【发布时间】:2017-12-20 14:54:36
【问题描述】:
在经历了昨天和今天之后,我已经设法解决了一些问题,但我又陷入了困境。 在做计数器时,我放了一个循环,使其从 1 计数到 53,然后再次重置为零。当检查它是否正常工作时出现问题我启动了测试台并且信号根本没有更新。
-- Process incorporated in vhdl
entity semaforo is
Port ( sensor : in STD_LOGIC;
clk : in STD_LOGIC;
rst_n : in STD_LOGIC;
light_highway : out STD_LOGIC_VECTOR (2 downto 0);
light_farm : out STD_LOGIC_VECTOR (2 downto 0));
end semaforo;
architecture Behavioral of semaforo is
signal cuenta: std_logic_vector(6 downto 0):="0000000";
begin
flip_flop: process (clk, rst_n)
begin
if (rst_n='0') then
light_highway <="001";
light_farm <="100";
elsif (clk'event and clk='1') then
if (sensor='1') then
light_highway<="010";
end if;
end if;
end process;
contador : process (clk, rst_n)
begin
if rst_n = '0' then
cuenta <= (others => '0');
elsif rising_edge(clk) then
if sensor = '1' then
if cuenta < 53 then
cuenta <= cuenta + 1;
else
cuenta <= (others => '0');
end if; -- count/wrap
end if; -- clock enable
end if; -- async reset/clock
end process;
end Behavioral;
如果您删除 for 并简单地直接更新计数器(如果它有效),但我需要计数器从第一次传感器 = '1' 开始累加,并且一旦帐户启动它就不会停止(即使传感器信号),直到达到极限。 还附上了测试平台的截图。
【问题讨论】:
标签: vhdl