Routing API
route_single
route_single
route_single places a Manhattan route between two ports.
route_single only works for an individual routes. For routing groups of ports you need to use route_bundle instead
To make a route, you need to supply:
- input port
- output port
- bend
- straight
- taper to taper to wider straights and reduce straight loss (Optional)
To generate a route:
-
Generate the backbone of the route. This is a list of manhattan coordinates that the route would pass through if it used only sharp bends (right angles)
-
Replace the corners by bend references (with rotation and position computed from the manhattan backbone)
-
Add tapers if needed and if space permits
-
generate straight portions in between tapers or bends
route_single
route_single(
component: Component,
port1: Port,
port2: Port,
cross_section: CrossSectionSpec | None = None,
layer: LayerSpec | None = None,
bend: ComponentSpec = "bend_euler",
straight: ComponentSpec = "straight",
start_straight_length: float = 0.0,
end_straight_length: float = 0.0,
waypoints: WayPoints | None = None,
steps: Sequence[Step] | None = None,
port_type: str | None = None,
allow_width_mismatch: bool = False,
radius: float | None = None,
route_width: float | None = None,
auto_taper: bool = True,
on_error: Literal["error"] | None = None,
layer_transitions: LayerTransitions | None = None,
) -> ManhattanRoute
Returns a Manhattan Route between 2 ports.
The references are straights, bends and tapers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
Component
|
to place the route into. |
required |
port1
|
Port
|
start port. |
required |
port2
|
Port
|
end port. |
required |
cross_section
|
CrossSectionSpec | None
|
spec. |
None
|
layer
|
LayerSpec | None
|
layer spec. |
None
|
bend
|
ComponentSpec
|
bend spec. |
'bend_euler'
|
straight
|
ComponentSpec
|
straight spec. |
'straight'
|
start_straight_length
|
float
|
length of starting straight. |
0.0
|
end_straight_length
|
float
|
length of end straight. |
0.0
|
waypoints
|
WayPoints | None
|
optional list of points to pass through. |
None
|
steps
|
Sequence[Step] | None
|
optional list of steps to pass through. Each step is a dict with keys: x (absolute), y (absolute), dx (relative), dy (relative). Use x/y to set an absolute coordinate and dx/dy to shift relative to the current position. |
None
|
port_type
|
str | None
|
port type to route. |
None
|
allow_width_mismatch
|
bool
|
allow different port widths. |
False
|
radius
|
float | None
|
bend radius. If None, defaults to cross_section.radius. |
None
|
route_width
|
float | None
|
width of the route in um. If None, defaults to cross_section.width. |
None
|
auto_taper
|
bool
|
add auto tapers. |
True
|
on_error
|
Literal['error'] | None
|
what to do on error. If error, raises an error. If None ignores the error. |
None
|
layer_transitions
|
LayerTransitions | None
|
dictionary of layer transitions to use for the routing when auto_taper=True. |
None
|
Example
import gdsfactory as gf
c = gf.Component()
mmi1 = c << gf.components.mmi1x2()
mmi2 = c << gf.components.mmi1x2()
mmi2.move((40, 20))
gf.routing.route_single(c, mmi1.ports["o2"], mmi2.ports["o1"], radius=5, cross_section="strip")
c.plot()
Source code in gdsfactory/routing/route_single.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
route_single_electrical
route_single_electrical(
component: Component,
port1: Port,
port2: Port,
start_straight_length: float | None = None,
end_straight_length: float | None = None,
layer: LayerSpec | None = None,
width: float | None = None,
cross_section: CrossSectionSpec = "metal_routing",
) -> None
Places a route between two electrical ports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
Component
|
The cell to place the route in. |
required |
port1
|
Port
|
The first port. |
required |
port2
|
Port
|
The second port. |
required |
start_straight_length
|
float | None
|
The length of the straight at the start of the route. |
None
|
end_straight_length
|
float | None
|
The length of the straight at the end of the route. |
None
|
layer
|
LayerSpec | None
|
The layer of the route. |
None
|
width
|
float | None
|
The width of the route. |
None
|
cross_section
|
CrossSectionSpec
|
The cross section of the route. |
'metal_routing'
|
Source code in gdsfactory/routing/route_single.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
route_quad
Route for electrical based on phidl.routing.route_quad.
route_quad
route_quad(
component: Component,
port1: Port,
port2: Port,
width1: float | None = None,
width2: float | None = None,
layer: LayerSpec = "M1",
manhattan_target_step: float | None = None,
) -> None
Routes a basic quadrilateral polygon directly between two ports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
Component
|
Component to add the route to. |
required |
port1
|
Port
|
Port to start route. |
required |
port2
|
Port objects to end route. |
required | |
width1
|
float | None
|
Width of quadrilateral at ports. If None, uses port widths. |
None
|
width2
|
float | None
|
Width of quadrilateral at ports. If None, uses port widths. |
None
|
layer
|
LayerSpec
|
Layer to put the route on. |
'M1'
|
manhattan_target_step
|
float | None
|
if not none, min step to manhattanize the polygon |
None
|
Example
import gdsfactory as gf
c = gf.Component()
pad1 = c << gf.components.pad(size=(50, 50))
pad2 = c << gf.components.pad(size=(10, 10))
pad2.movex(100)
pad2.movey(50)
gf.routing.route_quad(
c,
pad1.ports["e2"],
pad2.ports["e4"],
width1=None,
width2=None,
)
c.plot()
Source code in gdsfactory/routing/route_quad.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
route_sharp
based on phidl.routing.
path_C
path_C(
port1: Port,
port2: Port,
length1: float = 100,
left1: float = 100,
length2: float = 100,
) -> Path
Return waypoint path between port1 and port2 in a C shape. Useful when ports are parallel and face away from each other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port1
|
Port
|
start port. |
required |
port2
|
Port
|
end port. |
required |
length1
|
float
|
Length of route segment coming out of port1. Should be larger than bend radius. |
100
|
left1
|
float
|
Length of route segment that turns left (or right if negative) from port1. Should be larger than twice the bend radius. |
100
|
length2
|
float
|
Length of route segment coming out of port2. Should be larger than bend radius. |
100
|
Source code in gdsfactory/routing/route_sharp.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
path_J
path_J(
port1: Port,
port2: Port,
length1: float = 200,
length2: float = 200,
) -> Path
Return waypoint path between port1 and port2 in a J shape.
Useful when orthogonal ports cannot be connected directly with an L shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port1
|
Port
|
start port. |
required |
port2
|
Port
|
end port. |
required |
length1
|
float
|
Length of segment exiting port1. Should be larger than bend radius. |
200
|
length2
|
float
|
Length of segment exiting port2. Should be larger than bend radius. |
200
|
Source code in gdsfactory/routing/route_sharp.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
path_L
path_L(port1: Port, port2: Port) -> Path
Return waypoint path between port1 and port2 in an L shape.
Useful when orthogonal ports can be directly connected with one turn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port1
|
Port
|
start port. |
required |
port2
|
Port
|
end port. |
required |
Source code in gdsfactory/routing/route_sharp.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
path_U
path_U(
port1: Port, port2: Port, length1: float = 200
) -> Path
Return waypoint path between port1 and port2 in a U shape.
Useful when ports face the same direction or toward each other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port1
|
Port
|
start port. |
required |
port2
|
Port
|
end port. |
required |
length1
|
float
|
Length of segment exiting port1. Should be larger than bend radius. |
200
|
Source code in gdsfactory/routing/route_sharp.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
path_V
path_V(port1: Port, port2: Port) -> Path
Return waypoint path between port1 and port2 in a V shape.
Useful when ports point to a single connecting point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port1
|
Port
|
Start port. |
required |
port2
|
Port
|
End port. |
required |
Source code in gdsfactory/routing/route_sharp.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
path_Z
path_Z(
port1: Port,
port2: Port,
length1: float = 100,
length2: float = 100,
) -> Path
Return waypoint path between port1 and port2 in a Z shape.
Ports can have any relative orientation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port1
|
Port
|
start port. |
required |
port2
|
Port
|
end port. |
required |
length1
|
float
|
Length of route segment coming out of port1. |
100
|
length2
|
float
|
Length of route segment coming out of port2. |
100
|
Source code in gdsfactory/routing/route_sharp.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
path_manhattan
path_manhattan(
port1: Port, port2: Port, radius: float
) -> Path
Return waypoint path between port1 and port2 using manhattan routing.
Routing uses straight, L, U, J, or C waypoint path as needed. Ports must face orthogonal or parallel directions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port1
|
Port
|
start port. |
required |
port2
|
Port
|
end port. |
required |
radius
|
float
|
Bend radius for 90 degree bend. |
required |
Source code in gdsfactory/routing/route_sharp.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
path_straight
path_straight(port1: Port, port2: Port) -> Path
Return waypoint path between port1 and port2 in a straight line.
Useful when ports point directly at each other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port1
|
Port
|
start port. |
required |
port2
|
Port
|
end port. |
required |
Source code in gdsfactory/routing/route_sharp.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
route_sharp
route_sharp(
component: Component,
port1: Port,
port2: Port,
width: float | None = None,
path_type: str = "manhattan",
manual_path: Path | None = None,
layer: LayerSpec | None = None,
cross_section: CrossSectionSpec | None = None,
port_names: tuple[str, str] = ("o1", "o2"),
**kwargs: Any
) -> None
Returns Component route between ports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
Component
|
Component to add the route to. |
required |
port1
|
Port
|
start port. |
required |
port2
|
Port
|
end port. |
required |
width
|
float | None
|
None, int, float, array-like[2], or CrossSection. If None, the route linearly tapers between the widths the ports If set to a single number (e.g. |
None
|
path_type
|
{'manhattan', 'L', 'U', 'J', 'C', 'V', 'Z', 'straight', 'manual'}. |
required | |
manual_path
|
Path | None
|
array-like[N][2] or Path Waypoint for manual route. |
None
|
layer
|
LayerSpec | None
|
Layer to put route on. |
None
|
cross_section
|
CrossSectionSpec | None
|
CrossSection to use for the route. |
None
|
port_names
|
tuple[str, str]
|
Tuple of port names for the start and end of the route. |
('o1', 'o2')
|
kwargs
|
Any
|
Keyword arguments passed to the waypoint path function. |
{}
|
Method of waypoint path creation. Should be one of:
- manhattan: automatic manhattan routing (see path_manhattan() ).
- L: L-shaped path for orthogonal ports that can be directly connected.
- U: U-shaped path for parallel or facing ports.
- J: J-shaped path for orthogonal ports that cannot be directly connected.
- C: C-shaped path for ports that face away from each other.
- Z: Z-shaped path with three segments for ports at any angles.
- V: V-shaped path with two segments for ports at any angles.
- straight: straight path for ports that face each other.
- manual: use an explicit waypoint path provided in manual_path.
Example
import gdsfactory as gf
c = gf.Component()
c1 = c << gf.components.pad(port_orientation=None)
c2 = c << gf.components.pad(port_orientation=None)
c2.movex(400)
c2.movey(-200)
gf.routing.route_sharp(c, c1.ports["e4"], c2.ports["e1"], path_type="L")
c.plot()
Source code in gdsfactory/routing/route_sharp.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
route_bundle
When you need to route groups of ports together without them crossing each other you can use a bundle/river/bus router.
route_bundle is the generic river bundle bus routing function that will call different functions depending on
the port orientation. Get bundle acts as a high level entry point. Based on the angle
configurations of the banks of ports, it decides which sub-routine to call:
route_bundle
Routes bundles of ports (river routing).
get bundle is the generic river routing function route_bundle calls different function depending on the port orientation.
- route_bundle_same_axis: ports facing each other with arbitrary pitch on each side
- route_bundle_corner: 90Deg / 270Deg between ports with arbitrary pitch
- route_bundle_udirect: ports with direct U-turns
- route_bundle_uindirect: ports with indirect U-turns
get_min_spacing
get_min_spacing(
ports1: Ports,
ports2: Ports,
separation: float = 5.0,
radius: float = 5.0,
sort_ports: bool = True,
) -> float
Returns the minimum amount of spacing in um required to create a fanout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ports1
|
Ports
|
first list of ports. |
required |
ports2
|
Ports
|
second list of ports. |
required |
separation
|
float
|
minimum separation between two straights in um. |
5.0
|
radius
|
float
|
bend radius in um. |
5.0
|
sort_ports
|
bool
|
sort the ports according to the axis. |
True
|
Source code in gdsfactory/routing/route_bundle.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
route_bundle
route_bundle(
component: Component,
ports1: Port | Ports | list[Pin] | None = None,
ports2: Port | Ports | list[Pin] | None = None,
cross_section: CrossSectionSpec | None = None,
layer: LayerSpec | None = None,
separation: float = 3.0,
bend: ComponentSpec = "bend_euler",
sort_ports: bool = False,
start_straight_length: float = 0,
end_straight_length: float = 0,
min_straight_taper: float = 100,
taper: ComponentSpec | None = None,
port_type: str | None = None,
collision_check_layers: LayerSpecs | None = None,
on_collision: (
Literal["error", "show_error", "warning"] | None
) = None,
on_placer_error: (
Literal["error", "show_error", "warning"] | None
) = None,
bboxes: Sequence[DBox] | None = None,
allow_width_mismatch: bool | None = None,
allow_layer_mismatch: bool | None = None,
allow_type_mismatch: bool | None = None,
radius: float | None = None,
route_width: float | None = None,
straight: ComponentSpec = "straight",
sbend: ComponentSpec | None = None,
auto_taper: bool = True,
auto_taper_taper: ComponentSpec | None = None,
waypoints: Coordinates | Sequence[DPoint] | None = None,
steps: Sequence[Step] | None = None,
start_angles: float | list[float] | None = None,
end_angles: float | list[float] | None = None,
router: Literal["optical", "electrical"] | None = None,
layer_transitions: LayerTransitions | None = None,
show_waypoints: bool = False,
layer_marker: LayerSpec | None = None,
raise_on_error: bool | None = None,
path_length_matching_config: (
PathLengthConfig | None
) = None,
constraints: Sequence[Constraint] | None = None,
layer_label: LayerSpec | None = None,
port1: Port | None = None,
port2: Port | None = None,
name: str | None = None,
) -> list[ManhattanRoute]
Places a bundle of routes to connect two groups of ports.
Routes connect a bundle of ports with a river router. Chooses the correct routing function depending on port angles.
Can also be used with single ports instead of lists, replacing route_bundle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
Component
|
component to add the routes to. |
required |
ports1
|
Port | Ports | list[Pin] | None
|
starting port or list of starting ports. |
None
|
ports2
|
Port | Ports | list[Pin] | None
|
end port or list of end ports. |
None
|
cross_section
|
CrossSectionSpec | None
|
CrossSection or function that returns a cross_section. |
None
|
layer
|
LayerSpec | None
|
layer to use for the route. |
None
|
separation
|
float
|
bundle separation (center to center). Defaults to cross_section.width + cross_section.gap |
3.0
|
bend
|
ComponentSpec
|
function for the bend. Defaults to euler. |
'bend_euler'
|
sort_ports
|
bool
|
sort port coordinates. |
False
|
start_straight_length
|
float
|
straight length at the beginning of the route. If None, uses default value for the routing CrossSection. |
0
|
end_straight_length
|
float
|
end length at the beginning of the route. If None, uses default value for the routing CrossSection. |
0
|
min_straight_taper
|
float
|
minimum length for tapering the straight sections. |
100
|
taper
|
ComponentSpec | None
|
function for tapering long straight waveguides beyond min_straight_taper. Defaults to None. |
None
|
port_type
|
str | None
|
type of port to place. Defaults to optical. |
None
|
collision_check_layers
|
LayerSpecs | None
|
list of layers to check for collisions. |
None
|
on_collision
|
Literal['error', 'show_error', 'warning'] | None
|
action to take on collision. Defaults to None (ignore). |
None
|
on_placer_error
|
Literal['error', 'show_error', 'warning'] | None
|
action to take on placer error. Defaults to None (ignore). |
None
|
bboxes
|
Sequence[DBox] | None
|
list of bounding boxes to avoid collisions. |
None
|
allow_width_mismatch
|
bool | None
|
allow different port widths. |
None
|
allow_layer_mismatch
|
bool | None
|
allow different port layers to connect. |
None
|
allow_type_mismatch
|
bool | None
|
allow different port types to connect. |
None
|
radius
|
float | None
|
bend radius. If None, defaults to cross_section.radius. |
None
|
route_width
|
float | None
|
width of the route. If None, defaults to cross_section.width. |
None
|
straight
|
ComponentSpec
|
function for the straight. Defaults to straight. |
'straight'
|
sbend
|
ComponentSpec | None
|
function for the s-bend. If None, uses the same function as bend. |
None
|
auto_taper
|
bool
|
if True, auto-tapers ports to the cross-section of the route. |
True
|
auto_taper_taper
|
ComponentSpec | None
|
taper to use for auto-tapering. If None, uses the default taper for the cross-section. |
None
|
waypoints
|
Coordinates | Sequence[DPoint] | None
|
list of waypoints to add to the route. |
None
|
steps
|
Sequence[Step] | None
|
list of steps to add to the route. Each step is a dict with keys: x (absolute), y (absolute), dx (relative), dy (relative). Use x/y to set an absolute coordinate and dx/dy to shift relative to the current position. |
None
|
start_angles
|
float | list[float] | None
|
list of start angles for the routes. Only used for electrical ports. |
None
|
end_angles
|
float | list[float] | None
|
list of end angles for the routes. Only used for electrical ports. |
None
|
router
|
Literal['optical', 'electrical'] | None
|
Set the type of router to use, either the optical one or the electrical one. If None, the router is optical unless the port_type is "electrical". |
None
|
layer_transitions
|
LayerTransitions | None
|
dictionary of layer transitions to use for the routing when auto_taper=True. |
None
|
show_waypoints
|
bool
|
if True, places markers at each waypoint using CONF.layer_marker. |
False
|
layer_marker
|
LayerSpec | None
|
layer to place markers on the route. Overrides CONF.layer_marker when show_waypoints=True. |
None
|
raise_on_error
|
bool | None
|
if True, raises an exception on routing error instead of adding error markers. |
None
|
path_length_matching_config
|
PathLengthConfig | None
|
path length matching configuration. Convenience shortcut that is converted into a single |
None
|
constraints
|
Sequence[Constraint] | None
|
list of kfactory routing constraints ( |
None
|
layer_label
|
LayerSpec | None
|
layer to place length labels on the route. |
None
|
port1
|
Port | None
|
single start port (alternative to ports1 for single-port routing). |
None
|
port2
|
Port | None
|
single end port (alternative to ports2 for single-port routing). |
None
|
name
|
str | None
|
Name for the route. This is not important yet, but once constraints are implemented, the constraint, depending on the constraint class, might check against names to make enforcement or checking decisions. |
None
|
Example
import gdsfactory as gf
dy = 200.0
xs1 = [-500, -300, -100, -90, -80, -55, -35, 200, 210, 240, 500, 650]
pitch = 10.0
N = len(xs1)
xs2 = [-20 + i * pitch for i in range(N // 2)]
xs2 += [400 + i * pitch for i in range(N // 2)]
a1 = 90
a2 = a1 + 180
ports1 = [gf.Port(name=f"top_{i}", center=(xs1[i], +0), width=0.5, orientation=a1, layer=(1, 0)) for i in range(N)]
ports2 = [gf.Port(name=f"bot_{i}", center=(xs2[i], dy), width=0.5, orientation=a2, layer=(1, 0)) for i in range(N)]
c = gf.Component()
gf.routing.route_bundle(component=c, ports1=ports1, ports2=ports2, cross_section='strip', separation=5)
c.plot()
Source code in gdsfactory/routing/route_bundle.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 | |
route_bundle_electrical
module-attribute
route_bundle_electrical = partial(
route_bundle,
bend="wire_corner",
allow_width_mismatch=True,
)
route_bundle_all_angle
route_bundle_all_angle
route_bundle_all_angle
route_bundle_all_angle(
component: ComponentSpec,
ports1: list[Port],
ports2: list[Port],
backbone: Coordinates | None = None,
separation: list[float] | float = 3.0,
straight: CellAllAngleSpec = "straight_all_angle",
bend: CellAllAngleSpec = "bend_euler_all_angle",
bend_ports: tuple[str, str] = ("o1", "o2"),
straight_ports: tuple[str, str] = ("o1", "o2"),
cross_section: CrossSectionSpec | None = None,
) -> list[OpticalAllAngleRoute]
Route a bundle of ports to another bundle of ports with non manhattan ports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
ComponentSpec
|
to add the routing. |
required |
ports1
|
list[Port]
|
list of start ports to connect. |
required |
ports2
|
list[Port]
|
list of end ports to connect. |
required |
backbone
|
Coordinates | None
|
list of points to connect the ports. |
None
|
separation
|
list[float] | float
|
list of spacings. |
3.0
|
straight
|
CellAllAngleSpec
|
function to create straights. |
'straight_all_angle'
|
bend
|
CellAllAngleSpec
|
function to create bends. |
'bend_euler_all_angle'
|
bend_ports
|
tuple[str, str]
|
tuple of ports to connect the bends. |
('o1', 'o2')
|
straight_ports
|
tuple[str, str]
|
tuple of ports to connect the straights. |
('o1', 'o2')
|
cross_section
|
CrossSectionSpec | None
|
cross_section to use. Overrides the cross_section. |
None
|
Source code in gdsfactory/routing/route_bundle_all_angle.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
route_ports_to_side
For now route_bundle is not smart enough to decide whether it should call route_ports_to_side.
So you either need to connect your ports to face in one direction first, or to
use route_ports_to_side before calling route_bundle.
route_ports_to_side
route_ports_to_side
route_ports_to_side(
component: Component,
cross_section: CrossSectionSpec,
ports: Ports | None = None,
side: Literal[
"north", "east", "south", "west"
] = "north",
x: float | None | Literal["east", "west"] = None,
y: float | None | Literal["north", "south"] = None,
**kwargs: Any
) -> tuple[list[ManhattanRoute], list[kf.DPort]]
Routes ports to a given side.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
Component
|
component to route. |
required |
cross_section
|
CrossSectionSpec
|
cross_section to use for routing. |
required |
ports
|
Ports | None
|
ports to route to a side. |
None
|
side
|
Literal['north', 'east', 'south', 'west']
|
'north', 'south', 'east' or 'west'. |
'north'
|
x
|
float | None | Literal['east', 'west']
|
position to route ports for east/west. None, uses most east/west value. |
None
|
y
|
float | None | Literal['north', 'south']
|
position to route ports for south/north. None, uses most north/south value. |
None
|
kwargs
|
Any
|
additional arguments to pass to the routing function. |
{}
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
radius |
in um. |
|
separation |
in um. |
Returns:
| Type | Description |
|---|---|
list[ManhattanRoute]
|
List of routes: with routing elements. |
list[DPort]
|
List of ports: of the new ports. |
Example
import gdsfactory as gf
c = gf.Component()
dummy = gf.components.nxn(north=2, south=2, west=2, east=2)
sides = ["north", "south", "east", "west"]
d = 100
positions = [(0, 0), (d, 0), (d, d), (0, d)]
for pos, side in zip(positions, sides):
dummy_ref = c << dummy
dummy_ref.move(pos)
routes, ports = gf.routing.route_ports_to_side(
component=c, side=side, ports=dummy_ref.ports, cross_section="strip"
)
for i, p in enumerate(ports):
c.add_port(name=f"{side[0]}{i}", port=p)
c.plot()
Source code in gdsfactory/routing/route_ports_to_side.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
route_ports_to_x
route_ports_to_x(
component: Component,
ports: Ports,
cross_section: CrossSectionSpec,
x: float | Literal["east", "west"] = "east",
separation: float = 10.0,
radius: float = 10.0,
extend_bottom: float = 0.0,
extend_top: float = 0.0,
extension_length: float = 0.0,
y0_bottom: float | None = None,
y0_top: float | None = None,
backward_port_side_split_index: int = 0,
start_straight_length: float = 0.01,
dx_start: float | None = None,
dy_start: float | None = None,
side: Literal["east", "west"] = "east",
**routing_func_args: Any
) -> tuple[list[ManhattanRoute], list[typings.Port]]
Returns route to x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
Component
|
component to route. |
required |
ports
|
Ports
|
reasonably well behaved list of ports. ports facing north ports are norther than any other ports ports facing south ports are souther ... ports facing west ports are the wester ... ports facing east ports are the easter ... |
required |
cross_section
|
CrossSectionSpec
|
cross_section to use for routing. |
required |
x
|
float | Literal['east', 'west']
|
float or string. if float: x coordinate to which the ports will be routed if string: "east" -> route to east if string: "west" -> route to west |
'east'
|
separation
|
float
|
in um. |
10.0
|
radius
|
float
|
in um. |
10.0
|
extend_bottom
|
float
|
in um. |
0.0
|
extend_top
|
float
|
in um. |
0.0
|
extension_length
|
float
|
in um. |
0.0
|
y0_bottom
|
float | None
|
in um. |
None
|
y0_top
|
float | None
|
in um. |
None
|
backward_port_side_split_index
|
int
|
integer represents and index in the list of backwards ports (bottom to top) all ports with an index strictly lower or equal are routed bottom all ports with an index larger or equal are routed top. |
0
|
start_straight_length
|
float
|
in um. |
0.01
|
dx_start
|
float | None
|
override minimum starting x distance. |
None
|
dy_start
|
float | None
|
override minimum starting y distance. |
None
|
side
|
Literal['east', 'west']
|
"east" or "west". |
'east'
|
routing_func_args
|
Any
|
additional arguments to pass to the routing function. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
routes |
list[ManhattanRoute]
|
list of routes |
ports |
list[Port]
|
list of the new optical ports |
- routes the bottom-half of the ports facing opposite side of x
- routes the south ports
- front ports
- north ports
Source code in gdsfactory/routing/route_ports_to_side.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
route_ports_to_y
route_ports_to_y(
component: Component,
ports: Ports,
cross_section: CrossSectionSpec,
y: float | Literal["north", "south"] = "north",
separation: float = 10.0,
radius: float = 10.0,
x0_left: float | None = None,
x0_right: float | None = None,
extension_length: float = 0.0,
extend_left: float = 0.0,
extend_right: float = 0.0,
backward_port_side_split_index: int = 0,
start_straight_length: float = 0.01,
dx_start: float | None = None,
dy_start: float | None = None,
side: Literal["north", "south"] = "north",
**routing_func_args: Any
) -> tuple[list[ManhattanRoute], list[typings.Port]]
Route ports to y.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
Component
|
component to route. |
required |
ports
|
Ports
|
reasonably well behaved list of ports. ports facing north ports are norther than any other ports ports facing south ports are souther ... ports facing west ports are the wester ... ports facing east ports are the easter ... |
required |
cross_section
|
CrossSectionSpec
|
cross_section to use for routing. |
required |
y
|
float | Literal['north', 'south']
|
float or string. if float: y coordinate to which the ports will be routed if string: "north" -> route to north if string: "south" -> route to south |
'north'
|
separation
|
float
|
in um. |
10.0
|
radius
|
float
|
in um. |
10.0
|
x0_left
|
float | None
|
in um. |
None
|
x0_right
|
float | None
|
in um. |
None
|
extension_length
|
float
|
in um. |
0.0
|
extend_left
|
float
|
in um. |
0.0
|
extend_right
|
float
|
in um. |
0.0
|
backward_port_side_split_index
|
int
|
integer this integer represents and index in the list of backwards ports (sorted from left to right) all ports with an index strictly larger are routed right all ports with an index lower or equal are routed left |
0
|
start_straight_length
|
float
|
in um. |
0.01
|
dx_start
|
float | None
|
override minimum starting x distance. |
None
|
dy_start
|
float | None
|
override minimum starting y distance. |
None
|
side
|
Literal['north', 'south']
|
"north" or "south". |
'north'
|
routing_func_args
|
Any
|
additional arguments to pass to the routing function. |
{}
|
Returns:
| Type | Description |
|---|---|
list[ManhattanRoute]
|
|
list[Port]
|
|
First route the bottom-half of the back ports (back ports are the one facing opposite side of x) Then route the south ports then the front ports then the north ports
Source code in gdsfactory/routing/route_ports_to_side.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | |
route_ports_to_x
route_ports_to_x(
component: Component,
ports: Ports,
cross_section: CrossSectionSpec,
x: float | Literal["east", "west"] = "east",
separation: float = 10.0,
radius: float = 10.0,
extend_bottom: float = 0.0,
extend_top: float = 0.0,
extension_length: float = 0.0,
y0_bottom: float | None = None,
y0_top: float | None = None,
backward_port_side_split_index: int = 0,
start_straight_length: float = 0.01,
dx_start: float | None = None,
dy_start: float | None = None,
side: Literal["east", "west"] = "east",
**routing_func_args: Any
) -> tuple[list[ManhattanRoute], list[typings.Port]]
Returns route to x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
Component
|
component to route. |
required |
ports
|
Ports
|
reasonably well behaved list of ports. ports facing north ports are norther than any other ports ports facing south ports are souther ... ports facing west ports are the wester ... ports facing east ports are the easter ... |
required |
cross_section
|
CrossSectionSpec
|
cross_section to use for routing. |
required |
x
|
float | Literal['east', 'west']
|
float or string. if float: x coordinate to which the ports will be routed if string: "east" -> route to east if string: "west" -> route to west |
'east'
|
separation
|
float
|
in um. |
10.0
|
radius
|
float
|
in um. |
10.0
|
extend_bottom
|
float
|
in um. |
0.0
|
extend_top
|
float
|
in um. |
0.0
|
extension_length
|
float
|
in um. |
0.0
|
y0_bottom
|
float | None
|
in um. |
None
|
y0_top
|
float | None
|
in um. |
None
|
backward_port_side_split_index
|
int
|
integer represents and index in the list of backwards ports (bottom to top) all ports with an index strictly lower or equal are routed bottom all ports with an index larger or equal are routed top. |
0
|
start_straight_length
|
float
|
in um. |
0.01
|
dx_start
|
float | None
|
override minimum starting x distance. |
None
|
dy_start
|
float | None
|
override minimum starting y distance. |
None
|
side
|
Literal['east', 'west']
|
"east" or "west". |
'east'
|
routing_func_args
|
Any
|
additional arguments to pass to the routing function. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
routes |
list[ManhattanRoute]
|
list of routes |
ports |
list[Port]
|
list of the new optical ports |
- routes the bottom-half of the ports facing opposite side of x
- routes the south ports
- front ports
- north ports
Source code in gdsfactory/routing/route_ports_to_side.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
route_ports_to_y
route_ports_to_y(
component: Component,
ports: Ports,
cross_section: CrossSectionSpec,
y: float | Literal["north", "south"] = "north",
separation: float = 10.0,
radius: float = 10.0,
x0_left: float | None = None,
x0_right: float | None = None,
extension_length: float = 0.0,
extend_left: float = 0.0,
extend_right: float = 0.0,
backward_port_side_split_index: int = 0,
start_straight_length: float = 0.01,
dx_start: float | None = None,
dy_start: float | None = None,
side: Literal["north", "south"] = "north",
**routing_func_args: Any
) -> tuple[list[ManhattanRoute], list[typings.Port]]
Route ports to y.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
Component
|
component to route. |
required |
ports
|
Ports
|
reasonably well behaved list of ports. ports facing north ports are norther than any other ports ports facing south ports are souther ... ports facing west ports are the wester ... ports facing east ports are the easter ... |
required |
cross_section
|
CrossSectionSpec
|
cross_section to use for routing. |
required |
y
|
float | Literal['north', 'south']
|
float or string. if float: y coordinate to which the ports will be routed if string: "north" -> route to north if string: "south" -> route to south |
'north'
|
separation
|
float
|
in um. |
10.0
|
radius
|
float
|
in um. |
10.0
|
x0_left
|
float | None
|
in um. |
None
|
x0_right
|
float | None
|
in um. |
None
|
extension_length
|
float
|
in um. |
0.0
|
extend_left
|
float
|
in um. |
0.0
|
extend_right
|
float
|
in um. |
0.0
|
backward_port_side_split_index
|
int
|
integer this integer represents and index in the list of backwards ports (sorted from left to right) all ports with an index strictly larger are routed right all ports with an index lower or equal are routed left |
0
|
start_straight_length
|
float
|
in um. |
0.01
|
dx_start
|
float | None
|
override minimum starting x distance. |
None
|
dy_start
|
float | None
|
override minimum starting y distance. |
None
|
side
|
Literal['north', 'south']
|
"north" or "south". |
'north'
|
routing_func_args
|
Any
|
additional arguments to pass to the routing function. |
{}
|
Returns:
| Type | Description |
|---|---|
list[ManhattanRoute]
|
|
list[Port]
|
|
First route the bottom-half of the back ports (back ports are the one facing opposite side of x) Then route the south ports then the front ports then the north ports
Source code in gdsfactory/routing/route_ports_to_side.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | |
route_south
route_south
route_south(
component: Component,
component_to_route: Component | ComponentReference,
optical_routing_type: int = 1,
excluded_ports: Sequence[str] | None = None,
straight_separation: float = 4.0,
io_gratings_lines: (
list[list[ComponentReference]] | None
) = None,
gc_port_name: str = "o1",
bend: ComponentSpec = "bend_euler",
straight: ComponentSpec = "straight",
select_ports: SelectPorts = select_ports_optical,
port_names: Strs | None = None,
cross_section: CrossSectionSpec = "strip",
start_straight_length: float = 0.5,
port_type: str | None = None,
allow_width_mismatch: bool = False,
auto_taper: bool = True,
) -> list[ManhattanRoute]
Places routes to route a component ports to the south.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
Component
|
top level component to add the routes. |
required |
component_to_route
|
Component | ComponentReference
|
component or reference to route ports to south. |
required |
optical_routing_type
|
int
|
routing heuristic |
1
|
excluded_ports
|
Sequence[str] | None
|
list of port names to NOT route. |
None
|
straight_separation
|
float
|
in um. |
4.0
|
io_gratings_lines
|
list[list[ComponentReference]] | None
|
list of ports to which the ports produced by this function will be connected. Supplying this information helps avoiding straight collisions. |
None
|
gc_port_name
|
str
|
grating coupler port name. Used only if io_gratings_lines is supplied. |
'o1'
|
bend
|
ComponentSpec
|
spec. |
'bend_euler'
|
straight
|
ComponentSpec
|
spec. |
'straight'
|
select_ports
|
SelectPorts
|
function to select_ports. |
select_ports_optical
|
port_names
|
Strs | None
|
optional port names. Overrides select_ports. |
None
|
cross_section
|
CrossSectionSpec
|
cross_section spec. |
'strip'
|
start_straight_length
|
float
|
in um. |
0.5
|
port_type
|
str | None
|
optical or electrical. |
None
|
allow_width_mismatch
|
bool
|
allow width mismatch. |
False
|
auto_taper
|
bool
|
auto taper. |
True
|
Works well if the component looks roughly like a rectangular box with
north ports on the north of the box. south ports on the south of the box. east ports on the east of the box. west ports on the west of the box.
Example
import gdsfactory as gf
c = gf.Component()
ref = c << gf.components.ring_double()
r = gf.routing.route_south(c, ref)
c.plot()
Source code in gdsfactory/routing/route_south.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
fanout
fanout2x2
fanout2x2
fanout2x2(
component: ComponentSpec = "mmi2x2",
port_spacing: float = 20.0,
bend_length: float | None = None,
npoints: int = 101,
select_ports: PortsFactory = select_ports_optical,
cross_section: CrossSectionSpec = "strip",
port1: str = "o1",
port2: str = "o2",
port3: str = "o3",
port4: str = "o4",
**kwargs: Any
) -> Component
Returns component with Sbend fanout routes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
ComponentSpec
|
to fanout. |
'mmi2x2'
|
port_spacing
|
float
|
for the returned component. |
20.0
|
bend_length
|
float | None
|
length of the bend (defaults to port_spacing). |
None
|
npoints
|
int
|
for sbend. |
101
|
select_ports
|
PortsFactory
|
function to select optical_ports ports. |
select_ports_optical
|
cross_section
|
CrossSectionSpec
|
cross_section spec. |
'strip'
|
port1
|
str
|
bottom west port. |
'o1'
|
port2
|
str
|
top west port. |
'o2'
|
port3
|
str
|
top east port. |
'o3'
|
port4
|
str
|
bottom east port. |
'o4'
|
kwargs
|
Any
|
cross_section settings. |
{}
|
Example
import gdsfactory as gf
c = gf.components.nxn(west=2, east=2)
cc = gf.routing.fanout2x2(component=c, port_spacing=20)
cc.plot()
Source code in gdsfactory/routing/fanout2x2.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
add_fiber_array
In cases where individual components have to be tested, you can generate the array of optical I/O and connect them to the component.
You can connect the waveguides to a 127um pitch fiber array or to individual fibers for input and output.
add_fiber_array
add_fiber_array(
component: ComponentSpec = "straight",
grating_coupler: ComponentSpecOrList = "grating_coupler_te",
gc_port_name: str = "o1",
select_ports: PortsFactory = select_ports_optical,
cross_section: CrossSectionSpec = "strip",
start_straight_length: float = 0,
end_straight_length: float = 0,
mirror_grating_coupler: bool = False,
**kwargs: Any
) -> Component
Returns component with south routes and grating_couplers.
You can also use pads or other terminations instead of grating couplers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
ComponentSpec
|
component spec to connect to grating couplers. |
'straight'
|
grating_coupler
|
ComponentSpecOrList
|
spec for route terminations. |
'grating_coupler_te'
|
gc_port_name
|
str
|
grating coupler input port name. |
'o1'
|
select_ports
|
PortsFactory
|
function to select ports. |
select_ports_optical
|
cross_section
|
CrossSectionSpec
|
cross_section function. |
'strip'
|
mirror_grating_coupler
|
bool
|
if True, mirrors the grating coupler. |
False
|
kwargs
|
Any
|
additional arguments. |
{}
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
bend |
bend spec. |
|
straight |
straight spec. |
|
fanout_length |
if None, automatic calculation of fanout length. |
|
max_y0_optical |
in um. |
|
with_loopback |
True, adds loopback structures. |
|
with_loopback_inside |
True, adds loopback structures inside the component. |
|
straight_separation |
from edge to edge. |
|
list_port_labels |
None, adds TM labels to port indices in this list. |
|
nb_optical_ports_lines |
number of grating coupler lines. |
|
force_manhattan |
False |
|
excluded_ports |
list of port names to exclude when adding gratings. |
|
grating_indices |
list of grating coupler indices. |
|
routing_straight |
function to route. |
|
routing_method |
route_bundle. |
|
gc_rotation |
fiber coupler rotation in degrees. Defaults to -90. |
|
input_port_indexes |
to connect. |
|
pitch |
in um. |
|
radius |
optional radius of the bend. Defaults to the cross_section. |
|
radius_loopback |
optional radius of the loopback bend. Defaults to the cross_section. |
|
start_straight_length |
float
|
length of the start straight. |
end_straight_length |
float
|
length of the end straight. |
Example
import gdsfactory as gf
c = gf.components.crossing()
cc = gf.routing.add_fiber_array(
component=c,
grating_coupler=gf.components.grating_coupler_elliptical_te,
with_loopback=False
)
cc.plot()
Source code in gdsfactory/routing/add_fiber_array.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
add_pads
add_pads_top
add_pads_top(
component: ComponentSpec = "straight_heater_metal",
select_ports: SelectPorts = select_ports_electrical,
port_names: Strs | None = None,
cross_section: CrossSectionSpec = "metal_routing",
pad_port_name: str = "e1",
pad: ComponentSpec = "pad_rectangular",
bend: ComponentSpec = "wire_corner",
straight_separation: float = 15.0,
pad_pitch: float = 100.0,
port_type: str = "electrical",
allow_width_mismatch: bool = True,
fanout_length: float | None = None,
route_width: float | None = 0,
bboxes: BoundingBoxes | None = None,
avoid_component_bbox: bool = False,
auto_taper: bool = True,
**kwargs: Any
) -> Component
Returns new component with ports connected top pads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
ComponentSpec
|
component spec to connect to. |
'straight_heater_metal'
|
select_ports
|
SelectPorts
|
function to select_ports. |
select_ports_electrical
|
port_names
|
Strs | None
|
optional port names. Overrides select_ports. |
None
|
cross_section
|
CrossSectionSpec
|
cross_section spec. |
'metal_routing'
|
get_input_labels_function
|
function to get input labels. None skips labels. |
required | |
layer_label
|
optional layer for grating coupler label. |
required | |
pad_port_name
|
str
|
pad input port name. |
'e1'
|
pad_port_labels
|
pad list of labels. |
required | |
pad
|
ComponentSpec
|
spec for route terminations. |
'pad_rectangular'
|
bend
|
ComponentSpec
|
bend spec. |
'wire_corner'
|
straight_separation
|
float
|
from wire edge to edge. Defaults to xs.width+xs.gap |
15.0
|
pad_pitch
|
float
|
in um. Defaults to pad_pitch constant from the PDK. |
100.0
|
port_type
|
str
|
port type. |
'electrical'
|
allow_width_mismatch
|
bool
|
True |
True
|
fanout_length
|
float | None
|
if None, automatic calculation of fanout length. |
None
|
route_width
|
float | None
|
width of the route. If None, defaults to cross_section.width. |
0
|
bboxes
|
BoundingBoxes | None
|
list of bounding boxes to avoid. |
None
|
avoid_component_bbox
|
bool
|
True |
False
|
auto_taper
|
bool
|
adds tapers to the routing. |
True
|
kwargs
|
Any
|
additional arguments. |
{}
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
straight |
straight spec. |
|
get_input_label_text_loopback_function |
function to get input label test. |
|
get_input_label_text_function |
for labels. |
|
max_y0_optical |
in um. |
|
with_loopback |
True, adds loopback structures. |
|
list_port_labels |
None, adds TM labels to port indices in this list. |
|
connected_port_list_ids |
names of ports only for type 0 optical routing. |
|
nb_optical_ports_lines |
number of grating coupler lines. |
|
force_manhattan |
False |
|
excluded_ports |
list of port names to exclude when adding gratings. |
|
grating_indices |
list of grating coupler indices. |
|
routing_straight |
function to route. |
|
routing_method |
route_bundle. |
|
gc_rotation |
fiber coupler rotation in degrees. Defaults to -90. |
|
input_port_indexes |
to connect. |
|
allow_width_mismatch |
bool
|
True |
Example
import gdsfactory as gf
c = gf.c.nxn(
xsize=600,
ysize=200,
north=2,
south=3,
wg_width=10,
layer="M3",
port_type="electrical",
)
cc = gf.routing.add_pads_top(component=c, port_names=("e1", "e4"), fanout_length=50)
cc.plot()
Source code in gdsfactory/routing/add_pads.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
add_pads_bot
add_pads_bot(
component: ComponentSpec = "straight_heater_metal",
select_ports: SelectPorts = select_ports_electrical,
port_names: Strs | None = None,
cross_section: CrossSectionSpec = "metal_routing",
pad_port_name: str = "e1",
pad: ComponentSpec = "pad_rectangular",
bend: ComponentSpec = "wire_corner",
straight_separation: float = 15.0,
pad_pitch: float = 100.0,
port_type: str = "electrical",
allow_width_mismatch: bool = True,
fanout_length: float | None = None,
route_width: float | None = None,
bboxes: BoundingBoxes | None = None,
avoid_component_bbox: bool = False,
auto_taper: bool = True,
**kwargs: Any
) -> Component
Returns new component with ports connected bottom pads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
ComponentSpec
|
component spec to connect to. |
'straight_heater_metal'
|
select_ports
|
SelectPorts
|
function to select_ports. |
select_ports_electrical
|
port_names
|
Strs | None
|
optional port names. Overrides select_ports. |
None
|
cross_section
|
CrossSectionSpec
|
cross_section spec. |
'metal_routing'
|
get_input_labels_function
|
function to get input labels. None skips labels. |
required | |
layer_label
|
optional layer for grating coupler label. |
required | |
pad_port_name
|
str
|
pad input port name. |
'e1'
|
pad_port_labels
|
pad list of labels. |
required | |
pad
|
ComponentSpec
|
spec for route terminations. |
'pad_rectangular'
|
bend
|
ComponentSpec
|
bend spec. |
'wire_corner'
|
straight_separation
|
float
|
from wire edge to edge. Defaults to xs.width+xs.gap |
15.0
|
pad_pitch
|
float
|
in um. Defaults to pad_pitch constant from the PDK. |
100.0
|
port_type
|
str
|
port type. |
'electrical'
|
allow_width_mismatch
|
bool
|
True |
True
|
fanout_length
|
float | None
|
if None, automatic calculation of fanout length. |
None
|
route_width
|
float | None
|
width of the route. If None, defaults to cross_section.width. |
None
|
bboxes
|
BoundingBoxes | None
|
list bounding boxes to avoid for routing. |
None
|
avoid_component_bbox
|
bool
|
avoid component bbox for routing. |
False
|
auto_taper
|
bool
|
adds tapers to the routing. |
True
|
kwargs
|
Any
|
additional arguments. |
{}
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
straight |
straight spec. |
|
get_input_label_text_loopback_function |
function to get input label test. |
|
get_input_label_text_function |
for labels. |
|
max_y0_optical |
in um. |
|
with_loopback |
True, adds loopback structures. |
|
list_port_labels |
None, adds TM labels to port indices in this list. |
|
connected_port_list_ids |
names of ports only for type 0 optical routing. |
|
nb_optical_ports_lines |
number of grating coupler lines. |
|
force_manhattan |
False |
|
excluded_ports |
list of port names to exclude when adding gratings. |
|
grating_indices |
list of grating coupler indices. |
|
routing_straight |
function to route. |
|
routing_method |
route_bundle. |
|
gc_rotation |
fiber coupler rotation in degrees. Defaults to -90. |
|
input_port_indexes |
to connect. |
|
allow_width_mismatch |
bool
|
True |
Example
import gdsfactory as gf
c = gf.c.nxn(
xsize=600,
ysize=200,
north=2,
south=3,
wg_width=10,
layer="M3",
port_type="electrical",
)
cc = gf.routing.add_pads_bot(component=c, port_names=("e1", "e4"), fanout_length=50)
cc.plot()
Source code in gdsfactory/routing/add_pads.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
add_electrical_pads_shortest
add_electrical_pads_shortest
add_electrical_pads_shortest(
component: ComponentSpec = "wire_straight",
pad: ComponentSpec = "pad",
pad_port_spacing: float = 50.0,
pad_size: Size | None = None,
select_ports: PortsFactory = select_ports_electrical,
port_names: Strs | None = None,
port_orientation: AngleInDegrees = 90,
layer: LayerSpec = "M3",
) -> Component
Returns new Component with a pad by each electrical port.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
ComponentSpec
|
to route. |
'wire_straight'
|
pad
|
ComponentSpec
|
pad element or function. |
'pad'
|
pad_port_spacing
|
float
|
spacing between pad and port. |
50.0
|
pad_size
|
Size | None
|
pad size. |
None
|
select_ports
|
PortsFactory
|
function to select ports. |
select_ports_electrical
|
port_names
|
Strs | None
|
optional port names. Overrides select_ports. |
None
|
port_orientation
|
AngleInDegrees
|
in degrees. |
90
|
layer
|
LayerSpec
|
for the routing. |
'M3'
|
Example
import gdsfactory as gf
c = gf.components.cross(length=100, layer=(49, 0), port_type="electrical")
c = gf.routing.add_electrical_pads_shortest(c, pad_port_spacing=200)
c.plot()
Source code in gdsfactory/routing/add_electrical_pads_shortest.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
add_electrical_pads_top
add_electrical_pads_top
add_electrical_pads_top(
component: ComponentSpec,
direction: Literal["top", "right"] = "top",
spacing: Float2 = (0.0, 100.0),
pad_array: ComponentSpec = "pad_array",
select_ports: SelectPorts = select_ports_electrical,
port_names: Strs | None = None,
layer: LayerSpec = "MTOP",
**kwargs: Any
) -> Component
Returns new component with electrical ports connected to top pad array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
ComponentSpec
|
to route. |
required |
direction
|
Literal['top', 'right']
|
sets direction of the array (top or right). |
'top'
|
spacing
|
Float2
|
component to pad spacing. |
(0.0, 100.0)
|
pad_array
|
ComponentSpec
|
function for pad_array. |
'pad_array'
|
select_ports
|
SelectPorts
|
function to select electrical ports. |
select_ports_electrical
|
port_names
|
Strs | None
|
optional port names. Overrides select_ports. |
None
|
layer
|
LayerSpec
|
for the routes. |
'MTOP'
|
kwargs
|
Any
|
additional arguments. |
{}
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
ports |
Dict[str, Port] a port dict {port name: port}. |
|
prefix |
select ports with port name prefix. |
|
suffix |
select ports with port name suffix. |
|
orientation |
select ports with orientation in degrees. |
|
width |
select ports with port width. |
|
layers_excluded |
List of layers to exclude. |
|
port_type |
select ports with port type (optical, electrical, vertical_te). |
|
clockwise |
if True, sort ports clockwise, False: counter-clockwise. |
Example
import gdsfactory as gf
c = gf.components.wire_straight(length=200.)
cc = gf.routing.add_electrical_pads_top(component=c, spacing=(-150, 30))
cc.plot()
Source code in gdsfactory/routing/add_electrical_pads_top.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
add_electrical_pads_top_dc
add_electrical_pads_top_dc
add_electrical_pads_top_dc(
component: ComponentSpec,
spacing: Float2 = (0.0, 100.0),
pad_array: ComponentSpec = "pad_array270",
select_ports: SelectPorts = select_ports_electrical,
port_names: Strs | None = None,
cross_section: CrossSectionSpec = "metal_routing",
**kwargs: Any
) -> Component
Returns new component with electrical ports connected to top pad array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
ComponentSpec
|
component spec to connect to. |
required |
spacing
|
Float2
|
component to pad spacing. |
(0.0, 100.0)
|
pad_array
|
ComponentSpec
|
component factor for pad_array |
'pad_array270'
|
select_ports
|
SelectPorts
|
function to select_ports. |
select_ports_electrical
|
route_bundle_function
|
function to route bundle of ports. |
required | |
port_names
|
Strs | None
|
optional port names. Overrides select_ports. |
None
|
cross_section
|
CrossSectionSpec
|
cross_section for the route. |
'metal_routing'
|
kwargs
|
Any
|
route settings. |
{}
|
Example
import gdsfactory as gf
c = gf.components.wire_straight(length=200.)
c = gf.routing.add_electrical_pads_top_dc(c, width=10)
c.plot()
Source code in gdsfactory/routing/add_electrical_pads_top_dc.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |