Skip to content

Commit b4b32b9

Browse files
authored
Merge pull request #8301 from The-OpenROAD-Project-staging/cugr-refactor
Cugr refactor
2 parents 6f4b99d + bc7e193 commit b4b32b9

File tree

14 files changed

+365
-344
lines changed

14 files changed

+365
-344
lines changed

src/grt/src/cugr/include/CUGR.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ class CUGR
6666
NetRouteMap getRoutes();
6767

6868
private:
69+
void updateOverflowNets(std::vector<int>& netIndices);
70+
void patternRoute(std::vector<int>& netIndices);
71+
void patternRouteWithDetours(std::vector<int>& netIndices);
72+
void mazeRoute(std::vector<int>& netIndices);
6973
void sortNetIndices(std::vector<int>& netIndices) const;
7074
void getGuides(const GRNet* net,
7175
std::vector<std::pair<int, grt::BoxT>>& guides);

src/grt/src/cugr/src/CUGR.cpp

Lines changed: 142 additions & 141 deletions
Large diffs are not rendered by default.

src/grt/src/cugr/src/Design.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void Design::readNetlist()
102102
}
103103
}
104104

105-
pins.emplace_back(pin_count, db_bterm, pin_shapes, true);
105+
pins.emplace_back(pin_count, db_bterm, pin_shapes);
106106
pin_count++;
107107
}
108108

@@ -125,7 +125,7 @@ void Design::readNetlist()
125125
}
126126
}
127127

