我想用 Quartus II 创建一个项目,它的功能是根据代码启用三个不同的 LED。当您输入代码时,第一个 LED 将亮起。根据输入的代码,第二个或第三个将打开。我的问题是,当代码正确时,我希望第二个 LED 亮 3 秒,如果不正确,第三个 LED 将在 2 秒内亮。如果你能帮助我,那就太好了。
谢谢!
注:led 被声明为逻辑向量,代码的编号被声明为从 0 到 7 的中断。
代码:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
ENTITY programa IS
PORT
(
interrup : in Std_Logic_Vector (7 downto 0);
clk, rst: in Std_Logic;
led : out Std_Logic_Vector (2 downto 0)
);
END programa;
ARCHITECTURE arch_programa OF programa IS
    type state is (zero, one, two, three, four, five, six);
    signal pr_state, nx_state : state;
    signal A : Std_Logic_Vector (3 downto 0);
BEGIN
    process(interrup, pr_state)
    begin
        case pr_state is
            when zero =>
                led <= "100";
                A(0) <= interrup(7);
                nx_state <= one;
            when one =>
                led <= "100";
                A(1) <= interrup(6);
                nx_state <= two;
            when two =>
                led <= "100";
                A(2) <= interrup(5);
                nx_state <= three;
            when three =>
                led <= "100";
                A(3) <= interrup(3);
                nx_state <= four;
            when four =>
                led <= "100";
                if(A = "1111") then nx_state <= five;
                else nx_state <= six;
                end if;
            when five =>
                led <= "010";
                nx_state <=zero;
            when six =>
                led <= "001";
                nx_state <=zero;
            end case;
    end process;
    process(rst,clk)
    begin
        if(rst='1') then
            pr_state <= zero;
        elsif (clk'event and clk = '1') then
            pr_state <= nx_state;
        end if;         
    end process;
end arch_programa;