diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-06-21 19:31:50 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-06-21 19:31:50 +0200 |
commit | bfae4663fcb6028e8c20f28d5ffa15fd20d8e1fa (patch) | |
tree | b5dd0075a7a75ef9c24e0f758b80b5da5ee18b3f /common | |
parent | 38dc1cc5504961f666da32d7249532a23d5876ad (diff) | |
parent | c33a039ac388bfcb5e068a04a7cb1b05ebec7d7f (diff) | |
download | nextpnr-bfae4663fcb6028e8c20f28d5ffa15fd20d8e1fa.tar.gz nextpnr-bfae4663fcb6028e8c20f28d5ffa15fd20d8e1fa.tar.bz2 nextpnr-bfae4663fcb6028e8c20f28d5ffa15fd20d8e1fa.zip |
Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr
# Conflicts:
# common/route.cc
Diffstat (limited to 'common')
-rw-r--r-- | common/log.cc | 6 | ||||
-rw-r--r-- | common/log.h | 4 | ||||
-rw-r--r-- | common/place_sa.cc | 12 | ||||
-rw-r--r-- | common/route.cc | 335 |
4 files changed, 185 insertions, 172 deletions
diff --git a/common/log.cc b/common/log.cc index b0cd802a..495f83b1 100644 --- a/common/log.cc +++ b/common/log.cc @@ -150,12 +150,8 @@ void logv_error(const char *format, va_list ap) #ifdef EMSCRIPTEN log_files = backup_log_files; - throw 0; -#elif defined(_MSC_VER) - _exit(EXIT_FAILURE); -#else - _Exit(EXIT_FAILURE); #endif + throw log_execution_error_exception(); } void log(const char *format, ...) diff --git a/common/log.h b/common/log.h index 381843b3..65b3f178 100644 --- a/common/log.h +++ b/common/log.h @@ -43,6 +43,10 @@ struct log_cmd_error_exception { }; +struct log_execution_error_exception +{ +}; + extern std::vector<FILE *> log_files; extern std::vector<std::ostream *> log_streams; extern FILE *log_errfile; diff --git a/common/place_sa.cc b/common/place_sa.cc index 4d0d5d08..69ba968f 100644 --- a/common/place_sa.cc +++ b/common/place_sa.cc @@ -478,10 +478,14 @@ class SAPlacer bool place_design_sa(Context *ctx) { - SAPlacer placer(ctx); - placer.place(); - log_info("Checksum: 0x%08x\n", ctx->checksum()); - return true; + try { + SAPlacer placer(ctx); + placer.place(); + log_info("Checksum: 0x%08x\n", ctx->checksum()); + return true; + } catch (log_execution_error_exception) { + return false; + } } NEXTPNR_NAMESPACE_END diff --git a/common/route.cc b/common/route.cc index 0c072c3a..e6697349 100644 --- a/common/route.cc +++ b/common/route.cc @@ -406,233 +406,242 @@ NEXTPNR_NAMESPACE_BEGIN bool route_design(Context *ctx) { - delay_t ripup_penalty = ctx->getRipupDelayPenalty(); - RipupScoreboard scores; - - log_break(); - log_info("Routing..\n"); - - std::unordered_set<IdString> netsQueue; - - for (auto &net_it : ctx->nets) { - auto net_name = net_it.first; - auto net_info = net_it.second; - - if (net_info->driver.cell == nullptr) - continue; + try { + delay_t ripup_penalty = ctx->getRipupDelayPenalty(); + RipupScoreboard scores; - if (!net_info->wires.empty()) - continue; - - netsQueue.insert(net_name); - } - - if (netsQueue.empty()) { - log_info("found no unrouted nets. no routing necessary.\n"); - return true; - } + log_break(); + log_info("Routing..\n"); - log_info("found %d unrouted nets. starting routing procedure.\n", - int(netsQueue.size())); + std::unordered_set<IdString> netsQueue; - delay_t estimatedTotalDelay = 0.0; - int estimatedTotalDelayCnt = 0; + for (auto &net_it : ctx->nets) { + auto net_name = net_it.first; + auto net_info = net_it.second; - for (auto net_name : netsQueue) { - auto net_info = ctx->nets.at(net_name); + if (net_info->driver.cell == nullptr) + continue; - auto src_bel = net_info->driver.cell->bel; + if (!net_info->wires.empty()) + continue; - if (src_bel == BelId()) - continue; + netsQueue.insert(net_name); + } - IdString driver_port = net_info->driver.port; + if (netsQueue.empty()) { + log_info("found no unrouted nets. no routing necessary.\n"); + return true; + } - auto driver_port_it = net_info->driver.cell->pins.find(driver_port); - if (driver_port_it != net_info->driver.cell->pins.end()) - driver_port = driver_port_it->second; + log_info("found %d unrouted nets. starting routing procedure.\n", + int(netsQueue.size())); - auto src_wire = - ctx->getWireBelPin(src_bel, ctx->portPinFromId(driver_port)); + delay_t estimatedTotalDelay = 0.0; + int estimatedTotalDelayCnt = 0; - if (src_wire == WireId()) - continue; + for (auto net_name : netsQueue) { + auto net_info = ctx->nets.at(net_name); - for (auto &user_it : net_info->users) { - auto dst_bel = user_it.cell->bel; + auto src_bel = net_info->driver.cell->bel; - if (dst_bel == BelId()) + if (src_bel == BelId()) continue; - IdString user_port = user_it.port; - - auto user_port_it = user_it.cell->pins.find(user_port); + IdString driver_port = net_info->driver.port; - if (user_port_it != user_it.cell->pins.end()) - user_port = user_port_it->second; + auto driver_port_it = net_info->driver.cell->pins.find(driver_port); + if (driver_port_it != net_info->driver.cell->pins.end()) + driver_port = driver_port_it->second; - auto dst_wire = - ctx->getWireBelPin(dst_bel, ctx->portPinFromId(user_port)); + auto src_wire = ctx->getWireBelPin(src_bel, + ctx->portPinFromId(driver_port)); - if (dst_wire == WireId()) + if (src_wire == WireId()) continue; - estimatedTotalDelay += ctx->estimateDelay(src_wire, dst_wire); - estimatedTotalDelayCnt++; - } - } + for (auto &user_it : net_info->users) { + auto dst_bel = user_it.cell->bel; - log_info("estimated total wire delay: %.2f (avg %.2f)\n", - float(estimatedTotalDelay), - float(estimatedTotalDelay) / estimatedTotalDelayCnt); + if (dst_bel == BelId()) + continue; - int iterCnt = 0; + IdString user_port = user_it.port; - while (!netsQueue.empty()) { - if (iterCnt == 200) { - log_warning("giving up after %d iterations.\n", iterCnt); - log_info("Checksum: 0x%08x\n", ctx->checksum()); - return false; - } - - iterCnt++; - if (ctx->verbose) - log_info("-- %d --\n", iterCnt); - - int visitCnt = 0, revisitCnt = 0, overtimeRevisitCnt = 0, netCnt = 0; + auto user_port_it = user_it.cell->pins.find(user_port); - std::unordered_set<IdString> ripupQueue; + if (user_port_it != user_it.cell->pins.end()) + user_port = user_port_it->second; - if (ctx->verbose || iterCnt == 1) - log_info("routing queue contains %d nets.\n", - int(netsQueue.size())); + auto dst_wire = ctx->getWireBelPin( + dst_bel, ctx->portPinFromId(user_port)); - bool printNets = ctx->verbose && (netsQueue.size() < 10); + if (dst_wire == WireId()) + continue; - std::vector<IdString> netsArray(netsQueue.begin(), netsQueue.end()); - ctx->sorted_shuffle(netsArray); - netsQueue.clear(); - - for (auto net_name : netsArray) { - if (printNets) - log_info(" routing net %s. (%d users)\n", net_name.c_str(ctx), - int(ctx->nets.at(net_name)->users.size())); + estimatedTotalDelay += ctx->estimateDelay(src_wire, dst_wire); + estimatedTotalDelayCnt++; + } + } - Router router(ctx, scores, net_name, false); + log_info("estimated total wire delay: %.2f (avg %.2f)\n", + float(estimatedTotalDelay), + float(estimatedTotalDelay) / estimatedTotalDelayCnt); - netCnt++; - visitCnt += router.visitCnt; - revisitCnt += router.revisitCnt; - overtimeRevisitCnt += router.overtimeRevisitCnt; + int iterCnt = 0; - if (!router.routedOkay) { - if (printNets) - log_info(" failed to route to %s.\n", - ctx->getWireName(router.failedDest).c_str(ctx)); - ripupQueue.insert(net_name); + while (!netsQueue.empty()) { + if (iterCnt == 200) { + log_warning("giving up after %d iterations.\n", iterCnt); + log_info("Checksum: 0x%08x\n", ctx->checksum()); + return false; } - if ((ctx->verbose || iterCnt == 1) && !printNets && - (netCnt % 100 == 0)) - log_info(" processed %d nets. (%d routed, %d failed)\n", - netCnt, netCnt - int(ripupQueue.size()), - int(ripupQueue.size())); - } - - int normalRouteCnt = netCnt - int(ripupQueue.size()); + iterCnt++; + if (ctx->verbose) + log_info("-- %d --\n", iterCnt); - if ((ctx->verbose || iterCnt == 1) && (netCnt % 100 != 0)) - log_info(" processed %d nets. (%d routed, %d failed)\n", netCnt, - normalRouteCnt, int(ripupQueue.size())); + int visitCnt = 0, revisitCnt = 0, overtimeRevisitCnt = 0, netCnt = 0; - if (ctx->verbose) - log_info(" visited %d PIPs (%.2f%% revisits, %.2f%% overtime revisits).\n", - visitCnt, (100.0 * revisitCnt) / visitCnt, (100.0 * overtimeRevisitCnt) / visitCnt); + std::unordered_set<IdString> ripupQueue; - if (!ripupQueue.empty()) { if (ctx->verbose || iterCnt == 1) - log_info("failed to route %d nets. re-routing in ripup mode.\n", - int(ripupQueue.size())); - - printNets = ctx->verbose && (ripupQueue.size() < 10); + log_info("routing queue contains %d nets.\n", + int(netsQueue.size())); - visitCnt = 0; - revisitCnt = 0; - overtimeRevisitCnt = 0; - netCnt = 0; - int ripCnt = 0; + bool printNets = ctx->verbose && (netsQueue.size() < 10); - std::vector<IdString> ripupArray(ripupQueue.begin(), - ripupQueue.end()); - ctx->sorted_shuffle(ripupArray); + std::vector<IdString> netsArray(netsQueue.begin(), netsQueue.end()); + ctx->sorted_shuffle(netsArray); + netsQueue.clear(); - for (auto net_name : ripupArray) { + for (auto net_name : netsArray) { if (printNets) log_info(" routing net %s. (%d users)\n", net_name.c_str(ctx), int(ctx->nets.at(net_name)->users.size())); - Router router(ctx, scores, net_name, true, ripup_penalty); + Router router(ctx, scores, net_name, false); netCnt++; visitCnt += router.visitCnt; revisitCnt += router.revisitCnt; overtimeRevisitCnt += router.overtimeRevisitCnt; - if (!router.routedOkay) - log_error("Net %s is impossible to route.\n", - net_name.c_str(ctx)); - - for (auto it : router.rippedNets) - netsQueue.insert(it); - - if (printNets) { - if (router.rippedNets.size() < 10) { - log_info(" ripped up %d other nets:\n", - int(router.rippedNets.size())); - for (auto n : router.rippedNets) - log_info(" %s (%d users)\n", n.c_str(ctx), - int(ctx->nets.at(n)->users.size())); - } else { - log_info(" ripped up %d other nets.\n", - int(router.rippedNets.size())); - } + if (!router.routedOkay) { + if (printNets) + log_info( + " failed to route to %s.\n", + ctx->getWireName(router.failedDest).c_str(ctx)); + ripupQueue.insert(net_name); } - ripCnt += router.rippedNets.size(); - if ((ctx->verbose || iterCnt == 1) && !printNets && (netCnt % 100 == 0)) - log_info(" routed %d nets, ripped %d nets.\n", netCnt, - ripCnt); + log_info(" processed %d nets. (%d routed, %d failed)\n", + netCnt, netCnt - int(ripupQueue.size()), + int(ripupQueue.size())); } + int normalRouteCnt = netCnt - int(ripupQueue.size()); + if ((ctx->verbose || iterCnt == 1) && (netCnt % 100 != 0)) - log_info(" routed %d nets, ripped %d nets.\n", netCnt, ripCnt); + log_info(" processed %d nets. (%d routed, %d failed)\n", + netCnt, normalRouteCnt, int(ripupQueue.size())); if (ctx->verbose) log_info(" visited %d PIPs (%.2f%% revisits, %.2f%% overtime revisits).\n", visitCnt, (100.0 * revisitCnt) / visitCnt, (100.0 * overtimeRevisitCnt) / visitCnt); - if (ctx->verbose && !netsQueue.empty()) - log_info(" ripped up %d previously routed nets. continue " - "routing.\n", - int(netsQueue.size())); - } + if (!ripupQueue.empty()) { + if (ctx->verbose || iterCnt == 1) + log_info("failed to route %d nets. re-routing in ripup " + "mode.\n", + int(ripupQueue.size())); + + printNets = ctx->verbose && (ripupQueue.size() < 10); + + visitCnt = 0; + revisitCnt = 0; + overtimeRevisitCnt = 0; + netCnt = 0; + int ripCnt = 0; + + std::vector<IdString> ripupArray(ripupQueue.begin(), + ripupQueue.end()); + ctx->sorted_shuffle(ripupArray); + + for (auto net_name : ripupArray) { + if (printNets) + log_info(" routing net %s. (%d users)\n", + net_name.c_str(ctx), + int(ctx->nets.at(net_name)->users.size())); + + Router router(ctx, scores, net_name, true, ripup_penalty); + + netCnt++; + visitCnt += router.visitCnt; + revisitCnt += router.revisitCnt; + overtimeRevisitCnt += router.overtimeRevisitCnt; + + if (!router.routedOkay) + log_error("Net %s is impossible to route.\n", + net_name.c_str(ctx)); + + for (auto it : router.rippedNets) + netsQueue.insert(it); + + if (printNets) { + if (router.rippedNets.size() < 10) { + log_info(" ripped up %d other nets:\n", + int(router.rippedNets.size())); + for (auto n : router.rippedNets) + log_info(" %s (%d users)\n", n.c_str(ctx), + int(ctx->nets.at(n)->users.size())); + } else { + log_info(" ripped up %d other nets.\n", + int(router.rippedNets.size())); + } + } - if (!ctx->verbose) - log_info("iteration %d: routed %d nets without ripup, routed %d " - "nets with ripup.\n", - iterCnt, normalRouteCnt, int(ripupQueue.size())); + ripCnt += router.rippedNets.size(); - if (iterCnt == 8 || iterCnt == 16 || iterCnt == 32 || iterCnt == 64 || - iterCnt == 128) - ripup_penalty += ctx->getRipupDelayPenalty(); - } + if ((ctx->verbose || iterCnt == 1) && !printNets && + (netCnt % 100 == 0)) + log_info(" routed %d nets, ripped %d nets.\n", netCnt, + ripCnt); + } + + if ((ctx->verbose || iterCnt == 1) && (netCnt % 100 != 0)) + log_info(" routed %d nets, ripped %d nets.\n", netCnt, + ripCnt); - log_info("routing complete after %d iterations.\n", iterCnt); - log_info("Checksum: 0x%08x\n", ctx->checksum()); - return true; + if (ctx->verbose) + log_info(" visited %d PIPs (%.2f%% revisits, %.2f%% overtime revisits).\n", + visitCnt, (100.0 * revisitCnt) / visitCnt, (100.0 * overtimeRevisitCnt) / visitCnt); + + if (ctx->verbose && !netsQueue.empty()) + log_info(" ripped up %d previously routed nets. continue " + "routing.\n", + int(netsQueue.size())); + } + + if (!ctx->verbose) + log_info( + "iteration %d: routed %d nets without ripup, routed %d " + "nets with ripup.\n", + iterCnt, normalRouteCnt, int(ripupQueue.size())); + + if (iterCnt == 8 || iterCnt == 16 || iterCnt == 32 || + iterCnt == 64 || iterCnt == 128) + ripup_penalty += ctx->getRipupDelayPenalty(); + } + + log_info("routing complete after %d iterations.\n", iterCnt); + log_info("Checksum: 0x%08x\n", ctx->checksum()); + return true; + } catch (log_execution_error_exception) { + return false; + } } bool get_actual_route_delay(Context *ctx, WireId src_wire, WireId dst_wire, |