128-
pins.emplace_back(pin_count, db_iterm, pin_shapes, false);
128+
pins.emplace_back(pin_count, db_iterm, pin_shapes);
129129
pin_count++;
130130
}
131131
nets_.emplace_back(net_index, db_net, pins);
@@ -240,9 +240,9 @@ int Design::readSpecialNetObstructions()
240240
void Design::computeGrid()
241241
{
242242
gridlines_.resize(2);
243-
for (unsigned dimension = 0; dimension < 2; dimension++) {
244-
const int low = die_region_[dimension].low;
245-
const int high = die_region_[dimension].high;
243+
for (int dimension = 0; dimension < 2; dimension++) {
244+
const int low = die_region_[dimension].low();
245+
const int high = die_region_[dimension].high();
246246
for (int i = low; i + default_gridline_spacing_ < high;
247247
i += default_gridline_spacing_) {
248248
gridlines_[dimension].push_back(i);

src/grt/src/cugr/src/GRNet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ GRNet::GRNet(const CUGRNet& baseNet, const GridGraph* gridGraph)
2323
std::unordered_set<uint64_t> included;
2424
for (const auto& pinShape : pinShapes) {
2525
const BoxT cells = gridGraph->rangeSearchCells(pinShape);
26-
for (int x = cells.x.low; x <= cells.x.high; x++) {
27-
for (int y = cells.y.low; y <= cells.y.high; y++) {
26+
for (int x = cells.x.low(); x <= cells.x.high(); x++) {
27+
for (int y = cells.y.low(); y <= cells.y.high(); y++) {
2828
const GRPoint point(pinShape.getLayerIdx(), x, y);
2929
const uint64_t hash = gridGraph->hashCell(point);
3030
if (included.find(hash) == included.end()) {

src/grt/src/cugr/src/GridGraph.cpp

Lines changed: 68 additions & 66 deletions
Large diffs are not rendered by default.

src/grt/src/cugr/src/GridGraph.h

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,13 @@ class GridGraph
3535
GridGraph(const Design* design, const Constants& constants);
3636
int getLibDBU() const { return lib_dbu_; }
3737
int getM2Pitch() const { return m2_pitch_; }
38-
unsigned getNumLayers() const { return num_layers_; }
39-
unsigned getSize(unsigned dimension) const
40-
{
41-
return (dimension ? y_size_ : x_size_);
42-
}
38+
int getNumLayers() const { return num_layers_; }
39+
int getSize(int dimension) const { return (dimension ? y_size_ : x_size_); }
4340
std::string getLayerName(int layer_index) const
4441
{
4542
return layer_names_[layer_index];
4643
}
47-
unsigned getLayerDirection(int layer_index) const
44+
int getLayerDirection(int layer_index) const
4845
{
4946
return layer_directions_[layer_index];
5047
}
@@ -58,7 +55,7 @@ class GridGraph
5855
{
5956
return (uint64_t) x * y_size_ + y;
6057
}
61-
int getGridline(const unsigned dimension, const int index) const
58+
int getGridline(const int dimension, const int index) const
6259
{
6360
return gridlines_[dimension][index];
6461
}
@@ -70,7 +67,7 @@ class GridGraph
7067
}
7168

7269
// Costs
73-
int getEdgeLength(unsigned direction, unsigned edge_index) const;
70+
int getEdgeLength(int direction, int edge_index) const;
7471
CostT getWireCost(int layer_index, PointT u, PointT v) const;
7572
CostT getViaCost(int layer_index, PointT loc) const;
7673
CostT getUnitViaCost() const { return unit_via_cost_; }
@@ -114,13 +111,13 @@ class GridGraph
114111
const int lib_dbu_;
115112
int m2_pitch_;
116113

117-
unsigned num_layers_;
118-
unsigned x_size_;
119-
unsigned y_size_;
114+
int num_layers_;
115+
int x_size_;
116+
int y_size_;
120117
std::vector<std::vector<int>> gridlines_;
121118
std::vector<std::vector<int>> grid_centers_;
122119
std::vector<std::string> layer_names_;
123-
std::vector<unsigned> layer_directions_;
120+
std::vector<int> layer_directions_;
124121
std::vector<int> layer_min_lengths_;
125122

126123
// Unit costs
@@ -135,11 +132,10 @@ class GridGraph
135132
// (l, x, y+1)} depending on the routing direction of the layer
136133
Constants constants_;
137134

138-
IntervalT rangeSearchGridlines(unsigned dimension,
135+
IntervalT rangeSearchGridlines(int dimension,
139136
const IntervalT& loc_interval) const;
140137
// Find the gridlines_ within [locInterval.low, locInterval.high]
141-
IntervalT rangeSearchRows(unsigned dimension,
142-
const IntervalT& loc_interval) const;
138+
IntervalT rangeSearchRows(int dimension, const IntervalT& loc_interval) const;
143139
// Find the rows/columns overlapping with [locInterval.low, locInterval.high]
144140

145141
// Utility functions for cost calculation

src/grt/src/cugr/src/Layers.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,35 +88,35 @@ int MetalLayer::getTrackLocation(const int track_index) const
8888
IntervalT MetalLayer::rangeSearchTracks(const IntervalT& loc_range,
8989
const bool include_bound) const
9090
{
91-
IntervalT track_range(
92-
ceil(double(std::max(loc_range.low, first_track_loc_) - first_track_loc_)
93-
/ double(pitch_)),
94-
floor(double(std::min(loc_range.high, last_track_loc_) - first_track_loc_)
95-
/ double(pitch_)));
91+
const int lo = std::max(loc_range.low(), first_track_loc_);
92+
const int hi = std::min(loc_range.high(), last_track_loc_);
93+
const double pitch = pitch_;
94+
IntervalT track_range(std::ceil((lo - first_track_loc_) / pitch),
95+
std::floor((hi - first_track_loc_) / pitch));
9696
if (!track_range.IsValid()) {
9797
return track_range;
9898
}
9999
if (!include_bound) {
100-
if (getTrackLocation(track_range.low) == loc_range.low) {
101-
++track_range.low;
100+
if (getTrackLocation(track_range.low()) == loc_range.low()) {
101+
track_range.addToLow(1);
102102
}
103-
if (getTrackLocation(track_range.high) == loc_range.high) {
104-
--track_range.high;
103+
if (getTrackLocation(track_range.high()) == loc_range.high()) {
104+
track_range.addToHigh(-1);
105105
}
106106
}
107107
return track_range;
108108
}
109109

110110
int MetalLayer::getParallelSpacing(const int width, const int length) const
111111
{
112-
unsigned w = parallel_width_.size() - 1;
112+
int w = parallel_width_.size() - 1;
113113
while (w > 0 && parallel_width_[w] >= width) {
114114
w--;
115115
}
116116
if (length == 0) {
117117
return parallel_spacing_[w][0];
118118
}
119-
unsigned l = parallel_length_.size() - 1;
119+
int l = parallel_length_.size() - 1;
120120
while (l > 0 && parallel_length_[l] >= length) {
121121
l--;
122122
}

src/grt/src/cugr/src/MazeRoute.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,16 @@ void SparseGraph::init(const GridGraphView<CostT>& wire_cost_view,
8989
// 3. Add same-layer connections
9090
edges_.resize(vertices_.size(), {-1, -1, -1});
9191
costs_.resize(vertices_.size(), {-1, -1, -1});
92-
auto addSameLayerEdge
93-
= [&](const unsigned direction, const int xi, const int yi) {
94-
const int u = getVertexIndex(direction, xi, yi);
95-
const int v = direction == MetalLayer::H ? u + 1 : u + xs_.size();
96-
const PointT U(xs_[xi], ys_[yi]);
97-
const PointT V(xs_[xi + 1 - direction], ys_[yi + direction]);
92+
auto addSameLayerEdge = [&](const int direction, const int xi, const int yi) {
93+
const int u = getVertexIndex(direction, xi, yi);
94+
const int v = direction == MetalLayer::H ? u + 1 : u + xs_.size();
95+
const PointT U(xs_[xi], ys_[yi]);
96+
const PointT V(xs_[xi + 1 - direction], ys_[yi + direction]);
9897

99-
edges_[u][0] = v;
100-
edges_[v][1] = u;
101-
costs_[u][0] = costs_[v][1] = wire_cost_view.sum(U, V);
102-
};
98+
edges_[u][0] = v;
99+
edges_[v][1] = u;
100+
costs_[u][0] = costs_[v][1] = wire_cost_view.sum(U, V);
101+
};
103102

104103
for (int direction = 0; direction < 2; direction++) {
105104
if (direction == MetalLayer::H) {

src/grt/src/cugr/src/Netlist.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ namespace grt {
1313

1414
CUGRPin::CUGRPin(const int index,
1515
odb::dbITerm* iterm,
16-
const std::vector<BoxOnLayer>& pin_shapes,
17-
const bool is_port)
18-
: index_(index), iterm(iterm), pin_shapes_(pin_shapes), is_port_(is_port)
16+
const std::vector<BoxOnLayer>& pin_shapes)
17+
: iterm(iterm), pin_shapes_(pin_shapes), index_(index), is_port_(false)
1918
{
2019
}
2120

2221
CUGRPin::CUGRPin(const int index,
2322
odb::dbBTerm* bterm,
24-
const std::vector<BoxOnLayer>& pin_shapes,
25-
const bool is_port)
26-
: index_(index), bterm(bterm), pin_shapes_(pin_shapes), is_port_(is_port)
23+
const std::vector<BoxOnLayer>& pin_shapes)
24+
: bterm(bterm), pin_shapes_(pin_shapes), index_(index), is_port_(true)
2725
{
2826
}
2927

src/grt/src/cugr/src/Netlist.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ class CUGRPin
1616
public:
1717
CUGRPin(int index,
1818
odb::dbITerm* iterm,
19-
const std::vector<BoxOnLayer>& pin_shapes,
20-
bool is_port);
19+
const std::vector<BoxOnLayer>& pin_shapes);
2120
CUGRPin(int index,
2221
odb::dbBTerm* bterm,
23-
const std::vector<BoxOnLayer>& pin_shapes,
24-
bool is_port);
22+
const std::vector<BoxOnLayer>& pin_shapes);
2523

2624
int getIndex() const { return index_; }
2725
odb::dbITerm* getITerm() const;
@@ -31,13 +29,13 @@ class CUGRPin
3129
std::string getName() const;
3230

3331
private:
34-
const int index_;
3532
union
3633
{
3734
odb::dbITerm* iterm;
3835
odb::dbBTerm* bterm;
3936
};
4037
std::vector<BoxOnLayer> pin_shapes_;
38+
const int index_;
4139
const bool is_port_;
4240
};
4341

0 commit comments

Comments
 (0)