@tscircuit/schematic-trace-solver 0.0.65 → 0.0.67

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.
@@ -0,0 +1,258 @@
1
+ {
2
+ "chips": [
3
+ {
4
+ "chipId": "schematic_component_0",
5
+ "center": {
6
+ "x": 0,
7
+ "y": 0
8
+ },
9
+ "width": 2.2,
10
+ "height": 3,
11
+ "pins": [
12
+ {
13
+ "pinId": "U1.1",
14
+ "x": -1.5,
15
+ "y": 0.10000000000000009
16
+ },
17
+ {
18
+ "pinId": "U1.8",
19
+ "x": 1.5,
20
+ "y": 1.3
21
+ },
22
+ {
23
+ "pinId": "U1.11",
24
+ "x": -1.5,
25
+ "y": 1.3
26
+ },
27
+ {
28
+ "pinId": "U1.12",
29
+ "x": -1.5,
30
+ "y": 1.1
31
+ },
32
+ {
33
+ "pinId": "U1.17",
34
+ "x": 1.5,
35
+ "y": 1.0999999999999999
36
+ },
37
+ {
38
+ "pinId": "U1.25",
39
+ "x": -1.5,
40
+ "y": 0.9
41
+ },
42
+ {
43
+ "pinId": "U1.26",
44
+ "x": -1.5,
45
+ "y": -0.4999999999999998
46
+ },
47
+ {
48
+ "pinId": "U1.27",
49
+ "x": -1.5,
50
+ "y": -0.6999999999999997
51
+ },
52
+ {
53
+ "pinId": "U1.28",
54
+ "x": -1.5,
55
+ "y": -1.0999999999999999
56
+ },
57
+ {
58
+ "pinId": "U1.30",
59
+ "x": -1.5,
60
+ "y": 0.5
61
+ },
62
+ {
63
+ "pinId": "U1.31",
64
+ "x": 1.5,
65
+ "y": 0.8999999999999997
66
+ },
67
+ {
68
+ "pinId": "U1.34",
69
+ "x": -1.5,
70
+ "y": -0.09999999999999987
71
+ },
72
+ {
73
+ "pinId": "U1.35",
74
+ "x": 1.5,
75
+ "y": -1.1
76
+ },
77
+ {
78
+ "pinId": "U1.36",
79
+ "x": 1.5,
80
+ "y": -1.3
81
+ },
82
+ {
83
+ "pinId": "U1.37",
84
+ "x": -1.5,
85
+ "y": -0.8999999999999997
86
+ },
87
+ {
88
+ "pinId": "U1.38",
89
+ "x": 1.5,
90
+ "y": 0.6999999999999997
91
+ },
92
+ {
93
+ "pinId": "U1.39",
94
+ "x": 1.5,
95
+ "y": -2.220446049250313e-16
96
+ },
97
+ {
98
+ "pinId": "U1.40",
99
+ "x": 1.5,
100
+ "y": -0.40000000000000013
101
+ },
102
+ {
103
+ "pinId": "U1.41",
104
+ "x": -1.5,
105
+ "y": -1.3
106
+ }
107
+ ]
108
+ },
109
+ {
110
+ "chipId": "schematic_component_1",
111
+ "center": {
112
+ "x": -5.5,
113
+ "y": 0.6
114
+ },
115
+ "width": 1.16,
116
+ "height": 0.46,
117
+ "pins": [
118
+ {
119
+ "pinId": "L1.1",
120
+ "x": -6.05,
121
+ "y": 0.58
122
+ },
123
+ {
124
+ "pinId": "L1.2",
125
+ "x": -4.95,
126
+ "y": 0.57
127
+ }
128
+ ]
129
+ },
130
+ {
131
+ "chipId": "schematic_component_2",
132
+ "center": {
133
+ "x": -8,
134
+ "y": -1
135
+ },
136
+ "width": 0.53,
137
+ "height": 1.1,
138
+ "pins": [
139
+ {
140
+ "pinId": "C105.1",
141
+ "x": -8,
142
+ "y": -0.44999999999999996
143
+ },
144
+ {
145
+ "pinId": "C105.2",
146
+ "x": -8,
147
+ "y": -1.55
148
+ }
149
+ ]
150
+ },
151
+ {
152
+ "chipId": "schematic_component_3",
153
+ "center": {
154
+ "x": -4.3,
155
+ "y": -1
156
+ },
157
+ "width": 0.53,
158
+ "height": 1.1,
159
+ "pins": [
160
+ {
161
+ "pinId": "C106.1",
162
+ "x": -4.3,
163
+ "y": -0.44999999999999996
164
+ },
165
+ {
166
+ "pinId": "C106.2",
167
+ "x": -4.3,
168
+ "y": -1.55
169
+ }
170
+ ]
171
+ },
172
+ {
173
+ "chipId": "schematic_component_4",
174
+ "center": {
175
+ "x": -5.8,
176
+ "y": -1
177
+ },
178
+ "width": 0.53,
179
+ "height": 1.1,
180
+ "pins": [
181
+ {
182
+ "pinId": "C107.1",
183
+ "x": -5.8,
184
+ "y": -0.44999999999999996
185
+ },
186
+ {
187
+ "pinId": "C107.2",
188
+ "x": -5.8,
189
+ "y": -1.55
190
+ }
191
+ ]
192
+ }
193
+ ],
194
+ "directConnections": [
195
+ {
196
+ "pinIds": ["U1.30", "L1.2"],
197
+ "netId": ".U1 > .DCDC to L1.pin2"
198
+ },
199
+ {
200
+ "pinIds": ["U1.1", "U1.34"],
201
+ "netId": ".U1 > .pin1 to U1.pin34"
202
+ },
203
+ {
204
+ "pinIds": ["C106.1", "L1.1"],
205
+ "netId": ".C106 > .pin1 to L1.pin1"
206
+ },
207
+ {
208
+ "pinIds": ["C107.1", "C106.1"],
209
+ "netId": ".C107 > .pin1 to C106.pin1"
210
+ }
211
+ ],
212
+ "netConnections": [
213
+ {
214
+ "netId": "VDDS",
215
+ "pinIds": [
216
+ "U1.1",
217
+ "U1.8",
218
+ "U1.17",
219
+ "U1.31",
220
+ "U1.34",
221
+ "U1.38",
222
+ "L1.1",
223
+ "C105.1",
224
+ "C106.1",
225
+ "C107.1"
226
+ ],
227
+ "netLabelWidth": 0.6
228
+ },
229
+ {
230
+ "netId": "WMCU_SWDIO",
231
+ "pinIds": ["U1.11"],
232
+ "netLabelWidth": 1.32
233
+ },
234
+ {
235
+ "netId": "WMCU_SWDCK",
236
+ "pinIds": ["U1.12"],
237
+ "netLabelWidth": 1.32
238
+ },
239
+ {
240
+ "netId": "ANT_RF",
241
+ "pinIds": ["U1.39"],
242
+ "netLabelWidth": 0.84
243
+ },
244
+ {
245
+ "netId": "GND",
246
+ "pinIds": ["U1.40", "U1.41", "C105.2", "C106.2", "C107.2"],
247
+ "netLabelWidth": 0.48
248
+ }
249
+ ],
250
+ "availableNetLabelOrientations": {
251
+ "WMCU_SWDIO": ["x-", "x+"],
252
+ "WMCU_SWDCK": ["x-", "x+"],
253
+ "VDDS": ["y+"],
254
+ "GND": ["y-"],
255
+ "ANT_RF": ["x-", "x+"]
256
+ },
257
+ "maxMspPairDistance": 2.4
258
+ }
@@ -0,0 +1,350 @@
1
+ {
2
+ "chips": [
3
+ {
4
+ "chipId": "schematic_component_0",
5
+ "center": {
6
+ "x": 0,
7
+ "y": 0.55
8
+ },
9
+ "width": 4.6,
10
+ "height": 3,
11
+ "pins": [
12
+ {
13
+ "pinId": "U1.1",
14
+ "x": -2.6999999999999997,
15
+ "y": 1.5
16
+ },
17
+ {
18
+ "pinId": "U1.2",
19
+ "x": -2.6999999999999997,
20
+ "y": 1.3
21
+ },
22
+ {
23
+ "pinId": "U1.3",
24
+ "x": -2.6999999999999997,
25
+ "y": 1.1
26
+ },
27
+ {
28
+ "pinId": "U1.4",
29
+ "x": -2.6999999999999997,
30
+ "y": 0.55
31
+ },
32
+ {
33
+ "pinId": "U1.5",
34
+ "x": -2.6999999999999997,
35
+ "y": 0.10000000000000009
36
+ },
37
+ {
38
+ "pinId": "U1.6",
39
+ "x": -2.6999999999999997,
40
+ "y": -0.3999999999999999
41
+ },
42
+ {
43
+ "pinId": "U1.7",
44
+ "x": 2.6999999999999997,
45
+ "y": -0.42499999999999993
46
+ },
47
+ {
48
+ "pinId": "U1.8",
49
+ "x": 2.6999999999999997,
50
+ "y": -0.17499999999999993
51
+ },
52
+ {
53
+ "pinId": "U1.9",
54
+ "x": 2.6999999999999997,
55
+ "y": 0.32500000000000007
56
+ },
57
+ {
58
+ "pinId": "U1.10",
59
+ "x": 2.6999999999999997,
60
+ "y": 0.775
61
+ },
62
+ {
63
+ "pinId": "U1.11",
64
+ "x": 2.6999999999999997,
65
+ "y": 1.3250000000000002
66
+ },
67
+ {
68
+ "pinId": "U1.12",
69
+ "x": 2.6999999999999997,
70
+ "y": 1.525
71
+ },
72
+ {
73
+ "pinId": "U1.13",
74
+ "x": 0,
75
+ "y": -1.3499999999999999
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ "chipId": "schematic_component_1",
81
+ "center": {
82
+ "x": -8.4,
83
+ "y": -4.8
84
+ },
85
+ "width": 1.6,
86
+ "height": 0.8,
87
+ "pins": [
88
+ {
89
+ "pinId": "J5.1",
90
+ "x": -7.2,
91
+ "y": -5
92
+ },
93
+ {
94
+ "pinId": "J5.2",
95
+ "x": -7.2,
96
+ "y": -4.8
97
+ },
98
+ {
99
+ "pinId": "J5.3",
100
+ "x": -7.2,
101
+ "y": -4.6
102
+ }
103
+ ]
104
+ },
105
+ {
106
+ "chipId": "schematic_component_2",
107
+ "center": {
108
+ "x": 4.4,
109
+ "y": -4.8
110
+ },
111
+ "width": 1.1,
112
+ "height": 0.388910699999999,
113
+ "pins": [
114
+ {
115
+ "pinId": "R1.1",
116
+ "x": 3.8500000000000005,
117
+ "y": -4.8
118
+ },
119
+ {
120
+ "pinId": "R1.2",
121
+ "x": 4.950000000000001,
122
+ "y": -4.8
123
+ }
124
+ ]
125
+ },
126
+ {
127
+ "chipId": "schematic_component_3",
128
+ "center": {
129
+ "x": -6.25,
130
+ "y": 3.55
131
+ },
132
+ "width": 0.3194553499999995,
133
+ "height": 1.1,
134
+ "pins": [
135
+ {
136
+ "pinId": "R2.1",
137
+ "x": -6.25,
138
+ "y": 4.1
139
+ },
140
+ {
141
+ "pinId": "R2.2",
142
+ "x": -6.25,
143
+ "y": 3
144
+ }
145
+ ]
146
+ },
147
+ {
148
+ "chipId": "schematic_component_4",
149
+ "center": {
150
+ "x": -5.1,
151
+ "y": 3.55
152
+ },
153
+ "width": 0.3194553499999995,
154
+ "height": 1.1,
155
+ "pins": [
156
+ {
157
+ "pinId": "R3.1",
158
+ "x": -5.1,
159
+ "y": 4.1
160
+ },
161
+ {
162
+ "pinId": "R3.2",
163
+ "x": -5.1,
164
+ "y": 3
165
+ }
166
+ ]
167
+ },
168
+ {
169
+ "chipId": "schematic_component_5",
170
+ "center": {
171
+ "x": 6,
172
+ "y": 3.55
173
+ },
174
+ "width": 0.3194553499999995,
175
+ "height": 1.1,
176
+ "pins": [
177
+ {
178
+ "pinId": "R4.1",
179
+ "x": 6,
180
+ "y": 4.1
181
+ },
182
+ {
183
+ "pinId": "R4.2",
184
+ "x": 6,
185
+ "y": 3
186
+ }
187
+ ]
188
+ },
189
+ {
190
+ "chipId": "schematic_component_6",
191
+ "center": {
192
+ "x": 7.15,
193
+ "y": 3.55
194
+ },
195
+ "width": 0.3194553499999995,
196
+ "height": 1.1,
197
+ "pins": [
198
+ {
199
+ "pinId": "R5.1",
200
+ "x": 7.15,
201
+ "y": 4.1
202
+ },
203
+ {
204
+ "pinId": "R5.2",
205
+ "x": 7.15,
206
+ "y": 3
207
+ }
208
+ ]
209
+ },
210
+ {
211
+ "chipId": "schematic_component_7",
212
+ "center": {
213
+ "x": -4.7,
214
+ "y": -1.45
215
+ },
216
+ "width": 0.53,
217
+ "height": 1.1,
218
+ "pins": [
219
+ {
220
+ "pinId": "C1.1",
221
+ "x": -4.7,
222
+ "y": -0.8999999999999999
223
+ },
224
+ {
225
+ "pinId": "C1.2",
226
+ "x": -4.7,
227
+ "y": -2
228
+ }
229
+ ]
230
+ },
231
+ {
232
+ "chipId": "schematic_component_8",
233
+ "center": {
234
+ "x": -2.55,
235
+ "y": -5.65
236
+ },
237
+ "width": 0.53,
238
+ "height": 1.1,
239
+ "pins": [
240
+ {
241
+ "pinId": "C2.1",
242
+ "x": -2.55,
243
+ "y": -5.1
244
+ },
245
+ {
246
+ "pinId": "C2.2",
247
+ "x": -2.55,
248
+ "y": -6.2
249
+ }
250
+ ]
251
+ }
252
+ ],
253
+ "directConnections": [
254
+ {
255
+ "pinIds": ["R2.1", "R3.1"],
256
+ "netId": "R2.pin1 to R3.pin1"
257
+ },
258
+ {
259
+ "pinIds": ["R4.1", "R5.1"],
260
+ "netId": "R4.pin1 to R5.pin1"
261
+ },
262
+ {
263
+ "pinIds": ["R2.2", "U1.1"],
264
+ "netId": "R2.pin2 to U1.SDA"
265
+ },
266
+ {
267
+ "pinIds": ["R3.2", "U1.2"],
268
+ "netId": "R3.pin2 to U1.SCL"
269
+ },
270
+ {
271
+ "pinIds": ["R4.2", "U1.12"],
272
+ "netId": "R4.pin2 to U1.GPOUT"
273
+ },
274
+ {
275
+ "pinIds": ["R5.2", "U1.10"],
276
+ "netId": "R5.pin2 to U1.BIN"
277
+ },
278
+ {
279
+ "pinIds": ["C1.1", "U1.5"],
280
+ "netId": "C1.pin1 to U1.VDD"
281
+ },
282
+ {
283
+ "pinIds": ["J5.3", "C2.1"],
284
+ "netId": "J5.pin3 to C2.pin1"
285
+ },
286
+ {
287
+ "pinIds": ["C2.1", "U1.6"],
288
+ "netId": "C2.pin1 to U1.BAT"
289
+ },
290
+ {
291
+ "pinIds": ["C2.1", "R1.1"],
292
+ "netId": "C2.pin1 to R1.pin1"
293
+ },
294
+ {
295
+ "pinIds": ["R1.1", "U1.8"],
296
+ "netId": "R1.pin1 to U1.SRP"
297
+ },
298
+ {
299
+ "pinIds": ["R1.2", "U1.7"],
300
+ "netId": "R1.pin2 to U1.SRN"
301
+ }
302
+ ],
303
+ "netConnections": [
304
+ {
305
+ "netId": "SDA",
306
+ "pinIds": ["U1.1", "R2.2"],
307
+ "netLabelWidth": 0.48
308
+ },
309
+ {
310
+ "netId": "SCL",
311
+ "pinIds": ["U1.2", "R3.2"],
312
+ "netLabelWidth": 0.48
313
+ },
314
+ {
315
+ "netId": "PGND",
316
+ "pinIds": ["U1.3", "U1.13", "J5.1", "C1.2", "C2.2"],
317
+ "netLabelWidth": 0.6
318
+ },
319
+ {
320
+ "netId": "PACKP",
321
+ "pinIds": ["U1.6", "U1.8", "J5.3", "R1.1", "C2.1"],
322
+ "netLabelWidth": 0.72
323
+ },
324
+ {
325
+ "netId": "VSYS",
326
+ "pinIds": ["U1.7", "R1.2"],
327
+ "netLabelWidth": 0.6
328
+ },
329
+ {
330
+ "netId": "BIN",
331
+ "pinIds": ["U1.10", "J5.2", "R5.2"],
332
+ "netLabelWidth": 0.48
333
+ },
334
+ {
335
+ "netId": "GPOUT",
336
+ "pinIds": ["U1.12", "R4.2"],
337
+ "netLabelWidth": 0.72
338
+ }
339
+ ],
340
+ "availableNetLabelOrientations": {
341
+ "PGND": ["y-"],
342
+ "BIN": ["x-", "x+"],
343
+ "PACKP": ["x-", "x+"],
344
+ "VSYS": ["y+"],
345
+ "SDA": ["x-", "x+"],
346
+ "SCL": ["x-", "x+"],
347
+ "GPOUT": ["x-", "x+"]
348
+ },
349
+ "maxMspPairDistance": 20
350
+ }
@@ -0,0 +1,11 @@
1
+ import { expect, test } from "bun:test"
2
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
+ import inputProblem from "./assets/repro-cc2340r5.input.json"
4
+ import "tests/fixtures/matcher"
5
+
6
+ test("repro cc2340r5 VDDS trace overlaps its own net label", () => {
7
+ const solver = new SchematicTracePipelineSolver(inputProblem as any)
8
+ solver.solve()
9
+
10
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
11
+ })
@@ -0,0 +1,60 @@
1
+ import { expect, test } from "bun:test"
2
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
+ import inputProblem from "./assets/repro130-bq27441-fuel-gauge.input.json"
4
+ import "tests/fixtures/matcher"
5
+
6
+ const getChipRect = (chip: any) => ({
7
+ minX: chip.center.x - chip.width / 2,
8
+ maxX: chip.center.x + chip.width / 2,
9
+ minY: chip.center.y - chip.height / 2,
10
+ maxY: chip.center.y + chip.height / 2,
11
+ })
12
+
13
+ const EPS = 1e-9
14
+
15
+ const segmentIntersectsRect = (a: any, b: any, rect: any) => {
16
+ if (a.x === b.x) {
17
+ const overlap =
18
+ Math.min(Math.max(a.y, b.y), rect.maxY) -
19
+ Math.max(Math.min(a.y, b.y), rect.minY)
20
+ return a.x >= rect.minX - EPS && a.x <= rect.maxX + EPS && overlap > EPS
21
+ }
22
+
23
+ if (a.y === b.y) {
24
+ const overlap =
25
+ Math.min(Math.max(a.x, b.x), rect.maxX) -
26
+ Math.max(Math.min(a.x, b.x), rect.minX)
27
+ return a.y >= rect.minY - EPS && a.y <= rect.maxY + EPS && overlap > EPS
28
+ }
29
+
30
+ return false
31
+ }
32
+
33
+ const pathIntersectsRect = (path: Array<{ x: number; y: number }>, rect: any) =>
34
+ path.some((point, index) => {
35
+ if (index === 0) return false
36
+ return segmentIntersectsRect(path[index - 1], point, rect)
37
+ })
38
+
39
+ test("repro130 bq27441 fuel gauge trace crosses C1 obstacle", () => {
40
+ const solver = new SchematicTracePipelineSolver(inputProblem as any)
41
+ solver.solve()
42
+
43
+ const c1 = (inputProblem as any).chips.find((chip: any) =>
44
+ chip.pins.some((pin: any) => pin.pinId === "C1.1"),
45
+ )
46
+ const traces =
47
+ solver.netLabelTraceCollisionSolver?.getOutput().traces ??
48
+ solver.traceCleanupSolver?.getOutput().traces ??
49
+ []
50
+ const traceThroughC1 = traces.find(
51
+ (trace: any) => trace.mspPairId === "U1.3-C1.2",
52
+ )
53
+
54
+ expect(c1).toBeDefined()
55
+ expect(traceThroughC1).toBeDefined()
56
+ expect(pathIntersectsRect(traceThroughC1!.tracePath, getChipRect(c1))).toBe(
57
+ true,
58
+ )
59
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
60
+ })