Description

Barrel Shifter

Design a hardware module that performs variable bit shifting. The module should support both left and right shifts, as well as rotation operations. When rotate is false, vacant bits are filled with zeros. When rotate is true, bits shifted out wrap around to the other end.

Example: For 8-bit data=0b10110001, shift_amount=3, direction=1 (left), rotate=false, the output should be 0b10001000.

Input

data

32-bit Unsigned Integer
Data to shift.

shift_amount

5-bit Unsigned Integer
Shift amount (0-31).

direction

1-bit Unsigned Integer
0=right, 1=left.

rotate

1-bit Unsigned Integer
0=shift, 1=rotate.

Output

32-bit Unsigned Integer
Shifted result.