@tscircuit/schematic-trace-solver 0.0.137 → 0.0.140

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,537 @@
1
+ {
2
+ "chips": [
3
+ {
4
+ "chipId": "schematic_component_9",
5
+ "center": {
6
+ "x": 11.035000000000002,
7
+ "y": -5.0189106999999975
8
+ },
9
+ "width": 2.1999999999999993,
10
+ "height": 2.4000000000000004,
11
+ "pins": [
12
+ {
13
+ "pinId": "schematic_port_35",
14
+ "x": 9.935000000000002,
15
+ "y": -4.0189106999999975
16
+ },
17
+ {
18
+ "pinId": "schematic_port_36",
19
+ "x": 9.935000000000002,
20
+ "y": -4.218910699999998
21
+ },
22
+ {
23
+ "pinId": "schematic_port_37",
24
+ "x": 9.935000000000002,
25
+ "y": -4.418910699999998
26
+ },
27
+ {
28
+ "pinId": "schematic_port_38",
29
+ "x": 9.935000000000002,
30
+ "y": -4.618910699999998
31
+ },
32
+ {
33
+ "pinId": "schematic_port_39",
34
+ "x": 9.935000000000002,
35
+ "y": -4.818910699999997
36
+ },
37
+ {
38
+ "pinId": "schematic_port_40",
39
+ "x": 9.935000000000002,
40
+ "y": -5.0189106999999975
41
+ },
42
+ {
43
+ "pinId": "schematic_port_41",
44
+ "x": 9.935000000000002,
45
+ "y": -5.218910699999998
46
+ },
47
+ {
48
+ "pinId": "schematic_port_42",
49
+ "x": 9.935000000000002,
50
+ "y": -5.418910699999998
51
+ },
52
+ {
53
+ "pinId": "schematic_port_43",
54
+ "x": 9.935000000000002,
55
+ "y": -5.618910699999997
56
+ },
57
+ {
58
+ "pinId": "schematic_port_44",
59
+ "x": 9.935000000000002,
60
+ "y": -5.818910699999997
61
+ },
62
+ {
63
+ "pinId": "schematic_port_45",
64
+ "x": 9.935000000000002,
65
+ "y": -6.0189106999999975
66
+ },
67
+ {
68
+ "pinId": "schematic_port_46",
69
+ "x": 12.135000000000002,
70
+ "y": -6.0189106999999975
71
+ },
72
+ {
73
+ "pinId": "schematic_port_47",
74
+ "x": 12.135000000000002,
75
+ "y": -5.818910699999997
76
+ },
77
+ {
78
+ "pinId": "schematic_port_48",
79
+ "x": 12.135000000000002,
80
+ "y": -5.618910699999997
81
+ },
82
+ {
83
+ "pinId": "schematic_port_49",
84
+ "x": 12.135000000000002,
85
+ "y": -5.418910699999997
86
+ },
87
+ {
88
+ "pinId": "schematic_port_50",
89
+ "x": 12.135000000000002,
90
+ "y": -5.218910699999998
91
+ },
92
+ {
93
+ "pinId": "schematic_port_51",
94
+ "x": 12.135000000000002,
95
+ "y": -5.0189106999999975
96
+ },
97
+ {
98
+ "pinId": "schematic_port_52",
99
+ "x": 12.135000000000002,
100
+ "y": -4.818910699999997
101
+ },
102
+ {
103
+ "pinId": "schematic_port_53",
104
+ "x": 12.135000000000002,
105
+ "y": -4.618910699999997
106
+ },
107
+ {
108
+ "pinId": "schematic_port_54",
109
+ "x": 12.135000000000002,
110
+ "y": -4.418910699999998
111
+ },
112
+ {
113
+ "pinId": "schematic_port_55",
114
+ "x": 12.135000000000002,
115
+ "y": -4.218910699999998
116
+ },
117
+ {
118
+ "pinId": "schematic_port_56",
119
+ "x": 12.135000000000002,
120
+ "y": -4.0189106999999975
121
+ }
122
+ ],
123
+ "sectionId": "esp12f_power_and_boot"
124
+ },
125
+ {
126
+ "chipId": "schematic_component_10",
127
+ "center": {
128
+ "x": 7.610000000000001,
129
+ "y": -5.918910699999998
130
+ },
131
+ "width": 0.9200000000000008,
132
+ "height": 0.7599999999999998,
133
+ "pins": [
134
+ {
135
+ "pinId": "schematic_port_57",
136
+ "x": 7.475000000000001,
137
+ "y": -5.538910699999998,
138
+ "_facingDirection": "y+"
139
+ },
140
+ {
141
+ "pinId": "schematic_port_58",
142
+ "x": 7.475000000000001,
143
+ "y": -6.298910699999998,
144
+ "_facingDirection": "y-"
145
+ }
146
+ ],
147
+ "sectionId": "esp12f_power_and_boot"
148
+ },
149
+ {
150
+ "chipId": "schematic_component_11",
151
+ "center": {
152
+ "x": 8.910000000000002,
153
+ "y": -5.918910699999998
154
+ },
155
+ "width": 1.0399999999999991,
156
+ "height": 0.7599999999999998,
157
+ "pins": [
158
+ {
159
+ "pinId": "schematic_port_59",
160
+ "x": 8.715000000000002,
161
+ "y": -5.538910699999998,
162
+ "_facingDirection": "y+"
163
+ },
164
+ {
165
+ "pinId": "schematic_port_60",
166
+ "x": 8.715000000000002,
167
+ "y": -6.298910699999998,
168
+ "_facingDirection": "y-"
169
+ }
170
+ ],
171
+ "sectionId": "esp12f_power_and_boot"
172
+ },
173
+ {
174
+ "chipId": "schematic_component_12",
175
+ "center": {
176
+ "x": 8.547500000000003,
177
+ "y": -3.708910699999998
178
+ },
179
+ "width": 0.9649999999999999,
180
+ "height": 0.5999999999999996,
181
+ "pins": [
182
+ {
183
+ "pinId": "schematic_port_61",
184
+ "x": 8.390000000000002,
185
+ "y": -3.408910699999998,
186
+ "_facingDirection": "y+"
187
+ },
188
+ {
189
+ "pinId": "schematic_port_62",
190
+ "x": 8.390000000000002,
191
+ "y": -4.008910699999998,
192
+ "_facingDirection": "y-"
193
+ }
194
+ ],
195
+ "sectionId": "esp12f_power_and_boot"
196
+ },
197
+ {
198
+ "chipId": "schematic_component_13",
199
+ "center": {
200
+ "x": 9.300000000000002,
201
+ "y": -1.8989106999999983
202
+ },
203
+ "width": 0.9649999999999999,
204
+ "height": 0.5999999999999999,
205
+ "pins": [
206
+ {
207
+ "pinId": "schematic_port_63",
208
+ "x": 9.142500000000002,
209
+ "y": -1.5989106999999985,
210
+ "_facingDirection": "y+"
211
+ },
212
+ {
213
+ "pinId": "schematic_port_64",
214
+ "x": 9.142500000000002,
215
+ "y": -2.198910699999998,
216
+ "_facingDirection": "y-"
217
+ }
218
+ ],
219
+ "sectionId": "esp12f_power_and_boot"
220
+ },
221
+ {
222
+ "chipId": "schematic_component_14",
223
+ "center": {
224
+ "x": 9.740000000000002,
225
+ "y": -8.123910699999996
226
+ },
227
+ "width": 0.9649999999999999,
228
+ "height": 0.6000000000000014,
229
+ "pins": [
230
+ {
231
+ "pinId": "schematic_port_65",
232
+ "x": 9.582500000000001,
233
+ "y": -7.823910699999995
234
+ },
235
+ {
236
+ "pinId": "schematic_port_66",
237
+ "x": 9.582500000000001,
238
+ "y": -8.423910699999997
239
+ }
240
+ ],
241
+ "sectionId": "esp12f_power_and_boot"
242
+ },
243
+ {
244
+ "chipId": "schematic_component_15",
245
+ "center": {
246
+ "x": 7.860000000000001,
247
+ "y": -7.328910699999997
248
+ },
249
+ "width": 0.9649999999999999,
250
+ "height": 0.5999999999999996,
251
+ "pins": [
252
+ {
253
+ "pinId": "schematic_port_67",
254
+ "x": 7.7025000000000015,
255
+ "y": -7.028910699999997,
256
+ "_facingDirection": "y+"
257
+ },
258
+ {
259
+ "pinId": "schematic_port_68",
260
+ "x": 7.7025000000000015,
261
+ "y": -7.628910699999997,
262
+ "_facingDirection": "y-"
263
+ }
264
+ ],
265
+ "sectionId": "esp12f_power_and_boot"
266
+ },
267
+ {
268
+ "chipId": "schematic_component_16",
269
+ "center": {
270
+ "x": 11.620000000000003,
271
+ "y": -8.123910699999996
272
+ },
273
+ "width": 0.9649999999999999,
274
+ "height": 0.6000000000000014,
275
+ "pins": [
276
+ {
277
+ "pinId": "schematic_port_69",
278
+ "x": 11.462500000000002,
279
+ "y": -7.823910699999995
280
+ },
281
+ {
282
+ "pinId": "schematic_port_70",
283
+ "x": 11.462500000000002,
284
+ "y": -8.423910699999997
285
+ }
286
+ ],
287
+ "sectionId": "esp12f_power_and_boot"
288
+ },
289
+ {
290
+ "chipId": "schematic_component_17",
291
+ "center": {
292
+ "x": 11.157500000000002,
293
+ "y": -1.8594553499999984
294
+ },
295
+ "width": 0.9400000000000013,
296
+ "height": 0.7189106999999988,
297
+ "pins": [
298
+ {
299
+ "pinId": "schematic_port_71",
300
+ "x": 10.687500000000002,
301
+ "y": -1.9094553499999982,
302
+ "_facingDirection": "x-"
303
+ },
304
+ {
305
+ "pinId": "schematic_port_72",
306
+ "x": 11.627500000000003,
307
+ "y": -1.9094553499999982,
308
+ "_facingDirection": "x+"
309
+ }
310
+ ],
311
+ "sectionId": "esp12f_power_and_boot"
312
+ },
313
+ {
314
+ "chipId": "schematic_component_18",
315
+ "center": {
316
+ "x": 13.815000000000001,
317
+ "y": -7.171410699999997
318
+ },
319
+ "width": 0.9400000000000013,
320
+ "height": 0.7189106999999986,
321
+ "pins": [
322
+ {
323
+ "pinId": "schematic_port_73",
324
+ "x": 13.345,
325
+ "y": -7.221410699999997,
326
+ "_facingDirection": "x-"
327
+ },
328
+ {
329
+ "pinId": "schematic_port_74",
330
+ "x": 14.285000000000002,
331
+ "y": -7.221410699999997,
332
+ "_facingDirection": "x+"
333
+ }
334
+ ],
335
+ "sectionId": "esp12f_power_and_boot"
336
+ }
337
+ ],
338
+ "directConnections": [],
339
+ "netConnections": [
340
+ {
341
+ "netId": "GND",
342
+ "netLabelWidth": 0.42,
343
+ "netLabelHeight": 0.48,
344
+ "pinIds": [
345
+ "schematic_port_43",
346
+ "schematic_port_58",
347
+ "schematic_port_60",
348
+ "schematic_port_70"
349
+ ]
350
+ },
351
+ {
352
+ "netId": "V3_3",
353
+ "netLabelWidth": 0.42,
354
+ "netLabelHeight": 0.6,
355
+ "pinIds": [
356
+ "schematic_port_42",
357
+ "schematic_port_57",
358
+ "schematic_port_59",
359
+ "schematic_port_61",
360
+ "schematic_port_63",
361
+ "schematic_port_65",
362
+ "schematic_port_67"
363
+ ]
364
+ },
365
+ {
366
+ "netId": "ESP_RST",
367
+ "netLabelWidth": 0.96,
368
+ "pinIds": [
369
+ "schematic_port_35",
370
+ "schematic_port_64",
371
+ "schematic_port_71"
372
+ ]
373
+ },
374
+ {
375
+ "netId": "ESP_EN",
376
+ "netLabelWidth": 0.84,
377
+ "pinIds": [
378
+ "schematic_port_37",
379
+ "schematic_port_62"
380
+ ]
381
+ },
382
+ {
383
+ "netId": "RGB_BLUE_PWM",
384
+ "netLabelWidth": 1.56,
385
+ "pinIds": [
386
+ "schematic_port_39"
387
+ ]
388
+ },
389
+ {
390
+ "netId": "RGB_RED_PWM",
391
+ "netLabelWidth": 1.44,
392
+ "pinIds": [
393
+ "schematic_port_40"
394
+ ]
395
+ },
396
+ {
397
+ "netId": "RGB_GREEN_PWM",
398
+ "netLabelWidth": 1.68,
399
+ "pinIds": [
400
+ "schematic_port_41"
401
+ ]
402
+ },
403
+ {
404
+ "netId": "ESP_GPIO15",
405
+ "netLabelWidth": 1.32,
406
+ "pinIds": [
407
+ "schematic_port_44",
408
+ "schematic_port_69"
409
+ ]
410
+ },
411
+ {
412
+ "netId": "ESP_GPIO2",
413
+ "netLabelWidth": 1.2,
414
+ "pinIds": [
415
+ "schematic_port_45",
416
+ "schematic_port_68"
417
+ ]
418
+ },
419
+ {
420
+ "netId": "ESP_GPIO0",
421
+ "netLabelWidth": 1.2,
422
+ "pinIds": [
423
+ "schematic_port_46",
424
+ "schematic_port_66",
425
+ "schematic_port_73"
426
+ ]
427
+ },
428
+ {
429
+ "netId": "I2C_SDA",
430
+ "netLabelWidth": 0.96,
431
+ "pinIds": [
432
+ "schematic_port_47"
433
+ ]
434
+ },
435
+ {
436
+ "netId": "I2C_SCL",
437
+ "netLabelWidth": 0.96,
438
+ "pinIds": [
439
+ "schematic_port_48"
440
+ ]
441
+ },
442
+ {
443
+ "netId": "ESP_RX",
444
+ "netLabelWidth": 0.84,
445
+ "pinIds": [
446
+ "schematic_port_49"
447
+ ]
448
+ },
449
+ {
450
+ "netId": "ESP_TX",
451
+ "netLabelWidth": 0.84,
452
+ "pinIds": [
453
+ "schematic_port_50"
454
+ ]
455
+ }
456
+ ],
457
+ "textBoxes": [
458
+ {
459
+ "chipId": "schematic_component_9",
460
+ "center": {
461
+ "x": 11.475000000000001,
462
+ "y": -6.348910699999998
463
+ },
464
+ "width": 2.2799999999999994,
465
+ "height": 0.17999999999999972,
466
+ "text": "ESP_12F_ESP8266MOD_"
467
+ },
468
+ {
469
+ "chipId": "schematic_component_9",
470
+ "center": {
471
+ "x": 10.755000000000003,
472
+ "y": -3.703910699999997
473
+ },
474
+ "width": 0.9600000000000009,
475
+ "height": 0.24999999999999956,
476
+ "text": "ESP-12F"
477
+ }
478
+ ],
479
+ "availableNetLabelOrientations": {
480
+ "GND": [
481
+ "y-"
482
+ ],
483
+ "V3_3": [
484
+ "y+"
485
+ ],
486
+ "ESP_EN": [
487
+ "x-",
488
+ "x+"
489
+ ],
490
+ "ESP_RST": [
491
+ "x-",
492
+ "x+"
493
+ ],
494
+ "ESP_GPIO0": [
495
+ "x-",
496
+ "x+"
497
+ ],
498
+ "ESP_GPIO2": [
499
+ "x-",
500
+ "x+"
501
+ ],
502
+ "ESP_GPIO15": [
503
+ "x-",
504
+ "x+"
505
+ ],
506
+ "ESP_RX": [
507
+ "x-",
508
+ "x+"
509
+ ],
510
+ "ESP_TX": [
511
+ "x-",
512
+ "x+"
513
+ ],
514
+ "RGB_RED_PWM": [
515
+ "x-",
516
+ "x+"
517
+ ],
518
+ "RGB_GREEN_PWM": [
519
+ "x-",
520
+ "x+"
521
+ ],
522
+ "RGB_BLUE_PWM": [
523
+ "x-",
524
+ "x+"
525
+ ],
526
+ "I2C_SDA": [
527
+ "x-",
528
+ "x+"
529
+ ],
530
+ "I2C_SCL": [
531
+ "x-",
532
+ "x+"
533
+ ]
534
+ },
535
+ "maxMspPairDistance": 2.4,
536
+ "_hideRatsNet": false
537
+ }
@@ -0,0 +1,13 @@
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-board-648-esp12f-section.input.json"
6
+
7
+ test("board 648 ESP-12F power and boot section", () => {
8
+ const solver = new SchematicTracePipelineSolver(inputProblem as InputProblem)
9
+
10
+ solver.solve()
11
+
12
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
13
+ })
@@ -1,4 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
+ import { MAX_RECORDED_CANDIDATES } from "lib/solvers/AvailableNetOrientationSolver/constants"
2
3
  import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
