diff --git a/src/gpl/src/routeBase.cpp b/src/gpl/src/routeBase.cpp index 6e3091918a8..5e5741b6418 100644 --- a/src/gpl/src/routeBase.cpp +++ b/src/gpl/src/routeBase.cpp @@ -475,51 +475,44 @@ void RouteBase::updateRoute() tg_->setTileCnt(gridX.size(), gridY.size()); tg_->initTiles(); - int min_routing_layer = grouter_->getMinRoutingLayer(); - int max_routing_layer = grouter_->getMaxRoutingLayer(); for (int i = 1; i <= numLayers; i++) { odb::dbTechLayer* layer = tech->findRoutingLayer(i); bool isHorizontalLayer = (layer->getDirection() == odb::dbTechLayerDir::HORIZONTAL); for (auto& tile : tg_->tiles()) { - float ratio; - if (i >= min_routing_layer && i <= max_routing_layer) { - // Check left and down tile - // and set the minimum usage/cap vals for - // TileGrid setup. - - // first extract current tiles' usage - ratio = getUsageCapacityRatio( - tile, layer, gGrid, rbVars_.ignoreEdgeRatio); - - // if horizontal layer (i.e., vertical edges) - // should consider LEFT tile's RIGHT edge == current 'tile's LEFT edge - // (current 'ratio' points to RIGHT edges usage) - if (isHorizontalLayer && tile->x() >= 1) { - Tile* leftTile - = tg_->tiles()[tile->y() * tg_->tileCntX() + tile->x() - 1]; - float leftRatio = getUsageCapacityRatio( - leftTile, layer, gGrid, rbVars_.ignoreEdgeRatio); - ratio = std::fmax(leftRatio, ratio); - } + // Check left and down tile + // and set the minimum usage/cap vals for + // TileGrid setup. - // if vertical layer (i.e., horizontal edges) - // should consider DOWN tile's UP edge == current 'tile's DOWN edge - // (current 'ratio' points to UP edges usage) - if (!isHorizontalLayer && tile->y() >= 1) { - Tile* downTile - = tg_->tiles()[(tile->y() - 1) * tg_->tileCntX() + tile->x()]; - float downRatio = getUsageCapacityRatio( - downTile, layer, gGrid, rbVars_.ignoreEdgeRatio); - ratio = std::fmax(downRatio, ratio); - } + // first extract current tiles' usage + float ratio + = getUsageCapacityRatio(tile, layer, gGrid, rbVars_.ignoreEdgeRatio); - ratio = std::fmax(ratio, 0.0f); - } else { - ratio = 0.0; + // if horizontal layer (i.e., vertical edges) + // should consider LEFT tile's RIGHT edge == current 'tile's LEFT edge + // (current 'ratio' points to RIGHT edges usage) + if (isHorizontalLayer && tile->x() >= 1) { + Tile* leftTile + = tg_->tiles()[tile->y() * tg_->tileCntX() + tile->x() - 1]; + float leftRatio = getUsageCapacityRatio( + leftTile, layer, gGrid, rbVars_.ignoreEdgeRatio); + ratio = fmax(leftRatio, ratio); } + // if vertical layer (i.e., horizontal edges) + // should consider DOWN tile's UP edge == current 'tile's DOWN edge + // (current 'ratio' points to UP edges usage) + if (!isHorizontalLayer && tile->y() >= 1) { + Tile* downTile + = tg_->tiles()[(tile->y() - 1) * tg_->tileCntX() + tile->x()]; + float downRatio = getUsageCapacityRatio( + downTile, layer, gGrid, rbVars_.ignoreEdgeRatio); + ratio = fmax(downRatio, ratio); + } + + ratio = fmax(ratio, 0.0f); + // update inflation Ratio if (ratio >= rbVars_.minInflationRatio) { float inflationRatio = pow(ratio, rbVars_.inflationRatioCoef); @@ -773,8 +766,6 @@ float RouteBase::getRC() const odb::dbGCellGrid* gGrid = db_->getChip()->getBlock()->getGCellGrid(); for (auto& tile : tg_->tiles()) { - int min_routing_layer = grouter_->getMinRoutingLayer(); - int max_routing_layer = grouter_->getMaxRoutingLayer(); for (int i = 1; i <= tg_->numRoutingLayers(); i++) { odb::dbTechLayer* layer = db_->getTech()->findRoutingLayer(i); bool isHorizontalLayer @@ -783,9 +774,6 @@ float RouteBase::getRC() const // extract the ratio in the same way as inflation ratio cals float ratio = getUsageCapacityRatio(tile, layer, gGrid, rbVars_.ignoreEdgeRatio); - if (i < min_routing_layer || i > max_routing_layer) { - ratio = 0.0; - } // escape the case when blockageRatio is too huge if (ratio >= 0.0f) { diff --git a/src/grt/include/grt/GlobalRouter.h b/src/grt/include/grt/GlobalRouter.h index 7466353f04f..9c4422ce693 100644 --- a/src/grt/include/grt/GlobalRouter.h +++ b/src/grt/include/grt/GlobalRouter.h @@ -157,10 +157,7 @@ class GlobalRouter : public ant::GlobalRouteSource void setAdjustment(const float adjustment); void setMinRoutingLayer(const int min_layer); void setMaxRoutingLayer(const int max_layer); - int getMaxRoutingLayer() const - { - return std::max(max_routing_layer_, max_layer_for_clock_); - } + int getMaxRoutingLayer() const { return max_routing_layer_; } void setMinLayerForClock(const int min_layer); void setMaxLayerForClock(const int max_layer); void setCriticalNetsPercentage(float critical_nets_percentage); @@ -179,13 +176,7 @@ class GlobalRouter : public ant::GlobalRouteSource void setAllowCongestion(bool allow_congestion); void setMacroExtension(int macro_extension); void setPinOffset(int pin_offset); - int getMinRoutingLayer() const - { - int min_layer = min_layer_for_clock_ > 0 - ? std::min(min_routing_layer_, min_layer_for_clock_) - : min_routing_layer_; - return min_layer; - } + int getMinRoutingLayer() const { return min_routing_layer_; } // flow functions void readGuides(const char* file_name); diff --git a/src/grt/src/GlobalRouter.cpp b/src/grt/src/GlobalRouter.cpp index ce09a1d1ab9..996bc1336a3 100644 --- a/src/grt/src/GlobalRouter.cpp +++ b/src/grt/src/GlobalRouter.cpp @@ -270,7 +270,9 @@ void GlobalRouter::globalRoute(bool save_guides, max_routing_layer_ = computeMaxRoutingLayer(); } - int min_layer = getMinRoutingLayer(); + int min_layer = min_layer_for_clock_ > 0 + ? std::min(min_routing_layer_, min_layer_for_clock_) + : min_routing_layer_; int max_layer = std::max(max_routing_layer_, max_layer_for_clock_); std::vector nets = initFastRoute(min_layer, max_layer); @@ -322,9 +324,7 @@ void GlobalRouter::globalRoute(bool save_guides, void GlobalRouter::updateDbCongestion() { - int min_layer = getMinRoutingLayer(); - int max_layer = std::max(max_routing_layer_, max_layer_for_clock_); - fastroute_->updateDbCongestion(min_layer, max_layer); + fastroute_->updateDbCongestion(); heatmap_->update(); } @@ -1457,7 +1457,9 @@ void GlobalRouter::initGridAndNets() routes_.clear(); if (max_routing_layer_ == -1 || routing_layers_.empty()) { max_routing_layer_ = computeMaxRoutingLayer(); - int min_layer = getMinRoutingLayer(); + int min_layer = min_layer_for_clock_ > 0 + ? std::min(min_routing_layer_, min_layer_for_clock_) + : min_routing_layer_; int max_layer = std::max(max_routing_layer_, max_layer_for_clock_); initRoutingLayers(); @@ -3041,7 +3043,9 @@ void GlobalRouter::findLayerExtensions(std::vector& layer_extensions) { layer_extensions.resize(routing_layers_.size() + 1, 0); - int min_layer = getMinRoutingLayer(); + int min_layer = min_layer_for_clock_ > 0 + ? std::min(min_routing_layer_, min_layer_for_clock_) + : min_routing_layer_; int max_layer = std::max(max_routing_layer_, max_layer_for_clock_); for (auto const& [level, obstruct_layer] : routing_layers_) { diff --git a/src/grt/src/fastroute/include/FastRoute.h b/src/grt/src/fastroute/include/FastRoute.h index e6c7703f371..863dfe2212a 100644 --- a/src/grt/src/fastroute/include/FastRoute.h +++ b/src/grt/src/fastroute/include/FastRoute.h @@ -152,7 +152,7 @@ class FastRouteCore NetRouteMap run(); int totalOverflow() const { return total_overflow_; } bool has2Doverflow() const { return has_2D_overflow_; } - void updateDbCongestion(int min_routing_layer, int max_routing_layer); + void updateDbCongestion(); void findCongestedEdgesNets(NetsPerCongestedArea& nets_in_congested_edges, bool vertical); void getCongestionGrid(std::vector& congestionGridV, diff --git a/src/grt/src/fastroute/src/FastRoute.cpp b/src/grt/src/fastroute/src/FastRoute.cpp index 274355bf8aa..8c985b43b6c 100644 --- a/src/grt/src/fastroute/src/FastRoute.cpp +++ b/src/grt/src/fastroute/src/FastRoute.cpp @@ -806,8 +806,7 @@ NetRouteMap FastRouteCore::getPlanarRoutes() return routes; } -void FastRouteCore::updateDbCongestion(int min_routing_layer, - int max_routing_layer) +void FastRouteCore::updateDbCongestion() { auto block = db_->getChip()->getBlock(); auto db_gcell = block->getGCellGrid(); @@ -819,8 +818,8 @@ void FastRouteCore::updateDbCongestion(int min_routing_layer, db_gcell->addGridPatternX(x_corner_, x_grid_, tile_size_); db_gcell->addGridPatternY(y_corner_, y_grid_, tile_size_); auto db_tech = db_->getTech(); - for (int k = min_routing_layer - 1; k < max_routing_layer - 1; k++) { - auto layer = db_tech->findRoutingLayer(k); + for (int k = 0; k < num_layers_; k++) { + auto layer = db_tech->findRoutingLayer(k + 1); if (layer == nullptr) { continue; }