From af74f6e51136394d60384f736718056aaf422060 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sat, 4 Aug 2018 11:57:34 +0200 Subject: 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(-) (limited to 'common') 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); -- cgit v1.2.3 From bd36cc12755e4c90cfdaaa593e5af31c5ba38fa5 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sat, 4 Aug 2018 13:41:42 +0200 Subject: Refactor ice40 timing fuzzer used to create delay estimates Signed-off-by: Clifford Wolf --- common/nextpnr.h | 2 +- common/router1.cc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/nextpnr.h b/common/nextpnr.h index ba45c195..bb55d4ff 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -484,7 +484,7 @@ 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 = nullptr, std::unordered_map *route = nullptr, bool useEstimate = true); // -------------------------------------------------------------- diff --git a/common/router1.cc b/common/router1.cc index ad2d7c9e..03a06072 100644 --- a/common/router1.cc +++ b/common/router1.cc @@ -947,7 +947,7 @@ 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; @@ -959,7 +959,8 @@ bool Context::getActualRouteDelay(WireId src_wire, WireId dst_wire, delay_t &del if (!router.routedOkay) return false; - delay = router.visited.at(dst_wire).delay; + if (delay != nullptr) + *delay = router.visited.at(dst_wire).delay; if (route != nullptr) { WireId cursor = dst_wire; -- cgit v1.2.3 From 8aaf8456708a1d508b607f3fe1f06953ab14911b Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sat, 4 Aug 2018 17:23:46 +0200 Subject: Quick fix for router bug in unrouting a conflicting pip Signed-off-by: Clifford Wolf --- common/router1.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/router1.cc b/common/router1.cc index 03a06072..f5132941 100644 --- a/common/router1.cc +++ b/common/router1.cc @@ -422,7 +422,9 @@ struct Router NPNR_ASSERT(ripup); NPNR_ASSERT(conflicting_pip_net != net_name); - ctx->unbindPip(pip); + if (ctx->getBoundPipNet(pip) == conflicting_pip_net) + ctx->unbindPip(pip); + if (!ctx->checkPipAvail(pip)) ripup_net(ctx, conflicting_pip_net); -- cgit v1.2.3