|
最近编了个很简单的滤波程序,但是在ModelSim仿真时出现了一点问题,希望大神们快快现身,帮小弟解决这个困扰了好长时间的问题,特此把程序和仿真结果附上。
--****************************************************************************
--此程序为滤波源程序。通过计数输入脉冲的宽度,来滤除杂散窄脉冲。并将滤波后的脉冲输出,双边沿滤波。滤除高低电平杂波宽度范围不同
--****************************************************************************
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity filter_unbalance is
port( delayu,u,clku: in std_logic; --delayu复位信号,clku为时钟信号,u为输入待滤波信号
fu: out std_logic);
end entity;
architecture behav of filter_unbalance is
constant N1:integer:=50;
constant N2:integer:=120;
signal countu1: integer range 0 to N1+1;
signal countu2: integer range 0 to N2+1;
signal fu1:std_logic;
begin
process(delayu,u,clku)
begin
if(delayu ='0')then
countu1<=0;
countu2<=0;
fu1<='0';
elsif(clku'event and clku='1') then
if(u ='0' and countu2<=N2)then
countu1<=0;
countu2<=countu2+1;
elsif(u ='1' and countu1<=N1)then
countu2<=0;
countu1<=countu1+1;
else
null;
end if;
if(countu2 >= N2)then
fu1<='0'; --当输入低电平宽度大于或等于N2个时钟周期时输出低电平
end if;
if(countu1 >= N1)then
fu1<='1'; --当输入高电平宽度大于或等于N1个时钟周期时输出高电平
end if;
end if;
end process;
fu<=fu1;
end behav;
--**************************************************************************** |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|