@tscircuit/fanout-solver 0.0.37 → 0.0.39
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/README.md +23 -2
- package/lib/add-via-layer-metadata.ts +48 -0
- package/lib/complete-original-endpoints.ts +30 -2
- package/lib/fanout-solver.ts +721 -33
- package/lib/geometry.ts +21 -0
- package/lib/get-routed-trace-copper.ts +15 -6
- package/lib/index.ts +3 -0
- package/lib/layer-names.ts +40 -0
- package/lib/match-bus-lengths.ts +681 -0
- package/lib/match-component-dogbone-via-sites.ts +584 -0
- package/lib/prepare-buses.ts +26 -0
- package/lib/route-bus.ts +872 -112
- package/lib/route-via-minimal-winding.ts +390 -74
- package/lib/types.ts +39 -7
- package/lib/validate-fanout-solution.ts +62 -6
- package/lib/validate-routed-copper-drc.ts +47 -8
- package/package.json +1 -1
package/lib/geometry.ts
CHANGED
|
@@ -98,6 +98,27 @@ export function pointIsInsideObstacle(
|
|
|
98
98
|
)
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
export function circleFitsInsideObstacle(params: {
|
|
102
|
+
center: Point2D
|
|
103
|
+
diameter: number
|
|
104
|
+
obstacle: Obstacle
|
|
105
|
+
tolerance?: number
|
|
106
|
+
}): boolean {
|
|
107
|
+
const { center, diameter, obstacle, tolerance = EPSILON } = params
|
|
108
|
+
const radius = diameter / 2
|
|
109
|
+
if (obstacleIsCircular(obstacle)) {
|
|
110
|
+
return (
|
|
111
|
+
distance(center, obstacle.center) + radius <=
|
|
112
|
+
obstacle.width / 2 + tolerance
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
const localCenter = toObstacleLocalPoint(center, obstacle)
|
|
116
|
+
return (
|
|
117
|
+
Math.abs(localCenter.x) + radius <= obstacle.width / 2 + tolerance &&
|
|
118
|
+
Math.abs(localCenter.y) + radius <= obstacle.height / 2 + tolerance
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
101
122
|
export function distancePointToObstacle(
|
|
102
123
|
point: Point2D,
|
|
103
124
|
obstacle: Obstacle,
|
|
@@ -2,7 +2,7 @@ import type {
|
|
|
2
2
|
SimpleRouteJson,
|
|
3
3
|
SimplifiedPcbTrace,
|
|
4
4
|
} from "@tscircuit/capacity-autorouter"
|
|
5
|
-
import { getCopperLayerNames,
|
|
5
|
+
import { getCopperLayerNames, getRouteViaSpanLayers } from "./layer-names"
|
|
6
6
|
import type { Point2D, RoutedSegment } from "./types"
|
|
7
7
|
|
|
8
8
|
export interface RoutedTraceVia {
|
|
@@ -21,6 +21,7 @@ export interface RoutedTraceCopper {
|
|
|
21
21
|
export function getRoutedTraceCopper(
|
|
22
22
|
srj: SimpleRouteJson,
|
|
23
23
|
trace: SimplifiedPcbTrace,
|
|
24
|
+
allowBlindAndBuriedVias = true,
|
|
24
25
|
): RoutedTraceCopper {
|
|
25
26
|
const layerNames = getCopperLayerNames(srj.layerCount)
|
|
26
27
|
const segments: RoutedSegment[] = []
|
|
@@ -39,11 +40,16 @@ export function getRoutedTraceCopper(
|
|
|
39
40
|
srj.min_via_pad_diameter ??
|
|
40
41
|
srj.minViaDiameter ??
|
|
41
42
|
srj.minTraceWidth,
|
|
42
|
-
spanLayers:
|
|
43
|
-
routePoint.from_layer,
|
|
44
|
-
routePoint.to_layer,
|
|
43
|
+
spanLayers: getRouteViaSpanLayers({
|
|
44
|
+
fromLayer: routePoint.from_layer,
|
|
45
|
+
toLayer: routePoint.to_layer,
|
|
46
|
+
layers:
|
|
47
|
+
"layers" in routePoint && Array.isArray(routePoint.layers)
|
|
48
|
+
? (routePoint.layers as string[])
|
|
49
|
+
: undefined,
|
|
45
50
|
layerNames,
|
|
46
|
-
|
|
51
|
+
allowBlindAndBuriedVias,
|
|
52
|
+
}),
|
|
47
53
|
})
|
|
48
54
|
previousWire = undefined
|
|
49
55
|
continue
|
|
@@ -78,6 +84,9 @@ export function getRoutedTraceCopper(
|
|
|
78
84
|
|
|
79
85
|
export function getAllRoutedTraceCopper(
|
|
80
86
|
srj: SimpleRouteJson,
|
|
87
|
+
allowBlindAndBuriedVias = true,
|
|
81
88
|
): RoutedTraceCopper[] {
|
|
82
|
-
return (srj.traces ?? []).map((trace) =>
|
|
89
|
+
return (srj.traces ?? []).map((trace) =>
|
|
90
|
+
getRoutedTraceCopper(srj, trace, allowBlindAndBuriedVias),
|
|
91
|
+
)
|
|
83
92
|
}
|
package/lib/index.ts
CHANGED
|
@@ -24,10 +24,13 @@ export type {
|
|
|
24
24
|
FanoutPlaneConnectivity,
|
|
25
25
|
FanoutPlaneTermination,
|
|
26
26
|
FanoutRoutePlan,
|
|
27
|
+
FanoutRoutePoint,
|
|
28
|
+
FanoutSimplifiedPcbTrace,
|
|
27
29
|
FanoutSolverOptions,
|
|
28
30
|
FanoutSolverOutput,
|
|
29
31
|
FanoutValidationIssue,
|
|
30
32
|
FanoutValidationReport,
|
|
33
|
+
FanoutViaRoutePoint,
|
|
31
34
|
Point2D,
|
|
32
35
|
PreparedBus,
|
|
33
36
|
SimpleRouteJsonWithFanoutPlanes,
|
package/lib/layer-names.ts
CHANGED
|
@@ -34,6 +34,46 @@ export function getLayerSpan(
|
|
|
34
34
|
return layerNames.slice(firstIndex, lastIndex + 1)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
export function getViaSpanLayers(params: {
|
|
38
|
+
fromLayer: string
|
|
39
|
+
toLayer: string
|
|
40
|
+
layerNames: string[]
|
|
41
|
+
allowBlindAndBuriedVias: boolean
|
|
42
|
+
}): string[] {
|
|
43
|
+
const { fromLayer, toLayer, layerNames, allowBlindAndBuriedVias } = params
|
|
44
|
+
const logicalSpan = getLayerSpan(fromLayer, toLayer, layerNames)
|
|
45
|
+
return allowBlindAndBuriedVias ? logicalSpan : [...layerNames]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getRouteViaSpanLayers(params: {
|
|
49
|
+
fromLayer: string
|
|
50
|
+
toLayer: string
|
|
51
|
+
layers?: readonly string[]
|
|
52
|
+
layerNames: string[]
|
|
53
|
+
allowBlindAndBuriedVias: boolean
|
|
54
|
+
}): string[] {
|
|
55
|
+
const { fromLayer, toLayer, layers, layerNames, allowBlindAndBuriedVias } =
|
|
56
|
+
params
|
|
57
|
+
const configuredSpan = getViaSpanLayers({
|
|
58
|
+
fromLayer,
|
|
59
|
+
toLayer,
|
|
60
|
+
layerNames,
|
|
61
|
+
allowBlindAndBuriedVias,
|
|
62
|
+
})
|
|
63
|
+
if (!layers) return configuredSpan
|
|
64
|
+
if (
|
|
65
|
+
layers.length === 0 ||
|
|
66
|
+
!layers.includes(fromLayer) ||
|
|
67
|
+
!layers.includes(toLayer) ||
|
|
68
|
+
layers.some((layer) => !layerNames.includes(layer))
|
|
69
|
+
) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
`FanoutSolver: route via from "${fromLayer}" to "${toLayer}" has an invalid physical layer span`,
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
return [...layers]
|
|
75
|
+
}
|
|
76
|
+
|
|
37
77
|
export function generateLayerAssignments(params: {
|
|
38
78
|
busIds: string[]
|
|
39
79
|
layers: string[]
|