From af74f6e51136394d60384f736718056aaf422060 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sat, 4 Aug 2018 11:57:34 +0200 Subject: [PATCH] Add router1 cfg.useEstimate, improve getActualRouteDelay Signed-off-by: Clifford Wolf --- common/nextpnr.h | 3 ++- common/router1.cc | 35 ++++++++++++++++++++++++++++------- common/router1.h | 1 + 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/common/nextpnr.h b/common/nextpnr.h index c87a98d9..ba45c195 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -484,7 +484,8 @@ struct Context : Arch, DeterministicRNG delay_t getNetinfoRouteDelay(const NetInfo *net_info, const PortRef &sink) const; // provided by router1.cc - bool getActualRouteDelay(WireId src_wire, WireId dst_wire, delay_t &delay); + bool getActualRouteDelay(WireId src_wire, WireId dst_wire, delay_t &delay, + std::unordered_map *route = nullptr, bool useEstimate = true); // -------------------------------------------------------------- diff --git a/common/router1.cc b/common/router1.cc index 6e352866..ad2d7c9e 100644 --- a/common/router1.cc +++ b/common/router1.cc @@ -130,7 +130,8 @@ struct Router qw.wire = it.first; qw.pip = PipId(); qw.delay = it.second - (it.second / 16); - qw.togo = ctx->estimateDelay(qw.wire, dst_wire); + if (cfg.useEstimate) + qw.togo = ctx->estimateDelay(qw.wire, dst_wire); qw.randtag = ctx->rng(); queue.push(qw); @@ -216,7 +217,8 @@ struct Router next_qw.wire = next_wire; next_qw.pip = pip; next_qw.delay = next_delay; - next_qw.togo = ctx->estimateDelay(next_wire, dst_wire); + if (cfg.useEstimate) + next_qw.togo = ctx->estimateDelay(next_wire, dst_wire); next_qw.randtag = ctx->rng(); visited[next_qw.wire] = next_qw; @@ -945,13 +947,32 @@ bool router1(Context *ctx, const Router1Cfg &cfg) } } -bool Context::getActualRouteDelay(WireId src_wire, WireId dst_wire, delay_t &delay) +bool Context::getActualRouteDelay(WireId src_wire, WireId dst_wire, delay_t &delay, + std::unordered_map *route, bool useEstimate) { RipupScoreboard scores; - Router router(this, Router1Cfg(), scores, src_wire, dst_wire); - if (router.routedOkay) - delay = router.visited.at(dst_wire).delay; - return router.routedOkay; + Router1Cfg cfg; + cfg.useEstimate = useEstimate; + + Router router(this, cfg, scores, src_wire, dst_wire); + + if (!router.routedOkay) + return false; + + delay = router.visited.at(dst_wire).delay; + + if (route != nullptr) { + WireId cursor = dst_wire; + while (1) { + PipId pip = router.visited.at(cursor).pip; + (*route)[cursor] = pip; + if (pip == PipId()) + break; + cursor = getPipSrcWire(pip); + } + } + + return true; } NEXTPNR_NAMESPACE_END diff --git a/common/router1.h b/common/router1.h index a9e84b6b..0380adc2 100644 --- a/common/router1.h +++ b/common/router1.h @@ -29,6 +29,7 @@ struct Router1Cfg int maxIterCnt = 200; bool cleanupReroute = true; bool fullCleanupReroute = true; + bool useEstimate = true; }; extern bool router1(Context *ctx, const Router1Cfg &cfg);