-
Notifications
You must be signed in to change notification settings - Fork 611
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
63 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// See LICENSE for license details. | ||
|
||
package chiselTests | ||
|
||
import chisel3._ | ||
import chisel3.util._ | ||
import chisel3.testers.BasicTester | ||
|
||
class SwitchSpec extends ChiselFlatSpec { | ||
"switch" should "require literal conditions" in { | ||
a [java.lang.IllegalArgumentException] should be thrownBy { | ||
elaborate(new Module { | ||
val io = IO(new Bundle {}) | ||
val state = RegInit(0.U) | ||
val wire = WireInit(0.U) | ||
switch (state) { | ||
is (wire) { state := 1.U } | ||
} | ||
}) | ||
} | ||
} | ||
it should "require mutually exclusive conditions" in { | ||
a [java.lang.IllegalArgumentException] should be thrownBy { | ||
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 } | ||
} | ||
}) | ||
} | ||
} | ||
} |