diff --git a/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts b/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts index 9911d394..fe8f2d74 100644 --- a/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts +++ b/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts @@ -67,6 +67,17 @@ export class LongDistancePairSolver extends BaseSolver { } } + // Pins that participate in an explicit direct connection. Nets that are + // made up purely of net-label connections should not be connected with a + // (long-distance) trace "jumping" between their pins; each pin is instead + // represented with its own net label. + const directlyWiredPinIds = new Set() + for (const dc of inputProblem.directConnections) { + for (const pid of dc.pinIds) { + directlyWiredPinIds.add(pid) + } + } + // 2. Generate candidate pairs using N-Nearest-Neighbors approach const candidatePairs: Array< [InputPin & { chipId: string }, InputPin & { chipId: string }] @@ -77,6 +88,9 @@ export class LongDistancePairSolver extends BaseSolver { const allPinIdsInNet = netConnMap.getIdsConnectedToNet(netId) if (allPinIdsInNet.length < 2) continue + // Skip net-label-only nets (no pin has a direct connection) + if (!allPinIdsInNet.some((id) => directlyWiredPinIds.has(id))) continue + const unconnectedPinIds = allPinIdsInNet.filter( (pinId) => !primaryConnectedPinIds.has(pinId), ) diff --git a/lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts b/lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts index 5aae3806..874d0b17 100644 --- a/lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts +++ b/lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts @@ -75,7 +75,20 @@ export class MspConnectionPairSolver extends BaseSolver { } } - this.queuedDcNetIds = Object.keys(netConnMap.netMap) + // Only run the MSP/trace solver for nets that contain at least one pin + // with an explicit direct connection. Nets that are made up purely of + // net-label connections should be represented with separate net labels on + // each pin instead of a trace "jumping" between them. + const directlyWiredPinIds = new Set() + for (const dc of inputProblem.directConnections) { + for (const pid of dc.pinIds) { + directlyWiredPinIds.add(pid) + } + } + this.queuedDcNetIds = Object.keys(netConnMap.netMap).filter((netId) => { + const connectedIds = netConnMap.getIdsConnectedToNet(netId) as string[] + return connectedIds.some((id) => directlyWiredPinIds.has(id)) + }) } override getConstructorParams(): ConstructorParameters< diff --git a/site/examples/example35.page.tsx b/site/examples/example35.page.tsx new file mode 100644 index 00000000..2279aff0 --- /dev/null +++ b/site/examples/example35.page.tsx @@ -0,0 +1,4 @@ +import { PipelineDebugger } from "site/components/PipelineDebugger" +import inputProblem from "../../tests/assets/example35.json" + +export default () => diff --git a/tests/assets/example35.json b/tests/assets/example35.json new file mode 100644 index 00000000..6cdfc5eb --- /dev/null +++ b/tests/assets/example35.json @@ -0,0 +1,62 @@ +{ + "chips": [ + { + "chipId": "C2", + "center": { + "x": 0, + "y": 0 + }, + "width": 0.4, + "height": 1, + "pins": [ + { + "pinId": "C2.1", + "x": 0, + "y": 0.5 + }, + { + "pinId": "C2.2", + "x": 0, + "y": -0.5 + } + ] + }, + { + "chipId": "C1", + "center": { + "x": 2, + "y": 0 + }, + "width": 0.4, + "height": 1, + "pins": [ + { + "pinId": "C1.1", + "x": 2, + "y": 0.5 + }, + { + "pinId": "C1.2", + "x": 2, + "y": -0.5 + } + ] + } + ], + "directConnections": [], + "netConnections": [ + { + "pinIds": ["C1.1", "C2.1"], + "netId": "GND" + }, + { + "pinIds": ["C1.2", "C2.2"], + "netId": "VCC" + } + ], + "availableNetLabelOrientations": { + "GND": ["y+"], + "VCC": ["y-"] + }, + "maxMspPairDistance": 5 +} diff --git a/tests/examples/__snapshots__/example01.snap.svg b/tests/examples/__snapshots__/example01.snap.svg index 2614ba80..4829176e 100644 --- a/tests/examples/__snapshots__/example01.snap.svg +++ b/tests/examples/__snapshots__/example01.snap.svg @@ -2,106 +2,111 @@ +x-" data-x="-0.8" data-y="0.2" cx="422.5742574257426" cy="289.44950495049505" r="3" fill="hsl(319, 100%, 50%, 0.8)" /> +x-" data-x="-0.8" data-y="0" cx="422.5742574257426" cy="311.62772277227725" r="3" fill="hsl(320, 100%, 50%, 0.8)" /> +x-" data-x="-0.8" data-y="-0.2" cx="422.5742574257426" cy="333.80594059405945" r="3" fill="hsl(321, 100%, 50%, 0.8)" /> +x+" data-x="0.8" data-y="-0.2" cx="600" cy="333.80594059405945" r="3" fill="hsl(322, 100%, 50%, 0.8)" /> +x+" data-x="0.8" data-y="0" cx="600" cy="311.62772277227725" r="3" fill="hsl(323, 100%, 50%, 0.8)" /> +x+" data-x="0.8" data-y="0.2" cx="600" cy="289.44950495049505" r="3" fill="hsl(324, 100%, 50%, 0.8)" /> +y+" data-x="-2" data-y="0.5" cx="289.50495049504957" cy="256.1821782178218" r="3" fill="hsl(121, 100%, 50%, 0.8)" /> +y-" data-x="-2" data-y="-0.5" cx="289.50495049504957" cy="367.0732673267327" r="3" fill="hsl(122, 100%, 50%, 0.8)" /> +y+" data-x="-4" data-y="0.5" cx="67.72277227722776" cy="256.1821782178218" r="3" fill="hsl(2, 100%, 50%, 0.8)" /> +y-" data-x="-4" data-y="-0.5" cx="67.72277227722776" cy="367.0732673267327" r="3" fill="hsl(3, 100%, 50%, 0.8)" /> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + +globalConnNetId: connectivity_net0" data-x="-1.1" data-y="0.42500000000000016" x="378.21782178217825" y="239.54851485148515" width="22.178217821782198" height="49.9009900990099" fill="#ef444466" stroke="#ef4444" stroke-width="0.009017857142857143" /> +globalConnNetId: connectivity_net1" data-x="-1.5" data-y="0" x="320" y="300.5386138613862" width="49.90099009900996" height="22.17821782178214" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.009017857142857143" /> + + + + + + +globalConnNetId: connectivity_net2" data-x="-2" data-y="-0.726" x="278.41584158415844" y="367.1841584158416" width="22.178217821782198" height="49.90099009900996" fill="#00000066" stroke="#000000" stroke-width="0.009017857142857143" />