diff --git a/include/verilated.h b/include/verilated.h index 3a4fab003..ebb1990e8 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -273,11 +273,11 @@ public: /// Used to get to e.g. simulation time via contextp()->time() inline VerilatedContext* contextp() const { return &m_context; } /// Returns the hierarchical name of this module instance. - virtual const char* hierName() = 0; + virtual const char* hierName() const = 0; /// Returns the name of this model (the name of the generated model class). - virtual const char* modelName() = 0; + virtual const char* modelName() const = 0; /// Returns the thread level parallelism, this model was Verilated with. Always 1 or higher. - virtual unsigned threads() = 0; + virtual unsigned threads() const = 0; }; //========================================================================= diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index 9522b214f..04b422a97 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -220,9 +220,9 @@ class EmitCModel final : public EmitCFunc { } puts("\n// Abstract methods from VerilatedModel\n"); - puts("const char* hierName() override;\n"); - puts("const char* modelName() override;\n"); - puts("unsigned threads() override;\n"); + puts("const char* hierName() const override final;\n"); + puts("const char* modelName() const override final;\n"); + puts("unsigned threads() const override final;\n"); puts("} VL_ATTR_ALIGNED(VL_CACHE_LINE_BYTES);\n"); @@ -482,10 +482,10 @@ class EmitCModel final : public EmitCFunc { puts("}\n"); putSectionDelimiter("Implementations of abstract methods from VerilatedModel\n"); - puts("const char* " + topClassName() + "::hierName() { return vlSymsp->name(); }\n"); - puts("const char* " + topClassName() + "::modelName() { return \"" + topClassName() + puts("const char* " + topClassName() + "::hierName() const { return vlSymsp->name(); }\n"); + puts("const char* " + topClassName() + "::modelName() const { return \"" + topClassName() + "\"; }\n"); - puts("unsigned " + topClassName() + "::threads() { return " + puts("unsigned " + topClassName() + "::threads() const { return " + cvtToStr(std::max(1, v3Global.opt.threads())) + "; }\n"); }