Advertisement
crsandu

Untitled

May 20th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.53 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3.  
  4. entity SHIFT_BARREL is
  5.     port(
  6.     DATA_in: in std_logic_vector(7 downto 0); -- insert DATA to register  
  7.    
  8.     SEL: in std_logic; -- stanga sau dreapta
  9.     SHIFT_NR: in std_logic_vector(1 downto 0);
  10.    
  11.     DATA_out: out std_logic_vector(7 downto 0));
  12. end SHIFT_BARREL;
  13.  
  14. architecture SHIFT_arch of SHIFT_BARREL is
  15.     signal DATA_1: std_logic_vector(7 downto 0);
  16.     signal DATA_2: std_logic_vector(7 downto 0);
  17. begin
  18.     SHIFT_LEFT: process(DATA_in, SHIFT_NR)
  19.         variable temp_1: std_logic_vector(7 downto 0);
  20.         variable temp_2: std_logic_vector(7 downto 0);
  21.     begin  
  22.         case SHIFT_NR(0) is
  23.             when '1' => temp_1 := DATA_in(6 downto 0) & '0';
  24.             when '0' => temp_1 := DATA_in;
  25.             when others => null;
  26.         end case;
  27.        
  28.         case SHIFT_NR(1) is
  29.             when '1' => temp_2 := temp_1(5 downto 0) & "00";
  30.             when '0' => temp_2 := temp_1;
  31.             when others => null;
  32.         end case;
  33.         DATA_1 <= temp_2;
  34.     end process SHIFT_LEFT;
  35.    
  36.     SHIFT_RIGHT: process(DATA_in, SHIFT_NR)
  37.         variable temp_1: std_logic_vector(7 downto 0);
  38.         variable temp_2: std_logic_vector(7 downto 0);
  39.     begin  
  40.         case SHIFT_NR(0) is
  41.             when '1' => temp_1 :=  '0' & DATA_in(7 downto 1);
  42.             when '0' => temp_1 := DATA_in;
  43.             when others => null;
  44.         end case;
  45.        
  46.         case SHIFT_NR(1) is
  47.             when '1' => temp_2 := "00" & temp_1(7 downto 2);
  48.             when '0' => temp_2 := temp_1;
  49.             when others => null;
  50.         end case;
  51.         DATA_2 <= temp_2;
  52.     end process SHIFT_RIGHT;
  53.    
  54.     WITH SEL SELECT
  55.         DATA_out <= DATA_1 when '0',
  56.                     DATA_2 when others;
  57. end SHIFT_arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement