Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add verification #335

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading