Skip to content

Commit 4fbf7e3

Browse files
authored
Merge pull request #7988 from The-OpenROAD-Project-staging/grt-refactoring
grt: add const to Segment fields
2 parents be6d32d + ba31336 commit 4fbf7e3

File tree

6 files changed

+23
-27
lines changed

6 files changed

+23
-27
lines changed

src/grt/include/grt/GlobalRouter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ class GlobalRouter
332332
void computeWirelength();
333333
std::vector<Pin*> getAllPorts();
334334
void computeTrackConsumption(const Net* net,
335-
int& track_consumption,
335+
int8_t& track_consumption,
336336
std::vector<int8_t>*& edge_costs_per_layer);
337337

338338
// aux functions

src/grt/src/GlobalRouter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ void GlobalRouter::makeFastrouteNet(Net* net)
11631163

11641164
bool is_clock = (net->getSignalType() == odb::dbSigType::CLOCK);
11651165
std::vector<int8_t>* edge_cost_per_layer;
1166-
int edge_cost_for_net;
1166+
int8_t edge_cost_for_net;
11671167
computeTrackConsumption(net, edge_cost_for_net, edge_cost_per_layer);
11681168

11691169
// set layer restriction only to clock nets that are not connected to
@@ -1249,7 +1249,7 @@ void GlobalRouter::getCapacityReductionData(CapacityReductionData& cap_red_data)
12491249

12501250
void GlobalRouter::computeTrackConsumption(
12511251
const Net* net,
1252-
int& track_consumption,
1252+
int8_t& track_consumption,
12531253
std::vector<int8_t>*& edge_costs_per_layer)
12541254
{
12551255
edge_costs_per_layer = nullptr;
@@ -1289,7 +1289,8 @@ void GlobalRouter::computeTrackConsumption(
12891289
}
12901290
(*edge_costs_per_layer)[layerIdx - 1] = consumption;
12911291

1292-
track_consumption = std::max(track_consumption, consumption);
1292+
track_consumption
1293+
= std::max(track_consumption, static_cast<int8_t>(consumption));
12931294
}
12941295
}
12951296
}

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ enum class EdgeDirection
4747

4848
struct Segment // A Segment is a 2-pin connection
4949
{
50-
int16_t x1, y1, x2, y2; // coordinates of two endpoints
51-
int16_t Zpoint; // The coordinates of Z point (x for HVH and y for VHV)
52-
int8_t cost; // the netID of the net this segment belonging to
53-
bool xFirst : 1; // route x-direction first (only for L route)
54-
bool HVH : 1; // TRUE = HVH or false = VHV (only for Z route)
50+
Segment(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int8_t cost)
51+
: x1(x1), y1(y1), x2(x2), y2(y2), cost(cost)
52+
{
53+
}
54+
const int16_t x1, y1, x2, y2; // coordinates of two endpoints (x1 <= x2)
55+
int16_t Zpoint; // The coordinates of Z point (x for HVH and y for VHV)
56+
const int8_t cost; // the netID of the net this segment belonging to
57+
bool xFirst : 1; // route x-direction first (only for L route)
58+
bool HVH : 1; // TRUE = HVH or false = VHV (only for Z route)
5559
};
5660

5761
struct FrNet // A Net is a set of connected MazePoints
@@ -61,7 +65,7 @@ struct FrNet // A Net is a set of connected MazePoints
6165
float getSlack() const { return slack_; }
6266
odb::dbNet* getDbNet() const { return db_net_; }
6367
int getDriverIdx() const { return driver_idx_; }
64-
int getEdgeCost() const { return edge_cost_; }
68+
int8_t getEdgeCost() const { return edge_cost_; }
6569
const char* getName() const;
6670
int getMaxLayer() const { return max_layer_; }
6771
int getMinLayer() const { return min_layer_; }
@@ -79,7 +83,7 @@ struct FrNet // A Net is a set of connected MazePoints
7983
void reset(odb::dbNet* db_net,
8084
bool is_clock,
8185
int driver_idx,
82-
int edge_cost,
86+
int8_t edge_cost,
8387
int min_layer,
8488
int max_layer,
8589
float slack,
@@ -97,7 +101,7 @@ struct FrNet // A Net is a set of connected MazePoints
97101
bool is_clock_; // flag that indicates if net is a clock net
98102
bool is_critical_;
99103
int driver_idx_;
100-
int edge_cost_;
104+
int8_t edge_cost_;
101105
int min_layer_;
102106
int max_layer_;
103107
float slack_;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class FastRouteCore
104104
bool is_clock,
105105
bool is_local,
106106
int driver_idx,
107-
int cost,
107+
int8_t cost,
108108
int min_layer,
109109
int max_layer,
110110
float slack,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ FrNet* FastRouteCore::addNet(odb::dbNet* db_net,
231231
bool is_clock,
232232
bool is_local,
233233
int driver_idx,
234-
int cost,
234+
int8_t cost,
235235
int min_layer,
236236
int max_layer,
237237
float slack,
@@ -1601,7 +1601,7 @@ void FrNet::addPin(int x, int y, int layer)
16011601
void FrNet::reset(odb::dbNet* db_net,
16021602
bool is_clock,
16031603
int driver_idx,
1604-
int edge_cost,
1604+
int8_t edge_cost,
16051605
int min_layer,
16061606
int max_layer,
16071607
float slack,

src/grt/src/fastroute/src/RSMT.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -718,21 +718,12 @@ void FastRouteCore::gen_brk_RSMT(const bool congestionDriven,
718718

719719
if (x1 != x2 || y1 != y2) { // the branch is not degraded (a point)
720720
// the position of this segment in seglist
721-
seglist_[netID].push_back(Segment());
722-
auto& seg = seglist_[netID].back();
721+
const int8_t cost = nets_[netID]->getEdgeCost();
723722
if (x1 < x2) {
724-
seg.x1 = x1;
725-
seg.x2 = x2;
726-
seg.y1 = y1;
727-
seg.y2 = y2;
723+
seglist_[netID].emplace_back(x1, y1, x2, y2, cost);
728724
} else {
729-
seg.x1 = x2;
730-
seg.x2 = x1;
731-
seg.y1 = y2;
732-
seg.y2 = y1;
725+
seglist_[netID].emplace_back(x2, y2, x1, y1, cost);
733726
}
734-
735-
seg.cost = nets_[netID]->getEdgeCost();
736727
}
737728
} // loop j
738729

0 commit comments

Comments
 (0)