Skip to content

Commit 3f22e49

Browse files
committed
Merge remote-tracking branch 'origin/master' into dpl-site-intervals
2 parents 1e9ea30 + f8ce580 commit 3f22e49

34 files changed

+811
-398
lines changed

src/drt/src/dr/FlexDR_graphics.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class GridGraphDescriptor : public gui::Descriptor
3838
gui::Selected makeSelected(std::any object) const override;
3939
bool lessThan(std::any l, std::any r) const override;
4040

41-
bool getAllObjects(gui::SelectionSet& objects) const override;
41+
void visitAllObjects(
42+
const std::function<void(const gui::Selected&)>& func) const override;
4243
};
4344

4445
std::string GridGraphDescriptor::getName(std::any object) const
@@ -187,9 +188,9 @@ bool GridGraphDescriptor::lessThan(std::any l, std::any r) const
187188
< std::tie(r_grid.x, r_grid.y, r_grid.z);
188189
}
189190

190-
bool GridGraphDescriptor::getAllObjects(gui::SelectionSet& objects) const
191+
void GridGraphDescriptor::visitAllObjects(
192+
const std::function<void(const gui::Selected&)>& func) const
191193
{
192-
return false;
193194
}
194195

195196
//////////////////////////////////////////////////

src/grt/include/grt/GlobalRouter.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class GlobalRouter
155155
// flow functions
156156
void readGuides(const char* file_name);
157157
void loadGuidesFromDB();
158+
void ensurePinsPositions(odb::dbNet* db_net);
158159
void saveGuidesFromFile(std::unordered_map<odb::dbNet*, Guides>& guides);
159160
void saveGuides(const std::vector<odb::dbNet*>& nets);
160161
void writeSegments(const char* file_name);
@@ -332,14 +333,20 @@ class GlobalRouter
332333
std::vector<Pin*> getAllPorts();
333334
void computeTrackConsumption(const Net* net,
334335
int& track_consumption,
335-
std::vector<int>*& edge_costs_per_layer);
336+
std::vector<int8_t>*& edge_costs_per_layer);
336337

337338
// aux functions
338339
std::vector<odb::Point> findOnGridPositions(const Pin& pin,
339340
bool& has_access_points,
340-
odb::Point& pos_on_grid);
341+
odb::Point& pos_on_grid,
342+
bool ignore_db_access_points
343+
= false);
341344
int getNetMaxRoutingLayer(const Net* net);
342345
void findPins(Net* net);
346+
void computePinPositionOnGrid(std::vector<odb::Point>& pin_positions_on_grid,
347+
Pin& pin,
348+
odb::Point& pos_on_grid,
349+
bool has_access_points);
343350
void findFastRoutePins(Net* net,
344351
std::vector<RoutePt>& pins_on_grid,
345352
int& root_idx);

src/grt/src/GlobalRouter.cpp

Lines changed: 72 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,8 @@ bool GlobalRouter::findPinAccessPointPositions(
915915
std::vector<odb::Point> GlobalRouter::findOnGridPositions(
916916
const Pin& pin,
917917
bool& has_access_points,
918-
odb::Point& pos_on_grid)
918+
odb::Point& pos_on_grid,
919+
bool ignore_db_access_points)
919920
{
920921
std::vector<std::pair<odb::Point, odb::Point>> ap_positions;
921922

@@ -925,7 +926,7 @@ std::vector<odb::Point> GlobalRouter::findOnGridPositions(
925926

926927
std::vector<odb::Point> positions_on_grid;
927928

928-
if (has_access_points) {
929+
if (has_access_points && !ignore_db_access_points) {
929930
for (const auto& ap_position : ap_positions) {
930931
pos_on_grid = ap_position.second;
931932
positions_on_grid.push_back(pos_on_grid);
@@ -957,6 +958,7 @@ std::vector<odb::Point> GlobalRouter::findOnGridPositions(
957958
}
958959
}
959960
positions_on_grid.push_back(pos_on_grid);
961+
has_access_points = false;
960962
}
961963
}
962964

@@ -971,36 +973,46 @@ void GlobalRouter::findPins(Net* net)
971973
std::vector<odb::Point> pin_positions_on_grid
972974
= findOnGridPositions(pin, has_access_points, pos_on_grid);
973975

974-
int votes = -1;
976+
computePinPositionOnGrid(
977+
pin_positions_on_grid, pin, pos_on_grid, has_access_points);
978+
}
979+
}
975980

976-
odb::Point pin_position;
977-
for (odb::Point pos : pin_positions_on_grid) {
978-
int equals = std::count(
979-
pin_positions_on_grid.begin(), pin_positions_on_grid.end(), pos);
980-
if (equals > votes) {
981-
pin_position = pos;
982-
votes = equals;
983-
}
984-
}
981+
void GlobalRouter::computePinPositionOnGrid(
982+
std::vector<odb::Point>& pin_positions_on_grid,
983+
Pin& pin,
984+
odb::Point& pos_on_grid,
985+
const bool has_access_points)
986+
{
987+
int votes = -1;
985988

986-
// check if the pin has access points to avoid changing the position on grid
987-
// when the pin overlaps with a single track.
988-
// this way, the result based on drt APs is maintained
989-
if (!has_access_points && pinOverlapsWithSingleTrack(pin, pos_on_grid)) {
990-
const int conn_layer = pin.getConnectionLayer();
991-
odb::dbTechLayer* layer = routing_layers_[conn_layer];
992-
pos_on_grid = grid_->getPositionOnGrid(pos_on_grid);
993-
if (!(pos_on_grid == pin_position)
994-
&& ((layer->getDirection() == odb::dbTechLayerDir::HORIZONTAL
995-
&& pos_on_grid.y() != pin_position.y())
996-
|| (layer->getDirection() == odb::dbTechLayerDir::VERTICAL
997-
&& pos_on_grid.x() != pin_position.x()))) {
998-
pin_position = pos_on_grid;
999-
}
989+
odb::Point pin_position;
990+
for (odb::Point pos : pin_positions_on_grid) {
991+
int equals = std::count(
992+
pin_positions_on_grid.begin(), pin_positions_on_grid.end(), pos);
993+
if (equals > votes) {
994+
pin_position = pos;
995+
votes = equals;
1000996
}
997+
}
1001998

1002-
pin.setOnGridPosition(pin_position);
999+
// check if the pin has access points to avoid changing the position on grid
1000+
// when the pin overlaps with a single track.
1001+
// this way, the result based on drt APs is maintained
1002+
if (!has_access_points && pinOverlapsWithSingleTrack(pin, pos_on_grid)) {
1003+
const int conn_layer = pin.getConnectionLayer();
1004+
odb::dbTechLayer* layer = routing_layers_[conn_layer];
1005+
pos_on_grid = grid_->getPositionOnGrid(pos_on_grid);
1006+
if (!(pos_on_grid == pin_position)
1007+
&& ((layer->getDirection() == odb::dbTechLayerDir::HORIZONTAL
1008+
&& pos_on_grid.y() != pin_position.y())
1009+
|| (layer->getDirection() == odb::dbTechLayerDir::VERTICAL
1010+
&& pos_on_grid.x() != pin_position.x()))) {
1011+
pin_position = pos_on_grid;
1012+
}
10031013
}
1014+
1015+
pin.setOnGridPosition(pin_position);
10041016
}
10051017

10061018
int GlobalRouter::getNetMaxRoutingLayer(const Net* net)
@@ -1150,7 +1162,7 @@ void GlobalRouter::makeFastrouteNet(Net* net)
11501162
findFastRoutePins(net, pins_on_grid, root_idx);
11511163

11521164
bool is_clock = (net->getSignalType() == odb::dbSigType::CLOCK);
1153-
std::vector<int>* edge_cost_per_layer;
1165+
std::vector<int8_t>* edge_cost_per_layer;
11541166
int edge_cost_for_net;
11551167
computeTrackConsumption(net, edge_cost_for_net, edge_cost_per_layer);
11561168

@@ -1238,7 +1250,7 @@ void GlobalRouter::getCapacityReductionData(CapacityReductionData& cap_red_data)
12381250
void GlobalRouter::computeTrackConsumption(
12391251
const Net* net,
12401252
int& track_consumption,
1241-
std::vector<int>*& edge_costs_per_layer)
1253+
std::vector<int8_t>*& edge_costs_per_layer)
12421254
{
12431255
edge_costs_per_layer = nullptr;
12441256
track_consumption = 1;
@@ -1250,7 +1262,7 @@ void GlobalRouter::computeTrackConsumption(
12501262
odb::dbTechNonDefaultRule* ndr = db_net->getNonDefaultRule();
12511263
if (ndr) {
12521264
int num_layers = grid_->getNumLayers();
1253-
edge_costs_per_layer = new std::vector<int>(num_layers + 1, 1);
1265+
edge_costs_per_layer = new std::vector<int8_t>(num_layers + 1, 1);
12541266
std::vector<odb::dbTechLayerRule*> layer_rules;
12551267
ndr->getLayerRules(layer_rules);
12561268

@@ -1268,6 +1280,13 @@ void GlobalRouter::computeTrackConsumption(
12681280
int ndr_pitch = ndr_width / 2 + ndr_spacing + default_width / 2;
12691281

12701282
int consumption = std::ceil((float) ndr_pitch / default_pitch);
1283+
if (consumption > std::numeric_limits<int8_t>::max()) {
1284+
logger_->error(GRT,
1285+
272,
1286+
"NDR consumption {} exceeds {} and is unsupported",
1287+
consumption,
1288+
std::numeric_limits<int8_t>::max());
1289+
}
12711290
(*edge_costs_per_layer)[layerIdx - 1] = consumption;
12721291

12731292
track_consumption = std::max(track_consumption, consumption);
@@ -2166,13 +2185,36 @@ void GlobalRouter::loadGuidesFromDB()
21662185
mergeSegments(pins, route);
21672186
}
21682187

2188+
for (auto& [db_net, groute] : routes_) {
2189+
ensurePinsPositions(db_net);
2190+
}
2191+
21692192
updateEdgesUsage();
21702193
if (block_->getGCellGrid() == nullptr) {
21712194
updateDbCongestion();
21722195
}
21732196
heatmap_->update();
21742197
}
21752198

2199+
void GlobalRouter::ensurePinsPositions(odb::dbNet* db_net)
2200+
{
2201+
std::string pins_not_covered;
2202+
netIsCovered(db_net, pins_not_covered);
2203+
if (!pins_not_covered.empty()) {
2204+
Net* net = db_net_map_[db_net];
2205+
for (Pin& pin : net->getPins()) {
2206+
if (pins_not_covered.find(pin.getName()) != std::string::npos) {
2207+
bool has_aps;
2208+
odb::Point pos_on_grid;
2209+
std::vector<odb::Point> pin_positions_on_grid
2210+
= findOnGridPositions(pin, has_aps, pos_on_grid, true);
2211+
computePinPositionOnGrid(
2212+
pin_positions_on_grid, pin, pos_on_grid, has_aps);
2213+
}
2214+
}
2215+
}
2216+
}
2217+
21762218
void GlobalRouter::updateVias()
21772219
{
21782220
for (auto& net_route : routes_) {

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

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

4848
struct Segment // A Segment is a 2-pin connection
4949
{
50-
bool xFirst; // route x-direction first (only for L route)
51-
bool HVH; // TRUE = HVH or false = VHV (only for Z route)
52-
5350
int16_t x1, y1, x2, y2; // coordinates of two endpoints
54-
int netID; // the netID of the net this segment belonging to
55-
int16_t Zpoint; // The coordinates of Z point (x for HVH and y for VHV)
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)
5655
};
5756

5857
struct FrNet // A Net is a set of connected MazePoints
@@ -67,7 +66,7 @@ struct FrNet // A Net is a set of connected MazePoints
6766
int getMaxLayer() const { return max_layer_; }
6867
int getMinLayer() const { return min_layer_; }
6968
int getNumPins() const { return pin_x_.size(); }
70-
int getLayerEdgeCost(int layer) const;
69+
int8_t getLayerEdgeCost(int layer) const;
7170

7271
int getPinX(int idx) const { return pin_x_[idx]; }
7372
int getPinY(int idx) const { return pin_y_[idx]; }
@@ -84,7 +83,7 @@ struct FrNet // A Net is a set of connected MazePoints
8483
int min_layer,
8584
int max_layer,
8685
float slack,
87-
std::vector<int>* edge_cost_per_layer);
86+
std::vector<int8_t>* edge_cost_per_layer);
8887
void setMaxLayer(int max_layer) { max_layer_ = max_layer; }
8988
void setMinLayer(int min_layer) { min_layer_ = min_layer; }
9089
void setSlack(float slack) { slack_ = slack; }
@@ -103,7 +102,7 @@ struct FrNet // A Net is a set of connected MazePoints
103102
int max_layer_;
104103
float slack_;
105104
// Non-null when an NDR has been applied to the net.
106-
std::unique_ptr<std::vector<int>> edge_cost_per_layer_;
105+
std::unique_ptr<std::vector<int8_t>> edge_cost_per_layer_;
107106
};
108107

109108
struct Edge // An Edge is the routing track holder between two adjacent

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class FastRouteCore
108108
int min_layer,
109109
int max_layer,
110110
float slack,
111-
std::vector<int>* edge_cost_per_layer);
111+
std::vector<int8_t>* edge_cost_per_layer);
112112
void deleteNet(odb::dbNet* db_net);
113113
void removeNet(odb::dbNet* db_net);
114114
void mergeNet(odb::dbNet* removed_net, odb::dbNet* preserved_net);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ FrNet* FastRouteCore::addNet(odb::dbNet* db_net,
235235
int min_layer,
236236
int max_layer,
237237
float slack,
238-
std::vector<int>* edge_cost_per_layer)
238+
std::vector<int8_t>* edge_cost_per_layer)
239239
{
240240
int netID;
241241
bool exists;
@@ -1582,7 +1582,7 @@ void FastRouteCore::StTreeVisualization(const StTree& stree,
15821582

15831583
////////////////////////////////////////////////////////////////
15841584

1585-
int FrNet::getLayerEdgeCost(int layer) const
1585+
int8_t FrNet::getLayerEdgeCost(int layer) const
15861586
{
15871587
if (edge_cost_per_layer_) {
15881588
return (*edge_cost_per_layer_)[layer];
@@ -1605,7 +1605,7 @@ void FrNet::reset(odb::dbNet* db_net,
16051605
int min_layer,
16061606
int max_layer,
16071607
float slack,
1608-
std::vector<int>* edge_cost_per_layer)
1608+
std::vector<int8_t>* edge_cost_per_layer)
16091609
{
16101610
db_net_ = db_net;
16111611
is_critical_ = false;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ void FastRouteCore::gen_brk_RSMT(const bool congestionDriven,
732732
seg.y2 = y1;
733733
}
734734

735-
seg.netID = netID;
735+
seg.cost = nets_[netID]->getEdgeCost();
736736
}
737737
} // loop j
738738

src/grt/src/fastroute/src/RipUp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ using utl::GRT;
1717
// rip-up a L segment
1818
void FastRouteCore::ripupSegL(const Segment* seg)
1919
{
20-
const int edgeCost = nets_[seg->netID]->getEdgeCost();
20+
const int8_t edgeCost = seg->cost;
2121

2222
const auto [ymin, ymax] = std::minmax(seg->y1, seg->y2);
2323

src/grt/src/fastroute/src/route.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using utl::GRT;
1919
// possible L for L segments
2020
void FastRouteCore::estimateOneSeg(const Segment* seg)
2121
{
22-
const int edgeCost = nets_[seg->netID]->getEdgeCost();
22+
const int8_t edgeCost = seg->cost;
2323

2424
const auto [ymin, ymax] = std::minmax(seg->y1, seg->y2);
2525

@@ -39,7 +39,7 @@ void FastRouteCore::estimateOneSeg(const Segment* seg)
3939

4040
void FastRouteCore::routeSegV(const Segment* seg)
4141
{
42-
const int edgeCost = nets_[seg->netID]->getEdgeCost();
42+
const int8_t edgeCost = seg->cost;
4343

4444
const auto [ymin, ymax] = std::minmax(seg->y1, seg->y2);
4545

@@ -48,15 +48,15 @@ void FastRouteCore::routeSegV(const Segment* seg)
4848

4949
void FastRouteCore::routeSegH(const Segment* seg)
5050
{
51-
const int edgeCost = nets_[seg->netID]->getEdgeCost();
51+
const int8_t edgeCost = seg->cost;
5252

5353
graph2d_.addEstUsageH({seg->x1, seg->x2}, seg->y1, edgeCost);
5454
}
5555

5656
// L-route, based on previous L route
5757
void FastRouteCore::routeSegL(Segment* seg)
5858
{
59-
const int edgeCost = nets_[seg->netID]->getEdgeCost();
59+
const int8_t edgeCost = seg->cost;
6060

6161
const auto [ymin, ymax] = std::minmax(seg->y1, seg->y2);
6262

@@ -137,7 +137,7 @@ void FastRouteCore::routeSegLFirstTime(Segment* seg)
137137
}
138138
}
139139

140-
const int edgeCost = nets_[seg->netID]->getEdgeCost();
140+
const int8_t edgeCost = seg->cost;
141141

142142
if (costL1 < costL2) {
143143
// two parts (x1, y1)-(x1, y2) and (x1, y2)-(x2, y2)

src/gui/include/gui/gui.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ class Descriptor
312312
virtual bool isInst(std::any /* object */) const { return false; }
313313
virtual bool isNet(std::any /* object */) const { return false; }
314314

315-
virtual bool getAllObjects(SelectionSet& /* objects */) const = 0;
315+
virtual void visitAllObjects(
316+
const std::function<void(const Selected&)>& func) const
317+
= 0;
316318

317319
// A property is a name and a value.
318320
struct Property

0 commit comments

Comments
 (0)