您的位置】:知源论文网 > 理工类论文 > 交通运输 > 正文阅读资讯:基于FPGA的四阶IIR数字滤波器

基于FPGA的四阶IIR数字滤波器

[作者:5189lw| 打印 | 关闭 ]

entity smultadd1 is

port (clk_regbt,clk_reg: in std_logic:

x0,x1,x2,y0,y1:in std_logic_vector(9 downto 0);

yout: out std_logic_vector(9 downto 0));

end smultadd1;

architecture behav of smultadd1 is

signal tan,tbn,tp2n:std_logic;

signal cnt: std_logic_vector(2 downto 0);

signal ta,tb,taa,tbb:std_logic_vector(8 downto 0);

signal tmpa,tmpb:std_logic_vector(9 downto 0);

signal tp:std_logic_vector(18 downto 0);

signal tpp:std_logic_vector,22 downto 0);

signal ytmp,p:std_logic_vector(23 downto 0);

constant a0:std_logic_vector(9 downto 0:=“0000011100”

(其余常数说明略)

begin

tp2n<=tan xor tbn;--求补后送阵列乘法器

taa<=not ta +‘1’ when (tan=‘1’) else ta;

tbb<=not tb +‘1’ when (tbn=‘1’) else tb;

tpp<=‘1’&‘1’&‘1’&‘1’& not tp +‘1’ when(tp2n=‘1’) else tp;

tmpa<=a0 when cnt=0 else

a1 when cnt=1 else

a2 when cnt=2 else

b0 when cnt=3 else

b1 when cnt=4 else (others=>‘0’);

tmpb<=x0 when cnt=0 else

x1 when cnt=1 else

x2 when cnt=2 else

y0 when cnt=3 else

y1 when cnt=4 else (others=>‘0’);

ta<=tmpa(8 downto 0);tb<=tmpb(8 downto 0);

tan<=tmpa(9);tbn<=tmpb(9);

tp<=taa*tbb;

p<=(others=>‘0’) when (tmpb=“0000000000”) else

tp2n & tpp;

process (clk_reg,clk_regbt)

begin

if clk_reg=‘1’ then cnt<=“000”;ytmp<=(others=>‘0’);

elsif (clk_regbt’event and clk_regbt=‘1’) then

if cnt<5 then cnt<=cnt+1;ytmp<=ytmp+p;

elsif (cnt=5) then

if ytmp(7)=‘1’ then

yout(8 downto 0)<=ytmp(16 downto 8)+1;

yout(9)<=ytmp(23);

else yout(8 downto 0)<=ytmp(16 downto 8);

yout(9)<=ytmp(23); end if;

end if;

end if;

end process;

end behav;

IIR2模块的输出数据采用将补码最高符号位直接取反转换为移码后,就可以送到DAC7520实现双极性信号输出。

本文采用一个折中的方法实现,即乘加单元(MAC)的乘法器采用阵列乘法器,而不使用串行乘法器,以提高运算速度。需要注意的是,MAX+plusⅡ的LPM库中乘法运算为无符号数的阵列乘法,所以使用时需要先将两个补码乘数转换为无符号数相乘后,再将乘积转换为补码乘积输出。每个二阶节完成一次运算共需要6个时钟周期,而且需采用各自独立的MAC实现两级流水线结构,即每个数据经过两个二阶节输出只需要6个时钟周期。

2.1 系统原理框图

系统原理框图如图2所示,模拟信号经过TLC5510转换为00H~FFH的二进制数后,送入四阶IIR低通滤波器,处理后输出10位二进制数送AD7520得到双极性的模拟电压输出。

图3 四阶IIR滤波器的顶层原理图

3 系统性能测试

Tags: