/***************************************************************** * psd_fixpt_ccs.c - C program for computing FFT-based PSD ****************************************************************** * System configuration: * * _____ ____ __________ __________ * | | | | | | | | * x(n)-->| Buf |-->| BR |-->| (1/N)*FFT|-->| |X(k)|^2 |--> P(k) * |_____| |____| |__________| |__________| * * (a) Periodigram ****************************************************************** * System simulation configuration: * * x(n) is the input data from data file "in_int.dat" * out(n) is the power spectrum data to data file "out_int.dat" * *****************************************************************/ /* header files */ #include #include #include #include "def_complex_fixpt.h" /* complex.h header file */ int in_buffer[512]; #define TRUE 1 /*Function */ static void dataIO(void); /* external functions */ extern void ditr2fft_fixpt_ccs(complex *, unsigned int, complex *, unsigned int); extern void ibit_reversal_ccs(complex *, unsigned int); /*variables and constants */ #define N 512 /* Number of FFT points */ #define EXP 9 /* EXP=log2(N) */ #define pi 3.1415926535897 complex X[N]; /* Declare input array */ complex W[EXP]; /* Twiddle e^(-j2pi/N) table */ lcomplex ltemp; int spectrum[N]; int spectrum_db[N]; void main() { unsigned int i,L,LE,LE1; int *input = &in_buffer[0]; /* Step 1: Create a twiddle factor table */ for (L=1; L<=EXP; L++) /* Create twiddle factor table */ { LE=1<>1; /* Number of butterflies in sub-DFT */ W[L-1].re = (int)((0x7fff*cos(pi/LE1))+0.5); W[L-1].im = -(int)((0x7fff*sin(pi/LE1))+0.5); } /* Step 2: Enter input data to reference buffer */ dataIO(); for(i=0; i>9);/*Scaling is perform in fft*/ spectrum_db[i] = 10*log10(spectrum[i]+1); } } /* Function for dataIO */ static void dataIO() { return; }