Home / Learn Verilog / casez and casex

casez and casex

Wildcard matching.

In shortWildcard matching.

What's actually going on

1??? matches 1000-111113?2?1?0
1??? matches 1000-1111

In plain terms

In casez, z and ? bits in a label are wildcards; casex also ignores x.

Why we use it

Priority encoders and instruction decoding.

Under the hood

Prefer casez; avoid casex (it hides x bugs).

Real-world use

  • Everyday RTL design
  • FPGA and ASIC projects
  • Testbenches and debugging

Try it

casez priorityVerilog: edit and run

? matches any bit.

Quick quiz

1. In casez ? means...