summaryrefslogtreecommitdiff
path: root/integration-tests/src/test/scala/chiselTests/util/experimental/DecoderSpec.scala
diff options
context:
space:
mode:
authorJack Koenig2021-09-17 21:01:26 -0700
committerJack Koenig2021-09-17 21:01:26 -0700
commit5c8c19345e6711279594cf1f9ddab33623c8eba7 (patch)
treed9d6ced3934aa4a8be3dec19ddcefe50a7a93d5a /integration-tests/src/test/scala/chiselTests/util/experimental/DecoderSpec.scala
parente63b9667d89768e0ec6dc8a9153335cb48a213a7 (diff)
parent958904cb2f2f65d02b2ab3ec6d9ec2e06d04e482 (diff)
Merge branch 'master' into 3.5-release
Diffstat (limited to 'integration-tests/src/test/scala/chiselTests/util/experimental/DecoderSpec.scala')
-rw-r--r--integration-tests/src/test/scala/chiselTests/util/experimental/DecoderSpec.scala53
1 files changed, 53 insertions, 0 deletions
diff --git a/integration-tests/src/test/scala/chiselTests/util/experimental/DecoderSpec.scala b/integration-tests/src/test/scala/chiselTests/util/experimental/DecoderSpec.scala
new file mode 100644
index 00000000..c31fdee0
--- /dev/null
+++ b/integration-tests/src/test/scala/chiselTests/util/experimental/DecoderSpec.scala
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: Apache-2.0
+
+package chiselTests.util.experimental
+
+import chisel3.util.experimental.decode.{DecodeTableAnnotation, Minimizer, QMCMinimizer, TruthTable}
+import chiselTests.util.experimental.minimizer.DecodeTestModule
+import firrtl.annotations.ReferenceTarget
+import org.scalatest.flatspec.AnyFlatSpec
+import chiseltest._
+import chiseltest.formal._
+
+class DecoderSpec extends AnyFlatSpec with ChiselScalatestTester with Formal {
+ val xor = TruthTable(
+ """10->1
+ |01->1
+ | 0""".stripMargin)
+
+ def minimizer: Minimizer = QMCMinimizer
+
+ "decoder" should "pass without DecodeTableAnnotation" in {
+ verify(new DecodeTestModule(minimizer, table = xor), Seq(BoundedCheck(1)))
+ }
+
+ "decoder" should "fail with a incorrect DecodeTableAnnotation" in {
+ val annos = Seq(
+ DecodeTableAnnotation(ReferenceTarget("", "", Nil, "", Nil),
+ """10->1
+ |01->1
+ | 0""".stripMargin,
+ """10->1
+ | 0""".stripMargin
+ )
+ )
+ assertThrows[FailedBoundedCheckException] {
+ verify(new DecodeTestModule(minimizer, table = xor), BoundedCheck(1) +: annos)
+ }
+ }
+
+ "decoder" should "success with a correct DecodeTableAnnotation" in {
+ val annos = Seq(
+ DecodeTableAnnotation(ReferenceTarget("", "", Nil, "", Nil),
+ """10->1
+ |01->1
+ | 0""".stripMargin,
+ QMCMinimizer.minimize(TruthTable(
+ """10->1
+ |01->1
+ | 0""".stripMargin)).toString
+ )
+ )
+ verify(new DecodeTestModule(minimizer, table = xor), BoundedCheck(1) +: annos)
+ }
+}