Fix delay function used for update_budget()

This commit is contained in:
Eddie Hung 2018-07-21 18:04:54 -07:00
parent 5aa4cf2efb
commit e92698f32e

View File

@ -736,16 +736,29 @@ bool router1(Context *ctx)
log_info("routing queue contains %d jobs.\n", int(jobQueue.size())); log_info("routing queue contains %d jobs.\n", int(jobQueue.size()));
} else { } else {
static auto actual_delay = [](Context *ctx, WireId src, WireId dst) { static auto actual_delay = [](Context *ctx, WireId src, WireId dst) {
delay_t total_delay = ctx->getWireDelay(dst).maxDelay(); delay_t total_delay = 0;
WireId last_wire = dst; WireId last = dst;
for (auto pip : ctx->getPipsDownhill(dst)) { auto net_name = ctx->getBoundWireNet(src);
total_delay += ctx->getPipDelay(pip).maxDelay(); if (net_name != IdString()) {
WireId next_wire = ctx->getPipDstWire(pip); auto net = ctx->nets.at(net_name).get();
total_delay += ctx->getWireDelay(next_wire).maxDelay(); while (last != src) {
total_delay += ctx->getWireDelay(last).maxDelay();
auto pip = net->wires.at(last).pip;
NPNR_ASSERT(ctx->getBoundPipNet(pip) == net_name);
total_delay += ctx->getPipDelay(pip).maxDelay();
last = ctx->getPipSrcWire(pip);
if (ctx->getBoundWireNet(last) != net_name) {
log_warning("Wire %s bound to %s not %s!\n", ctx->getWireName(last).c_str(ctx), ctx->getBoundWireNet(last).c_str(ctx), net_name.c_str(ctx));
break;
}
NPNR_ASSERT(ctx->getBoundWireNet(last) == net_name);
}
NPNR_ASSERT(last != WireId());
} }
NPNR_ASSERT(last_wire != WireId()); if (last != src)
if (last_wire != src) total_delay += ctx->estimateDelay(src, last);
total_delay += ctx->estimateDelay(src, last_wire); else
total_delay += ctx->getWireDelay(last).maxDelay();
return total_delay; return total_delay;
}; };
update_budget(ctx, actual_delay); update_budget(ctx, actual_delay);