diff options
author | eshellko <kornukhin@mail.ru> | 2016-07-01 10:24:22 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-01 10:24:22 +0400 |
commit | 9a742f4069d6413bcf46b84c3b3f0e5cfc47f647 (patch) | |
tree | 2b7205866ff55746738d22fcf5ea0ae6434f03e9 /passes | |
parent | df5ebfa0a0fc6d060caaa21b74a2f1a7b4ba0f86 (diff) | |
download | yosys-9a742f4069d6413bcf46b84c3b3f0e5cfc47f647.tar.gz yosys-9a742f4069d6413bcf46b84c3b3f0e5cfc47f647.tar.bz2 yosys-9a742f4069d6413bcf46b84c3b3f0e5cfc47f647.zip |
Added 'assert-limit' option for 'select' command
For resource limited designs such as FPGA it can be useful to specify limit of specific resources available on board. So user can check if he should change RTL as early as mapping done.
Diffstat (limited to 'passes')
-rw-r--r-- | passes/cmds/select.cc | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/passes/cmds/select.cc b/passes/cmds/select.cc index 3e64dd846..9e0f953de 100644 --- a/passes/cmds/select.cc +++ b/passes/cmds/select.cc @@ -988,6 +988,10 @@ struct SelectPass : public Pass { log(" do not modify the current selection. instead assert that the given\n"); log(" selection contains exactly N objects.\n"); log("\n"); + log(" -assert-limit N\n"); + log(" do not modify the current selection. instead assert that the given\n"); + log(" selection contains more than N objects.\n"); + log("\n"); log(" -list\n"); log(" list all objects in the current selection\n"); log("\n"); @@ -1168,6 +1172,7 @@ struct SelectPass : public Pass { bool assert_none = false; bool assert_any = false; int assert_count = -1; + int assert_limit = -1; std::string write_file, read_file; std::string set_name, sel_str; @@ -1197,6 +1202,10 @@ struct SelectPass : public Pass { assert_count = atoi(args[++argidx].c_str()); continue; } + if (arg == "-assert-limit" && argidx+1 < args.size()) { + assert_limit = atoi(args[++argidx].c_str()); + continue; + } if (arg == "-clear") { clear_mode = true; continue; @@ -1273,13 +1282,13 @@ struct SelectPass : public Pass { if (none_mode && args.size() != 2) log_cmd_error("Option -none can not be combined with any other options.\n"); - if (add_mode + del_mode + assert_none + assert_any + (assert_count >= 0) > 1) - log_cmd_error("Options -add, -del, -assert-none, -assert-any or -assert-count can not be combined.\n"); + if (add_mode + del_mode + assert_none + assert_any + (assert_count >= 0) + (assert_limit >= 0) > 1) + log_cmd_error("Options -add, -del, -assert-none, -assert-any, assert-count or -assert-limit can not be combined.\n"); - if ((list_mode || !write_file.empty() || count_mode) && (add_mode || del_mode || assert_none || assert_any || assert_count >= 0)) - log_cmd_error("Options -list, -write and -count can not be combined with -add, -del, -assert-none, -assert-any or -assert-count.\n"); + if ((list_mode || !write_file.empty() || count_mode) && (add_mode || del_mode || assert_none || assert_any || assert_count >= 0 || assert_limit >= 0)) + log_cmd_error("Options -list, -write and -count can not be combined with -add, -del, -assert-none, -assert-any, assert-count, or -assert-limit.\n"); - if (!set_name.empty() && (list_mode || !write_file.empty() || count_mode || add_mode || del_mode || assert_none || assert_any || assert_count >= 0)) + if (!set_name.empty() && (list_mode || !write_file.empty() || count_mode || add_mode || del_mode || assert_none || assert_any || assert_count >= 0 || assert_limit >= 0)) log_cmd_error("Option -set can not be combined with -list, -write, -count, -add, -del, -assert-none, -assert-any or -assert-count.\n"); if (work_stack.size() == 0 && got_module) { @@ -1413,6 +1422,34 @@ struct SelectPass : public Pass { return; } + if (assert_limit >= 0) + { + int total_count = 0; + if (work_stack.size() == 0) + log_cmd_error("No selection to check.\n"); + RTLIL::Selection *sel = &work_stack.back(); + sel->optimize(design); + for (auto mod_it : design->modules_) + if (sel->selected_module(mod_it.first)) { + for (auto &it : mod_it.second->wires_) + if (sel->selected_member(mod_it.first, it.first)) + total_count++; + for (auto &it : mod_it.second->memories) + if (sel->selected_member(mod_it.first, it.first)) + total_count++; + for (auto &it : mod_it.second->cells_) + if (sel->selected_member(mod_it.first, it.first)) + total_count++; + for (auto &it : mod_it.second->processes) + if (sel->selected_member(mod_it.first, it.first)) + total_count++; + } + if (assert_limit < total_count) + log_error("Assertion failed: selection contains %d elements instead of the maximum number %d:%s\n", + total_count, assert_limit, sel_str.c_str()); + return; + } + if (!set_name.empty()) { if (work_stack.size() == 0) |