aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2020-02-01 15:37:50 +0000
committerDavid Shah <dave@ds0.me>2020-03-22 21:17:59 +0000
commit4b54253c24e6d1bae4dc25e95c25ef95d8d07086 (patch)
tree1a1c6c7729d5fb747ebfc8e36af11bc6592fb2c2 /common
parenta621e04062c1ce73c3df8552793f705807257a3b (diff)
downloadnextpnr-4b54253c24e6d1bae4dc25e95c25ef95d8d07086.tar.gz
nextpnr-4b54253c24e6d1bae4dc25e95c25ef95d8d07086.tar.bz2
nextpnr-4b54253c24e6d1bae4dc25e95c25ef95d8d07086.zip
router2: Prevent overflow
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'common')
-rw-r--r--common/router2.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/common/router2.cc b/common/router2.cc
index 00760c78..26e78eaa 100644
--- a/common/router2.cc
+++ b/common/router2.cc
@@ -747,7 +747,7 @@ struct Router2
total_wire_use += int(wire.bound_nets.size());
int overuse = int(wire.bound_nets.size()) - 1;
if (overuse > 0) {
- wire.hist_cong_cost += overuse * hist_cong_weight;
+ wire.hist_cong_cost = std::min(1e9, wire.hist_cong_cost + overuse * hist_cong_weight);
total_overuse += overuse;
overused_wires += 1;
for (auto &bound : wire.bound_nets)
@@ -1082,7 +1082,8 @@ struct Router2
log_info(" iter=%d wires=%d overused=%d overuse=%d archfail=%s\n", iter, total_wire_use, overused_wires,
total_overuse, overused_wires > 0 ? "NA" : std::to_string(arch_fail).c_str());
++iter;
- curr_cong_weight *= cfg.curr_cong_mult;
+ if (curr_cong_weight < 1e9)
+ curr_cong_weight *= cfg.curr_cong_mult;
} while (!failed_nets.empty());
if (cfg.perf_profile) {
std::vector<std::pair<int, IdString>> nets_by_runtime;