**Casez Wildcard Matching** Which branch of the casez statement will exec…
**Casez Wildcard Matching** Which branch of the casez statement will execute? reg [3:0] sel; integer out; initial begin sel = 4'b1100; casez (sel) 4'b1???: out = 1; 4'b11??: out = 2; 4'b1100: out = 3; default: out = 0; endcase end
- out = 1
- out = 2
- out = 3
- out = 0
Correct answer
A. out = 1
Explanation
casez treats ? and z as don't-care bits. Verilog evaluates case alternatives sequentially from top to bottom. Because 4'b1100 matches the first pattern 4'b1??? , branch 1 executes and the case terminates.