Better job choosing unique scope-local symbols during elaboration.

This commit is contained in:
Stephen Williams 2019-09-25 12:18:41 -07:00
parent ecd7b39244
commit 65aff65344
1 changed files with 22 additions and 3 deletions

View File

@ -743,9 +743,28 @@ const NetScope* NetScope::child_byname(perm_string name) const
perm_string NetScope::local_symbol()
{
perm_string sym;
do {
ostringstream res;
res << "_s" << (lcounter_++);
return lex_strings.make(res.str());
res << "_ivl_" << (lcounter_++);
perm_string sym_tmp = lex_strings.make(res.str());
// If the name already exists as a signal, try again.
if (signals_map_.find(sym_tmp) != signals_map_.end())
continue;
// If the name already exists as a parameter, try again.
if (parameters.find(sym_tmp) != parameters.end())
continue;
if (genvars_.find(sym_tmp) != genvars_.end())
continue;
// If the name already exists as a class, try again.
if (classes_.find(sym_tmp) != classes_.end())
continue;
// No collisions, this is the one.
sym = sym_tmp;
} while (sym.nil());
return sym;
}
void NetScope::add_tie_hi(Design*des)