@tscircuit/matchpack 0.0.1 → 0.0.3
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.d.ts +7 -1
- package/dist/index.js +47 -18
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ type Chip = {
|
|
|
47
47
|
chipId: ChipId;
|
|
48
48
|
pins: PinId[];
|
|
49
49
|
size: Point;
|
|
50
|
+
availableRotations?: Array<0 | 90 | 180 | 270>;
|
|
50
51
|
};
|
|
51
52
|
type Group = {
|
|
52
53
|
groupId: GroupId;
|
|
@@ -70,6 +71,10 @@ type InputProblem = {
|
|
|
70
71
|
/** This is a two-way map */
|
|
71
72
|
pinStrongConnMap: Record<`${PinId}-${PinId}`, boolean>;
|
|
72
73
|
netConnMap: Record<`${PinId}-${NetId}`, boolean>;
|
|
74
|
+
/** The minimum gap between chips within a partition */
|
|
75
|
+
chipGap: number;
|
|
76
|
+
/** The minimum gap between two partitions */
|
|
77
|
+
partitionGap: number;
|
|
73
78
|
};
|
|
74
79
|
|
|
75
80
|
/**
|
|
@@ -118,10 +123,12 @@ type LaidOutPartition = InputProblem;
|
|
|
118
123
|
interface PartitionPackingSolverInput {
|
|
119
124
|
resolvedLayout: OutputLayout;
|
|
120
125
|
laidOutPartitions: LaidOutPartition[];
|
|
126
|
+
inputProblem: InputProblem;
|
|
121
127
|
}
|
|
122
128
|
declare class PartitionPackingSolver extends BaseSolver {
|
|
123
129
|
resolvedLayout: OutputLayout;
|
|
124
130
|
laidOutPartitions: LaidOutPartition[];
|
|
131
|
+
inputProblem: InputProblem;
|
|
125
132
|
finalLayout: OutputLayout | null;
|
|
126
133
|
phasedPackSolver: PhasedPackSolver | null;
|
|
127
134
|
constructor(input: PartitionPackingSolverInput);
|
|
@@ -174,7 +181,6 @@ declare class SinglePinRangeLayoutSolver extends BaseSolver {
|
|
|
174
181
|
inputProblem: InputProblem;
|
|
175
182
|
layoutApplied: boolean;
|
|
176
183
|
layout: OutputLayout | null;
|
|
177
|
-
debugPackInput: any;
|
|
178
184
|
constructor(pinRange: PinRange, inputProblem: InputProblem);
|
|
179
185
|
_step(): void;
|
|
180
186
|
/**
|
package/dist/index.js
CHANGED
|
@@ -20727,7 +20727,9 @@ var ChipPartitionsSolver = class extends BaseSolver {
|
|
|
20727
20727
|
groupPinMap,
|
|
20728
20728
|
netMap,
|
|
20729
20729
|
pinStrongConnMap,
|
|
20730
|
-
netConnMap
|
|
20730
|
+
netConnMap,
|
|
20731
|
+
chipGap: originalProblem.chipGap,
|
|
20732
|
+
partitionGap: originalProblem.partitionGap
|
|
20731
20733
|
};
|
|
20732
20734
|
}
|
|
20733
20735
|
visualize() {
|
|
@@ -20747,12 +20749,14 @@ var ChipPartitionsSolver = class extends BaseSolver {
|
|
|
20747
20749
|
var PartitionPackingSolver = class extends BaseSolver {
|
|
20748
20750
|
resolvedLayout;
|
|
20749
20751
|
laidOutPartitions;
|
|
20752
|
+
inputProblem;
|
|
20750
20753
|
finalLayout = null;
|
|
20751
20754
|
phasedPackSolver = null;
|
|
20752
20755
|
constructor(input) {
|
|
20753
20756
|
super();
|
|
20754
20757
|
this.resolvedLayout = input.resolvedLayout;
|
|
20755
20758
|
this.laidOutPartitions = input.laidOutPartitions;
|
|
20759
|
+
this.inputProblem = input.inputProblem;
|
|
20756
20760
|
}
|
|
20757
20761
|
_step() {
|
|
20758
20762
|
try {
|
|
@@ -20830,14 +20834,18 @@ var PartitionPackingSolver = class extends BaseSolver {
|
|
|
20830
20834
|
const resolvedLayout = this.resolvedLayout;
|
|
20831
20835
|
const pinToNetworkMap = /* @__PURE__ */ new Map();
|
|
20832
20836
|
for (const laidOutPartition of this.laidOutPartitions) {
|
|
20833
|
-
for (const [connKey, connected] of Object.entries(
|
|
20837
|
+
for (const [connKey, connected] of Object.entries(
|
|
20838
|
+
laidOutPartition.netConnMap
|
|
20839
|
+
)) {
|
|
20834
20840
|
if (!connected) continue;
|
|
20835
20841
|
const [pinId, netId] = connKey.split("-");
|
|
20836
20842
|
if (pinId && netId) {
|
|
20837
20843
|
pinToNetworkMap.set(pinId, netId);
|
|
20838
20844
|
}
|
|
20839
20845
|
}
|
|
20840
|
-
for (const [connKey, connected] of Object.entries(
|
|
20846
|
+
for (const [connKey, connected] of Object.entries(
|
|
20847
|
+
laidOutPartition.pinStrongConnMap
|
|
20848
|
+
)) {
|
|
20841
20849
|
if (!connected) continue;
|
|
20842
20850
|
const pins = connKey.split("-");
|
|
20843
20851
|
if (pins.length === 2 && pins[0] && pins[1]) {
|
|
@@ -20883,15 +20891,32 @@ var PartitionPackingSolver = class extends BaseSolver {
|
|
|
20883
20891
|
});
|
|
20884
20892
|
}
|
|
20885
20893
|
}
|
|
20894
|
+
let availableRotationDegrees = [
|
|
20895
|
+
0,
|
|
20896
|
+
90,
|
|
20897
|
+
180,
|
|
20898
|
+
270
|
|
20899
|
+
];
|
|
20900
|
+
for (const chipId of group.chipIds) {
|
|
20901
|
+
const chip = this.laidOutPartitions[group.partitionIndex].chipMap[chipId];
|
|
20902
|
+
const chipRotations = chip.availableRotations || [0, 90, 180, 270];
|
|
20903
|
+
availableRotationDegrees = availableRotationDegrees.filter(
|
|
20904
|
+
(rotation2) => chipRotations.includes(rotation2)
|
|
20905
|
+
);
|
|
20906
|
+
}
|
|
20907
|
+
if (availableRotationDegrees.length === 0) {
|
|
20908
|
+
availableRotationDegrees = [0];
|
|
20909
|
+
}
|
|
20886
20910
|
return {
|
|
20887
20911
|
componentId: `partition_${group.partitionIndex}`,
|
|
20888
|
-
pads
|
|
20912
|
+
pads,
|
|
20913
|
+
availableRotationDegrees
|
|
20889
20914
|
};
|
|
20890
20915
|
});
|
|
20891
20916
|
return {
|
|
20892
20917
|
components: packComponents,
|
|
20893
|
-
minGap:
|
|
20894
|
-
//
|
|
20918
|
+
minGap: this.inputProblem.partitionGap,
|
|
20919
|
+
// Use partitionGap from input problem
|
|
20895
20920
|
packOrderStrategy: "largest_to_smallest",
|
|
20896
20921
|
packPlacementStrategy: "minimum_sum_squared_distance_to_network"
|
|
20897
20922
|
};
|
|
@@ -20942,7 +20967,9 @@ var PartitionPackingSolver = class extends BaseSolver {
|
|
|
20942
20967
|
groupPinMap: {},
|
|
20943
20968
|
pinStrongConnMap: {},
|
|
20944
20969
|
netMap: {},
|
|
20945
|
-
netConnMap: {}
|
|
20970
|
+
netConnMap: {},
|
|
20971
|
+
chipGap: this.inputProblem.chipGap,
|
|
20972
|
+
partitionGap: this.inputProblem.partitionGap
|
|
20946
20973
|
};
|
|
20947
20974
|
for (const laidOutPartition of this.laidOutPartitions) {
|
|
20948
20975
|
Object.assign(combinedProblem.chipMap, laidOutPartition.chipMap);
|
|
@@ -20961,7 +20988,8 @@ var PartitionPackingSolver = class extends BaseSolver {
|
|
|
20961
20988
|
getConstructorParams() {
|
|
20962
20989
|
return {
|
|
20963
20990
|
resolvedLayout: this.resolvedLayout,
|
|
20964
|
-
laidOutPartitions: this.laidOutPartitions
|
|
20991
|
+
laidOutPartitions: this.laidOutPartitions,
|
|
20992
|
+
inputProblem: this.inputProblem
|
|
20965
20993
|
};
|
|
20966
20994
|
}
|
|
20967
20995
|
};
|
|
@@ -20972,8 +21000,6 @@ var SinglePinRangeLayoutSolver = class extends BaseSolver {
|
|
|
20972
21000
|
inputProblem;
|
|
20973
21001
|
layoutApplied = false;
|
|
20974
21002
|
layout = null;
|
|
20975
|
-
debugPackInput = null;
|
|
20976
|
-
// For debugging - captures the pack input
|
|
20977
21003
|
constructor(pinRange, inputProblem) {
|
|
20978
21004
|
super();
|
|
20979
21005
|
this.pinRange = pinRange;
|
|
@@ -21175,7 +21201,8 @@ var SinglePinRangeLayoutSolver = class extends BaseSolver {
|
|
|
21175
21201
|
});
|
|
21176
21202
|
return {
|
|
21177
21203
|
componentId: chipId,
|
|
21178
|
-
pads
|
|
21204
|
+
pads,
|
|
21205
|
+
availableRotationDegrees: chip.availableRotations || [0, 90, 180, 270]
|
|
21179
21206
|
};
|
|
21180
21207
|
});
|
|
21181
21208
|
if (components.length === 0) {
|
|
@@ -21186,12 +21213,11 @@ var SinglePinRangeLayoutSolver = class extends BaseSolver {
|
|
|
21186
21213
|
}
|
|
21187
21214
|
const packInput = {
|
|
21188
21215
|
components,
|
|
21189
|
-
minGap:
|
|
21190
|
-
//
|
|
21216
|
+
minGap: this.inputProblem.chipGap,
|
|
21217
|
+
// Use chipGap from input problem
|
|
21191
21218
|
packOrderStrategy: "largest_to_smallest",
|
|
21192
21219
|
packPlacementStrategy: "minimum_sum_squared_distance_to_network"
|
|
21193
21220
|
};
|
|
21194
|
-
this.debugPackInput = packInput;
|
|
21195
21221
|
const packResult = pack(packInput);
|
|
21196
21222
|
const chipPlacements = {};
|
|
21197
21223
|
for (const component of packResult.components) {
|
|
@@ -22097,10 +22123,13 @@ var LayoutPipelineSolver = class extends BaseSolver {
|
|
|
22097
22123
|
definePipelineStep(
|
|
22098
22124
|
"partitionPackingSolver",
|
|
22099
22125
|
PartitionPackingSolver,
|
|
22100
|
-
() => [
|
|
22101
|
-
|
|
22102
|
-
|
|
22103
|
-
|
|
22126
|
+
() => [
|
|
22127
|
+
{
|
|
22128
|
+
resolvedLayout: this.pinRangeOverlapSolver.resolvedLayout,
|
|
22129
|
+
laidOutPartitions: this.chipPartitions || [this.inputProblem],
|
|
22130
|
+
inputProblem: this.inputProblem
|
|
22131
|
+
}
|
|
22132
|
+
],
|
|
22104
22133
|
{
|
|
22105
22134
|
onSolved: (_solver) => {
|
|
22106
22135
|
}
|