summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests
diff options
context:
space:
mode:
authorJack Koenig2020-08-11 10:28:15 -0700
committerGitHub2020-08-11 10:28:15 -0700
commit3668532fabc4ba4eaf70cf0ad1a55522aa33cdb3 (patch)
tree48a18bfa974e71845ec91140c32d0b0d4fcc73b4 /src/test/scala/chiselTests
parentf103ce0e468e106f4758f7b6a0088d909cc5c152 (diff)
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.
Diffstat (limited to 'src/test/scala/chiselTests')
-rw-r--r--src/test/scala/chiselTests/Counter.scala8
1 files changed, 6 insertions, 2 deletions
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") {