@tscircuit/core 0.0.1898 → 0.0.1899

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.
Files changed (2) hide show
  1. package/dist/index.js +137 -33
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -26555,6 +26555,7 @@ function normalizeFanoutPlanCorners(params) {
26555
26555
  if (new Set(params.plans.map((p) => p.connectionIndex)).size !== params.plans.length)
26556
26556
  return null;
26557
26557
  let plans = [...params.plans];
26558
+ let repairedSourceCorners = false;
26558
26559
  if (params.repairPlaneSourceCorners || params.repairSignalSourceCorners) {
26559
26560
  for (let index = 0; index < plans.length; index++) {
26560
26561
  const plan = plans[index];
@@ -26575,8 +26576,14 @@ function normalizeFanoutPlanCorners(params) {
26575
26576
  );
26576
26577
  if (!normalized) return null;
26577
26578
  plans[index] = normalized;
26579
+ repairedSourceCorners = true;
26578
26580
  }
26579
26581
  }
26582
+ if (repairedSourceCorners && params.rematchRepairedLengths) {
26583
+ const rematched = params.rematchRepairedLengths(plans);
26584
+ if (!rematched) return null;
26585
+ plans = rematched;
26586
+ }
26580
26587
  const sourceNormalizedPlans = [...plans];
26581
26588
  const pairs3 = getDeclaredDifferentialPairs(params.inputSrj);
26582
26589
  for (const plan of plans) {
@@ -33338,6 +33345,90 @@ function buildOutputSimpleRouteJson(params) {
33338
33345
  };
33339
33346
  }
33340
33347
 
33348
+ // node_modules/@tscircuit/fanout-solver/lib/dense-boundary-routing-policy.ts
33349
+ var minimumJointBoundaryBusCount = 5;
33350
+ var maximumJointBoundaryBusCount = 40;
33351
+ var maximumJointBoundaryConnectionCount = 64;
33352
+ var minimumLargeBoundaryOnlyBusCount = 10;
33353
+ var minimumMixedRoutingPlaneBusCount = 8;
33354
+ function shouldUseJointBoundaryViaReservation(boundaryBusConnectionCounts) {
33355
+ const boundaryBusCount = boundaryBusConnectionCounts.length;
33356
+ const boundaryConnectionCount = boundaryBusConnectionCounts.reduce(
33357
+ (sum, count) => sum + count,
33358
+ 0
33359
+ );
33360
+ return boundaryBusCount >= minimumJointBoundaryBusCount && boundaryBusCount <= maximumJointBoundaryBusCount && boundaryConnectionCount <= maximumJointBoundaryConnectionCount || boundaryBusCount === 4 && new Set(boundaryBusConnectionCounts).size > 1;
33361
+ }
33362
+ function getDenseBoundaryRoutingMode({
33363
+ boundaryBusConnectionCounts,
33364
+ planeBusCount
33365
+ }) {
33366
+ const boundaryBusCount = boundaryBusConnectionCounts.length;
33367
+ if (boundaryBusCount <= minimumLargeBoundaryOnlyBusCount - 1 && planeBusCount >= minimumMixedRoutingPlaneBusCount) {
33368
+ return "mixed_with_planes";
33369
+ }
33370
+ if (boundaryBusCount >= minimumLargeBoundaryOnlyBusCount && planeBusCount === 0 && shouldUseJointBoundaryViaReservation(boundaryBusConnectionCounts)) {
33371
+ return "large_boundary_only";
33372
+ }
33373
+ return null;
33374
+ }
33375
+ function getAverageBusBoundaryTargetTrack(bus) {
33376
+ if (!bus.exitEdge) {
33377
+ throw new Error(
33378
+ `Cannot order boundary bus ${bus.busId} without an exit edge`
33379
+ );
33380
+ }
33381
+ const boundaryDirection = getDirectionForExitEdge(bus.exitEdge);
33382
+ return bus.connections.reduce(
33383
+ (sum, connection) => sum + getBoundaryTargetTrack({ bus, connection, boundaryDirection }),
33384
+ 0
33385
+ ) / bus.connections.length;
33386
+ }
33387
+ function orderDenseBoundaryBusesForRouting({
33388
+ busesInRoutingOrder,
33389
+ busLayerAssignments,
33390
+ routingMode
33391
+ }) {
33392
+ if (routingMode !== "large_boundary_only") return [...busesInRoutingOrder];
33393
+ const singletonBuses = busesInRoutingOrder.filter(
33394
+ (bus) => bus.connections.length === 1
33395
+ );
33396
+ if (new Set(singletonBuses.map((bus) => bus.exitEdge)).size !== 1) {
33397
+ return [...busesInRoutingOrder];
33398
+ }
33399
+ const nonSingletonBuses = [
33400
+ ...busesInRoutingOrder.filter((bus) => bus.connections.length >= 8).toSorted(
33401
+ (first, second) => getAverageBusBoundaryTargetTrack(second) - getAverageBusBoundaryTargetTrack(first)
33402
+ ),
33403
+ ...busesInRoutingOrder.filter(
33404
+ (bus) => bus.connections.length > 1 && bus.connections.length < 8
33405
+ )
33406
+ ];
33407
+ const singletonLayerGroups = [];
33408
+ for (const bus of singletonBuses) {
33409
+ const targetLayer2 = busLayerAssignments[bus.busId];
33410
+ if (!targetLayer2) {
33411
+ throw new Error(`Cannot order boundary bus ${bus.busId} without a layer`);
33412
+ }
33413
+ let singletonLayerGroup = singletonLayerGroups.find(
33414
+ (candidate) => candidate.targetLayer === targetLayer2
33415
+ );
33416
+ if (!singletonLayerGroup) {
33417
+ singletonLayerGroup = { targetLayer: targetLayer2, buses: [] };
33418
+ singletonLayerGroups.push(singletonLayerGroup);
33419
+ }
33420
+ singletonLayerGroup.buses.push(bus);
33421
+ }
33422
+ return [
33423
+ ...nonSingletonBuses,
33424
+ ...singletonLayerGroups.flatMap(
33425
+ (singletonLayerGroup) => singletonLayerGroup.buses.toSorted(
33426
+ (first, second) => getAverageBusBoundaryTargetTrack(second) - getAverageBusBoundaryTargetTrack(first)
33427
+ )
33428
+ )
33429
+ ];
33430
+ }
33431
+
33341
33432
  // node_modules/@tscircuit/fanout-solver/lib/source-pad-reentry.ts
33342
33433
  var EPSILON15 = 1e-7;
33343
33434
  function getSourcePadReentries(plan, clearance) {
@@ -43740,9 +43831,6 @@ function busUsesCoordinatedWinding(bus) {
43740
43831
  )
43741
43832
  );
43742
43833
  }
