Skip to content

Commit 96e23db

Browse files
authored
Merge pull request #9136 from eder-matheus/grt_cugr_connectivity
grt: update access point with CUGR data for parasitics estimation
2 parents 7de25a9 + b6efb70 commit 96e23db

21 files changed

+16947
-18624
lines changed

src/grt/include/grt/GlobalRouter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ class GlobalRouter
390390
Pin& pin,
391391
odb::Point& pos_on_grid,
392392
bool has_access_points);
393+
void updatePinAccessPoints();
393394
void suggestAdjustment();
394395
void findFastRoutePins(Net* net,
395396
std::vector<RoutePt>& pins_on_grid,

src/grt/src/GlobalRouter.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "odb/dbSet.h"
4646
#include "odb/dbShape.h"
4747
#include "odb/dbTypes.h"
48+
#include "odb/geom.h"
4849
#include "odb/geom_boost.h"
4950
#include "odb/wOrder.h"
5051
#include "sta/Clock.hh"
@@ -354,6 +355,7 @@ void GlobalRouter::globalRoute(bool save_guides,
354355
cugr_->init(min_layer, max_layer, clock_nets);
355356
cugr_->route();
356357
routes_ = cugr_->getRoutes();
358+
updatePinAccessPoints();
357359
} else {
358360
if (verbose_) {
359361
reportResources();
@@ -1183,6 +1185,33 @@ void GlobalRouter::computePinPositionOnGrid(
11831185
pin.setConnectionLayer(pin_position.layer());
11841186
}
11851187

1188+
void GlobalRouter::updatePinAccessPoints()
1189+
{
1190+
for (const auto& [db_net, net] : db_net_map_) {
1191+
std::map<odb::dbITerm*, odb::Point3D> iterm_to_aps;
1192+
std::map<odb::dbBTerm*, odb::Point3D> bterm_to_aps;
1193+
cugr_->getITermsAccessPoints(db_net, iterm_to_aps);
1194+
cugr_->getBTermsAccessPoints(db_net, bterm_to_aps);
1195+
1196+
auto updatePinPos = [&](Pin& pin, auto* term, const auto& ap_map) {
1197+
if (auto it = ap_map.find(term); it != ap_map.end()) {
1198+
const auto& ap = it->second;
1199+
pin.setConnectionLayer(ap.z());
1200+
pin.setOnGridPosition(
1201+
grid_->getPositionOnGrid(odb::Point(ap.x(), ap.y())));
1202+
}
1203+
};
1204+
1205+
for (Pin& pin : net->getPins()) {
1206+
if (pin.isPort()) {
1207+
updatePinPos(pin, pin.getBTerm(), bterm_to_aps);
1208+
} else {
1209+
updatePinPos(pin, pin.getITerm(), iterm_to_aps);
1210+
}
1211+
}
1212+
}
1213+
}
1214+
11861215
int GlobalRouter::getNetMaxRoutingLayer(const Net* net)
11871216
{
11881217
return net->getSignalType() == odb::dbSigType::CLOCK

src/grt/src/cugr/include/CUGR.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
#pragma once
22

33
#include <csignal>
4+
#include <map>
45
#include <memory>
56
#include <set>
67
#include <string>
78
#include <utility>
89
#include <vector>
910

1011
#include "grt/GRoute.h"
12+
#include "odb/geom.h"
1113

1214
namespace odb {
1315
class dbDatabase;
1416
class dbNet;
17+
class dbITerm;
18+
class dbBTerm;
1519
} // namespace odb
1620

1721
namespace sta {
@@ -74,6 +78,12 @@ class CUGR
7478
void write(const std::string& guide_file);
7579
NetRouteMap getRoutes();
7680
void updateDbCongestion();
81+
void getITermsAccessPoints(
82+
odb::dbNet* net,
83+
std::map<odb::dbITerm*, odb::Point3D>& access_points);
84+
void getBTermsAccessPoints(
85+
odb::dbNet* net,
86+
std::map<odb::dbBTerm*, odb::Point3D>& access_points);
7787

7888
private:
7989
void updateOverflowNets(std::vector<int>& netIndices);
@@ -88,6 +98,7 @@ class CUGR
8898
std::unique_ptr<Design> design_;
8999
std::unique_ptr<GridGraph> grid_graph_;
90100
std::vector<std::unique_ptr<GRNet>> gr_nets_;
101+
std::map<odb::dbNet*, GRNet*> db_net_map_;
91102

92103
odb::dbDatabase* db_;
93104
utl::Logger* logger_;

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <fstream>
88
#include <iostream>
99
#include <limits>
10+
#include <map>
1011
#include <memory>
1112
#include <set>
1213
#include <sstream>
@@ -26,6 +27,7 @@
2627
#include "geo.h"
2728
#include "grt/GRoute.h"
2829
#include "odb/db.h"
30+
#include "odb/geom.h"
2931
#include "stt/SteinerTreeBuilder.h"
3032
#include "utl/Logger.h"
3133

@@ -58,6 +60,7 @@ void CUGR::init(const int min_routing_layer,
5860
gr_nets_.reserve(baseNets.size());
5961
for (const CUGRNet& baseNet : baseNets) {
6062
gr_nets_.push_back(std::make_unique<GRNet>(baseNet, grid_graph_.get()));
63+
db_net_map_[baseNet.getDbNet()] = gr_nets_.back().get();
6164
}
6265
}
6366

@@ -498,4 +501,28 @@ void CUGR::updateDbCongestion()
498501
}
499502
}
500503

504+
void CUGR::getITermsAccessPoints(
505+
odb::dbNet* net,
506+
std::map<odb::dbITerm*, odb::Point3D>& access_points)
507+
{
508+
GRNet* gr_net = db_net_map_.at(net);
509+
for (const auto& [iterm, ap] : gr_net->getITermAccessPoints()) {
510+
const int x = grid_graph_->getGridline(0, ap.point.x());
511+
const int y = grid_graph_->getGridline(1, ap.point.y());
512+
access_points[iterm] = odb::Point3D(x, y, ap.layers.high() + 1);
513+
}
514+
}
515+
516+
void CUGR::getBTermsAccessPoints(
517+
odb::dbNet* net,
518+
std::map<odb::dbBTerm*, odb::Point3D>& access_points)
519+
{
520+
GRNet* gr_net = db_net_map_.at(net);
521+
for (const auto& [bterm, ap] : gr_net->getBTermAccessPoints()) {
522+
const int x = grid_graph_->getGridline(0, ap.point.x());
523+
const int y = grid_graph_->getGridline(1, ap.point.y());
524+
access_points[bterm] = odb::Point3D(x, y, ap.layers.high() + 1);
525+
}
526+
}
527+
501528
} // namespace grt

src/grt/src/cugr/src/Design.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,10 @@ void Design::readLayers()
7575
odb::dbTrackGrid* track_grid = block_->findTrackGrid(tech_layer);
7676
if (track_grid != nullptr) {
7777
layers_.emplace_back(tech_layer, track_grid);
78-
if (tech_layer->getRoutingLevel() == 3) {
79-
int track_step, track_init, num_tracks;
80-
track_grid->getAverageTrackSpacing(
81-
track_step, track_init, num_tracks);
82-
default_gridline_spacing_ = track_step * 15;
83-
}
8478
}
8579
}
8680
}
81+
default_gridline_spacing_ = block_->getGCellTileSize();
8782
}
8883

8984
void Design::readNetlist()

src/grt/src/cugr/src/GRNet.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "GridGraph.h"
1010
#include "Netlist.h"
1111
#include "geo.h"
12+
#include "odb/db.h"
1213

1314
namespace grt {
1415

@@ -19,6 +20,8 @@ GRNet::GRNet(const CUGRNet& baseNet, const GridGraph* gridGraph)
1920
const int numPins = baseNet.getNumPins();
2021
pin_access_points_.resize(numPins);
2122
layer_range_ = baseNet.getLayerRange();
23+
24+
int pin_index = 0;
2225
for (CUGRPin& pin : baseNet.getPins()) {
2326
const std::vector<BoxOnLayer> pinShapes = pin.getPinShapes();
2427
std::unordered_set<uint64_t> included;
@@ -36,7 +39,15 @@ GRNet::GRNet(const CUGRNet& baseNet, const GridGraph* gridGraph)
3639
}
3740
}
3841
}
42+
43+
if (pin.isPort()) {
44+
pin_index_to_bterm_[pin_index] = pin.getBTerm();
45+
} else {
46+
pin_index_to_iterm_[pin_index] = pin.getITerm();
47+
}
48+
pin_index++;
3949
}
50+
4051
for (const auto& accessPoints : pin_access_points_) {
4152
for (const auto& point : accessPoints) {
4253
bounding_box_.Update(point);
@@ -50,4 +61,17 @@ bool GRNet::isInsideLayerRange(int layer_index) const
5061
&& layer_index <= layer_range_.max_layer;
5162
}
5263

64+
void GRNet::addPreferredAccessPoint(int pin_index, const AccessPoint& ap)
65+
{
66+
if (auto it = pin_index_to_iterm_.find(pin_index);
67+
it != pin_index_to_iterm_.end()) {
68+
odb::dbITerm* iterm = it->second;
69+
iterm_to_ap_[iterm] = ap;
70+
} else if (auto it = pin_index_to_bterm_.find(pin_index);
71+
it != pin_index_to_bterm_.end()) {
72+
odb::dbBTerm* bterm = it->second;
73+
bterm_to_ap_[bterm] = ap;
74+
}
75+
}
76+
5377
} // namespace grt

src/grt/src/cugr/src/GRNet.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <map>
34
#include <memory>
45
#include <string>
56
#include <utility>
@@ -28,6 +29,7 @@ class GRNet
2829
{
2930
return pin_access_points_;
3031
}
32+
3133
const BoxT& getBoundingBox() const { return bounding_box_; }
3234
const std::shared_ptr<GRTreeNode>& getRoutingTree() const
3335
{
@@ -40,11 +42,24 @@ class GRNet
4042
}
4143
void clearRoutingTree() { routing_tree_ = nullptr; }
4244
bool isInsideLayerRange(int layer_index) const;
45+
void addPreferredAccessPoint(int pin_index, const AccessPoint& ap);
46+
const std::map<odb::dbBTerm*, AccessPoint>& getBTermAccessPoints() const
47+
{
48+
return bterm_to_ap_;
49+
}
50+
const std::map<odb::dbITerm*, AccessPoint>& getITermAccessPoints() const
51+
{
52+
return iterm_to_ap_;
53+
}
4354

4455
private:
4556
int index_;
4657
odb::dbNet* db_net_;
4758
std::vector<std::vector<GRPoint>> pin_access_points_;
59+
std::map<int, odb::dbITerm*> pin_index_to_iterm_;
60+
std::map<int, odb::dbBTerm*> pin_index_to_bterm_;
61+
std::map<odb::dbBTerm*, AccessPoint> bterm_to_ap_;
62+
std::map<odb::dbITerm*, AccessPoint> iterm_to_ap_;
4863
BoxT bounding_box_;
4964
std::shared_ptr<GRTreeNode> routing_tree_;
5065
LayerRange layer_range_;

src/grt/src/cugr/src/GridGraph.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,11 @@ CostT GridGraph::getViaCost(const int layer_index, const PointT loc) const
366366
return cost;
367367
}
368368

