Skip to content

Commit ce2ab8f

Browse files
authored
Merge pull request #8917 from eder-matheus/grt_cugr_layer_range
grt: implement layer ranges for signal and clock in CUGR
2 parents ecf1eea + 7754a99 commit ce2ab8f

File tree

19 files changed

+275
-133
lines changed

19 files changed

+275
-133
lines changed

src/grt/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ cc_library(
101101
deps = [
102102
":groute",
103103
"//:ord",
104+
"//src/dbSta",
105+
"//src/dbSta:dbNetwork",
104106
"//src/odb",
107+
"//src/sta:opensta_lib",
105108
"//src/stt",
106109
"//src/utl",
107110
],

src/grt/include/grt/GlobalRouter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ class GlobalRouter
438438
void computeCapacities(int max_layer);
439439
void findTrackPitches(int max_layer);
440440
std::vector<Net*> findNets(bool init_clock_nets);
441+
void findClockNets(const std::vector<Net*>& nets,
442+
std::set<odb::dbNet*>& clock_nets);
441443
void computeObstructionsAdjustments();
442444
void findLayerExtensions(std::vector<int>& layer_extensions);
443445
int findObstructions(odb::Rect& die_area);

src/grt/src/GlobalRouter.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ GlobalRouter::GlobalRouter(utl::Logger* logger,
101101
{
102102
fastroute_
103103
= new FastRouteCore(db_, logger_, callback_handler_, stt_builder_, sta_);
104-
cugr_ = new CUGR(db_, logger_, stt_builder_);
104+
cugr_ = new CUGR(db_, logger_, stt_builder_, sta_);
105105
}
106106

107107
void GlobalRouter::initGui(std::unique_ptr<AbstractRoutingCongestionDataSource>
@@ -350,7 +350,9 @@ void GlobalRouter::globalRoute(bool save_guides,
350350
if (use_cugr_) {
351351
int min_layer, max_layer;
352352
getMinMaxLayer(min_layer, max_layer);
353-
cugr_->init(min_layer, max_layer);
353+
std::set<odb::dbNet*> clock_nets;
354+
findClockNets(nets, clock_nets);
355+
cugr_->init(min_layer, max_layer, clock_nets);
354356
cugr_->route();
355357
routes_ = cugr_->getRoutes();
356358
} else {
@@ -3770,6 +3772,7 @@ std::vector<Net*> GlobalRouter::findNets(bool init_clock_nets)
37703772
if (net) {
37713773
bool is_non_leaf_clock = isNonLeafClock(net->getDbNet());
37723774
if (is_non_leaf_clock) {
3775+
net->setIsClockNet(true);
37733776
clk_nets.push_back(net);
37743777
}
37753778
}
@@ -3794,6 +3797,16 @@ std::vector<Net*> GlobalRouter::findNets(bool init_clock_nets)
37943797
return nets;
37953798
}
37963799

3800+
void GlobalRouter::findClockNets(const std::vector<Net*>& nets,
3801+
std::set<odb::dbNet*>& clock_nets)
3802+
{
3803+
for (Net* net : nets) {
3804+
if (net->isClockNet()) {
3805+
clock_nets.insert(net->getDbNet());
3806+
}
3807+
}
3808+
}
3809+
37973810
Net* GlobalRouter::addNet(odb::dbNet* db_net)
37983811
{
37993812
if (!db_net->getSigType().isSupply() && !db_net->isSpecial()

src/grt/src/Net.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Net::Net(odb::dbNet* net, bool has_wires)
2323
has_wires_(has_wires),
2424
merged_net_(nullptr),
2525
is_merged_net_(false),
26-
is_dirty_net_(false)
26+
is_dirty_net_(false),
27+
is_clk_(false)
2728
{
2829
}
2930

src/grt/src/Net.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class Net
5858
bool isMergedNet() const { return is_merged_net_; }
5959
void setDirtyNet(bool is_dirty_net) { is_dirty_net_ = is_dirty_net; }
6060
bool isDirtyNet() const { return is_dirty_net_; }
61+
void setIsClockNet(bool is_clk) { is_clk_ = is_clk; }
62+
bool isClockNet() const { return is_clk_; }
6163

6264
private:
6365
int getNumBTermsAboveMaxLayer(odb::dbTechLayer* max_routing_layer);
@@ -71,6 +73,7 @@ class Net
7173
odb::dbNet* merged_net_;
7274
bool is_merged_net_;
7375
bool is_dirty_net_;
76+
bool is_clk_;
7477
};
7578

7679
} // namespace grt

src/grt/src/cugr/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ target_include_directories(CUGR
3131

3232
target_link_libraries(CUGR
3333
PRIVATE
34+
dbSta_lib
3435
utl_lib
3536
stt_lib
3637
odb

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <csignal>
44
#include <memory>
5+
#include <set>
56
#include <string>
67
#include <utility>
78
#include <vector>
@@ -10,8 +11,13 @@
1011

1112
namespace odb {
1213
class dbDatabase;
14+
class dbNet;
1315
} // namespace odb
1416

17+
namespace sta {
18+
class dbSta;
19+
} // namespace sta
20+
1521
namespace stt {
1622
class SteinerTreeBuilder;
1723
} // namespace stt
@@ -58,9 +64,12 @@ class CUGR
5864
public:
5965
CUGR(odb::dbDatabase* db,
6066
utl::Logger* log,
61-
stt::SteinerTreeBuilder* stt_builder);
67+
stt::SteinerTreeBuilder* stt_builder,
68+
sta::dbSta* sta);
6269
~CUGR();
63-
void init(int min_routing_layer, int max_routing_layer);
70+
void init(int min_routing_layer,
71+
int max_routing_layer,
72+
const std::set<odb::dbNet*>& clock_nets);
6473
void route();
6574
void write(const std::string& guide_file);
6675
NetRouteMap getRoutes();
@@ -83,6 +92,7 @@ class CUGR
8392
odb::dbDatabase* db_;
8493
utl::Logger* logger_;
8594
stt::SteinerTreeBuilder* stt_builder_;
95+
sta::dbSta* sta_;
8696

8797
Constants constants_;
8898

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <iostream>
99
#include <limits>
1010
#include <memory>
11+
#include <set>
1112
#include <sstream>
1213
#include <utility>
1314
#include <vector>
@@ -20,6 +21,8 @@
2021
#include "MazeRoute.h"
2122
#include "Netlist.h"
2223
#include "PatternRoute.h"
24+
#include "db_sta/dbNetwork.hh"
25+
#include "db_sta/dbSta.hh"
2326
#include "geo.h"
2427
#include "grt/GRoute.h"
2528
#include "odb/db.h"
@@ -30,17 +33,25 @@ namespace grt {
3033

3134
CUGR::CUGR(odb::dbDatabase* db,
3235
utl::Logger* log,
33-
stt::SteinerTreeBuilder* stt_builder)
34-
: db_(db), logger_(log), stt_builder_(stt_builder)
36+
stt::SteinerTreeBuilder* stt_builder,
37+
sta::dbSta* sta)
38+
: db_(db), logger_(log), stt_builder_(stt_builder), sta_(sta)
3539
{
3640
}
3741

3842
CUGR::~CUGR() = default;
3943

40-
void CUGR::init(const int min_routing_layer, const int max_routing_layer)
44+
void CUGR::init(const int min_routing_layer,
45+
const int max_routing_layer,
46+
const std::set<odb::dbNet*>& clock_nets)
4147
{
42-
design_ = std::make_unique<Design>(
43-
db_, logger_, constants_, min_routing_layer, max_routing_layer);
48+
design_ = std::make_unique<Design>(db_,
49+
logger_,
50+
sta_,
51+
constants_,
52+
min_routing_layer,
53+
max_routing_layer,
54+
clock_nets);
4455
grid_graph_ = std::make_unique<GridGraph>(design_.get(), constants_, logger_);
4556
// Instantiate the global routing netlist
4657
const std::vector<CUGRNet>& baseNets = design_->getAllNets();

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#include "Design.h"
22

33
#include <iostream>
4+
#include <set>
45
#include <vector>
56

67
#include "CUGR.h"
78
#include "GeoTypes.h"
89
#include "Netlist.h"
10+
#include "db_sta/dbNetwork.hh"
11+
#include "db_sta/dbSta.hh"
912
#include "odb/db.h"
1013
#include "odb/dbShape.h"
1114
#include "odb/dbTypes.h"
@@ -16,15 +19,19 @@ namespace grt {
1619

1720
Design::Design(odb::dbDatabase* db,
1821
utl::Logger* logger,
22+
sta::dbSta* sta,
1923
const Constants& constants,
2024
const int min_routing_layer,
21-
const int max_routing_layer)
25+
const int max_routing_layer,
26+
const std::set<odb::dbNet*>& clock_nets)
2227
: block_(db->getChip()->getBlock()),
2328
tech_(db->getTech()),
2429
logger_(logger),
30+
sta_(sta),
2531
constants_(constants),
2632
min_routing_layer_(min_routing_layer),
27-
max_routing_layer_(max_routing_layer)
33+
max_routing_layer_(max_routing_layer),
34+
clock_nets_(clock_nets)
2835
{
2936
read();
3037
setUnitCosts();
@@ -130,7 +137,15 @@ void Design::readNetlist()
130137
pins.emplace_back(pin_count, db_iterm, pin_shapes);
131138
pin_count++;
132139
}
133-
nets_.emplace_back(net_index, db_net, pins);
140+
141+
LayerRange layer_range
142+
= {.min_layer = min_routing_layer_, .max_layer = max_routing_layer_};
143+
if (clock_nets_.find(db_net) != clock_nets_.end()) {
144+
layer_range.min_layer = block_->getMinLayerForClock() - 1;
145+
layer_range.max_layer = block_->getMaxLayerForClock() - 1;
146+
}
147+
148+
nets_.emplace_back(net_index, db_net, pins, layer_range);
134149
net_index++;
135150
}
136151
}

src/grt/src/cugr/src/Design.h

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

3+
#include <set>
34
#include <vector>
45

56
#include "CUGR.h"
@@ -9,11 +10,18 @@
910
#include "geo.h"
1011

1112
namespace odb {
12-
class dbDatabase;
1313
class dbBlock;
14+
class dbDatabase;
15+
class dbITerm;
16+
class dbNet;
1417
class dbTech;
1518
} // namespace odb
1619

20+
namespace sta {
21+
class dbNetwork;
22+
class dbSta;
23+
} // namespace sta
24+
1725
namespace utl {
1826
class Logger;
1927
} // namespace utl
@@ -27,9 +35,11 @@ class Design
2735
public:
2836
Design(odb::dbDatabase* db,
2937
utl::Logger* logger,
38+
sta::dbSta* sta,
3039
const Constants& constants,
3140
int min_routing_layer,
32-
int max_routing_layer);
41+
int max_routing_layer,
42+
const std::set<odb::dbNet*>& clock_nets);
3343
int getLibDBU() const { return lib_dbu_; }
3444

3545
CostT getUnitLengthWireCost() const { return unit_length_wire_cost_; }
@@ -83,6 +93,7 @@ class Design
8393
odb::dbBlock* block_;
8494
odb::dbTech* tech_;
8595
utl::Logger* logger_;
96+
sta::dbSta* sta_;
8697

8798
// For detailed routing
8899
CostT unit_length_wire_cost_;
@@ -96,6 +107,7 @@ class Design
96107
const Constants constants_;
97108
const int min_routing_layer_;
98109
const int max_routing_layer_;
110+
std::set<odb::dbNet*> clock_nets_;
99111
};
100112

101113
} // namespace grt

0 commit comments

Comments
 (0)