feat(kicad9): snap 2-pin parts onto IC pins, power bus wires, label deconfliction#297
feat(kicad9): snap 2-pin parts onto IC pins, power bus wires, label deconfliction#297lachlanfysh wants to merge 2 commits into
Conversation
0162457 to
d7c302e
Compare
d7c302e to
e79fd48
Compare
e79fd48 to
7dced5b
Compare
|
Pushed two additional fixes addressing decoupling-cap visual issues observed on the Korg ER-1 successor schematic:
Observed on MR-1 schematic:
These were the two issues highlighted as the remaining visual gaps when reviewing the MR-1 generated schematic. |
When the connectivity-aware placer cannot route all nets, fallback placement now snaps 2-pin passive components (resistors, capacitors, LEDs) directly onto the IC pins they connect to. The algorithm runs three passes: 1. Direct snap — place each 2-pin part at its connected IC pin 2. Chain snap — extend chains (IC ← R ← LED) with occupied-pin tracking 3. Stack snap — stack parts sharing the same IC pin vertically Additional placement improvements: - Pre-shift ICs before stagger to prevent overlap - T-junction stagger for cleaner routing of fanout nets - Power cap offset from IC body with connecting wires Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…napped parts Improve schematic output quality when parts are snapped together: - Suppress redundant net labels when pins physically overlap (snapped) - Generate power bus wires connecting co-linear power net pins - Emit T-junction and power-cap wires from stagger placement data - Orient power symbols (GND down, VCC up) based on pin direction - Skip labels for NCNet pins and emit no_connect flags instead - Post-process label positions to avoid overlapping component bodies - Suppress NetTerminal labels when real pins already provide connectivity Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7dced5b to
143f45e
Compare
|
Thanks for your contribution! Please base your PR relative to the Also, your code seems to be doing a lot of place-and-route related work in the |
|
Thanks for the feedback! Rebasing onto Architecture split: Good point. The current split is:
The stub decision logic is already backend-agnostic. The snap/wire/label code is KiCad-specific because it needs pin world positions and S-expression geometry. I could refactor the geometric snap logic up to I'll get the rebase onto |
|
Closing in favor of a new PR targeting |
|
Both items addressed in #302:
|
What this does
When SKiDL's fallback placement kicks in (routing fails, schematic still needs to be readable), 2-pin passive parts used to float randomly around the page with net labels as the only clue they belonged to a particular IC. This PR makes the fallback output look like a human drew it.
Snap placement
Resistors, caps, LEDs, and switches now snap directly onto the IC pin they connect to, extending outward in the pin's direction. Three passes handle increasingly complex cases:
Decoupling caps get special treatment: they snap to power pins but offset away from the IC body so they don't obscure signal pins.
T-junction stagger
When an IC has a repeating pattern (3+ pins each driving the same number of parts, like 16 mux channels each with a pot), the parts are arranged in a stepped stagger extending outward from the IC. Each pin's group sits further from the body than the last, with junction wires connecting back. The step size adapts to the physical size of the parts being staggered (a row of switches needs more room than a row of resistors).
IC group redistribution
Before stagger fans are placed, ICs that will have large fans are shifted apart vertically so the fans don't overlap each other. Parts already snapped to the IC (from pass 1) move with it, so connectivity is preserved. The stagger fans are then placed at the final IC positions.
Power symbol orientation
GND bars and supply arrows now rotate to point away from their component pin. The previous code always placed them at angle 0, which meant ground symbols often sat on top of their IC instead of hanging below it. The fix accounts for the Y-axis flip between SKiDL's internal coordinate system (Y-up) and KiCad's schematic coordinates (Y-down).
Power bus wires
When multiple pins on the same power net are co-linear (e.g. a row of VCC pins along one side of an IC), a single bus wire connects them instead of each getting an independent power symbol.
Label cleanup
Redundant net labels on snapped pin clusters are suppressed (the physical wire connection makes them unnecessary). Label angles are computed from the transformed pin direction so they don't overlap their parent symbol.
Tested on
A 150+ part Daisy Seed carrier board design: CD74HC4067E mux with 16 pots, 4x SN74HC165N shift registers with 28 switches, 6x DM13A LED drivers with 85 LEDs, H11L1 optocoupler MIDI I/O, SSD1306 OLED, LD33V regulator. All through-hole DIP.