Commit 79fc7447 authored by frtabu's avatar frtabu

fix usrp problem, and some cppcheck errors

parent 10a3565d
...@@ -187,7 +187,6 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t ...@@ -187,7 +187,6 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t
// UE-specific RX processing for subframe n // UE-specific RX processing for subframe n
if (nfapi_mode == 0 || nfapi_mode == 1) */ if (nfapi_mode == 0 || nfapi_mode == 1) */
pthread_mutex_lock(&gNB->UL_INFO_mutex); pthread_mutex_lock(&gNB->UL_INFO_mutex);
gNB->UL_INFO.frame = frame_rx; gNB->UL_INFO.frame = frame_rx;
gNB->UL_INFO.slot = slot_rx; gNB->UL_INFO.slot = slot_rx;
...@@ -206,8 +205,8 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t ...@@ -206,8 +205,8 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t
if (oai_exit) return(-1); if (oai_exit) return(-1);
//if (slot_rx == NR_UPLINK_SLOT || gNB->frame_parms.frame_type == FDD) //if (slot_rx == NR_UPLINK_SLOT || gNB->frame_parms.frame_type == FDD)
phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx); phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx);
if(get_thread_parallel_conf() != PARALLEL_RU_L1_TRX_SPLIT) { if(get_thread_parallel_conf() != PARALLEL_RU_L1_TRX_SPLIT) {
phy_procedures_gNB_TX(gNB, frame_tx,slot_tx, 1); phy_procedures_gNB_TX(gNB, frame_tx,slot_tx, 1);
...@@ -907,7 +906,6 @@ void init_gNB(int single_thread_flag,int wait_for_sync) { ...@@ -907,7 +906,6 @@ void init_gNB(int single_thread_flag,int wait_for_sync) {
gNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = gNB->harq_pdu_list; gNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = gNB->harq_pdu_list;
gNB->UL_INFO.cqi_ind.cqi_pdu_list = gNB->cqi_pdu_list; gNB->UL_INFO.cqi_ind.cqi_pdu_list = gNB->cqi_pdu_list;
gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list; gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list;
gNB->prach_energy_counter = 0; gNB->prach_energy_counter = 0;
} }
} }
......
...@@ -525,8 +525,9 @@ void trashFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { ...@@ -525,8 +525,9 @@ void trashFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
dummy_rx, dummy_rx,
UE->frame_parms.samples_per_subframe, UE->frame_parms.samples_per_subframe,
UE->frame_parms.nb_antennas_rx); UE->frame_parms.nb_antennas_rx);
if (IS_SOFTMODEM_RFSIM ) { if (IS_SOFTMODEM_RFSIM ) {
usleep(1000); // slow down, as would do actuall rf to let cpu for the synchro thread usleep(1000); // slow down, as would do actuall rf to let cpu for the synchro thread
} }
} }
...@@ -681,14 +682,12 @@ void *UE_thread(void *arg) { ...@@ -681,14 +682,12 @@ void *UE_thread(void *arg) {
curMsg->proc.decoded_frame_rx=-1; curMsg->proc.decoded_frame_rx=-1;
//LOG_I(PHY,"Process slot %d thread Idx %d total gain %d\n", slot_nr, thread_idx, UE->rx_total_gain_dB); //LOG_I(PHY,"Process slot %d thread Idx %d total gain %d\n", slot_nr, thread_idx, UE->rx_total_gain_dB);
#ifdef OAI_ADRV9371_ZC706 #ifdef OAI_ADRV9371_ZC706
/*uint32_t total_gain_dB_prev = 0; /*uint32_t total_gain_dB_prev = 0;
if (total_gain_dB_prev != UE->rx_total_gain_dB) { if (total_gain_dB_prev != UE->rx_total_gain_dB) {
total_gain_dB_prev = UE->rx_total_gain_dB; total_gain_dB_prev = UE->rx_total_gain_dB;
openair0_cfg[0].rx_gain[0] = UE->rx_total_gain_dB; openair0_cfg[0].rx_gain[0] = UE->rx_total_gain_dB;
UE->rfdevice.trx_set_gains_func(&UE->rfdevice,&openair0_cfg[0]); UE->rfdevice.trx_set_gains_func(&UE->rfdevice,&openair0_cfg[0]);
}*/ }*/
#endif #endif
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
...@@ -721,17 +720,17 @@ void *UE_thread(void *arg) { ...@@ -721,17 +720,17 @@ void *UE_thread(void *arg) {
readBlockSize, readBlockSize,
UE->frame_parms.nb_antennas_rx),""); UE->frame_parms.nb_antennas_rx),"");
if (slot_nr==18) if (slot_nr==18)
AssertFatal( writeBlockSize == AssertFatal( writeBlockSize ==
UE->rfdevice.trx_write_func(&UE->rfdevice, UE->rfdevice.trx_write_func(&UE->rfdevice,
timestamp+ timestamp+
(DURATION_RX_TO_TX*UE->frame_parms.samples_per_slot) - (DURATION_RX_TO_TX*UE->frame_parms.samples_per_slot) -
UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 - UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 -
openair0_cfg[0].tx_sample_advance, openair0_cfg[0].tx_sample_advance,
txp, txp,
writeBlockSize, writeBlockSize,
UE->frame_parms.nb_antennas_tx, UE->frame_parms.nb_antennas_tx,
4),""); 4),"");
if( slot_nr==(nb_slot_frame-1)) { if( slot_nr==(nb_slot_frame-1)) {
// read in first symbol of next frame and adjust for timing drift // read in first symbol of next frame and adjust for timing drift
......
...@@ -478,24 +478,22 @@ void init_openair0(void) { ...@@ -478,24 +478,22 @@ void init_openair0(void) {
if (frame_parms[0]->threequarter_fs) { if (frame_parms[0]->threequarter_fs) {
openair0_cfg[card].sample_rate=92.16e6; openair0_cfg[card].sample_rate=92.16e6;
openair0_cfg[card].samples_per_frame = 921600; openair0_cfg[card].samples_per_frame = 921600;
} } else {
else {
openair0_cfg[card].sample_rate=122.88e6; openair0_cfg[card].sample_rate=122.88e6;
openair0_cfg[card].samples_per_frame = 1228800; openair0_cfg[card].samples_per_frame = 1228800;
} }
} else { } else {
LOG_E(PHY,"Unsupported numerology!\n"); LOG_E(PHY,"Unsupported numerology!\n");
exit(-1); exit(-1);
} }
}else if(frame_parms[0]->N_RB_DL == 273) { } else if(frame_parms[0]->N_RB_DL == 273) {
if (numerology==1) { if (numerology==1) {
if (frame_parms[0]->threequarter_fs) { if (frame_parms[0]->threequarter_fs) {
AssertFatal(0 == 1,"three quarter sampling not supported for N_RB 273\n"); AssertFatal(0 == 1,"three quarter sampling not supported for N_RB 273\n");
} } else {
else {
openair0_cfg[card].sample_rate=122.88e6; openair0_cfg[card].sample_rate=122.88e6;
openair0_cfg[card].samples_per_frame = 1228800; openair0_cfg[card].samples_per_frame = 1228800;
} }
} else { } else {
LOG_E(PHY,"Unsupported numerology!\n"); LOG_E(PHY,"Unsupported numerology!\n");
exit(-1); exit(-1);
...@@ -511,13 +509,12 @@ void init_openair0(void) { ...@@ -511,13 +509,12 @@ void init_openair0(void) {
} }
} else if (numerology==1) { } else if (numerology==1) {
if (frame_parms[0]->threequarter_fs) { if (frame_parms[0]->threequarter_fs) {
openair0_cfg[card].sample_rate=46.08e6; openair0_cfg[card].sample_rate=46.08e6;
openair0_cfg[card].samples_per_frame = 480800; openair0_cfg[card].samples_per_frame = 480800;
} } else {
else { openair0_cfg[card].sample_rate=61.44e6;
openair0_cfg[card].sample_rate=61.44e6; openair0_cfg[card].samples_per_frame = 614400;
openair0_cfg[card].samples_per_frame = 614400; }
}
} else if (numerology==2) { } else if (numerology==2) {
openair0_cfg[card].sample_rate=122.88e6; openair0_cfg[card].sample_rate=122.88e6;
openair0_cfg[card].samples_per_frame = 1228800; openair0_cfg[card].samples_per_frame = 1228800;
...@@ -534,8 +531,7 @@ void init_openair0(void) { ...@@ -534,8 +531,7 @@ void init_openair0(void) {
} else if (frame_parms[0]->N_RB_DL == 6) { } else if (frame_parms[0]->N_RB_DL == 6) {
openair0_cfg[card].sample_rate=1.92e6; openair0_cfg[card].sample_rate=1.92e6;
openair0_cfg[card].samples_per_frame = 19200; openair0_cfg[card].samples_per_frame = 19200;
} } else {
else {
LOG_E(PHY,"Unknown NB_RB %d!\n",frame_parms[0]->N_RB_DL); LOG_E(PHY,"Unknown NB_RB %d!\n",frame_parms[0]->N_RB_DL);
exit(-1); exit(-1);
} }
...@@ -620,10 +616,7 @@ int main( int argc, char **argv ) { ...@@ -620,10 +616,7 @@ int main( int argc, char **argv ) {
logInit(); logInit();
// get options and fill parameters from configuration file // get options and fill parameters from configuration file
get_options (); //Command-line options, enb_properties get_options (); //Command-line options, enb_properties
set_softmodem_optmask(SOFTMODEM_NRUE_BIT); set_softmodem_optmask(SOFTMODEM_NRUE_BIT);
#if T_TRACER #if T_TRACER
T_Config_Init(); T_Config_Init();
#endif #endif
......
...@@ -94,7 +94,7 @@ void get_common_options(void) { ...@@ -94,7 +94,7 @@ void get_common_options(void) {
} }
if (nokrnmod) { if (nokrnmod) {
printf("nokrnmod bit enabled \n"); printf("nokrnmod bit enabled \n");
set_softmodem_optmask(SOFTMODEM_NOKRNMOD_BIT); set_softmodem_optmask(SOFTMODEM_NOKRNMOD_BIT);
} }
...@@ -114,7 +114,6 @@ void get_common_options(void) { ...@@ -114,7 +114,6 @@ void get_common_options(void) {
set_softmodem_optmask(SOFTMODEM_DOFORMS_BIT); set_softmodem_optmask(SOFTMODEM_DOFORMS_BIT);
} }
if(parallel_config != NULL) set_parallel_conf(parallel_config); if(parallel_config != NULL) set_parallel_conf(parallel_config);
if(worker_config != NULL) set_worker_conf(worker_config); if(worker_config != NULL) set_worker_conf(worker_config);
......
...@@ -35,8 +35,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -35,8 +35,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
unsigned short p, unsigned short p,
unsigned char symbol, unsigned char symbol,
unsigned short bwp_start_subcarrier, unsigned short bwp_start_subcarrier,
unsigned short nb_rb_pusch) unsigned short nb_rb_pusch) {
{
int pilot[3280] __attribute__((aligned(16))); int pilot[3280] __attribute__((aligned(16)));
unsigned char aarx; unsigned char aarx;
unsigned short k; unsigned short k;
...@@ -47,86 +46,76 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -47,86 +46,76 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
unsigned short n_idDMRS[2] = {0,1}; //to update from pusch config unsigned short n_idDMRS[2] = {0,1}; //to update from pusch config
int32_t temp_in_ifft_0[8192*2] __attribute__((aligned(16))); int32_t temp_in_ifft_0[8192*2] __attribute__((aligned(16)));
int32_t **ul_ch_estimates_time = gNB->pusch_vars[UE_id]->ul_ch_estimates_time; int32_t **ul_ch_estimates_time = gNB->pusch_vars[UE_id]->ul_ch_estimates_time;
#ifdef DEBUG_CH #ifdef DEBUG_CH
FILE *debug_ch_est; FILE *debug_ch_est;
debug_ch_est = fopen("debug_ch_est.txt","w"); debug_ch_est = fopen("debug_ch_est.txt","w");
#endif #endif
//uint16_t Nid_cell = (eNB_offset == 0) ? gNB->frame_parms.Nid_cell : gNB->measurements.adj_cell_id[eNB_offset-1]; //uint16_t Nid_cell = (eNB_offset == 0) ? gNB->frame_parms.Nid_cell : gNB->measurements.adj_cell_id[eNB_offset-1];
uint8_t nushift; uint8_t nushift;
int **ul_ch_estimates = gNB->pusch_vars[UE_id]->ul_ch_estimates; int **ul_ch_estimates = gNB->pusch_vars[UE_id]->ul_ch_estimates;
int **rxdataF = gNB->common_vars.rxdataF; int **rxdataF = gNB->common_vars.rxdataF;
nushift = (p>>1)&1; nushift = (p>>1)&1;
gNB->frame_parms.nushift = nushift; gNB->frame_parms.nushift = nushift;
ch_offset = gNB->frame_parms.ofdm_symbol_size*symbol; ch_offset = gNB->frame_parms.ofdm_symbol_size*symbol;
symbol_offset = gNB->frame_parms.ofdm_symbol_size*symbol; symbol_offset = gNB->frame_parms.ofdm_symbol_size*symbol;
k = bwp_start_subcarrier; k = bwp_start_subcarrier;
int re_offset = k; int re_offset = k;
/* /*
#ifdef DEBUG_CH #ifdef DEBUG_CH
printf("PUSCH Channel Estimation : gNB_offset %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n", gNB_offset,ch_offset,symbol_offset,gNB->frame_parms.ofdm_symbol_size, printf("PUSCH Channel Estimation : gNB_offset %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n", gNB_offset,ch_offset,symbol_offset,gNB->frame_parms.ofdm_symbol_size,
gNB->frame_parms.Ncp,l,Ns,k, symbol); gNB->frame_parms.Ncp,l,Ns,k, symbol);
#endif #endif
*/ */
switch (nushift) { switch (nushift) {
case 0: case 0:
fl = filt8_l0; fl = filt8_l0;
fm = filt8_m0; fm = filt8_m0;
fr = filt8_r0; fr = filt8_r0;
fmm = filt8_mm0; fmm = filt8_mm0;
fml = filt8_m0; fml = filt8_m0;
fmr = filt8_mr0; fmr = filt8_mr0;
fdcl = filt8_dcl0; fdcl = filt8_dcl0;
fdcr = filt8_dcr0; fdcr = filt8_dcr0;
fdclh = filt8_dcl0_h; fdclh = filt8_dcl0_h;
fdcrh = filt8_dcr0_h; fdcrh = filt8_dcr0_h;
break; break;
case 1: case 1:
fl = filt8_l1; fl = filt8_l1;
fm = filt8_m1; fm = filt8_m1;
fr = filt8_r1; fr = filt8_r1;
fmm = filt8_mm1; fmm = filt8_mm1;
fml = filt8_ml1; fml = filt8_ml1;
fmr = filt8_m1; fmr = filt8_m1;
fdcl = filt8_dcl1; fdcl = filt8_dcl1;
fdcr = filt8_dcr1; fdcr = filt8_dcr1;
fdclh = filt8_dcl1_h; fdclh = filt8_dcl1_h;
fdcrh = filt8_dcr1_h; fdcrh = filt8_dcr1_h;
break; break;
default: default:
printf("pusch_channel_estimation: nushift=%d -> ERROR\n",nushift); #ifdef DEBUG_CH
return(-1); if (debug_ch_est)
break; fclose(debug_ch_est);
}
#endif
return(-1);
break;
}
//------------------generate DMRS------------------// //------------------generate DMRS------------------//
length_dmrs = 1; //to update from pusch config length_dmrs = 1; //to update from pusch config
nr_gold_pusch(gNB, symbol, n_idDMRS, length_dmrs); nr_gold_pusch(gNB, symbol, n_idDMRS, length_dmrs);
nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch[gNB_offset][Ns][0], &pilot[0], 1000, 0, nb_rb_pusch); nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch[gNB_offset][Ns][0], &pilot[0], 1000, 0, nb_rb_pusch);
//------------------------------------------------// //------------------------------------------------//
for (aarx=0; aarx<gNB->frame_parms.nb_antennas_rx; aarx++) { for (aarx=0; aarx<gNB->frame_parms.nb_antennas_rx; aarx++) {
pil = (int16_t *)&pilot[0]; pil = (int16_t *)&pilot[0];
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)];
ul_ch = (int16_t *)&ul_ch_estimates[aarx][ch_offset]; ul_ch = (int16_t *)&ul_ch_estimates[aarx][ch_offset];
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("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("k %d, first_carrier %d\n",k,gNB->frame_parms.first_carrier_offset);
...@@ -134,137 +123,119 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -134,137 +123,119 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
printf("ul_ch addr %p nushift %d\n",ul_ch,nushift); printf("ul_ch addr %p nushift %d\n",ul_ch,nushift);
#endif #endif
//if ((gNB->frame_parms.N_RB_UL&1)==0) { //if ((gNB->frame_parms.N_RB_UL&1)==0) {
// Treat first 2 pilots specially (left edge)
// Treat first 2 pilots specially (left edge) ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); 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("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) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[2],rxF[3],&rxF[2],ch[0],ch[1],pil[0],pil[1]);
#endif #endif
multadd_real_vector_complex_scalar(fl, multadd_real_vector_complex_scalar(fl,
ch, ch,
ul_ch, ul_ch,
8); 8);
pil+=2; pil+=2;
re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
//for (int i= 0; i<8; i++) //for (int i= 0; i<8; i++)
//printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i));
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#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]);
#endif
multadd_real_vector_complex_scalar(fml,
ch,
ul_ch,
8);
pil+=2;
re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
//printf("ul_ch addr %p\n",ul_ch);
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#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]);
#endif
multadd_real_vector_complex_scalar(fmm,
ch,
ul_ch,
8);
//for (int i= 0; i<16; i++)
//printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i));
pil+=2;
re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ul_ch+=8;
for (pilot_cnt=3; pilot_cnt<(6*nb_rb_pusch-3); pilot_cnt+=2) {
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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_CH
#ifdef DEBUG_PUSCH fprintf(debug_ch_est, "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 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]);
#endif #endif
multadd_real_vector_complex_scalar(fml, multadd_real_vector_complex_scalar(fm,
ch, ch,
ul_ch, ul_ch,
8); 8);
pil+=2; pil+=2;
re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
//printf("ul_ch addr %p\n",ul_ch);
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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 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 %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]);
#endif #endif
multadd_real_vector_complex_scalar(fmm, multadd_real_vector_complex_scalar(fmm,
ch, ch,
ul_ch, ul_ch,
8); 8);
//for (int i= 0; i<16; i++)
//printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i));
pil+=2; pil+=2;
re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ul_ch+=8; ul_ch+=8;
}
for (pilot_cnt=3; pilot_cnt<(6*nb_rb_pusch-3); pilot_cnt+=2) { // Treat first 2 pilots specially (right edge)
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); 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_CH
fprintf(debug_ch_est, "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("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]);
#endif
multadd_real_vector_complex_scalar(fm,
ch,
ul_ch,
8);
pil+=2;
re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>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 %d : 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,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
#endif #endif
multadd_real_vector_complex_scalar(fmm, multadd_real_vector_complex_scalar(fm,
ch, ch,
ul_ch, ul_ch,
8); 8);
pil+=2; //for (int i= 0; i<8; i++)
re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; //printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i));
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; pil+=2;
ul_ch+=8; re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
} ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
// Treat first 2 pilots specially (right edge)
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>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 %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("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]);
#endif #endif
multadd_real_vector_complex_scalar(fm, multadd_real_vector_complex_scalar(fmr,
ch, ch,
ul_ch, ul_ch,
8); 8);
pil+=2;
//for (int i= 0; i<8; i++) re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size;
//printf("ul_ch addr %p %d\n", ul_ch+i, *(ul_ch+i)); rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ul_ch+=8;
pil+=2; ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size; ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>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("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[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("pilot %d: 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]);
#endif #endif
multadd_real_vector_complex_scalar(fmr, multadd_real_vector_complex_scalar(fr,
ch, ch,
ul_ch, ul_ch,
8); 8);
pil+=2;
re_offset = (re_offset+2) % gNB->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ul_ch+=8;
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PUSCH
printf("pilot %d: 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]);
#endif
multadd_real_vector_complex_scalar(fr,
ch,
ul_ch,
8);
// check if PRB crosses DC and improve estimates around DC // check if PRB crosses DC and improve estimates around DC
if ((bwp_start_subcarrier >= gNB->frame_parms.ofdm_symbol_size/2) && (bwp_start_subcarrier+nb_rb_pusch*12 >= gNB->frame_parms.ofdm_symbol_size)) { if ((bwp_start_subcarrier >= gNB->frame_parms.ofdm_symbol_size/2) && (bwp_start_subcarrier+nb_rb_pusch*12 >= gNB->frame_parms.ofdm_symbol_size)) {
...@@ -280,111 +251,108 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -280,111 +251,108 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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);
// for proper allignment of SIMD vectors // for proper allignment of SIMD vectors
if((gNB->frame_parms.N_RB_UL&1)==0) { if((gNB->frame_parms.N_RB_UL&1)==0) {
multadd_real_vector_complex_scalar(fdcl, multadd_real_vector_complex_scalar(fdcl,
ch, ch,
ul_ch-4, ul_ch-4,
8); 8);
pil += 4; pil += 4;
re_offset = (re_offset+4) % gNB->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % gNB->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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);
multadd_real_vector_complex_scalar(fdcr, multadd_real_vector_complex_scalar(fdcr,
ch, ch,
ul_ch-4, ul_ch-4,
8); 8);
} else { } else {
multadd_real_vector_complex_scalar(fdclh, multadd_real_vector_complex_scalar(fdclh,
ch, ch,
ul_ch, ul_ch,
8); 8);
pil += 4; pil += 4;
re_offset = (re_offset+4) % gNB->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % gNB->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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);
multadd_real_vector_complex_scalar(fdcrh, multadd_real_vector_complex_scalar(fdcrh,
ch, ch,
ul_ch, ul_ch,
8); 8);
} }
} }
#ifdef DEBUG_PDSCH #ifdef DEBUG_PDSCH
ul_ch = (int16_t *)&ul_ch_estimates[aarx][ch_offset]; ul_ch = (int16_t *)&ul_ch_estimates[aarx][ch_offset];
for(uint16_t idxP=0; idxP<ceil((float)nb_rb_pusch*12/8); idxP++) { for(uint16_t idxP=0; idxP<ceil((float)nb_rb_pusch*12/8); idxP++) {
for(uint8_t idxI=0; idxI<16; idxI+=2) { for(uint8_t idxI=0; idxI<16; idxI+=2) {
printf("%d\t%d\t",ul_ch[idxP*16+idxI],ul_ch[idxP*16+idxI+1]); printf("%d\t%d\t",ul_ch[idxP*16+idxI],ul_ch[idxP*16+idxI+1]);
} }
printf("%d\n",idxP); printf("%d\n",idxP);
} }
#endif
#endif
// Convert to time domain // Convert to time domain
memset(temp_in_ifft_0, 0, gNB->frame_parms.ofdm_symbol_size*sizeof(int32_t)); memset(temp_in_ifft_0, 0, gNB->frame_parms.ofdm_symbol_size*sizeof(int32_t));
memcpy(temp_in_ifft_0, &ul_ch_estimates[aarx][symbol_offset], nb_rb_pusch * NR_NB_SC_PER_RB * sizeof(int32_t)); memcpy(temp_in_ifft_0, &ul_ch_estimates[aarx][symbol_offset], nb_rb_pusch * NR_NB_SC_PER_RB * sizeof(int32_t));
switch (gNB->frame_parms.ofdm_symbol_size) { switch (gNB->frame_parms.ofdm_symbol_size) {
case 128: case 128:
idft128((int16_t*) temp_in_ifft_0, idft128((int16_t *) temp_in_ifft_0,
(int16_t*) ul_ch_estimates_time[aarx], (int16_t *) ul_ch_estimates_time[aarx],
1); 1);
break; break;
case 256: case 256:
idft256((int16_t*) temp_in_ifft_0, idft256((int16_t *) temp_in_ifft_0,
(int16_t*) ul_ch_estimates_time[aarx], (int16_t *) ul_ch_estimates_time[aarx],
1); 1);
break; break;
case 512: case 512:
idft512((int16_t*) temp_in_ifft_0, idft512((int16_t *) temp_in_ifft_0,
(int16_t*) ul_ch_estimates_time[aarx], (int16_t *) ul_ch_estimates_time[aarx],
1); 1);
break; break;
case 1024: case 1024:
idft1024((int16_t*) temp_in_ifft_0, idft1024((int16_t *) temp_in_ifft_0,
(int16_t*) ul_ch_estimates_time[aarx], (int16_t *) ul_ch_estimates_time[aarx],
1); 1);
break; break;
case 1536: case 1536:
idft1536((int16_t*) temp_in_ifft_0, idft1536((int16_t *) temp_in_ifft_0,
(int16_t*) ul_ch_estimates_time[aarx], (int16_t *) ul_ch_estimates_time[aarx],
1); 1);
break; break;
case 2048: case 2048:
idft2048((int16_t*) temp_in_ifft_0, idft2048((int16_t *) temp_in_ifft_0,
(int16_t*) ul_ch_estimates_time[aarx], (int16_t *) ul_ch_estimates_time[aarx],
1); 1);
break; break;
case 4096: case 4096:
idft4096((int16_t*) temp_in_ifft_0, idft4096((int16_t *) temp_in_ifft_0,
(int16_t*) ul_ch_estimates_time[aarx], (int16_t *) ul_ch_estimates_time[aarx],
1); 1);
break; break;
case 8192: case 8192:
idft8192((int16_t*) temp_in_ifft_0, idft8192((int16_t *) temp_in_ifft_0,
(int16_t*) ul_ch_estimates_time[aarx], (int16_t *) ul_ch_estimates_time[aarx],
1); 1);
break; break;
default: default:
idft512((int16_t*) temp_in_ifft_0, idft512((int16_t *) temp_in_ifft_0,
(int16_t*) ul_ch_estimates_time[aarx], (int16_t *) ul_ch_estimates_time[aarx],
1); 1);
break; break;
} }
} }
...@@ -392,6 +360,5 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, ...@@ -392,6 +360,5 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
#ifdef DEBUG_CH #ifdef DEBUG_CH
fclose(debug_ch_est); fclose(debug_ch_est);
#endif #endif
return(0); return(0);
} }
...@@ -56,8 +56,7 @@ ...@@ -56,8 +56,7 @@
int16_t *base_sequence_less_than_36(unsigned int M_ZC, int16_t *base_sequence_less_than_36(unsigned int M_ZC,
unsigned int u, unsigned int u,
unsigned int scaling) unsigned int scaling) {
{
char *phi_table; char *phi_table;
int16_t *rv_overbar; int16_t *rv_overbar;
double x; double x;
...@@ -67,17 +66,22 @@ int16_t *base_sequence_less_than_36(unsigned int M_ZC, ...@@ -67,17 +66,22 @@ int16_t *base_sequence_less_than_36(unsigned int M_ZC,
case 6: case 6:
phi_table = (char *)phi_M_ZC_6; phi_table = (char *)phi_M_ZC_6;
break; break;
case 12: case 12:
phi_table = (char *)phi_M_ZC_12; phi_table = (char *)phi_M_ZC_12;
break; break;
case 18: case 18:
phi_table = (char *)phi_M_ZC_18; phi_table = (char *)phi_M_ZC_18;
break; break;
case 24: case 24:
phi_table = (char *)phi_M_ZC_24; phi_table = (char *)phi_M_ZC_24;
break; break;
case 30: case 30:
break; break;
default: default:
printf("function base_sequence_less_than 36_: unsupported base sequence size : %u \n", M_ZC); printf("function base_sequence_less_than 36_: unsupported base sequence size : %u \n", M_ZC);
abort(); abort();
...@@ -97,14 +101,14 @@ int16_t *base_sequence_less_than_36(unsigned int M_ZC, ...@@ -97,14 +101,14 @@ int16_t *base_sequence_less_than_36(unsigned int M_ZC,
rv_overbar[2*n] =(int16_t)(floor(scaling*cos(x))); rv_overbar[2*n] =(int16_t)(floor(scaling*cos(x)));
rv_overbar[2*n+1] =(int16_t)(floor(scaling*sin(x))); rv_overbar[2*n+1] =(int16_t)(floor(scaling*sin(x)));
} }
} } else {
else {
for (n=0; n<M_ZC; n++) { for (n=0; n<M_ZC; n++) {
x = (double)phi_table[n + u*M_ZC] * (M_PI/4); x = (double)phi_table[n + u*M_ZC] * (M_PI/4);
rv_overbar[2*n] = (int16_t)(floor(scaling*cos(x))); rv_overbar[2*n] = (int16_t)(floor(scaling*cos(x)));
rv_overbar[2*n+1] = (int16_t)(floor(scaling*sin(x))); rv_overbar[2*n+1] = (int16_t)(floor(scaling*sin(x)));
} }
} }
return rv_overbar; return rv_overbar;
} }
...@@ -126,22 +130,20 @@ int16_t *base_sequence_less_than_36(unsigned int M_ZC, ...@@ -126,22 +130,20 @@ int16_t *base_sequence_less_than_36(unsigned int M_ZC,
int16_t *base_sequence_36_or_larger(unsigned int Msc_RS, int16_t *base_sequence_36_or_larger(unsigned int Msc_RS,
unsigned int u, unsigned int u,
unsigned int v, unsigned int v,
unsigned int scaling) unsigned int scaling) {
{
int16_t *rv_overbar; int16_t *rv_overbar;
unsigned int N_ZC; unsigned int N_ZC;
double q_overbar, x; double q_overbar, x;
unsigned int q,m,n; unsigned int q,m,n;
unsigned int M_ZC = ul_allocated_re[Msc_RS]; unsigned int M_ZC = ul_allocated_re[Msc_RS];
rv_overbar = malloc16(IQ_SIZE*M_ZC); rv_overbar = malloc16(IQ_SIZE*M_ZC);
if (rv_overbar == NULL) { if (rv_overbar == NULL) {
msg("Fatal memory allocation problem \n"); msg("Fatal memory allocation problem \n");
assert(0); assert(0);
} }
N_ZC = ref_ul_primes[Msc_RS]; /* The length N_ZC is given by the largest prime number such that N_ZC < M_ZC */ N_ZC = ref_ul_primes[Msc_RS]; /* The length N_ZC is given by the largest prime number such that N_ZC < M_ZC */
q_overbar = N_ZC * (u+1)/(double)31; q_overbar = N_ZC * (u+1)/(double)31;
/* q = (q_overbar + 1/2) + v.(-1)^(2q_overbar) */ /* q = (q_overbar + 1/2) + v.(-1)^(2q_overbar) */
...@@ -156,6 +158,7 @@ int16_t *base_sequence_36_or_larger(unsigned int Msc_RS, ...@@ -156,6 +158,7 @@ int16_t *base_sequence_36_or_larger(unsigned int Msc_RS,
rv_overbar[2*n] = (int16_t)(floor(scaling*cos(M_PI*x))); /* cos(-x) = cos(x) */ rv_overbar[2*n] = (int16_t)(floor(scaling*cos(M_PI*x))); /* cos(-x) = cos(x) */
rv_overbar[2*n+1] = -(int16_t)(floor(scaling*sin(M_PI*x))); /* sin(-x) = -sin(x) */ rv_overbar[2*n+1] = -(int16_t)(floor(scaling*sin(M_PI*x))); /* sin(-x) = -sin(x) */
} }
return rv_overbar; return rv_overbar;
} }
...@@ -173,19 +176,16 @@ int16_t *base_sequence_36_or_larger(unsigned int Msc_RS, ...@@ -173,19 +176,16 @@ int16_t *base_sequence_36_or_larger(unsigned int Msc_RS,
* *
*********************************************************************/ *********************************************************************/
void generate_ul_reference_signal_sequences(unsigned int scaling) void generate_ul_reference_signal_sequences(unsigned int scaling) {
{ unsigned int u,v,Msc_RS;
unsigned int u,v,Msc_RS;
#if 0 #if 0
char output_file[255];
char output_file[255]; char sequence_name[255];
char sequence_name[255];
#endif #endif
for (Msc_RS=0; Msc_RS <= INDEX_SB_LESS_32; Msc_RS++) { for (Msc_RS=0; Msc_RS <= INDEX_SB_LESS_32; Msc_RS++) {
v = 0; v = 0;
for (u=0; u < U_GROUP_NUMBER; u++) { for (u=0; u < U_GROUP_NUMBER; u++) {
rv_ul_ref_sig[u][v][Msc_RS] = base_sequence_less_than_36(ul_allocated_re[Msc_RS], u, scaling); rv_ul_ref_sig[u][v][Msc_RS] = base_sequence_less_than_36(ul_allocated_re[Msc_RS], u, scaling);
#if 0 #if 0
...@@ -193,7 +193,6 @@ void generate_ul_reference_signal_sequences(unsigned int scaling) ...@@ -193,7 +193,6 @@ void generate_ul_reference_signal_sequences(unsigned int scaling)
sprintf(sequence_name, "rv_seq_%d_%d_%d.m", u, v, ul_allocated_re[Msc_RS]); sprintf(sequence_name, "rv_seq_%d_%d_%d.m", u, v, ul_allocated_re[Msc_RS]);
printf("u %d Msc_RS %d allocate memory %x of size %d \n", u, Msc_RS, rv_ul_ref_sig[u][v][Msc_RS], (IQ_SIZE* ul_allocated_re[Msc_RS])); printf("u %d Msc_RS %d allocate memory %x of size %d \n", u, Msc_RS, rv_ul_ref_sig[u][v][Msc_RS], (IQ_SIZE* ul_allocated_re[Msc_RS]));
write_output(output_file, sequence_name, rv_ul_ref_sig[u][v][Msc_RS], ul_allocated_re[Msc_RS], 1, 1); write_output(output_file, sequence_name, rv_ul_ref_sig[u][v][Msc_RS], ul_allocated_re[Msc_RS], 1, 1);
#endif #endif
} }
} }
...@@ -207,7 +206,6 @@ void generate_ul_reference_signal_sequences(unsigned int scaling) ...@@ -207,7 +206,6 @@ void generate_ul_reference_signal_sequences(unsigned int scaling)
sprintf(sequence_name, "rv_seq_%d_%d_%d.m", u, v, ul_allocated_re[Msc_RS]); sprintf(sequence_name, "rv_seq_%d_%d_%d.m", u, v, ul_allocated_re[Msc_RS]);
printf("u %d Msc_RS %d allocate memory %x of size %d \n", u, Msc_RS, rv_ul_ref_sig[u][v][Msc_RS], (IQ_SIZE* ul_allocated_re[Msc_RS])); printf("u %d Msc_RS %d allocate memory %x of size %d \n", u, Msc_RS, rv_ul_ref_sig[u][v][Msc_RS], (IQ_SIZE* ul_allocated_re[Msc_RS]));
write_output(output_file, sequence_name, rv_ul_ref_sig[u][v][Msc_RS], ul_allocated_re[Msc_RS], 1, 1); write_output(output_file, sequence_name, rv_ul_ref_sig[u][v][Msc_RS], ul_allocated_re[Msc_RS], 1, 1);
#endif #endif
} }
} }
...@@ -225,9 +223,9 @@ void generate_ul_reference_signal_sequences(unsigned int scaling) ...@@ -225,9 +223,9 @@ void generate_ul_reference_signal_sequences(unsigned int scaling)
* DESCRIPTION : free of uplink reference signal sequences * DESCRIPTION : free of uplink reference signal sequences
* *
*********************************************************************/ *********************************************************************/
void free_ul_reference_signal_sequences(void) void free_ul_reference_signal_sequences(void) {
{
unsigned int u,v,Msc_RS; unsigned int u,v,Msc_RS;
for (Msc_RS=0; Msc_RS < SRS_SB_CONF; Msc_RS++) { for (Msc_RS=0; Msc_RS < SRS_SB_CONF; Msc_RS++) {
for (u=0; u < U_GROUP_NUMBER; u++) { for (u=0; u < U_GROUP_NUMBER; u++) {
for (v=0; v < V_BASE_SEQUENCE_NUMBER; v++) { for (v=0; v < V_BASE_SEQUENCE_NUMBER; v++) {
......
...@@ -80,7 +80,7 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch, ...@@ -80,7 +80,7 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch,
time_stats_t *dlsch_modulation_stats); time_stats_t *dlsch_modulation_stats);
void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); void free_gNB_dlsch(NR_gNB_DLSCH_t **dlsch);
void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch);
......
...@@ -48,10 +48,10 @@ ...@@ -48,10 +48,10 @@
//#define DEBUG_DLSCH_CODING //#define DEBUG_DLSCH_CODING
//#define DEBUG_DLSCH_FREE 1 //#define DEBUG_DLSCH_FREE 1
void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr) {
{
int i; int i;
int r; int r;
NR_gNB_DLSCH_t *dlsch=*dlschptr;
if (dlsch) { if (dlsch) {
#ifdef DEBUG_DLSCH_FREE #ifdef DEBUG_DLSCH_FREE
...@@ -81,7 +81,6 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) ...@@ -81,7 +81,6 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch)
#endif #endif
for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++) { for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++) {
#ifdef DEBUG_DLSCH_FREE #ifdef DEBUG_DLSCH_FREE
printf("Freeing dlsch process %d c[%d] (%p)\n",i,r,dlsch->harq_processes[i]->c[r]); printf("Freeing dlsch process %d c[%d] (%p)\n",i,r,dlsch->harq_processes[i]->c[r]);
#endif #endif
...@@ -90,21 +89,21 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) ...@@ -90,21 +89,21 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch)
free16(dlsch->harq_processes[i]->c[r],1056); free16(dlsch->harq_processes[i]->c[r],1056);
dlsch->harq_processes[i]->c[r] = NULL; dlsch->harq_processes[i]->c[r] = NULL;
} }
if (dlsch->harq_processes[i]->d[r]) { if (dlsch->harq_processes[i]->d[r]) {
free16(dlsch->harq_processes[i]->d[r],3*8448); free16(dlsch->harq_processes[i]->d[r],3*8448);
dlsch->harq_processes[i]->d[r] = NULL; dlsch->harq_processes[i]->d[r] = NULL;
} }
}
} free16(dlsch->harq_processes[i],sizeof(NR_DL_gNB_HARQ_t));
free16(dlsch->harq_processes[i],sizeof(NR_DL_gNB_HARQ_t)); dlsch->harq_processes[i] = NULL;
dlsch->harq_processes[i] = NULL;
} }
} }
free16(dlsch,sizeof(NR_gNB_DLSCH_t)); free16(dlsch,sizeof(NR_gNB_DLSCH_t));
dlsch = NULL; *dlschptr = NULL;
} }
} }
NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
...@@ -112,9 +111,7 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, ...@@ -112,9 +111,7 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
uint32_t Nsoft, uint32_t Nsoft,
uint8_t abstraction_flag, uint8_t abstraction_flag,
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
nfapi_nr_config_request_t *config) nfapi_nr_config_request_t *config) {
{
NR_gNB_DLSCH_t *dlsch; NR_gNB_DLSCH_t *dlsch;
unsigned char exit_flag = 0,i,r,aa,layer; unsigned char exit_flag = 0,i,r,aa,layer;
int re; int re;
...@@ -122,14 +119,13 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, ...@@ -122,14 +119,13 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
uint16_t N_RB = config->rf_config.dl_carrier_bandwidth.value; uint16_t N_RB = config->rf_config.dl_carrier_bandwidth.value;
switch (N_RB) { switch (N_RB) {
case 106:
bw_scaling =2;
break;
case 106: default:
bw_scaling =2; bw_scaling =1;
break; break;
default:
bw_scaling =1;
break;
} }
dlsch = (NR_gNB_DLSCH_t *)malloc16(sizeof(NR_gNB_DLSCH_t)); dlsch = (NR_gNB_DLSCH_t *)malloc16(sizeof(NR_gNB_DLSCH_t));
...@@ -142,14 +138,15 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, ...@@ -142,14 +138,15 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
dlsch->Nsoft = Nsoft; dlsch->Nsoft = Nsoft;
for (layer=0; layer<NR_MAX_NB_LAYERS; layer++) { for (layer=0; layer<NR_MAX_NB_LAYERS; layer++) {
dlsch->ue_spec_bf_weights[layer] = (int32_t**)malloc16(64*sizeof(int32_t*)); dlsch->ue_spec_bf_weights[layer] = (int32_t **)malloc16(64*sizeof(int32_t *));
for (aa=0; aa<64; aa++) { for (aa=0; aa<64; aa++) {
dlsch->ue_spec_bf_weights[layer][aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t)); dlsch->ue_spec_bf_weights[layer][aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t));
for (re=0;re<OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES; re++) {
dlsch->ue_spec_bf_weights[layer][aa][re] = 0x00007fff; for (re=0; re<OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES; re++) {
} dlsch->ue_spec_bf_weights[layer][aa][re] = 0x00007fff;
} }
}
dlsch->txdataF[layer] = (int32_t *)malloc16((NR_MAX_PDSCH_ENCODED_LENGTH/NR_MAX_NB_LAYERS)*sizeof(int32_t)); // NR_MAX_NB_LAYERS is already included in NR_MAX_PDSCH_ENCODED_LENGTH dlsch->txdataF[layer] = (int32_t *)malloc16((NR_MAX_PDSCH_ENCODED_LENGTH/NR_MAX_NB_LAYERS)*sizeof(int32_t)); // NR_MAX_NB_LAYERS is already included in NR_MAX_PDSCH_ENCODED_LENGTH
} }
...@@ -157,11 +154,11 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, ...@@ -157,11 +154,11 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
for (int q=0; q<NR_MAX_NB_CODEWORDS; q++) for (int q=0; q<NR_MAX_NB_CODEWORDS; q++)
dlsch->mod_symbs[q] = (int32_t *)malloc16(NR_MAX_PDSCH_ENCODED_LENGTH*sizeof(int32_t)); dlsch->mod_symbs[q] = (int32_t *)malloc16(NR_MAX_PDSCH_ENCODED_LENGTH*sizeof(int32_t));
dlsch->calib_dl_ch_estimates = (int32_t**)malloc16(64*sizeof(int32_t*)); dlsch->calib_dl_ch_estimates = (int32_t **)malloc16(64*sizeof(int32_t *));
for (aa=0; aa<64; aa++) {
dlsch->calib_dl_ch_estimates[aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t));
} for (aa=0; aa<64; aa++) {
dlsch->calib_dl_ch_estimates[aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t));
}
for (i=0; i<20; i++) { for (i=0; i<20; i++) {
dlsch->harq_ids[0][i] = 0; dlsch->harq_ids[0][i] = 0;
...@@ -171,13 +168,14 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, ...@@ -171,13 +168,14 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
for (i=0; i<Mdlharq; i++) { for (i=0; i<Mdlharq; i++) {
dlsch->harq_processes[i] = (NR_DL_gNB_HARQ_t *)malloc16(sizeof(NR_DL_gNB_HARQ_t)); dlsch->harq_processes[i] = (NR_DL_gNB_HARQ_t *)malloc16(sizeof(NR_DL_gNB_HARQ_t));
LOG_T(PHY, "Required mem size %d (bw scaling %d), dlsch->harq_processes[%d] %p\n", LOG_T(PHY, "Required mem size %d (bw scaling %d), dlsch->harq_processes[%d] %p\n",
MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling,bw_scaling, i,dlsch->harq_processes[i]); MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling,bw_scaling, i,dlsch->harq_processes[i]);
if (dlsch->harq_processes[i]) { if (dlsch->harq_processes[i]) {
bzero(dlsch->harq_processes[i],sizeof(NR_DL_gNB_HARQ_t)); bzero(dlsch->harq_processes[i],sizeof(NR_DL_gNB_HARQ_t));
// dlsch->harq_processes[i]->first_tx=1; // dlsch->harq_processes[i]->first_tx=1;
dlsch->harq_processes[i]->b = (unsigned char*)malloc16(MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling); dlsch->harq_processes[i]->b = (unsigned char *)malloc16(MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling);
dlsch->harq_processes[i]->pdu = (uint8_t*)malloc16(MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling); dlsch->harq_processes[i]->pdu = (uint8_t *)malloc16(MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling);
if (dlsch->harq_processes[i]->pdu) { if (dlsch->harq_processes[i]->pdu) {
bzero(dlsch->harq_processes[i]->pdu,MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling); bzero(dlsch->harq_processes[i]->pdu,MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling);
nr_emulate_dlsch_payload(dlsch->harq_processes[i]->pdu, (MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling)>>3); nr_emulate_dlsch_payload(dlsch->harq_processes[i]->pdu, (MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling)>>3);
...@@ -199,14 +197,16 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, ...@@ -199,14 +197,16 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
// [hna] 8448 is the maximum CB size in NR // [hna] 8448 is the maximum CB size in NR
// 68*348 = 68*(maximum size of Zc) // 68*348 = 68*(maximum size of Zc)
// In section 5.3.2 in 38.212, the for loop is up to N + 2*Zc (maximum size of N is 66*Zc, therefore 68*Zc) // In section 5.3.2 in 38.212, the for loop is up to N + 2*Zc (maximum size of N is 66*Zc, therefore 68*Zc)
dlsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448); dlsch->harq_processes[i]->c[r] = (uint8_t *)malloc16(8448);
dlsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output dlsch->harq_processes[i]->d[r] = (uint8_t *)malloc16(68*384); //max size for coded output
if (dlsch->harq_processes[i]->c[r]) { if (dlsch->harq_processes[i]->c[r]) {
bzero(dlsch->harq_processes[i]->c[r],8448); bzero(dlsch->harq_processes[i]->c[r],8448);
} else { } else {
printf("Can't get c\n"); printf("Can't get c\n");
exit_flag=2; exit_flag=2;
} }
if (dlsch->harq_processes[i]->d[r]) { if (dlsch->harq_processes[i]->d[r]) {
bzero(dlsch->harq_processes[i]->d[r],(3*8448)); bzero(dlsch->harq_processes[i]->d[r],(3*8448));
} else { } else {
...@@ -231,16 +231,12 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, ...@@ -231,16 +231,12 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
} }
LOG_D(PHY,"new_gNB_dlsch exit flag %d, size of %ld\n", LOG_D(PHY,"new_gNB_dlsch exit flag %d, size of %ld\n",
exit_flag, sizeof(NR_gNB_DLSCH_t)); exit_flag, sizeof(NR_gNB_DLSCH_t));
free_gNB_dlsch(dlsch); free_gNB_dlsch(&dlsch);
return(NULL); return(NULL);
} }
void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) {
{
unsigned char Mdlharq; unsigned char Mdlharq;
unsigned char i,j,r; unsigned char i,j,r;
...@@ -253,17 +249,17 @@ void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) ...@@ -253,17 +249,17 @@ void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch)
dlsch->harq_ids[0][i] = Mdlharq; dlsch->harq_ids[0][i] = Mdlharq;
dlsch->harq_ids[1][i] = Mdlharq; dlsch->harq_ids[1][i] = Mdlharq;
} }
for (i=0; i<Mdlharq; i++) { for (i=0; i<Mdlharq; i++) {
if (dlsch->harq_processes[i]) { if (dlsch->harq_processes[i]) {
// dlsch->harq_processes[i]->Ndi = 0; // dlsch->harq_processes[i]->Ndi = 0;
//dlsch->harq_processes[i]->status = 0; //dlsch->harq_processes[i]->status = 0;
dlsch->harq_processes[i]->round = 0; dlsch->harq_processes[i]->round = 0;
for (j=0; j<96; j++) for (j=0; j<96; j++)
for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++) for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++)
if (dlsch->harq_processes[i]->d[r]) if (dlsch->harq_processes[i]->d[r])
dlsch->harq_processes[i]->d[r][j] = NR_NULL; dlsch->harq_processes[i]->d[r][j] = NR_NULL;
} }
} }
} }
...@@ -273,9 +269,7 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -273,9 +269,7 @@ int nr_dlsch_encoding(unsigned char *a,
int frame, int frame,
uint8_t slot, uint8_t slot,
NR_gNB_DLSCH_t *dlsch, NR_gNB_DLSCH_t *dlsch,
NR_DL_FRAME_PARMS* frame_parms) NR_DL_FRAME_PARMS *frame_parms) {
{
unsigned int G; unsigned int G;
unsigned int crc=1; unsigned int crc=1;
uint8_t harq_pid = dlsch->harq_ids[frame&2][slot]; uint8_t harq_pid = dlsch->harq_ids[frame&2][slot];
...@@ -298,26 +292,21 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -298,26 +292,21 @@ int nr_dlsch_encoding(unsigned char *a,
uint16_t length_dmrs = 1; uint16_t length_dmrs = 1;
float Coderate = 0.0; float Coderate = 0.0;
uint8_t Nl = 4; uint8_t Nl = 4;
/* /*
uint8_t *channel_input[MAX_NUM_DLSCH_SEGMENTS]; //unsigned char uint8_t *channel_input[MAX_NUM_DLSCH_SEGMENTS]; //unsigned char
for(j=0;j<MAX_NUM_DLSCH_SEGMENTS;j++) { for(j=0;j<MAX_NUM_DLSCH_SEGMENTS;j++) {
channel_input[j] = (unsigned char *)malloc16(sizeof(unsigned char) * 68*384); channel_input[j] = (unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
} }
*/ */
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN);
A = rel15.transport_block_size; A = rel15.transport_block_size;
G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,rel15.nb_layers); G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,rel15.nb_layers);
LOG_D(PHY,"dlsch coding A %d G %d mod_order %d\n", A,G, mod_order); LOG_D(PHY,"dlsch coding A %d G %d mod_order %d\n", A,G, mod_order);
// if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet // if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet
if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
printf("encoding thinks this is a new packet \n"); printf("encoding thinks this is a new packet \n");
#endif #endif
/* /*
int i; int i;
...@@ -330,55 +319,47 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -330,55 +319,47 @@ int nr_dlsch_encoding(unsigned char *a,
if (A > 3824) { if (A > 3824) {
// Add 24-bit crc (polynomial A) to payload // Add 24-bit crc (polynomial A) to payload
crc = crc24a(a,A)>>8; crc = crc24a(a,A)>>8;
a[A>>3] = ((uint8_t*)&crc)[2]; a[A>>3] = ((uint8_t *)&crc)[2];
a[1+(A>>3)] = ((uint8_t*)&crc)[1]; a[1+(A>>3)] = ((uint8_t *)&crc)[1];
a[2+(A>>3)] = ((uint8_t*)&crc)[0]; a[2+(A>>3)] = ((uint8_t *)&crc)[0];
//printf("CRC %x (A %d)\n",crc,A); //printf("CRC %x (A %d)\n",crc,A);
//printf("a0 %d a1 %d a2 %d\n", a[A>>3], a[1+(A>>3)], a[2+(A>>3)]); //printf("a0 %d a1 %d a2 %d\n", a[A>>3], a[1+(A>>3)], a[2+(A>>3)]);
dlsch->harq_processes[harq_pid]->B = A+24; dlsch->harq_processes[harq_pid]->B = A+24;
// dlsch->harq_processes[harq_pid]->b = a; // dlsch->harq_processes[harq_pid]->b = a;
AssertFatal((A/8)+4 <= MAX_DLSCH_PAYLOAD_BYTES,"A %d is too big (A/8+4 = %d > %d)\n",A,(A/8)+4,MAX_DLSCH_PAYLOAD_BYTES); AssertFatal((A/8)+4 <= MAX_DLSCH_PAYLOAD_BYTES,"A %d is too big (A/8+4 = %d > %d)\n",A,(A/8)+4,MAX_DLSCH_PAYLOAD_BYTES);
memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); // why is this +4 if the CRC is only 3 bytes? memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); // why is this +4 if the CRC is only 3 bytes?
} } else {
else {
// Add 16-bit crc (polynomial A) to payload // Add 16-bit crc (polynomial A) to payload
crc = crc16(a,A)>>16; crc = crc16(a,A)>>16;
a[A>>3] = ((uint8_t*)&crc)[1]; a[A>>3] = ((uint8_t *)&crc)[1];
a[1+(A>>3)] = ((uint8_t*)&crc)[0]; a[1+(A>>3)] = ((uint8_t *)&crc)[0];
//printf("CRC %x (A %d)\n",crc,A); //printf("CRC %x (A %d)\n",crc,A);
//printf("a0 %d a1 %d \n", a[A>>3], a[1+(A>>3)]); //printf("a0 %d a1 %d \n", a[A>>3], a[1+(A>>3)]);
dlsch->harq_processes[harq_pid]->B = A+16; dlsch->harq_processes[harq_pid]->B = A+16;
// dlsch->harq_processes[harq_pid]->b = a; // dlsch->harq_processes[harq_pid]->b = a;
AssertFatal((A/8)+3 <= MAX_DLSCH_PAYLOAD_BYTES,"A %d is too big (A/8+3 = %d > %d)\n",A,(A/8)+3,MAX_DLSCH_PAYLOAD_BYTES); AssertFatal((A/8)+3 <= MAX_DLSCH_PAYLOAD_BYTES,"A %d is too big (A/8+3 = %d > %d)\n",A,(A/8)+3,MAX_DLSCH_PAYLOAD_BYTES);
memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+3); // using 3 bytes to mimic the case of 24 bit crc memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+3); // using 3 bytes to mimic the case of 24 bit crc
} }
if (R<1000) if (R<1000)
Coderate = (float) R /(float) 1024; Coderate = (float) R /(float) 1024;
else // to scale for mcs 20 and 26 in table 5.1.3.1-2 which are decimal and input 2* in nr_tbs_tools else // to scale for mcs 20 and 26 in table 5.1.3.1-2 which are decimal and input 2* in nr_tbs_tools
Coderate = (float) R /(float) 2048; Coderate = (float) R /(float) 2048;
if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25)
BG = 2; BG = 2;
else else
BG = 1; BG = 1;
Kb = nr_segmentation(dlsch->harq_processes[harq_pid]->b, Kb = nr_segmentation(dlsch->harq_processes[harq_pid]->b,
dlsch->harq_processes[harq_pid]->c, dlsch->harq_processes[harq_pid]->c,
dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->B,
&dlsch->harq_processes[harq_pid]->C, &dlsch->harq_processes[harq_pid]->C,
&dlsch->harq_processes[harq_pid]->K, &dlsch->harq_processes[harq_pid]->K,
Zc, Zc,
&dlsch->harq_processes[harq_pid]->F, &dlsch->harq_processes[harq_pid]->F,
BG); BG);
F = dlsch->harq_processes[harq_pid]->F; F = dlsch->harq_processes[harq_pid]->F;
Kr = dlsch->harq_processes[harq_pid]->K; Kr = dlsch->harq_processes[harq_pid]->K;
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
uint16_t Kr_bytes; uint16_t Kr_bytes;
...@@ -393,51 +374,48 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -393,51 +374,48 @@ int nr_dlsch_encoding(unsigned char *a,
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
printf("Encoder: B %d F %d \n",dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->F); printf("Encoder: B %d F %d \n",dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->F);
printf("start ldpc encoder segment %d/%d\n",r,dlsch->harq_processes[harq_pid]->C); printf("start ldpc encoder segment %d/%d\n",r,dlsch->harq_processes[harq_pid]->C);
printf("input %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->c[r][0], dlsch->harq_processes[harq_pid]->c[r][1], dlsch->harq_processes[harq_pid]->c[r][2],dlsch->harq_processes[harq_pid]->c[r][3], dlsch->harq_processes[harq_pid]->c[r][4]); printf("input %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->c[r][0], dlsch->harq_processes[harq_pid]->c[r][1], dlsch->harq_processes[harq_pid]->c[r][2],dlsch->harq_processes[harq_pid]->c[r][3],
for (int cnt =0 ; cnt < 22*(*Zc)/8; cnt ++){ dlsch->harq_processes[harq_pid]->c[r][4]);
printf("%d ", dlsch->harq_processes[harq_pid]->c[r][cnt]);
for (int cnt =0 ; cnt < 22*(*Zc)/8; cnt ++) {
printf("%d ", dlsch->harq_processes[harq_pid]->c[r][cnt]);
} }
printf("\n");
printf("\n");
#endif #endif
//ldpc_encoder_orig((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],dlsch->harq_processes[harq_pid]->d[r],*Zc,Kb,Kr,BG,0); //ldpc_encoder_orig((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],dlsch->harq_processes[harq_pid]->d[r],*Zc,Kb,Kr,BG,0);
//ldpc_encoder_optim((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],(unsigned char*)&dlsch->harq_processes[harq_pid]->d[r][0],*Zc,Kb,Kr,BG,NULL,NULL,NULL,NULL); //ldpc_encoder_optim((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],(unsigned char*)&dlsch->harq_processes[harq_pid]->d[r][0],*Zc,Kb,Kr,BG,NULL,NULL,NULL,NULL);
} }
for(int j=0;j<(dlsch->harq_processes[harq_pid]->C/8+1);j++) { for(int j=0; j<(dlsch->harq_processes[harq_pid]->C/8+1); j++) {
ldpc_encoder_optim_8seg_multi(dlsch->harq_processes[harq_pid]->c,dlsch->harq_processes[harq_pid]->d,*Zc,Kb,Kr,BG,dlsch->harq_processes[harq_pid]->C,j,NULL,NULL,NULL,NULL); ldpc_encoder_optim_8seg_multi(dlsch->harq_processes[harq_pid]->c,dlsch->harq_processes[harq_pid]->d,*Zc,Kb,Kr,BG,dlsch->harq_processes[harq_pid]->C,j,NULL,NULL,NULL,NULL);
} }
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4); write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4);
write_output("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[0][0],(3*8*Kr_bytes)+12,1,4); write_output("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[0][0],(3*8*Kr_bytes)+12,1,4);
#endif #endif
} }
for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) {
if (dlsch->harq_processes[harq_pid]->F>0) { if (dlsch->harq_processes[harq_pid]->F>0) {
for (int k=(Kr-F-2*(*Zc)); k<Kr-2*(*Zc); k++) { for (int k=(Kr-F-2*(*Zc)); k<Kr-2*(*Zc); k++) {
dlsch->harq_processes[harq_pid]->d[r][k] = NR_NULL; dlsch->harq_processes[harq_pid]->d[r][k] = NR_NULL;
//if (k<(Kr-F+8)) //if (k<(Kr-F+8))
//printf("r %d filler bits [%d] = %d \n", r,k, dlsch->harq_processes[harq_pid]->d[r][k]); //printf("r %d filler bits [%d] = %d \n", r,k, dlsch->harq_processes[harq_pid]->d[r][k]);
} }
} }
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
printf("Rate Matching, Code segment %d (coded bits (G) %u, unpunctured/repeated bits per code segment %d, mod_order %d, nb_rb %d)...\n", printf("Rate Matching, Code segment %d (coded bits (G) %u, unpunctured/repeated bits per code segment %d, mod_order %d, nb_rb %d)...\n",
r, r,
G, G,
Kr*3, Kr*3,
mod_order,nb_rb); mod_order,nb_rb);
#endif #endif
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
printf("rvidx in encoding = %d\n", rel15.redundancy_version); printf("rvidx in encoding = %d\n", rel15.redundancy_version);
#endif #endif
E = nr_get_E(G, dlsch->harq_processes[harq_pid]->C, mod_order, rel15.nb_layers, r); E = nr_get_E(G, dlsch->harq_processes[harq_pid]->C, mod_order, rel15.nb_layers, r);
// for tbslbrm calculation according to 5.4.2.1 of 38.212 // for tbslbrm calculation according to 5.4.2.1 of 38.212
...@@ -445,7 +423,6 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -445,7 +423,6 @@ int nr_dlsch_encoding(unsigned char *a,
Nl = rel15.nb_layers; Nl = rel15.nb_layers;
Tbslbrm = nr_compute_tbslbrm(rel15.mcs_table,nb_rb,Nl,dlsch->harq_processes[harq_pid]->C); Tbslbrm = nr_compute_tbslbrm(rel15.mcs_table,nb_rb,Nl,dlsch->harq_processes[harq_pid]->C);
nr_rate_matching_ldpc(Ilbrm, nr_rate_matching_ldpc(Ilbrm,
Tbslbrm, Tbslbrm,
BG, BG,
...@@ -455,30 +432,28 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -455,30 +432,28 @@ int nr_dlsch_encoding(unsigned char *a,
dlsch->harq_processes[harq_pid]->C, dlsch->harq_processes[harq_pid]->C,
rel15.redundancy_version, rel15.redundancy_version,
E); E);
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
for (int i =0; i<16; i++) for (int i =0; i<16; i++)
printf("output ratematching e[%d]= %d r_offset %d\n", i,dlsch->harq_processes[harq_pid]->e[i+r_offset], r_offset); printf("output ratematching e[%d]= %d r_offset %d\n", i,dlsch->harq_processes[harq_pid]->e[i+r_offset], r_offset);
#endif
nr_interleaving_ldpc(E,
mod_order,
dlsch->harq_processes[harq_pid]->e+r_offset,
dlsch->harq_processes[harq_pid]->f+r_offset);
#endif
nr_interleaving_ldpc(E,
mod_order,
dlsch->harq_processes[harq_pid]->e+r_offset,
dlsch->harq_processes[harq_pid]->f+r_offset);
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
for (int i =0; i<16; i++) for (int i =0; i<16; i++)
printf("output interleaving f[%d]= %d r_offset %d\n", i,dlsch->harq_processes[harq_pid]->f[i+r_offset], r_offset); printf("output interleaving f[%d]= %d r_offset %d\n", i,dlsch->harq_processes[harq_pid]->f[i+r_offset], r_offset);
if (r==dlsch->harq_processes[harq_pid]->C-1) if (r==dlsch->harq_processes[harq_pid]->C-1)
write_output("enc_output.m","enc",dlsch->harq_processes[harq_pid]->f,G,1,4); write_output("enc_output.m","enc",dlsch->harq_processes[harq_pid]->f,G,1,4);
#endif
#endif
r_offset += E; r_offset += E;
} }
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT);
return 0; return 0;
} }
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "PHY/defs_gNB.h" #include "PHY/defs_gNB.h"
void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch); void free_gNB_ulsch(NR_gNB_ULSCH_t **ulsch);
NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag); NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag);
...@@ -67,11 +67,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -67,11 +67,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
@param n_RNTI, CRNTI @param n_RNTI, CRNTI
*/ */
void nr_ulsch_unscrambling(int16_t* llr, void nr_ulsch_unscrambling(int16_t *llr,
uint32_t size, uint32_t size,
uint8_t q, uint8_t q,
uint32_t Nid, uint32_t Nid,
uint32_t n_RNTI); uint32_t n_RNTI);
void nr_ulsch_procedures(PHY_VARS_gNB *gNB, void nr_ulsch_procedures(PHY_VARS_gNB *gNB,
......
...@@ -58,48 +58,49 @@ static uint64_t nb_error_decod =0; ...@@ -58,48 +58,49 @@ static uint64_t nb_error_decod =0;
//extern double cpuf; //extern double cpuf;
void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) void free_gNB_ulsch(NR_gNB_ULSCH_t **ulschptr) {
{
int i,r; int i,r;
NR_gNB_ULSCH_t *ulsch = *ulschptr;
if (ulsch) { if (ulsch) {
for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) { for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) {
if (ulsch->harq_processes[i]) { if (ulsch->harq_processes[i]) {
if (ulsch->harq_processes[i]->b) { if (ulsch->harq_processes[i]->b) {
free16(ulsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES); free16(ulsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES);
ulsch->harq_processes[i]->b = NULL; ulsch->harq_processes[i]->b = NULL;
} }
for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS; r++) { for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS; r++) {
free16(ulsch->harq_processes[i]->c[r],(8448)*sizeof(uint8_t)); free16(ulsch->harq_processes[i]->c[r],(8448)*sizeof(uint8_t));
ulsch->harq_processes[i]->c[r] = NULL; ulsch->harq_processes[i]->c[r] = NULL;
} }
for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS; r++) { for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS; r++) {
if (ulsch->harq_processes[i]->d[r]) { if (ulsch->harq_processes[i]->d[r]) {
free16(ulsch->harq_processes[i]->d[r],(68*384)*sizeof(int16_t)); free16(ulsch->harq_processes[i]->d[r],(68*384)*sizeof(int16_t));
ulsch->harq_processes[i]->d[r] = NULL; ulsch->harq_processes[i]->d[r] = NULL;
} }
} }
for (r=0; r<(MAX_NUM_NR_ULSCH_SEGMENTS); r++) { for (r=0; r<(MAX_NUM_NR_ULSCH_SEGMENTS); r++) {
if (ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]){ if (ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]) {
nrLDPC_free_mem(ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]); nrLDPC_free_mem(ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]);
ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL; ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL;
} }
} }
free16(ulsch->harq_processes[i],sizeof(NR_UL_gNB_HARQ_t)); free16(ulsch->harq_processes[i],sizeof(NR_UL_gNB_HARQ_t));
ulsch->harq_processes[i] = NULL; ulsch->harq_processes[i] = NULL;
} }
} }
free16(ulsch,sizeof(NR_gNB_ULSCH_t)); free16(ulsch,sizeof(NR_gNB_ULSCH_t));
ulsch = NULL; *ulschptr = NULL;
} }
} }
NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag) NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag) {
{
NR_gNB_ULSCH_t *ulsch; NR_gNB_ULSCH_t *ulsch;
uint8_t exit_flag = 0,i,r; uint8_t exit_flag = 0,i,r;
unsigned char bw_scaling =1; unsigned char bw_scaling =1;
...@@ -107,31 +108,26 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8 ...@@ -107,31 +108,26 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8
switch (N_RB_UL) { switch (N_RB_UL) {
case 106: case 106:
bw_scaling =2; bw_scaling =2;
break; break;
default: default:
bw_scaling =1; bw_scaling =1;
break; break;
} }
ulsch = (NR_gNB_ULSCH_t *)malloc16(sizeof(NR_gNB_ULSCH_t)); ulsch = (NR_gNB_ULSCH_t *)malloc16(sizeof(NR_gNB_ULSCH_t));
if (ulsch) { if (ulsch) {
memset(ulsch,0,sizeof(NR_gNB_ULSCH_t)); memset(ulsch,0,sizeof(NR_gNB_ULSCH_t));
ulsch->max_ldpc_iterations = max_ldpc_iterations; ulsch->max_ldpc_iterations = max_ldpc_iterations;
ulsch->Mlimit = 4; ulsch->Mlimit = 4;
for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) { for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) {
ulsch->harq_processes[i] = (NR_UL_gNB_HARQ_t *)malloc16(sizeof(NR_UL_gNB_HARQ_t)); ulsch->harq_processes[i] = (NR_UL_gNB_HARQ_t *)malloc16(sizeof(NR_UL_gNB_HARQ_t));
if (ulsch->harq_processes[i]) { if (ulsch->harq_processes[i]) {
memset(ulsch->harq_processes[i],0,sizeof(NR_UL_gNB_HARQ_t)); memset(ulsch->harq_processes[i],0,sizeof(NR_UL_gNB_HARQ_t));
ulsch->harq_processes[i]->b = (uint8_t *)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling);
ulsch->harq_processes[i]->b = (uint8_t*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling);
if (ulsch->harq_processes[i]->b) if (ulsch->harq_processes[i]->b)
memset(ulsch->harq_processes[i]->b,0,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); memset(ulsch->harq_processes[i]->b,0,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling);
...@@ -140,17 +136,15 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8 ...@@ -140,17 +136,15 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8
if (abstraction_flag == 0) { if (abstraction_flag == 0) {
for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling; r++) { for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling; r++) {
ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem(); ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
ulsch->harq_processes[i]->c[r] = (uint8_t *)malloc16(8448*sizeof(uint8_t));
ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448*sizeof(uint8_t));
if (ulsch->harq_processes[i]->c[r]) if (ulsch->harq_processes[i]->c[r])
memset(ulsch->harq_processes[i]->c[r],0,8448*sizeof(uint8_t)); memset(ulsch->harq_processes[i]->c[r],0,8448*sizeof(uint8_t));
else else
exit_flag=2; exit_flag=2;
ulsch->harq_processes[i]->d[r] = (int16_t*)malloc16((68*384)*sizeof(int16_t)); ulsch->harq_processes[i]->d[r] = (int16_t *)malloc16((68*384)*sizeof(int16_t));
if (ulsch->harq_processes[i]->d[r]) if (ulsch->harq_processes[i]->d[r])
memset(ulsch->harq_processes[i]->d[r],0,(68*384)*sizeof(int16_t)); memset(ulsch->harq_processes[i]->d[r],0,(68*384)*sizeof(int16_t));
...@@ -168,13 +162,11 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8 ...@@ -168,13 +162,11 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8
} }
printf("new_gNB_ulsch with size %zu: exit_flag = %u\n",sizeof(NR_UL_gNB_HARQ_t), exit_flag); printf("new_gNB_ulsch with size %zu: exit_flag = %u\n",sizeof(NR_UL_gNB_HARQ_t), exit_flag);
free_gNB_ulsch(ulsch); free_gNB_ulsch(&ulsch);
return(NULL); return(NULL);
} }
void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) {
{
unsigned char i, j; unsigned char i, j;
if (ulsch) { if (ulsch) {
...@@ -195,11 +187,13 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) ...@@ -195,11 +187,13 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch)
ulsch->max_ldpc_iterations = 0; ulsch->max_ldpc_iterations = 0;
ulsch->last_iteration_cnt = 0; ulsch->last_iteration_cnt = 0;
ulsch->num_active_cba_groups = 0; ulsch->num_active_cba_groups = 0;
for (i=0;i<NUM_MAX_CBA_GROUP;i++) ulsch->cba_rnti[i] = 0;
for (i=0;i<NR_MAX_SLOTS_PER_FRAME;i++) ulsch->harq_process_id[i] = 0; for (i=0; i<NUM_MAX_CBA_GROUP; i++) ulsch->cba_rnti[i] = 0;
for (i=0; i<NR_MAX_SLOTS_PER_FRAME; i++) ulsch->harq_process_id[i] = 0;
for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) { for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) {
if (ulsch->harq_processes[i]){ if (ulsch->harq_processes[i]) {
/// Nfapi ULSCH PDU /// Nfapi ULSCH PDU
//nfapi_nr_ul_config_ulsch_pdu ulsch_pdu; //nfapi_nr_ul_config_ulsch_pdu ulsch_pdu;
ulsch->harq_processes[i]->frame=0; ulsch->harq_processes[i]->frame=0;
...@@ -217,7 +211,6 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) ...@@ -217,7 +211,6 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch)
ulsch->harq_processes[i]->previous_first_rb=0; ulsch->harq_processes[i]->previous_first_rb=0;
ulsch->harq_processes[i]->handled=0; ulsch->harq_processes[i]->handled=0;
ulsch->harq_processes[i]->delta_TF=0; ulsch->harq_processes[i]->delta_TF=0;
ulsch->harq_processes[i]->TBS=0; ulsch->harq_processes[i]->TBS=0;
/// Pointer to the payload (38.212 V15.4.0 section 5.1) /// Pointer to the payload (38.212 V15.4.0 section 5.1)
//uint8_t *b; //uint8_t *b;
...@@ -235,33 +228,37 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) ...@@ -235,33 +228,37 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch)
/// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1)
//int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; //int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448];
ulsch->harq_processes[i]->E=0; ulsch->harq_processes[i]->E=0;
ulsch->harq_processes[i]->n_DMRS=0; ulsch->harq_processes[i]->n_DMRS=0;
ulsch->harq_processes[i]->n_DMRS2=0; ulsch->harq_processes[i]->n_DMRS2=0;
ulsch->harq_processes[i]->previous_n_DMRS=0; ulsch->harq_processes[i]->previous_n_DMRS=0;
ulsch->harq_processes[i]->cqi_crc_status=0;
for (j=0; j<MAX_CQI_BYTES; j++) ulsch->harq_processes[i]->o[j]=0;
ulsch->harq_processes[i]->cqi_crc_status=0;
for (j=0;j<MAX_CQI_BYTES;j++) ulsch->harq_processes[i]->o[j]=0;
ulsch->harq_processes[i]->uci_format=0; ulsch->harq_processes[i]->uci_format=0;
ulsch->harq_processes[i]->Or1=0; ulsch->harq_processes[i]->Or1=0;
ulsch->harq_processes[i]->Or2=0; ulsch->harq_processes[i]->Or2=0;
ulsch->harq_processes[i]->o_RI[0]=0; ulsch->harq_processes[i]->o_RI[1]=0; ulsch->harq_processes[i]->o_RI[0]=0;
ulsch->harq_processes[i]->o_RI[1]=0;
ulsch->harq_processes[i]->O_RI=0; ulsch->harq_processes[i]->O_RI=0;
ulsch->harq_processes[i]->o_ACK[0]=0; ulsch->harq_processes[i]->o_ACK[1]=0; ulsch->harq_processes[i]->o_ACK[0]=0;
ulsch->harq_processes[i]->o_ACK[2]=0; ulsch->harq_processes[i]->o_ACK[3]=0; ulsch->harq_processes[i]->o_ACK[1]=0;
ulsch->harq_processes[i]->o_ACK[2]=0;
ulsch->harq_processes[i]->o_ACK[3]=0;
ulsch->harq_processes[i]->O_ACK=0; ulsch->harq_processes[i]->O_ACK=0;
ulsch->harq_processes[i]->V_UL_DAI=0; ulsch->harq_processes[i]->V_UL_DAI=0;
/// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27)
//int8_t q[MAX_CQI_PAYLOAD]; //int8_t q[MAX_CQI_PAYLOAD];
ulsch->harq_processes[i]->o_RCC=0; ulsch->harq_processes[i]->o_RCC=0;
/// coded and interleaved CQI bits /// coded and interleaved CQI bits
//int8_t o_w[(MAX_CQI_BITS+8)*3]; //int8_t o_w[(MAX_CQI_BITS+8)*3];
/// coded CQI bits /// coded CQI bits
//int8_t o_d[96+((MAX_CQI_BITS+8)*3)]; //int8_t o_d[96+((MAX_CQI_BITS+8)*3)];
for (j=0;j<MAX_ACK_PAYLOAD;j++) ulsch->harq_processes[i]->q_ACK[j]=0; for (j=0; j<MAX_ACK_PAYLOAD; j++) ulsch->harq_processes[i]->q_ACK[j]=0;
for (j=0;j<MAX_RI_PAYLOAD;j++) ulsch->harq_processes[i]->q_RI[j]=0;
for (j=0; j<MAX_RI_PAYLOAD; j++) ulsch->harq_processes[i]->q_RI[j]=0;
/// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled
//uint8_t h[MAX_NUM_CHANNEL_BITS]; //uint8_t h[MAX_NUM_CHANNEL_BITS];
/// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
...@@ -283,9 +280,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -283,9 +280,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
uint16_t nb_symb_sch, uint16_t nb_symb_sch,
uint8_t nr_tti_rx, uint8_t nr_tti_rx,
uint8_t harq_pid, uint8_t harq_pid,
uint8_t is_crnti) uint8_t is_crnti) {
{
uint32_t A,E; uint32_t A,E;
uint32_t G; uint32_t G;
uint32_t ret,offset; uint32_t ret,offset;
...@@ -293,29 +288,29 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -293,29 +288,29 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0; uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0;
uint8_t crc_type; uint8_t crc_type;
int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32))); int8_t llrProcBuf[OAI_UL_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32)));
#ifdef PRINT_CRC_CHECK #ifdef PRINT_CRC_CHECK
prnt_crc_cnt++; prnt_crc_cnt++;
#endif #endif
NR_gNB_ULSCH_t *ulsch = phy_vars_gNB->ulsch[UE_id][0]; NR_gNB_ULSCH_t *ulsch = phy_vars_gNB->ulsch[UE_id][0];
NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid];
nfapi_nr_ul_config_ulsch_pdu_rel15_t *nfapi_ulsch_pdu_rel15 = &harq_process->ulsch_pdu.ulsch_pdu_rel15; nfapi_nr_ul_config_ulsch_pdu_rel15_t *nfapi_ulsch_pdu_rel15 = &harq_process->ulsch_pdu.ulsch_pdu_rel15;
t_nrLDPC_dec_params decParams; t_nrLDPC_dec_params decParams;
t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_dec_params *p_decParams = &decParams;
t_nrLDPC_time_stats procTime; t_nrLDPC_time_stats procTime;
t_nrLDPC_time_stats* p_procTime = &procTime ; t_nrLDPC_time_stats *p_procTime = &procTime ;
t_nrLDPC_procBuf** p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf;
if (!harq_process) {
printf("ulsch_decoding.c: NULL harq_process pointer\n");
return (ulsch->max_ldpc_iterations + 1);
}
t_nrLDPC_procBuf **p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf;
int16_t z [68*384]; int16_t z [68*384];
int8_t l [68*384]; int8_t l [68*384];
uint8_t kc=0; uint8_t kc=0;
uint8_t Ilbrm = 0; uint8_t Ilbrm = 0;
uint32_t Tbslbrm = 950984; uint32_t Tbslbrm = 950984;
double Coderate = 0.0; double Coderate = 0.0;
// ------------------------------------------------------------------ // ------------------------------------------------------------------
uint16_t nb_rb = nfapi_ulsch_pdu_rel15->number_rbs; uint16_t nb_rb = nfapi_ulsch_pdu_rel15->number_rbs;
uint16_t number_symbols = nfapi_ulsch_pdu_rel15->number_symbols; uint16_t number_symbols = nfapi_ulsch_pdu_rel15->number_symbols;
...@@ -326,23 +321,15 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -326,23 +321,15 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
uint8_t nb_re_dmrs = nfapi_ulsch_pdu_rel15->nb_re_dmrs; uint8_t nb_re_dmrs = nfapi_ulsch_pdu_rel15->nb_re_dmrs;
uint8_t length_dmrs = nfapi_ulsch_pdu_rel15->length_dmrs; uint8_t length_dmrs = nfapi_ulsch_pdu_rel15->length_dmrs;
// ------------------------------------------------------------------ // ------------------------------------------------------------------
uint32_t i,j; uint32_t i,j;
__m128i *pv = (__m128i *)&z;
__m128i *pl = (__m128i *)&l;
__m128i *pv = (__m128i*)&z; if (!ulsch_llr) {
__m128i *pl = (__m128i*)&l;
if (!ulsch_llr) {
printf("ulsch_decoding.c: NULL ulsch_llr pointer\n"); printf("ulsch_decoding.c: NULL ulsch_llr pointer\n");
return (ulsch->max_ldpc_iterations + 1); return (ulsch->max_ldpc_iterations + 1);
} }
if (!harq_process) {
printf("ulsch_decoding.c: NULL harq_process pointer\n");
return (ulsch->max_ldpc_iterations + 1);
}
if (!frame_parms) { if (!frame_parms) {
printf("ulsch_decoding.c: NULL frame_parms pointer\n"); printf("ulsch_decoding.c: NULL frame_parms pointer\n");
return (ulsch->max_ldpc_iterations + 1); return (ulsch->max_ldpc_iterations + 1);
...@@ -350,16 +337,12 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -350,16 +337,12 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
// harq_process->trials[nfapi_ulsch_pdu_rel15->round]++; // harq_process->trials[nfapi_ulsch_pdu_rel15->round]++;
harq_process->TBS = nr_compute_tbs(Qm, R, nb_rb, number_symbols, nb_re_dmrs*length_dmrs, 0, n_layers); harq_process->TBS = nr_compute_tbs(Qm, R, nb_rb, number_symbols, nb_re_dmrs*length_dmrs, 0, n_layers);
A = harq_process->TBS; A = harq_process->TBS;
ret = ulsch->max_ldpc_iterations + 1; ret = ulsch->max_ldpc_iterations + 1;
G = nr_get_G(nb_rb, number_symbols, nb_re_dmrs, length_dmrs, Qm, n_layers); G = nr_get_G(nb_rb, number_symbols, nb_re_dmrs, length_dmrs, Qm, n_layers);
LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, mcs, n_layers, nb_symb_sch,nb_rb); LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, mcs, n_layers, nb_symb_sch,nb_rb);
if (harq_process->round == 0) { if (harq_process->round == 0) {
// This is a new packet, so compute quantities regarding segmentation // This is a new packet, so compute quantities regarding segmentation
harq_process->B = A+24; harq_process->B = A+24;
...@@ -368,36 +351,35 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -368,36 +351,35 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
else else
Coderate = (float) R /(float) 2048; Coderate = (float) R /(float) 2048;
if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) {
p_decParams->BG = 2; p_decParams->BG = 2;
if (Coderate < 0.3333) { if (Coderate < 0.3333) {
p_decParams->R = 15; p_decParams->R = 15;
kc = 52; kc = 52;
} } else if (Coderate <0.6667) {
else if (Coderate <0.6667) { p_decParams->R = 13;
p_decParams->R = 13; kc = 32;
kc = 32; } else {
} p_decParams->R = 23;
else { kc = 17;
p_decParams->R = 23; }
kc = 17; } else {
} p_decParams->BG = 1;
} else {
p_decParams->BG = 1; if (Coderate < 0.6667) {
if (Coderate < 0.6667) { p_decParams->R = 13;
p_decParams->R = 13; kc = 68;
kc = 68; } else if (Coderate <0.8889) {
} p_decParams->R = 23;
else if (Coderate <0.8889) { kc = 35;
p_decParams->R = 23; } else {
kc = 35; p_decParams->R = 89;
} kc = 27;
else { }
p_decParams->R = 89;
kc = 27;
} }
}
AssertFatal(kc>0,"kc=%i has not been set to a consistent value",kc); AssertFatal(kc>0,"kc=%i has not been set to a consistent value",kc);
// [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F) // [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F)
nr_segmentation(NULL, nr_segmentation(NULL,
NULL, NULL,
...@@ -407,26 +389,23 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -407,26 +389,23 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
&harq_process->Z, // [hna] Z is Zc &harq_process->Z, // [hna] Z is Zc
&harq_process->F, &harq_process->F,
p_decParams->BG); p_decParams->BG);
#ifdef DEBUG_ULSCH_DECODING #ifdef DEBUG_ULSCH_DECODING
printf("ulsch decoding nr segmentation Z %d\n", harq_process->Z); printf("ulsch decoding nr segmentation Z %d\n", harq_process->Z);
if (!frame%100) if (!frame%100)
printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, harq_process->Z, harq_process->Nl); printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, harq_process->Z, harq_process->Nl);
#endif #endif
} }
p_decParams->Z = harq_process->Z;
p_decParams->Z = harq_process->Z;
p_decParams->numMaxIter = ulsch->max_ldpc_iterations; p_decParams->numMaxIter = ulsch->max_ldpc_iterations;
p_decParams->outMode= 0; p_decParams->outMode= 0;
err_flag = 0; err_flag = 0;
r_offset = 0; r_offset = 0;
unsigned char bw_scaling =1; unsigned char bw_scaling =1;
switch (frame_parms->N_RB_UL) { switch (frame_parms->N_RB_UL) {
case 106: case 106:
bw_scaling =2; bw_scaling =2;
break; break;
...@@ -440,46 +419,36 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -440,46 +419,36 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling); LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling);
return (ulsch->max_ldpc_iterations + 1); return (ulsch->max_ldpc_iterations + 1);
} }
#ifdef DEBUG_ULSCH_DECODING #ifdef DEBUG_ULSCH_DECODING
printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K); printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K);
#endif #endif
//opp_enabled=1; //opp_enabled=1;
Kr = harq_process->K; Kr = harq_process->K;
Kr_bytes = Kr>>3; Kr_bytes = Kr>>3;
K_bytes_F = Kr_bytes-(harq_process->F>>3); K_bytes_F = Kr_bytes-(harq_process->F>>3);
for (r=0; r<harq_process->C; r++) { for (r=0; r<harq_process->C; r++) {
E = nr_get_E(G, harq_process->C, nfapi_ulsch_pdu_rel15->Qm, nfapi_ulsch_pdu_rel15->n_layers, r); E = nr_get_E(G, harq_process->C, nfapi_ulsch_pdu_rel15->Qm, nfapi_ulsch_pdu_rel15->n_layers, r);
#if gNB_TIMING_TRACE #if gNB_TIMING_TRACE
start_meas(ulsch_deinterleaving_stats); start_meas(ulsch_deinterleaving_stats);
#endif #endif
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// nr_deinterleaving_ldpc /////////////////////////////////// ///////////////////////////////// nr_deinterleaving_ldpc ///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ulsch_llr =====> harq_process->e ////////////////////////////// //////////////////////////// ulsch_llr =====> harq_process->e //////////////////////////////
nr_deinterleaving_ldpc(E, nr_deinterleaving_ldpc(E,
nfapi_ulsch_pdu_rel15->Qm, nfapi_ulsch_pdu_rel15->Qm,
harq_process->e[r], harq_process->e[r],
ulsch_llr+r_offset); ulsch_llr+r_offset);
//for (int i =0; i<16; i++) //for (int i =0; i<16; i++)
// printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset); // printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset);
#if gNB_TIMING_TRACE #if gNB_TIMING_TRACE
stop_meas(ulsch_deinterleaving_stats); stop_meas(ulsch_deinterleaving_stats);
#endif #endif
#if gNB_TIMING_TRACE #if gNB_TIMING_TRACE
start_meas(ulsch_rate_unmatching_stats); start_meas(ulsch_rate_unmatching_stats);
#endif #endif
#ifdef DEBUG_ULSCH_DECODING #ifdef DEBUG_ULSCH_DECODING
LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n", LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n",
harq_pid,r, G, harq_pid,r, G,
...@@ -492,14 +461,10 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -492,14 +461,10 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
harq_process->round); harq_process->round);
#endif #endif
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// nr_rate_matching_ldpc_rx //////////////////////////////// //////////////////////////////// nr_rate_matching_ldpc_rx ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
///////////////////////// harq_process->e =====> harq_process->d ///////////////////////// ///////////////////////// harq_process->e =====> harq_process->d /////////////////////////
Tbslbrm = nr_compute_tbslbrm(0,nb_rb,nfapi_ulsch_pdu_rel15->n_layers,harq_process->C); Tbslbrm = nr_compute_tbslbrm(0,nb_rb,nfapi_ulsch_pdu_rel15->n_layers,harq_process->C);
if (nr_rate_matching_ldpc_rx(Ilbrm, if (nr_rate_matching_ldpc_rx(Ilbrm,
...@@ -524,21 +489,21 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -524,21 +489,21 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
} }
r_offset += E; r_offset += E;
#ifdef DEBUG_ULSCH_DECODING #ifdef DEBUG_ULSCH_DECODING
if (r==0) { if (r==0) {
write_output("decoder_llr.m","decllr",ulsch_llr,G,1,0); write_output("decoder_llr.m","decllr",ulsch_llr,G,1,0);
write_output("decoder_in.m","dec",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,0); write_output("decoder_in.m","dec",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,0);
} }
printf("decoder input(segment %d) :",r); printf("decoder input(segment %u) :",r);
int i; int i;
for (i=0;i<(3*8*Kr_bytes)+12;i++)
for (i=0; i<(3*8*Kr_bytes)+12; i++)
printf("%d : %d\n",i,harq_process->d[r][i]); printf("%d : %d\n",i,harq_process->d[r][i]);
printf("\n"); printf("\n");
#endif #endif
// printf("Clearing c, %p\n",harq_process->c[r]); // printf("Clearing c, %p\n",harq_process->c[r]);
memset(harq_process->c[r],0,Kr_bytes); memset(harq_process->c[r],0,Kr_bytes);
...@@ -546,83 +511,75 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -546,83 +511,75 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
if (harq_process->C == 1) { if (harq_process->C == 1) {
crc_type = CRC24_A; crc_type = CRC24_A;
length_dec = harq_process->B; length_dec = harq_process->B;
} } else {
else {
crc_type = CRC24_B; crc_type = CRC24_B;
length_dec = (harq_process->B+24*harq_process->C)/harq_process->C; length_dec = (harq_process->B+24*harq_process->C)/harq_process->C;
} }
if (err_flag == 0) { if (err_flag == 0) {
#if gNB_TIMING_TRACE #if gNB_TIMING_TRACE
start_meas(ulsch_turbo_decoding_stats); start_meas(ulsch_turbo_decoding_stats);
#endif #endif
//LOG_E(PHY,"AbsSubframe %d.%d Start LDPC segment %d/%d A %d ",frame%1024,nr_tti_rx,r,harq_process->C-1, A); //LOG_E(PHY,"AbsSubframe %d.%d Start LDPC segment %d/%d A %d ",frame%1024,nr_tti_rx,r,harq_process->C-1, A);
memset(pv,0,2*harq_process->Z*sizeof(int16_t)); memset(pv,0,2*harq_process->Z*sizeof(int16_t));
memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t)); memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t));
for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F; i++, j++) { for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F; i++, j++) {
pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j])); pv[i]= _mm_loadu_si128((__m128i *)(&harq_process->d[r][8*j]));
} }
for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++) { for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++) {
pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j])); pv[i]= _mm_loadu_si128((__m128i *)(&harq_process->d[r][8*j]));
} }
for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) { for (i=0, j=0; j < ((kc*p_decParams->Z)>>4); i+=2, j++) {
pl[j] = _mm_packs_epi16(pv[i],pv[i+1]); pl[j] = _mm_packs_epi16(pv[i],pv[i+1]);
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// nrLDPC_decoder ///////////////////////////////////// ///////////////////////////////////// nrLDPC_decoder /////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////// pl =====> llrProcBuf ////////////////////////////////// ////////////////////////////////// pl =====> llrProcBuf //////////////////////////////////
no_iteration_ldpc = nrLDPC_decoder(p_decParams, no_iteration_ldpc = nrLDPC_decoder(p_decParams,
(int8_t*)&pl[0], (int8_t *)&pl[0],
llrProcBuf, llrProcBuf,
p_nrLDPC_procBuf[r], p_nrLDPC_procBuf[r],
p_procTime); p_procTime);
if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { if (check_crc((uint8_t *)llrProcBuf,length_dec,harq_process->F,crc_type)) {
#ifdef PRINT_CRC_CHECK #ifdef PRINT_CRC_CHECK
//if (prnt_crc_cnt % 10 == 0) //if (prnt_crc_cnt % 10 == 0)
LOG_I(PHY, "Segment %d CRC OK\n",r); LOG_I(PHY, "Segment %d CRC OK\n",r);
#endif #endif
ret = no_iteration_ldpc; ret = no_iteration_ldpc;
} else { } else {
#ifdef PRINT_CRC_CHECK #ifdef PRINT_CRC_CHECK
//if (prnt_crc_cnt%10 == 0) //if (prnt_crc_cnt%10 == 0)
LOG_I(PHY, "CRC NOK\n"); LOG_I(PHY, "CRC NOK\n");
#endif #endif
ret = ulsch->max_ldpc_iterations + 1; ret = ulsch->max_ldpc_iterations + 1;
} }
nb_total_decod++; nb_total_decod++;
if (no_iteration_ldpc > ulsch->max_ldpc_iterations){ if (no_iteration_ldpc > ulsch->max_ldpc_iterations) {
nb_error_decod++; nb_error_decod++;
} }
for (int m=0; m < Kr>>3; m ++) { for (int m=0; m < Kr>>3; m ++) {
harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; harq_process->c[r][m]= (uint8_t) llrProcBuf[m];
} }
#ifdef DEBUG_ULSCH_DECODING #ifdef DEBUG_ULSCH_DECODING
//printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]); //printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]);
for (int k=0;k<A>>3;k++) for (int k=0; k<A>>3; k++)
printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]);
printf("no_iterations_ldpc %d (ret %d)\n",no_iteration_ldpc,ret);
printf("no_iterations_ldpc %d (ret %u)\n",no_iteration_ldpc,ret);
//write_output("dec_output.m","dec0",harq_process->c[0],Kr_bytes,1,4); //write_output("dec_output.m","dec0",harq_process->c[0],Kr_bytes,1,4);
#endif #endif
#if gNB_TIMING_TRACE #if gNB_TIMING_TRACE
stop_meas(ulsch_turbo_decoding_stats); stop_meas(ulsch_turbo_decoding_stats);
#endif #endif
...@@ -633,19 +590,21 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -633,19 +590,21 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1); LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1);
err_flag = 1; err_flag = 1;
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
} }
int32_t frame_rx_prev = frame; int32_t frame_rx_prev = frame;
int32_t tti_rx_prev = nr_tti_rx - 1; int32_t tti_rx_prev = nr_tti_rx - 1;
if (tti_rx_prev < 0) { if (tti_rx_prev < 0) {
frame_rx_prev--; frame_rx_prev--;
tti_rx_prev += 10*frame_parms->ttis_per_subframe; tti_rx_prev += 10*frame_parms->ttis_per_subframe;
} }
frame_rx_prev = frame_rx_prev%1024; frame_rx_prev = frame_rx_prev%1024;
if (err_flag == 1) { if (err_flag == 1) {
#ifdef gNB_DEBUG_TRACE #ifdef gNB_DEBUG_TRACE
LOG_I(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) Kr %d r %d\n", LOG_I(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) Kr %d r %d\n",
phy_vars_gNB->Mod_id, frame, nr_tti_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,Kr,r); phy_vars_gNB->Mod_id, frame, nr_tti_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,Kr,r);
...@@ -671,14 +630,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -671,14 +630,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
harq_process->handled = 1; harq_process->handled = 1;
return (ulsch->max_ldpc_iterations + 1); return (ulsch->max_ldpc_iterations + 1);
} else { } else {
#ifdef gNB_DEBUG_TRACE #ifdef gNB_DEBUG_TRACE
LOG_I(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d TBS %d\n", LOG_I(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d TBS %d\n",
phy_vars_gNB->Mod_id,nr_tti_rx,harq_process->TBS); phy_vars_gNB->Mod_id,nr_tti_rx,harq_process->TBS);
#endif #endif
harq_process->status = SCH_IDLE; harq_process->status = SCH_IDLE;
harq_process->round = 0; harq_process->round = 0;
// harq_process->handled = 0; // harq_process->handled = 0;
...@@ -687,8 +643,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -687,8 +643,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
// harq_process->harq_ack.harq_id = harq_pid; // harq_process->harq_ack.harq_id = harq_pid;
// harq_process->harq_ack.send_harq_status = 1; // harq_process->harq_ack.send_harq_status = 1;
if(is_crnti) if(is_crnti) {
{
LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d (pid %d, round %d, TBS %d)\n",phy_vars_gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->round,harq_process->TBS); LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d (pid %d, round %d, TBS %d)\n",phy_vars_gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->round,harq_process->TBS);
} }
} }
...@@ -699,15 +654,12 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -699,15 +654,12 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
Kr_bytes = Kr>>3; Kr_bytes = Kr>>3;
for (r=0; r<harq_process->C; r++) { for (r=0; r<harq_process->C; r++) {
memcpy(harq_process->b+offset, memcpy(harq_process->b+offset,
harq_process->c[r], harq_process->c[r],
Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0)); Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0));
offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0)); offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0));
#ifdef DEBUG_ULSCH_DECODING #ifdef DEBUG_ULSCH_DECODING
printf("Segment %d : Kr= %d bytes\n",r,Kr_bytes); printf("Segment %u : Kr= %u bytes\n",r,Kr_bytes);
printf("copied %d bytes to b sequence (harq_pid %d)\n", printf("copied %d bytes to b sequence (harq_pid %d)\n",
(Kr_bytes - (harq_process->F>>3)-((harq_process->C>1)?3:0)),harq_pid); (Kr_bytes - (harq_process->F>>3)-((harq_process->C>1)?3:0)),harq_pid);
printf("b[0] = %x,c[%d] = %x\n", printf("b[0] = %x,c[%d] = %x\n",
...@@ -715,10 +667,8 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -715,10 +667,8 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
harq_process->F>>3, harq_process->F>>3,
harq_process->c[r]); harq_process->c[r]);
#endif #endif
} }
ulsch->last_iteration_cnt = ret; ulsch->last_iteration_cnt = ret;
return(ret); return(ret);
} }
...@@ -35,170 +35,133 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, ...@@ -35,170 +35,133 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue,
unsigned char Ns, unsigned char Ns,
unsigned char symbol, unsigned char symbol,
int dmrss, int dmrss,
NR_UE_SSB *current_ssb) NR_UE_SSB *current_ssb) {
{
int pilot[200] __attribute__((aligned(16))); int pilot[200] __attribute__((aligned(16)));
unsigned char aarx; unsigned char aarx;
unsigned short k; unsigned short k;
unsigned int pilot_cnt; unsigned int pilot_cnt;
int16_t ch[2],*pil,*rxF; int16_t ch[2],*pil,*rxF;
int symbol_offset; int symbol_offset;
uint8_t nushift; uint8_t nushift;
uint8_t ssb_index=current_ssb->i_ssb; uint8_t ssb_index=current_ssb->i_ssb;
uint8_t n_hf=current_ssb->n_hf; uint8_t n_hf=current_ssb->n_hf;
int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF; int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF;
nushift = ue->frame_parms.Nid_cell%4; nushift = ue->frame_parms.Nid_cell%4;
ue->frame_parms.nushift = nushift; ue->frame_parms.nushift = nushift;
unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier;
if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset-=ue->frame_parms.ofdm_symbol_size; if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset-=ue->frame_parms.ofdm_symbol_size;
AssertFatal(dmrss >= 0 && dmrss < 3, AssertFatal(dmrss >= 0 && dmrss < 3,
"symbol %d is illegal for PBCH DM-RS \n", "symbol %d is illegal for PBCH DM-RS \n",
dmrss); dmrss);
symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol; symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol;
k = nushift; k = nushift;
#ifdef DEBUG_CH #ifdef DEBUG_CH
printf("PBCH DMRS Correlation : ThreadId %d, eNB_offset %d , OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ue->frame_parms.ofdm_symbol_size, printf("PBCH DMRS Correlation : ThreadId %d, eNB_offset %d , OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ue->frame_parms.ofdm_symbol_size,
ue->frame_parms.Ncp,Ns,k, symbol); ue->frame_parms.Ncp,Ns,k, symbol);
#endif #endif
// generate pilot // generate pilot
nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]); nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]);
int re_offset = ssb_offset; int re_offset = ssb_offset;
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
pil = (int16_t *)&pilot[0]; pil = (int16_t *)&pilot[0];
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
#ifdef DEBUG_CH #ifdef DEBUG_CH
printf("pbch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL); printf("pbch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL);
printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset); printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset);
printf("rxF addr %p\n", rxF); printf("rxF addr %p\n", rxF);
#endif #endif
//if ((ue->frame_parms.N_RB_DL&1)==0) { //if ((ue->frame_parms.N_RB_DL&1)==0) {
// Treat first 2 pilots specially (left edge) // Treat first 2 pilots specially (left edge)
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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);
current_ssb->c_re +=ch[0]; current_ssb->c_re +=ch[0];
current_ssb->c_im +=ch[1]; current_ssb->c_im +=ch[1];
#ifdef DEBUG_CH #ifdef DEBUG_CH
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]);
#endif #endif
pil+=2; pil+=2;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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);
current_ssb->c_re +=ch[0]; current_ssb->c_re +=ch[0];
current_ssb->c_im +=ch[1]; current_ssb->c_im +=ch[1];
#ifdef DEBUG_CH #ifdef DEBUG_CH
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]);
#endif #endif
pil+=2; pil+=2;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
current_ssb->c_re +=ch[0]; current_ssb->c_re +=ch[0];
current_ssb->c_im +=ch[1]; current_ssb->c_im +=ch[1];
#ifdef DEBUG_CH #ifdef DEBUG_CH
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]);
#endif #endif
pil+=2; pil+=2;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
for (pilot_cnt=3; pilot_cnt<(3*20); pilot_cnt+=3) { for (pilot_cnt=3; pilot_cnt<(3*20); pilot_cnt+=3) {
// if (pilot_cnt == 30)
// rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k)];
// if (pilot_cnt == 30) // in 2nd symbol, skip middle REs (48 with DMRS, 144 for SSS, and another 48 with DMRS)
// rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k)];
// in 2nd symbol, skip middle REs (48 with DMRS, 144 for SSS, and another 48 with DMRS)
if (dmrss == 1 && pilot_cnt == 12) { if (dmrss == 1 && pilot_cnt == 12) {
pilot_cnt=48; pilot_cnt=48;
re_offset = (re_offset+144) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+144) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
} }
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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);
current_ssb->c_re +=ch[0]; current_ssb->c_re +=ch[0];
current_ssb->c_im +=ch[1]; current_ssb->c_im +=ch[1];
#ifdef DEBUG_CH #ifdef DEBUG_CH
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]);
#endif #endif
pil+=2; pil+=2;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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);
current_ssb->c_re +=ch[0]; current_ssb->c_re +=ch[0];
current_ssb->c_im +=ch[1]; current_ssb->c_im +=ch[1];
#ifdef DEBUG_CH #ifdef DEBUG_CH
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]);
#endif #endif
pil+=2; pil+=2;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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);
current_ssb->c_re +=ch[0]; current_ssb->c_re +=ch[0];
current_ssb->c_im +=ch[1]; current_ssb->c_im +=ch[1];
#ifdef DEBUG_CH #ifdef DEBUG_CH
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]);
#endif #endif
pil+=2; pil+=2;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
} }
//} //}
} }
return(0); return(0);
} }
int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
uint8_t eNB_offset, uint8_t eNB_offset,
unsigned char Ns, unsigned char Ns,
unsigned char symbol, unsigned char symbol,
int dmrss, int dmrss,
uint8_t ssb_index, uint8_t ssb_index,
uint8_t n_hf) uint8_t n_hf) {
{
int pilot[200] __attribute__((aligned(16))); int pilot[200] __attribute__((aligned(16)));
unsigned char aarx,p; unsigned char aarx,p;
unsigned short k; unsigned short k;
...@@ -209,16 +172,14 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -209,16 +172,14 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
//fapi_nr_pbch_config_t *pbch_config = &ue->nrUE_config.pbch_config; //fapi_nr_pbch_config_t *pbch_config = &ue->nrUE_config.pbch_config;
// initialized to 5ms in nr_init_ue for scenarios where UE is not configured (otherwise acquired by cell configuration from gNB or LTE) // initialized to 5ms in nr_init_ue for scenarios where UE is not configured (otherwise acquired by cell configuration from gNB or LTE)
//uint8_t ssb_periodicity = 10;// ue->ssb_periodicity; //uint8_t ssb_periodicity = 10;// ue->ssb_periodicity;
//uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1]; //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1];
uint8_t nushift; uint8_t nushift;
int **dl_ch_estimates =ue->pbch_vars[eNB_offset]->dl_ch_estimates; int **dl_ch_estimates =ue->pbch_vars[eNB_offset]->dl_ch_estimates;
int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF; int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF;
nushift = ue->frame_parms.Nid_cell%4; nushift = ue->frame_parms.Nid_cell%4;
ue->frame_parms.nushift = nushift; ue->frame_parms.nushift = nushift;
unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier; unsigned int ssb_offset = ue->frame_parms.first_carrier_offset + ue->frame_parms.ssb_start_subcarrier;
if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset-=ue->frame_parms.ofdm_symbol_size; if (ssb_offset>= ue->frame_parms.ofdm_symbol_size) ssb_offset-=ue->frame_parms.ofdm_symbol_size;
if (ue->high_speed_flag == 0) // use second channel estimate position for temporary storage if (ue->high_speed_flag == 0) // use second channel estimate position for temporary storage
...@@ -227,65 +188,62 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -227,65 +188,62 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
ch_offset = ue->frame_parms.ofdm_symbol_size*symbol; ch_offset = ue->frame_parms.ofdm_symbol_size*symbol;
AssertFatal(dmrss >= 0 && dmrss < 3, AssertFatal(dmrss >= 0 && dmrss < 3,
"symbol %d is illegal for PBCH DM-RS \n", "symbol %d is illegal for PBCH DM-RS \n",
dmrss); dmrss);
symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol; symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol;
k = nushift; k = nushift;
#ifdef DEBUG_CH #ifdef DEBUG_CH
printf("PBCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,ue->frame_parms.ofdm_symbol_size, printf("PBCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,
ue->frame_parms.ofdm_symbol_size,
ue->frame_parms.Ncp,Ns,k, symbol); ue->frame_parms.Ncp,Ns,k, symbol);
#endif #endif
switch (k) { switch (k) {
case 0: case 0:
fl = filt16a_l0; fl = filt16a_l0;
fm = filt16a_m0; fm = filt16a_m0;
fr = filt16a_r0; fr = filt16a_r0;
break; break;
case 1: case 1:
fl = filt16a_l1; fl = filt16a_l1;
fm = filt16a_m1; fm = filt16a_m1;
fr = filt16a_r1; fr = filt16a_r1;
break; break;
case 2: case 2:
fl = filt16a_l2; fl = filt16a_l2;
fm = filt16a_m2; fm = filt16a_m2;
fr = filt16a_r2; fr = filt16a_r2;
break; break;
case 3: case 3:
fl = filt16a_l3; fl = filt16a_l3;
fm = filt16a_m3; fm = filt16a_m3;
fr = filt16a_r3; fr = filt16a_r3;
break; break;
default: default:
msg("pbch_channel_estimation: k=%d -> ERROR\n",k); msg("pbch_channel_estimation: k=%d -> ERROR\n",k);
return(-1); return(-1);
break; break;
} }
// generate pilot // generate pilot
nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]); nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]);
int re_offset = ssb_offset; int re_offset = ssb_offset;
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
pil = (int16_t *)&pilot[0]; pil = (int16_t *)&pilot[0];
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset]; dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size)); memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size));
if (ue->high_speed_flag==0) // multiply previous channel estimate by ch_est_alpha if (ue->high_speed_flag==0) // multiply previous channel estimate by ch_est_alpha
multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1), multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
ue->ch_est_alpha,dl_ch-(ue->frame_parms.ofdm_symbol_size<<1), ue->ch_est_alpha,dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
1,ue->frame_parms.ofdm_symbol_size); 1,ue->frame_parms.ofdm_symbol_size);
#ifdef DEBUG_CH #ifdef DEBUG_CH
printf("pbch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL); printf("pbch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL);
printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset); printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset);
...@@ -293,178 +251,156 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -293,178 +251,156 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
printf("dl_ch addr %p\n",dl_ch); printf("dl_ch addr %p\n",dl_ch);
#endif #endif
//if ((ue->frame_parms.N_RB_DL&1)==0) { //if ((ue->frame_parms.N_RB_DL&1)==0) {
// Treat first 2 pilots specially (left edge) // Treat first 2 pilots specially (left edge)
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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_CH #ifdef DEBUG_CH
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]);
#endif #endif
multadd_real_vector_complex_scalar(fl, multadd_real_vector_complex_scalar(fl,
ch, ch,
dl_ch, dl_ch,
16); 16);
pil+=2; pil+=2;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
//for (int i= 0; i<8; i++) //for (int i= 0; i<8; i++)
//printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i)); //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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_CH #ifdef DEBUG_CH
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]);
#endif #endif
multadd_real_vector_complex_scalar(fm, multadd_real_vector_complex_scalar(fm,
ch, ch,
dl_ch, dl_ch,
16); 16);
pil+=2; pil+=2;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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_CH #ifdef DEBUG_CH
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]);
#endif #endif
multadd_real_vector_complex_scalar(fr, multadd_real_vector_complex_scalar(fr,
ch, ch,
dl_ch, dl_ch,
16); 16);
pil+=2; pil+=2;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
dl_ch+=24; dl_ch+=24;
for (pilot_cnt=3; pilot_cnt<(3*20); pilot_cnt+=3) { for (pilot_cnt=3; pilot_cnt<(3*20); pilot_cnt+=3) {
// if (pilot_cnt == 30)
// rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k)];
// if (pilot_cnt == 30) // in 2nd symbol, skip middle REs (48 with DMRS, 144 for SSS, and another 48 with DMRS)
// rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k)];
// in 2nd symbol, skip middle REs (48 with DMRS, 144 for SSS, and another 48 with DMRS)
if (dmrss == 1 && pilot_cnt == 12) { if (dmrss == 1 && pilot_cnt == 12) {
pilot_cnt=48; pilot_cnt=48;
re_offset = (re_offset+144) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+144) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
dl_ch += 288; dl_ch += 288;
} }
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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_CH #ifdef DEBUG_CH
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]);
#endif #endif
multadd_real_vector_complex_scalar(fl, multadd_real_vector_complex_scalar(fl,
ch, ch,
dl_ch, dl_ch,
16); 16);
//for (int i= 0; i<8; i++) //for (int i= 0; i<8; i++)
// printf("pilot_cnt %d dl_ch %d %d\n", pilot_cnt, dl_ch+i, *(dl_ch+i)); // printf("pilot_cnt %d dl_ch %d %d\n", pilot_cnt, dl_ch+i, *(dl_ch+i));
pil+=2; pil+=2;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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_CH #ifdef DEBUG_CH
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]);
#endif #endif
multadd_real_vector_complex_scalar(fm, multadd_real_vector_complex_scalar(fm,
ch, ch,
dl_ch, dl_ch,
16); 16);
pil+=2; pil+=2;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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_CH #ifdef DEBUG_CH
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]);
#endif #endif
multadd_real_vector_complex_scalar(fr, multadd_real_vector_complex_scalar(fr,
ch, ch,
dl_ch, dl_ch,
16); 16);
pil+=2; pil+=2;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
dl_ch+=24; dl_ch+=24;
} }
void (*idft)(int16_t *,int16_t *, int); void (*idft)(int16_t *,int16_t *, int);
switch (ue->frame_parms.ofdm_symbol_size) { switch (ue->frame_parms.ofdm_symbol_size) {
case 128: case 128:
idft = idft128; idft = idft128;
break; break;
case 256: case 256:
idft = idft256; idft = idft256;
break; break;
case 512: case 512:
idft = idft512; idft = idft512;
break; break;
case 1024: case 1024:
idft = idft1024; idft = idft1024;
break; break;
case 1536: case 1536:
idft = idft1536; idft = idft1536;
break; break;
case 2048: case 2048:
idft = idft2048; idft = idft2048;
break; break;
case 3072: case 3072:
idft = idft3072; idft = idft3072;
break; break;
case 4096: case 4096:
idft = idft4096; idft = idft4096;
break; break;
default: default:
printf("unsupported ofdm symbol size \n"); printf("unsupported ofdm symbol size \n");
abort(); abort();
} }
if( symbol == 3) if( symbol == 3) {
{ // do ifft of channel estimate
// do ifft of channel estimate for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++)
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) for (p=0; p<ue->frame_parms.nb_antenna_ports_eNB; p++) {
for (p=0; p<ue->frame_parms.nb_antenna_ports_eNB; p++) { if (ue->pbch_vars[eNB_offset]->dl_ch_estimates[(p<<1)+aarx]) {
if (ue->pbch_vars[eNB_offset]->dl_ch_estimates[(p<<1)+aarx]) LOG_D(PHY,"Channel Impulse Computation Slot %d ThreadId %d Symbol %d ch_offset %d\n", Ns, ue->current_thread_id[Ns], symbol, ch_offset);
{ idft((int16_t *) &ue->pbch_vars[eNB_offset]->dl_ch_estimates[(p<<1)+aarx][ch_offset],
LOG_D(PHY,"Channel Impulse Computation Slot %d ThreadId %d Symbol %d ch_offset %d\n", Ns, ue->current_thread_id[Ns], symbol, ch_offset); (int16_t *) ue->pbch_vars[eNB_offset]->dl_ch_estimates_time[(p<<1)+aarx],1);
idft((int16_t*) &ue->pbch_vars[eNB_offset]->dl_ch_estimates[(p<<1)+aarx][ch_offset], }
(int16_t*) ue->pbch_vars[eNB_offset]->dl_ch_estimates_time[(p<<1)+aarx],1); }
}
}
} }
//} //}
} }
return(0); return(0);
} }
...@@ -473,21 +409,17 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -473,21 +409,17 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
unsigned char Ns, unsigned char Ns,
unsigned char symbol, unsigned char symbol,
unsigned short coreset_start_subcarrier, unsigned short coreset_start_subcarrier,
unsigned short nb_rb_coreset) unsigned short nb_rb_coreset) {
{
int pilot[200] __attribute__((aligned(16))); int pilot[200] __attribute__((aligned(16)));
unsigned char aarx; unsigned char aarx;
unsigned short k; unsigned short k;
unsigned int pilot_cnt; unsigned int pilot_cnt;
int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr; int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr;
int ch_offset,symbol_offset; int ch_offset,symbol_offset;
//uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1]; //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1];
uint8_t nushift; uint8_t nushift;
int **dl_ch_estimates =ue->pdcch_vars[ue->current_thread_id[Ns]][eNB_offset]->dl_ch_estimates; int **dl_ch_estimates =ue->pdcch_vars[ue->current_thread_id[Ns]][eNB_offset]->dl_ch_estimates;
int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF; int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF;
nushift = 1; nushift = 1;
ue->frame_parms.nushift = nushift; ue->frame_parms.nushift = nushift;
...@@ -497,62 +429,105 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -497,62 +429,105 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
ch_offset = ue->frame_parms.ofdm_symbol_size*symbol; ch_offset = ue->frame_parms.ofdm_symbol_size*symbol;
symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol; symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol;
k = coreset_start_subcarrier; k = coreset_start_subcarrier;
#ifdef DEBUG_PDCCH #ifdef DEBUG_PDCCH
printf("PDCCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,ue->frame_parms.ofdm_symbol_size, printf("PDCCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,
ue->frame_parms.ofdm_symbol_size,
ue->frame_parms.Ncp,Ns,k, symbol); ue->frame_parms.Ncp,Ns,k, symbol);
#endif #endif
fl = filt16a_l1; fl = filt16a_l1;
fm = filt16a_m1; fm = filt16a_m1;
fr = filt16a_r1; fr = filt16a_r1;
// generate pilot
// generate pilot
nr_pdcch_dmrs_rx(ue,eNB_offset,Ns,ue->nr_gold_pdcch[eNB_offset][Ns][symbol], &pilot[0],2000,nb_rb_coreset); nr_pdcch_dmrs_rx(ue,eNB_offset,Ns,ue->nr_gold_pdcch[eNB_offset][Ns][symbol], &pilot[0],2000,nb_rb_coreset);
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) { for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
pil = (int16_t *)&pilot[0]; pil = (int16_t *)&pilot[0];
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)];
dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset]; dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size)); memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size));
if (ue->high_speed_flag==0) // multiply previous channel estimate by ch_est_alpha if (ue->high_speed_flag==0) // multiply previous channel estimate by ch_est_alpha
multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1), multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
ue->ch_est_alpha,dl_ch-(ue->frame_parms.ofdm_symbol_size<<1), ue->ch_est_alpha,dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
1,ue->frame_parms.ofdm_symbol_size); 1,ue->frame_parms.ofdm_symbol_size);
#ifdef DEBUG_PDCCH #ifdef DEBUG_PDCCH
printf("pdcch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL); printf("pdcch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL);
printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset); printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset);
printf("rxF addr %p\n", rxF); printf("rxF addr %p\n", rxF);
printf("dl_ch addr %p\n",dl_ch); printf("dl_ch addr %p\n",dl_ch);
#endif #endif
// if ((ue->frame_parms.N_RB_DL&1)==0) { // if ((ue->frame_parms.N_RB_DL&1)==0) {
// Treat first 2 pilots specially (left edge) // Treat first 2 pilots specially (left edge)
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDCCH
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]);
#endif
multadd_real_vector_complex_scalar(fl,
ch,
dl_ch,
16);
pil+=2;
rxF+=8;
//for (int i= 0; i<8; i++)
//printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDCCH
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]);
#endif
multadd_real_vector_complex_scalar(fm,
ch,
dl_ch,
16);
pil+=2;
rxF+=8;
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDCCH
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]);
#endif
multadd_real_vector_complex_scalar(fr,
ch,
dl_ch,
16);
#ifdef DEBUG_PDCCH
for (int m =0; m<12; m++)
printf("data : dl_ch -> (%d,%d)\n",dl_ch[0+2*m],dl_ch[1+2*m]);
#endif
pil+=2;
rxF+=8;
dl_ch+=24;
k+=12;
for (pilot_cnt=3; pilot_cnt<(3*nb_rb_coreset); pilot_cnt+=3) {
if (k >= ue->frame_parms.ofdm_symbol_size) {
k-=ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)];
}
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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_PDCCH #ifdef DEBUG_PDCCH
printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[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("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]);
#endif #endif
multadd_real_vector_complex_scalar(fl, multadd_real_vector_complex_scalar(fl,
ch, ch,
dl_ch, dl_ch,
16); 16);
//for (int i= 0; i<8; i++)
// printf("pilot_cnt %d dl_ch %d %d\n", pilot_cnt, dl_ch+i, *(dl_ch+i));
pil+=2; pil+=2;
rxF+=8; rxF+=8;
//for (int i= 0; i<8; i++)
//printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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_PDCCH #ifdef DEBUG_PDCCH
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 %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]);
#endif #endif
multadd_real_vector_complex_scalar(fm, multadd_real_vector_complex_scalar(fm,
ch, ch,
...@@ -560,88 +535,24 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -560,88 +535,24 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
16); 16);
pil+=2; pil+=2;
rxF+=8; rxF+=8;
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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_PDCCH #ifdef DEBUG_PDCCH
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 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
#endif #endif
multadd_real_vector_complex_scalar(fr, multadd_real_vector_complex_scalar(fr,
ch, ch,
dl_ch, dl_ch,
16); 16);
#ifdef DEBUG_PDCCH
for (int m =0; m<12; m++)
printf("data : dl_ch -> (%d,%d)\n",dl_ch[0+2*m],dl_ch[1+2*m]);
#endif
pil+=2; pil+=2;
rxF+=8; rxF+=8;
dl_ch+=24; dl_ch+=24;
k+=12; k+=12;
}
for (pilot_cnt=3; pilot_cnt<(3*nb_rb_coreset); pilot_cnt+=3) {
if (k >= ue->frame_parms.ofdm_symbol_size){
k-=ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)];}
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDCCH
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]);
#endif
multadd_real_vector_complex_scalar(fl,
ch,
dl_ch,
16);
//for (int i= 0; i<8; i++)
// printf("pilot_cnt %d dl_ch %d %d\n", pilot_cnt, dl_ch+i, *(dl_ch+i));
pil+=2;
rxF+=8;
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDCCH
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]);
#endif
multadd_real_vector_complex_scalar(fm,
ch,
dl_ch,
16);
pil+=2;
rxF+=8;
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDCCH
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]);
#endif
multadd_real_vector_complex_scalar(fr,
ch,
dl_ch,
16);
pil+=2;
rxF+=8;
dl_ch+=24;
k+=12;
}
//}
//}
} }
return(0); return(0);
} }
...@@ -651,8 +562,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -651,8 +562,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
unsigned short p, unsigned short p,
unsigned char symbol, unsigned char symbol,
unsigned short bwp_start_subcarrier, unsigned short bwp_start_subcarrier,
unsigned short nb_rb_pdsch) unsigned short nb_rb_pdsch) {
{
int pilot[3280] __attribute__((aligned(16))); int pilot[3280] __attribute__((aligned(16)));
unsigned char aarx; unsigned char aarx;
unsigned short k; unsigned short k;
...@@ -660,13 +570,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -660,13 +570,10 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
int16_t ch[2],*pil,*rxF,*dl_ch; int16_t ch[2],*pil,*rxF,*dl_ch;
int16_t *fl,*fm,*fr,*fml,*fmr,*fmm,*fdcl,*fdcr,*fdclh,*fdcrh; int16_t *fl,*fm,*fr,*fml,*fmr,*fmm,*fdcl,*fdcr,*fdclh,*fdcrh;
int ch_offset,symbol_offset; int ch_offset,symbol_offset;
//uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1]; //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1];
uint8_t nushift; uint8_t nushift;
int **dl_ch_estimates =ue->pdsch_vars[ue->current_thread_id[Ns]][eNB_offset]->dl_ch_estimates; int **dl_ch_estimates =ue->pdsch_vars[ue->current_thread_id[Ns]][eNB_offset]->dl_ch_estimates;
int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF; int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF;
nushift = (p>>1)&1; nushift = (p>>1)&1;
ue->frame_parms.nushift = nushift; ue->frame_parms.nushift = nushift;
...@@ -676,48 +583,46 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -676,48 +583,46 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
ch_offset = ue->frame_parms.ofdm_symbol_size*symbol; ch_offset = ue->frame_parms.ofdm_symbol_size*symbol;
symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol; symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol;
k = bwp_start_subcarrier; k = bwp_start_subcarrier;
int re_offset = k; int re_offset = k;
#ifdef DEBUG_CH #ifdef DEBUG_CH
printf("PDSCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,symbol_offset,ue->frame_parms.ofdm_symbol_size, printf("PDSCH Channel Estimation : ThreadId %d, eNB_offset %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns], eNB_offset,ch_offset,
symbol_offset,ue->frame_parms.ofdm_symbol_size,
ue->frame_parms.Ncp,Ns,k, symbol); ue->frame_parms.Ncp,Ns,k, symbol);
#endif #endif
switch (nushift) { switch (nushift) {
case 0: case 0:
fl = filt8_l0; fl = filt8_l0;
fm = filt8_m0; fm = filt8_m0;
fr = filt8_r0; fr = filt8_r0;
fmm = filt8_mm0; fmm = filt8_mm0;
fml = filt8_m0; fml = filt8_m0;
fmr = filt8_mr0; fmr = filt8_mr0;
fdcl = filt8_dcl0; fdcl = filt8_dcl0;
fdcr = filt8_dcr0; fdcr = filt8_dcr0;
fdclh = filt8_dcl0_h; fdclh = filt8_dcl0_h;
fdcrh = filt8_dcr0_h; fdcrh = filt8_dcr0_h;
break; break;
case 1: case 1:
fl = filt8_l1; fl = filt8_l1;
fm = filt8_m1; fm = filt8_m1;
fr = filt8_r1; fr = filt8_r1;
fmm = filt8_mm1; fmm = filt8_mm1;
fml = filt8_ml1; fml = filt8_ml1;
fmr = filt8_m1; fmr = filt8_m1;
fdcl = filt8_dcl1; fdcl = filt8_dcl1;
fdcr = filt8_dcr1; fdcr = filt8_dcr1;
fdclh = filt8_dcl1_h; fdclh = filt8_dcl1_h;
fdcrh = filt8_dcr1_h; fdcrh = filt8_dcr1_h;
break; break;
default:
msg("pdsch_channel_estimation: nushift=%d -> ERROR\n",nushift);
return(-1);
break;
}
default:
msg("pdsch_channel_estimation: nushift=%d -> ERROR\n",nushift);
return(-1);
break;
}
// generate pilot // generate pilot
uint16_t rb_offset = (bwp_start_subcarrier - ue->frame_parms.first_carrier_offset) / 12; uint16_t rb_offset = (bwp_start_subcarrier - ue->frame_parms.first_carrier_offset) / 12;
...@@ -725,17 +630,17 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -725,17 +630,17 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
nr_pdsch_dmrs_rx(ue,Ns,ue->nr_gold_pdsch[eNB_offset][Ns][0], &pilot[0],1000,0,nb_rb_pdsch+rb_offset); nr_pdsch_dmrs_rx(ue,Ns,ue->nr_gold_pdsch[eNB_offset][Ns][0], &pilot[0],1000,0,nb_rb_pdsch+rb_offset);
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) { for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
pil = (int16_t *)&pilot[rb_offset*((config_type==0) ? 6:4)]; pil = (int16_t *)&pilot[rb_offset*((config_type==0) ? 6:4)];
k = k % ue->frame_parms.ofdm_symbol_size; k = k % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)];
dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset]; dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size)); memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size));
if (ue->high_speed_flag==0) // multiply previous channel estimate by ch_est_alpha if (ue->high_speed_flag==0) // multiply previous channel estimate by ch_est_alpha
multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1), multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
ue->ch_est_alpha,dl_ch-(ue->frame_parms.ofdm_symbol_size<<1), ue->ch_est_alpha,dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
1,ue->frame_parms.ofdm_symbol_size); 1,ue->frame_parms.ofdm_symbol_size);
#ifdef DEBUG_PDSCH #ifdef DEBUG_PDSCH
printf("ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL); printf("ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL);
printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset); printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset);
...@@ -743,137 +648,123 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -743,137 +648,123 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
printf("dl_ch addr %p nushift %d\n",dl_ch,nushift); printf("dl_ch addr %p nushift %d\n",dl_ch,nushift);
#endif #endif
//if ((ue->frame_parms.N_RB_DL&1)==0) { //if ((ue->frame_parms.N_RB_DL&1)==0) {
// Treat first 2 pilots specially (left edge)
// Treat first 2 pilots specially (left edge) ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); 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_PDSCH #ifdef DEBUG_PDSCH
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) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[2],rxF[3],&rxF[2],ch[0],ch[1],pil[0],pil[1]);
#endif #endif
multadd_real_vector_complex_scalar(fl, multadd_real_vector_complex_scalar(fl,
ch, ch,
dl_ch, dl_ch,
8); 8);
pil+=2; pil+=2;
re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
//for (int i= 0; i<8; i++) //for (int i= 0; i<8; i++)
//printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i)); //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDSCH
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]);
#endif
multadd_real_vector_complex_scalar(fml,
ch,
dl_ch,
8);
pil+=2;
re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
//printf("dl_ch addr %p\n",dl_ch);
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDSCH
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]);
#endif
multadd_real_vector_complex_scalar(fmm,
ch,
dl_ch,
8);
//for (int i= 0; i<16; i++)
//printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));
pil+=2;
re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
dl_ch+=8;
for (pilot_cnt=3; pilot_cnt<(6*nb_rb_pdsch-3); pilot_cnt+=2) {
//if ((pilot_cnt%6)==0)
//dl_ch+=4;
//printf("re_offset %d\n",re_offset);
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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_PDSCH #ifdef DEBUG_PDSCH
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 %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]);
#endif #endif
multadd_real_vector_complex_scalar(fml, multadd_real_vector_complex_scalar(fm,
ch, ch,
dl_ch, dl_ch,
8); 8);
pil+=2; pil+=2;
re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
//printf("dl_ch addr %p\n",dl_ch);
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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_PDSCH #ifdef DEBUG_PDSCH
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 %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]);
#endif #endif
multadd_real_vector_complex_scalar(fmm, multadd_real_vector_complex_scalar(fmm,
ch, ch,
dl_ch, dl_ch,
8); 8);
//for (int i= 0; i<16; i++)
//printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));
pil+=2; pil+=2;
re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
dl_ch+=8; dl_ch+=8;
}
for (pilot_cnt=3; pilot_cnt<(6*nb_rb_pdsch-3); pilot_cnt+=2) { // Treat first 2 pilots specially (right edge)
//if ((pilot_cnt%6)==0) ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
//dl_ch+=4; ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
//printf("re_offset %d\n",re_offset);
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDSCH
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]);
#endif
multadd_real_vector_complex_scalar(fm,
ch,
dl_ch,
8);
pil+=2;
re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDSCH
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]);
#endif
multadd_real_vector_complex_scalar(fmm,
ch,
dl_ch,
8);
pil+=2;
re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
dl_ch+=8;
}
// Treat first 2 pilots specially (right edge)
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDSCH #ifdef DEBUG_PDSCH
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]);
#endif #endif
multadd_real_vector_complex_scalar(fm, multadd_real_vector_complex_scalar(fm,
ch, ch,
dl_ch, dl_ch,
8); 8);
//for (int i= 0; i<8; i++)
//for (int i= 0; i<8; i++) //printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));
//printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i)); pil+=2;
re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
pil+=2; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size; ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDSCH #ifdef DEBUG_PDSCH
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]);
#endif #endif
multadd_real_vector_complex_scalar(fmr, multadd_real_vector_complex_scalar(fmr,
ch, ch,
dl_ch, dl_ch,
8); 8);
pil+=2;
pil+=2; re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size;
re_offset = (re_offset+2) % ue->frame_parms.ofdm_symbol_size; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; dl_ch+=8;
dl_ch+=8; ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
#ifdef DEBUG_PDSCH #ifdef DEBUG_PDSCH
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]);
#endif #endif
multadd_real_vector_complex_scalar(fr, multadd_real_vector_complex_scalar(fr,
ch, ch,
dl_ch, dl_ch,
8); 8);
//} //}
// check if PRB crosses DC and improve estimates around DC // check if PRB crosses DC and improve estimates around DC
if ((bwp_start_subcarrier >= ue->frame_parms.ofdm_symbol_size/2) && (bwp_start_subcarrier+nb_rb_pdsch*12 >= ue->frame_parms.ofdm_symbol_size)) { if ((bwp_start_subcarrier >= ue->frame_parms.ofdm_symbol_size/2) && (bwp_start_subcarrier+nb_rb_pdsch*12 >= ue->frame_parms.ofdm_symbol_size)) {
dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset]; dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
...@@ -888,55 +779,51 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -888,55 +779,51 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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);
// for proper allignment of SIMD vectors // for proper allignment of SIMD vectors
if((ue->frame_parms.N_RB_DL&1)==0) { if((ue->frame_parms.N_RB_DL&1)==0) {
multadd_real_vector_complex_scalar(fdcl, multadd_real_vector_complex_scalar(fdcl,
ch, ch,
dl_ch-4, dl_ch-4,
8); 8);
pil += 4; pil += 4;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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);
multadd_real_vector_complex_scalar(fdcr, multadd_real_vector_complex_scalar(fdcr,
ch, ch,
dl_ch-4, dl_ch-4,
8); 8);
} else { } else {
multadd_real_vector_complex_scalar(fdclh, multadd_real_vector_complex_scalar(fdclh,
ch, ch,
dl_ch, dl_ch,
8); 8);
pil += 4; pil += 4;
re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size; re_offset = (re_offset+4) % ue->frame_parms.ofdm_symbol_size;
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+nushift+re_offset)];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
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);
multadd_real_vector_complex_scalar(fdcrh, multadd_real_vector_complex_scalar(fdcrh,
ch, ch,
dl_ch, dl_ch,
8); 8);
} }
} }
#ifdef DEBUG_PDSCH #ifdef DEBUG_PDSCH
dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset]; dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
for(uint16_t idxP=0; idxP<ceil((float)nb_rb_pdsch*12/8); idxP++) { for(uint16_t idxP=0; idxP<ceil((float)nb_rb_pdsch*12/8); idxP++) {
for(uint8_t idxI=0; idxI<16; idxI+=2) { for(uint8_t idxI=0; idxI<16; idxI+=2) {
printf("%d\t%d\t",dl_ch[idxP*16+idxI],dl_ch[idxP*16+idxI+1]); printf("%d\t%d\t",dl_ch[idxP*16+idxI],dl_ch[idxP*16+idxI+1]);
} }
printf("%d\n",idxP); printf("%d\n",idxP);
} }
#endif
#endif
} }
return(0); return(0);
......
...@@ -46,50 +46,47 @@ ...@@ -46,50 +46,47 @@
//#define DEBUG_PUSCH_MAPPING //#define DEBUG_PUSCH_MAPPING
void nr_pusch_codeword_scrambling(uint8_t *in, void nr_pusch_codeword_scrambling(uint8_t *in,
uint32_t size, uint32_t size,
uint32_t Nid, uint32_t Nid,
uint32_t n_RNTI, uint32_t n_RNTI,
uint32_t* out) { uint32_t *out) {
uint8_t reset, b_idx; uint8_t reset, b_idx;
uint32_t x1, x2, s=0, temp_out; uint32_t x1, x2, s=0, temp_out;
reset = 1; reset = 1;
x2 = (n_RNTI<<15) + Nid; x2 = (n_RNTI<<15) + Nid;
for (int i=0; i<size; i++) { for (int i=0; i<size; i++) {
b_idx = i&0x1f; b_idx = i&0x1f;
if (b_idx==0) { if (b_idx==0) {
s = lte_gold_generic(&x1, &x2, reset); s = lte_gold_generic(&x1, &x2, reset);
reset = 0; reset = 0;
if (i) if (i)
out++; out++;
} }
if (in[i]==NR_PUSCH_x) if (in[i]==NR_PUSCH_x)
*out ^= 1<<b_idx; *out ^= 1<<b_idx;
else if (in[i]==NR_PUSCH_y){ else if (in[i]==NR_PUSCH_y) {
if (b_idx!=0) if (b_idx!=0)
*out ^= (*out & (1<<(b_idx-1)))<<1; *out ^= (*out & (1<<(b_idx-1)))<<1;
else{ else {
temp_out = *(out-1); temp_out = *(out-1);
*out ^= temp_out>>31; *out ^= temp_out>>31;
} }
} } else
else
*out ^= (((in[i])&1) ^ ((s>>b_idx)&1))<<b_idx; *out ^= (((in[i])&1) ^ ((s>>b_idx)&1))<<b_idx;
//printf("i %d b_idx %d in %d s 0x%08x out 0x%08x\n", i, b_idx, in[i], s, *out); //printf("i %d b_idx %d in %d s 0x%08x out 0x%08x\n", i, b_idx, in[i], s, *out);
} }
} }
void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
unsigned char harq_pid, unsigned char harq_pid,
uint8_t slot, uint8_t slot,
uint8_t thread_id, uint8_t thread_id,
int gNB_id) { int gNB_id) {
uint32_t available_bits; uint32_t available_bits;
uint8_t mod_order, cwd_index, num_of_codewords; uint8_t mod_order, cwd_index, num_of_codewords;
uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5];
...@@ -104,50 +101,42 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ...@@ -104,50 +101,42 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
int ap, start_symbol, Nid_cell, i; int ap, start_symbol, Nid_cell, i;
int sample_offsetF, N_RE_prime, N_PRB_oh; int sample_offsetF, N_RE_prime, N_PRB_oh;
uint16_t n_rnti; uint16_t n_rnti;
NR_UE_ULSCH_t *ulsch_ue; NR_UE_ULSCH_t *ulsch_ue;
NR_UL_UE_HARQ_t *harq_process_ul_ue; NR_UL_UE_HARQ_t *harq_process_ul_ue;
NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms; NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms;
NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][gNB_id]; NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][gNB_id];
num_of_codewords = 1; // tmp assumption num_of_codewords = 1; // tmp assumption
length_dmrs = 1; length_dmrs = 1;
n_rnti = 0x1234; n_rnti = 0x1234;
Nid_cell = 0; Nid_cell = 0;
N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig
for (cwd_index = 0;cwd_index < num_of_codewords; cwd_index++) { for (cwd_index = 0; cwd_index < num_of_codewords; cwd_index++) {
ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_index]; ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_index];
harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid]; harq_process_ul_ue = ulsch_ue->harq_processes[harq_pid];
ulsch_ue->length_dmrs = length_dmrs; ulsch_ue->length_dmrs = length_dmrs;
ulsch_ue->rnti = n_rnti; ulsch_ue->rnti = n_rnti;
ulsch_ue->Nid_cell = Nid_cell; ulsch_ue->Nid_cell = Nid_cell;
ulsch_ue->nb_re_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength*((UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4); ulsch_ue->nb_re_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength*((UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4);
N_RE_prime = NR_NB_SC_PER_RB*harq_process_ul_ue->number_of_symbols - ulsch_ue->nb_re_dmrs - N_PRB_oh; N_RE_prime = NR_NB_SC_PER_RB*harq_process_ul_ue->number_of_symbols - ulsch_ue->nb_re_dmrs - N_PRB_oh;
harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*harq_process_ul_ue->nb_rb*num_of_codewords; harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*harq_process_ul_ue->nb_rb*num_of_codewords;
mod_order = nr_get_Qm_ul(harq_process_ul_ue->mcs, 0); mod_order = nr_get_Qm_ul(harq_process_ul_ue->mcs, 0);
code_rate = nr_get_code_rate_ul(harq_process_ul_ue->mcs, 0); code_rate = nr_get_code_rate_ul(harq_process_ul_ue->mcs, 0);
harq_process_ul_ue->TBS = nr_compute_tbs(mod_order,
harq_process_ul_ue->TBS = nr_compute_tbs(mod_order, code_rate,
code_rate, harq_process_ul_ue->nb_rb,
harq_process_ul_ue->nb_rb, harq_process_ul_ue->number_of_symbols,
harq_process_ul_ue->number_of_symbols, ulsch_ue->nb_re_dmrs*ulsch_ue->length_dmrs,
ulsch_ue->nb_re_dmrs*ulsch_ue->length_dmrs, 0,
0, harq_process_ul_ue->Nl);
harq_process_ul_ue->Nl);
//-----------------------------------------------------// //-----------------------------------------------------//
// to be removed later when MAC is ready // to be removed later when MAC is ready
if (harq_process_ul_ue != NULL){ if (harq_process_ul_ue != NULL) {
for (i = 0; i < harq_process_ul_ue->TBS / 8; i++) { for (i = 0; i < harq_process_ul_ue->TBS / 8; i++) {
harq_process_ul_ue->a[i] = (unsigned char) rand(); harq_process_ul_ue->a[i] = (unsigned char) rand();
//printf("input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]); //printf("input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
} }
} else { } else {
LOG_E(PHY, "[phy_procedures_nrUE_TX] harq_process_ul_ue is NULL !!\n"); LOG_E(PHY, "[phy_procedures_nrUE_TX] harq_process_ul_ue is NULL !!\n");
...@@ -155,58 +144,40 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ...@@ -155,58 +144,40 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
} }
//-----------------------------------------------------// //-----------------------------------------------------//
/////////////////////////ULSCH coding///////////////////////// /////////////////////////ULSCH coding/////////////////////////
/////////// ///////////
nr_ulsch_encoding(ulsch_ue, frame_parms, harq_pid); nr_ulsch_encoding(ulsch_ue, frame_parms, harq_pid);
/////////// ///////////
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
/////////////////////////ULSCH scrambling///////////////////////// /////////////////////////ULSCH scrambling/////////////////////////
/////////// ///////////
mod_order = nr_get_Qm_ul(harq_process_ul_ue->mcs, 0); mod_order = nr_get_Qm_ul(harq_process_ul_ue->mcs, 0);
available_bits = nr_get_G(harq_process_ul_ue->nb_rb, available_bits = nr_get_G(harq_process_ul_ue->nb_rb,
harq_process_ul_ue->number_of_symbols, harq_process_ul_ue->number_of_symbols,
ulsch_ue->nb_re_dmrs, ulsch_ue->nb_re_dmrs,
ulsch_ue->length_dmrs, ulsch_ue->length_dmrs,
mod_order, mod_order,
1); 1);
memset(scrambled_output[cwd_index], 0, ((available_bits>>5)+1)*sizeof(uint32_t)); memset(scrambled_output[cwd_index], 0, ((available_bits>>5)+1)*sizeof(uint32_t));
nr_pusch_codeword_scrambling(ulsch_ue->g, nr_pusch_codeword_scrambling(ulsch_ue->g,
available_bits, available_bits,
ulsch_ue->Nid_cell, ulsch_ue->Nid_cell,
ulsch_ue->rnti, ulsch_ue->rnti,
scrambled_output[cwd_index]); // assume one codeword for the moment scrambled_output[cwd_index]); // assume one codeword for the moment
///////////// /////////////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/////////////////////////ULSCH modulation///////////////////////// /////////////////////////ULSCH modulation/////////////////////////
/////////// ///////////
nr_modulation(scrambled_output[cwd_index], // assume one codeword for the moment nr_modulation(scrambled_output[cwd_index], // assume one codeword for the moment
available_bits, available_bits,
mod_order, mod_order,
(int16_t *)ulsch_ue->d_mod); (int16_t *)ulsch_ue->d_mod);
// pusch_transform_precoding(ulsch_ue, frame_parms, harq_pid); // pusch_transform_precoding(ulsch_ue, frame_parms, harq_pid);
/////////// ///////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
} }
start_symbol = 14 - harq_process_ul_ue->number_of_symbols; start_symbol = 14 - harq_process_ul_ue->number_of_symbols;
/////////////////////////DMRS Modulation///////////////////////// /////////////////////////DMRS Modulation/////////////////////////
/////////// ///////////
pusch_dmrs = UE->nr_gold_pusch_dmrs[slot]; pusch_dmrs = UE->nr_gold_pusch_dmrs[slot];
...@@ -214,64 +185,46 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ...@@ -214,64 +185,46 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
int16_t mod_dmrs[n_dmrs<<1]; int16_t mod_dmrs[n_dmrs<<1];
dmrs_type = UE->dmrs_UplinkConfig.pusch_dmrs_type; dmrs_type = UE->dmrs_UplinkConfig.pusch_dmrs_type;
mapping_type = UE->pusch_config.pusch_TimeDomainResourceAllocation[0]->mappingType; mapping_type = UE->pusch_config.pusch_TimeDomainResourceAllocation[0]->mappingType;
l0 = get_l0_ul(mapping_type, 2); l0 = get_l0_ul(mapping_type, 2);
nr_modulation(pusch_dmrs[l0][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated nr_modulation(pusch_dmrs[l0][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated
/////////// ///////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/////////////////////////ULSCH layer mapping///////////////////////// /////////////////////////ULSCH layer mapping/////////////////////////
/////////// ///////////
tx_layers = (int16_t **)pusch_ue->txdataF_layers; tx_layers = (int16_t **)pusch_ue->txdataF_layers;
nr_ue_layer_mapping(UE->ulsch[thread_id][gNB_id], nr_ue_layer_mapping(UE->ulsch[thread_id][gNB_id],
harq_process_ul_ue->Nl, harq_process_ul_ue->Nl,
available_bits/mod_order, available_bits/mod_order,
tx_layers); tx_layers);
/////////// ///////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
//////////////////////// ULSCH transform precoding //////////////////////// //////////////////////// ULSCH transform precoding ////////////////////////
/////////// ///////////
l_prime[0] = 0; // single symbol ap 0 l_prime[0] = 0; // single symbol ap 0
uint8_t dmrs_symbol = l0+l_prime[0], l; // Assuming dmrs-AdditionalPosition = 0 uint8_t dmrs_symbol = l0+l_prime[0], l; // Assuming dmrs-AdditionalPosition = 0
#ifdef NR_SC_FDMA #ifdef NR_SC_FDMA
uint32_t nb_re_pusch, nb_re_dmrs_per_rb; uint32_t nb_re_pusch, nb_re_dmrs_per_rb;
uint32_t y_offset = 0; uint32_t y_offset = 0;
for (l = start_symbol; l < start_symbol + harq_process_ul_ue->number_of_symbols; l++) { for (l = start_symbol; l < start_symbol + harq_process_ul_ue->number_of_symbols; l++) {
if(l == dmrs_symbol) if(l == dmrs_symbol)
nb_re_dmrs_per_rb = ulsch_ue->nb_re_dmrs; // [hna] ulsch_ue->nb_re_dmrs = 6 in this configuration nb_re_dmrs_per_rb = ulsch_ue->nb_re_dmrs; // [hna] ulsch_ue->nb_re_dmrs = 6 in this configuration
else else
nb_re_dmrs_per_rb = 0; nb_re_dmrs_per_rb = 0;
nb_re_pusch = harq_process_ul_ue->nb_rb * (NR_NB_SC_PER_RB - nb_re_dmrs_per_rb);
nr_dft(&ulsch_ue->y[y_offset], &((int32_t*)tx_layers[0])[y_offset], nb_re_pusch);
nb_re_pusch = harq_process_ul_ue->nb_rb * (NR_NB_SC_PER_RB - nb_re_dmrs_per_rb);
nr_dft(&ulsch_ue->y[y_offset], &((int32_t *)tx_layers[0])[y_offset], nb_re_pusch);
y_offset = y_offset + nb_re_pusch; y_offset = y_offset + nb_re_pusch;
} }
#else #else
memcpy(ulsch_ue->y, tx_layers[0], (available_bits/mod_order)*sizeof(int32_t)); memcpy(ulsch_ue->y, tx_layers[0], (available_bits/mod_order)*sizeof(int32_t));
#endif #endif
/////////// ///////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/////////////////////////ULSCH RE mapping///////////////////////// /////////////////////////ULSCH RE mapping/////////////////////////
/////////// ///////////
txdataF = UE->common_vars.txdataF; txdataF = UE->common_vars.txdataF;
start_rb = harq_process_ul_ue->first_rb; start_rb = harq_process_ul_ue->first_rb;
start_sc = frame_parms->first_carrier_offset + start_rb*NR_NB_SC_PER_RB; start_sc = frame_parms->first_carrier_offset + start_rb*NR_NB_SC_PER_RB;
...@@ -279,53 +232,39 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ...@@ -279,53 +232,39 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
start_sc -= frame_parms->ofdm_symbol_size; start_sc -= frame_parms->ofdm_symbol_size;
for (ap=0; ap<harq_process_ul_ue->Nl; ap++) { for (ap=0; ap<harq_process_ul_ue->Nl; ap++) {
// DMRS params for this ap // DMRS params for this ap
get_Wt(Wt, ap, dmrs_type); get_Wt(Wt, ap, dmrs_type);
get_Wf(Wf, ap, dmrs_type); get_Wf(Wf, ap, dmrs_type);
delta = get_delta(ap, dmrs_type); delta = get_delta(ap, dmrs_type);
uint8_t k_prime=0; uint8_t k_prime=0;
uint16_t m=0, n=0, dmrs_idx=0, k=0; uint16_t m=0, n=0, dmrs_idx=0, k=0;
for (l=start_symbol; l<start_symbol+harq_process_ul_ue->number_of_symbols; l++) { for (l=start_symbol; l<start_symbol+harq_process_ul_ue->number_of_symbols; l++) {
k = start_sc; k = start_sc;
for (i=0; i<harq_process_ul_ue->nb_rb*NR_NB_SC_PER_RB; i++) { for (i=0; i<harq_process_ul_ue->nb_rb*NR_NB_SC_PER_RB; i++) {
sample_offsetF = l*frame_parms->ofdm_symbol_size + k; sample_offsetF = l*frame_parms->ofdm_symbol_size + k;
if ((l == dmrs_symbol) && (k == ((start_sc+get_dmrs_freq_idx_ul(n, k_prime, delta, dmrs_type))%(frame_parms->ofdm_symbol_size)))) { if ((l == dmrs_symbol) && (k == ((start_sc+get_dmrs_freq_idx_ul(n, k_prime, delta, dmrs_type))%(frame_parms->ofdm_symbol_size)))) {
((int16_t *)txdataF[ap])[(sample_offsetF)<<1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[dmrs_idx<<1]) >> 15;
((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[dmrs_idx<<1]) >> 15; ((int16_t *)txdataF[ap])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15;
((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; #ifdef DEBUG_PUSCH_MAPPING
printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t dmrs: %d %d\n",
#ifdef DEBUG_PUSCH_MAPPING dmrs_idx, l, k, k_prime, n, ((int16_t *)txdataF[ap])[(sample_offsetF)<<1],
printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t dmrs: %d %d\n", ((int16_t *)txdataF[ap])[((sample_offsetF)<<1) + 1]);
dmrs_idx, l, k, k_prime, n, ((int16_t*)txdataF[ap])[(sample_offsetF)<<1], #endif
((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1]);
#endif
dmrs_idx++; dmrs_idx++;
k_prime++; k_prime++;
k_prime&=1; k_prime&=1;
n+=(k_prime)?0:1; n+=(k_prime)?0:1;
} } else {
((int16_t *)txdataF[ap])[(sample_offsetF)<<1] = ((int16_t *) ulsch_ue->y)[m<<1];
else { ((int16_t *)txdataF[ap])[((sample_offsetF)<<1) + 1] = ((int16_t *) ulsch_ue->y)[(m<<1) + 1];
#ifdef DEBUG_PUSCH_MAPPING
((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = ((int16_t *) ulsch_ue->y)[m<<1]; printf("m %d\t l %d \t k %d \t txdataF: %d %d\n",
((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = ((int16_t *) ulsch_ue->y)[(m<<1) + 1]; m, l, k, ((int16_t *)txdataF[ap])[(sample_offsetF)<<1],
((int16_t *)txdataF[ap])[((sample_offsetF)<<1) + 1]);
#ifdef DEBUG_PUSCH_MAPPING #endif
printf("m %d\t l %d \t k %d \t txdataF: %d %d\n",
m, l, k, ((int16_t*)txdataF[ap])[(sample_offsetF)<<1],
((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1]);
#endif
m++; m++;
} }
...@@ -337,7 +276,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ...@@ -337,7 +276,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
/////////// ///////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
return; return;
} }
...@@ -348,22 +286,18 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, ...@@ -348,22 +286,18 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE,
uint8_t thread_id, uint8_t thread_id,
uint8_t gNB_id, uint8_t gNB_id,
NR_DL_FRAME_PARMS *frame_parms) { NR_DL_FRAME_PARMS *frame_parms) {
int tx_offset, ap; int tx_offset, ap;
int32_t **txdata; int32_t **txdata;
int32_t **txdataF; int32_t **txdataF;
int timing_advance; int timing_advance;
uint8_t Nl = UE->ulsch[thread_id][gNB_id][0]->harq_processes[harq_pid]->Nl; // cw 0 uint8_t Nl = UE->ulsch[thread_id][gNB_id][0]->harq_processes[harq_pid]->Nl; // cw 0
/////////////////////////IFFT/////////////////////// /////////////////////////IFFT///////////////////////
/////////// ///////////
#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
timing_advance = UE->timing_advance; timing_advance = UE->timing_advance;
#else #else
timing_advance = 0; timing_advance = 0;
#endif #endif
tx_offset = slot*frame_parms->samples_per_slot - timing_advance; tx_offset = slot*frame_parms->samples_per_slot - timing_advance;
if (tx_offset < 0) if (tx_offset < 0)
...@@ -373,20 +307,21 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, ...@@ -373,20 +307,21 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE,
txdataF = UE->common_vars.txdataF; txdataF = UE->common_vars.txdataF;
for (ap = 0; ap < Nl; ap++) { for (ap = 0; ap < Nl; ap++) {
if (frame_parms->Ncp == 1) { // extended cyclic prefix if (frame_parms->Ncp == 1) { // extended cyclic prefix
PHY_ofdm_mod(txdataF[ap], PHY_ofdm_mod(txdataF[ap],
&txdata[ap][tx_offset], &txdata[ap][tx_offset],
frame_parms->ofdm_symbol_size, frame_parms->ofdm_symbol_size,
12, 12,
frame_parms->nb_prefix_samples, frame_parms->nb_prefix_samples,
CYCLIC_PREFIX); CYCLIC_PREFIX);
} else { // normal cyclic prefix } else { // normal cyclic prefix
nr_normal_prefix_mod(txdataF[ap], nr_normal_prefix_mod(txdataF[ap],
&txdata[ap][tx_offset], &txdata[ap][tx_offset],
14, 14,
frame_parms); frame_parms);
}
} }
}
/////////// ///////////
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
return 0; return 0;
......
...@@ -60,8 +60,7 @@ ...@@ -60,8 +60,7 @@
//#define DBG_PSS_NR //#define DBG_PSS_NR
void *get_idft(int ofdm_symbol_size) void *get_idft(int ofdm_symbol_size) {
{
void (*idft)(int16_t *,int16_t *, int); void (*idft)(int16_t *,int16_t *, int);
switch (ofdm_symbol_size) { switch (ofdm_symbol_size) {
...@@ -105,8 +104,9 @@ void *get_idft(int ofdm_symbol_size) ...@@ -105,8 +104,9 @@ void *get_idft(int ofdm_symbol_size)
printf("function get_idft : unsupported ofdm symbol size \n"); printf("function get_idft : unsupported ofdm symbol size \n");
abort(); abort();
break; break;
} }
return idft;
return idft;
} }
/******************************************************************* /*******************************************************************
...@@ -121,8 +121,7 @@ void *get_idft(int ofdm_symbol_size) ...@@ -121,8 +121,7 @@ void *get_idft(int ofdm_symbol_size)
* *
*********************************************************************/ *********************************************************************/
void *get_dft(int ofdm_symbol_size) void *get_dft(int ofdm_symbol_size) {
{
void (*dft)(int16_t *,int16_t *, int); void (*dft)(int16_t *,int16_t *, int);
switch (ofdm_symbol_size) { switch (ofdm_symbol_size) {
...@@ -162,8 +161,9 @@ void *get_dft(int ofdm_symbol_size) ...@@ -162,8 +161,9 @@ void *get_dft(int ofdm_symbol_size)
printf("function get_dft : unsupported ofdm symbol size \n"); printf("function get_dft : unsupported ofdm symbol size \n");
abort(); abort();
break; break;
} }
return dft;
return dft;
} }
/******************************************************************* /*******************************************************************
...@@ -180,8 +180,7 @@ void *get_dft(int ofdm_symbol_size) ...@@ -180,8 +180,7 @@ void *get_dft(int ofdm_symbol_size)
* *
*********************************************************************/ *********************************************************************/
void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) {
{
AssertFatal(fp->ofdm_symbol_size > 127,"Illegal ofdm_symbol_size %d\n",fp->ofdm_symbol_size); AssertFatal(fp->ofdm_symbol_size > 127,"Illegal ofdm_symbol_size %d\n",fp->ofdm_symbol_size);
AssertFatal(N_ID_2>=0 && N_ID_2 <=2,"Illegal N_ID_2 %d\n",N_ID_2); AssertFatal(N_ID_2>=0 && N_ID_2 <=2,"Illegal N_ID_2 %d\n",N_ID_2);
int16_t d_pss[LENGTH_PSS_NR]; int16_t d_pss[LENGTH_PSS_NR];
...@@ -192,14 +191,11 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) ...@@ -192,14 +191,11 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2)
int16_t *primary_synchro = primary_synchro_nr[N_ID_2]; /* pss in complex with alternatively i then q */ int16_t *primary_synchro = primary_synchro_nr[N_ID_2]; /* pss in complex with alternatively i then q */
int16_t *primary_synchro2 = primary_synchro_nr2[N_ID_2]; /* pss in complex with alternatively i then q */ int16_t *primary_synchro2 = primary_synchro_nr2[N_ID_2]; /* pss in complex with alternatively i then q */
void (*idft)(int16_t *,int16_t *, int); void (*idft)(int16_t *,int16_t *, int);
#define INITIAL_PSS_NR (7)
#define INITIAL_PSS_NR (7) const int x_initial[INITIAL_PSS_NR] = {0, 1, 1, 0, 1, 1, 1};
const int x_initial[INITIAL_PSS_NR] = {0, 1, 1 , 0, 1, 1, 1};
assert(N_ID_2 < NUMBER_PSS_SEQUENCE); assert(N_ID_2 < NUMBER_PSS_SEQUENCE);
assert(size <= SYNCF_TMP_SIZE); assert(size <= SYNCF_TMP_SIZE);
assert(size <= SYNC_TMP_SIZE); assert(size <= SYNC_TMP_SIZE);
bzero(synchroF_tmp, size); bzero(synchroF_tmp, size);
bzero(synchro_tmp, size); bzero(synchro_tmp, size);
...@@ -212,7 +208,7 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) ...@@ -212,7 +208,7 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2)
} }
for (int n=0; n < LENGTH_PSS_NR; n++) { for (int n=0; n < LENGTH_PSS_NR; n++) {
int m = (n + 43*N_ID_2)%(LENGTH_PSS_NR); int m = (n + 43*N_ID_2)%(LENGTH_PSS_NR);
d_pss[n] = 1 - 2*x[m]; d_pss[n] = 1 - 2*x[m];
} }
...@@ -237,12 +233,10 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) ...@@ -237,12 +233,10 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2)
sprintf(output_file, "pss_seq_%d_%u.m", N_ID_2, length); sprintf(output_file, "pss_seq_%d_%u.m", N_ID_2, length);
sprintf(sequence_name, "pss_seq_%d_%u", N_ID_2, length); sprintf(sequence_name, "pss_seq_%d_%u", N_ID_2, length);
printf("file %s sequence %s\n", output_file, sequence_name); printf("file %s sequence %s\n", output_file, sequence_name);
LOG_M(output_file, sequence_name, primary_synchro, LENGTH_PSS_NR, 1, 1); LOG_M(output_file, sequence_name, primary_synchro, LENGTH_PSS_NR, 1, 1);
} }
#endif #endif
/* call of IDFT should be done with ordered input as below /* call of IDFT should be done with ordered input as below
* *
* n input samples * n input samples
...@@ -264,26 +258,20 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) ...@@ -264,26 +258,20 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2)
* *
* sample 0 is for continuous frequency which is used here * sample 0 is for continuous frequency which is used here
*/ */
unsigned int k = fp->first_carrier_offset + fp->ssb_start_subcarrier + 56; //and unsigned int k = fp->first_carrier_offset + fp->ssb_start_subcarrier + 56; //and
if (k>= fp->ofdm_symbol_size) k-=fp->ofdm_symbol_size;
if (k>= fp->ofdm_symbol_size) k-=fp->ofdm_symbol_size;
for (int i=0; i < LENGTH_PSS_NR; i++) { for (int i=0; i < LENGTH_PSS_NR; i++) {
synchroF_tmp[2*k] = primary_synchro[2*i]; synchroF_tmp[2*k] = primary_synchro[2*i];
synchroF_tmp[2*k+1] = primary_synchro[2*i+1]; synchroF_tmp[2*k+1] = primary_synchro[2*i+1];
k++; k++;
if (k == length) k=0; if (k == length) k=0;
} }
/* IFFT will give temporal signal of Pss */ /* IFFT will give temporal signal of Pss */
idft = get_idft(length); idft = get_idft(length);
idft(synchroF_tmp, /* complex input */ idft(synchroF_tmp, /* complex input */
synchro_tmp, /* complex output */ synchro_tmp, /* complex output */
1); /* scaling factor */ 1); /* scaling factor */
...@@ -300,9 +288,7 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) ...@@ -300,9 +288,7 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2)
char sequence_name[255]; char sequence_name[255];
sprintf(output_file, "%s%d_%u%s","pss_seq_t_", N_ID_2, length, ".m"); sprintf(output_file, "%s%d_%u%s","pss_seq_t_", N_ID_2, length, ".m");
sprintf(sequence_name, "%s%d_%u","pss_seq_t_", N_ID_2, length); sprintf(sequence_name, "%s%d_%u","pss_seq_t_", N_ID_2, length);
printf("file %s sequence %s\n", output_file, sequence_name); printf("file %s sequence %s\n", output_file, sequence_name);
LOG_M(output_file, sequence_name, primary_synchro_time, length, 1, 1); LOG_M(output_file, sequence_name, primary_synchro_time, length, 1, 1);
sprintf(output_file, "%s%d_%u%s","pss_seq_f_", N_ID_2, length, ".m"); sprintf(output_file, "%s%d_%u%s","pss_seq_f_", N_ID_2, length, ".m");
sprintf(sequence_name, "%s%d_%u","pss_seq_f_", N_ID_2, length); sprintf(sequence_name, "%s%d_%u","pss_seq_f_", N_ID_2, length);
...@@ -310,21 +296,14 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) ...@@ -310,21 +296,14 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2)
} }
#endif #endif
#if 0 #if 0
/* it allows checking that process of idft on a signal and then dft gives same signal with limited errors */ /* it allows checking that process of idft on a signal and then dft gives same signal with limited errors */
if ((N_ID_2 == 0) && (length == 256)) { if ((N_ID_2 == 0) && (length == 256)) {
LOG_M("pss_f00.m","pss_f00",synchro_tmp,length,1,1); LOG_M("pss_f00.m","pss_f00",synchro_tmp,length,1,1);
bzero(synchroF_tmp, size); bzero(synchroF_tmp, size);
void (*dft)(int16_t *,int16_t *, int) = get_dft(length); void (*dft)(int16_t *,int16_t *, int) = get_dft(length);
/* get pss in the time domain by applying an inverse FFT */ /* get pss in the time domain by applying an inverse FFT */
dft(synchro_tmp, /* complex input */ dft(synchro_tmp, /* complex input */
synchroF_tmp, /* complex output */ synchroF_tmp, /* complex output */
...@@ -336,14 +315,13 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) ...@@ -336,14 +315,13 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2)
/* check Pss */ /* check Pss */
k = length - (LENGTH_PSS_NR/2); k = length - (LENGTH_PSS_NR/2);
#define LIMIT_ERROR_FFT (10) #define LIMIT_ERROR_FFT (10)
for (int i=0; i < LENGTH_PSS_NR; i++) { for (int i=0; i < LENGTH_PSS_NR; i++) {
if (abs(synchroF_tmp[2*k] - primary_synchro[2*i]) > LIMIT_ERROR_FFT) { if (abs(synchroF_tmp[2*k] - primary_synchro[2*i]) > LIMIT_ERROR_FFT) {
printf("Pss Error[%d] Compute %d Reference %d \n", k, synchroF_tmp[2*k], primary_synchro[2*i]); printf("Pss Error[%d] Compute %d Reference %d \n", k, synchroF_tmp[2*k], primary_synchro[2*i]);
} }
if (abs(synchroF_tmp[2*k+1] - primary_synchro[2*i+1]) > LIMIT_ERROR_FFT) { if (abs(synchroF_tmp[2*k+1] - primary_synchro[2*i+1]) > LIMIT_ERROR_FFT) {
printf("Pss Error[%d] Compute %d Reference %d\n", (2*k+1), synchroF_tmp[2*k+1], primary_synchro[2*i+1]); printf("Pss Error[%d] Compute %d Reference %d\n", (2*k+1), synchroF_tmp[2*k+1], primary_synchro[2*i+1]);
} }
...@@ -355,6 +333,7 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) ...@@ -355,6 +333,7 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2)
} }
} }
} }
#endif #endif
} }
...@@ -371,48 +350,49 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2) ...@@ -371,48 +350,49 @@ void generate_pss_nr(NR_DL_FRAME_PARMS *fp,int N_ID_2)
* *
*********************************************************************/ *********************************************************************/
void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue) void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue) {
{
int ofdm_symbol_size = frame_parms_ue->ofdm_symbol_size; int ofdm_symbol_size = frame_parms_ue->ofdm_symbol_size;
int sizePss = LENGTH_PSS_NR * IQ_SIZE; /* complex value i & q signed 16 bits */ int sizePss = LENGTH_PSS_NR * IQ_SIZE; /* complex value i & q signed 16 bits */
int size = ofdm_symbol_size * IQ_SIZE; /* i and q samples signed 16 bits */ int size = ofdm_symbol_size * IQ_SIZE; /* i and q samples signed 16 bits */
int16_t *p = NULL; int16_t *p = NULL;
int64_t *q = NULL; int64_t *q = NULL;
AssertFatal(ofdm_symbol_size > 127, "illegal ofdm_symbol_size %d\n",ofdm_symbol_size); AssertFatal(ofdm_symbol_size > 127, "illegal ofdm_symbol_size %d\n",ofdm_symbol_size);
for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) {
for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) {
p = malloc16(sizePss); /* pss in complex with alternatively i then q */ p = malloc16(sizePss); /* pss in complex with alternatively i then q */
if (p != NULL) { if (p != NULL) {
primary_synchro_nr[i] = p; primary_synchro_nr[i] = p;
bzero( primary_synchro_nr[i], sizePss); bzero( primary_synchro_nr[i], sizePss);
} } else {
else {
LOG_E(PHY,"Fatal memory allocation problem \n"); LOG_E(PHY,"Fatal memory allocation problem \n");
assert(0); assert(0);
} }
p = malloc(LENGTH_PSS_NR*2); p = malloc(LENGTH_PSS_NR*2);
if (p != NULL) { if (p != NULL) {
primary_synchro_nr2[i] = p; primary_synchro_nr2[i] = p;
bzero( primary_synchro_nr2[i],LENGTH_PSS_NR*2); bzero( primary_synchro_nr2[i],LENGTH_PSS_NR*2);
} }
p = malloc16(size); p = malloc16(size);
if (p != NULL) { if (p != NULL) {
primary_synchro_time_nr[i] = p; primary_synchro_time_nr[i] = p;
bzero( primary_synchro_time_nr[i], size); bzero( primary_synchro_time_nr[i], size);
} } else {
else {
LOG_E(PHY,"Fatal memory allocation problem \n"); LOG_E(PHY,"Fatal memory allocation problem \n");
assert(0); assert(0);
} }
size = sizeof(int64_t)*(frame_parms_ue->samples_per_frame + (2*ofdm_symbol_size)); size = sizeof(int64_t)*(frame_parms_ue->samples_per_frame + (2*ofdm_symbol_size));
q = (int64_t*)malloc16(size); q = (int64_t *)malloc16(size);
if (q != NULL) { if (q != NULL) {
pss_corr_ue[i] = q; pss_corr_ue[i] = q;
bzero( pss_corr_ue[i], size); bzero( pss_corr_ue[i], size);
} } else {
else {
LOG_E(PHY,"Fatal memory allocation problem \n"); LOG_E(PHY,"Fatal memory allocation problem \n");
assert(0); assert(0);
} }
...@@ -433,15 +413,12 @@ void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue) ...@@ -433,15 +413,12 @@ void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue)
* *
*********************************************************************/ *********************************************************************/
void free_context_pss_nr(void) void free_context_pss_nr(void) {
{
for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) { for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) {
if (primary_synchro_time_nr[i] != NULL) { if (primary_synchro_time_nr[i] != NULL) {
free(primary_synchro_time_nr[i]); free(primary_synchro_time_nr[i]);
primary_synchro_time_nr[i] = NULL; primary_synchro_time_nr[i] = NULL;
} } else {
else {
LOG_E(PHY,"Fatal memory deallocation problem \n"); LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0); assert(0);
} }
...@@ -449,8 +426,7 @@ void free_context_pss_nr(void) ...@@ -449,8 +426,7 @@ void free_context_pss_nr(void)
if (primary_synchro_nr[i] != NULL) { if (primary_synchro_nr[i] != NULL) {
free(primary_synchro_nr[i]); free(primary_synchro_nr[i]);
primary_synchro_nr[i] = NULL; primary_synchro_nr[i] = NULL;
} } else {
else {
LOG_E(PHY,"Fatal memory deallocation problem \n"); LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0); assert(0);
} }
...@@ -458,8 +434,7 @@ void free_context_pss_nr(void) ...@@ -458,8 +434,7 @@ void free_context_pss_nr(void)
if (pss_corr_ue[i] != NULL) { if (pss_corr_ue[i] != NULL) {
free(pss_corr_ue[i]); free(pss_corr_ue[i]);
pss_corr_ue[i] = NULL; pss_corr_ue[i] = NULL;
} } else {
else {
LOG_E(PHY,"Fatal memory deallocation problem \n"); LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0); assert(0);
} }
...@@ -478,27 +453,25 @@ void free_context_pss_nr(void) ...@@ -478,27 +453,25 @@ void free_context_pss_nr(void)
* *
*********************************************************************/ *********************************************************************/
void init_context_synchro_nr(NR_DL_FRAME_PARMS *frame_parms_ue) void init_context_synchro_nr(NR_DL_FRAME_PARMS *frame_parms_ue) {
{
#ifndef STATIC_SYNC_BUFFER #ifndef STATIC_SYNC_BUFFER
/* initialise global buffers for synchronisation */ /* initialise global buffers for synchronisation */
synchroF_tmp = malloc16(SYNCF_TMP_SIZE); synchroF_tmp = malloc16(SYNCF_TMP_SIZE);
if (synchroF_tmp == NULL) { if (synchroF_tmp == NULL) {
LOG_E(PHY,"Fatal memory allocation problem \n"); LOG_E(PHY,"Fatal memory allocation problem \n");
assert(0); assert(0);
} }
synchro_tmp = malloc16(SYNC_TMP_SIZE); synchro_tmp = malloc16(SYNC_TMP_SIZE);
if (synchro_tmp == NULL) { if (synchro_tmp == NULL) {
LOG_E(PHY,"Fatal memory allocation problem \n"); LOG_E(PHY,"Fatal memory allocation problem \n");
assert(0); assert(0);
} }
#endif #endif
init_context_pss_nr(frame_parms_ue); init_context_pss_nr(frame_parms_ue);
init_context_sss_nr(AMP); init_context_sss_nr(AMP);
} }
...@@ -514,15 +487,13 @@ void init_context_synchro_nr(NR_DL_FRAME_PARMS *frame_parms_ue) ...@@ -514,15 +487,13 @@ void init_context_synchro_nr(NR_DL_FRAME_PARMS *frame_parms_ue)
* *
*********************************************************************/ *********************************************************************/
void free_context_synchro_nr(void) void free_context_synchro_nr(void) {
{
#ifndef STATIC_SYNC_BUFFER #ifndef STATIC_SYNC_BUFFER
if (synchroF_tmp != NULL) { if (synchroF_tmp != NULL) {
free(synchroF_tmp); free(synchroF_tmp);
synchroF_tmp = NULL; synchroF_tmp = NULL;
} } else {
else {
LOG_E(PHY,"Fatal memory deallocation problem \n"); LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0); assert(0);
} }
...@@ -530,14 +501,12 @@ void free_context_synchro_nr(void) ...@@ -530,14 +501,12 @@ void free_context_synchro_nr(void)
if (synchro_tmp != NULL) { if (synchro_tmp != NULL) {
free(synchro_tmp); free(synchro_tmp);
synchro_tmp = NULL; synchro_tmp = NULL;
} } else {
else {
LOG_E(PHY,"Fatal memory deallocation problem \n"); LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0); assert(0);
} }
#endif #endif
free_context_pss_nr(); free_context_pss_nr();
} }
...@@ -553,18 +522,14 @@ void free_context_synchro_nr(void) ...@@ -553,18 +522,14 @@ void free_context_synchro_nr(void)
* *
*********************************************************************/ *********************************************************************/
void set_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_change) void set_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_change) {
{
/* set new value according to rate_change */ /* set new value according to rate_change */
frame_parms_ue->ofdm_symbol_size = (frame_parms_ue->ofdm_symbol_size / rate_change); frame_parms_ue->ofdm_symbol_size = (frame_parms_ue->ofdm_symbol_size / rate_change);
frame_parms_ue->samples_per_tti = (frame_parms_ue->samples_per_tti / rate_change); frame_parms_ue->samples_per_tti = (frame_parms_ue->samples_per_tti / rate_change);
frame_parms_ue->samples_per_subframe = (frame_parms_ue->samples_per_subframe / rate_change); frame_parms_ue->samples_per_subframe = (frame_parms_ue->samples_per_subframe / rate_change);
free_context_pss_nr(); free_context_pss_nr();
/* pss reference have to be rebuild with new parameters ie ofdm symbol size */ /* pss reference have to be rebuild with new parameters ie ofdm symbol size */
init_context_synchro_nr(frame_parms_ue); init_context_synchro_nr(frame_parms_ue);
#ifdef SYNCHRO_DECIMAT #ifdef SYNCHRO_DECIMAT
set_pss_nr(frame_parms_ue->ofdm_symbol_size); set_pss_nr(frame_parms_ue->ofdm_symbol_size);
#endif #endif
...@@ -582,14 +547,11 @@ void set_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_change ...@@ -582,14 +547,11 @@ void set_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_change
* *
*********************************************************************/ *********************************************************************/
void restore_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_change) void restore_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_change) {
{
frame_parms_ue->ofdm_symbol_size = frame_parms_ue->ofdm_symbol_size * rate_change; frame_parms_ue->ofdm_symbol_size = frame_parms_ue->ofdm_symbol_size * rate_change;
frame_parms_ue->samples_per_tti = frame_parms_ue->samples_per_tti * rate_change; frame_parms_ue->samples_per_tti = frame_parms_ue->samples_per_tti * rate_change;
frame_parms_ue->samples_per_subframe = frame_parms_ue->samples_per_subframe * rate_change; frame_parms_ue->samples_per_subframe = frame_parms_ue->samples_per_subframe * rate_change;
free_context_pss_nr(); free_context_pss_nr();
/* pss reference have to be rebuild with new parameters ie ofdm symbol size */ /* pss reference have to be rebuild with new parameters ie ofdm symbol size */
init_context_synchro_nr(frame_parms_ue); init_context_synchro_nr(frame_parms_ue);
#ifdef SYNCHRO_DECIMAT #ifdef SYNCHRO_DECIMAT
...@@ -612,41 +574,26 @@ void restore_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_ch ...@@ -612,41 +574,26 @@ void restore_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_ch
* *
********************************************************************/ ********************************************************************/
void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int **rxdata) void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int **rxdata) {
{
NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms); NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms);
int samples_for_frame = 2*frame_parms->samples_per_frame; int samples_for_frame = 2*frame_parms->samples_per_frame;
AssertFatal(frame_parms->samples_per_tti > 3839,"Illegal samples_per_tti %d\n",frame_parms->samples_per_tti); AssertFatal(frame_parms->samples_per_tti > 3839,"Illegal samples_per_tti %d\n",frame_parms->samples_per_tti);
#if TEST_SYNCHRO_TIMING_PSS #if TEST_SYNCHRO_TIMING_PSS
opp_enabled = 1; opp_enabled = 1;
start_meas(&generic_time[TIME_RATE_CHANGE]); start_meas(&generic_time[TIME_RATE_CHANGE]);
#endif #endif
/* build with cic filter does not work properly. Performances are significantly deteriorated */
/* build with cic filter does not work properly. Performances are significantly deteriorated */
#ifdef CIC_DECIMATOR #ifdef CIC_DECIMATOR
cic_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][0]), (int16_t *)&(rxdata[0][0]), cic_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][0]), (int16_t *)&(rxdata[0][0]),
samples_for_frame, rate_change, CIC_FILTER_STAGE_NUMBER, 0, FIR_RATE_CHANGE); samples_for_frame, rate_change, CIC_FILTER_STAGE_NUMBER, 0, FIR_RATE_CHANGE);
#else #else
fir_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][0]), (int16_t *)&(rxdata[0][0]), fir_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][0]), (int16_t *)&(rxdata[0][0]),
samples_for_frame, rate_change, 0); samples_for_frame, rate_change, 0);
#endif #endif
set_frame_context_pss_nr(frame_parms, rate_change); set_frame_context_pss_nr(frame_parms, rate_change);
#if TEST_SYNCHRO_TIMING_PSS #if TEST_SYNCHRO_TIMING_PSS
stop_meas(&generic_time[TIME_RATE_CHANGE]); stop_meas(&generic_time[TIME_RATE_CHANGE]);
printf("Rate change execution duration %5.2f \n", generic_time[TIME_RATE_CHANGE].p_time/(cpuf*1000.0)); printf("Rate change execution duration %5.2f \n", generic_time[TIME_RATE_CHANGE].p_time/(cpuf*1000.0));
#endif #endif
} }
...@@ -662,109 +609,79 @@ void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int **r ...@@ -662,109 +609,79 @@ void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int **r
* *
*********************************************************************/ *********************************************************************/
int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) {
{
NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms); NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms);
int synchro_position; int synchro_position;
int **rxdata = NULL; int **rxdata = NULL;
int fo_flag = PHY_vars_UE->UE_fo_compensation; // flag to enable freq offset estimation and compensation int fo_flag = PHY_vars_UE->UE_fo_compensation; // flag to enable freq offset estimation and compensation
#ifdef DBG_PSS_NR #ifdef DBG_PSS_NR
LOG_M("rxdata0_rand.m","rxd0_rand", &PHY_vars_UE->common_vars.rxdata[0][0], frame_parms->samples_per_frame, 1, 1); LOG_M("rxdata0_rand.m","rxd0_rand", &PHY_vars_UE->common_vars.rxdata[0][0], frame_parms->samples_per_frame, 1, 1);
#endif #endif
if (rate_change != 1) { if (rate_change != 1) {
rxdata = (int32_t **)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t *));
rxdata = (int32_t**)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t*));
for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++) { for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++) {
rxdata[aa] = (int32_t*) malloc16_clear( (frame_parms->samples_per_frame+8192)*sizeof(int32_t)); rxdata[aa] = (int32_t *) malloc16_clear( (frame_parms->samples_per_frame+8192)*sizeof(int32_t));
} }
#ifdef SYNCHRO_DECIMAT
#ifdef SYNCHRO_DECIMAT
decimation_synchro_nr(PHY_vars_UE, rate_change, rxdata); decimation_synchro_nr(PHY_vars_UE, rate_change, rxdata);
#endif #endif
} } else {
else {
rxdata = PHY_vars_UE->common_vars.rxdata; rxdata = PHY_vars_UE->common_vars.rxdata;
} }
#ifdef DBG_PSS_NR #ifdef DBG_PSS_NR
LOG_M("rxdata0_des.m","rxd0_des", &rxdata[0][0], frame_parms->samples_per_frame,1,1); LOG_M("rxdata0_des.m","rxd0_des", &rxdata[0][0], frame_parms->samples_per_frame,1,1);
#endif #endif
#if TEST_SYNCHRO_TIMING_PSS #if TEST_SYNCHRO_TIMING_PSS
opp_enabled = 1; opp_enabled = 1;
start_meas(&generic_time[TIME_PSS]); start_meas(&generic_time[TIME_PSS]);
#endif #endif
synchro_position = pss_search_time_nr(rxdata, synchro_position = pss_search_time_nr(rxdata,
frame_parms, frame_parms,
fo_flag, fo_flag,
is, is,
(int *)&PHY_vars_UE->common_vars.eNb_id, (int *)&PHY_vars_UE->common_vars.eNb_id,
(int *)&PHY_vars_UE->common_vars.freq_offset); (int *)&PHY_vars_UE->common_vars.freq_offset);
#if TEST_SYNCHRO_TIMING_PSS #if TEST_SYNCHRO_TIMING_PSS
stop_meas(&generic_time[TIME_PSS]); stop_meas(&generic_time[TIME_PSS]);
int duration_ms = generic_time[TIME_PSS].p_time/(cpuf*1000.0); int duration_ms = generic_time[TIME_PSS].p_time/(cpuf*1000.0);
#ifndef NR_UNIT_TEST
#ifndef NR_UNIT_TEST printf("PSS execution duration %4d microseconds \n", duration_ms);
#endif
printf("PSS execution duration %4d microseconds \n", duration_ms);
#endif
#endif #endif
#ifdef SYNCHRO_DECIMAT #ifdef SYNCHRO_DECIMAT
if (rate_change != 1) { if (rate_change != 1) {
if (rxdata[0] != NULL) { if (rxdata[0] != NULL) {
for (int aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++) {
free(rxdata[aa]); free(rxdata[aa]);
} }
free(rxdata); free(rxdata);
} }
restore_frame_context_pss_nr(frame_parms, rate_change); restore_frame_context_pss_nr(frame_parms, rate_change);
} }
#endif
#endif
return synchro_position; return synchro_position;
} }
static inline int abs32(int x) static inline int abs32(int x) {
{ return (((int)((short *)&x)[0])*((int)((short *)&x)[0]) + ((int)((short *)&x)[1])*((int)((short *)&x)[1]));
return (((int)((short*)&x)[0])*((int)((short*)&x)[0]) + ((int)((short*)&x)[1])*((int)((short*)&x)[1]));
} }
static inline int64_t abs64(int64_t x) static inline int64_t abs64(int64_t x) {
{ return (((int64_t)((int32_t *)&x)[0])*((int64_t)((int32_t *)&x)[0]) + ((int64_t)((int32_t *)&x)[1])*((int64_t)((int32_t *)&x)[1]));
return (((int64_t)((int32_t*)&x)[0])*((int64_t)((int32_t*)&x)[0]) + ((int64_t)((int32_t*)&x)[1])*((int64_t)((int32_t*)&x)[1]));
} }
static inline double angle64(int64_t x) static inline double angle64(int64_t x) {
{ double re=((int32_t *)&x)[0];
double im=((int32_t *)&x)[1];
double re=((int32_t*)&x)[0];
double im=((int32_t*)&x)[1];
return (atan2(im,re)); return (atan2(im,re));
} }
...@@ -823,34 +740,34 @@ static inline double angle64(int64_t x) ...@@ -823,34 +740,34 @@ static inline double angle64(int64_t x)
int pss_search_time_nr(int **rxdata, ///rx data in time domain int pss_search_time_nr(int **rxdata, ///rx data in time domain
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
int fo_flag, int fo_flag,
int is, int is,
int *eNB_id, int *eNB_id,
int *f_off) int *f_off) {
{
unsigned int n, ar, peak_position, pss_source; unsigned int n, ar, peak_position, pss_source;
int64_t peak_value; int64_t peak_value;
int64_t result; int64_t result;
int64_t avg[NUMBER_PSS_SEQUENCE]; int64_t avg[NUMBER_PSS_SEQUENCE];
double ffo_est=0; double ffo_est=0;
// performing the correlation on a frame length plus one symbol for the first of the two frame // performing the correlation on a frame length plus one symbol for the first of the two frame
// to take into account the possibility of PSS in between the two frames // to take into account the possibility of PSS in between the two frames
unsigned int length; unsigned int length;
if (is==0) if (is==0)
length = frame_parms->samples_per_frame + (2*frame_parms->ofdm_symbol_size); length = frame_parms->samples_per_frame + (2*frame_parms->ofdm_symbol_size);
else else
length = frame_parms->samples_per_frame; length = frame_parms->samples_per_frame;
AssertFatal(length>0,"illegal length %d\n",length); AssertFatal(length>0,"illegal length %d\n",length);
for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) AssertFatal(pss_corr_ue[i] != NULL,"pss_corr_ue[%d] not yet allocated! Exiting.\n", i); for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) AssertFatal(pss_corr_ue[i] != NULL,"pss_corr_ue[%d] not yet allocated! Exiting.\n", i);
peak_value = 0; peak_value = 0;
peak_position = 0; peak_position = 0;
pss_source = 0; pss_source = 0;
int maxval=0; int maxval=0;
for (int i=0;i<2*(frame_parms->ofdm_symbol_size);i++) {
for (int i=0; i<2*(frame_parms->ofdm_symbol_size); i++) {
maxval = max(maxval,primary_synchro_time_nr[0][i]); maxval = max(maxval,primary_synchro_time_nr[0][i]);
maxval = max(maxval,-primary_synchro_time_nr[0][i]); maxval = max(maxval,-primary_synchro_time_nr[0][i]);
maxval = max(maxval,primary_synchro_time_nr[1][i]); maxval = max(maxval,primary_synchro_time_nr[1][i]);
...@@ -858,6 +775,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain ...@@ -858,6 +775,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
maxval = max(maxval,primary_synchro_time_nr[2][i]); maxval = max(maxval,primary_synchro_time_nr[2][i]);
maxval = max(maxval,-primary_synchro_time_nr[2][i]); maxval = max(maxval,-primary_synchro_time_nr[2][i]);
} }
int shift = log2_approx(maxval);//*(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*2); int shift = log2_approx(maxval);//*(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*2);
/* Search pss in the received buffer each 4 samples which ensures a memory alignment on 128 bits (32 bits x 4 ) */ /* Search pss in the received buffer each 4 samples which ensures a memory alignment on 128 bits (32 bits x 4 ) */
...@@ -866,39 +784,34 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain ...@@ -866,39 +784,34 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) { for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) {
avg[pss_index]=0; avg[pss_index]=0;
memset(pss_corr_ue[pss_index],0,length*sizeof(int64_t)); memset(pss_corr_ue[pss_index],0,length*sizeof(int64_t));
} }
for (n=0; n < length; n+=4) { // for (n=0; n < length; n+=4) { //
for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) { for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) {
if ( n < (length - frame_parms->ofdm_symbol_size)) { if ( n < (length - frame_parms->ofdm_symbol_size)) {
/* calculate dot product of primary_synchro_time_nr and rxdata[ar][n] (ar=0..nb_ant_rx) and store the sum in temp[n]; */ /* calculate dot product of primary_synchro_time_nr and rxdata[ar][n] (ar=0..nb_ant_rx) and store the sum in temp[n]; */
for (ar=0; ar<frame_parms->nb_antennas_rx; ar++) { for (ar=0; ar<frame_parms->nb_antennas_rx; ar++) {
/* perform correlation of rx data and pss sequence ie it is a dot product */ /* perform correlation of rx data and pss sequence ie it is a dot product */
result = dot_product64((short*)primary_synchro_time_nr[pss_index], result = dot_product64((short *)primary_synchro_time_nr[pss_index],
(short*) &(rxdata[ar][n])+(is*frame_parms->samples_per_frame), (short *) &(rxdata[ar][n])+(is*frame_parms->samples_per_frame),
frame_parms->ofdm_symbol_size, frame_parms->ofdm_symbol_size,
shift); shift);
pss_corr_ue[pss_index][n] += abs64(result); pss_corr_ue[pss_index][n] += abs64(result);
//((short*)pss_corr_ue[pss_index])[2*n] += ((short*) &result)[0]; /* real part */ //((short*)pss_corr_ue[pss_index])[2*n] += ((short*) &result)[0]; /* real part */
//((short*)pss_corr_ue[pss_index])[2*n+1] += ((short*) &result)[1]; /* imaginary part */ //((short*)pss_corr_ue[pss_index])[2*n+1] += ((short*) &result)[1]; /* imaginary part */
//((short*)&synchro_out)[0] += ((int*) &result)[0]; /* real part */ //((short*)&synchro_out)[0] += ((int*) &result)[0]; /* real part */
//((short*)&synchro_out)[1] += ((int*) &result)[1]; /* imaginary part */ //((short*)&synchro_out)[1] += ((int*) &result)[1]; /* imaginary part */
} }
} }
/* calculate the absolute value of sync_corr[n] */ /* calculate the absolute value of sync_corr[n] */
avg[pss_index]+=pss_corr_ue[pss_index][n]; avg[pss_index]+=pss_corr_ue[pss_index][n];
if (pss_corr_ue[pss_index][n] > peak_value) { if (pss_corr_ue[pss_index][n] > peak_value) {
peak_value = pss_corr_ue[pss_index][n]; peak_value = pss_corr_ue[pss_index][n];
peak_position = n; peak_position = n;
pss_source = pss_index; pss_source = pss_index;
#ifdef DEBUG_PSS_NR #ifdef DEBUG_PSS_NR
printf("pss_index %d: n %6u peak_value %15llu\n", pss_index, n, (unsigned long long)pss_corr_ue[pss_index][n]); printf("pss_index %d: n %6u peak_value %15llu\n", pss_index, n, (unsigned long long)pss_corr_ue[pss_index][n]);
#endif #endif
...@@ -906,61 +819,55 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain ...@@ -906,61 +819,55 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
} }
} }
if (fo_flag){ if (fo_flag) {
// fractional frequency offset computation according to Cross-correlation Synchronization Algorithm Using PSS
// fractional frequency offset computation according to Cross-correlation Synchronization Algorithm Using PSS // Shoujun Huang, Yongtao Su, Ying He and Shan Tang, "Joint time and frequency offset estimation in LTE downlink," 7th International Conference on Communications and Networking in China, 2012.
// Shoujun Huang, Yongtao Su, Ying He and Shan Tang, "Joint time and frequency offset estimation in LTE downlink," 7th International Conference on Communications and Networking in China, 2012. int64_t result1,result2;
// Computing cross-correlation at peak on half the symbol size for first half of data
int64_t result1,result2; result1 = dot_product64((short *)primary_synchro_time_nr[pss_source],
// Computing cross-correlation at peak on half the symbol size for first half of data (short *) &(rxdata[0][peak_position])+(is*frame_parms->samples_per_frame),
result1 = dot_product64((short*)primary_synchro_time_nr[pss_source], frame_parms->ofdm_symbol_size>>1,
(short*) &(rxdata[0][peak_position])+(is*frame_parms->samples_per_frame), shift);
frame_parms->ofdm_symbol_size>>1, // Computing cross-correlation at peak on half the symbol size for data shifted by half symbol size
shift); // as it is real and complex it is necessary to shift by a value equal to symbol size to obtain such shift
// Computing cross-correlation at peak on half the symbol size for data shifted by half symbol size result2 = dot_product64((short *)primary_synchro_time_nr[pss_source]+(frame_parms->ofdm_symbol_size),
// as it is real and complex it is necessary to shift by a value equal to symbol size to obtain such shift (short *) &(rxdata[0][peak_position])+(frame_parms->ofdm_symbol_size+(is*frame_parms->samples_per_frame)),
result2 = dot_product64((short*)primary_synchro_time_nr[pss_source]+(frame_parms->ofdm_symbol_size), frame_parms->ofdm_symbol_size>>1,
(short*) &(rxdata[0][peak_position])+(frame_parms->ofdm_symbol_size+(is*frame_parms->samples_per_frame)), shift);
frame_parms->ofdm_symbol_size>>1, int64_t re1,re2,im1,im2;
shift); re1=((int *) &result1)[0];
re2=((int *) &result2)[0];
int64_t re1,re2,im1,im2; im1=((int *) &result1)[1];
re1=((int*) &result1)[0]; im2=((int *) &result2)[1];
re2=((int*) &result2)[0]; // estimation of fractional frequency offset: angle[(result1)'*(result2)]/pi
im1=((int*) &result1)[1]; ffo_est=atan2(re1*im2-re2*im1,re1*re2+im1*im2)/M_PI;
im2=((int*) &result2)[1];
// estimation of fractional frequency offset: angle[(result1)'*(result2)]/pi
ffo_est=atan2(re1*im2-re2*im1,re1*re2+im1*im2)/M_PI;
#ifdef DBG_PSS_NR #ifdef DBG_PSS_NR
printf("ffo %lf\n",ffo_est); printf("ffo %lf\n",ffo_est);
#endif #endif
} }
// computing absolute value of frequency offset // computing absolute value of frequency offset
*f_off = ffo_est*frame_parms->subcarrier_spacing; *f_off = ffo_est*frame_parms->subcarrier_spacing;
for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) avg[pss_index]/=(length/4); for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) avg[pss_index]/=(length/4);
*eNB_id = pss_source; *eNB_id = pss_source;
LOG_I(PHY,"[UE] nr_synchro_time: Sync source = %d, Peak found at pos %d, val = %llu (%d dB) avg %d dB, ffo %lf\n", pss_source, peak_position, (unsigned long long)peak_value, dB_fixed64(peak_value),
LOG_I(PHY,"[UE] nr_synchro_time: Sync source = %d, Peak found at pos %d, val = %llu (%d dB) avg %d dB, ffo %lf\n", pss_source, peak_position, (unsigned long long)peak_value, dB_fixed64(peak_value),dB_fixed64(avg[pss_source]),ffo_est); dB_fixed64(avg[pss_source]),ffo_est);
if (peak_value < 5*avg[pss_source]) if (peak_value < 5*avg[pss_source])
return(-1); return(-1);
#ifdef DBG_PSS_NR #ifdef DBG_PSS_NR
static int debug_cnt = 0; static int debug_cnt = 0;
if (debug_cnt == 0) { if (debug_cnt == 0) {
LOG_M("pss_corr_ue0.m","pss_corr_ue0",pss_corr_ue[0],length,1,6); LOG_M("pss_corr_ue0.m","pss_corr_ue0",pss_corr_ue[0],length,1,6);
LOG_M("pss_corr_ue1.m","pss_corr_ue1",pss_corr_ue[1],length,1,6); LOG_M("pss_corr_ue1.m","pss_corr_ue1",pss_corr_ue[1],length,1,6);
LOG_M("pss_corr_ue2.m","pss_corr_ue2",pss_corr_ue[2],length,1,6); LOG_M("pss_corr_ue2.m","pss_corr_ue2",pss_corr_ue[2],length,1,6);
if (is) if (is)
LOG_M("rxdata1.m","rxd0",rxdata[frame_parms->samples_per_frame],length,1,1); LOG_M("rxdata1.m","rxd0",rxdata[frame_parms->samples_per_frame],length,1,1);
else else
LOG_M("rxdata0.m","rxd0",rxdata[0],length,1,1); LOG_M("rxdata0.m","rxd0",rxdata[0],length,1,1);
} else { } else {
...@@ -968,7 +875,6 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain ...@@ -968,7 +875,6 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
} }
#endif #endif
return(peak_position); return(peak_position);
} }
...@@ -64,591 +64,591 @@ PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } }; ...@@ -64,591 +64,591 @@ PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } };
uint16_t n_rnti = 0x1234; uint16_t n_rnti = 0x1234;
openair0_config_t openair0_cfg[MAX_CARDS]; openair0_config_t openair0_cfg[MAX_CARDS];
int main(int argc, char **argv) int main(int argc, char **argv) {
{ char c;
char c; int i; //,j,l,aa;
int i; //,j,l,aa; double SNR, SNR_lin, snr0 = -2.0, snr1 = 2.0;
double SNR, SNR_lin, snr0 = -2.0, snr1 = 2.0; double snr_step = 0.1;
double snr_step = 0.1; uint8_t snr1set = 0;
uint8_t snr1set = 0; int **txdata;
int **txdata; double **s_re, **s_im, **r_re, **r_im;
double **s_re, **s_im, **r_re, **r_im; // int sync_pos, sync_pos_slot;
// int sync_pos, sync_pos_slot; // FILE *rx_frame_file;
// FILE *rx_frame_file; FILE *output_fd = NULL;
FILE *output_fd = NULL; //uint8_t write_output_file = 0;
//uint8_t write_output_file = 0; // int subframe_offset;
// int subframe_offset; // char fname[40], vname[40];
// char fname[40], vname[40]; int trial, n_trials = 1, n_errors = 0, n_false_positive = 0;
int trial, n_trials = 1, n_errors = 0, n_false_positive = 0; uint8_t n_tx = 1, n_rx = 1;
uint8_t n_tx = 1, n_rx = 1; //uint8_t transmission_mode = 1;
//uint8_t transmission_mode = 1; uint16_t Nid_cell = 0;
uint16_t Nid_cell = 0; channel_desc_t *gNB2UE;
channel_desc_t *gNB2UE; uint8_t extended_prefix_flag = 0;
uint8_t extended_prefix_flag = 0; //int8_t interf1 = -21, interf2 = -21;
//int8_t interf1 = -21, interf2 = -21; FILE *input_fd = NULL, *pbch_file_fd = NULL;
FILE *input_fd = NULL, *pbch_file_fd = NULL; //char input_val_str[50],input_val_str2[50];
//char input_val_str[50],input_val_str2[50]; //uint16_t NB_RB=25;
//uint16_t NB_RB=25; SCM_t channel_model = AWGN; //Rayleigh1_anticorr;
SCM_t channel_model = AWGN; //Rayleigh1_anticorr; uint16_t N_RB_DL = 106, mu = 1;
uint16_t N_RB_DL = 106, mu = 1; //unsigned char frame_type = 0;
//unsigned char frame_type = 0; unsigned char pbch_phase = 0;
unsigned char pbch_phase = 0; int frame = 0, slot = 0;
int frame = 0, slot = 0; int frame_length_complex_samples;
int frame_length_complex_samples; //int frame_length_complex_samples_no_prefix;
//int frame_length_complex_samples_no_prefix; NR_DL_FRAME_PARMS *frame_parms;
NR_DL_FRAME_PARMS *frame_parms; //nfapi_nr_config_request_t *gNB_config;
//nfapi_nr_config_request_t *gNB_config; uint8_t Kmimo = 0;
uint8_t Kmimo = 0; uint32_t Nsoft = 0;
uint32_t Nsoft = 0; double sigma;
double sigma; unsigned char qbits = 8;
unsigned char qbits = 8; int ret;
int ret; //int run_initial_sync=0;
//int run_initial_sync=0; int loglvl = OAILOG_WARNING;
int loglvl = OAILOG_WARNING; float target_error_rate = 0.01;
float target_error_rate = 0.01; uint64_t SSB_positions=0x01;
uint64_t SSB_positions=0x01; uint16_t nb_symb_sch = 12;
uint16_t nb_symb_sch = 12; uint16_t nb_rb = 50;
uint16_t nb_rb = 50; uint8_t Imcs = 9;
uint8_t Imcs = 9; uint8_t mcs_table = 0;
uint8_t mcs_table = 0; cpuf = get_cpu_freq_GHz();
cpuf = get_cpu_freq_GHz(); if (load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY) == 0) {
exit_fun("[NR_DLSCHSIM] Error, configuration module init failed\n");
if (load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY) == 0) { }
exit_fun("[NR_DLSCHSIM] Error, configuration module init failed\n");
} //logInit();
randominit(0);
//logInit();
randominit(0); while ((c = getopt(argc, argv, "df:hpVg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:L:")) != -1) {
switch (c) {
while ((c = getopt(argc, argv, "df:hpVg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:L:")) != -1) { /*case 'f':
switch (c) { write_output_file = 1;
/*case 'f': output_fd = fopen(optarg, "w");
write_output_file = 1;
output_fd = fopen(optarg, "w"); if (output_fd == NULL) {
printf("Error opening %s\n", optarg);
if (output_fd == NULL) { exit(-1);
printf("Error opening %s\n", optarg); }
exit(-1);
} break;*/
break;*/ /*case 'd':
frame_type = 1;
/*case 'd': break;*/
frame_type = 1; case 'g':
break;*/ switch ((char) *optarg) {
case 'A':
case 'g': channel_model = SCM_A;
switch ((char) *optarg) { break;
case 'A':
channel_model = SCM_A; case 'B':
break; channel_model = SCM_B;
break;
case 'B':
channel_model = SCM_B; case 'C':
break; channel_model = SCM_C;
break;
case 'C':
channel_model = SCM_C; case 'D':
break; channel_model = SCM_D;
break;
case 'D':
channel_model = SCM_D; case 'E':
break; channel_model = EPA;
break;
case 'E':
channel_model = EPA; case 'F':
break; channel_model = EVA;
break;
case 'F':
channel_model = EVA; case 'G':
break; channel_model = ETU;
break;
case 'G':
channel_model = ETU; default:
break; printf("Unsupported channel model! Exiting.\n");
exit(-1);
default: }
printf("Unsupported channel model! Exiting.\n");
exit(-1); break;
}
/*case 'i':
break; interf1 = atoi(optarg);
break;
/*case 'i':
interf1 = atoi(optarg); case 'j':
break; interf2 = atoi(optarg);
break;*/
case 'j':
interf2 = atoi(optarg); case 'n':
break;*/ n_trials = atoi(optarg);
break;
case 'n':
n_trials = atoi(optarg); case 's':
break; snr0 = atof(optarg);
case 's':
snr0 = atof(optarg);
#ifdef DEBUG_NR_DLSCHSIM #ifdef DEBUG_NR_DLSCHSIM
printf("Setting SNR0 to %f\n", snr0); printf("Setting SNR0 to %f\n", snr0);
#endif #endif
break; break;
case 'V': case 'V':
ouput_vcd = 1; ouput_vcd = 1;
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);
#ifdef DEBUG_NR_DLSCHSIM #ifdef DEBUG_NR_DLSCHSIM
printf("Setting SNR1 to %f\n", snr1); printf("Setting SNR1 to %f\n", snr1);
#endif #endif
break; break;
case 'p': case 'p':
extended_prefix_flag = 1; extended_prefix_flag = 1;
break; 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 '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. Exiting.\n", n_tx); printf("Unsupported number of TX antennas %d. Exiting.\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. Exiting.\n", n_rx); printf("Unsupported number of RX antennas %d. Exiting.\n", n_rx);
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);
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. Exiting.\n", optarg); printf("Problem with filename %s. Exiting.\n", optarg);
exit(-1); exit(-1);
} }
break; break;
case 'P': case 'P':
pbch_phase = atoi(optarg); pbch_phase = atoi(optarg);
if (pbch_phase > 3) if (pbch_phase > 3)
printf("Illegal PBCH phase (0-3) got %d\n", pbch_phase); printf("Illegal PBCH phase (0-3) got %d\n", pbch_phase);
break; break;
case 'L': case 'L':
loglvl = atoi(optarg); loglvl = atoi(optarg);
break; break;
case 'm': case 'm':
Imcs = atoi(optarg); Imcs = atoi(optarg);
break; break;
case 'l': case 'l':
nb_symb_sch = atoi(optarg); nb_symb_sch = atoi(optarg);
break; break;
case 'r': case 'r':
nb_rb = atoi(optarg); nb_rb = atoi(optarg);
break; break;
/*case 'x': /*case 'x':
transmission_mode = atoi(optarg); transmission_mode = 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",
printf("-h This message\n"); argv[0]);
printf("-p Use extended prefix mode\n"); printf("-h This message\n");
printf("-V Enable VCD dumb functions\n"); printf("-p Use extended prefix mode\n");
//printf("-d Use TDD\n"); printf("-V Enable VCD dumb functions\n");
printf("-n Number of frames to simulate\n"); //printf("-d Use TDD\n");
printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); printf("-n Number of frames to simulate\n");
printf("-S Ending SNR, runs from SNR0 to SNR1\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n");
printf("-t Delay spread for multipath channel\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\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("-t Delay spread for multipath channel\n");
//printf("-x Transmission mode (1,2,6 for the moment)\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("-y Number of TX antennas used in eNB\n"); //printf("-x Transmission mode (1,2,6 for the moment)\n");
printf("-z Number of RX antennas used in UE\n"); printf("-y Number of TX antennas used in eNB\n");
//printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); printf("-z Number of RX antennas used in UE\n");
//printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n");
printf("-M Multiple SSB positions in burst\n"); //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n");
printf("-N Nid_cell\n"); printf("-M Multiple SSB positions in burst\n");
printf("-R N_RB_DL\n"); printf("-N Nid_cell\n");
printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-R N_RB_DL\n");
printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); printf("-O oversampling factor (1,2,4,8,16)\n");
//printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n");
//printf("-f Output filename (.txt format) for Pe/SNR results\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 Output filename (.txt format) for Pe/SNR results\n");
exit(-1); printf("-F Input filename (.txt format) for RX conformance testing\n");
break; exit(-1);
} break;
} }
}
logInit();
set_glog(loglvl); logInit();
T_stdout = 1; set_glog(loglvl);
T_stdout = 1;
if (snr1set == 0)
snr1 = snr0 + 10; if (snr1set == 0)
snr1 = snr0 + 10;
if (ouput_vcd)
vcd_signal_dumper_init("/tmp/openair_dump_nr_dlschsim.vcd"); if (ouput_vcd)
vcd_signal_dumper_init("/tmp/openair_dump_nr_dlschsim.vcd");
gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model,
61.44e6, //N_RB2sampling_rate(N_RB_DL), gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model,
40e6, //N_RB2channel_bandwidth(N_RB_DL), 61.44e6, //N_RB2sampling_rate(N_RB_DL),
0, 0, 0); 40e6, //N_RB2channel_bandwidth(N_RB_DL),
0, 0, 0);
if (gNB2UE == NULL) {
printf("Problem generating channel model. Exiting.\n"); if (gNB2UE == NULL) {
exit(-1); printf("Problem generating channel model. Exiting.\n");
} exit(-1);
}
RC.gNB = (PHY_VARS_gNB ** *) malloc(sizeof(PHY_VARS_gNB **));
RC.gNB[0] = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *)); RC.gNB = (PHY_VARS_gNB ** *) malloc(sizeof(PHY_VARS_gNB **));
RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB)); RC.gNB[0] = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *));
gNB = RC.gNB[0][0]; RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB));
//gNB_config = &gNB->gNB_config; gNB = RC.gNB[0][0];
frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) //gNB_config = &gNB->gNB_config;
frame_parms->nb_antennas_tx = n_tx; frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
frame_parms->nb_antennas_rx = n_rx; frame_parms->nb_antennas_tx = n_tx;
frame_parms->N_RB_DL = N_RB_DL; frame_parms->nb_antennas_rx = n_rx;
frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL; frame_parms->N_RB_DL = N_RB_DL;
crcTableInit(); frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL;
nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell,SSB_positions); crcTableInit();
phy_init_nr_gNB(gNB, 0, 0); nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell,SSB_positions);
//init_eNB_afterRU(); phy_init_nr_gNB(gNB, 0, 0);
frame_length_complex_samples = frame_parms->samples_per_subframe; //init_eNB_afterRU();
//frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP; frame_length_complex_samples = frame_parms->samples_per_subframe;
s_re = malloc(2 * sizeof(double *)); //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP;
s_im = malloc(2 * sizeof(double *)); s_re = malloc(2 * sizeof(double *));
r_re = malloc(2 * sizeof(double *)); s_im = malloc(2 * sizeof(double *));
r_im = malloc(2 * sizeof(double *)); r_re = malloc(2 * sizeof(double *));
txdata = malloc(2 * sizeof(int *)); r_im = malloc(2 * sizeof(double *));
txdata = malloc(2 * sizeof(int *));
for (i = 0; i < 2; i++) {
s_re[i] = malloc(frame_length_complex_samples * sizeof(double)); for (i = 0; i < 2; i++) {
bzero(s_re[i], frame_length_complex_samples * sizeof(double)); s_re[i] = malloc(frame_length_complex_samples * sizeof(double));
s_im[i] = malloc(frame_length_complex_samples * sizeof(double)); bzero(s_re[i], frame_length_complex_samples * sizeof(double));
bzero(s_im[i], frame_length_complex_samples * sizeof(double)); s_im[i] = malloc(frame_length_complex_samples * sizeof(double));
r_re[i] = malloc(frame_length_complex_samples * sizeof(double)); bzero(s_im[i], frame_length_complex_samples * sizeof(double));
bzero(r_re[i], frame_length_complex_samples * sizeof(double)); r_re[i] = malloc(frame_length_complex_samples * sizeof(double));
r_im[i] = malloc(frame_length_complex_samples * sizeof(double)); bzero(r_re[i], frame_length_complex_samples * sizeof(double));
bzero(r_im[i], frame_length_complex_samples * sizeof(double)); r_im[i] = malloc(frame_length_complex_samples * sizeof(double));
txdata[i] = malloc(frame_length_complex_samples * sizeof(int)); bzero(r_im[i], frame_length_complex_samples * sizeof(double));
bzero(r_re[i], frame_length_complex_samples * sizeof(int)); // [hna] r_re should be txdata txdata[i] = malloc(frame_length_complex_samples * sizeof(int));
} bzero(r_re[i], frame_length_complex_samples * sizeof(int)); // [hna] r_re should be txdata
}
if (pbch_file_fd != NULL) {
load_pbch_desc(pbch_file_fd); if (pbch_file_fd != NULL) {
} load_pbch_desc(pbch_file_fd);
}
/* for (int k=0; k<2; k++) {
// Create transport channel structures for 2 transport blocks (MIMO) /* for (int k=0; k<2; k++) {
for (i=0; i<2; i++) { // Create transport channel structures for 2 transport blocks (MIMO)
gNB->dlsch[k][i] = new_gNB_dlsch(Kmimo,8,Nsoft,0,frame_parms,gNB_config); for (i=0; i<2; i++) {
gNB->dlsch[k][i] = new_gNB_dlsch(Kmimo,8,Nsoft,0,frame_parms,gNB_config);
if (!gNB->dlsch[k][i]) {
printf("Can't get eNB dlsch structures\n"); if (!gNB->dlsch[k][i]) {
exit(-1); printf("Can't get eNB dlsch structures\n");
} exit(-1);
gNB->dlsch[k][i]->Nsoft = 10; }
gNB->dlsch[k][i]->rnti = n_rnti+k; gNB->dlsch[k][i]->Nsoft = 10;
} gNB->dlsch[k][i]->rnti = n_rnti+k;
}*/ }
//configure UE }*/
UE = malloc(sizeof(PHY_VARS_NR_UE)); //configure UE
memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS)); UE = malloc(sizeof(PHY_VARS_NR_UE));
memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS));
//phy_init_nr_top(frame_parms);
if (init_nr_ue_signal(UE, 1, 0) != 0) { //phy_init_nr_top(frame_parms);
printf("Error at UE NR initialisation\n"); if (init_nr_ue_signal(UE, 1, 0) != 0) {
exit(-1); printf("Error at UE NR initialisation\n");
} exit(-1);
}
//nr_init_frame_parms_ue(&UE->frame_parms);
//init_nr_ue_transport(UE, 0); //nr_init_frame_parms_ue(&UE->frame_parms);
for (int sf = 0; sf < 2; sf++) { //init_nr_ue_transport(UE, 0);
for (i = 0; i < 2; i++) { for (int sf = 0; sf < 2; sf++) {
UE->dlsch[sf][0][i] = new_nr_ue_dlsch(Kmimo, 8, Nsoft, 5, N_RB_DL, for (i = 0; i < 2; i++) {
0); UE->dlsch[sf][0][i] = new_nr_ue_dlsch(Kmimo, 8, Nsoft, 5, N_RB_DL,
0);
if (!UE->dlsch[sf][0][i]) {
printf("Can't get ue dlsch structures\n"); if (!UE->dlsch[sf][0][i]) {
exit(-1); printf("Can't get ue dlsch structures\n");
} exit(-1);
}
UE->dlsch[sf][0][i]->rnti = n_rnti;
} UE->dlsch[sf][0][i]->rnti = n_rnti;
} }
}
UE->dlsch_SI[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0);
UE->dlsch_ra[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0); UE->dlsch_SI[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0);
unsigned char harq_pid = 0; //dlsch->harq_ids[subframe]; UE->dlsch_ra[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0);
NR_gNB_DLSCH_t *dlsch = gNB->dlsch[0][0]; unsigned char harq_pid = 0; //dlsch->harq_ids[subframe];
nfapi_nr_dl_config_dlsch_pdu_rel15_t *rel15 = &dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15; NR_gNB_DLSCH_t *dlsch = gNB->dlsch[0][0];
//time_stats_t *rm_stats, *te_stats, *i_stats; nfapi_nr_dl_config_dlsch_pdu_rel15_t *rel15 = &dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15;
uint8_t is_crnti = 0, llr8_flag = 0; //time_stats_t *rm_stats, *te_stats, *i_stats;
unsigned int TBS = 8424; uint8_t is_crnti = 0, llr8_flag = 0;
unsigned int available_bits; unsigned int TBS = 8424;
uint8_t nb_re_dmrs = 6; unsigned int available_bits;
uint16_t length_dmrs = 1; uint8_t nb_re_dmrs = 6;
unsigned char mod_order; uint16_t length_dmrs = 1;
uint16_t rate; unsigned char mod_order;
uint8_t Nl = 1; uint16_t rate;
uint8_t rvidx = 0; uint8_t Nl = 1;
dlsch->rnti = 1; uint8_t rvidx = 0;
/*dlsch->harq_processes[0]->mcs = Imcs; dlsch->rnti = 1;
dlsch->harq_processes[0]->rvidx = rvidx;*/ /*dlsch->harq_processes[0]->mcs = Imcs;
//printf("dlschsim harqid %d nb_rb %d, mscs %d\n",dlsch->harq_ids[subframe], dlsch->harq_processes[0]->rvidx = rvidx;*/
// dlsch->harq_processes[0]->nb_rb,dlsch->harq_processes[0]->mcs,dlsch->harq_processes[0]->Nl); //printf("dlschsim harqid %d nb_rb %d, mscs %d\n",dlsch->harq_ids[subframe],
mod_order = nr_get_Qm_dl(Imcs, mcs_table); // dlsch->harq_processes[0]->nb_rb,dlsch->harq_processes[0]->mcs,dlsch->harq_processes[0]->Nl);
rate = nr_get_code_rate_dl(Imcs, mcs_table); mod_order = nr_get_Qm_dl(Imcs, mcs_table);
available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); rate = nr_get_code_rate_dl(Imcs, mcs_table);
TBS = nr_compute_tbs(mod_order,rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, Nl); available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1);
printf("available bits %u TBS %u mod_order %d\n", available_bits, TBS, mod_order); TBS = nr_compute_tbs(mod_order,rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, Nl);
//dlsch->harq_ids[subframe]= 0; printf("available bits %u TBS %u mod_order %d\n", available_bits, TBS, mod_order);
rel15->n_prb = nb_rb; //dlsch->harq_ids[subframe]= 0;
rel15->nb_symbols = nb_symb_sch; rel15->n_prb = nb_rb;
rel15->modulation_order = mod_order; rel15->nb_symbols = nb_symb_sch;
rel15->nb_layers = Nl; rel15->modulation_order = mod_order;
rel15->nb_re_dmrs = nb_re_dmrs; rel15->nb_layers = Nl;
rel15->transport_block_size = TBS; rel15->nb_re_dmrs = nb_re_dmrs;
rel15->transport_block_size = TBS;
rel15->coding_rate = rate; rel15->coding_rate = rate;
double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc
short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384);
short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384);
double errors_bit_uncoded = 0; double errors_bit_uncoded = 0;
//unsigned char *estimated_output; //unsigned char *estimated_output;
unsigned char *estimated_output_bit; unsigned char *estimated_output_bit;
unsigned char *test_input_bit; unsigned char *test_input_bit;
unsigned int errors_bit = 0; unsigned int errors_bit = 0;
test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
//estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); //estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[0][0][0]; NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[0][0][0];
NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid]; NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid];
harq_process->mcs = Imcs; harq_process->mcs = Imcs;
harq_process->mcs_table = mcs_table; harq_process->mcs_table = mcs_table;
harq_process->Nl = Nl; harq_process->Nl = Nl;
harq_process->nb_rb = nb_rb; harq_process->nb_rb = nb_rb;
harq_process->Qm = mod_order; harq_process->Qm = mod_order;
harq_process->rvidx = rvidx; harq_process->rvidx = rvidx;
harq_process->R = rate; harq_process->R = rate;
printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch); printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch);
unsigned char *test_input; unsigned char *test_input;
test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8); test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8);
for (i = 0; i < TBS / 8; i++) for (i = 0; i < TBS / 8; i++)
test_input[i] = (unsigned char) rand(); test_input[i] = (unsigned char) rand();
//estimated_output = harq_process->b; //estimated_output = harq_process->b;
#ifdef DEBUG_NR_DLSCHSIM #ifdef DEBUG_NR_DLSCHSIM
for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%hhu \n",test_input[i]);
for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%hhu \n",test_input[i]);
#endif #endif
/*for (int i=0; i<TBS/8; i++) /*for (int i=0; i<TBS/8; i++)
printf("test input[%d]=%d \n",i,test_input[i]);*/ printf("test input[%d]=%d \n",i,test_input[i]);*/
//printf("crc32: [0]->0x%08x\n",crc24c(test_input, 32));
// generate signal
if (input_fd == NULL) {
nr_dlsch_encoding(test_input, frame, slot, dlsch, frame_parms);
}
//printf("crc32: [0]->0x%08x\n",crc24c(test_input, 32)); for (SNR = snr0; SNR < snr1; SNR += snr_step) {
// generate signal n_errors = 0;
if (input_fd == NULL) { n_false_positive = 0;
nr_dlsch_encoding(test_input, frame, slot, dlsch, frame_parms);
}
for (SNR = snr0; SNR < snr1; SNR += snr_step) { for (trial = 0; trial < n_trials; trial++) {
n_errors = 0; errors_bit_uncoded = 0;
n_false_positive = 0;
for (trial = 0; trial < n_trials; trial++) { for (i = 0; i < available_bits; i++) {
errors_bit_uncoded = 0;
for (i = 0; i < available_bits; i++) {
#ifdef DEBUG_CODER #ifdef DEBUG_CODER
if ((i&0xf)==0)
printf("\ne %d..%d: ",i,i+15); if ((i&0xf)==0)
printf("\ne %d..%d: ",i,i+15);
#endif #endif
//if (i<16) //if (i<16)
// printf("encoder output f[%d] = %d\n",i,dlsch->harq_processes[0]->f[i]); // printf("encoder output f[%d] = %d\n",i,dlsch->harq_processes[0]->f[i]);
if (dlsch->harq_processes[0]->f[i] == 0) if (dlsch->harq_processes[0]->f[i] == 0)
modulated_input[i] = 1.0; ///sqrt(2); //QPSK modulated_input[i] = 1.0; ///sqrt(2); //QPSK
else else
modulated_input[i] = -1.0; ///sqrt(2); modulated_input[i] = -1.0; ///sqrt(2);
//if (i<16) printf("modulated_input[%d] = %d\n",i,modulated_input[i]); //if (i<16) printf("modulated_input[%d] = %d\n",i,modulated_input[i]);
//SNR =10; //SNR =10;
SNR_lin = pow(10, SNR / 10.0); SNR_lin = pow(10, SNR / 10.0);
sigma = 1.0 / sqrt(2 * SNR_lin); sigma = 1.0 / sqrt(2 * SNR_lin);
channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0, channel_output_fixed[i] = (short) quantize(sigma / 4.0 / 4.0,
modulated_input[i] + sigma * gaussdouble(0.0, 1.0), modulated_input[i] + sigma * gaussdouble(0.0, 1.0),
qbits); qbits);
//channel_output_fixed[i] = (char)quantize8bit(sigma/4.0,(2.0*modulated_input[i]) - 1.0 + sigma*gaussdouble(0.0,1.0)); //channel_output_fixed[i] = (char)quantize8bit(sigma/4.0,(2.0*modulated_input[i]) - 1.0 + sigma*gaussdouble(0.0,1.0));
//printf("llr[%d]=%d\n",i,channel_output_fixed[i]); //printf("llr[%d]=%d\n",i,channel_output_fixed[i]);
//printf("channel_output_fixed[%d]: %d\n",i,channel_output_fixed[i]); //printf("channel_output_fixed[%d]: %d\n",i,channel_output_fixed[i]);
//channel_output_fixed[i] = (char)quantize(1,channel_output_fixed[i],qbits); //channel_output_fixed[i] = (char)quantize(1,channel_output_fixed[i],qbits);
//if (i<16) printf("channel_output_fixed[%d] = %d\n",i,channel_output_fixed[i]); //if (i<16) printf("channel_output_fixed[%d] = %d\n",i,channel_output_fixed[i]);
//Uncoded BER //Uncoded BER
if (channel_output_fixed[i] < 0) if (channel_output_fixed[i] < 0)
channel_output_uncoded[i] = 1; //QPSK demod channel_output_uncoded[i] = 1; //QPSK demod
else else
channel_output_uncoded[i] = 0; channel_output_uncoded[i] = 0;
if (channel_output_uncoded[i] != dlsch->harq_processes[harq_pid]->f[i]) if (channel_output_uncoded[i] != dlsch->harq_processes[harq_pid]->f[i])
errors_bit_uncoded = errors_bit_uncoded + 1; errors_bit_uncoded = errors_bit_uncoded + 1;
} }
//if (errors_bit_uncoded>10) //if (errors_bit_uncoded>10)
//printf("errors bits uncoded %f\n", errors_bit_uncoded); //printf("errors bits uncoded %f\n", errors_bit_uncoded);
#ifdef DEBUG_CODER #ifdef DEBUG_CODER
printf("\n"); printf("\n");
exit(-1); exit(-1);
#endif #endif
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DECODING0, VCD_FUNCTION_IN);
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DECODING0, VCD_FUNCTION_IN); ret = nr_dlsch_decoding(UE, channel_output_fixed, &UE->frame_parms,
dlsch0_ue, dlsch0_ue->harq_processes[0], frame, nb_symb_sch,
ret = nr_dlsch_decoding(UE, channel_output_fixed, &UE->frame_parms, slot,harq_pid, is_crnti, llr8_flag);
dlsch0_ue, dlsch0_ue->harq_processes[0], frame, nb_symb_sch, vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DECODING0, VCD_FUNCTION_OUT);
slot,harq_pid, is_crnti, llr8_flag);
if (ret > dlsch0_ue->max_ldpc_iterations)
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DECODING0, VCD_FUNCTION_OUT); n_errors++;
if (ret > dlsch0_ue->max_ldpc_iterations) //count errors
n_errors++; errors_bit = 0;
//count errors for (i = 0; i < TBS; i++) {
errors_bit = 0; estimated_output_bit[i] = (dlsch0_ue->harq_processes[0]->b[i / 8] & (1 << (i & 7))) >> (i & 7);
test_input_bit[i] = (test_input[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments
for (i = 0; i < TBS; i++) {
estimated_output_bit[i] = (dlsch0_ue->harq_processes[0]->b[i / 8] & (1 << (i & 7))) >> (i & 7); if (estimated_output_bit[i] != test_input_bit[i]) {
test_input_bit[i] = (test_input[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments errors_bit++;
//printf("estimated bits error occurs @%d ",i);
if (estimated_output_bit[i] != test_input_bit[i]) { }
errors_bit++; }
//printf("estimated bits error occurs @%d ",i);
} if (errors_bit > 0) {
} n_false_positive++;
if (errors_bit > 0) { if (n_trials == 1)
n_false_positive++; printf("errors_bit %u (trial %d)\n", errors_bit, trial);
if (n_trials == 1) }
printf("errors_bit %u (trial %d)\n", errors_bit, trial); }
}
} printf("SNR %f, BLER %f (false positive %f)\n", SNR,
(float) n_errors / (float) n_trials,
printf("SNR %f, BLER %f (false positive %f)\n", SNR, (float) n_false_positive / (float) n_trials);
(float) n_errors / (float) n_trials,
(float) n_false_positive / (float) n_trials); if ((float) n_errors / (float) n_trials < target_error_rate) {
printf("PDSCH test OK\n");
if ((float) n_errors / (float) n_trials < target_error_rate) { break;
printf("PDSCH test OK\n"); }
break; }
}
} /*LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1);
if (gNB->frame_parms.nb_antennas_tx>1)
/*LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1); LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);*/
if (gNB->frame_parms.nb_antennas_tx>1)
LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);*/ //TODO: loop over slots
/*for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) {
//TODO: loop over slots if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) {
/*for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) { PHY_ofdm_mod(gNB->common_vars.txdataF[aa],
if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) { txdata[aa],
PHY_ofdm_mod(gNB->common_vars.txdataF[aa], frame_parms->ofdm_symbol_size,
txdata[aa], 12,
frame_parms->ofdm_symbol_size, frame_parms->nb_prefix_samples,
12, CYCLIC_PREFIX);
frame_parms->nb_prefix_samples, } else {
CYCLIC_PREFIX); nr_normal_prefix_mod(gNB->common_vars.txdataF[aa],
} else { txdata[aa],
nr_normal_prefix_mod(gNB->common_vars.txdataF[aa], 14,
txdata[aa], frame_parms);
14, }
frame_parms); }
}
} LOG_M("txsig0.m","txs0", txdata[0],frame_length_complex_samples,1,1);
if (gNB->frame_parms.nb_antennas_tx>1)
LOG_M("txsig0.m","txs0", txdata[0],frame_length_complex_samples,1,1); LOG_M("txsig1.m","txs1", txdata[1],frame_length_complex_samples,1,1);
if (gNB->frame_parms.nb_antennas_tx>1)
LOG_M("txsig1.m","txs1", txdata[1],frame_length_complex_samples,1,1);
for (i=0; i<frame_length_complex_samples; i++) {
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
for (i=0; i<frame_length_complex_samples; i++) { r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]);
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) { r_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]);
r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]); }
r_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]); }*/
}
}*/ for (i = 0; i < 2; i++) {
printf("gNB %d\n", i);
for (i = 0; i < 2; i++) { free_gNB_dlsch(&(gNB->dlsch[0][i]));
printf("gNB %d\n", i); printf("UE %d\n", i);
free_gNB_dlsch(gNB->dlsch[0][i]); free_nr_ue_dlsch(UE->dlsch[0][0][i]);
printf("UE %d\n", i); }
free_nr_ue_dlsch(UE->dlsch[0][0][i]);
} for (i = 0; i < 2; i++) {
free(s_re[i]);
for (i = 0; i < 2; i++) { free(s_im[i]);
free(s_re[i]); free(r_re[i]);
free(s_im[i]); free(r_im[i]);
free(r_re[i]); free(txdata[i]);
free(r_im[i]); }
free(txdata[i]);
} free(s_re);
free(s_im);
free(s_re); free(r_re);
free(s_im); free(r_im);
free(r_re); free(txdata);
free(r_im);
free(txdata); if (output_fd)
fclose(output_fd);
if (output_fd)
fclose(output_fd); if (input_fd)
fclose(input_fd);
if (input_fd)
fclose(input_fd); if (ouput_vcd)
vcd_signal_dumper_close();
if (ouput_vcd)
vcd_signal_dumper_close(); return (n_errors);
return (n_errors);
} }
...@@ -737,7 +737,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { ...@@ -737,7 +737,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
NRRRC_CONFIGURATION_REQ (msg_p).N_RB_DL[j]= N_RB_DL; NRRRC_CONFIGURATION_REQ (msg_p).N_RB_DL[j]= N_RB_DL;
if ((N_RB_DL != 273) && (N_RB_DL != 217) && (N_RB_DL != 106)) if ((N_RB_DL != 273) && (N_RB_DL != 217) && (N_RB_DL != 106))
AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for N_RB_DL choice: 106, 217 !\n", RC.config_file_name, i, N_RB_DL); AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for N_RB_DL choice: 106, 217 !\n", RC.config_file_name, i, N_RB_DL);
/* /*
if ((N_RB_DL!=6) && (N_RB_DL!=15) && (N_RB_DL!=25) && (N_RB_DL!=50) && (N_RB_DL!=75) && (N_RB_DL!=100)) { if ((N_RB_DL!=6) && (N_RB_DL!=15) && (N_RB_DL!=25) && (N_RB_DL!=50) && (N_RB_DL!=75) && (N_RB_DL!=100)) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -540,9 +540,6 @@ rrc_pdcp_config_security( ...@@ -540,9 +540,6 @@ rrc_pdcp_config_security(
derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm, derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm,
ue_context_pP->ue_context.kenb, ue_context_pP->ue_context.kenb,
&kRRCint); &kRRCint);
#if !defined(USRP_REC_PLAY)
SET_LOG_DUMP(DEBUG_SECURITY) ;
#endif
if ( LOG_DUMPFLAG( DEBUG_SECURITY ) ) { if ( LOG_DUMPFLAG( DEBUG_SECURITY ) ) {
if (print_keys ==1 ) { if (print_keys ==1 ) {
......
...@@ -377,7 +377,22 @@ static void trx_usrp_end(openair0_device *device) { ...@@ -377,7 +377,22 @@ static void trx_usrp_end(openair0_device *device) {
} }
} }
} }
/*! \brief Write iqs function when in replay mode, just introduce a delay, as configured at init time,
@param device pointer to the device structure specific to the RF hardware target
@param timestamp The timestamp at which the first sample MUST be sent
@param buff Buffer which holds the samples
@param nsamps number of samples to be sent
@param antenna_id index of the antenna if the device has multiple antennas
@param flags flags must be set to TRUE if timestamp parameter needs to be applied
*/
static int trx_usrp_write_recplay(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) {
struct timespec req;
usrp_state_t *s = (usrp_state_t *)device->priv;
req.tv_sec = 0;
req.tv_nsec = s->recplay_state->u_sf_write_delay * 1000;
nanosleep(&req, NULL);
return nsamps;
}
/*! \brief Called to send samples to the USRP RF target /*! \brief Called to send samples to the USRP RF target
@param device pointer to the device structure specific to the RF hardware target @param device pointer to the device structure specific to the RF hardware target
@param timestamp The timestamp at which the first sample MUST be sent @param timestamp The timestamp at which the first sample MUST be sent
...@@ -389,134 +404,125 @@ static void trx_usrp_end(openair0_device *device) { ...@@ -389,134 +404,125 @@ static void trx_usrp_end(openair0_device *device) {
static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) {
int ret=0; int ret=0;
usrp_state_t *s = (usrp_state_t *)device->priv; usrp_state_t *s = (usrp_state_t *)device->priv;
int nsamps2; // aligned to upper 32 or 16 byte boundary
if (s->recplay_mode != RECPLAY_REPLAYMODE) { // not replay mode
int nsamps2; // aligned to upper 32 or 16 byte boundary
#if defined(__x86_64) || defined(__i386__) #if defined(__x86_64) || defined(__i386__)
#ifdef __AVX2__ #ifdef __AVX2__
nsamps2 = (nsamps+7)>>3; nsamps2 = (nsamps+7)>>3;
__m256i buff_tx[2][nsamps2]; __m256i buff_tx[2][nsamps2];
#else #else
nsamps2 = (nsamps+3)>>2; nsamps2 = (nsamps+3)>>2;
__m128i buff_tx[2][nsamps2]; __m128i buff_tx[2][nsamps2];
#endif #endif
#elif defined(__arm__) #elif defined(__arm__)
nsamps2 = (nsamps+3)>>2; nsamps2 = (nsamps+3)>>2;
int16x8_t buff_tx[2][nsamps2]; int16x8_t buff_tx[2][nsamps2];
#else #else
#error Unsupported CPU architecture, USRP device cannot be built #error Unsupported CPU architecture, USRP device cannot be built
#endif #endif
// bring RX data into 12 LSBs for softmodem RX // bring RX data into 12 LSBs for softmodem RX
for (int i=0; i<cc; i++) { for (int i=0; i<cc; i++) {
for (int j=0; j<nsamps2; j++) { for (int j=0; j<nsamps2; j++) {
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
#ifdef __AVX2__ #ifdef __AVX2__
buff_tx[i][j] = _mm256_slli_epi16(((__m256i *)buff[i])[j],4); buff_tx[i][j] = _mm256_slli_epi16(((__m256i *)buff[i])[j],4);
#else #else
buff_tx[i][j] = _mm_slli_epi16(((__m128i *)buff[i])[j],4); buff_tx[i][j] = _mm_slli_epi16(((__m128i *)buff[i])[j],4);
#endif #endif
#elif defined(__arm__) #elif defined(__arm__)
buff_tx[i][j] = vshlq_n_s16(((int16x8_t *)buff[i])[j],4); buff_tx[i][j] = vshlq_n_s16(((int16x8_t *)buff[i])[j],4);
#endif #endif
}
} }
}
/* from develop branch... */ /* from develop branch... */
if ( IS_SOFTMODEM_LTE ) { if ( IS_SOFTMODEM_LTE ) {
s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate); s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate);
s->tx_md.has_time_spec = flags; s->tx_md.has_time_spec = flags;
if(flags>0) if(flags>0)
s->tx_md.has_time_spec = true; s->tx_md.has_time_spec = true;
else else
s->tx_md.has_time_spec = false; s->tx_md.has_time_spec = false;
if (flags == 2) { // start of burst if (flags == 2) { // start of burst
s->tx_md.start_of_burst = true; s->tx_md.start_of_burst = true;
s->tx_md.end_of_burst = false; s->tx_md.end_of_burst = false;
} else if (flags == 3) { // end of burst } else if (flags == 3) { // end of burst
s->tx_md.start_of_burst = false; s->tx_md.start_of_burst = false;
s->tx_md.end_of_burst = true; s->tx_md.end_of_burst = true;
} else if (flags == 4) { // start and end } else if (flags == 4) { // start and end
s->tx_md.start_of_burst = true; s->tx_md.start_of_burst = true;
s->tx_md.end_of_burst = true; s->tx_md.end_of_burst = true;
} else if (flags==1) { // middle of burst } else if (flags==1) { // middle of burst
s->tx_md.start_of_burst = false; s->tx_md.start_of_burst = false;
s->tx_md.end_of_burst = false; s->tx_md.end_of_burst = false;
} }
if(flags==10) { // fail safe mode if(flags==10) { // fail safe mode
s->tx_md.has_time_spec = false; s->tx_md.has_time_spec = false;
s->tx_md.start_of_burst = false; s->tx_md.start_of_burst = false;
s->tx_md.end_of_burst = true; s->tx_md.end_of_burst = true;
} }
if (cc>1) { if (cc>1) {
std::vector<void *> buff_ptrs; std::vector<void *> buff_ptrs;
for (int i=0; i<cc; i++)
buff_ptrs.push_back(buff_tx[i]);
ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md,1e-3);
} else
ret = (int)s->tx_stream->send(buff_tx[0], nsamps, s->tx_md,1e-3);
} else { /* => developnr code */
/* */
boolean_t first_packet_state=false,last_packet_state=false;
if (flags == 2) { // start of burst
// s->tx_md.start_of_burst = true;
// s->tx_md.end_of_burst = false;
first_packet_state = true;
last_packet_state = false;
} else if (flags == 3) { // end of burst
//s->tx_md.start_of_burst = false;
//s->tx_md.end_of_burst = true;
first_packet_state = false;
last_packet_state = true;
} else if (flags == 4) { // start and end
// s->tx_md.start_of_burst = true;
// s->tx_md.end_of_burst = true;
first_packet_state = true;
last_packet_state = true;
} else if (flags==1) { // middle of burst
// s->tx_md.start_of_burst = false;
// s->tx_md.end_of_burst = false;
first_packet_state = false;
last_packet_state = false;
} else if (flags==10) { // fail safe mode
// s->tx_md.has_time_spec = false;
// s->tx_md.start_of_burst = false;
// s->tx_md.end_of_burst = true;
first_packet_state = false;
last_packet_state = true;
}
s->tx_md.has_time_spec = true; for (int i=0; i<cc; i++)
s->tx_md.start_of_burst = (s->tx_count==0) ? true : first_packet_state; buff_ptrs.push_back(buff_tx[i]);
s->tx_md.end_of_burst = last_packet_state;
s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate); ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md,1e-3);
s->tx_count++; } else
ret = (int)s->tx_stream->send(buff_tx[0], nsamps, s->tx_md,1e-3);
} else { /* => developnr code */
/* */
boolean_t first_packet_state=false,last_packet_state=false;
if (flags == 2) { // start of burst
// s->tx_md.start_of_burst = true;
// s->tx_md.end_of_burst = false;
first_packet_state = true;
last_packet_state = false;
} else if (flags == 3) { // end of burst
//s->tx_md.start_of_burst = false;
//s->tx_md.end_of_burst = true;
first_packet_state = false;
last_packet_state = true;
} else if (flags == 4) { // start and end
// s->tx_md.start_of_burst = true;
// s->tx_md.end_of_burst = true;
first_packet_state = true;
last_packet_state = true;
} else if (flags==1) { // middle of burst
// s->tx_md.start_of_burst = false;
// s->tx_md.end_of_burst = false;
first_packet_state = false;
last_packet_state = false;
} else if (flags==10) { // fail safe mode
// s->tx_md.has_time_spec = false;
// s->tx_md.start_of_burst = false;
// s->tx_md.end_of_burst = true;
first_packet_state = false;
last_packet_state = true;
}
if (cc>1) { s->tx_md.has_time_spec = true;
std::vector<void *> buff_ptrs; s->tx_md.start_of_burst = (s->tx_count==0) ? true : first_packet_state;
s->tx_md.end_of_burst = last_packet_state;
s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate);
s->tx_count++;
for (int i=0; i<cc; i++) if (cc>1) {
buff_ptrs.push_back(&(((int16_t *)buff_tx[i])[0])); std::vector<void *> buff_ptrs;
ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md); for (int i=0; i<cc; i++)
} else ret = (int)s->tx_stream->send(&(((int16_t *)buff_tx[0])[0]), nsamps, s->tx_md); buff_ptrs.push_back(&(((int16_t *)buff_tx[i])[0]));
} /* end of developnr code */
if (ret != nsamps) LOG_E(HW,"[xmit] tx samples %d != %d\n",ret,nsamps); ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md);
} else { } else ret = (int)s->tx_stream->send(&(((int16_t *)buff_tx[0])[0]), nsamps, s->tx_md);
struct timespec req; } /* end of developnr code */
req.tv_sec = 0;
req.tv_nsec = s->recplay_state->u_sf_write_delay * 1000; if (ret != nsamps) LOG_E(HW,"[xmit] tx samples %d != %d\n",ret,nsamps);
nanosleep(&req, NULL);
ret = nsamps;
}
return ret; return ret;
} }
...@@ -932,7 +938,9 @@ static void uhd_set_thread_priority(void) { ...@@ -932,7 +938,9 @@ static void uhd_set_thread_priority(void) {
uhd::set_thread_priority_safe(1.0); uhd::set_thread_priority_safe(1.0);
} }
void noop_func(void) {
return;
}
extern "C" { extern "C" {
int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
LOG_D(HW, "openair0_cfg[0].sdr_addrs == '%s'\n", openair0_cfg[0].sdr_addrs); LOG_D(HW, "openair0_cfg[0].sdr_addrs == '%s'\n", openair0_cfg[0].sdr_addrs);
...@@ -941,7 +949,8 @@ extern "C" { ...@@ -941,7 +949,8 @@ extern "C" {
if ( device->priv == NULL) { if ( device->priv == NULL) {
s=(usrp_state_t *)calloc(sizeof(usrp_state_t),1); s=(usrp_state_t *)calloc(sizeof(usrp_state_t),1);
device->priv = s; device->priv=s;
AssertFatal( s!=NULL,"USRP device: memory allocation failure\n");
} else { } else {
LOG_E(HW, "multiple device init detected\n"); LOG_E(HW, "multiple device init detected\n");
return 0; return 0;
...@@ -949,11 +958,17 @@ extern "C" { ...@@ -949,11 +958,17 @@ extern "C" {
device->openair0_cfg = openair0_cfg; device->openair0_cfg = openair0_cfg;
read_usrpconfig(&(s->recplay_mode), &(s->recplay_state)); read_usrpconfig(&(s->recplay_mode), &(s->recplay_state));
device->trx_start_func = trx_usrp_start;
if (s!=NULL && s->recplay_mode == RECPLAY_REPLAYMODE) { device->trx_get_stats_func = trx_usrp_get_stats;
device->trx_reset_stats_func = trx_usrp_reset_stats;
device->trx_end_func = trx_usrp_end;
device->trx_stop_func = trx_usrp_stop;
device->trx_set_freq_func = trx_usrp_set_freq;
device->trx_set_gains_func = trx_usrp_set_gains;
if ( s->recplay_mode == RECPLAY_REPLAYMODE) {
// Replay subframes from from file // Replay subframes from from file
int bw_gain_adjust=0; int bw_gain_adjust=0;
device->openair0_cfg = openair0_cfg;
device->type = USRP_B200_DEV; device->type = USRP_B200_DEV;
openair0_cfg[0].rx_gain_calib_table = calib_table_b210_38; openair0_cfg[0].rx_gain_calib_table = calib_table_b210_38;
bw_gain_adjust=1; bw_gain_adjust=1;
...@@ -963,17 +978,9 @@ extern "C" { ...@@ -963,17 +978,9 @@ extern "C" {
openair0_cfg[0].iq_txshift = 4;//shift openair0_cfg[0].iq_txshift = 4;//shift
openair0_cfg[0].iq_rxrescale = 15;//rescale iqs openair0_cfg[0].iq_rxrescale = 15;//rescale iqs
set_rx_gain_offset(&openair0_cfg[0],0,bw_gain_adjust); set_rx_gain_offset(&openair0_cfg[0],0,bw_gain_adjust);
device->trx_start_func = trx_usrp_start; device->trx_write_func = trx_usrp_write_recplay;
device->trx_write_func = trx_usrp_write;
device->trx_read_func = trx_usrp_read_recplay; device->trx_read_func = trx_usrp_read_recplay;
device->trx_get_stats_func = trx_usrp_get_stats; device->uhd_set_thread_priority = noop_func;
device->trx_reset_stats_func = trx_usrp_reset_stats;
device->trx_end_func = trx_usrp_end;
device->trx_stop_func = trx_usrp_stop;
device->trx_set_freq_func = trx_usrp_set_freq;
device->trx_set_gains_func = trx_usrp_set_gains;
device->openair0_cfg = openair0_cfg;
device->uhd_set_thread_priority = uhd_set_thread_priority;
std::cerr << "USRP device initialized in subframes replay mode for " << s->recplay_state->u_sf_loops << " loops. Use mmap=" std::cerr << "USRP device initialized in subframes replay mode for " << s->recplay_state->u_sf_loops << " loops. Use mmap="
<< s->recplay_state->use_mmap << std::endl; << s->recplay_state->use_mmap << std::endl;
} else { } else {
...@@ -1110,13 +1117,9 @@ extern "C" { ...@@ -1110,13 +1117,9 @@ extern "C" {
break; break;
case 46080000: case 46080000:
<<<<<<< HEAD
//openair0_cfg[0].samples_per_packet = 2048; //openair0_cfg[0].samples_per_packet = 2048;
openair0_cfg[0].tx_sample_advance = 15; openair0_cfg[0].tx_sample_advance = 15;
=======
//openair0_cfg[0].samples_per_packet = 1024; //openair0_cfg[0].samples_per_packet = 1024;
openair0_cfg[0].tx_sample_advance = 115;
>>>>>>> Try to fix LTE UE connection problem
openair0_cfg[0].tx_bw = 40e6; openair0_cfg[0].tx_bw = 40e6;
openair0_cfg[0].rx_bw = 40e6; openair0_cfg[0].rx_bw = 40e6;
break; break;
...@@ -1318,16 +1321,8 @@ extern "C" { ...@@ -1318,16 +1321,8 @@ extern "C" {
} }
LOG_I(HW,"Device timestamp: %f...\n", s->usrp->get_time_now().get_real_secs()); LOG_I(HW,"Device timestamp: %f...\n", s->usrp->get_time_now().get_real_secs());
device->trx_start_func = trx_usrp_start;
device->trx_write_func = trx_usrp_write; device->trx_write_func = trx_usrp_write;
device->trx_read_func = trx_usrp_read; device->trx_read_func = trx_usrp_read;
device->trx_get_stats_func = trx_usrp_get_stats;
device->trx_reset_stats_func = trx_usrp_reset_stats;
device->trx_end_func = trx_usrp_end;
device->trx_stop_func = trx_usrp_stop;
device->trx_set_freq_func = trx_usrp_set_freq;
device->trx_set_gains_func = trx_usrp_set_gains;
device->openair0_cfg = openair0_cfg;
device->uhd_set_thread_priority = uhd_set_thread_priority; device->uhd_set_thread_priority = uhd_set_thread_priority;
s->sample_rate = openair0_cfg[0].sample_rate; s->sample_rate = openair0_cfg[0].sample_rate;
......
...@@ -115,7 +115,6 @@ typedef struct { ...@@ -115,7 +115,6 @@ typedef struct {
size_t mapsize; size_t mapsize;
iqrec_t *ms_sample; // memory for all subframes iqrec_t *ms_sample; // memory for all subframes
unsigned int nb_samples; unsigned int nb_samples;
unsigned int u_sf_mode; // 1=record, 2=replay
char u_sf_filename[1024]; // subframes file path char u_sf_filename[1024]; // subframes file path
unsigned int u_sf_max ; // max number of recorded subframes unsigned int u_sf_max ; // max number of recorded subframes
unsigned int u_sf_loops ; // number of loops in replay mode unsigned int u_sf_loops ; // number of loops in replay mode
......
...@@ -80,7 +80,7 @@ unsigned short config_frames[4] = {2,9,11,13}; ...@@ -80,7 +80,7 @@ unsigned short config_frames[4] = {2,9,11,13};
//#include "PHY/TOOLS/time_meas.h" //#include "PHY/TOOLS/time_meas.h"
#ifndef OPENAIR2 #ifndef OPENAIR2
#include "UTIL/OTG/otg_vars.h" #include "UTIL/OTG/otg_vars.h"
#endif #endif
...@@ -256,6 +256,7 @@ void exit_function(const char *file, const char *function, const int line, const ...@@ -256,6 +256,7 @@ void exit_function(const char *file, const char *function, const int line, const
if (s != NULL) { if (s != NULL) {
printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, s); printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, s);
} }
close_log_mem(); close_log_mem();
oai_exit = 1; oai_exit = 1;
...@@ -515,8 +516,7 @@ static void wait_nfapi_init(char *thread_name) { ...@@ -515,8 +516,7 @@ static void wait_nfapi_init(char *thread_name) {
printf( "NFAPI: got sync (%s)\n", thread_name); printf( "NFAPI: got sync (%s)\n", thread_name);
} }
int main ( int argc, char **argv ) int main ( int argc, char **argv ) {
{
int i; int i;
int CC_id = 0; int CC_id = 0;
int ru_id; int ru_id;
...@@ -531,14 +531,14 @@ int main ( int argc, char **argv ) ...@@ -531,14 +531,14 @@ int main ( int argc, char **argv )
logInit(); logInit();
printf("Reading in command-line options\n"); printf("Reading in command-line options\n");
get_options (); get_options ();
EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) { if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) {
fprintf(stderr,"Getting configuration failed\n"); fprintf(stderr,"Getting configuration failed\n");
exit(-1); exit(-1);
} }
set_softmodem_optmask(SOFTMODEM_ENB_BIT);
set_softmodem_optmask(SOFTMODEM_ENB_BIT);
#if T_TRACER #if T_TRACER
T_Config_Init(); T_Config_Init();
#endif #endif
...@@ -598,6 +598,7 @@ int main ( int argc, char **argv ) ...@@ -598,6 +598,7 @@ int main ( int argc, char **argv )
RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration; RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration;
itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
} }
node_type = RC.rrc[0]->node_type; node_type = RC.rrc[0]->node_type;
} else { } else {
printf("RC.nb_inst = 0, Initializing L1\n"); printf("RC.nb_inst = 0, Initializing L1\n");
...@@ -614,7 +615,7 @@ int main ( int argc, char **argv ) ...@@ -614,7 +615,7 @@ int main ( int argc, char **argv )
ctxt.subframe = 0; ctxt.subframe = 0;
pdcp_run(&ctxt); pdcp_run(&ctxt);
} }
/* start threads if only L1 or not a CU */ /* start threads if only L1 or not a CU */
if (RC.nb_inst == 0 || !NODE_IS_CU(node_type) || NFAPI_MODE == NFAPI_MODE_PNF || NFAPI_MODE == NFAPI_MODE_VNF) { if (RC.nb_inst == 0 || !NODE_IS_CU(node_type) || NFAPI_MODE == NFAPI_MODE_PNF || NFAPI_MODE == NFAPI_MODE_VNF) {
// init UE_PF_PO and mutex lock // init UE_PF_PO and mutex lock
...@@ -623,27 +624,26 @@ int main ( int argc, char **argv ) ...@@ -623,27 +624,26 @@ int main ( int argc, char **argv )
mlockall(MCL_CURRENT | MCL_FUTURE); mlockall(MCL_CURRENT | MCL_FUTURE);
pthread_cond_init(&sync_cond,NULL); pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL); pthread_mutex_init(&sync_mutex, NULL);
rt_sleep_ns(10*100000000ULL); rt_sleep_ns(10*100000000ULL);
if (NFAPI_MODE!=NFAPI_MONOLITHIC) { if (NFAPI_MODE!=NFAPI_MONOLITHIC) {
LOG_I(ENB_APP,"NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); LOG_I(ENB_APP,"NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n");
pthread_cond_init(&sync_cond,NULL); pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL); pthread_mutex_init(&sync_mutex, NULL);
} }
if (NFAPI_MODE==NFAPI_MODE_VNF) {// VNF if (NFAPI_MODE==NFAPI_MODE_VNF) {// VNF
#if defined(PRE_SCD_THREAD) #if defined(PRE_SCD_THREAD)
init_ru_vnf(); // ru pointer is necessary for pre_scd. init_ru_vnf(); // ru pointer is necessary for pre_scd.
#endif #endif
wait_nfapi_init("main?"); wait_nfapi_init("main?");
} }
LOG_I(ENB_APP,"START MAIN THREADS\n"); LOG_I(ENB_APP,"START MAIN THREADS\n");
// start the main threads // start the main threads
number_of_cards = 1; number_of_cards = 1;
printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst); printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst);
if (RC.nb_L1_inst > 0) { if (RC.nb_L1_inst > 0) {
printf("Initializing eNB threads single_thread_flag:%d wait_for_sync:%d\n", get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync); printf("Initializing eNB threads single_thread_flag:%d wait_for_sync:%d\n", get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync);
init_eNB(get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync); init_eNB(get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync);
...@@ -655,25 +655,25 @@ int main ( int argc, char **argv ) ...@@ -655,25 +655,25 @@ int main ( int argc, char **argv )
printf("wait_eNBs()\n"); printf("wait_eNBs()\n");
wait_eNBs(); wait_eNBs();
printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU);
// RU thread and some L1 procedure aren't necessary in VNF or L2 FAPI simulator. // RU thread and some L1 procedure aren't necessary in VNF or L2 FAPI simulator.
// but RU thread deals with pre_scd and this is necessary in VNF and simulator. // but RU thread deals with pre_scd and this is necessary in VNF and simulator.
// some initialization is necessary and init_ru_vnf do this. // some initialization is necessary and init_ru_vnf do this.
if (RC.nb_RU >0 && NFAPI_MODE!=NFAPI_MODE_VNF) { if (RC.nb_RU >0 && NFAPI_MODE!=NFAPI_MODE_VNF) {
printf("Initializing RU threads\n"); printf("Initializing RU threads\n");
init_RU(get_softmodem_params()->rf_config_file,get_softmodem_params()->clock_source,get_softmodem_params()->timing_source,get_softmodem_params()->send_dmrs_sync); init_RU(get_softmodem_params()->rf_config_file,get_softmodem_params()->clock_source,get_softmodem_params()->timing_source,get_softmodem_params()->send_dmrs_sync);
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) { for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
RC.ru[ru_id]->rf_map.card=0; RC.ru[ru_id]->rf_map.card=0;
RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset);
} }
config_sync_var=0; config_sync_var=0;
if (NFAPI_MODE==NFAPI_MODE_PNF) { // PNF if (NFAPI_MODE==NFAPI_MODE_PNF) { // PNF
wait_nfapi_init("main?"); wait_nfapi_init("main?");
} }
printf("wait RUs\n"); printf("wait RUs\n");
// CI -- Flushing the std outputs for the previous marker to show on the eNB / RRU log file // CI -- Flushing the std outputs for the previous marker to show on the eNB / RRU log file
fflush(stdout); fflush(stdout);
...@@ -701,15 +701,18 @@ int main ( int argc, char **argv ) ...@@ -701,15 +701,18 @@ int main ( int argc, char **argv )
pthread_mutex_unlock(&sync_mutex); pthread_mutex_unlock(&sync_mutex);
config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS); config_check_unknown_cmdlineopt(CONFIG_CHECKALLSECTIONS);
} }
// wait for end of program // wait for end of program
LOG_UI(ENB_APP,"TYPE <CTRL-C> TO TERMINATE\n"); LOG_UI(ENB_APP,"TYPE <CTRL-C> TO TERMINATE\n");
// CI -- Flushing the std outputs for the previous marker to show on the eNB / DU / CU log file // CI -- Flushing the std outputs for the previous marker to show on the eNB / DU / CU log file
fflush(stdout); fflush(stdout);
fflush(stderr); fflush(stderr);
// end of CI modifications // end of CI modifications
//getchar(); //getchar();
if(IS_SOFTMODEM_DOFORMS) if(IS_SOFTMODEM_DOFORMS)
load_softscope("enb"); load_softscope("enb");
itti_wait_tasks_end(); itti_wait_tasks_end();
oai_exit=1; oai_exit=1;
LOG_I(ENB_APP,"oai_exit=%d\n",oai_exit); LOG_I(ENB_APP,"oai_exit=%d\n",oai_exit);
...@@ -727,8 +730,8 @@ int main ( int argc, char **argv ) ...@@ -727,8 +730,8 @@ int main ( int argc, char **argv )
* threads have been stopped (they partially use the same memory) */ * threads have been stopped (they partially use the same memory) */
for (int inst = 0; inst < NB_eNB_INST; inst++) { for (int inst = 0; inst < NB_eNB_INST; inst++) {
for (int cc_id = 0; cc_id < RC.nb_CC[inst]; cc_id++) { for (int cc_id = 0; cc_id < RC.nb_CC[inst]; cc_id++) {
free_transport(RC.eNB[inst][cc_id]); free_transport(RC.eNB[inst][cc_id]);
phy_free_lte_eNB(RC.eNB[inst][cc_id]); phy_free_lte_eNB(RC.eNB[inst][cc_id]);
} }
} }
...@@ -746,17 +749,17 @@ int main ( int argc, char **argv ) ...@@ -746,17 +749,17 @@ int main ( int argc, char **argv )
for(ru_id=0; ru_id<RC.nb_RU; ru_id++) { for(ru_id=0; ru_id<RC.nb_RU; ru_id++) {
if (RC.ru[ru_id]->rfdevice.trx_end_func) { if (RC.ru[ru_id]->rfdevice.trx_end_func) {
RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);
RC.ru[ru_id]->rfdevice.trx_end_func = NULL; RC.ru[ru_id]->rfdevice.trx_end_func = NULL;
} }
if (RC.ru[ru_id]->ifdevice.trx_end_func) { if (RC.ru[ru_id]->ifdevice.trx_end_func) {
RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);
RC.ru[ru_id]->ifdevice.trx_end_func = NULL; RC.ru[ru_id]->ifdevice.trx_end_func = NULL;
} }
} }
} }
terminate_opt(); terminate_opt();
logClean(); logClean();
printf("Bye.\n"); printf("Bye.\n");
......
...@@ -314,7 +314,6 @@ static void get_options(void) { ...@@ -314,7 +314,6 @@ static void get_options(void) {
int timingadv = 0; int timingadv = 0;
uint8_t nfapi_mode = NFAPI_MONOLITHIC; uint8_t nfapi_mode = NFAPI_MONOLITHIC;
int simL1flag = 0; int simL1flag = 0;
set_default_frame_parms(frame_parms); set_default_frame_parms(frame_parms);
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
/* unknown parameters on command line will be checked in main /* unknown parameters on command line will be checked in main
...@@ -593,7 +592,7 @@ int main( int argc, char **argv ) { ...@@ -593,7 +592,7 @@ int main( int argc, char **argv ) {
for (int i=0; i<MAX_NUM_CCs; i++) tx_max_power[i]=23; for (int i=0; i<MAX_NUM_CCs; i++) tx_max_power[i]=23;
get_options (); get_options ();
set_softmodem_optmask(SOFTMODEM_LTEUE_BIT); set_softmodem_optmask(SOFTMODEM_LTEUE_BIT);
EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
printf("Running with %d UE instances\n",NB_UE_INST); printf("Running with %d UE instances\n",NB_UE_INST);
...@@ -622,7 +621,6 @@ int main( int argc, char **argv ) { ...@@ -622,7 +621,6 @@ int main( int argc, char **argv ) {
cpuf=get_cpu_freq_GHz(); cpuf=get_cpu_freq_GHz();
pthread_cond_init(&sync_cond,NULL); pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL); pthread_mutex_init(&sync_mutex, NULL);
printf("ITTI init\n"); printf("ITTI init\n");
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
...@@ -680,10 +678,7 @@ int main( int argc, char **argv ) { ...@@ -680,10 +678,7 @@ int main( int argc, char **argv ) {
} }
cpuf=get_cpu_freq_GHz(); cpuf=get_cpu_freq_GHz();
#if 0 // #ifndef DEADLINE_SCHEDULER #if 0 // #ifndef DEADLINE_SCHEDULER
printf("NO deadline scheduler\n"); printf("NO deadline scheduler\n");
/* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */ /* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */
cpu_set_t cpuset; cpu_set_t cpuset;
...@@ -692,16 +687,18 @@ int main( int argc, char **argv ) { ...@@ -692,16 +687,18 @@ int main( int argc, char **argv ) {
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
#ifdef CPU_AFFINITY #ifdef CPU_AFFINITY
int j; int j;
if (get_nprocs() > 2) { if (get_nprocs() > 2) {
for (j = 2; j < get_nprocs(); j++) for (j = 2; j < get_nprocs(); j++)
CPU_SET(j, &cpuset); CPU_SET(j, &cpuset);
s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (s != 0) { if (s != 0) {
perror( "pthread_setaffinity_np"); perror( "pthread_setaffinity_np");
exit_fun("Error setting processor affinity"); exit_fun("Error setting processor affinity");
} }
LOG_I(HW, "Setting the affinity of main function to all CPUs, for device library to use CPU 0 only!\n"); LOG_I(HW, "Setting the affinity of main function to all CPUs, for device library to use CPU 0 only!\n");
} }
......
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