Routing to IO#
Routing electrical#
For routing low speed DC electrical ports you can use sharp corners instead of smooth bends.
You can also define port.orientation = None
to ignore the port orientation for low speed DC ports.
For single route between ports you can use route_single_electrical
route_single_electrical#
route_single_electrical
has bend = wire_corner
with a 90deg bend corner.
import gdsfactory as gf
from gdsfactory.samples.big_device import big_device
gf.config.rich_output()
c = gf.Component()
pt = c << gf.components.pad_array(port_orientation=270, columns=3)
pb = c << gf.components.pad_array(port_orientation=90, columns=3)
pt.dmove((70, 200))
c.plot()
![../_images/92f2aeabe4d118d6894424ffea439395a410d8180f2c22e93f8e55ca878df6d3.png](../_images/92f2aeabe4d118d6894424ffea439395a410d8180f2c22e93f8e55ca878df6d3.png)
c = gf.Component()
pt = c << gf.components.pad_array(port_orientation=270, columns=3)
pb = c << gf.components.pad_array(port_orientation=90, columns=3)
pt.dmove((70, 200))
route = gf.routing.route_single_electrical(c, pt.ports["e11"], pb.ports["e11"])
c.plot()
![../_images/a0daa7f46d7601bfa1b617e02e147aecef2f8435d5eb45c7bd8e78ff8583155d.png](../_images/a0daa7f46d7601bfa1b617e02e147aecef2f8435d5eb45c7bd8e78ff8583155d.png)
There is also bend = wire_corner45
for 45deg bend corner with parametrizable “radius”:
c = gf.Component()
pt = c << gf.components.pad_array(port_orientation=270, columns=1)
pb = c << gf.components.pad_array(port_orientation=90, columns=1)
pt.dmove((300, 300))
route = gf.routing.route_single(
c,
pt.ports["e11"],
pb.ports["e11"],
bend="wire_corner45",
port_type="electrical",
taper=None,
cross_section="metal_routing",
allow_width_mismatch=True,
)
c.plot()
![../_images/7aa585b7c0fe7b7574760a762c6d1c65e37658fd245e413fc6afe58c01886e60.png](../_images/7aa585b7c0fe7b7574760a762c6d1c65e37658fd245e413fc6afe58c01886e60.png)
c = gf.Component()
pt = c << gf.components.pad_array(orientation=270, columns=1)
pb = c << gf.components.pad_array(orientation=90, columns=1)
pt.dmove((300, 300))
route = gf.routing.route_single(
c,
pt.ports["e11"],
pb.ports["e11"],
bend="wire_corner45",
radius=100,
taper=None,
cross_section="metal_routing",
port_type="electrical",
allow_width_mismatch=True,
)
c.plot()
/home/runner/work/gdsfactory/gdsfactory/gdsfactory/components/pad.py:101: UserWarning: orientation is deprecated, use port_orientation
warnings.warn("orientation is deprecated, use port_orientation")
![../_images/dd9112f80e64c488588b2ec4009f38314c854ae5c78d70b4ef82ea704ba3e315.png](../_images/dd9112f80e64c488588b2ec4009f38314c854ae5c78d70b4ef82ea704ba3e315.png)
route_quad#
c = gf.Component()
pt = c << gf.components.pad_array(orientation=270, columns=3)
pb = c << gf.components.pad_array(orientation=90, columns=3)
pt.dmove((100, 200))
gf.routing.route_quad(c, pt.ports["e11"], pb.ports["e11"], layer=(49, 0))
c.plot()
![../_images/39c91d7314424cc942ef633c43a31e86a4cf9fc79b4943038243d92ead377e93.png](../_images/39c91d7314424cc942ef633c43a31e86a4cf9fc79b4943038243d92ead377e93.png)
route_single_from_steps#
import gdsfactory as gf
c = gf.Component()
pt = c << gf.components.pad_array(orientation=270, columns=3)
pb = c << gf.components.pad_array(orientation=90, columns=3)
pt.dmove((100, 200))
route = gf.routing.route_single_from_steps(
c,
pb.ports["e11"],
pt.ports["e11"],
steps=[
{"y": 200},
],
cross_section="metal_routing",
bend=gf.components.wire_corner,
port_type="electrical",
allow_width_mismatch=True,
)
c.plot()
/home/runner/work/gdsfactory/gdsfactory/gdsfactory/pdk.py:399: UserWarning: {'radius': None} are ignored for cross_section 'xs_0efa6a61'
warnings.warn(
/home/runner/work/gdsfactory/gdsfactory/gdsfactory/pdk.py:399: UserWarning: {'width': 10.0} are ignored for cross_section 'xs_0efa6a61'
warnings.warn(
![../_images/ddf4ee5f100b3c42f8895a05f3d589875cdd4e2c95314e24071f90eb1872f37d.png](../_images/ddf4ee5f100b3c42f8895a05f3d589875cdd4e2c95314e24071f90eb1872f37d.png)
c = gf.Component()
pt = c << gf.components.pad_array(orientation=None, columns=3)
pb = c << gf.components.pad_array(orientation=None, columns=3)
pt.dmove((100, 200))
route = gf.routing.route_single_from_steps(
c,
pb.ports["e11"],
pt.ports["e11"],
steps=[
{"y": 200},
],
cross_section="metal_routing",
bend=gf.components.wire_corner,
port_type="electrical",
allow_width_mismatch=True,
)
c.plot()
![../_images/404c785fa59e7d3cd1a3d1c7e5622edbe0e7a3d46294603b50bd13eb75001626.png](../_images/404c785fa59e7d3cd1a3d1c7e5622edbe0e7a3d46294603b50bd13eb75001626.png)
route_bundle_electrical#
For routing groups of ports you can use route_bundle
that returns a bundle of routes using a bundle router (also known as bus or river router)
c = gf.Component()
pt = c << gf.components.pad_array(orientation=270, columns=3)
pb = c << gf.components.pad_array(orientation=90, columns=3)
pt.dmove((100, 200))
routes = gf.routing.route_bundle_electrical(
c, pb.ports, pt.ports, start_straight_length=30, separation=30
)
c.plot()
![../_images/e994fd3d33e466b161ca6f2954e9d7c0aa841ed5b3ca901cb0685c0f4952c436.png](../_images/e994fd3d33e466b161ca6f2954e9d7c0aa841ed5b3ca901cb0685c0f4952c436.png)
Routing to pads#
You can also route to electrical pads.
c = gf.components.straight_heater_metal(length=100.0)
cc = gf.routing.add_pads_bot(component=c, port_names=("l_e4", "r_e4"), fanout_length=80)
cc.plot()
![../_images/de203e4cac792ae0023597f158d6379df725c27a33047c231d62a7317c607553.png](../_images/de203e4cac792ae0023597f158d6379df725c27a33047c231d62a7317c607553.png)
c = gf.components.straight_heater_metal(length=100.0)
cc = gf.routing.add_pads_bot(component=c, port_names=("l_e4", "r_e4"), fanout_length=80)
cc.plot()
![../_images/de203e4cac792ae0023597f158d6379df725c27a33047c231d62a7317c607553.png](../_images/de203e4cac792ae0023597f158d6379df725c27a33047c231d62a7317c607553.png)
c = gf.components.straight_heater_metal(length=110)
cc = gf.routing.add_pads_top(component=c, port_names=("l_e2", "r_e2"), fanout_length=80)
cc.plot()
![../_images/ac34cb3e515a3f632fb43d58e698b21a26225bd09222407094a73b1e0e51421b.png](../_images/ac34cb3e515a3f632fb43d58e698b21a26225bd09222407094a73b1e0e51421b.png)
c = gf.c.nxn(
xsize=600,
ysize=200,
north=0,
south=3,
wg_width=10,
layer="M3",
port_type="electrical",
)
cc = gf.routing.add_pads_top(component=c)
cc.plot()
![../_images/50aff2114549764bf6a5ef9b1f47aee0934d3b44487c4580e97e63019091f61f.png](../_images/50aff2114549764bf6a5ef9b1f47aee0934d3b44487c4580e97e63019091f61f.png)
n = west = north = south = east = 10
spacing = 20
c = gf.components.nxn(
xsize=n * spacing,
ysize=n * spacing,
west=west,
east=east,
north=north,
south=south,
port_type="electrical",
wg_width=10,
)
c.plot()
![../_images/2587fdd8d1a0689fd51f4d4cf19bcb48ffa8be0034425923b42e19807caa5c30.png](../_images/2587fdd8d1a0689fd51f4d4cf19bcb48ffa8be0034425923b42e19807caa5c30.png)
cc = gf.routing.add_pads_top(component=c, fanout_length=300)
cc.plot()
![../_images/32f92ddc9e94dc76be3fe9d7274cec39f9e42a61ffa1a10ba30b1d5523595557.png](../_images/32f92ddc9e94dc76be3fe9d7274cec39f9e42a61ffa1a10ba30b1d5523595557.png)
Routing to optical terminations#
Route to Fiber Array#
You can route to a fiber array.
from gdsfactory.samples.big_device import big_device
component = big_device(nports=10)
c = gf.routing.add_fiber_array(component=component, radius=10.0, fanout_length=60.0)
c.plot()
![../_images/9c11b6b73984b96e295cc94ff11e86878d760b67b27fe5c0322861cfddb4f980.png](../_images/9c11b6b73984b96e295cc94ff11e86878d760b67b27fe5c0322861cfddb4f980.png)
You can also mix and match TE and TM grating couplers. Notice that the TM
polarization grating coupler is bigger.
import gdsfactory as gf
c = gf.components.mzi_phase_shifter()
gcte = gf.components.grating_coupler_te
cc = gf.routing.add_fiber_array(
component=c,
optical_routing_type=2,
grating_coupler=gf.components.grating_coupler_te,
radius=20,
)
cc.plot()
![../_images/ffab3fd3468f6c77380e2705387b2c70061a7fc55274d395221579e8c0e3c833.png](../_images/ffab3fd3468f6c77380e2705387b2c70061a7fc55274d395221579e8c0e3c833.png)
Route to edge couplers#
You can also route Edge couplers to a fiber array or to both sides of the chip.
For routing to both sides you can follow different strategies:
Place the edge couplers and route your components to the edge couplers.
Extend your component ports to each side.
Anything you imagine …