diff --git a/include/verilated_saif_c.cpp b/include/verilated_saif_c.cpp index 19611cf6a..8e73f9d15 100644 --- a/include/verilated_saif_c.cpp +++ b/include/verilated_saif_c.cpp @@ -230,7 +230,9 @@ void VerilatedSaif::close() VL_MT_SAFE_EXCLUDES(m_mutex) { printStr(")\n"); incrementIndent(); - recursivelyPrintScopes(TOP_SCOPE_INDEX); + for (uint32_t topScopeIndex : m_topScopes) { + recursivelyPrintScopes(topScopeIndex); + } decrementIndent(); printStr(")\n"); // SAIFILE @@ -403,6 +405,8 @@ void VerilatedSaif::pushPrefix(const std::string& name, VerilatedTracePrefixType if (m_currentScope >= 0) { m_scopes.at(m_currentScope).childScopesIndices.emplace_back(newScopeIndex); newScope.parentScopeIndex = m_currentScope; + } else { + m_topScopes.emplace_back(newScopeIndex); } m_currentScope = newScopeIndex; } diff --git a/include/verilated_saif_c.h b/include/verilated_saif_c.h index 04adb8f09..53f5995d0 100644 --- a/include/verilated_saif_c.h +++ b/include/verilated_saif_c.h @@ -92,9 +92,9 @@ private: size_t m_maxSignalBytes = 0; // Upper bound on number of bytes a single signal can generate uint64_t m_wroteBytes = 0; // Number of bytes written to this file - static constexpr int32_t TOP_SCOPE_INDEX{0}; int32_t m_currentScope{-1}; std::vector m_scopes{}; + std::vector m_topScopes{}; std::unordered_map m_activity; std::vector> m_activityArena;