@@ -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)
@@ -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)
12381250void 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+
21762218void GlobalRouter::updateVias ()
21772219{
21782220 for (auto & net_route : routes_) {
0 commit comments