Add router1 cfg.useEstimate, improve getActualRouteDelay

Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
Clifford Wolf 2018-08-04 11:57:34 +02:00
parent 086bc941a8
commit af74f6e511
3 changed files with 31 additions and 8 deletions

View File

@ -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<WireId, PipId> *route = nullptr, bool useEstimate = true);
// --------------------------------------------------------------

View File

@ -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<WireId, PipId> *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

View File

@ -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);