Skip to content

Commit

Permalink
Merge pull request #6138 from luis201420/drt_jumper_insertion
Browse files Browse the repository at this point in the history
Jumper insertion: modifications in DRT and ODB
  • Loading branch information
eder-matheus authored Nov 29, 2024
2 parents ecade09 + 24d1bf5 commit 0b348c1
Show file tree
Hide file tree
Showing 31 changed files with 601 additions and 333 deletions.
5 changes: 5 additions & 0 deletions src/drt/src/db/obj/frNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ class frNet : public frBlockObject
orig_guides_ = guides;
}
const std::vector<frRect>& getOrigGuides() const { return orig_guides_; }
void setHasJumpers(bool has_jumpers) { has_jumpers_ = has_jumpers; }
bool hasJumpers() { return has_jumpers_; }

protected:
frString name_;
Expand Down Expand Up @@ -276,6 +278,9 @@ class frNet : public frBlockObject
bool hasInitialRouting_{false};
bool isFixed_{false};

// Flag to mark when a frNet has a jumper, which is a special route guide used
// to prevent antenna violations
bool has_jumpers_{false};
std::vector<frPinFig*> all_pinfigs_;
};
} // namespace drt
2 changes: 1 addition & 1 deletion src/drt/src/dr/FlexDR_graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ gui::Descriptor::Properties GridGraphDescriptor::getProperties(
costs.push_back(
{name + " total cost",
graph->getCosts(
x, y, z, dir, layer, data.graph->getNDR() != nullptr)});
x, y, z, dir, layer, data.graph->getNDR() != nullptr, false)});
}
props.insert(props.end(), costs.begin(), costs.end());
return props;
Expand Down
6 changes: 5 additions & 1 deletion src/drt/src/dr/FlexDR_maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3223,6 +3223,9 @@ bool FlexDRWorker::routeNet(drNet* net, std::vector<FlexMazeIdx>& paths)
{
// ProfileTask profile("DR:routeNet");

// Verify if net has jumpers
const bool route_with_jumpers = net->getFrNet()->hasJumpers();

if (net->getPins().size() <= 1) {
return true;
}
Expand Down Expand Up @@ -3274,7 +3277,8 @@ bool FlexDRWorker::routeNet(drNet* net, std::vector<FlexMazeIdx>& paths)
ccMazeIdx1,
ccMazeIdx2,
centerPt,
mazeIdx2TaperBox)) {
mazeIdx2TaperBox,
route_with_jumpers)) {
routeNet_postAstarUpdate(
path, connComps, unConnPins, mazeIdx2unConnPins, isFirstConn);
routeNet_postAstarWritePath(
Expand Down
15 changes: 10 additions & 5 deletions src/drt/src/dr/FlexGridGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,8 @@ class FlexGridGraph
frMIdx gridZ,
frDirEnum dir,
frLayer* layer,
bool considerNDR) const;
bool considerNDR,
bool route_with_jumpers) const;
bool useNDRCosts(const FlexWavefrontGrid& p) const;

