微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > 实现按键去抖功能,中间定义的过程能否实现延时功能啊

实现按键去抖功能,中间定义的过程能否实现延时功能啊

时间:10-02 整理:3721RD 点击:
library ieee;
use ieee.std_logic_1164.all;
--主体
entity exp5 is
port
        (
                clc_sys,input : in std_logic;
                output : out std_logic
        );
end exp5;
-- 结构体
architecture qudou of exp5 is
   signal out_signal: std_logic;
        --延时过程
        procedure yanshi(constant n:in integer)is
        variable i:integer:=0;
        begin  
          if clc_sys'event and clc_sys='1' then
            i:=i+1;
          end if;
          if i=n then
            return;
          end if;
   end procedure yanshi;
        --主进程
begin
        process(input)
        begin
          if input'event and input='0' then  
            yanshi(1000000);
          if input='0' then
            out_signal<=not out_signal;
            output<=out_signal;
          end if;
          end if;
        end process;
end qudou;

感觉不行吧……感觉procedure和function主要是用来设计组合逻辑,好像主要针对constant吧……延时计数应该使用时序逻辑……网上有很多VHDL消抖程序,可以查一下!



在网上找到了去抖的程序,但是如果想写一个供调用的延时子程序,应该用什么写呢。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top