Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 77 additions & 89 deletions src/drt/src/dr/FlexDR_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1913,53 +1913,52 @@ void FlexDRWorker::initMazeCost_ap_planarGrid_helper(const FlexMazeIdx& mi,

void FlexDRWorker::initMazeCost_ap_helper(drNet* net, const bool isAddPathCost)
{
const int planarGridBloatNumWidth = 10;
const int planar_grid_bloat_num_width = 10;
for (auto& pin : net->getPins()) {
bool isStdCellPin = true;
auto term = pin->getFrTerm();
if (term) {
switch (term->typeId()) {
case frcInstTerm: { // macro cell or stdcell
const odb::dbMasterType masterType = static_cast<frInstTerm*>(term)
->getInst()
->getMaster()
->getMasterType();
if (masterType.isBlock() || masterType.isPad()
|| masterType == odb::dbMasterType::RING) {
isStdCellPin = false;
}
break;
}
case frcBTerm: { // IO
if (!term) {
continue;
}

switch (term->typeId()) {
case frcInstTerm: { // macro cell or stdcell
const odb::dbMasterType masterType = static_cast<frInstTerm*>(term)
->getInst()
->getMaster()
->getMasterType();
if (masterType.isBlock() || masterType.isPad()
|| masterType == odb::dbMasterType::RING) {
isStdCellPin = false;
break;
}
default:
break;
break;
}
} else {
continue;
case frcBTerm: { // IO
isStdCellPin = false;
break;
}
default:
break;
}

bool hasUpperOnTrackAP = false;
if (isStdCellPin) {
for (auto& ap : pin->getAccessPatterns()) {
const frLayerNum lNum = ap->getBeginLayerNum();
if (ap->hasValidAccess(frDirEnum::U)) {
if (lNum + 2 > getTech()->getTopLayerNum()) {
continue;
}
if (getTech()->getLayer(lNum + 2)->isHorizontal()
&& ap->isOnTrack(true)) {
hasUpperOnTrackAP = true;
break;
}
if (getTech()->getLayer(lNum + 2)->getDir()
== dbTechLayerDir::VERTICAL
&& ap->isOnTrack(false)) {
hasUpperOnTrackAP = true;
break;
}
if (!ap->hasValidAccess(frDirEnum::U)) {
continue;
}
if (lNum + 2 > getTech()->getTopLayerNum()) {
continue;
}
const frLayer* upper_layer = getTech()->getLayer(lNum + 2);
if (upper_layer->isHorizontal() && ap->isOnTrack(true)) {
hasUpperOnTrackAP = true;
break;
}
if (upper_layer->isVertical() && ap->isOnTrack(false)) {
hasUpperOnTrackAP = true;
break;
}
}
}
Expand All @@ -1968,59 +1967,48 @@ void FlexDRWorker::initMazeCost_ap_helper(drNet* net, const bool isAddPathCost)
const FlexMazeIdx mi = ap->getMazeIdx();
const frLayerNum lNum = ap->getBeginLayerNum();
const frCoord defaultWidth = getTech()->getLayer(lNum)->getWidth();
if (ap->hasValidAccess(frDirEnum::U)) {
if (lNum + 2 <= getTech()->getTopLayerNum()) {
const auto upperDefaultWidth
= getTech()->getLayer(lNum + 2)->getWidth();
if (getTech()->getLayer(lNum + 2)->getDir()
== dbTechLayerDir::HORIZONTAL
&& !ap->isOnTrack(true)) {
if (!hasUpperOnTrackAP) {
const auto upperMi = FlexMazeIdx(mi.x(), mi.y(), mi.z() + 1);
initMazeCost_ap_planarGrid_helper(
upperMi,
frDirEnum::W,
planarGridBloatNumWidth * upperDefaultWidth,
isAddPathCost);
initMazeCost_ap_planarGrid_helper(
upperMi,
frDirEnum::E,
planarGridBloatNumWidth * upperDefaultWidth,
isAddPathCost);
}
}
if (getTech()->getLayer(lNum + 2)->getDir()
== dbTechLayerDir::VERTICAL
&& !ap->isOnTrack(false)) {
if (!hasUpperOnTrackAP) {
const auto upperMi = FlexMazeIdx(mi.x(), mi.y(), mi.z() + 1);
initMazeCost_ap_planarGrid_helper(
upperMi,
frDirEnum::N,
planarGridBloatNumWidth * upperDefaultWidth,
isAddPathCost);
initMazeCost_ap_planarGrid_helper(
upperMi,
frDirEnum::S,
planarGridBloatNumWidth * upperDefaultWidth,
isAddPathCost);
}
}
}

if (isAddPathCost) {
gridGraph_.resetOverrideShapeCostVia(mi.x(), mi.y(), mi.z());
} else {
gridGraph_.setOverrideShapeCostVia(mi.x(), mi.y(), mi.z());
}
}

if (!isStdCellPin) {
for (const auto dir : frDirEnumPlanar) {
initMazeCost_ap_planarGrid_helper(
mi, dir, planarGridBloatNumWidth * defaultWidth, isAddPathCost);
mi,
dir,
planar_grid_bloat_num_width * defaultWidth,
isAddPathCost);
}
}

if (!ap->hasValidAccess(frDirEnum::U)) {
continue;
}

if (isAddPathCost) {
gridGraph_.resetOverrideShapeCostVia(mi.x(), mi.y(), mi.z());
} else {
gridGraph_.setOverrideShapeCostVia(mi.x(), mi.y(), mi.z());
}

if (lNum + 2 > getTech()->getTopLayerNum() || hasUpperOnTrackAP) {
continue;
}

const frLayer* upper_layer = getTech()->getLayer(lNum + 2);
const int planar_grid_bloat
= planar_grid_bloat_num_width * upper_layer->getWidth();
const auto upperMi = FlexMazeIdx(mi.x(), mi.y(), mi.z() + 1);

if (upper_layer->isHorizontal() && !ap->isOnTrack(true)) {
initMazeCost_ap_planarGrid_helper(
upperMi, frDirEnum::W, planar_grid_bloat, isAddPathCost);
initMazeCost_ap_planarGrid_helper(
upperMi, frDirEnum::E, planar_grid_bloat, isAddPathCost);
}
if (upper_layer->isVertical() && !ap->isOnTrack(false)) {
initMazeCost_ap_planarGrid_helper(
upperMi, frDirEnum::N, planar_grid_bloat, isAddPathCost);
initMazeCost_ap_planarGrid_helper(
upperMi, frDirEnum::S, planar_grid_bloat, isAddPathCost);
}
}
}
}
Expand Down Expand Up @@ -2070,8 +2058,8 @@ void FlexDRWorker::initMazeCost_marker_route_queue_addHistoryCost(
continue;
}
// add history cost
// get points to mark up, markup up to "width" grid points to the left and
// right of pathseg
// get points to mark up, markup up to "width" grid points to the left
// and right of pathseg
const frSegStyle segStyle = obj->getStyle();
const frCoord width = segStyle.getWidth();
odb::Rect bloatBox;
Expand All @@ -2086,9 +2074,9 @@ void FlexDRWorker::initMazeCost_marker_route_queue_addHistoryCost(
// the startpoint is
for (int i = 0; i < 5; i++) {
if (i == 4) {
std::cout
<< "Warning: marker bloat 4x width but could not find two grids "
"to add marker cost\n";
std::cout << "Warning: marker bloat 4x width but could not find "
"two grids "
"to add marker cost\n";
Comment on lines +2077 to +2079
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Unexpected failures during the routing flow, such as failing to find grids to add marker cost, should be logged as an error instead of a warning. This ensures that critical failure messages are not missed by the user. Additionally, avoid manual formatting changes and rely on the logger's standard output.

Suggested change
std::cout << "Warning: marker bloat 4x width but could not find "
"two grids "
"to add marker cost\n";
logger->error(utl::DRT, 1000, "marker bloat 4x width but could not find two grids to add marker cost");
References
  1. Unexpected failures during the routing flow, such as failing to generate a Steiner tree, should be logged as an error, not a warning. This ensures the end user does not miss critical failure messages.
  2. Rely on clang-format for code formatting instead of applying manual style changes.

Copy link
Copy Markdown
Contributor

@bnmfw bnmfw Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maliberty I sometimes find these kinds of "internal DRT errors" which look obsolete/legacy to me, should we transform them into actual error or get rid of them?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transform them unless you are certain they can't happen.

std::cout << " marker -- src: ";
for (auto src : marker.getSrcs()) {
if (src) {
Expand Down Expand Up @@ -2392,8 +2380,8 @@ void FlexDRWorker::route_queue_update_queue(
}

//*****************************************************************************************//
// EXPONENTIAL QUEUE SIZE IF NOT MAKE AGGRESSORS AND VICTIMS UNIQUE FOR A SET OF
// MARKERS!! // NET A --> PUSH ROUTE A --> PUSH CHECK A * 3 --> //
// EXPONENTIAL QUEUE SIZE IF NOT MAKE AGGRESSORS AND VICTIMS UNIQUE FOR A SET
// OF MARKERS!! // NET A --> PUSH ROUTE A --> PUSH CHECK A * 3 --> //
// | | //
// ---------------------------------------- //
//*****************************************************************************************//
Expand Down
27 changes: 5 additions & 22 deletions src/drt/src/dr/FlexGridGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class FlexGridGraph
}
}
} else {
correctU(x, y, z, dir);
correct(x, y, z, dir);
const Node& node = nodes_[getIdx(x, y, z)];
if (isOverrideShapeCost(x, y, z, dir)) {
sol = 0;
Expand All @@ -305,7 +305,7 @@ class FlexGridGraph
if (dir != frDirEnum::D && dir != frDirEnum::U) {
return false;
}
correctU(x, y, z, dir);
correct(x, y, z, dir);
auto idx = getIdx(x, y, z);
return nodes_[idx].overrideShapeCostVia;
}
Expand All @@ -327,7 +327,7 @@ class FlexGridGraph
sol = nodes_[idx].routeShapeCostPlanar;
}
} else {
correctU(x, y, z, dir);
correct(x, y, z, dir);
auto idx = getIdx(x, y, z);
if (consider_ndr) {
sol = std::max(nodes_[idx].routeShapeCostVia,
Expand Down Expand Up @@ -356,7 +356,7 @@ class FlexGridGraph
auto idx = getIdx(x, y, z);
sol += nodes_[idx].markerCostPlanar;
} else {
correctU(x, y, z, dir);
correct(x, y, z, dir);
auto idx = getIdx(x, y, z);
sol += nodes_[idx].markerCostVia;
}
Expand Down Expand Up @@ -1165,26 +1165,9 @@ class FlexGridGraph
{
switch (dir) {
case frDirEnum::W:
x--;
dir = frDirEnum::E;
break;
case frDirEnum::S:
y--;
dir = frDirEnum::N;
break;
case frDirEnum::D:
z--;
dir = frDirEnum::U;
break;
default:;
}
}
void correctU(frMIdx& x, frMIdx& y, frMIdx& z, frDirEnum& dir) const
{
switch (dir) {
case frDirEnum::D:
z--;
dir = frDirEnum::U;
reverse(x, y, z, dir);
break;
default:;
}
Expand Down
Loading