【发布时间】:2014-04-01 01:51:30
【问题描述】:
我正在尝试设计一个交通信号灯控制器,为此我需要许多不同的计时器。因此,我用 VHDL 设计了这个通用计时器:
library IEEE;
use IEEE.std_logic_1164.all, IEEE.numeric_std.all;
entity timer is
generic (n: NATURAL :=20);
port (clk, reset : in std_logic;
count : buffer std_logic);
end entity timer;
architecture behavioural of timer is
begin
o0: process (clk, reset) IS
variable cnt : unsigned (n-1 downto 0);
begin
if reset = '0' then
cnt := (others => '0');
elsif rising_edge(clk) then
cnt := cnt + 1;
end if;
if cnt = n-1 then
count <= '1';
else
count <= '0';
end if;
end process;
end architecture behavioural;
但是,当我运行定时器时,它输出 0 并且永远不会改变(我通过将计数映射到 Altera MAX II EMP240T100C5 上的 LED 对此进行了测试),因此我的控制器中的状态没有进展。我不知道为什么会这样?
【问题讨论】:
-
如果您按照 David 的建议修复此问题并按照您上面的建议映射到 LED,那么 LED 将仅每 2**n-1 个时钟点亮 1 个时钟,您不太可能会看到带领。它会如此短暂地开启,如果有的话,它的强度将非常低。
-
@JimLewis 谢谢,有没有办法让它在 1 的值上直到它被重置?我真的需要在计数到指定的数字后才能停止。
标签: generics timer counter vhdl intel-fpga