Updated 4 min readEDA Scripting
Automating EDA tool config with Python
Generate EDA tool setup files from a YAML manifest with Python and Jinja2: an MMMC example, pre-flight checks, log scanning for fatal message IDs, versioning.
By the SkyCadEda engineering teamHow these notes are written
On this page
Keep the intent of a run (design, corners, modes, tool versions) in a small YAML manifest, let Python validate it and derive anything that follows from it, and render the tool's native setup files from Jinja2 templates. After the run, scan the log for the message IDs your team treats as fatal instead of trusting the exit code. Version the manifests and generators, and archive the rendered files that a signoff run actually used.
Three layers
A configuration wrapper stays maintainable when it has three separate parts:
- Input: a YAML or JSON manifest that says what to run, not how. Corners, modes, library sets, file paths, tool versions.
- Logic: Python that validates the manifest, checks that every referenced file exists, and derives values (for example which libraries and RC tech files belong to a named corner).
- Generation: templates that know the tool's syntax and nothing else. When a tool version changes syntax, only a template changes.
The rendered files stay in the tool's native format, so an engineer can read them and run them by hand when debugging.
Example: MMMC setup from a manifest
Multi-mode multi-corner setup for Innovus or Tempus is a good first target: it is repetitive, easy to get subtly wrong, and every block needs it. The manifest:
# corners.yaml
design: top
sdc:
func: constraints/top_func.sdc
library_sets:
ss_0p72v_125c: [lib/std_ss_0p72v_125c.lib]
ff_0p88v_m40c: [lib/std_ff_0p88v_m40c.lib]
rc_corners:
cworst_125: {qrc: tech/cworst.tch, temp: 125}
cbest_m40: {qrc: tech/cbest.tch, temp: -40}
views:
- {name: func_ss_cw, mode: func,
lib: ss_0p72v_125c, rc: cworst_125, check: setup}
- {name: func_ff_cb, mode: func,
lib: ff_0p88v_m40c, rc: cbest_m40, check: hold}The template renders the MMMC commands in the classic (non-Stylus) Innovus/Tempus syntax. Option names are exactly the kind of detail that differs between releases and command interfaces, so check them against the MMMC reference for the version you run; that is also why they live in a template rather than in the Python:
# mmmc.tcl.j2
{% for name, libs in library_sets.items() %}
create_library_set -name {{ name }} \
-timing { {{ libs | join(" ") }} }
{% endfor %}
{% for name, rc in rc_corners.items() %}
create_rc_corner -name {{ name }} \
-qx_tech_file {{ rc.qrc }} \
-temperature {{ rc.temp }}
{% endfor %}
{% for mode, f in sdc.items() %}
create_constraint_mode -name {{ mode }} \
-sdc_files { {{ f }} }
{% endfor %}
{% for v in views %}
create_delay_corner -name {{ v.name }}_dc \
-library_set {{ v.lib }} -rc_corner {{ v.rc }}
create_analysis_view -name {{ v.name }} \
-constraint_mode {{ v.mode }} \
-delay_corner {{ v.name }}_dc
{% endfor %}
set_analysis_view \
-setup { {% for v in views if v.check == "setup" %}{{ v.name }} {% endfor %}} \
-hold { {% for v in views if v.check == "hold" %}{{ v.name }} {% endfor %}}And the generator, with pre-flight checks that fail before the tool spends an hour loading the design:
import sys
from pathlib import Path
import yaml
from jinja2 import Environment, FileSystemLoader
from jinja2 import StrictUndefined
cfg = yaml.safe_load(Path("corners.yaml").read_text())
errors = []
for name, libs in cfg["library_sets"].items():
errors += [f"{name}: missing {p}"
for p in libs if not Path(p).is_file()]
for name, rc in cfg["rc_corners"].items():
if not Path(rc["qrc"]).is_file():
errors.append(f"{name}: missing {rc['qrc']}")
for v in cfg["views"]:
if v["lib"] not in cfg["library_sets"]:
errors.append(f"{v['name']}: unknown lib {v['lib']}")
if v["rc"] not in cfg["rc_corners"]:
errors.append(f"{v['name']}: unknown rc {v['rc']}")
if errors:
sys.exit("\n".join(errors))
env = Environment(loader=FileSystemLoader("templates"),
undefined=StrictUndefined,
trim_blocks=True, lstrip_blocks=True)
out = env.get_template("mmmc.tcl.j2").render(**cfg)
Path("run/mmmc.tcl").write_text(out)StrictUndefined matters: without it, a typo in a template variable renders as an empty string and the tool gets a silently incomplete command.
Post-flight: scan for fatal message IDs
A tool can exit 0 after ignoring a constraint, failing to find a library cell, or skipping an object it could not parse. Exit codes are not enough. ASIC tools tag messages with severities and IDs (Innovus prints lines like **WARN: (IMPXXX-123): ..., PrimeTime prints Warning: ... (XXX-123)), so keep a list of IDs your team has decided are fatal and fail the run when one appears:
import re
MSG = re.compile(r"\*\*(ERROR|WARN): \((\w+-\d+)\)")
def fatal_hits(log_path, fatal_ids):
hits = []
with open(log_path, errors="replace") as f:
for n, line in enumerate(f, 1):
m = MSG.search(line)
if m and (m.group(1) == "ERROR"
or m.group(2) in fatal_ids):
hits.append((n, line.rstrip()))
return hitsBuild the fatal list from your own triage history: unresolved cells, ignored SDC commands, missing parasitics. Keep it in the manifest repository so additions are reviewed like code.
Scaling to the farm
Generate the configuration once, centrally, and point every job at the rendered files on shared storage, instead of letting each farm node regenerate them with whatever environment it happens to have. The wrapper can also set LSF or Slurm resource requests from the manifest, for example more memory and cores for a full-chip extraction than for a block STA run, which avoids jobs killed for running out of memory.
What to version
Version the generators and templates in a repository with tests that render a set of golden manifests and diff the output. Check the manifests into the design repository next to the data they describe. Do not commit every rendered file, which only makes noisy diffs, but do archive the exact rendered files and tool versions used for any signoff run, so the run can be reproduced after the generator has moved on.
Frequently asked questions
Why use Python rather than Tcl for orchestration?
Tcl stays inside the tools, where it is the native command language. Python is better outside them: YAML and JSON parsing, schema validation, templating with Jinja2, subprocess control, job scheduler and CI integration. A common split is Python generating and launching, Tcl executing inside the tool.
How do I validate generated config without running the tool?
Validate the input manifest against a schema (for example with Pydantic or jsonschema), check that every referenced file exists, render templates with undefined variables treated as errors, and keep golden rendered outputs under test so any change to a template shows up as a diff.
Related reading
- noteTool-agnostic Python wrappers for EDA
- noteDefensive Python for EDA pipelines
- noteEDA tool environment versioning
- serviceEDA automation services
More engineering notes
Working through a problem like this?
Tell us about your flow: the tools, the PDK, what is failing and when it needs to be clean.