当前位置:   article > 正文

2020-11-08_xm_real[ m ] [k[m:0] < (1<

xm_real[ m ] [k[m:0] < (1<

 

FFT 设计

设计说明

为了利用仿真简单的说明 FFT 的变换过程,数据点数取较小的值 8。

如果数据是串行输入,需要先进行缓存,所以设计时数据输入方式为并行。

数据输入分为实部和虚部共 2 部分,所以计算结果也分为实部和虚部。

设计采用流水结构,暂不考虑资源消耗的问题。

为了使设计结构更加简单,这里做一步妥协,乘法计算直接使用乘号。如果 FFT 设计应用于实际,一定要将乘法结构换成可以流水的乘法器,或使用官方提供的效率较高的乘法器 IP。

蝶形单元设计

蝶形单元为定点运算,需要对旋转因子进行定点量化。

借助 matlab 将旋转因子扩大 8192 倍(左移 13 位),可参考附录。

为了防止蝶形运算中的乘法和加法导致位宽逐级增大,每一级运算完成后,要对输出数据进行固定位宽的截位,也可去掉旋转因子倍数增大而带来的影响。 代码如下:

  1. `timescale 1ns/100ps
  2. /**************** butter unit *************************
  3. Xm(p) ------------------------> Xm+1(p)
  4. - ->
  5. - -
  6. -
  7. - -
  8. - ->
  9. Xm(q) ------------------------> Xm+1(q)
  10. Wn -1
  11. *//
  12. module butterfly
  13. (
  14. input clk,
  15. input rstn,
  16. input en,
  17. input signed [23:0] xp_real, // Xm(p)
  18. input signed [23:0] xp_imag,
  19. input signed [23:0] xq_real, // Xm(q)
  20. input signed [23:0] xq_imag,
  21. input signed [15:0] factor_real, // Wnr
  22. input signed [15:0] factor_imag,
  23. output valid,
  24. output signed [23:0] yp_real, //Xm+1(p)
  25. output signed [23:0] yp_imag,
  26. output signed [23:0] yq_real, //Xm+1(q)
  27. output signed [23:0] yq_imag);
  28. reg [4:0] en_r ;
  29. always @(posedge clk or negedge rstn) begin
  30. if (!rstn) begin
  31. en_r <= 'b0 ;
  32. end
  33. else begin
  34. en_r <= {en_r[3:0], en} ;
  35. end
  36. end
  37. //=====================================================//
  38. //(1.0) Xm(q) mutiply and Xm(p) delay
  39. reg signed [39:0] xq_wnr_real0;
  40. reg signed [39:0] xq_wnr_real1;
  41. reg signed [39:0] xq_wnr_imag0;
  42. reg signed [39:0] xq_wnr_imag1;
  43. reg signed [39:0] xp_real_d;
  44. reg signed [39:0] xp_imag_d;
  45. always @(posedge clk or negedge rstn) begin
  46. if (!rstn) begin
  47. xp_real_d <= 'b0;
  48. xp_imag_d <= 'b0;
  49. xq_wnr_real0 <= 'b0;
  50. xq_wnr_real1 <= 'b0;
  51. xq_wnr_imag0 <= 'b0;
  52. xq_wnr_imag1 <= 'b0;
  53. end
  54. else if (en) begin
  55. xq_wnr_real0 <= xq_real * factor_real;
  56. xq_wnr_real1 <= xq_imag * factor_imag;
  57. xq_wnr_imag0 <= xq_real * factor_imag;
  58. xq_wnr_imag1 <= xq_imag * factor_real;
  59. //expanding 8192 times as Wnr
  60. xp_real_d <= {
  61. {4{xp_real[23]}}, xp_real[22:0], 13'b0};
  62. xp_imag_d <= {
  63. {4{xp_imag[23]}}, xp_imag[22:0], 13'b0};
  64. end
  65. end
  66. //(1.1) get Xm(q) mutiplied-results and Xm(p) delay again
  67. reg signed [39:0] xp_real_d1;
  68. reg signed [39:0] xp_imag_d1;
  69. reg signed [39:0] xq_wnr_real;
  70. reg signed [39:0] xq_wnr_imag;
  71. always @(posedge clk or negedge rstn) begin
  72. if (!rstn) begin
  73. xp_real_d1 <= 'b0;
  74. xp_imag_d1 <= 'b0;
  75. xq_wnr_real <= 'b0 ;
  76. xq_wnr_imag <= 'b0 ;
  77. end
  78. else if (en_r[0]) begin
  79. xp_real_d1 <= xp_real_d;
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/534750
推荐阅读
相关标签