Skip to content

Commit 65ac6fa

Browse files
committed
grt: Add option of RUDY on nets from selection
Signed-off-by: Martin Povišer <[email protected]>
1 parent a759e53 commit 65ac6fa

File tree

8 files changed

+57
-9
lines changed

8 files changed

+57
-9
lines changed

src/grt/include/grt/Rudy.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class Rudy
3939
* \pre we need to call this function after `setGridConfig` and
4040
* `setWireWidth`.
4141
* */
42-
void calculateRudy();
42+
void calculateRudy(std::optional<std::set<odb::dbNet*>*> selection
43+
= std::nullopt);
4344

4445
/**
4546
* Set the grid area and grid numbers.
@@ -65,6 +66,7 @@ class Rudy
6566
void makeGrid();
6667
void getResourceReductions();
6768
Tile& getEditableTile(int x, int y) { return grid_.at(x).at(y); }
69+
void processNet(odb::dbNet* net);
6870
void processIntersectionSignalNet(odb::Rect net_rect);
6971

7072
odb::dbBlock* block_;

src/grt/src/Rudy.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void Rudy::getResourceReductions()
104104
}
105105
}
106106

107-
void Rudy::calculateRudy()
107+
void Rudy::calculateRudy(std::optional<std::set<odb::dbNet*>*> selection)
108108
{
109109
// Clear previous computation
110110
for (auto& grid_column : grid_) {
@@ -115,15 +115,26 @@ void Rudy::calculateRudy()
115115

116116
getResourceReductions();
117117

118-
// refer: https://ieeexplore.ieee.org/document/4211973
119-
for (auto net : block_->getNets()) {
120-
if (!net->getSigType().isSupply()) {
121-
const auto net_rect = net->getTermBBox();
122-
processIntersectionSignalNet(net_rect);
118+
if (selection.has_value()) {
119+
for (auto net : *selection.value()) {
120+
processNet(net);
121+
}
122+
} else {
123+
for (auto net : block_->getNets()) {
124+
processNet(net);
123125
}
124126
}
125127
}
126128

129+
void Rudy::processNet(odb::dbNet* net)
130+
{
131+
// refer: https://ieeexplore.ieee.org/document/4211973
132+
if (!net->getSigType().isSupply()) {
133+
const auto net_rect = net->getTermBBox();
134+
processIntersectionSignalNet(net_rect);
135+
}
136+
}
137+
127138
void Rudy::processIntersectionSignalNet(const odb::Rect net_rect)
128139
{
129140
const auto net_area = net_rect.area();

src/grt/src/heatMapRudy.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ RUDYDataSource::RUDYDataSource(utl::Logger* logger,
2020
: GlobalRoutingDataSource(logger,
2121
"Estimated Congestion (RUDY)",
2222
"RUDY",
23-
"RUDY")
23+
"RUDY"),
24+
selection_only_(false)
2425
{
2526
grouter_ = grouter;
2627
db_ = db;
2728
rudy_ = nullptr;
29+
selection_only_ = false;
30+
31+
addBooleanSetting(
32+
"Selection",
33+
"Only consider nets in selection",
34+
[this]() { return selection_only_; },
35+
[this](bool value) { selection_only_ = value; });
2836
}
2937

3038
void RUDYDataSource::combineMapData(bool base_has_value,
@@ -108,7 +116,17 @@ bool RUDYDataSource::populateMap()
108116
return false;
109117
}
110118

111-
rudy_->calculateRudy();
119+
if (selection_only_ && gui::Gui::enabled()) {
120+
std::set<odb::dbNet*> selection;
121+
for (const gui::Selected& item : gui::Gui::get()->selection()) {
122+
if (item.isNet()) {
123+
selection.insert(std::any_cast<odb::dbNet*>(item.getObject()));
124+
}
125+
}
126+
rudy_->calculateRudy(&selection);
127+
} else {
128+
rudy_->calculateRudy();
129+
}
112130

113131
for (int x = 0; x < x_grid_size; ++x) {
114132
for (int y = 0; y < y_grid_size; ++y) {

src/grt/src/heatMapRudy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class RUDYDataSource : public gui::GlobalRoutingDataSource,
5858
grt::GlobalRouter* grouter_;
5959
odb::dbDatabase* db_;
6060
grt::Rudy* rudy_;
61+
bool selection_only_;
6162
};
6263

6364
} // namespace grt

src/gui/include/gui/gui.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,9 @@ class Gui
639639
// Add an instance to the selection set
640640
void addSelectedInst(const char* name);
641641

642+
// Return the selected set
643+
SelectionSet& selection();
644+
642645
// check if any object(inst/net) is present in sect/highlight set
643646
bool anyObjectInSet(bool selection_set, odb::dbObjectType obj_type) const;
644647

src/gui/src/gui.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ void Gui::addSelectedInst(const char* name)
334334
main_window->addSelected(makeSelected(inst));
335335
}
336336

337+
SelectionSet& Gui::selection()
338+
{
339+
return main_window->selection();
340+
}
341+
337342
bool Gui::anyObjectInSet(bool selection_set, odb::dbObjectType obj_type) const
338343
{
339344
return main_window->anyObjectInSet(selection_set, obj_type);

src/gui/src/mainWindow.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,11 @@ void MainWindow::updateTitle()
530530
}
531531
}
532532

533+
SelectionSet& MainWindow::selection()
534+
{
535+
return selected_;
536+
}
537+
533538
void MainWindow::setBlock(odb::dbBlock* block)
534539
{
535540
updateTitle();

src/gui/src/mainWindow.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class MainWindow : public QMainWindow, public odb::dbDatabaseObserver
100100

101101
void setTitle(const std::string& title);
102102

103+
// Return the selected set
104+
SelectionSet& selection();
105+
103106
signals:
104107
// Signaled when we get a postRead callback to tell the sub-widgets
105108
// to update

0 commit comments

Comments
 (0)