From 38af9bcc3d7403c3ab3a0bb5a33ba21aff16cc09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?0hm=E2=98=98=EF=B8=8F?= Date: Wed, 15 Oct 2025 06:33:51 +0530 Subject: [PATCH 1/6] Fix: extra net label in repro61, or remove trace --- .../LongDistancePairSolver.ts | 9 +- .../MspConnectionPairSolver.ts | 10 ++ tests/assets/unconnect-gnd-vcc.json | 1 + .../examples/__snapshots__/example29.snap.svg | 112 ++++++++++++++++++ tests/examples/example29.test.ts | 12 ++ 5 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 tests/assets/unconnect-gnd-vcc.json create mode 100644 tests/examples/__snapshots__/example29.snap.svg create mode 100644 tests/examples/example29.test.ts diff --git a/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts b/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts index 31e0df3..2bebb9e 100644 --- a/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts +++ b/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts @@ -72,8 +72,13 @@ export class LongDistancePairSolver extends BaseSolver { > = [] const addedPairKeys = new Set() - for (const netId of Object.keys(netConnMap.netMap)) { - const allPinIdsInNet = netConnMap.getIdsConnectedToNet(netId) + for (const internalNetId of Object.keys(netConnMap.netMap)) { + const [originalNetId, ...allPinIdsInNet] = netConnMap.getIdsConnectedToNet(internalNetId) + + if (originalNetId === "GND" || originalNetId === "VCC") { + continue + } + if (allPinIdsInNet.length < 2) continue const unconnectedPinIds = allPinIdsInNet.filter( diff --git a/lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts b/lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts index 48b46c9..c51b74c 100644 --- a/lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts +++ b/lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts @@ -94,6 +94,16 @@ export class MspConnectionPairSolver extends BaseSolver { const dcNetId = this.queuedDcNetIds.shift()! const allIds = this.globalConnMap.getIdsConnectedToNet(dcNetId) as string[] + + // Find the user-facing net ID (if any) to check for exclusion + const firstPinId = allIds.find((id) => !!this.pinMap[id]) + if (firstPinId) { + const userNetId = this.userNetIdByPinId[firstPinId] + if (userNetId === "GND" || userNetId === "VCC") { + return + } + } + const directlyConnectedPins = allIds.filter((id) => !!this.pinMap[id]) if (directlyConnectedPins.length <= 1) { diff --git a/tests/assets/unconnect-gnd-vcc.json b/tests/assets/unconnect-gnd-vcc.json new file mode 100644 index 0000000..a654cf7 --- /dev/null +++ b/tests/assets/unconnect-gnd-vcc.json @@ -0,0 +1 @@ +{"chips":[{"chipId":"schematic_component_0","center":{"x":2,"y":0},"width":0.53,"height":1.1,"pins":[{"pinId":"C1.1","x":2,"y":-0.55},{"pinId":"C1.2","x":2,"y":0.55}]},{"chipId":"schematic_component_1","center":{"x":0,"y":0},"width":0.53,"height":1.1,"pins":[{"pinId":"C2.1","x":-3.469446951953614e-17,"y":-0.55},{"pinId":"C2.2","x":3.469446951953614e-17,"y":0.55}]}],"directConnections":[],"netConnections":[{"netId":"GND","pinIds":["C1.1","C2.1"],"netLabelWidth":0.3},{"netId":"VCC","pinIds":["C1.2","C2.2"],"netLabelWidth":0.3}],"availableNetLabelOrientations":{"GND":["y-"],"VCC":["y+"]},"maxMspPairDistance":2.4} \ No newline at end of file diff --git a/tests/examples/__snapshots__/example29.snap.svg b/tests/examples/__snapshots__/example29.snap.svg new file mode 100644 index 0000000..686f3f3 --- /dev/null +++ b/tests/examples/__snapshots__/example29.snap.svg @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/examples/example29.test.ts b/tests/examples/example29.test.ts new file mode 100644 index 0000000..7b2910a --- /dev/null +++ b/tests/examples/example29.test.ts @@ -0,0 +1,12 @@ +import { test, expect } from "bun:test" +import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver" +import "tests/fixtures/matcher" +import inputProblem from "../assets/unconnect-gnd-vcc.json" + +test("example28", () => { + const solver = new SchematicTracePipelineSolver(inputProblem as any) + + solver.solve() + + expect(solver).toMatchSolverSnapshot(import.meta.path) +}) From f9346401931958a087434610e40d049c884af3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?0hm=E2=98=98=EF=B8=8F?= Date: Wed, 15 Oct 2025 07:07:14 +0530 Subject: [PATCH 2/6] WIP --- .../LongDistancePairSolver.ts | 3 +- .../examples/__snapshots__/example01.snap.svg | 67 +++++---- .../examples/__snapshots__/example02.snap.svg | 26 ++-- .../examples/__snapshots__/example12.snap.svg | 60 ++++---- .../examples/__snapshots__/example15.snap.svg | 84 +++++++---- .../examples/__snapshots__/example16.snap.svg | 57 ++++---- .../examples/__snapshots__/example21.snap.svg | 136 +++++++++--------- .../examples/__snapshots__/example22.snap.svg | 49 ++++--- .../examples/__snapshots__/example23.snap.svg | 49 ++++--- .../examples/__snapshots__/example24.snap.svg | 53 +++---- .../examples/__snapshots__/example27.snap.svg | 9 +- .../examples/__snapshots__/example29.snap.svg | 34 ++--- 12 files changed, 344 insertions(+), 283 deletions(-) diff --git a/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts b/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts index 2bebb9e..a06bdc2 100644 --- a/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts +++ b/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts @@ -73,7 +73,8 @@ export class LongDistancePairSolver extends BaseSolver { const addedPairKeys = new Set() for (const internalNetId of Object.keys(netConnMap.netMap)) { - const [originalNetId, ...allPinIdsInNet] = netConnMap.getIdsConnectedToNet(internalNetId) + const [originalNetId, ...allPinIdsInNet] = + netConnMap.getIdsConnectedToNet(internalNetId) if (originalNetId === "GND" || originalNetId === "VCC") { continue diff --git a/tests/examples/__snapshots__/example01.snap.svg b/tests/examples/__snapshots__/example01.snap.svg index 293bf05..d682db5 100644 --- a/tests/examples/__snapshots__/example01.snap.svg +++ b/tests/examples/__snapshots__/example01.snap.svg @@ -2,97 +2,106 @@ +x-" data-x="-0.8" data-y="0.2" cx="422.5742574257426" cy="303.36633663366337" r="3" fill="hsl(319, 100%, 50%, 0.8)" /> +x-" data-x="-0.8" data-y="0" cx="422.5742574257426" cy="325.54455445544556" r="3" fill="hsl(320, 100%, 50%, 0.8)" /> +x-" data-x="-0.8" data-y="-0.2" cx="422.5742574257426" cy="347.72277227722776" r="3" fill="hsl(321, 100%, 50%, 0.8)" /> +x+" data-x="0.8" data-y="-0.2" cx="600" cy="347.72277227722776" r="3" fill="hsl(322, 100%, 50%, 0.8)" /> +x+" data-x="0.8" data-y="0" cx="600" cy="325.54455445544556" r="3" fill="hsl(323, 100%, 50%, 0.8)" /> +x+" data-x="0.8" data-y="0.2" cx="600" cy="303.36633663366337" r="3" fill="hsl(324, 100%, 50%, 0.8)" /> +y+" data-x="-2" data-y="0.5" cx="289.50495049504957" cy="270.0990099009901" r="3" fill="hsl(121, 100%, 50%, 0.8)" /> +y-" data-x="-2" data-y="-0.5" cx="289.50495049504957" cy="380.99009900990103" r="3" fill="hsl(122, 100%, 50%, 0.8)" /> +y+" data-x="-4" data-y="0.5" cx="67.72277227722776" cy="270.0990099009901" r="3" fill="hsl(2, 100%, 50%, 0.8)" /> +y-" data-x="-4" data-y="-0.5" cx="67.72277227722776" cy="380.99009900990103" r="3" fill="hsl(3, 100%, 50%, 0.8)" /> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + + + + + + + @@ -161,20 +167,14 @@ x+" data-x="1" data-y="0.1" cx="500.20151295522464" cy="324.189420823755" r="3" - + - + - - - - - - @@ -194,7 +194,13 @@ x+" data-x="1" data-y="0.1" cx="500.20151295522464" cy="324.189420823755" r="3" - + + + + + + + diff --git a/tests/examples/__snapshots__/example12.snap.svg b/tests/examples/__snapshots__/example12.snap.svg index 42504a0..e05ba7a 100644 --- a/tests/examples/__snapshots__/example12.snap.svg +++ b/tests/examples/__snapshots__/example12.snap.svg @@ -2,88 +2,94 @@ +x+" data-x="1.1" data-y="0.2" cx="288.33702882483374" cy="210.56742672848225" r="3" fill="hsl(218, 100%, 50%, 0.8)" /> +x+" data-x="1.1" data-y="0" cx="288.33702882483374" cy="233.1435202580126" r="3" fill="hsl(219, 100%, 50%, 0.8)" /> +x+" data-x="1.1" data-y="-0.2" cx="288.33702882483374" cy="255.71961378754293" r="3" fill="hsl(220, 100%, 50%, 0.8)" /> +x-" data-x="0.5499999999999996" data-y="-1.7944553499999996" cx="226.25277161862525" cy="435.702479338843" r="3" fill="hsl(226, 100%, 50%, 0.8)" /> +x+" data-x="1.6499999999999997" data-y="-1.7944553499999996" cx="350.4212860310421" cy="435.702479338843" r="3" fill="hsl(227, 100%, 50%, 0.8)" /> +x-" data-x="2.3099999999999996" data-y="0.01999999999999985" cx="424.9223946784922" cy="230.88591090505957" r="3" fill="hsl(121, 100%, 50%, 0.8)" /> +x+" data-x="3.41" data-y="0.01999999999999985" cx="549.090909090909" cy="230.88591090505957" r="3" fill="hsl(122, 100%, 50%, 0.8)" /> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -811,30 +835,6 @@ y-" data-x="-2.025" data-y="-2.7" cx="318.5204755614267" cy="526.0237780713342" - - - - - - - - - - - - - - - - - - - - - - - - @@ -890,13 +890,37 @@ y-" data-x="-2.025" data-y="-2.7" cx="318.5204755614267" cy="526.0237780713342" - + + + + + + + + + + + + + + + + + + + + + + + + + - + - +