From 3a072ba378a6eaf24f0d368d55b1d64ab2c27de7 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Tue, 30 Oct 2018 16:52:29 +0100 Subject: [PATCH] Number of mod symbols addition in fapi --- .../nfapi/public_inc/nfapi_nr_interface.h | 3 ++- openair1/PHY/NR_TRANSPORT/nr_dlsch.c | 27 ++++++++++--------- openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c | 5 +++- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 4 +-- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h index e7cd720e80..a3b59d5e7f 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -508,7 +508,7 @@ typedef struct{ typedef struct { nfapi_tl_t tl; - uint8_t rnti; + uint16_t rnti; uint8_t rnti_type; uint8_t dci_format; uint8_t config_type; @@ -550,6 +550,7 @@ typedef struct { uint16_t length; uint8_t pdu_index; uint16_t rnti; + uint16_t nb_mod_symbols; uint8_t time_allocation_type; uint8_t freq_allocation_type; uint8_t start_prb; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c index d12021a929..47eb25c21f 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c @@ -197,10 +197,11 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t dlsch, uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5]; int16_t **mod_symbs = (int16_t**)dlsch.mod_symbs; int16_t **tx_layers = (int16_t**)dlsch.txdataF; - uint16_t n_symbs; - int8_t Wf[2], Wt[2], l0, l_prime, delta; + int8_t Wf[2], Wt[2], l0, l_prime[2], delta; uint16_t TBS = rel15->transport_block_size; + uint16_t nb_symbols = rel15->nb_mod_symbols; uint8_t Qm = rel15->modulation_order; + uint16_t encoded_length = nb_symbols*Qm; /// CRC, coding, interleaving and rate matching nr_dlsch_encoding(harq->pdu, subframe, &dlsch, &frame_parms); @@ -212,7 +213,7 @@ for (int i=0; i>4; i++) { printf("\n"); } printf("\nEncoded payload:\n"); -for (int i=0; i>4; i++) { +for (int i=0; i>4; i++) { for (int j=0; j<16; j++) printf("0x%02x\t", harq->f[(i<<4)+j]); printf("\n"); @@ -226,14 +227,14 @@ for (int i=0; i>4; i++) { pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value; for (int q=0; qnb_codewords; q++) nr_pdsch_codeword_scrambling(harq->f, - TBS, + encoded_length, q, Nid, n_RNTI, scrambled_output[q]); #ifdef DEBUG_DLSCH printf("PDSCH scrambling:\n"); -for (int i=0; i>7; i++) { +for (int i=0; i>7; i++) { for (int j=0; j<8; j++) printf("0x%08x\t", scrambled_output[0][(i<<3)+j]); printf("\n"); @@ -241,15 +242,14 @@ for (int i=0; i>7; i++) { #endif /// Modulation - n_symbs = TBS/Qm; for (int q=0; qnb_codewords; q++) nr_pdsch_codeword_modulation(scrambled_output[q], Qm, - TBS, + encoded_length, mod_symbs[q]); #ifdef DEBUG_DLSCH printf("PDSCH Modulation: Qm %d(%d)\n", Qm, n_symbs); -for (int i=0; i>3; i++) { +for (int i=0; i>3; i++) { for (int j=0; j<8; j++) { printf("%d %d\t", mod_symbs[0][((i<<3)+j)<<1], mod_symbs[0][(((i<<3)+j)<<1)+1]); } @@ -261,12 +261,12 @@ for (int i=0; i>3; i++) { /// Layer mapping nr_pdsch_layer_mapping(mod_symbs, rel15->nb_layers, - n_symbs, + nb_symbols, tx_layers); #ifdef DEBUG_DLSCH printf("Layer mapping (%d layers):\n", rel15->nb_layers); for (int l=0; lnb_layers; l++) - for (int i=0; i>3; i++) { + for (int i=0; i<(nb_symbs/rel15->nb_layers)>>3; i++) { for (int j=0; j<8; j++) { printf("%d %d\t", tx_layers[l][((i<<3)+j)<<1], tx_layers[l][(((i<<3)+j)<<1)+1]); } @@ -308,6 +308,7 @@ for (int i=0; i>3; i++) { get_Wt(Wt, ap, dmrs_type); get_Wf(Wf, ap, dmrs_type); delta = get_delta(ap, dmrs_type); + l_prime[0] = 0; // single symbol ap 0 #ifdef DEBUG_DLSCH_MAPPING printf("DMRS params for ap %d: Wt %d %d \t Wf %d %d\n", ap, Wt[0], Wt[1], Wf[0], Wf[1]); #endif @@ -319,9 +320,9 @@ printf("DMRS params for ap %d: Wt %d %d \t Wf %d %d\n", ap, Wt[0], Wt[1], Wf[0], if (k >= frame_parms.ofdm_symbol_size) k -= frame_parms.ofdm_symbol_size; - if ((l==l0) && (k == ((dmrs_type)? (6*n+k_prime+delta):((n<<2)+(k_prime<<1)+delta)))) { - ((int16_t*)txdataF[ap])[(l*frame_parms.ofdm_symbol_size + k)<<1] = (Wt[k_prime]*Wf[k_prime]*amp/2*mod_dmrs[dmrs_idx<<1]) >> 15; - ((int16_t*)txdataF[ap])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (Wt[k_prime]*Wf[k_prime]*amp/2*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; + if ((l==(l0+l_prime[0])) && (k == ((dmrs_type)? (6*n+k_prime+delta):((n<<2)+(k_prime<<1)+delta)))) { + ((int16_t*)txdataF[ap])[(l*frame_parms.ofdm_symbol_size + k)<<1] = (Wt[l_prime[0]]*Wf[k_prime]*amp/2*mod_dmrs[dmrs_idx<<1]) >> 15; + ((int16_t*)txdataF[ap])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*amp/2*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; #ifdef DEBUG_DLSCH_MAPPING printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d\n", dmrs_idx, l, k, k_prime, n, ((int16_t*)txdataF[ap])[(l*frame_parms.ofdm_symbol_size + k)<<1], ((int16_t*)txdataF[ap])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1]); diff --git a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c index 0e74b8d5ac..71f1922b48 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c @@ -107,6 +107,8 @@ void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, nfapi_nr_dl_config_dci_dl_pdu dci_pdu, nfapi_nr_config_request_t config) { + LOG_I(MAC, "TBS calculation\n"); + nfapi_nr_dl_config_pdcch_parameters_rel15_t params_rel15 = dci_pdu.pdcch_params_rel15; nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_rel15 = &dlsch_pdu->dlsch_pdu_rel15; uint8_t rnti_type = params_rel15.rnti_type; @@ -125,7 +127,7 @@ void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, uint8_t table_idx, Qm, n, scale; table_idx = get_table_idx(mcs_table, dci_format, rnti_type, ss_type); - scale = 10 + (((table_idx==2)&&((Imcs==20)||(Imcs==26)))?1:0); + scale = ((table_idx==2)&&((Imcs==20)||(Imcs==26)))?11:10; N_RE = min(156, N_RE_prime)*dlsch_rel15->n_prb; R = nr_get_code_rate(Imcs, table_idx); @@ -165,6 +167,7 @@ void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, dlsch_rel15->modulation_order = Qm; dlsch_rel15->transport_block_size = TBS; dlsch_rel15->nb_re_dmrs = N_PRB_DMRS; + dlsch_rel15->nb_mod_symbols = N_RE_prime*dlsch_rel15->n_prb*dlsch_rel15->nb_codewords; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 308e261a7a..a82130024f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -76,8 +76,8 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, dlsch_pdu_rel15->start_prb = 0; dlsch_pdu_rel15->n_prb = 106; - dlsch_pdu_rel15->start_symbol = 8; - dlsch_pdu_rel15->nb_symbols = 6; + dlsch_pdu_rel15->start_symbol = 2; + dlsch_pdu_rel15->nb_symbols = 8; dlsch_pdu_rel15->rnti = rnti; dlsch_pdu_rel15->nb_layers =1; dlsch_pdu_rel15->nb_codewords = 1;