Klayout integration#

gdsfactory is a pure driven python flow where you define your components, circuits and masks in python or YAML code.

For rapid iteration, gdsfactory comes with a Klayout macro klive that runs inside klayout, so that when you run component.show() in python, it displays your GDS in Klayout.

workflow

You have 2 ways to install the klayout gdsfactory plugin to be able to see live updates on your GDS files:

  • from the terminal by typing gf tool install after installing gdsfactory pip install gdsfactory

  • using klayout package manager (see image below), Tools –> Manage Packages

klayout package

What does the klayout integration installs?

  • Klive: connects python to klayout, to show GDS files directly, when running component.show()

  • generic layermap: for the generic gdsfactory technology.

  • generic DRC: for generic gdsfactory technology

Klayout DRC#

You can write DRC rule decks from gdsfactory and customize the shortcut to run the DRC macro in Klayout.

[1]:
import gdsfactory as gf
from gdsfactory.geometry.write_drc import (
    write_drc_deck_macro,
    rule_enclosing,
    rule_width,
    rule_space,
    rule_separation,
)
2022-06-28 17:02:49.767 | INFO     | gdsfactory.config:<module>:52 - Load '/home/runner/work/gdsfactory/gdsfactory/gdsfactory' 5.11.4
[2]:
help(write_drc_deck_macro)
Help on function write_drc_deck_macro in module gdsfactory.geometry.write_drc:

write_drc_deck_macro(name: str = 'generic', filepath: Union[str, pathlib.Path, NoneType] = None, shortcut: str = 'Ctrl+Shift+D', **kwargs) -> str
    Write klayout DRC macro.
    You can customize the shortcut to run the DRC macro from the Klayout GUI.

    Args:
        name: drc rule deck name
        filepath: Optional macro path (defaults to .klayout/drc/name.lydrc)
        shortcut: to run macro from klayout GUI

    Keyword Args:
        rules: list of rules
        layer_map: layer definitions can be dict or dataclass

    Keyword Args:
        rules: list of rules
        layer_map: layer definitions can be dict or dataclass

[3]:
rules = [
    rule_width(layer="WG", value=0.2),
    rule_space(layer="WG", value=0.2),
    rule_width(layer="M1", value=1),
    rule_width(layer="M2", value=2),
    rule_space(layer="M2", value=2),
    rule_separation(layer1="HEATER", layer2="M1", value=1.0),
    rule_enclosing(layer1="M1", layer2="VIAC", value=0.2),
]

drc_rule_deck = write_drc_deck_macro(
    rules=rules,
    layer_map=gf.LAYER,
    shortcut="Ctrl+Shift+D",
)
2022-06-28 17:02:50.635 | INFO     | gdsfactory.geometry.write_drc:write_drc_deck_macro:159 - Wrote DRC deck to '/home/runner/.klayout/drc/generic.lydrc' with shortcut 'Ctrl+Shift+D'

Klayout connectivity checks#

Thanks to SiEPIC-Tools klayout macro gdsfactory supports component overlap and connectivity checks.

This is enabled by default for any components that use the strip cross_section, thanks to having add_pins=add_pins_siepic and add_bbox=add_bbox_siepic by default.

Siepic