diff options
author | Eddie Hung <eddie@fpgeh.com> | 2019-08-28 19:59:25 -0700 |
---|---|---|
committer | Eddie Hung <eddie@fpgeh.com> | 2019-08-28 19:59:25 -0700 |
commit | 116c2496011aeeac9847d69af597a0db58209793 (patch) | |
tree | 3dd99df44d7cd1201c320990e34690f06929ffec | |
parent | 34ae29295db53289e786c0279ed00474cf0294d3 (diff) | |
download | yosys-116c2496011aeeac9847d69af597a0db58209793.tar.gz yosys-116c2496011aeeac9847d69af597a0db58209793.tar.bz2 yosys-116c2496011aeeac9847d69af597a0db58209793.zip |
-auto-top should check $abstract (deferred) modules with (* top *)
-rw-r--r-- | passes/hierarchy/hierarchy.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/passes/hierarchy/hierarchy.cc b/passes/hierarchy/hierarchy.cc index fd95b94b2..ad795c69f 100644 --- a/passes/hierarchy/hierarchy.cc +++ b/passes/hierarchy/hierarchy.cc @@ -808,6 +808,37 @@ struct HierarchyPass : public Pass { if (mod_it.second->get_bool_attribute("\\top")) top_mod = mod_it.second; + if (top_mod != nullptr && auto_top_mode) { + IdString abstract_id = top_mod->name; + IdString top_name = abstract_id; + if (top_name.begins_with("$abstract")) + top_name = top_name.substr(strlen("$abstract")); + top_mod = design->module(top_name); + + dict<RTLIL::IdString, RTLIL::Const> top_parameters; + for (auto ¶ : parameters) { + SigSpec sig_value; + if (!RTLIL::SigSpec::parse(sig_value, NULL, para.second)) + log_cmd_error("Can't decode value '%s'!\n", para.second.c_str()); + top_parameters[RTLIL::escape_id(para.first)] = sig_value.as_const(); + } + + if (top_mod == nullptr && design->module(abstract_id)) + top_mod = design->module(design->module(abstract_id)->derive(design, top_parameters)); + else if (top_mod != nullptr && !top_parameters.empty()) + top_mod = design->module(top_mod->derive(design, top_parameters)); + + if (top_mod != nullptr && top_mod->name != top_name) { + Module *m = top_mod->clone(); + m->name = top_name; + Module *old_mod = design->module(top_name); + if (old_mod) + design->remove(old_mod); + design->add(m); + top_mod = m; + } + } + if (top_mod == nullptr && auto_top_mode) { log_header(design, "Finding top of design hierarchy..\n"); dict<Module*, int> db; |