diff options
| author | ducky | 2015-12-11 14:25:42 -0800 |
|---|---|---|
| committer | ducky | 2015-12-11 17:16:30 -0800 |
| commit | dbd072172f6312893e1922e48ed768ae0fab9a89 (patch) | |
| tree | c3a0f10dd286ae2bba50c31b987ab39c45189898 /src/test/scala/chiselTests/Tbl.scala | |
| parent | bffc67c2bbeb107d2ff9903aa35e85fbb7da73f9 (diff) | |
Refactor tests to use stop() and assert() instead of io.error/io.done
Gate assert, printf, stop by reset
Fix testbenches that never worked
Change simulation prints to display cycle at which test was signaled to end, not when simulator stops
Better documentation for Counter
Diffstat (limited to 'src/test/scala/chiselTests/Tbl.scala')
| -rw-r--r-- | src/test/scala/chiselTests/Tbl.scala | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/test/scala/chiselTests/Tbl.scala b/src/test/scala/chiselTests/Tbl.scala index a3b1feb0..003554c8 100644 --- a/src/test/scala/chiselTests/Tbl.scala +++ b/src/test/scala/chiselTests/Tbl.scala @@ -19,7 +19,9 @@ class Tbl(w: Int, n: Int) extends Module { io.o := m(io.ri) when (io.we) { m(io.wi) := io.d - when(io.ri === io.wi) { io.o := io.d } + when(io.ri === io.wi) { + io.o := io.d + } } } @@ -34,18 +36,24 @@ class TblTester(w: Int, n: Int, idxs: List[Int], values: List[Int]) extends Basi dut.io.ri := prev_idx dut.io.we := Bool(true) //TODO enSequence dut.io.d := vvalues(cnt) - when(cnt > UInt(0) && dut.io.o != prev_value) { io.done := Bool(true); io.error := prev_idx } - when(wrap) { io.done := Bool(true) } + when (cnt > UInt(0)) { + when (prev_idx === vidxs(cnt)) { + assert(dut.io.o === vvalues(cnt)) + } .otherwise { + assert(dut.io.o === prev_value) + } + } + when(wrap) { + stop() + } } class TblSpec extends ChiselPropSpec { - property("All table reads should return the previous write") { forAll(safeUIntPairN(8)) { case(w: Int, pairs: List[(Int, Int)]) => - whenever(w > 0) { - val (idxs, values) = pairs.unzip - assert(execute{ new TblTester(w, 1 << w, idxs, values) }) - } + require(w > 0) + val (idxs, values) = pairs.unzip + assert(execute{ new TblTester(w, 1 << w, idxs, values) }) } } } |
