From 545068dec4a0433d17741b508965a391029e3283 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 31 May 2019 11:09:13 +0200 Subject: Initial work on jsonwrite --- common/command.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 3eafdb17..242e5037 100644 --- a/common/command.cc +++ b/common/command.cc @@ -35,6 +35,7 @@ #include "command.h" #include "design_utils.h" #include "jsonparse.h" +#include "jsonwrite.h" #include "log.h" #include "timing.h" #include "util.h" @@ -120,6 +121,7 @@ po::options_description CommandHandler::getGeneralOptions() #endif general.add_options()("json", po::value(), "JSON design file to ingest"); + general.add_options()("write", po::value(), "JSON design file to write"); general.add_options()("seed", po::value(), "seed value for random number generator"); general.add_options()("randomize-seed,r", "randomize seed value for random number generator"); @@ -303,6 +305,12 @@ int CommandHandler::executeMain(std::unique_ptr ctx) customBitstream(ctx.get()); } + if (vm.count("write")) { + std::string filename = vm["write"].as(); + std::ofstream f(filename); + if (!write_json_file(f, filename, ctx.get())) + log_error("Loading design failed.\n"); + } if (vm.count("save")) { project.save(ctx.get(), vm["save"].as()); } -- cgit v1.2.3 From 5013724c0a98833b50ece75b13a3eeab12178a7e Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 1 Jun 2019 10:27:01 +0200 Subject: Solve issue with nets/cells not visible on load --- common/command.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 242e5037..3813a380 100644 --- a/common/command.cc +++ b/common/command.cc @@ -244,11 +244,11 @@ int CommandHandler::executeMain(std::unique_ptr ctx) if (vm.count("json")) { std::string filename = vm["json"].as(); std::ifstream f(filename); - w.notifyChangeContext(); if (!parse_json_file(f, filename, w.getContext())) log_error("Loading design failed.\n"); customAfterLoad(w.getContext()); + w.notifyChangeContext(); w.updateLoaded(); } else if (vm.count("load")) { w.projectLoad(vm["load"].as()); -- cgit v1.2.3 From bab6c9a09f9a5107267da70f5b2990975a1ce643 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 2 Jun 2019 08:50:48 +0200 Subject: Proper save message --- common/command.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 3813a380..e7ffef93 100644 --- a/common/command.cc +++ b/common/command.cc @@ -309,7 +309,7 @@ int CommandHandler::executeMain(std::unique_ptr ctx) std::string filename = vm["write"].as(); std::ofstream f(filename); if (!write_json_file(f, filename, ctx.get())) - log_error("Loading design failed.\n"); + log_error("Saving design failed.\n"); } if (vm.count("save")) { project.save(ctx.get(), vm["save"].as()); -- cgit v1.2.3 From 5c47b6034efd3898b666a18dd81cf4ae633a18c1 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 2 Jun 2019 09:13:19 +0200 Subject: added no-place and no-route options --- common/command.cc | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index e7ffef93..dc83f84d 100644 --- a/common/command.cc +++ b/common/command.cc @@ -137,6 +137,8 @@ po::options_description CommandHandler::getGeneralOptions() general.add_options()("placer-budgets", "use budget rather than criticality in placer timing weights"); general.add_options()("pack-only", "pack design only without placement or routing"); + general.add_options()("no-route", "process design without routing"); + general.add_options()("no-place", "process design without placement"); general.add_options()("ignore-loops", "ignore combinational loops in timing analysis"); @@ -282,25 +284,33 @@ int CommandHandler::executeMain(std::unique_ptr ctx) 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 (vm.count("json") || vm.count("load")) { + bool do_pack = true; + bool do_place = vm.count("pack-only")==0 && vm.count("no-place")==0; + bool do_route = vm.count("pack-only")==0 && vm.count("no-route")==0; + + if (do_pack) { + 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()); + } + + if (do_place) { + run_script_hook("pre-place"); if (!ctx->place() && !ctx->force) log_error("Placing design failed.\n"); ctx->check(); - run_script_hook("pre-route"); + } + if (do_route) { + run_script_hook("pre-route"); if (!ctx->route() && !ctx->force) log_error("Routing design failed.\n"); + run_script_hook("post-route"); } - run_script_hook("post-route"); customBitstream(ctx.get()); } -- cgit v1.2.3 From d0273f7faa9f7d75350f421966a7d5cbb4ccc9ba Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 2 Jun 2019 10:01:20 +0200 Subject: option to disable packing --- common/command.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index dc83f84d..e81967b4 100644 --- a/common/command.cc +++ b/common/command.cc @@ -139,6 +139,7 @@ po::options_description CommandHandler::getGeneralOptions() general.add_options()("pack-only", "pack design only without placement or routing"); general.add_options()("no-route", "process design without routing"); general.add_options()("no-place", "process design without placement"); + general.add_options()("no-pack", "process design without packing"); general.add_options()("ignore-loops", "ignore combinational loops in timing analysis"); @@ -285,7 +286,7 @@ int CommandHandler::executeMain(std::unique_ptr ctx) } else #endif if (vm.count("json") || vm.count("load")) { - bool do_pack = true; + bool do_pack = vm.count("pack-only")!=0 || vm.count("no-pack")==0; bool do_place = vm.count("pack-only")==0 && vm.count("no-place")==0; bool do_route = vm.count("pack-only")==0 && vm.count("no-route")==0; @@ -293,11 +294,14 @@ int CommandHandler::executeMain(std::unique_ptr ctx) 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()); + } else { + ctx->assignArchInfo(); } + assign_budget(ctx.get()); + ctx->check(); + print_utilisation(ctx.get()); + if (do_place) { run_script_hook("pre-place"); if (!ctx->place() && !ctx->force) -- cgit v1.2.3 From 7c65da417b5a222cc68a83e25c60c1f1326473f2 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 2 Jun 2019 17:33:37 +0200 Subject: Read constraints and placing from file --- common/command.cc | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index e81967b4..7d4cd252 100644 --- a/common/command.cc +++ b/common/command.cc @@ -232,6 +232,22 @@ void CommandHandler::setupContext(Context *ctx) ctx->timing_driven = false; } +std::vector split(const std::string& str, const std::string& delim) +{ + std::vector tokens; + size_t prev = 0, pos = 0; + do + { + pos = str.find(delim, prev); + if (pos == std::string::npos) pos = str.length(); + std::string token = str.substr(prev, pos-prev); + if (!token.empty()) tokens.push_back(token); + prev = pos + delim.length(); + } + while (pos < str.length() && prev < str.length()); + return tokens; +} + int CommandHandler::executeMain(std::unique_ptr ctx) { if (vm.count("test")) { @@ -295,6 +311,30 @@ int CommandHandler::executeMain(std::unique_ptr ctx) if (!ctx->pack() && !ctx->force) log_error("Packing design failed.\n"); } else { + for (auto &pair : ctx->cells) { + auto &c = pair.second; + auto constr_main = c->attrs.find(ctx->id("NEXTPNR_CONSTRAINT")); + auto constr_child = c->attrs.find(ctx->id("NEXTPNR_CONSTR_CHILDREN")); + if (constr_main!=c->attrs.end()) + { + std::vector val = split(constr_main->second.str.c_str(),";"); + c->constr_x = std::stoi(val[0]); + c->constr_y = std::stoi(val[1]); + c->constr_z = std::stoi(val[2]); + c->constr_abs_z = val[3]=="1" ? true : false; + c->constr_parent = nullptr; + if (val.size()==5) + c->constr_parent = ctx->cells.find(ctx->id(val[4].c_str()))->second.get(); + + } + if (constr_child!=c->attrs.end()) + { + for(auto val : split(constr_child->second.str.c_str(),";")) + { + c->constr_children.push_back(ctx->cells.find(ctx->id(val.c_str()))->second.get()); + } + } + } ctx->assignArchInfo(); } @@ -307,6 +347,16 @@ int CommandHandler::executeMain(std::unique_ptr ctx) if (!ctx->place() && !ctx->force) log_error("Placing design failed.\n"); ctx->check(); + } else { + for (auto &pair : ctx->cells) { + auto &c = pair.second; + auto bel = c->attrs.find(ctx->id("BEL")); + if (bel!=c->attrs.end()) + { + BelId b = ctx->getBelByName(ctx->id(bel->second.c_str())); + ctx->bindBel(b, c.get(), STRENGTH_USER); + } + } } if (do_route) { -- cgit v1.2.3 From 82ed1803c726e912730c3053179f179b90c9b694 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 2 Jun 2019 18:38:20 +0200 Subject: use NEXTPNR_BEL, since BEL is initial placement --- common/command.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 7d4cd252..d0ef5174 100644 --- a/common/command.cc +++ b/common/command.cc @@ -350,7 +350,7 @@ int CommandHandler::executeMain(std::unique_ptr ctx) } else { for (auto &pair : ctx->cells) { auto &c = pair.second; - auto bel = c->attrs.find(ctx->id("BEL")); + auto bel = c->attrs.find(ctx->id("NEXTPNR_BEL")); if (bel!=c->attrs.end()) { BelId b = ctx->getBelByName(ctx->id(bel->second.c_str())); -- cgit v1.2.3 From 44d6f16b66e5f7b89e8cf5711744d6e5f6a40b4a Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 3 Jun 2019 21:01:05 +0200 Subject: Support ecp5 read write additional cell info --- common/command.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index d0ef5174..d700f4ee 100644 --- a/common/command.cc +++ b/common/command.cc @@ -28,6 +28,7 @@ #endif #include +#include #include #include #include @@ -317,15 +318,27 @@ int CommandHandler::executeMain(std::unique_ptr ctx) auto constr_child = c->attrs.find(ctx->id("NEXTPNR_CONSTR_CHILDREN")); if (constr_main!=c->attrs.end()) { - std::vector val = split(constr_main->second.str.c_str(),";"); + std::vector val; + boost::split(val,constr_main->second.str,boost::is_any_of(";")); c->constr_x = std::stoi(val[0]); c->constr_y = std::stoi(val[1]); c->constr_z = std::stoi(val[2]); - c->constr_abs_z = val[3]=="1" ? true : false; + c->constr_abs_z = val[3]=="1"; c->constr_parent = nullptr; - if (val.size()==5) + if (!val[4].empty()) c->constr_parent = ctx->cells.find(ctx->id(val[4].c_str()))->second.get(); - + #ifdef ARCH_ECP5 + c->sliceInfo.using_dff = val[5]=="1"; + c->sliceInfo.has_l6mux = val[6]=="1"; + c->sliceInfo.is_carry = val[7]=="1"; + c->sliceInfo.clk_sig = ctx->id(val[8]); + c->sliceInfo.lsr_sig = ctx->id(val[9]); + c->sliceInfo.clkmux = ctx->id(val[10]); + c->sliceInfo.lsrmux = ctx->id(val[11]); + c->sliceInfo.srmode = ctx->id(val[12]); + c->sliceInfo.sd0 = std::stoi(val[13]); + c->sliceInfo.sd1 = std::stoi(val[14]); + #endif } if (constr_child!=c->attrs.end()) { -- cgit v1.2.3 From 1093d7e1228272ca73114bbc4415c48d6cba76ed Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 7 Jun 2019 11:48:15 +0200 Subject: WIP saving/loading attributes --- common/command.cc | 51 +-------------------------------------------------- 1 file changed, 1 insertion(+), 50 deletions(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index d700f4ee..96008d2b 100644 --- a/common/command.cc +++ b/common/command.cc @@ -311,46 +311,7 @@ int CommandHandler::executeMain(std::unique_ptr ctx) run_script_hook("pre-pack"); if (!ctx->pack() && !ctx->force) log_error("Packing design failed.\n"); - } else { - for (auto &pair : ctx->cells) { - auto &c = pair.second; - auto constr_main = c->attrs.find(ctx->id("NEXTPNR_CONSTRAINT")); - auto constr_child = c->attrs.find(ctx->id("NEXTPNR_CONSTR_CHILDREN")); - if (constr_main!=c->attrs.end()) - { - std::vector val; - boost::split(val,constr_main->second.str,boost::is_any_of(";")); - c->constr_x = std::stoi(val[0]); - c->constr_y = std::stoi(val[1]); - c->constr_z = std::stoi(val[2]); - c->constr_abs_z = val[3]=="1"; - c->constr_parent = nullptr; - if (!val[4].empty()) - c->constr_parent = ctx->cells.find(ctx->id(val[4].c_str()))->second.get(); - #ifdef ARCH_ECP5 - c->sliceInfo.using_dff = val[5]=="1"; - c->sliceInfo.has_l6mux = val[6]=="1"; - c->sliceInfo.is_carry = val[7]=="1"; - c->sliceInfo.clk_sig = ctx->id(val[8]); - c->sliceInfo.lsr_sig = ctx->id(val[9]); - c->sliceInfo.clkmux = ctx->id(val[10]); - c->sliceInfo.lsrmux = ctx->id(val[11]); - c->sliceInfo.srmode = ctx->id(val[12]); - c->sliceInfo.sd0 = std::stoi(val[13]); - c->sliceInfo.sd1 = std::stoi(val[14]); - #endif - } - if (constr_child!=c->attrs.end()) - { - for(auto val : split(constr_child->second.str.c_str(),";")) - { - c->constr_children.push_back(ctx->cells.find(ctx->id(val.c_str()))->second.get()); - } - } - } - ctx->assignArchInfo(); - } - + } assign_budget(ctx.get()); ctx->check(); print_utilisation(ctx.get()); @@ -360,16 +321,6 @@ int CommandHandler::executeMain(std::unique_ptr ctx) if (!ctx->place() && !ctx->force) log_error("Placing design failed.\n"); ctx->check(); - } else { - for (auto &pair : ctx->cells) { - auto &c = pair.second; - auto bel = c->attrs.find(ctx->id("NEXTPNR_BEL")); - if (bel!=c->attrs.end()) - { - BelId b = ctx->getBelByName(ctx->id(bel->second.c_str())); - ctx->bindBel(b, c.get(), STRENGTH_USER); - } - } } if (do_route) { -- cgit v1.2.3 From a8871ea8aa6e17b2fbc8f70ce0f96cca18bac928 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 7 Jun 2019 13:18:43 +0200 Subject: Cleanup and fixes, flow works now --- common/command.cc | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 96008d2b..46d6d014 100644 --- a/common/command.cc +++ b/common/command.cc @@ -233,22 +233,6 @@ void CommandHandler::setupContext(Context *ctx) ctx->timing_driven = false; } -std::vector split(const std::string& str, const std::string& delim) -{ - std::vector tokens; - size_t prev = 0, pos = 0; - do - { - pos = str.find(delim, prev); - if (pos == std::string::npos) pos = str.length(); - std::string token = str.substr(prev, pos-prev); - if (!token.empty()) tokens.push_back(token); - prev = pos + delim.length(); - } - while (pos < str.length() && prev < str.length()); - return tokens; -} - int CommandHandler::executeMain(std::unique_ptr ctx) { if (vm.count("test")) { -- cgit v1.2.3 From 1cd4a4d17aeaab26664add714c8a02f76f6a6a90 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 13 Jun 2019 17:42:41 +0200 Subject: Remove concept of project and code connected --- common/command.cc | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 46d6d014..43707c83 100644 --- a/common/command.cc +++ b/common/command.cc @@ -149,8 +149,6 @@ po::options_description CommandHandler::getGeneralOptions() general.add_options()("freq", po::value(), "set target frequency for design in MHz"); general.add_options()("timing-allow-fail", "allow timing to fail in design"); general.add_options()("no-tmdriv", "disable timing-driven placement"); - general.add_options()("save", po::value(), "project file to write"); - general.add_options()("load", po::value(), "project file to read"); return general; } @@ -254,8 +252,6 @@ int CommandHandler::executeMain(std::unique_ptr ctx) customAfterLoad(w.getContext()); w.notifyChangeContext(); w.updateLoaded(); - } else if (vm.count("load")) { - w.projectLoad(vm["load"].as()); } else w.notifyChangeContext(); } catch (log_execution_error_exception) { @@ -286,7 +282,7 @@ int CommandHandler::executeMain(std::unique_ptr ctx) execute_python_file(filename.c_str()); } else #endif - if (vm.count("json") || vm.count("load")) { + if (vm.count("json")) { bool do_pack = vm.count("pack-only")!=0 || vm.count("no-pack")==0; bool do_place = vm.count("pack-only")==0 && vm.count("no-place")==0; bool do_route = vm.count("pack-only")==0 && vm.count("no-route")==0; @@ -323,9 +319,6 @@ int CommandHandler::executeMain(std::unique_ptr ctx) if (!write_json_file(f, filename, ctx.get())) log_error("Saving design failed.\n"); } - if (vm.count("save")) { - project.save(ctx.get(), vm["save"].as()); - } #ifndef NO_PYTHON deinit_python(); @@ -361,12 +354,7 @@ int CommandHandler::exec() if (executeBeforeContext()) return 0; - std::unique_ptr ctx; - if (vm.count("load") && vm.count("gui") == 0) { - ctx = project.load(vm["load"].as()); - } else { - ctx = createContext(); - } + std::unique_ptr ctx = createContext(); settings = std::unique_ptr(new Settings(ctx.get())); setupContext(ctx.get()); setupArchContext(ctx.get()); -- cgit v1.2.3 From 4de147d9e42d7c932773544011a36e4550530a9e Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 13 Jun 2019 18:39:16 +0200 Subject: Save settings that we saved in project --- common/command.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 43707c83..4822585c 100644 --- a/common/command.cc +++ b/common/command.cc @@ -229,6 +229,10 @@ void CommandHandler::setupContext(Context *ctx) ctx->timing_driven = true; if (vm.count("no-tmdriv")) ctx->timing_driven = false; + + settings->set("arch.name", std::string(ctx->archId().c_str(ctx))); + settings->set("arch.type", std::string(ctx->archArgsToId(ctx->archArgs()).c_str(ctx))); + settings->set("seed", ctx->rngstate); } int CommandHandler::executeMain(std::unique_ptr ctx) -- cgit v1.2.3 From 03dff10cbde4c55e4ac9b53a01ba84f4bdac169b Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 13 Jun 2019 20:42:11 +0200 Subject: Load properties from json and propagate to context create --- common/command.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 4822585c..209f8cab 100644 --- a/common/command.cc +++ b/common/command.cc @@ -358,7 +358,14 @@ int CommandHandler::exec() if (executeBeforeContext()) return 0; - std::unique_ptr ctx = createContext(); + std::unordered_map values; + if (vm.count("json")) { + std::string filename = vm["json"].as(); + std::ifstream f(filename); + if (!load_json_settings(f, filename, values)) + log_error("Loading design failed.\n"); + } + std::unique_ptr ctx = createContext(values); settings = std::unique_ptr(new Settings(ctx.get())); setupContext(ctx.get()); setupArchContext(ctx.get()); -- cgit v1.2.3 From 0d8c80ad5daafc02030385da90c5a57182a5d4e5 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 14 Jun 2019 11:14:18 +0200 Subject: gui for json write and proper statuses --- common/command.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 209f8cab..7b0b2caa 100644 --- a/common/command.cc +++ b/common/command.cc @@ -255,7 +255,7 @@ int CommandHandler::executeMain(std::unique_ptr ctx) customAfterLoad(w.getContext()); w.notifyChangeContext(); - w.updateLoaded(); + w.updateActions(); } else w.notifyChangeContext(); } catch (log_execution_error_exception) { -- cgit v1.2.3 From 66ea9f39f7f5d6e1152105328f9a48a367bd8ce0 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 14 Jun 2019 15:18:35 +0200 Subject: enable lading of jsons and setting up context --- common/command.cc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 7b0b2caa..1a8f810e 100644 --- a/common/command.cc +++ b/common/command.cc @@ -245,7 +245,7 @@ int CommandHandler::executeMain(std::unique_ptr ctx) #ifndef NO_GUI if (vm.count("gui")) { Application a(argc, argv, (vm.count("gui-no-aa") > 0)); - MainWindow w(std::move(ctx), chipArgs); + MainWindow w(std::move(ctx), this); try { if (vm.count("json")) { std::string filename = vm["json"].as(); @@ -378,6 +378,28 @@ int CommandHandler::exec() } } +std::unique_ptr CommandHandler::load_json(std::string filename) +{ + vm.clear(); + std::unordered_map values; + { + std::ifstream f(filename); + if (!load_json_settings(f, filename, values)) + log_error("Loading design failed.\n"); + } + std::unique_ptr ctx = createContext(values); + settings = std::unique_ptr(new Settings(ctx.get())); + setupContext(ctx.get()); + setupArchContext(ctx.get()); + { + std::ifstream f(filename); + if (!parse_json_file(f, filename, ctx.get())) + log_error("Loading design failed.\n"); + } + customAfterLoad(ctx.get()); + return ctx; +} + void CommandHandler::run_script_hook(const std::string &name) { #ifndef NO_PYTHON -- cgit v1.2.3 From 95280060b869f266beaff023dd63d74905c39ef4 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 15 Jun 2019 13:09:49 +0200 Subject: No need for settings class --- common/command.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 1a8f810e..ca054532 100644 --- a/common/command.cc +++ b/common/command.cc @@ -192,11 +192,11 @@ void CommandHandler::setupContext(Context *ctx) } if (vm.count("ignore-loops")) { - settings->set("timing/ignoreLoops", true); + ctx->settings[ctx->id("timing/ignoreLoops")] = std::to_string(true); } if (vm.count("timing-allow-fail")) { - settings->set("timing/allowFail", true); + ctx->settings[ctx->id("timing/allowFail")] = std::to_string(true); } if (vm.count("placer")) { @@ -205,20 +205,20 @@ void CommandHandler::setupContext(Context *ctx) 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); + ctx->settings[ctx->id("placer")] = placer; } else { - settings->set("placer", Arch::defaultPlacer); + ctx->settings[ctx->id("placer")] = Arch::defaultPlacer; } if (vm.count("cstrweight")) { - settings->set("placer1/constraintWeight", vm["cstrweight"].as()); + ctx->settings[ctx->id("placer1/constraintWeight")] = std::to_string(vm["cstrweight"].as()); } if (vm.count("starttemp")) { - settings->set("placer1/startTemp", vm["starttemp"].as()); + ctx->settings[ctx->id("placer1/startTemp")] = std::to_string(vm["starttemp"].as()); } if (vm.count("placer-budgets")) { - settings->set("placer1/budgetBased", true); + ctx->settings[ctx->id("placer1/budgetBased")] = std::to_string(true); } if (vm.count("freq")) { auto freq = vm["freq"].as(); @@ -230,9 +230,9 @@ void CommandHandler::setupContext(Context *ctx) if (vm.count("no-tmdriv")) ctx->timing_driven = false; - settings->set("arch.name", std::string(ctx->archId().c_str(ctx))); - settings->set("arch.type", std::string(ctx->archArgsToId(ctx->archArgs()).c_str(ctx))); - settings->set("seed", ctx->rngstate); + 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("seed")] = std::to_string(ctx->rngstate); } int CommandHandler::executeMain(std::unique_ptr ctx) @@ -366,7 +366,6 @@ int CommandHandler::exec() log_error("Loading design failed.\n"); } std::unique_ptr ctx = createContext(values); - settings = std::unique_ptr(new Settings(ctx.get())); setupContext(ctx.get()); setupArchContext(ctx.get()); int rc = executeMain(std::move(ctx)); @@ -388,7 +387,6 @@ std::unique_ptr CommandHandler::load_json(std::string filename) log_error("Loading design failed.\n"); } std::unique_ptr ctx = createContext(values); - settings = std::unique_ptr(new Settings(ctx.get())); setupContext(ctx.get()); setupArchContext(ctx.get()); { -- cgit v1.2.3 From 8d5724f4fd8e384ac59b8a94ec6979593239976c Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 15 Jun 2019 15:23:51 +0200 Subject: moved some context variables to settings --- common/command.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index ca054532..89e05b4d 100644 --- a/common/command.cc +++ b/common/command.cc @@ -181,9 +181,9 @@ void CommandHandler::setupContext(Context *ctx) } if (vm.count("slack_redist_iter")) { - ctx->slack_redist_iter = vm["slack_redist_iter"].as(); + ctx->settings[ctx->id("slack_redist_iter")] = vm["slack_redist_iter"].as(); if (vm.count("freq") && vm["freq"].as() == 0) { - ctx->auto_freq = true; + ctx->settings[ctx->id("auto_freq")] = std::to_string(true); #ifndef NO_GUI if (!vm.count("gui")) #endif @@ -223,13 +223,22 @@ void CommandHandler::setupContext(Context *ctx) if (vm.count("freq")) { auto freq = vm["freq"].as(); if (freq > 0) - ctx->target_freq = freq * 1e6; + ctx->settings[ctx->id("target_freq")] = std::to_string(freq * 1e6); } - ctx->timing_driven = true; if (vm.count("no-tmdriv")) - ctx->timing_driven = false; - + ctx->settings[ctx->id("timing_driven")] = std::to_string(false); + + // Setting default values + if (ctx->settings.find(ctx->id("target_freq")) == ctx->settings.end()) + ctx->settings[ctx->id("target_freq")] = std::to_string(12e6); + if (ctx->settings.find(ctx->id("timing_driven")) == ctx->settings.end()) + ctx->settings[ctx->id("timing_driven")] = std::to_string(true); + if (ctx->settings.find(ctx->id("slack_redist_iter")) == ctx->settings.end()) + ctx->settings[ctx->id("slack_redist_iter")] = "0"; + if (ctx->settings.find(ctx->id("auto_freq")) == ctx->settings.end()) + ctx->settings[ctx->id("auto_freq")] = std::to_string(false); + 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("seed")] = std::to_string(ctx->rngstate); -- cgit v1.2.3 From 226885a58f67d81fb05e13bde91be8b654479210 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 15 Jun 2019 15:31:18 +0200 Subject: use save seed --- common/command.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 89e05b4d..09e75fdf 100644 --- a/common/command.cc +++ b/common/command.cc @@ -154,6 +154,9 @@ po::options_description CommandHandler::getGeneralOptions() void CommandHandler::setupContext(Context *ctx) { + if (ctx->settings.find(ctx->id("seed")) != ctx->settings.end()) + ctx->rngstate = ctx->setting("seed"); + if (vm.count("verbose")) { ctx->verbose = true; } -- cgit v1.2.3 From ff257a092930492a1260cf0c1f79d76c3d098612 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 15 Jun 2019 15:35:23 +0200 Subject: default placement only if not set --- common/command.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index 09e75fdf..dc98d032 100644 --- a/common/command.cc +++ b/common/command.cc @@ -209,8 +209,6 @@ void CommandHandler::setupContext(Context *ctx) log_error("Placer algorithm '%s' is not supported (available options: %s)\n", placer.c_str(), boost::algorithm::join(Arch::availablePlacers, ", ").c_str()); ctx->settings[ctx->id("placer")] = placer; - } else { - ctx->settings[ctx->id("placer")] = Arch::defaultPlacer; } if (vm.count("cstrweight")) { @@ -241,7 +239,9 @@ void CommandHandler::setupContext(Context *ctx) ctx->settings[ctx->id("slack_redist_iter")] = "0"; if (ctx->settings.find(ctx->id("auto_freq")) == ctx->settings.end()) ctx->settings[ctx->id("auto_freq")] = std::to_string(false); - + if (ctx->settings.find(ctx->id("placer")) == ctx->settings.end()) + ctx->settings[ctx->id("placer")] = Arch::defaultPlacer; + 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("seed")] = std::to_string(ctx->rngstate); -- cgit v1.2.3 From be47fc3e9a81a4890b05223ae18803cb07674dc9 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Tue, 25 Jun 2019 18:19:25 +0200 Subject: clangformat run --- common/command.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'common/command.cc') diff --git a/common/command.cc b/common/command.cc index dc98d032..8acbafd2 100644 --- a/common/command.cc +++ b/common/command.cc @@ -27,8 +27,8 @@ #include "pybindings.h" #endif -#include #include +#include #include #include #include @@ -156,7 +156,7 @@ void CommandHandler::setupContext(Context *ctx) { if (ctx->settings.find(ctx->id("seed")) != ctx->settings.end()) ctx->rngstate = ctx->setting("seed"); - + if (vm.count("verbose")) { ctx->verbose = true; } @@ -239,7 +239,7 @@ void CommandHandler::setupContext(Context *ctx) ctx->settings[ctx->id("slack_redist_iter")] = "0"; if (ctx->settings.find(ctx->id("auto_freq")) == ctx->settings.end()) ctx->settings[ctx->id("auto_freq")] = std::to_string(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("arch.name")] = std::string(ctx->archId().c_str(ctx)); @@ -298,16 +298,16 @@ int CommandHandler::executeMain(std::unique_ptr ctx) execute_python_file(filename.c_str()); } else #endif - if (vm.count("json")) { - bool do_pack = vm.count("pack-only")!=0 || vm.count("no-pack")==0; - bool do_place = vm.count("pack-only")==0 && vm.count("no-place")==0; - bool do_route = vm.count("pack-only")==0 && vm.count("no-route")==0; + if (vm.count("json")) { + bool do_pack = vm.count("pack-only") != 0 || vm.count("no-pack") == 0; + bool do_place = vm.count("pack-only") == 0 && vm.count("no-place") == 0; + bool do_route = vm.count("pack-only") == 0 && vm.count("no-route") == 0; if (do_pack) { 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()); @@ -329,7 +329,7 @@ int CommandHandler::executeMain(std::unique_ptr ctx) customBitstream(ctx.get()); } - if (vm.count("write")) { + if (vm.count("write")) { std::string filename = vm["write"].as(); std::ofstream f(filename); if (!write_json_file(f, filename, ctx.get())) @@ -370,7 +370,7 @@ int CommandHandler::exec() if (executeBeforeContext()) return 0; - std::unordered_map values; + std::unordered_map values; if (vm.count("json")) { std::string filename = vm["json"].as(); std::ifstream f(filename); @@ -392,7 +392,7 @@ int CommandHandler::exec() std::unique_ptr CommandHandler::load_json(std::string filename) { vm.clear(); - std::unordered_map values; + std::unordered_map values; { std::ifstream f(filename); if (!load_json_settings(f, filename, values)) -- cgit v1.2.3