-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #335 from gdsfactory/add_siepic_verification
add verification
- Loading branch information
Showing
4 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |