当前位置:   article > 正文

m基于FPGA的FIR低通滤波器实现和FPGA频谱分析,包含testbench和滤波器系数MATLAB计算程序_基于fpga的低通滤波器

基于fpga的低通滤波器

目录

1.算法仿真效果

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

​3.Verilog核心程序

4.完整算法代码文件


1.算法仿真效果

本系统进行了Vivado2019.2平台的开发,Vivado2019.2仿真结果如下:

整体仿真结果如下:

放大看,滤波效果如下:

对应的频谱如下:

FPGA的RTL结构如下:

最后用matlab对比仿真,结果如下:

可以看到,FPGA的滤波效果和频谱分析与matlab的结果一致。

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

       基于FPGA(Field-Programmable Gate Array,现场可编程门阵列)的数字低通滤波器实现和FPGA频谱分析是数字信号处理领域的重要应用,广泛应用于通信、音频处理、图像处理等多个行业。数字低通滤波器旨在允许低频信号通过而衰减高频信号,是信号处理中基础且重要的组件之一。其设计通常基于时域采样定理和滤波器设计理论,常见的实现方法有IIR(无限脉冲响应)滤波器和FIR(有限脉冲响应)滤波器。

       在FPGA上实现FIR滤波器,主要通过配置硬件逻辑资源(如查找表LUTs、触发器等)来实现上述卷积运算。具体步骤包括:

  • 系数存储:滤波器系数h[k]被存储在FPGA的块RAM中。
  • 并行处理:利用FPGA的并行处理能力,将输入信号序列分块处理,每一块与滤波器系数进行并行卷积。
  • 流水线设计:为了提高处理速度,设计中通常采用流水线技术,即每个运算步骤在不同的时钟周期完成,从而实现连续数据流处理。

      频谱分析是将信号从时域转换到频域,以观察其频率组成的技术。在FPGA上实现频谱分析,最常见的方式是使用离散傅里叶变换(DFT)或其快速版本——快速傅里叶变换(FFT)。


3.Verilog核心程序

  1. `timescale 1ns / 1ps
  2. //
  3. // Company:
  4. // Engineer:
  5. //
  6. // Create Date: 2024/05/27 21:38:45
  7. // Design Name:
  8. // Module Name: test
  9. // Project Name:
  10. // Target Devices:
  11. // Tool Versions:
  12. // Description:
  13. //
  14. // Dependencies:
  15. //
  16. // Revision:
  17. // Revision 0.01 - File Created
  18. // Additional Comments:
  19. //
  20. //
  21. module test();
  22. reg i_clk;
  23. reg i_rst;
  24. wire signed[15:0]o_x;
  25. wire signed[15:0]o_y;
  26. reg i_before_fft1;
  27. reg i_last_fft1;
  28. reg i_enable1;
  29. wire o_enable1;
  30. wire o_enable2;
  31. wire signed[63:0]o_abs_ifft1;
  32. wire signed[63:0]o_abs_ifft2;
  33. tops tops_U(
  34. .i_clk (i_clk),
  35. .i_rst (i_rst),
  36. .o_x (o_x),
  37. .o_y (o_y),
  38. .i_before_fft1 (i_before_fft1),
  39. .i_last_fft1 (i_last_fft1),
  40. .i_enable1 (i_enable1),
  41. .o_enable1 (o_enable1),
  42. .o_enable2 (o_enable2),
  43. .o_abs_ifft1 (o_abs_ifft1),
  44. .o_abs_ifft2 (o_abs_ifft2)
  45. );
  46. initial
  47. begin
  48. i_clk=1'b1;
  49. i_rst=1'b1;
  50. #100
  51. i_rst = 1'b0;
  52. end
  53. always #5 i_clk=~i_clk;
  54. reg [19:0]cnts2;
  55. always @(posedge i_clk or posedge i_rst)
  56. begin
  57. if(i_rst)
  58. begin
  59. cnts2 <= 20'd0;
  60. i_before_fft1<=1'b0;
  61. i_enable1 <=1'b0;
  62. i_last_fft1 <=1'b0;
  63. end
  64. else begin
  65. if(cnts2==20'd25000)
  66. cnts2 <= cnts2;
  67. else
  68. cnts2 <= cnts2 + 20'd1;
  69. if(cnts2==20'd0)
  70. begin
  71. i_before_fft1<=1'b1;
  72. i_enable1 <=1'b0;
  73. i_last_fft1 <=1'b0;
  74. end
  75. if(cnts2==20'd1)
  76. begin
  77. i_before_fft1<=1'b1;
  78. i_enable1 <=1'b0;
  79. i_last_fft1 <=1'b0;
  80. end
  81. if(cnts2==20'd2)
  82. begin
  83. i_before_fft1<=1'b1;
  84. i_enable1 <=1'b0;
  85. i_last_fft1 <=1'b0;
  86. end
  87. if(cnts2==20'd3)
  88. begin
  89. i_before_fft1<=1'b1;
  90. i_enable1 <=1'b0;
  91. i_last_fft1 <=1'b0;
  92. end
  93. if(cnts2==20'd4)
  94. begin
  95. i_before_fft1<=1'b0;
  96. i_enable1 <=1'b0;
  97. i_last_fft1 <=1'b0;
  98. end
  99. if(cnts2>=20'd5 & cnts2<=20'd4+2047)
  100. begin
  101. i_before_fft1<=1'b0;
  102. i_enable1 <=1'b1;
  103. i_last_fft1 <=1'b0;
  104. end
  105. if(cnts2==20'd4+2048)
  106. begin
  107. i_before_fft1<=1'b0;
  108. i_enable1 <=1'b1;
  109. i_last_fft1 <=1'b1;
  110. end
  111. if(cnts2>20'd4+2048)
  112. begin
  113. i_before_fft1<=1'b0;
  114. i_enable1 <=1'b0;
  115. i_last_fft1 <=1'b0;
  116. end
  117. end
  118. end
  119. endmodule
  120. 00_065m


4.完整算法代码文件


V

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/932924
推荐阅读
相关标签
  

闽ICP备14008679号