Skip to content

Commit d118b62

Browse files
authored
Merge pull request #23 from 0hmX/pre-exit-if-fount-an-port-that-contains-an-net-belong-to-same-connection-and-go-to-the-same-obstacle
Pre exit if fount an port that contains an net belong to same connection and go to the same obstacle
2 parents 799acad + 53a9235 commit d118b62

File tree

5 files changed

+41
-20
lines changed

5 files changed

+41
-20
lines changed

lib/core.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export interface Candidate {
122122
}
123123

124124
export interface TinyHyperGraphWorkingState {
125-
// portAssignment[portId] = RouteId, -1 means unassigned
125+
// portAssignment[portId] = NetId, -1 means unassigned
126126
portAssignment: Int32Array
127127

128128
// regionSegments[regionId] = Array<Route Assignment and Two Ports>
@@ -381,19 +381,18 @@ export class TinyHyperGraphSolver extends BaseSolver {
381381
topology.regionIncidentPorts[currentCandidate.nextRegionId]
382382

383383
for (const neighborPortId of neighbors) {
384-
const assignedRouteId = state.portAssignment[neighborPortId]
384+
const assignedNetId = state.portAssignment[neighborPortId]
385385
if (this.isPortReservedForDifferentNet(neighborPortId)) continue
386386
if (neighborPortId === state.goalPortId) {
387-
if (
388-
assignedRouteId !== -1 &&
389-
problem.routeNet[assignedRouteId] !== state.currentRouteNetId
390-
) {
387+
if (assignedNetId !== -1 && assignedNetId !== state.currentRouteNetId) {
391388
continue
392389
}
393390
this.onPathFound(currentCandidate)
394391
return
395392
}
396-
if (assignedRouteId !== -1) continue
393+
if (assignedNetId !== -1 && assignedNetId !== state.currentRouteNetId) {
394+
continue
395+
}
397396
if (neighborPortId === currentCandidate.portId) continue
398397
if (problem.portSectionMask[neighborPortId] === 0) continue
399398

@@ -765,8 +764,8 @@ export class TinyHyperGraphSolver extends BaseSolver {
765764
fromPortId,
766765
toPortId,
767766
])
768-
state.portAssignment[fromPortId] = currentRouteId
769-
state.portAssignment[toPortId] = currentRouteId
767+
state.portAssignment[fromPortId] = state.currentRouteNetId!
768+
state.portAssignment[toPortId] = state.currentRouteNetId!
770769
this.appendSegmentToRegionCache(regionId, fromPortId, toPortId)
771770
}
772771

lib/section-solver/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ const applyRouteSegmentsToSolver = (
374374
fromPortId,
375375
toPortId,
376376
])
377-
solver.state.portAssignment[fromPortId] = routeId
378-
solver.state.portAssignment[toPortId] = routeId
377+
solver.state.portAssignment[fromPortId] = solver.state.currentRouteNetId
378+
solver.state.portAssignment[toPortId] = solver.state.currentRouteNetId
379379
solver.appendSegmentToRegionCache(regionId, fromPortId, toPortId)
380380
}
381381
}
@@ -623,8 +623,8 @@ class TinyHyperGraphSectionSearchSolver extends TinyHyperGraphSolver {
623623
fromPortId,
624624
toPortId,
625625
])
626-
this.state.portAssignment[fromPortId] = routePlan.routeId
627-
this.state.portAssignment[toPortId] = routePlan.routeId
626+
this.state.portAssignment[fromPortId] = this.state.currentRouteNetId
627+
this.state.portAssignment[toPortId] = this.state.currentRouteNetId
628628
this.appendSegmentToRegionCache(regionId, fromPortId, toPortId)
629629
}
630630
}

lib/visualizeTinyGraph.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ const getPortNetLabel = (
234234
return `net: ${solver.problem.routeNet[routeId]}`
235235
}
236236

237-
const assignedRouteId = solver.state.portAssignment[portId]
238-
if (assignedRouteId >= 0) {
239-
return `net: ${solver.problem.routeNet[assignedRouteId]}`
237+
const assignedNetId = solver.state.portAssignment[portId]
238+
if (assignedNetId >= 0) {
239+
return `net: ${assignedNetId}`
240240
}
241241

242242
const netIds = new Set<number>()

tests/solver/__snapshots__/same-net-shared-bottleneck-repro.snap.svg

Lines changed: 24 additions & 2 deletions
Loading

tests/solver/same-net-shared-bottleneck-repro.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ test("repro: two same-net routes must share one bottleneck port to solve", () =>
2525
)
2626
expect(stagedSvg).toMatchSvgSnapshot(import.meta.path)
2727

28-
expect(solver.solved).toBe(false)
29-
expect(solver.failed).toBe(true)
28+
expect(solver.solved).toBe(true)
29+
expect(solver.failed).toBe(false)
3030
})

0 commit comments

Comments
 (0)