Skip to content

Commit

Permalink
improve drc docs and release cicd action
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab committed Oct 10, 2023
1 parent 349a416 commit 42cf276
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 37 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,26 @@ jobs:
make build
twine upload dist/*
release_environment:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
strategy:
max-parallel: 12
matrix:
python-version: ["3.10"]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: '3.11'
cache: "pip"
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
make install
pip freeze > requirements.txt
- name: Release
uses: softprops/action-gh-release@v1
with:
fail_on_unmatched_files: false
files: |
requirements.txt
- name: Publish Latest Draft
run: |
gh release edit ${{ github.ref_name }} --draft=false
gh release upload ${{ github.ref_name }} requirements.txt --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78 changes: 54 additions & 24 deletions gplugins/klayout/drc/write_drc.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def new_layers(**kwargs) -> str:
return "\n".join([f"{name} = input{layer}" for name, layer in kwargs.items()])


def size(layer: str, dbu: int, layer_out: str | None = None) -> str:
"""Returns a string with the sizing operation of a layer by dbu."""
def size(layer: str, value: int | float, layer_out: str | None = None) -> str:
"""Returns a string with the sizing operation of a layer by value."""
layer_out = layer_out or layer
return f"{layer_out} = {layer}.size({dbu})"
return f"{layer_out} = {layer}.size({value})"


def layer_or(layer_out: str, layer1: str, layer2: str) -> str:
Expand All @@ -90,8 +90,13 @@ def check_not_inside(layer: str, not_inside: str) -> str:
return f"{layer}.not_inside({not_inside})" f".output({error!r}, {error!r})"


def check_width(value: float, layer: str, angle_limit: float = 90) -> str:
"""Min feature size."""
def check_width(value: float | int, layer: str, angle_limit: float = 90.0) -> str:
"""Min feature size.
Args:
value: width in um if float, dbu if int (nm).
angle_limit: angle limit in degrees.
"""
category = "width"
error = f"{layer} {category} {value}um"
return (
Expand All @@ -100,8 +105,13 @@ def check_width(value: float, layer: str, angle_limit: float = 90) -> str:
)


def check_space(value: float, layer: str, angle_limit: float = 90) -> str:
"""Min Space between shapes of layer."""
def check_space(value: float | int, layer: str, angle_limit: float = 90.0) -> str:
"""Min Space between shapes of layer.
Args:
value: width in um if float, dbu if int (nm).
angle_limit: angle limit in degrees.
"""
category = "space"
error = f"{layer} {category} {value}um"
return (
Expand All @@ -110,25 +120,45 @@ def check_space(value: float, layer: str, angle_limit: float = 90) -> str:
)


def check_separation(value: float, layer1: str, layer2: str) -> str:
"""Min space between different layers."""
def check_separation(value: float | int, layer1: str, layer2: str) -> str:
"""Min space between different layers.
Args:
value: width in um if float, dbu if int (nm).
layer1: layer name.
layer2: layer name.
"""
error = f"min {layer1} {layer2} separation {value}um"
return f"{layer1}.separation({layer2}, {value}).output({error!r}, {error!r})"


def check_enclosing(
value: float, layer1: str, layer2: str, angle_limit: float = 90
value: float | int, layer1: str, layer2: str, angle_limit: float = 90.0
) -> str:
"""Checks if layer1 encloses (is bigger than) layer2 by value."""
"""Checks if layer1 encloses (is bigger than) layer2 by value.
Args:
value: width in um if float, dbu if int (nm).
layer1: layer name.
layer2: layer name.
angle_limit: angle limit in degrees.
"""
error = f"{layer1} enclosing {layer2} by {value}um"
return (
f"{layer1}.enclosing({layer2}, angle_limit({angle_limit}), {value})"
f".output({error!r}, {error!r})"
)


def check_area(layer: str, min_area_um2: float = 2.0) -> str:
"""Return script for min area checking."""
def check_area(layer: str, min_area_um2: float | int = 2.0) -> str:
"""Return script for min area checking.
Args:
layer1: layer name.
min_area_um2: min area in um2. int if dbu, float if um.
"""
return f"""
min_{layer}_a = {min_area_um2}.um2
Expand All @@ -140,8 +170,8 @@ def check_area(layer: str, min_area_um2: float = 2.0) -> str:
def check_density(
layer: str = "metal1",
layer_floorplan: str = "FLOORPLAN",
min_density=0.2,
max_density=0.8,
min_density: float = 0.2,
max_density: float = 0.8,
) -> str:
"""Return script to ensure density of layer is within min and max.
Expand Down Expand Up @@ -369,18 +399,18 @@ def write_drc_deck_macro(
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_not_inside(layer="VIAC", not_inside="NPP"),
new_layers(TRENCHES=(2, 33)),
size(layer="WG", dbu=1000),
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_not_inside(layer="VIAC", not_inside="NPP"),
# new_layers(TRENCHES=(2, 33)),
# size(layer="WG", dbu=1000),
]

layers = dict(LAYER)
layers["WG_PIN"] = (1, 10)
# drc_check_deck = write_drc_deck_macro(rules=rules, layers=layers, mode="tiled")
drc_check_deck = write_drc_deck_macro(rules=rules, layers=layers, mode="tiled")
script = get_drc_script(rules=rules, layers=layers, mode="tiled")
print(script)

0 comments on commit 42cf276

Please sign in to comment.