diff options
| author | Jack | 2022-03-15 19:37:37 +0000 |
|---|---|---|
| committer | Jack | 2022-03-15 19:37:37 +0000 |
| commit | 2f21943ff772da2171df866d4cee71dfa8127bf8 (patch) | |
| tree | d00c9059c9361920036e784425641288782515d5 /integration-tests | |
| parent | 1876e740a48be2e5ff5bd4fd6c2018927f1dcec2 (diff) | |
| parent | f26df23bbe0ae9b7162ed70369f24b01d75a1493 (diff) | |
Merge branch '3.5.x' into 3.5-release
Diffstat (limited to 'integration-tests')
| -rw-r--r-- | integration-tests/src/test/scala/chiselTests/util/experimental/algorithm/Bitwise.scala | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/integration-tests/src/test/scala/chiselTests/util/experimental/algorithm/Bitwise.scala b/integration-tests/src/test/scala/chiselTests/util/experimental/algorithm/Bitwise.scala new file mode 100644 index 00000000..6c8eb4b4 --- /dev/null +++ b/integration-tests/src/test/scala/chiselTests/util/experimental/algorithm/Bitwise.scala @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: Apache-2.0 + +import chisel3._ +import chisel3.util._ +import chiseltest._ +import chiseltest.formal._ +import org.scalatest.flatspec.AnyFlatSpec +import scala.math.min + +class ScanLeftOrTestModule(width: Int) extends Module { + val input = IO(Input(UInt(width.W))) + + var lsb = false.B + val vec = for(b <- input.asBools) yield { + val cur = b || lsb + lsb = cur + cur + } + val ref = VecInit(vec).asUInt + + val testee = scanLeftOr(input) + + assert(testee === ref) +} + +class ScanRightOrTestModule(width: Int) extends Module { + val input = IO(Input(UInt(width.W))) + + val ref = Reverse(scanLeftOr(Reverse(input))) + val testee = scanRightOr(input) + + assert(testee === ref) +} + +class scanOrTest extends AnyFlatSpec with ChiselScalatestTester with Formal { + "scanLeftOr" should "compute correctly" in { + for(i <- 1 to 16) { + verify(new ScanLeftOrTestModule(i), Seq(BoundedCheck(1))) + } + } + + "scanRightOr" should "compute correctly" in { + for(i <- 1 to 16) { + verify(new ScanRightOrTestModule(i), Seq(BoundedCheck(1))) + } + } +} |
