Skip to content

Commit 42457f2

Browse files
Merge pull request #10654 from VLSIDA/drt-gridgraph-routing-layer-opt
2 parents b27e32e + 0fe62b1 commit 42457f2

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

src/drt/src/dr/FlexDR_init.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,13 +2722,25 @@ void FlexDRWorker::initMazeCost_fixedObj(const frDesign* design)
27222722
result.clear();
27232723
if (getTech()->getLayer(layerNum)->getType() == dbTechLayerType::ROUTING) {
27242724
isRoutingLayer = true;
2725+
// The grid graph need not span the full layer stack: TOP_ROUTING_LAYER
2726+
// can trim routing layers above it out of the grid. Skip fixed-shape
2727+
// costing on layers absent from the grid so getMazeZIdx / getLayerNum
2728+
// stay in range. No-op when the grid spans every routing layer.
2729+
if (layerNum < gridGraph_.getMinLayerNum()
2730+
|| layerNum > gridGraph_.getMaxLayerNum()) {
2731+
continue;
2732+
}
27252733
zIdx = gridGraph_.getMazeZIdx(layerNum);
27262734
} else if (getTech()->getLayer(layerNum)->getType()
27272735
== dbTechLayerType::CUT) {
27282736
isRoutingLayer = false;
27292737
if (getTech()->getBottomLayerNum() <= layerNum - 1
27302738
&& getTech()->getLayer(layerNum - 1)->getType()
27312739
== dbTechLayerType::ROUTING) {
2740+
if (layerNum - 1 < gridGraph_.getMinLayerNum()
2741+
|| layerNum - 1 > gridGraph_.getMaxLayerNum()) {
2742+
continue;
2743+
}
27322744
zIdx = gridGraph_.getMazeZIdx(layerNum - 1);
27332745
} else {
27342746
continue;
@@ -2894,13 +2906,23 @@ void FlexDRWorker::initMazeCost_terms(
28942906
if (getTech()->getLayer(layerNum)->getType()
28952907
== dbTechLayerType::ROUTING) {
28962908
isRoutingLayer = true;
2909+
// Grid may not span the full stack (TOP_ROUTING_LAYER trim);
2910+
// skip layers absent from the grid. No-op when fully spanned.
2911+
if (layerNum < gridGraph_.getMinLayerNum()
2912+
|| layerNum > gridGraph_.getMaxLayerNum()) {
2913+
continue;
2914+
}
28972915
zIdx = gridGraph_.getMazeZIdx(layerNum);
28982916
} else if (getTech()->getLayer(layerNum)->getType()
28992917
== dbTechLayerType::CUT) {
29002918
isRoutingLayer = false;
29012919
if (getTech()->getBottomLayerNum() <= layerNum - 1
29022920
&& getTech()->getLayer(layerNum - 1)->getType()
29032921
== dbTechLayerType::ROUTING) {
2922+
if (layerNum - 1 < gridGraph_.getMinLayerNum()
2923+
|| layerNum - 1 > gridGraph_.getMaxLayerNum()) {
2924+
continue;
2925+
}
29042926
zIdx = gridGraph_.getMazeZIdx(layerNum - 1);
29052927
} else {
29062928
continue;
@@ -2971,13 +2993,23 @@ void FlexDRWorker::initMazeCost_terms(
29712993
if (getTech()->getLayer(layerNum)->getType()
29722994
== dbTechLayerType::ROUTING) {
29732995
isRoutingLayer = true;
2996+
// Grid may not span the full stack (TOP_ROUTING_LAYER trim);
2997+
// skip layers absent from the grid. No-op when fully spanned.
2998+
if (layerNum < gridGraph_.getMinLayerNum()
2999+
|| layerNum > gridGraph_.getMaxLayerNum()) {
3000+
continue;
3001+
}
29743002
zIdx = gridGraph_.getMazeZIdx(layerNum);
29753003
} else if (getTech()->getLayer(layerNum)->getType()
29763004
== dbTechLayerType::CUT) {
29773005
isRoutingLayer = false;
29783006
if (getTech()->getBottomLayerNum() <= layerNum - 1
29793007
&& getTech()->getLayer(layerNum - 1)->getType()
29803008
== dbTechLayerType::ROUTING) {
3009+
if (layerNum - 1 < gridGraph_.getMinLayerNum()
3010+
|| layerNum - 1 > gridGraph_.getMaxLayerNum()) {
3011+
continue;
3012+
}
29813013
zIdx = gridGraph_.getMazeZIdx(layerNum - 1);
29823014
} else {
29833015
continue;

src/drt/src/dr/FlexGridGraph.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,17 @@ void FlexGridGraph::initTracks(
471471
continue;
472472
}
473473
frLayerNum currLayerNum = layer->getLayerNum();
474+
// Layers above TOP_ROUTING_LAYER carry no routing edges or access vias
475+
// (initEdges and the special-access via loop already cap work at
476+
// TOP_ROUTING_LAYER), yet they were still added to the grid here, sizing
477+
// nodes_, the per-node arrays, and the maze search bounds across the full
478+
// layer stack. Skip them so the grid graph spans only the routing range,
479+
// cutting detailed-route memory and runtime when the design's top routing
480+
// layer is below the technology top. Default TOP_ROUTING_LAYER is INT_MAX,
481+
// so this is a no-op unless the top routing layer is explicitly lowered.
482+
if (currLayerNum > router_cfg_->TOP_ROUTING_LAYER) {
483+
continue;
484+
}
474485
dbTechLayerDir currPrefRouteDir = layer->getDir();
475486
for (auto& tp : design->getTopBlock()->getTrackPatterns(currLayerNum)) {
476487
// allow wrongway if global variable and design rule allow

0 commit comments

Comments
 (0)