我是初学的,大家帮忙看看吧,谢谢了。
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;
楼主的问题可能是寄存器或线网被综合器给优化掉了。
如果是线网在SIGNAL data :STD_LOGIC_VECTOR (7 DOWNTO 0);后加上下面这两句:
attribute keep : boolean;
attribute keep of data : signal is true ;
如果楼主是想生成8位的寄存器,代码里只做了四位的dff调用,肯定是不会生成8位的。
同时为了防止综合器优化掉寄存器可以加上下面两句:
attribute preserve : boolean;
attribute preserve of data : signal is true ;
我想做的是细胞自动机,产生伪随机序列的。就先写个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;
一周热门 更多>