Skip to content

Commit b500e16

Browse files
committed
hierarchy: Without a known top module, derive all deferred modules
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.
1 parent 2422dd6 commit b500e16

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

passes/hierarchy/hierarchy.cc

+12
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,18 @@ struct HierarchyPass : public Pass {
10061006
if (mod->get_bool_attribute(ID::top))
10071007
top_mod = mod;
10081008

1009+
if (top_mod == nullptr)
1010+
{
1011+
std::vector<IdString> abstract_ids;
1012+
for (auto module : design->modules())
1013+
if (module->name.begins_with("$abstract"))
1014+
abstract_ids.push_back(module->name);
1015+
for (auto abstract_id : abstract_ids)
1016+
design->module(abstract_id)->derive(design, {});
1017+
for (auto abstract_id : abstract_ids)
1018+
design->remove(design->module(abstract_id));
1019+
}
1020+
10091021
if (top_mod == nullptr && auto_top_mode) {
10101022
log_header(design, "Finding top of design hierarchy..\n");
10111023
dict<Module*, int> db;

tests/verilog/param_no_default.ys

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
read_verilog -sv param_no_default.sv
2-
hierarchy
2+
hierarchy -top top
33
proc
44
flatten
55
opt -full

0 commit comments

Comments
 (0)