Home of RF and Wireless Vendors and Resources

One Stop For Your RF and Wireless Need

Barrel Shifter VHDL code | Barrel Shifter test bench in vhdl

This page describes Barrel Shifter VHDL code. It mentions Barrel Shifter test bench in VHDL. The Simulated output and synthesized output of Barrel Shifter VHDL code using ModelSIM tool and Leonardo tool are also shown.

The functions of Barrel Shifter are as follows.
• It rotates or shifts the input data
• It rotates the data by specified number bits in combinational manner.

Barrel Shifter VHDL code

--Develop a VHDL model for a Barrel shifter that rotates
--the input data by the specified number of bits.
library ieee;
use ieee.std_logic_1164.all;
entity Barrel is
port (clk,reset,load :in std_logic;
data_in:in std_logic_vector (7 downto 0);
data_out:out std_logic_vector (7 downto 0));
end Barrel;
architecture Barrel of Barrel is
begin
process (reset,clk,data_in)
variable d: std_logic_vector (7 downto 0);
begin
if (reset = '0') then
d:=(others => '0');
elsif (clk'event and clk = '1') then
if (load ='1') then
d:=data_in;
else
d:= d(0) & d(7 downto 1) ;
end if;
end if;
data_out<= d;
end process;
end Barrel;


Barrel Shifter test bench in VHDL

--test bench for barrel shifter
library ieee;
use ieee.std_logic_1164.all;
entity tb_Barrel is
end tb_Barrel;
architecture tb_Barrel of tb_Barrel is
component Barrel
port (clk,reset,load :in std_logic;
data_in:in std_logic_vector (7 downto 0);
data_out:out std_logic_vector (7 downto 0));
end component;
signal clk,res,load : std_logic;
signal d_in,d_out : std_logic_vector (7 downto 0);
begin
br: Barrel port map (clk,res,load,d_in,d_out);
process
begin
res <= '1'; load <= '1';
wait for 5 ns;

load <= '1';
clk<='0';
d_in<="11111101";
wait for 5 ns;
clk<='1';
d_in<="11111111";
wait for 5 ns;
res <= '1';
d_in <= "01100101";
load <= '1';
wait for 5 ns;
load <= '0';
wait;
end process;
end tb_Barrel;


Simulated output using ModelSIM tool

Barrel Shifter simulated output

The figure-1 above depicts simulated output of Barrel Shifter obtained using ModelSim.

Synthesized output using Leonardo Spectrum Tool

Barrel Shifter synthesized output

The figure-2 above depicts synthesized output of Barrel Shifter obtained using Leonardo Spectrum Tool.


USEFUL LINKS to VHDL CODES

Refer following as well as links mentioned on left side panel for useful VHDL codes.
D Flipflop
T Flipflop
Read Write RAM
4X1 MUX
4 bit binary counter
Radix4 Butterfly
16QAM Modulation
2bit Parallel to serial

RF and Wireless tutorials

WLAN  802.11ac  802.11ad  wimax  Zigbee  z-wave  GSM  LTE  UMTS  Bluetooth  UWB  IoT  satellite  Antenna  RADAR 


Share this page

Translate this page