<< - a binary shift left Offset 1 8 seats.
4'b0001 << 1 => 4'b0010
>> - binary right shift, adding 0 to the MSB.
>>> - a shift from fixing that supports MSB value if left input signed.
4'sb1011 >> 1 => 0101 4'sb1011 >>> 1 => 1101
Three ways to specify the left operand:
module shift; logic [3:0] test1 = 4'b1000; logic signed [3:0] test2 = 4'b1000; initial begin $display("%b", $signed(test1) >>> 1 ); //Explicitly set as signed $display("%b", test2 >>> 1 ); //Declared as signed type $display("%b", 4'sb1000 >>> 1 ); //Signed constant $finish; end endmodule $ signed (test1) >>> module shift; logic [3:0] test1 = 4'b1000; logic signed [3:0] test2 = 4'b1000; initial begin $display("%b", $signed(test1) >>> 1 ); //Explicitly set as signed $display("%b", test2 >>> 1 ); //Declared as signed type $display("%b", 4'sb1000 >>> 1 ); //Signed constant $finish; end endmodule 4'sb1000 >>> module shift; logic [3:0] test1 = 4'b1000; logic signed [3:0] test2 = 4'b1000; initial begin $display("%b", $signed(test1) >>> 1 ); //Explicitly set as signed $display("%b", test2 >>> 1 ); //Declared as signed type $display("%b", 4'sb1000 >>> 1 ); //Signed constant $finish; end endmodule
source share