diff --git a/coupler_G0p2_L10_D5_D5_W0p5_LWG_E8a9ff7cf.gds b/coupler_G0p2_L10_D5_D5_W0p5_LWG_E8a9ff7cf.gds new file mode 100644 index 0000000..c833505 Binary files /dev/null and b/coupler_G0p2_L10_D5_D5_W0p5_LWG_E8a9ff7cf.gds differ diff --git a/kgeneric/__init__.py b/kgeneric/__init__.py index 52f8857..d69dc81 100644 --- a/kgeneric/__init__.py +++ b/kgeneric/__init__.py @@ -1,14 +1,17 @@ """kgeneric - KLayout extras for KCells, PDK and generic_tech""" __version__ = "0.0.2" -from kfactory.pdk import Pdk, get_cells + +import kfactory as kf +from kfactory.kcell import get_cells from kgeneric import cells, gpdk, layers from kgeneric.layers import LAYER from kgeneric.tech import TECH -cells_dict = get_cells([gpdk]) -pdk = Pdk(name="generic", cell_factories=cells_dict, layers=LAYER) +cells_dict = get_cells([cells]) + +kf.kcl.factories.update(cells_dict) -__all__ = ("pdk", "gpdk", "cells", "layers", "TECH") +__all__ = ("gpdk", "cells", "layers", "TECH", "LAYER") diff --git a/kgeneric/cells/bezier.py b/kgeneric/cells/bezier.py index 44333c4..75a1cea 100644 --- a/kgeneric/cells/bezier.py +++ b/kgeneric/cells/bezier.py @@ -5,7 +5,7 @@ import numpy as np import numpy.typing as nty from kfactory import KCell, LayerEnum, cell, kdb -from kfactory.utils.enclosure import LayerEnclosure, extrude_path +from kfactory.enclosure import LayerEnclosure, extrude_path from scipy.special import binom # type: ignore[import] __all__ = ["bend_s"] @@ -91,10 +91,11 @@ def bend_s( if __name__ == "__main__": - from kgeneric import pdk - from kgeneric.pdk import LAYER + import kfactory as kf - um = 1 / pdk.kcl.dbu + from kgeneric import LAYER + + um = 1 / kf.kcl.dbu enclosure = LayerEnclosure( [ (LAYER.DEEPTRENCH, 2 * um, 3 * um), diff --git a/kgeneric/cells/circular.py b/kgeneric/cells/circular.py index db48515..8f10ab6 100644 --- a/kgeneric/cells/circular.py +++ b/kgeneric/cells/circular.py @@ -5,8 +5,8 @@ import numpy as np from kfactory import kdb +from kfactory.enclosure import LayerEnclosure, extrude_path from kfactory.kcell import KCell, LayerEnum, cell -from kfactory.utils.enclosure import LayerEnclosure, extrude_path __all__ = ["bend_circular"] @@ -26,7 +26,7 @@ def bend_circular( width: Width of the core. [um] radius: Radius of the backbone. [um] layer: Layer index of the target layer. - enclosure: :py:class:`kfactory.utils.Enclosure` object to describe the + enclosure: :py:class:`kfactory.enclosure` object to describe the claddings. angle: Angle amount of the bend. angle_step: Angle amount per backbone point of the bend. @@ -69,7 +69,7 @@ def bend_circular( if __name__ == "__main__": - from kgeneric.pdk import LAYER + from kgeneric import LAYER c = bend_circular(width=1, radius=9, angle=9.0, layer=LAYER.WG) c.draw_ports() diff --git a/kgeneric/cells/coupler.py b/kgeneric/cells/coupler.py index 7189e1d..0e08d64 100644 --- a/kgeneric/cells/coupler.py +++ b/kgeneric/cells/coupler.py @@ -1,6 +1,6 @@ from kfactory import KCell, cell, kdb +from kfactory.enclosure import LayerEnclosure from kfactory.kcell import LayerEnum -from kfactory.utils.enclosure import LayerEnclosure from kgeneric.cells.bezier import bend_s from kgeneric.cells.straight import straight @@ -119,9 +119,9 @@ def straight_coupler( if __name__ == "__main__": - from kgeneric import pdk + import kfactory as kf - um = 1 / pdk.kcl.dbu + um = 1 / kf.kcl.dbu enclosure = LayerEnclosure( [ (LAYER.DEEPTRENCH, 2 * um, 3 * um), diff --git a/kgeneric/cells/dbu/straight.py b/kgeneric/cells/dbu/straight.py index 7faab12..249dc20 100644 --- a/kgeneric/cells/dbu/straight.py +++ b/kgeneric/cells/dbu/straight.py @@ -16,8 +16,8 @@ """ from kfactory import KCell, LayerEnum, cell, kdb +from kfactory.enclosure import LayerEnclosure from kfactory.kcell import Info -from kfactory.utils import LayerEnclosure __all__ = ["straight"] diff --git a/kgeneric/cells/dbu/taper.py b/kgeneric/cells/dbu/taper.py index d7533b5..ed6a8b2 100644 --- a/kgeneric/cells/dbu/taper.py +++ b/kgeneric/cells/dbu/taper.py @@ -4,7 +4,7 @@ """ from kfactory import KCell, cell, kdb -from kfactory.utils import LayerEnclosure +from kfactory.enclosure import LayerEnclosure __all__ = ["taper"] diff --git a/kgeneric/cells/euler.py b/kgeneric/cells/euler.py index e380cea..de2b328 100644 --- a/kgeneric/cells/euler.py +++ b/kgeneric/cells/euler.py @@ -7,8 +7,8 @@ import numpy as np from kfactory import kdb +from kfactory.enclosure import LayerEnclosure, extrude_path from kfactory.kcell import KCell, LayerEnum, cell -from kfactory.utils.enclosure import LayerEnclosure, extrude_path from scipy.optimize import brentq # type: ignore[import] from scipy.special import fresnel # type: ignore[import] @@ -267,7 +267,7 @@ def bend_s_euler( if __name__ == "__main__": - from kgeneric.pdk import LAYER + from kgeneric import LAYER c = bend_euler(width=1, radius=10, layer=LAYER.WG) c.draw_ports() diff --git a/kgeneric/cells/mzi.py b/kgeneric/cells/mzi.py index 2f2450d..f1f2c68 100644 --- a/kgeneric/cells/mzi.py +++ b/kgeneric/cells/mzi.py @@ -4,10 +4,10 @@ import kfactory as kf from kfactory import cell +from kfactory.enclosure import LayerEnclosure from kfactory.kcell import LayerEnum from kfactory.routing.optical import route from kfactory.typings import CellFactory -from kfactory.utils.enclosure import LayerEnclosure from kgeneric.cells.coupler import coupler from kgeneric.cells.dbu.straight import straight as straight_dbu diff --git a/kgeneric/cells/straight.py b/kgeneric/cells/straight.py index 8c24ff8..e6cbd9b 100644 --- a/kgeneric/cells/straight.py +++ b/kgeneric/cells/straight.py @@ -17,7 +17,7 @@ from kfactory import KCell, LayerEnum, kcl -from kfactory.utils import LayerEnclosure +from kfactory.enclosure import LayerEnclosure from kgeneric.cells.dbu.straight import straight as straight_dbu diff --git a/kgeneric/cells/taper.py b/kgeneric/cells/taper.py index c35a7bd..b4b2634 100644 --- a/kgeneric/cells/taper.py +++ b/kgeneric/cells/taper.py @@ -6,7 +6,7 @@ from kfactory import KCell, LayerEnum, kcl -from kfactory.utils import LayerEnclosure +from kfactory.enclosure import LayerEnclosure from kgeneric.cells.dbu.taper import taper as taper_dbu diff --git a/kgeneric/gpdk.py b/kgeneric/gpdk.py index d439744..30123b7 100644 --- a/kgeneric/gpdk.py +++ b/kgeneric/gpdk.py @@ -7,7 +7,7 @@ from kgeneric.layers import LAYER from kgeneric.tech import TECH -enclosure_sc = kf.utils.LayerEnclosure(name="WGSTD", sections=[(LAYER.WGCLAD, 0, 2000)]) +enclosure_sc = kf.LayerEnclosure(name="WGSTD", sections=[(LAYER.WGCLAD, 0, 2000)]) bend_s_sc = partial( cells.bend_s, diff --git a/kgeneric/layers.py b/kgeneric/layers.py index aa6363b..957ae7f 100644 --- a/kgeneric/layers.py +++ b/kgeneric/layers.py @@ -3,6 +3,7 @@ from typing import Any +import kfactory as kf from kfactory.kcell import LayerEnum from pydantic import BaseModel, Field @@ -17,6 +18,8 @@ class LAYER(LayerEnum): You will need to create a new LayerMap with your specific foundry layers. """ + kcl = kf.constant(kf.kcl) + WG = (1, 0) WAFER = (50, 0) WGCLAD = (111, 0) @@ -421,6 +424,8 @@ def get_layer_stack( ) +kf.kcl.layers = LAYER + LAYER_STACK = get_layer_stack() if __name__ == "__main__": diff --git a/tests/gds/gds_ref/mzi_DL10_LY2_LX0p1_Bbend_euler_Sstraight_SYNone_SXTNone_SXBNone_Scoupler_CNone_WSTrue_PESo3_PESo4_PECo1_W1_L0_R5_ENone.gds b/tests/gds/gds_ref/mzi_DL10_LY2_LX0p1_Bbend_euler_Sstraight_SYNone_SXTNone_SXBNone_Scoupler_CNone_WSTrue_PESo3_PESo4_PECo1_W1_L0_R5_ENone.gds new file mode 100644 index 0000000..c807e0f Binary files /dev/null and b/tests/gds/gds_ref/mzi_DL10_LY2_LX0p1_Bbend_euler_Sstraight_SYNone_SXTNone_SXBNone_Scoupler_CNone_WSTrue_PESo3_PESo4_PECo1_W1_L0_R5_ENone.gds differ diff --git a/tests/test_cells.py b/tests/test_cells.py index 79f8d12..fd64e61 100644 --- a/tests/test_cells.py +++ b/tests/test_cells.py @@ -33,7 +33,7 @@ def test_cells(cell_name: str) -> None: gds_ref.mkdir(parents=True, exist_ok=True) run_cell.write(str(ref_file)) raise FileNotFoundError(f"GDS file not found. Saving it to {ref_file}") - kcl_ref = kf.KCLayout() + kcl_ref = kf.KCLayout(cell_name) kcl_ref.read(gds_ref / f"{cell.name}.gds") ref_cell = kcl_ref[kcl_ref.top_cell().name]