Skip to content

Commit db73a5f

Browse files
committed
Handle inferred vias in trace clearance relaxation
1 parent 9b494e4 commit db73a5f

2 files changed

Lines changed: 93 additions & 2 deletions

File tree

lib/solvers/GlobalDrcForceImproveSolver/traceToPadClearanceRelaxation.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,31 @@ const getRouteViaDiameter = (srj: SimpleRouteJson, route: HighDensityRoute) =>
4747
const pointsEqual = (left: Point2D, right: Point2D) =>
4848
distance(left, right) < CLEARANCE_EPSILON
4949

50+
const getRouteViaCenters = (route: HighDensityRoute): Point2D[] => {
51+
const viaCenters: Point2D[] = []
52+
53+
const addViaCenter = (center: Point2D) => {
54+
if (viaCenters.some((viaCenter) => pointsEqual(viaCenter, center))) {
55+
return
56+
}
57+
viaCenters.push({ x: center.x, y: center.y })
58+
}
59+
60+
for (const via of route.vias) {
61+
addViaCenter(via)
62+
}
63+
64+
for (let i = 0; i < route.route.length - 1; i += 1) {
65+
const start = route.route[i]
66+
const end = route.route[i + 1]
67+
if (!start || !end || start.z === end.z) continue
68+
if (!pointsEqual(start, end)) continue
69+
addViaCenter(start)
70+
}
71+
72+
return viaCenters
73+
}
74+
5075
const normalizeVector = (vector: Point2D): Point2D => {
5176
const magnitude = distance({ x: 0, y: 0 }, vector)
5277
if (magnitude < CLEARANCE_EPSILON) return { x: 0, y: 0 }
@@ -113,7 +138,7 @@ const getClearanceBlockersForRoute = (
113138
for (const otherRoute of routes) {
114139
if (otherRoute === route || routesAreConnected(route, otherRoute)) continue
115140

116-
for (const via of otherRoute.vias) {
141+
for (const via of getRouteViaCenters(otherRoute)) {
117142
blockers.push({
118143
kind: "via",
119144
center: { x: via.x, y: via.y },
@@ -292,7 +317,7 @@ const getRouteOtherTraceClearancePenalty = (
292317
if (violation > 0) penalty += violation * violation
293318
}
294319

295-
for (const via of otherRoute.vias) {
320+
for (const via of getRouteViaCenters(otherRoute)) {
296321
const clearance =
297322
pointToSegmentDistance(via, start, end) -
298323
getTraceHalfWidth(srj, route) -

tests/solver-route-behavior.test.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,72 @@ test("does not move a trace away from a same-net pad", () => {
186186
}
187187
})
188188

189+
test("moves a trace until its edge clears an inferred different-net via edge", () => {
190+
const srj: SimpleRouteJson = {
191+
bounds: { minX: -1, minY: -1, maxX: 5, maxY: 3 },
192+
connections: [
193+
{ name: "A", pointsToConnect: [] },
194+
{ name: "B", pointsToConnect: [] },
195+
],
196+
obstacles: [],
197+
layerCount: 2,
198+
minTraceWidth: 0.1,
199+
minViaDiameter: 0.3,
200+
minTraceToPadEdgeClearance: 0.2,
201+
}
202+
const hdRoutes = [
203+
{
204+
connectionName: "A",
205+
route: [
206+
{ x: 0, y: 0, z: 0 },
207+
{ x: 0, y: 1.1, z: 0 },
208+
{ x: 4, y: 1.1, z: 0 },
209+
{ x: 4, y: 0, z: 0 },
210+
],
211+
vias: [],
212+
traceThickness: 0.1,
213+
viaDiameter: 0.3,
214+
},
215+
{
216+
connectionName: "B",
217+
route: [
218+
{ x: 2, y: 1, z: 0 },
219+
{ x: 2, y: 1, z: 1 },
220+
{ x: 2, y: 2, z: 1 },
221+
],
222+
vias: [],
223+
traceThickness: 0.1,
224+
viaDiameter: 0.3,
225+
},
226+
]
227+
const solver = new GlobalDrcForceImproveSolver({
228+
srj,
229+
hdRoutes,
230+
maxIterations: 1,
231+
drcEvaluator: () => [],
232+
})
233+
234+
solver.solve()
235+
236+
const output = solver.getOutput()
237+
const movedStart = output[0]?.route[1]
238+
const movedEnd = output[0]?.route[2]
239+
const inferredViaCenter = { x: 2, y: 1 }
240+
const viaRadius = 0.15
241+
const traceHalfWidth = 0.05
242+
const requiredClearance = 0.2
243+
244+
expect(movedStart?.y).toBeGreaterThan(1.1)
245+
expect(movedEnd?.y).toBeCloseTo(movedStart!.y, 6)
246+
expect(movedStart?.x).toBeCloseTo(0, 6)
247+
expect(movedEnd?.x).toBeCloseTo(4, 6)
248+
expect(output[1]?.route[0]).toMatchObject(inferredViaCenter)
249+
expect(output[1]?.route[1]).toMatchObject(inferredViaCenter)
250+
const traceEdgeToViaEdgeClearance =
251+
movedStart!.y - inferredViaCenter.y - viaRadius - traceHalfWidth
252+
expect(traceEdgeToViaEdgeClearance).toBeGreaterThanOrEqual(requiredClearance)
253+
})
254+
189255
test("moves a via until its edge clears a different-net pad edge", () => {
190256
const srj: SimpleRouteJson = {
191257
bounds: { minX: -2, minY: -2, maxX: 6, maxY: 4 },

0 commit comments

Comments
 (0)