forked from github/verilator
Move contextp() under VerilatedModel
This commit is contained in:
parent
f4038e3674
commit
b61d819fcb
@ -2908,6 +2908,12 @@ void VerilatedImp::versionDump() VL_MT_SAFE {
|
||||
VL_PRINTF_MT(" Version: %s %s\n", Verilated::productName(), Verilated::productVersion());
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// VerilatedModel:: Methods
|
||||
|
||||
VerilatedModel::VerilatedModel(VerilatedContext& context)
|
||||
: m_context{context} {}
|
||||
|
||||
//===========================================================================
|
||||
// VerilatedModule:: Methods
|
||||
|
||||
|
@ -81,6 +81,7 @@
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
class VerilatedContext;
|
||||
class VerilatedContextImp;
|
||||
class VerilatedContextImpData;
|
||||
class VerilatedCovContext;
|
||||
@ -261,11 +262,16 @@ public:
|
||||
class VerilatedModel VL_NOT_FINAL {
|
||||
VL_UNCOPYABLE(VerilatedModel);
|
||||
|
||||
VerilatedContext& m_context; // The VerilatedContext this model is instantiated under
|
||||
|
||||
protected:
|
||||
explicit VerilatedModel() = default;
|
||||
explicit VerilatedModel(VerilatedContext& context);
|
||||
virtual ~VerilatedModel() = default;
|
||||
|
||||
public:
|
||||
/// Returns the VerilatedContext this model is instantiated under
|
||||
/// 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;
|
||||
/// Returns the name of this model (the name of the generated model class).
|
||||
|
@ -195,9 +195,6 @@ class EmitCModel final : public EmitCFunc {
|
||||
}
|
||||
}
|
||||
|
||||
puts("/// Return current simulation context for this model.\n");
|
||||
puts("/// Used to get to e.g. simulation time via contextp()->time()\n");
|
||||
puts("VerilatedContext* contextp() const;\n");
|
||||
if (!optSystemC()) {
|
||||
puts("/// Retrieve name of this model instance (as passed to constructor).\n");
|
||||
puts("const char* name() const;\n");
|
||||
@ -241,11 +238,12 @@ class EmitCModel final : public EmitCFunc {
|
||||
puts(topClassName() + "::" + topClassName());
|
||||
if (optSystemC()) {
|
||||
puts("(sc_module_name /* unused */)\n");
|
||||
puts(" : vlSymsp{new " + symClassName()
|
||||
+ "(Verilated::threadContextp(), name(), this)}\n");
|
||||
puts(" : VerilatedModel{*Verilated::threadContextp()}\n");
|
||||
puts(" , vlSymsp{new " + symClassName() + "(contextp(), name(), this)}\n");
|
||||
} else {
|
||||
puts(+"(VerilatedContext* _vcontextp__, const char* _vcname__)\n");
|
||||
puts(" : vlSymsp{new " + symClassName() + "(_vcontextp__, _vcname__, this)}\n");
|
||||
puts(" : VerilatedModel{*_vcontextp__}\n");
|
||||
puts(" , vlSymsp{new " + symClassName() + "(contextp(), _vcname__, this)}\n");
|
||||
}
|
||||
|
||||
// Set up IO references
|
||||
@ -271,7 +269,7 @@ class EmitCModel final : public EmitCFunc {
|
||||
|
||||
puts("{\n");
|
||||
puts("// Register model with the context\n");
|
||||
puts("vlSymsp->_vm_contextp__->addModel(this);\n");
|
||||
puts("contextp()->addModel(this);\n");
|
||||
|
||||
if (optSystemC()) {
|
||||
// Create sensitivity list for when to evaluate the model.
|
||||
@ -469,10 +467,6 @@ class EmitCModel final : public EmitCFunc {
|
||||
}
|
||||
|
||||
putSectionDelimiter("Utilities");
|
||||
// ::contextp
|
||||
puts("\nVerilatedContext* " + topClassName() + "::contextp() const {\n");
|
||||
puts(/**/ "return vlSymsp->_vm_contextp__;\n");
|
||||
puts("}\n");
|
||||
|
||||
if (!optSystemC()) {
|
||||
// ::name
|
||||
|
Loading…
Reference in New Issue
Block a user