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
20 changes: 18 additions & 2 deletions lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,16 @@ export class MspConnectionPairSolver extends BaseSolver {
}
}

this.queuedDcNetIds = Object.keys(netConnMap.netMap)
// Queue all direct-wire nets from dcConnMap plus any nets that exist only in
// globalConnMap (net-label-only nets such as GND shared via netConnections).
// Because directConnMap and netConnMap now have independent netMap arrays (deep
// clone in getConnectivityMapsFromInputProblem), net-label pins that happen to
// share a name with a direct-wire pin are NOT merged into the direct-wire net.
const directNetIds = new Set(Object.keys(directConnMap.netMap))
const netLabelOnlyNetIds = Object.keys(netConnMap.netMap).filter(
(id) => !directNetIds.has(id),
)
this.queuedDcNetIds = [...directNetIds, ...netLabelOnlyNetIds]
}

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

const dcNetId = this.queuedDcNetIds.shift()!

const allIds = this.globalConnMap.getIdsConnectedToNet(dcNetId) as string[]
// For direct-wire nets use dcConnMap so that net-label-only pins merged into
// the same global net are not included in wire routing. For net-label-only
// nets (not present in dcConnMap) fall back to globalConnMap.
const dcIds = this.dcConnMap.getIdsConnectedToNet(dcNetId) as string[]
const allIds =
dcIds.length > 0
? dcIds
: (this.globalConnMap.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,12 @@ export const getConnectivityMapsFromInputProblem = (
])
}

const netConnMap = new ConnectivityMap(directConnMap.netMap)
// Deep-clone each array so that mutations in netConnMap (e.g. merging net-label
// pins into an existing direct-wire net) do NOT corrupt directConnMap.
const clonedNetMap = Object.fromEntries(
Object.entries(directConnMap.netMap).map(([k, v]) => [k, [...v]]),
)
const netConnMap = new ConnectivityMap(clonedNetMap)

for (const netConn of inputProblem.netConnections) {
netConnMap.addConnections([[netConn.netId, ...netConn.pinIds]])
Expand Down
12 changes: 6 additions & 6 deletions tests/examples/__snapshots__/example07.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 15 additions & 6 deletions tests/examples/__snapshots__/example13.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