drc_check

photonforge.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 source is a component), DRC RESULTS DATABASE and DRC SUMMARY REPORT (when the deck declares one) name the files of this check; the deck itself is never edited.

Parameters:
  • 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". None uses config.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=value with str(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 (.lyrdb for KLayout, ASCII .db for Calibre) at this path.

  • max_results (int | None) – Load at most this many markers. A RuntimeWarning reports when markers are left out.

  • timeout (float | None) – Seconds allowed for each engine run; TimeoutError when one exceeds it.

  • pre_export_function (Callable[[Component], object] | None) – Called with a shallow copy of each component exported from source, as in write_layout().

  • top_level (str | None) – Top cell Calibre checks (its LAYOUT PRIMARY). None uses the component’s name when source is 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:

Markers grouped by rule.

Return type:

photonforge.verification.DRCResults

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.