Commit 1793ae59 authored by lfarizav's avatar lfarizav

dlsim working in the frequency domain

parent 9ff4dabc
...@@ -297,7 +297,7 @@ void bit8_rxdemux(int32_t length,int32_t offset); ...@@ -297,7 +297,7 @@ void bit8_rxdemux(int32_t length,int32_t offset);
@param format data format (0 = real 16-bit, 1 = complex 16-bit,2 real 32-bit, 3 complex 32-bit,4 = real 8-bit, 5 = complex 8-bit) @param format data format (0 = real 16-bit, 1 = complex 16-bit,2 real 32-bit, 3 complex 32-bit,4 = real 8-bit, 5 = complex 8-bit)
*/ */
int32_t write_output(const char *fname, const char *vname, void *data, int length, int dec, char format); int32_t write_output(const char *fname, const char *vname, void *data, int length, int dec, char format);
int32_t write_output_chFf(const char *fname, const char *vname, float *data1, float *data2, int length, int dec, char format); int32_t write_output_chFf(const char *fname, const char *vname, float data1[1200], float data2[1200], int length, int dec);
#endif #endif
void Zero_Buffer(void *,uint32_t); void Zero_Buffer(void *,uint32_t);
......
...@@ -190,19 +190,16 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d ...@@ -190,19 +190,16 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d
return 0; return 0;
} }
int write_output_chFf(const char *fname,const char *vname,float *data1,float *data2,int length,int dec) int write_output_chFf(const char *fname,const char *vname,float data1[1200],float data2[1200],int length,int dec)
{ {
FILE *fp=NULL; FILE *fp=NULL;
fp = fopen(fname,"a+");
int i; int i;
printf("Writing %d to %s\n",length,fname); printf("Writing %d to %s\n",length,fname);
if (fp== NULL) {
printf("[OPENAIR][FILE OUTPUT] Cannot open file %s\n",fname);
return(-1);
}
for (i=0; i<length; i++) { for (i=0; i<length; i++) {
fprintf(fp,"%g + j*(%g)\n",data1[i],data2[i]); fprintf(fp,"%g + j*(%g)\n",data1[i],data2[i]);
} }
......
...@@ -259,32 +259,48 @@ void DL_channel_freq(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_fla ...@@ -259,32 +259,48 @@ void DL_channel_freq(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_fla
double channelx,channely; double channelx,channely;
double sigma2_dB,sigma2; double sigma2_dB,sigma2;
double iqim=0.0; double iqim=0.0;
float tx_pwr;
/*tx_pwr = dac_fixed_gain_AVX_float(s_re_f,
s_im_f,
eNB->common_vars.txdataF[0],
subframe*UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti,
eNB2UE[0]->nb_tx,
UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti,
subframe*UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti,
UE->frame_parms.ofdm_symbol_size,
14,
UE->frame_parms.pdsch_config_common.referenceSignalPower, // dBm/RE
UE->frame_parms.N_RB_DL*12);*/
// printf("Copying tx ..., nsymb %d (n_tx %d), awgn %d\n",nsymb,eNB->frame_parms.nb_antennas_tx,awgn_flag); // printf("Copying tx ..., nsymb %d (n_tx %d), awgn %d\n",nsymb,eNB->frame_parms.nb_antennas_tx,awgn_flag);
for (i=0; i<2*UE->frame_parms.samples_per_tti; i++) { for (i=0; i<2*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti); i++) {
for (aa=0; aa<eNB->frame_parms.nb_antennas_tx; aa++) { for (aa=0; aa<eNB->frame_parms.nb_antennas_tx; aa++) {
if (awgn_flag == 0) { if (awgn_flag == 0) {
s_re_f[aa][i] = ((double)(((short *)eNB->common_vars.txdataF[0][aa]))[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti)) + (i<<1)]); s_re_f[aa][i] = ((float)(((short *)eNB->common_vars.txdataF[0][aa]))[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti)) + (i<<1)]);
s_im_f[aa][i] = ((double)(((short *)eNB->common_vars.txdataF[0][aa]))[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti)) +(i<<1)+1]); s_im_f[aa][i] = ((float)(((short *)eNB->common_vars.txdataF[0][aa]))[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti)) +(i<<1)+1]);
} else { } else {
for (aarx=0; aarx<UE->frame_parms.nb_antennas_rx; aarx++) { for (aarx=0; aarx<UE->frame_parms.nb_antennas_rx; aarx++) {
if (aa==0) { if (aa==0) {
r_re_f[aarx][i] = ((double)(((short *)eNB->common_vars.txdataF[0][aa]))[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti)) +(i<<1)]); r_re_f[aarx][i] = ((float)(((short *)eNB->common_vars.txdataF[0][aa]))[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti)) +(i<<1)]);
r_im_f[aarx][i] = ((double)(((short *)eNB->common_vars.txdataF[0][aa]))[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti)) +(i<<1)+1]); r_im_f[aarx][i] = ((float)(((short *)eNB->common_vars.txdataF[0][aa]))[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti)) +(i<<1)+1]);
} else { } else {
r_re_f[aarx][i] += ((double)(((short *)eNB->common_vars.txdataF[0][aa]))[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti)) +(i<<1)]); r_re_f[aarx][i] += ((float)(((short *)eNB->common_vars.txdataF[0][aa]))[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti)) +(i<<1)]);
r_im_f[aarx][i] += ((double)(((short *)eNB->common_vars.txdataF[0][aa]))[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti)) +(i<<1)+1]); r_im_f[aarx][i] += ((float)(((short *)eNB->common_vars.txdataF[0][aa]))[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti)) +(i<<1)+1]);
} }
} }
} }
} }
} }
printf("subframe %d\n",subframe);
write_output("tx_data.m","txdata", &eNB->common_vars.txdata[0][0],UE->frame_parms.samples_per_tti,1,1);
write_output("tx_data_F.m","txdataF", &eNB->common_vars.txdataF[0][0],(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti),1,1);
write_output("r_re_f.m","rref", &r_re_f[0],(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti),1,1);
write_output("r_im_f.m","rimf", &r_im_f[0],(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti),1,1);
// Multipath channel // Multipath channel
if (awgn_flag == 0) { if (awgn_flag == 0) {
/*multipath_channel(eNB2UE[round],s_re,s_im,r_re,r_im,
2*UE->frame_parms.samples_per_tti,hold_channel);*/
multipath_channel_freq_AVX_float(eNB2UE[round],s_re_f,s_im_f,r_re_f,r_im_f, multipath_channel_freq_AVX_float(eNB2UE[round],s_re_f,s_im_f,r_re_f,r_im_f,
2*UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti,hold_channel,0,0,0,subframe&0x1); 2*UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti,hold_channel,0,0,0,subframe&0x1);
...@@ -310,15 +326,15 @@ void DL_channel_freq(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_fla ...@@ -310,15 +326,15 @@ void DL_channel_freq(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_fla
if(abstx) { if(abstx) {
if (trials==0 && round==0) { if (trials==0 && round==0) {
// calculate freq domain representation to compute SINR // calculate freq domain representation to compute SINR
freq_channel(eNB2UE[0], eNB->frame_parms.N_RB_DL,2*eNB->frame_parms.N_RB_DL + 1); freq_channel_AVX_float(eNB2UE[0], eNB->frame_parms.N_RB_DL,2*eNB->frame_parms.N_RB_DL + 1);
// snr=pow(10.0,.1*SNR); // snr=pow(10.0,.1*SNR);
fprintf(csv_fd,"%f,",SNR); fprintf(csv_fd,"%f,",SNR);
for (u=0; u<2*eNB->frame_parms.N_RB_DL; u++) { for (u=0; u<2*eNB->frame_parms.N_RB_DL; u++) {
for (aarx=0; aarx<eNB2UE[0]->nb_rx; aarx++) { for (aarx=0; aarx<eNB2UE[0]->nb_rx; aarx++) {
for (aatx=0; aatx<eNB2UE[0]->nb_tx; aatx++) { for (aatx=0; aatx<eNB2UE[0]->nb_tx; aatx++) {
channelx = eNB2UE[0]->chF[aarx+(aatx*eNB2UE[0]->nb_rx)][u].x; channelx = eNB2UE[0]->chFf[aarx+(aatx*eNB2UE[0]->nb_rx)].x[u];
channely = eNB2UE[0]->chF[aarx+(aatx*eNB2UE[0]->nb_rx)][u].y; channely = eNB2UE[0]->chFf[aarx+(aatx*eNB2UE[0]->nb_rx)].y[u];
fprintf(csv_fd,"%e+i*(%e),",channelx,channely); fprintf(csv_fd,"%e+i*(%e),",channelx,channely);
} }
} }
...@@ -330,8 +346,8 @@ void DL_channel_freq(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_fla ...@@ -330,8 +346,8 @@ void DL_channel_freq(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_fla
for (u=0; u<2*eNB->frame_parms.N_RB_DL; u++) { for (u=0; u<2*eNB->frame_parms.N_RB_DL; u++) {
for (aarx=0; aarx<eNB2UE[1]->nb_rx; aarx++) { for (aarx=0; aarx<eNB2UE[1]->nb_rx; aarx++) {
for (aatx=0; aatx<eNB2UE[1]->nb_tx; aatx++) { for (aatx=0; aatx<eNB2UE[1]->nb_tx; aatx++) {
channelx = eNB2UE[1]->chF[aarx+(aatx*eNB2UE[1]->nb_rx)][u].x; channelx = eNB2UE[1]->chFf[aarx+(aatx*eNB2UE[1]->nb_rx)].x[u];
channely = eNB2UE[1]->chF[aarx+(aatx*eNB2UE[1]->nb_rx)][u].y; channely = eNB2UE[1]->chFf[aarx+(aatx*eNB2UE[1]->nb_rx)].y[u];
fprintf(csv_fd,"%e+i*(%e),",channelx,channely); fprintf(csv_fd,"%e+i*(%e),",channelx,channely);
} }
} }
...@@ -342,8 +358,8 @@ void DL_channel_freq(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_fla ...@@ -342,8 +358,8 @@ void DL_channel_freq(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_fla
for (u=0; u<2*eNB->frame_parms.N_RB_DL; u++) { for (u=0; u<2*eNB->frame_parms.N_RB_DL; u++) {
for (aarx=0; aarx<eNB2UE[2]->nb_rx; aarx++) { for (aarx=0; aarx<eNB2UE[2]->nb_rx; aarx++) {
for (aatx=0; aatx<eNB2UE[2]->nb_tx; aatx++) { for (aatx=0; aatx<eNB2UE[2]->nb_tx; aatx++) {
channelx = eNB2UE[2]->chF[aarx+(aatx*eNB2UE[2]->nb_rx)][u].x; channelx = eNB2UE[2]->chFf[aarx+(aatx*eNB2UE[2]->nb_rx)].x[u];
channely = eNB2UE[2]->chF[aarx+(aatx*eNB2UE[2]->nb_rx)][u].y; channely = eNB2UE[2]->chFf[aarx+(aatx*eNB2UE[2]->nb_rx)].y[u];
fprintf(csv_fd,"%e+i*(%e),",channelx,channely); fprintf(csv_fd,"%e+i*(%e),",channelx,channely);
} }
} }
...@@ -354,8 +370,8 @@ void DL_channel_freq(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_fla ...@@ -354,8 +370,8 @@ void DL_channel_freq(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_fla
for (u=0; u<2*eNB->frame_parms.N_RB_DL; u++) { for (u=0; u<2*eNB->frame_parms.N_RB_DL; u++) {
for (aarx=0; aarx<eNB2UE[3]->nb_rx; aarx++) { for (aarx=0; aarx<eNB2UE[3]->nb_rx; aarx++) {
for (aatx=0; aatx<eNB2UE[3]->nb_tx; aatx++) { for (aatx=0; aatx<eNB2UE[3]->nb_tx; aatx++) {
channelx = eNB2UE[3]->chF[aarx+(aatx*eNB2UE[3]->nb_rx)][u].x; channelx = eNB2UE[3]->chFf[aarx+(aatx*eNB2UE[3]->nb_rx)].x[u];
channely = eNB2UE[3]->chF[aarx+(aatx*eNB2UE[3]->nb_rx)][u].y; channely = eNB2UE[3]->chFf[aarx+(aatx*eNB2UE[3]->nb_rx)].y[u];
fprintf(csv_fd,"%e+i*(%e),",channelx,channely); fprintf(csv_fd,"%e+i*(%e),",channelx,channely);
} }
} }
...@@ -374,9 +390,9 @@ void DL_channel_freq(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_fla ...@@ -374,9 +390,9 @@ void DL_channel_freq(PHY_VARS_eNB *eNB,PHY_VARS_UE *UE,int subframe,int awgn_fla
for (aa=0; aa<eNB->frame_parms.nb_antennas_rx; aa++) { for (aa=0; aa<eNB->frame_parms.nb_antennas_rx; aa++) {
//printf("s_re[0][%d]=> %f , r_re[0][%d]=> %f\n",i,s_re[aa][i],i,r_re[aa][i]); //printf("s_re[0][%d]=> %f , r_re[0][%d]=> %f\n",i,s_re[aa][i],i,r_re[aa][i]);
((short*) UE->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[aa])[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti))+2*i] = ((short*) UE->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[aa])[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti))+2*i] =
(short) (r_re_f[aa][i] + sqrt(sigma2/2)*ziggurat(0.0,1.0)); (short) (r_re_f[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0));
((short*) UE->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[aa])[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti))+2*i+1] = ((short*) UE->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[aa])[(2*subframe*(UE->frame_parms.ofdm_symbol_size*UE->frame_parms.symbols_per_tti))+2*i+1] =
(short) (r_im_f[aa][i] + (iqim*r_re_f[aa][i]) + sqrt(sigma2/2)*ziggurat(0.0,1.0)); (short) (r_im_f[aa][i] + (iqim*r_re_f[aa][i]) + sqrt(sigma2/2)*gaussdouble(0.0,1.0));
} }
} }
} }
...@@ -1448,6 +1464,7 @@ int main(int argc, char **argv) ...@@ -1448,6 +1464,7 @@ int main(int argc, char **argv)
//int re_allocated; //int re_allocated;
char fname[32],vname[32]; char fname[32],vname[32];
FILE *bler_fd; FILE *bler_fd;
//FILE *chFf;
char bler_fname[256]; char bler_fname[256];
FILE *time_meas_fd; FILE *time_meas_fd;
char time_meas_fname[256]; char time_meas_fname[256];
...@@ -2474,7 +2491,7 @@ int main(int argc, char **argv) ...@@ -2474,7 +2491,7 @@ int main(int argc, char **argv)
eNB_rxtx_proc_t *proc_eNB = &eNB->proc.proc_rxtx[UE->current_thread_id[subframe]]; eNB_rxtx_proc_t *proc_eNB = &eNB->proc.proc_rxtx[UE->current_thread_id[subframe]];
for (trials = 0; trials<n_frames; trials++) { for (trials = 0; trials<n_frames; trials++) {
//printf("Trial %d\n",trials); printf("Trial %d\n",trials);
fflush(stdout); fflush(stdout);
round=0; round=0;
...@@ -2650,7 +2667,7 @@ int main(int argc, char **argv) ...@@ -2650,7 +2667,7 @@ int main(int argc, char **argv)
if (n_frames==1) { if (n_frames==1) {
printf("tx_lev = %d (%d dB)\n",tx_lev,tx_lev_dB); printf("tx_lev = %d (%d dB)\n",tx_lev,tx_lev_dB);
if (!UE->do_ofdm_mod) if (!UE->do_ofdm_mod)
write_output("txsig0.m","txs0", &eNB->common_vars.txdataF[eNB_id][0][subframe*(eNB->frame_parms.ofdm_symbol_size*eNB->frame_parms.symbols_per_tti)], (eNB->frame_parms.ofdm_symbol_size*eNB->frame_parms.symbols_per_tti),1,1); write_output("txsig0.m","txs0", &eNB->common_vars.txdata[eNB_id][0][subframe*eNB->frame_parms.samples_per_tti],eNB->frame_parms.samples_per_tti,1,1);
if (transmission_mode<7) { if (transmission_mode<7) {
write_output("txsigF0.m","txsF0", &eNB->common_vars.txdataF[eNB_id][0][subframe*nsymb*eNB->frame_parms.ofdm_symbol_size],nsymb*eNB->frame_parms.ofdm_symbol_size,1,1); write_output("txsigF0.m","txsF0", &eNB->common_vars.txdataF[eNB_id][0][subframe*nsymb*eNB->frame_parms.ofdm_symbol_size],nsymb*eNB->frame_parms.ofdm_symbol_size,1,1);
...@@ -2749,10 +2766,10 @@ int main(int argc, char **argv) ...@@ -2749,10 +2766,10 @@ int main(int argc, char **argv)
if ((test_perf ==0 ) && (n_frames==1)) { if ((test_perf ==0 ) && (n_frames==1)) {
if (UE->do_ofdm_mod) if (UE->do_ofdm_mod)
{ {
write_output_chFf("ch0_f.m","ch0_f",eNB2UE[0]->chFf[0].x,eNB2UE[0]->chFf[0].y,eNB2UE[0]->channel_length,1,8); write_output_chFf("ch0_f.m","ch0_f",eNB2UE[0]->chFf[0].x,eNB2UE[0]->chFf[0].y,eNB2UE[0]->channel_length,1);
if (eNB->frame_parms.nb_antennas_tx>1) if (eNB->frame_parms.nb_antennas_tx>1)
write_output_chFf("ch1_f.m","ch1_f",eNB2UE[0]->chFf[eNB->frame_parms.nb_antennas_rx].x,eNB2UE[0]->chFf[eNB->frame_parms.nb_antennas_rx].y,eNB2UE[0]->channel_length,1,8); write_output_chFf("ch1_f.m","ch1_f",eNB2UE[0]->chFf[eNB->frame_parms.nb_antennas_rx].x,eNB2UE[0]->chFf[eNB->frame_parms.nb_antennas_rx].y,eNB2UE[0]->channel_length,1);
} }
else else
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment