From e6b19d557e848ec0077f4847cd19ddf0f2a46660 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 14 Mar 2021 09:08:17 -0400 Subject: [PATCH] Fix false $dumpfile warning on model save (#2834). --- Changes | 2 ++ include/verilated.cpp | 8 ++++++-- include/verilated.h | 1 + src/V3EmitC.cpp | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 841cb887d..a39db2e05 100644 --- a/Changes +++ b/Changes @@ -10,6 +10,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix exceeding command-line ar limit (#2834). [Yinan Xu] +**** Fix false $dumpfile warning on model save (#2834). [Yinan Xu] + * Verilator 4.200 2021-03-12 diff --git a/include/verilated.cpp b/include/verilated.cpp index 3d3f8bddc..0ee5a46e6 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -2202,11 +2202,15 @@ void VerilatedContext::dumpfile(const std::string& flag) VL_MT_SAFE_EXCLUDES(m_t } std::string VerilatedContext::dumpfile() const VL_MT_SAFE_EXCLUDES(m_timeDumpMutex) { const VerilatedLockGuard lock(m_timeDumpMutex); - if (VL_UNLIKELY(m_dumpfile.empty())) { + return m_dumpfile; +} +std::string VerilatedContext::dumpfileCheck() const VL_MT_SAFE_EXCLUDES(m_timeDumpMutex) { + const std::string out = dumpfile(); + if (VL_UNLIKELY(out.empty())) { VL_PRINTF_MT("%%Warning: $dumpvar ignored as not proceeded by $dumpfile\n"); return ""; } - return m_dumpfile; + return out; } void VerilatedContext::errorCount(int val) VL_MT_SAFE { const VerilatedLockGuard lock(m_mutex); diff --git a/include/verilated.h b/include/verilated.h index 980beda10..49997bcbc 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -529,6 +529,7 @@ public: // But for internal use only // Internal: $dumpfile void dumpfile(const std::string& flag) VL_MT_SAFE_EXCLUDES(m_timeDumpMutex); std::string dumpfile() const VL_MT_SAFE_EXCLUDES(m_timeDumpMutex); + std::string dumpfileCheck() const VL_MT_SAFE_EXCLUDES(m_timeDumpMutex); // Internal: --prof-threads related settings void profThreadsStart(vluint64_t flag) VL_MT_SAFE; diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index d231f37d5..0ea41997c 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -3523,7 +3523,7 @@ class EmitCTrace final : EmitCStmts { puts("if (VL_UNLIKELY(!__VlSymsp->__Vm_dumperp)) {\n"); puts("__VlSymsp->__Vm_dumperp = new " + v3Global.opt.traceClassLang() + "();\n"); puts("trace(__VlSymsp->__Vm_dumperp, 0, 0);\n"); - puts("std::string dumpfile = __VlSymsp->_vm_contextp__->dumpfile();\n"); + puts("std::string dumpfile = __VlSymsp->_vm_contextp__->dumpfileCheck();\n"); puts("__VlSymsp->__Vm_dumperp->open(dumpfile.c_str());\n"); puts("__VlSymsp->__Vm_dumping = true;\n"); puts("}\n");