Skip to content

ChiselSim integration for inline tests #4855

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

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

tmckay-sifive
Copy link
Contributor

@tmckay-sifive tmckay-sifive commented Apr 2, 2025

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)

Desired Merge Strategy

  • Squash: The PR will be squashed and merged (choose this if you have no preference).
  • Rebase: You will rebase the PR onto master and it will be merged with a merge commit.

Release Notes

  • Add ChiselSim.simulateTests API to simulate inline tests and report results

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.

Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

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

Very cool!

I started to review this then realized there are a bunch of prerequisite PRs.

Copy link
Member

Choose a reason for hiding this comment

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

It would be better to try to avoid the proliferation of different functions that all have slightly different arguments. This was, IMO, a big mistake in both our external and internal testing flows.

What I would do is move in a direction of adding a parameter with a default value that gives you a type-safe way to choose the tests, e.g., an enum like:

object TestSelection {
  sealed trait Type
  case object All
  case class Exactly(tests: Seq[String])
  case class Glob(glob: String)
}

I'm not proposing the above organization exactly, just something like this. You could see LayerControl for an example of how to organize this.

firtoolOptsModifications: FirtoolOptionsModifications,
commonSettingsModifications: svsim.CommonSettingsModifications,
backendSettingsModifications: svsim.BackendSettingsModifications
): Seq[(String, Simulator.BackendInvocationDigest[_])] = {
Copy link
Member

Choose a reason for hiding this comment

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

The return type of these methods is too low-level. This should just be Unit. Alternatively, there should be a ChiselSim-specific return type that is used for all methods here. I.e., also for simulate and simulateRaw.

@tmckay-sifive tmckay-sifive force-pushed the tmckay/inlinetest-chiselsim branch from 0f604d3 to 25182fb Compare April 9, 2025 22:13
@tmckay-sifive tmckay-sifive force-pushed the tmckay/inlinetest-chiselsim branch from e1c4ba7 to 8879da5 Compare April 9, 2025 22:28
@tmckay-sifive tmckay-sifive marked this pull request as ready for review April 9, 2025 22:31
@tmckay-sifive
Copy link
Contributor Author

tmckay-sifive commented Apr 9, 2025

This has been cleaned up and is ready for review. Note: this branch is based on #4833.

EDIT: For reviewers, probably best to hold off for a bit longer. I put this in draft. I have some cleanups I want to backport to this branch that I made in order to support generating scalatest specs for inline tests.

@tmckay-sifive tmckay-sifive marked this pull request as draft April 10, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants