vhdl按键计数器
该如何实现?消抖部分一坐处理,这里不用考虑。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
entity VHDL is
generic
(
DATA_WIDTH : natural := 8
);
port
(
b1 : in std_logic;
b2 : in std_logic;
result : out std_logic_vector((DATA_WIDTH-1) downto 0)
);
end entity;
architecture rtl of VHDL is
signal result_l :std_logic_vector((DATA_WIDTH-1) downto 0);
begin
process(b1,b2)
begin
if (b1='1') then
result_l<=result_l+'1';
elsif (b2='1') then
result_l <=result_l-'1';
end if;
end process;
result<=result_l;
end rtl;
没有验证,只是使用quartus ii10.1编译综合了一下,没有问题,很简单的功能,应该没问题!
我试了,貌似检测不到上升沿。
把2楼的改成同步时序就可以了
if clk'event and clk='1' then
if (b1='1') then
result_l<=result_l+'1';
elsif (b2='1') then
result_l <=result_l-'1';
end if;
end if
把2楼的改成同步时序就可以了
if clk'event and clk='1' then
if (b1='1') then
result_l<=result_l+'1';
elsif (b2='1') then
result_l <=result_l-'1';
end if;
end if
5楼对的,在输入端口添加clk和reset后,在if (b1='1') then 前面还要添加复位信号控制。
