URL
https://opencores.org/ocsvn/lfsr_randgen/lfsr_randgen/trunk
[/] [lfsr_randgen/] [trunk/] [lfsr.vhd] - Diff between revs 2 and 3
Show entire file |
Details |
Blame |
View Log
Rev 2 |
Rev 3 |
Line 49... |
Line 49... |
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_unsigned.all;
|
library work;
|
library work;
|
use work.lfsr_pkg.ALL;
|
use work.lfsr_pkg.ALL;
|
|
|
entity lfsr is
|
entity lfsr is
|
generic (width : integer := 32);
|
generic (width : integer := 4);
|
port (clk : in std_logic;
|
port (clk : in std_logic;
|
set_seed : in std_logic;
|
set_seed : in std_logic;
|
out_enable : in std_logic;
|
|
seed : in std_logic_vector(width-1 downto 0);
|
seed : in std_logic_vector(width-1 downto 0);
|
rand_out : out std_logic_vector(width-1 downto 0)
|
rand_out : out std_logic_vector(width-1 downto 0)
|
);
|
);
|
end lfsr;
|
end lfsr;
|
|
|
architecture Behavioral of lfsr is
|
architecture Behavioral of lfsr is
|
|
|
begin
|
begin
|
|
|
process(clk,set_seed,out_enable,seed)
|
process(clk)
|
|
|
variable rand_temp : std_logic_vector (width-1 downto 0):=(0 => '1',others => '0');
|
variable rand_temp : std_logic_vector (width-1 downto 0):=(0 => '1',others => '0');
|
variable temp : std_logic := '0';
|
variable temp : std_logic := '0';
|
|
|
begin
|
begin
|
|
|
|
if(rising_edge(clk)) then
|
|
|
if(set_seed = '1') then
|
if(set_seed = '1') then
|
rand_temp := seed;
|
rand_temp := seed;
|
elsif(rising_edge(clk)) then
|
end if;
|
|
|
temp := xor_gates(rand_temp);
|
temp := xor_gates(rand_temp);
|
rand_temp(width-1 downto 1) := rand_temp(width-2 downto 0);
|
rand_temp(width-1 downto 1) := rand_temp(width-2 downto 0);
|
rand_temp(0) := temp;
|
rand_temp(0) := temp;
|
end if;
|
|
|
|
if(out_enable ='1') then
|
|
rand_out <= rand_temp;
|
|
else
|
|
rand_out <= (others => '0');
|
|
end if;
|
end if;
|
|
rand_out <= rand_temp;
|
|
|
end process;
|
end process;
|
|
|
end Behavioral;
|
end Behavioral;
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.