/******************************************************************************* 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@lists.eurecom.fr Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE *******************************************************************************/ //#include "defs.h" #include #include #include //#include "PHY/defs.h" #include "SIMULATION/TOOLS/defs.h" /* extern void randominit(void); extern double gaussdouble(double,double); //free(input_data); //extern int write_output(const char *,const char *,void *,int,int,char); //flag change extern int write_output(const char *,const char *,void *,int,int,char); */ //double pn[1024]; //#define DEBUG_RF 1 //free(input_data); void rf_rx(double **r_re, double **r_im, double **r_re_i1, double **r_im_i1, double I0_dB, unsigned int nb_rx_antennas, unsigned int length, double s_time, double f_off, double drift, double noise_figure, double rx_gain_dB, int IP3_dBm, double *initial_phase, double pn_cutoff, double pn_amp_dBc, double IQ_imb_dB, double IQ_phase) { double phase = *initial_phase; double phase2 = *initial_phase; double phase_inc = 2*M_PI*f_off*s_time*1e-9; double IQ_imb_lin = pow(10.0,-.05*IQ_imb_dB); double rx_gain_lin = pow(10.0,.05*rx_gain_dB); double IP3_lin = pow(10.0,-.1*IP3_dBm); double p_noise = 0.0; double tmp_re,tmp_im; double N0W = pow(10.0,.1*(-174.0 - 10*log10(s_time*1e-9))); // printf("s_time=%f, N0W=%g\n",s_time,10*log10(N0W)); // phase-noise filter coefficients (2nd order digital Butterworth) double pn_cutoff_d = tan(M_PI*s_time*1e-9*pn_cutoff); double pn_c = 1+2*cos(M_PI/4)*pn_cutoff_d + (pn_cutoff_d*pn_cutoff_d); double pn_a0 = pn_cutoff_d*pn_cutoff_d/pn_c; double pn_b1 = 2*((pn_cutoff_d*pn_cutoff_d) - 1)/pn_c; double pn_b2 = (4*pn_a0) - pn_b1 - 1; double x_n=0.0,x_n1=0.0,x_n2=0.0,y_n1=0.0,y_n2=0.0; double pn_amp = pow(10.0,.1*pn_amp_dBc); double I0 = pow(10.0,.05*I0_dB); // double dummy; int i,a,have_interference=0; if (pn_amp_dBc > -20.0) { printf("rf.c: Illegal pn_amp_dBc %f\n",pn_amp_dBc); exit(-1); } if ((pn_cutoff > 1e6) || (pn_cutoff<1e3)) { printf("rf.c: Illegal pn_cutoff %f\n",pn_cutoff); exit(-1); } if (fabs(IQ_imb_dB) > 1.0) { printf("rf.c: Illegal IQ_imb %f\n",IQ_imb_dB); exit(-1); } if (fabs(IQ_phase) > 0.1) { printf("rf.c: Illegal IQ_phase %f\n",IQ_phase); exit(-1); } if (fabs(f_off) > 10000.0) { printf("rf.c: Illegal f_off %f\n",f_off); exit(-1); } if (fabs(drift) > 1000.0) { printf("rf.c: Illegal drift %f\n",drift); exit(-1); } #ifdef DEBUG_RF printf("pn_a0 = %f, pn_b1=%f,pn_b2=%f\n",pn_a0,pn_b1,pn_b2); #endif /* for (i=0;i