diff options
| author | Schuyler Eldridge | 2020-06-16 11:59:15 -0400 |
|---|---|---|
| committer | Schuyler Eldridge | 2020-06-22 20:00:10 -0400 |
| commit | 6e03f63d525aac0bdf4a59b6fe66a0b4d5a3a25a (patch) | |
| tree | 482481bcfe93ea5dfcece80772ce1957fb68c74c /src/test/scala/chiselTests/util | |
| parent | cc4fa583690292d690804144fe92427f0c9f5fdf (diff) | |
Use ChiselStage in Tests
This migrates the tests to Chisel 3.4/FIRRTL 1.4. This primarily
involves removing usages of deprecated methods including:
- Remove usages of Driver
- Use ChiselStage methods instead of BackendCompilationUtilities
methods
- Use Dependency API for custom transforms
- Use extractCause to unpack StackError
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Diffstat (limited to 'src/test/scala/chiselTests/util')
| -rw-r--r-- | src/test/scala/chiselTests/util/random/LFSRSpec.scala | 18 | ||||
| -rw-r--r-- | src/test/scala/chiselTests/util/random/PRNGSpec.scala | 15 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/test/scala/chiselTests/util/random/LFSRSpec.scala b/src/test/scala/chiselTests/util/random/LFSRSpec.scala index 9afe7670..1dc2db41 100644 --- a/src/test/scala/chiselTests/util/random/LFSRSpec.scala +++ b/src/test/scala/chiselTests/util/random/LFSRSpec.scala @@ -3,6 +3,7 @@ package chiselTests.util.random import chisel3._ +import chisel3.stage.ChiselStage import chisel3.util.{Cat, Counter, Enum} import chisel3.util.random._ import chisel3.testers.BasicTester @@ -105,7 +106,7 @@ class LFSRResetTester(gen: => LFSR, lockUpValue: BigInt) extends BasicTester { } -class LFSRSpec extends ChiselFlatSpec { +class LFSRSpec extends ChiselFlatSpec with Utils { def periodCheck(gen: (Int, Set[Int], LFSRReduce) => PRNG, reduction: LFSRReduce, range: Range): Unit = { it should s"have a maximal period over a range of widths (${range.head} to ${range.last}) using ${reduction.getClass}" in { @@ -122,13 +123,15 @@ class LFSRSpec extends ChiselFlatSpec { behavior of "LFSR" it should "throw an exception if initialized to a seed of zero for XOR configuration" in { - { the [IllegalArgumentException] thrownBy elaborate(new FooLFSR(XOR, Some(0))) } - .getMessage should include ("Seed cannot be zero") + { the [IllegalArgumentException] thrownBy extractCause[IllegalArgumentException] { + ChiselStage.elaborate(new FooLFSR(XOR, Some(0))) } + }.getMessage should include ("Seed cannot be zero") } it should "throw an exception if initialized to a seed of all ones for XNOR configuration" in { - { the [IllegalArgumentException] thrownBy elaborate(new FooLFSR(XNOR, Some(15))) } - .getMessage should include ("Seed cannot be all ones") + { the [IllegalArgumentException] thrownBy extractCause[IllegalArgumentException] { + ChiselStage.elaborate(new FooLFSR(XNOR, Some(15))) } + }.getMessage should include ("Seed cannot be all ones") } it should "reset correctly without a seed for XOR configuration" in { @@ -142,8 +145,9 @@ class LFSRSpec extends ChiselFlatSpec { behavior of "MaximalPeriodGaloisLFSR" it should "throw an exception if no LFSR taps are known" in { - { the [IllegalArgumentException] thrownBy elaborate(new MaxPeriodGaloisLFSR(787)) } - .getMessage should include ("No max period LFSR taps stored for requested width") + { the [IllegalArgumentException] thrownBy extractCause[IllegalArgumentException] { + ChiselStage.elaborate(new MaxPeriodGaloisLFSR(787)) } + }.getMessage should include ("No max period LFSR taps stored for requested width") } periodCheck((w: Int, t: Set[Int], r: LFSRReduce) => new GaloisLFSR(w, t, reduction=r), XOR, 2 to 16) diff --git a/src/test/scala/chiselTests/util/random/PRNGSpec.scala b/src/test/scala/chiselTests/util/random/PRNGSpec.scala index 341fb685..bf10a1c0 100644 --- a/src/test/scala/chiselTests/util/random/PRNGSpec.scala +++ b/src/test/scala/chiselTests/util/random/PRNGSpec.scala @@ -3,11 +3,12 @@ package chiselTests.util.random import chisel3._ +import chisel3.stage.ChiselStage import chisel3.testers.BasicTester import chisel3.util.Counter import chisel3.util.random.PRNG -import chiselTests.ChiselFlatSpec +import chiselTests.{ChiselFlatSpec, Utils} class CyclePRNG(width: Int, seed: Option[BigInt], step: Int, updateSeed: Boolean) extends PRNG(width, seed, step, updateSeed) { @@ -61,18 +62,20 @@ class PRNGUpdateSeedTest(updateSeed: Boolean, seed: BigInt, expected: BigInt) ex } -class PRNGSpec extends ChiselFlatSpec { +class PRNGSpec extends ChiselFlatSpec with Utils { behavior of "PRNG" it should "throw an exception if the step size is < 1" in { - { the [IllegalArgumentException] thrownBy elaborate(new CyclePRNG(0, Some(1), 1, true)) } - .getMessage should include ("Width must be greater than zero!") + { the [IllegalArgumentException] thrownBy extractCause[IllegalArgumentException] { + ChiselStage.elaborate(new CyclePRNG(0, Some(1), 1, true)) } + }.getMessage should include ("Width must be greater than zero!") } it should "throw an exception if the step size is <= 0" in { - { the [IllegalArgumentException] thrownBy elaborate(new CyclePRNG(1, Some(1), 0, true)) } - .getMessage should include ("Step size must be greater than one!") + { the [IllegalArgumentException] thrownBy extractCause[IllegalArgumentException] { + ChiselStage.elaborate(new CyclePRNG(1, Some(1), 0, true)) } + }.getMessage should include ("Step size must be greater than one!") } it should "handle non-unary steps" in { |
