diff --git a/cspdk/__init__.py b/cspdk/__init__.py index a9f96ff..4ee87eb 100644 --- a/cspdk/__init__.py +++ b/cspdk/__init__.py @@ -6,8 +6,7 @@ from cspdk.cells import _bend, _straight, _taper from cspdk.config import PATH from cspdk.models import get_models -from cspdk.routing import get_routing_strategies -from cspdk.tech import LAYER, LAYER_STACK, LAYER_VIEWS +from cspdk.tech import LAYER, LAYER_STACK, LAYER_VIEWS, routing_strategies _models = get_models() _cells = get_cells(cells) @@ -19,7 +18,6 @@ } ) _cross_sections = get_cross_sections(tech) -_routing_strategies = get_routing_strategies() PDK = Pdk( name="cornerstone", cells=_cells, @@ -28,7 +26,7 @@ layer_stack=LAYER_STACK, layer_views=LAYER_VIEWS, models=_models, - routing_strategies=_routing_strategies, + routing_strategies=routing_strategies, ) PDK.activate() diff --git a/cspdk/cells.py b/cspdk/cells.py index 8455b06..0dc47b7 100644 --- a/cspdk/cells.py +++ b/cspdk/cells.py @@ -1364,6 +1364,9 @@ def crossing_sc() -> gf.Component: return c +array = gf.components.array + + if __name__ == "__main__": # c = die_sc() c = crossing_sc() diff --git a/cspdk/routing.py b/cspdk/routing.py deleted file mode 100644 index 09ac61a..0000000 --- a/cspdk/routing.py +++ /dev/null @@ -1,86 +0,0 @@ -from functools import partial - -from gdsfactory.routing import get_route -from gdsfactory.routing.factories import routing_strategy - -from cspdk import cells -from cspdk.cells import _bend, _straight, _taper, wire_corner - - -def get_routing_strategies(): - return { - **get_routing_strategies_for_cross_section(""), - **get_routing_strategies_for_cross_section("xs_sc"), - **get_routing_strategies_for_cross_section("xs_so"), - **get_routing_strategies_for_cross_section("xs_rc"), - **get_routing_strategies_for_cross_section("xs_ro"), - **get_routing_strategies_for_cross_section("xs_nc"), - **get_routing_strategies_for_cross_section("xs_no"), - } - - -def get_routing_strategies_for_cross_section(cross_section): - suffix = "" - if "_" in cross_section: - suffix = f"_{cross_section.split('_')[-1]}" - else: - cross_section = "xs_sc" - straight = getattr(cells, f"straight{suffix}", _straight) - bend = getattr(cells, f"bend{suffix}", _bend) - taper = getattr(cells, f"taper{suffix}", _taper) - return { - f"get_bundle{suffix}": partial( - routing_strategy["get_bundle"], - straight=straight, - bend=bend, - cross_section=cross_section, - ), - f"get_bundle_electrical{suffix}": partial( - routing_strategy["get_bundle_electrical"], - straight=straight, - bend=wire_corner, - cross_section=cross_section, - ), - f"get_bundle_path_length_match{suffix}": partial( - routing_strategy["get_bundle_path_length_match"], - straight=straight, - bend=bend, - taper=taper, - cross_section=cross_section, - ), - f"get_bundle_same_axis_no_grouping{suffix}": partial( - routing_strategy["get_bundle_same_axis_no_grouping"], - taper=taper, - route_filter=partial( - get_route, - bend=bend, - straight=straight, - ), - cross_section=cross_section, - ), - f"get_bundle_from_waypoints{suffix}": partial( - routing_strategy["get_bundle_from_waypoints"], - straight=straight, - taper=taper, - bend=bend, - cross_section=cross_section, - ), - f"get_bundle_from_steps{suffix}": partial( - routing_strategy["get_bundle_from_steps"], - straight=straight, - taper=taper, - bend=bend, - cross_section=cross_section, - ), - f"get_bundle_from_steps_electrical{suffix}": partial( - routing_strategy["get_bundle_from_steps_electrical"], - straight=straight, - taper=taper, - bend=wire_corner, - cross_section=cross_section, - ), - } - - -if __name__ == "__main__": - print(get_routing_strategies()["get_bundle"]) diff --git a/cspdk/samples/get_route.py b/cspdk/samples/get_route.py new file mode 100644 index 0000000..0473a92 --- /dev/null +++ b/cspdk/samples/get_route.py @@ -0,0 +1,18 @@ +"""`get_route` returns a Manhattan route between two ports. """ + +import gdsfactory as gf + +import cspdk + +if __name__ == "__main__": + c = gf.Component("sample_connect") + mmi1 = c << cspdk.cells.mmi1x2_nc() + mmi2 = c << cspdk.cells.mmi1x2_nc() + mmi2.move((500, 50)) + + route = cspdk.tech.get_route_nc( + mmi1.ports["o3"], + mmi2.ports["o1"], + ) + c.add(route.references) + c.show() diff --git a/cspdk/tech.py b/cspdk/tech.py index 23bd4be..9f419aa 100644 --- a/cspdk/tech.py +++ b/cspdk/tech.py @@ -178,6 +178,59 @@ def get_layer_stack( cross_sections = get_cross_sections(sys.modules[__name__]) +############################ +# Routing functions +############################ + +_settings_sc = dict( + straight="straight_sc", cross_section=xs_sc, bend="bend_sc", taper="taper_sc" +) +_settings_so = dict( + straight="straight_so", cross_section=xs_so, bend="bend_so", taper="taper_so" +) +_settings_rc = dict( + straight="straight_rc", cross_section=xs_rc, bend="bend_rc", taper="taper_rc" +) +_settings_ro = dict( + straight="straight_ro", cross_section=xs_ro, bend="bend_ro", taper="taper_ro" +) +_settings_nc = dict( + straight="straight_nc", cross_section=xs_nc, bend="bend_nc", taper="taper_nc" +) +_settings_no = dict( + straight="straight_no", cross_section=xs_no, bend="bend_no", taper="taper_no" +) + + +get_route_sc = partial(gf.routing.get_route, **_settings_sc) +get_route_so = partial(gf.routing.get_route, **_settings_so) +get_route_rc = partial(gf.routing.get_route, **_settings_rc) +get_route_ro = partial(gf.routing.get_route, **_settings_ro) +get_route_nc = partial(gf.routing.get_route, **_settings_nc) +get_route_no = partial(gf.routing.get_route, **_settings_no) + +get_bundle_sc = partial(gf.routing.get_bundle, **_settings_sc) +get_bundle_so = partial(gf.routing.get_bundle, **_settings_so) +get_bundle_rc = partial(gf.routing.get_bundle, **_settings_rc) +get_bundle_ro = partial(gf.routing.get_bundle, **_settings_ro) +get_bundle_nc = partial(gf.routing.get_bundle, **_settings_nc) +get_bundle_no = partial(gf.routing.get_bundle, **_settings_no) + + +routing_strategies = dict( + get_route_sc=get_route_sc, + get_route_so=get_route_so, + get_route_rc=get_route_rc, + get_route_ro=get_route_ro, + get_route_nc=get_route_nc, + get_route_no=get_route_no, + get_bundle_sc=get_bundle_sc, + get_bundle_so=get_bundle_so, + get_bundle_rc=get_bundle_rc, + get_bundle_ro=get_bundle_ro, + get_bundle_nc=get_bundle_nc, +) + if __name__ == "__main__": from gdsfactory.technology.klayout_tech import KLayoutTechnology diff --git a/tests/gds_ref/array.gds b/tests/gds_ref/array.gds new file mode 100644 index 0000000..fb52ed8 Binary files /dev/null and b/tests/gds_ref/array.gds differ diff --git a/tests/test_netlists/test_netlists_array_.yml b/tests/test_netlists/test_netlists_array_.yml new file mode 100644 index 0000000..6d301e6 --- /dev/null +++ b/tests/test_netlists/test_netlists_array_.yml @@ -0,0 +1,197 @@ +connections: {} +instances: + pad_1__1_1: + component: pad + info: + layer: + - 41 + - 0 + size: + - 100.0 + - 100.0 + xsize: 100.0 + ysize: 100.0 + settings: + bbox_layers: null + bbox_offsets: null + layer: + - 41 + - 0 + port_inclusion: 0.0 + port_orientation: null + size: + - 100.0 + - 100.0 + pad_1__1_2: + component: pad + info: + layer: + - 41 + - 0 + size: + - 100.0 + - 100.0 + xsize: 100.0 + ysize: 100.0 + settings: + bbox_layers: null + bbox_offsets: null + layer: + - 41 + - 0 + port_inclusion: 0.0 + port_orientation: null + size: + - 100.0 + - 100.0 + pad_1__1_3: + component: pad + info: + layer: + - 41 + - 0 + size: + - 100.0 + - 100.0 + xsize: 100.0 + ysize: 100.0 + settings: + bbox_layers: null + bbox_offsets: null + layer: + - 41 + - 0 + port_inclusion: 0.0 + port_orientation: null + size: + - 100.0 + - 100.0 + pad_1__1_4: + component: pad + info: + layer: + - 41 + - 0 + size: + - 100.0 + - 100.0 + xsize: 100.0 + ysize: 100.0 + settings: + bbox_layers: null + bbox_offsets: null + layer: + - 41 + - 0 + port_inclusion: 0.0 + port_orientation: null + size: + - 100.0 + - 100.0 + pad_1__1_5: + component: pad + info: + layer: + - 41 + - 0 + size: + - 100.0 + - 100.0 + xsize: 100.0 + ysize: 100.0 + settings: + bbox_layers: null + bbox_offsets: null + layer: + - 41 + - 0 + port_inclusion: 0.0 + port_orientation: null + size: + - 100.0 + - 100.0 + pad_1__1_6: + component: pad + info: + layer: + - 41 + - 0 + size: + - 100.0 + - 100.0 + xsize: 100.0 + ysize: 100.0 + settings: + bbox_layers: null + bbox_offsets: null + layer: + - 41 + - 0 + port_inclusion: 0.0 + port_orientation: null + size: + - 100.0 + - 100.0 +name: pad_array +placements: + pad_1__1_1: + mirror: 0 + rotation: 0 + x: 0.0 + y: 0.0 + pad_1__1_2: + mirror: 0 + rotation: 0 + x: 150.0 + y: 0.0 + pad_1__1_3: + mirror: 0 + rotation: 0 + x: 300.0 + y: 0.0 + pad_1__1_4: + mirror: 0 + rotation: 0 + x: 450.0 + y: 0.0 + pad_1__1_5: + mirror: 0 + rotation: 0 + x: 600.0 + y: 0.0 + pad_1__1_6: + mirror: 0 + rotation: 0 + x: 750.0 + y: 0.0 +ports: + e1_1_1: pad_1__1_1,e1 + e1_1_2: pad_1__1_2,e1 + e1_1_3: pad_1__1_3,e1 + e1_1_4: pad_1__1_4,e1 + e1_1_5: pad_1__1_5,e1 + e1_1_6: pad_1__1_6,e1 + e2_1_1: pad_1__1_1,e2 + e2_1_2: pad_1__1_2,e2 + e2_1_3: pad_1__1_3,e2 + e2_1_4: pad_1__1_4,e2 + e2_1_5: pad_1__1_5,e2 + e2_1_6: pad_1__1_6,e2 + e3_1_1: pad_1__1_1,e3 + e3_1_2: pad_1__1_2,e3 + e3_1_3: pad_1__1_3,e3 + e3_1_4: pad_1__1_4,e3 + e3_1_5: pad_1__1_5,e3 + e3_1_6: pad_1__1_6,e3 + e4_1_1: pad_1__1_1,e4 + e4_1_2: pad_1__1_2,e4 + e4_1_3: pad_1__1_3,e4 + e4_1_4: pad_1__1_4,e4 + e4_1_5: pad_1__1_5,e4 + e4_1_6: pad_1__1_6,e4 + pad_1_1: pad_1__1_1,pad + pad_1_2: pad_1__1_2,pad + pad_1_3: pad_1__1_3,pad + pad_1_4: pad_1__1_4,pad + pad_1_5: pad_1__1_5,pad + pad_1_6: pad_1__1_6,pad diff --git a/tests/test_pdk/test_settings_array_.yml b/tests/test_pdk/test_settings_array_.yml new file mode 100644 index 0000000..a3682d4 --- /dev/null +++ b/tests/test_pdk/test_settings_array_.yml @@ -0,0 +1,22 @@ +function: array +info: + layer: + - 41 + - 0 + size: + - 100.0 + - 100.0 + xsize: 100.0 + ysize: 100.0 +module: gdsfactory.components.array_component +name: pad_array +settings: + add_ports: true + centered: false + columns: 6 + component: pad + rows: 1 + size: null + spacing: + - 150.0 + - 150.0