aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2019-02-25 11:03:59 +0000
committerDavid Shah <dave@ds0.me>2019-02-25 11:49:25 +0000
commit89de4caf6c1c97bd22cdd79abe24788ec3bb3665 (patch)
treee57706e9baca1d464d60485723c78ecd89625e03
parent4ec2bd1e5deebf738e35ecf594a958cb0166f4af (diff)
downloadnextpnr-89de4caf6c1c97bd22cdd79abe24788ec3bb3665.tar.gz
nextpnr-89de4caf6c1c97bd22cdd79abe24788ec3bb3665.tar.bz2
nextpnr-89de4caf6c1c97bd22cdd79abe24788ec3bb3665.zip
timing: Fix negative slack overflow issue
Signed-off-by: David Shah <dave@ds0.me>
-rw-r--r--common/timing.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/common/timing.cc b/common/timing.cc
index db38b11b..8ade2660 100644
--- a/common/timing.cc
+++ b/common/timing.cc
@@ -611,8 +611,9 @@ struct Timing
continue;
delay_t dmax = crit_path->at(ClockPair{startdomain.first, startdomain.first}).path_delay;
for (size_t i = 0; i < net->users.size(); i++) {
- float criticality = 1.0f - (float(nc.slack.at(i) - worst_slack.at(startdomain.first)) / dmax);
- nc.criticality.at(i) = criticality;
+ float criticality =
+ 1.0f - ((float(nc.slack.at(i)) - float(worst_slack.at(startdomain.first))) / dmax);
+ nc.criticality.at(i) = std::min<double>(1.0, std::max<double>(0.0, criticality));
}
nc.max_path_length = nd.max_path_length;
nc.cd_worst_slack = worst_slack.at(startdomain.first);