summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/UInt.scala
diff options
context:
space:
mode:
authorHenry Cook2015-08-14 14:28:56 -0700
committerHenry Cook2015-08-14 14:28:56 -0700
commit3dade9a48f059e3eecc7048bcd1cd1db48cdb56a (patch)
tree447f263f04de6ac3eac6e943ab57febf94e54f62 /src/test/scala/chiselTests/UInt.scala
parent0e1297437944956b3dd443436258f4c682190ca4 (diff)
more tests
Diffstat (limited to 'src/test/scala/chiselTests/UInt.scala')
-rw-r--r--src/test/scala/chiselTests/UInt.scala32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/UInt.scala b/src/test/scala/chiselTests/UInt.scala
new file mode 100644
index 00000000..8885c71f
--- /dev/null
+++ b/src/test/scala/chiselTests/UInt.scala
@@ -0,0 +1,32 @@
+package chiselTests
+
+import Chisel._
+import org.scalatest._
+import org.scalatest.prop._
+import Chisel.testers.BasicTester
+
+class GoodBoolConversion extends Module {
+ val io = new Bundle {
+ val u = UInt(1, width = 1).asInput
+ val b = Bool(OUTPUT)
+ }
+ io.b := io.u.toBool
+}
+
+class BadBoolConversion extends Module {
+ val io = new Bundle {
+ val u = UInt(1, width = 5).asInput
+ val b = Bool(OUTPUT)
+ }
+ io.b := io.u.toBool
+}
+
+class UIntSpec extends ChiselPropSpec with Matchers {
+ property("Bools can be created from 1 bit UInts") {
+ elaborate(new GoodBoolConversion)
+ }
+
+ property("Bools cannot be created from >1 bit UInts") {
+ a [Exception] should be thrownBy { elaborate(new BadBoolConversion) }
+ }
+}