From 04c5ae0d30ef2affa2b2b6f9b507fb3eda79741a Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Fri, 20 Feb 2026 11:00:12 -0300 Subject: [PATCH 1/4] grt: update addResourcesForPinAccess to iterate only a subset of nets Signed-off-by: Eder Monteiro --- src/grt/include/grt/GlobalRouter.h | 2 +- src/grt/src/GlobalRouter.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/grt/include/grt/GlobalRouter.h b/src/grt/include/grt/GlobalRouter.h index a25524a11cf..204487e406b 100644 --- a/src/grt/include/grt/GlobalRouter.h +++ b/src/grt/include/grt/GlobalRouter.h @@ -373,7 +373,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(); diff --git a/src/grt/src/GlobalRouter.cpp b/src/grt/src/GlobalRouter.cpp index b57d47085e2..46cd4bd7aae 100644 --- a/src/grt/src/GlobalRouter.cpp +++ b/src/grt/src/GlobalRouter.cpp @@ -1337,7 +1337,7 @@ void GlobalRouter::initNetlist(std::vector& nets) // add resources for pin access in macro/pad pins after defining their on grid // position - addResourcesForPinAccess(); + addResourcesForPinAccess(nets); fastroute_->initAuxVar(); } @@ -1917,10 +1917,10 @@ 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 auto& net : nets) { for (const Pin& pin : net->getPins()) { if (pin.isConnectedToPadOrMacro() && (pin.getEdge() != PinEdge::none)) { const odb::Point& pos = pin.getOnGridPosition(); From 8aee38e241dc92355213ccf04d8749767f2c07f3 Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Fri, 20 Feb 2026 11:04:11 -0300 Subject: [PATCH 2/4] grt: check if design has macros/pads before calling addResourcesForPinAccess Signed-off-by: Eder Monteiro --- src/grt/include/grt/GlobalRouter.h | 1 + src/grt/src/GlobalRouter.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/grt/include/grt/GlobalRouter.h b/src/grt/include/grt/GlobalRouter.h index 204487e406b..b635833759e 100644 --- a/src/grt/include/grt/GlobalRouter.h +++ b/src/grt/include/grt/GlobalRouter.h @@ -527,6 +527,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 46cd4bd7aae..a93add77611 100644 --- a/src/grt/src/GlobalRouter.cpp +++ b/src/grt/src/GlobalRouter.cpp @@ -1337,7 +1337,9 @@ void GlobalRouter::initNetlist(std::vector& nets) // add resources for pin access in macro/pad pins after defining their on grid // position - addResourcesForPinAccess(nets); + if (has_macros_or_pads_) { + addResourcesForPinAccess(nets); + } fastroute_->initAuxVar(); } @@ -4678,6 +4680,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) { From 09f16990f662d522b51094a6c3085c25f3ade024 Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Fri, 20 Feb 2026 11:30:08 -0300 Subject: [PATCH 3/4] grt: avoid adding resources for pin access during incremental iterations Signed-off-by: Eder Monteiro --- src/grt/include/grt/GlobalRouter.h | 2 +- src/grt/src/GlobalRouter.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/grt/include/grt/GlobalRouter.h b/src/grt/include/grt/GlobalRouter.h index b635833759e..6fd5c0734ae 100644 --- a/src/grt/include/grt/GlobalRouter.h +++ b/src/grt/include/grt/GlobalRouter.h @@ -349,7 +349,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); diff --git a/src/grt/src/GlobalRouter.cpp b/src/grt/src/GlobalRouter.cpp index a93add77611..ab94040e0a7 100644 --- a/src/grt/src/GlobalRouter.cpp +++ b/src/grt/src/GlobalRouter.cpp @@ -1295,7 +1295,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(); @@ -1335,9 +1335,10 @@ 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 - if (has_macros_or_pads_) { + // 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(); @@ -5826,7 +5827,7 @@ void GlobalRouter::getCongestionNets(std::set& congestion_nets) void GlobalRouter::initFastRouteIncr(std::vector& nets) { - initNetlist(nets); + initNetlist(nets, true); fastroute_->initAuxVar(); fastroute_->setIncrementalGrt(true); } From 8f6a061cc376d162368cd393d82fdf244115a42f Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Fri, 20 Feb 2026 14:10:35 -0300 Subject: [PATCH 4/4] grt: check if net is connected to pad or macro before iterating its pins Signed-off-by: Eder Monteiro --- src/grt/src/GlobalRouter.cpp | 80 +++++++++++++++++++----------------- src/grt/src/Net.cpp | 3 +- src/grt/src/Net.h | 6 +++ 3 files changed, 51 insertions(+), 38 deletions(-) diff --git a/src/grt/src/GlobalRouter.cpp b/src/grt/src/GlobalRouter.cpp index ab94040e0a7..0bc11b8cfa5 100644 --- a/src/grt/src/GlobalRouter.cpp +++ b/src/grt/src/GlobalRouter.cpp @@ -1924,45 +1924,47 @@ void GlobalRouter::addResourcesForPinAccess(const std::vector& nets) { odb::dbTech* tech = db_->getTech(); for (const auto& net : nets) { - 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; - } + 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); + } } } } @@ -4360,6 +4362,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()); 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