/******************************************************************************* OpenAirInterface Copyright(c) 1999 - 2014 Eurecom OpenAirInterface is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenAirInterface is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenAirInterface.The full GNU General Public License is included in this distribution in the file called "COPYING". If not, see . Contact Information OpenAirInterface Admin: openair_admin@eurecom.fr OpenAirInterface Tech : openair_tech@eurecom.fr OpenAirInterface Dev : openair4g-devel@eurecom.fr Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE *******************************************************************************/ #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