mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
Support tracing through --hierarchical/--lib-create libraries (#3200).
This commit is contained in:
@@ -124,6 +124,11 @@ private:
|
||||
addComment(txtp, fl, "Evaluates the library module's final process");
|
||||
}
|
||||
|
||||
void traceComment(AstTextBlock* txtp, FileLine* fl) {
|
||||
addComment(txtp, fl, "Enables the library module's tracing");
|
||||
addComment(txtp, fl, "Only usable when used with called from Verilator");
|
||||
}
|
||||
|
||||
void createSvFile(FileLine* fl, AstNodeModule* modp) {
|
||||
// Comments
|
||||
AstTextBlock* const txtp = new AstTextBlock(fl);
|
||||
@@ -197,6 +202,18 @@ private:
|
||||
txtp->addText(fl, "import \"DPI-C\" function void " + m_libName
|
||||
+ "_protectlib_final(chandle handle__V);\n\n");
|
||||
|
||||
if (v3Global.opt.trace() && !v3Global.opt.protectIds()) {
|
||||
txtp->addText(fl, "`ifdef verilator\n");
|
||||
traceComment(txtp, fl);
|
||||
txtp->addText(fl, "import \"DPI-C\" function void " + m_libName
|
||||
+ "_protectlib_trace(chandle handle__V, "
|
||||
"chandle tfp, int levels, int options)"
|
||||
+ " /*verilator trace_init_task*/;\n");
|
||||
// Note V3EmitCModel.cpp requires the name "handle__V".
|
||||
txtp->addText(fl, "`endif // verilator\n");
|
||||
txtp->addText(fl, "\n");
|
||||
}
|
||||
|
||||
// Local variables
|
||||
// Avoid tracing handle, as it is not a stable value, so breaks vcddiff
|
||||
// Likewise other internals aren't interesting to the user
|
||||
@@ -387,6 +404,18 @@ private:
|
||||
txtp->addText(fl, /**/ "delete handlep__V;\n");
|
||||
txtp->addText(fl, "}\n\n");
|
||||
|
||||
if (v3Global.opt.trace() && !v3Global.opt.protectIds()) {
|
||||
traceComment(txtp, fl);
|
||||
txtp->addText(fl, "void " + m_libName
|
||||
+ "_protectlib_trace(void* vhandlep__V, void* tfp, int levels, "
|
||||
"int options) {\n");
|
||||
castPtr(fl, txtp);
|
||||
txtp->addText(
|
||||
fl,
|
||||
/**/ "handlep__V->trace(static_cast<VerilatedVcdC*>(tfp), levels, options);\n");
|
||||
txtp->addText(fl, "}\n\n");
|
||||
}
|
||||
|
||||
txtp->addText(fl, "}\n");
|
||||
m_cfilep->tblockp(txtp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user