我是初学的,大家帮忙看看吧,谢谢了。
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
EN
tiTY ca2 IS
PORT (clk : IN std_logic;
Q1,Q2,Q3,Q4: OUT std_logic);
END ca2;
ARCHITECTURE behavioral OF ca2 IS
COMPONENT dff
PORT (
d,clk :IN STD_LOGIC;
q:OUT STD_LOGIC );
END COMPONENT;
SIGNAL data :STD_LOGIC_VECTOR (7 DOWNTO 0);
BEGIN
dffn_1: dff PORT MAP (data(0),clk,data(4));
dffn_2: dff PORT MAP (data(1),clk,data(5));
dffn_3: dff PORT MAP (data(2),clk,data(6));
dffn_4: dff PORT MAP (data(3),clk,data(7));
data(0) <= data(4) xor data(5);
data(1) <= data(4) xor data(6);
data(2) <= data(5) xor data(6) xor data(7);
data(3) <= data(6);
Q1 <= data(4);
Q2 <= data(5);
Q3 <= data(6);
Q4 <= data(7);
END behavioral;
我想做的是细胞自动机,产生伪随机序列的。就先写个4寄存器的试试。感觉初始信号都是0000,然后后面的就一直是0,该怎么解决?谢谢~
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
ENTITY ca3 IS
PORT (clk : IN std_logic;
Q1,Q2,Q3,Q4: OUT std_logic);
END ca3;
ARCHITECTURE behave OF ca3 IS
SIGNAL data :STD_LOGIC_VECTOR (7 DOWNTO 0);
BEGIN
data(0) <= 1;
cydff_inst:PROCESS (clk)
BEGIN
IF ( clk='1' AND clk'LAST_VALUE='0' AND clk'EVENT ) THEN
data(4) <=data(0);
data(5) <=data(1);
data(6) <=data(2);
data(7) <=data(3);
END IF;
data(0) <= data(4) xor data(5);
data(1) <= data(4) xor data(6);
data(2) <= data(5) xor data(6) xor data(7);
data(3) <= data(6);
Q1 <= data(4);
Q2 <= data(5);
Q3 <= data(6);
Q4 <= data(7);
END PROCESS;
END behave;
一周热门 更多>