Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.88 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3.  
  4. entity shiftregister is
  5.  
  6. port(
  7.     load: in std_logic_vector(3 downto 0);
  8.     input: in std_logic_vector(3 downto 0);
  9.     output: out std_logic_vector(3 downto 0);
  10.     q: out std_logic;
  11.     ld: in std_logic;
  12.     clr:in std_logic;
  13.     clk:in std_logic
  14.     );
  15.    
  16.     end entity shiftregister;
  17.    
  18.    
  19.     Architecture shift of shiftregister is
  20.     signal shift: std_logic_vector(3 downto 0);
  21.     begin
  22.     process(clk)
  23.     begin      
  24.     if (clk'Event and CLK= '1') then
  25.         if (clr='1') then --clear
  26.             shift <= "0000";
  27.         elsif(ld='1') then --load input from switches into shift register if load is asserted
  28.             shift<= load;
  29.         else
  30.             shift <= input;
  31.             shift <= '0' & shift(3 downto 1);-- concats a O to MSB and takes first 3 bits of of shift
  32.             end if;
  33.         end if;
  34.     end process;
  35.             q<=shift(0);-- Assigns LSB of shift to q
  36.             output<=shift;
  37.     end architecture shift;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement