我正在尝试验证四个按钮。当其中一个被推动时,我需要检查相应的 LED 是否亮起。所以,我做了代码,其中一个进程检查哪个按钮被按下,并将值与 LED 的值(亮与否)进行比较。当我想增加控制玩家命中(成功)数量的变量时,就会出现问题。
记住“acertos”是std_logic_vector(3 downto 0) 类型的信号
process(pb0,pb1,pb2,pb3)
variable erro_int : STD_LOGIC;
begin
if (clk_game = '0') then
erro_int:='0';
if rising_edge(pb0) then
if pb0 /= led(0) then
erro_int:='1';
end if;
elsif rising_edge(pb1) then
if pb1 /= led(1) then
erro_int:='1';
end if;
elsif rising_edge(pb2) then
if pb2 /= led(2) then
erro_int:='1';
end if;
elsif rising_edge(pb3) then
if pb3 /= led(3) then
erro_int:='1';
end if;
else
acertos <= acertos+1;
end if;
end if;
end process;