From f39e5e708f1755729e6cb028e99f90659f8126dd Mon Sep 17 00:00:00 2001 From: Mateusz Gancarz Date: Tue, 25 Feb 2025 14:20:03 +0100 Subject: [PATCH] [#73220] add clearing data after dumping it to output file --- include/verilated_saif_c.cpp | 13 ++++++++++++- include/verilated_saif_c.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/verilated_saif_c.cpp b/include/verilated_saif_c.cpp index 8bc806703..bda227629 100644 --- a/include/verilated_saif_c.cpp +++ b/include/verilated_saif_c.cpp @@ -224,7 +224,6 @@ void VerilatedSaif::closeErr() { } void VerilatedSaif::close() VL_MT_SAFE_EXCLUDES(m_mutex) { - assert(m_time > 0); printStr("(DURATION "); printStr(std::to_string(m_time).c_str()); printStr(")\n"); @@ -237,6 +236,8 @@ void VerilatedSaif::close() VL_MT_SAFE_EXCLUDES(m_mutex) { printStr(")\n"); // SAIFILE + clearCurrentlyCollectedData(); + // This function is on the flush() call path const VerilatedLockGuard lock{m_mutex}; if (!isOpen()) return; @@ -318,6 +319,16 @@ void VerilatedSaif::recursivelyPrintScopes(uint32_t scopeIndex) { printStr(")\n"); // INSTANCE } +void VerilatedSaif::clearCurrentlyCollectedData() +{ + m_currentScope = -1; + m_scopes.clear(); + m_topScopes.clear(); + m_activity.clear(); + m_activityArena.clear(); + m_time = 0; +} + void VerilatedSaif::flush() VL_MT_SAFE_EXCLUDES(m_mutex) { const VerilatedLockGuard lock{m_mutex}; Super::flushBase(); diff --git a/include/verilated_saif_c.h b/include/verilated_saif_c.h index 53f5995d0..9a54bc5e0 100644 --- a/include/verilated_saif_c.h +++ b/include/verilated_saif_c.h @@ -92,6 +92,8 @@ 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 + void clearCurrentlyCollectedData(); + int32_t m_currentScope{-1}; std::vector m_scopes{}; std::vector m_topScopes{};