赞
踩
设计说明
为了利用仿真简单的说明 FFT 的变换过程,数据点数取较小的值 8。
如果数据是串行输入,需要先进行缓存,所以设计时数据输入方式为并行。
数据输入分为实部和虚部共 2 部分,所以计算结果也分为实部和虚部。
设计采用流水结构,暂不考虑资源消耗的问题。
为了使设计结构更加简单,这里做一步妥协,乘法计算直接使用乘号。如果 FFT 设计应用于实际,一定要将乘法结构换成可以流水的乘法器,或使用官方提供的效率较高的乘法器 IP。
蝶形单元设计
蝶形单元为定点运算,需要对旋转因子进行定点量化。
借助 matlab 将旋转因子扩大 8192 倍(左移 13 位),可参考附录。
为了防止蝶形运算中的乘法和加法导致位宽逐级增大,每一级运算完成后,要对输出数据进行固定位宽的截位,也可去掉旋转因子倍数增大而带来的影响。 代码如下:
- `timescale 1ns/100ps
- /**************** butter unit *************************
- Xm(p) ------------------------> Xm+1(p)
- - ->
- - -
- -
- - -
- - ->
- Xm(q) ------------------------> Xm+1(q)
- Wn -1
- *//
- module butterfly
- (
- input clk,
- input rstn,
- input en,
- input signed [23:0] xp_real, // Xm(p)
- input signed [23:0] xp_imag,
- input signed [23:0] xq_real, // Xm(q)
- input signed [23:0] xq_imag,
- input signed [15:0] factor_real, // Wnr
- input signed [15:0] factor_imag,
-
- output valid,
- output signed [23:0] yp_real, //Xm+1(p)
- output signed [23:0] yp_imag,
- output signed [23:0] yq_real, //Xm+1(q)
- output signed [23:0] yq_imag);
-
- reg [4:0] en_r ;
- always @(posedge clk or negedge rstn) begin
- if (!rstn) begin
- en_r <= 'b0 ;
- end
- else begin
- en_r <= {en_r[3:0], en} ;
- end
- end
- //=====================================================//
- //(1.0) Xm(q) mutiply and Xm(p) delay
- reg signed [39:0] xq_wnr_real0;
- reg signed [39:0] xq_wnr_real1;
- reg signed [39:0] xq_wnr_imag0;
- reg signed [39:0] xq_wnr_imag1;
- reg signed [39:0] xp_real_d;
- reg signed [39:0] xp_imag_d;
- always @(posedge clk or negedge rstn) begin
- if (!rstn) begin
- xp_real_d <= 'b0;
- xp_imag_d <= 'b0;
- xq_wnr_real0 <= 'b0;
- xq_wnr_real1 <= 'b0;
- xq_wnr_imag0 <= 'b0;
- xq_wnr_imag1 <= 'b0;
- end
- else if (en) begin
- xq_wnr_real0 <= xq_real * factor_real;
- xq_wnr_real1 <= xq_imag * factor_imag;
- xq_wnr_imag0 <= xq_real * factor_imag;
- xq_wnr_imag1 <= xq_imag * factor_real;
- //expanding 8192 times as Wnr
- xp_real_d <= {
- {4{xp_real[23]}}, xp_real[22:0], 13'b0};
- xp_imag_d <= {
- {4{xp_imag[23]}}, xp_imag[22:0], 13'b0};
- end
- end
- //(1.1) get Xm(q) mutiplied-results and Xm(p) delay again
- reg signed [39:0] xp_real_d1;
- reg signed [39:0] xp_imag_d1;
- reg signed [39:0] xq_wnr_real;
- reg signed [39:0] xq_wnr_imag;
- always @(posedge clk or negedge rstn) begin
- if (!rstn) begin
- xp_real_d1 <= 'b0;
- xp_imag_d1 <= 'b0;
- xq_wnr_real <= 'b0 ;
- xq_wnr_imag <= 'b0 ;
- end
- else if (en_r[0]) begin
- xp_real_d1 <= xp_real_d;
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。