**Case Equality and Ternary Operations** What is the value of y ? reg [1:…
**Case Equality and Ternary Operations** What is the value of y ? reg [1:0] sel; reg [3:0] y; initial begin sel = 2'b1z; y = (sel == 2'b1z) ? 4'd10 : 4'd5; end
- 4'd10
- 4'd5
- 4'dx
- 4'd0
Correct answer
C. 4'dx
Explanation
The equality test evaluates to x . For an unknown ternary condition, Verilog merges the branches bit by bit; where they differ, the result bit is x . Since 4'd10 is 1010 and 4'd5 is 0101 , every bit differs, so y = 4'bxxxx .