一键导入
drc-eval-workflow
Use when running KLayout DRC evaluation pipelines — executing DRC rules against GDS test files, parsing results, and computing metrics.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when running KLayout DRC evaluation pipelines — executing DRC rules against GDS test files, parsing results, and computing metrics.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when writing, reading, or understanding KLayout DRC rules (.drc files). Provides KLayout Ruby DSL syntax, common DRC patterns, and reference lookup instructions.
Use when inspecting, reading, or modifying existing GDS layout files. Covers reading GDS with KLayout Python API, extracting geometry info, and GDS-to-text conversion.
Use when creating GDS layout files programmatically using KLayout's Python API (pya module). Covers cell creation, shape insertion, and file output.
| name | drc-eval-workflow |
| description | Use when running KLayout DRC evaluation pipelines — executing DRC rules against GDS test files, parsing results, and computing metrics. |
klayout -b -r rule.drc -rd input=test.gds -rd output=result.lyrdb
-b: Batch mode (no GUI)-r rule.drc: DRC rule file-rd input=...: Pass GDS input path as variable $input-rd output=...: Pass output path as variable $outputThe .lyrdb file is XML (KLayout Report Database). Parse it to extract violations:
import xml.etree.ElementTree as ET
def parse_lyrdb(lyrdb_path):
"""Parse KLayout RDB file and return violations by category."""
tree = ET.parse(lyrdb_path)
root = tree.getroot()
violations = {}
for cat in root.iter("category"):
name_el = cat.find("name")
if name_el is not None:
name = name_el.text
count = sum(1 for _ in cat.iter("value"))
violations[name] = count
return violations
def compute_f1(predictions, labels):
"""Compute F1 from binary predictions and labels.
predictions: dict of {filename: {category: violation_count}}
labels: dict of {filename: {category: 0_or_1}}
"""
tp = fp = fn = 0
for fname, cats in labels.items():
for cat, label in cats.items():
pred = 1 if predictions.get(fname, {}).get(cat, 0) > 0 else 0
if pred == 1 and label == 1:
tp += 1
elif pred == 1 and label == 0:
fp += 1
elif pred == 0 and label == 1:
fn += 1
precision = tp / (tp + fp) if (tp + fp) > 0 else 0
recall = tp / (tp + fn) if (tp + fn) > 0 else 0
f1 = 2 * precision * recall / (precision + recall) if (precision + recall) > 0 else 0
return {"f1": f1, "precision": precision, "recall": recall, "tp": tp, "fp": fp, "fn": fn}
For a quick validation of one DRC rule against one GDS file:
# Create temp output
TMPFILE=$(mktemp /tmp/drc_XXXXXX.lyrdb)
klayout -b -r my_rule.drc -rd input=test.gds -rd output=$TMPFILE
# Check if any violations found
grep -c "<value>" $TMPFILE # 0 = no violations