From 022211cdaf3eec1b546d55d57602919ad17e82cf Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Fri, 22 Jun 2018 10:00:03 +0200 Subject: [PATCH 001/114] Coreset and search space params --- openair1/PHY/INIT/nr_init.c | 1 + openair1/PHY/NR_REFSIG/nr_gold.c | 2 +- .../PHY/NR_REFSIG/{defs.h => nr_refsig.h} | 5 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 5 +- openair1/PHY/NR_TRANSPORT/nr_dci.h | 41 ++++++++++++- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 0 openair1/PHY/NR_TRANSPORT/nr_pdcch.c | 35 ----------- openair1/SCHED_NR/nr_ru_procedures.c | 2 +- openair1/SCHED_NR/phy_procedures_nr_common.c | 58 +++++++++++++++++-- openair1/SCHED_NR/sched_nr.h | 5 ++ 10 files changed, 105 insertions(+), 49 deletions(-) rename openair1/PHY/NR_REFSIG/{defs.h => nr_refsig.h} (96%) create mode 100644 openair1/PHY/NR_TRANSPORT/nr_dci_tools.c delete mode 100644 openair1/PHY/NR_TRANSPORT/nr_pdcch.c diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 00e1f67873..41a5bf7ad5 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -22,6 +22,7 @@ #include "PHY/defs_gNB.h" #include "SCHED/sched_eNB.h" #include "PHY/phy_extern.h" +#include "PHY/NR_REFSIG/nr_refsig.h" #include "PHY/INIT/phy_init.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" #include "RadioResourceConfigCommonSIB.h" diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index dca4089e6a..110692bc0a 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -#include "defs.h" +#include "nr_refsig.h" void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB) { diff --git a/openair1/PHY/NR_REFSIG/defs.h b/openair1/PHY/NR_REFSIG/nr_refsig.h similarity index 96% rename from openair1/PHY/NR_REFSIG/defs.h rename to openair1/PHY/NR_REFSIG/nr_refsig.h index 5bb53fac87..2417d72155 100644 --- a/openair1/PHY/NR_REFSIG/defs.h +++ b/openair1/PHY/NR_REFSIG/nr_refsig.h @@ -21,8 +21,9 @@ /* Definitions for LTE Reference signals */ /* Author R. Knopp / EURECOM / OpenAirInterface.org */ -#ifndef __NR_REFSIG_DEFS__H__ -#define __NR_REFSIG_DEFS__H__ +#ifndef __NR_REFSIG__H__ +#define __NR_REFSIG__H__ + #include "PHY/defs_gNB.h" diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 02005e5fc9..29f5a9edd5 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -20,7 +20,7 @@ */ /*! \file PHY/NR_TRANSPORT/nr_dci.c -* \brief Implements DCI encoding/decoding (38.212/38.213/38.214). Current NR compliance V15.1 2018-06. +* \brief Implements DCI encoding/decoding and PDCCH TX/RX procedures (38.212/38.213/38.214). V15.1 2018-06. * \author Guy De Souza * \date 2018 * \version 0.1 @@ -35,7 +35,7 @@ uint8_t nr_get_dci_size(nr_dci_format_e format, nr_rnti_type_e rnti, NR_BWP_PARMS* bwp, - nfapi_nr_config_request_t* config) + nfapi_config_request_t* config) { uint8_t size = 0; uint16_t N_RB = bwp->N_RB; @@ -125,7 +125,6 @@ uint8_t nr_get_dci_size(nr_dci_format_e format, return size; } - uint8_t nr_generate_dci_top(NR_DCI_ALLOC_t dci_alloc, int32_t** txdataF, int16_t amp, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index 03a044ad5e..6ed05e0e55 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -21,7 +21,7 @@ #ifndef __PHY_NR_TRANSPORT_DCI__H #define __PHY_NR_TRANSPORT_DCI__H -#include "defs_gNB.h" +#include "PHY/defs_gNB.h" typedef enum { @@ -44,6 +44,41 @@ typedef enum { nr_rnti_type_P_RNTI } nr_rnti_type_e; +// PDCCH search space types css: common, uss: ue specific +typedef enum { + nr_pdcch_css_type_0=0, + nr_pdcch_css_type_0_A, + nr_pdcch_css_type_1, + nr_pdcch_css_type_2, + nr_pdcch_css_type_3, + nr_pdcch_uss_type +} nr_pdcch_ss_type_e; + +typedef enum { + nr_pdcch_mux_pattern_type_1=0, + nr_pdcch_mux_pattern_type_2, + nr_pdcch_mux_pattern_type_3 +} nr_pdcch_mux_pattern_type_e; + +typedef struct { + uint8_t param_O; + uint8_t param_M; + uint8_t nb_ss_sets_per_slot; + uint8_t first_symbol_idx; + nr_pdcch_ss_type_e ss_type; +} nr_pdcch_ss_params_t; + +typedef struct { + uint8_t n_rb; + uint8_t n_symb; + uint8_t rb_offset; + nr_pdcch_mux_pattern_type_e mux_pattern; +} nr_pdcch_coreset_params_t; + +typedef struct { + nr_pdcch_ss_params_t ss_params; + nr_pdcch_coreset_params_t coreset_params; +} nr_pdcch_params_t; typedef struct { /// Length of DCI in bits @@ -66,12 +101,12 @@ typedef struct { uint8_t nr_get_dci_size(nr_dci_format_e format, nr_rnti_type_e rnti, NR_BWP_PARMS bwp, - nfapi_nr_config_request_t* config); + nfapi_config_request_t* config); uint8_t nr_generate_dci_top(NR_DCI_ALLOC_t dci_alloc, int32_t** txdataF, int16_t amp, NR_DL_FRAME_PARMS* frame_parms, - nfapi_config_request_t* config) + nfapi_config_request_t* config); #endif //__PHY_NR_TRANSPORT_DCI__H diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/openair1/PHY/NR_TRANSPORT/nr_pdcch.c b/openair1/PHY/NR_TRANSPORT/nr_pdcch.c deleted file mode 100644 index 469c0472a5..0000000000 --- a/openair1/PHY/NR_TRANSPORT/nr_pdcch.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*! \file PHY/NR_TRANSPORT/nr_pdcch.c -* \brief Implements PDCCH physical channel TX/RX procedures (38.211). Current NR compliance V15.1 2018-06. -* \author Guy De Souza -* \date 2018 -* \version 0.1 -* \company Eurecom -* \email: desouza@eurecom.fr -* \note -* \warning -*/ - -#include "nr_dci.h" - - diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index a2c117af71..776277e3b8 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -238,7 +238,7 @@ void nr_feptx_ofdm(RU_t *ru) { } // if S-subframe generate first slot only - if (nr_subframe_select(fp,subframe) == SF_S) + if (nr_subframe_select(cfg,subframe) == SF_S) len = fp->samples_per_subframe / fp->slots_per_subframe; else len = fp->samples_per_subframe; diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c index 623e14644a..8831efa54e 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_common.c +++ b/openair1/SCHED_NR/phy_procedures_nr_common.c @@ -29,15 +29,65 @@ * \note * \warning */ -#include "PHY/defs_gNB.h" -#include "PHY/phy_extern.h" + #include "sched_nr.h" +/// LUT for the number of symbols in the coreset indexed by SSB index +uint8_t nr_coreset_nsymb_pdcch_type_0[16] = {2,2,2,2,2,3,3,3,3,3,1,1,1,2,2,2}; +/// LUT for the number of RBs in the coreset indexed by SSB index +uint8_t nr_coreset_rb_offset_pdcch_type_0[16] = {0,1,2,3,4,0,1,2,3,4,12,14,16,12,14,16}; +/// LUT for monitoring occasions param O indexed by SSB index +uint8_t nr_ss_param_O_type_0_mux1_FR1[16] = {0,0,2,2,5,5,7,7,0,5,0,0,2,2,5,5}; +/// LUT for number of SS sets per slot indexed by SSB index +uint8_t nr_ss_sets_per_slot_type_0_FR1[16] = {1,2,1,2,1,2,1,2,1,1,1,1,1,1,1,1}; +/// LUT for monitoring occasions param M indexed by SSB index +uint8_t nr_ss_param_M_type_0_mux1_FR1[16] = {1,0.5,1,0.5,1,0.5,1,0.5,2,2,1,1,1,1,1,1}; +/// LUT for SS first symbol index indexed by SSB index +uint8_t nr_ss_first_symb_idx_type_0_mux1_FR1[8] = {0,0,1,2,1,2,1,2}; + + + nr_subframe_t nr_subframe_select(nfapi_config_request_t *cfg,unsigned char subframe) { if (cfg->subframe_config.duplex_mode.value == FDD) return(SF_DL); - else - return SF_DL; +} + + +void nr_fill_pdcch_params(nr_pdcch_params_t *pdcch_params, + nfapi_config_request_t* config, + uint8_t ssb_idx) +{ + nr_pdcch_coreset_params_t *coreset_params = &pdcch_params->coreset_params; + nr_pdcch_ss_params_t *ss_params = &pdcch_params->ss_params; + + // the switch case below assumes that only the cases where the SSB and the PDCCH have the same SCS are supported along with type 1 PDCCH/ mux pattern 1 and FR1 + switch(config->subframe_config.numerology_index_mu.value) { + + case NR_MU_0: + break; + + case NR_MU_1: + coreset_params->mux_pattern = nr_pdcch_mux_pattern_type_1; + coreset_params->n_rb = (ssb_idx < 10)? 24 : 48; + coreset_params->n_symb = nr_coreset_nsymb_pdcch_type_0[ssb_idx]; + coreset_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0[ssb_idx]; + ss_params->ss_type = nr_pdcch_css_type_1; + ss_params->param_O = nr_ss_param_O_type_0_mux1_FR1[ssb_idx]; + ss_params->nb_ss_sets_per_slot = nr_ss_sets_per_slot_type_0_FR1[ssb_idx]; + ss_params->param_M = nr_ss_param_M_type_0_mux1_FR1[ssb_idx]; + ss_params->first_symbol_idx = (ssb_idx < 8)? ( (ssb_idx&1)? coreset_params->n_symb : 0 ) : nr_ss_first_symb_idx_type_0_mux1_FR1[ssb_idx - 8]; + break; + + case NR_MU_2: + break; + + case NR_MU_3: + break; + + default: + AssertFatal(1==0,"Invalid PDCCH numerology index %d", config->subframe_config.numerology_index_mu.value); + + } } diff --git a/openair1/SCHED_NR/sched_nr.h b/openair1/SCHED_NR/sched_nr.h index dde2c77d6d..238fd743da 100644 --- a/openair1/SCHED_NR/sched_nr.h +++ b/openair1/SCHED_NR/sched_nr.h @@ -31,6 +31,7 @@ #include "PHY/defs_gNB.h" #include "PHY_INTERFACE/phy_interface.h" #include "SCHED/sched_eNB.h" +#include "PHY/NR_TRANSPORT/nr_dci.h" lte_subframe_t nr_subframe_select (nfapi_config_request_t *cfg, unsigned char subframe); void nr_set_ssb_first_subcarrier(nfapi_config_request_t *cfg, NR_DL_FRAME_PARMS *fp); @@ -40,4 +41,8 @@ void nr_feptx_ofdm(RU_t *ru); void nr_feptx_ofdm_2thread(RU_t *ru); void nr_feptx0(RU_t *ru,int slot); +void nr_fill_pdcch_params(nr_pdcch_params_t *pdcch_params, + nfapi_config_request_t* config, + uint8_t ssb_idx); + #endif From c34e33bf1e2877c6b79bc2560947fbb589284e09 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Wed, 27 Jun 2018 12:07:58 +0200 Subject: [PATCH 002/114] PDCCH DMRS generation/modulation --- cmake_targets/CMakeLists.txt | 1 + openair1/PHY/INIT/nr_init.c | 15 ++++++ openair1/PHY/INIT/nr_parms.c | 3 +- openair1/PHY/NR_REFSIG/nr_gold.c | 49 ++++++++++++-------- openair1/PHY/NR_REFSIG/nr_refsig.h | 6 +++ openair1/PHY/NR_TRANSPORT/nr_dci.c | 18 +++++++ openair1/PHY/NR_TRANSPORT/nr_dci.h | 8 +++- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 2 +- openair1/PHY/defs_gNB.h | 3 ++ openair1/PHY/defs_nr_common.h | 5 ++ openair1/SCHED_NR/phy_procedures_nr_common.c | 30 +++++++++--- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 6 ++- openair1/SCHED_NR/sched_nr.h | 10 ++-- 13 files changed, 122 insertions(+), 34 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 4df0cc51e1..55cc1190c4 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1245,6 +1245,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_pss.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_sss.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_pbch.c + ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_dci.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold.c ${OPENAIR1_DIR}/PHY/TOOLS/file_output.c ${OPENAIR1_DIR}/PHY/TOOLS/cadd_vv.c diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 41a5bf7ad5..27cc8785b8 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -88,6 +88,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, LTE_eNB_PUSCH** const pusch_vars = gNB->pusch_vars; LTE_eNB_SRS* const srs_vars = gNB->srs_vars; LTE_eNB_PRACH* const prach_vars = &gNB->prach_vars; + uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; int i, UE_id; @@ -118,6 +119,12 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, nr_init_pbch_dmrs(gNB); // Polar encoder init for PBCH nr_polar_init(&fp->pbch_polar_params, 1); + //PDCCH DMRS init + pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**)); + for (int slot=0; slotslots_per_frame; slot++) + pdcch_dmrs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot); + + nr_init_pdcch_dmrs(gNB, cfg->sch_config.physical_cell_id.value); /* lte_gold(fp,gNB->lte_gold_table,fp->Nid_cell); @@ -271,10 +278,12 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) { // NR_DL_FRAME_PARMS* const fp = &gNB->frame_parms; nfapi_config_request_t *cfg = &gNB->gNB_config; + NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; NR_gNB_COMMON* const common_vars = &gNB->common_vars; LTE_eNB_PUSCH** const pusch_vars = gNB->pusch_vars; LTE_eNB_SRS* const srs_vars = gNB->srs_vars; LTE_eNB_PRACH* const prach_vars = &gNB->prach_vars; + uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; int i, UE_id; @@ -287,6 +296,12 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) free_and_zero(common_vars->txdataF); free_and_zero(common_vars->rxdataF); + // PDCCH DMRS sequences + pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**)); + for (int slot=0; slotslots_per_frame; slot++) + free_and_zero(pdcch_dmrs[slot]); + free_and_zero(pdcch_dmrs); + // Channel estimates for SRS for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { for (i=0; i<64; i++) { diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 1fcaaed494..2cbb2fb5af 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -139,7 +139,7 @@ int nr_init_frame_parms(nfapi_config_request_t* config, AssertFatal(1==0,"Invalid numerology index %d", mu); } - + frame_parms->slots_per_frame = 10* frame_parms->slots_per_subframe; frame_parms->symbols_per_slot = ((Ncp == NORMAL)? 14 : 12); // to redefine for different slot formats frame_parms->samples_per_subframe_wCP = frame_parms->ofdm_symbol_size * frame_parms->symbols_per_slot * frame_parms->slots_per_subframe; frame_parms->samples_per_frame_wCP = 10 * frame_parms->samples_per_subframe_wCP; @@ -289,6 +289,7 @@ int nr_init_frame_parms_ue(nfapi_config_request_t* config, frame_parms->samples_per_subframe = 30720 * frame_parms->ttis_per_subframe; frame_parms->first_carrier_offset = 2048-600; + frame_parms->slots_per_frame = 10* frame_parms->slots_per_subframe; frame_parms->symbols_per_slot = ((Ncp == NORMAL)? 14 : 12); // to redefine for different slot formats frame_parms->samples_per_subframe_wCP = frame_parms->ofdm_symbol_size * frame_parms->symbols_per_slot * frame_parms->slots_per_subframe; frame_parms->samples_per_frame_wCP = 10 * frame_parms->samples_per_subframe_wCP; diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 110692bc0a..04e5b003b3 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -24,9 +24,10 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB) { - unsigned int n, x1, x2; - unsigned char Nid, i_ssb, i_ssb2; - unsigned char Lmax, l, n_hf, N_hf; + uint32_t x1, x2; + uint8_t Nid, i_ssb, i_ssb2; + uint8_t Lmax, l, n_hf, N_hf; + uint8_t reset = 1; nfapi_config_request_t *cfg = &gNB->gNB_config; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; @@ -36,32 +37,40 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB) N_hf = (Lmax == 4)? 2:1; for (n_hf = 0; n_hf < N_hf; n_hf++) { - for (l = 0; l < Lmax ; l++) { i_ssb = l & (Lmax-1); i_ssb2 = (i_ssb<<2) + n_hf; - x1 = 1 + (1<<31); x2 = (1<<11) * (i_ssb2 + 1) * ((Nid>>2) + 1) + (1<<6) * (i_ssb2 + 1) + (Nid&3); - x2 = x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31); - // skip first 50 double words (1600 bits) - for (n = 1; n < 50; n++) { - x1 = (x1>>1) ^ (x1>>4); - x1 = x1 ^ (x1<<31) ^ (x1<<28); - x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4); - x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28); - } - - for (n=0; n>1) ^ (x1>>4); - x1 = x1 ^ (x1<<31) ^ (x1<<28); - x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4); - x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28); - gNB->nr_gold_pbch_dmrs[n_hf][l][n] = x1 ^ x2; + for (uint8_t n=0; nnr_gold_pbch_dmrs[n_hf][l][n] = lte_gold_generic(&x1, &x2, reset); + reset = 0; } } } } + +void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid) +{ + + uint32_t n, x1, x2; + uint8_t reset = 1; + NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; + uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; + + for (uint8_t slot=0; fp->slots_per_frame; slot++) { + for (uint8_t symb=0; fp->symbols_per_slot; symb++) { + + x2 = ((1<<17) * (14*slot+symb+1) * ((Nid<<1)+1) + (Nid<<1))%(1<<31); + + for (uint32_t n=0; n>5]&(1<<(m&0x1f)))>>(m&0x1f)))<<1)]; + mod_dmrs[(m<<1)+1] = nr_mod_table[((NR_MOD_TABLE_BPSK_OFFSET + ((gold_pdcch_dmrs[m>>5]&(1<<(m&0x1f)))>>(m&0x1f)))<<1) + 1]; +#ifdef DEBUG_PBCH_DMRS + printf("m %d mod_dmrs %d %d\n", m, mod_dmrs[2*m], mod_dmrs[2*m+1]); +#endif + } + return 0; } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index 6ed05e0e55..f9edb66ef6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -76,9 +76,12 @@ typedef struct { } nr_pdcch_coreset_params_t; typedef struct { + uint8_t first_slot; + uint8_t nb_slots; + uint8_t sfn_mod2; nr_pdcch_ss_params_t ss_params; nr_pdcch_coreset_params_t coreset_params; -} nr_pdcch_params_t; +} nr_pdcch_vars_t; typedef struct { /// Length of DCI in bits @@ -100,10 +103,11 @@ typedef struct { uint8_t nr_get_dci_size(nr_dci_format_e format, nr_rnti_type_e rnti, - NR_BWP_PARMS bwp, + NR_BWP_PARMS* bwp, nfapi_config_request_t* config); uint8_t nr_generate_dci_top(NR_DCI_ALLOC_t dci_alloc, + uint32_t *gold_pdcch_dmrs, int32_t** txdataF, int16_t amp, NR_DL_FRAME_PARMS* frame_parms, diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 42d651d140..7c66342338 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -51,7 +51,7 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, { int k,l; int16_t a; - int16_t mod_dmrs[2 * NR_PBCH_DMRS_LENGTH]; + int16_t mod_dmrs[NR_PBCH_DMRS_LENGTH<<2]; LOG_I(PHY, "PBCH DMRS mapping started at symbol %d shift %d\n", ssb_start_symbol+1, nushift); diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 9728d6b2d0..038814b234 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -290,6 +290,9 @@ typedef struct PHY_VARS_gNB_s { /// PBCH DMRS sequence uint32_t nr_gold_pbch_dmrs[2][64][NR_PBCH_DMRS_LENGTH_DWORD]; + /// PDCCH DMRS sequence + uint32_t **nr_gold_pdcch_dmrs[NR_MAX_PDCCH_DMRS_LENGTH_DWORD]; + /// Indicator set to 0 after first SR uint8_t first_sr[NUMBER_OF_UE_MAX]; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 57b3159310..e55f2391c0 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -57,6 +57,9 @@ #define NR_PBCH_DMRS_LENGTH 144 #define NR_PBCH_DMRS_LENGTH_DWORD 5 // roundup(NR_PBCH_DMRS_LENGTH/32) +#define NR_MAX_PDCCH_DMRS_LENGTH 100 +#define NR_MAX_PDCCH_DMRS_LENGTH_DWORD 5 + #define NR_MAX_NUM_BWP 4 typedef enum { @@ -129,6 +132,8 @@ typedef struct NR_DL_FRAME_PARMS { uint16_t symbols_per_slot; /// Number of slots per subframe uint16_t slots_per_subframe; + /// Number of slots per frame + uint16_t slots_per_frame; /// Number of samples in a subframe uint32_t samples_per_subframe; /// Number of OFDM/SC-FDMA symbols in one subframe (to be modified to account for potential different in UL/DL) diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c index 8831efa54e..e685888232 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_common.c +++ b/openair1/SCHED_NR/phy_procedures_nr_common.c @@ -55,15 +55,15 @@ nr_subframe_t nr_subframe_select(nfapi_config_request_t *cfg,unsigned char subfr } -void nr_fill_pdcch_params(nr_pdcch_params_t *pdcch_params, - nfapi_config_request_t* config, +void nr_get_coreset_and_ss_params(nr_pdcch_vars_t *pdcch_vars, + uint8_t mu, uint8_t ssb_idx) { - nr_pdcch_coreset_params_t *coreset_params = &pdcch_params->coreset_params; - nr_pdcch_ss_params_t *ss_params = &pdcch_params->ss_params; + nr_pdcch_coreset_params_t *coreset_params = &pdcch_vars->coreset_params; + nr_pdcch_ss_params_t *ss_params = &pdcch_vars->ss_params; // the switch case below assumes that only the cases where the SSB and the PDCCH have the same SCS are supported along with type 1 PDCCH/ mux pattern 1 and FR1 - switch(config->subframe_config.numerology_index_mu.value) { + switch(mu) { case NR_MU_0: break; @@ -87,7 +87,25 @@ void nr_fill_pdcch_params(nr_pdcch_params_t *pdcch_params, break; default: - AssertFatal(1==0,"Invalid PDCCH numerology index %d", config->subframe_config.numerology_index_mu.value); + AssertFatal(1==0,"Invalid PDCCH numerology index %d\n", mu); } } + +void nr_get_pdcch_type_0_monitoring_period(nr_pdcch_vars_t *pdcch_vars, + uint8_t mu, + uint8_t nb_slots_per_frame, + uint8_t ssb_idx) +{ + uint8_t O = pdcch_vars->ss_params.param_O, M = pdcch_vars->ss_params.param_M; + + if (pdcch_vars->coreset_params.mux_pattern == nr_pdcch_mux_pattern_type_1) { + pdcch_vars->nb_slots = 2; + pdcch_vars->sfn_mod2 = ((uint8_t)(floor( (O*pow(2, mu) + floor(ssb_idx*M)) / nb_slots_per_frame )) & 1)? 1 : 0; + pdcch_vars->first_slot = (uint8_t)(O*pow(2, mu) + floor(ssb_idx*M)) % nb_slots_per_frame; + } + else { //nr_pdcch_mux_pattern_type_2, nr_pdcch_mux_pattern_type_3 + pdcch_vars->nb_slots = 1; + } + +} diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index e40d8e0a5c..5100e8fe61 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -46,7 +46,7 @@ extern uint8_t nfapi_mode; int return_ssb_type(nfapi_config_request_t *cfg) { int mu = cfg->subframe_config.numerology_index_mu.value; - nr_numerology_index_e ssb_type; + nr_ssb_type_e ssb_type; switch(mu) { @@ -181,5 +181,9 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, nr_common_signal_procedures(gNB,frame, subframe); //if (frame == 9) //write_output("txdataF.m","txdataF",gNB->common_vars.txdataF[aa],fp->samples_per_frame_wCP, 1, 1); + + //temporary DCI generation test + NR_DCI_ALLOC_t dci_alloc; + nr_generate_dci_top(dci_alloc, gNB->nr_gold_pdcch_dmrs[0][0],gNB->common_vars.txdataF, 512, fp, cfg); } } diff --git a/openair1/SCHED_NR/sched_nr.h b/openair1/SCHED_NR/sched_nr.h index 238fd743da..b7d71cfc17 100644 --- a/openair1/SCHED_NR/sched_nr.h +++ b/openair1/SCHED_NR/sched_nr.h @@ -41,8 +41,12 @@ void nr_feptx_ofdm(RU_t *ru); void nr_feptx_ofdm_2thread(RU_t *ru); void nr_feptx0(RU_t *ru,int slot); -void nr_fill_pdcch_params(nr_pdcch_params_t *pdcch_params, - nfapi_config_request_t* config, - uint8_t ssb_idx); +void nr_get_coreset_and_ss_params(nr_pdcch_vars_t *pdcch_params, + uint8_t mu, + uint8_t ssb_idx); +void nr_get_pdcch_type_0_monitoring_period(nr_pdcch_vars_t *pdcch_vars, + uint8_t mu, + uint8_t nb_slots_per_frame, + uint8_t ssb_idx); #endif From c9e28a2be4b69e0070ef5dc7c1abac475e4384f0 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Wed, 27 Jun 2018 15:11:46 +0200 Subject: [PATCH 003/114] pdcch_dmrs malloc fix --- openair1/PHY/INIT/nr_init.c | 9 ++++----- openair1/PHY/NR_REFSIG/nr_gold.c | 2 +- openair1/PHY/defs_gNB.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 27cc8785b8..a0b3b9f699 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -121,8 +121,11 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, nr_polar_init(&fp->pbch_polar_params, 1); //PDCCH DMRS init pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**)); - for (int slot=0; slotslots_per_frame; slot++) + for (int slot=0; slotslots_per_frame; slot++) { pdcch_dmrs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot); + for (int symb=0; symbsymbols_per_slot; symb++) + pdcch_dmrs[slot][symb] = (uint32_t *)malloc16(NR_MAX_PDCCH_DMRS_LENGTH_DWORD); + } nr_init_pdcch_dmrs(gNB, cfg->sch_config.physical_cell_id.value); @@ -278,7 +281,6 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) { // NR_DL_FRAME_PARMS* const fp = &gNB->frame_parms; nfapi_config_request_t *cfg = &gNB->gNB_config; - NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; NR_gNB_COMMON* const common_vars = &gNB->common_vars; LTE_eNB_PUSCH** const pusch_vars = gNB->pusch_vars; LTE_eNB_SRS* const srs_vars = gNB->srs_vars; @@ -297,9 +299,6 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) free_and_zero(common_vars->rxdataF); // PDCCH DMRS sequences - pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**)); - for (int slot=0; slotslots_per_frame; slot++) - free_and_zero(pdcch_dmrs[slot]); free_and_zero(pdcch_dmrs); // Channel estimates for SRS diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 04e5b003b3..fecf98298a 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -56,7 +56,7 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB) void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid) { - uint32_t n, x1, x2; + uint32_t x1, x2; uint8_t reset = 1; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 038814b234..e0d7b165f0 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -291,7 +291,7 @@ typedef struct PHY_VARS_gNB_s { uint32_t nr_gold_pbch_dmrs[2][64][NR_PBCH_DMRS_LENGTH_DWORD]; /// PDCCH DMRS sequence - uint32_t **nr_gold_pdcch_dmrs[NR_MAX_PDCCH_DMRS_LENGTH_DWORD]; + uint32_t ***nr_gold_pdcch_dmrs; /// Indicator set to 0 after first SR uint8_t first_sr[NUMBER_OF_UE_MAX]; From 817ea15e9c428e26441504a5b76707ff0f6dfaee Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Tue, 10 Jul 2018 15:51:43 +0200 Subject: [PATCH 004/114] Merge fixes ctd. --- openair1/PHY/INIT/nr_init.c | 2 +- openair1/PHY/NR_REFSIG/nr_gold.c | 1 + openair1/PHY/NR_TRANSPORT/nr_dci.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_dci.h | 4 ++-- openair1/SCHED_NR/phy_procedures_nr_common.c | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index b6038d2792..b3025dbe00 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -34,7 +34,7 @@ #include "assertions.h" #include -#include "PHY/NR_REFSIG/defs.h" +#include "PHY/NR_REFSIG/nr_refsig.h" #include "PHY/LTE_REFSIG/lte_refsig.h" extern uint32_t from_earfcn(int eutra_bandP,uint32_t dl_earfcn); diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 28d1be3480..cad245ec84 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -28,6 +28,7 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB) unsigned char Lmax, l, n_hf, N_hf; nfapi_nr_config_request_t *cfg = &gNB->gNB_config; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; + uint8_t reset=1; Nid = cfg->sch_config.physical_cell_id.value; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 2ac6c405f0..fdd49a6350 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -40,7 +40,7 @@ extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; uint8_t nr_get_dci_size(nr_dci_format_e format, nr_rnti_type_e rnti, NR_BWP_PARMS* bwp, - nfapi_config_request_t* config) + nfapi_nr_config_request_t* config) { uint8_t size = 0; uint16_t N_RB = bwp->N_RB; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index 630e4781bb..f0c787c72a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -106,13 +106,13 @@ typedef unsigned __int128 uint128_t; uint8_t nr_get_dci_size(nr_dci_format_e format, nr_rnti_type_e rnti, NR_BWP_PARMS* bwp, - nfapi_config_request_t* config); + nfapi_nr_config_request_t* config); uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, uint32_t *gold_pdcch_dmrs, int32_t** txdataF, int16_t amp, NR_DL_FRAME_PARMS* frame_parms, - nfapi_nr_config_request_t* config) + nfapi_nr_config_request_t* config); #endif //__PHY_NR_TRANSPORT_DCI__H diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c index e685888232..206d9ca03a 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_common.c +++ b/openair1/SCHED_NR/phy_procedures_nr_common.c @@ -48,7 +48,7 @@ uint8_t nr_ss_first_symb_idx_type_0_mux1_FR1[8] = {0,0,1,2,1,2,1,2}; -nr_subframe_t nr_subframe_select(nfapi_config_request_t *cfg,unsigned char subframe) +nr_subframe_t nr_subframe_select(nfapi_nr_config_request_t *cfg,unsigned char subframe) { if (cfg->subframe_config.duplex_mode.value == FDD) return(SF_DL); From b47547973f0e9d754266a777e28ee0b8a54bf6f5 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Fri, 13 Jul 2018 15:37:04 +0200 Subject: [PATCH 005/114] DCI size updates --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index fdd49a6350..657d3cf702 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -46,13 +46,13 @@ uint8_t nr_get_dci_size(nr_dci_format_e format, uint16_t N_RB = bwp->N_RB; switch(format) { - +/*Only sizes for 0_0 and 1_0 are correct at the moment*/ case nr_dci_format_0_0: - /// fixed: Format identifier 1, Hop flag 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2 --16 - size += 16; - size += ceil( log2( (N_RB*(N_RB+1))>>2 ) ); // Freq domain assignment -- hopping scenario to be updated - // Time domain assignment - // UL/SUL indicator + /// fixed: Format identifier 1, Hop flag 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2 Time Domain assgnmt 4 --20 + size += 20; + size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>2 ) ); // Freq domain assignment -- hopping scenario to be updated + // UL/SUL indicator assumed to be 0 + // Padding break; case nr_dci_format_0_1: @@ -80,7 +80,7 @@ uint8_t nr_get_dci_size(nr_dci_format_e format, case nr_dci_format_1_0: /// fixed: Format identifier 1, VRB2PRB 1, MCS 5, NDI 1, RV 2, HARQ PID 4, DAI 2, PUCCH TPC 2, PUCCH RInd 3, PDSCH to HARQ TInd 3 --24 size += 24; - size += ceil( log2( (N_RB*(N_RB+1))>>2 ) ); // Freq domain assignment + size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>2 ) ); // Freq domain assignment // Time domain assignment break; From 47710949a0f66b7517ad32512f823b21b7300eaa Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Wed, 18 Jul 2018 17:12:29 +0200 Subject: [PATCH 006/114] Type 0 pdcch coreset and ss params update --- .../nfapi/public_inc/nfapi_nr_interface.h | 1 + openair1/PHY/NR_TRANSPORT/nr_dci.h | 10 +- openair1/PHY/defs_nr_common.h | 7 + openair1/SCHED_NR/phy_procedures_nr_common.c | 126 +++++++++++++----- openair1/SCHED_NR/sched_nr.h | 9 +- 5 files changed, 115 insertions(+), 38 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 2823185c71..19f3e34a77 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -121,6 +121,7 @@ typedef struct { nfapi_uint16_tlv_t ssb_periodicity; nfapi_uint16_tlv_t ss_pbch_block_power; nfapi_uint16_tlv_t n_ssb_crb; + nfapi_uint16_tlv_t rmsi_pdcch_config; } nfapi_nr_sch_config_t; #define NFAPI_NR_SCH_CONFIG_PHYSICAL_CELL_ID_TAG 0x501E diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index f0c787c72a..f65f01a1ff 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -56,10 +56,10 @@ typedef enum { } nr_pdcch_ss_type_e; typedef enum { - nr_pdcch_mux_pattern_type_1=0, - nr_pdcch_mux_pattern_type_2, - nr_pdcch_mux_pattern_type_3 -} nr_pdcch_mux_pattern_type_e; + nr_ssb_and_cset_mux_pattern_type_1=0, + nr_ssb_and_cset_mux_pattern_type_2, + nr_ssb_and_cset_mux_pattern_type_3 +} nr_ssb_and_cset_mux_pattern_type_e; typedef struct { uint8_t param_O; @@ -73,7 +73,7 @@ typedef struct { uint8_t n_rb; uint8_t n_symb; uint8_t rb_offset; - nr_pdcch_mux_pattern_type_e mux_pattern; + nr_ssb_and_cset_mux_pattern_type_e mux_pattern; } nr_pdcch_coreset_params_t; typedef struct { diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index a3abfd8660..f760fe344a 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -70,6 +70,13 @@ typedef enum { NR_MU_4, } nr_numerology_index_e; +typedef enum { + kHz15=0, + kHz30, + kHz60, + kHz120, + kHz240 +} nr_scs_e; typedef enum{ nr_ssb_type_A = 0, diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c index 206d9ca03a..c833485e77 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_common.c +++ b/openair1/SCHED_NR/phy_procedures_nr_common.c @@ -33,17 +33,22 @@ #include "sched_nr.h" -/// LUT for the number of symbols in the coreset indexed by SSB index -uint8_t nr_coreset_nsymb_pdcch_type_0[16] = {2,2,2,2,2,3,3,3,3,3,1,1,1,2,2,2}; -/// LUT for the number of RBs in the coreset indexed by SSB index -uint8_t nr_coreset_rb_offset_pdcch_type_0[16] = {0,1,2,3,4,0,1,2,3,4,12,14,16,12,14,16}; -/// LUT for monitoring occasions param O indexed by SSB index +/// LUT for the number of symbols in the coreset indexed by coreset index (4 MSB rmsi_pdcch_config) +uint8_t nr_coreset_nsymb_pdcch_type_0_b40Mhz[16] = {2,2,2,2,2,3,3,3,3,3,1,1,1,2,2,2}; // below 40Mhz bw +uint8_t nr_coreset_nsymb_pdcch_type_0_a40Mhz[10] = {2,2,3,3,1,1,2,2,3,3}; // above 40Mhz bw +/// LUT for the number of RBs in the coreset indexed by coreset index +uint8_t nr_coreset_rb_offset_pdcch_type_0_b40Mhz[16] = {0,1,2,3,4,0,1,2,3,4,12,14,16,12,14,16}; +uint8_t nr_coreset_rb_offset_pdcch_type_0_a40Mhz[10] = {0,4,0,4,0,28,0,28,0,28}; +/// LUT for monitoring occasions param O indexed by ss index (4 MSB rmsi_pdcch_config) uint8_t nr_ss_param_O_type_0_mux1_FR1[16] = {0,0,2,2,5,5,7,7,0,5,0,0,2,2,5,5}; -/// LUT for number of SS sets per slot indexed by SSB index +uint8_t nr_ss_param_O_type_0_mux1_FR2[14] = {0,0,2.5,2.5,5,5,0,2.5,5,7.5,7.5,7.5,0,5}; +/// LUT for number of SS sets per slot indexed by ss index uint8_t nr_ss_sets_per_slot_type_0_FR1[16] = {1,2,1,2,1,2,1,2,1,1,1,1,1,1,1,1}; -/// LUT for monitoring occasions param M indexed by SSB index +uint8_t nr_ss_sets_per_slot_type_0_FR2[14] = {1,2,1,2,1,2,2,2,2,1,2,2,1,1}; +/// LUT for monitoring occasions param M indexed by ss index uint8_t nr_ss_param_M_type_0_mux1_FR1[16] = {1,0.5,1,0.5,1,0.5,1,0.5,2,2,1,1,1,1,1,1}; -/// LUT for SS first symbol index indexed by SSB index +uint8_t nr_ss_param_M_type_0_mux1_FR2[14] = {1,0.5,1,0.5,1,0.5,0.5,0.5,0.5,1,0.5,0.5,2,2}; +/// LUT for SS first symbol index indexed by ss index uint8_t nr_ss_first_symb_idx_type_0_mux1_FR1[8] = {0,0,1,2,1,2,1,2}; @@ -55,41 +60,102 @@ nr_subframe_t nr_subframe_select(nfapi_nr_config_request_t *cfg,unsigned char su } -void nr_get_coreset_and_ss_params(nr_pdcch_vars_t *pdcch_vars, - uint8_t mu, - uint8_t ssb_idx) +void nr_get_type0_coreset_and_ss_params(nr_pdcch_vars_t *pdcch_vars, + nr_scs_e scs_common, + nr_scs_e pdcch_scs, + nr_frequency_range_e freq_range, + uint8_t rmsi_pdcch_config, + uint16_t N_RB) { nr_pdcch_coreset_params_t *coreset_params = &pdcch_vars->coreset_params; nr_pdcch_ss_params_t *ss_params = &pdcch_vars->ss_params; + uint8_t ss_idx = rmsi_pdcch_config&0xf; + uint8_t cset_idx = (rmsi_pdcch_config>>4)&0xf; - // the switch case below assumes that only the cases where the SSB and the PDCCH have the same SCS are supported along with type 1 PDCCH/ mux pattern 1 and FR1 - switch(mu) { + /// Coreset params + switch(scs_common) { - case NR_MU_0: + case kHz15: break; - case NR_MU_1: - coreset_params->mux_pattern = nr_pdcch_mux_pattern_type_1; - coreset_params->n_rb = (ssb_idx < 10)? 24 : 48; - coreset_params->n_symb = nr_coreset_nsymb_pdcch_type_0[ssb_idx]; - coreset_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0[ssb_idx]; - ss_params->ss_type = nr_pdcch_css_type_1; - ss_params->param_O = nr_ss_param_O_type_0_mux1_FR1[ssb_idx]; - ss_params->nb_ss_sets_per_slot = nr_ss_sets_per_slot_type_0_FR1[ssb_idx]; - ss_params->param_M = nr_ss_param_M_type_0_mux1_FR1[ssb_idx]; - ss_params->first_symbol_idx = (ssb_idx < 8)? ( (ssb_idx&1)? coreset_params->n_symb : 0 ) : nr_ss_first_symb_idx_type_0_mux1_FR1[ssb_idx - 8]; + case kHz30: + + if (N_RB < 106) { // Minimum 40Mhz bandwidth not satisfied + switch(pdcch_scs) { + case kHz15: + break; + + case kHz30: + coreset_params->mux_pattern = nr_ssb_and_cset_mux_pattern_type_1; + coreset_params->n_rb = (cset_idx < 10)? 24 : 48; + coreset_params->n_symb = nr_coreset_nsymb_pdcch_type_0_b40Mhz[cset_idx]; + coreset_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0_b40Mhz[cset_idx]; + break; + + default: + AssertFatal(1==0,"Invalid scs_common/pdcch_scs combination %d/%d \n", scs_common, pdcch_scs); + } + } + + else { + AssertFatal(ss_idx<10 ,"Invalid scs_common/pdcch_scs combination %d/%d \n", scs_common, pdcch_scs); + switch(pdcch_scs) { + case kHz15: + break; + + case kHz30: + coreset_params->mux_pattern = nr_ssb_and_cset_mux_pattern_type_1; + coreset_params->n_rb = (cset_idx < 4)? 24 : 48; + coreset_params->n_symb = nr_coreset_nsymb_pdcch_type_0_b40Mhz[cset_idx]; + coreset_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0_b40Mhz[cset_idx]; + break; + + default: + AssertFatal(1==0,"Invalid scs_common/pdcch_scs combination %d/%d \n", scs_common, pdcch_scs); + } + } + + case kHz60: break; - case NR_MU_2: - break; - - case NR_MU_3: + case kHz120: break; default: - AssertFatal(1==0,"Invalid PDCCH numerology index %d\n", mu); + AssertFatal(1==0,"Invalid common subcarrier spacing %d\n", scs_common); } + + /// Search space params + switch(coreset_params->mux_pattern) { + + case nr_ssb_and_cset_mux_pattern_type_1: + if (freq_range == nr_FR1) { + ss_params->param_O = nr_ss_param_O_type_0_mux1_FR1[ss_idx]; + ss_params->nb_ss_sets_per_slot = nr_ss_sets_per_slot_type_0_FR1[ss_idx]; + ss_params->param_M = nr_ss_param_M_type_0_mux1_FR1[ss_idx]; + ss_params->first_symbol_idx = (ss_idx < 8)? ( (ss_idx&1)? coreset_params->n_symb : 0 ) : nr_ss_first_symb_idx_type_0_mux1_FR1[ss_idx - 8]; + } + + else { + AssertFatal(ss_idx<14 ,"Invalid search space index for multiplexing type 1 and FR2 %d\n", ss_idx); + ss_params->param_O = nr_ss_param_O_type_0_mux1_FR2[ss_idx]; + ss_params->nb_ss_sets_per_slot = nr_ss_sets_per_slot_type_0_FR2[ss_idx]; + ss_params->param_M = nr_ss_param_M_type_0_mux1_FR2[ss_idx]; + ss_params->first_symbol_idx = (ss_idx < 12)? ( (ss_idx&1)? 7 : 0 ) : 0; + } + + break; + + case nr_ssb_and_cset_mux_pattern_type_2: + break; + + case nr_ssb_and_cset_mux_pattern_type_3: + break; + + default: + AssertFatal(1==0, "Invalid SSB and coreset multiplexing pattern %d\n", coreset_params->mux_pattern); + } } void nr_get_pdcch_type_0_monitoring_period(nr_pdcch_vars_t *pdcch_vars, @@ -99,7 +165,7 @@ void nr_get_pdcch_type_0_monitoring_period(nr_pdcch_vars_t *pdcch_vars, { uint8_t O = pdcch_vars->ss_params.param_O, M = pdcch_vars->ss_params.param_M; - if (pdcch_vars->coreset_params.mux_pattern == nr_pdcch_mux_pattern_type_1) { + if (pdcch_vars->coreset_params.mux_pattern == nr_ssb_and_cset_mux_pattern_type_1) { pdcch_vars->nb_slots = 2; pdcch_vars->sfn_mod2 = ((uint8_t)(floor( (O*pow(2, mu) + floor(ssb_idx*M)) / nb_slots_per_frame )) & 1)? 1 : 0; pdcch_vars->first_slot = (uint8_t)(O*pow(2, mu) + floor(ssb_idx*M)) % nb_slots_per_frame; diff --git a/openair1/SCHED_NR/sched_nr.h b/openair1/SCHED_NR/sched_nr.h index bd89c16923..1bbcc6302e 100644 --- a/openair1/SCHED_NR/sched_nr.h +++ b/openair1/SCHED_NR/sched_nr.h @@ -42,9 +42,12 @@ void nr_feptx_ofdm(RU_t *ru); void nr_feptx_ofdm_2thread(RU_t *ru); void nr_feptx0(RU_t *ru,int slot); -void nr_get_coreset_and_ss_params(nr_pdcch_vars_t *pdcch_params, - uint8_t mu, - uint8_t ssb_idx); +void nr_get_type0_coreset_and_ss_params(nr_pdcch_vars_t *pdcch_vars, + nr_scs_e scs_common, + nr_scs_e pdcch_scs, + nr_frequency_range_e freq_range, + uint8_t rmsi_pdcch_config, + uint16_t N_RB); void nr_get_pdcch_type_0_monitoring_period(nr_pdcch_vars_t *pdcch_vars, uint8_t mu, uint8_t nb_slots_per_frame, From 591522ecfd91539613a24f9a98285684e3533048 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Thu, 19 Jul 2018 17:31:36 +0200 Subject: [PATCH 007/114] nfapi changes/payload scrambling --- .../nfapi/public_inc/nfapi_nr_interface.h | 87 ++++++++++--------- openair1/PHY/NR_TRANSPORT/nr_dci.c | 43 +++++++-- openair1/PHY/NR_TRANSPORT/nr_dci.h | 31 ++++--- openair1/SCHED_NR/phy_procedures_nr_common.c | 13 ++- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 3 +- openair1/SCHED_NR/sched_nr.h | 2 +- 6 files changed, 121 insertions(+), 58 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 19f3e34a77..e1bd4191b3 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -3,6 +3,9 @@ #include "nfapi_interface.h" + +#define NFAPI_NR_MAX_NB_CCE_AGGREGATION_LEVELS 5 + // nFAPI enums typedef enum { NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE = 0, @@ -283,7 +286,7 @@ uint8_t beta_offset_indicator; //0 or 2 bits uint8_t dmrs_sequence_initialization; //0 or 1 bit uint8_t ul_sch_indicator; //1 bit -} nfapi_nr_ul_config_dci_ul_pdu_rel15_t; +} nfapi_nr_ul_config_dci_pdu_rel15_t; //#define NFAPI_NR_UL_CONFIG_REQUEST_DCI_UL_PDU_REL15_TAG 0x???? //formats 1_0, 1_1, 2_0, 2_1, 2_2 and 2_3 @@ -340,39 +343,41 @@ uint16_t *pre_emption_indications; //14 bit uint8_t block_number_count; uint8_t *block_numbers; -} nfapi_nr_dl_config_dci_dl_pdu_rel15_t; +} nfapi_nr_dl_config_dci_pdu_rel15_t; //#define NFAPI_NR_DL_CONFIG_REQUEST_DCI_DL_PDU_REL15_TAG 0x???? typedef struct{ - nfapi_uint16_tlv_t controlResourceSetId; ///// L1 parameter 'CORESET-ID' - nfapi_uint16_tlv_t frequencyDomainResources; ///// L1 parameter 'CORESET-freq-dom' + nfapi_uint16_tlv_t coreset_id; ///// L1 parameter 'CORESET-ID' + nfapi_uint16_tlv_t frequency_domain_resources; ///// L1 parameter 'CORESET-freq-dom' nfapi_uint16_tlv_t duration; ///// L1 parameter 'CORESET-time-duration' - nfapi_uint16_tlv_t cce_REG_MappingType; ///// L1 parameter 'CORESET-CCE-REG-mapping-type' - nfapi_uint16_tlv_t reg_BundleSize; ///// L1 parameter 'CORESET-REG-bundle-size' - nfapi_uint16_tlv_t interleaverSize; ///// L1 parameter 'CORESET-interleaver-size' - nfapi_uint16_tlv_t shiftIndex; ///// L1 parameter 'CORESET-shift-index' - nfapi_uint16_tlv_t precoderGranularity; ///// L1 parameter 'CORESET-precoder-granuality' - nfapi_uint16_tlv_t TCI_StateId; ///// L1 parameter 'TCI-StatesPDCCH' - nfapi_uint16_tlv_t tci_PresentInDCI; ///// L1 parameter 'TCI-PresentInDCI' - nfapi_uint16_tlv_t pdcch_DMRS_ScramblingID; ///// L1 parameter 'PDCCH-DMRS-Scrambling-ID' -} nfapi_nr_ControlResourcesSets_t; + nfapi_uint16_tlv_t cce_reg_mapping_ype; ///// L1 parameter 'CORESET-CCE-REG-mapping-type' + nfapi_uint16_tlv_t reg_bundle_size; ///// L1 parameter 'CORESET-REG-bundle-size' + nfapi_uint16_tlv_t interleaver_size; ///// L1 parameter 'CORESET-interleaver-size' + nfapi_uint16_tlv_t shift_index; ///// L1 parameter 'CORESET-shift-index' + nfapi_uint16_tlv_t precoder_granularity; ///// L1 parameter 'CORESET-precoder-granuality' + nfapi_uint16_tlv_t tci_state_id; ///// L1 parameter 'TCI-StatesPDCCH' + nfapi_uint16_tlv_t tci_present_in_dci; ///// L1 parameter 'TCI-PresentInDCI' + nfapi_uint16_tlv_t pdcch_dmrs_scrambling_id; ///// L1 parameter 'PDCCH-DMRS-Scrambling-ID' +} nfapi_nr_coreset_t; typedef struct{ - nfapi_uint16_tlv_t SearchSpaceId; - nfapi_uint16_tlv_t controlResourceSetId; - nfapi_uint16_tlv_t monitoringSlotPeriodicityAndOffset; ///// L1 parameters 'Montoring-periodicity-PDCCH-slot' - nfapi_uint16_tlv_t monitoringSymbolsWithinSlot; ///// L1 parameter 'Montoring-symbols-PDCCH-within-slot' - nfapi_uint16_tlv_t nrofCand_aggLevel1; ///// L1 parameter 'Aggregation-level-1' - nfapi_uint16_tlv_t nrofCand_aggLevel2; ///// L1 parameter 'Aggregation-level-2' - nfapi_uint16_tlv_t nrofCand_aggLevel4; ///// L1 parameter 'Aggregation-level-4' - nfapi_uint16_tlv_t nrofCand_aggLevel8; ///// L1 parameter 'Aggregation-level-8' - nfapi_uint16_tlv_t nrofCand_aggLevel16; ///// L1 parameter 'Aggregation-level-16' + nfapi_uint16_tlv_t search_space_id; + nfapi_uint16_tlv_t coreset_id; + nfapi_uint16_tlv_t monitoring_slot_periodicity_and_offset; ///// L1 parameters 'Montoring-periodicity-PDCCH-slot' + nfapi_uint16_tlv_t monitoring_symbols_within_slot; ///// L1 parameter 'Montoring-symbols-PDCCH-within-slot' + nfapi_uint16_tlv_t number_of_candidates[NFAPI_NR_MAX_NB_CCE_AGGREGATION_LEVELS]; ///// L1 parameter 'Aggregation-level-1/2/4/8/16' nfapi_uint16_tlv_t Com_dci_Format2_0_nrofCand_SFI_And_aggLevel; ///// L1 parameters 'SFI-Num-PDCCH-cand' and 'SFI-Aggregation-Level' nfapi_uint16_tlv_t Com_dci_Format2_3_monitoringPeriodicity; ///// L1 parameter 'SRS-monitoring-periodicity' nfapi_uint16_tlv_t Com_dci_Format2_3_nrofPDCCH_Candidates; ///// L1 parameter 'SRS-Num-PDCCH-cand' nfapi_uint16_tlv_t ue_Specific_dci_Formats; -} nfapi_nr_SearchSpaces_t; +} nfapi_nr_search_space_t; + +typedef struct { + nfapi_tl_t tl; + nfapi_nr_search_space_t search_space; + +} nfapi_nr_dl_config_pdcch_parameters_rel15_t; typedef struct { nfapi_tl_t tl; @@ -385,18 +390,18 @@ typedef struct { typedef struct { nfapi_tl_t tl; - nfapi_nr_SearchSpaces_t sib1searchSpace; - nfapi_nr_ControlResourcesSets_t sib1ControlResourceSets; - nfapi_nr_SearchSpaces_t sibssearchSpace; - nfapi_nr_ControlResourcesSets_t sibsControlResourceSets; - nfapi_nr_SearchSpaces_t ra_SearchSpace; - nfapi_nr_ControlResourcesSets_t ra_ControlResourceSets; + nfapi_nr_search_space_t sib1searchSpace; + nfapi_nr_coreset_t sib1ControlResourceSets; + nfapi_nr_search_space_t sibssearchSpace; + nfapi_nr_coreset_t sibsControlResourceSets; + nfapi_nr_search_space_t ra_SearchSpace; + nfapi_nr_coreset_t ra_ControlResourceSets; }nfapi_nr_dl_config_dlsch_pdu_rel15_t; typedef struct { nfapi_tl_t tl; - nfapi_nr_SearchSpaces_t pagingSearchSpace; - nfapi_nr_ControlResourcesSets_t pagingControlResourceSets; + nfapi_nr_search_space_t pagingSearchSpace; + nfapi_nr_coreset_t pagingControlResourceSets; }nfapi_nr_dl_config_pch_pdu_rel15_t; typedef struct { @@ -411,19 +416,23 @@ typedef struct { }nfapi_nr_dl_config_ndlsch_pdu_rel15_t; + typedef struct { uint8_t pdu_type; uint8_t pdu_size; + union { - nfapi_nr_dl_config_dci_dl_pdu_rel15_t dci_dl_pdu_rel15; - nfapi_nr_ul_config_dci_ul_pdu_rel15_t dci_ul_pdu_rel15; - nfapi_nr_dl_config_bch_pdu_rel15_t bch_pdu_rel15; - nfapi_nr_dl_config_dlsch_pdu_rel15_t dlsch_pdu_rel15; - nfapi_nr_dl_config_pch_pdu_rel15_t pch_pdu_rel15; - nfapi_nr_dl_config_nbch_pdu_rel15_t nbch_pdu_rel15; - nfapi_nr_dl_config_npdcch_pdu_rel15_t npdcch_pdu_rel15; - nfapi_nr_dl_config_ndlsch_pdu_rel15_t ndlsch_pdu_rel15; + nfapi_nr_dl_config_dci_pdu_rel15_t dci_dl_pdu_rel15; + nfapi_nr_ul_config_dci_pdu_rel15_t dci_ul_pdu_rel15; + nfapi_nr_dl_config_bch_pdu_rel15_t bch_pdu_rel15; + nfapi_nr_dl_config_dlsch_pdu_rel15_t dlsch_pdu_rel15; + nfapi_nr_dl_config_pch_pdu_rel15_t pch_pdu_rel15; + nfapi_nr_dl_config_nbch_pdu_rel15_t nbch_pdu_rel15; + nfapi_nr_dl_config_npdcch_pdu_rel15_t npdcch_pdu_rel15; + nfapi_nr_dl_config_ndlsch_pdu_rel15_t ndlsch_pdu_rel15; }; + + nfapi_nr_dl_config_pdcch_parameters_rel15_t pdcch_params_rel15; } nfapi_nr_dl_config_request_pdu_t; typedef struct { diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 657d3cf702..ac745d05bb 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -38,7 +38,7 @@ extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; uint8_t nr_get_dci_size(nr_dci_format_e format, - nr_rnti_type_e rnti, + nr_rnti_type_e rnti_type, NR_BWP_PARMS* bwp, nfapi_nr_config_request_t* config) { @@ -50,7 +50,7 @@ uint8_t nr_get_dci_size(nr_dci_format_e format, case nr_dci_format_0_0: /// fixed: Format identifier 1, Hop flag 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2 Time Domain assgnmt 4 --20 size += 20; - size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>2 ) ); // Freq domain assignment -- hopping scenario to be updated + size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment -- hopping scenario to be updated // UL/SUL indicator assumed to be 0 // Padding break; @@ -80,7 +80,7 @@ uint8_t nr_get_dci_size(nr_dci_format_e format, case nr_dci_format_1_0: /// fixed: Format identifier 1, VRB2PRB 1, MCS 5, NDI 1, RV 2, HARQ PID 4, DAI 2, PUCCH TPC 2, PUCCH RInd 3, PDSCH to HARQ TInd 3 --24 size += 24; - size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>2 ) ); // Freq domain assignment + size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment // Time domain assignment break; @@ -130,12 +130,37 @@ uint8_t nr_get_dci_size(nr_dci_format_e format, return size; } +void nr_pdcch_scrambling(NR_gNB_DCI_ALLOC_t dci_alloc, + nr_pdcch_vars_t pdcch_vars, + nfapi_nr_config_request_t config, + uint32_t* out) { + + uint8_t reset; + uint32_t x1, x2, s=0; + uint32_t Nid = (dci_alloc.ss_type == nr_pdcch_uss_type)? pdcch_vars.dmrs_scrambling_id : config.sch_config.physical_cell_id.value; + uint32_t n_RNTI = (dci_alloc.ss_type == nr_pdcch_uss_type)? dci_alloc.rnti : 0; + uint32_t *in = dci_alloc.dci_pdu; + + reset = 1; + x2 = (n_RNTI<<16) + Nid; + + for (int i=0; i>i)&1) ^ ((s>>i)&1); + } + +} + uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, uint32_t *gold_pdcch_dmrs, int32_t** txdataF, int16_t amp, - NR_DL_FRAME_PARMS* frame_parms, - nfapi_nr_config_request_t* config) + NR_DL_FRAME_PARMS frame_parms, + nfapi_nr_config_request_t config, + nr_pdcch_vars_t pdcch_vars) { uint16_t mod_dmrs[NR_MAX_PDCCH_DMRS_LENGTH<<1]; @@ -152,5 +177,13 @@ uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, #endif } + /// DCI payload processing + // scrambling + uint32_t scrambled_payload[4]; + nr_pdcch_scrambling(dci_alloc, pdcch_vars, config, scrambled_payload); + + // QPSK modulation + + return 0; } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index f65f01a1ff..6ada2948b2 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -61,6 +61,11 @@ typedef enum { nr_ssb_and_cset_mux_pattern_type_3 } nr_ssb_and_cset_mux_pattern_type_e; +typedef enum { + nr_cce_reg_mapping_interleaved=0, + nr_cce_reg_mapping_non_interleaved +} nr_cce_reg_mapping_type_e; + typedef struct { uint8_t param_O; uint8_t param_M; @@ -80,6 +85,8 @@ typedef struct { uint8_t first_slot; uint8_t nb_slots; uint8_t sfn_mod2; + uint32_t dmrs_scrambling_id; + nr_cce_reg_mapping_type_e cr_mapping_type; nr_pdcch_ss_params_t ss_params; nr_pdcch_coreset_params_t coreset_params; } nr_pdcch_vars_t; @@ -89,22 +96,20 @@ typedef struct { uint8_t size; /// Aggregation level uint8_t L; - /// Position of first CCE of the dci - int firstCCE; - /// flag to indicate that this is a RA response - boolean_t ra_flag; - /// rnti + /// rnti type nr_rnti_type_e rnti; /// Format - DCI_format_t format; + nr_dci_format_e format; + /// type + nr_pdcch_ss_type_e ss_type; /// DCI pdu - uint8_t dci_pdu[8]; + uint32_t dci_pdu[4]; } NR_gNB_DCI_ALLOC_t; typedef unsigned __int128 uint128_t; uint8_t nr_get_dci_size(nr_dci_format_e format, - nr_rnti_type_e rnti, + nr_rnti_type_e rnti_type, NR_BWP_PARMS* bwp, nfapi_nr_config_request_t* config); @@ -112,7 +117,13 @@ uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, uint32_t *gold_pdcch_dmrs, int32_t** txdataF, int16_t amp, - NR_DL_FRAME_PARMS* frame_parms, - nfapi_nr_config_request_t* config); + NR_DL_FRAME_PARMS frame_parms, + nfapi_nr_config_request_t config, + nr_pdcch_vars_t pdcch_vars); + +void nr_pdcch_scrambling(NR_gNB_DCI_ALLOC_t dci_alloc, + nr_pdcch_vars_t pdcch_vars, + nfapi_nr_config_request_t config, + uint32_t* out); #endif //__PHY_NR_TRANSPORT_DCI__H diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c index c833485e77..8b22637814 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_common.c +++ b/openair1/SCHED_NR/phy_procedures_nr_common.c @@ -60,7 +60,7 @@ nr_subframe_t nr_subframe_select(nfapi_nr_config_request_t *cfg,unsigned char su } -void nr_get_type0_coreset_and_ss_params(nr_pdcch_vars_t *pdcch_vars, +void nr_get_pdcch_vars_from_mib(nr_pdcch_vars_t *pdcch_vars, nr_scs_e scs_common, nr_scs_e pdcch_scs, nr_frequency_range_e freq_range, @@ -170,8 +170,17 @@ void nr_get_pdcch_type_0_monitoring_period(nr_pdcch_vars_t *pdcch_vars, pdcch_vars->sfn_mod2 = ((uint8_t)(floor( (O*pow(2, mu) + floor(ssb_idx*M)) / nb_slots_per_frame )) & 1)? 1 : 0; pdcch_vars->first_slot = (uint8_t)(O*pow(2, mu) + floor(ssb_idx*M)) % nb_slots_per_frame; } - else { //nr_pdcch_mux_pattern_type_2, nr_pdcch_mux_pattern_type_3 + else { //nr_ssb_and_cset_mux_pattern_type_2, nr_ssb_and_cset_mux_pattern_type_3 pdcch_vars->nb_slots = 1; } } + +void nr_get_pdcch_vars_from_config(nr_pdcch_vars_t* pdcch_vars, + nfapi_nr_coreset_t* coreset, + nfapi_nr_search_space_t* search_space) { + + nr_pdcch_coreset_params_t cset_params = pdcch_vars->coreset_params; + nr_pdcch_ss_params_t ss_params = pdcch_vars->ss_params; + +} diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 69599ce180..2803fdddbf 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -181,6 +181,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, //temporary DCI generation test NR_gNB_DCI_ALLOC_t dci_alloc; - nr_generate_dci_top(dci_alloc, gNB->nr_gold_pdcch_dmrs[0][0],gNB->common_vars.txdataF, 512, fp, cfg); + nr_pdcch_vars_t pdcch_vars; + nr_generate_dci_top(dci_alloc, gNB->nr_gold_pdcch_dmrs[0][0],gNB->common_vars.txdataF, 512, *fp, *cfg, pdcch_vars); } } diff --git a/openair1/SCHED_NR/sched_nr.h b/openair1/SCHED_NR/sched_nr.h index 1bbcc6302e..aaa9dda69e 100644 --- a/openair1/SCHED_NR/sched_nr.h +++ b/openair1/SCHED_NR/sched_nr.h @@ -42,7 +42,7 @@ void nr_feptx_ofdm(RU_t *ru); void nr_feptx_ofdm_2thread(RU_t *ru); void nr_feptx0(RU_t *ru,int slot); -void nr_get_type0_coreset_and_ss_params(nr_pdcch_vars_t *pdcch_vars, +void nr_get_pdcch_vars_from_mib(nr_pdcch_vars_t *pdcch_vars, nr_scs_e scs_common, nr_scs_e pdcch_scs, nr_frequency_range_e freq_range, From b464e1adbabf20980fff3ad7dc252a36d9061913 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Fri, 20 Jul 2018 17:22:45 +0200 Subject: [PATCH 008/114] PDCCH resource mapping DCI payload --- .../nfapi/public_inc/nfapi_nr_interface.h | 4 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 58 ++++++++++++++++--- openair1/PHY/NR_TRANSPORT/nr_dci.h | 8 ++- openair1/PHY/defs_nr_common.h | 7 +++ openair1/SCHED_NR/phy_procedures_nr_common.c | 2 +- 5 files changed, 68 insertions(+), 11 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 e1bd4191b3..b227acd5e4 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -375,8 +375,8 @@ typedef struct{ typedef struct { nfapi_tl_t tl; - nfapi_nr_search_space_t search_space; - + nfapi_nr_coreset_t coreset; + nfapi_nr_search_space_t search_space; } nfapi_nr_dl_config_pdcch_parameters_rel15_t; typedef struct { diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index ac745d05bb..f99a201d18 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -165,25 +165,69 @@ uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, uint16_t mod_dmrs[NR_MAX_PDCCH_DMRS_LENGTH<<1]; uint8_t idx=0; + uint16_t a; + int k,l; + nr_cce_t cce; /// DMRS QPSK modulation - for (int m=0; m>1; m++) { - idx = ((((gold_pdcch_dmrs[(m<<1)>>5])>>((m<<1)&0x1f))&1)<<1) ^ (((gold_pdcch_dmrs[((m<<1)+1)>>5])>>(((m<<1)+1)&0x1f))&1); - mod_dmrs[m<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; - mod_dmrs[(m<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; + for (int i=0; i>1; i++) { + idx = ((((gold_pdcch_dmrs[(i<<1)>>5])>>((i<<1)&0x1f))&1)<<1) ^ (((gold_pdcch_dmrs[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1); + mod_dmrs[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; + mod_dmrs[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; #ifdef DEBUG_PDCCH_DMRS - printf("m %d idx %d gold seq %d b0-b1 %d-%d mod_dmrs %d %d\n", m, idx, gold_pdcch_dmrs[(m<<1)>>5], (((gold_pdcch_dmrs[(m<<1)>>5])>>((m<<1)&0x1f))&1), - (((gold_pdcch_dmrs[((m<<1)+1)>>5])>>(((m<<1)+1)&0x1f))&1), mod_dmrs[(m<<1)], mod_dmrs[(m<<1)+1]); + printf("i %d idx %d gold seq %d b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, gold_pdcch_dmrs[(i<<1)>>5], (((gold_pdcch_dmrs[(i<<1)>>5])>>((i<<1)&0x1f))&1), + (((gold_pdcch_dmrs[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), mod_dmrs[(i<<1)], mod_dmrs[(i<<1)+1]); #endif } /// DCI payload processing + //channel coding + // scrambling uint32_t scrambled_payload[4]; nr_pdcch_scrambling(dci_alloc, pdcch_vars, config, scrambled_payload); // QPSK modulation - + uint32_t mod_dci[NR_MAX_DCI_SIZE>>1]; + for (int i=0; i>1; i++) { + idx = (((scrambled_payload[i<<1]>>(i<<1))&1)<<1) ^ ((scrambled_payload[(i<<1)+1]>>((i<<1)+1))&1); + mod_dci[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; + mod_dci[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; + } + + /// Resource mapping + a = (config.rf_config.tx_antenna_ports.value == 1) ? amp : (amp*ONE_OVER_SQRT2_Q15)>>15; + uint8_t n_rb = pdcch_vars.coreset_params.n_rb; + uint8_t rb_offset = pdcch_vars.coreset_params.n_symb; + uint8_t n_symb = pdcch_vars.coreset_params.rb_offset; + uint8_t first_slot = pdcch_vars.first_slot; + uint8_t first_symb = pdcch_vars.ss_params.first_symbol_idx; + + /*The coreset is initialised + * in frequency: the first subcarrier is obtained by adding the first CRB overlapping the SSB and the rb_offset + * in time: by its first slot and its first symbol*/ + uint8_t cset_start_sc = frame_parms.first_carrier_offset + ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+rb_offset)*NR_NB_SC_PER_RB; + uint8_t cset_start_symb = first_slot*frame_parms.symbols_per_slot + first_symb; + + for (int aa = 0; aa < config.rf_config.tx_antenna_ports.value; aa++) + { + if (cset_start_sc >= frame_parms.ofdm_symbol_size) + cset_start_sc -= frame_parms.ofdm_symbol_size; + + for (int cce_idx=0; cce_idx> 15; + ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dci[(m<<1) + 1]) >> 15; + k++; + if (k >= frame_parms.ofdm_symbol_size) + k -= frame_parms.ofdm_symbol_size; + } + } + + } return 0; } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index 6ada2948b2..ab7cb5023a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -78,15 +78,21 @@ typedef struct { uint8_t n_rb; uint8_t n_symb; uint8_t rb_offset; + nr_cce_reg_mapping_type_e cr_mapping_type; nr_ssb_and_cset_mux_pattern_type_e mux_pattern; } nr_pdcch_coreset_params_t; +typedef struct { + uint8_t start_sc_idx; + uint8_t symb_idx; +} nr_cce_t; + typedef struct { uint8_t first_slot; uint8_t nb_slots; uint8_t sfn_mod2; uint32_t dmrs_scrambling_id; - nr_cce_reg_mapping_type_e cr_mapping_type; + nr_cce_t cce_list[NR_MAX_PDCCH_AGG_LEVEL]; nr_pdcch_ss_params_t ss_params; nr_pdcch_coreset_params_t coreset_params; } nr_pdcch_vars_t; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index f760fe344a..b30ed9e4a3 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -42,6 +42,8 @@ #define MAX_NUM_SUBCARRIER_SPACING 5 +#define NR_NB_SC_PER_RB 12 + #define NR_SYMBOLS_PER_SLOT 14 #define ONE_OVER_SQRT2_Q15 23170 @@ -60,8 +62,13 @@ #define NR_MAX_PDCCH_DMRS_LENGTH 100 #define NR_MAX_PDCCH_DMRS_LENGTH_DWORD 5 +#define NR_MAX_DCI_PAYLOAD_SIZE 64 +#define NR_MAX_DCI_SIZE 200 //random values + #define NR_MAX_NUM_BWP 4 +#define NR_MAX_PDCCH_AGG_LEVEL 16 + typedef enum { NR_MU_0=0, NR_MU_1, diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c index 8b22637814..8d88770acf 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_common.c +++ b/openair1/SCHED_NR/phy_procedures_nr_common.c @@ -39,7 +39,7 @@ uint8_t nr_coreset_nsymb_pdcch_type_0_a40Mhz[10] = {2,2,3,3,1,1,2,2,3,3}; // abo /// LUT for the number of RBs in the coreset indexed by coreset index uint8_t nr_coreset_rb_offset_pdcch_type_0_b40Mhz[16] = {0,1,2,3,4,0,1,2,3,4,12,14,16,12,14,16}; uint8_t nr_coreset_rb_offset_pdcch_type_0_a40Mhz[10] = {0,4,0,4,0,28,0,28,0,28}; -/// LUT for monitoring occasions param O indexed by ss index (4 MSB rmsi_pdcch_config) +/// LUT for monitoring occasions param O indexed by ss index (4 LSB rmsi_pdcch_config) uint8_t nr_ss_param_O_type_0_mux1_FR1[16] = {0,0,2,2,5,5,7,7,0,5,0,0,2,2,5,5}; uint8_t nr_ss_param_O_type_0_mux1_FR2[14] = {0,0,2.5,2.5,5,5,0,2.5,5,7.5,7.5,7.5,0,5}; /// LUT for number of SS sets per slot indexed by ss index From 88b1b593bf2a967c0efb9922474e57159fb2400b Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Mon, 23 Jul 2018 11:40:22 +0200 Subject: [PATCH 009/114] DMRS mapping update for precoder granularity same as reg bundle --- openair1/PHY/NR_REFSIG/nr_gold.c | 4 +-- openair1/PHY/NR_TRANSPORT/nr_dci.c | 46 +++++++++++++++++++++++------- openair1/PHY/NR_TRANSPORT/nr_dci.h | 20 ++++++++++++- openair1/PHY/defs_gNB.h | 1 + openair1/PHY/defs_nr_common.h | 1 + 5 files changed, 58 insertions(+), 14 deletions(-) diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index cad245ec84..cb2738b72a 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -23,7 +23,7 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB) { - unsigned int n, x1, x2; + unsigned int x1, x2; unsigned char Nid, i_ssb, i_ssb2; unsigned char Lmax, l, n_hf, N_hf; nfapi_nr_config_request_t *cfg = &gNB->gNB_config; @@ -63,7 +63,7 @@ void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid) for (uint8_t slot=0; fp->slots_per_frame; slot++) { for (uint8_t symb=0; fp->symbols_per_slot; symb++) { - x2 = ((1<<17) * (14*slot+symb+1) * ((Nid<<1)+1) + (Nid<<1))%(1<<31); + x2 = ((1<<17) * (14*slot+symb+1) * ((Nid<<1)+1) + (Nid<<1))&(((uint32_t)1<<31)-1); for (uint32_t n=0; n= frame_parms.ofdm_symbol_size) cset_start_sc -= frame_parms.ofdm_symbol_size; - for (int cce_idx=0; cce_idx> 15; - ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dci[(m<<1) + 1]) >> 15; - k++; - if (k >= frame_parms.ofdm_symbol_size) - k -= frame_parms.ofdm_symbol_size; + if (pdcch_vars.coreset_params.precoder_granularity == nr_cset_same_as_reg_bundle) { + + dci_idx = 0; + dmrs_idx = 0; + + for (int cce_idx=0; cce_idx> 15; + ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; + k_prime++; + dmrs_idx++; + } + else { // DCI payload + ((int16_t*)txdataF[aa])[(l*frame_parms.ofdm_symbol_size + k)<<1] = (a * mod_dci[dci_idx<<1]) >> 15; + ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dci[(dci_idx<<1) + 1]) >> 15; + dci_idx++; + } + k++; + if (k >= frame_parms.ofdm_symbol_size) + k -= frame_parms.ofdm_symbol_size; + } + } } } + else { //nr_cset_all_contiguous_rbs + } + } return 0; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index ab7cb5023a..2ab116c0a9 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -23,7 +23,7 @@ #define __PHY_NR_TRANSPORT_DCI__H #include "PHY/defs_gNB.h" - +#include "PHY/NR_REFSIG/nr_refsig.h" typedef enum { nr_dci_format_0_0=0, @@ -66,6 +66,16 @@ typedef enum { nr_cce_reg_mapping_non_interleaved } nr_cce_reg_mapping_type_e; +typedef enum { + nr_cset_config_mib_sib1=0, + nr_cset_config_pdcch_config +} nr_coreset_config_type_e; + +typedef enum { + nr_cset_same_as_reg_bundle=0, + nr_cset_all_contiguous_rbs +} nr_coreset_precoder_granularity_type_e; + typedef struct { uint8_t param_O; uint8_t param_M; @@ -80,11 +90,19 @@ typedef struct { uint8_t rb_offset; nr_cce_reg_mapping_type_e cr_mapping_type; nr_ssb_and_cset_mux_pattern_type_e mux_pattern; + nr_coreset_precoder_granularity_type_e precoder_granularity; + nr_coreset_config_type_e config_type; } nr_pdcch_coreset_params_t; typedef struct { + uint8_t reg_idx; uint8_t start_sc_idx; uint8_t symb_idx; +} nr_reg_t; + +typedef struct { + uint8_t cce_idx; + nr_reg_t reg_list[NR_NB_REG_PER_CCE]; } nr_cce_t; typedef struct { diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index c4969ef672..40186d8765 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -37,6 +37,7 @@ #include "CODING/nrPolar_tools/nr_polar_pbch_defs.h" #include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h" + typedef struct { uint8_t pbch_a[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; uint8_t pbch_a_interleaved[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index b30ed9e4a3..1bb4160f42 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -43,6 +43,7 @@ #define MAX_NUM_SUBCARRIER_SPACING 5 #define NR_NB_SC_PER_RB 12 +#define NR_NB_REG_PER_CCE 6 #define NR_SYMBOLS_PER_SLOT 14 From 3ac9bd32b329fac7bbe53e0ef67a85d5747d8310 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Tue, 24 Jul 2018 15:19:31 +0200 Subject: [PATCH 010/114] structures changes/ does not compile --- nfapi/oai_integration/nfapi_vnf.c | 1 - .../nfapi/public_inc/nfapi_nr_interface.h | 106 ++++++++++++------ openair1/PHY/NR_TRANSPORT/nr_dci.c | 26 +++-- openair1/PHY/NR_TRANSPORT/nr_dci.h | 47 -------- openair1/PHY/defs_gNB.h | 20 +++- openair1/PHY/defs_nr_common.h | 29 ++++- openair1/SCHED_NR/fapi_nr_l1.c | 19 ++++ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 3 +- 8 files changed, 149 insertions(+), 102 deletions(-) diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index d3df4edf25..a06527b5fe 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -1169,7 +1169,6 @@ int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_config_request_t *dl_config_req) int retval = nfapi_vnf_p7_dl_config_req(p7_config, dl_config_req); - dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols = 1; dl_config_req->dl_config_request_body.number_dci = 0; dl_config_req->dl_config_request_body.number_pdu = 0; dl_config_req->dl_config_request_body.number_pdsch_rnti = 0; 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 b227acd5e4..f2cabe0f45 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -6,6 +6,17 @@ #define NFAPI_NR_MAX_NB_CCE_AGGREGATION_LEVELS 5 +// Extension to the generic structures for single tlv values +typedef struct { + nfapi_tl_t tl; + int32_t value; +} nfapi_int32_tlv_t; + +typedef struct { + nfapi_tl_t tl; + uint32_t value; +} nfapi_uint32_tlv_t; + // nFAPI enums typedef enum { NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE = 0, @@ -203,7 +214,7 @@ typedef struct { typedef struct { nfapi_p4_p5_message_header_t header; - uint8_t num_tlv; + uint8_t num_tlv; nfapi_nr_subframe_config_t subframe_config; nfapi_nr_rf_config_t rf_config; nfapi_nr_sch_config_t sch_config; @@ -220,21 +231,18 @@ typedef struct { } nfapi_nr_config_request_t; typedef enum { - NFAPI_NR_DL_DCI_FORMAT_1_0 = 0, + NFAPI_NR_DL_DCI_FORMAT_1_0=0, NFAPI_NR_DL_DCI_FORMAT_1_1, NFAPI_NR_DL_DCI_FORMAT_2_0, NFAPI_NR_DL_DCI_FORMAT_2_1, NFAPI_NR_DL_DCI_FORMAT_2_2, - NFAPI_NR_DL_DCI_FORMAT_2_3 -} nfapi_nr_dl_dci_format_e; + NFAPI_NR_DL_DCI_FORMAT_2_3, + NFAPI_NR_UL_DCI_FORMAT_0_0, + NFAPI_NR_UL_DCI_FORMAT_1_0 +} nfapi_nr_dci_format_e; typedef enum { - NFAPI_NR_UL_DCI_FORMAT_0_0 = 0, - NFAPI_NR_UL_DCI_FORMAT_1_0, -} nfapi_nr_ul_dci_format_e; - -typedef enum { - NFAPI_NR_RNTI_new = 0, + NFAPI_NR_RNTI_new=0, NFAPI_NR_RNTI_C, NFAPI_NR_RNTI_RA, NFAPI_NR_RNTI_P, @@ -247,7 +255,17 @@ typedef enum { NFAPI_NR_RNTI_TPC_PUSCH, NFAPI_NR_RNTI_TPC_PUCCH, NFAPI_NR_RNTI_TPC_SRS -} nfapi_nr_rnti_type_e ; +} nfapi_nr_rnti_type_e; + +typedef enum { + NFAPI_NR_USS_FORMAT_0_0_AND_1_0, + NFAPI_NR_USS_FORMAT_0_1_AND_1_1, +} nfapi_nr_uss_dci_formats_e; + +typedef enum { + NFAPI_NR_SEARCH_SPACE_TYPE_COMMON=0, + NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC +} nfapi_nr_search_space_type_e; // P7 Sub Structures //formats 0_0 and 0_1 @@ -348,35 +366,52 @@ uint8_t *block_numbers; typedef struct{ - nfapi_uint16_tlv_t coreset_id; ///// L1 parameter 'CORESET-ID' - nfapi_uint16_tlv_t frequency_domain_resources; ///// L1 parameter 'CORESET-freq-dom' - nfapi_uint16_tlv_t duration; ///// L1 parameter 'CORESET-time-duration' - nfapi_uint16_tlv_t cce_reg_mapping_ype; ///// L1 parameter 'CORESET-CCE-REG-mapping-type' - nfapi_uint16_tlv_t reg_bundle_size; ///// L1 parameter 'CORESET-REG-bundle-size' - nfapi_uint16_tlv_t interleaver_size; ///// L1 parameter 'CORESET-interleaver-size' - nfapi_uint16_tlv_t shift_index; ///// L1 parameter 'CORESET-shift-index' - nfapi_uint16_tlv_t precoder_granularity; ///// L1 parameter 'CORESET-precoder-granuality' - nfapi_uint16_tlv_t tci_state_id; ///// L1 parameter 'TCI-StatesPDCCH' - nfapi_uint16_tlv_t tci_present_in_dci; ///// L1 parameter 'TCI-PresentInDCI' - nfapi_uint16_tlv_t pdcch_dmrs_scrambling_id; ///// L1 parameter 'PDCCH-DMRS-Scrambling-ID' + nfapi_uint16_tlv_t coreset_id; + nfapi_uint16_tlv_t frequency_domain_resources; + nfapi_uint16_tlv_t duration; + nfapi_uint16_tlv_t cce_reg_mapping_type; + nfapi_uint16_tlv_t reg_bundle_size; + nfapi_uint16_tlv_t interleaver_size; + nfapi_uint16_tlv_t shift_index; + nfapi_uint16_tlv_t precoder_granularity; + nfapi_uint16_tlv_t tci_state_id; + nfapi_uint16_tlv_t tci_present_in_dci; + nfapi_uint16_tlv_t pdcch_dmrs_scrambling_id; } nfapi_nr_coreset_t; typedef struct{ - nfapi_uint16_tlv_t search_space_id; - nfapi_uint16_tlv_t coreset_id; - nfapi_uint16_tlv_t monitoring_slot_periodicity_and_offset; ///// L1 parameters 'Montoring-periodicity-PDCCH-slot' - nfapi_uint16_tlv_t monitoring_symbols_within_slot; ///// L1 parameter 'Montoring-symbols-PDCCH-within-slot' - nfapi_uint16_tlv_t number_of_candidates[NFAPI_NR_MAX_NB_CCE_AGGREGATION_LEVELS]; ///// L1 parameter 'Aggregation-level-1/2/4/8/16' - nfapi_uint16_tlv_t Com_dci_Format2_0_nrofCand_SFI_And_aggLevel; ///// L1 parameters 'SFI-Num-PDCCH-cand' and 'SFI-Aggregation-Level' - nfapi_uint16_tlv_t Com_dci_Format2_3_monitoringPeriodicity; ///// L1 parameter 'SRS-monitoring-periodicity' - nfapi_uint16_tlv_t Com_dci_Format2_3_nrofPDCCH_Candidates; ///// L1 parameter 'SRS-Num-PDCCH-cand' - nfapi_uint16_tlv_t ue_Specific_dci_Formats; + nfapi_uint8_tlv_t search_space_id; + nfapi_uint8_tlv_t coreset_id; + nfapi_uint8_tlv_t search_space_type; + nfapi_uint8_tlv_t duration; + nfapi_uint8_tlv_t css_formats_0_0_and_1_0; + nfapi_uint8_tlv_t css_format_2_0; + nfapi_uint8_tlv_t css_format_2_1; + nfapi_uint8_tlv_t css_format_2_2; + nfapi_uint8_tlv_t css_format_2_3; + nfapi_uint8_tlv_t uss_dci_formats; + nfapi_uint8_tlv_t srs_monitoring_periodicity; + nfapi_uint8_tlv_t slot_monitoring_periodicity; + nfapi_uint8_tlv_t slot_monitoring_offset; + nfapi_uint16_tlv_t monitoring_symbols_in_slot; + nfapi_uint16_tlv_t number_of_candidates[NFAPI_NR_MAX_NB_CCE_AGGREGATION_LEVELS]; } nfapi_nr_search_space_t; typedef struct { nfapi_tl_t tl; - nfapi_nr_coreset_t coreset; - nfapi_nr_search_space_t search_space; + uint8_t n_rb; + uint8_t n_symb; + uint8_t rb_offset; + uint8_t cr_mapping_type; + uint8_t mux_pattern; + uint8_t precoder_granularity; + uint8_t config_type; + uint8_t first_slot; + uint8_t first_symbol; + uint8_t nb_ss_sets_per_slot; + uint8_t sfn_mod2; + uint8_t search_space_type; + nfapi_bf_vector_t bf_vector; } nfapi_nr_dl_config_pdcch_parameters_rel15_t; typedef struct { @@ -384,7 +419,7 @@ typedef struct { uint16_t length; uint16_t pdu_index; uint16_t transmission_power; -}nfapi_nr_dl_config_bch_pdu_rel15_t; +} nfapi_nr_dl_config_bch_pdu_rel15_t; #define NFAPI_NR_DL_CONFIG_REQUEST_BCH_PDU_REL15_TAG 0x5025 @@ -437,9 +472,8 @@ typedef struct { typedef struct { nfapi_tl_t tl; - uint8_t number_pdcch_ofdm_symbols; uint8_t number_dci; - uint16_t number_pdu; + uint8_t number_pdu; uint8_t number_pdsch_rnti; nfapi_nr_dl_config_request_pdu_t *dl_config_pdu_list; } nfapi_nr_dl_config_request_body_t; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 64003dfcf6..e3a85ee820 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -169,7 +169,18 @@ uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, int k,l,k_prime,dci_idx, dmrs_idx; nr_cce_t cce; + uint8_t n_rb = pdcch_vars.coreset_params.n_rb; + uint8_t rb_offset = pdcch_vars.coreset_params.n_symb; + uint8_t n_symb = pdcch_vars.coreset_params.rb_offset; + uint8_t first_slot = pdcch_vars.first_slot; + uint8_t first_symb = pdcch_vars.ss_params.first_symbol_idx; + /// DMRS QPSK modulation + /*There is a need to shift from which index the pregenerated DMRS sequence is used + * see 38211 r15.2.0 section 7.4.1.3.2: assumption is the reference point for k refers to the DMRS sequence*/ + if (pdcch_vars.coreset_params.config_type == nr_cset_config_pdcch_config) + gold_pdcch_dmrs += ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+rb_offset)*3/32; + for (int i=0; i>1; i++) { idx = ((((gold_pdcch_dmrs[(i<<1)>>5])>>((i<<1)&0x1f))&1)<<1) ^ (((gold_pdcch_dmrs[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1); mod_dmrs[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; @@ -197,17 +208,14 @@ uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, /// Resource mapping a = (config.rf_config.tx_antenna_ports.value == 1) ? amp : (amp*ONE_OVER_SQRT2_Q15)>>15; - uint8_t n_rb = pdcch_vars.coreset_params.n_rb; - uint8_t rb_offset = pdcch_vars.coreset_params.n_symb; - uint8_t n_symb = pdcch_vars.coreset_params.rb_offset; - uint8_t first_slot = pdcch_vars.first_slot; - uint8_t first_symb = pdcch_vars.ss_params.first_symbol_idx; /*The coreset is initialised * in frequency: the first subcarrier is obtained by adding the first CRB overlapping the SSB and the rb_offset * in time: by its first slot and its first symbol*/ uint8_t cset_start_sc = frame_parms.first_carrier_offset + ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+rb_offset)*NR_NB_SC_PER_RB; uint8_t cset_start_symb = first_slot*frame_parms.symbols_per_slot + first_symb; + dci_idx = 0; + dmrs_idx = 0; for (int aa = 0; aa < config.rf_config.tx_antenna_ports.value; aa++) { @@ -216,16 +224,10 @@ uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, if (pdcch_vars.coreset_params.precoder_granularity == nr_cset_same_as_reg_bundle) { - dci_idx = 0; - dmrs_idx = 0; - for (int cce_idx=0; cce_idxpdcch_vars[idx]; + nfapi_nr_dl_config_dci_dl_pdu *pdu = &dl_config_pdu->dci_dl_pdu; + + LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populating pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",frame,subframe, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); + + // copy dci configuration into gNB structure + nr_fill_dci_and_dlsch(eNB,frame,subframe,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],pdu); + + LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populated pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",proc->frame_tx,proc->subframe_tx, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); +} + + void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ PHY_VARS_gNB *gNB; gNB_rxtx_proc_t *proc; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index a409bcdbc2..431a0eb855 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -81,7 +81,6 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, if (nfapi_mode==0 || nfapi_mode == 1) { // monolithic or PNF - DL_req[CC_idP].dl_config_request_body.number_pdcch_ofdm_symbols = 1; DL_req[CC_idP].dl_config_request_body.number_dci = 0; DL_req[CC_idP].dl_config_request_body.number_pdu = 0; DL_req[CC_idP].dl_config_request_body.number_pdsch_rnti = 0; @@ -456,4 +455,4 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, */ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT); -} \ No newline at end of file +} From fa03cacef76c6a9dd390add995f2529c5dcdaefd Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Tue, 24 Jul 2018 17:26:59 +0200 Subject: [PATCH 011/114] Compiling version --- .../nfapi/public_inc/nfapi_nr_interface.h | 2 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 24 +++++++++---------- openair1/PHY/NR_TRANSPORT/nr_dci.h | 4 ++-- openair1/PHY/defs_gNB.h | 6 ++++- openair1/SCHED_NR/fapi_nr_l1.c | 4 ++-- targets/RT/USER/nr-gnb.c | 8 ++----- 6 files changed, 24 insertions(+), 24 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 f2cabe0f45..181e16444c 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -238,7 +238,7 @@ typedef enum { NFAPI_NR_DL_DCI_FORMAT_2_2, NFAPI_NR_DL_DCI_FORMAT_2_3, NFAPI_NR_UL_DCI_FORMAT_0_0, - NFAPI_NR_UL_DCI_FORMAT_1_0 + NFAPI_NR_UL_DCI_FORMAT_0_1 } nfapi_nr_dci_format_e; typedef enum { diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index e3a85ee820..e78b432b72 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -37,8 +37,8 @@ extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; -uint8_t nr_get_dci_size(nr_dci_format_e format, - nr_rnti_type_e rnti_type, +uint8_t nr_get_dci_size(nfapi_nr_dci_format_e format, + nfapi_nr_rnti_type_e rnti_type, NR_BWP_PARMS* bwp, nfapi_nr_config_request_t* config) { @@ -47,7 +47,7 @@ uint8_t nr_get_dci_size(nr_dci_format_e format, switch(format) { /*Only sizes for 0_0 and 1_0 are correct at the moment*/ - case nr_dci_format_0_0: + case NFAPI_NR_UL_DCI_FORMAT_0_0: /// fixed: Format identifier 1, Hop flag 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2 Time Domain assgnmt 4 --20 size += 20; size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment -- hopping scenario to be updated @@ -55,7 +55,7 @@ uint8_t nr_get_dci_size(nr_dci_format_e format, // Padding break; - case nr_dci_format_0_1: + case NFAPI_NR_UL_DCI_FORMAT_0_1: /// fixed: Format identifier 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2, SRS request 2 --17 size += 17; // Carrier indicator @@ -77,14 +77,14 @@ uint8_t nr_get_dci_size(nr_dci_format_e format, // DMRS sequence init break; - case nr_dci_format_1_0: + case NFAPI_NR_DL_DCI_FORMAT_1_0: /// fixed: Format identifier 1, VRB2PRB 1, MCS 5, NDI 1, RV 2, HARQ PID 4, DAI 2, PUCCH TPC 2, PUCCH RInd 3, PDSCH to HARQ TInd 3 --24 size += 24; size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment // Time domain assignment break; - case nr_dci_format_1_1: + case NFAPI_NR_DL_DCI_FORMAT_1_1: // Carrier indicator size += 1; // Format identifier // BWP Indicator @@ -111,16 +111,16 @@ uint8_t nr_get_dci_size(nr_dci_format_e format, break; - case nr_dci_format_2_0: + case NFAPI_NR_DL_DCI_FORMAT_2_0: break; - case nr_dci_format_2_1: + case NFAPI_NR_DL_DCI_FORMAT_2_1: break; - case nr_dci_format_2_2: + case NFAPI_NR_DL_DCI_FORMAT_2_2: break; - case nr_dci_format_2_3: + case NFAPI_NR_DL_DCI_FORMAT_2_3: break; default: @@ -137,8 +137,8 @@ void nr_pdcch_scrambling(NR_gNB_DCI_ALLOC_t dci_alloc, uint8_t reset; uint32_t x1, x2, s=0; - uint32_t Nid = (dci_alloc.ss_type == nr_pdcch_uss_type)? pdcch_vars.dmrs_scrambling_id : config.sch_config.physical_cell_id.value; - uint32_t n_RNTI = (dci_alloc.ss_type == nr_pdcch_uss_type)? dci_alloc.rnti : 0; + uint32_t Nid = (dci_alloc.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_vars.dmrs_scrambling_id : config.sch_config.physical_cell_id.value; + uint32_t n_RNTI = (dci_alloc.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? dci_alloc.rnti : 0; uint32_t *in = dci_alloc.dci_pdu; reset = 1; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index 461810a836..266a15260e 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -85,8 +85,8 @@ typedef struct { typedef unsigned __int128 uint128_t; -uint8_t nr_get_dci_size(nr_dci_format_e format, - nr_rnti_type_e rnti_type, +uint8_t nr_get_dci_size(nfapi_nr_dci_format_e format, + nfapi_nr_rnti_type_e rnti_type, NR_BWP_PARMS* bwp, nfapi_nr_config_request_t* config); diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index c8bf4f250e..9fe689c85f 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -50,8 +50,12 @@ typedef struct { uint8_t size; /// Aggregation level uint8_t L; + /// rnti + uint16_t rnti; /// rnti type - nfapi_nr_rnti_type_e rnti; + nfapi_nr_rnti_type_e rnti_type; + /// search space type + nfapi_nr_search_space_type_e search_space_type; /// Format nfapi_nr_dci_format_e format; /// DCI pdu diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index e4d53b0ef3..2ae723e9e4 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -61,12 +61,12 @@ void handle_nfapi_nr_dci_dl_pdu(PHY_VARS_gNB *gNB, { int idx = subframe&1; NR_gNB_PDCCH *pdcch_vars = &gNB->pdcch_vars[idx]; - nfapi_nr_dl_config_dci_dl_pdu *pdu = &dl_config_pdu->dci_dl_pdu; + nfapi_nr_dl_config_dci_pdu_rel15_t *pdu = &dl_config_pdu->dci_dl_pdu_rel15; LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populating pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",frame,subframe, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); // copy dci configuration into gNB structure - nr_fill_dci_and_dlsch(eNB,frame,subframe,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],pdu); + //nr_fill_dci_and_dlsch(eNB,frame,subframe,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],pdu); LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populated pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",proc->frame_tx,proc->subframe_tx, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); } diff --git a/targets/RT/USER/nr-gnb.c b/targets/RT/USER/nr-gnb.c index d750d0ee4f..09b95502c1 100644 --- a/targets/RT/USER/nr-gnb.c +++ b/targets/RT/USER/nr-gnb.c @@ -181,21 +181,17 @@ static inline int rxtx(PHY_VARS_gNB *gNB,gNB_rxtx_proc_t *proc, char *thread_nam gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles || gNB->UL_INFO.cqi_ind.number_of_cqis ) { - LOG_D(PHY, "UL_info[rx_ind:%05d:%d harqs:%05d:%d crcs:%05d:%d preambles:%05d:%d cqis:%d] RX:%04d%d TX:%04d%d num_pdcch_symbols:%d\n", + LOG_D(PHY, "UL_info[rx_ind:%05d:%d harqs:%05d:%d crcs:%05d:%d preambles:%05d:%d cqis:%d] RX:%04d%d TX:%04d%d \n", NFAPI_SFNSF2DEC(gNB->UL_INFO.rx_ind.sfn_sf), gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(gNB->UL_INFO.harq_ind.sfn_sf), gNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs, NFAPI_SFNSF2DEC(gNB->UL_INFO.crc_ind.sfn_sf), gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(gNB->UL_INFO.rach_ind.sfn_sf), gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles, gNB->UL_INFO.cqi_ind.number_of_cqis, proc->frame_rx, proc->subframe_rx, - proc->frame_tx, proc->subframe_tx, gNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols); + proc->frame_tx, proc->subframe_tx); } } - if (nfapi_mode == 1 && gNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols == 0) { - LOG_E(PHY, "gNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols == 0"); - return 0; - } /// NR disabling // **************************************** From 45db11de944cd414ff6b48211d339bfabbf129c4 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Wed, 25 Jul 2018 14:19:33 +0200 Subject: [PATCH 012/114] Interface adaptations/ gNB Tx procedure update --- .../nfapi/public_inc/nfapi_nr_interface.h | 31 ++++++++----- openair1/PHY/NR_TRANSPORT/nr_dci.c | 45 +++++++++---------- openair1/PHY/NR_TRANSPORT/nr_dci.h | 23 +++------- openair1/PHY/defs_gNB.h | 6 ++- openair1/PHY/defs_nr_common.h | 11 +++++ openair1/SCHED_NR/fapi_nr_l1.c | 11 ++++- openair1/SCHED_NR/fapi_nr_l1.h | 6 ++- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 19 +++++--- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 7 +++ 9 files changed, 100 insertions(+), 59 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 181e16444c..6c125b7555 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -17,6 +17,16 @@ typedef struct { uint32_t value; } nfapi_uint32_tlv_t; +typedef struct { + nfapi_tl_t tl; + int64_t value; +} nfapi_int64_tlv_t; + +typedef struct { + nfapi_tl_t tl; + uint64_t value; +} nfapi_uint64_tlv_t; + // nFAPI enums typedef enum { NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE = 0, @@ -366,16 +376,16 @@ uint8_t *block_numbers; typedef struct{ - nfapi_uint16_tlv_t coreset_id; - nfapi_uint16_tlv_t frequency_domain_resources; - nfapi_uint16_tlv_t duration; - nfapi_uint16_tlv_t cce_reg_mapping_type; - nfapi_uint16_tlv_t reg_bundle_size; - nfapi_uint16_tlv_t interleaver_size; - nfapi_uint16_tlv_t shift_index; - nfapi_uint16_tlv_t precoder_granularity; - nfapi_uint16_tlv_t tci_state_id; - nfapi_uint16_tlv_t tci_present_in_dci; + nfapi_uint8_tlv_t coreset_id; + nfapi_uint64_tlv_t frequency_domain_resources; + nfapi_uint8_tlv_t duration; + nfapi_uint8_tlv_t cce_reg_mapping_type; + nfapi_uint8_tlv_t reg_bundle_size; + nfapi_uint8_tlv_t interleaver_size; + nfapi_uint8_tlv_t shift_index; + nfapi_uint8_tlv_t precoder_granularity; + nfapi_uint8_tlv_t tci_state_id; + nfapi_uint8_tlv_t tci_present_in_dci; nfapi_uint16_tlv_t pdcch_dmrs_scrambling_id; } nfapi_nr_coreset_t; @@ -411,6 +421,7 @@ typedef struct { uint8_t nb_ss_sets_per_slot; uint8_t sfn_mod2; uint8_t search_space_type; + uint16_t scrambling_id; nfapi_bf_vector_t bf_vector; } nfapi_nr_dl_config_pdcch_parameters_rel15_t; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index e78b432b72..899be6dde4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -20,7 +20,7 @@ */ /*! \file PHY/NR_TRANSPORT/nr_dci.c -* \brief Implements DCI encoding/decoding and PDCCH TX/RX procedures (38.212/38.213/38.214). V15.1 2018-06. +* \brief Implements DCI encoding/decoding and PDCCH TX/RX procedures (38.212/38.213/38.214). V15.2.0 2018-06. * \author Guy De Souza * \date 2018 * \version 0.1 @@ -130,21 +130,19 @@ uint8_t nr_get_dci_size(nfapi_nr_dci_format_e format, return size; } -void nr_pdcch_scrambling(NR_gNB_DCI_ALLOC_t dci_alloc, - nr_pdcch_vars_t pdcch_vars, - nfapi_nr_config_request_t config, +void nr_pdcch_scrambling(uint32_t *in, + uint8_t size, + uint32_t Nid, + uint32_t n_RNTI, uint32_t* out) { uint8_t reset; uint32_t x1, x2, s=0; - uint32_t Nid = (dci_alloc.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_vars.dmrs_scrambling_id : config.sch_config.physical_cell_id.value; - uint32_t n_RNTI = (dci_alloc.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? dci_alloc.rnti : 0; - uint32_t *in = dci_alloc.dci_pdu; reset = 1; x2 = (n_RNTI<<16) + Nid; - for (int i=0; i>1; i++) { idx = ((((gold_pdcch_dmrs[(i<<1)>>5])>>((i<<1)&0x1f))&1)<<1) ^ (((gold_pdcch_dmrs[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1); @@ -195,8 +190,10 @@ uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, //channel coding // scrambling - uint32_t scrambled_payload[4]; - nr_pdcch_scrambling(dci_alloc, pdcch_vars, config, scrambled_payload); + uint32_t scrambled_payload[4]; + uint32_t Nid = (dci_alloc.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value; + uint32_t n_RNTI = (dci_alloc.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? dci_alloc.rnti : 0; + nr_pdcch_scrambling(dci_alloc.dci_pdu, dci_alloc.size, Nid, n_RNTI, scrambled_payload); // QPSK modulation uint32_t mod_dci[NR_MAX_DCI_SIZE>>1]; @@ -212,8 +209,8 @@ uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, /*The coreset is initialised * in frequency: the first subcarrier is obtained by adding the first CRB overlapping the SSB and the rb_offset * in time: by its first slot and its first symbol*/ - uint8_t cset_start_sc = frame_parms.first_carrier_offset + ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+rb_offset)*NR_NB_SC_PER_RB; - uint8_t cset_start_symb = first_slot*frame_parms.symbols_per_slot + first_symb; + uint8_t cset_start_sc = frame_parms.first_carrier_offset + ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+pdcch_params.rb_offset)*NR_NB_SC_PER_RB; + uint8_t cset_start_symb = pdcch_params.first_slot*frame_parms.symbols_per_slot + pdcch_params.first_symbol; dci_idx = 0; dmrs_idx = 0; @@ -222,10 +219,10 @@ uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc, if (cset_start_sc >= frame_parms.ofdm_symbol_size) cset_start_sc -= frame_parms.ofdm_symbol_size; - if (pdcch_vars.coreset_params.precoder_granularity == nr_cset_same_as_reg_bundle) { + if (pdcch_params.precoder_granularity == nr_cset_same_as_reg_bundle) { for (int cce_idx=0; cce_idxpdcch_vars[idx]; + NR_gNB_PDCCH *pdcch_vars = &gNB->pdcch_vars; nfapi_nr_dl_config_dci_pdu_rel15_t *pdu = &dl_config_pdu->dci_dl_pdu_rel15; LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populating pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",frame,subframe, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); @@ -121,6 +121,15 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ dl_config_pdu, TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->bch_pdu_rel15.pdu_index].segments[0].segment_data); break; + + case NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE: + handle_nfapi_nr_dci_dl_pdu(gNB, + frame, subframe, + proc, + dl_config_pdu); + gNB->pdcch_vars.num_dci++; + do_oai=1; + break; } } diff --git a/openair1/SCHED_NR/fapi_nr_l1.h b/openair1/SCHED_NR/fapi_nr_l1.h index a1c068c606..dfc93be9f3 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.h +++ b/openair1/SCHED_NR/fapi_nr_l1.h @@ -38,4 +38,8 @@ #include "SCHED_NR/sched_nr.h" #include "nfapi_nr_interface.h" -void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO); \ No newline at end of file +void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO); +void handle_nfapi_nr_dci_dl_pdu(PHY_VARS_gNB *gNB, + int frame, int subframe, + gNB_rxtx_proc_t *proc, + nfapi_nr_dl_config_request_pdu_t *dl_config_pdu); diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 2803fdddbf..689aab801f 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -157,6 +157,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, int aa; int frame=proc->frame_tx; int subframe=proc->subframe_tx; + uint8_t num_dci=0; NR_DL_FRAME_PARMS *fp=&gNB->frame_parms; nfapi_nr_config_request_t *cfg = &gNB->gNB_config; @@ -178,10 +179,18 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, nr_common_signal_procedures(gNB,frame, subframe); //if (frame == 9) //write_output("txdataF.m","txdataF",gNB->common_vars.txdataF[aa],fp->samples_per_frame_wCP, 1, 1); - - //temporary DCI generation test - NR_gNB_DCI_ALLOC_t dci_alloc; - nr_pdcch_vars_t pdcch_vars; - nr_generate_dci_top(dci_alloc, gNB->nr_gold_pdcch_dmrs[0][0],gNB->common_vars.txdataF, 512, *fp, *cfg, pdcch_vars); } + + num_dci = gNB->pdcch_vars.num_dci; + if (num_dci) { + LOG_I(PHY, "[gNB %d] Frame %d subframe %d \ + Calling nr_generate_dci_top (number of DCI %d)\n", gNB->Mod_id, frame, subframe, num_dci); + + if (nfapi_mode == 0 || nfapi_mode == 1) + nr_generate_dci_top(gNB->pdcch_vars, + gNB->nr_gold_pdcch_dmrs[0][0], + gNB->common_vars.txdataF, + AMP, *fp, *cfg); + } + } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 431a0eb855..a62c847225 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -416,6 +416,13 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, if((subframeP == 0) && (frameP & 7) == 0){ schedule_nr_mib(module_idP, frameP, subframeP); } + + /* + * Temporary DCI scheduling for PDCCH testing in the absence of phy-test mode and pending proper scheduling + * currently schedules PDCCH type 1 for RA-RNTI*/ + + + /* if (phy_test == 0){ // This schedules SI for legacy LTE and eMTC starting in subframeP From c7bb34aace5da4aec9b846da6a7cabc3f06c26d2 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Thu, 26 Jul 2018 13:56:04 +0200 Subject: [PATCH 013/114] changes for dci/does not compile --- .../nfapi/public_inc/nfapi_nr_interface.h | 11 +- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 7 +- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 98 ++++ openair1/PHY/defs_NR.h | 488 ------------------ openair1/PHY/defs_eNB.h | 3 +- openair1/PHY/defs_gNB.h | 5 +- openair1/SCHED_NR/fapi_nr_l1.c | 4 +- openair2/RRC/NR/nr_rrc_defs.h | 2 +- 8 files changed, 118 insertions(+), 500 deletions(-) delete mode 100644 openair1/PHY/defs_NR.h 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 6c125b7555..9e966b0b73 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -224,7 +224,7 @@ typedef struct { typedef struct { nfapi_p4_p5_message_header_t header; - uint8_t num_tlv; + uint8_t num_tlv; nfapi_nr_subframe_config_t subframe_config; nfapi_nr_rf_config_t rf_config; nfapi_nr_sch_config_t sch_config; @@ -241,7 +241,7 @@ typedef struct { } nfapi_nr_config_request_t; typedef enum { - NFAPI_NR_DL_DCI_FORMAT_1_0=0, + NFAPI_NR_DL_DCI_FORMAT_1_0 = 0, NFAPI_NR_DL_DCI_FORMAT_1_1, NFAPI_NR_DL_DCI_FORMAT_2_0, NFAPI_NR_DL_DCI_FORMAT_2_1, @@ -252,7 +252,7 @@ typedef enum { } nfapi_nr_dci_format_e; typedef enum { - NFAPI_NR_RNTI_new=0, + NFAPI_NR_RNTI_new = 0, NFAPI_NR_RNTI_C, NFAPI_NR_RNTI_RA, NFAPI_NR_RNTI_P, @@ -286,6 +286,7 @@ nfapi_tl_t tl; uint8_t cce_idx; uint8_t aggregation_level; uint16_t rnti; +uint8_t rnti_type; uint8_t dci_format; //1 bit uint16_t frequency_domain_resource_assignment; //up to 9 bits @@ -325,6 +326,7 @@ nfapi_tl_t tl; uint8_t cce_idx; uint8_t aggregation_level; uint16_t rnti; +uint8_t rnti_type; uint8_t dci_format; //1 bit uint16_t frequency_domain_resource_assignment; //up to 9 bits @@ -374,6 +376,9 @@ uint8_t *block_numbers; } nfapi_nr_dl_config_dci_pdu_rel15_t; //#define NFAPI_NR_DL_CONFIG_REQUEST_DCI_DL_PDU_REL15_TAG 0x???? +typedef struct { + nfapi_nr_dl_config_dci_pdu_rel15_t dci_dl_pdu_rel15; +} nfapi_dl_config_dci_dl_pdu; typedef struct{ nfapi_uint8_tlv_t coreset_id; diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 550ba3b6b8..149f85161b 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -224,7 +224,12 @@ void fill_pdcch_order(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_a proc->frame_tx, proc->subframe_tx, rel8->rnti); } -void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_alloc,nfapi_dl_config_dci_dl_pdu *pdu) +void fill_dci_and_dlsch(PHY_VARS_eNB *eNB, + int frame, + int subframe, + eNB_rxtx_proc_t *proc, + DCI_ALLOC_t *dci_alloc, + nfapi_dl_config_dci_dl_pdu *pdu) { LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; uint8_t *dci_pdu = &dci_alloc->dci_pdu[0]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index e69de29bb2..9362e74bb7 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -0,0 +1,98 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file PHY/NR_TRANSPORT/nr_dci_tools.c + * \brief + * \author + * \date 2018 + * \version 0.1 + * \company Eurecom + * \email: + * \note + * \warning + */ + +#include "nfapi_nr_interface.h" + +void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, + int frame, + int subframe, + gNB_rxtx_proc_t *proc, + NR_DCI_ALLOC_t *dci_alloc, + nfapi_nr_dl_config_dci_pdu_rel15_t *pdu) +{ + NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; + uint8_t *dci_pdu = &dci_alloc->dci_pdu[0]; + nfapi_nr_dl_config_dci_pdu_rel15_t *rel15 = &pdu->dci_dl_pdu_rel15; + nfapi_nr_config_request_t *cfg = &gNB->gNB_config; + + dci_alloc->L = rel15->aggregation_level; + dci_alloc->firstCCE = rel15->cce_idx; + dci_alloc->rnti = rel15->rnti; + dci_alloc->ra_flag = 0; + //dci_alloc->search_space = ??? + + if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_1_0) { + dci_alloc->format = format1_0; + dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,&cfg); + if (rel15->rnti_type == NFAPI_NR_RNTI_C + || rel15->rnti_type == NFAPI_NR_RNTI_CS + || rel15->rnti_type == NFAPI_NR_RNTI_new) { + + } else if (rel15->rnti_type == NFAPI_NR_RNTI_P) { + + } else if (rel15->rnti_type == NFAPI_NR_RNTI_SI) { + + } else if (rel15->rnti_type == NFAPI_NR_RNTI_RA) { + dci_alloc->ra_flag = 1; + + } else if (rel15->rnti_type == NFAPI_NR_RNTI_TC) { + + } else { + AssertFatal(1==0, "[nr_fill_dci_and_dlsch] Incorrect DCI Format(%d) and RNTI Type(%d) combination",rel15->dci_format, rel15->rnti_type); + } + } else if (rel15->dci_format == NFAPI_NR_UL_DCI_FORMAT_0_0) { + dci_alloc->format = format0_0; + dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_ul ,&cfg); + } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_1_1) { + dci_alloc->format = format1_1; + dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,&cfg); + } else if (rel15->dci_format == NFAPI_NR_UL_DCI_FORMAT_0_1) { + dci_alloc->format = format0_1; + dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_ul ,&cfg); + } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_2_0) { + dci_alloc->format = format2_0; + dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,&cfg); + } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_2_1) { + dci_alloc->format = format2_1; + dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,&cfg); + } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_2_2) { + dci_alloc->format = format2_2; + dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,&cfg); + } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_2_3) { + dci_alloc->format = format2_3; + dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,&cfg); + } else { + AssertFatal(1==0, "[nr_fill_dci_and_dlsch] Incorrect DCI Format(%d)",rel15->dci_format); + } + + return; +} diff --git a/openair1/PHY/defs_NR.h b/openair1/PHY/defs_NR.h deleted file mode 100644 index b705ef4c2e..0000000000 --- a/openair1/PHY/defs_NR.h +++ /dev/null @@ -1,488 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -/*#ifndef __INIT_DEFS_NR__H__ -#define __INIT_DEFS_NR__H__ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "types.h" -#include "defs.h" -#include "assertions.h"*/ -#include "impl_defs_nr.h" - -#define MAX_NUM_SUBCARRIER_SPACING 5 - -#define NR_SYMBOLS_PER_SLOT 14 - -#define NR_PSS_LENGTH 127 -#define NR_SSS_LENGTH 127 - -#define ONE_OVER_SQRT2_Q15 23170 -#define ONE_OVER_TWO_Q15 16384 - -#define MOD_TABLE_SIZE_SHORT 6 -#define MOD_TABLE_BPSK_OFFSET 1 - -typedef enum { - NR_MU_0=0, - NR_MU_1, - NR_MU_2, - NR_MU_3, - NR_MU_4, -} nr_numerology_index_e; - -//NR types temporarily placed here -typedef struct { - uint32_t subcarrier_spacing; - /// 3/4 sampling - uint8_t threequarter_fs; - /// Size of FFT - uint16_t ofdm_symbol_size; - /// Number of prefix samples in all but first symbol of slot - uint16_t nb_prefix_samples; - /// Number of prefix samples in first symbol of slot - uint16_t nb_prefix_samples0; - /// Carrier offset in FFT buffer for first RE in PRB0 - uint16_t first_carrier_offset; - /// Number of OFDM/SC-FDMA symbols in one slot - uint16_t symbols_per_slot; - /// Number of slots per subframe - uint16_t slots_per_subframe; - /// Number of samples in a subframe - uint32_t samples_per_subframe; - /// Number of samples in a radio frame - uint32_t samples_per_frame; - /// Number of samples in a subframe without CP - uint32_t samples_per_subframe_wCP; - /// Number of samples in a radio frame without CP - uint32_t samples_per_frame_wCP; - -} NR_DL_FRAME_PARMS; - -/// Top-level PHY Data Structure for gNB -typedef struct PHY_VARS_gNB_s { - /// Module ID indicator for this instance - module_id_t Mod_id; - uint8_t CC_id; - uint8_t configured; - gNB_proc_t proc; - int single_thread_flag; - int abstraction_flag; - int num_RU; - RU_t *RU_list[MAX_NUM_RU_PER_eNB]; - /// Ethernet parameters for northbound midhaul interface - eth_params_t eth_params_n; - /// Ethernet parameters for fronthaul interface - eth_params_t eth_params; - int rx_total_gain_dB; - int (*td)(struct PHY_VARS_gNB_s *eNB,int UE_id,int harq_pid,int llr8_flag); - int (*te)(struct PHY_VARS_gNB_s *,uint8_t *,uint8_t,LTE_eNB_DLSCH_t *,int,uint8_t,time_stats_t *,time_stats_t *,time_stats_t *); - int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_gNB_s *eNB); - uint8_t local_flag; - nfapi_nr_config_request_t gNB_config; - NR_DL_FRAME_PARMS frame_parms; - PHY_MEASUREMENTS_gNB measurements; - NR_IF_Module_t *if_inst; - NR_UL_IND_t UL_INFO; - pthread_mutex_t UL_INFO_mutex; - /// NFAPI RX ULSCH information - nfapi_rx_indication_pdu_t rx_pdu_list[NFAPI_RX_IND_MAX_PDU]; - /// NFAPI RX ULSCH CRC information - nfapi_crc_indication_pdu_t crc_pdu_list[NFAPI_CRC_IND_MAX_PDU]; - /// NFAPI HARQ information - nfapi_harq_indication_pdu_t harq_pdu_list[NFAPI_HARQ_IND_MAX_PDU]; - /// NFAPI SR information - nfapi_sr_indication_pdu_t sr_pdu_list[NFAPI_SR_IND_MAX_PDU]; - /// NFAPI CQI information - nfapi_cqi_indication_pdu_t cqi_pdu_list[NFAPI_CQI_IND_MAX_PDU]; - /// NFAPI CQI information (raw component) - nfapi_cqi_indication_raw_pdu_t cqi_raw_pdu_list[NFAPI_CQI_IND_MAX_PDU]; - /// NFAPI PRACH information - nfapi_preamble_pdu_t preamble_list[MAX_NUM_RX_PRACH_PREAMBLES]; - - Sched_Rsp_t Sched_INFO; - LTE_eNB_PDCCH pdcch_vars[2]; - LTE_eNB_PHICH phich_vars[2]; - - NR_gNB_COMMON common_vars; - LTE_eNB_UCI uci_vars[NUMBER_OF_UE_MAX]; - LTE_eNB_SRS srs_vars[NUMBER_OF_UE_MAX]; - LTE_eNB_PBCH pbch; - LTE_eNB_PUSCH *pusch_vars[NUMBER_OF_UE_MAX]; - LTE_eNB_PRACH prach_vars; - LTE_eNB_DLSCH_t *dlsch[NUMBER_OF_UE_MAX][2]; // Nusers times two spatial streams - LTE_eNB_ULSCH_t *ulsch[NUMBER_OF_UE_MAX+1]; // Nusers + number of RA - LTE_eNB_DLSCH_t *dlsch_SI,*dlsch_ra,*dlsch_p; - LTE_eNB_DLSCH_t *dlsch_MCH; - LTE_eNB_DLSCH_t *dlsch_PCH; - LTE_eNB_UE_stats UE_stats[NUMBER_OF_UE_MAX]; - LTE_eNB_UE_stats *UE_stats_ptr[NUMBER_OF_UE_MAX]; - - uint8_t pbch_configured; - uint8_t pbch_pdu[4]; //PBCH_PDU_SIZE - char gNB_generate_rar; - - /// Indicator set to 0 after first SR - uint8_t first_sr[NUMBER_OF_UE_MAX]; - - uint32_t max_peak_val; - - /// \brief sinr for all subcarriers of the current link (used only for abstraction). - /// first index: ? [0..N_RB_DL*12[ - double *sinr_dB; - - /// N0 (used for abstraction) - double N0; - - unsigned char first_run_timing_advance[NUMBER_OF_UE_MAX]; - unsigned char first_run_I0_measurements; - - - unsigned char is_secondary_gNB; // primary by default - unsigned char is_init_sync; /// Flag to tell if initial synchronization is performed. This affects how often the secondary eNB will listen to the PSS from the primary system. - unsigned char has_valid_precoder; /// Flag to tell if secondary eNB has channel estimates to create NULL-beams from, and this B/F vector is created. - unsigned char PgNB_id; /// id of Primary eNB - - /// hold the precoder for NULL beam to the primary user - int **dl_precoder_SgNB[3]; - char log2_maxp; /// holds the maximum channel/precoder coefficient - - /// if ==0 enables phy only test mode - int mac_enabled; - /// counter to average prach energh over first 100 prach opportunities - int prach_energy_counter; - - // PDSCH Varaibles - PDSCH_CONFIG_DEDICATED pdsch_config_dedicated[NUMBER_OF_UE_MAX]; - - // PUSCH Varaibles - PUSCH_CONFIG_DEDICATED pusch_config_dedicated[NUMBER_OF_UE_MAX]; - - // PUCCH variables - PUCCH_CONFIG_DEDICATED pucch_config_dedicated[NUMBER_OF_UE_MAX]; - - // UL-POWER-Control - UL_POWER_CONTROL_DEDICATED ul_power_control_dedicated[NUMBER_OF_UE_MAX]; - - // TPC - TPC_PDCCH_CONFIG tpc_pdcch_config_pucch[NUMBER_OF_UE_MAX]; - TPC_PDCCH_CONFIG tpc_pdcch_config_pusch[NUMBER_OF_UE_MAX]; - - // CQI reporting - CQI_REPORT_CONFIG cqi_report_config[NUMBER_OF_UE_MAX]; - - // SRS Variables - SOUNDINGRS_UL_CONFIG_DEDICATED soundingrs_ul_config_dedicated[NUMBER_OF_UE_MAX]; - uint8_t ncs_cell[20][7]; - - // Scheduling Request Config - SCHEDULING_REQUEST_CONFIG scheduling_request_config[NUMBER_OF_UE_MAX]; - - // Transmission mode per UE - uint8_t transmission_mode[NUMBER_OF_UE_MAX]; - - /// cba_last successful reception for each group, used for collision detection - uint8_t cba_last_reception[4]; - - // Pointers for active physicalConfigDedicated to be applied in current subframe - struct PhysicalConfigDedicated *physicalConfigDedicated[NUMBER_OF_UE_MAX]; - - - uint32_t rb_mask_ul[4]; - - /// Information regarding TM5 - MU_MIMO_mode mu_mimo_mode[NUMBER_OF_UE_MAX]; - - - /// target_ue_dl_mcs : only for debug purposes - uint32_t target_ue_dl_mcs; - /// target_ue_ul_mcs : only for debug purposes - uint32_t target_ue_ul_mcs; - /// target_ue_dl_rballoc : only for debug purposes - uint32_t ue_dl_rb_alloc; - /// target ul PRBs : only for debug - uint32_t ue_ul_nb_rb; - - ///check for Total Transmissions - uint32_t check_for_total_transmissions; - - ///check for MU-MIMO Transmissions - uint32_t check_for_MUMIMO_transmissions; - - ///check for SU-MIMO Transmissions - uint32_t check_for_SUMIMO_transmissions; - - ///check for FULL MU-MIMO Transmissions - uint32_t FULL_MUMIMO_transmissions; - - /// Counter for total bitrate, bits and throughput in downlink - uint32_t total_dlsch_bitrate; - uint32_t total_transmitted_bits; - uint32_t total_system_throughput; - - int hw_timing_advance; - - time_stats_t phy_proc; - time_stats_t phy_proc_tx; - time_stats_t phy_proc_rx; - time_stats_t rx_prach; - - time_stats_t ofdm_mod_stats; - time_stats_t dlsch_encoding_stats; - time_stats_t dlsch_modulation_stats; - time_stats_t dlsch_scrambling_stats; - time_stats_t dlsch_rate_matching_stats; - time_stats_t dlsch_turbo_encoding_stats; - time_stats_t dlsch_interleaving_stats; - - time_stats_t rx_dft_stats; - time_stats_t ulsch_channel_estimation_stats; - time_stats_t ulsch_freq_offset_estimation_stats; - time_stats_t ulsch_decoding_stats; - time_stats_t ulsch_demodulation_stats; - time_stats_t ulsch_rate_unmatching_stats; - time_stats_t ulsch_turbo_decoding_stats; - time_stats_t ulsch_deinterleaving_stats; - time_stats_t ulsch_demultiplexing_stats; - time_stats_t ulsch_llr_stats; - time_stats_t ulsch_tc_init_stats; - time_stats_t ulsch_tc_alpha_stats; - time_stats_t ulsch_tc_beta_stats; - time_stats_t ulsch_tc_gamma_stats; - time_stats_t ulsch_tc_ext_stats; - time_stats_t ulsch_tc_intl1_stats; - time_stats_t ulsch_tc_intl2_stats; - -#ifdef LOCALIZATION - /// time state for localization - time_stats_t localization_stats; -#endif - - int32_t pucch1_stats_cnt[NUMBER_OF_UE_MAX][10]; - int32_t pucch1_stats[NUMBER_OF_UE_MAX][10*1024]; - int32_t pucch1_stats_thres[NUMBER_OF_UE_MAX][10*1024]; - int32_t pucch1ab_stats_cnt[NUMBER_OF_UE_MAX][10]; - int32_t pucch1ab_stats[NUMBER_OF_UE_MAX][2*10*1024]; - int32_t pusch_stats_rb[NUMBER_OF_UE_MAX][10240]; - int32_t pusch_stats_round[NUMBER_OF_UE_MAX][10240]; - int32_t pusch_stats_mcs[NUMBER_OF_UE_MAX][10240]; - int32_t pusch_stats_bsr[NUMBER_OF_UE_MAX][10240]; - int32_t pusch_stats_BO[NUMBER_OF_UE_MAX][10240]; -} PHY_VARS_gNB; - -/// Context data structure for RX/TX portion of subframe processing -typedef struct { - /// Component Carrier index - uint8_t CC_id; - /// timestamp transmitted to HW - openair0_timestamp timestamp_tx; - /// subframe to act upon for transmission - int subframe_tx; - /// subframe to act upon for reception - int subframe_rx; - /// frame to act upon for transmission - int frame_tx; - /// frame to act upon for reception - int frame_rx; - /// \brief Instance count for RXn-TXnp4 processing thread. - /// \internal This variable is protected by \ref mutex_rxtx. - int instance_cnt_rxtx; - /// pthread structure for RXn-TXnp4 processing thread - pthread_t pthread_rxtx; - /// pthread attributes for RXn-TXnp4 processing thread - pthread_attr_t attr_rxtx; - /// condition variable for tx processing thread - pthread_cond_t cond_rxtx; - /// mutex for RXn-TXnp4 processing thread - pthread_mutex_t mutex_rxtx; - /// scheduling parameters for RXn-TXnp4 thread - struct sched_param sched_param_rxtx; -} gNB_rxtx_proc_t; - - -/// Context data structure for eNB subframe processing -typedef struct gNB_proc_t_s { - /// Component Carrier index - uint8_t CC_id; - /// thread index - int thread_index; - /// timestamp received from HW - openair0_timestamp timestamp_rx; - /// timestamp to send to "slave rru" - openair0_timestamp timestamp_tx; - /// subframe to act upon for reception - int subframe_rx; - /// subframe to act upon for PRACH - int subframe_prach; - /// frame to act upon for reception - int frame_rx; - /// frame to act upon for transmission - int frame_tx; - /// frame to act upon for PRACH - int frame_prach; - /// \internal This variable is protected by \ref mutex_td. - int instance_cnt_td; - /// \internal This variable is protected by \ref mutex_te. - int instance_cnt_te; - /// \internal This variable is protected by \ref mutex_prach. - int instance_cnt_prach; - - // instance count for over-the-air gNB synchronization - int instance_cnt_synch; - /// \internal This variable is protected by \ref mutex_asynch_rxtx. - int instance_cnt_asynch_rxtx; - /// pthread structure for eNB single processing thread - pthread_t pthread_single; - /// pthread structure for asychronous RX/TX processing thread - pthread_t pthread_asynch_rxtx; - /// flag to indicate first RX acquisition - int first_rx; - /// flag to indicate first TX transmission - int first_tx; - /// pthread attributes for parallel turbo-decoder thread - pthread_attr_t attr_td; - /// pthread attributes for parallel turbo-encoder thread - pthread_attr_t attr_te; - /// pthread attributes for single eNB processing thread - pthread_attr_t attr_single; - /// pthread attributes for prach processing thread - pthread_attr_t attr_prach; - /// pthread attributes for asynchronous RX thread - pthread_attr_t attr_asynch_rxtx; - /// scheduling parameters for parallel turbo-decoder thread - struct sched_param sched_param_td; - /// scheduling parameters for parallel turbo-encoder thread - struct sched_param sched_param_te; - /// scheduling parameters for single eNB thread - struct sched_param sched_param_single; - /// scheduling parameters for prach thread - struct sched_param sched_param_prach; - /// scheduling parameters for asynch_rxtx thread - struct sched_param sched_param_asynch_rxtx; - /// pthread structure for parallel turbo-decoder thread - pthread_t pthread_td; - /// pthread structure for parallel turbo-encoder thread - pthread_t pthread_te; - /// pthread structure for PRACH thread - pthread_t pthread_prach; - /// condition variable for parallel turbo-decoder thread - pthread_cond_t cond_td; - /// condition variable for parallel turbo-encoder thread - pthread_cond_t cond_te; - /// condition variable for PRACH processing thread; - pthread_cond_t cond_prach; - /// condition variable for asynch RX/TX thread - pthread_cond_t cond_asynch_rxtx; - /// mutex for parallel turbo-decoder thread - pthread_mutex_t mutex_td; - /// mutex for parallel turbo-encoder thread - pthread_mutex_t mutex_te; - /// mutex for PRACH thread - pthread_mutex_t mutex_prach; - /// mutex for asynch RX/TX thread - pthread_mutex_t mutex_asynch_rxtx; - /// mutex for RU access to eNB processing (PDSCH/PUSCH) - pthread_mutex_t mutex_RU; - /// mutex for RU access to eNB processing (PRACH) - pthread_mutex_t mutex_RU_PRACH; - /// mutex for RU access to eNB processing (PRACH BR) - pthread_mutex_t mutex_RU_PRACH_br; - /// mask for RUs serving eNB (PDSCH/PUSCH) - int RU_mask; - /// mask for RUs serving eNB (PRACH) - int RU_mask_prach; - /// parameters for turbo-decoding worker thread - td_params tdp; - /// parameters for turbo-encoding worker thread - te_params tep; - /// set of scheduling variables RXn-TXnp4 threads - gNB_rxtx_proc_t proc_rxtx[2]; -} gNB_proc_t; - -typedef struct { - // common measurements - //! estimated noise power (linear) - unsigned int n0_power[MAX_NUM_RU_PER_eNB]; - //! estimated noise power (dB) - unsigned short n0_power_dB[MAX_NUM_RU_PER_eNB]; - //! total estimated noise power (linear) - unsigned int n0_power_tot; - //! estimated avg noise power (dB) - unsigned short n0_power_tot_dB; - //! estimated avg noise power (dB) - short n0_power_tot_dBm; - //! estimated avg noise power per RB per RX ant (lin) - unsigned short n0_subband_power[MAX_NUM_RU_PER_eNB][100]; - //! estimated avg noise power per RB per RX ant (dB) - unsigned short n0_subband_power_dB[MAX_NUM_RU_PER_eNB][100]; - //! estimated avg noise power per RB (dB) - short n0_subband_power_tot_dB[100]; - //! estimated avg noise power per RB (dBm) - short n0_subband_power_tot_dBm[100]; - // gNB measurements (per user) - //! estimated received spatial signal power (linear) - unsigned int rx_spatial_power[NUMBER_OF_UE_MAX][2][2]; - //! estimated received spatial signal power (dB) - unsigned short rx_spatial_power_dB[NUMBER_OF_UE_MAX][2][2]; - //! estimated rssi (dBm) - short rx_rssi_dBm[NUMBER_OF_UE_MAX]; - //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation) - int rx_correlation[NUMBER_OF_UE_MAX][2]; - //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation) - int rx_correlation_dB[NUMBER_OF_UE_MAX][2]; - - /// Wideband CQI (= SINR) - int wideband_cqi[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_eNB]; - /// Wideband CQI in dB (= SINR dB) - int wideband_cqi_dB[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_eNB]; - /// Wideband CQI (sum of all RX antennas, in dB) - char wideband_cqi_tot[NUMBER_OF_UE_MAX]; - /// Subband CQI per RX antenna and RB (= SINR) - int subband_cqi[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_eNB][100]; - /// Total Subband CQI and RB (= SINR) - int subband_cqi_tot[NUMBER_OF_UE_MAX][100]; - /// Subband CQI in dB and RB (= SINR dB) - int subband_cqi_dB[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_eNB][100]; - /// Total Subband CQI and RB - int subband_cqi_tot_dB[NUMBER_OF_UE_MAX][100]; - /// PRACH background noise level - int prach_I0; -} PHY_MEASUREMENTS_gNB; - - -#endif diff --git a/openair1/PHY/defs_eNB.h b/openair1/PHY/defs_eNB.h index 7eb9ee23fa..506c83d9e9 100644 --- a/openair1/PHY/defs_eNB.h +++ b/openair1/PHY/defs_eNB.h @@ -596,7 +596,7 @@ typedef struct PHY_VARS_eNB_s { unsigned char first_run_timing_advance[NUMBER_OF_UE_MAX]; unsigned char first_run_I0_measurements; - + unsigned char is_secondary_eNB; // primary by default unsigned char is_init_sync; /// Flag to tell if initial synchronization is performed. This affects how often the secondary eNB will listen to the PSS from the primary system. unsigned char has_valid_precoder; /// Flag to tell if secondary eNB has channel estimates to create NULL-beams from, and this B/F vector is created. @@ -732,4 +732,3 @@ typedef struct PHY_VARS_eNB_s { } PHY_VARS_eNB; #endif // __PHY_DEFS_eNB_H__ - diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 13dc6814e1..5a3e5ab6cc 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -29,6 +29,7 @@ \note \warning */ + #ifndef __PHY_DEFS_GNB__H__ #define __PHY_DEFS_GNB__H__ @@ -337,7 +338,7 @@ typedef struct PHY_VARS_gNB_s { unsigned char first_run_timing_advance[NUMBER_OF_UE_MAX]; unsigned char first_run_I0_measurements; - + unsigned char is_secondary_gNB; // primary by default unsigned char is_init_sync; /// Flag to tell if initial synchronization is performed. This affects how often the secondary eNB will listen to the PSS from the primary system. unsigned char has_valid_precoder; /// Flag to tell if secondary eNB has channel estimates to create NULL-beams from, and this B/F vector is created. @@ -470,6 +471,4 @@ typedef struct PHY_VARS_gNB_s { int32_t pusch_stats_BO[NUMBER_OF_UE_MAX][10240]; } PHY_VARS_gNB; - - #endif diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index 46174b86f0..ad41917e2f 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -59,14 +59,14 @@ void handle_nfapi_nr_dci_dl_pdu(PHY_VARS_gNB *gNB, gNB_rxtx_proc_t *proc, nfapi_nr_dl_config_request_pdu_t *dl_config_pdu) { - int idx = subframe&1; + int idx = subframe&1; NR_gNB_PDCCH *pdcch_vars = &gNB->pdcch_vars; nfapi_nr_dl_config_dci_pdu_rel15_t *pdu = &dl_config_pdu->dci_dl_pdu_rel15; LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populating pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",frame,subframe, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); // copy dci configuration into gNB structure - //nr_fill_dci_and_dlsch(eNB,frame,subframe,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],pdu); + nr_fill_dci_and_dlsch(gNB,frame,subframe,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],pdu); LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populated pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",proc->frame_tx,proc->subframe_tx, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); } diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index a957e0054a..01e3c280a3 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -18,7 +18,7 @@ * contact@openairinterface.org */ -/*! \file RRC/LITE/defs_NR.h +/*! \file RRC/NR/nr_rrc_defs.h * \brief NR RRC struct definitions and function prototypes * \author Navid Nikaein, Raymond Knopp * \date 2010 - 2014, 2018 From b387b2034e0e063564bd6790d848284f26049e65 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Fri, 27 Jul 2018 15:25:51 +0200 Subject: [PATCH 014/114] Nfapi struct corrections/ DCI interface/ Phytest scheduler type 1 --- .../nfapi/public_inc/nfapi_nr_interface.h | 92 ++++++++++------ openair1/PHY/INIT/nr_init.c | 1 - openair1/PHY/NR_TRANSPORT/nr_dci.c | 6 +- openair1/PHY/NR_TRANSPORT/nr_dci.h | 47 -------- openair1/PHY/defs_gNB.h | 1 + openair1/PHY/defs_nr_common.h | 21 ---- openair1/SCHED_NR/fapi_nr_l1.c | 2 +- openair1/SCHED_NR/phy_procedures_nr_common.c | 96 ++++++++--------- openair1/SCHED_NR/sched_nr.h | 18 ++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 37 +------ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 62 +++++++++++ .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 2 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 101 ++++++++++++++++++ .../NR_MAC_gNB/gNB_scheduler_primitives.c | 4 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 6 +- .../LAYER2/NR_MAC_gNB/{mac.h => nr_mac_gNB.h} | 10 +- 16 files changed, 295 insertions(+), 211 deletions(-) create mode 100644 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c create mode 100644 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c rename openair2/LAYER2/NR_MAC_gNB/{mac.h => nr_mac_gNB.h} (96%) 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 6c125b7555..f7251a4cc3 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -277,6 +277,27 @@ typedef enum { NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC } nfapi_nr_search_space_type_e; +typedef enum { + NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1=0, + NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE2, + NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE3 +} nfapi_nr_ssb_and_cset_mux_pattern_type_e; + +typedef enum { + NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED=0, + NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED +} nfapi_nr_cce_reg_mapping_type_e; + +typedef enum { + NFAPI_NR_CSET_CONFIG_MIB_SIB1=0, + NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG +} nfapi_nr_coreset_config_type_e; + +typedef enum { + NFAPI_NR_CSET_SAME_AS_REG_BUNDLE=0, + NFAPI_NR_CSET_ALL_CONTIGUOUS_RBS +} nfapi_nr_coreset_precoder_granularity_type_e; + // P7 Sub Structures //formats 0_0 and 0_1 typedef struct { @@ -314,7 +335,7 @@ uint8_t beta_offset_indicator; //0 or 2 bits uint8_t dmrs_sequence_initialization; //0 or 1 bit uint8_t ul_sch_indicator; //1 bit -} nfapi_nr_ul_config_dci_pdu_rel15_t; +} nfapi_nr_ul_config_dci_ul_pdu_rel15_t; //#define NFAPI_NR_UL_CONFIG_REQUEST_DCI_UL_PDU_REL15_TAG 0x???? //formats 1_0, 1_1, 2_0, 2_1, 2_2 and 2_3 @@ -371,44 +392,48 @@ uint16_t *pre_emption_indications; //14 bit uint8_t block_number_count; uint8_t *block_numbers; -} nfapi_nr_dl_config_dci_pdu_rel15_t; +} nfapi_nr_dl_config_dci_dl_pdu_rel15_t; //#define NFAPI_NR_DL_CONFIG_REQUEST_DCI_DL_PDU_REL15_TAG 0x???? typedef struct{ - nfapi_uint8_tlv_t coreset_id; - nfapi_uint64_tlv_t frequency_domain_resources; - nfapi_uint8_tlv_t duration; - nfapi_uint8_tlv_t cce_reg_mapping_type; - nfapi_uint8_tlv_t reg_bundle_size; - nfapi_uint8_tlv_t interleaver_size; - nfapi_uint8_tlv_t shift_index; - nfapi_uint8_tlv_t precoder_granularity; - nfapi_uint8_tlv_t tci_state_id; - nfapi_uint8_tlv_t tci_present_in_dci; - nfapi_uint16_tlv_t pdcch_dmrs_scrambling_id; + uint8_t coreset_id; + uint64_t frequency_domain_resources; + uint8_t duration; + uint8_t cce_reg_mapping_type; + uint8_t reg_bundle_size; + uint8_t interleaver_size; + uint8_t shift_index; + uint8_t precoder_granularity; + uint8_t tci_state_id; + uint8_t tci_present_in_dci; + uint32_t dmrs_scrambling_id; } nfapi_nr_coreset_t; typedef struct{ - nfapi_uint8_tlv_t search_space_id; - nfapi_uint8_tlv_t coreset_id; - nfapi_uint8_tlv_t search_space_type; - nfapi_uint8_tlv_t duration; - nfapi_uint8_tlv_t css_formats_0_0_and_1_0; - nfapi_uint8_tlv_t css_format_2_0; - nfapi_uint8_tlv_t css_format_2_1; - nfapi_uint8_tlv_t css_format_2_2; - nfapi_uint8_tlv_t css_format_2_3; - nfapi_uint8_tlv_t uss_dci_formats; - nfapi_uint8_tlv_t srs_monitoring_periodicity; - nfapi_uint8_tlv_t slot_monitoring_periodicity; - nfapi_uint8_tlv_t slot_monitoring_offset; - nfapi_uint16_tlv_t monitoring_symbols_in_slot; - nfapi_uint16_tlv_t number_of_candidates[NFAPI_NR_MAX_NB_CCE_AGGREGATION_LEVELS]; + uint8_t search_space_id; + uint8_t coreset_id; + uint8_t search_space_type; + uint8_t duration; + uint8_t css_formats_0_0_and_1_0; + uint8_t css_format_2_0; + uint8_t css_format_2_1; + uint8_t css_format_2_2; + uint8_t css_format_2_3; + uint8_t uss_dci_formats; + uint8_t srs_monitoring_periodicity; + uint8_t slot_monitoring_periodicity; + uint8_t slot_monitoring_offset; + uint16_t monitoring_symbols_in_slot; + uint16_t number_of_candidates[NFAPI_NR_MAX_NB_CCE_AGGREGATION_LEVELS]; } nfapi_nr_search_space_t; typedef struct { nfapi_tl_t tl; + uint8_t rnti; + uint8_t rnti_type; + uint8_t dci_format; + uint8_t aggregation_level; uint8_t n_rb; uint8_t n_symb; uint8_t rb_offset; @@ -419,6 +444,7 @@ typedef struct { uint8_t first_slot; uint8_t first_symbol; uint8_t nb_ss_sets_per_slot; + uint8_t nb_slots; uint8_t sfn_mod2; uint8_t search_space_type; uint16_t scrambling_id; @@ -462,14 +488,18 @@ typedef struct { }nfapi_nr_dl_config_ndlsch_pdu_rel15_t; +typedef struct { + nfapi_nr_dl_config_dci_dl_pdu_rel15_t dci_dl_pdu_rel15; + nfapi_nr_dl_config_pdcch_parameters_rel15_t pdcch_params_rel15; +} nfapi_nr_dl_config_dci_dl_pdu; + typedef struct { uint8_t pdu_type; uint8_t pdu_size; union { - nfapi_nr_dl_config_dci_pdu_rel15_t dci_dl_pdu_rel15; - nfapi_nr_ul_config_dci_pdu_rel15_t dci_ul_pdu_rel15; + nfapi_nr_dl_config_dci_dl_pdu dci_dl_pdu; nfapi_nr_dl_config_bch_pdu_rel15_t bch_pdu_rel15; nfapi_nr_dl_config_dlsch_pdu_rel15_t dlsch_pdu_rel15; nfapi_nr_dl_config_pch_pdu_rel15_t pch_pdu_rel15; @@ -477,8 +507,6 @@ typedef struct { nfapi_nr_dl_config_npdcch_pdu_rel15_t npdcch_pdu_rel15; nfapi_nr_dl_config_ndlsch_pdu_rel15_t ndlsch_pdu_rel15; }; - - nfapi_nr_dl_config_pdcch_parameters_rel15_t pdcch_params_rel15; } nfapi_nr_dl_config_request_pdu_t; typedef struct { diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 534e9733e6..224fd46a38 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -20,7 +20,6 @@ */ #include "PHY/defs_gNB.h" -#include "SCHED/sched_eNB.h" #include "PHY/phy_extern.h" #include "PHY/NR_REFSIG/nr_refsig.h" #include "PHY/INIT/phy_init.h" diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 899be6dde4..5720a55d30 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -173,7 +173,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, /// DMRS QPSK modulation /*There is a need to shift from which index the pregenerated DMRS sequence is used * see 38211 r15.2.0 section 7.4.1.3.2: assumption is the reference point for k refers to the DMRS sequence*/ - if (pdcch_params.config_type == nr_cset_config_pdcch_config) + if (pdcch_params.config_type == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG) gold_pdcch_dmrs += ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+pdcch_params.rb_offset)*3/32; for (int i=0; i>1; i++) { @@ -219,7 +219,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, if (cset_start_sc >= frame_parms.ofdm_symbol_size) cset_start_sc -= frame_parms.ofdm_symbol_size; - if (pdcch_params.precoder_granularity == nr_cset_same_as_reg_bundle) { + if (pdcch_params.precoder_granularity == NFAPI_NR_CSET_SAME_AS_REG_BUNDLE) { for (int cce_idx=0; cce_idxpdcch_vars; - nfapi_nr_dl_config_dci_pdu_rel15_t *pdu = &dl_config_pdu->dci_dl_pdu_rel15; + nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu = &dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel15; LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populating pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",frame,subframe, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c index 8d88770acf..da39ceca4b 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_common.c +++ b/openair1/SCHED_NR/phy_procedures_nr_common.c @@ -60,25 +60,29 @@ nr_subframe_t nr_subframe_select(nfapi_nr_config_request_t *cfg,unsigned char su } -void nr_get_pdcch_vars_from_mib(nr_pdcch_vars_t *pdcch_vars, - nr_scs_e scs_common, - nr_scs_e pdcch_scs, - nr_frequency_range_e freq_range, - uint8_t rmsi_pdcch_config, - uint16_t N_RB) +void nr_configure_css_dci_from_mib(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params, + nr_scs_e scs_common, + nr_scs_e pdcch_scs, + nr_frequency_range_e freq_range, + uint8_t rmsi_pdcch_config, + uint8_t ssb_idx, + uint16_t nb_slots_per_frame, + uint16_t N_RB) { - nr_pdcch_coreset_params_t *coreset_params = &pdcch_vars->coreset_params; - nr_pdcch_ss_params_t *ss_params = &pdcch_vars->ss_params; + uint8_t O, M; uint8_t ss_idx = rmsi_pdcch_config&0xf; uint8_t cset_idx = (rmsi_pdcch_config>>4)&0xf; + uint8_t mu; /// Coreset params switch(scs_common) { case kHz15: + mu = 0; break; case kHz30: + mu = 1; if (N_RB < 106) { // Minimum 40Mhz bandwidth not satisfied switch(pdcch_scs) { @@ -86,10 +90,10 @@ void nr_get_pdcch_vars_from_mib(nr_pdcch_vars_t *pdcch_vars, break; case kHz30: - coreset_params->mux_pattern = nr_ssb_and_cset_mux_pattern_type_1; - coreset_params->n_rb = (cset_idx < 10)? 24 : 48; - coreset_params->n_symb = nr_coreset_nsymb_pdcch_type_0_b40Mhz[cset_idx]; - coreset_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0_b40Mhz[cset_idx]; + pdcch_params->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1; + pdcch_params->n_rb = (cset_idx < 10)? 24 : 48; + pdcch_params->n_symb = nr_coreset_nsymb_pdcch_type_0_b40Mhz[cset_idx]; + pdcch_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0_b40Mhz[cset_idx]; break; default: @@ -104,10 +108,10 @@ void nr_get_pdcch_vars_from_mib(nr_pdcch_vars_t *pdcch_vars, break; case kHz30: - coreset_params->mux_pattern = nr_ssb_and_cset_mux_pattern_type_1; - coreset_params->n_rb = (cset_idx < 4)? 24 : 48; - coreset_params->n_symb = nr_coreset_nsymb_pdcch_type_0_b40Mhz[cset_idx]; - coreset_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0_b40Mhz[cset_idx]; + pdcch_params->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1; + pdcch_params->n_rb = (cset_idx < 4)? 24 : 48; + pdcch_params->n_symb = nr_coreset_nsymb_pdcch_type_0_b40Mhz[cset_idx]; + pdcch_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0_b40Mhz[cset_idx]; break; default: @@ -116,9 +120,11 @@ void nr_get_pdcch_vars_from_mib(nr_pdcch_vars_t *pdcch_vars, } case kHz60: + mu = 2; break; case kHz120: + mu = 3; break; default: @@ -127,60 +133,46 @@ void nr_get_pdcch_vars_from_mib(nr_pdcch_vars_t *pdcch_vars, } /// Search space params - switch(coreset_params->mux_pattern) { + switch(pdcch_params->mux_pattern) { - case nr_ssb_and_cset_mux_pattern_type_1: + case NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1: if (freq_range == nr_FR1) { - ss_params->param_O = nr_ss_param_O_type_0_mux1_FR1[ss_idx]; - ss_params->nb_ss_sets_per_slot = nr_ss_sets_per_slot_type_0_FR1[ss_idx]; - ss_params->param_M = nr_ss_param_M_type_0_mux1_FR1[ss_idx]; - ss_params->first_symbol_idx = (ss_idx < 8)? ( (ss_idx&1)? coreset_params->n_symb : 0 ) : nr_ss_first_symb_idx_type_0_mux1_FR1[ss_idx - 8]; + O = nr_ss_param_O_type_0_mux1_FR1[ss_idx]; + pdcch_params->nb_ss_sets_per_slot = nr_ss_sets_per_slot_type_0_FR1[ss_idx]; + M = nr_ss_param_M_type_0_mux1_FR1[ss_idx]; + pdcch_params->first_symbol = (ss_idx < 8)? ( (ss_idx&1)? pdcch_params->n_symb : 0 ) : nr_ss_first_symb_idx_type_0_mux1_FR1[ss_idx - 8]; } else { AssertFatal(ss_idx<14 ,"Invalid search space index for multiplexing type 1 and FR2 %d\n", ss_idx); - ss_params->param_O = nr_ss_param_O_type_0_mux1_FR2[ss_idx]; - ss_params->nb_ss_sets_per_slot = nr_ss_sets_per_slot_type_0_FR2[ss_idx]; - ss_params->param_M = nr_ss_param_M_type_0_mux1_FR2[ss_idx]; - ss_params->first_symbol_idx = (ss_idx < 12)? ( (ss_idx&1)? 7 : 0 ) : 0; + O = nr_ss_param_O_type_0_mux1_FR2[ss_idx]; + pdcch_params->nb_ss_sets_per_slot = nr_ss_sets_per_slot_type_0_FR2[ss_idx]; + M = nr_ss_param_M_type_0_mux1_FR2[ss_idx]; + pdcch_params->first_symbol = (ss_idx < 12)? ( (ss_idx&1)? 7 : 0 ) : 0; } + pdcch_params->nb_slots = 2; + pdcch_params->sfn_mod2 = ((uint8_t)(floor( (O*pow(2, mu) + floor(ssb_idx*M)) / nb_slots_per_frame )) & 1)? 1 : 0; + pdcch_params->first_slot = (uint8_t)(O*pow(2, mu) + floor(ssb_idx*M)) % nb_slots_per_frame; break; - case nr_ssb_and_cset_mux_pattern_type_2: + case NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE2: break; - case nr_ssb_and_cset_mux_pattern_type_3: + case NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE3: break; default: - AssertFatal(1==0, "Invalid SSB and coreset multiplexing pattern %d\n", coreset_params->mux_pattern); + AssertFatal(1==0, "Invalid SSB and coreset multiplexing pattern %d\n", pdcch_params->mux_pattern); } + pdcch_params->config_type = NFAPI_NR_CSET_CONFIG_MIB_SIB1; + pdcch_params->cr_mapping_type = NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED; + pdcch_params->precoder_granularity = NFAPI_NR_CSET_SAME_AS_REG_BUNDLE; } -void nr_get_pdcch_type_0_monitoring_period(nr_pdcch_vars_t *pdcch_vars, - uint8_t mu, - uint8_t nb_slots_per_frame, - uint8_t ssb_idx) -{ - uint8_t O = pdcch_vars->ss_params.param_O, M = pdcch_vars->ss_params.param_M; +void nr_configure_css_dci_from_pdcch_config(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params, + nfapi_nr_coreset_t* coreset, + nfapi_nr_search_space_t* search_space) { - if (pdcch_vars->coreset_params.mux_pattern == nr_ssb_and_cset_mux_pattern_type_1) { - pdcch_vars->nb_slots = 2; - pdcch_vars->sfn_mod2 = ((uint8_t)(floor( (O*pow(2, mu) + floor(ssb_idx*M)) / nb_slots_per_frame )) & 1)? 1 : 0; - pdcch_vars->first_slot = (uint8_t)(O*pow(2, mu) + floor(ssb_idx*M)) % nb_slots_per_frame; - } - else { //nr_ssb_and_cset_mux_pattern_type_2, nr_ssb_and_cset_mux_pattern_type_3 - pdcch_vars->nb_slots = 1; - } - -} - -void nr_get_pdcch_vars_from_config(nr_pdcch_vars_t* pdcch_vars, - nfapi_nr_coreset_t* coreset, - nfapi_nr_search_space_t* search_space) { - - nr_pdcch_coreset_params_t cset_params = pdcch_vars->coreset_params; - nr_pdcch_ss_params_t ss_params = pdcch_vars->ss_params; } diff --git a/openair1/SCHED_NR/sched_nr.h b/openair1/SCHED_NR/sched_nr.h index aaa9dda69e..1e27c926f1 100644 --- a/openair1/SCHED_NR/sched_nr.h +++ b/openair1/SCHED_NR/sched_nr.h @@ -42,15 +42,13 @@ void nr_feptx_ofdm(RU_t *ru); void nr_feptx_ofdm_2thread(RU_t *ru); void nr_feptx0(RU_t *ru,int slot); -void nr_get_pdcch_vars_from_mib(nr_pdcch_vars_t *pdcch_vars, - nr_scs_e scs_common, - nr_scs_e pdcch_scs, - nr_frequency_range_e freq_range, - uint8_t rmsi_pdcch_config, - uint16_t N_RB); -void nr_get_pdcch_type_0_monitoring_period(nr_pdcch_vars_t *pdcch_vars, - uint8_t mu, - uint8_t nb_slots_per_frame, - uint8_t ssb_idx); +void nr_configure_css_dci_from_mib(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params, + nr_scs_e scs_common, + nr_scs_e pdcch_scs, + nr_frequency_range_e freq_range, + uint8_t rmsi_pdcch_config, + uint8_t ssb_idx, + uint16_t nb_slots_per_frame, + uint16_t N_RB); #endif diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index a62c847225..c3a65cb7ca 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -417,42 +417,13 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, schedule_nr_mib(module_idP, frameP, subframeP); } - /* - * Temporary DCI scheduling for PDCCH testing in the absence of phy-test mode and pending proper scheduling - * currently schedules PDCCH type 1 for RA-RNTI*/ - - - - /* - if (phy_test == 0){ - // This schedules SI for legacy LTE and eMTC starting in subframeP - schedule_SI(module_idP, frameP, subframeP); - // This schedules Paging in subframeP - schedule_PCH(module_idP,frameP,subframeP); - // This schedules Random-Access for legacy LTE and eMTC starting in subframeP - schedule_RA(module_idP, frameP, subframeP); - // copy previously scheduled UL resources (ULSCH + HARQ) - copy_nr_ulreq(module_idP, frameP, subframeP); - // This schedules SRS in subframeP - schedule_nr_SRS(module_idP, frameP, subframeP); - // This schedules ULSCH in subframeP (dci0) - schedule_ulsch(module_idP, frameP, subframeP); - // This schedules UCI_SR in subframeP - schedule_nr_SR(module_idP, frameP, subframeP); - // This schedules UCI_CSI in subframeP - schedule_nr_CSI(module_idP, frameP, subframeP); - // This schedules DLSCH in subframeP - schedule_dlsch(module_idP, frameP, subframeP, mbsfn_status); + if (phy_test == 0) { + } - else{ - schedule_ulsch_phy_test(module_idP,frameP,subframeP); - schedule_ue_spec_phy_test(module_idP,frameP,subframeP,mbsfn_status); + else { + void nr_schedule_css_dlsch_phytest(module_idP, frameP, subframeP); } - */ - if (RC.flexran[module_idP]->enabled) - flexran_agent_send_update_stats(module_idP); - /* // Allocate CCEs for good after scheduling is done for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c new file mode 100644 index 0000000000..d74df15eac --- /dev/null +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -0,0 +1,62 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file gNB_scheduler_RA.c + * \brief primitives used for random access + * \author + * \date + * \email: + * \version + */ + +#include nr_mac_gNB.h + +void +schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) +{ + + eNB_MAC_INST *mac = RC.mac[module_idP]; + COMMON_channels_t *cc = mac->common_channels; + RA_t *ra; + uint8_t i; + + start_meas(&mac->schedule_ra); + + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + + for (i = 0; i < NB_RA_PROC_MAX; i++) { + + ra = (RA_t *) & cc[CC_id].ra[i]; + //LOG_D(MAC,"RA[state:%d]\n",ra->state); + + if (ra->state == MSG2) + generate_Msg2(module_idP, CC_id, frameP, subframeP, ra); + else if (ra->state == MSG4) + generate_Msg4(module_idP, CC_id, frameP, subframeP, ra); + else if (ra->state == WAITMSG4ACK) + check_Msg4_retransmission(module_idP, CC_id, frameP, subframeP, ra); + + } // for i=0 .. N_RA_PROC-1 + } // CC_id + + stop_meas(&mac->schedule_ra); +} diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index c51eafbad4..11e564372d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -30,7 +30,7 @@ */ #include "assertions.h" -#include "LAYER2/NR_MAC_gNB/mac.h" +#include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "LAYER2/MAC/mac_extern.h" #include "UTIL/LOG/log.h" diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c new file mode 100644 index 0000000000..8ba61e37dd --- /dev/null +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -0,0 +1,101 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file gNB_scheduler_phytest.c + * \brief gNB scheduling procedures in phy_test mode + * \author Guy De Souza + * \date 07/2018 + * \email: desouza@eurecom.fr + * \version 1.0 + * @ingroup _mac + */ + +#include "nr_mac_gNB.h" +#include "PHY/SCHED/sched_nr.h" + +extern RAN_CONTEXT_t RC; + +/*Scheduling of DLSCH with associated DCI in common search space + * current version has only a DCI for type 1 PDCCH for RA-RNTI*/ +void nr_schedule_css_dlsch_phytest(module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP) +{ + uint8_t CC_id; + + gNB_MAC_INST *gNB_mac = RC.mac[module_idP]; + NR_COMMON_channels_t *cc = gNB_mac->common_channels; + nfapi_nr_dl_config_request_body_t *dl_req; + nfapi_nr_dl_config_request_pdu_t *dl_config_pdu; + + for (CC_id=0; CC_idgNB_config; + + dl_req = &gNB_mac->DL_req[CC_id].dl_config_request_body; + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_of_pdus]; + memset((void*)dl_config_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dci_dl_pdu)); + + nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel15; + nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &dl_config_pdu->dci_dl_pdu.pdcch_params_rel15; + nr_configure_css_dci_from_mib(&gNB->pdcch_type0_params, + kHz30, kHz30, NR_FR1, 0, 0, + fp->slots_per_frame, + cfg->rf_config.dl_channel_bandwidth.value); + + pdu_rel15->frequency_domain_resource_assignment = 5; + pdu_rel15->time_domain_resource_assignment = 2; + pdu_rel15->vrb_to_prb_mapping = 0; + pdu_rel15->tb_scaling = 1; + LOG_I(PHY, "DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, tb_scaling %d\n", + pdu_rel15->frequency_domain_resource_assignment, + pdu_rel15->time_domain_resource_assignment, + pdu_rel15->vrb_to_prb_mapping, + pdu_rel15->tb_scaling); + + params_rel15->rnti = 0x03; + params_rel15->rnti_type = NFAPI_NR_RNTI_RA; + params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0; + params_rel15->aggregation_level = 4; + LOG_I(PHY, "DCI type 1 params: rmsi_pdcch_config, rnti %d, rnti_type %d, dci_format, L %d\n \ + coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d \n \ + ss params : nb_ss_sets_per_slot %d, first symb %d, nb_slots %d, sfn_mod2 %d, first slot %d\n", + 0, + params_rel15->rnti, + params_rel15->rnti_type, + params_rel15->dci_format, + params_rel15->aggregation_level, + params_rel15->mux_pattern, + params_rel15->n_rb, + params_rel15->n_symb, + params_rel15->rb_offset, + params_rel15->nb_ss_sets_per_slot, + params_rel15->first_symbol, + params_rel15->nb_slots, + params_rel15->sfn_mod2, + params_rel15->first_slot); + + } +} diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 7b5d9ba8e4..f9c4aaf1bd 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -32,7 +32,7 @@ #include "assertions.h" #include "LAYER2/MAC/mac.h" -#include "LAYER2/NR_MAC_gNB/mac.h" +#include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h" #include "LAYER2/MAC/mac_extern.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" @@ -119,4 +119,4 @@ int is_nr_UL_sf(NR_COMMON_channels_t * ccP, sub_frame_t subframeP){ subframeP, (int) ccP->tdd_Config->subframeAssignment); break; } -} \ No newline at end of file +} diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 551cffeed3..dd6b381c47 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -2,8 +2,8 @@ #ifndef __LAYER2_NR_MAC_PROTO_H__ #define __LAYER2_NR_MAC_PROTO_H__ -#include "mac.h" -#include "PHY/defs_nr_common.h" +#include "nr_mac_gNB.h" +#include "PHY/defs_gNB.h" void mac_top_init_gNB(void); @@ -30,4 +30,4 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); -#endif /*__LAYER2_NR_MAC_PROTO_H__*/ \ No newline at end of file +#endif /*__LAYER2_NR_MAC_PROTO_H__*/ diff --git a/openair2/LAYER2/NR_MAC_gNB/mac.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h similarity index 96% rename from openair2/LAYER2/NR_MAC_gNB/mac.h rename to openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 29d9e3e43b..a6819c2b7f 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -34,8 +34,8 @@ /*@}*/ -#ifndef __LAYER2_NR_MAC_DEFS_H__ -#define __LAYER2_NR_MAC_DEFS_H__ +#ifndef __LAYER2_NR_MAC_GNB_H__ +#define __LAYER2_NR_MAC_GNB_H__ #include #include @@ -52,13 +52,13 @@ #include "PHY/TOOLS/time_meas.h" -#include "PHY/defs_common.h" // for PRACH_RESOURCES_t +#include "PHY/defs_gNB.h" #include "targets/ARCH/COMMON/common_lib.h" #include "LAYER2/MAC/mac.h" // temporary -/*! \brief eNB common channels */ +/*! \brief gNB common channels */ typedef struct { int physCellId; int p_gNB; @@ -163,4 +163,4 @@ typedef struct gNB_MAC_INST_s { time_stats_t schedule_pch; } gNB_MAC_INST; -#endif /*__LAYER2_NR_MAC_DEFS_H__ */ +#endif /*__LAYER2_NR_MAC_GNB_H__ */ From eb7fe108650c2c53750f7ec16c13f3f273668497 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Mon, 30 Jul 2018 11:37:58 +0200 Subject: [PATCH 015/114] Corrections to fill_dci/Compiling --- cmake_targets/CMakeLists.txt | 1 + .../nfapi/public_inc/nfapi_nr_interface.h | 7 +-- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 47 +++++++++---------- 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 92348798a4..d5aae74dcf 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1268,6 +1268,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_sss.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_pbch.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_dci.c + ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_dci_tools.c ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold.c ${OPENAIR1_DIR}/PHY/TOOLS/file_output.c ${OPENAIR1_DIR}/PHY/TOOLS/cadd_vv.c 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 914ead3151..576f024be5 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -17,7 +17,7 @@ typedef struct { uint32_t value; } nfapi_uint32_tlv_t; -typedef struct { +/*typedef struct { nfapi_tl_t tl; int64_t value; } nfapi_int64_tlv_t; @@ -25,7 +25,7 @@ typedef struct { typedef struct { nfapi_tl_t tl; uint64_t value; -} nfapi_uint64_tlv_t; +} nfapi_uint64_tlv_t;*/ // nFAPI enums typedef enum { @@ -397,9 +397,6 @@ uint8_t *block_numbers; } nfapi_nr_dl_config_dci_dl_pdu_rel15_t; //#define NFAPI_NR_DL_CONFIG_REQUEST_DCI_DL_PDU_REL15_TAG 0x???? -typedef struct { - nfapi_nr_dl_config_dci_pdu_rel15_t dci_dl_pdu_rel15; -} nfapi_dl_config_dci_dl_pdu; typedef struct{ uint8_t coreset_id; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 9362e74bb7..e6c286452b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -30,29 +30,25 @@ * \warning */ -#include "nfapi_nr_interface.h" +#include "nr_dci.h" void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, int frame, int subframe, gNB_rxtx_proc_t *proc, - NR_DCI_ALLOC_t *dci_alloc, - nfapi_nr_dl_config_dci_pdu_rel15_t *pdu) + NR_gNB_DCI_ALLOC_t *dci_alloc, + nfapi_nr_dl_config_request_pdu_t *pdu) { NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; - uint8_t *dci_pdu = &dci_alloc->dci_pdu[0]; - nfapi_nr_dl_config_dci_pdu_rel15_t *rel15 = &pdu->dci_dl_pdu_rel15; + uint32_t *dci_pdu = &dci_alloc->dci_pdu[0]; + nfapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &pdu->dci_dl_pdu.dci_dl_pdu_rel15; nfapi_nr_config_request_t *cfg = &gNB->gNB_config; dci_alloc->L = rel15->aggregation_level; - dci_alloc->firstCCE = rel15->cce_idx; - dci_alloc->rnti = rel15->rnti; - dci_alloc->ra_flag = 0; - //dci_alloc->search_space = ??? if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_1_0) { - dci_alloc->format = format1_0; - dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,&cfg); + dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_1_0; + dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); if (rel15->rnti_type == NFAPI_NR_RNTI_C || rel15->rnti_type == NFAPI_NR_RNTI_CS || rel15->rnti_type == NFAPI_NR_RNTI_new) { @@ -62,7 +58,6 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, } else if (rel15->rnti_type == NFAPI_NR_RNTI_SI) { } else if (rel15->rnti_type == NFAPI_NR_RNTI_RA) { - dci_alloc->ra_flag = 1; } else if (rel15->rnti_type == NFAPI_NR_RNTI_TC) { @@ -70,26 +65,26 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, AssertFatal(1==0, "[nr_fill_dci_and_dlsch] Incorrect DCI Format(%d) and RNTI Type(%d) combination",rel15->dci_format, rel15->rnti_type); } } else if (rel15->dci_format == NFAPI_NR_UL_DCI_FORMAT_0_0) { - dci_alloc->format = format0_0; - dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_ul ,&cfg); + dci_alloc->format = NFAPI_NR_UL_DCI_FORMAT_0_0; + dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_ul ,cfg); } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_1_1) { - dci_alloc->format = format1_1; - dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,&cfg); + dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_1_1; + dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); } else if (rel15->dci_format == NFAPI_NR_UL_DCI_FORMAT_0_1) { - dci_alloc->format = format0_1; - dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_ul ,&cfg); + dci_alloc->format = NFAPI_NR_UL_DCI_FORMAT_0_1; + dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_ul ,cfg); } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_2_0) { - dci_alloc->format = format2_0; - dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,&cfg); + dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_2_0; + dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_2_1) { - dci_alloc->format = format2_1; - dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,&cfg); + dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_2_1; + dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_2_2) { - dci_alloc->format = format2_2; - dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,&cfg); + dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_2_2; + dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_2_3) { - dci_alloc->format = format2_3; - dci_alloc->dci_length = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,&cfg); + dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_2_3; + dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); } else { AssertFatal(1==0, "[nr_fill_dci_and_dlsch] Incorrect DCI Format(%d)",rel15->dci_format); } From 9d8130568c61c17402fdc7c7b42e4cad7fedf2f7 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Mon, 30 Jul 2018 16:57:21 +0200 Subject: [PATCH 016/114] DMRS malloc fix --- openair1/PHY/INIT/nr_init.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 224fd46a38..2054a9ec1a 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -123,10 +123,14 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, nr_polar_init(&fp->pbch_polar_params, 1); //PDCCH DMRS init pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**)); + AssertFatal(pdcch_dmrs!=NULL, "NR init: pdcch_dmrs malloc failed\n"); for (int slot=0; slotslots_per_frame; slot++) { - pdcch_dmrs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot); - for (int symb=0; symbsymbols_per_slot; symb++) - pdcch_dmrs[slot][symb] = (uint32_t *)malloc16(NR_MAX_PDCCH_DMRS_LENGTH_DWORD); + pdcch_dmrs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t*)); + AssertFatal(pdcch_dmrs[slot]!=NULL, "NR init: pdcch_dmrs for slot %d - malloc failed\n", slot); + for (int symb=0; symbsymbols_per_slot; symb++){ + pdcch_dmrs[slot][symb] = (uint32_t *)malloc16(NR_MAX_PDCCH_DMRS_LENGTH_DWORD*sizeof(uint32_t)); + AssertFatal(pdcch_dmrs[slot][symb]!=NULL, "NR init: pdcch_dmrs for slot %d symbol %d - malloc failed\n", slot, symb); + } } nr_init_pdcch_dmrs(gNB, cfg->sch_config.physical_cell_id.value); From 6fad29454d9edbf9dfb32096638ae391aada7223 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Tue, 31 Jul 2018 17:03:21 +0200 Subject: [PATCH 017/114] dmrs gold sequence bug fix --- openair1/PHY/INIT/nr_init.c | 4 ++-- openair1/PHY/NR_REFSIG/nr_gold.c | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 2054a9ec1a..6538ce9f51 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -90,7 +90,6 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, LTE_eNB_PUSCH** const pusch_vars = gNB->pusch_vars; LTE_eNB_SRS* const srs_vars = gNB->srs_vars; LTE_eNB_PRACH* const prach_vars = &gNB->prach_vars; - uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; int i, UE_id; @@ -122,7 +121,8 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, // Polar encoder init for PBCH nr_polar_init(&fp->pbch_polar_params, 1); //PDCCH DMRS init - pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**)); + gNB->nr_gold_pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**)); + uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; AssertFatal(pdcch_dmrs!=NULL, "NR init: pdcch_dmrs malloc failed\n"); for (int slot=0; slotslots_per_frame; slot++) { pdcch_dmrs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t*)); diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index cb2738b72a..19137dd1a7 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -28,7 +28,7 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB) unsigned char Lmax, l, n_hf, N_hf; nfapi_nr_config_request_t *cfg = &gNB->gNB_config; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; - uint8_t reset=1; + uint8_t reset; Nid = cfg->sch_config.physical_cell_id.value; @@ -40,6 +40,7 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB) i_ssb = l & (Lmax-1); i_ssb2 = (i_ssb<<2) + n_hf; + reset = 1; x2 = (1<<11) * (i_ssb2 + 1) * ((Nid>>2) + 1) + (1<<6) * (i_ssb2 + 1) + (Nid&3); for (uint8_t n=0; nframe_parms; uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; - for (uint8_t slot=0; fp->slots_per_frame; slot++) { - for (uint8_t symb=0; fp->symbols_per_slot; symb++) { + for (uint8_t slot=0; slotslots_per_frame; slot++) { + for (uint8_t symb=0; symbsymbols_per_slot; symb++) { + reset = 1; x2 = ((1<<17) * (14*slot+symb+1) * ((Nid<<1)+1) + (Nid<<1))&(((uint32_t)1<<31)-1); for (uint32_t n=0; n Date: Thu, 2 Aug 2018 03:33:43 +0200 Subject: [PATCH 018/114] Working polartest.c --- cmake_targets/CMakeLists.txt | 2 +- openair1/PHY/CODING/TESTBENCH/polartest.c | 39 +++-- openair1/PHY/CODING/nrPolar_init.c | 86 ----------- .../CODING/nrPolar_tools/nr_polar_decoder.c | 2 +- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 11 +- .../CODING/nrPolar_tools/nr_polar_encoder.c | 2 +- openair1/PHY/CODING/nr_polar_init.c | 143 ++++++++++++++++++ openair1/PHY/INIT/nr_init.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 4 +- openair1/PHY/NR_TRANSPORT/nr_dci.h | 2 +- 10 files changed, 185 insertions(+), 108 deletions(-) delete mode 100644 openair1/PHY/CODING/nrPolar_init.c create mode 100644 openair1/PHY/CODING/nr_polar_init.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index d5aae74dcf..15ef945eb9 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1108,7 +1108,7 @@ set(PHY_TURBOSRC ${OPENAIR1_DIR}/PHY/CODING/3gpplte_turbo_decoder.c ) set(PHY_POLARSRC - ${OPENAIR1_DIR}/PHY/CODING/nrPolar_init.c + ${OPENAIR1_DIR}/PHY/CODING/nr_polar_init.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_crc_byte.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_bit_insertion.c diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 736eeec659..98a160f547 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -8,6 +8,7 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" +#include "PHY/defs_gNB.h" #include "SIMULATION/TOOLS/sim.h" int main(int argc, char *argv[]) { @@ -21,7 +22,7 @@ int main(int argc, char *argv[]) { randominit(0); //Default simulation values (Aim for iterations = 1000000.) - int itr, iterations = 1000, arguments, polarMessageType = 1; //0=DCI, 1=PBCH, 2=UCI + int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, -1=UCI double SNRstart = -20.0, SNRstop = 0.0, SNRinc= 0.5; //dB double SNR, SNR_lin; @@ -69,13 +70,13 @@ int main(int argc, char *argv[]) { abort (); } - if (polarMessageType == 0) { //DCI - //testLength = ; - //coderLength = ; - } else if (polarMessageType == 1) { //PBCH + if (polarMessageType == 0) { //PBCH testLength = NR_POLAR_PBCH_PAYLOAD_BITS; coderLength = NR_POLAR_PBCH_E; - } else if (polarMessageType == 2) { //UCI + } else if (polarMessageType == 1) { //DCI + //testLength = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_ul ,cfg); + //coderLength = ; + } else if (polarMessageType == -1) { //UCI //testLength = ; //coderLength = ; } @@ -110,12 +111,21 @@ int main(int argc, char *argv[]) { double *channelOutput = malloc (sizeof(double) * coderLength); //add noise uint8_t *estimatedOutput = malloc(sizeof(uint8_t) * testLength); //decoder output - t_nrPolar_params nrPolar_params; - nr_polar_init(&nrPolar_params, polarMessageType); + t_nrPolar_paramsPtr nrPolar_params = NULL; + nr_polar_init(&nrPolar_params, polarMessageType, testLength); + + t_nrPolar_paramsPtr currentPtr = nrPolar_params; + while (currentPtr != NULL) { + if (currentPtr->idx == (polarMessageType * testLength)) { + break; + } else { + currentPtr = currentPtr->nextPtr; + } + } // We assume no a priori knowledge available about the payload. - double aPrioriArray[nrPolar_params.payloadBits]; - for (int i=0; ipayloadBits]; + for (int i=0; ipayloadBits; i++) aPrioriArray[i] = NAN; for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) { SNR_lin = pow(10, SNR/10); @@ -124,7 +134,7 @@ int main(int argc, char *argv[]) { for(int i=0; in_max = NR_POLAR_PBCH_N_MAX; - polarParams->i_il = NR_POLAR_PBCH_I_IL; - polarParams->i_seg = NR_POLAR_PBCH_I_SEG; - polarParams->n_pc = NR_POLAR_PBCH_N_PC; - polarParams->n_pc_wm = NR_POLAR_PBCH_N_PC_WM; - polarParams->i_bil = NR_POLAR_PBCH_I_BIL; - polarParams->payloadBits = NR_POLAR_PBCH_PAYLOAD_BITS; - polarParams->encoderLength = NR_POLAR_PBCH_E; - polarParams->crcParityBits = NR_POLAR_PBCH_CRC_PARITY_BITS; - polarParams->crcCorrectionBits = NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS; - - polarParams->K = polarParams->payloadBits + polarParams->crcParityBits; // Number of bits to encode. - polarParams->N = nr_polar_output_length(polarParams->K, polarParams->encoderLength, polarParams->n_max); - polarParams->n = log2(polarParams->N); - - polarParams->crc_generator_matrix=crc24c_generator_matrix(polarParams->payloadBits); - polarParams->G_N = nr_polar_kronecker_power_matrices(polarParams->n); - - //polar_encoder vectors: - polarParams->nr_polar_crc = malloc(sizeof(uint8_t) * polarParams->crcParityBits); - polarParams->nr_polar_cPrime = malloc(sizeof(uint8_t) * polarParams->K); - polarParams->nr_polar_d = malloc(sizeof(uint8_t) * polarParams->N); - - //Polar Coding vectors - polarParams->nr_polar_u = malloc(sizeof(uint8_t) * polarParams->N); //Decoder: nr_polar_uHat - polarParams->nr_polar_cPrime = malloc(sizeof(uint8_t) * polarParams->K); //Decoder: nr_polar_cHat - polarParams->nr_polar_b = malloc(sizeof(uint8_t) * polarParams->K); //Decoder: nr_polar_bHat - } else if (messageType == 2) { //UCI - - } - - polarParams->Q_0_Nminus1 = nr_polar_sequence_pattern(polarParams->n); - - polarParams->interleaving_pattern = malloc(sizeof(uint16_t) * polarParams->K); - nr_polar_interleaving_pattern(polarParams->K, polarParams->i_il, polarParams->interleaving_pattern); - - polarParams->rate_matching_pattern = malloc(sizeof(uint16_t) * polarParams->encoderLength); - uint16_t *J = malloc(sizeof(uint16_t) * polarParams->N); - nr_polar_rate_matching_pattern(polarParams->rate_matching_pattern, J, - nr_polar_subblock_interleaver_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); - - - polarParams->information_bit_pattern = malloc(sizeof(uint8_t) * polarParams->N); - polarParams->Q_I_N = malloc(sizeof(int16_t) * (polarParams->K + polarParams->n_pc)); - polarParams->Q_F_N = malloc(sizeof(int16_t) * (polarParams->N+1)); // Last element shows the final array index assigned a value. - polarParams->Q_PC_N = malloc(sizeof(int16_t) * (polarParams->n_pc)); - for (int i=0; i<=polarParams->N; i++) polarParams->Q_F_N[i] = -1; // Empty array. - nr_polar_info_bit_pattern(polarParams->information_bit_pattern, - polarParams->Q_I_N, polarParams->Q_F_N, J, polarParams->Q_0_Nminus1, - polarParams->K, polarParams->N, polarParams->encoderLength, polarParams->n_pc); - - polarParams->channel_interleaver_pattern = malloc(sizeof(uint16_t) * polarParams->encoderLength); - nr_polar_channel_interleaver_pattern(polarParams->channel_interleaver_pattern, - polarParams->i_bil, polarParams->encoderLength); - - free(J); -} diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 3d076296d0..9232f74e15 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -31,7 +31,7 @@ int8_t polar_decoder( double *input, uint8_t *output, - t_nrPolar_params *polarParams, + t_nrPolar_paramsPtr polarParams, uint8_t listSize, double *aPrioriPayload, uint8_t pathMetricAppr) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 0db26f6f35..b5d2496f43 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -31,6 +31,10 @@ static const uint8_t nr_polar_subblock_interleaver_pattern[32] = { 0, 1, 2, 4, 3, 5, 6, 7, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 14, 22, 15, 23, 24, 25, 26, 28, 27, 29, 30, 31 }; struct nrPolar_params { + //messageType: 0=PBCH, 1=DCI, -1=UCI + int8_t idx; //idx = messageType*messageLength; + struct nrPolar_params *nextPtr; + uint8_t n_max; uint8_t i_il; uint8_t i_seg; @@ -65,13 +69,14 @@ struct nrPolar_params { uint8_t *nr_polar_d; } __attribute__ ((__packed__)); typedef struct nrPolar_params t_nrPolar_params; +typedef t_nrPolar_params *t_nrPolar_paramsPtr; -void polar_encoder(uint8_t *input, uint8_t *output, t_nrPolar_params* polarParams); +void polar_encoder(uint8_t *input, uint8_t *output, t_nrPolar_paramsPtr polarParams); -int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarParams, +int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_paramsPtr polarParams, uint8_t listSize, double *aPrioriPayload, uint8_t pathMetricAppr); -void nr_polar_init(t_nrPolar_params* polarParams, int messageType); +void nr_polar_init(t_nrPolar_paramsPtr *polarParams, int8_t messageType, uint16_t messageLength); uint8_t** nr_polar_kronecker_power_matrices(uint8_t n); diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index f1bfb37a62..74fb6bd900 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -25,7 +25,7 @@ void polar_encoder( uint8_t *input, uint8_t *output, - t_nrPolar_params *polarParams) + t_nrPolar_paramsPtr polarParams) { /* diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c new file mode 100644 index 0000000000..2f781e4a23 --- /dev/null +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -0,0 +1,143 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include "nrPolar_tools/nr_polar_defs.h" +#include "nrPolar_tools/nr_polar_pbch_defs.h" +#include "PHY/NR_TRANSPORT/nr_dci.h" + +void nr_polar_init(t_nrPolar_paramsPtr *polarParams, + int8_t messageType, + uint16_t messageLength) { + + t_nrPolar_paramsPtr currentPtr = *polarParams; + t_nrPolar_paramsPtr previousPtr = NULL; + + //Parse the list. If the node is already created, return without initialization. + while (currentPtr != NULL) { + if (currentPtr->idx == (messageType * messageLength)) { + return; + } else { + previousPtr = currentPtr; + currentPtr = currentPtr->nextPtr; + } + } + + //Else, initialize and add node to the end of the linked list. + t_nrPolar_paramsPtr newPolarInitNode = malloc(sizeof(t_nrPolar_params)); + + if (newPolarInitNode != NULL) { + + newPolarInitNode->idx = (messageType * messageLength); + newPolarInitNode->nextPtr = NULL; + + if (messageType == 0) { //PBCH + newPolarInitNode->n_max = NR_POLAR_PBCH_N_MAX; + newPolarInitNode->i_il = NR_POLAR_PBCH_I_IL; + newPolarInitNode->i_seg = NR_POLAR_PBCH_I_SEG; + newPolarInitNode->n_pc = NR_POLAR_PBCH_N_PC; + newPolarInitNode->n_pc_wm = NR_POLAR_PBCH_N_PC_WM; + newPolarInitNode->i_bil = NR_POLAR_PBCH_I_BIL; + newPolarInitNode->payloadBits = NR_POLAR_PBCH_PAYLOAD_BITS; + newPolarInitNode->encoderLength = NR_POLAR_PBCH_E; + newPolarInitNode->crcParityBits = NR_POLAR_PBCH_CRC_PARITY_BITS; + newPolarInitNode->crcCorrectionBits = NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS; + + newPolarInitNode->K = newPolarInitNode->payloadBits + newPolarInitNode->crcParityBits; // Number of bits to encode. + newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K, newPolarInitNode->encoderLength, newPolarInitNode->n_max); + newPolarInitNode->n = log2(newPolarInitNode->N); + + newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits); + newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n); + + //polar_encoder vectors: + newPolarInitNode->nr_polar_crc = malloc(sizeof(uint8_t) * newPolarInitNode->crcParityBits); + newPolarInitNode->nr_polar_cPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); + newPolarInitNode->nr_polar_d = malloc(sizeof(uint8_t) * newPolarInitNode->N); + + //Polar Coding vectors + newPolarInitNode->nr_polar_u = malloc(sizeof(uint8_t) * newPolarInitNode->N); //Decoder: nr_polar_uHat + newPolarInitNode->nr_polar_cPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_cHat + newPolarInitNode->nr_polar_b = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_bHat + } else if (messageType == 1) { //DCI + + } else if (messageType == -1) { //UCI + + } else { + AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType); + } + + newPolarInitNode->Q_0_Nminus1 = nr_polar_sequence_pattern(newPolarInitNode->n); + + newPolarInitNode->interleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K); + nr_polar_interleaving_pattern(newPolarInitNode->K, + newPolarInitNode->i_il, + newPolarInitNode->interleaving_pattern); + + newPolarInitNode->rate_matching_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength); + uint16_t *J = malloc(sizeof(uint16_t) * newPolarInitNode->N); + nr_polar_rate_matching_pattern(newPolarInitNode->rate_matching_pattern, + J, + nr_polar_subblock_interleaver_pattern, + newPolarInitNode->K, + newPolarInitNode->N, + newPolarInitNode->encoderLength); + + newPolarInitNode->information_bit_pattern = malloc(sizeof(uint8_t) * newPolarInitNode->N); + newPolarInitNode->Q_I_N = malloc(sizeof(int16_t) * (newPolarInitNode->K + newPolarInitNode->n_pc)); + newPolarInitNode->Q_F_N = malloc( sizeof(int16_t) * (newPolarInitNode->N + 1)); // Last element shows the final array index assigned a value. + newPolarInitNode->Q_PC_N = malloc( sizeof(int16_t) * (newPolarInitNode->n_pc)); + for (int i = 0; i <= newPolarInitNode->N; i++) + newPolarInitNode->Q_F_N[i] = -1; // Empty array. + nr_polar_info_bit_pattern(newPolarInitNode->information_bit_pattern, + newPolarInitNode->Q_I_N, + newPolarInitNode->Q_F_N, + J, + newPolarInitNode->Q_0_Nminus1, + newPolarInitNode->K, + newPolarInitNode->N, + newPolarInitNode->encoderLength, + newPolarInitNode->n_pc); + + newPolarInitNode->channel_interleaver_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength); + nr_polar_channel_interleaver_pattern(newPolarInitNode->channel_interleaver_pattern, + newPolarInitNode->i_bil, + newPolarInitNode->encoderLength); + + free(J); + + } else { + AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_paramsPtr could not be created"); + } + + currentPtr = *polarParams; + //If polarParams is empty: + if (currentPtr == NULL) + { + *polarParams = newPolarInitNode; + return; + } + //Else, add node to the end of the linked list. + while (currentPtr->nextPtr != NULL) { + currentPtr = currentPtr->nextPtr; + } + currentPtr->nextPtr= newPolarInitNode; + return; +} diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 2054a9ec1a..1ce17e9c9a 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -120,7 +120,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, // PBCH DMRS gold sequences generation nr_init_pbch_dmrs(gNB); // Polar encoder init for PBCH - nr_polar_init(&fp->pbch_polar_params, 1); + nr_polar_init(&fp->pbch_polar_params, 1, NR_POLAR_PBCH_PAYLOAD_BITS); //PDCCH DMRS init pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**)); AssertFatal(pdcch_dmrs!=NULL, "NR init: pdcch_dmrs malloc failed\n"); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 5720a55d30..62e0f44781 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -37,12 +37,12 @@ extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; -uint8_t nr_get_dci_size(nfapi_nr_dci_format_e format, +uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, nfapi_nr_rnti_type_e rnti_type, NR_BWP_PARMS* bwp, nfapi_nr_config_request_t* config) { - uint8_t size = 0; + uint16_t size = 0; uint16_t N_RB = bwp->N_RB; switch(format) { diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index f77e451270..ff33f1ee41 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -27,7 +27,7 @@ typedef unsigned __int128 uint128_t; -uint8_t nr_get_dci_size(nfapi_nr_dci_format_e format, +uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, nfapi_nr_rnti_type_e rnti_type, NR_BWP_PARMS* bwp, nfapi_nr_config_request_t* config); From 96bb073014c9d698c0667bd1f4e88ee3f25e09c4 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Thu, 2 Aug 2018 09:40:03 +0200 Subject: [PATCH 019/114] Minor fixes scheduler --- cmake_targets/CMakeLists.txt | 39 ++++++++++++++----- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 11 +++--- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 5 ++- targets/RT/USER/nr-softmodem.c | 2 +- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index d5aae74dcf..7ddff83b21 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1399,6 +1399,9 @@ set(L2_SRC ${RRC_DIR}/L2_interface.c ${RRC_DIR}/L2_interface_common.c ${RRC_DIR}/L2_interface_ue.c + ) + +set(L2_NR_SRC ${NR_RRC_DIR}/rrc_gNB.c ${NR_RRC_DIR}/nr_rrc_common.c ${NR_RRC_DIR}/L2_nr_interface.c @@ -1448,6 +1451,12 @@ set(L2_SRC_UE ${NR_UE_RRC_DIR}/rrc_UE.c ) +set(L2_NR_SRC_UE + ${NR_UE_RRC_DIR}/L2_interface_ue.c + ${NR_UE_RRC_DIR}/main_ue.c + ${NR_UE_RRC_DIR}/rrc_UE.c + ) + set (MAC_SRC ${PHY_INTERFACE_DIR}/IF_Module.c ${MAC_DIR}/main.c @@ -1468,12 +1477,16 @@ set (MAC_SRC ${MAC_DIR}/pre_processor.c ${MAC_DIR}/config.c ${MAC_DIR}/config_ue.c + ) + +set (MAC_NR_SRC ${NR_PHY_INTERFACE_DIR}/NR_IF_Module.c ${NR_MAC_DIR}/main.c ${NR_MAC_DIR}/config.c ${NR_MAC_DIR}/gNB_scheduler.c ${NR_MAC_DIR}/gNB_scheduler_bch.c ${NR_MAC_DIR}/gNB_scheduler_primitives.c + ${NR_MAC_DIR}/gNB_scheduler_phytest.c ) @@ -1509,15 +1522,21 @@ set (GNB_APP_SRC add_library(L2 ${L2_SRC} ${MAC_SRC} - ${ENB_APP_SRC} - ${GNB_APP_SRC}) + ${ENB_APP_SRC}) # ${OPENAIR2_DIR}/RRC/L2_INTERFACE/openair_rrc_L2_interface.c) +add_library(L2_NR + ${L2_NR_SRC} + ${MAC_NR_SRC} + ${GNB_APP_SRC}) + add_library(L2_UE ${L2_SRC_UE} - ${MAC_SRC_UE} - ${MAC_NR_SRC_UE} -) + ${MAC_SRC_UE}) + +add_library(L2_NR_UE + ${L2_NR_SRC_UE} + ${MAC_NR_SRC_UE}) include_directories(${NR_UE_PHY_INTERFACE_DIR}) @@ -2076,7 +2095,7 @@ add_executable(lte-softmodem target_link_libraries (lte-softmodem -Wl,--start-group - RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 + RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -Wl,--end-group z dl) @@ -2220,7 +2239,7 @@ target_link_libraries (nr-softmodem -Wl,--start-group UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} - RRC_LIB S1AP_LIB S1AP_ENB L2 + RRC_LIB S1AP_LIB S1AP_ENB L2 L2_NR NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -Wl,--end-group z dl) @@ -2260,7 +2279,7 @@ target_link_libraries (nr-softmodem -Wl,--start-group UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${MIH_LIB} - RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 + RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 L2_NR NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB -Wl,--end-group z dl) @@ -2295,7 +2314,7 @@ add_executable(nr-uesoftmodem target_link_libraries (nr-uesoftmodem -Wl,--start-group - RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_NR_UE PHY_COMMON PHY_UE PHY_RU LFDS L2_UE + RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_NR_UE PHY_COMMON PHY_UE PHY_RU LFDS L2_UE L2_NR_UE ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 -Wl,--end-group z dl) @@ -2330,7 +2349,7 @@ add_executable(nr-uesoftmodem-nos1 target_link_libraries (nr-uesoftmodem-nos1 -Wl,--start-group - RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_NR_UE PHY_COMMON PHY_UE PHY_RU LFDS L2_UE + RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB PHY_NR_UE PHY_COMMON PHY_UE PHY_RU LFDS L2_UE L2_NR_UE ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 -Wl,--end-group z dl) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 8ba61e37dd..88faeaba9d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -29,7 +29,7 @@ */ #include "nr_mac_gNB.h" -#include "PHY/SCHED/sched_nr.h" +#include "SCHED_NR/sched_nr.h" extern RAN_CONTEXT_t RC; @@ -49,11 +49,12 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, for (CC_id=0; CC_idgNB_config; + PHY_VARS_gNB *gNB = RC.gNB[module_idP][CC_id]; + nfapi_nr_config_request_t *cfg = &gNB->gNB_config; + NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; dl_req = &gNB_mac->DL_req[CC_id].dl_config_request_body; - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_of_pdus]; + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void*)dl_config_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE; dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dci_dl_pdu)); @@ -61,7 +62,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel15; nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &dl_config_pdu->dci_dl_pdu.pdcch_params_rel15; nr_configure_css_dci_from_mib(&gNB->pdcch_type0_params, - kHz30, kHz30, NR_FR1, 0, 0, + kHz30, kHz30, nr_FR1, 0, 0, fp->slots_per_frame, cfg->rf_config.dl_channel_bandwidth.value); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index a6819c2b7f..1ff3745352 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -56,7 +56,10 @@ #include "targets/ARCH/COMMON/common_lib.h" -#include "LAYER2/MAC/mac.h" // temporary +#include "LAYER2/MAC/mac.h" +#include "LAYER2/MAC/mac_proto.h" +#include "LAYER2/MAC/mac_extern.h" +#include "common/ran_context.h" /*! \brief gNB common channels */ typedef struct { diff --git a/targets/RT/USER/nr-softmodem.c b/targets/RT/USER/nr-softmodem.c index 8bace5d0a2..cf34804e1c 100644 --- a/targets/RT/USER/nr-softmodem.c +++ b/targets/RT/USER/nr-softmodem.c @@ -35,9 +35,9 @@ #include "msc.h" #include "PHY/types.h" +#include "common/ran_context.h" #include "PHY/defs_gNB.h" -#include "common/ran_context.h" #include "common/config/config_userapi.h" #include "common/utils/load_module_shlib.h" #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all From 32af23b0c137221bf9680398b89ae32b99843ce9 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Thu, 2 Aug 2018 10:04:54 +0200 Subject: [PATCH 020/114] Debug prints DCI modulation --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 10 ++++++++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 62e0f44781..d80db26fd6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -78,8 +78,8 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, break; case NFAPI_NR_DL_DCI_FORMAT_1_0: - /// fixed: Format identifier 1, VRB2PRB 1, MCS 5, NDI 1, RV 2, HARQ PID 4, DAI 2, PUCCH TPC 2, PUCCH RInd 3, PDSCH to HARQ TInd 3 --24 - size += 24; + /// fixed: Format identifier 1, VRB2PRB 1, MCS 5, NDI 1, RV 2, HARQ PID 4, DAI 2, PUCCH TPC 2, PUCCH RInd 3, PDSCH to HARQ TInd 3 Time Domain assgnmt 4 -- 28 + size += 28; size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment // Time domain assignment break; @@ -181,6 +181,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, mod_dmrs[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; mod_dmrs[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; #ifdef DEBUG_PDCCH_DMRS + printf("DMRS modulation\n"); printf("i %d idx %d gold seq %d b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, gold_pdcch_dmrs[(i<<1)>>5], (((gold_pdcch_dmrs[(i<<1)>>5])>>((i<<1)&0x1f))&1), (((gold_pdcch_dmrs[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), mod_dmrs[(i<<1)], mod_dmrs[(i<<1)+1]); #endif @@ -201,6 +202,11 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, idx = (((scrambled_payload[i<<1]>>(i<<1))&1)<<1) ^ ((scrambled_payload[(i<<1)+1]>>((i<<1)+1))&1); mod_dci[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; mod_dci[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; +#ifdef DEBUG_DCI + printf("DCI modulation\n"); + printf("i %d idx %d b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, (((scrambled_payload[(i<<1)>>5])>>((i<<1)&0x1f))&1), + (((scrambled_payload[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), mod_dci[(i<<1)], mod_dci[(i<<1)+1]); +#endif } /// Resource mapping diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 88faeaba9d..fe479915e0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -97,6 +97,8 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, params_rel15->nb_slots, params_rel15->sfn_mod2, params_rel15->first_slot); + dl_req->number_dci++; + dl_req->number_pdu++; } } From 271303c57ab328eaf76e4a394829ba63028e76ca Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Fri, 3 Aug 2018 09:59:12 +0200 Subject: [PATCH 021/114] fill_dci for 1_0 RA_RNTI --- .../nfapi/public_inc/nfapi_nr_interface.h | 83 ++++++------------- openair1/PHY/INIT/nr_init.c | 2 +- openair1/PHY/NR_REFSIG/nr_gold.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 14 ++-- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 60 +++++++++++--- openair1/PHY/defs_gNB.h | 10 +-- openair1/PHY/defs_nr_common.h | 14 ++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c | 9 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 22 ++--- 9 files changed, 108 insertions(+), 108 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 576f024be5..17bd564f2f 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -299,72 +299,28 @@ typedef enum { } nfapi_nr_coreset_precoder_granularity_type_e; // P7 Sub Structures -//formats 0_0 and 0_1 + typedef struct { nfapi_tl_t tl; -uint8_t cce_idx; -uint8_t aggregation_level; -uint16_t rnti; -uint8_t rnti_type; - -uint8_t dci_format; //1 bit -uint16_t frequency_domain_resource_assignment; //up to 9 bits -uint8_t time_domain_resource_assignment; //0, 1, 2, 3 or 4 bits +uint8_t format_indicator; //1 bit +uint16_t frequency_domain_assignment; //up to 9 bits +uint8_t time_domain_assignment; // 4 bits uint8_t frequency_hopping_flag; //1 bit -uint8_t mcs; //5 bits -uint8_t new_data_indicator; //1 bit -uint8_t redundancy_version; //2 bits -uint8_t harq_process; //4 bits -uint8_t tpc; //2 bits -uint16_t padding; -uint8_t ul_sul_indicator; //0 or 1 bit - -uint8_t carrier_indicator; //0 or 3 bits -uint8_t bwp_indicator; //0, 1 or 2 bits -uint8_t downlink_assignment_index1; //1 or 2 bits -uint8_t downlink_assignment_index2; //0 or 2 bits -uint8_t srs_resource_indicator; -uint8_t precoding_information; -uint8_t antenna_ports; -uint8_t srs_request; -uint8_t csi_request; -uint8_t cbgti; //CBG Transmission Information: 0, 2, 4, 6 or 8 bits -uint8_t ptrs_dmrs_association; -uint8_t beta_offset_indicator; //0 or 2 bits -uint8_t dmrs_sequence_initialization; //0 or 1 bit -uint8_t ul_sch_indicator; //1 bit - -} nfapi_nr_ul_config_dci_ul_pdu_rel15_t; -//#define NFAPI_NR_UL_CONFIG_REQUEST_DCI_UL_PDU_REL15_TAG 0x???? - -//formats 1_0, 1_1, 2_0, 2_1, 2_2 and 2_3 -typedef struct { - -nfapi_tl_t tl; - -uint8_t cce_idx; -uint8_t aggregation_level; -uint16_t rnti; -uint8_t rnti_type; - -uint8_t dci_format; //1 bit -uint16_t frequency_domain_resource_assignment; //up to 9 bits uint8_t ra_preamble_index; //6 bits -uint8_t ul_sul_indicator; //1 bit uint8_t ss_pbch_index; //6 bits uint8_t prach_mask_index; //4 bits -uint16_t reserved; //1_0/C-RNTI:10 bits, 1_0/P-RNTI: 6 bits, 1_0/SI-&RA-RNTI: 16 bits -uint8_t time_domain_resource_assignment; //0, 1, 2, 3 or 4 bits uint8_t vrb_to_prb_mapping; //0 or 1 bit uint8_t mcs; //5 bits -uint8_t new_data_indicator; //1 bit -uint8_t redundancy_version; //2 bits -uint8_t harq_process; //4 bits -uint8_t downlink_assignment_index; //0, 2 or 4 bits +uint8_t ndi; //1 bit +uint8_t rv; //2 bits +uint8_t harq_pid; //4 bits +uint8_t dai; //0, 2 or 4 bits +uint8_t dai1; //1 or 2 bits +uint8_t dai2; //0 or 2 bits uint8_t tpc; //2 bits uint8_t pucch_resource_indicator; //3 bits uint8_t pdsch_to_harq_feedback_timing_indicator; //0, 1, 2 or 3 bits @@ -378,13 +334,18 @@ uint8_t bwp_indicator; //0, 1 or 2 bits uint8_t prb_bundling_size_indicator; //0 or 1 bits uint8_t rate_matching_indicator; //0, 1 or 2 bits uint8_t zp_csi_rs_trigger; //0, 1 or 2 bits -uint8_t antenna_ports; //4, 5 or 6 bits uint8_t transmission_configuration_indication; //0 or 3 bits uint8_t srs_request; //2 bits uint8_t cbgti; //CBG Transmission Information: 0, 2, 4, 6 or 8 bits uint8_t cbgfi; //CBG Flushing Out Information: 0 or 1 bit uint8_t dmrs_sequence_initialization; //0 or 1 bit +uint8_t srs_resource_indicator; +uint8_t precoding_information; +uint8_t csi_request; +uint8_t ptrs_dmrs_association; +uint8_t beta_offset_indicator; //0 or 2 bits + uint8_t slot_format_indicator_count; uint8_t *slot_format_indicators; @@ -394,11 +355,18 @@ uint16_t *pre_emption_indications; //14 bit uint8_t block_number_count; uint8_t *block_numbers; +uint8_t ul_sul_indicator; //0 or 1 bit +uint8_t antenna_ports; + +uint16_t reserved; //1_0/C-RNTI:10 bits, 1_0/P-RNTI: 6 bits, 1_0/SI-&RA-RNTI: 16 bits +uint16_t padding; + } nfapi_nr_dl_config_dci_dl_pdu_rel15_t; //#define NFAPI_NR_DL_CONFIG_REQUEST_DCI_DL_PDU_REL15_TAG 0x???? typedef struct{ + nfapi_tl_t tl; uint8_t coreset_id; uint64_t frequency_domain_resources; uint8_t duration; @@ -413,6 +381,7 @@ typedef struct{ } nfapi_nr_coreset_t; typedef struct{ + nfapi_tl_t tl; uint8_t search_space_id; uint8_t coreset_id; uint8_t search_space_type; @@ -435,6 +404,8 @@ typedef struct { uint8_t rnti; uint8_t rnti_type; uint8_t dci_format; + uint8_t config_type; + uint8_t search_space_type; uint8_t aggregation_level; uint8_t n_rb; uint8_t n_symb; @@ -442,13 +413,11 @@ typedef struct { uint8_t cr_mapping_type; uint8_t mux_pattern; uint8_t precoder_granularity; - uint8_t config_type; uint8_t first_slot; uint8_t first_symbol; uint8_t nb_ss_sets_per_slot; uint8_t nb_slots; uint8_t sfn_mod2; - uint8_t search_space_type; uint16_t scrambling_id; nfapi_bf_vector_t bf_vector; } nfapi_nr_dl_config_pdcch_parameters_rel15_t; diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index d76b92eed2..ef7a9235d0 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -128,7 +128,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, pdcch_dmrs[slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t*)); AssertFatal(pdcch_dmrs[slot]!=NULL, "NR init: pdcch_dmrs for slot %d - malloc failed\n", slot); for (int symb=0; symbsymbols_per_slot; symb++){ - pdcch_dmrs[slot][symb] = (uint32_t *)malloc16(NR_MAX_PDCCH_DMRS_LENGTH_DWORD*sizeof(uint32_t)); + pdcch_dmrs[slot][symb] = (uint32_t *)malloc16(NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD*sizeof(uint32_t)); AssertFatal(pdcch_dmrs[slot][symb]!=NULL, "NR init: pdcch_dmrs for slot %d symbol %d - malloc failed\n", slot, symb); } } diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c index 19137dd1a7..b8197744ec 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold.c +++ b/openair1/PHY/NR_REFSIG/nr_gold.c @@ -67,7 +67,7 @@ void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid) reset = 1; x2 = ((1<<17) * (14*slot+symb+1) * ((Nid<<1)+1) + (Nid<<1))&(((uint32_t)1<<31)-1); - for (uint32_t n=0; n>1 ) ); // Freq domain assignment -- hopping scenario to be updated + size += nr_get_dci_size(NFAPI_NR_DL_DCI_FORMAT_1_0, rnti_type, bwp, config) - size; // Padding to match 1_0 size // UL/SUL indicator assumed to be 0 - // Padding break; case NFAPI_NR_UL_DCI_FORMAT_0_1: @@ -81,7 +81,7 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, /// fixed: Format identifier 1, VRB2PRB 1, MCS 5, NDI 1, RV 2, HARQ PID 4, DAI 2, PUCCH TPC 2, PUCCH RInd 3, PDSCH to HARQ TInd 3 Time Domain assgnmt 4 -- 28 size += 28; size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment - // Time domain assignment + break; case NFAPI_NR_DL_DCI_FORMAT_1_1: @@ -160,7 +160,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, nfapi_nr_config_request_t config) { - uint16_t mod_dmrs[NR_MAX_PDCCH_DMRS_LENGTH<<1]; + uint16_t mod_dmrs[NR_MAX_PDCCH_DMRS_LENGTH>>1]; uint8_t idx=0; uint16_t a; int k,l,k_prime,dci_idx, dmrs_idx; @@ -181,7 +181,6 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, mod_dmrs[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; mod_dmrs[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; #ifdef DEBUG_PDCCH_DMRS - printf("DMRS modulation\n"); printf("i %d idx %d gold seq %d b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, gold_pdcch_dmrs[(i<<1)>>5], (((gold_pdcch_dmrs[(i<<1)>>5])>>((i<<1)&0x1f))&1), (((gold_pdcch_dmrs[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), mod_dmrs[(i<<1)], mod_dmrs[(i<<1)+1]); #endif @@ -192,8 +191,8 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, // scrambling uint32_t scrambled_payload[4]; - uint32_t Nid = (dci_alloc.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value; - uint32_t n_RNTI = (dci_alloc.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? dci_alloc.rnti : 0; + uint32_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value; + uint32_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; nr_pdcch_scrambling(dci_alloc.dci_pdu, dci_alloc.size, Nid, n_RNTI, scrambled_payload); // QPSK modulation @@ -203,8 +202,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, mod_dci[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; mod_dci[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; #ifdef DEBUG_DCI - printf("DCI modulation\n"); - printf("i %d idx %d b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, (((scrambled_payload[(i<<1)>>5])>>((i<<1)&0x1f))&1), + printf("i %d idx %d b0-b1 %d-%d mod_dci %d %d\n", i, idx, (((scrambled_payload[(i<<1)>>5])>>((i<<1)&0x1f))&1), (((scrambled_payload[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), mod_dci[(i<<1)], mod_dci[(i<<1)+1]); #endif } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index e6c286452b..c2ac37a23f 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -33,20 +33,60 @@ #include "nr_dci.h" void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, - int frame, - int subframe, - gNB_rxtx_proc_t *proc, - NR_gNB_DCI_ALLOC_t *dci_alloc, - nfapi_nr_dl_config_request_pdu_t *pdu) + int frame, + int subframe, + gNB_rxtx_proc_t *proc, + NR_gNB_DCI_ALLOC_t *dci_alloc, + nfapi_nr_dl_config_request_pdu_t *pdu) { NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; - uint32_t *dci_pdu = &dci_alloc->dci_pdu[0]; - nfapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &pdu->dci_dl_pdu.dci_dl_pdu_rel15; + uint32_t *dci_pdu = dci_alloc->dci_pdu; + nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &pdu->dci_dl_pdu.dci_dl_pdu_rel15; + nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &pdu->dci_dl_pdu.pdcch_params_rel15; nfapi_nr_config_request_t *cfg = &gNB->gNB_config; - dci_alloc->L = rel15->aggregation_level; + uint16_t N_RB = fp->initial_bwp_dl.N_RB; + uint8_t fsize = 0; - if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_1_0) { + /// Payload generation + switch(params_rel15->dci_format) { + + case NFAPI_NR_DL_DCI_FORMAT_1_0: + switch(params_rel15->rnti_type) { + case NFAPI_NR_RNTI_RA: + // Freq domain assignment + fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + for (int i=0; ifrequency_domain_assignment>>(fsize-i))&1)<time_domain_assignment>>(4-i))&1)<mcs>>(5-i))&1)<tb_scaling>>(2-i))&1)<pdcch_params, (void*)params_rel15, sizeof(nfapi_nr_dl_config_pdcch_parameters_rel15_t)); + dci_alloc->size = nr_get_dci_size(NFAPI_NR_DL_DCI_FORMAT_1_0, + NFAPI_NR_RNTI_RA, + &fp->initial_bwp_dl, + cfg); + + + +/* if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_1_0) { dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_1_0; dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); if (rel15->rnti_type == NFAPI_NR_RNTI_C @@ -87,7 +127,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); } else { AssertFatal(1==0, "[nr_fill_dci_and_dlsch] Incorrect DCI Format(%d)",rel15->dci_format); - } + }*/ return; } diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 60fa298318..e699b76203 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -47,18 +47,10 @@ typedef struct { } NR_gNB_PBCH; typedef struct { - /// Length of DCI in bits + /// Length of DCI payload in bits uint8_t size; /// Aggregation level uint8_t L; - /// rnti - uint16_t rnti; - /// rnti type - nfapi_nr_rnti_type_e rnti_type; - /// search space type - nfapi_nr_search_space_type_e search_space_type; - /// Format - nfapi_nr_dci_format_e format; /// PDCCH parameters nfapi_nr_dl_config_pdcch_parameters_rel15_t pdcch_params; /// CCE list diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 8c5c24cb7c..ebcb29ee6b 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -62,11 +62,15 @@ #define NR_PBCH_DMRS_LENGTH 144 // in mod symbols #define NR_PBCH_DMRS_LENGTH_DWORD 10 // ceil(2(QPSK)*NR_PBCH_DMRS_LENGTH/32) -#define NR_MAX_PDCCH_DMRS_LENGTH ((NR_MAX_NB_RB<<1)*3) // 3 symbols *2(QPSK) -#define NR_MAX_PDCCH_DMRS_LENGTH_DWORD 52 // ceil(NR_MAX_PDCCH_DMRS_LENGTH/32) +/*These max values are for the gold sequences which are generated at init for the + * full carrier bandwidth*/ +#define NR_MAX_PDCCH_DMRS_INIT_LENGTH ((NR_MAX_NB_RB<<1)*3) // 3 symbols *2(QPSK) +#define NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD 52 // ceil(NR_MAX_PDCCH_DMRS_LENGTH/32) +/*used for the resource mapping*/ +#define NR_MAX_PDCCH_DMRS_LENGTH 576 // 16(L)*2(QPSK)*3(3 DMRS symbs per REG)*6(REG per CCE) #define NR_MAX_DCI_PAYLOAD_SIZE 64 -#define NR_MAX_DCI_SIZE 200 //random values +#define NR_MAX_DCI_SIZE 1728 //16(L)*2(QPSK)*9(12 RE per REG - 3(DMRS))*6(REG per CCE) #define NR_MAX_NUM_BWP 4 @@ -220,8 +224,8 @@ typedef struct NR_DL_FRAME_PARMS { t_nrPolar_params pbch_polar_params; //BWP params - NR_BWP_PARMS initial_bwp_params_dl; - NR_BWP_PARMS initial_bwp_params_ul; + NR_BWP_PARMS initial_bwp_dl; + NR_BWP_PARMS initial_bwp_ul; } NR_DL_FRAME_PARMS; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index c3a65cb7ca..0983acf891 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -417,12 +417,9 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, schedule_nr_mib(module_idP, frameP, subframeP); } - if (phy_test == 0) { - - } - else { - void nr_schedule_css_dlsch_phytest(module_idP, frameP, subframeP); - } + // Phytest scheduling/ option not activated because of pending bug + nr_schedule_css_dlsch_phytest(module_idP, frameP, subframeP); + /* // Allocate CCEs for good after scheduling is done diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index fe479915e0..bf3dd514b9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -41,8 +41,8 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, { uint8_t CC_id; - gNB_MAC_INST *gNB_mac = RC.mac[module_idP]; - NR_COMMON_channels_t *cc = gNB_mac->common_channels; + gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; + NR_COMMON_channels_t *cc = nr_mac->common_channels; nfapi_nr_dl_config_request_body_t *dl_req; nfapi_nr_dl_config_request_pdu_t *dl_config_pdu; @@ -53,7 +53,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, nfapi_nr_config_request_t *cfg = &gNB->gNB_config; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; - dl_req = &gNB_mac->DL_req[CC_id].dl_config_request_body; + dl_req = &nr_mac->DL_req[CC_id].dl_config_request_body; dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void*)dl_config_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE; @@ -61,33 +61,33 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel15; nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &dl_config_pdu->dci_dl_pdu.pdcch_params_rel15; + nr_configure_css_dci_from_mib(&gNB->pdcch_type0_params, kHz30, kHz30, nr_FR1, 0, 0, fp->slots_per_frame, cfg->rf_config.dl_channel_bandwidth.value); + memcpy((void*)params_rel15, (void*)&gNB->pdcch_type0_params, sizeof(nfapi_nr_dl_config_pdcch_parameters_rel15_t)); - pdu_rel15->frequency_domain_resource_assignment = 5; - pdu_rel15->time_domain_resource_assignment = 2; + pdu_rel15->frequency_domain_assignment = 5; + pdu_rel15->time_domain_assignment = 2; pdu_rel15->vrb_to_prb_mapping = 0; pdu_rel15->tb_scaling = 1; - LOG_I(PHY, "DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, tb_scaling %d\n", - pdu_rel15->frequency_domain_resource_assignment, - pdu_rel15->time_domain_resource_assignment, + LOG_I(MAC, "DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, tb_scaling %d\n", + pdu_rel15->frequency_domain_assignment, + pdu_rel15->time_domain_assignment, pdu_rel15->vrb_to_prb_mapping, pdu_rel15->tb_scaling); params_rel15->rnti = 0x03; params_rel15->rnti_type = NFAPI_NR_RNTI_RA; params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0; - params_rel15->aggregation_level = 4; - LOG_I(PHY, "DCI type 1 params: rmsi_pdcch_config, rnti %d, rnti_type %d, dci_format, L %d\n \ + LOG_I(MAC, "DCI type 1 params: rmsi_pdcch_config %d, rnti %d, rnti_type %d, dci_format %d\n \ coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d \n \ ss params : nb_ss_sets_per_slot %d, first symb %d, nb_slots %d, sfn_mod2 %d, first slot %d\n", 0, params_rel15->rnti, params_rel15->rnti_type, params_rel15->dci_format, - params_rel15->aggregation_level, params_rel15->mux_pattern, params_rel15->n_rb, params_rel15->n_symb, From 859aa1d28ceb83124cafefe4682a3370d3b56fbb Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Fri, 3 Aug 2018 11:27:08 +0200 Subject: [PATCH 022/114] Initial BWP config --- openair1/PHY/INIT/nr_parms.c | 16 +++++++++++++++- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 4 ++++ openair1/PHY/defs_nr_common.h | 11 +++++++---- .../CONF/gnb.band78.tm1.106PRB.usrpx300.conf | 12 ++++++------ 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index c541b4dc57..86a8a5afe5 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -40,7 +40,7 @@ int nr_init_frame_parms(nfapi_nr_config_request_t* config, LOG_I(PHY,"Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, N_RB, Ncp); #endif - if (Ncp == EXTENDED) + if (Ncp == NFAPI_CP_EXTENDED) AssertFatal(mu == NR_MU_2,"Invalid cyclic prefix %d for numerology index %d\n", Ncp, mu); switch(mu) { @@ -148,6 +148,14 @@ int nr_init_frame_parms(nfapi_nr_config_request_t* config, frame_parms->samples_per_frame = 10 * frame_parms->samples_per_subframe; frame_parms->freq_range = (frame_parms->dl_CarrierFreq < 6e9)? nr_FR1 : nr_FR2; + // Initial bandwidth part configuration -- full carrier bandwidth + frame_parms->initial_bwp_dl.bwp_id = 0; + frame_parms->initial_bwp_dl.scs = frame_parms->subcarrier_spacing; + frame_parms->initial_bwp_dl.location = 0; + frame_parms->initial_bwp_dl.N_RB = N_RB; + frame_parms->initial_bwp_dl.cyclic_prefix = Ncp; + frame_parms->initial_bwp_dl.ofdm_symbol_size = frame_parms->ofdm_symbol_size; + return 0; } @@ -300,4 +308,10 @@ void nr_dump_frame_parms(NR_DL_FRAME_PARMS *frame_parms) LOG_I(PHY,"frame_parms->samples_per_frame_wCP=%d\n",frame_parms->samples_per_frame_wCP); LOG_I(PHY,"frame_parms->samples_per_subframe=%d\n",frame_parms->samples_per_subframe); LOG_I(PHY,"frame_parms->samples_per_frame=%d\n",frame_parms->samples_per_frame); + LOG_I(PHY,"frame_parms->initial_bwp_dl.bwp_id=%d\n",frame_parms->initial_bwp_dl.bwp_id); + LOG_I(PHY,"frame_parms->initial_bwp_dl.scs=%d\n",frame_parms->initial_bwp_dl.scs); + LOG_I(PHY,"frame_parms->initial_bwp_dl.N_RB=%d\n",frame_parms->initial_bwp_dl.N_RB); + LOG_I(PHY,"frame_parms->initial_bwp_dl.cyclic_prefix=%d\n",frame_parms->initial_bwp_dl.cyclic_prefix); + LOG_I(PHY,"frame_parms->initial_bwp_dl.location=%d\n",frame_parms->initial_bwp_dl.location); + LOG_I(PHY,"frame_parms->initial_bwp_dl.ofdm_symbol_size=%d\n",frame_parms->initial_bwp_dl.ofdm_symbol_size); } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index c2ac37a23f..b43687a8ec 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -32,6 +32,7 @@ #include "nr_dci.h" + void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, int frame, int subframe, @@ -77,6 +78,9 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, break; } + LOG_I(MAC, "DCI PDU: [0]->0x%08x \t [0]->0x%08x [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]); + /// rest of DCI alloc memcpy((void*)&dci_alloc->pdcch_params, (void*)params_rel15, sizeof(nfapi_nr_dl_config_pdcch_parameters_rel15_t)); dci_alloc->size = nr_get_dci_size(NFAPI_NR_DL_DCI_FORMAT_1_0, diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index ebcb29ee6b..29e181d0fa 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -106,14 +106,18 @@ typedef enum { } nr_frequency_range_e; typedef struct NR_BWP_PARMS { - /// Associated numerology index - uint8_t numerology_index; - /// Freq domain location + /// BWP ID + uint8_t bwp_id; + /// Subcarrier spacing + nr_scs_e scs; + /// Freq domain location -- 1st CRB index uint8_t location; /// Bandwidth in PRB uint16_t N_RB; /// Size of FFT/IFFT uint16_t ofdm_symbol_size; + /// Cyclic prefix + uint8_t cyclic_prefix; } NR_BWP_PARMS; typedef struct { @@ -191,7 +195,6 @@ typedef struct NR_DL_FRAME_PARMS { uint8_t ttis_per_subframe; /// NR number of slots per tti . Assumption only 2 Slot per TTI is supported (Slot Config 1 in 38.211) uint8_t slots_per_tti; -//#endif /// Number of Physical transmit antennas in node uint8_t nb_antennas_tx; /// Number of Receive antennas in node diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf index 6e586c99c3..769ebcaaaa 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf @@ -53,11 +53,11 @@ gNBs = DL_FreqBandIndicatorNR = 15; DL_absoluteFrequencyPointA = 15; DL_offsetToCarrier = 15; - DL_SCS_SubcarrierSpacing = "kHz15"; + DL_SCS_SubcarrierSpacing = "kHz30"; DL_SCS_SpecificCarrier_k0 = 0; DL_carrierBandwidth = 15; DL_locationAndBandwidth = 15; - DL_BWP_SubcarrierSpacing = "kHz15"; + DL_BWP_SubcarrierSpacing = "kHz30"; DL_BWP_prefix_type = "NORMAL"; UL_FreqBandIndicatorNR = 15; UL_absoluteFrequencyPointA = 13; @@ -65,11 +65,11 @@ gNBs = UL_p_Max = -1; UL_frequencyShift7p5khz = "TRUE"; UL_offsetToCarrier = 10; - UL_SCS_SubcarrierSpacing = "kHz15"; + UL_SCS_SubcarrierSpacing = "kHz30"; UL_SCS_SpecificCarrier_k0 = 0; UL_carrierBandwidth = 15; UL_locationAndBandwidth = 15; - UL_BWP_SubcarrierSpacing = "kHz15"; + UL_BWP_SubcarrierSpacing = "kHz30"; UL_BWP_prefix_type = "NORMAL"; ServingCellConfigCommon__ssb_PositionsInBurst_PR = "shortBitmap"; ServingCellConfigCommon_ssb_periodicityServingCell = 10; @@ -102,7 +102,7 @@ gNBs = prach_RootSequenceIndex_choice = "l839"; prach_RootSequenceIndex_l839 = 0; prach_RootSequenceIndex_l139 = 0; - prach_msg1_SubcarrierSpacing = "kHz15"; + prach_msg1_SubcarrierSpacing = "kHz30"; restrictedSetConfig = "unrestrictedSet"; msg3_transformPrecoding = "ENABLE"; prach_ConfigurationIndex = 10; @@ -127,7 +127,7 @@ gNBs = symbolsInResourceBlock = "oneSlot"; periodicityAndPattern = 2; RateMatchPattern_controlResourceSet = 5; - RateMatchPattern_subcarrierSpacing = "kHz15"; + RateMatchPattern_subcarrierSpacing = "kHz30"; RateMatchPattern_mode = "dynamic"; searchSpaceSIB1 = 10; searchSpaceOtherSystemInformation = 10; From a24e5b1a2fc279805d699abfe4bfb5e324a72424 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Mon, 6 Aug 2018 11:04:30 +0200 Subject: [PATCH 023/114] Minor changes --- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 21 ++++++++++++------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 15 ++++++++++++- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index b43687a8ec..f706f3fd20 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -47,7 +47,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, nfapi_nr_config_request_t *cfg = &gNB->gNB_config; uint16_t N_RB = fp->initial_bwp_dl.N_RB; - uint8_t fsize = 0; + uint8_t fsize=0, pos=0; /// Payload generation switch(params_rel15->dci_format) { @@ -59,15 +59,21 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); for (int i=0; ifrequency_domain_assignment>>(fsize-i))&1)<vrb_to_prb_mapping&1)<time_domain_assignment>>(4-i))&1)<time_domain_assignment>>(4-i))&1)<<(pos+i); + pos += 4; //MCS for (int i=0; i<5; i++) - *dci_pdu |= ((pdu_rel15->mcs>>(5-i))&1)<mcs>>(5-i))&1)<<(pos+i); + pos += 5; // TB scaling for (int i=0; i<2; i++) - *dci_pdu |= ((pdu_rel15->tb_scaling>>(2-i))&1)<tb_scaling>>(2-i))&1)<<(pos+i); break; @@ -78,15 +84,16 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, break; } - LOG_I(MAC, "DCI PDU: [0]->0x%08x \t [0]->0x%08x [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + LOG_I(PHY, "DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]); /// rest of DCI alloc memcpy((void*)&dci_alloc->pdcch_params, (void*)params_rel15, sizeof(nfapi_nr_dl_config_pdcch_parameters_rel15_t)); - dci_alloc->size = nr_get_dci_size(NFAPI_NR_DL_DCI_FORMAT_1_0, - NFAPI_NR_RNTI_RA, + dci_alloc->size = nr_get_dci_size(dci_alloc->pdcch_params.dci_format, + dci_alloc->pdcch_params.rnti_type, &fp->initial_bwp_dl, cfg); + LOG_I(PHY, "DCI type %d payload (size %d) generated\n", dci_alloc->pdcch_params.dci_format, dci_alloc->size); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index bf3dd514b9..71f1e07e8c 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -45,6 +45,8 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, NR_COMMON_channels_t *cc = nr_mac->common_channels; nfapi_nr_dl_config_request_body_t *dl_req; nfapi_nr_dl_config_request_pdu_t *dl_config_pdu; + nfapi_tx_request_pdu_t *TX_req; + uint16_t sfn_sf = frameP << 4 | subframeP; for (CC_id=0; CC_idtime_domain_assignment = 2; pdu_rel15->vrb_to_prb_mapping = 0; pdu_rel15->tb_scaling = 1; - LOG_I(MAC, "DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, tb_scaling %d\n", + LOG_I(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, tb_scaling %d\n", pdu_rel15->frequency_domain_assignment, pdu_rel15->time_domain_assignment, pdu_rel15->vrb_to_prb_mapping, @@ -99,6 +101,17 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, params_rel15->first_slot); dl_req->number_dci++; dl_req->number_pdu++; + + TX_req = &nr_mac->TX_req[CC_id].tx_request_body.tx_pdu_list[nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus]; + TX_req->pdu_length = 6; + TX_req->pdu_index = nr_mac->pdu_index[CC_id]++; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = 8; + //TX_req->segments[0].segment_data = (uint8_t*)pdu_rel15; + nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus++; + nr_mac->TX_req[CC_id].sfn_sf = sfn_sf; + nr_mac->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + nr_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST; } } From 56448ab70d478cc80e0aae6192169e2104771654 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Mon, 6 Aug 2018 17:34:05 +0200 Subject: [PATCH 024/114] Addition of polar encoding to scheduler_phytest. --- openair1/PHY/CODING/TESTBENCH/polartest.c | 32 ++++--- .../nrPolar_tools/nr_bitwise_operations.c | 34 ++++--- .../CODING/nrPolar_tools/nr_polar_dci_defs.h | 6 +- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 17 +++- .../CODING/nrPolar_tools/nr_polar_encoder.c | 1 - .../CODING/nrPolar_tools/nr_polar_pbch_defs.h | 4 +- .../CODING/nrPolar_tools/nr_polar_uci_defs.h | 3 + openair1/PHY/CODING/nr_polar_init.c | 89 ++++++++++++++----- openair1/PHY/INIT/nr_init.c | 6 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 19 +++- openair1/PHY/NR_TRANSPORT/nr_dci.h | 1 + openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 7 +- openair1/PHY/defs_gNB.h | 4 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 5 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 1 + targets/RT/USER/nr-gnb.c | 5 +- 16 files changed, 170 insertions(+), 64 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 98a160f547..b9d52d849f 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -7,7 +7,7 @@ #include #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" +#include "PHY/NR_TRANSPORT/nr_dci.h" #include "PHY/defs_gNB.h" #include "SIMULATION/TOOLS/sim.h" @@ -20,6 +20,16 @@ int main(int argc, char *argv[]) { reset_meas(&timeEncoder); reset_meas(&timeDecoder); + //gNB scheduler + /*PHY_VARS_gNB *gNB = RC.gNB[0][0]; + NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; + nfapi_nr_config_request_t *cfg = &gNB->gNB_config; + + nfapi_nr_dl_config_request_pdu_t *pdu; + nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &pdu->dci_dl_pdu.pdcch_params_rel15; + params_rel15->rnti_type = NFAPI_NR_RNTI_RA; + params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0;*/ + randominit(0); //Default simulation values (Aim for iterations = 1000000.) int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, -1=UCI @@ -31,7 +41,7 @@ int main(int argc, char *argv[]) { uint16_t testLength, coderLength, blockErrorCumulative=0, bitErrorCumulative=0; double timeEncoderCumulative = 0, timeDecoderCumulative = 0; - uint8_t decoderListSize = 8, pathMetricAppr = 0; //0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12) + uint8_t aggregation_level, decoderListSize = 8, pathMetricAppr = 0; //0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12) while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:")) != -1) switch (arguments) @@ -73,9 +83,11 @@ int main(int argc, char *argv[]) { if (polarMessageType == 0) { //PBCH testLength = NR_POLAR_PBCH_PAYLOAD_BITS; coderLength = NR_POLAR_PBCH_E; + aggregation_level = NR_POLAR_PBCH_AGGREGATION_LEVEL; } else if (polarMessageType == 1) { //DCI - //testLength = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_ul ,cfg); - //coderLength = ; + //testLength = nr_get_dci_size(params_rel15->dci_format, params_rel15->rnti_type, &fp->initial_bwp_dl, cfg); + testLength = 20; + coderLength = 108; //to be changed by aggregate level function. } else if (polarMessageType == -1) { //UCI //testLength = ; //coderLength = ; @@ -112,16 +124,8 @@ int main(int argc, char *argv[]) { uint8_t *estimatedOutput = malloc(sizeof(uint8_t) * testLength); //decoder output t_nrPolar_paramsPtr nrPolar_params = NULL; - nr_polar_init(&nrPolar_params, polarMessageType, testLength); - - t_nrPolar_paramsPtr currentPtr = nrPolar_params; - while (currentPtr != NULL) { - if (currentPtr->idx == (polarMessageType * testLength)) { - break; - } else { - currentPtr = currentPtr->nextPtr; - } - } + nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); + t_nrPolar_paramsPtr currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength); // We assume no a priori knowledge available about the payload. double aPrioriArray[currentPtr->payloadBits]; diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c index 8e4953574c..ea47405d5b 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c @@ -21,17 +21,29 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -void nr_byte2bit(uint8_t *array, uint8_t arraySize, uint8_t *bitArray){//First 2 parameters are in bytes. +void nr_byte2bit_uint8(uint8_t *array, uint8_t arraySize, uint8_t *bitArray) { + //First 2 parameters are in bytes. - for (int i=0; i>0 & 0x01); - bitArray[(6+(i*8))] = ( array[i]>>1 & 0x01); - bitArray[(5+(i*8))] = ( array[i]>>2 & 0x01); - bitArray[(4+(i*8))] = ( array[i]>>3 & 0x01); - bitArray[(3+(i*8))] = ( array[i]>>4 & 0x01); - bitArray[(2+(i*8))] = ( array[i]>>5 & 0x01); - bitArray[(1+(i*8))] = ( array[i]>>6 & 0x01); - bitArray[ (i*8) ] = ( array[i]>>7 & 0x01); + for (int i = 0; i < arraySize; i++) { + bitArray[(7 + (i * 8))] = (array[i] >> 0 & 0x01); + bitArray[(6 + (i * 8))] = (array[i] >> 1 & 0x01); + bitArray[(5 + (i * 8))] = (array[i] >> 2 & 0x01); + bitArray[(4 + (i * 8))] = (array[i] >> 3 & 0x01); + bitArray[(3 + (i * 8))] = (array[i] >> 4 & 0x01); + bitArray[(2 + (i * 8))] = (array[i] >> 5 & 0x01); + bitArray[(1 + (i * 8))] = (array[i] >> 6 & 0x01); + bitArray[(i * 8)] = (array[i] >> 7 & 0x01); + } +} + +void nr_bit2byte(uint32_t *in, uint16_t arraySize, uint8_t *out) { + for (int i = 0; i < arraySize; i++) { + out[i] = ((*in) >> i) & 1; + } +} + +void nr_byte2bit(uint8_t *in, uint16_t arraySize, uint32_t *out) { + for (int i = 0; i < arraySize; i++) { + *out = (*out) << i | in[i]; } - } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h index 6c28a594f2..842088b26c 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h @@ -33,10 +33,14 @@ #ifndef __NR_POLAR_DCI_DEFS__H__ #define __NR_POLAR_DCI_DEFS__H__ +#define NR_POLAR_DCI_MESSAGE_TYPE 1 //int8_t +#define NR_POLAR_DCI_CRC_PARITY_BITS 24 +#define NR_POLAR_DCI_CRC_ERROR_CORRECTION_BITS 3 + //Sec. 7.3.3: Channel Coding #define NR_POLAR_DCI_N_MAX 9 //uint8_t #define NR_POLAR_DCI_I_IL 1 //uint8_t -//#define NR_POLAR_DCI_I_SEG 0 //uint8_t +#define NR_POLAR_DCI_I_SEG 0 //uint8_t #define NR_POLAR_DCI_N_PC 0 //uint8_t #define NR_POLAR_DCI_N_PC_WM 0 //uint8_t diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index b5d2496f43..574b199c50 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -28,6 +28,10 @@ #include #include +#include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h" +#include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" +#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" + static const uint8_t nr_polar_subblock_interleaver_pattern[32] = { 0, 1, 2, 4, 3, 5, 6, 7, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 14, 22, 15, 23, 24, 25, 26, 28, 27, 29, 30, 31 }; struct nrPolar_params { @@ -76,7 +80,14 @@ void polar_encoder(uint8_t *input, uint8_t *output, t_nrPolar_paramsPtr polarPar int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_paramsPtr polarParams, uint8_t listSize, double *aPrioriPayload, uint8_t pathMetricAppr); -void nr_polar_init(t_nrPolar_paramsPtr *polarParams, int8_t messageType, uint16_t messageLength); +void nr_polar_init(t_nrPolar_paramsPtr *polarParams, + int8_t messageType, + uint16_t messageLength, + uint8_t aggregation_level); +void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams); +t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams, + int8_t messageType, + uint16_t messageLength); uint8_t** nr_polar_kronecker_power_matrices(uint8_t n); @@ -102,7 +113,9 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, int16_t *Q_I_N, int16_t *Q_F_N, void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *output, uint8_t *pattern, uint16_t size); -void nr_byte2bit(uint8_t *array, uint8_t arraySize, uint8_t *bitArray); +void nr_byte2bit(uint8_t *in, uint16_t arraySize, uint32_t *out); +void nr_byte2bit_uint8(uint8_t *array, uint8_t arraySize, uint8_t *bitArray); +void nr_bit2byte(uint32_t *in, uint16_t arraySize, uint8_t *out); void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, uint16_t N, uint16_t K, int16_t *Q_I_N, int16_t *Q_PC_N, uint8_t n_PC); diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 74fb6bd900..eafb45cab4 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -20,7 +20,6 @@ */ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" void polar_encoder( uint8_t *input, diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h index 85b20f90fc..aa32b03e35 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h @@ -33,7 +33,9 @@ #ifndef __NR_POLAR_PBCH_DEFS__H__ #define __NR_POLAR_PBCH_DEFS__H__ -#define NR_POLAR_PBCH_PAYLOAD_BITS 32 //uint16_t +#define NR_POLAR_PBCH_AGGREGATION_LEVEL 0 //uint8_t +#define NR_POLAR_PBCH_MESSAGE_TYPE 0 //int8_t +#define NR_POLAR_PBCH_PAYLOAD_BITS 32 //uint16_t #define NR_POLAR_PBCH_CRC_PARITY_BITS 24 #define NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS 3 //Assumed 3 by 3GPP when NR_POLAR_PBCH_L>8 to meet false alarm rate requirements. diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h index 214267d94c..724da73fa0 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h @@ -33,4 +33,7 @@ #ifndef __NR_POLAR_UCI_DEFS__H__ #define __NR_POLAR_UCI_DEFS__H__ +#define NR_POLAR_UCI_MESSAGE_TYPE -1 //int8_t +#define NR_POLAR_UCI_CRC_ERROR_CORRECTION_BITS 3 + #endif diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index 2f781e4a23..c0dcdf7b0b 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -20,13 +20,16 @@ */ #include "nrPolar_tools/nr_polar_defs.h" -#include "nrPolar_tools/nr_polar_pbch_defs.h" +#include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h" +#include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" +#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" #include "PHY/NR_TRANSPORT/nr_dci.h" void nr_polar_init(t_nrPolar_paramsPtr *polarParams, int8_t messageType, - uint16_t messageLength) { - + uint16_t messageLength, + uint8_t aggregation_level) +{ t_nrPolar_paramsPtr currentPtr = *polarParams; t_nrPolar_paramsPtr previousPtr = NULL; @@ -55,35 +58,45 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, newPolarInitNode->n_pc = NR_POLAR_PBCH_N_PC; newPolarInitNode->n_pc_wm = NR_POLAR_PBCH_N_PC_WM; newPolarInitNode->i_bil = NR_POLAR_PBCH_I_BIL; + newPolarInitNode->crcParityBits = NR_POLAR_PBCH_CRC_PARITY_BITS; newPolarInitNode->payloadBits = NR_POLAR_PBCH_PAYLOAD_BITS; newPolarInitNode->encoderLength = NR_POLAR_PBCH_E; - newPolarInitNode->crcParityBits = NR_POLAR_PBCH_CRC_PARITY_BITS; newPolarInitNode->crcCorrectionBits = NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS; - - newPolarInitNode->K = newPolarInitNode->payloadBits + newPolarInitNode->crcParityBits; // Number of bits to encode. - newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K, newPolarInitNode->encoderLength, newPolarInitNode->n_max); - newPolarInitNode->n = log2(newPolarInitNode->N); - - newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits); - newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n); - - //polar_encoder vectors: - newPolarInitNode->nr_polar_crc = malloc(sizeof(uint8_t) * newPolarInitNode->crcParityBits); - newPolarInitNode->nr_polar_cPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); - newPolarInitNode->nr_polar_d = malloc(sizeof(uint8_t) * newPolarInitNode->N); - - //Polar Coding vectors - newPolarInitNode->nr_polar_u = malloc(sizeof(uint8_t) * newPolarInitNode->N); //Decoder: nr_polar_uHat - newPolarInitNode->nr_polar_cPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_cHat - newPolarInitNode->nr_polar_b = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_bHat } else if (messageType == 1) { //DCI - + newPolarInitNode->n_max = NR_POLAR_DCI_N_MAX; + newPolarInitNode->i_il = NR_POLAR_DCI_I_IL; + newPolarInitNode->i_seg = NR_POLAR_DCI_I_SEG; + newPolarInitNode->n_pc = NR_POLAR_DCI_N_PC; + newPolarInitNode->n_pc_wm = NR_POLAR_DCI_N_PC_WM; + newPolarInitNode->i_bil = NR_POLAR_DCI_I_BIL; + newPolarInitNode->crcParityBits = NR_POLAR_DCI_CRC_PARITY_BITS; + newPolarInitNode->payloadBits = messageLength; + newPolarInitNode->encoderLength = aggregation_level*108; + newPolarInitNode->crcCorrectionBits = NR_POLAR_DCI_CRC_ERROR_CORRECTION_BITS; } else if (messageType == -1) { //UCI } else { AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType); } + newPolarInitNode->K = newPolarInitNode->payloadBits + newPolarInitNode->crcParityBits; // Number of bits to encode. + newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K, newPolarInitNode->encoderLength, newPolarInitNode->n_max); + newPolarInitNode->n = log2(newPolarInitNode->N); + + newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits); + newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n); + + //polar_encoder vectors: + newPolarInitNode->nr_polar_crc = malloc(sizeof(uint8_t) * newPolarInitNode->crcParityBits); + newPolarInitNode->nr_polar_cPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); + newPolarInitNode->nr_polar_d = malloc(sizeof(uint8_t) * newPolarInitNode->N); + + //Polar Coding vectors + newPolarInitNode->nr_polar_u = malloc(sizeof(uint8_t) * newPolarInitNode->N); //Decoder: nr_polar_uHat + newPolarInitNode->nr_polar_cPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_cHat + newPolarInitNode->nr_polar_b = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_bHat + + newPolarInitNode->Q_0_Nminus1 = nr_polar_sequence_pattern(newPolarInitNode->n); newPolarInitNode->interleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K); @@ -141,3 +154,35 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, currentPtr->nextPtr= newPolarInitNode; return; } + +void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams) +{ + uint8_t i = 0; + if (polarParams == NULL) { + printf("polarParams is empty.\n"); + } else { + while (polarParams != NULL){ + printf("polarParams[%d] = %d\n", i, polarParams->idx); + polarParams = polarParams->nextPtr; + i++; + } + } + return; +} + +t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams, + int8_t messageType, + uint16_t messageLength) +{ + t_nrPolar_paramsPtr currentPtr; + + while (polarParams != NULL) { + if (polarParams->idx == (messageType * messageLength)) { + currentPtr = polarParams; + break; + } else { + polarParams = polarParams->nextPtr; + } + } + return currentPtr; +} diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index ef7a9235d0..d15c39e222 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -119,7 +119,11 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, // PBCH DMRS gold sequences generation nr_init_pbch_dmrs(gNB); // Polar encoder init for PBCH - nr_polar_init(&fp->pbch_polar_params, 1, NR_POLAR_PBCH_PAYLOAD_BITS); + nr_polar_init(&fp->pbch_polar_params, + NR_POLAR_PBCH_MESSAGE_TYPE, + NR_POLAR_PBCH_PAYLOAD_BITS, + NR_POLAR_PBCH_AGGREGATION_LEVEL); + //PDCCH DMRS init gNB->nr_gold_pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**)); uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 7de08ee5d6..fad9cd3a18 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -148,11 +148,12 @@ void nr_pdcch_scrambling(uint32_t *in, reset = 0; } *out ^= (((*in)>>i)&1) ^ ((s>>i)&1); - } + } } uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, + t_nrPolar_paramsPtr *nrPolar_params, uint32_t *gold_pdcch_dmrs, int32_t** txdataF, int16_t amp, @@ -187,13 +188,25 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, } /// DCI payload processing - //channel coding + //channel coding + uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); + nr_bit2byte(dci_alloc.dci_pdu, dci_alloc.size, encoderInput); + + nr_polar_init(&nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, pdcch_params.aggregation_level); + t_nrPolar_paramsPtr currentPtr = nr_polar_params(nrPolar_params, + NR_POLAR_DCI_MESSAGE_TYPE, + dci_alloc.size); + + uint8_t *encoderOutput = malloc(sizeof(uint8_t) * currentPtr->encoderLength); + polar_encoder(encoderInput, encoderOutput, currentPtr); + uint32_t encoded_payload[4]; + nr_byte2bit(encoderOutput,currentPtr->encoderLength,encoded_payload); // scrambling uint32_t scrambled_payload[4]; uint32_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value; uint32_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; - nr_pdcch_scrambling(dci_alloc.dci_pdu, dci_alloc.size, Nid, n_RNTI, scrambled_payload); + nr_pdcch_scrambling(encoded_payload, dci_alloc.size, Nid, n_RNTI, scrambled_payload); // QPSK modulation uint32_t mod_dci[NR_MAX_DCI_SIZE>>1]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index ff33f1ee41..681283cbe9 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -33,6 +33,7 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, nfapi_nr_config_request_t* config); uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, + t_nrPolar_paramsPtr *nrPolar_params, uint32_t *gold_pdcch_dmrs, int32_t** txdataF, int16_t amp, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index b43687a8ec..98894ef98a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -43,11 +43,11 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; uint32_t *dci_pdu = dci_alloc->dci_pdu; nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &pdu->dci_dl_pdu.dci_dl_pdu_rel15; - nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &pdu->dci_dl_pdu.pdcch_params_rel15; + nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &pdu->dci_dl_pdu.pdcch_params_rel15; nfapi_nr_config_request_t *cfg = &gNB->gNB_config; - uint16_t N_RB = fp->initial_bwp_dl.N_RB; - uint8_t fsize = 0; + uint16_t N_RB = fp->initial_bwp_dl.N_RB; + uint8_t fsize = 0; /// Payload generation switch(params_rel15->dci_format) { @@ -68,7 +68,6 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // TB scaling for (int i=0; i<2; i++) *dci_pdu |= ((pdu_rel15->tb_scaling>>(2-i))&1)<frame_tx; @@ -188,6 +188,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, if (nfapi_mode == 0 || nfapi_mode == 1) nr_generate_dci_top(gNB->pdcch_vars, + &gNB->nrPolar_params, gNB->nr_gold_pdcch_dmrs[0][0], gNB->common_vars.txdataF, AMP, *fp, *cfg); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index bf3dd514b9..97d8c0d6ca 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -81,6 +81,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, params_rel15->rnti = 0x03; params_rel15->rnti_type = NFAPI_NR_RNTI_RA; params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0; + params_rel15->aggregation_level = 1; LOG_I(MAC, "DCI type 1 params: rmsi_pdcch_config %d, rnti %d, rnti_type %d, dci_format %d\n \ coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d \n \ ss params : nb_ss_sets_per_slot %d, first symb %d, nb_slots %d, sfn_mod2 %d, first slot %d\n", diff --git a/targets/RT/USER/nr-gnb.c b/targets/RT/USER/nr-gnb.c index 09b95502c1..27d233bedb 100644 --- a/targets/RT/USER/nr-gnb.c +++ b/targets/RT/USER/nr-gnb.c @@ -916,7 +916,10 @@ void init_gNB(int single_thread_flag,int wait_for_sync) { gNB = RC.gNB[inst][CC_id]; gNB->abstraction_flag = 0; gNB->single_thread_flag = single_thread_flag; - + nr_polar_init(&gNB->nrPolar_params, + NR_POLAR_PBCH_MESSAGE_TYPE, + NR_POLAR_PBCH_PAYLOAD_BITS, + NR_POLAR_PBCH_AGGREGATION_LEVEL); LOG_I(PHY,"Initializing gNB %d CC_id %d single_thread_flag:%d\n",inst,CC_id,single_thread_flag); #ifndef OCP_FRAMEWORK From fa1fb8e58b309efa9c5f179e4a3e116e22d780fc Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Tue, 7 Aug 2018 11:14:24 +0200 Subject: [PATCH 025/114] Phytest scheduler fix --- openair1/SCHED_NR/fapi_nr_l1.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index 689bc63556..8f6217063e 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -61,12 +61,11 @@ void handle_nfapi_nr_dci_dl_pdu(PHY_VARS_gNB *gNB, { int idx = subframe&1; NR_gNB_PDCCH *pdcch_vars = &gNB->pdcch_vars; - nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu = &dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel15; LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populating pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",frame,subframe, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); // copy dci configuration into gNB structure - nr_fill_dci_and_dlsch(gNB,frame,subframe,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],pdu); + nr_fill_dci_and_dlsch(gNB,frame,subframe,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],dl_config_pdu); LOG_D(PHY,"Frame %d, Subframe %d: DCI processing - populated pdcch_vars->dci_alloc[%d] proc:subframe_tx:%d idx:%d pdcch_vars->num_dci:%d\n",proc->frame_tx,proc->subframe_tx, pdcch_vars->num_dci, proc->subframe_tx, idx, pdcch_vars->num_dci); } From 8060ffedf3c2751aecaf8bce20d512f1ba6d3334 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Tue, 7 Aug 2018 14:13:14 +0200 Subject: [PATCH 026/114] Payload generation fix --- .../nfapi/public_inc/nfapi_nr_interface.h | 2 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 4 ++-- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 15 ++++++++------- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 4 +++- 4 files changed, 14 insertions(+), 11 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 17bd564f2f..eb953b2c34 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -305,7 +305,7 @@ typedef struct { nfapi_tl_t tl; uint8_t format_indicator; //1 bit -uint16_t frequency_domain_assignment; //up to 9 bits +uint16_t frequency_domain_assignment; //up to 16 bits uint8_t time_domain_assignment; // 4 bits uint8_t frequency_hopping_flag; //1 bit diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index fad9cd3a18..ddf21d062d 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -32,8 +32,8 @@ #include "nr_dci.h" -#define DEBUG_PDCCH_DMRS -#define DEBUG_DCI +//#define DEBUG_PDCCH_DMRS +//#define DEBUG_DCI extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index c34428b6b0..a47f32d6e0 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -42,6 +42,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, { NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; uint32_t *dci_pdu = dci_alloc->dci_pdu; + memset((void*)dci_pdu,0,4*sizeof(uint32_t)); nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &pdu->dci_dl_pdu.dci_dl_pdu_rel15; nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &pdu->dci_dl_pdu.pdcch_params_rel15; nfapi_nr_config_request_t *cfg = &gNB->gNB_config; @@ -58,22 +59,22 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // Freq domain assignment fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); for (int i=0; ifrequency_domain_assignment>>(fsize-i))&1)<frequency_domain_assignment>>(fsize-i-1))&1)<time_domain_assignment>>(3-i))&1)<<(pos+i); + pos += 4; // VRB to PRB mapping *dci_pdu |= (pdu_rel15->vrb_to_prb_mapping&1)<time_domain_assignment>>(4-i))&1)<<(pos+i); - pos += 4; //MCS for (int i=0; i<5; i++) - *dci_pdu |= ((pdu_rel15->mcs>>(5-i))&1)<<(pos+i); + *dci_pdu |= ((pdu_rel15->mcs>>(4-i))&1)<<(pos+i); pos += 5; // TB scaling for (int i=0; i<2; i++) - *dci_pdu |= ((pdu_rel15->tb_scaling>>(2-i))&1)<<(pos+i); + *dci_pdu |= ((pdu_rel15->tb_scaling>>(1-i))&1)<<(pos+i); break; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 6c65066a2e..1868d987a4 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -73,11 +73,13 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, pdu_rel15->frequency_domain_assignment = 5; pdu_rel15->time_domain_assignment = 2; pdu_rel15->vrb_to_prb_mapping = 0; + pdu_rel15->mcs = 12; pdu_rel15->tb_scaling = 1; - LOG_I(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, tb_scaling %d\n", + LOG_I(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d\n", pdu_rel15->frequency_domain_assignment, pdu_rel15->time_domain_assignment, pdu_rel15->vrb_to_prb_mapping, + pdu_rel15->mcs, pdu_rel15->tb_scaling); params_rel15->rnti = 0x03; From 74ec8b31339ef2cf8581d88caff5f9d250ae65c2 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Tue, 7 Aug 2018 17:01:29 +0200 Subject: [PATCH 027/114] temp debug commit --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 16 +++++++++------- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index ddf21d062d..40ecfc1e6a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -170,6 +170,8 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, /*First iteration: single DCI*/ NR_gNB_DCI_ALLOC_t dci_alloc = pdcch_vars.dci_alloc[0]; nfapi_nr_dl_config_pdcch_parameters_rel15_t pdcch_params = dci_alloc.pdcch_params; + uint16_t dmrs_length = dci_alloc.L*36; //2(QPSK)*3(per RB)*6(REG per CCE) + uint16_t encoded_length = dci_alloc.L*108; //2(QPSK)*9(per RB)*6(REG per CCE) /// DMRS QPSK modulation /*There is a need to shift from which index the pregenerated DMRS sequence is used @@ -177,19 +179,19 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, if (pdcch_params.config_type == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG) gold_pdcch_dmrs += ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+pdcch_params.rb_offset)*3/32; - for (int i=0; i>1; i++) { + for (int i=0; i>1; i++) { idx = ((((gold_pdcch_dmrs[(i<<1)>>5])>>((i<<1)&0x1f))&1)<<1) ^ (((gold_pdcch_dmrs[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1); mod_dmrs[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; mod_dmrs[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; #ifdef DEBUG_PDCCH_DMRS - printf("i %d idx %d gold seq %d b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, gold_pdcch_dmrs[(i<<1)>>5], (((gold_pdcch_dmrs[(i<<1)>>5])>>((i<<1)&0x1f))&1), + printf("i %d idx %d gold seq %u b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, gold_pdcch_dmrs[(i<<1)>>5], (((gold_pdcch_dmrs[(i<<1)>>5])>>((i<<1)&0x1f))&1), (((gold_pdcch_dmrs[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), mod_dmrs[(i<<1)], mod_dmrs[(i<<1)+1]); #endif } /// DCI payload processing //channel coding - uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); + /*uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); nr_bit2byte(dci_alloc.dci_pdu, dci_alloc.size, encoderInput); nr_polar_init(&nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, pdcch_params.aggregation_level); @@ -200,17 +202,17 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, uint8_t *encoderOutput = malloc(sizeof(uint8_t) * currentPtr->encoderLength); polar_encoder(encoderInput, encoderOutput, currentPtr); uint32_t encoded_payload[4]; - nr_byte2bit(encoderOutput,currentPtr->encoderLength,encoded_payload); + nr_byte2bit(encoderOutput,currentPtr->encoderLength,encoded_payload);*/ // scrambling uint32_t scrambled_payload[4]; uint32_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value; uint32_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; - nr_pdcch_scrambling(encoded_payload, dci_alloc.size, Nid, n_RNTI, scrambled_payload); + nr_pdcch_scrambling(dci_alloc.dci_pdu, dci_alloc.size, Nid, n_RNTI, scrambled_payload); // QPSK modulation - uint32_t mod_dci[NR_MAX_DCI_SIZE>>1]; - for (int i=0; i>1; i++) { + uint16_t mod_dci[NR_MAX_DCI_SIZE>>1]; + for (int i=0; i>1; i++) { idx = (((scrambled_payload[i<<1]>>(i<<1))&1)<<1) ^ ((scrambled_payload[(i<<1)+1]>>((i<<1)+1))&1); mod_dci[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; mod_dci[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index a47f32d6e0..850507f839 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -68,7 +68,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // VRB to PRB mapping *dci_pdu |= (pdu_rel15->vrb_to_prb_mapping&1)<mcs>>(4-i))&1)<<(pos+i); pos += 5; @@ -89,6 +89,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]); /// rest of DCI alloc + dci_alloc->L = 2; memcpy((void*)&dci_alloc->pdcch_params, (void*)params_rel15, sizeof(nfapi_nr_dl_config_pdcch_parameters_rel15_t)); dci_alloc->size = nr_get_dci_size(dci_alloc->pdcch_params.dci_format, dci_alloc->pdcch_params.rnti_type, From 1095760c4e6cf14b34de9acca37a59ecf557443e Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Wed, 8 Aug 2018 16:25:35 +0200 Subject: [PATCH 028/114] CCE list --- .../nfapi/public_inc/nfapi_nr_interface.h | 3 + openair1/PHY/NR_TRANSPORT/nr_dci.c | 4 +- openair1/PHY/NR_TRANSPORT/nr_dci.h | 12 +++- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 57 ++++++++++++++++++- openair1/SCHED_NR/phy_procedures_nr_common.c | 2 + 5 files changed, 72 insertions(+), 6 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 eb953b2c34..757d546e51 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h @@ -411,6 +411,9 @@ typedef struct { uint8_t n_symb; uint8_t rb_offset; uint8_t cr_mapping_type; + uint8_t reg_bundle_size; + uint8_t interleaver_size; + uint8_t shift_index; uint8_t mux_pattern; uint8_t precoder_granularity; uint8_t first_slot; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 40ecfc1e6a..213fa6571d 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -161,7 +161,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, nfapi_nr_config_request_t config) { - uint16_t mod_dmrs[NR_MAX_PDCCH_DMRS_LENGTH>>1]; + int16_t mod_dmrs[NR_MAX_PDCCH_DMRS_LENGTH>>1]; uint8_t idx=0; uint16_t a; int k,l,k_prime,dci_idx, dmrs_idx; @@ -211,7 +211,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, nr_pdcch_scrambling(dci_alloc.dci_pdu, dci_alloc.size, Nid, n_RNTI, scrambled_payload); // QPSK modulation - uint16_t mod_dci[NR_MAX_DCI_SIZE>>1]; + int16_t mod_dci[NR_MAX_DCI_SIZE>>1]; for (int i=0; i>1; i++) { idx = (((scrambled_payload[i<<1]>>(i<<1))&1)<<1) ^ ((scrambled_payload[(i<<1)+1]>>((i<<1)+1))&1); mod_dci[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index 681283cbe9..e1e56becbe 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -33,7 +33,7 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, nfapi_nr_config_request_t* config); uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, - t_nrPolar_paramsPtr *nrPolar_params, + t_nrPolar_paramsPtr *nrPolar_params, uint32_t *gold_pdcch_dmrs, int32_t** txdataF, int16_t amp, @@ -46,4 +46,14 @@ void nr_pdcch_scrambling(uint32_t *in, uint32_t n_RNTI, uint32_t* out); +void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, + int frame, + int subframe, + gNB_rxtx_proc_t *proc, + NR_gNB_DCI_ALLOC_t *dci_alloc, + nfapi_nr_dl_config_request_pdu_t *pdu); + +void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m); + + #endif //__PHY_NR_TRANSPORT_DCI__H diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 850507f839..96e8cc50cc 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -33,6 +33,54 @@ #include "nr_dci.h" + +void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m) { + + nr_cce_t* cce; + nr_reg_t* reg; + nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params = &dci_alloc->pdcch_params; + + uint8_t L = dci_alloc->L; + uint8_t bsize = pdcch_params->reg_bundle_size; + uint8_t R = pdcch_params->interleaver_size; + uint16_t N_reg = pdcch_params->n_rb * pdcch_params->n_symb; + uint16_t Y, N_cce, M_s_max, n_CI=0, tmp, C; + + if (pdcch_params->config_type == NFAPI_NR_CSET_CONFIG_MIB_SIB1) + AssertFatal(L>=4, "Invalid aggregation level for SIB1 configured PDCCH %d\n", L); + + N_cce = N_reg / NR_NB_REG_PER_CCE; + /*Max number of candidates per aggregation level*/ + M_s_max = (L==4)?4:(L==8)?2:1; + + if (pdcch_params->search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_COMMON) + Y = 0; + else { //NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC + } + + AssertFatal((N_reg%(bsize*R))==0, "CCE to REG interleaving: Invalid configuration leading to non integer C\n"); + C = N_reg/(bsize*R); + + tmp = L * (( Y + (uint16_t)(floor((m*N_cce)/(L*M_s_max))) + n_CI ) % ((uint16_t)floor(N_cce/L))); + + LOG_I(PHY, "CCE list generation for candidate %d: bundle size %d ilv size %d tmp %d\n", m, bsize, R, tmp); + for (uint8_t cce_idx=0; cce_idxcce_list[cce_idx]; + cce->cce_idx = tmp + cce_idx; + LOG_I(PHY, "cce_idx %d\n", cce->cce_idx); + + for (uint8_t reg_idx=0; reg_idxreg_list[reg_idx]; + if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { + + } + else { // NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED + + } + } + } +} + void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, int frame, int subframe, @@ -41,6 +89,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, nfapi_nr_dl_config_request_pdu_t *pdu) { NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; + uint8_t n_shift; uint32_t *dci_pdu = dci_alloc->dci_pdu; memset((void*)dci_pdu,0,4*sizeof(uint32_t)); nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &pdu->dci_dl_pdu.dci_dl_pdu_rel15; @@ -48,7 +97,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, nfapi_nr_config_request_t *cfg = &gNB->gNB_config; uint16_t N_RB = fp->initial_bwp_dl.N_RB; - uint8_t fsize=0, pos=0; + uint8_t fsize=0, pos=0, cand_idx=0; /// Payload generation switch(params_rel15->dci_format) { @@ -89,12 +138,15 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]); /// rest of DCI alloc - dci_alloc->L = 2; + dci_alloc->L = 4; memcpy((void*)&dci_alloc->pdcch_params, (void*)params_rel15, sizeof(nfapi_nr_dl_config_pdcch_parameters_rel15_t)); dci_alloc->size = nr_get_dci_size(dci_alloc->pdcch_params.dci_format, dci_alloc->pdcch_params.rnti_type, &fp->initial_bwp_dl, cfg); + n_shift = (dci_alloc->pdcch_params.config_type == NFAPI_NR_CSET_CONFIG_MIB_SIB1)? + cfg->sch_config.physical_cell_id.value : dci_alloc->pdcch_params.shift_index; + nr_fill_cce_list(dci_alloc, n_shift, cand_idx); LOG_I(PHY, "DCI type %d payload (size %d) generated\n", dci_alloc->pdcch_params.dci_format, dci_alloc->size); @@ -144,4 +196,3 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, return; } - diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c index da39ceca4b..ad73457cb3 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_common.c +++ b/openair1/SCHED_NR/phy_procedures_nr_common.c @@ -168,6 +168,8 @@ void nr_configure_css_dci_from_mib(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params->config_type = NFAPI_NR_CSET_CONFIG_MIB_SIB1; pdcch_params->cr_mapping_type = NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED; pdcch_params->precoder_granularity = NFAPI_NR_CSET_SAME_AS_REG_BUNDLE; + pdcch_params->reg_bundle_size = 6; + pdcch_params->interleaver_size = 2; } void nr_configure_css_dci_from_pdcch_config(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params, From fa509297f48cae42074716e168283e5815ba870a Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Wed, 8 Aug 2018 17:48:55 +0200 Subject: [PATCH 029/114] Non interleaved REG mapping --- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 96e8cc50cc..4696caab93 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -67,15 +67,17 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m for (uint8_t cce_idx=0; cce_idxcce_list[cce_idx]; cce->cce_idx = tmp + cce_idx; - LOG_I(PHY, "cce_idx %d\n", cce->cce_idx); + LOG_D(PHY, "cce_idx %d\n", cce->cce_idx); for (uint8_t reg_idx=0; reg_idxreg_list[reg_idx]; - if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { + if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED) { } else { // NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED - + reg->start_sc_idx = (cce->cce_idx/pdcch_params->n_symb*NR_NB_REG_PER_CCE + reg_idx) * NR_NB_SC_PER_RB; + reg->symb_idx = cce->cce_idx % pdcch_params->n_symb; + LOG_I(PHY, "reg %d symbol %d start subcarrier %d\n", reg_idx, reg->symb_idx, reg->start_sc_idx); } } } From acfc5e6ca051ead91567c05a7100abceff30cc0f Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Thu, 9 Aug 2018 15:58:21 +0200 Subject: [PATCH 030/114] CR interleaved --- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 44 +++++++++++++++++------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 4696caab93..94aad0bee2 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -32,8 +32,6 @@ #include "nr_dci.h" - - void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m) { nr_cce_t* cce; @@ -50,7 +48,7 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m AssertFatal(L>=4, "Invalid aggregation level for SIB1 configured PDCCH %d\n", L); N_cce = N_reg / NR_NB_REG_PER_CCE; - /*Max number of candidates per aggregation level*/ + /*Max number of candidates per aggregation level -- SIB1 configured search space only*/ M_s_max = (L==4)?4:(L==8)?2:1; if (pdcch_params->search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_COMMON) @@ -69,17 +67,37 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m cce->cce_idx = tmp + cce_idx; LOG_D(PHY, "cce_idx %d\n", cce->cce_idx); - for (uint8_t reg_idx=0; reg_idxreg_list[reg_idx]; - if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED) { - - } - else { // NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED - reg->start_sc_idx = (cce->cce_idx/pdcch_params->n_symb*NR_NB_REG_PER_CCE + reg_idx) * NR_NB_SC_PER_RB; - reg->symb_idx = cce->cce_idx % pdcch_params->n_symb; - LOG_I(PHY, "reg %d symbol %d start subcarrier %d\n", reg_idx, reg->symb_idx, reg->start_sc_idx); + if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { + LOG_I(PHY, "Interleaved CCE to REG mapping\n"); + uint8_t j = cce->cce_idx, j_prime; + uint8_t r,c,idx; + + + for (uint8_t reg_idx=0; reg_idxreg_list[reg_idx]; + j_prime = 6*j/bsize + reg_idx; + r = j_prime%R; + c = (j_prime-r)/R; + idx = (r*C + c + n_shift)%(N_reg/bsize); + reg->reg_idx = idx; + LOG_I(PHY, "j = %d \t j_prime = %d \t r = %d \t c = %d \t idx = %d\n", j , j_prime, r, c, idx); + reg->start_sc_idx = (idx/pdcch_params->n_symb) * NR_NB_SC_PER_RB; + reg->symb_idx = idx % pdcch_params->n_symb; + LOG_I(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx); } } + else { // NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED + LOG_D(PHY, "Non interleaved CCE to REG mapping\n"); + for (uint8_t reg_idx=0; reg_idxreg_list[reg_idx]; + reg->reg_idx = cce->cce_idx*NR_NB_REG_PER_CCE + reg_idx; + reg->start_sc_idx = (reg->reg_idx/pdcch_params->n_symb) * NR_NB_SC_PER_RB; + reg->symb_idx = reg->reg_idx % pdcch_params->n_symb; + LOG_D(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx); + } + + } + } } @@ -149,7 +167,7 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, n_shift = (dci_alloc->pdcch_params.config_type == NFAPI_NR_CSET_CONFIG_MIB_SIB1)? cfg->sch_config.physical_cell_id.value : dci_alloc->pdcch_params.shift_index; nr_fill_cce_list(dci_alloc, n_shift, cand_idx); - LOG_I(PHY, "DCI type %d payload (size %d) generated\n", dci_alloc->pdcch_params.dci_format, dci_alloc->size); + LOG_I(PHY, "DCI type %d payload (size %d) generated on candidate %d\n", dci_alloc->pdcch_params.dci_format, dci_alloc->size, cand_idx); From 8ed4e0718d4909f396515a6b08a41ed75cd13095 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Thu, 9 Aug 2018 16:30:02 +0200 Subject: [PATCH 031/114] Bundle fix --- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 94aad0bee2..a31e8e5999 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -72,18 +72,20 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m uint8_t j = cce->cce_idx, j_prime; uint8_t r,c,idx; - - for (uint8_t reg_idx=0; reg_idxreg_list[reg_idx]; - j_prime = 6*j/bsize + reg_idx; + for (uint8_t bundle_idx=0; bundle_idxreg_idx = idx; - LOG_I(PHY, "j = %d \t j_prime = %d \t r = %d \t c = %d \t idx = %d\n", j , j_prime, r, c, idx); - reg->start_sc_idx = (idx/pdcch_params->n_symb) * NR_NB_SC_PER_RB; - reg->symb_idx = idx % pdcch_params->n_symb; - LOG_I(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx); + LOG_I(PHY, "bundle idx = %d \n j = %d \t j_prime = %d \t r = %d \t c = %d\n", idx, j , j_prime, r, c); + + for (uint8_t reg_idx=0; reg_idxreg_list[reg_idx]; + reg->reg_idx = bsize*bundle_idx + reg_idx; + reg->start_sc_idx = (idx/pdcch_params->n_symb) * NR_NB_SC_PER_RB; + reg->symb_idx = idx % pdcch_params->n_symb; + LOG_I(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx); + } } } else { // NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED From da8604b4ce8fc3ed25ce258cf790f0d2f4008ac3 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Thu, 9 Aug 2018 16:37:37 +0200 Subject: [PATCH 032/114] Interleaving index fix --- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index a31e8e5999..2f0b713a00 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -65,7 +65,7 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m for (uint8_t cce_idx=0; cce_idxcce_list[cce_idx]; cce->cce_idx = tmp + cce_idx; - LOG_D(PHY, "cce_idx %d\n", cce->cce_idx); + LOG_I(PHY, "cce_idx %d\n", cce->cce_idx); if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { LOG_I(PHY, "Interleaved CCE to REG mapping\n"); @@ -80,10 +80,10 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m LOG_I(PHY, "bundle idx = %d \n j = %d \t j_prime = %d \t r = %d \t c = %d\n", idx, j , j_prime, r, c); for (uint8_t reg_idx=0; reg_idxreg_list[reg_idx]; - reg->reg_idx = bsize*bundle_idx + reg_idx; - reg->start_sc_idx = (idx/pdcch_params->n_symb) * NR_NB_SC_PER_RB; - reg->symb_idx = idx % pdcch_params->n_symb; + reg = &cce->reg_list[reg_idx]; + reg->reg_idx = bsize*idx + reg_idx; + reg->start_sc_idx = (reg->reg_idx/pdcch_params->n_symb) * NR_NB_SC_PER_RB; + reg->symb_idx = reg->reg_idx % pdcch_params->n_symb; LOG_I(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx); } } From 3b17e145f512534c6a812913ca4d60852169ebf1 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Thu, 9 Aug 2018 17:37:32 +0200 Subject: [PATCH 033/114] Minor payload optim --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 25 +++++++++++------------- openair1/PHY/defs_nr_common.h | 1 + 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 213fa6571d..c830278b44 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -205,7 +205,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, nr_byte2bit(encoderOutput,currentPtr->encoderLength,encoded_payload);*/ // scrambling - uint32_t scrambled_payload[4]; + uint32_t scrambled_payload[NR_MAX_DCI_SIZE_DWORD]; uint32_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value; uint32_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; nr_pdcch_scrambling(dci_alloc.dci_pdu, dci_alloc.size, Nid, n_RNTI, scrambled_payload); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 2f0b713a00..fb75415bf3 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -56,7 +56,8 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m else { //NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC } - AssertFatal((N_reg%(bsize*R))==0, "CCE to REG interleaving: Invalid configuration leading to non integer C\n"); + uint8_t cond = N_reg%(bsize*R); + AssertFatal(cond==0, "CCE to REG interleaving: Invalid configuration leading to non integer C\n"); C = N_reg/(bsize*R); tmp = L * (( Y + (uint16_t)(floor((m*N_cce)/(L*M_s_max))) + n_CI ) % ((uint16_t)floor(N_cce/L))); @@ -65,10 +66,10 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m for (uint8_t cce_idx=0; cce_idxcce_list[cce_idx]; cce->cce_idx = tmp + cce_idx; - LOG_I(PHY, "cce_idx %d\n", cce->cce_idx); + LOG_D(PHY, "cce_idx %d\n", cce->cce_idx); if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { - LOG_I(PHY, "Interleaved CCE to REG mapping\n"); + LOG_D(PHY, "Interleaved CCE to REG mapping\n"); uint8_t j = cce->cce_idx, j_prime; uint8_t r,c,idx; @@ -77,14 +78,14 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m r = j_prime%R; c = (j_prime-r)/R; idx = (r*C + c + n_shift)%(N_reg/bsize); - LOG_I(PHY, "bundle idx = %d \n j = %d \t j_prime = %d \t r = %d \t c = %d\n", idx, j , j_prime, r, c); + LOG_D(PHY, "bundle idx = %d \n j = %d \t j_prime = %d \t r = %d \t c = %d\n", idx, j , j_prime, r, c); for (uint8_t reg_idx=0; reg_idxreg_list[reg_idx]; reg->reg_idx = bsize*idx + reg_idx; reg->start_sc_idx = (reg->reg_idx/pdcch_params->n_symb) * NR_NB_SC_PER_RB; reg->symb_idx = reg->reg_idx % pdcch_params->n_symb; - LOG_I(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx); + LOG_D(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx); } } } @@ -130,22 +131,18 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, // Freq domain assignment fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); for (int i=0; ifrequency_domain_assignment>>(fsize-i-1))&1)<frequency_domain_assignment>>(fsize-i-1))&1)<time_domain_assignment>>(3-i))&1)<<(pos+i); - pos += 4; + *dci_pdu |= ((pdu_rel15->time_domain_assignment>>(3-i))&1)<vrb_to_prb_mapping&1)<vrb_to_prb_mapping&1)<mcs>>(4-i))&1)<<(pos+i); - pos += 5; + *dci_pdu |= ((pdu_rel15->mcs>>(4-i))&1)<tb_scaling>>(1-i))&1)<<(pos+i); + *dci_pdu |= ((pdu_rel15->tb_scaling>>(1-i))&1)< Date: Fri, 10 Aug 2018 15:33:00 +0200 Subject: [PATCH 034/114] Symbol DMRS mapping fix --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 43 ++++++++++--------- openair1/PHY/NR_TRANSPORT/nr_dci.h | 2 +- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 4 +- .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 +- 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index c830278b44..f58561fecc 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -154,14 +154,14 @@ void nr_pdcch_scrambling(uint32_t *in, uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, t_nrPolar_paramsPtr *nrPolar_params, - uint32_t *gold_pdcch_dmrs, + uint32_t **gold_pdcch_dmrs, int32_t** txdataF, int16_t amp, NR_DL_FRAME_PARMS frame_parms, nfapi_nr_config_request_t config) { - int16_t mod_dmrs[NR_MAX_PDCCH_DMRS_LENGTH>>1]; + int16_t mod_dmrs[3][NR_MAX_PDCCH_DMRS_LENGTH>>1]; // 3 for the max coreset duration uint8_t idx=0; uint16_t a; int k,l,k_prime,dci_idx, dmrs_idx; @@ -173,20 +173,31 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, uint16_t dmrs_length = dci_alloc.L*36; //2(QPSK)*3(per RB)*6(REG per CCE) uint16_t encoded_length = dci_alloc.L*108; //2(QPSK)*9(per RB)*6(REG per CCE) + /*The coreset is initialised + * in frequency: the first subcarrier is obtained by adding the first CRB overlapping the SSB and the rb_offset + * in time: by its first slot and its first symbol*/ + uint8_t cset_start_sc = frame_parms.first_carrier_offset + ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+pdcch_params.rb_offset)*NR_NB_SC_PER_RB; + uint8_t cset_start_symb = pdcch_params.first_slot*frame_parms.symbols_per_slot + pdcch_params.first_symbol; + dci_idx = 0; + dmrs_idx = 0; + /// DMRS QPSK modulation /*There is a need to shift from which index the pregenerated DMRS sequence is used * see 38211 r15.2.0 section 7.4.1.3.2: assumption is the reference point for k refers to the DMRS sequence*/ if (pdcch_params.config_type == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG) gold_pdcch_dmrs += ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+pdcch_params.rb_offset)*3/32; - for (int i=0; i>1; i++) { - idx = ((((gold_pdcch_dmrs[(i<<1)>>5])>>((i<<1)&0x1f))&1)<<1) ^ (((gold_pdcch_dmrs[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1); - mod_dmrs[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; - mod_dmrs[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; -#ifdef DEBUG_PDCCH_DMRS - printf("i %d idx %d gold seq %u b0-b1 %d-%d mod_dmrs %d %d\n", i, idx, gold_pdcch_dmrs[(i<<1)>>5], (((gold_pdcch_dmrs[(i<<1)>>5])>>((i<<1)&0x1f))&1), - (((gold_pdcch_dmrs[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), mod_dmrs[(i<<1)], mod_dmrs[(i<<1)+1]); -#endif + for (int symb=cset_start_symb; symb>1; i++) { + idx = ((((gold_pdcch_dmrs[symb][(i<<1)>>5])>>((i<<1)&0x1f))&1)<<1) ^ (((gold_pdcch_dmrs[symb][((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1); + mod_dmrs[symb][i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; + mod_dmrs[symb][(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; + #ifdef DEBUG_PDCCH_DMRS + printf("symb %d i %d idx %d gold seq %u b0-b1 %d-%d mod_dmrs %d %d\n", symb, i, idx, gold_pdcch_dmrs[symb][(i<<1)>>5], + (((gold_pdcch_dmrs[symb][(i<<1)>>5])>>((i<<1)&0x1f))&1), (((gold_pdcch_dmrs[symb][((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), + mod_dmrs[symb][(i<<1)], mod_dmrs[symb][(i<<1)+1]); + #endif + } } /// DCI payload processing @@ -225,14 +236,6 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, /// Resource mapping a = (config.rf_config.tx_antenna_ports.value == 1) ? amp : (amp*ONE_OVER_SQRT2_Q15)>>15; - /*The coreset is initialised - * in frequency: the first subcarrier is obtained by adding the first CRB overlapping the SSB and the rb_offset - * in time: by its first slot and its first symbol*/ - uint8_t cset_start_sc = frame_parms.first_carrier_offset + ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+pdcch_params.rb_offset)*NR_NB_SC_PER_RB; - uint8_t cset_start_symb = pdcch_params.first_slot*frame_parms.symbols_per_slot + pdcch_params.first_symbol; - dci_idx = 0; - dmrs_idx = 0; - for (int aa = 0; aa < config.rf_config.tx_antenna_ports.value; aa++) { if (cset_start_sc >= frame_parms.ofdm_symbol_size) @@ -248,8 +251,8 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, k_prime = 0; for (int m=0; m> 15; - ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; + ((int16_t*)txdataF[aa])[(l*frame_parms.ofdm_symbol_size + k)<<1] = (a * mod_dmrs[l][dmrs_idx<<1]) >> 15; + ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dmrs[l][(dmrs_idx<<1) + 1]) >> 15; k_prime++; dmrs_idx++; } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index e1e56becbe..f7c885b499 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -34,7 +34,7 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, t_nrPolar_paramsPtr *nrPolar_params, - uint32_t *gold_pdcch_dmrs, + uint32_t **gold_pdcch_dmrs, int32_t** txdataF, int16_t amp, NR_DL_FRAME_PARMS frame_parms, diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 6ec1fb0409..c3325cb289 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -186,10 +186,12 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, LOG_I(PHY, "[gNB %d] Frame %d subframe %d \ Calling nr_generate_dci_top (number of DCI %d)\n", gNB->Mod_id, frame, subframe, num_dci); + uint8_t slot_idx = gNB->pdcch_vars.dci_alloc[0].pdcch_params.first_slot; + if (nfapi_mode == 0 || nfapi_mode == 1) nr_generate_dci_top(gNB->pdcch_vars, &gNB->nrPolar_params, - gNB->nr_gold_pdcch_dmrs[0][0], + gNB->nr_gold_pdcch_dmrs[slot_idx], gNB->common_vars.txdataF, AMP, *fp, *cfg); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 1868d987a4..339cb14151 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -85,7 +85,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, params_rel15->rnti = 0x03; params_rel15->rnti_type = NFAPI_NR_RNTI_RA; params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0; - params_rel15->aggregation_level = 1; + //params_rel15->aggregation_level = 1; LOG_I(MAC, "DCI type 1 params: rmsi_pdcch_config %d, rnti %d, rnti_type %d, dci_format %d\n \ coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d \n \ ss params : nb_ss_sets_per_slot %d, first symb %d, nb_slots %d, sfn_mod2 %d, first slot %d\n", From 5b990899973519bca96adc42f53df355be2b99d5 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Mon, 13 Aug 2018 20:00:23 +0200 Subject: [PATCH 035/114] Minor warning fixes --- openair1/PHY/CODING/TESTBENCH/polartest.c | 2 +- openair1/PHY/CODING/nr_polar_init.c | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index b9d52d849f..aa811399a0 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) { double SNR, SNR_lin; int16_t nBitError = 0; // -1 = Decoding failed (All list entries have failed the CRC checks). int8_t decoderState=0, blockErrorState=0; //0 = Success, -1 = Decoding failed, 1 = Block Error. - uint16_t testLength, coderLength, blockErrorCumulative=0, bitErrorCumulative=0; + uint16_t testLength = 0, coderLength = 0, blockErrorCumulative=0, bitErrorCumulative=0; double timeEncoderCumulative = 0, timeDecoderCumulative = 0; uint8_t aggregation_level, decoderListSize = 8, pathMetricAppr = 0; //0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12) diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index c0dcdf7b0b..a4a86389cc 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -31,16 +31,11 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, uint8_t aggregation_level) { t_nrPolar_paramsPtr currentPtr = *polarParams; - t_nrPolar_paramsPtr previousPtr = NULL; //Parse the list. If the node is already created, return without initialization. while (currentPtr != NULL) { - if (currentPtr->idx == (messageType * messageLength)) { - return; - } else { - previousPtr = currentPtr; - currentPtr = currentPtr->nextPtr; - } + if (currentPtr->idx == (messageType * messageLength)) return; + else currentPtr = currentPtr->nextPtr; } //Else, initialize and add node to the end of the linked list. @@ -174,7 +169,7 @@ t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams, int8_t messageType, uint16_t messageLength) { - t_nrPolar_paramsPtr currentPtr; + t_nrPolar_paramsPtr currentPtr = NULL; while (polarParams != NULL) { if (polarParams->idx == (messageType * messageLength)) { From d409ed1adbcdb2a9c0b78c6ee2ed64d7475a7036 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Mon, 13 Aug 2018 21:40:54 +0200 Subject: [PATCH 036/114] trial --- targets/RT/USER/nr-softmodem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/targets/RT/USER/nr-softmodem.c b/targets/RT/USER/nr-softmodem.c index cf34804e1c..99d45e1ba1 100644 --- a/targets/RT/USER/nr-softmodem.c +++ b/targets/RT/USER/nr-softmodem.c @@ -888,6 +888,7 @@ static void wait_nfapi_init(char *thread_name) { int main( int argc, char **argv ) { + printf( "HEREHERE"); int i; #if defined (XFORMS) //void *status; From 3c9a89576d5632706eec657f5d8ac1c5f64f3ee3 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Tue, 14 Aug 2018 11:36:59 +0200 Subject: [PATCH 037/114] Debug changes --- openair1/PHY/CODING/TESTBENCH/polartest.c | 11 +++++++++++ openair1/PHY/INIT/nr_init.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 12 ++++++++++-- openair1/PHY/defs_gNB.h | 9 ++++----- targets/RT/USER/nr-softmodem.c | 1 - 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index aa811399a0..32bfc23529 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -11,6 +11,8 @@ #include "PHY/defs_gNB.h" #include "SIMULATION/TOOLS/sim.h" +#define DEBUG_POLAR_PARAMS + int main(int argc, char *argv[]) { //Initiate timing. (Results depend on CPU Frequency. Therefore, might change due to performance variances during simulation.) @@ -125,6 +127,15 @@ int main(int argc, char *argv[]) { t_nrPolar_paramsPtr nrPolar_params = NULL; nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); +#ifdef DEBUG_POLAR_PARAMS + nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); + nr_polar_init(&nrPolar_params, 1, 20, 1); + nr_polar_init(&nrPolar_params, 1, 21, 1); + nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); + nr_polar_print_polarParams(nrPolar_params); + return (0); +#endif + t_nrPolar_paramsPtr currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength); // We assume no a priori knowledge available about the payload. diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index d15c39e222..29e10410be 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -119,7 +119,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, // PBCH DMRS gold sequences generation nr_init_pbch_dmrs(gNB); // Polar encoder init for PBCH - nr_polar_init(&fp->pbch_polar_params, + nr_polar_init(&gNB->nrPolar_params, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index f58561fecc..e31b63a26f 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -202,8 +202,14 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, /// DCI payload processing //channel coding - /*uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); +#ifdef DEBUG_POLAR_PARAMS + uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); + printf("\ndci_alloc.dci_pdu\n[0]=%d [1]=%d [2]=%d [3]=%d\n",dci_alloc.dci_pdu[0],dci_alloc.dci_pdu[1],dci_alloc.dci_pdu[2],dci_alloc.dci_pdu[3]); nr_bit2byte(dci_alloc.dci_pdu, dci_alloc.size, encoderInput); + printf("\ndci_alloc.dci_pdu\n[0]=%d [1]=%d [2]=%d [3]=%d\n",dci_alloc.dci_pdu[0],dci_alloc.dci_pdu[1],dci_alloc.dci_pdu[2],dci_alloc.dci_pdu[3]); + for (int i=0;iencoderLength); polar_encoder(encoderInput, encoderOutput, currentPtr); uint32_t encoded_payload[4]; - nr_byte2bit(encoderOutput,currentPtr->encoderLength,encoded_payload);*/ + nr_byte2bit(encoderOutput,currentPtr->encoderLength,encoded_payload); + return (0); +#endif // scrambling uint32_t scrambled_payload[NR_MAX_DCI_SIZE_DWORD]; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index bf023867ab..d622536042 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -283,15 +283,16 @@ typedef struct PHY_VARS_gNB_s { /// NFAPI PRACH information nfapi_preamble_pdu_t preamble_list[MAX_NUM_RX_PRACH_PREAMBLES]; - Sched_Rsp_t Sched_INFO; + Sched_Rsp_t Sched_INFO; NR_gNB_PDCCH pdcch_vars; + NR_gNB_PBCH pbch; + t_nrPolar_paramsPtr nrPolar_params; nfapi_nr_dl_config_pdcch_parameters_rel15_t pdcch_type0_params; - LTE_eNB_PHICH phich_vars[2]; + LTE_eNB_PHICH phich_vars[2]; NR_gNB_COMMON common_vars; LTE_eNB_UCI uci_vars[NUMBER_OF_UE_MAX]; LTE_eNB_SRS srs_vars[NUMBER_OF_UE_MAX]; - NR_gNB_PBCH pbch; LTE_eNB_PUSCH *pusch_vars[NUMBER_OF_UE_MAX]; LTE_eNB_PRACH prach_vars; LTE_eNB_DLSCH_t *dlsch[NUMBER_OF_UE_MAX][2]; // Nusers times two spatial streams @@ -462,8 +463,6 @@ typedef struct PHY_VARS_gNB_s { int32_t pusch_stats_mcs[NUMBER_OF_UE_MAX][10240]; int32_t pusch_stats_bsr[NUMBER_OF_UE_MAX][10240]; int32_t pusch_stats_BO[NUMBER_OF_UE_MAX][10240]; - - t_nrPolar_paramsPtr nrPolar_params; } PHY_VARS_gNB; #endif diff --git a/targets/RT/USER/nr-softmodem.c b/targets/RT/USER/nr-softmodem.c index 99d45e1ba1..cf34804e1c 100644 --- a/targets/RT/USER/nr-softmodem.c +++ b/targets/RT/USER/nr-softmodem.c @@ -888,7 +888,6 @@ static void wait_nfapi_init(char *thread_name) { int main( int argc, char **argv ) { - printf( "HEREHERE"); int i; #if defined (XFORMS) //void *status; From 67eec34a5cc03107f4af4a392189f83b9bdb46f1 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Tue, 14 Aug 2018 16:25:51 +0200 Subject: [PATCH 038/114] Minor fixes --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 1 + openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 2 +- openair2/GNB_APP/gnb_config.c | 4 ++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 +- targets/RT/USER/nr-ru.c | 2 +- targets/RT/USER/nr-softmodem.c | 4 ++-- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index e31b63a26f..25bafe6051 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -34,6 +34,7 @@ //#define DEBUG_PDCCH_DMRS //#define DEBUG_DCI +#define DEBUG_POLAR_PARAMS extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index 96806fbe82..cf50c71634 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -48,7 +48,7 @@ * @{ */ -#define SHRT_MAX 32767 +//#define SHRT_MAX 32767 typedef struct { /// Indicator of first transmission diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 9699dbada6..cbdf102bd1 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -606,11 +606,11 @@ int RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { paramdef_t GNBParams[] = GNBPARAMS_DESC; paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0}; ////////// Physical parameters - checkedparam_t config_check_CCparams[] = NRCCPARAMS_CHECK; + //checkedparam_t config_check_CCparams[] = NRCCPARAMS_CHECK; paramdef_t CCsParams[] = NRCCPARAMS_DESC; paramlist_def_t CCsParamList = {GNB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0}; - paramdef_t SRB1Params[] = SRB1PARAMS_DESC; + //paramdef_t SRB1Params[] = SRB1PARAMS_DESC; /* get global parameters, defined outside any section in the config file */ diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 339cb14151..2a59863977 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -42,7 +42,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, uint8_t CC_id; gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; - NR_COMMON_channels_t *cc = nr_mac->common_channels; + //NR_COMMON_channels_t *cc = nr_mac->common_channels; nfapi_nr_dl_config_request_body_t *dl_req; nfapi_nr_dl_config_request_pdu_t *dl_config_pdu; nfapi_tx_request_pdu_t *TX_req; diff --git a/targets/RT/USER/nr-ru.c b/targets/RT/USER/nr-ru.c index cbec8b7999..a9622df32d 100644 --- a/targets/RT/USER/nr-ru.c +++ b/targets/RT/USER/nr-ru.c @@ -604,7 +604,7 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *subframe) { RU_proc_t *proc = &ru->proc; uint16_t packet_type; - uint32_t symbol_number,symbol_mask,symbol_mask_full; + uint32_t symbol_number,symbol_mask,symbol_mask_full=0; int subframe_tx,frame_tx; LOG_D(PHY, "%s(ru:%p frame, subframe)\n", __FUNCTION__, ru); diff --git a/targets/RT/USER/nr-softmodem.c b/targets/RT/USER/nr-softmodem.c index cf34804e1c..d2f43b2cb8 100644 --- a/targets/RT/USER/nr-softmodem.c +++ b/targets/RT/USER/nr-softmodem.c @@ -396,8 +396,8 @@ static void *scope_thread(void *arg) { for(CC_id=0; CC_id Date: Thu, 16 Aug 2018 15:20:36 +0200 Subject: [PATCH 039/114] Debug changes --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 2 ++ openair2/GNB_APP/gnb_config.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 25bafe6051..949f8807f2 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -205,6 +205,8 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, //channel coding #ifdef DEBUG_POLAR_PARAMS uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); + printf("\n[TY]DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); printf("\ndci_alloc.dci_pdu\n[0]=%d [1]=%d [2]=%d [3]=%d\n",dci_alloc.dci_pdu[0],dci_alloc.dci_pdu[1],dci_alloc.dci_pdu[2],dci_alloc.dci_pdu[3]); nr_bit2byte(dci_alloc.dci_pdu, dci_alloc.size, encoderInput); printf("\ndci_alloc.dci_pdu\n[0]=%d [1]=%d [2]=%d [3]=%d\n",dci_alloc.dci_pdu[0],dci_alloc.dci_pdu[1],dci_alloc.dci_pdu[2],dci_alloc.dci_pdu[3]); diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index cbdf102bd1..455a1c0a83 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -592,12 +592,12 @@ int RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { int32_t RateMatchPatternLTE_CRS_radioframeAllocationOffset = 0; char* RateMatchPatternLTE_CRS_subframeAllocation_choice = NULL; - int32_t srb1_timer_poll_retransmit = 0; + /*int32_t srb1_timer_poll_retransmit = 0; int32_t srb1_timer_reordering = 0; int32_t srb1_timer_status_prohibit = 0; int32_t srb1_poll_pdu = 0; int32_t srb1_poll_byte = 0; - int32_t srb1_max_retx_threshold = 0; + int32_t srb1_max_retx_threshold = 0;*/ //int32_t my_int; From 948eb6f1ca6b61a1e2831e27c679e6b17730a44e Mon Sep 17 00:00:00 2001 From: yilmazt Date: Thu, 16 Aug 2018 15:43:23 +0200 Subject: [PATCH 040/114] Debug changes2 --- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index fb75415bf3..4890ce5510 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -31,6 +31,7 @@ */ #include "nr_dci.h" +#define DEBUG_NFAPI_NR_RNTI_RA void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m) { @@ -128,6 +129,9 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, case NFAPI_NR_DL_DCI_FORMAT_1_0: switch(params_rel15->rnti_type) { case NFAPI_NR_RNTI_RA: +#ifdef DEBUG_NFAPI_NR_RNTI_RA +printf("\npdu_rel15->frequency_domain_assignment = %d = 0x%x",pdu_rel15->frequency_domain_assignment,pdu_rel15->frequency_domain_assignment); +#endif // Freq domain assignment fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); for (int i=0; i Date: Thu, 16 Aug 2018 16:01:17 +0200 Subject: [PATCH 041/114] Debug changes3 --- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 4890ce5510..6e0b019cfe 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -130,7 +130,15 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, switch(params_rel15->rnti_type) { case NFAPI_NR_RNTI_RA: #ifdef DEBUG_NFAPI_NR_RNTI_RA -printf("\npdu_rel15->frequency_domain_assignment = %d = 0x%x",pdu_rel15->frequency_domain_assignment,pdu_rel15->frequency_domain_assignment); +printf("frequency_domain_assignment = %05d = %#08x\n" + " time_domain_assignment = %05d = %#08x\n" + " vrb_to_prb_mapping = %05d = %#08x\n" + " MCS = %05d = %#08x\n" + " tb_scaling = %05d = %#08x\n", + pdu_rel15->frequency_domain_assignment,pdu_rel15->frequency_domain_assignment, + pdu_rel15->time_domain_assignment,pdu_rel15->time_domain_assignment, + pdu_rel15->vrb_to_prb_mapping,pdu_rel15->vrb_to_prb_mapping, + pdu_rel15->mcs,pdu_rel15->mcs,pdu_rel15->tb_scaling,pdu_rel15->tb_scaling); #endif // Freq domain assignment fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); From b31a0b42ec1f32ee714b71401f11f5b5bf22c76b Mon Sep 17 00:00:00 2001 From: yilmazt Date: Thu, 16 Aug 2018 16:55:08 +0200 Subject: [PATCH 042/114] Debug changes4 --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 7 +++++-- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 10 +++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 949f8807f2..36616b6e21 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -204,16 +204,19 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, /// DCI payload processing //channel coding #ifdef DEBUG_POLAR_PARAMS + dci_alloc.dci_pdu[1]=10; uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); printf("\n[TY]DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); - printf("\ndci_alloc.dci_pdu\n[0]=%d [1]=%d [2]=%d [3]=%d\n",dci_alloc.dci_pdu[0],dci_alloc.dci_pdu[1],dci_alloc.dci_pdu[2],dci_alloc.dci_pdu[3]); nr_bit2byte(dci_alloc.dci_pdu, dci_alloc.size, encoderInput); - printf("\ndci_alloc.dci_pdu\n[0]=%d [1]=%d [2]=%d [3]=%d\n",dci_alloc.dci_pdu[0],dci_alloc.dci_pdu[1],dci_alloc.dci_pdu[2],dci_alloc.dci_pdu[3]); for (int i=0;i0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); return (0); + nr_polar_init(&nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, pdcch_params.aggregation_level); t_nrPolar_paramsPtr currentPtr = nr_polar_params(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 6e0b019cfe..e3504ea64e 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -130,11 +130,11 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, switch(params_rel15->rnti_type) { case NFAPI_NR_RNTI_RA: #ifdef DEBUG_NFAPI_NR_RNTI_RA -printf("frequency_domain_assignment = %05d = %#08x\n" - " time_domain_assignment = %05d = %#08x\n" - " vrb_to_prb_mapping = %05d = %#08x\n" - " MCS = %05d = %#08x\n" - " tb_scaling = %05d = %#08x\n", +printf("frequency_domain_assignment = %05d = %#010x\n" + " time_domain_assignment = %05d = %#010x\n" + " vrb_to_prb_mapping = %05d = %#010x\n" + " MCS = %05d = %#010x\n" + " tb_scaling = %05d = %#010x\n", pdu_rel15->frequency_domain_assignment,pdu_rel15->frequency_domain_assignment, pdu_rel15->time_domain_assignment,pdu_rel15->time_domain_assignment, pdu_rel15->vrb_to_prb_mapping,pdu_rel15->vrb_to_prb_mapping, From ca207808df6f84f65f0ad5905f66f049674796c7 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Thu, 16 Aug 2018 21:57:33 +0200 Subject: [PATCH 043/114] Debug changes5 --- openair1/PHY/CODING/TESTBENCH/polartest.c | 8 +++++ .../nrPolar_tools/nr_bitwise_operations.c | 34 +++++++------------ .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 5 ++- openair1/PHY/NR_TRANSPORT/nr_dci.c | 6 ++-- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 32bfc23529..eeca32df78 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -133,6 +133,14 @@ int main(int argc, char *argv[]) { nr_polar_init(&nrPolar_params, 1, 21, 1); nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); nr_polar_print_polarParams(nrPolar_params); + + uint32_t in[4]; + in[0]=0x01189400; + in[1]=0xffffff0f; + uint8_t *out = malloc(sizeof(uint8_t) * 41); + nr_bit2byte(in, 41, out); + for (int i=0;i<41;i++) + printf("out[%d]=%d\n",i,out[i]); return (0); #endif diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c index ea47405d5b..032eca98d3 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c @@ -21,29 +21,21 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -void nr_byte2bit_uint8(uint8_t *array, uint8_t arraySize, uint8_t *bitArray) { - //First 2 parameters are in bytes. - - for (int i = 0; i < arraySize; i++) { - bitArray[(7 + (i * 8))] = (array[i] >> 0 & 0x01); - bitArray[(6 + (i * 8))] = (array[i] >> 1 & 0x01); - bitArray[(5 + (i * 8))] = (array[i] >> 2 & 0x01); - bitArray[(4 + (i * 8))] = (array[i] >> 3 & 0x01); - bitArray[(3 + (i * 8))] = (array[i] >> 4 & 0x01); - bitArray[(2 + (i * 8))] = (array[i] >> 5 & 0x01); - bitArray[(1 + (i * 8))] = (array[i] >> 6 & 0x01); - bitArray[(i * 8)] = (array[i] >> 7 & 0x01); +void nr_bit2byte_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out) { + uint8_t arrayInd = ceil(arraySize / 32.0); + for (int i = 0; i < arrayInd; i++) { + for (int j = 0; j < 32; j++) { + out[j+(i*32)] = (in[i] >> j) & 1; + } } } -void nr_bit2byte(uint32_t *in, uint16_t arraySize, uint8_t *out) { - for (int i = 0; i < arraySize; i++) { - out[i] = ((*in) >> i) & 1; - } -} - -void nr_byte2bit(uint8_t *in, uint16_t arraySize, uint32_t *out) { - for (int i = 0; i < arraySize; i++) { - *out = (*out) << i | in[i]; +void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out) { + uint8_t arrayInd = ceil(arraySize / 32.0); + for (int i = 0; i < arrayInd; i++) { + for (int j = 0; j < 32; j++) { + out[i]|=in[j+(i*32)]; + out[i]<<=1; + } } } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 574b199c50..464f91d7ce 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -113,9 +113,8 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, int16_t *Q_I_N, int16_t *Q_F_N, void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *output, uint8_t *pattern, uint16_t size); -void nr_byte2bit(uint8_t *in, uint16_t arraySize, uint32_t *out); -void nr_byte2bit_uint8(uint8_t *array, uint8_t arraySize, uint8_t *bitArray); -void nr_bit2byte(uint32_t *in, uint16_t arraySize, uint8_t *out); +void nr_bit2byte_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out); +void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out); void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, uint16_t N, uint16_t K, int16_t *Q_I_N, int16_t *Q_PC_N, uint8_t n_PC); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 36616b6e21..a857aa7fb0 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -204,15 +204,15 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, /// DCI payload processing //channel coding #ifdef DEBUG_POLAR_PARAMS - dci_alloc.dci_pdu[1]=10; + dci_alloc.dci_pdu[1]=0xffffffff; uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); - printf("\n[TY]DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + printf("[TY]DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); nr_bit2byte(dci_alloc.dci_pdu, dci_alloc.size, encoderInput); for (int i=0;i0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + printf("[TY]DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); return (0); From 76b1ee89fa5225d6a2a61e97f04276fe2c5f188f Mon Sep 17 00:00:00 2001 From: yilmazt Date: Fri, 17 Aug 2018 11:22:13 +0200 Subject: [PATCH 044/114] Working polartest.c --- openair1/PHY/CODING/TESTBENCH/polartest.c | 7 +++++-- openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index eeca32df78..0a5a4f7aba 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -11,7 +11,7 @@ #include "PHY/defs_gNB.h" #include "SIMULATION/TOOLS/sim.h" -#define DEBUG_POLAR_PARAMS +//#define DEBUG_POLAR_PARAMS int main(int argc, char *argv[]) { @@ -138,9 +138,12 @@ int main(int argc, char *argv[]) { in[0]=0x01189400; in[1]=0xffffff0f; uint8_t *out = malloc(sizeof(uint8_t) * 41); - nr_bit2byte(in, 41, out); + nr_bit2byte_uint32_8_t(in, 41, out); for (int i=0;i<41;i++) printf("out[%d]=%d\n",i,out[i]); + uint32_t inn[4]; + nr_byte2bit_uint8_32_t(out, 41, inn); + printf("inn[0]=%#x, inn[1]=%#x\n",inn[0],inn[1]); return (0); #endif diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c index 032eca98d3..4394a2ffff 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c @@ -33,9 +33,11 @@ void nr_bit2byte_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out) { void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out) { uint8_t arrayInd = ceil(arraySize / 32.0); for (int i = 0; i < arrayInd; i++) { - for (int j = 0; j < 32; j++) { - out[i]|=in[j+(i*32)]; + out[i]=0; + for (int j = 31; j > 0; j--) { + out[i]|=in[(i*32)+j]; out[i]<<=1; } + out[i]|=in[(i*32)]; } } From 77b155c3b9798bc24f135287e4b2bae1a5ff5257 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Fri, 17 Aug 2018 13:59:59 +0200 Subject: [PATCH 045/114] Debug changes1 --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index a857aa7fb0..5496ca13fe 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -204,36 +204,29 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, /// DCI payload processing //channel coding #ifdef DEBUG_POLAR_PARAMS - dci_alloc.dci_pdu[1]=0xffffffff; - uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); - printf("[TY]DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); - nr_bit2byte(dci_alloc.dci_pdu, dci_alloc.size, encoderInput); - for (int i=0;i0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); - return (0); - - nr_polar_init(&nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, pdcch_params.aggregation_level); t_nrPolar_paramsPtr currentPtr = nr_polar_params(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size); + uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); uint8_t *encoderOutput = malloc(sizeof(uint8_t) * currentPtr->encoderLength); + printf("[TY]DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); + nr_bit2byte_uint32_8_t(dci_alloc.dci_pdu,dci_alloc.size,encoderInput); polar_encoder(encoderInput, encoderOutput, currentPtr); uint32_t encoded_payload[4]; - nr_byte2bit(encoderOutput,currentPtr->encoderLength,encoded_payload); + nr_byte2bit_uint8_32_t(encoderOutput, currentPtr->encoderLength, encoded_payload); + printf("[TY]Encoded Payload: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + encoded_payload[0], encoded_payload[1], encoded_payload[2], encoded_payload[3]); return (0); #endif - + // scrambling uint32_t scrambled_payload[NR_MAX_DCI_SIZE_DWORD]; uint32_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value; uint32_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; - nr_pdcch_scrambling(dci_alloc.dci_pdu, dci_alloc.size, Nid, n_RNTI, scrambled_payload); + nr_pdcch_scrambling(encoded_payload, dci_alloc.size, Nid, n_RNTI, scrambled_payload); // QPSK modulation int16_t mod_dci[NR_MAX_DCI_SIZE>>1]; From 48bd667b672a07475687e19754b83b7ba11ec635 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Fri, 17 Aug 2018 15:08:09 +0200 Subject: [PATCH 046/114] Minor fix --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 5496ca13fe..b004ccb12b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -204,10 +204,8 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, /// DCI payload processing //channel coding #ifdef DEBUG_POLAR_PARAMS - nr_polar_init(&nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, pdcch_params.aggregation_level); - t_nrPolar_paramsPtr currentPtr = nr_polar_params(nrPolar_params, - NR_POLAR_DCI_MESSAGE_TYPE, - dci_alloc.size); + nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); + t_nrPolar_paramsPtr currentPtr = nr_polar_params(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE,dci_alloc.size); uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); uint8_t *encoderOutput = malloc(sizeof(uint8_t) * currentPtr->encoderLength); From 866c2fedc8f2416223fccfa318ea01b4c48d1b0f Mon Sep 17 00:00:00 2001 From: yilmazt Date: Fri, 17 Aug 2018 15:26:22 +0200 Subject: [PATCH 047/114] Minor fix2 --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index b004ccb12b..7cf1f61eb8 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -205,7 +205,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, //channel coding #ifdef DEBUG_POLAR_PARAMS nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); - t_nrPolar_paramsPtr currentPtr = nr_polar_params(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE,dci_alloc.size); + t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size); uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); uint8_t *encoderOutput = malloc(sizeof(uint8_t) * currentPtr->encoderLength); From e6e99716adb990e4eae273e893d0f4ed244f7ee6 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Fri, 17 Aug 2018 15:35:01 +0200 Subject: [PATCH 048/114] Minor fix3 --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 7cf1f61eb8..7276d48592 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -203,21 +203,22 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, /// DCI payload processing //channel coding -#ifdef DEBUG_POLAR_PARAMS nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size); uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); uint8_t *encoderOutput = malloc(sizeof(uint8_t) * currentPtr->encoderLength); - printf("[TY]DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); + uint32_t encoded_payload[4]; + nr_bit2byte_uint32_8_t(dci_alloc.dci_pdu,dci_alloc.size,encoderInput); polar_encoder(encoderInput, encoderOutput, currentPtr); - uint32_t encoded_payload[4]; nr_byte2bit_uint8_32_t(encoderOutput, currentPtr->encoderLength, encoded_payload); - printf("[TY]Encoded Payload: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + +#ifdef DEBUG_POLAR_PARAMS + printf("DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); + printf("Encoded Payload: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", encoded_payload[0], encoded_payload[1], encoded_payload[2], encoded_payload[3]); - return (0); #endif // scrambling From 5b42e83df2d4b6111d20d70202a0f2de7bbf26b7 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Sun, 19 Aug 2018 19:24:14 +0200 Subject: [PATCH 049/114] Putting byte2bit operations within polar coders --- openair1/PHY/CODING/TESTBENCH/polartest.c | 29 +- .../CODING/nrPolar_tools/nr_polar_decoder.c | 269 +++++++++++++++++- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 41 ++- .../CODING/nrPolar_tools/nr_polar_encoder.c | 65 ++++- .../CODING/nrPolar_tools/nr_polar_pbch_defs.h | 21 +- openair1/PHY/CODING/nr_polar_init.c | 15 +- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 7 +- 7 files changed, 386 insertions(+), 61 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 0a5a4f7aba..a78146042b 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -7,8 +7,6 @@ #include #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -#include "PHY/NR_TRANSPORT/nr_dci.h" -#include "PHY/defs_gNB.h" #include "SIMULATION/TOOLS/sim.h" //#define DEBUG_POLAR_PARAMS @@ -22,16 +20,6 @@ int main(int argc, char *argv[]) { reset_meas(&timeEncoder); reset_meas(&timeDecoder); - //gNB scheduler - /*PHY_VARS_gNB *gNB = RC.gNB[0][0]; - NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; - nfapi_nr_config_request_t *cfg = &gNB->gNB_config; - - nfapi_nr_dl_config_request_pdu_t *pdu; - nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &pdu->dci_dl_pdu.pdcch_params_rel15; - params_rel15->rnti_type = NFAPI_NR_RNTI_RA; - params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0;*/ - randominit(0); //Default simulation values (Aim for iterations = 1000000.) int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, -1=UCI @@ -42,8 +30,7 @@ int main(int argc, char *argv[]) { int8_t decoderState=0, blockErrorState=0; //0 = Success, -1 = Decoding failed, 1 = Block Error. uint16_t testLength = 0, coderLength = 0, blockErrorCumulative=0, bitErrorCumulative=0; double timeEncoderCumulative = 0, timeDecoderCumulative = 0; - - uint8_t aggregation_level, decoderListSize = 8, pathMetricAppr = 0; //0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12) + uint8_t aggregation_level; while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:")) != -1) switch (arguments) @@ -171,16 +158,24 @@ int main(int argc, char *argv[]) { modulatedInput[i]=(-1)/sqrt(2); channelOutput[i] = modulatedInput[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin))); + printf("%f\n",channelOutput[i]); } + start_meas(&timeDecoder); - decoderState = polar_decoder(channelOutput, + /*decoderState = polar_decoder(channelOutput, estimatedOutput, currentPtr, - decoderListSize, + NR_POLAR_DECODER_LISTSIZE, aPrioriArray, - pathMetricAppr); + NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION);*/ + decoderState = polar_decoder_aPriori(channelOutput, + estimatedOutput, + currentPtr, + NR_POLAR_DECODER_LISTSIZE, + NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, + aPrioriArray); stop_meas(&timeDecoder); //calculate errors diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 9232f74e15..438044b447 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -19,6 +19,17 @@ * contact@openairinterface.org */ +/*!\file PHY/CODING/nrPolar_tools/nr_polar_decoder.c + * \brief + * \author Turker Yilmaz + * \date 2018 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + /* * Return values: * 0 --> Success @@ -26,16 +37,255 @@ */ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" int8_t polar_decoder( double *input, - uint8_t *output, + uint32_t *out, t_nrPolar_paramsPtr polarParams, uint8_t listSize, - double *aPrioriPayload, uint8_t pathMetricAppr) { + //Assumes no a priori knowledge. + + uint8_t ***bit = nr_alloc_uint8_t_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); + uint8_t **bitUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True + uint8_t **llrUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True + double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); + uint8_t **crcChecksum = nr_alloc_uint8_t_2D_array(polarParams->crcParityBits, 2*listSize); + double *pathMetric = malloc(sizeof(double)*(2*listSize)); + uint8_t *crcState = malloc(sizeof(uint8_t)*(2*listSize)); //0=False, 1=True + + for (int i=0; i<(2*listSize); i++) { + pathMetric[i] = 0; + crcState[i]=1; + } + for (int i=0; iN; i++) { + llrUpdated[i][polarParams->n]=1; + bitUpdated[i][0]=((polarParams->information_bit_pattern[i]+1) % 2); + } + + uint8_t **extended_crc_generator_matrix = malloc(polarParams->K * sizeof(uint8_t *)); //G_P3 + uint8_t **tempECGM = malloc(polarParams->K * sizeof(uint8_t *)); //G_P2 + for (int i = 0; i < polarParams->K; i++){ + extended_crc_generator_matrix[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t)); + tempECGM[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t)); + } + + for (int i=0; ipayloadBits; i++) { + for (int j=0; jcrcParityBits; j++) { + tempECGM[i][j]=polarParams->crc_generator_matrix[i][j]; + } + } + for (int i=polarParams->payloadBits; iK; i++) { + for (int j=0; jcrcParityBits; j++) { + if( (i-polarParams->payloadBits) == j ){ + tempECGM[i][j]=1; + } else { + tempECGM[i][j]=0; + } + } + } + + for (int i=0; iK; i++) { + for (int j=0; jcrcParityBits; j++) { + extended_crc_generator_matrix[i][j]=tempECGM[polarParams->interleaving_pattern[i]][j]; + } + } + + //The index of the last 1-valued bit that appears in each column. + uint16_t last1ind[polarParams->crcParityBits]; + for (int j=0; jcrcParityBits; j++) { + for (int i=0; iK; i++) { + if (extended_crc_generator_matrix[i][j]==1) last1ind[j]=i; + } + } + + double *d_tilde = malloc(sizeof(double) * polarParams->N); + nr_polar_rate_matching(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); + for (int j = 0; j < polarParams->N; j++) llr[j][polarParams->n][0]=d_tilde[j]; + + + /* + * SCL polar decoder. + */ + + uint32_t nonFrozenBit=0; + uint8_t currentListSize=1; + uint8_t decoderIterationCheck=0; + int16_t checkCrcBits=-1; + uint8_t listIndex[2*listSize], copyIndex; + + for (uint16_t currentBit=0; currentBitN; currentBit++){ + updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1), pathMetricAppr); + if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. + updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 + } else { //Information or CRC bit. + updatePathMetric2(pathMetric, llr, currentListSize, currentBit, pathMetricAppr); + + for (int i = 0; i < currentListSize; i++) { + for (int j = 0; j < polarParams->N; j++) { + for (int k = 0; k < (polarParams->n+1); k++) { + bit[j][k][i+currentListSize]=bit[j][k][i]; + llr[j][k][i+currentListSize]=llr[j][k][i];}}} + for (int i = 0; i < currentListSize; i++) { + bit[currentBit][0][i]=0; + crcState[i+currentListSize]=crcState[i]; + } + for (int i = currentListSize; i < 2*currentListSize; i++) bit[currentBit][0][i]=1; + bitUpdated[currentBit][0]=1; + updateCrcChecksum2(crcChecksum, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits); + currentListSize*=2; + + //Keep only the best "listSize" number of entries. + if (currentListSize > listSize) { + for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; + nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); + + //sort listIndex[listSize, ..., 2*listSize-1] in descending order. + uint8_t swaps, tempInd; + for (uint8_t i = 0; i < listSize; i++) { + swaps = 0; + for (uint8_t j = listSize; j < (2*listSize - i) - 1; j++) { + if (listIndex[j+1] > listIndex[j]) { + tempInd = listIndex[j]; + listIndex[j] = listIndex[j + 1]; + listIndex[j + 1] = tempInd; + swaps++; + } + } + if (swaps == 0) + break; + } + + //First, backup the best "listSize" number of entries. + for (int k=(listSize-1); k>0; k--) { + for (int i=0; iN; i++) { + for (int j=0; j<(polarParams->n+1); j++) { + bit[i][j][listIndex[(2*listSize-1)-k]]=bit[i][j][listIndex[k]]; + llr[i][j][listIndex[(2*listSize-1)-k]]=llr[i][j][listIndex[k]]; + } + } + } + for (int k=(listSize-1); k>0; k--) { + for (int i = 0; i < polarParams->crcParityBits; i++) { + crcChecksum[i][listIndex[(2*listSize-1)-k]] = crcChecksum[i][listIndex[k]]; + } + } + for (int k=(listSize-1); k>0; k--) crcState[listIndex[(2*listSize-1)-k]]=crcState[listIndex[k]]; + + //Copy the best "listSize" number of entries to the first indices. + for (int k = 0; k < listSize; k++) { + if (k > listIndex[k]) { + copyIndex = listIndex[(2*listSize-1)-k]; + } else { //Use the backup. + copyIndex = listIndex[k]; + } + for (int i = 0; i < polarParams->N; i++) { + for (int j = 0; j < (polarParams->n + 1); j++) { + bit[i][j][k] = bit[i][j][copyIndex]; + llr[i][j][k] = llr[i][j][copyIndex]; + } + } + } + for (int k = 0; k < listSize; k++) { + if (k > listIndex[k]) { + copyIndex = listIndex[(2*listSize-1)-k]; + } else { //Use the backup. + copyIndex = listIndex[k]; + } + for (int i = 0; i < polarParams->crcParityBits; i++) { + crcChecksum[i][k]=crcChecksum[i][copyIndex]; + } + } + for (int k = 0; k < listSize; k++) { + if (k > listIndex[k]) { + copyIndex = listIndex[(2*listSize-1)-k]; + } else { //Use the backup. + copyIndex = listIndex[k]; + } + crcState[k]=crcState[copyIndex]; + } + currentListSize = listSize; + } + + + for (int i=0; icrcParityBits; i++) { + if (last1ind[i]==nonFrozenBit) { + checkCrcBits=i; + break; + } + } + + if ( checkCrcBits > (-1) ) { + for (uint8_t i = 0; i < currentListSize; i++) { + if (crcChecksum[checkCrcBits][i]==1) { + crcState[i]=0; //0=False, 1=True + } + } + } + + for (uint8_t i = 0; i < currentListSize; i++) decoderIterationCheck+=crcState[i]; + if (decoderIterationCheck==0) { + //perror("[SCL polar decoder] All list entries have failed the CRC checks."); + free(d_tilde); + free(pathMetric); + free(crcState); + nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1)); + nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); + nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits); + return(-1); + } + + nonFrozenBit++; + decoderIterationCheck=0; + checkCrcBits=-1; + } + } + + for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; + nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); + + for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) { + if ( crcState[listIndex[i]] == 1 ) { + for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_u[j]=bit[j][0][listIndex[i]]; + + //Extract the information bits (û to ĉ) + nr_polar_info_bit_extraction(polarParams->nr_polar_u, polarParams->nr_polar_cPrime, polarParams->information_bit_pattern, polarParams->N); + + //Deinterleaving (ĉ to b) + nr_polar_deinterleaver(polarParams->nr_polar_cPrime, polarParams->nr_polar_b, polarParams->interleaving_pattern, polarParams->K); + + //Remove the CRC (â) + for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_a[j]=polarParams->nr_polar_b[j]; + + break; + } + } + + free(d_tilde); + free(pathMetric); + free(crcState); + nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1)); + nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); + nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits); + nr_free_uint8_t_2D_array(extended_crc_generator_matrix, polarParams->K); + nr_free_uint8_t_2D_array(tempECGM, polarParams->K); + + /* + * Return bits. + */ + nr_byte2bit_uint8_32_t(polarParams->nr_polar_a, polarParams->payloadBits, out); + return(0); +} + +int8_t polar_decoder_aPriori( + double *input, + uint32_t *out, + t_nrPolar_paramsPtr polarParams, + uint8_t listSize, + uint8_t pathMetricAppr, + double *aPrioriPayload) +{ uint8_t ***bit = nr_alloc_uint8_t_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); uint8_t **bitUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True @@ -110,11 +360,13 @@ int8_t polar_decoder( if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 } else { //Information or CRC bit. - if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 0) ) { + if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && + (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 0) ) { //Information bit with known value of "0". updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); bitUpdated[currentBit][0]=1; //0=False, 1=True - } else if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 1) ) { + } else if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && + (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 1) ) { //Information bit with known value of "1". updatePathMetric(pathMetric, llr, currentListSize, 1, currentBit, pathMetricAppr); for (uint8_t i=0; inr_polar_cPrime, polarParams->nr_polar_b, polarParams->interleaving_pattern, polarParams->K); //Remove the CRC (â) - for (int j = 0; j < polarParams->payloadBits; j++) output[j]=polarParams->nr_polar_b[j]; + for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_a[j]=polarParams->nr_polar_b[j]; break; } @@ -271,5 +523,10 @@ int8_t polar_decoder( nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits); nr_free_uint8_t_2D_array(extended_crc_generator_matrix, polarParams->K); nr_free_uint8_t_2D_array(tempECGM, polarParams->K); + + /* + * Return bits. + */ + nr_byte2bit_uint8_32_t(polarParams->nr_polar_a, polarParams->payloadBits, out); return(0); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 464f91d7ce..a76639810f 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -19,6 +19,17 @@ * contact@openairinterface.org */ +/*!\file PHY/CODING/nrPolar_tools/nr_polar_defs.h + * \brief + * \author Turker Yilmaz + * \date 2018 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + #ifndef __NR_POLAR_DEFS__H__ #define __NR_POLAR_DEFS__H__ @@ -32,6 +43,9 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" +#define NR_POLAR_DECODER_LISTSIZE 8 //uint8_t +#define NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION 0 //uint8_t; 0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12) + static const uint8_t nr_polar_subblock_interleaver_pattern[32] = { 0, 1, 2, 4, 3, 5, 6, 7, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 14, 22, 15, 23, 24, 25, 26, 28, 27, 29, 30, 31 }; struct nrPolar_params { @@ -65,20 +79,33 @@ struct nrPolar_params { uint8_t **crc_generator_matrix; //G_P uint8_t **G_N; - //polar_encoder vectors: + //polar_encoder vectors uint8_t *nr_polar_crc; - uint8_t *nr_polar_b; - uint8_t *nr_polar_cPrime; - uint8_t *nr_polar_u; uint8_t *nr_polar_d; + uint8_t *nr_polar_e; + + //Polar Coding vectors + uint8_t *nr_polar_a; + uint8_t *nr_polar_cPrime; + uint8_t *nr_polar_b; + uint8_t *nr_polar_u; } __attribute__ ((__packed__)); typedef struct nrPolar_params t_nrPolar_params; typedef t_nrPolar_params *t_nrPolar_paramsPtr; -void polar_encoder(uint8_t *input, uint8_t *output, t_nrPolar_paramsPtr polarParams); +void polar_encoder(uint32_t *input, uint32_t *output, t_nrPolar_paramsPtr polarParams); -int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_paramsPtr polarParams, - uint8_t listSize, double *aPrioriPayload, uint8_t pathMetricAppr); +int8_t polar_decoder(double *input, + uint32_t *output, + t_nrPolar_paramsPtr polarParams, + uint8_t listSize, + uint8_t pathMetricAppr); +int8_t polar_decoder_aPriori(double *input, + uint32_t *output, + t_nrPolar_paramsPtr polarParams, + uint8_t listSize, + uint8_t pathMetricAppr, + double *aPrioriPayload); void nr_polar_init(t_nrPolar_paramsPtr *polarParams, int8_t messageType, diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index eafb45cab4..81a94864c6 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -19,40 +19,75 @@ * contact@openairinterface.org */ +/*!\file PHY/CODING/nrPolar_tools/nr_polar_encoder.c + * \brief + * \author Turker Yilmaz + * \date 2018 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -void polar_encoder( - uint8_t *input, - uint8_t *output, - t_nrPolar_paramsPtr polarParams) +void polar_encoder(uint32_t *in, + uint32_t *out, + t_nrPolar_paramsPtr polarParams) { + nr_bit2byte_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_a); /* * Bytewise operations */ - //Calculate CRC. - nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(input, polarParams->crc_generator_matrix, - polarParams->nr_polar_crc, polarParams->payloadBits, polarParams->crcParityBits); - for (uint8_t i = 0; i < polarParams->crcParityBits; i++) polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2); + nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_a, + polarParams->crc_generator_matrix, + polarParams->nr_polar_crc, + polarParams->payloadBits, + polarParams->crcParityBits); + for (uint8_t i = 0; i < polarParams->crcParityBits; i++) + polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2); //Attach CRC to the Transport Block. (a to b) - for (uint16_t i = 0; i < polarParams->payloadBits; i++) polarParams->nr_polar_b[i] = input[i]; + for (uint16_t i = 0; i < polarParams->payloadBits; i++) polarParams->nr_polar_b[i] = polarParams->nr_polar_a[i]; for (uint16_t i = polarParams->payloadBits; i < polarParams->K; i++) polarParams->nr_polar_b[i]= polarParams->nr_polar_crc[i-(polarParams->payloadBits)]; //Interleaving (c to c') - nr_polar_interleaver(polarParams->nr_polar_b, polarParams->nr_polar_cPrime, polarParams->interleaving_pattern, polarParams->K); + nr_polar_interleaver(polarParams->nr_polar_b, + polarParams->nr_polar_cPrime, + polarParams->interleaving_pattern, + polarParams->K); //Bit insertion (c' to u) - nr_polar_bit_insertion(polarParams->nr_polar_cPrime, polarParams->nr_polar_u, polarParams->N, polarParams->K, - polarParams->Q_I_N, polarParams->Q_PC_N, polarParams->n_pc); + nr_polar_bit_insertion(polarParams->nr_polar_cPrime, + polarParams->nr_polar_u, + polarParams->N, + polarParams->K, + polarParams->Q_I_N, + polarParams->Q_PC_N, + polarParams->n_pc); //Encoding (u to d) - nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_u, polarParams->G_N, polarParams->nr_polar_d, polarParams->N, polarParams->N); - for (uint16_t i = 0; i < polarParams->N; i++) polarParams->nr_polar_d[i] = (polarParams->nr_polar_d[i] % 2); + nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_u, + polarParams->G_N, + polarParams->nr_polar_d, + polarParams->N, + polarParams->N); + for (uint16_t i = 0; i < polarParams->N; i++) + polarParams->nr_polar_d[i] = (polarParams->nr_polar_d[i] % 2); //Rate matching //Sub-block interleaving (d to y) and Bit selection (y to e) - nr_polar_rate_matcher(polarParams->nr_polar_d, output, polarParams->rate_matching_pattern, polarParams->encoderLength); + nr_polar_rate_matcher(polarParams->nr_polar_d, + polarParams->nr_polar_e, + polarParams->rate_matching_pattern, + polarParams->encoderLength); + + /* + * Return bits. + */ + nr_byte2bit_uint8_32_t(polarParams->nr_polar_e, polarParams->encoderLength, out); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h index aa32b03e35..e910b881cb 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h @@ -19,15 +19,15 @@ * contact@openairinterface.org */ -/*! \file PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h -* \brief Defines the constant variables for polar coding of the PBCH from 38-212, V15.1.1 2018-04. -* \author -* \date 2018 -* \version 0.1 -* \company Eurecom -* \email: -* \note -* \warning +/*!\file PHY/CODING/nrPolar_tools/nr_polar_defs.h + * \brief Defines the constant variables for polar coding of the PBCH from 38-212, V15.1.1 2018-04. + * \author Turker Yilmaz + * \date 2018 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning */ #ifndef __NR_POLAR_PBCH_DEFS__H__ @@ -52,9 +52,6 @@ #define NR_POLAR_PBCH_I_BIL 0 //uint8_t #define NR_POLAR_PBCH_E 864 //uint16_t -//#define NR_POLAR_PBCH_L 5 //uint8_t -#define NR_POLAR_PBCH_PATH_METRIC_APPROXIMATION 0 //uint8_t; 0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12) - /* * TEST CODE */ diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index a4a86389cc..425e53e8b3 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -19,6 +19,17 @@ * contact@openairinterface.org */ +/*!\file PHY/CODING/nr_polar_init.h + * \brief + * \author Turker Yilmaz + * \date 2018 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + #include "nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" @@ -83,13 +94,15 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, //polar_encoder vectors: newPolarInitNode->nr_polar_crc = malloc(sizeof(uint8_t) * newPolarInitNode->crcParityBits); - newPolarInitNode->nr_polar_cPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); newPolarInitNode->nr_polar_d = malloc(sizeof(uint8_t) * newPolarInitNode->N); + newPolarInitNode->nr_polar_e = malloc(sizeof(uint8_t) * newPolarInitNode->encoderLength); //Polar Coding vectors newPolarInitNode->nr_polar_u = malloc(sizeof(uint8_t) * newPolarInitNode->N); //Decoder: nr_polar_uHat newPolarInitNode->nr_polar_cPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_cHat newPolarInitNode->nr_polar_b = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_bHat + newPolarInitNode->nr_polar_a = malloc(sizeof(uint8_t) * newPolarInitNode->payloadBits); //Decoder: nr_polar_aHat + newPolarInitNode->Q_0_Nminus1 = nr_polar_sequence_pattern(newPolarInitNode->n); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 3c062dbfa7..187aca9705 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -501,13 +501,13 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, unsigned short idx_demod =0; int8_t decoderState=0; uint8_t decoderListSize = 8, pathMetricAppr = 0; - double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload. memset(&pbch_a[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS); //printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell); - for (int i=0; ipbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN; + /*double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload. + for (int i=0; ipbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN;*/ int subframe_rx = proc->subframe_rx; @@ -605,7 +605,8 @@ uint16_t nr_rx_pbch( PHY_VARS_NR_UE *ue, //polar decoding de-rate matching - decoderState = polar_decoder(demod_pbch_e, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); + decoderState = polar_decoder(demod_pbch_e, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, pathMetricAppr); + //decoderState = polar_decoder_aPriori(demod_pbch_e, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, aPrioriArray, pathMetricAppr); //for (i=0; i Date: Mon, 20 Aug 2018 10:57:07 +0200 Subject: [PATCH 050/114] DCI debug --- openair1/PHY/CODING/TESTBENCH/polartest.c | 8 ++++++-- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index a78146042b..bd5b06e4f1 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -32,6 +32,8 @@ int main(int argc, char *argv[]) { double timeEncoderCumulative = 0, timeDecoderCumulative = 0; uint8_t aggregation_level; + uint32_t dci_pdu[4]; + while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:")) != -1) switch (arguments) { @@ -105,8 +107,10 @@ int main(int argc, char *argv[]) { } fprintf(logFile,",SNR,nBitError,blockErrorState,t_encoder[us],t_decoder[us]\n"); - uint8_t *testInput = malloc(sizeof(uint8_t) * testLength); //generate randomly - uint8_t *encoderOutput = malloc(sizeof(uint8_t) * coderLength); + //uint8_t *testInput = malloc(sizeof(uint8_t) * testLength); //generate randomly + //uint8_t *encoderOutput = malloc(sizeof(uint8_t) * coderLength); + uint32_t testInput[4], encoderOutput[4]; + double *modulatedInput = malloc (sizeof(double) * coderLength); //channel input double *channelOutput = malloc (sizeof(double) * coderLength); //add noise diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index e3504ea64e..0747c0e4d2 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -142,6 +142,7 @@ printf("frequency_domain_assignment = %05d = %#010x\n" #endif // Freq domain assignment fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); + printf("N_RB=%d & fsize=%d\n\n",N_RB,fsize); for (int i=0; ifrequency_domain_assignment>>(fsize-i-1))&1)< Date: Tue, 21 Aug 2018 10:01:26 +0200 Subject: [PATCH 051/114] cset start RE type fix --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index e7a2f3e945..93337d9821 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -177,7 +177,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, /*The coreset is initialised * in frequency: the first subcarrier is obtained by adding the first CRB overlapping the SSB and the rb_offset * in time: by its first slot and its first symbol*/ - uint8_t cset_start_sc = frame_parms.first_carrier_offset + ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+pdcch_params.rb_offset)*NR_NB_SC_PER_RB; + uint16_t cset_start_sc = frame_parms.first_carrier_offset + ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+pdcch_params.rb_offset)*NR_NB_SC_PER_RB; uint8_t cset_start_symb = pdcch_params.first_slot*frame_parms.symbols_per_slot + pdcch_params.first_symbol; dci_idx = 0; dmrs_idx = 0; From adafb8f9f16f52668c5f869df065b53f5081c88f Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Tue, 21 Aug 2018 10:29:39 +0200 Subject: [PATCH 052/114] switch to aggregation level 8 --- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index e3504ea64e..3a29532606 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -169,7 +169,7 @@ printf("frequency_domain_assignment = %05d = %#010x\n" dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]); /// rest of DCI alloc - dci_alloc->L = 4; + dci_alloc->L = 8; memcpy((void*)&dci_alloc->pdcch_params, (void*)params_rel15, sizeof(nfapi_nr_dl_config_pdcch_parameters_rel15_t)); dci_alloc->size = nr_get_dci_size(dci_alloc->pdcch_params.dci_format, dci_alloc->pdcch_params.rnti_type, From bdbec1ba646fcf77cc18b1aff6a5541be3872bfd Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Tue, 21 Aug 2018 10:45:07 +0200 Subject: [PATCH 053/114] Tiny symbol jump --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 93337d9821..28930f82af 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -253,6 +253,8 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, cce = dci_alloc.cce_list[cce_idx]; for (int reg_idx=0; reg_idx= frame_parms.ofdm_symbol_size) + k -= frame_parms.ofdm_symbol_size; l = cset_start_symb + cce.reg_list[reg_idx].symb_idx; k_prime = 0; for (int m=0; m Date: Tue, 21 Aug 2018 15:56:14 +0200 Subject: [PATCH 054/114] DMRS index update --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 28930f82af..90235ccf9b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -179,8 +179,8 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, * in time: by its first slot and its first symbol*/ uint16_t cset_start_sc = frame_parms.first_carrier_offset + ((int)floor(frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB)+pdcch_params.rb_offset)*NR_NB_SC_PER_RB; uint8_t cset_start_symb = pdcch_params.first_slot*frame_parms.symbols_per_slot + pdcch_params.first_symbol; + uint8_t cset_nsymb = pdcch_params.n_symb; dci_idx = 0; - dmrs_idx = 0; /// DMRS QPSK modulation /*There is a need to shift from which index the pregenerated DMRS sequence is used @@ -256,6 +256,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, if (k >= frame_parms.ofdm_symbol_size) k -= frame_parms.ofdm_symbol_size; l = cset_start_symb + cce.reg_list[reg_idx].symb_idx; + dmrs_idx = (cce.reg_list[reg_idx].reg_idx/cset_nsymb)*3; k_prime = 0; for (int m=0; m Date: Wed, 22 Aug 2018 10:42:29 +0200 Subject: [PATCH 055/114] Polar coding update 1of2 --- cmake_targets/CMakeLists.txt | 2 +- openair1/PHY/CODING/TESTBENCH/polartest.c | 87 +++-- openair1/PHY/CODING/coding_defs.h | 8 + openair1/PHY/CODING/crc_byte.c | 56 +++- .../nrPolar_tools/nr_bitwise_operations.c | 13 + .../nrPolar_tools/nr_polar_bit_insertion.c | 52 --- .../nr_polar_channel_interleaver_pattern.c | 63 ---- .../nrPolar_tools/nr_polar_decoding_tools.c | 79 ++++- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 235 ++++++++++--- .../CODING/nrPolar_tools/nr_polar_encoder.c | 103 ++++-- .../nrPolar_tools/nr_polar_info_bit_pattern.c | 131 -------- .../nr_polar_interleaving_pattern.c | 11 + .../nr_polar_kronecker_power_matrices.c | 11 + .../nrPolar_tools/nr_polar_matrix_and_array.c | 11 + .../nrPolar_tools/nr_polar_output_length.c | 46 --- .../CODING/nrPolar_tools/nr_polar_pbch_defs.h | 2 +- .../nrPolar_tools/nr_polar_procedures.c | 315 ++++++++++++++++++ .../nrPolar_tools/nr_polar_rate_match.c | 81 ----- openair1/PHY/CODING/nr_polar_init.c | 33 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 29 +- 20 files changed, 834 insertions(+), 534 deletions(-) delete mode 100644 openair1/PHY/CODING/nrPolar_tools/nr_polar_bit_insertion.c delete mode 100644 openair1/PHY/CODING/nrPolar_tools/nr_polar_channel_interleaver_pattern.c delete mode 100644 openair1/PHY/CODING/nrPolar_tools/nr_polar_info_bit_pattern.c delete mode 100644 openair1/PHY/CODING/nrPolar_tools/nr_polar_output_length.c create mode 100644 openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c delete mode 100644 openair1/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 9cb5472a1c..ec5509ffb2 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2492,7 +2492,7 @@ target_link_libraries (dlsim_tm4 ) add_executable(polartest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/polartest.c) -target_link_libraries(polartest m SIMU PHY PHY_NR -lm ${ATLAS_LIBRARIES}) +target_link_libraries(polartest m SIMU PHY PHY_NR PHY_COMMON -lm ${ATLAS_LIBRARIES}) foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index bd5b06e4f1..b0e8c97302 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -7,9 +7,11 @@ #include #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" +#include "PHY/CODING/coding_defs.h" #include "SIMULATION/TOOLS/sim.h" //#define DEBUG_POLAR_PARAMS +#define DEBUG_DCI_POLAR_PARAMS int main(int argc, char *argv[]) { @@ -21,6 +23,8 @@ int main(int argc, char *argv[]) { reset_meas(&timeDecoder); randominit(0); + crcTableInit(); + uint32_t crc; //Default simulation values (Aim for iterations = 1000000.) int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, -1=UCI double SNRstart = -20.0, SNRstop = 0.0, SNRinc= 0.5; //dB @@ -30,9 +34,7 @@ int main(int argc, char *argv[]) { int8_t decoderState=0, blockErrorState=0; //0 = Success, -1 = Decoding failed, 1 = Block Error. uint16_t testLength = 0, coderLength = 0, blockErrorCumulative=0, bitErrorCumulative=0; double timeEncoderCumulative = 0, timeDecoderCumulative = 0; - uint8_t aggregation_level; - - uint32_t dci_pdu[4]; + uint8_t aggregation_level, decoderListSize, pathMetricAppr; while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:")) != -1) switch (arguments) @@ -110,35 +112,80 @@ int main(int argc, char *argv[]) { //uint8_t *testInput = malloc(sizeof(uint8_t) * testLength); //generate randomly //uint8_t *encoderOutput = malloc(sizeof(uint8_t) * coderLength); uint32_t testInput[4], encoderOutput[4]; + memset(testInput,0,sizeof(testInput)); + memset(encoderOutput,0,sizeof(encoderOutput)); double *modulatedInput = malloc (sizeof(double) * coderLength); //channel input double *channelOutput = malloc (sizeof(double) * coderLength); //add noise - uint8_t *estimatedOutput = malloc(sizeof(uint8_t) * testLength); //decoder output + uint32_t *estimatedOutput = malloc(sizeof(uint8_t) * testLength); //decoder output - t_nrPolar_paramsPtr nrPolar_params = NULL; + t_nrPolar_paramsPtr nrPolar_params = NULL, currentPtr = NULL; nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); -#ifdef DEBUG_POLAR_PARAMS - nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); - nr_polar_init(&nrPolar_params, 1, 20, 1); - nr_polar_init(&nrPolar_params, 1, 21, 1); +#ifdef DEBUG_DCI_POLAR_PARAMS + unsigned int poly24c = 0xb2b11700; + printf("testInput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + testInput[0], testInput[1], testInput[2], testInput[3]); + printf("encOutput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + encoderOutput[0], encoderOutput[1], encoderOutput[2], encoderOutput[3]); + testInput[0]=0x01189400; + uint8_t testInput2[8]; + nr_crc_bit2bit_uint32_8_t(testInput, 32, testInput2); + printf("testInput2: [0]->%x \t [1]->%x \t [2]->%x \t [3]->%x\n [4]->%x \t [5]->%x \t [6]->%x \t [7]->%x \t\n", + testInput2[0], testInput2[1], testInput2[2], testInput2[3], + testInput2[4], testInput2[5], testInput2[6], testInput2[7]); + printf("crc32: [0]->0x%08x\n",crc24c(testInput2, 32)); + printf("crc56: [0]->0x%08x\n",crc24c(testInput2, 56)); + return 0; + uint8_t testInput8[4]; + /*testInput8[0]=0x00; + testInput8[1]=0x49; + testInput8[2]=0x81; + testInput8[3]=0x10; + testInput8[4]=0x00;*/ + testInput8[0]=0xff; + testInput8[1]=0xd0; + testInput8[2]=0xff; + testInput8[3]=0x82; + crc = crc24c(testInput8, 31); + for (int i=0;i<24;i++) printf("[i]=%d\n",(crc>>i)&1); + printf("crc: [0]->0x%08x\n",crc); + printf("crcbit: %x\n",crcbit(testInput8, 3, poly24c)); + return 0; + unsigned char test[] = "Thebigredfox"; + + for (int i=0;i<8;i++) printf("[i]=%d\n",(test[0]>>i)&1); + printf("test[0]=%x\n",test[0]); + printf("%s -- sizeof=%d\n",test,sizeof(test)); + printf("%x\n", crcbit(test, sizeof(test) - 1, poly24c)); + printf("%x\n", crc24c(test, (sizeof(test) - 1)*8)); + polarMessageType = 1; + testLength = 41; + aggregation_level=1; + coderLength = 108; nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); nr_polar_print_polarParams(nrPolar_params); - uint32_t in[4]; - in[0]=0x01189400; - in[1]=0xffffff0f; - uint8_t *out = malloc(sizeof(uint8_t) * 41); - nr_bit2byte_uint32_8_t(in, 41, out); - for (int i=0;i<41;i++) - printf("out[%d]=%d\n",i,out[i]); - uint32_t inn[4]; - nr_byte2bit_uint8_32_t(out, 41, inn); - printf("inn[0]=%#x, inn[1]=%#x\n",inn[0],inn[1]); + crc = crc24c(testInput, testLength)>>8; + for (int i=0;i<24;i++) printf("[i]=%d\n",(crc>>i)&1); + printf("crc: [0]->0x%08x\n",crc); + testInput[testLength>>3] = ((uint8_t*)&crc)[2]; + testInput[1+(testLength>>3)] = ((uint8_t*)&crc)[1]; + testInput[2+(testLength>>3)] = ((uint8_t*)&crc)[0]; + printf("testInput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + testInput[0], testInput[1], testInput[2], testInput[3]); + return (0); + currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength); + polar_encoder(testInput, encoderOutput, currentPtr); + printf("AFTER POLAR ENCODING\n"); + printf("testInput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + testInput[0], testInput[1], testInput[2], testInput[3]); + printf("encOutput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + encoderOutput[0], encoderOutput[1], encoderOutput[2], encoderOutput[3]); return (0); #endif - t_nrPolar_paramsPtr currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength); + currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength); // We assume no a priori knowledge available about the payload. double aPrioriArray[currentPtr->payloadBits]; diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h index d2975f3f93..f733b91eaa 100644 --- a/openair1/PHY/CODING/coding_defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -341,6 +341,14 @@ based on 3GPP UMTS/LTE specifications. */ uint32_t crc24b (uint8_t *inPtr, int32_t bitlen); +/*!\fn uint32_t crc24c(uint8_t *inPtr, int32_t bitlen) +\brief This computes a 24-bit crc ('c' variant for transport-block segments) +based on 3GPP Rel 15 specifications. +@param inPtr Pointer to input byte stream +@param bitlen length of inputs in bits +*/ +uint32_t crc24c (uint8_t *inPtr, int32_t bitlen); + /*!\fn uint32_t crc16(uint8_t *inPtr, int32_t bitlen) \brief This computes a 16-bit crc based on 3GPP UMTS specifications. @param inPtr Pointer to input byte stream diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index 0e1f0e065f..7a4c9a7b69 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -36,8 +36,12 @@ /*ref 36-212 v8.6.0 , pp 8-9 */ /* the highest degree is set by default */ -unsigned int poly24a = 0x864cfb00; //1000 0110 0100 1100 1111 1011 D^24 + D^23 + D^18 + D^17 + D^14 + D^11 + D^10 + D^7 + D^6 + D^5 + D^4 + D^3 + D + 1 -unsigned int poly24b = 0x80006300; // 1000 0000 0000 0000 0110 0011 D^24 + D^23 + D^6 + D^5 + D + 1 +unsigned int poly24a = 0x864cfb00; // 1000 0110 0100 1100 1111 1011 + // D^24 + D^23 + D^18 + D^17 + D^14 + D^11 + D^10 + D^7 + D^6 + D^5 + D^4 + D^3 + D + 1 +unsigned int poly24b = 0x80006300; // 1000 0000 0000 0000 0110 0011 + // D^24 + D^23 + D^6 + D^5 + D + 1 +unsigned int poly24c = 0xb2b11700; // 1011 0010 1011 0001 0001 0111 + // D^24+D^23+D^21+D^20+D^17+D^15+D^13+D^12+D^8+D^4+D^2+D+1 unsigned int poly16 = 0x10210000; // 0001 0000 0010 0001 D^16 + D^12 + D^5 + 1 unsigned int poly12 = 0x80F00000; // 1000 0000 1111 D^12 + D^11 + D^3 + D^2 + D + 1 unsigned int poly8 = 0x9B000000; // 1001 1011 D^8 + D^7 + D^4 + D^3 + D + 1 @@ -49,10 +53,11 @@ For initialization && verification purposes, The first bit is in the MSB of each byte *********************************************************/ -unsigned int -crcbit (unsigned char * inputptr, int octetlen, unsigned int poly) +unsigned int crcbit (unsigned char * inputptr, + int octetlen, + unsigned int poly) { - unsigned int i, crc = 0, c; + unsigned int i, crc = 0, c; while (octetlen-- > 0) { c = (*inputptr++) << 24; @@ -75,19 +80,21 @@ crcbit (unsigned char * inputptr, int octetlen, unsigned int poly) crc table initialization *********************************************************/ -static unsigned int crc24aTable[256]; -static unsigned int crc24bTable[256]; +static unsigned int crc24aTable[256]; +static unsigned int crc24bTable[256]; +static unsigned int crc24cTable[256]; static unsigned short crc16Table[256]; static unsigned short crc12Table[256]; static unsigned char crc8Table[256]; void crcTableInit (void) { - unsigned char c = 0; + unsigned char c = 0; do { crc24aTable[c] = crcbit (&c, 1, poly24a); crc24bTable[c] = crcbit (&c, 1, poly24b); + crc24cTable[c] = crcbit (&c, 1, poly24c); crc16Table[c] = (unsigned short) (crcbit (&c, 1, poly16) >> 16); crc12Table[c] = (unsigned short) (crcbit (&c, 1, poly12) >> 16); crc8Table[c] = (unsigned char) (crcbit (&c, 1, poly8) >> 24); @@ -99,8 +106,8 @@ Byte by byte implementations, assuming initial byte is 0 padded (in MSB) if necessary *********************************************************/ -unsigned int -crc24a (unsigned char * inptr, int bitlen) +unsigned int crc24a (unsigned char * inptr, + int bitlen) { int octetlen, resbit; @@ -119,11 +126,11 @@ crc24a (unsigned char * inptr, int bitlen) return crc; } -unsigned int crc24b (unsigned char * inptr, int bitlen) +unsigned int crc24b (unsigned char * inptr, + int bitlen) { - - int octetlen, resbit; - unsigned int crc = 0; + int octetlen, resbit; + unsigned int crc = 0; octetlen = bitlen / 8; /* Change in octets */ resbit = (bitlen % 8); @@ -138,6 +145,27 @@ unsigned int crc24b (unsigned char * inptr, int bitlen) return crc; } +unsigned int crc24c (unsigned char * inptr, + int bitlen) +{ + int octetlen, resbit; + unsigned int crc = 0; + octetlen = bitlen / 8; /* Change in octets */ + resbit = (bitlen % 8); + + while (octetlen-- > 0) { +/*#ifdef DEBUG_CRC24C + printf("crc24c: in %x => crc %x (%x)\n",crc,*inptr,crc24cTable[(*inptr) ^ (crc >> 24)]); +#endif*/ + crc = (crc << 8) ^ crc24cTable[(*inptr++) ^ (crc >> 24)]; + } + + if (resbit > 0) + crc = (crc << resbit) ^ crc24cTable[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))]; + + return crc; +} + unsigned int crc16 (unsigned char * inptr, int bitlen) { diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c index 4394a2ffff..ba06922816 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c @@ -41,3 +41,16 @@ void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out) { out[i]|=in[(i*32)]; } } + +void nr_crc_bit2bit_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out) { + out[0]=0xff; + out[1]=0xff; + out[2]=0xff; + uint8_t arrayInd = ceil(arraySize / 32.0); + for (int i = 0; i < arrayInd; i++) { + out[3+i*4] = ((in[i] & (0x0000000f))<<4) | ((in[i] & (0x000000f0))>>4); + out[4+i*4] = (((in[i] & (0x00000f00))<<4) | ((in[i] & (0x0000f000))>>4))>>8; + out[5+i*4] = (((in[i] & (0x000f0000))<<4) | ((in[i] & (0x00f00000))>>4))>>16; + out[6+i*4] = (((in[i] & (0x0f000000))<<4) | ((in[i] & (0xf0000000))>>4))>>24; + } +} diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_bit_insertion.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_bit_insertion.c deleted file mode 100644 index 4c1c2bbce5..0000000000 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_bit_insertion.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" - -void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, uint16_t N, uint16_t K, - int16_t *Q_I_N, int16_t *Q_PC_N, uint8_t n_PC){ - - uint16_t k=0; - uint8_t flag; - - if (n_PC>0) { - /* - * - */ - } else { - for (int n=0; n<=N-1; n++) { - flag=0; - for (int m=0; m<=(K+n_PC)-1; m++) { - if ( n == Q_I_N[m]) { - flag=1; - break; - } - } - if (flag) { // n ϵ Q_I_N - output[n]=input[k]; - k++; - } else { - output[n] = 0; - } - } - } - -} diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_channel_interleaver_pattern.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_channel_interleaver_pattern.c deleted file mode 100644 index 35e7585e1a..0000000000 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_channel_interleaver_pattern.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" - -void nr_polar_channel_interleaver_pattern(uint16_t *cip, uint8_t I_BIL, uint16_t E){ - - if (I_BIL == 1) { - uint16_t T=0, k; - while( ((T/2)*(T+1)) < E ) T++; - - - int16_t **v = malloc(T * sizeof(*v)); - for (int i = 0; i <= T-1; i++) v[i] = malloc((T-i) * sizeof(*(v[i]))); - - k=0; - for (int i = 0; i <= T-1; i++) { - for (int j = 0; j <= (T-1)-i; j++) { - if (k= offset ) { @@ -40,8 +60,14 @@ void updateLLR(double ***llr, uint8_t **llrU, uint8_t ***bit, uint8_t **bitU, llrU[row][col]=1; } -void updateBit(uint8_t ***bit, uint8_t **bitU, uint8_t listSize, uint16_t row, - uint16_t col, uint16_t xlen, uint8_t ylen) { +void updateBit(uint8_t ***bit, + uint8_t **bitU, + uint8_t listSize, + uint16_t row, + uint16_t col, + uint16_t xlen, + uint8_t ylen) +{ uint16_t offset = ( xlen/(pow(2,(ylen-col))) ); for (uint8_t i=0; i eq. (8a) and (11b), 1 --> eq. (9) and (12) +#define NR_POLAR_AGGREGATION_LEVEL_1_PRIME 149 //uint16_t +#define NR_POLAR_AGGREGATION_LEVEL_2_PRIME 151 //uint16_t +#define NR_POLAR_AGGREGATION_LEVEL_4_PRIME 157 //uint16_t +#define NR_POLAR_AGGREGATION_LEVEL_8_PRIME 163 //uint16_t +#define NR_POLAR_AGGREGATION_LEVEL_16_PRIME 167 //uint16_t + static const uint8_t nr_polar_subblock_interleaver_pattern[32] = { 0, 1, 2, 4, 3, 5, 6, 7, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 14, 22, 15, 23, 24, 25, 26, 28, 27, 29, 30, 31 }; struct nrPolar_params { //messageType: 0=PBCH, 1=DCI, -1=UCI - int8_t idx; //idx = messageType*messageLength; + int idx; //idx = (messageType * messageLength * aggregation_prime); struct nrPolar_params *nextPtr; uint8_t n_max; @@ -66,6 +72,7 @@ struct nrPolar_params { uint16_t K; uint16_t N; uint8_t n; + uint32_t crcBit; uint16_t *interleaving_pattern; uint16_t *rate_matching_pattern; @@ -79,27 +86,37 @@ struct nrPolar_params { uint8_t **crc_generator_matrix; //G_P uint8_t **G_N; + //lowercase: bits, Uppercase: Bits stored in bytes //polar_encoder vectors uint8_t *nr_polar_crc; - uint8_t *nr_polar_d; - uint8_t *nr_polar_e; + uint8_t *nr_polar_aPrime; + uint8_t *nr_polar_D; + uint8_t *nr_polar_E; //Polar Coding vectors - uint8_t *nr_polar_a; - uint8_t *nr_polar_cPrime; - uint8_t *nr_polar_b; - uint8_t *nr_polar_u; + uint8_t *nr_polar_A; + uint8_t *nr_polar_CPrime; + uint8_t *nr_polar_B; + uint8_t *nr_polar_U; } __attribute__ ((__packed__)); typedef struct nrPolar_params t_nrPolar_params; typedef t_nrPolar_params *t_nrPolar_paramsPtr; -void polar_encoder(uint32_t *input, uint32_t *output, t_nrPolar_paramsPtr polarParams); +void polar_encoder(uint32_t *input, + uint32_t *output, + t_nrPolar_paramsPtr polarParams); + +void polar_encoder_dci(uint32_t *in, + uint32_t *out, + t_nrPolar_paramsPtr polarParams, + uint32_t n_RNTI); int8_t polar_decoder(double *input, uint32_t *output, t_nrPolar_paramsPtr polarParams, uint8_t listSize, uint8_t pathMetricAppr); + int8_t polar_decoder_aPriori(double *input, uint32_t *output, t_nrPolar_paramsPtr polarParams, @@ -111,83 +128,195 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, int8_t messageType, uint16_t messageLength, uint8_t aggregation_level); + void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams); + t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams, int8_t messageType, uint16_t messageLength); +uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level); + uint8_t** nr_polar_kronecker_power_matrices(uint8_t n); const uint16_t* nr_polar_sequence_pattern(uint8_t n); -uint32_t nr_polar_output_length(uint16_t K, uint16_t E, uint8_t n_max); +/*!@fn uint32_t nr_polar_output_length(uint16_t K, uint16_t E, uint8_t n_max) + * @brief Computes... + * @param K Number of bits to encode (=payloadBits+crcParityBits) + * @param E + * @param n_max */ +uint32_t nr_polar_output_length(uint16_t K, + uint16_t E, + uint8_t n_max); -void nr_polar_channel_interleaver_pattern(uint16_t *cip, uint8_t I_BIL, - uint16_t E); +void nr_polar_channel_interleaver_pattern(uint16_t *cip, + uint8_t I_BIL, + uint16_t E); -void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P_i_, - uint16_t K, uint16_t N, uint16_t E); +void nr_polar_rate_matching_pattern(uint16_t *rmp, + uint16_t *J, + const uint8_t *P_i_, + uint16_t K, + uint16_t N, + uint16_t E); -void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, - uint16_t K, uint16_t N, uint16_t E); +void nr_polar_rate_matching(double *input, + double *output, + uint16_t *rmp, + uint16_t K, + uint16_t N, + uint16_t E); -void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_); +void nr_polar_interleaving_pattern(uint16_t K, + uint8_t I_IL, + uint16_t *PI_k_); -void nr_polar_info_bit_pattern(uint8_t *ibp, int16_t *Q_I_N, int16_t *Q_F_N, - uint16_t *J, const uint16_t *Q_0_Nminus1, uint16_t K, uint16_t N, uint16_t E, - uint8_t n_PC); +void nr_polar_info_bit_pattern(uint8_t *ibp, + int16_t *Q_I_N, + int16_t *Q_F_N, + uint16_t *J, + const uint16_t *Q_0_Nminus1, + uint16_t K, + uint16_t N, + uint16_t E, + uint8_t n_PC); -void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *output, - uint8_t *pattern, uint16_t size); +void nr_polar_info_bit_extraction(uint8_t *input, + uint8_t *output, + uint8_t *pattern, + uint16_t size); -void nr_bit2byte_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out); -void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out); +void nr_bit2byte_uint32_8_t(uint32_t *in, + uint16_t arraySize, + uint8_t *out); -void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, uint16_t N, - uint16_t K, int16_t *Q_I_N, int16_t *Q_PC_N, uint8_t n_PC); +void nr_byte2bit_uint8_32_t(uint8_t *in, + uint16_t arraySize, + uint32_t *out); -void nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(uint8_t *matrix1, uint8_t **matrix2, - uint8_t *output, uint16_t row, uint16_t col); +void nr_crc_bit2bit_uint32_8_t(uint32_t *in, + uint16_t arraySize, + uint8_t *out); -uint8_t ***nr_alloc_uint8_t_3D_array(uint16_t xlen, uint16_t ylen, - uint16_t zlen); -uint8_t **nr_alloc_uint8_t_2D_array(uint16_t xlen, uint16_t ylen); -double ***nr_alloc_double_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen); +void nr_polar_bit_insertion(uint8_t *input, + uint8_t *output, + uint16_t N, + uint16_t K, + int16_t *Q_I_N, + int16_t *Q_PC_N, + uint8_t n_PC); -void nr_free_uint8_t_3D_array(uint8_t ***input, uint16_t xlen, uint16_t ylen); -void nr_free_uint8_t_2D_array(uint8_t **input, uint16_t xlen); -void nr_free_double_3D_array(double ***input, uint16_t xlen, uint16_t ylen); +void nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(uint8_t *matrix1, + uint8_t **matrix2, + uint8_t *output, + uint16_t row, + uint16_t col); -void updateLLR(double ***llr, uint8_t **llrU, uint8_t ***bit, uint8_t **bitU, - uint8_t listSize, uint16_t row, uint16_t col, uint16_t xlen, - uint8_t ylen, uint8_t approximation); -void updateBit(uint8_t ***bit, uint8_t **bitU, uint8_t listSize, uint16_t row, - uint16_t col, uint16_t xlen, uint8_t ylen); -void updatePathMetric(double *pathMetric, double ***llr, uint8_t listSize, - uint8_t bitValue, uint16_t row, uint8_t approximation); -void updatePathMetric2(double *pathMetric, double ***llr, uint8_t listSize, - uint16_t row, uint8_t approximation); -void computeLLR(double ***llr, uint16_t row, uint16_t col, uint8_t i, - uint16_t offset, uint8_t approximation); -void updateCrcChecksum(uint8_t **crcChecksum, uint8_t **crcGen, - uint8_t listSize, uint32_t i2, uint8_t len); -void updateCrcChecksum2(uint8_t **crcChecksum, uint8_t **crcGen, - uint8_t listSize, uint32_t i2, uint8_t len); -void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len); +uint8_t ***nr_alloc_uint8_t_3D_array(uint16_t xlen, + uint16_t ylen, + uint16_t zlen); + +uint8_t **nr_alloc_uint8_t_2D_array(uint16_t xlen, + uint16_t ylen); + +double ***nr_alloc_double_3D_array(uint16_t xlen, + uint16_t ylen, + uint16_t zlen); + +void nr_free_uint8_t_3D_array(uint8_t ***input, + uint16_t xlen, + uint16_t ylen); + +void nr_free_uint8_t_2D_array(uint8_t **input, + uint16_t xlen); + +void nr_free_double_3D_array(double ***input, + uint16_t xlen, + uint16_t ylen); + +void updateLLR(double ***llr, + uint8_t **llrU, + uint8_t ***bit, + uint8_t **bitU, + uint8_t listSize, + uint16_t row, + uint16_t col, + uint16_t xlen, + uint8_t ylen, + uint8_t approximation); + +void updateBit(uint8_t ***bit, + uint8_t **bitU, + uint8_t listSize, + uint16_t row, + uint16_t col, + uint16_t xlen, + uint8_t ylen); + +void updatePathMetric(double *pathMetric, + double ***llr, + uint8_t listSize, + uint8_t bitValue, + uint16_t row, + uint8_t approximation); + +void updatePathMetric2(double *pathMetric, + double ***llr, + uint8_t listSize, + uint16_t row, + uint8_t approximation); + +void computeLLR(double ***llr, + uint16_t row, + uint16_t col, + uint8_t i, + uint16_t offset, + uint8_t approximation); + +void updateCrcChecksum(uint8_t **crcChecksum, + uint8_t **crcGen, + uint8_t listSize, + uint32_t i2, + uint8_t len); + +void updateCrcChecksum2(uint8_t **crcChecksum, + uint8_t **crcGen, + uint8_t listSize, + uint32_t i2, + uint8_t len); + +void nr_sort_asc_double_1D_array_ind(double *matrix, + uint8_t *ind, + uint8_t len); uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits); + uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits); + uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits); -static inline void nr_polar_rate_matcher(uint8_t *input, unsigned char *output, uint16_t *pattern, uint16_t size) { +static inline void nr_polar_rate_matcher(uint8_t *input, + unsigned char *output, + uint16_t *pattern, + uint16_t size) +{ for (int i=0; ipayloadBits, polarParams->nr_polar_a); + if (polarParams->idx == 0){//PBCH + nr_bit2byte_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_A); + /* + * Bytewise operations + */ + //Calculate CRC. + nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_A, + polarParams->crc_generator_matrix, + polarParams->nr_polar_crc, + polarParams->payloadBits, + polarParams->crcParityBits); + for (uint8_t i = 0; i < polarParams->crcParityBits; i++) + polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2); - /* - * Bytewise operations - */ - //Calculate CRC. - nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_a, - polarParams->crc_generator_matrix, - polarParams->nr_polar_crc, - polarParams->payloadBits, - polarParams->crcParityBits); - for (uint8_t i = 0; i < polarParams->crcParityBits; i++) - polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2); + //Attach CRC to the Transport Block. (a to b) + for (uint16_t i = 0; i < polarParams->payloadBits; i++) + polarParams->nr_polar_B[i] = polarParams->nr_polar_A[i]; + for (uint16_t i = polarParams->payloadBits; i < polarParams->K; i++) + polarParams->nr_polar_B[i]= polarParams->nr_polar_crc[i-(polarParams->payloadBits)]; + } else { //UCI - //Attach CRC to the Transport Block. (a to b) - for (uint16_t i = 0; i < polarParams->payloadBits; i++) polarParams->nr_polar_b[i] = polarParams->nr_polar_a[i]; - for (uint16_t i = polarParams->payloadBits; i < polarParams->K; i++) - polarParams->nr_polar_b[i]= polarParams->nr_polar_crc[i-(polarParams->payloadBits)]; + } //Interleaving (c to c') - nr_polar_interleaver(polarParams->nr_polar_b, - polarParams->nr_polar_cPrime, + nr_polar_interleaver(polarParams->nr_polar_B, + polarParams->nr_polar_CPrime, polarParams->interleaving_pattern, polarParams->K); //Bit insertion (c' to u) - nr_polar_bit_insertion(polarParams->nr_polar_cPrime, - polarParams->nr_polar_u, + nr_polar_bit_insertion(polarParams->nr_polar_CPrime, + polarParams->nr_polar_U, polarParams->N, polarParams->K, polarParams->Q_I_N, @@ -71,23 +75,70 @@ void polar_encoder(uint32_t *in, polarParams->n_pc); //Encoding (u to d) - nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_u, + nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_U, polarParams->G_N, - polarParams->nr_polar_d, + polarParams->nr_polar_D, polarParams->N, polarParams->N); for (uint16_t i = 0; i < polarParams->N; i++) - polarParams->nr_polar_d[i] = (polarParams->nr_polar_d[i] % 2); + polarParams->nr_polar_D[i] = (polarParams->nr_polar_D[i] % 2); //Rate matching //Sub-block interleaving (d to y) and Bit selection (y to e) - nr_polar_rate_matcher(polarParams->nr_polar_d, - polarParams->nr_polar_e, + nr_polar_rate_matcher(polarParams->nr_polar_D, + polarParams->nr_polar_E, polarParams->rate_matching_pattern, polarParams->encoderLength); /* * Return bits. */ - nr_byte2bit_uint8_32_t(polarParams->nr_polar_e, polarParams->encoderLength, out); + nr_byte2bit_uint8_32_t(polarParams->nr_polar_E, polarParams->encoderLength, out); +} + +void polar_encoder_dci(uint32_t *in, + uint32_t *out, + t_nrPolar_paramsPtr polarParams, + uint32_t n_RNTI) +{ //(a to a') + nr_crc_bit2bit_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_aPrime); + //Parity bits computation (p) + polarParams->crcBit = crc24c(polarParams->nr_polar_aPrime, + (polarParams->payloadBits+polarParams->crcParityBits)); + + //Interleaving (c to c') + nr_polar_interleaver(polarParams->nr_polar_B, + polarParams->nr_polar_CPrime, + polarParams->interleaving_pattern, + polarParams->K); + + //Bit insertion (c' to u) + nr_polar_bit_insertion(polarParams->nr_polar_CPrime, + polarParams->nr_polar_U, + polarParams->N, + polarParams->K, + polarParams->Q_I_N, + polarParams->Q_PC_N, + polarParams->n_pc); + + //Encoding (u to d) + nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_U, + polarParams->G_N, + polarParams->nr_polar_D, + polarParams->N, + polarParams->N); + for (uint16_t i = 0; i < polarParams->N; i++) + polarParams->nr_polar_D[i] = (polarParams->nr_polar_D[i] % 2); + + //Rate matching + //Sub-block interleaving (d to y) and Bit selection (y to e) + nr_polar_rate_matcher(polarParams->nr_polar_D, + polarParams->nr_polar_E, + polarParams->rate_matching_pattern, + polarParams->encoderLength); + + /* + * Return bits. + */ + nr_byte2bit_uint8_32_t(polarParams->nr_polar_E, polarParams->encoderLength, out); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_info_bit_pattern.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_info_bit_pattern.c deleted file mode 100644 index a46c427b81..0000000000 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_info_bit_pattern.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" - -void nr_polar_info_bit_pattern(uint8_t *ibp, int16_t *Q_I_N, int16_t *Q_F_N, - uint16_t *J, const uint16_t *Q_0_Nminus1, uint16_t K, uint16_t N, uint16_t E, - uint8_t n_PC) { - - int16_t *Q_Ftmp_N = malloc(sizeof(int16_t) * (N + 1)); // Last element shows the final - int16_t *Q_Itmp_N = malloc(sizeof(int16_t) * (N + 1)); // array index assigned a value. - - for (int i = 0; i <= N; i++) { - Q_Ftmp_N[i] = -1; // Empty array. - Q_Itmp_N[i] = -1; - } - - uint8_t flag; - uint16_t limit, ind; - - if (E < N) { - if ((K / (double) E) <= (7.0 / 16)) { //puncturing - for (int n = 0; n <= N - E - 1; n++) { - ind = Q_Ftmp_N[N] + 1; - Q_Ftmp_N[ind] = J[n]; - Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; - } - - if ((E / (double) N) >= (3.0 / 4)) { - limit = ceil((double) (3 * N - 2 * E) / 4); - for (int n = 0; n <= limit - 1; n++) { - ind = Q_Ftmp_N[N] + 1; - Q_Ftmp_N[ind] = n; - Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; - } - } else { - limit = ceil((double) (9 * N - 4 * E) / 16); - for (int n = 0; n <= limit - 1; n++) { - ind = Q_Ftmp_N[N] + 1; - Q_Ftmp_N[ind] = n; - Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; - } - } - } else { //shortening - for (int n = E; n <= N - 1; n++) { - ind = Q_Ftmp_N[N] + 1; - Q_Ftmp_N[ind] = J[n]; - Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; - } - } - } - - //Q_I,tmp_N = Q_0_N-1 \ Q_F,tmp_N - for (int n = 0; n <= N - 1; n++) { - flag = 1; - for (int m = 0; m <= Q_Ftmp_N[N]; m++) { - if (Q_0_Nminus1[n] == Q_Ftmp_N[m]) { - flag = 0; - break; - } - } - if (flag) { - Q_Itmp_N[Q_Itmp_N[N] + 1] = Q_0_Nminus1[n]; - Q_Itmp_N[N]++; - } - } - - //Q_I_N comprises (K+n_PC) most reliable bit indices in Q_I,tmp_N - for (int n = 0; n <= (K + n_PC) - 1; n++) { - ind = Q_Itmp_N[N] + n - ((K + n_PC) - 1); - Q_I_N[n] = Q_Itmp_N[ind]; - } - - //Q_F_N = Q_0_N-1 \ Q_I_N - for (int n = 0; n <= N - 1; n++) { - flag = 1; - for (int m = 0; m <= (K + n_PC) - 1; m++) { - if (Q_0_Nminus1[n] == Q_I_N[m]) { - flag = 0; - break; - } - } - if (flag) { - Q_F_N[Q_F_N[N] + 1] = Q_0_Nminus1[n]; - Q_F_N[N]++; - } - } - - //Information Bit Pattern - for (int n = 0; n <= N - 1; n++) { - ibp[n] = 0; - - for (int m = 0; m <= (K + n_PC) - 1; m++) { - if (n == Q_I_N[m]) { - ibp[n] = 1; - break; - } - } - } - - free(Q_Ftmp_N); - free(Q_Itmp_N); -} - -void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *output, uint8_t *pattern, uint16_t size) { - uint16_t j = 0; - for (int i = 0; i < size; i++) { - if (pattern[i] > 0) { - output[j] = input[i]; - j++; - } - } -} diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c index da9c51085f..b4ba758b96 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c @@ -19,6 +19,17 @@ * contact@openairinterface.org */ +/*!\file PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c + * \brief + * \author Turker Yilmaz + * \date 2018 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" void nr_polar_interleaving_pattern(uint16_t K, uint8_t I_IL, uint16_t *PI_k_){ diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_kronecker_power_matrices.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_kronecker_power_matrices.c index ba72cd8b11..09892cb791 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_kronecker_power_matrices.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_kronecker_power_matrices.c @@ -19,6 +19,17 @@ * contact@openairinterface.org */ +/*!\file PHY/CODING/nrPolar_tools/nr_polar_kronecker_power_matrices.c + * \brief + * \author Turker Yilmaz + * \date 2018 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" uint8_t (*const(G_N_1[])) = { diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c index 572b016cfa..e6676238a3 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c @@ -19,6 +19,17 @@ * contact@openairinterface.org */ +/*!\file PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c + * \brief + * \author Turker Yilmaz + * \date 2018 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" void nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(uint8_t *matrix1, uint8_t **matrix2, diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_output_length.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_output_length.c deleted file mode 100644 index e2d65c22fc..0000000000 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_output_length.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include -#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" - -uint32_t nr_polar_output_length(uint16_t K, uint16_t E, uint8_t n_max){ - uint8_t n_1, n_2, n_min=5, n; - uint32_t polar_code_output_length; - double R_min=1.0/8; - - if ( (E <= (9.0/8)*pow(2,ceil(log2(E))-1)) && (K/E < 9.0/16) ) { - n_1 = ceil(log2(E))-1; - } else { - n_1 = ceil(log2(E)); - } - - n_2 = ceil(log2(K/R_min)); - - n=n_max; - if (n>n_1) n=n_1; - if (n>n_2) n=n_2; - if (n0) { + /* + * + */ + } else { + for (int n=0; n<=N-1; n++) { + flag=0; + for (int m=0; m<=(K+n_PC)-1; m++) { + if ( n == Q_I_N[m]) { + flag=1; + break; + } + } + if (flag) { // n ϵ Q_I_N + output[n]=input[k]; + k++; + } else { + output[n] = 0; + } + } + } + +} + + +uint32_t nr_polar_output_length(uint16_t K, + uint16_t E, + uint8_t n_max) +{ + uint8_t n_1, n_2, n_min=5, n; + double R_min=1.0/8; + + if ( (E <= (9.0/8)*pow(2,ceil(log2(E))-1)) && (K/E < 9.0/16) ) { + n_1 = ceil(log2(E))-1; + } else { + n_1 = ceil(log2(E)); + } + + n_2 = ceil(log2(K/R_min)); + + n=n_max; + if (n>n_1) n=n_1; + if (n>n_2) n=n_2; + if (n= (3.0 / 4)) { + limit = ceil((double) (3 * N - 2 * E) / 4); + for (int n = 0; n <= limit - 1; n++) { + ind = Q_Ftmp_N[N] + 1; + Q_Ftmp_N[ind] = n; + Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; + } + } else { + limit = ceil((double) (9 * N - 4 * E) / 16); + for (int n = 0; n <= limit - 1; n++) { + ind = Q_Ftmp_N[N] + 1; + Q_Ftmp_N[ind] = n; + Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; + } + } + } else { //shortening + for (int n = E; n <= N - 1; n++) { + ind = Q_Ftmp_N[N] + 1; + Q_Ftmp_N[ind] = J[n]; + Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; + } + } + } + + //Q_I,tmp_N = Q_0_N-1 \ Q_F,tmp_N + for (int n = 0; n <= N - 1; n++) { + flag = 1; + for (int m = 0; m <= Q_Ftmp_N[N]; m++) { + if (Q_0_Nminus1[n] == Q_Ftmp_N[m]) { + flag = 0; + break; + } + } + if (flag) { + Q_Itmp_N[Q_Itmp_N[N] + 1] = Q_0_Nminus1[n]; + Q_Itmp_N[N]++; + } + } + + //Q_I_N comprises (K+n_PC) most reliable bit indices in Q_I,tmp_N + for (int n = 0; n <= (K + n_PC) - 1; n++) { + ind = Q_Itmp_N[N] + n - ((K + n_PC) - 1); + Q_I_N[n] = Q_Itmp_N[ind]; + } + + //Q_F_N = Q_0_N-1 \ Q_I_N + for (int n = 0; n <= N - 1; n++) { + flag = 1; + for (int m = 0; m <= (K + n_PC) - 1; m++) { + if (Q_0_Nminus1[n] == Q_I_N[m]) { + flag = 0; + break; + } + } + if (flag) { + Q_F_N[Q_F_N[N] + 1] = Q_0_Nminus1[n]; + Q_F_N[N]++; + } + } + + //Information Bit Pattern + for (int n = 0; n <= N - 1; n++) { + ibp[n] = 0; + + for (int m = 0; m <= (K + n_PC) - 1; m++) { + if (n == Q_I_N[m]) { + ibp[n] = 1; + break; + } + } + } + + free(Q_Ftmp_N); + free(Q_Itmp_N); +} + + +void nr_polar_info_bit_extraction(uint8_t *input, + uint8_t *output, + uint8_t *pattern, + uint16_t size) +{ + uint16_t j = 0; + for (int i = 0; i < size; i++) { + if (pattern[i] > 0) { + output[j] = input[i]; + j++; + } + } +} + + +void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P_i_, uint16_t K, uint16_t N, uint16_t E){ + + uint8_t i; + uint16_t *d, *y, ind; + d = (uint16_t *)malloc(sizeof(uint16_t) * N); + y = (uint16_t *)malloc(sizeof(uint16_t) * N); + + for (int m=0; m<=N-1; m++) d[m]=m; + + for (int m=0; m<=N-1; m++){ + i=floor((32*m)/N); + J[m] = (P_i_[i]*(N/32)) + (m%(N/32)); + y[m] = d[J[m]]; + } + + if (E>=N) { //repetition + for (int k=0; k<=E-1; k++) { + ind = (k%N); + rmp[k]=y[ind]; + } + } else { + if ( (K/(double)E) <= (7.0/16) ) { //puncturing + for (int k=0; k<=E-1; k++) { + rmp[k]=y[k+N-E]; + } + } else { //shortening + for (int k=0; k<=E-1; k++) { + rmp[k]=y[k]; + } + } + } + + free(d); + free(y); +} + + +void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E){ + + if (E>=N) { //repetition + for (int i=0; i<=N-1; i++) output[i]=0; + for (int i=0; i<=E-1; i++){ + output[rmp[i]]+=input[i]; + } + } else { + if ( (K/(double)E) <= (7.0/16) ) { //puncturing + for (int i=0; i<=N-1; i++) output[i]=0; + } else { //shortening + for (int i=0; i<=N-1; i++) output[i]=INFINITY; + } + + for (int i=0; i<=E-1; i++){ + output[rmp[i]]=input[i]; + } + } + +} diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c deleted file mode 100644 index 90f16183c8..0000000000 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -#include -#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" - -void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P_i_, uint16_t K, uint16_t N, uint16_t E){ - - uint8_t i; - uint16_t *d, *y, ind; - d = (uint16_t *)malloc(sizeof(uint16_t) * N); - y = (uint16_t *)malloc(sizeof(uint16_t) * N); - - for (int m=0; m<=N-1; m++) d[m]=m; - - for (int m=0; m<=N-1; m++){ - i=floor((32*m)/N); - J[m] = (P_i_[i]*(N/32)) + (m%(N/32)); - y[m] = d[J[m]]; - } - - if (E>=N) { //repetition - for (int k=0; k<=E-1; k++) { - ind = (k%N); - rmp[k]=y[ind]; - } - } else { - if ( (K/(double)E) <= (7.0/16) ) { //puncturing - for (int k=0; k<=E-1; k++) { - rmp[k]=y[k+N-E]; - } - } else { //shortening - for (int k=0; k<=E-1; k++) { - rmp[k]=y[k]; - } - } - } - - free(d); - free(y); -} - - -void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E){ - - if (E>=N) { //repetition - for (int i=0; i<=N-1; i++) output[i]=0; - for (int i=0; i<=E-1; i++){ - output[rmp[i]]+=input[i]; - } - } else { - if ( (K/(double)E) <= (7.0/16) ) { //puncturing - for (int i=0; i<=N-1; i++) output[i]=0; - } else { //shortening - for (int i=0; i<=N-1; i++) output[i]=INFINITY; - } - - for (int i=0; i<=E-1; i++){ - output[rmp[i]]=input[i]; - } - } - -} diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index 425e53e8b3..dcf0c81575 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -42,10 +42,11 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, uint8_t aggregation_level) { t_nrPolar_paramsPtr currentPtr = *polarParams; + uint16_t aggregation_prime = nr_polar_aggregation_prime(aggregation_level); //Parse the list. If the node is already created, return without initialization. while (currentPtr != NULL) { - if (currentPtr->idx == (messageType * messageLength)) return; + if (currentPtr->idx == (messageType * messageLength * aggregation_prime)) return; else currentPtr = currentPtr->nextPtr; } @@ -54,7 +55,7 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, if (newPolarInitNode != NULL) { - newPolarInitNode->idx = (messageType * messageLength); + newPolarInitNode->idx = (messageType * messageLength * aggregation_prime); newPolarInitNode->nextPtr = NULL; if (messageType == 0) { //PBCH @@ -94,14 +95,15 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, //polar_encoder vectors: newPolarInitNode->nr_polar_crc = malloc(sizeof(uint8_t) * newPolarInitNode->crcParityBits); - newPolarInitNode->nr_polar_d = malloc(sizeof(uint8_t) * newPolarInitNode->N); - newPolarInitNode->nr_polar_e = malloc(sizeof(uint8_t) * newPolarInitNode->encoderLength); + newPolarInitNode->nr_polar_aPrime = malloc(sizeof(uint8_t) * ((ceil((newPolarInitNode->payloadBits)/32.0)*4)+3)); + newPolarInitNode->nr_polar_D = malloc(sizeof(uint8_t) * newPolarInitNode->N); + newPolarInitNode->nr_polar_E = malloc(sizeof(uint8_t) * newPolarInitNode->encoderLength); //Polar Coding vectors - newPolarInitNode->nr_polar_u = malloc(sizeof(uint8_t) * newPolarInitNode->N); //Decoder: nr_polar_uHat - newPolarInitNode->nr_polar_cPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_cHat - newPolarInitNode->nr_polar_b = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_bHat - newPolarInitNode->nr_polar_a = malloc(sizeof(uint8_t) * newPolarInitNode->payloadBits); //Decoder: nr_polar_aHat + newPolarInitNode->nr_polar_U = malloc(sizeof(uint8_t) * newPolarInitNode->N); //Decoder: nr_polar_uHat + newPolarInitNode->nr_polar_CPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_cHat + newPolarInitNode->nr_polar_B = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_bHat + newPolarInitNode->nr_polar_A = malloc(sizeof(uint8_t) * newPolarInitNode->payloadBits); //Decoder: nr_polar_aHat @@ -180,12 +182,14 @@ void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams) t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams, int8_t messageType, - uint16_t messageLength) + uint16_t messageLength, + uint8_t aggregation_level) { t_nrPolar_paramsPtr currentPtr = NULL; while (polarParams != NULL) { - if (polarParams->idx == (messageType * messageLength)) { + if (polarParams->idx == + (messageType * messageLength * (nr_polar_aggregation_prime(aggregation_level)) )) { currentPtr = polarParams; break; } else { @@ -194,3 +198,12 @@ t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams, } return currentPtr; } + +uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level) +{ + if (aggregation_level == 1) return NR_POLAR_AGGREGATION_LEVEL_1_PRIME; + else if (aggregation_level == 2) return NR_POLAR_AGGREGATION_LEVEL_2_PRIME; + else if (aggregation_level == 4) return NR_POLAR_AGGREGATION_LEVEL_4_PRIME; + else if (aggregation_level == 8) return NR_POLAR_AGGREGATION_LEVEL_8_PRIME; + else return NR_POLAR_AGGREGATION_LEVEL_16_PRIME; +} diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 7276d48592..e5965ca7b5 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -202,31 +202,22 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, } /// DCI payload processing - //channel coding - nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); - t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size); - - uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size); - uint8_t *encoderOutput = malloc(sizeof(uint8_t) * currentPtr->encoderLength); - uint32_t encoded_payload[4]; - - nr_bit2byte_uint32_8_t(dci_alloc.dci_pdu,dci_alloc.size,encoderInput); - polar_encoder(encoderInput, encoderOutput, currentPtr); - nr_byte2bit_uint8_32_t(encoderOutput, currentPtr->encoderLength, encoded_payload); + // CRC attachment + Scrambling + Channel coding + Rate matching + uint32_t scrambled_payload[NR_MAX_DCI_SIZE_DWORD]; + uint32_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; + //nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); + //t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); + //polar_encoder_dci(dci_alloc.dci_pdu, scrambled_payload, currentPtr, n_RNTI); #ifdef DEBUG_POLAR_PARAMS - printf("DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + printf("\n\nInt = %d \t Hex = 0x%08x\n\n",n_RNTI,n_RNTI); + /*printf("DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); printf("Encoded Payload: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - encoded_payload[0], encoded_payload[1], encoded_payload[2], encoded_payload[3]); + scrambled_payload[0], scrambled_payload[1], scrambled_payload[2], scrambled_payload[3]);*/ + return 0; #endif - // scrambling - uint32_t scrambled_payload[NR_MAX_DCI_SIZE_DWORD]; - uint32_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value; - uint32_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; - nr_pdcch_scrambling(encoded_payload, dci_alloc.size, Nid, n_RNTI, scrambled_payload); - // QPSK modulation int16_t mod_dci[NR_MAX_DCI_SIZE>>1]; for (int i=0; i>1; i++) { From 09b44d36233436f9b29c2c3ffb2ebf44c5760643 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Wed, 22 Aug 2018 12:21:10 +0200 Subject: [PATCH 056/114] CMakeLists update --- cmake_targets/CMakeLists.txt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index ec5509ffb2..6ee88e37ac 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1111,20 +1111,16 @@ set(PHY_POLARSRC ${OPENAIR1_DIR}/PHY/CODING/nr_polar_init.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_crc_byte.c - ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_bit_insertion.c - ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_channel_interleaver_pattern.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_crc.c + ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_decoder.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c - ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_info_bit_pattern.c + ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_encoder.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_interleaving_pattern.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_kernal_operation.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_kronecker_power_matrices.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c - ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_output_length.c - ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_rate_match.c + ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_procedures.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_sequence_pattern.c - ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_encoder.c - ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_decoder.c ) set(PHY_TURBOIF ${OPENAIR1_DIR}/PHY/CODING/coding_load.c From fdbf8e7f408bae535e8e8bba220164f87eea40bc Mon Sep 17 00:00:00 2001 From: yilmazt Date: Wed, 22 Aug 2018 12:37:24 +0200 Subject: [PATCH 057/114] minor update --- .../CODING/nrPolar_tools/nr_polar_decoder.c | 20 +++++++++---------- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 438044b447..f8969f790a 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -247,16 +247,16 @@ int8_t polar_decoder( for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) { if ( crcState[listIndex[i]] == 1 ) { - for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_u[j]=bit[j][0][listIndex[i]]; + for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_U[j]=bit[j][0][listIndex[i]]; //Extract the information bits (û to ĉ) - nr_polar_info_bit_extraction(polarParams->nr_polar_u, polarParams->nr_polar_cPrime, polarParams->information_bit_pattern, polarParams->N); + nr_polar_info_bit_extraction(polarParams->nr_polar_U, polarParams->nr_polar_CPrime, polarParams->information_bit_pattern, polarParams->N); //Deinterleaving (ĉ to b) - nr_polar_deinterleaver(polarParams->nr_polar_cPrime, polarParams->nr_polar_b, polarParams->interleaving_pattern, polarParams->K); + nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); //Remove the CRC (â) - for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_a[j]=polarParams->nr_polar_b[j]; + for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; break; } @@ -274,7 +274,7 @@ int8_t polar_decoder( /* * Return bits. */ - nr_byte2bit_uint8_32_t(polarParams->nr_polar_a, polarParams->payloadBits, out); + nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } @@ -500,16 +500,16 @@ int8_t polar_decoder_aPriori( for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) { if ( crcState[listIndex[i]] == 1 ) { - for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_u[j]=bit[j][0][listIndex[i]]; + for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_U[j]=bit[j][0][listIndex[i]]; //Extract the information bits (û to ĉ) - nr_polar_info_bit_extraction(polarParams->nr_polar_u, polarParams->nr_polar_cPrime, polarParams->information_bit_pattern, polarParams->N); + nr_polar_info_bit_extraction(polarParams->nr_polar_U, polarParams->nr_polar_CPrime, polarParams->information_bit_pattern, polarParams->N); //Deinterleaving (ĉ to b) - nr_polar_deinterleaver(polarParams->nr_polar_cPrime, polarParams->nr_polar_b, polarParams->interleaving_pattern, polarParams->K); + nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); //Remove the CRC (â) - for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_a[j]=polarParams->nr_polar_b[j]; + for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; break; } @@ -527,6 +527,6 @@ int8_t polar_decoder_aPriori( /* * Return bits. */ - nr_byte2bit_uint8_32_t(polarParams->nr_polar_a, polarParams->payloadBits, out); + nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 21fef0f329..a1ec1c6701 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -133,7 +133,8 @@ void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams); t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams, int8_t messageType, - uint16_t messageLength); + uint16_t messageLength, + uint8_t aggregation_level); uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level); From 2e44c4c186989c0db1357a0361a3152d5f45256f Mon Sep 17 00:00:00 2001 From: yilmazt Date: Wed, 22 Aug 2018 17:24:29 +0200 Subject: [PATCH 058/114] Polar coding update 2of2 --- openair1/PHY/CODING/TESTBENCH/polartest.c | 4 +- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 11 +--- .../CODING/nrPolar_tools/nr_polar_encoder.c | 55 +++++++++++++++---- openair1/PHY/CODING/nr_polar_init.c | 5 +- openair1/PHY/NR_TRANSPORT/nr_dci.c | 22 ++++---- 5 files changed, 62 insertions(+), 35 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index b0e8c97302..69a28dfb68 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -175,7 +175,7 @@ int main(int argc, char *argv[]) { printf("testInput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", testInput[0], testInput[1], testInput[2], testInput[3]); return (0); - currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength); + currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength, aggregation_level); polar_encoder(testInput, encoderOutput, currentPtr); printf("AFTER POLAR ENCODING\n"); printf("testInput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", @@ -185,7 +185,7 @@ int main(int argc, char *argv[]) { return (0); #endif - currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength); + currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength, aggregation_level); // We assume no a priori knowledge available about the payload. double aPrioriArray[currentPtr->payloadBits]; diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index a1ec1c6701..e44b4632dd 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -109,7 +109,7 @@ void polar_encoder(uint32_t *input, void polar_encoder_dci(uint32_t *in, uint32_t *out, t_nrPolar_paramsPtr polarParams, - uint32_t n_RNTI); + uint16_t n_RNTI); int8_t polar_decoder(double *input, uint32_t *output, @@ -297,14 +297,7 @@ uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits); uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits); -static inline void nr_polar_rate_matcher(uint8_t *input, - unsigned char *output, - uint16_t *pattern, - uint16_t size) -{ - for (int i=0; inr_polar_D, - polarParams->nr_polar_E, - polarParams->rate_matching_pattern, - polarParams->encoderLength); + nr_polar_interleaver(polarParams->nr_polar_D, + polarParams->nr_polar_E, + polarParams->rate_matching_pattern, + polarParams->encoderLength); /* * Return bits. @@ -99,12 +101,38 @@ void polar_encoder(uint32_t *in, void polar_encoder_dci(uint32_t *in, uint32_t *out, t_nrPolar_paramsPtr polarParams, - uint32_t n_RNTI) -{ //(a to a') + uint16_t n_RNTI) +{ +#ifdef DEBUG_POLAR_ENCODER_DCI + printf("[polar_encoder_dci] in: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", in[0], in[1], in[2], in[3]); +#endif + //(a to a') nr_crc_bit2bit_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_aPrime); //Parity bits computation (p) polarParams->crcBit = crc24c(polarParams->nr_polar_aPrime, (polarParams->payloadBits+polarParams->crcParityBits)); +#ifdef DEBUG_POLAR_ENCODER_DCI + printf("[polar_encoder_dci] crc: 0x%08x\n", polarParams->crcBit); +#endif + //(a to b) + //Using "nr_polar_aPrime" to hold "nr_polar_b". + uint8_t arrayInd = ceil(polarParams->payloadBits / 32.0); + for (int j=0; jnr_polar_B[i+j*32] = (in[j]>>i)&1; + } + } + for (int i=0; i<((polarParams->payloadBits)%32); i++) { + polarParams->nr_polar_B[i+(arrayInd-1)*32] = (in[(arrayInd-1)]>>i)&1; + } + for (int i=0; i<8; i++) { + polarParams->nr_polar_B[polarParams->payloadBits+i] = ((polarParams->crcBit)>>(31-i))&1; + } + //Scrambling + for (int i=0; i<16; i++) { + polarParams->nr_polar_B[polarParams->payloadBits+8+i] = + ( (((polarParams->crcBit)>>(23-i))&1) + ((n_RNTI>>(15-i))&1) ) % 2; + } //Interleaving (c to c') nr_polar_interleaver(polarParams->nr_polar_B, @@ -132,13 +160,20 @@ void polar_encoder_dci(uint32_t *in, //Rate matching //Sub-block interleaving (d to y) and Bit selection (y to e) - nr_polar_rate_matcher(polarParams->nr_polar_D, - polarParams->nr_polar_E, - polarParams->rate_matching_pattern, - polarParams->encoderLength); + nr_polar_interleaver(polarParams->nr_polar_D, + polarParams->nr_polar_E, + polarParams->rate_matching_pattern, + polarParams->encoderLength); /* * Return bits. */ nr_byte2bit_uint8_32_t(polarParams->nr_polar_E, polarParams->encoderLength, out); +#ifdef DEBUG_POLAR_ENCODER_DCI + uint8_t outputInd = ceil(polarParams->encoderLength / 32.0); + printf("[polar_encoder_dci] out: "); + for (int i = 0; i < outputInd; i++) { + printf("[%d]->0x%08x\t", i, out[i]); + } +#endif } diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index dcf0c81575..32e9cca553 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -201,9 +201,10 @@ t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams, uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level) { - if (aggregation_level == 1) return NR_POLAR_AGGREGATION_LEVEL_1_PRIME; + if (aggregation_level == 0) return 0; + else if (aggregation_level == 1) return NR_POLAR_AGGREGATION_LEVEL_1_PRIME; else if (aggregation_level == 2) return NR_POLAR_AGGREGATION_LEVEL_2_PRIME; else if (aggregation_level == 4) return NR_POLAR_AGGREGATION_LEVEL_4_PRIME; else if (aggregation_level == 8) return NR_POLAR_AGGREGATION_LEVEL_8_PRIME; - else return NR_POLAR_AGGREGATION_LEVEL_16_PRIME; + else return NR_POLAR_AGGREGATION_LEVEL_16_PRIME; //aggregation_level == 16 } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index e5965ca7b5..78a6241b7a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -34,7 +34,7 @@ //#define DEBUG_PDCCH_DMRS //#define DEBUG_DCI -#define DEBUG_POLAR_PARAMS +//#define DEBUG_POLAR_PARAMS extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; @@ -203,30 +203,28 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, /// DCI payload processing // CRC attachment + Scrambling + Channel coding + Rate matching - uint32_t scrambled_payload[NR_MAX_DCI_SIZE_DWORD]; - uint32_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; - //nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); - //t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); - //polar_encoder_dci(dci_alloc.dci_pdu, scrambled_payload, currentPtr, n_RNTI); + uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD]; + uint16_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; + nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); + t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); + polar_encoder_dci(dci_alloc.dci_pdu, encoder_output, currentPtr, n_RNTI); #ifdef DEBUG_POLAR_PARAMS - printf("\n\nInt = %d \t Hex = 0x%08x\n\n",n_RNTI,n_RNTI); /*printf("DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); printf("Encoded Payload: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - scrambled_payload[0], scrambled_payload[1], scrambled_payload[2], scrambled_payload[3]);*/ - return 0; + encoder_output[0], encoder_output[1], encoder_output[2], encoder_output[3]);*/ #endif // QPSK modulation int16_t mod_dci[NR_MAX_DCI_SIZE>>1]; for (int i=0; i>1; i++) { - idx = (((scrambled_payload[i<<1]>>(i<<1))&1)<<1) ^ ((scrambled_payload[(i<<1)+1]>>((i<<1)+1))&1); + idx = (((encoder_output[i<<1]>>(i<<1))&1)<<1) ^ ((encoder_output[(i<<1)+1]>>((i<<1)+1))&1); mod_dci[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; mod_dci[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; #ifdef DEBUG_DCI - printf("i %d idx %d b0-b1 %d-%d mod_dci %d %d\n", i, idx, (((scrambled_payload[(i<<1)>>5])>>((i<<1)&0x1f))&1), - (((scrambled_payload[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), mod_dci[(i<<1)], mod_dci[(i<<1)+1]); + printf("i %d idx %d b0-b1 %d-%d mod_dci %d %d\n", i, idx, (((encoder_output[(i<<1)>>5])>>((i<<1)&0x1f))&1), + (((encoder_output[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1), mod_dci[(i<<1)], mod_dci[(i<<1)+1]); #endif } From 42d70a9078a2f369205516fb41758cbc44dfbe44 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Wed, 22 Aug 2018 17:52:18 +0200 Subject: [PATCH 059/114] minor fixes --- .../CODING/nrPolar_tools/nr_polar_encoder.c | 5 ++ openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 62 +++++++++---------- targets/RT/USER/nr-softmodem.c | 1 + 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 0f63ec6e26..6ea207850f 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -133,6 +133,11 @@ void polar_encoder_dci(uint32_t *in, polarParams->nr_polar_B[polarParams->payloadBits+8+i] = ( (((polarParams->crcBit)>>(23-i))&1) + ((n_RNTI>>(15-i))&1) ) % 2; } +#ifdef DEBUG_POLAR_ENCODER_DCI + printf("[polar_encoder_dci] B: "); + for (int i = 0; i < polarParams->K; i++) printf("%d-", polarParams->nr_polar_B[i]); + printf("\n"); +#endif //Interleaving (c to c') nr_polar_interleaver(polarParams->nr_polar_B, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 0747c0e4d2..f79d58c822 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -31,7 +31,7 @@ */ #include "nr_dci.h" -#define DEBUG_NFAPI_NR_RNTI_RA +//#define DEBUG_NFAPI_NR_RNTI_RA void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m) { @@ -129,36 +129,36 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, case NFAPI_NR_DL_DCI_FORMAT_1_0: switch(params_rel15->rnti_type) { case NFAPI_NR_RNTI_RA: -#ifdef DEBUG_NFAPI_NR_RNTI_RA -printf("frequency_domain_assignment = %05d = %#010x\n" - " time_domain_assignment = %05d = %#010x\n" - " vrb_to_prb_mapping = %05d = %#010x\n" - " MCS = %05d = %#010x\n" - " tb_scaling = %05d = %#010x\n", - pdu_rel15->frequency_domain_assignment,pdu_rel15->frequency_domain_assignment, - pdu_rel15->time_domain_assignment,pdu_rel15->time_domain_assignment, - pdu_rel15->vrb_to_prb_mapping,pdu_rel15->vrb_to_prb_mapping, - pdu_rel15->mcs,pdu_rel15->mcs,pdu_rel15->tb_scaling,pdu_rel15->tb_scaling); -#endif - // Freq domain assignment - fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); - printf("N_RB=%d & fsize=%d\n\n",N_RB,fsize); - for (int i=0; ifrequency_domain_assignment>>(fsize-i-1))&1)<time_domain_assignment>>(3-i))&1)<vrb_to_prb_mapping&1)<mcs>>(4-i))&1)<tb_scaling>>(1-i))&1)<>1 ) ); + #ifdef DEBUG_NFAPI_NR_RNTI_RA + printf("frequency_domain_assignment = %05d = %#010x\n" + " time_domain_assignment = %05d = %#010x\n" + " vrb_to_prb_mapping = %05d = %#010x\n" + " MCS = %05d = %#010x\n" + " tb_scaling = %05d = %#010x\n" + " N_RB = %05d = %#010x\n" + " fsize = %05d = %#010x\n", + pdu_rel15->frequency_domain_assignment,pdu_rel15->frequency_domain_assignment, + pdu_rel15->time_domain_assignment,pdu_rel15->time_domain_assignment, + pdu_rel15->vrb_to_prb_mapping,pdu_rel15->vrb_to_prb_mapping, + pdu_rel15->mcs,pdu_rel15->mcs,pdu_rel15->tb_scaling,pdu_rel15->tb_scaling, + N_RB,N_RB,fsize,fsize); + #endif + for (int i=0; ifrequency_domain_assignment>>(fsize-i-1))&1)<time_domain_assignment>>(3-i))&1)<vrb_to_prb_mapping&1)<mcs>>(4-i))&1)<tb_scaling>>(1-i))&1)< Date: Wed, 22 Aug 2018 21:04:23 +0200 Subject: [PATCH 060/114] minor encoder fixes --- .../CODING/nrPolar_tools/nr_polar_encoder.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 6ea207850f..0334610fa1 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -114,21 +114,24 @@ void polar_encoder_dci(uint32_t *in, #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] crc: 0x%08x\n", polarParams->crcBit); #endif + //(a to b) - //Using "nr_polar_aPrime" to hold "nr_polar_b". - uint8_t arrayInd = ceil(polarParams->payloadBits / 32.0); - for (int j=0; jnr_polar_B[i+j*32] = (in[j]>>i)&1; + /* + * Bytewise operations + */ + uint8_t arrayInd = ceil(polarParams->payloadBits / 8.0); + for (int i=0; inr_polar_B[j+(i*8)] = ((polarParams->nr_polar_aPrime[3+i]>>(7-j)) & 1); } } - for (int i=0; i<((polarParams->payloadBits)%32); i++) { - polarParams->nr_polar_B[i+(arrayInd-1)*32] = (in[(arrayInd-1)]>>i)&1; + for (int i=0; i<((polarParams->payloadBits)%8); i++) { + polarParams->nr_polar_B[i+(arrayInd-1)*8] = ((polarParams->nr_polar_aPrime[3+(arrayInd-1)]>>(7-i)) & 1); } for (int i=0; i<8; i++) { polarParams->nr_polar_B[polarParams->payloadBits+i] = ((polarParams->crcBit)>>(31-i))&1; } - //Scrambling + //Scrambling (b to c) for (int i=0; i<16; i++) { polarParams->nr_polar_B[polarParams->payloadBits+8+i] = ( (((polarParams->crcBit)>>(23-i))&1) + ((n_RNTI>>(15-i))&1) ) % 2; @@ -175,8 +178,10 @@ void polar_encoder_dci(uint32_t *in, */ nr_byte2bit_uint8_32_t(polarParams->nr_polar_E, polarParams->encoderLength, out); #ifdef DEBUG_POLAR_ENCODER_DCI + printf("[polar_encoder_dci] E: "); + for (int i = 0; i < polarParams->encoderLength; i++) printf("%d-", polarParams->nr_polar_E[i]); uint8_t outputInd = ceil(polarParams->encoderLength / 32.0); - printf("[polar_encoder_dci] out: "); + printf("\n[polar_encoder_dci] out: "); for (int i = 0; i < outputInd; i++) { printf("[%d]->0x%08x\t", i, out[i]); } From d2f2dfc0a3616a4eb227574f06ce891f93e8724c Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Thu, 23 Aug 2018 11:07:02 +0200 Subject: [PATCH 061/114] MIB config assert --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index c3325cb289..b268d57a76 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -140,10 +140,10 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int subframe) { nr_generate_pss(gNB->d_pss, txdataF, AMP, ssb_start_symbol, cfg, fp); nr_generate_sss(gNB->d_sss, txdataF, AMP_OVER_2, ssb_start_symbol, cfg, fp); - /*if ((frame_mod8) == 0){ + if ((frame_mod8) == 0){ if (gNB->pbch_configured != 1)return; gNB->pbch_configured = 0; - }*/ + } nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF, AMP_OVER_2, ssb_start_symbol, cfg, fp); nr_generate_pbch(&gNB->pbch, pbch_pdu, txdataF, AMP_OVER_2, ssb_start_symbol, n_hf, Lmax, ssb_index, frame, cfg, fp); } From d89602c8afa72a71afb19cd390a143e3a7b44cf1 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Thu, 23 Aug 2018 11:16:20 +0200 Subject: [PATCH 062/114] UE adding polar decoder --- .../CODING/nrPolar_tools/nr_polar_decoder.c | 4 +- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 2 +- openair1/PHY/INIT/nr_init_ue.c | 9 +- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 96 +++++++------------ openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 14 ++- openair1/PHY/defs_nr_UE.h | 1 + targets/RT/USER/nr-ue.c | 4 +- 7 files changed, 55 insertions(+), 75 deletions(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index f8969f790a..51a0328d7e 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -40,7 +40,7 @@ int8_t polar_decoder( double *input, - uint32_t *out, + uint8_t *out, t_nrPolar_paramsPtr polarParams, uint8_t listSize, uint8_t pathMetricAppr) @@ -274,7 +274,7 @@ int8_t polar_decoder( /* * Return bits. */ - nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); + //nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index e44b4632dd..fdf34398fa 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -112,7 +112,7 @@ void polar_encoder_dci(uint32_t *in, uint16_t n_RNTI); int8_t polar_decoder(double *input, - uint32_t *output, + uint8_t *output, t_nrPolar_paramsPtr polarParams, uint8_t listSize, uint8_t pathMetricAppr); diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index bcbbb968d7..806350e2a9 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -933,8 +933,9 @@ void nr_lte_ue_transport(PHY_VARS_UE *ue,int abstraction_flag) { }*/ -void phy_init_nr_top(NR_DL_FRAME_PARMS *frame_parms) +void phy_init_nr_top(PHY_VARS_NR_UE *ue) { + NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; crcTableInit(); @@ -960,7 +961,11 @@ void phy_init_nr_top(NR_DL_FRAME_PARMS *frame_parms) generate_ul_reference_signal_sequences(SHRT_MAX); // Polar encoder init for PBCH - nr_polar_init(&frame_parms->pbch_polar_params, 1); + //nr_polar_init(&frame_parms->pbch_polar_params, 1); + nr_polar_init(&ue->nrPolar_params, + NR_POLAR_PBCH_MESSAGE_TYPE, + NR_POLAR_PBCH_PAYLOAD_BITS, + NR_POLAR_PBCH_AGGREGATION_LEVEL); //lte_sync_time_init(frame_parms); diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index acc4be1a14..2ee0f6dc26 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -36,6 +36,7 @@ #endif //#include "PHY/defs.h" #include "PHY/defs_nr_UE.h" +#include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h" //#include "PHY/extern.h" //#include "SCHED/defs.h" //#include "SIMULATION/TOOLS/defs.h" // for taus @@ -3719,67 +3720,34 @@ uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB, void dci_decoding(uint8_t DCI_LENGTH, uint8_t aggregation_level, - int8_t *e, + t_nrPolar_paramsPtr currentPtr, + double *e, uint8_t *decoded_output) { + + int8_t decoderState=0; - uint8_t dummy_w_rx[3*(MAX_DCI_SIZE_BITS+16+64)]; - int8_t w_rx[3*(MAX_DCI_SIZE_BITS+16+32)],d_rx[96+(3*(MAX_DCI_SIZE_BITS+16))]; - - uint16_t RCC; - - uint16_t D=(DCI_LENGTH+16+64); - uint16_t coded_bits; #ifdef DEBUG_DCI_DECODING int32_t i; #endif - if (aggregation_level>3) { + if (aggregation_level>16) { LOG_I(PHY," dci.c: dci_decoding FATAL, illegal aggregation_level %d\n",aggregation_level); return; } - coded_bits = 72 * (1<>3)); - -#ifdef DEBUG_DCI_DECODING - printf("Before Viterbi\n"); - - for (i=0; i<16+DCI_LENGTH; i++) - printf("%d : (%d,%d,%d)\n",i,*(d_rx+96+(3*i)),*(d_rx+97+(3*i)),*(d_rx+98+(3*i))); - -#endif - //debug_printf("Doing DCI Viterbi \n"); - phy_viterbi_lte_sse2(d_rx+96,decoded_output,16+DCI_LENGTH); - //debug_printf("Done DCI Viterbi \n"); + + decoderState = polar_decoder(e, + decoded_output, + currentPtr, + 8, + 0); + } @@ -3954,7 +3922,8 @@ void nr_dci_decoding_procedure0(int s, NR_DCI_ALLOC_t *dci_alloc, //x int16_t eNB_id, //x uint8_t current_thread_id, //x - NR_DL_FRAME_PARMS *frame_parms, //x + NR_DL_FRAME_PARMS *frame_parms, + t_nrPolar_paramsPtr *nrPolar_params, //x uint8_t mi, uint16_t crc_scrambled_values[13], //x uint8_t L, @@ -3974,6 +3943,7 @@ void nr_dci_decoding_procedure0(int s, int L2 = (1 << L); unsigned int Yk, nb_candidates = 0, i, m; unsigned int CCEmap_cand; + double *polar_input = malloc (sizeof(double) * 108*L); // A[p], p is the current active CORESET uint16_t A[3]={39827,39829,39839}; @@ -4171,7 +4141,12 @@ void nr_dci_decoding_procedure0(int s, printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we enter function dci_decoding(sizeof_bits=%d L=%d) -----\n",sizeof_bits,L); printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we have to replace this part of the code by polar decoding\n"); #endif - dci_decoding(sizeof_bits, L, &pdcch_vars[eNB_id]->e_rx[CCEind * 72], &dci_decoded_output[current_thread_id][0]); + //&pdcch_vars[eNB_id]->e_rx[CCEind * 54] + + nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits, L); + t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits,L); + + dci_decoding(sizeof_bits, L, currentPtr, polar_input, &dci_decoded_output[current_thread_id][0]); /* for (i=0;i<3+(sizeof_bits>>3);i++) printf("dci_decoded_output[%d] => %x\n",i,dci_decoded_output[i]); @@ -5124,6 +5099,7 @@ uint8_t nr_dci_decoding_procedure(int s, NR_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]]; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + t_nrPolar_paramsPtr *nrPolar_params = &ue->nrPolar_params; uint8_t mi;// = get_mi(&ue->frame_parms, nr_tti_rx); // we need to initialize this values as crc is going to be compared with them uint16_t c_rnti=pdcch_vars[eNB_id]->crnti; @@ -5223,7 +5199,7 @@ uint8_t nr_dci_decoding_procedure(int s, css_dci_format,(1<<2)); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 2, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5241,7 +5217,7 @@ uint8_t nr_dci_decoding_procedure(int s, css_dci_format,(1<<3)); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 3, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5259,7 +5235,7 @@ uint8_t nr_dci_decoding_procedure(int s, css_dci_format,(1<<4)); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 4, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5285,7 +5261,7 @@ uint8_t nr_dci_decoding_procedure(int s, #endif // for aggregation level 1. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 0, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, @@ -5298,7 +5274,7 @@ uint8_t nr_dci_decoding_procedure(int s, } // for aggregation level 2. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 1, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, @@ -5311,7 +5287,7 @@ uint8_t nr_dci_decoding_procedure(int s, } // for aggregation level 4. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 2, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, @@ -5324,7 +5300,7 @@ uint8_t nr_dci_decoding_procedure(int s, } // for aggregation level 8. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 3, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, @@ -5337,7 +5313,7 @@ uint8_t nr_dci_decoding_procedure(int s, } // for aggregation level 16. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 4, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, @@ -5403,7 +5379,7 @@ uint8_t nr_dci_decoding_procedure(int s, /* * To be removed until here */ - nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 0, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5431,7 +5407,7 @@ uint8_t nr_dci_decoding_procedure(int s, uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 1, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5448,7 +5424,7 @@ uint8_t nr_dci_decoding_procedure(int s, uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 2, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5465,7 +5441,7 @@ uint8_t nr_dci_decoding_procedure(int s, uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 3, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5482,7 +5458,7 @@ uint8_t nr_dci_decoding_procedure(int s, uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, mi, + nr_dci_decoding_procedure0(s,p,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 4, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index e526d0c5cf..59646eda41 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -535,15 +535,17 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, unsigned short idx_demod =0; int8_t decoderState=0; uint8_t decoderListSize = 8, pathMetricAppr = 0; + double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload. memset(&pbch_a[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS); //printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell); - /*double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload. - for (int i=0; ipbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN;*/ + for (int i=0; ipbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN; int subframe_rx = proc->subframe_rx; + + printf("ue->current_thread_id[subframe_rx] %d subframe_rx %d\n",ue->current_thread_id[subframe_rx], subframe_rx); pbch_e_rx = &nr_ue_pbch_vars->llr[0]; @@ -651,7 +653,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, //#endif //polar decoding de-rate matching - decoderState = polar_decoder(demod_pbch_e, pbch_a, &frame_parms->pbch_polar_params, decoderListSize, pathMetricAppr); + t_nrPolar_paramsPtr currentPtr = nr_polar_params(&ue->nrPolar_params, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL); + decoderState = polar_decoder(demod_pbch_e, pbch_a_b, currentPtr, decoderListSize, pathMetricAppr); printf("polar decoder state %d\n", decoderState); if(decoderState == -1) return(decoderState); @@ -715,8 +718,3 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, return 0; } - - - - - diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 4654564a26..45c61a372b 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -1085,6 +1085,7 @@ typedef struct { uint32_t dmrs_pbch_bitmap_nr[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE]; #endif + t_nrPolar_paramsPtr nrPolar_params; /// PBCH DMRS sequence uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD]; diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 85c7df1923..bfd6088e92 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -696,8 +696,8 @@ static void *UE_thread_rxn_txnp4(void *arg) { UE->ul_indication.slot = 0; // to be fill UE->ul_indication.frame = 0; // to be fill // [TODO] mapping right after NR initial sync - //UE->ul_indication.frame = ; - //UE->ul_indication.slot = ; + UE->ul_indication.frame = proc->frame_rx; + UE->ul_indication.slot = proc->nr_tti_rx; UE->if_inst->ul_indication(&UE->ul_indication); } From 03464d9131ce64d5142a0655254a0c2f4c6d6a65 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Thu, 23 Aug 2018 11:18:33 +0200 Subject: [PATCH 063/114] mod8 fix --- openair1/SCHED_NR/phy_procedures_nr_gNB.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index b268d57a76..07daa8da3e 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -140,7 +140,7 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int subframe) { nr_generate_pss(gNB->d_pss, txdataF, AMP, ssb_start_symbol, cfg, fp); nr_generate_sss(gNB->d_sss, txdataF, AMP_OVER_2, ssb_start_symbol, cfg, fp); - if ((frame_mod8) == 0){ + if (!(frame&7)){ if (gNB->pbch_configured != 1)return; gNB->pbch_configured = 0; } From 4bcc4951b58b90226d73044ab70f25d54f8b0b2b Mon Sep 17 00:00:00 2001 From: Turker YILMAZ Date: Thu, 23 Aug 2018 11:25:18 +0200 Subject: [PATCH 064/114] Update CMakeLists.txt --- cmake_targets/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 9433df05b0..2682582a46 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -2323,6 +2323,7 @@ add_executable(nr-softmodem-nos1 ${OPENAIR_TARGETS}/RT/USER/nr-softmodem.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR_TARGETS}/COMMON/create_tasks.c + ${OPENAIR_TARGETS}/COMMON/create_nr_tasks.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR2_DIR}/RRC/NAS/rb_config.c From 38501eb221ed9f6a6c9adcd54c0c0eeee8683d0a Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Thu, 23 Aug 2018 16:48:39 +0200 Subject: [PATCH 065/114] ue minor changes for init --- openair1/PHY/INIT/nr_init_ue.c | 2 +- targets/RT/USER/nr-uesoftmodem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 806350e2a9..cb560dc322 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -658,7 +658,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, printf("Initializing UE vars (abstraction %"PRIu8") for eNB TXant %"PRIu8", UE RXant %"PRIu8"\n",abstraction_flag,fp->nb_antennas_tx,fp->nb_antennas_rx); //LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_UE][MOD %02u][]\n", ue->Mod_id+NB_eNB_INST); - //phy_init_nr_top(&ue->frame_parms); + phy_init_nr_top(ue); //nr_init_frame_parms_ue(&ue->frame_parms); // many memory allocation sizes are hard coded diff --git a/targets/RT/USER/nr-uesoftmodem.c b/targets/RT/USER/nr-uesoftmodem.c index a93de1fc3f..468a616487 100644 --- a/targets/RT/USER/nr-uesoftmodem.c +++ b/targets/RT/USER/nr-uesoftmodem.c @@ -1001,7 +1001,7 @@ int main( int argc, char **argv ) { nr_init_frame_parms_ue(frame_parms[CC_id]); printf("after init frame_parms %d\n",frame_parms[CC_id]->ofdm_symbol_size); // phy_init_top(frame_parms[CC_id]); - phy_init_nr_top(frame_parms[CC_id]); + //phy_init_nr_top(frame_parms[CC_id]); } From 7d3cf4804c9bfe2364f6efae35845bba1a11f772 Mon Sep 17 00:00:00 2001 From: yilmazt Date: Fri, 24 Aug 2018 15:36:31 +0200 Subject: [PATCH 066/114] Working new polar coder with temporary fix --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index a53ec46a44..842b62ff3a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -35,6 +35,7 @@ //#define DEBUG_PDCCH_DMRS //#define DEBUG_DCI //#define DEBUG_POLAR_PARAMS +#define PDCCH_TEST_POLAR_TEMP_FIX extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; @@ -205,15 +206,21 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, // CRC attachment + Scrambling + Channel coding + Rate matching uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD]; uint16_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; +#ifdef PDCCH_TEST_POLAR_TEMP_FIX + t_nrPolar_paramsPtr currentPtr = NULL;//, polarParams = NULL; + nr_polar_init(¤tPtr, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); +// t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); +#else nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); +#endif polar_encoder_dci(dci_alloc.dci_pdu, encoder_output, currentPtr, n_RNTI); #ifdef DEBUG_POLAR_PARAMS - /*printf("DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + printf("DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); printf("Encoded Payload: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - encoder_output[0], encoder_output[1], encoder_output[2], encoder_output[3]);*/ + encoder_output[0], encoder_output[1], encoder_output[2], encoder_output[3]); #endif // QPSK modulation From 5449738861e3c1ad51ffae00760595c9995219a2 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Fri, 24 Aug 2018 15:40:32 +0200 Subject: [PATCH 067/114] remove encoder DCI debug --- openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 0334610fa1..2c9e3529a2 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -30,7 +30,7 @@ * \warning */ -#define DEBUG_POLAR_ENCODER_DCI +//#define DEBUG_POLAR_ENCODER_DCI #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" From 796eab07e1cbab01cee3e46cc2620924f90f3476 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Mon, 27 Aug 2018 10:54:16 +0200 Subject: [PATCH 068/114] debug commit --- openair1/PHY/INIT/nr_init.c | 4 ++-- openair1/PHY/NR_TRANSPORT/nr_dci.c | 4 ++-- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 2 +- targets/RT/USER/nr-gnb.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 29e10410be..a9d57fefce 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -119,10 +119,10 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, // PBCH DMRS gold sequences generation nr_init_pbch_dmrs(gNB); // Polar encoder init for PBCH - nr_polar_init(&gNB->nrPolar_params, + /*nr_polar_init(&gNB->nrPolar_params, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, - NR_POLAR_PBCH_AGGREGATION_LEVEL); + NR_POLAR_PBCH_AGGREGATION_LEVEL);*/ //PDCCH DMRS init gNB->nr_gold_pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**)); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 842b62ff3a..e62b6e2850 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -206,7 +206,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, // CRC attachment + Scrambling + Channel coding + Rate matching uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD]; uint16_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; -#ifdef PDCCH_TEST_POLAR_TEMP_FIX +/*#ifdef PDCCH_TEST_POLAR_TEMP_FIX t_nrPolar_paramsPtr currentPtr = NULL;//, polarParams = NULL; nr_polar_init(¤tPtr, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); // t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); @@ -221,7 +221,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); printf("Encoded Payload: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", encoder_output[0], encoder_output[1], encoder_output[2], encoder_output[3]); -#endif +#endif*/ // QPSK modulation int16_t mod_dci[NR_MAX_DCI_SIZE>>1]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 1e761ea0bb..267387408b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -288,7 +288,7 @@ pbch_a_b[m] = ((pbch->pbch_a_prime[m/8]>>(m&7))&01); } /// CRC, coding and rate matching - polar_encoder (pbch->pbch_a_prime, pbch->pbch_e, &frame_parms->pbch_polar_params); + //polar_encoder (pbch->pbch_a_prime, pbch->pbch_e, &frame_parms->pbch_polar_params); #ifdef DEBUG_PBCH_ENCODING printf("Channel coding:\n"); for (int i=0; i>3; i++) diff --git a/targets/RT/USER/nr-gnb.c b/targets/RT/USER/nr-gnb.c index 27d233bedb..fbd3c714d5 100644 --- a/targets/RT/USER/nr-gnb.c +++ b/targets/RT/USER/nr-gnb.c @@ -916,10 +916,10 @@ void init_gNB(int single_thread_flag,int wait_for_sync) { gNB = RC.gNB[inst][CC_id]; gNB->abstraction_flag = 0; gNB->single_thread_flag = single_thread_flag; - nr_polar_init(&gNB->nrPolar_params, + /*nr_polar_init(&gNB->nrPolar_params, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, - NR_POLAR_PBCH_AGGREGATION_LEVEL); + NR_POLAR_PBCH_AGGREGATION_LEVEL);*/ LOG_I(PHY,"Initializing gNB %d CC_id %d single_thread_flag:%d\n",inst,CC_id,single_thread_flag); #ifndef OCP_FRAMEWORK From 3e8b0dce7322632094b6cbbd21475aa85447e91f Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Mon, 27 Aug 2018 13:19:09 +0200 Subject: [PATCH 069/114] reverse debug mode --- openair1/PHY/INIT/nr_init.c | 4 ++-- openair1/PHY/NR_TRANSPORT/nr_dci.c | 4 ++-- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index a9d57fefce..29e10410be 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -119,10 +119,10 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, // PBCH DMRS gold sequences generation nr_init_pbch_dmrs(gNB); // Polar encoder init for PBCH - /*nr_polar_init(&gNB->nrPolar_params, + nr_polar_init(&gNB->nrPolar_params, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, - NR_POLAR_PBCH_AGGREGATION_LEVEL);*/ + NR_POLAR_PBCH_AGGREGATION_LEVEL); //PDCCH DMRS init gNB->nr_gold_pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**)); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index e62b6e2850..842b62ff3a 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -206,7 +206,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, // CRC attachment + Scrambling + Channel coding + Rate matching uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD]; uint16_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; -/*#ifdef PDCCH_TEST_POLAR_TEMP_FIX +#ifdef PDCCH_TEST_POLAR_TEMP_FIX t_nrPolar_paramsPtr currentPtr = NULL;//, polarParams = NULL; nr_polar_init(¤tPtr, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); // t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); @@ -221,7 +221,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); printf("Encoded Payload: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", encoder_output[0], encoder_output[1], encoder_output[2], encoder_output[3]); -#endif*/ +#endif // QPSK modulation int16_t mod_dci[NR_MAX_DCI_SIZE>>1]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 267387408b..1e761ea0bb 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -288,7 +288,7 @@ pbch_a_b[m] = ((pbch->pbch_a_prime[m/8]>>(m&7))&01); } /// CRC, coding and rate matching - //polar_encoder (pbch->pbch_a_prime, pbch->pbch_e, &frame_parms->pbch_polar_params); + polar_encoder (pbch->pbch_a_prime, pbch->pbch_e, &frame_parms->pbch_polar_params); #ifdef DEBUG_PBCH_ENCODING printf("Channel coding:\n"); for (int i=0; i>3; i++) From 260a4c132468e713b379f9b840d609bd7a8de32d Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Mon, 27 Aug 2018 13:57:11 +0200 Subject: [PATCH 070/114] Array size bug fix --- openair1/PHY/INIT/nr_init.c | 2 +- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 1 - openair1/PHY/defs_gNB.h | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 29e10410be..e736f356db 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -120,7 +120,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, nr_init_pbch_dmrs(gNB); // Polar encoder init for PBCH nr_polar_init(&gNB->nrPolar_params, - NR_POLAR_PBCH_MESSAGE_TYPE, + NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 8d87d2ed95..39a0370cb1 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -226,5 +226,4 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, AssertFatal(1==0, "[nr_fill_dci_and_dlsch] Incorrect DCI Format(%d)",rel15->dci_format); }*/ - return; } diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index d622536042..116e940c71 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -61,7 +61,7 @@ typedef struct { typedef struct { uint8_t num_dci; - NR_gNB_DCI_ALLOC_t dci_alloc[32]; + NR_gNB_DCI_ALLOC_t dci_alloc[256]; } NR_gNB_PDCCH; typedef struct { From 059733574e1cdc3dd7766ad11610f07f0b96edca Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Tue, 28 Aug 2018 11:09:21 +0200 Subject: [PATCH 071/114] ue frame_params update --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 2 +- targets/RT/USER/nr-uesoftmodem.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 2ee0f6dc26..a83568c13a 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -2929,7 +2929,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, pdcch_channel_level(pdcch_vars[eNB_id]->dl_ch_estimates_ext, frame_parms, avgP, - frame_parms->N_RB_DL); + n_rb_offset); avgs = 0; for (aatx = 0; aatx < frame_parms->nb_antenna_ports_eNB; aatx++) for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) diff --git a/targets/RT/USER/nr-uesoftmodem.c b/targets/RT/USER/nr-uesoftmodem.c index 468a616487..149ec92ec3 100644 --- a/targets/RT/USER/nr-uesoftmodem.c +++ b/targets/RT/USER/nr-uesoftmodem.c @@ -649,8 +649,8 @@ void set_default_frame_parms(NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { frame_parms[CC_id]->frame_type = FDD; frame_parms[CC_id]->tdd_config = 3; //frame_parms[CC_id]->tdd_config_S = 0; - frame_parms[CC_id]->N_RB_DL = 100; - frame_parms[CC_id]->N_RB_UL = 100; + frame_parms[CC_id]->N_RB_DL = 106; + frame_parms[CC_id]->N_RB_UL = 106; frame_parms[CC_id]->Ncp = NORMAL; //frame_parms[CC_id]->Ncp_UL = NORMAL; frame_parms[CC_id]->Nid_cell = 0; @@ -715,8 +715,8 @@ void set_default_frame_parms_single(nfapi_nr_config_request_t *config, NR_DL_FRA frame_parms->frame_type = FDD; frame_parms->tdd_config = 3; //frame_parms[CC_id]->tdd_config_S = 0; - frame_parms->N_RB_DL = 100; - frame_parms->N_RB_UL = 100; + frame_parms->N_RB_DL = 106; + frame_parms->N_RB_UL = 106; frame_parms->Ncp = NORMAL; //frame_parms[CC_id]->Ncp_UL = NORMAL; frame_parms->Nid_cell = 0; @@ -771,7 +771,7 @@ void init_openair0() { openair0_cfg[card].mmapped_dma=mmapped_dma; openair0_cfg[card].configFilename = NULL; - if(frame_parms[0]->N_RB_DL == 100) { + if(frame_parms[0]->N_RB_DL == 106) { if (numerology==0) { if (frame_parms[0]->threequarter_fs) { openair0_cfg[card].sample_rate=23.04e6; From 7b9b8348e140ea782a4429aa055ff694af0e5af8 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Tue, 28 Aug 2018 11:47:57 +0200 Subject: [PATCH 072/114] ue pbch debug MIB --- openair1/PHY/INIT/nr_init_ue.c | 3 ++- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index cb560dc322..d102b1f8f9 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -962,10 +962,11 @@ void phy_init_nr_top(PHY_VARS_NR_UE *ue) // Polar encoder init for PBCH //nr_polar_init(&frame_parms->pbch_polar_params, 1); + /*t_nrPolar_paramsPtr nrPolar_params = NULL, currentPtr = NULL; nr_polar_init(&ue->nrPolar_params, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, - NR_POLAR_PBCH_AGGREGATION_LEVEL); + NR_POLAR_PBCH_AGGREGATION_LEVEL);*/ //lte_sync_time_init(frame_parms); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 59646eda41..8c9166b1b3 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -653,7 +653,12 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, //#endif //polar decoding de-rate matching - t_nrPolar_paramsPtr currentPtr = nr_polar_params(&ue->nrPolar_params, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL); + t_nrPolar_paramsPtr nrPolar_params = NULL, currentPtr = NULL; + nr_polar_init(&nrPolar_params, + NR_POLAR_PBCH_MESSAGE_TYPE, + NR_POLAR_PBCH_PAYLOAD_BITS, + NR_POLAR_PBCH_AGGREGATION_LEVEL); + currentPtr = nr_polar_params(nrPolar_params, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL); decoderState = polar_decoder(demod_pbch_e, pbch_a_b, currentPtr, decoderListSize, pathMetricAppr); printf("polar decoder state %d\n", decoderState); if(decoderState == -1) @@ -696,6 +701,11 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, // Fix byte endian for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++) decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS>>3)-i-1] = pbch_a[i]; + + decoded_output[0] = 0x0a; + decoded_output[1] = 0x63; + decoded_output[2] = 0x00; + decoded_output[3] = 0x06; //#ifdef DEBUG_PBCH for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++){ From 34a56dcaf5adf87b5c8881d9503e6ebebd96c4b4 Mon Sep 17 00:00:00 2001 From: Agustin Date: Mon, 27 Aug 2018 09:14:41 +0200 Subject: [PATCH 073/114] NR UE PDCCH development: dci pdu implemented with 4 element table uint32_t (128 bits) --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 41 +-- openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c | 254 ++++++++++++------ .../PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 4 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 28 +- 4 files changed, 216 insertions(+), 111 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index a83568c13a..0eac129b97 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -1156,15 +1156,15 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, #endif } - dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol * (frame_parms->N_RB_DL * NBR_RE_PER_RB_WITH_DMRS)]; + dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol * (frame_parms->N_RB_DL * NBR_RE_PER_RB_WITHOUT_DMRS)]; #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> dl_ch0_ext = &dl_ch_estimates_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 12) = (%d)]\n", - aarx,symbol * (frame_parms->N_RB_DL * 12)); + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> dl_ch0_ext = &dl_ch_estimates_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 9) = (%d)]\n", + aarx,symbol * (frame_parms->N_RB_DL * NBR_RE_PER_RB_WITHOUT_DMRS)); #endif - rxF_ext = &rxdataF_ext[aarx][symbol * (frame_parms->N_RB_DL * NBR_RE_PER_RB_WITH_DMRS)]; + rxF_ext = &rxdataF_ext[aarx][symbol * (frame_parms->N_RB_DL * NBR_RE_PER_RB_WITHOUT_DMRS)]; #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> rxF_ext = &rxdataF_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 12) = (%d)]\n", - aarx,symbol * (frame_parms->N_RB_DL * 12)); + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> rxF_ext = &rxdataF_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 9) = (%d)]\n", + aarx,symbol * (frame_parms->N_RB_DL * NBR_RE_PER_RB_WITHOUT_DMRS)); printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> (for symbol=%d, aarx=%d), symbol_mod=%d, nushiftmod3=%d \n",symbol,aarx,symbol_mod,nushiftmod3); #endif @@ -1175,14 +1175,14 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, * Several cases have to be handled differently as IQ symbols are situated in different parts of rxdataF: * 1. Number of RBs in the system bandwidth is even * 1.1 The RB is < than the N_RB_DL/2 -> IQ symbols are in the second half of the rxdataF (from first_carrier_offset) - * 1.2 The RB is >= than the N_RB_DL/2 -> IQ symbols are in the first half of the rxdataF (from element 1) + * 1.2 The RB is >= than the N_RB_DL/2 -> IQ symbols are in the first half of the rxdataF (from element 0) * 2. Number of RBs in the system bandwidth is odd * (particular case when the RB with DC as it is treated differently: it is situated in symbol borders of rxdataF) * 2.1 The RB is <= than the N_RB_DL/2 -> IQ symbols are in the second half of the rxdataF (from first_carrier_offset) - * 2.2 The RB is > than the N_RB_DL/2+1 -> IQ symbols are in the first half of the rxdataF (from element 1 + 2nd half RB containing DC) + * 2.2 The RB is > than the N_RB_DL/2+1 -> IQ symbols are in the first half of the rxdataF (from element 0 + 2nd half RB containing DC) * 2.3 The RB is == N_RB_DL/2+1 -> IQ symbols are in the lower border of the rxdataF for first 6 IQ element and the upper border of the rxdataF for the last 6 IQ elements * If the first RB containing PDCCH within the UE BWP and within the CORESET is higher than half of the system bandwidth (N_RB_DL), - * then the IQ symbol is going to be found at the position 1+c_rb-N_RB_DL/2 in rxdataF and + * then the IQ symbol is going to be found at the position 0+c_rb-N_RB_DL/2 in rxdataF and * we have to point the pointer at (1+c_rb-N_RB_DL/2) in rxdataF */ @@ -2737,7 +2737,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, uint8_t is_secondary_ue, int nb_coreset_active, uint16_t symbol_mon, - int do_common) { + NR_SEARCHSPACE_TYPE_t searchSpaceType) { #ifdef MU_RECEIVER uint8_t eNB_id_i=eNB_id+1; //add 1 to eNB_id to separate from wanted signal, chosen as the B/F'd pilots from the SeNB are shifted by 1 @@ -2748,6 +2748,9 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, NR_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]]; NR_UE_PDCCH *pdcch_vars2 = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]; + int do_common; + if (searchSpaceType == common) do_common=1; + if (searchSpaceType == ue_specific) do_common=0; uint8_t log2_maxh, aatx, aarx; int32_t avgs; uint8_t n_pdcch_symbols; @@ -2811,7 +2814,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, // For each BWP the number of CORESETs is limited to 3 (including initial CORESET Id=0 -> ControlResourceSetId (0..maxNrofControlReourceSets-1) (0..12-1) //uint32_t n_BWP_start = 0; //uint32_t n_rb_offset = 0; - uint32_t n_rb_offset = pdcch_vars2->coreset[nb_coreset_active].rb_offset; + uint32_t n_rb_offset = pdcch_vars2->coreset[nb_coreset_active].rb_offset; // start time position for CORESET // parameter symbol_mon is a 14 bits bitmap indicating monitoring symbols within a slot uint8_t start_symbol = 0; @@ -2825,7 +2828,9 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, } } #ifdef NR_PDCCH_DCI_DEBUG - printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> symbol_mon=(%d) and start_symbol=%d\n",symbol_mon,start_symbol); + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> symbol_mon=(%d) and start_symbol=(%d)\n",symbol_mon,start_symbol); + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> coreset_freq_dom=(%lld) n_rb_offset=(%d) coreset_time_dur=(%d) n_shift=(%d) reg_bundle_size_L=(%d) coreset_interleaver_size_R=(%d) \n", + coreset_freq_dom,n_rb_offset,coreset_time_dur,n_shift,reg_bundle_size_L,coreset_interleaver_size_R); #endif // @@ -4240,14 +4245,14 @@ void nr_dci_decoding_procedure0(int s, dci_decoded_output[current_thread_id][3]); #endif } else { - dci_alloc[*dci_cnt].dci_pdu[7] = dci_decoded_output[current_thread_id][0]; +/* dci_alloc[*dci_cnt].dci_pdu[7] = dci_decoded_output[current_thread_id][0]; dci_alloc[*dci_cnt].dci_pdu[6] = dci_decoded_output[current_thread_id][1]; dci_alloc[*dci_cnt].dci_pdu[5] = dci_decoded_output[current_thread_id][2]; - dci_alloc[*dci_cnt].dci_pdu[4] = dci_decoded_output[current_thread_id][3]; - dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][4]; - dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][5]; - dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][6]; - dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][7]; + dci_alloc[*dci_cnt].dci_pdu[4] = dci_decoded_output[current_thread_id][3];*/ + dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][0]; + dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][1]; + dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][2]; + dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][3]; // MAX_DCI_SIZE_BITS has to be redefined for dci_decoded_output FIXME // format2_0, format2_1 can be longer than 8 bytes. FIXME #ifdef DEBUG_DCI_DECODING diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c index 37937e75eb..579b52fac1 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c @@ -31,6 +31,7 @@ */ //#include "PHY/defs.h" #include "PHY/defs_nr_UE.h" +//#include "PHY/NR_TRANSPORT/nr_dci.h" //#include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" //#include "PHY/extern.h" //#include "SCHED/defs.h" @@ -51,6 +52,8 @@ #define NR_PDCCH_DCI_TOOLS #define NR_PDCCH_DCI_TOOLS_DEBUG +typedef unsigned __int128 uint128_t; + #if 0 @@ -3953,12 +3956,39 @@ int dump_dci(NR_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci) #endif //(0) #ifdef NR_PDCCH_DCI_TOOLS +uint16_t nr_dci_field(uint32_t dci_pdu[4], + uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS], + uint8_t dci_field) +{ + uint16_t field_value = 0 ; + // first_bit_position contains the position of the first bit of the corresponding field within the dci pdu payload + uint16_t first_bit_position = 0; + // last_bit_position contains the position of the last bit of the corresponding field within the dci pdu payload + uint16_t last_bit_position = 0; + uint8_t bit=0; + //printf("\tdci_field=%d, \tsize=%d \t|",dci_field,dci_fields_sizes[dci_field]); + for (int i=0; i= first_bit_position) && (((i*32)+j) < last_bit_position)){ + bit = (dci_pdu[i]<<(31-j))>>31; + field_value = (field_value<<1) + bit; + //printf(" bit(%d)=%d[%d] ",(i*32)+j,bit,field_value); + } + } + return field_value; +} + int nr_extract_dci_info(PHY_VARS_NR_UE *ue, uint8_t eNB_id, lte_frame_type_t frame_type, uint8_t dci_length, uint16_t rnti, - void *dci_pdu, + uint32_t dci_pdu[4], NR_DCI_INFO_EXTRACTED_t *nr_pdci_info_extracted, uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS], NR_DL_UE_HARQ_t *pdlsch0_harq, @@ -4031,15 +4061,22 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, * 55 RESERVED_NR_DCI * */ - uint64_t pdu_bitmap = 0xFFFFFFFFFFFFFFFF; - pdu_bitmap = (pdu_bitmap << (64 - dci_length)) >> (64 - dci_length); // this variable will help to remove the bits of other fields when left-switching + uint8_t dci_fields_sizes_format[NBR_NR_DCI_FIELDS] ={0}; + for (int m=0; m> (DCI_MAX_SIZE - dci_length); // this variable will help to remove the bits of other fields when left-switching uint8_t dci_field=0; - uint8_t sizes_count=0; - uint8_t left_shift=0; +// uint8_t sizes_count=0; +// uint8_t left_shift=0; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG - printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> Entering function nr_extract_dci_info() with dci_pdu=%llx with pdu_bitmap=%llx dci_length=%d\n",(*(uint64_t *)dci_pdu), pdu_bitmap, dci_length); - printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> for format %d, dci_fields_sizes {",dci_format-15); - for (int i=0; i Entering function nr_extract_dci_info() with dci_pdu=%x %x %x %x dci_length=%d\n", + dci_pdu[0],dci_pdu[1],dci_pdu[2],dci_pdu[3], dci_length); + printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> for format %d, dci_fields_sizes {",dci_format); + for (int i=0; iharq_process_number = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format-15])); - left_shift = 0; + if (dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format] != 0) { // E.g: 27 HARQ_PROCESS_NUMBER (27 is the position in dci_fields_sizes array for field HARQ_PROCESS_NUMBER) + //for (int i=0; i<=HARQ_PROCESS_NUMBER; i++) left_shift = left_shift + dci_fields_sizes[i][dci_format]; + nr_pdci_info_extracted->harq_process_number = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,HARQ_PROCESS_NUMBER); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format])); + //left_shift = 0; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->harq_process_number=%x\n",nr_pdci_info_extracted->harq_process_number); #endif @@ -4204,18 +4242,19 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, } for (dci_field=0; dci_field sizes_count = dci_fields_sizes[%d][%d] = %d\n",dci_field,dci_format-15,sizes_count); + printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> dci_fields_sizes[%d][%d] = %d\n",dci_field,dci_format,dci_fields_sizes[dci_field][dci_format]); #endif switch (dci_field){ case IDENTIFIER_DCI_FORMATS: // 0 IDENTIFIER_DCI_FORMATS: (field defined for format0_0,format0_1,format1_0,format1_1,format2_0,format2_1,format2_2,format2_3) // if format 0_0: The value of this bit field is always set to 0, indicating an UL DCI format (TS38.212 Section 7.3.1.1.1) // if format 1_0: The value of this bit field is always set to 1, indicating a DL DCI format (TS38.212 Section 7.3.1.2.1) - nr_pdci_info_extracted->identifier_dci_formats = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->identifier_dci_formats = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->identifier_dci_formats=%x\n",nr_pdci_info_extracted->identifier_dci_formats); #endif @@ -4223,13 +4262,15 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case CARRIER_IND: // 1 CARRIER_IND: (field defined for -,format0_1,-,format1_1,-,-,-,-) // 0 or 3 bits, as defined in Subclause x.x of [5, TS38.213] - nr_pdci_info_extracted->carrier_ind = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->carrier_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->carrier_ind=%x\n",nr_pdci_info_extracted->carrier_ind); #endif break; case SUL_IND_0_1: // 2 SUL_IND_0_1: (field defined for -,format0_1,-,-,-,-,-,-) - nr_pdci_info_extracted->sul_ind_0_1 = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->sul_ind_0_1 = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->sul_ind_0_1=%x\n",nr_pdci_info_extracted->sul_ind_0_1); #endif @@ -4237,48 +4278,55 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case SLOT_FORMAT_IND: // 3 SLOT_FORMAT_IND: (field defined for -,-,-,-,format2_0,-,-,-) // size of DCI format 2_0 is configurable by higher layers up to 128 bits, according to Subclause 11.1.1 of [5, TS 38.213] - nr_pdci_info_extracted->slot_format_ind = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->slot_format_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->slot_format_ind=%x\n",nr_pdci_info_extracted->slot_format_ind); #endif break; case PRE_EMPTION_IND: // 4 PRE_EMPTION_IND: (field defined for -,-,-,-,-,format2_1,-,-) // size of DCI format 2_1 is configurable by higher layers up to 126 bits, according to Subclause 11.2 of [5, TS 38.213]. Each pre-emption indication is 14 bits - nr_pdci_info_extracted->pre_emption_ind = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->pre_emption_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->pre_emption_ind=%x\n",nr_pdci_info_extracted->pre_emption_ind); #endif break; case TPC_CMD_NUMBER: // 5 TPC_CMD_NUMBER: (field defined for -,-,-,-,-,-,format2_2,-) // The parameter xxx provided by higher layers determines the index to the TPC command number for an UL of a cell. Each TPC command number is 2 bits - nr_pdci_info_extracted->tpc_cmd_number = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->tpc_cmd_number = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tpc_cmd_number=%x\n",nr_pdci_info_extracted->tpc_cmd_number); #endif break; case BLOCK_NUMBER: // 6 BLOCK_NUMBER: (field defined for -,-,-,-,-,-,-,format2_3) // starting position of a block is determined by the parameter startingBitOfFormat2_3 - nr_pdci_info_extracted->block_number = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->block_number = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->block_number=%x\n",nr_pdci_info_extracted->block_number); #endif break; case BANDWIDTH_PART_IND: // 7 BANDWIDTH_PART_IND: (field defined for -,format0_1,-,format1_1,-,-,-,-) - nr_pdci_info_extracted->bandwidth_part_ind = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->bandwidth_part_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->bandwidth_part_ind=%x\n",nr_pdci_info_extracted->bandwidth_part_ind); #endif break; case SHORT_MESSAGE_IND: // 8 SHORT_MESSAGE_IND: (field defined for -,-,format1_0,format1_1,-,-,-,-) - nr_pdci_info_extracted->short_message_ind = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->short_message_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->short_message_ind=%x\n",nr_pdci_info_extracted->short_message_ind); #endif break; case SHORT_MESSAGES: // 9 SHORT_MESSAGES: (field defined for -,-,format1_0,format1_1,-,-,-,-) - nr_pdci_info_extracted->short_messages = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->short_messages = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->short_messages=%x\n",nr_pdci_info_extracted->short_messages); #endif @@ -4288,7 +4336,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // PUSCH hopping with resource allocation type 1 not considered // According to 38.214 V15.1.0 Section 6.1.2.2 Two uplink resource allocation schemes, type 0 and type 1, are supported. // The UE shall assume that when the scheduling PDCCH is received with DCI format 0_0, then uplink resource allocation type 1 is used. - nr_pdci_info_extracted->freq_dom_resource_assignment_UL = (uint16_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->freq_dom_resource_assignment_UL = (uint16_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); if (dci_format == format0_1){ // uplink resource allocation type 0 or 1 can be used } if (dci_format == format0_0){ // only uplink resource allocation type 1 @@ -4317,7 +4366,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case FREQ_DOM_RESOURCE_ASSIGNMENT_DL: // 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: (field defined for -,-,format1_0,format1_1,-,-,-,-) // According to 38.214 V15.1.0 Section 5.1.2.2 Two downlink resource allocation schemes, type 0 and type 1, are supported. // The UE shall assume that when the scheduling grant is received with DCI format 1_0, then downlink resource allocation type 1 is used. - nr_pdci_info_extracted->freq_dom_resource_assignment_DL = (uint16_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->freq_dom_resource_assignment_DL = (uint16_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); if (dci_format == format1_1){ // uplink resource allocation type 0 or 1 can be used } if (dci_format == format1_0){ // only uplink resource allocation type 1 @@ -4391,7 +4441,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // Subclause 5.1.2.1 of [6, TS 38.214] for formats format1_0,format1_1 // The bitwidth for this field is determined as log2(I) bits, // where I the number of entries in the higher layer parameter pusch-AllocationList - nr_pdci_info_extracted->time_dom_resource_assignment = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->time_dom_resource_assignment = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); if (dci_format == format0_0 || dci_format == format0_1){ // Subclause 6.1.2.1 of [6, TS 38.214] k_offset = table_6_1_2_1_1_2_time_dom_res_alloc_A[nr_pdci_info_extracted->time_dom_resource_assignment][0]; sliv_S = table_6_1_2_1_1_2_time_dom_res_alloc_A[nr_pdci_info_extracted->time_dom_resource_assignment][1]; @@ -4428,7 +4479,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, //Table 7.3.1.1.2-33: VRB-to-PRB mapping // 0 Non-interleaved // 1 Interleaved - nr_pdci_info_extracted->vrb_to_prb_mapping = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->vrb_to_prb_mapping = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); if (nr_pdci_info_extracted->vrb_to_prb_mapping == 0) { // Non-interleaved } else { // Interleaved // format 0_1 defined in TS 38.211 Section 6.3.1.7 @@ -4441,20 +4493,23 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case PRB_BUNDLING_SIZE_IND: // 14 PRB_BUNDLING_SIZE_IND: (field defined for -,-,-,format1_1,-,-,-,-) // 0 bit if the higher layer parameter PRB_bundling is not configured or is set to 'static', or 1 bit if the higher layer parameter PRB_bundling is set to 'dynamic' according to Subclause 5.1.2.3 of [6, TS 38.214] - nr_pdci_info_extracted->prb_bundling_size_ind = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->prb_bundling_size_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->prb_bundling_size_ind=%x\n",nr_pdci_info_extracted->prb_bundling_size_ind); #endif break; case RATE_MATCHING_IND: // 15 RATE_MATCHING_IND: (field defined for -,-,-,format1_1,-,-,-,-) // 0, 1, or 2 bits according to higher layer parameter rate-match-PDSCH-resource-set - nr_pdci_info_extracted->rate_matching_ind = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->rate_matching_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->rate_matching_ind=%x\n",nr_pdci_info_extracted->rate_matching_ind); #endif break; case ZP_CSI_RS_TRIGGER: // 16 ZP_CSI_RS_TRIGGER: (field defined for -,-,-,format1_1,-,-,-,-) - nr_pdci_info_extracted->zp_csi_rs_trigger = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->zp_csi_rs_trigger = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->zp_csi_rs_trigger=%x\n",nr_pdci_info_extracted->zp_csi_rs_trigger); #endif @@ -4463,7 +4518,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case FREQ_HOPPING_FLAG: // 17 FREQ_HOPPING_FLAG: (field defined for format0_0,format0_1,-,-,-,-,-,-) // 0 bit if only resource allocation type 0 // 1 bit otherwise, only applicable to resource allocation type 1, as defined in Subclause 6.3 of [6, TS 38.214] - nr_pdci_info_extracted->freq_hopping_flag = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->freq_hopping_flag = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); if (nr_pdci_info_extracted->freq_hopping_flag != 0) { // PUSCH frequency hopping is performed (only resource allocation type 1) } else { // PUSCH frequency hopping is not performed (only resource allocation type 1) @@ -4475,42 +4531,48 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, break; case TB1_MCS: // 18 TB1_MCS: (field defined for -,-,-,format1_1,-,-,-,-) - nr_pdci_info_extracted->tb1_mcs = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->tb1_mcs = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); if (nr_pdci_info_extracted->mcs < 29) pdlsch0_harq->mcs = nr_pdci_info_extracted->tb1_mcs; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb1_mcs=%x\n",nr_pdci_info_extracted->tb1_mcs); #endif break; case TB1_NDI: // 19 TB1_NDI: (field defined for -,-,-,format1_1,-,-,-,-) - nr_pdci_info_extracted->tb1_ndi = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->tb1_ndi = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); pdlsch0_harq->DCINdi = nr_pdci_info_extracted->tb1_ndi; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb1_ndi=%x\n",nr_pdci_info_extracted->tb1_ndi); #endif break; case TB1_RV: // 20 TB1_RV: (field defined for -,-,-,format1_1,-,-,-,-) - nr_pdci_info_extracted->tb1_rv = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->tb1_rv = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); pdlsch0_harq->rvidx = nr_pdci_info_extracted->tb1_rv; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb1_rv=%x\n",nr_pdci_info_extracted->tb1_rv); #endif break; case TB2_MCS: // 21 TB2_MCS: (field defined for -,-,-,format1_1,-,-,-,-) - nr_pdci_info_extracted->tb2_mcs = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->tb2_mcs = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); if (nr_pdci_info_extracted->mcs < 29) pdlsch0_harq->mcs = nr_pdci_info_extracted->tb2_mcs; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb2_mcs=%x\n",nr_pdci_info_extracted->tb2_mcs); #endif break; case TB2_NDI: // 22 TB2_NDI: (field defined for -,-,-,format1_1,-,-,-,-) - nr_pdci_info_extracted->tb2_ndi = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->tb2_ndi = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); pdlsch0_harq->DCINdi = nr_pdci_info_extracted->tb2_ndi; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb2_ndi=%x\n",nr_pdci_info_extracted->tb2_ndi); #endif break; case TB2_RV: // 23 TB2_RV: (field defined for -,-,-,format1_1,-,-,-,-) - nr_pdci_info_extracted->tb2_rv = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->tb2_rv = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); pdlsch0_harq->rvidx = nr_pdci_info_extracted->tb2_rv; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb2_rv=%x\n",nr_pdci_info_extracted->tb2_rv); @@ -4518,7 +4580,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, break; case MCS: // 24 MCS: (field defined for format0_0,format0_1,format1_0,-,-,-,-,-) - nr_pdci_info_extracted->mcs = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->mcs = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); if (nr_pdci_info_extracted->mcs < 29) { if (dci_format == format0_0 || dci_format == format0_1) ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->mcs = nr_pdci_info_extracted->mcs; @@ -4533,7 +4596,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, break; case NDI: // 25 NDI: (field defined for format0_0,format0_1,format1_0,-,-,-,-,-) - nr_pdci_info_extracted->ndi = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->ndi = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); if (dci_format == format0_0 || dci_format == format0_1) { ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi = nr_pdci_info_extracted->ndi; if (ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->first_tx==1) { @@ -4564,7 +4628,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, break; case RV: // 26 RV: (field defined for format0_0,format0_1,format1_0,-,-,-,-,-) - nr_pdci_info_extracted->rv = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->rv = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); if (dci_format == format0_0 || dci_format == format0_1) ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->rvidx = nr_pdci_info_extracted->rv; else @@ -4594,7 +4659,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, break; case HARQ_PROCESS_NUMBER: // 27 HARQ_PROCESS_NUMBER: (field defined for format0_0,format0_1,format1_0,format1_1,-,-,-,-) - nr_pdci_info_extracted->harq_process_number = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->harq_process_number = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); pdlsch0->current_harq_pid = nr_pdci_info_extracted->harq_process_number; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->harq_process_number=%x\n",nr_pdci_info_extracted->harq_process_number); @@ -4606,7 +4672,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI // 2 if one serving cell is configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 bits are the counter DAI // 0 otherwise - nr_pdci_info_extracted->dai = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->dai = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.vDAI_DL = nr_pdci_info_extracted->dai+1; //pdlsch0->harq_ack[nr_tti_rx].vDAI_DL = nr_pdci_info_extracted->dai+1; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG @@ -4616,14 +4683,16 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case FIRST_DAI: // 29 FIRST_DAI: (field defined for -,format0_1,-,-,-,-,-,-) // (1 or 2 bits) 1 bit for semi-static HARQ-ACK - nr_pdci_info_extracted->first_dai = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->first_dai = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->first_dai=%x\n",nr_pdci_info_extracted->first_dai); #endif break; case SECOND_DAI: // 30 SECOND_DAI: (field defined for -,format0_1,-,-,-,-,-,-) // (0 or 2 bits) 2 bits for dynamic HARQ-ACK codebook with two HARQ-ACK sub-codebooks - nr_pdci_info_extracted->second_dai = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->second_dai = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->second_dai=%x\n",nr_pdci_info_extracted->second_dai); #endif @@ -4631,7 +4700,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case TB_SCALING: // 31 TB_SCALING: (field defined for -,format0_1,-,-,-,-,-,-) // (0 or 2 bits) 2 bits for dynamic HARQ-ACK codebook with two HARQ-ACK sub-codebooks - nr_pdci_info_extracted->tb_scaling = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->tb_scaling = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb_scaling=%x\n",nr_pdci_info_extracted->tb_scaling); #endif @@ -4639,7 +4709,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case TPC_PUSCH: // 32 TPC_PUSCH: (field defined for format0_0,format0_1,-,-,-,-,-,-) // defined in Subclause 7.1.1 TS 38.213 - nr_pdci_info_extracted->tpc_pusch = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->tpc_pusch = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->TPC = nr_pdci_info_extracted->tpc_pusch; if (ue->ul_power_control_dedicated[eNB_id].accumulationEnabled == 1) { ulsch0->f_pusch += nr_delta_PUSCH_acc[ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->TPC]; @@ -4653,7 +4724,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case TPC_PUCCH: // 33 TPC_PUCCH: (field defined for -,-,format1_0,format1_1,-,-,-,-) // defined in Subclause 7.2.1 TS 38.213 - nr_pdci_info_extracted->tpc_pucch = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->tpc_pucch = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); pdlsch0_harq->delta_PUCCH = nr_delta_PUCCH_lut[nr_pdci_info_extracted->tpc_pucch &3]; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tpc_pucch=%x\n",nr_pdci_info_extracted->tpc_pucch); @@ -4663,7 +4735,8 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case PUCCH_RESOURCE_IND: // 34 PUCCH_RESOURCE_IND: (field defined for -,-,format1_0,format1_1,-,-,-,-) // defined in Subclause 9.2.3 TS 38.213 // PUCCH_RESOURCE_IND points to PUCCH-ResourceId, but PUCCH-ResourceId is not defined yet - nr_pdci_info_extracted->pucch_resource_ind = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->pucch_resource_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->pucch_resource_ind=%x\n",nr_pdci_info_extracted->pucch_resource_ind); #endif @@ -4672,91 +4745,105 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case PDSCH_TO_HARQ_FEEDBACK_TIME_IND: // 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND: (field defined for -,-,format1_0,format1_1,-,-,-,-) // defined in Subclause 9.2.3 TS 38.213 // PDSCH_TO_HARQ_FEEDBACK_TIME_IND points to DL-data-DL-acknowledgement, but DL-data-DL-acknowledgement is not defined yet - nr_pdci_info_extracted->pdsch_to_harq_feedback_time_ind = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->pdsch_to_harq_feedback_time_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->pdsch_to_harq_feedback_time_ind=%x\n",nr_pdci_info_extracted->pdsch_to_harq_feedback_time_ind); #endif break; case SRS_RESOURCE_IND: // 36 SRS_RESOURCE_IND: (field defined for -,format0_1,-,-,-,-,-,-) - nr_pdci_info_extracted->srs_resource_ind = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->srs_resource_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->srs_resource_ind=%x\n",nr_pdci_info_extracted->srs_resource_ind); #endif break; case PRECOD_NBR_LAYERS: // 37 PRECOD_NBR_LAYERS: (field defined for -,format0_1,-,-,-,-,-,-) - nr_pdci_info_extracted->precod_nbr_layers = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->precod_nbr_layers = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->precod_nbr_layers=%x\n",nr_pdci_info_extracted->precod_nbr_layers); #endif break; case ANTENNA_PORTS: // 38 ANTENNA_PORTS: (field defined for -,format0_1,-,format1_1,-,-,-,-) - nr_pdci_info_extracted->antenna_ports = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->antenna_ports = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->antenna_ports=%x\n",nr_pdci_info_extracted->antenna_ports); #endif break; case TCI: // 39 TCI: (field defined for -,-,-,format1_1,-,-,-,-) // 0 bit if higher layer parameter tci-PresentInDCI is not enabled; otherwise 3 bits - nr_pdci_info_extracted->tci = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->tci = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tci=%x\n",nr_pdci_info_extracted->tci); #endif break; case SRS_REQUEST: // 40 SRS_REQUEST: (field defined for -,format0_1,-,format1_1,-,-,-,format2_3) - nr_pdci_info_extracted->srs_request = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->srs_request = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->srs_request=%x\n",nr_pdci_info_extracted->srs_request); #endif break; case TPC_CMD_NUMBER_FORMAT2_3: // 41 TPC_CMD_NUMBER_FORMAT2_3: (field defined for -,-,-,-,-,-,-,format2_3) - nr_pdci_info_extracted->tpc_cmd_number_format2_3 = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->tpc_cmd_number_format2_3 = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tpc_cmd_number_format2_3=%x\n",nr_pdci_info_extracted->tpc_cmd_number_format2_3); #endif break; case CSI_REQUEST: // 42 CSI_REQUEST: (field defined for -,format0_1,-,-,-,-,-,-) - nr_pdci_info_extracted->csi_request = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->csi_request = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->csi_request=%x\n",nr_pdci_info_extracted->csi_request); #endif break; case CBGTI: // 43 CBGTI: (field defined for -,format0_1,-,format1_1,-,-,-,-) // 0, 2, 4, 6, or 8 bits determined by higher layer parameter maxCodeBlockGroupsPerTransportBlock for the PDSCH - nr_pdci_info_extracted->cbgti = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->cbgti = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->cbgti=%x\n",nr_pdci_info_extracted->cbgti); #endif break; case CBGFI: // 44 CBGFI: (field defined for -,-,-,format1_1,-,-,-,-) // 0 or 1 bit determined by higher layer parameter codeBlockGroupFlushIndicator - nr_pdci_info_extracted->cbgfi = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->cbgfi = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->cbgfi=%x\n",nr_pdci_info_extracted->cbgfi); #endif break; case PTRS_DMRS: // 45 PTRS_DMRS: (field defined for -,format0_1,-,-,-,-,-,-) - nr_pdci_info_extracted->ptrs_dmrs = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->ptrs_dmrs = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->ptrs_dmrs=%x\n",nr_pdci_info_extracted->ptrs_dmrs); #endif break; case BETA_OFFSET_IND: // 46 BETA_OFFSET_IND: (field defined for -,format0_1,-,-,-,-,-,-) - nr_pdci_info_extracted->beta_offset_ind = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->beta_offset_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->beta_offset_ind=%x\n",nr_pdci_info_extracted->beta_offset_ind); #endif break; case DMRS_SEQ_INI: // 47 DMRS_SEQ_INI: (field defined for -,format0_1,-,format1_1,-,-,-,-) // 1 bit if the cell has two ULs and the number of bits for DCI format 1_0 before padding is larger than the number of bits for DCI format 0_0 before padding; 0 bit otherwise - nr_pdci_info_extracted->dmrs_seq_ini = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->dmrs_seq_ini = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->dmrs_seq_ini=%x\n",nr_pdci_info_extracted->dmrs_seq_ini); #endif break; case UL_SCH_IND: // 48 UL_SCH_IND: (field defined for -,format0_1,-,-,-,-,-,-) // value of "1" indicates UL-SCH shall be transmitted on the PUSCH and a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH - nr_pdci_info_extracted->ul_sch_ind = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->ul_sch_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->dmrs_seq_ini=%x\n",nr_pdci_info_extracted->ul_sch_ind); #endif @@ -4764,49 +4851,56 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case PADDING_NR_DCI: // 49 PADDING_NR_DCI: (field defined for format0_0,-,format1_0,-,-,-,-,-) // (Note 2) If DCI format 0_0 is monitored in common search space - nr_pdci_info_extracted->padding_nr_dci = (uint16_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->padding_nr_dci = (uint16_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->padding=%x\n",nr_pdci_info_extracted->padding_nr_dci); #endif break; case SUL_IND_0_0: // 50 SUL_IND_0_0: (field defined for format0_0,-,-,-,-,-,-,-) - nr_pdci_info_extracted->sul_ind_0_0 = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->sul_ind_0_0 = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->sul_ind_0_0=%x\n",nr_pdci_info_extracted->sul_ind_0_0); #endif break; case RA_PREAMBLE_INDEX: // 51 RA_PREAMBLE_INDEX: (field defined for format0_0,-,-,-,-,-,-,-) - nr_pdci_info_extracted->ra_preamble_index = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->ra_preamble_index = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->ra_preamble_index=%x\n",nr_pdci_info_extracted->ra_preamble_index); #endif break; case SUL_IND_1_0: // 52 SUL_IND_1_0: (field defined for -,-,format1_0,-,-,-,-,-) - nr_pdci_info_extracted->sul_ind_1_0 = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->sul_ind_1_0 = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->sul_ind_1_0=%x\n",nr_pdci_info_extracted->sul_ind_1_0); #endif break; case SS_PBCH_INDEX: // 53 SS_PBCH_INDEX: (field defined for -,-,format1_0,-,-,-,-,-) - nr_pdci_info_extracted->ss_pbch_index = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->ss_pbch_index = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->ss_pbch_index=%x\n",nr_pdci_info_extracted->ss_pbch_index); #endif break; case PRACH_MASK_INDEX: // 54 PRACH_MASK_INDEX: (field defined for -,-,-,format1_0,-,-,-,-) - nr_pdci_info_extracted->prach_mask_index = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->prach_mask_index = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->prach_mask_index=%x\n",nr_pdci_info_extracted->prach_mask_index); #endif break; case RESERVED_NR_DCI: // 55 RESERVED_NR_DCI: (field defined for -,-,-,format1_0,-,-,-,-) - nr_pdci_info_extracted->reserved_nr_dci = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + nr_pdci_info_extracted->reserved_nr_dci = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->reserved_nr_dci=%x\n",nr_pdci_info_extracted->reserved_nr_dci); #endif @@ -6921,7 +7015,7 @@ int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, uint8_t eNB_id, int frame, uint8_t nr_tti_rx, - void *dci_pdu, + uint32_t dci_pdu[4], uint16_t rnti, uint8_t dci_length, NR_DCI_format_t dci_format, @@ -6949,16 +7043,20 @@ int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, NR_DL_UE_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; NR_UE_ULSCH_t *ulsch0=NULL,*ulsch1=NULL; //NR_DCI_INFO_EXTRACTED_t nr_dci_info_extracted; - uint8_t status=0,left_shift=0; + uint8_t status=0;//left_shift=0; uint64_t pdu_bitmap = 0xFFFFFFFFFFFFFFFF; pdu_bitmap = (pdu_bitmap << (64 - dci_length)) >> (64 - dci_length); // this variable will help to remove the bits of other fields when left-switching + uint8_t dci_fields_sizes_format[NBR_NR_DCI_FIELDS] ={0}; + for (int m=0; mactive = 0; - if (dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format-15] != 0) { // 27 HARQ_PROCESS_NUMBER (27 is the position in dci_fields_sizes array for field HARQ_PROCESS_NUMBER) - for (int i=0; i<=HARQ_PROCESS_NUMBER; i++) left_shift = left_shift + dci_fields_sizes[i][dci_format-15]; - nr_dci_info_extracted->harq_process_number = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format-15])); - left_shift = 0; + if (dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format] != 0) { // 27 HARQ_PROCESS_NUMBER (27 is the position in dci_fields_sizes array for field HARQ_PROCESS_NUMBER) + //for (int i=0; i<=HARQ_PROCESS_NUMBER; i++) left_shift = left_shift + dci_fields_sizes[i][dci_format]; + nr_dci_info_extracted->harq_process_number = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,HARQ_PROCESS_NUMBER); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format])); + //left_shift = 0; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> nr_dci_info_extracted->harq_process_number=%x\n",nr_dci_info_extracted->harq_process_number); #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index 789515d60d..ade1e88eb9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -385,12 +385,14 @@ typedef struct { boolean_t ra_flag; /// rnti rnti_t rnti; + /// rnti type + //crc_scrambled_t rnti_type; /// Format NR_DCI_format_t format; /// search space dci_space_t search_space; /// DCI pdu - uint8_t dci_pdu[8]; + uint32_t dci_pdu[4]; //#if defined(UPGRADE_RAT_NR) #if 1 /// harq information diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index b742fc0ded..509775f0c3 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -3147,6 +3147,13 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * #endif // p in TS 38.212 Subclause 10.1, for each active BWP the UE can deal with 3 different CORESETs (including coresetId 0 for common search space) int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; + unsigned int dci_cnt=0; + // this table contains 56 (NBR_NR_DCI_FIELDS) elements for each dci field and format described in TS 38.212. Each element represents the size in bits for each dci field + uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {0}; + // this is the UL bandwidth part. FIXME! To be defined where this value comes from + uint16_t n_RB_ULBWP = 106; + // this is the DL bandwidth part. FIXME! To be defined where this value comes from + uint16_t n_RB_DLBWP = 106; // First we have to identify each searchSpace active at a time and do PDCCH monitoring corresponding to current searchSpace // Up to 10 searchSpaces can be configured to UE (s<=10) @@ -3213,7 +3220,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * // FIXME! A table of five enum elements // searchSpaceType indicates whether this is a common search space or a UE-specific search space //int searchSpaceType = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceType.type; - int searchSpaceType = common; + NR_SEARCHSPACE_TYPE_t searchSpaceType = common; #ifdef NR_PDCCH_SCHED_DEBUG printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> searchSpaceType=%d is hardcoded THIS HAS TO BE FIXED!!!\n", searchSpaceType); @@ -3225,7 +3232,6 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * if (nb_coreset_active >= nb_coreset_total) return 0; // the coreset_id could not be found. There is a problem }*/ - unsigned int dci_cnt=0, i; /* * we do not need these parameters yet * @@ -3240,12 +3246,6 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * int tci_present = pdcch_vars2->coreset[nb_coreset_active].tciPresentInDCI; uint16_t pdcch_DMRS_scrambling_id = pdcch_vars2->coreset[nb_coreset_active].pdcchDMRSScramblingID; */ - // this table contains 56 (NBR_NR_DCI_FIELDS) elements for each dci field and format described in TS 38.212. Each element represents the size in bits for each dci field - uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {0}; - // this is the UL bandwidth part. FIXME! To be defined where this value comes from - uint16_t n_RB_ULBWP = 106; - // this is the DL bandwidth part. FIXME! To be defined where this value comes from - uint16_t n_RB_DLBWP = 106; // A set of PDCCH candidates for a UE to monitor is defined in terms of PDCCH search spaces. // Searchspace types: @@ -3346,10 +3346,10 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * nb_coreset_active, dci_cnt); #endif - dci_cnt = nr_dci_decoding_procedure(nb_searchspace_active, + dci_cnt += nr_dci_decoding_procedure(nb_searchspace_active, nb_coreset_active, ue, - dci_alloc_rx, + dci_alloc_rx[dci_cnt], searchSpaceType, // if we're in PUSCH don't listen to common search space, // later when we need paging or RA during connection, update this ... eNB_id, @@ -3371,10 +3371,10 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * nb_coreset_active, dci_cnt); #endif - dci_cnt = nr_dci_decoding_procedure(nb_searchspace_active, + dci_cnt += nr_dci_decoding_procedure(nb_searchspace_active, nb_coreset_active, ue, - dci_alloc_rx, + dci_alloc_rx[dci_cnt], searchSpaceType, // if we're in PUSCH don't listen to common search space, // later when we need paging or RA during connection, update this ... eNB_id, @@ -3470,7 +3470,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * ue->dci_ind.number_of_dcis = dci_cnt; ue->dl_indication.dci_ind = &ue->dci_ind; // hang on rx_ind instance - for (i=0; i Date: Tue, 28 Aug 2018 04:20:20 -0700 Subject: [PATCH 074/114] disabling debug messages in polartest + fixing incorrect free() --- openair1/PHY/CODING/TESTBENCH/polartest.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 69a28dfb68..d379aaf58e 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -11,7 +11,7 @@ #include "SIMULATION/TOOLS/sim.h" //#define DEBUG_POLAR_PARAMS -#define DEBUG_DCI_POLAR_PARAMS +//#define DEBUG_DCI_POLAR_PARAMS int main(int argc, char *argv[]) { @@ -209,7 +209,7 @@ int main(int argc, char *argv[]) { modulatedInput[i]=(-1)/sqrt(2); channelOutput[i] = modulatedInput[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin))); - printf("%f\n",channelOutput[i]); + //printf("%f\n",channelOutput[i]); } @@ -273,8 +273,8 @@ int main(int argc, char *argv[]) { print_meas(&timeDecoder,"polar_decoder",NULL,NULL); fclose(logFile); - free(testInput); - free(encoderOutput); + //free(testInput); + //free(encoderOutput); free(modulatedInput); free(channelOutput); free(estimatedOutput); From 06dd8845ea2795e70ff7839d299906795e9c8f50 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Tue, 28 Aug 2018 14:46:50 +0200 Subject: [PATCH 075/114] Polar parms struct fix --- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 3 ++- openair1/PHY/NR_TRANSPORT/nr_transport.h | 1 + openair1/SCHED_NR/phy_procedures_nr_gNB.c | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 1e761ea0bb..0784d9ca9d 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -199,6 +199,7 @@ uint8_t nr_pbch_payload_interleaver(uint8_t i) { // 29,31,16,23,18,17,8,30,10,6,24,7,0,5,3,2}; int nr_generate_pbch(NR_gNB_PBCH *pbch, + t_nrPolar_paramsPtr polar_params, uint8_t *pbch_pdu, int32_t **txdataF, int16_t amp, @@ -288,7 +289,7 @@ pbch_a_b[m] = ((pbch->pbch_a_prime[m/8]>>(m&7))&01); } /// CRC, coding and rate matching - polar_encoder (pbch->pbch_a_prime, pbch->pbch_e, &frame_parms->pbch_polar_params); + polar_encoder (pbch->pbch_a_prime, pbch->pbch_e, polar_params); #ifdef DEBUG_PBCH_ENCODING printf("Channel coding:\n"); for (int i=0; i>3; i++) diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport.h b/openair1/PHY/NR_TRANSPORT/nr_transport.h index e5a60dc021..e60bb0628c 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport.h @@ -84,6 +84,7 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, @returns 0 on success */ int nr_generate_pbch(NR_gNB_PBCH *pbch, + t_nrPolar_paramsPtr polar_params, uint8_t *pbch_pdu, int32_t **txdataF, int16_t amp, diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index 07daa8da3e..2ce9c7ef61 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -145,7 +145,7 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int subframe) { gNB->pbch_configured = 0; } nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF, AMP_OVER_2, ssb_start_symbol, cfg, fp); - nr_generate_pbch(&gNB->pbch, pbch_pdu, txdataF, AMP_OVER_2, ssb_start_symbol, n_hf, Lmax, ssb_index, frame, cfg, fp); + nr_generate_pbch(&gNB->pbch, gNB->nrPolar_params, pbch_pdu, txdataF, AMP_OVER_2, ssb_start_symbol, n_hf, Lmax, ssb_index, frame, cfg, fp); } } @@ -190,7 +190,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, if (nfapi_mode == 0 || nfapi_mode == 1) nr_generate_dci_top(gNB->pdcch_vars, - &gNB->nrPolar_params, + gNB->nrPolar_params, gNB->nr_gold_pdcch_dmrs[slot_idx], gNB->common_vars.txdataF, AMP, *fp, *cfg); From b9c823bcaa7525b16ea598d9990b0062f04e2292 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Tue, 28 Aug 2018 15:49:33 +0200 Subject: [PATCH 076/114] ue convert pdcch llr to double --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 0eac129b97..651e30f7c6 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -2934,7 +2934,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, pdcch_channel_level(pdcch_vars[eNB_id]->dl_ch_estimates_ext, frame_parms, avgP, - n_rb_offset); + coreset_nbr_rb); avgs = 0; for (aatx = 0; aatx < frame_parms->nb_antenna_ports_eNB; aatx++) for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) @@ -4146,8 +4146,10 @@ void nr_dci_decoding_procedure0(int s, printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we enter function dci_decoding(sizeof_bits=%d L=%d) -----\n",sizeof_bits,L); printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we have to replace this part of the code by polar decoding\n"); #endif - //&pdcch_vars[eNB_id]->e_rx[CCEind * 54] + for (int m=0; m < (nCCE[p]*6*9*2); m++) + polar_input[m] = (pdcch_vars[eNB_id]->e_rx[CCEind * 54+m]>0) ? (1.0):(-1.0); + nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits, L); t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits,L); From 5141341cb689438896c05a21697d77912cf907b6 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Thu, 30 Aug 2018 09:43:50 +0200 Subject: [PATCH 077/114] ue bug fix polar decoder init --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 651e30f7c6..86e89cbb42 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -54,6 +54,7 @@ //#define NR_PDCCH_DCI_DEBUG // activates NR_PDCCH_DCI_DEBUG logs #define NR_NBR_CORESET_ACT_BWP 3 // The number of CoreSets per BWP is limited to 3 (including initial CORESET: ControlResourceId 0) #define NR_NBR_SEARCHSPACE_ACT_BWP 10 // The number of SearSpaces per BWP is limited to 10 (including initial SEARCHSPACE: SearchSpaceId 0) +#define PDCCH_TEST_POLAR_TEMP_FIX //#undef ALL_AGGREGATION @@ -4150,8 +4151,14 @@ void nr_dci_decoding_procedure0(int s, for (int m=0; m < (nCCE[p]*6*9*2); m++) polar_input[m] = (pdcch_vars[eNB_id]->e_rx[CCEind * 54+m]>0) ? (1.0):(-1.0); - nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits, L); - t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits,L); + #ifdef PDCCH_TEST_POLAR_TEMP_FIX + t_nrPolar_paramsPtr currentPtr = NULL; + nr_polar_init(¤tPtr, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); + + #else + nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits, L); + t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits,L); + #endif dci_decoding(sizeof_bits, L, currentPtr, polar_input, &dci_decoded_output[current_thread_id][0]); /* From c631c064ecc3f0ead065215926c0dff5cc1b5bb3 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Fri, 31 Aug 2018 17:29:34 +0200 Subject: [PATCH 078/114] ue bug fix pdcch procedure --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 171 +++++++++++--------- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 105 ++++++------ 2 files changed, 149 insertions(+), 127 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 86e89cbb42..e15125af1b 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -51,7 +51,7 @@ //#define NR_LTE_PDCCH_DCI_SWITCH #define NR_PDCCH_DCI_RUN // activates new nr functions -//#define NR_PDCCH_DCI_DEBUG // activates NR_PDCCH_DCI_DEBUG logs +#define NR_PDCCH_DCI_DEBUG // activates NR_PDCCH_DCI_DEBUG logs #define NR_NBR_CORESET_ACT_BWP 3 // The number of CoreSets per BWP is limited to 3 (including initial CORESET: ControlResourceId 0) #define NR_NBR_SEARCHSPACE_ACT_BWP 10 // The number of SearSpaces per BWP is limited to 10 (including initial SEARCHSPACE: SearchSpaceId 0) #define PDCCH_TEST_POLAR_TEMP_FIX @@ -550,11 +550,12 @@ void nr_pdcch_deinterleaving(NR_DL_FRAME_PARMS *frame_parms, uint16_t *z, * if interleaved then do this: wbar table has bundles interleaved. We have to de-interleave then * following procedure described in 38.211 Section 7.3.2.2: */ - uint32_t bundle_id, bundle_interleaved, c=0 ,r=-1, k, l, i=0; - uint32_t coreset_C = (uint32_t)(coreset_nbr_rb / (coreset_interleaver_size_R*reg_bundle_size_L)); - uint16_t *wptr; - wptr = &wtemp_rx[0]; - z = &wtemp_rx[0]; + int c=0 ,r=-1; + uint32_t bundle_id, bundle_interleaved, k, l, i=0; + uint32_t coreset_C = (uint32_t)(coreset_nbr_rb * coreset_time_dur/ (coreset_interleaver_size_R*reg_bundle_size_L)); + //uint16_t *wptr; + //wptr = &wtemp_rx[0]; + //z = &wtemp_rx[0]; bundle_id=0; for (k=0 ; k<9*coreset_nbr_rb*coreset_time_dur; k++){ #ifdef NR_PDCCH_DCI_DEBUG @@ -571,7 +572,7 @@ void nr_pdcch_deinterleaving(NR_DL_FRAME_PARMS *frame_parms, uint16_t *z, r++; } #ifdef NR_PDCCH_DCI_DEBUG - printf("\t --> time to modify bundle_interleaved and bundle_id --> r=%d c=%d",r,c); + printf("\t --> time to modify bundle_interleaved and bundle_id --> r=%d c=%d\n",r,c); #endif bundle_id=c*coreset_interleaver_size_R+r; bundle_interleaved=(r*coreset_C+c+n_shift)%(coreset_nbr_rb * coreset_time_dur/reg_bundle_size_L); @@ -579,15 +580,15 @@ void nr_pdcch_deinterleaving(NR_DL_FRAME_PARMS *frame_parms, uint16_t *z, if (coreset_interleaved == 1){ //wptr[i+(bundle_interleaved-bundle_id)*9*reg_bundle_size_L]=wbar[i]; #ifdef NR_PDCCH_DCI_DEBUG - printf("\n\t\t\t\t\t\t\t\t\t wptr[%d] <-> wbar[%d]",i,i+(bundle_interleaved-bundle_id)*9*reg_bundle_size_L); + printf("\t\t\t\t\t wptr[%d] = (%d,%d) <-> wbar[%d]",i, *(char*) &wbar[i], *(1 + (char*) &wbar[i]),i+(bundle_interleaved-bundle_id)*9*reg_bundle_size_L); #endif - wptr[i]=wbar[i+(bundle_interleaved-bundle_id)*9*reg_bundle_size_L]; + z[i]=wbar[i+(bundle_interleaved-bundle_id)*9*reg_bundle_size_L]; #ifdef NR_PDCCH_DCI_DEBUG printf("\t\t bundle_id = %d \t bundle_interleaved = %d (r=%d, c=%d)\n",bundle_id,bundle_interleaved,r,c); #endif i++; } else { - wptr[i]=wbar[i]; + z[i]=wbar[i]; i++; } //bundle_id=c*coreset_interleaver_size_R+r; @@ -759,11 +760,11 @@ int32_t pdcch_qpsk_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, char *pdcch_llr, uint8_t symbol,uint32_t coreset_nbr_rb) { - int16_t *rxF = (int16_t*) &rxdataF_comp[0][(symbol * frame_parms->N_RB_DL * 12)]; + int16_t *rxF = (int16_t*) &rxdataF_comp[0][(symbol * coreset_nbr_rb * 9)]; int32_t i; char *pdcch_llr8; - pdcch_llr8 = &pdcch_llr[2 * symbol * frame_parms->N_RB_DL * 12]; + pdcch_llr8 = &pdcch_llr[2 * symbol * coreset_nbr_rb * 9]; if (!pdcch_llr8) { printf("pdcch_qpsk_llr: llr is null, symbol %d\n", symbol); @@ -1157,15 +1158,15 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, #endif } - dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol * (frame_parms->N_RB_DL * NBR_RE_PER_RB_WITHOUT_DMRS)]; + dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITHOUT_DMRS)]; #ifdef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> dl_ch0_ext = &dl_ch_estimates_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 9) = (%d)]\n", - aarx,symbol * (frame_parms->N_RB_DL * NBR_RE_PER_RB_WITHOUT_DMRS)); + aarx,symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITHOUT_DMRS)); #endif - rxF_ext = &rxdataF_ext[aarx][symbol * (frame_parms->N_RB_DL * NBR_RE_PER_RB_WITHOUT_DMRS)]; + rxF_ext = &rxdataF_ext[aarx][symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITHOUT_DMRS)]; #ifdef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> rxF_ext = &rxdataF_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 9) = (%d)]\n", - aarx,symbol * (frame_parms->N_RB_DL * NBR_RE_PER_RB_WITHOUT_DMRS)); + aarx,symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITHOUT_DMRS)); printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> (for symbol=%d, aarx=%d), symbol_mod=%d, nushiftmod3=%d \n",symbol,aarx,symbol_mod,nushiftmod3); #endif @@ -1332,7 +1333,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, #endif dl_ch0_ext[j++] = dl_ch0[i]; //printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> ch %d => dl_ch0(%d,%d)\n", i, *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i])); - printf("\t-> ch %d => dl_ch0(%d,%d)\n", i, *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i])); + printf("\t-> dl_ch0[%d] => dl_ch0_ext[%d](%d,%d)\n", i,(j-1), *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i])); } else { #ifdef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t\t <==> DM-RS PDCCH, this is a pilot symbol\n", @@ -2105,9 +2106,9 @@ short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; // dl_ch128 = (__m128i *) &dl_ch_estimates_ext[(aatx << 1) + aarx][symbol * frame_parms->N_RB_DL * 12]; // rxdataF128 = (__m128i *) &rxdataF_ext[aarx][symbol * frame_parms->N_RB_DL * 12]; // rxdataF_comp128 = (__m128i *) &rxdataF_comp[(aatx << 1) + aarx][symbol * frame_parms->N_RB_DL * 12]; - dl_ch128 = (__m128i *) &dl_ch_estimates_ext[(aatx << 1) + aarx][symbol * coreset_nbr_rb * 12]; - rxdataF128 = (__m128i *) &rxdataF_ext[aarx][symbol * coreset_nbr_rb * 12]; - rxdataF_comp128 = (__m128i *) &rxdataF_comp[(aatx << 1) + aarx][symbol * coreset_nbr_rb * 12]; + dl_ch128 = (__m128i *) &dl_ch_estimates_ext[(aatx << 1) + aarx][symbol * coreset_nbr_rb * 9]; + rxdataF128 = (__m128i *) &rxdataF_ext[aarx][symbol * coreset_nbr_rb * 9]; + rxdataF_comp128 = (__m128i *) &rxdataF_comp[(aatx << 1) + aarx][symbol * coreset_nbr_rb * 9]; #elif defined(__arm__) #endif #ifdef NR_PDCCH_DCI_DEBUG @@ -2120,7 +2121,10 @@ short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; #endif #if defined(__x86_64__) || defined(__i386__) #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF x dl_ch -> RB[%d] RE[%d]\n",rb,k); + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF_comp = rxdataF_ext(%d,%d) x dl_ch_ext(%d,%d) -> RB[%d] RE[%d]\n", + *(short *) &rxdataF_ext[(rb*9)+k],*(1 + (short*) &rxdataF_ext[(rb*9)+k]), + *(short *) &dl_ch_estimates_ext[(rb*9)+k],*(1 + (short*) &dl_ch_estimates_ext[(rb*9)+k]), + rb,k); #endif k++; if (k%9 == 0) rb++; @@ -2815,7 +2819,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, // For each BWP the number of CORESETs is limited to 3 (including initial CORESET Id=0 -> ControlResourceSetId (0..maxNrofControlReourceSets-1) (0..12-1) //uint32_t n_BWP_start = 0; //uint32_t n_rb_offset = 0; - uint32_t n_rb_offset = pdcch_vars2->coreset[nb_coreset_active].rb_offset; + uint32_t n_rb_offset = pdcch_vars2->coreset[nb_coreset_active].rb_offset+43; //to be removed 43 // start time position for CORESET // parameter symbol_mon is a 14 bits bitmap indicating monitoring symbols within a slot uint8_t start_symbol = 0; @@ -2823,11 +2827,12 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, // at the moment we are considering that the PDCCH is always starting at symbol 0 of current slot // the following code to initialize start_symbol must be activated once we implement PDCCH demapping on symbol not equal to 0 (considering symbol_mon) for (int i=0; i < 14; i++) { - if (symbol_mon >> (13-i) != 0) { + if ((symbol_mon >> (i+1))&0x1 != 0) { start_symbol = i; i=14; } } + #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> symbol_mon=(%d) and start_symbol=(%d)\n",symbol_mon,start_symbol); printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> coreset_freq_dom=(%lld) n_rb_offset=(%d) coreset_time_dur=(%d) n_shift=(%d) reg_bundle_size_L=(%d) coreset_interleaver_size_R=(%d) \n", @@ -2904,6 +2909,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter nr_pdcch_extract_rbs_single(is_secondary_ue=%d) to remove DM-RS PDCCH\n", is_secondary_ue); + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> in nr_pdcch_extract_rbs_single(rxdataF -> rxdataF_ext || dl_ch_estimates -> dl_ch_estimates_ext)\n"); #endif nr_pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF, common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id], @@ -2930,6 +2936,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter pdcch_channel_level(avgP=%d) => compute channel level based on ofdm symbol 0, pdcch_vars[eNB_id]->dl_ch_estimates_ext\n",avgP); + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> in pdcch_channel_level(dl_ch_estimates_ext -> dl_ch_estimates_ext)\n"); #endif // compute channel level based on ofdm symbol 0 pdcch_channel_level(pdcch_vars[eNB_id]->dl_ch_estimates_ext, @@ -2951,6 +2958,7 @@ T(T_UE_PHY_PDCCH_ENERGY, T_INT(eNB_id), T_INT(0), T_INT(frame%1024), T_INT(nr_tt #endif #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter nr_pdcch_channel_compensation(log2_maxh=%d)\n",log2_maxh); + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> in nr_pdcch_channel_compensation(rxdataF_ext x dl_ch_estimates_ext -> rxdataF_comp)\n"); #endif // compute LLRs for ofdm symbol 0 only nr_pdcch_channel_compensation(pdcch_vars[eNB_id]->rxdataF_ext, @@ -3058,6 +3066,7 @@ printf("\t### in nr_rx_pdcch() function we enter pdcch_channel_compensation(log2 #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter nr_pdcch_llr(for symbol %d), pdcch_vars[eNB_id]->rxdataF_comp ---> pdcch_vars[eNB_id]->llr \n",s); + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> in nr_pdcch_llr(rxdataF_comp -> llr)\n"); #endif nr_pdcch_llr(frame_parms, pdcch_vars[eNB_id]->rxdataF_comp, @@ -3107,6 +3116,11 @@ T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL), coreset_nbr_rb); #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter nr_pdcch_unscrambling()\n"); + for (int i=0; i<(coreset_time_dur*coreset_nbr_rb*9); i++){ + printf("\te_rx[%d]=(%d,%d)",i,*(char*) &pdcch_vars[eNB_id]->e_rx[i],*(1 + (char*) &pdcch_vars[eNB_id]->e_rx[i])); + if (i%10 == 0) printf("\n"); + } + printf("\n"); #endif nr_pdcch_unscrambling(pdcch_vars[eNB_id]->crnti, frame_parms, @@ -3116,6 +3130,15 @@ T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL), // get_nCCE(n_pdcch_symbols, frame_parms, mi) * 72, pdcch_DMRS_scrambling_id, do_common); + #ifdef NR_PDCCH_DCI_DEBUG + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we end nr_pdcch_unscrambling()\n"); + for (int i=0; i<(coreset_time_dur*coreset_nbr_rb*9); i++){ + printf("\te_rx[%d]=(%d,%d)",i,*(char*) &pdcch_vars[eNB_id]->e_rx[i],*(1 + (char*) &pdcch_vars[eNB_id]->e_rx[i])); + if (i%10 == 0) printf("\n"); + } + printf("\n"); + #endif + /* printf("\t### in nr_rx_pdcch() function we enter pdcch_demapping()\n"); @@ -3724,39 +3747,6 @@ uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB, #endif -void dci_decoding(uint8_t DCI_LENGTH, - uint8_t aggregation_level, - t_nrPolar_paramsPtr currentPtr, - double *e, - uint8_t *decoded_output) -{ - - int8_t decoderState=0; - -#ifdef DEBUG_DCI_DECODING - int32_t i; -#endif - - if (aggregation_level>16) { - LOG_I(PHY," dci.c: dci_decoding FATAL, illegal aggregation_level %d\n",aggregation_level); - return; - } - - -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY," Doing DCI decoding for %d bits, DCI_LENGTH %d,coded_bits %d, e %p\n",3*(DCI_LENGTH+16),DCI_LENGTH,coded_bits,e); -#endif - - - decoderState = polar_decoder(e, - decoded_output, - currentPtr, - 8, - 0); - -} - - static uint8_t dci_decoded_output[RX_NB_TH][(MAX_DCI_SIZE_BITS+64)/8]; /*uint16_t get_nCCE(uint8_t num_pdcch_symbols,NR_DL_FRAME_PARMS *frame_parms,uint8_t mi) @@ -3946,10 +3936,11 @@ void nr_dci_decoding_procedure0(int s, uint16_t crc, CCEind, nCCE[3]; uint32_t *CCEmap = NULL, CCEmap_mask = 0; - int L2 = (1 << L); + uint8_t L2 = (1 << L); unsigned int Yk, nb_candidates = 0, i, m; unsigned int CCEmap_cand; - double *polar_input = malloc (sizeof(double) * 108*L); + double *polar_input = malloc (sizeof(double) * 108*L2); + int8_t decoderState=0; // A[p], p is the current active CORESET uint16_t A[3]={39827,39829,39839}; @@ -4037,6 +4028,9 @@ void nr_dci_decoding_procedure0(int s, nb_candidates = pdcch_vars[eNB_id]->searchSpace[s].searchSpaceType.srs_nrofCandidates; } else { nb_candidates = (L2 == 4) ? 4 : ((L2 == 8)? 2 : 1); // according to Table 10.1-1 (38.213 section 10.1) + #ifdef NR_PDCCH_DCI_DEBUG + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> we are in common searchSpace and nb_candidates=%d for L2=%d\n",nb_candidates,L2); + #endif } } else { switch (L2) { @@ -4058,6 +4052,7 @@ void nr_dci_decoding_procedure0(int s, default: break; } + // Find first available in ue specific search space // according to procedure in Section 10.1 of 38.213 // compute Yk @@ -4148,19 +4143,31 @@ void nr_dci_decoding_procedure0(int s, printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we have to replace this part of the code by polar decoding\n"); #endif - for (int m=0; m < (nCCE[p]*6*9*2); m++) +// for (int m=0; m < (nCCE[p]*6*9*2); m++) + printf("polar intput: "); + for (int m=0; m < (L2*6*9*2); m++){ polar_input[m] = (pdcch_vars[eNB_id]->e_rx[CCEind * 54+m]>0) ? (1.0):(-1.0); + printf("\t polar_input[%d]=%lf <-> e_rx[%d]=%d\n",m,polar_input[m],(CCEind * 54+m),pdcch_vars[eNB_id]->e_rx[CCEind * 54+m]); + } + printf("\n"); #ifdef PDCCH_TEST_POLAR_TEMP_FIX t_nrPolar_paramsPtr currentPtr = NULL; - nr_polar_init(¤tPtr, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); + nr_polar_init(¤tPtr, NR_POLAR_DCI_MESSAGE_TYPE, 41, 8); - #else - nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits, L); - t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, sizeof_bits,L); + //#else + // nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, (uint16_t)sizeof_bits, L2); + // t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, (uint16_t)sizeof_bits,L2); #endif - - dci_decoding(sizeof_bits, L, currentPtr, polar_input, &dci_decoded_output[current_thread_id][0]); + + decoderState = polar_decoder(polar_input, + &dci_decoded_output[current_thread_id][0], + currentPtr, + 8, + 0); + printf("decoderState %d\n", decoderState); + + //dci_decoding(sizeof_bits, 2, currentPtr, polar_input, &dci_decoded_output[current_thread_id][0]); /* for (i=0;i<3+(sizeof_bits>>3);i++) printf("dci_decoded_output[%d] => %x\n",i,dci_decoded_output[i]); @@ -5093,30 +5100,37 @@ uint8_t nr_dci_decoding_procedure(int s, int p, PHY_VARS_NR_UE *ue, NR_DCI_ALLOC_t *dci_alloc, - int do_common, + NR_SEARCHSPACE_TYPE_t searchSpacetype, int16_t eNB_id, uint8_t nr_tti_rx, - uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS], uint8_t dci_fields_sizes_cnt[MAX_NR_DCI_DECODED_SLOT][NBR_NR_DCI_FIELDS][NBR_NR_FORMATS], uint16_t n_RB_ULBWP, uint16_t n_RB_DLBWP, crc_scrambled_t *crc_scrambled, format_found_t *format_found) { +// uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS], + #ifdef NR_PDCCH_DCI_DEBUG + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure) nr_tti_rx=%d n_RB_ULBWP=%d n_RB_DLBWP=%d format_found=%d\n", + nr_tti_rx,n_RB_ULBWP,n_RB_DLBWP,*format_found); + #endif + + int do_common = (int)searchSpacetype; + uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS]; crc_scrambled_t crc_scrambled_ = *crc_scrambled; format_found_t format_found_ = *format_found; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure) nr_tti_rx=%d and format_found=%d %d\n",nr_tti_rx,*format_found,format_found_); - #endif uint8_t dci_cnt = 0, old_dci_cnt = 0; uint32_t CCEmap0 = 0, CCEmap1 = 0, CCEmap2 = 0; NR_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]]; + NR_UE_PDCCH *pdcch_vars2 = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; t_nrPolar_paramsPtr *nrPolar_params = &ue->nrPolar_params; uint8_t mi;// = get_mi(&ue->frame_parms, nr_tti_rx); // we need to initialize this values as crc is going to be compared with them - uint16_t c_rnti=pdcch_vars[eNB_id]->crnti; + //uint16_t c_rnti=pdcch_vars[eNB_id]->crnti; + uint16_t c_rnti=pdcch_vars2->crnti; //to be removed FIXME!!! + printf("c_rnti=%d\n",c_rnti); uint16_t cs_rnti,new_rnti,tc_rnti; uint16_t p_rnti=P_RNTI; uint16_t si_rnti=SI_RNTI; @@ -5150,9 +5164,8 @@ uint8_t nr_dci_decoding_procedure(int s, * */ - NR_UE_PDCCH *pdcch_vars2 = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]; - NR_UE_SEARCHSPACE_CSS_DCI_FORMAT_t css_dci_format = pdcch_vars2->searchSpace[s].searchSpaceType.common_dci_formats; - NR_UE_SEARCHSPACE_USS_DCI_FORMAT_t uss_dci_format = pdcch_vars2->searchSpace[s].searchSpaceType.ue_specific_dci_formats; + NR_UE_SEARCHSPACE_CSS_DCI_FORMAT_t css_dci_format = pdcch_vars2->searchSpace[s].searchSpaceType.common_dci_formats; //FIXME!!! + NR_UE_SEARCHSPACE_USS_DCI_FORMAT_t uss_dci_format = pdcch_vars2->searchSpace[s].searchSpaceType.ue_specific_dci_formats; //FIXME!!! // The following initialization is only for test purposes. To be removed // NR_UE_SEARCHSPACE_CSS_DCI_FORMAT_t @@ -5168,14 +5181,16 @@ uint8_t nr_dci_decoding_procedure(int s, #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> searSpaceType=%d\n",do_common); - if (do_common) { + if (do_common==0) { printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> css_dci_format=%d\n",css_dci_format); } else { printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> uss_dci_format=%d\n",uss_dci_format); } #endif + + // A set of PDCCH candidates for a UE to monitor is defined in terms of PDCCH search spaces - if (do_common) { // COMMON SearchSpaceType assigned to current SearchSpace/CORESET + if (do_common==0) { // COMMON SearchSpaceType assigned to current SearchSpace/CORESET // Type0-PDCCH common search space for a DCI format with CRC scrambled by a SI-RNTI // number of consecutive resource blocks and a number of consecutive symbols for // the control resource set of the Type0-PDCCH common search space from @@ -5207,6 +5222,7 @@ uint8_t nr_dci_decoding_procedure(int s, printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> calculating dci format size for common searchSpaces with format css_dci_format=%d, format_0_0_1_0_size_bits=%d, format_0_0_1_0_size_bytes=%d\n", css_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); #endif +#if 0 // for aggregation level 4. The number of candidates (L2=4) will be calculated in function nr_dci_decoding_procedure0 #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", @@ -5225,6 +5241,7 @@ uint8_t nr_dci_decoding_procedure(int s, for (int j=0; j common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", @@ -5243,6 +5260,7 @@ uint8_t nr_dci_decoding_procedure(int s, for (int j=0; j common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", @@ -5261,6 +5279,7 @@ uint8_t nr_dci_decoding_procedure(int s, for (int j=0; jnb_search_space; #ifdef NR_PDCCH_SCHED_DEBUG + printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> there is a bug in FAPI to calculate nb_searchspace_total=%d\n",nb_searchspace_total); + #endif + if (nb_searchspace_total>1) nb_searchspace_total=1; // to be removed when fixing bug in FAPI + #ifdef NR_PDCCH_SCHED_DEBUG + printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> there is a bug in FAPI to calculate nb_searchspace_total so we set it to 1...\n"); printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> the number of searchSpaces active in the current slot(%d) is %d) \n", nr_tti_rx,nb_searchspace_total); #endif // p in TS 38.212 Subclause 10.1, for each active BWP the UE can deal with 3 different CORESETs (including coresetId 0 for common search space) int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; - unsigned int dci_cnt=0; + uint8_t dci_cnt=0; // this table contains 56 (NBR_NR_DCI_FIELDS) elements for each dci field and format described in TS 38.212. Each element represents the size in bits for each dci field - uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {0}; + //uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {0}; // this is the UL bandwidth part. FIXME! To be defined where this value comes from uint16_t n_RB_ULBWP = 106; // this is the DL bandwidth part. FIXME! To be defined where this value comes from uint16_t n_RB_DLBWP = 106; + #ifdef NR_PDCCH_SCHED_DEBUG + printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> n_RB_ULBWP=%d n_RB_DLBWP=%d\n", + n_RB_ULBWP, + n_RB_DLBWP); + #endif // First we have to identify each searchSpace active at a time and do PDCCH monitoring corresponding to current searchSpace // Up to 10 searchSpaces can be configured to UE (s<=10) @@ -3286,8 +3296,8 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * ue->high_speed_flag, ue->is_secondary_ue);*/ //removed for nr_ue_pdcch_procedures #ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_rx_pdcch(nb_coreset_active=%d, (symbol_within_slot_mon&0x3FFF)=%d, searchSpaceType=%d)\n", - nb_coreset_active,(symbol_within_slot_mon&0x3FFF), + printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_rx_pdcch with eNB_id=%d (nb_coreset_active=%d, (symbol_within_slot_mon&0x3FFF)=%d, searchSpaceType=%d)\n", + eNB_id,nb_coreset_active,(symbol_within_slot_mon&0x3FFF), searchSpaceType); #endif nr_rx_pdcch(ue, @@ -3337,57 +3347,42 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * */ //removed for nr_ue_pdcch_procedures crc_scrambled_t crc_scrambled; format_found_t format_found=255; - + + #ifdef NR_PDCCH_SCHED_DEBUG if (searchSpaceType == common) { // search all possible dci's for COMMON SEARCH SPACES according to the current SEARCHSPACE configuration - #ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_dci_decoding_procedure(searchSpaceType=%d, nb_searchspace_active=%d, nb_coreset_active=%d) -> dci_cnt=%d\n", - searchSpaceType, + printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_dci_decoding_procedure with eNB_id=%d (n_RB_ULBWP=%d, n_RB_DLBWP=%d, searchSpaceType=%d, nb_searchspace_active=%d, nb_coreset_active=%d) -> dci_cnt=%d\n", + eNB_id,n_RB_ULBWP,n_RB_DLBWP,searchSpaceType, nb_searchspace_active, nb_coreset_active, dci_cnt); - #endif - dci_cnt += nr_dci_decoding_procedure(nb_searchspace_active, - nb_coreset_active, - ue, - dci_alloc_rx[dci_cnt], - searchSpaceType, // if we're in PUSCH don't listen to common search space, - // later when we need paging or RA during connection, update this ... - eNB_id, - nr_tti_rx, - dci_fields_sizes,dci_fields_sizes_cnt, - n_RB_ULBWP, - n_RB_DLBWP, - &crc_scrambled, - &format_found); - #ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%d\n",dci_cnt); - #endif } if (searchSpaceType == ue_specific){// search all possible dci's for UE-SPECIFIC SEARCH SPACES according to the current SEARCHSPACE configuration - #ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_dci_decoding_procedure(searchSpaceType=%d, nb_searchspace_active=%d, nb_coreset_active=%d) -> dci_cnt=%d\n", - searchSpaceType, + printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_dci_decoding_procedure with eNB_id=%d (n_RB_ULBWP=%d, n_RB_DLBWP=%d, searchSpaceType=%d, nb_searchspace_active=%d, nb_coreset_active=%d) -> dci_cnt=%d\n", + eNB_id,n_RB_ULBWP,n_RB_DLBWP,searchSpaceType, nb_searchspace_active, nb_coreset_active, dci_cnt); - #endif - dci_cnt += nr_dci_decoding_procedure(nb_searchspace_active, - nb_coreset_active, - ue, - dci_alloc_rx[dci_cnt], - searchSpaceType, // if we're in PUSCH don't listen to common search space, - // later when we need paging or RA during connection, update this ... - eNB_id, - nr_tti_rx, - dci_fields_sizes,dci_fields_sizes_cnt, - n_RB_ULBWP, - n_RB_DLBWP, - &crc_scrambled, - &format_found); - #ifdef NR_PDCCH_SCHED_DEBUG - printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%d\n",dci_cnt); - #endif } + #endif + + + + nr_dci_decoding_procedure(nb_searchspace_active, + nb_coreset_active, + ue, + &dci_alloc_rx[dci_cnt], + searchSpaceType, + eNB_id, + nr_tti_rx, + dci_fields_sizes_cnt, + n_RB_ULBWP, + n_RB_DLBWP, + &crc_scrambled, + &format_found); + #ifdef NR_PDCCH_SCHED_DEBUG + printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%d\n",dci_cnt); + #endif + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_OUT); //LOG_D(PHY,"[UE %d][PUSCH] Frame %d nr_tti_rx %d PHICH RX\n",ue->Mod_id,frame_rx,nr_tti_rx); @@ -3504,7 +3499,12 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * if ((dci_alloc_rx[i].format == format1_1)){ // This format not implemented at a first time. FIXME } NR_DCI_INFO_EXTRACTED_t nr_dci_info_extracted; - nr_generate_ue_ul_dlsch_params_from_dci(ue, + #ifdef NR_PDCCH_SCHED_DEBUG + printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_generate_ue_ul_dlsch_params_from_dci with eNB_id=%d dci_cnt=%d\n", + eNB_id, + dci_cnt); + #endif + nr_generate_ue_ul_dlsch_params_from_dci(ue, eNB_id, frame_rx, nr_tti_rx, @@ -5448,6 +5448,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN uint8_t next1_thread_id = ue->current_thread_id[nr_tti_rx]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[nr_tti_rx]+1); uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1); +#if 0 VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); #if T_TRACER @@ -5459,9 +5460,9 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN #endif // start timers -#ifdef UE_DEBUG_TRACE +//#ifdef UE_DEBUG_TRACE LOG_I(PHY," ****** start RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, nr_tti_rx); -#endif +//#endif #if UE_TIMING_TRACE start_meas(&ue->phy_proc_rx[ue->current_thread_id[nr_tti_rx]]); @@ -5491,6 +5492,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN ue->Mod_id,frame_rx, nr_tti_rx); #endif + if (ue->frame_parms.Ncp == 0) { // normal prefix pilot1 = 4; } else { // extended prefix @@ -5521,6 +5523,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN LOG_D(PHY," ------ slot 0 Processing: AbsSubframe %d.%d ------ \n", frame_rx%1024, nr_tti_rx); LOG_D(PHY," ------ --> FFT/ChannelEst/PDCCH slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, nr_tti_rx); +#endif //nr_gold_pdcch(ue,0, 2); /* @@ -5546,7 +5549,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN }*/ //ue_measurement_procedures(l-1,ue,proc,eNB_id,(nr_tti_rx<<1),abstraction_flag,mode); - if (do_pdcch_flag) { + //if (do_pdcch_flag) { // if ((l==pilot1) || ((pmch_flag==1)&(l==l2))) { // LOG_D(PHY,"[UE %d] Frame %d: Calling pdcch procedures (eNB %d)\n",ue->Mod_id,frame_rx,eNB_id); @@ -5561,7 +5564,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN // (ue->rx_pdcch_stats[ue->current_thread_id[nr_tti_rx]].p_time)/(cpuf*1000.0)); LOG_D(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->num_pdcch_symbols); // } - } + //} // } // for l=1..l2 From 9d3980aa19401a629199f23375171a45dc9fdd37 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Fri, 31 Aug 2018 17:32:17 +0200 Subject: [PATCH 079/114] ue adding nr_compute_tbs and nr_segmentation --- cmake_targets/CMakeLists.txt | 2 + openair1/PHY/CODING/nr_compute_tbs.c | 116 ++++++++++++++++++++++++++ openair1/PHY/CODING/nr_segmentation.c | 4 +- 3 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 openair1/PHY/CODING/nr_compute_tbs.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 2682582a46..420a2932ae 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1171,6 +1171,8 @@ set(PHY_SRC_COMMON ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_mbsfn.c ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_ul_ref.c ${OPENAIR1_DIR}/PHY/CODING/lte_segmentation.c + ${OPENAIR1_DIR}/PHY/CODING/nr_segmentation.c + ${OPENAIR1_DIR}/PHY/CODING/nr_compute_tbs.c ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte.c ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte_lte.c ${OPENAIR1_DIR}/PHY/CODING/3gpplte_sse.c diff --git a/openair1/PHY/CODING/nr_compute_tbs.c b/openair1/PHY/CODING/nr_compute_tbs.c new file mode 100644 index 0000000000..6cc19d23ff --- /dev/null +++ b/openair1/PHY/CODING/nr_compute_tbs.c @@ -0,0 +1,116 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/* file: nr_compute_tbs.c + purpose: Compute NR TBS + author: Hongzhi WANG (TCL) +*/ +//#include "PHY/defs.h" +//#include "SCHED/extern.h" + +#define INDEX_MAX_TBS_TABLE (93) +//Table 5.1.3.1-1 +uint16_t Mcsindextable1[29][3] = {{2,120,0.2344}, + {2,157,0.3066}, + {2,193,0.3770}, + {2,251,0.4902}, + {2,308,0.6016}, + {2,379,0.7402}, + {2,449,0.8770}, + {2,526,1.0273}, + {2,602,1.1758}, + {2,679,1.3262}, + {4,340,1.3281}, + {4,378,1.4766}, + {4,434,1.6953}, + {4,490,1.9141}, + {4,553,2.1602}, + {4,616,2.4063}, + {4,658,2.5703}, + {6,438,2.5664}, + {6,466,2.7305}, + {6,517,3.0293}, + {6,567,3.3223}, + {6,616,3.6094}, + {6,666,3.9023}, + {6,719,4.2129}, + {6,772,4.5234}, + {6,822,4.8164}, + {6,873,5.1152}, + {6,910,5.3320}, + {6,948,5.5547}}; + +uint16_t Tbstable_nr[INDEX_MAX_TBS_TABLE] = {24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,208,224,240,256,272,288,304,320,336,352,368,384,408,432,456,480,504,528,552,576,608,640,672,704,736,768,808,848,888,928,984,1032,1064,1128,1160,1192,1224,1256,1288,1320,1352,1416,1480,1544,1608,1672,1736,1800,1864,1928,2024,2088,2152,2216,2280,2408,2472,2536,2600,2664,2728,2792,2856,2976,3104,3240,3368,3496,3624,3752,3824}; + +uint32_t nr_compute_tbs(uint8_t mcs, uint16_t nb_rb,uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Nl) +{ + + uint16_t nbp_re, nb_re, nb_dmrs_prb, nb_rb_oh, Ninfo,Np_info,n,Qm,R,C; + uint32_t nr_tbs; + + nb_rb_oh = 0; //set to 0 if not configured by higher layer + Qm = Mcsindextable1[mcs][0]; + R = Mcsindextable1[mcs][1]; + nb_dmrs_prb = nb_re_dmrs*length_dmrs; + + nbp_re = 12 * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; + + nb_re = min(156, nbp_re) * nb_rb; + + // Intermediate number of information bits + Ninfo = (nb_re * R * Qm * Nl)/1024; + + //printf("Ninfo %d nbp_re %d nb_re %d Qm %d, R %d\n", Ninfo, nbp_re, nb_re, Qm, R); + + if (Ninfo <=3824) { + + n = max(3, floor(log2(Ninfo)) - 6); + Np_info = max(24, pow(n,2) * floor(Ninfo/pow(n,2))); + + for (int i=0; i= Np_info){ + nr_tbs = Tbstable_nr[i]; + break; + } + } + } + else { + n = floor(log2(Ninfo-24)) - 5; + Np_info = max(3840, pow(n,2) * round((Ninfo - 24)/pow(n,2))); + + if (R <= 1/4) { + C = ceil( (Np_info + 24)/3816 ); + nr_tbs = 8 * C * ceil( (Np_info + 24)/(8*C) ) - 24; + } + else { + if (Np_info > 8424){ + C = ceil( (Np_info + 24)/8424 ); + nr_tbs = 8 * C * ceil( (Np_info + 24)/(8*C) ) - 24; + } + else + nr_tbs = 8 * ceil( (Np_info + 24)/8 ) - 24; + + } + + } + + return nr_tbs; +} diff --git a/openair1/PHY/CODING/nr_segmentation.c b/openair1/PHY/CODING/nr_segmentation.c index e7035fcfaa..e14d04df22 100644 --- a/openair1/PHY/CODING/nr_segmentation.c +++ b/openair1/PHY/CODING/nr_segmentation.c @@ -24,8 +24,8 @@ author: Hongzhi WANG (TCL) date: 12.09.2017 */ -#include "PHY/defs.h" -#include "SCHED/extern.h" +//#include "PHY/defs.h" +//#include "SCHED/extern.h" //#define DEBUG_SEGMENTATION From c8a6bbd528fb49add9208be9a0c78e90bed8e080 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Fri, 31 Aug 2018 17:53:50 +0200 Subject: [PATCH 080/114] ue add nr_compute_tbs in header --- openair1/PHY/CODING/coding_defs.h | 16 ++++++++++++++++ openair1/PHY/CODING/nr_compute_tbs.c | 10 +++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h index f733b91eaa..001f17dad7 100644 --- a/openair1/PHY/CODING/coding_defs.h +++ b/openair1/PHY/CODING/coding_defs.h @@ -430,4 +430,20 @@ uint32_t crcbit (uint8_t * , int16_t reverseBits(int32_t ,int32_t); void phy_viterbi_dot11(int8_t *,uint8_t *,uint16_t); +int32_t nr_segmentation(unsigned char *input_buffer, + unsigned char **output_buffers, + unsigned int B, + unsigned int *C, + unsigned int *Kplus, + unsigned int *Kminus, + unsigned int *Zout, + unsigned int *F); + +uint32_t nr_compute_tbs(uint8_t mcs, + uint16_t nb_rb, + uint16_t nb_symb_sch, + uint8_t nb_re_dmrs, + uint16_t length_dmrs, + uint8_t Nl); + #endif diff --git a/openair1/PHY/CODING/nr_compute_tbs.c b/openair1/PHY/CODING/nr_compute_tbs.c index 6cc19d23ff..d995befdb5 100644 --- a/openair1/PHY/CODING/nr_compute_tbs.c +++ b/openair1/PHY/CODING/nr_compute_tbs.c @@ -57,12 +57,16 @@ uint16_t Mcsindextable1[29][3] = {{2,120,0.2344}, {6,873,5.1152}, {6,910,5.3320}, {6,948,5.5547}}; - +//Table 5.1.2.2-2 uint16_t Tbstable_nr[INDEX_MAX_TBS_TABLE] = {24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,208,224,240,256,272,288,304,320,336,352,368,384,408,432,456,480,504,528,552,576,608,640,672,704,736,768,808,848,888,928,984,1032,1064,1128,1160,1192,1224,1256,1288,1320,1352,1416,1480,1544,1608,1672,1736,1800,1864,1928,2024,2088,2152,2216,2280,2408,2472,2536,2600,2664,2728,2792,2856,2976,3104,3240,3368,3496,3624,3752,3824}; -uint32_t nr_compute_tbs(uint8_t mcs, uint16_t nb_rb,uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Nl) +uint32_t nr_compute_tbs(uint8_t mcs, + uint16_t nb_rb, + uint16_t nb_symb_sch, + uint8_t nb_re_dmrs, + uint16_t length_dmrs, + uint8_t Nl) { - uint16_t nbp_re, nb_re, nb_dmrs_prb, nb_rb_oh, Ninfo,Np_info,n,Qm,R,C; uint32_t nr_tbs; From 5cd4046e6e7227e60a8aea8fbe1ecbd63f0e1d9e Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Mon, 3 Sep 2018 17:15:26 +0200 Subject: [PATCH 081/114] Freq first mapping correction- debug mode --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 63 ++++++++++++++++++------------ openair1/PHY/defs_nr_common.h | 1 + 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 842b62ff3a..b29367923b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -163,11 +163,13 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, nfapi_nr_config_request_t config) { - int16_t mod_dmrs[3][NR_MAX_PDCCH_DMRS_LENGTH>>1]; // 3 for the max coreset duration + int16_t mod_dmrs[NR_MAX_CSET_DURATION][NR_MAX_PDCCH_DMRS_LENGTH>>1]; // 3 for the max coreset duration uint8_t idx=0; uint16_t a; int k,l,k_prime,dci_idx, dmrs_idx; nr_cce_t cce; + nr_reg_t reg; + nr_reg_t reg_mapping_list[NR_MAX_PDCCH_AGG_LEVEL*NR_NB_REG_PER_CCE]; /*First iteration: single DCI*/ NR_gNB_DCI_ALLOC_t dci_alloc = pdcch_vars.dci_alloc[0]; @@ -245,31 +247,44 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, if (pdcch_params.precoder_granularity == NFAPI_NR_CSET_SAME_AS_REG_BUNDLE) { + /*Reorder REG list for a freq first mapping*/ + uint8_t symb_idx[NR_MAX_CSET_DURATION] = {0,0,0}; + uint8_t nb_regs = dci_alloc.L*NR_NB_REG_PER_CCE; + uint8_t regs_per_symb = nb_regs/cset_nsymb; for (int cce_idx=0; cce_idx= frame_parms.ofdm_symbol_size) - k -= frame_parms.ofdm_symbol_size; - l = cset_start_symb + cce.reg_list[reg_idx].symb_idx; - dmrs_idx = (cce.reg_list[reg_idx].reg_idx/cset_nsymb)*3; - k_prime = 0; - for (int m=0; m> 15; - ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dmrs[l][(dmrs_idx<<1) + 1]) >> 15; - k_prime++; - dmrs_idx++; - } - else { // DCI payload - ((int16_t*)txdataF[aa])[(l*frame_parms.ofdm_symbol_size + k)<<1] = (a * mod_dci[dci_idx<<1]) >> 15; - ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dci[(dci_idx<<1) + 1]) >> 15; - dci_idx++; - } - k++; - if (k >= frame_parms.ofdm_symbol_size) - k -= frame_parms.ofdm_symbol_size; - } + for (int reg_idx=0; reg_idx= frame_parms.ofdm_symbol_size) + k -= frame_parms.ofdm_symbol_size; + l = cset_start_symb + reg.symb_idx; + dmrs_idx = (reg.reg_idx/cset_nsymb)*3; + k_prime = 0; + for (int m=0; m> 15; + ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dmrs[l][(dmrs_idx<<1) + 1]) >> 15; + k_prime++; + dmrs_idx++; + } + else { // DCI payload + ((int16_t*)txdataF[aa])[(l*frame_parms.ofdm_symbol_size + k)<<1] = (a * mod_dci[dci_idx<<1]) >> 15; + ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dci[(dci_idx<<1) + 1]) >> 15; + dci_idx++; + } + k++; + if (k >= frame_parms.ofdm_symbol_size) + k -= frame_parms.ofdm_symbol_size; } } } diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index e31da351ea..47703de9fc 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -76,6 +76,7 @@ #define NR_MAX_NUM_BWP 4 #define NR_MAX_PDCCH_AGG_LEVEL 16 +#define NR_MAX_CSET_DURATION 3 typedef enum { NR_MU_0=0, From 0577eef49868e5dc46ef944ff67ac4df8e8fd043 Mon Sep 17 00:00:00 2001 From: Hongzhi Date: Tue, 4 Sep 2018 10:02:55 +0200 Subject: [PATCH 082/114] fix compilation for nr compute_tbs and segmentation --- openair1/PHY/CODING/nr_compute_tbs.c | 2 +- openair1/PHY/CODING/nr_segmentation.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/CODING/nr_compute_tbs.c b/openair1/PHY/CODING/nr_compute_tbs.c index d995befdb5..4a1f213d73 100644 --- a/openair1/PHY/CODING/nr_compute_tbs.c +++ b/openair1/PHY/CODING/nr_compute_tbs.c @@ -23,7 +23,7 @@ purpose: Compute NR TBS author: Hongzhi WANG (TCL) */ -//#include "PHY/defs.h" +#include "PHY/defs_nr_UE.h" //#include "SCHED/extern.h" #define INDEX_MAX_TBS_TABLE (93) diff --git a/openair1/PHY/CODING/nr_segmentation.c b/openair1/PHY/CODING/nr_segmentation.c index e14d04df22..ad2e809815 100644 --- a/openair1/PHY/CODING/nr_segmentation.c +++ b/openair1/PHY/CODING/nr_segmentation.c @@ -24,7 +24,7 @@ author: Hongzhi WANG (TCL) date: 12.09.2017 */ -//#include "PHY/defs.h" +#include "PHY/defs_nr_UE.h" //#include "SCHED/extern.h" //#define DEBUG_SEGMENTATION From 581605e8e88a78d212c368ee2f72ce70c8aa2054 Mon Sep 17 00:00:00 2001 From: Hongzhi Date: Tue, 4 Sep 2018 10:06:43 +0200 Subject: [PATCH 083/114] minor fix nr tbs --- openair1/PHY/CODING/nr_compute_tbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/CODING/nr_compute_tbs.c b/openair1/PHY/CODING/nr_compute_tbs.c index 4a1f213d73..ddb82fed04 100644 --- a/openair1/PHY/CODING/nr_compute_tbs.c +++ b/openair1/PHY/CODING/nr_compute_tbs.c @@ -100,7 +100,7 @@ uint32_t nr_compute_tbs(uint8_t mcs, n = floor(log2(Ninfo-24)) - 5; Np_info = max(3840, pow(n,2) * round((Ninfo - 24)/pow(n,2))); - if (R <= 1/4) { + if (R <= 1024/4) { C = ceil( (Np_info + 24)/3816 ); nr_tbs = 8 * C * ceil( (Np_info + 24)/(8*C) ) - 24; } From 854e0a68183bd5cde878c4e6f32da124948a7268 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Tue, 4 Sep 2018 11:56:48 +0200 Subject: [PATCH 084/114] readded scrambling --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index b29367923b..36b00c48c6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -207,7 +207,9 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, /// DCI payload processing // CRC attachment + Scrambling + Channel coding + Rate matching uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD]; - uint16_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0; + uint32_t scrambled_output[NR_MAX_DCI_SIZE_DWORD]; + uint16_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? ((pdcch_params.scrambling_id)?pdcch_params.rnti:0) : 0; + uint16_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value; #ifdef PDCCH_TEST_POLAR_TEMP_FIX t_nrPolar_paramsPtr currentPtr = NULL;//, polarParams = NULL; nr_polar_init(¤tPtr, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); @@ -224,11 +226,12 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, printf("Encoded Payload: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", encoder_output[0], encoder_output[1], encoder_output[2], encoder_output[3]); #endif + nr_pdcch_scrambling(encoder_output, encoded_length, Nid, n_RNTI, scrambled_output); // QPSK modulation int16_t mod_dci[NR_MAX_DCI_SIZE>>1]; for (int i=0; i>1; i++) { - idx = (((encoder_output[i<<1]>>(i<<1))&1)<<1) ^ ((encoder_output[(i<<1)+1]>>((i<<1)+1))&1); + idx = (((scrambled_output[i<<1]>>(i<<1))&1)<<1) ^ ((scrambled_output[(i<<1)+1]>>((i<<1)+1))&1); mod_dci[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; mod_dci[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; #ifdef DEBUG_DCI @@ -258,8 +261,12 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, reg_mapping_list[reg.symb_idx*regs_per_symb + symb_idx[reg.symb_idx]++] = reg; } } -printf("REG list reordered: %d %d %d %d %d %d %d %d\n", reg_mapping_list[0].reg_idx, reg_mapping_list[1].reg_idx, reg_mapping_list[2].reg_idx, reg_mapping_list[3].reg_idx, - reg_mapping_list[4].reg_idx, reg_mapping_list[5].reg_idx, reg_mapping_list[6].reg_idx, reg_mapping_list[7].reg_idx); +#ifdef DEBUG_DCI + printf("\n Ordered REG list:\n"); + for (int i=0; i Date: Tue, 4 Sep 2018 17:42:44 +0200 Subject: [PATCH 085/114] All contiguous RB update --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 93 ++++++++++++++---------- openair1/PHY/NR_TRANSPORT/nr_dci_tools.c | 61 +--------------- 2 files changed, 54 insertions(+), 100 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 36b00c48c6..431ff1a68e 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -34,7 +34,7 @@ //#define DEBUG_PDCCH_DMRS //#define DEBUG_DCI -//#define DEBUG_POLAR_PARAMS +//#define DEBUG_CHANNEL_CODING #define PDCCH_TEST_POLAR_TEMP_FIX extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; @@ -220,7 +220,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, #endif polar_encoder_dci(dci_alloc.dci_pdu, encoder_output, currentPtr, n_RNTI); -#ifdef DEBUG_POLAR_PARAMS +#ifdef DEBUG_CHANNEL_CODING printf("DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1], dci_alloc.dci_pdu[2], dci_alloc.dci_pdu[3]); printf("Encoded Payload: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", @@ -231,7 +231,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, // QPSK modulation int16_t mod_dci[NR_MAX_DCI_SIZE>>1]; for (int i=0; i>1; i++) { - idx = (((scrambled_output[i<<1]>>(i<<1))&1)<<1) ^ ((scrambled_output[(i<<1)+1]>>((i<<1)+1))&1); + idx = ((((scrambled_output[(i<<1)>>5])>>((i<<1)&0x1f))&1)<<1) ^ (((scrambled_output[((i<<1)+1)>>5])>>(((i<<1)+1)&0x1f))&1); mod_dci[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; mod_dci[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1]; #ifdef DEBUG_DCI @@ -248,57 +248,70 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, if (cset_start_sc >= frame_parms.ofdm_symbol_size) cset_start_sc -= frame_parms.ofdm_symbol_size; - if (pdcch_params.precoder_granularity == NFAPI_NR_CSET_SAME_AS_REG_BUNDLE) { - /*Reorder REG list for a freq first mapping*/ - uint8_t symb_idx[NR_MAX_CSET_DURATION] = {0,0,0}; - uint8_t nb_regs = dci_alloc.L*NR_NB_REG_PER_CCE; - uint8_t regs_per_symb = nb_regs/cset_nsymb; - for (int cce_idx=0; cce_idx= frame_parms.ofdm_symbol_size) + if (pdcch_params.precoder_granularity == NFAPI_NR_CSET_ALL_CONTIGUOUS_RBS) { + /*in this case the DMRS are mapped on all the coreset*/ + for (l=cset_start_symb; l> 15; + ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dmrs[l][(dmrs_idx<<1) + 1]) >> 15; + k+=4; + if (k >= frame_parms.ofdm_symbol_size) k -= frame_parms.ofdm_symbol_size; - l = cset_start_symb + reg.symb_idx; - dmrs_idx = (reg.reg_idx/cset_nsymb)*3; - k_prime = 0; - for (int m=0; m= frame_parms.ofdm_symbol_size) + k -= frame_parms.ofdm_symbol_size; + l = cset_start_symb + reg.symb_idx; + dmrs_idx = (reg.reg_idx/cset_nsymb)*3; + k_prime = 0; + for (int m=0; m> 15; ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dmrs[l][(dmrs_idx<<1) + 1]) >> 15; k_prime++; dmrs_idx++; } - else { // DCI payload - ((int16_t*)txdataF[aa])[(l*frame_parms.ofdm_symbol_size + k)<<1] = (a * mod_dci[dci_idx<<1]) >> 15; - ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dci[(dci_idx<<1) + 1]) >> 15; - dci_idx++; - } - k++; - if (k >= frame_parms.ofdm_symbol_size) - k -= frame_parms.ofdm_symbol_size; } + else { // DCI payload + ((int16_t*)txdataF[aa])[(l*frame_parms.ofdm_symbol_size + k)<<1] = (a * mod_dci[dci_idx<<1]) >> 15; + ((int16_t*)txdataF[aa])[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (a * mod_dci[(dci_idx<<1) + 1]) >> 15; + dci_idx++; + } + k++; + if (k >= frame_parms.ofdm_symbol_size) + k -= frame_parms.ofdm_symbol_size; } } - - else { //NFAPI_NR_CSET_ALL_CONTIGUOUS_RBS - } - } #ifdef DEBUG_DCI diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 39a0370cb1..aafafb6d7d 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -31,7 +31,7 @@ */ #include "nr_dci.h" -//#define DEBUG_NFAPI_NR_RNTI_RA + void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m) { @@ -131,20 +131,6 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB, case NFAPI_NR_RNTI_RA: // Freq domain assignment fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); - #ifdef DEBUG_NFAPI_NR_RNTI_RA - printf("frequency_domain_assignment = %05d = %#010x\n" - " time_domain_assignment = %05d = %#010x\n" - " vrb_to_prb_mapping = %05d = %#010x\n" - " MCS = %05d = %#010x\n" - " tb_scaling = %05d = %#010x\n" - " N_RB = %05d = %#010x\n" - " fsize = %05d = %#010x\n", - pdu_rel15->frequency_domain_assignment,pdu_rel15->frequency_domain_assignment, - pdu_rel15->time_domain_assignment,pdu_rel15->time_domain_assignment, - pdu_rel15->vrb_to_prb_mapping,pdu_rel15->vrb_to_prb_mapping, - pdu_rel15->mcs,pdu_rel15->mcs,pdu_rel15->tb_scaling,pdu_rel15->tb_scaling, - N_RB,N_RB,fsize,fsize); - #endif for (int i=0; ifrequency_domain_assignment>>(fsize-i-1))&1)<sch_config.physical_cell_id.value : dci_alloc->pdcch_params.shift_index; nr_fill_cce_list(dci_alloc, n_shift, cand_idx); LOG_I(PHY, "DCI type %d payload (size %d) generated on candidate %d\n", dci_alloc->pdcch_params.dci_format, dci_alloc->size, cand_idx); - - - -/* if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_1_0) { - dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_1_0; - dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); - if (rel15->rnti_type == NFAPI_NR_RNTI_C - || rel15->rnti_type == NFAPI_NR_RNTI_CS - || rel15->rnti_type == NFAPI_NR_RNTI_new) { - - } else if (rel15->rnti_type == NFAPI_NR_RNTI_P) { - - } else if (rel15->rnti_type == NFAPI_NR_RNTI_SI) { - - } else if (rel15->rnti_type == NFAPI_NR_RNTI_RA) { - - } else if (rel15->rnti_type == NFAPI_NR_RNTI_TC) { - - } else { - AssertFatal(1==0, "[nr_fill_dci_and_dlsch] Incorrect DCI Format(%d) and RNTI Type(%d) combination",rel15->dci_format, rel15->rnti_type); - } - } else if (rel15->dci_format == NFAPI_NR_UL_DCI_FORMAT_0_0) { - dci_alloc->format = NFAPI_NR_UL_DCI_FORMAT_0_0; - dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_ul ,cfg); - } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_1_1) { - dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_1_1; - dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); - } else if (rel15->dci_format == NFAPI_NR_UL_DCI_FORMAT_0_1) { - dci_alloc->format = NFAPI_NR_UL_DCI_FORMAT_0_1; - dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_ul ,cfg); - } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_2_0) { - dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_2_0; - dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); - } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_2_1) { - dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_2_1; - dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); - } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_2_2) { - dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_2_2; - dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); - } else if (rel15->dci_format == NFAPI_NR_DL_DCI_FORMAT_2_3) { - dci_alloc->format = NFAPI_NR_DL_DCI_FORMAT_2_3; - dci_alloc->size = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_dl ,cfg); - } else { - AssertFatal(1==0, "[nr_fill_dci_and_dlsch] Incorrect DCI Format(%d)",rel15->dci_format); - }*/ } From a1ae155b4e03fc1fb4691bbd11450cb961b742ac Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Wed, 5 Sep 2018 15:06:48 +0200 Subject: [PATCH 086/114] Minor size fix --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 6 ++++-- openair1/PHY/defs_nr_common.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 431ff1a68e..4cca9e85f6 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -205,9 +205,8 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, } /// DCI payload processing - // CRC attachment + Scrambling + Channel coding + Rate matching + // CRC attachment + Scrambling + Channel coding + Rate matching uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD]; - uint32_t scrambled_output[NR_MAX_DCI_SIZE_DWORD]; uint16_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? ((pdcch_params.scrambling_id)?pdcch_params.rnti:0) : 0; uint16_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value; #ifdef PDCCH_TEST_POLAR_TEMP_FIX @@ -226,6 +225,9 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, printf("Encoded Payload: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", encoder_output[0], encoder_output[1], encoder_output[2], encoder_output[3]); #endif + + /// Scrambling + uint32_t scrambled_output[NR_MAX_DCI_SIZE_DWORD]; nr_pdcch_scrambling(encoder_output, encoded_length, Nid, n_RNTI, scrambled_output); // QPSK modulation diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 47703de9fc..aca6f684a6 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -124,7 +124,7 @@ typedef struct NR_BWP_PARMS { typedef struct { uint8_t reg_idx; - uint8_t start_sc_idx; + uint16_t start_sc_idx; uint8_t symb_idx; } nr_reg_t; From 35c705787d3c95b7854d7f7b58a1f35f9fb2f7d8 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Wed, 5 Sep 2018 15:35:14 +0200 Subject: [PATCH 087/114] UE nr pdcch update --- .../nr_dl_channel_estimation.c | 7 + openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 700 +++++++++--------- 2 files changed, 344 insertions(+), 363 deletions(-) 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 daa228c29a..7385267dd1 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -326,10 +326,17 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, ch, dl_ch, 16); + +#ifdef DEBUG_CH + for (int m =0; m<12; m++) + printf("data : dl_ch -> (%d,%d)\n",dl_ch[0+2*m],dl_ch[1+2*m]); +#endif pil+=2; rxF+=8; dl_ch+=24; k+=12; + + for (pilot_cnt=3; pilot_cnt<(3*nb_rb_coreset); pilot_cnt+=3) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index e15125af1b..a13875ef9c 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -37,6 +37,8 @@ //#include "PHY/defs.h" #include "PHY/defs_nr_UE.h" #include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h" +#include "PHY/phy_extern_nr_ue.h" +#include "PHY/CODING/coding_extern.h" //#include "PHY/extern.h" //#include "SCHED/defs.h" //#include "SIMULATION/TOOLS/defs.h" // for taus @@ -273,7 +275,6 @@ uint32_t Y; #define Msymb (DCI_BITS_MAX/2) //#define Mquad (Msymb/4) -static uint32_t bitrev_cc_dci[32] = {1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31,0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30}; static int32_t wtemp[2][Msymb]; void pdcch_interleaving(NR_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **wbar,uint8_t n_symbols_pdcch,uint8_t mi) @@ -344,6 +345,96 @@ void pdcch_interleaving(NR_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **wb #ifdef NR_PDCCH_DCI_RUN + +void nr_pdcch_demapping_deinterleaving(uint16_t *llr, + uint16_t *z, + NR_DL_FRAME_PARMS *frame_parms, + uint8_t coreset_time_dur, + uint32_t coreset_nbr_rb, + uint8_t reg_bundle_size_L, + uint8_t coreset_interleaver_size_R, + uint8_t n_shift){ +/* + * This function will do demapping and deinterleaving from llr containing demodulated symbols + * Demapping will regroup in REG and bundles + * Deinterleaving will order the bundles + * + * In the following example we can see the process. The llr contains the demodulated IQs, but they are not ordered from REG 0,1,2,.. + * In e_rx (z) we will order the REG ids and group them into bundles. + * Then we will put the bundles in the correct order as indicated in subclause 7.3.2.2 + * + llr --------------------------> e_rx (z) ----> e_rx (z) + | ... + | ... + | REG 26 +symbol 2 | ... + | ... + | REG 5 + | REG 2 + + | ... + | ... + | REG 25 +symbol 1 | ... + | ... + | REG 4 + | REG 1 + + | ... + | ... ... ... + | REG 24 (bundle 7) ... ... +symbol 0 | ... bundle 3 bundle 6 + | ... bundle 2 bundle 1 + | REG 3 bundle 1 bundle 7 + | REG 0 (bundle 0) bundle 0 bundle 0 + +*/ + int c=0,r=0; + uint16_t bundle_j=0, f_bundle_j,f_reg; + uint32_t coreset_C; + uint16_t index_z, index_llr; + + int coreset_interleaved = 0; + if (reg_bundle_size_L!=0){ // interleaving will be done only if reg_bundle_size_L != 0 + coreset_interleaved=1; + coreset_C = (uint32_t)((coreset_nbr_rb * coreset_time_dur)/ (coreset_interleaver_size_R*reg_bundle_size_L)); + } else { + reg_bundle_size_L=6; + } + + for(int reg=0; reg<((coreset_nbr_rb*coreset_time_dur)); reg++){ + if ((reg%reg_bundle_size_L) == 0){ + if (r == coreset_interleaver_size_R) { + r=0; + c++; + } + bundle_j = (c*coreset_interleaver_size_R)+r; + f_bundle_j = ((r*coreset_C)+c+n_shift)%((coreset_nbr_rb*coreset_time_dur)/reg_bundle_size_L); + if (coreset_interleaved==0) f_bundle_j=bundle_j; + #ifdef NR_PDCCH_DCI_DEBUG + printf("\n\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_demapping_deinterleaving)-> [r=%d,c=%d] bundle_j(%d) interleaved at f_bundle_j(%d)\n",r,c,bundle_j,f_bundle_j); + #endif + } + f_reg = (f_bundle_j*reg_bundle_size_L)+(reg%reg_bundle_size_L); + index_z = 9*reg; + //index_llr = 9*(((uint16_t)floor(f_reg/reg_bundle_size_L)+(f_reg)%coreset_time_dur))*(coreset_nbr_rb); + index_llr = 9*((uint16_t)floor(f_reg/coreset_time_dur)+((f_reg%coreset_time_dur)*(coreset_nbr_rb))); + for (int i=0; i<9; i++){ + z[index_z + i] = llr[index_llr + i]; + #ifdef NR_PDCCH_DCI_DEBUG + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_demapping_deinterleaving)-> [reg=%d,bundle_j=%d] z[%d]=(%d,%d) <-> \t[f_reg=%d,fbundle_j=%d] llr[%d]=(%d,%d) \n", + reg,bundle_j,(index_z + i),*(char*) &z[index_z + i],*(1 + (char*) &z[index_z + i]), + f_reg,f_bundle_j,(index_llr + i),*(char*) &llr[index_llr + i], *(1 + (char*) &llr[index_llr + i])); + #endif + } + if ((reg%reg_bundle_size_L) == 0) r++; + } +} + + + + + void nr_pdcch_demapping(uint16_t *llr, uint16_t *wbar, NR_DL_FRAME_PARMS *frame_parms, uint8_t coreset_time_dur, uint32_t coreset_nbr_rb) { @@ -1331,9 +1422,10 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, c_rb, i, j, *(short *) &rxF_ext[j],*(1 + (short*) &rxF_ext[j]), i, *(short *) &rxF[i], *(1 + (short*) &rxF[i])); #endif - dl_ch0_ext[j++] = dl_ch0[i]; + dl_ch0_ext[j] = dl_ch0[i]; //printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> ch %d => dl_ch0(%d,%d)\n", i, *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i])); - printf("\t-> dl_ch0[%d] => dl_ch0_ext[%d](%d,%d)\n", i,(j-1), *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i])); + printf("\t-> dl_ch0[%d] => dl_ch0_ext[%d](%d,%d)\n", i,j, *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i])); + j++; } else { #ifdef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t\t <==> DM-RS PDCCH, this is a pilot symbol\n", @@ -2067,10 +2159,12 @@ void pdcch_extract_rbs_dual(int32_t **rxdataF, } } } +#if defined(__x86_64__) || defined(__i386__) +__m128i mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3; +#elif defined(__arm__) +int16x8_t mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3; +#endif - - -#ifdef NR_PDCCH_DCI_RUN void nr_pdcch_channel_compensation(int32_t **rxdataF_ext, int32_t **dl_ch_estimates_ext, int32_t **rxdataF_comp, @@ -2081,335 +2175,105 @@ void nr_pdcch_channel_compensation(int32_t **rxdataF_ext, uint32_t coreset_nbr_rb) { - uint16_t rb; - #if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128, *rxdataF128, *rxdataF_comp128; - __m128i *dl_ch128_2, *rho128; - #elif defined(__arm__) - #endif - uint8_t aatx, aarx, pilots = 0; - -short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; -short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; - - #ifdef DEBUG_DCI_DECODING - LOG_I(PHY, "PDCCH comp: symbol %d\n",symbol); - #endif -/* - if (symbol == 0) - pilots = 1; -*/ - for (aatx = 0; aatx < frame_parms->nb_antenna_ports_eNB; aatx++) { - //if (frame_parms->mode1_flag && aatx>0) break; //if mode1_flag is set then there is only one stream to extract, independent of nb_antenna_ports_eNB - for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { - #if defined(__x86_64__) || defined(__i386__) - // dl_ch128 = (__m128i *) &dl_ch_estimates_ext[(aatx << 1) + aarx][symbol * frame_parms->N_RB_DL * 12]; - // rxdataF128 = (__m128i *) &rxdataF_ext[aarx][symbol * frame_parms->N_RB_DL * 12]; - // rxdataF_comp128 = (__m128i *) &rxdataF_comp[(aatx << 1) + aarx][symbol * frame_parms->N_RB_DL * 12]; - dl_ch128 = (__m128i *) &dl_ch_estimates_ext[(aatx << 1) + aarx][symbol * coreset_nbr_rb * 9]; - rxdataF128 = (__m128i *) &rxdataF_ext[aarx][symbol * coreset_nbr_rb * 9]; - rxdataF_comp128 = (__m128i *) &rxdataF_comp[(aatx << 1) + aarx][symbol * coreset_nbr_rb * 9]; - #elif defined(__arm__) - #endif - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> Total of RBs to be computed (%d), and number of RE (%d) (9 RE per RB)\n",coreset_nbr_rb,coreset_nbr_rb*9); - #endif - uint32_t k=0; - for (rb = 0; rb < coreset_nbr_rb; rb) { //FIXME this for loop risks an infinite loop if rb is not increased by 1 inside the loop - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rb=%d\n", rb); - #endif - #if defined(__x86_64__) || defined(__i386__) - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF_comp = rxdataF_ext(%d,%d) x dl_ch_ext(%d,%d) -> RB[%d] RE[%d]\n", - *(short *) &rxdataF_ext[(rb*9)+k],*(1 + (short*) &rxdataF_ext[(rb*9)+k]), - *(short *) &dl_ch_estimates_ext[(rb*9)+k],*(1 + (short*) &dl_ch_estimates_ext[(rb*9)+k]), - rb,k); - #endif - k++; - if (k%9 == 0) rb++; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF x dl_ch -> RB[%d] RE[%d]\n",rb,k); - #endif - k++; - if (k%9 == 0) rb++; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF x dl_ch -> RB[%d] RE[%d]\n",rb,k); - #endif - k++; - if (k%9 == 0) rb++; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF x dl_ch -> RB[%d] RE[%d]\n",rb,k); - #endif - k++; - if (k%9 == 0) rb++; - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[0], rxdataF128[0]); // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - // print_ints("re",&mmtmpPD0); - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0], _MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1, _MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1, *(__m128i * )&conjugate[0]); - - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> conjugate\t ### \t"); - for (int conjugate_index=0 ; conjugate_index< 8 ; conjugate_index++) - printf("conjugate[%d]=%d",conjugate_index,conjugate[conjugate_index]); - printf("\n"); - #endif - - // print_ints("im",&mmtmpPD1); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1, rxdataF128[0]); // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0, output_shift); - // print_ints("re(shift)",&mmtmpPD0); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1, output_shift); - // print_ints("im(shift)",&mmtmpPD1); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0, mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0, mmtmpPD1); - // print_ints("c0",&mmtmpPD2); - // print_ints("c1",&mmtmpPD3); - rxdataF_comp128[0] = _mm_packs_epi32(mmtmpPD2, mmtmpPD3); - // print_shorts("rx:",rxdataF128); - // print_shorts("ch:",dl_ch128); - // print_shorts("pack:",rxdataF_comp128); - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF x dl_ch -> RB[%d] RE[%d]\n",rb,k); - #endif - k++; - if (k%9 == 0) rb++; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF x dl_ch -> RB[%d] RE[%d]\n",rb,k); - #endif - k++; - if (k%9 == 0) rb++; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF x dl_ch -> RB[%d] RE[%d]\n",rb,k); - #endif - k++; - if (k%9 == 0) rb++; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF x dl_ch -> RB[%d] RE[%d]\n",rb,k); - #endif - k++; - if (k%9 == 0) rb++; - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[1], rxdataF128[1]); // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1], _MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1, _MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1, *(__m128i * )conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1, rxdataF128[1]); // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0, output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1, output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0, mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0, mmtmpPD1); - rxdataF_comp128[1] = _mm_packs_epi32(mmtmpPD2, mmtmpPD3); - // print_shorts("rx:",rxdataF128+1); - // print_shorts("ch:",dl_ch128+1); - // print_shorts("pack:",rxdataF_comp128+1); - // multiply by conjugated channel - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF x dl_ch -> RB[%d] RE[%d]\n",rb,k); - #endif - k++; - if (k%9 == 0) rb++; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF x dl_ch -> RB[%d] RE[%d]\n",rb,k); - #endif - k++; - if (k%9 == 0) rb++; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF x dl_ch -> RB[%d] RE[%d]\n",rb,k); - #endif - k++; - if (k%9 == 0) rb++; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rxdataF x dl_ch -> RB[%d] RE[%d]\n",rb,k); - #endif - k++; - if (k%9 == 0) rb++; - mmtmpPD0 = _mm_madd_epi16(dl_ch128[2], rxdataF128[2]); // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1, _MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1, *(__m128i * )conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1, rxdataF128[2]); // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0, output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1, output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0, mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0, mmtmpPD1); - rxdataF_comp128[2] = _mm_packs_epi32(mmtmpPD2, mmtmpPD3); - // We compute the third part of 4 symbols contained in one entire RB = 12 RE - //if (rb < 6 || rb > 95) { - #ifdef NR_PDCCH_DCI_DEBUG - print_shorts("\t\trxdataF_ext:", rxdataF128); - print_shorts("\t\tdl_ch:", dl_ch128); - print_shorts("\t\trxdataF_comp:", rxdataF_comp128); - print_shorts("\t\trxdataF_ext:", rxdataF128 + 1); - print_shorts("\t\tdl_ch:", dl_ch128 + 1); - print_shorts("\t\trxdataF_comp:", rxdataF_comp128 + 1); - print_shorts("\t\ttrxdataF_ext:", rxdataF128 + 2); - print_shorts("\t\tdl_ch:", dl_ch128 + 2); - print_shorts("\t\trxdataF_comp:", rxdataF_comp128 + 2); - #endif - //} - dl_ch128 += 3; - rxdataF128 += 3; - rxdataF_comp128 += 3; - //if ((rb + 1) % 4 == 3) - //rb++; - // if rxdataF_comp does contains pilot DM-RS PDCCH, as in previous code rxdataF_comp128 is a set of 4 consecutive outputs (32-bit) - // the computation of third part of 4 symbols contains last 9th symbol of the current rb + 3 first symbols of the next rb - // so rb computing must be take this into consideration, and every 4 rb, rb must be increased twice - //} - -// This code will replace the code below for nr -//#else -/* - if (pilots == 0) { - mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[2]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - rxdataF_comp128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - } - - print_shorts("rx:",rxdataF128); - print_shorts("ch:",dl_ch128); - print_shorts("pack:",rxdataF_comp128); - print_shorts("\trx:",rxdataF128+1); - print_shorts("\tch:",dl_ch128+1); - print_shorts("\tpack:",rxdataF_comp128+1); - print_shorts("\t\trx:",rxdataF128+2); - print_shorts("\t\tch:",dl_ch128+2); - print_shorts("\t\tpack:",rxdataF_comp128+2); - - if (pilots==0) { - dl_ch128+=3; - rxdataF128+=3; - rxdataF_comp128+=3; - } else { - dl_ch128+=2; - rxdataF128+=2; - rxdataF_comp128+=2; - } - -*/ -//#endif - + uint16_t rb; //,nb_rb=20; + uint8_t aatx,aarx; +#if defined(__x86_64__) || defined(__i386__) + __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; #elif defined(__arm__) +#endif + + for (aatx=0; aatxnb_antenna_ports_eNB;aatx++) + for (aarx=0; aarxnb_antennas_rx; aarx++) { + +#if defined(__x86_64__) || defined(__i386__) + dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*20*12]; + rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*20*12]; + rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol*20*12]; + //printf("ch compensation dl_ch ext addr %p \n", &dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*20*12]); + //printf("rxdataf ext addr %p symbol %d\n", &rxdataF_ext[aarx][symbol*20*12], symbol); + //printf("rxdataf_comp addr %p\n",&rxdataF_comp[(aatx<<1)+aarx][symbol*20*12]); + +#elif defined(__arm__) +// to be filled in +#endif + + for (rb=0; rbnb_antennas_rx; aarx++) { - #if defined(__x86_64__) || defined(__i386__) - rho128 = (__m128i *) &rho[aarx][symbol * frame_parms->N_RB_DL * 12]; - dl_ch128 = (__m128i *) &dl_ch_estimates_ext[aarx][symbol - * frame_parms->N_RB_DL * 12]; - dl_ch128_2 = (__m128i *) &dl_ch_estimates_ext[2 + aarx][symbol - * frame_parms->N_RB_DL * 12]; - -#elif defined(__arm__) - -#endif - -//for (rb = 0; rb < frame_parms->N_RB_DL; rb++) { -for (rb = 0; rb < coreset_nbr_rb; rb++) { -#if defined(__x86_64__) || defined(__i386__) - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[0], dl_ch128_2[0]); - // print_ints("re",&mmtmpD0); - - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0], - _MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1, _MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1, *(__m128i * )&conjugate[0]); - // print_ints("im",&mmtmpPD1); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1, dl_ch128_2[0]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0, output_shift); - // print_ints("re(shift)",&mmtmpD0); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1, output_shift); - // print_ints("im(shift)",&mmtmpD1); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0, mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0, mmtmpPD1); - // print_ints("c0",&mmtmpPD2); - // print_ints("c1",&mmtmpPD3); - rho128[0] = _mm_packs_epi32(mmtmpPD2, mmtmpPD3); - - //print_shorts("rx:",dl_ch128_2); - //print_shorts("ch:",dl_ch128); - //print_shorts("pack:",rho128); - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[1], dl_ch128_2[1]); - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1], - _MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1, _MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1, *(__m128i * )conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1, dl_ch128_2[1]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0, output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1, output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0, mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0, mmtmpPD1); - - rho128[1] = _mm_packs_epi32(mmtmpPD2, mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+1); - //print_shorts("ch:",dl_ch128+1); - //print_shorts("pack:",rho128+1); - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[2], dl_ch128_2[2]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2], - _MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1, _MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1, *(__m128i * )conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1, dl_ch128_2[2]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0, output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1, output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0, mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0, mmtmpPD1); - - rho128[2] = _mm_packs_epi32(mmtmpPD2, mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+2); - //print_shorts("ch:",dl_ch128+2); - //print_shorts("pack:",rho128+2); - - dl_ch128 += 3; - dl_ch128_2 += 3; - rho128 += 3; - -#elif defined(__arm_) - -#endif - } - } - - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); + _mm_empty(); + _m_empty(); #endif } -#endif + /* void pdcch_channel_compensation(int32_t **rxdataF_ext, @@ -3095,9 +2959,30 @@ T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL), } + + #ifdef NR_PDCCH_DCI_DEBUG + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter nr_pdcch_demapping_deinterleaving()\n"); + #endif + +nr_pdcch_demapping_deinterleaving(pdcch_vars[eNB_id]->llr, + (uint16_t*) pdcch_vars[eNB_id]->e_rx, + frame_parms, + coreset_time_dur, + coreset_nbr_rb, + reg_bundle_size_L, + coreset_interleaver_size_R, + n_shift); + + + + + + +#if 0 #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter nr_pdcch_demapping()\n"); #endif + nr_pdcch_demapping(pdcch_vars[eNB_id]->llr, pdcch_vars[eNB_id]->wbar, frame_parms, @@ -3138,7 +3023,7 @@ T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL), } printf("\n"); #endif - +#endif /* printf("\t### in nr_rx_pdcch() function we enter pdcch_demapping()\n"); @@ -3206,7 +3091,7 @@ void pdcch_scrambling(NR_DL_FRAME_PARMS *frame_parms, #ifdef NR_PDCCH_DCI_RUN void nr_pdcch_unscrambling(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_tti_rx, - int8_t* llr, uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common) { + double llr[], uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common) { int i; uint8_t reset; @@ -3249,6 +3134,52 @@ printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> (c_init=%d, n_id=%d, } +#if 0 + +void nr_pdcch_unscrambling_old(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_tti_rx, + int8_t* llr, uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common) { + + int i; + uint8_t reset; + uint32_t x1, x2, s = 0; + uint16_t n_id; //{0,1,...,65535} + uint32_t n_rnti; + + reset = 1; + // x1 is set in first call to lte_gold_generic + //do_common=1; +if (do_common){ + n_id = frame_parms->Nid_cell; + n_rnti = 0; +} else { + n_id = pdcch_DMRS_scrambling_id; + n_rnti = (uint32_t)crnti; +} +//x2 = ((n_rnti * (1 << 16)) + n_id)%(1 << 31); +//uint32_t puissance_2_16 = ((1<<16)*n_rnti)+n_id; +//uint32_t puissance_2_31= (1<<30)*2; +//uint32_t calc_x2=puissance_2_16%puissance_2_31; + x2 = (((1<<16)*n_rnti)+n_id)%((1<<30)*2); //this is c_init in 38.211 v15.1.0 Section 7.3.2.3 +// x2 = (nr_tti_rx << 9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 +#ifdef NR_PDCCH_DCI_DEBUG +printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> (c_init=%d, n_id=%d, n_rnti=%d)\n",x2,n_id,n_rnti); +#endif + for (i = 0; i < length; i++) { + if ((i & 0x1f) == 0) { + s = lte_gold_generic(&x1, &x2, reset); + // printf("lte_gold[%d]=%x\n",i,s); + reset = 0; + } + + // printf("unscrambling %d : e %d, c %d => ",i,llr[i],((s>>(i&0x1f))&1)); + if (((s >> (i % 32)) & 1) == 0) + llr[i] = -llr[i]; + // printf("%d\n",llr[i]); + + } +} +#endif // 0 + #endif @@ -3910,7 +3841,9 @@ int get_nCCE_offset_l1(int *CCE_table, #ifdef NR_PDCCH_DCI_RUN void nr_dci_decoding_procedure0(int s, //x - int p, //x + int p, + int coreset_time_dur, + uint16_t coreset_nbr_rb, //x NR_UE_PDCCH **pdcch_vars, //x int do_common, //x //dci_detect_mode_t mode, //not sure if necessary @@ -3930,6 +3863,7 @@ void nr_dci_decoding_procedure0(int s, uint8_t *dci_cnt, crc_scrambled_t *crc_scrambled, format_found_t *format_found, + uint16_t pdcch_DMRS_scrambling_id, uint32_t *CCEmap0, uint32_t *CCEmap1, uint32_t *CCEmap2) { @@ -4142,15 +4076,45 @@ void nr_dci_decoding_procedure0(int s, printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we enter function dci_decoding(sizeof_bits=%d L=%d) -----\n",sizeof_bits,L); printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we have to replace this part of the code by polar decoding\n"); #endif - -// for (int m=0; m < (nCCE[p]*6*9*2); m++) - printf("polar intput: "); - for (int m=0; m < (L2*6*9*2); m++){ - polar_input[m] = (pdcch_vars[eNB_id]->e_rx[CCEind * 54+m]>0) ? (1.0):(-1.0); - printf("\t polar_input[%d]=%lf <-> e_rx[%d]=%d\n",m,polar_input[m],(CCEind * 54+m),pdcch_vars[eNB_id]->e_rx[CCEind * 54+m]); - } - printf("\n"); +// The polar_input has to be taken from the e_rx table but in the proper order +// e_rx contains the bits grouped by bundle +// polar_input has to contain the bits ordered by b_tilde_0, b_tilde_1, .... + +// for (int m=0; m < (nCCE[p]*6*9*2); m++) + #ifdef NR_PDCCH_DCI_DEBUG + printf("polar intput (with coreset_time_dur=%d, coreset_nbr_rb=%d, p=%d, CCEind=%d): \n", + coreset_time_dur,coreset_nbr_rb,p,CCEind); + #endif + int reg_p,reg_e; + for (int m=0; m < (L2*6); m++){ + reg_p = (((int)floor(m/coreset_time_dur))+((m%coreset_time_dur)*(L2*6/coreset_time_dur)))*9*2; + reg_e = m*9*2; + for (int i=0; i<9*2; i++){ + polar_input[reg_p+i] = (pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]>0) ? (1.0):(-1.0); + printf("\t m=%d \tpolar_input[%d]=%lf <-> e_rx[%d]=%d\n",m,reg_p+i,polar_input[reg_p+i], + ((CCEind*9*6*2) + reg_e + i),pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]); + } + } + + #ifdef NR_PDCCH_DCI_DEBUG + printf("\n"); + int j=0; + uint32_t polar_hex[27] = {0}; + for (int i=0; icrnti, + frame_parms, + nr_tti_rx, + polar_input, + L2*6*9*2, + pdcch_DMRS_scrambling_id, + do_common);*/ + #ifdef PDCCH_TEST_POLAR_TEMP_FIX t_nrPolar_paramsPtr currentPtr = NULL; nr_polar_init(¤tPtr, NR_POLAR_DCI_MESSAGE_TYPE, 41, 8); @@ -5124,6 +5088,16 @@ uint8_t nr_dci_decoding_procedure(int s, NR_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]]; NR_UE_PDCCH *pdcch_vars2 = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]; + uint16_t pdcch_DMRS_scrambling_id = pdcch_vars2->coreset[p].pdcchDMRSScramblingID; + uint64_t coreset_freq_dom = pdcch_vars2->coreset[p].frequencyDomainResources; + int coreset_time_dur = pdcch_vars2->coreset[p].duration; + uint16_t coreset_nbr_rb; + for (int i = 0; i < 45; i++) { + // this loop counts each bit of the bit map coreset_freq_dom, and increments nbr_RB_coreset for each bit set to '1' + if (((coreset_freq_dom & 0x1FFFFFFFFFFF) >> i) & 0x1) coreset_nbr_rb++; + } + coreset_nbr_rb = 6 * coreset_nbr_rb; + // coreset_time_dur,coreset_nbr_rb, NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; t_nrPolar_paramsPtr *nrPolar_params = &ue->nrPolar_params; uint8_t mi;// = get_mi(&ue->frame_parms, nr_tti_rx); @@ -5229,11 +5203,11 @@ uint8_t nr_dci_decoding_procedure(int s, css_dci_format,(1<<2)); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 2, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ format_0_0_1_0_size_bits = nr_dci_format_size(crc_scrambled_,16,n_RB_ULBWP,n_RB_DLBWP,dci_fields_sizes); // after decoding dci successfully we recalculate dci pdu size with correct crc scrambled to get the right field sizes old_dci_cnt = dci_cnt; @@ -5248,11 +5222,11 @@ uint8_t nr_dci_decoding_procedure(int s, css_dci_format,(1<<3)); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 3, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_, pdcch_DMRS_scrambling_id,&CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ format_0_0_1_0_size_bits = nr_dci_format_size(crc_scrambled_,16,n_RB_ULBWP,n_RB_DLBWP,dci_fields_sizes); // after decoding dci successfully we recalculate dci pdu size with correct crc scrambled to get the right field sizes old_dci_cnt = dci_cnt; @@ -5267,11 +5241,11 @@ uint8_t nr_dci_decoding_procedure(int s, css_dci_format,(1<<4)); #endif old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 4, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ format_0_0_1_0_size_bits = nr_dci_format_size(crc_scrambled_,16,n_RB_ULBWP,n_RB_DLBWP,dci_fields_sizes); // after decoding dci successfully we recalculate dci pdu size with correct crc scrambled to get the right field sizes old_dci_cnt = dci_cnt; @@ -5294,11 +5268,11 @@ uint8_t nr_dci_decoding_procedure(int s, #endif // for aggregation level 1. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 0, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ old_dci_cnt = dci_cnt; for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 1, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ old_dci_cnt = dci_cnt; for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 2, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ old_dci_cnt = dci_cnt; for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 3, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ old_dci_cnt = dci_cnt; for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 4, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ old_dci_cnt = dci_cnt; for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 0, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ old_dci_cnt = dci_cnt; for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 1, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ old_dci_cnt = dci_cnt; for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, crc_scrambled_values, 2, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ old_dci_cnt = dci_cnt; for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 3, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ old_dci_cnt = dci_cnt; for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, crc_scrambled_values, 4, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, &CCEmap0, &CCEmap1, &CCEmap2); + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); if (dci_cnt != old_dci_cnt){ old_dci_cnt = dci_cnt; for (int i=0; i Date: Thu, 6 Sep 2018 16:04:21 +0200 Subject: [PATCH 088/114] nr ue clean warnings --- openair1/PHY/INIT/nr_init_ue.c | 5 +- openair1/PHY/INIT/phy_init.h | 2 + .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 30 +- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 8 +- .../NR_UE_TRANSPORT/nr_transport_proto_ue.h | 14 +- targets/RT/USER/nr-ue.c | 8 +- targets/RT/USER/nr-uesoftmodem.c | 265 ++++++++---------- 7 files changed, 153 insertions(+), 179 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index d102b1f8f9..29869e615b 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -34,6 +34,9 @@ #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/LTE_REFSIG/lte_refsig.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" +#include "PHY/INIT/phy_init.h" +#include "PHY/NR_REFSIG/pss_nr.h" +#include "openair1/PHY/NR_REFSIG/ul_ref_seq_nr.h" //uint8_t dmrs1_tab_ue[8] = {0,2,3,4,6,8,9,10}; @@ -658,8 +661,8 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, printf("Initializing UE vars (abstraction %"PRIu8") for eNB TXant %"PRIu8", UE RXant %"PRIu8"\n",abstraction_flag,fp->nb_antennas_tx,fp->nb_antennas_rx); //LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_UE][MOD %02u][]\n", ue->Mod_id+NB_eNB_INST); + nr_init_frame_parms_ue(&ue->frame_parms); phy_init_nr_top(ue); - //nr_init_frame_parms_ue(&ue->frame_parms); // many memory allocation sizes are hard coded AssertFatal( fp->nb_antennas_rx <= 2, "hard coded allocation for ue_common_vars->dl_ch_estimates[eNB_id]" ); diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index 49aabc0d58..f35f9855f2 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -56,6 +56,8 @@ int l1_north_init_eNB(void); */ int phy_init_top(LTE_DL_FRAME_PARMS *frame_parms); +void phy_init_nr_top(PHY_VARS_NR_UE *ue); + /*! \brief Allocate and Initialize the PHY variables relevant to the LTE ue signal buffers. diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 05d4e3fc08..e5ac340cce 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -32,11 +32,11 @@ #include "PHY/types.h" #include "PHY/defs_nr_UE.h" #include "PHY/phy_extern_nr_ue.h" +#include "PHY/INIT/phy_init.h" +#include "PHY/MODULATION/modulation_UE.h" +#include "nr_transport_proto_ue.h" //#include "SCHED/defs.h" //#include "SCHED/extern.h" -//#include "defs.h" -//#include "extern.h" - #include "common_lib.h" @@ -45,20 +45,16 @@ #include "PHY/NR_REFSIG/refsig_defs_ue.h" extern openair0_config_t openair0_cfg[]; -static nfapi_nr_config_request_t config_t; -static nfapi_nr_config_request_t* config =&config_t; +//static nfapi_nr_config_request_t config_t; +//static nfapi_nr_config_request_t* config =&config_t; int cnt=0; -/* forward declarations */ -void set_default_frame_parms_single(nfapi_nr_config_request_t *config, NR_DL_FRAME_PARMS *frame_parms); //#define DEBUG_INITIAL_SYNCH int nr_pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) { printf("nr pbch detec RB_DL %d\n", ue->frame_parms.N_RB_DL); - uint8_t l,pbch_decoded,frame_mod4,pbch_tx_ant,dummy; NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - char phich_resource[6]; int ret =-1; #ifdef DEBUG_INITIAL_SYNCH @@ -98,23 +94,15 @@ int nr_pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode) frame_parms->nb_prefix_samples0 = nb_prefix_samples0; - pbch_decoded = 0; - printf("pbch_detection nid_cell %d\n",frame_parms->Nid_cell); - //for (frame_mod4=0; frame_mod4<4; frame_mod4++) { ret = nr_rx_pbch(ue, &ue->proc.proc_rxtx[0], ue->pbch_vars[0], frame_parms, 0, SISO, - ue->high_speed_flag, - frame_mod4); - - pbch_decoded = 0; //to be updated -// break; - //} + ue->high_speed_flag); if (ret==0) { @@ -176,7 +164,6 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) // First try FDD normal prefix frame_parms->Ncp=NORMAL; frame_parms->frame_type=TDD; - set_default_frame_parms_single(config,frame_parms); nr_init_frame_parms_ue(frame_parms); printf("nr_initial sync ue RB_DL %d\n", ue->frame_parms.N_RB_DL); /* @@ -198,7 +185,7 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) */ cnt++; if (cnt >100){ - cnt =0; + cnt =0; /* process pss search on received buffer */ sync_pos = pss_synchro_nr(ue, NO_RATE_CHANGE); @@ -233,8 +220,7 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) rx_sss_nr(ue,&metric_fdd_ncp,&phase_fdd_ncp); - //set_default_frame_parms_single(config,&ue->frame_parms); - nr_init_frame_parms_ue(config,&ue->frame_parms); + nr_init_frame_parms_ue(&ue->frame_parms); nr_gold_pbch(ue); ret = nr_pbch_detection(ue,mode); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 8c9166b1b3..6ce7718199 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -34,6 +34,7 @@ #include "PHY/phy_extern_nr_ue.h" #include "PHY/sse_intrin.h" #include "SIMULATION/TOOLS/sim.h" +#include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_PBCH 1 //#define DEBUG_PBCH_ENCODING @@ -508,8 +509,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, NR_DL_FRAME_PARMS *frame_parms, uint8_t eNB_id, MIMO_mode_t mimo_mode, - uint32_t high_speed_flag, - uint8_t frame_mod4) + uint32_t high_speed_flag) { NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars; @@ -535,13 +535,13 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, unsigned short idx_demod =0; int8_t decoderState=0; uint8_t decoderListSize = 8, pathMetricAppr = 0; - double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload. + //double aPrioriArray[frame_parms->pbch_polar_params.payloadBits]; // assume no a priori knowledge available about the payload. memset(&pbch_a[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS); //printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell); - for (int i=0; ipbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN; + //for (int i=0; ipbch_polar_params.payloadBits; i++) aPrioriArray[i] = NAN; int subframe_rx = proc->subframe_rx; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index c5a947269a..954099410f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -1072,13 +1072,13 @@ int rx_sss(PHY_VARS_NR_UE *phy_vars_ue,int32_t *tot_metric,uint8_t *flip_max,uin /*! \brief receiver for the PBCH \returns number of tx antennas or -1 if error */ -uint16_t rx_pbch(NR_UE_COMMON *lte_ue_common_vars, - NR_UE_PBCH *lte_ue_pbch_vars, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t eNB_id, - MIMO_mode_t mimo_mode, - uint32_t high_speed_flag, - uint8_t frame_mod4); +int nr_rx_pbch( PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + NR_UE_PBCH *nr_ue_pbch_vars, + NR_DL_FRAME_PARMS *frame_parms, + uint8_t eNB_id, + MIMO_mode_t mimo_mode, + uint32_t high_speed_flag); uint16_t rx_pbch_emul(PHY_VARS_NR_UE *phy_vars_ue, uint8_t eNB_id, diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index bfd6088e92..fc8d44a236 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -283,9 +283,10 @@ void init_UE(int nb_inst) NR_UE_MAC_INST_t *mac_inst; for (inst=0; inst < nb_inst; inst++) { // UE->rfdevice.type = NONE_DEV; - PHY_VARS_NR_UE *UE = PHY_vars_UE_g[inst][0]; + //PHY_VARS_NR_UE *UE = PHY_vars_UE_g[inst][0]; LOG_I(PHY,"Initializing memory for UE instance %d (%p)\n",inst,PHY_vars_UE_g[inst]); PHY_vars_UE_g[inst][0] = init_nr_ue_vars(NULL,inst,0); + PHY_VARS_NR_UE *UE = PHY_vars_UE_g[inst][0]; AssertFatal((UE->if_inst = nr_ue_if_module_init(inst)) != NULL, "can not initial IF module\n"); nr_l3_init_ue(); @@ -295,6 +296,11 @@ void init_UE(int nb_inst) mac_inst->if_module = UE->if_inst; UE->if_inst->scheduled_response = nr_ue_scheduled_response; UE->if_inst->phy_config_request = nr_ue_phy_config_request; + + LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]); + //init_UE_threads(inst); + //UE = PHY_vars_UE_g[inst][0]; + AssertFatal(0 == pthread_create(&UE->proc.pthread_ue, &UE->proc.attr_ue, diff --git a/targets/RT/USER/nr-uesoftmodem.c b/targets/RT/USER/nr-uesoftmodem.c index 149ec92ec3..635fe524e3 100644 --- a/targets/RT/USER/nr-uesoftmodem.c +++ b/targets/RT/USER/nr-uesoftmodem.c @@ -196,7 +196,7 @@ extern PHY_VARS_NR_UE* init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms, int transmission_mode=1; int numerology = 0; - +/* int16_t glog_level = LOG_INFO; int16_t glog_verbosity = LOG_MED; int16_t hw_log_level = LOG_INFO; @@ -213,6 +213,7 @@ int16_t rrc_log_level = LOG_INFO; int16_t rrc_log_verbosity = LOG_MED; int16_t opt_log_level = LOG_INFO; int16_t opt_log_verbosity = LOG_MED; +*/ # if defined(ENABLE_USE_MME) int16_t gtpu_log_level = LOG_DEBUG; @@ -543,78 +544,125 @@ void *l2l1_task(void *arg) { extern int16_t dlsch_demod_shift; -static void get_options (int argc, char **argv) { - int CC_id; - int tddflag, nonbiotflag; - char *loopfile=NULL; - int dumpframe; - uint32_t online_log_messages; - uint32_t glog_level, glog_verbosity; - uint32_t start_telnetsrv; - nfapi_nr_config_request_t *config[MAX_NUM_CCs]; +static void get_options(void) { + int CC_id; + int tddflag, nonbiotflag; + char *loopfile=NULL; + int dumpframe; + uint32_t online_log_messages; + uint32_t glog_level, glog_verbosity; + uint32_t start_telnetsrv; - paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ; - paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ; + paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ; + paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ; - //set_default_frame_parms(config,frame_parms); - config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); + set_default_frame_parms(frame_parms); + config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL); - if (strlen(in_path) > 0) { - opt_type = OPT_PCAP; - opt_enabled=1; - printf("Enabling OPT for PCAP with the following file %s \n",in_path); - } - if (strlen(in_ip) > 0) { - opt_enabled=1; - opt_type = OPT_WIRESHARK; - printf("Enabling OPT for wireshark for local interface"); - } + if (strlen(in_path) > 0) { + opt_type = OPT_PCAP; + opt_enabled=1; + printf("Enabling OPT for PCAP with the following file %s \n",in_path); + } + if (strlen(in_ip) > 0) { + opt_enabled=1; + opt_type = OPT_WIRESHARK; + printf("Enabling OPT for wireshark for local interface"); + } - config_process_cmdline( cmdline_logparams,sizeof(cmdline_logparams)/sizeof(paramdef_t),NULL); - if(config_isparamset(cmdline_logparams,CMDLINE_ONLINELOG_IDX)) { - set_glog_onlinelog(online_log_messages); - } - if(config_isparamset(cmdline_logparams,CMDLINE_GLOGLEVEL_IDX)) { - set_glog(glog_level, -1); - } - if(config_isparamset(cmdline_logparams,CMDLINE_GLOGVERBO_IDX)) { - set_glog(-1, glog_verbosity); - } - if (start_telnetsrv) { - load_module_shlib("telnetsrv",NULL,0); - } + config_process_cmdline( cmdline_logparams,sizeof(cmdline_logparams)/sizeof(paramdef_t),NULL); + if(config_isparamset(cmdline_logparams,CMDLINE_ONLINELOG_IDX)) { + set_glog_onlinelog(online_log_messages); + } + if(config_isparamset(cmdline_logparams,CMDLINE_GLOGLEVEL_IDX)) { + set_glog(glog_level, -1); + } + if(config_isparamset(cmdline_logparams,CMDLINE_GLOGVERBO_IDX)) { + set_glog(-1, glog_verbosity); + } + if (start_telnetsrv) { + load_module_shlib("telnetsrv",NULL,0); + } - paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC; - paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC; + paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC; + paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC; - config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL); - config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL); - if (loopfile != NULL) { - printf("Input file for hardware emulation: %s",loopfile); - mode=loop_through_memory; - input_fd = fopen(loopfile,"r"); - AssertFatal(input_fd != NULL,"Please provide a valid input file\n"); - } + config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL); + config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL); + if (loopfile != NULL) { + printf("Input file for hardware emulation: %s",loopfile); + mode=loop_through_memory; + input_fd = fopen(loopfile,"r"); + AssertFatal(input_fd != NULL,"Please provide a valid input file\n"); + } - if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue; - if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXMED_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_med; - if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXBYP_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_byp; - if (cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr) - if ( *(cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr) > 0) mode = debug_prach; - if (cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr) - if ( *(cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr) > 0) mode = no_L2_connect; - if (cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) - if ( *(cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) > 0) mode = calib_prach_tx; + if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue; + if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXMED_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_med; + if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXBYP_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_byp; + if (cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr) + if ( *(cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr) > 0) mode = debug_prach; + if (cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr) + if ( *(cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr) > 0) mode = no_L2_connect; + if (cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) + if ( *(cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) > 0) mode = calib_prach_tx; + if (dumpframe > 0) mode = rx_dump_frame; + + for (CC_id=0; CC_iddl_CarrierFreq = downlink_frequency[0][0]; + } + UE_scan=0; + - if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) && (!(CONFIG_ISFLAGSET(CONFIG_NOOOPT))) ) { - // Here the configuration file is the XER encoded UE capabilities - // Read it in and store in asn1c data structures - sprintf(uecap_xer,"%stargets/PROJECTS/GENERIC-LTE-EPC/CONF/UE_config.xml",getenv("OPENAIR_HOME")); - printf("%s\n",uecap_xer); - uecap_xer_in=1; - } /* UE with config file */ + if (tddflag > 0) { + for (CC_id=0; CC_idframe_type = TDD; + } + /*if (frame_parms[0]->N_RB_DL !=0) { + if ( frame_parms[0]->N_RB_DL < 6 ) { + frame_parms[0]->N_RB_DL = 6; + printf ( "%i: Invalid number of ressource blocks, adjusted to 6\n",frame_parms[0]->N_RB_DL); + } + if ( frame_parms[0]->N_RB_DL > 100 ) { + frame_parms[0]->N_RB_DL = 100; + printf ( "%i: Invalid number of ressource blocks, adjusted to 100\n",frame_parms[0]->N_RB_DL); + } + if ( frame_parms[0]->N_RB_DL > 50 && frame_parms[0]->N_RB_DL < 100 ) { + frame_parms[0]->N_RB_DL = 50; + printf ( "%i: Invalid number of ressource blocks, adjusted to 50\n",frame_parms[0]->N_RB_DL); + } + if ( frame_parms[0]->N_RB_DL > 25 && frame_parms[0]->N_RB_DL < 50 ) { + frame_parms[0]->N_RB_DL = 25; + printf ( "%i: Invalid number of ressource blocks, adjusted to 25\n",frame_parms[0]->N_RB_DL); + } + UE_scan = 0; + frame_parms[0]->N_RB_UL=frame_parms[0]->N_RB_DL; + for (CC_id=1; CC_idN_RB_DL=frame_parms[0]->N_RB_DL; + frame_parms[CC_id]->N_RB_UL=frame_parms[0]->N_RB_UL; + } + }*/ + + + for (CC_id=1;CC_idsubframe_config.numerology_index_mu.value =1; - config->subframe_config.duplex_mode.value = 1; //FDD - config->subframe_config.dl_cyclic_prefix_type.value = 0; //NORMAL - config->rf_config.dl_channel_bandwidth.value = 106; - config->rf_config.ul_channel_bandwidth.value = 106; - config->rf_config.tx_antenna_ports.value = 1; - config->rf_config.rx_antenna_ports.value = 1; - config->sch_config.physical_cell_id.value = 0; - - frame_parms->frame_type = FDD; - frame_parms->tdd_config = 3; - //frame_parms[CC_id]->tdd_config_S = 0; - frame_parms->N_RB_DL = 106; - frame_parms->N_RB_UL = 106; - frame_parms->Ncp = NORMAL; - //frame_parms[CC_id]->Ncp_UL = NORMAL; - frame_parms->Nid_cell = 0; - //frame_parms[CC_id]->num_MBSFN_config = 0; - frame_parms->nb_antenna_ports_eNB = 1; - frame_parms->nb_antennas_tx = 1; - frame_parms->nb_antennas_rx = 1; - - //frame_parms[CC_id]->nushift = 0; - - ///frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth; - //frame_parms[CC_id]->phich_config_common.phich_duration = normal; - // UL RS Config - /*frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = 1;//n_DMRS1 set to 0 - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 1; - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; - frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; - - frame_parms[CC_id]->pusch_config_common.n_SB = 1; - frame_parms[CC_id]->pusch_config_common.hoppingMode = 0; - frame_parms[CC_id]->pusch_config_common.pusch_HoppingOffset = 0; - frame_parms[CC_id]->pusch_config_common.enable64QAM = 0; - - frame_parms[CC_id]->prach_config_common.rootSequenceIndex=22; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0; - frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0;*/ - - // NR: Init to legacy LTE 20Mhz params - frame_parms->numerology_index = 0; - frame_parms->ttis_per_subframe = 1; - frame_parms->slots_per_tti = 2; - - downlink_frequency[0][0] = 2680000000; // Use float to avoid issue with frequency over 2^31. - //downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; - //downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; - //downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; - //printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]); - - //} - -} void init_openair0(void); void init_openair0() { @@ -897,14 +880,11 @@ int main( int argc, char **argv ) { set_latency_target(); - // set default parameters - set_default_frame_parms(frame_parms); - // initialize logging logInit(); // get options and fill parameters from configuration file - get_options (argc, argv); //Command-line options, enb_properties + get_options (); //Command-line options, enb_properties #if T_TRACER T_init(T_port, T_wait, T_dont_fork); @@ -984,7 +964,6 @@ int main( int argc, char **argv ) { LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); - // set_default_frame_parms(frame_parms);// // init the parameters for (CC_id=0; CC_idnb_antenna_ports_eNB = 1; //initial value overwritten by initial sync later LOG_I(PHY,"Set nb_rx_antenna %d , nb_tx_antenna %d \n",frame_parms[CC_id]->nb_antennas_rx, frame_parms[CC_id]->nb_antennas_tx); - - //set_default_frame_parms(config[CC_id],frame_parms[CC_id]); - + //init_ul_hopping(frame_parms[CC_id]); - nr_init_frame_parms_ue(frame_parms[CC_id]); - printf("after init frame_parms %d\n",frame_parms[CC_id]->ofdm_symbol_size); - // phy_init_top(frame_parms[CC_id]); //phy_init_nr_top(frame_parms[CC_id]); } @@ -1067,13 +1041,13 @@ int main( int argc, char **argv ) { if (UE[CC_id]->mac_enabled == 1) { - //UE[CC_id]->pdcch_vars[0][0]->crnti = 0x1234; - //UE[CC_id]->pdcch_vars[1][0]->crnti = 0x1234; + UE[CC_id]->pdcch_vars[0][0]->crnti = 0x1234; + UE[CC_id]->pdcch_vars[1][0]->crnti = 0x1234; } else { - //UE[CC_id]->pdcch_vars[0][0]->crnti = 0x1235; - //UE[CC_id]->pdcch_vars[1][0]->crnti = 0x1235; + UE[CC_id]->pdcch_vars[0][0]->crnti = 0x1235; + UE[CC_id]->pdcch_vars[1][0]->crnti = 0x1235; } rx_gain[CC_id][0] = 81; @@ -1145,7 +1119,7 @@ int main( int argc, char **argv ) { LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity); #endif - openair0_cfg[0].log_level = glog_level; + //openair0_cfg[0].log_level = glog_level; /*int eMBMS_active=0; if (node_function[0] <= NGFI_RAU_IF4p5) { // don't initialize L2 for RRU LOG_I(PHY,"Intializing L2\n"); @@ -1180,6 +1154,9 @@ int main( int argc, char **argv ) { mac_xface->mrbch_phy_sync_failure (0, 0, 0); }*/ + // init UE_PF_PO and mutex lock + pthread_mutex_init(&ue_pf_po_mutex, NULL); + memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*NUMBER_OF_UE_MAX*MAX_NUM_CCs); mlockall(MCL_CURRENT | MCL_FUTURE); From a80f1cf2e73a968980d2efb71bb96be9bf0a747b Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Fri, 7 Sep 2018 17:04:41 +0200 Subject: [PATCH 089/114] ue clean more warnings --- openair1/PHY/INIT/nr_init_ue.c | 11 +++++++---- openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 15 +++++++++------ openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 1 - targets/RT/USER/nr-ue.c | 6 +++--- targets/RT/USER/nr-uesoftmodem.c | 14 +++++++------- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 29869e615b..151a917f23 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -327,6 +327,7 @@ void phy_config_sib13_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id,int mbsfn_Area_ } } + void phy_config_meas_ue(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n_adj_cells,unsigned int *adj_cell_id) { @@ -344,6 +345,7 @@ void phy_config_meas_ue(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index,uint8_t n memcpy((void*)phy_meas->adj_cell_id,(void *)adj_cell_id,n_adj_cells*sizeof(unsigned int)); } +*/ #if defined(Rel10) || defined(Rel14) void phy_config_dedicated_scell_ue(uint8_t Mod_id, @@ -355,17 +357,17 @@ void phy_config_dedicated_scell_ue(uint8_t Mod_id, } #endif - void phy_config_harq_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, uint16_t max_harq_tx ) { - PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id]; + PHY_VARS_NR_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id]; phy_vars_ue->ulsch[eNB_id]->Mlimit = max_harq_tx; } extern uint16_t beta_cqi[16]; +/* void phy_config_dedicated_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, struct PhysicalConfigDedicated *physicalConfigDedicated ) { @@ -908,8 +910,9 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, return 0; } + /* -void nr_lte_ue_transport(PHY_VARS_UE *ue,int abstraction_flag) { +void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag) { int i,j,k; @@ -930,7 +933,7 @@ void nr_lte_ue_transport(PHY_VARS_UE *ue,int abstraction_flag) { ue->transmission_mode[i] = ue->frame_parms.nb_antenna_ports_eNB==1 ? 1 : 2; } - ue->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1; + //ue->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1; ue->dlsch_MCH[0] = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS_MBSFN,ue->frame_parms.N_RB_DL,0); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index e5ac340cce..095832128c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -150,12 +150,12 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; int ret=-1; - int aarx,rx_power=0; + int rx_power=0; //aarx, //nfapi_nr_config_request_t* config; /*offset parameters to be updated from higher layer */ - k_ssb =0; - N_ssb_crb = 0; + //k_ssb =0; + //N_ssb_crb = 0; /*#ifdef OAI_USRP __m128i *rxdata128; @@ -226,9 +226,12 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) ret = nr_pbch_detection(ue,mode); nr_gold_pdcch(ue,0, 2); - nr_slot_fep(ue,0, 0, ue->rx_offset, 1, 1, NR_PDCCH_EST); - nr_slot_fep(ue,1, 0, ue->rx_offset, 1, 1, NR_PDCCH_EST); - + int nb_prefix_samples0 = frame_parms->nb_prefix_samples0; + frame_parms->nb_prefix_samples0 = 0; + + nr_slot_fep(ue,0, 0, ue->rx_offset, 0, 1, NR_PDCCH_EST); + nr_slot_fep(ue,1, 0, ue->rx_offset, 0, 1, NR_PDCCH_EST); + frame_parms->nb_prefix_samples0 = nb_prefix_samples0; LOG_I(PHY,"[UE %d] AUTOTEST Cell Sync : frame = %d, rx_offset %d, freq_offset %d \n", ue->Mod_id, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 6ce7718199..337b6d8e33 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -394,7 +394,6 @@ void nr_pbch_unscrambling(NR_UE_PBCH *pbch, uint16_t length, uint8_t bitwise) { - int i; uint8_t reset, offset; uint32_t x1, x2, s=0; double *demod_pbch_e = pbch->demod_pbch_e; diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index fc8d44a236..04da3067c2 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -64,8 +64,8 @@ #include "T.h" extern double cpuf; -static nfapi_nr_config_request_t config_t; -static nfapi_nr_config_request_t* config =&config_t; +//static nfapi_nr_config_request_t config_t; +//static nfapi_nr_config_request_t* config =&config_t; /* * NR SLOT PROCESSING SEQUENCE @@ -810,7 +810,7 @@ void *UE_thread(void *arg) { PHY_VARS_NR_UE *UE = (PHY_VARS_NR_UE *) arg; // int tx_enabled = 0; int dummy_rx[UE->frame_parms.nb_antennas_rx][UE->frame_parms.samples_per_tti] __attribute__((aligned(32))); - openair0_timestamp timestamp,timestamp1; + openair0_timestamp timestamp; void* rxp[NB_ANTENNAS_RX], *txp[NB_ANTENNAS_TX]; int start_rx_stream = 0; int i; diff --git a/targets/RT/USER/nr-uesoftmodem.c b/targets/RT/USER/nr-uesoftmodem.c index 635fe524e3..54d169a171 100644 --- a/targets/RT/USER/nr-uesoftmodem.c +++ b/targets/RT/USER/nr-uesoftmodem.c @@ -1169,13 +1169,13 @@ int main( int argc, char **argv ) { if (do_forms==1) { fl_initialize (&argc, argv, NULL, 0, 0); - - //form_stats = create_form_stats_form(); - //fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); - UE_id = 0; - form_ue[UE_id] = create_lte_phy_scope_ue(); - sprintf (title, "LTE DL SCOPE UE"); - fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); + + form_stats = create_form_stats_form(); + fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); + UE_id = 0; + form_ue[UE_id] = create_lte_phy_scope_ue(); + sprintf (title, "NR DL SCOPE UE"); + fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); /* if (openair_daq_vars.use_ia_receiver) { From ce0b62668412bea67cde9eba6d3edbfe5d8881e4 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Mon, 10 Sep 2018 11:42:20 +0200 Subject: [PATCH 090/114] PBCH bitfield changes --- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 22 +++++++++++----------- openair1/PHY/NR_TRANSPORT/nr_transport.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 0784d9ca9d..5964a55569 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -136,7 +136,7 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, uint8_t nushift, uint16_t M, uint16_t length, - uint8_t bitwise) + uint8_t encoded) { uint8_t reset, offset; uint32_t x1, x2, s=0; @@ -168,12 +168,12 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, #ifdef DEBUG_PBCH_ENCODING printf("s: %04x\t", s); #endif - if (bitwise) { + if (!encoded) { (*pbch_a_prime) ^= ((unscrambling_mask>>i)&1)? (((*pbch_a_interleaved)>>i)&1)<>i)&1) ^ ((s>>((i+offset)&0x1f))&1))<>((i+offset)&0x1f))&1); + pbch_e[i>>5] ^= (((s>>((i+offset)&0x1f))&1)<<(i&0x1f)); } } @@ -276,7 +276,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, // Scrambling M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3); nushift = (((sfn>>2)&1)<<1) ^ ((sfn>>1)&1); - nr_pbch_scrambling(pbch, (uint32_t)config->sch_config.physical_cell_id.value, nushift, M, NR_POLAR_PBCH_PAYLOAD_BITS, 1); + nr_pbch_scrambling(pbch, (uint32_t)config->sch_config.physical_cell_id.value, nushift, M, NR_POLAR_PBCH_PAYLOAD_BITS, 0); #ifdef DEBUG_PBCH_ENCODING printf("Payload scrambling:\n"); for (int i=0; i<4; i++) @@ -284,7 +284,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, #endif for (int m=0;m<32;m++){ -pbch_a_b[m] = ((pbch->pbch_a_prime[m/8]>>(m&7))&01); +pbch_a_b[m] = ((pbch->pbch_a_prime[m>>3]>>(m&7))&1); //printf("pbch_a_b[%d] %d\n", m, pbch_a_b[m] ); } @@ -292,25 +292,25 @@ pbch_a_b[m] = ((pbch->pbch_a_prime[m/8]>>(m&7))&01); polar_encoder (pbch->pbch_a_prime, pbch->pbch_e, polar_params); #ifdef DEBUG_PBCH_ENCODING printf("Channel coding:\n"); - for (int i=0; i>3; i++) - printf("pbch_e[%d]: 0x%02x\t", i, pbch->pbch_e[i]); + for (int i=0; i<(uint16_t)ceil((NR_POLAR_PBCH_E>>3)/32); i++) + printf("pbch_e[%d]: 0x%08x\t", i, pbch->pbch_e[i]); printf("\n"); #endif /// Scrambling M = NR_POLAR_PBCH_E; nushift = (Lmax==4)? ssb_index&3 : ssb_index&7; - nr_pbch_scrambling(pbch, (uint32_t)config->sch_config.physical_cell_id.value, nushift, M, NR_POLAR_PBCH_E, 0); + nr_pbch_scrambling(pbch, (uint32_t)config->sch_config.physical_cell_id.value, nushift, M, NR_POLAR_PBCH_E, 1); #ifdef DEBUG_PBCH_ENCODING printf("Scrambling:\n"); - for (int i=0; i>3; i++) - printf("pbch_e[%d]: 0x%02x\t", i, pbch->pbch_e[i]); + for (int i=0; i<(uint16_t)ceil((NR_POLAR_PBCH_E>>3)/32); i++) + printf("pbch_e[%d]: 0x%08x\t", i, pbch->pbch_e[i]); printf("\n"); #endif /// QPSK modulation for (int i=0; i>1; i++){ - idx = ((pbch->pbch_e[i<<1]&1)<<1) ^ (pbch->pbch_e[(i<<1)+1]&1); + idx = (((pbch->pbch_e[(i<<1)>>5]>>((i<<1)&0x1f))&1)<<1) ^ ((pbch->pbch_e[((i<<1)+1)>>5]>>(((i<<1)+1)&0x1f))&1); mod_pbch_e[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1]; mod_pbch_e[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1)+1]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport.h b/openair1/PHY/NR_TRANSPORT/nr_transport.h index e60bb0628c..a051d776bd 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport.h @@ -75,7 +75,7 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, uint8_t nushift, uint16_t M, uint16_t length, - uint8_t bitwise); + uint8_t encoded); /*! \fn int nr_generate_pbch From 753d4b70b65bd7b3a5660f3279155f898f49ec03 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Mon, 10 Sep 2018 13:44:44 +0200 Subject: [PATCH 091/114] Minor debug changes --- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 5964a55569..f46685447c 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -283,16 +283,16 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, printf("pbch_a_prime[%d]: 0x%02x\n", i, pbch->pbch_a_prime[i]); #endif -for (int m=0;m<32;m++){ +/*for (int m=0;m<32;m++){ pbch_a_b[m] = ((pbch->pbch_a_prime[m>>3]>>(m&7))&1); //printf("pbch_a_b[%d] %d\n", m, pbch_a_b[m] ); -} +}*/ /// CRC, coding and rate matching polar_encoder (pbch->pbch_a_prime, pbch->pbch_e, polar_params); #ifdef DEBUG_PBCH_ENCODING printf("Channel coding:\n"); - for (int i=0; i<(uint16_t)ceil((NR_POLAR_PBCH_E>>3)/32); i++) + for (int i=0; i>5; i++) printf("pbch_e[%d]: 0x%08x\t", i, pbch->pbch_e[i]); printf("\n"); #endif @@ -303,7 +303,7 @@ pbch_a_b[m] = ((pbch->pbch_a_prime[m>>3]>>(m&7))&1); nr_pbch_scrambling(pbch, (uint32_t)config->sch_config.physical_cell_id.value, nushift, M, NR_POLAR_PBCH_E, 1); #ifdef DEBUG_PBCH_ENCODING printf("Scrambling:\n"); - for (int i=0; i<(uint16_t)ceil((NR_POLAR_PBCH_E>>3)/32); i++) + for (int i=0; i>5; i++) printf("pbch_e[%d]: 0x%08x\t", i, pbch->pbch_e[i]); printf("\n"); #endif From cfcd0d4baec34a48223b0693bb6e4e6d3dad65f5 Mon Sep 17 00:00:00 2001 From: Agustin Date: Fri, 14 Sep 2018 14:56:15 +0200 Subject: [PATCH 092/114] NR PDCCH: dci field interpreting in FAPI / Adding DCI format 0_1 and 1_1 --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 26 +- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 878 +++++++++++------- openair1/PHY/NR_UE_TRANSPORT/dci_nr.h | 6 +- openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c | 175 +++- .../PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 4 + openair1/PHY/defs_nr_UE.h | 18 +- openair1/PHY/impl_defs_nr.h | 274 +++++- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 37 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 588 ++++++++++-- 9 files changed, 1537 insertions(+), 469 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 7219477405..d6fafae7f1 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -37,8 +37,8 @@ typedef struct { uint8_t sul_ind_0_1 ; // 2 SUL_IND_0_1: uint8_t slot_format_ind ; // 3 SLOT_FORMAT_IND: size of DCI format 2_0 is configurable by higher layers up to 128 bits, according to Subclause 11.1.1 of [5, TS 38.213] uint8_t pre_emption_ind ; // 4 PRE_EMPTION_IND: size of DCI format 2_1 is configurable by higher layers up to 126 bits, according to Subclause 11.2 of [5, TS 38.213]. Each pre-emption indication is 14 bits - uint8_t tpc_cmd_number ; // 5 TPC_CMD_NUMBER: The parameter xxx provided by higher layers determines the index to the TPC command number for an UL of a cell. Each TPC command number is 2 bits - uint8_t block_number ; // 6 BLOCK_NUMBER: starting position of a block is determined by the parameter startingBitOfFormat2_3 + uint8_t block_number ; // 5 BLOCK_NUMBER: starting position of a block is determined by the parameter startingBitOfFormat2_3 + uint8_t close_loop_ind ; // 6 CLOSE_LOOP_IND: uint8_t bandwidth_part_ind ; // 7 BANDWIDTH_PART_IND: uint8_t short_message_ind ; // 8 SHORT_MESSAGE_IND: uint8_t short_messages ; // 9 SHORT_MESSAGES: @@ -81,7 +81,7 @@ typedef struct { uint8_t antenna_ports ; // 38 ANTENNA_PORTS: uint8_t tci ; // 39 TCI: 0 bit if higher layer parameter tci-PresentInDCI is not enabled; otherwise 3 bits uint8_t srs_request ; // 40 SRS_REQUEST: - uint8_t tpc_cmd_number_format2_3 ; // 41 TPC_CMD_NUMBER_FORMAT2_3: + uint8_t tpc_cmd ; // 41 TPC_CMD: uint8_t csi_request ; // 42 CSI_REQUEST: uint8_t cbgti ; // 43 CBGTI: 0, 2, 4, 6, or 8 bits determined by higher layer parameter maxCodeBlockGroupsPerTransportBlock for the PDSCH uint8_t cbgfi ; // 44 CBGFI: 0 or 1 bit determined by higher layer parameter codeBlockGroupFlushIndicator @@ -225,13 +225,19 @@ typedef struct { typedef struct { } fapi_nr_ul_config_pucch_pdu; - + typedef enum {pusch_freq_hopping_disabled = 0 , pusch_freq_hopping_enabled = 1}pusch_freq_hopping_t; typedef struct { uint16_t number_rbs; uint16_t start_rb; uint16_t number_symbols; uint16_t start_symbol; + pusch_freq_hopping_t pusch_freq_hopping; uint8_t mcs; + uint8_t ndi; + uint8_t rv; + uint8_t harq_process_nbr; + int8_t accumulated_delta_PUSCH; + int8_t absolute_delta_PUSCH; } fapi_nr_ul_config_pusch_pdu_rel15_t; typedef struct { @@ -273,6 +279,7 @@ typedef struct { fapi_nr_dl_config_dci_dl_pdu_rel15_t dci_config_rel15; } fapi_nr_dl_config_dci_pdu; + typedef enum{vrb_to_prb_mapping_non_interleaved = 0, vrb_to_prb_mapping_interleaved = 1} vrb_to_prb_mapping_t; //typedef fapi_nr_dci_pdu_rel15_t fapi_nr_dl_config_dlsch_pdu_rel15_t; typedef struct { uint16_t number_rbs; @@ -280,7 +287,18 @@ typedef struct { uint16_t number_symbols; uint16_t start_symbol; uint8_t mcs; + uint8_t ndi; uint8_t rv; + uint8_t tb2_mcs; + uint8_t tb2_ndi; + uint8_t tb2_rv; + uint8_t harq_process_nbr; + vrb_to_prb_mapping_t vrb_to_prb_mapping; + uint8_t dai; + double scaling_factor_S; + int8_t accumulated_delta_PUCCH; + uint8_t pucch_resource_id; + uint8_t pdsch_to_harq_feedback_time_ind; // to be check the fields needed to L1 with NR_DL_UE_HARQ_t and NR_UE_DLSCH_t } fapi_nr_dl_config_dlsch_pdu_rel15_t; diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index a13875ef9c..41e3f01691 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -4088,13 +4088,13 @@ void nr_dci_decoding_procedure0(int s, #endif int reg_p,reg_e; for (int m=0; m < (L2*6); m++){ - reg_p = (((int)floor(m/coreset_time_dur))+((m%coreset_time_dur)*(L2*6/coreset_time_dur)))*9*2; - reg_e = m*9*2; - for (int i=0; i<9*2; i++){ - polar_input[reg_p+i] = (pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]>0) ? (1.0):(-1.0); - printf("\t m=%d \tpolar_input[%d]=%lf <-> e_rx[%d]=%d\n",m,reg_p+i,polar_input[reg_p+i], - ((CCEind*9*6*2) + reg_e + i),pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]); - } + reg_p = (((int)floor(m/coreset_time_dur))+((m%coreset_time_dur)*(L2*6/coreset_time_dur)))*9*2; + reg_e = m*9*2; + for (int i=0; i<9*2; i++){ + polar_input[reg_p+i] = (pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]>0) ? (1.0):(-1.0); + printf("\t m=%d \tpolar_input[%d]=%lf <-> e_rx[%d]=%d\n",m,reg_p+i,polar_input[reg_p+i], + ((CCEind*9*6*2) + reg_e + i),pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]); + } } #ifdef NR_PDCCH_DCI_DEBUG @@ -4247,12 +4247,12 @@ void nr_dci_decoding_procedure0(int s, *dci_cnt = *dci_cnt + 1; format_found=_format_1_0_found; } else { - if ((dci_decoded_output[current_thread_id][7]>>(sizeof_bits-1))&1 == 0){ + if (dci_decoded_output[current_thread_id][0]&1 == 0){ dci_alloc[*dci_cnt].format = format0_0; *dci_cnt = *dci_cnt + 1; format_found=_format_0_0_found; } - if ((dci_decoded_output[current_thread_id][7]>>(sizeof_bits-1))&1 == 1){ + if (dci_decoded_output[current_thread_id][0]&1 == 1){ dci_alloc[*dci_cnt].format = format1_0; *dci_cnt = *dci_cnt + 1; format_found=_format_1_0_found; @@ -4276,7 +4276,16 @@ void nr_dci_decoding_procedure0(int s, *dci_cnt = *dci_cnt + 1; } if (format_uss == uformat0_1_and_1_1){ - // Not implemented yet FIXME + if (dci_decoded_output[current_thread_id][0]&1 == 0){ + dci_alloc[*dci_cnt].format = format0_1; + *dci_cnt = *dci_cnt + 1; + format_found=_format_0_1_found; + } + if (dci_decoded_output[current_thread_id][0]&1 == 1){ + dci_alloc[*dci_cnt].format = format1_1; + *dci_cnt = *dci_cnt + 1; + format_found=_format_1_1_found; + } } // store first nCCE of group for PUCCH transmission of ACK/NAK pdcch_vars[eNB_id]->nCCE[nr_tti_rx] = CCEind; @@ -4816,123 +4825,348 @@ uint16_t dci_CRNTI_decoding_procedure(PHY_VARS_NR_UE *ue, #ifdef NR_PDCCH_DCI_RUN -uint16_t nr_dci_format_size (crc_scrambled_t crc_scrambled, - uint8_t pusch_alloc_list, +uint16_t nr_dci_format_size (PHY_VARS_NR_UE *ue, + uint16_t eNB_id, + uint8_t nr_tti_rx, + int p, + crc_scrambled_t crc_scrambled, uint16_t n_RB_ULBWP, uint16_t n_RB_DLBWP, - uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS]){ + uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS], + uint8_t format){ #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_format_size)-> crc_scrambled=%d, pusch_alloc_list=%d, n_RB_ULBWP=%d, n_RB_DLBWP=%d\n",crc_scrambled,pusch_alloc_list,n_RB_ULBWP,n_RB_DLBWP); + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_format_size)-> crc_scrambled=%d, n_RB_ULBWP=%d, n_RB_DLBWP=%d\n",crc_scrambled,n_RB_ULBWP,n_RB_DLBWP); #endif /* - * Formats 0_1, not completely implemented. See (*) + * function nr_dci_format_size calculates and returns the size in bits of a determined format + * it also returns an bi-dimensional array 'dci_fields_sizes' with x rows and y columns, where: + * x is the number of fields defined in TS 38.212 subclause 7.3.1 (Each field is mapped in the order in which it appears in the description in the specification) + * y is the number of formats + * e.g.: dci_fields_sizes[10][0] contains the size in bits of the field FREQ_DOM_RESOURCE_ASSIGNMENT_UL for format 0_0 */ -// format {0_0,0_1,1_0,1_1,2_0,2_1,2_2,2_3} according to 38.212 Section 7.3.1 -/* -#define NBR_NR_FORMATS 8 -#define NBR_NR_DCI_FIELDS 56 -#define IDENTIFIER_DCI_FORMATS 0 -#define CARRIER_IND 1 -#define SUL_IND_0_1 2 -#define SLOT_FORMAT_IND 3 -#define PRE_EMPTION_IND 4 -#define TPC_CMD_NUMBER 5 -#define BLOCK_NUMBER 6 -#define BANDWIDTH_PART_IND 7 -#define SHORT_MESSAGE_IND 8 -#define SHORT_MESSAGES 9 -#define FREQ_DOM_RESOURCE_ASSIGNMENT_UL 10 -#define FREQ_DOM_RESOURCE_ASSIGNMENT_DL 11 -#define TIME_DOM_RESOURCE_ASSIGNMENT 12 -#define VRB_TO_PRB_MAPPING 13 -#define PRB_BUNDLING_SIZE_IND 14 -#define RATE_MATCHING_IND 15 -#define ZP_CSI_RS_TRIGGER 16 -#define FREQ_HOPPING_FLAG 17 -#define TB1_MCS 18 -#define TB1_NDI 19 -#define TB1_RV 20 -#define TB2_MCS 21 -#define TB2_NDI 22 -#define TB2_RV 23 -#define MCS 24 -#define NDI 25 -#define RV 26 -#define HARQ_PROCESS_NUMBER 27 -#define DAI_ 28 -#define FIRST_DAI 29 -#define SECOND_DAI 30 -#define TB_SCALING 31 -#define TPC_PUSCH 32 -#define TPC_PUCCH 33 -#define PUCCH_RESOURCE_IND 34 -#define PDSCH_TO_HARQ_FEEDBACK_TIME_IND 35 -//#define SHORT_MESSAGE_IND 33 -#define SRS_RESOURCE_IND 36 -#define PRECOD_NBR_LAYERS 37 -#define ANTENNA_PORTS 38 -#define TCI 39 -#define SRS_REQUEST 40 -#define TPC_CMD_NUMBER_FORMAT2_3 41 -#define CSI_REQUEST 42 -#define CBGTI 43 -#define CBGFI 44 -#define PTRS_DMRS 45 -#define BETA_OFFSET_IND 46 -#define DMRS_SEQ_INI 47 -#define UL_SCH_IND 48 -#define PADDING_NR_DCI 49 -#define SUL_IND_0_0 50 -#define RA_PREAMBLE_INDEX 51 -#define SUL_IND_1_0 52 -#define SS_PBCH_INDEX 53 -#define PRACH_MASK_INDEX 54 -#define RESERVED_NR_DCI 55 -*/ - //uint8_t pusch_alloc_list=1; - // number of ZP CSI-RS resource sets in the higher layer parameter [ZP-CSI-RS-ResourceConfigList] - uint8_t n_zp = 1; - uint8_t n_SRS=1; + // pdsch_config contains the PDSCH-Config IE is used to configure the UE specific PDSCH parameters (TS 38.331) + PDSCH_Config_t pdsch_config = ue->PDSCH_Config; + // pusch_config contains the PUSCH-Config IE is used to configure the UE specific PUSCH parameters (TS 38.331) + PUSCH_Config_t pusch_config = ue->pusch_config; + PUCCH_Config_t pucch_config_dedicated = ue->pucch_config_dedicated_nr[eNB_id]; + crossCarrierSchedulingConfig_t crossCarrierSchedulingConfig = ue->crossCarrierSchedulingConfig; + dmrs_UplinkConfig_t dmrs_UplinkConfig = ue->dmrs_UplinkConfig; + dmrs_DownlinkConfig_t dmrs_DownlinkConfig = ue->dmrs_DownlinkConfig; + csi_MeasConfig_t csi_MeasConfig = ue->csi_MeasConfig; + PUSCH_ServingCellConfig_t PUSCH_ServingCellConfig= ue->PUSCH_ServingCellConfig; + PDSCH_ServingCellConfig_t PDSCH_ServingCellConfig= ue->PDSCH_ServingCellConfig; + NR_UE_PDCCH *pdcch_vars2 = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]; + +// 1 CARRIER_IN + // crossCarrierSchedulingConfig from higher layers, variable crossCarrierSchedulingConfig indicates if 'cross carrier scheduling' is enabled or not: + // if No cross carrier scheduling: number of bits for CARRIER_IND is 0 + // if Cross carrier scheduling: number of bits for CARRIER_IND is 3 + // The IE CrossCarrierSchedulingConfig is used to specify the configuration when the cross-carrier scheduling is used in a cell + uint8_t crossCarrierSchedulingConfig_ind = 0; + if (crossCarrierSchedulingConfig.schedulingCellInfo.other.cif_InSchedulingCell !=0 ) crossCarrierSchedulingConfig_ind=1; + + +// 2 SUL_IND_0_1, // 40 SRS_REQUEST, // 50 SUL_IND_0_0 + // UL/SUL indicator (TS 38.331, supplementary uplink is indicated in higher layer parameter ServCellAdd-SUL from IE ServingCellConfig and ServingCellConfigCommon): + // 0 bit for UEs not configured with SUL in the cell or UEs configured with SUL in the cell but only PUCCH carrier in the cell is configured for PUSCH transmission + // 1 bit for UEs configured with SUL in the cell as defined in Table 7.3.1.1.1-1 + // sul_ind indicates whether SUL is configured in cell or not + uint8_t sul_ind=ue->supplementaryUplink.supplementaryUplink; // this value will be 0 or 1 depending on higher layer parameter ServCellAdd-SUL. FIXME!!! + +// 7 BANDWIDTH_PART_IND + // number of UL BWPs configured by higher layers + uint8_t n_UL_BWP_RRC=1; // initialized to 1 but it has to be initialized by higher layers FIXME!!! + (n_UL_BWP_RRC > 3)?n_UL_BWP_RRC:(n_UL_BWP_RRC+1); + // number of DL BWPs configured by higher layers + uint8_t n_DL_BWP_RRC=1; // initialized to 1 but it has to be initialized by higher layers FIXME!!! + (n_DL_BWP_RRC > 3)?n_DL_BWP_RRC:(n_DL_BWP_RRC+1); + + +// 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL + // if format0_0, only resource allocation type 1 is allowed + // if format0_1, then resource allocation type 0 can be configured and N_RBG is defined in TS 38.214 subclause 6.1.2.2.1 + // for PUSCH hopping with resource allocation type 1 // n_UL_hopping = 1 if the higher layer parameter frequencyHoppingOffsetLists contains two offset values // n_UL_hopping = 2 if the higher layer parameter frequencyHoppingOffsetLists contains four offset values - uint8_t n_UL_hopping=0; + uint8_t n_UL_hopping=pusch_config.n_frequencyHoppingOffsetLists; + if (n_UL_hopping == 2) { + n_UL_hopping = 1; + } else if (n_UL_hopping == 4) { + n_UL_hopping = 2; + } else { + n_UL_hopping = 0; + } + ul_resourceAllocation_t ul_resource_allocation_type = pusch_config.ul_resourceAllocation; + uint8_t ul_res_alloc_type_0 = 0; + uint8_t ul_res_alloc_type_1 = 0; + if (ul_resource_allocation_type == ul_resourceAllocationType0) ul_res_alloc_type_0 = 1; + if (ul_resource_allocation_type == ul_resourceAllocationType1) ul_res_alloc_type_1 = 1; + if (ul_resource_allocation_type == ul_dynamicSwitch) { + ul_res_alloc_type_0 = 1; + ul_res_alloc_type_1 = 1; + } + uint8_t n_bits_freq_dom_res_assign_ul,n_ul_RGB_tmp; + if (ul_res_alloc_type_0 == 1){ // implementation of Table 6.1.2.2.1-1 TC 38.214 subclause 6.1.2.2.1 + // config1: PUSCH-Config IE contains rbg-Size ENUMERATED {config1 config2} + ul_rgb_Size_t config = pusch_config.ul_rgbSize; + uint8_t nominal_RBG_P = (config==ul_rgb_config1?2:4); + if (n_RB_ULBWP > 36) nominal_RBG_P = (config==ul_rgb_config1?4:8); + if (n_RB_ULBWP > 72) nominal_RBG_P = (config==ul_rgb_config1?8:16); + if (n_RB_ULBWP > 144) nominal_RBG_P = 16; + n_bits_freq_dom_res_assign_ul = (uint8_t)ceil((n_RB_ULBWP+(0%nominal_RBG_P))/nominal_RBG_P); //FIXME!!! what is 0??? + n_ul_RGB_tmp = n_bits_freq_dom_res_assign_ul; + } + if (ul_res_alloc_type_1 == 1) n_bits_freq_dom_res_assign_ul = (uint8_t)(ceil(log2(n_RB_ULBWP*(n_RB_ULBWP+1)/2)))-n_UL_hopping; + if ((ul_res_alloc_type_0 == 1) && (ul_res_alloc_type_1 == 1)) + n_bits_freq_dom_res_assign_ul = ((n_bits_freq_dom_res_assign_ul>n_ul_RGB_tmp)?(n_bits_freq_dom_res_assign_ul+1):(n_ul_RGB_tmp+1)); + +// 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL + // if format1_0, only resource allocation type 1 is allowed + // if format1_1, then resource allocation type 0 can be configured and N_RBG is defined in TS 38.214 subclause 5.1.2.2.1 + dl_resourceAllocation_t dl_resource_allocation_type = pdsch_config.dl_resourceAllocation; + uint8_t dl_res_alloc_type_0 = 0; + uint8_t dl_res_alloc_type_1 = 0; + if (dl_resource_allocation_type == dl_resourceAllocationType0) dl_res_alloc_type_0 = 1; + if (dl_resource_allocation_type == dl_resourceAllocationType1) dl_res_alloc_type_1 = 1; + if (dl_resource_allocation_type == dl_dynamicSwitch) { + dl_res_alloc_type_0 = 1; + dl_res_alloc_type_1 = 1; + } + uint8_t n_bits_freq_dom_res_assign_dl,n_dl_RGB_tmp; + if (dl_res_alloc_type_0 == 1){ // implementation of Table 5.1.2.2.1-1 TC 38.214 subclause 6.1.2.2.1 + // config1: PDSCH-Config IE contains rbg-Size ENUMERATED {config1, config2} + dl_rgb_Size_t config = pdsch_config.dl_rgbSize; + uint8_t nominal_RBG_P = (config==dl_rgb_config1?2:4); + if (n_RB_DLBWP > 36) nominal_RBG_P = (config==dl_rgb_config1?4:8); + if (n_RB_DLBWP > 72) nominal_RBG_P = (config==dl_rgb_config1?8:16); + if (n_RB_DLBWP > 144) nominal_RBG_P = 16; + n_bits_freq_dom_res_assign_dl = (uint8_t)ceil((n_RB_DLBWP+(0%nominal_RBG_P))/nominal_RBG_P); //FIXME!!! what is 0??? + n_dl_RGB_tmp = n_bits_freq_dom_res_assign_dl; + } + if (dl_res_alloc_type_1 == 1) n_bits_freq_dom_res_assign_dl = (uint8_t)(ceil(log2(n_RB_DLBWP*(n_RB_DLBWP+1)/2))); + if ((dl_res_alloc_type_0 == 1) && (dl_res_alloc_type_1 == 1)) + n_bits_freq_dom_res_assign_dl = ((n_bits_freq_dom_res_assign_dl>n_dl_RGB_tmp)?(n_bits_freq_dom_res_assign_dl+1):(n_dl_RGB_tmp+1)); + +// 12 TIME_DOM_RESOURCE_ASSIGNMENT + uint8_t pusch_alloc_list = pusch_config.n_push_alloc_list; + uint8_t pdsch_alloc_list = pdsch_config.n_pdsh_alloc_list; + +// 14 PRB_BUNDLING_SIZE_IND:0 bit if the higher layer parameter PRB_bundling is not configured or is set to 'static', or 1 bit if the higher layer parameter PRB_bundling is set to 'dynamic' according to Subclause 5.1.2.3 of [6, TS 38.214] + static_bundleSize_t static_prb_BundlingType = pdsch_config.prbBundleType.staticBundling; + bundleSizeSet1_t dynamic_prb_BundlingType1 = pdsch_config.prbBundleType.dynamicBundlig.bundleSizeSet1; + bundleSizeSet2_t dynamic_prb_BundlingType2 = pdsch_config.prbBundleType.dynamicBundlig.bundleSizeSet2; + uint8_t prb_BundlingType_size=0; + if ((static_prb_BundlingType==st_n4)||(static_prb_BundlingType==st_wideband)) prb_BundlingType_size=0; + if ((dynamic_prb_BundlingType1==dy_1_n4)||(dynamic_prb_BundlingType1==dy_1_wideband)||(dynamic_prb_BundlingType1==dy_1_n2_wideband)||(dynamic_prb_BundlingType1==dy_1_n4_wideband)|| + (dynamic_prb_BundlingType2==dy_2_n4)||(dynamic_prb_BundlingType2==dy_2_wideband)) prb_BundlingType_size=1; + +// 15 RATE_MATCHING_IND FIXME!!! + // according to TS 38.212: Rate matching indicator – 0, 1, or 2 bits according to higher layer parameter rateMatchPattern + uint8_t rateMatching_bits = pdsch_config.n_rateMatchPatterns; +// 16 ZP_CSI_RS_TRIGGER FIXME!!! + // 0, 1, or 2 bits as defined in Subclause 5.1.4.2 of [6, TS 38.214]. + // is the number of ZP CSI-RS resource sets in the higher layer parameter zp-CSI-RS-Resource + uint8_t n_zp_bits = pdsch_config.n_zp_CSI_RS_ResourceId; + +// 17 FREQ_HOPPING_FLAG + // freqHopping is defined by higher layer parameter frequencyHopping from IE PUSCH-Config. Values are ENUMERATED{mode1, mode2} + frequencyHopping_t f_hopping = pusch_config.frequencyHopping; + uint8_t freqHopping = 0; + if ((f_hopping==f_hop_mode1)||(f_hopping==f_hop_mode2)) freqHopping = 1; + +// 28 DAI + pdsch_HARQ_ACK_Codebook_t pdsch_HARQ_ACK_Codebook = pdsch_config.pdsch_HARQ_ACK_Codebook; + uint8_t n_dai = 0; + uint8_t n_serving_cell_dl = 1; // this is hardcoded to 1 as we need to get this value from RRC higher layers parameters. FIXME!!! + if ((pdsch_HARQ_ACK_Codebook == dynamic) && (n_serving_cell_dl == 1)) n_dai = 2; + if ((pdsch_HARQ_ACK_Codebook == dynamic) && (n_serving_cell_dl > 1)) n_dai = 4; + +// 29 FIRST_DAI + uint8_t codebook_HARQ_ACK = 0; // We need to get this value to calculate number of bits of fields 1st DAI and 2nd DAI. + if (pdsch_HARQ_ACK_Codebook == semiStatic) codebook_HARQ_ACK = 1; + if (pdsch_HARQ_ACK_Codebook == dynamic) codebook_HARQ_ACK = 2; + +// 30 SECOND_DAI + uint8_t n_HARQ_ACK_sub_codebooks = 0; // We need to get this value to calculate number of bits of fields 1st DAI and 2nd DAI. FIXME!!! + +// 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND + uint8_t pdsch_harq_t_ind = (uint8_t)ceil(log2(pucch_config_dedicated.dl_DataToUL_ACK[0])); + +// 36 SRS_RESOURCE_IND + // n_SRS is the number of configured SRS resources in the SRS resource set associated with the higher layer parameter usage of value 'codeBook' or 'nonCodeBook' + // from SRS_ResourceSet_t type we should get the information of the usage parameter (with possible values beamManagement, codebook, nonCodebook, antennaSwitching) + // at frame_parms->srs_nr->p_SRS_ResourceSetList[]->usage + uint8_t n_SRS = ue->srs.number_srs_Resource_Set; + +// 37 PRECOD_NBR_LAYERS +// 38 ANTENNA_PORTS + txConfig_t txConfig = pusch_config.txConfig; + transformPrecoder_t transformPrecoder = pusch_config.transformPrecoder; + codebookSubset_t codebookSubset = pusch_config.codebookSubset; + uint8_t maxRank = pusch_config.maxRank; + uint8_t num_antenna_ports = 1; // this is hardcoded. We need to get the real value FIXME!!! + uint8_t precond_nbr_layers_bits = 0; + uint8_t antenna_ports_bits_ul = 0; + // searching number of bits at tables 7.3.1.1.2-2/3/4/5 from TS 38.212 subclause 7.3.1.1.2 + if (txConfig == txConfig_codebook){ + if (num_antenna_ports == 4) { + if ((transformPrecoder == transformPrecoder_disabled) && ((maxRank == 2)||(maxRank == 3)||(maxRank == 4))) { // Table 7.3.1.1.2-2 + if (codebookSubset == codebookSubset_fullyAndPartialAndNonCoherent) precond_nbr_layers_bits=6; + if (codebookSubset == codebookSubset_partialAndNonCoherent) precond_nbr_layers_bits=5; + if (codebookSubset == codebookSubset_nonCoherent) precond_nbr_layers_bits=4; + } + if (((transformPrecoder == transformPrecoder_enabled)||(transformPrecoder == transformPrecoder_disabled)) && (maxRank == 1)) { // Table 7.3.1.1.2-3 + if (codebookSubset == codebookSubset_fullyAndPartialAndNonCoherent) precond_nbr_layers_bits=5; + if (codebookSubset == codebookSubset_partialAndNonCoherent) precond_nbr_layers_bits=4; + if (codebookSubset == codebookSubset_nonCoherent) precond_nbr_layers_bits=2; + } + } + if (num_antenna_ports == 2) { + if ((transformPrecoder == transformPrecoder_disabled) && (maxRank == 2)) { // Table 7.3.1.1.2-4 + if (codebookSubset == codebookSubset_fullyAndPartialAndNonCoherent) precond_nbr_layers_bits=4; + if (codebookSubset == codebookSubset_nonCoherent) precond_nbr_layers_bits=2; + } + if (((transformPrecoder == transformPrecoder_enabled)||(transformPrecoder == transformPrecoder_disabled)) && (maxRank == 1)) { // Table 7.3.1.1.2-5 + if (codebookSubset == codebookSubset_fullyAndPartialAndNonCoherent) precond_nbr_layers_bits=3; + if (codebookSubset == codebookSubset_nonCoherent) precond_nbr_layers_bits=1; + } + } + } + if (txConfig == txConfig_nonCodebook){ + } + // searching number of bits at tables 7.3.1.1.2-6/7/8/9/10/11/12/13/14/15/16/17/18/19 + if((dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)){ + if ((transformPrecoder == transformPrecoder_enabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len1)) antenna_ports_bits_ul = 2; + if ((transformPrecoder == transformPrecoder_enabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len2)) antenna_ports_bits_ul = 4; + if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len1)) antenna_ports_bits_ul = 3; + if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len2)) antenna_ports_bits_ul = 4; + } + if((dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type2)){ + if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len1)) antenna_ports_bits_ul = 4; + if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len2)) antenna_ports_bits_ul = 5; + } + // for format 1_1 number of bits as defined by Tables 7.3.1.2.2-1/2/3/4 + uint8_t antenna_ports_bits_dl = 0; + if((dmrs_DownlinkConfig.pdsch_dmrs_type == pdsch_dmrs_type1) && (dmrs_DownlinkConfig.pdsch_maxLength == pdsch_len1)) antenna_ports_bits_dl = 4; // Table 7.3.1.2.2-1 + if((dmrs_DownlinkConfig.pdsch_dmrs_type == pdsch_dmrs_type1) && (dmrs_DownlinkConfig.pdsch_maxLength == pdsch_len2)) antenna_ports_bits_dl = 5; // Table 7.3.1.2.2-2 + if((dmrs_DownlinkConfig.pdsch_dmrs_type == pdsch_dmrs_type2) && (dmrs_DownlinkConfig.pdsch_maxLength == pdsch_len1)) antenna_ports_bits_dl = 5; // Table 7.3.1.2.2-3 + if((dmrs_DownlinkConfig.pdsch_dmrs_type == pdsch_dmrs_type2) && (dmrs_DownlinkConfig.pdsch_maxLength == pdsch_len2)) antenna_ports_bits_dl = 6; // Table 7.3.1.2.2-4 + +// 39 TCI + uint8_t tci_bits=0; + if (pdcch_vars2->coreset[p].tciPresentInDCI == tciPresentInDCI_enabled) tci_bits=3; + +// 42 CSI_REQUEST + // reportTriggerSize is defined in the CSI-MeasConfig IE (TS 38.331). + // Size of CSI request field in DCI (bits). Corresponds to L1 parameter 'ReportTriggerSize' (see 38.214, section 5.2) + uint8_t reportTriggerSize = csi_MeasConfig.reportTriggerSize; // value from 0..6 + +// 43 CBGTI + // for format 0_1 + uint8_t maxCodeBlockGroupsPerTransportBlock = 0; + if (PUSCH_ServingCellConfig.maxCodeBlockGroupsPerTransportBlock != 0) + maxCodeBlockGroupsPerTransportBlock = (uint8_t)PUSCH_ServingCellConfig.maxCodeBlockGroupsPerTransportBlock; + // for format 1_1, as defined in Subclause 5.1.7 of [6, TS38.214] + uint8_t maxCodeBlockGroupsPerTransportBlock_dl = 0; + if (PDSCH_ServingCellConfig.maxCodeBlockGroupsPerTransportBlock_dl != 0) + maxCodeBlockGroupsPerTransportBlock_dl = pdsch_config.maxNrofCodeWordsScheduledByDCI; // FIXME!!! + +// 44 CBGFI + uint8_t cbgfi_bit = PDSCH_ServingCellConfig.codeBlockGroupFlushIndicator; + +// 45 PTRS_DMRS + // 0 bit if PTRS-UplinkConfig is not configured and transformPrecoder=disabled, or if transformPrecoder=enabled, or if maxRank=1 + // 2 bits otherwise + uint8_t ptrs_dmrs_bits=0; //FIXME!!! + +// 46 BETA_OFFSET_IND + // at IE PUSCH-Config, beta_offset indicator – 0 if the higher layer parameter betaOffsets = semiStatic; otherwise 2 bits + // uci-OnPUSCH + // Selection between and configuration of dynamic and semi-static beta-offset. If the field is absent or released, the UE applies the value 'semiStatic' and the BetaOffsets + uint8_t betaOffsets = 0; + if (pusch_config.uci_onPusch.betaOffset_type == betaOffset_semiStatic); + if (pusch_config.uci_onPusch.betaOffset_type == betaOffset_dynamic) betaOffsets = 2; + +// 47 DMRS_SEQ_INI + uint8_t dmrs_seq_ini_bits_ul = 0; + uint8_t dmrs_seq_ini_bits_dl = 0; + //1 bit if both scramblingID0 and scramblingID1 are configured in DMRS-UplinkConfig + if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.scramblingID0 != 0) && (dmrs_UplinkConfig.scramblingID1 != 0)) dmrs_seq_ini_bits_ul = 1; + //1 bit if both scramblingID0 and scramblingID1 are configured in DMRS-DownlinkConfig + if ((dmrs_DownlinkConfig.scramblingID0 != 0) && (dmrs_DownlinkConfig.scramblingID0 != 0)) dmrs_seq_ini_bits_dl = 1; + +/* + * For format 2_2 + * + * This format supports power control commands for semi-persistent scheduling. + * As we can already support power control commands dynamically with formats 0_0/0_1 (TPC PUSCH) and 1_0/1_1 (TPC PUCCH) + * + * This format will be implemented in the future FIXME!!! + * + */ +// 5 BLOCK_NUMBER: The parameter tpc-PUSCH or tpc-PUCCH provided by higher layers determines the index to the block number for an UL of a cell +// The following fields are defined for each block: Closed loop indicator and TPC command +// 6 CLOSE_LOOP_IND +// 41 TPC_CMD + uint8_t tpc_cmd_bit_2_2 = 2; +/* + * For format 2_3 + * + * This format is used for power control of uplink sounding reference signals for devices which have not coupled SRS power control to the PUSCH power control + * either because independent control is desirable or because the device is configured without PUCCH and PUSCH + * + * This format will be implemented in the future FIXME!!! + * + */ +// 40 SRS_REQUEST +// 41 TPC_CMD + uint8_t tpc_cmd_bit_2_3 = 0; + uint8_t dci_field_size_table [NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = { // This table contains the number of bits for each field (row) contained in each dci format (column). // The values of the variables indicate field sizes in number of bits //Format0_0 Format0_1 Format1_0 Format1_1 Formats2_0/1/2/3 {1, 1, (((crc_scrambled == _p_rnti) || (crc_scrambled == _si_rnti) || (crc_scrambled == _ra_rnti)) ? 0:1), 1, 0,0,0,0}, // 0 IDENTIFIER_DCI_FORMATS: -{0, 3, 0, 3, 0,0,0,0}, // 1 CARRIER_IND: 0 or 3 bits, as defined in Subclause x.x of [5, TS38.213] -{0, 0, 0, 0, 0,0,0,0}, // 2 SUL_IND_0_1: +{0, ((crossCarrierSchedulingConfig_ind == 0) ? 0:3), + 0, ((crossCarrierSchedulingConfig_ind == 0) ? 0:3), + 0,0,0,0}, // 1 CARRIER_IND: 0 or 3 bits, as defined in Subclause x.x of [5, TS38.213] +{0, (sul_ind == 0)?0:1, 0, 0, 0,0,0,0}, // 2 SUL_IND_0_1: {0, 0, 0, 0, 1,0,0,0}, // 3 SLOT_FORMAT_IND: size of DCI format 2_0 is configurable by higher layers up to 128 bits, according to Subclause 11.1.1 of [5, TS 38.213] {0, 0, 0, 0, 0,1,0,0}, // 4 PRE_EMPTION_IND: size of DCI format 2_1 is configurable by higher layers up to 126 bits, according to Subclause 11.2 of [5, TS 38.213]. Each pre-emption indication is 14 bits -{0, 0, 0, 0, 0,0,1,0}, // 5 TPC_CMD_NUMBER: The parameter xxx provided by higher layers determines the index to the TPC command number for an UL of a cell. Each TPC command number is 2 bits -{0, 0, 0, 0, 0,0,0,1}, // 6 BLOCK_NUMBER: starting position of a block is determined by the parameter startingBitOfFormat2_3 -{0, ceil(log2(n_RB_ULBWP)), 0, ceil(log2(n_RB_ULBWP)), 0,0,0,0}, // 7 BANDWIDTH_PART_IND: +{0, 0, 0, 0, 0,0,0,0}, // 5 BLOCK_NUMBER: starting position of a block is determined by the parameter startingBitOfFormat2_3 +{0, 0, 0, 0, 0,0,1,0}, // 6 CLOSE_LOOP_IND +{0, (uint8_t)ceil(log2(n_UL_BWP_RRC)), + 0, (uint8_t)ceil(log2(n_DL_BWP_RRC)), + 0,0,0,0}, // 7 BANDWIDTH_PART_IND: {0, 0, ((crc_scrambled == _p_rnti) ? 2:0), 0, 0,0,0,0}, // 8 SHORT_MESSAGE_IND 2 bits if crc scrambled with P-RNTI {0, 0, ((crc_scrambled == _p_rnti) ? 8:0), 0, 0,0,0,0}, // 9 SHORT_MESSAGES 8 bit8 if crc scrambled with P-RNTI -{(ceil(log2(n_RB_ULBWP*(n_RB_ULBWP+1)/2)))-n_UL_hopping, - (ceil(log2(n_RB_ULBWP*(n_RB_ULBWP+1)/2)))-n_UL_hopping, +{(uint8_t)(ceil(log2(n_RB_ULBWP*(n_RB_ULBWP+1)/2)))-n_UL_hopping, + n_bits_freq_dom_res_assign_ul, 0, 0, 0,0,0,0}, // 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered // (NOTE 1) If DCI format 0_0 is monitored in common search space // and if the number of information bits in the DCI format 0_0 prior to padding // is larger than the payload size of the DCI format 1_0 monitored in common search space // the bitwidth of the frequency domain resource allocation field in the DCI format 0_0 // is reduced such that the size of DCI format 0_0 equals to the size of the DCI format 1_0 -{0, 0, ceil(log2(n_RB_DLBWP*(n_RB_DLBWP+1)/2)), - ceil(log2(n_RB_DLBWP*(n_RB_DLBWP+1)/2)), +{0, 0, (uint8_t)ceil(log2(n_RB_DLBWP*(n_RB_DLBWP+1)/2)), + n_bits_freq_dom_res_assign_dl, 0,0,0,0}, // 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: -{4, log2(pusch_alloc_list), 4, log2(pusch_alloc_list), 0,0,0,0}, // 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, +{4, (uint8_t)log2(pusch_alloc_list), + 4, (uint8_t)log2(pdsch_alloc_list), + 0,0,0,0}, // 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, // where I the number of entries in the higher layer parameter pusch-AllocationList -{0, 1, 1, 1, 0,0,0,0}, // 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 -{0, 0, 0, 1, 0,0,0,0}, // 14 PRB_BUNDLING_SIZE_IND:0 bit if the higher layer parameter PRB_bundling is not configured or is set to 'static', or 1 bit if the higher layer parameter PRB_bundling is set to 'dynamic' according to Subclause 5.1.2.3 of [6, TS 38.214] -{0, 0, 0, 2, 0,0,0,0}, // 15 RATE_MATCHING_IND: 0, 1, or 2 bits according to higher layer parameter rate-match-PDSCH-resource-set -{0, 0, 0, log2(n_zp)+1, 0,0,0,0}, // 16 ZP_CSI_RS_TRIGGER: -{1, 1, 0, 0, 0,0,0,0}, // 17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0 +{0, 0, 1, (((dl_res_alloc_type_0==1)&&(dl_res_alloc_type_1==0))?0:1), + 0,0,0,0}, // 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 +{0, 0, 0, prb_BundlingType_size, 0,0,0,0}, // 14 PRB_BUNDLING_SIZE_IND:0 bit if the higher layer parameter PRB_bundling is not configured or is set to 'static', or 1 bit if the higher layer parameter PRB_bundling is set to 'dynamic' according to Subclause 5.1.2.3 of [6, TS 38.214] +{0, 0, 0, rateMatching_bits, 0,0,0,0}, // 15 RATE_MATCHING_IND: 0, 1, or 2 bits according to higher layer parameter rate-match-PDSCH-resource-set +{0, 0, 0, n_zp_bits, 0,0,0,0}, // 16 ZP_CSI_RS_TRIGGER: +{1, (((ul_res_alloc_type_0==1)&&(ul_res_alloc_type_1==0))||(freqHopping == 0))?0:1, + 0, 0, 0,0,0,0}, // 17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0 {0, 0, 0, 5, 0,0,0,0}, // 18 TB1_MCS: {0, 0, 0, 1, 0,0,0,0}, // 19 TB1_NDI: {0, 0, 0, 2, 0,0,0,0}, // 20 TB1_RV: @@ -4944,29 +5178,34 @@ uint16_t nr_dci_format_size (crc_scrambled_t crc_scrambled, {2, 2, (((crc_scrambled == _c_rnti) || (crc_scrambled == _si_rnti)) ? 2:0), 0, 0,0,0,0}, // 26 RV: {4, 4, (crc_scrambled == _c_rnti)?4:0,4, 0,0,0,0}, // 27 HARQ_PROCESS_NUMBER: -{0, 0, (crc_scrambled == _c_rnti)?2:0,2, 0,0,0,0}, // 28 DAI: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI +{0, 0, (crc_scrambled == _c_rnti)?2:0,n_dai, 0,0,0,0}, // 28 DAI: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI // 2 if one serving cell is configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 bits are the counter DAI // 0 otherwise -{0, 2, 0, 0, 0,0,0,0}, // 29 FIRST_DAI: (1 or 2 bits) 1 bit for semi-static HARQ-ACK // 2 bits for dynamic HARQ-ACK codebook with single HARQ-ACK codebook -{0, 2, 0, 0, 0,0,0,0}, // 30 SECOND_DAI: (0 or 2 bits) 2 bits for dynamic HARQ-ACK codebook with two HARQ-ACK sub-codebooks // 0 bits otherwise +{0, codebook_HARQ_ACK, 0, 0, 0,0,0,0}, // 29 FIRST_DAI: (1 or 2 bits) 1 bit for semi-static HARQ-ACK // 2 bits for dynamic HARQ-ACK codebook with single HARQ-ACK codebook +{0, (((codebook_HARQ_ACK == 2) && (n_HARQ_ACK_sub_codebooks==2))?2:0), + 0, 0, 0,0,0,0}, // 30 SECOND_DAI: (0 or 2 bits) 2 bits for dynamic HARQ-ACK codebook with two HARQ-ACK sub-codebooks // 0 bits otherwise {0, 0, (((crc_scrambled == _p_rnti) || (crc_scrambled == _ra_rnti)) ? 2:0), 0, 0,0,0,0}, // 31 TB_SCALING {2, 2, 0, 0, 0,0,0,0}, // 32 TPC_PUSCH: {0, 0, (crc_scrambled == _c_rnti)?2:0,2, 0,0,0,0}, // 33 TPC_PUCCH: {0, 0, (crc_scrambled == _c_rnti)?3:0,3, 0,0,0,0}, // 34 PUCCH_RESOURCE_IND: -{0, 0, (crc_scrambled == _c_rnti)?3:0,3, 0,0,0,0}, // 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND: -{0, log2(n_SRS), 0, 0, 0,0,0,0}, // 36 SRS_RESOURCE_IND: -{0, 0, 0, 0, 0,0,0,0}, // 37 PRECOD_NBR_LAYERS: -{0, 0, 0, 0, 0,0,0,0}, // 38 ANTENNA_PORTS: -{0, 0, 0, 3, 0,0,0,0}, // 39 TCI: 0 bit if higher layer parameter tci-PresentInDCI is not enabled; otherwise 3 bits -{0, 3, 0, 0, 0,0,0,2}, // 40 SRS_REQUEST: -{0, 0, 0, 0, 0,0,0,2}, // 41 TPC_CMD_NUMBER_FORMAT2_3: -{0, 6, 0, 0, 0,0,0,0}, // 42 CSI_REQUEST: -{0, 8, 0, 8, 0,0,0,0}, // 43 CBGTI: 0, 2, 4, 6, or 8 bits determined by higher layer parameter maxCodeBlockGroupsPerTransportBlock for the PDSCH -{0, 0, 0, 1, 0,0,0,0}, // 44 CBGFI: 0 or 1 bit determined by higher layer parameter codeBlockGroupFlushIndicator -{0, 2, 0, 0, 0,0,0,0}, // 45 PTRS_DMRS: -{0, 2, 0, 0, 0,0,0,0}, // 46 BETA_OFFSET_IND: -{0, 1, 0, 1, 0,0,0,0}, // 47 DMRS_SEQ_INI: 1 bit if the cell has two ULs and the number of bits for DCI format 1_0 before padding +{0, 0, (crc_scrambled == _c_rnti)?3:0,pdsch_harq_t_ind, 0,0,0,0}, // 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND: +{0, (uint8_t)log2(n_SRS), 0, 0, 0,0,0,0}, // 36 SRS_RESOURCE_IND: +{0, precond_nbr_layers_bits, 0, 0, 0,0,0,0}, // 37 PRECOD_NBR_LAYERS: +{0, antenna_ports_bits_ul, 0, antenna_ports_bits_dl, 0,0,0,0}, // 38 ANTENNA_PORTS: +{0, 0, 0, tci_bits, 0,0,0,0}, // 39 TCI: 0 bit if higher layer parameter tci-PresentInDCI is not enabled; otherwise 3 bits +{0, (sul_ind == 0)?2:3, 0, (sul_ind == 0)?2:3, 0,0,0,2}, // 40 SRS_REQUEST: +{0, 0, 0, 0, 0,0,tpc_cmd_bit_2_2, + tpc_cmd_bit_2_3}, + // 41 TPC_CMD: +{0, reportTriggerSize, 0, 0, 0,0,0,0}, // 42 CSI_REQUEST: +{0, maxCodeBlockGroupsPerTransportBlock, + 0, maxCodeBlockGroupsPerTransportBlock_dl, + 0,0,0,0}, // 43 CBGTI: 0, 2, 4, 6, or 8 bits determined by higher layer parameter maxCodeBlockGroupsPerTransportBlock for the PDSCH +{0, 0, 0, cbgfi_bit, 0,0,0,0}, // 44 CBGFI: 0 or 1 bit determined by higher layer parameter codeBlockGroupFlushIndicator +{0, ptrs_dmrs_bits, 0, 0, 0,0,0,0}, // 45 PTRS_DMRS: +{0, betaOffsets, 0, 0, 0,0,0,0}, // 46 BETA_OFFSET_IND: +{0, dmrs_seq_ini_bits_ul, 0, dmrs_seq_ini_bits_dl, 0,0,0,0}, // 47 DMRS_SEQ_INI: 1 bit if the cell has two ULs and the number of bits for DCI format 1_0 before padding // is larger than the number of bits for DCI format 0_0 before padding; 0 bit otherwise {0, 1, 0, 0, 0,0,0,0}, // 48 UL_SCH_IND: value of "1" indicates UL-SCH shall be transmitted on the PUSCH and a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH {0, 0, 0, 0, 0,0,0,0}, // 49 PADDING_NR_DCI: @@ -4975,7 +5214,7 @@ uint16_t nr_dci_format_size (crc_scrambled_t crc_scrambled, // is less than the payload size of the DCI format 1_0 monitored in common search space // zeros shall be appended to the DCI format 0_0 // until the payload size equals that of the DCI format 1_0 -{0, 0, 0, 0, 0,0,0,0}, // 50 SUL_IND_0_0: +{(sul_ind == 0)?0:1, 0, 0, 0, 0,0,0,0}, // 50 SUL_IND_0_0: {0, 0, 0, 0, 0,0,0,0}, // 51 RA_PREAMBLE_INDEX (random access procedure initiated by a PDCCH order not implemented, FIXME!!!) {0, 0, 0, 0, 0,0,0,0}, // 52 SUL_IND_1_0 (random access procedure initiated by a PDCCH order not implemented, FIXME!!!) {0, 0, 0, 0, 0,0,0,0}, // 53 SS_PBCH_INDEX (random access procedure initiated by a PDCCH order not implemented, FIXME!!!) @@ -5012,9 +5251,17 @@ uint8_t dci_size [8] = {0,0,0,0,0,0,0,0}; // will contain size for each format printf("\n"); } printf(" }\n"); - printf("\n\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_format_size) dci_size[0]=%d, dci_size[2]=%d\n",dci_size[0],dci_size[2]); + printf("\n\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_format_size) dci_size[0_0]=%d, dci_size[0_1]=%d, dci_size[1_0]=%d, dci_size[1_1]=%d,\n",dci_size[0],dci_size[1],dci_size[2],dci_size[3]); #endif +//UL/SUL indicator format0_0 (TS 38.212 subclause 7.3.1.1.1) + // - 1 bit if the cell has two ULs and the number of bits for DCI format 1_0 before padding is larger than the number of bits for DCI format 0_0 before padding; + // - 0 bit otherwise. + // The UL/SUL indicator, if present, locates in the last bit position of DCI format 0_0, after the padding bit(s) + if ((dci_field_size_table[SUL_IND_0_0][0] == 1) && (dci_size[0] > dci_size[2])){ + dci_field_size_table[SUL_IND_0_0][0] = 0; + dci_size[0]=dci_size[0]-1; + } // if ((format == format0_0) || (format == format1_0)) { // According to Section 7.3.1.1.1 in TS 38.212 // If DCI format 0_0 is monitored in common search space and if the number of information bits in the DCI format 0_0 prior to padding @@ -5042,6 +5289,19 @@ uint8_t dci_size [8] = {0,0,0,0,0,0,0,0}; // will contain size for each format #endif //} } + + /* + * TS 38.212 subclause 7.3.1.1.2 + * For a UE configured with SUL in a cell: + * if PUSCH is configured to be transmitted on both the SUL and the non-SUL of the cell and + * if the number of information bits in format 0_1 for the SUL + * is not equal to the number of information bits in format 0_1 for the non-SUL, + * zeros shall be appended to smaller format 0_1 until the payload size equals that of the larger format 0_1 + * + * Not implemented. FIXME!!! + * + */ + // } #ifdef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_format_size) dci_fields_sizes[][] = { \n"); @@ -5053,7 +5313,7 @@ uint8_t dci_size [8] = {0,0,0,0,0,0,0,0}; // will contain size for each format printf(" }\n"); #endif - return dci_size[0]; + return dci_size[format]; } #endif @@ -5190,291 +5450,225 @@ uint8_t nr_dci_decoding_procedure(int s, // for format0_0 => we are NOT implementing format0_0 for common search spaces. FIXME! // for format0_0 and format1_0, first we calculate dci pdu size - format_0_0_1_0_size_bits = nr_dci_format_size(_c_rnti,16,n_RB_ULBWP,n_RB_DLBWP,dci_fields_sizes); + format_0_0_1_0_size_bits = nr_dci_format_size(ue,eNB_id,nr_tti_rx,p,_c_rnti,n_RB_ULBWP,n_RB_DLBWP,dci_fields_sizes,0); format_0_0_1_0_size_bytes = (format_0_0_1_0_size_bits%8 == 0) ? (uint8_t)floor(format_0_0_1_0_size_bits/8) : (uint8_t)(floor(format_0_0_1_0_size_bits/8) + 1); #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> calculating dci format size for common searchSpaces with format css_dci_format=%d, format_0_0_1_0_size_bits=%d, format_0_0_1_0_size_bytes=%d\n", css_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); #endif -#if 0 - // for aggregation level 4. The number of candidates (L2=4) will be calculated in function nr_dci_decoding_procedure0 - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", - css_dci_format,(1<<2)); - #endif - old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, - crc_scrambled_values, 2, - cformat0_0_and_1_0, uformat0_0_and_1_0, - format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ - format_0_0_1_0_size_bits = nr_dci_format_size(crc_scrambled_,16,n_RB_ULBWP,n_RB_DLBWP,dci_fields_sizes); // after decoding dci successfully we recalculate dci pdu size with correct crc scrambled to get the right field sizes + for (int aggregationLevel = 3; aggregationLevel<4 ; aggregationLevel++) { // We fix aggregationLevel to 3 for testing=> nbr of CCE=8 + //for (int aggregationLevel = 2; aggregationLevel<5 ; aggregationLevel++) { + // for aggregation level aggregationLevel. The number of candidates (for L2= 2^aggregationLevel) will be calculated in function nr_dci_decoding_procedure0 + #ifdef NR_PDCCH_DCI_DEBUG + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", + css_dci_format,(1<current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + crc_scrambled_values, aggregationLevel, + cformat0_0_and_1_0, uformat0_0_and_1_0, + format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, + &crc_scrambled_, &format_found_, pdcch_DMRS_scrambling_id,&CCEmap0, &CCEmap1, &CCEmap2); + if (dci_cnt != old_dci_cnt){ + // we will exit the loop as we have found the DCI + aggregationLevel = 5; + format_0_0_1_0_size_bits = nr_dci_format_size(ue,eNB_id,nr_tti_rx,p,crc_scrambled_,n_RB_ULBWP,n_RB_DLBWP,dci_fields_sizes,0); // after decoding dci successfully we recalculate dci pdu size with correct crc scrambled to get the right field sizes + old_dci_cnt = dci_cnt; + for (int i=0; i common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", - css_dci_format,(1<<3)); - #endif - old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, - crc_scrambled_values, 3, - cformat0_0_and_1_0, uformat0_0_and_1_0, - format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_, pdcch_DMRS_scrambling_id,&CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ - format_0_0_1_0_size_bits = nr_dci_format_size(crc_scrambled_,16,n_RB_ULBWP,n_RB_DLBWP,dci_fields_sizes); // after decoding dci successfully we recalculate dci pdu size with correct crc scrambled to get the right field sizes - old_dci_cnt = dci_cnt; - for (int i=0; i common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", - css_dci_format,(1<<4)); - #endif - old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, - crc_scrambled_values, 4, - cformat0_0_and_1_0, uformat0_0_and_1_0, - format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ - format_0_0_1_0_size_bits = nr_dci_format_size(crc_scrambled_,16,n_RB_ULBWP,n_RB_DLBWP,dci_fields_sizes); // after decoding dci successfully we recalculate dci pdu size with correct crc scrambled to get the right field sizes - old_dci_cnt = dci_cnt; - for (int i=0; i calculating dci format size for common searchSpaces with format css_dci_format=%d, format2_0_size_bits=%d, format2_0_size_bytes=%d\n", css_dci_format,format_2_0_size_bits,format_2_0_size_bytes); #endif - // for aggregation level 1. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 - old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, - crc_scrambled_values, 0, - cformat2_0, uformat0_0_and_1_0, - format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ + for (int aggregationLevelSFI = 0; aggregationLevelSFI<5 ; aggregationLevelSFI++){ + #ifdef NR_PDCCH_DCI_DEBUG + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", + css_dci_format,(1<current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, - crc_scrambled_values, 1, - cformat2_0, uformat0_0_and_1_0, - format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ - old_dci_cnt = dci_cnt; - for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, - crc_scrambled_values, 2, - cformat2_0, uformat0_0_and_1_0, - format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ - old_dci_cnt = dci_cnt; - for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, - crc_scrambled_values, 3, - cformat2_0, uformat0_0_and_1_0, - format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ - old_dci_cnt = dci_cnt; - for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, - crc_scrambled_values, 4, - cformat2_0, uformat0_0_and_1_0, - format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ - old_dci_cnt = dci_cnt; - for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + crc_scrambled_values, aggregationLevelSFI, + cformat2_0, uformat0_0_and_1_0, + format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); + if (dci_cnt != old_dci_cnt){ + // we will exit the loop as we have found the DCI + aggregationLevelSFI = 5; + old_dci_cnt = dci_cnt; + for (int i=0; i calculating dci format size for common searchSpaces with format css_dci_format=%d, format2_1_size_bits=%d, format2_1_size_bytes=%d\n", css_dci_format,format_2_1_size_bits,format_2_1_size_bytes); #endif + for (int aggregationLevel = 0; aggregationLevel<5 ; aggregationLevel++){ + #ifdef NR_PDCCH_DCI_DEBUG + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", + css_dci_format,(1<current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + crc_scrambled_values, aggregationLevel, + cformat2_1, uformat0_0_and_1_0, + format_2_1_size_bits, format_2_1_size_bytes, &dci_cnt, + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); + if (dci_cnt != old_dci_cnt){ + // we will exit the loop as we have found the DCI + aggregationLevel = 5; + old_dci_cnt = dci_cnt; + for (int i=0; i calculating dci format size for common searchSpaces with format css_dci_format=%d, format2_2_size_bits=%d, format2_2_size_bytes=%d\n", css_dci_format,format_2_2_size_bits,format_2_2_size_bytes); #endif + for (int aggregationLevel = 0; aggregationLevel<5 ; aggregationLevel++){ + #ifdef NR_PDCCH_DCI_DEBUG + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", + css_dci_format,(1<current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + crc_scrambled_values, aggregationLevel, + cformat2_2, uformat0_0_and_1_0, + format_2_2_size_bits, format_2_2_size_bytes, &dci_cnt, + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); + if (dci_cnt != old_dci_cnt){ + // we will exit the loop as we have found the DCI + aggregationLevel = 5; + old_dci_cnt = dci_cnt; + for (int i=0; i calculating dci format size for common searchSpaces with format css_dci_format=%d, format2_3_size_bits=%d, format2_3_size_bytes=%d\n", css_dci_format,format_2_3_size_bits,format_2_3_size_bytes); #endif + for (int aggregationLevel = 0; aggregationLevel<5 ; aggregationLevel++){ + #ifdef NR_PDCCH_DCI_DEBUG + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", + css_dci_format,(1<current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + crc_scrambled_values, aggregationLevel, + cformat2_3, uformat0_0_and_1_0, + format_2_3_size_bits, format_2_3_size_bytes, &dci_cnt, + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); + if (dci_cnt != old_dci_cnt){ + // we will exit the loop as we have found the DCI + aggregationLevel = 5; + old_dci_cnt = dci_cnt; + for (int i=0; i calculating dci format size for UE-specific searchSpaces with format uss_dci_format=%d, format_0_0_1_0_size_bits=%d, format_0_0_1_0_size_bytes=%d\n", css_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); #endif - // blind decoding format0_0 for aggregation level 1. The number of candidates (nrofCandidates) will be calculated in function nr_dci_decoding_procedure0 - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> ue-Specific searchSpaces with format uss_dci_format=%d and aggregation level 1, format_0_0_1_0_size_bits=%d, format_0_0_1_0_size_bytes=%d\n", - uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); - #endif - old_dci_cnt = dci_cnt; -/* - * To be removed, just for unitary testing - */ -//#ifdef NR_PDCCH_DCI_DEBUG -// printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> ### WE PROVOKE DCI DETECTION !!! ### old_dci_cnt=%d and dci_cnt=%d\n", -// old_dci_cnt,dci_cnt); -// dci_cnt++; -//#endif -/* - * To be removed until here - */ - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, - crc_scrambled_values, 0, - cformat0_0_and_1_0, uformat0_0_and_1_0, - format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ + for (int aggregationLevel = 0; aggregationLevel<5 ; aggregationLevel++) { // We fix aggregationLevel to 3 for testing=> nbr of CCE=8 + //for (int aggregationLevel = 2; aggregationLevel<5 ; aggregationLevel++) { + // for aggregation level aggregationLevel. The number of candidates (for L2= 2^aggregationLevel) will be calculated in function nr_dci_decoding_procedure0 + #ifdef NR_PDCCH_DCI_DEBUG + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", + css_dci_format,(1<current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, + crc_scrambled_values, aggregationLevel, + cformat0_0_and_1_0, uformat0_0_and_1_0, + format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); + if (dci_cnt != old_dci_cnt){ + // we will exit the loop as we have found the DCI + aggregationLevel = 5; + old_dci_cnt = dci_cnt; + for (int i=0; i ue-Specific searchSpaces with format uss_dci_format=%d and aggregation level 2, format_0_0_1_0_size_bits=%d, format_0_0_1_0_size_bytes=%d\n", - uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> calculating dci format size for UE-specific searchSpaces with format uss_dci_format=%d, format_0_1_1_1_size_bits=%d, format_0_1_1_1_size_bytes=%d\n", + css_dci_format,format_0_1_1_1_size_bits,format_0_1_1_1_size_bytes); #endif - old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, - crc_scrambled_values, 1, - cformat0_0_and_1_0, uformat0_0_and_1_0, - format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ + for (int aggregationLevel = 0; aggregationLevel<5 ; aggregationLevel++) { // We fix aggregationLevel to 3 for testing=> nbr of CCE=8 + //for (int aggregationLevel = 2; aggregationLevel<5 ; aggregationLevel++) { + // for aggregation level aggregationLevel. The number of candidates (for L2= 2^aggregationLevel) will be calculated in function nr_dci_decoding_procedure0 + #ifdef NR_PDCCH_DCI_DEBUG + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> common searchSpaces with format css_dci_format=%d and aggregation_level=%d\n", + css_dci_format,(1< ue-Specific searchSpaces with format uss_dci_format=%d and aggregation level 4, format_0_0_1_0_size_bits=%d, format_0_0_1_0_size_bytes=%d\n", - uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); - #endif - old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, - crc_scrambled_values, 2, - cformat0_0_and_1_0, uformat0_0_and_1_0, - format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ - old_dci_cnt = dci_cnt; - for (int i=0; i ue-Specific searchSpaces with format uss_dci_format=%d and aggregation level 8, format_0_0_1_0_size_bits=%d, format_0_0_1_0_size_bytes=%d\n", - uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); - #endif - old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, - crc_scrambled_values, 3, - cformat0_0_and_1_0, uformat0_0_and_1_0, - format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ - old_dci_cnt = dci_cnt; - for (int i=0; i ue-Specific searchSpaces with format uss_dci_format=%d and aggregation level 16, format_0_0_1_0_size_bits=%d, format_0_0_1_0_size_bytes=%d\n", - uss_dci_format,format_0_0_1_0_size_bits,format_0_0_1_0_size_bytes); - #endif - old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, - crc_scrambled_values, 4, - cformat0_0_and_1_0, uformat0_0_and_1_0, - format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, - &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); - if (dci_cnt != old_dci_cnt){ - old_dci_cnt = dci_cnt; - for (int i=0; icurrent_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, + crc_scrambled_values, aggregationLevel, + cformat0_0_and_1_0, uformat0_1_and_1_1, + format_0_1_1_1_size_bits, format_0_1_1_1_size_bytes, &dci_cnt, + &crc_scrambled_, &format_found_,pdcch_DMRS_scrambling_id, &CCEmap0, &CCEmap1, &CCEmap2); + if (dci_cnt != old_dci_cnt){ + // we will exit the loop as we have found the DCI + aggregationLevel = 5; + old_dci_cnt = dci_cnt; + for (int i=0; i at the end dci_cnt=%d \n",dci_cnt); #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.h b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.h index 4aa441c837..95b6cfd2e2 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.h +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.h @@ -49,8 +49,8 @@ struct NR_DCI_INFO_EXTRACTED { uint8_t sul_ind_0_1 ; // 2 SUL_IND_0_1: uint8_t slot_format_ind ; // 3 SLOT_FORMAT_IND: size of DCI format 2_0 is configurable by higher layers up to 128 bits, according to Subclause 11.1.1 of [5, TS 38.213] uint8_t pre_emption_ind ; // 4 PRE_EMPTION_IND: size of DCI format 2_1 is configurable by higher layers up to 126 bits, according to Subclause 11.2 of [5, TS 38.213]. Each pre-emption indication is 14 bits - uint8_t tpc_cmd_number ; // 5 TPC_CMD_NUMBER: The parameter xxx provided by higher layers determines the index to the TPC command number for an UL of a cell. Each TPC command number is 2 bits - uint8_t block_number ; // 6 BLOCK_NUMBER: starting position of a block is determined by the parameter startingBitOfFormat2_3 + uint8_t block_number ; // 5 BLOCK_NUMBER: starting position of a block is determined by the parameter startingBitOfFormat2_3 + uint8_t close_loop_ind ; // 6 CLOSE_LOOP_IND: uint8_t bandwidth_part_ind ; // 7 BANDWIDTH_PART_IND: uint8_t short_message_ind ; // 8 SHORT_MESSAGE_IND: uint8_t short_messages ; // 9 SHORT_MESSAGES: @@ -93,7 +93,7 @@ struct NR_DCI_INFO_EXTRACTED { uint8_t antenna_ports ; // 38 ANTENNA_PORTS: uint8_t tci ; // 39 TCI: 0 bit if higher layer parameter tci-PresentInDCI is not enabled; otherwise 3 bits uint8_t srs_request ; // 40 SRS_REQUEST: - uint8_t tpc_cmd_number_format2_3 ; // 41 TPC_CMD_NUMBER_FORMAT2_3: + uint8_t tpc_cmd ; // 41 TPC_CMD: uint8_t csi_request ; // 42 CSI_REQUEST: uint8_t cbgti ; // 43 CBGTI: 0, 2, 4, 6, or 8 bits determined by higher layer parameter maxCodeBlockGroupsPerTransportBlock for the PDSCH uint8_t cbgfi ; // 44 CBGFI: 0 or 1 bit determined by higher layer parameter codeBlockGroupFlushIndicator diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c index 579b52fac1..5980ed3bb6 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c @@ -4024,8 +4024,10 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, * then we will do a right-shit of dci_length-13 positions -> (1 1010 1000 1001). And this is the content of the freq_dom_resource_assignment_DL field * * - * At the moment we have implemented: + * At the moment we have implemented the following formats: + * * Format 0_0, that contains the following fields according to Specification 38.212 V15.1.1 Section 7.3.1 + * with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI * 0 IDENTIFIER_DCI_FORMATS: * 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, @@ -4038,10 +4040,37 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, * 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space * 50 SUL_IND_0_0: * + * Format 0_1, that contains the following fields + * with CRC scrambled by C-RNTI or CS-RNTI or SP-CSI-RNTI or new-RNTI + * 0 IDENTIFIER_DCI_FORMATS: + * 1 CARRIER_IND + * 2 SUL_IND_0_1 + * 7 BANDWIDTH_PART_IND + * 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0 + * 24 MCS: + * 25 NDI: + * 26 RV: + * 27 HARQ_PROCESS_NUMBER: + * 29 FIRST_DAI + * 30 SECOND_DAI + * 32 TPC_PUSCH: + * 36 SRS_RESOURCE_IND: + * 37 PRECOD_NBR_LAYERS: + * 38 ANTENNA_PORTS: + * 40 SRS_REQUEST: + * 42 CSI_REQUEST: + * 43 CBGTI + * 45 PTRS_DMRS + * 46 BETA_OFFSET_IND + * 47 DMRS_SEQ_INI + * 48 UL_SCH_IND + * 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space + * * Format 1_0, that contains the following fields + * with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI * 0 IDENTIFIER_DCI_FORMATS: - * 8 SHORT_MESSAGE_IND - * 9 SHORT_MESSAGES * 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, * 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 @@ -4050,18 +4079,102 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, * 26 RV: * 27 HARQ_PROCESS_NUMBER: * 28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI - * 31 TB_SCALING * 33 TPC_PUCCH: * 34 PUCCH_RESOURCE_IND: * 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND: - * 51 RA_PREAMBLE_INDEX: - * 52 SUL_IND_1_0: - * 53 SS_PBCH_INDEX: - * 54 PRACH_MASK_INDEX: * 55 RESERVED_NR_DCI * + * If the CRC of the DCI format 1_0 is scrambled by C-RNTI and the "Frequency domain resource assignment" field are of all ones, + * the DCI format 1_0 is for random access procedure initiated by a PDCCH order. + * This is not implemented, but the fields are already included: FIXME!!! + * + * with CRC scrambled by P-RNTI + * 8 SHORT_MESSAGE_IND + * 9 SHORT_MESSAGES + * 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 + * 24 MCS: + * 31 TB_SCALING + * 55 RESERVED_NR_DCI + * + * with CRC scrambled by SI-RNTI + * 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 + * 24 MCS: + * 26 RV: + * 55 RESERVED_NR_DCI + * + * with CRC scrambled by RA-RNTI + * 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 + * 24 MCS: + * 31 TB_SCALING + * 55 RESERVED_NR_DCI + * + * with CRC scrambled by TC-RNTI + * 0 IDENTIFIER_DCI_FORMATS: + * 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 + * 24 MCS: + * 25 NDI: + * 26 RV: + * 27 HARQ_PROCESS_NUMBER: + * 28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI + * 33 TPC_PUCCH: + * + * Format 1_1, that contains the following fields + * with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI + * 0 IDENTIFIER_DCI_FORMATS: + * 1 CARRIER_IND: + * 7 BANDWIDTH_PART_IND: + * 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 + * 14 PRB_BUNDLING_SIZE_IND: + * 15 RATE_MATCHING_IND: + * 16 ZP_CSI_RS_TRIGGER: + * 18 TB1_MCS: + * 19 TB1_NDI: + * 20 TB1_RV: + * 21 TB2_MCS: + * 22 TB2_NDI: + * 23 TB2_RV: + * 27 HARQ_PROCESS_NUMBER: + * 28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI + * 33 TPC_PUCCH: + * 34 PUCCH_RESOURCE_IND: + * 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND: + * 38 ANTENNA_PORTS: + * 39 TCI: + * 40 SRS_REQUEST: + * 43 CBGTI: + * 44 CBGFI: + * 47 DMRS_SEQ_INI: + * + * We have not implemented the following formats: + * + * Format 2_0 + * Used for notifying the slot format + * + * Format 2_1 + * Used for notifying the PRB(s) and OFDM symbol(s) where UE may assume no transmission is intended for the UE + * + * Format 2_2 + * This format supports power control commands for semi-persistent scheduling. + * As we can already support power control commands dynamically with formats 0_0/0_1 (TPC PUSCH) and 1_0/1_1 (TPC PUCCH) + * This format will be implemented in the future FIXME!!! + * + * Format 2_3 + * This format is used for power control of uplink sounding reference signals for devices which have not coupled SRS power control to the PUSCH power control + * either because independent control is desirable or because the device is configured without PUCCH and PUSCH + * This format will be implemented in the future FIXME!!! + * */ - uint8_t dci_fields_sizes_format[NBR_NR_DCI_FIELDS] ={0}; + uint8_t dci_fields_sizes_format[NBR_NR_DCI_FIELDS] = {0}; for (int m=0; mDCINdi; - uint16_t l_RB; + /*uint16_t l_RB; uint16_t start_RB; uint16_t tmp_RIV; uint16_t l_symbol; @@ -4202,7 +4315,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, {j, 8,4}, // row index 14 {j+3,0,8}, // row index 15 {j+3,0,10} // row index 16 - }; + };*/ /* @@ -4292,20 +4405,20 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->pre_emption_ind=%x\n",nr_pdci_info_extracted->pre_emption_ind); #endif break; - case TPC_CMD_NUMBER: // 5 TPC_CMD_NUMBER: (field defined for -,-,-,-,-,-,format2_2,-) - // The parameter xxx provided by higher layers determines the index to the TPC command number for an UL of a cell. Each TPC command number is 2 bits - nr_pdci_info_extracted->tpc_cmd_number = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); - //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG - printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tpc_cmd_number=%x\n",nr_pdci_info_extracted->tpc_cmd_number); -#endif - break; - case BLOCK_NUMBER: // 6 BLOCK_NUMBER: (field defined for -,-,-,-,-,-,-,format2_3) + case BLOCK_NUMBER: // 5 BLOCK_NUMBER: (field defined for -,-,-,-,-,-,-,format2_3) // starting position of a block is determined by the parameter startingBitOfFormat2_3 nr_pdci_info_extracted->block_number = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->block_number=%x\n",nr_pdci_info_extracted->block_number); +#endif + break; + case CLOSE_LOOP_IND: // 6 CLOSE_LOOP_IND: (field defined for -,-,-,-,-,-,format2_2,-) + // The parameter xxx provided by higher layers determines the index to the TPC command number for an UL of a cell. Each TPC command number is 2 bits + nr_pdci_info_extracted->close_loop_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); +#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->close_loop_ind=%x\n",nr_pdci_info_extracted->close_loop_ind); #endif break; case BANDWIDTH_PART_IND: // 7 BANDWIDTH_PART_IND: (field defined for -,format0_1,-,format1_1,-,-,-,-) @@ -4338,7 +4451,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // The UE shall assume that when the scheduling PDCCH is received with DCI format 0_0, then uplink resource allocation type 1 is used. nr_pdci_info_extracted->freq_dom_resource_assignment_UL = (uint16_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - if (dci_format == format0_1){ // uplink resource allocation type 0 or 1 can be used + /*if (dci_format == format0_1){ // uplink resource allocation type 0 or 1 can be used } if (dci_format == format0_0){ // only uplink resource allocation type 1 // At the moment we are supporting only format 1_0 (and not format 1_1), so we only support resource allocation type 1 (and not type 0). @@ -4356,10 +4469,10 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, } ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->first_rb = start_RB; ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->nb_rb = l_RB; - } + }*/ #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->freq_dom_resource_assignment_UL=%x\n",nr_pdci_info_extracted->freq_dom_resource_assignment_UL); - printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> l_RB=%d, start_RB=%d, n_RB_DLBWP=%d\n",l_RB,start_RB,n_RB_ULBWP); + //printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> l_RB=%d, start_RB=%d, n_RB_DLBWP=%d\n",l_RB,start_RB,n_RB_ULBWP); #endif break; @@ -4368,7 +4481,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // The UE shall assume that when the scheduling grant is received with DCI format 1_0, then downlink resource allocation type 1 is used. nr_pdci_info_extracted->freq_dom_resource_assignment_DL = (uint16_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - if (dci_format == format1_1){ // uplink resource allocation type 0 or 1 can be used + /*if (dci_format == format1_1){ // uplink resource allocation type 0 or 1 can be used } if (dci_format == format1_0){ // only uplink resource allocation type 1 // At the moment we are supporting only format 0_0 (and not format 0_1), so we only support resource allocation type 1 (and not type 0). @@ -4388,10 +4501,10 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, pdlsch0->current_harq_pid = nr_pdci_info_extracted->harq_process_number; pdlsch0->active = 1; pdlsch0->rnti = rnti; - } + }*/ #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->freq_dom_resource_assignment_DL=%x, RIV = %d\n",nr_pdci_info_extracted->freq_dom_resource_assignment_DL,nr_pdci_info_extracted->freq_dom_resource_assignment_DL); - printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> l_RB=%d, start_RB=%d, n_RB_DLBWP=%d\n",l_RB,start_RB,n_RB_DLBWP); + //printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> l_RB=%d, start_RB=%d, n_RB_DLBWP=%d\n",l_RB,start_RB,n_RB_DLBWP); /* * According to TC 38.212 Subclause 7.3.1.2.1 (V15.2.0) (not implemented FIXME!!!) * If the CRC of the DCI format 1_0 is scrambled by C-RNTI @@ -4443,7 +4556,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // where I the number of entries in the higher layer parameter pusch-AllocationList nr_pdci_info_extracted->time_dom_resource_assignment = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - if (dci_format == format0_0 || dci_format == format0_1){ // Subclause 6.1.2.1 of [6, TS 38.214] + /*if (dci_format == format0_0 || dci_format == format0_1){ // Subclause 6.1.2.1 of [6, TS 38.214] k_offset = table_6_1_2_1_1_2_time_dom_res_alloc_A[nr_pdci_info_extracted->time_dom_resource_assignment][0]; sliv_S = table_6_1_2_1_1_2_time_dom_res_alloc_A[nr_pdci_info_extracted->time_dom_resource_assignment][1]; sliv_L = table_6_1_2_1_1_2_time_dom_res_alloc_A[nr_pdci_info_extracted->time_dom_resource_assignment][2]; @@ -4467,7 +4580,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // k_offset = table_5_1_2_1_1_5_time_dom_res_alloc_C[nr_pdci_info_extracted->time_dom_resource_assignment][0]; // sliv_S = table_5_1_2_1_1_5_time_dom_res_alloc_C[nr_pdci_info_extracted->time_dom_resource_assignment][1]; // sliv_L = table_5_1_2_1_1_5_time_dom_res_alloc_C[nr_pdci_info_extracted->time_dom_resource_assignment][2]; - } + }*/ #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->time_dom_resource_assignment=%x\n",nr_pdci_info_extracted->time_dom_resource_assignment); #endif @@ -4788,11 +4901,11 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->srs_request=%x\n",nr_pdci_info_extracted->srs_request); #endif break; - case TPC_CMD_NUMBER_FORMAT2_3: // 41 TPC_CMD_NUMBER_FORMAT2_3: (field defined for -,-,-,-,-,-,-,format2_3) - nr_pdci_info_extracted->tpc_cmd_number_format2_3 = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); + case TPC_CMD: // 41 TPC_CMD: (field defined for -,-,-,-,-,-,-,format2_3) + nr_pdci_info_extracted->tpc_cmd = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG - printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tpc_cmd_number_format2_3=%x\n",nr_pdci_info_extracted->tpc_cmd_number_format2_3); + printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tpc_cmd=%x\n",nr_pdci_info_extracted->tpc_cmd); #endif break; case CSI_REQUEST: // 42 CSI_REQUEST: (field defined for -,format0_1,-,-,-,-,-,-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index ade1e88eb9..92bdb71f0f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -145,6 +145,10 @@ typedef struct { // int calibration_flag; /// Number of soft channel bits uint32_t G; + // number of symbols + uint8_t nb_symbols; + // first symbol in the slot + uint8_t start_symbol; // decode phich uint8_t decode_phich; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 45c61a372b..603c02e380 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -624,8 +624,8 @@ typedef struct { #define SUL_IND_0_1 2 #define SLOT_FORMAT_IND 3 #define PRE_EMPTION_IND 4 -#define TPC_CMD_NUMBER 5 -#define BLOCK_NUMBER 6 +#define BLOCK_NUMBER 5 +#define CLOSE_LOOP_IND 6 #define BANDWIDTH_PART_IND 7 #define SHORT_MESSAGE_IND 8 #define SHORT_MESSAGES 9 @@ -660,7 +660,7 @@ typedef struct { #define ANTENNA_PORTS 38 #define TCI 39 #define SRS_REQUEST 40 -#define TPC_CMD_NUMBER_FORMAT2_3 41 +#define TPC_CMD 41 #define CSI_REQUEST 42 #define CBGTI 43 #define CBGFI 44 @@ -732,7 +732,7 @@ typedef struct { } NR_UE_CORESET_CCE_REG_MAPPING_t; typedef enum {allContiguousRBs=0,sameAsREGbundle=1} NR_UE_CORESET_precoder_granularity_t; - +typedef enum {tciPresentInDCI_enabled = 1} tciPresentInDCI_t; typedef struct { /* * define CORESET structure according to 38.331 @@ -771,7 +771,7 @@ typedef struct { NR_UE_CORESET_CCE_REG_MAPPING_t cce_reg_mappingType; NR_UE_CORESET_precoder_granularity_t precoderGranularity; int tciStatesPDCCH; - int tciPresentInDCI; + tciPresentInDCI_t tciPresentInDCI; uint16_t pdcchDMRSScramblingID; uint16_t rb_offset; } NR_UE_PDCCH_CORESET; @@ -1214,6 +1214,14 @@ typedef struct { PUCCH_Config_t pucch_config_dedicated_nr[NUMBER_OF_CONNECTED_eNB_MAX]; PUSCH_Config_t pusch_config; + SRS_NR srs; + + crossCarrierSchedulingConfig_t crossCarrierSchedulingConfig; + supplementaryUplink_t supplementaryUplink; + dmrs_UplinkConfig_t dmrs_UplinkConfig; + dmrs_DownlinkConfig_t dmrs_DownlinkConfig; + csi_MeasConfig_t csi_MeasConfig; + PUSCH_ServingCellConfig_t PUSCH_ServingCellConfig; #endif diff --git a/openair1/PHY/impl_defs_nr.h b/openair1/PHY/impl_defs_nr.h index b2be888e18..f3f1e39d5b 100644 --- a/openair1/PHY/impl_defs_nr.h +++ b/openair1/PHY/impl_defs_nr.h @@ -372,12 +372,104 @@ typedef struct { /* FFS TODO_NR partial structure that should be complete */ +typedef enum { + semiStatic = 0, + dynamic = 1 +} pdsch_HARQ_ACK_Codebook_t; + + +////////////////////////////////////////////////////////////////////////////////################################ +#define MAX_NR_RATE_MATCH_PATTERNS 4 +#define MAX_NR_ZP_CSI_RS_RESOURCES 32 + +typedef enum{ + dl_resourceAllocationType0 = 1, + dl_resourceAllocationType1 = 2, + dl_dynamicSwitch = 3 +} dl_resourceAllocation_t; +typedef enum{ + dl_rgb_config1 = 1, + dl_rgb_config2 = 2 +} dl_rgb_Size_t; +typedef enum { + st_n4 = 1, + st_wideband = 2 +} static_bundleSize_t; +typedef enum { + dy_1_n4 = 1, + dy_1_wideband = 2, + dy_1_n2_wideband = 3, + dy_1_n4_wideband = 4 +} bundleSizeSet1_t; +typedef enum { + dy_2_n4 = 1, + dy_2_wideband = 2, +} bundleSizeSet2_t; +typedef struct{ + bundleSizeSet1_t bundleSizeSet1; + bundleSizeSet2_t bundleSizeSet2; +} dynamic_bundleSize_t; +typedef struct { + static_bundleSize_t staticBundling; + dynamic_bundleSize_t dynamicBundlig; +} prb_bundleType_t; typedef enum { nb_code_n1 = 1, nb_code_n2 = 2 } maxNrofCodeWordsScheduledByDCI_t; - +typedef struct{ +// to be defined FIXME!!! +}rateMatchPattern_t; +typedef struct{ +// to be defined FIXME!!! +}zp_CSI_RS_Resource_t; typedef struct { +/* + * resourceAllocation + */ + dl_resourceAllocation_t dl_resourceAllocation; +/* + * corresponds to I, where I the number of entries in the higher layer parameter pdsch-AllocationList + */ + uint8_t n_pdsh_alloc_list; +/* + * rateMatchPatternToAddModList + */ + rateMatchPattern_t rateMatchPatternToAddModList[MAX_NR_RATE_MATCH_PATTERNS]; +/* + * rateMatchPatternToReleaseList + */ + uint8_t rateMatchPatternToReleaseList[MAX_NR_RATE_MATCH_PATTERNS]; + /* + * n_rateMatchPatterns indicates the number of rateMatchPatterns defined currently + */ + uint8_t n_rateMatchPatterns; + /* + * zp-CSI-RS-ResourceToAddModList + */ + zp_CSI_RS_Resource_t zp_CSI_RS_Resource[MAX_NR_ZP_CSI_RS_RESOURCES]; + /* + * zp-CSI-RS-ResourceToReleaseList + */ + uint8_t zp_CSI_RS_ResourceId[MAX_NR_ZP_CSI_RS_RESOURCES]; + /* + * n_zp-CSI-RS-Resource + */ + uint8_t n_zp_CSI_RS_ResourceId; +/* + * rgb_Size + */ + dl_rgb_Size_t dl_rgbSize; +/* + * prb-BundlingType + */ + prb_bundleType_t prbBundleType; +/* + * pdsch-HARQ-ACK-Codebook: this is part of the IE PhysicalCellGroupConfig which is used to configure cell-group specific L1 parameters (TS 38.331) + */ + pdsch_HARQ_ACK_Codebook_t pdsch_HARQ_ACK_Codebook; + ////////////////////////////////////////////////////////////////////////////////################################ + /* Maximum number of code words that a single DCI may schedule. This changes the number of MCS/RV/NDI bits in the DCI message from 1 to 2. */ @@ -415,8 +507,168 @@ typedef struct { mappingType_t mappingType; uint8_t startSymbolAndLength; } PUSCH_TimeDomainResourceAllocation_t; +////////////////////////////////////////////////////////////////////////////////################################ +typedef struct { // The IE PTRS-UplinkConfig is used to configure uplink Phase-Tracking-Reference-Signals (PTRS) +} ptrs_UplinkConfig_t; +typedef enum{ + maxCodeBlockGroupsPerTransportBlock_n2 = 2, + maxCodeBlockGroupsPerTransportBlock_n4 = 4, + maxCodeBlockGroupsPerTransportBlock_n6 = 6, + maxCodeBlockGroupsPerTransportBlock_n8 = 8 +} maxCodeBlockGroupsPerTransportBlock_t; +typedef struct{ // The IE PUSCH-ServingCellConfig is used to configure UE specific PUSCH parameters that are common across the UE's BWPs of one serving cell + maxCodeBlockGroupsPerTransportBlock_t maxCodeBlockGroupsPerTransportBlock; +} PUSCH_ServingCellConfig_t; +typedef struct{ // CSI-MeasConfig IE is used to configure CSI-RS (reference signals) + uint8_t reportTriggerSize; +} csi_MeasConfig_t; +typedef enum { + pdsch_dmrs_type1 = 1, + pdsch_dmrs_type2 = 2 +} pdsch_dmrs_type_t; +typedef enum { + pusch_dmrs_type1 = 1, + pusch_dmrs_type2 = 2 +} pusch_dmrs_type_t; +typedef enum { + pdsch_dmrs_pos0 = 0, + pdsch_dmrs_pos1 = 1, + pdsch_dmrs_pos3 = 3, +} pdsch_dmrs_AdditionalPosition_t; +typedef enum { + pusch_dmrs_pos0 = 0, + pusch_dmrs_pos1 = 1, + pusch_dmrs_pos3 = 3, +} pusch_dmrs_AdditionalPosition_t; +typedef enum { + pdsch_len1 = 1, + pdsch_len2 = 2 +} pdsch_maxLength_t; +typedef enum { + pusch_len1 = 1, + pusch_len2 = 2 +} pusch_maxLength_t; +typedef struct { // The IE DMRS-DownlinkConfig is used to configure downlink demodulation reference signals for PDSCH + pdsch_dmrs_type_t pdsch_dmrs_type; + pdsch_dmrs_AdditionalPosition_t pdsch_dmrs_AdditionalPosition; + pdsch_maxLength_t pdsch_maxLength; + uint16_t scramblingID0; + uint16_t scramblingID1; +} dmrs_DownlinkConfig_t; +typedef struct { // The IE DMRS-UplinkConfig is used to configure uplink demodulation reference signals for PUSCH + pusch_dmrs_type_t pusch_dmrs_type; + pusch_dmrs_AdditionalPosition_t pusch_dmrs_AdditionalPosition; + pusch_maxLength_t pusch_maxLength; + uint16_t scramblingID0; + uint16_t scramblingID1; +} dmrs_UplinkConfig_t; typedef struct { +/* + * Serving cell ID of a PSCell. The PCell of the Master Cell Group uses ID = 0 + */ + uint8_t servCellIndex; +}servCellIndex_t; +typedef struct{ + uint8_t cif_presence; +}own_t; +typedef struct{ + servCellIndex_t scheduling_cell_id; + uint8_t cif_InSchedulingCell; +}other_t; +typedef struct{ + own_t own; + other_t other; +}schedulingCellInfo_t; +typedef struct{ + schedulingCellInfo_t schedulingCellInfo; +} crossCarrierSchedulingConfig_t; +typedef struct{ + // this variable will be filled with '1' if SUL is supported and '0' if SUL is not supported + uint8_t supplementaryUplink; +}supplementaryUplink_t; + +typedef enum { + txConfig_codebook = 1, + txConfig_nonCodebook = 2 +} txConfig_t; +typedef enum { + f_hop_mode1 = 1, + f_hop_mode2 = 2 +} frequencyHopping_t; +typedef enum{ + ul_resourceAllocationType0 = 1, + ul_resourceAllocationType1 = 2, + ul_dynamicSwitch = 3 +} ul_resourceAllocation_t; +typedef enum{ + ul_rgb_config1 = 1, + ul_rgb_config2 = 2 +} ul_rgb_Size_t; +typedef enum { + transformPrecoder_enabled = 1, + transformPrecoder_disabled = 2 +} transformPrecoder_t; +typedef enum { + codebookSubset_fullyAndPartialAndNonCoherent = 1, + codebookSubset_partialAndNonCoherent = 2, + codebookSubset_nonCoherent = 3 +} codebookSubset_t; +typedef enum{ + betaOffset_dynamic = 1, + betaOffset_semiStatic = 2 +}betaOffset_type_t; +typedef struct{ + +} betaOffset_t; +typedef struct { + betaOffset_type_t betaOffset_type; + betaOffset_t betaOffset; +} uci_onPusch_t; +typedef struct { +/* + * txConfig + */ + txConfig_t txConfig; +/* + * frequencyHopping + */ + frequencyHopping_t frequencyHopping; +/* + * frequencyHoppingOffsetLists + */ + uint16_t frequencyHoppingOffsetLists[4]; + // n_frequencyHoppingOffsetLists contains the number of offsets listed. We can list up to 4 offsets + uint8_t n_frequencyHoppingOffsetLists; +/* + * resourceAllocation + */ + ul_resourceAllocation_t ul_resourceAllocation; +/* + * rgb_Size + */ + ul_rgb_Size_t ul_rgbSize; +/* + * corresponds to I, where I the number of entries in the higher layer parameter pusch-AllocationList + */ + uint8_t n_push_alloc_list; +/* + * transformPrecoder + */ +transformPrecoder_t transformPrecoder; +/* + * codebookSubset + */ +codebookSubset_t codebookSubset; +/* + * maxRank + */ +uint8_t maxRank; +/* + * uci_onPusch + */ +uci_onPusch_t uci_onPusch; +////////////////////////////////////////////////////////////////////////////////################################ PUSCH_PowerControl_t pusch_PowerControl; PUSCH_TimeDomainResourceAllocation_t *pusch_TimeDomainResourceAllocation[MAX_NR_OF_UL_ALLOCATIONS]; } PUSCH_Config_t; @@ -649,11 +901,6 @@ typedef struct { typedef uint16_t RNTI_value_t; -typedef enum { - semiStatic = 0, - dynamic = 1 -} pdsch_HARQ_ACK_Codebook_t; - typedef struct { /* -- Enables spatial bundling of HARQ ACKs. It is configured per cell group (i.e. for all the cells within the cell group) for PUCCH @@ -750,6 +997,12 @@ typedef enum { n12_dl_harq = 12, n16_dl_harq = 16 } nrofHARQ_ProcessesForPDSCH_t; +typedef enum{ + maxCodeBlockGroupsPerTransportBlock_dl_n2 = 2, + maxCodeBlockGroupsPerTransportBlock_dl_n4 = 4, + maxCodeBlockGroupsPerTransportBlock_dl_n6 = 6, + maxCodeBlockGroupsPerTransportBlock_dl_n8 = 8 +} maxCodeBlockGroupsPerTransportBlock_dl_t; typedef struct { /* @@ -772,7 +1025,14 @@ typedef struct { -- If the field is absent, the UE sends the HARQ feedback on the PUCCH of the SpCell of this cell group. */ uint8_t pucch_Cell; - +/* + * maxCodeBlockGroupsPerTransportBlock_dl_t + */ + maxCodeBlockGroupsPerTransportBlock_dl_t maxCodeBlockGroupsPerTransportBlock_dl; +/* + * codeBlockGroupFlushIndicator (boolean) + */ + uint8_t codeBlockGroupFlushIndicator; } PDSCH_ServingCellConfig_t; /*********************************************************************** diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 53d3ae339b..188beb3ec7 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -49,6 +49,8 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ if(scheduled_response != NULL){ NR_UE_PDCCH *pdcch_vars2 = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[0][0]; + NR_UE_DLSCH_t *dlsch0 = PHY_vars_UE_g[module_id][cc_id]->dlsch[0][0]; + NR_UE_ULSCH_t *ulsch0 = PHY_vars_UE_g[module_id][cc_id]->ulsch[0]; if(scheduled_response->dl_config != NULL){ fapi_nr_dl_config_request_t *dl_config = scheduled_response->dl_config; @@ -86,16 +88,47 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ //pdcch_vars2->coreset[i].tciStatesPDCCH; //pdcch_vars2->coreset[i].tciPresentInDCI; pdcch_vars2->coreset[i].pdcchDMRSScramblingID = dci_config->coreset.pdcch_dmrs_scrambling_id; + }else{ //FAPI_NR_DL_CONFIG_TYPE_DLSCH // dlsch config pdu - } + fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu = &dl_config->dl_config_list[i].dlsch_config_pdu.dlsch_config_rel15; + uint8_t current_harq_pid = dlsch_config_pdu->harq_process_nbr; + dlsch0->current_harq_pid = current_harq_pid; + dlsch0->active = 1; + dlsch0->harq_processes[current_harq_pid]->nb_rb = dlsch_config_pdu->number_rbs; + dlsch0->harq_processes[current_harq_pid]->start_rb = dlsch_config_pdu->start_rb; + dlsch0->harq_processes[current_harq_pid]->nb_symbols = dlsch_config_pdu->number_symbols; + dlsch0->harq_processes[current_harq_pid]->start_symbol = dlsch_config_pdu->start_symbol; + dlsch0->harq_processes[current_harq_pid]->mcs = dlsch_config_pdu->mcs; + dlsch0->harq_processes[current_harq_pid]->DCINdi = dlsch_config_pdu->ndi; + dlsch0->harq_processes[current_harq_pid]->rvidx = dlsch_config_pdu->rv; + dlsch0->g_pucch = dlsch_config_pdu->accumulated_delta_PUCCH; + dlsch0->harq_processes[current_harq_pid]->harq_ack.pucch_resource_indicator = dlsch_config_pdu->pucch_resource_id; + dlsch0->harq_processes[current_harq_pid]->harq_ack.slot_for_feedback_ack = dlsch_config_pdu->pdsch_to_harq_feedback_time_ind; + //pdlsch0->rnti = rnti; + } } }else{ pdcch_vars2->nb_search_space = 0; } if(scheduled_response->ul_config != NULL){ - + fapi_nr_ul_config_request_t *ul_config = scheduled_response->ul_config; + for(i=0; inumber_pdus; ++i){ + if(ul_config->ul_config_list[i].pdu_type == FAPI_NR_DL_CONFIG_TYPE_PUSCH){ + // pusch config pdu + fapi_nr_ul_config_pusch_pdu_rel15_t *pusch_config_pdu = &ul_config->ul_config_list[i].ulsch_config_pdu.ulsch_pdu_rel15; + uint8_t current_harq_pid = pusch_config_pdu->harq_process_nbr; + ulsch0->harq_processes[current_harq_pid]->nb_rb = pusch_config_pdu->number_rbs; + ulsch0->harq_processes[current_harq_pid]->first_rb = pusch_config_pdu->start_rb; + ulsch0->harq_processes[current_harq_pid]->nb_symbols = pusch_config_pdu->number_symbols; + ulsch0->harq_processes[current_harq_pid]->start_symbol = pusch_config_pdu->start_symbol; + ulsch0->harq_processes[current_harq_pid]->mcs = pusch_config_pdu->mcs; + ulsch0->harq_processes[current_harq_pid]->DCINdi = pusch_config_pdu->ndi; + ulsch0->harq_processes[current_harq_pid]->rvidx = pusch_config_pdu->rv; + ulsch0->f_pusch = pusch_config_pdu->absolute_delta_PUSCH; + } + } }else{ } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 69c8ca6845..309d3a42ba 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -538,6 +538,233 @@ NR_UE_L2_STATE_t nr_ue_scheduler( return CONNECTION_OK; } +////////////// +/* + * This code contains all the functions needed to process all dci fields. + * These functions are going to be called by function nr_ue_process_dci + */ + +int8_t nr_ue_process_dci_freq_dom_resource_assignment( + fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu, + fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, + uint16_t n_RB_ULBWP, + uint16_t n_RB_DLBWP, + uint16_t riv +){ + uint16_t l_RB; + uint16_t start_RB; + uint16_t tmp_RIV; + +/* + * TS 38.214 subclause 5.1.2.2 Resource allocation in frequency domain (downlink) + * when the scheduling grant is received with DCI format 1_0, then downlink resource allocation type 1 is used + */ + if(dlsch_config_pdu != NULL){ + /* + * TS 38.214 subclause 5.1.2.2.1 Downlink resource allocation type 0 + */ + /* + * TS 38.214 subclause 5.1.2.2.2 Downlink resource allocation type 1 + */ + // For resource allocation type 1, the resource allocation field consists of a resource indication value (RIV): + // RIV = n_RB_DLBWP * (l_RB - 1) + start_RB if (l_RB - 1) <= floor (n_RB_DLBWP/2) + // RIV = n_RB_DLBWP * (n_RB_DLBWP - l_RB + 1) + (n_RB_DLBWP - 1 - start_RB) if (l_RB - 1) > floor (n_RB_DLBWP/2) + // the following two expressions apply only if (l_RB - 1) <= floor (n_RB_DLBWP/2) + l_RB = floor(riv/n_RB_DLBWP) + 1; + start_RB = riv%n_RB_DLBWP; + // if (l_RB - 1) > floor (n_RB_DLBWP/2) we need to recalculate them using the following lines + tmp_RIV = n_RB_DLBWP * (l_RB - 1) + start_RB; + if (tmp_RIV != riv) { // then (l_RB - 1) > floor (n_RB_DLBWP/2) and we need to recalculate l_RB and start_RB + l_RB = n_RB_DLBWP - l_RB + 2; + start_RB = n_RB_DLBWP - start_RB - 1; + } + dlsch_config_pdu->number_rbs = l_RB; + dlsch_config_pdu->start_rb = start_RB; + } + if(ulsch_config_pdu != NULL){ +/* + * TS 38.214 subclause 6.1.2.2 Resource allocation in frequency domain (uplink) + */ + /* + * TS 38.214 subclause 6.1.2.2.1 Uplink resource allocation type 0 + */ + /* + * TS 38.214 subclause 6.1.2.2.2 Uplink resource allocation type 1 + */ + // For resource allocation type 1, the resource allocation field consists of a resource indication value (RIV): + // RIV = n_RB_ULBWP * (l_RB - 1) + start_RB if (l_RB - 1) <= floor (n_RB_ULBWP/2) + // RIV = n_RB_ULBWP * (n_RB_ULBWP - l_RB + 1) + (n_RB_ULBWP - 1 - start_RB) if (l_RB - 1) > floor (n_RB_ULBWP/2) + // the following two expressions apply only if (l_RB - 1) <= floor (n_RB_ULBWP/2) + l_RB = floor(riv/n_RB_ULBWP) + 1; + start_RB = riv%n_RB_ULBWP; + // if (l_RB - 1) > floor (n_RB_ULBWP/2) we need to recalculate them using the following lines + tmp_RIV = n_RB_ULBWP * (l_RB - 1) + start_RB; + if (tmp_RIV != riv) { // then (l_RB - 1) > floor (n_RB_ULBWP/2) and we need to recalculate l_RB and start_RB + l_RB = n_RB_ULBWP - l_RB + 2; + start_RB = n_RB_ULBWP - start_RB - 1; + } + ulsch_config_pdu->number_rbs = l_RB; + ulsch_config_pdu->start_rb = start_RB; + } + return 0; +} + +int8_t nr_ue_process_dci_time_dom_resource_assignment( + fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu, + fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, + uint8_t time_domain_ind, + long dmrs_typeA_pos +){ + uint8_t k_offset; + uint8_t sliv_S; + uint8_t sliv_L; + uint8_t table_5_1_2_1_1_2_time_dom_res_alloc_A[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 + {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?12:11}, // row index 1 + {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?10:9}, // row index 2 + {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?9:8}, // row index 3 + {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?7:6}, // row index 4 + {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?5:4}, // row index 5 + {0,(dmrs_typeA_pos == 2)?9:10,(dmrs_typeA_pos == 2)?4:4}, // row index 6 + {0,(dmrs_typeA_pos == 2)?4:6, (dmrs_typeA_pos == 2)?4:4}, // row index 7 + {0,5,7}, // row index 8 + {0,5,2}, // row index 9 + {0,9,2}, // row index 10 + {0,12,2}, // row index 11 + {0,1,13}, // row index 12 + {0,1,6}, // row index 13 + {0,2,4}, // row index 14 + {0,4,7}, // row index 15 + {0,8,4} // row index 16 + }; + uint8_t table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 + {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?6:5}, // row index 1 + {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?10:9}, // row index 2 + {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?9:8}, // row index 3 + {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?7:6}, // row index 4 + {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?5:4}, // row index 5 + {0,(dmrs_typeA_pos == 2)?6:8, (dmrs_typeA_pos == 2)?4:2}, // row index 6 + {0,(dmrs_typeA_pos == 2)?4:6, (dmrs_typeA_pos == 2)?4:4}, // row index 7 + {0,5,6}, // row index 8 + {0,5,2}, // row index 9 + {0,9,2}, // row index 10 + {0,10,2}, // row index 11 + {0,1,11}, // row index 12 + {0,1,6}, // row index 13 + {0,2,4}, // row index 14 + {0,4,6}, // row index 15 + {0,8,4} // row index 16 + }; + uint8_t table_5_1_2_1_1_4_time_dom_res_alloc_B[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 + {0,2,2}, // row index 1 + {0,4,2}, // row index 2 + {0,6,2}, // row index 3 + {0,8,2}, // row index 4 + {0,10,2}, // row index 5 + {1,2,2}, // row index 6 + {1,4,2}, // row index 7 + {0,2,4}, // row index 8 + {0,4,4}, // row index 9 + {0,6,4}, // row index 10 + {0,8,4}, // row index 11 + {0,10,4}, // row index 12 + {0,2,7}, // row index 13 + {0,(dmrs_typeA_pos == 2)?2:3,(dmrs_typeA_pos == 2)?12:11}, // row index 14 + {1,2,4}, // row index 15 + {0,0,0} // row index 16 + }; + uint8_t table_5_1_2_1_1_5_time_dom_res_alloc_C[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 + {0,2,2}, // row index 1 + {0,4,2}, // row index 2 + {0,6,2}, // row index 3 + {0,8,2}, // row index 4 + {0,10,2}, // row index 5 + {0,0,0}, // row index 6 + {0,0,0}, // row index 7 + {0,2,4}, // row index 8 + {0,4,4}, // row index 9 + {0,6,4}, // row index 10 + {0,8,4}, // row index 11 + {0,10,4}, // row index 12 + {0,2,7}, // row index 13 + {0,(dmrs_typeA_pos == 2)?2:3,(dmrs_typeA_pos == 2)?12:11}, // row index 14 + {0,0,6}, // row index 15 + {0,2,6} // row index 16 + }; + uint8_t mu_pusch = 1; + // definition table j Table 6.1.2.1.1-4 + uint8_t j = (mu_pusch==3)?3:(mu_pusch==2)?2:1; + uint8_t table_6_1_2_1_1_2_time_dom_res_alloc_A[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1 + {j, 0,14}, // row index 1 + {j, 0,12}, // row index 2 + {j, 0,10}, // row index 3 + {j, 2,10}, // row index 4 + {j, 4,10}, // row index 5 + {j, 4,8}, // row index 6 + {j, 4,6}, // row index 7 + {j+1,0,14}, // row index 8 + {j+1,0,12}, // row index 9 + {j+1,0,10}, // row index 10 + {j+2,0,14}, // row index 11 + {j+2,0,12}, // row index 12 + {j+2,0,10}, // row index 13 + {j, 8,6}, // row index 14 + {j+3,0,14}, // row index 15 + {j+3,0,10} // row index 16 + }; + uint8_t table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1 + {j, 0,8}, // row index 1 + {j, 0,12}, // row index 2 + {j, 0,10}, // row index 3 + {j, 2,10}, // row index 4 + {j, 4,4}, // row index 5 + {j, 4,8}, // row index 6 + {j, 4,6}, // row index 7 + {j+1,0,8}, // row index 8 + {j+1,0,12}, // row index 9 + {j+1,0,10}, // row index 10 + {j+2,0,6}, // row index 11 + {j+2,0,12}, // row index 12 + {j+2,0,10}, // row index 13 + {j, 8,4}, // row index 14 + {j+3,0,8}, // row index 15 + {j+3,0,10} // row index 16 + }; + +/* + * TS 38.214 subclause 5.1.2.1 Resource allocation in time domain (downlink) + */ + if(dlsch_config_pdu != NULL){ + k_offset = table_5_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind][0]; + sliv_S = table_5_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind][1]; + sliv_L = table_5_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind][2]; + // k_offset = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][0]; + // sliv_S = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][1]; + // sliv_L = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][2]; + // k_offset = table_5_1_2_1_1_4_time_dom_res_alloc_B[nr_pdci_info_extracted->time_dom_resource_assignment][0]; + // sliv_S = table_5_1_2_1_1_4_time_dom_res_alloc_B[nr_pdci_info_extracted->time_dom_resource_assignment][1]; + // sliv_L = table_5_1_2_1_1_4_time_dom_res_alloc_B[nr_pdci_info_extracted->time_dom_resource_assignment][2]; + // k_offset = table_5_1_2_1_1_5_time_dom_res_alloc_C[nr_pdci_info_extracted->time_dom_resource_assignment][0]; + // sliv_S = table_5_1_2_1_1_5_time_dom_res_alloc_C[nr_pdci_info_extracted->time_dom_resource_assignment][1]; + // sliv_L = table_5_1_2_1_1_5_time_dom_res_alloc_C[nr_pdci_info_extracted->time_dom_resource_assignment][2]; + dlsch_config_pdu->number_symbols = sliv_L; + dlsch_config_pdu->start_symbol = sliv_S; + } /* + * TS 38.214 subclause 6.1.2.1 Resource allocation in time domain (uplink) + */ + if(ulsch_config_pdu != NULL){ + k_offset = table_6_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind][0]; + sliv_S = table_6_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind][1]; + sliv_L = table_6_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind][2]; + // k_offset = table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][0]; + // sliv_S = table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][1]; + // sliv_L = table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][2]; + ulsch_config_pdu->number_symbols = sliv_L; + ulsch_config_pdu->start_symbol = sliv_S; + } + return 0; +} +////////////// + int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format){ NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); @@ -546,50 +773,63 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fa const uint16_t n_RB_ULBWP = 106; const uint16_t n_RB_DLBWP = 106; - uint32_t k_offset; - uint32_t sliv_S; - uint32_t sliv_L; - - uint32_t l_RB; - uint32_t start_RB; - uint32_t tmp_RIV; switch(dci_format){ case format0_0: - /* TIME_DOM_RESOURCE_ASSIGNMENT */ - // 0, 1, 2, 3, or 4 bits as defined in: - // Subclause 6.1.2.1 of [6, TS 38.214] for formats format0_0,format0_1 - // Subclause 5.1.2.1 of [6, TS 38.214] for formats format1_0,format1_1 - // The bitwidth for this field is determined as log2(I) bits, - // where I the number of entries in the higher layer parameter pusch-AllocationList - k_offset = table_6_1_2_1_1_2_time_dom_res_alloc_A[dci->time_dom_resource_assignment][0]; - sliv_S = table_6_1_2_1_1_2_time_dom_res_alloc_A[dci->time_dom_resource_assignment][1]; - sliv_L = table_6_1_2_1_1_2_time_dom_res_alloc_A[dci->time_dom_resource_assignment][2]; - - /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */ - // At the moment we are supporting only format 1_0 (and not format 1_1), so we only support resource allocation type 1 (and not type 0). - // For resource allocation type 1, the resource allocation field consists of a resource indication value (RIV): - // RIV = n_RB_ULBWP * (l_RB - 1) + start_RB if (l_RB - 1) <= floor (n_RB_ULBWP/2) - // RIV = n_RB_ULBWP * (n_RB_ULBWP - l_RB + 1) + (n_RB_ULBWP - 1 - start_RB) if (l_RB - 1) > floor (n_RB_ULBWP/2) - // the following two expressions apply only if (l_RB - 1) <= floor (n_RB_ULBWP/2) - l_RB = floor(dci->freq_dom_resource_assignment_DL/n_RB_ULBWP) + 1; - start_RB = dci->freq_dom_resource_assignment_DL%n_RB_ULBWP; - // if (l_RB - 1) > floor (n_RB_ULBWP/2) we need to recalculate them using the following lines - tmp_RIV = n_RB_ULBWP * (l_RB - 1) + start_RB; - if (tmp_RIV != dci->freq_dom_resource_assignment_DL) { // then (l_RB - 1) > floor (n_RB_ULBWP/2) and we need to recalculate l_RB and start_RB - l_RB = n_RB_ULBWP - l_RB + 2; - start_RB = n_RB_ULBWP - start_RB - 1; - } - - // UL_CONFIG_REQ +/* + * with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI + * 0 IDENTIFIER_DCI_FORMATS: + * 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0 + * 24 MCS: + * 25 NDI: + * 26 RV: + * 27 HARQ_PROCESS_NUMBER: + * 32 TPC_PUSCH: + * 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space + * 50 SUL_IND_0_0: + */ ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_PUSCH; ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti; - fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu = &ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15; - ulsch_config_pdu->number_rbs = l_RB; - ulsch_config_pdu->start_rb = start_RB; - ulsch_config_pdu->number_symbols = sliv_L; - ulsch_config_pdu->start_symbol = sliv_S; - ulsch_config_pdu->mcs = dci->mcs; + fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu_0_0 = &ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15; + /* IDENTIFIER_DCI_FORMATS */ + /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */ + nr_ue_process_dci_freq_dom_resource_assignment(&ulsch_config_pdu_0_0,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL); + /* TIME_DOM_RESOURCE_ASSIGNMENT */ + nr_ue_process_dci_time_dom_resource_assignment(&ulsch_config_pdu_0_0,NULL,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); + /* FREQ_HOPPING_FLAG */ + if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.resource_allocation != 0) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.frequency_hopping !=0)) + ulsch_config_pdu_0_0->pusch_freq_hopping = (dci->freq_hopping_flag == 0)? pusch_freq_hopping_disabled:pusch_freq_hopping_enabled; + /* MCS */ + ulsch_config_pdu_0_0->mcs = dci->mcs; + /* NDI */ + ulsch_config_pdu_0_0->ndi = dci->ndi; + /* RV */ + ulsch_config_pdu_0_0->rv = dci->rv; + /* HARQ_PROCESS_NUMBER */ + ulsch_config_pdu_0_0->harq_process_nbr = dci->harq_process_number; + /* TPC_PUSCH */ + // according to TS 38.213 Table Table 7.1.1-1 + if (dci->tpc_pusch == 0) { + ulsch_config_pdu_0_0->accumulated_delta_PUSCH = -1; + ulsch_config_pdu_0_0->absolute_delta_PUSCH = -4; + } + if (dci->tpc_pusch == 1) { + ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 0; + ulsch_config_pdu_0_0->absolute_delta_PUSCH = -1; + } + if (dci->tpc_pusch == 2) { + ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 1; + ulsch_config_pdu_0_0->absolute_delta_PUSCH = 1; + } + if (dci->tpc_pusch == 3) { + ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 3; + ulsch_config_pdu_0_0->absolute_delta_PUSCH = 4; + } + /* SUL_IND_0_0 */ // To be implemented, FIXME!!! + // UL_CONFIG_REQ //ulsch0->harq_processes[dci->harq_process_number]->first_rb = start_RB; //ulsch0->harq_processes[dci->harq_process_number]->nb_rb = l_RB; //ulsch0->harq_processes[dci->harq_process_number]->mcs = dci->mcs; @@ -597,48 +837,170 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fa break; case format0_1: +/* + * with CRC scrambled by C-RNTI or CS-RNTI or SP-CSI-RNTI or new-RNTI + * 0 IDENTIFIER_DCI_FORMATS: + * 1 CARRIER_IND + * 2 SUL_IND_0_1 + * 7 BANDWIDTH_PART_IND + * 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0 + * 24 MCS: + * 25 NDI: + * 26 RV: + * 27 HARQ_PROCESS_NUMBER: + * 29 FIRST_DAI + * 30 SECOND_DAI + * 32 TPC_PUSCH: + * 36 SRS_RESOURCE_IND: + * 37 PRECOD_NBR_LAYERS: + * 38 ANTENNA_PORTS: + * 40 SRS_REQUEST: + * 42 CSI_REQUEST: + * 43 CBGTI + * 45 PTRS_DMRS + * 46 BETA_OFFSET_IND + * 47 DMRS_SEQ_INI + * 48 UL_SCH_IND + * 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space + */ + ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_PUSCH; + ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti; + fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu_0_1 = &ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15; + /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */ + nr_ue_process_dci_freq_dom_resource_assignment(&ulsch_config_pdu_0_1,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL); + /* TIME_DOM_RESOURCE_ASSIGNMENT */ + nr_ue_process_dci_time_dom_resource_assignment(&ulsch_config_pdu_0_1,NULL,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); + /* FREQ_HOPPING_FLAG */ + if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.resource_allocation != 0) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.frequency_hopping !=0)) + ulsch_config_pdu_0_1->pusch_freq_hopping = (dci->freq_hopping_flag == 0)? pusch_freq_hopping_disabled:pusch_freq_hopping_enabled; + /* MCS */ + ulsch_config_pdu_0_1->mcs = dci->mcs; + /* NDI */ + ulsch_config_pdu_0_1->ndi = dci->ndi; + /* RV */ + ulsch_config_pdu_0_1->rv = dci->rv; + /* HARQ_PROCESS_NUMBER */ + ulsch_config_pdu_0_1->harq_process_nbr = dci->harq_process_number; + /* FIRST_DAI */ //To be implemented, FIXME!!! + /* SECOND_DAI */ //To be implemented, FIXME!!! + /* TPC_PUSCH */ + // according to TS 38.213 Table Table 7.1.1-1 + if (dci->tpc_pusch == 0) { + ulsch_config_pdu_0_0->accumulated_delta_PUSCH = -1; + ulsch_config_pdu_0_0->absolute_delta_PUSCH = -4; + } + if (dci->tpc_pusch == 1) { + ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 0; + ulsch_config_pdu_0_0->absolute_delta_PUSCH = -1; + } + if (dci->tpc_pusch == 2) { + ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 1; + ulsch_config_pdu_0_0->absolute_delta_PUSCH = 1; + } + if (dci->tpc_pusch == 3) { + ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 3; + ulsch_config_pdu_0_0->absolute_delta_PUSCH = 4; + } break; case format1_0: - - /* TIME_DOM_RESOURCE_ASSIGNMENT */ - // Subclause 5.1.2.1 of [6, TS 38.214] - // the Time domain resource assignment field of the DCI provides a row index of a higher layer configured table pdsch-symbolAllocation - // FIXME! To clarify which parameters to update after reception of row index - k_offset = table_5_1_2_1_1_2_time_dom_res_alloc_A[dci->time_dom_resource_assignment][0]; - sliv_S = table_5_1_2_1_1_2_time_dom_res_alloc_A[dci->time_dom_resource_assignment][1]; - sliv_L = table_5_1_2_1_1_2_time_dom_res_alloc_A[dci->time_dom_resource_assignment][2]; - - - /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */ - // only uplink resource allocation type 1 - // At the moment we are supporting only format 0_0 (and not format 0_1), so we only support resource allocation type 1 (and not type 0). - // For resource allocation type 1, the resource allocation field consists of a resource indication value (RIV): - // RIV = n_RB_DLBWP * (l_RB - 1) + start_RB if (l_RB - 1) <= floor (n_RB_DLBWP/2) - // RIV = n_RB_DLBWP * (n_RB_DLBWP - l_RB + 1) + (n_RB_DLBWP - 1 - start_RB) if (l_RB - 1) > floor (n_RB_DLBWP/2) - // the following two expressions apply only if (l_RB - 1) <= floor (n_RB_DLBWP/2) - - l_RB = floor(dci->freq_dom_resource_assignment_DL/n_RB_DLBWP) + 1; - start_RB = dci->freq_dom_resource_assignment_DL%n_RB_DLBWP; - // if (l_RB - 1) > floor (n_RB_DLBWP/2) we need to recalculate them using the following lines - tmp_RIV = n_RB_DLBWP * (l_RB - 1) + start_RB; - if (tmp_RIV != dci->freq_dom_resource_assignment_DL) { // then (l_RB - 1) > floor (n_RB_DLBWP/2) and we need to recalculate l_RB and start_RB - l_RB = n_RB_DLBWP - l_RB + 2; - start_RB = n_RB_DLBWP - start_RB - 1; - } - - - // DL_CONFIG_REQ +/* + * with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI + * 0 IDENTIFIER_DCI_FORMATS: + * 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 + * 24 MCS: + * 25 NDI: + * 26 RV: + * 27 HARQ_PROCESS_NUMBER: + * 28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI + * 33 TPC_PUCCH: + * 34 PUCCH_RESOURCE_IND: + * 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND: + * 55 RESERVED_NR_DCI + * with CRC scrambled by P-RNTI + * 8 SHORT_MESSAGE_IND + * 9 SHORT_MESSAGES + * 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 + * 24 MCS: + * 31 TB_SCALING + * 55 RESERVED_NR_DCI + * with CRC scrambled by SI-RNTI + * 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 + * 24 MCS: + * 26 RV: + * 55 RESERVED_NR_DCI + * with CRC scrambled by RA-RNTI + * 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 + * 24 MCS: + * 31 TB_SCALING + * 55 RESERVED_NR_DCI + * with CRC scrambled by TC-RNTI + * 0 IDENTIFIER_DCI_FORMATS: + * 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 + * 24 MCS: + * 25 NDI: + * 26 RV: + * 27 HARQ_PROCESS_NUMBER: + * 28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI + * 33 TPC_PUCCH: + */ dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti; - fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; - dlsch_config_pdu->number_rbs = l_RB; - dlsch_config_pdu->start_rb = start_RB; - dlsch_config_pdu->number_symbols = sliv_L; - dlsch_config_pdu->start_symbol = sliv_S; - dlsch_config_pdu->mcs = dci->mcs; - + fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_0 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; + /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */ + nr_ue_process_dci_freq_dom_resource_assignment(NULL,&dlsch_config_pdu_1_0,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL); + /* TIME_DOM_RESOURCE_ASSIGNMENT */ + nr_ue_process_dci_time_dom_resource_assignment(NULL,&dlsch_config_pdu_1_0,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); + /* VRB_TO_PRB_MAPPING */ + dlsch_config_pdu_1_0->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping == 0) ? vrb_to_prb_mapping_non_interleaved:vrb_to_prb_mapping_interleaved; + /* MCS */ + dlsch_config_pdu_1_0->mcs = dci->mcs; + /* NDI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ + dlsch_config_pdu_1_0->ndi = dci->ndi; + /* RV (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ + dlsch_config_pdu_1_0->rv = dci->rv; + /* HARQ_PROCESS_NUMBER (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ + dlsch_config_pdu_1_0->harq_process_nbr = dci->harq_process_number; + /* DAI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ + dlsch_config_pdu_1_0->dai = dci ->dai; + /* TB_SCALING (only if CRC scrambled by P-RNTI or RA-RNTI) */ + // according to TS 38.214 Table 5.1.3.2-3 + if (dci->tb_scaling == 0) dlsch_config_pdu_1_0->scaling_factor_S = 1; + if (dci->tb_scaling == 1) dlsch_config_pdu_1_0->scaling_factor_S = 0.5; + if (dci->tb_scaling == 2) dlsch_config_pdu_1_0->scaling_factor_S = 0.25; + if (dci->tb_scaling == 3) dlsch_config_pdu_1_0->scaling_factor_S = 0; // value not defined in table + /* TPC_PUCCH (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ + // according to TS 38.213 Table 7.2.1-1 + if (dci->tpc_pucch == 0) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = -1; + if (dci->tpc_pucch == 1) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 0; + if (dci->tpc_pucch == 2) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 1; + if (dci->tpc_pucch == 3) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 3; + /* PUCCH_RESOURCE_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/ + if (dci->pucch_resource_ind == 0) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 1st value of resourceList FIXME!!! + if (dci->pucch_resource_ind == 1) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 2nd value of resourceList FIXME!! + if (dci->pucch_resource_ind == 2) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 3rd value of resourceList FIXME!! + if (dci->pucch_resource_ind == 3) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 4th value of resourceList FIXME!! + if (dci->pucch_resource_ind == 4) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 5th value of resourceList FIXME!! + if (dci->pucch_resource_ind == 5) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 6th value of resourceList FIXME!! + if (dci->pucch_resource_ind == 6) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 7th value of resourceList FIXME!! + if (dci->pucch_resource_ind == 7) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 8th value of resourceList FIXME!! + /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/ + dlsch_config_pdu_1_0-> pdsch_to_harq_feedback_time_ind = dci->pdsch_to_harq_feedback_time_ind; + // DL_CONFIG_REQ //pdlsch0_harq->nb_rb = l_RB; //pdlsch0->current_harq_pid = dci->harq_process_number; //pdlsch0->active = 1; @@ -650,6 +1012,81 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fa break; case format1_1: +/* + * with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI + * 0 IDENTIFIER_DCI_FORMATS: + * 1 CARRIER_IND: + * 7 BANDWIDTH_PART_IND: + * 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL: + * 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits, + * 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0 + * 14 PRB_BUNDLING_SIZE_IND: + * 15 RATE_MATCHING_IND: + * 16 ZP_CSI_RS_TRIGGER: + * 18 TB1_MCS: + * 19 TB1_NDI: + * 20 TB1_RV: + * 21 TB2_MCS: + * 22 TB2_NDI: + * 23 TB2_RV: + * 27 HARQ_PROCESS_NUMBER: + * 28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI + * 33 TPC_PUCCH: + * 34 PUCCH_RESOURCE_IND: + * 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND: + * 38 ANTENNA_PORTS: + * 39 TCI: + * 40 SRS_REQUEST: + * 43 CBGTI: + * 44 CBGFI: + * 47 DMRS_SEQ_INI: + */ + dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; + dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti; + fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_1 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; + /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */ + nr_ue_process_dci_freq_dom_resource_assignment(NULL,&dlsch_config_pdu_1_1,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL); + /* TIME_DOM_RESOURCE_ASSIGNMENT */ + nr_ue_process_dci_time_dom_resource_assignment(NULL,&dlsch_config_pdu_1_1,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); + /* VRB_TO_PRB_MAPPING */ + if (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.resource_allocation != 0) + dlsch_config_pdu_1_1->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping == 0) ? vrb_to_prb_mapping_non_interleaved:vrb_to_prb_mapping_interleaved; + /* MCS (for transport block 1)*/ + dlsch_config_pdu_1_1->mcs = dci->tb1_mcs; + /* NDI (for transport block 1)*/ + dlsch_config_pdu_1_1->ndi = dci->tb1_ndi; + /* RV (for transport block 1)*/ + dlsch_config_pdu_1_1->rv = dci->tb1_rv; + /* MCS (for transport block 2)*/ + dlsch_config_pdu_1_1->tb2_mcs = dci->tb2_mcs; + /* NDI (for transport block 2)*/ + dlsch_config_pdu_1_1->tb2_ndi = dci->tb2_ndi; + /* RV (for transport block 2)*/ + dlsch_config_pdu_1_1->tb2_rv = dci->tb2_rv; + /* HARQ_PROCESS_NUMBER */ + dlsch_config_pdu_1_1->harq_process_nbr = dci->harq_process_number; + /* DAI */ + dlsch_config_pdu_1_0->dai = dci ->dai; + /* TPC_PUCCH */ + // according to TS 38.213 Table 7.2.1-1 + if (dci->tpc_pucch == 0) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = -1; + if (dci->tpc_pucch == 1) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 0; + if (dci->tpc_pucch == 2) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 1; + if (dci->tpc_pucch == 3) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 3; + /* PUCCH_RESOURCE_IND */ + if (dci->pucch_resource_ind == 0) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 1st value of resourceList FIXME!!! + if (dci->pucch_resource_ind == 1) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 2nd value of resourceList FIXME!! + if (dci->pucch_resource_ind == 2) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 3rd value of resourceList FIXME!! + if (dci->pucch_resource_ind == 3) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 4th value of resourceList FIXME!! + if (dci->pucch_resource_ind == 4) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 5th value of resourceList FIXME!! + if (dci->pucch_resource_ind == 5) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 6th value of resourceList FIXME!! + if (dci->pucch_resource_ind == 6) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 7th value of resourceList FIXME!! + if (dci->pucch_resource_ind == 7) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 8th value of resourceList FIXME!! + /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */ + // according to TS 38.213 Table 9.2.3-1 + dlsch_config_pdu_1_1-> pdsch_to_harq_feedback_time_ind = + mac->phy_config.config_req.ul_bwp_dedicated.pucch_config_dedicated.dl_data_to_ul_ack[dci->pdsch_to_harq_feedback_time_ind]; + break; case format2_0: @@ -685,6 +1122,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fa /// else normal DL-SCH grant } + return 0; } int8_t nr_ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe){ From 2dec82b336fe55dfb63c3413064e78fb04af790b Mon Sep 17 00:00:00 2001 From: yilmazt Date: Tue, 18 Sep 2018 10:12:34 +0200 Subject: [PATCH 093/114] Working polartest --- openair1/PHY/CODING/TESTBENCH/polartest.c | 249 ++++++++-------- .../CODING/nrPolar_tools/nr_polar_decoder.c | 269 +++++++++++++++++- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 17 ++ .../CODING/nrPolar_tools/nr_polar_encoder.c | 82 ++++++ 4 files changed, 494 insertions(+), 123 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index d379aaf58e..0aa0dd118f 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -10,8 +10,8 @@ #include "PHY/CODING/coding_defs.h" #include "SIMULATION/TOOLS/sim.h" -//#define DEBUG_POLAR_PARAMS //#define DEBUG_DCI_POLAR_PARAMS +//#define DEBUG_POLAR_TIMING int main(int argc, char *argv[]) { @@ -24,7 +24,6 @@ int main(int argc, char *argv[]) { randominit(0); crcTableInit(); - uint32_t crc; //Default simulation values (Aim for iterations = 1000000.) int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, -1=UCI double SNRstart = -20.0, SNRstop = 0.0, SNRinc= 0.5; //dB @@ -34,14 +33,13 @@ int main(int argc, char *argv[]) { int8_t decoderState=0, blockErrorState=0; //0 = Success, -1 = Decoding failed, 1 = Block Error. uint16_t testLength = 0, coderLength = 0, blockErrorCumulative=0, bitErrorCumulative=0; double timeEncoderCumulative = 0, timeDecoderCumulative = 0; - uint8_t aggregation_level, decoderListSize, pathMetricAppr; + uint8_t aggregation_level = 8, decoderListSize = 8, pathMetricAppr = 0; while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:")) != -1) switch (arguments) { case 's': SNRstart = atof(optarg); - printf("SNRstart = %f\n", SNRstart); break; case 'd': @@ -93,7 +91,12 @@ int main(int argc, char *argv[]) { folderName=getenv("HOME"); strcat(folderName,"/Desktop/polartestResults"); + + #ifdef DEBUG_POLAR_TIMING + sprintf(fileName,"%s/TIMING_ListSize_%d_pmAppr_%d_Payload_%d_Itr_%d",folderName,decoderListSize,pathMetricAppr,testLength,iterations); + #else sprintf(fileName,"%s/_ListSize_%d_pmAppr_%d_Payload_%d_Itr_%d",folderName,decoderListSize,pathMetricAppr,testLength,iterations); + #endif strftime(currentTimeInfo, 25, "_%Y-%m-%d-%H-%M-%S.csv", localtime(¤tTime)); strcat(fileName,currentTimeInfo); @@ -107,65 +110,45 @@ int main(int argc, char *argv[]) { fprintf(stderr,"[polartest.c] Problem creating file %s with fopen\n",fileName); exit(-1); } + +#ifdef DEBUG_POLAR_TIMING + fprintf(logFile,",timeEncoderCRCByte[us],timeEncoderCRCBit[us],timeEncoderInterleaver[us],timeEncoderBitInsertion[us],timeEncoder1[us],timeEncoder2[us],timeEncoderRateMatching[us],timeEncoderByte2Bit[us]\n"); +#else fprintf(logFile,",SNR,nBitError,blockErrorState,t_encoder[us],t_decoder[us]\n"); +#endif - //uint8_t *testInput = malloc(sizeof(uint8_t) * testLength); //generate randomly - //uint8_t *encoderOutput = malloc(sizeof(uint8_t) * coderLength); - uint32_t testInput[4], encoderOutput[4]; - memset(testInput,0,sizeof(testInput)); - memset(encoderOutput,0,sizeof(encoderOutput)); + uint8_t testArrayLength = ceil(testLength / 32.0); + uint8_t coderArrayLength = ceil(coderLength / 32.0); + uint32_t *testInput = malloc(sizeof(uint32_t) * testArrayLength); //generate randomly + uint32_t *encoderOutput = malloc(sizeof(uint32_t) * coderArrayLength); + uint32_t *estimatedOutput = malloc(sizeof(uint32_t) * testArrayLength); //decoder output + memset(testInput,0,sizeof(uint32_t) * testArrayLength); + memset(encoderOutput,0,sizeof(uint32_t) * coderArrayLength); + memset(estimatedOutput,0,sizeof(uint32_t) * testArrayLength); + + uint8_t *encoderOutputByte = malloc(sizeof(uint8_t) * coderLength); double *modulatedInput = malloc (sizeof(double) * coderLength); //channel input - double *channelOutput = malloc (sizeof(double) * coderLength); //add noise - uint32_t *estimatedOutput = malloc(sizeof(uint8_t) * testLength); //decoder output t_nrPolar_paramsPtr nrPolar_params = NULL, currentPtr = NULL; nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); + currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength, aggregation_level); + #ifdef DEBUG_DCI_POLAR_PARAMS + uint32_t crc; unsigned int poly24c = 0xb2b11700; + testInput[0]=0x01189400; printf("testInput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", testInput[0], testInput[1], testInput[2], testInput[3]); - printf("encOutput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - encoderOutput[0], encoderOutput[1], encoderOutput[2], encoderOutput[3]); - testInput[0]=0x01189400; uint8_t testInput2[8]; nr_crc_bit2bit_uint32_8_t(testInput, 32, testInput2); - printf("testInput2: [0]->%x \t [1]->%x \t [2]->%x \t [3]->%x\n [4]->%x \t [5]->%x \t [6]->%x \t [7]->%x \t\n", + printf("testInput2: [0]->%x \t [1]->%x \t [2]->%x \t [3]->%x\n" + " [4]->%x \t [5]->%x \t [6]->%x \t [7]->%x\n", testInput2[0], testInput2[1], testInput2[2], testInput2[3], testInput2[4], testInput2[5], testInput2[6], testInput2[7]); printf("crc32: [0]->0x%08x\n",crc24c(testInput2, 32)); printf("crc56: [0]->0x%08x\n",crc24c(testInput2, 56)); - return 0; - uint8_t testInput8[4]; - /*testInput8[0]=0x00; - testInput8[1]=0x49; - testInput8[2]=0x81; - testInput8[3]=0x10; - testInput8[4]=0x00;*/ - testInput8[0]=0xff; - testInput8[1]=0xd0; - testInput8[2]=0xff; - testInput8[3]=0x82; - crc = crc24c(testInput8, 31); - for (int i=0;i<24;i++) printf("[i]=%d\n",(crc>>i)&1); - printf("crc: [0]->0x%08x\n",crc); - printf("crcbit: %x\n",crcbit(testInput8, 3, poly24c)); - return 0; - unsigned char test[] = "Thebigredfox"; - - for (int i=0;i<8;i++) printf("[i]=%d\n",(test[0]>>i)&1); - printf("test[0]=%x\n",test[0]); - printf("%s -- sizeof=%d\n",test,sizeof(test)); - printf("%x\n", crcbit(test, sizeof(test) - 1, poly24c)); - printf("%x\n", crc24c(test, (sizeof(test) - 1)*8)); - polarMessageType = 1; - testLength = 41; - aggregation_level=1; - coderLength = 108; - nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); - nr_polar_print_polarParams(nrPolar_params); - crc = crc24c(testInput, testLength)>>8; for (int i=0;i<24;i++) printf("[i]=%d\n",(crc>>i)&1); printf("crc: [0]->0x%08x\n",crc); @@ -174,18 +157,30 @@ int main(int argc, char *argv[]) { testInput[2+(testLength>>3)] = ((uint8_t*)&crc)[0]; printf("testInput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", testInput[0], testInput[1], testInput[2], testInput[3]); - return (0); - currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength, aggregation_level); - polar_encoder(testInput, encoderOutput, currentPtr); - printf("AFTER POLAR ENCODING\n"); - printf("testInput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - testInput[0], testInput[1], testInput[2], testInput[3]); - printf("encOutput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - encoderOutput[0], encoderOutput[1], encoderOutput[2], encoderOutput[3]); - return (0); #endif - currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength, aggregation_level); +#ifdef DEBUG_POLAR_TIMING + for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) { + SNR_lin = pow(10, SNR / 10); + for (itr = 1; itr <= iterations; itr++) { + for (int j=0; j0x%08x \n", testInput[0]); + polar_encoder_timing(testInput, encoderOutput, currentPtr, cpu_freq_GHz, logFile); + } + } + fclose(logFile); + free(testInput); + free(encoderOutput); + free(modulatedInput); + free(channelOutput); + free(estimatedOutput); + return (0); +#endif // We assume no a priori knowledge available about the payload. double aPrioriArray[currentPtr->payloadBits]; @@ -195,68 +190,87 @@ int main(int argc, char *argv[]) { SNR_lin = pow(10, SNR/10); for (itr = 1; itr <= iterations; itr++) { - for(int i=0; i0) blockErrorState=1; - } - //Iteration times are in microseconds. - timeEncoderCumulative+=(timeEncoder.diff_now/(cpu_freq_GHz*1000.0)); - timeDecoderCumulative+=(timeDecoder.diff_now/(cpu_freq_GHz*1000.0)); - fprintf(logFile,",%f,%d,%d,%f,%f\n", SNR, nBitError, blockErrorState, - (timeEncoder.diff_now/(cpu_freq_GHz*1000.0)), (timeDecoder.diff_now/(cpu_freq_GHz*1000.0))); + /*printf("testInput: [0]->0x%08x\n", testInput[0]); + for (int i=0; i<32; i++) + printf("%d\n",(testInput[0]>>i)&1);*/ - if (nBitError<0) { - blockErrorCumulative++; - bitErrorCumulative+=testLength; - } else { - blockErrorCumulative+=blockErrorState; - bitErrorCumulative+=nBitError; - } + start_meas(&timeEncoder); + polar_encoder(testInput, encoderOutput, currentPtr); + stop_meas(&timeEncoder); - decoderState=0; - nBitError=0; - blockErrorState=0; + /*printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]); + printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]); +*/ + //Bit-to-byte: + nr_bit2byte_uint32_8_t(encoderOutput, coderLength, encoderOutputByte); + + //BPSK modulation + for(int i=0; i0x%08x\n", testInput[0]); + printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]); +*/ + + //calculate errors + if (decoderState==-1) { + blockErrorState=-1; + nBitError=-1; + } else { + for (int i = 0; i < testArrayLength; i++) { + for (int j = 0; j < (sizeof(testInput[0])*8); j++) { + if (((estimatedOutput[i]>>j) & 1) != ((testInput[i]>>j) & 1)) nBitError++; + } + } + + if (nBitError>0) blockErrorState=1; + } + + //Iteration times are in microseconds. + timeEncoderCumulative+=(timeEncoder.diff_now/(cpu_freq_GHz*1000.0)); + timeDecoderCumulative+=(timeDecoder.diff_now/(cpu_freq_GHz*1000.0)); + fprintf(logFile,",%f,%d,%d,%f,%f\n", SNR, nBitError, blockErrorState, + (timeEncoder.diff_now/(cpu_freq_GHz*1000.0)), (timeDecoder.diff_now/(cpu_freq_GHz*1000.0))); + + if (nBitError<0) { + blockErrorCumulative++; + bitErrorCumulative+=testLength; + } else { + blockErrorCumulative+=blockErrorState; + bitErrorCumulative+=nBitError; + } + + decoderState=0; + nBitError=0; + blockErrorState=0; } //Calculate error statistics for the SNR. @@ -273,11 +287,14 @@ int main(int argc, char *argv[]) { print_meas(&timeDecoder,"polar_decoder",NULL,NULL); fclose(logFile); - //free(testInput); - //free(encoderOutput); + //Bit + free(testInput); + free(encoderOutput); + free(estimatedOutput); + //Byte + free(encoderOutputByte); free(modulatedInput); free(channelOutput); - free(estimatedOutput); return (0); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 51a0328d7e..1616c498e4 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -278,13 +278,268 @@ int8_t polar_decoder( return(0); } -int8_t polar_decoder_aPriori( - double *input, - uint32_t *out, - t_nrPolar_paramsPtr polarParams, - uint8_t listSize, - uint8_t pathMetricAppr, - double *aPrioriPayload) +int8_t polar_decoder_aPriori(double *input, + uint32_t *out, + t_nrPolar_paramsPtr polarParams, + uint8_t listSize, + uint8_t pathMetricAppr, + double *aPrioriPayload) +{ + + uint8_t ***bit = nr_alloc_uint8_t_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); + uint8_t **bitUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True + uint8_t **llrUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True + double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); + uint8_t **crcChecksum = nr_alloc_uint8_t_2D_array(polarParams->crcParityBits, 2*listSize); + double *pathMetric = malloc(sizeof(double)*(2*listSize)); + uint8_t *crcState = malloc(sizeof(uint8_t)*(2*listSize)); //0=False, 1=True + + for (int i=0; i<(2*listSize); i++) { + pathMetric[i] = 0; + crcState[i]=1; + } + for (int i=0; iN; i++) { + llrUpdated[i][polarParams->n]=1; + bitUpdated[i][0]=((polarParams->information_bit_pattern[i]+1) % 2); + } + + uint8_t **extended_crc_generator_matrix = malloc(polarParams->K * sizeof(uint8_t *)); //G_P3 + uint8_t **tempECGM = malloc(polarParams->K * sizeof(uint8_t *)); //G_P2 + for (int i = 0; i < polarParams->K; i++){ + extended_crc_generator_matrix[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t)); + tempECGM[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t)); + } + + for (int i=0; ipayloadBits; i++) { + for (int j=0; jcrcParityBits; j++) { + tempECGM[i][j]=polarParams->crc_generator_matrix[i][j]; + } + } + for (int i=polarParams->payloadBits; iK; i++) { + for (int j=0; jcrcParityBits; j++) { + if( (i-polarParams->payloadBits) == j ){ + tempECGM[i][j]=1; + } else { + tempECGM[i][j]=0; + } + } + } + + for (int i=0; iK; i++) { + for (int j=0; jcrcParityBits; j++) { + extended_crc_generator_matrix[i][j]=tempECGM[polarParams->interleaving_pattern[i]][j]; + } + } + + //The index of the last 1-valued bit that appears in each column. + uint16_t last1ind[polarParams->crcParityBits]; + for (int j=0; jcrcParityBits; j++) { + for (int i=0; iK; i++) { + if (extended_crc_generator_matrix[i][j]==1) last1ind[j]=i; + } + } + + double *d_tilde = malloc(sizeof(double) * polarParams->N); + nr_polar_rate_matching(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); + for (int j = 0; j < polarParams->N; j++) llr[j][polarParams->n][0]=d_tilde[j]; + + + /* + * SCL polar decoder. + */ + + uint32_t nonFrozenBit=0; + uint8_t currentListSize=1; + uint8_t decoderIterationCheck=0; + int16_t checkCrcBits=-1; + uint8_t listIndex[2*listSize], copyIndex; + + for (uint16_t currentBit=0; currentBitN; currentBit++){ + updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1), pathMetricAppr); + if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. + updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 + } else { //Information or CRC bit. + if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && + (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 0) ) { + //Information bit with known value of "0". + updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); + bitUpdated[currentBit][0]=1; //0=False, 1=True + } else if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && + (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 1) ) { + //Information bit with known value of "1". + updatePathMetric(pathMetric, llr, currentListSize, 1, currentBit, pathMetricAppr); + for (uint8_t i=0; icrcParityBits); + } else { + updatePathMetric2(pathMetric, llr, currentListSize, currentBit, pathMetricAppr); + + for (int i = 0; i < currentListSize; i++) { + for (int j = 0; j < polarParams->N; j++) { + for (int k = 0; k < (polarParams->n+1); k++) { + bit[j][k][i+currentListSize]=bit[j][k][i]; + llr[j][k][i+currentListSize]=llr[j][k][i];}}} + for (int i = 0; i < currentListSize; i++) { + bit[currentBit][0][i]=0; + crcState[i+currentListSize]=crcState[i]; + } + for (int i = currentListSize; i < 2*currentListSize; i++) bit[currentBit][0][i]=1; + bitUpdated[currentBit][0]=1; + updateCrcChecksum2(crcChecksum, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits); + currentListSize*=2; + + //Keep only the best "listSize" number of entries. + if (currentListSize > listSize) { + for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; + nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); + + //sort listIndex[listSize, ..., 2*listSize-1] in descending order. + uint8_t swaps, tempInd; + for (uint8_t i = 0; i < listSize; i++) { + swaps = 0; + for (uint8_t j = listSize; j < (2*listSize - i) - 1; j++) { + if (listIndex[j+1] > listIndex[j]) { + tempInd = listIndex[j]; + listIndex[j] = listIndex[j + 1]; + listIndex[j + 1] = tempInd; + swaps++; + } + } + if (swaps == 0) + break; + } + + //First, backup the best "listSize" number of entries. + for (int k=(listSize-1); k>0; k--) { + for (int i=0; iN; i++) { + for (int j=0; j<(polarParams->n+1); j++) { + bit[i][j][listIndex[(2*listSize-1)-k]]=bit[i][j][listIndex[k]]; + llr[i][j][listIndex[(2*listSize-1)-k]]=llr[i][j][listIndex[k]]; + } + } + } + for (int k=(listSize-1); k>0; k--) { + for (int i = 0; i < polarParams->crcParityBits; i++) { + crcChecksum[i][listIndex[(2*listSize-1)-k]] = crcChecksum[i][listIndex[k]]; + } + } + for (int k=(listSize-1); k>0; k--) crcState[listIndex[(2*listSize-1)-k]]=crcState[listIndex[k]]; + + //Copy the best "listSize" number of entries to the first indices. + for (int k = 0; k < listSize; k++) { + if (k > listIndex[k]) { + copyIndex = listIndex[(2*listSize-1)-k]; + } else { //Use the backup. + copyIndex = listIndex[k]; + } + for (int i = 0; i < polarParams->N; i++) { + for (int j = 0; j < (polarParams->n + 1); j++) { + bit[i][j][k] = bit[i][j][copyIndex]; + llr[i][j][k] = llr[i][j][copyIndex]; + } + } + } + for (int k = 0; k < listSize; k++) { + if (k > listIndex[k]) { + copyIndex = listIndex[(2*listSize-1)-k]; + } else { //Use the backup. + copyIndex = listIndex[k]; + } + for (int i = 0; i < polarParams->crcParityBits; i++) { + crcChecksum[i][k]=crcChecksum[i][copyIndex]; + } + } + for (int k = 0; k < listSize; k++) { + if (k > listIndex[k]) { + copyIndex = listIndex[(2*listSize-1)-k]; + } else { //Use the backup. + copyIndex = listIndex[k]; + } + crcState[k]=crcState[copyIndex]; + } + currentListSize = listSize; + } + } + + for (int i=0; icrcParityBits; i++) { + if (last1ind[i]==nonFrozenBit) { + checkCrcBits=i; + break; + } + } + + if ( checkCrcBits > (-1) ) { + for (uint8_t i = 0; i < currentListSize; i++) { + if (crcChecksum[checkCrcBits][i]==1) { + crcState[i]=0; //0=False, 1=True + } + } + } + + for (uint8_t i = 0; i < currentListSize; i++) decoderIterationCheck+=crcState[i]; + if (decoderIterationCheck==0) { + //perror("[SCL polar decoder] All list entries have failed the CRC checks."); + free(d_tilde); + free(pathMetric); + free(crcState); + nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1)); + nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); + nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits); + return(-1); + } + + nonFrozenBit++; + decoderIterationCheck=0; + checkCrcBits=-1; + } + } + + for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; + nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); + + for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) { + if ( crcState[listIndex[i]] == 1 ) { + for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_U[j]=bit[j][0][listIndex[i]]; + + //Extract the information bits (û to ĉ) + nr_polar_info_bit_extraction(polarParams->nr_polar_U, polarParams->nr_polar_CPrime, polarParams->information_bit_pattern, polarParams->N); + + //Deinterleaving (ĉ to b) + nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); + + //Remove the CRC (â) + for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; + + break; + } + } + + free(d_tilde); + free(pathMetric); + free(crcState); + nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1)); + nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); + nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits); + nr_free_uint8_t_2D_array(extended_crc_generator_matrix, polarParams->K); + nr_free_uint8_t_2D_array(tempECGM, polarParams->K); + + /* + * Return bits. + */ + nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); + return(0); +} + + + +int8_t polar_decoder_aPriori_timing(double *input, + uint32_t *out, + t_nrPolar_paramsPtr polarParams, + uint8_t listSize, + uint8_t pathMetricAppr, + double *aPrioriPayload, + double cpuFreqGHz, + FILE* logFile) { uint8_t ***bit = nr_alloc_uint8_t_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index fdf34398fa..28e4c72864 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -42,6 +42,8 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" +#include "PHY/CODING/coding_defs.h" +#include "SIMULATION/TOOLS/sim.h" #define NR_POLAR_DECODER_LISTSIZE 8 //uint8_t #define NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION 0 //uint8_t; 0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12) @@ -111,6 +113,12 @@ void polar_encoder_dci(uint32_t *in, t_nrPolar_paramsPtr polarParams, uint16_t n_RNTI); +void polar_encoder_timing(uint32_t *in, + uint32_t *out, + t_nrPolar_paramsPtr polarParams, + double cpuFreqGHz, + FILE* logFile); + int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_paramsPtr polarParams, @@ -124,6 +132,15 @@ int8_t polar_decoder_aPriori(double *input, uint8_t pathMetricAppr, double *aPrioriPayload); +int8_t polar_decoder_aPriori_timing(double *input, + uint32_t *output, + t_nrPolar_paramsPtr polarParams, + uint8_t listSize, + uint8_t pathMetricAppr, + double *aPrioriPayload, + double cpuFreqGHz, + FILE* logFile); + void nr_polar_init(t_nrPolar_paramsPtr *polarParams, int8_t messageType, uint16_t messageLength, diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 2c9e3529a2..c1a0c31a42 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -30,10 +30,15 @@ * \warning */ +//#define DEBUG_POLAR_ENCODER //#define DEBUG_POLAR_ENCODER_DCI +//#define DEBUG_POLAR_ENCODER_TIMING #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" +//input [a_31 a_30 ... a_0] +//output [f_31 f_30 ... f_0] [f_63 f_62 ... f_32] ... + void polar_encoder(uint32_t *in, uint32_t *out, t_nrPolar_paramsPtr polarParams) @@ -95,6 +100,10 @@ void polar_encoder(uint32_t *in, /* * Return bits. */ +#ifdef DEBUG_POLAR_ENCODER + for (int i=0; i< polarParams->encoderLength;i++) printf("f[%d]=%d\n", i, polarParams->nr_polar_E[i]); +#endif + nr_byte2bit_uint8_32_t(polarParams->nr_polar_E, polarParams->encoderLength, out); } @@ -187,3 +196,76 @@ void polar_encoder_dci(uint32_t *in, } #endif } + +void polar_encoder_timing(uint32_t *in, + uint32_t *out, + t_nrPolar_paramsPtr polarParams, + double cpuFreqGHz, + FILE* logFile) +{ + //Initiate timing. + time_stats_t timeEncoderCRCByte, timeEncoderCRCBit, timeEncoderInterleaver, timeEncoderBitInsertion, timeEncoder1, timeEncoder2, timeEncoderRateMatching, timeEncoderByte2Bit; + reset_meas(&timeEncoderCRCByte); reset_meas(&timeEncoderCRCBit); reset_meas(&timeEncoderInterleaver); reset_meas(&timeEncoderBitInsertion); reset_meas(&timeEncoder1); reset_meas(&timeEncoder2); reset_meas(&timeEncoderRateMatching); reset_meas(&timeEncoderByte2Bit); + uint16_t n_RNTI=0x0000; + + start_meas(&timeEncoderCRCByte); + nr_crc_bit2bit_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_aPrime); //(a to a') + polarParams->crcBit = crc24c(polarParams->nr_polar_aPrime, (polarParams->payloadBits+polarParams->crcParityBits)); //Parity bits computation (p) + uint8_t arrayInd = ceil(polarParams->payloadBits / 8.0); //(a to b) + for (int i=0; inr_polar_B[j+(i*8)] = ((polarParams->nr_polar_aPrime[3+i]>>(7-j)) & 1); + for (int i=0; i<((polarParams->payloadBits)%8); i++) polarParams->nr_polar_B[i+(arrayInd-1)*8] = ((polarParams->nr_polar_aPrime[3+(arrayInd-1)]>>(7-i)) & 1); + for (int i=0; i<8; i++) polarParams->nr_polar_B[polarParams->payloadBits+i] = ((polarParams->crcBit)>>(31-i))&1; + for (int i=0; i<16; i++) polarParams->nr_polar_B[polarParams->payloadBits+8+i] = ( (((polarParams->crcBit)>>(23-i))&1) + ((n_RNTI>>(15-i))&1) ) % 2; //Scrambling (b to c) + stop_meas(&timeEncoderCRCByte); + + + start_meas(&timeEncoderCRCBit); + nr_bit2byte_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_A); + nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_A, polarParams->crc_generator_matrix, polarParams->nr_polar_crc, polarParams->payloadBits, polarParams->crcParityBits); //Calculate CRC. + for (uint8_t i = 0; i < polarParams->crcParityBits; i++) polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2); + for (uint16_t i = 0; i < polarParams->payloadBits; i++) polarParams->nr_polar_B[i] = polarParams->nr_polar_A[i]; //Attach CRC to the Transport Block. (a to b) + for (uint16_t i = polarParams->payloadBits; i < polarParams->K; i++) polarParams->nr_polar_B[i]= polarParams->nr_polar_crc[i-(polarParams->payloadBits)]; + stop_meas(&timeEncoderCRCBit); + + + start_meas(&timeEncoderInterleaver); //Interleaving (c to c') + nr_polar_interleaver(polarParams->nr_polar_B, polarParams->nr_polar_CPrime, polarParams->interleaving_pattern, polarParams->K); + stop_meas(&timeEncoderInterleaver); + + + start_meas(&timeEncoderBitInsertion); //Bit insertion (c' to u) + nr_polar_bit_insertion(polarParams->nr_polar_CPrime, polarParams->nr_polar_U, polarParams->N, polarParams->K, polarParams->Q_I_N, polarParams->Q_PC_N, polarParams->n_pc); + stop_meas(&timeEncoderBitInsertion); + + + start_meas(&timeEncoder1); //Encoding (u to d) + nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_U, polarParams->G_N, polarParams->nr_polar_D, polarParams->N, polarParams->N); + stop_meas(&timeEncoder1); + + + start_meas(&timeEncoder2); + for (uint16_t i = 0; i < polarParams->N; i++) polarParams->nr_polar_D[i] = (polarParams->nr_polar_D[i] % 2); + stop_meas(&timeEncoder2); + + + start_meas(&timeEncoderRateMatching);//Rate matching //Sub-block interleaving (d to y) and Bit selection (y to e) + nr_polar_interleaver(polarParams->nr_polar_D, polarParams->nr_polar_E, polarParams->rate_matching_pattern, polarParams->encoderLength); + stop_meas(&timeEncoderRateMatching); + + + start_meas(&timeEncoderByte2Bit); //Return bits. + nr_byte2bit_uint8_32_t(polarParams->nr_polar_E, polarParams->encoderLength, out); + stop_meas(&timeEncoderByte2Bit); + + fprintf(logFile,",%f,%f,%f,%f,%f,%f,%f,%f\n", + (timeEncoderCRCByte.diff_now/(cpuFreqGHz*1000.0)), + (timeEncoderCRCBit.diff_now/(cpuFreqGHz*1000.0)), + (timeEncoderInterleaver.diff_now/(cpuFreqGHz*1000.0)), + (timeEncoderBitInsertion.diff_now/(cpuFreqGHz*1000.0)), + (timeEncoder1.diff_now/(cpuFreqGHz*1000.0)), + (timeEncoder2.diff_now/(cpuFreqGHz*1000.0)), + (timeEncoderRateMatching.diff_now/(cpuFreqGHz*1000.0)), + (timeEncoderByte2Bit.diff_now/(cpuFreqGHz*1000.0))); +} From 52bdf7e0774bd5e0f183aa0bdd1e5b4fd9c2ec13 Mon Sep 17 00:00:00 2001 From: Hongzhi Date: Wed, 19 Sep 2018 15:10:43 +0200 Subject: [PATCH 094/114] nr pbch format change --- .../CODING/nrPolar_tools/nr_polar_pbch_defs.h | 1 + openair1/PHY/NR_TRANSPORT/nr_pbch.c | 37 ++++++++----------- openair1/PHY/defs_gNB.h | 6 +-- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h index f8fd5f88f0..2ced9633ce 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h @@ -51,6 +51,7 @@ //Sec. 7.1.5: Rate Matching #define NR_POLAR_PBCH_I_BIL 0 //uint8_t #define NR_POLAR_PBCH_E 864 //uint16_t +#define NR_POLAR_PBCH_E_DWORD 27 // NR_POLAR_PBCH_E/32 /* * TEST CODE diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 5964a55569..cd5024fa49 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -36,7 +36,7 @@ #include "PHY/sse_intrin.h" //#define DEBUG_PBCH -//#define DEBUG_PBCH_ENCODING +#define DEBUG_PBCH_ENCODING //#define DEBUG_PBCH_DMRS extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; @@ -140,9 +140,9 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, { uint8_t reset, offset; uint32_t x1, x2, s=0; - uint8_t *pbch_e = pbch->pbch_e; - uint32_t *pbch_a_prime = (uint32_t*)pbch->pbch_a_prime; - uint32_t *pbch_a_interleaved = (uint32_t*)pbch->pbch_a_interleaved; + uint32_t *pbch_e = pbch->pbch_e; + uint32_t pbch_a_prime = pbch->pbch_a_prime; + uint32_t pbch_a_interleaved = pbch->pbch_a_interleaved; uint32_t unscrambling_mask = 0x100006D; reset = 1; @@ -157,7 +157,7 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, // Scrambling is now done with offset (nushift*M)%32 offset = (nushift*M)&0x1f; #ifdef DEBUG_PBCH_ENCODING - printf("Scrambling params: nushift %d M %d length %d bitwise %d offset %d\n", nushift, M, length, bitwise, offset); + printf("Scrambling params: nushift %d M %d length %d encoded %d offset %d\n", nushift, M, length, encoded, offset); #endif for (int i=0; i>i)&1)? (((*pbch_a_interleaved)>>i)&1)<>i)&1) ^ ((s>>((i+offset)&0x1f))&1))<>i)&1)? ((pbch_a_interleaved>>i)&1)<>i)&1) ^ ((s>>((i+offset)&0x1f))&1))<>(3+i))&1)<<(5+i); // resp. 4th, 5th and 6th bits of ssb_index else (*xbyte) ^= ((config->sch_config.ssb_subcarrier_offset.value>>5)&1)<<5; //MSB of k_SSB -#ifdef DEBUG_PBCH_ENCODING +//#ifdef DEBUG_PBCH_ENCODING printf("Extra byte:\n"); for (int i=0; i<4; i++) printf("pbch_a[%d]: 0x%02x\n", i, pbch->pbch_a[i]); -#endif +//#endif // Payload interleaving uint32_t in=0, out=0; @@ -258,19 +258,18 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, in |= (uint32_t)(pbch->pbch_a[i]<<((3-i)<<3)); for (int i=0; i<32; i++) { - out |= ((in>>i)&1)<<(nr_pbch_payload_interleaver(i));//nr_pbch_payload_interleaving_pattern[i] + pbch->pbch_a_interleaved |= ((in>>i)&1)<<(nr_pbch_payload_interleaver(i));//nr_pbch_payload_interleaving_pattern[i] #ifdef DEBUG_PBCH_ENCODING printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) %d\n", i, in, out, nr_pbch_payload_interleaver(i), (in>>i)&1); #endif } - for (int i=0; i>3; i++) - pbch->pbch_a_interleaved[i] = (uint8_t)((out>>(i<<3))&0xff); + /*for (int i=0; i>3; i++) + pbch->pbch_a_interleaved[i] = (uint8_t)((out>>(i<<3))&0xff);*/ #ifdef DEBUG_PBCH_ENCODING printf("Interleaving:\n"); - for (int i=0; i<4; i++) - printf("pbch_a_interleaved[%d]: 0x%02x\n", i, pbch->pbch_a_interleaved[i]); + printf("pbch_a_interleaved: 0x%08x\n", pbch->pbch_a_interleaved); #endif // Scrambling @@ -279,20 +278,14 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, nr_pbch_scrambling(pbch, (uint32_t)config->sch_config.physical_cell_id.value, nushift, M, NR_POLAR_PBCH_PAYLOAD_BITS, 0); #ifdef DEBUG_PBCH_ENCODING printf("Payload scrambling:\n"); - for (int i=0; i<4; i++) - printf("pbch_a_prime[%d]: 0x%02x\n", i, pbch->pbch_a_prime[i]); + printf("pbch_a_prime[%d]: 0x%08x\n", pbch->pbch_a_prime); #endif -for (int m=0;m<32;m++){ -pbch_a_b[m] = ((pbch->pbch_a_prime[m>>3]>>(m&7))&1); -//printf("pbch_a_b[%d] %d\n", m, pbch_a_b[m] ); -} - /// CRC, coding and rate matching polar_encoder (pbch->pbch_a_prime, pbch->pbch_e, polar_params); #ifdef DEBUG_PBCH_ENCODING printf("Channel coding:\n"); - for (int i=0; i<(uint16_t)ceil((NR_POLAR_PBCH_E>>3)/32); i++) + for (int i=0; ipbch_e[i]); printf("\n"); #endif @@ -303,7 +296,7 @@ pbch_a_b[m] = ((pbch->pbch_a_prime[m>>3]>>(m&7))&1); nr_pbch_scrambling(pbch, (uint32_t)config->sch_config.physical_cell_id.value, nushift, M, NR_POLAR_PBCH_E, 1); #ifdef DEBUG_PBCH_ENCODING printf("Scrambling:\n"); - for (int i=0; i<(uint16_t)ceil((NR_POLAR_PBCH_E>>3)/32); i++) + for (int i=0; ipbch_e[i]); printf("\n"); #endif diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 116e940c71..f5e9efa3cb 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -41,9 +41,9 @@ typedef struct { uint8_t pbch_a[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; - uint8_t pbch_a_interleaved[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; - uint8_t pbch_a_prime[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; - uint8_t pbch_e[NR_POLAR_PBCH_E]; + uint32_t pbch_a_interleaved; + uint32_t pbch_a_prime; + uint32_t pbch_e[NR_POLAR_PBCH_E_DWORD]; } NR_gNB_PBCH; typedef struct { From e8780cb743703b8a2f263e810383c3cd009c2e49 Mon Sep 17 00:00:00 2001 From: Hongzhi Date: Wed, 19 Sep 2018 15:15:58 +0200 Subject: [PATCH 095/114] remove sim.h in nr_ploar_def.h --- openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 28e4c72864..9615a0d245 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -43,7 +43,7 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" #include "PHY/CODING/coding_defs.h" -#include "SIMULATION/TOOLS/sim.h" +//#include "SIMULATION/TOOLS/sim.h" #define NR_POLAR_DECODER_LISTSIZE 8 //uint8_t #define NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION 0 //uint8_t; 0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12) From 3996241b17de5f7b025a0a9404ed8beb94d320d9 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 19 Sep 2018 15:47:00 +0200 Subject: [PATCH 096/114] Polar encoder entry fix --- cmake_targets/CMakeLists.txt | 3 +-- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 420a2932ae..8d27a67a40 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -176,8 +176,7 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath -Wl,${CMAKE_CU # these changes are related to hardcoded path to include .h files add_definitions(-DCMAKER) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -DMALLOC_CHECK_=3") -#set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -DMALLOC_CHECK_=3 -O2") -set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -DMALLOC_CHECK_=3") +set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -DMALLOC_CHECK_=3 -O2") set(GIT_BRANCH "UNKNOWN") diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 473451fe52..70cf18ab57 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -36,7 +36,7 @@ #include "PHY/sse_intrin.h" //#define DEBUG_PBCH -#define DEBUG_PBCH_ENCODING +//#define DEBUG_PBCH_ENCODING //#define DEBUG_PBCH_DMRS extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; @@ -278,11 +278,11 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, nr_pbch_scrambling(pbch, (uint32_t)config->sch_config.physical_cell_id.value, nushift, M, NR_POLAR_PBCH_PAYLOAD_BITS, 0); #ifdef DEBUG_PBCH_ENCODING printf("Payload scrambling:\n"); - printf("pbch_a_prime[%d]: 0x%08x\n", pbch->pbch_a_prime); + printf("pbch_a_prime: 0x%08x\n", pbch->pbch_a_prime); #endif /// CRC, coding and rate matching - polar_encoder (pbch->pbch_a_prime, pbch->pbch_e, polar_params); + polar_encoder (&pbch->pbch_a_prime, pbch->pbch_e, polar_params); #ifdef DEBUG_PBCH_ENCODING printf("Channel coding:\n"); for (int i=0; i Date: Thu, 20 Sep 2018 11:58:06 +0200 Subject: [PATCH 097/114] Update nr_pbch.c --- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 337b6d8e33..43c7c2772c 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -650,7 +650,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, for (i=0; i<16; i++){ printf("unscrambling demod_pbch_e[%d] r = %2.3f i = %2.3f\n", i<<1 , demod_pbch_e[i<<1], demod_pbch_e[(i<<1)+1]);} //#endif - + uint32_t pbch_out; //polar decoding de-rate matching t_nrPolar_paramsPtr nrPolar_params = NULL, currentPtr = NULL; nr_polar_init(&nrPolar_params, @@ -658,10 +658,14 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL); currentPtr = nr_polar_params(nrPolar_params, NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL); - decoderState = polar_decoder(demod_pbch_e, pbch_a_b, currentPtr, decoderListSize, pathMetricAppr); + double aPrioriArray[currentPtr->payloadBits]; + for (int i=0; ipayloadBits; i++) aPrioriArray[i] = NAN; + decoderState = polar_decoder_aPriori(demod_pbch_e, pbch_out, currentPtr, decoderListSize, pathMetricAppr,aPrioriArray); printf("polar decoder state %d\n", decoderState); if(decoderState == -1) return(decoderState); + + printf("polar decoder output 0x%08x\n",pbch_out); memset(&pbch_a_prime[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS>>3); for (i=0; i Date: Thu, 20 Sep 2018 16:41:31 +0200 Subject: [PATCH 098/114] nr pbch working with format change --- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 51 ++++++++------------------ openair1/PHY/defs_nr_UE.h | 4 +- 2 files changed, 17 insertions(+), 38 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 43c7c2772c..11a1d54990 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -397,8 +397,6 @@ void nr_pbch_unscrambling(NR_UE_PBCH *pbch, uint8_t reset, offset; uint32_t x1, x2, s=0; double *demod_pbch_e = pbch->demod_pbch_e; - uint32_t *pbch_a_prime = (uint32_t*)pbch->pbch_a_prime; - uint32_t *pbch_a_interleaved = (uint32_t*)pbch->pbch_a_interleaved; uint32_t unscrambling_mask = 0x100006D; printf("unscramb nid_cell %d\n",Nid); @@ -408,7 +406,7 @@ void nr_pbch_unscrambling(NR_UE_PBCH *pbch, x2 = Nid; //this is c_init // The Gold sequence is shifted by nushift* M, so we skip (nushift*M /32) double words - for (int i=0; i<(uint16_t)ceil((nushift*M)/32); i++) { + for (int i=0; i<(uint16_t)ceil(((float)nushift*M)/32); i++) { s = lte_gold_generic(&x1, &x2, reset); reset = 0; } @@ -423,9 +421,11 @@ void nr_pbch_unscrambling(NR_UE_PBCH *pbch, #ifdef DEBUG_PBCH_ENCODING if (i<8) printf("s: %04x\t", s); + printf("pbch_a_interleaved 0x%08x\n", pbch->pbch_a_interleaved); #endif if (bitwise) { - (*pbch_a_interleaved) ^= ((unscrambling_mask>>i)&1)? (((*pbch_a_prime)>>i)&1)<>i)&1) ^ ((s>>((i+offset)&0x1f))&1))<pbch_a_interleaved) ^= ((unscrambling_mask>>i)&1)? ((pbch->pbch_a_prime>>i)&1)<pbch_a_prime>>i)&1) ^ ((s>>((i+offset)&0x1f))&1))<decoded_output; uint8_t nushift; @@ -619,15 +618,14 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, pbch_e_rx = nr_ue_pbch_vars->llr; demod_pbch_e = nr_ue_pbch_vars->demod_pbch_e; pbch_a = nr_ue_pbch_vars->pbch_a; - pbch_a_prime = nr_ue_pbch_vars->pbch_a_prime; -//#ifdef DEBUG_PBCH +#ifdef DEBUG_PBCH //pbch_e_rx = &nr_ue_pbch_vars->llr[0]; short *p = (short *)&(nr_ue_pbch_vars->rxdataF_comp[0][5*20*12]); - for (int cnt = 0; cnt < 8 ; cnt++) + for (int cnt = 0; cnt < 32 ; cnt++) printf("pbch rx llr %d rxdata_comp %d addr %p\n",*(pbch_e_rx+cnt), p[cnt], &p[0]); -//#endif +#endif for (i=0; ipayloadBits]; for (int i=0; ipayloadBits; i++) aPrioriArray[i] = NAN; - decoderState = polar_decoder_aPriori(demod_pbch_e, pbch_out, currentPtr, decoderListSize, pathMetricAppr,aPrioriArray); + decoderState = polar_decoder_aPriori(demod_pbch_e,&nr_ue_pbch_vars->pbch_a_prime, currentPtr, decoderListSize, pathMetricAppr,aPrioriArray); printf("polar decoder state %d\n", decoderState); if(decoderState == -1) return(decoderState); - printf("polar decoder output 0x%08x\n",pbch_out); - - memset(&pbch_a_prime[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS>>3); - for (i=0; i>3; i++) - printf("pbch_a_prime[%d] = 0x%02x\n", i,pbch_a_prime[i]); -//#endif + //printf("polar decoder output 0x%08x\n",nr_ue_pbch_vars->pbch_a_prime); //payload un-scrambling - memset(nr_ue_pbch_vars->pbch_a_interleaved, 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS>>3); + memset(&nr_ue_pbch_vars->pbch_a_interleaved, 0, sizeof(uint32_t) ); M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3); - nushift = ((pbch_a_prime[0]>>6)&1) ^ (((pbch_a_prime[3])&1)<<1); - //printf("payload unscrambling nushift %d sfn3 %d sfn2 %d M %d\n",nushift, ((pbch_a_prime[0]>>6)&1),((pbch_a_prime[3])&1),M); + nushift = ((nr_ue_pbch_vars->pbch_a_prime>>6)&1) ^ (((nr_ue_pbch_vars->pbch_a_prime>>24)&1)<<1); + printf("payload unscrambling nushift %d sfn3 %d sfn2 %d M %d\n",nushift, ((nr_ue_pbch_vars->pbch_a_prime>>6)&1),((nr_ue_pbch_vars->pbch_a_prime>>24)&1),M); nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_PAYLOAD_BITS,1); //payload deinterleaving uint32_t in=0, out=0; - for (int i=0; i>3; i++) - in |= (uint32_t)(nr_ue_pbch_vars->pbch_a_interleaved[i]<<(i<<3)); for (int i=0; i<32; i++) { - out |= ((in>>i)&1)<<(pbch_deinterleaving_pattern[i]); + out |= ((nr_ue_pbch_vars->pbch_a_interleaved>>i)&1)<<(pbch_deinterleaving_pattern[i]); #ifdef DEBUG_PBCH - printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, in, out, pbch_deinterleaving_pattern[i], (in>>i)&1); + printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, nr_ue_pbch_vars->pbch_a_interleaved, out, pbch_deinterleaving_pattern[i], (in>>i)&1); #endif } @@ -705,11 +689,6 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++) decoded_output[(NR_POLAR_PBCH_PAYLOAD_BITS>>3)-i-1] = pbch_a[i]; - decoded_output[0] = 0x0a; - decoded_output[1] = 0x63; - decoded_output[2] = 0x00; - decoded_output[3] = 0x06; - //#ifdef DEBUG_PBCH for (i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++){ //printf("unscrambling pbch_a[%d] = %x \n", i,pbch_a[i]); diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 603c02e380..07c70d24c0 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -945,8 +945,8 @@ typedef struct { /// - second index: ? [0..287] (hard coded) int32_t **dl_ch_estimates_ext; uint8_t pbch_a[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; - uint8_t pbch_a_interleaved[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; - uint8_t pbch_a_prime[NR_POLAR_PBCH_PAYLOAD_BITS>>3]; + uint32_t pbch_a_interleaved; + uint32_t pbch_a_prime; uint8_t pbch_e[NR_POLAR_PBCH_E]; double demod_pbch_e[NR_POLAR_PBCH_E]; /// \brief Pointer to PBCH llrs. From 90ccc5034ef299748cac2aa65f21e3062d268254 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 20 Sep 2018 16:56:27 +0200 Subject: [PATCH 099/114] PBCH debug changes --- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 26 ++++++++------------ targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 2 +- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index 70cf18ab57..6ef6be34fa 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -141,17 +141,13 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, uint8_t reset, offset; uint32_t x1, x2, s=0; uint32_t *pbch_e = pbch->pbch_e; - uint32_t pbch_a_prime = pbch->pbch_a_prime; - uint32_t pbch_a_interleaved = pbch->pbch_a_interleaved; uint32_t unscrambling_mask = 0x100006D; - reset = 1; // x1 is set in lte_gold_generic x2 = Nid; - // The Gold sequence is shifted by nushift* M, so we skip (nushift*M /32) double words - for (int i=0; i<(uint16_t)ceil((nushift*M)/32); i++) { - s = lte_gold_generic(&x1, &x2, reset); + for (int i=0; i<(uint16_t)ceil(((float)nushift*M)/32); i++) { +s = lte_gold_generic(&x1, &x2, reset); reset = 0; } // Scrambling is now done with offset (nushift*M)%32 @@ -168,9 +164,8 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch, #ifdef DEBUG_PBCH_ENCODING printf("s: %04x\t", s); #endif - if (!encoded) { - pbch_a_prime ^= ((unscrambling_mask>>i)&1)? ((pbch_a_interleaved>>i)&1)<>i)&1) ^ ((s>>((i+offset)&0x1f))&1))<pbch_a_prime ^= ((unscrambling_mask>>i)&1)? ((pbch->pbch_a_interleaved>>i)&1)<pbch_a_interleaved>>i)&1) ^ ((s>>((i+offset)&0x1f))&1))<>5] ^= (((s>>((i+offset)&0x1f))&1)<<(i&0x1f)); @@ -224,6 +219,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, LOG_I(PHY, "PBCH generation started\n"); + memset((void*)pbch, 0, sizeof(NR_gNB_PBCH)); ///Payload generation // Fix byte endian if (!(sfn&7)) @@ -260,25 +256,23 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, for (int i=0; i<32; i++) { pbch->pbch_a_interleaved |= ((in>>i)&1)<<(nr_pbch_payload_interleaver(i));//nr_pbch_payload_interleaving_pattern[i] #ifdef DEBUG_PBCH_ENCODING - printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) %d\n", i, in, out, nr_pbch_payload_interleaver(i), (in>>i)&1); + printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) %d\n", i, in, pbch->pbch_a_interleaved, nr_pbch_payload_interleaver(i), (in>>i)&1); #endif } - /*for (int i=0; i>3; i++) - pbch->pbch_a_interleaved[i] = (uint8_t)((out>>(i<<3))&0xff);*/ - #ifdef DEBUG_PBCH_ENCODING printf("Interleaving:\n"); - printf("pbch_a_interleaved: 0x%08x\n", pbch->pbch_a_interleaved); + printf("pbch_a_interleaved: 0x%08x\n", pbch->pbch_a_interleaved); #endif // Scrambling M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3); nushift = (((sfn>>2)&1)<<1) ^ ((sfn>>1)&1); + pbch->pbch_a_prime = 0; nr_pbch_scrambling(pbch, (uint32_t)config->sch_config.physical_cell_id.value, nushift, M, NR_POLAR_PBCH_PAYLOAD_BITS, 0); #ifdef DEBUG_PBCH_ENCODING - printf("Payload scrambling:\n"); - printf("pbch_a_prime: 0x%08x\n", pbch->pbch_a_prime); + printf("Payload scrambling: nushift %d M %d sfn3 %d sfn2 %d\n", nushift, M, (sfn>>2)&1, (sfn>>1)&1); + printf("pbch_a_prime: 0x%08x\n", pbch->pbch_a_prime); #endif /// CRC, coding and rate matching diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index a0e8fcff89..7fa7c643b5 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -977,7 +977,7 @@ extern "C" { if(device_adds.size() == 0) { double usrp_master_clock = 184.32e6; - std::string args = "type=x300"; + std::string args = "type=x300, addr=192.168.30.2"; // workaround for an api problem, master clock has to be set with the constructor not via set_master_clock_rate args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock); From 2f66c11db3f360fb3a13f3f5d6f27f3109c67d66 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Mon, 24 Sep 2018 15:56:24 +0200 Subject: [PATCH 100/114] adding emulate-rf feature in nr --- targets/RT/USER/nr-ru.c | 138 +++++++++++++++++++++++---------- targets/RT/USER/nr-softmodem.c | 2 +- targets/RT/USER/nr-softmodem.h | 3 + 3 files changed, 103 insertions(+), 40 deletions(-) diff --git a/targets/RT/USER/nr-ru.c b/targets/RT/USER/nr-ru.c index a9622df32d..46896f73ac 100644 --- a/targets/RT/USER/nr-ru.c +++ b/targets/RT/USER/nr-ru.c @@ -151,6 +151,9 @@ int connect_rau(RU_t *ru); extern uint16_t sf_ahead; +extern int emulate_rf; +extern int numerology; + /*************************************************************/ /* Functions to attach and configure RRU */ @@ -686,6 +689,34 @@ void fh_if4p5_north_out(RU_t *ru) { } +static void* emulatedRF_thread(void* param) { + RU_proc_t *proc = (RU_proc_t *) param; + int microsec = 500; // length of time to sleep, in miliseconds + struct timespec req = {0}; + req.tv_sec = 0; + req.tv_nsec = (numerology>0)? ((microsec * 1000L)/numerology):(microsec * 1000L)*2; + cpu_set_t cpuset; + CPU_SET(1,&cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + + int policy; + struct sched_param sparam; + memset(&sparam, 0, sizeof(sparam)); + sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); + policy = SCHED_FIFO ; + pthread_setschedparam(pthread_self(), policy, &sparam); + + wait_sync("emulatedRF_thread"); + while(!oai_exit){ + nanosleep(&req, (struct timespec *)NULL); + pthread_mutex_lock(&proc->mutex_emulateRF); + ++proc->instance_cnt_emulateRF; + pthread_mutex_unlock(&proc->mutex_emulateRF); + pthread_cond_signal(&proc->cond_emulateRF); + } + return 0; +} + void rx_rf(RU_t *ru,int *frame,int *subframe) { RU_proc_t *proc = &ru->proc; @@ -702,11 +733,18 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { old_ts = proc->timestamp_rx; - rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, + if(emulate_rf){ + wait_on_condition(&proc->mutex_emulateRF,&proc->cond_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); + release_thread(&proc->mutex_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); + rxs = fp->samples_per_tti; + } + else{ + rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, &ts, rxp, fp->samples_per_subframe, ru->nb_rx); + } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); @@ -1377,26 +1415,37 @@ static void* ru_thread( void* param ) { LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,NB_functions[ru->function],NB_timing[ru->if_timing]); - - // Start IF device if any - if (ru->start_if) { - LOG_I(PHY,"Starting IF interface for RU %d\n",ru->idx); - AssertFatal(ru->start_if(ru,NULL) == 0, "Could not start the IF device\n"); - if (ru->if_south == LOCAL_RF) ret = connect_rau(ru); - else ret = attach_rru(ru); - AssertFatal(ret==0,"Cannot connect to radio\n"); - } - if (ru->if_south == LOCAL_RF) { // configure RF parameters only + if(emulate_rf){ fill_rf_config(ru,ru->rf_config_file); nr_init_frame_parms(&ru->gNB_list[0]->gNB_config, fp); nr_dump_frame_parms(fp); nr_phy_init_RU(ru); - - ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); + if (setup_RU_buffers(ru)!=0) { + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); + } } - if (setup_RU_buffers(ru)!=0) { - printf("Exiting, cannot initialize RU Buffers\n"); - exit(-1); + else{ + // Start IF device if any + if (ru->start_if) { + LOG_I(PHY,"Starting IF interface for RU %d\n",ru->idx); + AssertFatal(ru->start_if(ru,NULL) == 0, "Could not start the IF device\n"); + if (ru->if_south == LOCAL_RF) ret = connect_rau(ru); + else ret = attach_rru(ru); + AssertFatal(ret==0,"Cannot connect to radio\n"); + } + if (ru->if_south == LOCAL_RF) { // configure RF parameters only + fill_rf_config(ru,ru->rf_config_file); + nr_init_frame_parms(&ru->gNB_list[0]->gNB_config, fp); + nr_dump_frame_parms(fp); + nr_phy_init_RU(ru); + + ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); + } + if (setup_RU_buffers(ru)!=0) { + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); + } } LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx); @@ -1407,28 +1456,30 @@ static void* ru_thread( void* param ) { wait_sync("ru_thread"); - // Start RF device if any - if (ru->start_rf) { - if (ru->start_rf(ru) != 0) - LOG_E(HW,"Could not start the RF device\n"); - else LOG_I(PHY,"RU %d rf device ready\n",ru->idx); - } - else LOG_I(PHY,"RU %d no rf device\n",ru->idx); + if(!emulate_rf){ + // Start RF device if any + if (ru->start_rf) { + if (ru->start_rf(ru) != 0) + LOG_E(HW,"Could not start the RF device\n"); + else LOG_I(PHY,"RU %d rf device ready\n",ru->idx); + } + else LOG_I(PHY,"RU %d no rf device\n",ru->idx); - // if an asnych_rxtx thread exists - // wakeup the thread because the devices are ready at this point + // if an asnych_rxtx thread exists + // wakeup the thread because the devices are ready at this point - if ((ru->fh_south_asynch_in)||(ru->fh_north_asynch_in)) { - pthread_mutex_lock(&proc->mutex_asynch_rxtx); - proc->instance_cnt_asynch_rxtx=0; - pthread_mutex_unlock(&proc->mutex_asynch_rxtx); - pthread_cond_signal(&proc->cond_asynch_rxtx); - } - else LOG_I(PHY,"RU %d no asynch_south interface\n",ru->idx); + if ((ru->fh_south_asynch_in)||(ru->fh_north_asynch_in)) { + pthread_mutex_lock(&proc->mutex_asynch_rxtx); + proc->instance_cnt_asynch_rxtx=0; + pthread_mutex_unlock(&proc->mutex_asynch_rxtx); + pthread_cond_signal(&proc->cond_asynch_rxtx); + } + else LOG_I(PHY,"RU %d no asynch_south interface\n",ru->idx); - // if this is a slave RRU, try to synchronize on the DL frequency - if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); + // if this is a slave RRU, try to synchronize on the DL frequency + if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); + } // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices @@ -1487,9 +1538,12 @@ static void* ru_thread( void* param ) { // do OFDM if needed if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); - // do outgoing fronthaul (south) if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); - + if (!emulate_rf) + { + // do outgoing fronthaul (south) if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); + } + if (ru->fh_north_out) ru->fh_north_out(ru); } @@ -1610,7 +1664,7 @@ void init_RU_proc(RU_t *ru) { int i=0; RU_proc_t *proc; - pthread_attr_t *attr_FH=NULL,*attr_prach=NULL,*attr_asynch=NULL;// *attr_synch=NULL; + pthread_attr_t *attr_FH=NULL,*attr_prach=NULL,*attr_asynch=NULL, *attr_emulateRF=NULL;// *attr_synch=NULL; //pthread_attr_t *attr_fep=NULL; #ifdef Rel14 //pthread_attr_t *attr_prach_br=NULL; @@ -1628,6 +1682,7 @@ void init_RU_proc(RU_t *ru) { proc->instance_cnt_synch = -1; ; proc->instance_cnt_FH = -1; proc->instance_cnt_asynch_rxtx = -1; + proc->instance_cnt_emulateRF = -1; proc->first_rx = 1; proc->first_tx = 1; proc->frame_offset = 0; @@ -1640,15 +1695,18 @@ void init_RU_proc(RU_t *ru) { pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); pthread_mutex_init( &proc->mutex_synch,NULL); pthread_mutex_init( &proc->mutex_FH,NULL); + pthread_mutex_init( &proc->mutex_emulateRF,NULL); pthread_mutex_init( &proc->mutex_gNBs, NULL); pthread_cond_init( &proc->cond_prach, NULL); pthread_cond_init( &proc->cond_FH, NULL); + pthread_cond_init( &proc->cond_emulateRF, NULL); pthread_cond_init( &proc->cond_asynch_rxtx, NULL); pthread_cond_init( &proc->cond_synch,NULL); pthread_cond_init( &proc->cond_gNBs, NULL); pthread_attr_init( &proc->attr_FH); + pthread_attr_init( &proc->attr_emulateRF); pthread_attr_init( &proc->attr_prach); pthread_attr_init( &proc->attr_synch); pthread_attr_init( &proc->attr_asynch_rxtx); @@ -1657,13 +1715,15 @@ void init_RU_proc(RU_t *ru) { #ifndef DEADLINE_SCHEDULER attr_FH = &proc->attr_FH; + attr_emulateRF = &proc->attr_emulateRF; attr_prach = &proc->attr_prach; //attr_synch = &proc->attr_synch; attr_asynch = &proc->attr_asynch_rxtx; #endif pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru ); - + if(emulate_rf) + pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void*)proc ); if (ru->function == NGFI_RRU_IF4p5) { pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void*)ru ); ///tmp deactivation of synch thread diff --git a/targets/RT/USER/nr-softmodem.c b/targets/RT/USER/nr-softmodem.c index 992ca65981..cddefdf585 100644 --- a/targets/RT/USER/nr-softmodem.c +++ b/targets/RT/USER/nr-softmodem.c @@ -208,7 +208,7 @@ extern void init_eNB_afterRU(void); int transmission_mode=1; int emulate_rf = 0; -//int numerology = 0; +int numerology = 0; int codingw = 0; //int fepw = 0; diff --git a/targets/RT/USER/nr-softmodem.h b/targets/RT/USER/nr-softmodem.h index 13ac6dc329..ac79557f70 100644 --- a/targets/RT/USER/nr-softmodem.h +++ b/targets/RT/USER/nr-softmodem.h @@ -86,6 +86,8 @@ #define CONFIG_HLP_TNOFORK "to ease debugging with gdb\n" #define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n" +#define CONFIG_HLP_EMULATE_RF "Emulated RF enabled(disable by defult)\n" + /***************************************************************************************************************************************/ /* command line options definitions, CMDLINE_XXXX_DESC macros are used to initialize paramdef_t arrays which are then used as argument when calling config_get or config_getlist functions */ @@ -167,6 +169,7 @@ {"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ {"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ +{"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&emulate_rf, defintval:0, TYPE_INT, 0}, \ {"nbiot-disable", CONFIG_HLP_DISABLNBIOT,PARAMFLAG_BOOL, iptr:&nonbiotflag, defintval:0, TYPE_INT, 0} \ } From 34deaae4b8e17b16a37b9178b86cfa4eb430506e Mon Sep 17 00:00:00 2001 From: yilmazt Date: Wed, 26 Sep 2018 16:14:49 +0200 Subject: [PATCH 101/114] Working but uncleaned polar_decoder_dci and related code --- openair1/PHY/CODING/TESTBENCH/polartest.c | 135 ++++++++-- .../nrPolar_tools/nr_bitwise_operations.c | 4 +- .../CODING/nrPolar_tools/nr_polar_decoder.c | 249 ++++++++++++++++++ .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 10 +- .../CODING/nrPolar_tools/nr_polar_encoder.c | 65 ++++- openair1/PHY/CODING/nr_polar_init.c | 5 +- 6 files changed, 433 insertions(+), 35 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 0aa0dd118f..12892b8039 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -10,8 +10,9 @@ #include "PHY/CODING/coding_defs.h" #include "SIMULATION/TOOLS/sim.h" -//#define DEBUG_DCI_POLAR_PARAMS +#define DEBUG_DCI_POLAR_PARAMS //#define DEBUG_POLAR_TIMING +//#define DEBUG_CRC int main(int argc, char *argv[]) { @@ -136,27 +137,119 @@ int main(int argc, char *argv[]) { currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength, aggregation_level); #ifdef DEBUG_DCI_POLAR_PARAMS + uint32_t dci_pdu[4]; + memset(dci_pdu,0,sizeof(uint32_t)*4); + dci_pdu[0]=0x01189400; + printf("dci_pdu: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]); + uint32_t encoder_output[54]; + memset(encoder_output,0,sizeof(uint32_t)*54); + uint16_t size=41; + uint16_t rnti=3; + aggregation_level=8; + nr_polar_init(&nrPolar_params, 1, size, aggregation_level); + t_nrPolar_paramsPtr currentPtrDCI=nr_polar_params(nrPolar_params, 1, size, aggregation_level); + + polar_encoder_dci(dci_pdu, encoder_output, currentPtrDCI, rnti); + for (int i=0;i<54;i++) + printf("encoder_output: [%2d]->0x%08x \n",i, encoder_output[i]); + + uint8_t *encoder_outputByte = malloc(sizeof(uint8_t) * currentPtrDCI->encoderLength); + double *channel_output = malloc (sizeof(double) * currentPtrDCI->encoderLength); + uint32_t dci_estimation[4]; + memset(dci_estimation,0,sizeof(uint32_t)*4); + printf("dci_estimation: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + dci_estimation[0], dci_estimation[1], dci_estimation[2], dci_estimation[3]); + nr_bit2byte_uint32_8_t(encoder_output, currentPtrDCI->encoderLength, encoder_outputByte); + printf("[polartest] encoder_outputByte: "); + for (int i = 0; i < currentPtrDCI->encoderLength; i++) printf("%d-", encoder_outputByte[i]); + printf("\n"); + for(int i=0; iencoderLength; i++) { + if (encoder_outputByte[i] == 0) { + channel_output[i]=1/sqrt(2); + } + else { + channel_output[i]=(-1)/sqrt(2); + } + } + + decoderState = polar_decoder_dci(channel_output, + dci_estimation, + currentPtrDCI, + NR_POLAR_DECODER_LISTSIZE, + NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, + rnti); + printf("dci_estimation: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + dci_estimation[0], dci_estimation[1], dci_estimation[2], dci_estimation[3]); + return 0; +#endif + +#ifdef DEBUG_CRC uint32_t crc; unsigned int poly24c = 0xb2b11700; - testInput[0]=0x01189400; - printf("testInput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - testInput[0], testInput[1], testInput[2], testInput[3]); - uint8_t testInput2[8]; - nr_crc_bit2bit_uint32_8_t(testInput, 32, testInput2); - printf("testInput2: [0]->%x \t [1]->%x \t [2]->%x \t [3]->%x\n" + uint32_t testInputCRC[4]; + testInputCRC[0]=0x00291880; + //testInputCRC[0]=0x01189400; + testInputCRC[1]=0x00000000; + testInputCRC[2]=0x00000000; + testInputCRC[3]=0x00000000; + + uint32_t testInputcrc=0x01189400; + uint32_t testInputcrc2=0x00291880; + + uint8_t testInputCRC2[8]; + nr_crc_bit2bit_uint32_8_t(testInputCRC, 32, testInputCRC2); + printf("testInputCRC2: [0]->%x \t [1]->%x \t [2]->%x \t [3]->%x\n" " [4]->%x \t [5]->%x \t [6]->%x \t [7]->%x\n", - testInput2[0], testInput2[1], testInput2[2], testInput2[3], - testInput2[4], testInput2[5], testInput2[6], testInput2[7]); - printf("crc32: [0]->0x%08x\n",crc24c(testInput2, 32)); - printf("crc56: [0]->0x%08x\n",crc24c(testInput2, 56)); - crc = crc24c(testInput, testLength)>>8; + testInputCRC2[0], testInputCRC2[1], testInputCRC2[2], testInputCRC2[3], + testInputCRC2[4], testInputCRC2[5], testInputCRC2[6], testInputCRC2[7]); + unsigned int crc41 = crc24c(testInputCRC, 32); + unsigned int crc65 = crc24c(testInputCRC, 56); + printf("crc41: [0]->0x%08x\tcrc65: [0]->0x%08x\n",crc41, crc65); + for (int i=0;i<32;i++) printf("crc41[%d]=%d\tcrc65[%d]=%d\n",i,(crc41>>i)&1,i,(crc65>>i)&1); + + crc = crc24c(testInputCRC, testLength)>>8; for (int i=0;i<24;i++) printf("[i]=%d\n",(crc>>i)&1); printf("crc: [0]->0x%08x\n",crc); - testInput[testLength>>3] = ((uint8_t*)&crc)[2]; - testInput[1+(testLength>>3)] = ((uint8_t*)&crc)[1]; - testInput[2+(testLength>>3)] = ((uint8_t*)&crc)[0]; - printf("testInput: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - testInput[0], testInput[1], testInput[2], testInput[3]); + //crcbit(testInputCRC, sizeof(test) - 1, poly24c)); + + testInputCRC[testLength>>3] = ((uint8_t*)&crc)[2]; + testInputCRC[1+(testLength>>3)] = ((uint8_t*)&crc)[1]; + testInputCRC[2+(testLength>>3)] = ((uint8_t*)&crc)[0]; + printf("testInputCRC: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + testInputCRC[0], testInputCRC[1], testInputCRC[2], testInputCRC[3]); + + + //uint32_t trial32 = 0xffffffff; + uint32_t trial32 = 0xf10fffff; + uint8_t a[4]; + //memcpy(a, &trial32, sizeof(trial32)); + *(uint32_t *)a = trial32; + unsigned char trial[4]; + trial[0]=0xff; trial[1]=0xff; trial[2]=0x0f; trial[3]=0xf1; + uint32_t trialcrc = crc24c(trial, 32); + uint32_t trialcrc32 = crc24c((uint8_t *)&trial32, 32); + //uint32_t trialcrc32 = crc24c(a, 32); + printf("crcbit(trial = %x\n", crcbit(trial, 4, poly24c)); + printf("trialcrc = %x\n", trialcrc); + printf("trialcrc32 = %x\n", trialcrc32); + for (int i=0;i<32;i++) printf("trialcrc[%2d]=%d\ttrialcrc32[%2d]=%d\n",i,(trialcrc>>i)&1,i,(trialcrc32>>i)&1); + + + //uint8_t nr_polar_A[32] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; + uint8_t nr_polar_A[32] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,1}; + uint8_t nr_polar_crc[24]; + uint8_t **crc_generator_matrix = crc24c_generator_matrix(32); + nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(nr_polar_A, + crc_generator_matrix, + nr_polar_crc, + 32, + 24); + for (uint8_t i = 0; i < 24; i++){ + nr_polar_crc[i] = (nr_polar_crc[i] % 2); + printf("nr_polar_crc[%d]=%d\n",i,nr_polar_crc[i]); + } + return 0; #endif #ifdef DEBUG_POLAR_TIMING @@ -207,8 +300,8 @@ int main(int argc, char *argv[]) { stop_meas(&timeEncoder); /*printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]); - printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]); -*/ + printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]);*/ + //Bit-to-byte: nr_bit2byte_uint32_8_t(encoderOutput, coderLength, encoderOutputByte); @@ -237,8 +330,8 @@ int main(int argc, char *argv[]) { aPrioriArray); stop_meas(&timeDecoder); /*printf("testInput: [0]->0x%08x\n", testInput[0]); - printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]); -*/ + printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]);*/ + //calculate errors if (decoderState==-1) { diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c index ba06922816..beabeead36 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c @@ -23,11 +23,13 @@ void nr_bit2byte_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out) { uint8_t arrayInd = ceil(arraySize / 32.0); - for (int i = 0; i < arrayInd; i++) { + for (int i = 0; i < (arrayInd-1); i++) { for (int j = 0; j < 32; j++) { out[j+(i*32)] = (in[i] >> j) & 1; } } + + for (int j = 0; j < arraySize - ((arrayInd-1) * 32); j++) out[j + ((arrayInd-1) * 32)] = (in[(arrayInd-1)] >> j) & 1; } void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out) { diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 1616c498e4..0a866381b1 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -785,3 +785,252 @@ int8_t polar_decoder_aPriori_timing(double *input, nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } + + +int8_t polar_decoder_dci(double *input, + uint32_t *out, + t_nrPolar_paramsPtr polarParams, + uint8_t listSize, + uint8_t pathMetricAppr, + uint16_t n_RNTI) +{ + + uint8_t ***bit = nr_alloc_uint8_t_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); + uint8_t **bitUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True + uint8_t **llrUpdated = nr_alloc_uint8_t_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True + double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); + uint8_t **crcChecksum = nr_alloc_uint8_t_2D_array(polarParams->crcParityBits, 2*listSize); + double *pathMetric = malloc(sizeof(double)*(2*listSize)); + uint8_t *crcState = malloc(sizeof(uint8_t)*(2*listSize)); //0=False, 1=True + uint8_t extended_crc_scrambling_pattern[polarParams->crcParityBits]; + + for (int i=0; i<(2*listSize); i++) { + pathMetric[i] = 0; + crcState[i]=1; + } + for (int i=0; iN; i++) { + llrUpdated[i][polarParams->n]=1; + bitUpdated[i][0]=((polarParams->information_bit_pattern[i]+1) % 2); + } + + uint8_t **extended_crc_generator_matrix = malloc(polarParams->K * sizeof(uint8_t *)); //G_P3: K-by-P + uint8_t **tempECGM = malloc(polarParams->K * sizeof(uint8_t *)); //G_P2: K-by-P + for (int i = 0; i < polarParams->K; i++){ + extended_crc_generator_matrix[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t)); + tempECGM[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t)); + } + + for (int i=0; ipayloadBits; i++) { + for (int j=0; jcrcParityBits; j++) { + tempECGM[i][j]=polarParams->crc_generator_matrix[i+polarParams->crcParityBits][j]; + } + } + for (int i=polarParams->payloadBits; iK; i++) { + for (int j=0; jcrcParityBits; j++) { + if( (i-polarParams->payloadBits) == j ){ + tempECGM[i][j]=1; + } else { + tempECGM[i][j]=0; + } + } + } + + for (int i=0; iK; i++) { + for (int j=0; jcrcParityBits; j++) { + extended_crc_generator_matrix[i][j]=tempECGM[polarParams->interleaving_pattern[i]][j]; + } + } + + //The index of the last 1-valued bit that appears in each column. + uint16_t last1ind[polarParams->crcParityBits]; + for (int j=0; jcrcParityBits; j++) { + for (int i=0; iK; i++) { + if (extended_crc_generator_matrix[i][j]==1) last1ind[j]=i; + } + } + + for (int i=0;i<8;i++) extended_crc_scrambling_pattern[i]=0; + for (int i=8; icrcParityBits; i++) { + extended_crc_scrambling_pattern[i]=(n_RNTI>>(23-i))&1; + } + + double *d_tilde = malloc(sizeof(double) * polarParams->N); + nr_polar_rate_matching(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); + for (int j = 0; j < polarParams->N; j++) llr[j][polarParams->n][0]=d_tilde[j]; + + /* + * SCL polar decoder. + */ + + for (int i=0; icrcParityBits; i++) { + for (int j=0; jcrcParityBits; j++) crcChecksum[i][0]=crcChecksum[i][0]+polarParams->crc_generator_matrix[j][i]; + crcChecksum[i][0]=(crcChecksum[i][0]%2); + } + + uint32_t nonFrozenBit=0; + uint8_t currentListSize=1; + uint8_t decoderIterationCheck=0; + int16_t checkCrcBits=-1; + uint8_t listIndex[2*listSize], copyIndex; + + for (uint16_t currentBit=0; currentBitN; currentBit++){ + updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1), pathMetricAppr); + if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. + updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 + } else { //Information or CRC bit. + updatePathMetric2(pathMetric, llr, currentListSize, currentBit, pathMetricAppr); + + for (int i = 0; i < currentListSize; i++) { + for (int j = 0; j < polarParams->N; j++) { + for (int k = 0; k < (polarParams->n+1); k++) { + bit[j][k][i+currentListSize]=bit[j][k][i]; + llr[j][k][i+currentListSize]=llr[j][k][i];}}} + for (int i = 0; i < currentListSize; i++) { + bit[currentBit][0][i]=0; + crcState[i+currentListSize]=crcState[i]; + } + for (int i = currentListSize; i < 2*currentListSize; i++) bit[currentBit][0][i]=1; + bitUpdated[currentBit][0]=1; + updateCrcChecksum2(crcChecksum, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits); + currentListSize*=2; + + //Keep only the best "listSize" number of entries. + if (currentListSize > listSize) { + for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; + nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); + + //sort listIndex[listSize, ..., 2*listSize-1] in descending order. + uint8_t swaps, tempInd; + for (uint8_t i = 0; i < listSize; i++) { + swaps = 0; + for (uint8_t j = listSize; j < (2*listSize - i) - 1; j++) { + if (listIndex[j+1] > listIndex[j]) { + tempInd = listIndex[j]; + listIndex[j] = listIndex[j + 1]; + listIndex[j + 1] = tempInd; + swaps++; + } + } + if (swaps == 0) + break; + } + + //First, backup the best "listSize" number of entries. + for (int k=(listSize-1); k>0; k--) { + for (int i=0; iN; i++) { + for (int j=0; j<(polarParams->n+1); j++) { + bit[i][j][listIndex[(2*listSize-1)-k]]=bit[i][j][listIndex[k]]; + llr[i][j][listIndex[(2*listSize-1)-k]]=llr[i][j][listIndex[k]]; + } + } + } + for (int k=(listSize-1); k>0; k--) { + for (int i = 0; i < polarParams->crcParityBits; i++) { + crcChecksum[i][listIndex[(2*listSize-1)-k]] = crcChecksum[i][listIndex[k]]; + } + } + for (int k=(listSize-1); k>0; k--) crcState[listIndex[(2*listSize-1)-k]]=crcState[listIndex[k]]; + + //Copy the best "listSize" number of entries to the first indices. + for (int k = 0; k < listSize; k++) { + if (k > listIndex[k]) { + copyIndex = listIndex[(2*listSize-1)-k]; + } else { //Use the backup. + copyIndex = listIndex[k]; + } + for (int i = 0; i < polarParams->N; i++) { + for (int j = 0; j < (polarParams->n + 1); j++) { + bit[i][j][k] = bit[i][j][copyIndex]; + llr[i][j][k] = llr[i][j][copyIndex]; + } + } + } + for (int k = 0; k < listSize; k++) { + if (k > listIndex[k]) { + copyIndex = listIndex[(2*listSize-1)-k]; + } else { //Use the backup. + copyIndex = listIndex[k]; + } + for (int i = 0; i < polarParams->crcParityBits; i++) { + crcChecksum[i][k]=crcChecksum[i][copyIndex]; + } + } + for (int k = 0; k < listSize; k++) { + if (k > listIndex[k]) { + copyIndex = listIndex[(2*listSize-1)-k]; + } else { //Use the backup. + copyIndex = listIndex[k]; + } + crcState[k]=crcState[copyIndex]; + } + currentListSize = listSize; + } + + for (int i=0; icrcParityBits; i++) { + if (last1ind[i]==nonFrozenBit) { + checkCrcBits=i; + break; + } + } + + if ( checkCrcBits > (-1) ) { + for (uint8_t i = 0; i < currentListSize; i++) { + if (crcChecksum[checkCrcBits][i]!=extended_crc_scrambling_pattern[checkCrcBits]) { + crcState[i]=0; //0=False, 1=True + } + } + } + + for (uint8_t i = 0; i < currentListSize; i++) decoderIterationCheck+=crcState[i]; + if (decoderIterationCheck==0) { + //perror("[SCL polar decoder] All list entries have failed the CRC checks."); + free(d_tilde); + free(pathMetric); + free(crcState); + nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1)); + nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); + nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits); + return(-1); + } + + nonFrozenBit++; + decoderIterationCheck=0; + checkCrcBits=-1; + } + } + + for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; + nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); + + for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) { + if ( crcState[listIndex[i]] == 1 ) { + for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_U[j]=bit[j][0][listIndex[i]]; + + //Extract the information bits (û to ĉ) + nr_polar_info_bit_extraction(polarParams->nr_polar_U, polarParams->nr_polar_CPrime, polarParams->information_bit_pattern, polarParams->N); + + //Deinterleaving (ĉ to b) + nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); + + //Remove the CRC (â) + for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; + + break; + } + } + + free(d_tilde); + free(pathMetric); + free(crcState); + nr_free_uint8_t_3D_array(bit, polarParams->N, (polarParams->n+1)); + nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1)); + nr_free_uint8_t_2D_array(crcChecksum, polarParams->crcParityBits); + nr_free_uint8_t_2D_array(extended_crc_generator_matrix, polarParams->K); + nr_free_uint8_t_2D_array(tempECGM, polarParams->K); + + /* + * Return bits. + */ + nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); + return(0); +} diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 9615a0d245..da602b66e3 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -43,7 +43,7 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" #include "PHY/CODING/coding_defs.h" -//#include "SIMULATION/TOOLS/sim.h" +#include "SIMULATION/TOOLS/sim.h" #define NR_POLAR_DECODER_LISTSIZE 8 //uint8_t #define NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION 0 //uint8_t; 0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12) @@ -92,6 +92,7 @@ struct nrPolar_params { //polar_encoder vectors uint8_t *nr_polar_crc; uint8_t *nr_polar_aPrime; + uint8_t *nr_polar_APrime; uint8_t *nr_polar_D; uint8_t *nr_polar_E; @@ -141,6 +142,13 @@ int8_t polar_decoder_aPriori_timing(double *input, double cpuFreqGHz, FILE* logFile); +int8_t polar_decoder_dci(double *input, + uint32_t *out, + t_nrPolar_paramsPtr polarParams, + uint8_t listSize, + uint8_t pathMetricAppr, + uint16_t n_RNTI); + void nr_polar_init(t_nrPolar_paramsPtr *polarParams, int8_t messageType, uint16_t messageLength, diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index c1a0c31a42..9d84bc7dc8 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -115,19 +115,64 @@ void polar_encoder_dci(uint32_t *in, #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] in: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", in[0], in[1], in[2], in[3]); #endif - //(a to a') - nr_crc_bit2bit_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_aPrime); - //Parity bits computation (p) - polarParams->crcBit = crc24c(polarParams->nr_polar_aPrime, - (polarParams->payloadBits+polarParams->crcParityBits)); -#ifdef DEBUG_POLAR_ENCODER_DCI - printf("[polar_encoder_dci] crc: 0x%08x\n", polarParams->crcBit); -#endif - //(a to b) /* * Bytewise operations */ + //(a to a') + nr_bit2byte_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_A); + for (int i=0; icrcParityBits; i++) polarParams->nr_polar_APrime[i]=1; + for (int i=0; ipayloadBits; i++) polarParams->nr_polar_APrime[i+(polarParams->crcParityBits)]=polarParams->nr_polar_A[i]; +#ifdef DEBUG_POLAR_ENCODER_DCI + printf("[polar_encoder_dci] A: "); + for (int i=0; ipayloadBits; i++) printf("%d-", polarParams->nr_polar_A[i]); + printf("\n"); + printf("[polar_encoder_dci] APrime: "); + for (int i=0; iK; i++) printf("%d-", polarParams->nr_polar_APrime[i]); + printf("\n"); + printf("[polar_encoder_dci] GP: "); + for (int i=0; icrcParityBits; i++) printf("%d-", polarParams->crc_generator_matrix[0][i]); + printf("\n"); +#endif + //Calculate CRC. + nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(polarParams->nr_polar_APrime, + polarParams->crc_generator_matrix, + polarParams->nr_polar_crc, + polarParams->K, + polarParams->crcParityBits); + for (uint8_t i = 0; i < polarParams->crcParityBits; i++) polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2); +#ifdef DEBUG_POLAR_ENCODER_DCI + printf("[polar_encoder_dci] CRC: "); + for (int i=0; icrcParityBits; i++) printf("%d-", polarParams->nr_polar_crc[i]); + printf("\n"); +#endif + + //Attach CRC to the Transport Block. (a to b) + for (uint16_t i = 0; i < polarParams->payloadBits; i++) + polarParams->nr_polar_B[i] = polarParams->nr_polar_A[i]; + for (uint16_t i = polarParams->payloadBits; i < polarParams->K; i++) + polarParams->nr_polar_B[i]= polarParams->nr_polar_crc[i-(polarParams->payloadBits)]; + //Scrambling (b to c) + for (int i=0; i<16; i++) { + polarParams->nr_polar_B[polarParams->payloadBits+8+i] = + ( polarParams->nr_polar_B[polarParams->payloadBits+8+i] + ((n_RNTI>>(15-i))&1) ) % 2; + } + +/* //(a to a') + nr_crc_bit2bit_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_aPrime); + //Parity bits computation (p) + polarParams->crcBit = crc24c(polarParams->nr_polar_aPrime, (polarParams->payloadBits+polarParams->crcParityBits)); +#ifdef DEBUG_POLAR_ENCODER_DCI + printf("[polar_encoder_dci] crc: 0x%08x\n", polarParams->crcBit); + for (int i=0; i<32; i++) + { + printf("%d\n",((polarParams->crcBit)>>i)&1); + } +#endif + //(a to b) + // + // Bytewise operations + // uint8_t arrayInd = ceil(polarParams->payloadBits / 8.0); for (int i=0; inr_polar_B[polarParams->payloadBits+8+i] = ( (((polarParams->crcBit)>>(23-i))&1) + ((n_RNTI>>(15-i))&1) ) % 2; - } + }*/ #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] B: "); for (int i = 0; i < polarParams->K; i++) printf("%d-", polarParams->nr_polar_B[i]); diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index 32e9cca553..87da29c48e 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -69,6 +69,7 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, newPolarInitNode->payloadBits = NR_POLAR_PBCH_PAYLOAD_BITS; newPolarInitNode->encoderLength = NR_POLAR_PBCH_E; newPolarInitNode->crcCorrectionBits = NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS; + newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits);//G_P } else if (messageType == 1) { //DCI newPolarInitNode->n_max = NR_POLAR_DCI_N_MAX; newPolarInitNode->i_il = NR_POLAR_DCI_I_IL; @@ -80,6 +81,7 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, newPolarInitNode->payloadBits = messageLength; newPolarInitNode->encoderLength = aggregation_level*108; newPolarInitNode->crcCorrectionBits = NR_POLAR_DCI_CRC_ERROR_CORRECTION_BITS; + newPolarInitNode->crc_generator_matrix=crc24c_generator_matrix(newPolarInitNode->payloadBits+newPolarInitNode->crcParityBits);//G_P } else if (messageType == -1) { //UCI } else { @@ -89,13 +91,12 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, newPolarInitNode->K = newPolarInitNode->payloadBits + newPolarInitNode->crcParityBits; // Number of bits to encode. newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K, newPolarInitNode->encoderLength, newPolarInitNode->n_max); newPolarInitNode->n = log2(newPolarInitNode->N); - - newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits); newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n); //polar_encoder vectors: newPolarInitNode->nr_polar_crc = malloc(sizeof(uint8_t) * newPolarInitNode->crcParityBits); newPolarInitNode->nr_polar_aPrime = malloc(sizeof(uint8_t) * ((ceil((newPolarInitNode->payloadBits)/32.0)*4)+3)); + newPolarInitNode->nr_polar_APrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); newPolarInitNode->nr_polar_D = malloc(sizeof(uint8_t) * newPolarInitNode->N); newPolarInitNode->nr_polar_E = malloc(sizeof(uint8_t) * newPolarInitNode->encoderLength); From b6b86cce4150d6c1f5c14a88ec90bdf99a6e6829 Mon Sep 17 00:00:00 2001 From: Turker YILMAZ Date: Wed, 26 Sep 2018 16:20:12 +0200 Subject: [PATCH 102/114] Removing #include "SIMULATION/TOOLS/sim.h" in nr_polar_defs.h --- openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index da602b66e3..e2e79e22a7 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -43,7 +43,7 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" #include "PHY/CODING/coding_defs.h" -#include "SIMULATION/TOOLS/sim.h" +//#include "SIMULATION/TOOLS/sim.h" #define NR_POLAR_DECODER_LISTSIZE 8 //uint8_t #define NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION 0 //uint8_t; 0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12) From 6177e2d8817118fb64dc1cd8a4e113dbdf0e20ca Mon Sep 17 00:00:00 2001 From: Turker YILMAZ Date: Wed, 26 Sep 2018 18:07:26 +0200 Subject: [PATCH 103/114] Update nr_dci.c --- openair1/PHY/NR_TRANSPORT/nr_dci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 4cca9e85f6..ed2cb5950d 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -217,7 +217,7 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars, nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L); #endif - polar_encoder_dci(dci_alloc.dci_pdu, encoder_output, currentPtr, n_RNTI); + polar_encoder_dci(dci_alloc.dci_pdu, encoder_output, currentPtr, pdcch_params.rnti); #ifdef DEBUG_CHANNEL_CODING printf("DCI PDU: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", From 926b7a49d50ec69c2ad56f5642354276dd084417 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Thu, 27 Sep 2018 14:57:27 +0200 Subject: [PATCH 104/114] NR PDCCH development: polar decoder integration --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 350 +++++++++++-------- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 13 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 6 +- 3 files changed, 226 insertions(+), 143 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 41e3f01691..53b1c554db 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -411,17 +411,18 @@ symbol 0 | ... bundle 3 bundle 6 bundle_j = (c*coreset_interleaver_size_R)+r; f_bundle_j = ((r*coreset_C)+c+n_shift)%((coreset_nbr_rb*coreset_time_dur)/reg_bundle_size_L); if (coreset_interleaved==0) f_bundle_j=bundle_j; - #ifdef NR_PDCCH_DCI_DEBUG + #ifndef NR_PDCCH_DCI_DEBUG printf("\n\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_demapping_deinterleaving)-> [r=%d,c=%d] bundle_j(%d) interleaved at f_bundle_j(%d)\n",r,c,bundle_j,f_bundle_j); #endif } f_reg = (f_bundle_j*reg_bundle_size_L)+(reg%reg_bundle_size_L); - index_z = 9*reg; + //index_z = 9*reg; + index_z = 9*(uint16_t)floor(reg/coreset_time_dur) + (9*coreset_nbr_rb)*(reg%coreset_time_dur); //index_llr = 9*(((uint16_t)floor(f_reg/reg_bundle_size_L)+(f_reg)%coreset_time_dur))*(coreset_nbr_rb); index_llr = 9*((uint16_t)floor(f_reg/coreset_time_dur)+((f_reg%coreset_time_dur)*(coreset_nbr_rb))); for (int i=0; i<9; i++){ z[index_z + i] = llr[index_llr + i]; - #ifdef NR_PDCCH_DCI_DEBUG + #ifndef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_demapping_deinterleaving)-> [reg=%d,bundle_j=%d] z[%d]=(%d,%d) <-> \t[f_reg=%d,fbundle_j=%d] llr[%d]=(%d,%d) \n", reg,bundle_j,(index_z + i),*(char*) &z[index_z + i],*(1 + (char*) &z[index_z + i]), f_reg,f_bundle_j,(index_llr + i),*(char*) &llr[index_llr + i], *(1 + (char*) &llr[index_llr + i])); @@ -431,10 +432,7 @@ symbol 0 | ... bundle 3 bundle 6 } } - - - - +#if 0 void nr_pdcch_demapping(uint16_t *llr, uint16_t *wbar, NR_DL_FRAME_PARMS *frame_parms, uint8_t coreset_time_dur, uint32_t coreset_nbr_rb) { @@ -503,6 +501,7 @@ void nr_pdcch_demapping(uint16_t *llr, uint16_t *wbar, } } } +#endif //0 #endif @@ -614,7 +613,7 @@ void pdcch_demapping(uint16_t *llr,uint16_t *wbar,NR_DL_FRAME_PARMS *frame_parms static uint16_t wtemp_rx[Msymb]; - +#if 0 #ifdef NR_PDCCH_DCI_RUN void nr_pdcch_deinterleaving(NR_DL_FRAME_PARMS *frame_parms, uint16_t *z, uint16_t *wbar, uint8_t coreset_time_dur, uint8_t reg_bundle_size_L, @@ -686,6 +685,7 @@ void nr_pdcch_deinterleaving(NR_DL_FRAME_PARMS *frame_parms, uint16_t *z, } } #endif +#endif //0 @@ -851,7 +851,7 @@ int32_t pdcch_qpsk_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, char *pdcch_llr, uint8_t symbol,uint32_t coreset_nbr_rb) { - int16_t *rxF = (int16_t*) &rxdataF_comp[0][(symbol * coreset_nbr_rb * 9)]; + int16_t *rxF = (int16_t*) &rxdataF_comp[0][(symbol * coreset_nbr_rb * 12)]; int32_t i; char *pdcch_llr8; @@ -873,8 +873,8 @@ int32_t nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, *pdcch_llr8 = -32; else *pdcch_llr8 = (char) (*rxF); -#ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_llr)-> llr logs: i=%d *rxF:%d => *pdcch_llr8:%d\n",i/18,i,*rxF,*pdcch_llr8); +#ifndef NR_PDCCH_DCI_DEBUG + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_llr)-> llr logs: rb=%d i=%d *rxF:%d => *pdcch_llr8:%d\n",i/18,i,*rxF,*pdcch_llr8); #endif rxF++; pdcch_llr8++; @@ -1249,15 +1249,15 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, #endif } - dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITHOUT_DMRS)]; + dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITH_DMRS)]; #ifdef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> dl_ch0_ext = &dl_ch_estimates_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 9) = (%d)]\n", - aarx,symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITHOUT_DMRS)); + aarx,symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITH_DMRS)); #endif - rxF_ext = &rxdataF_ext[aarx][symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITHOUT_DMRS)]; + rxF_ext = &rxdataF_ext[aarx][symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITH_DMRS)]; #ifdef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> rxF_ext = &rxdataF_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 9) = (%d)]\n", - aarx,symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITHOUT_DMRS)); + aarx,symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITH_DMRS)); printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> (for symbol=%d, aarx=%d), symbol_mod=%d, nushiftmod3=%d \n",symbol,aarx,symbol_mod,nushiftmod3); #endif @@ -1307,7 +1307,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, if ((c_rb < (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) == 0)) { //if RB to be treated is lower than middle system bandwidth then rxdataF pointed at (offset + c_br + symbol * ofdm_symbol_size): even case rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))]; - #ifdef NR_PDCCH_DCI_DEBUG + #ifndef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> in even case c_rb (%d) is lower than half N_RB_DL -> rxF = &rxdataF[aarx = (%d)][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", c_rb,aarx,(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))); #endif @@ -1316,7 +1316,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, // number of RBs is even and c_rb is higher than half system bandwidth (we don't skip DC) // if these conditions are true the pointer has to be situated at the 1st part of the rxdataF rxF = &rxdataF[aarx][(12*(c_rb - (frame_parms->N_RB_DL>>1)) + (symbol * (frame_parms->ofdm_symbol_size)))]; // we point at the 1st part of the rxdataF in symbol - #ifdef NR_PDCCH_DCI_DEBUG + #ifndef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> in even case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][(12*(c_rb - (frame_parms->N_RB_DL>>1)) + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", c_rb,aarx,(12*(c_rb - (frame_parms->N_RB_DL>>1)) + (symbol * (frame_parms->ofdm_symbol_size)))); #endif @@ -1329,7 +1329,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, if ((c_rb < (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)){ //if RB to be treated is lower than middle system bandwidth then rxdataF pointed at (offset + c_br + symbol * ofdm_symbol_size): odd case rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))]; - #ifdef NR_PDCCH_DCI_DEBUG + #ifndef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> in odd case c_rb (%d) is lower or equal than half N_RB_DL -> rxF = &rxdataF[aarx = (%d)][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", c_rb,aarx,(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))); #endif @@ -1338,7 +1338,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, // number of RBs is odd and c_rb is higher than half system bandwidth + 1 // if these conditions are true the pointer has to be situated at the 1st part of the rxdataF just after the first IQ symbols of the RB containing DC rxF = &rxdataF[aarx][(12*(c_rb - (frame_parms->N_RB_DL>>1)) - 6 + (symbol * (frame_parms->ofdm_symbol_size)))]; // we point at the 1st part of the rxdataF in symbol - #ifdef NR_PDCCH_DCI_DEBUG + #ifndef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> in odd case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][(12*(c_rb - frame_parms->N_RB_DL) - 5 + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", c_rb,aarx,(12*(c_rb - (frame_parms->N_RB_DL>>1)) - 6 + (symbol * (frame_parms->ofdm_symbol_size)))); #endif @@ -1347,7 +1347,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, // if odd number RBs in system bandwidth and first RB to be treated is higher than middle system bandwidth (around DC) // we have to treat the RB in two parts: first part from i=0 to 5, the data is at the end of rxdataF (pointing at the end of the table) rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))]; - #ifdef NR_PDCCH_DCI_DEBUG + #ifndef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> in odd case c_rb (%d) is half N_RB_DL + 1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", c_rb,aarx,(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))); #endif @@ -1382,7 +1382,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, } // then we point at the begining of the symbol part of rxdataF do process second part of RB rxF = &rxdataF[aarx][((symbol * (frame_parms->ofdm_symbol_size)))]; // we point at the 1st part of the rxdataF in symbol - #ifdef NR_PDCCH_DCI_DEBUG + #ifndef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> in odd case c_rb (%d) is half N_RB_DL +1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][(symbol * (frame_parms->ofdm_symbol_size)) = (%d)]\n", c_rb,aarx,(symbol * (frame_parms->ofdm_symbol_size))); #endif @@ -1417,17 +1417,17 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, for (i = 0; i < 12; i++) { if ((i != 1) && (i != 5) && (i != 9)) { rxF_ext[j] = rxF[i]; - #ifdef NR_PDCCH_DCI_DEBUG + #ifndef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d)", c_rb, i, j, *(short *) &rxF_ext[j],*(1 + (short*) &rxF_ext[j]), i, *(short *) &rxF[i], *(1 + (short*) &rxF[i])); #endif dl_ch0_ext[j] = dl_ch0[i]; //printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> ch %d => dl_ch0(%d,%d)\n", i, *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i])); - printf("\t-> dl_ch0[%d] => dl_ch0_ext[%d](%d,%d)\n", i,j, *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i])); + //printf("\t-> dl_ch0[%d] => dl_ch0_ext[%d](%d,%d)\n", i,j, *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i])); j++; } else { - #ifdef NR_PDCCH_DCI_DEBUG + #ifndef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t\t <==> DM-RS PDCCH, this is a pilot symbol\n", c_rb, i, j, *(short *) &rxF_ext[j], *(1 + (short*) &rxF_ext[j]), i, *(short *) &rxF[i], *(1 + (short*) &rxF[i])); @@ -2187,9 +2187,9 @@ void nr_pdcch_channel_compensation(int32_t **rxdataF_ext, for (aarx=0; aarxnb_antennas_rx; aarx++) { #if defined(__x86_64__) || defined(__i386__) - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*20*12]; - rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*20*12]; - rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol*20*12]; + dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*coreset_nbr_rb*12]; + rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*coreset_nbr_rb*12]; + rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol*coreset_nbr_rb*12]; //printf("ch compensation dl_ch ext addr %p \n", &dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*20*12]); //printf("rxdataf ext addr %p symbol %d\n", &rxdataF_ext[aarx][symbol*20*12], symbol); //printf("rxdataf_comp addr %p\n",&rxdataF_comp[(aatx<<1)+aarx][symbol*20*12]); @@ -2220,9 +2220,9 @@ void nr_pdcch_channel_compensation(int32_t **rxdataF_ext, // print_ints("c0",&mmtmpP2); // print_ints("c1",&mmtmpP3); rxdataF_comp128[0] = _mm_packs_epi32(mmtmpP2,mmtmpP3); - // print_shorts("rx:",rxdataF128); - // print_shorts("ch:",dl_ch128); - // print_shorts("pack:",rxdataF_comp128); + //print_shorts("rx:",rxdataF128); + //print_shorts("ch:",dl_ch128); + //print_shorts("pack:",rxdataF_comp128); // multiply by conjugated channel mmtmpP0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); @@ -2237,9 +2237,9 @@ void nr_pdcch_channel_compensation(int32_t **rxdataF_ext, mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); rxdataF_comp128[1] = _mm_packs_epi32(mmtmpP2,mmtmpP3); - // print_shorts("rx:",rxdataF128+1); - // print_shorts("ch:",dl_ch128+1); - // print_shorts("pack:",rxdataF_comp128+1); + //print_shorts("rx:",rxdataF128+1); + //print_shorts("ch:",dl_ch128+1); + //print_shorts("pack:",rxdataF_comp128+1); // multiply by conjugated channel mmtmpP0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); @@ -2254,9 +2254,18 @@ void nr_pdcch_channel_compensation(int32_t **rxdataF_ext, mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1); mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1); rxdataF_comp128[2] = _mm_packs_epi32(mmtmpP2,mmtmpP3); - // print_shorts("rx:",rxdataF128+2); - // print_shorts("ch:",dl_ch128+2); - // print_shorts("pack:",rxdataF_comp128+2); + /////////////////////////////////////////////////////////////////////////////////////////////// + //print_shorts("rx:",rxdataF128+2); + //print_shorts("ch:",dl_ch128+2); + //print_shorts("pack:",rxdataF_comp128+2); + +#ifndef NR_PDCCH_DCI_DEBUG + for (int i=0; i<20 ; i++) + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_channel_compensation)-> rb=%d rxdataF128[%d]=(%d,%d) rxdataF_comp128[%d]=(%d,%d)\n", + rb, i, *(short *) &rxdataF128[i],*(1 + (short*) &rxdataF128[i]), + i,*(short *) &rxdataF_comp128[i], *(1 + (short*) &rxdataF_comp128[i])); + +#endif dl_ch128+=3; rxdataF128+=3; @@ -3007,23 +3016,33 @@ nr_pdcch_demapping_deinterleaving(pdcch_vars[eNB_id]->llr, } printf("\n"); #endif +#endif + +//#if 0 + #ifdef NR_PDCCH_DCI_DEBUG +// printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we end nr_pdcch_unscrambling()\n"); +// for (int i=0; i<(coreset_time_dur*coreset_nbr_rb*9); i++){ +// printf("\t before unscrambling : e_rx[%d]=(%d,%d)\n",i,*(char*) &pdcch_vars[eNB_id]->e_rx[i],*(1 + (char*) &pdcch_vars[eNB_id]->e_rx[i])); +// } +// printf("\n"); + #endif + nr_pdcch_unscrambling(pdcch_vars[eNB_id]->crnti, frame_parms, nr_tti_rx, - pdcch_vars[eNB_id]->e_rx, + (uint16_t*) pdcch_vars[eNB_id]->e_rx, coreset_time_dur*coreset_nbr_rb*9*2, // get_nCCE(n_pdcch_symbols, frame_parms, mi) * 72, pdcch_DMRS_scrambling_id, do_common); #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we end nr_pdcch_unscrambling()\n"); - for (int i=0; i<(coreset_time_dur*coreset_nbr_rb*9); i++){ - printf("\te_rx[%d]=(%d,%d)",i,*(char*) &pdcch_vars[eNB_id]->e_rx[i],*(1 + (char*) &pdcch_vars[eNB_id]->e_rx[i])); - if (i%10 == 0) printf("\n"); - } - printf("\n"); +// for (int i=0; i<(coreset_time_dur*coreset_nbr_rb*9); i++){ +// printf("\t after unscrambling : e_rx[%d]=(%d,%d)\n",i,*(char*) &pdcch_vars[eNB_id]->e_rx[i],*(1 + (char*) &pdcch_vars[eNB_id]->e_rx[i])); +// } +// printf("\n"); #endif -#endif +//#endif //0 /* printf("\t### in nr_rx_pdcch() function we enter pdcch_demapping()\n"); @@ -3091,6 +3110,84 @@ void pdcch_scrambling(NR_DL_FRAME_PARMS *frame_parms, #ifdef NR_PDCCH_DCI_RUN void nr_pdcch_unscrambling(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_tti_rx, + uint16_t *z, uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common) { + + int i; + uint8_t reset; + uint32_t x1, x2, s = 0; + uint16_t n_id; //{0,1,...,65535} + uint32_t n_rnti; + + reset = 1; + // x1 is set in first call to lte_gold_generic + //do_common=1; +if (do_common){ + n_id = frame_parms->Nid_cell; + n_rnti = 0; +} else { + n_id = pdcch_DMRS_scrambling_id; + n_rnti = (uint32_t)crnti; +} +//x2 = ((n_rnti * (1 << 16)) + n_id)%(1 << 31); +//uint32_t puissance_2_16 = ((1<<16)*n_rnti)+n_id; +//uint32_t puissance_2_31= (1<<30)*2; +//uint32_t calc_x2=puissance_2_16%puissance_2_31; + x2 = (((1<<16)*n_rnti)+n_id)%((1<<30)*2); //this is c_init in 38.211 v15.1.0 Section 7.3.2.3 +// x2 = (nr_tti_rx << 9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 +#ifndef NR_PDCCH_DCI_DEBUG +printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> (c_init=%d, n_id=%d, n_rnti=%d, length=%d)\n",x2,n_id,n_rnti,length); +#endif + for (i = 0; i < length; i++) { + if ((i & 0x1f) == 0) { + s = lte_gold_generic(&x1, &x2, reset); + //printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> lte_gold[%d]=%x\n",i,s); + reset = 0; + } + + #ifndef NR_PDCCH_DCI_DEBUG + if (i%2 == 0) printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> unscrambling %d : scrambled_z=%d, => ", + i,*(char*) &z[(int)floor(i/2)]); + if (i%2 == 1) printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> unscrambling %d : scrambled_z=%d, => ", + i,*(1 + (char*) &z[(int)floor(i/2)])); + #endif + if (((s >> (i % 32)) & 1) == 1){ + if (i%2 == 0) *(char*) &z[(int)floor(i/2)] = -(*(char*) &z[(int)floor(i/2)]); + if (i%2 == 1) *(1 + (char*) &z[(int)floor(i/2)]) = -(*(1 + (char*) &z[(int)floor(i/2)])); + } + //llr[i] = -llr[i]; + //llr[i] = (-1)*llr[i]; + #ifndef NR_PDCCH_DCI_DEBUG + if (i%2 == 0) printf("unscrambled_z=%d\n",*(char*) &z[(int)floor(i/2)]); + if (i%2 == 1) printf("unscrambled_z=%d\n",*(1 + (char*) &z[(int)floor(i/2)])); + #endif + + } + +#ifdef NR_PDCCH_DCI_DEBUG +//k = 0; +//for (int j = 0; j < length; j++){ +// if ((j%32==0) && (j!=0)) k++; +// if ((j%2 == 0) && ((*(char*) &z[(int)floor(i/2)]) > 0)) { +// unscrambled[k] = (unscrambled[k]<<1) + 1; +// } +// if ((j%2 == 0) && ((*(char*) &z[(int)floor(i/2)]) <= 0)) { +// unscrambled[k] = (unscrambled[k]<<1) + 0; +// } +// if ((j%2 == 1) && ((*(1 + (char*) &z[(int)floor(i/2)])) > 0)) { +// unscrambled[k] = (unscrambled[k]<<1) + 1; +// } +// if ((j%2 == 1) && ((*(1 + (char*) &z[(int)floor(i/2)])) <= 0)) { +// unscrambled[k] = (unscrambled[k]<<1) + 0; +// } +//} +//for (int p=0; p after scrambling, unscrambled[%d]=%x\n",p,unscrambled[p]); +#endif + + +} + +void nr_pdcch_unscrambling_tmp(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_tti_rx, double llr[], uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common) { int i; @@ -3116,19 +3213,21 @@ if (do_common){ x2 = (((1<<16)*n_rnti)+n_id)%((1<<30)*2); //this is c_init in 38.211 v15.1.0 Section 7.3.2.3 // x2 = (nr_tti_rx << 9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 #ifdef NR_PDCCH_DCI_DEBUG -printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> (c_init=%d, n_id=%d, n_rnti=%d)\n",x2,n_id,n_rnti); +printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> (c_init=%d, n_id=%d, n_rnti=%d, length=%d)\n",x2,n_id,n_rnti,length); #endif for (i = 0; i < length; i++) { if ((i & 0x1f) == 0) { s = lte_gold_generic(&x1, &x2, reset); - // printf("lte_gold[%d]=%x\n",i,s); + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> lte_gold[%d]=%x\n",i,s); reset = 0; } - // printf("unscrambling %d : e %d, c %d => ",i,llr[i],((s>>(i&0x1f))&1)); - if (((s >> (i % 32)) & 1) == 0) + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> unscrambling %d : scrambled_llr=%d, c %d => ",i,llr[i],((s>>(i&0x1f))&1)); + if (((s >> (i % 32)) & 1) == 1) llr[i] = -llr[i]; - // printf("%d\n",llr[i]); + //llr[i] = (-1)*llr[i]; + printf("unscrambled_llr=%d\n",llr[i]); + } } @@ -4072,18 +4171,15 @@ void nr_dci_decoding_procedure0(int s, LOG_I(PHY,"[DCI search nPdcch %d - ue spec] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x) format %d\n", pdcch_vars[eNB_id]->num_pdcch_symbols,m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask,format_c); #endif - #ifdef NR_PDCCH_DCI_DEBUG + #ifndef NR_PDCCH_DCI_DEBUG printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we enter function dci_decoding(sizeof_bits=%d L=%d) -----\n",sizeof_bits,L); printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we have to replace this part of the code by polar decoding\n"); #endif -// The polar_input has to be taken from the e_rx table but in the proper order -// e_rx contains the bits grouped by bundle -// polar_input has to contain the bits ordered by b_tilde_0, b_tilde_1, .... // for (int m=0; m < (nCCE[p]*6*9*2); m++) #ifdef NR_PDCCH_DCI_DEBUG - printf("polar intput (with coreset_time_dur=%d, coreset_nbr_rb=%d, p=%d, CCEind=%d): \n", + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0: polar decoding)-> polar intput (with coreset_time_dur=%d, coreset_nbr_rb=%d, p=%d, CCEind=%d): \n", coreset_time_dur,coreset_nbr_rb,p,CCEind); #endif int reg_p,reg_e; @@ -4091,60 +4187,55 @@ void nr_dci_decoding_procedure0(int s, reg_p = (((int)floor(m/coreset_time_dur))+((m%coreset_time_dur)*(L2*6/coreset_time_dur)))*9*2; reg_e = m*9*2; for (int i=0; i<9*2; i++){ - polar_input[reg_p+i] = (pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]>0) ? (1.0):(-1.0); - printf("\t m=%d \tpolar_input[%d]=%lf <-> e_rx[%d]=%d\n",m,reg_p+i,polar_input[reg_p+i], - ((CCEind*9*6*2) + reg_e + i),pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]); + //polar_input[reg_p+i] = (pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]>0) ? (1.0):(-1.0); + polar_input[reg_e+i] = (pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]>0) ? (1/sqrt(2)):((-1)/sqrt(2)); + //printf("\t m=%d \tpolar_input[%d]=%lf <-> e_rx[%d]=%d\n",m,reg_e+i,polar_input[reg_e+i], + // ((CCEind*9*6*2) + reg_e + i),pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]); + //printf("\t m=%d \tpolar_input[%d]=%lf <-> e_rx[%d]=%d\n",m,reg_p+i,polar_input[reg_p+i], + // ((CCEind*9*6*2) + reg_e + i),pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]); } } - #ifdef NR_PDCCH_DCI_DEBUG + #ifndef NR_PDCCH_DCI_DEBUG printf("\n"); int j=0; uint32_t polar_hex[27] = {0}; for (int i=0; i polar_hex[%d]=%x\n",j,polar_hex[j]); #endif -/* nr_pdcch_unscrambling(pdcch_vars[eNB_id]->crnti, - frame_parms, - nr_tti_rx, - polar_input, - L2*6*9*2, - pdcch_DMRS_scrambling_id, - do_common);*/ +uint32_t dci_estimation[4]={0}; +uint16_t rnti=3; #ifdef PDCCH_TEST_POLAR_TEMP_FIX - t_nrPolar_paramsPtr currentPtr = NULL; - nr_polar_init(¤tPtr, NR_POLAR_DCI_MESSAGE_TYPE, 41, 8); + t_nrPolar_paramsPtr nrPolar_params = NULL; + nr_polar_init(&nrPolar_params, 1, 41, 8); + t_nrPolar_paramsPtr currentPtrDCI=nr_polar_params(nrPolar_params, 1, 41, 8); + decoderState = polar_decoder_dci(polar_input, + dci_estimation, + currentPtrDCI,//nrPolar_params, + 8,//NR_POLAR_DECODER_LISTSIZE, + 0,//NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, + rnti); //rnti + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0: \t\tpolar decoding)-> decoderState %d\n", decoderState); + #endif + //dci_estimation[0] = 0x01189400; + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0: \t\tdci_estimation: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", + dci_estimation[0], dci_estimation[1], dci_estimation[2], dci_estimation[3]); - //#else - // nr_polar_init(nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, (uint16_t)sizeof_bits, L2); - // t_nrPolar_paramsPtr currentPtr = nr_polar_params(*nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, (uint16_t)sizeof_bits,L2); - #endif - - decoderState = polar_decoder(polar_input, - &dci_decoded_output[current_thread_id][0], - currentPtr, - 8, - 0); - printf("decoderState %d\n", decoderState); - - //dci_decoding(sizeof_bits, 2, currentPtr, polar_input, &dci_decoded_output[current_thread_id][0]); - /* - for (i=0;i<3+(sizeof_bits>>3);i++) - printf("dci_decoded_output[%d] => %x\n",i,dci_decoded_output[i]); - */ - crc = (crc16(&dci_decoded_output[current_thread_id][0], sizeof_bits) >> 16) ^ extract_crc(&dci_decoded_output[current_thread_id][0], sizeof_bits); - #ifdef NR_PDCCH_DCI_DEBUG - printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we end function dci_decoding() with crc=%x\n",crc); - printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we have to replace this part of the code by polar decoding\n"); - #endif - #ifdef DEBUG_DCI_DECODING - printf("crc =>%x\n",crc); - #endif //uint16_t tc_rnti, uint16_t int_rnti, uint16_t sfi_rnti, uint16_t tpc_pusch_rnti, uint16_t tpc_pucch_rnti, uint16_t tpc_srs__rnti - #ifdef NR_PDCCH_DCI_DEBUG + crc = rnti; + //crc = (crc16(&dci_decoded_output[current_thread_id][0], sizeof_bits) >> 16) ^ extract_crc(&dci_decoded_output[current_thread_id][0], sizeof_bits); + #ifndef NR_PDCCH_DCI_DEBUG + printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we end function dci_decoding() with crc=%x\n",crc); + printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> ... we have to replace this part of the code by polar decoding\n"); + #endif + #ifdef DEBUG_DCI_DECODING + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0: crc =>%d\n",crc); + #endif //uint16_t tc_rnti, uint16_t int_rnti, uint16_t sfi_rnti, uint16_t tpc_pusch_rnti, uint16_t tpc_pucch_rnti, uint16_t tpc_srs__rnti + #ifdef NR_PDCCH_DCI_DEBUG printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> format_found=%d\n",*format_found); printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> crc_scrambled=%d\n",*crc_scrambled); #endif @@ -4176,6 +4267,7 @@ void nr_dci_decoding_procedure0(int s, if (crc == crc_scrambled_values[_RA_RNTI_]) { *crc_scrambled =_ra_rnti; *format_found=_format_1_0_found; + printf(""); } if (crc == crc_scrambled_values[_SP_CSI_RNTI_]) { *crc_scrambled =_sp_csi_rnti; @@ -4206,57 +4298,39 @@ void nr_dci_decoding_procedure0(int s, printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> crc_scrambled=%d\n",*crc_scrambled); #endif if (*format_found!=255) { - #ifdef NR_PDCCH_DCI_DEBUG - printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> rnti matches -> DCI FOUND !!! crc =>%x, sizeof_bits %d, sizeof_bytes %d \n",crc, sizeof_bits, sizeof_bytes); - #endif dci_alloc[*dci_cnt].dci_length = sizeof_bits; dci_alloc[*dci_cnt].rnti = crc; dci_alloc[*dci_cnt].L = L; dci_alloc[*dci_cnt].firstCCE = CCEind; - if (sizeof_bytes <= 4) { - dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][0]; - dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][1]; - dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][2]; - dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][3]; -#ifdef DEBUG_DCI_DECODING - printf("DCI => %x,%x,%x,%x\n",dci_decoded_output[current_thread_id][0], - dci_decoded_output[current_thread_id][1], - dci_decoded_output[current_thread_id][2], - dci_decoded_output[current_thread_id][3]); -#endif - } else { -/* dci_alloc[*dci_cnt].dci_pdu[7] = dci_decoded_output[current_thread_id][0]; - dci_alloc[*dci_cnt].dci_pdu[6] = dci_decoded_output[current_thread_id][1]; - dci_alloc[*dci_cnt].dci_pdu[5] = dci_decoded_output[current_thread_id][2]; - dci_alloc[*dci_cnt].dci_pdu[4] = dci_decoded_output[current_thread_id][3];*/ - dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][0]; - dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][1]; - dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][2]; - dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][3]; - // MAX_DCI_SIZE_BITS has to be redefined for dci_decoded_output FIXME - // format2_0, format2_1 can be longer than 8 bytes. FIXME -#ifdef DEBUG_DCI_DECODING - printf("DCI => %x,%x,%x,%x,%x,%x,%x,%x\n", - dci_decoded_output[current_thread_id][0],dci_decoded_output[current_thread_id][1],dci_decoded_output[current_thread_id][2],dci_decoded_output[current_thread_id][3], - dci_decoded_output[current_thread_id][4],dci_decoded_output[current_thread_id][5],dci_decoded_output[current_thread_id][6],dci_decoded_output[current_thread_id][7]); -#endif - } + dci_alloc[*dci_cnt].dci_pdu[0] = dci_estimation[0]; + dci_alloc[*dci_cnt].dci_pdu[1] = dci_estimation[1]; + dci_alloc[*dci_cnt].dci_pdu[2] = dci_estimation[2]; + dci_alloc[*dci_cnt].dci_pdu[3] = dci_estimation[3]; + #ifdef NR_PDCCH_DCI_DEBUG + printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> rnti matches -> DCI FOUND !!! crc =>%x, sizeof_bits %d, sizeof_bytes %d \n", + dci_alloc[*dci_cnt].rnti, dci_alloc[*dci_cnt].dci_length, sizeof_bytes); + printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> dci_cnt %d (format_css %d crc_scrambled %d) L %d, firstCCE %d pdu[0] %x pdu[1] %x pdu[2] %x pdu[3] %x \n", + *dci_cnt, format_css,*crc_scrambled,dci_alloc[*dci_cnt].L, dci_alloc[*dci_cnt].firstCCE,dci_alloc[*dci_cnt].dci_pdu[0],dci_alloc[*dci_cnt].dci_pdu[1],dci_alloc[*dci_cnt].dci_pdu[2],dci_alloc[*dci_cnt].dci_pdu[3]); + #endif if ((format_css == cformat0_0_and_1_0) || (format_uss == uformat0_0_and_1_0)){ - if ((crc_scrambled == _p_rnti) || (crc_scrambled == _si_rnti) || (crc_scrambled == _ra_rnti)){ + if ((*crc_scrambled == _p_rnti) || (*crc_scrambled == _si_rnti) || (*crc_scrambled == _ra_rnti)){ dci_alloc[*dci_cnt].format = format1_0; *dci_cnt = *dci_cnt + 1; format_found=_format_1_0_found; - } else { - if (dci_decoded_output[current_thread_id][0]&1 == 0){ + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> a format1_0=%d and dci_cnt=%d\n",format_found,*dci_cnt); + } else { + if (dci_estimation[0]&1 == 0){ dci_alloc[*dci_cnt].format = format0_0; *dci_cnt = *dci_cnt + 1; format_found=_format_0_0_found; + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> b format0_0=%d and dci_cnt=%d\n",format_found,*dci_cnt); } - if (dci_decoded_output[current_thread_id][0]&1 == 1){ + if (dci_estimation[0]&1 == 1){ dci_alloc[*dci_cnt].format = format1_0; *dci_cnt = *dci_cnt + 1; format_found=_format_1_0_found; - } + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> c format1_0=%d and dci_cnt=%d\n",format_found,*dci_cnt); + } } } if (format_css == cformat2_0){ @@ -4276,12 +4350,12 @@ void nr_dci_decoding_procedure0(int s, *dci_cnt = *dci_cnt + 1; } if (format_uss == uformat0_1_and_1_1){ - if (dci_decoded_output[current_thread_id][0]&1 == 0){ + if (dci_estimation[0]&1 == 0){ dci_alloc[*dci_cnt].format = format0_1; *dci_cnt = *dci_cnt + 1; format_found=_format_0_1_found; } - if (dci_decoded_output[current_thread_id][0]&1 == 1){ + if (dci_estimation[0]&1 == 1){ dci_alloc[*dci_cnt].format = format1_1; *dci_cnt = *dci_cnt + 1; format_found=_format_1_1_found; @@ -5243,7 +5317,7 @@ uint8_t dci_size [8] = {0,0,0,0,0,0,0,0}; // will contain size for each format i,dci_size[i],n_RB_ULBWP); #endif } -#ifdef NR_PDCCH_DCI_DEBUG +#ifndef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_format_size) dci_fields_sizes[][] = { \n"); for (int j=0; j Ending function nr_dci_decoding_procedure() -> dci_cnt=%d\n",dci_cnt); #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_OUT); //LOG_D(PHY,"[UE %d][PUSCH] Frame %d nr_tti_rx %d PHICH RX\n",ue->Mod_id,frame_rx,nr_tti_rx); @@ -3466,6 +3465,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * ue->dl_indication.dci_ind = &ue->dci_ind; // hang on rx_ind instance for (int i=0; i Entering function nr_generate_ue_ul_dlsch_params_from_dci with eNB_id=%d dci_cnt=%d\n", + printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_generate_ue_ul_dlsch_params_from_dci with eNB_id=%d dci_cnt=%d format=%d, rnti=%d\n", eNB_id, - dci_cnt); + dci_cnt, + dci_alloc_rx[i].format, + dci_alloc_rx[i].rnti); #endif + nr_generate_ue_ul_dlsch_params_from_dci(ue, eNB_id, frame_rx, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 309d3a42ba..0e589a08d8 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -108,7 +108,7 @@ int8_t nr_ue_decode_mib( }else{ //NR_MIB__subCarrierSpacingCommon_scs30or120 scs_pdcch = scs_30kHz; } - + scs_pdcch = 2; channel_bandwidth_t min_channel_bw = bw_40MHz; // deafult for testing @@ -119,6 +119,8 @@ int8_t nr_ue_decode_mib( int32_t num_rbs = -1; int32_t num_symbols = -1; int32_t rb_offset = -1; + printf("<<<<<<<<mib->pdcch_ConfigSIB1,index_4msb,index_4lsb,scs_ssb,scs_pdcch, (scs_ssb << 5)|scs_pdcch); // type0-pdcch coreset switch( (scs_ssb << 5)|scs_pdcch ){ @@ -161,6 +163,7 @@ int8_t nr_ue_decode_mib( num_rbs = table_38213_13_4_c2[index_4msb]; num_symbols = table_38213_13_4_c3[index_4msb]; rb_offset = table_38213_13_4_c4[index_4msb]; + printf("<<<<<<<<type0_pdcch_ss_mux_pattern = 1; @@ -247,6 +250,7 @@ int8_t nr_ue_decode_mib( mask = mask >> 1; mask = mask | 0x100000000000; } + printf(">>>>>>>>mask 0x%16x num_rbs %d rb_offset %d\n", mask, num_rbs, rb_offset); mac->type0_pdcch_dci_config.coreset.frequency_domain_resource = mask; mac->type0_pdcch_dci_config.coreset.rb_offset = rb_offset; // additional parameter other than coreset From cf99ea1937a1674855930cb148e65a888b35be2d Mon Sep 17 00:00:00 2001 From: Agustin Date: Thu, 27 Sep 2018 15:21:30 +0200 Subject: [PATCH 105/114] NR PDCCH development: modifications for interpreting DCI formats 0_1 and 1_1 --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 42 +- openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c | 133 +-- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 839 ++++++++++++++++-- 3 files changed, 825 insertions(+), 189 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index d6fafae7f1..a1f4d3b856 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -226,7 +226,11 @@ typedef struct { } fapi_nr_ul_config_pucch_pdu; typedef enum {pusch_freq_hopping_disabled = 0 , pusch_freq_hopping_enabled = 1}pusch_freq_hopping_t; + typedef struct{ + uint8_t aperiodicSRS_ResourceTrigger; + } fapi_nr_ul_srs_config_t; typedef struct { + uint8_t bandwidth_part_ind; uint16_t number_rbs; uint16_t start_rb; uint16_t number_symbols; @@ -238,6 +242,16 @@ typedef struct { uint8_t harq_process_nbr; int8_t accumulated_delta_PUSCH; int8_t absolute_delta_PUSCH; + uint8_t n_layers; + uint8_t tpmi; + uint8_t n_dmrs_cdm_groups; + uint8_t dmrs_ports[4]; + uint8_t n_front_load_symb; + fapi_nr_ul_srs_config_t srs_config; + uint8_t csi_reportTriggerSize; + uint8_t maxCodeBlockGroupsPerTransportBlock; + uint8_t ptrs_dmrs_association_port; + uint8_t beta_offset_ind; } fapi_nr_ul_config_pusch_pdu_rel15_t; typedef struct { @@ -278,14 +292,21 @@ typedef struct { typedef struct { fapi_nr_dl_config_dci_dl_pdu_rel15_t dci_config_rel15; } fapi_nr_dl_config_dci_pdu; + typedef struct{ + uint8_t aperiodicSRS_ResourceTrigger; + } fapi_nr_dl_srs_config_t; typedef enum{vrb_to_prb_mapping_non_interleaved = 0, vrb_to_prb_mapping_interleaved = 1} vrb_to_prb_mapping_t; //typedef fapi_nr_dci_pdu_rel15_t fapi_nr_dl_config_dlsch_pdu_rel15_t; typedef struct { + uint8_t bandwidth_part_ind; uint16_t number_rbs; uint16_t start_rb; uint16_t number_symbols; uint16_t start_symbol; + uint8_t prb_bundling_size_ind; + uint8_t rate_matching_ind; + uint8_t zp_csi_rs_trigger; uint8_t mcs; uint8_t ndi; uint8_t rv; @@ -299,6 +320,13 @@ typedef struct { int8_t accumulated_delta_PUCCH; uint8_t pucch_resource_id; uint8_t pdsch_to_harq_feedback_time_ind; + uint8_t n_dmrs_cdm_groups; + uint8_t dmrs_ports[10]; + uint8_t n_front_load_symb; + uint8_t tci_state; + fapi_nr_dl_srs_config_t srs_config; + uint8_t cbgti; + uint8_t codeBlockGroupFlushIndicator; // to be check the fields needed to L1 with NR_DL_UE_HARQ_t and NR_UE_DLSCH_t } fapi_nr_dl_config_dlsch_pdu_rel15_t; @@ -597,7 +625,7 @@ typedef struct { typedef struct { uint8_t dmrs_type; uint8_t dmrs_addition_position; - + uint8_t ptrs_uplink_config; // to indicate if PTRS Uplink is configured of not uint8_t ptrs_type; //cp-OFDM, dft-S-OFDM uint16_t ptrs_frequency_density[2]; uint8_t ptrs_time_density[3]; @@ -623,9 +651,15 @@ typedef struct { uint8_t delta_mcs; } fapi_nr_pusch_power_control_t; + typedef enum {tx_config_codebook = 1, tx_config_nonCodebook = 2} tx_config_t; + typedef enum {transform_precoder_disabled = 0, transform_precoder_enabled = 1} transform_precoder_t; + typedef enum { + codebook_subset_fullyAndPartialAndNonCoherent = 1, + codebook_subset_partialAndNonCoherent = 2, + codebook_subset_nonCoherent = 3} codebook_subset_t; typedef struct { uint16_t data_scrambling_identity; - uint8_t tx_config; + tx_config_t tx_config; fapi_nr_dmrs_uplink_config_t dmrs_ul_for_pusch_mapping_type_a; fapi_nr_dmrs_uplink_config_t dmrs_ul_for_pusch_mapping_type_b; fapi_nr_pusch_power_control_t pusch_power_control; @@ -636,8 +670,8 @@ typedef struct { uint8_t pusch_aggregation_factor; uint8_t mcs_table; uint8_t mcs_table_transform_precoder; - uint8_t transform_precoder; - uint8_t codebook_subset; + transform_precoder_t transform_precoder; + codebook_subset_t codebook_subset; uint8_t max_rank; uint8_t rbg_size; diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c index 5980ed3bb6..a8acc735a9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c @@ -7157,8 +7157,8 @@ int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, NR_UE_ULSCH_t *ulsch0=NULL,*ulsch1=NULL; //NR_DCI_INFO_EXTRACTED_t nr_dci_info_extracted; uint8_t status=0;//left_shift=0; - uint64_t pdu_bitmap = 0xFFFFFFFFFFFFFFFF; - pdu_bitmap = (pdu_bitmap << (64 - dci_length)) >> (64 - dci_length); // this variable will help to remove the bits of other fields when left-switching + //uint64_t pdu_bitmap = 0xFFFFFFFFFFFFFFFF; + //pdu_bitmap = (pdu_bitmap << (64 - dci_length)) >> (64 - dci_length); // this variable will help to remove the bits of other fields when left-switching uint8_t dci_fields_sizes_format[NBR_NR_DCI_FIELDS] ={0}; for (int m=0; m Entering function nr_extract_dci_info(dci_format=%d) \n",dci_format); - #endif - status = nr_extract_dci_info(ue, - eNB_id, - frame_type, - dci_length, - rnti, - dci_pdu, - &nr_dci_info_extracted, - dci_fields_sizes, - dlsch0_harq, - dlsch0, - ulsch0, - dci_format, - nr_tti_rx, - n_RB_ULBWP, - n_RB_DLBWP, - crc_scrambled_values); - //status = check_dci_format1_1a_coherency(format1_1, frame_parms->N_RB_DL, rnti, tc_rnti, si_rnti, ra_rnti, p_rnti,frame,nr_tti_rx, &nr_dci_info_extracted, dlsch0_harq); - #ifdef NR_PDCCH_DCI_TOOLS_DEBUG - if(status == 0) - { - printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> bad DCI %d !!! \n",dci_format); - return(-1); - } - #endif -// break; -/* - case format0_1: - #ifdef NR_PDCCH_DCI_TOOLS_DEBUG - printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> format %d not implemented yet\n",dci_format); - #endif - break; - - case format1_0: - #ifdef NR_PDCCH_DCI_TOOLS_DEBUG - printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> Entering function nr_extract_dci_info(dci_format=%d)for PDSCH allocation\n",dci_format); - #endif - status = nr_extract_dci_info(ue, - eNB_id, - frame_type, - dci_length, - dci_pdu,rnti, - &nr_dci_info_extracted, - dci_fields_sizes, - dlsch0_harq, - dlsch0, - ulsch0, - dci_format, - nr_tti_rx, - n_RB_ULBWP, - n_RB_DLBWP,crc_scrambled_values); - //status = check_dci_format1_1a_coherency(format1_1, frame_parms->N_RB_DL, rnti, tc_rnti, si_rnti, ra_rnti, p_rnti,frame,nr_tti_rx, &nr_dci_info_extracted, dlsch0_harq); - #ifdef NR_PDCCH_DCI_TOOLS_DEBUG - if(status == 0) - { - printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> bad DCI %d !!! \n",dci_format); - return(-1); - } - #endif - break; - - case format1_1: - #ifdef NR_PDCCH_DCI_TOOLS_DEBUG - printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> format %d not implemented yet\n",dci_format); - #endif - break; - - case format2_0: - #ifdef NR_PDCCH_DCI_TOOLS_DEBUG - printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> format %d not implemented yet\n",dci_format); - #endif - break; - - case format2_1: - #ifdef NR_PDCCH_DCI_TOOLS_DEBUG - printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> format %d not implemented yet\n",dci_format); - #endif - break; - - case format2_2: - #ifdef NR_PDCCH_DCI_TOOLS_DEBUG - printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> format %d not implemented yet\n",dci_format); - #endif - break; - - case format2_3: - #ifdef NR_PDCCH_DCI_TOOLS_DEBUG - printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> format %d not implemented yet\n",dci_format); - #endif - break; - - default: - printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> we go to the default in switch\n"); - //LOG_E(PHY,"format %d not yet implemented\n",dci_format); - return(-1); - break; - }*/ #ifdef NR_PDCCH_DCI_TOOLS_DEBUG + printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> Entering function nr_extract_dci_info(dci_format=%d) \n",dci_format); + #endif + status = nr_extract_dci_info(ue, + eNB_id, + frame_type, + dci_length, + rnti, + dci_pdu, + &nr_dci_info_extracted, + dci_fields_sizes, + dlsch0_harq, + dlsch0, + ulsch0, + dci_format, + nr_tti_rx, + n_RB_ULBWP, + n_RB_DLBWP, + crc_scrambled_values); + //status = check_dci_format1_1a_coherency(format1_1, frame_parms->N_RB_DL, rnti, tc_rnti, si_rnti, ra_rnti, p_rnti,frame,nr_tti_rx, &nr_dci_info_extracted, dlsch0_harq); + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG + if(status == 0) { + printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> bad DCI %d !!! \n",dci_format); + return(-1); + } printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> Ending function nr_extract_dci_info()\n"); #endif return(0); } - - - #endif #if 0 int generate_ue_dlsch_params_from_dci(int frame, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 0e589a08d8..b04540f972 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -547,7 +547,365 @@ NR_UE_L2_STATE_t nr_ue_scheduler( * This code contains all the functions needed to process all dci fields. * These functions are going to be called by function nr_ue_process_dci */ - +// table_7_3_1_1_2_2_3_4_5 contains values for number of layers and precoding information for tables 7.3.1.1.2-2/3/4/5 from TS 38.212 subclause 7.3.1.1.2 +// the first 6 columns contain table 7.3.1.1.2-2: Precoding information and number of layers, for 4 antenna ports, if transformPrecoder=disabled and maxRank = 2 or 3 or 4 +// next six columns contain table 7.3.1.1.2-3: Precoding information and number of layers for 4 antenna ports, if transformPrecoder= enabled, or if transformPrecoder=disabled and maxRank = 1 +// next four columns contain table 7.3.1.1.2-4: Precoding information and number of layers, for 2 antenna ports, if transformPrecoder=disabled and maxRank = 2 +// next four columns contain table 7.3.1.1.2-5: Precoding information and number of layers, for 2 antenna ports, if transformPrecoder= enabled, or if transformPrecoder= disabled and maxRank = 1 +uint8_t table_7_3_1_1_2_2_3_4_5[63][20] = { +{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}, +{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, +{1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 0, 2, 0, 1, 2, 0, 0}, +{1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 2, 0, 0, 1, 3, 0, 0}, +{2, 0, 2, 0, 2, 0, 1, 4, 1, 4, 0, 0, 1, 3, 0, 0, 1, 4, 0, 0}, +{2, 1, 2, 1, 2, 1, 1, 5, 1, 5, 0, 0, 1, 4, 0, 0, 1, 5, 0, 0}, +{2, 2, 2, 2, 2, 2, 1, 6, 1, 6, 0, 0, 1, 5, 0, 0, 0, 0, 0, 0}, +{2, 3, 2, 3, 2, 3, 1, 7, 1, 7, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0}, +{2, 4, 2, 4, 2, 4, 1, 8, 1, 8, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0}, +{2, 5, 2, 5, 2, 5, 1, 9, 1, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{3, 0, 3, 0, 3, 0, 1, 10, 1, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{4, 0, 4, 0, 4, 0, 1, 11, 1, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 4, 1, 4, 0, 0, 1, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 5, 1, 5, 0, 0, 1, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 6, 1, 6, 0, 0, 1, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 7, 1, 7, 0, 0, 1, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 8, 1, 8, 0, 0, 1, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 9, 1, 9, 0, 0, 1, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 10, 1, 10, 0, 0, 1, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 11, 1, 11, 0, 0, 1, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 6, 2, 6, 0, 0, 1, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 7, 2, 7, 0, 0, 1, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 8, 2, 8, 0, 0, 1, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 9, 2, 9, 0, 0, 1, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 10, 2, 10, 0, 0, 1, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 11, 2, 11, 0, 0, 1, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 12, 2, 12, 0, 0, 1, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 13, 2, 13, 0, 0, 1, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{3, 1, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{3, 2, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{4, 1, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{4, 2, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{1, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{2, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{3, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{3, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, +{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +}; +uint8_t table_7_3_1_1_2_12[14][3] = { +{1,0,1}, +{1,1,1}, +{2,0,1}, +{2,1,1}, +{2,2,1}, +{2,3,1}, +{2,0,2}, +{2,1,2}, +{2,2,2}, +{2,3,2}, +{2,4,2}, +{2,5,2}, +{2,6,2}, +{2,7,2} +}; +uint8_t table_7_3_1_1_2_13[10][4] = { +{1,0,1,1}, +{2,0,1,1}, +{2,2,3,1}, +{2,0,2,1}, +{2,0,1,2}, +{2,2,3,2}, +{2,4,5,2}, +{2,6,7,2}, +{2,0,4,2}, +{2,2,6,2} +}; +uint8_t table_7_3_1_1_2_14[3][5] = { +{2,0,1,2,1}, +{2,0,1,4,2}, +{2,2,3,6,2} +}; +uint8_t table_7_3_1_1_2_15[4][6] = { +{2,0,1,2,3,1}, +{2,0,1,4,5,2}, +{2,2,3,6,7,2}, +{2,0,2,4,6,2} +}; +uint8_t table_7_3_1_1_2_16[12][2] = { +{1,0}, +{1,1}, +{2,0}, +{2,1}, +{2,2}, +{2,3}, +{3,0}, +{3,1}, +{3,2}, +{3,3}, +{3,4}, +{3,5} +}; +uint8_t table_7_3_1_1_2_17[7][3] = { +{1,0,1}, +{2,0,1}, +{2,2,3}, +{3,0,1}, +{3,2,3}, +{3,4,5}, +{2,0,2} +}; +uint8_t table_7_3_1_1_2_18[3][4] = { +{2,0,1,2}, +{3,0,1,2}, +{3,3,4,5} +}; +uint8_t table_7_3_1_1_2_19[2][5] = { +{2,0,1,2,3}, +{3,0,1,2,3} +}; +uint8_t table_7_3_1_1_2_20[28][3] = { +{1,0,1}, +{1,1,1}, +{2,0,1}, +{2,1,1}, +{2,2,1}, +{2,3,1}, +{3,0,1}, +{3,1,1}, +{3,2,1}, +{3,3,1}, +{3,4,1}, +{3,5,1}, +{3,0,2}, +{3,1,2}, +{3,2,2}, +{3,3,2}, +{3,4,2}, +{3,5,2}, +{3,6,2}, +{3,7,2}, +{3,8,2}, +{3,9,2}, +{3,10,2}, +{3,11,2}, +{1,0,2}, +{1,1,2}, +{1,6,2}, +{1,7,2} +}; +uint8_t table_7_3_1_1_2_21[19][4] = { +{1,0,1,1}, +{2,0,1,1}, +{2,2,3,1}, +{3,0,1,1}, +{3,2,3,1}, +{3,4,5,1}, +{2,0,2,1}, +{3,0,1,2}, +{3,2,3,2}, +{3,4,5,2}, +{3,6,7,2}, +{3,8,9,2}, +{3,10,11,2}, +{1,0,1,2}, +{1,6,7,2}, +{2,0,1,2}, +{2,2,3,2}, +{2,6,7,2}, +{2,8,9,2} +}; +uint8_t table_7_3_1_1_2_22[6][5] = { +{2,0,1,2,1}, +{3,0,1,2,1}, +{3,3,4,5,1}, +{3,0,1,6,2}, +{3,2,3,8,2}, +{3,4,5,10,2} +}; +uint8_t table_7_3_1_1_2_23[5][6] = { +{2,0,1,2,3,1}, +{3,0,1,2,3,1}, +{3,0,1,6,7,2}, +{3,2,3,8,9,2}, +{3,4,5,10,11,2} +}; +uint8_t table_7_3_2_3_3_1[12][5] = { +{1,0,0,0,0}, +{1,1,0,0,0}, +{1,0,1,0,0}, +{2,0,0,0,0}, +{2,1,0,0,0}, +{2,2,0,0,0}, +{2,3,0,0,0}, +{2,0,1,0,0}, +{2,2,3,0,0}, +{2,0,1,2,0}, +{2,0,1,2,3}, +{2,0,2,0,0} +}; +uint8_t table_7_3_2_3_3_2_oneCodeword[31][6] = { +{1,0,0,0,0,1}, +{1,1,0,0,0,1}, +{1,0,1,0,0,1}, +{2,0,0,0,0,1}, +{2,1,0,0,0,1}, +{2,2,0,0,0,1}, +{2,3,0,0,0,1}, +{2,0,1,0,0,1}, +{2,2,3,0,0,1}, +{2,0,1,2,0,1}, +{2,0,1,2,3,1}, +{2,0,2,0,0,1}, +{2,0,0,0,0,2}, +{2,1,0,0,0,2}, +{2,2,0,0,0,2}, +{2,3,0,0,0,2}, +{2,4,0,0,0,2}, +{2,5,0,0,0,2}, +{2,6,0,0,0,2}, +{2,7,0,0,0,2}, +{2,0,1,0,0,2}, +{2,2,3,0,0,2}, +{2,4,5,0,0,2}, +{2,6,7,0,0,2}, +{2,0,4,0,0,2}, +{2,2,6,0,0,2}, +{2,0,1,4,0,2}, +{2,2,3,6,0,2}, +{2,0,1,4,5,2}, +{2,2,3,6,7,2}, +{2,0,2,4,6,2} +}; +uint8_t table_7_3_2_3_3_2_twoCodeword[4][10] = { +{2,0,1,2,3,4,0,0,0,2}, +{2,0,1,2,3,4,6,0,0,2}, +{2,0,1,2,3,4,5,6,0,2}, +{2,0,1,2,3,4,5,6,7,2} +}; +uint8_t table_7_3_2_3_3_3_oneCodeword[24][5] = { +{1,0,0,0,0}, +{1,1,0,0,0}, +{1,0,1,0,0}, +{2,0,0,0,0}, +{2,1,0,0,0}, +{2,2,0,0,0}, +{2,3,0,0,0}, +{2,0,1,0,0}, +{2,2,3,0,0}, +{2,0,1,2,0}, +{2,0,1,2,3}, +{3,0,0,0,0}, +{3,1,0,0,0}, +{3,2,0,0,0}, +{3,3,0,0,0}, +{3,4,0,0,0}, +{3,5,0,0,0}, +{3,0,1,0,0}, +{3,2,3,0,0}, +{3,4,5,0,0}, +{3,0,1,2,0}, +{3,3,4,5,0}, +{3,0,1,2,3}, +{2,0,2,0,0} +}; +uint8_t table_7_3_2_3_3_3_twoCodeword[2][7] = { +{3,0,1,2,3,4,0}, +{3,0,1,2,3,4,5} +}; +uint8_t table_7_3_2_3_3_4_oneCodeword[58][6] = { +{1,0,0,0,0,1}, +{1,1,0,0,0,1}, +{1,0,1,0,0,1}, +{2,0,0,0,0,1}, +{2,1,0,0,0,1}, +{2,2,0,0,0,1}, +{2,3,0,0,0,1}, +{2,0,1,0,0,1}, +{2,2,3,0,0,1}, +{2,0,1,2,0,1}, +{2,0,1,2,3,1}, +{3,0,0,0,0,1}, +{3,1,0,0,0,1}, +{3,2,0,0,0,1}, +{3,3,0,0,0,1}, +{3,4,0,0,0,1}, +{3,5,0,0,0,1}, +{3,0,1,0,0,1}, +{3,2,3,0,0,1}, +{3,4,5,0,0,1}, +{3,0,1,2,0,1}, +{3,3,4,5,0,1}, +{3,0,1,2,3,1}, +{2,0,2,0,0,1}, +{3,0,0,0,0,2}, +{3,1,0,0,0,2}, +{3,2,0,0,0,2}, +{3,3,0,0,0,2}, +{3,4,0,0,0,2}, +{3,5,0,0,0,2}, +{3,6,0,0,0,2}, +{3,7,0,0,0,2}, +{3,8,0,0,0,2}, +{3,9,0,0,0,2}, +{3,10,0,0,0,2}, +{3,11,0,0,0,2}, +{3,0,1,0,0,2}, +{3,2,3,0,0,2}, +{3,4,5,0,0,2}, +{3,6,7,0,0,2}, +{3,8,9,0,0,2}, +{3,10,11,0,0,2}, +{3,0,1,6,0,2}, +{3,2,3,8,0,2}, +{3,4,5,10,0,2}, +{3,0,1,6,7,2}, +{3,2,3,8,9,2}, +{3,4,5,10,11,2}, +{1,0,0,0,0,2}, +{1,1,0,0,0,2}, +{1,6,0,0,0,2}, +{1,7,0,0,0,2}, +{1,0,1,0,0,2}, +{1,6,7,0,0,2}, +{2,0,1,0,0,2}, +{2,2,3,0,0,2}, +{2,6,7,0,0,2}, +{2,8,9,0,0,2} +}; +uint8_t table_7_3_2_3_3_4_twoCodeword[6][10] = { +{3,0,1,2,3,4,0,0,0,1}, +{3,0,1,2,3,4,5,0,0,1}, +{2,0,1,2,3,6,0,0,0,2}, +{2,0,1,2,3,6,8,0,0,2}, +{2,0,1,2,3,6,7,8,0,2}, +{2,0,1,2,3,6,7,8,9,2} +}; int8_t nr_ue_process_dci_freq_dom_resource_assignment( fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu, fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu, @@ -797,24 +1155,24 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fa ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_PUSCH; ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti; fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu_0_0 = &ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15; - /* IDENTIFIER_DCI_FORMATS */ - /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */ + /* IDENTIFIER_DCI_FORMATS */ + /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */ nr_ue_process_dci_freq_dom_resource_assignment(&ulsch_config_pdu_0_0,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL); - /* TIME_DOM_RESOURCE_ASSIGNMENT */ + /* TIME_DOM_RESOURCE_ASSIGNMENT */ nr_ue_process_dci_time_dom_resource_assignment(&ulsch_config_pdu_0_0,NULL,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); - /* FREQ_HOPPING_FLAG */ + /* FREQ_HOPPING_FLAG */ if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.resource_allocation != 0) && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.frequency_hopping !=0)) ulsch_config_pdu_0_0->pusch_freq_hopping = (dci->freq_hopping_flag == 0)? pusch_freq_hopping_disabled:pusch_freq_hopping_enabled; - /* MCS */ + /* MCS */ ulsch_config_pdu_0_0->mcs = dci->mcs; - /* NDI */ + /* NDI */ ulsch_config_pdu_0_0->ndi = dci->ndi; - /* RV */ + /* RV */ ulsch_config_pdu_0_0->rv = dci->rv; - /* HARQ_PROCESS_NUMBER */ + /* HARQ_PROCESS_NUMBER */ ulsch_config_pdu_0_0->harq_process_nbr = dci->harq_process_number; - /* TPC_PUSCH */ + /* TPC_PUSCH */ // according to TS 38.213 Table Table 7.1.1-1 if (dci->tpc_pusch == 0) { ulsch_config_pdu_0_0->accumulated_delta_PUSCH = -1; @@ -832,12 +1190,9 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fa ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 3; ulsch_config_pdu_0_0->absolute_delta_PUSCH = 4; } - /* SUL_IND_0_0 */ // To be implemented, FIXME!!! - // UL_CONFIG_REQ - //ulsch0->harq_processes[dci->harq_process_number]->first_rb = start_RB; - //ulsch0->harq_processes[dci->harq_process_number]->nb_rb = l_RB; - //ulsch0->harq_processes[dci->harq_process_number]->mcs = dci->mcs; - //ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi= nr_pdci_info_extracted->ndi; + /* SUL_IND_0_0 */ // To be implemented, FIXME!!! + + ul_config->number_pdus = ul_config->number_pdus + 1; break; case format0_1: @@ -872,42 +1227,272 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fa ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_PUSCH; ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti; fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu_0_1 = &ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15; - /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */ + /* IDENTIFIER_DCI_FORMATS */ + /* CARRIER_IND */ + /* SUL_IND_0_1 */ + /* BANDWIDTH_PART_IND */ + ulsch_config_pdu_0_1->bandwidth_part_ind = dci->bandwidth_part_ind; + /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */ nr_ue_process_dci_freq_dom_resource_assignment(&ulsch_config_pdu_0_1,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL); - /* TIME_DOM_RESOURCE_ASSIGNMENT */ + /* TIME_DOM_RESOURCE_ASSIGNMENT */ nr_ue_process_dci_time_dom_resource_assignment(&ulsch_config_pdu_0_1,NULL,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); - /* FREQ_HOPPING_FLAG */ + /* FREQ_HOPPING_FLAG */ if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.resource_allocation != 0) && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.frequency_hopping !=0)) ulsch_config_pdu_0_1->pusch_freq_hopping = (dci->freq_hopping_flag == 0)? pusch_freq_hopping_disabled:pusch_freq_hopping_enabled; - /* MCS */ + /* MCS */ ulsch_config_pdu_0_1->mcs = dci->mcs; - /* NDI */ + /* NDI */ ulsch_config_pdu_0_1->ndi = dci->ndi; - /* RV */ + /* RV */ ulsch_config_pdu_0_1->rv = dci->rv; - /* HARQ_PROCESS_NUMBER */ + /* HARQ_PROCESS_NUMBER */ ulsch_config_pdu_0_1->harq_process_nbr = dci->harq_process_number; - /* FIRST_DAI */ //To be implemented, FIXME!!! - /* SECOND_DAI */ //To be implemented, FIXME!!! - /* TPC_PUSCH */ + /* FIRST_DAI */ //To be implemented, FIXME!!! + /* SECOND_DAI */ //To be implemented, FIXME!!! + /* TPC_PUSCH */ // according to TS 38.213 Table Table 7.1.1-1 if (dci->tpc_pusch == 0) { - ulsch_config_pdu_0_0->accumulated_delta_PUSCH = -1; - ulsch_config_pdu_0_0->absolute_delta_PUSCH = -4; + ulsch_config_pdu_0_1->accumulated_delta_PUSCH = -1; + ulsch_config_pdu_0_1->absolute_delta_PUSCH = -4; } if (dci->tpc_pusch == 1) { - ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 0; - ulsch_config_pdu_0_0->absolute_delta_PUSCH = -1; + ulsch_config_pdu_0_1->accumulated_delta_PUSCH = 0; + ulsch_config_pdu_0_1->absolute_delta_PUSCH = -1; } if (dci->tpc_pusch == 2) { - ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 1; - ulsch_config_pdu_0_0->absolute_delta_PUSCH = 1; + ulsch_config_pdu_0_1->accumulated_delta_PUSCH = 1; + ulsch_config_pdu_0_1->absolute_delta_PUSCH = 1; } if (dci->tpc_pusch == 3) { - ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 3; - ulsch_config_pdu_0_0->absolute_delta_PUSCH = 4; + ulsch_config_pdu_0_1->accumulated_delta_PUSCH = 3; + ulsch_config_pdu_0_1->absolute_delta_PUSCH = 4; } + /* SRS_RESOURCE_IND */ + //FIXME!! + /* PRECOD_NBR_LAYERS */ + if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.tx_config == tx_config_nonCodebook)); + // 0 bits if the higher layer parameter txConfig = nonCodeBook + if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.tx_config == tx_config_codebook)){ + uint8_t n_antenna_port = 0; //FIXME!!! + if (n_antenna_port == 1); // 1 antenna port and the higher layer parameter txConfig = codebook 0 bits + if (n_antenna_port == 4){ // 4 antenna port and the higher layer parameter txConfig = codebook + // Table 7.3.1.1.2-2: transformPrecoder=disabled and maxRank = 2 or 3 or 4 + if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) + && ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 2) || + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 3) || + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 4))){ + if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_fullyAndPartialAndNonCoherent) { + ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][0]; + ulsch_config_pdu_0_1->tpmi = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][1]; + } + if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_partialAndNonCoherent){ + ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][2]; + ulsch_config_pdu_0_1->tpmi = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][3]; + } + if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){ + ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][4]; + ulsch_config_pdu_0_1->tpmi = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][5]; + } + } + // Table 7.3.1.1.2-3: transformPrecoder= enabled, or transformPrecoder=disabled and maxRank = 1 + if (((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled) + || (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled)) + && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 1)){ + if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_fullyAndPartialAndNonCoherent) { + ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][6]; + ulsch_config_pdu_0_1->tpmi = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][7]; + } + if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_partialAndNonCoherent){ + ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][8]; + ulsch_config_pdu_0_1->tpmi = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][9]; + } + if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){ + ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][10]; + ulsch_config_pdu_0_1->tpmi = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][11]; + } + } + } + if (n_antenna_port == 4){ // 2 antenna port and the higher layer parameter txConfig = codebook + // Table 7.3.1.1.2-4: transformPrecoder=disabled and maxRank = 2 + if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) + && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 2)){ + if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_fullyAndPartialAndNonCoherent) { + ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][12]; + ulsch_config_pdu_0_1->tpmi = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][13]; + } + if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){ + ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][14]; + ulsch_config_pdu_0_1->tpmi = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][15]; + } + } + // Table 7.3.1.1.2-5: transformPrecoder= enabled, or transformPrecoder= disabled and maxRank = 1 + if (((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled) + || (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled)) + && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 1)){ + if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_fullyAndPartialAndNonCoherent) { + ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][16]; + ulsch_config_pdu_0_1->tpmi = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][17]; + } + if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){ + ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][18]; + ulsch_config_pdu_0_1->tpmi = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][19]; + } + } + } + } + /* ANTENNA_PORTS */ + uint8_t rank=0; // We need to initialize rank FIXME!!! + if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 1) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 1)) { // tables 7.3.1.1.2-6 + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2; + ulsch_config_pdu_0_1->dmrs_ports[0] = dci->antenna_ports; + } + if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 1) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 2)) { // tables 7.3.1.1.2-7 + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2; + ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 3)?(dci->antenna_ports-4):(dci->antenna_ports); + ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 3)?2:1; + } + if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 1) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 1)) { // tables 7.3.1.1.2-8/9/10/11 + if (rank == 1){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 1)?2:1; + ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports-2):(dci->antenna_ports); + } + if (rank == 2){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 0)?2:1; + ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports > 2 ?0:2):0; + ulsch_config_pdu_0_1->dmrs_ports[1] = (dci->antenna_ports > 1)?(dci->antenna_ports > 2 ?2:3):1; + } + if (rank == 3){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2; + ulsch_config_pdu_0_1->dmrs_ports[0] = 0; + ulsch_config_pdu_0_1->dmrs_ports[1] = 1; + ulsch_config_pdu_0_1->dmrs_ports[2] = 2; + } + if (rank == 4){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2; + ulsch_config_pdu_0_1->dmrs_ports[0] = 0; + ulsch_config_pdu_0_1->dmrs_ports[1] = 1; + ulsch_config_pdu_0_1->dmrs_ports[2] = 2; + ulsch_config_pdu_0_1->dmrs_ports[3] = 3; + } + } + if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 1) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 2)) { // tables 7.3.1.1.2-12/13/14/15 + if (rank == 1){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 1)?2:1; + ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports > 5 ?(dci->antenna_ports-6):(dci->antenna_ports-2)):dci->antenna_ports; + ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 6)?2:1; + } + if (rank == 2){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 0)?2:1; + ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_13[dci->antenna_ports][1]; + ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_13[dci->antenna_ports][2]; + ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 3)?2:1; + } + if (rank == 3){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2; + ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_14[dci->antenna_ports][1]; + ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_14[dci->antenna_ports][2]; + ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_14[dci->antenna_ports][3]; + ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 1)?2:1; + } + if (rank == 4){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2; + ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_15[dci->antenna_ports][1]; + ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_15[dci->antenna_ports][2]; + ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_15[dci->antenna_ports][3]; + ulsch_config_pdu_0_1->dmrs_ports[3] = table_7_3_1_1_2_15[dci->antenna_ports][4]; + ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 1)?2:1; + } + } + if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 2) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 1)) { // tables 7.3.1.1.2-16/17/18/19 + if (rank == 1){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 1)?((dci->antenna_ports > 5)?3:2):1; + ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports > 5 ?(dci->antenna_ports-6):(dci->antenna_ports-2)):dci->antenna_ports; + } + if (rank == 2){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 0)?((dci->antenna_ports > 2)?3:2):1; + ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_17[dci->antenna_ports][1]; + ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_17[dci->antenna_ports][2]; + } + if (rank == 3){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 0)?3:2; + ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_18[dci->antenna_ports][1]; + ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_18[dci->antenna_ports][2]; + ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_18[dci->antenna_ports][3]; + } + if (rank == 4){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = dci->antenna_ports + 2; + ulsch_config_pdu_0_1->dmrs_ports[0] = 0; + ulsch_config_pdu_0_1->dmrs_ports[1] = 1; + ulsch_config_pdu_0_1->dmrs_ports[2] = 2; + ulsch_config_pdu_0_1->dmrs_ports[3] = 3; + } + } + if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 2) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 2)) { // tables 7.3.1.1.2-20/21/22/23 + if (rank == 1){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = table_7_3_1_1_2_20[dci->antenna_ports][0]; + ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_20[dci->antenna_ports][1]; + ulsch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_20[dci->antenna_ports][2]; + } + if (rank == 2){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = table_7_3_1_1_2_21[dci->antenna_ports][0]; + ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_21[dci->antenna_ports][1]; + ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_21[dci->antenna_ports][2]; + ulsch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_21[dci->antenna_ports][3]; + } + if (rank == 3){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = table_7_3_1_1_2_22[dci->antenna_ports][0]; + ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_22[dci->antenna_ports][1]; + ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_22[dci->antenna_ports][2]; + ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_22[dci->antenna_ports][3]; + ulsch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_22[dci->antenna_ports][4]; + } + if (rank == 4){ + ulsch_config_pdu_0_1->n_dmrs_cdm_groups = table_7_3_1_1_2_23[dci->antenna_ports][0]; + ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_23[dci->antenna_ports][1]; + ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_23[dci->antenna_ports][2]; + ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_23[dci->antenna_ports][3]; + ulsch_config_pdu_0_1->dmrs_ports[3] = table_7_3_1_1_2_23[dci->antenna_ports][4]; + ulsch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_23[dci->antenna_ports][5]; + } + } + /* SRS_REQUEST */ + // if SUL is supported in the cell, there is an additional bit in thsi field and the value of this bit represents table 7.1.1.1-1 TS 38.212 FIXME!!! + ulsch_config_pdu_0_1->srs_config.aperiodicSRS_ResourceTrigger = (dci->srs_request & 0x11); // as per Table 7.3.1.1.2-24 TS 38.212 + /* CSI_REQUEST */ + ulsch_config_pdu_0_1->csi_reportTriggerSize = dci->csi_request; + /* CBGTI */ + ulsch_config_pdu_0_1->maxCodeBlockGroupsPerTransportBlock = dci->cbgti; + /* PTRS_DMRS */ + if (((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.ptrs_uplink_config == 0)) || + ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled) && + (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 1))){ + } else { + ulsch_config_pdu_0_1->ptrs_dmrs_association_port = dci->ptrs_dmrs; + } + /* BETA_OFFSET_IND */ + // Table 9.3-3 in [5, TS 38.213] + ulsch_config_pdu_0_1->beta_offset_ind = dci->beta_offset_ind; + /* DMRS_SEQ_INI */ + // FIXME!! + /* UL_SCH_IND */ + // A value of "1" indicates UL-SCH shall be transmitted on the PUSCH and + // a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH + + ul_config->number_pdus = ul_config->number_pdus + 1; break; case format1_0: @@ -964,54 +1549,48 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fa dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti; fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_0 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; - /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */ + /* IDENTIFIER_DCI_FORMATS */ + /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */ nr_ue_process_dci_freq_dom_resource_assignment(NULL,&dlsch_config_pdu_1_0,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL); - /* TIME_DOM_RESOURCE_ASSIGNMENT */ + /* TIME_DOM_RESOURCE_ASSIGNMENT */ nr_ue_process_dci_time_dom_resource_assignment(NULL,&dlsch_config_pdu_1_0,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); - /* VRB_TO_PRB_MAPPING */ + /* VRB_TO_PRB_MAPPING */ dlsch_config_pdu_1_0->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping == 0) ? vrb_to_prb_mapping_non_interleaved:vrb_to_prb_mapping_interleaved; - /* MCS */ + /* MCS */ dlsch_config_pdu_1_0->mcs = dci->mcs; - /* NDI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ + /* NDI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ dlsch_config_pdu_1_0->ndi = dci->ndi; - /* RV (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ + /* RV (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ dlsch_config_pdu_1_0->rv = dci->rv; - /* HARQ_PROCESS_NUMBER (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ + /* HARQ_PROCESS_NUMBER (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ dlsch_config_pdu_1_0->harq_process_nbr = dci->harq_process_number; - /* DAI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ + /* DAI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ dlsch_config_pdu_1_0->dai = dci ->dai; - /* TB_SCALING (only if CRC scrambled by P-RNTI or RA-RNTI) */ + /* TB_SCALING (only if CRC scrambled by P-RNTI or RA-RNTI) */ // according to TS 38.214 Table 5.1.3.2-3 if (dci->tb_scaling == 0) dlsch_config_pdu_1_0->scaling_factor_S = 1; if (dci->tb_scaling == 1) dlsch_config_pdu_1_0->scaling_factor_S = 0.5; if (dci->tb_scaling == 2) dlsch_config_pdu_1_0->scaling_factor_S = 0.25; if (dci->tb_scaling == 3) dlsch_config_pdu_1_0->scaling_factor_S = 0; // value not defined in table - /* TPC_PUCCH (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ + /* TPC_PUCCH (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ // according to TS 38.213 Table 7.2.1-1 if (dci->tpc_pucch == 0) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = -1; if (dci->tpc_pucch == 1) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 0; if (dci->tpc_pucch == 2) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 1; if (dci->tpc_pucch == 3) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 3; - /* PUCCH_RESOURCE_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/ - if (dci->pucch_resource_ind == 0) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 1st value of resourceList FIXME!!! - if (dci->pucch_resource_ind == 1) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 2nd value of resourceList FIXME!! - if (dci->pucch_resource_ind == 2) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 3rd value of resourceList FIXME!! - if (dci->pucch_resource_ind == 3) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 4th value of resourceList FIXME!! - if (dci->pucch_resource_ind == 4) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 5th value of resourceList FIXME!! - if (dci->pucch_resource_ind == 5) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 6th value of resourceList FIXME!! - if (dci->pucch_resource_ind == 6) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 7th value of resourceList FIXME!! - if (dci->pucch_resource_ind == 7) dlsch_config_pdu_1_0->pucch_resource_id = 0; //pucch-ResourceId obtained from the 8th value of resourceList FIXME!! - /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/ + /* PUCCH_RESOURCE_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/ + //if (dci->pucch_resource_ind == 0) dlsch_config_pdu_1_0->pucch_resource_id = 1; //pucch-ResourceId obtained from the 1st value of resourceList FIXME!!! + //if (dci->pucch_resource_ind == 1) dlsch_config_pdu_1_0->pucch_resource_id = 2; //pucch-ResourceId obtained from the 2nd value of resourceList FIXME!! + //if (dci->pucch_resource_ind == 2) dlsch_config_pdu_1_0->pucch_resource_id = 3; //pucch-ResourceId obtained from the 3rd value of resourceList FIXME!! + //if (dci->pucch_resource_ind == 3) dlsch_config_pdu_1_0->pucch_resource_id = 4; //pucch-ResourceId obtained from the 4th value of resourceList FIXME!! + //if (dci->pucch_resource_ind == 4) dlsch_config_pdu_1_0->pucch_resource_id = 5; //pucch-ResourceId obtained from the 5th value of resourceList FIXME!! + //if (dci->pucch_resource_ind == 5) dlsch_config_pdu_1_0->pucch_resource_id = 6; //pucch-ResourceId obtained from the 6th value of resourceList FIXME!! + //if (dci->pucch_resource_ind == 6) dlsch_config_pdu_1_0->pucch_resource_id = 7; //pucch-ResourceId obtained from the 7th value of resourceList FIXME!! + //if (dci->pucch_resource_ind == 7) dlsch_config_pdu_1_0->pucch_resource_id = 8; //pucch-ResourceId obtained from the 8th value of resourceList FIXME!! + dlsch_config_pdu_1_0->pucch_resource_id = dci->pucch_resource_ind; + /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/ dlsch_config_pdu_1_0-> pdsch_to_harq_feedback_time_ind = dci->pdsch_to_harq_feedback_time_ind; - // DL_CONFIG_REQ - //pdlsch0_harq->nb_rb = l_RB; - //pdlsch0->current_harq_pid = dci->harq_process_number; - //pdlsch0->active = 1; - //pdlsch0->rnti = rnti; - //pdlsch0_harq->mcs = nr_pdci_info_extracted->mcs; - //pdlsch0_harq->DCINdi = nr_pdci_info_extracted->ndi; - dl_config->number_pdus = dl_config->number_pdus + 1; break; @@ -1048,36 +1627,46 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fa dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti; fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_1 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; - /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */ + /* IDENTIFIER_DCI_FORMATS */ + /* CARRIER_IND */ + /* BANDWIDTH_PART_IND */ + dlsch_config_pdu_1_1->bandwidth_part_ind = dci->bandwidth_part_ind; + /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */ nr_ue_process_dci_freq_dom_resource_assignment(NULL,&dlsch_config_pdu_1_1,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL); - /* TIME_DOM_RESOURCE_ASSIGNMENT */ + /* TIME_DOM_RESOURCE_ASSIGNMENT */ nr_ue_process_dci_time_dom_resource_assignment(NULL,&dlsch_config_pdu_1_1,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); - /* VRB_TO_PRB_MAPPING */ + /* VRB_TO_PRB_MAPPING */ if (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.resource_allocation != 0) dlsch_config_pdu_1_1->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping == 0) ? vrb_to_prb_mapping_non_interleaved:vrb_to_prb_mapping_interleaved; - /* MCS (for transport block 1)*/ + /* PRB_BUNDLING_SIZE_IND */ + dlsch_config_pdu_1_1->prb_bundling_size_ind = dci->prb_bundling_size_ind; + /* RATE_MATCHING_IND */ + dlsch_config_pdu_1_1->rate_matching_ind = dci->rate_matching_ind; + /* ZP_CSI_RS_TRIGGER */ + dlsch_config_pdu_1_1->zp_csi_rs_trigger = dci->zp_csi_rs_trigger; + /* MCS (for transport block 1)*/ dlsch_config_pdu_1_1->mcs = dci->tb1_mcs; - /* NDI (for transport block 1)*/ + /* NDI (for transport block 1)*/ dlsch_config_pdu_1_1->ndi = dci->tb1_ndi; - /* RV (for transport block 1)*/ + /* RV (for transport block 1)*/ dlsch_config_pdu_1_1->rv = dci->tb1_rv; - /* MCS (for transport block 2)*/ + /* MCS (for transport block 2)*/ dlsch_config_pdu_1_1->tb2_mcs = dci->tb2_mcs; - /* NDI (for transport block 2)*/ + /* NDI (for transport block 2)*/ dlsch_config_pdu_1_1->tb2_ndi = dci->tb2_ndi; - /* RV (for transport block 2)*/ + /* RV (for transport block 2)*/ dlsch_config_pdu_1_1->tb2_rv = dci->tb2_rv; - /* HARQ_PROCESS_NUMBER */ + /* HARQ_PROCESS_NUMBER */ dlsch_config_pdu_1_1->harq_process_nbr = dci->harq_process_number; - /* DAI */ + /* DAI */ dlsch_config_pdu_1_0->dai = dci ->dai; - /* TPC_PUCCH */ + /* TPC_PUCCH */ // according to TS 38.213 Table 7.2.1-1 if (dci->tpc_pucch == 0) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = -1; if (dci->tpc_pucch == 1) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 0; if (dci->tpc_pucch == 2) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 1; if (dci->tpc_pucch == 3) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 3; - /* PUCCH_RESOURCE_IND */ + /* PUCCH_RESOURCE_IND */ if (dci->pucch_resource_ind == 0) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 1st value of resourceList FIXME!!! if (dci->pucch_resource_ind == 1) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 2nd value of resourceList FIXME!! if (dci->pucch_resource_ind == 2) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 3rd value of resourceList FIXME!! @@ -1086,11 +1675,105 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fa if (dci->pucch_resource_ind == 5) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 6th value of resourceList FIXME!! if (dci->pucch_resource_ind == 6) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 7th value of resourceList FIXME!! if (dci->pucch_resource_ind == 7) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 8th value of resourceList FIXME!! - /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */ + /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */ // according to TS 38.213 Table 9.2.3-1 - dlsch_config_pdu_1_1-> pdsch_to_harq_feedback_time_ind = - mac->phy_config.config_req.ul_bwp_dedicated.pucch_config_dedicated.dl_data_to_ul_ack[dci->pdsch_to_harq_feedback_time_ind]; + dlsch_config_pdu_1_1-> pdsch_to_harq_feedback_time_ind = mac->phy_config.config_req.ul_bwp_dedicated.pucch_config_dedicated.dl_data_to_ul_ack[dci->pdsch_to_harq_feedback_time_ind]; + /* ANTENNA_PORTS */ + uint8_t n_codewords = 1; // FIXME!!! + if ((mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.dmrs_type == 1) && + (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.max_length == 1)){ + // Table 7.3.1.2.2-1: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=1 + dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_1[dci->antenna_ports][0]; + dlsch_config_pdu_1_1->dmrs_ports[0] = table_7_3_2_3_3_1[dci->antenna_ports][1]; + dlsch_config_pdu_1_1->dmrs_ports[1] = table_7_3_2_3_3_1[dci->antenna_ports][2]; + dlsch_config_pdu_1_1->dmrs_ports[2] = table_7_3_2_3_3_1[dci->antenna_ports][3]; + dlsch_config_pdu_1_1->dmrs_ports[3] = table_7_3_2_3_3_1[dci->antenna_ports][4]; + } + if ((mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.dmrs_type == 1) && + (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.max_length == 2)){ + // Table 7.3.1.2.2-2: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=2 + if (n_codewords == 1) { + dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][0]; + dlsch_config_pdu_1_1->dmrs_ports[0] = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][1]; + dlsch_config_pdu_1_1->dmrs_ports[1] = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][2]; + dlsch_config_pdu_1_1->dmrs_ports[2] = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][3]; + dlsch_config_pdu_1_1->dmrs_ports[3] = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][4]; + dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][5]; + } + if (n_codewords == 1) { + dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][0]; + dlsch_config_pdu_1_1->dmrs_ports[0] = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][1]; + dlsch_config_pdu_1_1->dmrs_ports[1] = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][2]; + dlsch_config_pdu_1_1->dmrs_ports[2] = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][3]; + dlsch_config_pdu_1_1->dmrs_ports[3] = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][4]; + dlsch_config_pdu_1_1->dmrs_ports[4] = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][5]; + dlsch_config_pdu_1_1->dmrs_ports[5] = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][6]; + dlsch_config_pdu_1_1->dmrs_ports[6] = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][7]; + dlsch_config_pdu_1_1->dmrs_ports[7] = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][8]; + dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][9]; + } + } + if ((mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.dmrs_type == 2) && + (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.max_length == 1)){ + // Table 7.3.1.2.2-3: Antenna port(s) (1000 + DMRS port), dmrs-Type=2, maxLength=1 + if (n_codewords == 1) { + dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][0]; + dlsch_config_pdu_1_1->dmrs_ports[0] = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][1]; + dlsch_config_pdu_1_1->dmrs_ports[1] = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][2]; + dlsch_config_pdu_1_1->dmrs_ports[2] = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][3]; + dlsch_config_pdu_1_1->dmrs_ports[3] = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][4]; + } + if (n_codewords == 1) { + dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][0]; + dlsch_config_pdu_1_1->dmrs_ports[0] = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][1]; + dlsch_config_pdu_1_1->dmrs_ports[1] = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][2]; + dlsch_config_pdu_1_1->dmrs_ports[2] = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][3]; + dlsch_config_pdu_1_1->dmrs_ports[3] = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][4]; + dlsch_config_pdu_1_1->dmrs_ports[4] = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][5]; + dlsch_config_pdu_1_1->dmrs_ports[5] = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][6]; + } + } + if ((mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.dmrs_type == 2) && + (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.max_length == 2)){ + // Table 7.3.1.2.2-4: Antenna port(s) (1000 + DMRS port), dmrs-Type=2, maxLength=2 + if (n_codewords == 1) { + dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][0]; + dlsch_config_pdu_1_1->dmrs_ports[0] = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][1]; + dlsch_config_pdu_1_1->dmrs_ports[1] = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][2]; + dlsch_config_pdu_1_1->dmrs_ports[2] = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][3]; + dlsch_config_pdu_1_1->dmrs_ports[3] = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][4]; + dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][5]; + } + if (n_codewords == 1) { + dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][0]; + dlsch_config_pdu_1_1->dmrs_ports[0] = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][1]; + dlsch_config_pdu_1_1->dmrs_ports[1] = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][2]; + dlsch_config_pdu_1_1->dmrs_ports[2] = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][3]; + dlsch_config_pdu_1_1->dmrs_ports[3] = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][4]; + dlsch_config_pdu_1_1->dmrs_ports[4] = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][5]; + dlsch_config_pdu_1_1->dmrs_ports[5] = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][6]; + dlsch_config_pdu_1_1->dmrs_ports[6] = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][7]; + dlsch_config_pdu_1_1->dmrs_ports[7] = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][8]; + dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][9]; + } + } + /* TCI */ + if (mac->dl_config_request.dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.tci_present_in_dci == 1){ + // 0 bit if higher layer parameter tci-PresentInDCI is not enabled + // otherwise 3 bits as defined in Subclause 5.1.5 of [6, TS38.214] + dlsch_config_pdu_1_1->tci_state = dci->tci; + } + /* SRS_REQUEST */ + // if SUL is supported in the cell, there is an additional bit in this field and the value of this bit represents table 7.1.1.1-1 TS 38.212 FIXME!!! + dlsch_config_pdu_1_1->srs_config.aperiodicSRS_ResourceTrigger = (dci->srs_request & 0x11); // as per Table 7.3.1.1.2-24 TS 38.212 + /* CBGTI */ + dlsch_config_pdu_1_1->cbgti = dci->cbgti; + /* CBGFI */ + dlsch_config_pdu_1_1->codeBlockGroupFlushIndicator = dci->cbgfi; + /* DMRS_SEQ_INI */ + //FIXME!!! + dl_config->number_pdus = dl_config->number_pdus + 1; break; case format2_0: From 41809d5d65dc1d8b98c2a0e7ef048a439c7804d7 Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Thu, 27 Sep 2018 17:22:53 +0200 Subject: [PATCH 106/114] NR PDCCH validation: modifications for pdcch validation --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c | 289 ++++++------------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 1 + targets/RT/USER/nr-ue.c | 5 + 4 files changed, 93 insertions(+), 204 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 53b1c554db..465e278c0c 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -4294,7 +4294,7 @@ uint16_t rnti=3; *format_found=_format_2_3_found; } #ifdef NR_PDCCH_DCI_DEBUG - printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> format_found=%d %d %d\n",*format_found, format_found, &format_found); + printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> format_found=%d\n",*format_found); printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> crc_scrambled=%d\n",*crc_scrambled); #endif if (*format_found!=255) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c index a8acc735a9..a7a0e2b752 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c @@ -4193,129 +4193,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, printf("}\n"); #endif - uint8_t prev_ndi = pdlsch0_harq->DCINdi; - /*uint16_t l_RB; - uint16_t start_RB; - uint16_t tmp_RIV; - uint16_t l_symbol; - uint16_t start_symbol; - uint16_t tmp_symbol; - // dmrs_typeA_pos provided by higher layers. FIXME !!! - uint8_t dmrs_typeA_pos = 2; - uint8_t sliv_S; - uint8_t sliv_L; - uint8_t k_offset; - uint8_t table_5_1_2_1_1_2_time_dom_res_alloc_A[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 - {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?12:11}, // row index 1 - {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?10:9}, // row index 2 - {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?9:8}, // row index 3 - {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?7:6}, // row index 4 - {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?5:4}, // row index 5 - {0,(dmrs_typeA_pos == 2)?9:10,(dmrs_typeA_pos == 2)?4:4}, // row index 6 - {0,(dmrs_typeA_pos == 2)?4:6, (dmrs_typeA_pos == 2)?4:4}, // row index 7 - {0,5,7}, // row index 8 - {0,5,2}, // row index 9 - {0,9,2}, // row index 10 - {0,12,2}, // row index 11 - {0,1,13}, // row index 12 - {0,1,6}, // row index 13 - {0,2,4}, // row index 14 - {0,4,7}, // row index 15 - {0,8,4} // row index 16 - }; - uint8_t table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 - {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?6:5}, // row index 1 - {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?10:9}, // row index 2 - {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?9:8}, // row index 3 - {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?7:6}, // row index 4 - {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?5:4}, // row index 5 - {0,(dmrs_typeA_pos == 2)?6:8, (dmrs_typeA_pos == 2)?4:2}, // row index 6 - {0,(dmrs_typeA_pos == 2)?4:6, (dmrs_typeA_pos == 2)?4:4}, // row index 7 - {0,5,6}, // row index 8 - {0,5,2}, // row index 9 - {0,9,2}, // row index 10 - {0,10,2}, // row index 11 - {0,1,11}, // row index 12 - {0,1,6}, // row index 13 - {0,2,4}, // row index 14 - {0,4,6}, // row index 15 - {0,8,4} // row index 16 - }; - uint8_t table_5_1_2_1_1_4_time_dom_res_alloc_B[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 - {0,2,2}, // row index 1 - {0,4,2}, // row index 2 - {0,6,2}, // row index 3 - {0,8,2}, // row index 4 - {0,10,2}, // row index 5 - {1,2,2}, // row index 6 - {1,4,2}, // row index 7 - {0,2,4}, // row index 8 - {0,4,4}, // row index 9 - {0,6,4}, // row index 10 - {0,8,4}, // row index 11 - {0,10,4}, // row index 12 - {0,2,7}, // row index 13 - {0,(dmrs_typeA_pos == 2)?2:3,(dmrs_typeA_pos == 2)?12:11}, // row index 14 - {1,2,4}, // row index 15 - {0,0,0} // row index 16 - }; - uint8_t table_5_1_2_1_1_5_time_dom_res_alloc_C[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 - {0,2,2}, // row index 1 - {0,4,2}, // row index 2 - {0,6,2}, // row index 3 - {0,8,2}, // row index 4 - {0,10,2}, // row index 5 - {0,0,0}, // row index 6 - {0,0,0}, // row index 7 - {0,2,4}, // row index 8 - {0,4,4}, // row index 9 - {0,6,4}, // row index 10 - {0,8,4}, // row index 11 - {0,10,4}, // row index 12 - {0,2,7}, // row index 13 - {0,(dmrs_typeA_pos == 2)?2:3,(dmrs_typeA_pos == 2)?12:11}, // row index 14 - {0,0,6}, // row index 15 - {0,2,6} // row index 16 - }; - uint8_t mu_pusch = 1; - // definition table j Table 6.1.2.1.1-4 - uint8_t j = (mu_pusch==3)?3:(mu_pusch==2)?2:1; - uint8_t table_6_1_2_1_1_2_time_dom_res_alloc_A[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1 - {j, 0,14}, // row index 1 - {j, 0,12}, // row index 2 - {j, 0,10}, // row index 3 - {j, 2,10}, // row index 4 - {j, 4,10}, // row index 5 - {j, 4,8}, // row index 6 - {j, 4,6}, // row index 7 - {j+1,0,14}, // row index 8 - {j+1,0,12}, // row index 9 - {j+1,0,10}, // row index 10 - {j+2,0,14}, // row index 11 - {j+2,0,12}, // row index 12 - {j+2,0,10}, // row index 13 - {j, 8,6}, // row index 14 - {j+3,0,14}, // row index 15 - {j+3,0,10} // row index 16 - }; - uint8_t table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1 - {j, 0,8}, // row index 1 - {j, 0,12}, // row index 2 - {j, 0,10}, // row index 3 - {j, 2,10}, // row index 4 - {j, 4,4}, // row index 5 - {j, 4,8}, // row index 6 - {j, 4,6}, // row index 7 - {j+1,0,8}, // row index 8 - {j+1,0,12}, // row index 9 - {j+1,0,10}, // row index 10 - {j+2,0,6}, // row index 11 - {j+2,0,12}, // row index 12 - {j+2,0,10}, // row index 13 - {j, 8,4}, // row index 14 - {j+3,0,8}, // row index 15 - {j+3,0,10} // row index 16 - };*/ +// uint8_t prev_ndi = pdlsch0_harq->DCINdi; /* @@ -4330,7 +4208,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->harq_process_number=%x\n",nr_pdci_info_extracted->harq_process_number); #endif } - +/* if ((dci_format == format1_0) || (dci_format == format1_1)) { if (rnti==crc_scrambled_values[_SI_RNTI_]) { ue->dlsch_SI[eNB_id]->active = 1; @@ -4353,7 +4231,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, } else { } } - +*/ for (dci_field=0; dci_fieldvrb_to_prb_mapping = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - if (nr_pdci_info_extracted->vrb_to_prb_mapping == 0) { // Non-interleaved - } else { // Interleaved + //if (nr_pdci_info_extracted->vrb_to_prb_mapping == 0) { // Non-interleaved + //} else { // Interleaved // format 0_1 defined in TS 38.211 Section 6.3.1.7 // formats 1_0 and 1_1 not defined yet - } + //} #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->vrb_to_prb_mapping=%x\n",nr_pdci_info_extracted->vrb_to_prb_mapping); #endif @@ -4633,11 +4511,11 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // 1 bit otherwise, only applicable to resource allocation type 1, as defined in Subclause 6.3 of [6, TS 38.214] nr_pdci_info_extracted->freq_hopping_flag = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - if (nr_pdci_info_extracted->freq_hopping_flag != 0) { // PUSCH frequency hopping is performed (only resource allocation type 1) + //if (nr_pdci_info_extracted->freq_hopping_flag != 0) { // PUSCH frequency hopping is performed (only resource allocation type 1) - } else { // PUSCH frequency hopping is not performed (only resource allocation type 1) + //} else { // PUSCH frequency hopping is not performed (only resource allocation type 1) // At the moment PUSCH hopping is not implemented. We are considering that the bit is present and the value is '0' - } + //} #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->freq_hopping_flag=%x\n",nr_pdci_info_extracted->freq_hopping_flag); #endif @@ -4654,7 +4532,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case TB1_NDI: // 19 TB1_NDI: (field defined for -,-,-,format1_1,-,-,-,-) nr_pdci_info_extracted->tb1_ndi = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - pdlsch0_harq->DCINdi = nr_pdci_info_extracted->tb1_ndi; + //pdlsch0_harq->DCINdi = nr_pdci_info_extracted->tb1_ndi; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb1_ndi=%x\n",nr_pdci_info_extracted->tb1_ndi); #endif @@ -4662,7 +4540,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case TB1_RV: // 20 TB1_RV: (field defined for -,-,-,format1_1,-,-,-,-) nr_pdci_info_extracted->tb1_rv = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - pdlsch0_harq->rvidx = nr_pdci_info_extracted->tb1_rv; + //pdlsch0_harq->rvidx = nr_pdci_info_extracted->tb1_rv; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb1_rv=%x\n",nr_pdci_info_extracted->tb1_rv); #endif @@ -4670,7 +4548,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case TB2_MCS: // 21 TB2_MCS: (field defined for -,-,-,format1_1,-,-,-,-) nr_pdci_info_extracted->tb2_mcs = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - if (nr_pdci_info_extracted->mcs < 29) pdlsch0_harq->mcs = nr_pdci_info_extracted->tb2_mcs; + //if (nr_pdci_info_extracted->mcs < 29) pdlsch0_harq->mcs = nr_pdci_info_extracted->tb2_mcs; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb2_mcs=%x\n",nr_pdci_info_extracted->tb2_mcs); #endif @@ -4678,7 +4556,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case TB2_NDI: // 22 TB2_NDI: (field defined for -,-,-,format1_1,-,-,-,-) nr_pdci_info_extracted->tb2_ndi = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - pdlsch0_harq->DCINdi = nr_pdci_info_extracted->tb2_ndi; + //pdlsch0_harq->DCINdi = nr_pdci_info_extracted->tb2_ndi; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb2_ndi=%x\n",nr_pdci_info_extracted->tb2_ndi); #endif @@ -4686,7 +4564,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case TB2_RV: // 23 TB2_RV: (field defined for -,-,-,format1_1,-,-,-,-) nr_pdci_info_extracted->tb2_rv = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - pdlsch0_harq->rvidx = nr_pdci_info_extracted->tb2_rv; + //pdlsch0_harq->rvidx = nr_pdci_info_extracted->tb2_rv; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb2_rv=%x\n",nr_pdci_info_extracted->tb2_rv); #endif @@ -4695,14 +4573,14 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case MCS: // 24 MCS: (field defined for format0_0,format0_1,format1_0,-,-,-,-,-) nr_pdci_info_extracted->mcs = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - if (nr_pdci_info_extracted->mcs < 29) { - if (dci_format == format0_0 || dci_format == format0_1) - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->mcs = nr_pdci_info_extracted->mcs; - else - pdlsch0_harq->mcs = nr_pdci_info_extracted->mcs; - } else { - return(0); - } + //if (nr_pdci_info_extracted->mcs < 29) { + // if (dci_format == format0_0 || dci_format == format0_1) + // ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->mcs = nr_pdci_info_extracted->mcs; + // else + // pdlsch0_harq->mcs = nr_pdci_info_extracted->mcs; + //} else { + // return(0); + //} #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->mcs=%x\n",nr_pdci_info_extracted->mcs); #endif @@ -4711,30 +4589,30 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case NDI: // 25 NDI: (field defined for format0_0,format0_1,format1_0,-,-,-,-,-) nr_pdci_info_extracted->ndi = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - if (dci_format == format0_0 || dci_format == format0_1) { - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi = nr_pdci_info_extracted->ndi; - if (ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->first_tx==1) { - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->first_tx=0; - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi= nr_pdci_info_extracted->ndi; - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->round = 0; - } else { - if (ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi != nr_pdci_info_extracted->ndi) { // new SDU opportunity - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi= nr_pdci_info_extracted->ndi; - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->round = 0; - } - } - } else { - if (rnti == crc_scrambled_values[_TC_RNTI_]) { //fix for standalone Contention Resolution Id - pdlsch0_harq->DCINdi = (uint8_t)-1; - } else { - if ((prev_ndi != nr_pdci_info_extracted->ndi) || (pdlsch0_harq->first_tx==1)) { - pdlsch0_harq->round = 0; - pdlsch0_harq->first_tx = 0; - pdlsch0_harq->status = ACTIVE; - } - pdlsch0_harq->DCINdi = nr_pdci_info_extracted->ndi; - } - } + //if (dci_format == format0_0 || dci_format == format0_1) { + // ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi = nr_pdci_info_extracted->ndi; + // if (ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->first_tx==1) { + // ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->first_tx=0; + // ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi= nr_pdci_info_extracted->ndi; + // ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->round = 0; + // } else { + // if (ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi != nr_pdci_info_extracted->ndi) { // new SDU opportunity + // ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi= nr_pdci_info_extracted->ndi; + // ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->round = 0; + // } + // } + //} else { + // if (rnti == crc_scrambled_values[_TC_RNTI_]) { //fix for standalone Contention Resolution Id + // pdlsch0_harq->DCINdi = (uint8_t)-1; + // } else { + // if ((prev_ndi != nr_pdci_info_extracted->ndi) || (pdlsch0_harq->first_tx==1)) { + // pdlsch0_harq->round = 0; + // pdlsch0_harq->first_tx = 0; + // pdlsch0_harq->status = ACTIVE; + // } + // pdlsch0_harq->DCINdi = nr_pdci_info_extracted->ndi; + // } + //} #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->ndi=%x\n",nr_pdci_info_extracted->ndi); #endif @@ -4743,29 +4621,29 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case RV: // 26 RV: (field defined for format0_0,format0_1,format1_0,-,-,-,-,-) nr_pdci_info_extracted->rv = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - if (dci_format == format0_0 || dci_format == format0_1) - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->rvidx = nr_pdci_info_extracted->rv; - else - pdlsch0_harq->rvidx = nr_pdci_info_extracted->rv; - if ((prev_ndi == nr_pdci_info_extracted->ndi) && (pdlsch0_harq->rvidx != 0)) { // NDI has not been toggled but rv was increased by eNB: retransmission - if (pdlsch0_harq->status == SCH_IDLE) { + //if (dci_format == format0_0 || dci_format == format0_1) + // ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->rvidx = nr_pdci_info_extracted->rv; + //else + // pdlsch0_harq->rvidx = nr_pdci_info_extracted->rv; + //if ((prev_ndi == nr_pdci_info_extracted->ndi) && (pdlsch0_harq->rvidx != 0)) { // NDI has not been toggled but rv was increased by eNB: retransmission + // if (pdlsch0_harq->status == SCH_IDLE) { // packet was actually decoded in previous transmission (ACK was missed by eNB) // however, the round is not a good check as it might have been decoded in a retransmission prior to this one. // skip pdsch decoding and report ack - pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.ack = 1; - pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.send_harq_status; + // pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.ack = 1; + // pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.send_harq_status; #if 0 - pdlsch0->active = 0; - pdlsch0->harq_ack[nr_tti_rx].ack = 1; - pdlsch0->harq_ack[nr_tti_rx].harq_id = nr_pdci_info_extracted->harq_process_number; - pdlsch0->harq_ack[nr_tti_rx].send_harq_status = 1; + // pdlsch0->active = 0; + // pdlsch0->harq_ack[nr_tti_rx].ack = 1; + // pdlsch0->harq_ack[nr_tti_rx].harq_id = nr_pdci_info_extracted->harq_process_number; + // pdlsch0->harq_ack[nr_tti_rx].send_harq_status = 1; #endif - } else { // normal retransmission, nothing special to do - } - } else { - pdlsch0_harq->status = ACTIVE; - } + // } else { // normal retransmission, nothing special to do + // } + //} else { + // pdlsch0_harq->status = ACTIVE; + //} #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->rv=%x\n",nr_pdci_info_extracted->rv); #endif @@ -4774,7 +4652,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case HARQ_PROCESS_NUMBER: // 27 HARQ_PROCESS_NUMBER: (field defined for format0_0,format0_1,format1_0,format1_1,-,-,-,-) nr_pdci_info_extracted->harq_process_number = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - pdlsch0->current_harq_pid = nr_pdci_info_extracted->harq_process_number; + //pdlsch0->current_harq_pid = nr_pdci_info_extracted->harq_process_number; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->harq_process_number=%x\n",nr_pdci_info_extracted->harq_process_number); #endif @@ -4787,7 +4665,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // 0 otherwise nr_pdci_info_extracted->dai = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.vDAI_DL = nr_pdci_info_extracted->dai+1; + //pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.vDAI_DL = nr_pdci_info_extracted->dai+1; //pdlsch0->harq_ack[nr_tti_rx].vDAI_DL = nr_pdci_info_extracted->dai+1; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->dai=%x\n",nr_pdci_info_extracted->dai); @@ -4824,12 +4702,12 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // defined in Subclause 7.1.1 TS 38.213 nr_pdci_info_extracted->tpc_pusch = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->TPC = nr_pdci_info_extracted->tpc_pusch; - if (ue->ul_power_control_dedicated[eNB_id].accumulationEnabled == 1) { - ulsch0->f_pusch += nr_delta_PUSCH_acc[ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->TPC]; - } else { - ulsch0->f_pusch = nr_delta_PUSCH_abs[ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->TPC]; - } + //ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->TPC = nr_pdci_info_extracted->tpc_pusch; + //if (ue->ul_power_control_dedicated[eNB_id].accumulationEnabled == 1) { + // ulsch0->f_pusch += nr_delta_PUSCH_acc[ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->TPC]; + //} else { + // ulsch0->f_pusch = nr_delta_PUSCH_abs[ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->TPC]; + //} #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tpc_pusch=%x\n",nr_pdci_info_extracted->tpc_pusch); #endif @@ -4839,7 +4717,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // defined in Subclause 7.2.1 TS 38.213 nr_pdci_info_extracted->tpc_pucch = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); - pdlsch0_harq->delta_PUCCH = nr_delta_PUCCH_lut[nr_pdci_info_extracted->tpc_pucch &3]; + //pdlsch0_harq->delta_PUCCH = nr_delta_PUCCH_lut[nr_pdci_info_extracted->tpc_pucch &3]; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tpc_pucch=%x\n",nr_pdci_info_extracted->tpc_pucch); #endif @@ -7156,13 +7034,17 @@ int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, NR_DL_UE_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; NR_UE_ULSCH_t *ulsch0=NULL,*ulsch1=NULL; //NR_DCI_INFO_EXTRACTED_t nr_dci_info_extracted; - uint8_t status=0;//left_shift=0; - //uint64_t pdu_bitmap = 0xFFFFFFFFFFFFFFFF; - //pdu_bitmap = (pdu_bitmap << (64 - dci_length)) >> (64 - dci_length); // this variable will help to remove the bits of other fields when left-switching + uint8_t status=0; + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG + printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> dci_format=%d, rnti=%d, dci_length=%d, dci_pdu[0]=%x, dci_pdu[2]=%x, dci_pdu[2]=%x, dci_pdu[3]=%x\n", + dci_format,rnti,dci_length,dci_pdu[0],dci_pdu[1],dci_pdu[2],dci_pdu[3]); + #endif + + uint8_t dci_fields_sizes_format[NBR_NR_DCI_FIELDS] ={0}; for (int m=0; mactive = 0; if (dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format] != 0) { // 27 HARQ_PROCESS_NUMBER (27 is the position in dci_fields_sizes array for field HARQ_PROCESS_NUMBER) @@ -7172,19 +7054,20 @@ int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, //left_shift = 0; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> nr_dci_info_extracted->harq_process_number=%x\n",nr_dci_info_extracted->harq_process_number); - #endif + for (int i=0; i<1000; i++) printf("%d",i); + #endif } dlsch0_harq = dlsch[0]->harq_processes[nr_dci_info_extracted->harq_process_number]; ulsch0 = ulsch; -/* printf("nr_dci_info_extracted.harq_process_number = %d\n",nr_dci_info_extracted.harq_process_number); - printf("dlsch0 = %d\n",dlsch0); - printf("dlsch0_harq = %d\n",dlsch0_harq);*/ + //printf("nr_dci_info_extracted.harq_process_number = %d\n",nr_dci_info_extracted.harq_process_number); + //printf("dlsch0 = %d\n",dlsch0); + //printf("dlsch0_harq = %d\n",dlsch0_harq); if (!dlsch[0]) return -1; if (!ulsch) return -1; - +*/ memset(&nr_dci_info_extracted,0,sizeof(nr_dci_info_extracted)); // printf("we reach this point\n"); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index b04540f972..c2bca72271 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -1135,6 +1135,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fa const uint16_t n_RB_ULBWP = 106; const uint16_t n_RB_DLBWP = 106; +printf(">>> nr_ue_process_dci at MAC layer"); switch(dci_format){ case format0_0: diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 04da3067c2..05e25f7371 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -684,12 +684,16 @@ static void *UE_thread_rxn_txnp4(void *arg) { phy_procedures_slot_parallelization_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); #else phy_procedures_nrUE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); + printf(">>> nr_ue_pdcch_procedures ended\n"); + #endif } #if UE_TIMING_TRACE start_meas(&UE->generic_stat); #endif +printf(">>> mac init\n"); + if (UE->mac_enabled==1) { // trigger L2 to run ue_scheduler thru IF module @@ -759,6 +763,7 @@ static void *UE_thread_rxn_txnp4(void *arg) { #if UE_TIMING_TRACE stop_meas(&UE->generic_stat); #endif +printf(">>> mac ended\n"); // Prepare the future Tx data #if 0 From 1f1160ae37a470b3d56c456a72e2c92c2e91f48e Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Wed, 3 Oct 2018 15:00:17 +0200 Subject: [PATCH 107/114] NR PDCCH development: validation modifications --- openair1/PHY/INIT/nr_init_ue.c | 2 + openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c | 153 +++++++++--------- .../PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 8 +- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 30 +++- openair1/SCHED_NR_UE/harq_nr.c | 18 +-- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 71 +++++--- openair1/SCHED_NR_UE/pucch_uci_ue_nr.c | 8 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 71 ++++++-- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 4 +- 9 files changed, 228 insertions(+), 137 deletions(-) diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 151a917f23..fc2d762178 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -942,6 +942,8 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag) { void phy_init_nr_top(PHY_VARS_NR_UE *ue) { NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; + NR_UE_DLSCH_t *dlsch0 = ue->dlsch[0][0][0]; + dlsch0 =(NR_UE_DLSCH_t *)malloc16(sizeof(NR_UE_DLSCH_t)); crcTableInit(); diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c index a7a0e2b752..86959ee66d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c @@ -4000,6 +4000,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, uint16_t n_RB_DLBWP, uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES]) { + /* * This function will extract the different elements of the dci pdu and interpret the values extracted to update correctly the parameters in: * NR_DL_UE_HARQ_t *pdlsch0_harq, @@ -4255,72 +4256,72 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // 0 or 3 bits, as defined in Subclause x.x of [5, TS38.213] nr_pdci_info_extracted->carrier_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->carrier_ind=%x\n",nr_pdci_info_extracted->carrier_ind); -#endif + #endif break; case SUL_IND_0_1: // 2 SUL_IND_0_1: (field defined for -,format0_1,-,-,-,-,-,-) nr_pdci_info_extracted->sul_ind_0_1 = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->sul_ind_0_1=%x\n",nr_pdci_info_extracted->sul_ind_0_1); -#endif + #endif break; case SLOT_FORMAT_IND: // 3 SLOT_FORMAT_IND: (field defined for -,-,-,-,format2_0,-,-,-) // size of DCI format 2_0 is configurable by higher layers up to 128 bits, according to Subclause 11.1.1 of [5, TS 38.213] nr_pdci_info_extracted->slot_format_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->slot_format_ind=%x\n",nr_pdci_info_extracted->slot_format_ind); -#endif + #endif break; case PRE_EMPTION_IND: // 4 PRE_EMPTION_IND: (field defined for -,-,-,-,-,format2_1,-,-) // size of DCI format 2_1 is configurable by higher layers up to 126 bits, according to Subclause 11.2 of [5, TS 38.213]. Each pre-emption indication is 14 bits nr_pdci_info_extracted->pre_emption_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->pre_emption_ind=%x\n",nr_pdci_info_extracted->pre_emption_ind); -#endif + #endif break; case BLOCK_NUMBER: // 5 BLOCK_NUMBER: (field defined for -,-,-,-,-,-,-,format2_3) // starting position of a block is determined by the parameter startingBitOfFormat2_3 nr_pdci_info_extracted->block_number = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->block_number=%x\n",nr_pdci_info_extracted->block_number); -#endif + #endif break; case CLOSE_LOOP_IND: // 6 CLOSE_LOOP_IND: (field defined for -,-,-,-,-,-,format2_2,-) // The parameter xxx provided by higher layers determines the index to the TPC command number for an UL of a cell. Each TPC command number is 2 bits nr_pdci_info_extracted->close_loop_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->close_loop_ind=%x\n",nr_pdci_info_extracted->close_loop_ind); -#endif + #endif break; case BANDWIDTH_PART_IND: // 7 BANDWIDTH_PART_IND: (field defined for -,format0_1,-,format1_1,-,-,-,-) nr_pdci_info_extracted->bandwidth_part_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->bandwidth_part_ind=%x\n",nr_pdci_info_extracted->bandwidth_part_ind); -#endif + #endif break; case SHORT_MESSAGE_IND: // 8 SHORT_MESSAGE_IND: (field defined for -,-,format1_0,format1_1,-,-,-,-) nr_pdci_info_extracted->short_message_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->short_message_ind=%x\n",nr_pdci_info_extracted->short_message_ind); -#endif + #endif break; case SHORT_MESSAGES: // 9 SHORT_MESSAGES: (field defined for -,-,format1_0,format1_1,-,-,-,-) nr_pdci_info_extracted->short_messages = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->short_messages=%x\n",nr_pdci_info_extracted->short_messages); -#endif + #endif break; case FREQ_DOM_RESOURCE_ASSIGNMENT_UL: // 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: (field defined for format0_0,format0_1,-,-,-,-,-,-) @@ -4486,24 +4487,24 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // 0 bit if the higher layer parameter PRB_bundling is not configured or is set to 'static', or 1 bit if the higher layer parameter PRB_bundling is set to 'dynamic' according to Subclause 5.1.2.3 of [6, TS 38.214] nr_pdci_info_extracted->prb_bundling_size_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->prb_bundling_size_ind=%x\n",nr_pdci_info_extracted->prb_bundling_size_ind); -#endif + #endif break; case RATE_MATCHING_IND: // 15 RATE_MATCHING_IND: (field defined for -,-,-,format1_1,-,-,-,-) // 0, 1, or 2 bits according to higher layer parameter rate-match-PDSCH-resource-set nr_pdci_info_extracted->rate_matching_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->rate_matching_ind=%x\n",nr_pdci_info_extracted->rate_matching_ind); -#endif + #endif break; case ZP_CSI_RS_TRIGGER: // 16 ZP_CSI_RS_TRIGGER: (field defined for -,-,-,format1_1,-,-,-,-) nr_pdci_info_extracted->zp_csi_rs_trigger = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->zp_csi_rs_trigger=%x\n",nr_pdci_info_extracted->zp_csi_rs_trigger); -#endif + #endif break; case FREQ_HOPPING_FLAG: // 17 FREQ_HOPPING_FLAG: (field defined for format0_0,format0_1,-,-,-,-,-,-) @@ -4676,26 +4677,26 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // (1 or 2 bits) 1 bit for semi-static HARQ-ACK nr_pdci_info_extracted->first_dai = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->first_dai=%x\n",nr_pdci_info_extracted->first_dai); -#endif + #endif break; case SECOND_DAI: // 30 SECOND_DAI: (field defined for -,format0_1,-,-,-,-,-,-) // (0 or 2 bits) 2 bits for dynamic HARQ-ACK codebook with two HARQ-ACK sub-codebooks nr_pdci_info_extracted->second_dai = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->second_dai=%x\n",nr_pdci_info_extracted->second_dai); -#endif + #endif break; case TB_SCALING: // 31 TB_SCALING: (field defined for -,format0_1,-,-,-,-,-,-) // (0 or 2 bits) 2 bits for dynamic HARQ-ACK codebook with two HARQ-ACK sub-codebooks nr_pdci_info_extracted->tb_scaling = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tb_scaling=%x\n",nr_pdci_info_extracted->tb_scaling); -#endif + #endif break; case TPC_PUSCH: // 32 TPC_PUSCH: (field defined for format0_0,format0_1,-,-,-,-,-,-) @@ -4746,161 +4747,160 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case SRS_RESOURCE_IND: // 36 SRS_RESOURCE_IND: (field defined for -,format0_1,-,-,-,-,-,-) nr_pdci_info_extracted->srs_resource_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->srs_resource_ind=%x\n",nr_pdci_info_extracted->srs_resource_ind); -#endif + #endif break; case PRECOD_NBR_LAYERS: // 37 PRECOD_NBR_LAYERS: (field defined for -,format0_1,-,-,-,-,-,-) nr_pdci_info_extracted->precod_nbr_layers = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->precod_nbr_layers=%x\n",nr_pdci_info_extracted->precod_nbr_layers); -#endif + #endif break; case ANTENNA_PORTS: // 38 ANTENNA_PORTS: (field defined for -,format0_1,-,format1_1,-,-,-,-) nr_pdci_info_extracted->antenna_ports = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->antenna_ports=%x\n",nr_pdci_info_extracted->antenna_ports); -#endif + #endif break; case TCI: // 39 TCI: (field defined for -,-,-,format1_1,-,-,-,-) // 0 bit if higher layer parameter tci-PresentInDCI is not enabled; otherwise 3 bits nr_pdci_info_extracted->tci = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tci=%x\n",nr_pdci_info_extracted->tci); -#endif + #endif break; case SRS_REQUEST: // 40 SRS_REQUEST: (field defined for -,format0_1,-,format1_1,-,-,-,format2_3) nr_pdci_info_extracted->srs_request = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->srs_request=%x\n",nr_pdci_info_extracted->srs_request); -#endif + #endif break; case TPC_CMD: // 41 TPC_CMD: (field defined for -,-,-,-,-,-,-,format2_3) nr_pdci_info_extracted->tpc_cmd = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->tpc_cmd=%x\n",nr_pdci_info_extracted->tpc_cmd); -#endif + #endif break; case CSI_REQUEST: // 42 CSI_REQUEST: (field defined for -,format0_1,-,-,-,-,-,-) nr_pdci_info_extracted->csi_request = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->csi_request=%x\n",nr_pdci_info_extracted->csi_request); -#endif + #endif break; case CBGTI: // 43 CBGTI: (field defined for -,format0_1,-,format1_1,-,-,-,-) // 0, 2, 4, 6, or 8 bits determined by higher layer parameter maxCodeBlockGroupsPerTransportBlock for the PDSCH nr_pdci_info_extracted->cbgti = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->cbgti=%x\n",nr_pdci_info_extracted->cbgti); -#endif + #endif break; case CBGFI: // 44 CBGFI: (field defined for -,-,-,format1_1,-,-,-,-) // 0 or 1 bit determined by higher layer parameter codeBlockGroupFlushIndicator nr_pdci_info_extracted->cbgfi = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->cbgfi=%x\n",nr_pdci_info_extracted->cbgfi); -#endif + #endif break; case PTRS_DMRS: // 45 PTRS_DMRS: (field defined for -,format0_1,-,-,-,-,-,-) nr_pdci_info_extracted->ptrs_dmrs = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->ptrs_dmrs=%x\n",nr_pdci_info_extracted->ptrs_dmrs); -#endif + #endif break; case BETA_OFFSET_IND: // 46 BETA_OFFSET_IND: (field defined for -,format0_1,-,-,-,-,-,-) nr_pdci_info_extracted->beta_offset_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->beta_offset_ind=%x\n",nr_pdci_info_extracted->beta_offset_ind); -#endif + #endif break; case DMRS_SEQ_INI: // 47 DMRS_SEQ_INI: (field defined for -,format0_1,-,format1_1,-,-,-,-) // 1 bit if the cell has two ULs and the number of bits for DCI format 1_0 before padding is larger than the number of bits for DCI format 0_0 before padding; 0 bit otherwise nr_pdci_info_extracted->dmrs_seq_ini = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->dmrs_seq_ini=%x\n",nr_pdci_info_extracted->dmrs_seq_ini); -#endif + #endif break; case UL_SCH_IND: // 48 UL_SCH_IND: (field defined for -,format0_1,-,-,-,-,-,-) // value of "1" indicates UL-SCH shall be transmitted on the PUSCH and a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH nr_pdci_info_extracted->ul_sch_ind = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->dmrs_seq_ini=%x\n",nr_pdci_info_extracted->ul_sch_ind); -#endif + #endif break; case PADDING_NR_DCI: // 49 PADDING_NR_DCI: (field defined for format0_0,-,format1_0,-,-,-,-,-) // (Note 2) If DCI format 0_0 is monitored in common search space nr_pdci_info_extracted->padding_nr_dci = (uint16_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->padding=%x\n",nr_pdci_info_extracted->padding_nr_dci); -#endif + #endif break; case SUL_IND_0_0: // 50 SUL_IND_0_0: (field defined for format0_0,-,-,-,-,-,-,-) nr_pdci_info_extracted->sul_ind_0_0 = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->sul_ind_0_0=%x\n",nr_pdci_info_extracted->sul_ind_0_0); -#endif + #endif break; case RA_PREAMBLE_INDEX: // 51 RA_PREAMBLE_INDEX: (field defined for format0_0,-,-,-,-,-,-,-) nr_pdci_info_extracted->ra_preamble_index = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->ra_preamble_index=%x\n",nr_pdci_info_extracted->ra_preamble_index); -#endif + #endif break; case SUL_IND_1_0: // 52 SUL_IND_1_0: (field defined for -,-,format1_0,-,-,-,-,-) nr_pdci_info_extracted->sul_ind_1_0 = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->sul_ind_1_0=%x\n",nr_pdci_info_extracted->sul_ind_1_0); -#endif + #endif break; case SS_PBCH_INDEX: // 53 SS_PBCH_INDEX: (field defined for -,-,format1_0,-,-,-,-,-) nr_pdci_info_extracted->ss_pbch_index = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->ss_pbch_index=%x\n",nr_pdci_info_extracted->ss_pbch_index); -#endif + #endif break; case PRACH_MASK_INDEX: // 54 PRACH_MASK_INDEX: (field defined for -,-,-,format1_0,-,-,-,-) nr_pdci_info_extracted->prach_mask_index = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->prach_mask_index=%x\n",nr_pdci_info_extracted->prach_mask_index); -#endif + #endif break; case RESERVED_NR_DCI: // 55 RESERVED_NR_DCI: (field defined for -,-,-,format1_0,-,-,-,-) nr_pdci_info_extracted->reserved_nr_dci = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field); //(((((*(uint128_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format])); -#ifdef NR_PDCCH_DCI_TOOLS_DEBUG + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->reserved_nr_dci=%x\n",nr_pdci_info_extracted->reserved_nr_dci); -#endif + #endif break; } } } - #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> Ending function nr_extract_dci_info()\n"); #endif @@ -7033,7 +7033,11 @@ int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, NR_UE_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; NR_DL_UE_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; NR_UE_ULSCH_t *ulsch0=NULL,*ulsch1=NULL; - //NR_DCI_INFO_EXTRACTED_t nr_dci_info_extracted; + + + NR_DCI_INFO_EXTRACTED_t *ptr_nr_dci_info_extracted = nr_dci_info_extracted; + + uint8_t status=0; #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> dci_format=%d, rnti=%d, dci_length=%d, dci_pdu[0]=%x, dci_pdu[2]=%x, dci_pdu[2]=%x, dci_pdu[3]=%x\n", @@ -7079,7 +7083,7 @@ int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, dci_length, rnti, dci_pdu, - &nr_dci_info_extracted, + ptr_nr_dci_info_extracted,//&nr_dci_info_extracted, dci_fields_sizes, dlsch0_harq, dlsch0, @@ -7089,12 +7093,13 @@ int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, n_RB_ULBWP, n_RB_DLBWP, crc_scrambled_values); - //status = check_dci_format1_1a_coherency(format1_1, frame_parms->N_RB_DL, rnti, tc_rnti, si_rnti, ra_rnti, p_rnti,frame,nr_tti_rx, &nr_dci_info_extracted, dlsch0_harq); + //printf("\n>>> inside nr_generate_ue_ul_dlsch_params_from_dci after nr_extract_dci_info: mcs=%d\n",nr_dci_info_extracted->mcs); #ifdef NR_PDCCH_DCI_TOOLS_DEBUG if(status == 0) { printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> bad DCI %d !!! \n",dci_format); return(-1); } + //printf("\n>>> inside nr_generate_ue_ul_dlsch_params_from_dci after nr_extract_dci_info: modified mcs=%d \n",nr_dci_info_extracted->mcs); printf("\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci) -> Ending function nr_extract_dci_info()\n"); #endif return(0); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index 92bdb71f0f..7d2ebd4aea 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -317,6 +317,8 @@ typedef struct { uint16_t rnti; /// Active flag for DLSCH demodulation uint8_t active; + /// accumulated tx power adjustment for PUCCH + int8_t g_pucch; /// Transmission mode uint8_t mode1_flag; /// amplitude of PDSCH (compared to RS) in symbols without pilots @@ -338,7 +340,7 @@ typedef struct { //#if defined(UPGRADE_RAT_NR) #if 1 /// Pointers to up to HARQ processes - NR_DL_UE_HARQ_t *harq_processes[NR_MAX_DLSCH_HARQ_PROCESSES]; + NR_DL_UE_HARQ_t harq_processes[NR_MAX_DLSCH_HARQ_PROCESSES]; // DL number of harq processes uint8_t number_harq_processes_for_pdsch; /* higher layer parameter for reception of two transport blocks TS 38.213 9.1.3.1 Type-2 HARQ-ACK codebook dtermination */ @@ -356,8 +358,8 @@ typedef struct { uint8_t max_turbo_iterations; /// number of iterations used in last turbo decoding uint8_t last_iteration_cnt; - /// accumulated tx power adjustment for PUCCH - int8_t g_pucch; + + } NR_UE_DLSCH_t; typedef enum {format0_0, diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 188beb3ec7..bd3690546d 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -95,17 +95,31 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ uint8_t current_harq_pid = dlsch_config_pdu->harq_process_nbr; dlsch0->current_harq_pid = current_harq_pid; dlsch0->active = 1; - dlsch0->harq_processes[current_harq_pid]->nb_rb = dlsch_config_pdu->number_rbs; - dlsch0->harq_processes[current_harq_pid]->start_rb = dlsch_config_pdu->start_rb; - dlsch0->harq_processes[current_harq_pid]->nb_symbols = dlsch_config_pdu->number_symbols; - dlsch0->harq_processes[current_harq_pid]->start_symbol = dlsch_config_pdu->start_symbol; + + //dlsch0->harq_processes[0]->mcs = &dlsch_config_pdu->mcs; + + NR_DL_UE_HARQ_t dlsch0_harq = dlsch0->harq_processes[current_harq_pid]; + + //dlsch0->harq_processes[current_harq_pid]->nb_rb = dlsch_config_pdu->number_rbs; + + dlsch0_harq.nb_rb = dlsch_config_pdu->number_rbs; + dlsch0_harq.start_rb = dlsch_config_pdu->start_rb; + dlsch0_harq.nb_symbols = dlsch_config_pdu->number_symbols; + dlsch0_harq.start_symbol = dlsch_config_pdu->start_symbol; + dlsch0_harq.mcs = dlsch_config_pdu->mcs; + dlsch0_harq.DCINdi = dlsch_config_pdu->ndi; + dlsch0_harq.rvidx = dlsch_config_pdu->rv; + dlsch0->g_pucch = dlsch_config_pdu->accumulated_delta_PUCCH; + dlsch0_harq.harq_ack.pucch_resource_indicator = dlsch_config_pdu->pucch_resource_id; + dlsch0_harq.harq_ack.slot_for_feedback_ack = dlsch_config_pdu->pdsch_to_harq_feedback_time_ind; + printf(">>>> \tdlsch0->g_pucch=%d\tdlsch0_harq.mcs=%d\n",dlsch0->g_pucch,dlsch0_harq.mcs); + //for (int j = 0 ; j<1000; j++) printf("\nk = %d",j); + + #if 0 dlsch0->harq_processes[current_harq_pid]->mcs = dlsch_config_pdu->mcs; - dlsch0->harq_processes[current_harq_pid]->DCINdi = dlsch_config_pdu->ndi; - dlsch0->harq_processes[current_harq_pid]->rvidx = dlsch_config_pdu->rv; dlsch0->g_pucch = dlsch_config_pdu->accumulated_delta_PUCCH; - dlsch0->harq_processes[current_harq_pid]->harq_ack.pucch_resource_indicator = dlsch_config_pdu->pucch_resource_id; - dlsch0->harq_processes[current_harq_pid]->harq_ack.slot_for_feedback_ack = dlsch_config_pdu->pdsch_to_harq_feedback_time_ind; //pdlsch0->rnti = rnti; + #endif } } }else{ diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index f88ffa3afc..599b76324b 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -337,7 +337,7 @@ void config_downlink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int TB_id, int { NR_UE_DLSCH_t *dlsch; - dlsch = (NR_UE_DLSCH_t *)malloc16(sizeof(NR_UE_DLSCH_t)); + //dlsch = (NR_UE_DLSCH_t *)malloc16(sizeof(NR_UE_DLSCH_t)); if (dlsch != NULL) { @@ -356,18 +356,18 @@ void config_downlink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int TB_id, int /* allocation of HARQ process context */ for (int harq_pid = 0; harq_pid < number_harq_processes_for_pdsch; harq_pid++) { - dlsch->harq_processes[harq_pid] = (NR_DL_UE_HARQ_t *)malloc16(sizeof(NR_DL_UE_HARQ_t)); + //dlsch->harq_processes[harq_pid] = (NR_DL_UE_HARQ_t *)malloc16(sizeof(NR_DL_UE_HARQ_t)); - if (dlsch->harq_processes[harq_pid] == NULL) { + /*if (dlsch->harq_processes[harq_pid] == NULL) { LOG_E(PHY, "Fatal memory allocation problem at line %d in function %s of file %s \n", __LINE__ , __func__, __FILE__); assert(0); - } + }*/ - memset(dlsch->harq_processes[harq_pid],0,sizeof(NR_DL_UE_HARQ_t)); + memset(&dlsch->harq_processes[harq_pid],0,sizeof(NR_DL_UE_HARQ_t)); - NR_DL_UE_HARQ_t *dl_harq = dlsch->harq_processes[harq_pid]; + NR_DL_UE_HARQ_t dl_harq = dlsch->harq_processes[harq_pid]; - init_downlink_harq_status(dl_harq); + init_downlink_harq_status(&dl_harq); } } @@ -389,12 +389,12 @@ void release_downlink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int TB_id, in { NR_UE_DLSCH_t *dlsch = ue->dlsch[execution_thread_number][gNB_id][TB_id]; - for (int process_id = 0; process_id < dlsch->Mdlharq; process_id++) { + /*for (int process_id = 0; process_id < dlsch->Mdlharq; process_id++) { free16(dlsch->harq_processes[process_id],sizeof(NR_DL_UE_HARQ_t)); dlsch->harq_processes[process_id] = NULL; - } + }*/ free16(dlsch,sizeof(NR_UE_DLSCH_t)); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index e1624f680d..8966bbb821 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -3129,15 +3129,19 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * // table dci_fields_sizes_cnt[dci_cnt-1][i][j] will then be used in function nr_extract_dci_info uint8_t dci_fields_sizes_cnt[MAX_NR_DCI_DECODED_SLOT][NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {0}; - uint16_t tc_rnti = 1; // FIXME - uint16_t int_rnti = 1; // FIXME - uint16_t sfi_rnti = 1; // FIXME - uint16_t tpc_pusch_rnti =1; // FIXME - uint16_t tpc_pucch_rnti = 1; // FIXME - uint16_t tpc_srs_rnti = 1; // FIXME int nb_searchspace_active=0; NR_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]]; NR_UE_PDCCH *pdcch_vars2 = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]; + + uint16_t c_rnti=pdcch_vars[eNB_id]->crnti; + uint16_t cs_rnti=1,new_rnti=1,tc_rnti=1; + uint16_t p_rnti=P_RNTI; + uint16_t si_rnti=SI_RNTI; + uint16_t ra_rnti=3; + uint16_t sp_csi_rnti=1,sfi_rnti=1,int_rnti=1,tpc_pusch_rnti=1,tpc_pucch_rnti=1,tpc_srs_rnti=1; //FIXME + uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES] = + {c_rnti,cs_rnti,new_rnti,tc_rnti,p_rnti,si_rnti,ra_rnti,sp_csi_rnti,sfi_rnti,int_rnti,tpc_pusch_rnti,tpc_pucch_rnti,tpc_srs_rnti}; + // s in TS 38.212 Subclause 10.1, for each active BWP the UE can deal with 10 different search spaces // Higher layers have updated the number of searchSpaces with are active in the current slot and this value is stored in variable nb_searchspace_total int nb_searchspace_total = pdcch_vars2->nb_search_space; @@ -3366,7 +3370,6 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * #endif - dci_cnt += nr_dci_decoding_procedure(nb_searchspace_active, nb_coreset_active, ue, @@ -3378,7 +3381,8 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * n_RB_ULBWP, n_RB_DLBWP, &crc_scrambled, - &format_found); + &format_found, + crc_scrambled_values); #ifdef NR_PDCCH_SCHED_DEBUG printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%d\n",dci_cnt); #endif @@ -3469,14 +3473,6 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * /* * This is the NR part */ - uint16_t c_rnti=pdcch_vars[eNB_id]->crnti; - uint16_t cs_rnti,new_rnti,tc_rnti; - uint16_t p_rnti=P_RNTI; - uint16_t si_rnti=SI_RNTI; - uint16_t ra_rnti=3; - uint16_t sp_csi_rnti,sfi_rnti,int_rnti,tpc_pusch_rnti,tpc_pucch_rnti,tpc_srs_rnti; //FIXME - uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES] = - {c_rnti,cs_rnti,new_rnti,tc_rnti,p_rnti,si_rnti,ra_rnti,sp_csi_rnti,sfi_rnti,int_rnti,tpc_pusch_rnti,tpc_pucch_rnti,tpc_srs_rnti}; if ((dci_alloc_rx[i].format == format0_0)) if ((dci_alloc_rx[i].format == format1_0) && @@ -3499,6 +3495,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * if ((dci_alloc_rx[i].format == format1_1)){ // This format not implemented at a first time. FIXME } NR_DCI_INFO_EXTRACTED_t nr_dci_info_extracted; + NR_DCI_INFO_EXTRACTED_t *ptr_nr_dci_info_extracted = &nr_dci_info_extracted; #ifdef NR_PDCCH_SCHED_DEBUG printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_generate_ue_ul_dlsch_params_from_dci with eNB_id=%d dci_cnt=%d format=%d, rnti=%d\n", eNB_id, @@ -3526,15 +3523,19 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * n_RB_ULBWP, n_RB_DLBWP, crc_scrambled_values, - &nr_dci_info_extracted); + ptr_nr_dci_info_extracted);//&nr_dci_info_extracted); ue->dci_ind.dci_list[i].rnti = dci_alloc_rx[i].rnti; ue->dci_ind.dci_list[i].dci_format = dci_alloc_rx[i].format; memcpy(&ue->dci_ind.dci_list[i].dci, &nr_dci_info_extracted, sizeof(fapi_nr_dci_pdu_rel15_t) ); - - // TODO: check where should we send up this message. - //ue->if_inst->dl_indication(&ue->dl_indication); + + //printf(">>> example mcs=%d\n",nr_dci_info_extracted.mcs); + //printf(">>> calling MAC with dl_indication DCI_IND\n"); + + // TODO: check where should we send up this message. + ue->dl_indication.dci_ind=&ue->dci_ind; + ue->if_inst->dl_indication(&ue->dl_indication); /* * This is the LTE part to be removed @@ -4040,11 +4041,11 @@ void ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB_id if ((pdsch==PDSCH) && (ue->transmission_mode[eNB_id] == 5) && - (dlsch0->harq_processes[harq_pid]->dl_power_off==0) && + (dlsch0->harq_processes[harq_pid].dl_power_off==0) && (ue->use_ia_receiver ==1)) { dual_stream_UE = 1; eNB_id_i = ue->n_connected_eNB; - i_mod = dlsch0->harq_processes[harq_pid]->Qm; + i_mod = dlsch0->harq_processes[harq_pid].Qm; } else if((pdsch==PDSCH) && (ue->transmission_mode[eNB_id]==3)) @@ -5473,6 +5474,10 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN #endif pmch_flag = is_pmch_subframe(frame_rx,nr_tti_rx,&ue->frame_parms) ? 1 : 0; + + + + if (do_pdcch_flag) { // deactivate reception until we scan pdcch @@ -5557,10 +5562,30 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN // LOG_D(PHY,"[UE %d] Frame %d: Calling pdcch procedures (eNB %d)\n",ue->Mod_id,frame_rx,eNB_id); //start_meas(&ue->rx_pdcch_stats[ue->current_thread_id[nr_tti_rx]]); + +//printf(">>> at phy_procedures_nrUE_RX, nr_ue_pdcch_procedures init, dlsch->active=%d\n", +// ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active); if (nr_ue_pdcch_procedures(eNB_id,ue,proc,abstraction_flag) == -1) { LOG_E(PHY,"[UE %d] Frame %d, nr_tti_rx %d: Error in pdcch procedures\n",ue->Mod_id,frame_rx,nr_tti_rx); return(-1); } +//for (int m=0;m<1000;m++) printf("%d",m); +//printf("\n>>> at phy_procedures_nrUE_RX, nr_ue_pdcch_procedures end, dlsch->active=%d\n", +// ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active); + + // preparing for PDSCH procedures +// if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active == 1) { +// ue_pdsch_procedures(ue, +// proc, +// eNB_id, +// PDSCH, +// ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0], +// NULL, +// ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->num_pdcch_symbols, +// ue->frame_parms.symbols_per_tti>>1, +// abstraction_flag); +// } +#if 0 //stop_meas(&ue->rx_pdcch_stats[ue->current_thread_id[nr_tti_rx]]); //printf("nr_tti_rx %d n_pdcch_sym %d pdcch procedures %5.3f \n", // nr_tti_rx, ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->num_pdcch_symbols, @@ -5571,7 +5596,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN // } // for l=1..l2 -#if 0 + ue_measurement_procedures(l-1,ue,proc,eNB_id,(nr_tti_rx<<1),abstraction_flag,mode); LOG_D(PHY," ------ end FFT/ChannelEst/PDCCH slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, nr_tti_rx); diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c index b64c3ab114..326410be73 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c @@ -139,7 +139,7 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ if (dl_harq_pid < ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->number_harq_processes_for_pdsch) { /* pucch indicator can be reseted in function get_downlink_ack so it should be get now */ - pucch_resource_indicator = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->harq_processes[dl_harq_pid]->harq_ack.pucch_resource_indicator; + pucch_resource_indicator = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->harq_processes[dl_harq_pid].harq_ack.pucch_resource_indicator; } /* Part - I @@ -238,7 +238,7 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ int occ_length = 0; int occ_Index = 0; - NR_UE_HARQ_STATUS_t *harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->harq_processes[dl_harq_pid]->harq_ack; + NR_UE_HARQ_STATUS_t *harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->harq_processes[dl_harq_pid].harq_ack; if (select_pucch_resource(ue, gNB_id, N_UCI, pucch_resource_indicator, &initial_pucch_id, &pucch_resource_set, &pucch_resource_id, harq_status) == TRUE) { @@ -630,7 +630,7 @@ uint8_t get_downlink_ack(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_t for (int dl_harq_pid = 0; dl_harq_pid < number_pid_dl; dl_harq_pid++) { - harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][code_word]->harq_processes[dl_harq_pid]->harq_ack; + harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][code_word]->harq_processes[dl_harq_pid].harq_ack; /* check if current tx slot should transmit downlink acknowlegment */ if (harq_status->slot_for_feedback_ack == proc->nr_tti_tx) { @@ -668,7 +668,7 @@ uint8_t get_downlink_ack(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_t } } if (do_reset == TRUE) { - init_downlink_harq_status(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][code_word]->harq_processes[dl_harq_pid]); + init_downlink_harq_status(&ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][code_word]->harq_processes[dl_harq_pid]); } } } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c2bca72271..9b79f35231 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -119,8 +119,8 @@ int8_t nr_ue_decode_mib( int32_t num_rbs = -1; int32_t num_symbols = -1; int32_t rb_offset = -1; - printf("<<<<<<<<mib->pdcch_ConfigSIB1,index_4msb,index_4lsb,scs_ssb,scs_pdcch, (scs_ssb << 5)|scs_pdcch); + //printf("<<<<<<<<mib->pdcch_ConfigSIB1,index_4msb,index_4lsb,scs_ssb,scs_pdcch, (scs_ssb << 5)|scs_pdcch); // type0-pdcch coreset switch( (scs_ssb << 5)|scs_pdcch ){ @@ -250,7 +250,7 @@ int8_t nr_ue_decode_mib( mask = mask >> 1; mask = mask | 0x100000000000; } - printf(">>>>>>>>mask 0x%16x num_rbs %d rb_offset %d\n", mask, num_rbs, rb_offset); + //printf(">>>>>>>>mask %x num_rbs %d rb_offset %d\n", mask, num_rbs, rb_offset); mac->type0_pdcch_dci_config.coreset.frequency_domain_resource = mask; mac->type0_pdcch_dci_config.coreset.rb_offset = rb_offset; // additional parameter other than coreset @@ -545,14 +545,14 @@ NR_UE_L2_STATE_t nr_ue_scheduler( ////////////// /* * This code contains all the functions needed to process all dci fields. - * These functions are going to be called by function nr_ue_process_dci + * These tables and functions are going to be called by function nr_ue_process_dci */ // table_7_3_1_1_2_2_3_4_5 contains values for number of layers and precoding information for tables 7.3.1.1.2-2/3/4/5 from TS 38.212 subclause 7.3.1.1.2 // the first 6 columns contain table 7.3.1.1.2-2: Precoding information and number of layers, for 4 antenna ports, if transformPrecoder=disabled and maxRank = 2 or 3 or 4 // next six columns contain table 7.3.1.1.2-3: Precoding information and number of layers for 4 antenna ports, if transformPrecoder= enabled, or if transformPrecoder=disabled and maxRank = 1 // next four columns contain table 7.3.1.1.2-4: Precoding information and number of layers, for 2 antenna ports, if transformPrecoder=disabled and maxRank = 2 // next four columns contain table 7.3.1.1.2-5: Precoding information and number of layers, for 2 antenna ports, if transformPrecoder= enabled, or if transformPrecoder= disabled and maxRank = 1 -uint8_t table_7_3_1_1_2_2_3_4_5[63][20] = { +uint8_t table_7_3_1_1_2_2_3_4_5[64][20] = { {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 0, 2, 0, 1, 2, 0, 0}, @@ -1135,7 +1135,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fa const uint16_t n_RB_ULBWP = 106; const uint16_t n_RB_DLBWP = 106; -printf(">>> nr_ue_process_dci at MAC layer"); +printf("\n>>> nr_ue_process_dci at MAC layer with dci_format=%d\n",dci_format); switch(dci_format){ case format0_0: @@ -1547,19 +1547,19 @@ printf(">>> nr_ue_process_dci at MAC layer"); * 28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI * 33 TPC_PUCCH: */ - dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti; + //fapi_nr_dl_config_dlsch_pdu_rel15_t dlsch_config_pdu_1_0 = dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_0 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; /* IDENTIFIER_DCI_FORMATS */ /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */ - nr_ue_process_dci_freq_dom_resource_assignment(NULL,&dlsch_config_pdu_1_0,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL); + nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_0,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL); /* TIME_DOM_RESOURCE_ASSIGNMENT */ - nr_ue_process_dci_time_dom_resource_assignment(NULL,&dlsch_config_pdu_1_0,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); + nr_ue_process_dci_time_dom_resource_assignment(NULL,dlsch_config_pdu_1_0,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); /* VRB_TO_PRB_MAPPING */ dlsch_config_pdu_1_0->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping == 0) ? vrb_to_prb_mapping_non_interleaved:vrb_to_prb_mapping_interleaved; /* MCS */ dlsch_config_pdu_1_0->mcs = dci->mcs; - /* NDI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ + /* NDI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ dlsch_config_pdu_1_0->ndi = dci->ndi; /* RV (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/ dlsch_config_pdu_1_0->rv = dci->rv; @@ -1590,9 +1590,45 @@ printf(">>> nr_ue_process_dci at MAC layer"); //if (dci->pucch_resource_ind == 7) dlsch_config_pdu_1_0->pucch_resource_id = 8; //pucch-ResourceId obtained from the 8th value of resourceList FIXME!! dlsch_config_pdu_1_0->pucch_resource_id = dci->pucch_resource_ind; /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/ - dlsch_config_pdu_1_0-> pdsch_to_harq_feedback_time_ind = dci->pdsch_to_harq_feedback_time_ind; + dlsch_config_pdu_1_0->pdsch_to_harq_feedback_time_ind = dci->pdsch_to_harq_feedback_time_ind; dl_config->number_pdus = dl_config->number_pdus + 1; + + printf("\n>>> (nr_ue_procedures.c) rnti=%d dl_config->number_pdus=%d\n", + dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti, + dl_config->number_pdus); + printf(">>> (nr_ue_procedures.c) frequency_domain_resource_assignment=%d \t number_rbs=%d \t start_rb=%d\n", + dci->freq_dom_resource_assignment_DL, + dlsch_config_pdu_1_0->number_rbs, + dlsch_config_pdu_1_0->start_rb); + printf(">>> (nr_ue_procedures.c) time_domain_resource_assignment=%d \t number_symbols=%d \t start_symbol=%d\n", + dci->time_dom_resource_assignment, + dlsch_config_pdu_1_0->number_symbols, + dlsch_config_pdu_1_0->start_symbol); + printf(">>> (nr_ue_procedures.c) vrb_to_prb_mapping=%d \n>>> mcs=%d\n>>> ndi=%d\n>>> rv=%d\n>>> harq_process_nbr=%d\n>>> dai=%d\n>>> scaling_factor_S=%d\n>>> tpc_pucch=%d\n>>> pucch_res_ind=%d\n>>> pdsch_to_harq_feedback_time_ind=%d\n", + dlsch_config_pdu_1_0->vrb_to_prb_mapping, + dlsch_config_pdu_1_0->mcs, + dlsch_config_pdu_1_0->ndi, + dlsch_config_pdu_1_0->rv, + dlsch_config_pdu_1_0->harq_process_nbr, + dlsch_config_pdu_1_0->dai, + dlsch_config_pdu_1_0->scaling_factor_S, + dlsch_config_pdu_1_0->accumulated_delta_PUCCH, + dlsch_config_pdu_1_0->pucch_resource_id, + dlsch_config_pdu_1_0->pdsch_to_harq_feedback_time_ind); + + dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; + printf(">>> (nr_ue_procedures.c) pdu_type=%d\n\n",dl_config->dl_config_list[dl_config->number_pdus].pdu_type); + + if(mac->if_module != NULL && mac->if_module->dl_indication != NULL) + //printf(">>> mac->if_module->dl_indication(&mac->phy_config); \n"); + //for (int k=0;k<1000;k++) printf(">>> %d ",k); + //mac->if_module->dl_indication(&mac->dl_info); + //mac->if_module->dl_indication(&mac->dl_config_request); + mac->if_module->dl_indication(&mac->phy_config); + + + break; case format1_1: @@ -1633,9 +1669,9 @@ printf(">>> nr_ue_process_dci at MAC layer"); /* BANDWIDTH_PART_IND */ dlsch_config_pdu_1_1->bandwidth_part_ind = dci->bandwidth_part_ind; /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */ - nr_ue_process_dci_freq_dom_resource_assignment(NULL,&dlsch_config_pdu_1_1,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL); + nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_1,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL); /* TIME_DOM_RESOURCE_ASSIGNMENT */ - nr_ue_process_dci_time_dom_resource_assignment(NULL,&dlsch_config_pdu_1_1,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); + nr_ue_process_dci_time_dom_resource_assignment(NULL,dlsch_config_pdu_1_1,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position); /* VRB_TO_PRB_MAPPING */ if (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.resource_allocation != 0) dlsch_config_pdu_1_1->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping == 0) ? vrb_to_prb_mapping_non_interleaved:vrb_to_prb_mapping_interleaved; @@ -1660,7 +1696,7 @@ printf(">>> nr_ue_process_dci at MAC layer"); /* HARQ_PROCESS_NUMBER */ dlsch_config_pdu_1_1->harq_process_nbr = dci->harq_process_number; /* DAI */ - dlsch_config_pdu_1_0->dai = dci ->dai; + dlsch_config_pdu_1_1->dai = dci ->dai; /* TPC_PUCCH */ // according to TS 38.213 Table 7.2.1-1 if (dci->tpc_pucch == 0) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = -1; @@ -1775,6 +1811,13 @@ printf(">>> nr_ue_process_dci at MAC layer"); //FIXME!!! dl_config->number_pdus = dl_config->number_pdus + 1; + + dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; + printf(">>> (nr_ue_procedures.c) pdu_type=%d\n\n",dl_config->dl_config_list[dl_config->number_pdus].pdu_type); + + if(mac->if_module != NULL && mac->if_module->dl_indication != NULL) + mac->if_module->dl_indication(&mac->phy_config); + break; case format2_0: diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 3e9bb6285b..657b414714 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -142,7 +142,8 @@ int8_t nr_ue_dl_indication(nr_downlink_indication_t *dl_info){ if(dl_info->dci_ind != NULL){ printf("[L2][IF MODULE][DL INDICATION][DCI_IND]\n"); - for(i=0; dl_info->dci_ind->number_of_dcis; ++i){ + for(i=0; idci_ind->number_of_dcis; ++i){ + //printf(">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n",i,dl_info->dci_ind->number_of_dcis); fapi_nr_dci_pdu_rel15_t *dci = &dl_info->dci_ind->dci_list[i].dci; ret_mask |= (handle_dci( @@ -193,7 +194,6 @@ int8_t nr_ue_dl_indication(nr_downlink_indication_t *dl_info){ break; }*/ - //(dl_info->dci_list+i)->rnti From 70e0bba3d72d9e7878671de779841b58653725cb Mon Sep 17 00:00:00 2001 From: hongzhi wang Date: Wed, 3 Oct 2018 15:31:34 +0200 Subject: [PATCH 108/114] NR PDCCH development: validation modification dci_nr.c file --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 64 +++++++-------------------- 1 file changed, 16 insertions(+), 48 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 465e278c0c..59412aa469 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -3162,31 +3162,9 @@ printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> (c_init=%d, n_id=%d, #endif } - -#ifdef NR_PDCCH_DCI_DEBUG -//k = 0; -//for (int j = 0; j < length; j++){ -// if ((j%32==0) && (j!=0)) k++; -// if ((j%2 == 0) && ((*(char*) &z[(int)floor(i/2)]) > 0)) { -// unscrambled[k] = (unscrambled[k]<<1) + 1; -// } -// if ((j%2 == 0) && ((*(char*) &z[(int)floor(i/2)]) <= 0)) { -// unscrambled[k] = (unscrambled[k]<<1) + 0; -// } -// if ((j%2 == 1) && ((*(1 + (char*) &z[(int)floor(i/2)])) > 0)) { -// unscrambled[k] = (unscrambled[k]<<1) + 1; -// } -// if ((j%2 == 1) && ((*(1 + (char*) &z[(int)floor(i/2)])) <= 0)) { -// unscrambled[k] = (unscrambled[k]<<1) + 0; -// } -//} -//for (int p=0; p after scrambling, unscrambled[%d]=%x\n",p,unscrambled[p]); -#endif - - } +#if 0 void nr_pdcch_unscrambling_tmp(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_tti_rx, double llr[], uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common) { @@ -3233,7 +3211,6 @@ printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> (c_init=%d, n_id=%d, } -#if 0 void nr_pdcch_unscrambling_old(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_tti_rx, int8_t* llr, uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common) { @@ -3939,21 +3916,20 @@ int get_nCCE_offset_l1(int *CCE_table, #ifdef NR_PDCCH_DCI_RUN -void nr_dci_decoding_procedure0(int s, //x +void nr_dci_decoding_procedure0(int s, int p, int coreset_time_dur, - uint16_t coreset_nbr_rb, //x - NR_UE_PDCCH **pdcch_vars, //x - int do_common, //x - //dci_detect_mode_t mode, //not sure if necessary - uint8_t nr_tti_rx, //x - NR_DCI_ALLOC_t *dci_alloc, //x - int16_t eNB_id, //x - uint8_t current_thread_id, //x + uint16_t coreset_nbr_rb, + NR_UE_PDCCH **pdcch_vars, + int do_common, + uint8_t nr_tti_rx, + NR_DCI_ALLOC_t *dci_alloc, + int16_t eNB_id, + uint8_t current_thread_id, NR_DL_FRAME_PARMS *frame_parms, - t_nrPolar_paramsPtr *nrPolar_params, //x + t_nrPolar_paramsPtr *nrPolar_params, uint8_t mi, - uint16_t crc_scrambled_values[13], //x + uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES], uint8_t L, NR_UE_SEARCHSPACE_CSS_DCI_FORMAT_t format_css, NR_UE_SEARCHSPACE_USS_DCI_FORMAT_t format_uss, @@ -5407,8 +5383,10 @@ uint8_t nr_dci_decoding_procedure(int s, uint16_t n_RB_ULBWP, uint16_t n_RB_DLBWP, crc_scrambled_t *crc_scrambled, - format_found_t *format_found) { + format_found_t *format_found, + uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES]) { // uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS], + for (int n=0; n<13; n++) printf("################ 2 crc_scrambled_values[%d]=%d\n",n,crc_scrambled_values[n]); #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure) nr_tti_rx=%d n_RB_ULBWP=%d n_RB_DLBWP=%d format_found=%d\n", @@ -5437,18 +5415,7 @@ uint8_t nr_dci_decoding_procedure(int s, NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; t_nrPolar_paramsPtr *nrPolar_params = &ue->nrPolar_params; uint8_t mi;// = get_mi(&ue->frame_parms, nr_tti_rx); - // we need to initialize this values as crc is going to be compared with them - //uint16_t c_rnti=pdcch_vars[eNB_id]->crnti; - uint16_t c_rnti=pdcch_vars2->crnti; //to be removed FIXME!!! - printf("c_rnti=%d\n",c_rnti); - uint16_t cs_rnti,new_rnti,tc_rnti; - uint16_t p_rnti=P_RNTI; - uint16_t si_rnti=SI_RNTI; - uint16_t ra_rnti=3; //at the moment this value is hardcoded FIXME!!! - uint16_t sp_csi_rnti,sfi_rnti,int_rnti,tpc_pusch_rnti,tpc_pucch_rnti,tpc_srs_rnti; //FIXME !!! - uint16_t crc_scrambled_values[13] = {c_rnti,cs_rnti,new_rnti,tc_rnti,p_rnti,si_rnti,ra_rnti,sp_csi_rnti,sfi_rnti,int_rnti,tpc_pusch_rnti,tpc_pucch_rnti,tpc_srs_rnti}; - - //uint8_t format0_found = 0, format_c_found = 0; + uint8_t tmode = ue->transmission_mode[eNB_id]; uint8_t frame_type = frame_parms->frame_type; @@ -5458,6 +5425,7 @@ uint8_t nr_dci_decoding_procedure(int s, uint8_t format_2_1_size_bits = 0, format_2_1_size_bytes = 0; //FIXME uint8_t format_2_2_size_bits = 0, format_2_2_size_bytes = 0; //FIXME uint8_t format_2_3_size_bits = 0, format_2_3_size_bytes = 0; //FIXME + /* * * The implementation of this function will depend on the information given by the searchSpace IE From 39fd45946642277c9ae0b146d0c9f394622f4457 Mon Sep 17 00:00:00 2001 From: Agustin Date: Thu, 4 Oct 2018 18:03:31 +0200 Subject: [PATCH 109/114] NR PDCCH development warning clean up --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 2 + openair1/PHY/NR_REFSIG/nr_dmrs_rx.c | 5 +- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 117 +++++++++--------- openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c | 14 +-- .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 5 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 77 +++++++++--- openair1/SCHED_NR_UE/pucch_uci_ue_nr.c | 54 ++++++++ openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 8 +- targets/RT/USER/nr-uesoftmodem.c | 16 +-- 10 files changed, 205 insertions(+), 95 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index a1f4d3b856..6feecc68f4 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -233,6 +233,7 @@ typedef struct { uint8_t bandwidth_part_ind; uint16_t number_rbs; uint16_t start_rb; + uint8_t frame_offset; uint16_t number_symbols; uint16_t start_symbol; pusch_freq_hopping_t pusch_freq_hopping; @@ -302,6 +303,7 @@ typedef struct { uint8_t bandwidth_part_ind; uint16_t number_rbs; uint16_t start_rb; + uint8_t frame_offset; uint16_t number_symbols; uint16_t start_symbol; uint8_t prb_bundling_size_ind; diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c index e2ca70d82f..3c58f5535d 100644 --- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c +++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c @@ -115,7 +115,8 @@ int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue, unsigned short nb_rb_pdsch) { int32_t qpsk[4],nqpsk[4],*qpsk_p, n; - int w,mprime,ind,l,ind_dword,ind_qpsk_symb,kp,lp, config_type, k; + //int w,mprime,ind,l,ind_dword,ind_qpsk_symb,kp,lp, config_type, k; + int w,ind,ind_dword,ind_qpsk_symb,kp,lp, config_type, k=0; short pamp; typedef int array_of_w[2]; @@ -196,7 +197,7 @@ int nr_pdcch_dmrs_rx(PHY_VARS_NR_UE *ue, { uint8_t idx=0; - uint8_t pdcch_rb_offset =0; + //uint8_t pdcch_rb_offset =0; //nr_gold_pdcch += ((int)floor(ue->frame_parms.ssb_start_subcarrier/12)+pdcch_rb_offset)*3/32; if (p==2000) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 59412aa469..2f44497d04 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -390,8 +390,8 @@ symbol 0 | ... bundle 3 bundle 6 */ int c=0,r=0; - uint16_t bundle_j=0, f_bundle_j,f_reg; - uint32_t coreset_C; + uint16_t bundle_j=0, f_bundle_j=0,f_reg=0; + uint32_t coreset_C=0; uint16_t index_z, index_llr; int coreset_interleaved = 0; @@ -504,7 +504,7 @@ void nr_pdcch_demapping(uint16_t *llr, uint16_t *wbar, #endif //0 #endif - +#if 0 void pdcch_demapping(uint16_t *llr,uint16_t *wbar,NR_DL_FRAME_PARMS *frame_parms,uint8_t num_pdcch_symbols,uint8_t mi) { @@ -610,8 +610,9 @@ void pdcch_demapping(uint16_t *llr,uint16_t *wbar,NR_DL_FRAME_PARMS *frame_parms } // kprime loop } +#endif //0 -static uint16_t wtemp_rx[Msymb]; +//static uint16_t wtemp_rx[Msymb]; #if 0 #ifdef NR_PDCCH_DCI_RUN @@ -691,7 +692,7 @@ void nr_pdcch_deinterleaving(NR_DL_FRAME_PARMS *frame_parms, uint16_t *z, - +#if 0 void pdcch_deinterleaving(NR_DL_FRAME_PARMS *frame_parms,uint16_t *z, uint16_t *wbar,uint8_t number_pdcch_symbols,uint8_t mi) { @@ -794,8 +795,9 @@ void pdcch_deinterleaving(NR_DL_FRAME_PARMS *frame_parms,uint16_t *z, uint16_t * } } +#endif //0 - +#if 0 int32_t pdcch_qpsk_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, int32_t **rxdataF_comp_i, @@ -845,7 +847,7 @@ int32_t pdcch_qpsk_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, return(0); } - +#endif //0 #ifdef NR_PDCCH_DCI_RUN int32_t nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, @@ -861,7 +863,7 @@ int32_t nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, printf("pdcch_qpsk_llr: llr is null, symbol %d\n", symbol); return (-1); } -#ifdef NR_PDCCH_DCI_DEBUG +#ifndef NR_PDCCH_DCI_DEBUG printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_llr)-> llr logs: pdcch qpsk llr for symbol %d (pos %d), llr offset %d\n",symbol,(symbol*frame_parms->N_RB_DL*12),pdcch_llr8-pdcch_llr); #endif //for (i = 0; i < (frame_parms->N_RB_DL * ((symbol == 0) ? 16 : 24)); i++) { @@ -1219,10 +1221,11 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, // after removing the 3 DMRS RE, the RB contains 9 RE with PDCCH #define NBR_RE_PER_RB_WITHOUT_DMRS 9 - uint16_t c_rb, c_rb_tmp, rb, nb_rb = 0; + uint16_t c_rb, nb_rb = 0; // this variable will be incremented by 1 each time a bit set to '0' is found in coreset_freq_dom bitmap uint16_t offset_discontiguous=0; - uint8_t rb_count_bit,i, j, aarx, bitcnt_coreset_freq_dom=0; + //uint8_t rb_count_bit; + uint8_t i, j, aarx, bitcnt_coreset_freq_dom=0; int32_t *dl_ch0, *dl_ch0_ext, *rxF, *rxF_ext; int nushiftmod3 = frame_parms->nushift % 3; uint8_t symbol_mod; @@ -1294,7 +1297,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, c_rb = c_rb + BIT_TO_NBR_RB_CORESET_FREQ_DOMAIN; offset_discontiguous ++; #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> we entered here as coreset_freq_dom=%llx (bit %d) is 0, coreset_freq_domain is discontiguous\n",coreset_freq_dom,(46 - bitcnt_coreset_freq_dom)); + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_extract_rbs_single)-> we entered here as coreset_freq_dom=%lx (bit %d) is 0, coreset_freq_domain is discontiguous\n",coreset_freq_dom,(46 - bitcnt_coreset_freq_dom)); #endif } } @@ -2631,9 +2634,9 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, if (searchSpaceType == ue_specific) do_common=0; uint8_t log2_maxh, aatx, aarx; int32_t avgs; - uint8_t n_pdcch_symbols; + //uint8_t n_pdcch_symbols; // the variable mi can be removed for NR - uint8_t mi = get_mi(frame_parms, nr_tti_rx); + //uint8_t mi = get_mi(frame_parms, nr_tti_rx); /* * The following variables have been extracted from higher layer parameters @@ -2683,9 +2686,9 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, NR_UE_CORESET_REG_bundlesize_t reg_bundle_size_L = pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.reg_bundlesize; // higher-layer parameter CORESET-interleaver-size {2,3,6} NR_UE_CORESET_interleaversize_t coreset_interleaver_size_R= pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.interleaversize; - NR_UE_CORESET_precoder_granularity_t precoder_granularity = pdcch_vars2->coreset[nb_coreset_active].precoderGranularity; - int tci_statesPDCCH = pdcch_vars2->coreset[nb_coreset_active].tciStatesPDCCH; - int tci_present = pdcch_vars2->coreset[nb_coreset_active].tciPresentInDCI; + //NR_UE_CORESET_precoder_granularity_t precoder_granularity = pdcch_vars2->coreset[nb_coreset_active].precoderGranularity; + //int tci_statesPDCCH = pdcch_vars2->coreset[nb_coreset_active].tciStatesPDCCH; + //int tci_present = pdcch_vars2->coreset[nb_coreset_active].tciPresentInDCI; uint16_t pdcch_DMRS_scrambling_id = pdcch_vars2->coreset[nb_coreset_active].pdcchDMRSScramblingID; // The UE can be assigned 4 different BWP but only one active at a time. @@ -2700,7 +2703,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, // at the moment we are considering that the PDCCH is always starting at symbol 0 of current slot // the following code to initialize start_symbol must be activated once we implement PDCCH demapping on symbol not equal to 0 (considering symbol_mon) for (int i=0; i < 14; i++) { - if ((symbol_mon >> (i+1))&0x1 != 0) { + if (((symbol_mon >> (i+1))&0x1) != 0) { start_symbol = i; i=14; } @@ -2708,7 +2711,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> symbol_mon=(%d) and start_symbol=(%d)\n",symbol_mon,start_symbol); - printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> coreset_freq_dom=(%lld) n_rb_offset=(%d) coreset_time_dur=(%d) n_shift=(%d) reg_bundle_size_L=(%d) coreset_interleaver_size_R=(%d) \n", + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> coreset_freq_dom=(%ld) n_rb_offset=(%d) coreset_time_dur=(%d) n_shift=(%d) reg_bundle_size_L=(%d) coreset_interleaver_size_R=(%d) \n", coreset_freq_dom,n_rb_offset,coreset_time_dur,n_shift,reg_bundle_size_L,coreset_interleaver_size_R); #endif @@ -2722,7 +2725,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, // this may lead to a modification in ue scheduler // indicates the number of active CORESETs for the current BWP to decode PDCCH: max is 3 (this variable is not useful here, to be removed) - uint8_t coreset_nbr_act; + //uint8_t coreset_nbr_act; // indicates the number of REG contained in the PDCCH (number of RBs * number of symbols, in CORESET) uint8_t coreset_nbr_reg; uint32_t coreset_C; @@ -2732,7 +2735,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, // for each active CORESET (max number of active CORESETs in a BWP is 3), // we calculate the number of RB for each CORESET bitmap #ifdef NR_PDCCH_DCI_DEBUG - printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> coreset_freq_dom=(%lld)\n",coreset_freq_dom); + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> coreset_freq_dom=(%ld)\n",coreset_freq_dom); #endif int i; //for each bit in the coreset_freq_dom bitmap for (i = 0; i < 45; i++) { @@ -2741,7 +2744,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, } coreset_nbr_rb = 6 * coreset_nbr_rb; // coreset_nbr_rb has to be multiplied by 6 to indicate the number of PRB or REG(=12 RE) within the CORESET #ifdef NR_PDCCH_DCI_DEBUG - printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> coreset_freq_dom=(%lld,%llx), coreset_nbr_rb=%d\n", coreset_freq_dom,coreset_freq_dom,coreset_nbr_rb); + printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> coreset_freq_dom=(%ld,%lx), coreset_nbr_rb=%d\n", coreset_freq_dom,coreset_freq_dom,coreset_nbr_rb); #endif coreset_nbr_reg = coreset_time_dur * coreset_nbr_rb; coreset_C = (uint32_t)(coreset_nbr_reg / (reg_bundle_size_L * coreset_interleaver_size_R)); @@ -3066,10 +3069,10 @@ nr_pdcch_demapping_deinterleaving(pdcch_vars[eNB_id]->llr, nr_tti_rx, pdcch_vars[eNB_id]->e_rx, get_nCCE(n_pdcch_symbols,frame_parms,mi)*72); -*/ + pdcch_vars[eNB_id]->num_pdcch_symbols = n_pdcch_symbols; - +*/ #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> Ending nr_rx_pdcch() function\n"); #endif @@ -3754,7 +3757,7 @@ uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB, #endif -static uint8_t dci_decoded_output[RX_NB_TH][(MAX_DCI_SIZE_BITS+64)/8]; +//static uint8_t dci_decoded_output[RX_NB_TH][(MAX_DCI_SIZE_BITS+64)/8]; /*uint16_t get_nCCE(uint8_t num_pdcch_symbols,NR_DL_FRAME_PARMS *frame_parms,uint8_t mi) { @@ -3928,7 +3931,7 @@ void nr_dci_decoding_procedure0(int s, uint8_t current_thread_id, NR_DL_FRAME_PARMS *frame_parms, t_nrPolar_paramsPtr *nrPolar_params, - uint8_t mi, + //uint8_t mi, uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES], uint8_t L, NR_UE_SEARCHSPACE_CSS_DCI_FORMAT_t format_css, @@ -3972,7 +3975,7 @@ void nr_dci_decoding_procedure0(int s, //} #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> frequencyDomainResources=%llx, duration=%d\n", + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> frequencyDomainResources=%lx, duration=%d\n", pdcch_vars[eNB_id]->coreset[p].frequencyDomainResources, pdcch_vars[eNB_id]->coreset[p].duration); #endif @@ -4158,7 +4161,7 @@ void nr_dci_decoding_procedure0(int s, printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0: polar decoding)-> polar intput (with coreset_time_dur=%d, coreset_nbr_rb=%d, p=%d, CCEind=%d): \n", coreset_time_dur,coreset_nbr_rb,p,CCEind); #endif - int reg_p,reg_e; + int reg_p=0,reg_e=0; for (int m=0; m < (L2*6); m++){ reg_p = (((int)floor(m/coreset_time_dur))+((m%coreset_time_dur)*(L2*6/coreset_time_dur)))*9*2; reg_e = m*9*2; @@ -4243,7 +4246,6 @@ uint16_t rnti=3; if (crc == crc_scrambled_values[_RA_RNTI_]) { *crc_scrambled =_ra_rnti; *format_found=_format_1_0_found; - printf(""); } if (crc == crc_scrambled_values[_SP_CSI_RNTI_]) { *crc_scrambled =_sp_csi_rnti; @@ -4292,49 +4294,53 @@ uint16_t rnti=3; if ((*crc_scrambled == _p_rnti) || (*crc_scrambled == _si_rnti) || (*crc_scrambled == _ra_rnti)){ dci_alloc[*dci_cnt].format = format1_0; *dci_cnt = *dci_cnt + 1; - format_found=_format_1_0_found; - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> a format1_0=%d and dci_cnt=%d\n",format_found,*dci_cnt); + *format_found=_format_1_0_found; + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> a format1_0=%d and dci_cnt=%d\n",*format_found,*dci_cnt); } else { - if (dci_estimation[0]&1 == 0){ + if ((dci_estimation[0]&1) == 0){ dci_alloc[*dci_cnt].format = format0_0; *dci_cnt = *dci_cnt + 1; - format_found=_format_0_0_found; - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> b format0_0=%d and dci_cnt=%d\n",format_found,*dci_cnt); + *format_found=_format_0_0_found; + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> b format0_0=%d and dci_cnt=%d\n",*format_found,*dci_cnt); } - if (dci_estimation[0]&1 == 1){ + if ((dci_estimation[0]&1) == 1){ dci_alloc[*dci_cnt].format = format1_0; *dci_cnt = *dci_cnt + 1; - format_found=_format_1_0_found; - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> c format1_0=%d and dci_cnt=%d\n",format_found,*dci_cnt); + *format_found=_format_1_0_found; + printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> c format1_0=%d and dci_cnt=%d\n",*format_found,*dci_cnt); } } } if (format_css == cformat2_0){ dci_alloc[*dci_cnt].format = format2_0; *dci_cnt = *dci_cnt + 1; + *format_found=_format_2_0_found; } if (format_css == cformat2_1){ dci_alloc[*dci_cnt].format = format2_1; *dci_cnt = *dci_cnt + 1; + *format_found=_format_2_1_found; } if (format_css == cformat2_2){ dci_alloc[*dci_cnt].format = format2_2; *dci_cnt = *dci_cnt + 1; + *format_found=_format_2_2_found; } if (format_css == cformat2_3){ dci_alloc[*dci_cnt].format = format2_3; *dci_cnt = *dci_cnt + 1; + *format_found=_format_2_3_found; } if (format_uss == uformat0_1_and_1_1){ - if (dci_estimation[0]&1 == 0){ + if ((dci_estimation[0]&1) == 0){ dci_alloc[*dci_cnt].format = format0_1; *dci_cnt = *dci_cnt + 1; - format_found=_format_0_1_found; + *format_found=_format_0_1_found; } - if (dci_estimation[0]&1 == 1){ + if ((dci_estimation[0]&1) == 1){ dci_alloc[*dci_cnt].format = format1_1; *dci_cnt = *dci_cnt + 1; - format_found=_format_1_1_found; + *format_found=_format_1_1_found; } } // store first nCCE of group for PUCCH transmission of ACK/NAK @@ -4928,10 +4934,10 @@ uint16_t nr_dci_format_size (PHY_VARS_NR_UE *ue, // 7 BANDWIDTH_PART_IND // number of UL BWPs configured by higher layers uint8_t n_UL_BWP_RRC=1; // initialized to 1 but it has to be initialized by higher layers FIXME!!! - (n_UL_BWP_RRC > 3)?n_UL_BWP_RRC:(n_UL_BWP_RRC+1); + n_UL_BWP_RRC = ((n_UL_BWP_RRC > 3)?n_UL_BWP_RRC:(n_UL_BWP_RRC+1)); // number of DL BWPs configured by higher layers uint8_t n_DL_BWP_RRC=1; // initialized to 1 but it has to be initialized by higher layers FIXME!!! - (n_DL_BWP_RRC > 3)?n_DL_BWP_RRC:(n_DL_BWP_RRC+1); + n_DL_BWP_RRC = ((n_DL_BWP_RRC > 3)?n_DL_BWP_RRC:(n_DL_BWP_RRC+1)); // 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL @@ -4958,7 +4964,7 @@ uint16_t nr_dci_format_size (PHY_VARS_NR_UE *ue, ul_res_alloc_type_0 = 1; ul_res_alloc_type_1 = 1; } - uint8_t n_bits_freq_dom_res_assign_ul,n_ul_RGB_tmp; + uint8_t n_bits_freq_dom_res_assign_ul=0,n_ul_RGB_tmp; if (ul_res_alloc_type_0 == 1){ // implementation of Table 6.1.2.2.1-1 TC 38.214 subclause 6.1.2.2.1 // config1: PUSCH-Config IE contains rbg-Size ENUMERATED {config1 config2} ul_rgb_Size_t config = pusch_config.ul_rgbSize; @@ -4985,7 +4991,7 @@ uint16_t nr_dci_format_size (PHY_VARS_NR_UE *ue, dl_res_alloc_type_0 = 1; dl_res_alloc_type_1 = 1; } - uint8_t n_bits_freq_dom_res_assign_dl,n_dl_RGB_tmp; + uint8_t n_bits_freq_dom_res_assign_dl=0,n_dl_RGB_tmp; if (dl_res_alloc_type_0 == 1){ // implementation of Table 5.1.2.2.1-1 TC 38.214 subclause 6.1.2.2.1 // config1: PDSCH-Config IE contains rbg-Size ENUMERATED {config1, config2} dl_rgb_Size_t config = pdsch_config.dl_rgbSize; @@ -5386,7 +5392,6 @@ uint8_t nr_dci_decoding_procedure(int s, format_found_t *format_found, uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES]) { // uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS], - for (int n=0; n<13; n++) printf("################ 2 crc_scrambled_values[%d]=%d\n",n,crc_scrambled_values[n]); #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure) nr_tti_rx=%d n_RB_ULBWP=%d n_RB_DLBWP=%d format_found=%d\n", @@ -5405,7 +5410,7 @@ uint8_t nr_dci_decoding_procedure(int s, uint16_t pdcch_DMRS_scrambling_id = pdcch_vars2->coreset[p].pdcchDMRSScramblingID; uint64_t coreset_freq_dom = pdcch_vars2->coreset[p].frequencyDomainResources; int coreset_time_dur = pdcch_vars2->coreset[p].duration; - uint16_t coreset_nbr_rb; + uint16_t coreset_nbr_rb=0; for (int i = 0; i < 45; i++) { // this loop counts each bit of the bit map coreset_freq_dom, and increments nbr_RB_coreset for each bit set to '1' if (((coreset_freq_dom & 0x1FFFFFFFFFFF) >> i) & 0x1) coreset_nbr_rb++; @@ -5414,10 +5419,10 @@ uint8_t nr_dci_decoding_procedure(int s, // coreset_time_dur,coreset_nbr_rb, NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; t_nrPolar_paramsPtr *nrPolar_params = &ue->nrPolar_params; - uint8_t mi;// = get_mi(&ue->frame_parms, nr_tti_rx); + //uint8_t mi;// = get_mi(&ue->frame_parms, nr_tti_rx); - uint8_t tmode = ue->transmission_mode[eNB_id]; - uint8_t frame_type = frame_parms->frame_type; + //uint8_t tmode = ue->transmission_mode[eNB_id]; + //uint8_t frame_type = frame_parms->frame_type; uint8_t format_0_0_1_0_size_bits = 0, format_0_0_1_0_size_bytes = 0; //FIXME uint8_t format_0_1_1_1_size_bits = 0, format_0_1_1_1_size_bytes = 0; //FIXME @@ -5508,7 +5513,7 @@ uint8_t nr_dci_decoding_procedure(int s, css_dci_format,(1<current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params, crc_scrambled_values, aggregationLevel, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5542,7 +5547,7 @@ uint8_t nr_dci_decoding_procedure(int s, #endif // for aggregation level 'aggregationLevelSFI'. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params, crc_scrambled_values, aggregationLevelSFI, cformat2_0, uformat0_0_and_1_0, format_2_0_size_bits, format_2_0_size_bytes, &dci_cnt, @@ -5572,7 +5577,7 @@ uint8_t nr_dci_decoding_procedure(int s, #endif // for aggregation level 'aggregationLevelSFI'. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params, crc_scrambled_values, aggregationLevel, cformat2_1, uformat0_0_and_1_0, format_2_1_size_bits, format_2_1_size_bytes, &dci_cnt, @@ -5602,7 +5607,7 @@ uint8_t nr_dci_decoding_procedure(int s, #endif // for aggregation level 'aggregationLevelSFI'. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params, crc_scrambled_values, aggregationLevel, cformat2_2, uformat0_0_and_1_0, format_2_2_size_bits, format_2_2_size_bytes, &dci_cnt, @@ -5632,7 +5637,7 @@ uint8_t nr_dci_decoding_procedure(int s, #endif // for aggregation level 'aggregationLevelSFI'. The number of candidates (nrofCandidates-SFI) will be calculated in function nr_dci_decoding_procedure0 old_dci_cnt = dci_cnt; - nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params,mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 1, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms, nrPolar_params, crc_scrambled_values, aggregationLevel, cformat2_3, uformat0_0_and_1_0, format_2_3_size_bits, format_2_3_size_bytes, &dci_cnt, @@ -5667,7 +5672,7 @@ uint8_t nr_dci_decoding_procedure(int s, css_dci_format,(1<current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, crc_scrambled_values, aggregationLevel, cformat0_0_and_1_0, uformat0_0_and_1_0, format_0_0_1_0_size_bits, format_0_0_1_0_size_bytes, &dci_cnt, @@ -5699,7 +5704,7 @@ uint8_t nr_dci_decoding_procedure(int s, css_dci_format,(1<current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, mi, + nr_dci_decoding_procedure0(s,p,coreset_time_dur,coreset_nbr_rb,pdcch_vars, 0, nr_tti_rx, dci_alloc, eNB_id, ue->current_thread_id[nr_tti_rx], frame_parms,nrPolar_params, crc_scrambled_values, aggregationLevel, cformat0_0_and_1_0, uformat0_1_and_1_1, format_0_1_1_1_size_bits, format_0_1_1_1_size_bytes, &dci_cnt, diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c index 86959ee66d..72c575d49f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c @@ -7027,12 +7027,12 @@ int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, * Note only format0_0 and format1_0 are implemented */ - uint8_t harq_pid=0; + //uint8_t harq_pid=0; uint8_t frame_type=frame_parms->frame_type; - uint8_t tpmi=0; - NR_UE_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; - NR_DL_UE_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; - NR_UE_ULSCH_t *ulsch0=NULL,*ulsch1=NULL; + //uint8_t tpmi=0; + NR_UE_DLSCH_t *dlsch0=NULL;//*dlsch1=NULL; + NR_DL_UE_HARQ_t *dlsch0_harq=NULL;//*dlsch1_harq=NULL; + NR_UE_ULSCH_t *ulsch0=NULL;//*ulsch1=NULL; NR_DCI_INFO_EXTRACTED_t *ptr_nr_dci_info_extracted = nr_dci_info_extracted; @@ -7046,8 +7046,8 @@ int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, - uint8_t dci_fields_sizes_format[NBR_NR_DCI_FIELDS] ={0}; - for (int m=0; mactive = 0; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index 095832128c..d64c0e916b 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -144,7 +144,7 @@ char prefix_string[2][9] = {"NORMAL","EXTENDED"}; int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) { - int32_t sync_pos, sync_pos2, k_ssb, N_ssb_crb, sync_pos_slot; + int32_t sync_pos, sync_pos2, sync_pos_slot; // k_ssb, N_ssb_crb, int32_t metric_fdd_ncp=0; uint8_t phase_fdd_ncp; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 11a1d54990..d98d866271 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -648,7 +648,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, for (i=0; i<16; i++){ printf("unscrambling demod_pbch_e[%d] r = %2.3f i = %2.3f\n", i<<1 , demod_pbch_e[i<<1], demod_pbch_e[(i<<1)+1]);} //#endif - uint32_t pbch_out; +// uint32_t pbch_out; //polar decoding de-rate matching t_nrPolar_paramsPtr nrPolar_params = NULL, currentPtr = NULL; nr_polar_init(&nrPolar_params, @@ -673,7 +673,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_PAYLOAD_BITS,1); //payload deinterleaving - uint32_t in=0, out=0; + //uint32_t in=0; + uint32_t out=0; for (int i=0; i<32; i++) { out |= ((nr_ue_pbch_vars->pbch_a_interleaved>>i)&1)<<(pbch_deinterleaving_pattern[i]); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 8966bbb821..6048c741de 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -89,7 +89,51 @@ fifo_dump_emos_UE emos_dump_UE; extern double cpuf; +int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, + uint32_t frame, + uint8_t nr_tti_rx, + uint8_t eNB_id, + MIMO_mode_t mimo_mode, + uint32_t high_speed_flag, + uint8_t is_secondary_ue, + int nb_coreset_active, + uint16_t symbol_mon, + NR_SEARCHSPACE_TYPE_t searchSpaceType); +uint8_t nr_dci_decoding_procedure(int s, + int p, + PHY_VARS_NR_UE *ue, + NR_DCI_ALLOC_t *dci_alloc, + NR_SEARCHSPACE_TYPE_t searchSpacetype, + int16_t eNB_id, + uint8_t nr_tti_rx, + uint8_t dci_fields_sizes_cnt[MAX_NR_DCI_DECODED_SLOT][NBR_NR_DCI_FIELDS][NBR_NR_FORMATS], + uint16_t n_RB_ULBWP, + uint16_t n_RB_DLBWP, + crc_scrambled_t *crc_scrambled, + format_found_t *format_found, + uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES]); + +int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, + uint8_t eNB_id, + int frame, + uint8_t nr_tti_rx, + uint32_t dci_pdu[4], + uint16_t rnti, + uint8_t dci_length, + NR_DCI_format_t dci_format, + NR_UE_PDCCH *pdcch_vars, + NR_UE_PDSCH *pdsch_vars, + NR_UE_DLSCH_t **dlsch, + NR_UE_ULSCH_t *ulsch, + NR_DL_FRAME_PARMS *frame_parms, + PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, + uint8_t beamforming_mode, + uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS], + uint16_t n_RB_ULBWP, + uint16_t n_RB_DLBWP, + uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES], + NR_DCI_INFO_EXTRACTED_t *nr_dci_info_extracted); #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706) extern uint32_t downlink_frequency[MAX_NUM_CCs][4]; @@ -3155,7 +3199,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * nr_tti_rx,nb_searchspace_total); #endif // p in TS 38.212 Subclause 10.1, for each active BWP the UE can deal with 3 different CORESETs (including coresetId 0 for common search space) - int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; + //int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; uint8_t dci_cnt=0; // this table contains 56 (NBR_NR_DCI_FIELDS) elements for each dci field and format described in TS 38.212. Each element represents the size in bits for each dci field //uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {0}; @@ -3191,7 +3235,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * * To be implemented LATER !!! */ //int _offset,_index,_M; - int searchSpace_id = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceId; + //int searchSpace_id = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceId; /* * The following code has been removed as it is handled by higher layers (fapi) if (searchSpace_id == 0){ // Implementing TS 38.213 subclause 13, UE procedure for monitoring Type0-PDCCH common search space @@ -3221,16 +3265,16 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * // the searchSpace indicates that we need to monitor PDCCH in current nr_tti_rx // get the parameters describing the current SEARCHSPACE // the CORESET id applicable to the current SearchSpace - int searchSpace_coreset_id = pdcch_vars2->searchSpace[nb_searchspace_active].controlResourceSetId; + //int searchSpace_coreset_id = pdcch_vars2->searchSpace[nb_searchspace_active].controlResourceSetId; // FIXME this variable is a bit string (14 bits) identifying every OFDM symbol in a slot. // at the moment we will not take into consideration this variable and we will consider that the OFDM symbol offset is always the first OFDM in a symbol uint16_t symbol_within_slot_mon = pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSymbolWithinSlot; // get the remaining parameters describing the current SEARCHSPACE: // FIXME! To be defined where we get this information from - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1; - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L2 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel2; - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L4 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel4; - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L8 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel8; - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16; + //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1; + //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L2 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel2; + //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L4 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel4; + //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L8 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel8; + //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16; // FIXME! A table of five enum elements // searchSpaceType indicates whether this is a common search space or a UE-specific search space //int searchSpaceType = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceType.type; @@ -3531,8 +3575,6 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * //printf(">>> example mcs=%d\n",nr_dci_info_extracted.mcs); //printf(">>> calling MAC with dl_indication DCI_IND\n"); - - // TODO: check where should we send up this message. ue->dl_indication.dci_ind=&ue->dci_ind; ue->if_inst->dl_indication(&ue->dl_indication); @@ -3764,7 +3806,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * #ifdef DEBUG_PHY_PROC LOG_D(PHY,"[UE %d][PUSCH] Frame %d nr_tti_rx %d: Found cba rnti %x, format 0, dci_cnt %d\n", ue->Mod_id,frame_rx,nr_tti_rx,dci_alloc_rx[i].rnti,i); - /* + if (((frame_rx%100) == 0) || (frame_rx < 20)) dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); @@ -4022,6 +4064,7 @@ void copy_harq_proc_struct(NR_DL_UE_HARQ_t *harq_processes_dest, NR_DL_UE_HARQ_t memcpy(harq_ack_dest, current_harq_ack, sizeof(nr_harq_status_t)); }*/ +#if 0 void ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB_id, PDSCH_t pdsch, NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1, int s0, int s1, int abstraction_flag) { int nr_tti_rx = proc->nr_tti_rx; @@ -4110,6 +4153,8 @@ void ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB_id } // CRNTI active } } +#endif + #if 0 void process_rar(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB_id, runmode_t mode, int abstraction_flag) { @@ -5441,16 +5486,16 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode, relaying_type_t r_type) { - int l,l2; - int pilot1; - int pmch_flag=0; + //int l,l2; + //int pilot1; + //int pmch_flag=0; int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; proc->decoder_switch = 0; //int counter_decoder = 0; - uint8_t next1_thread_id = ue->current_thread_id[nr_tti_rx]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[nr_tti_rx]+1); - uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1); + //uint8_t next1_thread_id = ue->current_thread_id[nr_tti_rx]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[nr_tti_rx]+1); + //uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1); #if 0 VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c index 326410be73..20a9f76a9f 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c @@ -48,6 +48,60 @@ #endif +int8_t nr_ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe); +uint8_t is_cqi_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id); +uint8_t is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id); +/* +void nr_generate_pucch0(int32_t **txdataF, + NR_DL_FRAME_PARMS *frame_parms, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + int16_t amp, + int nr_tti_tx, + uint8_t mcs, + uint8_t nrofSymbols, + uint8_t startingSymbolIndex, + uint16_t startingPRB); + +void nr_generate_pucch1(int32_t **txdataF, + NR_DL_FRAME_PARMS *frame_parms, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint64_t payload, + int16_t amp, + int nr_tti_tx, + uint8_t nrofSymbols, + uint8_t startingSymbolIndex, + uint16_t startingPRB, + uint16_t startingPRB_intraSlotHopping, + uint8_t timeDomainOCC, + uint8_t nr_bit); + +void nr_generate_pucch2(int32_t **txdataF, + NR_DL_FRAME_PARMS *frame_parms, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint64_t payload, + int16_t amp, + int nr_tti_tx, + uint8_t nrofSymbols, + uint8_t startingSymbolIndex, + uint8_t nrofPRB, + uint16_t startingPRB, + uint8_t nr_bit); + +void nr_generate_pucch3_4(int32_t **txdataF, + NR_DL_FRAME_PARMS *frame_parms, + pucch_format_nr_t fmt, + PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, + uint64_t payload, + int16_t amp, + int nr_tti_tx, + uint8_t nrofSymbols, + uint8_t startingSymbolIndex, + uint8_t nrofPRB, + uint16_t startingPRB, + uint8_t nr_bit, + uint8_t occ_length_format4, + uint8_t occ_index_format4); +*/ /**************** variables **************************************/ diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 9b79f35231..da6d844cb7 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -977,9 +977,9 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( uint8_t time_domain_ind, long dmrs_typeA_pos ){ - uint8_t k_offset; - uint8_t sliv_S; - uint8_t sliv_L; + uint8_t k_offset=0; + uint8_t sliv_S=0; + uint8_t sliv_L=0; uint8_t table_5_1_2_1_1_2_time_dom_res_alloc_A[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?12:11}, // row index 1 {0,(dmrs_typeA_pos == 2)?2:3, (dmrs_typeA_pos == 2)?10:9}, // row index 2 @@ -1108,6 +1108,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( // k_offset = table_5_1_2_1_1_5_time_dom_res_alloc_C[nr_pdci_info_extracted->time_dom_resource_assignment][0]; // sliv_S = table_5_1_2_1_1_5_time_dom_res_alloc_C[nr_pdci_info_extracted->time_dom_resource_assignment][1]; // sliv_L = table_5_1_2_1_1_5_time_dom_res_alloc_C[nr_pdci_info_extracted->time_dom_resource_assignment][2]; + dlsch_config_pdu->frame_offset = k_offset; dlsch_config_pdu->number_symbols = sliv_L; dlsch_config_pdu->start_symbol = sliv_S; } /* @@ -1120,6 +1121,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( // k_offset = table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][0]; // sliv_S = table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][1]; // sliv_L = table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][2]; + ulsch_config_pdu->frame_offset = k_offset; ulsch_config_pdu->number_symbols = sliv_L; ulsch_config_pdu->start_symbol = sliv_S; } diff --git a/targets/RT/USER/nr-uesoftmodem.c b/targets/RT/USER/nr-uesoftmodem.c index 54d169a171..f8f37ef861 100644 --- a/targets/RT/USER/nr-uesoftmodem.c +++ b/targets/RT/USER/nr-uesoftmodem.c @@ -123,7 +123,7 @@ uint32_t downlink_frequency[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; -static char *conf_config_file_name = NULL; +//static char *conf_config_file_name = NULL; #if defined(ENABLE_ITTI) static char *itti_dump_file = NULL; #endif @@ -171,7 +171,7 @@ int codingw = 0; int fepw = 0; int rx_input_level_dBm; -static int online_log_messages=0; +//static int online_log_messages=0; #ifdef XFORMS extern int otg_enabled; static char do_forms=0; @@ -410,7 +410,7 @@ void exit_fun(const char* s) { void reset_stats(FL_OBJECT *button, long arg) { - int i,j,k; + //int i,j,k; /*PHY_VARS_eNB *phy_vars_eNB = PHY_vars_eNB_g[0][0]; for (i=0; i Date: Fri, 5 Oct 2018 17:39:34 +0200 Subject: [PATCH 110/114] NR PDCCH development code clean up --- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 2793 +----- openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c | 9046 ------------------- 2 files changed, 3 insertions(+), 11836 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 2f44497d04..497a44b201 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -63,66 +63,6 @@ //extern uint16_t phich_reg[MAX_NUM_PHICH_GROUPS][3]; //extern uint16_t pcfich_reg[4]; -/*uint32_t check_phich_reg(NR_DL_FRAME_PARMS *frame_parms,uint32_t kprime,uint8_t lprime,uint8_t mi) -{ - - uint16_t i; - uint16_t Ngroup_PHICH = (frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)/48; - uint16_t mprime; - uint16_t *pcfich_reg = frame_parms->pcfich_reg; - - if ((lprime>0) && (frame_parms->Ncp==0) ) - return(0); - - // printf("check_phich_reg : mi %d\n",mi); - - // compute REG based on symbol - if ((lprime == 0)|| - ((lprime==1)&&(frame_parms->nb_antenna_ports_eNB == 4))) - mprime = kprime/6; - else - mprime = kprime>>2; - - // check if PCFICH uses mprime - if ((lprime==0) && - ((mprime == pcfich_reg[0]) || - (mprime == pcfich_reg[1]) || - (mprime == pcfich_reg[2]) || - (mprime == pcfich_reg[3]))) { -#ifdef DEBUG_DCI_ENCODING - printf("[PHY] REG %d allocated to PCFICH\n",mprime); -#endif - return(1); - } - - // handle Special subframe case for TDD !!! - - // printf("Checking phich_reg %d\n",mprime); - if (mi > 0) { - if (((frame_parms->phich_config_common.phich_resource*frame_parms->N_RB_DL)%48) > 0) - Ngroup_PHICH++; - - if (frame_parms->Ncp == 1) { - Ngroup_PHICH<<=1; - } - - - - for (i=0; iphich_reg[i][0]) || - (mprime == frame_parms->phich_reg[i][1]) || - (mprime == frame_parms->phich_reg[i][2])) { -#ifdef DEBUG_DCI_ENCODING - printf("[PHY] REG %d (lprime %d) allocated to PHICH\n",mprime,lprime); -#endif - return(1); - } - } - } - - return(0); -}*/ - uint16_t extract_crc(uint8_t *dci,uint8_t dci_len) { @@ -432,423 +372,8 @@ symbol 0 | ... bundle 3 bundle 6 } } -#if 0 -void nr_pdcch_demapping(uint16_t *llr, uint16_t *wbar, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t coreset_time_dur, uint32_t coreset_nbr_rb) { -/* - * LLR contains the PDCCH for the coreset_time_dur symbols in the following sequence: - * - * The REGs have to be numbered in increasing order in a time-first manner, - * starting with 0 for the first OFDM symbol and the lowest-numbered resource - * block in the control resource set - * - * | ... | ... | ... | - * | REG 3 | REG 4 | REG 5 | - * | REG 0 | REG 1 | REG 2 | - * | symbol0 | symbol1 | symbol2 | - * - * ................. - * ___________REG 1+2l - * ___________REG 1+l - * symbol 1___REG 1 - * ................. - * ___________REG 2l - * ___________REG l - * symbol 0___REG 0 - * - * WBAR will contain the PDCCH organized in REGx where x will be consecutive: - * REG 0 - * REG 1 - * REG 2 - * ... - * REG l - * REG 1+l - * REG 2+l - * ... - * - */ - - uint32_t m,i,k,l; - uint32_t num_re_pdcch = 12 * coreset_nbr_rb; - i=0; - m=0; - for (k=0; k k,l=(%d,%d) DM-RS PDCCH signal\n",k,l); - #endif - } else { - if ((m%9)==0 && (m !=0) && (l==0)) { - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_demapping)-> we have modified m: old_m=%d, new_m=%d\n", - m,m+(9*(coreset_time_dur-1))); - #endif - m=m+(9*(coreset_time_dur-1)); // to avoid overwriting m+1 when a whole REG has been completed - } - wbar[(l*9)+m] = llr[(l*9*coreset_nbr_rb)+i]; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_demapping)-> k,l=(%d,%d) i,m=(%d,%d) REG (%d) > wbar(%d,%d) \t llr[%d]->wbar[%d]\n", - k,l,i,m, (m+(l*9)) / 9, *(char*) &wbar[m+(l*9)], *(1 + (char*) &wbar[m+(l*9)]), - (l*9*coreset_nbr_rb)+i,m+(l*9)); - #endif - if (l==coreset_time_dur-1) { - i++; - m++; - } - } - } - } -} -#endif //0 #endif -#if 0 -void pdcch_demapping(uint16_t *llr,uint16_t *wbar,NR_DL_FRAME_PARMS *frame_parms,uint8_t num_pdcch_symbols,uint8_t mi) -{ - - uint32_t i, lprime; - uint16_t kprime,kprime_mod12,mprime,symbol_offset,tti_offset,tti_offset0; - int16_t re_offset,re_offset0; - - // This is the REG allocation algorithm from 36-211, second part of Section 6.8.5 - - int Msymb2; - - switch (frame_parms->N_RB_DL) { - case 100: - Msymb2 = Msymb; - break; - - case 75: - Msymb2 = 3*Msymb/4; - break; - - case 50: - Msymb2 = Msymb>>1; - break; - - case 25: - Msymb2 = Msymb>>2; - break; - - case 15: - Msymb2 = Msymb*15/100; - break; - - case 6: - Msymb2 = Msymb*6/100; - break; - - default: - Msymb2 = Msymb>>2; - break; - } - - mprime=0; - - - re_offset = 0; - re_offset0 = 0; // counter for symbol with pilots (extracted outside!) - - for (kprime=0; kprimeN_RB_DL*12; kprime++) { - for (lprime=0; lprimeN_RB_DL*12*lprime; - - tti_offset = symbol_offset + re_offset; - tti_offset0 = symbol_offset + re_offset0; - - // if REG is allocated to PHICH, skip it - if (check_phich_reg(frame_parms,kprime,lprime,mi) == 1) { - // printf("dci_demapping : skipping REG %d (RE %d)\n",(lprime==0)?kprime/6 : kprime>>2,kprime); - if ((lprime == 0)&&((kprime%6)==0)) - re_offset0+=4; - } else { // not allocated to PHICH/PCFICH - // printf("dci_demapping: REG %d\n",(lprime==0)?kprime/6 : kprime>>2); - if (lprime == 0) { - // first symbol, or second symbol+4 TX antennas skip pilots - kprime_mod12 = kprime%12; - - if ((kprime_mod12 == 0) || (kprime_mod12 == 6)) { - // kprime represents REG - - for (i=0; i<4; i++) { - wbar[mprime] = llr[tti_offset0+i]; -#ifdef DEBUG_DCI_DECODING -// LOG_I(PHY,"PDCCH demapping mprime %d.%d <= llr %d (symbol %d re %d) -> (%d,%d)\n",mprime/4,i,tti_offset0+i,symbol_offset,re_offset0,*(char*)&wbar[mprime],*(1+(char*)&wbar[mprime])); -#endif - mprime++; - re_offset0++; - } - } - } else if ((lprime==1)&&(frame_parms->nb_antenna_ports_eNB == 4)) { - // LATER!!!! - } else { // no pilots in this symbol - kprime_mod12 = kprime%12; - - if ((kprime_mod12 == 0) || (kprime_mod12 == 4) || (kprime_mod12 == 8)) { - // kprime represents REG - for (i=0; i<4; i++) { - wbar[mprime] = llr[tti_offset+i]; -#ifdef DEBUG_DCI_DECODING -// LOG_I(PHY,"PDCCH demapping mprime %d.%d <= llr %d (symbol %d re %d) -> (%d,%d)\n",mprime/4,i,tti_offset+i,symbol_offset,re_offset+i,*(char*)&wbar[mprime],*(1+(char*)&wbar[mprime])); -#endif - mprime++; - } - } // is representative - } // no pilots case - } // not allocated to PHICH/PCFICH - - // Stop when all REGs are copied in - if (mprime>=Msymb2) - break; - } //lprime loop - - re_offset++; - - } // kprime loop -} -#endif //0 - -//static uint16_t wtemp_rx[Msymb]; - -#if 0 -#ifdef NR_PDCCH_DCI_RUN -void nr_pdcch_deinterleaving(NR_DL_FRAME_PARMS *frame_parms, uint16_t *z, - uint16_t *wbar, uint8_t coreset_time_dur, uint8_t reg_bundle_size_L, - uint8_t coreset_interleaver_size_R, uint8_t n_shift, uint32_t coreset_nbr_rb) -{ -/* - * This function will perform deinterleaving described in 38.211 Section 7.3.2.2 - * coreset_freq_dom (bit map 45 bits: each bit indicates 6 RB in CORESET -> 1 bit MSB indicates PRB 0..6 are part of CORESET) - * coreset_time_dur (1,2,3) - * coreset_CCE_REG_mapping_type (interleaved, non-interleaved) - * reg_bundle_size (2,3,6) - */ -#ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_deinterleaving)-> coreset_nbr_rb=(%lld), reg_bundle_size_L=(%d), coreset_interleaver_size_R=(%d), n_shift=(%d)\n", - coreset_nbr_rb,reg_bundle_size_L,coreset_interleaver_size_R,n_shift); -#endif -/* - * First verify that CORESET is interleaved or not interleaved depending on parameter cce-REG-MappingType - * if non-interleaved then do nothing: wbar table stays as it is (if REG bundle size is set to 0 by higher layer, then we consider that there is no interleaving) - */ - int coreset_interleaved = 1; - if (reg_bundle_size_L==0) coreset_interleaved=0; -/* - * if interleaved then do this: wbar table has bundles interleaved. We have to de-interleave then - * following procedure described in 38.211 Section 7.3.2.2: - */ - int c=0 ,r=-1; - uint32_t bundle_id, bundle_interleaved, k, l, i=0; - uint32_t coreset_C = (uint32_t)(coreset_nbr_rb * coreset_time_dur/ (coreset_interleaver_size_R*reg_bundle_size_L)); - //uint16_t *wptr; - //wptr = &wtemp_rx[0]; - //z = &wtemp_rx[0]; - bundle_id=0; - for (k=0 ; k<9*coreset_nbr_rb*coreset_time_dur; k++){ - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_deinterleaving)-> k=%d \t coreset_interleaved=%d reg_bundle_size_L=%d coreset_C=%d coreset_interleaver_R=%d", - k,coreset_interleaved,reg_bundle_size_L, coreset_C,coreset_interleaver_size_R); - #endif - if (k%(9*reg_bundle_size_L)==0) { - // calculate offset properly - if (r==coreset_interleaver_size_R-1) { - //if (bundle_id>=(c+1)*coreset_interleaver_size_R) { - c++; - r=0; - } else { - r++; - } - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t --> time to modify bundle_interleaved and bundle_id --> r=%d c=%d\n",r,c); - #endif - bundle_id=c*coreset_interleaver_size_R+r; - bundle_interleaved=(r*coreset_C+c+n_shift)%(coreset_nbr_rb * coreset_time_dur/reg_bundle_size_L); - } - if (coreset_interleaved == 1){ - //wptr[i+(bundle_interleaved-bundle_id)*9*reg_bundle_size_L]=wbar[i]; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t\t\t\t wptr[%d] = (%d,%d) <-> wbar[%d]",i, *(char*) &wbar[i], *(1 + (char*) &wbar[i]),i+(bundle_interleaved-bundle_id)*9*reg_bundle_size_L); - #endif - z[i]=wbar[i+(bundle_interleaved-bundle_id)*9*reg_bundle_size_L]; - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t\t bundle_id = %d \t bundle_interleaved = %d (r=%d, c=%d)\n",bundle_id,bundle_interleaved,r,c); - #endif - i++; - } else { - z[i]=wbar[i]; - i++; - } - //bundle_id=c*coreset_interleaver_size_R+r; - } -} -#endif -#endif //0 - - - - - -#if 0 - -void pdcch_deinterleaving(NR_DL_FRAME_PARMS *frame_parms,uint16_t *z, uint16_t *wbar,uint8_t number_pdcch_symbols,uint8_t mi) -{ - - uint16_t *wptr,*zptr,*wptr2; - - uint16_t Mquad=get_nquad(number_pdcch_symbols,frame_parms,mi); - uint32_t RCC = (Mquad>>5), ND; - uint32_t row,col,Kpi,index; - int32_t i,k; - - - // printf("Mquad %d, RCC %d\n",Mquad,RCC); - - if (!z) { - printf("dci.c: pdcch_deinterleaving: FATAL z is Null\n"); - return; - } - - // undo permutation - for (i=0; iNid_cell)%Mquad)<<2]; - wptr2 = &wbar[i<<2]; - - wptr[0] = wptr2[0]; - wptr[1] = wptr2[1]; - wptr[2] = wptr2[2]; - wptr[3] = wptr2[3]; - /* - printf("pdcch_deinterleaving (%p,%p): quad %d (%d) -> (%d,%d %d,%d %d,%d %d,%d)\n",wptr,wptr2,i,(i+frame_parms->Nid_cell)%Mquad, - ((char*)wptr2)[0], - ((char*)wptr2)[1], - ((char*)wptr2)[2], - ((char*)wptr2)[3], - ((char*)wptr2)[4], - ((char*)wptr2)[5], - ((char*)wptr2)[6], - ((char*)wptr2)[7]); - */ - - } - - if ((Mquad&0x1f) > 0) - RCC++; - - Kpi = (RCC<<5); - ND = Kpi - Mquad; - - k=0; - - for (col=0; col<32; col++) { - index = bitrev_cc_dci[col]; - - for (row=0; row=ND) { - - - - wptr = &wtemp_rx[k<<2]; - zptr = &z[(index-ND)<<2]; - - zptr[0] = wptr[0]; - zptr[1] = wptr[1]; - zptr[2] = wptr[2]; - zptr[3] = wptr[3]; - - /* - printf("deinterleaving ; k %d, index-Nd %d => (%d,%d,%d,%d,%d,%d,%d,%d)\n",k,(index-ND), - ((int8_t *)wptr)[0], - ((int8_t *)wptr)[1], - ((int8_t *)wptr)[2], - ((int8_t *)wptr)[3], - ((int8_t *)wptr)[4], - ((int8_t *)wptr)[5], - ((int8_t *)wptr)[6], - ((int8_t *)wptr)[7]); - */ - k++; - } - - index+=32; - - } - } - - for (i=0; i (%d,%d,%d,%d,%d,%d,%d,%d)\n",i, - ((int8_t *)zptr)[0], - ((int8_t *)zptr)[1], - ((int8_t *)zptr)[2], - ((int8_t *)zptr)[3], - ((int8_t *)zptr)[4], - ((int8_t *)zptr)[5], - ((int8_t *)zptr)[6], - ((int8_t *)zptr)[7]); - */ - } - -} -#endif //0 - -#if 0 -int32_t pdcch_qpsk_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, - int32_t **rxdataF_comp, - int32_t **rxdataF_comp_i, - int32_t **rho_i, - int16_t *pdcch_llr16, - int16_t *pdcch_llr8in, - uint8_t symbol) -{ - - int16_t *rxF=(int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *rxF_i=(int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *rho=(int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *llr128; - int32_t i; - char *pdcch_llr8; - int16_t *pdcch_llr; - pdcch_llr8 = (char *)&pdcch_llr8in[symbol*frame_parms->N_RB_DL*12]; - pdcch_llr = &pdcch_llr16[symbol*frame_parms->N_RB_DL*12]; - - // printf("dlsch_qpsk_qpsk: symbol %d\n",symbol); - - llr128 = (int16_t*)pdcch_llr; - - if (!llr128) { - printf("dlsch_qpsk_qpsk_llr: llr is null, symbol %d\n",symbol); - return -1; - } - - qpsk_qpsk(rxF, - rxF_i, - llr128, - rho, - frame_parms->N_RB_DL*12); - - //prepare for Viterbi which accepts 8 bit, but prefers 4 bit, soft input. - for (i=0; i<(frame_parms->N_RB_DL*24); i++) { - if (*pdcch_llr>7) - *pdcch_llr8=7; - else if (*pdcch_llr<-8) - *pdcch_llr8=-8; - else - *pdcch_llr8 = (char)(*pdcch_llr); - - pdcch_llr++; - pdcch_llr8++; - } - - return(0); -} -#endif //0 - #ifdef NR_PDCCH_DCI_RUN int32_t nr_pdcch_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, char *pdcch_llr, uint8_t symbol,uint32_t coreset_nbr_rb) { @@ -993,117 +518,7 @@ __m128i mmtmpPD0,mmtmpPD1,mmtmpPD2,mmtmpPD3; #elif defined(__arm__) #endif -/* -void pdcch_dual_stream_correlation(NR_DL_FRAME_PARMS *frame_parms, - uint8_t symbol, - int32_t **dl_ch_estimates_ext, - int32_t **dl_ch_estimates_ext_i, - int32_t **dl_ch_rho_ext, - uint8_t output_shift) -{ - uint16_t rb; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128,*dl_ch128i,*dl_ch_rho128; -#elif defined(__arm__) - -#endif - uint8_t aarx; - - // printf("dlsch_dual_stream_correlation: symbol %d\n",symbol); - - - for (aarx=0; aarxnb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch128i = (__m128i *)&dl_ch_estimates_ext_i[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch_rho128 = (__m128i *)&dl_ch_rho_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - -#elif defined(__arm__) - -#endif - - for (rb=0; rbN_RB_DL; rb++) { - // multiply by conjugated channel -#if defined(__x86_64__) || defined(__i386__) - mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128i[0]); - // print_ints("re",&mmtmpPD0); - - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpPD1); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128i[0]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - // print_ints("re(shift)",&mmtmpPD0); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - // print_ints("im(shift)",&mmtmpPD1); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - // print_ints("c0",&mmtmpPD2); - // print_ints("c1",&mmtmpPD3); - dl_ch_rho128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - - //print_shorts("rx:",dl_ch128_2); - //print_shorts("ch:",dl_ch128); - //print_shorts("pack:",rho128); - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],dl_ch128i[1]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128i[1]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - - dl_ch_rho128[1] =_mm_packs_epi32(mmtmpPD2,mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+1); - //print_shorts("ch:",dl_ch128+1); - //print_shorts("pack:",rho128+1); - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128i[2]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128i[2]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - dl_ch_rho128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+2); - //print_shorts("ch:",dl_ch128+2); - //print_shorts("pack:",rho128+2); - - dl_ch128+=3; - dl_ch128i+=3; - dl_ch_rho128+=3; - - -#elif defined(__arm__) - -#endif - } - } -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif - -} -*/ void pdcch_detection_mrc_i(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, @@ -1449,248 +864,6 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, } #endif -#ifdef NR_PDCCH_DCI_RUN_bis -// this function is just a second implementation of nr_pdcch_extract_rbs_single -// the code modification is minimum but it can be slower in processing time -// to be removed - -void nr_pdcch_extract_rbs_single_bis(int32_t **rxdataF, int32_t **dl_ch_estimates, - int32_t **rxdataF_ext, int32_t **dl_ch_estimates_ext, uint8_t symbol, - uint32_t high_speed_flag, NR_DL_FRAME_PARMS *frame_parms, uint64_t coreset_freq_dom, uint32_t coreset_nbr_rb, uint32_t n_BWP_start) { - - uint16_t rb, nb_rb = 0; - uint8_t i, j, aarx; - int32_t *dl_ch0, *dl_ch0_ext, *rxF, *rxF_ext; - int nushiftmod3 = frame_parms->nushift % 3; - uint8_t symbol_mod; - - symbol_mod = (symbol >= (7 - frame_parms->Ncp)) ? symbol - (7 - frame_parms->Ncp) : symbol; -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY, "extract_rbs_single: symbol_mod %d\n",symbol_mod); -#endif - for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { - if (high_speed_flag == 1){ - dl_ch0 = &dl_ch_estimates[aarx][5 + (symbol * (frame_parms->ofdm_symbol_size))]; - printf("\t\t### in function nr_pdcch_extract_rbs_single(), \t ### dl_ch0 = &dl_ch_estimates[aarx = (%d) ][5 + (symbol * (frame_parms->ofdm_symbol_size)) = (%d)]\n", - aarx,5 + (symbol * (frame_parms->ofdm_symbol_size))); - } else { - dl_ch0 = &dl_ch_estimates[aarx][5]; - printf("\t\t### in function nr_pdcch_extract_rbs_single(), \t ### dl_ch0 = &dl_ch_estimates[aarx = (%d)][5]\n",aarx); - } - dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol * (frame_parms->N_RB_DL * 12)]; - printf("\t\t### in function nr_pdcch_extract_rbs_single(), \t ### dl_ch0_ext = &dl_ch_estimates_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 12) = (%d)]\n", - aarx,symbol * (frame_parms->N_RB_DL * 12)); - rxF_ext = &rxdataF_ext[aarx][symbol * (frame_parms->N_RB_DL * 12)]; - printf("\t\t### in function nr_pdcch_extract_rbs_single(), \t ### rxF_ext = &rxdataF_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 12) = (%d)]\n", - aarx,symbol * (frame_parms->N_RB_DL * 12)); - rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + (symbol * (frame_parms->ofdm_symbol_size)))]; - printf("\t\t### in function nr_pdcch_extract_rbs_single(), \t ### rxF = &rxdataF[aarx = (%d)][(frame_parms->first_carrier_offset + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n", - aarx,(frame_parms->first_carrier_offset + (symbol * (frame_parms->ofdm_symbol_size)))); - printf("\t\t ###### in function pdcch_extract_rbs_single(for symbol=%d, aarx=%d), symbol_mod=%d, nushiftmod3=%d \n",symbol,aarx,symbol_mod,nushiftmod3); - printf("\t\t ###### rxF_ext = &rxdataF_ext[aarx(%d)][symbol(%d) * (frame_parms->N_RB_DL(%d) * 12)]\n",aarx,symbol,frame_parms->N_RB_DL); - printf("\t\t ###### rxF = &rxdataF[aarx(%d)][(frame_parms->first_carrier_offset(%d) + (symbol(%d) * (frame_parms->ofdm_symbol_size(%d))))]\n", - aarx,frame_parms->first_carrier_offset,symbol,frame_parms->ofdm_symbol_size); - - if ((frame_parms->N_RB_DL & 1) == 0) { // even number of RBs - for (rb = 0; rb < frame_parms->N_RB_DL; rb++) { - printf("\t\t\t ###### rb=%d\n",rb); - if (rb == (frame_parms->N_RB_DL >> 1)) { // For second half of RBs skip DC carrier - rxF = &rxdataF[aarx][(1 + (symbol * (frame_parms->ofdm_symbol_size)))]; - printf("\t\t\t ###### if rb (%d) is half N_RB_DL, skip DC carrier -> rxF = &rxdataF[aarx(%d)][(1 + (symbol(%d) * (frame_parms->ofdm_symbol_size(%d))))\n", - rb,aarx,symbol,frame_parms->ofdm_symbol_size); - //dl_ch0++; - } - if (symbol_mod > 0) { - memcpy(dl_ch0_ext, dl_ch0, 12 * sizeof(int32_t)); - for (i = 0; i < 12; i++) { - rxF_ext[i] = rxF[i]; - } - nb_rb++; - dl_ch0_ext += 12; - rxF_ext += 12; - dl_ch0 += 12; - rxF += 12; - } else { - j = 0; - for (i = 0; i < 12; i++) { - if ((i != 1) && (i != 5) && (i != 9)) { - rxF_ext[j] = rxF[i]; - printf("\textract rb %d \t re %d => rxF_ext[%d]=(%d,%d)", rb, i, j, *(short *) &rxF_ext[j], *(1 + (short*) &rxF_ext[j])); - dl_ch0_ext[j++] = dl_ch0[i]; - printf("\t\tch %d => dl_ch0(%d,%d)\n", i, *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i])); - } - } - nb_rb++; - dl_ch0_ext += 9; - rxF_ext += 9; - dl_ch0 += 12; - rxF += 12; - } - } - } else { // Odd number of RBs - for (rb = 0; rb < frame_parms->N_RB_DL >> 1; rb++) { - printf("\t\t\t ###### rb=%d (Odd number of RBs, rb < half of band)\n",rb); - if (symbol_mod > 0) { - memcpy(dl_ch0_ext, dl_ch0, 12 * sizeof(int32_t)); - for (i = 0; i < 12; i++) - rxF_ext[i] = rxF[i]; - nb_rb++; - dl_ch0_ext += 12; - rxF_ext += 12; - dl_ch0 += 12; - rxF += 12; - } else { - j = 0; - for (i = 0; i < 12; i++) { - if ((i != 1) && (i != 5) && (i != 9)) { - rxF_ext[j] = rxF[i]; - printf("\t\t\t\t ###### extract rb %d, re %d => rxF_ext[%d]=(%d,%d) rxF[%d]=(%d,%d)", - rb,i,j,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]),i,*(short *)&rxF[i],*(1+(short*)&rxF[i])); - dl_ch0_ext[j++] = dl_ch0[i]; - printf("\t ###### extract rb %d, re %d => dl_ch0 []=(%d,%d)\n",rb,i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); - } else { - printf("\t\t\t\t ###### THIS IS a pilot rb %d \t re %d => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t this is a pilot symbol\n", - rb,i,j,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j]),i,*(short *)&rxF[i],*(1+(short*)&rxF[i])); - } - } - nb_rb++; - dl_ch0_ext += 9; - rxF_ext += 9; - dl_ch0 += 12; - rxF += 12; - } - } - // Do middle RB (around DC) - //printf("dlch_ext %d\n",dl_ch0_ext-&dl_ch_estimates_ext[aarx][0]); - if (symbol_mod == 0) { - j = 0; - for (i = 0; i < 6; i++) { - if ((i != 1) && (i != 5)) { - dl_ch0_ext[j] = dl_ch0[i]; - rxF_ext[j++] = rxF[i]; - //printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1])); - } - } - rxF = &rxdataF[aarx][((symbol * (frame_parms->ofdm_symbol_size)))]; - for (; i < 12; i++) { - if (i != 9) { - dl_ch0_ext[j] = dl_ch0[i]; - rxF_ext[j++] = rxF[(1 + i - 6)]; - //printf("**extract rb %d, re %d => (%d,%d)\n",rb,i,*(short *)&rxF_ext[j-1],*(1+(short*)&rxF_ext[j-1])); - } - } - nb_rb++; - dl_ch0_ext += 9; - rxF_ext += 9; - dl_ch0 += 12; - rxF += 7; - rb++; - } else { - for (i = 0; i < 6; i++) { - dl_ch0_ext[i] = dl_ch0[i]; - rxF_ext[i] = rxF[i]; - } - rxF = &rxdataF[aarx][((symbol * (frame_parms->ofdm_symbol_size)))]; - for (; i < 12; i++) { - dl_ch0_ext[i] = dl_ch0[i]; - rxF_ext[i] = rxF[(1 + i - 6)]; - } - nb_rb++; - dl_ch0_ext += 12; - rxF_ext += 12; - dl_ch0 += 12; - rxF += 7; - rb++; - } - for (; rb < frame_parms->N_RB_DL; rb++) { - printf("\t\t\t ###### rb=%d (Even number of RBs, rb > half of band)\n",rb); - if (symbol_mod > 0) { - memcpy(dl_ch0_ext, dl_ch0, 12 * sizeof(int32_t)); - for (i = 0; i < 12; i++) - rxF_ext[i] = rxF[i]; - nb_rb++; - dl_ch0_ext += 12; - rxF_ext += 12; - dl_ch0 += 12; - rxF += 12; - } else { - j = 0; - for (i = 0; i < 12; i++) { - if ((i != 1) && (i != 5) && (i != 9)) { - rxF_ext[j] = rxF[i]; - printf("\t\t\t\t ###### extract rb %d, re %d => rxF_ext[]=(%d,%d)",rb,i,*(short *)&rxF_ext[j],*(1+(short*)&rxF_ext[j])); - //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]; - printf("\t ###### extract rb %d, re %d => dl_ch0 []=(%d,%d)\n",rb,i,*(short *)&dl_ch0[i],*(1+(short*)&dl_ch0[i])); - } else { - printf("\t\t\t\t ###### THIS IS a RS at re %d\n",i); - } - } - nb_rb++; - dl_ch0_ext += 9; - rxF_ext += 9; - dl_ch0 += 12; - rxF += 12; - } - } - } - } - -// The function has created table rxdataF_ext with the contents of rxdataF and removing the pilots at positions 1,5,9 in every RB. -// Now we need to check the contents of rxdataF_ext and keep only the values which correspond to our CORESET depending on variables: -// - coreset_freq_dom (45 bit map) -// - n_BWP_start (first RB within the active BWP and the CORESET) - j=0; - k=0; - rxF_ext = &rxdataF_ext[aarx][(symbol * (frame_parms->N_RB_DL * 12))]; - printf("\t\t### in function nr_pdcch_extract_rbs_single(), \t ### rxF_ext = &rxdataF_ext[aarx = (%d)][n_BWP_start + (symbol * (frame_parms->N_RB_DL * 12)) = (%d)]\n", - aarx,(n_BWP_start + (symbol * (frame_parms->N_RB_DL * 12)))); - - int bitcnt_coreset_freq_dom = 1; // this variable will allow to check each bit of the 45 bitmap coreset_freq_dom. - //Eg: if bitcnt_coreset_freq_dom = 3, (46-3) we verify bit 43 starting from LSB - for (rb=0; rbN_RB_DL;rb++) { - if (rb < n_BWP_start) { - // while rb is not within CORESET, then remove values - for (i=0; i<8; i++) { - //rxF_ext[i] = 0; - j++; - } - //rxF_ext = &rxdataF_ext[aarx][(j + (symbol * (frame_parms->N_RB_DL * 12)))]; - } else if ((rb >= n_BWP_start) && (rb < (n_BWP_start + 6 * 45))) { - // rb is within CORESET, we need to verify now whether bit in coreset_freq_dom is set or not - if ((((coreset_freq_dom & 0x1FFFFFFFFFFF) >> (46 - bitcnt_coreset_freq_dom)) & 0x1)== 0){ - // if bit is 0, next 6 consecutive RBs do not belong to CORESET - bitcnt_coreset_freq_dom ++; - rb = rb + 6; - for (i=0; i<(9*6); i++) { - //rxF_ext[i] = 0; - j++; - } - //rxF_ext = &rxdataF_ext[aarx][(j + (symbol * (frame_parms->N_RB_DL * 12)))]; - } else { - // if bit is 1, next 6 consecutive RBs belong to CORESET - bitcnt_coreset_freq_dom ++; - rb = rb + 6; - for (i=0; i<(9*6); i++) { - rxF_ext[k] = rxF_ext[j]; - k++; - j++; - } - //rxF_ext = &rxdataF_ext[aarx][(j + (symbol * (frame_parms->N_RB_DL * 12)))]; - } - } else { // for the RBs that are in the upper side of the CORESET bitmap - for (i=0; i<8; i++) { - rxF_ext[k] = 0; - k++; - j++; - } - //rxF_ext = &rxdataF_ext[aarx][(j + (symbol * (frame_parms->N_RB_DL * 12)))]; - } - } -} - -#endif - void pdcch_extract_rbs_single(int32_t **rxdataF, @@ -2286,227 +1459,6 @@ void nr_pdcch_channel_compensation(int32_t **rxdataF_ext, } - -/* -void pdcch_channel_compensation(int32_t **rxdataF_ext, - int32_t **dl_ch_estimates_ext, - int32_t **rxdataF_comp, - int32_t **rho, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t symbol, - uint8_t output_shift) -{ - - uint16_t rb; -#if defined(__x86_64__) || defined(__i386__) - __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128; - __m128i *dl_ch128_2, *rho128; -#elif defined(__arm__) - -#endif - uint8_t aatx,aarx,pilots=0; - - - - -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY, "PDCCH comp: symbol %d\n",symbol); -#endif - - if (symbol==0) - pilots=1; - - for (aatx=0; aatxnb_antenna_ports_eNB; aatx++) { - //if (frame_parms->mode1_flag && aatx>0) break; //if mode1_flag is set then there is only one stream to extract, independent of nb_antenna_ports_eNB - - for (aarx=0; aarxnb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12]; - rxdataF128 = (__m128i *)&rxdataF_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - rxdataF_comp128 = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol*frame_parms->N_RB_DL*12]; -#elif defined(__arm__) - -#endif - - for (rb=0; rbN_RB_DL; rb++) { - -#if defined(__x86_64__) || defined(__i386__) - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]); - // print_ints("re",&mmtmpPD0); - - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpPD1); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[0]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - // print_ints("re(shift)",&mmtmpPD0); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - // print_ints("im(shift)",&mmtmpPD1); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - // print_ints("c0",&mmtmpPD2); - // print_ints("c1",&mmtmpPD3); - rxdataF_comp128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - // print_shorts("rx:",rxdataF128); - // print_shorts("ch:",dl_ch128); - // print_shorts("pack:",rxdataF_comp128); - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[1]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - rxdataF_comp128[1] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - - // print_shorts("rx:",rxdataF128+1); - // print_shorts("ch:",dl_ch128+1); - // print_shorts("pack:",rxdataF_comp128+1); - // multiply by conjugated channel - if (pilots == 0) { - mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,rxdataF128[2]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - rxdataF_comp128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - } - - // print_shorts("rx:",rxdataF128+2); - // print_shorts("ch:",dl_ch128+2); - // print_shorts("pack:",rxdataF_comp128+2); - - if (pilots==0) { - dl_ch128+=3; - rxdataF128+=3; - rxdataF_comp128+=3; - } else { - dl_ch128+=2; - rxdataF128+=2; - rxdataF_comp128+=2; - } -#elif defined(__arm__) - -#endif - } - } - } - - - if (rho) { - - for (aarx=0; aarxnb_antennas_rx; aarx++) { - -#if defined(__x86_64__) || defined(__i386__) - rho128 = (__m128i *)&rho[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aarx][symbol*frame_parms->N_RB_DL*12]; - dl_ch128_2 = (__m128i *)&dl_ch_estimates_ext[2+aarx][symbol*frame_parms->N_RB_DL*12]; - -#elif defined(__arm__) - -#endif - for (rb=0; rbN_RB_DL; rb++) { -#if defined(__x86_64__) || defined(__i386__) - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[0],dl_ch128_2[0]); - // print_ints("re",&mmtmpD0); - - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)&conjugate[0]); - // print_ints("im",&mmtmpPD1); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[0]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - // print_ints("re(shift)",&mmtmpD0); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - // print_ints("im(shift)",&mmtmpD1); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - // print_ints("c0",&mmtmpPD2); - // print_ints("c1",&mmtmpPD3); - rho128[0] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - - //print_shorts("rx:",dl_ch128_2); - //print_shorts("ch:",dl_ch128); - //print_shorts("pack:",rho128); - - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[1],dl_ch128_2[1]); - // mmtmpD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[1]); - // mmtmpD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - - rho128[1] =_mm_packs_epi32(mmtmpPD2,mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+1); - //print_shorts("ch:",dl_ch128+1); - //print_shorts("pack:",rho128+1); - // multiply by conjugated channel - mmtmpPD0 = _mm_madd_epi16(dl_ch128[2],dl_ch128_2[2]); - // mmtmpPD0 contains real part of 4 consecutive outputs (32-bit) - mmtmpPD1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_shufflehi_epi16(mmtmpPD1,_MM_SHUFFLE(2,3,0,1)); - mmtmpPD1 = _mm_sign_epi16(mmtmpPD1,*(__m128i*)conjugate); - mmtmpPD1 = _mm_madd_epi16(mmtmpPD1,dl_ch128_2[2]); - // mmtmpPD1 contains imag part of 4 consecutive outputs (32-bit) - mmtmpPD0 = _mm_srai_epi32(mmtmpPD0,output_shift); - mmtmpPD1 = _mm_srai_epi32(mmtmpPD1,output_shift); - mmtmpPD2 = _mm_unpacklo_epi32(mmtmpPD0,mmtmpPD1); - mmtmpPD3 = _mm_unpackhi_epi32(mmtmpPD0,mmtmpPD1); - - rho128[2] = _mm_packs_epi32(mmtmpPD2,mmtmpPD3); - //print_shorts("rx:",dl_ch128_2+2); - //print_shorts("ch:",dl_ch128+2); - //print_shorts("pack:",rho128+2); - - dl_ch128+=3; - dl_ch128_2+=3; - rho128+=3; - -#elif defined(__arm_) - - -#endif - } - } - - } - -#if defined(__x86_64__) || defined(__i386__) - _mm_empty(); - _m_empty(); -#endif -} -*/ void pdcch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, uint8_t symbol) @@ -2634,46 +1586,6 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, if (searchSpaceType == ue_specific) do_common=0; uint8_t log2_maxh, aatx, aarx; int32_t avgs; - //uint8_t n_pdcch_symbols; - // the variable mi can be removed for NR - //uint8_t mi = get_mi(frame_parms, nr_tti_rx); - -/* - * The following variables have been extracted from higher layer parameters - * MIB1 => pdcchConfigSIB1 - * ControlResourceSet IE - * pdcch-Config - * pdcch-ConfigCommon - */ -#if 0 -/* - * initialize this values for testing - */ - - pdcch_vars2->coreset[nb_coreset_active].frequencyDomainResources = 0x1FFF2FF00000; - //pdcch_vars2->coreset[nb_coreset_active].frequencyDomainResources = 0x1E0000000000; - pdcch_vars2->coreset[nb_coreset_active].duration = 2; - pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.shiftIndex = 0; - pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.reg_bundlesize = bundle_n6; - pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.interleaversize = interleave_n2; - pdcch_vars2->coreset[nb_coreset_active].pdcchDMRSScramblingID = 1; - for (int i=0; i < NR_NBR_SEARCHSPACE_ACT_BWP; i++){ - pdcch_vars[eNB_id]->searchSpace[i].nrofCandidates_aggrlevel1 = 7; - pdcch_vars[eNB_id]->searchSpace[i].nrofCandidates_aggrlevel2 = 6; - pdcch_vars[eNB_id]->searchSpace[i].nrofCandidates_aggrlevel4 = 4; - pdcch_vars[eNB_id]->searchSpace[i].nrofCandidates_aggrlevel8 = 3; - pdcch_vars[eNB_id]->searchSpace[i].nrofCandidates_aggrlevel16 = 1; - pdcch_vars[eNB_id]->searchSpace[i].searchSpaceType.sfi_nrofCandidates_aggrlevel1 = 7; - pdcch_vars[eNB_id]->searchSpace[i].searchSpaceType.sfi_nrofCandidates_aggrlevel2 = 6; - pdcch_vars[eNB_id]->searchSpace[i].searchSpaceType.sfi_nrofCandidates_aggrlevel4 = 4; - pdcch_vars[eNB_id]->searchSpace[i].searchSpaceType.sfi_nrofCandidates_aggrlevel8 = 3; - pdcch_vars[eNB_id]->searchSpace[i].searchSpaceType.sfi_nrofCandidates_aggrlevel16 = 1; - } - -/* - * to be removed after testing - */ -#endif //(0) // number of RB (1 symbol) or REG (12 RE) in one CORESET: higher-layer parameter CORESET-freq-dom // (bit map 45 bits: each bit indicates 6 RB in CORESET -> 1 bit MSB indicates PRB 0..6 are part of CORESET) @@ -2756,32 +1668,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, for (int s = start_symbol; s < (start_symbol + coreset_time_dur); s++) { printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter process pdcch ofdm symbol s=%d where coreset_time_dur=%d\n",s,coreset_time_dur); -/* if (is_secondary_ue == 1) { - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id+1], //add 1 to eNB_id to compensate for the shifted B/F'd pilots from the SeNB - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - 0, - high_speed_flag, - frame_parms); -#ifdef MU_RECEIVER - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id_i - 1], //subtract 1 to eNB_id_i to compensate for the non-shifted pilots from the PeNB - pdcch_vars[eNB_id_i]->rxdataF_ext,//shift by two to simulate transmission from a second antenna - pdcch_vars[eNB_id_i]->dl_ch_estimates_ext,//shift by two to simulate transmission from a second antenna - 0, - high_speed_flag, - frame_parms); -#endif //MU_RECEIVER - } else if (frame_parms->nb_antenna_ports_eNB>1) { - pdcch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id], - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - 0, - high_speed_flag, - frame_parms); - } else {*/ + #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter nr_pdcch_extract_rbs_single(is_secondary_ue=%d) to remove DM-RS PDCCH\n", is_secondary_ue); @@ -2797,18 +1684,6 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, coreset_freq_dom, coreset_nbr_rb, n_rb_offset); -/* - printf("\t### in nr_rx_pdcch() function we enter pdcch_extract_rbs_single(is_secondary_ue=%d) to remove DM-RS PDCCH\n",is_secondary_ue); - pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF, - common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id], - pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - 0, - high_speed_flag, - frame_parms); -*/ - -//} #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter pdcch_channel_level(avgP=%d) => compute channel level based on ofdm symbol 0, pdcch_vars[eNB_id]->dl_ch_estimates_ext\n",avgP); @@ -2818,7 +1693,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, pdcch_channel_level(pdcch_vars[eNB_id]->dl_ch_estimates_ext, frame_parms, avgP, - coreset_nbr_rb); + coreset_nbr_rb); avgs = 0; for (aatx = 0; aatx < frame_parms->nb_antenna_ports_eNB; aatx++) for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) @@ -2846,19 +1721,6 @@ T(T_UE_PHY_PDCCH_ENERGY, T_INT(eNB_id), T_INT(0), T_INT(frame%1024), T_INT(nr_tt log2_maxh, coreset_nbr_rb); // log2_maxh+I0_shift -/* -printf("\t### in nr_rx_pdcch() function we enter pdcch_channel_compensation(log2_maxh=%d) => compute LLRs for ofdm symbol 0 only, pdcch_vars[eNB_id]->rxdataF_ext ---> pdcch_vars[eNB_id]->rxdataF_comp\n",log2_maxh); - - // compute LLRs for ofdm symbol 0 only - pdcch_channel_compensation(pdcch_vars[eNB_id]->rxdataF_ext, - pdcch_vars[eNB_id]->dl_ch_estimates_ext, - pdcch_vars[eNB_id]->rxdataF_comp, - (aatx>1) ? pdcch_vars[eNB_id]->rho : NULL, - frame_parms, - 0, - log2_maxh);// log2_maxh+I0_shift -*/ - #ifdef DEBUG_PHY @@ -2949,13 +1811,6 @@ printf("\t### in nr_rx_pdcch() function we enter pdcch_channel_compensation(log2 (char *) pdcch_vars[eNB_id]->llr, s, coreset_nbr_rb); - /* - printf("\t### in nr_rx_pdcch() function we enter pdcch_llr(for symbol 0), pdcch_vars[eNB_id]->rxdataF_comp ---> pdcch_vars[eNB_id]->llr \n"); - pdcch_llr(frame_parms, pdcch_vars[eNB_id]->rxdataF_comp,(char *) pdcch_vars[eNB_id]->llr, 0); - */ - /*#ifdef DEBUG_PHY - write_output("llr8_seq.m","llr8",&pdcch_vars[eNB_id]->llr[s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,4); - #endif*/ #ifdef MU_RECEIVER } @@ -2986,50 +1841,6 @@ nr_pdcch_demapping_deinterleaving(pdcch_vars[eNB_id]->llr, n_shift); - - - - -#if 0 - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter nr_pdcch_demapping()\n"); - #endif - - nr_pdcch_demapping(pdcch_vars[eNB_id]->llr, - pdcch_vars[eNB_id]->wbar, - frame_parms, - coreset_time_dur, - coreset_nbr_rb); - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter nr_pdcch_deinterleaving()\n"); - #endif - nr_pdcch_deinterleaving(frame_parms, - (uint16_t*) pdcch_vars[eNB_id]->e_rx, - pdcch_vars[eNB_id]->wbar, - coreset_time_dur, - reg_bundle_size_L, - coreset_interleaver_size_R, - n_shift, - coreset_nbr_rb); - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we enter nr_pdcch_unscrambling()\n"); - for (int i=0; i<(coreset_time_dur*coreset_nbr_rb*9); i++){ - printf("\te_rx[%d]=(%d,%d)",i,*(char*) &pdcch_vars[eNB_id]->e_rx[i],*(1 + (char*) &pdcch_vars[eNB_id]->e_rx[i])); - if (i%10 == 0) printf("\n"); - } - printf("\n"); - #endif -#endif - -//#if 0 - #ifdef NR_PDCCH_DCI_DEBUG -// printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we end nr_pdcch_unscrambling()\n"); -// for (int i=0; i<(coreset_time_dur*coreset_nbr_rb*9); i++){ -// printf("\t before unscrambling : e_rx[%d]=(%d,%d)\n",i,*(char*) &pdcch_vars[eNB_id]->e_rx[i],*(1 + (char*) &pdcch_vars[eNB_id]->e_rx[i])); -// } -// printf("\n"); - #endif - nr_pdcch_unscrambling(pdcch_vars[eNB_id]->crnti, frame_parms, nr_tti_rx, @@ -3038,41 +1849,10 @@ nr_pdcch_demapping_deinterleaving(pdcch_vars[eNB_id]->llr, // get_nCCE(n_pdcch_symbols, frame_parms, mi) * 72, pdcch_DMRS_scrambling_id, do_common); - #ifdef NR_PDCCH_DCI_DEBUG + #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> we end nr_pdcch_unscrambling()\n"); -// for (int i=0; i<(coreset_time_dur*coreset_nbr_rb*9); i++){ -// printf("\t after unscrambling : e_rx[%d]=(%d,%d)\n",i,*(char*) &pdcch_vars[eNB_id]->e_rx[i],*(1 + (char*) &pdcch_vars[eNB_id]->e_rx[i])); -// } -// printf("\n"); #endif -//#endif //0 -/* - printf("\t### in nr_rx_pdcch() function we enter pdcch_demapping()\n"); - pdcch_demapping(pdcch_vars[eNB_id]->llr, - pdcch_vars[eNB_id]->wbar, - frame_parms, - n_pdcch_symbols, - get_mi(frame_parms,nr_tti_rx)); - - printf("\t### in nr_rx_pdcch() function we enter pdcch_deinterleaving()\n"); - - pdcch_deinterleaving(frame_parms, - (uint16_t*)pdcch_vars[eNB_id]->e_rx, - pdcch_vars[eNB_id]->wbar, - n_pdcch_symbols, - mi); - - printf("\t### in nr_rx_pdcch() function we enter pdcch_unscrambling()\n"); - - pdcch_unscrambling(frame_parms, - nr_tti_rx, - pdcch_vars[eNB_id]->e_rx, - get_nCCE(n_pdcch_symbols,frame_parms,mi)*72); - - - pdcch_vars[eNB_id]->num_pdcch_symbols = n_pdcch_symbols; -*/ #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> Ending nr_rx_pdcch() function\n"); #endif @@ -3167,504 +1947,9 @@ printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> (c_init=%d, n_id=%d, } } -#if 0 -void nr_pdcch_unscrambling_tmp(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_tti_rx, - double llr[], uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common) { - - int i; - uint8_t reset; - uint32_t x1, x2, s = 0; - uint16_t n_id; //{0,1,...,65535} - uint32_t n_rnti; - - reset = 1; - // x1 is set in first call to lte_gold_generic - //do_common=1; -if (do_common){ - n_id = frame_parms->Nid_cell; - n_rnti = 0; -} else { - n_id = pdcch_DMRS_scrambling_id; - n_rnti = (uint32_t)crnti; -} -//x2 = ((n_rnti * (1 << 16)) + n_id)%(1 << 31); -//uint32_t puissance_2_16 = ((1<<16)*n_rnti)+n_id; -//uint32_t puissance_2_31= (1<<30)*2; -//uint32_t calc_x2=puissance_2_16%puissance_2_31; - x2 = (((1<<16)*n_rnti)+n_id)%((1<<30)*2); //this is c_init in 38.211 v15.1.0 Section 7.3.2.3 -// x2 = (nr_tti_rx << 9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 -#ifdef NR_PDCCH_DCI_DEBUG -printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> (c_init=%d, n_id=%d, n_rnti=%d, length=%d)\n",x2,n_id,n_rnti,length); -#endif - for (i = 0; i < length; i++) { - if ((i & 0x1f) == 0) { - s = lte_gold_generic(&x1, &x2, reset); - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> lte_gold[%d]=%x\n",i,s); - reset = 0; - } - - printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> unscrambling %d : scrambled_llr=%d, c %d => ",i,llr[i],((s>>(i&0x1f))&1)); - if (((s >> (i % 32)) & 1) == 1) - llr[i] = -llr[i]; - //llr[i] = (-1)*llr[i]; - printf("unscrambled_llr=%d\n",llr[i]); - - - } -} - - - -void nr_pdcch_unscrambling_old(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_tti_rx, - int8_t* llr, uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common) { - - int i; - uint8_t reset; - uint32_t x1, x2, s = 0; - uint16_t n_id; //{0,1,...,65535} - uint32_t n_rnti; - - reset = 1; - // x1 is set in first call to lte_gold_generic - //do_common=1; -if (do_common){ - n_id = frame_parms->Nid_cell; - n_rnti = 0; -} else { - n_id = pdcch_DMRS_scrambling_id; - n_rnti = (uint32_t)crnti; -} -//x2 = ((n_rnti * (1 << 16)) + n_id)%(1 << 31); -//uint32_t puissance_2_16 = ((1<<16)*n_rnti)+n_id; -//uint32_t puissance_2_31= (1<<30)*2; -//uint32_t calc_x2=puissance_2_16%puissance_2_31; - x2 = (((1<<16)*n_rnti)+n_id)%((1<<30)*2); //this is c_init in 38.211 v15.1.0 Section 7.3.2.3 -// x2 = (nr_tti_rx << 9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 -#ifdef NR_PDCCH_DCI_DEBUG -printf("\t\t<-NR_PDCCH_DCI_DEBUG (nr_pdcch_unscrambling)-> (c_init=%d, n_id=%d, n_rnti=%d)\n",x2,n_id,n_rnti); -#endif - for (i = 0; i < length; i++) { - if ((i & 0x1f) == 0) { - s = lte_gold_generic(&x1, &x2, reset); - // printf("lte_gold[%d]=%x\n",i,s); - reset = 0; - } - - // printf("unscrambling %d : e %d, c %d => ",i,llr[i],((s>>(i&0x1f))&1)); - if (((s >> (i % 32)) & 1) == 0) - llr[i] = -llr[i]; - // printf("%d\n",llr[i]); - - } -} -#endif // 0 - #endif - - -void pdcch_unscrambling(NR_DL_FRAME_PARMS *frame_parms, - uint8_t nr_tti_rx, - int8_t* llr, - uint32_t length) -{ - - int i; - uint8_t reset; - uint32_t x1, x2, s=0; - - reset = 1; - // x1 is set in first call to lte_gold_generic - - x2 = (nr_tti_rx<<9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2 - - for (i=0; i ",i,llr[i],((s>>(i&0x1f))&1)); - if (((s>>(i%32))&1)==0) - llr[i] = -llr[i]; - // printf("%d\n",llr[i]); - - } -} - - -/*uint8_t get_num_pdcch_symbols(uint8_t num_dci, - DCI_ALLOC_t *dci_alloc, - NR_DL_FRAME_PARMS *frame_parms, - uint8_t nr_tti_rx) -{ - - uint16_t numCCE = 0; - uint8_t i; - uint8_t nCCEmin = 0; - uint16_t CCE_max_used_index = 0; - uint16_t firstCCE_max = dci_alloc[0].firstCCE; - uint8_t L = dci_alloc[0].L; - - // check pdcch duration imposed by PHICH duration (Section 6.9 of 36-211) - if (frame_parms->Ncp==1) { // extended prefix - if ((frame_parms->frame_type == TDD) && - ((frame_parms->tdd_config<3)||(frame_parms->tdd_config==6)) && - ((nr_tti_rx==1) || (nr_tti_rx==6))) // subframes 1 and 6 (S-subframes) for 5ms switching periodicity are 2 symbols - nCCEmin = 2; - else { // 10ms switching periodicity is always 3 symbols, any DL-only subframe is 3 symbols - nCCEmin = 3; - } - } - - // compute numCCE - for (i=0; i %d\n",i,dci_alloc[i].L); - numCCE += (1<<(dci_alloc[i].L)); - - if(firstCCE_max < dci_alloc[i].firstCCE) { - firstCCE_max = dci_alloc[i].firstCCE; - L = dci_alloc[i].L; - } - } - CCE_max_used_index = firstCCE_max + (1<N_RB_DL*2)) - if (CCE_max_used_index < get_nCCE(1, frame_parms, get_mi(frame_parms, nr_tti_rx))) - return(cmax(1,nCCEmin)); - //else if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 4 : 5))) - else if (CCE_max_used_index < get_nCCE(2, frame_parms, get_mi(frame_parms, nr_tti_rx))) - return(cmax(2,nCCEmin)); - //else if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 7 : 8))) - else if (CCE_max_used_index < get_nCCE(3, frame_parms, get_mi(frame_parms, nr_tti_rx))) - return(cmax(3,nCCEmin)); - else if (frame_parms->N_RB_DL<=10) { - if (frame_parms->Ncp == 0) { // normal CP - printf("numCCE %d, N_RB_DL = %d : should be returning 4 PDCCH symbols (%d,%d,%d)\n",numCCE,frame_parms->N_RB_DL, - get_nCCE(1, frame_parms, get_mi(frame_parms, nr_tti_rx)), - get_nCCE(2, frame_parms, get_mi(frame_parms, nr_tti_rx)), - get_nCCE(3, frame_parms, get_mi(frame_parms, nr_tti_rx))); - - if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 10 : 11))) - return(4); - } else { // extended CP - if ((9*numCCE) <= (frame_parms->N_RB_DL*((frame_parms->nb_antenna_ports_eNB==4) ? 9 : 10))) - return(4); - } - } - - - LOG_D(PHY," dci.c: get_num_pdcch_symbols nr_tti_rx %d FATAL, illegal numCCE %d (num_dci %d)\n",nr_tti_rx,numCCE,num_dci); - //for (i=0;inushift%3; - - int Msymb2; - int split_flag=0; - - switch (frame_parms->N_RB_DL) { - case 100: - Msymb2 = Msymb; - break; - - case 75: - Msymb2 = 3*Msymb/4; - break; - - case 50: - Msymb2 = Msymb>>1; - break; - - case 25: - Msymb2 = Msymb>>2; - break; - - case 15: - Msymb2 = Msymb*15/100; - break; - - case 6: - Msymb2 = Msymb*6/100; - break; - - default: - Msymb2 = Msymb>>2; - break; - } - - num_pdcch_symbols = get_num_pdcch_symbols(num_dci,dci_alloc,frame_parms,nr_tti_rx); - // printf("nr_tti_rx %d in generate_dci_top num_pdcch_symbols = %d, num_dci %d\n", - // nr_tti_rx,num_pdcch_symbols,num_dci); - generate_pcfich(num_pdcch_symbols, - amp, - frame_parms, - txdataF, - nr_tti_rx); - wbar[0] = &wbar0[0]; - wbar[1] = &wbar1[0]; - y[0] = &yseq0[0]; - y[1] = &yseq1[0]; - - // reset all bits to , here we set elements as 2 - // memset(e, 2, DCI_BITS_MAX); - // here we interpret NIL as a random QPSK sequence. That makes power estimation easier. - for (i=0; i=0) { - e_ptr = generate_dci0(dci_alloc[i].dci_pdu, - e+(72*dci_alloc[i].firstCCE), - dci_alloc[i].dci_length, - dci_alloc[i].L, - dci_alloc[i].rnti); - } - } - - // Scrambling - // printf("pdcch scrambling\n"); - pdcch_scrambling(frame_parms, - nr_tti_rx, - e, - 8*get_nquad(num_pdcch_symbols, frame_parms, mi)); - //72*get_nCCE(num_pdcch_symbols,frame_parms,mi)); - - - - - // Now do modulation - if (frame_parms->mode1_flag==1) - gain_lin_QPSK = (int16_t)((amp*ONE_OVER_SQRT2_Q15)>>15); - else - gain_lin_QPSK = amp/2; - - e_ptr = e; - -#ifdef DEBUG_DCI_ENCODING - printf(" PDCCH Modulation, Msymb %d, Msymb2 %d,gain_lin_QPSK %d\n",Msymb,Msymb2,gain_lin_QPSK); -#endif - - - if (frame_parms->mode1_flag) { //SISO - - - for (i=0; i>2); -#endif - // first antenna position n -> x0 - ((int16_t*)&y[0][i])[0] = (*e_ptr==2) ? 0 : (*e_ptr == 1) ? -gain_lin_QPSK : gain_lin_QPSK; - e_ptr++; - ((int16_t*)&y[0][i])[1] = (*e_ptr==2) ? 0 : (*e_ptr == 1) ? -gain_lin_QPSK : gain_lin_QPSK; - e_ptr++; - - // second antenna position n -> -x1* - ((int16_t*)&y[1][i])[0] = (*e_ptr==2) ? 0 : (*e_ptr == 1) ? gain_lin_QPSK : -gain_lin_QPSK; - e_ptr++; - ((int16_t*)&y[1][i])[1] = (*e_ptr==2) ? 0 : (*e_ptr == 1) ? -gain_lin_QPSK : gain_lin_QPSK; - e_ptr++; - - // fill in the rest of the ALAMOUTI precoding - ((int16_t*)&y[0][i+1])[0] = -((int16_t*)&y[1][i])[0]; - ((int16_t*)&y[0][i+1])[1] = ((int16_t*)&y[1][i])[1]; - ((int16_t*)&y[1][i+1])[0] = ((int16_t*)&y[0][i])[0]; - ((int16_t*)&y[1][i+1])[1] = -((int16_t*)&y[0][i])[1]; - - } - } - - -#ifdef DEBUG_DCI_ENCODING - printf(" PDCCH Interleaving\n"); -#endif - - // printf("y %p (%p,%p), wbar %p (%p,%p)\n",y,y[0],y[1],wbar,wbar[0],wbar[1]); - // This is the interleaving procedure defined in 36-211, first part of Section 6.8.5 - pdcch_interleaving(frame_parms,&y[0],&wbar[0],num_pdcch_symbols,mi); - - mprime=0; - nsymb = (frame_parms->Ncp==0) ? 14:12; - re_offset = frame_parms->first_carrier_offset; - - // This is the REG allocation algorithm from 36-211, second part of Section 6.8.5 - // printf("DCI (SF %d) : txdataF %p (0 %p)\n",subframe,&txdataF[0][512*14*subframe],&txdataF[0][0]); - for (kprime=0; kprimeN_RB_DL*12; kprime++) { - for (lprime=0; lprimeofdm_symbol_size*(lprime+(nr_tti_rx*nsymb)); - - - - tti_offset = symbol_offset + re_offset; - - (re_offset==(frame_parms->ofdm_symbol_size-2)) ? (split_flag=1) : (split_flag=0); - - // printf("kprime %d, lprime %d => REG %d (symbol %d)\n",kprime,lprime,(lprime==0)?(kprime/6) : (kprime>>2),symbol_offset); - // if REG is allocated to PHICH, skip it - if (check_phich_reg(frame_parms,kprime,lprime,mi) == 1) { -#ifdef DEBUG_DCI_ENCODING - printf("generate_dci: skipping REG %d (kprime %d, lprime %d)\n",(lprime==0)?(kprime/6) : (kprime>>2),kprime,lprime); -#endif - } else { - // Copy REG to TX buffer - - if ((lprime == 0)|| - ((lprime==1)&&(frame_parms->nb_antenna_ports_eNB == 4))) { - // first symbol, or second symbol+4 TX antennas skip pilots - - kprime_mod12 = kprime%12; - - if ((kprime_mod12 == 0) || (kprime_mod12 == 6)) { - // kprime represents REG - - for (i=0; i<6; i++) { - if ((i!=(nushiftmod3))&&(i!=(nushiftmod3+3))) { - txdataF[0][tti_offset+i] = wbar[0][mprime]; - - if (frame_parms->nb_antenna_ports_eNB > 1) - txdataF[1][tti_offset+i] = wbar[1][mprime]; - -#ifdef DEBUG_DCI_ENCODING - printf(" PDCCH mapping mprime %d => %d (symbol %d re %d) -> (%d,%d)\n",mprime,tti_offset,symbol_offset,re_offset+i,*(short*)&wbar[0][mprime],*(1+(short*)&wbar[0][mprime])); -#endif - - mprime++; - } - } - } - } else { // no pilots in this symbol - kprime_mod12 = kprime%12; - - if ((kprime_mod12 == 0) || (kprime_mod12 == 4) || (kprime_mod12 == 8)) { - // kprime represents REG - if (split_flag==0) { - for (i=0; i<4; i++) { - txdataF[0][tti_offset+i] = wbar[0][mprime]; - - if (frame_parms->nb_antenna_ports_eNB > 1) - txdataF[1][tti_offset+i] = wbar[1][mprime]; - -#ifdef DEBUG_DCI_ENCODING - LOG_I(PHY," PDCCH mapping mprime %d => %d (symbol %d re %d) -> (%d,%d)\n",mprime,tti_offset,symbol_offset,re_offset+i,*(short*)&wbar[0][mprime],*(1+(short*)&wbar[0][mprime])); -#endif - mprime++; - } - } else { - txdataF[0][tti_offset+0] = wbar[0][mprime]; - - if (frame_parms->nb_antenna_ports_eNB > 1) - txdataF[1][tti_offset+0] = wbar[1][mprime]; - -#ifdef DEBUG_DCI_ENCODING - printf(" PDCCH mapping mprime %d => %d (symbol %d re %d) -> (%d,%d)\n",mprime,tti_offset,symbol_offset,re_offset,*(short*)&wbar[0][mprime],*(1+(short*)&wbar[0][mprime])); -#endif - mprime++; - txdataF[0][tti_offset+1] = wbar[0][mprime]; - - if (frame_parms->nb_antenna_ports_eNB > 1) - txdataF[1][tti_offset+1] = wbar[1][mprime]; - -#ifdef DEBUG_DCI_ENCODING - printf("PDCCH mapping mprime %d => %d (symbol %d re %d) -> (%d,%d)\n",mprime,tti_offset,symbol_offset,re_offset+1,*(short*)&wbar[0][mprime],*(1+(short*)&wbar[0][mprime])); -#endif - mprime++; - txdataF[0][tti_offset-frame_parms->ofdm_symbol_size+3] = wbar[0][mprime]; - - if (frame_parms->nb_antenna_ports_eNB > 1) - txdataF[1][tti_offset-frame_parms->ofdm_symbol_size+3] = wbar[1][mprime]; - -#ifdef DEBUG_DCI_ENCODING - printf(" PDCCH mapping mprime %d => %d (symbol %d re %d) -> (%d,%d)\n",mprime,tti_offset,symbol_offset,re_offset-frame_parms->ofdm_symbol_size+3,*(short*)&wbar[0][mprime], - *(1+(short*)&wbar[0][mprime])); -#endif - mprime++; - txdataF[0][tti_offset-frame_parms->ofdm_symbol_size+4] = wbar[0][mprime]; - - if (frame_parms->nb_antenna_ports_eNB > 1) - txdataF[1][tti_offset-frame_parms->ofdm_symbol_size+4] = wbar[1][mprime]; - -#ifdef DEBUG_DCI_ENCODING - printf(" PDCCH mapping mprime %d => %d (symbol %d re %d) -> (%d,%d)\n",mprime,tti_offset,symbol_offset,re_offset-frame_parms->ofdm_symbol_size+4,*(short*)&wbar[0][mprime], - *(1+(short*)&wbar[0][mprime])); -#endif - mprime++; - - } - } - } - - if (mprime>=Msymb2) - return(num_pdcch_symbols); - } // check_phich_reg - - } //lprime loop - - re_offset++; - - if (re_offset == (frame_parms->ofdm_symbol_size)) - re_offset = 1; - } // kprime loop - - return(num_pdcch_symbols); -} -*/ #ifdef PHY_ABSTRACTION uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB, int num_dci, @@ -5725,1088 +4010,16 @@ uint8_t nr_dci_decoding_procedure(int s, #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> at the end crc_scrambled=%d and format_found=%d\n",*crc_scrambled,*format_found); #endif - /*if (uss_dci_format == uformat0_1_and_1_1) { // Not implemented yet. FIXME!!! - // for format0_1, first we calculate dci pdu size - format0_1_size_bits = nr_dci_format_size(format0_1,c_rnti,16,n_RB_ULBWP,n_RB_DLBWP,dci_fields_sizes); - format0_1_size_bytes = (format0_1_size_bits%8 == 0) ? (uint8_t)floor(format0_1_size_bits/8) : (uint8_t)(floor(format0_1_size_bits/8) + 1); - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> calculating dci format size for UE-specific searchSpaces with format uss_dci_format=%d, format0_1_size_bits=%d, format0_1_size_bytes=%d\n", - css_dci_format,format0_1_size_bits,format0_1_size_bytes); - #endif - // blind decoding format0_1 for aggregation level 1. The number of candidates (nrofCandidates) will be calculated in function nr_dci_decoding_procedure0 - // blind decoding format0_1 for aggregation level 2. The number of candidates (nrofCandidates) will be calculated in function nr_dci_decoding_procedure0 - // blind decoding format0_1 for aggregation level 4. The number of candidates (nrofCandidates) will be calculated in function nr_dci_decoding_procedure0 - // blind decoding format0_1 for aggregation level 8. The number of candidates (nrofCandidates) will be calculated in function nr_dci_decoding_procedure0 - // blind decoding format0_1 for aggregation level 16. The number of candidates (nrofCandidates) will be calculated in function nr_dci_decoding_procedure0 - // for format1_1, first we calculate dci pdu size - format1_1_size_bits = nr_dci_format_size(format1_1,c_rnti,16,n_RB_ULBWP,n_RB_DLBWP,dci_fields_sizes); - format1_1_size_bytes = (format1_1_size_bits%8 == 0) ? (uint8_t)floor(format1_1_size_bits/8) : (uint8_t)(floor(format1_1_size_bits/8) + 1); - #ifdef NR_PDCCH_DCI_DEBUG - printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> calculating dci format size for UE-specific searchSpaces with format uss_dci_format=%d, format1_1_size_bits=%d, format1_1_size_bytes=%d\n", - css_dci_format,format1_1_size_bits,format1_1_size_bytes); - #endif - // blind decoding format1_1 for aggregation level 1. The number of candidates (nrofCandidates) will be calculated in function nr_dci_decoding_procedure0 - // blind decoding format1_1 for aggregation level 2. The number of candidates (nrofCandidates) will be calculated in function nr_dci_decoding_procedure0 - // blind decoding format1_1 for aggregation level 4. The number of candidates (nrofCandidates) will be calculated in function nr_dci_decoding_procedure0 - // blind decoding format1_1 for aggregation level 8. The number of candidates (nrofCandidates) will be calculated in function nr_dci_decoding_procedure0 - // blind decoding format1_1 for aggregation level 16. The number of candidates (nrofCandidates) will be calculated in function nr_dci_decoding_procedure0 - }*/ - //} #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure)-> at the end dci_cnt=%d \n",dci_cnt); #endif return(dci_cnt); } - - - #endif - - - -/* -uint16_t dci_decoding_procedure(PHY_VARS_NR_UE *ue, - DCI_ALLOC_t *dci_alloc, - int do_common, - int16_t eNB_id, - uint8_t nr_tti_rx) -{ - - uint8_t dci_cnt=0,old_dci_cnt=0; - uint32_t CCEmap0=0,CCEmap1=0,CCEmap2=0; - NR_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]]; - NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - uint8_t mi = get_mi(&ue->frame_parms,nr_tti_rx); - uint16_t ra_rnti=99; - uint8_t format0_found=0,format_c_found=0; - uint8_t tmode = ue->transmission_mode[eNB_id]; - uint8_t frame_type = frame_parms->frame_type; - uint8_t format1A_size_bits=0,format1A_size_bytes=0; - uint8_t format1C_size_bits=0,format1C_size_bytes=0; - uint8_t format0_size_bits=0,format0_size_bytes=0; - uint8_t format1_size_bits=0,format1_size_bytes=0; - uint8_t format2_size_bits=0,format2_size_bytes=0; - uint8_t format2A_size_bits=0,format2A_size_bytes=0; - dci_detect_mode_t mode = dci_detect_mode_select(&ue->frame_parms,nr_tti_rx); - - switch (frame_parms->N_RB_DL) { - case 6: - if (frame_type == TDD) { - format1A_size_bits = sizeof_DCI1A_1_5MHz_TDD_1_6_t; - format1A_size_bytes = sizeof(DCI1A_1_5MHz_TDD_1_6_t); - format1C_size_bits = sizeof_DCI1C_1_5MHz_t; - format1C_size_bytes = sizeof(DCI1C_1_5MHz_t); - format0_size_bits = sizeof_DCI0_1_5MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_1_5MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_1_5MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_1_5MHz_TDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_1_5MHz_2A_TDD_t; - format2_size_bytes = sizeof(DCI2_1_5MHz_2A_TDD_t); - format2A_size_bits = sizeof_DCI2A_1_5MHz_2A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_1_5MHz_2A_TDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_1_5MHz_4A_TDD_t; - format2_size_bytes = sizeof(DCI2_1_5MHz_4A_TDD_t); - format2A_size_bits = sizeof_DCI2A_1_5MHz_4A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_1_5MHz_4A_TDD_t); - } - } else { - format1A_size_bits = sizeof_DCI1A_1_5MHz_FDD_t; - format1A_size_bytes = sizeof(DCI1A_1_5MHz_FDD_t); - format1C_size_bits = sizeof_DCI1C_1_5MHz_t; - format1C_size_bytes = sizeof(DCI1C_1_5MHz_t); - format0_size_bits = sizeof_DCI0_1_5MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_1_5MHz_FDD_t); - format1_size_bits = sizeof_DCI1_1_5MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_1_5MHz_FDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_1_5MHz_2A_FDD_t; - format2_size_bytes = sizeof(DCI2_1_5MHz_2A_FDD_t); - format2A_size_bits = sizeof_DCI2A_1_5MHz_2A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_1_5MHz_2A_FDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_1_5MHz_4A_FDD_t; - format2_size_bytes = sizeof(DCI2_1_5MHz_4A_FDD_t); - format2A_size_bits = sizeof_DCI2A_1_5MHz_4A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_1_5MHz_4A_FDD_t); - } - } - - break; - - case 25: - default: - if (frame_type == TDD) { - format1A_size_bits = sizeof_DCI1A_5MHz_TDD_1_6_t; - format1A_size_bytes = sizeof(DCI1A_5MHz_TDD_1_6_t); - format1C_size_bits = sizeof_DCI1C_5MHz_t; - format1C_size_bytes = sizeof(DCI1C_5MHz_t); - format0_size_bits = sizeof_DCI0_5MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_5MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_5MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_5MHz_TDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_5MHz_2A_TDD_t; - format2_size_bytes = sizeof(DCI2_5MHz_2A_TDD_t); - format2A_size_bits = sizeof_DCI2A_5MHz_2A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_5MHz_2A_TDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_5MHz_4A_TDD_t; - format2_size_bytes = sizeof(DCI2_5MHz_4A_TDD_t); - format2A_size_bits = sizeof_DCI2A_5MHz_4A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_5MHz_4A_TDD_t); - } - } else { - format1A_size_bits = sizeof_DCI1A_5MHz_FDD_t; - format1A_size_bytes = sizeof(DCI1A_5MHz_FDD_t); - format1C_size_bits = sizeof_DCI1C_5MHz_t; - format1C_size_bytes = sizeof(DCI1C_5MHz_t); - format0_size_bits = sizeof_DCI0_5MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_5MHz_FDD_t); - format1_size_bits = sizeof_DCI1_5MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_5MHz_FDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_5MHz_2A_FDD_t; - format2_size_bytes = sizeof(DCI2_5MHz_2A_FDD_t); - format2A_size_bits = sizeof_DCI2A_5MHz_2A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_5MHz_2A_FDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_5MHz_4A_FDD_t; - format2_size_bytes = sizeof(DCI2_5MHz_4A_FDD_t); - format2A_size_bits = sizeof_DCI2A_5MHz_4A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_5MHz_4A_FDD_t); - } - } - - break; - - case 50: - if (frame_type == TDD) { - format1A_size_bits = sizeof_DCI1A_10MHz_TDD_1_6_t; - format1A_size_bytes = sizeof(DCI1A_10MHz_TDD_1_6_t); - format1C_size_bits = sizeof_DCI1C_10MHz_t; - format1C_size_bytes = sizeof(DCI1C_10MHz_t); - format0_size_bits = sizeof_DCI0_10MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_10MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_10MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_10MHz_TDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_10MHz_2A_TDD_t; - format2_size_bytes = sizeof(DCI2_10MHz_2A_TDD_t); - format2A_size_bits = sizeof_DCI2A_10MHz_2A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_10MHz_2A_TDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_10MHz_4A_TDD_t; - format2_size_bytes = sizeof(DCI2_10MHz_4A_TDD_t); - format2A_size_bits = sizeof_DCI2A_10MHz_4A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_10MHz_4A_TDD_t); - } - } else { - format1A_size_bits = sizeof_DCI1A_10MHz_FDD_t; - format1A_size_bytes = sizeof(DCI1A_10MHz_FDD_t); - format1C_size_bits = sizeof_DCI1C_10MHz_t; - format1C_size_bytes = sizeof(DCI1C_10MHz_t); - format0_size_bits = sizeof_DCI0_10MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_10MHz_FDD_t); - format1_size_bits = sizeof_DCI1_10MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_10MHz_FDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_10MHz_2A_FDD_t; - format2_size_bytes = sizeof(DCI2_10MHz_2A_FDD_t); - format2A_size_bits = sizeof_DCI2A_10MHz_2A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_10MHz_2A_FDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_10MHz_4A_FDD_t; - format2_size_bytes = sizeof(DCI2_10MHz_4A_FDD_t); - format2A_size_bits = sizeof_DCI2A_10MHz_4A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_10MHz_4A_FDD_t); - } - } - - break; - - case 100: - if (frame_type == TDD) { - format1A_size_bits = sizeof_DCI1A_20MHz_TDD_1_6_t; - format1A_size_bytes = sizeof(DCI1A_20MHz_TDD_1_6_t); - format1C_size_bits = sizeof_DCI1C_20MHz_t; - format1C_size_bytes = sizeof(DCI1C_20MHz_t); - format0_size_bits = sizeof_DCI0_20MHz_TDD_1_6_t; - format0_size_bytes = sizeof(DCI0_20MHz_TDD_1_6_t); - format1_size_bits = sizeof_DCI1_20MHz_TDD_t; - format1_size_bytes = sizeof(DCI1_20MHz_TDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_20MHz_2A_TDD_t; - format2_size_bytes = sizeof(DCI2_20MHz_2A_TDD_t); - format2A_size_bits = sizeof_DCI2A_20MHz_2A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_20MHz_2A_TDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_20MHz_4A_TDD_t; - format2_size_bytes = sizeof(DCI2_20MHz_4A_TDD_t); - format2A_size_bits = sizeof_DCI2A_20MHz_4A_TDD_t; - format2A_size_bytes = sizeof(DCI2A_20MHz_4A_TDD_t); - } - } else { - format1A_size_bits = sizeof_DCI1A_20MHz_FDD_t; - format1A_size_bytes = sizeof(DCI1A_20MHz_FDD_t); - format1C_size_bits = sizeof_DCI1C_20MHz_t; - format1C_size_bytes = sizeof(DCI1C_20MHz_t); - format0_size_bits = sizeof_DCI0_20MHz_FDD_t; - format0_size_bytes = sizeof(DCI0_20MHz_FDD_t); - format1_size_bits = sizeof_DCI1_20MHz_FDD_t; - format1_size_bytes = sizeof(DCI1_20MHz_FDD_t); - - if (frame_parms->nb_antenna_ports_eNB == 2) { - format2_size_bits = sizeof_DCI2_20MHz_2A_FDD_t; - format2_size_bytes = sizeof(DCI2_20MHz_2A_FDD_t); - format2A_size_bits = sizeof_DCI2A_20MHz_2A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_20MHz_2A_FDD_t); - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - format2_size_bits = sizeof_DCI2_20MHz_4A_FDD_t; - format2_size_bytes = sizeof(DCI2_20MHz_4A_FDD_t); - format2A_size_bits = sizeof_DCI2A_20MHz_4A_FDD_t; - format2A_size_bytes = sizeof(DCI2A_20MHz_4A_FDD_t); - } - } - - break; - } - - if (do_common == 1) { -#ifdef DEBUG_DCI_DECODING - printf("[DCI search] doing common search/format0 aggregation 4\n"); -#endif - - if (ue->prach_resources[eNB_id]) - ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; - - // First check common search spaces at aggregation 4 (SI_RNTI, P_RNTI and RA_RNTI format 0/1A), - // and UE_SPEC format0 (PUSCH) too while we're at it - dci_decoding_procedure0(pdcch_vars,1,mode,nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0) , - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format0, - format1A_size_bits, - format1A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff) || - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - // Now check common search spaces at aggregation 4 (SI_RNTI,P_RNTI and RA_RNTI and C-RNTI format 1C), - // and UE_SPEC format0 (PUSCH) too while we're at it - dci_decoding_procedure0(pdcch_vars,1,mode,nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1C, - format1C, - format1C, - format1C, - format1C_size_bits, - format1C_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff) || - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - // Now check common search spaces at aggregation 8 (SI_RNTI,P_RNTI and RA_RNTI format 1A), - // and UE_SPEC format0 (PUSCH) too while we're at it - // printf("[DCI search] doing common search/format0 aggregation 3\n"); -#ifdef DEBUG_DCI_DECODING - printf("[DCI search] doing common search/format0 aggregation 8\n"); -#endif - dci_decoding_procedure0(pdcch_vars,1,mode,nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - P_RNTI, - ra_rnti, - 3, - format1A, - format1A, - format1A, - format0, - format1A_size_bits, - format1A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - // Now check common search spaces at aggregation 8 (SI_RNTI and RA_RNTI and C-RNTI format 1C), - // and UE_SPEC format0 (PUSCH) too while we're at it - dci_decoding_procedure0(pdcch_vars,1,mode,nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1C, - format1C, - format1C, - format1C, - format1C_size_bits, - format1C_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //#endif - - } - - if (ue->UE_mode[eNB_id] <= PRACH) - return(dci_cnt); - - if (ue->prach_resources[eNB_id]) - ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI; - - // Now check UE_SPEC format0/1A ue_spec search spaces at aggregation 8 - // printf("[DCI search] Format 0/1A aggregation 8\n"); - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - //printf("[DCI search] Format 0 aggregation 1 dci_cnt %d\n",dci_cnt); - - if (dci_cnt == 0) - { - // Now check UE_SPEC format 0 search spaces at aggregation 4 - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - - //printf("[DCI search] Format 0 aggregation 2 dci_cnt %d\n",dci_cnt); - } - - if (dci_cnt == 0) - { - // Now check UE_SPEC format 0 search spaces at aggregation 2 - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - //printf("[DCI search] Format 0 aggregation 4 dci_cnt %d\n",dci_cnt); - } - - if (dci_cnt == 0) - { - // Now check UE_SPEC format 0 search spaces at aggregation 1 - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format0, - format0_size_bits, - format0_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - //printf("[DCI search] Format 0 aggregation 8 dci_cnt %d\n",dci_cnt); - - } - // These are for CRNTI based on transmission mode - if ((tmode < 3) || (tmode == 7)) { - // Now check UE_SPEC format 1 search spaces at aggregation 1 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //printf("[DCI search] Format 1 aggregation 1 dci_cnt %d\n",dci_cnt); - - if ((CCEmap0==0xffff) || - (format_c_found==1)) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 1 search spaces at aggregation 2 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //printf("[DCI search] Format 1 aggregation 2 dci_cnt %d\n",dci_cnt); - - if ((CCEmap0==0xffff)|| - (format_c_found==1)) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 1 search spaces at aggregation 4 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //printf("[DCI search] Format 1 aggregation 4 dci_cnt %d\n",dci_cnt); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#ifdef ALL_AGGREGATION - // Now check UE_SPEC format 1 search spaces at aggregation 8 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode,nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format1, - format1_size_bits, - format1_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //printf("[DCI search] Format 1 aggregation 8 dci_cnt %d\n",dci_cnt); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#endif //ALL_AGGREGATION - } else if (tmode == 3) { - - - LOG_D(PHY," Now check UE_SPEC format 2A_2A search aggregation 1 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); - // Now check UE_SPEC format 2A_2A search spaces at aggregation 1 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format2A, - format2A_size_bits, - format2A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - LOG_D(PHY," format 2A_2A search CCEmap0 %x, format0_found %d, format_c_found %d \n", CCEmap0, format0_found, format_c_found); - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 2 search spaces at aggregation 2 - LOG_D(PHY," Now check UE_SPEC format 2A_2A search aggregation 2 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format2A, - format2A_size_bits, - format2A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 2_2A search spaces at aggregation 4 - LOG_D(PHY," Now check UE_SPEC format 2_2A search spaces at aggregation 4 \n"); - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format2A, - format2A_size_bits, - format2A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#ifdef ALL_AGGREGATION - // Now check UE_SPEC format 2_2A search spaces at aggregation 8 - LOG_D(PHY," Now check UE_SPEC format 2_2A search spaces at aggregation 8 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes); - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format2A, - format2A_size_bits, - format2A_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //#endif - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - LOG_D(PHY," format 2A_2A search dci_cnt %d, old_dci_cn t%d \n", dci_cnt, old_dci_cnt); - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - } else if (tmode == 4) { - - // Now check UE_SPEC format 2_2A search spaces at aggregation 1 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format2, - format2_size_bits, - format2_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 2 search spaces at aggregation 2 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format2, - format2_size_bits, - format2_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 2_2A search spaces at aggregation 4 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format2, - format2_size_bits, - format2_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#ifdef ALL_AGGREGATION - // Now check UE_SPEC format 2_2A search spaces at aggregation 8 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format2, - format2_size_bits, - format2_size_bytes, - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - //#endif - } else if ((tmode==5) || (tmode==6)) { // This is MU-MIMO - - // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 1 -#ifdef DEBUG_DCI_DECODING - LOG_I(PHY," MU-MIMO check UE_SPEC format 1E_2A_M10PRB\n"); -#endif - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 0, - format1A, - format1A, - format1A, - format1E_2A_M10PRB, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 2 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 1, - format1A, - format1A, - format1A, - format1E_2A_M10PRB, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - // Now check UE_SPEC format 1E_2A_M10PRB search spaces aggregation 4 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 2, - format1A, - format1A, - format1A, - format1E_2A_M10PRB, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#ifdef ALL_AGGREGATION - - // Now check UE_SPEC format 1E_2A_M10PRB search spaces at aggregation 8 - old_dci_cnt=dci_cnt; - dci_decoding_procedure0(pdcch_vars,0,mode, - nr_tti_rx, - dci_alloc, - eNB_id, - ue->current_thread_id[nr_tti_rx], - frame_parms, - mi, - ((ue->decode_SIB == 1) ? SI_RNTI : 0), - ra_rnti, - P_RNTI, - 3, - format1A, - format1A, - format1A, - format1E_2A_M10PRB, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - &dci_cnt, - &format0_found, - &format_c_found, - &CCEmap0, - &CCEmap1, - &CCEmap2); - - if ((CCEmap0==0xffff)|| - ((format0_found==1)&&(format_c_found==1))) - return(dci_cnt); - - if (dci_cnt>old_dci_cnt) - return(dci_cnt); - - //#endif //ALL_AGGREGATION - - } - - return(dci_cnt); -} -*/ #ifdef PHY_ABSTRACTION uint16_t dci_decoding_procedure_emul(NR_UE_PDCCH **pdcch_vars, uint8_t num_ue_spec_dci, diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c index 72c575d49f..e45cb1de9d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c @@ -54,3906 +54,12 @@ typedef unsigned __int128 uint128_t; - -#if 0 - -uint32_t localRIV2alloc_LUT6[32]; -uint32_t distRIV2alloc_even_LUT6[32]; -uint32_t distRIV2alloc_odd_LUT6[32]; -uint16_t RIV2nb_rb_LUT6[32]; -uint16_t RIV2first_rb_LUT6[32]; -uint16_t RIV_max6=0; - -uint32_t localRIV2alloc_LUT25[512]; -uint32_t distRIV2alloc_even_LUT25[512]; -uint32_t distRIV2alloc_odd_LUT25[512]; -uint16_t RIV2nb_rb_LUT25[512]; -uint16_t RIV2first_rb_LUT25[512]; -uint16_t RIV_max25=0; - - -uint32_t localRIV2alloc_LUT50_0[1600]; -uint32_t localRIV2alloc_LUT50_1[1600]; -uint32_t distRIV2alloc_gap0_even_LUT50_0[1600]; -uint32_t distRIV2alloc_gap0_odd_LUT50_0[1600]; -uint32_t distRIV2alloc_gap0_even_LUT50_1[1600]; -uint32_t distRIV2alloc_gap0_odd_LUT50_1[1600]; -uint32_t distRIV2alloc_gap1_even_LUT50_0[1600]; -uint32_t distRIV2alloc_gap1_odd_LUT50_0[1600]; -uint32_t distRIV2alloc_gap1_even_LUT50_1[1600]; -uint32_t distRIV2alloc_gap1_odd_LUT50_1[1600]; -uint16_t RIV2nb_rb_LUT50[1600]; -uint16_t RIV2first_rb_LUT50[1600]; -uint16_t RIV_max50=0; - -uint32_t localRIV2alloc_LUT100_0[6000]; -uint32_t localRIV2alloc_LUT100_1[6000]; -uint32_t localRIV2alloc_LUT100_2[6000]; -uint32_t localRIV2alloc_LUT100_3[6000]; -uint32_t distRIV2alloc_gap0_even_LUT100_0[6000]; -uint32_t distRIV2alloc_gap0_odd_LUT100_0[6000]; -uint32_t distRIV2alloc_gap0_even_LUT100_1[6000]; -uint32_t distRIV2alloc_gap0_odd_LUT100_1[6000]; -uint32_t distRIV2alloc_gap0_even_LUT100_2[6000]; -uint32_t distRIV2alloc_gap0_odd_LUT100_2[6000]; -uint32_t distRIV2alloc_gap0_even_LUT100_3[6000]; -uint32_t distRIV2alloc_gap0_odd_LUT100_3[6000]; -uint32_t distRIV2alloc_gap1_even_LUT100_0[6000]; -uint32_t distRIV2alloc_gap1_odd_LUT100_0[6000]; -uint32_t distRIV2alloc_gap1_even_LUT100_1[6000]; -uint32_t distRIV2alloc_gap1_odd_LUT100_1[6000]; -uint32_t distRIV2alloc_gap1_even_LUT100_2[6000]; -uint32_t distRIV2alloc_gap1_odd_LUT100_2[6000]; -uint32_t distRIV2alloc_gap1_even_LUT100_3[6000]; -uint32_t distRIV2alloc_gap1_odd_LUT100_3[6000]; -uint16_t RIV2nb_rb_LUT100[6000]; -uint16_t RIV2first_rb_LUT100[6000]; -uint16_t RIV_max100=0; - - -extern uint32_t current_dlsch_cqi; - -// Table 8.6.3-3 36.213 -uint16_t beta_cqi[16] = {0, //reserved - 0, //reserved - 9, //1.125 - 10, //1.250 - 11, //1.375 - 13, //1.625 - 14, //1.750 - 16, //2.000 - 18, //2.250 - 20, //2.500 - 23, //2.875 - 25, //3.125 - 28, //3.500 - 32, //4.000 - 40, //5.000 - 50 - }; //6.250 - -// Table 8.6.3-2 36.213 -uint16_t beta_ri[16] = {10, //1.250 - 13, //1.625 - 16, //2.000 - 20, //2.500 - 25, //3.125 - 32, //4.000 - 40, //5.000 - 50, //6.250 - 64, //8.000 - 80, //10.000 - 101, //12.625 - 127, //15.875 - 160, //20.000 - 0, //reserved - 0, //reserved - 0 - }; //reserved - -// Table 8.6.3-2 36.213 -uint16_t beta_ack[16] = {16, //2.000 - 20, //2.500 - 25, //3.125 - 32, //4.000 - 40, //5.000 - 50, //6.250 - 64, //8.000 - 80, //10.000 - 101, //12.625 - 127, //15.875 - 160, //20.000 - 248, //31.000 - 400, //50.000 - 640, //80.000 - 808 - };//126.00 - - -#endif int8_t nr_delta_PUSCH_abs[4] = {-4,-1,1,4}; int8_t nr_delta_PUSCH_acc[4] = {-1,0,1,3}; int8_t *nr_delta_PUCCH_lut = nr_delta_PUSCH_acc; -#if 0 -void conv_rballoc(uint8_t ra_header,uint32_t rb_alloc,uint32_t N_RB_DL,uint32_t *rb_alloc2) -{ - uint32_t i,shift,subset; - rb_alloc2[0] = 0; - rb_alloc2[1] = 0; - rb_alloc2[2] = 0; - rb_alloc2[3] = 0; - // printf("N_RB_DL %d, ra_header %d, rb_alloc %x\n",N_RB_DL,ra_header,rb_alloc); - - switch (N_RB_DL) { - - case 6: - rb_alloc2[0] = rb_alloc&0x3f; - break; - - case 25: - if (ra_header == 0) {// Type 0 Allocation - - for (i=12; i>0; i--) { - if ((rb_alloc&(1<>1)&1; - - for (i=0; i<11; i++) { - if ((rb_alloc&(1<<(i+2))) != 0) - rb_alloc2[0] |= (1<<(2*i)); - - //printf("rb_alloc2 (type 1) %x\n",rb_alloc2); - } - - if ((shift == 0) && (subset == 1)) - rb_alloc2[0]<<=1; - else if ((shift == 1) && (subset == 0)) - rb_alloc2[0]<<=4; - else if ((shift == 1) && (subset == 1)) - rb_alloc2[0]<<=3; - } - - break; - - case 50: - if (ra_header == 0) {// Type 0 Allocation - - for (i=16; i>0; i--) { - if ((rb_alloc&(1<>5] |= (7<<((3*(16-i))%32)); - } - - /* - for (i=1;i<=16;i++) { - if ((rb_alloc&(1<<(16-i))) != 0) - rb_alloc2[(3*i)>>5] |= (7<<((3*i)%32)); - } - */ - // bit mask across - if ((rb_alloc2[0]>>31)==1) - rb_alloc2[1] |= 1; - - if ((rb_alloc&1) != 0) - rb_alloc2[1] |= (3<<16); - - /* - for (i=0;i<16;i++) { - if (((rb_alloc>>(16-i))&1) != 0) - rb_alloc2[(3*i)>>5] |= (7<<((3*i)%32)); - if ((i==10)&&((rb_alloc&(1<<6))!=0)) - rb_alloc2[1] = 1; - // printf("rb_alloc2[%d] (type 0) %x ((%x>>%d)&1=%d)\n",(3*i)>>5,rb_alloc2[(3*i)>>5],rb_alloc,i,(rb_alloc>>i)&1); - - } - // fill in 2 from last bit instead of 3 - if ((rb_alloc&1) != 0) - rb_alloc2[1] |= (3<>%d)&1=%d)\n",(3*i)>>5,rb_alloc2[(3*i)>>5],rb_alloc,i,(rb_alloc>>i)&1); - */ - // printf("rb_alloc[1]=%x,rb_alloc[0]=%x\n",rb_alloc2[1],rb_alloc2[0]); - } else { - LOG_E(PHY,"resource type 1 not supported for N_RB_DL=50\n"); - // mac_xface->macphy_exit("resource type 1 not supported for N_RB_DL=100\n"); - /* - subset = rb_alloc&1; - shift = (rb_alloc>>1)&1; - for (i=0;i<11;i++) { - if ((rb_alloc&(1<<(i+2))) != 0) - rb_alloc2 |= (1<<(2*i)); - // printf("rb_alloc2 (type 1) %x\n",rb_alloc2); - } - if ((shift == 0) && (subset == 1)) - rb_alloc2<<=1; - else if ((shift == 1) && (subset == 0)) - rb_alloc2<<=4; - else if ((shift == 1) && (subset == 1)) - rb_alloc2<<=3; - */ - } - - break; - - case 100: - if (ra_header == 0) {// Type 0 Allocation - for (i=0; i<25; i++) { - if ((rb_alloc&(1<<(24-i))) != 0) - rb_alloc2[(4*i)>>5] |= (0xf<<((4*i)%32)); - - // printf("rb_alloc2[%d] (type 0) %x (%d)\n",(4*i)>>5,rb_alloc2[(4*i)>>5],rb_alloc&(1<macphy_exit("resource type 1 not supported for N_RB_DL=100\n"); - /* - subset = rb_alloc&1; - shift = (rb_alloc>>1)&1; - for (i=0;i<11;i++) { - if ((rb_alloc&(1<<(i+2))) != 0) - rb_alloc2 |= (1<<(2*i)); - // printf("rb_alloc2 (type 1) %x\n",rb_alloc2); - } - if ((shift == 0) && (subset == 1)) - rb_alloc2<<=1; - else if ((shift == 1) && (subset == 0)) - rb_alloc2<<=4; - else if ((shift == 1) && (subset == 1)) - rb_alloc2<<=3; - */ - } - - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", N_RB_DL); - DevParam (N_RB_DL, 0, 0); - break; - } - -} - - - -uint32_t conv_nprb(uint8_t ra_header,uint32_t rb_alloc,int N_RB_DL) -{ - - uint32_t nprb=0,i; - - switch (N_RB_DL) { - case 6: - for (i=0; i<6; i++) { - if ((rb_alloc&(1<0; i--) { - if ((rb_alloc&(1<>1))) - RIV = (N_RB_DL*(Lcrbs-1)) + RBstart; - else - RIV = (N_RB_DL*(N_RB_DL+1-Lcrbs)) + (N_RB_DL-1-RBstart); - - return(RIV); -} - -// Convert a DCI Format 1C RIV to a Format 1A RIV -// This extracts the start and length in PRBs from the 1C rballoc and -// recomputes the RIV as if it were the 1A rballoc - -uint32_t conv_1C_RIV(int32_t rballoc,uint32_t N_RB_DL) { - - int NpDLVRB,N_RB_step,LpCRBsm1,RBpstart; - - switch (N_RB_DL) { - - case 6: // N_RB_step = 2, NDLVRB = 6, NpDLVRB = 3 - NpDLVRB = 3; - N_RB_step = 2; - break; - case 25: // N_RB_step = 2, NDLVRB = 24, NpDLVRB = 12 - NpDLVRB = 12; - N_RB_step = 2; - break; - case 50: // N_RB_step = 4, NDLVRB = 46, NpDLVRB = 11 - NpDLVRB = 11; - N_RB_step = 4; - break; - case 100: // N_RB_step = 4, NDLVRB = 96, NpDLVRB = 24 - NpDLVRB = 24; - N_RB_step = 4; - break; - default: - NpDLVRB = 24; - N_RB_step = 4; - break; - } - - // This is the 1C part from 7.1.6.3 in 36.213 - LpCRBsm1 = rballoc/NpDLVRB; - // printf("LpCRBs = %d\n",LpCRBsm1+1); - - if (LpCRBsm1 <= (NpDLVRB/2)) { - RBpstart = rballoc % NpDLVRB; - } - else { - LpCRBsm1 = NpDLVRB-LpCRBsm1; - RBpstart = NpDLVRB-(rballoc%NpDLVRB); - } - // printf("RBpstart %d\n",RBpstart); - return(computeRIV(N_RB_DL,N_RB_step*RBpstart,N_RB_step*(LpCRBsm1+1))); - -} - -uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) { - - int offset; - - switch (N_RB_DL) { - - case 6: - // N_RB_DL = tildeN_RB_DL = 6 - // Ngap = 4 , P=1, Nrow = 2, Nnull = 2 - - switch (vrb) { - case 0: // even: 0->0, 1->2, odd: 0->3, 1->5 - case 1: - return ((3*odd_slot) + 2*(vrb&3))%6; - break; - case 2: // even: 2->3, 3->5, odd: 2->0, 3->2 - case 3: - return ((3*odd_slot) + 2*(vrb&3) + 5)%6; - break; - case 4: // even: 4->1, odd: 4->4 - return ((3*odd_slot) + 1)%6; - case 5: // even: 5->4, odd: 5->1 - return ((3*odd_slot) + 4)%6; - break; - } - break; - - case 15: - if (vrb<12) { - if ((vrb&3) < 2) // even: 0->0, 1->4, 4->1, 5->5, 8->2, 9->6 odd: 0->7, 1->11 - return(((7*odd_slot) + 4*(vrb&3) + (vrb>>2))%14) + 14*(vrb/14); - else if (vrb < 12) // even: 2->7, 3->11, 6->8, 7->12, 10->9, 11->13 - return (((7*odd_slot) + 4*(vrb&3) + (vrb>>2) +13 )%14) + 14*(vrb/14); - } - if (vrb==12) - return (3+(7*odd_slot)) % 14; - if (vrb==13) - return (10+(7*odd_slot)) % 14; - return 14; - break; - - case 25: - return (((12*odd_slot) + 6*(vrb&3) + (vrb>>2))%24) + 24*(vrb/24); - break; - - case 50: // P=3 - if (Ngap==0) { - // Nrow=12,Nnull=2,NVRBDL=46,Ngap1= 27 - if (vrb>=23) - offset=4; - else - offset=0; - if (vrb<44) { - if ((vrb&3)>=2) - return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2) + 45)%46; - else - return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2))%46; - } - if (vrb==44) // even: 44->11, odd: 45->34 - return offset+((23*odd_slot) + 22-12+1); - if (vrb==45) // even: 45->10, odd: 45->33 - return offset+((23*odd_slot) + 22+12); - if (vrb==46) - return offset+46+((23*odd_slot) + 23-12+1) % 46; - if (vrb==47) - return offset+46+((23*odd_slot) + 23+12) % 46; - if (vrb==48) - return offset+46+((23*odd_slot) + 23-12+1) % 46; - if (vrb==49) - return offset+46+((23*odd_slot) + 23+12) % 46; - } - else { - // Nrow=6,Nnull=6,NVRBDL=18,Ngap1= 27 - if (vrb>=9) - offset=18; - else - offset=0; - - if (vrb<12) { - if ((vrb&3)>=2) - return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2) + 17)%18; - else - return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2))%18; - } - else { - return offset+((9*odd_slot) + 12*(vrb&1)+(vrb>>1) )%18 + 18*(vrb/18); - } - } - break; - case 75: - // Ngap1 = 32, NVRBRL=64, P=4, Nrow= 16, Nnull=0 - if (Ngap ==0) { - return ((32*odd_slot) + 16*(vrb&3) + (vrb>>2))%64 + (vrb/64); - } else { - // Ngap2 = 16, NVRBDL=32, Nrow=8, Nnull=0 - return ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); - } - break; - case 100: - // Ngap1 = 48, NVRBDL=96, Nrow=24, Nnull=0 - if (Ngap ==0) { - return ((48*odd_slot) + 24*(vrb&3) + (vrb>>2))%96 + (vrb/96); - } else { - // Ngap2 = 16, NVRBDL=32, Nrow=8, Nnull=0 - return ((16*odd_slot) + 8*(vrb&3) + (vrb>>2))%32 + (vrb/32); - } - break; - default: - LOG_E(PHY,"Unknown N_RB_DL %d\n",N_RB_DL); - return 0; - } - return 0; - -} - - -void generate_RIV_tables() -{ - - // 6RBs localized RIV - uint8_t Lcrbs,RBstart; - uint16_t RIV; - uint32_t alloc0,allocdist0_0_even,allocdist0_0_odd,allocdist0_1_even,allocdist0_1_odd; - uint32_t alloc1,allocdist1_0_even,allocdist1_0_odd,allocdist1_1_even,allocdist1_1_odd; - uint32_t alloc2,allocdist2_0_even,allocdist2_0_odd,allocdist2_1_even,allocdist2_1_odd; - uint32_t alloc3,allocdist3_0_even,allocdist3_0_odd,allocdist3_1_even,allocdist3_1_odd; - uint32_t nVRB,nVRB_even_dist,nVRB_odd_dist; - - for (RBstart=0; RBstart<6; RBstart++) { - alloc0 = 0; - allocdist0_0_even = 0; - allocdist0_0_odd = 0; - for (Lcrbs=1; Lcrbs<=(6-RBstart); Lcrbs++) { - //printf("RBstart %d, len %d --> ",RBstart,Lcrbs); - nVRB = Lcrbs-1+RBstart; - alloc0 |= (1<RIV_max6) - RIV_max6 = RIV; - - // printf("RIV %d (%d) : first_rb %d NBRB %d\n",RIV,localRIV2alloc_LUT25[RIV],RBstart,Lcrbs); - localRIV2alloc_LUT6[RIV] = alloc0; - distRIV2alloc_even_LUT6[RIV] = allocdist0_0_even; - distRIV2alloc_odd_LUT6[RIV] = allocdist0_0_odd; - RIV2nb_rb_LUT6[RIV] = Lcrbs; - RIV2first_rb_LUT6[RIV] = RBstart; - } - } - - - for (RBstart=0; RBstart<25; RBstart++) { - alloc0 = 0; - allocdist0_0_even = 0; - allocdist0_0_odd = 0; - for (Lcrbs=1; Lcrbs<=(25-RBstart); Lcrbs++) { - nVRB = Lcrbs-1+RBstart; - //printf("RBstart %d, len %d --> ",RBstart,Lcrbs); - alloc0 |= (1<RIV_max25) - RIV_max25 = RIV;; - - - localRIV2alloc_LUT25[RIV] = alloc0; - distRIV2alloc_even_LUT25[RIV] = allocdist0_0_even; - distRIV2alloc_odd_LUT25[RIV] = allocdist0_0_odd; - RIV2nb_rb_LUT25[RIV] = Lcrbs; - RIV2first_rb_LUT25[RIV] = RBstart; - } - } - - - for (RBstart=0; RBstart<50; RBstart++) { - alloc0 = 0; - alloc1 = 0; - allocdist0_0_even=0; - allocdist1_0_even=0; - allocdist0_0_odd=0; - allocdist1_0_odd=0; - allocdist0_1_even=0; - allocdist1_1_even=0; - allocdist0_1_odd=0; - allocdist1_1_odd=0; - - for (Lcrbs=1; Lcrbs<=(50-RBstart); Lcrbs++) { - - nVRB = Lcrbs-1+RBstart; - - - if (nVRB<32) - alloc0 |= (1<RIV_max50) - RIV_max50 = RIV; - - // printf("RIV %d : first_rb %d NBRB %d\n",RIV,RBstart,Lcrbs); - localRIV2alloc_LUT50_0[RIV] = alloc0; - localRIV2alloc_LUT50_1[RIV] = alloc1; - distRIV2alloc_gap0_even_LUT50_0[RIV] = allocdist0_0_even; - distRIV2alloc_gap0_even_LUT50_1[RIV] = allocdist1_0_even; - distRIV2alloc_gap0_odd_LUT50_0[RIV] = allocdist0_0_odd; - distRIV2alloc_gap0_odd_LUT50_1[RIV] = allocdist1_0_odd; - distRIV2alloc_gap1_even_LUT50_0[RIV] = allocdist0_1_even; - distRIV2alloc_gap1_even_LUT50_1[RIV] = allocdist1_1_even; - distRIV2alloc_gap1_odd_LUT50_0[RIV] = allocdist0_1_odd; - distRIV2alloc_gap1_odd_LUT50_1[RIV] = allocdist1_1_odd; - RIV2nb_rb_LUT50[RIV] = Lcrbs; - RIV2first_rb_LUT50[RIV] = RBstart; - } - } - - - for (RBstart=0; RBstart<100; RBstart++) { - alloc0 = 0; - alloc1 = 0; - alloc2 = 0; - alloc3 = 0; - allocdist0_0_even=0; - allocdist1_0_even=0; - allocdist2_0_even=0; - allocdist3_0_even=0; - allocdist0_0_odd=0; - allocdist1_0_odd=0; - allocdist2_0_odd=0; - allocdist3_0_odd=0; - allocdist0_1_even=0; - allocdist1_1_even=0; - allocdist2_1_even=0; - allocdist3_1_even=0; - allocdist0_1_odd=0; - allocdist1_1_odd=0; - allocdist2_1_odd=0; - allocdist3_1_odd=0; - - for (Lcrbs=1; Lcrbs<=(100-RBstart); Lcrbs++) { - - nVRB = Lcrbs-1+RBstart; - - if (nVRB<32) - alloc0 |= (1< nVRB_even_dist %d\n",nVRB,nVRB_even_dist); - - - if (nVRB_even_dist<32) - allocdist0_0_even |= (1<(%08x.%08x.%08x.%08x)\n", - allocdist0_0_even, - allocdist1_0_even, - allocdist2_0_even, - allocdist3_0_even - ); -*/ - // Distributed Gap1, odd slot - nVRB_odd_dist = get_prb(100,1,nVRB,0); - if (nVRB_odd_dist<32) - allocdist0_0_odd |= (1<RIV_max100) - RIV_max100 = RIV; - - // printf("RIV %d : first_rb %d NBRB %d\n",RIV,RBstart,Lcrbs); - localRIV2alloc_LUT100_0[RIV] = alloc0; - localRIV2alloc_LUT100_1[RIV] = alloc1; - localRIV2alloc_LUT100_2[RIV] = alloc2; - localRIV2alloc_LUT100_3[RIV] = alloc3; - distRIV2alloc_gap0_even_LUT100_0[RIV] = allocdist0_0_even; - distRIV2alloc_gap0_even_LUT100_1[RIV] = allocdist1_0_even; - distRIV2alloc_gap0_even_LUT100_2[RIV] = allocdist2_0_even; - distRIV2alloc_gap0_even_LUT100_3[RIV] = allocdist3_0_even; - distRIV2alloc_gap0_odd_LUT100_0[RIV] = allocdist0_0_odd; - distRIV2alloc_gap0_odd_LUT100_1[RIV] = allocdist1_0_odd; - distRIV2alloc_gap0_odd_LUT100_2[RIV] = allocdist2_0_odd; - distRIV2alloc_gap0_odd_LUT100_3[RIV] = allocdist3_0_odd; - distRIV2alloc_gap1_even_LUT100_0[RIV] = allocdist0_1_even; - distRIV2alloc_gap1_even_LUT100_1[RIV] = allocdist1_1_even; - distRIV2alloc_gap1_even_LUT100_2[RIV] = allocdist2_1_even; - distRIV2alloc_gap1_even_LUT100_3[RIV] = allocdist3_1_even; - distRIV2alloc_gap1_odd_LUT100_0[RIV] = allocdist0_1_odd; - distRIV2alloc_gap1_odd_LUT100_1[RIV] = allocdist1_1_odd; - distRIV2alloc_gap1_odd_LUT100_2[RIV] = allocdist2_1_odd; - distRIV2alloc_gap1_odd_LUT100_3[RIV] = allocdist3_1_odd; - - RIV2nb_rb_LUT100[RIV] = Lcrbs; - RIV2first_rb_LUT100[RIV] = RBstart; - } - } -} - -// Ngap = 3, N_VRB_DL=6, P=1, N_row=2, N_null=4*2-6=2 -// permutation for even slots : -// n_PRB'(0,2,4) = (0,1,2), n_PRB'(1,3,5) = (4,5,6) -// n_PRB''(0,1,2,3) = (0,2,4,6) -// => n_tilde_PRB(5) = (4) -// n_tilde_PRB(4) = (1) -// n_tilde_PRB(2,3) = (3,5) -// n_tilde_PRB(0,1) = (0,2) - - - -uint32_t get_rballoc(vrb_t vrb_type,uint16_t rb_alloc_dci) -{ - - return(localRIV2alloc_LUT25[rb_alloc_dci]); - -} - -uint8_t get_transmission_mode(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti) -{ - unsigned char UE_id; - - // find the UE_index corresponding to rnti - UE_id = find_ue(rnti,PHY_vars_eNB_g[Mod_id][CC_id]); - DevAssert( UE_id != (unsigned char)-1 ); - - return(PHY_vars_eNB_g[Mod_id][CC_id]->transmission_mode[UE_id]); -} - -int generate_eNB_dlsch_params_from_dci(int frame, - uint8_t subframe, - void *dci_pdu, - uint16_t rnti, - DCI_format_t dci_format, - LTE_eNB_DLSCH_t **dlsch, - NR_DL_FRAME_PARMS *frame_parms, - PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint16_t DL_pmi_single, - uint8_t beamforming_mode) -{ - - uint8_t harq_pid = UINT8_MAX; - uint32_t rballoc = UINT32_MAX; - uint32_t RIV_max = 0; - uint8_t NPRB,tbswap,tpmi=0; - LTE_eNB_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; - uint8_t frame_type=frame_parms->frame_type; - uint8_t vrb_type=0; - uint8_t mcs=0,mcs1=0,mcs2=0; - uint8_t I_mcs = 0; - uint8_t rv=0,rv1=0,rv2=0; - uint8_t rah=0; - uint8_t TPC=0; - uint8_t TB0_active=0,TB1_active=0; - LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; - - // printf("Generate eNB DCI, format %d, rnti %x (pdu %p)\n",dci_format,rnti,dci_pdu); - - switch (dci_format) { - - case format0: - return(-1); - break; - - case format1A: // This is DLSCH allocation for control traffic - - - - dlsch[0]->subframe_tx[subframe] = 1; - - - switch (frame_parms->N_RB_DL) { - case 6: - if (frame_type == TDD) { - vrb_type = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->rv; - TPC = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); - } else { - vrb_type = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->harq_pid; - - // printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); - } - - dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - dlsch0_harq->codeword=0; - - if (vrb_type==LOCALIZED) { - dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT6[rballoc]; - } - else { - LOG_E(PHY,"Distributed RB allocation not done yet\n"); - mac_xface->macphy_exit("exiting"); - } - dlsch0_harq->vrb_type = vrb_type; - dlsch0_harq->nb_rb = RIV2nb_rb_LUT6[rballoc];//NPRB; - RIV_max = RIV_max6; - - - break; - - case 25: - if (frame_type == TDD) { - vrb_type = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rv; - TPC = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); - } else { - vrb_type = ((DCI1A_5MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_5MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1A_5MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_5MHz_FDD_t *)dci_pdu)->harq_pid; - - // printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); - } - - dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - - - if (vrb_type==LOCALIZED) { - dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT25[rballoc]; - } - else { - LOG_E(PHY,"Distributed RB allocation not done yet\n"); - mac_xface->macphy_exit("exiting"); - } - dlsch0_harq->vrb_type = vrb_type; - dlsch0_harq->nb_rb = RIV2nb_rb_LUT25[rballoc];//NPRB; - RIV_max = RIV_max25; - break; - - case 50: - if (frame_type == TDD) { - vrb_type = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rv; - TPC = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); - } else { - vrb_type = ((DCI1A_10MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_10MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_10MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_10MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1A_10MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_10MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } - - dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - if (vrb_type==LOCALIZED) { - dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT50_0[rballoc]; - dlsch0_harq->rb_alloc[1] = localRIV2alloc_LUT50_1[rballoc]; - } - else { - LOG_E(PHY,"Distributed RB allocation not done yet\n"); - mac_xface->macphy_exit("exiting"); - } - - - dlsch0_harq->vrb_type = vrb_type; - dlsch0_harq->nb_rb = RIV2nb_rb_LUT50[rballoc];//NPRB; - RIV_max = RIV_max50; - break; - - case 100: - if (frame_type == TDD) { - vrb_type = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rv; - TPC = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); - } else { - vrb_type = ((DCI1A_20MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_20MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_20MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_20MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1A_20MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_20MHz_FDD_t *)dci_pdu)->harq_pid; - // printf("FDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); - } - - dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - - dlsch0_harq->vrb_type = vrb_type; - if (vrb_type==LOCALIZED) { - dlsch0_harq->rb_alloc[0] = localRIV2alloc_LUT100_0[rballoc]; - dlsch0_harq->rb_alloc[1] = localRIV2alloc_LUT100_1[rballoc]; - dlsch0_harq->rb_alloc[2] = localRIV2alloc_LUT100_2[rballoc]; - dlsch0_harq->rb_alloc[3] = localRIV2alloc_LUT100_3[rballoc]; - } - else { - LOG_E(PHY,"Distributed RB allocation not done yet\n"); - mac_xface->macphy_exit("exiting"); - } - - - - dlsch0_harq->nb_rb = RIV2nb_rb_LUT100[rballoc];//NPRB; - RIV_max = RIV_max100; - break; - - default: - LOG_E(PHY,"Invalid N_RB_D %dL\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - // harq_pid field is reserved - if ((rnti==si_rnti) || (rnti==ra_rnti) || (rnti==p_rnti)) { // - harq_pid=0; - // see 36-212 V8.6.0 p. 45 - NPRB = (TPC&1)+2; - // 36-213 sec.7.1.7.2 p.26 - I_mcs = mcs; - } else { - if (harq_pid>=8) { - LOG_E(PHY,"ERROR: Format 1A: harq_pid=%d >= 8\n", harq_pid); - return(-1); - } - - if (rballoc>RIV_max) { - LOG_E(PHY,"ERROR: Format 1A: rb_alloc (%x) > RIV_max (%x)\n",rballoc,RIV_max); - return(-1); - } - - NPRB = dlsch0_harq->nb_rb; - I_mcs = get_I_TBS(mcs); - } - - if (NPRB==0) - return(-1); - - //printf("NPRB %d, nb_rb %d, ndi %d\n",NPRB,dlsch0_harq->nb_rb,ndi); - dlsch0_harq->rvidx = rv; - - dlsch0_harq->Nl = 1; - //dlsch0_harq->layer_index = 0; - - dlsch0_harq->mimo_mode = (frame_parms->mode1_flag == 1) ? SISO : ALAMOUTI; - /* - if ((rnti!=si_rnti)&&(rnti!=ra_rnti)&&(rnti!=p_rnti)) { //handle toggling for C-RNTI - if (dlsch0_harq->first_tx == 1) { - LOG_D(PHY,"First TX for TC-RNTI %x, clearing first_tx flag\n",rnti); - dlsch0_harq->first_tx=0; - dlsch0_harq->Ndi = 1; - } - else { - if (ndi == dlsch0_harq->DCINdi) - dlsch0_harq->Ndi = 0; - else - dlsch0_harq->Ndi = 1; - } - - dlsch0_harq->DCINdi=ndi; - } - else { - dlsch0_harq->Ndi = 1; - } - */ - dlsch0_harq->dl_power_off = 1; - - - - dlsch0_harq->mcs = mcs; - dlsch0_harq->TBS = TBStable[I_mcs][NPRB-1]; - - dlsch[0]->current_harq_pid = harq_pid; - dlsch[0]->harq_ids[subframe] = harq_pid; - - dlsch[0]->active = 1; - dlsch0 = dlsch[0]; - - dlsch[0]->rnti = rnti; - - dlsch[0]->harq_ids[subframe] = harq_pid; - - if (dlsch0_harq->round == 0) - dlsch0_harq->status = ACTIVE; - - break; - - case format1: - - switch (frame_parms->N_RB_DL) { - - case 6: - if (frame_type == TDD) { - mcs = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rv; - harq_pid = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rv; - harq_pid = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 25: - - if (frame_type == TDD) { - mcs = ((DCI1_5MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_5MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_5MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_5MHz_TDD_t *)dci_pdu)->rv; - harq_pid = ((DCI1_5MHz_TDD_t *)dci_pdu)->harq_pid; - LOG_D(PHY,"eNB: subframe %d UE %x, Format1 DCI: ndi %d, harq_pid %d\n",subframe,rnti,((DCI1_5MHz_TDD_t *)dci_pdu)->ndi,harq_pid); - } else { - mcs = ((DCI1_5MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_5MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_5MHz_FDD_t *)dci_pdu)->rv; - harq_pid = ((DCI1_5MHz_FDD_t *)dci_pdu)->harq_pid; - LOG_D(PHY,"eNB: subframe %d UE %x, Format1 DCI: ndi %d, harq_pid %d\n",subframe,rnti,((DCI1_5MHz_FDD_t *)dci_pdu)->ndi,harq_pid); - - } - - break; - - case 50: - if (frame_type == TDD) { - mcs = ((DCI1_10MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_10MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_10MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_10MHz_TDD_t *)dci_pdu)->rv; - harq_pid = ((DCI1_10MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_10MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_10MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_10MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_10MHz_FDD_t *)dci_pdu)->rv; - harq_pid = ((DCI1_10MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 100: - if (frame_type == TDD) { - mcs = ((DCI1_20MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_20MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_20MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_20MHz_TDD_t *)dci_pdu)->rv; - harq_pid = ((DCI1_20MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_20MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_20MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_20MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_20MHz_FDD_t *)dci_pdu)->rv; - harq_pid = ((DCI1_20MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - } - - if (harq_pid>=8) { - LOG_E(PHY,"ERROR: Format 1: harq_pid=%d >= 8\n", harq_pid); - return(-1); - } - - dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - dlsch0_harq->codeword=0; - - // printf("DCI: Setting subframe_tx for subframe %d\n",subframe); - dlsch[0]->subframe_tx[subframe] = 1; - - conv_rballoc(rah, - rballoc,frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc); - - dlsch0_harq->nb_rb = conv_nprb(rah, - rballoc, - frame_parms->N_RB_DL); - - NPRB = dlsch0_harq->nb_rb; - - - if (NPRB==0) - return(-1); - - - dlsch0_harq->rvidx = rv; - - dlsch0_harq->Nl = 1; - // dlsch[0]->layer_index = 0; - if (beamforming_mode == 0) - dlsch0_harq->mimo_mode = (frame_parms->mode1_flag == 1) ? SISO : ALAMOUTI; - else if (beamforming_mode == 7) - dlsch0_harq->mimo_mode = TM7; - else - LOG_E(PHY,"Invalid beamforming mode %dL\n", beamforming_mode); - - dlsch0_harq->dl_power_off = 1; - /* - if (dlsch[0]->harq_processes[harq_pid]->first_tx == 1) { - LOG_D(PHY,"First TX for C-RNTI %x, clearing first_tx flag, shouldn't happen!\n",rnti); - dlsch[0]->harq_processes[harq_pid]->first_tx=0; - dlsch[0]->harq_processes[harq_pid]->Ndi = 1; - } - else { - LOG_D(PHY,"Checking for Toggled Ndi for C-RNTI %x, old value %d, DCINdi %d\n",rnti,dlsch[0]->harq_processes[harq_pid]->DCINdi,ndi); - if (ndi == dlsch[0]->harq_processes[harq_pid]->DCINdi) - dlsch[0]->harq_processes[harq_pid]->Ndi = 0; - else - dlsch[0]->harq_processes[harq_pid]->Ndi = 1; - } - dlsch[0]->harq_processes[harq_pid]->DCINdi=ndi; - */ - - dlsch[0]->active = 1; - - - - if (dlsch0_harq->round == 0) { - dlsch0_harq->status = ACTIVE; - // MCS and TBS don't change across HARQ rounds - dlsch0_harq->mcs = mcs; - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][NPRB-1]; - - } - - dlsch[0]->current_harq_pid = harq_pid; - dlsch[0]->harq_ids[subframe] = harq_pid; - - - - dlsch0 = dlsch[0]; - - dlsch[0]->rnti = rnti; - - - break; - - case format2: // DL Scheduling assignment for MIMO including closed loop spatial multiplexing - - switch (frame_parms->N_RB_DL) { - - case 6: - if (frame_parms->nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2_1_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_1_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_1_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_1_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_1_5MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_1_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_1_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_1_5MHz_2A_TDD_t *)dci_pdu)->tpmi; - } else { - mcs1 = ((DCI2_1_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_1_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_1_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_1_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_1_5MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_1_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_1_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_1_5MHz_2A_FDD_t *)dci_pdu)->tpmi; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2_1_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_1_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_1_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_1_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_1_5MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_1_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_1_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_1_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - } else { - mcs1 = ((DCI2_1_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_1_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_1_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_1_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_1_5MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_1_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_1_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_1_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - } - } else { - LOG_E(PHY,"eNB: subframe %d UE %x, Format2 DCI: unsupported number of TX antennas %d\n",subframe,rnti,frame_parms->nb_antenna_ports_eNB); - } - - break; - - case 25: - if (frame_parms->nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tpmi; - } else { - mcs1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - } else { - mcs1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - } - } else { - LOG_E(PHY,"eNB: subframe %d UE %x, Format2 DCI: unsupported number of TX antennas %d\n",subframe,rnti,frame_parms->nb_antenna_ports_eNB); - } - - break; - - case 50: - if (frame_parms->nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tpmi; - } else { - mcs1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tpmi; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->tpmi; - } else { - mcs1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->tpmi; - } - } else { - LOG_E(PHY,"eNB: subframe %d UE %x, Format2 DCI: unsupported number of TX antennas %d\n",subframe,rnti,frame_parms->nb_antenna_ports_eNB); - } - - break; - - case 100: - if (frame_parms->nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tpmi; - } else { - mcs1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tpmi; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->tpmi; - } else { - mcs1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->tpmi; - } - } else { - LOG_E(PHY,"eNB: subframe %d UE %x, Format2 DCI: unsupported number of TX antennas %d\n",subframe,rnti,frame_parms->nb_antenna_ports_eNB); - } - - break; - } - - if (harq_pid>=8) { - LOG_E(PHY,"ERROR: Format 2_2A: harq_pid=%d >= 8\n", harq_pid); - return(-1); - } - - - // Flip the TB to codeword mapping as described in 5.3.3.1.5 of 36-212 V11.3.0 - // note that we must set tbswap=0 in eNB scheduler if one TB is deactivated - TB0_active = 1; - TB1_active = 1; - - if ((rv1 == 1) && (mcs1 == 0)) { - TB0_active=0; - } - if ((rv2 == 1) && (mcs2 == 0)) { - TB1_active=0; - } -#ifdef DEBUG_HARQ - printf(" eNOdeB RV0 = %d, RV1 = %d. MCS0 = %d, MCS1=%d\n", rv1, rv2, mcs1, mcs2); -#endif - if (TB0_active && TB1_active && tbswap==0) { - dlsch0=dlsch[0]; - dlsch1=dlsch[1]; - dlsch0->active = 1; - dlsch1->active = 1; - dlsch0_harq = dlsch0->harq_processes[harq_pid]; - dlsch1_harq = dlsch1->harq_processes[harq_pid]; - dlsch0_harq->mcs = mcs1; - dlsch1_harq->mcs = mcs2; - dlsch0_harq->rvidx = rv1; - dlsch1_harq->rvidx = rv2; - dlsch0_harq->status = ACTIVE; - dlsch1_harq->status = ACTIVE; - dlsch0_harq->codeword=0; - dlsch1_harq->codeword=1; -#ifdef DEBUG_HARQ - printf("\n ENB: BOTH ACTIVE\n"); -#endif - } - else if (TB0_active && TB1_active && tbswap==1) { - dlsch0=dlsch[0]; - dlsch1=dlsch[1]; - dlsch0->active = 1; - dlsch1->active = 1; - dlsch0_harq = dlsch0->harq_processes[harq_pid]; - dlsch1_harq = dlsch1->harq_processes[harq_pid]; - dlsch0_harq->mcs = mcs1; - dlsch1_harq->mcs = mcs2; - dlsch0_harq->rvidx = rv1; - dlsch1_harq->rvidx = rv2; - dlsch0_harq->status = ACTIVE; - dlsch1_harq->status = ACTIVE; - dlsch0_harq->codeword=1; - dlsch1_harq->codeword=0; - } - else if (TB0_active && (TB1_active==0)) { - dlsch0=dlsch[0]; - dlsch0->active = 1; - dlsch0_harq = dlsch0->harq_processes[harq_pid]; - dlsch0_harq->mcs = mcs1; - dlsch0_harq->rvidx = rv1; - dlsch0_harq->status = ACTIVE; - dlsch0_harq->codeword = 0; - dlsch1=NULL; - dlsch1_harq = NULL; -#ifdef DEBUG_HARQ - printf("\n ENB: TB1 is deactivated, retransmit TB0 transmit in TM6\n"); -#endif - } - else if ((TB0_active==0) && TB1_active) { - dlsch1=dlsch[1]; - dlsch1->active = 1; - dlsch1_harq = dlsch1->harq_processes[harq_pid]; - dlsch1_harq->mcs = mcs2; - dlsch1_harq->rvidx = rv2; - dlsch1_harq->status = ACTIVE; - dlsch1_harq->codeword = 0; - dlsch0=NULL; - dlsch0_harq = NULL; -#ifdef DEBUG_HARQ - printf("\n ENB: TB0 is deactivated, retransmit TB1 transmit in TM6\n"); -#endif - } - // printf("[eNB] dlsch0_harq->round = %d, dlsch1_harq->round = %d \n", dlsch0_harq->round, dlsch1_harq->round); - - - if (dlsch0 != NULL){ - dlsch0->subframe_tx[subframe] = 1; - - dlsch0->current_harq_pid = harq_pid; - dlsch0->harq_ids[subframe] = harq_pid; - } - - if (dlsch1_harq != NULL){ - dlsch1->current_harq_pid = harq_pid; - dlsch1->harq_ids[subframe] = harq_pid; - } - - - if (dlsch0 != NULL ){ - conv_rballoc(rah, - rballoc, - frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc); - - dlsch0_harq->nb_rb = conv_nprb(rah, rballoc, frame_parms->N_RB_DL); - - if (dlsch1 != NULL){ - dlsch1_harq->rb_alloc[0] = dlsch0_harq->rb_alloc[0]; - dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; - } - } else if ((dlsch0 == NULL ) && (dlsch1 != NULL )){ - conv_rballoc(rah, - rballoc, - frame_parms->N_RB_DL, - dlsch1_harq->rb_alloc); - - dlsch1_harq->nb_rb = conv_nprb(rah, rballoc, frame_parms->N_RB_DL); - } - - - /*if (dlsch0_harq->nb_rb == 0) - return(-1);*/ - - - // assume both TBs are active - if (dlsch0_harq != NULL) - dlsch0_harq->Nl = 1; - if (dlsch1_harq != NULL) - dlsch1_harq->Nl = 1; - - - // check if either TB is disabled (see 36-213 V11.3 Section ) - - if (frame_parms->nb_antenna_ports_eNB == 2) { - if ((dlsch0 != NULL) && (dlsch1 != NULL)) { //two CW active - - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1]; - switch (tpmi) { - case 0: - dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1; - dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0,1); - dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,0,1); - break; - case 1: - dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj; - dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1,1); - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1,1); - - break; - case 2: // PUSCH precoding - dlsch0_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING; - dlsch0_harq->pmi_alloc = DL_pmi_single; - dlsch1_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING; - dlsch1_harq->pmi_alloc = DL_pmi_single; - break; - default: - break; - } - } else if ((dlsch0 != NULL) && (dlsch1 == NULL)) { // only CW 0 active - dlsch0_harq->dl_power_off = 1; - dlsch0_harq->TBS= TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - switch (tpmi) { - case 0 : - dlsch0_harq->mimo_mode = ALAMOUTI; - break; - case 1: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING11; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0,0); - break; - case 2: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1m1; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1,0); - break; - case 3: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1j; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,2,0); - break; - case 4: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1mj; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,3,0); - break; - case 5: - dlsch0_harq->mimo_mode = PUSCH_PRECODING0; - dlsch0_harq->pmi_alloc = DL_pmi_single; - break; - case 6: - dlsch0_harq->mimo_mode = PUSCH_PRECODING1; - dlsch0_harq->pmi_alloc = DL_pmi_single; - break; - } - } else if ((dlsch0 == NULL) && (dlsch1 != NULL)) { - dlsch1_harq->dl_power_off = 1; - dlsch1_harq->TBS= TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1]; - switch (tpmi) { - case 0 : - dlsch1_harq->mimo_mode = ALAMOUTI; - break; - case 1: - dlsch1_harq->mimo_mode = UNIFORM_PRECODING11; - dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,0,0); - break; - case 2: - dlsch1_harq->mimo_mode = UNIFORM_PRECODING1m1; - dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,1,0); - break; - case 3: - dlsch1_harq->mimo_mode = UNIFORM_PRECODING1j; - dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,2,0); - break; - case 4: - dlsch1_harq->mimo_mode = UNIFORM_PRECODING1mj; - dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,3,0); - break; - case 5: - dlsch1_harq->mimo_mode = PUSCH_PRECODING0; - dlsch1_harq->pmi_alloc = DL_pmi_single; - break; - case 6: - dlsch1_harq->mimo_mode = PUSCH_PRECODING1; - dlsch1_harq->pmi_alloc = DL_pmi_single; - break; - } - // printf ("[eNB] dlsch1_harq->pmi_alloc %d\n", dlsch1_harq->pmi_alloc); - } - - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - // fill in later - } - - // reset HARQ process if this is the first transmission - /* if (dlsch0_harq->round == 0) - dlsch0_harq->status = ACTIVE; - - if (dlsch1_harq->round == 0) - dlsch1_harq->status = ACTIVE;*/ - if (dlsch0_harq != NULL) - dlsch0->rnti = rnti; - if (dlsch1 != NULL) - dlsch1->rnti = rnti; - - - break; - - case format2A: - - switch (frame_parms->N_RB_DL) { - - case 6: - if (frame_parms->nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - } else { - mcs1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - } else { - mcs1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - } - } else { - LOG_E(PHY,"eNB: subframe %d UE %x, Format2A DCI: unsupported number of TX antennas %d\n",subframe,rnti,frame_parms->nb_antenna_ports_eNB); - } - - break; - - case 25: - if (frame_parms->nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - } else { - mcs1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - } else { - mcs1 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - } - } else { - LOG_E(PHY,"eNB: subframe %d UE %x, Format2A DCI: unsupported number of TX antennas %d\n",subframe,rnti,frame_parms->nb_antenna_ports_eNB); - } - - break; - - case 50: - if (frame_parms->nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->tb_swap; - } else { - mcs1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->tb_swap; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->tpmi; - } else { - mcs1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->tpmi; - } - } else { - LOG_E(PHY,"eNB: subframe %d UE %x, Format2A DCI: unsupported number of TX antennas %d\n",subframe,rnti,frame_parms->nb_antenna_ports_eNB); - } - - break; - - case 100: - if (frame_parms->nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->tb_swap; - } else { - mcs1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->tb_swap; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->tpmi; - } else { - mcs1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->tpmi; - } - } else { - LOG_E(PHY,"eNB: subframe %d UE %x, Format2A DCI: unsupported number of TX antennas %d\n",subframe,rnti,frame_parms->nb_antenna_ports_eNB); - } - - break; - } - - - if (harq_pid>=8) { - LOG_E(PHY,"ERROR: Format 2_2A: harq_pid=%d >= 8\n", harq_pid); - return(-1); - } - - - // Flip the TB to codeword mapping as described in 5.3.3.1.5 of 36-212 V11.3.0 - // note that we must set tbswap=0 in eNB scheduler if one TB is deactivated - // This must be set as in TM4, does not work properly now. - if (tbswap == 0) { - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - } else { - dlsch0 = dlsch[1]; - dlsch1 = dlsch[0]; - } - - dlsch0_harq = dlsch0->harq_processes[harq_pid]; - dlsch1_harq = dlsch1->harq_processes[harq_pid]; - - dlsch0->subframe_tx[subframe] = 1; - - dlsch0->current_harq_pid = harq_pid; - dlsch1->current_harq_pid = harq_pid; - dlsch0->harq_ids[subframe] = harq_pid; - dlsch1->harq_ids[subframe] = harq_pid; - // printf("Setting DLSCH harq id %d to subframe %d\n",harq_pid,subframe); - - - conv_rballoc(rah, - rballoc, - frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc); - - dlsch1_harq->rb_alloc[0] = dlsch0_harq->rb_alloc[0]; - dlsch0_harq->nb_rb = conv_nprb(rah, - rballoc, - frame_parms->N_RB_DL); - dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; - - if (dlsch0_harq->nb_rb == 0) - return(-1); - - dlsch0_harq->mcs = mcs1; - dlsch1_harq->mcs = mcs2; - dlsch0_harq->rvidx = rv1; - dlsch1_harq->rvidx = rv2; - - // assume both TBs are active - dlsch0_harq->Nl = 1; - dlsch1_harq->Nl = 1; - dlsch0->active = 1; - dlsch1->active = 1; - - - // check if either TB is disabled (see 36-213 V11.3 Section ) - if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) { - dlsch0->active = 0; - } - - if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) { - dlsch1->active = 0; - } - - // dlsch0_harq->dl_power_off = 0; - // dlsch1_harq->dl_power_off = 0; - - - if (frame_parms->nb_antenna_ports_eNB == 2) { - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch0_harq->nb_rb-1]; - - if ((dlsch0->active==1) && (dlsch1->active==1)) { - - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - } else { - dlsch0_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->mimo_mode = ALAMOUTI; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { // 4 antenna case - if ((dlsch0->active==1) && (dlsch1->active==1)) { - switch (tpmi) { - case 0: // one layer per transport block - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - break; - - case 1: // one-layers on TB 0, two on TB 1 - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->Nl = 2; - dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][(dlsch1_harq->nb_rb<<1)-1]; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - break; - - case 2: // two-layers on TB 0, two on TB 1 - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - - if (frame_parms->N_RB_DL <= 56) { - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][(dlsch0_harq->nb_rb<<1)-1]; - dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][(dlsch1_harq->nb_rb<<1)-1]; - } else { - LOG_E(PHY,"Add implementation of Table 7.1.7.2.2-1 for two-layer TBS conversion with N_RB_DL > 56\n"); - } - - break; - - case 3: // - LOG_E(PHY,"Illegal value (3) for TPMI in Format 2A DCI\n"); - break; - } - } else if (dlsch0->active == 1) { - switch (tpmi) { - case 0: // one layer per transport block - dlsch0_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->mimo_mode = ALAMOUTI; - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - break; - - case 1: // two-layers on TB 0 - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][(dlsch0_harq->nb_rb<<1)-1]; - break; - - case 2: // two-layers on TB 0, two on TB 1 - case 3: // - LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",tpmi); - break; - } - } else if (dlsch1->active == 1) { - switch (tpmi) { - case 0: // one layer per transport block - dlsch0_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1]; - break; - - case 1: // two-layers on TB 0 - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->Nl = 2; - dlsch1_harq->dl_power_off = 1; - dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][(dlsch1_harq->nb_rb<<1)-1]; - break; - - case 2: // two-layers on TB 0, two on TB 1 - case 3: // - LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",tpmi); - break; - } - } - } else { - LOG_E(PHY,"Illegal number of antennas for eNB %d\n",frame_parms->nb_antenna_ports_eNB); - } - - // reset HARQ process if this is the first transmission - if ((dlsch0->active==1) && (dlsch0_harq->round == 0)) - dlsch0_harq->status = ACTIVE; - - if ((dlsch1->active==1) && (dlsch1_harq->round == 0)) - dlsch1_harq->status = ACTIVE; - - dlsch0->rnti = rnti; - dlsch1->rnti = rnti; - - - // printf("eNB: Format 2A TBS0 %d, TBS1 %d\n",dlsch0_harq->TBS,dlsch1_harq->TBS); - - break; - - case format2B: - - switch (frame_parms->N_RB_DL) { - - case 6: - if (frame_type == TDD) { - mcs1 = ((DCI2B_1_5MHz_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2B_1_5MHz_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2B_1_5MHz_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2B_1_5MHz_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2B_1_5MHz_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2B_1_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs1 = ((DCI2B_1_5MHz_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2B_1_5MHz_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2B_1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2B_1_5MHz_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2B_1_5MHz_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2B_1_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 25: - if (frame_type == TDD) { - mcs1 = ((DCI2B_5MHz_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2B_5MHz_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2B_5MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2B_5MHz_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2B_5MHz_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2B_5MHz_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2B_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs1 = ((DCI2B_5MHz_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2B_5MHz_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2B_5MHz_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2B_5MHz_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2B_5MHz_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2B_5MHz_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2B_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 50: - if (frame_type == TDD) { - mcs1 = ((DCI2B_10MHz_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2B_10MHz_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2B_10MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2B_10MHz_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2B_10MHz_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2B_10MHz_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2B_10MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs1 = ((DCI2B_10MHz_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2B_10MHz_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2B_10MHz_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2B_10MHz_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2B_10MHz_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2B_10MHz_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2B_10MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 100: - if (frame_type == TDD) { - mcs1 = ((DCI2B_20MHz_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2B_20MHz_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2B_20MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2B_20MHz_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2B_20MHz_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2B_20MHz_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2B_20MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs1 = ((DCI2B_20MHz_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2B_20MHz_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2B_20MHz_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2B_20MHz_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2B_20MHz_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2B_20MHz_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2B_20MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - } - - - if (harq_pid>=8) { - LOG_E(PHY,"ERROR: Format 2_2A: harq_pid=%d >= 8\n", harq_pid); - return(-1); - } - - - - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - - - dlsch0->subframe_tx[subframe] = 1; - - dlsch0->current_harq_pid = harq_pid; - dlsch1->current_harq_pid = harq_pid; - dlsch0->harq_ids[subframe] = harq_pid; - dlsch1->harq_ids[subframe] = harq_pid; - // printf("Setting DLSCH harq id %d to subframe %d\n",harq_pid,subframe); - - - dlsch0_harq = dlsch0->harq_processes[harq_pid]; - dlsch1_harq = dlsch1->harq_processes[harq_pid]; - - // Needs to be checked - dlsch0_harq->codeword=0; - dlsch1_harq->codeword=1; - - conv_rballoc(rah, - rballoc, - frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc); - - dlsch1_harq->rb_alloc[0] = dlsch0_harq->rb_alloc[0]; - - dlsch0_harq->nb_rb = conv_nprb(rah, - rballoc, - frame_parms->N_RB_DL); - dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; - - dlsch0_harq->mcs = mcs1; - dlsch1_harq->mcs = mcs2; - dlsch0_harq->rvidx = rv1; - dlsch1_harq->rvidx = rv2; - - // check if either TB is disabled (see 36-213 V8.6 p. 26) - - - if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) - dlsch0_harq->status = DISABLED; - - if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) - dlsch1_harq->status = DISABLED; - - dlsch0_harq->Nl = 1; - - - if (dlsch0_harq->round == 0) { - dlsch0_harq->status = ACTIVE; - // printf("Setting DLSCH process %d to ACTIVE\n",harq_pid); - } - - dlsch0_harq->mcs = mcs1; - - if (dlsch0_harq->nb_rb > 0) { - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - } else { - dlsch0_harq->TBS = 0; - } - - dlsch0->active = 1; - - dlsch0->rnti = rnti; - dlsch1->rnti = rnti; - - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - - break; - - case format2C: - - switch (frame_parms->N_RB_DL) { - - case 6: - if (frame_type == TDD) { - mcs1 = ((DCI2C_1_5MHz_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2C_1_5MHz_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2C_1_5MHz_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2C_1_5MHz_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2C_1_5MHz_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2C_1_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs1 = ((DCI2C_1_5MHz_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2C_1_5MHz_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2C_1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2C_1_5MHz_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2C_1_5MHz_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2C_1_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 25: - if (frame_type == TDD) { - mcs1 = ((DCI2C_5MHz_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2C_5MHz_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2C_5MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2C_5MHz_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2C_5MHz_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2C_5MHz_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2C_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs1 = ((DCI2C_5MHz_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2C_5MHz_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2C_5MHz_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2C_5MHz_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2C_5MHz_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2C_5MHz_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2C_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 50: - if (frame_type == TDD) { - mcs1 = ((DCI2C_10MHz_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2C_10MHz_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2C_10MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2C_10MHz_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2C_10MHz_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2C_10MHz_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2C_10MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs1 = ((DCI2C_10MHz_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2C_10MHz_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2C_10MHz_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2C_10MHz_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2C_10MHz_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2C_10MHz_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2C_10MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 100: - if (frame_type == TDD) { - mcs1 = ((DCI2C_20MHz_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2C_20MHz_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2C_20MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2C_20MHz_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2C_20MHz_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2C_20MHz_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2C_20MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs1 = ((DCI2C_20MHz_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2C_20MHz_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2C_20MHz_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2C_20MHz_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2C_20MHz_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2C_20MHz_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2C_20MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - } - - - if (harq_pid>=8) { - LOG_E(PHY,"ERROR: Format 2_2A: harq_pid=%d >= 8\n", harq_pid); - return(-1); - } - - - - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - - dlsch0->subframe_tx[subframe] = 1; - - dlsch0->current_harq_pid = harq_pid; - dlsch1->current_harq_pid = harq_pid; - dlsch0->harq_ids[subframe] = harq_pid; - dlsch1->harq_ids[subframe] = harq_pid; - // printf("Setting DLSCH harq id %d to subframe %d\n",harq_pid,subframe); - - dlsch0_harq = dlsch0->harq_processes[harq_pid]; - dlsch1_harq = dlsch1->harq_processes[harq_pid]; - - // Needs to be checked - dlsch0_harq->codeword=0; - dlsch1_harq->codeword=1; - - conv_rballoc(rah, - rballoc, - frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc); - dlsch1_harq->rb_alloc[0] = dlsch0_harq->rb_alloc[0]; - - dlsch0_harq->nb_rb = conv_nprb(rah, - rballoc, - frame_parms->N_RB_DL); - dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; - - if (dlsch0_harq->nb_rb == 0) - return(-1); - - dlsch0_harq->mcs = mcs1; - dlsch1_harq->mcs = mcs2; - dlsch0_harq->rvidx = rv1; - dlsch1_harq->rvidx = rv2; - - // check if either TB is disabled (see 36-213 V8.6 p. 26) - - - if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) { - dlsch0->active = 0; - } - - if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) { - dlsch1->active = 0; - } - - - - if ((dlsch0_harq->round == 0) && (dlsch0->active == 1) ) { - dlsch0_harq->status = ACTIVE; - dlsch0_harq->mcs = mcs1; - } - - if ((dlsch1_harq->round == 0) && (dlsch1->active == 1) ) { - dlsch1_harq->status = ACTIVE; - dlsch1_harq->mcs = mcs2; - } - - // check TPMI information to compute TBS - if (frame_parms->nb_antenna_ports_eNB == 2) { - if (dlsch1->active == 1) { // both TBs are active - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch0_harq->nb_rb-1]; - } else { - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - - } - - dlsch0->rnti = rnti; - dlsch1->rnti = rnti; - - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - - break; - - case format2D: - - switch (frame_parms->N_RB_DL) { - - case 6: - if (frame_type == TDD) { - mcs1 = ((DCI2D_1_5MHz_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2D_1_5MHz_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2D_1_5MHz_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2D_1_5MHz_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2D_1_5MHz_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2D_1_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs1 = ((DCI2D_1_5MHz_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2D_1_5MHz_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2D_1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2D_1_5MHz_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2D_1_5MHz_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2D_1_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 25: - if (frame_type == TDD) { - mcs1 = ((DCI2D_5MHz_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2D_5MHz_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2D_5MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2D_5MHz_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2D_5MHz_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2D_5MHz_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2D_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs1 = ((DCI2D_5MHz_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2D_5MHz_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2D_5MHz_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2D_5MHz_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2D_5MHz_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2D_5MHz_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2D_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 50: - if (frame_type == TDD) { - mcs1 = ((DCI2D_10MHz_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2D_10MHz_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2D_10MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2D_10MHz_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2D_10MHz_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2D_10MHz_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2D_10MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs1 = ((DCI2D_10MHz_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2D_10MHz_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2D_10MHz_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2D_10MHz_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2D_10MHz_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2D_10MHz_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2D_10MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 100: - if (frame_type == TDD) { - mcs1 = ((DCI2D_20MHz_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2D_20MHz_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2D_20MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2D_20MHz_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2D_20MHz_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2D_20MHz_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2D_20MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs1 = ((DCI2D_20MHz_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2D_20MHz_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2D_20MHz_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2D_20MHz_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2D_20MHz_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2D_20MHz_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2D_20MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - } - - - if (harq_pid>=8) { - LOG_E(PHY,"ERROR: Format 2_2A: harq_pid=%d >= 8\n", harq_pid); - return(-1); - } - - - - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - - dlsch0->subframe_tx[subframe] = 1; - - dlsch0->current_harq_pid = harq_pid; - dlsch1->current_harq_pid = harq_pid; - dlsch0->harq_ids[subframe] = harq_pid; - dlsch1->harq_ids[subframe] = harq_pid; - // printf("Setting DLSCH harq id %d to subframe %d\n",harq_pid,subframe); - - - dlsch0_harq = dlsch0->harq_processes[harq_pid]; - dlsch1_harq = dlsch1->harq_processes[harq_pid]; - - // Needs to be checked - dlsch0_harq->codeword=0; - dlsch1_harq->codeword=1; - - conv_rballoc(rah, - rballoc, - frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc); - dlsch1_harq->rb_alloc[0] = dlsch0_harq->rb_alloc[0]; - - dlsch0_harq->nb_rb = conv_nprb(rah, - rballoc, - frame_parms->N_RB_DL); - dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; - - dlsch0_harq->mcs = mcs1; - dlsch1_harq->mcs = mcs2; - dlsch0_harq->rvidx = rv1; - dlsch1_harq->rvidx = rv2; - - // check if either TB is disabled (see 36-213 V8.6 p. 26) - - - if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) - dlsch0_harq->status = DISABLED; - - if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) - dlsch1_harq->status = DISABLED; - - dlsch0_harq->Nl = 1; - - - if (dlsch0_harq->round == 0) { - dlsch0_harq->status = ACTIVE; - // printf("Setting DLSCH process %d to ACTIVE\n",harq_pid); - } - - dlsch0_harq->mcs = mcs1; - - if (dlsch0_harq->nb_rb > 0) { - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - } else { - dlsch0_harq->TBS = 0; - } - - dlsch0->active = 1; - - dlsch0->rnti = rnti; - dlsch1->rnti = rnti; - - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - - break; - - - case format1E_2A_M10PRB: - - harq_pid = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->harq_pid; - - if (harq_pid>=8) { - LOG_E(PHY,"ERROR: Format 1E_2A_M10PRB: harq_pid=%d >= 8\n", harq_pid); - return(-1); - } - - /* - tbswap = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->tb_swap; - if (tbswap == 0) { - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - } - else{ - dlsch0 = dlsch[1]; - dlsch1 = dlsch[0]; - } - */ - dlsch0 = dlsch[0]; - dlsch0->subframe_tx[subframe] = 1; - - dlsch0->current_harq_pid = harq_pid; - //dlsch1->current_harq_pid = harq_pid; - dlsch0->harq_ids[subframe] = harq_pid; - //dlsch1->harq_ids[subframe] = harq_pid; - // printf("Setting DLSCH harq id %d to subframe %d\n",harq_pid,subframe); - dlsch0_harq = dlsch0->harq_processes[harq_pid]; - // Needs to be checked - dlsch0_harq->codeword=0; - - conv_rballoc(((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rah, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rballoc,frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc); - - //dlsch1->rb_alloc[0] = dlsch0->rb_alloc[0]; - - dlsch0_harq->nb_rb = conv_nprb(((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rah, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rballoc, - frame_parms->N_RB_DL); - //dlsch1->nb_rb = dlsch0->nb_rb; - - dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; - //dlsch1_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs2; - dlsch0_harq->rvidx = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rv; - //dlsch1_harq->rvidx = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rv2; - - // check if either TB is disabled (see 36-213 V8.6 p. 26) --> only for format 2 and 2A - - //if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) - // dlsch0_harq->status = DISABLED; - - //if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) - // dlsch1_harq->status = DISABLED; - - dlsch0_harq->Nl = 1; - - //dlsch0->layer_index = tbswap; - //dlsch1->layer_index = 1-tbswap; - - // Fix this - tpmi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->tpmi; - - switch (tpmi) { - case 0 : - dlsch0_harq->mimo_mode = ALAMOUTI; - break; - - case 1: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING11; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0, 0); - - break; - - case 2: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1m1; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1, 0); - - break; - - case 3: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1j; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,2, 0); - - break; - - case 4: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1mj; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,3, 0); - break; - - case 5: - dlsch0_harq->mimo_mode = PUSCH_PRECODING0; - dlsch0_harq->pmi_alloc = DL_pmi_single; - break; - - case 6: - dlsch0_harq->mimo_mode = PUSCH_PRECODING1; - return(-1); - break; - } - - // printf("Set pmi %x (tpmi %d)\n",dlsch0->pmi_alloc,tpmi); - - - if (frame_parms->mode1_flag == 1) - dlsch0_harq->mimo_mode = SISO; - - // dlsch0_harq->Ndi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi; - if (dlsch0_harq->round == 0) { - dlsch0_harq->status = ACTIVE; - // printf("Setting DLSCH process %d to ACTIVE\n",harq_pid); - } - - dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; - - if (dlsch0_harq->nb_rb > 0) { - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - } else { - dlsch0_harq->TBS = 0; - } - - dlsch0->active = 1; - - dlsch0->rnti = rnti; - //dlsch1->rnti = rnti; - - // dlsch0->dl_power_off = 1; - dlsch0_harq->dl_power_off = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->dl_power_off; - //dlsch1->dl_power_off = 1; - - break; - - default: - LOG_E(PHY,"Unknown DCI format\n"); - return(-1); - break; - } - - - if (dlsch0_harq) { - dlsch0_harq->frame = frame; - dlsch0_harq->subframe = subframe; - } - if (dlsch1_harq) { - dlsch1_harq->frame = frame; - dlsch1_harq->subframe = subframe; - } - -#ifdef DEBUG_DCI - - if (dlsch0) { - printf("dlsch0 eNB: dlsch0 %p\n",dlsch0); - printf("dlsch0 eNB: rnti %x\n",dlsch0->rnti); - printf("dlsch0 eNB: NBRB %d\n",dlsch0_harq->nb_rb); - printf("dlsch0 eNB: rballoc %x\n",dlsch0_harq->rb_alloc[0]); - printf("dlsch0 eNB: harq_pid %d\n",harq_pid); - printf("dlsch0 eNB: round %d\n",dlsch0_harq->round); - printf("dlsch0 eNB: rvidx %d\n",dlsch0_harq->rvidx); - printf("dlsch0 eNB: TBS %d (NPRB %d)\n",dlsch0_harq->TBS,NPRB); - printf("dlsch0 eNB: mcs %d\n",dlsch0_harq->mcs); - printf("dlsch0 eNB: tpmi %d\n",tpmi); - printf("dlsch0 eNB: mimo_mode %d\n",dlsch0_harq->mimo_mode); - } - - if (dlsch1) { - printf("dlsch1 eNB: dlsch1 %p\n",dlsch1); - printf("dlsch1 eNB: rnti %x\n",dlsch1->rnti); - printf("dlsch1 eNB: NBRB %d\n",dlsch1_harq->nb_rb); - printf("dlsch1 eNB: rballoc %x\n",dlsch1_harq->rb_alloc[0]); - printf("dlsch1 eNB: harq_pid %d\n",harq_pid); - printf("dlsch1 eNB: round %d\n",dlsch1_harq->round); - printf("dlsch1 eNB: rvidx %d\n",dlsch1_harq->rvidx); - printf("dlsch1 eNB: TBS %d (NPRB %d)\n",dlsch1_harq->TBS,NPRB); - printf("dlsch1 eNB: mcs %d\n",dlsch1_harq->mcs); - printf("dlsch1 eNB: tpmi %d\n",tpmi); - printf("dlsch1 eNB: mimo_mode %d\n",dlsch1_harq->mimo_mode); - } - -#endif - - // compute DL power control parameters - - if (dlsch0 != NULL){ - computeRhoA_eNB(pdsch_config_dedicated, dlsch[0],dlsch0_harq->dl_power_off, frame_parms->nb_antenna_ports_eNB); - computeRhoB_eNB(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antenna_ports_eNB,dlsch[0],dlsch0_harq->dl_power_off); -} - if (dlsch1 != NULL){ - computeRhoA_eNB(pdsch_config_dedicated, dlsch[1],dlsch1_harq->dl_power_off, frame_parms->nb_antenna_ports_eNB); - computeRhoB_eNB(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antenna_ports_eNB,dlsch[1],dlsch1_harq->dl_power_off); - } - - - return(0); -} - - -int dump_dci(NR_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci) -{ - switch (dci->format) { - - case format0: // This is an UL SCH allocation so nothing here, inform MAC - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format0 (TDD, 1.5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, - ((DCI0_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 25: - LOG_D(PHY,"DCI format0 (TDD1-6, 5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, - ((DCI0_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 50: - LOG_D(PHY,"DCI format0 (TDD1-6, 10MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, - ((DCI0_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 100: - LOG_D(PHY,"DCI format0 (TDD1-6, 20MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, dai %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai, - ((DCI0_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->cqi_req); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - else if (frame_parms->frame_type == FDD) - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format0 (FDD, 1.5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_1_5MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 25: - LOG_D(PHY,"DCI format0 (FDD, 5MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_5MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 50: - LOG_D(PHY,"DCI format0 (FDD, 10MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_10MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); - break; - - case 100: - LOG_D(PHY,"DCI format0 (FDD, 20MHz), rnti %x (%x): hopping %d, rb_alloc %x, mcs %d, ndi %d, TPC %d, cshift %d, cqi_req %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu[0])[0], - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->hopping, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->cshift, - ((DCI0_20MHz_FDD_t *)&dci->dci_pdu[0])->cqi_req); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - else - LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); - - break; - - case format1: - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) - - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1 (TDD 1.5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI1_1_5MHz_TDD_t *)&dci->dci_pdu[0])->dai); - break; - - case 25: - LOG_D(PHY,"DCI format1 (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI1_5MHz_TDD_t *)&dci->dci_pdu[0])->dai); - break; - - case 50: - LOG_D(PHY,"DCI format1 (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI1_10MHz_TDD_t *)&dci->dci_pdu[0])->dai); - break; - - case 100: - LOG_D(PHY,"DCI format1 (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d, dai %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI1_20MHz_TDD_t *)&dci->dci_pdu[0])->dai); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - else if (frame_parms->frame_type == FDD) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1 (FDD, 1.5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format1 (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format1 (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format1 (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d, harq_pid %d, ndi %d, RV %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - - else - LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); - - break; - - case format1A: // This is DLSCH allocation for control traffic - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) { - switch (frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1A (TDD1-6, 1_5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); - LOG_D(PHY,"DAI %d\n",((DCI1A_1_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); - break; - - case 25: - LOG_D(PHY,"DCI format1A (TDD1-6, 5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %d (NB_RB %d)\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); - LOG_D(PHY,"DAI %d\n",((DCI1A_5MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); - break; - - case 50: - LOG_D(PHY,"DCI format1A (TDD1-6, 10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); - LOG_D(PHY,"DAI %d\n",((DCI1A_10MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); - break; - - case 100: - LOG_D(PHY,"DCI format1A (TDD1-6, 20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT100[((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->TPC); - LOG_D(PHY,"DAI %d\n",((DCI1A_20MHz_TDD_1_6_t *)&dci->dci_pdu[0])->dai); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - } else if (frame_parms->frame_type == FDD) { - switch (frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1A(FDD, 1.5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_1_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format1A(FDD, 5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_5MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format1A(FDD, 10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format1A(FDD, 20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT100[((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]); - LOG_D(PHY,"MCS %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->mcs); - LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid); - LOG_D(PHY,"NDI %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->ndi); - LOG_D(PHY,"RV %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->rv); - LOG_D(PHY,"TPC %d\n",((DCI1A_20MHz_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - - break; - - case format1C: // This is DLSCH allocation for control traffic - switch (frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format1C (1.5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n", - ((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT6[conv_1C_RIV(((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->rballoc,6)]); - LOG_D(PHY,"MCS %d\n",((DCI1C_1_5MHz_t *)&dci->dci_pdu[0])->mcs); - break; - - case 25: - LOG_D(PHY,"DCI format1C (5MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_5MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT25[conv_1C_RIV(((DCI1C_5MHz_t *)&dci->dci_pdu[0])->rballoc,25)]); - LOG_D(PHY,"MCS %d\n",((DCI1C_5MHz_t *)&dci->dci_pdu[0])->mcs); - break; - - case 50: - LOG_D(PHY,"DCI format1C (10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"Ngap %d\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->Ngap); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[conv_1C_RIV(((DCI1C_10MHz_t *)&dci->dci_pdu[0])->rballoc,50)]); - LOG_D(PHY,"MCS %d\n",((DCI1C_10MHz_t *)&dci->dci_pdu[0])->mcs); - break; - - case 100: - LOG_D(PHY,"DCI format1C (20MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]); - LOG_D(PHY,"Ngap %d\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->Ngap); - LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[conv_1C_RIV(((DCI1C_20MHz_t *)&dci->dci_pdu[0])->rballoc,100)]); - LOG_D(PHY,"MCS %d\n",((DCI1C_20MHz_t *)&dci->dci_pdu[0])->mcs); - break; - - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - - break; - - case format2: - - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) { - if (frame_parms->nb_antenna_ports_eNB == 2) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2 2 antennas (TDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi - ); - break; - - case 25: - LOG_D(PHY,"DCI format2 2 antennas (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 50: - LOG_D(PHY,"DCI format2 2 antennas (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 100: - LOG_D(PHY,"DCI format2 2 antennas (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2 2 antennas (TDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi - ); - break; - - case 25: - LOG_D(PHY,"DCI format2 2 antennas (TDD 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 50: - LOG_D(PHY,"DCI format2 2 antennas (TDD 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 100: - LOG_D(PHY,"DCI format2 2 antennas (TDD 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, TPC %d, dai %d, tb_swap %d, tpmi %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - } else if (frame_parms->frame_type == FDD) { - if (frame_parms->nb_antenna_ports_eNB == 2) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2 2 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - - LOG_D(PHY,"DCI format2 2 antennas (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, swap %d, TPMI %d, TPC %d\n", - - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format2 2 antennas (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format2 2 antennas (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - switch(frame_parms->N_RB_DL) { - - case 6: - LOG_D(PHY,"DCI format2 4 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format2 4 antennas (FDD, 5 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format2 4 antennas (FDD, 10 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format2 4 antennas (FDD, 20 MHz), rnti %x (%x): rah %d, rb_alloc %x, mcs %d|%d, harq_pid %d, ndi %d|%d, RV %d|%d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - } - - else - LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); - - break; - - case format2A: - - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config>0)) { - if (frame_parms->nb_antenna_ports_eNB == 2) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2A 2 antennas (FDD 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_1_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap - ); - break; - - case 25: - LOG_D(PHY,"DCI format2A 2 antennas (FDD 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_5MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); - break; - - case 50: - LOG_D(PHY,"DCI format2A 2 antennas (FDD 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_10MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); - break; - - case 100: - LOG_D(PHY,"DCI format2A 2 antennas (FDD 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_20MHz_2A_TDD_t *)&dci->dci_pdu[0])->tb_swap); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2A 4 antennas (TDD 1.5 MHz), rnti %x (%"PRIu64"): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_1_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi - ); - break; - - case 25: - LOG_D(PHY,"DCI format2A 4 antennas (TDD 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_5MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 50: - LOG_D(PHY,"DCI format2A 4 antennas (TDD 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_10MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - case 100: - LOG_D(PHY,"DCI format2A 4 antennas (TDD 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, TPC %d, dai %d, tbswap %d, tpmi %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->TPC, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->dai, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_20MHz_4A_TDD_t *)&dci->dci_pdu[0])->tpmi); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - } else if (frame_parms->frame_type == FDD) { - if (frame_parms->nb_antenna_ports_eNB == 2) { - switch(frame_parms->N_RB_DL) { - case 6: - LOG_D(PHY,"DCI format2A 2 antennas (FDD, 1.5 MHz), rnti %x (%x): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", - dci->rnti, - ((uint32_t*)&dci->dci_pdu)[0], - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_1_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format2A 2 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_5MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format2A 2 antennas (FDD, 10 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_10MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format2A 2 antennas (FDD, 20 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_20MHz_2A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } else if (frame_parms->nb_antenna_ports_eNB == 4) { - switch(frame_parms->N_RB_DL) { - - case 6: - LOG_D(PHY,"DCI format2A 4 antennas (FDD, 1.5 MHz), rnti %x (%"PRIu64"): rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2A_1_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 25: - LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2A_5MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 50: - LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2A_10MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - case 100: - LOG_D(PHY,"DCI format2A 4 antennas (FDD, 5 MHz), rnti %x (%"PRIu64"): rah %d, rb_alloc %x, mcs1 %d, mcs2 %d, harq_pid %d, ndi1 %d, ndi2 %d, RV1 %d, RV2 %d, tb_swap %d, tpmi %d, TPC %d\n", - dci->rnti, - ((uint64_t*)&dci->dci_pdu)[0], - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rah, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs1, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->mcs2, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->harq_pid, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi1, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->ndi2, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv1, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->rv2, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI2A_20MHz_4A_FDD_t *)&dci->dci_pdu[0])->TPC); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - } - } - - else - LOG_E(PHY,"Don't know how to handle TDD format 0 yet\n"); - - break; - - case format1E_2A_M10PRB: - - LOG_D(PHY,"DCI format1E_2A_M10PRB, rnti %x (%8x): harq_pid %d, rah %d, rb_alloc %x, mcs %d, rv %d, tpmi %d, ndi %d, dl_power_offset %d\n", - dci->rnti, - ((uint32_t *)&dci->dci_pdu)[0], - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->harq_pid, - //((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->tb_swap, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rah, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rballoc, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->mcs, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->rv, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->tpmi, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->ndi, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)&dci->dci_pdu[0])->dl_power_off - ); - - break; - - default: - LOG_E(PHY,"dci_tools.c: dump_dci, unknown format %d\n",dci->format); - return(-1); - } - - return(0); -} -#endif //(0) #ifdef NR_PDCCH_DCI_TOOLS uint16_t nr_dci_field(uint32_t dci_pdu[4], @@ -4909,2097 +1015,6 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, #endif -#if 0 -void extract_dci1A_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) -{ - uint8_t harq_pid=0; - uint32_t rballoc=0; - uint8_t vrb_type=0; - uint8_t mcs=0; - uint8_t rv=0; - uint8_t ndi=0; - uint8_t TPC=0; - - uint8_t dai=0; - - switch (N_RB_DL) { - case 6: - if (frame_type == TDD) { - vrb_type = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->rv; - ndi = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->ndi; - TPC = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - dai = ((DCI1A_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } else { - vrb_type = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->rv; - ndi = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->ndi; - TPC = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_1_5MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } - break; - - case 25: - - if (frame_type == TDD) { - vrb_type = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->rv; - ndi = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->ndi; - TPC = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - dai = ((DCI1A_5MHz_TDD_1_6_t *)dci_pdu)->dai; - //printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } else { - vrb_type = ((DCI1A_5MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_5MHz_FDD_t *)dci_pdu)->rv; - ndi = ((DCI1A_5MHz_FDD_t *)dci_pdu)->ndi; - TPC = ((DCI1A_5MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_5MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } - - break; - - case 50: - if (frame_type == TDD) { - vrb_type = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->rv; - ndi = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->ndi; - TPC = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - dai = ((DCI1A_10MHz_TDD_1_6_t *)dci_pdu)->dai; - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } else { - vrb_type = ((DCI1A_10MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_10MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_10MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_10MHz_FDD_t *)dci_pdu)->rv; - ndi = ((DCI1A_10MHz_FDD_t *)dci_pdu)->ndi; - TPC = ((DCI1A_10MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_10MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, vrb_type %d, rballoc %x,ndi %d, rv %d, TPC %d\n",mcs,vrb_type,rballoc,ndi,rv,TPC); - } - break; - - case 100: - if (frame_type == TDD) { - vrb_type = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; - rv = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->rv; - ndi = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->ndi; - TPC = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->harq_pid; - dai = ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->dai; - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } else { - vrb_type = ((DCI1A_20MHz_FDD_t *)dci_pdu)->vrb_type; - mcs = ((DCI1A_20MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1A_20MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1A_20MHz_FDD_t *)dci_pdu)->rv; - ndi = ((DCI1A_20MHz_FDD_t *)dci_pdu)->ndi; - TPC = ((DCI1A_20MHz_FDD_t *)dci_pdu)->TPC; - harq_pid = ((DCI1A_20MHz_FDD_t *)dci_pdu)->harq_pid; - //printf("FDD 1A: mcs %d, rballoc %x,rv %d, TPC %d\n",mcs,rballoc,rv,TPC); - } - break; - } - - pdci_info_extarcted->vrb_type = vrb_type; - pdci_info_extarcted->mcs1 = mcs; - pdci_info_extarcted->rballoc = rballoc; - pdci_info_extarcted->rv1 = rv; - pdci_info_extarcted->ndi1 = ndi; - pdci_info_extarcted->TPC = TPC; - pdci_info_extarcted->harq_pid = harq_pid; - pdci_info_extarcted->dai = dai; -} - -void extract_dci1C_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) -{ - - uint32_t rballoc=0; - uint8_t mcs=0; - - switch (N_RB_DL) { - case 6: - mcs = ((DCI1C_5MHz_t *)dci_pdu)->mcs; - rballoc = conv_1C_RIV(((DCI1C_5MHz_t *)dci_pdu)->rballoc,6); - - break; - - case 25: - mcs = ((DCI1C_5MHz_t *)dci_pdu)->mcs; - rballoc = conv_1C_RIV(((DCI1C_5MHz_t *)dci_pdu)->rballoc,6); - - break; - - case 50: - mcs = ((DCI1C_10MHz_t *)dci_pdu)->mcs; - rballoc = conv_1C_RIV(((DCI1C_10MHz_t *)dci_pdu)->rballoc,6); - - break; - - case 100: - mcs = ((DCI1C_20MHz_t *)dci_pdu)->mcs; - rballoc = conv_1C_RIV(((DCI1C_20MHz_t *)dci_pdu)->rballoc,6); - break; - - default: - AssertFatal(0,"Format 1C: Unknown N_RB_DL %d\n",N_RB_DL); - break; - } - - pdci_info_extarcted->mcs1 = mcs; - pdci_info_extarcted->rballoc = rballoc; -} - -void extract_dci1_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) -{ - - uint32_t rballoc=0; - uint8_t mcs=0; - uint8_t rah=0; - uint8_t rv=0; - uint8_t TPC=0; - uint8_t ndi=0; - uint8_t harq_pid=0; - - switch (N_RB_DL) { - case 6: - if (frame_type == TDD) { - mcs = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->rv; - TPC = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_1_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_1_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 25: - if (frame_type == TDD) { - mcs = ((DCI1_5MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_5MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_5MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_5MHz_TDD_t *)dci_pdu)->rv; - TPC = ((DCI1_5MHz_TDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_5MHz_TDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_5MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_5MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_5MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_5MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_5MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1_5MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_5MHz_FDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_5MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 50: - if (frame_type == TDD) { - mcs = ((DCI1_10MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_10MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_10MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_10MHz_TDD_t *)dci_pdu)->rv; - TPC = ((DCI1_10MHz_TDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_10MHz_TDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_10MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_10MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_10MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_10MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_10MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1_10MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_10MHz_FDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_10MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - - case 100: - if (frame_type == TDD) { - mcs = ((DCI1_20MHz_TDD_t *)dci_pdu)->mcs; - rballoc = ((DCI1_20MHz_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI1_20MHz_TDD_t *)dci_pdu)->rah; - rv = ((DCI1_20MHz_TDD_t *)dci_pdu)->rv; - TPC = ((DCI1_20MHz_TDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_20MHz_TDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_20MHz_TDD_t *)dci_pdu)->harq_pid; - } else { - mcs = ((DCI1_20MHz_FDD_t *)dci_pdu)->mcs; - rah = ((DCI1_20MHz_FDD_t *)dci_pdu)->rah; - rballoc = ((DCI1_20MHz_FDD_t *)dci_pdu)->rballoc; - rv = ((DCI1_20MHz_FDD_t *)dci_pdu)->rv; - TPC = ((DCI1_20MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI1_20MHz_FDD_t *)dci_pdu)->ndi; - harq_pid = ((DCI1_20MHz_FDD_t *)dci_pdu)->harq_pid; - } - - break; - } - - pdci_info_extarcted->mcs1 = mcs; - pdci_info_extarcted->rah = rah; - pdci_info_extarcted->rballoc = rballoc; - pdci_info_extarcted->rv1 = rv; - pdci_info_extarcted->TPC = TPC; - pdci_info_extarcted->ndi1 = ndi; - pdci_info_extarcted->harq_pid = harq_pid; - -} - -void extract_dci2_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) -{ - - uint32_t rballoc=0; - uint8_t rah=0; - uint8_t mcs1=0; - uint8_t mcs2=0; - uint8_t rv1=0; - uint8_t rv2=0; - uint8_t ndi1=0; - uint8_t ndi2=0; - uint8_t tbswap=0; - uint8_t tpmi=0; - uint8_t harq_pid=0; - uint8_t TPC=0; - - switch (N_RB_DL) { - - case 6: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - rah = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi2; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - rah = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi2; - } - } else { - LOG_E(PHY,"UE: Format2 DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); - } - - break; - - case 25: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - rah = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_FDD_t *)dci_pdu)->ndi2; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - rah = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_4A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_5MHz_4A_FDD_t *)dci_pdu)->ndi2; - } - } else { - LOG_E(PHY,"UE: Format2 DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); - } - - break; - - case 50: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - rah = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_10MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_10MHz_2A_FDD_t *)dci_pdu)->ndi2; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - rah = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_10MHz_4A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_10MHz_4A_FDD_t *)dci_pdu)->ndi2; - } - } else { - LOG_E(PHY,"UE: Format2A DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); - } - - break; - - case 100: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - rah = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_20MHz_2A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_20MHz_2A_FDD_t *)dci_pdu)->ndi2; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - rah = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_20MHz_4A_TDD_t *)dci_pdu)->ndi2; - } else { - rah = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rah; - mcs1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->rv2; - harq_pid = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->TPC; - ndi1 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2_20MHz_4A_FDD_t *)dci_pdu)->ndi2; - } - } else { - LOG_E(PHY,"UE: Format2A DCI: unsupported number of TX antennas %d\n",nb_antenna_ports_eNB); - } - - break; - } - - pdci_info_extarcted->rah = rah; - pdci_info_extarcted->mcs1 = mcs1; - pdci_info_extarcted->mcs2 = mcs2; - pdci_info_extarcted->rv1 = rv1; - pdci_info_extarcted->rv2 = rv2; - pdci_info_extarcted->harq_pid = harq_pid; - pdci_info_extarcted->rballoc = rballoc; - pdci_info_extarcted->tb_swap = tbswap; - pdci_info_extarcted->tpmi = tpmi; - pdci_info_extarcted->TPC = TPC; - pdci_info_extarcted->ndi1 = ndi1; - pdci_info_extarcted->ndi2 = ndi2; - -} - -void extract_dci2A_info(uint8_t N_RB_DL, lte_frame_type_t frame_type, uint8_t nb_antenna_ports_eNB, void *dci_pdu, DCI_INFO_EXTRACTED_t *pdci_info_extarcted) -{ - - uint32_t rballoc=0; - uint8_t rah=0; - uint8_t mcs1=0; - uint8_t mcs2=0; - uint8_t rv1=0; - uint8_t rv2=0; - uint8_t ndi1=0; - uint8_t ndi2=0; - uint8_t tbswap=0; - uint8_t tpmi=0; - uint8_t harq_pid=0; - uint8_t TPC=0; - - AssertFatal( (nb_antenna_ports_eNB == 2) || (nb_antenna_ports_eNB == 4), "unsupported nb_antenna_ports_eNB %d\n", nb_antenna_ports_eNB); - switch (N_RB_DL) { - - case 6: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_1_5MHz_2A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_1_5MHz_2A_FDD_t *)dci_pdu)->TPC; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_1_5MHz_4A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rv1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_1_5MHz_4A_FDD_t *)dci_pdu)->TPC; - } - } - - break; - - case 25: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_5MHz_2A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_5MHz_2A_FDD_t *)dci_pdu)->TPC; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_5MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_5MHz_4A_FDD_t *)dci_pdu)->TPC; - } - } - break; - - case 50: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_10MHz_2A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_10MHz_2A_FDD_t *)dci_pdu)->TPC; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_10MHz_4A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_10MHz_4A_FDD_t *)dci_pdu)->TPC; - } - } - - break; - - case 100: - if (nb_antenna_ports_eNB == 2) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_20MHz_2A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->tb_swap; - TPC = ((DCI2A_20MHz_2A_FDD_t *)dci_pdu)->TPC; - } - } else if (nb_antenna_ports_eNB == 4) { - if (frame_type == TDD) { - mcs1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_20MHz_4A_TDD_t *)dci_pdu)->TPC; - } else { - mcs1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->mcs1; - mcs2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->mcs2; - rballoc = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rballoc; - rah = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rah; - rv1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rv1; - rv2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->rv2; - ndi1 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->ndi1; - ndi2 = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->ndi2; - harq_pid = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->harq_pid; - tbswap = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->tb_swap; - tpmi = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->tpmi; - TPC = ((DCI2A_20MHz_4A_FDD_t *)dci_pdu)->TPC; - } - } - - break; - } - - pdci_info_extarcted->mcs1 = mcs1; - pdci_info_extarcted->mcs2 = mcs2; - pdci_info_extarcted->rballoc = rballoc; - pdci_info_extarcted->rah = rah; - pdci_info_extarcted->rv1 = rv1; - pdci_info_extarcted->rv2 = rv2; - pdci_info_extarcted->ndi1 = ndi1; - pdci_info_extarcted->ndi2 = ndi2; - pdci_info_extarcted->harq_pid = harq_pid; - pdci_info_extarcted->tb_swap = tbswap; - pdci_info_extarcted->TPC = TPC; - pdci_info_extarcted->tpmi = tpmi; -} - -int check_dci_format1_1a_coherency(DCI_format_t dci_format, - uint8_t N_RB_DL, - uint16_t rnti, - uint16_t tc_rnti, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint32_t frame, - uint8_t nr_tti_rx, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - NR_DL_UE_HARQ_t *pdlsch0_harq) -{ - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint32_t rballoc = pdci_info_extarcted->rballoc; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t TPC = pdci_info_extarcted->TPC; - uint8_t rah = pdci_info_extarcted->rah; -#ifdef DEBUG_DCI - uint8_t rv1 = pdci_info_extarcted->rv1; - uint8_t ndi1 = pdci_info_extarcted->ndi1; -#endif - - uint8_t NPRB = 0; - long long int RIV_max = 0; - -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1-1A] AbsSubframe %d.%d dci_format %d\n", frame, nr_tti_rx, dci_format); - LOG_I(PHY,"[DCI-FORMAT-1-1A] rnti %x\n", rnti); - LOG_I(PHY,"[DCI-FORMAT-1-1A] harq_pid %d\n", harq_pid); - LOG_I(PHY,"[DCI-FORMAT-1-1A] rah %d\n", rah); - LOG_I(PHY,"[DCI-FORMAT-1-1A] rballoc %x\n", rballoc); - LOG_I(PHY,"[DCI-FORMAT-1-1A] mcs1 %d\n", mcs1); - LOG_I(PHY,"[DCI-FORMAT-1-1A] rv1 %d\n", rv1); - LOG_I(PHY,"[DCI-FORMAT-1-1A] ndi1 %d\n", ndi1); - LOG_I(PHY,"[DCI-FORMAT-1-1A] TPC %d\n", TPC); -#endif - - - // I- check dci content minimum coherency - if( ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) && harq_pid > 0) - { - return(0); - } - - if(harq_pid>=8) - { - LOG_I(PHY,"bad harq id \n"); - return(0); - } - - if(dci_format == format1 && ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) ) - { - LOG_I(PHY,"bad dci format \n"); - return(0); - } - - - if( mcs1 > 28) - { - if(pdlsch0_harq->round == 0) - { - LOG_I(PHY,"bad dci mcs + round \n"); - return(0); - } - - if((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - LOG_I(PHY,"bad dci mcs + rnti \n"); - return(0); - } - } - - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - NPRB = (TPC&1) + 2; - switch (N_RB_DL) { - case 6: - RIV_max = RIV_max6; - break; - case 25: - RIV_max = RIV_max25; - break; - case 50: - RIV_max = RIV_max50; - break; - case 100: - RIV_max = RIV_max100; - break; - } - } - /*else - { - switch (N_RB_DL) { - case 6: - NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; - if(rah) - RIV_max = RIV_max6; - else - RIV_max = 0x3F; - break; - case 25: - NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; - if(rah) - RIV_max = RIV_max25; - else - RIV_max = 0x1FFF; - break; - case 50: - NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; - if(rah) - RIV_max = RIV_max50; - else - RIV_max = 0x1FFFF; - break; - case 100: - NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; - if(rah) - RIV_max = RIV_max100; - else - RIV_max = 0x1FFFFFF; - break; - } - }*/ - - - if(dci_format == format1) - { - NPRB = conv_nprb(rah, rballoc, N_RB_DL); - } - - /* - if(rballoc > RIV_max) - { - LOG_I(PHY,"bad dci rballoc rballoc %d RIV_max %lld \n",rballoc, RIV_max); - // DCI false detection - return(0); - } - */ - - if(NPRB == 0) - { - // DCI false detection - LOG_I(PHY,"bad NPRB = 0 \n"); - return(0); - } - - // this a retransmission - if(pdlsch0_harq->round>0) - { - // compare old TBS to new TBS - if((mcs1<29) && (pdlsch0_harq->TBS != TBStable[get_I_TBS(mcs1)][NPRB-1])) - { - // this is an eNB issue - // retransmisison but old and new TBS are different !!! - // work around, consider it as a new transmission - LOG_E(PHY,"Format1A Retransmission but TBS are different: consider it as new transmission !!! \n"); - pdlsch0_harq->round = 0; - //return(0); // ?? to cross check - } - } - - return(1); -} - -int check_dci_format1c_coherency(uint8_t N_RB_DL, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - uint16_t rnti, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - NR_DL_UE_HARQ_t *pdlsch0_harq) -{ - uint32_t rballoc = pdci_info_extarcted->rballoc; - - uint8_t NPRB = 0; - uint32_t RIV_max = 0; - - // I- check dci content minimum coherency - - if((rnti!=si_rnti) && (rnti!=p_rnti) && (rnti!=ra_rnti)) - return(0); - - switch (N_RB_DL) { - case 6: - NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; - RIV_max = RIV_max6; - break; - case 25: - NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; - RIV_max = RIV_max25; - break; - case 50: - NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; - RIV_max = RIV_max50; - break; - case 100: - NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; - RIV_max = RIV_max100; - break; - } - - if(rballoc > RIV_max) - { - // DCI false detection - return(0); - } - - if(NPRB == 0) - { - // DCI false detection - return(0); - } - - return(1); -} - -int check_dci_format2_2a_coherency(DCI_format_t dci_format, - uint8_t N_RB_DL, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - uint16_t rnti, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - NR_DL_UE_HARQ_t *pdlsch0_harq, - NR_DL_UE_HARQ_t *pdlsch1_harq) -{ - uint8_t rah = pdci_info_extarcted->rah; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t mcs2 = pdci_info_extarcted->mcs2; - uint8_t rv1 = pdci_info_extarcted->rv1; - uint8_t rv2 = pdci_info_extarcted->rv2; - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint32_t rballoc = pdci_info_extarcted->rballoc; - -#ifdef DEBUG_DCI - uint8_t ndi1 = pdci_info_extarcted->ndi1; - uint8_t ndi2 = pdci_info_extarcted->ndi2; -#endif - - uint8_t NPRB = 0; - long long RIV_max = 0; - -#ifdef DEBUG_DCI - LOG_I(PHY, "extarcted dci - dci_format %d \n", dci_format); - LOG_I(PHY, "extarcted dci - rnti %d \n", rnti); - LOG_I(PHY, "extarcted dci - rah %d \n", rah); - LOG_I(PHY, "extarcted dci - mcs1 %d \n", mcs1); - LOG_I(PHY, "extarcted dci - mcs2 %d \n", mcs2); - LOG_I(PHY, "extarcted dci - rv1 %d \n", rv1); - LOG_I(PHY, "extarcted dci - rv2 %d \n", rv2); - //LOG_I(PHY, "extarcted dci - ndi1 %d \n", ndi1); - //LOG_I(PHY, "extarcted dci - ndi2 %d \n", ndi2); - LOG_I(PHY, "extarcted dci - rballoc %x \n", rballoc); - LOG_I(PHY, "extarcted dci - harq pid %d \n", harq_pid); - LOG_I(PHY, "extarcted dci - round0 %d \n", pdlsch0_harq->round); - LOG_I(PHY, "extarcted dci - round1 %d \n", pdlsch1_harq->round); -#endif - - // I- check dci content minimum coherency - if(harq_pid>=8) - { - LOG_I(PHY,"bad harq pid\n"); - return(0); - } - - if( (rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti) ) - { - LOG_I(PHY,"bad rnti\n"); - return(0); - } - - - if( mcs1 > 28) - { - if(pdlsch0_harq->round == 0) - { - LOG_I(PHY,"bad mcs1\n"); - return(0); - } - } - - if( mcs2 > 28) - { - if(pdlsch1_harq->round == 0) - { - LOG_I(PHY,"bad mcs2\n"); - return(0); - } - - } - - - if((pdlsch0_harq->round == 0) && (rv1 > 0) && (mcs1 != 0)) - { - // DCI false detection - LOG_I(PHY,"bad rv1\n"); - return(0); - } - - if((pdlsch1_harq->round == 0) && (rv2 > 0) && (mcs2 != 0)) - { - // DCI false detection - LOG_I(PHY,"bad rv2\n"); - return(0); - } - - - switch (N_RB_DL) { - case 6: - if (rah == 0) - { - //RBG = 1; - RIV_max = 0x3F; - } - else - { - RIV_max = RIV_max6; - } - break; - case 25: - if (rah == 0) - { - //RBG = 2; - RIV_max = 0x1FFF; - } - else - { - RIV_max = RIV_max25; - } - break; - case 50: - if (rah == 0) - { - //RBG = 3; - RIV_max = 0x1FFFF; - } - else - { - RIV_max = RIV_max50; - } - break; - case 100: - if (rah == 0) - { - //RBG = 4; - RIV_max = 0x1FFFFFF; - } - else - { - RIV_max = RIV_max100; - } - break; - } - - NPRB = conv_nprb(rah, - rballoc, - N_RB_DL); - - - - if( (rballoc > RIV_max) && (rah == 1) ) - { - // DCI false detection - LOG_I(PHY,"bad rballoc %d RIV_max %lld\n", rballoc, RIV_max); - return(0); - } - - if(NPRB == 0) - { - // DCI false detection - LOG_I(PHY,"bad NPRB\n"); - return(0); - } - - return(1); -} - -void compute_llr_offset(NR_DL_FRAME_PARMS *frame_parms, - NR_UE_PDCCH *pdcch_vars, - NR_UE_PDSCH *pdsch_vars, - NR_DL_UE_HARQ_t *dlsch0_harq, - uint8_t nb_rb_alloc, - uint8_t nr_tti_rx) -{ - uint32_t pbch_pss_sss_re; - uint32_t crs_re; - uint32_t granted_re; - uint32_t data_re; - uint32_t llr_offset; - uint8_t symbol; - uint8_t symbol_mod; - - pdsch_vars->llr_offset[pdcch_vars->num_pdcch_symbols] = 0; - - //LOG_I(PHY,"compute_llr_offset: nb RB %d - Qm %d \n", nb_rb_alloc, dlsch0_harq->Qm); - - //dlsch0_harq->rb_alloc_even; - //dlsch0_harq->rb_alloc_odd; - - for(symbol=pdcch_vars->num_pdcch_symbols; symbolsymbols_per_tti; symbol++) - { - symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol; - if((symbol_mod == 0) || symbol_mod == (4-frame_parms->Ncp)) - { - if (frame_parms->mode1_flag==0) - crs_re = 4; - else - crs_re = 2; - } - else - { - crs_re = 0; - } - - granted_re = nb_rb_alloc * (12-crs_re); - pbch_pss_sss_re = adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,dlsch0_harq->Qm,nr_tti_rx,symbol); - pbch_pss_sss_re = (double)pbch_pss_sss_re * ((double)(12-crs_re)/12); - data_re = granted_re - pbch_pss_sss_re; - llr_offset = data_re * dlsch0_harq->Qm * 2; - - pdsch_vars->llr_length[symbol] = data_re; - if(symbol < (frame_parms->symbols_per_tti-1)) - pdsch_vars->llr_offset[symbol+1] = pdsch_vars->llr_offset[symbol] + llr_offset; - - //LOG_I(PHY,"Granted Re nr_tti_rx %d / symbol %d => %d (%d RBs)\n", nr_tti_rx, symbol_mod, granted_re,dlsch0_harq->nb_rb); - //LOG_I(PHY,"Pbch/PSS/SSS Re nr_tti_rx %d / symbol %d => %d \n", nr_tti_rx, symbol_mod, pbch_pss_sss_re); - //LOG_I(PHY,"CRS Re Per PRB nr_tti_rx %d / symbol %d => %d \n", nr_tti_rx, symbol_mod, crs_re); - //LOG_I(PHY,"Data Re nr_tti_rx %d / symbol %d => %d \n", nr_tti_rx, symbol_mod, data_re); - - - - //LOG_I(PHY,"Data Re nr_tti_rx %d-symbol %d => llr length %d, llr offset %d \n", nr_tti_rx, symbol, - // pdsch_vars->llr_length[symbol], pdsch_vars->llr_offset[symbol]); - } -} -void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, - uint8_t N_RB_DL, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - NR_DL_FRAME_PARMS *frame_parms, - NR_UE_PDCCH *pdcch_vars, - NR_UE_PDSCH *pdsch_vars, - uint8_t nr_tti_rx, - uint16_t rnti, - uint16_t tc_rnti, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - NR_DL_UE_HARQ_t *pdlsch0_harq, - NR_UE_DLSCH_t *pdlsch0) -{ - - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint8_t vrb_type = pdci_info_extarcted->vrb_type; - uint32_t rballoc = pdci_info_extarcted->rballoc; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t rv1 = pdci_info_extarcted->rv1; - uint8_t ndi1 = pdci_info_extarcted->ndi1; - uint8_t TPC = pdci_info_extarcted->TPC; - uint8_t rah = pdci_info_extarcted->rah; - uint8_t dai = pdci_info_extarcted->dai; - - uint8_t NPRB = 0; - uint8_t nb_rb_alloc = 0; - - if(dci_format == format1A) - { - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - NPRB = (TPC&1) + 2; - switch (N_RB_DL) { - case 6: - nb_rb_alloc = RIV2nb_rb_LUT6[rballoc];//NPRB; - break; - case 25: - nb_rb_alloc = RIV2nb_rb_LUT25[rballoc];//NPRB; - break; - case 50: - nb_rb_alloc = RIV2nb_rb_LUT50[rballoc];//NPRB; - break; - case 100: - nb_rb_alloc = RIV2nb_rb_LUT100[rballoc];//NPRB; - break; - } - } - else - { - switch (N_RB_DL) { - case 6: - NPRB = RIV2nb_rb_LUT6[rballoc];//NPRB; - break; - case 25: - NPRB = RIV2nb_rb_LUT25[rballoc];//NPRB; - break; - case 50: - NPRB = RIV2nb_rb_LUT50[rballoc];//NPRB; - break; - case 100: - NPRB = RIV2nb_rb_LUT100[rballoc];//NPRB; - break; - } - nb_rb_alloc = NPRB; - } - } - else // format1 - { - NPRB = conv_nprb(rah, rballoc, N_RB_DL); - nb_rb_alloc = NPRB; - } - - pdlsch0->current_harq_pid = harq_pid; - pdlsch0->active = 1; - pdlsch0->rnti = rnti; - if(dci_format == format1A) - pdlsch0->harq_ack[nr_tti_rx].vDAI_DL = dai+1; - - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - pdlsch0_harq->round = 0; - pdlsch0_harq->status = ACTIVE; - } - else //CRNTI - { - if (rnti == tc_rnti) { - //fix for standalone Contention Resolution Id - pdlsch0_harq->DCINdi = (uint8_t)-1; - LOG_D(PHY,"UE (%x/%d): Format1A DCI: C-RNTI is temporary. Set NDI = %d and to be ignored\n", - rnti,harq_pid,pdlsch0_harq->DCINdi); - } - - // NDI has been toggled or this is the first transmission - if ((ndi1!=pdlsch0_harq->DCINdi) || (pdlsch0_harq->first_tx==1)) - { - pdlsch0_harq->round = 0; - pdlsch0_harq->first_tx = 0; - pdlsch0_harq->status = ACTIVE; - - }else if (rv1 != 0 ) - //NDI has not been toggled but rv was increased by eNB: retransmission - { - if (pdlsch0_harq->status == SCH_IDLE) - //packet was actually decoded in previous transmission (ACK was missed by eNB) - //However, the round is not a good check as it might have been decoded in a retransmission prior to this one. - { - LOG_D(PHY,"skip pdsch decoding and report ack\n"); - // skip pdsch decoding and report ack - //pdlsch0_harq->status = SCH_IDLE; - pdlsch0->active = 0; - pdlsch0->harq_ack[nr_tti_rx].ack = 1; - pdlsch0->harq_ack[nr_tti_rx].harq_id = harq_pid; - pdlsch0->harq_ack[nr_tti_rx].send_harq_status = 1; - - //pdlsch0_harq->first_tx = 0; - } - else //normal retransmission - { - // nothing special to do - } - } - else - { - pdlsch0_harq->status = ACTIVE; - } - } - - pdlsch0_harq->DCINdi = ndi1; - pdlsch0_harq->mcs = mcs1; - pdlsch0_harq->rvidx = rv1; - pdlsch0_harq->nb_rb = NPRB; - - pdlsch0_harq->codeword = 0; - pdlsch0_harq->Nl = 1; - pdlsch0_harq->mimo_mode = frame_parms->mode1_flag == 1 ?SISO : ALAMOUTI; - pdlsch0_harq->dl_power_off = 1; //no power offset - pdlsch0_harq->delta_PUCCH = nr_delta_PUCCH_lut[TPC &3]; - - // compute resource allocation - if(dci_format == format1A) - { - switch (N_RB_DL) { - case 6: - if (vrb_type == LOCALIZED) { - pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT6[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT6[rballoc]; - } - else { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT6[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT6[rballoc]; - } - break; - - case 25: - if (vrb_type == LOCALIZED) { - pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT25[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT25[rballoc]; - } - else { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT25[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT25[rballoc]; - } - break; - - case 50: - if (vrb_type == LOCALIZED) { - pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = localRIV2alloc_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = localRIV2alloc_LUT50_1[rballoc]; - // printf("rballoc: %08x.%08x\n",pdlsch0_harq->rb_alloc_even[0],pdlsch0_harq->rb_alloc_even[1]); - } else { // DISTRIBUTED - if ((rballoc&(1<<10)) == 0) { - rballoc = rballoc&(~(1<<10)); - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; - } - else { - rballoc = rballoc&(~(1<<10)); - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; - } - } - break; - - case 100: - if (vrb_type == LOCALIZED) { - pdlsch0_harq->rb_alloc_even[0] = localRIV2alloc_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = localRIV2alloc_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = localRIV2alloc_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = localRIV2alloc_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = localRIV2alloc_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = localRIV2alloc_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = localRIV2alloc_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = localRIV2alloc_LUT100_3[rballoc]; - } else { - if ((rballoc&(1<<10)) == 0) { //Gap 1 - rballoc = rballoc&(~(1<<12)); - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap0_even_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap0_even_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap0_odd_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap0_odd_LUT100_3[rballoc]; - } - else { //Gap 2 - rballoc = rballoc&(~(1<<12)); - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap1_even_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap1_even_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap1_odd_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap1_odd_LUT100_3[rballoc]; - } - } - break; - } - } - else // format1 - { - conv_rballoc(rah,rballoc,frame_parms->N_RB_DL,pdlsch0_harq->rb_alloc_even); - pdlsch0_harq->rb_alloc_odd[0]= pdlsch0_harq->rb_alloc_even[0]; - pdlsch0_harq->rb_alloc_odd[1]= pdlsch0_harq->rb_alloc_even[1]; - pdlsch0_harq->rb_alloc_odd[2]= pdlsch0_harq->rb_alloc_even[2]; - pdlsch0_harq->rb_alloc_odd[3]= pdlsch0_harq->rb_alloc_even[3]; - } - if ((rnti==si_rnti) || (rnti==p_rnti) || (rnti==ra_rnti)) - { - pdlsch0_harq->TBS = TBStable[mcs1][NPRB-1]; - pdlsch0_harq->Qm = 2; - } - else - { - if(mcs1 < 29) - { - pdlsch0_harq->TBS = TBStable[get_I_TBS(mcs1)][NPRB-1]; - pdlsch0_harq->Qm = get_Qm(mcs1); - } - } - - compute_llr_offset(frame_parms, - pdcch_vars, - pdsch_vars, - pdlsch0_harq, - nb_rb_alloc, - nr_tti_rx); -} - -void prepare_dl_decoding_format1C(uint8_t N_RB_DL, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - NR_DL_FRAME_PARMS *frame_parms, - NR_UE_PDCCH *pdcch_vars, - NR_UE_PDSCH *pdsch_vars, - uint32_t rnti, - uint32_t si_rnti, - uint32_t ra_rnti, - uint32_t p_rnti, - uint32_t frame, - uint8_t nr_tti_rx, - NR_DL_UE_HARQ_t *pdlsch0_harq, - NR_UE_DLSCH_t *pdlsch0) -{ - - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint32_t rballoc = pdci_info_extarcted->rballoc; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t Ngap = pdci_info_extarcted->Ngap; - - pdlsch0_harq->round = 0; - pdlsch0_harq->first_tx = 1; - pdlsch0_harq->vrb_type = DISTRIBUTED; - - if (rnti==si_rnti) { // rule from Section 5.3.1 of 36.321 - if (((frame&1) == 0) && (nr_tti_rx == 5)) - pdlsch0_harq->rvidx = (((3*((frame>>1)&3))+1)>>1)&3; // SIB1 - else - pdlsch0_harq->rvidx = (((3*(nr_tti_rx&3))+1)>>1)&3; // other SIBs - } - else if ((rnti==p_rnti) || (rnti==ra_rnti)) { // Section 7.1.7.3 - pdlsch0_harq->rvidx = 0; - } - - - pdlsch0_harq->Nl = 1; - pdlsch0_harq->mimo_mode = frame_parms->mode1_flag == 1 ?SISO : ALAMOUTI; - pdlsch0_harq->dl_power_off = 1; //no power offset - - pdlsch0_harq->codeword = 0; - pdlsch0_harq->mcs = mcs1; - pdlsch0_harq->TBS = TBStable1C[mcs1]; - pdlsch0_harq->Qm = 2; - - - pdlsch0->current_harq_pid = harq_pid; - pdlsch0->active = 1; - pdlsch0->rnti = rnti; - - switch (N_RB_DL) { - case 6: - pdlsch0_harq->nb_rb = RIV2nb_rb_LUT6[rballoc]; - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT6[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT6[rballoc]; - - break; - - case 25: - pdlsch0_harq->nb_rb = RIV2nb_rb_LUT25[rballoc]; - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_even_LUT25[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_odd_LUT25[rballoc]; - break; - - case 50: - pdlsch0_harq->nb_rb = RIV2nb_rb_LUT50[rballoc]; - if (Ngap == 0) { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT50_1[rballoc]; - } - else { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT50_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT50_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT50_1[rballoc]; - } - break; - - case 100: - pdlsch0_harq->nb_rb = RIV2nb_rb_LUT100[rballoc]; - if (Ngap==0) { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap0_even_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap0_odd_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap0_even_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap0_odd_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap0_even_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap0_odd_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap0_even_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap0_odd_LUT100_3[rballoc]; - } - else { - pdlsch0_harq->rb_alloc_even[0] = distRIV2alloc_gap1_even_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_odd[0] = distRIV2alloc_gap1_odd_LUT100_0[rballoc]; - pdlsch0_harq->rb_alloc_even[1] = distRIV2alloc_gap1_even_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_odd[1] = distRIV2alloc_gap1_odd_LUT100_1[rballoc]; - pdlsch0_harq->rb_alloc_even[2] = distRIV2alloc_gap1_even_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_odd[2] = distRIV2alloc_gap1_odd_LUT100_2[rballoc]; - pdlsch0_harq->rb_alloc_even[3] = distRIV2alloc_gap1_even_LUT100_3[rballoc]; - pdlsch0_harq->rb_alloc_odd[3] = distRIV2alloc_gap1_odd_LUT100_3[rballoc]; - } - break; - - default: - AssertFatal(0,"Format 1C: Unknown N_RB_DL %d\n",frame_parms->N_RB_DL); - break; - } - - compute_llr_offset(frame_parms, - pdcch_vars, - pdsch_vars, - pdlsch0_harq, - pdlsch0_harq->nb_rb, - nr_tti_rx); - -} - -void compute_precoding_info_2cw(uint8_t tpmi, uint8_t tbswap, uint16_t pmi_alloc, NR_DL_FRAME_PARMS *frame_parms, NR_DL_UE_HARQ_t *dlsch0_harq, NR_DL_UE_HARQ_t *dlsch1_harq) -{ - -switch (tpmi) { - case 0: - dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1; - dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODING1; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0, 1); - dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,0, 1); - break; - case 1: - dlsch0_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj; - dlsch1_harq->mimo_mode = DUALSTREAM_UNIFORM_PRECODINGj; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1, 1); - dlsch1_harq->pmi_alloc = pmi_extend(frame_parms,1, 1); - break; - case 2: // PUSCH precoding - dlsch0_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING; - dlsch1_harq->mimo_mode = DUALSTREAM_PUSCH_PRECODING; - if (tbswap==0){ - dlsch0_harq->pmi_alloc = pmi_alloc; - dlsch1_harq->pmi_alloc = pmi_alloc^0x1555; - } else { - dlsch1_harq->pmi_alloc = pmi_alloc; - dlsch0_harq->pmi_alloc = pmi_alloc^0x1555; - } -#ifdef DEBUG_HARQ - printf ("\n \n compute_precoding_info_2cw pmi_alloc_new = %d\n", dlsch0_harq->pmi_alloc); - #endif - break; - default: - break; - } -} - -void compute_precoding_info_1cw(uint8_t tpmi, uint16_t pmi_alloc, NR_DL_FRAME_PARMS *frame_parms, NR_DL_UE_HARQ_t *dlsch_harq) -{ - -switch (tpmi) { - case 0 : - dlsch_harq->mimo_mode = ALAMOUTI; - break; - case 1: - dlsch_harq->mimo_mode = UNIFORM_PRECODING11; - dlsch_harq->pmi_alloc = pmi_extend(frame_parms,0, 0); - break; - case 2: - dlsch_harq->mimo_mode = UNIFORM_PRECODING1m1; - dlsch_harq->pmi_alloc = pmi_extend(frame_parms,1, 0); - break; - case 3: - dlsch_harq->mimo_mode = UNIFORM_PRECODING1j; - dlsch_harq->pmi_alloc = pmi_extend(frame_parms,2, 0); - break; - case 4: - dlsch_harq->mimo_mode = UNIFORM_PRECODING1mj; - dlsch_harq->pmi_alloc = pmi_extend(frame_parms,3, 0); - break; - case 5: - dlsch_harq->mimo_mode = PUSCH_PRECODING0; - dlsch_harq->pmi_alloc = pmi_alloc;//pmi_convert(frame_parms,dlsch0->pmi_alloc,0); - break; - case 6: - dlsch_harq->mimo_mode = PUSCH_PRECODING1; - dlsch_harq->pmi_alloc = pmi_alloc;//pmi_convert(frame_parms,dlsch0->pmi_alloc,1); - break; - } - #ifdef DEBUG_HARQ - printf ("[DCI UE] I am calling from the UE side pmi_alloc_new = %d with tpmi %d\n", dlsch_harq->pmi_alloc, tpmi); - #endif - } - -void compute_precoding_info_format2A(uint8_t tpmi, - uint8_t nb_antenna_ports_eNB, - uint8_t tb0_active, - uint8_t tb1_active, - NR_DL_UE_HARQ_t *dlsch0_harq, - NR_DL_UE_HARQ_t *dlsch1_harq) -{ - - dlsch0_harq->dl_power_off = 0; - dlsch1_harq->dl_power_off = 0; - - if (nb_antenna_ports_eNB == 2) { - if ((tb0_active==1) && (tb1_active==1)) { - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - } else { - dlsch0_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->mimo_mode = ALAMOUTI; - } - } else if (nb_antenna_ports_eNB == 4) { // 4 antenna case - if ((tb0_active==1) && (tb1_active==1)) { - switch (tpmi) { - case 0: // one layer per transport block - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - break; - - case 1: // one-layers on TB 0, two on TB 1 - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - break; - - case 2: // two-layers on TB 0, two on TB 1 - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - break; - - case 3: // - LOG_E(PHY,"Illegal value (3) for TPMI in Format 2A DCI\n"); - break; - } - } else if (tb0_active == 1) { - switch (tpmi) { - case 0: // one layer per transport block - dlsch0_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->mimo_mode = ALAMOUTI; - break; - - case 1: // two-layers on TB 0 - dlsch0_harq->mimo_mode = LARGE_CDD; - dlsch0_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - break; - - case 2: // two-layers on TB 0, two on TB 1 - case 3: // - LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",tpmi); - break; - } - } else if (tb1_active == 1) { - switch (tpmi) { - case 0: // one layer per transport block - dlsch0_harq->mimo_mode = ALAMOUTI; - dlsch1_harq->mimo_mode = ALAMOUTI; - break; - - case 1: // two-layers on TB 0 - dlsch1_harq->mimo_mode = LARGE_CDD; - dlsch1_harq->Nl = 2; - dlsch0_harq->dl_power_off = 1; - break; - - case 2: // two-layers on TB 0, two on TB 1 - case 3: // - LOG_E(PHY,"Illegal value %d for TPMI in Format 2A DCI with one transport block enabled\n",tpmi); - break; - } - } - } - // printf("Format 2A: NPRB=%d (rballoc %x,mcs1 %d, mcs2 %d, frame_type %d N_RB_DL %d,active %d/%d)\n",NPRB,rballoc,mcs1,mcs2,frame_parms->frame_type,frame_parms->N_RB_DL,dlsch0->active,dlsch1->active); - //printf("UE (%x/%d): nr_tti_rx %d Format2A DCI: ndi1 %d, old_ndi1 %d, ndi2 %d, old_ndi2 %d (first tx1 %d, first tx2 %d) harq_status1 %d, harq_status2 %d\n",dlsch0->rnti,harq_pid,nr_tti_rx,ndi,dlsch0_harq->DCINdi, - // dlsch0_harq->first_tx,dlsch1_harq->first_tx,dlsch0_harq->status,dlsch1_harq->status); - //printf("TBS0 %d, TBS1 %d\n",dlsch0_harq->TBS,dlsch1_harq->TBS); - -} - -void prepare_dl_decoding_format2_2A(DCI_format_t dci_format, - DCI_INFO_EXTRACTED_t *pdci_info_extarcted, - NR_DL_FRAME_PARMS *frame_parms, - NR_UE_PDCCH *pdcch_vars, - NR_UE_PDSCH *pdsch_vars, - uint16_t rnti, - uint8_t nr_tti_rx, - NR_DL_UE_HARQ_t *dlsch0_harq, - NR_DL_UE_HARQ_t *dlsch1_harq, - NR_UE_DLSCH_t *pdlsch0, - NR_UE_DLSCH_t *pdlsch1) -{ - - uint8_t rah = pdci_info_extarcted->rah; - uint8_t mcs1 = pdci_info_extarcted->mcs1; - uint8_t mcs2 = pdci_info_extarcted->mcs2; - uint8_t rv1 = pdci_info_extarcted->rv1; - uint8_t rv2 = pdci_info_extarcted->rv2; - uint8_t harq_pid = pdci_info_extarcted->harq_pid; - uint32_t rballoc = pdci_info_extarcted->rballoc; - uint8_t tbswap = pdci_info_extarcted->tb_swap; - uint8_t tpmi = pdci_info_extarcted->tpmi; - uint8_t TPC = pdci_info_extarcted->TPC; - uint8_t ndi1 = pdci_info_extarcted->ndi1; - uint8_t ndi2 = pdci_info_extarcted->ndi2; - - uint8_t TB0_active = 1; - uint8_t TB1_active = 1; - - // printf("inside prepare pdlsch1->pmi_alloc %d \n",pdlsch1->pmi_alloc); - - - if ((rv1 == 1) && (mcs1 == 0)) { - TB0_active=0; - } - if ((rv2 == 1) && (mcs2 == 0)) { - TB1_active=0; - } - -#ifdef DEBUG_HARQ - printf("[DCI UE]: TB0 status %d , TB1 status %d\n", TB0_active, TB1_active); -#endif - - dlsch0_harq->mcs = mcs1; - dlsch1_harq->mcs = mcs2; - dlsch0_harq->rvidx = rv1; - dlsch1_harq->rvidx = rv2; - dlsch0_harq->DCINdi = ndi1; - dlsch1_harq->DCINdi = ndi2; - - dlsch0_harq->codeword = 0; - dlsch1_harq->codeword = 1; - dlsch0_harq->Nl = 1; - dlsch1_harq->Nl = 1; - dlsch0_harq->delta_PUCCH = nr_delta_PUCCH_lut[TPC&3]; - dlsch1_harq->delta_PUCCH = nr_delta_PUCCH_lut[TPC&3]; - dlsch0_harq->dl_power_off = 1; - dlsch1_harq->dl_power_off = 1; - - pdlsch0->current_harq_pid = harq_pid; - pdlsch0->harq_ack[nr_tti_rx].harq_id = harq_pid; - pdlsch1->current_harq_pid = harq_pid; - pdlsch1->harq_ack[nr_tti_rx].harq_id = harq_pid; - - // assume two CW are active - dlsch0_harq->status = ACTIVE; - dlsch1_harq->status = ACTIVE; - pdlsch0->active = 1; - pdlsch1->active = 1; - pdlsch0->rnti = rnti; - pdlsch1->rnti = rnti; - - - if (TB0_active && TB1_active && tbswap==1) { - dlsch0_harq->codeword = 1; - dlsch1_harq->codeword = 0; - } - - - if (!TB0_active && TB1_active){ - dlsch1_harq->codeword = 0; - } - - if (TB0_active && !TB1_active){ - dlsch0_harq->codeword = 0; - } - - - if (TB0_active==0) { - dlsch0_harq->status = SCH_IDLE; - pdlsch0->active = 0; - #ifdef DEBUG_HARQ - printf("[DCI UE]: TB0 is deactivated, retransmit TB1 transmit in TM6\n"); - #endif - } - - if (TB1_active==0) { - dlsch1_harq->status = SCH_IDLE; - pdlsch1->active = 0; - } - -#ifdef DEBUG_HARQ - printf("[DCI UE]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); -#endif - - // compute resource allocation - if (TB0_active == 1){ - - dlsch0_harq->nb_rb = conv_nprb(rah, - rballoc, - frame_parms->N_RB_DL); - conv_rballoc(rah, - rballoc, - frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc_even); - - dlsch0_harq->rb_alloc_odd[0]= dlsch0_harq->rb_alloc_even[0]; - dlsch0_harq->rb_alloc_odd[1]= dlsch0_harq->rb_alloc_even[1]; - dlsch0_harq->rb_alloc_odd[2]= dlsch0_harq->rb_alloc_even[2]; - dlsch0_harq->rb_alloc_odd[3]= dlsch0_harq->rb_alloc_even[3]; - - if (TB1_active == 1){ - dlsch1_harq->rb_alloc_even[0]= dlsch0_harq->rb_alloc_even[0]; - dlsch1_harq->rb_alloc_even[1]= dlsch0_harq->rb_alloc_even[1]; - dlsch1_harq->rb_alloc_even[2]= dlsch0_harq->rb_alloc_even[2]; - dlsch1_harq->rb_alloc_even[3]= dlsch0_harq->rb_alloc_even[3]; - dlsch1_harq->rb_alloc_odd[0] = dlsch0_harq->rb_alloc_odd[0]; - dlsch1_harq->rb_alloc_odd[1] = dlsch0_harq->rb_alloc_odd[1]; - dlsch1_harq->rb_alloc_odd[2] = dlsch0_harq->rb_alloc_odd[2]; - dlsch1_harq->rb_alloc_odd[3] = dlsch0_harq->rb_alloc_odd[3]; - - dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; - - //dlsch0_harq->Nl = 1; - //dlsch1_harq->Nl = 1; - } - } else if ((TB0_active == 0) && (TB1_active == 1)){ - - conv_rballoc(rah, - rballoc, - frame_parms->N_RB_DL, - dlsch1_harq->rb_alloc_even); - - dlsch1_harq->rb_alloc_odd[0]= dlsch1_harq->rb_alloc_even[0]; - dlsch1_harq->rb_alloc_odd[1]= dlsch1_harq->rb_alloc_even[1]; - dlsch1_harq->rb_alloc_odd[2]= dlsch1_harq->rb_alloc_even[2]; - dlsch1_harq->rb_alloc_odd[3]= dlsch1_harq->rb_alloc_even[3]; - dlsch1_harq->nb_rb = conv_nprb(rah, - rballoc, - frame_parms->N_RB_DL); - } - - - // compute precoding matrix + mimo mode - if(dci_format == format2) - { - if ((TB0_active) && (TB1_active)){ //two CW active - compute_precoding_info_2cw(tpmi, tbswap, pdlsch0->pmi_alloc,frame_parms, dlsch0_harq, dlsch1_harq); - - // printf("[DCI UE 1]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); - } else if ((TB0_active) && (!TB1_active)) { // only CW 0 active - compute_precoding_info_1cw(tpmi, pdlsch0->pmi_alloc, frame_parms, dlsch0_harq); - } else { - compute_precoding_info_1cw(tpmi, pdlsch1->pmi_alloc, frame_parms, dlsch1_harq); - // printf("I am doing compute_precoding_info_1cw with tpmi %d \n", tpmi); - } - //printf(" UE DCI harq0 MIMO mode = %d\n", dlsch0_harq->mimo_mode); - if ((frame_parms->mode1_flag == 1) && (TB0_active)) - dlsch0_harq->mimo_mode = SISO; - } - else - { - compute_precoding_info_format2A( tpmi, - frame_parms->nb_antenna_ports_eNB, - TB0_active, - TB1_active, - dlsch0_harq, - dlsch1_harq); - } - // printf("[DCI UE 2]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); - // reset round + compute Qm - if (TB0_active) { - // printf("TB0 ndi1 =%d, dlsch0_harq->DCINdi =%d, dlsch0_harq->first_tx = %d\n", ndi1, dlsch0_harq->DCINdi, dlsch0_harq->first_tx); - if ((ndi1!=dlsch0_harq->DCINdi) || (dlsch0_harq->first_tx==1)) { - dlsch0_harq->round = 0; - dlsch0_harq->status = ACTIVE; - dlsch0_harq->DCINdi = ndi1; - - //LOG_I(PHY,"[UE] DLSCH: New Data Indicator CW0 subframe %d (pid %d, round %d)\n", - // subframe,harq_pid,dlsch0_harq->round); - if ( dlsch0_harq->first_tx==1) { - LOG_D(PHY,"Format 2 DCI First TX0: Clearing flag\n"); - dlsch0_harq->first_tx = 0; - } - } - /*else if (rv1 != 0 ) - //NDI has not been toggled but rv was increased by eNB: retransmission - { - if(dlsch0_harq->status == SCH_IDLE) { - // skip pdsch decoding and report ack - //dlsch0_harq->status = SCH_IDLE; - pdlsch0->active = 0; - pdlsch0->harq_ack[subframe].ack = 1; - pdlsch0->harq_ack[subframe].harq_id = harq_pid; - pdlsch0->harq_ack[subframe].send_harq_status = 1; - }*/ - - // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest - // PDCCH for the same trasport block using Imcs in [0 .. 28] - if(dlsch0_harq->mcs <= 28) - { - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - LOG_D(PHY,"[UE] DLSCH: New TBS CW0 nr_tti_rx %d (pid %d, round %d) TBS %d \n", - nr_tti_rx,harq_pid,dlsch0_harq->round, dlsch0_harq->TBS); - } - else - { - LOG_D(PHY,"[UE] DLSCH: Keep the same TBS CW0 nr_tti_rx %d (pid %d, round %d) TBS %d \n", - nr_tti_rx,harq_pid,dlsch0_harq->round, dlsch0_harq->TBS); - } - //if(dlsch0_harq->Nl == 2) - //dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][(dlsch0_harq->nb_rb<<1)-1]; - if (mcs1 <= 28) - dlsch0_harq->Qm = get_Qm(mcs1); - else if (mcs1<=31) - dlsch0_harq->Qm = (mcs1-28)<<1; - } - - // printf("[DCI UE 3]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); - - if (TB1_active) { - // printf("TB1 ndi2 =%d, dlsch1_harq->DCINdi =%d, dlsch1_harq->first_tx = %d\n", ndi2, dlsch1_harq->DCINdi, dlsch1_harq->first_tx); - if ((ndi2!=dlsch1_harq->DCINdi) || (dlsch1_harq->first_tx==1)) { - dlsch1_harq->round = 0; - dlsch1_harq->status = ACTIVE; - dlsch1_harq->DCINdi = ndi2; - //LOG_I(PHY,"[UE] DLSCH: New Data Indicator CW1 subframe %d (pid %d, round %d)\n", - // subframe,harq_pid,dlsch0_harq->round); - if (dlsch1_harq->first_tx==1) { - LOG_D(PHY,"Format 2 DCI First TX1: Clearing flag\n"); - dlsch1_harq->first_tx = 0; - } - } - /*else if (rv1 != 0 ) - //NDI has not been toggled but rv was increased by eNB: retransmission - { - if(dlsch1_harq->status == SCH_IDLE) { - // skip pdsch decoding and report ack - //dlsch1_harq->status = SCH_IDLE; - pdlsch1->active = 0; - pdlsch1->harq_ack[subframe].ack = 1; - pdlsch1->harq_ack[subframe].harq_id = harq_pid; - pdlsch1->harq_ack[subframe].send_harq_status = 1; - } - }*/ - - // if Imcs in [29..31] TBS is assumed to be as determined from DCI transported in the latest - // PDCCH for the same trasport block using Imcs in [0 .. 28] - if(dlsch1_harq->mcs <= 28) - { - dlsch1_harq->TBS = TBStable[get_I_TBS(dlsch1_harq->mcs)][dlsch1_harq->nb_rb-1]; - LOG_D(PHY,"[UE] DLSCH: New TBS CW1 nr_tti_rx %d (pid %d, round %d) TBS %d \n", - nr_tti_rx,harq_pid,dlsch1_harq->round, dlsch1_harq->TBS); - } - else - { - LOG_D(PHY,"[UE] DLSCH: Keep the same TBS CW1 nr_tti_rx %d (pid %d, round %d) TBS %d \n", - nr_tti_rx,harq_pid,dlsch1_harq->round, dlsch1_harq->TBS); - } - if (mcs2 <= 28) - dlsch1_harq->Qm = get_Qm(mcs2); - else if (mcs1<=31) - dlsch1_harq->Qm = (mcs2-28)<<1; - } - - - compute_llr_offset(frame_parms, - pdcch_vars, - pdsch_vars, - dlsch0_harq, - dlsch0_harq->nb_rb, - nr_tti_rx); - - - /* #ifdef DEBUG_HARQ - printf("[DCI UE]: dlsch0_harq status %d , dlsch1_harq status %d\n", dlsch0_harq->status, dlsch1_harq->status); - printf("[DCI UE]: TB0_active %d , TB1_active %d\n", TB0_active, TB1_active); - if (dlsch0 != NULL && dlsch1 != NULL) - printf("[DCI UE] dlsch0_harq status = %d, dlsch1_harq status = %d\n", dlsch0_harq->status, dlsch1_harq->status); - else if (dlsch0 == NULL && dlsch1 != NULL) - printf("[DCI UE] dlsch0_harq NULL dlsch1_harq status = %d\n", dlsch1_harq->status); - else if (dlsch0 != NULL && dlsch1 == NULL) - printf("[DCI UE] dlsch1_harq NULL dlsch0_harq status = %d\n", dlsch0_harq->status); - #endif*/ -} -#endif //(0) - #ifdef NR_PDCCH_DCI_TOOLS int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, @@ -7106,563 +1121,7 @@ int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue, } #endif -#if 0 -int generate_ue_dlsch_params_from_dci(int frame, - uint8_t nr_tti_rx, - void *dci_pdu, - uint16_t rnti, - DCI_format_t dci_format, - NR_UE_PDCCH *pdcch_vars, - NR_UE_PDSCH *pdsch_vars, - NR_UE_DLSCH_t **dlsch, - NR_DL_FRAME_PARMS *frame_parms, - PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint8_t beamforming_mode, - uint16_t tc_rnti) -{ - uint8_t harq_pid=0; - uint8_t frame_type=frame_parms->frame_type; - uint8_t tpmi=0; - NR_UE_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; - NR_DL_UE_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; - - DCI_INFO_EXTRACTED_t dci_info_extarcted; - uint8_t status=0; -//////////////////////////////////////////////////////////////////////////////////////////////////////////////// - printf("####################### verifying pointer\n"); - dlsch0 = dlsch[0]; - dlsch0->active = 0; - dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; - printf("####################### verifying pointer, dlsch0 = %p, dlsch0_harq = %p\n",dlsch0,dlsch0_harq); -//////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if (!dlsch[0]) return -1; - - #ifdef DEBUG_DCI - LOG_D(PHY,"dci_tools.c: Filling ue dlsch params -> rnti %x, SFN/SF %d/%d, dci_format %s\n", - rnti, - frame%1024, - nr_tti_rx, - (dci_format==format0? "Format 0":( - dci_format==format1? "format 1":( - dci_format==format1A? "format 1A":( - dci_format==format1B? "format 1B":( - dci_format==format1C? "format 1C":( - dci_format==format1D? "format 1D":( - dci_format==format1E_2A_M10PRB? "format 1E_2A_M10PRB":( - dci_format==format2? "format 2":( - dci_format==format2A? "format 2A":( - dci_format==format2B? "format 2B":( - dci_format==format2C? "format 2C":( - dci_format==format2D? "format 2D":( - dci_format==format3? "format 3": "UNKNOWN" - )))))))))))))); - #endif - - memset(&dci_info_extarcted,0,sizeof(dci_info_extarcted)); - switch (dci_format) { - - case format0: // This is an ULSCH allocation so nothing here, inform MAC - LOG_E(PHY,"format0 not possible\n"); - return(-1); - break; - - case format1A: - { - // extract dci infomation -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d extarct dci info \n", frame, nr_tti_rx); -#endif - extract_dci1A_info(frame_parms->N_RB_DL, - frame_type, - dci_pdu, - &dci_info_extarcted); - - - // check dci content - dlsch0 = dlsch[0]; - dlsch0->active = 0; - dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d check dci coherency \n", frame, nr_tti_rx); -#endif - status = check_dci_format1_1a_coherency(format1A, - frame_parms->N_RB_DL, - rnti, - tc_rnti, - si_rnti, - ra_rnti, - p_rnti,frame,nr_tti_rx, - &dci_info_extarcted, - dlsch0_harq); - if(status == 0) - { - printf("bad DCI 1A !!! \n"); - return(-1); - } - - // dci is correct ==> update internal structure and prepare dl decoding -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1A] AbsSubframe %d.%d prepare dl decoding \n", frame, nr_tti_rx); -#endif - prepare_dl_decoding_format1_1A(format1A, - frame_parms->N_RB_DL, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - nr_tti_rx, - rnti, - tc_rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq, - dlsch0); - - - - break; - } - case format1C: - { - // extract dci infomation -#ifdef DEBUG_DL_DECODING - LOG_I(PHY,"[DCI Format-1C] extact dci information \n"); -#endif - extract_dci1C_info(frame_parms->N_RB_DL, - frame_type, - dci_pdu, - &dci_info_extarcted); - - - // check dci content -#ifdef DEBUG_DL_DECODING - LOG_I(PHY,"[DCI Format-1C] check dci content \n"); -#endif - dlsch0 = dlsch[0]; - dlsch0->active = 0; - dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; - - status = check_dci_format1c_coherency(frame_parms->N_RB_DL, - &dci_info_extarcted, - rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq); - if(status == 0) - return(-1); - - // dci is correct ==> update internal structure and prepare dl decoding -#ifdef DEBUG_DL_DECODING - LOG_I(PHY,"[DCI Format-1C] prepare downlink decoding \n"); -#endif - prepare_dl_decoding_format1C(frame_parms->N_RB_DL, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - rnti, - si_rnti, - ra_rnti, - p_rnti, - frame, - nr_tti_rx, - dlsch0_harq, - dlsch0); - - break; - } - - case format1: - { - // extract dci infomation -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d extarct dci info \n", frame, nr_tti_rx); -#endif - extract_dci1_info(frame_parms->N_RB_DL, - frame_type, - dci_pdu, - &dci_info_extarcted); - - // check dci content - dlsch0 = dlsch[0]; - dlsch0->active = 0; - dlsch0_harq = dlsch[0]->harq_processes[dci_info_extarcted.harq_pid]; - -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d check dci coherency \n", frame, nr_tti_rx); -#endif - status = check_dci_format1_1a_coherency(format1, - frame_parms->N_RB_DL, - rnti, - tc_rnti, - si_rnti, - ra_rnti, - p_rnti,frame,nr_tti_rx, - &dci_info_extarcted, - dlsch0_harq); - if(status == 0) - { - printf("bad DCI 1 !!! \n"); - return(-1); - } - - - // dci is correct ==> update internal structure and prepare dl decoding -#ifdef DEBUG_DCI - LOG_I(PHY,"[DCI-FORMAT-1] AbsSubframe %d.%d prepare dl decoding \n", frame, nr_tti_rx); -#endif - prepare_dl_decoding_format1_1A(format1, - frame_parms->N_RB_DL, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - nr_tti_rx, - rnti, - tc_rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq, - dlsch0); - break; - } - - case format2: - { - // extract dci infomation - //LOG_I(PHY,"[DCI-format2] AbsSubframe %d.%d extract dci infomation \n", frame, subframe); - extract_dci2_info(frame_parms->N_RB_DL, - frame_type, - frame_parms->nb_antenna_ports_eNB, - dci_pdu, - &dci_info_extarcted); - - - // check dci content - dlsch[0]->active = 1; - dlsch[1]->active = 1; - - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - - dlsch0_harq = dlsch0->harq_processes[dci_info_extarcted.harq_pid]; - dlsch1_harq = dlsch1->harq_processes[dci_info_extarcted.harq_pid]; - // printf("before coherency dlsch[1]->pmi_alloc %d\n",dlsch[1]->pmi_alloc); - // printf("before coherency dlsch1->pmi_alloc %d\n",dlsch1->pmi_alloc); - // printf("before coherency dlsch1_harq->pmi_alloc %d\n",dlsch1_harq->pmi_alloc); - - //LOG_I(PHY,"[DCI-format2] check dci content \n"); - status = check_dci_format2_2a_coherency(format2, - frame_parms->N_RB_DL, - &dci_info_extarcted, - rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq, - dlsch1_harq); - if(status == 0) - return(-1); - - - // dci is correct ==> update internal structure and prepare dl decoding - //LOG_I(PHY,"[DCI-format2] update internal structure and prepare dl decoding \n"); - prepare_dl_decoding_format2_2A(format2, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - rnti, - nr_tti_rx, - dlsch0_harq, - dlsch1_harq, - dlsch0, - dlsch1); - } - break; - - case format2A: - { - // extract dci infomation - LOG_I(PHY,"[DCI-format2] AbsSubframe %d.%d extract dci infomation \n", frame%1024, nr_tti_rx); - extract_dci2A_info(frame_parms->N_RB_DL, - frame_type, - frame_parms->nb_antenna_ports_eNB, - dci_pdu, - &dci_info_extarcted); - - // check dci content - //LOG_I(PHY,"[DCI-format2A] check dci content \n"); - //LOG_I(PHY,"[DCI-format2A] tb_swap %d harq_pid %d\n", dci_info_extarcted.tb_swap, dci_info_extarcted.harq_pid); - //dlsch[0]->active = 0; - //dlsch[1]->active = 0; - - if (dci_info_extarcted.tb_swap == 0) { - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - } else { - dlsch0 = dlsch[1]; - dlsch1 = dlsch[0]; - } - dlsch0_harq = dlsch0->harq_processes[dci_info_extarcted.harq_pid]; - dlsch1_harq = dlsch1->harq_processes[dci_info_extarcted.harq_pid]; - - //LOG_I(PHY,"[DCI-format2A] check dci content \n"); - status = check_dci_format2_2a_coherency(format2A, - frame_parms->N_RB_DL, - &dci_info_extarcted, - rnti, - si_rnti, - ra_rnti, - p_rnti, - dlsch0_harq, - dlsch1_harq); - if(status == 0) - return(-1); - - // dci is correct ==> update internal structure and prepare dl decoding - //LOG_I(PHY,"[DCI-format2A] update internal structure and prepare dl decoding \n"); - prepare_dl_decoding_format2_2A(format2A, - &dci_info_extarcted, - frame_parms, - pdcch_vars, - pdsch_vars, - rnti, - nr_tti_rx, - dlsch0_harq, - dlsch1_harq, - dlsch0, - dlsch1); - } - break; - - case format1E_2A_M10PRB: - if (!dlsch[0]) return -1; - - harq_pid = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->harq_pid; - - if (harq_pid>=8) { - LOG_E(PHY,"Format 1E_2A_M10PRB: harq_pid=%d >= 8\n", harq_pid); - return(-1); - } - - dlsch[0]->current_harq_pid = harq_pid; - dlsch[0]->harq_ack[nr_tti_rx].harq_id = harq_pid; - - /* - tbswap = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->tb_swap; - if (tbswap == 0) { - dlsch0 = dlsch[0]; - dlsch1 = dlsch[1]; - } - else{ - dlsch0 = dlsch[1]; - dlsch1 = dlsch[0]; - } - */ - dlsch0 = dlsch[0]; - - dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; - // Needs to be checked - dlsch0_harq->codeword=0; - conv_rballoc(((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rah, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rballoc,frame_parms->N_RB_DL, - dlsch0_harq->rb_alloc_even); - - dlsch0_harq->rb_alloc_odd[0] = dlsch0_harq->rb_alloc_even[0]; - dlsch0_harq->rb_alloc_odd[1] = dlsch0_harq->rb_alloc_even[1]; - dlsch0_harq->rb_alloc_odd[2] = dlsch0_harq->rb_alloc_even[2]; - dlsch0_harq->rb_alloc_odd[3] = dlsch0_harq->rb_alloc_even[3]; - /* - dlsch1_harq->rb_alloc_even[0] = dlsch0_harq->rb_alloc_even[0]; - dlsch1_harq->rb_alloc_even[1] = dlsch0_harq->rb_alloc_even[1]; - dlsch1_harq->rb_alloc_even[2] = dlsch0_harq->rb_alloc_even[2]; - dlsch1_harq->rb_alloc_even[3] = dlsch0_harq->rb_alloc_even[3]; - */ - dlsch0_harq->nb_rb = conv_nprb(((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rah, - ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rballoc, - frame_parms->N_RB_DL); - //dlsch1_harq->nb_rb = dlsch0_harq->nb_rb; - - dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; - dlsch0_harq->delta_PUCCH = nr_delta_PUCCH_lut[((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->TPC&3]; - - - - /* - if (dlsch0_harq->mcs>20) { - printf("dci_tools.c: mcs > 20 disabled for now (asked %d)\n",dlsch0_harq->mcs); - return(-1); - } - */ - - //dlsch1_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs2; - dlsch0_harq->rvidx = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rv; - //dlsch1_harq->rvidx = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->rv2; - - // check if either TB is disabled (see 36-213 V8.6 p. 26) - - if ((dlsch0_harq->rvidx == 1) && (dlsch0_harq->mcs == 0)) { - dlsch0_harq->status = DISABLED; - } - - //if ((dlsch1_harq->rvidx == 1) && (dlsch1_harq->mcs == 0)) { - //dlsch1_harq->status = DISABLED; - //} - dlsch0_harq->Nl = 1; - - //dlsch0->layer_index = tbswap; - //dlsch1->layer_index = 1-tbswap; - - - // Fix this - tpmi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->tpmi; - // printf("ue: tpmi %d\n",tpmi); - - switch (tpmi) { - case 0 : - dlsch0_harq->mimo_mode = ALAMOUTI; - break; - - case 1: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING11; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,0,0); - break; - - case 2: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1m1; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,1, 0); - break; - - case 3: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1j; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,2, 0); - - break; - - case 4: - dlsch0_harq->mimo_mode = UNIFORM_PRECODING1mj; - dlsch0_harq->pmi_alloc = pmi_extend(frame_parms,3, 0); - break; - - case 5: - dlsch0_harq->mimo_mode = PUSCH_PRECODING0; - // pmi stored from ulsch allocation routine - dlsch0_harq->pmi_alloc = dlsch0->pmi_alloc; - //LOG_I(PHY,"XXX using PMI %x\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc)); - break; - - case 6: - dlsch0_harq->mimo_mode = PUSCH_PRECODING1; - LOG_E(PHY,"Unsupported TPMI\n"); - return(-1); - break; - } - - - if (frame_parms->mode1_flag == 1) - dlsch0_harq->mimo_mode = SISO; - - - if ((dlsch0_harq->DCINdi != ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi) || - (dlsch0_harq->first_tx==1)) { - - dlsch0_harq->round = 0; - dlsch0_harq->first_tx = 0; - dlsch0_harq->status = ACTIVE; - } - /* - else if (dlsch0_harq->status == SCH_IDLE) { // we got same ndi for a previously decoded process, - // this happens if either another harq process in the same - // is NAK or an ACK was not received - - dlsch0->harq_ack[subframe].ack = 1; - dlsch0->harq_ack[subframe].harq_id = harq_pid; - dlsch0->harq_ack[subframe].send_harq_status = 1; - dlsch0->active = 0; - return(0); - } - */ - - dlsch0_harq->DCINdi = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->ndi; - dlsch0_harq->mcs = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->mcs; - - if (dlsch0_harq->nb_rb>1) { - dlsch0_harq->TBS = TBStable[get_I_TBS(dlsch0_harq->mcs)][dlsch0_harq->nb_rb-1]; - } else - dlsch0_harq->TBS =0; - - dlsch0->rnti = rnti; - //dlsch1->rnti = rnti; - - dlsch0->active = 1; - //dlsch1->active = 1; - - dlsch0_harq->dl_power_off = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->dl_power_off; - //dlsch1_harq->dl_power_off = ((DCI1E_5MHz_2A_M10PRB_TDD_t *)dci_pdu)->dl_power_off; - - - break; - - default: - LOG_E(PHY,"format %d not yet implemented\n",dci_format); - return(-1); - break; - } - -#ifdef UE_DEBUG_TRACE - - if (dlsch[0] && (dlsch[0]->rnti != 0xffff)) { - LOG_I(PHY,"dci_format:%d Abssubframe: %d.%d \n",dci_format,frame%1024,nr_tti_rx); - LOG_I(PHY,"PDSCH dlsch0 UE: rnti %x\n",dlsch[0]->rnti); - LOG_D(PHY,"PDSCH dlsch0 UE: NBRB %d\n",dlsch0_harq->nb_rb); - LOG_D(PHY,"PDSCH dlsch0 UE: rballoc %x\n",dlsch0_harq->rb_alloc_even[0]); - LOG_I(PHY,"PDSCH dlsch0 UE: harq_pid %d\n",dci_info_extarcted.harq_pid); - LOG_I(PHY,"PDSCH dlsch0 UE: g %d\n",dlsch[0]->g_pucch); - LOG_D(PHY,"PDSCH dlsch0 UE: round %d\n",dlsch0_harq->round); - LOG_D(PHY,"PDSCH dlsch0 UE: DCINdi %d\n",dlsch0_harq->DCINdi); - LOG_D(PHY,"PDSCH dlsch0 UE: rvidx %d\n",dlsch0_harq->rvidx); - LOG_D(PHY,"PDSCH dlsch0 UE: TBS %d\n",dlsch0_harq->TBS); - LOG_D(PHY,"PDSCH dlsch0 UE: mcs %d\n",dlsch0_harq->mcs); - LOG_D(PHY,"PDSCH dlsch0 UE: pwr_off %d\n",dlsch0_harq->dl_power_off); - } -#endif - - #if T_TRACER - if( (dlsch[0]->rnti != si_rnti) && (dlsch[0]->rnti != ra_rnti) && (dlsch[0]->rnti != p_rnti)) - { - T(T_UE_PHY_DLSCH_UE_DCI, T_INT(0), T_INT(frame%1024), T_INT(nr_tti_rx), T_INT(0), - T_INT(dlsch[0]->rnti), T_INT(dci_format), - T_INT(harq_pid), - T_INT(dlsch0_harq->mcs), - T_INT(dlsch0_harq->TBS)); - } - #endif - - - // compute DL power control parameters - if (dlsch0_harq != NULL){ - computeRhoA_UE(pdsch_config_dedicated, dlsch[0],dlsch0_harq->dl_power_off, frame_parms->nb_antenna_ports_eNB); - computeRhoB_UE(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antenna_ports_eNB,dlsch[0],dlsch0_harq->dl_power_off); - } - - if (dlsch1_harq != NULL) { - computeRhoA_UE(pdsch_config_dedicated, dlsch[1],dlsch1_harq->dl_power_off, frame_parms->nb_antenna_ports_eNB); - computeRhoB_UE(pdsch_config_dedicated,&(frame_parms->pdsch_config_common),frame_parms->nb_antenna_ports_eNB,dlsch[1],dlsch1_harq->dl_power_off); - } - - - return(0); -} - -#endif //(0) uint8_t nr_subframe2harq_pid(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t nr_tti_rx) { /* @@ -7781,26 +1240,6 @@ uint8_t nr_pdcch_alloc2ul_subframe(NR_DL_FRAME_PARMS *frame_parms,uint8_t n) LOG_D(PHY, "subframe %d: PUSCH subframe = %d\n", n, ul_subframe); return ul_subframe; } -#if 0 -uint8_t ul_subframe2pdcch_alloc_subframe(NR_DL_FRAME_PARMS *frame_parms,uint8_t n) -{ - if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 1) && - ((n==7)||(n==2))) // tdd_config 0,1 SF 1,5 - return((n==7)? 1 : 6); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - ((n==7)||(n==8)||(n==2)||(n==3))) - return((n+3)%10); - else if ((frame_parms->frame_type == TDD) && - (frame_parms->tdd_config == 6) && - (n==4)) // tdd_config 6 SF 9 - return(9); - else - return((n+6)%10); - -} -#endif //(0) uint32_t nr_pdcch_alloc2ul_frame(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n) { @@ -7825,2489 +1264,4 @@ uint32_t nr_pdcch_alloc2ul_frame(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame, return ul_frame; } -#if 0 -int32_t pmi_convert_rank1_from_rank2(uint16_t pmi_alloc, int tpmi, int nb_rb) -{ - int nb_subbands = 0; - int32_t pmi_alloc_new = 0, pmi_new = 0, pmi_old = 0; - int i; - - switch (nb_rb) { - case 6: - nb_subbands = 6; - break; - default: - case 25: - nb_subbands = 7; - break; - case 50: - nb_subbands = 9; - break; - case 100: - nb_subbands = 13; - break; - } - - for (i = 0; i < nb_subbands; i++) { - pmi_old = (pmi_alloc >> i)&1; - - if (pmi_old == 0) - if (tpmi == 5) - pmi_new = 0; - else - pmi_new = 1; - else - if (tpmi == 5) - pmi_new = 2; - else - pmi_new = 3; - - pmi_alloc_new|=pmi_new<<(2*i); - - } -#ifdef DEBUG_HARQ -printf(" [DCI UE] pmi_alloc_old %d, pmi_alloc_new %d pmi_old %d , pmi_new %d\n", pmi_alloc, pmi_alloc_new,pmi_old, pmi_new ); -#endif -return(pmi_alloc_new); - -} - -uint16_t quantize_subband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,int nb_rb) -{ - - int i, aarx; - uint16_t pmiq=0; - uint32_t pmivect = 0; - uint8_t rank = meas->rank[eNB_id]; - int pmi_re,pmi_im; - int nb_subbands=0; - - - switch (nb_rb) { - case 6: - nb_subbands = 6; - break; - default: - case 25: - nb_subbands = 7; - break; - case 50: - nb_subbands = 9; - break; - case 100: - nb_subbands = 13; - break; - } - - - for (i=0; inb_antennas_rx; aarx++) { - pmi_re += meas->subband_pmi_re[eNB_id][i][aarx]; - pmi_im += meas->subband_pmi_im[eNB_id][i][aarx]; - } - - // pmi_re = meas->subband_pmi_re[eNB_id][i][meas->selected_rx_antennas[eNB_id][i]]; - // pmi_im = meas->subband_pmi_im[eNB_id][i][meas->selected_rx_antennas[eNB_id][i]]; - - // printf("pmi => (%d,%d)\n",pmi_re,pmi_im); - if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_11; - else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_1j; - else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1m1; - else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1mj; - - // printf("subband %d, pmi%d \n",i,pmiq); - pmivect |= (pmiq<<(2*i)); - } - - else if (rank==1) { - for (aarx=0; aarxnb_antennas_rx; aarx++) { - pmi_re += meas->subband_pmi_re[eNB_id][i][aarx]; - //printf("meas->subband_pmi_re[eNB_id][i][%d]=%d\n", aarx, meas->subband_pmi_re[eNB_id][i][aarx]); - pmi_im += meas->subband_pmi_im[eNB_id][i][aarx]; - //printf("meas->subband_pmi_im[eNB_id][i][%d]=%d\n",aarx, meas->subband_pmi_im[eNB_id][i][aarx]); - } - if (pmi_re >= pmi_im) // this is not orthogonal - // this is orthogonal - //if (((pmi_re >= pmi_im) && (pmi_re >= -pmi_im)) || ((pmi_re <= pmi_im) && (pmi_re >= -pmi_im))) - pmiq = PMI_2A_R1_11; - else - pmiq = PMI_2A_R1_1j; - - // printf("subband %d, pmi_re %d, pmi_im %d, pmiq %d \n",i,pmi_re,pmi_im,pmiq); - // printf("subband %d, pmi%d \n",i,pmiq); - //According to Section 7.2.4 of 36.213 - - pmivect |= ((pmiq-1)<<(i)); //shift 1 since only one bit - } - else { - LOG_E(PHY,"PMI feedback for rank>1 not supported!\n"); - pmivect = 0; - } - - } -#ifdef DEBUG_HARQ - printf( "quantize_subband_pmi pmivect %d \n", pmivect); -#endif - return(pmivect); -} - -uint16_t quantize_subband_pmi2(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t a_id,int nb_subbands) -{ - - uint8_t i; - uint16_t pmiq=0; - uint16_t pmivect = 0; - uint8_t rank = meas->rank[eNB_id]; - int pmi_re,pmi_im; - - for (i=0; isubband_pmi_re[eNB_id][i][a_id]; - pmi_im = meas->subband_pmi_im[eNB_id][i][a_id]; - - if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_11; - else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_1j; - else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1m1; - else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1mj; - - pmivect |= (pmiq<<(2*i)); - } else { - // This needs to be done properly!!! - pmivect = 0; - } - } - - return(pmivect); -} - -uint16_t quantize_wideband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id) -{ - - uint16_t pmiq=0; - uint8_t rank = meas->rank[eNB_id]; - //int pmi; - int pmi_re,pmi_im; - - if (rank == 1) { - //pmi = - pmi_re = meas->wideband_pmi_re[eNB_id][meas->selected_rx_antennas[eNB_id][0]]; - pmi_im = meas->wideband_pmi_im[eNB_id][meas->selected_rx_antennas[eNB_id][0]]; - - if ((pmi_re > pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_11; - else if ((pmi_re < pmi_im) && (pmi_re > -pmi_im)) - pmiq = PMI_2A_1j; - else if ((pmi_re < pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1m1; - else if ((pmi_re > pmi_im) && (pmi_re < -pmi_im)) - pmiq = PMI_2A_1mj; - - } else { - // This needs to be done properly! - pmiq = PMI_2A_11; - } - - - return(pmiq); -} -/* - uint8_t sinr2cqi(int sinr) { - if (sinr<-3) - return(0); - if (sinr>14) - return(10); - else - return(3+(sinr>>1)); - } -*/ - -uint8_t sinr2cqi(double sinr,uint8_t trans_mode) -{ - // int flag_LA=0; - - uint8_t retValue = 0; - - if(flag_LA==0) { - // Ideal Channel Estimation - if (sinr<=-4.89) - retValue = (0); - else if (sinr < -3.53) - retValue = (3); - else if (sinr <= -1.93) - retValue = (4); - else if (sinr <= -0.43) - retValue = (5); - else if (sinr <= 1.11) - retValue = (6); - else if (sinr <= 3.26) - retValue = (7); - else if (sinr <= 5.0) - retValue = (8); - else if (sinr <= 7.0) - retValue = (9); - else if (sinr <= 9.0) - retValue = (10); - else if (sinr <= 11.0) - retValue = (11); - else if (sinr <= 13.0) - retValue = (12); - else if (sinr <= 15.5) - retValue = (13); - else if (sinr <= 17.5) - retValue = (14); - else - retValue = (15); - } else { - int h=0; - int trans_mode_tmp; - - if (trans_mode ==5) - trans_mode_tmp=2; - else if(trans_mode ==6) - trans_mode_tmp=3; - else - trans_mode_tmp = trans_mode-1; - - for(h=0; h<16; h++) { - if(sinr<=sinr_to_cqi[trans_mode_tmp][h]) - retValue = (h); - } - } - - LOG_D(PHY, "sinr=%f trans_mode=%d cqi=%d\n", sinr, trans_mode, retValue); - return retValue; -} -//uint32_t fill_subband_cqi(PHY_MEASUREMENTS *meas,uint8_t eNB_id) { -// -// uint8_t i; -//// uint16_t cqivect = 0; -// uint32_t cqivect = 0; -// -//// char diff_cqi; -// int diff_cqi=0; -// -// for (i=0;iwideband_cqi_dB[eNB_id][0]) + sinr2cqi(meas->subband_cqi_dB[eNB_id][0][i]); -// -// // Note, this is Table 7.2.1-2 from 36.213 -// if (diff_cqi<=-1) -// diff_cqi = 3; -// else if (diff_cqi>2) -// diff_cqi = 2; -// cqivect |= (diff_cqi<<(2*i)); -// -// } -// -// return(cqivect); -//} - - -uint32_t fill_subband_cqi(PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t trans_mode,int nb_subbands) -{ - - uint8_t i; - - uint32_t cqivect = 0,offset=0; - - - int diff_cqi=0; - - for (i=0; iwideband_cqi_avg[eNB_id],trans_mode) + sinr2cqi(meas->subband_cqi_tot_dB[eNB_id][i],trans_mode); - - // Note, this is Table 7.2.1-2 from 36.213 - if (diff_cqi<=-1) - offset = 3; - else if (diff_cqi>=2) - offset = 2; - else - offset=(uint32_t)diff_cqi; - - cqivect |= (offset<<(2*i)); - - } - - return(cqivect); -} - -void fill_CQI(NR_UE_ULSCH_t *ulsch,PHY_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t harq_pid,int N_RB_DL,uint16_t rnti, uint8_t trans_mode, double sinr_eff) -{ - - // printf("[PHY][UE] Filling CQI for eNB %d, meas->wideband_cqi_tot[%d] %d\n", - // eNB_id,eNB_id,meas->wideband_cqi_tot[eNB_id]); - double sinr_tmp; - uint8_t *o = ulsch->o; - UCI_format_t uci_format = ulsch->uci_format; - - if(flag_LA==1) - sinr_tmp = sinr_eff; - else - sinr_tmp = (double) meas->wideband_cqi_avg[eNB_id]; - - - - //LOG_I(PHY,"[UE][UCI] Filling CQI format %d for eNB %d N_RB_DL %d\n",uci_format,eNB_id,N_RB_DL); - - switch (N_RB_DL) { - - case 6: - switch (uci_format) { - case wideband_cqi_rank1_2A: - ((wideband_cqi_rank1_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((wideband_cqi_rank1_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); - break; - - case wideband_cqi_rank2_2A: - ((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_1_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); - break; - - case HLC_subband_cqi_nopmi: - ((HLC_subband_cqi_nopmi_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_nopmi_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); - break; - - case HLC_subband_cqi_rank1_2A: - ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); - ((HLC_subband_cqi_rank1_2A_1_5MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); - break; - - case HLC_subband_cqi_rank2_2A: - // This has to be improved!!! - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,6); - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,6); - ((HLC_subband_cqi_rank2_2A_1_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,6); - break; - - case HLC_subband_cqi_mcs_CBA: - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; - ((HLC_subband_cqi_mcs_CBA_1_5MHz *)o)->crnti = rnti; - LOG_D(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); - break; - - case ue_selected: - LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); - mac_xface->macphy_exit("fill_CQI ue_selected CQI not supported yet!!!"); - break; - - default: - LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); - mac_xface->macphy_exit("unsupported CQI mode !!!"); - break; - - } - - break; - - case 25: - switch (uci_format) { - case wideband_cqi_rank1_2A: - ((wideband_cqi_rank1_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((wideband_cqi_rank1_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); - break; - - case wideband_cqi_rank2_2A: - ((wideband_cqi_rank2_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); - break; - - case HLC_subband_cqi_nopmi: - ((HLC_subband_cqi_nopmi_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_nopmi_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); - break; - - case HLC_subband_cqi_rank1_2A: - ((HLC_subband_cqi_rank1_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank1_2A_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); - ((HLC_subband_cqi_rank1_2A_5MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); - break; - - case HLC_subband_cqi_rank2_2A: - // This has to be improved!!! - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,7); - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,7); - ((HLC_subband_cqi_rank2_2A_5MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,7); - break; - - case HLC_subband_cqi_mcs_CBA: - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; - ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti = rnti; - LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); - break; - - case ue_selected: - LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); - mac_xface->macphy_exit("fill_CQI ue_selected CQI not supported yet!!!"); - break; - - default: - LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); - mac_xface->macphy_exit("unsupported CQI mode !!!"); - break; - - } - - break; - - case 50: - switch (uci_format) { - case wideband_cqi_rank1_2A: - ((wideband_cqi_rank1_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((wideband_cqi_rank1_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); - break; - - case wideband_cqi_rank2_2A: - ((wideband_cqi_rank2_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_10MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); - break; - - case HLC_subband_cqi_nopmi: - ((HLC_subband_cqi_nopmi_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_nopmi_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); - break; - - case HLC_subband_cqi_rank1_2A: - ((HLC_subband_cqi_rank1_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank1_2A_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); - ((HLC_subband_cqi_rank1_2A_10MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); - break; - - case HLC_subband_cqi_rank2_2A: - // This has to be improved!!! - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,9); - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,9); - ((HLC_subband_cqi_rank2_2A_10MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,9); - break; - - case HLC_subband_cqi_mcs_CBA: - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; - ((HLC_subband_cqi_mcs_CBA_10MHz *)o)->crnti = rnti; - LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); - break; - - case ue_selected: - LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); - mac_xface->macphy_exit("fill_CQI ue_selected CQI not supported yet!!!"); - break; - - default: - LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); - mac_xface->macphy_exit("unsupported CQI mode !!!"); - break; - - } - - break; - - case 100: - switch (uci_format) { - case wideband_cqi_rank1_2A: - ((wideband_cqi_rank1_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((wideband_cqi_rank1_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); - break; - - case wideband_cqi_rank2_2A: - ((wideband_cqi_rank2_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_20MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); //FIXME: calculate rank2 cqi - ((wideband_cqi_rank2_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); - break; - - case HLC_subband_cqi_nopmi: - ((HLC_subband_cqi_nopmi_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_nopmi_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); - break; - - case HLC_subband_cqi_rank1_2A: - ((HLC_subband_cqi_rank1_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank1_2A_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); - ((HLC_subband_cqi_rank1_2A_20MHz *)o)->pmi = quantize_wideband_pmi(meas,eNB_id); - break; - - case HLC_subband_cqi_rank2_2A: - // This has to be improved!!! - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi1 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi1 = fill_subband_cqi(meas,eNB_id,trans_mode,13); - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->cqi2 = sinr2cqi(sinr_tmp,trans_mode); - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->diffcqi2 = fill_subband_cqi(meas,eNB_id,trans_mode,13); - ((HLC_subband_cqi_rank2_2A_20MHz *)o)->pmi = quantize_subband_pmi(meas,eNB_id,13); - break; - - case HLC_subband_cqi_mcs_CBA: - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->mcs = ulsch->harq_processes[harq_pid]->mcs; - ((HLC_subband_cqi_mcs_CBA_20MHz *)o)->crnti = rnti; - LOG_N(PHY,"fill uci for cba rnti %x, mcs %d \n", rnti, ulsch->harq_processes[harq_pid]->mcs); - break; - - case ue_selected: - LOG_E(PHY,"fill_CQI ue_selected CQI not supported yet!!!\n"); - mac_xface->macphy_exit("fill_CQI ue_selected CQI not supported yet!!!"); - break; - - default: - LOG_E(PHY,"unsupported CQI mode (%d)!!!\n",uci_format); - mac_xface->macphy_exit("unsupported CQI mode !!!"); - break; - - } - - break; - - } - - -} - -void reset_cba_uci(void *o) -{ - // this is the cba mcs uci for cba transmission - ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->mcs = 0; //fixme - ((HLC_subband_cqi_mcs_CBA_5MHz *)o)->crnti = 0x0; -} - - -uint32_t pmi_extend(NR_DL_FRAME_PARMS *frame_parms,uint8_t wideband_pmi, uint8_t rank) -{ - - uint8_t i,wideband_pmi2; - uint32_t pmi_ex = 0; - - if (frame_parms->N_RB_DL!=25) { - LOG_E(PHY,"pmi_extend not yet implemented for anything else than 25PRB\n"); - return(-1); - } - - if (rank==0) { - wideband_pmi2=wideband_pmi&3; - for (i=0; i<14; i+=2) - pmi_ex|=(wideband_pmi2<transmission_mode[eNB_id]; - ANFBmode_t AckNackFBMode; - NR_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; - NR_UE_DLSCH_t **dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][0]; - PHY_MEASUREMENTS *meas = &ue->measurements; - NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - // uint32_t current_dlsch_cqi = ue->current_dlsch_cqi[eNB_id]; - - if(frame_parms->frame_type == TDD) - { - AckNackFBMode = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; - } - else - { - AckNackFBMode = 1; // 1: multiplexing for FDD - } - - uint32_t cqi_req; - uint32_t dai=3; - uint32_t cshift; - uint32_t TPC; - uint32_t ndi; - uint32_t mcs; - uint32_t rballoc,RIV_max; - uint16_t* RIV2first_rb_LUT; - uint16_t* RIV2nb_rb_LUT; - - // uint32_t hopping; - // uint32_t type; - - if (dci_format == format0) { - - if (!ulsch) - return -1; - - if (rnti == ra_rnti) - harq_pid = 0; - else - harq_pid = nr_subframe2harq_pid(frame_parms, - nr_pdcch_alloc2ul_frame(frame_parms,proc->frame_rx,nr_tti_rx), - nr_pdcch_alloc2ul_subframe(frame_parms,nr_tti_rx)); - - if (harq_pid == 255) { - LOG_E(PHY, "frame %d, nr_tti_rx %d, rnti %x, format %d: illegal harq_pid!\n", - proc->frame_rx, nr_tti_rx, rnti, dci_format); - return(-1); - } - - switch (frame_parms->N_RB_DL) { - case 6: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - ndi = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->ndi; - mcs = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->ndi; - mcs = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max6; - RIV2first_rb_LUT = RIV2first_rb_LUT6; - RIV2nb_rb_LUT = RIV2nb_rb_LUT6; - - break; - - case 25: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - ndi = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->ndi; - mcs = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_5MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_5MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_5MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI0_5MHz_FDD_t *)dci_pdu)->ndi; - mcs = ((DCI0_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_5MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_5MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_5MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max25; - RIV2first_rb_LUT = RIV2first_rb_LUT25; - RIV2nb_rb_LUT = RIV2nb_rb_LUT25; - // printf("***********rballoc %d, first_rb %d, nb_rb %d (dci %p)\n",rballoc,ulsch->harq_processes[harq_pid]->first_rb,ulsch->harq_processes[harq_pid]->nb_rb,dci_pdu); - break; - - case 50: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->TPC; - ndi = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->ndi; - mcs = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_10MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_10MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_10MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI0_10MHz_FDD_t *)dci_pdu)->ndi; - mcs = ((DCI0_10MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_10MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_10MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_10MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max50; - RIV2first_rb_LUT = RIV2first_rb_LUT50; - RIV2nb_rb_LUT = RIV2nb_rb_LUT50; - - break; - - case 100: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->TPC; - ndi = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->ndi; - mcs = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_20MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_20MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_20MHz_FDD_t *)dci_pdu)->TPC; - ndi = ((DCI0_20MHz_FDD_t *)dci_pdu)->ndi; - mcs = ((DCI0_20MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_20MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_20MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_20MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max100; - RIV2first_rb_LUT = RIV2first_rb_LUT100; - RIV2nb_rb_LUT = RIV2nb_rb_LUT100; - - // printf("rb_alloc (20 MHz dci) %d\n",rballoc); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - - if (rballoc > RIV_max) { - LOG_E(PHY,"frame %d, nr_tti_rx %d, rnti %x, format %d: FATAL ERROR: generate_ue_ulsch_params_from_dci, rb_alloc[%d] > RIV_max[%d]\n", - proc->frame_rx, nr_tti_rx, rnti, dci_format,rballoc,RIV_max); - LOG_E(PHY,"Wrong DCI0 detection, do not transmit PUSCH for HARQID: %d\n",harq_pid); - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - return(-1); - } - - - // indicate that this process is to be serviced in subframe n+4 - if ((rnti >= cba_rnti) && (rnti < p_rnti)) - ulsch->harq_processes[harq_pid]->subframe_cba_scheduling_flag = 1; //+=1 this indicates the number of dci / cba group: not supported in the data struct - else - { - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; - //LOG_I(PHY,"[HARQ-UL harqId: %d] DCI0 ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); - - } - - ulsch->harq_processes[harq_pid]->TPC = TPC; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT[rballoc]; - - if (ue->ul_power_control_dedicated[eNB_id].accumulationEnabled == 1) { - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d nr_tti_rx %d: f_pusch (ACC) %d, adjusting by %d (TPC %d)\n", - ue->Mod_id,harq_pid,proc->frame_rx,nr_tti_rx,ulsch->f_pusch, - nr_delta_PUSCH_acc[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC], - ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC); - ulsch->f_pusch += nr_delta_PUSCH_acc[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC]; - } else { - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d nr_tti_rx %d: f_pusch (ABS) %d, adjusting to %d (TPC %d)\n", - ue->Mod_id,harq_pid,proc->frame_rx,nr_tti_rx,ulsch->f_pusch, - nr_delta_PUSCH_abs[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC], - ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC); - ulsch->f_pusch = nr_delta_PUSCH_abs[ue->ulsch[eNB_id]->harq_processes[harq_pid]->TPC]; - } - - if (ulsch->harq_processes[harq_pid]->first_tx==1) { - // ulsch->harq_processes[harq_pid]->Ndi = 1; - ulsch->harq_processes[harq_pid]->first_tx=0; - ulsch->harq_processes[harq_pid]->DCINdi= ndi; - ulsch->harq_processes[harq_pid]->round = 0; - } else { - if (ulsch->harq_processes[harq_pid]->DCINdi!=ndi) { // new SDU opportunity - // ulsch->harq_processes[harq_pid]->Ndi = 1; - ulsch->harq_processes[harq_pid]->DCINdi= ndi; - ulsch->harq_processes[harq_pid]->round = 0; - } else { - // ulsch->harq_processes[harq_pid]->Ndi = 0; - //ulsch->harq_processes[harq_pid]->round++; // This is done in phich RX - - //#ifdef DEBUG_PHICH - //LOG_I(PHY,"[UE %d][PUSCH %d] Frame %d subframe %d Adaptative Retrans, NDI not toggled => Nack. maxHARQ_Tx %d \n", - // ue->Mod_id,harq_pid, - // proc->frame_rx, - // subframe, - // ulsch->Mlimit); - //#endif -/* - if (ulsch->harq_processes[harq_pid]->round > 0) // NACK detected on phich - { - // ulsch->harq_processes[harq_pid]->round++; already done on phich_rx - // ulsch->harq_processes[harq_pid] = ulsch->harq_processes[8]; - // LOG_I(PHY," Adaptative retransmission - copy temporary harq Process to current harq process. [harqId %d round %d] \n",harq_pid, ulsch->harq_processes[8]->round); - - if (ulsch->harq_processes[harq_pid]->round >= ulsch->Mlimit) //UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx) - { - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - ulsch->harq_processes[harq_pid]->round = 0; - ulsch->harq_processes[harq_pid]->status = IDLE; - //LOG_I(PHY," PUSCH MAX Retransmission acheived ==> flush harq buff (%d) \n",harq_pid); - //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK MAX RETRANS(%d) ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, UE_mac_inst[eNB_id].scheduling_info.maxHARQ_Tx, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, ulsch->harq_processes[harq_pid]->round); - } - else - { - // ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; - uint8_t rv_table[4] = {0, 2, 3, 1}; - ulsch->harq_processes[harq_pid]->rvidx = rv_table[ulsch->harq_processes[harq_pid]->round&3]; - ulsch->O_RI = 0; - ulsch->O = 0; - ulsch->uci_format = HLC_subband_cqi_nopmi; - //LOG_I(PHY," [HARQ-UL harqId: %d] Adaptative retransmission NACK ==> subframe_scheduling_flag = %d round: %d\n", harq_pid, ulsch->harq_processes[harq_pid]->subframe_scheduling_flag,ulsch->harq_processes[harq_pid]->round); - } - } -*/ - } - } - - ulsch->harq_processes[harq_pid]->n_DMRS = cshift; - - //printf("nb_rb %d, first_rb %d (RIV %d)\n",ulsch->harq_processes[harq_pid]->nb_rb,ulsch->harq_processes[harq_pid]->first_rb,rballoc); - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - // ulsch->cba_rnti[0]=rnti; - } else { - ulsch->rnti = rnti; - } - - // printf("[PHY][UE] DCI format 0: harq_pid %d nb_rb %d, rballoc %d\n",harq_pid,ulsch->harq_processes[harq_pid]->nb_rb, - // ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc); - //Mapping of cyclic shift field in DCI format0 to n_DMRS2 (3GPP 36.211, Table 5.5.2.1.1-1) - if(cshift == 0) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 0; - else if(cshift == 1) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 6; - else if(cshift == 2) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 3; - else if(cshift == 3) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 4; - else if(cshift == 4) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 2; - else if(cshift == 5) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 8; - else if(cshift == 6) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 10; - else if(cshift == 7) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; - - - //reserved for cooperative communication - /* - if(ulsch->n_DMRS2 == 6) - ulsch->cooperation_flag = 2; - else - ulsch->cooperation_flag = 0; - */ - - if ((ulsch->harq_processes[harq_pid]->nb_rb>0) && (ulsch->harq_processes[harq_pid]->nb_rb < 25)) - ulsch->power_offset = ue_power_offsets[ulsch->harq_processes[harq_pid]->nb_rb-1]; - - // if (ulsch->harq_processes[harq_pid]->Ndi == 1) - // ulsch->harq_processes[harq_pid]->status = ACTIVE; - - - if (cqi_req == 1) { - - if( (AntennaInfoDedicated__transmissionMode_tm3 == transmission_mode) || (AntennaInfoDedicated__transmissionMode_tm4 == transmission_mode) ) - { - ulsch->O_RI = 1; - } - else - { - ulsch->O_RI = 0; - } - //ulsch->O_RI = 0; //we only support 2 antenna ports, so this is always 1 according to 3GPP 36.213 Table - - switch(transmission_mode) { - // The aperiodic CQI reporting mode is fixed for every transmission mode instead of being configured by higher layer signaling - case 1: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 1; - } - - break; - - case 2: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 1; - } - - break; - - case 3: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 1; - } - - break; - - case 4: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank1_2A; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank2_2A; - ulsch->o_RI[0] = 1; - } - - break; - - case 5: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank1_2A; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank2_2A; - ulsch->o_RI[0] = 1; - } - - break; - - case 6: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank1_2A; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_wideband_cqi_rank2_2A_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_wideband_cqi_rank2_2A_5MHz; - break; - - case 50: - ulsch->O = sizeof_wideband_cqi_rank2_2A_10MHz; - break; - - case 100: - ulsch->O = sizeof_wideband_cqi_rank2_2A_20MHz; - break; - } - - ulsch->uci_format = wideband_cqi_rank2_2A; - ulsch->o_RI[0] = 1; - } - - break; - - case 7: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_mcs_CBA; - ulsch->o_RI[0] = 0; - } else if(meas->rank[eNB_id] == 0) { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 0; - } else { - switch (ue->frame_parms.N_RB_DL) { - case 6: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->O = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->uci_format = HLC_subband_cqi_nopmi; - ulsch->o_RI[0] = 1; - } - - break; - - default: - LOG_E(PHY,"Incorrect Transmission Mode \n"); - break; - } - } else { - ulsch->O_RI = 0; - ulsch->O = 0; - ulsch->uci_format = HLC_subband_cqi_nopmi; - } - - print_CQI(ulsch->o,ulsch->uci_format,eNB_id,ue->frame_parms.N_RB_DL); - - ulsch->bundling = 1-AckNackFBMode; - - if (frame_parms->frame_type == FDD) { - //int dl_subframe = (subframe<4) ? (subframe+6) : (subframe-4); - int dl_tti = nr_tti_rx; - - if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->harq_ack[dl_tti].send_harq_status>0) { // we have downlink transmission - ulsch->harq_processes[harq_pid]->O_ACK = 1; - } else { - ulsch->harq_processes[harq_pid]->O_ACK = 0; - } - /*LOG_I(PHY,"DCI 0 Processing: dl_subframe %d send_harq_status Odd %d send_harq_status Even %d harq_pid %d O_ACK %d\n", dl_subframe, - ue->dlsch[0][eNB_id][0]->harq_ack[dl_subframe].send_harq_status, - ue->dlsch[1][eNB_id][0]->harq_ack[dl_subframe].send_harq_status, - harq_pid, - ulsch->harq_processes[harq_pid]->O_ACK);*/ - - } else { - if (ulsch->bundling) - ulsch->harq_processes[harq_pid]->O_ACK = (dai == 3)? 0 : 1; - else - ulsch->harq_processes[harq_pid]->O_ACK = (dai >= 2)? 2 : (dai+1)&3; //(dai+1)&3; - - // ulsch->harq_processes[harq_pid]->V_UL_DAI = dai+1; - } - - dlsch[0]->harq_ack[nr_tti_rx].vDAI_UL = dai+1; - - - /*LOG_I(PHY, "[PUSCH %d] Format0 DCI %s, CQI_req=%d, cshift=%d, TPC=%d, DAI=%d, vDAI_UL[sf#%d]=%d, NDI=%d, MCS=%d, RBalloc=%d, first_rb=%d, harq_pid=%d, nb_rb=%d, subframe_scheduling_flag=%d" - " ulsch->bundling %d, O_ACK %d \n", - harq_pid, - (frame_parms->frame_type == TDD? "TDD" : "FDD"), - cqi_req, cshift, TPC, dai, subframe, dlsch[0]->harq_ack[subframe].vDAI_UL, ndi, mcs, rballoc, - ulsch->harq_processes[harq_pid]->first_rb, harq_pid, ulsch->harq_processes[harq_pid]->nb_rb, - ulsch->harq_processes[harq_pid]->subframe_scheduling_flag, - ulsch->bundling, - ulsch->harq_processes[harq_pid]->O_ACK);*/ - - ulsch->beta_offset_cqi_times8 = beta_cqi[ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index];//18; - ulsch->beta_offset_ri_times8 = beta_ri[ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index];//10; - ulsch->beta_offset_harqack_times8 = beta_ack[ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index];//16; - - ulsch->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); - ulsch->srs_active = use_srs; - - if ((rnti >= cba_rnti) && (rnti < p_rnti)) - ulsch->harq_processes[harq_pid]->status = CBA_ACTIVE; - else - ulsch->harq_processes[harq_pid]->status = ACTIVE; - - ulsch->harq_processes[harq_pid]->rvidx = 0; - - // ulsch->harq_processes[harq_pid]->calibration_flag =0; - if (mcs < 29) { - ulsch->harq_processes[harq_pid]->mcs = mcs; - // ulsch->harq_processes[harq_pid]->round = 0; - } else { - ulsch->harq_processes[harq_pid]->rvidx = mcs - 28; - if (ulsch->harq_processes[harq_pid]->round == 0) { - LOG_W(PHY,"PUSCH::mcs = %d and DCI0::mcs(%d) > 28 and round == %d\n", ulsch->harq_processes[harq_pid]->mcs, mcs, ulsch->harq_processes[harq_pid]->round); - } else { - LOG_D(PHY,"PUSCH::mcs = %d and DCI0::mcs(%d) > 28 and round == %d\n", ulsch->harq_processes[harq_pid]->mcs, mcs, ulsch->harq_processes[harq_pid]->round); - } - //LOG_E(PHY,"Fatal: mcs(%d) > 28!!! and round == 0\n", mcs); - } - ulsch->harq_processes[harq_pid]->TBS = TBStableUL[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; - - /* - else if (ulsch->harq_processes[harq_pid]->mcs == 29) { - ulsch->harq_processes[harq_pid]->mcs = 4; - ulsch->harq_processes[harq_pid]->TBS = TBStable[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; - // ulsch->harq_processes[harq_pid]->calibration_flag =1; - // printf("Auto-Calibration (UE): mcs %d, TBS %d, nb_rb %d\n",ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->TBS,ulsch->harq_processes[harq_pid]->nb_rb); - }*/ - ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; - ulsch->harq_processes[harq_pid]->Nsymb_initial = ulsch->Nsymb_pusch; - - // a Ndi=1 automatically acknowledges previous PUSCH transmission - if (ue->ulsch_Msg3_active[eNB_id] == 1) - ue->ulsch_Msg3_active[eNB_id] = 0; - - LOG_D(PHY,"[UE %d][PUSCH %d] Frame %d, nr_tti_rx %d : Programming PUSCH with n_DMRS2 %d (cshift %d), nb_rb %d, first_rb %d, mcs %d, round %d, rv %d, ulsch_ue_Msg3_active %d\n", - ue->Mod_id,harq_pid, - proc->frame_rx,nr_tti_rx,ulsch->harq_processes[harq_pid]->n_DMRS2,cshift,ulsch->harq_processes[harq_pid]->nb_rb,ulsch->harq_processes[harq_pid]->first_rb, - ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->round,ulsch->harq_processes[harq_pid]->rvidx, ue->ulsch_Msg3_active[eNB_id]); - - // ulsch->n_DMRS2 = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - -//printf("Format 0 DCI : ulsch (ue): AbsSubframe %d.%d nrb %d harq_pid %d round %d mcs %d\n",proc->frame_rx%1024,nr_tti_rx,ulsch->harq_processes[harq_pid]->nb_rb, - // harq_pid,ulsch->harq_processes[harq_pid]->round,ulsch->harq_processes[harq_pid]->mcs); - -#ifdef UE_DEBUG_TRACE - - LOG_I(PHY,"Format 0 DCI : ulsch (ue): AbsSubframe %d.%d\n",proc->frame_rx%1024,nr_tti_rx); - LOG_D(PHY,"Format 0 DCI : ulsch (ue): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): first_rb %d\n",ulsch->harq_processes[harq_pid]->first_rb); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): rballoc %d\n",rballoc); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): harq_pid %d\n",harq_pid); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): first_tx %d\n",ulsch->harq_processes[harq_pid]->first_tx); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): DCINdi %d\n",ulsch->harq_processes[harq_pid]->DCINdi); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): round %d\n",ulsch->harq_processes[harq_pid]->round); - //LOG_I(PHY,"Format 0 DCI :ulsch (ue): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); - //LOG_I(PHY,"Format 0 DCI :ulsch (ue): O %d\n",ulsch->O); - //LOG_I(PHY,"Format 0 DCI :ulsch (ue): cqiReq %d\n",cqi_req); - //if (frame_parms->frame_type == TDD) - // LOG_I(PHY,"Format 0 DCI :ulsch (ue): O_ACK/DAI %d/%d\n",ulsch->harq_processes[harq_pid]->O_ACK,dai); - //else - // LOG_I(PHY,"Format 0 DCI :ulsch (ue): O_ACK %d\n",ulsch->harq_processes[harq_pid]->O_ACK); - - LOG_D(PHY,"Format 0 DCI :ulsch (ue): Nsymb_pusch %d\n",ulsch->Nsymb_pusch); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): cshift %d\n",ulsch->harq_processes[harq_pid]->n_DMRS2); - LOG_D(PHY,"Format 0 DCI :ulsch (ue): phich status %d\n",ulsch->harq_processes[harq_pid]->status); -#else - UNUSED_VARIABLE(dai); -#endif - return(0); - } else { - LOG_E(PHY,"frame %d, nr_tti_rx %d: FATAL ERROR, generate_ue_ulsch_params_from_dci, Illegal dci_format %d\n", - proc->frame_rx, nr_tti_rx,dci_format); - return(-1); - } - -} - -int generate_eNB_ulsch_params_from_dci(PHY_VARS_eNB *eNB, - eNB_rxtx_proc_t *proc, - void *dci_pdu, - uint16_t rnti, - DCI_format_t dci_format, - uint8_t UE_id, - uint16_t si_rnti, - uint16_t ra_rnti, - uint16_t p_rnti, - uint16_t cba_rnti, - uint8_t use_srs) -{ - - uint8_t harq_pid; - uint32_t rb_alloc; - uint8_t transmission_mode=eNB->transmission_mode[UE_id]; - ANFBmode_t AckNackFBMode = eNB->pucch_config_dedicated[UE_id].tdd_AckNackFeedbackMode; - LTE_eNB_ULSCH_t *ulsch=eNB->ulsch[UE_id]; - NR_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; - int subframe = proc->subframe_tx; - - uint32_t cqi_req = 0; - uint32_t dai = 0; - uint32_t cshift = 0; - uint32_t TPC = 0; - uint32_t mcs = 0; - uint32_t rballoc = UINT32_MAX; - uint32_t RIV_max = 0; - // uint32_t hopping; - // uint32_t type; - -#ifdef DEBUG_DCI - printf("filling eNB ulsch params for rnti %x, dci format %d, dci %x, subframe %d\n", - rnti,dci_format,*(uint32_t*)dci_pdu,subframe); -#endif - - if (dci_format == format0) { - - harq_pid = nr_subframe2harq_pid(frame_parms, - nr_pdcch_alloc2ul_frame(frame_parms, - proc->frame_tx, - subframe), - nr_pdcch_alloc2ul_subframe(frame_parms,subframe)); - switch (frame_parms->N_RB_DL) { - case 6: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - mcs = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_1_5MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->TPC; - mcs = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_1_5MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max6; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT6[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT6[rballoc]; - - break; - - case 25: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->TPC; - mcs = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_5MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_5MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_5MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_5MHz_FDD_t *)dci_pdu)->TPC; - mcs = ((DCI0_5MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_5MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_5MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_5MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max25; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT25[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT25[rballoc]; - - break; - - case 50: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->TPC; - mcs = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_10MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_10MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_10MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_10MHz_FDD_t *)dci_pdu)->TPC; - mcs = ((DCI0_10MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_10MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_10MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_10MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max50; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT50[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT50[rballoc]; - - break; - - case 100: - if (frame_parms->frame_type == TDD) { - cqi_req = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cqi_req; - dai = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->dai; - cshift = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->cshift; - TPC = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->TPC; - mcs = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->mcs; - rballoc = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->hopping; - // type = ((DCI0_20MHz_TDD_1_6_t *)dci_pdu)->type; - } else { - cqi_req = ((DCI0_20MHz_FDD_t *)dci_pdu)->cqi_req; - cshift = ((DCI0_20MHz_FDD_t *)dci_pdu)->cshift; - TPC = ((DCI0_20MHz_FDD_t *)dci_pdu)->TPC; - mcs = ((DCI0_20MHz_FDD_t *)dci_pdu)->mcs; - rballoc = ((DCI0_20MHz_FDD_t *)dci_pdu)->rballoc; - // hopping = ((DCI0_20MHz_FDD_t *)dci_pdu)->hopping; - // type = ((DCI0_20MHz_FDD_t *)dci_pdu)->type; - } - - RIV_max = RIV_max100; - ulsch->harq_processes[harq_pid]->first_rb = RIV2first_rb_LUT100[rballoc]; - ulsch->harq_processes[harq_pid]->nb_rb = RIV2nb_rb_LUT100[rballoc]; - - //printf("eNB: rb_alloc (20 MHz dci) %d\n",rballoc); - break; - - default: - LOG_E(PHY,"Invalid N_RB_DL %d\n", frame_parms->N_RB_DL); - DevParam (frame_parms->N_RB_DL, 0, 0); - break; - } - - rb_alloc = rballoc; - - if (rb_alloc>RIV_max) { - LOG_E(PHY,"Format 0: rb_alloc (%d) > RIV_max (%d)\n",rb_alloc,RIV_max); - mac_xface->macphy_exit("Format 0: error"); - return(-1); - } - -#ifdef DEBUG_DCI - printf("generate_eNB_ulsch_params_from_dci: subframe %d, rnti %x,harq_pid %d,cqi_req %d\n",subframe,rnti,harq_pid,cqi_req); -#endif - - ulsch->harq_processes[harq_pid]->dci_alloc = 1; - ulsch->harq_processes[harq_pid]->rar_alloc = 0; - ulsch->harq_processes[harq_pid]->TPC = TPC; - ulsch->harq_processes[harq_pid]->n_DMRS = cshift; - - - if (cqi_req == 1) { - /* 36.213 7.2.1 (release 10) says: - * "RI is only reported for transmission modes 3 and 4, - * as well as transmission modes 8 and 9 with PMI/RI reporting" - * This is for aperiodic reporting. - * TODO: deal with TM 8&9 correctly when they are implemented. - * TODO: deal with periodic reporting if we implement it. - */ - if (transmission_mode == 3 || transmission_mode == 4) - ulsch->harq_processes[harq_pid]->O_RI = 1; //we only support 2 antenna ports, so this is always 1 according to 3GPP 36.213 Table - else - ulsch->harq_processes[harq_pid]->O_RI = 0; - - switch(transmission_mode) { - // The aperiodic CQI reporting mode is fixed for every transmission mode instead of being configured by higher layer signaling - case 1: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - } - - break; - - case 2: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - } - - break; - - case 3: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - } - - break; - - case 4: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - - } - - ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; - } - - break; - - case 5: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; - } - - break; - - case 6: - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_mcs_CBA_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_mcs_CBA; - } else { - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_1_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_5MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_10MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or2 = sizeof_wideband_cqi_rank2_2A_20MHz; - ulsch->harq_processes[harq_pid]->Or1 = sizeof_wideband_cqi_rank1_2A_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = wideband_cqi_rank1_2A; - } - - break; - - case 7: - ulsch->harq_processes[harq_pid]->Or2 = 0; - - switch (frame_parms->N_RB_DL) { - case 6: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_1_5MHz; - break; - - case 25: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_5MHz; - break; - - case 50: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_10MHz; - break; - - case 100: - ulsch->harq_processes[harq_pid]->Or1 = sizeof_HLC_subband_cqi_nopmi_20MHz; - break; - } - - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - break; - - default: - LOG_E(PHY,"Incorrect Transmission Mode \n"); - break; - } - } else { - ulsch->harq_processes[harq_pid]->O_RI = 0; - ulsch->harq_processes[harq_pid]->Or2 = 0; - ulsch->harq_processes[harq_pid]->Or1 = 0; - ulsch->harq_processes[harq_pid]->uci_format = HLC_subband_cqi_nopmi; - } - - ulsch->bundling = 1-AckNackFBMode; - - if (frame_parms->frame_type == FDD) { - int dl_subframe = (subframe<4) ? (subframe+6) : (subframe-4); - - if (eNB->dlsch[UE_id][0]->subframe_tx[dl_subframe]>0) { // we have downlink transmission - ulsch->harq_processes[harq_pid]->O_ACK = 1; - } else { - ulsch->harq_processes[harq_pid]->O_ACK = 0; - } - } else { - if (ulsch->bundling) - ulsch->harq_processes[harq_pid]->O_ACK = (dai == 3)? 0 : 1; - else - ulsch->harq_processes[harq_pid]->O_ACK = (dai+1)&3; - - ulsch->harq_processes[harq_pid]->V_UL_DAI = dai+1; - } - - ulsch->beta_offset_cqi_times8 = beta_cqi[eNB->pusch_config_dedicated[UE_id].betaOffset_CQI_Index];//18; - ulsch->beta_offset_ri_times8 = beta_ri[eNB->pusch_config_dedicated[UE_id].betaOffset_RI_Index];//10; - ulsch->beta_offset_harqack_times8 = beta_ack[eNB->pusch_config_dedicated[UE_id].betaOffset_ACK_Index];//16; - - ulsch->harq_processes[harq_pid]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)-(use_srs==0?0:1); - ulsch->harq_processes[harq_pid]->srs_active = use_srs; - - //Mapping of cyclic shift field in DCI format0 to n_DMRS2 (3GPP 36.211, Table 5.5.2.1.1-1) - if(cshift == 0) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 0; - else if(cshift == 1) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 6; - else if(cshift == 2) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 3; - else if(cshift == 3) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 4; - else if(cshift == 4) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 2; - else if(cshift == 5) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 8; - else if(cshift == 6) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 10; - else if(cshift == 7) - ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; - - - LOG_D(PHY,"[eNB %d][PUSCH %d] Frame %d, subframe %d : Programming PUSCH with n_DMRS2 %d (cshift %d)\n", - eNB->Mod_id,harq_pid,proc->frame_tx,subframe,ulsch->harq_processes[harq_pid]->n_DMRS2,cshift); - - - - if (ulsch->harq_processes[harq_pid]->round == 0) { - if ((rnti >= cba_rnti) && (rnti < p_rnti)) - ulsch->harq_processes[harq_pid]->status = CBA_ACTIVE; - else - ulsch->harq_processes[harq_pid]->status = ACTIVE; - - ulsch->harq_processes[harq_pid]->rvidx = 0; - ulsch->harq_processes[harq_pid]->mcs = mcs; - // ulsch->harq_processes[harq_pid]->calibration_flag = 0; - //if (ulsch->harq_processes[harq_pid]->mcs) - /* - if (ulsch->harq_processes[harq_pid]->mcs == 29) { - ulsch->harq_processes[harq_pid]->mcs = 4; - // ulsch->harq_processes[harq_pid]->calibration_flag = 1; - // printf("Auto-Calibration (eNB): mcs %d, nb_rb %d\n",ulsch->harq_processes[harq_pid]->mcs,ulsch->harq_processes[harq_pid]->nb_rb); - } - */ - ulsch->harq_processes[harq_pid]->TBS = TBStableUL[get_I_TBS_UL(ulsch->harq_processes[harq_pid]->mcs)][ulsch->harq_processes[harq_pid]->nb_rb-1]; - - ulsch->harq_processes[harq_pid]->Msc_initial = 12*ulsch->harq_processes[harq_pid]->nb_rb; - ulsch->harq_processes[harq_pid]->Nsymb_initial = ulsch->harq_processes[harq_pid]->Nsymb_pusch; - ulsch->harq_processes[harq_pid]->round = 0; - } else { - if (mcs>28) - ulsch->harq_processes[harq_pid]->rvidx = mcs - 28; - else { - ulsch->harq_processes[harq_pid]->rvidx = 0; - ulsch->harq_processes[harq_pid]->mcs = mcs; - } - - // ulsch->harq_processes[harq_pid]->round++; - } - - if ((rnti >= cba_rnti) && (rnti < p_rnti)) { - ulsch->cba_rnti[0] = rnti; - } else { - ulsch->rnti = rnti; - } - - //ulsch->n_DMRS2 = cshift; - -#ifdef DEBUG_DCI - printf("ulsch (eNB): NBRB %d\n",ulsch->harq_processes[harq_pid]->nb_rb); - printf("ulsch (eNB): first_rb %d\n",ulsch->harq_processes[harq_pid]->first_rb); - printf("ulsch (eNB): harq_pid %d\n",harq_pid); - printf("ulsch (eNB): round %d\n",ulsch->harq_processes[harq_pid]->round); - printf("ulsch (eNB): TBS %d\n",ulsch->harq_processes[harq_pid]->TBS); - printf("ulsch (eNB): mcs %d\n",ulsch->harq_processes[harq_pid]->mcs); - printf("ulsch (eNB): Or1 %d\n",ulsch->harq_processes[harq_pid]->Or1); - printf("ulsch (eNB): Nsymb_pusch %d\n",ulsch->harq_processes[harq_pid]->Nsymb_pusch); - printf("ulsch (eNB): cshift %d\n",ulsch->harq_processes[harq_pid]->n_DMRS2); -#else - UNUSED_VARIABLE(dai); -#endif - return(0); - } else { - LOG_E(PHY,"generate_eNB_ulsch_params_from_dci, Illegal dci_format %d\n",dci_format); - return(-1); - } - -} - - -double sinr_eff_cqi_calc(PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t nr_tti_rx) -{ - uint8_t transmission_mode = ue->transmission_mode[eNB_id]; - PHY_MEASUREMENTS *meas = &ue->measurements; - NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - int32_t **dl_channel_est = ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[eNB_id]; - double *s_dB; - s_dB = ue->sinr_CQI_dB; - // NR_UE_ULSCH_t *ulsch = ue->ulsch[eNB_id]; - //for the calculation of SINR_eff for CQI calculation - int count,a_rx,a_tx; - double abs_channel=0; - double channelx=0; - double channely=0; - double channelx_i=0; - double channely_i=0; - uint16_t q = quantize_subband_pmi(meas,eNB_id,7); - uint8_t qq; - - switch(transmission_mode) { - case 1: - for (count=0; countN_RB_DL*12; count++) { - for(a_tx=0; a_txnb_antenna_ports_eNB; a_tx++) { - for (a_rx=0; a_rxnb_antennas_rx; a_rx++) { - s_dB[count] = 10*log10(pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2],2) + pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2], - 2)) - meas->n0_power_avg_dB; - } - } - } - - break; - - case 2: - for (count=0; countN_RB_DL*12; count++) { - abs_channel=0; - - for(a_tx=0; a_txnb_antenna_ports_eNB; a_tx++) { - for (a_rx=0; a_rxnb_antennas_rx; a_rx++) { - abs_channel += (pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2],2) + pow(((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2],2)); - } - } - - s_dB[count] = 10*log10(abs_channel/2) - meas->n0_power_avg_dB; - } - - break; - - case 5: - for (count=0; countN_RB_DL*12; count++) { - channelx=0; - channely=0; - channelx_i=0; - channely_i=0; - qq = (q>>(((count/12)>>2)<<1))&3; - - //printf("pmi_alloc %d: rb %d, pmi %d\n",q,count/12,qq); - for(a_tx=0; a_txnb_antenna_ports_eNB; a_tx++) { - for (a_rx=0; a_rxnb_antennas_rx; a_rx++) { - switch(qq) { - case 0: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 1: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 2: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 3: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely_i = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channelx_i -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely_i += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - default: - printf("Problem in SINR Calculation for TM5 \n"); - break; - }//switch(qq) - }//a_rx - }//a_tx - - s_dB[count] = 10 * log10 ((pow(channelx,2) + pow(channely,2))/2) - 10 * log10 ((pow(channelx_i,2) + pow(channely_i,2))/2) - meas->n0_power_avg_dB; - }//count - - break; - - case 6: - for (count=0; countN_RB_DL*12; count++) { - channelx=0; - channely=0; - qq = (q>>(((count/12)>>2)<<1))&3; - - //printf("pmi_alloc %d: rb %d, pmi %d\n",q,count/12,qq); - for(a_tx=0; a_txnb_antenna_ports_eNB; a_tx++) { - for (a_rx=0; a_rxnb_antennas_rx; a_rx++) { - switch(qq) { - case 0: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 1: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 2: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - case 3: - if (channelx==0 || channely==0) { - channelx = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - channely = ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - } else { - channelx += ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+1+(LTE_CE_FILTER_LENGTH)*2]; - channely -= ((int16_t *) dl_channel_est[(a_tx<<1)+a_rx])[2*count+(LTE_CE_FILTER_LENGTH)*2]; - } - - break; - - default: - printf("Problem in SINR Calculation for TM6 \n"); - break; - }//switch(qq) - }//a_rx - }//a_tx - - s_dB[count] = 10 * log10 ((pow(channelx,2) + pow(channely,2))/2) - meas->n0_power_avg_dB; - }//count - - break; - - default: - printf("Problem in SINR Calculation for CQI \n"); - break; - } - - int ii; - double sinr_eff = 0; - double sinr_eff_qpsk=0; - double sinr_eff_qam16=0; - double sinr_eff_qam64=0; - double x = 0; - double I_qpsk=0; - double I_qam16=0; - double I_qam64=0; - double I_qpsk_avg=0; - double I_qam16_avg=0; - double I_qam64_avg=0; - double qpsk_max=12.2; - double qam16_max=19.2; - double qam64_max=25.2; - double sinr_min = -20; - int offset=0; - - - for (offset = 0; offset <= 24; offset++) { - for(ii=0; ii<12; ii++) { - //x is the sinr_dB in dB - x = s_dB[(offset*12)+ii]; - - if(xqpsk_max) - I_qpsk += 1; - else - I_qpsk += (q_qpsk[0]*pow(x,7) + q_qpsk[1]*pow(x,6) + q_qpsk[2]*pow(x,5) + q_qpsk[3]*pow(x,4) + q_qpsk[4]*pow(x,3) + q_qpsk[5]*pow(x,2) + q_qpsk[6]*x + q_qpsk[7]); - - if(x>qam16_max) - I_qam16 += 1; - else - I_qam16 += (q_qam16[0]*pow(x,7) + q_qam16[1]*pow(x,6) + q_qam16[2]*pow(x,5) + q_qam16[3]*pow(x,4) + q_qam16[4]*pow(x,3) + q_qam16[5]*pow(x,2) + q_qam16[6]*x + q_qam16[7]); - - if(x>qam64_max) - I_qam64 += 1; - else - I_qam64 += (q_qam64[0]*pow(x,7) + q_qam64[1]*pow(x,6) + q_qam64[2]*pow(x,5) + q_qam64[3]*pow(x,4) + q_qam64[4]*pow(x,3) + q_qam64[5]*pow(x,2) + q_qam64[6]*x + q_qam64[7]); - - } - } - } - - // averaging of accumulated MI - I_qpsk_avg = I_qpsk/(12*frame_parms->N_RB_DL); - I_qam16_avg = I_qam16/(12*frame_parms->N_RB_DL); - I_qam64_avg = I_qam64/(12*frame_parms->N_RB_DL); - - // I->SINR_effective Mapping - - sinr_eff_qpsk = (p_qpsk[0]*pow(I_qpsk_avg,7) + p_qpsk[1]*pow(I_qpsk_avg,6) + p_qpsk[2]*pow(I_qpsk_avg,5) + p_qpsk[3]*pow(I_qpsk_avg,4) + p_qpsk[4]*pow(I_qpsk_avg,3) + p_qpsk[5]*pow(I_qpsk_avg, - 2) + p_qpsk[6]*I_qpsk_avg + p_qpsk[7]); - - sinr_eff_qam16 = (p_qam16[0]*pow(I_qam16_avg,7) + p_qam16[1]*pow(I_qam16_avg,6) + p_qam16[2]*pow(I_qam16_avg,5) + p_qam16[3]*pow(I_qam16_avg,4) + p_qam16[4]*pow(I_qam16_avg, - 3) + p_qam16[5]*pow(I_qam16_avg,2) + p_qam16[6]*I_qam16_avg + p_qam16[7]); - - sinr_eff_qam64 = (p_qam64[0]*pow(I_qam64_avg,7) + p_qam64[1]*pow(I_qam64_avg,6) + p_qam64[2]*pow(I_qam64_avg,5) + p_qam64[3]*pow(I_qam64_avg,4) + p_qam64[4]*pow(I_qam64_avg, - 3) + p_qam64[5]*pow(I_qam64_avg,2) + p_qam64[6]*I_qam64_avg + p_qam64[7]); - sinr_eff = cmax3(sinr_eff_qpsk,sinr_eff_qam16,sinr_eff_qam64); - - //printf("SINR_Eff = %e\n",sinr_eff); - - return(sinr_eff); -} -// - - -#ifdef DEBUG_DLSCH_TOOLS -main() -{ - - int i; - uint8_t rah; - uint32_t rballoc; - - generate_RIV_tables(); - - rah = 0; - rballoc = 0x1fff; - printf("rballoc 0 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - rah = 1; - - rballoc = 0x1678; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - - rballoc = 0xfffc; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - rballoc = 0xfffd; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - rballoc = 0xffff; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); - rballoc = 0xfffe; - printf("rballoc 1 %x => %x\n",rballoc,conv_rballoc(rah,rballoc)); -} - -#endif -#endif //(0) From ee6239a8384edd95bb94fe9ba1b4fc833a8c242a Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Thu, 11 Oct 2018 07:45:54 -0700 Subject: [PATCH 111/114] fixing merge --- .../open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h | 3 ++- openair1/PHY/CODING/TESTBENCH/polartest.c | 4 ++-- openair1/PHY/INIT/nr_init_ue.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/dci_nr.c | 4 +++- openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c | 1 - openair1/SCHED_NR/fapi_nr_l1.c | 10 +++++----- openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 2 +- openair1/SCHED_NR_UE/harq_nr.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 4 ++-- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c | 8 ++++---- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 2 +- targets/RT/USER/nr-ue.c | 2 +- targets/RT/USER/nr-uesoftmodem.c | 9 +++------ 13 files changed, 26 insertions(+), 27 deletions(-) diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h index 4ab81c1a0c..babcc6404f 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h @@ -40,6 +40,7 @@ #define FAPI_NR_DL_CONFIG_TYPE_DCI 0x01 #define FAPI_NR_DL_CONFIG_TYPE_DLSCH 0x02 + #define CCE_REG_MAPPING_TYPE_INTERLEAVED 0x01 #define CCE_REG_MAPPING_TYPE_NON_INTERLEAVED 0x02 @@ -55,4 +56,4 @@ #define FAPI_NR_UL_CONFIG_TYPE_SRS 0x04 -#endif \ No newline at end of file +#endif diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 56e1add850..20db3624cf 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -10,7 +10,7 @@ #include "PHY/CODING/coding_defs.h" #include "SIMULATION/TOOLS/sim.h" -#define DEBUG_DCI_POLAR_PARAMS +//#define DEBUG_DCI_POLAR_PARAMS //#define DEBUG_POLAR_TIMING //#define DEBUG_CRC @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) { break; case 'h': - printf("./polartest -s SNRstart -d SNRinc -f SNRstop -m [0=DCI|1=PBCH|2=UCI] -i iterations -l decoderListSize -a pathMetricAppr\n"); + printf("./polartest -s SNRstart -d SNRinc -f SNRstop -m [0=PBCH|1=DCI|2=UCI] -i iterations -l decoderListSize -a pathMetricAppr\n"); exit(-1); default: diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 4574036ff3..c1d6399e46 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -357,7 +357,7 @@ void phy_config_dedicated_scell_ue(uint8_t Mod_id, } #endif -void phy_config_harq_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id, +void phy_config_harq_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, uint16_t max_harq_tx ) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 497a44b201..cb30ae7c21 100755 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -1816,9 +1816,11 @@ T(T_UE_PHY_PDCCH_ENERGY, T_INT(eNB_id), T_INT(0), T_INT(frame%1024), T_INT(nr_tt } #endif //MU_RECEIVER #if T_TRACER -T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL), +/* + T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL), T_INT(n_pdcch_symbols), T_BUFFER(pdcch_vars[eNB_id]->rxdataF_comp, frame_parms->N_RB_DL*12*n_pdcch_symbols* 4)); +*/ #endif #ifdef DEBUG_DCI_DECODING printf("demapping: nr_tti_rx %d, mi %d, tdd_config %d\n",nr_tti_rx,get_mi(frame_parms,nr_tti_rx),frame_parms->tdd_config); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index d98d866271..24641a6e6a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -33,7 +33,6 @@ #include "PHY/CODING/coding_extern.h" #include "PHY/phy_extern_nr_ue.h" #include "PHY/sse_intrin.h" -#include "SIMULATION/TOOLS/sim.h" #include "PHY/LTE_REFSIG/lte_refsig.h" //#define DEBUG_PBCH 1 diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index b6e1a95a82..e6fda71d39 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -42,8 +42,8 @@ void handle_nr_nfapi_bch_pdu(PHY_VARS_gNB *gNB, uint8_t *sdu) { - AssertFatal(dl_config_pdu->bch_pdu.bch_pdu_rel15.length == 3, "BCH PDU has length %d != 3\n", - dl_config_pdu->bch_pdu.bch_pdu_rel15.length); + AssertFatal(dl_config_pdu->bch_pdu_rel15.length == 3, "BCH PDU has length %d != 3\n", + dl_config_pdu->bch_pdu_rel15.length); LOG_I(PHY,"pbch_pdu[0]: %x,pbch_pdu[1]: %x,gNB->pbch_pdu[2]: %x\n",sdu[0],sdu[1],sdu[2]); gNB->pbch_pdu[0] = sdu[2]; @@ -108,9 +108,9 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ //LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_config_pdu->pdu_type); switch (dl_config_pdu->pdu_type) { case NFAPI_NR_DL_CONFIG_BCH_PDU_TYPE: - AssertFatal(dl_config_pdu->bch_pdu.bch_pdu_rel15.pdu_index < TX_req->tx_request_body.number_of_pdus, + AssertFatal(dl_config_pdu->bch_pdu_rel15.pdu_index < TX_req->tx_request_body.number_of_pdus, "bch_pdu_rel8.pdu_index>=TX_req->number_of_pdus (%d>%d)\n", - dl_config_pdu->bch_pdu.bch_pdu_rel15.pdu_index, + dl_config_pdu->bch_pdu_rel15.pdu_index, TX_req->tx_request_body.number_of_pdus); gNB->pbch_configured=1; do_oai=1; @@ -118,7 +118,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ handle_nr_nfapi_bch_pdu(gNB, proc, dl_config_pdu, - TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->bch_pdu.bch_pdu_rel15.pdu_index].segments[0].segment_data); + TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->bch_pdu_rel15.pdu_index].segments[0].segment_data); break; case NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE: diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index ac255e85e4..fd19e71b1b 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -130,7 +130,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ if(scheduled_response->ul_config != NULL){ fapi_nr_ul_config_request_t *ul_config = scheduled_response->ul_config; for(i=0; inumber_pdus; ++i){ - if(ul_config->ul_config_list[i].pdu_type == FAPI_NR_DL_CONFIG_TYPE_PUSCH){ + if(ul_config->ul_config_list[i].pdu_type == FAPI_NR_UL_CONFIG_TYPE_PUSCH){ // pusch config pdu fapi_nr_ul_config_pusch_pdu_rel15_t *pusch_config_pdu = &ul_config->ul_config_list[i].ulsch_config_pdu.ulsch_pdu_rel15; uint8_t current_harq_pid = pusch_config_pdu->harq_process_nbr; diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index 95a0d1c78e..796b87cc59 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -120,7 +120,7 @@ void get_dci_info_for_harq(PHY_VARS_NR_UE *ue, NR_DCI_INFO_EXTRACTED_t *nr_dci_i dlsch[0]->current_harq_pid = nr_dci_info_extracted->harq_process_number; - NR_DL_UE_HARQ_t *dl_harq = dlsch[0]->harq_processes[dlsch[0]->current_harq_pid]; + NR_DL_UE_HARQ_t *dl_harq = &dlsch[0]->harq_processes[dlsch[0]->current_harq_pid]; dl_harq->harq_ack.vDAI_DL = nr_dci_info_extracted->dai+1; dl_harq->harq_ack.pucch_resource_indicator = nr_dci_info_extracted->pucch_resource_ind; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index d9a095f5c2..7e5e00c066 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -1140,7 +1140,7 @@ printf("\n>>> nr_ue_process_dci at MAC layer with dci_format=%d\n",dci_format); * 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space * 50 SUL_IND_0_0: */ - ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_PUSCH; + ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti; fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu_0_0 = &ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15; /* IDENTIFIER_DCI_FORMATS */ @@ -1212,7 +1212,7 @@ printf("\n>>> nr_ue_process_dci at MAC layer with dci_format=%d\n",dci_format); * 48 UL_SCH_IND * 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space */ - ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_PUSCH; + ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH; ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti; fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu_0_1 = &ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15; /* IDENTIFIER_DCI_FORMATS */ diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index 85530e9841..95f685a536 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -97,10 +97,10 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t subfram memset((void *) dl_config_pdu, 0,sizeof(nfapi_nr_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_NR_DL_CONFIG_BCH_PDU_TYPE; dl_config_pdu->pdu_size =2 + sizeof(nfapi_nr_dl_config_bch_pdu_rel15_t); - dl_config_pdu->bch_pdu.bch_pdu_rel15.tl.tag = NFAPI_NR_DL_CONFIG_REQUEST_BCH_PDU_REL15_TAG; - dl_config_pdu->bch_pdu.bch_pdu_rel15.length = mib_sdu_length; - dl_config_pdu->bch_pdu.bch_pdu_rel15.pdu_index = gNB->pdu_index[CC_id]; - dl_config_pdu->bch_pdu.bch_pdu_rel15.transmission_power = 6000; + dl_config_pdu->bch_pdu_rel15.tl.tag = NFAPI_NR_DL_CONFIG_REQUEST_BCH_PDU_REL15_TAG; + dl_config_pdu->bch_pdu_rel15.length = mib_sdu_length; + dl_config_pdu->bch_pdu_rel15.pdu_index = gNB->pdu_index[CC_id]; + dl_config_pdu->bch_pdu_rel15.transmission_power = 6000; dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; dl_req->number_pdu++; dl_config_request->header.message_id = NFAPI_DL_CONFIG_REQUEST; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 2a59863977..5f88a20b8b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -67,7 +67,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, nr_configure_css_dci_from_mib(&gNB->pdcch_type0_params, kHz30, kHz30, nr_FR1, 0, 0, fp->slots_per_frame, - cfg->rf_config.dl_channel_bandwidth.value); + cfg->rf_config.dl_carrier_bandwidth.value); memcpy((void*)params_rel15, (void*)&gNB->pdcch_type0_params, sizeof(nfapi_nr_dl_config_pdcch_parameters_rel15_t)); pdu_rel15->frequency_domain_assignment = 5; diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 956650e308..f694de4b16 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -1002,7 +1002,7 @@ void *UE_thread(void *arg) { if ( first_symbols > 0 ) AssertFatal(first_symbols == UE->rfdevice.trx_read_func(&UE->rfdevice, - ×tamp1, + ×tamp, (void**)UE->common_vars.rxdata, first_symbols, UE->frame_parms.nb_antennas_rx),""); diff --git a/targets/RT/USER/nr-uesoftmodem.c b/targets/RT/USER/nr-uesoftmodem.c index 641cf6bc2e..baa996980c 100644 --- a/targets/RT/USER/nr-uesoftmodem.c +++ b/targets/RT/USER/nr-uesoftmodem.c @@ -215,7 +215,6 @@ int16_t rrc_log_level = LOG_INFO; int16_t rrc_log_verbosity = LOG_MED; int16_t opt_log_level = LOG_INFO; int16_t opt_log_verbosity = LOG_MED; -*/ # if defined(ENABLE_USE_MME) int16_t gtpu_log_level = LOG_DEBUG; @@ -525,11 +524,9 @@ static void get_options(void) { set_glog_onlinelog(online_log_messages); } if(config_isparamset(cmdline_logparams,CMDLINE_GLOGLEVEL_IDX)) { - set_glog(glog_level, -1); - } - if(config_isparamset(cmdline_logparams,CMDLINE_GLOGVERBO_IDX)) { - set_glog(-1, glog_verbosity); + set_glog(glog_level); } + if (start_telnetsrv) { load_module_shlib("telnetsrv",NULL,0); } @@ -877,7 +874,7 @@ int main( int argc, char **argv ) { #endif // get options and fill parameters from configuration file - get_options (argc, argv); //Command-line options, enb_properties + get_options (); //Command-line options, enb_properties if (opt_type != OPT_NONE) { radio_type_t radio_type; From 6a2dc297c7ba402101f98823c8a7bab15f797741 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 12 Oct 2018 07:21:05 +0200 Subject: [PATCH 112/114] compilation of nr-uesoftmodem fixed (polar_decoder parameter list) --- openair1/PHY/CODING/TESTBENCH/polartest.c | 18 +--- .../CODING/nrPolar_tools/nr_polar_decoder.c | 93 ++++--------------- .../PHY/CODING/nrPolar_tools/nr_polar_defs.h | 23 +---- 3 files changed, 24 insertions(+), 110 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index e23c69215a..f5390aeb70 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -191,15 +191,9 @@ int main(int argc, char *argv[]) { start_meas(&timeDecoder); if (decoder_int8==0) decoderState = polar_decoder(channelOutput, estimatedOutput, &nrPolar_params, - decoderListSize, aPrioriArray, pathMetricAppr, - &polar_decoder_init,&polar_rate_matching,&decoding, - &bit_extraction,&deinterleaving,&sorting,&path_metric,&update_LLR); + decoderListSize, aPrioriArray, pathMetricAppr); else - decoderState = polar_decoder_int8_new(channelOutput_int8, estimatedOutput, &nrPolar_params, - decoderListSize, &polar_decoder_init,&polar_rate_matching, - &decoding,&bit_extraction,&deinterleaving, - &sorting,&path_metric,&update_LLR, - generate_optim_code); + decoderState = polar_decoder_int8_new(channelOutput_int8, estimatedOutput, &nrPolar_params); stop_meas(&timeDecoder); //calculate errors @@ -237,15 +231,7 @@ int main(int argc, char *argv[]) { decoderListSize, pathMetricAppr, SNR, ((double)blockErrorCumulative/iterations), ((double)bitErrorCumulative / (iterations*testLength)), (timeEncoderCumulative/iterations),timeDecoderCumulative/iterations); - printf("decoding init %9.3fus\n",polar_decoder_init.diff/(cpu_freq_GHz*1000.0*polar_decoder_init.trials)); - printf("decoding polar_rate_matching %9.3fus\n",polar_rate_matching.diff/(cpu_freq_GHz*1000.0*polar_rate_matching.trials)); - printf("decoding decoding %9.3fus\n",decoding.diff/(cpu_freq_GHz*1000.0*decoding.trials)); - printf("decoding bit_extraction %9.3fus\n",bit_extraction.diff/(cpu_freq_GHz*1000.0*bit_extraction.trials)); - printf("decoding deinterleaving %9.3fus\n",deinterleaving.diff/(cpu_freq_GHz*1000.0*deinterleaving.trials)); - printf("decoding path_metric %9.3fus\n",path_metric.diff/(cpu_freq_GHz*1000.0*decoding.trials)); - printf("decoding sorting %9.3fus\n",sorting.diff/(cpu_freq_GHz*1000.0*decoding.trials)); - printf("decoding updateLLR %9.3fus\n",update_LLR.diff/(cpu_freq_GHz*1000.0*decoding.trials)); blockErrorCumulative = 0; bitErrorCumulative = 0; timeEncoderCumulative = 0; timeDecoderCumulative = 0; } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 67fe489424..349d367ce5 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -27,7 +27,6 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" -#include "PHY/TOOLS/time_meas.h" int8_t polar_decoder( @@ -36,19 +35,7 @@ int8_t polar_decoder( t_nrPolar_params *polarParams, uint8_t listSize, double *aPrioriPayload, - uint8_t pathMetricAppr, - time_stats_t *init, - time_stats_t *polar_rate_matching, - time_stats_t *decoding, - time_stats_t *bit_extraction, - time_stats_t *deinterleaving, - time_stats_t *sorting, - time_stats_t *path_metric, - time_stats_t *update_LLR) -{ - - start_meas(init); - + uint8_t pathMetricAppr) { uint8_t **extended_crc_generator_matrix = malloc(polarParams->K * sizeof(uint8_t *)); //G_P3 uint8_t **tempECGM = malloc(polarParams->K * sizeof(uint8_t *)); //G_P2 for (int i = 0; i < polarParams->K; i++){ @@ -102,18 +89,14 @@ int8_t polar_decoder( } - stop_meas(init); - start_meas(polar_rate_matching); double d_tilde[polarParams->N];// = malloc(sizeof(double) * polarParams->N); nr_polar_rate_matching(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); memcpy((void*)&dlist[0].llr[polarParams->n][0],(void*)&d_tilde[0],sizeof(double)*polarParams->N); - stop_meas(polar_rate_matching); /* * SCL polar decoder. */ - start_meas(decoding); uint32_t nonFrozenBit=0; uint8_t currentListSize=1; @@ -128,9 +111,7 @@ int8_t polar_decoder( // printf("***************** BIT %d (currentListSize %d, information_bit_pattern %d)\n", // currentBit,currentListSize,polarParams->information_bit_pattern[currentBit]); - start_meas(update_LLR); updateLLR(sorted_dlist, llrUpdated, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1), pathMetricAppr); - stop_meas(update_LLR); if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. updatePathMetric(sorted_dlist,currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 @@ -148,11 +129,9 @@ int8_t polar_decoder( updateCrcChecksum(sorted_dlist, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits); } else { - start_meas(path_metric); + updatePathMetric2(sorted_dlist, currentListSize, currentBit, pathMetricAppr); - stop_meas(path_metric); - - start_meas(sorting); + if (currentListSize <= listSize/2) { @@ -243,7 +222,6 @@ int8_t polar_decoder( sorted_dlist[i] = temp_dlist[listIndex[i]]; } } - stop_meas(sorting); } nonFrozenBit++; @@ -260,14 +238,10 @@ int8_t polar_decoder( if (crcState == 1) { for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_u[j]=sorted_dlist[i]->bit[0][j]; - start_meas(bit_extraction); //Extract the information bits (û to ĉ) nr_polar_info_bit_extraction(polarParams->nr_polar_u, polarParams->nr_polar_cPrime, polarParams->information_bit_pattern, polarParams->N); - stop_meas(bit_extraction); //Deinterleaving (ĉ to b) - start_meas(deinterleaving); nr_polar_deinterleaver(polarParams->nr_polar_cPrime, polarParams->nr_polar_b, polarParams->interleaving_pattern, polarParams->K); - stop_meas(deinterleaving); //Remove the CRC (â) for (int j = 0; j < polarParams->payloadBits; j++) output[j]=polarParams->nr_polar_b[j]; @@ -285,7 +259,7 @@ int8_t polar_decoder( }*/ nr_free_uint8_t_2D_array(extended_crc_generator_matrix, polarParams->K); nr_free_uint8_t_2D_array(tempECGM, polarParams->K); - stop_meas(decoding); + return(0); } @@ -296,15 +270,8 @@ int8_t polar_decoder_int8(int16_t *input, uint8_t *output, t_nrPolar_params *polarParams, uint8_t listSize, - time_stats_t *init, - time_stats_t *polar_rate_matching, - time_stats_t *decoding, - time_stats_t *bit_extraction, - time_stats_t *deinterleaving, - time_stats_t *sorting, - time_stats_t *path_metric, - time_stats_t *update_LLR, int generate_optim_code) + { @@ -318,7 +285,6 @@ int8_t polar_decoder_int8(int16_t *input, decoder_list_int8_t dlist[2*listSize]; - start_meas(init); for ( int i=0;i<2*listSize;i++) { // dlist[i].bit = nr_alloc_uint8_t_2D_array((polarParams->n+1), polarParams->N); @@ -332,7 +298,6 @@ int8_t polar_decoder_int8(int16_t *input, dlist[i].pathMetric = 0; } - stop_meas(init); if (generate_optim_code == 1 || polarParams->decoder_kernel==NULL) { for (int i=0; iN; i++) { @@ -345,7 +310,6 @@ int8_t polar_decoder_int8(int16_t *input, - start_meas(polar_rate_matching); int16_t d_tilde[polarParams->N];// = malloc(sizeof(double) * polarParams->N); nr_polar_rate_matching_int8(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); @@ -354,12 +318,11 @@ int8_t polar_decoder_int8(int16_t *input, else if (d_tilde[i]>127) d_tilde[i]=128; } memcpy((void*)&dlist[0].llr[polarParams->n][0],(void*)&d_tilde[0],sizeof(int16_t)*polarParams->N); - stop_meas(polar_rate_matching); /* * SCL polar decoder. */ - start_meas(decoding); + uint32_t nonFrozenBit=0; uint8_t currentListSize=1; @@ -383,18 +346,16 @@ int8_t polar_decoder_int8(int16_t *input, printf("***************** BIT %d (currentListSize %d, information_bit_pattern %d)\n", currentBit,currentListSize,polarParams->information_bit_pattern[currentBit]); - start_meas(update_LLR); + updateLLR_int8(sorted_dlist, llrUpdated, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1),generate_optim_code,fd); - stop_meas(update_LLR); if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. updatePathMetric0_int8(sorted_dlist,currentListSize, currentBit,generate_optim_code,fd); //approximation=0 --> 11b, approximation=1 --> 12 } else { //Information or CRC bit. - start_meas(path_metric); + updatePathMetric2_int8(sorted_dlist, currentListSize, currentBit,generate_optim_code,fd); - stop_meas(path_metric); + - start_meas(sorting); if (currentListSize <= listSize/2) { // until listsize is full we need to copy bit and LLR arrays to new entries @@ -426,7 +387,6 @@ int8_t polar_decoder_int8(int16_t *input, currentListSize = listSize; } - stop_meas(sorting); nonFrozenBit++; } @@ -446,14 +406,11 @@ int8_t polar_decoder_int8(int16_t *input, if (crcState == 1) { for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_u[j]=sorted_dlist[i]->bit[0][j]; - start_meas(bit_extraction); + //Extract the information bits (û to ĉ) nr_polar_info_bit_extraction(polarParams->nr_polar_u, polarParams->nr_polar_cPrime, polarParams->information_bit_pattern, polarParams->N); - stop_meas(bit_extraction); //Deinterleaving (ĉ to b) - start_meas(deinterleaving); nr_polar_deinterleaver(polarParams->nr_polar_cPrime, polarParams->nr_polar_b, polarParams->interleaving_pattern, polarParams->K); - stop_meas(deinterleaving); //Remove the CRC (â) for (int j = 0; j < polarParams->payloadBits; j++) output[j]=polarParams->nr_polar_b[j]; @@ -469,31 +426,16 @@ int8_t polar_decoder_int8(int16_t *input, nr_free_double_2D_array(dlist[i].llr, (polarParams->n+1)); free(dlist[i].crcChecksum); }*/ - stop_meas(decoding); return(0); } int8_t polar_decoder_int8_new(int16_t *input, uint8_t *output, - t_nrPolar_params *polarParams, - uint8_t listSize, - time_stats_t *init, - time_stats_t *polar_rate_matching, - time_stats_t *decoding, - time_stats_t *bit_extraction, - time_stats_t *deinterleaving, - time_stats_t *sorting, - time_stats_t *path_metric, - time_stats_t *update_LLR, - int generate_optim_code) + t_nrPolar_params *polarParams) { - start_meas(init); - stop_meas(init); - - start_meas(polar_rate_matching); int16_t d_tilde[polarParams->N];// = malloc(sizeof(double) * polarParams->N); nr_polar_rate_matching_int8(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength); @@ -502,23 +444,22 @@ int8_t polar_decoder_int8_new(int16_t *input, else if (d_tilde[i]>127) d_tilde[i]=128; } memcpy((void*)&polarParams->tree.root->alpha[0],(void*)&d_tilde[0],sizeof(int16_t)*polarParams->N); - stop_meas(polar_rate_matching); /* * SCL polar decoder. */ - start_meas(decoding); + generic_polar_decoder(polarParams,polarParams->tree.root); - start_meas(bit_extraction); + //Extract the information bits (û to ĉ) nr_polar_info_bit_extraction(polarParams->nr_polar_u, polarParams->nr_polar_cPrime, polarParams->information_bit_pattern, polarParams->N); - stop_meas(bit_extraction); + //Deinterleaving (ĉ to b) - start_meas(deinterleaving); + nr_polar_deinterleaver(polarParams->nr_polar_cPrime, polarParams->nr_polar_b, polarParams->interleaving_pattern, polarParams->K); - stop_meas(deinterleaving); + //Remove the CRC (â) for (int j = 0; j < polarParams->payloadBits; j++) output[j]=polarParams->nr_polar_b[j]; @@ -532,6 +473,6 @@ int8_t polar_decoder_int8_new(int16_t *input, nr_free_double_2D_array(dlist[i].llr, (polarParams->n+1)); free(dlist[i].crcChecksum); }*/ - stop_meas(decoding); + return(0); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 34c2e9a50b..23314593a5 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -30,7 +30,6 @@ #include #include -#include "PHY/TOOLS/time_meas.h" static const uint8_t nr_polar_subblock_interleaver_pattern[32] = { 0, 1, 2, 4, 3, 5, 6, 7, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 14, 22, 15, 23, 24, 25, 26, 28, 27, 29, 30, 31 }; @@ -126,30 +125,18 @@ void polar_encoder(uint8_t *input, uint8_t *output, t_nrPolar_params* polarParam void nr_polar_kernal_operation(uint8_t *u, uint8_t *d, uint16_t N); int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_params *polarParams, - uint8_t listSize, double *aPrioriPayload, uint8_t pathMetricAppr, - time_stats_t *init, - time_stats_t *polar_rate_matching, - time_stats_t *decoding, - time_stats_t *bit_extraction, - time_stats_t *deinterleaving, - time_stats_t *sorting, - time_stats_t *path_metric, - time_stats_t *update_LLR); + uint8_t listSize, double *aPrioriPayload, uint8_t pathMetricAppr); int8_t polar_decoder_int8(int16_t *input, uint8_t *output, t_nrPolar_params *polarParams, uint8_t listSize, - time_stats_t *init, - time_stats_t *polar_rate_matching, - time_stats_t *decoding, - time_stats_t *bit_extraction, - time_stats_t *deinterleaving, - time_stats_t *sorting, - time_stats_t *path_metric, - time_stats_t *update_LLR, int generate_optim_code); +int8_t polar_decoder_int8_new(int16_t *input, + uint8_t *output, + t_nrPolar_params *polarParams); + void nr_polar_llrtableinit(void); From 88d5bf42f8aa309010109b48e6d043aaf8885ca8 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sat, 13 Oct 2018 16:05:43 +0200 Subject: [PATCH 113/114] 16-bit llr decoder integrated --- openair1/PHY/CODING/TESTBENCH/polartest.c | 39 ++++++++++++------- .../CODING/nrPolar_tools/nr_polar_decoder.c | 6 +-- .../nrPolar_tools/nr_polar_decoding_tools.c | 16 ++++++-- openair1/PHY/CODING/nr_polar_init.c | 3 ++ 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 9f3ddf97a8..f412be1271 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -151,7 +151,9 @@ int main(int argc, char *argv[]) { uint8_t *encoderOutputByte = malloc(sizeof(uint8_t) * coderLength); double *modulatedInput = malloc (sizeof(double) * coderLength); //channel input double *channelOutput = malloc (sizeof(double) * coderLength); //add noise - + int16_t *channelOutput_int16; + if (decoder_int16 == 1) channelOutput_int16 = (int16_t*)malloc (sizeof(int16_t) * coderLength); + t_nrPolar_paramsPtr nrPolar_params = NULL, currentPtr = NULL; nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level); currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength, aggregation_level); @@ -323,13 +325,6 @@ int main(int argc, char *argv[]) { /*printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]); printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]);*/ -/* - if (decoder_int16==1) { - if (channelOutput[i] > 15) channelOutput_int8[i] = 127; - else if (channelOutput[i] < -16) channelOutput_int8[i] = -128; - else channelOutput_int8[i] = (int16_t) (8*channelOutput[i]); - } -*/ //Bit-to-byte: nr_bit2byte_uint32_8_t(encoderOutput, coderLength, encoderOutputByte); @@ -341,6 +336,15 @@ int main(int argc, char *argv[]) { modulatedInput[i]=(-1)/sqrt(2); channelOutput[i] = modulatedInput[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin))); + + + if (decoder_int16==1) { + if (channelOutput[i] > 15) channelOutput_int16[i] = 127; + else if (channelOutput[i] < -16) channelOutput_int16[i] = -128; + else channelOutput_int16[i] = (int16_t) (8*channelOutput[i]); + } + + } start_meas(&timeDecoder); @@ -350,12 +354,19 @@ int main(int argc, char *argv[]) { NR_POLAR_DECODER_LISTSIZE, aPrioriArray, NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION);*/ - decoderState = polar_decoder_aPriori(channelOutput, - estimatedOutput, - currentPtr, - NR_POLAR_DECODER_LISTSIZE, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, - aPrioriArray); + if (decoder_int16==0) + decoderState = polar_decoder_aPriori(channelOutput, + estimatedOutput, + currentPtr, + NR_POLAR_DECODER_LISTSIZE, + NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, + aPrioriArray); + else + decoderState = polar_decoder_int16(channelOutput_int16, + estimatedOutput, + currentPtr); + + stop_meas(&timeDecoder); /*printf("testInput: [0]->0x%08x\n", testInput[0]); printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]);*/ diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 8353d0f21e..f1b72ae897 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -1039,7 +1039,7 @@ int8_t polar_decoder_dci(double *input, int8_t polar_decoder_int16(int16_t *input, - uint8_t *output, + uint8_t *out, t_nrPolar_params *polarParams) { @@ -1069,9 +1069,9 @@ int8_t polar_decoder_int16(int16_t *input, nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); //Remove the CRC (â) - for (int j = 0; j < polarParams->payloadBits; j++) output[j]=polarParams->nr_polar_B[j]; - + for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; + nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c index 5f019146f3..2891a3399b 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c @@ -34,6 +34,7 @@ #include "PHY/sse_intrin.h" #include "PHY/impl_defs_top.h" +//#define DEBUG_NEW_IMPL void updateLLR(double ***llr, uint8_t **llrU, @@ -266,7 +267,7 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { for (int i=0;iNv;i++) printf("i%d (frozen %d): alpha_v[i] = %d\n",i,1-pp->information_bit_pattern[node->first_leaf_index+i],alpha_v[i]); #endif - + if (node->left->all_frozen == 0) { @@ -275,7 +276,8 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { if (avx2mod == 0) { __m256i a256,b256,absa256,absb256,minabs256; int avx2len = node->Nv/2/16; - + + // printf("avx2len %d\n",avx2len); for (int i=0;iNv/2)]); + */ } } else if (avx2mod == 8) { @@ -315,6 +324,7 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { absb=(b+maskb)^maskb; minabs = absaNv == 2) { // apply hard decision on left node @@ -368,7 +378,7 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) { betar[0] = (alpha_r[0]>0) ? -1 : 1; pp->nr_polar_U[node->first_leaf_index+1] = (1+betar[0])>>1; #ifdef DEBUG_NEW_IMPL - printf("Setting bit %d to %d (LLR %d frozen_mask %d)\n",node->first_leaf_index+1,(betar[0]+1)>>1,alpha_r[0],frozen_mask); + printf("Setting bit %d to %d (LLR %d)\n",node->first_leaf_index+1,(betar[0]+1)>>1,alpha_r[0]); #endif } } diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index 87da29c48e..e238c7b84f 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -147,6 +147,9 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams, free(J); + build_decoder_tree(newPolarInitNode); + printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes); + } else { AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_paramsPtr could not be created"); } From 76ebc5adeb61364b3a2e8de75fb7707d9e9c5500 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 14 Oct 2018 10:10:56 +0200 Subject: [PATCH 114/114] addition of ARM NEON intrinsics --- .../nrPolar_tools/nr_polar_decoding_tools.c | 144 ++++++++++++++---- 1 file changed, 114 insertions(+), 30 deletions(-) diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c index 2891a3399b..b79739e98d 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c @@ -254,6 +254,18 @@ void build_decoder_tree(t_nrPolar_params *pp) { } +#if defined(__arm__) || defined(__aarch64__) +// translate 1-1 SIMD functions from SSE to NEON +#define __m128i int16x8_t +#define __m64 int8x8_t +#define _mm_abs_epi16(a) vabsq_s16(a) +#define _mm_min_epi16(a,b) vminq_s16(a,b) +#define _mm_subs_epi16(a,b) vsubq_s16(a,b) +#define _mm_abs_pi16(a) vabs_s16(a) +#define _mm_min_pi16(a,b) vmin_s16(a,b) +#define _mm_subs_pi16(a,b) vsub_s16(a,b) +#endif + void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { int16_t *alpha_v=node->alpha; int16_t *alpha_l=node->left->alpha; @@ -270,7 +282,6 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { if (node->left->all_frozen == 0) { - #if defined(__AVX2__) int avx2mod = (node->Nv/2)&15; if (avx2mod == 0) { @@ -284,14 +295,7 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { absa256 =_mm256_abs_epi16(a256); absb256 =_mm256_abs_epi16(b256); minabs256 =_mm256_min_epi16(absa256,absb256); - ((__m256i*)alpha_l)[i] =_mm256_sign_epi16(minabs256,_mm256_xor_si256(a256,b256)); - /* for (int j=0;j<16;j++) printf("alphal[%d] %d (%d,%d,%d)\n", - (16*i) + j, - alpha_l[(16*i)+j], - ((int16_t*)&minabs256)[j], - alpha_v[(16*i)+j], - alpha_v[(16*i)+j+(node->Nv/2)]); - */ + ((__m256i*)alpha_l)[i] =_mm256_sign_epi16(minabs256,_mm256_sign_epi16(a256,b256)); } } else if (avx2mod == 8) { @@ -301,7 +305,7 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { absa128 =_mm_abs_epi16(a128); absb128 =_mm_abs_epi16(b128); minabs128 =_mm_min_epi16(absa128,absb128); - *((__m128i*)alpha_l) =_mm_sign_epi16(minabs128,_mm_xor_si128(a128,b128)); + *((__m128i*)alpha_l) =_mm_sign_epi16(minabs128,_mm_sign_epi16(a128,b128)); } else if (avx2mod == 4) { __m64 a64,b64,absa64,absb64,minabs64; @@ -310,11 +314,56 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { absa64 =_mm_abs_pi16(a64); absb64 =_mm_abs_pi16(b64); minabs64 =_mm_min_pi16(absa64,absb64); - *((__m64*)alpha_l) =_mm_sign_pi16(minabs64,_mm_xor_si64(a64,b64)); + *((__m64*)alpha_l) =_mm_sign_pi16(minabs64,_mm_sign_pi16(a64,b64)); } else +#else + int sse4mod = (node->Nv/2)&7; + int sse4len = node->Nv/2/8; +#if defined(__arm__) || defined(__aarch64__) + int16x8_t signatimesb,comp1,comp2,negminabs128; + int16x8_t zero=vdupq_n_s16(0); #endif - { + + if (sse4mod == 0) { + for (int i=0;iNv/2/8; + + a128 =*((__m128i*)alpha_v); + b128 =((__m128i*)alpha_v)[1]; + absa128 =_mm_abs_epi16(a128); + absb128 =_mm_abs_epi16(b128); + minabs128 =_mm_min_epi16(absa128,absb128); +#if defined(__arm__) || defined(__aarch64__) + // unfortunately no direct equivalent to _mm_sign_epi16 + signatimesb=vxorrq_s16(a128,b128); + comp1=vcltq_s16(signatimesb,zero); + comp2=vcgeq_s16(signatimesb,zero); + negminabs128=vnegq_s16(minabs128); + *((__m128i*)alpha_l) =vorrq_s16(vandq_s16(minabs128,comp0),vandq_s16(negminabs128,comp1)); +#else + *((__m128i*)alpha_l) =_mm_sign_epi16(minabs128,_mm_sign_epi16(a128,b128)); +#endif + } + } + else if (sse4mod == 4) { + __m64 a64,b64,absa64,absb64,minabs64; + a64 =*((__m64*)alpha_v); + b64 =((__m64*)alpha_v)[1]; + absa64 =_mm_abs_pi16(a64); + absb64 =_mm_abs_pi16(b64); + minabs64 =_mm_min_pi16(absa64,absb64); +#if defined(__arm__) || defined(__aarch64__) + AssertFatal(1==0,"Need to do this still for ARM\n"); +#else + *((__m64*)alpha_l) =_mm_sign_pi16(minabs64,_mm_sign_epi16(a64,b64)); +#endif + } + + else +#endif + { // equvalent scalar code to above, activated only on non x86/ARM architectures for (int i=0;iNv/2;i++) { a=alpha_v[i]; b=alpha_v[i+(node->Nv/2)]; @@ -367,9 +416,34 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) { else if (avx2mod == 8) { ((__m128i *)alpha_r)[0] = _mm_subs_epi16(((__m128i *)alpha_v)[1],_mm_sign_epi16(((__m128i *)alpha_v)[0],((__m128i *)betal)[0])); } + else if (avx2mod == 4) { + ((__m64 *)alpha_r)[0] = _mm_subs_pi16(((__m64 *)alpha_v)[1],_mm_sign_pi16(((__m64 *)alpha_v)[0],((__m64 *)betal)[0])); + } + else +#else + int sse4mod = (node->Nv/2)&7; + + if (sse4mod == 0) { + int sse4len = node->Nv/2/8; + + for (int i=0;iNv/2;i++) { alpha_r[i] = alpha_v[i+(node->Nv/2)] - (betal[i]*alpha_v[i]); } @@ -385,10 +459,10 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) { } -int16_t minus1[16] = {-1,-1,-1,-1, - -1,-1,-1,-1, - -1,-1,-1,-1, - -1,-1,-1,-1}; +int16_t all1[16] = {1,1,1,1, + 1,1,1,1, + 1,1,1,1, + 1,1,1,1}; void computeBeta(t_nrPolar_params *pp,decoder_node_t *node) { @@ -401,27 +475,37 @@ void computeBeta(t_nrPolar_params *pp,decoder_node_t *node) { if (node->left->all_frozen==0) { // if left node is not aggregation of frozen bits #if defined(__AVX2__) int avx2mod = (node->Nv/2)&15; + register __m256i allones=*((__m256i*)all1); if (avx2mod == 0) { int avx2len = node->Nv/2/16; - for (int i=0;iNv/2)&15; + + if (ssr4mod == 0) { + int ssr4len = node->Nv/2/8; + register __m128i allones=*((__m128i*)all1); + for (int i=0;i