[#73220] add clearing data after dumping it to output file

This commit is contained in:
Mateusz Gancarz 2025-02-25 14:20:03 +01:00
parent cf838ae96f
commit f39e5e708f
2 changed files with 14 additions and 1 deletions

View File

@ -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();

View File

@ -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<SaifScope> m_scopes{};
std::vector<uint32_t> m_topScopes{};