mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Commentary on traces (#2925)
This commit is contained in:
parent
3718fe1ca1
commit
88fed4bc2f
@ -118,9 +118,9 @@ A. Pass the :vlopt:`--trace` option to Verilator, and in your top level C
|
||||
|
||||
B. Or, for finer-grained control, or C++ files with multiple Verilated
|
||||
modules you may also create the trace purely from C++. Create a
|
||||
VerilatedVcdC object, and in your main loop call
|
||||
``trace_object->dump(time)`` every time step, and finally call
|
||||
``trace_object->close()``.
|
||||
VerilatedVcdC object, and in your main loop right after ``eval()`` call
|
||||
``trace_object->dump(contextp->time())`` every time step, and finally
|
||||
call ``trace_object->close()``.
|
||||
|
||||
.. code-block:: C++
|
||||
:emphasize-lines: 1,5-8,12
|
||||
@ -128,15 +128,17 @@ B. Or, for finer-grained control, or C++ files with multiple Verilated
|
||||
#include "verilated_vcd_c.h"
|
||||
...
|
||||
int main(int argc, char** argv, char** env) {
|
||||
const std::unique_ptr<VerilatedContext> contextp{new VerilatedContext};
|
||||
...
|
||||
Verilated::traceEverOn(true);
|
||||
VerilatedVcdC* tfp = new VerilatedVcdC;
|
||||
topp->trace(tfp, 99); // Trace 99 levels of hierarchy
|
||||
tfp->open("obj_dir/t_trace_ena_cc/simx.vcd");
|
||||
...
|
||||
while (Verilated::time() < sim_time && !Verilated::gotFinish()) {
|
||||
Verilated::timeInc(1);
|
||||
tfp->dump(main_time);
|
||||
while (contextp->time() < sim_time && !contextp->gotFinish()) {
|
||||
contextp->timeInc(1);
|
||||
topp->eval();
|
||||
tfp->dump(contextp->time());
|
||||
}
|
||||
tfp->close();
|
||||
}
|
||||
|
@ -152,6 +152,8 @@ public:
|
||||
/// Flush dump
|
||||
void flush() VL_MT_SAFE { m_sptrace.flush(); }
|
||||
/// Write one cycle of dump data
|
||||
/// Call with the current context's time just after eval'ed,
|
||||
/// e.g. ->dump(contextp->time())
|
||||
void dump(vluint64_t timeui) { m_sptrace.dump(timeui); }
|
||||
/// Write one cycle of dump data - backward compatible and to reduce
|
||||
/// conversion warnings. It's better to use a vluint64_t time instead.
|
||||
|
@ -368,6 +368,8 @@ public:
|
||||
/// Flush dump
|
||||
void flush() VL_MT_SAFE { m_sptrace.flush(); }
|
||||
/// Write one cycle of dump data
|
||||
/// Call with the current context's time just after eval'ed,
|
||||
/// e.g. ->dump(contextp->time())
|
||||
void dump(vluint64_t timeui) VL_MT_SAFE { m_sptrace.dump(timeui); }
|
||||
/// Write one cycle of dump data - backward compatible and to reduce
|
||||
/// conversion warnings. It's better to use a vluint64_t time instead.
|
||||
|
Loading…
Reference in New Issue
Block a user