diff options
| author | mergify[bot] | 2022-08-12 20:04:33 +0000 |
|---|---|---|
| committer | GitHub | 2022-08-12 20:04:33 +0000 |
| commit | 7bad3d2ec316f24f3da79d1dfef19e128cfe8bf5 (patch) | |
| tree | 67337939dbb98f8a6c127560156213c3c2420515 /docs/src | |
| parent | db18ae16a26dab5231ca83172c88b9735a977582 (diff) | |
Add ability to suppress enum cast warnings (#2671) (#2674)
(cherry picked from commit 1ad820f7f549eddcd7188b737f59a240e48a7f0a)
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
Diffstat (limited to 'docs/src')
| -rw-r--r-- | docs/src/explanations/chisel-enum.md | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/docs/src/explanations/chisel-enum.md b/docs/src/explanations/chisel-enum.md index a390aea4..16b5570d 100644 --- a/docs/src/explanations/chisel-enum.md +++ b/docs/src/explanations/chisel-enum.md @@ -17,6 +17,7 @@ import chisel3._ import chisel3.util._ import chisel3.stage.ChiselStage import chisel3.experimental.ChiselEnum +import chisel3.experimental.suppressEnumCastWarning ``` ```scala mdoc:invisible @@ -167,6 +168,30 @@ val (log2, _) = grabLog(ChiselStage.emitChirrtl(new SafeFromUInt)) println(s"```\n$log2```") ``` +You can also suppress the warning by using `suppressEnumCastWarning`. This is +primarily used for casting from [[UInt]] to a Bundle type that contains an +Enum, where the [[UInt]] is known to be valid for the Bundle type. + +```scala mdoc +class MyBundle extends Bundle { + val addr = UInt(8.W) + val op = Opcode() +} + +class SuppressedFromUInt extends Module { + val in = IO(Input(UInt(15.W))) + val out = IO(Output(new MyBundle())) + suppressEnumCastWarning { + out := in.asTypeOf(new MyBundle) + } +} +``` + +```scala mdoc:invisible +val (log3, _) = grabLog(ChiselStage.emitChirrtl(new SuppressedFromUInt)) +assert(log3.isEmpty) +``` + ## Testing The _Type_ of the enums values is `<ChiselEnum Object>.Type` which can be useful for passing the values |
