VHDL产生伪随机数
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Library IEEE ;
use IEEE.std_logic_1164.all ;
use IEEE.std_logic_arith.all ;
entity lfsr is
generic (data_width : natural := 8 );
port (
clk : in std_logic ;
reset : in std_logic ;
data_out : out UNSIGNED(data_width - 1 downto 0)
);
end lfsr ;
architecture rtl of lfsr is
signal feedback : std_logic ;
signal lfsr_reg : UNSIGNED(data_width - 1 downto 0) ; begin
feedback <= lfsr_reg(7) xor lfsr_reg(0) ;
latch_it : process(clk,reset)
begin
if (reset = '1') then
lfsr_reg <= (others => '0') ;
elsif (clk = '1' and clk'event) then
lfsr_reg <= lfsr_reg(lfsr_reg'high - 1 downto 0) & feedback ;
end if;
end process ;
data_out <= lfsr_reg ;
end RTL ;
Reference URL:/eda/edasrc/6153.html