summaryrefslogtreecommitdiff
path: root/src/test/scala
diff options
context:
space:
mode:
authorJiuyang Liu2021-05-18 14:53:59 +0000
committerJiuyang Liu2021-06-16 10:32:04 +0800
commitb0c76525ed53c20dbbe4bd8eea4a9676d7247ec7 (patch)
tree1535ad204c5fbd8d7cb2f91fb8c8b9a913ffd9fb /src/test/scala
parent88b7c48c18267e55c755f4fe6615c2faf2910906 (diff)
test decode cache.
Diffstat (limited to 'src/test/scala')
-rw-r--r--src/test/scala/chiselTests/util/experimental/DecoderSpec.scala61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/util/experimental/DecoderSpec.scala b/src/test/scala/chiselTests/util/experimental/DecoderSpec.scala
new file mode 100644
index 00000000..3c9d490d
--- /dev/null
+++ b/src/test/scala/chiselTests/util/experimental/DecoderSpec.scala
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: Apache-2.0
+
+package chiselTests.util.experimental
+
+import chisel3.util.experimental.decode.{DecodeTableAnnotation, Minimizer, QMCMinimizer, TruthTable}
+import chiselTests.SMTModelCheckingSpec
+import chiselTests.util.experimental.minimizer.DecodeTestModule
+import firrtl.annotations.ReferenceTarget
+
+class DecoderSpec extends SMTModelCheckingSpec {
+ val xor = TruthTable(
+ """10->1
+ |01->1
+ | 0""".stripMargin)
+
+ def minimizer: Minimizer = QMCMinimizer
+
+ "decoder" should "pass without DecodeTableAnnotation" in {
+ test(
+ () => new DecodeTestModule(minimizer, table = xor),
+ s"${minimizer.getClass.getSimpleName}.noAnno",
+ success
+ )
+ }
+
+ "decoder" should "fail with a incorrect DecodeTableAnnotation" in {
+ test(
+ () => new DecodeTestModule(minimizer, table = xor),
+ s"${minimizer.getClass.getSimpleName}.incorrectAnno",
+ fail(0),
+ annos = Seq(
+ DecodeTableAnnotation(ReferenceTarget("", "", Nil, "", Nil),
+ """10->1
+ |01->1
+ | 0""".stripMargin,
+ """10->1
+ | 0""".stripMargin
+ )
+ )
+ )
+ }
+
+ "decoder" should "success with a correct DecodeTableAnnotation" in {
+ test(
+ () => new DecodeTestModule(minimizer, table = xor),
+ s"${minimizer.getClass.getSimpleName}.correctAnno",
+ success,
+ annos = Seq(
+ DecodeTableAnnotation(ReferenceTarget("", "", Nil, "", Nil),
+ """10->1
+ |01->1
+ | 0""".stripMargin,
+ QMCMinimizer.minimize(TruthTable(
+ """10->1
+ |01->1
+ | 0""".stripMargin)).toString
+ )
+ )
+ )
+ }
+}