diff options
author | Alberto Gonzalez <boqwxp@airmail.cc> | 2020-04-07 03:29:54 +0000 |
---|---|---|
committer | Alberto Gonzalez <boqwxp@airmail.cc> | 2020-04-07 03:29:54 +0000 |
commit | 194354e1280b082c2d4066839010b9d250386bb7 (patch) | |
tree | 1ca31fd2315f2b5a61c2473f32c93364c506c3ff | |
parent | 5fedd0931c6e749483b8ddb3d7672ddca9ac5310 (diff) | |
download | yosys-194354e1280b082c2d4066839010b9d250386bb7.tar.gz yosys-194354e1280b082c2d4066839010b9d250386bb7.tar.bz2 yosys-194354e1280b082c2d4066839010b9d250386bb7.zip |
Remove `$anyconst` cells before specialization to eliminate warnings and the need to run `opt_clean`.
-rw-r--r-- | passes/sat/qbfsat.cc | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/passes/sat/qbfsat.cc b/passes/sat/qbfsat.cc index 798a8edbb..b9b9267eb 100644 --- a/passes/sat/qbfsat.cc +++ b/passes/sat/qbfsat.cc @@ -124,6 +124,8 @@ void write_solution(RTLIL::Module *module, const QbfSolutionType &sol, const std void specialize_from_file(RTLIL::Module *module, const std::string &file) { YS_REGEX_TYPE hole_assn_regex = YS_REGEX_COMPILE_WITH_SUBS("^(.*)=([01]+)$"); YS_REGEX_MATCH_TYPE m; + std::set<RTLIL::Cell *> anyconsts_to_remove; + std::map<std::string, std::string> hole_name_to_value; std::ifstream fin(file.c_str()); if (!fin) log_cmd_error("could not read solution file.\n"); @@ -133,7 +135,23 @@ void specialize_from_file(RTLIL::Module *module, const std::string &file) { log_assert(YS_REGEX_NS::regex_search(buf, m, hole_assn_regex)); std::string hole_name = m[1].str(); std::string hole_value = m[2].str(); + hole_name_to_value[hole_name] = hole_value; + } + + for (auto cell : module->cells()) + if (cell->type == "$anyconst") { + auto anyconst_port_y = cell->getPort(ID::Y).as_wire(); + if (anyconst_port_y == nullptr) + continue; + if (hole_name_to_value.find(anyconst_port_y->name.str()) != hole_name_to_value.end()) + anyconsts_to_remove.insert(cell); + } + for (auto cell : anyconsts_to_remove) + module->remove(cell); + for (auto &it : hole_name_to_value) { + std::string hole_name = it.first; + std::string hole_value = it.second; RTLIL::Wire *wire = module->wire(hole_name); #ifndef NDEBUG log_assert(wire != nullptr); @@ -152,6 +170,13 @@ void specialize_from_file(RTLIL::Module *module, const std::string &file) { void specialize(RTLIL::Module *module, const QbfSolutionType &sol) { std::map<std::string, std::string> hole_loc_to_name = get_hole_loc_name_map(module, sol); + std::set<RTLIL::Cell *> anyconsts_to_remove; + for (auto cell : module->cells()) + if (cell->type == "$anyconst") + if (hole_loc_to_name.find(cell->get_src_attribute()) != hole_loc_to_name.end()) + anyconsts_to_remove.insert(cell); + for (auto cell : anyconsts_to_remove) + module->remove(cell); for (auto &it : sol.hole_to_value) { std::string hole_loc = it.first; std::string hole_value = it.second; @@ -508,7 +533,6 @@ struct QbfSatPass : public Pass { } if (opt.specialize) { specialize(module, ret); - Pass::call(design, "opt_clean"); } else { dump_model(module, ret); } @@ -521,7 +545,6 @@ struct QbfSatPass : public Pass { log_cmd_error("expected problem to be %s\n", opt.sat? "SAT" : "UNSAT"); } else { specialize_from_file(module, opt.specialize_soln_file); - Pass::call(design, "opt_clean"); } log_pop(); } |