基于FPGA的FIR低通滤波器verilog开发,包含testbench测试程序,输入噪声信号使用MATLAB模拟产生

1.算法仿真效果

VIVADO2019.2/matlab2022a仿真结果如下:

 

运行matlab

 

 

 

 matlab得到的数据文件保存到FPGAproject_13.sim\sim_1\behav\xsim路径,测试仿真时,可以自动调用matlab任意产生的测试数据。

 

 

 

rtl:

 

 

 

2.算法涉及理论知识概要

         FIR(Finite Impulse Response)滤波器:有限长单位冲激响应滤波器,又称为非递归型滤波器,是数字信号处理系统中最基本的元件,它可以在保证任意幅频特性的同时具有严格的线性相频特性,同时其单位抽样响应是有限长的,因而滤波器是稳定的系统。因此,FIR滤波器在通信、图像处理、模式识别等领域都有着广泛的应用。

        在进入FIR滤波器前,首先要将信号通过A/D器件进行模数转换,把模拟信号转化为数字信号;为了使信号处理能够不发生失真,信号的采样速度必须满足香农采样定理,一般取信号频率上限的4-5倍做为采样频率;一般可用速度较高的逐次逼进式A/D转换器,不论采用乘累加方法还是分布式算法设计FIR滤波器,滤波器输出的数据都是一串序列,要使它能直观地反应出来,还需经过数模转换,因此由FPGA构成的FIR滤波器的输出须外接D/A模块。FPGA有着规整的内部逻辑阵列和丰富的连线资源,特别适合于数字信号处理任务,相对于串行运算为主导的通用DSP芯片来说,其并行性和可扩展性更好,利用FPGA乘累加的快速算法,可以设计出高速的FIR数字滤波器。

(1) 系统的单位冲激响应h (n)在有限个n值处不为零

(2) 系统函数H(z)|z|>0处收敛,极点全部在z = 0处(因果系统)

(3) 结构上主要是非递归结构,没有输出到输入的反馈,但有些结构中(例如频率抽样结构)也包含有反馈的递归部分。

FIR滤波器的单位冲激响应h (n)为一个N点序列,0 n N 1,则滤波器的系统函数为

H(z)=h(n)*z^-k

就是说,它有(N1)阶极点在z = 0处,有(N1)个零点位于有限z平面的任何位置。

 

 

3.Verilog核心程序

 

reg[15:0]delay_pipeline[0:8]; 
reg[26:0]sum;						 
 
reg[23:0]product[0:8]; 
 
always@(posedge clk or negedge rst_n) begin
 
	if(!rst_n) begin
	
		delay_pipeline[0] <= 0;
		delay_pipeline[1] <= 0;
		delay_pipeline[2] <= 0;
		delay_pipeline[3] <= 0;
		delay_pipeline[4] <= 0;
		delay_pipeline[5] <= 0;
		delay_pipeline[6] <= 0;
		delay_pipeline[7] <= 0;
		delay_pipeline[8] <= 0;
	
	end
		
		
	else if(clk_en) begin
		
		delay_pipeline[0] <= filter_in;
		delay_pipeline[1] <= delay_pipeline[0];
		delay_pipeline[2] <= delay_pipeline[1];
		delay_pipeline[3] <= delay_pipeline[2];
	   delay_pipeline[4] <= delay_pipeline[3];
		delay_pipeline[5] <= delay_pipeline[4];
		delay_pipeline[6] <= delay_pipeline[5];
		delay_pipeline[7] <= delay_pipeline[6];
	   delay_pipeline[8] <= delay_pipeline[7];
	
	end
end
 
 
always@(posedge clk or negedge rst_n) begin
 
	if(!rst_n) begin
		product[0] <= 0; 
		product[1] <= 0; 
		product[2] <= 0; 
		product[3] <= 0; 
	   product[4] <= 0; 
	   product[5] <= 0; 
	   product[6] <= 0; 
	   product[7] <= 0; 
	   product[8] <= 0; 
	end
	
	else if(clk_en) begin
		product[0] <= delay_pipeline[0]*coeff0;
		product[1] <= delay_pipeline[1]*coeff1;
		product[2] <= delay_pipeline[2]*coeff2;
		product[3] <= delay_pipeline[3]*coeff3;
		product[4] <= delay_pipeline[4]*coeff4;
		product[5] <= delay_pipeline[5]*coeff5;
		product[6] <= delay_pipeline[6]*coeff6;
		product[7] <= delay_pipeline[7]*coeff7;
		product[8] <= delay_pipeline[8]*coeff8;
	end
 
end
..................................................	
 
assign filter_out = sum[26:11];
 
endmodule

 

  

 

posted @ 2023-05-17 23:14  我爱C编程  阅读(56)  评论(0编辑  收藏  举报