From f064a94f1d34d05347977a5894c1fd2288851efe Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Sat, 19 Jun 2021 17:12:56 +0100 Subject: [PATCH] Configure time unit/time precision in the Sym constructor. This used to be done in the constructor of the top module, but there is no reason to do it there. Internals are cleaner with this in the Sym constructor. No functional change intended. --- src/V3EmitC.cpp | 8 -------- src/V3EmitCSyms.cpp | 12 ++++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 77142c101..b8f870f21 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -2549,14 +2549,6 @@ void EmitCImp::emitConfigureImp(AstNodeModule* modp) { if (v3Global.opt.coverage()) { puts(modName + "__" + protect("_configure_coverage") + "(this, first);\n"); } - if (modp->isTop() && !v3Global.rootp()->timeunit().isNone()) { - puts("vlSymsp->_vm_contextp__->timeunit(" - + cvtToStr(v3Global.rootp()->timeunit().powerOfTen()) + ");\n"); - } - if (modp->isTop() && !v3Global.rootp()->timeprecision().isNone()) { - puts("vlSymsp->_vm_contextp__->timeprecision(" - + cvtToStr(v3Global.rootp()->timeprecision().powerOfTen()) + ");\n"); - } puts("}\n"); splitSizeInc(10); } diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index f5d41845b..ccd80af56 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -704,6 +704,18 @@ void EmitCSyms::emitSymImp() { } } + puts("// Configure time unit / time precision\n"); + if (!v3Global.rootp()->timeunit().isNone()) { + puts("_vm_contextp__->timeunit("); + puts(cvtToStr(v3Global.rootp()->timeunit().powerOfTen())); + puts(");\n"); + } + if (!v3Global.rootp()->timeprecision().isNone()) { + puts("_vm_contextp__->timeprecision("); + puts(cvtToStr(v3Global.rootp()->timeprecision().powerOfTen())); + puts(");\n"); + } + puts("// Setup each module's pointer back to symbol table (for public functions)\n"); puts("TOPp->" + protect("__Vconfigure") + "(this, true);\n"); for (const auto& i : m_scopes) {