Digital Signal Processing Reference
In-Depth Information
// FFTr4_sim.c Radix-4 FFT and IFFT using a sine table
//Uses TI's optimized linear ASM radix-4 complex FFT function
#include <math.h>
#define N 16 //# of complex FFT points
float x[2*N]; //input real/imag aligned
float w[3*N/2]; //complex twiddle factors
unsigned short J[4*N];
//index for digit reversal
unsigned short I[4*N];
//index for digit reversal
#pragma DATA_ALIGN(x,8);
//align x for unscrambling
#pragma DATA_ALIGN(w,8);
//align w for unscrambling
double delta = 2*3.14159265359/N;
short sine_table[16]={0,383,707,924,1000,924,707,383,
-0,-383,-707,-924,-1000,-924,-707,-383};//sine
void main(void)
{
int i, count;
R4DigitRevIndexTableGen(N,&count,I,J);//indexes for digit reversal
for(i = 0; i < 3*N/4; i++)
//generate twiddle constants
{
w[2*i+1] = sin(i * delta);
//real component of w
w[2*i] = cos(i * delta);
//imag component of w negated
}
for (i=0 ; i<N ; i++)
{
x[2*i] = sine_table[i];
//input from sine table
x[2*i+1] = 0;
//set imag component to zero
}
cfftr4_dif(x, w, N); //call ASM FFT function
digit_reverse((double*)x,I,J,count); //digit reverse FFT output
for(i = 0; i < N; i++)
x[2*i + 1] = -x[2*i + 1]; //for IFFT conjugate input
cfftr4_dif(x, w, N); //to perform IFFT call FFT
digit_reverse((double *)x,I,J,count); //digit reverse to unscramble
for (i=0; i <(2*N); i++)
x[i] /= N;
//scale to get original input
}
FIGURE 6.19. FFT program that calls TI's optimized radix-4 FFT function with input from
a lookup table ( FFTr4_sim.c ).
point), and verify that the output sequence is now unscrambled or in normal
order. These results can be also verified using MATLAB (see Appendix D).
3. Run the program again (with the breakpoint in the same location). Verify that
the output is now the same as the original input. By taking the complex
conjugate of the input, again calling the same FFT function, unscrambling the
output sequence, and scaling by N yields the original input.
4. In lieu of using a sine as input, let the input be a rectangular signal consisting
of eight values of 1000 followed by eight values of 0. Repeat the previous pro-
cedures and verify the results with those in Figure 6.6 or with MATLAB. Note
that the magnitude of the FFT output after the digit reversal is a sinc func-
tion, as in Figure 6.7.
Search WWH ::




Custom Search