blob: 78e5d59ee9e4723f1505c91801081d5e3abcd882 (
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
33
34
35
|
// SPDX-License-Identifier: Apache-2.0
package chiselTests
import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util.{switch, is}
class SwitchSpec extends ChiselFlatSpec with Utils {
"switch" should "require literal conditions" in {
a [java.lang.IllegalArgumentException] should be thrownBy extractCause[IllegalArgumentException] {
ChiselStage.elaborate(new Module {
val io = IO(new Bundle {})
val state = RegInit(0.U)
val wire = WireDefault(0.U)
switch (state) {
is (wire) { state := 1.U }
}
})
}
}
it should "require mutually exclusive conditions" in {
a [java.lang.IllegalArgumentException] should be thrownBy extractCause[IllegalArgumentException] {
ChiselStage.elaborate(new Module {
val io = IO(new Bundle {})
val state = RegInit(0.U)
switch (state) {
is (0.U) { state := 1.U }
is (1.U) { state := 2.U }
is (0.U) { state := 3.U }
}
})
}
}
}
|