Fixed bug in "hierarchy" for parametric designs

This commit is contained in:
Clifford Wolf 2015-03-04 15:52:34 +01:00
parent adc12ce46e
commit ed15400fc6
1 changed files with 19 additions and 20 deletions

View File

@ -285,7 +285,7 @@ void hierarchy_worker(RTLIL::Design *design, std::set<RTLIL::Module*> &used, RTL
} }
} }
void hierarchy(RTLIL::Design *design, RTLIL::Module *top, bool purge_lib, bool first_pass) void hierarchy_clean(RTLIL::Design *design, RTLIL::Module *top, bool purge_lib)
{ {
std::set<RTLIL::Module*> used; std::set<RTLIL::Module*> used;
hierarchy_worker(design, used, top, 0); hierarchy_worker(design, used, top, 0);
@ -297,7 +297,7 @@ void hierarchy(RTLIL::Design *design, RTLIL::Module *top, bool purge_lib, bool f
int del_counter = 0; int del_counter = 0;
for (auto mod : del_modules) { for (auto mod : del_modules) {
if (first_pass && mod->name.substr(0, 9) == "$abstract") if (mod->name.substr(0, 9) == "$abstract")
continue; continue;
if (!purge_lib && mod->get_bool_attribute("\\blackbox")) if (!purge_lib && mod->get_bool_attribute("\\blackbox"))
continue; continue;
@ -488,30 +488,29 @@ struct HierarchyPass : public Pass {
if (mod_it.second->get_bool_attribute("\\top")) if (mod_it.second->get_bool_attribute("\\top"))
top_mod = mod_it.second; top_mod = mod_it.second;
if (top_mod != NULL)
hierarchy(design, top_mod, purge_lib, true);
bool did_something = true; bool did_something = true;
bool did_something_once = false; while (did_something)
while (did_something) { {
did_something = false; did_something = false;
std::vector<RTLIL::IdString> modnames;
modnames.reserve(design->modules_.size()); std::set<RTLIL::Module*> used_modules;
for (auto &mod_it : design->modules_) if (top_mod != NULL) {
modnames.push_back(mod_it.first); log_header("Analyzing design hierarchy..\n");
for (auto &modname : modnames) { hierarchy_worker(design, used_modules, top_mod, 0);
if (design->modules_.count(modname) == 0) } else {
continue; for (auto mod : design->modules())
if (expand_module(design, design->modules_[modname], flag_check, libdirs)) used_modules.insert(mod);
}
for (auto module : used_modules) {
if (expand_module(design, module, flag_check, libdirs))
did_something = true; did_something = true;
} }
if (did_something)
did_something_once = true;
} }
if (top_mod != NULL && did_something_once) { if (top_mod != NULL) {
log_header("Re-running hierarchy analysis..\n"); log_header("Analyzing design hierarchy..\n");
hierarchy(design, top_mod, purge_lib, false); hierarchy_clean(design, top_mod, purge_lib);
} }
if (top_mod != NULL) { if (top_mod != NULL) {