Skip to content

Commit

Permalink
Merge branch 'master' into scandef
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Garay <fgaray@google.com>
  • Loading branch information
fgaray committed Jul 22, 2024
2 parents 973432d + 8f56dc4 commit 871e499
Show file tree
Hide file tree
Showing 27 changed files with 485 additions and 265 deletions.
7 changes: 5 additions & 2 deletions src/drt/src/dr/FlexDR.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ class FlexDRWorker
frBlockObject* block;
int numReroute;
bool doRoute;
frBlockObject* checkingObj;
};
frDesign* design_ = nullptr;
Logger* logger_ = nullptr;
Expand Down Expand Up @@ -737,7 +738,8 @@ class FlexDRWorker
std::set<frBlockObject*>& uniqueVictims,
std::set<frBlockObject*>& uniqueAggressors,
std::vector<RouteQueueEntry>& checks,
std::vector<RouteQueueEntry>& routes);
std::vector<RouteQueueEntry>& routes,
frBlockObject* checkingObj);
void getRipUpNetsFromMarker(frMarker* marker,
std::set<drNet*>& nets,
frCoord bloatDist = 0);
Expand All @@ -746,7 +748,8 @@ class FlexDRWorker
std::queue<RouteQueueEntry>& rerouteQueue);
void route_queue_update_queue(
const std::vector<std::unique_ptr<frMarker>>& markers,
std::queue<RouteQueueEntry>& rerouteQueue);
std::queue<RouteQueueEntry>& rerouteQueue,
frBlockObject* checkingObj = nullptr);
bool canRipup(drNet* n);
// route
void addPathCost(drConnFig* connFig,
Expand Down
58 changes: 40 additions & 18 deletions src/drt/src/dr/FlexDR_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2746,7 +2746,7 @@ void FlexDRWorker::route_queue_init_queue(
if (getRipupMode() == RipUpMode::DRC) {
for (auto& marker : markers_) {
route_queue_update_from_marker(
&marker, uniqueVictims, uniqueAggressors, checks, routes);
&marker, uniqueVictims, uniqueAggressors, checks, routes, nullptr);
}
mazeIterInit_sortRerouteQueue(0, checks);
mazeIterInit_sortRerouteQueue(0, routes);
Expand All @@ -2761,7 +2761,7 @@ void FlexDRWorker::route_queue_init_queue(
// sort nets
mazeIterInit_sortRerouteNets(0, ripupNets);
for (auto& net : ripupNets) {
routes.push_back({net, 0, true});
routes.push_back({net, 0, true, nullptr});
// reserve via because all nets are ripped up
initMazeCost_via_helper(net, true);
// no need to clear the net because route objs are not pushed to the net
Expand Down Expand Up @@ -2790,7 +2790,7 @@ void FlexDRWorker::route_queue_init_queue(
// sort nets
mazeIterInit_sortRerouteNets(0, ripupNets);
for (auto& net : ripupNets) {
routes.push_back({net, 0, true});
routes.push_back({net, 0, true, nullptr});
initMazeCost_via_helper(net, true);
}
} else if (getRipupMode() == RipUpMode::INCR) {
Expand All @@ -2804,7 +2804,7 @@ void FlexDRWorker::route_queue_init_queue(
// sort nets
mazeIterInit_sortRerouteNets(0, ripupNets);
for (auto& net : ripupNets) {
routes.push_back({net, 0, true});
routes.push_back({net, 0, true, nullptr});
// reserve via because all nets are ripped up
initMazeCost_via_helper(net, true);
// no need to clear the net because route objs are not pushed to the net
Expand Down Expand Up @@ -2840,7 +2840,8 @@ void FlexDRWorker::route_queue_update_from_marker(
std::set<frBlockObject*>& uniqueVictims,
std::set<frBlockObject*>& uniqueAggressors,
std::vector<RouteQueueEntry>& checks,
std::vector<RouteQueueEntry>& routes)
std::vector<RouteQueueEntry>& routes,
frBlockObject* checkingObj)
{
// if shapes don't overlap routeBox, ignore violation
if (!getRouteBox().intersects(marker->getBBox())) {
Expand Down Expand Up @@ -3002,7 +3003,7 @@ void FlexDRWorker::route_queue_update_from_marker(
allowAvoidRipup = true;
dNet->setNRipupAvoids(0);
}
routes.push_back({dNet, dNet->getNumReroutes(), true});
routes.push_back({dNet, dNet->getNumReroutes(), true, checkingObj});
}
}
}
Expand All @@ -3011,14 +3012,14 @@ void FlexDRWorker::route_queue_update_from_marker(
for (drNet* dNet : avoidRipupCandidates) {
if (allowAvoidRipup) {
dNet->incNRipupAvoids();
checks.push_back({dNet, -1, false});
checks.push_back({dNet, -1, false, checkingObj});
} else {
dNet->setNRipupAvoids(0);
routes.push_back({dNet, dNet->getNumReroutes(), true});
routes.push_back({dNet, dNet->getNumReroutes(), true, checkingObj});
}
}
for (auto& victimOwner : uniqueVictimOwners) {
checks.push_back({victimOwner, -1, false});
checks.push_back({victimOwner, -1, false, checkingObj});
}
}

Expand Down Expand Up @@ -3068,17 +3069,21 @@ bool FlexDRWorker::canRipup(drNet* n)

void FlexDRWorker::route_queue_update_queue(
const std::vector<std::unique_ptr<frMarker>>& markers,
std::queue<RouteQueueEntry>& rerouteQueue)
std::queue<RouteQueueEntry>& rerouteQueue,
frBlockObject* checkingObj)
{
std::set<frBlockObject*> uniqueVictims;
std::set<frBlockObject*> uniqueAggressors;
std::vector<RouteQueueEntry> checks;
std::vector<RouteQueueEntry> routes;

if (checkingObj != nullptr
&& checkingObj->typeId() == frBlockObjectEnum::drcNet) {
checkingObj = static_cast<drNet*>(checkingObj)->getFrNet();
}
for (auto& uMarker : markers) {
auto marker = uMarker.get();
route_queue_update_from_marker(
marker, uniqueVictims, uniqueAggressors, checks, routes);
marker, uniqueVictims, uniqueAggressors, checks, routes, checkingObj);
}

route_queue_update_queue(checks, routes, rerouteQueue);
Expand Down Expand Up @@ -3460,6 +3465,23 @@ void FlexDRWorker::initMazeCost_planarTerm(const frDesign* design)
// term no bloat
switch (obj->typeId()) {
case frcBTerm: {
auto bterm = static_cast<frBTerm*>(obj);
bool hasHorizontalAccess = false;
bool hasVerticalAccess = false;
for (const auto& pin : bterm->getPins()) {
for (int i = 0; i < pin->getNumPinAccess(); i++) {
const auto& pa = pin->getPinAccess(i);
for (const auto& ap : pa->getAccessPoints()) {
if (ap->getLayerNum() != layerNum) {
continue;
}
hasVerticalAccess |= ap->hasAccess(frDirEnum::N);
hasVerticalAccess |= ap->hasAccess(frDirEnum::S);
hasHorizontalAccess |= ap->hasAccess(frDirEnum::W);
hasHorizontalAccess |= ap->hasAccess(frDirEnum::E);
}
}
}
FlexMazeIdx mIdx1, mIdx2;
gridGraph_.getIdxBox(mIdx1, mIdx2, box);
const bool isLayerHorz = layer->isHorizontal();
Expand All @@ -3468,10 +3490,10 @@ void FlexDRWorker::initMazeCost_planarTerm(const frDesign* design)
FlexMazeIdx mIdx(i, j, zIdx);
gridGraph_.setBlocked(i, j, zIdx, frDirEnum::U);
gridGraph_.setBlocked(i, j, zIdx, frDirEnum::D);
if (isLayerHorz) {
if (isLayerHorz && hasHorizontalAccess) {
gridGraph_.setBlocked(i, j, zIdx, frDirEnum::N);
gridGraph_.setBlocked(i, j, zIdx, frDirEnum::S);
} else {
} else if (!isLayerHorz && hasVerticalAccess) {
gridGraph_.setBlocked(i, j, zIdx, frDirEnum::W);
gridGraph_.setBlocked(i, j, zIdx, frDirEnum::E);
}
Expand All @@ -3490,10 +3512,10 @@ void FlexDRWorker::initMazeCost_connFig()
{
for (auto& net : nets_) {
for (auto& connFig : net->getExtConnFigs()) {
addPathCost(connFig.get());
addPathCost(connFig.get(), false, true);
}
for (auto& connFig : net->getRouteConnFigs()) {
addPathCost(connFig.get());
addPathCost(connFig.get(), false, true);
}
gcWorker_->updateDRNet(net.get());
gcWorker_->updateGCWorker();
Expand Down Expand Up @@ -3548,9 +3570,9 @@ void FlexDRWorker::initMazeCost_via_helper(drNet* net, bool isAddPathCost)
via->addToNet(net);
initMazeIdx_connFig(via.get());
if (isAddPathCost) {
addPathCost(via.get(), true);
addPathCost(via.get(), true, true);
} else {
subPathCost(via.get(), true);
subPathCost(via.get(), true, true);
}
}
}
Expand Down
23 changes: 16 additions & 7 deletions src/drt/src/dr/FlexDR_maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ void FlexDRWorker::modPathCost(drConnFig* connFig,
box = rect->getBBox();
xform.apply(box);
if (modCutSpc) {
modCutSpacingCost(box, bi.z(), type);
modCutSpacingCost(box, bi.z(), type, false, bi.x(), bi.y());
}
modInterLayerCutSpacingCost(box, bi.z(), type, true);
modInterLayerCutSpacingCost(box, bi.z(), type, false);
Expand Down Expand Up @@ -1755,7 +1755,7 @@ void FlexDRWorker::identifyCongestionLevel()
void FlexDRWorker::route_queue_main(std::queue<RouteQueueEntry>& rerouteQueue)
{
int gc_version = 1;
std::map<frBlockObject*, int> obj_gc_version;
std::map<frBlockObject*, std::pair<int, int>> obj_gc_version;
auto& workerRegionQuery = getWorkerRegionQuery();
while (!rerouteQueue.empty()) {
auto& entry = rerouteQueue.front();
Expand All @@ -1772,6 +1772,14 @@ void FlexDRWorker::route_queue_main(std::queue<RouteQueueEntry>& rerouteQueue)
if (numReroute != net->getNumReroutes()) {
continue;
}
if (ripupMode_ == RipUpMode::DRC && entry.checkingObj != nullptr
&& obj_gc_version.find(net->getFrNet()) != obj_gc_version.end()
&& obj_gc_version.find(entry.checkingObj) != obj_gc_version.end()
&& obj_gc_version[net->getFrNet()] == std::make_pair(gc_version, 0)
&& obj_gc_version[entry.checkingObj]
== std::make_pair(gc_version, 0)) {
continue;
}
// init
net->setModified(true);
if (net->getFrNet()) {
Expand All @@ -1782,7 +1790,7 @@ void FlexDRWorker::route_queue_main(std::queue<RouteQueueEntry>& rerouteQueue)
graphics_->startNet(net);
}
for (auto& uConnFig : net->getRouteConnFigs()) {
subPathCost(uConnFig.get());
subPathCost(uConnFig.get(), false, true);
workerRegionQuery.remove(uConnFig.get()); // worker region query
}
modEolCosts_poly(gcWorker_->getNet(net->getFrNet()),
Expand Down Expand Up @@ -1890,18 +1898,18 @@ void FlexDRWorker::route_queue_main(std::queue<RouteQueueEntry>& rerouteQueue)
}
}
didCheck = true;
obj_gc_version[net->getFrNet()] = gc_version;
obj_gc_version[net->getFrNet()]
= {gc_version, gcWorker_->getMarkers().size()};

} else {
logger_->error(DRT, 1006, "failed to setTargetNet");
}
} else {
gcWorker_->setEnableSurgicalFix(false);
if (obj_gc_version.find(obj) != obj_gc_version.end()
&& obj_gc_version[obj] == gc_version) {
&& obj_gc_version[obj].first == gc_version) {
continue;
}
obj_gc_version[obj] = gc_version;
if (obj->typeId() == frcNet) {
auto net = static_cast<frNet*>(obj);
if (gcWorker_->setTargetNet(net)) {
Expand All @@ -1914,10 +1922,11 @@ void FlexDRWorker::route_queue_main(std::queue<RouteQueueEntry>& rerouteQueue)
didCheck = true;
}
}
obj_gc_version[obj] = {gc_version, gcWorker_->getMarkers().size()};
}
// end
if (didCheck) {
route_queue_update_queue(gcWorker_->getMarkers(), rerouteQueue);
route_queue_update_queue(gcWorker_->getMarkers(), rerouteQueue, obj);
}
if (didRoute) {
route_queue_markerCostDecay();
Expand Down
32 changes: 16 additions & 16 deletions src/drt/src/dr/FlexGridGraph_maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,31 +216,31 @@ frCost FlexGridGraph::getEstCost(const FlexMazeIdx& src,
// avoid propagating to location that will cause forbidden via spacing to
// boundary pin
bool isForbidden = false;
if (dstMazeIdx1 == dstMazeIdx2 && gridZ == dstMazeIdx1.z()) {
if (dstMazeIdx1.z() == dstMazeIdx2.z() && gridZ == dstMazeIdx1.z()) {
auto layerNum = (gridZ + 1) * 2;
auto layer = getTech()->getLayer(layerNum);
if (layer->isUnidirectional()) {
if (!USENONPREFTRACKS || layer->isUnidirectional()) {
bool isH = (layer->getDir() == dbTechLayerDir::HORIZONTAL);
if (isH) {
if (isH && dstMazeIdx1.y() == dstMazeIdx2.y()) {
auto gap = abs(nextPoint.y() - dstPoint1.y());
if (gap
&& (getTech()->isVia2ViaForbiddenLen(
gridZ, false, false, false, gap, ndr_)
|| layerNum - 2 < BOTTOM_ROUTING_LAYER)
&& (getTech()->isVia2ViaForbiddenLen(
gridZ, true, true, false, gap, ndr_)
|| layerNum + 2 > getTech()->getTopLayerNum())) {
&& (layerNum - 2 < BOTTOM_ROUTING_LAYER
|| getTech()->isVia2ViaForbiddenLen(
gridZ - 1, false, false, false, gap, ndr_))
&& (layerNum + 2 > getTech()->getTopLayerNum()
|| getTech()->isVia2ViaForbiddenLen(
gridZ + 1, true, true, false, gap, ndr_))) {
isForbidden = true;
}
} else {
} else if (!isH && dstMazeIdx1.x() == dstMazeIdx2.x()) {
auto gap = abs(nextPoint.x() - dstPoint1.x());
if (gap
&& (getTech()->isVia2ViaForbiddenLen(
gridZ, false, false, true, gap, ndr_)
|| layerNum - 2 < BOTTOM_ROUTING_LAYER)
&& (getTech()->isVia2ViaForbiddenLen(
gridZ, true, true, true, gap, ndr_)
|| layerNum + 2 > getTech()->getTopLayerNum())) {
&& (layerNum - 2 < BOTTOM_ROUTING_LAYER
|| getTech()->isVia2ViaForbiddenLen(
gridZ - 1, false, false, true, gap, ndr_))
&& (layerNum + 2 > getTech()->getTopLayerNum()
|| getTech()->isVia2ViaForbiddenLen(
gridZ + 1, true, true, true, gap, ndr_))) {
isForbidden = true;
}
}
Expand Down
Loading

0 comments on commit 871e499

Please sign in to comment.