Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export class LongDistancePairSolver extends BaseSolver {
primaryConnectedPinIds.add(pair.pins[1].pinId)
}

const { netConnMap } = getConnectivityMapsFromInputProblem(inputProblem)
const { directConnMap, netConnMap } =
getConnectivityMapsFromInputProblem(inputProblem)
this.netConnMap = netConnMap
const pinMap = new Map<PinId, InputPin & { chipId: string }>()
for (const chip of inputProblem.chips) {
Expand All @@ -72,8 +73,10 @@ export class LongDistancePairSolver extends BaseSolver {
> = []
const addedPairKeys = new Set<string>()

for (const netId of Object.keys(netConnMap.netMap)) {
const allPinIdsInNet = netConnMap.getIdsConnectedToNet(netId)
// Use directConnMap for candidate pair generation so that net-label-only
// connections don't produce long-distance traces.
for (const netId of Object.keys(directConnMap.netMap)) {
const allPinIdsInNet = directConnMap.getIdsConnectedToNet(netId)
if (allPinIdsInNet.length < 2) continue

const unconnectedPinIds = allPinIdsInNet.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export class MspConnectionPairSolver extends BaseSolver {
}
}

this.queuedDcNetIds = Object.keys(netConnMap.netMap)
// Only queue nets from the direct-connection map. Net-label-only nets
// (netConnections) should produce net labels, not MSP pairs / traces.
this.queuedDcNetIds = Object.keys(directConnMap.netMap)
}

override getConstructorParams(): ConstructorParameters<
Expand All @@ -93,7 +95,7 @@ export class MspConnectionPairSolver extends BaseSolver {

const dcNetId = this.queuedDcNetIds.shift()!

const allIds = this.globalConnMap.getIdsConnectedToNet(dcNetId) as string[]
const allIds = this.dcConnMap.getIdsConnectedToNet(dcNetId) as string[]
const directlyConnectedPins = allIds.filter((id) => !!this.pinMap[id])

if (directlyConnectedPins.length <= 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ export const getConnectivityMapsFromInputProblem = (
])
}

const netConnMap = new ConnectivityMap(directConnMap.netMap)
// Deep-clone the netMap so that netConnMap mutations (adding net-label
// connections) don't pollute directConnMap. Without this, net-label-only
// connections leak into directConnMap and cause spurious MSP pairs / traces.
const clonedNetMap: Record<string, string[]> = {}
for (const [key, ids] of Object.entries(directConnMap.netMap)) {
clonedNetMap[key] = [...ids]
}
const netConnMap = new ConnectivityMap(clonedNetMap)

for (const netConn of inputProblem.netConnections) {
netConnMap.addConnections([[netConn.netId, ...netConn.pinIds]])
Expand Down
64 changes: 35 additions & 29 deletions tests/examples/__snapshots__/example01.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading