Skip to content

Commit

Permalink
Merge pull request #335 from gdsfactory/add_siepic_verification
Browse files Browse the repository at this point in the history
add verification
  • Loading branch information
joamatab authored Feb 19, 2024
2 parents ecf237b + e91bf67 commit 14142c2
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ classifiers = [
]
dependencies = [
"gdsfactory[cad]==7.8.18",
"gplugins[tidy3d,sax,schematic]>=0.8.4,<0.9.0"
"gplugins[tidy3d,sax,schematic]>=0.8.4,<0.9.0",
'siepic==0.5.3'
]
description = "ubcpdk pdk"
keywords = ["python"]
Expand Down
22 changes: 22 additions & 0 deletions tests/test_verification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Test functional verification of simple layouts """
import os

import gdsfactory as gf

import ubcpdk.components as uc
from ubcpdk.verification import layout_check


def test_verification_import_gds():
file_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)), "tests/mmi2x2.oas"
)
c = gf.import_gds(file_path)
layout_check(c)


def test_verification_mzi():
splitter = uc.ebeam_y_1550(decorator=gf.port.auto_rename_ports)
mzi = gf.components.mzi(splitter=splitter)
c = uc.add_fiber_array(component=mzi)
layout_check(c)
Binary file added tests/tests/mmi2x2.oas
Binary file not shown.
58 changes: 58 additions & 0 deletions ubcpdk/verification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from pathlib import Path

import gdsfactory
import klayout.db as kdb
import pya
import SiEPIC
import SiEPIC.verification
from SiEPIC.utils import get_technology_by_name, klive

from ubcpdk.config import PATH


def layout_check(
component: gdsfactory.Component,
klayout_tech_path: str | Path | None = PATH.lyt,
show_klive: bool = False,
) -> int:
"""Run a layout check using SiEPIC-Tool's functional verification.
Args:
component: gdsfactory component.
klayout_tech_path: path to the klayout technology folder.
show_klive: show results in KLayout.
"""

gdspath = component.write_gds()

# load in KLayout database
ly = pya.Layout()

# load SiEPIC technology
tech = kdb.Technology()
tech.load(str(klayout_tech_path))
tech.create_technology("UBCPDK")
ly.TECHNOLOGY = get_technology_by_name("UBCPDK")

ly.read(str(gdspath))
if len(ly.top_cells()) != 1:
raise ValueError("Layout can only have one top cell")
topcell = ly.top_cell()

# perform verification
file_lyrdb = str(gdspath) + ".lyrdb"
num_errors = SiEPIC.verification.layout_check(cell=topcell, file_rdb=file_lyrdb)

if show_klive:
klive.show(gdspath, lyrdb_filename=file_lyrdb)

return num_errors


if __name__ == "__main__":
import gdsfactory as gf

file_path = PATH.repo / "tests" / "tests" / "mmi2x2.oas"
c = gf.import_gds(file_path, read_metadata=True)

layout_check(c)

0 comments on commit 14142c2

Please sign in to comment.