Skip to content

Commit

Permalink
simplify routing
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab committed Apr 17, 2024
1 parent 93f6903 commit fc97d06
Show file tree
Hide file tree
Showing 8 changed files with 295 additions and 90 deletions.
6 changes: 2 additions & 4 deletions cspdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -19,7 +18,6 @@
}
)
_cross_sections = get_cross_sections(tech)
_routing_strategies = get_routing_strategies()
PDK = Pdk(
name="cornerstone",
cells=_cells,
Expand All @@ -28,7 +26,7 @@
layer_stack=LAYER_STACK,
layer_views=LAYER_VIEWS,
models=_models,
routing_strategies=_routing_strategies,
routing_strategies=routing_strategies,
)
PDK.activate()

Expand Down
3 changes: 3 additions & 0 deletions cspdk/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,9 @@ def crossing_sc() -> gf.Component:
return c


array = gf.components.array


if __name__ == "__main__":
# c = die_sc()
c = crossing_sc()
Expand Down
86 changes: 0 additions & 86 deletions cspdk/routing.py

This file was deleted.

18 changes: 18 additions & 0 deletions cspdk/samples/get_route.py
Original file line number Diff line number Diff line change
@@ -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()
53 changes: 53 additions & 0 deletions cspdk/tech.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added tests/gds_ref/array.gds
Binary file not shown.
Loading

0 comments on commit fc97d06

Please sign in to comment.