#include #include #include #include #include #include "openair_device.h" #define PI 3.14159265359 #define MAXPOW 24 FILE *rx_frame_file; FILE *fid; struct complex { double r; double i; }; struct complex_fixed { short r; short i; }; int pow_2[MAXPOW]; int pow_4[MAXPOW]; void twiddle(struct complex *W, int N, double stuff) { W->r=cos(stuff*2.0*PI/(double)N); W->i=-sin(stuff*2.0*PI/(double)N); } void bit_r4_reorder(struct complex *W, int N) { int bits, i, j, k; double tempr, tempi; for (i=0; ii) /** Only make "up" swaps */ { tempr=W[i].r; tempi=W[i].i; W[i].r=W[j].r; W[i].i=W[j].i; W[j].r=tempr; W[j].i=tempi; } } } /** RADIX-4 FFT ALGORITHM */ void radix4(struct complex *x, int N) { int n2, k1, N1, N2; struct complex W, bfly[4]; N1=4; N2=N/4; /** Do 4 Point DFT */ for (n2=0; n2 *maxSNR) { *maxSNR = SNR; memcpy(maxscale,scale,7); } } void fft_test(char *dma_buffer_local, char log2N, char test, int openair_fd) { int N=pow(2,log2N), radix=4; //,test=0; int i; char maxscale[7],MAXSHIFT; char *scale; //scale[7] double maxSNR,input_dB; struct complex *data; struct complex_fixed *data_fixed; set_taus_seed(); if ((data=malloc(sizeof(struct complex)*(size_t)N))==NULL) { fprintf(stderr, "Out of memory!\n"); exit(1); } // data_fixed = &((struct complex_fixed *)dma_buffer_local)[2]; scale = &((char *)dma_buffer_local)[0]; if ((data_fixed=malloc(sizeof(struct complex_fixed)*(size_t)N))==NULL) { fprintf(stderr, "Out of memory!\n"); exit(1); } /** Set up power of two arrays */ pow_2[0]=1; for (i=1; i