369-
void GridGraph::convertODBtoCUGR(AccessPointSet& selected_access_points,
370-
odb::dbAccessPoint* ap,
371-
int x,
372-
int y) const
369+
void GridGraph::translateAccessPointsToGrid(
370+
odb::dbAccessPoint* ap,
371+
int x,
372+
int y,
373+
AccessPointSet& selected_access_points) const
373374
{
374375
const int amount_per_x = design_->getDieRegion().hx() / x_size_;
375376
const int amount_per_y = design_->getDieRegion().hy() / y_size_;
@@ -405,7 +406,7 @@ bool GridGraph::findODBAccessPoints(
405406
access_points.insert(
406407
access_points.begin(), bpin_pas.begin(), bpin_pas.end());
407408
for (auto ap : bpin_pas) {
408-
convertODBtoCUGR(selected_access_points, ap, 0, 0);
409+
translateAccessPointsToGrid(ap, 0, 0, selected_access_points);
409410
}
410411
}
411412
}
@@ -420,7 +421,7 @@ bool GridGraph::findODBAccessPoints(
420421
for (auto ap : pref_access_points) {
421422
int x, y;
422423
iterms->getInst()->getLocation(x, y);
423-
convertODBtoCUGR(selected_access_points, ap, x, y);
424+
translateAccessPointsToGrid(ap, x, y, selected_access_points);
424425
}
425426
}
426427
// Currently ignoring non preferred APs
@@ -432,7 +433,7 @@ bool GridGraph::findODBAccessPoints(
432433
return true;
433434
}
434435

435-
AccessPointSet GridGraph::selectAccessPoints(const GRNet* net) const
436+
AccessPointSet GridGraph::selectAccessPoints(GRNet* net) const
436437
{
437438
AccessPointHash hasher(y_size_);
438439
AccessPointSet selected_access_points(0, hasher);
@@ -442,6 +443,7 @@ AccessPointSet GridGraph::selectAccessPoints(const GRNet* net) const
442443
const PointT netCenter(boundingBox.cx(), boundingBox.cy());
443444
// Skips calculations if DRT already created APs in ODB
444445
if (!findODBAccessPoints(net, selected_access_points)) {
446+
int pin_idx = 0;
445447
for (const std::vector<GRPoint>& accessPoints : net->getPinAccessPoints()) {
446448
std::pair<int, int> bestAccessDist = {0, std::numeric_limits<int>::max()};
447449
int bestIndex = -1;
@@ -492,6 +494,9 @@ AccessPointSet GridGraph::selectAccessPoints(const GRNet* net) const
492494
fixedLayerInterval.Update(point.getLayerIdx());
493495
}
494496
}
497+
498+
net->addPreferredAccessPoint(pin_idx, *it);
499+
pin_idx++;
495500
}
496501
}
497502
return selected_access_points;

src/grt/src/cugr/src/GridGraph.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class GridGraph
107107
CostT getUnitViaCost() const { return unit_via_cost_; }
108108

109109
// Misc
110-
AccessPointSet selectAccessPoints(const GRNet* net) const;
110+
AccessPointSet selectAccessPoints(GRNet* net) const;
111111

112112
// Methods for updating demands
113113
void commitTree(const std::shared_ptr<GRTreeNode>& tree, bool rip_up = false);
@@ -151,10 +151,11 @@ class GridGraph
151151
{
152152
return unit_length_short_costs_[layer_index];
153153
}
154-
void convertODBtoCUGR(AccessPointSet& selected_access_points,
155-
odb::dbAccessPoint* ap,
156-
int x,
157-
int y) const;
154+
void translateAccessPointsToGrid(
155+
odb::dbAccessPoint* ap,
156+
int x,
157+
int y,
158+
AccessPointSet& selected_access_points) const;
158159
bool findODBAccessPoints(const GRNet* net,
159160
AccessPointSet& selected_access_points) const;
160161

src/grt/test/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ TESTS = [
2525
"est_rc2",
2626
"est_rc3",
2727
"est_rc4",
28+
"est_rc_cugr1",
2829
"estimate_path_resistance",
2930
"gcd",
3031
"gcd_cugr",

0 commit comments

Comments
 (0)