Sunday, April 24, 2011

IFFT with Symmetric Input in System Generator

The FFT/IFFT of real data input is symmetric: X(N-k) = X*(k). The FFT/IFFT of data with X(N-k) = X*(k) symmetry may not be real numbers unless X(0) is real and X(N/2) is real (this is implied by the symmetry equation X(N-N/2) = X*(N/2) ).

When the FFT core (view all Xilinx documents in Document Navigator) is used in SysGen to calculate the IFFT of symmetric input, there are a couple of more things to consider.

Set up FFT core for inverse FFT 
The FFT core needs to be set to IFFT mode by writing 0 to s_axis_config_tdata_fw_inv input through the AXI configuration interface PRIOR to the start of frame (see the constant blocks in the red circle below)


Starting index difference between Matlab and FFT
In Matlab, the array index starts from 1, while the index for FFT equations starts from 0. When the symmetric data input to the FFT core is created manually from a script, make sure this starting index difference is accounted for. Using an 8-point FFT as an example, the input array fft_in(1:8) should be set up like the below:
    Sample 0:   fft_in(1) = real
    Sample 1,7: fft_in(2) = conj(fft_in(8))
    Sample 2,6: fft_in(3) = conj(fft_in(7)) 
    Sample 3,5: fft_in(4) = conj(fft_in(6)) 
    Sample 4:   fft_in(5) = real

Input data range of FFT core
The FFT block in SysGen expects the input data to be in the range [-1, 1) or a N bit fixed point with N-1 fractional bits, so make sure the input samples are properly scaled to [-1,1) when they are generated in the script.

Exampe
An example with 256-point FFT block set to compute IFFT can be downloaded here. The input samples are symmetric (i.e. X(N-k) = X*(k)). Below are the magnitudes of the real and imaginary parts of the IFFT outputs, where the imaginary part is negligible (i.e. the IFFT outputs are real.).

max_abs_real_fft_sg =
    0.0078

max_abs_imag_fft_sg =
  3.5763e-007

1 comment:

  1. Hello Jim!

    I checked for the samples X(0) and X(N\2) to be real, and they actually are (both their imaginary and real part are null), but the output of the ifft is still not purely real.

    I'm doing a N=256 fft of a signal generated with a dds and then its ifft again.

    Both the modules are Burst Radix 2 and their scale factors are set to 01 for each stage of the fft and to 00 for each stage of the ifft.

    I've noticed that the imaginary part incoming inside the ifft module is not symmetrical but its second block of 128 bins are inverted (sign) with respect to the first 128.
    Could this be the problem or is it correct?

    Thanks in advance for any help!

    ReplyDelete