Skip to content

Commit

Permalink
Merge pull request #2874 from whitequark/cxxrtl-fix-2589
Browse files Browse the repository at this point in the history
cxxrtl: run hierarchy pass regardless of (*top*) attribute presence
  • Loading branch information
whitequark authored Jul 16, 2021
2 parents efc4327 + 5b003d6 commit 2db4137
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions backends/cxxrtl/cxxrtl_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2939,9 +2939,9 @@ struct CxxrtlWorker {
}
}

void check_design(RTLIL::Design *design, bool &has_top, bool &has_sync_init)
void check_design(RTLIL::Design *design, bool &has_sync_init)
{
has_sync_init = has_top = false;
has_sync_init = false;

for (auto module : design->modules()) {
if (module->get_blackbox_attribute() && !module->has_attribute(ID(cxxrtl_blackbox)))
Expand All @@ -2953,9 +2953,6 @@ struct CxxrtlWorker {
if (!design->selected_module(module))
continue;

if (module->get_bool_attribute(ID::top))
has_top = true;

for (auto proc : module->processes)
for (auto sync : proc.second->syncs)
if (sync->type == RTLIL::STi)
Expand All @@ -2966,10 +2963,10 @@ struct CxxrtlWorker {
void prepare_design(RTLIL::Design *design)
{
bool did_anything = false;
bool has_top, has_sync_init;
bool has_sync_init;
log_push();
check_design(design, has_top, has_sync_init);
if (run_hierarchy && !has_top) {
check_design(design, has_sync_init);
if (run_hierarchy) {
Pass::call(design, "hierarchy -auto-top");
did_anything = true;
}
Expand All @@ -2990,7 +2987,7 @@ struct CxxrtlWorker {
}
// Recheck the design if it was modified.
if (did_anything)
check_design(design, has_top, has_sync_init);
check_design(design, has_sync_init);
log_assert(!has_sync_init);
log_pop();
if (did_anything)
Expand Down

0 comments on commit 2db4137

Please sign in to comment.