Advertisement
Roniere

Shift Register Advanced

Aug 26th, 2021
2,402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.33 KB | None | 0 0
  1. library IEEE;
  2.     use IEEE.std_logic_1164.all;
  3.     use IEEE.numeric_std.all;
  4.  
  5. entity Exemplo_3 is
  6.     port(
  7.         shift_register_in  : in std_logic;
  8.         parallel_data      : in std_logic_vector(1023 downto 0);
  9.         clk                : in std_logic;
  10.         rst                : in std_logic;
  11.         en                 : in std_logic;
  12.         direction          : in std_logic;
  13.         force_0            : in std_logic;
  14.         force_1            : in std_logic;
  15.         parallel_load      : in std_logic;
  16.        
  17.         shift_register_out : out std_logic
  18.     );
  19. end Exemplo_3;
  20.  
  21.  
  22. architecture behavioral of Exemplo_3 is
  23.     signal shift_register : std_logic_vector(1023 downto 0);
  24.     signal data_selected  : std_logic;
  25. begin
  26.     data_selected <= '0' when force_0 = '1' else
  27.              '1' when force_1 = '1' else
  28.              shift_register_in;
  29.                
  30.     process(clk, rst)
  31.     begin
  32.         if rst = '1' then
  33.             shift_register <= (others => '0');
  34.         elsif clk'event and clk = '1' then
  35.             if parallel_load = '1' then
  36.                 shift_register <= parallel_data;
  37.             elsif en = '1' then
  38.                 if direction = '0' then
  39.                     shift_register <= data_selected & shift_register ( 1023 downto 1);
  40.                 else
  41.                     shift_register <= shift_register (1022 downto 0) & data_selected;
  42.                 end if;
  43.             end if;
  44.         end if;
  45.     end process;
  46.  
  47.     shift_register_out <= shift_register(0) when direction = '0' else
  48.                           shift_register(1023);
  49. end behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement