diff options
| author | Henry Cook | 2015-08-12 19:32:43 -0700 |
|---|---|---|
| committer | Henry Cook | 2015-08-12 19:32:57 -0700 |
| commit | 85d7403f9bf7bc2b3520f924736c237f21f70ebd (patch) | |
| tree | 64560f779063a419395a2fb8a31ea52c52af4404 /src/test/scala/ChiselTests/Counter.scala | |
| parent | 7e69966362b1dbd9835695250494857f3a3767c8 (diff) | |
being to convert tests to scala-test; tests compile and run
Diffstat (limited to 'src/test/scala/ChiselTests/Counter.scala')
| -rw-r--r-- | src/test/scala/ChiselTests/Counter.scala | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/test/scala/ChiselTests/Counter.scala b/src/test/scala/ChiselTests/Counter.scala deleted file mode 100644 index 55fbf6db..00000000 --- a/src/test/scala/ChiselTests/Counter.scala +++ /dev/null @@ -1,45 +0,0 @@ -package ChiselTests -import Chisel._ -import Chisel.testers._ - -object Counter { - def wrapAround(n: UInt, max: UInt) = - Mux(n > max, UInt(0), n) - def apply(max: UInt, en: Bool, amt: UInt): UInt = { - val x = Reg(init=UInt(0, max.getWidth)) - when (en) { x := wrapAround(x +% amt, max) } - x - } -} - -class Counter extends Module { - val io = new Bundle { - val inc = Bool(INPUT) - val amt = UInt(INPUT, 4) - val tot = UInt(OUTPUT, 8) - } - io.tot := Counter(UInt(255), io.inc, io.amt) -} - -class CounterTester(c: Counter) extends Tester(c) { - val maxInt = 16 - var curCnt = 0 - - def intWrapAround(n: Int, max: Int) = - if(n > max) 0 else n - - // let it spin for a bit - for (i <- 0 until 5) { - step(1) - } - - for (i <- 0 until 10) { - val inc = rnd.nextBoolean() - val amt = rnd.nextInt(maxInt) - poke(c.io.inc, if (inc) 1 else 0) - poke(c.io.amt, amt) - step(1) - curCnt = if(inc) intWrapAround(curCnt + amt, 255) else curCnt - expect(c.io.tot, curCnt) - } -} |
