BARREL SHIFTER
A barrel shifter is a digital circuit that can shift a data word by a specified number of bits in one clock cycle. Shifts the input data in combinational manner It can be implemented as a sequence of multiplexers (mux.) or FET A common usage of a barrel shifter is in the hardware implementation of floating-point arithmetic.
PROGRAM library IEEE; use IEEE.STD_1164.all entity BARREL_SHIFTER is Generic (N: POSITIVE:= 4); Port( DATA:in STD_LOGIC_VECTOR(N-1 down to 0)); SELEKT : in INTEGER range 0 to N-1; BARR_OUT : out STD_LOGIC_VECTOR ( N-1 down to 0)); end BARREL_SHIFTER; architechture FOR_LOOP_STYLE of BARREL_SHIFTER is begin process(SELEKT,DATA) variable VAR_BUF: STD_LOGIC_VECTOR( N-1 down to 0)); VAR_BUF:=DATA;
for K in 1 to SELEKT LOOP VAR_BUF := VAR_BUF(N-2 down to 0)& VAR_BUF(N-1); end loop; BARR_OUT<= VAR_BUF; end process; end FOR_LOOP_STYLE; architecture CONCURRENT_STYLE of BARREL_SHIFTER is begin BARRE_OUT<= DATA(N-1- SELEKT down to 0)& DATA(N-1 down to N- SELEKT) When SELEKT> 0; else DATA; end CONCURRENT _STYLE;