0

我需要设计 VHDL 在七段显示器上运行计数器。三个输入是基于三个按钮的启动、停止和增量。Start 将启动计数器,并且在按下停止按钮之前它不会停止。我需要创建一个增量按钮,它只会加 1 一次。我只需要让增量按钮工作。

process(start, stop, inc, clk)
begin

if (clk'event and clk = '1') then
    if (rst = '1') then 
    run <= '0';
    end if;
     if(start = '1') then
           run <= '1';
     end if;
          if(stop = '1') then
           run <= '0';

     end if;
     end if;


    end process;
4

1 回答 1

0

首先将您的按钮与内部时钟同步 - 将每个按钮依次通过几个触发器。

然后您需要对按钮进行去抖动 - 一种方法是仅在输入引脚处于相同状态多个时钟周期后才传递来自输入引脚的信号。开关可能会弹跳数毫秒,因此请确保您计算足够长的时间来处理此问题。

现在你有干净的信号可以输入你的逻辑 - 你有一个好的开始,现在你需要一个信号,当inc按钮从“0”转换为“1”时,该信号会在单个时钟脉冲内变为高电平。然后可以使用您的开始按钮对该信号进行 ored,以启用计数器作为单个滴答声

例如

process(clk)
  variable last_inc := '0';
begin
  if rising_edge(clk) then
    do_increment <= '0';
    if last_inc = '0' and inc = '1' then
        do_increment <= '1';
    end if;
    last_inc := inc;
  end if;
end process;
于 2013-05-13T15:31:23.210 回答