Skip to content

Commit 728f450

Browse files
authored
Merge pull request #8523 from The-OpenROAD-Project-staging/grt-resistance-aware
GRT: resistance-aware layer assignment and 3D routing
2 parents d3ab270 + 52f5ce8 commit 728f450

File tree

10 files changed

+235
-39
lines changed

10 files changed

+235
-39
lines changed

src/grt/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ global_route
2929
[-start_incremental]
3030
[-end_incremental]
3131
[-use_cugr]
32+
[-resistance_aware]
3233
```
3334

3435
#### Options
@@ -46,6 +47,7 @@ global_route
4647
| `-start_incremental` | This flag initializes the GRT listener to get the net modified. The default is false. |
4748
| `-end_incremental` | This flag run incremental GRT with the nets modified. The default is false. |
4849
| `-use_cugr` | This flag run GRT using CUGR as the router solver. NOTE: this is not ready for production. |
50+
| `-resistance_aware` | This flag enables resistance-aware layer assignment and 3D routing. NOTE: this is not ready for production. |
4951

5052
### Set Routing Layers
5153

src/grt/include/grt/GlobalRouter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class GlobalRouter
151151
void setCongestionReportFile(const char* file_name);
152152
void setGridOrigin(int x, int y);
153153
void setAllowCongestion(bool allow_congestion);
154+
void setResistanceAware(bool resistance_aware);
154155
void setMacroExtension(int macro_extension);
155156
void setUseCUGR(bool use_cugr) { use_cugr_ = use_cugr; };
156157

@@ -484,6 +485,7 @@ class GlobalRouter
484485
int congestion_iterations_{50};
485486
int congestion_report_iter_step_;
486487
bool allow_congestion_;
488+
bool resistance_aware_{false};
487489
std::vector<int> vertical_capacities_;
488490
std::vector<int> horizontal_capacities_;
489491
int macro_extension_;

src/grt/src/GlobalRouter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,11 @@ void GlobalRouter::setAllowCongestion(bool allow_congestion)
20582058
allow_congestion_ = allow_congestion;
20592059
}
20602060

2061+
void GlobalRouter::setResistanceAware(bool resistance_aware)
2062+
{
2063+
resistance_aware_ = resistance_aware;
2064+
}
2065+
20612066
void GlobalRouter::setMacroExtension(int macro_extension)
20622067
{
20632068
macro_extension_ = macro_extension;
@@ -2159,6 +2164,7 @@ void GlobalRouter::configFastRoute()
21592164
fastroute_->setVerbose(verbose_);
21602165
fastroute_->setOverflowIterations(congestion_iterations_);
21612166
fastroute_->setCongestionReportIterStep(congestion_report_iter_step_);
2167+
fastroute_->setResistanceAware(resistance_aware_);
21622168

21632169
if (congestion_file_name_ != nullptr) {
21642170
fastroute_->setCongestionReportFile(congestion_file_name_);

src/grt/src/GlobalRouter.i

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ set_allow_congestion(bool allowCongestion)
104104
getGlobalRouter()->setAllowCongestion(allowCongestion);
105105
}
106106

107+
void
108+
set_resistance_aware(bool resistance_aware)
109+
{
110+
getGlobalRouter()->setResistanceAware(resistance_aware);
111+
}
112+
107113
void
108114
set_critical_nets_percentage(float criticalNetsPercentage)
109115
{

src/grt/src/GlobalRouter.tcl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,17 @@ sta::define_cmd_args "global_route" {[-guide_file out_file] \
150150
[-verbose] \
151151
[-start_incremental] \
152152
[-end_incremental] \
153-
[-use_cugr]
153+
[-use_cugr] \
154+
[-resistance_aware]
154155
}
155156

156157
proc global_route { args } {
157158
sta::parse_key_args "global_route" args \
158159
keys {-guide_file -congestion_iterations -congestion_report_file \
159160
-grid_origin -critical_nets_percentage -congestion_report_iter_step
160161
} \
161-
flags {-allow_congestion -verbose -start_incremental -end_incremental -use_cugr}
162+
flags {-allow_congestion -resistance_aware -verbose -start_incremental -end_incremental \
163+
-use_cugr}
162164

163165
sta::check_argc_eq0 "global_route" $args
164166

@@ -215,6 +217,9 @@ proc global_route { args } {
215217
set allow_congestion [info exists flags(-allow_congestion)]
216218
grt::set_allow_congestion $allow_congestion
217219

220+
set resistance_aware [info exists flags(-resistance_aware)]
221+
grt::set_resistance_aware $resistance_aware
222+
218223
set start_incremental [info exists flags(-start_incremental)]
219224
set end_incremental [info exists flags(-end_incremental)]
220225

src/grt/src/fastroute/include/DataType.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ struct OrderNetPin
238238
int minX;
239239
float length_per_pin; // net length over pin count
240240
int ndr_priority; // NDR nets are assigned first
241+
float slack;
241242
};
242243

243244
struct OrderTree

src/grt/src/fastroute/include/FastRoute.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class FastRouteCore
103103
void addHCapacity(short horizontalCapacity, int layer);
104104
void setLowerLeft(int x, int y);
105105
void setTileSize(int size);
106+
void setResistanceAware(bool resistance_aware);
106107
void addLayerDirection(int layer_idx, const odb::dbTechLayerDir& direction);
107108
FrNet* addNet(odb::dbNet* db_net,
108109
bool is_clock,
@@ -354,6 +355,14 @@ class FastRouteCore
354355
void reInitTree(int netID);
355356

356357
// maze3D functions
358+
float getMazeRouteCost3D(int net_id,
359+
int from_layer,
360+
int to_layer,
361+
int from_x,
362+
int from_y,
363+
int to_x,
364+
int to_y,
365+
bool is_via);
357366
void mazeRouteMSMDOrder3D(int expand, int ripupTHlb, int ripupTHub);
358367
void addNeighborPoints(int netID,
359368
int n1,
@@ -513,6 +522,8 @@ class FastRouteCore
513522
int& best_cost,
514523
multi_array<int, 2>& layer_grid);
515524
void assignEdge(int netID, int edgeID, bool processDIR);
525+
int getLayerResistance(int layer, int length, FrNet* net);
526+
int getViaResistance(int from_layer, int to_layer);
516527
void recoverEdge(int netID, int edgeID);
517528
void layerAssignmentV4();
518529
void netpinOrderInc();
@@ -589,6 +600,7 @@ class FastRouteCore
589600
int x_range_;
590601
int y_range_;
591602

603+
bool resistance_aware_ = false;
592604
int num_adjust_;
593605
int v_capacity_;
594606
int h_capacity_;

src/grt/src/fastroute/src/FastRoute.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,11 @@ void FastRouteCore::setCongestionReportIterStep(int congestion_report_iter_step)
18021802
congestion_report_iter_step_ = congestion_report_iter_step;
18031803
}
18041804

1805+
void FastRouteCore::setResistanceAware(bool resistance_aware)
1806+
{
1807+
resistance_aware_ = resistance_aware;
1808+
}
1809+
18051810
void FastRouteCore::setCongestionReportFile(const char* congestion_file_name)
18061811
{
18071812
congestion_file_name_ = congestion_file_name;

src/grt/src/fastroute/src/maze3D.cpp

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,57 @@ void FastRouteCore::updateRouteType23D(int netID,
652652
}
653653
}
654654

655+
// Resistance-aware cost calculation
656+
float FastRouteCore::getMazeRouteCost3D(const int net_id,
657+
const int from_layer,
658+
const int to_layer,
659+
const int from_x,
660+
const int from_y,
661+
const int to_x,
662+
const int to_y,
663+
const bool is_via)
664+
{
665+
FrNet* net = nets_[net_id];
666+
float base_cost = 1.0;
667+
668+
if (is_via) {
669+
// Via transition cost
670+
base_cost = via_cost_;
671+
const int via_resistance = getViaResistance(from_layer, to_layer);
672+
673+
return base_cost + via_resistance;
674+
}
675+
676+
// Wire segment cost
677+
const float length = abs(to_x - from_x) + abs(to_y - from_y);
678+
const float wire_resistance
679+
= getLayerResistance(from_layer, length * tile_size_, net);
680+
681+
// Check congestion
682+
bool congested = false;
683+
if (from_x == to_x) { // vertical
684+
int min_y = std::min(from_y, to_y);
685+
if (v_edges_3D_[from_layer][min_y][from_x].usage
686+
+ net->getLayerEdgeCost(from_layer)
687+
> v_edges_3D_[from_layer][min_y][from_x].cap) {
688+
congested = true;
689+
}
690+
} else { // horizontal
691+
int min_x = std::min(from_x, to_x);
692+
if (h_edges_3D_[from_layer][from_y][min_x].usage
693+
+ net->getLayerEdgeCost(from_layer)
694+
> h_edges_3D_[from_layer][from_y][min_x].cap) {
695+
congested = true;
696+
}
697+
}
698+
699+
if (congested) {
700+
base_cost = BIG_INT; // Heavy penalty for congestion
701+
}
702+
703+
return base_cost + wire_resistance;
704+
}
705+
655706
void FastRouteCore::mazeRouteMSMDOrder3D(int expand,
656707
int ripupTHlb,
657708
int ripupTHub)
@@ -766,7 +817,9 @@ void FastRouteCore::mazeRouteMSMDOrder3D(int expand,
766817
// left
767818
if (curX > regionX1
768819
&& directions_3D_[curL][curY][curX] != Direction::East) {
769-
const float tmp = d1_3D_[curL][curY][curX] + 1;
820+
const float cost = getMazeRouteCost3D(
821+
netID, curL, curL, curX, curY, curX - 1, curY, false);
822+
const float tmp = d1_3D_[curL][curY][curX] + cost;
770823
if (h_edges_3D_[curL][curY][curX - 1].usage + edge_cost
771824
<= h_edges_3D_[curL][curY][curX - 1].cap
772825
&& net->getMinLayer() <= curL && curL <= net->getMaxLayer()) {
@@ -811,7 +864,9 @@ void FastRouteCore::mazeRouteMSMDOrder3D(int expand,
811864
// right
812865
if (Horizontal && curX < regionX2
813866
&& directions_3D_[curL][curY][curX] != Direction::West) {
814-
const float tmp = d1_3D_[curL][curY][curX] + 1;
867+
const float cost = getMazeRouteCost3D(
868+
netID, curL, curL, curX, curY, curX + 1, curY, false);
869+
const float tmp = d1_3D_[curL][curY][curX] + cost;
815870
const int tmpX = curX + 1; // the right neighbor
816871

817872
if (h_edges_3D_[curL][curY][curX].usage + edge_cost
@@ -857,7 +912,9 @@ void FastRouteCore::mazeRouteMSMDOrder3D(int expand,
857912
// bottom
858913
if (!Horizontal && curY > regionY1
859914
&& directions_3D_[curL][curY][curX] != Direction::South) {
860-
const float tmp = d1_3D_[curL][curY][curX] + 1;
915+
const float cost = getMazeRouteCost3D(
916+
netID, curL, curL, curX, curY, curX, curY - 1, false);
917+
const float tmp = d1_3D_[curL][curY][curX] + cost;
861918
const int tmpY = curY - 1; // the bottom neighbor
862919
if (v_edges_3D_[curL][curY - 1][curX].usage + edge_cost
863920
<= v_edges_3D_[curL][curY - 1][curX].cap
@@ -901,7 +958,9 @@ void FastRouteCore::mazeRouteMSMDOrder3D(int expand,
901958
// top
902959
if (!Horizontal && curY < regionY2
903960
&& directions_3D_[curL][curY][curX] != Direction::North) {
904-
const float tmp = d1_3D_[curL][curY][curX] + 1;
961+
const float cost = getMazeRouteCost3D(
962+
netID, curL, curL, curX, curY, curX, curY + 1, false);
963+
const float tmp = d1_3D_[curL][curY][curX] + cost;
905964
const int tmpY = curY + 1; // the top neighbor
906965
if (v_edges_3D_[curL][curY][curX].usage + edge_cost
907966
<= v_edges_3D_[curL][curY][curX].cap
@@ -945,7 +1004,10 @@ void FastRouteCore::mazeRouteMSMDOrder3D(int expand,
9451004

9461005
// down
9471006
if (curL > 0 && directions_3D_[curL][curY][curX] != Direction::Up) {
948-
const float tmp = d1_3D_[curL][curY][curX] + via_cost_;
1007+
// Via cost
1008+
const float cost = getMazeRouteCost3D(
1009+
netID, curL, curL - 1, curX, curY, curX, curY, true);
1010+
const float tmp = d1_3D_[curL][curY][curX] + cost;
9491011
const int tmpL = curL - 1; // the bottom neighbor
9501012

9511013
if (d1_3D_[tmpL][curY][curX]
@@ -986,7 +1048,10 @@ void FastRouteCore::mazeRouteMSMDOrder3D(int expand,
9861048
// up
9871049
if (curL < num_layers_ - 1
9881050
&& directions_3D_[curL][curY][curX] != Direction::Down) {
989-
const float tmp = d1_3D_[curL][curY][curX] + via_cost_;
1051+
// Via cost
1052+
const float cost = getMazeRouteCost3D(
1053+
netID, curL, curL + 1, curX, curY, curX, curY, true);
1054+
const float tmp = d1_3D_[curL][curY][curX] + cost;
9901055
const int tmpL = curL + 1; // the bottom neighbor
9911056
if (d1_3D_[tmpL][curY][curX]
9921057
>= BIG_INT) // bottom neighbor not been put into src_heap_3D

0 commit comments

Comments
 (0)