Specialized decoupling-cap layout with VCC-pin alignment (#15)#94
Specialized decoupling-cap layout with VCC-pin alignment (#15)#94s300169140 wants to merge 1 commit into
Conversation
…it#15) closes tscircuit#15 Adds a specialized layout path for partitions tagged \`partitionType: "decoupling_caps"\`. Instead of running them through the generic \`PackSolver2\`, the caps are placed in a centered horizontal row, each rotated so its positive-voltage pin consistently faces the same direction across the row. Why rotation alignment matters: a hand-drawn schematic of decoupling caps always has every cap oriented identically (VCC up, GND down, or the opposite) — never alternating. The previous layout code (and an alternative attempt in tscircuit#59) just used \`availableRotations[0]\`, which left mixed orientations whenever the input was wired with VCC on different pins of different caps. Algorithm: 1. For each cap in the partition, find which pin (if any) is connected to a positive-voltage net (\`netMap[netId].isPositiveVoltageSource\`) 2. Pick a target side for that pin via majority vote of the caps' natural-rotation positions (preferring \`y+\` on ties), so already- correctly-oriented caps don't get unnecessarily rotated 3. For each cap, pick the rotation from \`availableRotations\` that puts its positive pin on the target side; fall back to the first allowed rotation when the cap has no voltage signal Caps are then laid out left-to-right with \`decouplingCapsGap\` (or \`chipGap\` as fallback) and the resulting row is centered on x=0. Tests added: - happy-path: three caps where one is wired backwards; verifies it gets flipped 180° while the others keep their natural rotation - no-voltage-signal: cap with no positive-voltage net falls back to \`availableRotations[0]\` Note: the existing test \`IdentifyDecouplingCapsSolver06.test.ts\` fails on \`main\` due to an unrelated import error in the linked \`LayoutPipelineSolver06.page.tsx\`. That failure is unchanged by this PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@s300169140 is attempting to deploy a commit to the tscircuit Team on Vercel. A member of the Team first needs to authorize it. |
|
Heads up on the red 'test' check — that failure is pre-existing on The error is a transitive dep version mismatch:
You can confirm by running I deliberately didn't touch deps in this PR to keep the diff minimal and focused on #15. Two clean follow-up options when you're ready:
Happy to send the fix as a separate PR if helpful. Just wanted to make sure the red badge doesn't read as 'this PR broke tests' — the new tests I added ( |
Closes #15.
What
Adds a dedicated layout path for partitions tagged `partitionType: "decoupling_caps"`. Caps are placed in a centered horizontal row, each rotated so its positive-voltage pin consistently faces the same direction across the row.
Why rotation alignment matters
In a clean schematic, all decoupling caps in a row should be oriented identically — every VCC pin pointing the same way (typically up). Mixed orientations make the schematic look messy even when the geometry is otherwise correct.
The straightforward "linear row" approach (which is also what #59 implements) just calls `availableRotations[0]` per cap. That works when all caps happen to be wired with VCC on the same pin number, but breaks the moment one cap is wired backwards (which happens whenever a maintainer drops in a cap from a different reference design).
This PR adds the bit that makes the row look uniform: it picks each cap's rotation based on which pin is actually connected to a positive-voltage net.
Algorithm
Caps are then laid out left-to-right using `decouplingCapsGap` (or `chipGap`) and the row is centered on x=0.
Tests
Relationship to #59
#59 (h/t @Ojas2095) implements the same overall pattern (special-case for `decoupling_caps` → linear row) and is a good baseline. The differences are:
If you'd prefer #59's broader changes plus the rotation alignment from this PR, happy to rebase mine on top.
Verification