Skip to content

Commit ae0a928

Browse files
[TritonCTS] Updated CTS tests and interface
1 parent 5466361 commit ae0a928

21 files changed

+67
-171176
lines changed

src/TritonCTS/src/CtsOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#define PARAMETERSFORCTS_H
4545

4646
#include "Util.h"
47+
#include "db.h"
4748

4849
#include <string>
4950
#include <iostream>
@@ -114,6 +115,8 @@ class CtsOptions {
114115
bool runPostCtsOpt() { return _runPostCtsOpt; }
115116
void setBufDistRatio(double ratio) { _bufDistRatio = ratio; }
116117
double getBufDistRatio() { return _bufDistRatio; }
118+
void setClockNetsObjs(std::vector<odb::dbNet*> nets) { _clockNetsObjs = nets; }
119+
std::vector<odb::dbNet*> getClockNetsObjs() const { return _clockNetsObjs; }
117120

118121
private:
119122
std::string _blockName = "";
@@ -146,6 +149,7 @@ class CtsOptions {
146149
double _bufDistRatio = 0.1;
147150

148151
std::vector<std::string> _bufferList;
152+
std::vector<odb::dbNet*> _clockNetsObjs;
149153
};
150154

151155
}

src/TritonCTS/src/DbWrapper.cpp

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -89,39 +89,22 @@ void DbWrapper::initAllClocks() {
8989
_openSta->findClkNets(clockNets);
9090

9191
//Checks the user input in case there are other nets that need to be added to the set.
92-
std::vector<std::string> clockNetNames;
93-
parseClockNames(clockNetNames);
94-
95-
for (const std::string& name: clockNetNames) {
96-
odb::dbNet* net = _block->findNet(name.c_str());
97-
if (!net) {
98-
odb::dbITerm* iterm = _block->findITerm(name.c_str());
99-
if (!iterm) {
100-
std::cout << " [WARNING] Net \"" << name << "\" not in design. Skipping...\n";
101-
continue;
102-
}
103-
net = iterm->getNet();
104-
}
105-
if (!net) {
106-
std::cout << " [WARNING] Net \"" << name << "\" not in design. Skipping...\n";
107-
continue;
108-
}
92+
std::vector<odb::dbNet*> inputClkNets = _options->getClockNetsObjs();
93+
94+
for (odb::dbNet* net : inputClkNets) {
10995
//Since a set is unique, only the nets not found by dbSta are added.
11096
clockNets.insert(net);
11197
}
98+
99+
//Iterate over all the nets found by the user-input and dbSta
112100
for (odb::dbNet* net : clockNets){
113-
if (!net) {
114-
odb::dbITerm* iterm = _block->findITerm(net->getName().c_str());
115-
net = iterm->getNet();
101+
if (net != nullptr) {
102+
std::cout << " Net \"" << net->getName() << "\" found\n";
103+
//Initializes the net in TritonCTS. If the number of sinks is less than 2, the net is discarded.
104+
initClock(net);
105+
} else {
106+
std::cout << " [WARNING] A net was not found in the design. Skipping...\n";
116107
}
117-
if (!net) {
118-
std::cout << " [WARNING] Net \"" << net->getName() << "\" not in design. Skipping...\n";
119-
continue;
120-
}
121-
122-
std::cout << " Net \"" << net->getName() << "\" found\n";
123-
//Initializes the net in TritonCTS. If the number of sinks is less than 2, the net is discarded.
124-
initClock(net);
125108
}
126109

127110
if (getNumClocks() <= 0) {
@@ -137,7 +120,7 @@ void DbWrapper::initClock(odb::dbNet* net) {
137120
std::string driver = "";
138121
odb::dbITerm* iterm = net->getFirstOutput();
139122
int xPin, yPin;
140-
if (!iterm) {
123+
if (iterm == nullptr) {
141124
odb::dbBTerm* bterm = net->get1stBTerm(); // Clock pin
142125
driver = bterm->getConstName();
143126
bterm->getFirstPinLocation(xPin, yPin);
@@ -158,11 +141,8 @@ void DbWrapper::initClock(odb::dbNet* net) {
158141
driver,
159142
xPin, yPin);
160143

161-
odb::dbSet<odb::dbITerm> iterms = net->getITerms();
162-
odb::dbSet<odb::dbITerm>::iterator itr;
163-
for (itr = iterms.begin(); itr != iterms.end(); ++itr) {
164-
odb::dbITerm* iterm = *itr;
165-
144+
for (odb::dbITerm* iterm : net->getITerms()) {
145+
166146
if (!(iterm->isInputSignal())) {
167147
continue;
168148
}

src/TritonCTS/src/TritonCTSKernel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class TritonCTSKernel {
9393
void export_characterization(const char* file);
9494
void set_root_buffer(const char* buffer);
9595
void set_buffer_list(const char* buffers);
96-
void set_clock_nets(const char* names);
96+
int set_clock_nets(const char* names);
9797
void set_wire_segment_distance_unit(unsigned unit);
9898
void set_max_char_slew(double slew);
9999
void set_max_char_cap(double cap);

src/TritonCTS/src/TritonCTSKernelTcl.cpp

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242

4343
#include "TritonCTSKernel.h"
4444

45+
// DB includes
46+
#include "db.h"
47+
4548
#include <iostream>
4649
#include <iterator>
4750
#include <sstream>
@@ -61,8 +64,45 @@ void TritonCTSKernel::set_sol_list_file(const char* file) {
6164
_options.setSolListFile(file);
6265
}
6366

64-
void TritonCTSKernel::set_clock_nets(const char* names) {
67+
int TritonCTSKernel::set_clock_nets(const char* names) {
68+
odb::dbDatabase* db = odb::dbDatabase::getDatabase(_options.getDbId());
69+
odb::dbChip* chip = db->getChip();
70+
odb::dbBlock* block = chip->getBlock();
71+
6572
_options.setClockNets(names);
73+
std::stringstream ss(names);
74+
std::istream_iterator<std::string> begin(ss);
75+
std::istream_iterator<std::string> end;
76+
std::vector<std::string> nets(begin, end);
77+
78+
std::vector<odb::dbNet*> netObjects;
79+
80+
for (std::string name : nets){
81+
odb::dbNet* net = block->findNet(name.c_str());
82+
bool netFound = false;
83+
if (net != nullptr) {
84+
//Since a set is unique, only the nets not found by dbSta are added.
85+
netObjects.push_back(net);
86+
netFound = true;
87+
} else {
88+
//User input was a pin, transform it into an iterm if possible
89+
odb::dbITerm* iterm = block->findITerm(name.c_str());
90+
if (iterm != nullptr) {
91+
net = iterm->getNet();
92+
if (net != nullptr) {
93+
//Since a set is unique, only the nets not found by dbSta are added.
94+
netObjects.push_back(net);
95+
netFound = true;
96+
}
97+
}
98+
99+
}
100+
if (!netFound) {
101+
return 1;
102+
}
103+
}
104+
_options.setClockNetsObjs(netObjects);
105+
return 0;
66106
}
67107

68108
void TritonCTSKernel::set_max_char_cap(double cap) {

src/TritonCTS/src/tritoncts.tcl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ proc clock_tree_synthesis { args } {
113113

114114
if { [info exists keys(-clk_nets)] } {
115115
set clk_nets $keys(-clk_nets)
116-
$cts set_clock_nets $clk_nets
116+
set fail [$cts set_clock_nets $clk_nets]
117+
if {$fail} {
118+
puts "Error when finding -clk_nets in DB!"
119+
exit
120+
}
117121
}
118122

119123
if { [info exists keys(-slew_inter)] } {

src/TritonCTS/test/regression

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ do
3131
fi
3232

3333
cd $unit_test_path
34+
ln -s $testdir/../../../test/Nangate45
3435
$test_script $binary
36+
unlink Nangate45
3537
test_return_code=$?
3638
cd $test_root
3739

0 commit comments

Comments
 (0)