diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c index 11a316d77e..36e737f0e6 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c @@ -506,7 +506,6 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB, uint16_t *dmrsSymbPos = &rel15_ul->ul_dmrs_symb_pos; uint16_t *ptrsSymbPos = &pusch_vars->ptrs_symbols; uint8_t *ptrsSymbIdx = &pusch_vars->ptrs_symbol_index; - uint8_t *dmrsConfigType = &rel15_ul->dmrs_config_type; uint16_t *nb_rb = &rel15_ul->rb_size; uint8_t *ptrsReOffset = &rel15_ul->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset; @@ -548,7 +547,6 @@ void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB, /*------------------------------------------------------------------------------------------------------- */ nr_ptrs_cpe_estimation(*K_ptrs, *ptrsReOffset, - *dmrsConfigType, *nb_rb, rel15_ul->rnti, nr_tti_rx, diff --git a/openair1/PHY/NR_REFSIG/ptrs_nr.c b/openair1/PHY/NR_REFSIG/ptrs_nr.c index 0d10f74c92..f95302918c 100644 --- a/openair1/PHY/NR_REFSIG/ptrs_nr.c +++ b/openair1/PHY/NR_REFSIG/ptrs_nr.c @@ -35,62 +35,16 @@ #include "dmrs_nr.h" #include "PHY/NR_REFSIG/ptrs_nr.h" #include "PHY/NR_REFSIG/nr_refsig.h" -/***********************************************************************/ - - -//#define max(a,b) (((a) > (b)) ? (a) : (b)) - -// TS 38.211 Table 6.4.1.2.2.1-1: The parameter kRE_ref. -// The first 4 colomns are DM-RS Configuration type 1 and the last 4 colomns are DM-RS Configuration type 2. - -static const int16_t table_6_4_1_2_2_1_1_pusch_ptrs_kRE_ref[6][8] = { - {0, 2, 6, 8, 0, 1, 6, 7}, - {2, 4, 8, 10, 1, 6, 7, 0}, - {1, 3, 7, 9, 2, 3, 8, 9}, - {3, 5, 9, 11, 3, 8, 9, 2}, - {-1, -1, -1, -1, 4, 5, 10, 11}, - {-1, -1, -1, -1, 5, 10, 11, 4}, -}; - -/******************************************************************* -* -* NAME : get_kRE_ref -* -* PARAMETERS : dmrs_antenna_port DMRS antenna port -* pusch_dmrs_type PUSCH DMRS type -* resourceElementOffset the parameter resourceElementOffset -* -* RETURN : the parameter k_RE_ref -* -* DESCRIPTION : 3GPP TS 38.211 Table 6.4.1.2.2.1-1 -* -*********************************************************************/ - -int16_t get_kRE_ref(uint8_t dmrs_antenna_port, uint8_t pusch_dmrs_type, uint8_t resourceElementOffset) { - uint8_t colomn; - int16_t k_RE_ref; - colomn = resourceElementOffset; - - if (pusch_dmrs_type == 2) - colomn += 4; - - k_RE_ref = table_6_4_1_2_2_1_1_pusch_ptrs_kRE_ref[dmrs_antenna_port][colomn]; - AssertFatal(k_RE_ref>=0,"invalid k_RE_ref < 0. Check PTRS Configuration\n"); - return k_RE_ref; -} - - - /******************************************************************* * * NAME : set_ptrs_symb_idx * * PARAMETERS : ptrs_symbols PTRS OFDM symbol indicies bit mask -* duration_in_symbols number of scheduled PUSCH ofdm symbols -* start_symbol first ofdm symbol of PUSCH within slot +* duration_in_symbols number of scheduled ofdm symbols +* start_symbol first ofdm symbol within slot * L_ptrs the parameter L_ptrs -* ul_dmrs_symb_pos bitmap of the time domain positions of the DMRS symbols in the scheduled PUSCH +* dmrs_symb_pos bitmap of the time domain positions of the DMRS symbols * * RETURN : sets the bit map of PTRS ofdm symbol indicies * @@ -102,37 +56,31 @@ void set_ptrs_symb_idx(uint16_t *ptrs_symbols, uint8_t duration_in_symbols, uint8_t start_symbol, uint8_t L_ptrs, - uint16_t ul_dmrs_symb_pos) { - + uint16_t dmrs_symb_pos) +{ int i = 0; int l_ref = start_symbol; - const int last_symbol = start_symbol + duration_in_symbols - 1; - if (L_ptrs==0) { + const int last_symbol = start_symbol + duration_in_symbols - 1; + if (L_ptrs == 0) { LOG_E(PHY,"bug: impossible L_ptrs\n"); *ptrs_symbols = 0; return; } - while ( (l_ref + i*L_ptrs) <= last_symbol) { - + while ((l_ref + i * L_ptrs) <= last_symbol) { int is_dmrs_symbol = 0, l_counter; - - for(l_counter = l_ref + i*L_ptrs; l_counter >= max(l_ref + (i-1)*L_ptrs + 1, l_ref); l_counter--) { - - if((ul_dmrs_symb_pos >> l_counter) & 0x01) { + for(l_counter = l_ref + i * L_ptrs; l_counter >= max(l_ref + (i - 1) * L_ptrs + 1, l_ref); l_counter--) { + if((dmrs_symb_pos >> l_counter) & 0x01) { is_dmrs_symbol = 1; break; } - } - if (is_dmrs_symbol) { l_ref = l_counter; - i = 1; + i = 1; continue; } - - *ptrs_symbols = *ptrs_symbols | (1<<(l_ref + i*L_ptrs)); + *ptrs_symbols = *ptrs_symbols | (1 << (l_ref + i * L_ptrs)); i++; } } @@ -143,31 +91,26 @@ void set_ptrs_symb_idx(uint16_t *ptrs_symbols, * * PARAMETERS : k subcarrier index * n_rnti UE CRNTI -* dmrs_antenna_port DMRS antenna port * K_ptrs the parameter K_ptrs -* pusch_dmrs_type the DMRS configuration type used for PUSCH -* N_RB number of RBs scheduled for PUSCH +* N_RB number of RBs scheduled * k_RE_ref the parameter k_RE_ref * start_sc first subcarrier index * ofdm_symbol_size number of samples in an OFDM symbol * * RETURN : 1 if subcarrier k is PTRS, or 0 otherwise * -* DESCRIPTION : 3GPP TS 38.211 6.4.1.2 Phase-tracking reference signal for PUSCH +* DESCRIPTION : 3GPP TS 38.211 6.4.1.2 Phase-tracking reference signal * *********************************************************************/ uint8_t is_ptrs_subcarrier(uint16_t k, uint16_t n_rnti, - uint8_t dmrs_antenna_port, - uint8_t pusch_dmrs_type, uint8_t K_ptrs, uint16_t N_RB, uint8_t k_RE_ref, uint16_t start_sc, uint16_t ofdm_symbol_size) { - // int16_t k_RE_ref = get_kRE_ref(dmrs_antenna_port, pusch_dmrs_type, resourceElementOffset); uint16_t k_RB_ref; if (N_RB % K_ptrs == 0) @@ -178,19 +121,18 @@ uint8_t is_ptrs_subcarrier(uint16_t k, if (k < start_sc) k += ofdm_symbol_size; - if ((k - k_RE_ref - k_RB_ref*NR_NB_SC_PER_RB - start_sc) % (K_ptrs*NR_NB_SC_PER_RB) == 0) + if ((k - k_RE_ref - k_RB_ref * NR_NB_SC_PER_RB - start_sc) % (K_ptrs * NR_NB_SC_PER_RB) == 0) return 1; return 0; } + /* return the total number of ptrs symbol in a slot */ uint8_t get_ptrs_symbols_in_slot(uint16_t l_prime_mask, uint16_t start_symb, uint16_t nb_symb) { uint8_t tmp = 0; for (int i = start_symb; i <= nb_symb; i++) - { - tmp += (l_prime_mask >> i) & 0x01; - } + tmp += (l_prime_mask >> i) & 0x01; return tmp; } @@ -198,7 +140,7 @@ uint8_t get_ptrs_symbols_in_slot(uint16_t l_prime_mask, uint16_t start_symb, uin int8_t get_next_ptrs_symbol_in_slot(uint16_t ptrs_symb_pos, uint8_t counter, uint8_t nb_symb) { for(int8_t symbol = counter; symbol < nb_symb; symbol++) { - if((ptrs_symb_pos >>symbol)&0x01 ) { + if((ptrs_symb_pos >> symbol) & 0x01) { return symbol; } } @@ -226,7 +168,6 @@ int8_t get_next_estimate_in_slot(uint16_t ptrsSymbPos,uint16_t dmrsSymbPos, ui * * PARAMETERS : K_ptrs : K value for PTRS * ptrsReOffset : RE offset for PTRS - * dmrsConfigType: DMRS configuration type * nb_rb : No. of resource blocks * rnti : RNTI * Ns : @@ -244,7 +185,6 @@ int8_t get_next_estimate_in_slot(uint16_t ptrsSymbPos,uint16_t dmrsSymbPos, ui *********************************************************************/ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, uint8_t ptrsReOffset, - uint8_t dmrsConfigType, uint16_t nb_rb, uint16_t rnti, unsigned char Ns, @@ -256,38 +196,27 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, int32_t *ptrs_sc) { //#define DEBUG_PTRS 1 - uint8_t is_ptrs_re = 0; - uint16_t re_cnt = 0; - uint16_t cnt = 0; - unsigned short nb_re_pdsch = NR_NB_SC_PER_RB * nb_rb; - if (K_ptrs==0) { + if (K_ptrs == 0) { LOG_E(PHY,"K_ptrs == 0\n"); return; } - uint16_t sc_per_symbol = (nb_rb + K_ptrs - 1)/K_ptrs; - c16_t ptrs_p[(1 + sc_per_symbol/4)*4]; - c16_t ptrs_ch_p[(1 + sc_per_symbol/4)*4]; - c16_t dmrs_comp_p[(1 + sc_per_symbol/4)*4]; - double abs = 0.0; - double real = 0.0; - double imag = 0.0; -#ifdef DEBUG_PTRS - double alpha = 0; -#endif + + uint16_t sc_per_symbol = (nb_rb + K_ptrs - 1) / K_ptrs; + c16_t ptrs_p[(1 + sc_per_symbol / 4) * 4]; + c16_t dmrs_comp_p[(1 + sc_per_symbol / 4) * 4]; + /* generate PTRS RE for the symbol */ nr_gen_ref_conj_symbols(gold_seq,sc_per_symbol*2,(int16_t*)ptrs_p, NR_MOD_TABLE_QPSK_OFFSET,2);// 2 for QPSK - + uint32_t re_cnt = 0, cnt = 0; /* loop over all sub carriers to get compensated RE on ptrs symbols*/ - for (int re = 0; re < nb_re_pdsch; re++) { - is_ptrs_re = is_ptrs_subcarrier(re, - rnti, - 0, - dmrsConfigType, - K_ptrs, - nb_rb, - ptrsReOffset, - 0,// start_re is 0 here - ofdm_symbol_size); + for (int re = 0; re < NR_NB_SC_PER_RB * nb_rb; re++) { + uint8_t is_ptrs_re = is_ptrs_subcarrier(re, + rnti, + K_ptrs, + nb_rb, + ptrsReOffset, + 0,// start_re is 0 here + ofdm_symbol_size); if(is_ptrs_re) { dmrs_comp_p[re_cnt].r = rxF_comp[re *2]; dmrs_comp_p[re_cnt].i = rxF_comp[(re *2)+1]; @@ -303,24 +232,27 @@ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, /* update the total ptrs RE in a symbol */ *ptrs_sc = re_cnt; + c16_t ptrs_ch_p[(1 + sc_per_symbol / 4) * 4]; /*Multiple compensated data with conj of PTRS */ mult_cpx_vector((int16_t*)dmrs_comp_p, (int16_t*)ptrs_p, (int16_t*)ptrs_ch_p, (1 + sc_per_symbol/4)*4, 15); // 2^15 shifted /* loop over all ptrs sub carriers in a symbol */ /* sum the error vector */ + double real = 0.0; + double imag = 0.0; for(int i = 0;i < sc_per_symbol; i++) { real += ptrs_ch_p[i].r; imag += ptrs_ch_p[i].i; } #ifdef DEBUG_PTRS - alpha = atan(imag/real); + double alpha = atan(imag/real); printf("[PHY][PTRS]: Symbol %d atan(Im,real):= %f \n",symbol, alpha ); #endif /* mean */ real /= sc_per_symbol; imag /= sc_per_symbol; /* absolute calculation */ - abs = sqrt(((real * real) + (imag * imag))); + double abs = sqrt(((real * real) + (imag * imag))); /* normalized error estimation */ error_est[0]= (real / abs)*(1<<15); /* compensation in given by conjugate of estimated phase (e^-j*2*pi*fd*t)*/ diff --git a/openair1/PHY/NR_REFSIG/ptrs_nr.h b/openair1/PHY/NR_REFSIG/ptrs_nr.h index f46c5c7aee..eca50feace 100644 --- a/openair1/PHY/NR_REFSIG/ptrs_nr.h +++ b/openair1/PHY/NR_REFSIG/ptrs_nr.h @@ -47,18 +47,14 @@ /************** FUNCTION ******************************************/ -int16_t get_kRE_ref(uint8_t dmrs_antenna_port, uint8_t pusch_dmrs_type, uint8_t resourceElementOffset); - void set_ptrs_symb_idx(uint16_t *ptrs_symbols, uint8_t duration_in_symbols, uint8_t start_symbol, uint8_t L_ptrs, - uint16_t ul_dmrs_symb_pos); + uint16_t dmrs_symb_pos); uint8_t is_ptrs_subcarrier(uint16_t k, uint16_t n_rnti, - uint8_t dmrs_antenna_port, - uint8_t pusch_dmrs_type, uint8_t K_ptrs, uint16_t N_RB, uint8_t k_RE_ref, @@ -93,7 +89,6 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos, /* general function to estimate common phase error based upon PTRS */ void nr_ptrs_cpe_estimation(uint8_t K_ptrs, uint8_t ptrsReOffset, - uint8_t dmrsConfigType, uint16_t nb_rb, uint16_t rnti, unsigned char Ns, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c index ef537ea8f2..8d81b42fdf 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c @@ -109,20 +109,19 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, int16_t mod_dmrs[n_dmrs<<1] __attribute__ ((aligned(16))); /* PTRS */ - uint16_t beta_ptrs = 1; - uint8_t ptrs_symbol = 0; uint16_t dlPtrsSymPos = 0; uint16_t n_ptrs = 0; - uint16_t ptrs_idx = 0; - uint8_t is_ptrs_re = 0; + uint32_t ptrsSymbPerSlot = 0; if(rel15->pduBitmap & 0x1) { set_ptrs_symb_idx(&dlPtrsSymPos, - rel15->NrOfSymbols, - rel15->StartSymbolIndex, - 1<PTRSTimeDensity, - rel15->dlDmrsSymbPos); - n_ptrs = (rel15->rbSize + rel15->PTRSFreqDensity - 1)/rel15->PTRSFreqDensity; + rel15->NrOfSymbols, + rel15->StartSymbolIndex, + 1 << rel15->PTRSTimeDensity, + rel15->dlDmrsSymbPos); + n_ptrs = (rel15->rbSize + rel15->PTRSFreqDensity - 1) / rel15->PTRSFreqDensity; + ptrsSymbPerSlot = get_ptrs_symbols_in_slot(dlPtrsSymPos, rel15->StartSymbolIndex, rel15->NrOfSymbols); } + harq->unav_res = ptrsSymbPerSlot * n_ptrs; /// CRC, coding, interleaving and rate matching AssertFatal(harq->pdu!=NULL,"harq->pdu is null\n"); @@ -131,7 +130,15 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, start_meas(dlsch_encoding_stats); if (nr_dlsch_encoding(gNB, - frame, slot, harq, frame_parms,output,tinput,tprep,tparity,toutput, + frame, + slot, + harq, + frame_parms, + output, + tinput, + tprep, + tparity, + toutput, dlsch_rate_matching_stats, dlsch_interleaving_stats, dlsch_segmentation_stats) == -1) @@ -300,16 +307,17 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, } /* calculate if current symbol is PTRS symbols */ - ptrs_idx = 0; + uint16_t ptrs_idx = 0; int16_t *mod_ptrs = NULL; + uint8_t ptrs_symbol = 0; if(rel15->pduBitmap & 0x1) { - ptrs_symbol = is_ptrs_symbol(l,dlPtrsSymPos); + ptrs_symbol = is_ptrs_symbol(l, dlPtrsSymPos); if(ptrs_symbol) { /* PTRS QPSK Modulation for each OFDM symbol in a slot */ - LOG_D(PHY,"Doing ptrs modulation for symbol %d, n_ptrs %d\n",l,n_ptrs); + LOG_D(PHY,"Doing ptrs modulation for symbol %d, n_ptrs %d\n", l, n_ptrs); int16_t mod_ptrsBuf[n_ptrs<<1] __attribute__ ((aligned(16))); - mod_ptrs =mod_ptrsBuf; - nr_modulation(pdsch_dmrs[l][rel15->SCID], (n_ptrs<<1), DMRS_MOD_ORDER, mod_ptrs); + mod_ptrs = mod_ptrsBuf; + nr_modulation(pdsch_dmrs[l][rel15->SCID], (n_ptrs << 1), DMRS_MOD_ORDER, mod_ptrs); } } uint16_t k = start_sc; @@ -318,13 +326,11 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, // Loop Over SCs: for (int i=0; irbSize*NR_NB_SC_PER_RB; i++) { /* check if cuurent RE is PTRS RE*/ - is_ptrs_re = 0; + uint8_t is_ptrs_re = 0; /* check for PTRS symbol and set flag for PTRS RE */ if(ptrs_symbol){ is_ptrs_re = is_ptrs_subcarrier(k, rel15->rnti, - nl, - rel15->dmrsConfigType, rel15->PTRSFreqDensity, rel15->rbSize, rel15->PTRSReOffset, @@ -348,6 +354,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx, } /* Map PTRS Symbol */ else if(is_ptrs_re){ + uint16_t beta_ptrs = 1; txdataF_precoding[nl][((l*frame_parms->ofdm_symbol_size + k)<<1) ] = (beta_ptrs*amp*mod_ptrs[ptrs_idx<<1]) >> 15; txdataF_precoding[nl][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1] = (beta_ptrs*amp*mod_ptrs[(ptrs_idx<<1) + 1])>> 15; #ifdef DEBUG_DLSCH_MAPPING diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 5f5a9260cd..4521c08673 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -159,10 +159,11 @@ void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) { dlsch->active = 0; } -void ldpc8blocks( void *p) { +void ldpc8blocks(void *p) +{ encoder_implemparams_t *impp=(encoder_implemparams_t *) p; NR_DL_gNB_HARQ_t *harq = (NR_DL_gNB_HARQ_t *)impp->harq; - uint16_t Kr= impp->K; + uint16_t Kr = impp->K; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &harq->pdsch_pdu.pdsch_pdu_rel15; uint8_t mod_order = rel15->qamModOrder[0]; uint16_t nb_rb = rel15->rbSize; @@ -176,7 +177,7 @@ void ldpc8blocks( void *p) { else nb_re_dmrs = 4*rel15->numDmrsCdmGrpsNoData; - unsigned int G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,rel15->nrOfLayers); + unsigned int G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, harq->unav_res, mod_order, rel15->nrOfLayers); LOG_D(PHY,"dlsch coding A %d Kr %d G %d (nb_rb %d, nb_symb_sch %d, nb_re_dmrs %d, length_dmrs %d, mod_order %d)\n", A,impp->K,G, nb_rb,nb_symb_sch,nb_re_dmrs,length_dmrs,(int)mod_order); // nrLDPC_encoder output is in "d" diff --git a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c index aa51f23cb6..f37a905ca2 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c @@ -34,10 +34,17 @@ #include "PHY/CODING/coding_defs.h" #include "PHY/defs_nr_common.h" -uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Qm, uint8_t Nl) { - uint32_t G; - G = ((NR_NB_SC_PER_RB*nb_symb_sch)-(nb_re_dmrs*length_dmrs))*nb_rb*Qm*Nl; - return(G); +uint32_t nr_get_G(uint16_t nb_rb, + uint16_t nb_symb_sch, + uint8_t nb_re_dmrs, + uint16_t length_dmrs, + uint32_t unav_res, + uint8_t Qm, + uint8_t Nl) +{ + uint32_t G = ((NR_NB_SC_PER_RB * nb_symb_sch) - (nb_re_dmrs * length_dmrs)) * nb_rb * Qm * Nl; + G -= unav_res * Qm * Nl; + return(G); } uint32_t nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r) { diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h index 64ffc9a36a..6890e52553 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h @@ -55,7 +55,13 @@ double nr_cyclic_shift_hopping(uint32_t n_id, int nr_slot_tx); /** \brief Computes available bits G. */ -uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch, uint8_t nb_re_dmrs, uint16_t length_dmrs, uint8_t Qm, uint8_t Nl); +uint32_t nr_get_G(uint16_t nb_rb, + uint16_t nb_symb_sch, + uint8_t nb_re_dmrs, + uint16_t length_dmrs, + uint32_t unav_res, + uint8_t Qm, + uint8_t Nl); uint32_t nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c index afa1dac143..217d6bbc88 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c @@ -1258,20 +1258,20 @@ static uint8_t nr_ulsch_mmse_2layers(NR_DL_FRAME_PARMS *frame_parms, return(0); } -static void inner_rx (PHY_VARS_gNB *gNB, - int ulsch_id, - int slot, - NR_DL_FRAME_PARMS *frame_parms, - NR_gNB_PUSCH *pusch_vars, - nfapi_nr_pusch_pdu_t *rel15_ul, - c16_t **rxF, - c16_t **ul_ch, - int16_t **llr, - int soffset, - int length, - int symbol, - int output_shift, - uint32_t nvar) +static void inner_rx(PHY_VARS_gNB *gNB, + int ulsch_id, + int slot, + NR_DL_FRAME_PARMS *frame_parms, + NR_gNB_PUSCH *pusch_vars, + nfapi_nr_pusch_pdu_t *rel15_ul, + c16_t **rxF, + c16_t **ul_ch, + int16_t **llr, + int soffset, + int length, + int symbol, + int output_shift, + uint32_t nvar) { int nb_layer = rel15_ul->nrOfLayers; int nb_rx_ant = frame_parms->nb_antennas_rx; @@ -1457,7 +1457,7 @@ int nr_rx_pusch_tp(PHY_VARS_gNB *gNB, NR_gNB_PUSCH *pusch_vars = &gNB->pusch_vars[ulsch_id]; pusch_vars->dmrs_symbol = INVALID_VALUE; - gNB->nbSymb=0; + gNB->nbSymb = 0; bwp_start_subcarrier = ((rel15_ul->rb_start + rel15_ul->bwp_start)*NR_NB_SC_PER_RB + frame_parms->first_carrier_offset) % frame_parms->ofdm_symbol_size; LOG_D(PHY,"pusch %d.%d : bwp_start_subcarrier %d, rb_start %d, first_carrier_offset %d\n", frame,slot,bwp_start_subcarrier, rel15_ul->rb_start, frame_parms->first_carrier_offset); LOG_D(PHY,"pusch %d.%d : ul_dmrs_symb_pos %x\n",frame,slot,rel15_ul->ul_dmrs_symb_pos); @@ -1550,13 +1550,29 @@ int nr_rx_pusch_tp(PHY_VARS_gNB *gNB, else nb_re_dmrs = 4*rel15_ul->num_dmrs_cdm_grps_no_data; + uint32_t unav_res = 0; + if (rel15_ul->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { + uint16_t ptrsSymbPos = 0; + set_ptrs_symb_idx(&ptrsSymbPos, + rel15_ul->nr_of_symbols, + rel15_ul->start_symbol_index, + 1 << rel15_ul->pusch_ptrs.ptrs_time_density, + rel15_ul->ul_dmrs_symb_pos); + int ptrsSymbPerSlot = get_ptrs_symbols_in_slot(ptrsSymbPos, rel15_ul->start_symbol_index, rel15_ul->nr_of_symbols); + int n_ptrs = (rel15_ul->rb_size + rel15_ul->pusch_ptrs.ptrs_freq_density - 1) / rel15_ul->pusch_ptrs.ptrs_freq_density; + unav_res = n_ptrs * ptrsSymbPerSlot; + } + // get how many bit in a slot // int G = nr_get_G(rel15_ul->rb_size, rel15_ul->nr_of_symbols, nb_re_dmrs, number_dmrs_symbols, // number of dmrs symbols irrespective of single or double symbol dmrs + unav_res, rel15_ul->qam_mod_order, rel15_ul->nrOfLayers); + gNB->ulsch[ulsch_id].unav_res = unav_res; + // initialize scrambling sequence // int16_t s[G+96] __attribute__((aligned(32))); diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index f763e04688..d658f012ad 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -1777,7 +1777,6 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, uint16_t *ptrsSymbPos = NULL; uint8_t *ptrsSymbIdx = NULL; uint8_t *ptrsReOffset = NULL; - uint8_t *dmrsConfigType = NULL; uint16_t *nb_rb = NULL; int nscid = 0; @@ -1789,7 +1788,6 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, K_ptrs = &dlsch[0].dlsch_config.PTRSFreqDensity; dmrsSymbPos = &dlsch[0].dlsch_config.dlDmrsSymbPos; ptrsReOffset = &dlsch[0].dlsch_config.PTRSReOffset; - dmrsConfigType = &dlsch[0].dlsch_config.dmrsConfigType; nb_rb = &dlsch[0].dlsch_config.number_rbs; ptrsSymbPos = &dlsch[0].ptrs_symbols; ptrsSymbIdx = &dlsch[0].ptrs_symbol_index; @@ -1803,7 +1801,6 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, K_ptrs = &dlsch[1].dlsch_config.PTRSFreqDensity; dmrsSymbPos = &dlsch[1].dlsch_config.dlDmrsSymbPos; ptrsReOffset = &dlsch[1].dlsch_config.PTRSReOffset; - dmrsConfigType = &dlsch[1].dlsch_config.dmrsConfigType; nb_rb = &dlsch[1].dlsch_config.number_rbs; ptrsSymbPos = &dlsch[1].ptrs_symbols; ptrsSymbIdx = &dlsch[1].ptrs_symbol_index; @@ -1844,7 +1841,9 @@ void nr_pdsch_ptrs_processing(PHY_VARS_NR_UE *ue, /*------------------------------------------------------------------------------------------------------- */ /* 1) Estimate common phase error per PTRS symbol */ /*------------------------------------------------------------------------------------------------------- */ - nr_ptrs_cpe_estimation(*K_ptrs,*ptrsReOffset,*dmrsConfigType,*nb_rb, + nr_ptrs_cpe_estimation(*K_ptrs, + *ptrsReOffset, + *nb_rb, rnti, nr_slot_rx, symbol, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 9a81aa6eb6..19f133ff9a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -276,9 +276,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, uint8_t nr_slot_rx, uint8_t harq_pid, int b_size, - uint8_t b[b_size]) { - uint32_t E; - uint32_t G; + uint8_t b[b_size]) +{ uint32_t ret,offset; uint32_t r,r_offset=0,Kr=8424,Kr_bytes; t_nrLDPC_dec_params decParams; @@ -342,8 +341,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, uint32_t A = dlsch->dlsch_config.TBS; ret = dlsch->max_ldpc_iterations + 1; dlsch->last_iteration_cnt = ret; - harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, dmrs_length, dlsch->dlsch_config.qamModOrder,dlsch->Nl); - G = harq_process->G; + uint32_t G = harq_process->G; // target_code_rate is in 0.1 units float Coderate = (float) dlsch->dlsch_config.targetCodeRate / 10240.0f; @@ -406,7 +404,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, set_abort(&harq_process->abort_decode, false); for (r=0; rC; r++) { //printf("start rx segment %d\n",r); - E = nr_get_E(G, harq_process->C, dlsch->dlsch_config.qamModOrder, dlsch->Nl, r); + uint32_t E = nr_get_E(G, harq_process->C, dlsch->dlsch_config.qamModOrder, dlsch->Nl, r); decParams.R = nr_get_R_ldpc_decoder(dlsch->dlsch_config.rv, E, decParams.BG, decParams.Z, &harq_process->llrLen, harq_process->DLround); union ldpcReqUnion id = {.s={dlsch->rnti,frame,nr_slot_rx,0,0}}; notifiedFIFO_elt_t *req = newNotifiedFIFO_elt(sizeof(ldpcDecode_ue_t), id.p, &nf, &nr_processDLSegment); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 894a2ee3a3..0f4bb266a7 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -602,37 +602,21 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, ue, nbRx, ptrs_phase_per_slot, ptrs_re_per_slot, rx_size_symbol, rxdataF_comp, frame_parms, dlsch0_harq, dlsch1_harq, gNB_id, nr_slot_rx, symbol, (nb_rb_pdsch * 12), dlsch[0].rnti, dlsch); dl_valid_re[symbol-1] -= ptrs_re_per_slot[0][symbol]; } - + /* at last symbol in a slot calculate LLR's for whole slot */ if(symbol == (startSymbIdx + nbSymb -1)) { - uint8_t nb_re_dmrs; - if (dlsch[0].dlsch_config.dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { - nb_re_dmrs = 6*dlsch[0].dlsch_config.n_dmrs_cdm_groups; - } - else { - nb_re_dmrs = 4*dlsch[0].dlsch_config.n_dmrs_cdm_groups; - } - uint16_t dmrs_len = get_num_dmrs(dlsch[0].dlsch_config.dlDmrsSymbPos); - const uint32_t rx_llr_size = nr_get_G(dlsch[0].dlsch_config.number_rbs, - dlsch[0].dlsch_config.number_symbols, - nb_re_dmrs, - dmrs_len, - dlsch[0].dlsch_config.qamModOrder, - dlsch[0].Nl); - const uint32_t rx_llr_layer_size = (rx_llr_size + dlsch[0].Nl - 1) / dlsch[0].Nl; + const uint32_t rx_llr_layer_size = (dlsch0_harq->G + dlsch[0].Nl - 1) / dlsch[0].Nl; int16_t* layer_llr[NR_MAX_NB_LAYERS]; - for (int i=0; iG = nr_get_G(dlsch[0].dlsch_config.number_rbs, - dlsch[0].dlsch_config.number_symbols, - nb_re_dmrs, - dmrs_len, - dlsch[0].dlsch_config.qamModOrder, - dlsch[0].Nl); nr_dlsch_layer_demapping(llr, dlsch[0].Nl, @@ -1156,17 +1133,13 @@ void nr_dlsch_scale_channel(uint32_t rx_size_symbol, //compute average channel_level on each (TX,RX) antenna pair void nr_dlsch_channel_level(uint32_t rx_size_symbol, int32_t dl_ch_estimates_ext[][rx_size_symbol], - NR_DL_FRAME_PARMS *frame_parms, - uint8_t n_tx, - int32_t *avg, - uint8_t symbol, - uint32_t len, - unsigned short nb_rb) + NR_DL_FRAME_PARMS *frame_parms, + uint8_t n_tx, + int32_t *avg, + uint8_t symbol, + uint32_t len, + unsigned short nb_rb) { - - - short rb; - unsigned char aatx,aarx; simde__m128i *dl_ch128, avg128D; //nb_rb*nre = y * 2^x @@ -1178,14 +1151,14 @@ void nr_dlsch_channel_level(uint32_t rx_size_symbol, AssertFatal(y!=0,"Cannot divide by zero: in function %s of file %s\n", __func__, __FILE__); - for (aatx=0; aatxnb_antennas_rx; aarx++) { + for (int aatx = 0; aatx < n_tx; aatx++) { + for (int aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { //clear average level avg128D = simde_mm_setzero_si128(); - dl_ch128=(simde__m128i *)dl_ch_estimates_ext[(aatx*frame_parms->nb_antennas_rx)+aarx]; + dl_ch128 = (simde__m128i *)dl_ch_estimates_ext[(aatx * frame_parms->nb_antennas_rx) + aarx]; - for (rb=0;rbnb_antennas_rx)+aarx] =(((int32_t*)&avg128D)[0] + ((int32_t*)&avg128D)[1] + ((int32_t*)&avg128D)[2] + - ((int32_t*)&avg128D)[3])/y; - // printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); + ((int32_t*)&avg128D)[3])/y; + // printf("Channel level : %d\n",avg[(aatx<<1)+aarx]); } - + } simde_mm_empty(); simde_m_empty(); } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 1750098a51..e0b0313462 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -162,12 +162,43 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, N_RE_prime = NR_NB_SC_PER_RB*number_of_symbols - nb_dmrs_re_per_rb*number_dmrs_symbols - N_PRB_oh; harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*nb_rb; + /////////////////////////PTRS parameters' initialization///////////////////////// + /////////// + + uint8_t L_ptrs, K_ptrs = 0; + uint32_t unav_res = 0; + if (pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { + K_ptrs = pusch_pdu->pusch_ptrs.ptrs_freq_density; + L_ptrs = 1 << pusch_pdu->pusch_ptrs.ptrs_time_density; + + ulsch_ue->ptrs_symbols = 0; + + set_ptrs_symb_idx(&ulsch_ue->ptrs_symbols, + number_of_symbols, + start_symbol, + L_ptrs, + ul_dmrs_symb_pos); + int n_ptrs = (nb_rb + K_ptrs - 1) / K_ptrs; + int ptrsSymbPerSlot = get_ptrs_symbols_in_slot(ulsch_ue->ptrs_symbols, + start_symbol, + number_of_symbols); + unav_res = n_ptrs * ptrsSymbPerSlot; + } + + /////////// + //////////////////////////////////////////////////////////////////// + + /////////////////////////ULSCH coding///////////////////////// /////////// - unsigned int G = nr_get_G(nb_rb, number_of_symbols, - nb_dmrs_re_per_rb, number_dmrs_symbols, mod_order, Nl); - + unsigned int G = nr_get_G(nb_rb, + number_of_symbols, + nb_dmrs_re_per_rb, + number_dmrs_symbols, + unav_res, + mod_order, + Nl); trace_NRpdu(DIRECTION_UPLINK, harq_process_ul_ue->a, @@ -177,7 +208,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, if (nr_ulsch_encoding(UE, ulsch_ue, frame_parms, harq_pid, tb_size, G) == -1) return; - /////////// //////////////////////////////////////////////////////////////////// @@ -230,32 +260,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, //////////////////////////////////////////////////////////////////////// - /////////////////////////PTRS parameters' initialization///////////////////////// - /////////// - - int16_t mod_ptrs[nb_rb] __attribute((aligned(16))); // assume maximum number of PTRS per pusch allocation - uint8_t L_ptrs, K_ptrs = 0; - uint16_t beta_ptrs = 1; // temp value until power control is implemented - - if (pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { - - K_ptrs = pusch_pdu->pusch_ptrs.ptrs_freq_density; - L_ptrs = 1<pusch_ptrs.ptrs_time_density; - - beta_ptrs = 1; // temp value until power control is implemented - - ulsch_ue->ptrs_symbols = 0; - - set_ptrs_symb_idx(&ulsch_ue->ptrs_symbols, - number_of_symbols, - start_symbol, - L_ptrs, - ul_dmrs_symb_pos); - } - - /////////// - //////////////////////////////////////////////////////////////////////////////// - /////////////////////////ULSCH layer mapping///////////////////////// /////////// @@ -377,6 +381,8 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint8_t is_ptrs_sym = 0; uint16_t dmrs_idx = 0, ptrs_idx = 0; + int16_t mod_ptrs[nb_rb] __attribute((aligned(16))); // assume maximum number of PTRS per pusch allocation + if ((ul_dmrs_symb_pos >> l) & 0x01) { is_dmrs_sym = 1; @@ -416,8 +422,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, } else if (is_ptrs_sym) { is_ptrs = is_ptrs_subcarrier(k, rnti, - nl, - dmrs_type, K_ptrs, nb_rb, pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset, @@ -447,6 +451,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, n+=(k_prime)?0:1; } else if (is_ptrs == 1) { + uint16_t beta_ptrs = 1; // temp value until power control is implemented ((int16_t*)tx_precoding[nl])[(sample_offsetF)<<1] = (beta_ptrs*AMP*mod_ptrs[ptrs_idx<<1]) >> 15; ((int16_t*)tx_precoding[nl])[((sample_offsetF)<<1) + 1] = (beta_ptrs*AMP*mod_ptrs[(ptrs_idx<<1) + 1]) >> 15; ptrs_idx++; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index e4b7180186..5c3a5490af 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -87,6 +87,8 @@ typedef struct { uint8_t *f; /// LDPC lifting size uint32_t Z; + /// REs unavailable for DLSCH (overlapping with PTRS, CSIRS etc.) + uint32_t unav_res; } NR_DL_gNB_HARQ_t; typedef struct { @@ -262,6 +264,7 @@ typedef struct { typedef struct { uint32_t frame; uint32_t slot; + uint32_t unav_res; /// Pointers to 16 HARQ processes for the ULSCH NR_UL_gNB_HARQ_t *harq_process; /// HARQ process mask, indicates which processes are currently active diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index b98de5a1f8..b91f8e5210 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -374,6 +374,7 @@ static int nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int number_symbols, nb_re_dmrs, number_dmrs_symbols, // number of dmrs symbols irrespective of single or double symbol dmrs + gNB->ulsch[ULSCH_id].unav_res, pusch_pdu->qam_mod_order, pusch_pdu->nrOfLayers); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 6831c7f475..266a72b0fe 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -40,6 +40,7 @@ #include "PHY/phy_extern_nr_ue.h" #include "PHY/MODULATION/modulation_UE.h" #include "PHY/INIT/nr_phy_init.h" +#include "PHY/NR_REFSIG/ptrs_nr.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/NR_UE_TRANSPORT/srs_modulation_nr.h" @@ -491,8 +492,8 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, NR_UE_DLSCH_t dlsch[2], int16_t *llr[2], - c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) { - + c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) +{ int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; int m; @@ -692,14 +693,6 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, return false; } - // start ldpc decode for CW 0 - dl_harq0->G = nr_get_G(dlsch[0].dlsch_config.number_rbs, - nb_symb_sch, - nb_re_dmrs, - dmrs_len, - dlsch[0].dlsch_config.qamModOrder, - dlsch[0].Nl); - start_meas(&ue->dlsch_unscrambling_stats); nr_dlsch_unscrambling(llr[0], dl_harq0->G, @@ -776,11 +769,25 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, if(is_cw1_active) { // start ldpc decode for CW 1 - dl_harq1->G = nr_get_G(dlsch[1].dlsch_config.number_rbs, + fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config = &dlsch[1].dlsch_config; + uint32_t unav_res = 0; + if(dlsch_config->pduBitmap & 0x1) { + uint16_t ptrsSymbPos = 0; + set_ptrs_symb_idx(&ptrsSymbPos, + dlsch_config->number_symbols, + dlsch_config->start_symbol, + 1 << dlsch_config->PTRSTimeDensity, + dlsch_config->dlDmrsSymbPos); + int n_ptrs = (dlsch_config->number_rbs + dlsch_config->PTRSFreqDensity - 1) / dlsch_config->PTRSFreqDensity; + int ptrsSymbPerSlot = get_ptrs_symbols_in_slot(ptrsSymbPos, dlsch_config->start_symbol, dlsch_config->number_symbols); + unav_res = n_ptrs * ptrsSymbPerSlot; + } + dl_harq1->G = nr_get_G(dlsch_config->number_rbs, nb_symb_sch, nb_re_dmrs, dmrs_len, - dlsch[1].dlsch_config.qamModOrder, + unav_res, + dlsch_config->qamModOrder, dlsch[1].Nl); start_meas(&ue->dlsch_unscrambling_stats); nr_dlsch_unscrambling(llr[1], @@ -1012,8 +1019,8 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue, void pdsch_processing(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, - nr_phy_data_t *phy_data) { - + nr_phy_data_t *phy_data) +{ int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; int gNB_id = proc->gNB_id; @@ -1027,10 +1034,10 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, const uint32_t rxdataF_sz = ue->frame_parms.samples_per_slot_wCP; __attribute__ ((aligned(32))) c16_t rxdataF[ue->frame_parms.nb_antennas_rx][rxdataF_sz]; if (dlsch[0].active) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PDSCH, VCD_FUNCTION_IN); - uint16_t nb_symb_sch = dlsch[0].dlsch_config.number_symbols; - uint16_t start_symb_sch = dlsch[0].dlsch_config.start_symbol; + fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config = &dlsch[0].dlsch_config; + uint16_t nb_symb_sch = dlsch_config->number_symbols; + uint16_t start_symb_sch = dlsch_config->start_symbol; LOG_D(PHY," ------ --> PDSCH ChannelComp/LLR Frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); //to update from pdsch config @@ -1044,25 +1051,38 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PDSCH, VCD_FUNCTION_OUT); uint8_t nb_re_dmrs; - if (dlsch[0].dlsch_config.dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { - nb_re_dmrs = 6*dlsch[0].dlsch_config.n_dmrs_cdm_groups; + if (dlsch_config->dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { + nb_re_dmrs = 6 * dlsch_config->n_dmrs_cdm_groups; } else { - nb_re_dmrs = 4*dlsch[0].dlsch_config.n_dmrs_cdm_groups; + nb_re_dmrs = 4 * dlsch_config->n_dmrs_cdm_groups; } - uint16_t dmrs_len = get_num_dmrs(dlsch[0].dlsch_config.dlDmrsSymbPos); - - const uint32_t rx_llr_size = nr_get_G(dlsch[0].dlsch_config.number_rbs, - dlsch[0].dlsch_config.number_symbols, - nb_re_dmrs, - dmrs_len, - dlsch[0].dlsch_config.qamModOrder, - dlsch[0].Nl); - const uint32_t rx_llr_buf_sz = ((rx_llr_size+15)/16)*16; + uint16_t dmrs_len = get_num_dmrs(dlsch_config->dlDmrsSymbPos); + uint32_t unav_res = 0; + if(dlsch_config->pduBitmap & 0x1) { + uint16_t ptrsSymbPos = 0; + set_ptrs_symb_idx(&ptrsSymbPos, + dlsch_config->number_symbols, + dlsch_config->start_symbol, + 1 << dlsch_config->PTRSTimeDensity, + dlsch_config->dlDmrsSymbPos); + int n_ptrs = (dlsch_config->number_rbs + dlsch_config->PTRSFreqDensity - 1) / dlsch_config->PTRSFreqDensity; + int ptrsSymbPerSlot = get_ptrs_symbols_in_slot(ptrsSymbPos, dlsch_config->start_symbol, dlsch_config->number_symbols); + unav_res = n_ptrs * ptrsSymbPerSlot; + } + NR_DL_UE_HARQ_t *dlsch0_harq = &ue->dl_harq_processes[0][dlsch_config->harq_process_nbr]; + dlsch0_harq->G = nr_get_G(dlsch_config->number_rbs, + dlsch_config->number_symbols, + nb_re_dmrs, + dmrs_len, + unav_res, + dlsch_config->qamModOrder, + dlsch[0].Nl); + const uint32_t rx_llr_buf_sz = ((dlsch0_harq->G + 15) / 16) * 16; const uint32_t nb_codewords = NR_MAX_NB_LAYERS > 4 ? 2 : 1; int16_t* llr[2]; - for (int i=0; iG, 0); LOG_D(PHY, "DLSCH data reception at nr_slot_rx: %d\n", nr_slot_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); @@ -1084,7 +1104,7 @@ void pdsch_processing(PHY_VARS_NR_UE *ue, nr_ue_dlsch_procedures(ue, proc, dlsch, llr); else // don't wait anymore - send_slot_ind(ue->tx_resume_ind_fifo[(proc->nr_slot_rx + dlsch[0].dlsch_config.k1_feedback) % ue->frame_parms.slots_per_frame], proc->nr_slot_rx); + send_slot_ind(ue->tx_resume_ind_fifo[(proc->nr_slot_rx + dlsch_config->k1_feedback) % ue->frame_parms.slots_per_frame], proc->nr_slot_rx); stop_meas(&ue->dlsch_procedures_stat); if (cpumeas(CPUMEAS_GETSTATE)) { diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 3e003252ea..8e5b405343 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -446,7 +446,7 @@ int main(int argc, char **argv) // dlsch->harq_processes[0]->nb_rb,dlsch->harq_processes[0]->mcs,dlsch->harq_processes[0]->Nl); unsigned char mod_order = nr_get_Qm_dl(Imcs, mcs_table); uint16_t rate = nr_get_code_rate_dl(Imcs, mcs_table); - unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1); + unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, 0, mod_order, Nl); TBS = nr_compute_tbs(mod_order,rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, 0, Nl); printf("available bits %u TBS %u mod_order %d\n", available_bits, TBS, mod_order); //dlsch->harq_ids[subframe]= 0; @@ -472,6 +472,7 @@ int main(int argc, char **argv) unsigned char estimated_output_bit[16 * 68 * 384]; NR_UE_DLSCH_t *dlsch0_ue = &dlsch_ue[0]; NR_DL_UE_HARQ_t *harq_process = &UE->dl_harq_processes[0][harq_pid]; + harq_process->G = available_bits; harq_process->first_rx = 1; dlsch0_ue->dlsch_config.mcs = Imcs; dlsch0_ue->dlsch_config.mcs_table = mcs_table; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 21a237785d..c20f4ddf15 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -1018,8 +1018,8 @@ int main(int argc, char **argv) 1<PTRSTimeDensity, pdsch_pdu_rel15->dlDmrsSymbPos); ptrsSymbPerSlot = get_ptrs_symbols_in_slot(dlPtrsSymPos, pdsch_pdu_rel15->StartSymbolIndex, pdsch_pdu_rel15->NrOfSymbols); - ptrsRePerSymb = ((rel15->rbSize + rel15->PTRSFreqDensity - 1)/rel15->PTRSFreqDensity); - LOG_D(PHY,"[DLSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb ); + ptrsRePerSymb = ((rel15->rbSize + rel15->PTRSFreqDensity - 1) / rel15->PTRSFreqDensity); + LOG_D(PHY,"[DLSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot, ptrsRePerSymb, ptrsSymbPerSlot * ptrsRePerSymb); } msgDataTx->ssb[0].ssb_pdu.ssb_pdu_rel15.bchPayload=0x001234; @@ -1125,12 +1125,11 @@ int main(int argc, char **argv) uint8_t nb_re_dmrs = rel15->dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6*dlsch0->dlsch_config.n_dmrs_cdm_groups : 4*dlsch0->dlsch_config.n_dmrs_cdm_groups; uint8_t mod_order = rel15->qamModOrder[0]; uint8_t nb_symb_sch = rel15->NrOfSymbols; - - available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, rel15->nrOfLayers); + uint32_t unav_res = ptrsSymbPerSlot * ptrsRePerSymb; + available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, unav_res, mod_order, rel15->nrOfLayers); if (pdu_bit_map & 0x1) { - available_bits -= (ptrsSymbPerSlot * ptrsRePerSymb * rel15->nrOfLayers * 2); if (trial == 0 && round == 0) { - printf("[DLSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5u \n", available_bits, (ptrsSymbPerSlot * ptrsRePerSymb * rel15->nrOfLayers * 2)); + printf("[DLSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5u \n", available_bits, (ptrsSymbPerSlot * ptrsRePerSymb * rel15->nrOfLayers * mod_order)); } } diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index 9691957339..dc776b0fa4 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -464,7 +464,7 @@ int main(int argc, char **argv) mod_order = nr_get_Qm_ul(Imcs, mcs_table); code_rate = nr_get_code_rate_ul(Imcs, mcs_table); - available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, Nl); + available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, 0, mod_order, Nl); TBS = nr_compute_tbs(mod_order,code_rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, 0, Nl); printf("\nAvailable bits %u TBS %u mod_order %d\n", available_bits, TBS, mod_order); @@ -519,7 +519,7 @@ int main(int argc, char **argv) /////////////////////////ULSCH coding///////////////////////// /////////// - unsigned int G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, Nl); + unsigned int G = available_bits; if (input_fd == NULL) { nr_ulsch_encoding(UE, ulsch_ue, frame_parms, harq_pid, TBS>>3, G); @@ -586,13 +586,6 @@ int main(int argc, char **argv) exit(-1); #endif - uint32_t G = nr_get_G(rel15_ul->rb_size, - rel15_ul->nr_of_symbols, - nb_re_dmrs, - 1, // FIXME only single dmrs is implemented - rel15_ul->qam_mod_order, - rel15_ul->nrOfLayers); - int nbDecode = nr_ulsch_decoding(gNB, UE_id, channel_output_fixed, frame_parms, rel15_ul, frame, subframe, harq_pid, G); int nb_ok = 0; if (nbDecode > 0) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 668c1cb633..595bf35b52 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -791,18 +791,12 @@ int main(int argc, char *argv[]) } nb_re_dmrs = nb_re_dmrs * num_dmrs_cdm_grps_no_data; - - unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, number_dmrs_symbols, mod_order, precod_nbr_layers); unsigned int TBS = nr_compute_tbs(mod_order, code_rate, nb_rb, nb_symb_sch, nb_re_dmrs * number_dmrs_symbols, 0, 0, precod_nbr_layers); - printf("[ULSIM]: length_dmrs: %u, l_prime_mask: %u number_dmrs_symbols: %u, mapping_type: %u add_pos: %d \n", length_dmrs, l_prime_mask, number_dmrs_symbols, mapping_type, add_pos); printf("[ULSIM]: CDM groups: %u, dmrs_config_type: %d, num_rbs: %u, nb_symb_sch: %u\n", num_dmrs_cdm_grps_no_data, dmrs_config_type, nb_rb, nb_symb_sch); printf("[ULSIM]: MCS: %d, mod order: %u, code_rate: %u\n", Imcs, mod_order, code_rate); - printf("[ULSIM]: VALUE OF G: %u, TBS: %u\n", available_bits, TBS); - - uint8_t ulsch_input_buffer[TBS/8]; ulsch_input_buffer[0] = 0x31; @@ -812,7 +806,6 @@ int main(int argc, char *argv[]) uint8_t ptrs_time_density = get_L_ptrs(ptrs_mcs1, ptrs_mcs2, ptrs_mcs3, Imcs, mcs_table); uint8_t ptrs_freq_density = get_K_ptrs(n_rb0, n_rb1, nb_rb); - int ptrs_symbols = 0; // to calculate total PTRS RE's in a slot double ts = 1.0/(frame_parms->subcarrier_spacing * frame_parms->ofdm_symbol_size); @@ -834,6 +827,18 @@ int main(int argc, char *argv[]) printf("\n"); + uint32_t unav_res = 0; + if (pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { + set_ptrs_symb_idx(&ptrsSymPos, nb_symb_sch, start_symbol, 1 << ptrs_time_density, l_prime_mask); + ptrsSymbPerSlot = get_ptrs_symbols_in_slot(ptrsSymPos, start_symbol, nb_symb_sch); + ptrsRePerSymb = ((nb_rb + ptrs_freq_density - 1) / ptrs_freq_density); + unav_res = ptrsSymbPerSlot * ptrsRePerSymb; + LOG_D(PHY, "[ULSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot, ptrsRePerSymb, unav_res); + } + + unsigned int available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, number_dmrs_symbols, unav_res, mod_order, precod_nbr_layers); + printf("[ULSIM]: VALUE OF G: %u, TBS: %u\n", available_bits, TBS); + int frame_length_complex_samples = frame_parms->samples_per_subframe*NR_NUMBER_OF_SUBFRAMES_PER_FRAME; for (int aatx=0; aatxpdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { - set_ptrs_symb_idx(&ptrsSymPos, pusch_pdu->nr_of_symbols, pusch_pdu->start_symbol_index, 1 << ptrs_time_density, pusch_pdu->ul_dmrs_symb_pos); - ptrsSymbPerSlot = get_ptrs_symbols_in_slot(ptrsSymPos, pusch_pdu->start_symbol_index, pusch_pdu->nr_of_symbols); - ptrsRePerSymb = ((pusch_pdu->rb_size + ptrs_freq_density - 1) / ptrs_freq_density); - LOG_D(PHY, "[ULSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot, ptrsRePerSymb, ptrsSymbPerSlot * ptrsRePerSymb); - } - //---------------------------------------------------------- //------------------- gNB phy procedures ------------------- //---------------------------------------------------------- @@ -1452,13 +1450,8 @@ int main(int argc, char *argv[]) //---------------------------------------------------------- if ((pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) && (SNR == snr0) && (trial == 0) && (round == 0)) { - ptrs_symbols = 0; - for (int i = pusch_pdu->start_symbol_index; i < pusch_pdu->start_symbol_index + pusch_pdu->nr_of_symbols; i++) - ptrs_symbols += ((pusch_vars->ptrs_symbols) >> i) & 1; - - /* 2*5*(50/2), for RB = 50,K = 2 for 5 OFDM PTRS symbols */ - available_bits -= 2 * ptrs_symbols * ((nb_rb + ptrs_freq_density - 1) / ptrs_freq_density); - printf("[ULSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5d \n", available_bits, (ptrsSymbPerSlot * ptrsRePerSymb * 2)); + printf("[ULSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5d \n", + available_bits, (ptrsSymbPerSlot * ptrsRePerSymb * mod_order * precod_nbr_layers)); } for (i = 0; i < available_bits; i++) {