Skip to content

Commit 27ef7c9

Browse files
authored
Merge pull request The-OpenROAD-Project#7969 from The-OpenROAD-Project-staging/grt_fallback_ap
grt: fallback to interal access point calculation when pins are not connected to the route guides
2 parents 5b7dfb9 + ecd4f97 commit 27ef7c9

File tree

2 files changed

+70
-28
lines changed

2 files changed

+70
-28
lines changed

src/grt/include/grt/GlobalRouter.h

Lines changed: 8 additions & 1 deletion
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);
@@ -337,9 +338,15 @@ class GlobalRouter
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: 62 additions & 27 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)
@@ -2166,13 +2178,36 @@ void GlobalRouter::loadGuidesFromDB()
21662178
mergeSegments(pins, route);
21672179
}
21682180

2181+
for (auto& [db_net, groute] : routes_) {
2182+
ensurePinsPositions(db_net);
2183+
}
2184+
21692185
updateEdgesUsage();
21702186
if (block_->getGCellGrid() == nullptr) {
21712187
updateDbCongestion();
21722188
}
21732189
heatmap_->update();
21742190
}
21752191

2192+
void GlobalRouter::ensurePinsPositions(odb::dbNet* db_net)
2193+
{
2194+
std::string pins_not_covered;
2195+
netIsCovered(db_net, pins_not_covered);
2196+
if (!pins_not_covered.empty()) {
2197+
Net* net = db_net_map_[db_net];
2198+
for (Pin& pin : net->getPins()) {
2199+
if (pins_not_covered.find(pin.getName()) != std::string::npos) {
2200+
bool has_aps;
2201+
odb::Point pos_on_grid;
2202+
std::vector<odb::Point> pin_positions_on_grid
2203+
= findOnGridPositions(pin, has_aps, pos_on_grid, true);
2204+
computePinPositionOnGrid(
2205+
pin_positions_on_grid, pin, pos_on_grid, has_aps);
2206+
}
2207+
}
2208+
}
2209+
}
2210+
21762211
void GlobalRouter::updateVias()
21772212
{
21782213
for (auto& net_route : routes_) {

0 commit comments

Comments
 (0)