diff --git a/src/grt/include/grt/GlobalRouter.h b/src/grt/include/grt/GlobalRouter.h index 147a6f74be8..1b5a49c700e 100644 --- a/src/grt/include/grt/GlobalRouter.h +++ b/src/grt/include/grt/GlobalRouter.h @@ -351,7 +351,7 @@ class GlobalRouter int track_count, bool horizontal); odb::Rect getGCellRect(int x, int y); - void initNetlist(std::vector& nets); + void initNetlist(std::vector& nets, bool incremental = false); void makeFastrouteNet(Net* net); bool pinPositionsChanged(Net* net); bool newPinOnGrid(Net* net, std::multiset& last_pos); @@ -375,7 +375,7 @@ class GlobalRouter void savePositionWithReducedResources(const odb::Rect& rect, odb::dbTechLayer* tech_layer, odb::dbNet* db_net); - void addResourcesForPinAccess(); + void addResourcesForPinAccess(const std::vector& nets); bool isPinReachable(const Pin& pin, const odb::Point& pos_on_grid); int computeNetWirelength(odb::dbNet* db_net); void computeWirelength(); @@ -529,6 +529,7 @@ class GlobalRouter bool is_congested_{false}; bool use_cugr_{false}; int skip_large_fanout_{std::numeric_limits::max()}; + bool has_macros_or_pads_{false}; // Region adjustment variables std::vector region_adjustments_; diff --git a/src/grt/src/GlobalRouter.cpp b/src/grt/src/GlobalRouter.cpp index ba6b62a6ca0..1a03b5242cf 100644 --- a/src/grt/src/GlobalRouter.cpp +++ b/src/grt/src/GlobalRouter.cpp @@ -1303,7 +1303,7 @@ float GlobalRouter::getNetSlack(Net* net) return slack; } -void GlobalRouter::initNetlist(std::vector& nets) +void GlobalRouter::initNetlist(std::vector& nets, bool incremental) { pad_pins_connections_.clear(); @@ -1343,9 +1343,12 @@ void GlobalRouter::initNetlist(std::vector& nets) logger_->info(GRT, 2, "Maximum degree: {}", max_degree); } - // add resources for pin access in macro/pad pins after defining their on grid - // position - addResourcesForPinAccess(); + // Add resources for pin access in macro/pad pins after defining their on grid + // position. It must be done only in the initialization of the tool, not + // during incremental. + if (has_macros_or_pads_ && !incremental) { + addResourcesForPinAccess(nets); + } fastroute_->initAuxVar(); } @@ -1925,49 +1928,51 @@ void GlobalRouter::applyObstructionAdjustment(const odb::Rect& obstruction, // This function adds the resources necessary to route these pins. Only pins in // the east and north edges are affected because FastRoute routes from left to // right, and bottom to top. -void GlobalRouter::addResourcesForPinAccess() +void GlobalRouter::addResourcesForPinAccess(const std::vector& nets) { odb::dbTech* tech = db_->getTech(); - for (const auto& [db_net, net] : db_net_map_) { - for (const Pin& pin : net->getPins()) { - if (pin.isConnectedToPadOrMacro() && (pin.getEdge() != PinEdge::none)) { - const odb::Point& pos = pin.getOnGridPosition(); - int pin_x = ((pos.x() - grid_->getXMin()) / grid_->getTileSize()); - int pin_y = ((pos.y() - grid_->getYMin()) / grid_->getTileSize()); - const int layer = pin.getConnectionLayer(); - odb::dbTechLayer* tech_layer = tech->findRoutingLayer(layer); - if (tech_layer->getDirection() == odb::dbTechLayerDir::VERTICAL) { - const bool north_pin = pin.getEdge() == PinEdge::north; - const int pin_y1 = north_pin ? pin_y : pin_y - 1; - const int pin_y2 = north_pin ? pin_y + 1 : pin_y; - - // Ensure we do not go out of bounds when the pin is at the edge of - // the grid. If the pin is on the south edge and at y=0, there is no - // room for adding resources. - if (pin_y1 < 0) { - continue; - } + for (const auto& net : nets) { + if (net->isConnectedToPadOrMacro()) { + for (const Pin& pin : net->getPins()) { + if (pin.isConnectedToPadOrMacro() && (pin.getEdge() != PinEdge::none)) { + const odb::Point& pos = pin.getOnGridPosition(); + int pin_x = ((pos.x() - grid_->getXMin()) / grid_->getTileSize()); + int pin_y = ((pos.y() - grid_->getYMin()) / grid_->getTileSize()); + const int layer = pin.getConnectionLayer(); + odb::dbTechLayer* tech_layer = tech->findRoutingLayer(layer); + if (tech_layer->getDirection() == odb::dbTechLayerDir::VERTICAL) { + const bool north_pin = pin.getEdge() == PinEdge::north; + const int pin_y1 = north_pin ? pin_y : pin_y - 1; + const int pin_y2 = north_pin ? pin_y + 1 : pin_y; + + // Ensure we do not go out of bounds when the pin is at the edge of + // the grid. If the pin is on the south edge and at y=0, there is no + // room for adding resources. + if (pin_y1 < 0) { + continue; + } - const int edge_cap = fastroute_->getEdgeCapacity( - pin_x, pin_y1, pin_x, pin_y2, layer); - fastroute_->addAdjustment( - pin_x, pin_y1, pin_x, pin_y2, layer, edge_cap + 1, false); - } else { - const bool east_pin = pin.getEdge() == PinEdge::east; - const int pin_x1 = east_pin ? pin_x : pin_x - 1; - const int pin_x2 = east_pin ? pin_x + 1 : pin_x; - - // Ensure we do not go out of bounds when the pin is at the edge of - // the grid. If the pin is on the west edge and at x=0, there is no - // room for adding resources. - if (pin_x1 < 0) { - continue; - } + const int edge_cap = fastroute_->getEdgeCapacity( + pin_x, pin_y1, pin_x, pin_y2, layer); + fastroute_->addAdjustment( + pin_x, pin_y1, pin_x, pin_y2, layer, edge_cap + 1, false); + } else { + const bool east_pin = pin.getEdge() == PinEdge::east; + const int pin_x1 = east_pin ? pin_x : pin_x - 1; + const int pin_x2 = east_pin ? pin_x + 1 : pin_x; + + // Ensure we do not go out of bounds when the pin is at the edge of + // the grid. If the pin is on the west edge and at x=0, there is no + // room for adding resources. + if (pin_x1 < 0) { + continue; + } - const int edge_cap = fastroute_->getEdgeCapacity( - pin_x1, pin_y, pin_x2, pin_y, layer); - fastroute_->addAdjustment( - pin_x1, pin_y, pin_x2, pin_y, layer, edge_cap + 1, false); + const int edge_cap = fastroute_->getEdgeCapacity( + pin_x1, pin_y, pin_x2, pin_y, layer); + fastroute_->addAdjustment( + pin_x1, pin_y, pin_x2, pin_y, layer, edge_cap + 1, false); + } } } } @@ -4365,6 +4370,10 @@ void GlobalRouter::makeItermPins(Net* net, const bool connected_to_pad = type.isPad(); const bool connected_to_macro = master->isBlock(); + if (connected_to_pad || connected_to_macro) { + net->setIsConnectedToPadOrMacro(true); + } + odb::dbInst* inst = iterm->getInst(); if (!inst->isPlaced()) { logger_->error(GRT, 10, "Instance {} is not placed.", inst->getName()); @@ -4686,6 +4695,11 @@ int GlobalRouter::findInstancesObstructions( if (master->isBlock()) { macros_cnt++; is_macro = true; + has_macros_or_pads_ = true; + } + + if (master->getType().isPad()) { + has_macros_or_pads_ = true; } if (is_macro) { @@ -5827,7 +5841,7 @@ void GlobalRouter::getCongestionNets(std::set& congestion_nets) void GlobalRouter::initFastRouteIncr(std::vector& nets) { - initNetlist(nets); + initNetlist(nets, true); fastroute_->initAuxVar(); fastroute_->setIncrementalGrt(true); } diff --git a/src/grt/src/Net.cpp b/src/grt/src/Net.cpp index a3745e2267c..e887aa8e89b 100644 --- a/src/grt/src/Net.cpp +++ b/src/grt/src/Net.cpp @@ -26,7 +26,8 @@ Net::Net(odb::dbNet* net, bool has_wires) merged_net_(nullptr), is_merged_net_(false), is_dirty_net_(false), - is_clk_(false) + is_clk_(false), + is_connected_to_pad_or_macro_(false) { } diff --git a/src/grt/src/Net.h b/src/grt/src/Net.h index eeecd57667d..78ce8df4589 100644 --- a/src/grt/src/Net.h +++ b/src/grt/src/Net.h @@ -60,6 +60,11 @@ class Net bool isDirtyNet() const { return is_dirty_net_; } void setIsClockNet(bool is_clk) { is_clk_ = is_clk; } bool isClockNet() const { return is_clk_; } + void setIsConnectedToPadOrMacro(bool is_connected) + { + is_connected_to_pad_or_macro_ = is_connected; + } + bool isConnectedToPadOrMacro() const { return is_connected_to_pad_or_macro_; } private: int getNumBTermsAboveMaxLayer(odb::dbTechLayer* max_routing_layer); @@ -74,6 +79,7 @@ class Net bool is_merged_net_; bool is_dirty_net_; bool is_clk_; + bool is_connected_to_pad_or_macro_; }; } // namespace grt