@tscircuit/hypergraph 0.0.31 → 0.0.33

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 (3) hide show
  1. package/dist/index.d.ts +563 -107
  2. package/dist/index.js +628 -128
  3. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -3490,117 +3490,562 @@ ${errors.map((e) => ` - ${e}`).join("\n")}`
3490
3490
  }
3491
3491
  };
3492
3492
 
3493
- // assets/ViaGraphSolver/vias-by-net.json
3494
- var vias_by_net_default = {
3495
- Net6: [
3496
- {
3497
- viaId: "4ef04070-bacf-4a8a-8ac9-ea222cf4bf2c",
3498
- diameter: 0.6,
3499
- position: {
3500
- x: 1.483834,
3501
- y: 0.582296
3493
+ // assets/ViaGraphSolver/via-tile.json
3494
+ var via_tile_default = {
3495
+ viasByNet: {
3496
+ Net6: [
3497
+ {
3498
+ viaId: "4ef04070-bacf-4a8a-8ac9-ea222cf4bf2c",
3499
+ diameter: 0.6,
3500
+ position: {
3501
+ x: 1.483834,
3502
+ y: 0.582296
3503
+ }
3504
+ },
3505
+ {
3506
+ viaId: "79364d38-c966-4eff-aa4a-e3ff6cca6339",
3507
+ diameter: 0.6,
3508
+ position: {
3509
+ x: -0.8,
3510
+ y: -1.893395
3511
+ }
3512
+ },
3513
+ {
3514
+ viaId: "f1d52fd5-ddd2-4440-8772-da3d096b033f",
3515
+ diameter: 0.6,
3516
+ position: {
3517
+ x: -0.703066,
3518
+ y: 1.2
3519
+ }
3502
3520
  }
3503
- },
3504
- {
3505
- viaId: "79364d38-c966-4eff-aa4a-e3ff6cca6339",
3506
- diameter: 0.6,
3507
- position: {
3508
- x: -0.8,
3509
- y: -1.893395
3521
+ ],
3522
+ Net5: [
3523
+ {
3524
+ viaId: "4e57cee8-0910-4c83-9ec1-1ed2c9d16dcc",
3525
+ diameter: 0.6,
3526
+ position: {
3527
+ x: 1.268717,
3528
+ y: -1.698536
3529
+ }
3530
+ },
3531
+ {
3532
+ viaId: "a3797f13-73f9-48c3-a448-bea3980cdd65",
3533
+ diameter: 0.6,
3534
+ position: {
3535
+ x: -1.115754,
3536
+ y: -0.799377
3537
+ }
3538
+ },
3539
+ {
3540
+ viaId: "b0c56bb1-ea80-4154-9bb7-cb0fd760de8f",
3541
+ diameter: 0.6,
3542
+ position: {
3543
+ x: 0.397934,
3544
+ y: 1.458567
3545
+ }
3510
3546
  }
3511
- },
3512
- {
3513
- viaId: "f1d52fd5-ddd2-4440-8772-da3d096b033f",
3514
- diameter: 0.6,
3515
- position: {
3516
- x: -0.703066,
3517
- y: 1.2
3547
+ ],
3548
+ Net7: [
3549
+ {
3550
+ viaId: "3719876b-17c8-4ee3-9cce-5b5c073d6614",
3551
+ diameter: 0.6,
3552
+ position: {
3553
+ x: 1.186721,
3554
+ y: 1.32508
3555
+ }
3556
+ },
3557
+ {
3558
+ viaId: "4e46d759-a04a-4f7e-99cd-9e05adf5fa23",
3559
+ diameter: 0.6,
3560
+ position: {
3561
+ x: -1.275,
3562
+ y: 0
3563
+ }
3564
+ },
3565
+ {
3566
+ viaId: "63afce65-b94e-47da-ae14-51ff0ee8eb39",
3567
+ diameter: 0.6,
3568
+ position: {
3569
+ x: 1.655408,
3570
+ y: -0.998198
3571
+ }
3518
3572
  }
3519
- }
3520
- ],
3521
- Net5: [
3522
- {
3523
- viaId: "4e57cee8-0910-4c83-9ec1-1ed2c9d16dcc",
3524
- diameter: 0.6,
3525
- position: {
3526
- x: 1.268717,
3527
- y: -1.698536
3573
+ ],
3574
+ Net8: [
3575
+ {
3576
+ viaId: "26d3bef1-a78f-4947-b551-c48f04289a98",
3577
+ diameter: 0.6,
3578
+ position: {
3579
+ x: 1.553029,
3580
+ y: -0.164505
3581
+ }
3582
+ },
3583
+ {
3584
+ viaId: "548acbca-8b68-4186-a589-681ec44fba42",
3585
+ diameter: 0.6,
3586
+ position: {
3587
+ x: 0.222457,
3588
+ y: -1.866711
3589
+ }
3590
+ },
3591
+ {
3592
+ viaId: "d6bf60bf-4b90-4967-a295-fc930b1f2549",
3593
+ diameter: 0.6,
3594
+ position: {
3595
+ x: -1.419706,
3596
+ y: 0.868747
3597
+ }
3528
3598
  }
3529
- },
3599
+ ]
3600
+ },
3601
+ routeSegments: [
3530
3602
  {
3531
- viaId: "a3797f13-73f9-48c3-a448-bea3980cdd65",
3532
- diameter: 0.6,
3533
- position: {
3534
- x: -1.115754,
3535
- y: -0.799377
3536
- }
3603
+ routeId: "Net6:route_0",
3604
+ fromPort: "4ef04070-bacf-4a8a-8ac9-ea222cf4bf2c",
3605
+ toPort: "f1d52fd5-ddd2-4440-8772-da3d096b033f",
3606
+ layer: "bottom",
3607
+ segments: [
3608
+ {
3609
+ x: 1.483834,
3610
+ y: 0.582296
3611
+ },
3612
+ {
3613
+ x: 1.31705,
3614
+ y: 0.74908
3615
+ },
3616
+ {
3617
+ x: 1.425309,
3618
+ y: 0.74908
3619
+ },
3620
+ {
3621
+ x: 1.762721,
3622
+ y: 1.086492
3623
+ },
3624
+ {
3625
+ x: 1.762721,
3626
+ y: 1.563668
3627
+ },
3628
+ {
3629
+ x: 1.425309,
3630
+ y: 1.90108
3631
+ },
3632
+ {
3633
+ x: 1.266397,
3634
+ y: 1.90108
3635
+ },
3636
+ {
3637
+ x: 0.781911,
3638
+ y: 2.385567
3639
+ },
3640
+ {
3641
+ x: 0.013957,
3642
+ y: 2.385567
3643
+ },
3644
+ {
3645
+ x: -0.753066,
3646
+ y: 1.618543
3647
+ },
3648
+ {
3649
+ x: -0.753066,
3650
+ y: 1.360375
3651
+ },
3652
+ {
3653
+ x: -0.703066,
3654
+ y: 1.310375
3655
+ },
3656
+ {
3657
+ x: -0.703066,
3658
+ y: 1.2
3659
+ }
3660
+ ]
3537
3661
  },
3538
3662
  {
3539
- viaId: "b0c56bb1-ea80-4154-9bb7-cb0fd760de8f",
3540
- diameter: 0.6,
3541
- position: {
3542
- x: 0.397934,
3543
- y: 1.458567
3544
- }
3545
- }
3546
- ],
3547
- Net7: [
3663
+ routeId: "Net6:route_1",
3664
+ fromPort: "79364d38-c966-4eff-aa4a-e3ff6cca6339",
3665
+ toPort: "f1d52fd5-ddd2-4440-8772-da3d096b033f",
3666
+ layer: "bottom",
3667
+ segments: [
3668
+ {
3669
+ x: -0.8,
3670
+ y: -1.893395
3671
+ },
3672
+ {
3673
+ x: -1.706605,
3674
+ y: -1.893395
3675
+ },
3676
+ {
3677
+ x: -2.2,
3678
+ y: -1.4
3679
+ },
3680
+ {
3681
+ x: -2.2,
3682
+ y: 0.903041
3683
+ },
3684
+ {
3685
+ x: -1.603041,
3686
+ y: 1.5
3687
+ },
3688
+ {
3689
+ x: -1.516757,
3690
+ y: 1.5
3691
+ },
3692
+ {
3693
+ x: -1.430473,
3694
+ y: 1.586284
3695
+ },
3696
+ {
3697
+ x: -0.978975,
3698
+ y: 1.586284
3699
+ },
3700
+ {
3701
+ x: -0.703066,
3702
+ y: 1.310375
3703
+ },
3704
+ {
3705
+ x: -0.703066,
3706
+ y: 1.2
3707
+ }
3708
+ ]
3709
+ },
3548
3710
  {
3549
- viaId: "3719876b-17c8-4ee3-9cce-5b5c073d6614",
3550
- diameter: 0.6,
3551
- position: {
3552
- x: 1.186721,
3553
- y: 1.32508
3554
- }
3711
+ routeId: "Net5:route_0",
3712
+ fromPort: "a3797f13-73f9-48c3-a448-bea3980cdd65",
3713
+ toPort: "b0c56bb1-ea80-4154-9bb7-cb0fd760de8f",
3714
+ layer: "bottom",
3715
+ segments: [
3716
+ {
3717
+ x: -1.115754,
3718
+ y: -0.799377
3719
+ },
3720
+ {
3721
+ x: -0.764375,
3722
+ y: -0.447998
3723
+ },
3724
+ {
3725
+ x: -0.636191,
3726
+ y: -0.447998
3727
+ },
3728
+ {
3729
+ x: -0.368136,
3730
+ y: -0.179943
3731
+ },
3732
+ {
3733
+ x: -0.368136,
3734
+ y: -0.178529
3735
+ },
3736
+ {
3737
+ x: 0.556834,
3738
+ y: 0.746441
3739
+ },
3740
+ {
3741
+ x: 0.397934,
3742
+ y: 0.905341
3743
+ },
3744
+ {
3745
+ x: 0.397934,
3746
+ y: 1.458567
3747
+ }
3748
+ ]
3555
3749
  },
3556
3750
  {
3557
- viaId: "4e46d759-a04a-4f7e-99cd-9e05adf5fa23",
3558
- diameter: 0.6,
3559
- position: {
3560
- x: -1.275,
3561
- y: 0
3562
- }
3751
+ routeId: "Net5:route_1",
3752
+ fromPort: "4e57cee8-0910-4c83-9ec1-1ed2c9d16dcc",
3753
+ toPort: "b0c56bb1-ea80-4154-9bb7-cb0fd760de8f",
3754
+ layer: "bottom",
3755
+ segments: [
3756
+ {
3757
+ x: 1.268717,
3758
+ y: -1.698536
3759
+ },
3760
+ {
3761
+ x: 1.405649,
3762
+ y: -1.561604
3763
+ },
3764
+ {
3765
+ x: 1.393076,
3766
+ y: -1.561604
3767
+ },
3768
+ {
3769
+ x: 1.055664,
3770
+ y: -1.224192
3771
+ },
3772
+ {
3773
+ x: 1.055664,
3774
+ y: -0.905992
3775
+ },
3776
+ {
3777
+ x: 0.556834,
3778
+ y: -0.407162
3779
+ },
3780
+ {
3781
+ x: 0.556834,
3782
+ y: 0.746441
3783
+ },
3784
+ {
3785
+ x: 0.397934,
3786
+ y: 0.905341
3787
+ },
3788
+ {
3789
+ x: 0.397934,
3790
+ y: 1.458567
3791
+ }
3792
+ ]
3563
3793
  },
3564
3794
  {
3565
- viaId: "63afce65-b94e-47da-ae14-51ff0ee8eb39",
3566
- diameter: 0.6,
3567
- position: {
3568
- x: 1.655408,
3569
- y: -0.998198
3570
- }
3571
- }
3572
- ],
3573
- Net8: [
3795
+ routeId: "Net7:route_0",
3796
+ fromPort: "3719876b-17c8-4ee3-9cce-5b5c073d6614",
3797
+ toPort: "63afce65-b94e-47da-ae14-51ff0ee8eb39",
3798
+ layer: "bottom",
3799
+ segments: [
3800
+ {
3801
+ x: 1.186721,
3802
+ y: 1.32508
3803
+ },
3804
+ {
3805
+ x: 0.907834,
3806
+ y: 1.046193
3807
+ },
3808
+ {
3809
+ x: 0.907834,
3810
+ y: -0.261774
3811
+ },
3812
+ {
3813
+ x: 1.644258,
3814
+ y: -0.998198
3815
+ },
3816
+ {
3817
+ x: 1.655408,
3818
+ y: -0.998198
3819
+ }
3820
+ ]
3821
+ },
3574
3822
  {
3575
- viaId: "26d3bef1-a78f-4947-b551-c48f04289a98",
3576
- diameter: 0.6,
3577
- position: {
3578
- x: 1.553029,
3579
- y: -0.164505
3580
- }
3823
+ routeId: "Net7:route_1",
3824
+ fromPort: "3719876b-17c8-4ee3-9cce-5b5c073d6614",
3825
+ toPort: "4e46d759-a04a-4f7e-99cd-9e05adf5fa23",
3826
+ layer: "bottom",
3827
+ segments: [
3828
+ {
3829
+ x: 1.186721,
3830
+ y: 1.32508
3831
+ },
3832
+ {
3833
+ x: 1.186721,
3834
+ y: 1.484368
3835
+ },
3836
+ {
3837
+ x: 0.636522,
3838
+ y: 2.034567
3839
+ },
3840
+ {
3841
+ x: 0.159346,
3842
+ y: 2.034567
3843
+ },
3844
+ {
3845
+ x: 0.06239,
3846
+ y: 1.93761
3847
+ },
3848
+ {
3849
+ x: -0.178066,
3850
+ y: 1.697155
3851
+ },
3852
+ {
3853
+ x: -0.178066,
3854
+ y: 0.824715
3855
+ },
3856
+ {
3857
+ x: -1.042874,
3858
+ y: -0.040093
3859
+ },
3860
+ {
3861
+ x: -1.169705,
3862
+ y: -0.040093
3863
+ },
3864
+ {
3865
+ x: -1.209798,
3866
+ y: 0
3867
+ },
3868
+ {
3869
+ x: -1.275,
3870
+ y: 0
3871
+ }
3872
+ ]
3581
3873
  },
3582
3874
  {
3583
- viaId: "548acbca-8b68-4186-a589-681ec44fba42",
3584
- diameter: 0.6,
3585
- position: {
3586
- x: 0.222457,
3587
- y: -1.866711
3588
- }
3875
+ routeId: "Net8:route_0",
3876
+ fromPort: "26d3bef1-a78f-4947-b551-c48f04289a98",
3877
+ toPort: "548acbca-8b68-4186-a589-681ec44fba42",
3878
+ layer: "bottom",
3879
+ segments: [
3880
+ {
3881
+ x: 1.553029,
3882
+ y: -0.164505
3883
+ },
3884
+ {
3885
+ x: 1.562188,
3886
+ y: -0.173664
3887
+ },
3888
+ {
3889
+ x: 1.634312,
3890
+ y: -0.173664
3891
+ },
3892
+ {
3893
+ x: 2.207664,
3894
+ y: -0.747016
3895
+ },
3896
+ {
3897
+ x: 2.207664,
3898
+ y: -1.224192
3899
+ },
3900
+ {
3901
+ x: 1.870252,
3902
+ y: -1.561604
3903
+ },
3904
+ {
3905
+ x: 1.844717,
3906
+ y: -1.561604
3907
+ },
3908
+ {
3909
+ x: 1.844717,
3910
+ y: -1.937124
3911
+ },
3912
+ {
3913
+ x: 1.507305,
3914
+ y: -2.274536
3915
+ },
3916
+ {
3917
+ x: 1.030129,
3918
+ y: -2.274536
3919
+ },
3920
+ {
3921
+ x: 0.692717,
3922
+ y: -1.937124
3923
+ },
3924
+ {
3925
+ x: 0.692717,
3926
+ y: -1.739534
3927
+ },
3928
+ {
3929
+ x: 0.475553,
3930
+ y: -1.739534
3931
+ },
3932
+ {
3933
+ x: 0.470734,
3934
+ y: -1.744353
3935
+ },
3936
+ {
3937
+ x: 0.455647,
3938
+ y: -1.744353
3939
+ },
3940
+ {
3941
+ x: 0.30246,
3942
+ y: -1.89754
3943
+ },
3944
+ {
3945
+ x: 0.253286,
3946
+ y: -1.89754
3947
+ },
3948
+ {
3949
+ x: 0.222457,
3950
+ y: -1.866711
3951
+ }
3952
+ ]
3589
3953
  },
3590
3954
  {
3591
- viaId: "d6bf60bf-4b90-4967-a295-fc930b1f2549",
3592
- diameter: 0.6,
3593
- position: {
3594
- x: -1.419706,
3595
- y: 0.868747
3596
- }
3955
+ routeId: "Net8:route_1",
3956
+ fromPort: "548acbca-8b68-4186-a589-681ec44fba42",
3957
+ toPort: "d6bf60bf-4b90-4967-a295-fc930b1f2549",
3958
+ layer: "bottom",
3959
+ segments: [
3960
+ {
3961
+ x: 0.222457,
3962
+ y: -1.866711
3963
+ },
3964
+ {
3965
+ x: 0.208345,
3966
+ y: -1.866711
3967
+ },
3968
+ {
3969
+ x: 0.2,
3970
+ y: -1.858366
3971
+ },
3972
+ {
3973
+ x: 0.2,
3974
+ y: -1.2
3975
+ },
3976
+ {
3977
+ x: -0.701789,
3978
+ y: -1.2
3979
+ },
3980
+ {
3981
+ x: -0.869184,
3982
+ y: -1.367395
3983
+ },
3984
+ {
3985
+ x: -1.017877,
3986
+ y: -1.367395
3987
+ },
3988
+ {
3989
+ x: -1.025859,
3990
+ y: -1.375377
3991
+ },
3992
+ {
3993
+ x: -1.354342,
3994
+ y: -1.375377
3995
+ },
3996
+ {
3997
+ x: -1.529719,
3998
+ y: -1.2
3999
+ },
4000
+ {
4001
+ x: -1.636994,
4002
+ y: -1.2
4003
+ },
4004
+ {
4005
+ x: -1.718497,
4006
+ y: -1.118497
4007
+ },
4008
+ {
4009
+ x: -1.8,
4010
+ y: -1.2
4011
+ },
4012
+ {
4013
+ x: -1.8,
4014
+ y: -1.036995
4015
+ },
4016
+ {
4017
+ x: -1.80003,
4018
+ y: -1.036965
4019
+ },
4020
+ {
4021
+ x: -1.80003,
4022
+ y: -0.559789
4023
+ },
4024
+ {
4025
+ x: -1.8,
4026
+ y: -0.559759
4027
+ },
4028
+ {
4029
+ x: -1.8,
4030
+ y: 0.877363
4031
+ },
4032
+ {
4033
+ x: -1.614161,
4034
+ y: 1.063202
4035
+ },
4036
+ {
4037
+ x: -1.419706,
4038
+ y: 0.868747
4039
+ }
4040
+ ]
3597
4041
  }
3598
4042
  ]
3599
4043
  };
3600
4044
 
3601
4045
  // lib/ViaGraphSolver/via-graph-generator/generateViaTopologyRegions.ts
3602
4046
  var TRACE_PITCH = 0.4;
3603
- var generateViaTopologyRegions = (viasByNet, opts) => {
4047
+ var generateViaTopologyRegions = (viaTile, opts) => {
4048
+ const viasByNet = viaTile.viasByNet;
3604
4049
  const graphSize = opts?.graphSize ?? 5;
3605
4050
  const idPrefix = opts?.idPrefix ?? "via";
3606
4051
  const half = graphSize / 2;
@@ -3903,6 +4348,18 @@ function translateGraph(graph, dx, dy, prefix) {
3903
4348
  });
3904
4349
  return { regions, ports };
3905
4350
  }
4351
+ function translateRouteSegments(routeSegments, dx, dy, prefix) {
4352
+ return routeSegments.map((segment2) => ({
4353
+ routeId: `${prefix}:${segment2.routeId}`,
4354
+ fromPort: `${prefix}:${segment2.fromPort}`,
4355
+ toPort: `${prefix}:${segment2.toPort}`,
4356
+ layer: segment2.layer,
4357
+ segments: segment2.segments.map((point2) => ({
4358
+ x: point2.x + dx,
4359
+ y: point2.y + dy
4360
+ }))
4361
+ }));
4362
+ }
3906
4363
  function createBoundaryPorts(portIdPrefix, region1, region2, axis, fixedCoord, start, end, portPitch) {
3907
4364
  const length = Math.abs(end - start);
3908
4365
  if (length < 1e-3) return [];
@@ -3978,14 +4435,15 @@ function rangeOverlap(a, b) {
3978
4435
  function generateViaTopologyGrid(opts) {
3979
4436
  const tileSize = opts.tileSize ?? DEFAULT_TILE_SIZE;
3980
4437
  const portPitch = opts.portPitch ?? DEFAULT_PORT_PITCH;
3981
- const { bounds, viasByNet } = opts;
4438
+ const { bounds, viaTile: inputViaTile } = opts;
4439
+ const { viasByNet, routeSegments } = inputViaTile;
3982
4440
  const width = bounds.maxX - bounds.minX;
3983
4441
  const height = bounds.maxY - bounds.minY;
3984
4442
  const cols = Math.floor(width / tileSize);
3985
4443
  const rows = Math.floor(height / tileSize);
3986
4444
  const allRegions = [];
3987
4445
  const allPorts = [];
3988
- const tiledViasByNet = {};
4446
+ const viaTile = { viasByNet: {}, routeSegments: [] };
3989
4447
  const gridWidth = cols * tileSize;
3990
4448
  const gridHeight = rows * tileSize;
3991
4449
  const gridMinX = bounds.minX + (width - gridWidth) / 2;
@@ -3994,7 +4452,7 @@ function generateViaTopologyGrid(opts) {
3994
4452
  const gridMaxY = gridMinY + gridHeight;
3995
4453
  const tileGraphs = [];
3996
4454
  if (rows > 0 && cols > 0) {
3997
- const baseGraph = generateViaTopologyRegions(viasByNet, {
4455
+ const baseGraph = generateViaTopologyRegions(inputViaTile, {
3998
4456
  graphSize: tileSize,
3999
4457
  idPrefix: "v"
4000
4458
  });
@@ -4021,9 +4479,11 @@ function generateViaTopologyGrid(opts) {
4021
4479
  allRegions.push(...tile.regions);
4022
4480
  allPorts.push(...tile.ports);
4023
4481
  for (const [netName, vias] of Object.entries(viasByNet)) {
4024
- if (!tiledViasByNet[netName]) tiledViasByNet[netName] = [];
4482
+ if (!viaTile.viasByNet[netName]) {
4483
+ viaTile.viasByNet[netName] = [];
4484
+ }
4025
4485
  for (const via of vias) {
4026
- tiledViasByNet[netName].push({
4486
+ viaTile.viasByNet[netName].push({
4027
4487
  viaId: `${prefix}:${via.viaId}`,
4028
4488
  diameter: via.diameter,
4029
4489
  position: {
@@ -4033,6 +4493,14 @@ function generateViaTopologyGrid(opts) {
4033
4493
  });
4034
4494
  }
4035
4495
  }
4496
+ viaTile.routeSegments.push(
4497
+ ...translateRouteSegments(
4498
+ routeSegments,
4499
+ tileCenterX,
4500
+ tileCenterY,
4501
+ prefix
4502
+ )
4503
+ );
4036
4504
  }
4037
4505
  }
4038
4506
  const hPairs = [
@@ -4260,7 +4728,7 @@ function generateViaTopologyGrid(opts) {
4260
4728
  for (let col = 0; col < cols; col++) {
4261
4729
  const tile = tileGraphs[rows - 1][col];
4262
4730
  const tileT = findRegionBySuffix(tile, "v:T");
4263
- const baseT = generateViaTopologyRegions(viasByNet, {
4731
+ const baseT = generateViaTopologyRegions(inputViaTile, {
4264
4732
  graphSize: tileSize,
4265
4733
  idPrefix: "v"
4266
4734
  }).regions.find((r) => r.regionId === "v:T");
@@ -4286,7 +4754,7 @@ function generateViaTopologyGrid(opts) {
4286
4754
  for (let col = 0; col < cols; col++) {
4287
4755
  const tile = tileGraphs[0][col];
4288
4756
  const tileB = findRegionBySuffix(tile, "v:B");
4289
- const baseB = generateViaTopologyRegions(viasByNet, {
4757
+ const baseB = generateViaTopologyRegions(inputViaTile, {
4290
4758
  graphSize: tileSize,
4291
4759
  idPrefix: "v"
4292
4760
  }).regions.find((r) => r.regionId === "v:B");
@@ -4316,7 +4784,7 @@ function generateViaTopologyGrid(opts) {
4316
4784
  for (let row = 0; row < rows; row++) {
4317
4785
  const tile = tileGraphs[row][0];
4318
4786
  const tileL = findRegionBySuffix(tile, "v:L");
4319
- const baseL = generateViaTopologyRegions(viasByNet, {
4787
+ const baseL = generateViaTopologyRegions(inputViaTile, {
4320
4788
  graphSize: tileSize,
4321
4789
  idPrefix: "v"
4322
4790
  }).regions.find((r) => r.regionId === "v:L");
@@ -4342,7 +4810,7 @@ function generateViaTopologyGrid(opts) {
4342
4810
  for (let row = 0; row < rows; row++) {
4343
4811
  const tile = tileGraphs[row][cols - 1];
4344
4812
  const tileR = findRegionBySuffix(tile, "v:R");
4345
- const baseR = generateViaTopologyRegions(viasByNet, {
4813
+ const baseR = generateViaTopologyRegions(inputViaTile, {
4346
4814
  graphSize: tileSize,
4347
4815
  idPrefix: "v"
4348
4816
  }).regions.find((r) => r.regionId === "v:R");
@@ -4365,7 +4833,7 @@ function generateViaTopologyGrid(opts) {
4365
4833
  }
4366
4834
  }
4367
4835
  if (outerLeft) {
4368
- const baseGraph = generateViaTopologyRegions(viasByNet, {
4836
+ const baseGraph = generateViaTopologyRegions(inputViaTile, {
4369
4837
  graphSize: tileSize,
4370
4838
  idPrefix: "v"
4371
4839
  });
@@ -4409,7 +4877,7 @@ function generateViaTopologyGrid(opts) {
4409
4877
  }
4410
4878
  }
4411
4879
  if (outerRight) {
4412
- const baseGraph = generateViaTopologyRegions(viasByNet, {
4880
+ const baseGraph = generateViaTopologyRegions(inputViaTile, {
4413
4881
  graphSize: tileSize,
4414
4882
  idPrefix: "v"
4415
4883
  });
@@ -4461,19 +4929,19 @@ function generateViaTopologyGrid(opts) {
4461
4929
  return {
4462
4930
  regions: allRegions,
4463
4931
  ports: allPorts,
4464
- tiledViasByNet,
4932
+ viaTile,
4465
4933
  tileCount: { rows, cols }
4466
4934
  };
4467
4935
  }
4468
4936
 
4469
4937
  // lib/ViaGraphSolver/defaultTopology.ts
4470
4938
  function generateDefaultViaTopologyRegions(opts) {
4471
- return generateViaTopologyRegions(vias_by_net_default, opts);
4939
+ return generateViaTopologyRegions(via_tile_default, opts);
4472
4940
  }
4473
4941
  function generateDefaultViaTopologyGrid(opts) {
4474
4942
  return generateViaTopologyGrid({
4475
4943
  ...opts,
4476
- viasByNet: vias_by_net_default
4944
+ viaTile: via_tile_default
4477
4945
  });
4478
4946
  }
4479
4947
 
@@ -4716,9 +5184,9 @@ var visualizeViaGraphSolver = (solver) => {
4716
5184
  });
4717
5185
  }
4718
5186
  }
4719
- if (solver.viasByNet) {
5187
+ if (solver.viaTile) {
4720
5188
  if (!graphics.circles) graphics.circles = [];
4721
- for (const [netName, vias] of Object.entries(solver.viasByNet)) {
5189
+ for (const [netName, vias] of Object.entries(solver.viaTile.viasByNet)) {
4722
5190
  const netColor = netColorMap.get(netName);
4723
5191
  const viaFill = netColor ? netColor.replace("0.35", "0.5") : "rgba(255, 0, 0, 0.3)";
4724
5192
  for (const via of vias) {
@@ -4748,7 +5216,7 @@ var ViaGraphSolver = class extends HyperGraphSolver {
4748
5216
  return "ViaGraphSolver";
4749
5217
  }
4750
5218
  UNIT_OF_COST = "hops";
4751
- viasByNet;
5219
+ viaTile;
4752
5220
  portUsagePenalty = VIA_GRAPH_SOLVER_DEFAULTS.portUsagePenalty;
4753
5221
  portUsagePenaltySq = VIA_GRAPH_SOLVER_DEFAULTS.portUsagePenaltySq;
4754
5222
  crossingPenalty = VIA_GRAPH_SOLVER_DEFAULTS.crossingPenalty;
@@ -4763,7 +5231,7 @@ var ViaGraphSolver = class extends HyperGraphSolver {
4763
5231
  rippingEnabled: true,
4764
5232
  ...input
4765
5233
  });
4766
- this.viasByNet = input.viasByNet;
5234
+ this.viaTile = input.viaTile;
4767
5235
  this.ripCost = input.ripCost ?? this.ripCost;
4768
5236
  this.portUsagePenalty = input.portUsagePenalty ?? this.portUsagePenalty;
4769
5237
  this.crossingPenalty = input.crossingPenalty ?? this.crossingPenalty;
@@ -14218,19 +14686,32 @@ function translateVias(vias, dx, dy, prefix) {
14218
14686
  }
14219
14687
  }));
14220
14688
  }
14689
+ function translateRouteSegments2(routeSegments, dx, dy, prefix) {
14690
+ return routeSegments.map((segment2) => ({
14691
+ routeId: `${prefix}:${segment2.routeId}`,
14692
+ fromPort: `${prefix}:${segment2.fromPort}`,
14693
+ toPort: `${prefix}:${segment2.toPort}`,
14694
+ layer: segment2.layer,
14695
+ segments: segment2.segments.map((point2) => ({
14696
+ x: point2.x + dx,
14697
+ y: point2.y + dy
14698
+ }))
14699
+ }));
14700
+ }
14221
14701
  function generateConvexViaTopologyRegions(opts) {
14222
14702
  const tileSize = opts.tileSize ?? DEFAULT_TILE_SIZE2;
14223
14703
  const portPitch = opts.portPitch ?? DEFAULT_PORT_PITCH2;
14224
14704
  const clearance = opts.clearance ?? DEFAULT_CLEARANCE;
14225
14705
  const concavityTolerance = opts.concavityTolerance ?? 0;
14226
- const { bounds, viasByNet } = opts;
14706
+ const { bounds, viaTile: inputViaTile } = opts;
14707
+ const { viasByNet, routeSegments } = inputViaTile;
14227
14708
  const width = bounds.maxX - bounds.minX;
14228
14709
  const height = bounds.maxY - bounds.minY;
14229
14710
  const cols = Math.floor(width / tileSize);
14230
14711
  const rows = Math.floor(height / tileSize);
14231
14712
  const allRegions = [];
14232
14713
  const allPorts = [];
14233
- const tiledViasByNet = {};
14714
+ const viaTile = { viasByNet: {}, routeSegments: [] };
14234
14715
  const viaRegions = [];
14235
14716
  const gridWidth = cols * tileSize;
14236
14717
  const gridHeight = rows * tileSize;
@@ -14251,8 +14732,10 @@ function generateConvexViaTopologyRegions(opts) {
14251
14732
  tileCenterY,
14252
14733
  prefix
14253
14734
  );
14254
- if (!tiledViasByNet[netName]) tiledViasByNet[netName] = [];
14255
- tiledViasByNet[netName].push(...translatedVias);
14735
+ if (!viaTile.viasByNet[netName]) {
14736
+ viaTile.viasByNet[netName] = [];
14737
+ }
14738
+ viaTile.viasByNet[netName].push(...translatedVias);
14256
14739
  const polygon2 = generateViaRegionPolygon(translatedVias);
14257
14740
  if (polygon2.length === 0) continue;
14258
14741
  const viaRegion = createRegionFromPolygon(
@@ -14263,18 +14746,27 @@ function generateConvexViaTopologyRegions(opts) {
14263
14746
  viaRegions.push(viaRegion);
14264
14747
  allRegions.push(viaRegion);
14265
14748
  }
14749
+ viaTile.routeSegments.push(
14750
+ ...translateRouteSegments2(
14751
+ routeSegments,
14752
+ tileCenterX,
14753
+ tileCenterY,
14754
+ prefix
14755
+ )
14756
+ );
14266
14757
  }
14267
14758
  }
14268
14759
  }
14269
14760
  const obstaclePolygons = viaRegions.map((r) => ({
14270
14761
  points: r.d.polygon
14271
14762
  }));
14272
- const solver = new ConvexRegionsSolver({
14763
+ const solverInput = {
14273
14764
  bounds,
14274
14765
  polygons: obstaclePolygons,
14275
14766
  clearance,
14276
14767
  concavityTolerance
14277
- });
14768
+ };
14769
+ const solver = new ConvexRegionsSolver(solverInput);
14278
14770
  solver.solve();
14279
14771
  const solverOutput = solver.getOutput();
14280
14772
  if (!solverOutput) {
@@ -14337,7 +14829,7 @@ function generateConvexViaTopologyRegions(opts) {
14337
14829
  return {
14338
14830
  regions: allRegions,
14339
14831
  ports: allPorts,
14340
- tiledViasByNet,
14832
+ viaTile,
14341
14833
  tileCount: { rows, cols }
14342
14834
  };
14343
14835
  }
@@ -14359,10 +14851,15 @@ function calculateBoundsFromConnections(xyConnections) {
14359
14851
  }
14360
14852
  return { minX, maxX, minY, maxY };
14361
14853
  }
14362
- function createConvexViaGraphFromXYConnections(xyConnections, viasByNet = vias_by_net_default, opts) {
14854
+ function createConvexViaGraphFromXYConnections(xyConnections, viaTile = via_tile_default, opts) {
14363
14855
  const bounds = calculateBoundsFromConnections(xyConnections);
14364
- const { regions, ports, tiledViasByNet, tileCount } = generateConvexViaTopologyRegions({
14365
- viasByNet,
14856
+ const {
14857
+ regions,
14858
+ ports,
14859
+ viaTile: generatedViaTile,
14860
+ tileCount
14861
+ } = generateConvexViaTopologyRegions({
14862
+ viaTile,
14366
14863
  bounds,
14367
14864
  tileSize: opts?.tileSize,
14368
14865
  portPitch: opts?.portPitch,
@@ -14376,7 +14873,7 @@ function createConvexViaGraphFromXYConnections(xyConnections, viasByNet = vias_b
14376
14873
  );
14377
14874
  return {
14378
14875
  ...graphWithConnections,
14379
- tiledViasByNet,
14876
+ viaTile: generatedViaTile,
14380
14877
  tileCount
14381
14878
  };
14382
14879
  }
@@ -14398,16 +14895,19 @@ function calculateBoundsFromConnections2(xyConnections) {
14398
14895
  }
14399
14896
  return { minX, maxX, minY, maxY };
14400
14897
  }
14401
- function createViaGraphFromXYConnections(xyConnections, viasByNet, opts) {
14898
+ function createViaGraphFromXYConnections(xyConnections, viaTile, opts) {
14402
14899
  const bounds = calculateBoundsFromConnections2(xyConnections);
14403
- const { regions, ports, tiledViasByNet, tileCount } = generateViaTopologyGrid(
14404
- {
14405
- viasByNet,
14406
- bounds,
14407
- tileSize: opts?.tileSize,
14408
- portPitch: opts?.portPitch
14409
- }
14410
- );
14900
+ const {
14901
+ regions,
14902
+ ports,
14903
+ viaTile: generatedViaTile,
14904
+ tileCount
14905
+ } = generateViaTopologyGrid({
14906
+ viaTile,
14907
+ bounds,
14908
+ tileSize: opts?.tileSize,
14909
+ portPitch: opts?.portPitch
14910
+ });
14411
14911
  const baseGraph = { regions, ports };
14412
14912
  const graphWithConnections = createViaGraphWithConnections(
14413
14913
  baseGraph,
@@ -14415,7 +14915,7 @@ function createViaGraphFromXYConnections(xyConnections, viasByNet, opts) {
14415
14915
  );
14416
14916
  return {
14417
14917
  ...graphWithConnections,
14418
- tiledViasByNet,
14918
+ viaTile: generatedViaTile,
14419
14919
  tileCount
14420
14920
  };
14421
14921
  }
@@ -14446,7 +14946,7 @@ export {
14446
14946
  generateViaTopologyGrid,
14447
14947
  generateViaTopologyRegions,
14448
14948
  rotateGraph90Degrees,
14449
- vias_by_net_default as viasByNet
14949
+ via_tile_default as viaTile
14450
14950
  };
14451
14951
  /*! Bundled license information:
14452
14952