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
|
B. Or, for finer-grained control, or C++ files with multiple Verilated
|
||||||
modules you may also create the trace purely from C++. Create a
|
modules you may also create the trace purely from C++. Create a
|
||||||
VerilatedVcdC object, and in your main loop call
|
VerilatedVcdC object, and in your main loop right after ``eval()`` call
|
||||||
``trace_object->dump(time)`` every time step, and finally call
|
``trace_object->dump(contextp->time())`` every time step, and finally
|
||||||
``trace_object->close()``.
|
call ``trace_object->close()``.
|
||||||
|
|
||||||
.. code-block:: C++
|
.. code-block:: C++
|
||||||
:emphasize-lines: 1,5-8,12
|
: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"
|
#include "verilated_vcd_c.h"
|
||||||
...
|
...
|
||||||
int main(int argc, char** argv, char** env) {
|
int main(int argc, char** argv, char** env) {
|
||||||
|
const std::unique_ptr<VerilatedContext> contextp{new VerilatedContext};
|
||||||
...
|
...
|
||||||
Verilated::traceEverOn(true);
|
Verilated::traceEverOn(true);
|
||||||
VerilatedVcdC* tfp = new VerilatedVcdC;
|
VerilatedVcdC* tfp = new VerilatedVcdC;
|
||||||
topp->trace(tfp, 99); // Trace 99 levels of hierarchy
|
topp->trace(tfp, 99); // Trace 99 levels of hierarchy
|
||||||
tfp->open("obj_dir/t_trace_ena_cc/simx.vcd");
|
tfp->open("obj_dir/t_trace_ena_cc/simx.vcd");
|
||||||
...
|
...
|
||||||
while (Verilated::time() < sim_time && !Verilated::gotFinish()) {
|
while (contextp->time() < sim_time && !contextp->gotFinish()) {
|
||||||
Verilated::timeInc(1);
|
contextp->timeInc(1);
|
||||||
tfp->dump(main_time);
|
topp->eval();
|
||||||
|
tfp->dump(contextp->time());
|
||||||
}
|
}
|
||||||
tfp->close();
|
tfp->close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,8 @@ public:
|
||||||
/// Flush dump
|
/// Flush dump
|
||||||
void flush() VL_MT_SAFE { m_sptrace.flush(); }
|
void flush() VL_MT_SAFE { m_sptrace.flush(); }
|
||||||
/// Write one cycle of dump data
|
/// 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); }
|
void dump(vluint64_t timeui) { m_sptrace.dump(timeui); }
|
||||||
/// Write one cycle of dump data - backward compatible and to reduce
|
/// Write one cycle of dump data - backward compatible and to reduce
|
||||||
/// conversion warnings. It's better to use a vluint64_t time instead.
|
/// conversion warnings. It's better to use a vluint64_t time instead.
|
||||||
|
|
|
||||||
|
|
@ -368,6 +368,8 @@ public:
|
||||||
/// Flush dump
|
/// Flush dump
|
||||||
void flush() VL_MT_SAFE { m_sptrace.flush(); }
|
void flush() VL_MT_SAFE { m_sptrace.flush(); }
|
||||||
/// Write one cycle of dump data
|
/// 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); }
|
void dump(vluint64_t timeui) VL_MT_SAFE { m_sptrace.dump(timeui); }
|
||||||
/// Write one cycle of dump data - backward compatible and to reduce
|
/// Write one cycle of dump data - backward compatible and to reduce
|
||||||
/// conversion warnings. It's better to use a vluint64_t time instead.
|
/// conversion warnings. It's better to use a vluint64_t time instead.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue