Skip to content

Commit

Permalink
hierarchy: Without a known top module, derive all deferred modules
Browse files Browse the repository at this point in the history
This fixes hierarchy when used with cell libraries that were loaded with
-defer and also makes more of the hierarchy visible to the auto-top
heuristic.
  • Loading branch information
jix committed Jan 12, 2024
1 parent 1eb823b commit 8af1833
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions passes/hierarchy/hierarchy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,18 @@ struct HierarchyPass : public Pass {
if (mod->get_bool_attribute(ID::top))
top_mod = mod;

if (top_mod == nullptr)
{
std::vector<IdString> abstract_ids;
for (auto module : design->modules())
if (module->name.begins_with("$abstract"))
abstract_ids.push_back(module->name);
for (auto abstract_id : abstract_ids)
design->module(abstract_id)->derive(design, {});
for (auto abstract_id : abstract_ids)
design->remove(design->module(abstract_id));
}

if (top_mod == nullptr && auto_top_mode) {
log_header(design, "Finding top of design hierarchy..\n");
dict<Module*, int> db;
Expand Down

0 comments on commit 8af1833

Please sign in to comment.