Live Agent working · engine-01 Placer/router engine positioning
DC-05 — PCB Design Automation

PCB Pipeline

The fully automated PCB design pipeline: TOML board definition, Rust analytical placement, 3D visibility-graph routing, KiCad DRC validation, and rendering. No manual KiCad steps. See the product-facing Placer/Router Engine page for the higher-level story.

V2 IMPROVEMENTS
2-3s
Route Time
was 300-400s
0
Failed Nets
was 22
0
Shorts
was 199
Rust
Router Engine
visibility graph + A*
OVERVIEW

mise run kicad:build runs the full pipeline end-to-end. Every step is scripted. The only manual interaction is reviewing renders. The board definition lives in kehvm.toml (7 subcircuits), parsed by the Rust designgraph crate.

Design spec DesignGraph Placement Vias placed Routed .kicad_pcb Pass Fail kehvm.tomlHierarchical board definition designgraphTyped Rust source of truth crates/placerRust analytical placement plane access plannerPer-pad GND + power access crates/router3D VG + A* + Pathfinder kicad-cli pcb drcDesign rules check kicad-cli pcb renderPNG + GLB export
INPUTS

TOML board definition, Python constraints, KiCad symbol libraries, board config

OUTPUTS

Routed .kicad_pcb, PNG renders, GLB 3D model, DRC report

LAYER STACKUP

6-layer board: three signal layers with GND pours, a dedicated GND plane, a +3V3 plane, and a +1V2 plane. Power nets (GND, +3V3, +1V2, +1V8, +2V5, +5V) are connected via copper planes, not routed traces. Per-GND-pad vias connect pads into the GND pours and plane.

6-Layer Stackup F.Cu — Signal + GND Pour In1.Cu — Signal + GND Pour In2.Cu — GND Plane In3.Cu — +3V3 Plane In4.Cu — +1V2 Plane B.Cu — Signal + GND Pour
PLACEMENT — crates/placer

Placement happens in three phases. Phase 1 anchors immovable components: module sockets flush to board edges, connectors distributed along edges using best-fit-decreasing, and near-constrained decoupling caps placed by topological sort.

Phase 2 runs the canonical Rust analytical placer — a Nesterov gradient descent optimizer that simultaneously minimizes wirelength (LSE-smoothed HPWL), density (ePlace electric field), BGA escape violations, and near-constraint distances. RUDY congestion feedback steers components away from routing bottlenecks. Gamma doubles every 200 iterations for coarse-to-fine refinement.

Phase 3 legalizes (resolve overlaps), places silkscreen labels, creates copper zones, generates the USGC cartouche, and verifies no edge/overlap violations remain.

Phase 1 — Anchor Phase 2 — Analytical Placer Phase 3 — Finalize Board Outline120 x 92mm Edge.Cuts Geometry ScanRead footprint BBoxes + pads Module HeadersESP32 left, Duo S right Edge Connectors6 connectors, best-fit Near ConstraintsTopo-sort + radial search Warm StartV3 greedy positions Nesterov GD Loopup to 5000 iterations WirelengthLSE DensityField BGAEscape NearPenalty RUDY Congestion Gamma Schedule Legalization Label Placement Copper Zones Silkscreen Verification
OBJECTIVE TERMS

WirelengthLSE, DensityField, BGAEscape, NearPenalty

SCHEDULE

Gamma x2 every 200 iters, RUDY every 50, density weight adaptive

CONVERGENCE

Up to 5000 iterations, Nesterov momentum 0.9, LR 0.05um

LEGALIZATION

Greedy sort-and-place, then iterative push-apart (up to 500 iters)

ROUTING — Rust Visibility-Graph Router

V2 replaces the old grid router and KiCadRoutingTools pipeline with a Rust visibility-graph router that runs in 2-3 seconds (down from 300-400s). The router builds a visibility graph from axis-aligned obstacle corners, then runs A* pathfinding with push-and-shove rip-up negotiation.

BGA fanout uses classify_net to identify differential pairs vs. single-ended signals, applies cumulative stagger offsets for clean escape routing, and preserves pair symmetry. Power vias are placed in Rust by add_power_vias.py before routing begins, connecting each GND pad to the In1.Cu ground plane.

Each successfully routed trace becomes an obstacle for subsequent nets. PathFinder-style congestion negotiation runs multiple iterations, re-ordering failed nets first. The router handles multi-pin nets via MST decomposition into 2-pin segments.

Placed .kicad_pcbwith power vias Stage 1: BGA Fanoutclassify_net, cumulative stagger, diff pairs Stage 2: Differential PairsCSI + ETH, impedance-controlled Stage 3: Power Routing+1V2, +2V5 via Rust VG Stage 4: Signal NetsSingle-ended, push-and-shove Stage 5: FallbackFull stackup, remaining nets Routed .kicad_pcb
ROUTER ENGINE

Visibility graph + A* + rstar R-tree spatial index, push-and-shove rip-up

DIFF PAIRS

CSI_* (camera), ETH_* (ethernet) — impedance-controlled, pair-aware BGA fanout

