【发布时间】:2017-05-20 15:34:57
【问题描述】:
我是 VHDL 新手,我对 FSM 的实现有疑问。 我想要图片中显示的行为(我用 AHDL 实现了相同的 FSM)。当我在 VHDL 中实现它时,我有一个不同的复位行为:如果它检测到 reset=1 并且同时有一个上升沿,则 FSM 不会继续,但它会继续将 PS 置于 S0。 我知道问题是如果... elsif (它检测到第一个条件并且我想没有进入第二个条件)。 我尝试了许多不同的方式,但仍然无法正常工作,并且在第一个上升沿之后输出也保持在 00。
LIBRARY ieee; -- Bibliotheksvereinbarung
USE ieee.std_logic_1164.all;
ENTITY sumconvol IS -- Schaltungssymbol
PORT
(
x : IN STD_LOGIC; --input of 1st FF
clk : IN STD_LOGIC; --clock of all the 3 FFs
clrn : IN STD_LOGIC;
y : OUT STD_LOGIC_VECTOR (1 downto 0) --vector of output data
);
END sumconvol;
ARCHITECTURE a OF sumconvol IS -- Creation of architecture
--SIGNAL output_tmp : STD_LOGIC_VECTOR (1 downto 0); -- temporary variables (e.g. input/output between FFs)7
TYPE state_type IS (S0,S1,S2,S3);
SIGNAL NS,PS : state_type;
SIGNAL stato : STD_LOGIC;
BEGIN
sync_proc: PROCESS (clk,clrn)
BEGIN
if ((clrn='1')) THEN
PS<=S0;
y <= "00";
elsif (rising_edge(clk)) then
PS <= NS;
CASE PS IS
when S0 =>
if ((x='0'))then
NS <= S0;
y <= "00";
else
NS <= S1;
y <= "11";
end if;
when S1 =>
if (x='0') then
NS <= S2;
y<="10";
else
NS <= S3;
y <= "01";
end if;
when S2 =>
if (x='0') then
NS <= S0;
y <="11";
else
NS <= S1;
y <= "00";
end if;
when S3 =>
if (x='0') then
NS <= S2;
y <="01";
else
NS <= S3;
y <= "10";
end if;
end case;
end if;
end process sync_proc;
END a;
【问题讨论】:
-
clrn表示低电平有效,但您将其用作高电平...您只是感到困惑吗? -
啊,是的,我把信号命名错了……它是高电平有效
-
请出示您的测试台。
标签: vhdl hdl state-machine quartus