diff --git a/kernel/fstdata.cc b/kernel/fstdata.cc index dd88590b2..f2e73e9ec 100644 --- a/kernel/fstdata.cc +++ b/kernel/fstdata.cc @@ -397,7 +397,7 @@ int FstData::getWidth(fstHandle signal) } // Auto-discover scope from FST by finding the top module -std::vector FstData::autoScope(Module *topmod) { +std::string FstData::autoScope(Module *topmod) { log("Auto-discovering scopes from file...\n"); std::string top = RTLIL::unescape_id(topmod->name); @@ -449,11 +449,17 @@ std::vector FstData::autoScope(Module *topmod) { if (results.empty()) { log_warning("Could not auto-discover scope for module '%s'...\n", RTLIL::unescape_id(topmod->name).c_str()); + return ""; } else { log("Found %d scopes for module '%s':\n", GetSize(results), RTLIL::unescape_id(topmod->name).c_str()); for (const auto& scope : results) { log(" %s\n", scope.c_str()); } + if (results.size() > 1) { + log_warning("Multiple scopes found for module '%s'. Using the first one.\n", + RTLIL::unescape_id(topmod->name).c_str()); + } + std::string scope = results[0]; } - return results; + return scope; } diff --git a/kernel/fstdata.h b/kernel/fstdata.h index 01e175691..f95806cca 100644 --- a/kernel/fstdata.h +++ b/kernel/fstdata.h @@ -58,7 +58,7 @@ class FstData double getTimescale() { return timescale; } const char *getTimescaleString() { return timescale_str.c_str(); } int getWidth(fstHandle signal); - std::vector autoScope(Module *topmod); + std::string autoScope(Module *topmod); private: void extractVarNames(); diff --git a/passes/sat/sim.cc b/passes/sat/sim.cc index 00b144037..113a15bdd 100644 --- a/passes/sat/sim.cc +++ b/passes/sat/sim.cc @@ -1475,12 +1475,11 @@ struct SimWorker : SimShared fst = new FstData(sim_filename); timescale = fst->getTimescaleString(); if (scope.empty()) { - std::vector scopes = fst->autoScope(topmod); - if (scopes.empty()) { + scope = fst->autoScope(topmod); + if (scope.empty()) { log_error("No scope found for module '%s'. Please specify -scope explicitly.\n", RTLIL::unescape_id(topmod->name).c_str()); } - scope = scopes[0]; // Use the first scope found by default } log("Using scope: \"%s\"\n", scope.c_str()); diff --git a/passes/silimate/reg_rename.cc b/passes/silimate/reg_rename.cc index e5c7ffca2..5635b6869 100644 --- a/passes/silimate/reg_rename.cc +++ b/passes/silimate/reg_rename.cc @@ -200,12 +200,11 @@ struct RegRenamePass : public Pass { try { FstData fst(vcd_filename); if (scope.empty()) { - std::vector scopes = fst.autoScope(topmod); - if (scopes.empty()) { + scope = fst.autoScope(topmod); + if (scope.empty()) { log_error("No scope found for module '%s'. Please specify -scope explicitly.\n", RTLIL::unescape_id(topmod->name).c_str()); } - scope = scopes[0]; // Use the first scope found by default } log("Using scope: \"%s\"\n", scope.c_str()); for (auto &var : fst.getVars()) {