summaryrefslogtreecommitdiff
path: root/integration-tests/src/test/scala/chiselTests/util/experimental/minimizer
diff options
context:
space:
mode:
authormergify[bot]2022-10-25 01:58:03 +0000
committerGitHub2022-10-25 01:58:03 +0000
commit2f890aabc1ecf04c6efcb84cee4f00da67be6a53 (patch)
treef913d335a49fa5394ff4435018277fd00e458235 /integration-tests/src/test/scala/chiselTests/util/experimental/minimizer
parentf86c1ff7b39146f23cd1959bcc63dcb3b0b27125 (diff)
Add Scalafmt for mill (backport #2805) (#2807)
* Add Scalafmt for mill (#2805) * add scalafmt for test in mill build system. * reformat codes in integration-tests (cherry picked from commit d881fd29d7af91a7c514565b4b21797f1e44fbdb) # Conflicts: # build.sc # integration-tests/src/test/scala/chiselTests/util/experimental/BitPat.scala * Resolve backport conflicts Co-authored-by: Jiuyang Liu <liu@jiuyang.me> Co-authored-by: Jack Koenig <koenig@sifive.com>
Diffstat (limited to 'integration-tests/src/test/scala/chiselTests/util/experimental/minimizer')
-rw-r--r--integration-tests/src/test/scala/chiselTests/util/experimental/minimizer/MinimizerSpec.scala197
1 files changed, 106 insertions, 91 deletions
diff --git a/integration-tests/src/test/scala/chiselTests/util/experimental/minimizer/MinimizerSpec.scala b/integration-tests/src/test/scala/chiselTests/util/experimental/minimizer/MinimizerSpec.scala
index 2d3e073c..0b6d8e91 100644
--- a/integration-tests/src/test/scala/chiselTests/util/experimental/minimizer/MinimizerSpec.scala
+++ b/integration-tests/src/test/scala/chiselTests/util/experimental/minimizer/MinimizerSpec.scala
@@ -34,82 +34,92 @@ trait MinimizerSpec extends AnyFlatSpec with ChiselScalatestTester with Formal {
// making optimization opportunities to decoder algorithms
"case0" should "pass" in {
- minimizerTest(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")
- ))
+ minimizerTest(
+ 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")
+ )
+ )
}
"case1" should "pass" in {
- minimizerTest(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("b1")
- ))
+ minimizerTest(
+ 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("b1")
+ )
+ )
}
"caseX" should "pass" in {
- minimizerTest(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("b?")
- ))
+ minimizerTest(
+ 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("b?")
+ )
+ )
}
"caseMultiDefault" should "pass" in {
- minimizerTest(TruthTable(
- Map(
- BitPat("b000") -> BitPat("b0100"),
- BitPat("b001") -> BitPat("b?111"),
- BitPat("b010") -> BitPat("b?000"),
- BitPat("b011") -> BitPat("b0101"),
- BitPat("b111") -> BitPat("b1101")
- ),
- BitPat("b?100")
- ))
+ minimizerTest(
+ TruthTable(
+ Map(
+ BitPat("b000") -> BitPat("b0100"),
+ BitPat("b001") -> BitPat("b?111"),
+ BitPat("b010") -> BitPat("b?000"),
+ BitPat("b011") -> BitPat("b0101"),
+ BitPat("b111") -> BitPat("b1101")
+ ),
+ BitPat("b?100")
+ )
+ )
}
"case7SegDecoder" should "pass" in {
- minimizerTest(TruthTable(
- Map(
- BitPat("b0000") -> BitPat("b111111001"),
- BitPat("b0001") -> BitPat("b011000001"),
- BitPat("b0010") -> BitPat("b110110101"),
- BitPat("b0011") -> BitPat("b111100101"),
- BitPat("b0100") -> BitPat("b011001101"),
- BitPat("b0101") -> BitPat("b101101101"),
- BitPat("b0110") -> BitPat("b101111101"),
- BitPat("b0111") -> BitPat("b111000001"),
- BitPat("b1000") -> BitPat("b111111101"),
- BitPat("b1001") -> BitPat("b111101101"),
- ),
- BitPat("b???????10")
- ))
+ minimizerTest(
+ TruthTable(
+ Map(
+ BitPat("b0000") -> BitPat("b111111001"),
+ BitPat("b0001") -> BitPat("b011000001"),
+ BitPat("b0010") -> BitPat("b110110101"),
+ BitPat("b0011") -> BitPat("b111100101"),
+ BitPat("b0100") -> BitPat("b011001101"),
+ BitPat("b0101") -> BitPat("b101101101"),
+ BitPat("b0110") -> BitPat("b101111101"),
+ BitPat("b0111") -> BitPat("b111000001"),
+ BitPat("b1000") -> BitPat("b111111101"),
+ BitPat("b1001") -> BitPat("b111101101")
+ ),
+ BitPat("b???????10")
+ )
+ )
}
// A simple RV32I decode table example
@@ -217,6 +227,7 @@ trait MinimizerSpec extends AnyFlatSpec with ChiselScalatestTester with Formal {
val FN_SLTU = "1110"
val FN_SGEU = "1111"
+ // format: off
minimizerTest(TruthTable(
Map(
BNE -> Seq(Y, N, N, Y, N, N, Y, Y, N, A2_RS2, A1_RS1, IMM_SB, DW_X, FN_SNE, N, M_X, N, N, N, N, N, N, N, CSR_N, N, N, N, N),
@@ -271,40 +282,44 @@ trait MinimizerSpec extends AnyFlatSpec with ChiselScalatestTester with Formal {
).map { case (k, v) => BitPat(s"b$k") -> BitPat(s"b${v.reduce(_ + _)}") },
BitPat(s"b${Seq(N, X, X, X, X, X, X, X, X, A2_X, A1_X, IMM_X, DW_X, FN_X, N, M_X, X, X, X, X, X, X, X, CSR_X, X, X, X, X).reduce(_ + _)}")
))
+ // format: on
}
"output is 0" should "pass" in {
- minimizerTest(TruthTable.fromString(
- """00->0
- |01->?
- |10->0
- |11->0
- | ?
- |""".stripMargin
-
- ))
+ minimizerTest(
+ TruthTable.fromString(
+ """00->0
+ |01->?
+ |10->0
+ |11->0
+ | ?
+ |""".stripMargin
+ )
+ )
}
"output is 1" should "pass" in {
- minimizerTest(TruthTable.fromString(
- """00->1
- |01->?
- |10->1
- |11->1
- | ?
- |""".stripMargin
-
- ))
+ minimizerTest(
+ TruthTable.fromString(
+ """00->1
+ |01->?
+ |10->1
+ |11->1
+ | ?
+ |""".stripMargin
+ )
+ )
}
// I know this seems to be crazy, but if user is crazy as well...
"output is dont care" should "pass" in {
- minimizerTest(TruthTable.fromString(
- """00->?
- |01->?
- |10->?
- |11->?
- | ?
- |""".stripMargin
-
- ))
+ minimizerTest(
+ TruthTable.fromString(
+ """00->?
+ |01->?
+ |10->?
+ |11->?
+ | ?
+ |""".stripMargin
+ )
+ )
}
}