--伪随机序列(m序列)
library ieee;
use ieee.std_logic_1164.all;
entity wsj is
port(clk:in std_logic;
qout ut std_logic);
end wsj;
architecture behav of wsj is
component ddf
port(d,clk:in std_logic;
q ut std_logic);
end component;
signal tmp:std_logic_vector(0 to 4);
begin
--tmp(0)<=tmp(1) xor (not(tmp(4)or tmp(3) or tmp(2)));
tmp(0)<=not(tmp(1)xor tmp(4)); --防止进入全0循环后不能自启动,则反馈系数异或后再取反,避免全0信号。
g1:for i in 0 to 3 generate --把ddf看作已经生成的元件,然后
ddfx:ddf port map(tmp(i),clk,tmp(i+1)); --利用GENERATE来循环生成串行连接的4个D触发器。
end generate;
qout<=tmp(4);
end behav;
|