From 3668532fabc4ba4eaf70cf0ad1a55522aa33cdb3 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Tue, 11 Aug 2020 10:28:15 -0700 Subject: Restore Counter.n API (#1546) Includes special case support for Counter(0) which has identical behavior to Counter(1) except for the value of n.--- src/test/scala/chiselTests/Counter.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/scala/chiselTests/Counter.scala b/src/test/scala/chiselTests/Counter.scala index 31bfe7eb..985cf3fd 100644 --- a/src/test/scala/chiselTests/Counter.scala +++ b/src/test/scala/chiselTests/Counter.scala @@ -8,8 +8,10 @@ import chisel3.util._ class CountTester(max: Int) extends BasicTester { val cnt = Counter(max) + assert(cnt.n == max) when(true.B) { cnt.inc() } - when(cnt.value === (max-1).asUInt) { + val expected = if (max == 0) 0.U else (max - 1).U + when(cnt.value === expected) { stop() } } @@ -50,7 +52,9 @@ class RangeTester(r: Range) extends BasicTester { class CounterSpec extends ChiselPropSpec { property("Counter should count up") { - forAll(smallPosInts) { (max: Int) => assertTesterPasses{ new CountTester(max) } } + for (i <- 0 until 4) { + assertTesterPasses(new CountTester(i)) + } } property("Counter can be en/disabled") { -- cgit v1.2.3