Skip to content

Commit a205a02

Browse files
Test equalTo, greaterThan, atLeast in PopCount tester and fix property name
1 parent 340b837 commit a205a02

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/test/scala-2/chiselTests/PopCount.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@ class PopCountTester(n: Int) extends Module {
1818
val expected = x.asBools.foldLeft(0.U)(_ +& _)
1919
assert(result === expected)
2020

21+
for (c <- 0 to n + 2) {
22+
assert(PopCount.equalTo (c, x) === (PopCount(x)===c.U), s"Wrong result for PopCount.equalTo ($c,x) function, x.width=$n")
23+
assert(PopCount.greaterThan(c, x) === (PopCount(x)> c.U), s"Wrong result for PopCount.greaterThan($c,x) function, x.width=$n")
24+
assert(PopCount.atLeast (c, x) === (PopCount(x)>= c.U), s"Wrong result for PopCount.atLeast ($c,x) function, x.width=$n")
25+
}
2126
require(result.getWidth == BigInt(n).bitLength)
2227
}
2328

2429
class PopCountSpec extends AnyPropSpec with PropertyUtils with ChiselSim {
25-
property("Mul lookup table should return the correct result") {
30+
property("PopCount circuitry should return the correct result") {
2631
forAll(smallPosInts) { (n: Int) => simulate(new PopCountTester(n))(RunUntilFinished(math.pow(2, n).toInt + 2)) }
2732
}
2833
}

0 commit comments

Comments
 (0)