From 78e0cd5b34832fbb4fcd4e54fad979273c3bf603 Mon Sep 17 00:00:00 2001 From: Mateusz Gancarz Date: Mon, 3 Mar 2025 15:24:06 +0100 Subject: [PATCH] [#73912] fix incorrect nesting of scopes in case of empty top name --- include/verilated_saif_c.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/include/verilated_saif_c.cpp b/include/verilated_saif_c.cpp index 5cdd253bb..90a524777 100644 --- a/include/verilated_saif_c.cpp +++ b/include/verilated_saif_c.cpp @@ -376,10 +376,14 @@ void VerilatedSaif::printIndent() { } void VerilatedSaif::pushPrefix(const std::string& name, VerilatedTracePrefixType type) { - assert(!m_prefixStack.empty()); - std::string pname = name; - if (pname.empty()) { pname = "$rootio"; } + + if (m_prefixStack.back().second == VerilatedTracePrefixType::ROOTIO_MODULE) popPrefix(); + if (pname.empty()) + { + pname = "$rootio"; + type = VerilatedTracePrefixType::ROOTIO_MODULE; + } if (type != VerilatedTracePrefixType::ARRAY_UNPACKED && type != VerilatedTracePrefixType::ARRAY_PACKED) { @@ -403,10 +407,9 @@ void VerilatedSaif::pushPrefix(const std::string& name, VerilatedTracePrefixType } void VerilatedSaif::popPrefix() { - assert(m_prefixStack.size() > 1); - if (m_prefixStack.back().second != VerilatedTracePrefixType::ARRAY_UNPACKED - && m_prefixStack.back().second != VerilatedTracePrefixType::ARRAY_PACKED) { + && m_prefixStack.back().second != VerilatedTracePrefixType::ARRAY_PACKED + && m_currentScope >= 0) { m_currentScope = m_scopes.at(m_currentScope).getParentScopeIndex(); }