summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/util/experimental
diff options
context:
space:
mode:
authorJiuyang Liu2021-05-06 16:18:58 +0000
committerJiuyang Liu2021-06-16 10:32:04 +0800
commit71575609ae7242585ed1008b8473acae1a42165e (patch)
tree91d6f5b110f6bf857aec2b53a95b03ffe5fabb60 /src/test/scala/chiselTests/util/experimental
parentea84a17691c1fbea81644788b78699702c8faaf3 (diff)
implement TruthTable to represent a decode table.
Diffstat (limited to 'src/test/scala/chiselTests/util/experimental')
-rw-r--r--src/test/scala/chiselTests/util/experimental/TruthTableSpec.scala39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/util/experimental/TruthTableSpec.scala b/src/test/scala/chiselTests/util/experimental/TruthTableSpec.scala
new file mode 100644
index 00000000..ed79f7f5
--- /dev/null
+++ b/src/test/scala/chiselTests/util/experimental/TruthTableSpec.scala
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: Apache-2.0
+
+package chiselTests.util.experimental
+
+import chisel3.util.BitPat
+import chisel3.util.experimental.decode.TruthTable
+import org.scalatest.flatspec.AnyFlatSpec
+
+class TruthTableSpec extends AnyFlatSpec {
+ val table = TruthTable(
+ Map(
+ // BitPat("b000") -> BitPat("b0"),
+ BitPat("b001") -> BitPat("b?"),
+ BitPat("b010") -> BitPat("b?"),
+ // BitPat("b011") -> BitPat("b0"),
+ BitPat("b100") -> BitPat("b1"),
+ BitPat("b101") -> BitPat("b1"),
+ // BitPat("b110") -> BitPat("b0"),
+ BitPat("b111") -> BitPat("b1")
+ ),
+ BitPat("b0")
+ )
+ val str = """001->?
+ |010->?
+ |100->1
+ |101->1
+ |111->1
+ |0""".stripMargin
+ "TruthTable" should "serialize" in {
+ assert(table.toString contains "001->?")
+ assert(table.toString contains "010->?")
+ assert(table.toString contains "100->1")
+ assert(table.toString contains "111->1")
+ assert(table.toString contains " 0")
+ }
+ "TruthTable" should "deserialize" in {
+ assert(TruthTable(str) == table)
+ }
+}