chisel
chisel copied to clipboard
Add trace functionality to make-replay
Type of issue: Feature Request
Is your feature request related to a problem? Please describe.
Currently make replay supports changing arbitrary command-line flags before replaying a test. As such, it is possible to replay a test and enable tracing. Unfortunately, this currently requires some knowledge of the inner workings of the system (i.e. what flags to set, possibly needing to add a TRACE command to the execution script). We could make this much more ergonomic, but it requires a bit of a refactor of the Backend API.
Some issues:
- Tracing modes are not mutually exclusive (i.e. you can do both vcd and fsdb tracing of the same run), but some require common flags (i.e. vpd and fsdb both require the
-debug_acc+pp+dmptfflag). We want to avoid duplicating these flags - Some tracing modes require CFLAGS (
SVSIM_VERILATOR_TRACE_ENABLED) and CFLAGS is currently an opaque string from the point of view ofWorkspace - Some flags require additional information, such as the $VERDI_HOME environment variable.
Describe the solution you'd like
The first step would be to improve InvocationSettings so that arguments aren't just a list of strings, but actually semantic. This would also simplify the code in {vcs,verilator}/Backend.scala, since we could add things like ConditionalFlag("flag", Boolean) and move the Seq-processing code into Workspace. I imagine a sealed trait CommandLineArgument, and a number of implemented types such as ConditionalFlag, and AggregatedList. CFLAGS would become an AggregatedList with semantics that multiple CFLAGS in a list of CommandLineArguments are merged.
The second step would be to add a separate method to the Backend trait which would provide additional arguments for a given trace style. Workspace would then call these methods and process the two sets of CommandLineArguments into either multiple targets in the resulting Makefile, or just make the replay target modifiable via environment variables.
We may also want to add a SVSIM_FORCE_ENABLE_TRACE configuration setting to simulation-driver.c which enables trace on startup and otherwise disables the TRACE command.
Describe alternatives you've considered
This may be too-clever-by-half, but it may be nice to just run something like SVSIM_VCD_TRACE_ENABLE=true SVSIM_FSDB_TRACE_ENABLE=true make replay instead of monkeying with the flags. As it stands there are some subtle things you need to remember (like sending a TRACE command) to get this to work properly.
What is the use case for implementing this feature?
You want to use make replay to generate a waveform when the original invocation was not set up to emit a waveform.