@@ -915,7 +915,8 @@ bool GlobalRouter::findPinAccessPointPositions(
915915std::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
10061018int 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+
21762211void GlobalRouter::updateVias ()
21772212{
21782213 for (auto & net_route : routes_) {
0 commit comments