From 977002b1d2677b0bb82e3e0decec5c03c6eb69a9 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Tue, 5 Apr 2022 14:02:37 +0200 Subject: [PATCH] Reorder steps in -auto-top to fix synth command, fixes #3261 --- passes/hierarchy/hierarchy.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/passes/hierarchy/hierarchy.cc b/passes/hierarchy/hierarchy.cc index 440881f19..d40d6e59f 100644 --- a/passes/hierarchy/hierarchy.cc +++ b/passes/hierarchy/hierarchy.cc @@ -976,6 +976,19 @@ struct HierarchyPass : public Pass { if (mod->get_bool_attribute(ID::top)) top_mod = mod; + if (top_mod == nullptr && auto_top_mode) { + log_header(design, "Finding top of design hierarchy..\n"); + dict db; + for (Module *mod : design->selected_modules()) { + int score = find_top_mod_score(design, mod, db); + log("root of %3d design levels: %-20s\n", score, log_id(mod)); + if (!top_mod || score > db[top_mod]) + top_mod = mod; + } + if (top_mod != nullptr) + log("Automatically selected %s as design top module.\n", log_id(top_mod)); + } + if (top_mod != nullptr && top_mod->name.begins_with("$abstract")) { IdString top_name = top_mod->name.substr(strlen("$abstract")); @@ -1000,19 +1013,6 @@ struct HierarchyPass : public Pass { } } - if (top_mod == nullptr && auto_top_mode) { - log_header(design, "Finding top of design hierarchy..\n"); - dict db; - for (Module *mod : design->selected_modules()) { - int score = find_top_mod_score(design, mod, db); - log("root of %3d design levels: %-20s\n", score, log_id(mod)); - if (!top_mod || score > db[top_mod]) - top_mod = mod; - } - if (top_mod != nullptr) - log("Automatically selected %s as design top module.\n", log_id(top_mod)); - } - if (flag_simcheck && top_mod == nullptr) log_error("Design has no top module.\n"); -- 2.30.2