Commit 40a51f76 authored by Raymond Knopp's avatar Raymond Knopp

added file reading for ulsim

parent 3a19aa6e
...@@ -176,6 +176,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, ...@@ -176,6 +176,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
} }
uint32_t Nid_pusch[2] = {cfg->cell_config.phy_cell_id.value,cfg->cell_config.phy_cell_id.value}; uint32_t Nid_pusch[2] = {cfg->cell_config.phy_cell_id.value,cfg->cell_config.phy_cell_id.value};
LOG_D(PHY,"Initializing PUSCH DMRS Gold sequence with (%x,%x)\n",Nid_pusch[1],Nid_pusch[2]);
nr_gold_pusch(gNB, &Nid_pusch[0]); nr_gold_pusch(gNB, &Nid_pusch[0]);
/// Transport init necessary for NR synchro /// Transport init necessary for NR synchro
......
...@@ -456,13 +456,15 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, ...@@ -456,13 +456,15 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
memcpy((void *)&tmp_dft_in[sample_offset-rxdata_offset], memcpy((void *)&tmp_dft_in[sample_offset-rxdata_offset],
(void *) &rxdata[0], (void *) &rxdata[0],
(frame_parms->ofdm_symbol_size-sample_offset+rxdata_offset)*sizeof(int)); (frame_parms->ofdm_symbol_size-sample_offset+rxdata_offset)*sizeof(int));
dft((int16_t *)&tmp_dft_in, dft((int16_t *)&tmp_dft_in,
(int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1); (int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1);
} }
else else
dft((int16_t *)&rxdata[rxdata_offset-sample_offset], dft((int16_t *)&rxdata[rxdata_offset-sample_offset],
(int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1); (int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1);
// clear DC carrier from OFDM symbols
rxdataF[symbol * frame_parms->ofdm_symbol_size] = 0;
return(0); return(0);
} }
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "PHY/NR_UE_ESTIMATION/filt16a_32.h" #include "PHY/NR_UE_ESTIMATION/filt16a_32.h"
//#define DEBUG_CH //#define DEBUG_CH
//#define DEBUG_PUSCH
int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
unsigned char Ns, unsigned char Ns,
...@@ -116,7 +116,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -116,7 +116,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
//------------------generate DMRS------------------// //------------------generate DMRS------------------//
if (pusch_pdu->transform_precoding) // if transform precoding is disabled if (pusch_pdu->transform_precoding==0) // if transform precoding is disabled
nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch_dmrs[pusch_pdu->scid][Ns][symbol], &pilot[0], 1000, 0, nb_rb_pusch, pusch_pdu->rb_start*NR_NB_SC_PER_RB, pusch_pdu->dmrs_config_type); nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch_dmrs[pusch_pdu->scid][Ns][symbol], &pilot[0], 1000, 0, nb_rb_pusch, pusch_pdu->rb_start*NR_NB_SC_PER_RB, pusch_pdu->dmrs_config_type);
else else
nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch_dmrs[pusch_pdu->scid][Ns][symbol], &pilot[0], 1000, 0, nb_rb_pusch, 0, pusch_pdu->dmrs_config_type); nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch_dmrs[pusch_pdu->scid][Ns][symbol], &pilot[0], 1000, 0, nb_rb_pusch, 0, pusch_pdu->dmrs_config_type);
...@@ -132,8 +132,9 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -132,8 +132,9 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
memset(ul_ch,0,4*(gNB->frame_parms.ofdm_symbol_size)); memset(ul_ch,0,4*(gNB->frame_parms.ofdm_symbol_size));
#ifdef DEBUG_PUSCH #ifdef DEBUG_PUSCH
printf("symbol_offset %d, nushift %d\n",symbol_offset,nushift);
printf("ch est pilot addr %p RB_DL %d\n",&pilot[0], gNB->frame_parms.N_RB_UL); printf("ch est pilot addr %p RB_DL %d\n",&pilot[0], gNB->frame_parms.N_RB_UL);
printf("k %d, first_carrier %d\n",k,gNB->frame_parms.first_carrier_offset); printf("bwp_start_subcarrier %d, k %d, first_carrier %d\n",bwp_start_subcarrier,k,gNB->frame_parms.first_carrier_offset);
printf("rxF addr %p p %d\n", rxF,p); printf("rxF addr %p p %d\n", rxF,p);
printf("ul_ch addr %p nushift %d\n",ul_ch,nushift); printf("ul_ch addr %p nushift %d\n",ul_ch,nushift);
#endif #endif
...@@ -148,7 +149,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -148,7 +149,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
#ifdef DEBUG_PUSCH #ifdef DEBUG_PUSCH
printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1]));
printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
printf("data 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[2],rxF[3],&rxF[2],ch[0],ch[1],pil[0],pil[1]); printf("data 0 : rxF - > (%d,%d)\n",rxF[2],rxF[3]);
#endif #endif
multadd_real_vector_complex_scalar(fl, multadd_real_vector_complex_scalar(fl,
...@@ -166,6 +167,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -166,6 +167,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
#ifdef DEBUG_PUSCH #ifdef DEBUG_PUSCH
printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
printf("data 1 : rxF - > (%d,%d)\n",rxF[2],rxF[3]);
#endif #endif
multadd_real_vector_complex_scalar(fml, multadd_real_vector_complex_scalar(fml,
ch, ch,
...@@ -181,6 +183,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -181,6 +183,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
#ifdef DEBUG_PUSCH #ifdef DEBUG_PUSCH
printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
printf("data 2 : rxF - > (%d,%d)\n",rxF[2],rxF[3]);
#endif #endif
multadd_real_vector_complex_scalar(fmm, multadd_real_vector_complex_scalar(fmm,
ch, ch,
...@@ -201,7 +204,8 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -201,7 +204,8 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PUSCH #ifdef DEBUG_PUSCH
printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
printf("data %d : rxF - > (%d,%d)\n",pilot_cnt,rxF[2],rxF[3]);
#endif #endif
multadd_real_vector_complex_scalar(fml, multadd_real_vector_complex_scalar(fml,
ch, ch,
...@@ -217,6 +221,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -217,6 +221,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
#ifdef DEBUG_PUSCH #ifdef DEBUG_PUSCH
printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
printf("data %d : rxF - > (%d,%d)\n",pilot_cnt+1,rxF[2],rxF[3]);
#endif #endif
multadd_real_vector_complex_scalar(fmm, multadd_real_vector_complex_scalar(fmm,
ch, ch,
...@@ -238,6 +243,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -238,6 +243,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PUSCH #ifdef DEBUG_PUSCH
printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
printf("data %d : rxF - > (%d,%d)\n",pilot_cnt,rxF[2],rxF[3]);
#endif #endif
multadd_real_vector_complex_scalar(fm, multadd_real_vector_complex_scalar(fm,
ch, ch,
...@@ -256,6 +262,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -256,6 +262,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
#ifdef DEBUG_PUSCH #ifdef DEBUG_PUSCH
printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1]));
printf("pilot %u: rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); printf("pilot %u: rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
printf("data %d : rxF - > (%d,%d)\n",pilot_cnt+1,rxF[2],rxF[3]);
#endif #endif
multadd_real_vector_complex_scalar(fmr, multadd_real_vector_complex_scalar(fmr,
ch, ch,
...@@ -271,6 +278,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -271,6 +278,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PUSCH #ifdef DEBUG_PUSCH
printf("pilot %u: rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); printf("pilot %u: rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
printf("data %d : rxF - > (%d,%d)\n",pilot_cnt+2,rxF[2],rxF[3]);
#endif #endif
multadd_real_vector_complex_scalar(fr, multadd_real_vector_complex_scalar(fr,
ch, ch,
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
//#define NR_PBCH_DMRS_LENGTH_DWORD 5 //#define NR_PBCH_DMRS_LENGTH_DWORD 5
//#define NR_PBCH_DMRS_LENGTH 144 //#define NR_PBCH_DMRS_LENGTH 144
//#define DEBUG_PDCCH //#define DEBUG_PUSCH
#include "refsig_defs_ue.h" #include "refsig_defs_ue.h"
#include "PHY/defs_nr_UE.h" #include "PHY/defs_nr_UE.h"
......
...@@ -1014,7 +1014,7 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext, ...@@ -1014,7 +1014,7 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext,
} }
void nr_rx_pusch(PHY_VARS_gNB *gNB, void nr_rx_pusch(PHY_VARS_gNB *gNB,
uint8_t UE_id, uint8_t ulsch_id,
uint32_t frame, uint32_t frame,
uint8_t nr_tti_rx, uint8_t nr_tti_rx,
unsigned char symbol, unsigned char symbol,
...@@ -1027,23 +1027,23 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -1027,23 +1027,23 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
int avgs; int avgs;
int avg[4]; int avg[4];
NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
nfapi_nr_pusch_pdu_t *rel15_ul = &gNB->ulsch[UE_id][0]->harq_processes[harq_pid]->ulsch_pdu; nfapi_nr_pusch_pdu_t *rel15_ul = &gNB->ulsch[ulsch_id][0]->harq_processes[harq_pid]->ulsch_pdu;
uint8_t nodata_dmrs = 1; // FIXME to be properly configured from fapi uint8_t nodata_dmrs = 1; // FIXME to be properly configured from fapi
dmrs_symbol_flag = 0; dmrs_symbol_flag = 0;
ptrs_symbol_flag = 0; ptrs_symbol_flag = 0;
gNB->pusch_vars[UE_id]->ptrs_sc_per_ofdm_symbol = 0; gNB->pusch_vars[ulsch_id]->ptrs_sc_per_ofdm_symbol = 0;
if(symbol == rel15_ul->start_symbol_index){ if(symbol == rel15_ul->start_symbol_index){
gNB->pusch_vars[UE_id]->rxdataF_ext_offset = 0; gNB->pusch_vars[ulsch_id]->rxdataF_ext_offset = 0;
gNB->pusch_vars[UE_id]->dmrs_symbol = 0; gNB->pusch_vars[ulsch_id]->dmrs_symbol = 0;
gNB->pusch_vars[UE_id]->cl_done = 0; gNB->pusch_vars[ulsch_id]->cl_done = 0;
gNB->pusch_vars[UE_id]->ptrs_symbols = 0; gNB->pusch_vars[ulsch_id]->ptrs_symbols = 0;
if ( ((rel15_ul->pdu_bit_map)>>2)& 0x01 ) { // if there is ptrs pdu if ( ((rel15_ul->pdu_bit_map)>>2)& 0x01 ) { // if there is ptrs pdu
L_ptrs = 1<<(rel15_ul->pusch_ptrs.ptrs_time_density); L_ptrs = 1<<(rel15_ul->pusch_ptrs.ptrs_time_density);
set_ptrs_symb_idx(&gNB->pusch_vars[UE_id]->ptrs_symbols, set_ptrs_symb_idx(&gNB->pusch_vars[ulsch_id]->ptrs_symbols,
rel15_ul->nr_of_symbols, rel15_ul->nr_of_symbols,
rel15_ul->start_symbol_index, rel15_ul->start_symbol_index,
rel15_ul->dmrs_config_type, rel15_ul->dmrs_config_type,
...@@ -1064,7 +1064,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -1064,7 +1064,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
nb_re_pusch = 0; nb_re_pusch = 0;
else else
nb_re_pusch = rel15_ul->rb_size * ((rel15_ul->dmrs_config_type==pusch_dmrs_type1)?6:8); nb_re_pusch = rel15_ul->rb_size * ((rel15_ul->dmrs_config_type==pusch_dmrs_type1)?6:8);
gNB->pusch_vars[UE_id]->dmrs_symbol = symbol; gNB->pusch_vars[ulsch_id]->dmrs_symbol = symbol;
} else { } else {
nb_re_pusch = rel15_ul->rb_size * NR_NB_SC_PER_RB; nb_re_pusch = rel15_ul->rb_size * NR_NB_SC_PER_RB;
} }
...@@ -1077,7 +1077,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -1077,7 +1077,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
rel15_ul->nr_of_symbols, rel15_ul->nr_of_symbols,
0, 0,
(rel15_ul->pusch_ptrs.ptrs_freq_density)?4:2, (rel15_ul->pusch_ptrs.ptrs_freq_density)?4:2,
gNB->pusch_vars[UE_id]->ptrs_symbols, gNB->pusch_vars[ulsch_id]->ptrs_symbols,
0, 0,
frame_parms->ofdm_symbol_size, frame_parms->ofdm_symbol_size,
rel15_ul->dmrs_config_type, rel15_ul->dmrs_config_type,
...@@ -1085,7 +1085,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -1085,7 +1085,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
} }
if (ptrs_symbol_flag == 1){ if (ptrs_symbol_flag == 1){
gNB->pusch_vars[UE_id]->ptrs_symbol_index = symbol; gNB->pusch_vars[ulsch_id]->ptrs_symbol_index = symbol;
} }
...@@ -1110,25 +1110,25 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -1110,25 +1110,25 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
start_meas(&gNB->ulsch_rbs_extraction_stats); start_meas(&gNB->ulsch_rbs_extraction_stats);
nr_ulsch_extract_rbs_single(gNB->common_vars.rxdataF, nr_ulsch_extract_rbs_single(gNB->common_vars.rxdataF,
gNB->pusch_vars[UE_id], gNB->pusch_vars[ulsch_id],
symbol, symbol,
dmrs_symbol_flag, dmrs_symbol_flag,
rel15_ul, rel15_ul,
frame_parms); frame_parms);
stop_meas(&gNB->ulsch_rbs_extraction_stats); stop_meas(&gNB->ulsch_rbs_extraction_stats);
nr_ulsch_scale_channel(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext, nr_ulsch_scale_channel(gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext,
frame_parms, frame_parms,
gNB->ulsch[UE_id], gNB->ulsch[ulsch_id],
symbol, symbol,
dmrs_symbol_flag, dmrs_symbol_flag,
rel15_ul->rb_size, rel15_ul->rb_size,
rel15_ul->dmrs_config_type); rel15_ul->dmrs_config_type);
if (gNB->pusch_vars[UE_id]->cl_done==0) { if (gNB->pusch_vars[ulsch_id]->cl_done==0) {
nr_ulsch_channel_level(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext, nr_ulsch_channel_level(gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext,
frame_parms, frame_parms,
avg, avg,
symbol, symbol,
...@@ -1141,26 +1141,26 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -1141,26 +1141,26 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++)
avgs = cmax(avgs,avg[(aatx<<1)+aarx]); avgs = cmax(avgs,avg[(aatx<<1)+aarx]);
gNB->pusch_vars[UE_id]->log2_maxh = (log2_approx(avgs)/2)+1; gNB->pusch_vars[ulsch_id]->log2_maxh = (log2_approx(avgs)/2)+1;
gNB->pusch_vars[UE_id]->cl_done = 1; gNB->pusch_vars[ulsch_id]->cl_done = 1;
} }
start_meas(&gNB->ulsch_channel_compensation_stats); start_meas(&gNB->ulsch_channel_compensation_stats);
nr_ulsch_channel_compensation(gNB->pusch_vars[UE_id]->rxdataF_ext, nr_ulsch_channel_compensation(gNB->pusch_vars[ulsch_id]->rxdataF_ext,
gNB->pusch_vars[UE_id]->ul_ch_estimates_ext, gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext,
gNB->pusch_vars[UE_id]->ul_ch_mag0, gNB->pusch_vars[ulsch_id]->ul_ch_mag0,
gNB->pusch_vars[UE_id]->ul_ch_magb0, gNB->pusch_vars[ulsch_id]->ul_ch_magb0,
gNB->pusch_vars[UE_id]->rxdataF_comp, gNB->pusch_vars[ulsch_id]->rxdataF_comp,
(frame_parms->nb_antennas_tx>1) ? gNB->pusch_vars[UE_id]->rho : NULL, (frame_parms->nb_antennas_tx>1) ? gNB->pusch_vars[ulsch_id]->rho : NULL,
frame_parms, frame_parms,
symbol, symbol,
dmrs_symbol_flag, dmrs_symbol_flag,
rel15_ul->qam_mod_order, rel15_ul->qam_mod_order,
rel15_ul->rb_size, rel15_ul->rb_size,
gNB->pusch_vars[UE_id]->log2_maxh); gNB->pusch_vars[ulsch_id]->log2_maxh);
stop_meas(&gNB->ulsch_channel_compensation_stats); stop_meas(&gNB->ulsch_channel_compensation_stats);
#ifdef NR_SC_FDMA #ifdef NR_SC_FDMA
nr_idft(&((uint32_t*)gNB->pusch_vars[UE_id]->rxdataF_ext[0])[symbol * rel15_ul->rb_size * NR_NB_SC_PER_RB], nb_re_pusch); nr_idft(&((uint32_t*)gNB->pusch_vars[ulsch_id]->rxdataF_ext[0])[symbol * rel15_ul->rb_size * NR_NB_SC_PER_RB], nb_re_pusch);
#endif #endif
//---------------------------------------------------------- //----------------------------------------------------------
...@@ -1168,10 +1168,10 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -1168,10 +1168,10 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
//---------------------------------------------------------- //----------------------------------------------------------
start_meas(&gNB->ulsch_llr_stats); start_meas(&gNB->ulsch_llr_stats);
nr_ulsch_compute_llr(&gNB->pusch_vars[UE_id]->rxdataF_comp[0][symbol * rel15_ul->rb_size * NR_NB_SC_PER_RB], nr_ulsch_compute_llr(&gNB->pusch_vars[ulsch_id]->rxdataF_comp[0][symbol * rel15_ul->rb_size * NR_NB_SC_PER_RB],
gNB->pusch_vars[UE_id]->ul_ch_mag0, gNB->pusch_vars[ulsch_id]->ul_ch_mag0,
gNB->pusch_vars[UE_id]->ul_ch_magb0, gNB->pusch_vars[ulsch_id]->ul_ch_magb0,
&gNB->pusch_vars[UE_id]->llr[gNB->pusch_vars[UE_id]->rxdataF_ext_offset * rel15_ul->qam_mod_order], &gNB->pusch_vars[ulsch_id]->llr[gNB->pusch_vars[ulsch_id]->rxdataF_ext_offset * rel15_ul->qam_mod_order],
rel15_ul->rb_size, rel15_ul->rb_size,
nb_re_pusch, nb_re_pusch,
symbol, symbol,
...@@ -1180,6 +1180,6 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -1180,6 +1180,6 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
} }
gNB->pusch_vars[UE_id]->rxdataF_ext_offset = gNB->pusch_vars[UE_id]->rxdataF_ext_offset + nb_re_pusch; gNB->pusch_vars[ulsch_id]->rxdataF_ext_offset = gNB->pusch_vars[ulsch_id]->rxdataF_ext_offset + nb_re_pusch;
} }
...@@ -114,7 +114,7 @@ int main(int argc, char **argv) ...@@ -114,7 +114,7 @@ int main(int argc, char **argv)
double sigma, sigma_dB; double sigma, sigma_dB;
double snr_step = 1; double snr_step = 1;
uint8_t snr1set = 0; uint8_t snr1set = 0;
int slot = 0, frame = 0; int slot = 17, frame = 0;
FILE *output_fd = NULL; FILE *output_fd = NULL;
//uint8_t write_output_file = 0; //uint8_t write_output_file = 0;
int trial, n_trials = 1, n_errors = 0, n_false_positive = 0, delay = 0; int trial, n_trials = 1, n_errors = 0, n_false_positive = 0, delay = 0;
...@@ -147,12 +147,13 @@ int main(int argc, char **argv) ...@@ -147,12 +147,13 @@ int main(int argc, char **argv)
float target_error_rate = 0.01; float target_error_rate = 0.01;
int print_perf = 0; int print_perf = 0;
cpuf = get_cpu_freq_GHz(); cpuf = get_cpu_freq_GHz();
int msg3_flag = 0;
UE_nr_rxtx_proc_t UE_proc; UE_nr_rxtx_proc_t UE_proc;
FILE *scg_fd=NULL; FILE *scg_fd=NULL;
int ibwp_size=24;
int ibwp_rboffset=41;
if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0 ) { if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0 ) {
exit_fun("[NR_ULSIM] Error, configuration module init failed\n"); exit_fun("[NR_ULSIM] Error, configuration module init failed\n");
} }
...@@ -160,202 +161,226 @@ int main(int argc, char **argv) ...@@ -160,202 +161,226 @@ int main(int argc, char **argv)
//logInit(); //logInit();
randominit(0); randominit(0);
while ((c = getopt(argc, argv, "d:f:g:h:i:j:l:m:n:p:r:s:y:z:F:M:N:PR:S:L:")) != -1) { while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:i:j:kl:m:n:p:r:s:y:z:F:M:N:PR:S:L:")) != -1) {
printf("handling optarg %c\n",c);
switch (c) { switch (c) {
/*case 'd': /*case 'd':
frame_type = 1; frame_type = 1;
break;*/ break;*/
case 'd': case 'a':
delay = atoi(optarg); start_symbol = atoi(optarg);
break; AssertFatal(start_symbol >= 0 && start_symbol < 13,"start_symbol %d is not in 0..12\n",start_symbol);
break;
case 'f':
scg_fd = fopen(optarg, "r"); case 'b':
nb_symb_sch = atoi(optarg);
if (scg_fd == NULL) { AssertFatal(nb_symb_sch > 0 && nb_symb_sch < 15,"start_symbol %d is not in 1..14\n",nb_symb_sch);
printf("Error opening %s\n", optarg); break;
exit(-1); case 'c':
} n_rnti = atoi(optarg);
AssertFatal(n_rnti > 0 && n_rnti<=65535,"Illegal n_rnti %x\n",n_rnti);
break; break;
case 'g': case 'd':
switch ((char) *optarg) { delay = atoi(optarg);
case 'A': break;
channel_model = SCM_A;
break; case 'e':
msg3_flag = 1;
case 'B': break;
channel_model = SCM_B;
break; case 'f':
scg_fd = fopen(optarg, "r");
case 'C':
channel_model = SCM_C; if (scg_fd == NULL) {
break; printf("Error opening %s\n", optarg);
exit(-1);
case 'D': }
channel_model = SCM_D;
break;
case 'E':
channel_model = EPA;
break;
case 'F':
channel_model = EVA;
break;
case 'G':
channel_model = ETU;
break;
default:
printf("Unsupported channel model!\n");
exit(-1);
}
break;
break;
case 'g':
switch ((char) *optarg) {
case 'A':
channel_model = SCM_A;
break;
case 'B':
channel_model = SCM_B;
break;
case 'C':
channel_model = SCM_C;
break;
case 'D':
channel_model = SCM_D;
break;
case 'E':
channel_model = EPA;
break;
case 'F':
channel_model = EVA;
break;
case 'G':
channel_model = ETU;
break;
default:
printf("Unsupported channel model!\n");
exit(-1);
}
break;
/*case 'i': /*case 'i':
interf1 = atoi(optarg); interf1 = atoi(optarg);
break; break;
case 'j': case 'j':
interf2 = atoi(optarg); interf2 = atoi(optarg);
break;*/ break;*/
case 'l': case 'k':
nb_symb_sch = atoi(optarg); printf("Setting threequarter_fs_flag\n");
break; openair0_cfg[0].threequarter_fs= 1;
break;
case 'm':
Imcs = atoi(optarg);
break;
case 'n':
n_trials = atoi(optarg);
break;
case 'p':
extended_prefix_flag = 1;
break;
case 'r':
nb_rb = atoi(optarg);
break;
case 's':
snr0 = atof(optarg);
printf("Setting SNR0 to %f\n", snr0);
break;
case 'l':
nb_symb_sch = atoi(optarg);
break;
case 'm':
Imcs = atoi(optarg);
break;
case 'n':
n_trials = atoi(optarg);
break;
case 'p':
extended_prefix_flag = 1;
break;
case 'r':
nb_rb = atoi(optarg);
break;
case 's':
snr0 = atof(optarg);
printf("Setting SNR0 to %f\n", snr0);
break;
/* /*
case 'r': case 'r':
ricean_factor = pow(10,-.1*atof(optarg)); ricean_factor = pow(10,-.1*atof(optarg));
if (ricean_factor>1) { if (ricean_factor>1) {
printf("Ricean factor must be between 0 and 1\n"); printf("Ricean factor must be between 0 and 1\n");
exit(-1); exit(-1);
} }
break; break;
*/ */
/*case 'x': /*case 'x':
transmission_mode = atoi(optarg); transmission_mode = atoi(optarg);
break;*/ break;*/
case 'y': case 'y':
n_tx = atoi(optarg); n_tx = atoi(optarg);
if ((n_tx == 0) || (n_tx > 2)) { if ((n_tx == 0) || (n_tx > 2)) {
printf("Unsupported number of tx antennas %d\n", n_tx); printf("Unsupported number of tx antennas %d\n", n_tx);
exit(-1); exit(-1);
} }
break; break;
case 'z': case 'z':
n_rx = atoi(optarg); n_rx = atoi(optarg);
if ((n_rx == 0) || (n_rx > 2)) { if ((n_rx == 0) || (n_rx > 2)) {
printf("Unsupported number of rx antennas %d\n", n_rx); printf("Unsupported number of rx antennas %d\n", n_rx);
exit(-1); exit(-1);
} }
break; break;
case 'F': case 'F':
input_fd = fopen(optarg, "r"); input_fd = fopen(optarg, "r");
if (input_fd == NULL) { if (input_fd == NULL) {
printf("Problem with filename %s\n", optarg); printf("Problem with filename %s\n", optarg);
exit(-1); exit(-1);
} }
break; break;
case 'M': case 'M':
SSB_positions = atoi(optarg); SSB_positions = atoi(optarg);
break; break;
case 'N': case 'N':
Nid_cell = atoi(optarg); Nid_cell = atoi(optarg);
break; break;
case 'R': case 'R':
N_RB_DL = atoi(optarg); N_RB_DL = atoi(optarg);
N_RB_UL = N_RB_DL; N_RB_UL = N_RB_DL;
break; break;
case 'S': case 'S':
snr1 = atof(optarg); snr1 = atof(optarg);
snr1set = 1; snr1set = 1;
printf("Setting SNR1 to %f\n", snr1); printf("Setting SNR1 to %f\n", snr1);
break; break;
case 'P': case 'P':
print_perf=1; print_perf=1;
opp_enabled=1; opp_enabled=1;
break; break;
case 'L': case 'L':
loglvl = atoi(optarg); loglvl = atoi(optarg);
break; break;
default: default:
case 'h': case 'h':
printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]);
//printf("-d Use TDD\n"); //printf("-d Use TDD\n");
printf("-d Introduce delay in terms of number of samples\n"); printf("-d Introduce delay in terms of number of samples\n");
printf("-f Number of frames to simulate\n"); printf("-f Number of frames to simulate\n");
printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n"); printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n");
printf("-h This message\n"); printf("-h This message\n");
//printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n");
//printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n");
printf("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if ending SNR isn't given\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if ending SNR isn't given\n");
printf("-m MCS value\n"); printf("-m MCS value\n");
printf("-n Number of trials to simulate\n"); printf("-n Number of trials to simulate\n");
printf("-p Use extended prefix mode\n"); printf("-p Use extended prefix mode\n");
printf("-t Delay spread for multipath channel\n"); printf("-t Delay spread for multipath channel\n");
//printf("-x Transmission mode (1,2,6 for the moment)\n"); //printf("-x Transmission mode (1,2,6 for the moment)\n");
printf("-y Number of TX antennas used in eNB\n"); printf("-y Number of TX antennas used in eNB\n");
printf("-z Number of RX antennas used in UE\n"); printf("-z Number of RX antennas used in UE\n");
printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n");
//printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n");
printf("-F Input filename (.txt format) for RX conformance testing\n"); printf("-F Input filename (.txt format) for RX conformance testing\n");
printf("-G raw file containing RRC configuration (generated by gNB)\n"); printf("-G raw file containing RRC configuration (generated by gNB)\n");
printf("-M Multiple SSB positions in burst\n"); printf("-M Multiple SSB positions in burst\n");
printf("-N Nid_cell\n"); printf("-N Nid_cell\n");
printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-O oversampling factor (1,2,4,8,16)\n");
printf("-R N_RB_DL\n"); printf("-R N_RB_DL\n");
printf("-S Ending SNR, runs from SNR0 to SNR1\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n");
printf("-P Print ULSCH performances\n"); printf("-P Print ULSCH performances\n");
exit(-1); exit(-1);
break; break;
} }
} }
logInit(); logInit();
set_glog(loglvl); set_glog(loglvl);
T_stdout = 1; T_stdout = 1;
...@@ -387,12 +412,15 @@ int main(int argc, char **argv) ...@@ -387,12 +412,15 @@ int main(int argc, char **argv)
gNB->UL_INFO.rx_ind.number_of_pdus = 0; gNB->UL_INFO.rx_ind.number_of_pdus = 0;
gNB->UL_INFO.crc_ind.number_crcs = 0; gNB->UL_INFO.crc_ind.number_crcs = 0;
frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
frame_parms->nb_antennas_tx = n_tx; frame_parms->nb_antennas_tx = n_tx;
frame_parms->nb_antennas_rx = n_rx; frame_parms->nb_antennas_rx = n_rx;
frame_parms->N_RB_DL = N_RB_DL; frame_parms->N_RB_DL = N_RB_DL;
frame_parms->N_RB_UL = N_RB_UL; frame_parms->N_RB_UL = N_RB_UL;
frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL; frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL;
RC.nb_nr_macrlc_inst = 1; RC.nb_nr_macrlc_inst = 1;
RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int)); RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int));
for (i = 0; i < RC.nb_nr_macrlc_inst; i++) for (i = 0; i < RC.nb_nr_macrlc_inst; i++)
...@@ -421,6 +449,7 @@ int main(int argc, char **argv) ...@@ -421,6 +449,7 @@ int main(int argc, char **argv)
xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup); xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup);
AssertFatal((gNB->if_inst = NR_IF_Module_init(0))!=NULL,"Cannot register interface"); AssertFatal((gNB->if_inst = NR_IF_Module_init(0))!=NULL,"Cannot register interface");
gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; gNB->if_inst->NR_PHY_config_req = nr_phy_config_request;
// common configuration // common configuration
rrc_mac_config_req_gNB(0,0,1,scc,0,0,NULL); rrc_mac_config_req_gNB(0,0,1,scc,0,0,NULL);
...@@ -429,6 +458,10 @@ int main(int argc, char **argv) ...@@ -429,6 +458,10 @@ int main(int argc, char **argv)
phy_init_nr_gNB(gNB,0,0); phy_init_nr_gNB(gNB,0,0);
N_RB_DL = gNB->frame_parms.N_RB_DL; N_RB_DL = gNB->frame_parms.N_RB_DL;
NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[0];
//crcTableInit(); //crcTableInit();
//nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_UL, mu, Nid_cell, SSB_positions); //nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_UL, mu, Nid_cell, SSB_positions);
...@@ -570,6 +603,25 @@ int main(int argc, char **argv) ...@@ -570,6 +603,25 @@ int main(int argc, char **argv)
UL_tti_req->pdus_list[0].pdu_size = sizeof(nfapi_nr_pusch_pdu_t); UL_tti_req->pdus_list[0].pdu_size = sizeof(nfapi_nr_pusch_pdu_t);
memset(pusch_pdu,0,sizeof(nfapi_nr_pusch_pdu_t)); memset(pusch_pdu,0,sizeof(nfapi_nr_pusch_pdu_t));
int abwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275);
int abwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275);
int ibwp_size = ibwp_size;
int ibwp_start = ibwp_rboffset;
if (msg3_flag == 1) {
if ((ibwp_start < abwp_start) || (ibwp_size > abwp_size))
pusch_pdu->bwp_start = abwp_start;
else
pusch_pdu->bwp_start = ibwp_start;
pusch_pdu->bwp_size = ibwp_size;
start_rb += (ibwp_start - abwp_start);
printf("msg3: ibwp_size %d, abwp_size %d, ibwp_start %d, abwp_start %d\n",
ibwp_size,abwp_size,ibwp_start,abwp_start);
}
else {
pusch_pdu->bwp_start = abwp_start;
pusch_pdu->bwp_size = abwp_size;
}
pusch_pdu->pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA; pusch_pdu->pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA;
pusch_pdu->rnti = n_rnti; pusch_pdu->rnti = n_rnti;
pusch_pdu->mcs_index = Imcs; pusch_pdu->mcs_index = Imcs;
...@@ -577,12 +629,14 @@ int main(int argc, char **argv) ...@@ -577,12 +629,14 @@ int main(int argc, char **argv)
pusch_pdu->target_code_rate = code_rate; pusch_pdu->target_code_rate = code_rate;
pusch_pdu->qam_mod_order = mod_order; pusch_pdu->qam_mod_order = mod_order;
pusch_pdu->transform_precoding = 0; pusch_pdu->transform_precoding = 0;
pusch_pdu->data_scrambling_id = 0; pusch_pdu->data_scrambling_id = *scc->physCellId;
pusch_pdu->nrOfLayers = 1; pusch_pdu->nrOfLayers = 1;
pusch_pdu->ul_dmrs_symb_pos = 1; pusch_pdu->ul_dmrs_symb_pos = (1<<start_symbol);
pusch_pdu->dmrs_config_type = 0; pusch_pdu->dmrs_config_type = 0;
pusch_pdu->ul_dmrs_scrambling_id = 0; pusch_pdu->ul_dmrs_scrambling_id = *scc->physCellId;
pusch_pdu->scid = 0; pusch_pdu->scid = 0;
pusch_pdu->dmrs_ports = 1;
pusch_pdu->num_dmrs_cdm_grps_no_data = 2;
pusch_pdu->resource_alloc = 1; pusch_pdu->resource_alloc = 1;
pusch_pdu->rb_start = start_rb; pusch_pdu->rb_start = start_rb;
pusch_pdu->rb_size = nb_rb; pusch_pdu->rb_size = nb_rb;
...@@ -626,62 +680,98 @@ int main(int argc, char **argv) ...@@ -626,62 +680,98 @@ int main(int argc, char **argv)
//there are plenty of other parameters that we don't seem to be using for now. e.g. //there are plenty of other parameters that we don't seem to be using for now. e.g.
//ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.absolute_delta_PUSCH = 0; //ul_config.ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.absolute_delta_PUSCH = 0;
// set FAPI parameters for UE, put them in the scheduled response and call if (input_fd != NULL) {
nr_ue_scheduled_response(&scheduled_response); // set FAPI parameters for UE, put them in the scheduled response and call
nr_ue_scheduled_response(&scheduled_response);
/////////////////////////phy_procedures_nr_ue_TX///////////////////////
/////////// /////////////////////////phy_procedures_nr_ue_TX///////////////////////
///////////
phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0);
phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0);
if (n_trials==1)
LOG_M("txsig0.m","txs0", UE->common_vars.txdata[0],frame_length_complex_samples,1,1); if (n_trials==1)
LOG_M("txsig0.m","txs0", UE->common_vars.txdata[0],frame_length_complex_samples,1,1);
///////////
//////////////////////////////////////////////////// ///////////
tx_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0); ////////////////////////////////////////////////////
tx_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);
txlev = signal_energy(&UE->common_vars.txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0],
frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); txlev = signal_energy(&UE->common_vars.txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0],
frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples);
txlev_float = (double)txlev; // output of signal_energy is fixed point representation
txlev_float = (double)txlev; // output of signal_energy is fixed point representation
n_errors = 0;
n_false_positive = 0; n_errors = 0;
n_false_positive = 0;
//AWGN
sigma_dB = 10*log10(txlev_float)-SNR; //AWGN
sigma = pow(10,sigma_dB/10); sigma_dB = 10*log10(txlev_float)-SNR;
sigma = pow(10,sigma_dB/10);
}
else n_trials = 1;
for (trial = 0; trial < n_trials; trial++) { for (trial = 0; trial < n_trials; trial++) {
errors_scrambling = 0; errors_scrambling = 0;
errors_decoding = 0; errors_decoding = 0;
//---------------------------------------------------------- //----------------------------------------------------------
//------------------------ add noise ----------------------- //------------------------ add noise -----------------------
//---------------------------------------------------------- //----------------------------------------------------------
for (i=0; i<frame_length_complex_samples; i++) { if (input_fd == NULL ) {
for (ap=0; ap<frame_parms->nb_antennas_rx; ap++) { for (i=0; i<frame_length_complex_samples; i++) {
((short*) gNB->common_vars.rxdata[ap])[(2*i) + (delay*2)] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)); // convert to fixed point for (ap=0; ap<frame_parms->nb_antennas_rx; ap++) {
((short*) gNB->common_vars.rxdata[ap])[2*i+1 + (delay*2)] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)); ((short*) gNB->common_vars.rxdata[ap])[(2*i) + (delay*2)] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)); // convert to fixed point
} ((short*) gNB->common_vars.rxdata[ap])[2*i+1 + (delay*2)] = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0));
} }
//////////////////////////////////////////////////////////// }
}
//---------------------------------------------------------- else {
//------------------- gNB phy procedures ------------------- AssertFatal(frame_parms->nb_antennas_rx == 1, "nb_ant != 1\n");
//---------------------------------------------------------- // 800 samples is N_TA_OFFSET for FR1 @ 30.72 Ms/s,
gNB->UL_INFO.rx_ind.number_of_pdus = 0; AssertFatal(frame_parms->subcarrier_spacing==30000,"only 30 kHz for file input for now (%d)\n",frame_parms->subcarrier_spacing);
gNB->UL_INFO.crc_ind.number_crcs = 0; double factor = 1;
if (openair0_cfg[0].threequarter_fs== 1) factor =.75;
int ta_offset=1600;
if (N_RB_DL <217) ta_offset=800;
else if (N_RB_DL < 106) ta_offset = 400;
int slot_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);// - (int)(800*factor);
int slot_length = slot_offset - frame_parms->get_samples_slot_timestamp(slot-1,frame_parms,0);
fread((void*)&gNB->common_vars.rxdata[0][slot_offset],
sizeof(int16_t),
slot_length<<1,
input_fd);
for (int i=0;i<16;i+=2) printf("slot_offset %d : %d,%d\n",
slot_offset,
((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[i],
((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[1+i]);
fclose(input_fd);
}
////////////////////////////////////////////////////////////
//----------------------------------------------------------
//------------------- gNB phy procedures -------------------
//----------------------------------------------------------
gNB->UL_INFO.rx_ind.number_of_pdus = 0;
gNB->UL_INFO.crc_ind.number_crcs = 0;
start_meas(&gNB->phy_proc_rx); start_meas(&gNB->phy_proc_rx);
phy_procedures_gNB_common_RX(gNB, frame, slot); phy_procedures_gNB_common_RX(gNB, frame, slot);
if (n_trials==1) if (n_trials==1) {
LOG_M("rxsigF0.m","rxsF0",gNB->common_vars.rxdataF[0],frame_length_complex_samples_no_prefix,1,1); LOG_M("rxsigF0.m","rxsF0",gNB->common_vars.rxdataF[0]+start_symbol*frame_parms->ofdm_symbol_size,nb_symb_sch*frame_parms->ofdm_symbol_size,1,1);
}
phy_procedures_gNB_uespec_RX(gNB, frame, slot); phy_procedures_gNB_uespec_RX(gNB, frame, slot);
if (n_trials == 1) {
LOG_M("rxsigF0_ext.m","rxsF0_ext",
&gNB->pusch_vars[0]->rxdataF_ext[0][(start_symbol+1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size,1,1);
LOG_M("chestF0.m","chF0",
&gNB->pusch_vars[0]->ul_ch_estimates[0][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1);
LOG_M("chestF0_ext.m","chF0_ext",
&gNB->pusch_vars[0]->ul_ch_estimates_ext[0][(start_symbol+1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size,1,1);
}
start_meas(&gNB->phy_proc_rx); start_meas(&gNB->phy_proc_rx);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
......
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