43743
- function shouldUseJointBoundaryViaReservation(boundaryBusConnectionCounts) {
43744
- return boundaryBusConnectionCounts.length === 5 || boundaryBusConnectionCounts.length === 6 || boundaryBusConnectionCounts.length === 7 || boundaryBusConnectionCounts.length === 8 || boundaryBusConnectionCounts.length === 9 || boundaryBusConnectionCounts.length === 4 && new Set(boundaryBusConnectionCounts).size > 1;
43745
- }
43746
43834
  function shouldDeferSingletonBoundaryViaReservation(boundaryBusConnectionCounts) {
43747
43835
  const boundaryBusCount = boundaryBusConnectionCounts.length;
43748
43836
  const singletonBusCount = boundaryBusConnectionCounts.filter(
@@ -44813,13 +44901,20 @@ var FanoutSolver = class extends BaseSolver {
44813
44901
  const unroutablePlaneBusIds = /* @__PURE__ */ new Set();
44814
44902
  let failedBoundaryBus;
44815
44903
  let failedWideBoundaryBus;
44904
+ const boundaryBusConnectionCounts = boundaryBuses.map(
44905
+ (bus) => bus.connections.length
44906
+ );
44907
+ const denseBoundaryRoutingMode = getDenseBoundaryRoutingMode({
44908
+ boundaryBusConnectionCounts,
44909
+ planeBusCount: planeBuses.length
44910
+ });
44816
44911
  debugDense(
44817
44912
  "start",
44818
44913
  boundaryBuses.map((bus) => `${bus.busId}:${bus.connections.length}`),
44819
44914
  `planes:${planeBuses.length}`,
44820
44915
  `joint:${useJointBoundaryViaReservation}`
44821
44916
  );
44822
- if (boundaryBuses.length === 0 || boundaryBuses.length > 9 || planeBuses.length < 8 || boundaryBuses.some((bus) => !busUsesCoordinatedWinding(bus)) || planeBuses.some((bus) => bus.connections.length !== 1) || boundaryBuses.length + planeBuses.length !== params.busesInRoutingOrder.length) {
44917
+ if (boundaryBuses.length === 0 || denseBoundaryRoutingMode === null || boundaryBuses.some((bus) => !busUsesCoordinatedWinding(bus)) || planeBuses.some((bus) => bus.connections.length !== 1) || boundaryBuses.length + planeBuses.length !== params.busesInRoutingOrder.length) {
44823
44918
  return null;
44824
44919
  }
44825
44920
  const connectionNameByIndex = new Map(
@@ -44829,9 +44924,6 @@ var FanoutSolver = class extends BaseSolver {
44829
44924
  )
44830
44925
  )
44831
44926
  );
44832
- const boundaryBusConnectionCounts = boundaryBuses.map(
44833
- (bus) => bus.connections.length
44834
- );
44835
44927
  const singletonBoundaryBusCount = boundaryBusConnectionCounts.filter(
44836
44928
  (connectionCount) => connectionCount === 1
44837
44929
  ).length;
@@ -45132,17 +45224,21 @@ var FanoutSolver = class extends BaseSolver {
45132
45224
  });
45133
45225
  yield;
45134
45226
  if (seedViaPoints) {
45135
- const denseBoundaryBusesInRoutingOrder = [
45136
- ...hasForeignAllLayerObstaclesInComponent ? [] : multiLayerLeadingSingletonBuses,
45137
- ...boundaryBuses.filter(
45138
- (bus) => (hasForeignAllLayerObstaclesInComponent || !multiLayerLeadingSingletonBuses.includes(bus)) && !throughAllLeadingBuses.includes(bus)
45139
- ).flatMap((bus) => [
45140
- ...throughAllLeadingBuses.filter(
45141
- (candidate) => getContainingWideSourceField(candidate) === bus
45142
- ),
45143
- bus
45144
- ])
45145
- ];
45227
+ const denseBoundaryBusesInRoutingOrder = orderDenseBoundaryBusesForRouting({
45228
+ busesInRoutingOrder: [
45229
+ ...hasForeignAllLayerObstaclesInComponent ? [] : multiLayerLeadingSingletonBuses,
45230
+ ...boundaryBuses.filter(
45231
+ (bus) => (hasForeignAllLayerObstaclesInComponent || !multiLayerLeadingSingletonBuses.includes(bus)) && !throughAllLeadingBuses.includes(bus)
45232
+ ).flatMap((bus) => [
45233
+ ...throughAllLeadingBuses.filter(
45234
+ (candidate) => getContainingWideSourceField(candidate) === bus
45235
+ ),
45236
+ bus
45237
+ ])
45238
+ ],
45239
+ busLayerAssignments: params.busLayerAssignments,
45240
+ routingMode: denseBoundaryRoutingMode
45241
+ });
45146
45242
  const allWideBusesExitDirectly = wideBoundaryBuses.every(
45147
45243
  (bus) => bus.exitEdge && bus.direction === getDirectionForExitEdge(bus.exitEdge)
45148
45244
  );
@@ -45684,7 +45780,6 @@ var FanoutSolver = class extends BaseSolver {
45684
45780
  debugDense("route:complete", bus.busId, busPlans.length);
45685
45781
  return true;
45686
45782
  }.bind(this);
45687
- const firstBoundaryBus = denseBoundaryBusesInRoutingOrder[0];
45688
45783
  const routedBoundaryBuses = [];
45689
45784
  const reserveAllPlaneDogbonesAfterFirstWideBus = (bus) => {
45690
45785
  if (bus.connections.length >= 8 && !useConfiguredDensePlaneRouting && !useSameNetPlaneCopperStaging && process.env.FANOUT_DEBUG_NO_PLANE_EXPANSION !== "1" && activeBoundaryReservationPlaneBuses.length < planeBuses.length) {
@@ -45692,23 +45787,32 @@ var FanoutSolver = class extends BaseSolver {
45692
45787
  debugDense("plane-reservations:expanded", planeBuses.length);
45693
45788
  }
45694
45789
  };
45695
- const firstBoundaryBusRouted = yield* routeMatchedBoundaryBusSteps(firstBoundaryBus);
45696
- this.setInProgressPlans({
45697
- phase: "route-dense-boundary-buses",
45698
- plans: matchedPlans,
45699
- strategy: "default",
45700
- unitIndex: ++denseWorkUnitIndex,
45701
- unitCount: denseWorkUnitCount,
45702
- busId: firstBoundaryBus.busId
45703
- });
45704
- yield;
45705
- if (firstBoundaryBusRouted) {
45790
+ const firstBoundaryCandidates = denseBoundaryRoutingMode === "large_boundary_only" ? denseBoundaryBusesInRoutingOrder : denseBoundaryBusesInRoutingOrder.slice(0, 1);
45791
+ let firstBoundaryBus;
45792
+ for (const candidate of firstBoundaryCandidates) {
45793
+ const candidateRouted = yield* routeMatchedBoundaryBusSteps(candidate);
45794
+ this.setInProgressPlans({
45795
+ phase: "route-dense-boundary-buses",
45796
+ plans: matchedPlans,
45797
+ strategy: "default",
45798
+ unitIndex: ++denseWorkUnitIndex,
45799
+ unitCount: denseWorkUnitCount,
45800
+ busId: candidate.busId
45801
+ });
45802
+ yield;
45803
+ if (!candidateRouted) continue;
45804
+ firstBoundaryBus = candidate;
45805
+ break;
45806
+ }
45807
+ if (firstBoundaryBus) {
45706
45808
  routedBoundaryBuses.push(firstBoundaryBus);
45707
45809
  reserveAllPlaneDogbonesAfterFirstWideBus(firstBoundaryBus);
45708
45810
  } else {
45709
45811
  matchedRoutingSucceeded = false;
45710
45812
  }
45711
- const remainingBoundaryBuses = denseBoundaryBusesInRoutingOrder.slice(1);
45813
+ const remainingBoundaryBuses = denseBoundaryBusesInRoutingOrder.filter(
45814
+ (bus) => bus !== firstBoundaryBus
45815
+ );
45712
45816
  while (matchedRoutingSucceeded && remainingBoundaryBuses.length > 0) {
45713
45817
  const blockingSegments = matchedPlans.flatMap(
45714
45818
  (plan) => plan.segments.map((segment2) => ({
@@ -61704,7 +61808,7 @@ function Group_getRoutingPhasePlans(group) {
61704
61808
  var package_default = {
61705
61809
  name: "@tscircuit/core",
61706
61810
  type: "module",
61707
- version: "0.0.1897",
61811
+ version: "0.0.1898",
61708
61812
  types: "dist/index.d.ts",
61709
61813
  main: "dist/index.js",
61710
61814
  module: "dist/index.js",
@@ -61744,7 +61848,7 @@ var package_default = {
61744
61848
  "@tscircuit/common": "^0.0.20",
61745
61849
  "@tscircuit/copper-pour-solver": "^0.0.54",
61746
61850
  "@tscircuit/create-fdm-enclosure": "0.0.4",
61747
- "@tscircuit/fanout-solver": "0.0.75",
61851
+ "@tscircuit/fanout-solver": "0.0.76",
61748
61852
  "@tscircuit/footprinter": "^0.0.426",
61749
61853
  "@tscircuit/image-utils": "^0.0.8",
61750
61854
  "@tscircuit/implicit-copper-pour-solver": "github:tscircuit/implicit-copper-pour-solver#a5cbbda0cd65fd4707c5c1af25779837c25aba92",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1898",
4
+ "version": "0.0.1899",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -41,7 +41,7 @@
41
41
  "@tscircuit/common": "^0.0.20",
42
42
  "@tscircuit/copper-pour-solver": "^0.0.54",
43
43
  "@tscircuit/create-fdm-enclosure": "0.0.4",
44
- "@tscircuit/fanout-solver": "0.0.75",
44
+ "@tscircuit/fanout-solver": "0.0.76",
45
45
  "@tscircuit/footprinter": "^0.0.426",
46
46
  "@tscircuit/image-utils": "^0.0.8",
47
47
  "@tscircuit/implicit-copper-pour-solver": "github:tscircuit/implicit-copper-pour-solver#a5cbbda0cd65fd4707c5c1af25779837c25aba92",