3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-18 21:25:47 +00:00

cleaner with warning

This commit is contained in:
Stan Lee 2026-03-06 10:23:31 -08:00
parent c3a9a6d90e
commit 20c1f3212f
4 changed files with 13 additions and 9 deletions

View file

@ -397,7 +397,7 @@ int FstData::getWidth(fstHandle signal)
}
// Auto-discover scope from FST by finding the top module
std::vector<std::string> 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<std::string> 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;
}

View file

@ -58,7 +58,7 @@ class FstData
double getTimescale() { return timescale; }
const char *getTimescaleString() { return timescale_str.c_str(); }
int getWidth(fstHandle signal);
std::vector<std::string> autoScope(Module *topmod);
std::string autoScope(Module *topmod);
private:
void extractVarNames();

View file

@ -1475,12 +1475,11 @@ struct SimWorker : SimShared
fst = new FstData(sim_filename);
timescale = fst->getTimescaleString();
if (scope.empty()) {
std::vector<std::string> 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());

View file

@ -200,12 +200,11 @@ struct RegRenamePass : public Pass {
try {
FstData fst(vcd_filename);
if (scope.empty()) {
std::vector<std::string> 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()) {