Fixed return codes for packer, placer and router
This commit is contained in:
parent
54549d36e9
commit
8fac26c2b7
@ -478,10 +478,14 @@ class SAPlacer
|
|||||||
|
|
||||||
bool place_design_sa(Context *ctx)
|
bool place_design_sa(Context *ctx)
|
||||||
{
|
{
|
||||||
SAPlacer placer(ctx);
|
try {
|
||||||
placer.place();
|
SAPlacer placer(ctx);
|
||||||
log_info("Checksum: 0x%08x\n", ctx->checksum());
|
placer.place();
|
||||||
return true;
|
log_info("Checksum: 0x%08x\n", ctx->checksum());
|
||||||
|
return true;
|
||||||
|
} catch (log_execution_error_exception) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
352
common/route.cc
352
common/route.cc
@ -395,230 +395,240 @@ NEXTPNR_NAMESPACE_BEGIN
|
|||||||
|
|
||||||
bool route_design(Context *ctx)
|
bool route_design(Context *ctx)
|
||||||
{
|
{
|
||||||
delay_t ripup_penalty = ctx->getRipupDelayPenalty();
|
try {
|
||||||
RipupScoreboard scores;
|
delay_t ripup_penalty = ctx->getRipupDelayPenalty();
|
||||||
|
RipupScoreboard scores;
|
||||||
|
|
||||||
log_break();
|
log_break();
|
||||||
log_info("Routing..\n");
|
log_info("Routing..\n");
|
||||||
|
|
||||||
std::unordered_set<IdString> netsQueue;
|
std::unordered_set<IdString> netsQueue;
|
||||||
|
|
||||||
for (auto &net_it : ctx->nets) {
|
for (auto &net_it : ctx->nets) {
|
||||||
auto net_name = net_it.first;
|
auto net_name = net_it.first;
|
||||||
auto net_info = net_it.second;
|
auto net_info = net_it.second;
|
||||||
|
|
||||||
if (net_info->driver.cell == nullptr)
|
if (net_info->driver.cell == nullptr)
|
||||||
continue;
|
|
||||||
|
|
||||||
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_info("found %d unrouted nets. starting routing procedure.\n",
|
|
||||||
int(netsQueue.size()));
|
|
||||||
|
|
||||||
delay_t estimatedTotalDelay = 0.0;
|
|
||||||
int estimatedTotalDelayCnt = 0;
|
|
||||||
|
|
||||||
for (auto net_name : netsQueue) {
|
|
||||||
auto net_info = ctx->nets.at(net_name);
|
|
||||||
|
|
||||||
auto src_bel = net_info->driver.cell->bel;
|
|
||||||
|
|
||||||
if (src_bel == BelId())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
IdString driver_port = net_info->driver.port;
|
|
||||||
|
|
||||||
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 src_wire =
|
|
||||||
ctx->getWireBelPin(src_bel, ctx->portPinFromId(driver_port));
|
|
||||||
|
|
||||||
if (src_wire == WireId())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (auto &user_it : net_info->users) {
|
|
||||||
auto dst_bel = user_it.cell->bel;
|
|
||||||
|
|
||||||
if (dst_bel == BelId())
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
IdString user_port = user_it.port;
|
if (!net_info->wires.empty())
|
||||||
|
|
||||||
auto user_port_it = user_it.cell->pins.find(user_port);
|
|
||||||
|
|
||||||
if (user_port_it != user_it.cell->pins.end())
|
|
||||||
user_port = user_port_it->second;
|
|
||||||
|
|
||||||
auto dst_wire =
|
|
||||||
ctx->getWireBelPin(dst_bel, ctx->portPinFromId(user_port));
|
|
||||||
|
|
||||||
if (dst_wire == WireId())
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
estimatedTotalDelay += ctx->estimateDelay(src_wire, dst_wire);
|
netsQueue.insert(net_name);
|
||||||
estimatedTotalDelayCnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log_info("estimated total wire delay: %.2f (avg %.2f)\n",
|
|
||||||
float(estimatedTotalDelay),
|
|
||||||
float(estimatedTotalDelay) / estimatedTotalDelayCnt);
|
|
||||||
|
|
||||||
int iterCnt = 0;
|
|
||||||
|
|
||||||
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 (netsQueue.empty()) {
|
||||||
if (ctx->verbose)
|
log_info("found no unrouted nets. no routing necessary.\n");
|
||||||
log_info("-- %d --\n", iterCnt);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int visitCnt = 0, revisitCnt = 0, netCnt = 0;
|
log_info("found %d unrouted nets. starting routing procedure.\n",
|
||||||
|
int(netsQueue.size()));
|
||||||
|
|
||||||
std::unordered_set<IdString> ripupQueue;
|
delay_t estimatedTotalDelay = 0.0;
|
||||||
|
int estimatedTotalDelayCnt = 0;
|
||||||
|
|
||||||
if (ctx->verbose || iterCnt == 1)
|
for (auto net_name : netsQueue) {
|
||||||
log_info("routing queue contains %d nets.\n",
|
auto net_info = ctx->nets.at(net_name);
|
||||||
int(netsQueue.size()));
|
|
||||||
|
|
||||||
bool printNets = ctx->verbose && (netsQueue.size() < 10);
|
auto src_bel = net_info->driver.cell->bel;
|
||||||
|
|
||||||
std::vector<IdString> netsArray(netsQueue.begin(), netsQueue.end());
|
if (src_bel == BelId())
|
||||||
ctx->sorted_shuffle(netsArray);
|
continue;
|
||||||
netsQueue.clear();
|
|
||||||
|
|
||||||
for (auto net_name : netsArray) {
|
IdString driver_port = net_info->driver.port;
|
||||||
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, false);
|
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;
|
||||||
|
|
||||||
netCnt++;
|
auto src_wire = ctx->getWireBelPin(src_bel,
|
||||||
visitCnt += router.visitCnt;
|
ctx->portPinFromId(driver_port));
|
||||||
revisitCnt += router.revisitCnt;
|
|
||||||
|
|
||||||
if (!router.routedOkay) {
|
if (src_wire == WireId())
|
||||||
if (printNets)
|
continue;
|
||||||
log_info(" failed to route to %s.\n",
|
|
||||||
ctx->getWireName(router.failedDest).c_str(ctx));
|
for (auto &user_it : net_info->users) {
|
||||||
ripupQueue.insert(net_name);
|
auto dst_bel = user_it.cell->bel;
|
||||||
|
|
||||||
|
if (dst_bel == BelId())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
IdString user_port = user_it.port;
|
||||||
|
|
||||||
|
auto user_port_it = user_it.cell->pins.find(user_port);
|
||||||
|
|
||||||
|
if (user_port_it != user_it.cell->pins.end())
|
||||||
|
user_port = user_port_it->second;
|
||||||
|
|
||||||
|
auto dst_wire = ctx->getWireBelPin(
|
||||||
|
dst_bel, ctx->portPinFromId(user_port));
|
||||||
|
|
||||||
|
if (dst_wire == WireId())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
estimatedTotalDelay += ctx->estimateDelay(src_wire, dst_wire);
|
||||||
|
estimatedTotalDelayCnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log_info("estimated total wire delay: %.2f (avg %.2f)\n",
|
||||||
|
float(estimatedTotalDelay),
|
||||||
|
float(estimatedTotalDelay) / estimatedTotalDelayCnt);
|
||||||
|
|
||||||
|
int iterCnt = 0;
|
||||||
|
|
||||||
|
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 &&
|
iterCnt++;
|
||||||
(netCnt % 100 == 0))
|
if (ctx->verbose)
|
||||||
log_info(" processed %d nets. (%d routed, %d failed)\n",
|
log_info("-- %d --\n", iterCnt);
|
||||||
netCnt, netCnt - int(ripupQueue.size()),
|
|
||||||
int(ripupQueue.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
int normalRouteCnt = netCnt - int(ripupQueue.size());
|
int visitCnt = 0, revisitCnt = 0, netCnt = 0;
|
||||||
|
|
||||||
if ((ctx->verbose || iterCnt == 1) && (netCnt % 100 != 0))
|
std::unordered_set<IdString> ripupQueue;
|
||||||
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 (!ripupQueue.empty()) {
|
|
||||||
if (ctx->verbose || iterCnt == 1)
|
if (ctx->verbose || iterCnt == 1)
|
||||||
log_info("failed to route %d nets. re-routing in ripup mode.\n",
|
log_info("routing queue contains %d nets.\n",
|
||||||
int(ripupQueue.size()));
|
int(netsQueue.size()));
|
||||||
|
|
||||||
printNets = ctx->verbose && (ripupQueue.size() < 10);
|
bool printNets = ctx->verbose && (netsQueue.size() < 10);
|
||||||
|
|
||||||
visitCnt = 0;
|
std::vector<IdString> netsArray(netsQueue.begin(), netsQueue.end());
|
||||||
revisitCnt = 0;
|
ctx->sorted_shuffle(netsArray);
|
||||||
netCnt = 0;
|
netsQueue.clear();
|
||||||
int ripCnt = 0;
|
|
||||||
|
|
||||||
std::vector<IdString> ripupArray(ripupQueue.begin(),
|
for (auto net_name : netsArray) {
|
||||||
ripupQueue.end());
|
|
||||||
ctx->sorted_shuffle(ripupArray);
|
|
||||||
|
|
||||||
for (auto net_name : ripupArray) {
|
|
||||||
if (printNets)
|
if (printNets)
|
||||||
log_info(" routing net %s. (%d users)\n",
|
log_info(" routing net %s. (%d users)\n",
|
||||||
net_name.c_str(ctx),
|
net_name.c_str(ctx),
|
||||||
int(ctx->nets.at(net_name)->users.size()));
|
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++;
|
netCnt++;
|
||||||
visitCnt += router.visitCnt;
|
visitCnt += router.visitCnt;
|
||||||
revisitCnt += router.revisitCnt;
|
revisitCnt += router.revisitCnt;
|
||||||
|
|
||||||
if (!router.routedOkay)
|
if (!router.routedOkay) {
|
||||||
log_error("Net %s is impossible to route.\n",
|
if (printNets)
|
||||||
net_name.c_str(ctx));
|
log_info(
|
||||||
|
" failed to route to %s.\n",
|
||||||
for (auto it : router.rippedNets)
|
ctx->getWireName(router.failedDest).c_str(ctx));
|
||||||
netsQueue.insert(it);
|
ripupQueue.insert(net_name);
|
||||||
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ripCnt += router.rippedNets.size();
|
|
||||||
|
|
||||||
if ((ctx->verbose || iterCnt == 1) && !printNets &&
|
if ((ctx->verbose || iterCnt == 1) && !printNets &&
|
||||||
(netCnt % 100 == 0))
|
(netCnt % 100 == 0))
|
||||||
log_info(" routed %d nets, ripped %d nets.\n", netCnt,
|
log_info(" processed %d nets. (%d routed, %d failed)\n",
|
||||||
ripCnt);
|
netCnt, netCnt - int(ripupQueue.size()),
|
||||||
|
int(ripupQueue.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int normalRouteCnt = netCnt - int(ripupQueue.size());
|
||||||
|
|
||||||
if ((ctx->verbose || iterCnt == 1) && (netCnt % 100 != 0))
|
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)
|
if (ctx->verbose)
|
||||||
log_info(" routing pass visited %d PIPs (%.2f%% revisits).\n",
|
log_info(" routing pass visited %d PIPs (%.2f%% revisits).\n",
|
||||||
visitCnt, (100.0 * revisitCnt) / visitCnt);
|
visitCnt, (100.0 * revisitCnt) / visitCnt);
|
||||||
|
|
||||||
if (ctx->verbose && !netsQueue.empty())
|
if (!ripupQueue.empty()) {
|
||||||
log_info(" ripped up %d previously routed nets. continue "
|
if (ctx->verbose || iterCnt == 1)
|
||||||
"routing.\n",
|
log_info("failed to route %d nets. re-routing in ripup "
|
||||||
int(netsQueue.size()));
|
"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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ripCnt += router.rippedNets.size();
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx->verbose)
|
log_info("routing complete after %d iterations.\n", iterCnt);
|
||||||
log_info("iteration %d: routed %d nets without ripup, routed %d "
|
log_info("Checksum: 0x%08x\n", ctx->checksum());
|
||||||
"nets with ripup.\n",
|
return true;
|
||||||
iterCnt, normalRouteCnt, int(ripupQueue.size()));
|
} catch (log_execution_error_exception) {
|
||||||
|
return false;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_actual_route_delay(Context *ctx, WireId src_wire, WireId dst_wire,
|
bool get_actual_route_delay(Context *ctx, WireId src_wire, WireId dst_wire,
|
||||||
|
@ -19,20 +19,22 @@ void Worker::parsejson(const std::string &filename)
|
|||||||
{
|
{
|
||||||
std::string fn = filename;
|
std::string fn = filename;
|
||||||
std::ifstream f(fn);
|
std::ifstream f(fn);
|
||||||
|
try {
|
||||||
|
parse_json_file(f, fn, ctx);
|
||||||
|
if (!pack_design(ctx))
|
||||||
|
log_error("Packing design failed.\n");
|
||||||
|
double freq = 50e6;
|
||||||
|
assign_budget(ctx, freq);
|
||||||
|
print_utilisation(ctx);
|
||||||
|
|
||||||
parse_json_file(f, fn, ctx);
|
if (!place_design_sa(ctx))
|
||||||
if (!pack_design(ctx))
|
log_error("Placing design failed.\n");
|
||||||
log_error("Packing design failed.\n");
|
if (!route_design(ctx))
|
||||||
double freq = 50e6;
|
log_error("Routing design failed.\n");
|
||||||
assign_budget(ctx, freq);
|
Q_EMIT log("done");
|
||||||
print_utilisation(ctx);
|
} catch (log_execution_error_exception) {
|
||||||
|
Q_EMIT log("failed");
|
||||||
if (!place_design_sa(ctx))
|
}
|
||||||
log_error("Placing design failed.\n");
|
|
||||||
if (!route_design(ctx))
|
|
||||||
log_error("Routing design failed.\n");
|
|
||||||
print_utilisation(ctx);
|
|
||||||
Q_EMIT log("done");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskManager::TaskManager(Context *ctx)
|
TaskManager::TaskManager(Context *ctx)
|
||||||
|
@ -487,15 +487,19 @@ static void promote_globals(Context *ctx)
|
|||||||
// Main pack function
|
// Main pack function
|
||||||
bool pack_design(Context *ctx)
|
bool pack_design(Context *ctx)
|
||||||
{
|
{
|
||||||
log_break();
|
try {
|
||||||
pack_constants(ctx);
|
log_break();
|
||||||
promote_globals(ctx);
|
pack_constants(ctx);
|
||||||
pack_io(ctx);
|
promote_globals(ctx);
|
||||||
pack_lut_lutffs(ctx);
|
pack_io(ctx);
|
||||||
pack_nonlut_ffs(ctx);
|
pack_lut_lutffs(ctx);
|
||||||
pack_ram(ctx);
|
pack_nonlut_ffs(ctx);
|
||||||
log_info("Checksum: 0x%08x\n", ctx->checksum());
|
pack_ram(ctx);
|
||||||
return true;
|
log_info("Checksum: 0x%08x\n", ctx->checksum());
|
||||||
|
return true;
|
||||||
|
} catch (log_execution_error_exception) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
Loading…
Reference in New Issue
Block a user