Hello simulavr folks,

Thanks for making simulavr! I recently started using simulavr for a university project, and wound up generating VCD files from simulavr to view later in Gtkwaves. I was amazed at the level of detail I could get in my traces.

However, it took some effort for me to dig up how to do VCD traces in simulavr, and the man pages didn't have any examples I could find for how to create VCD traces. Ultimately, I had to search through the mailing lists to find the command-line incantations I needed.

I have written up a possible docs patch (attached in Git patch format) which might provide useful examples/info for future folks looking to do VCD traces. It may have issues (formatting especially), so please let me know if there's anything I could do to make the patch better.

Thank you!
-Philip Conrad

>From 91d9982c56fc2cc0f86923f9d7eef57f4f70f571 Mon Sep 17 00:00:00 2001
From: Philip Conrad <conr...@chariot-chaser.com>
Date: Tue, 3 Mar 2020 02:06:52 -0500
Subject: [PATCH] Add VCD tracing to docs.

---
 doc/simulavr.texi | 61 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/doc/simulavr.texi b/doc/simulavr.texi
index e649b09..2e9e8a5 100644
--- a/doc/simulavr.texi
+++ b/doc/simulavr.texi
@@ -345,6 +345,67 @@ for tracing could not be updated which means that the label information
 in the trace output is wrong. That is not a bug, this is related to the
 possibilities of the avr-gdb interface.
 
+@comment  node-name,  next,  previous,  up
+@node VCD Trace Files, Graphic User Interface, Tracing, Top
+@chapter VCD Trace Files
+@cindex VCD Trace Files
+simulavr can generate VCD trace files, suitable for loading into Gtkwaves and
+other VCD trace viewing programs.
+
+@subsection Generating the tracepoint list
+
+To generate VCD traces, a file listing the desired trace values is required.
+You can generate a file listing all the available trace points for the
+atmega328 platform by running the following command:
+
+@example
+simulavr -d atmega328 -o tracepoints.txt
+@end example
+
+This will create a file containing several dozen lines in the following format:
+
+@example
++ SPMCR
++ CORE.SREG
++ CORE.PRESCALER2
++ CORE.GTCCR
++ CORE.ASSR
++ CORE.PRESCALER01
++ CORE.CLKPR
++ CORE.OSCCAL
++ CORE.EICRA
+...
+@end example
+
+You can trim out the values you don't need from the file to get a reduced set
+of traced values. This speeds up VCD trace generation, and reduces the trace
+sizes substantially.
+
+An example tracepoint list file that only tracks the state of PORTB might
+look like the following:
+
+@example
++ PORTB.PORT
++ PORTB.PIN
++ PORTB.DDR
++ PORTB.B1-Out
+@end example
+
+@subsection Generating VCD traces
+
+Once you have a tracepoint list you are happy with, you can use it to generate
+a VCD trace with a command using the @code{-cvcd:...} option.
+
+An example invocation for an @code{atmega328}:
+
+@example
+simulavr -m 12000000000 -d atmega328 -f blink.elf -cvcd:ports.txt:trace.vcd
+@end example
+
+This would run simulavr for 12 seconds on an @code{atmega328}, using an
+executable named @code{blink.elf}, and would generate a VCD trace in a file
+named @code{trace.vcd}, for all of the tracepoints listed in @code{ports.txt}.
+
 @comment  node-name,  next,  previous,  up
 @node Graphic User Interface, Building and Installing SimulAVR, Tracing, Top
 @chapter Graphic User Interface
-- 
2.17.1

Reply via email to