Set vlSymsp in modules at construction time.

This ensures it's available from very early on. No functional change.
This commit is contained in:
Geza Lore 2022-03-27 15:05:24 +01:00
parent b1b5b5dfe2
commit f9e69984ff
3 changed files with 13 additions and 13 deletions

View File

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

View File

@ -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");
}

View File

@ -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;
}