From 343db78c03b1754ba4756440fcffc333adb39ccc Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 9 Apr 2020 23:03:28 -0400 Subject: [PATCH] Fix including verilated_sc in Syms to fix compile order problem exposed in #2237. --- src/V3EmitC.cpp | 6 +++++- src/V3EmitCSyms.cpp | 24 +++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 1bf5cbc19..2e98bc6a4 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -3110,7 +3110,11 @@ class EmitCTrace : EmitCStmts { cfilep->support(true); if (m_ofp) v3fatalSrc("Previous file not closed"); - m_ofp = new V3OutCFile(filename); + if (optSystemC()) { + m_ofp = new V3OutScFile(filename); + } else { + m_ofp = new V3OutCFile(filename); + } m_ofp->putsHeader(); m_ofp->puts("// DESCR" "IPTION: Verilator output: Tracing implementation internals\n"); diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 51616453e..3a4534e7d 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -360,8 +360,12 @@ void EmitCSyms::emitSymHdr() { UINFO(6,__FUNCTION__<<": "<putsHeader(); puts("// DESCR" "IPTION: Verilator output: Symbol table internal header\n"); @@ -482,6 +486,7 @@ void EmitCSyms::emitSymHdr() { puts("} VL_ATTR_ALIGNED(VL_CACHE_LINE_BYTES);\n"); ofp()->putsEndGuard(); + VL_DO_CLEAR(delete m_ofp, m_ofp = NULL); } void EmitCSyms::closeSplit() { @@ -502,7 +507,11 @@ void EmitCSyms::checkSplit(bool usesVfinal) { m_usesVfinal[m_funcNum] = usesVfinal; closeSplit(); - m_ofp = new V3OutCFile(filename); + if (v3Global.opt.systemC()) { + m_ofp = new V3OutScFile(filename); + } else { + m_ofp = new V3OutCFile(filename); + } m_ofpBase->puts(symClassName()+"_"+cvtToStr(m_funcNum)+"("); if (usesVfinal) { @@ -541,8 +550,13 @@ void EmitCSyms::emitSymImp() { string filename = v3Global.opt.makeDir()+"/"+symClassName()+".cpp"; AstCFile* cfilep = newCFile(filename, true/*slow*/, true/*source*/); cfilep->support(true); - V3OutCFile cf (filename); - m_ofp = &cf; + + if (v3Global.opt.systemC()) { + m_ofp = new V3OutScFile(filename); + } else { + m_ofp = new V3OutCFile(filename); + } + m_ofpBase = m_ofp; emitSymImpPreamble();