4
  import type { InputProblem } from "lib/types/InputProblem"
4
5
  import "tests/fixtures/matcher"
@@ -30,5 +31,11 @@ test("core repro161 power section trace routing", () => {
30
31
  for (const railY of horizontalRailYs) {
31
32
  expect(railY).toBeCloseTo(EXPECTED_V3V3_RAIL_Y)
32
33
  }
34
+ expect(
35
+ solver.availableNetOrientationSolver!.stats.candidateEvaluations,
36
+ ).toBeGreaterThan(MAX_RECORDED_CANDIDATES)
37
+ expect(
38
+ solver.availableNetOrientationSolver!.stats.maxRecordedCandidates,
39
+ ).toBe(MAX_RECORDED_CANDIDATES)
33
40
  expect(solver).toMatchSolverSnapshot(import.meta.path)
34
41
  })
@@ -0,0 +1,122 @@
1
+ import { expect, test } from "bun:test"
2
+ import { AvailableNetOrientationObstacleIndex } from "lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationObstacleIndex"
3
+ import { ChipObstacleSpatialIndex } from "lib/data-structures/ChipObstacleSpatialIndex"
4
+ import type { NetLabelPlacement } from "lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver"
5
+ import type { SolvedTracePath } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceLinesSolver"
6
+
7
+ const netLabelPlacements: NetLabelPlacement[] = [
8
+ {
9
+ globalConnNetId: "net-1",
10
+ mspConnectionPairIds: ["trace-1"],
11
+ pinIds: ["pin-1", "pin-2"],
12
+ orientation: "x+",
13
+ anchorPoint: { x: 0, y: 0 },
14
+ center: { x: 1, y: 0 },
15
+ width: 2,
16
+ height: 1,
17
+ },
18
+ {
19
+ globalConnNetId: "net-2",
20
+ mspConnectionPairIds: [],
21
+ pinIds: ["pin-3"],
22
+ orientation: "x-",
23
+ anchorPoint: { x: 11, y: 10 },
24
+ center: { x: 10, y: 10 },
25
+ width: 2,
26
+ height: 1,
27
+ },
28
+ ]
29
+
30
+ const traces: SolvedTracePath[] = [
31
+ {
32
+ mspPairId: "trace-1",
33
+ dcConnNetId: "net-1",
34
+ globalConnNetId: "net-1",
35
+ pins: [
36
+ { pinId: "pin-1", chipId: "chip-1", x: -2, y: 3 },
37
+ { pinId: "pin-2", chipId: "chip-2", x: 2, y: 3 },
38
+ ],
39
+ tracePath: [
40
+ { x: -2, y: 3 },
41
+ { x: 2, y: 3 },
42
+ ],
43
+ mspConnectionPairIds: ["trace-1"],
44
+ pinIds: ["pin-1", "pin-2"],
45
+ },
46
+ ]
47
+
48
+ const chipObstacleSpatialIndex = new ChipObstacleSpatialIndex([
49
+ {
50
+ chipId: "chip-obstacle",
51
+ center: { x: 0, y: 3 },
52
+ width: 1,
53
+ height: 1,
54
+ pins: [],
55
+ },
56
+ ])
57
+
58
+ test("queries only nearby net labels and trace segments", () => {
59
+ const obstacleIndex = new AvailableNetOrientationObstacleIndex({
60
+ chipObstacleSpatialIndex,
61
+ netLabelPlacements,
62
+ traces,
63
+ })
64
+
65
+ expect(
66
+ obstacleIndex.getLabelIndicesInBounds({
67
+ minX: -0.1,
68
+ minY: -0.1,
69
+ maxX: 0.1,
70
+ maxY: 0.1,
71
+ }),
72
+ ).toEqual([0])
73
+ expect(
74
+ obstacleIndex.getTraceSegmentsInBounds({
75
+ minX: -0.1,
76
+ minY: 2.9,
77
+ maxX: 0.1,
78
+ maxY: 3.1,
79
+ }),
80
+ ).toHaveLength(1)
81
+ expect(
82
+ obstacleIndex.getTraceSegmentsInBounds({
83
+ minX: -0.1,
84
+ minY: 9.9,
85
+ maxX: 0.1,
86
+ maxY: 10.1,
87
+ }),
88
+ ).toHaveLength(0)
89
+ expect(obstacleIndex.doesTracePathCrossChip(traces[0]!.tracePath)).toBe(true)
90
+ expect(
91
+ obstacleIndex.getLabelIndicesNearTracePath([
92
+ { x: 2 + 5e-10, y: -1 },
93
+ { x: 2 + 5e-10, y: 1 },
94
+ ]),
95
+ ).toEqual([0])
96
+ })
97
+
98
+ test("rebuilds after a net label moves", () => {
99
+ const obstacleIndex = new AvailableNetOrientationObstacleIndex({
100
+ chipObstacleSpatialIndex,
101
+ netLabelPlacements,
102
+ traces,
103
+ })
104
+ const movedNetLabelPlacements = [
105
+ { ...netLabelPlacements[0]!, center: { x: 20, y: 20 } },
106
+ netLabelPlacements[1]!,
107
+ ]
108
+
109
+ obstacleIndex.rebuild({
110
+ netLabelPlacements: movedNetLabelPlacements,
111
+ traces,
112
+ })
113
+
114
+ expect(
115
+ obstacleIndex.getLabelIndicesInBounds({
116
+ minX: -0.1,
117
+ minY: -0.1,
118
+ maxX: 0.1,
119
+ maxY: 0.1,
120
+ }),
121
+ ).toHaveLength(0)
122
+ })