**Shift with Negative/Unknown Count** What is the value of res ? reg [3:0…
**Shift with Negative/Unknown Count** What is the value of res ? reg [3:0] a, res; integer sh; initial begin a = 4'b1111; sh = 32'bx; res = a << sh; end
- 4'b1111
- 4'b0000
- 4'bxxxx
- 4'bzzzz
Correct answer
C. 4'bxxxx
Explanation
In Verilog, if any bit of the shift distance is unknown ( x ) or high-impedance ( z ), the entire result of the shift operation evaluates to unknown ( 4'bxxxx ).