ucb-bar / chiseltest

The batteries-included testing and formal verification library for Chisel-based RTL designs.
Other
220 stars 73 forks source link

Test configurations #101

Closed ducky64 closed 1 year ago

ducky64 commented 4 years ago

This arose out of support for -DwriteVcd=1 in ScalaTest being broken, and whether that breakage was intentional or not. At the chisel-dev meeting, this turned into a longer discussion about configurations, in particular addressing #65.

There seems to be agreement about using annotations as the internal mechanism for representing configurations, including (as currently supported) dumping VCDs and simulator backend.

The overall design requirements are:

That being said, there was a debate on what the interface should look like.

Proposal 1: universal configurations in a separate file

Under this proposal, there would be a configuration file, probably in the resources folder, formatted as annotations command line syntax, that would be read in to provide default annotations for all tests.

Pros:

Cons:

I personally think the cons outweigh the pros here, especially since the configuration is somewhat implicit.

Proposal 2: two mechanisms for two purposes

This proposal provides both a temporary mechanism (akin to the debug printf - something that isn't pushed to version control) for changing global configurations, and a permanent mechanism (something that does get pushed to version control) for sharing annotations across multiple test classes while remaining in Scala.

Temporary (per-run) annotations through test infrastructure arguments

Basically, bring back (and possibly expand) the -DwriteVcd=1 option that can be passed to ScalaTest in sbt.

Pros:

Cons:

Permanent annotations in the class hierarchy

Currently, tests are largely written with

class BasicTest extends FlatSpec with ChiselScalatestTester { ...

This proposal would allow subclassing ChiselScalatestTester with annotations, for example:

class MyTestConfig extends ChiselScalatestTester(annos=Seq(writeVcdAnnotataion))
...
class BasicTest extends FlatSpec with MyTestConfig { ...

Potential solution for #65.

Pros:

Cons:

Misc

Still up for debate how to run multiple backends. Should this be a responsibility of the build system (and above the ChiselTest level)? Or should there be an annotation that runs a single test multiple times under different backends? Should all tests be written such that they can run multiple times in the same JVM invocation? How would this coexist with proposals to avoid multiple elaboration?

ducky64 commented 4 years ago

@seldridge @chick @ucbjrl @azidar @jackkoenig since you were all part of that discussion

chick commented 4 years ago

I think this is a good summary. I am open to any approach that brings this capability to the stack. I'd like to add that there be a diagnostic interface, .i.e. a way to get the relevant Stage to report what options are in play and where they are coming from.

ekiwi commented 1 year ago

I see test configuration management as out of scope for chiseltest. Users should be able to create their own solutions on top of the testing APIs that we provide.