Concept Flow - Shift operators
Input Vector
Select Shift Type
Shift Left
Shift Bits by N Positions
Output Shifted Vector
The input vector is shifted left or right by a specified number of positions, producing a new shifted vector as output.
signal data_in : std_logic_vector(7 downto 0) := "10110011"; signal data_out : std_logic_vector(7 downto 0); -- Shift left by 2 data_out <= data_in sll 2;
| Step | Operation | Input Vector | Shift Amount | Result Vector | Explanation |
|---|---|---|---|---|---|
| 1 | Initial value | 10110011 | N/A | 10110011 | Starting vector before shift |
| 2 | Shift left by 2 | 10110011 | 2 | 11001100 | Bits shifted left 2 places, zeros fill right |
| 3 | Shift right by 3 | 10110011 | 3 | 00010110 | Bits shifted right 3 places, zeros fill left |
| 4 | Shift left by 0 | 10110011 | 0 | 10110011 | Shift by zero leaves vector unchanged |
| 5 | Shift right by 8 | 10110011 | 8 | 00000000 | Shift by full length results in all zeros |
| Variable | Start | After Shift Left 2 | After Shift Right 3 | After Shift Left 0 | After Shift Right 8 |
|---|---|---|---|---|---|
| data_in | 10110011 | 10110011 | 10110011 | 10110011 | 10110011 |
| data_out | undefined | 11001100 | 00010110 | 10110011 | 00000000 |
Shift operators in VHDL move bits left (sll) or right (srl). Bits shifted out are lost; zeros fill the empty positions. Syntax: result <= input_vector sll n; or srl n; Shift amount n must be integer. Shifting by zero leaves vector unchanged. Shifting by vector length results in all zeros.