ecp5: Fixing global router bugs

Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
David Shah 2018-09-29 17:01:19 +01:00
parent 2a0bb2be29
commit 9ff5d5a735

View File

@ -198,17 +198,19 @@ class Ecp5GlobalRouter
visit.push(src); visit.push(src);
WireId cursor; WireId cursor;
while (true) { while (true) {
if (visit.empty() || visit.size() > 50000) { if (visit.empty() || visit.size() > 50000) {
if (allow_fail) if (allow_fail)
return false; return false;
log_error("cannot route global from %s to %s.\n", ctx->getWireName(src).c_str(ctx), log_error("cannot route global from %s to %s.\n", ctx->getWireName(src).c_str(ctx),
ctx->getWireName(dst).c_str(ctx)); ctx->getWireName(dst).c_str(ctx));
} }
cursor = visit.back(); cursor = visit.front();
visit.pop(); visit.pop();
NetInfo *bound = ctx->getBoundWireNet(cursor); NetInfo *bound = ctx->getBoundWireNet(cursor);
if (ctx->verbose)
log_info(" exploring %s\n", ctx->getWireName(cursor).c_str(ctx));
if (bound == net) { if (bound == net) {
break;
} else if (bound != nullptr) { } else if (bound != nullptr) {
continue; continue;
} }
@ -216,6 +218,8 @@ class Ecp5GlobalRouter
break; break;
for (auto dh : ctx->getPipsDownhill(cursor)) { for (auto dh : ctx->getPipsDownhill(cursor)) {
WireId pipDst = ctx->getPipDstWire(dh); WireId pipDst = ctx->getPipDstWire(dh);
if (ctx->verbose)
log_info(" downhill -> %s\n", ctx->getWireName(pipDst).c_str(ctx));
if (backtrace.count(pipDst)) if (backtrace.count(pipDst))
continue; continue;
backtrace[pipDst] = dh; backtrace[pipDst] = dh;
@ -226,9 +230,16 @@ class Ecp5GlobalRouter
auto fnd = backtrace.find(cursor); auto fnd = backtrace.find(cursor);
if (fnd == backtrace.end()) if (fnd == backtrace.end())
break; break;
NetInfo * bound = ctx->getBoundWireNet(cursor);
if (bound != nullptr) {
NPNR_ASSERT(bound == net);
break;
}
ctx->bindPip(fnd->second, net, STRENGTH_LOCKED); ctx->bindPip(fnd->second, net, STRENGTH_LOCKED);
cursor = ctx->getPipSrcWire(fnd->second); cursor = ctx->getPipSrcWire(fnd->second);
} }
if (ctx->getBoundWireNet(src) == nullptr)
ctx->bindWire(src, net, STRENGTH_LOCKED);
return true; return true;
} }
@ -294,7 +305,7 @@ class Ecp5GlobalRouter
public: public:
void promote_and_route_globals() { void promote_and_route_globals() {
log_info("Promoting and routing globals..."); log_info("Promoting and routing globals...\n");
auto clocks = get_clocks(); auto clocks = get_clocks();
int glbid = 0; int glbid = 0;
for (auto clock : clocks) { for (auto clock : clocks) {