diff options
author | gatecat <gatecat@ds0.me> | 2021-09-18 10:00:05 +0100 |
---|---|---|
committer | gatecat <gatecat@ds0.me> | 2021-12-18 14:30:48 +0000 |
commit | 53ce8f3736e7e4535c4fb4b323c01cbea95314a9 (patch) | |
tree | 84c751062af2fd5937257305af1b1ee19cb236fe /common/router1.cc | |
parent | f80f56d69ff171d9d1079258a92963cee7d796b5 (diff) | |
download | nextpnr-53ce8f3736e7e4535c4fb4b323c01cbea95314a9.tar.gz nextpnr-53ce8f3736e7e4535c4fb4b323c01cbea95314a9.tar.bz2 nextpnr-53ce8f3736e7e4535c4fb4b323c01cbea95314a9.zip |
router1: Improve timing heuristic
Signed-off-by: gatecat <gatecat@ds0.me>
Diffstat (limited to 'common/router1.cc')
-rw-r--r-- | common/router1.cc | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/common/router1.cc b/common/router1.cc index 0ff2bedd..6977a799 100644 --- a/common/router1.cc +++ b/common/router1.cc @@ -117,14 +117,21 @@ struct Router1 int arcs_without_ripup = 0; bool ripup_flag; - Router1(Context *ctx, const Router1Cfg &cfg) : ctx(ctx), cfg(cfg) {} + TimingAnalyser tmg; + + Router1(Context *ctx, const Router1Cfg &cfg) : ctx(ctx), cfg(cfg), tmg(ctx) + { + tmg.setup(); + tmg.run(); + } void arc_queue_insert(const arc_key &arc, WireId src_wire, WireId dst_wire) { if (queued_arcs.count(arc)) return; - delay_t pri = ctx->estimateDelay(src_wire, dst_wire) - arc.net_info->users[arc.user_idx].budget; + delay_t pri = ctx->estimateDelay(src_wire, dst_wire) * + (100 * tmg.get_criticality(CellPortKey(arc.net_info->users.at(arc.user_idx)))); arc_entry entry; entry.arc = arc; @@ -459,6 +466,8 @@ struct Router1 auto dst_wire = ctx->getNetinfoSinkWire(net_info, net_info->users[user_idx], arc.phys_idx); ripup_flag = false; + float crit = tmg.get_criticality(CellPortKey(net_info->users.at(user_idx))); + if (ctx->debug) { log("Routing arc %d on net %s (%d arcs total):\n", user_idx, ctx->nameOf(net_info), int(net_info->users.size())); @@ -536,6 +545,7 @@ struct Router1 delay_t next_delay = qw.delay + ctx->getPipDelay(pip).maxDelay(); delay_t next_penalty = qw.penalty; delay_t next_bonus = qw.bonus; + delay_t penalty_delta = 0; WireId next_wire = ctx->getPipDstWire(pip); next_delay += ctx->getWireDelay(next_wire).maxDelay(); @@ -544,7 +554,7 @@ struct Router1 NetInfo *conflictWireNet = nullptr, *conflictPipNet = nullptr; if (net_info->wires.count(next_wire) && net_info->wires.at(next_wire).pip == pip) { - next_bonus += cfg.reuseBonus; + next_bonus += cfg.reuseBonus * (1.0 - crit); } else { if (!ctx->checkWireAvail(next_wire)) { if (!ripup) @@ -609,34 +619,36 @@ struct Router1 if (conflictWireWire != WireId()) { auto scores_it = wireScores.find(conflictWireWire); if (scores_it != wireScores.end()) - next_penalty += scores_it->second * cfg.wireRipupPenalty; - next_penalty += cfg.wireRipupPenalty; + penalty_delta += scores_it->second * cfg.wireRipupPenalty; + penalty_delta += cfg.wireRipupPenalty; } if (conflictPipWire != WireId()) { auto scores_it = wireScores.find(conflictPipWire); if (scores_it != wireScores.end()) - next_penalty += scores_it->second * cfg.wireRipupPenalty; - next_penalty += cfg.wireRipupPenalty; + penalty_delta += scores_it->second * cfg.wireRipupPenalty; + penalty_delta += cfg.wireRipupPenalty; } if (conflictWireNet != nullptr) { auto scores_it = netScores.find(conflictWireNet); if (scores_it != netScores.end()) - next_penalty += scores_it->second * cfg.netRipupPenalty; - next_penalty += cfg.netRipupPenalty; - next_penalty += conflictWireNet->wires.size() * cfg.wireRipupPenalty; + penalty_delta += scores_it->second * cfg.netRipupPenalty; + penalty_delta += cfg.netRipupPenalty; + penalty_delta += conflictWireNet->wires.size() * cfg.wireRipupPenalty; } if (conflictPipNet != nullptr) { auto scores_it = netScores.find(conflictPipNet); if (scores_it != netScores.end()) - next_penalty += scores_it->second * cfg.netRipupPenalty; - next_penalty += cfg.netRipupPenalty; - next_penalty += conflictPipNet->wires.size() * cfg.wireRipupPenalty; + penalty_delta += scores_it->second * cfg.netRipupPenalty; + penalty_delta += cfg.netRipupPenalty; + penalty_delta += conflictPipNet->wires.size() * cfg.wireRipupPenalty; } } + next_penalty += penalty_delta * std::max(0.05, (1.0 - crit)); + delay_t next_score = next_delay + next_penalty; NPNR_ASSERT(next_score >= 0); |