From f9e69984ff44816c56f60f10d4ef8f6c2ef5caa0 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Sun, 27 Mar 2022 15:05:24 +0100 Subject: [PATCH] Set vlSymsp in modules at construction time. This ensures it's available from very early on. No functional change. --- src/V3EmitCHeaders.cpp | 7 +++---- src/V3EmitCImp.cpp | 9 ++++----- src/V3EmitCSyms.cpp | 10 ++++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/V3EmitCHeaders.cpp b/src/V3EmitCHeaders.cpp index bb26512f2..ef53dfa16 100644 --- a/src/V3EmitCHeaders.cpp +++ b/src/V3EmitCHeaders.cpp @@ -118,7 +118,7 @@ class EmitCHeader final : public EmitCConstInit { void emitInternalVarDecls(const AstNodeModule* modp) { if (!VN_IS(modp, Class)) { putsDecoration("\n// INTERNAL VARIABLES\n"); - puts(symClassName() + "* vlSymsp; // Symbol table\n"); + puts(symClassName() + "* const vlSymsp;\n"); } } void emitParamDecls(const AstNodeModule* modp) { @@ -146,7 +146,7 @@ class EmitCHeader final : public EmitCConstInit { if (!VN_IS(modp, Class)) { // Classes use CFuncs with isConstructor/isDestructor const string& name = prefixNameProtect(modp); putsDecoration("\n// CONSTRUCTORS\n"); - puts(name + "(const char* name);\n"); + puts(name + "(" + symClassName() + "* symsp, const char* name);\n"); puts("~" + name + "();\n"); puts("VL_UNCOPYABLE(" + name + ");\n"); } @@ -157,8 +157,7 @@ class EmitCHeader final : public EmitCConstInit { if (!VN_IS(modp, Class)) { decorateFirst(first, section); - puts("void " + protect("__Vconfigure") + "(" + symClassName() - + "* symsp, bool first);\n"); + puts("void " + protect("__Vconfigure") + "(bool first);\n"); } if (v3Global.opt.coverage()) { diff --git a/src/V3EmitCImp.cpp b/src/V3EmitCImp.cpp index e4c48c181..116b2582b 100644 --- a/src/V3EmitCImp.cpp +++ b/src/V3EmitCImp.cpp @@ -234,8 +234,8 @@ class EmitCImp final : EmitCFunc { "(" + modName + "* vlSelf);"); puts("\n"); - puts(modName + "::" + modName + "(const char* _vcname__)\n"); - puts(" : VerilatedModule(_vcname__)\n"); + puts(modName + "::" + modName + "(" + symClassName() + "* symsp, const char* name)\n"); + puts(" : VerilatedModule{name}\n"); ofp()->indentInc(); for (const AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { @@ -258,6 +258,7 @@ class EmitCImp final : EmitCFunc { } } } + puts(", vlSymsp{symsp}\n"); ofp()->indentDec(); puts(" {\n"); @@ -277,10 +278,8 @@ class EmitCImp final : EmitCFunc { "(" + modName + "* vlSelf, bool first);"); } - puts("\nvoid " + modName + "::" + protect("__Vconfigure") + "(" + symClassName() - + "* _vlSymsp, bool first) {\n"); + puts("\nvoid " + modName + "::" + protect("__Vconfigure") + "(bool first) {\n"); puts("if (false && first) {} // Prevent unused\n"); - puts("this->vlSymsp = _vlSymsp;\n"); // First, as later stuff needs it. if (v3Global.opt.coverage()) { puts(modName + "__" + protect("_configure_coverage") + "(this, first);\n"); } diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 8857c23d8..07626fbed 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -726,14 +726,16 @@ void EmitCSyms::emitSymImp() { const AstNodeModule* const modp = i.second; puts(" , "); puts(protect(scopep->nameDotless())); + puts("{this"); if (modp->isTop()) { - puts("(namep)\n"); + puts(", namep"); } else { // The "." is added by catName - puts("(Verilated::catName(namep, "); + puts(", Verilated::catName(namep, "); putsQuoted(protectWordsIf(scopep->prettyName(), scopep->protect())); - puts("))\n"); + puts(")"); } + puts("}\n"); ++m_numStmts; } puts("{\n"); @@ -793,7 +795,7 @@ void EmitCSyms::emitSymImp() { const bool first = !modp->user1(); modp->user1(true); puts(protectIf(scopep->nameDotless(), scopep->protect()) + "." + protect("__Vconfigure") - + "(this, " + (first ? "true" : "false") + ");\n"); + + "(" + (first ? "true" : "false") + ");\n"); ++m_numStmts; }