blob: 8885c71f3d2064b6b3950027fae31933b5d85c71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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) }
}
}
|