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
22 changes: 21 additions & 1 deletion lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ export class LongDistancePairSolver extends BaseSolver {
primaryConnectedPinIds.add(pair.pins[1].pinId)
}

// Build helpers to skip nets handled by net labels only (mirrors the same
// logic added to MspConnectionPairSolver for issue #79).
const directlyWiredPinIds = new Set<string>()
for (const dc of inputProblem.directConnections) {
for (const pid of dc.pinIds) directlyWiredPinIds.add(pid)
}
const netLabelOrientedNets = new Set<string>(
Object.keys(inputProblem.availableNetLabelOrientations ?? {}),
)

const { netConnMap } = getConnectivityMapsFromInputProblem(inputProblem)
this.netConnMap = netConnMap
const pinMap = new Map<PinId, InputPin & { chipId: string }>()
Expand All @@ -76,8 +86,18 @@ export class LongDistancePairSolver extends BaseSolver {
const allPinIdsInNet = netConnMap.getIdsConnectedToNet(netId)
if (allPinIdsInNet.length < 2) continue

// Skip nets that are represented by net labels only — they have no direct
// wire connections and have a configured label orientation.
const hasDirect = allPinIdsInNet.some((id: string) =>
directlyWiredPinIds.has(id),
)
const hasLabel = allPinIdsInNet.some((id: string) =>
netLabelOrientedNets.has(id),
)
if (!hasDirect && hasLabel) continue

const unconnectedPinIds = allPinIdsInNet.filter(
(pinId) => !primaryConnectedPinIds.has(pinId),
(pinId: string) => !primaryConnectedPinIds.has(pinId),
)

for (const unconnectedPinId of unconnectedPinIds) {
Expand Down
22 changes: 21 additions & 1 deletion lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,27 @@ export class MspConnectionPairSolver extends BaseSolver {
}
}

this.queuedDcNetIds = Object.keys(netConnMap.netMap)
// Only queue nets that need wire traces.
// Nets that are handled exclusively via netConnections with a configured
// net-label orientation should be represented by net labels only — routing
// a wire trace on top of them produces the spurious extra lines in #79.
const directlyWiredPinIds = new Set<string>()
for (const dc of inputProblem.directConnections) {
for (const pid of dc.pinIds) {
directlyWiredPinIds.add(pid)
}
}
const netLabelOrientedNets = new Set<string>(
Object.keys(inputProblem.availableNetLabelOrientations ?? {}),
)
this.queuedDcNetIds = Object.keys(netConnMap.netMap).filter((netId) => {
const connectedIds = netConnMap.getIdsConnectedToNet(netId) as string[]
// Always route if any pin has a direct wire connection.
if (connectedIds.some((id) => directlyWiredPinIds.has(id))) return true
// Skip nets that have a label orientation and no direct connections —
// NetLabelPlacementSolver will place the label instead.
return !connectedIds.some((id) => netLabelOrientedNets.has(id))
})
}

override getConstructorParams(): ConstructorParameters<
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