Guest User

Untitled

a guest
Sep 9th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.90 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.std_logic_unsigned.all;
  4. use IEEE.numeric_std.all;
  5.  
  6.  
  7. use work.filter_pkg.all;
  8.  
  9.      
  10.     entity lfsr is
  11.         generic (num_hash_bits : integer);
  12.     port (
  13.           clk : in std_logic;
  14.           random_num : out std_logic_vector (num_hash_bits-1 downto 0)   --output vector            
  15.         );
  16.     end lfsr;
  17.      
  18.     architecture Behavioral of lfsr is
  19.     begin
  20.    
  21.      process(clk)
  22.    
  23.      variable rand_temp : std_logic_vector(num_hash_bits-1 downto 0):=(num_hash_bits-1 => '1',others => '0');
  24.     variable temp : std_logic := '0';
  25.    
  26.      begin
  27.          if(rising_edge(clk)) then
  28.          temp := rand_temp(num_hash_bits-1) xor rand_temp(num_hash_bits-2);
  29.          rand_temp(num_hash_bits-1 downto 1) := rand_temp(num_hash_bits-2 downto 0);
  30.          rand_temp(0) := temp;
  31.          end if;
  32.       random_num <= rand_temp;
  33.     end process;
  34.  
  35.  
  36. end Behavioral;
Add Comment
Please, Sign In to add comment