**Casex Hazards with Unknowns** What value does out receive? reg [3:0] se…
**Casex Hazards with Unknowns** What value does out receive? reg [3:0] sel; integer out; initial begin sel = 4'b10x0; casex (sel) 4'b1010: out = 1; 4'b1000: out = 2; default: out = 3; endcase end
- out = 1
- out = 2
- out = 3
- out = 0
Correct answer
A. out = 1
Explanation
casex treats x and z in both the case expression and the branch targets as don't-cares. Since bit 1 of sel is x , it matches the 1 in 4'b1010 on the very first branch, setting out = 1 . This shows why casex can mask unintended hardware errors.