frNonDefaultRule* getNDR() const { return ndr_; }
Expand All @@ -949,7 +950,8 @@ class FlexGridGraph
FlexMazeIdx& ccMazeIdx1,
FlexMazeIdx& ccMazeIdx2,
const Point& centerPt,
std::map<FlexMazeIdx, frBox3D*>& mazeIdx2TaperBox);
std::map<FlexMazeIdx, frBox3D*>& mazeIdx2TaperBox,
bool route_with_jumpers);
void setCost(frUInt4 drcCostIn,
frUInt4 markerCostIn,
frUInt4 FixedShapeCostIn)
Expand Down Expand Up @@ -1296,7 +1298,8 @@ class FlexGridGraph
const FlexMazeIdx& dstMazeIdx2,
const frDirEnum& dir) const;
frCost getNextPathCost(const FlexWavefrontGrid& currGrid,
const frDirEnum& dir) const;
const frDirEnum& dir,
bool route_with_jumpers) const;
frDirEnum getLastDir(const std::bitset<WAVEFRONTBITSIZE>& buffer) const;
void traceBackPath(const FlexWavefrontGrid& currGrid,
std::vector<FlexMazeIdx>& path,
Expand All @@ -1306,15 +1309,17 @@ class FlexGridGraph
void expandWavefront(FlexWavefrontGrid& currGrid,
const FlexMazeIdx& dstMazeIdx1,
const FlexMazeIdx& dstMazeIdx2,
const Point& centerPt);
const Point& centerPt,
bool route_with_jumpers);
bool isExpandable(const FlexWavefrontGrid& currGrid, frDirEnum dir) const;
FlexMazeIdx getTailIdx(const FlexMazeIdx& currIdx,
const FlexWavefrontGrid& currGrid) const;
void expand(FlexWavefrontGrid& currGrid,
const frDirEnum& dir,
const FlexMazeIdx& dstMazeIdx1,
const FlexMazeIdx& dstMazeIdx2,
const Point& centerPt);
const Point& centerPt,
bool route_with_jumpers);
bool hasAlignedUpDefTrack(
frLayerNum layerNum,
const std::map<frLayerNum, frTrackPattern*>& xSubMap,
Expand Down
42 changes: 31 additions & 11 deletions src/drt/src/dr/FlexGridGraph_maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void FlexGridGraph::expand(FlexWavefrontGrid& currGrid,
const frDirEnum& dir,
const FlexMazeIdx& dstMazeIdx1,
const FlexMazeIdx& dstMazeIdx2,
const Point& centerPt)
const Point& centerPt,
bool route_with_jumpers)
{
frCost nextEstCost, nextPathCost;
int gridX = currGrid.x();
Expand All @@ -53,7 +54,7 @@ void FlexGridGraph::expand(FlexWavefrontGrid& currGrid,
dstMazeIdx1,
dstMazeIdx2,
dir);
nextPathCost = getNextPathCost(currGrid, dir);
nextPathCost = getNextPathCost(currGrid, dir, route_with_jumpers);
Point currPt;
getPoint(currPt, gridX, gridY);
frCoord currDist = Point::manhattanDistance(currPt, centerPt);
Expand Down Expand Up @@ -153,11 +154,17 @@ void FlexGridGraph::expand(FlexWavefrontGrid& currGrid,
void FlexGridGraph::expandWavefront(FlexWavefrontGrid& currGrid,
const FlexMazeIdx& dstMazeIdx1,
const FlexMazeIdx& dstMazeIdx2,
const Point& centerPt)
const Point& centerPt,
bool route_with_jumpers)
{
for (const auto dir : frDirEnumAll) {
if (isExpandable(currGrid, dir)) {
expand(currGrid, dir, dstMazeIdx1, dstMazeIdx2, centerPt);
expand(currGrid,
dir,
dstMazeIdx1,
dstMazeIdx2,
centerPt,
route_with_jumpers);
}
}
}
Expand Down Expand Up @@ -322,7 +329,8 @@ void FlexGridGraph::getPrevGrid(frMIdx& gridX,
}

frCost FlexGridGraph::getNextPathCost(const FlexWavefrontGrid& currGrid,
const frDirEnum& dir) const
const frDirEnum& dir,
bool route_with_jumpers) const
{
frMIdx gridX = currGrid.x();
frMIdx gridY = currGrid.y();
Expand Down Expand Up @@ -473,8 +481,13 @@ frCost FlexGridGraph::getNextPathCost(const FlexWavefrontGrid& currGrid,
}
}
}
nextPathCost
+= getCosts(gridX, gridY, gridZ, dir, layer, useNDRCosts(currGrid));
nextPathCost += getCosts(gridX,
gridY,
gridZ,
dir,
layer,
useNDRCosts(currGrid),
route_with_jumpers);

