**Arithmetic Shift with Unsigned Variable** What is the binary value of o…
**Arithmetic Shift with Unsigned Variable** What is the binary value of out ? reg [3:0] a; reg [3:0] out; initial begin a = 4'b1000; out = a >>> 2; end
- 4'b1110
- 4'b1100
- 4'b0010
- 4'b0001
Correct answer
C. 4'b0010
Explanation
Even though >>> is the arithmetic right shift operator, in Verilog it performs sign-extension **only if** the operand is explicitly declared as signed . Because a is an unsigned reg , zero-filling is used instead of sign-extension, giving 4'b0010 .