diff --git a/passes/hierarchy/hierarchy.cc b/passes/hierarchy/hierarchy.cc index ea68add18..5e0f8afd0 100644 --- a/passes/hierarchy/hierarchy.cc +++ b/passes/hierarchy/hierarchy.cc @@ -659,6 +659,8 @@ bool set_keep_print(std::map &cache, RTLIL::Module *mod) { if (cache.count(mod) == 0) for (auto c : mod->cells()) { + if (mod->name == c->type) + continue; RTLIL::Module *m = mod->design->module(c->type); if ((m != nullptr && set_keep_print(cache, m)) || c->type == ID($print)) return cache[mod] = true; @@ -670,6 +672,8 @@ bool set_keep_assert(std::map &cache, RTLIL::Module *mod) { if (cache.count(mod) == 0) for (auto c : mod->cells()) { + if (mod->name == c->type) + continue; RTLIL::Module *m = mod->design->module(c->type); if ((m != nullptr && set_keep_assert(cache, m)) || c->type.in(ID($check), ID($assert), ID($assume), ID($live), ID($fair), ID($cover))) return cache[mod] = true;