Generic
generic
Generic routing functions which are independent of the potential use.
ManhattanRoute
pydantic-model
Bases: BaseModel
Optical route containing a connection between two ports.
Attrs
backbone: backbone points start_port: port at the first instance denoting the start of the route end_port: port at the last instance denoting the end of the route instances: list of the instances in order from start to end of the route n_bend90: number of bends used length: length of the route without the bends length_straights: length of the straight_factory elements
Fields:
-
backbone(list[Point]) -
start_port(Port) -
end_port(Port) -
instances(list[Instance]) -
n_bend90(int) -
n_taper(int) -
bend90_radius(dbu) -
taper_length(dbu) -
length_straights(dbu) -
polygons(dict[LayerInfo, list[Polygon]]) -
length_function(LengthFunction)
Source code in kfactory/routing/generic.py
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 | |
length_backbone
property
length_backbone: dbu
Length of the backbone in dbu.
taper_length
pydantic-field
taper_length: dbu = 0
Length of backbone without the bends.
PlacerFunction
Bases: Protocol
A placer function. Used to place Instances given a path.
Source code in kfactory/routing/generic.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
__call__
__call__(
c: KCell,
p1: Port,
p2: Port,
pts: Sequence[Point],
route_width: int | None = None,
**kwargs: Any,
) -> ManhattanRoute
Implementation of the function.
Source code in kfactory/routing/generic.py
47 48 49 50 51 52 53 54 55 56 57 | |
check_collisions
check_collisions(
c: KCell,
start_ports: Sequence[BasePort],
end_ports: Sequence[BasePort],
routers: Sequence[ManhattanRouter],
routes: Sequence[ManhattanRoute],
on_collision: Literal["error", "show_error"]
| None = "show_error",
collision_check_layers: Sequence[LayerInfo]
| None = None,
) -> None
Checks for collisions given manhattan routes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
KCell
|
The KCell to check. |
required |
start_ports
|
Sequence[BasePort]
|
Ports from which the routes are supposed to start. |
required |
end_ports
|
Sequence[BasePort]
|
Ports where the routes are supposed to end. |
required |
routers
|
Sequence[ManhattanRouter]
|
The ManhattanRouters that constructed the routes. |
required |
routes
|
Sequence[ManhattanRoute]
|
The ManhatnnaRoutes which were used by the placer. |
required |
on_collision
|
Literal['error', 'show_error'] | None
|
What to do on error. Can either do nothing (None), throw an error ("error"), or throw an error and open the cell with report in Klayout ("show_error"). |
'show_error'
|
collision_check_layers
|
Sequence[LayerInfo] | None
|
Sequence of layers which should be checked for overlaps to determine error. If not defined, all layers occurring in ports will be used. |
None
|
Source code in kfactory/routing/generic.py
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 | |
get_radius
get_radius(ports: Sequence[ProtoPort[Any]]) -> dbu
Calculates a radius between two ports.
This can be used to determine the radius of two bend ports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ports
|
Sequence[ProtoPort[Any]]
|
A sequence of exactly two ports. |
required |
Returns:
| Type | Description |
|---|---|
dbu
|
Radius in dbu. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Radius cannot be determined |
Source code in kfactory/routing/generic.py
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 | |
route_bundle
route_bundle(
*,
c: KCell,
start_ports: list[BasePort],
end_ports: list[BasePort],
route_width: dbu | list[dbu] | None = None,
on_collision: Literal["error", "show_error"]
| None = "show_error",
on_placer_error: Literal["error", "show_error"]
| None = "show_error",
collision_check_layers: Sequence[LayerInfo]
| None = None,
routing_function: ManhattanBundleRoutingFunction = route_smart,
routing_kwargs: dict[str, Any] | None = None,
placer_function: PlacerFunction,
placer_kwargs: dict[str, Any] | None = None,
constraints: Sequence[Constraint] | None = None,
starts: dbu
| list[dbu]
| list[Step]
| list[list[Step]]
| None = None,
ends: dbu
| list[dbu]
| list[Step]
| list[list[Step]]
| None = None,
start_angles: int | list[int] | None = None,
end_angles: int | list[int] | None = None,
route_debug: RouteDebug | None = None,
route_name: str | None = None,
) -> list[ManhattanRoute]
Route a bundle from starting ports to end_ports.
Waypoints will create a front which will create ports in a 1D array. If waypoints are a transformation it will be like a point with a direction. If multiple points are passed, the direction will be invfered. For orientation of 0 degrees it will create the following front for 4 ports:
│
│
│
p1 ->
│
│
│
│
│
│
p2 ->
│
│
│
___\waypoint
/
│
│
│
p3 ->
│
│
│
│
│
│
p4 ->
│
│
│
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
KCell
|
Cell to place the route in. |
required |
start_ports
|
list[BasePort]
|
List of start ports. |
required |
end_ports
|
list[BasePort]
|
List of end ports. |
required |
route_width
|
dbu | list[dbu] | None
|
Width of the route. If None, the width of the ports is used. |
None
|
sort_ports
|
Automatically sort ports. |
required | |
on_collision
|
Literal['error', 'show_error'] | None
|
Define what to do on routing collision. Default behaviour is to open send the layout of c to klive and open an error lyrdb with the collisions. "error" will simply raise an error. None will ignore any error. |
'show_error'
|
on_placer_error
|
Literal['error', 'show_error'] | None
|
If a placing of the components fails, use the strategy above to handle the error. show_error will visualize it in klayout with the intended route along the already placed parts of c. Error will just throw an error. None will ignore the error. |
'show_error'
|
collision_check_layers
|
Sequence[LayerInfo] | None
|
Layers to check for actual errors if manhattan routes detect potential collisions. |
None
|
routing_function
|
ManhattanBundleRoutingFunction
|
Function to place the routes. Must return a corresponding list of OpticalManhattan routes. Must accept the following protocol: |
route_smart
|
routing_kwargs
|
dict[str, Any] | None
|
Additional kwargs passed to the placer_function. |
None
|
placer_function
|
PlacerFunction
|
Function to place the routes. Must return a corresponding list of OpticalManhattan routes. Must accept the following protocol: |
required |
placer_kwargs
|
dict[str, Any] | None
|
Additional kwargs passed to the placer_function. |
None
|
constraints
|
Sequence[Constraint] | None
|
Routing constraints to enforce after routing but before placement.
Each constraint's |
None
|
starts
|
dbu | list[dbu] | list[Step] | list[list[Step]] | None
|
List of steps to use on each starting port or all of them. |
None
|
ends
|
dbu | list[dbu] | list[Step] | list[list[Step]] | None
|
List of steps to use on each end port or all of them. |
None
|
start_angles
|
int | list[int] | None
|
Overwrite the port orientation of all start_ports together (single value) or each one (list of values which is as long as start_ports). |
None
|
end_angles
|
int | list[int] | None
|
Overwrite the port orientation of all start_ports together (single value) or each one (list of values which is as long as end_ports). |
None
|
Returns:
| Type | Description |
|---|---|
list[ManhattanRoute]
|
List of ManattanRoutes containing the instances of the route. |
Raises:
| Type | Description |
|---|---|
PlacerError
|
Something went wrong and the resulting route of the placer function is not manhattan or the elements cannot be fitted. |
ValueError
|
Ports or places or args are misconfigured. |
Source code in kfactory/routing/generic.py
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 | |