drc_check
drc_check( source, rules, *, engine=None, args=None, variable_names=None, results_file=None, max_results=None, timeout=None, pre_export_function=None, top_level=None, show_progress=True,)Run a design rule check (DRC) on a layout.
For KLayout, the rules file is a DRC runset (.drc or .lydrc)
that calls source($gdsfile) and report("...", $resultsfile);
the results database is then read with KLayout’s own Python module,
so the executable must include Python, as the official builds do.
For Calibre, the rules file is an SVRF rule deck. Calibre runs a copy
of it whose LAYOUT PATH, LAYOUT SYSTEM, LAYOUT PRIMARY
(when the top cell is known), DRC RESULTS DATABASE and DRC SUMMARY REPORT (when the deck declares one) name the files of this
check; the deck itself is never edited.
Args
- source (Component | str | PathLike): Component to check, exported to GDSII with default settings, or path to a GDSII or OASIS file.
- rules (str | PathLike): Rules file for the engine.
- engine (str | None): Verification engine,
"klayout"or"calibre".Noneusesconfig.default_drc_lvs_engine, and when that is unset the first engine found (KLayout, then Calibre). - args (dict[str, object] | Sequence[str] | None): For KLayout, extra script variables for the rules file, passed as
-rd name=valuewithstr(value). For Calibre, extra command-line arguments, one per item, such as("-hier", "-turbo", "4"). - variable_names (dict[str, str] | None): Names of the file variables used by a KLayout runset when they differ from the defaults. Keys are
"gdsfile"and"resultsfile". - results_file (str | PathLike | None): Keep the engine’s native results database (
.lyrdbfor KLayout, ASCII.dbfor Calibre) at this path. - max_results (int | None): Load at most this many markers. A
RuntimeWarningreports when markers are left out. - timeout (float | None): Seconds allowed for each engine run;
TimeoutErrorwhen one exceeds it. - pre_export_function (Callable[[Component], object] | None): Called with a shallow copy of each component exported from
source, as inwrite_layout. - top_level (str | None): Top cell Calibre checks (its
LAYOUT PRIMARY).Noneuses the component’s name whensourceis a component, otherwise the deck’s own primary, or the layout’s top cell when the deck names none. Calibre only. - show_progress (bool): Show the phase and the elapsed time while the engine runs.
Returns
verification.DRCResults: Markers grouped by rule.
Raises
- RuntimeError: When the engine cannot run, or exits with a non-zero code: a runset that stops at an error leaves a results database holding the rules before it only. The verdict is
is_clean, never the exit code, so a KLayout runset must exit 0.
Note
KLayout is taken from config.klayout_executable when set, then
searched in PATH and in common install locations. Calibre is
taken from config.calibre_executable when set, then searched in
PATH, $CALIBRE_HOME/bin and $MGC_HOME/bin, and requires
a PhotonForge Photonic Canvas license.