Skip to content

Commit 22ecee6

Browse files
authored
Merge pull request #10903 from eder-matheus/pr1-cugr-net-lifecycle
2 parents 873a7ba + 215d855 commit 22ecee6

2 files changed

Lines changed: 32 additions & 5 deletions

File tree

src/grt/src/GlobalRouter.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4805,6 +4805,12 @@ void GlobalRouter::removeNet(odb::dbNet* db_net)
48054805

48064806
if (use_cugr_) {
48074807
cugr_->removeNet(db_net);
4808+
auto it = db_net_map_.find(db_net);
4809+
if (it != db_net_map_.end()) {
4810+
delete it->second;
4811+
db_net_map_.erase(it);
4812+
}
4813+
routes_.erase(db_net);
48084814
} else {
48094815
auto it = db_net_map_.find(db_net);
48104816
if (it == db_net_map_.end() || it->second == nullptr) {
@@ -6363,13 +6369,24 @@ std::vector<Net*> GlobalRouter::updateDirtyRoutes(bool save_guides)
63636369

63646370
if (use_cugr_) {
63656371
cugr_->setVerbose(false);
6366-
for (odb::dbNet* net : dirty_nets_) {
6367-
cugr_->updateNet(net);
6372+
std::vector<Net*> dirty_nets;
6373+
dirty_nets.reserve(dirty_nets_.size());
6374+
for (odb::dbNet* db_net : dirty_nets_) {
6375+
// Rebuild the GlobalRouter pin set from the netlist (as updateDirtyNets
6376+
// does for FastRoute); updatePinAccessPoints below fixes the positions.
6377+
Net* net = getNet(db_net);
6378+
updateNetPins(net);
6379+
net->setDirtyNet(false);
6380+
net->clearLastPinPositions();
6381+
cugr_->updateNet(db_net);
6382+
dirty_nets.push_back(net);
63686383
}
63696384
dirty_nets_.clear();
63706385
cugr_->routeIncremental();
63716386
routes_ = cugr_->getRoutes();
6372-
return {};
6387+
// Sync pin access points with CUGR's routing, as the full route does.
6388+
updatePinAccessPoints();
6389+
return dirty_nets;
63736390
}
63746391

63756392
std::vector<Net*> dirty_nets;

src/grt/src/cugr/src/CUGR.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,13 @@ void CUGR::getITermsAccessPoints(
12231223
odb::dbNet* net,
12241224
odb::PtrMap<odb::dbITerm, odb::Point3D>& access_points)
12251225
{
1226-
GRNet* gr_net = db_net_map_.at(net);
1226+
// Nets absent from the map (e.g. < 2 pins, skipped by updateNet) have no
1227+
// CUGR access points; leave the output empty.
1228+
auto it = db_net_map_.find(net);
1229+
if (it == db_net_map_.end()) {
1230+
return;
1231+
}
1232+
GRNet* gr_net = it->second;
12271233
for (const auto& [iterm, ap] : gr_net->getITermAccessPoints()) {
12281234
const int x = grid_graph_->getGridline(0, ap.point.x());
12291235
const int y = grid_graph_->getGridline(1, ap.point.y());
@@ -1235,7 +1241,11 @@ void CUGR::getBTermsAccessPoints(
12351241
odb::dbNet* net,
12361242
odb::PtrMap<odb::dbBTerm, odb::Point3D>& access_points)
12371243
{
1238-
GRNet* gr_net = db_net_map_.at(net);
1244+
auto it = db_net_map_.find(net);
1245+
if (it == db_net_map_.end()) {
1246+
return;
1247+
}
1248+
GRNet* gr_net = it->second;
12391249
for (const auto& [bterm, ap] : gr_net->getBTermAccessPoints()) {
12401250
const int x = grid_graph_->getGridline(0, ap.point.x());
12411251
const int y = grid_graph_->getGridline(1, ap.point.y());

0 commit comments

Comments
 (0)