netlist ¤
circulax netlists.
Supports both kfnetlist.Netlist (primary) and SAX-format dicts (backward compat). SAX dicts are converted to kfnetlist.Netlist via :func:sax_to_kfnetlist before node-index assignment.
Functions:
| Name | Description |
|---|---|
build_net_map | Maps every port (e.g. 'R1,p1') to a generic Node Index (integer). |
build_net_map_kfnetlist | Map every port in a kfnetlist.Netlist to a node index. |
draw_circuit_graph | Visualize a circuit netlist as a connectivity graph. |
flatten_recursive_netlist | Flatten a |
sax_to_kfnetlist | Convert a SAX-format netlist dict to a |
Attributes:
| Name | Type | Description |
|---|---|---|
circulaxNetlist | Legacy SAX-format netlist type. Prefer |
circulaxNetlist module-attribute ¤
circulaxNetlist = Annotated[
TypedDict(
"Netlist",
{
"instances": Instances,
"connections": NotRequired[Connections],
"ports": Ports,
"placements": NotRequired[Placements],
"settings": NotRequired[Settings],
},
),
bval(val_netlist),
]
Legacy SAX-format netlist type. Prefer kfnetlist.Netlist for new code.
build_net_map ¤
Maps every port (e.g. 'R1,p1') to a generic Node Index (integer).
Returns:
| Name | Type | Description |
|---|---|---|
port_to_idx | dict[str, int] | dict mapping 'Instance,Pin' -> int index |
num_nets | int | Total number of unique electrical nodes (excluding Ground). |
Source code in circulax/netlist.py
build_net_map_kfnetlist ¤
Map every port in a kfnetlist.Netlist to a node index.
Each Net in the netlist becomes one electrical node. Nets containing a ground instance port, or a synthetic net label containing "GND", are assigned node index 0.
Returns:
| Name | Type | Description |
|---|---|---|
port_to_idx | dict[str, int] |
|
num_nets | int | next free node index (== number of non-ground nets + 1). |
Source code in circulax/netlist.py
draw_circuit_graph ¤
draw_circuit_graph(
netlist: dict[str, dict] | Netlist, layout_attempts: int = 10, *, show: bool = True
) -> Figure
Visualize a circuit netlist as a connectivity graph.
Accepts either a SAX-format dict or a kfnetlist.Netlist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
netlist | dict[str, dict] | Netlist | Circuit description (SAX dict or kfnetlist.Netlist). | required |
show | bool | If | True |
layout_attempts | int | Number of spring-layout seeds to try. | 10 |
Returns:
| Name | Type | Description |
|---|---|---|
The | Figure | class: |
Source code in circulax/netlist.py
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 | |
flatten_recursive_netlist ¤
Flatten a RecursiveNetlist into a single SAX-format netlist.
A RecursiveNetlist is a dict[str, Netlist] where the first key is the top-level circuit and remaining keys define subcircuits. An instance whose component string matches a key in the dict is treated as a subcircuit and inlined with prefixed instance names.
Handles circulax connection extensions (tuple targets, nets lists) that SAX's own flatten_netlist does not support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recnet | dict[str, dict] | Mapping from circuit name to SAX-format netlist dict. | required |
sep | str | Separator for hierarchical instance names (default | '~' |
Returns:
| Type | Description |
|---|---|
dict | A flat SAX-format netlist dict. |
Source code in circulax/netlist.py
sax_to_kfnetlist ¤
Convert a SAX-format netlist dict to a kfnetlist.Netlist.
Pairwise SAX connections (and GDSFactory-style nets lists) are grouped into equivalence classes via union-find, then emitted as one kfnetlist.Net per class.
Returns:
| Type | Description |
|---|---|
Netlist | A 2-tuple |
dict[str, dict[str, Any]] | settings_override maps instance names to their full settings |
tuple[Netlist, dict[str, dict[str, Any]]] | dict (including non-JSON-safe values such as complex numbers). |
tuple[Netlist, dict[str, dict[str, Any]]] | When all settings are JSON-safe the override dict is empty. |
Source code in circulax/netlist.py
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 | |