diff options
| author | Henry Cook | 2015-11-04 09:21:07 -0800 |
|---|---|---|
| committer | Henry Cook | 2015-11-04 09:21:07 -0800 |
| commit | a3c9680d1e2b84693759747a4779341ba80c4a50 (patch) | |
| tree | e97ab1d8394b0463ec7f600fce7ba278bd68d93a /src/test/scala/chiselTests/Counter.scala | |
| parent | 23d15d166d2ed32f8bd9a153a806c09982659011 (diff) | |
Remove Parameters library and refactor Driver.
In addition to removing all the extraneous Driver invocations that created various top-level Parameters instances,
this commit also lays the groundwork for stanza-firrtl/verilator based testing of Modules that extend BasicTester.
The execution-based tests have been updated accordingly. They will only succeed if firrtl and verilator binaries have been installed.
Further work is needed on individual tests to use assertions instead of .io.error.
Diffstat (limited to 'src/test/scala/chiselTests/Counter.scala')
| -rw-r--r-- | src/test/scala/chiselTests/Counter.scala | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/test/scala/chiselTests/Counter.scala b/src/test/scala/chiselTests/Counter.scala index 0e8601b3..080130df 100644 --- a/src/test/scala/chiselTests/Counter.scala +++ b/src/test/scala/chiselTests/Counter.scala @@ -6,37 +6,37 @@ import org.scalatest._ import org.scalatest.prop._ import Chisel.testers.BasicTester -class CounterSpec extends ChiselPropSpec { +class CountTester(max: Int) extends BasicTester { + val cnt = Counter(max) + when(cnt.value === UInt(max)) { io.done := Bool(true) } +} - class CountTester(max: Int) extends BasicTester { - val cnt = Counter(max) - when(cnt.value === UInt(max)) { io.done := Bool(true) } +class EnableTester(seed: Int) extends BasicTester { + val ens = Reg(init = UInt(seed)) + ens := ens >> 1 + val (cntEn, cntWrap) = Counter(ens(0), 32) + val cnt = Counter(32) + when(cnt.value === UInt(31)) { + io.done := Bool(true) + io.error := cnt.value != UInt(popCount(seed)) } +} + +class WrapTester(max: Int) extends BasicTester { + val (cnt, wrap) = Counter(Bool(true), max) + when(wrap) { io.done := Bool(true); io.error := cnt != UInt(max) } +} + +class CounterSpec extends ChiselPropSpec { property("Counter should count up") { forAll(smallPosInts) { (max: Int) => assert(execute{ new CountTester(max) }) } } - class EnableTester(seed: Int) extends BasicTester { - val ens = Reg(init = UInt(seed)) - ens := ens >> 1 - val (cntEn, cntWrap) = Counter(ens(0), 32) - val cnt = Counter(32) - when(cnt.value === UInt(31)) { - io.done := Bool(true) - io.error := cnt.value != UInt(popCount(seed)) - } - } - property("Counter can be en/disabled") { forAll(safeUInts) { (seed: Int) => assert(execute{ new EnableTester(seed) }) } } - class WrapTester(max: Int) extends BasicTester { - val (cnt, wrap) = Counter(Bool(true), max) - when(wrap) { io.done := Bool(true); io.error := cnt != UInt(max) } - } - property("Counter should wrap") { forAll(smallPosInts) { (max: Int) => assert(execute{ new WrapTester(max) }) } } |
