-
Notifications
You must be signed in to change notification settings - Fork 618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add waveform tracing support for simulateRaw and simulate in SimulatorAPI #4770
base: main
Are you sure you want to change the base?
Conversation
…mulations This commit introduces a new `enableTrace` parameter to the `simulate` and `simulateRaw` methods in `SimulatorAPI.scala`, allowing users to enable waveform tracing during simulations. Additionally, corresponding test cases have been added to `ChiselSimSpec.scala` to verify that waveform files are correctly generated for both `Module` and `RawModule` simulations. Signed-off-by: Qiming Chu <[email protected]>
I think it should be abstract to an API with SimulatorConfig or something like this, there are many other things to configure the simulator and different simulator has different behaviors, for example fst, vcd choice for verilator, fsdb for vcs, threading configs… |
I appreciate your concern about API design and future extensibility. Here's my reasoning:
This design maintains API simplicity for the common case while preserving extension points for backend-specific configuration. Would you prefer we implement the comprehensive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for starting on this. It is really annoying in that it is basically impossible to turn on waveform dumping today.
Couple of things:
- I agree with Jiuyang and there's currently a bunch of options that need to be handled for waveforms w/ different simulators handling things differently. However, this may be fine as is as a top level "turn on waveform dumping option" (like the PR adds) and then leave the simulator-specific waveform-enabling options to backends. The one thing that needs to be validated is that these are properly synchronized. If a user turns on waveforms, a proper backend option should be set automatically.
- The trace enabling from a specific point in time is actually useful. Given this, I'm not sure if we actually want to turn on waveform dumping as an option and instead want to do it via stimulus. Going in this direction, this would then mean adding something to the
stimulus
package (likeRunUntilFinished
that just turns on waveforms). That would require figuring out how to make it work with the initialization procedure of thesimulate
method as you would like to have a wave for the whole simulation and not just post-reset.
@sequencer: Do you have any thoughts about this?
chiselSettings: ChiselSettings[T] = ChiselSettings.defaultRaw[T] | ||
chiselSettings: ChiselSettings[T] = ChiselSettings.defaultRaw[T], | ||
enableTrace: Boolean = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, I think we do want to expose this. However, it would be better to make it part of ChiselSettings
. I'd like to keep the options organized under ChiselSettings
and not have a proliferation of other options.
There are already per-backend options for compiling different backends with support for different trace formats:
|
I thought about it a bit more. What about this:
WDYT? Also (and again), @sequencer WDYT? |
Agree with this approach. I think adding another parameter feels a bit cluttered, too.
Regarding enabling waveform dumping by default for all backends, my concern is: would this impact simulation performance or other aspects? However, I do think including waveform saving options during compilation by default would help implement the "start saving at specific points" functionality you mentioned.
I had considered accessing the controller externally in serveral other ways, but didn't get the desired results, which is why I used the current approach. |
Right, I want to know if this is a performance problem. Note: I'm only saying to enable dumping, not to actually dump. I.e., the default would be for VCD:
Is this slow even if The code for how this works in Chiselsim is here: https://github.com/chipsalliance/chisel/blob/main/svsim/src/main/scala/Workspace.scala#L169 You'll see that VCD, VPD, and FSDB are all gated by macros which is what those backend options are controlling. |
There is another option that could be explored here. Command line options can be passed using Scalatest's config map. I've added support for this in the Internally, we have historically had an option |
Add Scalatest integration for Chiselsim which allows users to write traits which add command line options to a Scalatest test. These hook into the `-D` Scalatest options (i.e., the ConfigMap) and allow the user to modify the common or backend-specific options of a test. This includes validation features to guarantee that illegal options are not passed. Add an example trait, `WaveformVCD` which will enable VCD dumping for _either_ Verilator or VCS. With this, you can then do, for a test which adds this trait: ./mill 'chisel3[2.13.16].test.testOnly' 'FooSpec' -- -DemitVCD=true This is related to #4770. Signed-off-by: Schuyler Eldridge <[email protected]>
sorry I missed this.
There is almost no overhead in both compile time and runtime from my experience in vcs. But introducing compile time issue in verilator.
Almost no runtime overhead from my understanding. I think the API design of this PR is fine if Schuyler approves;) From my experience, I’m a little bit concerned about adding more simulation features, we may eventually go into the Verilog Verbatim nightmare like t1 https://github.com/chipsalliance/t1/blob/master/t1rocketemu/vsrc/VerbatimModule.sv |
Essentially we need to think about some fundamental issues when adding new APIs:
|
I thought about this even more. Here is how I would like to proceed:
I realize that (3) and (4), along with the existing backend-specific compilation options means that there are three redundant ways to compile in waveform support. However, the backend-specific options are what we are trying to not have users use and (3) and (4) are two different ways of using ChiselSim. One is pure ChiselSim. The other is more Scalatest friendly. |
I agree with this approach of adding a ControlAPI to ChiselSim. This would indeed provide more direct and flexible control over waveform generation compared to just adding options in ChiselSettings (We can get access to the controller more directly).
I think the backend-agnostic abstraction for ChiselSim is a nice design that helps provide a more user-friendly API. But I think we could also allow users to pass their compile parameters to backends like verilator, vcs or arcilator (maybe in the future?). This would help in a couple of ways:
BTW, I'd like to ask if ChiselSim currently has any plans to support the arcilator backend ? :) |
This commit introduces a new
enableTrace
parameter to thesimulate
andsimulateRaw
methods inSimulatorAPI.scala
, allowing users to enable waveform tracing during simulations. Additionally, corresponding test cases have been added toChiselSimSpec.scala
to verify that waveform files are correctly generated for bothModule
andRawModule
simulations.By adding this feature, users can enable tracing like this:
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
and clean up the commit message.Create a merge commit
.