@tscircuit/schematic-trace-solver 0.0.171 → 0.0.172
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 +49 -13
- package/lib/solvers/NetLabelToTraceSolver/NetLabelToTraceSolver.ts +68 -14
- package/package.json +1 -1
- package/tests/repros/__snapshots__/repro-battery-management-bq24073.snap.svg +191 -0
- package/tests/repros/__snapshots__/repro-powerbank-3v-system-power.snap.svg +11 -29
- package/tests/repros/__snapshots__/repro-tida-01389-hbridge.snap.svg +216 -0
- package/tests/repros/__snapshots__/repro-tmp1075-ground-label-overlap.snap.svg +166 -0
- package/tests/repros/assets/repro-battery-management-bq24073.input.json +721 -0
- package/tests/repros/assets/repro-tida-01389-hbridge.input.json +780 -0
- package/tests/repros/assets/repro-tmp1075-ground-label-overlap.input.json +305 -0
- package/tests/repros/repro-battery-management-bq24073.test.ts +62 -0
- package/tests/repros/repro-tida-01389-hbridge.test.ts +23 -0
- package/tests/repros/repro-tmp1075-ground-label-overlap.test.ts +18 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
{
|
|
2
|
+
"chips": [
|
|
3
|
+
{
|
|
4
|
+
"chipId": "U2",
|
|
5
|
+
"center": {
|
|
6
|
+
"x": -4.8,
|
|
7
|
+
"y": 0
|
|
8
|
+
},
|
|
9
|
+
"width": 3.7,
|
|
10
|
+
"height": 4.9,
|
|
11
|
+
"pins": [
|
|
12
|
+
{
|
|
13
|
+
"pinId": "schematic_port_0",
|
|
14
|
+
"displayName": "SDA",
|
|
15
|
+
"x": -2.9499999999999997,
|
|
16
|
+
"y": 0.7999999999999999
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"pinId": "schematic_port_1",
|
|
20
|
+
"displayName": "SCL",
|
|
21
|
+
"x": -2.9499999999999997,
|
|
22
|
+
"y": 0.15000000000000002
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"pinId": "schematic_port_2",
|
|
26
|
+
"displayName": "ALERT",
|
|
27
|
+
"x": -2.9499999999999997,
|
|
28
|
+
"y": -0.7999999999999999
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"chipId": "U1",
|
|
34
|
+
"center": {
|
|
35
|
+
"x": 1.7,
|
|
36
|
+
"y": 0
|
|
37
|
+
},
|
|
38
|
+
"width": 4.2,
|
|
39
|
+
"height": 4.7,
|
|
40
|
+
"pins": [
|
|
41
|
+
{
|
|
42
|
+
"pinId": "schematic_port_3",
|
|
43
|
+
"displayName": "I2C_SDA",
|
|
44
|
+
"x": -0.40000000000000013,
|
|
45
|
+
"y": 1.275
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"pinId": "schematic_port_4",
|
|
49
|
+
"displayName": "I2C_SCL",
|
|
50
|
+
"x": -0.40000000000000013,
|
|
51
|
+
"y": 0.6249999999999999
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"pinId": "schematic_port_5",
|
|
55
|
+
"displayName": "ALERT",
|
|
56
|
+
"x": -0.40000000000000013,
|
|
57
|
+
"y": -0.3250000000000002
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"pinId": "schematic_port_6",
|
|
61
|
+
"displayName": "GND",
|
|
62
|
+
"x": -0.40000000000000013,
|
|
63
|
+
"y": -1.275
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"pinId": "schematic_port_7",
|
|
67
|
+
"displayName": "I2C_ADDR2",
|
|
68
|
+
"x": 3.8,
|
|
69
|
+
"y": -1.075
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"pinId": "schematic_port_8",
|
|
73
|
+
"displayName": "I2C_ADDR1",
|
|
74
|
+
"x": 3.8,
|
|
75
|
+
"y": -0.32499999999999996
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"pinId": "schematic_port_9",
|
|
79
|
+
"displayName": "I2C_ADDR0",
|
|
80
|
+
"x": 3.8,
|
|
81
|
+
"y": 0.42500000000000004
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"pinId": "schematic_port_10",
|
|
85
|
+
"displayName": "V_POS",
|
|
86
|
+
"x": 3.8,
|
|
87
|
+
"y": 1.075
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"chipId": "R1",
|
|
93
|
+
"center": {
|
|
94
|
+
"x": -2.5650000000000004,
|
|
95
|
+
"y": 2
|
|
96
|
+
},
|
|
97
|
+
"width": 0.9700000000000002,
|
|
98
|
+
"height": 0.6000000000000001,
|
|
99
|
+
"pins": [
|
|
100
|
+
{
|
|
101
|
+
"pinId": "schematic_port_11",
|
|
102
|
+
"displayName": "anode",
|
|
103
|
+
"x": -2.6,
|
|
104
|
+
"y": 2.3
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"pinId": "schematic_port_12",
|
|
108
|
+
"displayName": "cathode",
|
|
109
|
+
"x": -2.6,
|
|
110
|
+
"y": 1.7
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"chipId": "R2",
|
|
116
|
+
"center": {
|
|
117
|
+
"x": -1.665,
|
|
118
|
+
"y": 2
|
|
119
|
+
},
|
|
120
|
+
"width": 0.9699999999999998,
|
|
121
|
+
"height": 0.6000000000000001,
|
|
122
|
+
"pins": [
|
|
123
|
+
{
|
|
124
|
+
"pinId": "schematic_port_13",
|
|
125
|
+
"displayName": "anode",
|
|
126
|
+
"x": -1.7,
|
|
127
|
+
"y": 2.3
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"pinId": "schematic_port_14",
|
|
131
|
+
"displayName": "cathode",
|
|
132
|
+
"x": -1.7,
|
|
133
|
+
"y": 1.7
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"chipId": "R3",
|
|
139
|
+
"center": {
|
|
140
|
+
"x": -0.765,
|
|
141
|
+
"y": 2
|
|
142
|
+
},
|
|
143
|
+
"width": 0.97,
|
|
144
|
+
"height": 0.6000000000000001,
|
|
145
|
+
"pins": [
|
|
146
|
+
{
|
|
147
|
+
"pinId": "schematic_port_15",
|
|
148
|
+
"displayName": "anode",
|
|
149
|
+
"x": -0.8,
|
|
150
|
+
"y": 2.3
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"pinId": "schematic_port_16",
|
|
154
|
+
"displayName": "cathode",
|
|
155
|
+
"x": -0.8,
|
|
156
|
+
"y": 1.7
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"chipId": "C1",
|
|
162
|
+
"center": {
|
|
163
|
+
"x": 4.4425,
|
|
164
|
+
"y": 1.1
|
|
165
|
+
},
|
|
166
|
+
"width": 1.2850000000000001,
|
|
167
|
+
"height": 0.7599999999999998,
|
|
168
|
+
"pins": [
|
|
169
|
+
{
|
|
170
|
+
"pinId": "schematic_port_17",
|
|
171
|
+
"displayName": "anode",
|
|
172
|
+
"x": 4.25,
|
|
173
|
+
"y": 1.48,
|
|
174
|
+
"_facingDirection": "y+"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"pinId": "schematic_port_18",
|
|
178
|
+
"displayName": "cathode",
|
|
179
|
+
"x": 4.25,
|
|
180
|
+
"y": 0.7200000000000002,
|
|
181
|
+
"_facingDirection": "y-"
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
],
|
|
186
|
+
"directConnections": [],
|
|
187
|
+
"netConnections": [
|
|
188
|
+
{
|
|
189
|
+
"netId": "SDA",
|
|
190
|
+
"netLabelWidth": 0.48,
|
|
191
|
+
"pinIds": [
|
|
192
|
+
"schematic_port_0",
|
|
193
|
+
"schematic_port_3",
|
|
194
|
+
"schematic_port_12"
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"netId": "SCL",
|
|
199
|
+
"netLabelWidth": 0.48,
|
|
200
|
+
"pinIds": [
|
|
201
|
+
"schematic_port_1",
|
|
202
|
+
"schematic_port_4",
|
|
203
|
+
"schematic_port_14"
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"netId": "ALERT",
|
|
208
|
+
"netLabelWidth": 0.72,
|
|
209
|
+
"pinIds": [
|
|
210
|
+
"schematic_port_2",
|
|
211
|
+
"schematic_port_5",
|
|
212
|
+
"schematic_port_16"
|
|
213
|
+
]
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"netId": "GND",
|
|
217
|
+
"isGround": true,
|
|
218
|
+
"netLabelWidth": 0.42,
|
|
219
|
+
"netLabelHeight": 0.48,
|
|
220
|
+
"pinIds": [
|
|
221
|
+
"schematic_port_6",
|
|
222
|
+
"schematic_port_7",
|
|
223
|
+
"schematic_port_8",
|
|
224
|
+
"schematic_port_9",
|
|
225
|
+
"schematic_port_18"
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"netId": "VDD",
|
|
230
|
+
"netLabelWidth": 0.42,
|
|
231
|
+
"netLabelHeight": 0.48,
|
|
232
|
+
"pinIds": [
|
|
233
|
+
"schematic_port_10",
|
|
234
|
+
"schematic_port_11",
|
|
235
|
+
"schematic_port_13",
|
|
236
|
+
"schematic_port_15",
|
|
237
|
+
"schematic_port_17"
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
"textBoxes": [
|
|
242
|
+
{
|
|
243
|
+
"chipId": "U2",
|
|
244
|
+
"center": {
|
|
245
|
+
"x": -4.8100000000000005,
|
|
246
|
+
"y": -2.58
|
|
247
|
+
},
|
|
248
|
+
"width": 2.88,
|
|
249
|
+
"height": 0.17999999999999972,
|
|
250
|
+
"text": "Two-Wire Host Controller"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"chipId": "U2",
|
|
254
|
+
"center": {
|
|
255
|
+
"x": -6.13,
|
|
256
|
+
"y": 2.5650000000000004
|
|
257
|
+
},
|
|
258
|
+
"width": 0.35999999999999943,
|
|
259
|
+
"height": 0.24999999999999956,
|
|
260
|
+
"text": "U2"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"chipId": "U1",
|
|
264
|
+
"center": {
|
|
265
|
+
"x": 0.6599999999999999,
|
|
266
|
+
"y": -2.48
|
|
267
|
+
},
|
|
268
|
+
"width": 1.3199999999999998,
|
|
269
|
+
"height": 0.17999999999999972,
|
|
270
|
+
"text": "TMP1075DSGR"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"chipId": "U1",
|
|
274
|
+
"center": {
|
|
275
|
+
"x": 0.12,
|
|
276
|
+
"y": 2.465
|
|
277
|
+
},
|
|
278
|
+
"width": 0.36,
|
|
279
|
+
"height": 0.24999999999999956,
|
|
280
|
+
"text": "U1"
|
|
281
|
+
}
|
|
282
|
+
],
|
|
283
|
+
"availableNetLabelOrientations": {
|
|
284
|
+
"SDA": [
|
|
285
|
+
"x-",
|
|
286
|
+
"x+"
|
|
287
|
+
],
|
|
288
|
+
"SCL": [
|
|
289
|
+
"x-",
|
|
290
|
+
"x+"
|
|
291
|
+
],
|
|
292
|
+
"ALERT": [
|
|
293
|
+
"x-",
|
|
294
|
+
"x+"
|
|
295
|
+
],
|
|
296
|
+
"GND": [
|
|
297
|
+
"y-"
|
|
298
|
+
],
|
|
299
|
+
"VDD": [
|
|
300
|
+
"y+"
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
"maxMspPairDistance": 2.4,
|
|
304
|
+
"_hideRatsNet": false
|
|
305
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 type { FacingDirection } from "lib/utils/dir"
|
|
5
|
+
import "tests/fixtures/matcher"
|
|
6
|
+
import inputProblem from "./assets/repro-battery-management-bq24073.input.json"
|
|
7
|
+
|
|
8
|
+
const getPinPair = (pinIds: string[]): [string, string] => {
|
|
9
|
+
if (pinIds.length !== 2) {
|
|
10
|
+
throw new Error(`Expected two pin IDs, received ${pinIds.length}`)
|
|
11
|
+
}
|
|
12
|
+
return [pinIds[0]!, pinIds[1]!]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const parseFacingDirection = (facingDirection: string): FacingDirection => {
|
|
16
|
+
if (
|
|
17
|
+
facingDirection === "x+" ||
|
|
18
|
+
facingDirection === "x-" ||
|
|
19
|
+
facingDirection === "y+" ||
|
|
20
|
+
facingDirection === "y-"
|
|
21
|
+
) {
|
|
22
|
+
return facingDirection
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`Unexpected facing direction: ${facingDirection}`)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Captured from tscircuit/ti's BatteryManagement_BQ24073 on main at
|
|
28
|
+
// b009960e using @tscircuit/core main at 01b67dbb.
|
|
29
|
+
test("repro BatteryManagement_BQ24073 schematic traces", () => {
|
|
30
|
+
const solverInput: InputProblem = {
|
|
31
|
+
...inputProblem,
|
|
32
|
+
chips: inputProblem.chips.map((chip) => ({
|
|
33
|
+
...chip,
|
|
34
|
+
pins: chip.pins.map((pin) => {
|
|
35
|
+
if ("_facingDirection" in pin) {
|
|
36
|
+
return {
|
|
37
|
+
...pin,
|
|
38
|
+
_facingDirection: parseFacingDirection(pin._facingDirection),
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return pin
|
|
42
|
+
}),
|
|
43
|
+
})),
|
|
44
|
+
directConnections: inputProblem.directConnections.map((connection) => ({
|
|
45
|
+
...connection,
|
|
46
|
+
pinIds: getPinPair(connection.pinIds),
|
|
47
|
+
})),
|
|
48
|
+
availableNetLabelOrientations: Object.fromEntries(
|
|
49
|
+
Object.entries(inputProblem.availableNetLabelOrientations).map(
|
|
50
|
+
([netId, facingDirections]) => [
|
|
51
|
+
netId,
|
|
52
|
+
facingDirections.map(parseFacingDirection),
|
|
53
|
+
],
|
|
54
|
+
),
|
|
55
|
+
),
|
|
56
|
+
}
|
|
57
|
+
const solver = new SchematicTracePipelineSolver(solverInput)
|
|
58
|
+
solver.solve()
|
|
59
|
+
|
|
60
|
+
expect(solver.inlineNetLabelSolver!.stats.pushedAnchoredNetLabelCount).toBe(1)
|
|
61
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
62
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
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-tida-01389-hbridge.input.json"
|
|
6
|
+
|
|
7
|
+
// Captured from the TIDA-01389 H-bridge in tscircuit/ti#116. Only display
|
|
8
|
+
// metadata was normalized; component positions and connectivity are unchanged.
|
|
9
|
+
test("repro: TIDA-01389 H-bridge traces float above MOSFET ports", () => {
|
|
10
|
+
expect(inputProblem.chips).toHaveLength(18)
|
|
11
|
+
expect(inputProblem.directConnections).toHaveLength(21)
|
|
12
|
+
expect(inputProblem.netConnections).toHaveLength(11)
|
|
13
|
+
|
|
14
|
+
const solver = new SchematicTracePipelineSolver(
|
|
15
|
+
inputProblem as unknown as InputProblem,
|
|
16
|
+
{ hideRatsNet: true },
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
solver.solve()
|
|
20
|
+
|
|
21
|
+
expect(solver.solved).toBe(true)
|
|
22
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
23
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
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-tmp1075-ground-label-overlap.input.json"
|
|
6
|
+
|
|
7
|
+
test("repro TMP1075 ground label overlap", () => {
|
|
8
|
+
const solver = new SchematicTracePipelineSolver(
|
|
9
|
+
inputProblem as InputProblem,
|
|
10
|
+
{
|
|
11
|
+
hideRatsNet: true,
|
|
12
|
+
},
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
solver.solve()
|
|
16
|
+
|
|
17
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
18
|
+
})
|