[#73220] change top scope index type to int32_t and fix errors with empty top scope names

This commit is contained in:
Mateusz Gancarz 2025-02-25 14:39:12 +01:00
parent dc383eb6d8
commit b875ed0ea4
2 changed files with 5 additions and 14 deletions

View File

@ -229,7 +229,7 @@ void VerilatedSaif::close() VL_MT_SAFE_EXCLUDES(m_mutex) {
printStr(")\n");
incrementIndent();
for (uint32_t topScopeIndex : m_topScopes) {
for (int32_t topScopeIndex : m_topScopes) {
recursivelyPrintScopes(topScopeIndex);
}
decrementIndent();
@ -405,6 +405,9 @@ void VerilatedSaif::pushPrefix(const std::string& name, VerilatedTracePrefixType
assert(!m_prefixStack.empty());
std::string pname = name;
if (name.empty()) {
pname = "$rootio";
}
if (type != VerilatedTracePrefixType::ARRAY_UNPACKED && type != VerilatedTracePrefixType::ARRAY_PACKED)
{
@ -422,18 +425,6 @@ void VerilatedSaif::pushPrefix(const std::string& name, VerilatedTracePrefixType
m_currentScope = newScopeIndex;
}
// An empty name means this is the root of a model created with name()=="". The
// tools get upset if we try to pass this as empty, so we put the signals under a
// new scope, but the signals further down will be peers, not children (as usual
// for name()!="")
// Terminate earlier $root?
if (m_prefixStack.back().second == VerilatedTracePrefixType::ROOTIO_MODULE) popPrefix();
if (pname.empty()) { // Start new temporary root
pname = "$rootio"; // SAIF names are not backslash escaped
m_prefixStack.emplace_back("", VerilatedTracePrefixType::ROOTIO_WRAPPER);
type = VerilatedTracePrefixType::ROOTIO_MODULE;
}
std::string newPrefix = m_prefixStack.back().first + pname;
if (type != VerilatedTracePrefixType::ARRAY_UNPACKED && type != VerilatedTracePrefixType::ARRAY_PACKED) {
newPrefix += ' ';

View File

@ -96,7 +96,7 @@ private:
int32_t m_currentScope{-1};
std::vector<SaifScope> m_scopes{};
std::vector<uint32_t> m_topScopes{};
std::vector<int32_t> m_topScopes{};
std::unordered_map<uint32_t, ActivityVar> m_activity;
std::vector<std::vector<ActivityBit>> m_activityArena;