diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-11-09 12:57:14 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-11-09 12:57:14 +0100 |
commit | 66dd17664c08aca17b53d2853558121aa9e702e4 (patch) | |
tree | b6bc5dd919e5f525ec7328861b81f616673a1ea6 /common/command.cc | |
parent | e91241f10d68fcaaf0a81fa77e9a91666120ccee (diff) | |
parent | 15d9b3d3cc05656e58d01ba2f97ec92b6daaee1c (diff) | |
download | nextpnr-66dd17664c08aca17b53d2853558121aa9e702e4.tar.gz nextpnr-66dd17664c08aca17b53d2853558121aa9e702e4.tar.bz2 nextpnr-66dd17664c08aca17b53d2853558121aa9e702e4.zip |
Merge branch 'master' of github.com:YosysHQ/nextpnr into router_improve
Diffstat (limited to 'common/command.cc')
-rw-r--r-- | common/command.cc | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/common/command.cc b/common/command.cc index ab0c92f2..c5c777e8 100644 --- a/common/command.cc +++ b/common/command.cc @@ -91,8 +91,14 @@ po::options_description CommandHandler::getGeneralOptions() general.add_options()("gui", "start gui"); #endif #ifndef NO_PYTHON - general.add_options()("run", po::value<std::vector<std::string>>(), "python file to execute"); + general.add_options()("run", po::value<std::vector<std::string>>(), + "python file to execute instead of default flow"); pos.add("run", -1); + general.add_options()("pre-pack", po::value<std::vector<std::string>>(), "python file to run before packing"); + general.add_options()("pre-place", po::value<std::vector<std::string>>(), "python file to run before placement"); + general.add_options()("pre-route", po::value<std::vector<std::string>>(), "python file to run before routing"); + general.add_options()("post-route", po::value<std::vector<std::string>>(), "python file to run after routing"); + #endif 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"); @@ -200,40 +206,48 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx) customAfterLoad(ctx.get()); } - if (vm.count("json") || vm.count("load")) { +#ifndef NO_PYTHON + init_python(argv[0], true); + python_export_global("ctx", *ctx); + + if (vm.count("run")) { + + std::vector<std::string> files = vm["run"].as<std::vector<std::string>>(); + for (auto filename : files) + execute_python_file(filename.c_str()); + } else +#endif + if (vm.count("json") || vm.count("load")) { + run_script_hook("pre-pack"); if (!ctx->pack() && !ctx->force) log_error("Packing design failed.\n"); assign_budget(ctx.get()); ctx->check(); print_utilisation(ctx.get()); + run_script_hook("pre-place"); + if (!vm.count("pack-only")) { if (!ctx->place() && !ctx->force) log_error("Placing design failed.\n"); ctx->check(); + run_script_hook("pre-route"); + if (!ctx->route() && !ctx->force) log_error("Routing design failed.\n"); } + run_script_hook("post-route"); customBitstream(ctx.get()); } -#ifndef NO_PYTHON - if (vm.count("run")) { - init_python(argv[0], true); - python_export_global("ctx", *ctx); - - std::vector<std::string> files = vm["run"].as<std::vector<std::string>>(); - for (auto filename : files) - execute_python_file(filename.c_str()); - - deinit_python(); - } -#endif - if (vm.count("save")) { project.save(ctx.get(), vm["save"].as<std::string>()); } +#ifndef NO_PYTHON + deinit_python(); +#endif + return 0; } @@ -270,4 +284,15 @@ int CommandHandler::exec() } } +void CommandHandler::run_script_hook(const std::string &name) +{ +#ifndef NO_PYTHON + if (vm.count(name)) { + std::vector<std::string> files = vm[name].as<std::vector<std::string>>(); + for (auto filename : files) + execute_python_file(filename.c_str()); + } +#endif +} + NEXTPNR_NAMESPACE_END |