Skip to content

Commit 2ce6ab3

Browse files
committed
[chiselsim] Require help text in Scale trait
Change the `Scale` trait (which adds the `-Dscale=<float>` Scalatest parameter) to require the user to provide documentation about what the scale is for that test. This is done to avoid potential confusion about what the "scale" means for a given test. Does it lengthen the test? Does it test more aggressively? Does it instantiate more more units? Does it change latencies? While it is entirely reasonable for the "scaling factor" to mean different things for different tests, I want test authors to be forced to say what it means for their test and to then make this both discoverable in the code and discoverable on the command line (via `-Dhelp=1`). Signed-off-by: Schuyler Eldridge <[email protected]>
1 parent f30eae3 commit 2ce6ab3

File tree

1 file changed

+18
-1
lines changed
  • src/main/scala/chisel3/simulator/scalatest

1 file changed

+18
-1
lines changed

src/main/scala/chisel3/simulator/scalatest/Cli.scala

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,28 @@ object Cli {
248248
* for briefly in a pre-merge Continuous Integration (CI) flow, but runs for
249249
* much longer in nightly CI.
250250
*
251+
* Note that the interpretation of the "scaling factor" is test dependent.
252+
* In order to document this and help end users, this trait has an abstract
253+
* member `scaleHelpText` which must be overridden to document what the scale
254+
* affects in the test. E.g., if the scale is used to lengthen a test, a
255+
* test author could write:
256+
*
257+
* {{{
258+
* override protected def scaleHelpText = "scales the runtime of a test"
259+
* }}}
260+
*
251261
* While this adds the low-level `scale` option. A user of this should use
252262
* the member functions that this trait adds, e.d., `scaled`.
253263
*/
254264
trait Scale { this: HasCliOptions =>
255265

266+
/** Help text that describes what the `-Dscale` parameter does for this test.
267+
*
268+
* This is used to populate the help text that an end user sees when
269+
* invoking this test with `-Dhelp=1`.
270+
*/
271+
protected def scaleHelpText: String
272+
256273
/** Scale an integer by the scaling factor, if set.
257274
*
258275
* If no scaling factor is set, this will scale by `1.0`, i.e., the input
@@ -263,7 +280,7 @@ object Cli {
263280
addOption(
264281
CliOption.double(
265282
name = "scale",
266-
help = "scale the test up or down by a floating point number"
283+
help = scaleHelpText
267284
)
268285
)
269286

0 commit comments

Comments
 (0)