当num更改时,计数器应该增加1,因为num在灵敏度列表中。但模拟说没有。我想知道我的代码有什么问题。 在Quartus 9.0上
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY tmp IS
PORT (
num : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
counter : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
clr : IN STD_LOGIC
);
END tmp;
ARCHITECTURE ar OF tmp IS
SIGNAL c : STD_LOGIC_VECTOR(3 DOWNTO 0);
BEGIN
PROCESS(num, clr)
BEGIN
IF clr'EVENT AND clr = '1' THEN
c <= "0000";
END IF;
c <= c + 1;
END PROCESS;
counter <= c;
END;
答案 0 :(得分:0)
如果您直接使用计数器而不是C,它可能会对您有所帮助。 试试这个
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY tmp IS
PORT (
num : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
counter : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
clr : IN STD_LOGIC
);
END tmp;
ARCHITECTURE ar OF tmp IS
BEGIN
PROCESS(num, clr)
BEGIN
IF clr'EVENT AND clr = '1' THEN
counter <= "0000";
END IF;
counter <= counter + 1;
END PROCESS;
END;
异步体的代码将一起运行,因此计数器将保持与以前相同