chipsalliance / rocket-chip

Rocket Chip Generator
Other
3.21k stars 1.12k forks source link

Working around the generated VCD files' size #1689

Closed noureddine-as closed 5 years ago

noureddine-as commented 5 years ago

Type of issue: enhancement suggestion

What is the current behavior? Using Verilated emulator (also called C or C++ Emulator) generates VCD files that have a very big size (~ GiBytes) even for very simple

Enhancement request: According to the following documentation of Verilator, The --trace option (used in emulator/Makefile) enables the emulator to produce VCD waveforms, which are very huge especially when having a significant payload to be run. As far as I know, the solution to overcome this is to use vcd2fst command to convert from VCD to FST, but this is annoying, especially if we don't have enough space on disk since the VCD file is created anyway, moreover the conversion takes some time to execute. There is an option --trace-fst which is available in new versions of Verilator. However I don't know how far is updating verilator's version in RocketChip possible?

Anyway this is just a suggestion (a low priority one may be?), I don't have any experience with Verilator, but I may help if I have enough pointers to a solution.

Thank you. Best Regards!

seldridge commented 5 years ago

Note: some of the existing options the emulator has and postprocessing the VCD through stdin can help. Current emulator VCD options are:

  -v, --vcd=FILE,          Write vcd trace to FILE (or '-' for stdout)
  -x, --dump-start=CYCLE   Start VCD tracing at CYCLE
       +dump-start

Try:

  1. -x <CYCLE> to start the VCD dump after all the initialization stuff has happened
  2. -v - | vcd2fst - to send the VCD file directly to vcd2fst
  3. You can further process a VCD file down to only dump what you care about (arguably this should eventually be a feature migrated into Chisel3/FIRRTL). I've done this in the past using a Perl script that will prune the VCD file to only include what is in a user-specified module and it's submodules. E.g., -v - | vcd-prune -m MyRoCC | vcd2fst -.

I haven't tested those commands above, but something like that should do it. Anecdotally, the combination of starting the VCD dump later and pruning to what I need has been sufficient for debugging. Rarely do you need a complete VCD dump of the entire design.

noureddine-as commented 5 years ago

@seldridge , nice and it works perfectly, thank you for the help!

Best regards.

NazerkeT commented 4 years ago

Hi, @noureddine-as, could you, please, point (if you remember) what exact command has worked in your case to generate fst dump? I am facing the same situation and running above and related commands ended up unsuccessful.

Best regards,

noureddine-as commented 3 years ago

Hi @NazerkeT, Sorry I didn't see your question until today, accidentally. Anyway, we ended up using the following command:

<path to emulator> -v - +max-cycles=<max cycles> <target executable> | vcd2fst - <path to the resulting waveform>.fst

Best Regards,

NazerkeT commented 3 years ago

Hi @NazerkeT, Sorry I didn't see your question until today, accidentally. Anyway, we ended up using the following command:

<path to emulator> -v - +max-cycles=<max cycles> <target executable> | vcd2fst - <path to the resulting waveform>.fst

Best Regards,

Hi, @noureddine-as Thanks for the response!