From cf3682e3f15f543cc6733813ae06e37d585d035a Mon Sep 17 00:00:00 2001 From: Calvin HSU Date: Tue, 10 Jul 2018 19:38:47 +0200 Subject: [PATCH 1/3] Fixed error during build procedure --- openair1/PHY/phy_extern_nr_ue.h | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- openair2/LAYER2/NR_MAC_UE/mac.h | 58 ++++++--------- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 57 -------------- openair2/LAYER2/NR_MAC_UE/mac_vars.c | 2 +- openair2/LAYER2/NR_MAC_UE/proto.h | 2 +- openair2/RRC/NR_UE/main_ue.c | 2 +- openair2/RRC/NR_UE/rrc_UE.c | 36 ++++----- openair2/RRC/NR_UE/rrc_list.h | 82 +++++++++++++++++++++ targets/RT/USER/nr-ue.c | 13 ++-- 10 files changed, 131 insertions(+), 125 deletions(-) delete mode 100644 openair2/LAYER2/NR_MAC_UE/mac_proto.h create mode 100644 openair2/RRC/NR_UE/rrc_list.h diff --git a/openair1/PHY/phy_extern_nr_ue.h b/openair1/PHY/phy_extern_nr_ue.h index a9694ea058..253c5b7fb9 100644 --- a/openair1/PHY/phy_extern_nr_ue.h +++ b/openair1/PHY/phy_extern_nr_ue.h @@ -23,7 +23,7 @@ #define __PHY_EXTERN_UE__H__ #include "PHY/defs_nr_UE.h" -#include "common/ran_context.h" +//#include "common/ran_context.h" extern char* namepointer_chMag ; extern char* namepointer_log2; diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 44123a2479..05d26bd8e6 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -60,7 +60,7 @@ #endif #include "LAYER2/NR_MAC_UE/extern.h" -#include "LAYER2/NR_MAC_UE/defs.h" +#include "LAYER2/NR_MAC_UE/mac_defs.h" #include "UTIL/LOG/log.h" #ifdef EMOS diff --git a/openair2/LAYER2/NR_MAC_UE/mac.h b/openair2/LAYER2/NR_MAC_UE/mac.h index 253c855da8..e4935b1fea 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac.h +++ b/openair2/LAYER2/NR_MAC_UE/mac.h @@ -34,8 +34,8 @@ /*@}*/ -#ifndef __LAYER2_MAC_DEFS_H__ -#define __LAYER2_MAC_DEFS_H__ +#ifndef __LAYER2_NR_UE_MAC_DEFS_H__ +#define __LAYER2_NR_UE_MAC_DEFS_H__ @@ -43,40 +43,6 @@ #include #include -#include "COMMON/platform_constants.h" -#include "BCCH-BCH-Message.h" -#include "RadioResourceConfigCommon.h" -#include "RadioResourceConfigCommonSIB.h" -#include "RadioResourceConfigDedicated.h" -#include "MeasGapConfig.h" -#include "SchedulingInfoList.h" -#include "TDD-Config.h" -#include "RACH-ConfigCommon.h" -#include "MeasObjectToAddModList.h" -#include "MobilityControlInfo.h" -#if defined(Rel10) || defined(Rel14) -#include "MBSFN-AreaInfoList-r9.h" -#include "MBSFN-SubframeConfigList.h" -#include "PMCH-InfoList-r9.h" -#include "SCellToAddMod-r10.h" -#endif -#ifdef Rel14 -#include "SystemInformationBlockType1-v1310-IEs.h" -#endif - -#include "nfapi_interface.h" -#include "PHY_INTERFACE/IF_Module.h" - -#include "PHY/TOOLS/time_meas.h" - -#include "PHY/defs_common.h" // for PRACH_RESOURCES_t - -#include "targets/ARCH/COMMON/common_lib.h" - -//solve implicit declaration -#include "PHY/LTE_ESTIMATION/lte_estimation.h" -#include "PHY/LTE_TRANSPORT/transport_proto.h" -#include "PHY/LTE_TRANSPORT/transport_common_proto.h" /** @defgroup _mac MAC * @ingroup _oai2 @@ -89,4 +55,24 @@ /*!\brief Values of PCCH logical channel (fake) */ #define NR_BCCH_BCH 5 // MIB /*@}*/ + + + + + +/*!\brief UE layer 2 status */ +typedef enum { + CONNECTION_OK = 0, + CONNECTION_LOST, + PHY_RESYNCH, + PHY_HO_PRACH +} UE_L2_STATE_t; + + + + + + + + #endif /*__LAYER2_MAC_DEFS_H__ */ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h deleted file mode 100644 index b8f18bf950..0000000000 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ /dev/null @@ -1,57 +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 LAYER2/MAC/proto.h - * \brief MAC functions prototypes for eNB and UE - * \author Navid Nikaein and Raymond Knopp - * \date 2010 - 2014 - * \email navid.nikaein@eurecom.fr - * \version 1.0 - */ -#ifndef __LAYER2_MAC_PROTO_H__ -#define __LAYER2_MAC_PROTO_H__ - -#include "mac_defs.h" - -/**\brief decode mib pdu in NR_UE, from if_module ul_ind with P7 tx_ind message - \param module_id module id - \param CC_id component carrier id - \param gNB_index gNB index - \param extra_bits extra bits for frame calculation - \param ssb_index SSB index for frame calculation - \param frameP pointer to frame for revising after frame calculation - \param pduP pointer to pdu - \param pdu_length length of pdu*/ -void nr_ue_decode_mib(module_id_t module_id, int CC_id, uint8_t gNB_index, uint8_t extra_bits, uint32_t ssb_index, uint32_t *frameP, void *pduP, uint16_t pdu_len); - - -/**\brief primitive from RRC layer to MAC layer for configuration L1/L2, now supported 4 rrc messages: MIB, cell_group_config for MAC/PHY, spcell_config(serving cell config) - \param module_id module id - \param CC_id component carrier id - \param gNB_index gNB index - \param mibP pointer to RRC message MIB - \param mac_cell_group_configP pointer to RRC message MAC-related in cell group config - \param phy_cell_group_configP pointer to RRC message PHY-related in cell group config - \param spcell_configP pointer to RRC message serving cell config*/ -int nr_rrc_mac_config_req_ue( module_id_t module_id, int CC_id, uint8_t gNB_index, NR_MIB_t *mibP, NR_MAC_CellGroupConfig_t *mac_cell_group_configP, NR_PhysicalCellGroupConfig_t *phy_cell_group_configP, NR_SpCellConfig_t *spcell_configP ){ - -#endif -/** @}*/ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_vars.c b/openair2/LAYER2/NR_MAC_UE/mac_vars.c index 4ce77e2b93..3192d6dcc9 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_vars.c +++ b/openair2/LAYER2/NR_MAC_UE/mac_vars.c @@ -29,7 +29,7 @@ */ -#include "defs.h" +#include "mac_defs.h" NR_UE_MAC_INST_t UE_mac_inst; //[NB_MODULE_MAX]; diff --git a/openair2/LAYER2/NR_MAC_UE/proto.h b/openair2/LAYER2/NR_MAC_UE/proto.h index ffab06a43f..387bbc4e86 100755 --- a/openair2/LAYER2/NR_MAC_UE/proto.h +++ b/openair2/LAYER2/NR_MAC_UE/proto.h @@ -29,7 +29,7 @@ #ifndef __LAYER2_MAC_PROTO_H__ #define __LAYER2_MAC_PROTO_H__ -#include "defs.h" +#include "mac_defs.h" /**\brief decode mib pdu in NR_UE, from if_module ul_ind with P7 tx_ind message \param module_id module id diff --git a/openair2/RRC/NR_UE/main_ue.c b/openair2/RRC/NR_UE/main_ue.c index bbb3c0a64e..70d1cbb998 100644 --- a/openair2/RRC/NR_UE/main_ue.c +++ b/openair2/RRC/NR_UE/main_ue.c @@ -4,7 +4,7 @@ #include "rrc_proto.h" int nr_l3_init_ue(void){ - LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n"); + //LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n"); openair_rrc_top_init_ue_nr(); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 846a7a6b27..10f5a00266 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -71,21 +71,21 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(NR_RRCReconfiguration_t *rrcReconfig switch(rrcReconfiguration->criticalExtensions.present){ case NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration: - if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.radioBearerConfig != NULL){ + if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->radioBearerConfig != NULL){ if(NR_UE_rrc_inst->radio_bearer_config == NULL){ - NR_UE_rrc_inst->radio_bearer_config = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.radioBearerConfig; + NR_UE_rrc_inst->radio_bearer_config = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->radioBearerConfig; }else{ - nr_rrc_ue_process_radio_bearer_config(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.radioBearerConfig); + nr_rrc_ue_process_radio_bearer_config(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->radioBearerConfig); } } - if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.secondaryCellGroup != NULL){ + if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup != NULL){ NR_CellGroupConfig_t *cellGroupConfig = NULL; uper_decode(NULL, &asn_DEF_NR_CellGroupConfig, //might be added prefix later (void **)&cellGroupConfig, - (uint8_t *)rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.secondaryCellGroup->buf, - rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.secondaryCellGroup->size, 0, 0); + (uint8_t *)rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup->buf, + rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup->size, 0, 0); if(NR_UE_rrc_inst->cell_group_config == NULL){ // first time receive the configuration, just use the memory allocated from uper_decoder. TODO this is not good implementation, need to maintain RRC_INST own structure every time. @@ -100,21 +100,21 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(NR_RRCReconfiguration_t *rrcReconfig } - if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.measConfig != NULL){ + if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->measConfig != NULL){ if(NR_UE_rrc_inst->meas_config == NULL){ - NR_UE_rrc_inst->meas_config = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.measConfig; + NR_UE_rrc_inst->meas_config = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->measConfig; }else{ // if some element need to be updated - nr_rrc_ue_process_meas_config(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.measConfig); + nr_rrc_ue_process_meas_config(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->measConfig); } } - if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.lateNonCriticalExtension != NULL){ + if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->lateNonCriticalExtension != NULL){ // unuse now } - if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration.nonCriticalExtension != NULL){ + if(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->nonCriticalExtension != NULL){ // unuse now } break; @@ -298,10 +298,7 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( buffer_len ); if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E( RRC, "[UE %"PRIu8"] Failed to decode BCCH_DLSCH_MESSAGE (%zu bits)\n", - module_id, - dec_rval.consumed ); - + for (i=0; imessage.choice.mib; + mib = bcch_message->message.choice.mib; //memcpy( (void *)mib, // (void *)&bcch_message->message.choice.mib, // sizeof(NR_MIB_t) ); @@ -340,9 +337,6 @@ int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message( buffer_len, 0, 0); if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E( RRC, "[UE %"PRIu8"] Failed to decode NR_DL_DCCH_Message (%zu bits)\n", - module_id, - dec_rval.consumed ); for (i=0; imessage.present){ case NR_DL_DCCH_MessageType_PR_c1: - switch(nr_dl_dcch_msg->message.choice.c1.present){ + switch(nr_dl_dcch_msg->message.choice.c1->present){ case NR_DL_DCCH_MessageType__c1_PR_rrcReconfiguration: - nr_rrc_ue_process_rrcReconfiguration(&nr_dl_dcch_msg->message.choice.c1.choice.rrcReconfiguration); + nr_rrc_ue_process_rrcReconfiguration(nr_dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration); break; case NR_DL_DCCH_MessageType__c1_PR_NOTHING: diff --git a/openair2/RRC/NR_UE/rrc_list.h b/openair2/RRC/NR_UE/rrc_list.h new file mode 100644 index 0000000000..5bad103dd4 --- /dev/null +++ b/openair2/RRC/NR_UE/rrc_list.h @@ -0,0 +1,82 @@ +#ifndef _RRC_LIST_H_ +#define _RRC_LIST_H_ + + +#define RRC_LIST_TYPE(T, N) \ + struct { \ + T *entries[N]; \ + int next[N]; \ + int prev[N]; \ + int start; \ + int count; \ + } + +// initial function for the certain list, storage number of entry, initial pointer and corresponding links +#define RRC_LIST_INIT(list, c) \ + do { \ + int iterator; \ + (list).count = (c); \ + for(iterator=0; iteratorid_name == (list).entries[iterator]->id_name){ \ + (list).entries[iterator] = (new); \ + break; \ + } \ + } \ + if(iterator==-1){ \ + for(iterator=0; iterator<(list).count; ++iterator){ \ + if((list).entries[iterator] == NULL){ \ + (list).next[iterator] = (list).start; \ + (list).prev[iterator] = -1; \ + if((list).start != -1){ \ + (list).prev[list.start] = iterator; \ + } \ + (list).start = iterator; \ + (list).entries[iterator] = (new); \ + break; \ + } \ + } \ + } \ + }while(0) + +// search entries by id, unlink from the list and output free pointer for upper function to release memory +#define RRC_LIST_MOD_REL(list, id_name, id, free) \ + do{ \ + int iterator; \ + for(iterator=(list).start; iterator!=-1; iterator=(list).next[iterator]){ \ + if(id == (list).entries[iterator]->id_name){ \ + if((list).prev[iterator] == -1){ \ + (list).start = (list).next[iterator]; \ + }else{ \ + (list).next[(list).prev[iterator]] = (list).next[iterator]; \ + } \ + if((list).next[iterator] != -1){ \ + (list).prev[(list).next[iterator]] = (list).prev[iterator]; \ + } \ + (free) = (list).entries[iterator]; \ + (list).entries[iterator] = NULL; \ + break; \ + } \ + } \ + }while(0) + + +#define RRC_LIST_FOREACH(list, i) \ + for((i)=(list).start; (i) != -1; (i)=(list).next[i]) + +#define RRC_LIST_ENTRY(list, i) \ + list.entries[i] + +#endif \ No newline at end of file diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 5c6f25bb8d..cb80fede45 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -33,16 +33,16 @@ #include "rt_wrapper.h" -#include "LAYER2/MAC/mac.h" -#include "RRC/LTE/rrc_extern.h" +#include "LAYER2/NR_MAC_UE/mac.h" +//#include "RRC/LTE/rrc_extern.h" #include "PHY_INTERFACE/phy_interface_extern.h" #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all #include "PHY/phy_extern_nr_ue.h" -#include "LAYER2/MAC/mac_extern.h" -#include "LAYER2/MAC/mac_proto.h" +//#include "LAYER2/NR_MAC_UE/extern.h" +#include "LAYER2/NR_MAC_UE/proto.h" #include "SCHED_NR/extern.h" //#ifndef NO_RAT_NR @@ -734,7 +734,7 @@ void *UE_thread(void *arg) { init_UE_threads(UE); #ifdef NAS_UE - MessageDef *message_p; + //MessageDef *message_p; //message_p = itti_alloc_new_message(TASK_NAS_UE, INITIALIZE_MESSAGE); //itti_send_msg_to_task (TASK_NAS_UE, UE->Mod_id + NB_eNB_INST, message_p); #endif @@ -1037,6 +1037,7 @@ void init_UE_threads(PHY_VARS_NR_UE *UE) { #ifdef OPENAIR2 +/* void fill_ue_band_info(void) { UE_EUTRA_Capability_t *UE_EUTRA_Capability = UE_rrc_inst[0].UECap->UE_EUTRA_Capability; @@ -1063,7 +1064,7 @@ void fill_ue_band_info(void) { break; } } -} +}*/ #endif int setup_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg) { From 18b62e535e6b60f27c71990cd3ee4abac63e3f78 Mon Sep 17 00:00:00 2001 From: Calvin Date: Wed, 11 Jul 2018 11:31:06 +0200 Subject: [PATCH 2/3] Update FAPI DCI structure from Rel15.1 to Rel15.2 structure name: fapi_nr_dci_pdu_rel15_t DCI format 0_0 - define CS-RNTI - C-RNTI, CS-RNTI add padding bits DCI format 0_1 - define CS-RNTI, SP-CSI-RNTI - C-RNTI, CS-RNTI, SP-CSI-RNTI: - remove VRB-to-PRB-mapping - add UL-SCH indicator DCI format 1_0 - define CS-RNTI - C-RNTI & freq_domain_resource all ones: - add random access preamble index - add ul/sch indication - add ss/pbch index - add prach mask index - P-RNTI: - add short messages - add freq_domain_resource - add time_domain_resource - add VRB-to-PRB-mapping - add NDI - add TB scaling - SI-RNTI: - add freq_domain_resource - add time_domain_resource - add VRB-to-PRB-mapping - add MCS - add RV - RA-RNTI (for RAR): - add TB scaling - remove NDI - remove RV - remove HARQ process number - remove Downlink assignment index - remove TPC - remove PUCCH resource indicator - remove PDSCH to HARQ feedback DCI format 1_1 - define CS-RNTI DCI format 2_2 - change TPC commands to block numbers - add closed loop indicator - add TPC command DCI format 2_3 - add TPC command numbers --- .../nfapi/public_inc/fapi_nr_ue_interface.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 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 ad4dcc349b..607786ee97 100755 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -79,8 +79,13 @@ typedef struct { uint8_t redundancy_version; uint8_t harq_process; uint8_t tpc_command; - + uint8_t padding_bits; uint8_t ul_sul_ind; + uint8_t ul_sch_indicator; + + uint8_t random_access_preamble_index; + uint8_t ss_pbch_index; + uint8_t prach_mask_index; uint8_t carrier_indicator; uint8_t bwp_indndicator; @@ -100,6 +105,9 @@ typedef struct { uint8_t pdsch_to_harq_feedback_timing_indicator; uint8_t short_messages_indicator; + uint8_t short_messages; + uint8_t tb_scaling; + uint8_t prb_bundling_size_indicator; // 38.214 chapter 5.1.2.3 uint8_t rate_matching_indicator; @@ -113,11 +121,12 @@ typedef struct { uint8_t preemption_indication_count; uint8_t *preemption_indications; // 38.213 chapter 11.2 + uint8_t block_number_count; // for F22 and F23 + uint8_t *block_numbers; // for F22 and F23 + uint8_t closed_loop_indicator; + uint8_t tpc_command_count; uint8_t *tpc_command_numbers; - - uint8_t block_number_count; - uint8_t *block_numbers; uint8_t dci2_3_srs_request; // 38.212 table 7.3.1.1.2-5 uint8_t dci2_3_tpc_command; From aeb298d012d1f7e9fa57a545323bb47da2d51482 Mon Sep 17 00:00:00 2001 From: Guy De Souza Date: Wed, 11 Jul 2018 15:39:49 +0200 Subject: [PATCH 3/3] Interleaving update --- openair1/PHY/NR_TRANSPORT/nr_pbch.c | 30 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c index e66bed3908..efad146dbf 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c @@ -183,7 +183,7 @@ uint8_t nr_pbch_payload_interleaving_pattern[32] = {16, 23, 18, 17, 8, 30, 10, 6 uint8_t nr_pbch_payload_interleaver(uint8_t i) { uint8_t j_sfn=0, j_hrf=10, j_ssb=11, j_other=14; - if (24<=i && i<=27) //Sfn bits + if (18<=i && i<=27) //Sfn bits return nr_pbch_payload_interleaving_pattern[j_sfn + i -24]; else if (i==28) // Hrf bit return nr_pbch_payload_interleaving_pattern[j_hrf]; @@ -206,7 +206,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, NR_DL_FRAME_PARMS *frame_parms) { - int k,l,m; + int j,k,l,m; int16_t a; int16_t mod_pbch_e[NR_POLAR_PBCH_E]; uint8_t idx=0; @@ -225,7 +225,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, #ifdef DEBUG_PBCH_ENCODING printf("Byte endian fix:\n"); for (int i=0; i<4; i++) - printf("pbch_a[%d]: 0x%04x\n", i, pbch->pbch_a[i]); + printf("pbch_a[%d]: 0x%02x\n", i, pbch->pbch_a[i]); #endif // Extra byte generation @@ -242,18 +242,24 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, #ifdef DEBUG_PBCH_ENCODING printf("Extra byte:\n"); for (int i=0; i<4; i++) - printf("pbch_a[%d]: 0x%04x\n", i, pbch->pbch_a[i]); + printf("pbch_a[%d]: 0x%02x\n", i, pbch->pbch_a[i]); #endif // Payload interleaving - uint32_t* input = (uint32_t*)pbch->pbch_a; - uint32_t* output = (uint32_t*)pbch->pbch_a_interleaved; - for (int i=0; i<32; i++) - (*output) |= (((*input)>>i)&1)<<(nr_pbch_payload_interleaver(i)); + uint8_t *in = &pbch->pbch_a[3]; + uint8_t *out = &pbch->pbch_a_interleaved[3]; + for (int i=0; i<32; i++) { + j = i&7; + if (!j) { + in--; + out--; + } + (*out) |= (((*in)>>j)&1)<<((nr_pbch_payload_interleaver(i))&7); + } #ifdef DEBUG_PBCH_ENCODING printf("Interleaving:\n"); for (int i=0; i<4; i++) - printf("pbch_a_interleaved[%d]: 0x%04x\n", i, pbch->pbch_a_interleaved[i]); + printf("pbch_a_interleaved[%d]: 0x%02x\n", i, pbch->pbch_a_interleaved[i]); #endif // Scrambling @@ -263,7 +269,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, #ifdef DEBUG_PBCH_ENCODING printf("Payload scrambling:\n"); for (int i=0; i<4; i++) - printf("pbch_a_prime[%d]: 0x%04x\n", i, pbch->pbch_a_prime[i]); + printf("pbch_a_prime[%d]: 0x%02x\n", i, pbch->pbch_a_prime[i]); #endif @@ -272,7 +278,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, #ifdef DEBUG_PBCH_ENCODING printf("Channel coding:\n"); for (int i=0; i>3; i++) - printf("pbch_e[%d]: 0x%04x\t", i, pbch->pbch_e[i]); + printf("pbch_e[%d]: 0x%02x\t", i, pbch->pbch_e[i]); printf("\n"); #endif @@ -283,7 +289,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, #ifdef DEBUG_PBCH_ENCODING printf("Scrambling:\n"); for (int i=0; i>3; i++) - printf("pbch_e[%d]: 0x%04x\t", i, pbch->pbch_e[i]); + printf("pbch_e[%d]: 0x%02x\t", i, pbch->pbch_e[i]); printf("\n"); #endif