Skip to content

[svsim] Trace options for the Verilator backend #4911

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kammoh
Copy link
Contributor

@kammoh kammoh commented Apr 30, 2025

  • Adds the following options for generating traces using the Verilator backend:
    • maxArraySize: Maximum array depth for tracing
    • maxWidth: Maximum bit width for tracing
    • traceDepth: Depth of tracing

The corresponding Verilator flags are only added if the above integer values are > 0.

  • Adds TraceStyle.Fst for generating FST traces.

  • Removes the unused filename field from TraceStyle which seemed very confusing. The trace file name (stem) is only configured through CommonSimulationSettings.traceFileStem.

  • svsim: Try to figure out the project root directory in the presense of build-system sandboxing (e.g., as in the newer versions of mill). Introduces workingDirectory to be used instead of workingDirectoryPath. I've had this issue with my own Chisel projects, but decided to sneak the fix in as it was causing problems while testing this PR.

I guess, technically an API change due to the change of the TraceStyle.Vcd case class?

Replaces #4910

Contributor Checklist

  • Did you add Scaladoc to every public function/method?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you add appropriate documentation in docs/src?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • Feature (or new API)
  • API modification

Desired Merge Strategy

  • Rebase: You will rebase the PR onto master and it will be merged with a merge commit.

Release Notes

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels? (Select the most appropriate one based on the "Type of Improvement")
  • Did you mark the proper milestone (Bug fix: 3.6.x, 5.x, or 6.x depending on impact, API modification or big change: 7.0)?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you do one of the following when ready to merge:
    • Squash: You/ the contributor Enable auto-merge (squash) and clean up the commit message.
    • Merge: Ensure that contributor has cleaned up their commit history, then merge with Create a merge commit.

@kammoh
Copy link
Contributor Author

kammoh commented Apr 30, 2025

One question is if the default values for maxArraySize and maxWidth should be non-zero. Not being able to see arrays or wide signals in the waveform could be confusing to new-commers (or people less familiar with Verilator). I don't think performance is major concern as waveforms are only used for debugging, and from my experience any extra overhead is unnoticable. If the answer is yes, what choice values sounds reasonable?

.getOrElse(Paths.get(""))
.toAbsolutePath

def workingDirectory: Path = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a better API to use generally should we deprecate val workingDirectoryPath and suggest people use this?

Copy link
Contributor Author

@kammoh kammoh May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think why not, so I moved getProjectRootOrCwd to the Simulation object so it's accessable elsewhere (and public).
I also added CHISEL_PROJECT_ROOT env variable as an alternative way of specifying/detecting the project root. Then I used it for buildDir of scalatest.TestingDirectory.
Now scalatest.ChiselSim build directory in my mill projects are created in the workspace folder (./build) instead of being hidden under ./out/module_name/tests/testOnly.dest/sandbox/build.

kammoh added 5 commits May 1, 2025 12:16
+ added `getProjectRootOrCwd`
+ added `workingDirectory` which should always be used (read) instead of `workingDirectoryPath`
+ replaced workingDirectoryPath usage with workingDirectory
Can't think of any reason for having them disabled, so not exposing them
as options.
…Directory

+ added CHISEL_PROJECT_ROOT as an alternative for detectig project root
+ fixed tests to work with with both relative and absolute HasTestingDirectory.getDirectory path
@kammoh kammoh force-pushed the verilator_trace_options branch from 7c87e1c to 558a2bd Compare May 1, 2025 16:49
@kammoh
Copy link
Contributor Author

kammoh commented May 1, 2025

@jackkoenig @seldridge this is now ready for your reviews.
The getProjectRootOrCwd change should have ideally been on a separate PR, but it was needed for testing and I think it should be all fine.

@kammoh kammoh requested a review from jackkoenig May 1, 2025 17:01
@seldridge seldridge added the Feature New feature, will be included in release notes label May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature, will be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants