Skip to content

Commit 44634f3

Browse files
committed
fix crash on balance levels graph building
Signed-off-by: arthurjolo <arthurjl@precisioninno.com>
1 parent 30edbc8 commit 44634f3

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

src/cts/include/cts/TritonCTS.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ class TritonCTS
221221
std::set<odb::dbNet*> visitedClockNets_;
222222
std::map<odb::dbInst*, ClockInst*> inst2clkbuf_;
223223
std::map<ClockInst*, ClockSubNet*> driver2subnet_;
224+
std::map<odb::dbNet*, TreeBuilder*> net2builder_;
224225

225226
// db vars
226227
odb::dbDatabase* db_ = nullptr;

src/cts/src/LatencyBalancer.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ void LatencyBalancer::buildGraph(odb::dbNet* clkInputNet)
158158

159159
for (odb::dbITerm* sinkIterm : driverNet->getITerms()) {
160160
if (sinkIterm->getIoType() == odb::dbIoType::INPUT) {
161+
if (!propagateClock(sinkIterm)) {
162+
continue;
163+
}
161164
int sinkId = graph_.size();
162165
odb::dbInst* sinkInst = sinkIterm->getInst();
163166
std::string sinkName = sinkInst->getName();
@@ -197,7 +200,7 @@ void LatencyBalancer::buildGraph(odb::dbNet* clkInputNet)
197200
}
198201
}
199202
}
200-
203+
worseDelay_ = std::max(worseDelay_, (arrival + insDelay));
201204
graph_[sinkId].arrival = arrival + insDelay;
202205
debugPrint(logger_,
203206
CTS,
@@ -288,7 +291,10 @@ float LatencyBalancer::computeAveSinkArrivals(TreeBuilder* builder)
288291
odb::dbITerm* iterm = sink.getDbInputPin();
289292
computeSinkArrivalRecur(topInputClockNet, iterm, sumArrivals, numSinks);
290293
});
291-
float aveArrival = sumArrivals / (float) numSinks;
294+
float aveArrival = 0.0;
295+
if(numSinks) {
296+
aveArrival = sumArrivals / (float) numSinks;
297+
}
292298
builder->setAveSinkArrival(aveArrival);
293299
debugPrint(logger_,
294300
CTS,

src/cts/src/TritonCTS.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ void TritonCTS::initOneClockTree(odb::dbNet* driverNet,
302302
} else {
303303
clockBuilder = initClock(driverNet, clkInputNet, sdcClockName, parent);
304304
}
305+
if(clockBuilder != nullptr && net2builder_[clkInputNet] == nullptr) {
306+
net2builder_[clkInputNet] = clockBuilder;
307+
}
305308
// Treat gated clocks as separate clock trees
306309
// TODO: include sinks from gated clocks together with other sinks and build
307310
// one clock tree
@@ -317,8 +320,13 @@ void TritonCTS::initOneClockTree(odb::dbNet* driverNet,
317320
if (visitedClockNets_.find(outputNet) == visitedClockNets_.end()
318321
&& !openSta_->sdc()->isLeafPinClock(
319322
network_->dbToSta(outputPin))) {
320-
initOneClockTree(
321-
outputNet, clkInputNet, sdcClockName, clockBuilder);
323+
if(clockBuilder == nullptr && net2builder_[clkInputNet] != nullptr) {
324+
initOneClockTree(
325+
outputNet, clkInputNet, sdcClockName, net2builder_[clkInputNet]);
326+
} else {
327+
initOneClockTree(
328+
outputNet, clkInputNet, sdcClockName, clockBuilder);
329+
}
322330
}
323331
}
324332
}

0 commit comments

Comments
 (0)