Skip to content

Commit b4dad65

Browse files
authored
Merge pull request #8766 from The-OpenROAD-Project-staging/grt-rudy-selection
grt: Add option of RUDY on nets from selection
2 parents aaf308c + bb78336 commit b4dad65

File tree

9 files changed

+70
-9
lines changed

9 files changed

+70
-9
lines changed

src/grt/include/grt/Rudy.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Copyright (c) 2024-2025, The OpenROAD Authors
33

44
#include <cassert>
5+
#include <optional>
6+
#include <set>
57
#include <utility>
68
// #define _CRTDBG_MAP_ALLOC
79

@@ -39,7 +41,8 @@ class Rudy
3941
* \pre we need to call this function after `setGridConfig` and
4042
* `setWireWidth`.
4143
* */
42-
void calculateRudy();
44+
void calculateRudy(std::optional<std::set<odb::dbNet*>*> selection
45+
= std::nullopt);
4346

4447
/**
4548
* Set the grid area and grid numbers.
@@ -65,6 +68,7 @@ class Rudy
6568
void makeGrid();
6669
void getResourceReductions();
6770
Tile& getEditableTile(int x, int y) { return grid_.at(x).at(y); }
71+
void processNet(odb::dbNet* net);
6872
void processIntersectionSignalNet(odb::Rect net_rect);
6973

7074
odb::dbBlock* block_;

src/grt/src/Rudy.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include <algorithm>
77
#include <cstdint>
8+
#include <optional>
9+
#include <set>
810
#include <utility>
911

1012
#include "grt/GRoute.h"
@@ -104,7 +106,7 @@ void Rudy::getResourceReductions()
104106
}
105107
}
106108

107-
void Rudy::calculateRudy()
109+
void Rudy::calculateRudy(std::optional<std::set<odb::dbNet*>*> selection)
108110
{
109111
// Clear previous computation
110112
for (auto& grid_column : grid_) {
@@ -115,15 +117,26 @@ void Rudy::calculateRudy()
115117

116118
getResourceReductions();
117119

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);
120+
if (selection.has_value()) {
121+
for (auto net : *selection.value()) {
122+
processNet(net);
123+
}
124+
} else {
125+
for (auto net : block_->getNets()) {
126+
processNet(net);
123127
}
124128
}
125129
}
126130

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

src/grt/src/heatMapRudy.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
#include "heatMapRudy.h"
55

66
#include <algorithm>
7+
#include <any>
78
#include <cmath>
9+
#include <set>
810
#include <stdexcept>
911
#include <vector>
1012

13+
#include "gui/gui.h"
1114
#include "odb/db.h"
1215
#include "odb/dbTypes.h"
1316
#include "odb/geom.h"
@@ -20,11 +23,19 @@ RUDYDataSource::RUDYDataSource(utl::Logger* logger,
2023
: GlobalRoutingDataSource(logger,
2124
"Estimated Congestion (RUDY)",
2225
"RUDY",
23-
"RUDY")
26+
"RUDY"),
27+
selection_only_(false)
2428
{
2529
grouter_ = grouter;
2630
db_ = db;
2731
rudy_ = nullptr;
32+
selection_only_ = false;
33+
34+
addBooleanSetting(
35+
"Selection",
36+
"Only consider nets in selection",
37+
[this]() { return selection_only_; },
38+
[this](bool value) { selection_only_ = value; });
2839
}
2940

3041
void RUDYDataSource::combineMapData(bool base_has_value,
@@ -108,7 +119,17 @@ bool RUDYDataSource::populateMap()
108119
return false;
109120
}
110121

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

113134
for (int x = 0; x < x_grid_size; ++x) {
114135
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+
const 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+
const 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+
const 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+
const SelectionSet& selection();
105+
103106
signals:
104107
// Signaled when we get a postRead callback to tell the sub-widgets
105108
// to update

src/gui/src/stub.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ void Gui::setSelected(const Selected& selection)
133133
{
134134
}
135135

136+
const SelectionSet& Gui::selection()
137+
{
138+
static SelectionSet dummy;
139+
return dummy;
140+
}
141+
136142
void Gui::registerDescriptor(const std::type_info& type,
137143
const Descriptor* descriptor)
138144
{

0 commit comments

Comments
 (0)