gplugins.klayout.drc.write_drc.write_drc_deck_macro

gplugins.klayout.drc.write_drc.write_drc_deck_macro#

gplugins.klayout.drc.write_drc.write_drc_deck_macro(rules: list[str], layers: dict[str, tuple[int, int]] | None = None, name: str = 'generic', filepath: str | Path | None = None, shortcut: str = 'Ctrl+Shift+D', mode: str = 'tiled', threads: int = 4, tile_size: int = 500, tile_borders: int | None = None) str[source]#

Write KLayout DRC macro.

You can customize the shortcut to run the DRC macro from the Klayout GUI.

Parameters:
  • rules – list of rules.

  • layers – layer definitions can be dict or dataclass.

  • name – drc rule deck name.

  • filepath – Optional macro path (defaults to .klayout/drc/name.lydrc).

  • shortcut – to run macro from KLayout GUI.

  • mode – tiled, default or deep (hierarchical).

  • threads – number of threads.

  • tile_size – in um for tile mode.

  • tile_borders – sides for each. Defaults None to automatic.

import gdsfactory as gf
from gplugins.klayout.drc.write_drc import (
    write_drc_deck_macro,
    check_enclosing,
    check_width,
    check_space,
    check_separation,
    check_area,
    check_density,
)
from gdsfactory.generic_tech import LAYER
rules = [
    check_width(layer="WG", value=0.2),
    check_space(layer="WG", value=0.2),
    check_separation(layer1="HEATER", layer2="M1", value=1.0),
    check_enclosing(layer1="VIAC", layer2="M1", value=0.2),
    check_area(layer="WG", min_area_um2=0.05),
    check_density(
        layer="WG", layer_floorplan="FLOORPLAN", min_density=0.5, max_density=0.6
    ),
    check_not_inside(layer="VIAC", not_inside="NPP"),
]

drc_check_deck = write_drc_deck_macro(rules=rules, layers=LAYER, mode="tiled")
print(drc_check_deck)