按键去抖动按键去抖动
library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity key_buffer is
port(a,clk:in std_logic;
y:buffer std_logic_vector(3 downto 0));
end key_buffer;
architecture beh of key_buffer is type state i...
按键去抖动
library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity key_buffer is
port(a,clk:in std_logic;
y:buffer std_logic_vector(3 downto 0));
end key_buffer;
architecture beh of key_buffer is type state is (s0,s1,s2); signal s:state;
signal f:std_logic;
signal t:std_logic_vector(18 downto 0);
signal p:std_logic;
begin
process(clk,t)
begin
if clk'event and clk='1' then
if t="1000000000000000000" then
t<="0000000000000000000";
else
t<=t+1;
end if;
end if;
end process;
p<='1' when t>"0100000000000000000" and t<"1000000000000000001" else
'0';
process(p)
begin
if(p'event and p='1') then case s is
when s0=> if (a='1') then
s<=s0;
else
s<=s1;
end if;
when s1=> if (a='0') then
s<=s2;
else
s<=s0;
end if;
when s2=> s<=s0;
end case;
end if;
end process;
f<='1' when s=s2 else
'0';
process(f)
begin
if(f'event and f='0') then
y<=y+1;
end if;
end process;
end beh;
本文档为【按键去抖动】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。