mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Pass VerilatedModel at trace registration time
This commit is contained in:
parent
0dfa7d3af5
commit
9085e34d70
@ -215,7 +215,7 @@ private:
|
||||
double m_timeRes = 1e-9; // Time resolution (ns/ms etc)
|
||||
double m_timeUnit = 1e-0; // Time units (ns/ms etc)
|
||||
|
||||
void addContext(VerilatedContext*) VL_MT_SAFE_EXCLUDES(m_mutex);
|
||||
void addModel(VerilatedModel*) VL_MT_SAFE_EXCLUDES(m_mutex);
|
||||
|
||||
void addCallbackRecord(std::vector<CallbackRecord>& cbVec, CallbackRecord&& cbRec)
|
||||
VL_MT_SAFE_EXCLUDES(m_mutex);
|
||||
@ -339,10 +339,10 @@ public:
|
||||
//=========================================================================
|
||||
// Non-hot path internal interface to Verilator generated code
|
||||
|
||||
void addInitCb(initCb_t cb, void* userp, VerilatedContext*) VL_MT_SAFE;
|
||||
void addFullCb(dumpCb_t cb, void* userp, VerilatedContext*) VL_MT_SAFE;
|
||||
void addChgCb(dumpCb_t cb, void* userp, VerilatedContext*) VL_MT_SAFE;
|
||||
void addCleanupCb(cleanupCb_t cb, void* userp, VerilatedContext*) VL_MT_SAFE;
|
||||
void addInitCb(initCb_t cb, void* userp, VerilatedModel*) VL_MT_SAFE;
|
||||
void addFullCb(dumpCb_t cb, void* userp, VerilatedModel*) VL_MT_SAFE;
|
||||
void addChgCb(dumpCb_t cb, void* userp, VerilatedModel*) VL_MT_SAFE;
|
||||
void addCleanupCb(cleanupCb_t cb, void* userp, VerilatedModel*) VL_MT_SAFE;
|
||||
|
||||
void scopeEscape(char flag) { m_scopeEscape = flag; }
|
||||
|
||||
|
@ -604,9 +604,10 @@ void VerilatedTrace<VL_SUB_T, VL_BUF_T>::dump(uint64_t timeui) VL_MT_SAFE_EXCLUD
|
||||
// Non-hot path internal interface to Verilator generated code
|
||||
|
||||
template <>
|
||||
void VerilatedTrace<VL_SUB_T, VL_BUF_T>::addContext(VerilatedContext* contextp)
|
||||
void VerilatedTrace<VL_SUB_T, VL_BUF_T>::addModel(VerilatedModel* modelp)
|
||||
VL_MT_SAFE_EXCLUDES(m_mutex) {
|
||||
const VerilatedLockGuard lock{m_mutex};
|
||||
VerilatedContext* const contextp = modelp->contextp();
|
||||
if (m_contextp && contextp != m_contextp) {
|
||||
VL_FATAL_MT(
|
||||
__FILE__, __LINE__, "",
|
||||
@ -630,26 +631,26 @@ void VerilatedTrace<VL_SUB_T, VL_BUF_T>::addCallbackRecord(std::vector<CallbackR
|
||||
|
||||
template <>
|
||||
void VerilatedTrace<VL_SUB_T, VL_BUF_T>::addInitCb(initCb_t cb, void* userp,
|
||||
VerilatedContext* contextp) VL_MT_SAFE {
|
||||
addContext(contextp);
|
||||
VerilatedModel* modelp) VL_MT_SAFE {
|
||||
addModel(modelp);
|
||||
addCallbackRecord(m_initCbs, CallbackRecord{cb, userp});
|
||||
}
|
||||
template <>
|
||||
void VerilatedTrace<VL_SUB_T, VL_BUF_T>::addFullCb(dumpCb_t cb, void* userp,
|
||||
VerilatedContext* contextp) VL_MT_SAFE {
|
||||
addContext(contextp);
|
||||
VerilatedModel* modelp) VL_MT_SAFE {
|
||||
addModel(modelp);
|
||||
addCallbackRecord(m_fullCbs, CallbackRecord{cb, userp});
|
||||
}
|
||||
template <>
|
||||
void VerilatedTrace<VL_SUB_T, VL_BUF_T>::addChgCb(dumpCb_t cb, void* userp,
|
||||
VerilatedContext* contextp) VL_MT_SAFE {
|
||||
addContext(contextp);
|
||||
VerilatedModel* modelp) VL_MT_SAFE {
|
||||
addModel(modelp);
|
||||
addCallbackRecord(m_chgCbs, CallbackRecord{cb, userp});
|
||||
}
|
||||
template <>
|
||||
void VerilatedTrace<VL_SUB_T, VL_BUF_T>::addCleanupCb(cleanupCb_t cb, void* userp,
|
||||
VerilatedContext* contextp) VL_MT_SAFE {
|
||||
addContext(contextp);
|
||||
VerilatedModel* modelp) VL_MT_SAFE {
|
||||
addModel(modelp);
|
||||
addCallbackRecord(m_cleanupCbs, CallbackRecord{cb, userp});
|
||||
}
|
||||
|
||||
|
@ -540,7 +540,7 @@ class EmitCModel final : public EmitCFunc {
|
||||
}
|
||||
puts(/**/ "if (false && levels && options) {} // Prevent unused\n");
|
||||
puts(/**/ "tfp->spTrace()->addInitCb(&" + protect("trace_init")
|
||||
+ ", &(vlSymsp->TOP), contextp());\n");
|
||||
+ ", &(vlSymsp->TOP), this);\n");
|
||||
puts(/**/ topModNameProtected + "__" + protect("trace_register")
|
||||
+ "(&(vlSymsp->TOP), tfp->spTrace());\n");
|
||||
|
||||
|
@ -513,8 +513,7 @@ private:
|
||||
}
|
||||
m_regFuncp->addStmtsp(new AstAddrOfCFunc(flp, funcp));
|
||||
m_regFuncp->addStmtsp(new AstText(flp, ", vlSelf", true));
|
||||
m_regFuncp->addStmtsp(
|
||||
new AstText(flp, ", vlSelf->vlSymsp->__Vm_modelp->contextp()", true));
|
||||
m_regFuncp->addStmtsp(new AstText(flp, ", vlSelf->vlSymsp->__Vm_modelp", true));
|
||||
m_regFuncp->addStmtsp(new AstText(flp, ");\n", true));
|
||||
} else {
|
||||
// Sub functions
|
||||
@ -702,8 +701,7 @@ private:
|
||||
// Register it
|
||||
m_regFuncp->addStmtsp(new AstText(fl, "tracep->addCleanupCb(", true));
|
||||
m_regFuncp->addStmtsp(new AstAddrOfCFunc(fl, cleanupFuncp));
|
||||
m_regFuncp->addStmtsp(
|
||||
new AstText(fl, ", vlSelf, vlSelf->vlSymsp->__Vm_modelp->contextp());\n", true));
|
||||
m_regFuncp->addStmtsp(new AstText(fl, ", vlSelf, vlSelf->vlSymsp->__Vm_modelp);\n", true));
|
||||
|
||||
// Clear global activity flag
|
||||
cleanupFuncp->addStmtsp(
|
||||
|
Loading…
Reference in New Issue
Block a user