Multi-layer crossing minimization for PCB connector pin assignment
Project description
PCB Crossing Optimizer
Multi-layer crossing minimization for PCB connector pin assignment. Detects trace crossings in SKiDL-generated KiCad netlists and computes optimal pin orderings for single-layer routing using Sugiyama-style barycenter sweep.
Installation
pip install pcb-crossing-optimizer
After installation, the pcb-crossing-optimizer command is available on your PATH.
Usage
The tool has two subcommands: analyze (default) and plan-footprint.
analyze (default)
Analyze crossings between component layers. This is the original behavior and remains the default when no subcommand is given.
pcb-crossing-optimizer [analyze] <netlist.net> --layers "L0_refs | L1_refs | L2_refs" --reorderable REF [REF ...] [--exclude REF:PIN ...] [--json] [--quiet]
Analyze the microSD breakout with passives in the middle layer:
pcb-crossing-optimizer examples/microsd_breakout.net --layers "J1 | R1,R2,C1 | J2" --reorderable J2 --exclude J1:SH
Simple two-connector case (just use two layers):
pcb-crossing-optimizer examples/i2c_breakout.net --layers "J1 | J2" --reorderable J2
JSON output for tooling integration:
pcb-crossing-optimizer examples/i2c_breakout.net --layers "J1 | J2" --reorderable J2 --json
Quiet mode for CI (exit code 0 = no crossings, 1 = crossings remain):
pcb-crossing-optimizer examples/i2c_breakout.net --layers "J1 | J2" --reorderable J2 --quiet
plan-footprint
Compute an optimal pin map for a custom footprint. Given a target component (whose footprint you are designing), fixed anchor components, and optional pin locks, it runs the crossing sweep and produces a complete pin-to-net assignment proposal.
pcb-crossing-optimizer plan-footprint <netlist.net> \
--target J1 \
--anchors "J2,U1 | R1,R2,R3,C1" \
--lock 1=NC 2=NC 3=GND_EARLY_A \
--unmatched end \
--exclude-nets GND \
[--json] [--quiet]
Options:
--target REF: Component whose footprint is being designed--anchors "...": Fixed components organized in layers separated by|--lock PIN=NET: Lock specific pins to nets (usePIN=NCfor no-connect)--unmatched start|end|split: Where to place pins with no anchor connections (default:end)--exclude-nets NET [NET ...]: Nets to exclude from analysis (e.g. ground pours)
Nets spanning non-adjacent layers (e.g., J1 to J2 through a passive layer) are handled automatically via virtual pass-through nodes.
How it works
- Parses a KiCad .net file (S-expression format generated by SKiDL)
- Extracts pin-to-net connectivity for specified components
- Sugiyama-style barycenter sweep across all layers:
- Inserts virtual nodes for long edges spanning non-adjacent layers
- Reorders both pins within reorderable components and components within layers
- Iterates forward/backward sweeps until convergence
- Reports current crossings, recommended reordering, and remaining crossings
Project structure
src/crossing_analyzer.py Core logic + CLI
tests/ pytest tests
examples/ Sample netlists for testing
Running tests
pip install pytest
pytest -v
Roadmap
- Passive placement optimizer (assign positions to resistors/caps in routing channel)
- F.Cu/B.Cu layer assignment for unavoidable crossings
- Migration to skidl-vscode extension (core/crossing.py + MCP tool + VS Code command)
Python import
The PyPI package name is pcb-crossing-optimizer, but the importable module is crossing_analyzer:
from crossing_analyzer import sweep_optimize, PinColumn, format_multilayer_report
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pcb_crossing_optimizer-0.4.0.tar.gz.
File metadata
- Download URL: pcb_crossing_optimizer-0.4.0.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c2e3c491a3cf2834aba1c5651fbebac84f4c1349fac4c6be1b3b0af08cf2b96
|
|
| MD5 |
5bbc26c5efa7e515f0b20414d514363b
|
|
| BLAKE2b-256 |
61304fbade0343774be69b89a7b388e288aba260a8491ba3a86f76bc0e4e90ac
|
Provenance
The following attestation bundles were made for pcb_crossing_optimizer-0.4.0.tar.gz:
Publisher:
publish.yml on ashergarland/pcb-crossing-optimizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pcb_crossing_optimizer-0.4.0.tar.gz -
Subject digest:
3c2e3c491a3cf2834aba1c5651fbebac84f4c1349fac4c6be1b3b0af08cf2b96 - Sigstore transparency entry: 1392578168
- Sigstore integration time:
-
Permalink:
ashergarland/pcb-crossing-optimizer@fc2c19891ae5de53ca8c23aee4dbf78d098b032e -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/ashergarland
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fc2c19891ae5de53ca8c23aee4dbf78d098b032e -
Trigger Event:
push
-
Statement type:
File details
Details for the file pcb_crossing_optimizer-0.4.0-py3-none-any.whl.
File metadata
- Download URL: pcb_crossing_optimizer-0.4.0-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14a13551006245e177c3e7f0b5492bcbcc502127ae99535bfe03b60c1aca8684
|
|
| MD5 |
2065e785de54f7daeb945145eac0590b
|
|
| BLAKE2b-256 |
41d54f97dbd96a56e334962be1834261c843f3de643ac8f43f41f9047555343c
|
Provenance
The following attestation bundles were made for pcb_crossing_optimizer-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on ashergarland/pcb-crossing-optimizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pcb_crossing_optimizer-0.4.0-py3-none-any.whl -
Subject digest:
14a13551006245e177c3e7f0b5492bcbcc502127ae99535bfe03b60c1aca8684 - Sigstore transparency entry: 1392578174
- Sigstore integration time:
-
Permalink:
ashergarland/pcb-crossing-optimizer@fc2c19891ae5de53ca8c23aee4dbf78d098b032e -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/ashergarland
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fc2c19891ae5de53ca8c23aee4dbf78d098b032e -
Trigger Event:
push
-
Statement type: