summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/MuxSpec.scala
diff options
context:
space:
mode:
authorRichard Lin2019-01-21 21:31:06 -0800
committerGitHub2019-01-21 21:31:06 -0800
commit99bb15f13491637f1c7ce58edb5ba494efc810dc (patch)
treeb257572551776759c29876fff68aa9f079498eb1 /src/test/scala/chiselTests/MuxSpec.scala
parent9e992816e570284193e121cd9c24503fd8cb4427 (diff)
Support DontCare in Mux and cloneSupertype (#995)
Diffstat (limited to 'src/test/scala/chiselTests/MuxSpec.scala')
-rw-r--r--src/test/scala/chiselTests/MuxSpec.scala25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/MuxSpec.scala b/src/test/scala/chiselTests/MuxSpec.scala
new file mode 100644
index 00000000..d06c00af
--- /dev/null
+++ b/src/test/scala/chiselTests/MuxSpec.scala
@@ -0,0 +1,25 @@
+package chiselTests
+
+import chisel3._
+import chisel3.testers.BasicTester
+
+class MuxTester extends BasicTester {
+ assert(Mux(0.B, 1.U, 2.U) === 2.U)
+ assert(Mux(1.B, 1.U, 2.U) === 1.U)
+ val dontCareMux1 = Wire(UInt())
+ dontCareMux1 := Mux(0.B, DontCare, 4.U) // note: Mux output of type Element
+ assert(dontCareMux1 === 4.U)
+
+ val dontCareMux2 = Wire(UInt())
+ dontCareMux2 := Mux(1.B, 3.U, DontCare) // note: Mux output of type Element
+ assert(dontCareMux2 === 3.U)
+
+ Mux(0.B, 3.U, DontCare) // just to make sure nothing crashes, any result is valid
+ stop()
+}
+
+class MuxSpec extends ChiselFlatSpec {
+ "Mux" should "pass basic checks" in {
+ assertTesterPasses { new MuxTester }
+ }
+} \ No newline at end of file