diff options
| author | Adam Izraelevitz | 2015-12-11 17:21:36 -0800 |
|---|---|---|
| committer | Adam Izraelevitz | 2015-12-11 17:21:36 -0800 |
| commit | b8cd46de6c01febdbdba7ecb83db494bad8a7a94 (patch) | |
| tree | c3a0f10dd286ae2bba50c31b987ab39c45189898 /src/test/scala/chiselTests/Counter.scala | |
| parent | bffc67c2bbeb107d2ff9903aa35e85fbb7da73f9 (diff) | |
| parent | dbd072172f6312893e1922e48ed768ae0fab9a89 (diff) | |
Merge pull request #67 from ucb-bar/asserttest
Refactor tests to use stop() and assert() instead of io.error/io.done
Diffstat (limited to 'src/test/scala/chiselTests/Counter.scala')
| -rw-r--r-- | src/test/scala/chiselTests/Counter.scala | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/test/scala/chiselTests/Counter.scala b/src/test/scala/chiselTests/Counter.scala index 1aa2aaba..aa21423f 100644 --- a/src/test/scala/chiselTests/Counter.scala +++ b/src/test/scala/chiselTests/Counter.scala @@ -9,27 +9,33 @@ import Chisel.testers.BasicTester class CountTester(max: Int) extends BasicTester { val cnt = Counter(max) when(Bool(true)) { cnt.inc() } - when(cnt.value === UInt(max-1)) { io.done := Bool(true) } + when(cnt.value === UInt(max-1)) { + stop() + } } 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(Bool(true), 32)._1 - when(cnt === UInt(31)) { - io.done := Bool(true) - io.error := cnt != UInt(popCount(seed)) + + val (cntEnVal, _) = Counter(ens(0), 32) + val (_, done) = Counter(Bool(true), 33) + + when(done) { + assert(cntEnVal === UInt(popCount(seed))) + stop() } } class WrapTester(max: Int) extends BasicTester { val (cnt, wrap) = Counter(Bool(true), max) - when(wrap) { io.done := Bool(true); io.error := cnt != UInt(max) } + when(wrap) { + assert(cnt === UInt(max - 1)) + stop() + } } class CounterSpec extends ChiselPropSpec { - property("Counter should count up") { forAll(smallPosInts) { (max: Int) => assert(execute{ new CountTester(max) }) } } |
