hneemann / Digital

A digital logic designer and circuit simulator.
GNU General Public License v3.0
4.29k stars 435 forks source link

Request: VCD output of signal waveforms for use with gtkwave #864

Open rj45 opened 2 years ago

rj45 commented 2 years ago

It would be awesome if Digital had a mode where the signals in the waveform viewer could be logged to a VCD file, especially if it supports dumping single step traces so it's possible to see glitches that happen between the clock edges.

I find being able to view signal waveforms in gtkwave to be invaluable. It has a lot of functionality that I miss when using Digital's built in waveform viewer, not to mention that there's a lot of limitations as far as how may signals can be plotted and how much history can be viewed.

I can use verilator to produce VCD traces, but that often takes a lot of time to build up C++ code to simulate peripherals that Digital supports out of the box. I'm also not sure it can dump traces of what the signals do between clock edges, which Digital can do no problem.

VCD (Value Change Dump) files are a very simple format (with a IEEE standard), and I have implemented it in the past with little trouble. It's basically text-based log file for what signals change at what time. The only issue is that it often produces enormous files, and so FST (Fast Signal Trace) would be nice, but FST is significantly more complicated to implement. I would be very happy with just VCD support.

I don't have a lot of time to implement this feature unfortunately. But maybe someone else has the time? If not, maybe I can find some time in a month or two. Thanks!

hneemann commented 2 years ago

Is there any more detailed documentation available?

rj45 commented 2 years ago

https://zipcpu.com/blog/2017/07/31/vcd.html https://en.wikipedia.org/wiki/Value_change_dump

Probably the best documentation is in the standard where it's specified, unfortunately that's not free, but perhaps you have access to it?

The FST file format is described in appendix F here: http://gtkwave.sourceforge.net/gtkwave.pdf

bwburnsides commented 2 years ago

+1 here. Debugging glitches in Digital would be a lot easier with better tooling support.