Allow selection of router algorithm

Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
David Shah 2020-02-03 11:54:38 +00:00
parent 25f57a1e38
commit 7123209324
8 changed files with 81 additions and 7 deletions

View File

@ -132,6 +132,12 @@ po::options_description CommandHandler::getGeneralOptions()
"; default: " + Arch::defaultPlacer) "; default: " + Arch::defaultPlacer)
.c_str()); .c_str());
general.add_options()(
"router", po::value<std::string>(),
std::string("router algorithm to use; available: " + boost::algorithm::join(Arch::availableRouters, ", ") +
"; default: " + Arch::defaultPlacer)
.c_str());
general.add_options()("slack_redist_iter", po::value<int>(), "number of iterations between slack redistribution"); general.add_options()("slack_redist_iter", po::value<int>(), "number of iterations between slack redistribution");
general.add_options()("cstrweight", po::value<float>(), "placer weighting for relative constraint satisfaction"); general.add_options()("cstrweight", po::value<float>(), "placer weighting for relative constraint satisfaction");
general.add_options()("starttemp", po::value<float>(), "placer SA start temperature"); general.add_options()("starttemp", po::value<float>(), "placer SA start temperature");
@ -214,6 +220,15 @@ void CommandHandler::setupContext(Context *ctx)
ctx->settings[ctx->id("placer")] = placer; ctx->settings[ctx->id("placer")] = placer;
} }
if (vm.count("router")) {
std::string router = vm["router"].as<std::string>();
if (std::find(Arch::availableRouters.begin(), Arch::availableRouters.end(), router) ==
Arch::availableRouters.end())
log_error("Router algorithm '%s' is not supported (available options: %s)\n", router.c_str(),
boost::algorithm::join(Arch::availableRouters, ", ").c_str());
ctx->settings[ctx->id("router")] = router;
}
if (vm.count("cstrweight")) { if (vm.count("cstrweight")) {
ctx->settings[ctx->id("placer1/constraintWeight")] = std::to_string(vm["cstrweight"].as<float>()); ctx->settings[ctx->id("placer1/constraintWeight")] = std::to_string(vm["cstrweight"].as<float>());
} }
@ -244,6 +259,8 @@ void CommandHandler::setupContext(Context *ctx)
ctx->settings[ctx->id("auto_freq")] = false; ctx->settings[ctx->id("auto_freq")] = false;
if (ctx->settings.find(ctx->id("placer")) == ctx->settings.end()) if (ctx->settings.find(ctx->id("placer")) == ctx->settings.end())
ctx->settings[ctx->id("placer")] = Arch::defaultPlacer; ctx->settings[ctx->id("placer")] = Arch::defaultPlacer;
if (ctx->settings.find(ctx->id("router")) == ctx->settings.end())
ctx->settings[ctx->id("router")] = Arch::defaultRouter;
ctx->settings[ctx->id("arch.name")] = std::string(ctx->archId().c_str(ctx)); ctx->settings[ctx->id("arch.name")] = std::string(ctx->archId().c_str(ctx));
ctx->settings[ctx->id("arch.type")] = std::string(ctx->archArgsToId(ctx->archArgs()).c_str(ctx)); ctx->settings[ctx->id("arch.type")] = std::string(ctx->archArgsToId(ctx->archArgs()).c_str(ctx));

View File

@ -508,3 +508,13 @@ Name of the default placement algorithm for the architecture, if
Name of available placer algorithms for the architecture, used Name of available placer algorithms for the architecture, used
to provide help for and validate `--placer`. to provide help for and validate `--placer`.
### static const std::string defaultRouter
Name of the default router algorithm for the architecture, if
`--router` isn't specified on the command line.
### static const std::vector\<std::string\> availableRouters
Name of available router algorithms for the architecture, used
to provide help for and validate `--router`.

View File

@ -621,12 +621,23 @@ bool Arch::place()
bool Arch::route() bool Arch::route()
{ {
std::string router = str_or_default(settings, id("router"), defaultRouter);
setupWireLocations(); setupWireLocations();
route_ecp5_globals(getCtx()); route_ecp5_globals(getCtx());
assignArchInfo(); assignArchInfo();
assign_budget(getCtx(), true); assign_budget(getCtx(), true);
router2(getCtx(), Router2Cfg(getCtx()));
bool result = router1(getCtx(), Router1Cfg(getCtx())); bool result;
if (router == "router1") {
result = router1(getCtx(), Router1Cfg(getCtx()));
} else if (router == "router2") {
router2(getCtx(), Router2Cfg(getCtx()));
result = router1(getCtx(), Router1Cfg(getCtx()));
} else {
log_error("ECP5 architecture does not support router '%s'\n", router.c_str());
}
#if 0 #if 0
std::vector<std::pair<WireId, int>> fanout_vector; std::vector<std::pair<WireId, int>> fanout_vector;
std::copy(wire_fanout.begin(), wire_fanout.end(), std::back_inserter(fanout_vector)); std::copy(wire_fanout.begin(), wire_fanout.end(), std::back_inserter(fanout_vector));
@ -1173,6 +1184,9 @@ const std::vector<std::string> Arch::availablePlacers = {"sa",
#endif #endif
}; };
const std::string Arch::defaultRouter = "router1";
const std::vector<std::string> Arch::availableRouters = {"router1", "router2"};
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
GroupId Arch::getGroupByName(IdString name) const GroupId Arch::getGroupByName(IdString name) const

View File

@ -1066,6 +1066,8 @@ struct Arch : BaseCtx
static const std::string defaultPlacer; static const std::string defaultPlacer;
static const std::vector<std::string> availablePlacers; static const std::vector<std::string> availablePlacers;
static const std::string defaultRouter;
static const std::vector<std::string> availableRouters;
}; };
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -23,6 +23,7 @@
#include "placer1.h" #include "placer1.h"
#include "placer_heap.h" #include "placer_heap.h"
#include "router1.h" #include "router1.h"
#include "router2.h"
#include "util.h" #include "util.h"
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
@ -553,10 +554,19 @@ bool Arch::place()
bool Arch::route() bool Arch::route()
{ {
bool retVal = router1(getCtx(), Router1Cfg(getCtx())); std::string router = str_or_default(settings, id("router"), defaultRouter);
bool result;
if (router == "router1") {
result = router1(getCtx(), Router1Cfg(getCtx()));
} else if (router == "router2") {
router2(getCtx(), Router2Cfg(getCtx()));
result = router1(getCtx(), Router1Cfg(getCtx()));
} else {
log_error("iCE40 architecture does not support router '%s'\n", router.c_str());
}
getCtx()->settings[getCtx()->id("route")] = 1; getCtx()->settings[getCtx()->id("route")] = 1;
archInfoToAttributes(); archInfoToAttributes();
return retVal; return result;
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------
@ -653,6 +663,10 @@ const std::vector<std::string> Arch::availablePlacers = {"sa",
"heap" "heap"
#endif #endif
}; };
const std::string Arch::defaultRouter = "router1";
const std::vector<std::string> Arch::availableRouters = {"router1", "router2"};
void Arch::assignArchInfo() void Arch::assignArchInfo()
{ {
for (auto &cell : getCtx()->cells) { for (auto &cell : getCtx()->cells) {

View File

@ -288,6 +288,8 @@ struct Arch : BaseCtx
static const std::string defaultPlacer; static const std::string defaultPlacer;
static const std::vector<std::string> availablePlacers; static const std::vector<std::string> availablePlacers;
static const std::string defaultRouter;
static const std::vector<std::string> availableRouters;
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Internal usage // Internal usage

View File

@ -28,6 +28,7 @@
#include "placer1.h" #include "placer1.h"
#include "placer_heap.h" #include "placer_heap.h"
#include "router1.h" #include "router1.h"
#include "router2.h"
#include "timing_opt.h" #include "timing_opt.h"
#include "util.h" #include "util.h"
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
@ -696,10 +697,19 @@ bool Arch::place()
bool Arch::route() bool Arch::route()
{ {
bool retVal = router1(getCtx(), Router1Cfg(getCtx())); std::string router = str_or_default(settings, id("router"), defaultRouter);
bool result;
if (router == "router1") {
result = router1(getCtx(), Router1Cfg(getCtx()));
} else if (router == "router2") {
router2(getCtx(), Router2Cfg(getCtx()));
result = router1(getCtx(), Router1Cfg(getCtx()));
} else {
log_error("iCE40 architecture does not support router '%s'\n", router.c_str());
}
getCtx()->settings[getCtx()->id("route")] = 1; getCtx()->settings[getCtx()->id("route")] = 1;
archInfoToAttributes(); archInfoToAttributes();
return retVal; return result;
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -1257,4 +1267,7 @@ const std::vector<std::string> Arch::availablePlacers = {"sa",
#endif #endif
}; };
const std::string Arch::defaultRouter = "router1";
const std::vector<std::string> Arch::availableRouters = {"router1", "router2"};
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -900,6 +900,8 @@ struct Arch : BaseCtx
static const std::string defaultPlacer; static const std::string defaultPlacer;
static const std::vector<std::string> availablePlacers; static const std::vector<std::string> availablePlacers;
static const std::string defaultRouter;
static const std::vector<std::string> availableRouters;
}; };
void ice40DelayFuzzerMain(Context *ctx); void ice40DelayFuzzerMain(Context *ctx);