From dbd072172f6312893e1922e48ed768ae0fab9a89 Mon Sep 17 00:00:00 2001 From: ducky Date: Fri, 11 Dec 2015 14:25:42 -0800 Subject: 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 --- src/test/scala/chiselTests/Tbl.scala | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/test/scala/chiselTests/Tbl.scala') 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) }) } } } -- cgit v1.2.3