Trying to Build an SoC Environment with LiteX (10. Capturing Waveforms with VexRiscV)

https://raw.githubusercontent.com/enjoy-digital/litex/master/doc/litex.png

For verifying my own CPU in LiteX, I have not yet reached the point where the simulation starts correctly.

Instead, I got as far as capturing VexRiscV waveforms in the LiteX environment.

The command line is as follows.

./sim.py --trace --trace-fst --trace-start 0 --trace-end 1000000000000

This command outputs an FST file so that the waveforms can be observed.

The reason for adding --trace-end is that if you stop the program with Ctrl-C, the FST file ends up incomplete and cannot be opened correctly in GTKWave. Therefore, I changed the C++ file as follows so that the FST file is always closed.

diff --git a/litex/build/sim/core/veril.cpp b/litex/build/sim/core/veril.cpp
index 2ea9a348..7680cdfc 100644
--- a/litex/build/sim/core/veril.cpp
+++ b/litex/build/sim/core/veril.cpp
@@ -74,6 +74,9 @@ extern "C" void litex_sim_tracer_dump()
   if (dump_enabled && tfp_start <= main_time && main_time <= tfp_end) {
     tfp->dump((vluint64_t) main_time);
   }
+  if (dump_enabled && main_time > tfp_end) {
+    tfp->close();
+  }
 }

This is an English translation of the original Japanese post: LiteXによるSoC環境構築を試行する (10. VexRiscVでの波形取得)