diff options
author | David Shah <dave@ds0.me> | 2019-03-24 11:10:20 +0000 |
---|---|---|
committer | David Shah <dave@ds0.me> | 2019-03-24 11:10:20 +0000 |
commit | 02ae21d8fc3bc1375848f40702cd4bb7f6700595 (patch) | |
tree | db9e1fc5f4329285c9c5c5a5eb1c615418530138 /common | |
parent | 52e05f4a0706b1c108221e600ff11e654f6e85a5 (diff) | |
download | nextpnr-02ae21d8fc3bc1375848f40702cd4bb7f6700595.tar.gz nextpnr-02ae21d8fc3bc1375848f40702cd4bb7f6700595.tar.bz2 nextpnr-02ae21d8fc3bc1375848f40702cd4bb7f6700595.zip |
Add --placer option and refactor placer selection
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'common')
-rw-r--r-- | common/command.cc | 19 | ||||
-rw-r--r-- | common/settings.h | 27 |
2 files changed, 38 insertions, 8 deletions
diff --git a/common/command.cc b/common/command.cc index b7fc13e6..6f4137fe 100644 --- a/common/command.cc +++ b/common/command.cc @@ -27,6 +27,7 @@ #include "pybindings.h" #endif +#include <boost/algorithm/string/join.hpp> #include <boost/filesystem/convenience.hpp> #include <boost/program_options.hpp> #include <fstream> @@ -120,6 +121,13 @@ po::options_description CommandHandler::getGeneralOptions() general.add_options()("json", po::value<std::string>(), "JSON design file to ingest"); general.add_options()("seed", po::value<int>(), "seed value for random number generator"); general.add_options()("randomize-seed,r", "randomize seed value for random number generator"); + + general.add_options()( + "placer", po::value<std::string>(), + std::string("placer algorithm to use; available: " + boost::algorithm::join(Arch::availablePlacers, ", ") + + "; default: " + Arch::defaultPlacer) + .c_str()); + 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()("starttemp", po::value<float>(), "placer SA start temperature"); @@ -186,6 +194,17 @@ void CommandHandler::setupContext(Context *ctx) settings->set("timing/allowFail", true); } + if (vm.count("placer")) { + std::string placer = vm["placer"].as<std::string>(); + if (std::find(Arch::availablePlacers.begin(), Arch::availablePlacers.end(), placer) == + Arch::availablePlacers.end()) + log_error("Placer algorithm '%s' is not supported (available options: %s)\n", placer.c_str(), + boost::algorithm::join(Arch::availablePlacers, ", ").c_str()); + settings->set("placer", placer); + } else { + settings->set("placer", Arch::defaultPlacer); + } + if (vm.count("cstrweight")) { settings->set("placer1/constraintWeight", vm["cstrweight"].as<float>()); } diff --git a/common/settings.h b/common/settings.h index 0c4a67db..b57947c9 100644 --- a/common/settings.h +++ b/common/settings.h @@ -45,19 +45,30 @@ class Settings return defaultValue; } - template <typename T> void set(const char *name, T value) - { - IdString id = ctx->id(name); - auto pair = ctx->settings.emplace(id, std::to_string(value)); - if (!pair.second) { - ctx->settings[pair.first->first] = value; - } - } + template <typename T> void set(const char *name, T value); private: Context *ctx; }; +template <typename T> inline void Settings::set(const char *name, T value) +{ + IdString id = ctx->id(name); + auto pair = ctx->settings.emplace(id, std::to_string(value)); + if (!pair.second) { + ctx->settings[pair.first->first] = value; + } +} + +template <> inline void Settings::set<std::string>(const char *name, std::string value) +{ + IdString id = ctx->id(name); + auto pair = ctx->settings.emplace(id, value); + if (!pair.second) { + ctx->settings[pair.first->first] = value; + } +} + NEXTPNR_NAMESPACE_END #endif // SETTINGS_H |