File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -897,6 +897,31 @@ compile(new TooWideOrNarrowUInt(8, 2))
897897compile(new TooWideOrNarrowUInt (8 , 4 ))
898898```
899899
900+ ## How can I use Verilog "case equality" operators in Chisel?
901+
902+ Verilog has "case equality" (` === ` ) and inequality (` !== ` ) operators.
903+ They are typically used to ignore unknown (` X ` ) values in assertions.
904+
905+ Chisel does not support Verilog ` X ` directly, but it is possible to check if a value is ` X ` with ` chisel3.util.circt.isX ` .
906+ ` isX ` is commonly used to guard assertions against ` X ` which gives similar behavior to Verilog case equality.
907+
908+ ``` scala mdoc:silent:reset
909+ import chisel3 ._
910+ import chisel3 .util .circt .IsX
911+
912+ class AssertButAllowX extends Module {
913+ val in = IO (Input (UInt (8 .W )))
914+
915+ // Assert that in is never zero; also do not trigger assert in the presence of X.
916+ assert(IsX (in) || in =/= 0 .U , " in should never equal 0" )
917+ }
918+ ```
919+
920+ ``` scala mdoc:invisible
921+ // Hidden but will make sure this actually compiles
922+ chisel3.docs.emitSystemVerilog(new AssertButAllowX )
923+ ```
924+
900925## Predictable Naming
901926
902927### How do I get Chisel to name signals properly in blocks like when/withClockAndReset?
You can’t perform that action at this time.
0 commit comments