Commit 42e9c655 authored by Parminder Singh's avatar Parminder Singh

Moved LLR calculations inside a static function

- LLR calculations are moved inside a static function and done for a
  slot in last symbol processing
parent cf3780c0
......@@ -99,6 +99,29 @@ static void nr_dlsch_layer_demapping(int16_t **llr_cw,
uint16_t length,
int16_t **llr_layers);
/* compute LLR */
static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars,
NR_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp_ptr,
int32_t **dl_ch_mag_ptr,
NR_DL_UE_HARQ_t *dlsch0_harq,
NR_DL_UE_HARQ_t *dlsch1_harq,
RX_type_t rx_type,
unsigned char harq_pid,
unsigned char eNB_id,
unsigned char eNB_id_i,
unsigned char first_symbol_flag,
unsigned char symbol,
unsigned short nb_rb,
unsigned short round,
int32_t codeword_TB0,
int32_t codeword_TB1,
uint32_t len,
uint8_t nr_tti_rx,
uint8_t beamforming_mode);
/* Main Function */
int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
PDSCH_t type,
unsigned char eNB_id,
......@@ -117,6 +140,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
PHY_NR_MEASUREMENTS *measurements = &ue->measurements;
NR_UE_DLSCH_t **dlsch;
uint16_t startSymbIdx=0;
uint16_t nbSymb=0;
int avg[4];
// int avg_0[2];
......@@ -142,13 +167,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
//to be updated higher layer
unsigned short start_rb = 0;
unsigned short nb_rb_pdsch = 50;
int16_t *pllr_symbol_cw0;
int16_t *pllr_symbol_cw1;
int16_t *pllr_symbol_layer0;
int16_t *pllr_symbol_layer1;
//int16_t *pllr_symbol_cw0_deint;
//int16_t *pllr_symbol_cw1_deint;
uint32_t llr_offset_symbol;
//uint16_t bundle_L = 2;
uint8_t pilots=0;
uint16_t n_tx=1, n_rx=1;
......@@ -666,460 +686,164 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
start_meas(&ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot]);
#endif
/* Store the valid DL RE's */
pdsch_vars[eNB_id]->dl_valid_re[symbol-1] = len;
if(dlsch0_harq->status == ACTIVE)
{
startSymbIdx = dlsch0_harq->start_symbol;
nbSymb = dlsch0_harq->nb_symbols;
}
if(dlsch1_harq)
{
startSymbIdx = dlsch1_harq->start_symbol;
nbSymb = dlsch1_harq->nb_symbols;
}
//printf("LLR dlsch0_harq->Qm %d rx_type %d cw0 %d cw1 %d symbol %d \n",dlsch0_harq->Qm,rx_type,codeword_TB0,codeword_TB1,symbol);
// compute LLRs
// -> // compute @pointer where llrs should filled for this ofdm-symbol
if (first_symbol_flag==1) pdsch_vars[eNB_id]->llr_offset[symbol-1] = 0;
llr_offset_symbol = pdsch_vars[eNB_id]->llr_offset[symbol-1];
//pllr_symbol_cw0_deint = (int8_t*)pdsch_vars[eNB_id]->llr[0];
//pllr_symbol_cw1_deint = (int8_t*)pdsch_vars[eNB_id]->llr[1];
pllr_symbol_layer0 = pdsch_vars[eNB_id]->layer_llr[0];
pllr_symbol_layer1 = pdsch_vars[eNB_id]->layer_llr[1];
pllr_symbol_layer0 += llr_offset_symbol;
pllr_symbol_layer1 += llr_offset_symbol;
pllr_symbol_cw0 = pdsch_vars[eNB_id]->llr[0];
pllr_symbol_cw1 = pdsch_vars[eNB_id]->llr[1];
pllr_symbol_cw0 += llr_offset_symbol;
pllr_symbol_cw1 += llr_offset_symbol;
pdsch_vars[eNB_id]->llr_offset[symbol] = len*dlsch0_harq->Qm + llr_offset_symbol;
/*LOG_I(PHY,"compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %x @LLR Buff(symb) %x\n",
symbol,
nb_rb,dlsch0_harq->Qm,
pdsch_vars[eNB_id]->llr_length[symbol],
pdsch_vars[eNB_id]->llr_offset[symbol],
(int16_t*)pdsch_vars[eNB_id]->llr[0],
pllr_symbol_cw0);*/
/*printf("compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %p @LLR Buff(symb) %p\n",
symbol,
nb_rb,dlsch0_harq->Qm,
pdsch_vars[eNB_id]->llr_length[symbol],
pdsch_vars[eNB_id]->llr_offset[symbol],
pdsch_vars[eNB_id]->llr[0],
pllr_symbol_cw0);*/
switch (dlsch0_harq->Qm) {
case 2 :
if ((rx_type==rx_standard) || (codeword_TB1 == -1)) {
nr_dlsch_qpsk_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pllr_symbol_cw0,
symbol,
len,
first_symbol_flag,
nb_rb,
beamforming_mode);
} else if (codeword_TB0 == -1){
nr_dlsch_qpsk_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pllr_symbol_cw1,
symbol,
len,
if(symbol == (startSymbIdx + nbSymb -1))
{
for(uint8_t i =startSymbIdx; i <= nbSymb;i++)
{
/* re evaluating the first symbol flag as LLR's are done in symbol loop */
if(i == startSymbIdx && i < 3)
{
first_symbol_flag =1;
}
else
{
first_symbol_flag=0;
}
/* Calculate LLR's for ech symbol */
nr_dlsch_llr(pdsch_vars,
frame_parms,
rxdataF_comp_ptr,
dl_ch_mag_ptr,
dlsch0_harq,
dlsch1_harq,
rx_type,
harq_pid,
eNB_id,
eNB_id_i,
first_symbol_flag,
i,
nb_rb,
round,
codeword_TB0,
codeword_TB1,
pdsch_vars[eNB_id]->dl_valid_re[i-1],
nr_tti_rx,
beamforming_mode);
}
else if (rx_type >= rx_IC_single_stream) {
if (dlsch1_harq->Qm == 2) {
nr_dlsch_qpsk_qpsk_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,len,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
//nr_dlsch_deinterleaving(symbol,bundle_L,(int16_t*)pllr_symbol_cw0,(int16_t*)pllr_symbol_cw0_deint, nb_rb_pdsch);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_qpsk_qpsk_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,len,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
nr_dlsch_layer_demapping(pdsch_vars[eNB_id]->llr,
dlsch[0]->harq_processes[harq_pid]->Nl,
dlsch[0]->harq_processes[harq_pid]->Qm,
dlsch[0]->harq_processes[harq_pid]->G,
pdsch_vars[eNB_id]->layer_llr);
}
}
else if (dlsch1_harq->Qm == 4) {
nr_dlsch_qpsk_16qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
dl_ch_mag_ptr,//i
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
//nr_dlsch_deinterleaving(symbol,bundle_L,(int16_t*)pllr_symbol_cw0,(int16_t*)pllr_symbol_cw0_deint, nb_rb_pdsch);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_16qam_qpsk_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
dl_ch_mag_ptr,
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
nr_dlsch_layer_demapping(pdsch_vars[eNB_id]->llr,
dlsch[0]->harq_processes[harq_pid]->Nl,
dlsch[0]->harq_processes[harq_pid]->Qm,
dlsch[0]->harq_processes[harq_pid]->G,
pdsch_vars[eNB_id]->layer_llr);
}
#if UE_TIMING_TRACE
stop_meas(&ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot]);
#if DISABLE_LOG_X
printf("[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_tti_rx,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0));
#else
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_tti_rx,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0));
#endif
#endif
// Please keep it: useful for debugging
#ifdef DEBUG_PDSCH_RX
char filename[40];
uint8_t aa = 0;
snprintf(filename, 40, "rxdataF0_symb_%d_nr_tti_rx_%d.m", symbol, nr_tti_rx);
write_output(filename, "rxdataF0", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1);
snprintf(filename, 40, "dl_ch_estimates0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx);
write_output(filename, "dl_ch_estimates", &pdsch_vars[eNB_id]->dl_ch_estimates[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1);
snprintf(filename, 40, "rxdataF_ext0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx);
write_output(filename, "rxdataF_ext", &pdsch_vars[eNB_id]->rxdataF_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1);
snprintf(filename, 40, "dl_ch_estimates_ext0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx);
write_output(filename, "dl_ch_estimates_ext00", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1);
snprintf(filename, 40, "rxdataF_comp0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx);
write_output(filename, "rxdataF_comp00", &pdsch_vars[eNB_id]->rxdataF_comp0[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1);
for (int i=0; i < 2; i++){
snprintf(filename, 40, "llr%d_symb_%d_nr_tti_rx_%d.m", i, symbol, nr_tti_rx);
write_output(filename,"llr", &pdsch_vars[eNB_id]->llr[i][0], (NR_SYMBOLS_PER_SLOT*nb_rb*NR_NB_SC_PER_RB*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm), 1, 0);
}
else {
nr_dlsch_qpsk_64qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
dl_ch_mag_ptr,//i
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_64qam_qpsk_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
dl_ch_mag_ptr,
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
#endif
#if T_TRACER
T(T_UE_PHY_PDSCH_IQ, T_INT(eNB_id), T_INT(ue->Mod_id), T_INT(frame%1024),
T_INT(nr_tti_rx), T_INT(nb_rb),
T_INT(frame_parms->N_RB_UL), T_INT(frame_parms->symbols_per_slot),
T_BUFFER(&pdsch_vars[eNB_id]->rxdataF_comp0[eNB_id][0],
2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_slot*2));
#endif
return(0);
}
void nr_dlsch_deinterleaving(uint8_t symbol,
uint8_t start_symbol,
uint16_t L,
uint16_t *llr,
uint16_t *llr_deint,
uint16_t nb_rb_pdsch)
{
uint32_t bundle_idx, N_bundle, R, C, r,c;
int32_t m,k;
uint8_t nb_re;
R=2;
N_bundle = nb_rb_pdsch/L;
C=N_bundle/R;
uint32_t *bundle_deint = malloc(N_bundle*sizeof(uint32_t));
printf("N_bundle %u L %d nb_rb_pdsch %d\n",N_bundle, L,nb_rb_pdsch);
if (symbol==start_symbol)
nb_re = 6;
else
nb_re = 12;
AssertFatal(llr!=NULL,"nr_dlsch_deinterleaving: FATAL llr is Null\n");
for (c =0; c< C; c++){
for (r=0; r<R;r++){
bundle_idx = r*C+c;
bundle_deint[bundle_idx] = c*R+r;
//printf("c %u r %u bundle_idx %u bundle_deinter %u\n", c, r, bundle_idx, bundle_deint[bundle_idx]);
}
}
}
break;
case 4 :
if ((rx_type==rx_standard ) || (codeword_TB1 == -1)) {
nr_dlsch_16qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pdsch_vars[eNB_id]->llr[0],
pdsch_vars[eNB_id]->dl_ch_mag0,
symbol,len,first_symbol_flag,nb_rb,
pdsch_vars[eNB_id]->llr128,
beamforming_mode);
} else if (codeword_TB0 == -1){
nr_dlsch_16qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pdsch_vars[eNB_id]->llr[1],
pdsch_vars[eNB_id]->dl_ch_mag0,
symbol,len,first_symbol_flag,nb_rb,
pdsch_vars[eNB_id]->llr128_2ndstream,
beamforming_mode);
}
else if (rx_type >= rx_IC_single_stream) {
if (dlsch1_harq->Qm == 2) {
nr_dlsch_16qam_qpsk_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_qpsk_16qam_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
pdsch_vars[eNB_id]->dl_ch_mag0,//i
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
}
else if (dlsch1_harq->Qm == 4) {
nr_dlsch_16qam_16qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
dl_ch_mag_ptr,//i
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,len,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_16qam_16qam_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
dl_ch_mag_ptr,
pdsch_vars[eNB_id]->dl_ch_mag0,//i
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,len,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
}
else {
nr_dlsch_16qam_64qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
dl_ch_mag_ptr,//i
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_64qam_16qam_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,
dl_ch_mag_ptr,
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
}
}
break;
case 6 :
if ((rx_type==rx_standard) || (codeword_TB1 == -1)) {
nr_dlsch_64qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
(int16_t*)pllr_symbol_cw0,
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_magb0,
symbol,len,first_symbol_flag,nb_rb,
pdsch_vars[eNB_id]->llr_offset[symbol],
beamforming_mode);
} else if (codeword_TB0 == -1){
nr_dlsch_64qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pllr_symbol_cw1,
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_magb0,
symbol,len,first_symbol_flag,nb_rb,
pdsch_vars[eNB_id]->llr_offset[symbol],
beamforming_mode);
}
else if (rx_type >= rx_IC_single_stream) {
if (dlsch1_harq->Qm == 2) {
nr_dlsch_64qam_qpsk_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_qpsk_64qam_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
}
else if (dlsch1_harq->Qm == 4) {
nr_dlsch_64qam_16qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
dl_ch_mag_ptr,//i
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_16qam_64qam_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
dl_ch_mag_ptr,
pdsch_vars[eNB_id]->dl_ch_mag0,//i
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
}
else {
nr_dlsch_64qam_64qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
dl_ch_mag_ptr,//i
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
(int16_t*)pllr_symbol_layer0,
symbol,len,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr_offset[symbol]);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_64qam_64qam_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
dl_ch_mag_ptr,
pdsch_vars[eNB_id]->dl_ch_mag0,//i
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pllr_symbol_layer1,
symbol,len,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr_offset[symbol]);
}
}
}
break;
default:
LOG_W(PHY,"rx_dlsch.c : Unknown mod_order!!!!\n");
return(-1);
break;
}
if (dlsch1_harq) {
switch (nr_get_Qm_dl(dlsch1_harq->mcs,dlsch1_harq->mcs_table)) {
case 2 :
if (rx_type==rx_standard) {
nr_dlsch_qpsk_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pllr_symbol_cw0,
symbol,len,first_symbol_flag,nb_rb,
beamforming_mode);
}
break;
case 4:
if (rx_type==rx_standard) {
nr_dlsch_16qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pdsch_vars[eNB_id]->llr[0],
pdsch_vars[eNB_id]->dl_ch_mag0,
symbol,len,first_symbol_flag,nb_rb,
pdsch_vars[eNB_id]->llr128,
beamforming_mode);
}
break;
case 6 :
if (rx_type==rx_standard) {
nr_dlsch_64qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pllr_symbol_cw0,
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_magb0,
symbol,len,first_symbol_flag,nb_rb,
pdsch_vars[eNB_id]->llr_offset[symbol],
beamforming_mode);
}
break;
default:
LOG_W(PHY,"rx_dlsch.c : Unknown mod_order!!!!\n");
return(-1);
break;
}
}
//nr_dlsch_deinterleaving(symbol,bundle_L,(int16_t*)pllr_symbol_cw0,(int16_t*)pllr_symbol_cw0_deint, nb_rb_pdsch);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_layer_demapping(pdsch_vars[eNB_id]->llr,
dlsch[0]->harq_processes[harq_pid]->Nl,
dlsch[0]->harq_processes[harq_pid]->Qm,
dlsch[0]->harq_processes[harq_pid]->G,
pdsch_vars[eNB_id]->layer_llr);
}
#if UE_TIMING_TRACE
stop_meas(&ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot]);
#if DISABLE_LOG_X
printf("[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_tti_rx,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0));
#else
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_tti_rx,slot,symbol,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0));
#endif
#endif
// Please keep it: useful for debugging
#ifdef DEBUG_PDSCH_RX
char filename[40];
uint8_t aa = 0;
snprintf(filename, 40, "rxdataF0_symb_%d_nr_tti_rx_%d.m", symbol, nr_tti_rx);
write_output(filename, "rxdataF0", &common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1);
snprintf(filename, 40, "dl_ch_estimates0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx);
write_output(filename, "dl_ch_estimates", &pdsch_vars[eNB_id]->dl_ch_estimates[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->ofdm_symbol_size, 1, 1);
snprintf(filename, 40, "rxdataF_ext0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx);
write_output(filename, "rxdataF_ext", &pdsch_vars[eNB_id]->rxdataF_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1);
snprintf(filename, 40, "dl_ch_estimates_ext0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx);
write_output(filename, "dl_ch_estimates_ext00", &pdsch_vars[eNB_id]->dl_ch_estimates_ext[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1);
snprintf(filename, 40, "rxdataF_comp0%d_symb_%d_nr_tti_rx_%d.m", aa, symbol, nr_tti_rx);
write_output(filename, "rxdataF_comp00", &pdsch_vars[eNB_id]->rxdataF_comp0[aa][0], NR_SYMBOLS_PER_SLOT*frame_parms->N_RB_DL*NR_NB_SC_PER_RB, 1, 1);
for (int i=0; i < 2; i++){
snprintf(filename, 40, "llr%d_symb_%d_nr_tti_rx_%d.m", i, symbol, nr_tti_rx);
write_output(filename,"llr", &pdsch_vars[eNB_id]->llr[i][0], (NR_SYMBOLS_PER_SLOT*nb_rb*NR_NB_SC_PER_RB*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm), 1, 0);
}
#endif
#if T_TRACER
T(T_UE_PHY_PDSCH_IQ, T_INT(eNB_id), T_INT(ue->Mod_id), T_INT(frame%1024),
T_INT(nr_tti_rx), T_INT(nb_rb),
T_INT(frame_parms->N_RB_UL), T_INT(frame_parms->symbols_per_slot),
T_BUFFER(&pdsch_vars[eNB_id]->rxdataF_comp0[eNB_id][0],
2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL *12*frame_parms->symbols_per_slot*2));
#endif
return(0);
}
void nr_dlsch_deinterleaving(uint8_t symbol,
uint8_t start_symbol,
uint16_t L,
uint16_t *llr,
uint16_t *llr_deint,
uint16_t nb_rb_pdsch)
{
uint32_t bundle_idx, N_bundle, R, C, r,c;
int32_t m,k;
uint8_t nb_re;
R=2;
N_bundle = nb_rb_pdsch/L;
C=N_bundle/R;
uint32_t *bundle_deint = malloc(N_bundle*sizeof(uint32_t));
printf("N_bundle %u L %d nb_rb_pdsch %d\n",N_bundle, L,nb_rb_pdsch);
if (symbol==start_symbol)
nb_re = 6;
else
nb_re = 12;
AssertFatal(llr!=NULL,"nr_dlsch_deinterleaving: FATAL llr is Null\n");
for (c =0; c< C; c++){
for (r=0; r<R;r++){
bundle_idx = r*C+c;
bundle_deint[bundle_idx] = c*R+r;
//printf("c %u r %u bundle_idx %u bundle_deinter %u\n", c, r, bundle_idx, bundle_deint[bundle_idx]);
}
}
for (k=0; k<N_bundle;k++)
{
for (m=0; m<nb_re*L;m++){
llr_deint[bundle_deint[k]*nb_re*L+m]= llr[k*nb_re*L+m];
//printf("k %d m %d bundle_deint %d llr_deint %d\n", k, m, bundle_deint[k], llr_deint[bundle_deint[k]*nb_re*L+m]);
for (k=0; k<N_bundle;k++)
{
for (m=0; m<nb_re*L;m++){
llr_deint[bundle_deint[k]*nb_re*L+m]= llr[k*nb_re*L+m];
//printf("k %d m %d bundle_deint %d llr_deint %d\n", k, m, bundle_deint[k], llr_deint[bundle_deint[k]*nb_re*L+m]);
}
}
free(bundle_deint);
......@@ -2167,399 +1891,780 @@ void nr_dlsch_detection_mrc_core(int **rxdataF_comp,
if (n_rx>1) {
for (aatx=0; aatx<n_tx; aatx++) {
for (aatx=0; aatx<n_tx; aatx++) {
rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][start_point];
rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][start_point];
dl_ch_mag128_0 = (__m128i *)&dl_ch_mag[(aatx<<1)][start_point];
dl_ch_mag128_1 = (__m128i *)&dl_ch_mag[(aatx<<1)+1][start_point];
dl_ch_mag128_0b = (__m128i *)&dl_ch_magb[(aatx<<1)][start_point];
dl_ch_mag128_1b = (__m128i *)&dl_ch_magb[(aatx<<1)+1][start_point];
if (length_mod4 == 0){
length2 = length>>2;
for (i=0; i<length2; ++i) {
rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1));
dl_ch_mag128_0[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0[i],1),_mm_srai_epi16(dl_ch_mag128_1[i],1));
dl_ch_mag128_0b[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0b[i],1),_mm_srai_epi16(dl_ch_mag128_1b[i],1));
}
}
}
if (rho) {
rho128_0 = (__m128i *) &rho[0][start_point];
rho128_1 = (__m128i *) &rho[1][start_point];
if (n_tx == 4){
rho128_2 = (__m128i *) &rho[2][start_point];
rho128_3 = (__m128i *) &rho[3][start_point];
}
if (length_mod4 == 0){
length2 = length>>2;
for (i=0; i<length2; ++i) {
rho128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_0[i],1),_mm_srai_epi16(rho128_1[i],1));
if (n_tx == 4){
rho128_2[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_2[i],1),_mm_srai_epi16(rho128_3[i],1));
}
}
}
}
if (rho_i){
rho128_i0 = (__m128i *) &rho_i[0][start_point];
rho128_i1 = (__m128i *) &rho_i[1][start_point];
if (n_tx == 4){
rho128_i2 = (__m128i *) &rho_i[2][start_point];
rho128_i3 = (__m128i *) &rho_i[3][start_point];
}
if (length_mod4 == 0){
length2 = length>>2;
for (i=0; i<length2; ++i){
rho128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_i0[i],1),_mm_srai_epi16(rho128_i1[i],1));
if (n_tx == 4){
rho128_i2[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_i2[i],1),_mm_srai_epi16(rho128_i3[i],1));
}
}
}
}
if (n_tx == 4){
rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[0][start_point];
rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[2][start_point];
rxdataF_comp128_2 = (__m128i *)&rxdataF_comp[4][start_point];
rxdataF_comp128_3 = (__m128i *)&rxdataF_comp[6][start_point];
dl_ch_mag128_0 = (__m128i *)&dl_ch_mag[0][start_point];
dl_ch_mag128_1 = (__m128i *)&dl_ch_mag[2][start_point];
dl_ch_mag128_2 = (__m128i *)&dl_ch_mag[4][start_point];
dl_ch_mag128_3 = (__m128i *)&dl_ch_mag[6][start_point];
dl_ch_mag128_0b = (__m128i *)&dl_ch_magb[0][start_point];
dl_ch_mag128_1b = (__m128i *)&dl_ch_magb[2][start_point];
dl_ch_mag128_2b = (__m128i *)&dl_ch_magb[4][start_point];
dl_ch_mag128_3b = (__m128i *)&dl_ch_magb[6][start_point];
rho128_0 = (__m128i *)&rho[0][start_point];
rho128_1 = (__m128i *)&rho[2][start_point];
rho128_i0 = (__m128i *)&rho_i[0][start_point];
rho128_i1 = (__m128i *)&rho_i[2][start_point];
if (length_mod4 == 0){
length2 = length>>2;
for (i=0; i<length2; ++i) {
rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1));
rxdataF_comp128_2[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_2[i],1),_mm_srai_epi16(rxdataF_comp128_3[i],1));
dl_ch_mag128_0[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0[i],1),_mm_srai_epi16(dl_ch_mag128_1[i],1));
dl_ch_mag128_2[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_2[i],1),_mm_srai_epi16(dl_ch_mag128_3[i],1));
dl_ch_mag128_0b[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0b[i],1),_mm_srai_epi16(dl_ch_mag128_1b[i],1));
dl_ch_mag128_2b[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_2b[i],1),_mm_srai_epi16(dl_ch_mag128_3b[i],1));
rho128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_0[i],1),_mm_srai_epi16(rho128_1[i],1));
rho128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_i0[i],1),_mm_srai_epi16(rho128_i1[i],1));
}
}
}
}
_mm_empty();
_m_empty();
#elif defined(__arm__)
unsigned char aatx;
int i;
int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1;
int length_mod4 = 0;
int length2;
int ii=0;
if (n_rx>1) {
for (aatx=0; aatx<n_tx; aatx++) {
rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][start_point];
rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][start_point];
dl_ch_mag128_0 = (int16x8_t *)&dl_ch_mag[(aatx<<1)][start_point];
dl_ch_mag128_1 = (int16x8_t *)&dl_ch_mag[(aatx<<1)+1][start_point];
dl_ch_mag128_0b = (int16x8_t *)&dl_ch_magb[(aatx<<1)][start_point];
dl_ch_mag128_1b = (int16x8_t *)&dl_ch_magb[(aatx<<1)+1][start_point];
if (length_mod4 == 0){
length2 = length>>2;
for (i=0; i<length2; ++ii) {
rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]);
dl_ch_mag128_0[i] = vhaddq_s16(dl_ch_mag128_0[i],dl_ch_mag128_1[i]);
dl_ch_mag128_0b[i] = vhaddq_s16(dl_ch_mag128_0b[i],dl_ch_mag128_1b[i]);
}
}
if (rho) {
rho128_0 = (int16x8_t *) &rho[0][start_point];
rho128_1 = (int16x8_t *) &rho[1][start_point];
if (length_mod4 == 0){
length2 = length>>2;
for (i=0; i<length2; ++i) {
rho128_0[i] = vhaddq_s16(rho128_0[i],rho128_1[i]);
}
}
}
if (rho_i){
rho128_i0 = (__m128i *) &rho_i[0][start_point];
rho128_i1 = (__m128i *) &rho_i[1][start_point];
if (length_mod4 == 0){
length2 = length>>2;
for (i=0; i<length2; ++i)
rho128_i0[i] = vhaddq_s16(rho128_i0[i],rho128_i1[i]);
}
}
}
}
#endif
}
//==============================================================================================
// Extraction functions
//==============================================================================================
unsigned short nr_dlsch_extract_rbs_single(int **rxdataF,
int **dl_ch_estimates,
int **rxdataF_ext,
int **dl_ch_estimates_ext,
unsigned short pmi,
unsigned char *pmi_ext,
unsigned char symbol,
uint8_t pilots,
unsigned short start_rb,
unsigned short nb_rb_pdsch,
unsigned char nr_tti_rx,
uint32_t high_speed_flag,
NR_DL_FRAME_PARMS *frame_parms,
uint16_t dlDmrsSymbPos) {
unsigned short k,rb;
unsigned char i,aarx; //,nsymb,sss_symb,pss_symb=0,l;
int *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext;
uint8_t ClosestDMRSIdx = 15; //closest DMRS index to the current OFDM symbol
uint8_t ClosestDMRSdist = 15; //temporarily save the distance to the closest DMRS symbol
int8_t DMRSdist = 15; //temporarily save the distance to the DMRS symbol
unsigned char j=0;
AssertFatal(frame_parms->nushift ==0 || frame_parms->nushift == 1,
"nushift %d is illegal\n",frame_parms->nushift);
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
k = frame_parms->first_carrier_offset + NR_NB_SC_PER_RB*start_rb;
if (high_speed_flag == 1) {
for (int i=0; i<16; i++) { //loop over all possible DMRS symbols
if ( (1<<i & dlDmrsSymbPos) > 0 ) {
DMRSdist = symbol-i;
DMRSdist = DMRSdist>=0 ? DMRSdist : -DMRSdist;
if ( DMRSdist < ClosestDMRSdist ) {
ClosestDMRSIdx = i;
ClosestDMRSdist = DMRSdist;
}
}
}
dl_ch0 = &dl_ch_estimates[aarx][(ClosestDMRSIdx*(frame_parms->ofdm_symbol_size))]; //use closest DMRS
}
else
dl_ch0 = &dl_ch_estimates[aarx][0];
dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(nb_rb_pdsch*12)];
rxF_ext = &rxdataF_ext[aarx][symbol*(nb_rb_pdsch*12)];
rxF = &rxdataF[aarx][(k+(symbol*(frame_parms->ofdm_symbol_size)))];
for (rb = 0; rb < nb_rb_pdsch; rb++) {
if (k>frame_parms->ofdm_symbol_size) {
k = k-frame_parms->ofdm_symbol_size;
rxF = &rxdataF[aarx][(k+(symbol*(frame_parms->ofdm_symbol_size)))];
}
if (pilots==0) {
memcpy((void*)rxF_ext,(void*)rxF,12*sizeof(*rxF_ext));
memcpy((void*)dl_ch0_ext,(void*)dl_ch0,12*sizeof(*dl_ch0_ext));
dl_ch0_ext+=12;
rxF_ext+=12;
} else {
j=0;
for (i = (1-frame_parms->nushift);
i<12;
i+=2) {
rxF_ext[j]=rxF[i];
dl_ch0_ext[j]=dl_ch0[i];
j++;
}
rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[(aatx<<1)][start_point];
rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[(aatx<<1)+1][start_point];
dl_ch_mag128_0 = (__m128i *)&dl_ch_mag[(aatx<<1)][start_point];
dl_ch_mag128_1 = (__m128i *)&dl_ch_mag[(aatx<<1)+1][start_point];
dl_ch_mag128_0b = (__m128i *)&dl_ch_magb[(aatx<<1)][start_point];
dl_ch_mag128_1b = (__m128i *)&dl_ch_magb[(aatx<<1)+1][start_point];
if (length_mod4 == 0){
length2 = length>>2;
dl_ch0_ext+=6;
rxF_ext+=6;
}
for (i=0; i<length2; ++i) {
rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1));
dl_ch_mag128_0[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0[i],1),_mm_srai_epi16(dl_ch_mag128_1[i],1));
dl_ch_mag128_0b[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0b[i],1),_mm_srai_epi16(dl_ch_mag128_1b[i],1));
dl_ch0+=12;
rxF+=12;
k+=12;
if (k>=frame_parms->ofdm_symbol_size) {
k=k-(frame_parms->ofdm_symbol_size);
rxF = &rxdataF[aarx][k+(symbol*(frame_parms->ofdm_symbol_size))];
}
}
}
if (rho) {
rho128_0 = (__m128i *) &rho[0][start_point];
rho128_1 = (__m128i *) &rho[1][start_point];
return(nb_rb_pdsch/frame_parms->nb_antennas_rx);
}
if (n_tx == 4){
rho128_2 = (__m128i *) &rho[2][start_point];
rho128_3 = (__m128i *) &rho[3][start_point];
}
if (length_mod4 == 0){
length2 = length>>2;
unsigned short nr_dlsch_extract_rbs_dual(int **rxdataF,
int **dl_ch_estimates,
int **rxdataF_ext,
int **dl_ch_estimates_ext,
unsigned short pmi,
unsigned char *pmi_ext,
unsigned char symbol,
uint8_t pilots,
unsigned short start_rb,
unsigned short nb_rb_pdsch,
unsigned char nr_tti_rx,
uint32_t high_speed_flag,
NR_DL_FRAME_PARMS *frame_parms,
MIMO_mode_t mimo_mode) {
for (i=0; i<length2; ++i) {
rho128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_0[i],1),_mm_srai_epi16(rho128_1[i],1));
if (n_tx == 4){
rho128_2[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_2[i],1),_mm_srai_epi16(rho128_3[i],1));
}
}
}
}
int prb,nb_rb=0;
unsigned short k;
int i,j,aarx;
int32_t *dl_ch0=NULL,*dl_ch0_ext=NULL,*dl_ch1=NULL,*dl_ch1_ext=NULL,*rxF=NULL,*rxF_ext=NULL;
if (rho_i){
rho128_i0 = (__m128i *) &rho_i[0][start_point];
rho128_i1 = (__m128i *) &rho_i[1][start_point];
if (n_tx == 4){
rho128_i2 = (__m128i *) &rho_i[2][start_point];
rho128_i3 = (__m128i *) &rho_i[3][start_point];
}
if (length_mod4 == 0){
length2 = length>>2;
k = frame_parms->first_carrier_offset + 516; //0
for (i=0; i<length2; ++i){
rho128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_i0[i],1),_mm_srai_epi16(rho128_i1[i],1));
if (n_tx == 4){
rho128_i2[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_i2[i],1),_mm_srai_epi16(rho128_i3[i],1));
}
}
}
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
if (high_speed_flag==1) {
dl_ch0 = &dl_ch_estimates[aarx][symbol*(frame_parms->ofdm_symbol_size)];
dl_ch1 = &dl_ch_estimates[2+aarx][symbol*(frame_parms->ofdm_symbol_size)];
} else {
dl_ch0 = &dl_ch_estimates[aarx][0];
dl_ch1 = &dl_ch_estimates[2+aarx][0];
}
if (n_tx == 4){
//pmi_loc = pmi_ext;
rxdataF_comp128_0 = (__m128i *)&rxdataF_comp[0][start_point];
rxdataF_comp128_1 = (__m128i *)&rxdataF_comp[2][start_point];
rxdataF_comp128_2 = (__m128i *)&rxdataF_comp[4][start_point];
rxdataF_comp128_3 = (__m128i *)&rxdataF_comp[6][start_point];
// pointers to extracted RX signals and channel estimates
rxF_ext = &rxdataF_ext[aarx][symbol*(nb_rb_pdsch*12)];
dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(nb_rb_pdsch*12)];
dl_ch1_ext = &dl_ch_estimates_ext[2+aarx][symbol*(nb_rb_pdsch*12)];
dl_ch_mag128_0 = (__m128i *)&dl_ch_mag[0][start_point];
dl_ch_mag128_1 = (__m128i *)&dl_ch_mag[2][start_point];
dl_ch_mag128_2 = (__m128i *)&dl_ch_mag[4][start_point];
dl_ch_mag128_3 = (__m128i *)&dl_ch_mag[6][start_point];
for (prb=0; prb<frame_parms->N_RB_DL; prb++) {
//skip_half=0;
dl_ch_mag128_0b = (__m128i *)&dl_ch_magb[0][start_point];
dl_ch_mag128_1b = (__m128i *)&dl_ch_magb[2][start_point];
dl_ch_mag128_2b = (__m128i *)&dl_ch_magb[4][start_point];
dl_ch_mag128_3b = (__m128i *)&dl_ch_magb[6][start_point];
if ((frame_parms->N_RB_DL&1) == 0) { // even number of RBs
rho128_0 = (__m128i *)&rho[0][start_point];
rho128_1 = (__m128i *)&rho[2][start_point];
// For second half of RBs skip DC carrier
if (k>=frame_parms->ofdm_symbol_size) {
rxF = &rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))];
k=k-(frame_parms->ofdm_symbol_size);
}
rho128_i0 = (__m128i *)&rho_i[0][start_point];
rho128_i1 = (__m128i *)&rho_i[2][start_point];
/*
if (mimo_mode <= PUSCH_PRECODING1)
*pmi_loc = (pmi>>((prb>>2)<<1))&3;
else
*pmi_loc=(pmi>>prb)&1;*/
// *pmi_loc = get_pmi(frame_parms->N_RB_DL,mimo_mode,pmi,prb);
// pmi_loc++;
if (length_mod4 == 0){
if (pilots == 0) {
length2 = length>>2;
memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int));
memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int));
memcpy(rxF_ext,rxF,12*sizeof(int));
dl_ch0_ext +=12;
dl_ch1_ext +=12;
rxF_ext +=12;
} else { // pilots==1
j=0;
for (i=0; i<12; i++) {
if ((i&1)!=frame_parms->nushift) {
rxF_ext[j]=rxF[i];
// printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
dl_ch0_ext[j]=dl_ch0[i];
dl_ch1_ext[j++]=dl_ch1[i];
}
}
dl_ch0_ext+=6;
dl_ch1_ext+=6;
rxF_ext+=6;
} // pilots==1
for (i=0; i<length2; ++i) {
rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1));
rxdataF_comp128_2[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_2[i],1),_mm_srai_epi16(rxdataF_comp128_3[i],1));
dl_ch0+=12;
dl_ch1+=12;
rxF+=12;
k+=12;
}
} // for prb
} // for aarx
return(nb_rb/frame_parms->nb_antennas_rx);
}
dl_ch_mag128_0[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0[i],1),_mm_srai_epi16(dl_ch_mag128_1[i],1));
dl_ch_mag128_2[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_2[i],1),_mm_srai_epi16(dl_ch_mag128_3[i],1));
dl_ch_mag128_0b[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_0b[i],1),_mm_srai_epi16(dl_ch_mag128_1b[i],1));
dl_ch_mag128_2b[i] = _mm_adds_epi16(_mm_srai_epi16(dl_ch_mag128_2b[i],1),_mm_srai_epi16(dl_ch_mag128_3b[i],1));
static void nr_dlsch_layer_demapping(int16_t **llr_cw,
uint8_t Nl,
uint8_t mod_order,
uint16_t length,
int16_t **llr_layers) {
rho128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_0[i],1),_mm_srai_epi16(rho128_1[i],1));
switch (Nl) {
rho128_i0[i] = _mm_adds_epi16(_mm_srai_epi16(rho128_i0[i],1),_mm_srai_epi16(rho128_i1[i],1));
case 1:
memcpy((void*)llr_layers[0], (void*)llr_cw[0], (length)*sizeof(int16_t));
break;
case 2:
case 3:
case 4:
for (int i=0; i<(length/Nl/mod_order); i++){
for (int l=0; l<Nl; l++) {
for (int m=0; m<mod_order; m++){
llr_cw[0][Nl*i+l*mod_order+m] = llr_layers[l][i*mod_order+m];
}
}
}
break;
default:
AssertFatal(0, "Not supported number of layers %d\n", Nl);
}
}
_mm_empty();
_m_empty();
#elif defined(__arm__)
unsigned char aatx;
int i;
int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1,*dl_ch_mag128_0,*dl_ch_mag128_1,*dl_ch_mag128_0b,*dl_ch_mag128_1b,*rho128_0,*rho128_1,*rho128_i0,*rho128_i1;
int length_mod4 = 0;
int length2;
int ii=0;
static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars,
NR_DL_FRAME_PARMS *frame_parms,
int32_t **rxdataF_comp_ptr,
int32_t **dl_ch_mag_ptr,
NR_DL_UE_HARQ_t *dlsch0_harq,
NR_DL_UE_HARQ_t *dlsch1_harq,
RX_type_t rx_type,
unsigned char harq_pid,
unsigned char eNB_id,
unsigned char eNB_id_i,
unsigned char first_symbol_flag,
unsigned char symbol,
unsigned short nb_rb,
unsigned short round,
int32_t codeword_TB0,
int32_t codeword_TB1,
uint32_t len,
uint8_t nr_tti_rx,
uint8_t beamforming_mode)
{
if (n_rx>1) {
int16_t *pllr_symbol_cw0;
int16_t *pllr_symbol_cw1;
int16_t *pllr_symbol_layer0;
int16_t *pllr_symbol_layer1;
uint32_t llr_offset_symbol;
for (aatx=0; aatx<n_tx; aatx++) {
if (first_symbol_flag==1) pdsch_vars[eNB_id]->llr_offset[symbol-1] = 0;
llr_offset_symbol = pdsch_vars[eNB_id]->llr_offset[symbol-1];
//pllr_symbol_cw0_deint = (int8_t*)pdsch_vars[eNB_id]->llr[0];
//pllr_symbol_cw1_deint = (int8_t*)pdsch_vars[eNB_id]->llr[1];
pllr_symbol_layer0 = pdsch_vars[eNB_id]->layer_llr[0];
pllr_symbol_layer1 = pdsch_vars[eNB_id]->layer_llr[1];
pllr_symbol_layer0 += llr_offset_symbol;
pllr_symbol_layer1 += llr_offset_symbol;
pllr_symbol_cw0 = pdsch_vars[eNB_id]->llr[0];
pllr_symbol_cw1 = pdsch_vars[eNB_id]->llr[1];
pllr_symbol_cw0 += llr_offset_symbol;
pllr_symbol_cw1 += llr_offset_symbol;
rxdataF_comp128_0 = (int16x8_t *)&rxdataF_comp[(aatx<<1)][start_point];
rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][start_point];
dl_ch_mag128_0 = (int16x8_t *)&dl_ch_mag[(aatx<<1)][start_point];
dl_ch_mag128_1 = (int16x8_t *)&dl_ch_mag[(aatx<<1)+1][start_point];
dl_ch_mag128_0b = (int16x8_t *)&dl_ch_magb[(aatx<<1)][start_point];
dl_ch_mag128_1b = (int16x8_t *)&dl_ch_magb[(aatx<<1)+1][start_point];
pdsch_vars[eNB_id]->llr_offset[symbol] = len*dlsch0_harq->Qm + llr_offset_symbol;
if (length_mod4 == 0){
length2 = length>>2;
/*LOG_I(PHY,"compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %x @LLR Buff(symb) %x\n",
symbol,
nb_rb,dlsch0_harq->Qm,
pdsch_vars[eNB_id]->llr_length[symbol],
pdsch_vars[eNB_id]->llr_offset[symbol],
(int16_t*)pdsch_vars[eNB_id]->llr[0],
pllr_symbol_cw0);*/
for (i=0; i<length2; ++ii) {
rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]);
dl_ch_mag128_0[i] = vhaddq_s16(dl_ch_mag128_0[i],dl_ch_mag128_1[i]);
dl_ch_mag128_0b[i] = vhaddq_s16(dl_ch_mag128_0b[i],dl_ch_mag128_1b[i]);
}
}
/*printf("compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %p @LLR Buff(symb) %p\n",
symbol,
nb_rb,dlsch0_harq->Qm,
pdsch_vars[eNB_id]->llr_length[symbol],
pdsch_vars[eNB_id]->llr_offset[symbol],
pdsch_vars[eNB_id]->llr[0],
pllr_symbol_cw0);*/
if (rho) {
rho128_0 = (int16x8_t *) &rho[0][start_point];
rho128_1 = (int16x8_t *) &rho[1][start_point];
switch (dlsch0_harq->Qm) {
case 2 :
if ((rx_type==rx_standard) || (codeword_TB1 == -1)) {
nr_dlsch_qpsk_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pllr_symbol_cw0,
symbol,
len,
first_symbol_flag,
nb_rb,
beamforming_mode);
if (length_mod4 == 0){
length2 = length>>2;
} else if (codeword_TB0 == -1){
for (i=0; i<length2; ++i) {
rho128_0[i] = vhaddq_s16(rho128_0[i],rho128_1[i]);
nr_dlsch_qpsk_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pllr_symbol_cw1,
symbol,
len,
first_symbol_flag,
nb_rb,
beamforming_mode);
}
else if (rx_type >= rx_IC_single_stream) {
if (dlsch1_harq->Qm == 2) {
nr_dlsch_qpsk_qpsk_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,len,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_qpsk_qpsk_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,len,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
}
if (rho_i){
rho128_i0 = (__m128i *) &rho_i[0][start_point];
rho128_i1 = (__m128i *) &rho_i[1][start_point];
if (length_mod4 == 0){
length2 = length>>2;
for (i=0; i<length2; ++i)
rho128_i0[i] = vhaddq_s16(rho128_i0[i],rho128_i1[i]);
else if (dlsch1_harq->Qm == 4) {
nr_dlsch_qpsk_16qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
dl_ch_mag_ptr,//i
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_16qam_qpsk_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
dl_ch_mag_ptr,
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
}
else {
nr_dlsch_qpsk_64qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
dl_ch_mag_ptr,//i
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_64qam_qpsk_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
dl_ch_mag_ptr,
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
}
#endif
}
//==============================================================================================
// Extraction functions
//==============================================================================================
unsigned short nr_dlsch_extract_rbs_single(int **rxdataF,
int **dl_ch_estimates,
int **rxdataF_ext,
int **dl_ch_estimates_ext,
unsigned short pmi,
unsigned char *pmi_ext,
unsigned char symbol,
uint8_t pilots,
unsigned short start_rb,
unsigned short nb_rb_pdsch,
unsigned char nr_tti_rx,
uint32_t high_speed_flag,
NR_DL_FRAME_PARMS *frame_parms,
uint16_t dlDmrsSymbPos) {
unsigned short k,rb;
unsigned char i,aarx; //,nsymb,sss_symb,pss_symb=0,l;
int *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext;
uint8_t ClosestDMRSIdx = 15; //closest DMRS index to the current OFDM symbol
uint8_t ClosestDMRSdist = 15; //temporarily save the distance to the closest DMRS symbol
int8_t DMRSdist = 15; //temporarily save the distance to the DMRS symbol
unsigned char j=0;
AssertFatal(frame_parms->nushift ==0 || frame_parms->nushift == 1,
"nushift %d is illegal\n",frame_parms->nushift);
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
k = frame_parms->first_carrier_offset + NR_NB_SC_PER_RB*start_rb;
if (high_speed_flag == 1) {
for (int i=0; i<16; i++) { //loop over all possible DMRS symbols
if ( (1<<i & dlDmrsSymbPos) > 0 ) {
DMRSdist = symbol-i;
DMRSdist = DMRSdist>=0 ? DMRSdist : -DMRSdist;
if ( DMRSdist < ClosestDMRSdist ) {
ClosestDMRSIdx = i;
ClosestDMRSdist = DMRSdist;
}
break;
case 4 :
if ((rx_type==rx_standard ) || (codeword_TB1 == -1)) {
nr_dlsch_16qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pdsch_vars[eNB_id]->llr[0],
pdsch_vars[eNB_id]->dl_ch_mag0,
symbol,len,first_symbol_flag,nb_rb,
pdsch_vars[eNB_id]->llr128,
beamforming_mode);
} else if (codeword_TB0 == -1){
nr_dlsch_16qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pdsch_vars[eNB_id]->llr[1],
pdsch_vars[eNB_id]->dl_ch_mag0,
symbol,len,first_symbol_flag,nb_rb,
pdsch_vars[eNB_id]->llr128_2ndstream,
beamforming_mode);
}
else if (rx_type >= rx_IC_single_stream) {
if (dlsch1_harq->Qm == 2) {
nr_dlsch_16qam_qpsk_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_qpsk_16qam_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
pdsch_vars[eNB_id]->dl_ch_mag0,//i
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
dl_ch0 = &dl_ch_estimates[aarx][(ClosestDMRSIdx*(frame_parms->ofdm_symbol_size))]; //use closest DMRS
}
else
dl_ch0 = &dl_ch_estimates[aarx][0];
dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(nb_rb_pdsch*12)];
rxF_ext = &rxdataF_ext[aarx][symbol*(nb_rb_pdsch*12)];
rxF = &rxdataF[aarx][(k+(symbol*(frame_parms->ofdm_symbol_size)))];
for (rb = 0; rb < nb_rb_pdsch; rb++) {
if (k>frame_parms->ofdm_symbol_size) {
k = k-frame_parms->ofdm_symbol_size;
rxF = &rxdataF[aarx][(k+(symbol*(frame_parms->ofdm_symbol_size)))];
else if (dlsch1_harq->Qm == 4) {
nr_dlsch_16qam_16qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
dl_ch_mag_ptr,//i
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,len,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_16qam_16qam_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
dl_ch_mag_ptr,
pdsch_vars[eNB_id]->dl_ch_mag0,//i
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,len,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
if (pilots==0) {
memcpy((void*)rxF_ext,(void*)rxF,12*sizeof(*rxF_ext));
memcpy((void*)dl_ch0_ext,(void*)dl_ch0,12*sizeof(*dl_ch0_ext));
dl_ch0_ext+=12;
rxF_ext+=12;
} else {
j=0;
for (i = (1-frame_parms->nushift);
i<12;
i+=2) {
rxF_ext[j]=rxF[i];
dl_ch0_ext[j]=dl_ch0[i];
j++;
}
dl_ch0_ext+=6;
rxF_ext+=6;
else {
nr_dlsch_16qam_64qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
dl_ch_mag_ptr,//i
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_64qam_16qam_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,
dl_ch_mag_ptr,
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
}
dl_ch0+=12;
rxF+=12;
k+=12;
if (k>=frame_parms->ofdm_symbol_size) {
k=k-(frame_parms->ofdm_symbol_size);
rxF = &rxdataF[aarx][k+(symbol*(frame_parms->ofdm_symbol_size))];
}
break;
case 6 :
if ((rx_type==rx_standard) || (codeword_TB1 == -1)) {
nr_dlsch_64qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
(int16_t*)pllr_symbol_cw0,
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_magb0,
symbol,len,first_symbol_flag,nb_rb,
pdsch_vars[eNB_id]->llr_offset[symbol],
beamforming_mode);
} else if (codeword_TB0 == -1){
nr_dlsch_64qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pllr_symbol_cw1,
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_magb0,
symbol,len,first_symbol_flag,nb_rb,
pdsch_vars[eNB_id]->llr_offset[symbol],
beamforming_mode);
}
else if (rx_type >= rx_IC_single_stream) {
if (dlsch1_harq->Qm == 2) {
nr_dlsch_64qam_qpsk_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_qpsk_64qam_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
return(nb_rb_pdsch/frame_parms->nb_antennas_rx);
}
unsigned short nr_dlsch_extract_rbs_dual(int **rxdataF,
int **dl_ch_estimates,
int **rxdataF_ext,
int **dl_ch_estimates_ext,
unsigned short pmi,
unsigned char *pmi_ext,
unsigned char symbol,
uint8_t pilots,
unsigned short start_rb,
unsigned short nb_rb_pdsch,
unsigned char nr_tti_rx,
uint32_t high_speed_flag,
NR_DL_FRAME_PARMS *frame_parms,
MIMO_mode_t mimo_mode) {
int prb,nb_rb=0;
unsigned short k;
int i,j,aarx;
int32_t *dl_ch0=NULL,*dl_ch0_ext=NULL,*dl_ch1=NULL,*dl_ch1_ext=NULL,*rxF=NULL,*rxF_ext=NULL;
k = frame_parms->first_carrier_offset + 516; //0
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
if (high_speed_flag==1) {
dl_ch0 = &dl_ch_estimates[aarx][symbol*(frame_parms->ofdm_symbol_size)];
dl_ch1 = &dl_ch_estimates[2+aarx][symbol*(frame_parms->ofdm_symbol_size)];
} else {
dl_ch0 = &dl_ch_estimates[aarx][0];
dl_ch1 = &dl_ch_estimates[2+aarx][0];
}
//pmi_loc = pmi_ext;
// pointers to extracted RX signals and channel estimates
rxF_ext = &rxdataF_ext[aarx][symbol*(nb_rb_pdsch*12)];
dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*(nb_rb_pdsch*12)];
dl_ch1_ext = &dl_ch_estimates_ext[2+aarx][symbol*(nb_rb_pdsch*12)];
for (prb=0; prb<frame_parms->N_RB_DL; prb++) {
//skip_half=0;
if ((frame_parms->N_RB_DL&1) == 0) { // even number of RBs
// For second half of RBs skip DC carrier
if (k>=frame_parms->ofdm_symbol_size) {
rxF = &rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))];
k=k-(frame_parms->ofdm_symbol_size);
else if (dlsch1_harq->Qm == 4) {
nr_dlsch_64qam_16qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
dl_ch_mag_ptr,//i
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
pdsch_vars[eNB_id]->layer_llr[0],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_16qam_64qam_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
dl_ch_mag_ptr,
pdsch_vars[eNB_id]->dl_ch_mag0,//i
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pdsch_vars[eNB_id]->layer_llr[1],
symbol,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr128_2ndstream);
}
/*
if (mimo_mode <= PUSCH_PRECODING1)
*pmi_loc = (pmi>>((prb>>2)<<1))&3;
else
*pmi_loc=(pmi>>prb)&1;*/
// *pmi_loc = get_pmi(frame_parms->N_RB_DL,mimo_mode,pmi,prb);
// pmi_loc++;
if (pilots == 0) {
memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int));
memcpy(dl_ch1_ext,dl_ch1,12*sizeof(int));
memcpy(rxF_ext,rxF,12*sizeof(int));
dl_ch0_ext +=12;
dl_ch1_ext +=12;
rxF_ext +=12;
} else { // pilots==1
j=0;
for (i=0; i<12; i++) {
if ((i&1)!=frame_parms->nushift) {
rxF_ext[j]=rxF[i];
// printf("extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]));
dl_ch0_ext[j]=dl_ch0[i];
dl_ch1_ext[j++]=dl_ch1[i];
}
else {
nr_dlsch_64qam_64qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
rxdataF_comp_ptr,//i
pdsch_vars[eNB_id]->dl_ch_mag0,
dl_ch_mag_ptr,//i
pdsch_vars[eNB_id]->dl_ch_rho2_ext,
(int16_t*)pllr_symbol_layer0,
symbol,len,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr_offset[symbol]);
if (rx_type==rx_IC_dual_stream) {
nr_dlsch_64qam_64qam_llr(frame_parms,
rxdataF_comp_ptr,
pdsch_vars[eNB_id]->rxdataF_comp0,//i
dl_ch_mag_ptr,
pdsch_vars[eNB_id]->dl_ch_mag0,//i
pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round],
pllr_symbol_layer1,
symbol,len,first_symbol_flag,nb_rb,
adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,nr_tti_rx,symbol),
pdsch_vars[eNB_id]->llr_offset[symbol]);
}
}
dl_ch0_ext+=6;
dl_ch1_ext+=6;
rxF_ext+=6;
} // pilots==1
dl_ch0+=12;
dl_ch1+=12;
rxF+=12;
k+=12;
}
} // for prb
} // for aarx
return(nb_rb/frame_parms->nb_antennas_rx);
}
static void nr_dlsch_layer_demapping(int16_t **llr_cw,
uint8_t Nl,
uint8_t mod_order,
uint16_t length,
int16_t **llr_layers) {
switch (Nl) {
case 1:
memcpy((void*)llr_layers[0], (void*)llr_cw[0], (length)*sizeof(int16_t));
break;
default:
LOG_W(PHY,"rx_dlsch.c : Unknown mod_order!!!!\n");
return(-1);
break;
}
case 2:
case 3:
case 4:
for (int i=0; i<(length/Nl/mod_order); i++){
for (int l=0; l<Nl; l++) {
for (int m=0; m<mod_order; m++){
llr_cw[0][Nl*i+l*mod_order+m] = llr_layers[l][i*mod_order+m];
if (dlsch1_harq) {
switch (nr_get_Qm_dl(dlsch1_harq->mcs,dlsch1_harq->mcs_table)) {
case 2 :
if (rx_type==rx_standard) {
nr_dlsch_qpsk_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pllr_symbol_cw0,
symbol,len,first_symbol_flag,nb_rb,
beamforming_mode);
}
break;
case 4:
if (rx_type==rx_standard) {
nr_dlsch_16qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pdsch_vars[eNB_id]->llr[0],
pdsch_vars[eNB_id]->dl_ch_mag0,
symbol,len,first_symbol_flag,nb_rb,
pdsch_vars[eNB_id]->llr128,
beamforming_mode);
}
break;
case 6 :
if (rx_type==rx_standard) {
nr_dlsch_64qam_llr(frame_parms,
pdsch_vars[eNB_id]->rxdataF_comp0,
pllr_symbol_cw0,
pdsch_vars[eNB_id]->dl_ch_mag0,
pdsch_vars[eNB_id]->dl_ch_magb0,
symbol,len,first_symbol_flag,nb_rb,
pdsch_vars[eNB_id]->llr_offset[symbol],
beamforming_mode);
}
break;
default:
AssertFatal(0, "Not supported number of layers %d\n", Nl);
LOG_W(PHY,"rx_dlsch.c : Unknown mod_order!!!!\n");
return(-1);
break;
}
}
return 0;
}
//==============================================================================================
......
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