PERFORMANCE

Benchmark-backed route closure with KiCad DRC feedback, not hand-routed geometry

V2 PIPELINE DETAIL
TOML Design (kehvm.toml — 7 subcircuits)
DesignGraph (Rust crate, PyO3 bindings)
Rust Analytical Placer (Nesterov, HPWL, density, RUDY)
Legalize + edge/module constraints + clearance nudge
Plane access planning + per-GND-pad vias
Rust VG Router (3D visibility graph + A*)
1. BGA Fanout (classify_net, cumulative stagger, diff pair symmetry)
2. Differential Pairs (CSI + ETH, impedance-controlled)
3. Power Routing (+1V2, +2V5 via VG engine)
4. Signal Nets (push-and-shove, PathFinder congestion)
5. Fallback (full stackup, remaining nets)
Add Zones + Cartouche + KiCad DRC + 3D/2D Renders
WHAT CHANGED FROM V1
REMOVED

Grid router (0.1mm cell arrays), continuous_router, trace_nudge post-processing, KiCadRoutingTools dependency, CBS conflict detection module. The grid approach was fundamentally limited: 300-400s route time, 199 shorts from net_excluded overriding trace_blocked in dense BGA regions.

ADDED

Visibility-graph router with continuous coordinates (no grid quantization), rstar R-tree spatial index for O(log n) obstacle queries, push-and-shove rip-up negotiation, classify_net BGA fanout with cumulative stagger, per-GND-pad power vias in Rust, DesignGraph TOML-to-KiCad pipeline with PyO3 bindings.

RESULT

Continuous geometry, 3D A* routing, and DRC-guided repair replaced the retired grid path. The improvement is measured by isolated pipeline runs, not by manual board editing.

KEY FILES
hardware/design/kehvm.tomlHierarchical TOML board definition (7 subcircuits)
crates/designgraph/Rust: TOML to DesignGraph to KiCad export, PyO3 bindings
crates/router/src/router_engine.rsRust: VG router with A* pathfinding + push-and-shove
crates/router/src/bga_fanout.rsRust: BGA escape routing with classify_net + cumulative stagger
crates/router/src/power_vias.rsRust: Per-GND-pad vias + power plane via drops
scripts/kicad/gen_schematics.pyGenerates .kicad_sch files + kvm_constraints()
crates/placerCanonical Rust analytical placer used by pipeline:zero
crates/router3D VG router, Pathfinder negotiation, dense escape, repair, and via validation
scripts/kicad/convergence.pyAutomatic placement/routing/DRC feedback loop
crates/pipelineCanonical orchestration from TOML to DRC and bench artifacts
DEBUG VISUALIZATIONS

The router emits debug SVGs for every routing run. These show the obstacle field, any clearance violations, and per-net route paths overlaid on the visibility-graph node cloud. Obstacles are color-coded by net ownership: orange for one net family, blue for another. Routed paths show the A* solution through VG corner nodes.

OBSTACLE MAP
Router obstacle map showing all pad and via obstacles as axis-aligned rectangles

392 axis-aligned rectangle obstacles extracted from the placed PCB. Each pad, via, and keepout zone becomes a rectangle in the visibility graph. Orange = net family A, blue = net family B. The dashed border is the board outline (120 x 92mm).

CLEARANCE VIOLATIONS
Clearance violations showing where routed traces clip obstacle boundaries

Red crosshatch overlay marks where routed traces violate minimum clearance to obstacle boundaries. These violations drive the push-and-shove rip-up iterations. Reducing these to zero is the convergence target.

PER-NET ROUTE TRACES
HDMICP net route through visibility graph

HDMICP — HDMI clock positive. 6-point path through 2,294 VG nodes. The colored path shows the A* solution; small circles are the VG node cloud at obstacle corners.

XTAL_IN net route through visibility graph

XTAL_IN — HDMI transmitter crystal input. Multi-segment path navigating dense BGA escape region with tight obstacle spacing.

CEC net route through visibility graph

CEC — HDMI Consumer Electronics Control bus. Single-ended signal routed through the connector region on F.Cu.

INTERACTIVE ROUTER DEMO

The same visibility-graph A* router that runs in the PCB pipeline, compiled to WebAssembly and running in your browser. Click to set a source point, shift-click to set a target point. The router computes the shortest obstacle-avoiding path in real time. The demo obstacles below are a simplified subset of the actual board.

Source (click) Target (shift-click) Obstacle VG node Route
Loading WASM router...
REAL BOARD ROUTING

All 392 obstacles from the actual KVM board loaded into the WASM router. Click and shift-click to route between any two points on the real board layout. The obstacle density in the BGA regions (center-left and center-right clusters) shows why escape routing is the hardest part of this design.

Loading board data...
INTERACTIVE PLACER DEMO

The same simulated annealing placer used in the PCB pipeline, compiled to WebAssembly. 12 components are randomly placed on a board with interconnecting nets. Click Optimize to run 50,000 SA iterations — the placer minimizes total wirelength (HPWL) while eliminating component overlaps.

Component Net connection
Loading WASM placer...