📄 button_test.vhd
字号:
--** 按键(防抖动)控制
--文件名:button_test.vhd
--功 能:按键发声
--说 明:
-- 为了便于观察将obutton接在蜂鸣器的输入端,即按下按键后蜂鸣器发出蜂鸣声;
-- ibutton接在S3处;
-- ibutton的默认电平为"1",有效电平为"0";
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity button_test is
Port (clk : in std_logic; --50M的时钟频率;
ibutton : in std_logic; --按键输入;
obutton : out std_logic ); --经过防抖动处理过后的按键信号;
end button_test;
architecture Behavioral of button_test is
begin
process(clk,ibutton)
variable cnt : integer range 0 to 50000;
begin
if ibutton='1' then cnt:=0;obutton<='1';
elsif clk'event and clk='1' then cnt:=cnt+1;
if cnt<25000 then obutton<='0';
elsif cnt<50000 then obutton<='1';
else cnt:=0;obutton<='1';
end if;
end if;
end process;
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -