【问题标题】:Run and increment a counter in VHDL在 VHDL 中运行并增加一个计数器
【发布时间】:2013-05-13 14:41:17
【问题描述】:

我需要设计 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;

【问题讨论】:

标签: counter vhdl increment


【解决方案1】:

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

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

现在您可以将干净的信号输入到您的逻辑 - 您所拥有的是一个良好的开端,现在您需要一个信号,当 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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-15
    • 2016-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多