aboutsummaryrefslogtreecommitdiffstats
path: root/common/route.cc
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-06-21 17:56:45 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-06-21 17:56:45 +0200
commit8fac26c2b795865098b1ba16152cd1c510133f29 (patch)
tree1b0d9a48c1198fc8cfd5f2ef6253104e93c54048 /common/route.cc
parent54549d36e911aac8d0b0a2eea6074654c06c9717 (diff)
downloadnextpnr-8fac26c2b795865098b1ba16152cd1c510133f29.tar.gz
nextpnr-8fac26c2b795865098b1ba16152cd1c510133f29.tar.bz2
nextpnr-8fac26c2b795865098b1ba16152cd1c510133f29.zip
Fixed return codes for packer, placer and router
Diffstat (limited to 'common/route.cc')
-rw-r--r--common/route.cc332
1 files changed, 171 insertions, 161 deletions
diff --git a/common/route.cc b/common/route.cc
index 69a314d7..e747f09c 100644
--- a/common/route.cc
+++ b/common/route.cc
@@ -395,230 +395,240 @@ 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, 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;
+ 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, netCnt = 0;
- if (ctx->verbose)
- log_info(" routing pass visited %d PIPs (%.2f%% revisits).\n",
- visitCnt, (100.0 * revisitCnt) / 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;
- 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;
- 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(" routing pass visited %d PIPs (%.2f%% revisits).\n",
visitCnt, (100.0 * revisitCnt) / 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;
+ 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;
+
+ 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(" routing pass visited %d PIPs (%.2f%% "
+ "revisits).\n",
+ visitCnt, (100.0 * revisitCnt) / 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,