Skip to content

Commit 0fe62b1

Browse files
committed
drt: limit detailed-route grid graph to the routing-layer range
FlexGridGraph::initTracks() added every routing layer in the tech to the grid, sizing nodes_, the per-node arrays (prevDirs_/srcs_/dsts_/guides_), and the maze search bounds across the full layer stack. Routing edges and access vias are already capped at TOP_ROUTING_LAYER, so layers above it were dead weight. Skip routing layers above TOP_ROUTING_LAYER so the grid graph spans only the routing range. Default TOP_ROUTING_LAYER is INT_MAX, so this is a no-op unless the top routing layer is explicitly lowered. Once the grid is trimmed it no longer spans the full layer stack, so maze-cost init must not assume every tech layer maps to a grid node. initMazeCost_fixedObj and initMazeCost_terms looped over the whole stack and called getMazeZIdx(layerNum) for routing layers above TOP_ROUTING_LAYER, returning an out-of-range z that the cost path dereferenced (getLayerNum -> zCoords_[z]), crashing on platforms with fixed shapes or instance pins above the top routing layer (e.g. ihp-sg13g2, with PDN and sg13g2_io pins on TopMetal above Metal5). Guard both so fixed-shape costing skips layers outside the grid's [getMinLayerNum, getMaxLayerNum] span. The skip is before any cost call, and is a no-op when the grid spans every routing layer. (The setBlocked/setGuide paths in initMazeCost_planarTerm, modBlockedEdgesForMacroPin and the guide helper are already bounds-checked, so they need no change.) Verified: - gt2n gcd: at the tech-top layer the routed DB is bit-identical to before (true no-op); with the top routing layer lowered to M5, detailed-route wall time dropped ~10% and peak memory ~14%, 0 DRC. - ihp-sg13g2 gcd (fixedObj) and i2c-gpio-expander (terms) crashed before the guard and route DRC-clean after it. Signed-off-by: mrg <mrg@ucsc.edu>
1 parent 065077a commit 0fe62b1

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)