【发布时间】:2023-03-09 06:24:01
【问题描述】:
我有一个从“000”向上计数的 3 位计数器。每次达到“101”时,我都希望 o_en 信号为高电平。
我有以下 VHDL 文件。
不幸的是,行为不同。
o_en 信号为 HIGH,当达到“110”时(延迟一个时钟周期)。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity special_counter is
port(
i_clk : in std_logic;
i_en : in std_logic;
i_rst : in std_logic;
o_data : out std_logic_vector(2 downto 0);
o_en : out std_logic
);
end entity;
architecture behave of special_counter is
signal w_data : std_logic_vector(2 downto 0);
signal w_en : std_logic;
begin
process(i_clk, i_rst) begin
if i_rst = '1' then
w_data <= "000";
elsif rising_edge(i_clk) then
if i_en = '1' then
if w_data = "101" then
w_en <= '1';
w_data <= w_data + 1;
else
w_en <= '0';
w_data <= w_data + 1;
end if;
end if;
end if;
end process;
o_data <= w_data;
o_en <= w_en;
end architecture;
如何更改我的程序以执行预期的行为?
【问题讨论】:
标签: if-statement vhdl counter