summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authormergify[bot]2022-07-06 21:42:13 +0000
committerGitHub2022-07-06 21:42:13 +0000
commit4f10bdd703d7559cddae50541cf7c8e0a1c1d4c0 (patch)
tree70321d89b0c68583080610587921715cf09e9ef5 /src/test
parent2b977a74293a49e9e2a5d960a6a9c07df22430ce (diff)
Refactor TruthTable.apply and add factory method for Espresso (backport #2612) (#2620)
* Refactor TruthTable.apply and add factory method for Espresso (#2612) Improves performance of creating TruthTables by processing entire BitPats rather than individual bits. New TruthTable factory method enables constructing TruthTables with semantics of OR-ing output BitPats together rather than erroring when multiple terms have the same input BitPat. This alternative factory method matches semantics for the output format of Espresso. Co-authored-by: Megan Wachs <megan@sifive.com> Co-authored-by: Jack Koenig <koenig@sifive.com> (cherry picked from commit 231f14e74f112a9f721e774561126b2bd1250039) # Conflicts: # src/main/scala/chisel3/util/BitPat.scala * Resolve backport conflicts Co-authored-by: Aditya Naik <91489422+adkian-sifive@users.noreply.github.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/chiselTests/util/experimental/TruthTableSpec.scala17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/util/experimental/TruthTableSpec.scala b/src/test/scala/chiselTests/util/experimental/TruthTableSpec.scala
index fa2c6f08..9b2dd600 100644
--- a/src/test/scala/chiselTests/util/experimental/TruthTableSpec.scala
+++ b/src/test/scala/chiselTests/util/experimental/TruthTableSpec.scala
@@ -104,4 +104,21 @@ class TruthTableSpec extends AnyFlatSpec {
assert(t.toString contains "111->?")
assert(t.toString contains " 0")
}
+
+ "Using TruthTable.fromEspressoOutput" should "merge rows on conflict" in {
+ val mapping = List(
+ (BitPat("b110"), BitPat("b001")),
+ (BitPat("b111"), BitPat("b001")),
+ (BitPat("b111"), BitPat("b010")),
+ (BitPat("b111"), BitPat("b100"))
+ )
+
+ assert(
+ TruthTable.fromEspressoOutput(mapping, BitPat("b?")) ==
+ TruthTable.fromString("""110->001
+ |111->111
+ |?
+ |""".stripMargin)
+ )
+ }
}