return nextPathCost;
}
Expand All @@ -484,7 +497,8 @@ frCost FlexGridGraph::getCosts(frMIdx gridX,
frMIdx gridZ,
frDirEnum dir,
frLayer* layer,
bool considerNDR) const
bool considerNDR,
bool route_with_jumpers) const
{
bool gridCost = hasGridCost(gridX, gridY, gridZ, dir);
bool drcCost = hasRouteShapeCostAdj(gridX, gridY, gridZ, dir, considerNDR);
Expand All @@ -494,14 +508,18 @@ frCost FlexGridGraph::getCosts(frMIdx gridX,
bool guideCost = hasGuide(gridX, gridY, gridZ, dir);
frCoord edgeLength = getEdgeLength(gridX, gridY, gridZ, dir);

// increase cost when a net has jumper
frUInt4 jumper_cost = route_with_jumpers ? 10 : 1;

// temporarily disable guideCost
return getEdgeLength(gridX, gridY, gridZ, dir)
+ (gridCost ? router_cfg_->GRIDCOST * edgeLength : 0)
+ (drcCost ? ggDRCCost_ * edgeLength : 0)
+ (markerCost ? ggMarkerCost_ * edgeLength : 0)
+ (shapeCost ? ggFixedShapeCost_ * edgeLength : 0)
+ (blockCost ? router_cfg_->BLOCKCOST * layer->getMinWidth() * 20 : 0)
+ (!guideCost ? router_cfg_->GUIDECOST * edgeLength : 0);
+ (!guideCost ? (router_cfg_->GUIDECOST * jumper_cost) * edgeLength
: 0);
}

bool FlexGridGraph::useNDRCosts(const FlexWavefrontGrid& p) const
Expand Down Expand Up @@ -659,7 +677,8 @@ bool FlexGridGraph::search(std::vector<FlexMazeIdx>& connComps,
FlexMazeIdx& ccMazeIdx1,
FlexMazeIdx& ccMazeIdx2,
const Point& centerPt,
std::map<FlexMazeIdx, frBox3D*>& mazeIdx2TaperBox)
std::map<FlexMazeIdx, frBox3D*>& mazeIdx2TaperBox,
bool route_with_jumpers)
{
if (drWorker_->getDRIter() >= debugMazeIter) {
std::cout << "INIT search: target pin " << nextPin->getName()
Expand Down Expand Up @@ -735,7 +754,8 @@ bool FlexGridGraph::search(std::vector<FlexMazeIdx>& connComps,
return true;
}
// expand and update wavefront
expandWavefront(currGrid, dstMazeIdx1, dstMazeIdx2, centerPt);
expandWavefront(
currGrid, dstMazeIdx1, dstMazeIdx2, centerPt, route_with_jumpers);
}
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/drt/src/io/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ void io::Parser::setNets(odb::dbBlock* block)
frNet* io::Parser::addNet(odb::dbNet* db_net)
{
bool is_special = db_net->isSpecial();
bool has_jumpers = db_net->hasJumpers();
if (!is_special && db_net->getSigType().isSupply()) {
logger_->error(DRT,
305,
Expand All @@ -1001,6 +1002,9 @@ frNet* io::Parser::addNet(odb::dbNet* db_net)
if (is_special) {
uNetIn->setIsSpecial(true);
}
if (has_jumpers) {
uNetIn->setHasJumpers(has_jumpers);
}
updateNetRouting(netIn, db_net);
netIn->setType(db_net->getSigType());
if (is_special) {
Expand Down
4 changes: 3 additions & 1 deletion src/grt/include/grt/GRoute.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ struct GSegment
int final_x;
int final_y;
int final_layer;
bool is_jumper;
GSegment() = default;
GSegment(int x0, int y0, int l0, int x1, int y1, int l1);
GSegment(int x0, int y0, int l0, int x1, int y1, int l1, bool jumper = false);
bool isVia() const { return (init_x == final_x && init_y == final_y); }
bool isJumper() const { return is_jumper; }
int length() const
{
return std::abs(init_x - final_x) + std::abs(init_y - final_y);
Expand Down
29 changes: 27 additions & 2 deletions src/grt/src/GlobalRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ int GlobalRouter::repairAntennas(odb::dbMTerm* diode_mterm,
"repair_antennas should perform only one iteration when the "
"routing source is detailed routing.");
}

while (violations && itr < iterations) {
if (verbose_) {
logger_->info(GRT, 6, "Repairing antennas, iteration {}.", itr + 1);
Expand All @@ -410,6 +411,23 @@ int GlobalRouter::repairAntennas(odb::dbMTerm* diode_mterm,
diode_mterm,
ratio_margin,
num_threads);
// if run in GRT and it need run jumper insertion
if (!haveDetailedRoutes(nets_to_repair)
&& repair_antennas_->hasNewViolations()) {
// Run jumper insertion and clean
repair_antennas_->jumperInsertion(
routes_, grid_->getTileSize(), getMaxRoutingLayer());
repair_antennas_->clearViolations();

// run again antenna checker
violations
= repair_antennas_->checkAntennaViolations(routes_,
nets_to_repair,
getMaxRoutingLayer(),
diode_mterm,
ratio_margin,
num_threads);
}
if (violations) {
IncrementalGRoute incr_groute(this, block_);
repair_antennas_->repairAntennas(diode_mterm);
Expand Down Expand Up @@ -2367,7 +2385,13 @@ void GlobalRouter::saveGuides()
}

odb::dbTechLayer* layer = routing_layers_[segment.init_layer];
odb::dbGuide::create(db_net, layer, layer, box, guide_is_congested);
// Set guide flag when it is jumper
bool is_jumper = segment.isJumper();
auto guide = odb::dbGuide::create(
db_net, layer, layer, box, guide_is_congested);
if (is_jumper) {
guide->setIsJumper(true);
}
}
}
}
Expand Down Expand Up @@ -4875,14 +4899,15 @@ void GRouteDbCbk::inDbBTermPreDisconnect(odb::dbBTerm* bterm)

////////////////////////////////////////////////////////////////

GSegment::GSegment(int x0, int y0, int l0, int x1, int y1, int l1)
GSegment::GSegment(int x0, int y0, int l0, int x1, int y1, int l1, bool jumper)
{
init_x = std::min(x0, x1);
init_y = std::min(y0, y1);
init_layer = l0;
final_x = std::max(x0, x1);
final_y = std::max(y0, y1);
final_layer = l1;
is_jumper = jumper;
}

bool GSegment::operator==(const GSegment& segment) const
Expand Down
Loading

0 comments on commit 0b348c1

Please sign in to comment.