@tscircuit/schematic-trace-solver 0.0.189 → 0.0.190
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +252 -223
- package/lib/solvers/SameNetJunctionAlignmentSolver/SameNetJunctionAlignmentSolver.ts +4 -9
- package/lib/solvers/SameNetJunctionAlignmentSolver/alignSameNetJunctions.ts +10 -2
- package/lib/solvers/SameNetJunctionAlignmentSolver/collapseSameNetCycles.ts +75 -38
- package/package.json +1 -1
- package/tests/repros/__snapshots__/repro-pmp11282-isolated-dcdc.snap.svg +18 -18
- package/tests/repros/__snapshots__/repro-repeated-power-rail-junctions.snap.svg +255 -0
- package/tests/repros/assets/repro-repeated-power-rail-junctions.input.json +927 -0
- package/tests/repros/repro-repeated-power-rail-junctions.test.ts +22 -0
- package/tests/solvers/SameNetJunctionAlignmentSolver/collapse-same-net-cycles.test.ts +30 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import type { InputProblem } from "lib/types/InputProblem"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
import inputProblem from "./assets/repro-repeated-power-rail-junctions.input.json"
|
|
6
|
+
|
|
7
|
+
// Reduced from the DS1 area of a Core clock schematic. Three repeated
|
|
8
|
+
// controller/decoupling pairs are the minimum input that preserves the local
|
|
9
|
+
// rectangular branches and multiple junctions beside U_DS1 pins 2 and 3.
|
|
10
|
+
test("collapses repeated junctions around adjacent power rails", () => {
|
|
11
|
+
const solver = new SchematicTracePipelineSolver(
|
|
12
|
+
inputProblem as unknown as InputProblem,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
solver.solve()
|
|
16
|
+
|
|
17
|
+
expect(solver.solved).toBe(true)
|
|
18
|
+
expect(solver.sameNetJunctionAlignmentSolver?.stats.collapsedCycleCount).toBe(
|
|
19
|
+
2,
|
|
20
|
+
)
|
|
21
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
22
|
+
})
|
|
@@ -87,6 +87,36 @@ test("collapses a same-net cycle between a shared pin and crossing", () => {
|
|
|
87
87
|
expect(result.netLabelPlacements[0]?.anchorPoint).toEqual({ x: 0, y: 0 })
|
|
88
88
|
})
|
|
89
89
|
|
|
90
|
+
test("collapses a cycle within one same-net trace", () => {
|
|
91
|
+
const traces = [
|
|
92
|
+
createTraceFixture({
|
|
93
|
+
mspPairId: "self-crossing-trace",
|
|
94
|
+
pinIds: ["start", "end"],
|
|
95
|
+
tracePath: [
|
|
96
|
+
{ x: 0, y: 4 },
|
|
97
|
+
{ x: 0, y: 0 },
|
|
98
|
+
{ x: 4, y: 0 },
|
|
99
|
+
{ x: 4, y: 2 },
|
|
100
|
+
{ x: 1, y: 2 },
|
|
101
|
+
{ x: 1, y: -1 },
|
|
102
|
+
],
|
|
103
|
+
}),
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
const result = collapseSameNetCycles({
|
|
107
|
+
traces,
|
|
108
|
+
netLabelPlacements: [],
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
expect(result.collapsedCycleCount).toBe(1)
|
|
112
|
+
expect(result.traces[0]?.tracePath).toEqual([
|
|
113
|
+
{ x: 0, y: 4 },
|
|
114
|
+
{ x: 0, y: 0 },
|
|
115
|
+
{ x: 1, y: 0 },
|
|
116
|
+
{ x: 1, y: -1 },
|
|
117
|
+
])
|
|
118
|
+
})
|
|
119
|
+
|
|
90
120
|
test("keeps a valid shared same-net branch", () => {
|
|
91
121
|
const traces = [
|
|
92
122
|
createTraceFixture({
|