集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2785|回复: 2

怎么用VHDL编写去抖小程序

[复制链接]
小泡泡 发表于 2010-4-20 15:54:28 | 显示全部楼层 |阅读模式
本帖最后由 fpgaw 于 2010-10-29 09:42 编辑

怎么用VHDL编写去抖小程序,用于按键消除抖动的,防止误判
蓝余 发表于 2011-7-17 16:39:54 | 显示全部楼层
这其实是用一个计数器来判断输入的脉冲的宽度,如果宽度大于3个脉冲,则认为这次输入有效,输出一个脉冲宽度的脉冲来替代输入信号,否则认为该次输入无效!

library ieee;
use ieee.std_logic_1164.all;

entity xiaodou is
port(clk,input: in std_logic;
output: out std_logic);
end xiaodou;

architecture xiaodou_arc of xiaodou is
signal cp:std_logic;
signal count:integer range 0 to 3;
begin
process(clk)
begin
if(clk'event and clk='1') then 检测上升沿
if(input='1')then  如果有输入信号
if(count=3)then count<=count; 当计数达到3时,保持计数值不变
else count<=count+1;    当其小于3时,进行加1处理
end if;
if(count=2)then cp<='1';  如果计数达到2,cp置1
else cp<='0';             其余情况全部为0
end if;  
else count<=0;            如果计数出现非法状况,进行清零复位
end if;
end if;
output<=cp;              信号输出
end process;
end xiaodou_arc
liujilei311 发表于 2011-7-17 21:28:19 | 显示全部楼层
很实用,顶蓝余大哥!!!!
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-6-23 21:03 , Processed in 0.071919 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表