diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index 261b51e54876fe84f6bb6e13465435e355c0d736..c4015fa0cd8504b106c31f09a9cd94965a7c979f 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -1287,6 +1287,18 @@ set(PHY_SRC_UE
   # actual source
   ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep.c
   ${OPENAIR1_DIR}/PHY/INIT/nr_parms.c
+  ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/pss_nr.c
+  ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/sss_nr.c
+  ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/cic_filter_nr.c
+  ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/dmrs_nr.c
+  ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_initial_sync.c
+  ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_pbch.c
+  ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/
+  ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c
+  ${OPENAIR1_DIR}/PHY/NR_REFSIG/ul_ref_seq_nr.c
+  ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_dmrs_rx.c
+  ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold_ue.c
+  ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
   ${OPENAIR1_DIR}/PHY/TOOLS/file_output.c
   ${OPENAIR1_DIR}/PHY/TOOLS/cadd_vv.c
   ${OPENAIR1_DIR}/PHY/TOOLS/lte_dfts.c
@@ -1299,6 +1311,7 @@ set(PHY_SRC_UE
   ${OPENAIR1_DIR}/PHY/TOOLS/sqrt.c
   ${OPENAIR1_DIR}/PHY/TOOLS/time_meas.c
   ${OPENAIR1_DIR}/PHY/TOOLS/lut.c
+  ${OPENAIR1_DIR}/PHY/INIT/nr_init_ue.c
   )
 
 if (${SMBV})
@@ -1306,7 +1319,7 @@ if (${SMBV})
 endif  (${SMBV})
 
 if (${COMPILATION_AVX2} STREQUAL "True")
- # set(PHY_SRC ${PHY_SRC} ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c)
+  #set(PHY_SRC ${PHY_SRC} ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dlsch_llr_computation_avx2.c)
   set(PHY_SRC_UE ${PHY_SRC_UE} ${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c)
 endif ()
 
@@ -2161,6 +2174,44 @@ add_executable(nr-softmodem
   ${OPENAIR_TARGETS}/COMMON/create_tasks.c
   ${OPENAIR_TARGETS}/COMMON/create_nr_tasks.c
   ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
+  ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
+  ${OPENAIR_DIR}/common/utils/utils.c
+  ${OPENAIR_DIR}/common/utils/system.c
+  ${GTPU_need_ITTI}
+  ${XFORMS_SOURCE}
+  ${XFORMS_SOURCE_SOFTMODEM}
+  ${T_SOURCE}
+  ${CONFIG_SOURCES}
+  ${SHLIB_LOADER_SOURCES}
+  )
+
+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
+  NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
+  -Wl,--end-group z dl)
+
+target_link_libraries (nr-softmodem ${LIBXML2_LIBRARIES})
+target_link_libraries (nr-softmodem pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp  ${XFORMS_LIBRARIES} ${PROTOBUF_LIB}  ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES})
+target_link_libraries (nr-softmodem ${LIB_LMS_LIBRARIES})
+target_link_libraries (nr-softmodem ${T_LIB})
+
+# nr-softmodem-nos1
+###################################################
+
+add_executable(nr-softmodem-nos1
+  ${rrc_h}
+  ${s1ap_h}
+  ${OPENAIR_BIN_DIR}/messages_xml.h
+  ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
+  ${OPENAIR_TARGETS}/RT/USER/nr-gnb.c
+  ${OPENAIR_TARGETS}/RT/USER/nr-ru.c
+  ${OPENAIR_TARGETS}/RT/USER/nr-softmodem.c
+  ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
+  ${OPENAIR_TARGETS}/COMMON/create_tasks.c
+  ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
   ${OPENAIR2_DIR}/RRC/NAS/nas_config.c
   ${OPENAIR2_DIR}/RRC/NAS/rb_config.c
   ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
@@ -2177,7 +2228,7 @@ add_executable(nr-softmodem
 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}
+  ${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
   NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
   -Wl,--end-group z dl)
@@ -2187,6 +2238,76 @@ target_link_libraries (nr-softmodem pthread m ${CONFIG_LIBRARIES} rt crypt ${CRY
 target_link_libraries (nr-softmodem ${LIB_LMS_LIBRARIES})
 target_link_libraries (nr-softmodem ${T_LIB})
 
+# nr-uesoftmodem is  UE implementation
+#######################################
+
+add_executable(nr-uesoftmodem
+  ${rrc_h}
+  ${s1ap_h}
+  ${OPENAIR_BIN_DIR}/messages_xml.h
+  ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
+  ${OPENAIR_TARGETS}/RT/USER/nr-ue.c
+  ${OPENAIR_TARGETS}/RT/USER/nr-uesoftmodem.c
+  ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
+  ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c
+  ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
+  ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
+  ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
+  ${OPENAIR_DIR}/common/utils/utils.c
+  ${OPENAIR_DIR}/common/utils/system.c
+  ${XFORMS_SOURCE}
+  ${XFORMS_SOURCE_SOFTMODEM}
+  ${T_SOURCE}
+  ${CONFIG_SOURCES}
+  ${SHLIB_LOADER_SOURCES}
+  )
+
+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 
+  ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7
+  -Wl,--end-group z dl)
+
+target_link_libraries (nr-uesoftmodem ${LIBXML2_LIBRARIES})
+target_link_libraries (nr-uesoftmodem pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp  ${XFORMS_LIBRARIES} ${PROTOBUF_LIB}  ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES})
+target_link_libraries (nr-uesoftmodem ${LIB_LMS_LIBRARIES})
+target_link_libraries (nr-uesoftmodem ${T_LIB})
+
+# nr-uesoftmodem is  UE implementation
+#######################################
+
+add_executable(nr-uesoftmodem-nos1
+  ${rrc_h}
+  ${s1ap_h}
+  ${OPENAIR_BIN_DIR}/messages_xml.h
+  ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c
+  ${OPENAIR_TARGETS}/RT/USER/nr-ue.c
+  ${OPENAIR_TARGETS}/RT/USER/nr-uesoftmodem.c
+  ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
+  ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c
+  ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
+  ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
+  ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c
+  ${OPENAIR_DIR}/common/utils/utils.c
+  ${OPENAIR_DIR}/common/utils/system.c
+  ${XFORMS_SOURCE}
+  ${XFORMS_SOURCE_SOFTMODEM}
+  ${T_SOURCE}
+  ${CONFIG_SOURCES}
+  ${SHLIB_LOADER_SOURCES}
+  )
+
+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 
+  ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7
+  -Wl,--end-group z dl)
+
+target_link_libraries (nr-uesoftmodem-nos1 ${LIBXML2_LIBRARIES})
+target_link_libraries (nr-uesoftmodem-nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp  ${XFORMS_LIBRARIES} ${PROTOBUF_LIB}  ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES})
+target_link_libraries (nr-uesoftmodem-nos1 ${LIB_LMS_LIBRARIES})
+target_link_libraries (nr-uesoftmodem-nos1 ${T_LIB})
+
 # USIM process
 #################
 #add_executable(usim
@@ -2442,7 +2563,7 @@ endforeach()
 # force castxml and clang compilation with gnu89 standard
 # we can't use cXX standard as pthread_rwlock_t is gnu standard
 list(APPEND itti_compiler_options "-std=gnu89")
-set (ITTI_H ${ITTI_DIR}/intertask_interface_types.h)
+set (ITTI_H ${OPENAIR_DIR}/common/utils/T/T.h) #${ITTI_DIR}/intertask_interface_types.h)
 if(EXISTS /usr/bin/gccxml)
    set(xml_command gccxml ${itti_compiler_options} -fxml=${OPENAIR_BIN_DIR}/messages.xml ${ITTI_H})
 else()
diff --git a/common/ran_context.h b/common/ran_context.h
index 14db3056d32a6047ea609d7e0e1ab2de9be8caab..4a011c8644a51853553174e6d5489853b2538441 100644
--- a/common/ran_context.h
+++ b/common/ran_context.h
@@ -48,10 +48,10 @@
 #include "gtpv1u_eNB_defs.h"
 
 #include "PHY/defs_L1_NB_IoT.h"
-
 #include "RRC/LTE/defs_NB_IoT.h"
 #include "RRC/NR/nr_rrc_defs.h"
 
+
 typedef struct {
   /// RAN context config file name
   char *config_file_name;
diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h
index 0d4eec073d88a6f8a6c7c5e773abed64bec18a3f..cbf9ab47c98b3ed98612249df3c28340b48ae7f7 100644
--- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h
+++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h
@@ -15,8 +15,7 @@
  */
 
 
-#ifndef _NFAPI_INTERFACE_NR_EXTENSION_H_
-#define _NFAPI_INTERFACE_NR_EXTENSION_H_
+#ifndef _NFAPI_INTERFACE_H_
 #define _NFAPI_INTERFACE_H_
 
 #include "stddef.h"
diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface_nr_extension.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface_nr_extension.h
deleted file mode 100644
index fcfb7e7b25c5ea6971d0adeac1550a0a30e8d51b..0000000000000000000000000000000000000000
--- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface_nr_extension.h
+++ /dev/null
@@ -1,3886 +0,0 @@
-/*
- * Copyright 2017 Cisco Systems, Inc.
- *
- * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
- *
- * 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.
- */
-
-
-#ifndef _NFAPI_INTERFACE_NR_EXTENSION_H_
-#define _NFAPI_INTERFACE_NR_EXTENSION_H_
-#define _NFAPI_INTERFACE_H_
-
-#include "stddef.h"
-
-// Constants - update based on implementation
-#define NFAPI_MAX_PHY_RF_INSTANCES 2
-#define NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH 16
-#define NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH 3
-#define NFAPI_MAX_NUM_RF_BANDS 16
-
-// The following definition control the size of arrays used in the interface.
-// These may be changed if desired. They are used in the encoder to make sure 
-// that the user has not specified a 'count' larger than the max array, and also
-// used by the decoder when decode an array. If the 'count' received is larger
-// than the array it is to be stored in the decode fails.
-#define NFAPI_MAX_NUM_ANTENNAS 8
-#define NFAPI_MAX_NUM_SUBBANDS 13
-#define NFAPI_MAX_BF_VECTORS 8
-#define NFAPI_MAX_CC 1
-#define NFAPI_MAX_NUM_PHYSICAL_ANTENNAS 8
-#define NFAPI_MAX_RSSI 8
-#define NFAPI_MAX_PSC_LIST 32
-#define NFAPI_MAX_PCI_LIST 32
-#define NFAPI_MAX_CARRIER_LIST 32
-#define NFAPI_MAX_ARFCN_LIST 128
-#define NFAPI_MAX_LTE_CELLS_FOUND 8
-#define NFAPI_MAX_UTRAN_CELLS_FOUND 8
-#define NFAPI_MAX_GSM_CELLS_FOUND 8
-#define NFAPI_MAX_NB_IOT_CELLS_FOUND 8
-#define NFAPI_MAX_SI_PERIODICITY 8
-#define NFAPI_MAX_SI_INDEX 8
-#define NFAPI_MAX_MIB_LENGTH 32
-#define NFAPI_MAX_SIB_LENGTH 256
-#define NFAPI_MAX_SI_LENGTH 256
-#define NFAPI_MAX_OPAQUE_DATA 64
-#define NFAPI_MAX_NUM_SCHEDULED_UES 8 // Used in the TPM structure
-#define NFAPI_MAX_PNF_PHY 5
-#define NFAPI_MAX_PNF_PHY_RF_CONFIG 5
-#define NFAPI_MAX_PNF_RF  5
-#define NFAPI_MAX_NMM_FREQUENCY_BANDS 32
-#define NFAPI_MAX_RECEIVED_INTERFERENCE_POWER_RESULTS 100
-#define NFAPI_MAX_UL_DL_CONFIGURATIONS 5
-#define NFAPI_MAX_CSI_RS_RESOURCE_CONFIG 4
-#define NFAPI_MAX_ANTENNA_PORT_COUNT 8
-#define NFAPI_MAX_EPDCCH_PRB 8
-#define NFAPI_MAX_TX_PHYSICAL_ANTENNA_PORTS 8
-#define NFAPI_MAX_NUMBER_ACK_NACK_TDD 8
-#define NFAPI_MAX_RO_DL 8
-
-#define NFAPI_HEADER_LENGTH 8
-#define NFAPI_P7_HEADER_LENGTH 16
-
-#define NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE 0xF000
-#define NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE 0xFFFF
-
-#define NFAPI_VERSION_3_0_11	0x000
-#define NFAPI_VERSION_3_0_12    0x001
-
-// The IANA agreed port definition of the P5 SCTP VNF enpoint 
-// http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=7701
-#define NFAPI_P5_SCTP_PORT		7701
-
-typedef unsigned int	uint32_t;
-typedef unsigned short	uint16_t;
-typedef unsigned char	uint8_t;
-typedef signed int		int32_t;
-typedef signed short	int16_t;
-typedef signed char		int8_t;
-
-typedef struct {
-	uint16_t phy_id;
-	uint16_t message_id;
-	uint16_t message_length;
-	uint16_t spare;
-} nfapi_p4_p5_message_header_t;
-
-typedef struct {
-	uint16_t phy_id;
-	uint16_t message_id;
-	uint16_t message_length;
-	uint16_t m_segment_sequence; /* This consists of 3 fields - namely, M, Segement & Sequence number*/
-	uint32_t checksum;
-	uint32_t transmit_timestamp;
-} nfapi_p7_message_header_t;
-
-#define NFAPI_PHY_ID_NA 0
-
-//#define NFAPI_P7_GET_MORE(_mss) ( ((_mss) & 0x80) >> 7 )
-//#define NFAPI_P7_GET_SEGMENT(_mss) ( ((_mss) & 0x70) >> 4 )
-#define NFAPI_P7_GET_MORE(_mss) ( ((_mss) & 0x8000) >> 15 )
-#define NFAPI_P7_GET_SEGMENT(_mss) ( ((_mss) & 0x7F00) >> 8 )
-#define NFAPI_P7_GET_SEQUENCE(_mss) ( (_mss) & 0x00FF )
-#define NFAPI_P7_SET_MSS(_more, _segm, _sequ) ( (((_more) & 0x1) << 7) | (((_segm) & 0x7) << 4) | ((_sequ) & 0xF) )
-
-typedef struct {
-	uint16_t tag;
-	uint16_t length;
-} nfapi_tl_t;
-#define NFAPI_TAG_LENGTH_PACKED_LEN 4
-
-// Convenience methods to convert between SFN/SFN formats
-#define NFAPI_SFNSF2DEC(_sfnsf) ((((_sfnsf) >> 4) * 10) + ((_sfnsf) & 0xF))
-#define NFAPI_SFNSFDEC2SFNSF(_sfnsf_dec) ((((_sfnsf_dec) / 10) << 4) | (((_sfnsf_dec) - (((_sfnsf_dec) / 10) * 10)) & 0xF))
-
-#define NFAPI_SFNSF2SFN(_sfnsf) ((_sfnsf) >> 4)
-#define NFAPI_SFNSF2SF(_sfnsf) ((_sfnsf) & 0xF)
-
-#define NFAPI_MAX_SFNSFDEC 10240
-
-typedef nfapi_tl_t* nfapi_vendor_extension_tlv_t;
-
-
-// nFAPI Message IDs
-typedef enum {
-	NFAPI_DL_CONFIG_REQUEST = 0x0080,
-	NFAPI_UL_CONFIG_REQUEST,
-	NFAPI_SUBFRAME_INDICATION,
-	NFAPI_HI_DCI0_REQUEST,
-	NFAPI_TX_REQUEST,
-	NFAPI_HARQ_INDICATION,
-	NFAPI_CRC_INDICATION,
-	NFAPI_RX_ULSCH_INDICATION,
-	NFAPI_RACH_INDICATION,
-	NFAPI_SRS_INDICATION,
-	NFAPI_RX_SR_INDICATION,
-	NFAPI_RX_CQI_INDICATION,
-	NFAPI_LBT_DL_CONFIG_REQUEST,
-	NFAPI_LBT_DL_INDICATION,
-	NFAPI_NB_HARQ_INDICATION,
-	NFAPI_NRACH_INDICATION,
-
-	NFAPI_PNF_PARAM_REQUEST = 0x0100,
-	NFAPI_PNF_PARAM_RESPONSE,
-	NFAPI_PNF_CONFIG_REQUEST,
-	NFAPI_PNF_CONFIG_RESPONSE,
-	NFAPI_PNF_START_REQUEST,
-	NFAPI_PNF_START_RESPONSE,
-	NFAPI_PNF_STOP_REQUEST,
-	NFAPI_PNF_STOP_RESPONSE,
-	NFAPI_PARAM_REQUEST,
-	NFAPI_PARAM_RESPONSE,
-	NFAPI_CONFIG_REQUEST,
-	NFAPI_CONFIG_RESPONSE,
-	NFAPI_START_REQUEST,
-	NFAPI_START_RESPONSE,
-	NFAPI_STOP_REQUEST,
-	NFAPI_STOP_RESPONSE,
-	NFAPI_MEASUREMENT_REQUEST,
-	NFAPI_MEASUREMENT_RESPONSE,
-
-	NFAPI_UL_NODE_SYNC = 0x0180,
-	NFAPI_DL_NODE_SYNC,
-	NFAPI_TIMING_INFO,
-
-
-	NFAPI_RSSI_REQUEST = 0x0200,
-	NFAPI_RSSI_RESPONSE,
-	NFAPI_RSSI_INDICATION,
-	NFAPI_CELL_SEARCH_REQUEST,
-	NFAPI_CELL_SEARCH_RESPONSE,
-	NFAPI_CELL_SEARCH_INDICATION,
-	NFAPI_BROADCAST_DETECT_REQUEST,
-	NFAPI_BROADCAST_DETECT_RESPONSE,
-	NFAPI_BROADCAST_DETECT_INDICATION,
-	NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST,
-	NFAPI_SYSTEM_INFORMATION_SCHEDULE_RESPONSE,
-	NFAPI_SYSTEM_INFORMATION_SCHEDULE_INDICATION,
-	NFAPI_SYSTEM_INFORMATION_REQUEST,
-	NFAPI_SYSTEM_INFORMATION_RESPONSE,
-	NFAPI_SYSTEM_INFORMATION_INDICATION,
-	NFAPI_NMM_STOP_REQUEST,
-	NFAPI_NMM_STOP_RESPONSE,
-
-	NFAPI_VENDOR_EXT_MSG_MIN = 0x0300,
-	NFAPI_VENDOR_EXT_MSG_MAX = 0x03FF,
-
-
-	NFAPI_MAX_MESSAGE_ID,
-} nfapi_message_id_e;
-
-// nFAPI Error Codes
-typedef enum {
-	NFAPI_MSG_OK = 0,
-	NFAPI_MSG_INVALID_STATE,
-	NFAPI_MSG_INVALID_CONFIG,
-	NFAPI_SFN_OUT_OF_SYNC,
-	NFAPI_MSG_SUBFRAME_ERR,
-	NFAPI_MSG_BCH_MISSING,
-	NFAPI_MSG_INVALID_SFN,
-	NFAPI_MSG_HI_ERR,
-	NFAPI_MSG_TX_ERR,
-	
-	NFAPI_LBT_NO_PDU_IN_DL_REQ,
-	NFAPI_LBT_NO_VALID_CONFIG_REQ_RECEIVED,
-	NFAPI_FAPI_E_LBT_SF_SFN_PASSED_END_SF_SFN,
-	NFAPI_FAPI_E_LBT_OVERLAP,
-	NFAPI_MSG_BCH_PRESENT,
-	
-	NFAPI_NBIOT_UNEXPECTED_REQ,
-
-	// This is special return code that indicates that a response has
-	// been send via P9
-	NFAPI_MSG_P9_RESPONSE = 0xAA
-} nfapi_error_code_e;
-
-
-typedef enum {
-	NFAPI_P4_MSG_OK = 100,
-	NFAPI_P4_MSG_INVALID_STATE = 101,
-	NFAPI_P4_MSG_INVALID_CONFIG = 102,
-	NFAPI_P4_MSG_RAT_NOT_SUPPORTED = 103,
-	NFAPI_P4_MSG_NMM_STOP_OK = 200,
-	NFAPI_P4_MSG_NMM_STOP_IGNOREDED = 201,
-	NFAPI_P4_MSG_NMM_STOP_INVALID_STATE = 202,
-	NFAPI_P4_MSG_PROCEDURE_COMPLETE = 300,
-	NFAPI_P4_MSG_PROCEDURE_STOPPED = 301,
-	NFAPI_P4_MSG_PARTIAL_RESULTS = 302,
-	NFAPI_P4_MSG_TIMEOUT = 303
-} nfapi_p4_error_code_e;
-
-// nFAPI enums
-typedef enum {
-	NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE = 0,
-	NFAPI_DL_CONFIG_BCH_PDU_TYPE,
-	NFAPI_DL_CONFIG_MCH_PDU_TYPE,
-	NFAPI_DL_CONFIG_DLSCH_PDU_TYPE,
-	NFAPI_DL_CONFIG_PCH_PDU_TYPE,
-	NFAPI_DL_CONFIG_PRS_PDU_TYPE,
-	NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE,
-	NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE,
-	NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE,
-	NFAPI_DL_CONFIG_NBCH_PDU_TYPE,
-	NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE,
-	NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE
-} nfapi_dl_config_pdu_type_e;
-
-typedef enum {
-	NFAPI_DL_DCI_FORMAT_1 = 0,
-	NFAPI_DL_DCI_FORMAT_1A,
-	NFAPI_DL_DCI_FORMAT_1B,
-	NFAPI_DL_DCI_FORMAT_1C,
-	NFAPI_DL_DCI_FORMAT_1D,
-	NFAPI_DL_DCI_FORMAT_2,
-	NFAPI_DL_DCI_FORMAT_2A,
-	NFAPI_DL_DCI_FORMAT_2B,
-	NFAPI_DL_DCI_FORMAT_2C
-} nfapi_dl_dci_format_e;
-
-typedef enum {
-	NFAPI_UL_DCI_FORMAT_0 = 0,
-	NFAPI_UL_DCI_FORMAT_3,
-	NFAPI_UL_DCI_FORMAT_3A,
-	NFAPI_UL_DCI_FORMAT_4
-} nfapi_ul_dci_format_e;
-
-typedef enum {
-	NFAPI_UL_CONFIG_ULSCH_PDU_TYPE = 0,
-	NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE,
-	NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE,
-	NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE,
-	NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE,
-	NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE,
-	NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE,
-	NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE,
-	NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE,
-	NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE,
-	NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE,
-	NFAPI_UL_CONFIG_SRS_PDU_TYPE,
-	NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE,
-	NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE,
-	NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE,
-	NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE,
-	NFAPI_UL_CONFIG_NULSCH_PDU_TYPE,
-	NFAPI_UL_CONFIG_NRACH_PDU_TYPE,
-} nfapi_ul_config_pdu_type_e;
-
-typedef enum {
-	NFAPI_HI_DCI0_HI_PDU_TYPE = 0,
-	NFAPI_HI_DCI0_DCI_PDU_TYPE,
-	NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE,
-	NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE,
-	NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE,
-} nfapi_hi_dci0_pdu_type_e;
-
-typedef enum {
-	NFAPI_HARQ_ACK = 1,
-	NFAPI_HARQ_NACK,
-	NFAPI_HARQ_ACK_OR_NACK,
-	NFAPI_HARQ_DTX,
-	NFAPI_HARQ_ACK_OR_DTX,
-	NFAPI_HARQ_NACK_OR_DTX,
-	NFAPI_HARQ_ACK_OR_NACK_OR_DTX
-} nfapi_harq_type_e;
-
-typedef enum {
-	NFAPI_CSI_REPORT_TYPE_PERIODIC = 0,
-	NFAPI_CSI_REPORT_TYPE_APERIODIC
-} nfapi_csi_report_type_e;
-
-typedef enum {
-	NFAPI_DL_BW_SUPPORTED_6 = 1,
-	NFAPI_DL_BW_SUPPORTED_15 = 2,
-	NFAPI_DL_BW_SUPPORTED_25 = 4,
-	NFAPI_DL_BW_SUPPORTED_50 = 8,
-	NFAPI_DL_BW_SUPPORTED_75 = 16,
-	NFAPI_DL_BW_SUPPORTED_100 = 32
-} nfapi_dl_bandwith_supported_e;
-
-typedef enum {
-	NFAPI_UL_BW_SUPPORTED_6 = 1,
-	NFAPI_UL_BW_SUPPORTED_15 = 2,
-	NFAPI_UL_BW_SUPPORTED_25 = 4,
-	NFAPI_UL_BW_SUPPORTED_50 = 8,
-	NFAPI_UL_BW_SUPPORTED_75 = 16,
-	NFAPI_UL_BW_SUPPORTED_100 = 32
-} nfapi_ul_bandwith_supported_e;
-
-typedef enum {
-	NFAPI_3GPP_REL_SUPPORTED_8 = 0,
-	NFAPI_3GPP_REL_SUPPORTED_9 = 1,
-	NFAPI_3GPP_REL_SUPPORTED_10 = 2,
-	NFAPI_3GPP_REL_SUPPORTED_11 = 4,
-	NFAPI_3GPP_REL_SUPPORTED_12 = 8,
-  NFAPI_3GPP_REL_SUPPORTED_15 = 64
-} nfapi_3gpp_release_supported_e;
-
-
-typedef enum {
-	NFAPI_DUPLEXING_MODE_TDD = 0,
-	NFAPI_DUPLEXING_MODE_FDD = 1,
-	NFAPI_DUPLEXING_MODE_HD_FDD = 2,
-} nfapi_duplexing_mode_e;
-
-typedef enum {
-	NFAPI_CP_NORMAL = 0,
-	NFAPI_CP_EXTENDED = 1
-} nfapi_cyclic_prefix_type_e;
-
-typedef enum {
-	NFAPI_RAT_TYPE_LTE = 0,
-	NFAPI_RAT_TYPE_UTRAN = 1,
-	NFAPI_RAT_TYPE_GERAN = 2,
-	NFAPI_RAT_TYPE_NB_IOT = 3,
-  NFAPI_RAT_TYPE_NR = 4
-} nfapi_rat_type_e;
-
-typedef enum {
-	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_BUNDLING,
-	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_MULIPLEXING,
-	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_SPECIAL_BUNDLING,
-	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_CHANNEL_SELECTION,
-	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_3,
-	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_4,
-	NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_5
-} nfapi_harq_indication_tdd_ack_nackformat_e;
-
-
-typedef enum {
-	NFAPI_LBT_DL_CONFIG_REQUEST_PDSCH_PDU_TYPE = 0,
-	NFAPI_LBT_DL_CONFIG_REQUEST_DRS_PDU_TYPE
-} nfapi_lbt_dl_config_pdu_type_e;
-
-typedef enum {
-	NFAPI_LBT_DL_RSP_PDSCH_PDU_TYPE = 0,
-	NFAPI_LBT_DL_RSP_DRS_PDU_TYPE
-} nfapi_lbt_dl_rsp_pdu_type_e;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint32_t length;
-	uint8_t value[NFAPI_MAX_OPAQUE_DATA];
-} nfapi_opaqaue_data_t;
-
-// Utility functions to turn enums into char*
-const char* nfapi_error_code_to_str(nfapi_error_code_e value);
-
-
-// P5 Sub Structures
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t nfapi_sync_mode;
-	uint8_t location_mode;
-	uint16_t location_coordinates_length;
-	uint8_t location_coordinates[NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH];
-	uint32_t dl_config_timing;
-	uint32_t tx_timing;
-	uint32_t ul_config_timing;
-	uint32_t hi_dci0_timing;
-	uint16_t maximum_number_phys;
-	uint16_t maximum_total_bandwidth;
-	uint8_t maximum_total_number_dl_layers;
-	uint8_t maximum_total_number_ul_layers;
-	uint8_t shared_bands;
-	uint8_t shared_pa;
-	int16_t maximum_total_power;
-	uint8_t oui[NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH];
-} nfapi_pnf_param_general_t;
-#define NFAPI_PNF_PARAM_GENERAL_TAG 0x1000
-
-
-
-
-
-typedef struct {
-	uint16_t rf_config_index;
-} nfapi_rf_config_info_t;
-
-typedef struct {
-	uint16_t phy_config_index;
-	uint16_t number_of_rfs;
-	nfapi_rf_config_info_t rf_config[NFAPI_MAX_PNF_PHY_RF_CONFIG];
-	uint16_t number_of_rf_exclusions;
-	nfapi_rf_config_info_t excluded_rf_config[NFAPI_MAX_PNF_PHY_RF_CONFIG];
-	uint16_t downlink_channel_bandwidth_supported;
-	uint16_t uplink_channel_bandwidth_supported;
-	uint8_t number_of_dl_layers_supported;
-	uint8_t number_of_ul_layers_supported;
-	uint16_t maximum_3gpp_release_supported;
-	uint8_t nmm_modes_supported;
-} nfapi_pnf_phy_info_t;
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_phys;
-	nfapi_pnf_phy_info_t phy[NFAPI_MAX_PNF_PHY];
-} nfapi_pnf_phy_t;
-#define NFAPI_PNF_PHY_TAG 0x1001
-
-typedef struct {
-	uint16_t phy_config_index;
-	uint16_t transmission_mode_7_supported;
-	uint16_t transmission_mode_8_supported;
-	uint16_t two_antenna_ports_for_pucch;
-	uint16_t transmission_mode_9_supported;
-	uint16_t simultaneous_pucch_pusch;
-	uint16_t four_layer_tx_with_tm3_and_tm4;
-} nfapi_pnf_phy_rel10_info_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_phys;
-	nfapi_pnf_phy_rel10_info_t phy[NFAPI_MAX_PNF_PHY];
-} nfapi_pnf_phy_rel10_t;
-#define NFAPI_PNF_PHY_REL10_TAG 0x100A
-
-typedef struct {
-	uint16_t phy_config_index;
-	uint16_t edpcch_supported;
-	uint16_t multi_ack_csi_reporting;
-	uint16_t pucch_tx_diversity;
-	uint16_t ul_comp_supported;
-	uint16_t transmission_mode_5_supported;
-} nfapi_pnf_phy_rel11_info_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_phys;
-	nfapi_pnf_phy_rel11_info_t phy[NFAPI_MAX_PNF_PHY];
-} nfapi_pnf_phy_rel11_t;
-#define NFAPI_PNF_PHY_REL11_TAG 0x100B
-
-
-typedef struct {
-	uint16_t phy_config_index;
-	uint16_t csi_subframe_set;
-	uint16_t enhanced_4tx_codebook;
-	uint16_t drs_supported;
-	uint16_t ul_64qam_supported;
-	uint16_t transmission_mode_10_supported;
-	uint16_t alternative_bts_indices;
-} nfapi_pnf_phy_rel12_info_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_phys;
-	nfapi_pnf_phy_rel12_info_t phy[NFAPI_MAX_PNF_PHY];
-} nfapi_pnf_phy_rel12_t;
-#define NFAPI_PNF_PHY_REL12_TAG 0x100C
-
-typedef struct {
-	uint16_t phy_config_index;
-	uint16_t pucch_format4_supported;
-	uint16_t pucch_format5_supported;
-	uint16_t more_than_5_ca_support;
-	uint16_t laa_supported;
-	uint16_t laa_ending_in_dwpts_supported;
-	uint16_t laa_starting_in_second_slot_supported;
-	uint16_t beamforming_supported;
-	uint16_t csi_rs_enhancement_supported;
-	uint16_t drms_enhancement_supported;
-	uint16_t srs_enhancement_supported;
-} nfapi_pnf_phy_rel13_info_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_phys;
-	nfapi_pnf_phy_rel13_info_t phy[NFAPI_MAX_PNF_PHY];
-} nfapi_pnf_phy_rel13_t;
-#define NFAPI_PNF_PHY_REL13_TAG 0x100D
-
-typedef struct {
-	uint16_t phy_config_index;
-	uint16_t number_of_rfs;
-	nfapi_rf_config_info_t rf_config[NFAPI_MAX_PNF_PHY_RF_CONFIG];
-	uint16_t number_of_rf_exclusions;
-	nfapi_rf_config_info_t excluded_rf_config[NFAPI_MAX_PNF_PHY_RF_CONFIG];
-	uint8_t number_of_dl_layers_supported;
-	uint8_t number_of_ul_layers_supported;
-	uint16_t maximum_3gpp_release_supported;
-	uint8_t nmm_modes_supported;
-} nfapi_pnf_phy_rel13_nb_iot_info_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_phys;
-	nfapi_pnf_phy_rel13_nb_iot_info_t phy[NFAPI_MAX_PNF_PHY];
-} nfapi_pnf_phy_rel13_nb_iot_t;
-#define NFAPI_PNF_PHY_REL13_NB_IOT_TAG 0x100E
-
-typedef struct {
-  uint16_t phy_config_index;
-} nfapi_pnf_phy_rel15_info_t;
-
-typedef struct {
-  nfapi_tl_t tl;
-  uint16_t number_of_phys;
-  nfapi_pnf_phy_rel15_info_t phy[NFAPI_MAX_PNF_PHY];
-} nfapi_pnf_phy_rel15_t;
-#define NFAPI_PNF_PHY_REL15_TAG 0x100H
-
-
-typedef struct {
-	uint16_t rf_config_index;
-	uint16_t band;
-	int16_t maximum_transmit_power; 
-	int16_t minimum_transmit_power;
-	uint8_t number_of_antennas_suppported;
-	uint32_t minimum_downlink_frequency;
-	uint32_t maximum_downlink_frequency;
-	uint32_t minimum_uplink_frequency;
-	uint32_t maximum_uplink_frequency;
-} nfapi_pnf_rf_info_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_rfs;
-	nfapi_pnf_rf_info_t rf[NFAPI_MAX_PNF_RF];
-} nfapi_pnf_rf_t;
-#define NFAPI_PNF_RF_TAG 0x1002
-
-typedef struct {
-	uint16_t phy_id;
-	uint16_t phy_config_index;
-	uint16_t rf_config_index;
-} nfapi_phy_rf_config_info_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_phy_rf_config_info;
-	nfapi_phy_rf_config_info_t phy_rf_config[NFAPI_MAX_PHY_RF_INSTANCES];
-} nfapi_pnf_phy_rf_config_t;
-#define NFAPI_PNF_PHY_RF_TAG 0x1003
-
-// Generic strucutre for single tlv value.
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t value;
-} nfapi_uint16_tlv_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	int16_t value;
-} nfapi_int16_tlv_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t value;
-} nfapi_uint8_tlv_t;
-
-typedef struct {
-	nfapi_uint16_tlv_t phy_state;
-} nfapi_l1_status;
-
-#define NFAPI_L1_STATUS_PHY_STATE_TAG 0x00FA
-
-typedef struct {
-	nfapi_uint16_tlv_t dl_bandwidth_support;
-	nfapi_uint16_tlv_t ul_bandwidth_support;
-	nfapi_uint16_tlv_t dl_modulation_support;
-	nfapi_uint16_tlv_t ul_modulation_support;
-	nfapi_uint16_tlv_t phy_antenna_capability;
-	nfapi_uint16_tlv_t release_capability;
-	nfapi_uint16_tlv_t mbsfn_capability;
-} nfapi_phy_capabilities_t;
-
-#define NFAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG 0x00C8
-#define NFAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG 0x00C9
-#define NFAPI_PHY_CAPABILITIES_DL_MODULATION_SUPPORT_TAG 0x00CA
-#define NFAPI_PHY_CAPABILITIES_UL_MODULATION_SUPPORT_TAG 0x00CB
-#define NFAPI_PHY_CAPABILITIES_PHY_ANTENNA_CAPABILITY_TAG 0x00CC
-#define NFAPI_PHY_CAPABILITIES_RELEASE_CAPABILITY_TAG 0x00CD
-#define NFAPI_PHY_CAPABILITIES_MBSFN_CAPABILITY_TAG 0x00CE
-
-
-typedef struct {
-	nfapi_uint16_tlv_t data_report_mode;
-	nfapi_uint16_tlv_t sfnsf;
-} nfapi_l23_config_t;
-
-
-#define NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG 0x00F0
-#define NFAPI_L23_CONFIG_SFNSF_TAG 0x00F1
-
-typedef struct {
-  nfapi_uint16_tlv_t numerology_index_mu;
-	nfapi_uint16_tlv_t duplex_mode;
-	nfapi_uint16_tlv_t pcfich_power_offset;
-	nfapi_uint16_tlv_t pb;
-	nfapi_uint16_tlv_t dl_cyclic_prefix_type;
-	nfapi_uint16_tlv_t ul_cyclic_prefix_type;
-} nfapi_subframe_config_t;
-
-#define NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG 0x0001
-#define NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG 0x0002
-#define NFAPI_SUBFRAME_CONFIG_PB_TAG 0x0003
-#define NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG 0x0004
-#define NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG 0x0005
-#define NFAPI_SUBFRAME_CONFIG_NUMEROLOGY_INDEX_MU_TAG 0x0006
-
-typedef struct {
-	nfapi_uint16_tlv_t dl_channel_bandwidth;
-	nfapi_uint16_tlv_t ul_channel_bandwidth;
-	nfapi_uint16_tlv_t reference_signal_power;
-	nfapi_uint16_tlv_t tx_antenna_ports;
-	nfapi_uint16_tlv_t rx_antenna_ports;
-} nfapi_rf_config_t;
-
-#define NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG 0x000A
-#define NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG 0x000B
-#define NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG 0x000C
-#define NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG 0x000D
-#define NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG 0x000E
-
-typedef struct {
-	nfapi_uint16_tlv_t phich_resource;
-	nfapi_uint16_tlv_t phich_duration;
-	nfapi_uint16_tlv_t phich_power_offset;
-} nfapi_phich_config_t;
-
-#define NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG 0x0014
-#define NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG 0x0015
-#define NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG 0x0016
-
-typedef enum {
-  NFAPI_HALF_FRAME_INDEX_FIRST_HALF = 0,
-  NFAPI_HALF_FRAME_INDEX_SECOND_HALF = 1
-} nfapi_half_frame_index_e;
-
-typedef struct {
-	nfapi_uint16_tlv_t primary_synchronization_signal_epre_eprers;
-	nfapi_uint16_tlv_t secondary_synchronization_signal_epre_eprers;
-	nfapi_uint16_tlv_t physical_cell_id;
-  nfapi_half_frame_index_e half_frame_index;
-  nfapi_uint16_tlv_t ssb_subcarrier_offset;
-  nfapi_uint16_tlv_t ssb_position_in_burst;
-  nfapi_uint16_tlv_t ssb_periodicity;
-  nfapi_uint16_tlv_t ss_pbch_block_power;
-} nfapi_sch_config_t;
-
-#define NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG 0x001E
-#define NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG 0x001F
-#define NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG 0x0020
-#define NFAPI_SCH_CONFIG_HALF_FRAME_INDEX_TAG 0x0021
-#define NFAPI_SCH_CONFIG_SSB_SUBCARRIER_OFFSET_TAG 0x0022
-#define NFAPI_SCH_CONFIG_SSB_POSITION_IN_BURST 0x0023
-#define NFAPI_SCH_CONFIG_SSB_PERIODICITY 0x0024
-#define NFAPI_SCH_CONFIG_SS_PBCH_BLOCK_POWER 0x0025
-
-typedef struct {
-	nfapi_uint16_tlv_t configuration_index;
-	nfapi_uint16_tlv_t root_sequence_index;
-	nfapi_uint16_tlv_t zero_correlation_zone_configuration;
-	nfapi_uint16_tlv_t high_speed_flag;
-	nfapi_uint16_tlv_t frequency_offset;
-} nfapi_prach_config_t;
-
-#define NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG 0x0028
-#define NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG 0x0029
-#define NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG 0x002A
-#define NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG 0x002B
-#define NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG 0x002C
-
-typedef struct {
-	nfapi_uint16_tlv_t hopping_mode;
-	nfapi_uint16_tlv_t hopping_offset;
-	nfapi_uint16_tlv_t number_of_subbands;
-} nfapi_pusch_config_t;
-
-#define NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG 0x0032
-#define NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG 0x0033
-#define NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG 0x0034
-
-typedef struct {
-	nfapi_uint16_tlv_t delta_pucch_shift;
-	nfapi_uint16_tlv_t n_cqi_rb;
-	nfapi_uint16_tlv_t n_an_cs;
-	nfapi_uint16_tlv_t n1_pucch_an;
-} nfapi_pucch_config_t;
-
-#define NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG 0x003C
-#define NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG 0x003D
-#define NFAPI_PUCCH_CONFIG_N_AN_CS_TAG 0x003E
-#define NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG 0x003F
-
-typedef struct {
-	nfapi_uint16_tlv_t bandwidth_configuration;
-	nfapi_uint16_tlv_t max_up_pts;
-	nfapi_uint16_tlv_t srs_subframe_configuration;
-	nfapi_uint16_tlv_t srs_acknack_srs_simultaneous_transmission;
-} nfapi_srs_config_t;
-
-#define NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG 0x0046
-#define NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG 0x0047
-#define NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG 0x0048
-#define NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG 0x0049
-
-typedef struct {
-	nfapi_uint16_tlv_t uplink_rs_hopping;
-	nfapi_uint16_tlv_t group_assignment;
-	nfapi_uint16_tlv_t cyclic_shift_1_for_drms;
-} nfapi_uplink_reference_signal_config_t;
-
-#define NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG 0x0050
-#define NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG 0x0051
-#define NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG 0x0052
-
-
-typedef struct {
-	nfapi_uint16_tlv_t ed_threshold_lbt_pdsch;
-	nfapi_uint16_tlv_t ed_threshold_lbt_drs;
-	nfapi_uint16_tlv_t pd_threshold;
-	nfapi_uint16_tlv_t multi_carrier_type;
-	nfapi_uint16_tlv_t multi_carrier_tx;
-	nfapi_uint16_tlv_t multi_carrier_freeze;
-	nfapi_uint16_tlv_t tx_antenna_ports_drs;
-	nfapi_uint16_tlv_t tx_power_drs;
-} nfapi_laa_config_t;
-
-#define NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_PDSCH_TAG 0x0064
-#define NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_DRS_TAG 0x0065
-#define NFAPI_LAA_CONFIG_PD_THRESHOLD_TAG 0x0066
-#define NFAPI_LAA_CONFIG_MULTI_CARRIER_TYPE_TAG 0x0067
-#define NFAPI_LAA_CONFIG_MULTI_CARRIER_TX_TAG 0x0068
-#define NFAPI_LAA_CONFIG_MULTI_CARRIER_FREEZE_TAG 0x0069
-#define NFAPI_LAA_CONFIG_TX_ANTENNA_PORTS_FOR_DRS_TAG 0x006A
-#define NFAPI_LAA_CONFIG_TRANSMISSION_POWER_FOR_DRS_TAG 0x006B
-
-typedef struct {
-
-	nfapi_uint16_tlv_t pbch_repetitions_enable_r13;
-	nfapi_uint16_tlv_t prach_catm_root_sequence_index;
-	nfapi_uint16_tlv_t prach_catm_zero_correlation_zone_configuration;
-	nfapi_uint16_tlv_t prach_catm_high_speed_flag;
-	nfapi_uint16_tlv_t prach_ce_level_0_enable;
-	nfapi_uint16_tlv_t prach_ce_level_0_configuration_index;
-	nfapi_uint16_tlv_t prach_ce_level_0_frequency_offset;
-	nfapi_uint16_tlv_t prach_ce_level_0_number_of_repetitions_per_attempt;
-	nfapi_uint16_tlv_t prach_ce_level_0_starting_subframe_periodicity;
-	nfapi_uint16_tlv_t prach_ce_level_0_hopping_enable;
-	nfapi_uint16_tlv_t prach_ce_level_0_hopping_offset;
-	nfapi_uint16_tlv_t prach_ce_level_1_enable;
-	nfapi_uint16_tlv_t prach_ce_level_1_configuration_index;
-	nfapi_uint16_tlv_t prach_ce_level_1_frequency_offset;
-	nfapi_uint16_tlv_t prach_ce_level_1_number_of_repetitions_per_attempt;
-	nfapi_uint16_tlv_t prach_ce_level_1_starting_subframe_periodicity;
-	nfapi_uint16_tlv_t prach_ce_level_1_hopping_enable;
-	nfapi_uint16_tlv_t prach_ce_level_1_hopping_offset;
-	nfapi_uint16_tlv_t prach_ce_level_2_enable;
-	nfapi_uint16_tlv_t prach_ce_level_2_configuration_index;
-	nfapi_uint16_tlv_t prach_ce_level_2_frequency_offset;
-	nfapi_uint16_tlv_t prach_ce_level_2_number_of_repetitions_per_attempt;
-	nfapi_uint16_tlv_t prach_ce_level_2_starting_subframe_periodicity;
-	nfapi_uint16_tlv_t prach_ce_level_2_hopping_enable;
-	nfapi_uint16_tlv_t prach_ce_level_2_hopping_offset;
-	nfapi_uint16_tlv_t prach_ce_level_3_enable;
-	nfapi_uint16_tlv_t prach_ce_level_3_configuration_index;
-	nfapi_uint16_tlv_t prach_ce_level_3_frequency_offset;
-	nfapi_uint16_tlv_t prach_ce_level_3_number_of_repetitions_per_attempt;
-	nfapi_uint16_tlv_t prach_ce_level_3_starting_subframe_periodicity;
-	nfapi_uint16_tlv_t prach_ce_level_3_hopping_enable;
-	nfapi_uint16_tlv_t prach_ce_level_3_hopping_offset;
-	nfapi_uint16_tlv_t pucch_interval_ulhoppingconfigcommonmodea;
-	nfapi_uint16_tlv_t pucch_interval_ulhoppingconfigcommonmodeb;
-} nfapi_emtc_config_t;
-
-#define NFAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLE_R13_TAG 0x0078
-#define NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG 0x0079
-#define NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG 0x007A
-#define NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG 0x007B
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG 0x007C
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG 0x007D
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG 0x007E
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x007F
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG 0x0080
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG 0x0081
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG 0x0082
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG 0x0083
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG 0x0084
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG 0x0085
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x0086
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG 0x0087
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG 0x0088
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG 0x0089
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG 0x008A
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG 0x008B
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG 0x008C
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x008D
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG 0x008E
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG 0x008F
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG 0x0090
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG 0x0091
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG 0x0092
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG 0x0093
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x0094
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG 0x0095
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG 0x0096
-#define NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG 0x0097
-#define NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG 0x0098
-#define NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG 0x0099
-
-typedef struct {
-	nfapi_uint16_tlv_t operating_mode;
-	nfapi_uint16_tlv_t anchor;
-	nfapi_uint16_tlv_t prb_index;
-	nfapi_uint16_tlv_t control_region_size;
-	nfapi_uint16_tlv_t assumed_crs_aps;
-	nfapi_uint16_tlv_t nprach_config_0_enabled;
-	nfapi_uint16_tlv_t nprach_config_0_sf_periodicity;
-	nfapi_uint16_tlv_t nprach_config_0_start_time;
-	nfapi_uint16_tlv_t nprach_config_0_subcarrier_offset;
-	nfapi_uint16_tlv_t nprach_config_0_number_of_subcarriers;
-	nfapi_uint16_tlv_t nprach_config_0_cp_length;
-	nfapi_uint16_tlv_t nprach_config_0_number_of_repetitions_per_attempt;
-	nfapi_uint16_tlv_t nprach_config_1_enabled;
-	nfapi_uint16_tlv_t nprach_config_1_sf_periodicity;
-	nfapi_uint16_tlv_t nprach_config_1_start_time;
-	nfapi_uint16_tlv_t nprach_config_1_subcarrier_offset;
-	nfapi_uint16_tlv_t nprach_config_1_number_of_subcarriers;
-	nfapi_uint16_tlv_t nprach_config_1_cp_length;
-	nfapi_uint16_tlv_t nprach_config_1_number_of_repetitions_per_attempt;
-	nfapi_uint16_tlv_t nprach_config_2_enabled;
-	nfapi_uint16_tlv_t nprach_config_2_sf_periodicity;
-	nfapi_uint16_tlv_t nprach_config_2_start_time;
-	nfapi_uint16_tlv_t nprach_config_2_subcarrier_offset;
-	nfapi_uint16_tlv_t nprach_config_2_number_of_subcarriers;
-	nfapi_uint16_tlv_t nprach_config_2_cp_length;
-	nfapi_uint16_tlv_t nprach_config_2_number_of_repetitions_per_attempt;
-	nfapi_uint16_tlv_t three_tone_base_sequence;
-	nfapi_uint16_tlv_t six_tone_base_sequence;
-	nfapi_uint16_tlv_t twelve_tone_base_sequence;
-	nfapi_uint16_tlv_t three_tone_cyclic_shift;
-	nfapi_uint16_tlv_t six_tone_cyclic_shift;
-	nfapi_uint16_tlv_t dl_gap_config_enable;
-	nfapi_uint16_tlv_t dl_gap_threshold;
-	nfapi_uint16_tlv_t dl_gap_periodicity;
-	nfapi_uint16_tlv_t dl_gap_duration_coefficient;
-} nfapi_nb_iot_config_t;
-
-#define NFAPI_NB_IOT_CONFIG_OPERATING_MODE_TAG 0x00A5
-#define NFAPI_NB_IOT_CONFIG_ANCHOR_TAG 0x00A6
-#define NFAPI_NB_IOT_CONFIG_PRB_INDEX_TAG 0x00A7
-#define NFAPI_NB_IOT_CONFIG_CONTROL_REGION_SIZE_TAG 0x00A8
-#define NFAPI_NB_IOT_CONFIG_ASSUMED_CRS_APS_TAG 0x00A9
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_ENABLED_TAG 0x00AA
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_SF_PERIODICITY_TAG 0x00AB
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_START_TIME_TAG 0x00AC
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_SUBCARRIER_OFFSET_TAG 0x00AD
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_NUMBER_OF_SUBCARRIERS_TAG 0x00AE
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_CP_LENGTH_TAG 0x00AF
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x00B0
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_ENABLED_TAG 0x00B1
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_SF_PERIODICITY_TAG 0x00B2
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_START_TIME_TAG 0x00B3
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_SUBCARRIER_OFFSET_TAG 0x00B4
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_NUMBER_OF_SUBCARRIERS_TAG 0x00B5
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_CP_LENGTH_TAG 0x00B6
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x00B7
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_ENABLED_TAG 0x00B8
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_SF_PERIODICITY_TAG 0x00B9
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_START_TIME_TAG 0x00BA
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_SUBCARRIER_OFFSET_TAG 0x00BB
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_NUMBER_OF_SUBCARRIERS_TAG 0x00BC
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_CP_LENGTH_TAG 0x00BD
-#define NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x00BE
-#define NFAPI_NB_IOT_CONFIG_THREE_TONE_BASE_SEQUENCE_TAG 0x00BF
-#define NFAPI_NB_IOT_CONFIG_SIX_TONE_BASE_SEQUENCE_TAG 0x00C0
-#define NFAPI_NB_IOT_CONFIG_TWELVE_TONE_BASE_SEQUENCE_TAG 0x00C1
-#define NFAPI_NB_IOT_CONFIG_THREE_TONE_CYCLIC_SHIFT_TAG 0x00C2
-#define NFAPI_NB_IOT_CONFIG_SIX_TONE_CYCLIC_SHIFT_TAG 0x00C3
-#define NFAPI_NB_IOT_CONFIG_DL_GAP_CONFIG_ENABLE_TAG 0x00C4
-#define NFAPI_NB_IOT_CONFIG_DL_GAP_THRESHOLD_TAG 0x00C5
-#define NFAPI_NB_IOT_CONFIG_DL_GAP_PERIODICITY_TAG 0x00C6
-#define NFAPI_NB_IOT_CONFIG_DL_GAP_DURATION_COEFFICIENT_TAG 0x00C7
-
-typedef struct {
-	nfapi_uint16_tlv_t laa_support;
-	nfapi_uint16_tlv_t pd_sensing_lbt_support;
-	nfapi_uint16_tlv_t multi_carrier_lbt_support;
-	nfapi_uint16_tlv_t partial_sf_support;
-} nfapi_laa_capability_t;
-
-#define NFAPI_LAA_CAPABILITY_LAA_SUPPORT_TAG 0x00D1
-#define NFAPI_LAA_CAPABILITY_PD_SENSING_LBT_SUPPORT_TAG 0x00D2
-#define NFAPI_LAA_CAPABILITY_MULTI_CARRIER_LBT_SUPPORT_TAG 0x00D3
-#define NFAPI_LAA_CAPABILITY_PARTIAL_SF_SUPPORT_TAG 0x00D4
-
-typedef struct {
-	nfapi_uint16_tlv_t nb_iot_support;
-	nfapi_uint16_tlv_t nb_iot_operating_mode_capability;
-} nfapi_nb_iot_capability_t;
-
-#define NFAPI_LAA_CAPABILITY_NB_IOT_SUPPORT_TAG 0x00D5
-#define NFAPI_LAA_CAPABILITY_NB_IOT_OPERATING_MODE_CAPABILITY_TAG 0x00D6
-
-typedef struct {
-	nfapi_uint16_tlv_t subframe_assignment;
-	nfapi_uint16_tlv_t special_subframe_patterns;
-} nfapi_tdd_frame_structure_t;
-
-#define NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG 0x005A
-#define NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG 0x005B
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_rf_bands;
-	uint16_t rf_band[NFAPI_MAX_NUM_RF_BANDS];
-} nfapi_rf_bands_t;
-#define NFAPI_PHY_RF_BANDS_TAG 0x0114
-
-#define NFAPI_IPV4_ADDRESS_LENGTH 4
-#define NFAPI_IPV6_ADDRESS_LENGTH 16
-
-// Convience enum to allow the ip addres type to be distinguished
-typedef enum {
-	NFAPI_IP_ADDRESS_IPV4 = 0,
-	NFAPI_IP_ADDRESS_IPV6
-} nfapi_ip_address_type_e;
-
-// The type could be infered from the length, but it is clearer in 
-// code to have a type variable set
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t type;
-	union {
-		uint8_t ipv4_address[NFAPI_IPV4_ADDRESS_LENGTH];
-		uint8_t ipv6_address[NFAPI_IPV6_ADDRESS_LENGTH];
-	} u;
-} nfapi_ip_address_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t address[NFAPI_IPV4_ADDRESS_LENGTH];
-} nfapi_ipv4_address_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t address[NFAPI_IPV6_ADDRESS_LENGTH];
-} nfapi_ipv6_address_t;
-
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_rf_bands;
-	uint16_t bands[NFAPI_MAX_NMM_FREQUENCY_BANDS];
-} nfapi_nmm_frequency_bands_t;
-
-//These TLVs are used exclusively by nFAPI
-typedef struct
-{
-	// These TLVs are used to setup the transport connection between VNF and PNF
-	nfapi_ipv4_address_t p7_vnf_address_ipv4;
-	nfapi_ipv6_address_t p7_vnf_address_ipv6;
-	nfapi_uint16_tlv_t p7_vnf_port;
-
-	nfapi_ipv4_address_t p7_pnf_address_ipv4;
-	nfapi_ipv6_address_t p7_pnf_address_ipv6;
-	nfapi_uint16_tlv_t p7_pnf_port;
-	
-	// These TLVs are used to setup the transport connection between VNF and PNF
-	nfapi_uint8_tlv_t dl_ue_per_sf;
-	nfapi_uint8_tlv_t ul_ue_per_sf;
-
-	// These TLVs are used by PNF to report its RF capabilities to the VNF software
-	nfapi_rf_bands_t rf_bands;
-
-	// These TLVs are used by the VNF to configure the synchronization with the PNF.
-	nfapi_uint8_tlv_t timing_window;
-	nfapi_uint8_tlv_t timing_info_mode;
-	nfapi_uint8_tlv_t timing_info_period;
-
-	// These TLVs are used by the VNF to configure the RF in the PNF
-	nfapi_uint16_tlv_t max_transmit_power;
-	nfapi_uint16_tlv_t earfcn;
-
-	nfapi_nmm_frequency_bands_t nmm_gsm_frequency_bands;
-	nfapi_nmm_frequency_bands_t nmm_umts_frequency_bands;
-	nfapi_nmm_frequency_bands_t nmm_lte_frequency_bands;
-	nfapi_uint8_tlv_t nmm_uplink_rssi_supported;
-
-} nfapi_nfapi_t;
-
-#define NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG 0x0100
-#define NFAPI_NFAPI_P7_VNF_ADDRESS_IPV6_TAG 0x0101
-#define NFAPI_NFAPI_P7_VNF_PORT_TAG 0x0102
-#define NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG 0x0103
-#define NFAPI_NFAPI_P7_PNF_ADDRESS_IPV6_TAG 0x0104
-#define NFAPI_NFAPI_P7_PNF_PORT_TAG 0x0105
-
-#define NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG 0x010A
-#define NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG 0x010B
-#define NFAPI_NFAPI_RF_BANDS_TAG 0x0114
-#define NFAPI_NFAPI_TIMING_WINDOW_TAG 0x011E
-#define NFAPI_NFAPI_TIMING_INFO_MODE_TAG 0x011F
-#define NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG 0x0120
-#define NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG 0x0128
-#define NFAPI_NFAPI_EARFCN_TAG 0x0129
-#define NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG 0x0130
-#define NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG 0x0131
-#define NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG 0x0132
-#define NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG 0x0133
-
-
-// P5 Message Structures
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_pnf_param_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_pnf_param_general_t pnf_param_general;
-	nfapi_pnf_phy_t pnf_phy;
-	nfapi_pnf_rf_t pnf_rf;
-	nfapi_pnf_phy_rel10_t pnf_phy_rel10;
-	nfapi_pnf_phy_rel11_t pnf_phy_rel11;
-	nfapi_pnf_phy_rel12_t pnf_phy_rel12;
-	nfapi_pnf_phy_rel13_t pnf_phy_rel13;
-	nfapi_pnf_phy_rel13_nb_iot_t pnf_phy_rel13_nb_iot;
-  nfapi_pnf_phy_rel15_t pnf_phy_rel15;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_pnf_param_response_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	nfapi_pnf_phy_rf_config_t pnf_phy_rf_config;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_pnf_config_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_pnf_config_response_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_pnf_start_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_pnf_start_response_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_pnf_stop_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_pnf_stop_response_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_param_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint8_t error_code;
-	uint8_t num_tlv;
-	// fdd or tdd in idle or configured tlvs
-	nfapi_l1_status l1_status;
-	nfapi_phy_capabilities_t phy_capabilities;
-	nfapi_laa_capability_t laa_capability;
-	nfapi_nb_iot_capability_t nb_iot_capability;
-	
-	nfapi_subframe_config_t subframe_config;
-	nfapi_rf_config_t rf_config;
-	nfapi_phich_config_t phich_config;
-	nfapi_sch_config_t sch_config;
-	nfapi_prach_config_t prach_config;
-	nfapi_pusch_config_t pusch_config;
-	nfapi_pucch_config_t pucch_config;
-	nfapi_srs_config_t srs_config;
-	nfapi_uplink_reference_signal_config_t uplink_reference_signal_config;
-	nfapi_tdd_frame_structure_t tdd_frame_structure_config;
-	nfapi_l23_config_t l23_config;
-	nfapi_nb_iot_config_t nb_iot_config;
-
-	// addition nfapi tlvs as per table 2-16 in idle or configure
-	nfapi_nfapi_t nfapi_config;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_param_response_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint8_t num_tlv;
-	nfapi_subframe_config_t subframe_config;
-	nfapi_rf_config_t rf_config;
-	nfapi_phich_config_t phich_config;
-	nfapi_sch_config_t sch_config;
-	nfapi_prach_config_t prach_config;
-	nfapi_pusch_config_t pusch_config;
-	nfapi_pucch_config_t pucch_config;
-	nfapi_srs_config_t srs_config;
-	nfapi_uplink_reference_signal_config_t uplink_reference_signal_config;
-	nfapi_laa_config_t laa_config;
-	nfapi_emtc_config_t emtc_config;
-	nfapi_tdd_frame_structure_t tdd_frame_structure_config;
-	nfapi_l23_config_t l23_config;
-	nfapi_nb_iot_config_t nb_iot_config;
-	
-	// addition nfapi tlvs as per table 2-16 in idle or configure
-	nfapi_nfapi_t nfapi_config;
-
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_config_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_config_response_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_start_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_start_response_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_stop_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_stop_response_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	nfapi_uint16_tlv_t dl_rs_tx_power;
-	nfapi_uint16_tlv_t received_interference_power;
-	nfapi_uint16_tlv_t thermal_noise_power;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_measurement_request_t;
-
-#define NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG 0x1004
-#define NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG 0x1005
-#define NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG 0x1006
-
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_resource_blocks;
-	int16_t received_interference_power[NFAPI_MAX_RECEIVED_INTERFERENCE_POWER_RESULTS];
-} nfapi_received_interference_power_measurement_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_int16_tlv_t dl_rs_tx_power_measurement;
-	nfapi_received_interference_power_measurement_t received_interference_power_measurement;
-	nfapi_int16_tlv_t thermal_noise_power_measurement;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_measurement_response_t;
-
-#define NFAPI_MEASUREMENT_RESPONSE_DL_RS_POWER_MEASUREMENT_TAG 0x1007
-#define NFAPI_MEASUREMENT_RESPONSE_RECEIVED_INTERFERENCE_POWER_MEASUREMENT_TAG 0x1008
-#define NFAPI_MEASUREMENT_RESPONSE_THERMAL_NOISE_MEASUREMENT_TAG 0x1009
-
-// P7 Sub Structures
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t dci_format;
-	uint8_t cce_idx;
-	uint8_t aggregation_level;
-	uint16_t rnti;
-	uint8_t resource_allocation_type;
-	uint8_t virtual_resource_block_assignment_flag;
-	uint32_t resource_block_coding;
-	uint8_t mcs_1;
-	uint8_t redundancy_version_1;
-	uint8_t new_data_indicator_1;
-	uint8_t transport_block_to_codeword_swap_flag;
-	uint8_t mcs_2;
-	uint8_t redundancy_version_2;
-	uint8_t new_data_indicator_2;
-	uint8_t harq_process;
-	uint8_t tpmi;
-	uint8_t pmi;
-	uint8_t precoding_information;
-	uint8_t tpc;
-	uint8_t downlink_assignment_index;
-	uint8_t ngap;
-	uint8_t transport_block_size_index;
-	uint8_t downlink_power_offset;
-	uint8_t allocate_prach_flag;
-	uint8_t preamble_index;
-	uint8_t prach_mask_index;
-	uint8_t rnti_type;
-	uint16_t transmission_power;
-} nfapi_dl_config_dci_dl_pdu_rel8_t;
-#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG 0x2001
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t mcch_flag;
-	uint8_t mcch_change_notification;
-	uint8_t scrambling_identity;
-} nfapi_dl_config_dci_dl_pdu_rel9_t;
-#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL9_TAG 0x2002
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t cross_carrier_scheduling_flag;
-	uint8_t carrier_indicator;
-	uint8_t srs_flag;
-	uint8_t srs_request;
-	uint8_t antenna_ports_scrambling_and_layers;
-	uint8_t total_dci_length_including_padding;
-	uint8_t n_dl_rb;
-} nfapi_dl_config_dci_dl_pdu_rel10_t;
-#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL10_TAG 0x2003
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t harq_ack_resource_offset;
-	uint8_t pdsch_re_mapping_quasi_co_location_indicator;
-} nfapi_dl_config_dci_dl_pdu_rel11_t;
-
-#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL11_TAG 0x2039
-
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t primary_cell_type;
-	uint8_t ul_dl_configuration_flag;
-	uint8_t number_ul_dl_configurations;
-	uint8_t ul_dl_configuration_indication[NFAPI_MAX_UL_DL_CONFIGURATIONS];
-} nfapi_dl_config_dci_dl_pdu_rel12_t;
-
-#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL12_TAG 0x203a
-
-
-
-typedef struct {
-	uint8_t subband_index;
-	uint8_t scheduled_ues;
-	uint16_t precoding_value[NFAPI_MAX_NUM_PHYSICAL_ANTENNAS][NFAPI_MAX_NUM_SCHEDULED_UES];
-} nfapi_dl_config_dci_dl_tpm_subband_info_t;
-
-typedef struct {
-	uint8_t num_prb_per_subband;
-	uint8_t number_of_subbands;
-	uint8_t num_antennas;
-	nfapi_dl_config_dci_dl_tpm_subband_info_t subband_info[NFAPI_MAX_NUM_SUBBANDS];
-} nfapi_dl_config_dci_dl_tpm_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t laa_end_partial_sf_flag;
-	uint8_t laa_end_partial_sf_configuration;
-	uint8_t initial_lbt_sf;
-	uint8_t codebook_size_determination;
-	uint8_t drms_table_flag;
-	uint8_t tpm_struct_flag;
-	nfapi_dl_config_dci_dl_tpm_t tpm;
-} nfapi_dl_config_dci_dl_pdu_rel13_t;
-
-#define NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL13_TAG 0x203b
-
-typedef struct {
-	nfapi_dl_config_dci_dl_pdu_rel8_t dci_dl_pdu_rel8;
-	nfapi_dl_config_dci_dl_pdu_rel9_t dci_dl_pdu_rel9;
-	nfapi_dl_config_dci_dl_pdu_rel10_t dci_dl_pdu_rel10;
-	nfapi_dl_config_dci_dl_pdu_rel11_t dci_dl_pdu_rel11;
-	nfapi_dl_config_dci_dl_pdu_rel12_t dci_dl_pdu_rel12;
-	nfapi_dl_config_dci_dl_pdu_rel13_t dci_dl_pdu_rel13;
-} nfapi_dl_config_dci_dl_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint16_t transmission_power;
-} nfapi_dl_config_bch_pdu_rel8_t;
-#define NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG 0x2004
-
-typedef struct {
-	nfapi_dl_config_bch_pdu_rel8_t bch_pdu_rel8;
-} nfapi_dl_config_bch_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint16_t rnti;
-	uint8_t resource_allocation_type;
-	uint32_t resource_block_coding;
-	uint8_t modulation;
-	uint16_t transmission_power;
-	uint16_t mbsfn_area_id;
-} nfapi_dl_config_mch_pdu_rel8_t;
-#define NFAPI_DL_CONFIG_REQUEST_MCH_PDU_REL8_TAG 0x2005
-
-typedef struct {
-	nfapi_dl_config_mch_pdu_rel8_t mch_pdu_rel8;
-} nfapi_dl_config_mch_pdu;
-
-
-typedef struct {
-	uint8_t subband_index;
-	uint8_t num_antennas;
-	uint16_t bf_value[NFAPI_MAX_NUM_ANTENNAS];
-} nfapi_bf_vector_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint16_t rnti;
-	uint8_t resource_allocation_type;
-	uint8_t virtual_resource_block_assignment_flag;
-	uint32_t resource_block_coding;
-	uint8_t modulation;
-	uint8_t redundancy_version;
-	uint8_t transport_blocks;
-	uint8_t transport_block_to_codeword_swap_flag;
-	uint8_t transmission_scheme;
-	uint8_t number_of_layers;
-	uint8_t number_of_subbands;
-	uint8_t codebook_index[NFAPI_MAX_NUM_SUBBANDS];
-	uint8_t ue_category_capacity;
-	uint8_t pa;
-	uint8_t delta_power_offset_index;
-	uint8_t ngap;
-	uint8_t nprb;
-	uint8_t transmission_mode;
-	uint8_t num_bf_prb_per_subband;
-	uint8_t num_bf_vector;
-	nfapi_bf_vector_t bf_vector[NFAPI_MAX_BF_VECTORS];
-} nfapi_dl_config_dlsch_pdu_rel8_t;
-#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG 0x2006
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t nscid;
-} nfapi_dl_config_dlsch_pdu_rel9_t;
-#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL9_TAG 0x2007
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t csi_rs_flag;
-	uint8_t csi_rs_resource_config_r10;
-	uint16_t csi_rs_zero_tx_power_resource_config_bitmap_r10;
-	uint8_t csi_rs_number_nzp_configuration;
-	uint8_t csi_rs_resource_config[NFAPI_MAX_CSI_RS_RESOURCE_CONFIG];
-	uint8_t pdsch_start;
-} nfapi_dl_config_dlsch_pdu_rel10_t;
-#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG 0x2008
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t drms_config_flag;
-	uint16_t drms_scrambling;
-	uint8_t csi_config_flag;
-	uint16_t csi_scrambling;
-	uint8_t pdsch_re_mapping_flag;
-	uint8_t pdsch_re_mapping_atenna_ports;
-	uint8_t pdsch_re_mapping_freq_shift;
-} nfapi_dl_config_dlsch_pdu_rel11_t;
-#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL11_TAG 0x203C
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t altcqi_table_r12;
-	uint8_t maxlayers;
-	uint8_t n_dl_harq;
-} nfapi_dl_config_dlsch_pdu_rel12_t;
-#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL12_TAG 0x203D
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t dwpts_symbols;
-	uint8_t initial_lbt_sf;
-	uint8_t ue_type;
-	uint8_t pdsch_payload_type;
-	uint16_t initial_transmission_sf_io;
-	uint8_t drms_table_flag;
-} nfapi_dl_config_dlsch_pdu_rel13_t;
-#define NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG 0x203E
-
-typedef struct {
-	nfapi_dl_config_dlsch_pdu_rel8_t dlsch_pdu_rel8;
-	nfapi_dl_config_dlsch_pdu_rel9_t dlsch_pdu_rel9;
-	nfapi_dl_config_dlsch_pdu_rel10_t dlsch_pdu_rel10;
-	nfapi_dl_config_dlsch_pdu_rel11_t dlsch_pdu_rel11;
-	nfapi_dl_config_dlsch_pdu_rel12_t dlsch_pdu_rel12;
-	nfapi_dl_config_dlsch_pdu_rel13_t dlsch_pdu_rel13;
-} nfapi_dl_config_dlsch_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint16_t p_rnti;
-	uint8_t resource_allocation_type;
-	uint8_t virtual_resource_block_assignment_flag;
-	uint32_t resource_block_coding;
-	uint8_t mcs;
-	uint8_t redundancy_version;
-	uint8_t number_of_transport_blocks;
-	uint8_t transport_block_to_codeword_swap_flag;
-	uint8_t transmission_scheme;
-	uint8_t number_of_layers;
-	uint8_t codebook_index;
-	uint8_t ue_category_capacity;
-	uint8_t pa;
-	uint16_t transmission_power;
-	uint8_t nprb;
-	uint8_t ngap;
-} nfapi_dl_config_pch_pdu_rel8_t;
-#define NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL8_TAG 0x2009
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t ue_mode;
-	uint16_t initial_transmission_sf_io;
-} nfapi_dl_config_pch_pdu_rel13_t;
-#define NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL13_TAG 0x203F
-
-typedef struct {
-	nfapi_dl_config_pch_pdu_rel8_t pch_pdu_rel8;
-	nfapi_dl_config_pch_pdu_rel13_t pch_pdu_rel13;
-} nfapi_dl_config_pch_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t transmission_power;
-	uint8_t prs_bandwidth;
-	uint8_t prs_cyclic_prefix_type;
-	uint8_t prs_muting;
-} nfapi_dl_config_prs_pdu_rel9_t;
-#define NFAPI_DL_CONFIG_REQUEST_PRS_PDU_REL9_TAG 0x200A
-
-typedef struct {
-	nfapi_dl_config_prs_pdu_rel9_t prs_pdu_rel9;
-} nfapi_dl_config_prs_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t csi_rs_antenna_port_count_r10;
-	uint8_t csi_rs_resource_config_r10;
-	uint16_t transmission_power;
-	uint16_t csi_rs_zero_tx_power_resource_config_bitmap_r10;
-	uint8_t csi_rs_number_of_nzp_configuration;
-	uint8_t csi_rs_resource_config[NFAPI_MAX_CSI_RS_RESOURCE_CONFIG];
-} nfapi_dl_config_csi_rs_pdu_rel10_t;
-#define NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL10_TAG 0x200B
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t csi_rs_class;
-	uint8_t cdm_type;
-	uint8_t num_bf_vector;
-	struct {
-		uint8_t csi_rs_resource_index;
-		uint16_t bf_value[NFAPI_MAX_ANTENNA_PORT_COUNT];
-	} bf_vector[NFAPI_MAX_BF_VECTORS];
-
-}nfapi_dl_config_csi_rs_pdu_rel13_t;
-#define NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL13_TAG 0x2040
-
-typedef struct {
-	nfapi_dl_config_csi_rs_pdu_rel10_t csi_rs_pdu_rel10;
-	nfapi_dl_config_csi_rs_pdu_rel13_t csi_rs_pdu_rel13;
-} nfapi_dl_config_csi_rs_pdu;
-
-#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL8_TAG 0x2001
-#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL9_TAG 0x2002
-#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL10_TAG 0x2003
-#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL11_TAG 0x2039
-#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL12_TAG 0x203a
-#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL13_TAG 0x203b
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t epdcch_resource_assignment_flag;
-	uint16_t epdcch_id;
-	uint8_t epdcch_start_symbol;
-	uint8_t epdcch_num_prb;
-	uint8_t epdcch_prb_index[NFAPI_MAX_EPDCCH_PRB];
-	nfapi_bf_vector_t bf_vector;
-} nfapi_dl_config_epdcch_parameters_rel11_t;
-#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL11_TAG 0x2041
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t dwpts_symbols;
-	uint8_t initial_lbt_sf;
-} nfapi_dl_config_epdcch_parameters_rel13_t;
-#define NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL13_TAG 0x2042
-
-typedef struct {
-	nfapi_dl_config_dci_dl_pdu_rel8_t			epdcch_pdu_rel8;
-	nfapi_dl_config_dci_dl_pdu_rel9_t			epdcch_pdu_rel9;
-	nfapi_dl_config_dci_dl_pdu_rel10_t			epdcch_pdu_rel10;
-	nfapi_dl_config_dci_dl_pdu_rel11_t			epdcch_pdu_rel11;
-	nfapi_dl_config_dci_dl_pdu_rel12_t			epdcch_pdu_rel12;
-	nfapi_dl_config_dci_dl_pdu_rel13_t			epdcch_pdu_rel13;
-	nfapi_dl_config_epdcch_parameters_rel11_t	epdcch_params_rel11;
-	nfapi_dl_config_epdcch_parameters_rel13_t	epdcch_params_rel13;
-} nfapi_dl_config_epdcch_pdu;
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t mpdcch_narrow_band;
-	uint8_t number_of_prb_pairs;
-	uint8_t resource_block_assignment;
-	uint8_t mpdcch_tansmission_type;
-	uint8_t start_symbol;
-	uint8_t ecce_index;
-	uint8_t aggregation_level;
-	uint8_t rnti_type;
-	uint16_t rnti;
-	uint8_t ce_mode;
-	uint16_t drms_scrambling_init;
-	uint16_t initial_transmission_sf_io;
-	uint16_t transmission_power;
-	uint8_t dci_format;
-	uint16_t resource_block_coding;
-	uint8_t mcs;
-	uint8_t pdsch_reptition_levels;
-	uint8_t redundancy_version;
-	uint8_t new_data_indicator;
-	uint8_t harq_process;
-	uint8_t tpmi_length;
-	uint8_t tpmi;
-	uint8_t pmi_flag;
-	uint8_t pmi;
-	uint8_t harq_resource_offset;
-	uint8_t dci_subframe_repetition_number;
-	uint8_t tpc;
-	uint8_t downlink_assignment_index_length;
-	uint8_t downlink_assignment_index;
-	uint8_t allocate_prach_flag;
-	uint8_t preamble_index;
-	uint8_t prach_mask_index;
-	uint8_t starting_ce_level;
-	uint8_t srs_request;
-	uint8_t antenna_ports_and_scrambling_identity_flag;
-	uint8_t antenna_ports_and_scrambling_identity;
-	uint8_t frequency_hopping_enabled_flag;
-	uint8_t paging_direct_indication_differentiation_flag;
-	uint8_t direct_indication;
-	uint8_t total_dci_length_including_padding;
-	uint8_t number_of_tx_antenna_ports;
-	uint16_t precoding_value[NFAPI_MAX_TX_PHYSICAL_ANTENNA_PORTS];
-} nfapi_dl_config_mpdcch_pdu_rel13_t;
-#define NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG 0x205B
-
-
-typedef struct {
-	nfapi_dl_config_mpdcch_pdu_rel13_t mpdcch_pdu_rel13;
-} nfapi_dl_config_mpdcch_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint16_t transmission_power;
-	uint16_t hyper_sfn_2_lsbs;
-} nfapi_dl_config_nbch_pdu_rel13_t;
-
-#define NFAPI_DL_CONFIG_REQUEST_NBCH_PDU_REL13_TAG 0x205C
-
-typedef struct {
-	nfapi_dl_config_nbch_pdu_rel13_t nbch_pdu_rel13;
-} nfapi_dl_config_nbch_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint8_t ncce_index;
-	uint8_t aggregation_level;
-	uint8_t start_symbol;
-	uint8_t rnti_type;
-	uint16_t rnti;
-	uint8_t scrambling_reinitialization_batch_index;
-	uint8_t nrs_antenna_ports_assumed_by_the_ue;
-	uint8_t dci_format;
-	uint8_t scheduling_delay;
-	uint8_t resource_assignment;
-	uint8_t repetition_number;
-	uint8_t mcs;
-	uint8_t new_data_indicator;
-	uint8_t harq_ack_resource;
-	uint8_t npdcch_order_indication;
-	uint8_t starting_number_of_nprach_repetitions;
-	uint8_t subcarrier_indication_of_nprach;
-	uint8_t paging_direct_indication_differentation_flag;
-	uint8_t direct_indication;
-	uint8_t dci_subframe_repetition_number;
-	uint8_t total_dci_length_including_padding;
-} nfapi_dl_config_npdcch_pdu_rel13_t;
-
-#define NFAPI_DL_CONFIG_REQUEST_NPDCCH_PDU_REL13_TAG 0x205D
-
-typedef struct {
-	nfapi_dl_config_npdcch_pdu_rel13_t npdcch_pdu_rel13;
-} nfapi_dl_config_npdcch_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint8_t start_symbol;
-	uint8_t rnti_type;
-	uint16_t rnti;
-	uint16_t resource_assignment;
-	uint16_t repetition_number;
-	uint8_t modulation;
-	uint8_t number_of_subframes_for_resource_assignment;
-	uint8_t scrambling_sequence_initialization_cinit;
-	uint16_t sf_idx;
-	uint8_t nrs_antenna_ports_assumed_by_the_ue;
-} nfapi_dl_config_ndlsch_pdu_rel13_t;
-
-#define NFAPI_DL_CONFIG_REQUEST_NDLSCH_PDU_REL13_TAG 0x205E
-
-typedef struct {
-	nfapi_dl_config_ndlsch_pdu_rel13_t ndlsch_pdu_rel13;
-} nfapi_dl_config_ndlsch_pdu;
-
-
-typedef struct {
-	uint8_t pdu_type;
-	uint8_t pdu_size;
-	union {
-		nfapi_dl_config_dci_dl_pdu	dci_dl_pdu;
-		nfapi_dl_config_bch_pdu		bch_pdu;
-		nfapi_dl_config_mch_pdu		mch_pdu;
-		nfapi_dl_config_dlsch_pdu	dlsch_pdu;
-		nfapi_dl_config_pch_pdu		pch_pdu;
-		nfapi_dl_config_prs_pdu		prs_pdu;
-		nfapi_dl_config_csi_rs_pdu	csi_rs_pdu;
-		nfapi_dl_config_epdcch_pdu	epdcch_pdu;
-		nfapi_dl_config_mpdcch_pdu	mpdcch_pdu;
-		nfapi_dl_config_nbch_pdu	nbch_pdu;
-		nfapi_dl_config_npdcch_pdu	npdcch_pdu;
-		nfapi_dl_config_ndlsch_pdu	ndlsch_pdu;
-	};
-} nfapi_dl_config_request_pdu_t;
-
-#define NFAPI_DL_CONFIG_MAX_PDU 100
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t number_pdcch_ofdm_symbols;
-	uint8_t number_dci;
-	uint16_t number_pdu;
-	uint8_t number_pdsch_rnti;
-	uint16_t transmission_power_pcfich;
-	nfapi_dl_config_request_pdu_t* dl_config_pdu_list;
-} nfapi_dl_config_request_body_t;
-#define NFAPI_DL_CONFIG_REQUEST_BODY_TAG 0x2000
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint32_t handle;
-	uint16_t size;
-	uint16_t rnti;
-	uint8_t resource_block_start;
-	uint8_t number_of_resource_blocks;
-	uint8_t modulation_type;
-	uint8_t cyclic_shift_2_for_drms;
-	uint8_t frequency_hopping_enabled_flag;
-	uint8_t frequency_hopping_bits;
-	uint8_t new_data_indication;
-	uint8_t redundancy_version;
-	uint8_t harq_process_number;
-	uint8_t ul_tx_mode;
-	uint8_t current_tx_nb;
-	uint8_t n_srs;
-} nfapi_ul_config_ulsch_pdu_rel8_t;
-#define NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG 0x200D
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t resource_allocation_type;
-	uint32_t resource_block_coding;
-	uint8_t transport_blocks;
-	uint8_t transmission_scheme;
-	uint8_t number_of_layers;
-	uint8_t codebook_index;
-	uint8_t disable_sequence_hopping_flag;
-} nfapi_ul_config_ulsch_pdu_rel10_t;
-#define NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL10_TAG 0x200E
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t virtual_cell_id_enabled_flag;
-	uint16_t npusch_identity;
-	uint8_t dmrs_config_flag;
-	uint16_t ndmrs_csh_identity;
-} nfapi_ul_config_ulsch_pdu_rel11_t;
-
-#define NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL11_TAG 0x2043
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t  ue_type;
-	uint16_t total_number_of_repetitions;
-	uint16_t repetition_number;
-	uint16_t initial_transmission_sf_io;
-	uint8_t  empty_symbols_due_to_re_tunning;
-} nfapi_ul_config_ulsch_pdu_rel13_t;
-#define NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG 0x2044
-
-typedef struct {
-	nfapi_ul_config_ulsch_pdu_rel8_t ulsch_pdu_rel8;
-	nfapi_ul_config_ulsch_pdu_rel10_t ulsch_pdu_rel10;
-	nfapi_ul_config_ulsch_pdu_rel11_t ulsch_pdu_rel11;
-	nfapi_ul_config_ulsch_pdu_rel13_t ulsch_pdu_rel13;
-} nfapi_ul_config_ulsch_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t dl_cqi_pmi_size_rank_1;
-	uint8_t dl_cqi_pmi_size_rank_greater_1;
-	uint8_t ri_size;
-	uint8_t delta_offset_cqi;
-	uint8_t delta_offset_ri;
-} nfapi_ul_config_cqi_ri_information_rel8_t;
-#define NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL8_TAG 0x2010
-
-typedef struct {
-	uint8_t dl_cqi_pmi_ri_size;
-	uint8_t control_type;
-} nfapi_ul_config_periodic_cqi_pmi_ri_report_t;
-
-typedef struct {
-	uint8_t number_of_cc;
-	struct {
-		uint8_t ri_size;
-		uint8_t dl_cqi_pmi_size[8];
-	} cc[NFAPI_MAX_CC];
-} nfapi_ul_config_aperiodic_cqi_pmi_ri_report_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t report_type;
-	uint8_t delta_offset_cqi;
-	uint8_t delta_offset_ri;
-	union {
-		nfapi_ul_config_periodic_cqi_pmi_ri_report_t periodic_cqi_pmi_ri_report;
-		nfapi_ul_config_aperiodic_cqi_pmi_ri_report_t aperiodic_cqi_pmi_ri_report;
-	};
-} nfapi_ul_config_cqi_ri_information_rel9_t;
-#define NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL9_TAG 0x2011
-
-typedef struct {
-	uint16_t dl_cqi_pmi_ri_size_2;
-} nfapi_ul_config_periodic_cqi_pmi_ri_report_re13_t;
-
-typedef struct {
-} nfapi_ul_config_aperiodic_cqi_pmi_ri_report_re13_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t report_type; // Convience parameter, not sent on the wire
-	union {
-		nfapi_ul_config_periodic_cqi_pmi_ri_report_re13_t periodic_cqi_pmi_ri_report;
-		nfapi_ul_config_aperiodic_cqi_pmi_ri_report_re13_t aperiodic_cqi_pmi_ri_report;
-	};
-} nfapi_ul_config_cqi_ri_information_rel13_t;
-#define NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL13_TAG 0x2045
-
-typedef struct {
-	nfapi_ul_config_cqi_ri_information_rel8_t cqi_ri_information_rel8;
-	nfapi_ul_config_cqi_ri_information_rel9_t cqi_ri_information_rel9;
-	nfapi_ul_config_cqi_ri_information_rel13_t cqi_ri_information_rel13;
-} nfapi_ul_config_cqi_ri_information;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t harq_size;
-	uint8_t delta_offset_harq;
-	uint8_t ack_nack_mode;
-} nfapi_ul_config_ulsch_harq_information_rel10_t;
-#define NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL10_TAG 0x2012
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t harq_size_2;
-	uint8_t delta_offset_harq_2;
-} nfapi_ul_config_ulsch_harq_information_rel13_t;
-#define NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL13_TAG 0x2046
-
-typedef struct {
-	nfapi_ul_config_ulsch_harq_information_rel10_t harq_information_rel10;
-	nfapi_ul_config_ulsch_harq_information_rel13_t harq_information_rel13;
-} nfapi_ul_config_ulsch_harq_information;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t n_srs_initial;
-	uint8_t initial_number_of_resource_blocks;
-} nfapi_ul_config_initial_transmission_parameters_rel8_t;
-#define NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG 0x200F
-
-typedef struct {
-	nfapi_ul_config_initial_transmission_parameters_rel8_t initial_transmission_parameters_rel8;
-} nfapi_ul_config_initial_transmission_parameters;
-
-typedef struct {
-	nfapi_ul_config_ulsch_pdu ulsch_pdu;
-	nfapi_ul_config_cqi_ri_information cqi_ri_information;
-	nfapi_ul_config_initial_transmission_parameters initial_transmission_parameters;
-} nfapi_ul_config_ulsch_cqi_ri_pdu;
-
-typedef struct {
-	nfapi_ul_config_ulsch_pdu ulsch_pdu;
-	nfapi_ul_config_ulsch_harq_information harq_information;
-	nfapi_ul_config_initial_transmission_parameters initial_transmission_parameters;
-} nfapi_ul_config_ulsch_harq_pdu;
-
-typedef struct {
-	nfapi_ul_config_ulsch_pdu ulsch_pdu;
-	nfapi_ul_config_cqi_ri_information cqi_ri_information;
-	nfapi_ul_config_ulsch_harq_information harq_information;
-	nfapi_ul_config_initial_transmission_parameters initial_transmission_parameters;
-} nfapi_ul_config_ulsch_cqi_harq_ri_pdu;
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint32_t handle;
-	uint16_t rnti;
-} nfapi_ul_config_ue_information_rel8_t;
-#define NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG 0x2013
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t virtual_cell_id_enabled_flag;
-	uint16_t npusch_identity;
-} nfapi_ul_config_ue_information_rel11_t;
-
-#define NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG 0x2047
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t  ue_type;
-	uint8_t  empty_symbols;
-	uint16_t total_number_of_repetitions;
-	uint16_t repetition_number;
-} nfapi_ul_config_ue_information_rel13_t;
-
-#define NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG 0x2048
-
-typedef struct {
-	nfapi_ul_config_ue_information_rel8_t ue_information_rel8;
-	nfapi_ul_config_ue_information_rel11_t ue_information_rel11;
-	nfapi_ul_config_ue_information_rel13_t ue_information_rel13;
-} nfapi_ul_config_ue_information;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t pucch_index;
-	uint8_t dl_cqi_pmi_size;
-} nfapi_ul_config_cqi_information_rel8_t;
-#define NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG 0x2014
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t number_of_pucch_resource;
-	uint16_t pucch_index_p1;
-} nfapi_ul_config_cqi_information_rel10_t;
-#define NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL10_TAG 0x2015
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t csi_mode;
-	uint16_t dl_cqi_pmi_size_2;
-	uint8_t starting_prb;
-	uint8_t n_prb;
-	uint8_t cdm_index;
-	uint8_t n_srs;
-} nfapi_ul_config_cqi_information_rel13_t;
-#define NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL13_TAG 0x2049
-
-typedef struct {
-	nfapi_ul_config_cqi_information_rel8_t cqi_information_rel8;
-	nfapi_ul_config_cqi_information_rel10_t cqi_information_rel10;
-	nfapi_ul_config_cqi_information_rel13_t cqi_information_rel13;
-} nfapi_ul_config_cqi_information;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t pucch_index;
-} nfapi_ul_config_sr_information_rel8_t;
-#define NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG 0x2016
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t number_of_pucch_resources;
-	uint16_t pucch_index_p1;
-} nfapi_ul_config_sr_information_rel10_t;
-#define NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG 0x2017
-
-typedef struct { 
-	nfapi_ul_config_sr_information_rel8_t sr_information_rel8;
-	nfapi_ul_config_sr_information_rel10_t sr_information_rel10;
-} nfapi_ul_config_sr_information;
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint8_t harq_size;
-	uint8_t ack_nack_mode;
-	uint8_t number_of_pucch_resources;
-	uint16_t n_pucch_1_0;
-	uint16_t n_pucch_1_1;
-	uint16_t n_pucch_1_2;
-	uint16_t n_pucch_1_3;
-} nfapi_ul_config_harq_information_rel10_tdd_t;
-#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG 0x2018
-
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint16_t n_pucch_1_0;
-	uint8_t harq_size;
-} nfapi_ul_config_harq_information_rel8_fdd_t;
-#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG 0x2019
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint8_t harq_size;
-	uint8_t ack_nack_mode;
-	uint8_t number_of_pucch_resources;
-	uint16_t n_pucch_1_0;
-	uint16_t n_pucch_1_1;
-	uint16_t n_pucch_1_2;
-	uint16_t n_pucch_1_3;
-} nfapi_ul_config_harq_information_rel9_fdd_t;
-#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG 0x201a
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint8_t  num_ant_ports;
-	uint16_t n_pucch_2_0;
-	uint16_t n_pucch_2_1;
-	uint16_t n_pucch_2_2;
-	uint16_t n_pucch_2_3;	
-} nfapi_ul_config_harq_information_rel11_t;
-#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG 0x204A
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint16_t  harq_size_2;
-	uint8_t starting_prb;
-	uint8_t n_prb;
-	uint8_t cdm_index;
-	uint8_t n_srs;
-} nfapi_ul_config_harq_information_rel13_t;
-#define NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL13_TAG 0x204B
-
-typedef struct {
-	nfapi_ul_config_harq_information_rel10_tdd_t harq_information_rel10_tdd;
-	nfapi_ul_config_harq_information_rel8_fdd_t harq_information_rel8_fdd;
-	nfapi_ul_config_harq_information_rel9_fdd_t harq_information_rel9_fdd;
-	nfapi_ul_config_harq_information_rel11_t harq_information_rel11;
-	nfapi_ul_config_harq_information_rel13_t harq_information_rel13;
-} nfapi_ul_config_harq_information;
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint32_t handle;
-	uint16_t size;
-	uint16_t rnti;
-	uint8_t srs_bandwidth;
-	uint8_t frequency_domain_position;
-	uint8_t srs_hopping_bandwidth;
-	uint8_t transmission_comb;
-	uint16_t i_srs;
-	uint8_t sounding_reference_cyclic_shift;
-} nfapi_ul_config_srs_pdu_rel8_t;
-#define NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG 0x201b
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint8_t antenna_port;
-} nfapi_ul_config_srs_pdu_rel10_t;
-#define NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL10_TAG 0x201c
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint8_t number_of_combs;
-} nfapi_ul_config_srs_pdu_rel13_t;
-#define NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL13_TAG 0x204c
-
-typedef struct {
-	nfapi_ul_config_srs_pdu_rel8_t srs_pdu_rel8;
-	nfapi_ul_config_srs_pdu_rel10_t srs_pdu_rel10;
-	nfapi_ul_config_srs_pdu_rel13_t srs_pdu_rel13;
-} nfapi_ul_config_srs_pdu;
-
-typedef struct {
-	nfapi_ul_config_ue_information ue_information;
-	nfapi_ul_config_cqi_information cqi_information;
-} nfapi_ul_config_uci_cqi_pdu;
-
-typedef struct {
-	nfapi_ul_config_ue_information ue_information;
-	nfapi_ul_config_sr_information sr_information;
-} nfapi_ul_config_uci_sr_pdu;
-
-typedef struct {
-	nfapi_ul_config_ue_information ue_information;
-	nfapi_ul_config_harq_information harq_information;
-} nfapi_ul_config_uci_harq_pdu;
-
-typedef struct {
-	nfapi_ul_config_ue_information ue_information;
-	nfapi_ul_config_sr_information sr_information;
-	nfapi_ul_config_harq_information harq_information;
-} nfapi_ul_config_uci_sr_harq_pdu;
-
-typedef struct {
-	nfapi_ul_config_ue_information ue_information;
-	nfapi_ul_config_cqi_information cqi_information;
-	nfapi_ul_config_harq_information harq_information;
-} nfapi_ul_config_uci_cqi_harq_pdu;
-
-typedef struct {
-	nfapi_ul_config_ue_information ue_information;
-	nfapi_ul_config_cqi_information cqi_information;
-	nfapi_ul_config_sr_information sr_information;
-} nfapi_ul_config_uci_cqi_sr_pdu;
-
-typedef struct {
-	nfapi_ul_config_ue_information ue_information;
-	nfapi_ul_config_cqi_information cqi_information;
-	nfapi_ul_config_sr_information sr_information;
-	nfapi_ul_config_harq_information harq_information;
-} nfapi_ul_config_uci_cqi_sr_harq_pdu;
-
-typedef struct {
-	nfapi_ul_config_ue_information ue_information;
-} nfapi_ul_config_harq_buffer_pdu;
-
-typedef struct {
-	nfapi_ul_config_ulsch_pdu ulsch_pdu;
-	nfapi_ul_config_cqi_information csi_information;
-} nfapi_ul_config_ulsch_uci_csi_pdu;
-
-typedef struct {
-	nfapi_ul_config_ulsch_pdu ulsch_pdu;
-	nfapi_ul_config_harq_information harq_information;
-} nfapi_ul_config_ulsch_uci_harq_pdu;
-
-typedef struct {
-	nfapi_ul_config_ulsch_pdu ulsch_pdu;
-	nfapi_ul_config_cqi_information csi_information;
-	nfapi_ul_config_harq_information harq_information;
-} nfapi_ul_config_ulsch_csi_uci_harq_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t harq_ack_resource;
-} nfapi_ul_config_nb_harq_information_rel13_fdd_t;
-#define NFAPI_UL_CONFIG_REQUEST_NB_HARQ_INFORMATION_REL13_FDD_TAG 0x2061
-
-typedef struct {
-	nfapi_ul_config_nb_harq_information_rel13_fdd_t nb_harq_information_rel13_fdd;
-} nfapi_ul_config_nb_harq_information;
-
-typedef struct {
-	nfapi_tl_t tl;	
-	uint8_t nulsch_format;
-	uint32_t handle;
-	uint16_t size;
-	uint16_t rnti;
-	uint8_t subcarrier_indication;
-	uint8_t resource_assignment;
-	uint8_t mcs;
-	uint8_t redudancy_version;
-	uint8_t repetition_number;
-	uint8_t new_data_indication;
-	uint8_t n_srs;
-	uint16_t scrambling_sequence_initialization_cinit;
-	uint16_t sf_idx;
-	nfapi_ul_config_ue_information ue_information;
-	nfapi_ul_config_nb_harq_information nb_harq_information;
-} nfapi_ul_config_nulsch_pdu_rel13_t;
-#define NFAPI_UL_CONFIG_REQUEST_NULSCH_PDU_REL13_TAG 0x205F
-
-typedef struct {
-	nfapi_ul_config_nulsch_pdu_rel13_t nulsch_pdu_rel13;
-} nfapi_ul_config_nulsch_pdu;
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t nprach_config_0;
-	uint8_t nprach_config_1;
-	uint8_t nprach_config_2;
-} nfapi_ul_config_nrach_pdu_rel13_t;
-#define NFAPI_UL_CONFIG_REQUEST_NRACH_PDU_REL13_TAG 0x2067
-
-typedef struct {
-	nfapi_ul_config_nrach_pdu_rel13_t nrach_pdu_rel13;
-} nfapi_ul_config_nrach_pdu;
-
-typedef struct {
-	uint8_t pdu_type;
-	uint8_t pdu_size;
-	union {
-		nfapi_ul_config_ulsch_pdu				ulsch_pdu;
-		nfapi_ul_config_ulsch_cqi_ri_pdu		ulsch_cqi_ri_pdu;
-		nfapi_ul_config_ulsch_harq_pdu			ulsch_harq_pdu;
-		nfapi_ul_config_ulsch_cqi_harq_ri_pdu	ulsch_cqi_harq_ri_pdu;
-		nfapi_ul_config_uci_cqi_pdu				uci_cqi_pdu;
-		nfapi_ul_config_uci_sr_pdu				uci_sr_pdu;
-		nfapi_ul_config_uci_harq_pdu			uci_harq_pdu;
-		nfapi_ul_config_uci_sr_harq_pdu			uci_sr_harq_pdu;
-		nfapi_ul_config_uci_cqi_harq_pdu		uci_cqi_harq_pdu;
-		nfapi_ul_config_uci_cqi_sr_pdu			uci_cqi_sr_pdu;
-		nfapi_ul_config_uci_cqi_sr_harq_pdu		uci_cqi_sr_harq_pdu;
-		nfapi_ul_config_srs_pdu					srs_pdu;
-		nfapi_ul_config_harq_buffer_pdu			harq_buffer_pdu;
-		nfapi_ul_config_ulsch_uci_csi_pdu		ulsch_uci_csi_pdu;
-		nfapi_ul_config_ulsch_uci_harq_pdu		ulsch_uci_harq_pdu;
-		nfapi_ul_config_ulsch_csi_uci_harq_pdu	ulsch_csi_uci_harq_pdu;
-		nfapi_ul_config_nulsch_pdu				nulsch_pdu;
-		nfapi_ul_config_nrach_pdu				nrach_pdu;
-	};
-} nfapi_ul_config_request_pdu_t;
-
-#define NFAPI_UL_CONFIG_MAX_PDU 100
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t number_of_pdus;
-	uint8_t rach_prach_frequency_resources;
-	uint8_t srs_present;
-	nfapi_ul_config_request_pdu_t* ul_config_pdu_list;
-} nfapi_ul_config_request_body_t;
-#define NFAPI_UL_CONFIG_REQUEST_BODY_TAG 0x200C
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t resource_block_start;
-	uint8_t cyclic_shift_2_for_drms;
-	uint8_t hi_value;
-	uint8_t i_phich;
-	uint16_t transmission_power;
-} nfapi_hi_dci0_hi_pdu_rel8_t;
-#define NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG 0x201e
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t flag_tb2;
-	uint8_t hi_value_2;
-} nfapi_hi_dci0_hi_pdu_rel10_t;
-#define NFAPI_HI_DCI0_REQUEST_HI_PDU_REL10_TAG 0x201f
-
-typedef struct {
-	nfapi_hi_dci0_hi_pdu_rel8_t		hi_pdu_rel8;
-	nfapi_hi_dci0_hi_pdu_rel10_t	hi_pdu_rel10;
-} nfapi_hi_dci0_hi_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t dci_format;
-	uint8_t cce_index;
-	uint8_t aggregation_level;
-	uint16_t rnti;
-	uint8_t resource_block_start;
-	uint8_t number_of_resource_block;
-	uint8_t mcs_1;
-	uint8_t cyclic_shift_2_for_drms;
-	uint8_t frequency_hopping_enabled_flag;
-	uint8_t frequency_hopping_bits;
-	uint8_t new_data_indication_1;
-	uint8_t ue_tx_antenna_seleciton;
-	uint8_t tpc;
-	uint8_t cqi_csi_request;
-	uint8_t ul_index;
-	uint8_t dl_assignment_index;
-	uint32_t tpc_bitmap;
-	uint16_t transmission_power;
-} nfapi_hi_dci0_dci_pdu_rel8_t;
-#define NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG 0x2020
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t cross_carrier_scheduling_flag;
-	uint8_t carrier_indicator;
-	uint8_t size_of_cqi_csi_feild;
-	uint8_t srs_flag;
-	uint8_t srs_request;
-	uint8_t resource_allocation_flag;
-	uint8_t resource_allocation_type;
-	uint32_t resource_block_coding;
-	uint8_t mcs_2;
-	uint8_t new_data_indication_2;
-	uint8_t number_of_antenna_ports;
-	uint8_t tpmi;
-	uint8_t total_dci_length_including_padding;
-	uint8_t n_ul_rb;
-} nfapi_hi_dci0_dci_pdu_rel10_t;
-#define NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL10_TAG 0x2021
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t pscch_resource;
-	uint8_t time_resource_pattern;
-} nfapi_hi_dci0_dci_pdu_rel12_t;
-
-#define NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL12_TAG 0x204D
-
-typedef struct {
-	nfapi_hi_dci0_dci_pdu_rel8_t	dci_pdu_rel8;
-	nfapi_hi_dci0_dci_pdu_rel10_t	dci_pdu_rel10;
-	nfapi_hi_dci0_dci_pdu_rel12_t	dci_pdu_rel12;
-} nfapi_hi_dci0_dci_pdu;
-
-typedef nfapi_hi_dci0_dci_pdu_rel8_t nfapi_hi_dci0_epdcch_dci_pdu_rel8_t;
-#define NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL8_TAG 0x2020
-
-typedef nfapi_hi_dci0_dci_pdu_rel10_t nfapi_hi_dci0_epdcch_dci_pdu_rel10_t;
-#define NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL10_TAG 0x2021
-
-typedef nfapi_dl_config_epdcch_parameters_rel11_t nfapi_hi_dci0_epdcch_parameters_rel11_t;
-#define NFAPI_HI_DCI0_REQUEST_EPDCCH_PARAMETERS_REL11_TAG 0x2041
-
-typedef struct {
-	nfapi_hi_dci0_epdcch_dci_pdu_rel8_t		epdcch_dci_pdu_rel8;
-	nfapi_hi_dci0_epdcch_dci_pdu_rel10_t	epdcch_dci_pdu_rel10;
-	nfapi_hi_dci0_epdcch_parameters_rel11_t	epdcch_parameters_rel11;
-} nfapi_hi_dci0_epdcch_dci_pdu;
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t mpdcch_narrowband;
-	uint8_t number_of_prb_pairs;
-	uint8_t resource_block_assignment;
-	uint8_t mpdcch_transmission_type;
-	uint8_t start_symbol;
-	uint8_t ecce_index;
-	uint8_t aggreagation_level;
-	uint8_t rnti_type;
-	uint16_t rnti;
-	uint8_t ce_mode;
-	uint16_t drms_scrambling_init;
-	uint16_t initial_transmission_sf_io;
-	uint16_t transmission_power;
-	uint8_t dci_format;
-	uint8_t resource_block_start;
-	uint8_t number_of_resource_blocks;
-	uint8_t mcs;
-	uint8_t pusch_repetition_levels;
-	uint8_t frequency_hopping_flag;
-	uint8_t new_data_indication;
-	uint8_t harq_process;
-	uint8_t redudency_version;
-	uint8_t tpc;
-	uint8_t csi_request;
-	uint8_t ul_inex;
-	uint8_t dai_presence_flag;
-	uint8_t dl_assignment_index;
-	uint8_t srs_request;
-	uint8_t dci_subframe_repetition_number;
-	uint32_t tcp_bitmap;
-	uint8_t total_dci_length_include_padding;
-	uint8_t number_of_tx_antenna_ports;
-	uint16_t precoding_value[NFAPI_MAX_ANTENNA_PORT_COUNT];
-} nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t;
-#define NFAPI_HI_DCI0_REQUEST_MPDCCH_DCI_PDU_REL13_TAG 0x204E
-
-typedef struct {
-	nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t	mpdcch_dci_pdu_rel13;
-} nfapi_hi_dci0_mpdcch_dci_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t ncce_index;
-	uint8_t aggregation_level;
-	uint8_t start_symbol;
-	uint16_t rnti;
-	uint8_t scrambling_reinitialization_batch_index;
-	uint8_t nrs_antenna_ports_assumed_by_the_ue;
-	uint8_t subcarrier_indication;
-	uint8_t resource_assignment;
-	uint8_t scheduling_delay;
-	uint8_t mcs;
-	uint8_t redudancy_version;
-	uint8_t repetition_number;
-	uint8_t new_data_indicator;
-	uint8_t dci_subframe_repetition_number;
-} nfapi_hi_dci0_npdcch_dci_pdu_rel13_t;
-
-#define NFAPI_HI_DCI0_REQUEST_NPDCCH_DCI_PDU_REL13_TAG 0x2062
-
-typedef struct {
-	nfapi_hi_dci0_npdcch_dci_pdu_rel13_t	npdcch_dci_pdu_rel13;
-} nfapi_hi_dci0_npdcch_dci_pdu;
-
-typedef struct {
-	uint8_t pdu_type;
-	uint8_t pdu_size;
-	union {
-		nfapi_hi_dci0_hi_pdu			hi_pdu;
-		nfapi_hi_dci0_dci_pdu			dci_pdu;
-		nfapi_hi_dci0_epdcch_dci_pdu	epdcch_dci_pdu;
-		nfapi_hi_dci0_mpdcch_dci_pdu	mpdcch_dci_pdu;
-		nfapi_hi_dci0_npdcch_dci_pdu	npdcch_dci_pdu;
-	};
-} nfapi_hi_dci0_request_pdu_t;
-
-#define NFAPI_HI_DCI0_MAX_PDU 100
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t sfnsf;
-	uint8_t number_of_dci;
-	uint8_t number_of_hi;
-	nfapi_hi_dci0_request_pdu_t* hi_dci0_pdu_list;
-} nfapi_hi_dci0_request_body_t;
-#define NFAPI_HI_DCI0_REQUEST_BODY_TAG 0x201D
-
-#define NFAPI_TX_MAX_SEGMENTS 32
-typedef struct {
-	uint16_t pdu_length;
-	uint16_t pdu_index;
-	uint8_t num_segments;
-	struct {
-		uint32_t segment_length;
-		uint8_t* segment_data;
-	} segments[NFAPI_TX_MAX_SEGMENTS];
-} nfapi_tx_request_pdu_t;
-
-#define NFAPI_TX_MAX_PDU 100
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_pdus;
-	nfapi_tx_request_pdu_t* tx_pdu_list;
-} nfapi_tx_request_body_t;
-#define NFAPI_TX_REQUEST_BODY_TAG 0x2022
-
-// P7 Message Structures
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint32_t t1;
-	int32_t delta_sfn_sf;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_dl_node_sync_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint32_t t1;
-	uint32_t t2;
-	uint32_t t3;	
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_ul_node_sync_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint32_t last_sfn_sf;
-	uint32_t time_since_last_timing_info;
-	uint32_t dl_config_jitter;
-	uint32_t tx_request_jitter;
-	uint32_t ul_config_jitter;
-	uint32_t hi_dci0_jitter;
-	int32_t dl_config_latest_delay;
-	int32_t tx_request_latest_delay;
-	int32_t ul_config_latest_delay;
-	int32_t hi_dci0_latest_delay;
-	int32_t dl_config_earliest_arrival;
-	int32_t tx_request_earliest_arrival;
-	int32_t ul_config_earliest_arrival;
-	int32_t hi_dci0_earliest_arrival;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_timing_info_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint32_t handle;
-	uint16_t rnti;
-} nfapi_rx_ue_information;
-#define NFAPI_RX_UE_INFORMATION_TAG 0x2038
-
-typedef struct { 
-	uint8_t value_0;
-	uint8_t value_1;
-} nfapi_harq_indication_tdd_harq_data_bundling_t;
-
-typedef struct { 
-	uint8_t value_0;
-	uint8_t value_1;
-	uint8_t value_2;
-	uint8_t value_3;
-} nfapi_harq_indication_tdd_harq_data_multiplexing_t;
-
-typedef struct { 
-	uint8_t value_0;
-} nfapi_harq_indication_tdd_harq_data_special_bundling_t;
-
-typedef struct { 
-	uint8_t value_0;
-} nfapi_harq_indication_tdd_harq_data_t;
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint8_t mode;
-	uint8_t number_of_ack_nack;
-	union{
-		nfapi_harq_indication_tdd_harq_data_bundling_t			bundling;
-		nfapi_harq_indication_tdd_harq_data_multiplexing_t		multiplex;
-		nfapi_harq_indication_tdd_harq_data_special_bundling_t	special_bundling;
-	} harq_data;
-} nfapi_harq_indication_tdd_rel8_t;
-#define NFAPI_HARQ_INDICATION_TDD_REL8_TAG 0x2027
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t mode;
-	uint8_t number_of_ack_nack;
-	union{
-		nfapi_harq_indication_tdd_harq_data_t	bundling;
-		nfapi_harq_indication_tdd_harq_data_t	multiplex;
-		nfapi_harq_indication_tdd_harq_data_special_bundling_t	special_bundling;
-		nfapi_harq_indication_tdd_harq_data_t	channel_selection;
-		nfapi_harq_indication_tdd_harq_data_t	format_3;
-	} harq_data[NFAPI_MAX_NUMBER_ACK_NACK_TDD];
-} nfapi_harq_indication_tdd_rel9_t;
-#define NFAPI_HARQ_INDICATION_TDD_REL9_TAG 0x2028
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t mode;
-	uint16_t number_of_ack_nack;
-	union{
-		nfapi_harq_indication_tdd_harq_data_t					bundling;
-		nfapi_harq_indication_tdd_harq_data_t					multiplex;
-		nfapi_harq_indication_tdd_harq_data_special_bundling_t	special_bundling;
-		nfapi_harq_indication_tdd_harq_data_t					channel_selection;
-		nfapi_harq_indication_tdd_harq_data_t			format_3;
-		nfapi_harq_indication_tdd_harq_data_t			format_4;
-		nfapi_harq_indication_tdd_harq_data_t			format_5;
-	} harq_data[NFAPI_MAX_NUMBER_ACK_NACK_TDD];
-} nfapi_harq_indication_tdd_rel13_t;
-#define NFAPI_HARQ_INDICATION_TDD_REL13_TAG 0x204F
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint8_t harq_tb1;
-	uint8_t harq_tb2;
-} nfapi_harq_indication_fdd_rel8_t;
-#define NFAPI_HARQ_INDICATION_FDD_REL8_TAG 0x2029
-
-#define NFAPI_HARQ_ACK_NACK_REL9_MAX 10
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t mode;
-	uint8_t number_of_ack_nack;
-	uint8_t harq_tb_n[NFAPI_HARQ_ACK_NACK_REL9_MAX];
-} nfapi_harq_indication_fdd_rel9_t;
-#define NFAPI_HARQ_INDICATION_FDD_REL9_TAG 0x202a
-
-#define NFAPI_HARQ_ACK_NACK_REL13_MAX 22 // Need to check this max?
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t mode;
-	uint16_t number_of_ack_nack;
-	uint8_t harq_tb_n[NFAPI_HARQ_ACK_NACK_REL13_MAX];
-} nfapi_harq_indication_fdd_rel13_t;
-#define NFAPI_HARQ_INDICATION_FDD_REL13_TAG 0x2050
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t ul_cqi;
-	uint8_t channel;
-} nfapi_ul_cqi_information_t;
-#define NFAPI_UL_CQI_INFORMATION_TAG 0x2052
-
-// Only expect 1 harq_indication TLV.tag to be set
-// Would this be a better a an union, but not clear which combinations
-// are valid
-typedef struct {
-	uint16_t							instance_length;
-	nfapi_rx_ue_information				rx_ue_information;
-	nfapi_harq_indication_tdd_rel8_t	harq_indication_tdd_rel8;
-	nfapi_harq_indication_tdd_rel9_t	harq_indication_tdd_rel9;
-	nfapi_harq_indication_tdd_rel13_t	harq_indication_tdd_rel13;
-	nfapi_harq_indication_fdd_rel8_t	harq_indication_fdd_rel8;
-	nfapi_harq_indication_fdd_rel9_t	harq_indication_fdd_rel9;
-	nfapi_harq_indication_fdd_rel13_t	harq_indication_fdd_rel13;
-	nfapi_ul_cqi_information_t			ul_cqi_information;
-} nfapi_harq_indication_pdu_t;
-
-#define NFAPI_HARQ_IND_MAX_PDU 100
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_harqs;
-	nfapi_harq_indication_pdu_t* harq_pdu_list;
-} nfapi_harq_indication_body_t;
-#define NFAPI_HARQ_INDICATION_BODY_TAG 0x2026
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t crc_flag;
-} nfapi_crc_indication_rel8_t;
-#define NFAPI_CRC_INDICATION_REL8_TAG 0x202c
-
-typedef struct {
-	uint16_t					instance_length;
-	nfapi_rx_ue_information		rx_ue_information;
-	nfapi_crc_indication_rel8_t	crc_indication_rel8;
-} nfapi_crc_indication_pdu_t;
-
-#define NFAPI_CRC_IND_MAX_PDU 100
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_crcs;
-	nfapi_crc_indication_pdu_t* crc_pdu_list;
-} nfapi_crc_indication_body_t;
-#define NFAPI_CRC_INDICATION_BODY_TAG 0x202b
-
-typedef struct {
-	uint16_t					instance_length;
-	nfapi_rx_ue_information		rx_ue_information;
-	nfapi_ul_cqi_information_t	ul_cqi_information;
-} nfapi_sr_indication_pdu_t;
-
-#define NFAPI_SR_IND_MAX_PDU 100
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_srs;				// Question : should this be srs
-	nfapi_sr_indication_pdu_t* sr_pdu_list;
-} nfapi_sr_indication_body_t;
-#define NFAPI_SR_INDICATION_BODY_TAG 0x202d
-
-// The data offset should be set to 0 or 1 before encoding
-// If it is set to 1 the nfapi library will detemine the correct offset
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t data_offset;
-	uint8_t ul_cqi;
-	uint8_t ri;
-	uint16_t timing_advance;
-} nfapi_cqi_indication_rel8_t;
-#define NFAPI_CQI_INDICATION_REL8_TAG 0x202f
-
-#define NFAPI_CC_MAX 4
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t data_offset;
-	uint8_t ul_cqi;
-	uint8_t number_of_cc_reported;
-	uint8_t ri[NFAPI_CC_MAX];
-	uint16_t timing_advance;
-	uint16_t timing_advance_r9;
-} nfapi_cqi_indication_rel9_t;
-#define NFAPI_CQI_INDICATION_REL9_TAG 0x2030
-
-typedef struct {
-	uint16_t					instance_length;
-	nfapi_rx_ue_information		rx_ue_information;
-	nfapi_cqi_indication_rel8_t cqi_indication_rel8;
-	nfapi_cqi_indication_rel9_t cqi_indication_rel9;
-	nfapi_ul_cqi_information_t	ul_cqi_information;
-} nfapi_cqi_indication_pdu_t;
-
-#define NFAPI_CQI_RAW_MAX_LEN 12
-typedef struct {
-	uint8_t pdu[NFAPI_CQI_RAW_MAX_LEN];
-} nfapi_cqi_indication_raw_pdu_t;
-
-#define NFAPI_CQI_IND_MAX_PDU 100
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_cqis;
-	nfapi_cqi_indication_pdu_t*			cqi_pdu_list;
-	nfapi_cqi_indication_raw_pdu_t*		cqi_raw_pdu_list;
-} nfapi_cqi_indication_body_t;
-#define NFAPI_CQI_INDICATION_BODY_TAG 0x202e
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint16_t rnti;
-	uint8_t preamble;
-	uint16_t timing_advance;
-} nfapi_preamble_pdu_rel8_t;
-#define NFAPI_PREAMBLE_REL8_TAG 0x2032
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t timing_advance_r9;
-} nfapi_preamble_pdu_rel9_t;
-#define NFAPI_PREAMBLE_REL9_TAG 0x2033
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t rach_resource_type;
-} nfapi_preamble_pdu_rel13_t;
-#define NFAPI_PREAMBLE_REL13_TAG 0x2051
-
-typedef struct { 
-	uint16_t					instance_length;
-	nfapi_preamble_pdu_rel8_t	preamble_rel8;
-	nfapi_preamble_pdu_rel9_t	preamble_rel9;
-	nfapi_preamble_pdu_rel13_t	preamble_rel13;
-} nfapi_preamble_pdu_t;
-
-#define NFAPI_PREAMBLE_MAX_PDU 100
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_preambles;
-	nfapi_preamble_pdu_t*			preamble_list;
-} nfapi_rach_indication_body_t;
-#define NFAPI_RACH_INDICATION_BODY_TAG 0x2031
-
-#define NFAPI_NUM_RB_MAX 1000
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t doppler_estimation;
-	uint16_t timing_advance;
-	uint8_t number_of_resource_blocks;
-	uint8_t rb_start;
-	uint8_t snr[NFAPI_NUM_RB_MAX];
-} nfapi_srs_indication_fdd_rel8_t;
-#define NFAPI_SRS_INDICATION_FDD_REL8_TAG 0x2035
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint16_t timing_advance_r9;
-} nfapi_srs_indication_fdd_rel9_t;
-#define NFAPI_SRS_INDICATION_FDD_REL9_TAG 0x2036
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint8_t uppts_symbol;
-} nfapi_srs_indication_ttd_rel10_t;
-#define NFAPI_SRS_INDICATION_TDD_REL10_TAG 0x2037
-
-typedef struct { 
-	nfapi_tl_t tl;
-	uint16_t ul_rtoa;
-} nfapi_srs_indication_fdd_rel11_t;
-#define NFAPI_SRS_INDICATION_FDD_REL11_TAG 0x2053
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t num_prb_per_subband;
-	uint8_t number_of_subbands;
-	uint8_t num_atennas;
-	struct {
-		uint8_t subband_index;
-		uint16_t channel[NFAPI_MAX_NUM_PHYSICAL_ANTENNAS];
-	} subands[NFAPI_MAX_NUM_SUBBANDS];
-} nfapi_tdd_channel_measurement_t;
-#define NFAPI_TDD_CHANNEL_MEASUREMENT_TAG 0x2054
-
-typedef struct {
-	uint16_t							instance_length;
-	nfapi_rx_ue_information				rx_ue_information;
-	nfapi_srs_indication_fdd_rel8_t		srs_indication_fdd_rel8;
-	nfapi_srs_indication_fdd_rel9_t		srs_indication_fdd_rel9;
-	nfapi_srs_indication_ttd_rel10_t	srs_indication_tdd_rel10;
-	nfapi_srs_indication_fdd_rel11_t	srs_indication_fdd_rel11;
-	nfapi_tdd_channel_measurement_t		tdd_channel_measurement;
-} nfapi_srs_indication_pdu_t;
-
-#define NFAPI_SRS_IND_MAX_PDU 16
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t number_of_ues;
-	nfapi_srs_indication_pdu_t* srs_pdu_list;
-} nfapi_srs_indication_body_t;
-#define NFAPI_SRS_INDICATION_BODY_TAG 0x2034
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t offset;
-	uint8_t ul_cqi;
-	uint16_t timing_advance;
-} nfapi_rx_indication_rel8_t;
-#define NFAPI_RX_INDICATION_REL8_TAG 0x2024
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t timing_advance_r9;
- } nfapi_rx_indication_rel9_t;
-#define NFAPI_RX_INDICATION_REL9_TAG 0x2025
-
-typedef struct {
-	nfapi_rx_ue_information rx_ue_information;
-	nfapi_rx_indication_rel8_t rx_indication_rel8;
-	nfapi_rx_indication_rel9_t rx_indication_rel9;
-	uint8_t* data;
-} nfapi_rx_indication_pdu_t;
-
-#define NFAPI_RX_IND_MAX_PDU 100
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_pdus;
-	nfapi_rx_indication_pdu_t* rx_pdu_list;
-} nfapi_rx_indication_body_t;
-#define NFAPI_RX_INDICATION_BODY_TAG 0x2023
-
-typedef struct {
-	nfapi_tl_t tl;	
-	uint8_t harq_tb1;
-} nfapi_nb_harq_indication_fdd_rel13_t;
-#define NFAPI_NB_HARQ_INDICATION_FDD_REL13_TAG 0x2064
-
-typedef struct {
-	uint16_t								instance_length;
-	nfapi_rx_ue_information					rx_ue_information;
-	nfapi_nb_harq_indication_fdd_rel13_t	nb_harq_indication_fdd_rel13;
-	nfapi_ul_cqi_information_t				ul_cqi_information;
-} nfapi_nb_harq_indication_pdu_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_harqs;
-	nfapi_nb_harq_indication_pdu_t* nb_harq_pdu_list;
-} nfapi_nb_harq_indication_body_t;
-#define NFAPI_NB_HARQ_INDICATION_BODY_TAG 0x2063
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t rnti;
-	uint8_t initial_sc;
-	uint16_t timing_advance;
-	uint8_t nrach_ce_level;
-} nfapi_nrach_indication_pdu_rel13_t;
-#define NFAPI_NRACH_INDICATION_REL13_TAG 0x2066
-
-typedef struct {
-	nfapi_nrach_indication_pdu_rel13_t		nrach_indication_rel13;
-} nfapi_nrach_indication_pdu_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t number_of_initial_scs_detected;
-	nfapi_nrach_indication_pdu_t* nrach_pdu_list;
-} nfapi_nrach_indication_body_t;
-#define NFAPI_NRACH_INDICATION_BODY_TAG 0x2065
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint32_t handle;
-	uint32_t mp_cca;
-	uint32_t n_cca;
-	uint32_t offset;
-	uint32_t lte_txop_sf;
-	uint16_t txop_sfn_sf_end;
-	uint32_t lbt_mode;
-} nfapi_lbt_pdsch_req_pdu_rel13_t;
-#define NFAPI_LBT_PDSCH_REQ_PDU_REL13_TAG 0x2056
-
-typedef struct {
-	nfapi_lbt_pdsch_req_pdu_rel13_t lbt_pdsch_req_pdu_rel13;
-} nfapi_lbt_pdsch_req_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint32_t handle;
-	uint32_t offset;
-	uint16_t sfn_sf_end;
-	uint32_t lbt_mode;
-} nfapi_lbt_drs_req_pdu_rel13_t;
-#define NFAPI_LBT_DRS_REQ_PDU_REL13_TAG 0x2057
-
-typedef struct {
-	nfapi_lbt_drs_req_pdu_rel13_t lbt_drs_req_pdu_rel13;
-} nfapi_lbt_drs_req_pdu;
-
-typedef struct {
-	uint8_t pdu_type;
-	uint8_t pdu_size;
-	union {
-		nfapi_lbt_pdsch_req_pdu		lbt_pdsch_req_pdu;
-		nfapi_lbt_drs_req_pdu		lbt_drs_req_pdu;
-	};
-} nfapi_lbt_dl_config_request_pdu_t;
-
-#define NFAPI_LBT_DL_CONFIG_REQ_MAX_PDU 16
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_pdus;
-	nfapi_lbt_dl_config_request_pdu_t*		lbt_dl_config_req_pdu_list;
-} nfapi_lbt_dl_config_request_body_t;
-#define NFAPI_LBT_DL_CONFIG_REQUEST_BODY_TAG 0x2055
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint32_t handle;
-	uint32_t result;
-	uint32_t lte_txop_symbols;
-	uint32_t initial_partial_sf;
-} nfapi_lbt_pdsch_rsp_pdu_rel13_t;
-#define NFAPI_LBT_PDSCH_RSP_PDU_REL13_TAG 0x2059
-
-typedef struct {
-	nfapi_lbt_pdsch_rsp_pdu_rel13_t lbt_pdsch_rsp_pdu_rel13;
-} nfapi_lbt_pdsch_rsp_pdu;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint32_t handle;
-	uint32_t result;
-} nfapi_lbt_drs_rsp_pdu_rel13_t;
-#define NFAPI_LBT_DRS_RSP_PDU_REL13_TAG 0x205A
-
-typedef struct {
-	nfapi_lbt_drs_rsp_pdu_rel13_t lbt_drs_rsp_pdu_rel13;
-} nfapi_lbt_drs_rsp_pdu;
-
-
-typedef struct {
-	uint8_t pdu_type;
-	uint8_t pdu_size;
-	union {
-		nfapi_lbt_pdsch_rsp_pdu		lbt_pdsch_rsp_pdu;
-		nfapi_lbt_drs_rsp_pdu		lbt_drs_rsp_pdu;
-	};
-} nfapi_lbt_dl_indication_pdu_t;
-
-#define NFAPI_LBT_IND_MAX_PDU 16
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_pdus;
-	nfapi_lbt_dl_indication_pdu_t* lbt_indication_pdu_list;
-} nfapi_lbt_dl_indication_body_t;
-#define NFAPI_LBT_DL_INDICATION_BODY_TAG 0x2058
-
-typedef struct {
-} nfapi_error_indication_msg_invalid_state;
-
-typedef struct {
-} nfapi_error_indication_msg_bch_missing;
-
-typedef struct {
-	uint16_t recieved_sfn_sf;
-	uint16_t expected_sfn_sf;
-} nfapi_error_indication_sfn_out_of_sync;
-
-typedef struct {
-	uint8_t sub_error_code;
-	uint8_t direction;
-	uint16_t rnti;
-	uint8_t pdu_type;
-} nfapi_error_indication_msg_pdu_err;
-
-typedef struct {
-	uint16_t recieved_sfn_sf;
-	uint16_t expected_sfn_sf;
-} nfapi_error_indication_msg_invalid_sfn;
-
-typedef struct {
-	uint8_t sub_error_code;
-	uint8_t phich_lowest_ul_rb_index;
-} nfapi_error_indication_msg_hi_err;
-
-typedef struct {
-	uint8_t sub_error_code;
-	uint16_t pdu_index;
-} nfapi_error_indication_msg_tx_err;
-
-// 
-// P4 Message Structures
-//
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t frequency_band_indicator;
-	uint16_t measurement_period;
-	uint8_t bandwidth;
-	uint32_t timeout;
-	uint8_t number_of_earfcns;
-	uint16_t earfcn[NFAPI_MAX_CARRIER_LIST];
-} nfapi_lte_rssi_request_t;
-
-#define NFAPI_LTE_RSSI_REQUEST_TAG 0x3000
-
-#define NFAPI_P4_START_TAG NFAPI_LTE_RSSI_REQUEST_TAG
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t frequency_band_indicator;
-	uint16_t measurement_period;
-	uint32_t timeout;
-	uint8_t number_of_uarfcns;
-	uint16_t uarfcn[NFAPI_MAX_CARRIER_LIST];
-} nfapi_utran_rssi_request_t;
-
-#define NFAPI_UTRAN_RSSI_REQUEST_TAG 0x3001
-
-typedef struct {
-	uint16_t arfcn;
-	uint8_t direction;
-} nfapi_arfcn_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t frequency_band_indicator;
-	uint16_t measurement_period;
-	uint32_t timeout;
-	uint8_t number_of_arfcns;
-	nfapi_arfcn_t arfcn[NFAPI_MAX_CARRIER_LIST];
-} nfapi_geran_rssi_request_t;
-
-#define NFAPI_GERAN_RSSI_REQUEST_TAG 0x3002
-
-
-
-typedef struct {
-	uint16_t earfcn;
-	uint8_t number_of_ro_dl;
-	uint8_t ro_dl[NFAPI_MAX_RO_DL];
-} nfapi_earfcn_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t frequency_band_indicator;
-	uint16_t measurement_period;
-	uint32_t timeout;
-	uint8_t number_of_earfcns;
-	nfapi_earfcn_t earfcn[NFAPI_MAX_CARRIER_LIST];
-} nfapi_nb_iot_rssi_request_t;
-
-#define NFAPI_NB_IOT_RSSI_REQUEST_TAG 0x3020
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_rssi;
-	int16_t rssi[NFAPI_MAX_RSSI];
-} nfapi_rssi_indication_body_t;
-
-#define NFAPI_RSSI_INDICATION_TAG 0x3003
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint8_t measurement_bandwidth;
-	uint8_t exhaustive_search;
-	uint32_t timeout;
-	uint8_t number_of_pci;
-	uint16_t pci[NFAPI_MAX_PCI_LIST];
-} nfapi_lte_cell_search_request_t;
-
-#define NFAPI_LTE_CELL_SEARCH_REQUEST_TAG 0x3004
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t uarfcn;
-	uint8_t exhaustive_search;
-	uint32_t timeout;
-	uint8_t number_of_psc;
-	uint16_t psc[NFAPI_MAX_PSC_LIST];
-} nfapi_utran_cell_search_request_t;
-
-#define NFAPI_UTRAN_CELL_SEARCH_REQUEST_TAG 0x3005
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint32_t timeout;
-	uint8_t number_of_arfcn;
-	uint16_t arfcn[NFAPI_MAX_ARFCN_LIST];
-} nfapi_geran_cell_search_request_t;
-
-#define NFAPI_GERAN_CELL_SEARCH_REQUEST_TAG 0x3006
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint8_t ro_dl;
-	uint8_t exhaustive_search;
-	uint32_t timeout;
-	uint8_t number_of_pci;
-	uint16_t pci[NFAPI_MAX_PCI_LIST];
-} nfapi_nb_iot_cell_search_request_t;
-
-#define NFAPI_NB_IOT_CELL_SEARCH_REQUEST_TAG 0x3021
-
-typedef struct {
-	uint16_t pci;
-	uint8_t rsrp;
-	uint8_t rsrq;
-	int16_t frequency_offset;
-} nfapi_lte_found_cell_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_lte_cells_found;
-	nfapi_lte_found_cell_t lte_found_cells[NFAPI_MAX_LTE_CELLS_FOUND];
-} nfapi_lte_cell_search_indication_t;
-
-#define NFAPI_LTE_CELL_SEARCH_INDICATION_TAG 0x3007
-
-typedef struct {
-	uint16_t psc;
-	uint8_t rscp;
-	uint8_t ecno;
-	int16_t frequency_offset;
-} nfapi_utran_found_cell_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_utran_cells_found;
-	nfapi_utran_found_cell_t utran_found_cells[NFAPI_MAX_UTRAN_CELLS_FOUND];
-} nfapi_utran_cell_search_indication_t;
-
-#define NFAPI_UTRAN_CELL_SEARCH_INDICATION_TAG 0x3008
-
-typedef struct {
-	uint16_t arfcn;
-	uint8_t bsic;
-	uint8_t rxlev;
-	uint8_t rxqual;
-	int16_t frequency_offset;
-	uint32_t sfn_offset;
-} nfapi_gsm_found_cell_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_gsm_cells_found;
-	nfapi_gsm_found_cell_t gsm_found_cells[NFAPI_MAX_GSM_CELLS_FOUND];
-} nfapi_geran_cell_search_indication_t;
-
-#define NFAPI_GERAN_CELL_SEARCH_INDICATION_TAG 0x3009
-
-typedef struct {
-	uint16_t pci;
-	uint8_t rsrp;
-	uint8_t rsrq;
-	int16_t frequency_offset;
-} nfapi_nb_iot_found_cell_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t number_of_nb_iot_cells_found;
-	nfapi_nb_iot_found_cell_t nb_iot_found_cells[NFAPI_MAX_NB_IOT_CELLS_FOUND];
-} nfapi_nb_iot_cell_search_indication_t;
-
-#define NFAPI_NB_IOT_CELL_SEARCH_INDICATION_TAG 0x3022
-
-typedef nfapi_opaqaue_data_t nfapi_pnf_cell_search_state_t;
-
-#define NFAPI_PNF_CELL_SEARCH_STATE_TAG 0x300A
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint16_t pci;
-	uint32_t timeout;
-} nfapi_lte_broadcast_detect_request_t;
-
-#define NFAPI_LTE_BROADCAST_DETECT_REQUEST_TAG 0x300B
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t uarfcn;
-	uint16_t psc;
-	uint32_t timeout;
-} nfapi_utran_broadcast_detect_request_t;
-
-#define NFAPI_UTRAN_BROADCAST_DETECT_REQUEST_TAG 0x300C
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint8_t ro_dl;
-	uint16_t pci;
-	uint32_t timeout;
-} nfapi_nb_iot_broadcast_detect_request_t;
-
-#define NFAPI_NB_IOT_BROADCAST_DETECT_REQUEST_TAG 0x3023
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t number_of_tx_antenna;
-	uint16_t mib_length;
-	uint8_t mib[NFAPI_MAX_MIB_LENGTH];
-	uint32_t sfn_offset;
-} nfapi_lte_broadcast_detect_indication_t;
-
-#define NFAPI_LTE_BROADCAST_DETECT_INDICATION_TAG 0x300E
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t mib_length;
-	uint8_t mib[NFAPI_MAX_MIB_LENGTH];
-	uint32_t sfn_offset;
-} nfapi_utran_broadcast_detect_indication_t;
-
-#define NFAPI_UTRAN_BROADCAST_DETECT_INDICATION_TAG 0x300F
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t number_of_tx_antenna;
-	uint16_t mib_length;
-	uint8_t mib[NFAPI_MAX_MIB_LENGTH];
-	uint32_t sfn_offset;
-} nfapi_nb_iot_broadcast_detect_indication_t;
-
-#define NFAPI_NB_IOT_BROADCAST_DETECT_INDICATION_TAG 0x3024
-
-#define NFAPI_PNF_CELL_BROADCAST_STATE_TAG 0x3010
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint16_t pci;
-	uint16_t downlink_channel_bandwidth;
-	uint8_t phich_configuration;
-	uint8_t number_of_tx_antenna;
-	uint8_t retry_count;
-	uint32_t timeout;
-} nfapi_lte_system_information_schedule_request_t;
-
-#define NFAPI_LTE_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG 0x3011
-
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint8_t ro_dl;
-	uint16_t pci;
-	uint8_t scheduling_info_sib1_nb;
-	uint32_t timeout;
-} nfapi_nb_iot_system_information_schedule_request_t;
-
-#define NFAPI_NB_IOT_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG 0x3025
-
-typedef nfapi_opaqaue_data_t nfapi_pnf_cell_broadcast_state_t;
-
-typedef struct {
-	uint8_t si_periodicity;
-	uint8_t si_index;
-} nfapi_lte_system_information_si_periodicity_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint16_t pci;
-	uint16_t downlink_channel_bandwidth;
-	uint8_t phich_configuration;
-	uint8_t number_of_tx_antenna;
-	uint8_t number_of_si_periodicity;
-	nfapi_lte_system_information_si_periodicity_t si_periodicity[NFAPI_MAX_SI_PERIODICITY];
-	uint8_t si_window_length;
-	uint32_t timeout;
-} nfapi_lte_system_information_request_t;
-
-#define NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG 0x3014
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t uarfcn;
-	uint16_t psc;
-	uint32_t timeout;
-} nfapi_utran_system_information_request_t;
-
-#define NFAPI_UTRAN_SYSTEM_INFORMATION_REQUEST_TAG 0x3015
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t arfcn;
-	uint8_t bsic;
-	uint32_t timeout;
-} nfapi_geran_system_information_request_t;
-
-#define NFAPI_GERAN_SYSTEM_INFORMATION_REQUEST_TAG 0x3016
-
-typedef struct {
-	uint8_t si_periodicity;
-	uint8_t si_repetition_pattern;
-	uint8_t si_tb_size;
-	uint8_t number_of_si_index;
-	uint8_t si_index[NFAPI_MAX_SI_INDEX];
-} nfapi_nb_iot_system_information_si_periodicity_t;
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint8_t ro_dl;
-	uint16_t pci;
-	uint8_t number_of_si_periodicity;
-	nfapi_nb_iot_system_information_si_periodicity_t si_periodicity[NFAPI_MAX_SI_PERIODICITY];
-	uint8_t si_window_length;
-	uint32_t timeout;
-} nfapi_nb_iot_system_information_request_t;
-
-#define NFAPI_NB_IOT_SYSTEM_INFORMATION_REQUEST_TAG 0x3027
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t sib_type;
-	uint16_t sib_length;
-	uint8_t sib[NFAPI_MAX_SIB_LENGTH];
-} nfapi_lte_system_information_indication_t;
-
-#define NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG 0x3018
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t sib_length;
-	uint8_t sib[NFAPI_MAX_SIB_LENGTH];
-} nfapi_utran_system_information_indication_t;
-
-#define NFAPI_UTRAN_SYSTEM_INFORMATION_INDICATION_TAG 0x3019
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t si_length;
-	uint8_t si[NFAPI_MAX_SI_LENGTH];
-} nfapi_geran_system_information_indication_t;
-
-#define NFAPI_GERAN_SYSTEM_INFORMATION_INDICATION_TAG 0x301a
-
-typedef struct {
-	nfapi_tl_t tl;
-	uint8_t sib_type;
-	uint16_t sib_length;
-	uint8_t sib[NFAPI_MAX_SIB_LENGTH];
-} nfapi_nb_iot_system_information_indication_t;
-
-#define NFAPI_NB_IOT_SYSTEM_INFORMATION_INDICATION_TAG 0x3026
-
-
-//
-// Top level NFAP messages
-//
-
-//
-// P7
-//
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_dl_config_request_body_t dl_config_request_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_dl_config_request_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_ul_config_request_body_t ul_config_request_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_ul_config_request_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_hi_dci0_request_body_t hi_dci0_request_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_hi_dci0_request_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_tx_request_body_t tx_request_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_tx_request_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-} nfapi_subframe_indication_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_harq_indication_body_t harq_indication_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_harq_indication_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_crc_indication_body_t crc_indication_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_crc_indication_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_sr_indication_body_t sr_indication_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_sr_indication_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_cqi_indication_body_t cqi_indication_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_cqi_indication_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_rach_indication_body_t rach_indication_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_rach_indication_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_srs_indication_body_t srs_indication_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_srs_indication_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_rx_indication_body_t rx_indication_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_rx_indication_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_nb_harq_indication_body_t nb_harq_indication_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_nb_harq_indication_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_nrach_indication_body_t nrach_indication_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_nrach_indication_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_lbt_dl_config_request_body_t lbt_dl_config_request_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_lbt_dl_config_request_t;
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nfapi_lbt_dl_indication_body_t lbt_dl_indication_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_lbt_dl_indication_t;
-
-
-typedef struct {
-	nfapi_p7_message_header_t header;
-	uint8_t message_id;
-	uint8_t error_code;
-	union {
-		nfapi_error_indication_msg_invalid_state	msg_invalid_state;
-		nfapi_error_indication_msg_bch_missing		msg_bch_missing;
-		nfapi_error_indication_sfn_out_of_sync		sfn_out_of_sync;
-		nfapi_error_indication_msg_pdu_err			msg_pdu_err;
-		nfapi_error_indication_msg_invalid_sfn		msg_invalid_sfn;
-		nfapi_error_indication_msg_hi_err			msg_hi_err;
-		nfapi_error_indication_msg_tx_err			msg_tx_err;
-	};
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_error_indication_t;
-
-// 
-// P4 Messages
-// 
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint8_t rat_type;
-	union {
-		nfapi_lte_rssi_request_t					lte_rssi_request;
-		nfapi_utran_rssi_request_t					utran_rssi_request;
-		nfapi_geran_rssi_request_t					geran_rssi_request;
-		nfapi_nb_iot_rssi_request_t					nb_iot_rssi_request;
-	};
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_rssi_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_rssi_response_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_rssi_indication_body_t rssi_indication_body;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_rssi_indication_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint8_t rat_type;
-	union {
-		nfapi_lte_cell_search_request_t				lte_cell_search_request;
-		nfapi_utran_cell_search_request_t			utran_cell_search_request;
-		nfapi_geran_cell_search_request_t			geran_cell_search_request;
-		nfapi_nb_iot_cell_search_request_t			nb_iot_cell_search_request;
-	};
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_cell_search_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_cell_search_response_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_lte_cell_search_indication_t lte_cell_search_indication;
-	nfapi_utran_cell_search_indication_t utran_cell_search_indication;
-	nfapi_geran_cell_search_indication_t geran_cell_search_indication;
-	nfapi_pnf_cell_search_state_t pnf_cell_search_state;
-	nfapi_nb_iot_cell_search_indication_t nb_iot_cell_search_indication;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_cell_search_indication_t;
-
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint8_t rat_type;
-	union {
-		nfapi_lte_broadcast_detect_request_t		lte_broadcast_detect_request;
-		nfapi_utran_broadcast_detect_request_t		utran_broadcast_detect_request;
-		nfapi_nb_iot_broadcast_detect_request_t		nb_iot_broadcast_detect_request;
-	};
-	nfapi_pnf_cell_search_state_t pnf_cell_search_state;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_broadcast_detect_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_broadcast_detect_response_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_lte_broadcast_detect_indication_t lte_broadcast_detect_indication;
-	nfapi_utran_broadcast_detect_indication_t utran_broadcast_detect_indication;
-	nfapi_nb_iot_broadcast_detect_indication_t nb_iot_broadcast_detect_indication;
-	nfapi_pnf_cell_broadcast_state_t pnf_cell_broadcast_state;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_broadcast_detect_indication_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint8_t rat_type;
-	union {
-		nfapi_lte_system_information_schedule_request_t lte_system_information_schedule_request;
-		nfapi_nb_iot_system_information_schedule_request_t nb_iot_system_information_schedule_request;
-	};
-	nfapi_pnf_cell_broadcast_state_t pnf_cell_broadcast_state;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_system_information_schedule_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_system_information_schedule_response_t;
-
-typedef struct { 
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_lte_system_information_indication_t lte_system_information_indication;
-	nfapi_nb_iot_system_information_indication_t nb_iot_system_information_indication;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_system_information_schedule_indication_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint8_t rat_type;
-	union {
-		nfapi_lte_system_information_request_t lte_system_information_request;
-		nfapi_utran_system_information_request_t utran_system_information_request;
-		nfapi_geran_system_information_request_t geran_system_information_request;
-		nfapi_nb_iot_system_information_request_t nb_iot_system_information_request;
-	};
-	nfapi_pnf_cell_broadcast_state_t pnf_cell_broadcast_state;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_system_information_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_system_information_response_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_lte_system_information_indication_t lte_system_information_indication;
-	nfapi_utran_system_information_indication_t utran_system_information_indication;
-	nfapi_geran_system_information_indication_t geran_system_information_indication;
-	nfapi_nb_iot_system_information_indication_t nb_iot_system_information_indication;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_system_information_indication_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_nmm_stop_request_t;
-
-typedef struct {
-	nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_nmm_stop_response_t;
-
-//
-// Configuration options for the encode decode functions
-//
-
-/*! Configuration options for the p7 pack unpack functions
- *
- */
-typedef struct nfapi_p7_codec_config {
-
-	/*! Optional call back to allow the user to define the memory allocator. 
-	 *  \param size The size of the memory to allocate
-	 *  \return a pointer to a valid memory block or 0 if it has failed.
-	 *
-	 * If not set the nfapi unpack functions will use malloc
-	 */
-	void* (*allocate)(size_t size);
-
-	/*! Optional call back to allow the user to define the memory deallocator. 
-	 *  \param ptr A poiner to a memory block allocated by the allocate callback
-	 * 
-	 *	If not set the client should use free
-	 */
-	void (*deallocate)(void* ptr);
-
-	/*! Optional call back function to handle unpacking vendor extension tlv.
-	 *  \param tl A pointer to a decoded tag length structure
-	 *  \param ppReadPackedMsg A handle to the read buffer. 
-	 *  \param end The end of the read buffer
-	 *  \param ve A handle to a vendor extention structure that the call back should allocate if the structure can be decoded
-	 *  \param config A pointer to the p7 codec configuration
-	 *  \return return 0 if packed successfully, -1 if failed.
-	 *
-	 *  If not set the tlv will be skipped
-	 *
-	 *  Client should use the help methods in nfapi.h to decode the vendor extention.
-	 * 
-	 *  \todo Add code example
-	 */
-	int (*unpack_vendor_extension_tlv)(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, void** ve, struct nfapi_p7_codec_config* config);
-
-	/*! Optional call back function to handle packing vendor extension tlv. 
-	 *  \param ve A pointer to a vendor extention structure.
-	 *  \param ppWritePackedMsg A handle to the write buffer
-	 *  \param end The end of the write buffer. The callee should make sure not to write beyond the end
-	 *  \param config A pointer to the p7 codec configuration
-	 *  \return return 0 if packed successfully, -1 if failed.
-	 * 
-	 *  If not set the the tlv will be skipped
-	 * 
-	 *  Client should use the help methods in nfapi.h to encode the vendor extention
-	 * 
-	 *  \todo Add code example
-	 */
-	int (*pack_vendor_extension_tlv)(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, struct nfapi_p7_codec_config* config);
-
-	/*! Optional call back function to handle unpacking vendor extension messages. 
-	 *  \param header A pointer to a decode P7 message header for the vendor extention message
-	 *  \param ppReadPackedMsg A handle to the encoded data buffer
-	 *  \param end A pointer to the end of the encoded data buffer
-	 *  \param config  A pointer to the p7 codec configuration
-	 *  \return 0 if unpacked successfully, -1 if failed
-	 *
-	 *  If not set the message will be ignored
-	 *
-	 *  If the message if is unknown the function should return -1
-	 */
-	int (*unpack_p7_vendor_extension)(nfapi_p7_message_header_t* header, uint8_t **ppReadPackedMsg, uint8_t *end, struct nfapi_p7_codec_config* config);
-
-	/*! Optional call back function to handle packing vendor extension messages. 
-	 *  \param header A poiner to a P7 message structure for the venfor extention message
-	 *  \param ppWritePackedmsg A handle to the buffer to write the encoded message into
-	 *  \param end A pointer to the end of the buffer
-	 *  \param cofig A pointer to the p7 codec configuration
-	 *  \return 0 if packed successfully, -1 if failed
-	 * 
-	 * If not set the the message will be ingored
-	 *	 
-	 *  If the message if is unknown the function should return -1
-	 */
-	int (*pack_p7_vendor_extension)(nfapi_p7_message_header_t* header, uint8_t **ppWritePackedmsg, uint8_t *end, struct nfapi_p7_codec_config* config);
-
-	/*! Optional user data that will be passed back with callbacks
-	 */
-	void* user_data;
-
-} nfapi_p7_codec_config_t;
-
-/*! Configuration options for the p4 & p5 pack unpack functions
- *
- */
-typedef struct nfapi_p4_p5_codec_config {
-
-	/*! Optional call back to allow the user to define the memory allocator.
-     *  \param size The size of the memory to allocate
-	 *  \return a pointer to a valid memory block or 0 if it has failed.
-	 *
-	 *  If not set the nfapi unpack functions will use malloc
-	 */
-	void* (*allocate)(size_t size);
-
-	/*! Optional call back to allow the user to define the memory deallocator. 
-	 *  \param ptr A poiner to a memory block allocated by the allocate callback
-	 *
-	 *  If not set free will be used
-	 */
-	void (*deallocate)(void* ptr);
-
-	/*! Optional call back function to handle unpacking vendor extension tlv.
-	 *  \param tl A pointer to a decoded tag length structure
-	 *  \param ppReadPackedMsg A handle to the data buffer to decode
-	 *  \param end A pointer to the end of the buffer
-	 *  \param ve A handle to a vendor extention structure that will be allocated by this callback
-	 *  \param config A pointer to the P4/P5 codec configuration
-	 *  \return 0 if unpacked successfully, -1 if failed
-	 *  
-	 *  If not set the tlv will be skipped
-	 */
-	int (*unpack_vendor_extension_tlv)(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, void** ve, struct nfapi_p4_p5_codec_config* config);
-
-	/*! Optional call back function to handle packing vendor extension tlv. 
-	 *  \param ve
-	 *  \param ppWritePackedMsg A handle to the data buffer pack the tlv into
-	 *  \param end A pointer to the end of the buffer
-	 *  \param config A pointer to the P4/P5 codec configuration
-	 *  \return 0 if packed successfully, -1 if failed
-	 *
-	 *  If not set the the tlv will be skipped
-	 */
-	int (*pack_vendor_extension_tlv)(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, struct nfapi_p4_p5_codec_config* config);
-
-	/*! Optional call back function to handle unpacking vendor extension messages. 
-	 *  \param header A pointer to a decode P4/P5 message header
-	 *  \param ppReadPackgedMsg A handle to the data buffer to decode
-	 *  \param end A pointer to the end of the buffer
-	 *  \param config A pointer to the P4/P5 codec configuration
-	 *  \return 0 if packed successfully, -1 if failed
-	 *
-	 * If not set the message will be ignored
-	 */
-	int (*unpack_p4_p5_vendor_extension)(nfapi_p4_p5_message_header_t* header, uint8_t **ppReadPackedMsg, uint8_t *end, struct nfapi_p4_p5_codec_config* config);
-
-	/*! Optional call back function to handle packing vendor extension messages.
-	 *  \param header A pointer to the P4/P5 message header to be encoded
-	 *  \param ppWritePackedMsg A handle to the data buffer pack the message into
-	 *  \param end A pointer to the end of the buffer
-	 *  \param config A pointer to the P4/P5 codec configuration
-	 *  \return 0 if packed successfully, -1 if failed
-	 *  
-	 *  If not set the the message will be ingored
-	 */
-	int (*pack_p4_p5_vendor_extension)(nfapi_p4_p5_message_header_t* header, uint8_t **ppwritepackedmsg, uint8_t *end, struct nfapi_p4_p5_codec_config* config);
-
-	/*! Optional user data that will be passed back with callbacks
-	 */
-	void* user_data;
-
-} nfapi_p4_p5_codec_config_t;
-
-//
-// Functions
-// 
-
-/*! \brief Encodes an NFAPI P4 message to a buffer
- *  \param pMessageBuf A pointer to a nfapi p4 message structure
- *  \param messageBufLen The size of the p4 message structure
- *  \param pPackedBuf A pointer to the buffer that the p4 message will be packed into
- *  \param packedBufLen The size of the buffer 
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will encode a nFAPI P4 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf.
- * 
- */
-int nfapi_p4_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
-
-/*! \brief Decodes a NFAPI P4 message header
- *  \param pMessageBuf A pointer to an encoded P4 message header
- *  \param messageBufLen The size of the encoded P4 message header
- *  \param pUnpackedBuf A pointer to the nfapi_message_header
- *  \param unpackedBufLen The size of nfapi_message_header structure.
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will decode a byte stream pointed to by pMessageBuf into a nfapi_p4_p5_message_header structure pointer to by pUnpackedBuf
- */
-int nfapi_p4_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
-
-/*! \brief Decodes a NFAPI P4 message
- *  \param pMessageBuf A pointer to an encoded P4 message
- *  \param messageBufLen The size of the encoded P4 message
- *  \param pUnpackedBuf A pointer to the nfapi_message_header
- *  \param unpackedBufLen The size of nfapi_message_header structure.
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will decode a byte stream pointed to by pMessageBuf into a nfapi p4 message structure pointer to by pUnpackedBuf 
- */
-int nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
-
-/*! \brief Encodes an NFAPI P5 message to a buffer
- *  \param pMessageBuf A pointer to a nfapi p5 message structure
- *  \param messageBufLen The size of the p5 message structure
- *  \param pPackedBuf A pointer to the buffer that the p5 message will be packed into
- *  \param packedBufLen The size of the buffer 
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will encode a nFAPI P5 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf.
- * 
- */
-int nfapi_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nfapi_p4_p5_codec_config_t* config);
-
-/*! \brief Decodes an NFAPI P5 message header
- *  \param pMessageBuf A pointer to an encoded P5 message header
- *  \param messageBufLen The size of the encoded P5 message header
- *  \param pUnpackedBuf A pointer to the nfapi_message_header
- *  \param unpackedBufLen The size of nfapi_message_header structure.
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will decode a byte stream pointed to by pMessageBuf into a nfapi_p4_p5_message_header structure pointer to by pUnpackedBuf
- */
-int nfapi_p5_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
-
-/*! \brief Decodes a NFAPI P5 message
- *  \param pMessageBuf A pointer to an encoded P5 message
- *  \param messageBufLen The size of the encoded P5 message
- *  \param pUnpackedBuf A pointer to the nfapi_message_header
- *  \param unpackedBufLen The size of nfapi_message_header structure.
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will decode a byte stream pointed to by pMessageBuf into a nfapi p5 message structure pointer to by pUnpackedBuf 
- */
-int nfapi_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p4_p5_codec_config_t* config);
-
-/*! \brief Encodes an NFAPI P7 message to a buffer
- *  \param pMessageBuf A pointer to a nfapi p7 message structure
- *  \param pPackedBuf A pointer to the buffer that the p7 message will be packed into
- *  \param packedBufLen The size of the buffer 
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will encode a nFAPI P7 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf.
- * 
- */
-int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config);
-
-/*! \brief Decodes an NFAPI P7 message header
- *  \param pMessageBuf A pointer to an encoded P7 message header
- *  \param messageBufLen The size of the encoded P7 message header
- *  \param pUnpackedBuf A pointer to the nfapi_message_header
- *  \param unpackedBufLen The size of nfapi_message_header structure.
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will decode a byte stream pointed to by pMessageBuf into a nfapi_p7_message_header structure pointer to by pUnpackedBuf
-
- */
-int nfapi_p7_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config);
-
-/*! \brief Decodes a NFAPI P7 message
- *  \param pMessageBuf A pointer to an encoded P7 message
- *  \param messageBufLen The size of the encoded P7 message
- *  \param pUnpackedBuf A pointer to the nfapi_message_header
- *  \param unpackedBufLen The size of nfapi_message_header structure.
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will decode a byte stream pointed to by pMessageBuf into a nfapi p7 message structure pointer to by pUnpackedBuf 
- */
-int nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nfapi_p7_codec_config_t* config);
-
-/*! \brief Calculates the checksum of a  message
- *
- *  \param buffer Pointer to the packed message
- *  \param len The length of the message
- *  \return The checksum. If there is an error the function with return -1
- */
-uint32_t nfapi_p7_calculate_checksum(uint8_t* buffer, uint32_t len);
-
-/*! \brief Calculates & updates the checksum in the message
- *
- *  \param buffer Pointer to the packed message
- *  \param len The length of the message
-  *  \return 0 means success, -1 means failure.
- */
-int nfapi_p7_update_checksum(uint8_t* buffer, uint32_t len);
-
-/*! \brief Updates the transmition time stamp in the p7 message header
- *
- *  \param buffer Pointer to the packed message
- *  \param timestamp The time stamp value
-  *  \return 0 means success, -1 means failure.
- */
-int nfapi_p7_update_transmit_timestamp(uint8_t* buffer, uint32_t timestamp);
-
-#endif /* _NFAPI_INTERFACE_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 fc35bc761932a2ac5cfde587b5aa64401b004e0d..560ae4b3c24a4184a88e78b0bdcb60460a801d0d 100644
--- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h
+++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h
@@ -270,4 +270,36 @@ typedef struct {
   nfapi_vendor_extension_tlv_t              vendor_extension;
 } nfapi_nr_config_request_t;
 
-#endif
\ No newline at end of file
+typedef enum {
+	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;
+
+typedef enum {
+	NFAPI_NR_UL_DCI_FORMAT_0_0 = 0,
+	NFAPI_NR_UL_DCI_FORMAT_1_0,
+} nfapi_nr_ul_dci_format_e;
+
+// P7 Sub Structures
+typedef struct {
+	nfapi_tl_t tl;
+  // conf
+	uint8_t dci_format;
+	uint8_t cce_idx;
+	uint8_t aggregation_level;
+	uint16_t rnti;
+  // DCI fields
+
+} nfapi_nr_dl_config_dci_dl_pdu_rel15_t;
+#define NFAPI_NR_DL_CONFIG_REQUEST_DCI_DL_PDU_REL15_TAG
+
+typedef struct {
+	nfapi_nr_dl_config_dci_dl_pdu_rel15_t dci_dl_pdu_rel15;
+} nfapi_nr_dl_config_dci_dl_pdu;
+
+#endif
+
diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nr_ue_fapi_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nr_ue_fapi_interface.h
deleted file mode 100644
index ecee7c02e3c4999d4588ded9a493d6a9d9952e91..0000000000000000000000000000000000000000
--- a/nfapi/open-nFAPI/nfapi/public_inc/nr_ue_fapi_interface.h
+++ /dev/null
@@ -1,3887 +0,0 @@
-/*
- * Copyright 2017 Cisco Systems, Inc.
- *
- * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
- *
- * 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.
- */
-
-
-#ifndef _NFAPI_INTERFACE_NR_EXTENSION_H_
-#define _NFAPI_INTERFACE_NR_EXTENSION_H_
-#define _NFAPI_INTERFACE_H_
-
-#include "stddef.h"
-
-// Constants - update based on implementation
-#define NR_NFAPI_MAX_PHY_RF_INSTANCES 2
-#define NR_NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH 16
-#define NR_NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH 3
-#define NR_NFAPI_MAX_NUM_RF_BANDS 16
-
-// The following definition control the size of arrays used in the interface.
-// These may be changed if desired. They are used in the encoder to make sure 
-// that the user has not specified a 'count' larger than the max array, and also
-// used by the decoder when decode an array. If the 'count' received is larger
-// than the array it is to be stored in the decode fails.
-#define NR_NFAPI_MAX_NUM_ANTENNAS 8
-#define NR_NFAPI_MAX_NUM_SUBBANDS 13
-#define NR_NFAPI_MAX_BF_VECTORS 8
-#define NR_NFAPI_MAX_CC 1
-#define NR_NFAPI_MAX_NUM_PHYSICAL_ANTENNAS 8
-#define NR_NFAPI_MAX_RSSI 8
-#define NR_NFAPI_MAX_PSC_LIST 32
-#define NR_NFAPI_MAX_PCI_LIST 32
-#define NR_NFAPI_MAX_CARRIER_LIST 32
-#define NR_NFAPI_MAX_ARFCN_LIST 128
-#define NR_NFAPI_MAX_LTE_CELLS_FOUND 8
-#define NR_NFAPI_MAX_UTRAN_CELLS_FOUND 8
-#define NR_NFAPI_MAX_GSM_CELLS_FOUND 8
-#define NR_NFAPI_MAX_NB_IOT_CELLS_FOUND 8
-#define NR_NFAPI_MAX_SI_PERIODICITY 8
-#define NR_NFAPI_MAX_SI_INDEX 8
-#define NR_NFAPI_MAX_MIB_LENGTH 32
-#define NR_NFAPI_MAX_SIB_LENGTH 256
-#define NR_NFAPI_MAX_SI_LENGTH 256
-#define NR_NFAPI_MAX_OPAQUE_DATA 64
-#define NR_NFAPI_MAX_NUM_SCHEDULED_UES 8 // Used in the TPM structure
-#define NR_NFAPI_MAX_PNF_PHY 5
-#define NR_NFAPI_MAX_PNF_PHY_RF_CONFIG 5
-#define NR_NFAPI_MAX_PNF_RF  5
-#define NR_NFAPI_MAX_NMM_FREQUENCY_BANDS 32
-#define NR_NFAPI_MAX_RECEIVED_INTERFERENCE_POWER_RESULTS 100
-#define NR_NFAPI_MAX_UL_DL_CONFIGURATIONS 5
-#define NR_NFAPI_MAX_CSI_RS_RESOURCE_CONFIG 4
-#define NR_NFAPI_MAX_ANTENNA_PORT_COUNT 8
-#define NR_NFAPI_MAX_EPDCCH_PRB 8
-#define NR_NFAPI_MAX_TX_PHYSICAL_ANTENNA_PORTS 8
-#define NR_NFAPI_MAX_NUMBER_ACK_NACK_TDD 8
-#define NR_NFAPI_MAX_RO_DL 8
-
-#define NR_NFAPI_HEADER_LENGTH 8
-#define NR_NFAPI_P7_HEADER_LENGTH 16
-
-#define NR_NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE 0xF000
-#define NR_NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE 0xFFFF
-
-#define NR_NFAPI_VERSION_3_0_11	0x000
-#define NR_NFAPI_VERSION_3_0_12    0x001
-
-#define NR_NFAPI_HALF_FRAME_INDEX_FIRST_HALF 0
-#define NR_NFAPI_HALF_FRAME_INDEX_SECOND_HALF 1
-
-// The IANA agreed port definition of the P5 SCTP VNF enpoint 
-// http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=7701
-#define NR_NFAPI_P5_SCTP_PORT		7701
-
-typedef unsigned int	uint32_t;
-typedef unsigned short	uint16_t;
-typedef unsigned char	uint8_t;
-typedef signed int		int32_t;
-typedef signed short	int16_t;
-typedef signed char		int8_t;
-
-typedef struct {
-	uint16_t phy_id;
-	uint16_t message_id;
-	uint16_t message_length;
-	uint16_t spare;
-} nr_nfapi_p4_p5_message_header_t;
-
-typedef struct {
-	uint16_t phy_id;
-	uint16_t message_id;
-	uint16_t message_length;
-	uint16_t m_segment_sequence; /* This consists of 3 fields - namely, M, Segement & Sequence number*/
-	uint32_t checksum;
-	uint32_t transmit_timestamp;
-} nr_nfapi_p7_message_header_t;
-
-#define NR_NFAPI_PHY_ID_NA 0
-
-//#define NR_NFAPI_P7_GET_MORE(_mss) ( ((_mss) & 0x80) >> 7 )
-//#define NR_NFAPI_P7_GET_SEGMENT(_mss) ( ((_mss) & 0x70) >> 4 )
-#define NR_NFAPI_P7_GET_MORE(_mss) ( ((_mss) & 0x8000) >> 15 )
-#define NR_NFAPI_P7_GET_SEGMENT(_mss) ( ((_mss) & 0x7F00) >> 8 )
-#define NR_NFAPI_P7_GET_SEQUENCE(_mss) ( (_mss) & 0x00FF )
-#define NR_NFAPI_P7_SET_MSS(_more, _segm, _sequ) ( (((_more) & 0x1) << 7) | (((_segm) & 0x7) << 4) | ((_sequ) & 0xF) )
-
-typedef struct {
-	uint16_t tag;
-	uint16_t length;
-} nr_nfapi_tl_t;
-#define NR_NFAPI_TAG_LENGTH_PACKED_LEN 4
-
-// Convenience methods to convert between SFN/SFN formats
-#define NR_NFAPI_SFNSF2DEC(_sfnsf) ((((_sfnsf) >> 4) * 10) + ((_sfnsf) & 0xF))
-#define NR_NFAPI_SFNSFDEC2SFNSF(_sfnsf_dec) ((((_sfnsf_dec) / 10) << 4) | (((_sfnsf_dec) - (((_sfnsf_dec) / 10) * 10)) & 0xF))
-
-#define NR_NFAPI_SFNSF2SFN(_sfnsf) ((_sfnsf) >> 4)
-#define NR_NFAPI_SFNSF2SF(_sfnsf) ((_sfnsf) & 0xF)
-
-#define NR_NFAPI_MAX_SFNSFDEC 10240
-
-typedef nr_nfapi_tl_t* nr_nfapi_vendor_extension_tlv_t;
-
-
-// nFAPI Message IDs
-typedef enum {
-	NR_NFAPI_DL_CONFIG_REQUEST = 0x0080,
-	NR_NFAPI_UL_CONFIG_REQUEST,
-	NR_NFAPI_SUBFRAME_INDICATION,
-	NR_NFAPI_HI_DCI0_REQUEST,
-	NR_NFAPI_TX_REQUEST,
-	NR_NFAPI_HARQ_INDICATION,
-	NR_NFAPI_CRC_INDICATION,
-	NR_NFAPI_RX_ULSCH_INDICATION,
-	NR_NFAPI_RACH_INDICATION,
-	NR_NFAPI_SRS_INDICATION,
-	NR_NFAPI_RX_SR_INDICATION,
-	NR_NFAPI_RX_CQI_INDICATION,
-	NR_NFAPI_LBT_DL_CONFIG_REQUEST,
-	NR_NFAPI_LBT_DL_INDICATION,
-	NR_NFAPI_NB_HARQ_INDICATION,
-	NR_NFAPI_NRACH_INDICATION,
-
-	NR_NFAPI_PNF_PARAM_REQUEST = 0x0100,
-	NR_NFAPI_PNF_PARAM_RESPONSE,
-	NR_NFAPI_PNF_CONFIG_REQUEST,
-	NR_NFAPI_PNF_CONFIG_RESPONSE,
-	NR_NFAPI_PNF_START_REQUEST,
-	NR_NFAPI_PNF_START_RESPONSE,
-	NR_NFAPI_PNF_STOP_REQUEST,
-	NR_NFAPI_PNF_STOP_RESPONSE,
-	NR_NFAPI_PARAM_REQUEST,
-	NR_NFAPI_PARAM_RESPONSE,
-	NR_NFAPI_CONFIG_REQUEST,
-	NR_NFAPI_CONFIG_RESPONSE,
-	NR_NFAPI_START_REQUEST,
-	NR_NFAPI_START_RESPONSE,
-	NR_NFAPI_STOP_REQUEST,
-	NR_NFAPI_STOP_RESPONSE,
-	NR_NFAPI_MEASUREMENT_REQUEST,
-	NR_NFAPI_MEASUREMENT_RESPONSE,
-
-	NR_NFAPI_UL_NODE_SYNC = 0x0180,
-	NR_NFAPI_DL_NODE_SYNC,
-	NR_NFAPI_TIMING_INFO,
-
-
-	NR_NFAPI_RSSI_REQUEST = 0x0200,
-	NR_NFAPI_RSSI_RESPONSE,
-	NR_NFAPI_RSSI_INDICATION,
-	NR_NFAPI_CELL_SEARCH_REQUEST,
-	NR_NFAPI_CELL_SEARCH_RESPONSE,
-	NR_NFAPI_CELL_SEARCH_INDICATION,
-	NR_NFAPI_BROADCAST_DETECT_REQUEST,
-	NR_NFAPI_BROADCAST_DETECT_RESPONSE,
-	NR_NFAPI_BROADCAST_DETECT_INDICATION,
-	NR_NFAPI_SYSTEM_INFORMATION_SCHEDULE_REQUEST,
-	NR_NFAPI_SYSTEM_INFORMATION_SCHEDULE_RESPONSE,
-	NR_NFAPI_SYSTEM_INFORMATION_SCHEDULE_INDICATION,
-	NR_NFAPI_SYSTEM_INFORMATION_REQUEST,
-	NR_NFAPI_SYSTEM_INFORMATION_RESPONSE,
-	NR_NFAPI_SYSTEM_INFORMATION_INDICATION,
-	NR_NFAPI_NMM_STOP_REQUEST,
-	NR_NFAPI_NMM_STOP_RESPONSE,
-
-	NR_NFAPI_VENDOR_EXT_MSG_MIN = 0x0300,
-	NR_NFAPI_VENDOR_EXT_MSG_MAX = 0x03FF,
-
-
-	NR_NFAPI_MAX_MESSAGE_ID,
-} nr_nfapi_message_id_e;
-
-// nFAPI Error Codes
-typedef enum {
-	NR_NFAPI_MSG_OK = 0,
-	NR_NFAPI_MSG_INVALID_STATE,
-	NR_NFAPI_MSG_INVALID_CONFIG,
-	NR_NFAPI_SFN_OUT_OF_SYNC,
-	NR_NFAPI_MSG_SUBFRAME_ERR,
-	NR_NFAPI_MSG_BCH_MISSING,
-	NR_NFAPI_MSG_INVALID_SFN,
-	NR_NFAPI_MSG_HI_ERR,
-	NR_NFAPI_MSG_TX_ERR,
-	
-	NR_NFAPI_LBT_NO_PDU_IN_DL_REQ,
-	NR_NFAPI_LBT_NO_VALID_CONFIG_REQ_RECEIVED,
-	NR_NFAPI_FAPI_E_LBT_SF_SFN_PASSED_END_SF_SFN,
-	NR_NFAPI_FAPI_E_LBT_OVERLAP,
-	NR_NFAPI_MSG_BCH_PRESENT,
-	
-	NR_NFAPI_NBIOT_UNEXPECTED_REQ,
-
-	// This is special return code that indicates that a response has
-	// been send via P9
-	NR_NFAPI_MSG_P9_RESPONSE = 0xAA
-} nr_nfapi_error_code_e;
-
-
-typedef enum {
-	NR_NFAPI_P4_MSG_OK = 100,
-	NR_NFAPI_P4_MSG_INVALID_STATE = 101,
-	NR_NFAPI_P4_MSG_INVALID_CONFIG = 102,
-	NR_NFAPI_P4_MSG_RAT_NOT_SUPPORTED = 103,
-	NR_NFAPI_P4_MSG_NMM_STOP_OK = 200,
-	NR_NFAPI_P4_MSG_NMM_STOP_IGNOREDED = 201,
-	NR_NFAPI_P4_MSG_NMM_STOP_INVALID_STATE = 202,
-	NR_NFAPI_P4_MSG_PROCEDURE_COMPLETE = 300,
-	NR_NFAPI_P4_MSG_PROCEDURE_STOPPED = 301,
-	NR_NFAPI_P4_MSG_PARTIAL_RESULTS = 302,
-	NR_NFAPI_P4_MSG_TIMEOUT = 303
-} nr_nfapi_p4_error_code_e;
-
-// nFAPI enums
-typedef enum {
-	NR_NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE = 0,
-	NR_NFAPI_DL_CONFIG_BCH_PDU_TYPE,
-	NR_NFAPI_DL_CONFIG_MCH_PDU_TYPE,
-	NR_NFAPI_DL_CONFIG_DLSCH_PDU_TYPE,
-	NR_NFAPI_DL_CONFIG_PCH_PDU_TYPE,
-	NR_NFAPI_DL_CONFIG_PRS_PDU_TYPE,
-	NR_NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE,
-	NR_NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE,
-	NR_NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE,
-	NR_NFAPI_DL_CONFIG_NBCH_PDU_TYPE,
-	NR_NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE,
-	NR_NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE
-} nr_nfapi_dl_config_pdu_type_e;
-
-typedef enum {
-	NR_NFAPI_DL_DCI_FORMAT_1 = 0,
-	NR_NFAPI_DL_DCI_FORMAT_1A,
-	NR_NFAPI_DL_DCI_FORMAT_1B,
-	NR_NFAPI_DL_DCI_FORMAT_1C,
-	NR_NFAPI_DL_DCI_FORMAT_1D,
-	NR_NFAPI_DL_DCI_FORMAT_2,
-	NR_NFAPI_DL_DCI_FORMAT_2A,
-	NR_NFAPI_DL_DCI_FORMAT_2B,
-	NR_NFAPI_DL_DCI_FORMAT_2C
-} nr_nfapi_dl_dci_format_e;
-
-typedef enum {
-	NR_NFAPI_UL_DCI_FORMAT_0 = 0,
-	NR_NFAPI_UL_DCI_FORMAT_3,
-	NR_NFAPI_UL_DCI_FORMAT_3A,
-	NR_NFAPI_UL_DCI_FORMAT_4
-} nr_nfapi_ul_dci_format_e;
-
-typedef enum {
-	NR_NFAPI_UL_CONFIG_ULSCH_PDU_TYPE = 0,
-	NR_NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_SRS_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_NULSCH_PDU_TYPE,
-	NR_NFAPI_UL_CONFIG_NRACH_PDU_TYPE,
-} nr_nfapi_ul_config_pdu_type_e;
-
-typedef enum {
-	NR_NFAPI_HI_DCI0_HI_PDU_TYPE = 0,
-	NR_NFAPI_HI_DCI0_DCI_PDU_TYPE,
-	NR_NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE,
-	NR_NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE,
-	NR_NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE,
-} nr_nfapi_hi_dci0_pdu_type_e;
-
-typedef enum {
-	NR_NFAPI_HARQ_ACK = 1,
-	NR_NFAPI_HARQ_NACK,
-	NR_NFAPI_HARQ_ACK_OR_NACK,
-	NR_NFAPI_HARQ_DTX,
-	NR_NFAPI_HARQ_ACK_OR_DTX,
-	NR_NFAPI_HARQ_NACK_OR_DTX,
-	NR_NFAPI_HARQ_ACK_OR_NACK_OR_DTX
-} nr_nfapi_harq_type_e;
-
-typedef enum {
-	NR_NFAPI_CSI_REPORT_TYPE_PERIODIC = 0,
-	NR_NFAPI_CSI_REPORT_TYPE_APERIODIC
-} nr_nfapi_csi_report_type_e;
-
-typedef enum {
-	NR_NFAPI_DL_BW_SUPPORTED_6 = 1,
-	NR_NFAPI_DL_BW_SUPPORTED_15 = 2,
-	NR_NFAPI_DL_BW_SUPPORTED_25 = 4,
-	NR_NFAPI_DL_BW_SUPPORTED_50 = 8,
-	NR_NFAPI_DL_BW_SUPPORTED_75 = 16,
-	NR_NFAPI_DL_BW_SUPPORTED_100 = 32
-} nr_nfapi_dl_bandwith_supported_e;
-
-typedef enum {
-	NR_NFAPI_UL_BW_SUPPORTED_6 = 1,
-	NR_NFAPI_UL_BW_SUPPORTED_15 = 2,
-	NR_NFAPI_UL_BW_SUPPORTED_25 = 4,
-	NR_NFAPI_UL_BW_SUPPORTED_50 = 8,
-	NR_NFAPI_UL_BW_SUPPORTED_75 = 16,
-	NR_NFAPI_UL_BW_SUPPORTED_100 = 32
-} nr_nfapi_ul_bandwith_supported_e;
-
-typedef enum {
-	NR_NFAPI_3GPP_REL_SUPPORTED_8 = 0,
-	NR_NFAPI_3GPP_REL_SUPPORTED_9 = 1,
-	NR_NFAPI_3GPP_REL_SUPPORTED_10 = 2,
-	NR_NFAPI_3GPP_REL_SUPPORTED_11 = 4,
-	NR_NFAPI_3GPP_REL_SUPPORTED_12 = 8,
-  NR_NFAPI_3GPP_REL_SUPPORTED_15 = 64
-} nr_nfapi_3gpp_release_supported_e;
-
-
-typedef enum {
-	NR_NFAPI_DUPLEXING_MODE_TDD = 0,
-	NR_NFAPI_DUPLEXING_MODE_FDD = 1,
-	NR_NFAPI_DUPLEXING_MODE_HD_FDD = 2,
-} nr_nfapi_duplexing_mode_e;
-
-typedef enum {
-	NR_NFAPI_CP_NORMAL = 0,
-	NR_NFAPI_CP_EXTENDED = 1
-} nr_nfapi_cyclic_prefix_type_e;
-
-typedef enum {
-	NR_NFAPI_RAT_TYPE_LTE = 0,
-	NR_NFAPI_RAT_TYPE_UTRAN = 1,
-	NR_NFAPI_RAT_TYPE_GERAN = 2,
-	NR_NFAPI_RAT_TYPE_NB_IOT = 3,
-  NR_NFAPI_RAT_TYPE_NR = 4
-} nr_nfapi_rat_type_e;
-
-typedef enum {
-	NR_NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_BUNDLING,
-	NR_NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_MULIPLEXING,
-	NR_NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_SPECIAL_BUNDLING,
-	NR_NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_CHANNEL_SELECTION,
-	NR_NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_3,
-	NR_NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_4,
-	NR_NFAPI_HARQ_INDICATION_TDD_HARQ_ACK_NACK_FORMAT_FORMAT_5
-} nr_nfapi_harq_indication_tdd_ack_nackformat_e;
-
-
-typedef enum {
-	NR_NFAPI_LBT_DL_CONFIG_REQUEST_PDSCH_PDU_TYPE = 0,
-	NR_NFAPI_LBT_DL_CONFIG_REQUEST_DRS_PDU_TYPE
-} nr_nfapi_lbt_dl_config_pdu_type_e;
-
-typedef enum {
-	NR_NFAPI_LBT_DL_RSP_PDSCH_PDU_TYPE = 0,
-	NR_NFAPI_LBT_DL_RSP_DRS_PDU_TYPE
-} nr_nfapi_lbt_dl_rsp_pdu_type_e;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint32_t length;
-	uint8_t value[NR_NFAPI_MAX_OPAQUE_DATA];
-} nr_nfapi_opaqaue_data_t;
-
-// Utility functions to turn enums into char*
-const char* nr_nfapi_error_code_to_str(nr_nfapi_error_code_e value);
-
-
-// P5 Sub Structures
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t nr_nfapi_sync_mode;
-	uint8_t location_mode;
-	uint16_t location_coordinates_length;
-	uint8_t location_coordinates[NR_NFAPI_PNF_PARAM_GENERAL_LOCATION_LENGTH];
-	uint32_t dl_config_timing;
-	uint32_t tx_timing;
-	uint32_t ul_config_timing;
-	uint32_t hi_dci0_timing;
-	uint16_t maximum_number_phys;
-	uint16_t maximum_total_bandwidth;
-	uint8_t maximum_total_number_dl_layers;
-	uint8_t maximum_total_number_ul_layers;
-	uint8_t shared_bands;
-	uint8_t shared_pa;
-	int16_t maximum_total_power;
-	uint8_t oui[NR_NFAPI_PNF_PARAM_GENERAL_OUI_LENGTH];
-} nr_nfapi_pnf_param_general_t;
-#define NR_NFAPI_PNF_PARAM_GENERAL_TAG 0x1000
-
-
-
-
-
-typedef struct {
-	uint16_t rf_config_index;
-} nr_nfapi_rf_config_info_t;
-
-typedef struct {
-	uint16_t phy_config_index;
-	uint16_t number_of_rfs;
-	nr_nfapi_rf_config_info_t rf_config[NR_NFAPI_MAX_PNF_PHY_RF_CONFIG];
-	uint16_t number_of_rf_exclusions;
-	nr_nfapi_rf_config_info_t excluded_rf_config[NR_NFAPI_MAX_PNF_PHY_RF_CONFIG];
-	uint16_t downlink_channel_bandwidth_supported;
-	uint16_t uplink_channel_bandwidth_supported;
-	uint8_t number_of_dl_layers_supported;
-	uint8_t number_of_ul_layers_supported;
-	uint16_t maximum_3gpp_release_supported;
-	uint8_t nmm_modes_supported;
-} nr_nfapi_pnf_phy_info_t;
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_phys;
-	nr_nfapi_pnf_phy_info_t phy[NR_NFAPI_MAX_PNF_PHY];
-} nr_nfapi_pnf_phy_t;
-#define NR_NFAPI_PNF_PHY_TAG 0x1001
-
-typedef struct {
-	uint16_t phy_config_index;
-	uint16_t transmission_mode_7_supported;
-	uint16_t transmission_mode_8_supported;
-	uint16_t two_antenna_ports_for_pucch;
-	uint16_t transmission_mode_9_supported;
-	uint16_t simultaneous_pucch_pusch;
-	uint16_t four_layer_tx_with_tm3_and_tm4;
-} nr_nfapi_pnf_phy_rel10_info_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_phys;
-	nr_nfapi_pnf_phy_rel10_info_t phy[NR_NFAPI_MAX_PNF_PHY];
-} nr_nfapi_pnf_phy_rel10_t;
-#define NR_NFAPI_PNF_PHY_REL10_TAG 0x100A
-
-typedef struct {
-	uint16_t phy_config_index;
-	uint16_t edpcch_supported;
-	uint16_t multi_ack_csi_reporting;
-	uint16_t pucch_tx_diversity;
-	uint16_t ul_comp_supported;
-	uint16_t transmission_mode_5_supported;
-} nr_nfapi_pnf_phy_rel11_info_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_phys;
-	nr_nfapi_pnf_phy_rel11_info_t phy[NR_NFAPI_MAX_PNF_PHY];
-} nr_nfapi_pnf_phy_rel11_t;
-#define NR_NFAPI_PNF_PHY_REL11_TAG 0x100B
-
-
-typedef struct {
-	uint16_t phy_config_index;
-	uint16_t csi_subframe_set;
-	uint16_t enhanced_4tx_codebook;
-	uint16_t drs_supported;
-	uint16_t ul_64qam_supported;
-	uint16_t transmission_mode_10_supported;
-	uint16_t alternative_bts_indices;
-} nr_nfapi_pnf_phy_rel12_info_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_phys;
-	nr_nfapi_pnf_phy_rel12_info_t phy[NR_NFAPI_MAX_PNF_PHY];
-} nr_nfapi_pnf_phy_rel12_t;
-#define NR_NFAPI_PNF_PHY_REL12_TAG 0x100C
-
-typedef struct {
-	uint16_t phy_config_index;
-	uint16_t pucch_format4_supported;
-	uint16_t pucch_format5_supported;
-	uint16_t more_than_5_ca_support;
-	uint16_t laa_supported;
-	uint16_t laa_ending_in_dwpts_supported;
-	uint16_t laa_starting_in_second_slot_supported;
-	uint16_t beamforming_supported;
-	uint16_t csi_rs_enhancement_supported;
-	uint16_t drms_enhancement_supported;
-	uint16_t srs_enhancement_supported;
-} nr_nfapi_pnf_phy_rel13_info_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_phys;
-	nr_nfapi_pnf_phy_rel13_info_t phy[NR_NFAPI_MAX_PNF_PHY];
-} nr_nfapi_pnf_phy_rel13_t;
-#define NR_NFAPI_PNF_PHY_REL13_TAG 0x100D
-
-typedef struct {
-	uint16_t phy_config_index;
-	uint16_t number_of_rfs;
-	nr_nfapi_rf_config_info_t rf_config[NR_NFAPI_MAX_PNF_PHY_RF_CONFIG];
-	uint16_t number_of_rf_exclusions;
-	nr_nfapi_rf_config_info_t excluded_rf_config[NR_NFAPI_MAX_PNF_PHY_RF_CONFIG];
-	uint8_t number_of_dl_layers_supported;
-	uint8_t number_of_ul_layers_supported;
-	uint16_t maximum_3gpp_release_supported;
-	uint8_t nmm_modes_supported;
-} nr_nfapi_pnf_phy_rel13_nb_iot_info_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_phys;
-	nr_nfapi_pnf_phy_rel13_nb_iot_info_t phy[NR_NFAPI_MAX_PNF_PHY];
-} nr_nfapi_pnf_phy_rel13_nb_iot_t;
-#define NR_NFAPI_PNF_PHY_REL13_NB_IOT_TAG 0x100E
-
-typedef struct {
-  uint16_t phy_config_index;
-} nr_nfapi_pnf_phy_rel15_info_t;
-
-typedef struct {
-  nr_nfapi_tl_t tl;
-  uint16_t number_of_phys;
-  nr_nfapi_pnf_phy_rel15_info_t phy[NR_NFAPI_MAX_PNF_PHY];
-} nr_nfapi_pnf_phy_rel15_t;
-#define NR_NFAPI_PNF_PHY_REL15_TAG 0x100H
-
-
-typedef struct {
-	uint16_t rf_config_index;
-	uint16_t band;
-	int16_t maximum_transmit_power; 
-	int16_t minimum_transmit_power;
-	uint8_t number_of_antennas_suppported;
-	uint32_t minimum_downlink_frequency;
-	uint32_t maximum_downlink_frequency;
-	uint32_t minimum_uplink_frequency;
-	uint32_t maximum_uplink_frequency;
-} nr_nfapi_pnf_rf_info_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_rfs;
-	nr_nfapi_pnf_rf_info_t rf[NR_NFAPI_MAX_PNF_RF];
-} nr_nfapi_pnf_rf_t;
-#define NR_NFAPI_PNF_RF_TAG 0x1002
-
-typedef struct {
-	uint16_t phy_id;
-	uint16_t phy_config_index;
-	uint16_t rf_config_index;
-} nr_nfapi_phy_rf_config_info_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_phy_rf_config_info;
-	nr_nfapi_phy_rf_config_info_t phy_rf_config[NR_NFAPI_MAX_PHY_RF_INSTANCES];
-} nr_nfapi_pnf_phy_rf_config_t;
-#define NR_NFAPI_PNF_PHY_RF_TAG 0x1003
-
-// Generic strucutre for single tlv value.
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t value;
-} nr_nfapi_uint16_tlv_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	int16_t value;
-} nr_nfapi_int16_tlv_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t value;
-} nr_nfapi_uint8_tlv_t;
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t phy_state;
-} nr_nfapi_l1_status;
-
-#define NR_NFAPI_L1_STATUS_PHY_STATE_TAG 0x00FA
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t dl_bandwidth_support;
-	nr_nfapi_uint16_tlv_t ul_bandwidth_support;
-	nr_nfapi_uint16_tlv_t dl_modulation_support;
-	nr_nfapi_uint16_tlv_t ul_modulation_support;
-	nr_nfapi_uint16_tlv_t phy_antenna_capability;
-	nr_nfapi_uint16_tlv_t release_capability;
-	nr_nfapi_uint16_tlv_t mbsfn_capability;
-} nr_nfapi_phy_capabilities_t;
-
-#define NR_NFAPI_PHY_CAPABILITIES_DL_BANDWIDTH_SUPPORT_TAG 0x00C8
-#define NR_NFAPI_PHY_CAPABILITIES_UL_BANDWIDTH_SUPPORT_TAG 0x00C9
-#define NR_NFAPI_PHY_CAPABILITIES_DL_MODULATION_SUPPORT_TAG 0x00CA
-#define NR_NFAPI_PHY_CAPABILITIES_UL_MODULATION_SUPPORT_TAG 0x00CB
-#define NR_NFAPI_PHY_CAPABILITIES_PHY_ANTENNA_CAPABILITY_TAG 0x00CC
-#define NR_NFAPI_PHY_CAPABILITIES_RELEASE_CAPABILITY_TAG 0x00CD
-#define NR_NFAPI_PHY_CAPABILITIES_MBSFN_CAPABILITY_TAG 0x00CE
-
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t data_report_mode;
-	nr_nfapi_uint16_tlv_t sfnsf;
-} nr_nfapi_l23_config_t;
-
-
-#define NR_NFAPI_L23_CONFIG_DATA_REPORT_MODE_TAG 0x00F0
-#define NR_NFAPI_L23_CONFIG_SFNSF_TAG 0x00F1
-
-typedef struct {
-  nr_nfapi_uint16_tlv_t numerology_index_mu;
-	nr_nfapi_uint16_tlv_t duplex_mode;
-	nr_nfapi_uint16_tlv_t pcfich_power_offset;
-	nr_nfapi_uint16_tlv_t pb;
-	nr_nfapi_uint16_tlv_t dl_cyclic_prefix_type;
-	nr_nfapi_uint16_tlv_t ul_cyclic_prefix_type;
-} nr_nfapi_subframe_config_t;
-
-#define NR_NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG 0x0001
-#define NR_NFAPI_SUBFRAME_CONFIG_PCFICH_POWER_OFFSET_TAG 0x0002
-#define NR_NFAPI_SUBFRAME_CONFIG_PB_TAG 0x0003
-#define NR_NFAPI_SUBFRAME_CONFIG_DL_CYCLIC_PREFIX_TYPE_TAG 0x0004
-#define NR_NFAPI_SUBFRAME_CONFIG_UL_CYCLIC_PREFIX_TYPE_TAG 0x0005
-#define NR_NFAPI_SUBFRAME_CONFIG_NUMEROLOGY_INDEX_MU_TAG 0x0006
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t dl_channel_bandwidth;
-	nr_nfapi_uint16_tlv_t ul_channel_bandwidth;
-	nr_nfapi_uint16_tlv_t reference_signal_power;
-	nr_nfapi_uint16_tlv_t tx_antenna_ports;
-	nr_nfapi_uint16_tlv_t rx_antenna_ports;
-} nr_nfapi_rf_config_t;
-
-#define NR_NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG 0x000A
-#define NR_NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG 0x000B
-#define NR_NFAPI_RF_CONFIG_REFERENCE_SIGNAL_POWER_TAG 0x000C
-#define NR_NFAPI_RF_CONFIG_TX_ANTENNA_PORTS_TAG 0x000D
-#define NR_NFAPI_RF_CONFIG_RX_ANTENNA_PORTS_TAG 0x000E
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t phich_resource;
-	nr_nfapi_uint16_tlv_t phich_duration;
-	nr_nfapi_uint16_tlv_t phich_power_offset;
-} nr_nfapi_phich_config_t;
-
-#define NR_NFAPI_PHICH_CONFIG_PHICH_RESOURCE_TAG 0x0014
-#define NR_NFAPI_PHICH_CONFIG_PHICH_DURATION_TAG 0x0015
-#define NR_NFAPI_PHICH_CONFIG_PHICH_POWER_OFFSET_TAG 0x0016
-
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t primary_synchronization_signal_epre_eprers;
-	nr_nfapi_uint16_tlv_t secondary_synchronization_signal_epre_eprers;
-	nr_nfapi_uint16_tlv_t physical_cell_id;
-  nr_nfapi_uint16_tlv_t half_frame_index;
-  nr_nfapi_uint16_tlv_t ssb_subcarrier_offset;
-  nr_nfapi_uint16_tlv_t ssb_position_in_burst;
-  nr_nfapi_uint16_tlv_t ssb_periodicity;
-  nr_nfapi_uint16_tlv_t ss_pbch_block_power;
-  nr_nfapi_uint16_tlv_t n_ssb_crb;
-} nr_nfapi_sch_config_t;
-
-#define NR_NFAPI_SCH_CONFIG_PRIMARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG 0x001E
-#define NR_NFAPI_SCH_CONFIG_SECONDARY_SYNCHRONIZATION_SIGNAL_EPRE_EPRERS_TAG 0x001F
-#define NR_NFAPI_SCH_CONFIG_PHYSICAL_CELL_ID_TAG 0x0020
-#define NR_NFAPI_SCH_CONFIG_HALF_FRAME_INDEX_TAG 0x0021
-#define NR_NFAPI_SCH_CONFIG_SSB_SUBCARRIER_OFFSET_TAG 0x0022
-#define NR_NFAPI_SCH_CONFIG_SSB_POSITION_IN_BURST 0x0023
-#define NR_NFAPI_SCH_CONFIG_SSB_PERIODICITY 0x0024
-#define NR_NFAPI_SCH_CONFIG_SS_PBCH_BLOCK_POWER 0x0025
-#define NR_NFAPI_SCH_CONFIG_N_SSB_CRB 0x0025
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t configuration_index;
-	nr_nfapi_uint16_tlv_t root_sequence_index;
-	nr_nfapi_uint16_tlv_t zero_correlation_zone_configuration;
-	nr_nfapi_uint16_tlv_t high_speed_flag;
-	nr_nfapi_uint16_tlv_t frequency_offset;
-} nr_nfapi_prach_config_t;
-
-#define NR_NFAPI_PRACH_CONFIG_CONFIGURATION_INDEX_TAG 0x0028
-#define NR_NFAPI_PRACH_CONFIG_ROOT_SEQUENCE_INDEX_TAG 0x0029
-#define NR_NFAPI_PRACH_CONFIG_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG 0x002A
-#define NR_NFAPI_PRACH_CONFIG_HIGH_SPEED_FLAG_TAG 0x002B
-#define NR_NFAPI_PRACH_CONFIG_FREQUENCY_OFFSET_TAG 0x002C
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t hopping_mode;
-	nr_nfapi_uint16_tlv_t hopping_offset;
-	nr_nfapi_uint16_tlv_t number_of_subbands;
-} nr_nfapi_pusch_config_t;
-
-#define NR_NFAPI_PUSCH_CONFIG_HOPPING_MODE_TAG 0x0032
-#define NR_NFAPI_PUSCH_CONFIG_HOPPING_OFFSET_TAG 0x0033
-#define NR_NFAPI_PUSCH_CONFIG_NUMBER_OF_SUBBANDS_TAG 0x0034
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t delta_pucch_shift;
-	nr_nfapi_uint16_tlv_t n_cqi_rb;
-	nr_nfapi_uint16_tlv_t n_an_cs;
-	nr_nfapi_uint16_tlv_t n1_pucch_an;
-} nr_nfapi_pucch_config_t;
-
-#define NR_NFAPI_PUCCH_CONFIG_DELTA_PUCCH_SHIFT_TAG 0x003C
-#define NR_NFAPI_PUCCH_CONFIG_N_CQI_RB_TAG 0x003D
-#define NR_NFAPI_PUCCH_CONFIG_N_AN_CS_TAG 0x003E
-#define NR_NFAPI_PUCCH_CONFIG_N1_PUCCH_AN_TAG 0x003F
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t bandwidth_configuration;
-	nr_nfapi_uint16_tlv_t max_up_pts;
-	nr_nfapi_uint16_tlv_t srs_subframe_configuration;
-	nr_nfapi_uint16_tlv_t srs_acknack_srs_simultaneous_transmission;
-} nr_nfapi_srs_config_t;
-
-#define NR_NFAPI_SRS_CONFIG_BANDWIDTH_CONFIGURATION_TAG 0x0046
-#define NR_NFAPI_SRS_CONFIG_MAX_UP_PTS_TAG 0x0047
-#define NR_NFAPI_SRS_CONFIG_SRS_SUBFRAME_CONFIGURATION_TAG 0x0048
-#define NR_NFAPI_SRS_CONFIG_SRS_ACKNACK_SRS_SIMULTANEOUS_TRANSMISSION_TAG 0x0049
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t uplink_rs_hopping;
-	nr_nfapi_uint16_tlv_t group_assignment;
-	nr_nfapi_uint16_tlv_t cyclic_shift_1_for_drms;
-} nr_nfapi_uplink_reference_signal_config_t;
-
-#define NR_NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_UPLINK_RS_HOPPING_TAG 0x0050
-#define NR_NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_GROUP_ASSIGNMENT_TAG 0x0051
-#define NR_NFAPI_UPLINK_REFERENCE_SIGNAL_CONFIG_CYCLIC_SHIFT_1_FOR_DRMS_TAG 0x0052
-
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t ed_threshold_lbt_pdsch;
-	nr_nfapi_uint16_tlv_t ed_threshold_lbt_drs;
-	nr_nfapi_uint16_tlv_t pd_threshold;
-	nr_nfapi_uint16_tlv_t multi_carrier_type;
-	nr_nfapi_uint16_tlv_t multi_carrier_tx;
-	nr_nfapi_uint16_tlv_t multi_carrier_freeze;
-	nr_nfapi_uint16_tlv_t tx_antenna_ports_drs;
-	nr_nfapi_uint16_tlv_t tx_power_drs;
-} nr_nfapi_laa_config_t;
-
-#define NR_NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_PDSCH_TAG 0x0064
-#define NR_NFAPI_LAA_CONFIG_ED_THRESHOLD_FOR_LBT_FOR_DRS_TAG 0x0065
-#define NR_NFAPI_LAA_CONFIG_PD_THRESHOLD_TAG 0x0066
-#define NR_NFAPI_LAA_CONFIG_MULTI_CARRIER_TYPE_TAG 0x0067
-#define NR_NFAPI_LAA_CONFIG_MULTI_CARRIER_TX_TAG 0x0068
-#define NR_NFAPI_LAA_CONFIG_MULTI_CARRIER_FREEZE_TAG 0x0069
-#define NR_NFAPI_LAA_CONFIG_TX_ANTENNA_PORTS_FOR_DRS_TAG 0x006A
-#define NR_NFAPI_LAA_CONFIG_TRANSMISSION_POWER_FOR_DRS_TAG 0x006B
-
-typedef struct {
-
-	nr_nfapi_uint16_tlv_t pbch_repetitions_enable_r13;
-	nr_nfapi_uint16_tlv_t prach_catm_root_sequence_index;
-	nr_nfapi_uint16_tlv_t prach_catm_zero_correlation_zone_configuration;
-	nr_nfapi_uint16_tlv_t prach_catm_high_speed_flag;
-	nr_nfapi_uint16_tlv_t prach_ce_level_0_enable;
-	nr_nfapi_uint16_tlv_t prach_ce_level_0_configuration_index;
-	nr_nfapi_uint16_tlv_t prach_ce_level_0_frequency_offset;
-	nr_nfapi_uint16_tlv_t prach_ce_level_0_number_of_repetitions_per_attempt;
-	nr_nfapi_uint16_tlv_t prach_ce_level_0_starting_subframe_periodicity;
-	nr_nfapi_uint16_tlv_t prach_ce_level_0_hopping_enable;
-	nr_nfapi_uint16_tlv_t prach_ce_level_0_hopping_offset;
-	nr_nfapi_uint16_tlv_t prach_ce_level_1_enable;
-	nr_nfapi_uint16_tlv_t prach_ce_level_1_configuration_index;
-	nr_nfapi_uint16_tlv_t prach_ce_level_1_frequency_offset;
-	nr_nfapi_uint16_tlv_t prach_ce_level_1_number_of_repetitions_per_attempt;
-	nr_nfapi_uint16_tlv_t prach_ce_level_1_starting_subframe_periodicity;
-	nr_nfapi_uint16_tlv_t prach_ce_level_1_hopping_enable;
-	nr_nfapi_uint16_tlv_t prach_ce_level_1_hopping_offset;
-	nr_nfapi_uint16_tlv_t prach_ce_level_2_enable;
-	nr_nfapi_uint16_tlv_t prach_ce_level_2_configuration_index;
-	nr_nfapi_uint16_tlv_t prach_ce_level_2_frequency_offset;
-	nr_nfapi_uint16_tlv_t prach_ce_level_2_number_of_repetitions_per_attempt;
-	nr_nfapi_uint16_tlv_t prach_ce_level_2_starting_subframe_periodicity;
-	nr_nfapi_uint16_tlv_t prach_ce_level_2_hopping_enable;
-	nr_nfapi_uint16_tlv_t prach_ce_level_2_hopping_offset;
-	nr_nfapi_uint16_tlv_t prach_ce_level_3_enable;
-	nr_nfapi_uint16_tlv_t prach_ce_level_3_configuration_index;
-	nr_nfapi_uint16_tlv_t prach_ce_level_3_frequency_offset;
-	nr_nfapi_uint16_tlv_t prach_ce_level_3_number_of_repetitions_per_attempt;
-	nr_nfapi_uint16_tlv_t prach_ce_level_3_starting_subframe_periodicity;
-	nr_nfapi_uint16_tlv_t prach_ce_level_3_hopping_enable;
-	nr_nfapi_uint16_tlv_t prach_ce_level_3_hopping_offset;
-	nr_nfapi_uint16_tlv_t pucch_interval_ulhoppingconfigcommonmodea;
-	nr_nfapi_uint16_tlv_t pucch_interval_ulhoppingconfigcommonmodeb;
-} nr_nfapi_emtc_config_t;
-
-#define NR_NFAPI_EMTC_CONFIG_PBCH_REPETITIONS_ENABLE_R13_TAG 0x0078
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CATM_ROOT_SEQUENCE_INDEX_TAG 0x0079
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CATM_ZERO_CORRELATION_ZONE_CONFIGURATION_TAG 0x007A
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CATM_HIGH_SPEED_FLAG 0x007B
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_ENABLE_TAG 0x007C
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_CONFIGURATION_INDEX_TAG 0x007D
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_FREQUENCY_OFFSET_TAG 0x007E
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x007F
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_STARTING_SUBFRAME_PERIODICITY_TAG 0x0080
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_ENABLE_TAG 0x0081
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_0_HOPPING_OFFSET_TAG 0x0082
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_ENABLE_TAG 0x0083
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_CONFIGURATION_INDEX_TAG 0x0084
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_FREQUENCY_OFFSET_TAG 0x0085
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x0086
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_STARTING_SUBFRAME_PERIODICITY_TAG 0x0087
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_ENABLE_TAG 0x0088
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_1_HOPPING_OFFSET_TAG 0x0089
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_ENABLE_TAG 0x008A
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_CONFIGURATION_INDEX_TAG 0x008B
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_FREQUENCY_OFFSET_TAG 0x008C
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x008D
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_STARTING_SUBFRAME_PERIODICITY_TAG 0x008E
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_ENABLE_TAG 0x008F
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_2_HOPPING_OFFSET_TAG 0x0090
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_ENABLE_TAG 0x0091
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_CONFIGURATION_INDEX_TAG 0x0092
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_FREQUENCY_OFFSET_TAG 0x0093
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x0094
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_STARTING_SUBFRAME_PERIODICITY_TAG 0x0095
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_ENABLE_TAG 0x0096
-#define NR_NFAPI_EMTC_CONFIG_PRACH_CE_LEVEL_3_HOPPING_OFFSET_TAG 0x0097
-#define NR_NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEA_TAG 0x0098
-#define NR_NFAPI_EMTC_CONFIG_PUCCH_INTERVAL_ULHOPPINGCONFIGCOMMONMODEB_TAG 0x0099
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t operating_mode;
-	nr_nfapi_uint16_tlv_t anchor;
-	nr_nfapi_uint16_tlv_t prb_index;
-	nr_nfapi_uint16_tlv_t control_region_size;
-	nr_nfapi_uint16_tlv_t assumed_crs_aps;
-	nr_nfapi_uint16_tlv_t nprach_config_0_enabled;
-	nr_nfapi_uint16_tlv_t nprach_config_0_sf_periodicity;
-	nr_nfapi_uint16_tlv_t nprach_config_0_start_time;
-	nr_nfapi_uint16_tlv_t nprach_config_0_subcarrier_offset;
-	nr_nfapi_uint16_tlv_t nprach_config_0_number_of_subcarriers;
-	nr_nfapi_uint16_tlv_t nprach_config_0_cp_length;
-	nr_nfapi_uint16_tlv_t nprach_config_0_number_of_repetitions_per_attempt;
-	nr_nfapi_uint16_tlv_t nprach_config_1_enabled;
-	nr_nfapi_uint16_tlv_t nprach_config_1_sf_periodicity;
-	nr_nfapi_uint16_tlv_t nprach_config_1_start_time;
-	nr_nfapi_uint16_tlv_t nprach_config_1_subcarrier_offset;
-	nr_nfapi_uint16_tlv_t nprach_config_1_number_of_subcarriers;
-	nr_nfapi_uint16_tlv_t nprach_config_1_cp_length;
-	nr_nfapi_uint16_tlv_t nprach_config_1_number_of_repetitions_per_attempt;
-	nr_nfapi_uint16_tlv_t nprach_config_2_enabled;
-	nr_nfapi_uint16_tlv_t nprach_config_2_sf_periodicity;
-	nr_nfapi_uint16_tlv_t nprach_config_2_start_time;
-	nr_nfapi_uint16_tlv_t nprach_config_2_subcarrier_offset;
-	nr_nfapi_uint16_tlv_t nprach_config_2_number_of_subcarriers;
-	nr_nfapi_uint16_tlv_t nprach_config_2_cp_length;
-	nr_nfapi_uint16_tlv_t nprach_config_2_number_of_repetitions_per_attempt;
-	nr_nfapi_uint16_tlv_t three_tone_base_sequence;
-	nr_nfapi_uint16_tlv_t six_tone_base_sequence;
-	nr_nfapi_uint16_tlv_t twelve_tone_base_sequence;
-	nr_nfapi_uint16_tlv_t three_tone_cyclic_shift;
-	nr_nfapi_uint16_tlv_t six_tone_cyclic_shift;
-	nr_nfapi_uint16_tlv_t dl_gap_config_enable;
-	nr_nfapi_uint16_tlv_t dl_gap_threshold;
-	nr_nfapi_uint16_tlv_t dl_gap_periodicity;
-	nr_nfapi_uint16_tlv_t dl_gap_duration_coefficient;
-} nr_nfapi_nb_iot_config_t;
-
-#define NR_NFAPI_NB_IOT_CONFIG_OPERATING_MODE_TAG 0x00A5
-#define NR_NFAPI_NB_IOT_CONFIG_ANCHOR_TAG 0x00A6
-#define NR_NFAPI_NB_IOT_CONFIG_PRB_INDEX_TAG 0x00A7
-#define NR_NFAPI_NB_IOT_CONFIG_CONTROL_REGION_SIZE_TAG 0x00A8
-#define NR_NFAPI_NB_IOT_CONFIG_ASSUMED_CRS_APS_TAG 0x00A9
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_ENABLED_TAG 0x00AA
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_SF_PERIODICITY_TAG 0x00AB
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_START_TIME_TAG 0x00AC
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_SUBCARRIER_OFFSET_TAG 0x00AD
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_NUMBER_OF_SUBCARRIERS_TAG 0x00AE
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_CP_LENGTH_TAG 0x00AF
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_0_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x00B0
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_ENABLED_TAG 0x00B1
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_SF_PERIODICITY_TAG 0x00B2
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_START_TIME_TAG 0x00B3
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_SUBCARRIER_OFFSET_TAG 0x00B4
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_NUMBER_OF_SUBCARRIERS_TAG 0x00B5
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_CP_LENGTH_TAG 0x00B6
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_1_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x00B7
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_ENABLED_TAG 0x00B8
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_SF_PERIODICITY_TAG 0x00B9
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_START_TIME_TAG 0x00BA
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_SUBCARRIER_OFFSET_TAG 0x00BB
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_NUMBER_OF_SUBCARRIERS_TAG 0x00BC
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_CP_LENGTH_TAG 0x00BD
-#define NR_NFAPI_NB_IOT_CONFIG_NPRACH_CONFIG_2_NUMBER_OF_REPETITIONS_PER_ATTEMPT_TAG 0x00BE
-#define NR_NFAPI_NB_IOT_CONFIG_THREE_TONE_BASE_SEQUENCE_TAG 0x00BF
-#define NR_NFAPI_NB_IOT_CONFIG_SIX_TONE_BASE_SEQUENCE_TAG 0x00C0
-#define NR_NFAPI_NB_IOT_CONFIG_TWELVE_TONE_BASE_SEQUENCE_TAG 0x00C1
-#define NR_NFAPI_NB_IOT_CONFIG_THREE_TONE_CYCLIC_SHIFT_TAG 0x00C2
-#define NR_NFAPI_NB_IOT_CONFIG_SIX_TONE_CYCLIC_SHIFT_TAG 0x00C3
-#define NR_NFAPI_NB_IOT_CONFIG_DL_GAP_CONFIG_ENABLE_TAG 0x00C4
-#define NR_NFAPI_NB_IOT_CONFIG_DL_GAP_THRESHOLD_TAG 0x00C5
-#define NR_NFAPI_NB_IOT_CONFIG_DL_GAP_PERIODICITY_TAG 0x00C6
-#define NR_NFAPI_NB_IOT_CONFIG_DL_GAP_DURATION_COEFFICIENT_TAG 0x00C7
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t laa_support;
-	nr_nfapi_uint16_tlv_t pd_sensing_lbt_support;
-	nr_nfapi_uint16_tlv_t multi_carrier_lbt_support;
-	nr_nfapi_uint16_tlv_t partial_sf_support;
-} nr_nfapi_laa_capability_t;
-
-#define NR_NFAPI_LAA_CAPABILITY_LAA_SUPPORT_TAG 0x00D1
-#define NR_NFAPI_LAA_CAPABILITY_PD_SENSING_LBT_SUPPORT_TAG 0x00D2
-#define NR_NFAPI_LAA_CAPABILITY_MULTI_CARRIER_LBT_SUPPORT_TAG 0x00D3
-#define NR_NFAPI_LAA_CAPABILITY_PARTIAL_SF_SUPPORT_TAG 0x00D4
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t nb_iot_support;
-	nr_nfapi_uint16_tlv_t nb_iot_operating_mode_capability;
-} nr_nfapi_nb_iot_capability_t;
-
-#define NR_NFAPI_LAA_CAPABILITY_NB_IOT_SUPPORT_TAG 0x00D5
-#define NR_NFAPI_LAA_CAPABILITY_NB_IOT_OPERATING_MODE_CAPABILITY_TAG 0x00D6
-
-typedef struct {
-	nr_nfapi_uint16_tlv_t subframe_assignment;
-	nr_nfapi_uint16_tlv_t special_subframe_patterns;
-} nr_nfapi_tdd_frame_structure_t;
-
-#define NR_NFAPI_TDD_FRAME_STRUCTURE_SUBFRAME_ASSIGNMENT_TAG 0x005A
-#define NR_NFAPI_TDD_FRAME_STRUCTURE_SPECIAL_SUBFRAME_PATTERNS_TAG 0x005B
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_rf_bands;
-	uint16_t rf_band[NR_NFAPI_MAX_NUM_RF_BANDS];
-} nr_nfapi_rf_bands_t;
-#define NR_NFAPI_PHY_RF_BANDS_TAG 0x0114
-
-#define NR_NFAPI_IPV4_ADDRESS_LENGTH 4
-#define NR_NFAPI_IPV6_ADDRESS_LENGTH 16
-
-// Convience enum to allow the ip addres type to be distinguished
-typedef enum {
-	NR_NFAPI_IP_ADDRESS_IPV4 = 0,
-	NR_NFAPI_IP_ADDRESS_IPV6
-} nr_nfapi_ip_address_type_e;
-
-// The type could be infered from the length, but it is clearer in 
-// code to have a type variable set
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t type;
-	union {
-		uint8_t ipv4_address[NR_NFAPI_IPV4_ADDRESS_LENGTH];
-		uint8_t ipv6_address[NR_NFAPI_IPV6_ADDRESS_LENGTH];
-	} u;
-} nr_nfapi_ip_address_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t address[NR_NFAPI_IPV4_ADDRESS_LENGTH];
-} nr_nfapi_ipv4_address_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t address[NR_NFAPI_IPV6_ADDRESS_LENGTH];
-} nr_nfapi_ipv6_address_t;
-
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_rf_bands;
-	uint16_t bands[NR_NFAPI_MAX_NMM_FREQUENCY_BANDS];
-} nr_nfapi_nmm_frequency_bands_t;
-
-//These TLVs are used exclusively by nFAPI
-typedef struct
-{
-	// These TLVs are used to setup the transport connection between VNF and PNF
-	nr_nfapi_ipv4_address_t p7_vnf_address_ipv4;
-	nr_nfapi_ipv6_address_t p7_vnf_address_ipv6;
-	nr_nfapi_uint16_tlv_t p7_vnf_port;
-
-	nr_nfapi_ipv4_address_t p7_pnf_address_ipv4;
-	nr_nfapi_ipv6_address_t p7_pnf_address_ipv6;
-	nr_nfapi_uint16_tlv_t p7_pnf_port;
-	
-	// These TLVs are used to setup the transport connection between VNF and PNF
-	nr_nfapi_uint8_tlv_t dl_ue_per_sf;
-	nr_nfapi_uint8_tlv_t ul_ue_per_sf;
-
-	// These TLVs are used by PNF to report its RF capabilities to the VNF software
-	nr_nfapi_rf_bands_t rf_bands;
-
-	// These TLVs are used by the VNF to configure the synchronization with the PNF.
-	nr_nfapi_uint8_tlv_t timing_window;
-	nr_nfapi_uint8_tlv_t timing_info_mode;
-	nr_nfapi_uint8_tlv_t timing_info_period;
-
-	// These TLVs are used by the VNF to configure the RF in the PNF
-	nr_nfapi_uint16_tlv_t max_transmit_power;
-	nr_nfapi_uint16_tlv_t earfcn;
-
-	nr_nfapi_nmm_frequency_bands_t nmm_gsm_frequency_bands;
-	nr_nfapi_nmm_frequency_bands_t nmm_umts_frequency_bands;
-	nr_nfapi_nmm_frequency_bands_t nmm_lte_frequency_bands;
-	nr_nfapi_uint8_tlv_t nmm_uplink_rssi_supported;
-
-} nr_nfapi_nfapi_t;
-
-#define NR_NFAPI_NFAPI_P7_VNF_ADDRESS_IPV4_TAG 0x0100
-#define NR_NFAPI_NFAPI_P7_VNF_ADDRESS_IPV6_TAG 0x0101
-#define NR_NFAPI_NFAPI_P7_VNF_PORT_TAG 0x0102
-#define NR_NFAPI_NFAPI_P7_PNF_ADDRESS_IPV4_TAG 0x0103
-#define NR_NFAPI_NFAPI_P7_PNF_ADDRESS_IPV6_TAG 0x0104
-#define NR_NFAPI_NFAPI_P7_PNF_PORT_TAG 0x0105
-
-#define NR_NFAPI_NFAPI_DOWNLINK_UES_PER_SUBFRAME_TAG 0x010A
-#define NR_NFAPI_NFAPI_UPLINK_UES_PER_SUBFRAME_TAG 0x010B
-#define NR_NFAPI_NFAPI_RF_BANDS_TAG 0x0114
-#define NR_NFAPI_NFAPI_TIMING_WINDOW_TAG 0x011E
-#define NR_NFAPI_NFAPI_TIMING_INFO_MODE_TAG 0x011F
-#define NR_NFAPI_NFAPI_TIMING_INFO_PERIOD_TAG 0x0120
-#define NR_NFAPI_NFAPI_MAXIMUM_TRANSMIT_POWER_TAG 0x0128
-#define NR_NFAPI_NFAPI_EARFCN_TAG 0x0129
-#define NR_NFAPI_NFAPI_NMM_GSM_FREQUENCY_BANDS_TAG 0x0130
-#define NR_NFAPI_NFAPI_NMM_UMTS_FREQUENCY_BANDS_TAG 0x0131
-#define NR_NFAPI_NFAPI_NMM_LTE_FREQUENCY_BANDS_TAG 0x0132
-#define NR_NFAPI_NFAPI_NMM_UPLINK_RSSI_SUPPORTED_TAG 0x0133
-
-
-// P5 Message Structures
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_pnf_param_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_pnf_param_general_t pnf_param_general;
-	nr_nfapi_pnf_phy_t pnf_phy;
-	nr_nfapi_pnf_rf_t pnf_rf;
-	nr_nfapi_pnf_phy_rel10_t pnf_phy_rel10;
-	nr_nfapi_pnf_phy_rel11_t pnf_phy_rel11;
-	nr_nfapi_pnf_phy_rel12_t pnf_phy_rel12;
-	nr_nfapi_pnf_phy_rel13_t pnf_phy_rel13;
-	nr_nfapi_pnf_phy_rel13_nb_iot_t pnf_phy_rel13_nb_iot;
-  nr_nfapi_pnf_phy_rel15_t pnf_phy_rel15;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_pnf_param_response_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	nr_nfapi_pnf_phy_rf_config_t pnf_phy_rf_config;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_pnf_config_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_pnf_config_response_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_pnf_start_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_pnf_start_response_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_pnf_stop_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_pnf_stop_response_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_param_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint8_t error_code;
-	uint8_t num_tlv;
-	// fdd or tdd in idle or configured tlvs
-	nr_nfapi_l1_status l1_status;
-	nr_nfapi_phy_capabilities_t phy_capabilities;
-	nr_nfapi_laa_capability_t laa_capability;
-	nr_nfapi_nb_iot_capability_t nb_iot_capability;
-	
-	nr_nfapi_subframe_config_t subframe_config;
-	nr_nfapi_rf_config_t rf_config;
-	nr_nfapi_phich_config_t phich_config;
-	nr_nfapi_sch_config_t sch_config;
-	nr_nfapi_prach_config_t prach_config;
-	nr_nfapi_pusch_config_t pusch_config;
-	nr_nfapi_pucch_config_t pucch_config;
-	nr_nfapi_srs_config_t srs_config;
-	nr_nfapi_uplink_reference_signal_config_t uplink_reference_signal_config;
-	nr_nfapi_tdd_frame_structure_t tdd_frame_structure_config;
-	nr_nfapi_l23_config_t l23_config;
-	nr_nfapi_nb_iot_config_t nb_iot_config;
-
-	// addition nfapi tlvs as per table 2-16 in idle or configure
-	nr_nfapi_nfapi_t nr_nfapi_config;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_param_response_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint8_t num_tlv;
-	nr_nfapi_subframe_config_t subframe_config;
-	nr_nfapi_rf_config_t rf_config;
-	nr_nfapi_phich_config_t phich_config;
-	nr_nfapi_sch_config_t sch_config;
-	nr_nfapi_prach_config_t prach_config;
-	nr_nfapi_pusch_config_t pusch_config;
-	nr_nfapi_pucch_config_t pucch_config;
-	nr_nfapi_srs_config_t srs_config;
-	nr_nfapi_uplink_reference_signal_config_t uplink_reference_signal_config;
-	nr_nfapi_laa_config_t laa_config;
-	nr_nfapi_emtc_config_t emtc_config;
-	nr_nfapi_tdd_frame_structure_t tdd_frame_structure_config;
-	nr_nfapi_l23_config_t l23_config;
-	nr_nfapi_nb_iot_config_t nb_iot_config;
-	
-	// addition nfapi tlvs as per table 2-16 in idle or configure
-	nr_nfapi_nfapi_t nr_nfapi_config;
-
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_config_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_config_response_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_start_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_start_response_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_stop_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_stop_response_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	nr_nfapi_uint16_tlv_t dl_rs_tx_power;
-	nr_nfapi_uint16_tlv_t received_interference_power;
-	nr_nfapi_uint16_tlv_t thermal_noise_power;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_measurement_request_t;
-
-#define NR_NFAPI_MEASUREMENT_REQUEST_DL_RS_XTX_POWER_TAG 0x1004
-#define NR_NFAPI_MEASUREMENT_REQUEST_RECEIVED_INTERFERENCE_POWER_TAG 0x1005
-#define NR_NFAPI_MEASUREMENT_REQUEST_THERMAL_NOISE_POWER_TAG 0x1006
-
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_resource_blocks;
-	int16_t received_interference_power[NR_NFAPI_MAX_RECEIVED_INTERFERENCE_POWER_RESULTS];
-} nr_nfapi_received_interference_power_measurement_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_int16_tlv_t dl_rs_tx_power_measurement;
-	nr_nfapi_received_interference_power_measurement_t received_interference_power_measurement;
-	nr_nfapi_int16_tlv_t thermal_noise_power_measurement;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_measurement_response_t;
-
-#define NR_NFAPI_MEASUREMENT_RESPONSE_DL_RS_POWER_MEASUREMENT_TAG 0x1007
-#define NR_NFAPI_MEASUREMENT_RESPONSE_RECEIVED_INTERFERENCE_POWER_MEASUREMENT_TAG 0x1008
-#define NR_NFAPI_MEASUREMENT_RESPONSE_THERMAL_NOISE_MEASUREMENT_TAG 0x1009
-
-// P7 Sub Structures
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t dci_format;
-	uint8_t cce_idx;
-	uint8_t aggregation_level;
-	uint16_t rnti;
-	uint8_t resource_allocation_type;
-	uint8_t virtual_resource_block_assignment_flag;
-	uint32_t resource_block_coding;
-	uint8_t mcs_1;
-	uint8_t redundancy_version_1;
-	uint8_t new_data_indicator_1;
-	uint8_t transport_block_to_codeword_swap_flag;
-	uint8_t mcs_2;
-	uint8_t redundancy_version_2;
-	uint8_t new_data_indicator_2;
-	uint8_t harq_process;
-	uint8_t tpmi;
-	uint8_t pmi;
-	uint8_t precoding_information;
-	uint8_t tpc;
-	uint8_t downlink_assignment_index;
-	uint8_t ngap;
-	uint8_t transport_block_size_index;
-	uint8_t downlink_power_offset;
-	uint8_t allocate_prach_flag;
-	uint8_t preamble_index;
-	uint8_t prach_mask_index;
-	uint8_t rnti_type;
-	uint16_t transmission_power;
-} nr_nfapi_dl_config_dci_dl_pdu_rel8_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG 0x2001
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t mcch_flag;
-	uint8_t mcch_change_notification;
-	uint8_t scrambling_identity;
-} nr_nfapi_dl_config_dci_dl_pdu_rel9_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL9_TAG 0x2002
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t cross_carrier_scheduling_flag;
-	uint8_t carrier_indicator;
-	uint8_t srs_flag;
-	uint8_t srs_request;
-	uint8_t antenna_ports_scrambling_and_layers;
-	uint8_t total_dci_length_including_padding;
-	uint8_t n_dl_rb;
-} nr_nfapi_dl_config_dci_dl_pdu_rel10_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL10_TAG 0x2003
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t harq_ack_resource_offset;
-	uint8_t pdsch_re_mapping_quasi_co_location_indicator;
-} nr_nfapi_dl_config_dci_dl_pdu_rel11_t;
-
-#define NR_NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL11_TAG 0x2039
-
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t primary_cell_type;
-	uint8_t ul_dl_configuration_flag;
-	uint8_t number_ul_dl_configurations;
-	uint8_t ul_dl_configuration_indication[NR_NFAPI_MAX_UL_DL_CONFIGURATIONS];
-} nr_nfapi_dl_config_dci_dl_pdu_rel12_t;
-
-#define NR_NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL12_TAG 0x203a
-
-
-
-typedef struct {
-	uint8_t subband_index;
-	uint8_t scheduled_ues;
-	uint16_t precoding_value[NR_NFAPI_MAX_NUM_PHYSICAL_ANTENNAS][NR_NFAPI_MAX_NUM_SCHEDULED_UES];
-} nr_nfapi_dl_config_dci_dl_tpm_subband_info_t;
-
-typedef struct {
-	uint8_t num_prb_per_subband;
-	uint8_t number_of_subbands;
-	uint8_t num_antennas;
-	nr_nfapi_dl_config_dci_dl_tpm_subband_info_t subband_info[NR_NFAPI_MAX_NUM_SUBBANDS];
-} nr_nfapi_dl_config_dci_dl_tpm_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t laa_end_partial_sf_flag;
-	uint8_t laa_end_partial_sf_configuration;
-	uint8_t initial_lbt_sf;
-	uint8_t codebook_size_determination;
-	uint8_t drms_table_flag;
-	uint8_t tpm_struct_flag;
-	nr_nfapi_dl_config_dci_dl_tpm_t tpm;
-} nr_nfapi_dl_config_dci_dl_pdu_rel13_t;
-
-#define NR_NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL13_TAG 0x203b
-
-typedef struct {
-	nr_nfapi_dl_config_dci_dl_pdu_rel8_t dci_dl_pdu_rel8;
-	nr_nfapi_dl_config_dci_dl_pdu_rel9_t dci_dl_pdu_rel9;
-	nr_nfapi_dl_config_dci_dl_pdu_rel10_t dci_dl_pdu_rel10;
-	nr_nfapi_dl_config_dci_dl_pdu_rel11_t dci_dl_pdu_rel11;
-	nr_nfapi_dl_config_dci_dl_pdu_rel12_t dci_dl_pdu_rel12;
-	nr_nfapi_dl_config_dci_dl_pdu_rel13_t dci_dl_pdu_rel13;
-} nr_nfapi_dl_config_dci_dl_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint16_t transmission_power;
-} nr_nfapi_dl_config_bch_pdu_rel8_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG 0x2004
-
-typedef struct {
-	nr_nfapi_dl_config_bch_pdu_rel8_t bch_pdu_rel8;
-} nr_nfapi_dl_config_bch_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint16_t rnti;
-	uint8_t resource_allocation_type;
-	uint32_t resource_block_coding;
-	uint8_t modulation;
-	uint16_t transmission_power;
-	uint16_t mbsfn_area_id;
-} nr_nfapi_dl_config_mch_pdu_rel8_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_MCH_PDU_REL8_TAG 0x2005
-
-typedef struct {
-	nr_nfapi_dl_config_mch_pdu_rel8_t mch_pdu_rel8;
-} nr_nfapi_dl_config_mch_pdu;
-
-
-typedef struct {
-	uint8_t subband_index;
-	uint8_t num_antennas;
-	uint16_t bf_value[NR_NFAPI_MAX_NUM_ANTENNAS];
-} nr_nfapi_bf_vector_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint16_t rnti;
-	uint8_t resource_allocation_type;
-	uint8_t virtual_resource_block_assignment_flag;
-	uint32_t resource_block_coding;
-	uint8_t modulation;
-	uint8_t redundancy_version;
-	uint8_t transport_blocks;
-	uint8_t transport_block_to_codeword_swap_flag;
-	uint8_t transmission_scheme;
-	uint8_t number_of_layers;
-	uint8_t number_of_subbands;
-	uint8_t codebook_index[NR_NFAPI_MAX_NUM_SUBBANDS];
-	uint8_t ue_category_capacity;
-	uint8_t pa;
-	uint8_t delta_power_offset_index;
-	uint8_t ngap;
-	uint8_t nprb;
-	uint8_t transmission_mode;
-	uint8_t num_bf_prb_per_subband;
-	uint8_t num_bf_vector;
-	nr_nfapi_bf_vector_t bf_vector[NR_NFAPI_MAX_BF_VECTORS];
-} nr_nfapi_dl_config_dlsch_pdu_rel8_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG 0x2006
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t nscid;
-} nr_nfapi_dl_config_dlsch_pdu_rel9_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL9_TAG 0x2007
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t csi_rs_flag;
-	uint8_t csi_rs_resource_config_r10;
-	uint16_t csi_rs_zero_tx_power_resource_config_bitmap_r10;
-	uint8_t csi_rs_number_nzp_configuration;
-	uint8_t csi_rs_resource_config[NR_NFAPI_MAX_CSI_RS_RESOURCE_CONFIG];
-	uint8_t pdsch_start;
-} nr_nfapi_dl_config_dlsch_pdu_rel10_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL10_TAG 0x2008
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t drms_config_flag;
-	uint16_t drms_scrambling;
-	uint8_t csi_config_flag;
-	uint16_t csi_scrambling;
-	uint8_t pdsch_re_mapping_flag;
-	uint8_t pdsch_re_mapping_atenna_ports;
-	uint8_t pdsch_re_mapping_freq_shift;
-} nr_nfapi_dl_config_dlsch_pdu_rel11_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL11_TAG 0x203C
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t altcqi_table_r12;
-	uint8_t maxlayers;
-	uint8_t n_dl_harq;
-} nr_nfapi_dl_config_dlsch_pdu_rel12_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL12_TAG 0x203D
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t dwpts_symbols;
-	uint8_t initial_lbt_sf;
-	uint8_t ue_type;
-	uint8_t pdsch_payload_type;
-	uint16_t initial_transmission_sf_io;
-	uint8_t drms_table_flag;
-} nr_nfapi_dl_config_dlsch_pdu_rel13_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL13_TAG 0x203E
-
-typedef struct {
-	nr_nfapi_dl_config_dlsch_pdu_rel8_t dlsch_pdu_rel8;
-	nr_nfapi_dl_config_dlsch_pdu_rel9_t dlsch_pdu_rel9;
-	nr_nfapi_dl_config_dlsch_pdu_rel10_t dlsch_pdu_rel10;
-	nr_nfapi_dl_config_dlsch_pdu_rel11_t dlsch_pdu_rel11;
-	nr_nfapi_dl_config_dlsch_pdu_rel12_t dlsch_pdu_rel12;
-	nr_nfapi_dl_config_dlsch_pdu_rel13_t dlsch_pdu_rel13;
-} nr_nfapi_dl_config_dlsch_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint16_t p_rnti;
-	uint8_t resource_allocation_type;
-	uint8_t virtual_resource_block_assignment_flag;
-	uint32_t resource_block_coding;
-	uint8_t mcs;
-	uint8_t redundancy_version;
-	uint8_t number_of_transport_blocks;
-	uint8_t transport_block_to_codeword_swap_flag;
-	uint8_t transmission_scheme;
-	uint8_t number_of_layers;
-	uint8_t codebook_index;
-	uint8_t ue_category_capacity;
-	uint8_t pa;
-	uint16_t transmission_power;
-	uint8_t nprb;
-	uint8_t ngap;
-} nr_nfapi_dl_config_pch_pdu_rel8_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL8_TAG 0x2009
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t ue_mode;
-	uint16_t initial_transmission_sf_io;
-} nr_nfapi_dl_config_pch_pdu_rel13_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_PCH_PDU_REL13_TAG 0x203F
-
-typedef struct {
-	nr_nfapi_dl_config_pch_pdu_rel8_t pch_pdu_rel8;
-	nr_nfapi_dl_config_pch_pdu_rel13_t pch_pdu_rel13;
-} nr_nfapi_dl_config_pch_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t transmission_power;
-	uint8_t prs_bandwidth;
-	uint8_t prs_cyclic_prefix_type;
-	uint8_t prs_muting;
-} nr_nfapi_dl_config_prs_pdu_rel9_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_PRS_PDU_REL9_TAG 0x200A
-
-typedef struct {
-	nr_nfapi_dl_config_prs_pdu_rel9_t prs_pdu_rel9;
-} nr_nfapi_dl_config_prs_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t csi_rs_antenna_port_count_r10;
-	uint8_t csi_rs_resource_config_r10;
-	uint16_t transmission_power;
-	uint16_t csi_rs_zero_tx_power_resource_config_bitmap_r10;
-	uint8_t csi_rs_number_of_nzp_configuration;
-	uint8_t csi_rs_resource_config[NR_NFAPI_MAX_CSI_RS_RESOURCE_CONFIG];
-} nr_nfapi_dl_config_csi_rs_pdu_rel10_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL10_TAG 0x200B
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t csi_rs_class;
-	uint8_t cdm_type;
-	uint8_t num_bf_vector;
-	struct {
-		uint8_t csi_rs_resource_index;
-		uint16_t bf_value[NR_NFAPI_MAX_ANTENNA_PORT_COUNT];
-	} bf_vector[NR_NFAPI_MAX_BF_VECTORS];
-
-} nr_nfapi_dl_config_csi_rs_pdu_rel13_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_CSI_RS_PDU_REL13_TAG 0x2040
-
-typedef struct {
-	nr_nfapi_dl_config_csi_rs_pdu_rel10_t csi_rs_pdu_rel10;
-	nr_nfapi_dl_config_csi_rs_pdu_rel13_t csi_rs_pdu_rel13;
-} nr_nfapi_dl_config_csi_rs_pdu;
-
-#define NR_NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL8_TAG 0x2001
-#define NR_NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL9_TAG 0x2002
-#define NR_NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL10_TAG 0x2003
-#define NR_NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL11_TAG 0x2039
-#define NR_NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL12_TAG 0x203a
-#define NR_NFAPI_DL_CONFIG_REQUEST_EPDCCH_PDU_REL13_TAG 0x203b
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t epdcch_resource_assignment_flag;
-	uint16_t epdcch_id;
-	uint8_t epdcch_start_symbol;
-	uint8_t epdcch_num_prb;
-	uint8_t epdcch_prb_index[NR_NFAPI_MAX_EPDCCH_PRB];
-	nr_nfapi_bf_vector_t bf_vector;
-} nr_nfapi_dl_config_epdcch_parameters_rel11_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL11_TAG 0x2041
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t dwpts_symbols;
-	uint8_t initial_lbt_sf;
-} nr_nfapi_dl_config_epdcch_parameters_rel13_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_EPDCCH_PARAM_REL13_TAG 0x2042
-
-typedef struct {
-	nr_nfapi_dl_config_dci_dl_pdu_rel8_t			epdcch_pdu_rel8;
-	nr_nfapi_dl_config_dci_dl_pdu_rel9_t			epdcch_pdu_rel9;
-	nr_nfapi_dl_config_dci_dl_pdu_rel10_t			epdcch_pdu_rel10;
-	nr_nfapi_dl_config_dci_dl_pdu_rel11_t			epdcch_pdu_rel11;
-	nr_nfapi_dl_config_dci_dl_pdu_rel12_t			epdcch_pdu_rel12;
-	nr_nfapi_dl_config_dci_dl_pdu_rel13_t			epdcch_pdu_rel13;
-	nr_nfapi_dl_config_epdcch_parameters_rel11_t	epdcch_params_rel11;
-	nr_nfapi_dl_config_epdcch_parameters_rel13_t	epdcch_params_rel13;
-} nr_nfapi_dl_config_epdcch_pdu;
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t mpdcch_narrow_band;
-	uint8_t number_of_prb_pairs;
-	uint8_t resource_block_assignment;
-	uint8_t mpdcch_tansmission_type;
-	uint8_t start_symbol;
-	uint8_t ecce_index;
-	uint8_t aggregation_level;
-	uint8_t rnti_type;
-	uint16_t rnti;
-	uint8_t ce_mode;
-	uint16_t drms_scrambling_init;
-	uint16_t initial_transmission_sf_io;
-	uint16_t transmission_power;
-	uint8_t dci_format;
-	uint16_t resource_block_coding;
-	uint8_t mcs;
-	uint8_t pdsch_reptition_levels;
-	uint8_t redundancy_version;
-	uint8_t new_data_indicator;
-	uint8_t harq_process;
-	uint8_t tpmi_length;
-	uint8_t tpmi;
-	uint8_t pmi_flag;
-	uint8_t pmi;
-	uint8_t harq_resource_offset;
-	uint8_t dci_subframe_repetition_number;
-	uint8_t tpc;
-	uint8_t downlink_assignment_index_length;
-	uint8_t downlink_assignment_index;
-	uint8_t allocate_prach_flag;
-	uint8_t preamble_index;
-	uint8_t prach_mask_index;
-	uint8_t starting_ce_level;
-	uint8_t srs_request;
-	uint8_t antenna_ports_and_scrambling_identity_flag;
-	uint8_t antenna_ports_and_scrambling_identity;
-	uint8_t frequency_hopping_enabled_flag;
-	uint8_t paging_direct_indication_differentiation_flag;
-	uint8_t direct_indication;
-	uint8_t total_dci_length_including_padding;
-	uint8_t number_of_tx_antenna_ports;
-	uint16_t precoding_value[NR_NFAPI_MAX_TX_PHYSICAL_ANTENNA_PORTS];
-} nr_nfapi_dl_config_mpdcch_pdu_rel13_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_MPDCCH_PDU_REL13_TAG 0x205B
-
-
-typedef struct {
-	nr_nfapi_dl_config_mpdcch_pdu_rel13_t mpdcch_pdu_rel13;
-} nr_nfapi_dl_config_mpdcch_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint16_t transmission_power;
-	uint16_t hyper_sfn_2_lsbs;
-} nr_nfapi_dl_config_nbch_pdu_rel13_t;
-
-#define NR_NFAPI_DL_CONFIG_REQUEST_NBCH_PDU_REL13_TAG 0x205C
-
-typedef struct {
-	nr_nfapi_dl_config_nbch_pdu_rel13_t nbch_pdu_rel13;
-} nr_nfapi_dl_config_nbch_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint8_t ncce_index;
-	uint8_t aggregation_level;
-	uint8_t start_symbol;
-	uint8_t rnti_type;
-	uint16_t rnti;
-	uint8_t scrambling_reinitialization_batch_index;
-	uint8_t nrs_antenna_ports_assumed_by_the_ue;
-	uint8_t dci_format;
-	uint8_t scheduling_delay;
-	uint8_t resource_assignment;
-	uint8_t repetition_number;
-	uint8_t mcs;
-	uint8_t new_data_indicator;
-	uint8_t harq_ack_resource;
-	uint8_t npdcch_order_indication;
-	uint8_t starting_number_of_nprach_repetitions;
-	uint8_t subcarrier_indication_of_nprach;
-	uint8_t paging_direct_indication_differentation_flag;
-	uint8_t direct_indication;
-	uint8_t dci_subframe_repetition_number;
-	uint8_t total_dci_length_including_padding;
-} nr_nfapi_dl_config_npdcch_pdu_rel13_t;
-
-#define NR_NFAPI_DL_CONFIG_REQUEST_NPDCCH_PDU_REL13_TAG 0x205D
-
-typedef struct {
-	nr_nfapi_dl_config_npdcch_pdu_rel13_t npdcch_pdu_rel13;
-} nr_nfapi_dl_config_npdcch_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t pdu_index;
-	uint8_t start_symbol;
-	uint8_t rnti_type;
-	uint16_t rnti;
-	uint16_t resource_assignment;
-	uint16_t repetition_number;
-	uint8_t modulation;
-	uint8_t number_of_subframes_for_resource_assignment;
-	uint8_t scrambling_sequence_initialization_cinit;
-	uint16_t sf_idx;
-	uint8_t nrs_antenna_ports_assumed_by_the_ue;
-} nr_nfapi_dl_config_ndlsch_pdu_rel13_t;
-
-#define NR_NFAPI_DL_CONFIG_REQUEST_NDLSCH_PDU_REL13_TAG 0x205E
-
-typedef struct {
-	nr_nfapi_dl_config_ndlsch_pdu_rel13_t ndlsch_pdu_rel13;
-} nr_nfapi_dl_config_ndlsch_pdu;
-
-
-typedef struct {
-	uint8_t pdu_type;
-	uint8_t pdu_size;
-	union {
-		nr_nfapi_dl_config_dci_dl_pdu	dci_dl_pdu;
-		nr_nfapi_dl_config_bch_pdu		bch_pdu;
-		nr_nfapi_dl_config_mch_pdu		mch_pdu;
-		nr_nfapi_dl_config_dlsch_pdu	dlsch_pdu;
-		nr_nfapi_dl_config_pch_pdu		pch_pdu;
-		nr_nfapi_dl_config_prs_pdu		prs_pdu;
-		nr_nfapi_dl_config_csi_rs_pdu	csi_rs_pdu;
-		nr_nfapi_dl_config_epdcch_pdu	epdcch_pdu;
-		nr_nfapi_dl_config_mpdcch_pdu	mpdcch_pdu;
-		nr_nfapi_dl_config_nbch_pdu	nbch_pdu;
-		nr_nfapi_dl_config_npdcch_pdu	npdcch_pdu;
-		nr_nfapi_dl_config_ndlsch_pdu	ndlsch_pdu;
-	};
-} nr_nfapi_dl_config_request_pdu_t;
-
-#define NR_NFAPI_DL_CONFIG_MAX_PDU 100
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t number_pdcch_ofdm_symbols;
-	uint8_t number_dci;
-	uint16_t number_pdu;
-	uint8_t number_pdsch_rnti;
-	uint16_t transmission_power_pcfich;
-	nr_nfapi_dl_config_request_pdu_t* dl_config_pdu_list;
-} nr_nfapi_dl_config_request_body_t;
-#define NR_NFAPI_DL_CONFIG_REQUEST_BODY_TAG 0x2000
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint32_t handle;
-	uint16_t size;
-	uint16_t rnti;
-	uint8_t resource_block_start;
-	uint8_t number_of_resource_blocks;
-	uint8_t modulation_type;
-	uint8_t cyclic_shift_2_for_drms;
-	uint8_t frequency_hopping_enabled_flag;
-	uint8_t frequency_hopping_bits;
-	uint8_t new_data_indication;
-	uint8_t redundancy_version;
-	uint8_t harq_process_number;
-	uint8_t ul_tx_mode;
-	uint8_t current_tx_nb;
-	uint8_t n_srs;
-} nr_nfapi_ul_config_ulsch_pdu_rel8_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG 0x200D
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t resource_allocation_type;
-	uint32_t resource_block_coding;
-	uint8_t transport_blocks;
-	uint8_t transmission_scheme;
-	uint8_t number_of_layers;
-	uint8_t codebook_index;
-	uint8_t disable_sequence_hopping_flag;
-} nr_nfapi_ul_config_ulsch_pdu_rel10_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL10_TAG 0x200E
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t virtual_cell_id_enabled_flag;
-	uint16_t npusch_identity;
-	uint8_t dmrs_config_flag;
-	uint16_t ndmrs_csh_identity;
-} nr_nfapi_ul_config_ulsch_pdu_rel11_t;
-
-#define NR_NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL11_TAG 0x2043
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t  ue_type;
-	uint16_t total_number_of_repetitions;
-	uint16_t repetition_number;
-	uint16_t initial_transmission_sf_io;
-	uint8_t  empty_symbols_due_to_re_tunning;
-} nr_nfapi_ul_config_ulsch_pdu_rel13_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL13_TAG 0x2044
-
-typedef struct {
-	nr_nfapi_ul_config_ulsch_pdu_rel8_t ulsch_pdu_rel8;
-	nr_nfapi_ul_config_ulsch_pdu_rel10_t ulsch_pdu_rel10;
-	nr_nfapi_ul_config_ulsch_pdu_rel11_t ulsch_pdu_rel11;
-	nr_nfapi_ul_config_ulsch_pdu_rel13_t ulsch_pdu_rel13;
-} nr_nfapi_ul_config_ulsch_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t dl_cqi_pmi_size_rank_1;
-	uint8_t dl_cqi_pmi_size_rank_greater_1;
-	uint8_t ri_size;
-	uint8_t delta_offset_cqi;
-	uint8_t delta_offset_ri;
-} nr_nfapi_ul_config_cqi_ri_information_rel8_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL8_TAG 0x2010
-
-typedef struct {
-	uint8_t dl_cqi_pmi_ri_size;
-	uint8_t control_type;
-} nr_nfapi_ul_config_periodic_cqi_pmi_ri_report_t;
-
-typedef struct {
-	uint8_t number_of_cc;
-	struct {
-		uint8_t ri_size;
-		uint8_t dl_cqi_pmi_size[8];
-	} cc[NR_NFAPI_MAX_CC];
-} nr_nfapi_ul_config_aperiodic_cqi_pmi_ri_report_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t report_type;
-	uint8_t delta_offset_cqi;
-	uint8_t delta_offset_ri;
-	union {
-		nr_nfapi_ul_config_periodic_cqi_pmi_ri_report_t periodic_cqi_pmi_ri_report;
-		nr_nfapi_ul_config_aperiodic_cqi_pmi_ri_report_t aperiodic_cqi_pmi_ri_report;
-	};
-} nr_nfapi_ul_config_cqi_ri_information_rel9_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL9_TAG 0x2011
-
-typedef struct {
-	uint16_t dl_cqi_pmi_ri_size_2;
-} nr_nfapi_ul_config_periodic_cqi_pmi_ri_report_re13_t;
-
-typedef struct {
-} nr_nfapi_ul_config_aperiodic_cqi_pmi_ri_report_re13_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t report_type; // Convience parameter, not sent on the wire
-	union {
-		nr_nfapi_ul_config_periodic_cqi_pmi_ri_report_re13_t periodic_cqi_pmi_ri_report;
-		nr_nfapi_ul_config_aperiodic_cqi_pmi_ri_report_re13_t aperiodic_cqi_pmi_ri_report;
-	};
-} nr_nfapi_ul_config_cqi_ri_information_rel13_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_CQI_RI_INFORMATION_REL13_TAG 0x2045
-
-typedef struct {
-	nr_nfapi_ul_config_cqi_ri_information_rel8_t cqi_ri_information_rel8;
-	nr_nfapi_ul_config_cqi_ri_information_rel9_t cqi_ri_information_rel9;
-	nr_nfapi_ul_config_cqi_ri_information_rel13_t cqi_ri_information_rel13;
-} nr_nfapi_ul_config_cqi_ri_information;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t harq_size;
-	uint8_t delta_offset_harq;
-	uint8_t ack_nack_mode;
-} nr_nfapi_ul_config_ulsch_harq_information_rel10_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL10_TAG 0x2012
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t harq_size_2;
-	uint8_t delta_offset_harq_2;
-} nr_nfapi_ul_config_ulsch_harq_information_rel13_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL13_TAG 0x2046
-
-typedef struct {
-	nr_nfapi_ul_config_ulsch_harq_information_rel10_t harq_information_rel10;
-	nr_nfapi_ul_config_ulsch_harq_information_rel13_t harq_information_rel13;
-} nr_nfapi_ul_config_ulsch_harq_information;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t n_srs_initial;
-	uint8_t initial_number_of_resource_blocks;
-} nr_nfapi_ul_config_initial_transmission_parameters_rel8_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG 0x200F
-
-typedef struct {
-	nr_nfapi_ul_config_initial_transmission_parameters_rel8_t initial_transmission_parameters_rel8;
-} nr_nfapi_ul_config_initial_transmission_parameters;
-
-typedef struct {
-	nr_nfapi_ul_config_ulsch_pdu ulsch_pdu;
-	nr_nfapi_ul_config_cqi_ri_information cqi_ri_information;
-	nr_nfapi_ul_config_initial_transmission_parameters initial_transmission_parameters;
-} nr_nfapi_ul_config_ulsch_cqi_ri_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ulsch_pdu ulsch_pdu;
-	nr_nfapi_ul_config_ulsch_harq_information harq_information;
-	nr_nfapi_ul_config_initial_transmission_parameters initial_transmission_parameters;
-} nr_nfapi_ul_config_ulsch_harq_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ulsch_pdu ulsch_pdu;
-	nr_nfapi_ul_config_cqi_ri_information cqi_ri_information;
-	nr_nfapi_ul_config_ulsch_harq_information harq_information;
-	nr_nfapi_ul_config_initial_transmission_parameters initial_transmission_parameters;
-} nr_nfapi_ul_config_ulsch_cqi_harq_ri_pdu;
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint32_t handle;
-	uint16_t rnti;
-} nr_nfapi_ul_config_ue_information_rel8_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG 0x2013
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t virtual_cell_id_enabled_flag;
-	uint16_t npusch_identity;
-} nr_nfapi_ul_config_ue_information_rel11_t;
-
-#define NR_NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL11_TAG 0x2047
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t  ue_type;
-	uint8_t  empty_symbols;
-	uint16_t total_number_of_repetitions;
-	uint16_t repetition_number;
-} nr_nfapi_ul_config_ue_information_rel13_t;
-
-#define NR_NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL13_TAG 0x2048
-
-typedef struct {
-	nr_nfapi_ul_config_ue_information_rel8_t ue_information_rel8;
-	nr_nfapi_ul_config_ue_information_rel11_t ue_information_rel11;
-	nr_nfapi_ul_config_ue_information_rel13_t ue_information_rel13;
-} nr_nfapi_ul_config_ue_information;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t pucch_index;
-	uint8_t dl_cqi_pmi_size;
-} nr_nfapi_ul_config_cqi_information_rel8_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL8_TAG 0x2014
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t number_of_pucch_resource;
-	uint16_t pucch_index_p1;
-} nr_nfapi_ul_config_cqi_information_rel10_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL10_TAG 0x2015
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t csi_mode;
-	uint16_t dl_cqi_pmi_size_2;
-	uint8_t starting_prb;
-	uint8_t n_prb;
-	uint8_t cdm_index;
-	uint8_t n_srs;
-} nr_nfapi_ul_config_cqi_information_rel13_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_CQI_INFORMATION_REL13_TAG 0x2049
-
-typedef struct {
-	nr_nfapi_ul_config_cqi_information_rel8_t cqi_information_rel8;
-	nr_nfapi_ul_config_cqi_information_rel10_t cqi_information_rel10;
-	nr_nfapi_ul_config_cqi_information_rel13_t cqi_information_rel13;
-} nr_nfapi_ul_config_cqi_information;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t pucch_index;
-} nr_nfapi_ul_config_sr_information_rel8_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL8_TAG 0x2016
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t number_of_pucch_resources;
-	uint16_t pucch_index_p1;
-} nr_nfapi_ul_config_sr_information_rel10_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_SR_INFORMATION_REL10_TAG 0x2017
-
-typedef struct { 
-	nr_nfapi_ul_config_sr_information_rel8_t sr_information_rel8;
-	nr_nfapi_ul_config_sr_information_rel10_t sr_information_rel10;
-} nr_nfapi_ul_config_sr_information;
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint8_t harq_size;
-	uint8_t ack_nack_mode;
-	uint8_t number_of_pucch_resources;
-	uint16_t n_pucch_1_0;
-	uint16_t n_pucch_1_1;
-	uint16_t n_pucch_1_2;
-	uint16_t n_pucch_1_3;
-} nr_nfapi_ul_config_harq_information_rel10_tdd_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG 0x2018
-
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint16_t n_pucch_1_0;
-	uint8_t harq_size;
-} nr_nfapi_ul_config_harq_information_rel8_fdd_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL8_FDD_TAG 0x2019
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint8_t harq_size;
-	uint8_t ack_nack_mode;
-	uint8_t number_of_pucch_resources;
-	uint16_t n_pucch_1_0;
-	uint16_t n_pucch_1_1;
-	uint16_t n_pucch_1_2;
-	uint16_t n_pucch_1_3;
-} nr_nfapi_ul_config_harq_information_rel9_fdd_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG 0x201a
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint8_t  num_ant_ports;
-	uint16_t n_pucch_2_0;
-	uint16_t n_pucch_2_1;
-	uint16_t n_pucch_2_2;
-	uint16_t n_pucch_2_3;	
-} nr_nfapi_ul_config_harq_information_rel11_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG 0x204A
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint16_t  harq_size_2;
-	uint8_t starting_prb;
-	uint8_t n_prb;
-	uint8_t cdm_index;
-	uint8_t n_srs;
-} nr_nfapi_ul_config_harq_information_rel13_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL13_TAG 0x204B
-
-typedef struct {
-	nr_nfapi_ul_config_harq_information_rel10_tdd_t harq_information_rel10_tdd;
-	nr_nfapi_ul_config_harq_information_rel8_fdd_t harq_information_rel8_fdd;
-	nr_nfapi_ul_config_harq_information_rel9_fdd_t harq_information_rel9_fdd;
-	nr_nfapi_ul_config_harq_information_rel11_t harq_information_rel11;
-	nr_nfapi_ul_config_harq_information_rel13_t harq_information_rel13;
-} nr_nfapi_ul_config_harq_information;
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint32_t handle;
-	uint16_t size;
-	uint16_t rnti;
-	uint8_t srs_bandwidth;
-	uint8_t frequency_domain_position;
-	uint8_t srs_hopping_bandwidth;
-	uint8_t transmission_comb;
-	uint16_t i_srs;
-	uint8_t sounding_reference_cyclic_shift;
-} nr_nfapi_ul_config_srs_pdu_rel8_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL8_TAG 0x201b
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint8_t antenna_port;
-} nr_nfapi_ul_config_srs_pdu_rel10_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL10_TAG 0x201c
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint8_t number_of_combs;
-} nr_nfapi_ul_config_srs_pdu_rel13_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_SRS_PDU_REL13_TAG 0x204c
-
-typedef struct {
-	nr_nfapi_ul_config_srs_pdu_rel8_t srs_pdu_rel8;
-	nr_nfapi_ul_config_srs_pdu_rel10_t srs_pdu_rel10;
-	nr_nfapi_ul_config_srs_pdu_rel13_t srs_pdu_rel13;
-} nr_nfapi_ul_config_srs_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ue_information ue_information;
-	nr_nfapi_ul_config_cqi_information cqi_information;
-} nr_nfapi_ul_config_uci_cqi_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ue_information ue_information;
-	nr_nfapi_ul_config_sr_information sr_information;
-} nr_nfapi_ul_config_uci_sr_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ue_information ue_information;
-	nr_nfapi_ul_config_harq_information harq_information;
-} nr_nfapi_ul_config_uci_harq_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ue_information ue_information;
-	nr_nfapi_ul_config_sr_information sr_information;
-	nr_nfapi_ul_config_harq_information harq_information;
-} nr_nfapi_ul_config_uci_sr_harq_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ue_information ue_information;
-	nr_nfapi_ul_config_cqi_information cqi_information;
-	nr_nfapi_ul_config_harq_information harq_information;
-} nr_nfapi_ul_config_uci_cqi_harq_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ue_information ue_information;
-	nr_nfapi_ul_config_cqi_information cqi_information;
-	nr_nfapi_ul_config_sr_information sr_information;
-} nr_nfapi_ul_config_uci_cqi_sr_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ue_information ue_information;
-	nr_nfapi_ul_config_cqi_information cqi_information;
-	nr_nfapi_ul_config_sr_information sr_information;
-	nr_nfapi_ul_config_harq_information harq_information;
-} nr_nfapi_ul_config_uci_cqi_sr_harq_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ue_information ue_information;
-} nr_nfapi_ul_config_harq_buffer_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ulsch_pdu ulsch_pdu;
-	nr_nfapi_ul_config_cqi_information csi_information;
-} nr_nfapi_ul_config_ulsch_uci_csi_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ulsch_pdu ulsch_pdu;
-	nr_nfapi_ul_config_harq_information harq_information;
-} nr_nfapi_ul_config_ulsch_uci_harq_pdu;
-
-typedef struct {
-	nr_nfapi_ul_config_ulsch_pdu ulsch_pdu;
-	nr_nfapi_ul_config_cqi_information csi_information;
-	nr_nfapi_ul_config_harq_information harq_information;
-} nr_nfapi_ul_config_ulsch_csi_uci_harq_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t harq_ack_resource;
-} nr_nfapi_ul_config_nb_harq_information_rel13_fdd_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_NB_HARQ_INFORMATION_REL13_FDD_TAG 0x2061
-
-typedef struct {
-	nr_nfapi_ul_config_nb_harq_information_rel13_fdd_t nb_harq_information_rel13_fdd;
-} nr_nfapi_ul_config_nb_harq_information;
-
-typedef struct {
-	nr_nfapi_tl_t tl;	
-	uint8_t nulsch_format;
-	uint32_t handle;
-	uint16_t size;
-	uint16_t rnti;
-	uint8_t subcarrier_indication;
-	uint8_t resource_assignment;
-	uint8_t mcs;
-	uint8_t redudancy_version;
-	uint8_t repetition_number;
-	uint8_t new_data_indication;
-	uint8_t n_srs;
-	uint16_t scrambling_sequence_initialization_cinit;
-	uint16_t sf_idx;
-	nr_nfapi_ul_config_ue_information ue_information;
-	nr_nfapi_ul_config_nb_harq_information nb_harq_information;
-} nr_nfapi_ul_config_nulsch_pdu_rel13_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_NULSCH_PDU_REL13_TAG 0x205F
-
-typedef struct {
-	nr_nfapi_ul_config_nulsch_pdu_rel13_t nulsch_pdu_rel13;
-} nr_nfapi_ul_config_nulsch_pdu;
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t nprach_config_0;
-	uint8_t nprach_config_1;
-	uint8_t nprach_config_2;
-} nr_nfapi_ul_config_nrach_pdu_rel13_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_NRACH_PDU_REL13_TAG 0x2067
-
-typedef struct {
-	nr_nfapi_ul_config_nrach_pdu_rel13_t nrach_pdu_rel13;
-} nr_nfapi_ul_config_nrach_pdu;
-
-typedef struct {
-	uint8_t pdu_type;
-	uint8_t pdu_size;
-	union {
-		nr_nfapi_ul_config_ulsch_pdu				ulsch_pdu;
-		nr_nfapi_ul_config_ulsch_cqi_ri_pdu		ulsch_cqi_ri_pdu;
-		nr_nfapi_ul_config_ulsch_harq_pdu			ulsch_harq_pdu;
-		nr_nfapi_ul_config_ulsch_cqi_harq_ri_pdu	ulsch_cqi_harq_ri_pdu;
-		nr_nfapi_ul_config_uci_cqi_pdu				uci_cqi_pdu;
-		nr_nfapi_ul_config_uci_sr_pdu				uci_sr_pdu;
-		nr_nfapi_ul_config_uci_harq_pdu			uci_harq_pdu;
-		nr_nfapi_ul_config_uci_sr_harq_pdu			uci_sr_harq_pdu;
-		nr_nfapi_ul_config_uci_cqi_harq_pdu		uci_cqi_harq_pdu;
-		nr_nfapi_ul_config_uci_cqi_sr_pdu			uci_cqi_sr_pdu;
-		nr_nfapi_ul_config_uci_cqi_sr_harq_pdu		uci_cqi_sr_harq_pdu;
-		nr_nfapi_ul_config_srs_pdu					srs_pdu;
-		nr_nfapi_ul_config_harq_buffer_pdu			harq_buffer_pdu;
-		nr_nfapi_ul_config_ulsch_uci_csi_pdu		ulsch_uci_csi_pdu;
-		nr_nfapi_ul_config_ulsch_uci_harq_pdu		ulsch_uci_harq_pdu;
-		nr_nfapi_ul_config_ulsch_csi_uci_harq_pdu	ulsch_csi_uci_harq_pdu;
-		nr_nfapi_ul_config_nulsch_pdu				nulsch_pdu;
-		nr_nfapi_ul_config_nrach_pdu				nrach_pdu;
-	};
-} nr_nfapi_ul_config_request_pdu_t;
-
-#define NR_NFAPI_UL_CONFIG_MAX_PDU 100
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t number_of_pdus;
-	uint8_t rach_prach_frequency_resources;
-	uint8_t srs_present;
-	nr_nfapi_ul_config_request_pdu_t* ul_config_pdu_list;
-} nr_nfapi_ul_config_request_body_t;
-#define NR_NFAPI_UL_CONFIG_REQUEST_BODY_TAG 0x200C
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t resource_block_start;
-	uint8_t cyclic_shift_2_for_drms;
-	uint8_t hi_value;
-	uint8_t i_phich;
-	uint16_t transmission_power;
-} nr_nfapi_hi_dci0_hi_pdu_rel8_t;
-#define NR_NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG 0x201e
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t flag_tb2;
-	uint8_t hi_value_2;
-} nr_nfapi_hi_dci0_hi_pdu_rel10_t;
-#define NR_NFAPI_HI_DCI0_REQUEST_HI_PDU_REL10_TAG 0x201f
-
-typedef struct {
-	nr_nfapi_hi_dci0_hi_pdu_rel8_t		hi_pdu_rel8;
-	nr_nfapi_hi_dci0_hi_pdu_rel10_t	hi_pdu_rel10;
-} nr_nfapi_hi_dci0_hi_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t dci_format;
-	uint8_t cce_index;
-	uint8_t aggregation_level;
-	uint16_t rnti;
-	uint8_t resource_block_start;
-	uint8_t number_of_resource_block;
-	uint8_t mcs_1;
-	uint8_t cyclic_shift_2_for_drms;
-	uint8_t frequency_hopping_enabled_flag;
-	uint8_t frequency_hopping_bits;
-	uint8_t new_data_indication_1;
-	uint8_t ue_tx_antenna_seleciton;
-	uint8_t tpc;
-	uint8_t cqi_csi_request;
-	uint8_t ul_index;
-	uint8_t dl_assignment_index;
-	uint32_t tpc_bitmap;
-	uint16_t transmission_power;
-} nr_nfapi_hi_dci0_dci_pdu_rel8_t;
-#define NR_NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG 0x2020
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t cross_carrier_scheduling_flag;
-	uint8_t carrier_indicator;
-	uint8_t size_of_cqi_csi_feild;
-	uint8_t srs_flag;
-	uint8_t srs_request;
-	uint8_t resource_allocation_flag;
-	uint8_t resource_allocation_type;
-	uint32_t resource_block_coding;
-	uint8_t mcs_2;
-	uint8_t new_data_indication_2;
-	uint8_t number_of_antenna_ports;
-	uint8_t tpmi;
-	uint8_t total_dci_length_including_padding;
-	uint8_t n_ul_rb;
-} nr_nfapi_hi_dci0_dci_pdu_rel10_t;
-#define NR_NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL10_TAG 0x2021
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t pscch_resource;
-	uint8_t time_resource_pattern;
-} nr_nfapi_hi_dci0_dci_pdu_rel12_t;
-
-#define NR_NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL12_TAG 0x204D
-
-typedef struct {
-	nr_nfapi_hi_dci0_dci_pdu_rel8_t	dci_pdu_rel8;
-	nr_nfapi_hi_dci0_dci_pdu_rel10_t	dci_pdu_rel10;
-	nr_nfapi_hi_dci0_dci_pdu_rel12_t	dci_pdu_rel12;
-} nr_nfapi_hi_dci0_dci_pdu;
-
-typedef nr_nfapi_hi_dci0_dci_pdu_rel8_t nr_nfapi_hi_dci0_epdcch_dci_pdu_rel8_t;
-#define NR_NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL8_TAG 0x2020
-
-typedef nr_nfapi_hi_dci0_dci_pdu_rel10_t nr_nfapi_hi_dci0_epdcch_dci_pdu_rel10_t;
-#define NR_NFAPI_HI_DCI0_REQUEST_EPDCCH_DCI_PDU_REL10_TAG 0x2021
-
-typedef nr_nfapi_dl_config_epdcch_parameters_rel11_t nr_nfapi_hi_dci0_epdcch_parameters_rel11_t;
-#define NR_NFAPI_HI_DCI0_REQUEST_EPDCCH_PARAMETERS_REL11_TAG 0x2041
-
-typedef struct {
-	nr_nfapi_hi_dci0_epdcch_dci_pdu_rel8_t		epdcch_dci_pdu_rel8;
-	nr_nfapi_hi_dci0_epdcch_dci_pdu_rel10_t	epdcch_dci_pdu_rel10;
-	nr_nfapi_hi_dci0_epdcch_parameters_rel11_t	epdcch_parameters_rel11;
-} nr_nfapi_hi_dci0_epdcch_dci_pdu;
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t mpdcch_narrowband;
-	uint8_t number_of_prb_pairs;
-	uint8_t resource_block_assignment;
-	uint8_t mpdcch_transmission_type;
-	uint8_t start_symbol;
-	uint8_t ecce_index;
-	uint8_t aggreagation_level;
-	uint8_t rnti_type;
-	uint16_t rnti;
-	uint8_t ce_mode;
-	uint16_t drms_scrambling_init;
-	uint16_t initial_transmission_sf_io;
-	uint16_t transmission_power;
-	uint8_t dci_format;
-	uint8_t resource_block_start;
-	uint8_t number_of_resource_blocks;
-	uint8_t mcs;
-	uint8_t pusch_repetition_levels;
-	uint8_t frequency_hopping_flag;
-	uint8_t new_data_indication;
-	uint8_t harq_process;
-	uint8_t redudency_version;
-	uint8_t tpc;
-	uint8_t csi_request;
-	uint8_t ul_inex;
-	uint8_t dai_presence_flag;
-	uint8_t dl_assignment_index;
-	uint8_t srs_request;
-	uint8_t dci_subframe_repetition_number;
-	uint32_t tcp_bitmap;
-	uint8_t total_dci_length_include_padding;
-	uint8_t number_of_tx_antenna_ports;
-	uint16_t precoding_value[NR_NFAPI_MAX_ANTENNA_PORT_COUNT];
-} nr_nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t;
-#define NR_NFAPI_HI_DCI0_REQUEST_MPDCCH_DCI_PDU_REL13_TAG 0x204E
-
-typedef struct {
-	nr_nfapi_hi_dci0_mpdcch_dci_pdu_rel13_t	mpdcch_dci_pdu_rel13;
-} nr_nfapi_hi_dci0_mpdcch_dci_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t ncce_index;
-	uint8_t aggregation_level;
-	uint8_t start_symbol;
-	uint16_t rnti;
-	uint8_t scrambling_reinitialization_batch_index;
-	uint8_t nrs_antenna_ports_assumed_by_the_ue;
-	uint8_t subcarrier_indication;
-	uint8_t resource_assignment;
-	uint8_t scheduling_delay;
-	uint8_t mcs;
-	uint8_t redudancy_version;
-	uint8_t repetition_number;
-	uint8_t new_data_indicator;
-	uint8_t dci_subframe_repetition_number;
-} nr_nfapi_hi_dci0_npdcch_dci_pdu_rel13_t;
-
-#define NR_NFAPI_HI_DCI0_REQUEST_NPDCCH_DCI_PDU_REL13_TAG 0x2062
-
-typedef struct {
-	nr_nfapi_hi_dci0_npdcch_dci_pdu_rel13_t	npdcch_dci_pdu_rel13;
-} nr_nfapi_hi_dci0_npdcch_dci_pdu;
-
-typedef struct {
-	uint8_t pdu_type;
-	uint8_t pdu_size;
-	union {
-		nr_nfapi_hi_dci0_hi_pdu			hi_pdu;
-		nr_nfapi_hi_dci0_dci_pdu			dci_pdu;
-		nr_nfapi_hi_dci0_epdcch_dci_pdu	epdcch_dci_pdu;
-		nr_nfapi_hi_dci0_mpdcch_dci_pdu	mpdcch_dci_pdu;
-		nr_nfapi_hi_dci0_npdcch_dci_pdu	npdcch_dci_pdu;
-	};
-} nr_nfapi_hi_dci0_request_pdu_t;
-
-#define NR_NFAPI_HI_DCI0_MAX_PDU 100
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t sfnsf;
-	uint8_t number_of_dci;
-	uint8_t number_of_hi;
-	nr_nfapi_hi_dci0_request_pdu_t* hi_dci0_pdu_list;
-} nr_nfapi_hi_dci0_request_body_t;
-#define NR_NFAPI_HI_DCI0_REQUEST_BODY_TAG 0x201D
-
-#define NR_NFAPI_TX_MAX_SEGMENTS 32
-typedef struct {
-	uint16_t pdu_length;
-	uint16_t pdu_index;
-	uint8_t num_segments;
-	struct {
-		uint32_t segment_length;
-		uint8_t* segment_data;
-	} segments[NR_NFAPI_TX_MAX_SEGMENTS];
-} nr_nfapi_tx_request_pdu_t;
-
-#define NR_NFAPI_TX_MAX_PDU 100
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_pdus;
-	nr_nfapi_tx_request_pdu_t* tx_pdu_list;
-} nr_nfapi_tx_request_body_t;
-#define NR_NFAPI_TX_REQUEST_BODY_TAG 0x2022
-
-// P7 Message Structures
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint32_t t1;
-	int32_t delta_sfn_sf;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_dl_node_sync_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint32_t t1;
-	uint32_t t2;
-	uint32_t t3;	
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_ul_node_sync_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint32_t last_sfn_sf;
-	uint32_t time_since_last_timing_info;
-	uint32_t dl_config_jitter;
-	uint32_t tx_request_jitter;
-	uint32_t ul_config_jitter;
-	uint32_t hi_dci0_jitter;
-	int32_t dl_config_latest_delay;
-	int32_t tx_request_latest_delay;
-	int32_t ul_config_latest_delay;
-	int32_t hi_dci0_latest_delay;
-	int32_t dl_config_earliest_arrival;
-	int32_t tx_request_earliest_arrival;
-	int32_t ul_config_earliest_arrival;
-	int32_t hi_dci0_earliest_arrival;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_timing_info_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint32_t handle;
-	uint16_t rnti;
-} nr_nfapi_rx_ue_information;
-#define NR_NFAPI_RX_UE_INFORMATION_TAG 0x2038
-
-typedef struct { 
-	uint8_t value_0;
-	uint8_t value_1;
-} nr_nfapi_harq_indication_tdd_harq_data_bundling_t;
-
-typedef struct { 
-	uint8_t value_0;
-	uint8_t value_1;
-	uint8_t value_2;
-	uint8_t value_3;
-} nr_nfapi_harq_indication_tdd_harq_data_multiplexing_t;
-
-typedef struct { 
-	uint8_t value_0;
-} nr_nfapi_harq_indication_tdd_harq_data_special_bundling_t;
-
-typedef struct { 
-	uint8_t value_0;
-} nr_nfapi_harq_indication_tdd_harq_data_t;
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint8_t mode;
-	uint8_t number_of_ack_nack;
-	union{
-		nr_nfapi_harq_indication_tdd_harq_data_bundling_t			bundling;
-		nr_nfapi_harq_indication_tdd_harq_data_multiplexing_t		multiplex;
-		nr_nfapi_harq_indication_tdd_harq_data_special_bundling_t	special_bundling;
-	} harq_data;
-} nr_nfapi_harq_indication_tdd_rel8_t;
-#define NR_NFAPI_HARQ_INDICATION_TDD_REL8_TAG 0x2027
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t mode;
-	uint8_t number_of_ack_nack;
-	union{
-		nr_nfapi_harq_indication_tdd_harq_data_t	bundling;
-		nr_nfapi_harq_indication_tdd_harq_data_t	multiplex;
-		nr_nfapi_harq_indication_tdd_harq_data_special_bundling_t	special_bundling;
-		nr_nfapi_harq_indication_tdd_harq_data_t	channel_selection;
-		nr_nfapi_harq_indication_tdd_harq_data_t	format_3;
-	} harq_data[NR_NFAPI_MAX_NUMBER_ACK_NACK_TDD];
-} nr_nfapi_harq_indication_tdd_rel9_t;
-#define NR_NFAPI_HARQ_INDICATION_TDD_REL9_TAG 0x2028
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t mode;
-	uint16_t number_of_ack_nack;
-	union{
-		nr_nfapi_harq_indication_tdd_harq_data_t					bundling;
-		nr_nfapi_harq_indication_tdd_harq_data_t					multiplex;
-		nr_nfapi_harq_indication_tdd_harq_data_special_bundling_t	special_bundling;
-		nr_nfapi_harq_indication_tdd_harq_data_t					channel_selection;
-		nr_nfapi_harq_indication_tdd_harq_data_t			format_3;
-		nr_nfapi_harq_indication_tdd_harq_data_t			format_4;
-		nr_nfapi_harq_indication_tdd_harq_data_t			format_5;
-	} harq_data[NR_NFAPI_MAX_NUMBER_ACK_NACK_TDD];
-} nr_nfapi_harq_indication_tdd_rel13_t;
-#define NR_NFAPI_HARQ_INDICATION_TDD_REL13_TAG 0x204F
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint8_t harq_tb1;
-	uint8_t harq_tb2;
-} nr_nfapi_harq_indication_fdd_rel8_t;
-#define NR_NFAPI_HARQ_INDICATION_FDD_REL8_TAG 0x2029
-
-#define NR_NFAPI_HARQ_ACK_NACK_REL9_MAX 10
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t mode;
-	uint8_t number_of_ack_nack;
-	uint8_t harq_tb_n[NR_NFAPI_HARQ_ACK_NACK_REL9_MAX];
-} nr_nfapi_harq_indication_fdd_rel9_t;
-#define NR_NFAPI_HARQ_INDICATION_FDD_REL9_TAG 0x202a
-
-#define NR_NFAPI_HARQ_ACK_NACK_REL13_MAX 22 // Need to check this max?
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t mode;
-	uint16_t number_of_ack_nack;
-	uint8_t harq_tb_n[NR_NFAPI_HARQ_ACK_NACK_REL13_MAX];
-} nr_nfapi_harq_indication_fdd_rel13_t;
-#define NR_NFAPI_HARQ_INDICATION_FDD_REL13_TAG 0x2050
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t ul_cqi;
-	uint8_t channel;
-} nr_nfapi_ul_cqi_information_t;
-#define NR_NFAPI_UL_CQI_INFORMATION_TAG 0x2052
-
-// Only expect 1 harq_indication TLV.tag to be set
-// Would this be a better a an union, but not clear which combinations
-// are valid
-typedef struct {
-	uint16_t							instance_length;
-	nr_nfapi_rx_ue_information				rx_ue_information;
-	nr_nfapi_harq_indication_tdd_rel8_t	harq_indication_tdd_rel8;
-	nr_nfapi_harq_indication_tdd_rel9_t	harq_indication_tdd_rel9;
-	nr_nfapi_harq_indication_tdd_rel13_t	harq_indication_tdd_rel13;
-	nr_nfapi_harq_indication_fdd_rel8_t	harq_indication_fdd_rel8;
-	nr_nfapi_harq_indication_fdd_rel9_t	harq_indication_fdd_rel9;
-	nr_nfapi_harq_indication_fdd_rel13_t	harq_indication_fdd_rel13;
-	nr_nfapi_ul_cqi_information_t			ul_cqi_information;
-} nr_nfapi_harq_indication_pdu_t;
-
-#define NR_NFAPI_HARQ_IND_MAX_PDU 100
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_harqs;
-	nr_nfapi_harq_indication_pdu_t* harq_pdu_list;
-} nr_nfapi_harq_indication_body_t;
-#define NR_NFAPI_HARQ_INDICATION_BODY_TAG 0x2026
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t crc_flag;
-} nr_nfapi_crc_indication_rel8_t;
-#define NR_NFAPI_CRC_INDICATION_REL8_TAG 0x202c
-
-typedef struct {
-	uint16_t					instance_length;
-	nr_nfapi_rx_ue_information		rx_ue_information;
-	nr_nfapi_crc_indication_rel8_t	crc_indication_rel8;
-} nr_nfapi_crc_indication_pdu_t;
-
-#define NR_NFAPI_CRC_IND_MAX_PDU 100
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_crcs;
-	nr_nfapi_crc_indication_pdu_t* crc_pdu_list;
-} nr_nfapi_crc_indication_body_t;
-#define NR_NFAPI_CRC_INDICATION_BODY_TAG 0x202b
-
-typedef struct {
-	uint16_t					instance_length;
-	nr_nfapi_rx_ue_information		rx_ue_information;
-	nr_nfapi_ul_cqi_information_t	ul_cqi_information;
-} nr_nfapi_sr_indication_pdu_t;
-
-#define NR_NFAPI_SR_IND_MAX_PDU 100
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_srs;				// Question : should this be srs
-	nr_nfapi_sr_indication_pdu_t* sr_pdu_list;
-} nr_nfapi_sr_indication_body_t;
-#define NR_NFAPI_SR_INDICATION_BODY_TAG 0x202d
-
-// The data offset should be set to 0 or 1 before encoding
-// If it is set to 1 the nfapi library will detemine the correct offset
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t data_offset;
-	uint8_t ul_cqi;
-	uint8_t ri;
-	uint16_t timing_advance;
-} nr_nfapi_cqi_indication_rel8_t;
-#define NR_NFAPI_CQI_INDICATION_REL8_TAG 0x202f
-
-#define NR_NFAPI_CC_MAX 4
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t data_offset;
-	uint8_t ul_cqi;
-	uint8_t number_of_cc_reported;
-	uint8_t ri[NR_NFAPI_CC_MAX];
-	uint16_t timing_advance;
-	uint16_t timing_advance_r9;
-} nr_nfapi_cqi_indication_rel9_t;
-#define NR_NFAPI_CQI_INDICATION_REL9_TAG 0x2030
-
-typedef struct {
-	uint16_t					instance_length;
-	nr_nfapi_rx_ue_information		rx_ue_information;
-	nr_nfapi_cqi_indication_rel8_t cqi_indication_rel8;
-	nr_nfapi_cqi_indication_rel9_t cqi_indication_rel9;
-	nr_nfapi_ul_cqi_information_t	ul_cqi_information;
-} nr_nfapi_cqi_indication_pdu_t;
-
-#define NR_NFAPI_CQI_RAW_MAX_LEN 12
-typedef struct {
-	uint8_t pdu[NR_NFAPI_CQI_RAW_MAX_LEN];
-} nr_nfapi_cqi_indication_raw_pdu_t;
-
-#define NR_NFAPI_CQI_IND_MAX_PDU 100
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_cqis;
-	nr_nfapi_cqi_indication_pdu_t*			cqi_pdu_list;
-	nr_nfapi_cqi_indication_raw_pdu_t*		cqi_raw_pdu_list;
-} nr_nfapi_cqi_indication_body_t;
-#define NR_NFAPI_CQI_INDICATION_BODY_TAG 0x202e
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint16_t rnti;
-	uint8_t preamble;
-	uint16_t timing_advance;
-} nr_nfapi_preamble_pdu_rel8_t;
-#define NR_NFAPI_PREAMBLE_REL8_TAG 0x2032
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t timing_advance_r9;
-} nr_nfapi_preamble_pdu_rel9_t;
-#define NR_NFAPI_PREAMBLE_REL9_TAG 0x2033
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t rach_resource_type;
-} nr_nfapi_preamble_pdu_rel13_t;
-#define NR_NFAPI_PREAMBLE_REL13_TAG 0x2051
-
-typedef struct { 
-	uint16_t					instance_length;
-	nr_nfapi_preamble_pdu_rel8_t	preamble_rel8;
-	nr_nfapi_preamble_pdu_rel9_t	preamble_rel9;
-	nr_nfapi_preamble_pdu_rel13_t	preamble_rel13;
-} nr_nfapi_preamble_pdu_t;
-
-#define NR_NFAPI_PREAMBLE_MAX_PDU 100
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_preambles;
-	nr_nfapi_preamble_pdu_t*			preamble_list;
-} nr_nfapi_rach_indication_body_t;
-#define NR_NFAPI_RACH_INDICATION_BODY_TAG 0x2031
-
-#define NR_NFAPI_NUM_RB_MAX 1000
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t doppler_estimation;
-	uint16_t timing_advance;
-	uint8_t number_of_resource_blocks;
-	uint8_t rb_start;
-	uint8_t snr[NR_NFAPI_NUM_RB_MAX];
-} nr_nfapi_srs_indication_fdd_rel8_t;
-#define NR_NFAPI_SRS_INDICATION_FDD_REL8_TAG 0x2035
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint16_t timing_advance_r9;
-} nr_nfapi_srs_indication_fdd_rel9_t;
-#define NR_NFAPI_SRS_INDICATION_FDD_REL9_TAG 0x2036
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint8_t uppts_symbol;
-} nr_nfapi_srs_indication_ttd_rel10_t;
-#define NR_NFAPI_SRS_INDICATION_TDD_REL10_TAG 0x2037
-
-typedef struct { 
-	nr_nfapi_tl_t tl;
-	uint16_t ul_rtoa;
-} nr_nfapi_srs_indication_fdd_rel11_t;
-#define NR_NFAPI_SRS_INDICATION_FDD_REL11_TAG 0x2053
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t num_prb_per_subband;
-	uint8_t number_of_subbands;
-	uint8_t num_atennas;
-	struct {
-		uint8_t subband_index;
-		uint16_t channel[NR_NFAPI_MAX_NUM_PHYSICAL_ANTENNAS];
-	} subands[NR_NFAPI_MAX_NUM_SUBBANDS];
-} nr_nfapi_tdd_channel_measurement_t;
-#define NR_NFAPI_TDD_CHANNEL_MEASUREMENT_TAG 0x2054
-
-typedef struct {
-	uint16_t							instance_length;
-	nr_nfapi_rx_ue_information				rx_ue_information;
-	nr_nfapi_srs_indication_fdd_rel8_t		srs_indication_fdd_rel8;
-	nr_nfapi_srs_indication_fdd_rel9_t		srs_indication_fdd_rel9;
-	nr_nfapi_srs_indication_ttd_rel10_t	srs_indication_tdd_rel10;
-	nr_nfapi_srs_indication_fdd_rel11_t	srs_indication_fdd_rel11;
-	nr_nfapi_tdd_channel_measurement_t		tdd_channel_measurement;
-} nr_nfapi_srs_indication_pdu_t;
-
-#define NR_NFAPI_SRS_IND_MAX_PDU 16
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t number_of_ues;
-	nr_nfapi_srs_indication_pdu_t* srs_pdu_list;
-} nr_nfapi_srs_indication_body_t;
-#define NR_NFAPI_SRS_INDICATION_BODY_TAG 0x2034
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t length;
-	uint16_t offset;
-	uint8_t ul_cqi;
-	uint16_t timing_advance;
-} nr_nfapi_rx_indication_rel8_t;
-#define NR_NFAPI_RX_INDICATION_REL8_TAG 0x2024
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t timing_advance_r9;
- } nr_nfapi_rx_indication_rel9_t;
-#define NR_NFAPI_RX_INDICATION_REL9_TAG 0x2025
-
-typedef struct {
-	nr_nfapi_rx_ue_information rx_ue_information;
-	nr_nfapi_rx_indication_rel8_t rx_indication_rel8;
-	nr_nfapi_rx_indication_rel9_t rx_indication_rel9;
-	uint8_t* data;
-} nr_nfapi_rx_indication_pdu_t;
-
-#define NR_NFAPI_RX_IND_MAX_PDU 100
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_pdus;
-	nr_nfapi_rx_indication_pdu_t* rx_pdu_list;
-} nr_nfapi_rx_indication_body_t;
-#define NR_NFAPI_RX_INDICATION_BODY_TAG 0x2023
-
-typedef struct {
-	nr_nfapi_tl_t tl;	
-	uint8_t harq_tb1;
-} nr_nfapi_nb_harq_indication_fdd_rel13_t;
-#define NR_NFAPI_NB_HARQ_INDICATION_FDD_REL13_TAG 0x2064
-
-typedef struct {
-	uint16_t								instance_length;
-	nr_nfapi_rx_ue_information					rx_ue_information;
-	nr_nfapi_nb_harq_indication_fdd_rel13_t	nb_harq_indication_fdd_rel13;
-	nr_nfapi_ul_cqi_information_t				ul_cqi_information;
-} nr_nfapi_nb_harq_indication_pdu_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_harqs;
-	nr_nfapi_nb_harq_indication_pdu_t* nb_harq_pdu_list;
-} nr_nfapi_nb_harq_indication_body_t;
-#define NR_NFAPI_NB_HARQ_INDICATION_BODY_TAG 0x2063
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t rnti;
-	uint8_t initial_sc;
-	uint16_t timing_advance;
-	uint8_t nrach_ce_level;
-} nr_nfapi_nrach_indication_pdu_rel13_t;
-#define NR_NFAPI_NRACH_INDICATION_REL13_TAG 0x2066
-
-typedef struct {
-	nr_nfapi_nrach_indication_pdu_rel13_t		nrach_indication_rel13;
-} nr_nfapi_nrach_indication_pdu_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t number_of_initial_scs_detected;
-	nr_nfapi_nrach_indication_pdu_t* nrach_pdu_list;
-} nr_nfapi_nrach_indication_body_t;
-#define NR_NFAPI_NRACH_INDICATION_BODY_TAG 0x2065
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint32_t handle;
-	uint32_t mp_cca;
-	uint32_t n_cca;
-	uint32_t offset;
-	uint32_t lte_txop_sf;
-	uint16_t txop_sfn_sf_end;
-	uint32_t lbt_mode;
-} nr_nfapi_lbt_pdsch_req_pdu_rel13_t;
-#define NR_NFAPI_LBT_PDSCH_REQ_PDU_REL13_TAG 0x2056
-
-typedef struct {
-	nr_nfapi_lbt_pdsch_req_pdu_rel13_t lbt_pdsch_req_pdu_rel13;
-} nr_nfapi_lbt_pdsch_req_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint32_t handle;
-	uint32_t offset;
-	uint16_t sfn_sf_end;
-	uint32_t lbt_mode;
-} nr_nfapi_lbt_drs_req_pdu_rel13_t;
-#define NR_NFAPI_LBT_DRS_REQ_PDU_REL13_TAG 0x2057
-
-typedef struct {
-	nr_nfapi_lbt_drs_req_pdu_rel13_t lbt_drs_req_pdu_rel13;
-} nr_nfapi_lbt_drs_req_pdu;
-
-typedef struct {
-	uint8_t pdu_type;
-	uint8_t pdu_size;
-	union {
-		nr_nfapi_lbt_pdsch_req_pdu		lbt_pdsch_req_pdu;
-		nr_nfapi_lbt_drs_req_pdu		lbt_drs_req_pdu;
-	};
-} nr_nfapi_lbt_dl_config_request_pdu_t;
-
-#define NR_NFAPI_LBT_DL_CONFIG_REQ_MAX_PDU 16
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_pdus;
-	nr_nfapi_lbt_dl_config_request_pdu_t*		lbt_dl_config_req_pdu_list;
-} nr_nfapi_lbt_dl_config_request_body_t;
-#define NR_NFAPI_LBT_DL_CONFIG_REQUEST_BODY_TAG 0x2055
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint32_t handle;
-	uint32_t result;
-	uint32_t lte_txop_symbols;
-	uint32_t initial_partial_sf;
-} nr_nfapi_lbt_pdsch_rsp_pdu_rel13_t;
-#define NR_NFAPI_LBT_PDSCH_RSP_PDU_REL13_TAG 0x2059
-
-typedef struct {
-	nr_nfapi_lbt_pdsch_rsp_pdu_rel13_t lbt_pdsch_rsp_pdu_rel13;
-} nr_nfapi_lbt_pdsch_rsp_pdu;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint32_t handle;
-	uint32_t result;
-} nr_nfapi_lbt_drs_rsp_pdu_rel13_t;
-#define NR_NFAPI_LBT_DRS_RSP_PDU_REL13_TAG 0x205A
-
-typedef struct {
-	nr_nfapi_lbt_drs_rsp_pdu_rel13_t lbt_drs_rsp_pdu_rel13;
-} nr_nfapi_lbt_drs_rsp_pdu;
-
-
-typedef struct {
-	uint8_t pdu_type;
-	uint8_t pdu_size;
-	union {
-		nr_nfapi_lbt_pdsch_rsp_pdu		lbt_pdsch_rsp_pdu;
-		nr_nfapi_lbt_drs_rsp_pdu		lbt_drs_rsp_pdu;
-	};
-} nr_nfapi_lbt_dl_indication_pdu_t;
-
-#define NR_NFAPI_LBT_IND_MAX_PDU 16
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_pdus;
-	nr_nfapi_lbt_dl_indication_pdu_t* lbt_indication_pdu_list;
-} nr_nfapi_lbt_dl_indication_body_t;
-#define NR_NFAPI_LBT_DL_INDICATION_BODY_TAG 0x2058
-
-typedef struct {
-} nr_nfapi_error_indication_msg_invalid_state;
-
-typedef struct {
-} nr_nfapi_error_indication_msg_bch_missing;
-
-typedef struct {
-	uint16_t recieved_sfn_sf;
-	uint16_t expected_sfn_sf;
-} nr_nfapi_error_indication_sfn_out_of_sync;
-
-typedef struct {
-	uint8_t sub_error_code;
-	uint8_t direction;
-	uint16_t rnti;
-	uint8_t pdu_type;
-} nr_nfapi_error_indication_msg_pdu_err;
-
-typedef struct {
-	uint16_t recieved_sfn_sf;
-	uint16_t expected_sfn_sf;
-} nr_nfapi_error_indication_msg_invalid_sfn;
-
-typedef struct {
-	uint8_t sub_error_code;
-	uint8_t phich_lowest_ul_rb_index;
-} nr_nfapi_error_indication_msg_hi_err;
-
-typedef struct {
-	uint8_t sub_error_code;
-	uint16_t pdu_index;
-} nr_nfapi_error_indication_msg_tx_err;
-
-// 
-// P4 Message Structures
-//
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t frequency_band_indicator;
-	uint16_t measurement_period;
-	uint8_t bandwidth;
-	uint32_t timeout;
-	uint8_t number_of_earfcns;
-	uint16_t earfcn[NR_NFAPI_MAX_CARRIER_LIST];
-} nr_nfapi_lte_rssi_request_t;
-
-#define NR_NFAPI_LTE_RSSI_REQUEST_TAG 0x3000
-
-#define NR_NFAPI_P4_START_TAG NR_NFAPI_LTE_RSSI_REQUEST_TAG
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t frequency_band_indicator;
-	uint16_t measurement_period;
-	uint32_t timeout;
-	uint8_t number_of_uarfcns;
-	uint16_t uarfcn[NR_NFAPI_MAX_CARRIER_LIST];
-} nr_nfapi_utran_rssi_request_t;
-
-#define NR_NFAPI_UTRAN_RSSI_REQUEST_TAG 0x3001
-
-typedef struct {
-	uint16_t arfcn;
-	uint8_t direction;
-} nr_nfapi_arfcn_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t frequency_band_indicator;
-	uint16_t measurement_period;
-	uint32_t timeout;
-	uint8_t number_of_arfcns;
-	nr_nfapi_arfcn_t arfcn[NR_NFAPI_MAX_CARRIER_LIST];
-} nr_nfapi_geran_rssi_request_t;
-
-#define NR_NFAPI_GERAN_RSSI_REQUEST_TAG 0x3002
-
-
-
-typedef struct {
-	uint16_t earfcn;
-	uint8_t number_of_ro_dl;
-	uint8_t ro_dl[NR_NFAPI_MAX_RO_DL];
-} nr_nfapi_earfcn_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t frequency_band_indicator;
-	uint16_t measurement_period;
-	uint32_t timeout;
-	uint8_t number_of_earfcns;
-	nr_nfapi_earfcn_t earfcn[NR_NFAPI_MAX_CARRIER_LIST];
-} nr_nfapi_nb_iot_rssi_request_t;
-
-#define NR_NFAPI_NB_IOT_RSSI_REQUEST_TAG 0x3020
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_rssi;
-	int16_t rssi[NR_NFAPI_MAX_RSSI];
-} nr_nfapi_rssi_indication_body_t;
-
-#define NR_NFAPI_RSSI_INDICATION_TAG 0x3003
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint8_t measurement_bandwidth;
-	uint8_t exhaustive_search;
-	uint32_t timeout;
-	uint8_t number_of_pci;
-	uint16_t pci[NR_NFAPI_MAX_PCI_LIST];
-} nr_nfapi_lte_cell_search_request_t;
-
-#define NR_NFAPI_LTE_CELL_SEARCH_REQUEST_TAG 0x3004
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t uarfcn;
-	uint8_t exhaustive_search;
-	uint32_t timeout;
-	uint8_t number_of_psc;
-	uint16_t psc[NR_NFAPI_MAX_PSC_LIST];
-} nr_nfapi_utran_cell_search_request_t;
-
-#define NR_NFAPI_UTRAN_CELL_SEARCH_REQUEST_TAG 0x3005
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint32_t timeout;
-	uint8_t number_of_arfcn;
-	uint16_t arfcn[NR_NFAPI_MAX_ARFCN_LIST];
-} nr_nfapi_geran_cell_search_request_t;
-
-#define NR_NFAPI_GERAN_CELL_SEARCH_REQUEST_TAG 0x3006
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint8_t ro_dl;
-	uint8_t exhaustive_search;
-	uint32_t timeout;
-	uint8_t number_of_pci;
-	uint16_t pci[NR_NFAPI_MAX_PCI_LIST];
-} nr_nfapi_nb_iot_cell_search_request_t;
-
-#define NR_NFAPI_NB_IOT_CELL_SEARCH_REQUEST_TAG 0x3021
-
-typedef struct {
-	uint16_t pci;
-	uint8_t rsrp;
-	uint8_t rsrq;
-	int16_t frequency_offset;
-} nr_nfapi_lte_found_cell_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_lte_cells_found;
-	nr_nfapi_lte_found_cell_t lte_found_cells[NR_NFAPI_MAX_LTE_CELLS_FOUND];
-} nr_nfapi_lte_cell_search_indication_t;
-
-#define NR_NFAPI_LTE_CELL_SEARCH_INDICATION_TAG 0x3007
-
-typedef struct {
-	uint16_t psc;
-	uint8_t rscp;
-	uint8_t ecno;
-	int16_t frequency_offset;
-} nr_nfapi_utran_found_cell_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_utran_cells_found;
-	nr_nfapi_utran_found_cell_t utran_found_cells[NR_NFAPI_MAX_UTRAN_CELLS_FOUND];
-} nr_nfapi_utran_cell_search_indication_t;
-
-#define NR_NFAPI_UTRAN_CELL_SEARCH_INDICATION_TAG 0x3008
-
-typedef struct {
-	uint16_t arfcn;
-	uint8_t bsic;
-	uint8_t rxlev;
-	uint8_t rxqual;
-	int16_t frequency_offset;
-	uint32_t sfn_offset;
-} nr_nfapi_gsm_found_cell_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_gsm_cells_found;
-	nr_nfapi_gsm_found_cell_t gsm_found_cells[NR_NFAPI_MAX_GSM_CELLS_FOUND];
-} nr_nfapi_geran_cell_search_indication_t;
-
-#define NR_NFAPI_GERAN_CELL_SEARCH_INDICATION_TAG 0x3009
-
-typedef struct {
-	uint16_t pci;
-	uint8_t rsrp;
-	uint8_t rsrq;
-	int16_t frequency_offset;
-} nr_nfapi_nb_iot_found_cell_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t number_of_nb_iot_cells_found;
-	nr_nfapi_nb_iot_found_cell_t nb_iot_found_cells[NR_NFAPI_MAX_NB_IOT_CELLS_FOUND];
-} nr_nfapi_nb_iot_cell_search_indication_t;
-
-#define NR_NFAPI_NB_IOT_CELL_SEARCH_INDICATION_TAG 0x3022
-
-typedef nr_nfapi_opaqaue_data_t nr_nfapi_pnf_cell_search_state_t;
-
-#define NR_NFAPI_PNF_CELL_SEARCH_STATE_TAG 0x300A
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint16_t pci;
-	uint32_t timeout;
-} nr_nfapi_lte_broadcast_detect_request_t;
-
-#define NR_NFAPI_LTE_BROADCAST_DETECT_REQUEST_TAG 0x300B
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t uarfcn;
-	uint16_t psc;
-	uint32_t timeout;
-} nr_nfapi_utran_broadcast_detect_request_t;
-
-#define NR_NFAPI_UTRAN_BROADCAST_DETECT_REQUEST_TAG 0x300C
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint8_t ro_dl;
-	uint16_t pci;
-	uint32_t timeout;
-} nr_nfapi_nb_iot_broadcast_detect_request_t;
-
-#define NR_NFAPI_NB_IOT_BROADCAST_DETECT_REQUEST_TAG 0x3023
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t number_of_tx_antenna;
-	uint16_t mib_length;
-	uint8_t mib[NR_NFAPI_MAX_MIB_LENGTH];
-	uint32_t sfn_offset;
-} nr_nfapi_lte_broadcast_detect_indication_t;
-
-#define NR_NFAPI_LTE_BROADCAST_DETECT_INDICATION_TAG 0x300E
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t mib_length;
-	uint8_t mib[NR_NFAPI_MAX_MIB_LENGTH];
-	uint32_t sfn_offset;
-} nr_nfapi_utran_broadcast_detect_indication_t;
-
-#define NR_NFAPI_UTRAN_BROADCAST_DETECT_INDICATION_TAG 0x300F
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t number_of_tx_antenna;
-	uint16_t mib_length;
-	uint8_t mib[NR_NFAPI_MAX_MIB_LENGTH];
-	uint32_t sfn_offset;
-} nr_nfapi_nb_iot_broadcast_detect_indication_t;
-
-#define NR_NFAPI_NB_IOT_BROADCAST_DETECT_INDICATION_TAG 0x3024
-
-#define NR_NFAPI_PNF_CELL_BROADCAST_STATE_TAG 0x3010
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint16_t pci;
-	uint16_t downlink_channel_bandwidth;
-	uint8_t phich_configuration;
-	uint8_t number_of_tx_antenna;
-	uint8_t retry_count;
-	uint32_t timeout;
-} nr_nfapi_lte_system_information_schedule_request_t;
-
-#define NR_NFAPI_LTE_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG 0x3011
-
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint8_t ro_dl;
-	uint16_t pci;
-	uint8_t scheduling_info_sib1_nb;
-	uint32_t timeout;
-} nr_nfapi_nb_iot_system_information_schedule_request_t;
-
-#define NR_NFAPI_NB_IOT_SYSTEM_INFORMATION_SCHEDULE_REQUEST_TAG 0x3025
-
-typedef nr_nfapi_opaqaue_data_t nr_nfapi_pnf_cell_broadcast_state_t;
-
-typedef struct {
-	uint8_t si_periodicity;
-	uint8_t si_index;
-} nr_nfapi_lte_system_information_si_periodicity_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint16_t pci;
-	uint16_t downlink_channel_bandwidth;
-	uint8_t phich_configuration;
-	uint8_t number_of_tx_antenna;
-	uint8_t number_of_si_periodicity;
-	nr_nfapi_lte_system_information_si_periodicity_t si_periodicity[NR_NFAPI_MAX_SI_PERIODICITY];
-	uint8_t si_window_length;
-	uint32_t timeout;
-} nr_nfapi_lte_system_information_request_t;
-
-#define NR_NFAPI_LTE_SYSTEM_INFORMATION_REQUEST_TAG 0x3014
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t uarfcn;
-	uint16_t psc;
-	uint32_t timeout;
-} nr_nfapi_utran_system_information_request_t;
-
-#define NR_NFAPI_UTRAN_SYSTEM_INFORMATION_REQUEST_TAG 0x3015
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t arfcn;
-	uint8_t bsic;
-	uint32_t timeout;
-} nr_nfapi_geran_system_information_request_t;
-
-#define NR_NFAPI_GERAN_SYSTEM_INFORMATION_REQUEST_TAG 0x3016
-
-typedef struct {
-	uint8_t si_periodicity;
-	uint8_t si_repetition_pattern;
-	uint8_t si_tb_size;
-	uint8_t number_of_si_index;
-	uint8_t si_index[NR_NFAPI_MAX_SI_INDEX];
-} nr_nfapi_nb_iot_system_information_si_periodicity_t;
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t earfcn;
-	uint8_t ro_dl;
-	uint16_t pci;
-	uint8_t number_of_si_periodicity;
-	nr_nfapi_nb_iot_system_information_si_periodicity_t si_periodicity[NR_NFAPI_MAX_SI_PERIODICITY];
-	uint8_t si_window_length;
-	uint32_t timeout;
-} nr_nfapi_nb_iot_system_information_request_t;
-
-#define NR_NFAPI_NB_IOT_SYSTEM_INFORMATION_REQUEST_TAG 0x3027
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t sib_type;
-	uint16_t sib_length;
-	uint8_t sib[NR_NFAPI_MAX_SIB_LENGTH];
-} nr_nfapi_lte_system_information_indication_t;
-
-#define NR_NFAPI_LTE_SYSTEM_INFORMATION_INDICATION_TAG 0x3018
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t sib_length;
-	uint8_t sib[NR_NFAPI_MAX_SIB_LENGTH];
-} nr_nfapi_utran_system_information_indication_t;
-
-#define NR_NFAPI_UTRAN_SYSTEM_INFORMATION_INDICATION_TAG 0x3019
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint16_t si_length;
-	uint8_t si[NR_NFAPI_MAX_SI_LENGTH];
-} nr_nfapi_geran_system_information_indication_t;
-
-#define NR_NFAPI_GERAN_SYSTEM_INFORMATION_INDICATION_TAG 0x301a
-
-typedef struct {
-	nr_nfapi_tl_t tl;
-	uint8_t sib_type;
-	uint16_t sib_length;
-	uint8_t sib[NR_NFAPI_MAX_SIB_LENGTH];
-} nr_nfapi_nb_iot_system_information_indication_t;
-
-#define NR_NFAPI_NB_IOT_SYSTEM_INFORMATION_INDICATION_TAG 0x3026
-
-
-//
-// Top level NFAP messages
-//
-
-//
-// P7
-//
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_dl_config_request_body_t dl_config_request_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_dl_config_request_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_ul_config_request_body_t ul_config_request_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_ul_config_request_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_hi_dci0_request_body_t hi_dci0_request_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_hi_dci0_request_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_tx_request_body_t tx_request_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_tx_request_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-} nr_nfapi_subframe_indication_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_harq_indication_body_t harq_indication_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_harq_indication_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_crc_indication_body_t crc_indication_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_crc_indication_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_sr_indication_body_t sr_indication_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_sr_indication_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_cqi_indication_body_t cqi_indication_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_cqi_indication_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_rach_indication_body_t rach_indication_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_rach_indication_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_srs_indication_body_t srs_indication_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_srs_indication_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_rx_indication_body_t rx_indication_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_rx_indication_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_nb_harq_indication_body_t nb_harq_indication_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_nb_harq_indication_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_nrach_indication_body_t nrach_indication_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_nrach_indication_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_lbt_dl_config_request_body_t lbt_dl_config_request_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_lbt_dl_config_request_t;
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint16_t sfn_sf;
-	nr_nfapi_lbt_dl_indication_body_t lbt_dl_indication_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_lbt_dl_indication_t;
-
-
-typedef struct {
-	nr_nfapi_p7_message_header_t header;
-	uint8_t message_id;
-	uint8_t error_code;
-	union {
-		nr_nfapi_error_indication_msg_invalid_state	msg_invalid_state;
-		nr_nfapi_error_indication_msg_bch_missing		msg_bch_missing;
-		nr_nfapi_error_indication_sfn_out_of_sync		sfn_out_of_sync;
-		nr_nfapi_error_indication_msg_pdu_err			msg_pdu_err;
-		nr_nfapi_error_indication_msg_invalid_sfn		msg_invalid_sfn;
-		nr_nfapi_error_indication_msg_hi_err			msg_hi_err;
-		nr_nfapi_error_indication_msg_tx_err			msg_tx_err;
-	};
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_error_indication_t;
-
-// 
-// P4 Messages
-// 
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint8_t rat_type;
-	union {
-		nr_nfapi_lte_rssi_request_t					lte_rssi_request;
-		nr_nfapi_utran_rssi_request_t					utran_rssi_request;
-		nr_nfapi_geran_rssi_request_t					geran_rssi_request;
-		nr_nfapi_nb_iot_rssi_request_t					nb_iot_rssi_request;
-	};
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_rssi_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_rssi_response_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_rssi_indication_body_t rssi_indication_body;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_rssi_indication_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint8_t rat_type;
-	union {
-		nr_nfapi_lte_cell_search_request_t				lte_cell_search_request;
-		nr_nfapi_utran_cell_search_request_t			utran_cell_search_request;
-		nr_nfapi_geran_cell_search_request_t			geran_cell_search_request;
-		nr_nfapi_nb_iot_cell_search_request_t			nb_iot_cell_search_request;
-	};
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_cell_search_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_cell_search_response_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_lte_cell_search_indication_t lte_cell_search_indication;
-	nr_nfapi_utran_cell_search_indication_t utran_cell_search_indication;
-	nr_nfapi_geran_cell_search_indication_t geran_cell_search_indication;
-	nr_nfapi_pnf_cell_search_state_t pnf_cell_search_state;
-	nr_nfapi_nb_iot_cell_search_indication_t nb_iot_cell_search_indication;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_cell_search_indication_t;
-
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint8_t rat_type;
-	union {
-		nr_nfapi_lte_broadcast_detect_request_t		lte_broadcast_detect_request;
-		nr_nfapi_utran_broadcast_detect_request_t		utran_broadcast_detect_request;
-		nr_nfapi_nb_iot_broadcast_detect_request_t		nb_iot_broadcast_detect_request;
-	};
-	nr_nfapi_pnf_cell_search_state_t pnf_cell_search_state;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_broadcast_detect_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_broadcast_detect_response_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_lte_broadcast_detect_indication_t lte_broadcast_detect_indication;
-	nr_nfapi_utran_broadcast_detect_indication_t utran_broadcast_detect_indication;
-	nr_nfapi_nb_iot_broadcast_detect_indication_t nb_iot_broadcast_detect_indication;
-	nr_nfapi_pnf_cell_broadcast_state_t pnf_cell_broadcast_state;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_broadcast_detect_indication_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint8_t rat_type;
-	union {
-		nr_nfapi_lte_system_information_schedule_request_t lte_system_information_schedule_request;
-		nr_nfapi_nb_iot_system_information_schedule_request_t nb_iot_system_information_schedule_request;
-	};
-	nr_nfapi_pnf_cell_broadcast_state_t pnf_cell_broadcast_state;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_system_information_schedule_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_system_information_schedule_response_t;
-
-typedef struct { 
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_lte_system_information_indication_t lte_system_information_indication;
-	nr_nfapi_nb_iot_system_information_indication_t nb_iot_system_information_indication;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_system_information_schedule_indication_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint8_t rat_type;
-	union {
-		nr_nfapi_lte_system_information_request_t lte_system_information_request;
-		nr_nfapi_utran_system_information_request_t utran_system_information_request;
-		nr_nfapi_geran_system_information_request_t geran_system_information_request;
-		nr_nfapi_nb_iot_system_information_request_t nb_iot_system_information_request;
-	};
-	nr_nfapi_pnf_cell_broadcast_state_t pnf_cell_broadcast_state;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_system_information_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_system_information_response_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_lte_system_information_indication_t lte_system_information_indication;
-	nr_nfapi_utran_system_information_indication_t utran_system_information_indication;
-	nr_nfapi_geran_system_information_indication_t geran_system_information_indication;
-	nr_nfapi_nb_iot_system_information_indication_t nb_iot_system_information_indication;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_system_information_indication_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_nmm_stop_request_t;
-
-typedef struct {
-	nr_nfapi_p4_p5_message_header_t header;
-	uint32_t error_code;
-	nr_nfapi_vendor_extension_tlv_t vendor_extension;
-} nr_nfapi_nmm_stop_response_t;
-
-//
-// Configuration options for the encode decode functions
-//
-
-/*! Configuration options for the p7 pack unpack functions
- *
- */
-typedef struct nr_nfapi_p7_codec_config {
-
-	/*! Optional call back to allow the user to define the memory allocator. 
-	 *  \param size The size of the memory to allocate
-	 *  \return a pointer to a valid memory block or 0 if it has failed.
-	 *
-	 * If not set the nfapi unpack functions will use malloc
-	 */
-	void* (*allocate)(size_t size);
-
-	/*! Optional call back to allow the user to define the memory deallocator. 
-	 *  \param ptr A poiner to a memory block allocated by the allocate callback
-	 * 
-	 *	If not set the client should use free
-	 */
-	void (*deallocate)(void* ptr);
-
-	/*! Optional call back function to handle unpacking vendor extension tlv.
-	 *  \param tl A pointer to a decoded tag length structure
-	 *  \param ppReadPackedMsg A handle to the read buffer. 
-	 *  \param end The end of the read buffer
-	 *  \param ve A handle to a vendor extention structure that the call back should allocate if the structure can be decoded
-	 *  \param config A pointer to the p7 codec configuration
-	 *  \return return 0 if packed successfully, -1 if failed.
-	 *
-	 *  If not set the tlv will be skipped
-	 *
-	 *  Client should use the help methods in nfapi.h to decode the vendor extention.
-	 * 
-	 *  \todo Add code example
-	 */
-	int (*unpack_vendor_extension_tlv)(nr_nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, void** ve, struct nr_nfapi_p7_codec_config* config);
-
-	/*! Optional call back function to handle packing vendor extension tlv. 
-	 *  \param ve A pointer to a vendor extention structure.
-	 *  \param ppWritePackedMsg A handle to the write buffer
-	 *  \param end The end of the write buffer. The callee should make sure not to write beyond the end
-	 *  \param config A pointer to the p7 codec configuration
-	 *  \return return 0 if packed successfully, -1 if failed.
-	 * 
-	 *  If not set the the tlv will be skipped
-	 * 
-	 *  Client should use the help methods in nfapi.h to encode the vendor extention
-	 * 
-	 *  \todo Add code example
-	 */
-	int (*pack_vendor_extension_tlv)(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, struct nr_nfapi_p7_codec_config* config);
-
-	/*! Optional call back function to handle unpacking vendor extension messages. 
-	 *  \param header A pointer to a decode P7 message header for the vendor extention message
-	 *  \param ppReadPackedMsg A handle to the encoded data buffer
-	 *  \param end A pointer to the end of the encoded data buffer
-	 *  \param config  A pointer to the p7 codec configuration
-	 *  \return 0 if unpacked successfully, -1 if failed
-	 *
-	 *  If not set the message will be ignored
-	 *
-	 *  If the message if is unknown the function should return -1
-	 */
-	int (*unpack_p7_vendor_extension)(nr_nfapi_p7_message_header_t* header, uint8_t **ppReadPackedMsg, uint8_t *end, struct nr_nfapi_p7_codec_config* config);
-
-	/*! Optional call back function to handle packing vendor extension messages. 
-	 *  \param header A poiner to a P7 message structure for the venfor extention message
-	 *  \param ppWritePackedmsg A handle to the buffer to write the encoded message into
-	 *  \param end A pointer to the end of the buffer
-	 *  \param cofig A pointer to the p7 codec configuration
-	 *  \return 0 if packed successfully, -1 if failed
-	 * 
-	 * If not set the the message will be ingored
-	 *	 
-	 *  If the message if is unknown the function should return -1
-	 */
-	int (*pack_p7_vendor_extension)(nr_nfapi_p7_message_header_t* header, uint8_t **ppWritePackedmsg, uint8_t *end, struct nr_nfapi_p7_codec_config* config);
-
-	/*! Optional user data that will be passed back with callbacks
-	 */
-	void* user_data;
-
-} nr_nfapi_p7_codec_config_t;
-
-/*! Configuration options for the p4 & p5 pack unpack functions
- *
- */
-typedef struct nr_nfapi_p4_p5_codec_config {
-
-	/*! Optional call back to allow the user to define the memory allocator.
-     *  \param size The size of the memory to allocate
-	 *  \return a pointer to a valid memory block or 0 if it has failed.
-	 *
-	 *  If not set the nfapi unpack functions will use malloc
-	 */
-	void* (*allocate)(size_t size);
-
-	/*! Optional call back to allow the user to define the memory deallocator. 
-	 *  \param ptr A poiner to a memory block allocated by the allocate callback
-	 *
-	 *  If not set free will be used
-	 */
-	void (*deallocate)(void* ptr);
-
-	/*! Optional call back function to handle unpacking vendor extension tlv.
-	 *  \param tl A pointer to a decoded tag length structure
-	 *  \param ppReadPackedMsg A handle to the data buffer to decode
-	 *  \param end A pointer to the end of the buffer
-	 *  \param ve A handle to a vendor extention structure that will be allocated by this callback
-	 *  \param config A pointer to the P4/P5 codec configuration
-	 *  \return 0 if unpacked successfully, -1 if failed
-	 *  
-	 *  If not set the tlv will be skipped
-	 */
-	int (*unpack_vendor_extension_tlv)(nr_nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, void** ve, struct nr_nfapi_p4_p5_codec_config* config);
-
-	/*! Optional call back function to handle packing vendor extension tlv. 
-	 *  \param ve
-	 *  \param ppWritePackedMsg A handle to the data buffer pack the tlv into
-	 *  \param end A pointer to the end of the buffer
-	 *  \param config A pointer to the P4/P5 codec configuration
-	 *  \return 0 if packed successfully, -1 if failed
-	 *
-	 *  If not set the the tlv will be skipped
-	 */
-	int (*pack_vendor_extension_tlv)(void* ve, uint8_t **ppWritePackedMsg, uint8_t *end, struct nr_nfapi_p4_p5_codec_config* config);
-
-	/*! Optional call back function to handle unpacking vendor extension messages. 
-	 *  \param header A pointer to a decode P4/P5 message header
-	 *  \param ppReadPackgedMsg A handle to the data buffer to decode
-	 *  \param end A pointer to the end of the buffer
-	 *  \param config A pointer to the P4/P5 codec configuration
-	 *  \return 0 if packed successfully, -1 if failed
-	 *
-	 * If not set the message will be ignored
-	 */
-	int (*unpack_p4_p5_vendor_extension)(nr_nfapi_p4_p5_message_header_t* header, uint8_t **ppReadPackedMsg, uint8_t *end, struct nr_nfapi_p4_p5_codec_config* config);
-
-	/*! Optional call back function to handle packing vendor extension messages.
-	 *  \param header A pointer to the P4/P5 message header to be encoded
-	 *  \param ppWritePackedMsg A handle to the data buffer pack the message into
-	 *  \param end A pointer to the end of the buffer
-	 *  \param config A pointer to the P4/P5 codec configuration
-	 *  \return 0 if packed successfully, -1 if failed
-	 *  
-	 *  If not set the the message will be ingored
-	 */
-	int (*pack_p4_p5_vendor_extension)(nr_nfapi_p4_p5_message_header_t* header, uint8_t **ppwritepackedmsg, uint8_t *end, struct nr_nfapi_p4_p5_codec_config* config);
-
-	/*! Optional user data that will be passed back with callbacks
-	 */
-	void* user_data;
-
-} nr_nfapi_p4_p5_codec_config_t;
-
-//
-// Functions
-// 
-
-/*! \brief Encodes an NFAPI P4 message to a buffer
- *  \param pMessageBuf A pointer to a nfapi p4 message structure
- *  \param messageBufLen The size of the p4 message structure
- *  \param pPackedBuf A pointer to the buffer that the p4 message will be packed into
- *  \param packedBufLen The size of the buffer 
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will encode a nFAPI P4 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf.
- * 
- */
-int nr_nfapi_p4_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nr_nfapi_p4_p5_codec_config_t* config);
-
-/*! \brief Decodes a NFAPI P4 message header
- *  \param pMessageBuf A pointer to an encoded P4 message header
- *  \param messageBufLen The size of the encoded P4 message header
- *  \param pUnpackedBuf A pointer to the nr_nfapi_message_header
- *  \param unpackedBufLen The size of nr_nfapi_message_header structure.
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will decode a byte stream pointed to by pMessageBuf into a nr_nfapi_p4_p5_message_header structure pointer to by pUnpackedBuf
- */
-int nr_nfapi_p4_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nr_nfapi_p4_p5_codec_config_t* config);
-
-/*! \brief Decodes a NFAPI P4 message
- *  \param pMessageBuf A pointer to an encoded P4 message
- *  \param messageBufLen The size of the encoded P4 message
- *  \param pUnpackedBuf A pointer to the nr_nfapi_message_header
- *  \param unpackedBufLen The size of nr_nfapi_message_header structure.
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will decode a byte stream pointed to by pMessageBuf into a nfapi p4 message structure pointer to by pUnpackedBuf 
- */
-int nr_nfapi_p4_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nr_nfapi_p4_p5_codec_config_t* config);
-
-/*! \brief Encodes an NFAPI P5 message to a buffer
- *  \param pMessageBuf A pointer to a nfapi p5 message structure
- *  \param messageBufLen The size of the p5 message structure
- *  \param pPackedBuf A pointer to the buffer that the p5 message will be packed into
- *  \param packedBufLen The size of the buffer 
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will encode a nFAPI P5 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf.
- * 
- */
-int nr_nfapi_p5_message_pack(void *pMessageBuf, uint32_t messageBufLen, void *pPackedBuf, uint32_t packedBufLen, nr_nfapi_p4_p5_codec_config_t* config);
-
-/*! \brief Decodes an NFAPI P5 message header
- *  \param pMessageBuf A pointer to an encoded P5 message header
- *  \param messageBufLen The size of the encoded P5 message header
- *  \param pUnpackedBuf A pointer to the nr_nfapi_message_header
- *  \param unpackedBufLen The size of nr_nfapi_message_header structure.
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will decode a byte stream pointed to by pMessageBuf into a nr_nfapi_p4_p5_message_header structure pointer to by pUnpackedBuf
- */
-int nr_nfapi_p5_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nr_nfapi_p4_p5_codec_config_t* config);
-
-/*! \brief Decodes a NFAPI P5 message
- *  \param pMessageBuf A pointer to an encoded P5 message
- *  \param messageBufLen The size of the encoded P5 message
- *  \param pUnpackedBuf A pointer to the nr_nfapi_message_header
- *  \param unpackedBufLen The size of nr_nfapi_message_header structure.
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will decode a byte stream pointed to by pMessageBuf into a nfapi p5 message structure pointer to by pUnpackedBuf 
- */
-int nr_nfapi_p5_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nr_nfapi_p4_p5_codec_config_t* config);
-
-/*! \brief Encodes an NFAPI P7 message to a buffer
- *  \param pMessageBuf A pointer to a nfapi p7 message structure
- *  \param pPackedBuf A pointer to the buffer that the p7 message will be packed into
- *  \param packedBufLen The size of the buffer 
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will encode a nFAPI P7 message structure pointed to be pMessageBuf into a byte stream pointed to by pPackedBuf.
- * 
- */
-int nr_nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nr_nfapi_p7_codec_config_t* config);
-
-/*! \brief Decodes an NFAPI P7 message header
- *  \param pMessageBuf A pointer to an encoded P7 message header
- *  \param messageBufLen The size of the encoded P7 message header
- *  \param pUnpackedBuf A pointer to the nr_nfapi_message_header
- *  \param unpackedBufLen The size of nr_nfapi_message_header structure.
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will decode a byte stream pointed to by pMessageBuf into a nr_nfapi_p7_message_header structure pointer to by pUnpackedBuf
-
- */
-int nr_nfapi_p7_message_header_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nr_nfapi_p7_codec_config_t* config);
-
-/*! \brief Decodes a NFAPI P7 message
- *  \param pMessageBuf A pointer to an encoded P7 message
- *  \param messageBufLen The size of the encoded P7 message
- *  \param pUnpackedBuf A pointer to the nr_nfapi_message_header
- *  \param unpackedBufLen The size of nr_nfapi_message_header structure.
- *  \param config A pointer to the nfapi configuration structure
- *  \return 0 means success, -1 means failure.
- *
- * The function will decode a byte stream pointed to by pMessageBuf into a nfapi p7 message structure pointer to by pUnpackedBuf 
- */
-int nr_nfapi_p7_message_unpack(void *pMessageBuf, uint32_t messageBufLen, void *pUnpackedBuf, uint32_t unpackedBufLen, nr_nfapi_p7_codec_config_t* config);
-
-/*! \brief Calculates the checksum of a  message
- *
- *  \param buffer Pointer to the packed message
- *  \param len The length of the message
- *  \return The checksum. If there is an error the function with return -1
- */
-uint32_t nr_nfapi_p7_calculate_checksum(uint8_t* buffer, uint32_t len);
-
-/*! \brief Calculates & updates the checksum in the message
- *
- *  \param buffer Pointer to the packed message
- *  \param len The length of the message
-  *  \return 0 means success, -1 means failure.
- */
-int nr_nfapi_p7_update_checksum(uint8_t* buffer, uint32_t len);
-
-/*! \brief Updates the transmition time stamp in the p7 message header
- *
- *  \param buffer Pointer to the packed message
- *  \param timestamp The time stamp value
-  *  \return 0 means success, -1 means failure.
- */
-int nr_nfapi_p7_update_transmit_timestamp(uint8_t* buffer, uint32_t timestamp);
-
-#endif /* _NFAPI_INTERFACE_H_ */
diff --git a/oaienv b/oaienv
index d9a540697b445bba06e5686718bc0380dabcc44c..4dfc5f8cb59dd6ad417f97fa12007c2fe2d4a97a 100644
--- a/oaienv
+++ b/oaienv
@@ -18,5 +18,5 @@ alias oailte='cd $OPENAIR_TARGETS/RT/USER'
 alias oais='cd $OPENAIR_TARGETS/SIMU/USER'
 alias oaiex='cd $OPENAIR_TARGETS/SIMU/EXAMPLES'
 
-export IIOD_REMOTE=192.168.121.32
+export IIOD_REMOTE=192.168.1.2
 
diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c
new file mode 100644
index 0000000000000000000000000000000000000000..91b318f94e356f163c11745b5fa75c5f17a3621b
--- /dev/null
+++ b/openair1/PHY/INIT/nr_init_ue.c
@@ -0,0 +1,972 @@
+/*
+ * 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_init.h"
+#include "SCHED_UE/sched_UE.h"
+#include "PHY/phy_extern_nr_ue.h"
+#include "SIMULATION/TOOLS/sim.h"
+#include "RadioResourceConfigCommonSIB.h"
+#include "RadioResourceConfigDedicated.h"
+#include "TDD-Config.h"
+#include "MBSFN-SubframeConfigList.h"
+#include "UTIL/LOG/vcd_signal_dumper.h"
+#include "assertions.h"
+#include <math.h>
+#include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h"
+#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h"
+#include "PHY/LTE_REFSIG/lte_refsig.h"
+
+//uint8_t dmrs1_tab_ue[8] = {0,2,3,4,6,8,9,10};
+
+/*void phy_config_sib1_ue(uint8_t Mod_id,int CC_id,
+                        uint8_t eNB_id,
+                        TDD_Config_t *tdd_Config,
+                        uint8_t SIwindowsize,
+                        uint16_t SIperiod)
+{
+
+  NR_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][CC_id]->frame_parms;
+
+  if (tdd_Config) {
+    fp->tdd_config    = tdd_Config->subframeAssignment;
+    fp->tdd_config_S  = tdd_Config->specialSubframePatterns;
+  }
+
+  fp->SIwindowsize  = SIwindowsize;
+  fp->SIPeriod      = SIperiod;
+}
+
+void phy_config_sib2_ue(uint8_t Mod_id,int CC_id,
+                        uint8_t eNB_id,
+                        RadioResourceConfigCommonSIB_t *radioResourceConfigCommon,
+                        ARFCN_ValueEUTRA_t *ul_CarrierFreq,
+                        long *ul_Bandwidth,
+                        AdditionalSpectrumEmission_t *additionalSpectrumEmission,
+                        struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList)
+{
+
+  PHY_VARS_UE *ue        = PHY_vars_UE_g[Mod_id][CC_id];
+  NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
+  int i;
+
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_CONFIG_SIB2, VCD_FUNCTION_IN);
+
+  LOG_I(PHY,"[UE%d] Applying radioResourceConfigCommon from eNB%d\n",Mod_id,eNB_id);
+
+  fp->prach_config_common.rootSequenceIndex                           =radioResourceConfigCommon->prach_Config.rootSequenceIndex;
+
+  fp->prach_config_common.prach_Config_enabled=1;
+  fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex          =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_ConfigIndex;
+  fp->prach_config_common.prach_ConfigInfo.highSpeedFlag              =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.highSpeedFlag;
+  fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig  =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig;
+  fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset           =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_FreqOffset;
+
+  compute_prach_seq(fp->prach_config_common.rootSequenceIndex,
+		    fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex,
+		    fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig,
+		    fp->prach_config_common.prach_ConfigInfo.highSpeedFlag,
+		    fp->frame_type,ue->X_u);
+
+
+
+  fp->pucch_config_common.deltaPUCCH_Shift = 1+radioResourceConfigCommon->pucch_ConfigCommon.deltaPUCCH_Shift;
+  fp->pucch_config_common.nRB_CQI          = radioResourceConfigCommon->pucch_ConfigCommon.nRB_CQI;
+  fp->pucch_config_common.nCS_AN           = radioResourceConfigCommon->pucch_ConfigCommon.nCS_AN;
+  fp->pucch_config_common.n1PUCCH_AN       = radioResourceConfigCommon->pucch_ConfigCommon.n1PUCCH_AN;
+
+
+
+  fp->pdsch_config_common.referenceSignalPower = radioResourceConfigCommon->pdsch_ConfigCommon.referenceSignalPower;
+  fp->pdsch_config_common.p_b                  = radioResourceConfigCommon->pdsch_ConfigCommon.p_b;
+
+
+  fp->pusch_config_common.n_SB                                         = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB;
+  fp->pusch_config_common.hoppingMode                                  = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode;
+  fp->pusch_config_common.pusch_HoppingOffset                          = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset;
+  fp->pusch_config_common.enable64QAM                                  = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM;
+  fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled    = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled;
+  fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH   = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH;
+  fp->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled;
+  fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift            = dmrs1_tab_ue[radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift];
+
+
+  init_ul_hopping(fp);
+  fp->soundingrs_ul_config_common.enabled_flag                        = 0;
+
+  if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon.present==SoundingRS_UL_ConfigCommon_PR_setup) {
+    fp->soundingrs_ul_config_common.enabled_flag                        = 1;
+    fp->soundingrs_ul_config_common.srs_BandwidthConfig                 = radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.srs_BandwidthConfig;
+    fp->soundingrs_ul_config_common.srs_SubframeConfig                  = radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig;
+    fp->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission = radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission;
+
+    if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts)
+      fp->soundingrs_ul_config_common.srs_MaxUpPts                      = 1;
+    else
+      fp->soundingrs_ul_config_common.srs_MaxUpPts                      = 0;
+  }
+
+
+
+  fp->ul_power_control_config_common.p0_NominalPUSCH   = radioResourceConfigCommon->uplinkPowerControlCommon.p0_NominalPUSCH;
+  fp->ul_power_control_config_common.alpha             = radioResourceConfigCommon->uplinkPowerControlCommon.alpha;
+  fp->ul_power_control_config_common.p0_NominalPUCCH   = radioResourceConfigCommon->uplinkPowerControlCommon.p0_NominalPUCCH;
+  fp->ul_power_control_config_common.deltaPreambleMsg3 = radioResourceConfigCommon->uplinkPowerControlCommon.deltaPreambleMsg3;
+  fp->ul_power_control_config_common.deltaF_PUCCH_Format1  = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1;
+  fp->ul_power_control_config_common.deltaF_PUCCH_Format1b  = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1b;
+  fp->ul_power_control_config_common.deltaF_PUCCH_Format2  = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2;
+  fp->ul_power_control_config_common.deltaF_PUCCH_Format2a  = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2a;
+  fp->ul_power_control_config_common.deltaF_PUCCH_Format2b  = radioResourceConfigCommon->uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b;
+
+  fp->maxHARQ_Msg3Tx = radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx;
+
+  // Now configure some of the Physical Channels
+
+  // PUCCH
+  init_ncs_cell(fp,ue->ncs_cell);
+
+  init_ul_hopping(fp);
+
+  // PCH
+  init_ue_paging_info(ue,radioResourceConfigCommon->pcch_Config.defaultPagingCycle,radioResourceConfigCommon->pcch_Config.nB);
+
+  // MBSFN
+
+  if (mbsfn_SubframeConfigList != NULL) {
+    fp->num_MBSFN_config = mbsfn_SubframeConfigList->list.count;
+
+    for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) {
+      fp->MBSFN_config[i].radioframeAllocationPeriod = mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod;
+      fp->MBSFN_config[i].radioframeAllocationOffset = mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset;
+
+      if (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame) {
+        fp->MBSFN_config[i].fourFrames_flag = 0;
+        fp->MBSFN_config[i].mbsfn_SubframeConfig = mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0]; // 6-bit subframe configuration
+        LOG_I(PHY, "[CONFIG] MBSFN_SubframeConfig[%d] pattern is  %d\n", i,
+              fp->MBSFN_config[i].mbsfn_SubframeConfig);
+      } else if (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_fourFrames) { // 24-bit subframe configuration
+        fp->MBSFN_config[i].fourFrames_flag = 1;
+        fp->MBSFN_config[i].mbsfn_SubframeConfig =
+          mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0]|
+          (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[1]<<8)|
+          (mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[2]<<16);
+
+        LOG_I(PHY, "[CONFIG] MBSFN_SubframeConfig[%d] pattern is  %d\n", i,
+              fp->MBSFN_config[i].mbsfn_SubframeConfig);
+      }
+    }
+  }
+
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_CONFIG_SIB2, VCD_FUNCTION_OUT);
+
+}
+
+void phy_config_sib13_ue(uint8_t Mod_id,int CC_id,uint8_t eNB_id,int mbsfn_Area_idx,
+                         long mbsfn_AreaId_r9)
+{
+
+  NR_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][CC_id]->frame_parms;
+
+
+  LOG_I(PHY,"[UE%d] Applying MBSFN_Area_id %ld for index %d\n",Mod_id,mbsfn_AreaId_r9,mbsfn_Area_idx);
+
+  if (mbsfn_Area_idx == 0) {
+    fp->Nid_cell_mbsfn = (uint16_t)mbsfn_AreaId_r9;
+    LOG_N(PHY,"Fix me: only called when mbsfn_Area_idx == 0)\n");
+  }
+
+  lte_gold_mbsfn(fp,PHY_vars_UE_g[Mod_id][CC_id]->lte_gold_mbsfn_table,fp->Nid_cell_mbsfn);
+
+}*/
+
+
+/*
+ * Configures UE MAC and PHY with radioResourceCommon received in mobilityControlInfo IE during Handover
+ */
+/*void phy_config_afterHO_ue(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_id, MobilityControlInfo_t *mobilityControlInfo, uint8_t ho_failed)
+{
+
+  if(mobilityControlInfo!=NULL) {
+    RadioResourceConfigCommon_t *radioResourceConfigCommon = &mobilityControlInfo->radioResourceConfigCommon;
+    LOG_I(PHY,"radioResourceConfigCommon %p\n", radioResourceConfigCommon);
+    memcpy((void *)&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms_before_ho,
+           (void *)&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms,
+           sizeof(NR_DL_FRAME_PARMS));
+    PHY_vars_UE_g[Mod_id][CC_id]->ho_triggered = 1;
+    //PHY_vars_UE_g[UE_id]->UE_mode[0] = PRACH;
+
+    NR_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][CC_id]->frame_parms;
+    //     int N_ZC;
+    //     uint8_t prach_fmt;
+    //     int u;
+
+    LOG_I(PHY,"[UE%d] Handover triggered: Applying radioResourceConfigCommon from eNB %d\n",
+          Mod_id,eNB_id);
+
+    fp->prach_config_common.rootSequenceIndex                           =radioResourceConfigCommon->prach_Config.rootSequenceIndex;
+    fp->prach_config_common.prach_Config_enabled=1;
+    fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex          =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_ConfigIndex;
+    fp->prach_config_common.prach_ConfigInfo.highSpeedFlag              =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->highSpeedFlag;
+    fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig  =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->zeroCorrelationZoneConfig;
+    fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset           =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_FreqOffset;
+
+    //     prach_fmt = get_prach_fmt(radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_ConfigIndex,fp->frame_type);
+    //     N_ZC = (prach_fmt <4)?839:139;
+    //     u = (prach_fmt < 4) ? prach_root_sequence_map0_3[fp->prach_config_common.rootSequenceIndex] :
+    //       prach_root_sequence_map4[fp->prach_config_common.rootSequenceIndex];
+
+    //compute_prach_seq(u,N_ZC, PHY_vars_UE_g[Mod_id]->X_u);
+    compute_prach_seq(PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.rootSequenceIndex,
+		      PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex,
+		      PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig,
+		      PHY_vars_UE_g[Mod_id][CC_id]->frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag,
+                      fp->frame_type,
+                      PHY_vars_UE_g[Mod_id][CC_id]->X_u);
+
+
+    fp->pucch_config_common.deltaPUCCH_Shift = 1+radioResourceConfigCommon->pucch_ConfigCommon->deltaPUCCH_Shift;
+    fp->pucch_config_common.nRB_CQI          = radioResourceConfigCommon->pucch_ConfigCommon->nRB_CQI;
+    fp->pucch_config_common.nCS_AN           = radioResourceConfigCommon->pucch_ConfigCommon->nCS_AN;
+    fp->pucch_config_common.n1PUCCH_AN       = radioResourceConfigCommon->pucch_ConfigCommon->n1PUCCH_AN;
+    fp->pdsch_config_common.referenceSignalPower = radioResourceConfigCommon->pdsch_ConfigCommon->referenceSignalPower;
+    fp->pdsch_config_common.p_b                  = radioResourceConfigCommon->pdsch_ConfigCommon->p_b;
+
+
+    fp->pusch_config_common.n_SB                                         = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB;
+    fp->pusch_config_common.hoppingMode                                  = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode;
+    fp->pusch_config_common.pusch_HoppingOffset                          = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset;
+    fp->pusch_config_common.enable64QAM                                  = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM;
+    fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled    = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled;
+    fp->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH   = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH;
+    fp->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled;
+    fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift            = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift;
+
+    init_ul_hopping(fp);
+    fp->soundingrs_ul_config_common.enabled_flag                        = 0;
+
+    if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon->present==SoundingRS_UL_ConfigCommon_PR_setup) {
+      fp->soundingrs_ul_config_common.enabled_flag                        = 1;
+      fp->soundingrs_ul_config_common.srs_BandwidthConfig                 = radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.srs_BandwidthConfig;
+      fp->soundingrs_ul_config_common.srs_SubframeConfig                  = radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.srs_SubframeConfig;
+      fp->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission = radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.ackNackSRS_SimultaneousTransmission;
+
+      if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.srs_MaxUpPts)
+        fp->soundingrs_ul_config_common.srs_MaxUpPts                      = 1;
+      else
+        fp->soundingrs_ul_config_common.srs_MaxUpPts                      = 0;
+    }
+
+    fp->ul_power_control_config_common.p0_NominalPUSCH   = radioResourceConfigCommon->uplinkPowerControlCommon->p0_NominalPUSCH;
+    fp->ul_power_control_config_common.alpha             = radioResourceConfigCommon->uplinkPowerControlCommon->alpha;
+    fp->ul_power_control_config_common.p0_NominalPUCCH   = radioResourceConfigCommon->uplinkPowerControlCommon->p0_NominalPUCCH;
+    fp->ul_power_control_config_common.deltaPreambleMsg3 = radioResourceConfigCommon->uplinkPowerControlCommon->deltaPreambleMsg3;
+    fp->ul_power_control_config_common.deltaF_PUCCH_Format1  = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format1;
+    fp->ul_power_control_config_common.deltaF_PUCCH_Format1b  = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format1b;
+    fp->ul_power_control_config_common.deltaF_PUCCH_Format2  = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2;
+    fp->ul_power_control_config_common.deltaF_PUCCH_Format2a  = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2a;
+    fp->ul_power_control_config_common.deltaF_PUCCH_Format2b  = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2b;
+
+    fp->maxHARQ_Msg3Tx = radioResourceConfigCommon->rach_ConfigCommon->maxHARQ_Msg3Tx;
+
+    // Now configure some of the Physical Channels
+    if (radioResourceConfigCommon->antennaInfoCommon)
+      fp->nb_antennas_tx                     = (1<<radioResourceConfigCommon->antennaInfoCommon->antennaPortsCount);
+    else
+      fp->nb_antennas_tx                     = 1;
+
+    //PHICH
+    if (radioResourceConfigCommon->antennaInfoCommon) {
+      fp->phich_config_common.phich_resource = radioResourceConfigCommon->phich_Config->phich_Resource;
+      fp->phich_config_common.phich_duration = radioResourceConfigCommon->phich_Config->phich_Duration;
+    }
+
+    //Target CellId
+    fp->Nid_cell = mobilityControlInfo->targetPhysCellId;
+    fp->nushift  = fp->Nid_cell%6;
+
+    // PUCCH
+    init_ncs_cell(fp,PHY_vars_UE_g[Mod_id][CC_id]->ncs_cell);
+
+    init_ul_hopping(fp);
+
+    // RNTI
+
+
+    PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[0][eNB_id]->crnti = mobilityControlInfo->newUE_Identity.buf[0]|(mobilityControlInfo->newUE_Identity.buf[1]<<8);
+    PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[1][eNB_id]->crnti = mobilityControlInfo->newUE_Identity.buf[0]|(mobilityControlInfo->newUE_Identity.buf[1]<<8);
+
+    LOG_I(PHY,"SET C-RNTI %x %x\n",PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[0][eNB_id]->crnti,
+                                   PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[1][eNB_id]->crnti);
+  }
+
+  if(ho_failed) {
+    LOG_D(PHY,"[UE%d] Handover failed, triggering RACH procedure\n",Mod_id);
+    memcpy((void *)&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms,(void *)&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms_before_ho, sizeof(NR_DL_FRAME_PARMS));
+    PHY_vars_UE_g[Mod_id][CC_id]->UE_mode[eNB_id] = PRACH;
+  }
+}
+
+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)
+{
+
+  PHY_NR_MEASUREMENTS *phy_meas = &PHY_vars_UE_g[Mod_id][CC_id]->measurements;
+  int i;
+
+  LOG_I(PHY,"Configuring inter-cell measurements for %d cells, ids: \n",n_adj_cells);
+
+  for (i=0; i<n_adj_cells; i++) {
+    LOG_I(PHY,"%d\n",adj_cell_id[i]);
+    lte_gold(&PHY_vars_UE_g[Mod_id][CC_id]->frame_parms,PHY_vars_UE_g[Mod_id][CC_id]->lte_gold_table[i+1],adj_cell_id[i]);
+  }
+
+  phy_meas->n_adj_cells = n_adj_cells;
+  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,
+                                   uint8_t eNB_index,
+                                   SCellToAddMod_r10_t *sCellToAddMod_r10,
+                                   int CC_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_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 )
+{
+
+  static uint8_t first_dedicated_configuration = 0;
+  PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id][CC_id];
+
+  phy_vars_ue->total_TBS[eNB_id]=0;
+  phy_vars_ue->total_TBS_last[eNB_id]=0;
+  phy_vars_ue->bitrate[eNB_id]=0;
+  phy_vars_ue->total_received_bits[eNB_id]=0;
+  phy_vars_ue->dlsch_errors[eNB_id]=0;
+  phy_vars_ue->dlsch_errors_last[eNB_id]=0;
+  phy_vars_ue->dlsch_received[eNB_id]=0;
+  phy_vars_ue->dlsch_received_last[eNB_id]=0;
+  phy_vars_ue->dlsch_fer[eNB_id]=0;
+
+  phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = -1;
+  phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = -1;
+
+  if (physicalConfigDedicated) {
+    LOG_D(PHY,"[UE %d] Received physicalConfigDedicated from eNB %d\n",Mod_id, eNB_id);
+    LOG_D(PHY,"------------------------------------------------------------------------\n");
+
+    if (physicalConfigDedicated->pdsch_ConfigDedicated) {
+      phy_vars_ue->pdsch_config_dedicated[eNB_id].p_a=physicalConfigDedicated->pdsch_ConfigDedicated->p_a;
+      LOG_D(PHY,"pdsch_config_dedicated.p_a %d\n",phy_vars_ue->pdsch_config_dedicated[eNB_id].p_a);
+      LOG_D(PHY,"\n");
+    }
+
+    if (physicalConfigDedicated->pucch_ConfigDedicated) {
+      if (physicalConfigDedicated->pucch_ConfigDedicated->ackNackRepetition.present==PUCCH_ConfigDedicated__ackNackRepetition_PR_release)
+        phy_vars_ue->pucch_config_dedicated[eNB_id].ackNackRepetition=0;
+      else {
+        phy_vars_ue->pucch_config_dedicated[eNB_id].ackNackRepetition=1;
+      }
+
+      if (physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode)
+        phy_vars_ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode = *physicalConfigDedicated->pucch_ConfigDedicated->tdd_AckNackFeedbackMode;
+      else
+        phy_vars_ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode = bundling;
+
+      if ( phy_vars_ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode == multiplexing)
+        LOG_D(PHY,"pucch_config_dedicated.tdd_AckNackFeedbackMode = multiplexing\n");
+      else
+        LOG_D(PHY,"pucch_config_dedicated.tdd_AckNackFeedbackMode = bundling\n");
+    }
+
+    if (physicalConfigDedicated->pusch_ConfigDedicated) {
+      phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_ACK_Index;
+      phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index;
+      phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index;
+
+
+      LOG_D(PHY,"pusch_config_dedicated.betaOffset_ACK_Index %d\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_ACK_Index);
+      LOG_D(PHY,"pusch_config_dedicated.betaOffset_RI_Index %d\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_RI_Index);
+      LOG_D(PHY,"pusch_config_dedicated.betaOffset_CQI_Index %d => %d)\n",phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index,beta_cqi[phy_vars_ue->pusch_config_dedicated[eNB_id].betaOffset_CQI_Index]);
+      LOG_D(PHY,"\n");
+
+
+    }
+
+    if (physicalConfigDedicated->uplinkPowerControlDedicated) {
+
+      phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUSCH = physicalConfigDedicated->uplinkPowerControlDedicated->p0_UE_PUSCH;
+      phy_vars_ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled= physicalConfigDedicated->uplinkPowerControlDedicated->deltaMCS_Enabled;
+      phy_vars_ue->ul_power_control_dedicated[eNB_id].accumulationEnabled= physicalConfigDedicated->uplinkPowerControlDedicated->accumulationEnabled;
+      phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUCCH= physicalConfigDedicated->uplinkPowerControlDedicated->p0_UE_PUCCH;
+      phy_vars_ue->ul_power_control_dedicated[eNB_id].pSRS_Offset= physicalConfigDedicated->uplinkPowerControlDedicated->pSRS_Offset;
+      phy_vars_ue->ul_power_control_dedicated[eNB_id].filterCoefficient= *physicalConfigDedicated->uplinkPowerControlDedicated->filterCoefficient;
+      LOG_D(PHY,"ul_power_control_dedicated.p0_UE_PUSCH %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUSCH);
+      LOG_D(PHY,"ul_power_control_dedicated.deltaMCS_Enabled %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].deltaMCS_Enabled);
+      LOG_D(PHY,"ul_power_control_dedicated.accumulationEnabled %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].accumulationEnabled);
+      LOG_D(PHY,"ul_power_control_dedicated.p0_UE_PUCCH %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].p0_UE_PUCCH);
+      LOG_D(PHY,"ul_power_control_dedicated.pSRS_Offset %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].pSRS_Offset);
+      LOG_D(PHY,"ul_power_control_dedicated.filterCoefficient %d\n",phy_vars_ue->ul_power_control_dedicated[eNB_id].filterCoefficient);
+      LOG_D(PHY,"\n");
+    }
+
+    if (physicalConfigDedicated->antennaInfo) {
+      phy_vars_ue->transmission_mode[eNB_id] = 1+(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode);
+      LOG_I(PHY,"Transmission Mode %d\n",phy_vars_ue->transmission_mode[eNB_id]);
+      switch(physicalConfigDedicated->antennaInfo->choice.explicitValue.transmissionMode) {
+      case AntennaInfoDedicated__transmissionMode_tm1:
+        phy_vars_ue->transmission_mode[eNB_id] = 1;
+        break;
+      case AntennaInfoDedicated__transmissionMode_tm2:
+        phy_vars_ue->transmission_mode[eNB_id] = 2;
+        break;
+      case AntennaInfoDedicated__transmissionMode_tm3:
+        phy_vars_ue->transmission_mode[eNB_id] = 3;
+        break;
+      case AntennaInfoDedicated__transmissionMode_tm4:
+        phy_vars_ue->transmission_mode[eNB_id] = 4;
+        break;
+      case AntennaInfoDedicated__transmissionMode_tm5:
+        phy_vars_ue->transmission_mode[eNB_id] = 5;
+        break;
+      case AntennaInfoDedicated__transmissionMode_tm6:
+        phy_vars_ue->transmission_mode[eNB_id] = 6;
+        break;
+      case AntennaInfoDedicated__transmissionMode_tm7:
+        lte_gold_ue_spec_port5(phy_vars_ue->lte_gold_uespec_port5_table, phy_vars_ue->frame_parms.Nid_cell, phy_vars_ue->pdcch_vars[0][eNB_id]->crnti);
+        phy_vars_ue->transmission_mode[eNB_id] = 7;
+        break;
+      default:
+        LOG_E(PHY,"Unknown transmission mode!\n");
+        break;
+      }
+    } else {
+      LOG_D(PHY,"[UE %d] Received NULL physicalConfigDedicated->antennaInfo from eNB %d\n",Mod_id, eNB_id);
+    }
+
+    if (physicalConfigDedicated->schedulingRequestConfig) {
+      if (physicalConfigDedicated->schedulingRequestConfig->present == SchedulingRequestConfig_PR_setup) {
+        phy_vars_ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex = physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex;
+        phy_vars_ue->scheduling_request_config[eNB_id].sr_ConfigIndex=physicalConfigDedicated->schedulingRequestConfig->choice.setup.sr_ConfigIndex;
+        phy_vars_ue->scheduling_request_config[eNB_id].dsr_TransMax=physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax;
+
+        LOG_D(PHY,"scheduling_request_config.sr_PUCCH_ResourceIndex %d\n",phy_vars_ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex);
+        LOG_D(PHY,"scheduling_request_config.sr_ConfigIndex %d\n",phy_vars_ue->scheduling_request_config[eNB_id].sr_ConfigIndex);
+        LOG_D(PHY,"scheduling_request_config.dsr_TransMax %d\n",phy_vars_ue->scheduling_request_config[eNB_id].dsr_TransMax);
+      }
+
+      LOG_D(PHY,"------------------------------------------------------------\n");
+
+    }
+
+    if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated) {
+
+      phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 0;
+      if (physicalConfigDedicated->soundingRS_UL_ConfigDedicated->present == SoundingRS_UL_ConfigDedicated_PR_setup) {
+        phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srsConfigDedicatedSetup = 1;
+        phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].duration             = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.duration;
+        phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].cyclicShift          = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift;
+        phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].freqDomainPosition   = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition;
+        phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_Bandwidth        = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth;
+        phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_ConfigIndex      = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex;
+        phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_HoppingBandwidth = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth;
+        phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].transmissionComb     = physicalConfigDedicated->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb;
+
+
+        LOG_D(PHY,"soundingrs_ul_config_dedicated.srs_ConfigIndex %d\n",phy_vars_ue->soundingrs_ul_config_dedicated[eNB_id].srs_ConfigIndex);
+      }
+
+      LOG_D(PHY,"------------------------------------------------------------\n");
+
+    }
+
+
+    if (physicalConfigDedicated->cqi_ReportConfig) {
+      if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic) {
+        // configure PUSCH CQI reporting
+        phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic = *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic;
+        if ((phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm12) &&
+            (phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm30) &&
+            (phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic != rm31))
+          LOG_E(PHY,"Unsupported Aperiodic CQI Feedback Mode : %d\n",phy_vars_ue->cqi_report_config[eNB_id].cqi_ReportModeAperiodic);
+      }
+      if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic) {
+        if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_setup) {
+        // configure PUCCH CQI reporting
+          phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PUCCH_ResourceIndex = physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex;
+          phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex     = physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex;
+          if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex)
+            phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = *physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex;
+        }
+        else if (physicalConfigDedicated->cqi_ReportConfig->cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_release) {
+          // handle release
+          phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex = -1;
+          phy_vars_ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex = -1;
+        }
+      }
+    }
+
+#ifdef CBA
+
+    if (physicalConfigDedicated->pusch_CBAConfigDedicated_vlola) {
+      phy_vars_ue->pusch_ca_config_dedicated[eNB_id].betaOffset_CA_Index = (uint16_t) *physicalConfigDedicated->pusch_CBAConfigDedicated_vlola->betaOffset_CBA_Index;
+      phy_vars_ue->pusch_ca_config_dedicated[eNB_id].cShift = (uint16_t) *physicalConfigDedicated->pusch_CBAConfigDedicated_vlola->cShift_CBA;
+      LOG_D(PHY,"[UE %d ] physicalConfigDedicated pusch CBA config dedicated: beta offset %d cshift %d \n",Mod_id,
+            phy_vars_ue->pusch_ca_config_dedicated[eNB_id].betaOffset_CA_Index,
+            phy_vars_ue->pusch_ca_config_dedicated[eNB_id].cShift);
+    }
+
+#endif
+  } else {
+    LOG_D(PHY,"[PHY][UE %d] Received NULL radioResourceConfigDedicated from eNB %d\n",Mod_id,eNB_id);
+    return;
+  }
+
+  // fill cqi parameters for periodic CQI reporting
+  get_cqipmiri_params(phy_vars_ue,eNB_id);
+
+  // disable MIB SIB decoding once we are on connected mode
+  first_dedicated_configuration ++;
+  if(first_dedicated_configuration > 1)
+  {
+  	LOG_I(PHY,"Disable SIB MIB decoding \n");
+  	phy_vars_ue->decode_SIB = 0;
+  	phy_vars_ue->decode_MIB = 0;
+  }
+  //phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti;
+  if(phy_vars_ue->pdcch_vars[0][eNB_id]->crnti == 0x1234)
+      phy_vars_ue->pdcch_vars[0][eNB_id]->crnti = phy_vars_ue->pdcch_vars[1][eNB_id]->crnti;
+  else
+      phy_vars_ue->pdcch_vars[1][eNB_id]->crnti = phy_vars_ue->pdcch_vars[0][eNB_id]->crnti;
+
+  LOG_I(PHY,"C-RNTI %x %x \n", phy_vars_ue->pdcch_vars[0][eNB_id]->crnti,
+                               phy_vars_ue->pdcch_vars[1][eNB_id]->crnti);
+
+
+}*/
+
+/*! \brief Helper function to allocate memory for DLSCH data structures.
+ * \param[out] pdsch Pointer to the LTE_UE_PDSCH structure to initialize.
+ * \param[in] frame_parms LTE_DL_FRAME_PARMS structure.
+ * \note This function is optimistic in that it expects malloc() to succeed.
+ */
+void phy_init_nr_ue__PDSCH( NR_UE_PDSCH* const pdsch, const NR_DL_FRAME_PARMS* const fp )
+{
+  AssertFatal( pdsch, "pdsch==0" );
+
+  pdsch->pmi_ext = (uint8_t*)malloc16_clear( fp->N_RB_DL );
+  pdsch->llr[0] = (int16_t*)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) );
+  pdsch->llr128 = (int16_t**)malloc16_clear( sizeof(int16_t*) );
+  // FIXME! no further allocation for (int16_t*)pdsch->llr128 !!! expect SIGSEGV
+  // FK, 11-3-2015: this is only as a temporary pointer, no memory is stored there
+
+
+  pdsch->rxdataF_ext            = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+  pdsch->rxdataF_uespec_pilots  = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+  pdsch->rxdataF_comp0          = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+  pdsch->rho                    = (int32_t**)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t*) );
+  pdsch->dl_ch_estimates_ext    = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+  pdsch->dl_bf_ch_estimates     = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+  pdsch->dl_bf_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+  //pdsch->dl_ch_rho_ext          = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+  //pdsch->dl_ch_rho2_ext         = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+  pdsch->dl_ch_mag0             = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+  pdsch->dl_ch_magb0            = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+
+
+  // the allocated memory size is fixed:
+  AssertFatal( fp->nb_antennas_rx <= 2, "nb_antennas_rx > 2" );
+
+  for (int i=0; i<fp->nb_antennas_rx; i++) {
+    pdsch->rho[i]     = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->N_RB_DL*12*7*2) );
+
+    for (int j=0; j<4; j++) { //fp->nb_antennas_tx; j++)
+      const int idx = (j<<1)+i;
+      const size_t num = 7*2*fp->N_RB_DL*12;
+      pdsch->rxdataF_ext[idx]             = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+      pdsch->rxdataF_uespec_pilots[idx]   = (int32_t*)malloc16_clear( sizeof(int32_t) * fp->N_RB_DL*12);
+      pdsch->rxdataF_comp0[idx]           = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+      pdsch->dl_ch_estimates_ext[idx]     = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+      pdsch->dl_bf_ch_estimates[idx]      = (int32_t*)malloc16_clear( sizeof(int32_t) * fp->ofdm_symbol_size*7*2);
+      pdsch->dl_bf_ch_estimates_ext[idx]  = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+      //pdsch->dl_ch_rho_ext[idx]           = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+      //pdsch->dl_ch_rho2_ext[idx]          = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+      pdsch->dl_ch_mag0[idx]              = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+      pdsch->dl_ch_magb0[idx]             = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+    }
+  }
+}
+
+int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
+		       int nb_connected_eNB,
+		       uint8_t abstraction_flag)
+{
+  // create shortcuts
+  NR_DL_FRAME_PARMS* const fp            = &ue->frame_parms;
+  NR_UE_COMMON* const common_vars        = &ue->common_vars;
+  NR_UE_PDSCH** const pdsch_vars_SI      = ue->pdsch_vars_SI;
+  NR_UE_PDSCH** const pdsch_vars_ra      = ue->pdsch_vars_ra;
+  NR_UE_PDSCH** const pdsch_vars_p       = ue->pdsch_vars_p;
+  NR_UE_PDSCH** const pdsch_vars_mch     = ue->pdsch_vars_MCH;
+  NR_UE_PDSCH* (*pdsch_vars_th)[][NUMBER_OF_CONNECTED_eNB_MAX+1] = &ue->pdsch_vars;
+  NR_UE_PDCCH* (*pdcch_vars_th)[][NUMBER_OF_CONNECTED_eNB_MAX]   = &ue->pdcch_vars;
+  NR_UE_PBCH** const pbch_vars           = ue->pbch_vars;
+  NR_UE_PRACH** const prach_vars         = ue->prach_vars;
+
+
+
+  int i,j,k,l;
+  int eNB_id;
+  int th_id;
+
+  abstraction_flag = 0;
+  fp->nb_antennas_tx = 1;
+  fp->nb_antennas_rx=1;
+
+  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);
+
+  // 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]" );
+  AssertFatal( ue->n_connected_eNB <= NUMBER_OF_CONNECTED_eNB_MAX, "n_connected_eNB is too large" );
+  // init phy_vars_ue
+
+  for (i=0; i<4; i++) {
+    ue->rx_gain_max[i] = 135;
+    ue->rx_gain_med[i] = 128;
+    ue->rx_gain_byp[i] = 120;
+  }
+
+  ue->n_connected_eNB = nb_connected_eNB;
+
+  for(eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++) {
+    ue->total_TBS[eNB_id] = 0;
+    ue->total_TBS_last[eNB_id] = 0;
+    ue->bitrate[eNB_id] = 0;
+    ue->total_received_bits[eNB_id] = 0;
+  }
+
+  for (i=0;i<10;i++)
+    ue->tx_power_dBm[i]=-127;
+
+  if (abstraction_flag == 0) {
+
+    // init TX buffers
+
+    common_vars->txdata  = (int32_t**)malloc16( fp->nb_antennas_tx*sizeof(int32_t*) );
+    common_vars->txdataF = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t*) );
+
+    for (i=0; i<fp->nb_antennas_tx; i++) {
+
+      common_vars->txdata[i]  = (int32_t*)malloc16_clear( fp->samples_per_subframe*10*sizeof(int32_t) );
+      common_vars->txdataF[i] = (int32_t *)malloc16_clear( fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) );
+    }
+
+    // init RX buffers
+
+    common_vars->rxdata   = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+    for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+        common_vars->common_vars_rx_data_per_thread[th_id].rxdataF  = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+    }
+
+    for (i=0; i<fp->nb_antennas_rx; i++) {
+      common_vars->rxdata[i] = (int32_t*) malloc16_clear( (fp->samples_per_subframe*10+2048)*sizeof(int32_t) );
+      for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+          common_vars->common_vars_rx_data_per_thread[th_id].rxdataF[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->ofdm_symbol_size*14) );
+      }
+    }
+  }
+
+  // Channel estimates
+  for (eNB_id=0; eNB_id<7; eNB_id++) {
+    for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+        common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates[eNB_id]      = (int32_t**)malloc16_clear(8*sizeof(int32_t*));
+        common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates_time[eNB_id] = (int32_t**)malloc16_clear(8*sizeof(int32_t*));
+    }
+
+    for (i=0; i<fp->nb_antennas_rx; i++)
+      for (j=0; j<4; j++) {
+        int idx = (j<<1) + i;
+        for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+            common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates[eNB_id][idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->symbols_per_tti*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH) );
+            common_vars->common_vars_rx_data_per_thread[th_id].dl_ch_estimates_time[eNB_id][idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 );
+        }
+      }
+  }
+
+  // DLSCH
+  for (eNB_id=0; eNB_id<ue->n_connected_eNB; eNB_id++) {
+    for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+        (*pdsch_vars_th)[th_id][eNB_id]     = (NR_UE_PDSCH *)malloc16_clear(sizeof(NR_UE_PDSCH));
+    }
+
+    for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+        (*pdcch_vars_th)[th_id][eNB_id] = (NR_UE_PDCCH *)malloc16_clear(sizeof(NR_UE_PDCCH));
+    }
+
+    pdsch_vars_SI[eNB_id]  = (NR_UE_PDSCH *)malloc16_clear(sizeof(NR_UE_PDSCH));
+    pdsch_vars_ra[eNB_id]  = (NR_UE_PDSCH *)malloc16_clear(sizeof(NR_UE_PDSCH));
+    pdsch_vars_p[eNB_id]   = (NR_UE_PDSCH *)malloc16_clear(sizeof(NR_UE_PDSCH));
+    pdsch_vars_mch[eNB_id] = (NR_UE_PDSCH *)malloc16_clear(sizeof(NR_UE_PDSCH));
+    prach_vars[eNB_id]     = (NR_UE_PRACH *)malloc16_clear(sizeof(NR_UE_PRACH));
+    pbch_vars[eNB_id]      = (NR_UE_PBCH *)malloc16_clear(sizeof(NR_UE_PBCH));
+
+    if (abstraction_flag == 0) {
+      for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+         phy_init_nr_ue__PDSCH( (*pdsch_vars_th)[th_id][eNB_id], fp );
+      }
+
+      for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+        (*pdsch_vars_th)[th_id][eNB_id]->llr_shifts      = (uint8_t*)malloc16_clear(7*2*fp->N_RB_DL*12);
+        (*pdsch_vars_th)[th_id][eNB_id]->llr_shifts_p        = (*pdsch_vars_th)[0][eNB_id]->llr_shifts;
+        (*pdsch_vars_th)[th_id][eNB_id]->llr[1]              = (int16_t*)malloc16_clear( (8*((3*8*8448)+12))*sizeof(int16_t) );
+        (*pdsch_vars_th)[th_id][eNB_id]->llr128_2ndstream    = (int16_t**)malloc16_clear( sizeof(int16_t*) );
+        (*pdsch_vars_th)[th_id][eNB_id]->rho                 = (int32_t**)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t*) );
+      }
+
+      for (int i=0; i<fp->nb_antennas_rx; i++){
+        for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+            (*pdsch_vars_th)[th_id][eNB_id]->rho[i]     = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) );
+        }
+
+        }
+      for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+          (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho2_ext      = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+      }
+
+      for (i=0; i<fp->nb_antennas_rx; i++)
+        for (j=0; j<4; j++) {
+          const int idx = (j<<1)+i;
+          const size_t num = 7*2*fp->N_RB_DL*12+4;
+          for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+              (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho2_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+          }
+
+        }
+
+      //const size_t num = 7*2*fp->N_RB_DL*12+4;
+      for (k=0;k<8;k++) { //harq_pid
+        for (l=0;l<8;l++) { //round
+          for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+              (*pdsch_vars_th)[th_id][eNB_id]->rxdataF_comp1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+              (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+              (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_mag1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+              (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_magb1[k][l] = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+          }
+
+
+          for (int i=0; i<fp->nb_antennas_rx; i++)
+            for (int j=0; j<4; j++) { //frame_parms->nb_antennas_tx; j++)
+              const int idx = (j<<1)+i;
+              for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+                  (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) );
+                  (*pdsch_vars_th)[th_id][eNB_id]->rxdataF_comp1[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) );
+                  (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_mag1[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) );
+                  (*pdsch_vars_th)[th_id][eNB_id]->dl_ch_magb1[k][l][idx] = (int32_t*)malloc16_clear( 7*2*sizeof(int32_t)*(fp->N_RB_DL*12) );
+              }
+
+                }
+        }
+      }
+      phy_init_nr_ue__PDSCH( pdsch_vars_SI[eNB_id], fp );
+      phy_init_nr_ue__PDSCH( pdsch_vars_ra[eNB_id], fp );
+      phy_init_nr_ue__PDSCH( pdsch_vars_p[eNB_id], fp );
+      phy_init_nr_ue__PDSCH( pdsch_vars_mch[eNB_id], fp );
+
+      // 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE
+      for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+          (*pdcch_vars_th)[th_id][eNB_id]->llr   = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
+          (*pdcch_vars_th)[th_id][eNB_id]->llr16 = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
+          (*pdcch_vars_th)[th_id][eNB_id]->wbar  = (uint16_t*)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
+          (*pdcch_vars_th)[th_id][eNB_id]->e_rx  = (int8_t*)malloc16_clear( 4*2*100*12 );
+
+          (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp        = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+          (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext       = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+          (*pdcch_vars_th)[th_id][eNB_id]->rho                 = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+          (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext         = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+          (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+      }
+      
+      for (i=0; i<fp->nb_antennas_rx; i++) {
+        //ue_pdcch_vars[eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(fp->N_RB_DL*12*7*2) );
+        for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+            (*pdcch_vars_th)[th_id][eNB_id]->rho[i] = (int32_t*)malloc16_clear( sizeof(int32_t)*(100*12*4) );
+        }
+
+        for (j=0; j<4; j++) { //fp->nb_antennas_tx; j++)
+          int idx = (j<<1)+i;
+          //  size_t num = 7*2*fp->N_RB_DL*12;
+          size_t num = 4*100*12;  // 4 symbols, 100 PRBs, 12 REs per PRB
+          for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+              (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_comp[idx]        = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+              (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_rho_ext[idx]       = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+              (*pdcch_vars_th)[th_id][eNB_id]->rxdataF_ext[idx]         = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+              (*pdcch_vars_th)[th_id][eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t) * num );
+          }
+        }
+      }
+
+      // PBCH
+      pbch_vars[eNB_id]->rxdataF_ext         = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
+      pbch_vars[eNB_id]->rxdataF_comp        = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+      pbch_vars[eNB_id]->dl_ch_estimates_ext = (int32_t**)malloc16_clear( 8*sizeof(int32_t*) );
+      pbch_vars[eNB_id]->llr                 = (int8_t*)malloc16_clear( 1920 );
+      prach_vars[eNB_id]->prachF             = (int16_t*)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
+      prach_vars[eNB_id]->prach              = (int16_t*)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
+
+      for (i=0; i<fp->nb_antennas_rx; i++) {
+        pbch_vars[eNB_id]->rxdataF_ext[i]    = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 );
+
+        for (j=0; j<4; j++) {//fp->nb_antennas_tx;j++) {
+          int idx = (j<<1)+i;
+          pbch_vars[eNB_id]->rxdataF_comp[idx]        = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 );
+          pbch_vars[eNB_id]->dl_ch_estimates_ext[idx] = (int32_t*)malloc16_clear( sizeof(int32_t)*6*12*4 );
+        }
+      }
+    }
+
+    pbch_vars[eNB_id]->decoded_output = (uint8_t*)malloc16_clear( 64 );
+  }
+
+  // initialization for the last instance of pdsch_vars (used for MU-MIMO)
+  for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+      (*pdsch_vars_th)[th_id][eNB_id]     = (NR_UE_PDSCH *)malloc16_clear( sizeof(NR_UE_PDSCH) );
+  }
+
+  pdsch_vars_SI[eNB_id]  = (NR_UE_PDSCH *)malloc16_clear( sizeof(NR_UE_PDSCH) );
+  pdsch_vars_ra[eNB_id]  = (NR_UE_PDSCH *)malloc16_clear( sizeof(NR_UE_PDSCH) );
+  pdsch_vars_p[eNB_id]   = (NR_UE_PDSCH *)malloc16_clear( sizeof(NR_UE_PDSCH) );
+
+  if (abstraction_flag == 0) {
+    for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
+        phy_init_lte_ue__PDSCH( (*pdsch_vars_th)[th_id][eNB_id], fp );
+        (*pdsch_vars_th)[th_id][eNB_id]->llr[1] = (int16_t*)malloc16_clear( (8*((3*8*8448)+12))*sizeof(int16_t) );
+    }
+
+  } else { //abstraction == 1
+    ue->sinr_dB = (double*) malloc16_clear( fp->N_RB_DL*12*sizeof(double) );
+  }
+
+  ue->sinr_CQI_dB = (double*) malloc16_clear( fp->N_RB_DL*12*sizeof(double) );
+
+  ue->init_averaging = 1;
+  // default value until overwritten by RRCConnectionReconfiguration
+  if (fp->nb_antenna_ports_eNB==2)
+    ue->pdsch_config_dedicated->p_a = dBm3;
+  else
+    ue->pdsch_config_dedicated->p_a = dB0;
+
+  // set channel estimation to do linear interpolation in time
+  ue->high_speed_flag = 1;
+  ue->ch_est_alpha    = 24576;
+
+  // enable MIB/SIB decoding by default
+  ue->decode_MIB = 1;
+  ue->decode_SIB = 1;
+
+  init_prach_tables(839);
+
+
+  return 0;
+
+}
+/*
+void nr_lte_ue_transport(PHY_VARS_UE *ue,int abstraction_flag) {
+
+  int i,j,k;
+
+  for (i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) {
+    for (j=0; j<2; j++) {
+      for (k=0; k<2; k++) {
+	AssertFatal((ue->dlsch[k][i][j]  = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag))!=NULL,"Can't get ue dlsch structures\n");
+
+	LOG_D(PHY,"dlsch[%d][%d][%d] => %p\n",k,i,j,ue->dlsch[i][j]);
+      }
+    }
+
+    AssertFatal((ue->ulsch[i]  = new_ue_ulsch(ue->frame_parms.N_RB_UL, abstraction_flag))!=NULL,"Can't get ue ulsch structures\n");
+
+    ue->dlsch_SI[i]  = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag);
+    ue->dlsch_ra[i]  = new_ue_dlsch(1,1,NSOFT,MAX_TURBO_ITERATIONS,ue->frame_parms.N_RB_DL, 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->dlsch_MCH[0]  = new_ue_dlsch(1,NUMBER_OF_HARQ_PID_MAX,NSOFT,MAX_TURBO_ITERATIONS_MBSFN,ue->frame_parms.N_RB_DL,0);
+
+}*/
+
+void phy_init_nr_top(NR_DL_FRAME_PARMS *frame_parms)
+{
+
+  crcTableInit();
+
+  ccodedot11_init();
+  ccodedot11_init_inv();
+
+  ccodelte_init();
+  ccodelte_init_inv();
+
+  //treillis_table_init();
+
+  phy_generate_viterbi_tables();
+  phy_generate_viterbi_tables_lte();
+
+  //init_td8();
+  //init_td16();
+#ifdef __AVX2__
+  //init_td16avx2();
+#endif
+
+  init_context_synchro_nr(frame_parms);
+
+  generate_ul_reference_signal_sequences(SHRT_MAX);
+
+  //lte_sync_time_init(frame_parms);
+
+  //generate_ul_ref_sigs();
+  //generate_ul_ref_sigs_rx();
+
+  //generate_64qam_table();
+  //generate_16qam_table();
+  //generate_RIV_tables();
+
+  //init_unscrambling_lut();
+  //init_scrambling_lut();
+  
+  //set_taus_seed(1328);
+
+}
diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c
index 2a6bb66700fc78a95b344127d867ebb28d3dbe4d..1fcaaed494362ce17fcacf5bb354c0c437d3fd71 100644
--- a/openair1/PHY/INIT/nr_parms.c
+++ b/openair1/PHY/INIT/nr_parms.c
@@ -139,11 +139,161 @@ int nr_init_frame_parms(nfapi_config_request_t* config,
     AssertFatal(1==0,"Invalid numerology index %d", mu);
   }
 
+
+  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;
+  frame_parms->samples_per_subframe = (frame_parms->samples_per_subframe_wCP + (frame_parms->nb_prefix_samples0 * frame_parms->slots_per_subframe) +
+                                      (frame_parms->nb_prefix_samples * frame_parms->slots_per_subframe * (frame_parms->symbols_per_slot - 1)));
+  frame_parms->samples_per_frame = 10 * frame_parms->samples_per_subframe;
+
+
+  return 0;
+}
+
+int nr_init_frame_parms_ue(nfapi_config_request_t* config,
+                        NR_DL_FRAME_PARMS *frame_parms)
+{
+
+  int N_RB = 106;
+  int Ncp = 0;
+  int mu = 1;
+
+#if DISABLE_LOG_X
+  printf("Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, N_RB, Ncp);
+#else
+  LOG_I(PHY,"Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, N_RB, Ncp);
+#endif
+
+  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->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;
+
+  if (Ncp == EXTENDED)
+    AssertFatal(mu == NR_MU_2,"Invalid cyclic prefix %d for numerology index %d\n", Ncp, mu);
+
+  switch(mu) {
+
+    case NR_MU_0: //15kHz scs
+      frame_parms->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_0];
+      frame_parms->slots_per_subframe = nr_slots_per_subframe[NR_MU_0];
+      break;
+
+    case NR_MU_1: //30kHz scs
+      frame_parms->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_1];
+      frame_parms->slots_per_subframe = nr_slots_per_subframe[NR_MU_1];
+
+      switch(N_RB){
+        case 11:
+        case 24:
+        case 38:
+        case 78:
+        case 51:
+        case 65:
+
+        case 106: //40 MHz
+          if (frame_parms->threequarter_fs) {
+            frame_parms->ofdm_symbol_size = 1536;
+            frame_parms->first_carrier_offset = 900; //1536 - 636
+            frame_parms->nb_prefix_samples0 = 132;
+            frame_parms->nb_prefix_samples = 108;
+          }
+          else {
+            frame_parms->ofdm_symbol_size = 2048;
+            frame_parms->first_carrier_offset = 1412; //2048 - 636
+            frame_parms->nb_prefix_samples0 = 176;
+            frame_parms->nb_prefix_samples = 144;
+          }
+          break;
+
+        case 133:
+        case 162:
+        case 189:
+
+        case 217: //80 MHz
+          if (frame_parms->threequarter_fs) {
+            frame_parms->ofdm_symbol_size = 3072;
+            frame_parms->first_carrier_offset = 1770; //3072 - 1302
+            frame_parms->nb_prefix_samples0 = 264;
+            frame_parms->nb_prefix_samples = 216;
+          }
+          else {
+            frame_parms->ofdm_symbol_size = 4096;
+            frame_parms->first_carrier_offset = 2794; //4096 - 1302
+            frame_parms->nb_prefix_samples0 = 352;
+            frame_parms->nb_prefix_samples = 288;
+          }
+          break;
+
+        case 245:
+        case 273:
+      default:
+        AssertFatal(1==0,"Number of resource blocks %d undefined for mu %d, frame parms = %p\n", N_RB, mu, frame_parms);
+      }
+      break;
+
+    case NR_MU_2: //60kHz scs
+      frame_parms->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_2];
+      frame_parms->slots_per_subframe = nr_slots_per_subframe[NR_MU_2];
+
+      switch(N_RB){ //FR1 bands only
+        case 11:
+        case 18:
+        case 38:
+        case 24:
+        case 31:
+        case 51:
+        case 65:
+        case 79:
+        case 93:
+        case 107:
+        case 121:
+        case 135:
+      default:
+        AssertFatal(1==0,"Number of resource blocks %d undefined for mu %d, frame parms = %p\n", N_RB, mu, frame_parms);
+      }
+      break;
+
+    case NR_MU_3:
+      frame_parms->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_3];
+      frame_parms->slots_per_subframe = nr_slots_per_subframe[NR_MU_3];
+      break;
+
+    case NR_MU_4:
+      frame_parms->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_4];
+      frame_parms->slots_per_subframe = nr_slots_per_subframe[NR_MU_4];
+      break;
+
+  default:
+    AssertFatal(1==0,"Invalid numerology index %d", mu);
+  }
+
+    frame_parms->nb_prefix_samples0 = 160;
+    frame_parms->nb_prefix_samples = 144;
+    frame_parms->symbols_per_tti = 14;
+    frame_parms->numerology_index = 0;
+    frame_parms->ttis_per_subframe = 1;
+    frame_parms->slots_per_tti = 2; //only slot config 1 is supported     
+
+    frame_parms->ofdm_symbol_size = 2048;
+    frame_parms->samples_per_tti = 30720;
+    frame_parms->samples_per_subframe = 30720 * frame_parms->ttis_per_subframe;
+    frame_parms->first_carrier_offset = 2048-600;
+
   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;
-  frame_parms->samples_per_subframe = frame_parms->samples_per_subframe_wCP + (frame_parms->nb_prefix_samples0 * frame_parms->slots_per_subframe) +
-                                      (frame_parms->nb_prefix_samples * frame_parms->slots_per_subframe * (frame_parms->symbols_per_slot - 1));
+  //frame_parms->samples_per_subframe = (frame_parms->samples_per_subframe_wCP + (frame_parms->nb_prefix_samples0 * frame_parms->slots_per_subframe) +
+  //                                    (frame_parms->nb_prefix_samples * frame_parms->slots_per_subframe * (frame_parms->symbols_per_slot - 1)));
   frame_parms->samples_per_frame = 10 * frame_parms->samples_per_subframe;
 
 
diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h
index 2a6196aa293977aeac35ee03a21871123430df51..40ec1bd308a9a29dbbdf20571ee5e72ed1c8e71c 100644
--- a/openair1/PHY/INIT/phy_init.h
+++ b/openair1/PHY/INIT/phy_init.h
@@ -375,6 +375,7 @@ void phy_config_request(PHY_Config_t *phy_config);
 int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf);
 void dump_frame_parms(LTE_DL_FRAME_PARMS *frame_parms);
 int nr_init_frame_parms(nfapi_config_request_t* config, NR_DL_FRAME_PARMS *frame_parms);
+int nr_init_frame_parms_ue(nfapi_config_request_t* config, NR_DL_FRAME_PARMS *frame_parms);
 void nr_dump_frame_parms(NR_DL_FRAME_PARMS *frame_parms);
 int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char is_secondary_gNB, unsigned char abstraction_flag);
 void nr_phy_config_request(PHY_VARS_gNB *gNB);
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c
index 8810752398f1991361c2826519d70075bf645a30..7e2354090be53666edadb57a2c347c145600687a 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync.c
@@ -22,6 +22,7 @@
 #include "PHY/types.h"
 #include "PHY/defs_UE.h"
 #include "PHY/phy_extern_ue.h"
+#include "lte_estimation.h"
 
 #include "UTIL/LOG/vcd_signal_dumper.h"
 #include "openair2/LAYER2/MAC/mac_proto.h"
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_timefreq.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_timefreq.c
index fd7b8d601ab9db9811c99a7df8b6b75cd0e2a9e0..388ed6bf29cf8171a6cfea003ebdf9af4e764a65 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_sync_timefreq.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_timefreq.c
@@ -81,7 +81,8 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
 
       //compute frequency-domain representation of 6144-sample chunk
       dft6144((int16_t *)rxp,
-              sp);
+              sp,
+              1);
 
 
       /*
diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c
index f782129c81e92d4afc383f9382ec76e4d962fb65..fb80d13b5e0935b9d86b1155d8cd951d77e9ff80 100644
--- a/openair1/PHY/LTE_TRANSPORT/prach.c
+++ b/openair1/PHY/LTE_TRANSPORT/prach.c
@@ -357,10 +357,10 @@ void rx_prach0(PHY_VARS_eNB *eNB,
 	if (prach_fmt == 4) {
 	  dft256(prach2,rxsigF[aa],1);
 	} else {
-	  dft3072(prach2,rxsigF[aa]);
+	  dft3072(prach2,rxsigF[aa],1);
 	  
 	  if (prach_fmt>1)
-	    dft3072(prach2+6144,rxsigF[aa]+6144);
+	    dft3072(prach2+6144,rxsigF[aa]+6144,1);
 	}
 	
 	break;
@@ -371,10 +371,10 @@ void rx_prach0(PHY_VARS_eNB *eNB,
 	  dft1024(prach2,rxsigF[aa],1);
 	  fft_size = 1024;
 	} else {
-	  dft6144(prach2,rxsigF[aa]);
+	  dft6144(prach2,rxsigF[aa],1);
 	  
 	  if (prach_fmt>1)
-	    dft6144(prach2+12288,rxsigF[aa]+12288);
+	    dft6144(prach2+12288,rxsigF[aa]+12288,1);
 	  
 	  fft_size = 6144;
 	}
@@ -395,7 +395,7 @@ void rx_prach0(PHY_VARS_eNB *eNB,
 	
       case 75:
 	if (prach_fmt == 4) {
-	  dft3072(prach2,rxsigF[aa]);
+	  dft3072(prach2,rxsigF[aa],1);
 	} else {
 	  dft18432(prach2,rxsigF[aa]);
 	  
@@ -417,7 +417,7 @@ void rx_prach0(PHY_VARS_eNB *eNB,
 	  }
 	} else {
 	  if (prach_fmt == 4) {
-	    dft3072(prach2,rxsigF[aa]);
+	    dft3072(prach2,rxsigF[aa],1);
 	  } else {
 	    dft18432(prach2,rxsigF[aa]);
 	    
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c
index 81cd18c954f647ceb9bd58c50a828fdf94a35b14..f6938f32343badabe40defad97b45b19802e928e 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c
@@ -33,7 +33,6 @@
 #include "PHY/defs_UE.h"
 #include "PHY/TOOLS/tools_defs.h"
 #include "PHY/phy_extern_ue.h"
-#include "transport_ue.h"
 #include "PHY/sse_intrin.h"
 
 int16_t ones256[16] __attribute__ ((aligned(32))) = {0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff};
diff --git a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c
index c9763465cdfbc55c8091289fc2773e2aa8e7a6a1..a0e771e669d1a7bf4d5c4da355669b27d3f2fd13 100644
--- a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c
+++ b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c
@@ -374,7 +374,7 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1
       memmove( prach, prach+1024, Ncp<<2 );
       prach_len = 512+Ncp;
     } else {
-      idft3072(prachF,prach2);
+      idft3072(prachF,prach2,1);
       memmove( prach, prach+6144, Ncp<<2 );
       prach_len = 3072+Ncp;
 
@@ -393,7 +393,7 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1
       memmove( prach, prach+2048, Ncp<<2 );
       prach_len = 1024+Ncp;
     } else {
-      idft6144(prachF,prach2);
+      idft6144(prachF,prach2,1);
       /*for (i=0;i<6144*2;i++)
       prach2[i]<<=1;*/
       memmove( prach, prach+12288, Ncp<<2 );
@@ -427,7 +427,7 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1
 
   case 75:
     if (prach_fmt == 4) {
-      idft3072(prachF,prach2);
+      idft3072(prachF,prach2,1);
       //TODO: account for repeated format in dft output
       memmove( prach, prach+6144, Ncp<<2 );
       prach_len = 3072+Ncp;
@@ -463,7 +463,7 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1
     }
     else {
       if (prach_fmt == 4) {
-	idft3072(prachF,prach2);
+	idft3072(prachF,prach2,1);
 	//TODO: account for repeated format in dft output
 	memmove( prach, prach+6144, Ncp<<2 );
 	prach_len = 3072+Ncp;
diff --git a/openair1/PHY/MODULATION/modulation_UE.h b/openair1/PHY/MODULATION/modulation_UE.h
index 7e2a3c8a27778f75b59866ea60392916baf9c684..92afcea7246f6f8e097cf1ba25b11a5427fd6009 100644
--- a/openair1/PHY/MODULATION/modulation_UE.h
+++ b/openair1/PHY/MODULATION/modulation_UE.h
@@ -23,6 +23,8 @@
 #define __MODULATION_DEFS__H__
 #include "PHY/defs_common.h"
 #include "modulation_common.h"
+#include "PHY/defs_UE.h"
+#include "PHY/defs_nr_UE.h"
 /** @addtogroup _PHY_MODULATION_
  * @{
 */
@@ -46,6 +48,13 @@ int slot_fep(PHY_VARS_UE *phy_vars_ue,
              int no_prefix,
 	     int reset_freq_est);
 
+int slot_fep_pbch(PHY_VARS_NR_UE *phy_vars_ue,
+             unsigned char l,
+             unsigned char Ns,
+             int sample_offset,
+             int no_prefix,
+	     int reset_freq_est);
+
 int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue,
                    unsigned char l,
                    int subframe,
diff --git a/openair1/PHY/MODULATION/slot_fep.c b/openair1/PHY/MODULATION/slot_fep.c
index b01979431dcf88212604aa71cf0d0470eb177d06..28fc0e02ffc68c7c68b3b8c6bc18c0f3b385bb90 100644
--- a/openair1/PHY/MODULATION/slot_fep.c
+++ b/openair1/PHY/MODULATION/slot_fep.c
@@ -20,6 +20,7 @@
  */
 
 #include "PHY/defs_UE.h"
+#include "PHY/defs_nr_UE.h"
 #include "modulation_UE.h"
 #include "PHY/LTE_ESTIMATION/lte_estimation.h"
 
@@ -27,6 +28,207 @@
 
 #define SOFFSET 0
 
+int slot_fep_pbch(PHY_VARS_NR_UE *ue,
+             unsigned char l,
+             unsigned char Ns,
+             int sample_offset,
+             int no_prefix,
+			 int reset_freq_est)
+{
+  NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
+  NR_UE_COMMON *common_vars   = &ue->common_vars;
+  uint8_t eNB_id = 0;//ue_common_vars->eNb_id;
+  unsigned char aa;
+  unsigned char symbol = l;//+((7-frame_parms->Ncp)*(Ns&1)); ///symbol within sub-frame
+  unsigned int nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
+  unsigned int nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0);
+  unsigned int subframe_offset;//,subframe_offset_F;
+  unsigned int slot_offset;
+  int i;
+  unsigned int frame_length_samples = frame_parms->samples_per_subframe * 10;
+  unsigned int rx_offset;
+
+  /*LTE_UE_DLSCH_t **dlsch_ue = phy_vars_ue->dlsch_ue[eNB_id];
+  unsigned char harq_pid = dlsch_ue[0]->current_harq_pid;
+  LTE_DL_UE_HARQ_t *dlsch0_harq = dlsch_ue[0]->harq_processes[harq_pid];
+  int uespec_pilot[9][1200];*/
+
+  void (*dft)(int16_t *,int16_t *, int);
+  int tmp_dft_in[2048] __attribute__ ((aligned (32)));  // This is for misalignment issues for 6 and 15 PRBs
+
+  switch (frame_parms->ofdm_symbol_size) {
+  case 128:
+    dft = dft128;
+    break;
+
+  case 256:
+    dft = dft256;
+    break;
+
+  case 512:
+    dft = dft512;
+    break;
+
+  case 1024:
+    dft = dft1024;
+    break;
+
+  case 1536:
+    dft = dft1536;
+    break;
+
+  case 2048:
+    dft = dft2048;
+    break;
+
+  default:
+    dft = dft512;
+    break;
+  }
+
+  if (no_prefix) {
+    subframe_offset = frame_parms->ofdm_symbol_size * frame_parms->symbols_per_tti * (Ns>>1);
+    slot_offset = frame_parms->ofdm_symbol_size * (frame_parms->symbols_per_tti>>1) * (Ns%2);
+  } else {
+    subframe_offset = frame_parms->samples_per_tti * (Ns>>1);
+    slot_offset = (frame_parms->samples_per_tti>>1) * (Ns%2);
+  }
+
+  if (l<0 || l>=7-frame_parms->Ncp) {
+    printf("slot_fep: l must be between 0 and %d\n",7-frame_parms->Ncp);
+    return(-1);
+  }
+
+  if (Ns<0 || Ns>=20) {
+    printf("slot_fep: Ns must be between 0 and 19\n");
+    return(-1);
+  }
+
+
+
+  for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
+    memset(&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],0,frame_parms->ofdm_symbol_size*sizeof(int));
+
+    rx_offset = sample_offset + slot_offset + nb_prefix_samples0 + subframe_offset - SOFFSET;
+    // Align with 256 bit
+    //    rx_offset = rx_offset&0xfffffff8;
+
+    if (l==0) {
+
+      if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size))
+        memcpy((short *)&common_vars->rxdata[aa][frame_length_samples],
+               (short *)&common_vars->rxdata[aa][0],
+               frame_parms->ofdm_symbol_size*sizeof(int));
+
+      if ((rx_offset&7)!=0) {  // if input to dft is not 256-bit aligned, issue for size 6,15 and 25 PRBs
+        memcpy((void *)tmp_dft_in,
+               (void *)&common_vars->rxdata[aa][rx_offset % frame_length_samples],
+               frame_parms->ofdm_symbol_size*sizeof(int));
+        dft((int16_t *)tmp_dft_in,
+            (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
+      } else { // use dft input from RX buffer directly
+#if UE_TIMING_TRACE
+          start_meas(&ue->rx_dft_stats);
+#endif
+
+        dft((int16_t *)&common_vars->rxdata[aa][(rx_offset) % frame_length_samples],
+            (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
+#if UE_TIMING_TRACE
+        stop_meas(&ue->rx_dft_stats);
+#endif
+
+      }
+    } else {
+      rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*l;// +
+      //                   (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1);
+
+#ifdef DEBUG_FEP
+      //  if (ue->frame <100)
+      LOG_I(PHY,"slot_fep: frame %d: slot %d, symbol %d, nb_prefix_samples %d, nb_prefix_samples0 %d, slot_offset %d, subframe_offset %d, sample_offset %d,rx_offset %d, frame_length_samples %d\n", ue->proc.proc_rxtx[(Ns>>1)&1].frame_rx,Ns, symbol,
+          nb_prefix_samples,nb_prefix_samples0,slot_offset,subframe_offset,sample_offset,rx_offset,frame_length_samples);
+#endif
+
+      if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size))
+        memcpy((void *)&common_vars->rxdata[aa][frame_length_samples],
+               (void *)&common_vars->rxdata[aa][0],
+               frame_parms->ofdm_symbol_size*sizeof(int));
+#if UE_TIMING_TRACE
+      start_meas(&ue->rx_dft_stats);
+#endif
+
+      if ((rx_offset&7)!=0) {  // if input to dft is not 128-bit aligned, issue for size 6 and 15 PRBs
+        memcpy((void *)tmp_dft_in,
+               (void *)&common_vars->rxdata[aa][(rx_offset) % frame_length_samples],
+               frame_parms->ofdm_symbol_size*sizeof(int));
+        dft((int16_t *)tmp_dft_in,
+            (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
+      } else { // use dft input from RX buffer directly
+
+        dft((int16_t *)&common_vars->rxdata[aa][(rx_offset) % frame_length_samples],
+            (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
+      }
+#if UE_TIMING_TRACE
+      stop_meas(&ue->rx_dft_stats);
+#endif
+
+
+    }
+
+    #ifdef DEBUG_FEP
+        //  if (ue->frame <100)
+        printf("slot_fep: frame %d: symbol %d rx_offset %d\n", ue->proc.proc_rxtx[(Ns>>1)&1].frame_rx, symbol,rx_offset);
+    #endif
+  }
+
+  if (ue->perfect_ce == 0) {
+    if ((l>0) && (l<4)) {
+      for (aa=0; aa<frame_parms->nb_antenna_ports_eNB; aa++) {
+
+#ifdef DEBUG_FEP
+        printf("Channel estimation eNB %d, aatx %d, slot %d, symbol %d\n",eNB_id,aa,Ns,l);
+#endif
+#if UE_TIMING_TRACE
+        start_meas(&ue->dlsch_channel_estimation_stats);
+#endif
+        nr_pbch_channel_estimation(ue,eNB_id,0,
+                                  Ns,
+                                  aa,
+                                  l,
+                                  symbol);
+      }
+
+
+      // do frequency offset estimation here!
+      // use channel estimates from current symbol (=ch_t) and last symbol (ch_{t-1})
+#ifdef DEBUG_FEP
+      printf("Frequency offset estimation\n");
+#endif
+
+      if (l==(4-frame_parms->Ncp)) {
+
+#if UE_TIMING_TRACE
+          start_meas(&ue->dlsch_freq_offset_estimation_stats);
+#endif
+
+        /*lte_est_freq_offset(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].dl_ch_estimates[0],
+                            frame_parms,
+                            l,
+                            &common_vars->freq_offset,
+			    reset_freq_est);*/
+#if UE_TIMING_TRACE
+        stop_meas(&ue->dlsch_freq_offset_estimation_stats);
+#endif
+
+      }
+    }
+
+  }
+
+#ifdef DEBUG_FEP
+  printf("slot_fep: done\n");
+#endif
+  return(0);
+}
 
 int slot_fep(PHY_VARS_UE *ue,
              unsigned char l,
diff --git a/openair1/PHY/NR_REFSIG/dmrs_nr.h b/openair1/PHY/NR_REFSIG/dmrs_nr.h
new file mode 100644
index 0000000000000000000000000000000000000000..a695006304762b3eee95e0d644ce2cb5b7d683e0
--- /dev/null
+++ b/openair1/PHY/NR_REFSIG/dmrs_nr.h
@@ -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
+ */
+
+/**********************************************************************
+*
+* FILENAME    :  dmrs.h
+*
+* MODULE      :  demodulation reference signals
+*
+* DESCRIPTION :  generation of dmrs sequences for NR 5G
+*                3GPP TS 38.211
+*
+************************************************************************/
+
+#ifndef DMRS_NR_H
+#define DMRS_NR_H
+
+#include "PHY/defs_nr_UE.h"
+#include "PHY/types.h"
+#include "PHY/NR_REFSIG/ss_pbch_nr.h"
+#include "PHY/NR_REFSIG/pss_nr.h"
+#include "PHY/NR_REFSIG/sss_nr.h"
+
+/************** CODE GENERATION ***********************************/
+
+/************** DEFINE ********************************************/
+
+
+/************* STRUCTURES *****************************************/
+
+
+/************** VARIABLES *****************************************/
+
+/************** FUNCTION ******************************************/
+
+int pseudo_random_sequence(int M_PN, uint32_t *c, uint32_t cinit);
+void lte_gold_new(LTE_DL_FRAME_PARMS *frame_parms, uint32_t lte_gold_table[20][2][14], uint16_t Nid_cell);
+void generate_dmrs_pbch(uint32_t dmrs_pbch_bitmap[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE], uint16_t Nid_cell);
+
+#undef EXTERN
+
+#endif /* DMRS_NR_H */
+
+
diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c
new file mode 100644
index 0000000000000000000000000000000000000000..0b3ffe5bc7bc0b8c67be1d2763af54e8f18c83b0
--- /dev/null
+++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c
@@ -0,0 +1,159 @@
+/*
+ * 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 PHY/NR_REFSIG/nr_dl_dmrs.c
+* \brief Top-level routines for generating DMRS from 38-211
+* \author
+* \date 2018
+* \version 0.1
+* \company Eurecom
+* \email:
+* \note
+* \warning
+*/
+
+//#define DEBUG_DL_DMRS
+//#define NR_PBCH_DMRS_LENGTH_DWORD 5
+//#define NR_PBCH_DMRS_LENGTH 144
+
+#ifdef USER_MODE
+#include <stdio.h>
+#include <stdlib.h>
+#endif
+
+#include "refsig_defs_ue.h"
+#include "PHY/defs_nr_UE.h"
+#include "log.h"
+
+/*Table 7.4.1.1.2-1/2 from 38.211 */
+int wf1[8][2] = {{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,1}};
+int wt1[8][2] = {{1,1},{1,1},{1,1},{1,1},{1,-1},{1,-1},{1,-1},{1,-1}};
+int wf2[12][2] = {{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,-1},{1,1},{1,1},{1,1},{1,-1},{1,1},{1,1}};
+int wt2[12][2] = {{1,1},{1,1},{1,1},{1,1},{1,1},{1,1},{1,-1},{1,-1},{1,-1},{1,-1},{1,-1},{1,-1}};
+
+short nr_mod_table[14] = {0,0,23170,23170,-23170,-23170,23170,23170,23170,-23170,-23170,23170,-23170,-23170};
+//extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT];
+
+
+int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue,
+						unsigned int ncp,
+						unsigned int Ns,
+						unsigned int nr_gold_pdsch[2][20][2][21],
+						int32_t *output,
+						unsigned short p,
+						int length_dmrs,
+						unsigned short nb_pdsch_rb)
+{
+  int32_t qpsk[4],nqpsk[4],*qpsk_p, n;
+  int w,mprime,ind,l,ind_dword,ind_qpsk_symb,kp,lp, config_type, k;
+  short pamp;
+
+  typedef int array_of_w[2];
+  array_of_w *wf;
+  array_of_w *wt;
+
+  config_type = 1;
+  printf("dmrs config type %d port %d\n", config_type, p);
+
+  // Compute the correct pilot amplitude, sqrt_rho_b = Q3.13
+  pamp = 23170; //ONE_OVER_SQRT2_Q15;
+
+  // This includes complex conjugate for channel estimation
+  ((short *)&qpsk[0])[0] = pamp;
+  ((short *)&qpsk[0])[1] = -pamp;
+  ((short *)&qpsk[1])[0] = -pamp;
+  ((short *)&qpsk[1])[1] = -pamp;
+  ((short *)&qpsk[2])[0] = pamp;
+  ((short *)&qpsk[2])[1] = pamp;
+  ((short *)&qpsk[3])[0] = -pamp;
+  ((short *)&qpsk[3])[1] = pamp;
+
+  ((short *)&nqpsk[0])[0] = -pamp;
+  ((short *)&nqpsk[0])[1] = pamp;
+  ((short *)&nqpsk[1])[0] = pamp;
+  ((short *)&nqpsk[1])[1] = pamp;
+  ((short *)&nqpsk[2])[0] = -pamp;
+  ((short *)&nqpsk[2])[1] = -pamp;
+  ((short *)&nqpsk[3])[0] = pamp;
+  ((short *)&nqpsk[3])[1] = -pamp;
+
+  wf = (config_type==0) ? wf1 : wf2;
+  wt = (config_type==0) ? wt1 : wt2;
+
+  if (config_type > 1)
+      LOG_E(PHY,"Bad PDSCH DMRS config type %d\n", config_type);
+
+  if ((p>=1000) && (p<((config_type==0) ? 1008 : 1012))) {
+      if (/*ue->frame_parms.Ncp == NORMAL*/ncp ==0) {
+
+        // r_n from 38.211 7.4.1.1
+        for (n=0; n<nb_pdsch_rb*((config_type==0) ? 3:2); n++) {
+        	for (lp =0; lp<length_dmrs; lp++){
+        		for (kp=0; kp<2; kp++){
+        			w = (wf[p-1000][kp])*(wt[p-1000][lp]);
+        			qpsk_p = (w==1) ? qpsk : nqpsk;
+
+        			ind = 2*n+kp;
+        			ind_dword = ind>>4;
+        			ind_qpsk_symb = ind&0xf;
+
+        			output[k] = qpsk_p[(ue->nr_gold_pdsch[0][Ns][lp][ind_dword]>>(2*ind_qpsk_symb))&3];
+
+
+#ifdef DEBUG_DL_DMRS
+          LOG_I(PHY,"Ns %d, p %d, ind_dword %d, ind_qpsk_symbol %d\n",
+                Ns,p,idx_dword,idx_qpsk_symb);
+          LOG_I(PHY,"index = %d\n",(nr_gold_pdsch[0][Ns][lprime][ind_dword]>>(2*ind_qpsk_symb))&3);
+#endif
+
+          	  	  	k++;
+        		}
+        	}
+        }
+      } else {
+        LOG_E(PHY,"extended cp not supported for PDSCH DMRS yet\n");
+      }
+  } else {
+    LOG_E(PHY,"Illegal p %d PDSCH DMRS port\n",p);
+  }
+
+  return(0);
+}
+
+int nr_pbch_dmrs_rx(unsigned int *nr_gold_pbch,
+					int32_t *output	)
+{
+	int m;
+
+	/// BPSK modulation
+    for (m=0; m<NR_PBCH_DMRS_LENGTH; m++) {
+      ((int16_t*)output)[m<<1] = nr_mod_table[((1 + ((nr_gold_pbch[m>>5]&(1<<(m&0x1f)))>>(m&0x1f)))<<1)];
+      ((int16_t*)output)[(m<<1)+1] = nr_mod_table[((1 + ((nr_gold_pbch[m>>5]&(1<<(m&0x1f)))>>(m&0x1f)))<<1) + 1];
+#ifdef DEBUG_PBCH
+	//printf("nr_gold_pbch[m>>5] %x\n",nr_gold_pbch[m>>5]);
+       if (m<6)
+	printf("m %d  output %d %d addr %p\n", m, output[2*m], output[2*m+1],&output[0]);
+#endif
+    }
+
+  return(0);
+}
+
diff --git a/openair1/PHY/NR_REFSIG/nr_gold_ue.c b/openair1/PHY/NR_REFSIG/nr_gold_ue.c
new file mode 100644
index 0000000000000000000000000000000000000000..1386f9846b3049515ea7a622d70ca961a7f8685a
--- /dev/null
+++ b/openair1/PHY/NR_REFSIG/nr_gold_ue.c
@@ -0,0 +1,115 @@
+/*
+ * 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 "refsig_defs_ue.h"
+
+void nr_gold_pbch(PHY_VARS_NR_UE* ue)
+{
+
+  unsigned int n, x1, x2;
+  unsigned char Nid, i_ssb, i_ssb2;
+  unsigned char Lmax, l, n_hf, N_hf;
+
+  Nid = ue->frame_parms.Nid_cell;
+
+  Lmax = 8; //(fp->dl_CarrierFreq < 3e9)? 4:8;
+  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<NR_PBCH_DMRS_LENGTH_DWORD; 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);
+        ue->nr_gold_pbch[n_hf][l][n] = x1 ^ x2;
+      }
+
+    }
+  }
+
+}
+
+void nr_gold_pdsch(PHY_VARS_NR_UE* ue,unsigned short lbar,unsigned int nr_gold_pdsch[2][20][2][21],unsigned int Nid_cell, unsigned short *n_idDMRS, unsigned short length_dmrs)
+{
+
+  unsigned char ns,l;
+  unsigned int n,x1,x2,x2tmp0,x2tmp1, x2tmp2,x2s;
+  int nscid;
+  unsigned int nid;
+
+  /// to be updated from higher layer
+  //unsigned short lbar = 0;
+
+  for (nscid=0; nscid<2; nscid++) {
+    if (n_idDMRS)
+      nid = n_idDMRS[nscid];
+    else
+      nid = Nid_cell;
+
+    for (ns=0; ns<20; ns++) {
+
+      for (l=0; l<length_dmrs; l++) {
+
+    	x2tmp0 = ((14*ns+(lbar+l)+1)*((nid<<1)+1))<<17;
+        x2 = (x2tmp0+(nid<<1))%(1<<31);  //cinit
+
+        x1 = 1+ (1<<31);
+        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);
+            //printf("x1 : %x, x2 : %x\n",x1,x2);
+        }
+
+        for (n=0; n<14; 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);
+          nr_gold_pdsch[nscid][ns][l][n] = x1^x2;
+            //printf("n=%d : c %x\n",n,x1^x2);
+        }
+
+      }
+    }
+  }
+}
diff --git a/openair1/PHY/NR_REFSIG/pss_nr.h b/openair1/PHY/NR_REFSIG/pss_nr.h
new file mode 100644
index 0000000000000000000000000000000000000000..c171cf501bdf64257c03df398f023dcacf798f92
--- /dev/null
+++ b/openair1/PHY/NR_REFSIG/pss_nr.h
@@ -0,0 +1,142 @@
+/*
+ * 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
+ */
+
+/**********************************************************************
+*
+* FILENAME    :  pss_nr.h
+*
+* MODULE      :  primary synchronisation signal
+*
+* DESCRIPTION :  elements related to pss
+*
+************************************************************************/
+
+#ifndef PSS_NR_H
+#define PSS_NR_H
+
+#include "PHY/defs_nr_UE.h"
+#include "PHY/types.h"
+
+#include "PHY/NR_REFSIG/ss_pbch_nr.h"
+
+#ifdef DEFINE_VARIABLES_PSS_NR_H
+#define EXTERN
+#else
+#define EXTERN  extern
+#endif
+
+/************** CODE GENERATION ***********************************/
+
+//#define PSS_DECIMATOR                          /* decimation of sample is done between time correlation */
+
+//#define CIC_DECIMATOR                          /* it allows enabling decimation based on CIC filter. By default, decimation is based on a FIF filter */
+
+#define TEST_SYNCHRO_TIMING_PSS        (1)     /* enable time profiling */
+
+//#define DBG_PSS_NR
+
+/************** DEFINE ********************************************/
+
+/* PROFILING */
+#define TIME_PSS                      (0)
+#define TIME_RATE_CHANGE              (TIME_PSS+1)
+#define TIME_SSS                      (TIME_RATE_CHANGE+1)
+#define TIME_LAST                     (TIME_SSS+1)
+
+/* PSS configuration */
+
+#define SYNCHRO_FFT_SIZE_MAX           (2048)                       /* maximum size of fft for synchronisation */
+
+#define  NO_RATE_CHANGE                (1)
+
+#ifdef PSS_DECIMATOR
+  #define  RATE_CHANGE                 (SYNCHRO_FFT_SIZE_MAX/SYNCHRO_FFT_SIZE_PSS)
+  #define  SYNCHRO_FFT_SIZE_PSS        (256)
+  #define  OFDM_SYMBOL_SIZE_PSS        (SYNCHRO_FFT_SIZE_PSS)
+  #define  SYNCHRO_RATE_CHANGE_FACTOR  (SYNCHRO_FFT_SIZE_MAX/SYNCHRO_FFT_SIZE_PSS)
+  #define  CIC_FILTER_STAGE_NUMBER     (4)
+#else
+  #define  RATE_CHANGE                 (1)
+  #define  SYNCHRO_RATE_CHANGE_FACTOR  (1)
+#endif
+
+#define SYNC_TMP_SIZE                  (NB_ANTENNAS_RX*SYNCHRO_FFT_SIZE_MAX*IQ_SIZE) /* to be aligned with existing lte synchro */
+#define SYNCF_TMP_SIZE                 (SYNCHRO_FFT_SIZE_MAX*IQ_SIZE)
+
+/************* STRUCTURES *****************************************/
+
+
+/************** VARIABLES *****************************************/
+
+//#define STATIC_SYNC_BUFFER
+
+#ifdef STATIC_SYNC_BUFFER
+/* buffer defined in file lte_sync_time */
+EXTERN int16_t synchro_tmp[SYNC_TMP_SIZE]   __attribute__((aligned(32)));
+EXTERN int16_t synchroF_tmp[SYNCF_TMP_SIZE] __attribute__((aligned(32)));
+#else
+EXTERN int16_t *synchro_tmp;
+EXTERN int16_t *synchroF_tmp;
+#endif
+
+EXTERN int16_t *primary_synchro_nr[NUMBER_PSS_SEQUENCE]
+#ifdef INIT_VARIABLES_PSS_NR_H
+= { NULL, NULL, NULL}
+#endif
+;
+EXTERN int16_t *primary_synchro_time_nr[NUMBER_PSS_SEQUENCE]
+#ifdef INIT_VARIABLES_PSS_NR_H
+= { NULL, NULL, NULL}
+#endif
+;
+
+EXTERN int *pss_corr_ue[NUMBER_PSS_SEQUENCE]
+#ifdef INIT_VARIABLES_PSS_NR_H
+= { NULL, NULL, NULL}
+#endif
+;
+
+/* profiling structure */
+EXTERN double cpuf;
+time_stats_t generic_time[TIME_LAST];
+
+#ifndef DEFINE_HEADER_ONLY
+
+/************** FUNCTION ******************************************/
+
+void *get_idft(int ofdm_symbol_size);
+void *get_dft(int ofdm_symbol_size);
+void init_context_synchro_nr(NR_DL_FRAME_PARMS *frame_parms_ue);
+void free_context_synchro_nr(void);
+void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue);
+void free_context_pss_nr(void);
+int set_pss_nr(int ofdm_symbol_size);
+int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change);
+int pss_search_time_nr(int **rxdata, ///rx data in time domain
+                       NR_DL_FRAME_PARMS *frame_parms,
+                       int *eNB_id);
+
+#endif
+#undef EXTERN
+
+#endif /* PSS_NR_H */
+
+
diff --git a/openair1/PHY/NR_REFSIG/refsig_defs_ue.h b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h
new file mode 100644
index 0000000000000000000000000000000000000000..2d4db86ef9bcf3bfb9538bfe57a883da290ef866
--- /dev/null
+++ b/openair1/PHY/NR_REFSIG/refsig_defs_ue.h
@@ -0,0 +1,53 @@
+/*
+ * 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
+ */
+
+/* Definitions for LTE Reference signals */
+/* Author R. Knopp / EURECOM / OpenAirInterface.org */
+#ifndef __NR_REFSIG_DEFS__H__
+#define __NR_REFSIG_DEFS__H__
+#include "PHY/defs_nr_UE.h"
+
+
+/*!\brief This function generates the NR Gold sequence (38-211, Sec 5.2.1) for the PBCH DMRS.
+@param PHY_VARS_NR_UE* ue structure provides configuration, frame parameters and the pointers to the 32 bits sequence storage tables
+ */
+int nr_pbch_dmrs_rx(unsigned int *nr_gold_pbch,	int32_t *output	);
+
+/*int nr_pdsch_dmrs_rx(PHY_VARS_NR_UE *ue,
+						unsigned int ncp,
+						unsigned int Ns,
+						unsigned int nr_gold_pdsch[2][20][2][21],
+						int32_t *output,
+						unsigned short p,
+						int length_dmrs,
+						unsigned short nb_pdsch_rb);*/
+
+void nr_gold_pbch(PHY_VARS_NR_UE* ue);
+
+void nr_gold_pdsch(PHY_VARS_NR_UE* ue,
+					unsigned short lbar,
+					unsigned int nr_gold_pdsch[2][20][2][21],
+					unsigned int Nid_cell,
+					unsigned short *n_idDMRS,
+					unsigned short length_dmrs);
+
+
+#endif
diff --git a/openair1/PHY/NR_REFSIG/ss_pbch_nr.h b/openair1/PHY/NR_REFSIG/ss_pbch_nr.h
new file mode 100644
index 0000000000000000000000000000000000000000..e230d8035b86d49120f0812cd62cb6c0ef2027be
--- /dev/null
+++ b/openair1/PHY/NR_REFSIG/ss_pbch_nr.h
@@ -0,0 +1,81 @@
+/*
+ * 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
+ */
+
+/**********************************************************************
+*
+* FILENAME    :  ss_pbch_nr.h
+*
+* MODULE      : this file contains define only
+*
+* DESCRIPTION : define elements related to SS/PBCH block ie synchronisation (pss/sss) and pbch
+*
+*               see TS 38.211  7.4.2 Synchronisation Signals
+*               see TS 38.213  4 Synchronisation procedures
+*
+************************************************************************/
+
+#ifndef SS_PBCH_NR_H
+#define SS_PBCH_NR_H
+
+/************** DEFINE ********************************************/
+
+#define VOID_PARAMETER                (void)   /* avoid a compiler warning for unused parameters of function */
+
+/* PSS parameters */
+#define  NUMBER_PSS_SEQUENCE          (3)
+#define  INVALID_PSS_SEQUENCE         (NUMBER_PSS_SEQUENCE)
+#define  LENGTH_PSS_NR                (127)
+#define  N_SC_RB                      (12)     /* Resource block size in frequency domain expressed as a number if subcarriers */
+#define  SCALING_PSS_NR               (3)
+#define  SCALING_CE_PSS_NR            (13)     /* scaling channel estimation based on ps */
+#define  PSS_IFFT_SIZE                (256)
+
+#define  PSS_SC_START_NR              (52)     /* see from TS 38.211 table 7.4.3.1-1: Resources within an SS/PBCH block for PSS... */
+
+/* define ofdm symbol offset in the SS/PBCH block of NR synchronisation */
+#define  PSS_SYMBOL_NB                (0)     /* symbol numbers for each element */
+#define  PBCH_SYMBOL_NB               (1)
+#define  SSS_SYMBOL_NB                (2)
+#define  PBCH_LAST_SYMBOL_NB          (3)
+
+/* SS/PBCH parameters */
+#define  N_RB_SS_PBCH_BLOCK           (20)
+#define  NB_SYMBOLS_PBCH              (3)
+
+#define  IQ_SIZE                      (sizeof(int16_t) * 2)        /* I and Q are alternatively stored into buffers */
+#define  N_SYMB_SLOT                  (14)
+
+/* SS/PBCH parameters :  see from TS 38.211 table 7.4.3.1-1: Resources within an SS/PBCH block for PSS... */
+#define  DMRS_PBCH_PER_RB             (N_SC_RB >> 4)               /* at 0+v, 4+v, 8+v for a resource block with v = NcellID modulo 4 */
+#define  DMRS_END_FIRST_PART          (44)
+#define  DMRS_START_SECOND_PART       (192)
+#define  DMRS_END_SECOND_PART         (236)
+#define  DMRS_PBCH_NUMBER             (NB_SYMBOLS_PBCH*(N_RB_SS_PBCH_BLOCK * DMRS_PBCH_PER_RB))    /* there are both PBCH and SSS/(Set to 0) at the second OFDM symbol of SS/PBCH so size is increased */
+
+/* see TS 38211 7.4.1.4 Demodulation reference signals for PBCH */
+#define  DMRS_PBCH_I_SSB              (8)         /* maximum index value for SSB/PBCH which can have alength of L=4 or L=8 */
+#define  DMRS_PBCH_N_HF               (2)         /* half frame indication - 0 for first part of frame and 1 for second part of frame */
+#define  DMRS_ALIGNMENT_32_BIT        (20)        /* it is just for ensuring a 32 bits alignment for storing dmrs pbch into a 32 bits map */
+#define  DMRS_BITMAP_SIZE             ((DMRS_PBCH_NUMBER-DMRS_ALIGNMENT_32_BIT)/32)   /* size is divided by 32 (to get bitmap on uint32) DMRS_PBCH_NUMBER should be a multiple of 32 */
+
+#endif /* SS_PBCH_NR_H */
+
+
diff --git a/openair1/PHY/NR_REFSIG/sss_nr.h b/openair1/PHY/NR_REFSIG/sss_nr.h
new file mode 100644
index 0000000000000000000000000000000000000000..fb16bb1ca4d430191e6d99983774174af3cfb403
--- /dev/null
+++ b/openair1/PHY/NR_REFSIG/sss_nr.h
@@ -0,0 +1,107 @@
+/*
+ * 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
+ */
+
+/***********************************************************************
+*
+* FILENAME    :  sss_nr.h
+*
+* MODULE      :  Secondary synchronisation signal
+*
+* DESCRIPTION :  variables related to sss
+*
+************************************************************************/
+
+#ifndef SSS_NR_H
+#define SSS_NR_H
+
+#include "PHY/defs_nr_UE.h"
+#include "PHY/types.h"
+
+#include "pss_nr.h"
+
+#ifdef DEFINE_VARIABLES_SSS_NR_H
+#define EXTERN
+#define INIT_VARIABLES_SSS_NR_H
+#else
+#define EXTERN  extern
+#endif
+
+/************** DEFINE ********************************************/
+
+#define  INT_MIN	   (-2147483647 - 1)
+#define  SAMPLES_IQ                   (sizeof(int16_t)*2)
+#define  NUMBER_SSS_SEQUENCE          (336)
+#define  INVALID_SSS_SEQUENCE         (NUMBER_SSS_SEQUENCE)
+#define  LENGTH_SSS_NR                (127)
+#define  SCALING_METRIC_SSS_NR        (19)
+
+#define  N_ID_2_NUMBER                (NUMBER_PSS_SEQUENCE)
+#define  N_ID_1_NUMBER                (NUMBER_SSS_SEQUENCE)
+
+#define  GET_NID2(Nid_cell)           (Nid_cell%3)
+#define  GET_NID1(Nid_cell)           (Nid_cell/3)
+
+#define  PSS_SC_START_NR              (52)     /* see from TS 38.211 table 7.4.3.1-1: Resources within an SS/PBCH block for PSS... */
+
+/************** VARIABLES *****************************************/
+
+#define PHASE_HYPOTHESIS_NUMBER       (7)
+#define INDEX_NO_PHASE_DIFFERENCE     (3)          /* this is for no phase shift case */
+
+EXTERN const int16_t phase_re_nr[PHASE_HYPOTHESIS_NUMBER]
+#ifdef INIT_VARIABLES_SSS_NR_H
+= {16383, 25101, 30791, 32767, 30791, 25101, 16383}
+#endif
+;
+
+EXTERN const int16_t phase_im_nr[PHASE_HYPOTHESIS_NUMBER]
+#ifdef INIT_VARIABLES_SSS_NR_H
+= {-28378, -21063, -11208, 0, 11207, 21062, 28377};
+#endif
+;
+
+EXTERN int16_t d_sss[N_ID_2_NUMBER][N_ID_1_NUMBER][LENGTH_SSS_NR];
+
+/************** FUNCTION ******************************************/
+
+void init_context_sss_nr(int amp);
+void free_context_sss_nr(void);
+
+void insert_sss_nr(int16_t *sss_time,
+                   NR_DL_FRAME_PARMS *frame_parms);
+
+int pss_ch_est_nr(PHY_VARS_NR_UE *ue,
+                  int32_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR],
+                  int32_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR]);
+
+int _do_pss_sss_extract_nr(PHY_VARS_NR_UE *ue,
+                           int32_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR],
+                           int32_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR],
+                           uint8_t doPss, uint8_t doSss,
+					       uint8_t subframe);
+
+int rx_sss_nr(PHY_VARS_NR_UE *ue, int32_t *tot_metric, uint8_t *phase_max);
+
+#undef INIT_VARIABLES_SSS_NR_H
+#undef EXTERN
+
+#endif /* SSS_NR_H */
+
diff --git a/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.c b/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.c
new file mode 100644
index 0000000000000000000000000000000000000000..1a64c8902c9ad89038a9a73e0b92bdf1cdd81e73
--- /dev/null
+++ b/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.c
@@ -0,0 +1,234 @@
+/*
+ * 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
+ */
+
+/***********************************************************************
+*
+* FILENAME    :  ul_ref_seq_nr.c
+*
+* MODULE      :  generation of uplink reference sequence for nr
+*
+* DESCRIPTION :  function to generate uplink reference sequences
+*                see 3GPP TS 38.211 5.2.2 Low-PAPR sequence generation
+*
+************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "defs.h"
+
+#define DEFINE_VARIABLES_LOWPAPR_SEQUENCES_NR_H
+#include "PHY/NR_REFSIG/ul_ref_seq_nr.h"
+#undef DEFINE_VARIABLES_LOWPAPR_SEQUENCES_NR_H
+
+/*******************************************************************
+*
+* NAME :         base_sequence_less_3_RB
+*
+* PARAMETERS :   M_ZC length of Zadoff Chu sequence
+*                u sequence group number
+*                scaling to apply
+*
+* RETURN :       pointer to generated sequence
+*
+* DESCRIPTION :  base sequence generation of less than 36 elements
+*                see TS 38.211 5.2.2.2 Base sequences of length less than 36
+*
+*********************************************************************/
+
+int16_t *base_sequence_less_than_36(unsigned int M_ZC, unsigned int u, unsigned int scaling)
+{
+  char *phi_table;
+  int16_t *rv_overbar;
+  double x;
+  unsigned int n;
+
+  switch(M_ZC) {
+    case 6:
+      phi_table = (char *)phi_M_ZC_6;
+      break;
+    case 12:
+      phi_table = (char *)phi_M_ZC_12;
+      break;
+    case 18:
+      phi_table = (char *)phi_M_ZC_18;
+      break;
+    case 24:
+      phi_table = (char *)phi_M_ZC_24;
+      break;
+    case 30:
+      break;
+    default:
+      printf("function base_sequence_less_than 36_: unsupported base sequence size : %d \n", M_ZC);
+      assert(0);
+      break;
+  }
+
+  rv_overbar = malloc16(IQ_SIZE*M_ZC);
+
+  if (rv_overbar == NULL) {
+    msg("Fatal memory allocation problem \n");
+    assert(0);
+  }
+
+  if (M_ZC == 30) {
+    for (n=0; n<M_ZC; n++) {
+      x = -(M_PI * (u + 1) * (n + 1) * (n + 2))/(double)31;
+      rv_overbar[2*n]   =(int16_t)(floor(scaling*cos(x)));
+      rv_overbar[2*n+1] =(int16_t)(floor(scaling*sin(x)));
+    }
+  }
+  else {
+    for (n=0; n<M_ZC; n++) {
+      x = (double)phi_table[n + u*M_ZC] * (M_PI/4);
+      rv_overbar[2*n]   = (int16_t)(floor(scaling*cos(x)));
+      rv_overbar[2*n+1] = (int16_t)(floor(scaling*sin(x)));
+    }
+  }
+  return rv_overbar;
+}
+
+/*******************************************************************
+*
+* NAME :         base_sequence_36_or_larger
+*
+* PARAMETERS :   M_ZC length of Zadoff chu sequence
+*                u sequence group number
+*                scaling to apply
+*
+* RETURN :       pointer to generated sequence
+*
+* DESCRIPTION :  base sequence generation of less than 36 elements
+*                5.2.2.1 Base sequences of length 36 or larger
+*
+*********************************************************************/
+
+int16_t *base_sequence_36_or_larger(unsigned int Msc_RS, unsigned int u, unsigned int v, unsigned int scaling)
+{
+  int16_t *rv_overbar;
+  unsigned int N_ZC;
+  double q_overbar, x;
+  unsigned int q,m,n;
+  unsigned int M_ZC = ul_allocated_re[Msc_RS];
+
+  rv_overbar = malloc16(IQ_SIZE*M_ZC);
+  if (rv_overbar == NULL) {
+    msg("Fatal memory allocation problem \n");
+    assert(0);
+  }
+
+  N_ZC = ref_ul_primes[Msc_RS]; /* The length N_ZC is given by the largest prime number such that N_ZC < M_ZC */
+
+  q_overbar = N_ZC * (u+1)/(double)31;
+
+  /*  q = (q_overbar + 1/2) + v.(-1)^(2q_overbar) */
+  if ((((int)floor(2*q_overbar))&1) == 0)
+    q = (int)(floor(q_overbar+.5)) - v;
+  else
+    q = (int)(floor(q_overbar+.5)) + v;
+
+  for (n = 0; n < M_ZC; n++) {
+    m=n%N_ZC;
+    x = (double)q * m * (m+1)/N_ZC;
+    rv_overbar[2*n]   =  (int16_t)(floor(scaling*cos(M_PI*x)));   /* cos(-x) = cos(x) */
+    rv_overbar[2*n+1] = -(int16_t)(floor(scaling*sin(M_PI*x)));   /* sin(-x) = -sin(x) */
+  }
+  return rv_overbar;
+}
+
+/*******************************************************************
+*
+* NAME :         generate_ul_srs_sequences
+*
+* PARAMETERS :   scaling to apply
+*
+* RETURN :       none
+*
+* DESCRIPTION :  uplink reference signal sequences generation
+*                which are Low-PAPR base sequences
+*                see TS 38.211 5.2.2 Low-PAPR sequence generation
+*
+*********************************************************************/
+
+void generate_ul_reference_signal_sequences(unsigned int scaling)
+{
+	unsigned int u,v,Msc_RS;
+
+#if 0
+
+    char output_file[255];
+    char sequence_name[255];
+
+#endif
+
+  for (Msc_RS=0; Msc_RS <= INDEX_SB_LESS_32; Msc_RS++) {
+	v = 0;
+    for (u=0; u < U_GROUP_NUMBER; u++) {
+      rv_ul_ref_sig[u][v][Msc_RS] = base_sequence_less_than_36(ul_allocated_re[Msc_RS], u, scaling);
+#if 0
+      sprintf(output_file, "rv_seq_%d_%d_%d.m", u, v, ul_allocated_re[Msc_RS]);
+      sprintf(sequence_name, "rv_seq_%d_%d_%d.m", u, v, ul_allocated_re[Msc_RS]);
+      printf("u %d Msc_RS %d allocate memory %x of size %d \n", u, Msc_RS, rv_ul_ref_sig[u][v][Msc_RS], (IQ_SIZE* ul_allocated_re[Msc_RS]));
+      write_output(output_file, sequence_name,  rv_ul_ref_sig[u][v][Msc_RS], ul_allocated_re[Msc_RS], 1, 1);
+
+#endif
+    }
+  }
+
+  for (Msc_RS=INDEX_SB_LESS_32+1; Msc_RS < SRS_SB_CONF; Msc_RS++) {
+    for (u=0; u < U_GROUP_NUMBER; u++) {
+      for (v=0; v < V_BASE_SEQUENCE_NUMBER; v++) {
+        rv_ul_ref_sig[u][v][Msc_RS] = base_sequence_36_or_larger(Msc_RS, u, v, scaling);
+#if 0
+        sprintf(output_file, "rv_seq_%d_%d_%d.m", u, v, ul_allocated_re[Msc_RS]);
+        sprintf(sequence_name, "rv_seq_%d_%d_%d.m", u, v, ul_allocated_re[Msc_RS]);
+        printf("u %d Msc_RS %d allocate memory %x of size %d \n", u, Msc_RS, rv_ul_ref_sig[u][v][Msc_RS], (IQ_SIZE* ul_allocated_re[Msc_RS]));
+        write_output(output_file, sequence_name,  rv_ul_ref_sig[u][v][Msc_RS], ul_allocated_re[Msc_RS], 1, 1);
+
+#endif
+      }
+    }
+  }
+}
+
+/*******************************************************************
+*
+* NAME :         free_ul_reference_signal_sequences
+*
+* PARAMETERS :   none
+*
+* RETURN :       none
+*
+* DESCRIPTION :  free of uplink reference signal sequences
+*
+*********************************************************************/
+void free_ul_reference_signal_sequences(void)
+{
+  unsigned int u,v,Msc_RS;
+  for (Msc_RS=0; Msc_RS < SRS_SB_CONF; Msc_RS++) {
+    for (u=0; u < U_GROUP_NUMBER; u++) {
+      for (v=0; v < V_BASE_SEQUENCE_NUMBER; v++) {
+        if (rv_ul_ref_sig[u][v][Msc_RS])
+          free16(rv_ul_ref_sig[u][v][Msc_RS],2*sizeof(int16_t)*ul_allocated_re[Msc_RS]);
+      }
+    }
+  }
+}
diff --git a/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.h b/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.h
new file mode 100644
index 0000000000000000000000000000000000000000..dd967e8e5e6339478c9287bd1b352c2654042e36
--- /dev/null
+++ b/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.h
@@ -0,0 +1,271 @@
+/*
+ * 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
+ */
+
+/***********************************************************************
+*
+* FILENAME    :  ul_ref_seq_nr.hh
+*
+* MODULE      :  generation of uplink reference sequence for nr
+*
+* DESCRIPTION :  variables to generate sequences with low peak to average power
+*                see 3GPP TS 38.211 5.2.2 Low-PAPR sequence generation
+*
+************************************************************************/
+
+#ifndef LOWPAPR_SEQUENCES_NR_H
+#define LOWPAPR_SEQUENCES_NR_H
+
+#include "PHY/defs_nr_UE.h"
+#include "PHY/types.h"
+
+#include "PHY/NR_REFSIG/ss_pbch_nr.h"
+
+#ifdef DEFINE_VARIABLES_LOWPAPR_SEQUENCES_NR_H
+#define EXTERN
+#define INIT_VARIABLES_LOWPAPR_SEQUENCES_NR_H
+#else
+#define EXTERN  extern
+#endif
+
+/************** DEFINE ********************************************/
+#define U_GROUP_NUMBER               (30)    /* maximum number of sequence-group */
+#define V_BASE_SEQUENCE_NUMBER       (2)     /* maximum number of base sequences */
+#define SRS_SB_CONF                  (71)    /* maximum number of configuration for srs subcarrier allocation */
+
+/************** VARIABLES *****************************************/
+
+#define   INDEX_SB_LESS_32            (4)    /* index of dftsizes array for which subcarrier number is less than 36 */
+
+const uint16_t ul_allocated_re[SRS_SB_CONF]     /* number of uplink allocated resource elements */
+/* this table is derivated from TS 38.211 Table 6.4.1.4.3-1: SRS bandwidth configuration which gives m_SRS_b then all possible values of sequence length is */
+/* M_sc_b_SRS = m_SRS_b * N_SC_RB/K_TC with K_TC = 2 or K_TC = 4  as specified in TS 38.211 6.4.1.4.3 */
+#ifdef INIT_VARIABLES_LOWPAPR_SEQUENCES_NR_H
+= { /*
+K_TC               3           3           3     3     3     3     3     3     3     3     3     3     3     3     3     3     3     3     3     3
+m_SRS_b            4           8          12    16    20    24    28    32    36    40    44    48    52    56    60    64    68    72    76    80   */
+             6,   12,   18,   24,   30,   36,   48,   60,   72,   84,   96,  108,  120,  132,  144,  156,  168,  180,  192,  204,  216,  228,  240,
+/*
+K_TC         3     3     3     3     3     3     3     3     3     3     3    3      3     3     3     3     3     3     3     3     6     3     3
+m_SRS_b     84    88    92    96   100   104   108   112   116   120   128   132   136   144   152   160   168   176   184   192   100   208   216   */
+           252,  264,  276,  288,  300,  312,  324,  336,  348,  360,  384,  396,  408,  432,  456,  480,  504,  528,  552,  576,  600,  624,  648,
+/*
+K_TC         3     6     3     3     3     3     6     6     6     6     6     6     6     6     6     6     6     6     6     6
+m_SRS_b    224   116,  240   256   264   272   144   152   160   168   176   184   192   208   216   224   240   256   264   272                     */
+           672,  696,  720,  768,  792,  816,  864,  912,  960, 1008, 1056, 1104, 1152, 1248, 1296, 1344, 1440, 1536, 1584, 1632,
+
+/* below numbers have been added just to include all possible lengths already used for lte */
+           540,  900,  972, 1080, 1200,
+}
+#endif
+;
+
+/* table of largest prime number lower than uplink allocated resource elements "ul_allocated_re" */
+const uint16_t ref_ul_primes[SRS_SB_CONF]
+#ifdef INIT_VARIABLES_LOWPAPR_SEQUENCES_NR_H
+= {
+/*           6,   12,   18,   24,   30,   36,   48,   60,   72,   84,   96,  108,  120,  132,  144,  156,  168,  180,  192,  204,  216,  228,  240,  */
+             5,   11,   17,   23,   29,   31,   47,   59,   71,   83,   89,  107,  113,  127,  139,  151,  167,  179,  191,  199,  211,  227,  239,
+
+/*         252,  264,  276,  288,  300,  312,  324,  336,  348,  360,  384,  396,  408,  432,  456,  480,  504,  528,  552,  576,  600,  624,  648,  */
+           251,  263,  271,  283,  293,  311,  317,  331,  347,  359,  383,  389,  401,  431,  449,  479,  503,  523,  547,  571,  599,  619,  647,
+
+/*         672,  696,  720,  768,  792,  816,  864,  912,  960, 1008, 1056, 1104, 1152, 1248, 1296, 1344, 1440, 1536, 1584, 1632,                    */
+           661,  691,  719,  761,  787,  811,  863,  911,  953,  997, 1051, 1103, 1151, 1237, 1291, 1327, 1439, 1531, 1583, 1627,
+
+/*         540,  900,  972, 1080, 1200,                                                                                                              */
+           523,  887,  971, 1069, 1193,
+}
+#endif
+;
+
+/* Low-PAPR base sequence; see TS 38.211 clause 5.2.2 */
+int16_t  *rv_ul_ref_sig[U_GROUP_NUMBER][V_BASE_SEQUENCE_NUMBER][SRS_SB_CONF];
+
+/* 38.211 table Table 5.2.2.2-1: Definition of phi(n) for M_ZC = 6 */
+const char phi_M_ZC_6[6*U_GROUP_NUMBER]
+#ifdef INIT_VARIABLES_LOWPAPR_SEQUENCES_NR_H
+= {
+/*        0   1   2   3   4   5  */
+/*  0 */ -3, -1,  3,  3, -1, -3,
+/*  1 */ -3,  3, -1, -1,  3, -3,
+/*  2 */ -3, -3, -3,  3,  1, -3,
+/*  3 */  1,  1,  1,  3, -1, -3,
+/*  4 */  1,  1,  1, -3, -1,  3,
+/*  5 */ -3,  1, -1, -3, -3, -3,
+/*  6 */ -3,  1,  3, -3, -3, -3,
+/*  7 */ -3, -1,  1, -3,  1, -1,
+/*  8 */ -3, -1, -3,  1, -3, -3,
+/*  9 */ -3, -3,  1, -3,  3, -3,
+/* 10 */ -3,  1,  3,  1, -3, -3,
+/* 11 */ -3, -1, -3,  1,  1, -3,
+/* 12 */  1,  1,  3, -1, -3,  3,
+/* 13 */  1,  1,  3,  3, -1,  3,
+/* 14 */  1,  1,  1, -3,  3, -1,
+/* 15 */ -1,  1,  1, -1,  3, -3,
+/* 16 */ -3, -1, -1, -1,  3, -1,
+/* 17 */ -3, -3, -1,  1, -1, -3,
+/* 18 */ -3, -3, -3,  1, -3, -1,
+/* 19 */ -3,  1,  1, -3, -1, -3,
+/* 20 */ -3,  3, -3,  1,  1, -3,
+/* 21 */ -3,  1, -3, -3, -3, -1,
+/* 22 */  1,  1, -3,  3,  1,  3,
+/* 23 */  1,  1, -3, -3,  1, -3,
+/* 24 */  1,  1,  3, -1,  3,  3,
+/* 25 */  1,  1, -3,  1,  3,  3,
+/* 26 */  1,  1, -1, -1,  3, -1,
+/* 27 */  1,  1, -1,  3, -1, -1,
+/* 28 */  1,  1, -1,  3, -3, -1,
+/* 29 */  1,  1, -3,  1, -1, -1,
+}
+#endif
+;
+/* Table 5.2.2.2-2: Definition of phi ( n ) for M ZC = 12  */
+const char phi_M_ZC_12[12*U_GROUP_NUMBER]
+#ifdef INIT_VARIABLES_LOWPAPR_SEQUENCES_NR_H
+= {
+/*        0   1   2   3   4   5   6   7   8   9  10  11  */
+/* 0  */  1, -1,  3,  1,  1, -1, -1, -1,  1,  3, -3,  1,
+/* 1  */ -1, -1, -1, -1,  1, -3, -1,  3,  3, -1, -3,  1,
+/* 2  */ -3,  1, -3, -3, -3,  3, -3, -1,  1,  1,  1, -3,
+/* 3  */ -3,  3,  1,  3, -3,  1,  1,  1,  1,  3, -3,  3,
+/* 4  */ -3,  1,  3, -1, -1, -3, -3, -1, -1,  3,  1, -3,
+/* 5  */ -1,  1,  1, -1,  1,  3,  3, -1, -1, -3,  1, -3,
+/* 6  */ -3, -3, -1,  3,  3,  3, -3,  3, -3,  1, -1, -3,
+/* 7  */ -3,  3, -3,  3,  3, -3, -1, -1,  3,  3,  1, -3,
+/* 8  */ -3, -1, -3, -1, -1, -3,  3,  3, -1, -1,  1, -3,
+/* 9  */ -3,  3,  3,  3, -1, -3, -3, -1, -3,  1,  3, -3,
+/* 10 */  1,  3, -3,  1,  3,  3,  3,  1, -1,  1, -1,  3,
+/* 11 */ -1, -3,  3, -1, -3, -3, -3, -1,  1, -1,  1, -3,
+/* 12 */  3,  1,  3,  1,  3, -3, -1,  1,  3,  1, -1, -3,
+/* 13 */ -3, -3,  3,  3,  3, -3, -1,  1, -3,  3,  1, -3,
+/* 14 */ -3, -1,  1, -3,  1,  3,  3,  3, -1, -3,  3,  3,
+/* 15 */ -3, -3,  3,  1, -3, -3, -3, -1,  3, -1,  1,  3,
+/* 16 */ -1,  1,  3, -3,  1, -1,  1, -1, -1, -3,  1, -1,
+/* 17 */ -3, -1, -1,  1,  3,  1,  1, -1,  1, -1, -3,  1,
+/* 18 */ -3, -1,  3, -3, -3, -1, -3,  1, -1, -3,  3,  3,
+/* 19 */ -3, -3,  3, -3, -1,  3,  3,  3, -1, -3,  1, -3,
+/* 20 */ -3,  1, -1, -1,  3,  3, -3, -1, -1, -3, -1, -3,
+/* 21 */ -3,  1,  3,  3, -1, -1, -3,  3,  3, -3,  3, -3,
+/* 22 */ -3, -1, -1, -3, -3, -1, -3,  3,  1,  3, -1, -3,
+/* 23 */ -3, -1,  3,  1, -3, -1, -3,  3,  1,  3,  3,  1,
+/* 24 */ -3,  3,  3,  1, -3,  3, -1,  1,  3, -3,  3, -3,
+/* 25 */  3, -1, -3,  3, -3, -1,  3,  3,  3, -3, -1, -3,
+/* 26 */  1, -1,  3, -1, -1, -1, -3, -1,  1,  1,  1, -3,
+/* 27 */ -3,  3,  1, -3,  1,  3, -1, -1,  1,  3,  3,  3,
+/* 28 */ -3,  3, -3,  3, -3, -3,  3, -1, -1,  1,  3, -3,
+/* 29 */ -3,  3,  1, -1,  3,  3, -3,  1, -1,  1, -1,  1,
+}
+#endif
+;
+
+/* Table 5.2.2.2-3: Definition of phi (n ) for M_ZC = 18 */
+const char phi_M_ZC_18[18*U_GROUP_NUMBER]
+#ifdef INIT_VARIABLES_LOWPAPR_SEQUENCES_NR_H
+= {
+/*          0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17 */
+/* 0   */   3, -3,  3, -1,  1,  3, -3, -1, -3, -3, -1, -3,  3,  1, -1,  3, -3,  3,
+/* 1   */   3, -3,  1,  1,  3, -1,  1, -1, -1, -3,  1,  1, -1,  3,  3, -3,  3, -1,
+/* 2   */  -3,  3, -1, -3, -1, -3,  1,  1, -3, -3, -1, -1,  3, -3,  1,  3,  1,  1,
+/* 3   */   1,  1, -1, -1, -3, -1,  1, -3, -3, -3,  1, -3, -1, -1,  1, -1,  3,  1,
+/* 4   */   1,  1, -3,  3,  3,  1,  3, -3,  3, -1,  1,  1, -1,  1, -3, -3, -1,  3,
+/* 5   */  -3, -3,  1, -3,  3,  3,  3, -1,  3,  1,  1, -3, -3, -3,  3, -3, -1, -1,
+/* 6   */  -1,  3, -1, -3,  3,  1, -3, -1,  3, -3, -1, -1,  1,  1,  1, -1, -1, -1,
+/* 7   */  -3,  1, -3, -3,  1, -3, -3,  3,  1, -3, -1, -3, -3, -3, -1,  1,  1,  3,
+/* 8   */   1, -3, -1, -3,  3,  3, -1, -3,  1, -3, -3, -1, -3, -1,  1,  3,  3,  3,
+/* 9   */  -3,  3,  1, -1, -1, -1, -1,  1, -1,  3,  3, -3, -1,  1,  3, -1,  3, -1,
+/* 10  */  -3, -3,  1, -1, -1,  1,  1, -3, -1,  3,  3,  3,  3, -1,  3,  1,  3,  1,
+/* 11  */  -3, -3,  3,  3, -3,  1,  3, -1, -3,  1, -1, -3,  3, -3, -1, -1, -1,  3,
+/* 12  */  -3, -3,  3,  3,  3,  1, -3,  1,  3,  3,  1, -3, -3,  3, -1, -3, -1,  1,
+/* 13  */  -3,  3, -1,  1,  3,  1, -3, -1,  1,  1, -3,  1,  3,  3, -1, -3, -3, -3,
+/* 14  */  -3,  1, -3, -1, -1,  3,  1, -3, -3, -3, -1, -3, -3,  1,  1,  1, -1, -1,
+/* 15  */  -3, -3,  3,  3,  3, -1, -1, -3, -1, -1, -1,  3,  1, -3, -3, -1,  3, -1,
+/* 16  */  -3, -1,  3,  3, -1,  3, -1, -3, -1,  1, -1, -3, -1, -1, -1,  3,  3,  1,
+/* 17  */  -3, -1, -3, -1, -3,  1,  3, -3, -1,  3,  3,  3,  1, -1, -3,  3, -1, -3,
+/* 18  */  -3,  3,  1, -1, -1,  3, -3, -1,  1,  1,  1,  1,  1, -1,  3, -1, -3, -1,
+/* 19  */   3, -1, -3,  1, -3, -3, -3,  3,  3, -1,  1, -3, -1,  3,  1,  1,  3,  3,
+/* 20  */   3,  3,  3, -3, -1, -3, -1,  3, -1,  1, -1, -3,  1, -3, -3, -1,  3,  3,
+/* 21  */   3, -1,  3,  1, -3, -3, -1,  1, -3, -3,  3,  3,  3,  1,  3, -3,  3, -3,
+/* 22  */  -3,  1,  1, -3,  1,  1,  3, -3, -1, -3, -1,  3, -3,  3, -1, -1, -1, -3,
+/* 23  */  -3, -1, -1, -3,  1, -3,  3, -1, -1, -3,  3,  3, -3, -1,  3, -1, -1, -1,
+/* 24  */  -3, -3, -3,  1, -3,  3,  1,  1,  3, -3, -3,  1,  3, -1,  3, -3, -3,  3,
+/* 25  */   1,  1, -3, -3, -3, -3,  1,  3, -3,  3,  3,  1, -3, -1,  3, -1, -3,  1,
+/* 26  */   3, -1, -1,  1, -3, -1, -3, -1, -3, -3, -1, -3,  1,  1,  1, -3, -3,  3,
+/* 27  */   3,  1, -3,  1, -3,  3,  3, -1, -3, -3, -1, -3, -3,  3, -3, -1,  1,  3,
+/* 28  */  -1, -3,  1, -3, -3, -3,  1,  1,  3,  3, -3,  3,  3, -3, -1,  3, -3,  1,
+/* 29  */  -3, -1, -3, -3,  1,  1, -1, -3, -1, -3, -1, -1,  3,  3, -1,  3,  1,  3,
+}
+#endif
+;
+
+/* Table 5.2.2.2-4: Definition of phi (n ) for M_ZC = 24 */
+const char phi_M_ZC_24[24*U_GROUP_NUMBER]
+#ifdef INIT_VARIABLES_LOWPAPR_SEQUENCES_NR_H
+= {
+/*          0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23 */
+/* 0   */  -1, -3,  3,  1,  1, -3,  1, -3, -3,  1, -3, -1, -1,  3, -3,  3,  3,  3, -3,  1,  3,  3, -3, -3,
+/* 1   */  -1, -3,  3, -1,  3,  1,  3, -1,  1, -3, -1, -3, -1,  1,  3, -3, -1, -3,  3,  3,  3, -3, -3, -3,
+/* 2   */  -3,  3,  1,  3, -1,  1, -3,  1, -3,  1, -1, -3, -1, -3, -3, -3, -3, -1, -1, -1,  1,  1, -3, -3,
+/* 3   */   3, -1,  3, -1,  1, -3,  1,  1, -3, -3,  3, -3, -1, -1, -1, -1, -1, -3, -3, -1,  1,  1, -3, -3,
+/* 4   */   1, -3,  3, -1, -3, -1,  3,  3,  1, -1,  1,  1,  3, -3, -1, -3, -3, -3, -1,  3, -3, -1, -3, -3,
+/* 5   */   3, -1,  1, -1,  3, -3,  1,  1,  3, -1, -3,  3,  1, -3,  3, -1, -1, -1, -1,  1, -3, -3, -3, -3,
+/* 6   */  -3,  3, -1,  3,  1, -1, -1, -1,  3,  3,  1,  1,  1,  3,  3,  1, -3, -3, -1,  1, -3,  1,  3, -3,
+/* 7   */  -3, -1,  1, -3, -3,  1,  1, -3,  3, -1, -1, -3,  1,  3,  1, -1, -3, -1, -3,  1, -3, -3, -3, -3,
+/* 8   */  -3,  1, -3,  1, -3, -3,  1, -3,  1, -3, -3, -3, -3, -3,  1, -3, -3,  1,  1, -3,  1,  1, -3, -3,
+/* 9   */   3, -3, -3, -1,  3,  3, -3, -1,  3,  1,  1,  1,  3, -1,  3, -3, -1,  3, -1,  3,  1, -1, -3, -3,
+/* 10  */  -3, -3, -1, -1, -1, -3,  1, -1, -3, -1,  3, -3,  1, -3,  3, -3,  3,  3,  1, -1, -1,  1, -3, -3,
+/* 11  */  -3, -3,  3,  3,  1, -1, -1, -1,  1, -3, -1,  1, -1,  3, -3, -1, -3, -1, -1,  1, -3,  3, -1, -3,
+/* 12  */  -3, -3,  1, -1,  3,  3, -3, -1,  1, -1, -1,  1,  1, -1, -1,  3, -3,  1, -3,  1, -1, -1, -1, -3,
+/* 13  */  -3,  1, -3,  3, -1, -1, -1, -3,  3,  1, -1, -3, -1,  1,  3, -1,  1, -1,  1, -3, -3, -3, -3, -3,
+/* 14  */  -3, -3, -3, -1,  3, -3,  3,  1,  3,  1, -3, -1, -1, -3,  1,  1,  3,  1, -1, -3,  3,  1,  3, -3,
+/* 15  */   1,  1, -1, -3, -1,  1,  1, -3,  1, -1,  1, -3,  3, -3, -3,  3, -1, -3,  1,  3, -3,  1, -3, -3,
+/* 16  */  -3,  3, -1,  3, -1,  3,  3,  1,  1, -3,  1,  3, -3,  3, -3, -3, -1,  1,  3, -3, -1, -1, -3, -3,
+/* 17  */  -1, -3, -3,  1, -1, -1, -3,  1,  3, -1, -3, -1, -1, -3,  1,  1,  3,  1, -3, -1, -1,  3, -3, -3,
+/* 18  */  -3,  1, -3,  1, -3,  1,  1,  3,  1, -3, -3, -1,  1,  3, -1, -3,  3,  1, -1, -3, -3, -3, -3, -3,
+/* 19  */   3, -3,  3, -1, -3,  1,  3,  1, -1, -1, -3, -1,  3, -3,  3, -1, -1,  3,  3, -3, -3,  3, -3, -3,
+/* 20  */  -1,  3, -3, -3, -1,  3, -1, -1,  1,  3,  1,  3, -1, -1, -3,  1,  3,  1, -1, -3,  1, -1, -3, -3,
+/* 21  */  -3,  1, -3, -1, -1,  3,  1,  3, -3,  1, -1,  3,  3, -1, -3,  3, -3, -1, -1, -3, -3, -3,  3, -3,
+/* 22  */  -3, -1, -1, -3,  1, -3, -3, -1, -1,  3, -1,  1, -1,  3,  1, -3, -1,  3,  1,  1, -1, -1, -3, -3,
+/* 23  */  -3,  1, -3,  3, -3,  1, -3,  3,  1, -1, -3, -1, -3, -3, -3, -3,  1,  3, -1,  1,  3,  3,  3, -3,
+/* 24  */  -3, -1,  1, -3, -1, -1,  1,  1,  1,  3,  3, -1,  1, -1,  1, -1, -1, -3, -3, -3,  3,  1, -1, -3,
+/* 25  */   3, -3, -1,  1,  3, -1, -1, -3, -1,  3, -1, -3, -1, -3,  3, -1,  3,  1,  1, -3,  3, -3, -3, -3,
+/* 26  */  -3,  1,  3, -1,  1, -1,  3, -3,  3, -1, -3, -1, -3,  3, -1, -1, -1, -3, -1, -1, -3,  3,  3, -3,
+/* 27  */  -3,  3, -1, -3, -1, -1, -1,  3, -1, -1,  3, -3, -1,  3, -3,  3, -3, -1,  3,  1,  1, -1, -3, -3,
+/* 28  */  -3,  1, -1, -3, -3, -1,  1, -3, -1, -3,  1,  1, -1,  1,  1,  3,  3,  3, -1,  1, -1,  1, -1, -3,
+/* 29  */  -1,  3, -1, -1,  3,  3, -1, -1, -1,  3, -1, -3,  1,  3,  1,  1, -3, -3, -3, -1, -3, -1, -3, -3,
+}
+#endif
+;
+/************** FUNCTION ******************************************/
+
+int16_t *base_sequence_36_or_larger(unsigned int M_ZC, unsigned int u, unsigned int v, unsigned int scaling);
+int16_t *base_sequence_less_than_36(unsigned int M_ZC, unsigned int u, unsigned int scaling);
+/*!
+\brief This function generate the sounding reference symbol (SRS) for the uplink.
+@param tables of srs
+@param scaling amplitude of the reference signal
+*/
+void generate_ul_reference_signal_sequences(unsigned int scaling);
+void free_ul_reference_signal_sequences(void);
+
+#undef INIT_VARIABLES_LOWPAPR_SEQUENCES_NR_H
+#undef EXTERN
+
+#endif /* SSS_NR_H */
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c
new file mode 100644
index 0000000000000000000000000000000000000000..5ebfd5a05c241dc0ab8e332acff71176944548de
--- /dev/null
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c
@@ -0,0 +1,132 @@
+/*
+ * 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.c
+* \brief Implements DCI encoding/decoding (38.212/38.213/38.214). 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"
+
+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)
+{
+  uint8_t size = 0;
+  uint16_t N_RB = bwp->N_RB;
+
+  switch(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 --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
+      break;
+
+    case nr_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
+      // UL/SUL indicator
+      // BWP Indicator
+      // Freq domain assignment
+      // Time domain assignment
+      // VRB to PRB mapping
+      // Frequency Hopping flag
+      // 1st DAI
+      // 2nd DAI
+      // SRS resource indicator
+      // Precoding info and number of layers
+      // Antenna ports
+      // CSI request
+      // CBGTI
+      // PTRS - DMRS association
+      // beta offset indicator
+      // DMRS sequence init
+      break;
+
+    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
+      // Time domain assignment
+      break;
+
+    case nr_dci_format_1_1:
+      // Carrier indicator
+      size += 1; // Format identifier
+      // BWP Indicator
+      // Freq domain assignment
+      // Time domain assignment
+      // VRB to PRB mapping
+      // PRB bundling size indicator
+      // Rate matching indicator
+      // ZP CSI-RS trigger
+        /// TB1- MCS 5, NDI 1, RV 2
+      size += 8;
+      // TB2
+      size += 4 ;  // HARQ PID
+      // DAI
+      size += 2; // TPC PUCCH
+      size += 3; // PUCCH resource indicator
+      size += 3; // PDSCH to HARQ timing indicator
+      // Antenna ports
+      // Tx Config Indication
+      size += 2; // SRS request
+      // CBGTI
+      // CBGFI
+      size += 1; // DMRS sequence init
+      
+      break;
+
+    case nr_dci_format_2_0:
+      break;
+
+    case nr_dci_format_2_1:
+      break;
+
+    case nr_dci_format_2_2:
+      break;
+
+    case nr_dci_format_2_3:
+      break;
+
+  default:
+    AssertFatal(1==0, "Invalid NR DCI format %d\n", format);
+  }
+
+  return size;
+}
+
+
+uint8_t nr_generate_dci_top()
+{
+  return 0;
+}
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h
new file mode 100644
index 0000000000000000000000000000000000000000..a1a58e6598577c371ab9e9714908f286c1821a9b
--- /dev/null
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h
@@ -0,0 +1,74 @@
+/*
+ * 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 __PHY_NR_TRANSPORT_DCI__H
+#define __PHY_NR_TRANSPORT_DCI__H
+
+#include "defs_gNB.h"
+
+
+typedef enum {
+  nr_dci_format_0_0=0,
+  nr_dci_format_0_1,
+  nr_dci_format_1_0,
+  nr_dci_format_1_1,
+  nr_dci_format_2_0,
+  nr_dci_format_2_1,
+  nr_dci_format_2_2,
+  nr_dci_format_2_3
+} nr_dci_format_e;
+
+typedef enum {
+  nr_rnti_type_SI_RNTI=0,
+  nr_rnti_type_RA_RNTI,
+  nr_rnti_type_C_RNTI,
+  nr_rnti_type_TC_RNTI,
+  nr_rnti_type_CS_RNTI,
+  nr_rnti_type_P_RNTI
+} nr_rnti_type_e;
+
+
+
+typedef struct {
+  /// Length of DCI in bits
+  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
+  nr_rnti_type_e rnti;
+  /// Format
+  DCI_format_t format;
+  /// DCI pdu
+  uint8_t dci_pdu[8];
+} NR_DCI_ALLOC_t;
+
+
+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);
+
+uint8_t nr_generate_dci_top();
+
+#endif //__PHY_NR_TRANSPORT_DCI__H
diff --git a/openair1/PHY/NR_TRANSPORT/nr_pdcch.c b/openair1/PHY/NR_TRANSPORT/nr_pdcch.c
new file mode 100644
index 0000000000000000000000000000000000000000..469c0472a5bf4304aa4c34742b9ec1aaa60166a7
--- /dev/null
+++ b/openair1/PHY/NR_TRANSPORT/nr_pdcch.c
@@ -0,0 +1,35 @@
+/*
+ * 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/PHY/NR_UE_ESTIMATION/filt16a_32.h b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h
new file mode 100644
index 0000000000000000000000000000000000000000..a37a591d2f57d3f79439fc85c9e42bbb9e28ee05
--- /dev/null
+++ b/openair1/PHY/NR_UE_ESTIMATION/filt16a_32.h
@@ -0,0 +1,86 @@
+short filt16a_l0[16] = {
+16384,12288,8192,4096,0,0,0,0,0,0,0,0,0,0,0,0};
+
+short filt16a_r0[16] = {
+0,0,0,0,0,4096,8192,12288,16384,20480,24576,28672,0,0,0,0};
+
+short filt16a_m0[16] = {
+0,4096,8192,12288,16384,12288,8192,4096,0,-4096,-8192,-12288,0,0,0,0};
+
+short filt16a_l1[16] = {
+20480,16384,12288,8192,4096,0,0,0,0,0,0,0,0,0,0,0};
+
+short filt16a_r1[16] = {
+0,0,0,0,0,0,4096,8192,12288,16384,20480,24576,0,0,0,0};
+
+short filt16a_m1[16] = {
+-4096,0,4096,8192,12288,16384,12288,8192,4096,0,-4096,-8192,0,0,0,0};
+
+short filt16a_l2[16] = {
+24576,20480,16384,12288,8192,4096,0,0,0,0,0,0,0,0,0,0};
+
+short filt16a_r2[16] = {
+0,0,0,0,0,0,0,4096,8192,12288,16384,20480,0,0,0,0};
+
+short filt16a_m2[16] = {
+-8192,-4096,0,4096,8192,12288,16384,12288,8192,4096,0,-4096,0,0,0,0};
+
+short filt16a_l3[16] = {
+28672,24576,20480,16384,12288,8192,4096,0,0,0,0,0,0,0,0,0};
+
+short filt16a_r3[16] = {
+0,0,0,0,0,0,0,0,4096,8192,12288,16384,0,0,0,0};
+
+short filt16a_m3[16] = {
+-12288,-8192,-4096,0,4096,8192,12288,16384,12288,8192,4096,0,0,0,0,0};
+
+short filt16a_l0_dc[16] = {
+16384,12288,8192,4096,0,0,0,0,0,0,0,0,0,0,0,0};
+
+short filt16a_r0_dc[16] = {
+0,0,0,0,0,3276,9830,13107,16384,19660,22937,26214,0,0,0,0};
+
+short filt16a_m0_dc[16] = {
+0,4096,8192,12288,16384,13107,6553,3276,0,-3277,-6554,-9831,0,0,0,0};
+
+short filt16a_l1_dc[16] = {
+16384,12288,8192,4096,0,-4096,0,0,0,0,0,0,0,0,0,0};
+
+short filt16a_r1_dc[16] = {
+0,0,0,0,0,0,6553,9830,13107,16384,19660,22937,0,0,0,0};
+
+short filt16a_m1_dc[16] = {
+-4096,0,4096,8192,12288,16384,9830,6553,3276,0,-3277,-6554,0,0,0,0};
+
+short filt16a_l2_dc[16] = {
+26214,22937,19660,16384,13107,9830,6553,0,0,0,0,0,0,0,0,0};
+
+short filt16a_r2_dc[16] = {
+0,0,0,0,0,0,0,4096,8192,12288,16384,20480,0,0,0,0};
+
+short filt16a_m2_dc[16] = {
+-6554,-3277,0,3276,6553,6553,16384,12288,8192,4096,0,-4096,0,0,0,0};
+
+short filt16a_l3_dc[16] = {
+26214,22937,19660,16384,13107,9830,3276,0,0,0,0,0,0,0,0,0};
+
+short filt16a_r3_dc[16] = {
+0,0,0,0,0,0,0,0,4096,8192,12288,16384,0,0,0,0};
+
+short filt16a_m3_dc[16] = {
+-9831,-6554,-3277,0,3276,6553,9830,16384,12288,8192,4096,0,0,0,0,0};
+
+short filt16a_1[16] = {
+16384,16384,16384,16384,16384,16384,16384,16384,16384,16384,16384,16384};
+
+short filt16a_2l0[16] = {
+16384,12288,8192,4096,-4096,0,0,0,0,0,0,0,0,0,0,0};
+
+short filt16a_2r0[16] = {
+0,4096,8192,12288,16384,20480,0,0,0,0,0,0,0,0,0,0};
+
+short filt16a_2l1[16] = {
+20480,16384,12288,8192,4096,0,0,0,0,0,0,0,0,0,0,0};
+
+short filt16a_2r1[16] = {
+-4096,0,4096,8192,12288,16384,0,0,0,0,0,0,0,0,0,0};
diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d262e845851e396e3ff1e305d7ace48f1615356
--- /dev/null
+++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
@@ -0,0 +1,258 @@
+/*
+ * 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
+ */
+
+#ifdef USER_MODE
+#include <string.h>
+#endif
+//#include "defs.h"
+//#include "SCHED/defs.h"
+#include "PHY/defs_nr_UE.h"
+#include "filt16a_32.h"
+#include "T.h"
+#define DEBUG_CH
+
+int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
+                              uint8_t eNB_id,
+                              uint8_t eNB_offset,
+                              unsigned char Ns,
+                              unsigned char p,
+                              unsigned char l,
+                              unsigned char symbol)
+{
+  int pilot[2][200] __attribute__((aligned(16)));
+  unsigned char aarx;
+  unsigned short k;
+  unsigned int pilot_cnt;
+  int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*f2l,*fr,f1,*f2r,*fl_dc,*fm_dc,*fr_dc;
+  int ch_offset,symbol_offset;
+
+  uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1];
+
+  uint8_t nushift;
+  uint8_t previous_thread_id = ue->current_thread_id[Ns>>1]==0 ? (RX_NB_TH-1):(ue->current_thread_id[Ns>>1]-1);
+  int **dl_ch_estimates         =ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].dl_ch_estimates[eNB_offset];
+  int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].rxdataF;
+
+
+  // recompute nushift with eNB_offset corresponding to adjacent eNB on which to perform channel estimation
+  nushift =  Nid_cell%4;
+
+  if (ue->high_speed_flag == 0) // use second channel estimate position for temporary storage
+    ch_offset     = ue->frame_parms.ofdm_symbol_size ;
+  else
+    ch_offset     = ue->frame_parms.ofdm_symbol_size*symbol;
+
+  symbol_offset = ue->frame_parms.ofdm_symbol_size*symbol;
+
+  k = nushift;
+
+#ifdef DEBUG_CH
+  printf("PBCH Channel Estimation : ThreadId %d, eNB_offset %d cell_id %d ch_offset %d, OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n",ue->current_thread_id[Ns>>1], eNB_offset,Nid_cell,ch_offset,ue->frame_parms.ofdm_symbol_size,
+         ue->frame_parms.Ncp,l,Ns,k, symbol);
+#endif
+
+  switch (k) {
+  case 0:
+        fl = filt16a_l0;
+        fm = filt16a_m0;
+        fr = filt16a_r0;
+        fl_dc = filt16a_l0;
+        fm_dc = filt16a_m0;
+        fr_dc = filt16a_r0;
+        f1 = filt16a_1;
+        f2l = filt16a_2l0;
+        f2r = filt16a_2r0;
+        break;
+
+  case 1:
+        fl = filt16a_l1;
+        fm = filt16a_m1;
+        fr = filt16a_r1;
+        fl_dc = filt16a_l1;
+        fm_dc = filt16a_m1;
+        fr_dc = filt16a_r1;
+        f1 = filt16a_1;
+        f2l = filt16a_2l1;
+        f2r = filt16a_2r1;
+        break;
+
+  case 2:
+        fl = filt16a_l2;
+        fm = filt16a_m2;
+        fr = filt16a_r2;
+        fl_dc = filt16a_l2;
+        fm_dc = filt16a_m2;
+        fr_dc = filt16a_r2;
+        f1 = filt16a_1;
+        f2l = filt16a_2l0;
+        f2r = filt16a_2r0;
+        break;
+
+  case 3:
+        fl = filt16a_l3;
+        fm = filt16a_m3;
+        fr = filt16a_r3;
+        fl_dc = filt16a_l3;
+        fm_dc = filt16a_m3;
+        fr_dc = filt16a_r3;
+        f1 = filt16a_1;
+        f2l = filt16a_2l1;
+        f2r = filt16a_2r1;
+        break;
+
+  default:
+    msg("pbch_channel_estimation: k=%d -> ERROR\n",k);
+    return(-1);
+    break;
+  }
+
+
+
+  // generate pilot
+  nr_pbch_dmrs_rx(ue->nr_gold_pbch,
+					  &pilot[p][0]);
+
+  for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
+
+    pil   = (int16_t *)&pilot[p][0];
+    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+(ue->frame_parms.ofdm_symbol_size-10*12))];
+    dl_ch = (int16_t *)&dl_ch_estimates[(p<<1)+aarx][ch_offset];
+
+    memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size));
+    if (ue->high_speed_flag==0) // multiply previous channel estimate by ch_est_alpha
+      multadd_complex_vector_real_scalar(dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
+                                         ue->ch_est_alpha,dl_ch-(ue->frame_parms.ofdm_symbol_size<<1),
+                                         1,ue->frame_parms.ofdm_symbol_size);
+#ifdef DEBUG_CH
+    printf("ch est pilot addr %p RB_DL %d\n",&pilot[p][0], ue->frame_parms.N_RB_DL);
+    printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset);
+    printf("rxF addr %p\n", rxF);
+    printf("dl_ch addr %p\n",dl_ch);
+#endif
+    if ((ue->frame_parms.N_RB_DL&1)==0) {
+
+      // Treat first 2 pilots specially (left edge)
+      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
+      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
+#ifdef DEBUG_CH
+      printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1]));
+      printf("pilot 0 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
+#endif
+      multadd_real_vector_complex_scalar(fl,
+                                         ch,
+                                         dl_ch,
+                                         16);
+      pil+=2;
+      rxF+=8;
+      for (int i= 0; i<8; i++)
+      printf("dl_ch addr %p %d\n", dl_ch+i, *(dl_ch+i));
+
+      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
+      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
+#ifdef DEBUG_CH
+      printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
+#endif
+      multadd_real_vector_complex_scalar(fm,
+                                         ch,
+                                         dl_ch,
+                                         16);
+      //printf("after dl_ch %d %d\n", dl_ch, *(dl_ch));
+      //for (int i= 0; i<16; i++)
+      //      printf("dl_ch %d %d\n", dl_ch+i, *(dl_ch+i));
+
+      pil+=2;
+      rxF+=8;
+
+      ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
+      ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
+
+      #ifdef DEBUG_CH
+            printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
+      #endif
+
+      multadd_real_vector_complex_scalar(fr,
+                                         ch,
+                                         dl_ch,
+                                         16);
+      pil+=2;
+      rxF+=8;
+      dl_ch+=24;
+
+      for (pilot_cnt=3; pilot_cnt<(3*20); pilot_cnt+=3) {
+
+	if (pilot_cnt == 30)
+	  rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k)];
+
+        ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
+        ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
+#ifdef DEBUG_CH
+	//printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
+#endif
+        multadd_real_vector_complex_scalar(fl,
+                                           ch,
+                                           dl_ch,
+                                           16);
+
+        //for (int i= 0; i<8; i++)
+        //            printf("pilot_cnt %d dl_ch %d %d\n", pilot_cnt, dl_ch+i, *(dl_ch+i));
+
+        pil+=2;
+        rxF+=8;
+  
+        ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
+        ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
+#ifdef DEBUG_CH
+	//printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
+#endif
+        multadd_real_vector_complex_scalar(fm,
+                                           ch,
+                                           dl_ch,
+                                           16);
+        pil+=2;
+        rxF+=8;
+
+        ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
+        ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
+
+        #ifdef DEBUG_CH
+	// printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
+        #endif
+
+        multadd_real_vector_complex_scalar(fr,
+                                           ch,
+                                           dl_ch,
+                                           16);
+        pil+=2;
+        rxF+=8;
+        dl_ch+=24;
+
+      }
+
+
+    }
+
+    printf("finish dl_ch addr %p\n", dl_ch);
+
+  }
+
+  return(0);
+}
+
diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h
new file mode 100644
index 0000000000000000000000000000000000000000..7ec222727b7381fb22d742c05487f69b61bb214d
--- /dev/null
+++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h
@@ -0,0 +1,60 @@
+/*
+ * 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 __LTE_ESTIMATION_DEFS__H__
+#define __LTE_ESTIMATION_DEFS__H__
+
+
+#include "PHY/defs_nr_UE.h"
+#include "PHY/defs_gNB.h"
+/** @addtogroup _PHY_PARAMETER_ESTIMATION_BLOCKS_
+ * @{
+ */
+
+/*!\brief Timing drift hysterisis in samples*/
+#define SYNCH_HYST 2
+
+/*!
+\brief This function performs channel estimation including frequency and temporal interpolation
+\param phy_vars_ue Pointer to UE PHY variables
+\param eNB_id Index of target eNB
+\param eNB_offset Offset for interfering eNB (in terms cell ID mod 3)
+\param Ns slot number (0..19)
+\param p antenna port
+\param l symbol within slot
+\param symbol symbol within frame
+*/
+int nr_dl_channel_estimation(PHY_VARS_NR_UE *ue,
+                              uint8_t eNB_id,
+                              uint8_t eNB_offset,
+                              unsigned char Ns,
+                              unsigned char p,
+                              unsigned char l,
+                              unsigned char symbol);
+
+int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
+                              uint8_t eNB_id,
+                              uint8_t eNB_offset,
+                              unsigned char Ns,
+                              unsigned char p,
+                              unsigned char l,
+                              unsigned char symbol);
+#endif
diff --git a/openair1/PHY/NR_UE_TRANSPORT/cic_filter_nr.c b/openair1/PHY/NR_UE_TRANSPORT/cic_filter_nr.c
new file mode 100644
index 0000000000000000000000000000000000000000..98248d02dd523267629419a48d87a9f73d605b3c
--- /dev/null
+++ b/openair1/PHY/NR_UE_TRANSPORT/cic_filter_nr.c
@@ -0,0 +1,578 @@
+/*
+ * 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
+ */
+
+/**********************************************************************
+*
+* FILENAME    :  cic_filter_nr.c
+*
+* MODULE      :  generic functions for cic filters
+*
+* DESCRIPTION :  generic functions useful for decimation based on cascaded integrator comb filter
+*
+************************************************************************/
+
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+#include <math.h>
+
+#include "PHY/defs_nr_UE.h"
+
+#define DEFINE_VARIABLES_CIC_FILTER_NR_H
+#include "PHY/NR_UE_TRANSPORT/cic_filter_nr.h"
+#undef DEFINE_VARIABLES_CIC_FILTER_NR_H
+
+/*******************************************************************
+*
+* NAME :         integrator_stage
+*
+* PARAMETERS :   pointer to input complex data
+*                pointer to output complex data
+*
+* RETURN :
+*
+* DESCRIPTION :  single stage of an integrator
+*
+*                It is a single-pole IIR filter with a unity feedback coefficient
+*
+*                y(n) = y(n-1) +x(n)*
+*
+*********************************************************************/
+
+void integrator_stage(int32_t *input, int32_t *output, int length)
+{
+  /* first sample is just copied */
+  for (int i = 0; i < 1; i++) {
+    output[2*i]   = input[2*i];
+    output[2*i+1] = input[2*i+1];
+  }
+
+  /* then process all other samples */
+  for (int i = 1; i < length; i++) {
+    output[2*i]   = output[2*(i-1)]   + input[2*i];
+    output[2*i+1] = output[2*(i-1)+1] + input[2*i+1];
+
+#ifdef DBG_CIC_FILTER_NR
+    if (i < 20) {
+      printf("output[%d] = output[%d]    + input[%d] \n", (2*i), 2*(i-1), 2*i);
+      printf("%d         =    %d         + %d \n", output[2*i], output[2*(i-1)], input[2*i]);
+    }
+#endif
+  }
+}
+
+/*******************************************************************
+*
+* NAME :         comb_stage
+*
+* PARAMETERS :   pointer to input complex data
+*                pointer to output complex data
+*
+* RETURN :
+*
+* DESCRIPTION :  single stage of a comb filter which is an odd-symetric FIR filter
+*
+*                y(n) = x(n) - x(n - M)
+*
+*                M is called the differential delay. It can take any positive
+*                integer but it is usually limited to 1 or 2.
+*
+*********************************************************************/
+
+void comb_stage(int32_t *input, int32_t *output, int length, int differential_delay)
+{
+  /* first sample is just copied */
+  for (int i = 0; i < differential_delay; i++) {
+    output[2*i]   = input[2*i];
+	output[2*i+1] = input[2*i+1];
+  }
+
+  /* then process all other samples */
+  for (int i = differential_delay; i < length; i++) {
+    output[2*i]   = input[2*i]   - input[2*(i-differential_delay)];
+    output[2*i+1] = input[2*i+1] - input[2*(i-differential_delay)+1];
+
+#ifdef DBG_CIC_FILTER_NR
+    if (i < 20) {
+      printf("output[%d] = input[%d]    - input[%d] \n", (2*i), (2*i), 2*(i-differential_delay));
+      printf("%d         =    %d        - %d \n", output[2*i], input[2*i], input[2*(i-differential_delay)]);
+    }
+#endif
+  }
+}
+
+/*******************************************************************
+*
+* NAME :         rate_change_stage
+*
+* PARAMETERS :   pointer to input complex data
+*                pointer to output complex data
+*
+* RETURN :       none
+*
+* DESCRIPTION :  change sampling rate by a factor of R
+*                just copy one samples over R from input to output buffer
+*
+*********************************************************************/
+
+void rate_change_stage(int32_t *input, int32_t *output, int length, int rate_change)
+{
+  for (int i = 0; (i*rate_change) < length; i++) {
+    output[2*i]   = input[2*i*rate_change];
+    output[2*i+1] = input[(2*i*rate_change)+1];
+
+#ifdef DBG_CIC_FILTER_NR
+    if (i < 20) {
+      printf("input[%d] : %d \n", 2*i*rate_change, input[2*i*rate_change]);
+      printf("output[%d] : %d \n", 2*i, output[2*i]);
+    }
+#endif
+  }
+}
+
+/*******************************************************************
+*
+* NAME :         fir_filter
+*
+* PARAMETERS :   pointer to input complex data
+*                pointer to output complex data
+*
+* RETURN :       none
+*
+* DESCRIPTION :  implement a fir filter with taps from an array
+*
+*********************************************************************/
+
+void fir_filter_init(fir_filter_t* f, int taps_fir_number, int32_t *filter_taps) {
+  int i;
+  for(i = 0; i < taps_fir_number; ++i)
+    f->history[i] = 0;
+  f->last_index = 0;
+  if (taps_fir_number > MAX_SAMPLEFILTER_TAP_NUM) {
+    printf("Number of taps of this FIR filter %d exceeds maximum value %d \n", taps_fir_number, MAX_SAMPLEFILTER_TAP_NUM);
+    assert(0);
+  }
+  f->filter_tap_number = taps_fir_number;
+  f->filter_taps = filter_taps;
+}
+
+void fir_filter_put(fir_filter_t* f, int32_t input) {
+  f->history[f->last_index++] = input;
+  if(f->last_index == f->filter_tap_number)
+    f->last_index = 0;
+}
+
+int32_t fir_filter_get(fir_filter_t* f, int scaling_shift) {
+  long long acc = 0;
+  int index = f->last_index, i;
+  for(i = 0; i < f->filter_tap_number; ++i) {
+    index = index != 0 ? index-1 : f->filter_tap_number-1;
+    acc += (long long)f->history[index] * f->filter_taps[i];
+  };
+  return acc >> scaling_shift;
+}
+
+void fir_filter_basic(int32_t *input, int32_t *output, int length, int taps_fir_number, int32_t *filter_taps, int scaling_shift)
+{
+  fir_filter_t filter;
+
+  for (int j = 0; j < 2; j++) {
+
+    fir_filter_init(&filter, taps_fir_number, filter_taps);
+
+    for (int i = 0; i < length; i++) {
+      fir_filter_put(&filter, input[2*i+j]);
+      output[2*i+j] = fir_filter_get(&filter, scaling_shift);
+      //printf("i %d input %d output %d ", 2*i+j, input[2*i+j], output[2*i + j]);
+    }
+  }
+}
+
+/*******************************************************************
+*
+* NAME :         fir_filter
+*
+* PARAMETERS :   pointer to input complex data
+*                pointer to output complex data
+*
+* RETURN :
+*
+* DESCRIPTION :  single stage of a fir filter which is an odd-symetric FIR filter
+*
+*                y(n) = SUM ( bi * x(n - i) )
+*
+*                bi are tags of FIR filter
+*
+*********************************************************************/
+
+void fir_filter(int32_t *input, int32_t *output, int length, int taps_fir_number, int *taps_fir, int scaling_shift)
+{
+  int32_t current;
+
+  /* taps start from 1 to taps_fir_number */
+  for (int i = 0; i < taps_fir_number; i++) {
+    for (int j=0; j<2 ; j++) {
+      current = 0;
+      for (int taps_number = 0; taps_number < taps_fir_number; taps_number++) {
+        if (i >= taps_number) {
+          current += taps_fir[taps_number]*input[2*(i-taps_number)+j];
+#ifdef DBG_CIC_FILTER_NR
+          printf("current[%d] %d = taps[%d] : %d x input[%d] : %d \n", (2*i+j), current, taps_number, taps_fir[taps_number], (2*(i-taps_number)+j), input[2*(i-taps_number)+j]);
+#endif
+        }
+      }
+      output[2*i+j] = current >> scaling_shift;
+    }
+  }
+
+  for (int i = taps_fir_number; i < length; i++) {
+    for (int j=0; j<2 ; j++) {
+      current = 0;
+      for (int taps_number = 0; taps_number < taps_fir_number; taps_number++) {
+        current += taps_fir[taps_number]*input[2*(i-taps_number)+j];
+#ifdef DBG_CIC_FILTER_NR
+        if (i < taps_fir_number + 16) {
+          printf("current[%d] %d = taps[%d] : %d x input[%d] : %d \n", (2*i+j), current, taps_number, taps_fir[taps_number], (2*(i-taps_number)+j), input[2*(i-taps_number)+j]);
+        }
+#endif
+      }
+      output[2*i+j] = current >> scaling_shift; // SHARPENED_FIR_SCALING_ACC;
+    }
+  }
+}
+
+/*******************************************************************
+*
+* NAME :         cic_decimator
+*
+* PARAMETERS :   pointer to input complex data
+*                pointer to output complex data
+*                length size of input buffer
+*                decimation by a factor of R
+*
+* RETURN :       result of decimator is the output buffer
+*
+* DESCRIPTION :  Cascaded integrator-comb filter
+*                rate change by a factor of R
+*
+*                CIC filter with N stages is composed of:
+*                - N cascaded integrator filters clocked at high sampling rate fs
+*                - N cascaded comb stage running at fs/R
+*
+*              +-----------+  +----------+  +----------+  +----+  +----------+  +----------+  +----------+         +--------------+
+*              | Integrator|  |Integrator|  |Integrator|  |  R |  |   Comb   |  |   Comb   |  |   Comb   |         | Compensation |
+*    input --->|   stage   |->|   stage  |->| stage    |->|    |->|   stage  |->|   stage  |->|   stage  |-------->|   FIR Filter |---> output
+*              +-----------+  +----------+  +----------+  +----+  +----------+  +----------+  +----------+         +--------------+
+*             <---------------------------------------->    |      <-------------------------------------->
+*                   N cascaded integrator filters           |        N cascaded comb stage running at fs/R
+*                 clocked at high sampling rate fs          V
+*                                                        downsampling
+*                                                      from fs to fs/R
+*
+* In order that cic filter works properly, some caution should be taken for getting good accuracy.
+* Firstly data should be in fixed point in order to balance integrator and comb stages. If does not work with data in floating point.
+*
+* k1 is the number of significant bits for input
+* k2 is the number of significant bits for output
+* m = k2 - k2 > N * log2(RM - 1)   N number of stage, M differential delay and R rate change factor
+* for example with R=16  N=4 and M=1 with input data on 16 bits
+* output data should be on k2 = m + k1 > 31
+*
+* Additionally there is a bit growth so processing has a gain of
+* G = (RM)power(N)
+* For example with R=16 N=4 M=1  G=(16*1)power(4)=65536
+*
+* It gives size of output data with number of significant bit Bout = (N x log2(R x M)) + Bin
+* With R=16 N=4 M=1 Bin=16 => Bout = (4 x log2(16 x 1)) + 16 = (4 x 4) + 16 = 32 so output significant bits should be 32.
+* As a consequence, all computations are done with 32 bits up to the last stage (no rounding or truncation).
+* Except for the final result which can be casted from 32 bits to 16 bits.
+*
+*********************************************************************/
+
+void cic_decimator(int16_t *input_buffer, int16_t *output_buffer, int length, int rate_change, int number_cic_stage, int set_scaling_factor, int fir_rate_change)
+{
+  int32_t *buffer_one;
+  int32_t *buffer_two;
+  int32_t *input;
+  int32_t *output;
+  int32_t *tmp;
+  int new_length;
+  int current_rate_change;
+
+  /* for cic decimator, gain g of the output depends on rate change R, differential delay M and number of stage N */
+  /* g = power(R x M, N) / power(2 , log2 (R x M)  */
+  /* so a scale factor should be applied to output in order to get a unity DC gain */
+
+  int scaling_factor =  0; // pow(2, log2(rate_change * M_DIFFERENTIAL_DELAY))/pow((rate_change * M_DIFFERENTIAL_DELAY), number_cic_stage);
+
+  if (set_scaling_factor != 0) {
+    scaling_factor = set_scaling_factor;
+    printf("Decimation with rate change of %d with set gain of %d \n", rate_change, scaling_factor);
+  }
+
+  /* get working buffers */
+  buffer_one = malloc(length*sizeof(int32_t) * 2);   /* for i&q samples */
+  if (buffer_one == NULL) {
+     msg("Fatal memory allocation problem \n");
+     assert(0);
+  }
+
+  buffer_two = malloc(length*sizeof(int32_t) * 2);  /* for i&q samples */
+  if (buffer_two == NULL) {
+    msg("Fatal memory allocation problem \n");
+    assert(0);
+  }
+
+  /* copy of input buffer from int16 to int32 */
+  for (int i = 0; i < length; i++) {
+    buffer_one[2*i]     = input_buffer[2*i];
+    buffer_one[2*i + 1] = input_buffer[2*i + 1];
+
+#ifdef DBG_CIC_FILTER_NR
+    if (i < 10) {
+      printf("buffer_one[%d] : %d %d \n", i, buffer_one[2*i], buffer_one[2*i + 1]);
+    }
+#endif
+  }
+
+  input = buffer_one;
+  output = buffer_two;
+
+  /* call of integrator stages running at Fs */
+  for (int stage = 0; stage < number_cic_stage; stage++)
+  {
+    integrator_stage(input, output, length);
+
+    /* swap between output and input */
+    tmp = input;
+    input = output;
+    output = tmp;
+
+#if 0
+    char output_file[255];
+    char sequence_name[255];
+    sprintf(output_file, "int_seq_%d.m", stage);
+    sprintf(sequence_name, "int_seq_%d", stage);
+
+    printf("file %s signal %s\n", output_file, sequence_name);
+    write_output(output_file, sequence_name, input, length, 1, 3); /* format = 3 is for int32_t */
+#endif
+  }
+
+  /* a sharpened Fir filter can be added which can provide also a rate change */
+  current_rate_change = rate_change/fir_rate_change;
+
+  /* rate change from sampling frequency Fs to Fs/R */
+  rate_change_stage(input, output, length, current_rate_change);
+
+  /* new length of samples should be computed based on the rate change factor R */
+  new_length = length/current_rate_change;
+
+  /* swap between output and input */
+  tmp = input;
+  input = output;
+  output = tmp;
+
+  /* call of comb stages running at Fs/R */
+  for (int stage = 0; stage < number_cic_stage; stage++)
+  {
+    comb_stage(input, output, new_length, M_DIFFERENTIAL_DELAY);
+
+    /* swap between output and input */
+    tmp = input;
+    input = output;
+    output = tmp;
+
+#if 0
+    char output_file[255];
+    char sequence_name[255];
+    sprintf(output_file, "comb_seq_%d.m", stage);
+    sprintf(sequence_name, "comb_seq_%d", stage);
+    printf("file %s signal %s\n", output_file, sequence_name);
+    write_output(output_file, sequence_name, input, new_length, 1, 3); /* format = 3 for int32_t */
+#endif
+  }
+
+#if 1
+
+  if (fir_rate_change > 1)
+  {
+#define FIR_TAPS_SCALING   (10000)
+
+    /* convert float taps of fir filter to int32 taps */
+    int32_t *filter_taps_fixed_point = malloc(FIR_TAPS_NUMBER*sizeof(int32_t));
+    if (filter_taps_fixed_point == NULL) {
+      msg("Fatal memory allocation problem \n");
+      assert(0);
+    }
+
+    for (int i = 0; i < FIR_TAPS_NUMBER; i++) {
+      filter_taps_fixed_point[i] = (int32_t)(sharpened_fir_taps[i] * FIR_TAPS_SCALING);
+    }
+
+#if 1
+
+    /* compensation filter for equalizing the passband drop and perform a low rate change */
+    fir_filter(input, output, new_length, FIR_TAPS_NUMBER, filter_taps_fixed_point, FIR_FITER_SCALING_ACC);
+
+#else
+
+    fir_filter_basic(input, output, new_length,  FIR_TAPS_NUMBER, filter_taps, SHARPENED_FIR_SCALING_ACC);
+
+#endif
+  }
+  else
+  {
+    output = input;
+  }
+
+  /* new length of samples should be computed based on the rate change */
+  current_rate_change = fir_rate_change;
+  new_length = new_length/current_rate_change;
+
+  /* filter has created a delay on the signal which can be compensated */
+  //int delay = FIR_TAPS_NUMBER;
+  int delay = 0;
+
+  for (int i = 0; (i*fir_rate_change) < new_length; i++) {
+    output_buffer[2*i] = output[(2*i+delay)*current_rate_change]>> scaling_factor;
+    output_buffer[2*i+1] = output[((2*i+delay)*current_rate_change)+1]>> scaling_factor;
+
+#ifdef DBG_CIC_FILTER_NR
+    if (i < 10) {
+      printf("output_buffer[%d] = output[%d] >> scaling_factor \n", (2*i), ((2*i+delay)*current_rate_change));
+      printf("      %d           =     %d     >> %d \n", output_buffer[2*i], output[((2*i+delay)*current_rate_change)], scaling_factor);
+    }
+#endif
+  }
+
+#else
+
+  scaling_factor = 0;
+
+  /* copy of final result from int32 to int16 with a scaling factor and a rate change */
+  for (int i = 0; i < new_length; i++) {
+    output_buffer[2*i] = input[2*i] >> scaling_factor;
+    output_buffer[2*i + 1] = input[2*i + 1] >> scaling_factor;
+
+#ifdef DBG_CIC_FILTER_NR
+    if (i < 10) {
+      printf("output_buffer[%d] : %d \n", (2*i), output_buffer[2*i]);
+      printf("input[%d] : %d \n", 2*i, input[2*i] >> scaling_factor);
+    }
+#endif
+  }
+
+#endif
+
+#if 1
+  /* clear till end of the buffer */
+  for (int i = new_length; i < length; i++) {
+    output_buffer[2*i] = 0;
+    output_buffer[2*i + 1] = 0;
+  }
+#endif
+}
+
+/*******************************************************************
+*
+* NAME :         fir_decimator
+*
+* PARAMETERS :   pointer to input complex data
+*                pointer to output complex data
+*                length size of input buffer
+*                decimation by a factor of R
+*
+* RETURN :       result of decimator is the output buffer
+*
+* DESCRIPTION :  fir filter
+*                rate change by a factor of R
+*
+*
+*********************************************************************/
+
+void fir_decimator(int16_t *input_buffer, int16_t *output_buffer, int length, int rate_change, int scaling_factor)
+{
+  int32_t *buffer_one;
+  int32_t *buffer_two;
+  int32_t *input;
+  int32_t *output;
+  int new_length;
+
+  /* get working buffers */
+  buffer_one = malloc(length*sizeof(int32_t) * 2);   /* for i&q samples */
+  if (buffer_one == NULL) {
+    msg("Fatal memory allocation problem \n");
+    assert(0);
+  }
+
+  buffer_two = malloc(length*sizeof(int32_t) * 2);  /* for i&q samples */
+  if (buffer_two == NULL) {
+    msg("Fatal memory allocation problem \n");
+    assert(0);
+  }
+
+  /* copy of input buffer from int16 to int32 */
+  for (int i = 0; i < length; i++) {
+    buffer_one[2*i]     = input_buffer[2*i];
+    buffer_one[2*i + 1] = input_buffer[2*i + 1];
+  }
+
+  input = buffer_one;
+  output = buffer_two;
+
+#if 1
+
+  fir_filter(input, output, length, SAMPLEFILTER_TAP_NUM, filter_taps, FIR_SCALING_ACC);
+
+#else
+
+  fir_filter_basic(input, output, length,  SAMPLEFILTER_TAP_NUM, filter_taps, FIR_SCALING_ACC);
+
+#endif
+
+  /* rate change from sampling frequency Fs to Fs/R */
+  rate_change_stage(output, input, length, rate_change);
+
+  new_length = length/rate_change;
+
+  /* copy of final result from int32 to int16 with a scaling factor and a rate change */
+  for (int i = 0; i < new_length; i++) {
+    output_buffer[2*i] = input[2*i] >> scaling_factor;
+    output_buffer[2*i + 1] = input[2*i + 1] >> scaling_factor;
+  }
+
+#if 1
+  /* clear till end of the buffer */
+  for (int i = new_length; i < length; i++) {
+    output_buffer[2*i] = 0;
+    output_buffer[2*i + 1] = 0;
+  }
+#endif
+
+}
+
+
+
+
+
+
+
diff --git a/openair1/PHY/NR_UE_TRANSPORT/cic_filter_nr.h b/openair1/PHY/NR_UE_TRANSPORT/cic_filter_nr.h
new file mode 100644
index 0000000000000000000000000000000000000000..74e02731ff2a16dd634761af4afb3e1b9ad1c398
--- /dev/null
+++ b/openair1/PHY/NR_UE_TRANSPORT/cic_filter_nr.h
@@ -0,0 +1,207 @@
+/*
+ * 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
+ */
+
+/**********************************************************************
+*
+* FILENAME    :  cic_filter_nr.h
+*
+* MODULE      :  synchronisation signal
+*
+* DESCRIPTION :  function related to nr synchronisation
+*                It provides filters for sampling decimation
+*
+************************************************************************/
+
+#ifndef CIC_FILTER_NR_H
+#define CIC_FILTER_NR_H
+
+#include "PHY/defs_nr_UE.h"
+#include "PHY/types.h"
+
+#ifdef DEFINE_VARIABLES_CIC_FILTER_NR_H
+#define EXTERN
+#define INIT_VARIABLES_CIC_FILTER_NR_H
+#else
+#define EXTERN  extern
+#endif
+
+/************** DEFINE ********************************************/
+
+#define M_DIFFERENTIAL_DELAY        (1)
+#define FIR_RATE_CHANGE             (2)
+
+/************** VARIABLES *****************************************/
+
+#define FIR_TAPS_NUMBER                 (20)
+#define FIR_FITER_SCALING_ACC           (14)
+
+EXTERN double sharpened_fir_taps[FIR_TAPS_NUMBER]
+#ifdef INIT_VARIABLES_CIC_FILTER_NR_H
+= {
+/*
+cic filter and compensation FIR have been designed based on cic design tools provided at
+http://www.tsdconseil.fr/tutos/index.html
+-->cfir = cic_comp_design(4,4,1,30720000,2,1650000,20);
+R = 4.00, Fin = 30720000.00 Hz, Fout = 7680000.00 Hz.
+Attenuation for f > fout/2 : -14.82 dB.
+Attenuation at 1650000.00 Hz: -0.15 dB.
+Attenuation max. between 0 et 1650000.00 Hz: -0.15 dB.
+E.g. in linear scale : * 0.983
+Number of additionnal bits needed for implementation: 7.
+Fout = 7680000.00 Hz.
+index = 1026 / 4096.
+Correction Fint ?
+Filtre global :
+
+-->cfir
+ cfir  =
+*/
+  - 0.0059900,
+  - 0.0056191,
+    0.0107582,
+    0.0266043,
+    0.0130358,
+  - 0.0331228,
+  - 0.0680440,
+  - 0.0278570,
+    0.1106335,
+    0.2897060,
+    0.3607857,
+    0.2607354,
+    0.0983409,
+  - 0.0243749,
+  - 0.0583235,
+  - 0.0276023,
+    0.0104286,
+    0.0199533,
+    0.0071721,
+  - 0.0028096,
+}
+#endif
+;
+
+#define MAX_SAMPLEFILTER_TAP_NUM  (100)
+#define FIR_SCALING_ACC           (15)
+
+typedef struct {
+  int32_t history[MAX_SAMPLEFILTER_TAP_NUM];
+  int last_index;
+  int filter_tap_number;
+  int32_t *filter_taps;
+} fir_filter_t;
+
+#define SAMPLEFILTER_TAP_NUM       (59)
+
+/*
+ * This low pass filter was designed based on the tool at http://t-filter.engineerjs.com/
+ * with below parameters
+ * sampling frequency 30.72 MHz
+ * from 	to 	          gain 	ripple/att.
+ * 0 Hz     1.9 MHz        1     0.5 dB
+ * 2 MHz     15 MHz        0     -20 dB
+ */
+
+EXTERN int filter_taps[SAMPLEFILTER_TAP_NUM]
+#ifdef INIT_VARIABLES_CIC_FILTER_NR_H
+= {
+  -1572,
+  65,
+  -132,
+  197,
+  26,
+  393,
+  194,
+  536,
+  250,
+  514,
+  105,
+  279,
+  -234,
+  -105,
+  -646,
+  -466,
+  -924,
+  -583,
+  -856,
+  -279,
+  -321,
+  492,
+  639,
+  1601,
+  1812,
+  2766,
+  2872,
+  3650,
+  3503,
+  3976,
+  3503,
+  3650,
+  2872,
+  2766,
+  1812,
+  1601,
+  639,
+  492,
+  -321,
+  -279,
+  -856,
+  -583,
+  -924,
+  -466,
+  -646,
+  -105,
+  -234,
+  279,
+  105,
+  514,
+  250,
+  536,
+  194,
+  393,
+  26,
+  197,
+  -132,
+  65,
+  -1572
+}
+#endif
+;
+
+/************** FUNCTION ******************************************/
+
+void integrator_stage(int32_t *input, int32_t *output, int length);
+
+void comb_stage(int32_t *input, int32_t *output, int length, int differential_delay);
+
+void rate_change_stage(int32_t *input, int32_t *output, int length, int rate_change);
+
+void fir_filter(int32_t *input, int32_t *output, int length, int taps_fir_number, int32_t *taps_fir, int scaling_shift);
+
+void cic_decimator(int16_t *input_buffer, int16_t *output_buffer, int length, int rate_change, int number_cic_stage, int set_scaling_factor, int fir_rate_change);
+
+void fir_decimator(int16_t *input_buffer, int16_t *output_buffer, int length, int rate_change, int scaling_factor);
+
+#undef EXTERN
+#undef INIT_VARIABLES_CIC_FILTER_NR_H
+
+#endif /* CIC_FILTER_NR_H */
+
+
diff --git a/openair1/PHY/NR_UE_TRANSPORT/dmrs_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dmrs_nr.c
new file mode 100644
index 0000000000000000000000000000000000000000..06ccd9459f699be59ae45b12167710c64cbef0d2
--- /dev/null
+++ b/openair1/PHY/NR_UE_TRANSPORT/dmrs_nr.c
@@ -0,0 +1,311 @@
+/*
+ * 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
+ */
+
+/**********************************************************************
+*
+* FILENAME    :  dmrs_nr.c
+*
+* MODULE      :  demodulation reference signals
+*
+* DESCRIPTION :  generation of dmrs sequences
+*                3GPP TS 38.211
+*
+************************************************************************/
+
+//#include "PHY/LTE_REFSIG/defs.h"
+#include "PHY/NR_REFSIG/ss_pbch_nr.h"
+#include "PHY/NR_REFSIG/dmrs_nr.h"
+
+/*******************************************************************
+*
+* NAME :         pseudo_random_gold_sequence
+*
+* PARAMETERS :
+*
+* RETURN :       generate pseudo-random sequence which is a length-31 Gold sequence
+*
+* DESCRIPTION :  3GPP TS 38.211 5.2.1 Pseudo-random sequence generation
+*                Sequence generation is a length-31 Gold sequence
+*
+*********************************************************************/
+
+#define NC                     (1600)
+#define GOLD_SEQUENCE_LENGTH   (31)
+
+int pseudo_random_sequence(int M_PN, uint32_t *c, uint32_t cinit)
+{
+  int n;
+  int size_x =  NC + GOLD_SEQUENCE_LENGTH + M_PN;
+  uint32_t *x1;
+  uint32_t *x2;
+
+  x1 = calloc(size_x, sizeof(uint32_t));
+
+  if (x1 == NULL) {
+    msg("Fatal error: memory allocation problem \n");
+    assert(0);
+  }
+
+  x2 = calloc(size_x, sizeof(uint32_t));
+
+  if (x2 == NULL) {
+    free(x1);
+    msg("Fatal error: memory allocation problem \n");
+    assert(0);
+  }
+
+  x1[0] = 1;  /* init first m sequence */
+
+  /* cinit allows to initialise second m-sequence x2 */
+  for (n = 0; n < GOLD_SEQUENCE_LENGTH; n++) {
+     x2[n] = (cinit >> n) & 0x1;
+  }
+
+  for (n = 0; n < (NC + M_PN); n++) {
+    x1[n+31] = (x1[n+3] + x1[n])%2;
+    x2[n+31] = (x2[n+3] + x2[n+2] + x2[n+1] + x2[n])%2;
+  }
+
+  for (int n = 0; n < M_PN; n++) {
+    c[n] = (x1[n+NC] + x2[n+NC])%2;
+  }
+
+  free(x1);
+  free(x2);
+
+  return 0;
+}
+
+/*******************************************************************
+*
+* NAME :         pseudo_random_sequence_optimised
+*
+* PARAMETERS :
+*
+* RETURN :       generate pseudo-random sequence which is a length-31 Gold sequence
+*
+* DESCRIPTION :  3GPP TS 38.211 5.2.1 Pseudo-random sequence generation
+*                Sequence generation is a length-31 Gold sequence
+*                This is an optimized function based on bitmap variables
+*
+*                x1(0)=1,x1(1)=0,...x1(30)=0,x1(31)=1
+*                x2 <=> cinit, x2(31) = x2(3)+x2(2)+x2(1)+x2(0)
+*                x2 <=> cinit = sum_{i=0}^{30} x2(i)2^i
+*                c(n) = x1(n+Nc) + x2(n+Nc) mod 2
+*
+*                                             equivalent to
+* x1(n+31) = (x1(n+3)+x1(n))mod 2                   <=>      x1(n) = x1(n-28) + x1(n-31)
+* x2(n+31) = (x2(n+3)+x2(n+2)+x2(n+1)+x2(n))mod 2   <=>      x2(n) = x2(n-28) + x2(n-29) + x2(n-30) + x2(n-31)
+*
+*********************************************************************/
+
+void pseudo_random_sequence_optimised(unsigned int size, uint32_t *c, uint32_t cinit)
+{
+  unsigned int n,x1,x2;
+
+  /* init of m-sequences */
+  x1 = 1+ (1<<31);
+  x2 = cinit;
+  x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
+
+  /* skip first 50 double words of uint32_t (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<size; 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);
+    c[n] = x1^x2;
+  }
+}
+
+/*******************************************************************
+*
+* NAME :         lte_gold_new
+*
+* PARAMETERS :
+*
+* RETURN :       generate pseudo-random sequence which is a length-31 Gold sequence
+*
+* DESCRIPTION :  This function is the same as "lte_gold" function in file lte_gold.c
+*                It allows checking that optimization works fine.
+*                generated sequence is given in an array as a bit map.
+*
+*********************************************************************/
+
+#define CELL_DMRS_LENGTH   (224*2)
+#define CHECK_GOLD_SEQUENCE
+
+void lte_gold_new(LTE_DL_FRAME_PARMS *frame_parms, uint32_t lte_gold_table[20][2][14], uint16_t Nid_cell)
+{
+  unsigned char ns,l,Ncp=1-frame_parms->Ncp;
+  uint32_t cinit;
+
+#ifdef CHECK_GOLD_SEQUENCE
+
+  uint32_t dmrs_bitmap[20][2][14];
+  uint32_t *dmrs_sequence =  calloc(CELL_DMRS_LENGTH, sizeof(uint32_t));
+  if (dmrs_sequence == NULL) {
+    msg("Fatal error: memory allocation problem \n");
+  	assert(0);
+  }
+  else
+  {
+    printf("Check of demodulation reference signal of pbch sequence \n");
+  }
+
+#endif
+
+  /* for each slot number */
+  for (ns=0; ns<20; ns++) {
+
+  /* for each ofdm position */
+    for (l=0; l<2; l++) {
+
+      cinit = Ncp +
+             (Nid_cell<<1) +
+             (((1+(Nid_cell<<1))*(1 + (((frame_parms->Ncp==0)?4:3)*l) + (7*(1+ns))))<<10);
+
+      pseudo_random_sequence_optimised(14, &(lte_gold_table[ns][l][0]), cinit);
+
+#ifdef CHECK_GOLD_SEQUENCE
+
+      pseudo_random_sequence(CELL_DMRS_LENGTH, dmrs_sequence, cinit);
+
+      int j = 0;
+      int k = 0;
+
+      /* format for getting bitmap from uint32_t */
+      for (int i=0; i<14; i++) {
+        dmrs_bitmap[ns][l][i] = 0;
+        for (; j < k + 32; j++) {
+          dmrs_bitmap[ns][l][i] |= (dmrs_sequence[j]<<j);
+        }
+        k = j;
+      }
+
+      for (int i=0; i<14; i++) {
+        if (lte_gold_table[ns][l][i] != dmrs_bitmap[ns][l][i]) {
+          printf("Error in gold sequence computation for ns %d l %d and index %i : 0x%x 0x%x \n", ns, l, i, lte_gold_table[ns][l][i], dmrs_bitmap[ns][l][i]);
+          assert(0);
+        }
+      }
+
+#endif
+
+    }
+  }
+
+#ifdef CHECK_GOLD_SEQUENCE
+  free(dmrs_sequence);
+#endif
+}
+
+/*******************************************************************
+*
+* NAME :         get_dmrs_pbch
+*
+* PARAMETERS :   i_ssb : index of ssb/pbch beam
+*                n_hf  : number of the half frame in which PBCH is transmitted in frame
+*
+* RETURN :       demodulation reference signal for PBCH
+*
+* DESCRIPTION :  see TS 38.211 7.4.1.4 Demodulation reference signals for PBCH
+*
+*********************************************************************/
+
+#define CHECK_DMRS_PBCH_SEQUENCE
+
+void generate_dmrs_pbch(uint32_t dmrs_pbch_bitmap[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE], uint16_t Nid_cell)
+{
+  uint32_t cinit;
+  int i_ssb;
+  int n_hf;
+  int _i_ssb;
+
+#ifdef CHECK_DMRS_PBCH_SEQUENCE
+
+  uint32_t dmrs_bitmap[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE];
+  uint32_t *dmrs_sequence =  calloc(CELL_DMRS_LENGTH, sizeof(uint32_t));
+  if (dmrs_sequence == NULL) {
+    msg("Fatal error: memory allocation problem \n");
+  	assert(0);
+  }
+  else
+  {
+    printf("Check of demodulation reference signal of pbch sequence \n");
+  }
+
+#endif
+
+  /* for each slot number */
+  for (i_ssb = 0; i_ssb<DMRS_PBCH_I_SSB; i_ssb++) {
+
+    /* for each ofdm position */
+    for (n_hf=0; n_hf<DMRS_PBCH_N_HF; n_hf++) {
+
+      _i_ssb = i_ssb + 4*n_hf;
+
+      cinit = (((_i_ssb + 1)*((Nid_cell>>4) + 1))<<11) + ((_i_ssb + 1)<<6) + (Nid_cell%4);
+
+      pseudo_random_sequence_optimised(DMRS_BITMAP_SIZE, &(dmrs_pbch_bitmap[i_ssb][n_hf][0]), cinit);
+
+#ifdef CHECK_DMRS_PBCH_SEQUENCE
+
+      /* it allows checking generated with standard generation code */
+      pseudo_random_sequence(DMRS_BITMAP_SIZE*sizeof(uint32_t), dmrs_sequence, cinit);
+
+      int j = 0;
+      int k = 0;
+
+      /* format for getting bitmap from uint32_t */
+      for (int i=0; i<DMRS_BITMAP_SIZE; i++) {
+    	dmrs_bitmap[i_ssb][n_hf][i] = 0;
+    	/* convert to bitmap */
+      	for (; j < k + 32; j++) {
+          dmrs_bitmap[i_ssb][n_hf][i] |= (dmrs_sequence[j]<<j);
+      	}
+      	k = j;
+      }
+
+      for (int i=0; i<DMRS_BITMAP_SIZE; i++) {
+        if (dmrs_pbch_bitmap[i_ssb][n_hf][i] != dmrs_bitmap[i_ssb][n_hf][i]) {
+          printf("Error in gold sequence computation for ns %d l %d and index %i : 0x%x 0x%x \n", i_ssb, n_hf, i, dmrs_pbch_bitmap[i_ssb][n_hf][i], dmrs_bitmap[i_ssb][n_hf][i]);
+      	  assert(0);
+        }
+      }
+
+#endif
+
+    }
+  }
+
+#ifdef CHECK_DMRS_PBCH_SEQUENCE
+  free(dmrs_sequence);
+#endif
+}
+
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c
new file mode 100644
index 0000000000000000000000000000000000000000..f791a1d597018454b88e0d17f7ff6b708e2fa95d
--- /dev/null
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c
@@ -0,0 +1,465 @@
+/*
+ * 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 PHY/LTE_TRANSPORT/initial_sync.c
+* \brief Routines for initial UE synchronization procedure (PSS,SSS,PBCH and frame format detection)
+* \author R. Knopp, F. Kaltenberger
+* \date 2011
+* \version 0.1
+* \company Eurecom
+* \email: knopp@eurecom.fr,kaltenberger@eurecom.fr
+* \note
+* \warning
+*/
+#include "PHY/types.h"
+#include "PHY/defs_nr_UE.h"
+#include "PHY/phy_extern_nr_ue.h"
+//#include "SCHED/defs.h"
+//#include "SCHED/extern.h"
+//#include "defs.h"
+//#include "extern.h"
+
+
+#include "common_lib.h"
+
+#include "PHY/NR_REFSIG/pss_nr.h"
+#include "PHY/NR_REFSIG/sss_nr.h"
+#include "PHY/NR_REFSIG/refsig_defs_ue.h"
+
+extern openair0_config_t openair0_cfg[];
+static  nfapi_config_request_t config_t;
+static  nfapi_config_request_t* config =&config_t;
+/* forward declarations */
+void set_default_frame_parms_single(nfapi_config_request_t *config, NR_DL_FRAME_PARMS *frame_parms);
+
+//#define DEBUG_INITIAL_SYNCH
+
+int pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode)
+{
+
+  uint8_t l,pbch_decoded,frame_mod4,pbch_tx_ant,dummy;
+  NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms;
+  char phich_resource[6];
+
+#ifdef DEBUG_INITIAL_SYNCH
+  LOG_I(PHY,"[UE%d] Initial sync: starting PBCH detection (rx_offset %d)\n",ue->Mod_id,
+        ue->rx_offset);
+#endif
+
+  int nb_prefix_samples0 = frame_parms->nb_prefix_samples0;
+  frame_parms->nb_prefix_samples0 = 0;
+
+  //symbol 1
+  slot_fep_pbch(ue,
+    	   1,
+    	   0,
+    	   ue->rx_offset,
+    	   0,
+    	   1);
+
+  //symbol 2
+  slot_fep_pbch(ue,
+    	   2,
+    	   0,
+    	   ue->rx_offset,
+    	   0,
+    	   1);
+
+  //symbol 3
+  slot_fep_pbch(ue,
+    	   3,
+    	   0,
+    	   ue->rx_offset,
+    	   0,
+    	   1);
+
+  frame_parms->nb_prefix_samples0 = nb_prefix_samples0;
+
+  pbch_decoded = 0;
+
+  //for (frame_mod4=0; frame_mod4<4; frame_mod4++) {
+    pbch_tx_ant = nr_rx_pbch(ue,
+						  &ue->proc.proc_rxtx[0],
+                          ue->pbch_vars[0],
+                          frame_parms,
+                          0,
+                          SISO,
+                          ue->high_speed_flag,
+                          frame_mod4);
+
+    if ((pbch_tx_ant>0) && (pbch_tx_ant<=2)) {
+      pbch_decoded = 1;
+//      break;
+    }
+
+  //}
+
+
+  if (pbch_decoded) {
+
+    frame_parms->nb_antenna_ports_eNB = pbch_tx_ant;
+
+    // set initial transmission mode to 1 or 2 depending on number of detected TX antennas
+    //frame_parms->mode1_flag = (pbch_tx_ant==1);
+    // openair_daq_vars.dlsch_transmission_mode = (pbch_tx_ant>1) ? 2 : 1;
+
+
+    // flip byte endian on 24-bits for MIB
+    //    dummy = ue->pbch_vars[0]->decoded_output[0];
+    //    ue->pbch_vars[0]->decoded_output[0] = ue->pbch_vars[0]->decoded_output[2];
+    //    ue->pbch_vars[0]->decoded_output[2] = dummy;
+
+    // now check for Bandwidth of Cell
+    dummy = (ue->pbch_vars[0]->decoded_output[2]>>5)&7;
+
+    switch (dummy) {
+
+    case 0 :
+      frame_parms->N_RB_DL = 6;
+      break;
+
+    case 1 :
+      frame_parms->N_RB_DL = 15;
+      break;
+
+    case 2 :
+      frame_parms->N_RB_DL = 25;
+      break;
+
+    case 3 :
+      frame_parms->N_RB_DL = 50;
+      break;
+
+    case 4 :
+      frame_parms->N_RB_DL = 75;
+      break;
+
+    case 5:
+      frame_parms->N_RB_DL = 100;
+      break;
+
+    default:
+      LOG_E(PHY,"[UE%d] Initial sync: PBCH decoding: Unknown N_RB_DL\n",ue->Mod_id);
+      return -1;
+      break;
+    }
+
+
+
+    for(int i=0; i<RX_NB_TH;i++)
+    {
+        ue->proc.proc_rxtx[i].frame_rx =   (((ue->pbch_vars[0]->decoded_output[2]&3)<<6) + (ue->pbch_vars[0]->decoded_output[1]>>2))<<2;
+        ue->proc.proc_rxtx[i].frame_rx =   (((ue->pbch_vars[0]->decoded_output[2]&3)<<6) + (ue->pbch_vars[0]->decoded_output[1]>>2))<<2;
+
+#ifndef USER_MODE
+        // one frame delay
+        ue->proc.proc_rxtx[i].frame_rx ++;
+#endif
+        ue->proc.proc_rxtx[i].frame_tx = ue->proc.proc_rxtx[0].frame_rx;
+    }
+#ifdef DEBUG_INITIAL_SYNCH
+    LOG_I(PHY,"[UE%d] Initial sync: pbch decoded sucessfully mode1_flag %d, tx_ant %d, frame %d, N_RB_DL %d, phich_duration %d, phich_resource %s!\n",
+          ue->Mod_id,
+          frame_parms->mode1_flag,
+          pbch_tx_ant,
+          ue->proc.proc_rxtx[0].frame_rx,
+          frame_parms->N_RB_DL,
+          frame_parms->phich_config_common.phich_duration,
+          phich_resource);  //frame_parms->phich_config_common.phich_resource);
+#endif
+    return(0);
+  } else {
+    return(-1);
+  }
+
+}
+
+char phich_string[13][4] = {"","1/6","","1/2","","","one","","","","","","two"};
+char duplex_string[2][4] = {"FDD","TDD"};
+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;
+  int32_t metric_fdd_ncp=0;
+  uint8_t phase_fdd_ncp;
+
+  NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
+  int ret=-1;
+  int aarx,rx_power=0;
+  //nfapi_config_request_t* config;
+
+  /*offset parameters to be updated from higher layer */
+  k_ssb =0;
+  N_ssb_crb = 0;
+
+  /*#ifdef OAI_USRP
+  __m128i *rxdata128;
+  #endif*/
+  //  LOG_I(PHY,"**************************************************************\n");
+  // First try FDD normal prefix
+  frame_parms->Ncp=NORMAL;
+  frame_parms->frame_type=FDD;
+  set_default_frame_parms_single(config,frame_parms);
+  nr_init_frame_parms_ue(config,frame_parms);
+  /*
+  write_output("rxdata0.m","rxd0",ue->common_vars.rxdata[0],10*frame_parms->samples_per_tti,1,1);
+  exit(-1);
+  */
+
+  /*   Initial synchronisation
+   *
+  *                                 1 radio frame = 10 ms
+  *     <--------------------------------------------------------------------------->
+  *     -----------------------------------------------------------------------------
+  *     |                                 Received UE data buffer                    |
+  *     ----------------------------------------------------------------------------
+  *                     --------------------------
+  *     <-------------->| pss | pbch | sss | pbch |
+  *                     --------------------------
+  *          sync_pos            SS/PBCH block
+  */
+
+  /* process pss search on received buffer */
+  sync_pos = pss_synchro_nr(ue, NO_RATE_CHANGE);
+
+  /* offset is used by sss serach as it is returned from pss search */
+  ue->rx_offset = sync_pos;
+
+  //  write_output("rxdata1.m","rxd1",ue->common_vars.rxdata[0],10*frame_parms->samples_per_tti,1,1);
+
+#ifdef DEBUG_INITIAL_SYNCH
+  LOG_I(PHY,"[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos,ue->common_vars.eNb_id);
+#endif
+
+  /* check that SSS/PBCH block is continuous inside the received buffer */
+  if (sync_pos < (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->ttis_per_subframe*frame_parms->samples_per_tti - (NB_SYMBOLS_PBCH * frame_parms->ofdm_symbol_size))) {
+
+#ifdef DEBUG_INITIAL_SYNCH
+    LOG_I(PHY,"Calling sss detection (normal CP)\n");
+#endif
+
+    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_gold_pbch(ue);
+    ret = pbch_detection(ue,mode);
+    //   write_output("rxdata2.m","rxd2",ue->common_vars.rxdata[0],10*frame_parms->samples_per_tti,1,1);
+
+#ifdef DEBUG_INITIAL_SYNCH
+    LOG_I(PHY,"FDD Normal prefix: CellId %d metric %d, phase %d, flip %d, pbch %d\n",
+          frame_parms->Nid_cell,metric_fdd_ncp,phase_fdd_ncp,flip_fdd_ncp,ret);
+#endif
+  }
+  else {
+#ifdef DEBUG_INITIAL_SYNCH
+    LOG_I(PHY,"FDD Normal prefix: SSS error condition: sync_pos %d, sync_pos_slot %d\n", sync_pos, sync_pos_slot);
+#endif
+  }
+
+  /* Consider this is a false detection if the offset is > 1000 Hz */
+  if( (abs(ue->common_vars.freq_offset) > 150) && (ret == 0) )
+  {
+	  ret=-1;
+#if DISABLE_LOG_X
+	  printf("Ignore MIB with high freq offset [%d Hz] estimation \n",ue->common_vars.freq_offset);
+#else
+	  LOG_E(HW, "Ignore MIB with high freq offset [%d Hz] estimation \n",ue->common_vars.freq_offset);
+#endif
+  }
+
+  if (ret==0) {  // PBCH found so indicate sync to higher layers and configure frame parameters
+
+    //#ifdef DEBUG_INITIAL_SYNCH
+#if DISABLE_LOG_X
+    printf("[UE%d] In synch, rx_offset %d samples\n",ue->Mod_id, ue->rx_offset);
+#else
+    LOG_I(PHY, "[UE%d] In synch, rx_offset %d samples\n",ue->Mod_id, ue->rx_offset);
+#endif
+    //#endif
+
+    if (ue->UE_scan_carrier == 0) {
+
+    #if UE_AUTOTEST_TRACE
+      LOG_I(PHY,"[UE  %d] AUTOTEST Cell Sync : frame = %d, rx_offset %d, freq_offset %d \n",
+              ue->Mod_id,
+              ue->proc.proc_rxtx[0].frame_rx,
+              ue->rx_offset,
+              ue->common_vars.freq_offset );
+    #endif
+
+// send sync status to higher layers later when timing offset converge to target timing
+#if OAISIM
+      if (ue->mac_enabled==1) {
+	LOG_I(PHY,"[UE%d] Sending synch status to higher layers\n",ue->Mod_id);
+	//mac_resynch();
+	mac_xface->dl_phy_sync_success(ue->Mod_id,ue->proc.proc_rxtx[0].frame_rx,0,1);//ue->common_vars.eNb_id);
+	ue->UE_mode[0] = PRACH;
+      }
+      else {
+	ue->UE_mode[0] = PUSCH;
+      }
+#endif
+
+      generate_pcfich_reg_mapping(frame_parms);
+      generate_phich_reg_mapping(frame_parms);
+
+
+      ue->pbch_vars[0]->pdu_errors_conseq=0;
+
+    }
+
+#if DISABLE_LOG_X
+    printf("[UE %d] Frame %d RRC Measurements => rssi %3.1f dBm (dig %3.1f dB, gain %d), N0 %d dBm,  rsrp %3.1f dBm/RE, rsrq %3.1f dB\n",ue->Mod_id,
+	  ue->proc.proc_rxtx[0].frame_rx,
+	  10*log10(ue->measurements.rssi)-ue->rx_total_gain_dB,
+	  10*log10(ue->measurements.rssi),
+	  ue->rx_total_gain_dB,
+	  ue->measurements.n0_power_tot_dBm,
+	  10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB,
+	  (10*log10(ue->measurements.rsrq[0])));
+
+
+    printf("[UE %d] Frame %d MIB Information => %s, %s, NidCell %d, N_RB_DL %d, PHICH DURATION %d, PHICH RESOURCE %s, TX_ANT %d\n",
+	  ue->Mod_id,
+	  ue->proc.proc_rxtx[0].frame_rx,
+	  duplex_string[ue->frame_parms.frame_type],
+	  prefix_string[ue->frame_parms.Ncp],
+	  ue->frame_parms.Nid_cell,
+	  ue->frame_parms.N_RB_DL,
+	  ue->frame_parms.phich_config_common.phich_duration,
+	  phich_string[ue->frame_parms.phich_config_common.phich_resource],
+	  ue->frame_parms.nb_antenna_ports_eNB);
+#else
+    LOG_I(PHY, "[UE %d] Frame %d RRC Measurements => rssi %3.1f dBm (dig %3.1f dB, gain %d), N0 %d dBm,  rsrp %3.1f dBm/RE, rsrq %3.1f dB\n",ue->Mod_id,
+	  ue->proc.proc_rxtx[0].frame_rx,
+	  10*log10(ue->measurements.rssi)-ue->rx_total_gain_dB,
+	  10*log10(ue->measurements.rssi),
+	  ue->rx_total_gain_dB,
+	  ue->measurements.n0_power_tot_dBm,
+	  10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB,
+	  (10*log10(ue->measurements.rsrq[0])));
+
+/*    LOG_I(PHY, "[UE %d] Frame %d MIB Information => %s, %s, NidCell %d, N_RB_DL %d, PHICH DURATION %d, PHICH RESOURCE %s, TX_ANT %d\n",
+	  ue->Mod_id,
+	  ue->proc.proc_rxtx[0].frame_rx,
+	  duplex_string[ue->frame_parms.frame_type],
+	  prefix_string[ue->frame_parms.Ncp],
+	  ue->frame_parms.Nid_cell,
+	  ue->frame_parms.N_RB_DL,
+	  ue->frame_parms.phich_config_common.phich_duration,
+	  phich_string[ue->frame_parms.phich_config_common.phich_resource],
+	  ue->frame_parms.nb_antenna_ports_eNB);*/
+#endif
+
+#if defined(OAI_USRP) || defined(EXMIMO) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
+#  if DISABLE_LOG_X
+    printf("[UE %d] Frame %d Measured Carrier Frequency %.0f Hz (offset %d Hz)\n",
+	  ue->Mod_id,
+	  ue->proc.proc_rxtx[0].frame_rx,
+	  openair0_cfg[0].rx_freq[0]-ue->common_vars.freq_offset,
+	  ue->common_vars.freq_offset);
+#  else
+    LOG_I(PHY, "[UE %d] Frame %d Measured Carrier Frequency %.0f Hz (offset %d Hz)\n",
+	  ue->Mod_id,
+	  ue->proc.proc_rxtx[0].frame_rx,
+	  openair0_cfg[0].rx_freq[0]-ue->common_vars.freq_offset,
+	  ue->common_vars.freq_offset);
+#  endif
+#endif
+  } else {
+#ifdef DEBUG_INITIAL_SYNC
+    LOG_I(PHY,"[UE%d] Initial sync : PBCH not ok\n",ue->Mod_id);
+    LOG_I(PHY,"[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n",ue->Mod_id,sync_pos,ue->common_vars.eNb_id);
+    /*      LOG_I(PHY,"[UE%d] Initial sync: (metric fdd_ncp %d (%d), metric fdd_ecp %d (%d), metric_tdd_ncp %d (%d), metric_tdd_ecp %d (%d))\n",
+          ue->Mod_id,
+          metric_fdd_ncp,Nid_cell_fdd_ncp,
+          metric_fdd_ecp,Nid_cell_fdd_ecp,
+          metric_tdd_ncp,Nid_cell_tdd_ncp,
+          metric_tdd_ecp,Nid_cell_tdd_ecp);*/
+    LOG_I(PHY,"[UE%d] Initial sync : Estimated Nid_cell %d, Frame_type %d\n",ue->Mod_id,
+          frame_parms->Nid_cell,frame_parms->frame_type);
+#endif
+
+    ue->UE_mode[0] = NOT_SYNCHED;
+    ue->pbch_vars[0]->pdu_errors_last=ue->pbch_vars[0]->pdu_errors;
+    ue->pbch_vars[0]->pdu_errors++;
+    ue->pbch_vars[0]->pdu_errors_conseq++;
+
+  }
+
+  // gain control
+  if (ret!=0) { //we are not synched, so we cannot use rssi measurement (which is based on channel estimates)
+    rx_power = 0;
+
+    // do a measurement on the best guess of the PSS
+    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++)
+      rx_power += signal_energy(&ue->common_vars.rxdata[aarx][sync_pos2],
+				frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples);
+
+    /*
+    // do a measurement on the full frame
+    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++)
+      rx_power += signal_energy(&ue->common_vars.rxdata[aarx][0],
+				frame_parms->samples_per_subframe*10);
+    */
+
+    // we might add a low-pass filter here later
+    ue->measurements.rx_power_avg[0] = rx_power/frame_parms->nb_antennas_rx;
+
+    ue->measurements.rx_power_avg_dB[0] = dB_fixed(ue->measurements.rx_power_avg[0]);
+
+#ifdef DEBUG_INITIAL_SYNCH
+  LOG_I(PHY,"[UE%d] Initial sync : Estimated power: %d dB\n",ue->Mod_id,ue->measurements.rx_power_avg_dB[0] );
+#endif
+
+#ifndef OAI_USRP
+#ifndef OAI_BLADERF
+#ifndef OAI_LMSSDR
+#ifndef OAI_ADRV9371_ZC706
+  phy_adjust_gain(ue,ue->measurements.rx_power_avg_dB[0],0);
+#endif
+#endif
+#endif
+#endif
+
+  }
+  else {
+
+#ifndef OAI_USRP
+#ifndef OAI_BLADERF
+#ifndef OAI_LMSSDR
+#ifndef OAI_ADRV9371_ZC706
+  phy_adjust_gain(ue,dB_fixed(ue->measurements.rssi),0);
+#endif
+#endif
+#endif
+#endif
+
+  }
+
+  //  exit_fun("debug exit");
+  return ret;
+}
+
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c
new file mode 100644
index 0000000000000000000000000000000000000000..bbb29877763a22c106b00fb282a5bc8dbaeb6340
--- /dev/null
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c
@@ -0,0 +1,737 @@
+/*
+ * 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 PHY/LTE_TRANSPORT/pbch.c
+* \brief Top-level routines for generating and decoding  the PBCH/BCH physical/transport channel V8.6 2009-03
+* \author R. Knopp, F. Kaltenberger
+* \date 2011
+* \version 0.1
+* \company Eurecom
+* \email: knopp@eurecom.fr,florian.kaltenberger.fr
+* \note
+* \warning
+*/
+#include "PHY/defs_nr_UE.h"
+#include "PHY/CODING/coding_extern.h"
+#include "PHY/CODING/lte_interleaver_inline.h"
+//#include "defs.h"
+//#include "extern.h"
+#include "PHY/phy_extern_nr_ue.h"
+#include "PHY/sse_intrin.h"
+
+#ifdef PHY_ABSTRACTION
+#include "SIMULATION/TOOLS/defs.h"
+#endif
+
+
+//#define DEBUG_PBCH 1
+//#define DEBUG_PBCH_ENCODING
+//#define INTERFERENCE_MITIGATION 1
+
+#ifdef OPENAIR2
+//#include "PHY_INTERFACE/defs.h"
+#endif
+
+#define PBCH_A 24
+
+
+uint16_t nr_pbch_extract(int **rxdataF,
+                      int **dl_ch_estimates,
+                      int **rxdataF_ext,
+                      int **dl_ch_estimates_ext,
+                      uint32_t symbol,
+                      uint32_t high_speed_flag,
+                      NR_DL_FRAME_PARMS *frame_parms)
+{
+
+
+  uint16_t rb;
+  uint8_t i,j,aarx,aatx;
+  int32_t *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext;
+
+  int rx_offset = frame_parms->ofdm_symbol_size-10*12;
+  int nushiftmod4 = frame_parms->nushift;
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+    
+    printf("extract_rbs (nushift %d): rx_offset=%d, symbol %d\n",frame_parms->nushift,
+     (rx_offset + (symbol*(frame_parms->ofdm_symbol_size))),symbol);
+    
+    rxF        = &rxdataF[aarx][(rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))];
+    rxF_ext    = &rxdataF_ext[aarx][symbol*(20*12)];
+#ifdef DEBUG_PBCH
+     int16_t *p = (int16_t *)rxF;
+     for (int i =0; i<240;i++){
+        printf("rxF [%d]= %d\n",i,rxF[i]);
+      printf("pbch pss %d %d @%p\n", p[2*i], p[2*i+1], &p[2*i]);
+     }
+#endif
+
+    for (rb=0; rb<20; rb++) {
+      if (rb==10) {
+        rxF       = &rxdataF[aarx][((symbol*(frame_parms->ofdm_symbol_size)))];
+      }
+
+      j=0;
+      if ((symbol==1) || (symbol==3)) {
+        for (i=0; i<12; i++) {
+          if ((i!=nushiftmod4) &&
+              (i!=(nushiftmod4+4)) &&
+              (i!=(nushiftmod4+8))) {
+            rxF_ext[j]=rxF[i];
+	    //printf("rxF ext[%d] = %d rxF [%d]= %d\n",j,rxF_ext[j],i,rxF[i]);
+	    j++;
+          }
+        }
+
+        rxF+=12;
+        rxF_ext+=9;
+      } else { //symbol 2
+    	if ((rb < 4) && (rb >15)){
+    	  for (i=0; i<12; i++) {
+        	if ((i!=nushiftmod4) &&
+        	    (i!=(nushiftmod4+4)) &&
+        	    (i!=(nushiftmod4+8))) {
+        	  rxF_ext[j]=rxF[i];
+		  //printf("rxF ext[%d] = %d at %p\n",j,rxF_ext[j],&rxF[i]);
+		  j++;
+        	}
+    	  }
+	}
+
+        rxF+=12;
+        rxF_ext+=9;
+      }
+    }
+
+    for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB;aatx++) {
+      if (high_speed_flag == 1)
+        dl_ch0     = &dl_ch_estimates[(aatx<<1)+aarx][(symbol*(frame_parms->ofdm_symbol_size))];
+      else
+        dl_ch0     = &dl_ch_estimates[(aatx<<1)+aarx][0];
+
+      printf("dl_ch0 addr %p\n",dl_ch0);
+
+      dl_ch0_ext = &dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*(20*12)];
+
+      for (rb=0; rb<20; rb++) {
+	j=0;
+        if ((symbol==1) || (symbol==3)) {
+              	  for (i=0; i<12; i++) {
+                    if ((i!=nushiftmod4) &&
+                        (i!=(nushiftmod4+4)) &&
+                        (i!=(nushiftmod4+8))) {
+                           dl_ch0_ext[j]=dl_ch0[i];
+			   if ((rb==0) && (i<2))
+			   printf("dl ch0 ext[%d] = %d dl_ch0 [%d]= %d\n",j,dl_ch0_ext[j],i,dl_ch0[i]);
+		           j++;
+                    }
+          	  }
+
+          dl_ch0+=12;
+          dl_ch0_ext+=9;
+        }
+        else { //symbol 2
+              if ((rb < 4) && (rb >15)){
+              	  for (i=0; i<12; i++) {
+                    if ((i!=nushiftmod4) &&
+                        (i!=(nushiftmod4+4)) &&
+                        (i!=(nushiftmod4+8))) {
+		           dl_ch0_ext[j]=dl_ch0[i];
+			   j++;
+                       	}
+               	  }
+              }
+
+              dl_ch0+=12;
+              dl_ch0_ext+=9;
+
+         }
+      }
+    }  //tx antenna loop
+
+  }
+
+  return(0);
+}
+
+//__m128i avg128;
+
+//compute average channel_level on each (TX,RX) antenna pair
+int nr_pbch_channel_level(int **dl_ch_estimates_ext,
+                       NR_DL_FRAME_PARMS *frame_parms,
+                       uint32_t symbol)
+{
+
+  int16_t rb, nb_rb=6;
+  uint8_t aatx,aarx;
+
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i avg128;
+  __m128i *dl_ch128;
+#elif defined(__arm__)
+  int32x4_t avg128;
+  int16x8_t *dl_ch128;
+#endif
+  int avg1=0,avg2=0;
+
+  uint32_t nsymb = (frame_parms->Ncp==0) ? 7:6;
+  uint32_t symbol_mod = symbol % nsymb;
+
+  for (aatx=0; aatx<4; aatx++) //frame_parms->nb_antenna_ports_eNB;aatx++)
+    for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+      //clear average level
+
+#if defined(__x86_64__) || defined(__i386__)
+      avg128 = _mm_setzero_si128();
+      dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12];
+#elif defined(__arm__)
+      avg128 = vdupq_n_s32(0);
+      dl_ch128=(int16x8_t *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol_mod*6*12];
+
+#endif
+      for (rb=0; rb<nb_rb; rb++) {
+#if defined(__x86_64__) || defined(__i386__)
+        avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0]));
+        avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[1],dl_ch128[1]));
+        avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[2],dl_ch128[2]));
+#elif defined(__arm__)
+// to be filled in
+#endif
+        dl_ch128+=3;
+        /*
+          if (rb==0) {
+          print_shorts("dl_ch128",&dl_ch128[0]);
+          print_shorts("dl_ch128",&dl_ch128[1]);
+          print_shorts("dl_ch128",&dl_ch128[2]);
+          }
+        */
+      }
+
+      avg1 = (((int*)&avg128)[0] +
+              ((int*)&avg128)[1] +
+              ((int*)&avg128)[2] +
+              ((int*)&avg128)[3])/(nb_rb*12);
+
+      if (avg1>avg2)
+        avg2 = avg1;
+
+      //msg("Channel level : %d, %d\n",avg1, avg2);
+    }
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+  return(avg2);
+
+}
+
+#if defined(__x86_64__) || defined(__i386__)
+__m128i mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3;
+#elif defined(__arm__)
+int16x8_t mmtmpP0,mmtmpP1,mmtmpP2,mmtmpP3;
+#endif
+void nr_pbch_channel_compensation(int **rxdataF_ext,
+                               int **dl_ch_estimates_ext,
+                               int **rxdataF_comp,
+                               NR_DL_FRAME_PARMS *frame_parms,
+                               uint8_t symbol,
+                               uint8_t output_shift)
+{
+
+  uint16_t rb,nb_rb=6;
+  uint8_t aatx,aarx,symbol_mod;
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i *dl_ch128,*rxdataF128,*rxdataF_comp128;
+#elif defined(__arm__)
+
+#endif
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  for (aatx=0; aatx<4; aatx++) //frame_parms->nb_antenna_ports_eNB;aatx++)
+    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_mod*6*12];
+      rxdataF128        = (__m128i *)&rxdataF_ext[aarx][symbol_mod*6*12];
+      rxdataF_comp128   = (__m128i *)&rxdataF_comp[(aatx<<1)+aarx][symbol_mod*6*12];
+
+#elif defined(__arm__)
+// to be filled in
+#endif
+
+      for (rb=0; rb<nb_rb; rb++) {
+        //printf("rb %d\n",rb);
+#if defined(__x86_64__) || defined(__i386__)
+        // multiply by conjugated channel
+        mmtmpP0 = _mm_madd_epi16(dl_ch128[0],rxdataF128[0]);
+        //  print_ints("re",&mmtmpP0);
+        // mmtmpP0 contains real part of 4 consecutive outputs (32-bit)
+        mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[0],_MM_SHUFFLE(2,3,0,1));
+        mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1));
+        mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]);
+        //  print_ints("im",&mmtmpP1);
+        mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[0]);
+        // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit)
+        mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift);
+        //  print_ints("re(shift)",&mmtmpP0);
+        mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift);
+        //  print_ints("im(shift)",&mmtmpP1);
+        mmtmpP2 = _mm_unpacklo_epi32(mmtmpP0,mmtmpP1);
+        mmtmpP3 = _mm_unpackhi_epi32(mmtmpP0,mmtmpP1);
+        //      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);
+
+        // multiply by conjugated channel
+        mmtmpP0 = _mm_madd_epi16(dl_ch128[1],rxdataF128[1]);
+        // mmtmpP0 contains real part of 4 consecutive outputs (32-bit)
+        mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[1],_MM_SHUFFLE(2,3,0,1));
+        mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1));
+        mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]);
+        mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[1]);
+        // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit)
+        mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift);
+        mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift);
+        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);
+
+        if (symbol_mod>1) {
+          // multiply by conjugated channel
+          mmtmpP0 = _mm_madd_epi16(dl_ch128[2],rxdataF128[2]);
+          // mmtmpP0 contains real part of 4 consecutive outputs (32-bit)
+          mmtmpP1 = _mm_shufflelo_epi16(dl_ch128[2],_MM_SHUFFLE(2,3,0,1));
+          mmtmpP1 = _mm_shufflehi_epi16(mmtmpP1,_MM_SHUFFLE(2,3,0,1));
+          mmtmpP1 = _mm_sign_epi16(mmtmpP1,*(__m128i*)&conjugate[0]);
+          mmtmpP1 = _mm_madd_epi16(mmtmpP1,rxdataF128[2]);
+          // mmtmpP1 contains imag part of 4 consecutive outputs (32-bit)
+          mmtmpP0 = _mm_srai_epi32(mmtmpP0,output_shift);
+          mmtmpP1 = _mm_srai_epi32(mmtmpP1,output_shift);
+          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);
+
+          dl_ch128+=3;
+          rxdataF128+=3;
+          rxdataF_comp128+=3;
+        } else {
+          dl_ch128+=2;
+          rxdataF128+=2;
+          rxdataF_comp128+=2;
+        }
+#elif defined(__arm__)
+// to be filled in
+#endif
+      }
+    }
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+}
+
+void nr_pbch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms,
+                        int **rxdataF_comp,
+                        uint8_t symbol)
+{
+
+  uint8_t aatx, symbol_mod;
+  int i, nb_rb=6;
+#if defined(__x86_64__) || defined(__i386__)
+  __m128i *rxdataF_comp128_0,*rxdataF_comp128_1;
+#elif defined(__arm__)
+  int16x8_t *rxdataF_comp128_0,*rxdataF_comp128_1;
+#endif
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+
+  if (frame_parms->nb_antennas_rx>1) {
+    for (aatx=0; aatx<4; aatx++) { //frame_parms->nb_antenna_ports_eNB;aatx++) {
+#if defined(__x86_64__) || defined(__i386__)
+      rxdataF_comp128_0   = (__m128i *)&rxdataF_comp[(aatx<<1)][symbol_mod*6*12];
+      rxdataF_comp128_1   = (__m128i *)&rxdataF_comp[(aatx<<1)+1][symbol_mod*6*12];
+#elif defined(__arm__)
+      rxdataF_comp128_0   = (int16x8_t *)&rxdataF_comp[(aatx<<1)][symbol_mod*6*12];
+      rxdataF_comp128_1   = (int16x8_t *)&rxdataF_comp[(aatx<<1)+1][symbol_mod*6*12];
+
+#endif
+      // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation)
+      for (i=0; i<nb_rb*3; i++) {
+#if defined(__x86_64__) || defined(__i386__)
+        rxdataF_comp128_0[i] = _mm_adds_epi16(_mm_srai_epi16(rxdataF_comp128_0[i],1),_mm_srai_epi16(rxdataF_comp128_1[i],1));
+#elif defined(__arm__)
+        rxdataF_comp128_0[i] = vhaddq_s16(rxdataF_comp128_0[i],rxdataF_comp128_1[i]);
+
+#endif
+      }
+    }
+  }
+#if defined(__x86_64__) || defined(__i386__)
+  _mm_empty();
+  _m_empty();
+#endif
+}
+
+void nr_pbch_scrambling(NR_DL_FRAME_PARMS *frame_parms,
+                     uint8_t *pbch_e,
+                     uint32_t length)
+{
+  int i;
+  uint8_t reset;
+  uint32_t x1, x2, s=0;
+
+  reset = 1;
+  // x1 is set in lte_gold_generic
+  x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1
+  //  msg("pbch_scrambling: Nid_cell = %d\n",x2);
+
+  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;
+    }
+
+    pbch_e[i] = (pbch_e[i]&1) ^ ((s>>(i&0x1f))&1);
+
+  }
+}
+
+void nr_pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms,
+                       int8_t* llr,
+                       uint32_t length,
+                       uint8_t frame_mod4)
+{
+  int i;
+  uint8_t reset;
+  uint32_t x1, x2, s=0;
+
+  reset = 1;
+  // x1 is set in first call to lte_gold_generic
+  x2 = frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.6.1
+  //  msg("pbch_unscrambling: Nid_cell = %d\n",x2);
+
+  for (i=0; i<length; i++) {
+    if (i%32==0) {
+      s = lte_gold_generic(&x1, &x2, reset);
+      //      printf("lte_gold[%d]=%x\n",i,s);
+      reset = 0;
+    }
+
+    // take the quarter of the PBCH that corresponds to this frame
+    if ((i>=(frame_mod4*(length>>2))) && (i<((1+frame_mod4)*(length>>2)))) {
+      //      if (((s>>(i%32))&1)==1)
+
+      if (((s>>(i%32))&1)==0)
+        llr[i] = -llr[i];
+    }
+  }
+}
+
+void nr_pbch_alamouti(NR_DL_FRAME_PARMS *frame_parms,
+                   int **rxdataF_comp,
+                   uint8_t symbol)
+{
+
+
+  int16_t *rxF0,*rxF1;
+  //  __m128i *ch_mag0,*ch_mag1,*ch_mag0b,*ch_mag1b;
+  uint8_t rb,re,symbol_mod;
+  int jj;
+
+  //  printf("Doing alamouti\n");
+  symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
+  jj         = (symbol_mod*6*12);
+
+  rxF0     = (int16_t*)&rxdataF_comp[0][jj];  //tx antenna 0  h0*y
+  rxF1     = (int16_t*)&rxdataF_comp[2][jj];  //tx antenna 1  h1*y
+
+  for (rb=0; rb<6; rb++) {
+
+    for (re=0; re<12; re+=2) {
+
+      // Alamouti RX combining
+
+      rxF0[0] = rxF0[0] + rxF1[2];
+      rxF0[1] = rxF0[1] - rxF1[3];
+
+      rxF0[2] = rxF0[2] - rxF1[0];
+      rxF0[3] = rxF0[3] + rxF1[1];
+
+      rxF0+=4;
+      rxF1+=4;
+    }
+
+  }
+
+}
+
+void nr_pbch_quantize(int8_t *pbch_llr8,
+                   int16_t *pbch_llr,
+                   uint16_t len)
+{
+
+  uint16_t i;
+
+  for (i=0; i<len; i++) {
+    if (pbch_llr[i]>7)
+      pbch_llr8[i]=7;
+    else if (pbch_llr[i]<-8)
+      pbch_llr8[i]=-8;
+    else
+      pbch_llr8[i] = (char)(pbch_llr[i]);
+
+  }
+}
+
+static unsigned char dummy_w_rx[3*3*(16+PBCH_A)];
+static int8_t pbch_w_rx[3*3*(16+PBCH_A)],pbch_d_rx[96+(3*(16+PBCH_A))];
+
+
+uint16_t 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,
+		     uint8_t frame_mod4)
+{
+
+  NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars;
+
+  uint8_t log2_maxh;//,aatx,aarx;
+  int max_h=0;
+
+  int symbol,i;
+  uint32_t nsymb = (frame_parms->Ncp==0) ? 14:12;
+  uint16_t  pbch_E;
+  uint8_t pbch_a[8];
+  uint8_t RCC;
+
+  int8_t *pbch_e_rx;
+  uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output;
+  uint16_t crc;
+
+  int subframe_rx = proc->subframe_rx;
+
+  //  pbch_D    = 16+PBCH_A;
+
+  pbch_E  = (frame_parms->Ncp==0) ? 1920 : 1728; //RE/RB * #RB * bits/RB (QPSK)
+  pbch_e_rx = &nr_ue_pbch_vars->llr[frame_mod4*(pbch_E>>2)];
+#ifdef DEBUG_PBCH
+  msg("[PBCH] starting symbol loop (Ncp %d, frame_mod4 %d,mimo_mode %d\n",frame_parms->Ncp,frame_mod4,mimo_mode);
+#endif
+
+  // clear LLR buffer
+  memset(nr_ue_pbch_vars->llr,0,pbch_E);
+
+  for (symbol=1; symbol<4; symbol++) {
+
+#ifdef DEBUG_PBCH
+    msg("[PBCH] starting extract ofdm size %d\n",frame_parms->ofdm_symbol_size );
+#endif
+
+    printf("address dataf %p",nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF);
+    //write_output("rxdataF0_pbch.m","rxF0pbch",nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF,frame_parms->ofdm_symbol_size*4,2,1);
+  
+    nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF,
+                 nr_ue_common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].dl_ch_estimates[eNB_id],
+                 nr_ue_pbch_vars->rxdataF_ext,
+                 nr_ue_pbch_vars->dl_ch_estimates_ext,
+                 symbol,
+                 high_speed_flag,
+                 frame_parms);
+#ifdef DEBUG_PBCH
+    msg("[PHY] PBCH Symbol %d\n",symbol);
+    msg("[PHY] PBCH starting channel_level\n");
+#endif
+
+    max_h = nr_pbch_channel_level(nr_ue_pbch_vars->dl_ch_estimates_ext,
+                               frame_parms,
+                               symbol);
+    log2_maxh = 3+(log2_approx(max_h)/2);
+
+#ifdef DEBUG_PBCH
+    msg("[PHY] PBCH log2_maxh = %d (%d)\n",log2_maxh,max_h);
+#endif
+
+    nr_pbch_channel_compensation(nr_ue_pbch_vars->rxdataF_ext,
+                              nr_ue_pbch_vars->dl_ch_estimates_ext,
+                              nr_ue_pbch_vars->rxdataF_comp,
+                              frame_parms,
+                              symbol,
+                              log2_maxh); // log2_maxh+I0_shift
+
+    /*if (frame_parms->nb_antennas_rx > 1)
+      pbch_detection_mrc(frame_parms,
+                         nr_ue_pbch_vars->rxdataF_comp,
+                         symbol);*/
+
+
+    if (mimo_mode == ALAMOUTI) {
+      nr_pbch_alamouti(frame_parms,nr_ue_pbch_vars->rxdataF_comp,symbol);
+      //  msg("[PBCH][RX] Alamouti receiver not yet implemented!\n");
+      //  return(-1);
+    } else if (mimo_mode != SISO) {
+      msg("[PBCH][RX] Unsupported MIMO mode\n");
+      return(-1);
+    }
+
+    if (symbol>(nsymb>>1)+1) {
+      nr_pbch_quantize(pbch_e_rx,
+                    (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*72]),
+                    144);
+
+      pbch_e_rx+=144;
+    } else {
+      nr_pbch_quantize(pbch_e_rx,
+                    (short*)&(nr_ue_pbch_vars->rxdataF_comp[0][(symbol%(nsymb>>1))*72]),
+                    96);
+
+      pbch_e_rx+=96;
+    }
+
+
+  }
+
+  pbch_e_rx = nr_ue_pbch_vars->llr;
+
+
+
+  //un-scrambling
+#ifdef DEBUG_PBCH
+  msg("[PBCH] doing unscrambling\n");
+#endif
+
+
+  nr_pbch_unscrambling(frame_parms,
+                    pbch_e_rx,
+                    pbch_E,
+                    frame_mod4);
+
+
+
+  //un-rate matching
+#ifdef DEBUG_PBCH
+  msg("[PBCH] doing un-rate-matching\n");
+#endif
+
+
+  memset(dummy_w_rx,0,3*3*(16+PBCH_A));
+  RCC = generate_dummy_w_cc(16+PBCH_A,
+                            dummy_w_rx);
+
+
+  lte_rate_matching_cc_rx(RCC,pbch_E,pbch_w_rx,dummy_w_rx,pbch_e_rx);
+
+  sub_block_deinterleaving_cc((unsigned int)(PBCH_A+16),
+                              &pbch_d_rx[96],
+                              &pbch_w_rx[0]);
+
+  memset(pbch_a,0,((16+PBCH_A)>>3));
+
+
+
+
+  phy_viterbi_lte_sse2(pbch_d_rx+96,pbch_a,16+PBCH_A);
+
+  // Fix byte endian of PBCH (bit 23 goes in first)
+  for (i=0; i<(PBCH_A>>3); i++)
+    decoded_output[(PBCH_A>>3)-i-1] = pbch_a[i];
+
+#ifdef DEBUG_PBCH
+
+  for (i=0; i<(PBCH_A>>3); i++)
+    msg("[PBCH] pbch_a[%d] = %x\n",i,decoded_output[i]);
+
+#endif //DEBUG_PBCH
+
+#ifdef DEBUG_PBCH
+  msg("PBCH CRC %x : %x\n",
+      crc16(pbch_a,PBCH_A),
+      ((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]);
+#endif
+
+  crc = (crc16(pbch_a,PBCH_A)>>16) ^
+        (((uint16_t)pbch_a[PBCH_A>>3]<<8)+pbch_a[(PBCH_A>>3)+1]);
+
+  if (crc == 0x0000)
+    return(1);
+  else if (crc == 0xffff)
+    return(2);
+  else if (crc == 0x5555)
+    return(4);
+  else
+    return(-1);
+
+
+}
+
+#ifdef PHY_ABSTRACTION
+uint16_t rx_pbch_emul(PHY_VARS_UE *phy_vars_ue,
+                      uint8_t eNB_id,
+                      uint8_t pbch_phase)
+{
+
+  double bler=0.0;//, x=0.0;
+  double sinr=0.0;
+  uint16_t nb_rb = phy_vars_ue->frame_parms.N_RB_DL;
+  int16_t f;
+  uint8_t CC_id=phy_vars_ue->CC_id;
+  int frame_rx = phy_vars_ue->proc.proc_rxtx[0].frame_rx;
+
+  // compute effective sinr
+  // TODO: adapt this to varible bandwidth
+  for (f=(nb_rb*6-3*12); f<(nb_rb*6+3*12); f++) {
+    if (f!=0) //skip DC
+      sinr += pow(10, 0.1*(phy_vars_ue->sinr_dB[f]));
+  }
+
+  sinr = 10*log10(sinr/(6*12));
+
+  bler = pbch_bler(sinr);
+
+  LOG_D(PHY,"EMUL UE rx_pbch_emul: eNB_id %d, pbch_phase %d, sinr %f dB, bler %f \n",
+        eNB_id,
+        pbch_phase,
+        sinr,
+        bler);
+
+  if (pbch_phase == (frame_rx % 4)) {
+    if (uniformrandom() >= bler) {
+      memcpy(phy_vars_ue->pbch_vars[eNB_id]->decoded_output,PHY_vars_eNB_g[eNB_id][CC_id]->pbch_pdu,PBCH_PDU_SIZE);
+      return(PHY_vars_eNB_g[eNB_id][CC_id]->frame_parms.nb_antenna_ports_eNB);
+    } else
+      return(-1);
+  } else
+    return(-1);
+}
+#endif
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h
new file mode 100644
index 0000000000000000000000000000000000000000..24134358c5b23c5d0575101f170b3a879a8fe999
--- /dev/null
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h
@@ -0,0 +1,1662 @@
+/*
+ * 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_UE_TRANSPORT/transport_proto_ue.h
+ * \brief Function prototypes for PHY physical/transport channel processing and generation V8.6 2009-03
+ * \author R. Knopp, F. Kaltenberger
+ * \date 2011
+ * \version 0.1
+ * \company Eurecom
+ * \email: knopp@eurecom.fr
+ * \note
+ * \warning
+ */
+#ifndef __NR_TRANSPORT_PROTO_UE__H__
+#define __NR_TRANSPORT_PROTO_UE__H__
+#include "PHY/defs_nr_UE.h"
+//#include "PHY/LTE_TRANSPORT/transport_common_proto.h"
+#include <math.h>
+#include "nfapi_interface.h"
+
+// Functions below implement 36-211 and 36-212
+
+/** @addtogroup _PHY_TRANSPORT_
+ * @{
+ */
+
+/** \fn free_ue_dlsch(NR_UE_DLSCH_t *dlsch)
+    \brief This function frees memory allocated for a particular DLSCH at UE
+    @param dlsch Pointer to DLSCH to be removed
+*/
+void free_ue_dlsch(NR_UE_DLSCH_t *dlsch);
+
+/** \fn new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag)
+    \brief This function allocates structures for a particular DLSCH at UE
+    @returns Pointer to DLSCH to be removed
+    @param Kmimo Kmimo factor from 36-212/36-213
+    @param Mdlharq Maximum number of HARQ rounds (36-212/36-213)
+    @param Nsoft Soft-LLR buffer size from UE-Category
+    @params N_RB_DL total number of resource blocks (determine the operating BW)
+    @param abstraction_flag Flag to indicate abstracted interface
+*/
+NR_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag);
+
+
+void free_ue_ulsch(NR_UE_ULSCH_t *ulsch);
+
+
+NR_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag);
+
+void fill_UE_dlsch_MCH(PHY_VARS_NR_UE *ue,int mcs,int ndi,int rvidx,int eNB_id);
+
+int rx_pmch(PHY_VARS_NR_UE *phy_vars_ue,
+            unsigned char eNB_id,
+            uint8_t subframe,
+            unsigned char symbol);
+
+/** \brief Dump OCTAVE/MATLAB files for PMCH debugging
+    @param phy_vars_ue Pointer to UE variables
+    @param eNB_id index of eNB in ue variables
+    @param coded_bits_per_codeword G from 36.211
+    @param subframe Index of subframe
+    @returns 0 on success
+*/
+void dump_mch(PHY_VARS_NR_UE *phy_vars_ue,uint8_t eNB_id,uint16_t coded_bits_per_codeword,int subframe);
+
+
+
+/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/QPSK reception.
+    @param stream0_in Input from channel compensated (MR combined) stream 0
+    @param stream1_in Input from channel compensated (MR combined) stream 1
+    @param stream0_out Output from LLR unit for stream0
+    @param rho01 Cross-correlation between channels (MR combined)
+    @param length in complex channel outputs*/
+void qpsk_qpsk(int16_t *stream0_in,
+               int16_t *stream1_in,
+               int16_t *stream0_out,
+               int16_t *rho01,
+               int32_t length);
+
+/** \brief This function perform LLR computation for dual-stream (QPSK/QPSK) transmission.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param rxdataF_comp_i Compensated channel output for interference
+    @param rho_i Correlation between channel of signal and inteference
+    @param dlsch_llr llr output
+    @param symbol OFDM symbol index in sub-frame
+    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
+    @param nb_rb number of RBs for this allocation
+    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
+    @param llr128p pointer to pointer to symbol in dlsch_llr*/
+int32_t dlsch_qpsk_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms,
+                            int32_t **rxdataF_comp,
+                            int32_t **rxdataF_comp_i,
+                            int32_t **rho_i,
+                            int16_t *dlsch_llr,
+                            uint8_t symbol,
+                            uint8_t first_symbol_flag,
+                            uint16_t nb_rb,
+                            uint16_t pbch_pss_sss_adj,
+                            int16_t **llr128p);
+
+/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/16QAM reception.
+    @param stream0_in Input from channel compensated (MR combined) stream 0
+    @param stream1_in Input from channel compensated (MR combined) stream 1
+    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
+    @param stream0_out Output from LLR unit for stream0
+    @param rho01 Cross-correlation between channels (MR combined)
+    @param length in complex channel outputs*/
+void qpsk_qam16(int16_t *stream0_in,
+                int16_t *stream1_in,
+                short *ch_mag_i,
+                int16_t *stream0_out,
+                int16_t *rho01,
+                int32_t length);
+
+/** \brief This function perform LLR computation for dual-stream (QPSK/16QAM) transmission.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param rxdataF_comp_i Compensated channel output for interference
+    @param rho_i Correlation between channel of signal and inteference
+    @param dlsch_llr llr output
+    @param symbol OFDM symbol index in sub-frame
+    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
+    @param nb_rb number of RBs for this allocation
+    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
+    @param llr128p pointer to pointer to symbol in dlsch_llr*/
+int32_t dlsch_qpsk_16qam_llr(NR_DL_FRAME_PARMS *frame_parms,
+                             int32_t **rxdataF_comp,
+                             int32_t **rxdataF_comp_i,
+                             int **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10})
+                             int32_t **rho_i,
+                             int16_t *dlsch_llr,
+                             uint8_t symbol,
+                             uint8_t first_symbol_flag,
+                             uint16_t nb_rb,
+                             uint16_t pbch_pss_sss_adj,
+                             int16_t **llr128p);
+
+/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/64QAM reception.
+    @param stream0_in Input from channel compensated (MR combined) stream 0
+    @param stream1_in Input from channel compensated (MR combined) stream 1
+    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
+    @param stream0_out Output from LLR unit for stream0
+    @param rho01 Cross-correlation between channels (MR combined)
+    @param length in complex channel outputs*/
+void qpsk_qam64(int16_t *stream0_in,
+                int16_t *stream1_in,
+                short *ch_mag_i,
+                int16_t *stream0_out,
+                int16_t *rho01,
+                int32_t length);
+
+/** \brief This function perform LLR computation for dual-stream (QPSK/64QAM) transmission.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param rxdataF_comp_i Compensated channel output for interference
+    @param rho_i Correlation between channel of signal and inteference
+    @param dlsch_llr llr output
+    @param symbol OFDM symbol index in sub-frame
+    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
+    @param nb_rb number of RBs for this allocation
+    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
+    @param llr128p pointer to pointer to symbol in dlsch_llr*/
+int32_t dlsch_qpsk_64qam_llr(NR_DL_FRAME_PARMS *frame_parms,
+                             int32_t **rxdataF_comp,
+                             int32_t **rxdataF_comp_i,
+                             int **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10})
+                             int32_t **rho_i,
+                             int16_t *dlsch_llr,
+                             uint8_t symbol,
+                             uint8_t first_symbol_flag,
+                             uint16_t nb_rb,
+                             uint16_t pbch_pss_sss_adj,
+                             int16_t **llr128p);
+
+
+/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 16QAM/QPSK reception.
+    @param stream0_in Input from channel compensated (MR combined) stream 0
+    @param stream1_in Input from channel compensated (MR combined) stream 1
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param stream0_out Output from LLR unit for stream0
+    @param rho01 Cross-correlation between channels (MR combined)
+    @param length in complex channel outputs*/
+void qam16_qpsk(short *stream0_in,
+                short *stream1_in,
+                short *ch_mag,
+                short *stream0_out,
+                short *rho01,
+                int length);
+/** \brief This function perform LLR computation for dual-stream (16QAM/QPSK) transmission.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param rxdataF_comp_i Compensated channel output for interference
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param rho_i Correlation between channel of signal and inteference
+    @param dlsch_llr llr output
+    @param symbol OFDM symbol index in sub-frame
+    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
+    @param nb_rb number of RBs for this allocation
+    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
+    @param llr16p pointer to pointer to symbol in dlsch_llr*/
+int dlsch_16qam_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms,
+                         int **rxdataF_comp,
+                         int **rxdataF_comp_i,
+                         int **dl_ch_mag,   //|h_0|^2*(2/sqrt{10})
+                         int **rho_i,
+                         short *dlsch_llr,
+                         unsigned char symbol,
+                         unsigned char first_symbol_flag,
+                         unsigned short nb_rb,
+                         uint16_t pbch_pss_sss_adjust,
+                         short **llr16p);
+
+/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 16QAM/16QAM reception.
+    @param stream0_in Input from channel compensated (MR combined) stream 0
+    @param stream1_in Input from channel compensated (MR combined) stream 1
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
+    @param stream0_out Output from LLR unit for stream0
+    @param rho01 Cross-correlation between channels (MR combined)
+    @param length in complex channel outputs*/
+void qam16_qam16(short *stream0_in,
+                 short *stream1_in,
+                 short *ch_mag,
+                 short *ch_mag_i,
+                 short *stream0_out,
+                 short *rho01,
+                 int length);
+
+/** \brief This function perform LLR computation for dual-stream (16QAM/16QAM) transmission.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param rxdataF_comp_i Compensated channel output for interference
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
+    @param rho_i Correlation between channel of signal and inteference
+    @param dlsch_llr llr output
+    @param symbol OFDM symbol index in sub-frame
+    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
+    @param nb_rb number of RBs for this allocation
+    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
+    @param llr16p pointer to pointer to symbol in dlsch_llr*/
+int dlsch_16qam_16qam_llr(NR_DL_FRAME_PARMS *frame_parms,
+                          int **rxdataF_comp,
+                          int **rxdataF_comp_i,
+                          int **dl_ch_mag,   //|h_0|^2*(2/sqrt{10})
+                          int **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10})
+                          int **rho_i,
+                          short *dlsch_llr,
+                          unsigned char symbol,
+                          unsigned char first_symbol_flag,
+                          unsigned short nb_rb,
+                          uint16_t pbch_pss_sss_adjust,
+                          short **llr16p);
+
+/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 16QAM/64QAM reception.
+    @param stream0_in Input from channel compensated (MR combined) stream 0
+    @param stream1_in Input from channel compensated (MR combined) stream 1
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
+    @param stream0_out Output from LLR unit for stream0
+    @param rho01 Cross-correlation between channels (MR combined)
+    @param length in complex channel outputs*/
+void qam16_qam64(short *stream0_in,
+                 short *stream1_in,
+                 short *ch_mag,
+                 short *ch_mag_i,
+                 short *stream0_out,
+                 short *rho01,
+                 int length);
+
+/** \brief This function perform LLR computation for dual-stream (16QAM/64QAM) transmission.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param rxdataF_comp_i Compensated channel output for interference
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
+    @param rho_i Correlation between channel of signal and inteference
+    @param dlsch_llr llr output
+    @param symbol OFDM symbol index in sub-frame
+    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
+    @param nb_rb number of RBs for this allocation
+    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
+    @param llr16p pointer to pointer to symbol in dlsch_llr*/
+int dlsch_16qam_64qam_llr(NR_DL_FRAME_PARMS *frame_parms,
+                          int **rxdataF_comp,
+                          int **rxdataF_comp_i,
+                          int **dl_ch_mag,   //|h_0|^2*(2/sqrt{10})
+                          int **dl_ch_mag_i, //|h_1|^2*(2/sqrt{10})
+                          int **rho_i,
+                          short *dlsch_llr,
+                          unsigned char symbol,
+                          unsigned char first_symbol_flag,
+                          unsigned short nb_rb,
+                          uint16_t pbch_pss_sss_adjust,
+                          short **llr16p);
+
+/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/64QAM reception.
+    @param stream0_in Input from channel compensated (MR combined) stream 0
+    @param stream1_in Input from channel compensated (MR combined) stream 1
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param stream0_out Output from LLR unit for stream0
+    @param rho01 Cross-correlation between channels (MR combined)
+    @param length in complex channel outputs*/
+void qam64_qpsk(short *stream0_in,
+                short *stream1_in,
+                short *ch_mag,
+                short *stream0_out,
+                short *rho01,
+                int length);
+
+/** \brief This function perform LLR computation for dual-stream (64QAM/64QAM) transmission.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param rxdataF_comp_i Compensated channel output for interference
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param rho_i Correlation between channel of signal and inteference
+    @param dlsch_llr llr output
+    @param symbol OFDM symbol index in sub-frame
+    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
+    @param nb_rb number of RBs for this allocation
+    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
+    @param llr16p pointer to pointer to symbol in dlsch_llr*/
+int dlsch_64qam_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms,
+                         int **rxdataF_comp,
+                         int **rxdataF_comp_i,
+                         int **dl_ch_mag,
+                         int **rho_i,
+                         short *dlsch_llr,
+                         unsigned char symbol,
+                         unsigned char first_symbol_flag,
+                         unsigned short nb_rb,
+                         uint16_t pbch_pss_sss_adjust,
+                         short **llr16p);
+
+/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/16QAM reception.
+    @param stream0_in Input from channel compensated (MR combined) stream 0
+    @param stream1_in Input from channel compensated (MR combined) stream 1
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
+    @param stream0_out Output from LLR unit for stream0
+    @param rho01 Cross-correlation between channels (MR combined)
+    @param length in complex channel outputs*/
+void qam64_qam16(short *stream0_in,
+                 short *stream1_in,
+                 short *ch_mag,
+                 short *ch_mag_i,
+                 short *stream0_out,
+                 short *rho01,
+                 int length);
+
+/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/16QAM reception.
+    @param stream0_in Input from channel compensated (MR combined) stream 0
+    @param stream1_in Input from channel compensated (MR combined) stream 1
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
+    @param stream0_out Output from LLR unit for stream0
+    @param rho01 Cross-correlation between channels (MR combined)
+    @param length in complex channel outputs*/
+void qam64_qam16_avx2(short *stream0_in,
+                      short *stream1_in,
+                      short *ch_mag,
+                      short *ch_mag_i,
+                      short *stream0_out,
+                      short *rho01,
+                      int length);
+
+/** \brief This function perform LLR computation for dual-stream (64QAM/16QAM) transmission.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param rxdataF_comp_i Compensated channel output for interference
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
+    @param rho_i Correlation between channel of signal and inteference
+    @param dlsch_llr llr output
+    @param symbol OFDM symbol index in sub-frame
+    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
+    @param nb_rb number of RBs for this allocation
+    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
+    @param llr16p pointer to pointer to symbol in dlsch_llr*/
+int dlsch_64qam_16qam_llr(NR_DL_FRAME_PARMS *frame_parms,
+                          int **rxdataF_comp,
+                          int **rxdataF_comp_i,
+                          int **dl_ch_mag,
+                          int **dl_ch_mag_i,
+                          int **rho_i,
+                          short *dlsch_llr,
+                          unsigned char symbol,
+                          unsigned char first_symbol_flag,
+                          unsigned short nb_rb,
+                          uint16_t pbch_pss_sss_adjust,
+                          short **llr16p);
+
+/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/64QAM reception.
+    @param stream0_in Input from channel compensated (MR combined) stream 0
+    @param stream1_in Input from channel compensated (MR combined) stream 1
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
+    @param stream0_out Output from LLR unit for stream0
+    @param rho01 Cross-correlation between channels (MR combined)
+    @param length in complex channel outputs*/
+void qam64_qam64(short *stream0_in,
+                 short *stream1_in,
+                 short *ch_mag,
+                 short *ch_mag_i,
+                 short *stream0_out,
+                 short *rho01,
+                 int length);
+
+/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream 64QAM/64QAM reception.
+    @param stream0_in Input from channel compensated (MR combined) stream 0
+    @param stream1_in Input from channel compensated (MR combined) stream 1
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
+    @param stream0_out Output from LLR unit for stream0
+    @param rho01 Cross-correlation between channels (MR combined)
+    @param length in complex channel outputs*/
+void qam64_qam64_avx2(int32_t *stream0_in,
+                      int32_t *stream1_in,
+                      int32_t *ch_mag,
+                      int32_t *ch_mag_i,
+                      int16_t *stream0_out,
+                      int32_t *rho01,
+                      int length);
+
+/** \brief This function perform LLR computation for dual-stream (64QAM/64QAM) transmission.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param rxdataF_comp_i Compensated channel output for interference
+    @param ch_mag   Input from scaled channel magnitude square of h0'*g0
+    @param ch_mag_i Input from scaled channel magnitude square of h0'*g1
+    @param rho_i Correlation between channel of signal and inteference
+    @param dlsch_llr llr output
+    @param symbol OFDM symbol index in sub-frame
+    @param first_symbol_flag flag to indicate this is the first symbol of the dlsch
+    @param nb_rb number of RBs for this allocation
+    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
+    @param llr16p pointer to pointer to symbol in dlsch_llr*/
+int dlsch_64qam_64qam_llr(NR_DL_FRAME_PARMS *frame_parms,
+                          int **rxdataF_comp,
+                          int **rxdataF_comp_i,
+                          int **dl_ch_mag,
+                          int **dl_ch_mag_i,
+                          int **rho_i,
+                          short *dlsch_llr,
+                          unsigned char symbol,
+                          unsigned char first_symbol_flag,
+                          unsigned short nb_rb,
+                          uint16_t pbch_pss_sss_adjust,
+                          //short **llr16p,
+                          uint32_t llr_offset);
+
+
+/** \brief This function generates log-likelihood ratios (decoder input) for single-stream QPSK received waveforms.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param dlsch_llr llr output
+    @param symbol OFDM symbol index in sub-frame
+    @param first_symbol_flag
+    @param nb_rb number of RBs for this allocation
+    @param pbch_pss_sss_adj Number of channel bits taken by PBCH/PSS/SSS
+    @param llr128p pointer to pointer to symbol in dlsch_llr
+    @param beamforming_mode beamforming mode
+*/
+int32_t dlsch_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms,
+                       int32_t **rxdataF_comp,
+                       int16_t *dlsch_llr,
+                       uint8_t symbol,
+                       uint8_t first_symbol_flag,
+                       uint16_t nb_rb,
+                       uint16_t pbch_pss_sss_adj,
+                       //int16_t **llr128p,
+                       uint8_t beamforming_mode);
+
+/**
+   \brief This function generates log-likelihood ratios (decoder input) for single-stream 16QAM received waveforms
+   @param frame_parms Frame descriptor structure
+   @param rxdataF_comp Compensated channel output
+   @param dlsch_llr llr output
+   @param dl_ch_mag Squared-magnitude of channel in each resource element position corresponding to allocation and weighted for mid-point in 16QAM constellation
+   @param symbol OFDM symbol index in sub-frame
+   @param first_symbol_flag
+   @param nb_rb number of RBs for this allocation
+   @param pbch_pss_sss_adjust  Adjustment factor in RE for PBCH/PSS/SSS allocations
+   @param llr128p pointer to pointer to symbol in dlsch_llr
+   @param beamforming_mode beamforming mode
+*/
+
+int32_t dlsch_qpsk_llr_SIC(NR_DL_FRAME_PARMS *frame_parms,
+                           int **rxdataF_comp,
+                           int32_t **sic_buffer,
+                           int **rho_i,
+                           short *dlsch_llr,
+                           uint8_t num_pdcch_symbols,
+                           uint16_t nb_rb,
+                           uint8_t subframe,
+                           uint16_t mod_order_0,
+                           uint32_t rb_alloc);
+
+void dlsch_16qam_llr(NR_DL_FRAME_PARMS *frame_parms,
+                     int32_t **rxdataF_comp,
+                     int16_t *dlsch_llr,
+                     int32_t **dl_ch_mag,
+                     uint8_t symbol,
+                     uint8_t first_symbol_flag,
+                     uint16_t nb_rb,
+                     uint16_t pbch_pss_sss_adjust,
+                     int16_t **llr128p,
+                     uint8_t beamforming_mode);
+/**
+   \brief This function generates log-likelihood ratios (decoder input) for single-stream 16QAM received waveforms
+   @param frame_parms Frame descriptor structure
+   @param rxdataF_comp Compensated channel output
+   @param dlsch_llr llr output
+   @param dl_ch_mag Squared-magnitude of channel in each resource element position corresponding to allocation, weighted by first mid-point of 64-QAM constellation
+   @param dl_ch_magb Squared-magnitude of channel in each resource element position corresponding to allocation, weighted by second mid-point of 64-QAM constellation
+   @param symbol OFDM symbol index in sub-frame
+   @param first_symbol_flag
+   @param nb_rb number of RBs for this allocation
+   @param pbch_pss_sss_adjust PBCH/PSS/SSS RE adjustment (in REs)
+   @param beamforming_mode beamforming mode
+*/
+void dlsch_16qam_llr_SIC (NR_DL_FRAME_PARMS *frame_parms,
+                          int32_t **rxdataF_comp,
+                          int32_t **sic_buffer,  //Q15
+                          int32_t **rho_i,
+                          int16_t *dlsch_llr,
+                          uint8_t num_pdcch_symbols,
+                          int32_t **dl_ch_mag,
+                          uint16_t nb_rb,
+                          uint8_t subframe,
+                          uint16_t mod_order_0,
+                          uint32_t rb_alloc);
+
+void dlsch_64qam_llr_SIC(NR_DL_FRAME_PARMS *frame_parms,
+                         int32_t **rxdataF_comp,
+                         int32_t **sic_buffer,  //Q15
+                         int32_t **rho_i,
+                         int16_t *dlsch_llr,
+                         uint8_t num_pdcch_symbols,
+                         int32_t **dl_ch_mag,
+                         int32_t **dl_ch_magb,
+                         uint16_t nb_rb,
+                         uint8_t subframe,
+                         uint16_t mod_order_0,
+                         uint32_t rb_alloc);
+
+
+void dlsch_64qam_llr(NR_DL_FRAME_PARMS *frame_parms,
+                     int32_t **rxdataF_comp,
+                     int16_t *dlsch_llr,
+                     int32_t **dl_ch_mag,
+                     int32_t **dl_ch_magb,
+                     uint8_t symbol,
+                     uint8_t first_symbol_flag,
+                     uint16_t nb_rb,
+                     uint16_t pbch_pss_sss_adjust,
+                     //int16_t **llr_save,
+                     uint32_t llr_offset,
+                     uint8_t beamforming_mode);
+
+
+/** \fn dlsch_siso(NR_DL_FRAME_PARMS *frame_parms,
+    int32_t **rxdataF_comp,
+    int32_t **rxdataF_comp_i,
+    uint8_t l,
+    uint16_t nb_rb)
+    \brief This function does the first stage of llr computation for SISO, by just extracting the pilots, PBCH and primary/secondary synchronization sequences.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param rxdataF_comp_i Compensated channel output for interference
+    @param l symbol in sub-frame
+    @param nb_rb Number of RBs in this allocation
+*/
+
+void dlsch_siso(NR_DL_FRAME_PARMS *frame_parms,
+                int32_t **rxdataF_comp,
+                int32_t **rxdataF_comp_i,
+                uint8_t l,
+                uint16_t nb_rb);
+
+/** \fn dlsch_alamouti(NR_DL_FRAME_PARMS *frame_parms,
+    int32_t **rxdataF_comp,
+    int32_t **dl_ch_mag,
+    int32_t **dl_ch_magb,
+    uint8_t symbol,
+    uint16_t nb_rb)
+    \brief This function does Alamouti combining on RX and prepares LLR inputs by skipping pilots, PBCH and primary/secondary synchronization signals.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param dl_ch_mag First squared-magnitude of channel (16QAM and 64QAM) for LLR computation.  Alamouti combining should be performed on this as well. Result is stored in first antenna position
+    @param dl_ch_magb Second squared-magnitude of channel (64QAM only) for LLR computation.  Alamouti combining should be performed on this as well. Result is stored in first antenna position
+    @param symbol Symbol in sub-frame
+    @param nb_rb Number of RBs in this allocation
+*/
+void dlsch_alamouti(NR_DL_FRAME_PARMS *frame_parms,
+                    int32_t **rxdataF_comp,
+                    int32_t **dl_ch_mag,
+                    int32_t **dl_ch_magb,
+                    uint8_t symbol,
+                    uint16_t nb_rb);
+
+/** \fn dlsch_antcyc(NR_DL_FRAME_PARMS *frame_parms,
+    int32_t **rxdataF_comp,
+    int32_t **dl_ch_mag,
+    int32_t **dl_ch_magb,
+    uint8_t symbol,
+    uint16_t nb_rb)
+    \brief This function does antenna selection (based on antenna cycling pattern) on RX and prepares LLR inputs by skipping pilots, PBCH and primary/secondary synchronization signals.  Note that this is not LTE, it is just included for comparison purposes.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param dl_ch_mag First squared-magnitude of channel (16QAM and 64QAM) for LLR computation.  Alamouti combining should be performed on this as well. Result is stored in first antenna position
+    @param dl_ch_magb Second squared-magnitude of channel (64QAM only) for LLR computation.  Alamouti combining should be performed on this as well. Result is stored in first antenna position
+    @param symbol Symbol in sub-frame
+    @param nb_rb Number of RBs in this allocation
+*/
+void dlsch_antcyc(NR_DL_FRAME_PARMS *frame_parms,
+                  int32_t **rxdataF_comp,
+                  int32_t **dl_ch_mag,
+                  int32_t **dl_ch_magb,
+                  uint8_t symbol,
+                  uint16_t nb_rb);
+
+/** \fn dlsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms,
+    int32_t **rxdataF_comp,
+    int32_t **rxdataF_comp_i,
+    int32_t **rho,
+    int32_t **rho_i,
+    int32_t **dl_ch_mag,
+    int32_t **dl_ch_magb,
+    uint8_t symbol,
+    uint16_t nb_rb,
+    uint8_t dual_stream_UE)
+
+    \brief This function does maximal-ratio combining for dual-antenna receivers.
+    @param frame_parms Frame descriptor structure
+    @param rxdataF_comp Compensated channel output
+    @param rxdataF_comp_i Compensated channel output for interference
+    @param rho Cross correlation between spatial channels
+    @param rho_i Cross correlation between signal and inteference channels
+    @param dl_ch_mag First squared-magnitude of channel (16QAM and 64QAM) for LLR computation.  Alamouti combining should be performed on this as well. Result is stored in first antenna position
+    @param dl_ch_magb Second squared-magnitude of channel (64QAM only) for LLR computation.  Alamouti combining should be performed on this as well. Result is stored in first antenna position
+    @param symbol Symbol in sub-frame
+    @param nb_rb Number of RBs in this allocation
+    @param dual_stream_UE Flag to indicate dual-stream detection
+*/
+void dlsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms,
+                         int32_t **rxdataF_comp,
+                         int32_t **rxdataF_comp_i,
+                         int32_t **rho,
+                         int32_t **rho_i,
+                         int32_t **dl_ch_mag,
+                         int32_t **dl_ch_magb,
+                         int32_t **dl_ch_mag_i,
+                         int32_t **dl_ch_magb_i,
+                         uint8_t symbol,
+                         uint16_t nb_rb,
+                         uint8_t dual_stream_UE);
+
+void dlsch_detection_mrc_TM34(NR_DL_FRAME_PARMS *frame_parms,
+                              NR_UE_PDSCH *lte_ue_pdsch_vars,
+                              int harq_pid,
+                              int round,
+                              unsigned char symbol,
+                              unsigned short nb_rb,
+                              unsigned char dual_stream_UE);
+
+/** \fn dlsch_extract_rbs_single(int32_t **rxdataF,
+    int32_t **dl_ch_estimates,
+    int32_t **rxdataF_ext,
+    int32_t **dl_ch_estimates_ext,
+    uint16_t pmi,
+    uint8_t *pmi_ext,
+    uint32_t *rb_alloc,
+    uint8_t symbol,
+    uint8_t subframe,
+    NR_DL_FRAME_PARMS *frame_parms)
+    \brief This function extracts the received resource blocks, both channel estimates and data symbols,
+    for the current allocation and for single antenna eNB transmission.
+    @param rxdataF Raw FFT output of received signal
+    @param dl_ch_estimates Channel estimates of current slot
+    @param rxdataF_ext FFT output for RBs in this allocation
+    @param dl_ch_estimates_ext Channel estimates for RBs in this allocation
+    @param pmi subband Precoding matrix indicator
+    @param pmi_ext Extracted PMI for chosen RBs
+    @param rb_alloc RB allocation vector
+    @param symbol Symbol to extract
+    @param subframe Subframe number
+    @param vrb_type Flag to indicate distributed VRB type
+    @param high_speed_flag
+    @param frame_parms Pointer to frame descriptor
+*/
+uint16_t dlsch_extract_rbs_single(int32_t **rxdataF,
+                                  int32_t **dl_ch_estimates,
+                                  int32_t **rxdataF_ext,
+                                  int32_t **dl_ch_estimates_ext,
+                                  uint16_t pmi,
+                                  uint8_t *pmi_ext,
+                                  uint32_t *rb_alloc,
+                                  uint8_t symbol,
+                                  uint8_t subframe,
+                                  uint32_t high_speed_flag,
+                                  NR_DL_FRAME_PARMS *frame_parms);
+
+/** \fn dlsch_extract_rbs_dual(int32_t **rxdataF,
+    int32_t **dl_ch_estimates,
+    int32_t **rxdataF_ext,
+    int32_t **dl_ch_estimates_ext,
+    uint16_t pmi,
+    uint8_t *pmi_ext,
+    uint32_t *rb_alloc,
+    uint8_t symbol,
+    NR_DL_FRAME_PARMS *frame_parms)
+    \brief This function extracts the received resource blocks, both channel estimates and data symbols,
+    for the current allocation and for dual antenna eNB transmission.
+    @param rxdataF Raw FFT output of received signal
+    @param dl_ch_estimates Channel estimates of current slot
+    @param rxdataF_ext FFT output for RBs in this allocation
+    @param dl_ch_estimates_ext Channel estimates for RBs in this allocation
+    @param pmi subband Precoding matrix indicator
+    @param pmi_ext Extracted PMI for chosen RBs
+    @param rb_alloc RB allocation vector
+    @param symbol Symbol to extract
+    @param subframe Subframe index
+    @param high_speed_flag
+    @param frame_parms Pointer to frame descriptor
+*/
+uint16_t dlsch_extract_rbs_dual(int32_t **rxdataF,
+                                int32_t **dl_ch_estimates,
+                                int32_t **rxdataF_ext,
+                                int32_t **dl_ch_estimates_ext,
+                                uint16_t pmi,
+                                uint8_t *pmi_ext,
+                                uint32_t *rb_alloc,
+                                uint8_t symbol,
+                                uint8_t subframe,
+                                uint32_t high_speed_flag,
+                                NR_DL_FRAME_PARMS *frame_parms,
+                                MIMO_mode_t mimo_mode);
+
+/** \fn dlsch_extract_rbs_TM7(int32_t **rxdataF,
+    int32_t **dl_bf_ch_estimates,
+    int32_t **rxdataF_ext,
+    int32_t **dl_bf_ch_estimates_ext,
+    uint32_t *rb_alloc,
+    uint8_t symbol,
+    uint8_t subframe,
+    uint32_t high_speed_flag,
+    NR_DL_FRAME_PARMS *frame_parms)
+    \brief This function extracts the received resource blocks, both channel estimates and data symbols,
+    for the current allocation and for single antenna eNB transmission.
+    @param rxdataF Raw FFT output of received signal
+    @param dl_bf_ch_estimates Beamforming channel estimates of current slot
+    @param rxdataF_ext FFT output for RBs in this allocation
+    @param dl_bf_ch_estimates_ext Beamforming channel estimates for RBs in this allocation
+    @param rb_alloc RB allocation vector
+    @param symbol Symbol to extract
+    @param subframe Subframe number
+    @param high_speed_flag
+    @param frame_parms Pointer to frame descriptor
+*/
+uint16_t dlsch_extract_rbs_TM7(int32_t **rxdataF,
+                               int32_t **dl_bf_ch_estimates,
+                               int32_t **rxdataF_ext,
+                               int32_t **dl_bf_ch_estimates_ext,
+                               uint32_t *rb_alloc,
+                               uint8_t symbol,
+                               uint8_t subframe,
+                               uint32_t high_speed_flag,
+                               NR_DL_FRAME_PARMS *frame_parms);
+
+/** \brief This function performs channel compensation (matched filtering) on the received RBs for this allocation.  In addition, it computes the squared-magnitude of the channel with weightings for 16QAM/64QAM detection as well as dual-stream detection (cross-correlation)
+    @param rxdataF_ext Frequency-domain received signal in RBs to be demodulated
+    @param dl_ch_estimates_ext Frequency-domain channel estimates in RBs to be demodulated
+    @param dl_ch_mag First Channel magnitudes (16QAM/64QAM)
+    @param dl_ch_magb Second weighted Channel magnitudes (64QAM)
+    @param rxdataF_comp Compensated received waveform
+    @param rho Cross-correlation between two spatial channels on each RX antenna
+    @param frame_parms Pointer to frame descriptor
+    @param symbol Symbol on which to operate
+    @param first_symbol_flag set to 1 on first DLSCH symbol
+    @param mod_order Modulation order of allocation
+    @param nb_rb Number of RBs in allocation
+    @param output_shift Rescaling for compensated output (should be energy-normalizing)
+    @param phy_measurements Pointer to UE PHY measurements
+*/
+void dlsch_channel_compensation(int32_t **rxdataF_ext,
+                                int32_t **dl_ch_estimates_ext,
+                                int32_t **dl_ch_mag,
+                                int32_t **dl_ch_magb,
+                                int32_t **rxdataF_comp,
+                                int32_t **rho,
+                                NR_DL_FRAME_PARMS *frame_parms,
+                                uint8_t symbol,
+                                uint8_t first_symbol_flag,
+                                uint8_t mod_order,
+                                uint16_t nb_rb,
+                                uint8_t output_shift,
+                                PHY_NR_MEASUREMENTS *phy_measurements);
+
+void dlsch_dual_stream_correlation(NR_DL_FRAME_PARMS *frame_parms,
+                                   unsigned char symbol,
+                                   unsigned short nb_rb,
+                                   int **dl_ch_estimates_ext,
+                                   int **dl_ch_estimates_ext_i,
+                                   int **dl_ch_rho_ext,
+                                   unsigned char output_shift);
+
+void dlsch_dual_stream_correlationTM34(NR_DL_FRAME_PARMS *frame_parms,
+                                   unsigned char symbol,
+                                   unsigned short nb_rb,
+                                   int **dl_ch_estimates_ext,
+                                   int **dl_ch_estimates_ext_i,
+                                   int **dl_ch_rho_ext,
+                                   unsigned char output_shift0,
+                                   unsigned char output_shift1);
+//This function is used to compute multiplications in Hhermitian * H matrix
+void conjch0_mult_ch1(int *ch0,
+                      int *ch1,
+                      int32_t *ch0conj_ch1,
+                      unsigned short nb_rb,
+                      unsigned char output_shift0);
+
+void construct_HhH_elements(int *ch0conj_ch0,
+                         int *ch1conj_ch1,
+                         int *ch2conj_ch2,
+                         int *ch3conj_ch3,
+                         int *ch0conj_ch1,
+                         int *ch1conj_ch0,
+                         int *ch2conj_ch3,
+                         int *ch3conj_ch2,
+                         int32_t *after_mf_00,
+                         int32_t *after_mf_01,
+                         int32_t *after_mf_10,
+                         int32_t *after_mf_11,
+                         unsigned short nb_rb);
+
+void squared_matrix_element(int32_t *Hh_h_00,
+                            int32_t *Hh_h_00_sq,
+                            unsigned short nb_rb);
+
+void dlsch_channel_level_TM34_meas(int *ch00,
+                                   int *ch01,
+                                   int *ch10,
+                                   int *ch11,
+                                   int *avg_0,
+                                   int *avg_1,
+                                   unsigned short nb_rb);
+
+void det_HhH(int32_t *after_mf_00,
+             int32_t *after_mf_01,
+             int32_t *after_mf_10,
+             int32_t *after_mf_11,
+             int32_t *det_fin_128,
+             unsigned short nb_rb);
+
+void numer(int32_t *Hh_h_00_sq,
+           int32_t *Hh_h_01_sq,
+           int32_t *Hh_h_10_sq,
+           int32_t *Hh_h_11_sq,
+           int32_t *num_fin,
+           unsigned short nb_rb);
+
+uint8_t rank_estimation_tm3_tm4(int *dl_ch_estimates_00,
+                                int *dl_ch_estimates_01,
+                                int *dl_ch_estimates_10,
+                                int *dl_ch_estimates_11,
+                                unsigned short nb_rb);
+
+void dlsch_channel_compensation_TM56(int **rxdataF_ext,
+                                     int **dl_ch_estimates_ext,
+                                     int **dl_ch_mag,
+                                     int **dl_ch_magb,
+                                     int **rxdataF_comp,
+                                     unsigned char *pmi_ext,
+                                     NR_DL_FRAME_PARMS *frame_parms,
+                                     PHY_NR_MEASUREMENTS *phy_measurements,
+                                     int eNB_id,
+                                     unsigned char symbol,
+                                     unsigned char mod_order,
+                                     unsigned short nb_rb,
+                                     unsigned char output_shift,
+                                     unsigned char dl_power_off);
+
+
+void dlsch_channel_compensation_TM34(NR_DL_FRAME_PARMS *frame_parms,
+                                    NR_UE_PDSCH *lte_ue_pdsch_vars,
+                                    PHY_NR_MEASUREMENTS *phy_measurements,
+                                    int eNB_id,
+                                    unsigned char symbol,
+                                    unsigned char mod_order0,
+                                    unsigned char mod_order1,
+                                    int harq_pid,
+                                    int round,
+                                    MIMO_mode_t mimo_mode,
+                                    unsigned short nb_rb,
+                                    unsigned char output_shift0,
+                                    unsigned char output_shift1);
+
+
+/** \brief This function computes the average channel level over all allocated RBs and antennas (TX/RX) in order to compute output shift for compensated signal
+    @param dl_ch_estimates_ext Channel estimates in allocated RBs
+    @param frame_parms Pointer to frame descriptor
+    @param avg Pointer to average signal strength
+    @param pilots_flag Flag to indicate pilots in symbol
+    @param nb_rb Number of allocated RBs
+*/
+void dlsch_channel_level(int32_t **dl_ch_estimates_ext,
+                         NR_DL_FRAME_PARMS *frame_parms,
+                         int32_t *avg,
+                         uint8_t pilots_flag,
+                         uint16_t nb_rb);
+
+
+void dlsch_channel_level_TM34(int **dl_ch_estimates_ext,
+                              NR_DL_FRAME_PARMS *frame_parms,
+                              unsigned char *pmi_ext,
+                              int *avg_0,
+                              int *avg_1,
+                              uint8_t symbol,
+                              unsigned short nb_rb,
+                              MIMO_mode_t mimo_mode);
+
+
+void dlsch_channel_level_TM56(int32_t **dl_ch_estimates_ext,
+                              NR_DL_FRAME_PARMS *frame_parms,
+                              unsigned char *pmi_ext,
+                              int32_t *avg,
+                              uint8_t symbol_mod,
+                              uint16_t nb_rb);
+
+void dlsch_channel_level_TM7(int32_t **dl_bf_ch_estimates_ext,
+                         NR_DL_FRAME_PARMS *frame_parms,
+                         int32_t *avg,
+                         uint8_t pilots_flag,
+                         uint16_t nb_rb);
+
+void dlsch_scale_channel(int32_t **dl_ch_estimates_ext,
+                         NR_DL_FRAME_PARMS *frame_parms,
+                         NR_UE_DLSCH_t **dlsch_ue,
+                         uint8_t symbol_mod,
+                         uint16_t nb_rb);
+
+/** \brief This is the top-level entry point for DLSCH decoding in UE.  It should be replicated on several
+    threads (on multi-core machines) corresponding to different HARQ processes. The routine first
+    computes the segmentation information, followed by rate dematching and sub-block deinterleaving the of the
+    received LLRs computed by dlsch_demodulation for each transport block segment. It then calls the
+    turbo-decoding algorithm for each segment and stops after either after unsuccesful decoding of at least
+    one segment or correct decoding of all segments.  Only the segment CRCs are check for the moment, the
+    overall CRC is ignored.  Finally transport block reassembly is performed.
+    @param phy_vars_ue Pointer to ue variables
+    @param dlsch_llr Pointer to LLR values computed by dlsch_demodulation
+    @param lte_frame_parms Pointer to frame descriptor
+    @param dlsch Pointer to DLSCH descriptor
+    @param frame Frame number
+    @param subframe Subframe number
+    @param num_pdcch_symbols Number of PDCCH symbols
+    @param is_crnti indicates if PDSCH belongs to a CRNTI (necessary for parallelizing decoding threads)
+    @param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used
+    @returns 0 on success, 1 on unsuccessful decoding
+*/
+uint32_t dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
+                        int16_t *dlsch_llr,
+                        NR_DL_FRAME_PARMS *lte_frame_parms,
+                        NR_UE_DLSCH_t *dlsch,
+                        NR_DL_UE_HARQ_t *harq_process,
+                        uint32_t frame,
+                        uint8_t subframe,
+                        uint8_t harq_pid,
+                        uint8_t is_crnti,
+                        uint8_t llr8_flag);
+
+
+uint32_t dlsch_decoding_emul(PHY_VARS_NR_UE *phy_vars_ue,
+                             uint8_t subframe,
+                             PDSCH_t dlsch_id,
+                             uint8_t eNB_id);
+
+/** \brief This function is the top-level entry point to PDSCH demodulation, after frequency-domain transformation and channel estimation.  It performs
+    - RB extraction (signal and channel estimates)
+    - channel compensation (matched filtering)
+    - RE extraction (pilot, PBCH, synch. signals)
+    - antenna combining (MRC, Alamouti, cycling)
+    - LLR computation
+    This function supports TM1, 2, 3, 5, and 6.
+    @param PHY_VARS_NR_UE Pointer to PHY variables
+    @param type Type of PDSCH (SI_PDSCH,RA_PDSCH,PDSCH,PMCH)
+    @param eNB_id eNb index (Nid1) 0,1,2
+    @param eNB_id_i Interfering eNB index (Nid1) 0,1,2, or 3 in case of MU-MIMO IC receiver
+    @param subframe Subframe number
+    @param symbol Symbol on which to act (within sub-frame)
+    @param first_symbol_flag set to 1 on first DLSCH symbol
+    @param rx_type. rx_type=RX_IC_single_stream will enable interference cancellation of a second stream when decoding the first stream. In case of TM1, 2, 5, and this can cancel interference from a neighbouring cell given by eNB_id_i. In case of TM5, eNB_id_i should be set to n_connected_eNB to perform multi-user interference cancellation. In case of TM3, eNB_id_i should be set to eNB_id to perform co-channel interference cancellation; this option should be used together with an interference cancellation step [...]. In case of TM3, if rx_type=RX_IC_dual_stream, both streams will be decoded by applying the IC single stream receiver twice.
+    @param i_mod Modulation order of the interfering stream
+*/
+int32_t rx_pdsch(PHY_VARS_NR_UE *phy_vars_ue,
+                 PDSCH_t type,
+                 uint8_t eNB_id,
+                 uint8_t eNB_id_i,
+                 uint32_t frame,
+                 uint8_t subframe,
+                 uint8_t symbol,
+                 uint8_t first_symbol_flag,
+                 RX_type_t rx_type,
+                 uint8_t i_mod,
+                 uint8_t harq_pid);
+
+int32_t rx_pdcch(PHY_VARS_NR_UE *ue,
+                 uint32_t frame,
+                 uint8_t subframe,
+                 uint8_t eNB_id,
+                 MIMO_mode_t mimo_mode,
+                 uint32_t high_speed_flag);
+
+/*! \brief Extract PSS and SSS resource elements
+  @param phy_vars_ue Pointer to UE variables
+  @param[out] pss_ext contain the PSS signals after the extraction
+  @param[out] sss_ext contain the SSS signals after the extraction
+  @returns 0 on success
+*/
+int pss_sss_extract(PHY_VARS_NR_UE *phy_vars_ue,
+                    int32_t pss_ext[4][72],
+                    int32_t sss_ext[4][72],
+                                        uint8_t subframe);
+
+/*! \brief Extract only PSS resource elements
+  @param phy_vars_ue Pointer to UE variables
+  @param[out] pss_ext contain the PSS signals after the extraction
+  @returns 0 on success
+*/
+int pss_only_extract(PHY_VARS_NR_UE *phy_vars_ue,
+                    int32_t pss_ext[4][72],
+                    uint8_t subframe);
+
+/*! \brief Extract only SSS resource elements
+  @param phy_vars_ue Pointer to UE variables
+  @param[out] sss_ext contain the SSS signals after the extraction
+  @returns 0 on success
+*/
+int sss_only_extract(PHY_VARS_NR_UE *phy_vars_ue,
+                    int32_t sss_ext[4][72],
+                    uint8_t subframe);
+
+/*! \brief Performs detection of SSS to find cell ID and other framing parameters (FDD/TDD, normal/extended prefix)
+  @param phy_vars_ue Pointer to UE variables
+  @param tot_metric Pointer to variable containing maximum metric under framing hypothesis (to be compared to other hypotheses
+  @param flip_max Pointer to variable indicating if start of frame is in second have of RX buffer (i.e. PSS/SSS is flipped)
+  @param phase_max Pointer to variable (0 ... 6) containing rought phase offset between PSS and SSS (can be used for carrier
+  frequency adjustment. 0 means -pi/3, 6 means pi/3.
+  @returns 0 on success
+*/
+int rx_sss(PHY_VARS_NR_UE *phy_vars_ue,int32_t *tot_metric,uint8_t *flip_max,uint8_t *phase_max);
+
+/*! \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);
+
+uint16_t rx_pbch_emul(PHY_VARS_NR_UE *phy_vars_ue,
+                      uint8_t eNB_id,
+                      uint8_t pbch_phase);
+
+
+/*! \brief PBCH unscrambling
+  This is similar to pbch_scrabling with the difference that inputs are signed s16s (llr values) and instead of flipping bits we change signs.
+  \param frame_parms Pointer to frame descriptor
+  \param llr Output of the demodulator
+  \param length Length of the sequence
+  \param frame_mod4 Frame number modulo 4*/
+void pbch_unscrambling(NR_DL_FRAME_PARMS *frame_parms,
+                       int8_t* llr,
+                       uint32_t length,
+                       uint8_t frame_mod4);
+
+
+void generate_64qam_table(void);
+void generate_16qam_table(void);
+void generate_qpsk_table(void);
+
+uint16_t extract_crc(uint8_t *dci,uint8_t DCI_LENGTH);
+
+/*! \brief LLR from two streams. This function takes two streams (qpsk modulated) and calculates the LLR, considering one stream as interference.
+  \param stream0_in pointer to first stream0
+  \param stream1_in pointer to first stream1
+  \param stream0_out pointer to output stream
+  \param rho01 pointer to correlation matrix
+  \param length*/
+void qpsk_qpsk_TM3456(short *stream0_in,
+                      short *stream1_in,
+                      short *stream0_out,
+                      short *rho01,
+                      int length
+                     );
+
+/** \brief Attempt decoding of a particular DCI with given length and format.
+    @param DCI_LENGTH length of DCI in bits
+    @param DCI_FMT Format of DCI
+    @param e e-sequence (soft bits)
+    @param decoded_output Output of Viterbi decoder
+*/
+void dci_decoding(uint8_t DCI_LENGTH,
+                  uint8_t DCI_FMT,
+                  int8_t *e,
+                  uint8_t *decoded_output);
+
+/** \brief Do 36.213 DCI decoding procedure by searching different RNTI options and aggregation levels.  Currently does
+    not employ the complexity reducing procedure based on RNTI.
+    @param phy_vars_ue UE variables
+    @param dci_alloc Pointer to DCI_ALLOC_t array to store results for DLSCH/ULSCH programming
+    @param do_common If 1 perform search in common search-space else ue-specific search-space
+    @param eNB_id eNB Index on which to act
+    @param subframe Index of subframe
+    @returns bitmap of occupied CCE positions (i.e. those detected)
+*/
+uint16_t dci_decoding_procedure(PHY_VARS_NR_UE *phy_vars_ue,
+                                DCI_ALLOC_t *dci_alloc,
+                                int do_common,
+                                int16_t eNB_id,
+                                uint8_t subframe);
+
+uint16_t dci_CRNTI_decoding_procedure(PHY_VARS_NR_UE *ue,
+                                DCI_ALLOC_t *dci_alloc,
+                                uint8_t DCIFormat,
+                                uint8_t agregationLevel,
+                                int16_t eNB_id,
+                                uint8_t subframe);
+
+uint16_t dci_decoding_procedure_emul(NR_UE_PDCCH **lte_ue_pdcch_vars,
+                                     uint8_t num_ue_spec_dci,
+                                     uint8_t num_common_dci,
+                                     DCI_ALLOC_t *dci_alloc_tx,
+                                     DCI_ALLOC_t *dci_alloc_rx,
+                                     int16_t eNB_id);
+
+/** \brief Compute Q (modulation order) based on I_MCS PDSCH.  Implements table 7.1.7.1-1 from 36.213.
+    @param I_MCS */
+uint8_t get_Qm(uint8_t I_MCS);
+
+/** \brief Compute Q (modulation order) based on I_MCS for PUSCH.  Implements table 8.6.1-1 from 36.213.
+    @param I_MCS */
+uint8_t get_Qm_ul(uint8_t I_MCS);
+
+/** \brief Compute I_TBS (transport-block size) based on I_MCS for PDSCH.  Implements table 7.1.7.1-1 from 36.213.
+    @param I_MCS */
+uint8_t get_I_TBS(uint8_t I_MCS);
+
+/** \brief Compute I_TBS (transport-block size) based on I_MCS for PUSCH.  Implements table 8.6.1-1 from 36.213.
+    @param I_MCS */
+unsigned char get_I_TBS_UL(unsigned char I_MCS);
+
+/** \brief Compute Q (modulation order) based on downlink I_MCS. Implements table 7.1.7.1-1 from 36.213.
+    @param I_MCS
+    @param nb_rb
+    @return Transport block size */
+uint32_t get_TBS_DL(uint8_t mcs, uint16_t nb_rb);
+
+/** \brief Compute Q (modulation order) based on uplink I_MCS. Implements table 7.1.7.1-1 from 36.213.
+    @param I_MCS
+    @param nb_rb
+    @return Transport block size */
+uint32_t get_TBS_UL(uint8_t mcs, uint16_t nb_rb);
+
+/* \brief Return bit-map of resource allocation for a given DCI rballoc (RIV format) and vrb type
+   @param N_RB_DL number of PRB on DL
+   @param indicator for even/odd slot
+   @param vrb vrb index
+   @param Ngap Gap indicator
+*/
+uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap);
+
+/* \brief Return prb for a given vrb index
+   @param vrb_type VRB type (0=localized,1=distributed)
+   @param rb_alloc_dci rballoc field from DCI
+*/
+uint32_t get_rballoc(vrb_t vrb_type,uint16_t rb_alloc_dci);
+
+
+/* \brief Return bit-map of resource allocation for a given DCI rballoc (RIV format) and vrb type
+   @returns Transmission mode (1-7)
+*/
+uint8_t get_transmission_mode(module_id_t Mod_id, uint8_t CC_id, rnti_t rnti);
+
+
+/* \brief
+   @param ra_header Header of resource allocation (0,1) (See sections 7.1.6.1/7.1.6.2 of 36.213 Rel8.6)
+   @param rb_alloc Bitmap allocation from DCI (format 1,2)
+   @returns number of physical resource blocks
+*/
+uint32_t conv_nprb(uint8_t ra_header,uint32_t rb_alloc,int N_RB_DL);
+
+int get_G(NR_DL_FRAME_PARMS *frame_parms,uint16_t nb_rb,uint32_t *rb_alloc,uint8_t mod_order,uint8_t Nl,uint8_t num_pdcch_symbols,int frame,uint8_t subframe, uint8_t beamforming_mode);
+
+int adjust_G(NR_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe);
+int adjust_G2(NR_DL_FRAME_PARMS *frame_parms,uint32_t *rb_alloc,uint8_t mod_order,uint8_t subframe,uint8_t symbol);
+
+
+#ifndef modOrder
+#define modOrder(I_MCS,I_TBS) ((I_MCS-I_TBS)*2+2) // Find modulation order from I_TBS and I_MCS
+#endif
+
+/** \fn uint8_t I_TBS2I_MCS(uint8_t I_TBS);
+    \brief This function maps I_tbs to I_mcs according to Table 7.1.7.1-1 in 3GPP TS 36.213 V8.6.0. Where there is two supported modulation orders for the same I_TBS then either high or low modulation is chosen by changing the equality of the two first comparisons in the if-else statement.
+    \param I_TBS Index of Transport Block Size
+    \return I_MCS given I_TBS
+*/
+uint8_t I_TBS2I_MCS(uint8_t I_TBS);
+
+/** \fn uint8_t SE2I_TBS(float SE,
+    uint8_t N_PRB,
+    uint8_t symbPerRB);
+    \brief This function maps a requested throughput in number of bits to I_tbs. The throughput is calculated as a function of modulation order, RB allocation and number of symbols per RB. The mapping orginates in the "Transport block size table" (Table 7.1.7.2.1-1 in 3GPP TS 36.213 V8.6.0)
+    \param SE Spectral Efficiency (before casting to integer, multiply by 1024, remember to divide result by 1024!)
+    \param N_PRB Number of PhysicalResourceBlocks allocated \sa lte_frame_parms->N_RB_DL
+    \param symbPerRB Number of symbols per resource block allocated to this channel
+    \return I_TBS given an SE and an N_PRB
+*/
+uint8_t SE2I_TBS(float SE,
+                 uint8_t N_PRB,
+                 uint8_t symbPerRB);
+/** \brief This function generates the sounding reference symbol (SRS) for the uplink according to 36.211 v8.6.0. If IFFT_FPGA is defined, the SRS is quantized to a QPSK sequence.
+    @param frame_parms LTE DL Frame Parameters
+    @param soundingrs_ul_config_dedicated Dynamic configuration from RRC during Connection Establishment
+    @param txdataF pointer to the frequency domain TX signal
+    @returns 0 on success*/
+int generate_srs(NR_DL_FRAME_PARMS *frame_parms,
+		 SOUNDINGRS_UL_CONFIG_DEDICATED *soundingrs_ul_config_dedicated,
+		 int *txdataF,
+		 int16_t amp,
+		 uint32_t subframe);
+
+
+/*!
+  \brief This function is similar to generate_srs_tx but generates a conjugate sequence for channel estimation. If IFFT_FPGA is defined, the SRS is quantized to a QPSK sequence.
+  @param phy_vars_ue Pointer to PHY_VARS structure
+  @param eNB_id Index of destination eNB for this SRS
+  @param amp Linear amplitude of SRS
+  @param subframe Index of subframe on which to act
+  @returns 0 on success, -1 on error with message
+*/
+
+int32_t generate_srs_tx(PHY_VARS_NR_UE *phy_vars_ue,
+                        uint8_t eNB_id,
+                        int16_t amp,
+                        uint32_t subframe);
+
+/*!
+  \brief This function generates the downlink reference signal for the PUSCH according to 36.211 v8.6.0. The DRS occuies the RS defined by rb_alloc and the symbols 2 and 8 for extended CP and 3 and 10 for normal CP.
+*/
+
+int32_t generate_drs_pusch(PHY_VARS_NR_UE *phy_vars_ue,
+                           UE_nr_rxtx_proc_t *proc,
+                           uint8_t eNB_id,
+                           int16_t amp,
+                           uint32_t subframe,
+                           uint32_t first_rb,
+                           uint32_t nb_rb,
+                           uint8_t ant);
+
+/*!
+  \brief This function initializes the Group Hopping, Sequence Hopping and nPRS sequences for PUCCH/PUSCH according to 36.211 v8.6.0. It should be called after configuration of UE (reception of SIB2/3) and initial configuration of eNB (or after reconfiguration of cell-specific parameters).
+  @param frame_parms Pointer to a NR_DL_FRAME_PARMS structure (eNB or UE)*/
+void init_ul_hopping(NR_DL_FRAME_PARMS *frame_parms);
+
+
+/*!
+  \brief This function implements the initialization of paging parameters for UE (See Section 7, 36.304).It must be called after setting IMSImod1024 during UE startup and after receiving SIB2
+  @param ue Pointer to UE context
+  @param defaultPagingCycle T from 36.304 (0=32,1=64,2=128,3=256)
+  @param nB nB from 36.304 (0=4T,1=2T,2=T,3=T/2,4=T/4,5=T/8,6=T/16,7=T/32*/
+int init_ue_paging_info(PHY_VARS_NR_UE *ue, long defaultPagingCycle, long nB);
+
+int32_t compareints (const void * a, const void * b);
+
+
+void ulsch_modulation(int32_t **txdataF,
+                      int16_t amp,
+                      frame_t frame,
+                      uint32_t subframe,
+                      NR_DL_FRAME_PARMS *frame_parms,
+                      NR_UE_ULSCH_t *ulsch);
+
+
+
+
+
+
+int generate_ue_dlsch_params_from_dci(int frame,
+                                      uint8_t subframe,
+                                      void *dci_pdu,
+                                      rnti_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);
+
+
+int generate_ue_ulsch_params_from_dci(void *dci_pdu,
+                                      rnti_t rnti,
+                                      uint8_t subframe,
+                                      DCI_format_t dci_format,
+                                      PHY_VARS_NR_UE *phy_vars_ue,
+                                      UE_nr_rxtx_proc_t *proc,
+                                      uint16_t si_rnti,
+                                      uint16_t ra_rnti,
+                                      uint16_t p_rnti,
+                                      uint16_t cba_rnti,
+                                      uint8_t eNB_id,
+                                      uint8_t use_srs);
+
+int32_t generate_ue_ulsch_params_from_rar(PHY_VARS_NR_UE *phy_vars_ue,
+                                          UE_nr_rxtx_proc_t *proc,
+                                          uint8_t eNB_id);
+double sinr_eff_cqi_calc(PHY_VARS_NR_UE *phy_vars_ue,
+                         uint8_t eNB_id,
+                                                 uint8_t subframe);
+
+uint8_t sinr2cqi(double sinr,uint8_t trans_mode);
+
+
+int dump_dci(NR_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci);
+
+int dump_ue_stats(PHY_VARS_NR_UE *phy_vars_ue, UE_nr_rxtx_proc_t *proc, char* buffer, int length, runmode_t mode, int input_level_dBm);
+
+
+
+void generate_pcfich_reg_mapping(NR_DL_FRAME_PARMS *frame_parms);
+
+
+void pcfich_unscrambling(NR_DL_FRAME_PARMS *frame_parms,
+                         uint8_t subframe,
+                         int16_t *d);
+
+
+uint8_t rx_pcfich(NR_DL_FRAME_PARMS *frame_parms,
+                  uint8_t subframe,
+                  NR_UE_PDCCH *lte_ue_pdcch_vars,
+                  MIMO_mode_t mimo_mode);
+
+void generate_phich_reg_mapping(NR_DL_FRAME_PARMS *frame_parms);
+
+
+void init_transport_channels(uint8_t);
+
+void generate_RIV_tables(void);
+
+/*!
+  \brief This function performs the initial cell search procedure - PSS detection, SSS detection and PBCH detection.  At the
+  end, the basic frame parameters are known (Frame configuration - TDD/FDD and cyclic prefix length,
+  N_RB_DL, PHICH_CONFIG and Nid_cell) and the UE can begin decoding PDCCH and DLSCH SI to retrieve the rest.  Once these
+  parameters are know, the routine calls some basic initialization routines (cell-specific reference signals, etc.)
+  @param phy_vars_ue Pointer to UE variables
+*/
+int initial_sync(PHY_VARS_NR_UE *phy_vars_ue, runmode_t mode);
+
+
+/*!
+  \brief Encoding of PUSCH/ACK/RI/ACK from 36-212.
+  @param a Pointer to ulsch SDU
+  @param frame_parms Pointer to Frame parameters
+  @param ulsch Pointer to ulsch descriptor
+  @param harq_pid HARQ process ID
+  @param tmode Transmission mode (1-7)
+  @param control_only_flag Generate PUSCH with control information only
+  @param Nbundled Parameter for ACK/NAK bundling (36.213 Section 7.3)
+*/
+uint32_t ulsch_encoding(uint8_t *a,
+                        PHY_VARS_NR_UE *phy_vars_ue,
+                        uint8_t harq_pid,
+                        uint8_t eNB_id,
+                        uint8_t subframe_rx,
+                        uint8_t tmode,
+                        uint8_t control_only_flag,
+                        uint8_t Nbundled);
+
+
+
+
+/* \brief  This routine demodulates the PHICH and updates PUSCH/ULSCH parameters.
+   @param phy_vars_ue Pointer to UE variables
+   @param proc Pointer to RXN_TXNp4 proc
+   @param subframe Subframe of received PDCCH/PHICH
+   @param eNB_id Index of eNB
+*/
+
+void rx_phich(PHY_VARS_NR_UE *phy_vars_ue,
+              UE_nr_rxtx_proc_t *proc,
+              uint8_t subframe,
+              uint8_t eNB_id);
+
+
+/** \brief  This routine provides the relationship between a PHICH TXOp and its corresponding PUSCH subframe (Table 8.3.-1 from 36.213).
+    @param frame_parms Pointer to DL frame configuration parameters
+    @param subframe Subframe of received/transmitted PHICH
+    @returns subframe of PUSCH transmission
+*/
+uint8_t phich_subframe2_pusch_subframe(NR_DL_FRAME_PARMS *frame_parms,uint8_t subframe);
+
+/** \brief  This routine provides the relationship between a PHICH TXOp and its corresponding PUSCH frame (Table 8.3.-1 from 36.213).
+    @param frame_parms Pointer to DL frame configuration parameters
+    @param frame Frame of received/transmitted PHICH
+    @param subframe Subframe of received/transmitted PHICH
+    @returns frame of PUSCH transmission
+*/
+int phich_frame2_pusch_frame(NR_DL_FRAME_PARMS *frame_parms, int frame, int subframe);
+
+void print_CQI(void *o,UCI_format_t uci_format,uint8_t eNB_id,int N_RB_DL);
+
+void fill_CQI(NR_UE_ULSCH_t *ulsch,PHY_NR_MEASUREMENTS *meas,uint8_t eNB_id, uint8_t harq_pid,int N_RB_DL, rnti_t rnti, uint8_t trans_mode,double sinr_eff);
+
+void reset_cba_uci(void *o);
+
+/** \brief  This routine computes the subband PMI bitmap based on measurements (0,1,2,3 for rank 0 and 0,1 for rank 1) in the format needed for UCI
+    @param meas pointer to measurements
+    @param eNB_id eNB_id
+    @param nb_subbands number of subbands
+    @returns subband PMI bitmap
+*/
+uint16_t quantize_subband_pmi(PHY_NR_MEASUREMENTS *meas,uint8_t eNB_id,int nb_subbands);
+
+int32_t pmi_convert_rank1_from_rank2(uint16_t pmi_alloc, int tpmi, int nb_rb);
+
+uint16_t quantize_subband_pmi2(PHY_NR_MEASUREMENTS *meas,uint8_t eNB_id,uint8_t a_id,int nb_subbands);
+
+
+
+uint64_t cqi2hex(uint32_t cqi);
+
+uint16_t computeRIV(uint16_t N_RB_DL,uint16_t RBstart,uint16_t Lcrbs);
+
+
+/** \brief  This routine extracts a single subband PMI from a bitmap coming from UCI or the pmi_extend function
+    @param N_RB_DL number of resource blocks
+    @param mimo_mode
+    @param pmi_alloc subband PMI bitmap
+    @param rb resource block for which to extract PMI
+    @returns subband PMI
+*/
+uint8_t get_pmi(uint8_t N_RB_DL,MIMO_mode_t mode, uint32_t pmi_alloc,uint16_t rb);
+
+int get_nCCE_offset_l1(int *CCE_table,
+                       const unsigned char L,
+                       const int nCCE,
+                       const int common_dci,
+                       const unsigned short rnti,
+                       const unsigned char subframe);
+
+uint16_t get_nCCE(uint8_t num_pdcch_symbols,NR_DL_FRAME_PARMS *frame_parms,uint8_t mi);
+
+uint16_t get_nquad(uint8_t num_pdcch_symbols,NR_DL_FRAME_PARMS *frame_parms,uint8_t mi);
+
+uint8_t get_mi(NR_DL_FRAME_PARMS *frame,uint8_t subframe);
+
+uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe);
+
+uint8_t get_num_pdcch_symbols(uint8_t num_dci,DCI_ALLOC_t *dci_alloc,NR_DL_FRAME_PARMS *frame_parms,uint8_t subframe);
+
+void pdcch_interleaving(NR_DL_FRAME_PARMS *frame_parms,int32_t **z, int32_t **wbar,uint8_t n_symbols_pdcch,uint8_t mi);
+
+void pdcch_unscrambling(NR_DL_FRAME_PARMS *frame_parms,
+                        uint8_t subframe,
+                        int8_t* llr,
+                        uint32_t length);
+
+
+
+void dlsch_unscrambling(NR_DL_FRAME_PARMS *frame_parms,
+                        int mbsfn_flag,
+                        NR_UE_DLSCH_t *dlsch,
+                        int G,
+                        int16_t* llr,
+                        uint8_t q,
+                        uint8_t Ns);
+
+void init_ncs_cell(NR_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7]);
+
+void generate_pucch1x(int32_t **txdataF,
+                      NR_DL_FRAME_PARMS *frame_parms,
+                      uint8_t ncs_cell[20][7],
+                      PUCCH_FMT_t fmt,
+                      PUCCH_CONFIG_DEDICATED *pucch_config_dedicated,
+                      uint16_t n1_pucch,
+                      uint8_t shortened_format,
+                      uint8_t *payload,
+                      int16_t amp,
+                      uint8_t subframe);
+
+void generate_pucch2x(int32_t **txdataF,
+                      NR_DL_FRAME_PARMS *fp,
+                      uint8_t ncs_cell[20][7],
+                      PUCCH_FMT_t fmt,
+                      PUCCH_CONFIG_DEDICATED *pucch_config_dedicated,
+                      uint16_t n2_pucch,
+                      uint8_t *payload,
+                      int A,
+                      int B2,
+                      int16_t amp,
+                      uint8_t subframe,
+                      uint16_t rnti);
+
+void generate_pucch3x(int32_t **txdataF,
+                    NR_DL_FRAME_PARMS *frame_parms,
+                    uint8_t ncs_cell[20][7],
+                    PUCCH_FMT_t fmt,
+                    PUCCH_CONFIG_DEDICATED *pucch_config_dedicated,
+                    uint16_t n3_pucch,
+                    uint8_t shortened_format,
+                    uint8_t *payload,
+                    int16_t amp,
+                    uint8_t subframe,
+                    uint16_t rnti);
+
+
+void init_ulsch_power_LUT(void);
+
+/*!
+  \brief Check for PRACH TXop in subframe
+  @param frame_parms Pointer to NR_DL_FRAME_PARMS
+  @param frame frame index to check
+  @param subframe subframe index to check
+  @returns 0 on success
+*/
+int is_prach_subframe(NR_DL_FRAME_PARMS *frame_parms,frame_t frame, uint8_t subframe);
+
+/*!
+  \brief Generate PRACH waveform
+  @param phy_vars_ue Pointer to ue top-level descriptor
+  @param eNB_id Index of destination eNB
+  @param subframe subframe index to operate on
+  @param index of preamble (0-63)
+  @param Nf System frame number
+  @returns 0 on success
+
+*/
+int32_t generate_prach(PHY_VARS_NR_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subframe,uint16_t Nf);
+
+
+/*!
+  \brief Helper for MAC, returns number of available PRACH in TDD for a particular configuration index
+  @param frame_parms Pointer to NR_DL_FRAME_PARMS structure
+  @returns 0-5 depending on number of available prach
+*/
+uint8_t get_num_prach_tdd(module_id_t Mod_id);
+
+/*!
+  \brief Return the PRACH format as a function of the Configuration Index and Frame type.
+  @param prach_ConfigIndex PRACH Configuration Index
+  @param frame_type 0-FDD, 1-TDD
+  @returns 0-1 accordingly
+*/
+uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type);
+
+/*!
+  \brief Helper for MAC, returns frequency index of PRACH resource in TDD for a particular configuration index
+  @param frame_parms Pointer to NR_DL_FRAME_PARMS structure
+  @returns 0-5 depending on number of available prach
+*/
+uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index);
+
+/*!
+  \brief Comp ute DFT of PRACH ZC sequences.  Used for generation of prach in UE and reception of PRACH in eNB.
+  @param rootSequenceIndex PRACH root sequence
+  #param prach_ConfigIndex PRACH Configuration Index
+  @param zeroCorrelationZoneConfig PRACH ncs_config
+  @param highSpeedFlat PRACH High-Speed Flag
+  @param frame_type TDD/FDD flag
+  @param Xu DFT output
+*/
+void compute_prach_seq(uint16_t rootSequenceIndex,
+		       uint8_t prach_ConfigIndex,
+		       uint8_t zeroCorrelationZoneConfig,
+		       uint8_t highSpeedFlag,
+		       lte_frame_type_t frame_type,
+		       uint32_t X_u[64][839]);
+
+
+void init_prach_tables(int N_ZC);
+
+void init_unscrambling_lut(void);
+void init_scrambling_lut(void);
+
+/*!
+  \brief Return the status of MBSFN in this frame/subframe
+  @param frame Frame index
+  @param subframe Subframe index
+  @param frame_parms Pointer to frame parameters
+  @returns 1 if subframe is for MBSFN
+*/
+int is_pmch_subframe(frame_t frame, int subframe, NR_DL_FRAME_PARMS *frame_parms);
+
+uint8_t is_not_pilot(uint8_t pilots, uint8_t re, uint8_t nushift, uint8_t use2ndpilots);
+
+uint8_t is_not_UEspecRS(int8_t lprime, uint8_t re, uint8_t nushift, uint8_t Ncp, uint8_t beamforming_mode);
+
+uint32_t dlsch_decoding_abstraction(double *dlsch_MIPB,
+                                    NR_DL_FRAME_PARMS *lte_frame_parms,
+                                    NR_UE_DLSCH_t *dlsch,
+                                    uint8_t subframe,
+                                    uint8_t num_pdcch_symbols);
+
+// DL power control functions
+double get_pa_dB(uint8_t pa);
+
+
+double computeRhoA_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
+                      NR_UE_DLSCH_t *dlsch_ue,
+                      uint8_t dl_power_off,
+                      uint8_t n_antenna_port);
+
+double computeRhoB_UE(PDSCH_CONFIG_DEDICATED  *pdsch_config_dedicated,
+                      PDSCH_CONFIG_COMMON *pdsch_config_common,
+                      uint8_t n_antenna_port,
+                      NR_UE_DLSCH_t *dlsch_ue,
+                      uint8_t dl_power_off);
+
+/*void compute_sqrt_RhoAoRhoB(PDSCH_CONFIG_DEDICATED  *pdsch_config_dedicated,
+  PDSCH_CONFIG_COMMON *pdsch_config_common,
+  uint8_t n_antenna_port,
+  NR_UE_DLSCH_t *dlsch_ue);
+*/
+
+uint8_t get_prach_prb_offset(NR_DL_FRAME_PARMS *frame_parms,
+			     uint8_t prach_ConfigIndex, 
+			     uint8_t n_ra_prboffset,
+			     uint8_t tdd_mapindex, uint16_t Nf);
+
+
+
+
+
+/**@}*/
+#endif
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
new file mode 100644
index 0000000000000000000000000000000000000000..3ff99c12d6f7a8d64dddba1884cf7fd1ff87853e
--- /dev/null
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
@@ -0,0 +1,335 @@
+/*
+ * 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/defs.h
+* \brief data structures for PDSCH/DLSCH/PUSCH/ULSCH physical and transport channel descriptors (TX/RX)
+* \author R. Knopp
+* \date 2011
+* \version 0.1
+* \company Eurecom
+* \email: raymond.knopp@eurecom.fr, florian.kaltenberger@eurecom.fr, oscar.tonelli@yahoo.it
+* \note
+* \warning
+*/
+#ifndef __NR_TRANSPORT_UE__H__
+#define __NR_TRANSPORT_UE__H__
+#include "PHY/defs_nr_UE.h"
+//#include "../LTE_TRANSPORT/dci.h"
+//#include "../LTE_TRANSPORT/mdci.h"
+//#include "../LTE_TRANSPORT/uci_common.h"
+//#include "../LTE_TRANSPORT/transport_common.h"
+#ifndef STANDALONE_COMPILE
+#include "UTIL/LISTS/list.h"
+#endif
+
+//#include "../LTE_TRANSPORT/transport_common.h"
+
+// structures below implement 36-211 and 36-212
+
+/** @addtogroup _PHY_TRANSPORT_
+ * @{
+ */
+
+#define SHRT_MAX   32767
+
+typedef struct {
+  /// Indicator of first transmission
+  uint8_t first_tx;
+  /// Last Ndi received for this process on DCI (used for C-RNTI only)
+  uint8_t DCINdi;
+  /// Flag indicating that this ULSCH has a new packet (start of new round)
+  //  uint8_t Ndi;
+  /// Status Flag indicating for this ULSCH (idle,active,disabled)
+  SCH_status_t status;
+  /// Subframe scheduling indicator (i.e. Transmission opportunity indicator)
+  uint8_t subframe_scheduling_flag;
+  /// Subframe cba scheduling indicator (i.e. Transmission opportunity indicator)
+  uint8_t subframe_cba_scheduling_flag;
+  /// First Allocated RB
+  uint16_t first_rb;
+  /// Current Number of RBs
+  uint16_t nb_rb;
+  /// Last TPC command
+  uint8_t TPC;
+  /// Transport block size
+  uint32_t TBS;
+  /// The payload + CRC size in bits, "B" from 36-212
+  uint32_t B;
+  /// Length of ACK information (bits)
+  uint8_t O_ACK;
+  /// Pointer to the payload
+  uint8_t *b;
+  /// Pointers to transport block segments
+  uint8_t *c[MAX_NUM_ULSCH_SEGMENTS];
+  /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
+  uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS];
+  /// Index of current HARQ round for this ULSCH
+  uint8_t round;
+  /// MCS format of this ULSCH
+  uint8_t mcs;
+  /// Redundancy-version of the current sub-frame
+  uint8_t rvidx;
+  /// Turbo-code outputs (36-212 V8.6 2009-03, p.12
+  uint8_t d[MAX_NUM_ULSCH_SEGMENTS][(96+3+(3*6144))];
+  /// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17)
+  uint8_t w[MAX_NUM_ULSCH_SEGMENTS][3*6144];
+  /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
+  uint32_t C;
+  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
+  uint32_t Cminus;
+  /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
+  uint32_t Cplus;
+  /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
+  uint32_t Kminus;
+  /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
+  uint32_t Kplus;
+  /// Total number of bits across all segments
+  uint32_t sumKr;
+  /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
+  uint32_t F;
+  /// Msc_initial, Initial number of subcarriers for ULSCH (36-212, v8.6 2009-03, p.26-27)
+  uint16_t Msc_initial;
+  /// Nsymb_initial, Initial number of symbols for ULSCH (36-212, v8.6 2009-03, p.26-27)
+  uint8_t Nsymb_initial;
+  /// n_DMRS  for cyclic shift of DMRS (36.213 Table 9.1.2-2)
+  uint8_t n_DMRS;
+  /// n_DMRS2 for cyclic shift of DMRS (36.211 Table 5.5.1.1.-1)
+  uint8_t n_DMRS2;
+  /// Flag to indicate that this is a control only ULSCH (i.e. no MAC SDU)
+  uint8_t control_only;
+  /// Flag to indicate that this is a calibration ULSCH (i.e. no MAC SDU and filled with TDD calibration information)
+  //  int calibration_flag;
+  /// Number of soft channel bits
+  uint32_t G;
+
+  // decode phich
+  uint8_t decode_phich;
+} NR_UL_UE_HARQ_t;
+
+typedef struct {
+  /// Current Number of Symbols
+  uint8_t Nsymb_pusch;
+  /// SRS active flag
+  uint8_t srs_active;
+  /// Pointers to 8 HARQ processes for the ULSCH
+  NR_UL_UE_HARQ_t *harq_processes[8];
+  /// Pointer to CQI data (+1 for 8 bits crc)
+  uint8_t o[1+MAX_CQI_BYTES];
+  /// Length of CQI data (bits)
+  uint8_t O;
+  /// Format of CQI data
+  UCI_format_t uci_format;
+  /// Rank information
+  uint8_t o_RI[2];
+  /// Length of rank information (bits)
+  uint8_t O_RI;
+  /// Pointer to ACK
+  uint8_t o_ACK[4];
+  /// Minimum number of CQI bits for PUSCH (36-212 r8.6, Sec 5.2.4.1 p. 37)
+  uint8_t O_CQI_MIN;
+  /// ACK/NAK Bundling flag
+  uint8_t bundling;
+  /// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
+  uint8_t e[MAX_NUM_CHANNEL_BITS];
+  /// Interleaved "h"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
+  uint8_t h[MAX_NUM_CHANNEL_BITS];
+  /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
+  uint8_t b_tilde[MAX_NUM_CHANNEL_BITS];
+  /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
+  int32_t d[MAX_NUM_RE];
+  /// Transform-coded "z"-sequences (for definition see 36-211 V8.6 2009-03, p.14-15)
+  int32_t z[MAX_NUM_RE];
+  /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27)
+  uint8_t q[MAX_CQI_PAYLOAD];
+  /// coded and interleaved CQI bits
+  uint8_t o_w[(MAX_CQI_BITS+8)*3];
+  /// coded CQI bits
+  uint8_t o_d[96+((MAX_CQI_BITS+8)*3)];
+  /// coded ACK bits
+  uint8_t q_ACK[MAX_ACK_PAYLOAD];
+  /// coded RI bits
+  uint8_t q_RI[MAX_RI_PAYLOAD];
+  /// beta_offset_cqi times 8
+  uint16_t beta_offset_cqi_times8;
+  /// beta_offset_ri times 8
+  uint16_t beta_offset_ri_times8;
+  /// beta_offset_harqack times 8
+  uint16_t beta_offset_harqack_times8;
+  /// power_offset
+  uint8_t power_offset;
+  // for cooperative communication
+  uint8_t cooperation_flag;
+  /// RNTI attributed to this ULSCH
+  uint16_t rnti;
+  /// f_PUSCH parameter for PUSCH power control
+  int16_t f_pusch;
+  /// Po_PUSCH - target output power for PUSCH
+  int16_t Po_PUSCH;
+  /// PHR - current power headroom (based on last PUSCH transmission)
+  int16_t PHR;
+  /// Po_SRS - target output power for SRS
+  int16_t Po_SRS;
+  /// num active cba group
+  uint8_t num_active_cba_groups;
+  /// num dci found for cba
+  uint8_t num_cba_dci[10];
+  /// allocated CBA RNTI
+  uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
+  /// UL max-harq-retransmission
+  uint8_t Mlimit;
+} NR_UE_ULSCH_t;
+
+
+
+
+typedef struct {
+  /// Indicator of first transmission
+  uint8_t first_tx;
+  /// Last Ndi received for this process on DCI (used for C-RNTI only)
+  uint8_t DCINdi;
+  /// DLSCH status flag indicating
+  SCH_status_t status;
+  /// Transport block size
+  uint32_t TBS;
+  /// The payload + CRC size in bits
+  uint32_t B;
+  /// Pointer to the payload
+  uint8_t *b;
+  /// Pointers to transport block segments
+  uint8_t *c[MAX_NUM_DLSCH_SEGMENTS];
+  /// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
+  uint32_t RTC[MAX_NUM_DLSCH_SEGMENTS];
+  /// Index of current HARQ round for this DLSCH
+  uint8_t round;
+  /// MCS format for this DLSCH
+  uint8_t mcs;
+  /// Qm (modulation order) for this DLSCH
+  uint8_t Qm;
+  /// Redundancy-version of the current sub-frame
+  uint8_t rvidx;
+  /// MIMO mode for this DLSCH
+  MIMO_mode_t mimo_mode;
+  /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
+  int16_t w[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)];
+  /// for abstraction soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
+  double w_abs[MAX_NUM_DLSCH_SEGMENTS][3*(6144+64)];
+  /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
+  int16_t *d[MAX_NUM_DLSCH_SEGMENTS];
+  /// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
+  uint32_t C;
+  /// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
+  uint32_t Cminus;
+  /// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
+  uint32_t Cplus;
+  /// Number of bits in "small" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
+  uint32_t Kminus;
+  /// Number of bits in "large" code segments (<6144) (for definition see 36-212 V8.6 2009-03, p.10)
+  uint32_t Kplus;
+  /// Number of "Filler" bits (for definition see 36-212 V8.6 2009-03, p.10)
+  uint32_t F;
+  /// Number of MIMO layers (streams) (for definition see 36-212 V8.6 2009-03, p.17)
+  uint8_t Nl;
+  /// current delta_pucch
+  int8_t delta_PUCCH;
+  /// Number of soft channel bits
+  uint32_t G;
+  /// Current Number of RBs
+  uint16_t nb_rb;
+  /// Current subband PMI allocation
+  uint16_t pmi_alloc;
+  /// Current RB allocation (even slots)
+  uint32_t rb_alloc_even[4];
+  /// Current RB allocation (odd slots)
+  uint32_t rb_alloc_odd[4];
+  /// distributed/localized flag
+  vrb_t vrb_type;
+  /// downlink power offset field
+  uint8_t dl_power_off;
+  /// trials per round statistics
+  uint32_t trials[8];
+  /// error statistics per round
+  uint32_t errors[8];
+  /// codeword this transport block is mapped to
+  uint8_t codeword;
+} NR_DL_UE_HARQ_t;
+
+
+typedef struct {
+  /// HARQ process id
+  uint8_t harq_id;
+  /// ACK bits (after decoding) 0:NACK / 1:ACK / 2:DTX
+  uint8_t ack;
+  /// send status (for PUCCH)
+  uint8_t send_harq_status;
+  /// nCCE (for PUCCH)
+  uint8_t nCCE;
+  /// DAI value detected from DCI1/1a/1b/1d/2/2a/2b/2c. 0xff indicates not touched
+  uint8_t vDAI_DL;
+  /// DAI value detected from DCI0/4. 0xff indicates not touched
+  uint8_t vDAI_UL;
+} nr_harq_status_t;
+
+typedef struct {
+  /// RNTI
+  uint16_t rnti;
+  /// Active flag for DLSCH demodulation
+  uint8_t active;
+  /// Transmission mode
+  uint8_t mode1_flag;
+  /// amplitude of PDSCH (compared to RS) in symbols without pilots
+  int16_t sqrt_rho_a;
+  /// amplitude of PDSCH (compared to RS) in symbols containing pilots
+  int16_t sqrt_rho_b;
+  /// Current HARQ process id threadRx Odd and threadRx Even
+  uint8_t current_harq_pid;
+  /// Current subband antenna selection
+  uint32_t antenna_alloc;
+  /// Current subband RI allocation
+  uint32_t ri_alloc;
+  /// Current subband CQI1 allocation
+  uint32_t cqi_alloc1;
+  /// Current subband CQI2 allocation
+  uint32_t cqi_alloc2;
+  /// saved subband PMI allocation from last PUSCH/PUCCH report
+  uint16_t pmi_alloc;
+  /// HARQ-ACKs
+  nr_harq_status_t harq_ack[10];
+  /// Pointers to up to 8 HARQ processes
+  NR_DL_UE_HARQ_t *harq_processes[8];
+  /// Maximum number of HARQ processes(for definition see 36-212 V8.6 2009-03, p.17
+  uint8_t Mdlharq;
+  /// MIMO transmission mode indicator for this sub-frame (for definition see 36-212 V8.6 2009-03, p.17)
+  uint8_t Kmimo;
+  /// Nsoft parameter related to UE Category
+  uint32_t Nsoft;
+  /// Maximum number of Turbo iterations
+  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;
+
+
+
+
+/**@}*/
+#endif
diff --git a/openair1/PHY/NR_UE_TRANSPORT/pbch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pbch_nr.c
new file mode 100644
index 0000000000000000000000000000000000000000..334faafecd4f0593d2d2b623bb29064468b68a10
--- /dev/null
+++ b/openair1/PHY/NR_UE_TRANSPORT/pbch_nr.c
@@ -0,0 +1,100 @@
+/*
+ * 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
+ */
+
+/**********************************************************************
+*
+* FILENAME    :  pbch_nr.c
+*
+* MODULE      :  broacast channel
+*
+* DESCRIPTION :  generation of pbch
+*                3GPP TS 38.211 7.3.3 Physical broadcast channel
+*
+************************************************************************/
+
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+
+#include "PHY/defs.h"
+
+#define DEFINE_VARIABLES_PBCH_NR_H
+#include "PHY/NR_REFSIG/pbch_nr.h"
+#undef DEFINE_VARIABLES_PBCH_NR_H
+
+/*******************************************************************
+*
+* NAME :         pseudo_random_gold_sequence
+*
+* PARAMETERS :
+*
+* RETURN :       generate pseudo-random sequence which is a length-31 Gold sequence
+*
+* DESCRIPTION :  3GPP TS 38.211 5.2.1 Pseudo-random sequence generation
+*                Sequence generation
+*
+*********************************************************************/
+
+#define NC           (1600)
+#define GOLD_LENGTH  (31)
+
+uint32_t *pseudo_random_gold_sequence(length M_PN, uint32_t cinit)
+{
+  int size = M_PN * sizeof(uint32_t);
+  int size_x = (sizeof(int)*M_PN + size;
+  int *x1 = malloc(size_x);
+  int *x2 = malloc(size_x);
+
+  if ((x1 == NULL) || (x2 == NULL)) {
+    msg("Fatal memory allocation problem \n");
+	assert(0);
+  }
+  else {
+    bzero(x1, size_x);
+    bzero(x2, size_x);
+  }
+
+  x1[0] = 1;
+
+  for (n = 0; n < 31; n++) {
+     x2[n] = (cinit >> n) & 0x1;
+  }
+
+  for (int n = 0; n < (NC+M_PN); n++) {
+    x1(n+31) = (x1(n+3) + x1(n))%2;
+    x2(n+31) = (x2(n+3) + x2(n+2) + x2(n+1) + x2(n))%2;
+  }
+
+  int *c = calloc(size);
+  if (c != NULL) {
+    bzero(c, size);
+  }
+  else {
+   msg("Fatal memory allocation problem \n");
+   assert(0);
+  }
+
+  for (int n = 0; n < M_PN; n++) {
+    c(i) = (x1(n+NC) + x2(n+NC))%2;
+  }
+
+  return c;
+}
diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c
new file mode 100644
index 0000000000000000000000000000000000000000..216273c8a0afa11c6e687c42563bf6e82c63393a
--- /dev/null
+++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c
@@ -0,0 +1,873 @@
+/*
+ * 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
+ */
+
+/**********************************************************************
+*
+* FILENAME    :  pss_nr.c
+*
+* MODULE      :  synchronisation signal
+*
+* DESCRIPTION :  generation of pss
+*                3GPP TS 38.211 7.4.2.2 Primary synchronisation signal
+*
+************************************************************************/
+
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+
+#include "PHY/defs_nr_UE.h"
+
+#include "PHY/NR_REFSIG/ss_pbch_nr.h"
+
+#define DEFINE_VARIABLES_PSS_NR_H
+#include "PHY/NR_REFSIG/pss_nr.h"
+#undef DEFINE_VARIABLES_PSS_NR_H
+
+#include "PHY/NR_REFSIG/sss_nr.h"
+#include "PHY/NR_UE_TRANSPORT/cic_filter_nr.h"
+
+/*******************************************************************
+*
+* NAME :         get_idft
+*
+* PARAMETERS :   size of ofdm symbol
+*
+* RETURN :       function idft
+*
+* DESCRIPTION :  get idft function depending of ofdm size
+*
+*********************************************************************/
+
+void *get_idft(int ofdm_symbol_size)
+{
+  void (*idft)(int16_t *,int16_t *, int);
+
+  switch (ofdm_symbol_size) {
+    case 128:
+      idft = idft128;
+      break;
+
+    case 256:
+      idft = idft256;
+      break;
+
+    case 512:
+      idft = idft512;
+      break;
+
+    case 1024:
+      idft = idft1024;
+      break;
+
+    case 1536:
+      idft = idft1536;
+      break;
+
+    case 2048:
+      idft = idft2048;
+      break;
+
+    default:
+      printf("function get_idft : unsupported ofdm symbol size \n");
+      assert(0);
+      break;
+ }
+ return idft;
+}
+
+/*******************************************************************
+*
+* NAME :         get_dft
+*
+* PARAMETERS :   size of ofdm symbol
+*
+* RETURN :       function for discrete fourier transform
+*
+* DESCRIPTION :  get dft function depending of ofdm size
+*
+*********************************************************************/
+
+void *get_dft(int ofdm_symbol_size)
+{
+  void (*dft)(int16_t *,int16_t *, int);
+
+  switch (ofdm_symbol_size) {
+    case 128:
+      dft = dft128;
+      break;
+
+    case 256:
+      dft = dft256;
+      break;
+
+    case 512:
+      dft = dft512;
+      break;
+
+    case 1024:
+      dft = dft1024;
+      break;
+
+    case 1536:
+      dft = dft1536;
+      break;
+
+    case 2048:
+      dft = dft2048;
+      break;
+
+    default:
+      printf("function get_dft : unsupported ofdm symbol size \n");
+      assert(0);
+      break;
+ }
+ return dft;
+}
+
+/*******************************************************************
+*
+* NAME :         generate_pss_nr
+*
+* PARAMETERS :   N_ID_2 : element 2 of physical layer cell identity
+*                value : { 0, 1, 2}
+*
+* RETURN :       generate binary pss sequence (this is a m-sequence)
+*
+* DESCRIPTION :  3GPP TS 38.211 7.4.2.2 Primary synchronisation signal
+*                Sequence generation
+*
+*********************************************************************/
+
+void generate_pss_nr(int N_ID_2, int ofdm_symbol_size)
+{
+  int16_t d_pss[LENGTH_PSS_NR];
+  int16_t x[LENGTH_PSS_NR];
+  int16_t *primary_synchro_time = primary_synchro_time_nr[N_ID_2];
+  unsigned int length = ofdm_symbol_size;
+  unsigned int size = length * IQ_SIZE; /* i & q */
+  int16_t *primary_synchro = primary_synchro_nr[N_ID_2]; /* pss in complex with alternatively i then q */
+  void (*idft)(int16_t *,int16_t *, int);
+
+  #define INITIAL_PSS_NR    (7)
+  const int x_initial[INITIAL_PSS_NR] = {0, 1, 1 , 0, 1, 1, 1};
+
+  assert(N_ID_2 < NUMBER_PSS_SEQUENCE);
+  assert(size <= SYNCF_TMP_SIZE);
+  assert(size <= SYNC_TMP_SIZE);
+
+  bzero(synchroF_tmp, size);
+  bzero(synchro_tmp, size);
+
+  for (int i=0; i < INITIAL_PSS_NR; i++) {
+    x[i] = x_initial[i];
+  }
+
+  for (int i=0; i < (LENGTH_PSS_NR - INITIAL_PSS_NR); i++) {
+    x[i+INITIAL_PSS_NR] = (x[i + 4] + x[i])%(2);
+  }
+
+  for (int n=0; n < LENGTH_PSS_NR; n++) {
+	int m = (n + 43*N_ID_2)%(LENGTH_PSS_NR);
+    d_pss[n] = 1 - 2*x[m];
+  }
+
+  /* PSS is directly mapped to subcarrier without modulation 38.211 */
+  for (int i=0; i < LENGTH_PSS_NR; i++) {
+#if 1
+    primary_synchro[2*i] = (d_pss[i] * SHRT_MAX)>>SCALING_PSS_NR; /* Maximum value for type short int ie int16_t */
+    primary_synchro[2*i+1] = 0;
+#else
+    primary_synchro[2*i] = d_pss[i] * AMP;
+    primary_synchro[2*i+1] = 0;
+#endif
+  }
+
+#ifdef DBG_PSS_NR
+
+  if (N_ID_2 == 0) {
+    char output_file[255];
+    char sequence_name[255];
+    sprintf(output_file, "pss_seq_%d_%d.m", N_ID_2, length);
+    sprintf(sequence_name, "pss_seq_%d_%d", N_ID_2, length);
+    printf("file %s sequence %s\n", output_file, sequence_name);
+
+    write_output(output_file, sequence_name, primary_synchro, LENGTH_PSS_NR, 1, 1);
+  }
+
+#endif
+
+  /* call of IDFT should be done with ordered input as below
+  *
+  *                n input samples
+  *  <------------------------------------------------>
+  *  0                                                n
+  *  are written into input buffer for IFFT
+  *   -------------------------------------------------
+  *  |xxxxxxx                       N/2       xxxxxxxx|
+  *  --------------------------------------------------
+  *  ^      ^                 ^               ^          ^
+  *  |      |                 |               |          |
+  * n/2    end of            n=0            start of    n/2-1
+  *         pss                               pss
+  *
+  *                   Frequencies
+  *      positives                   negatives
+  * 0                 (+N/2)(-N/2)
+  * |-----------------------><-------------------------|
+  *
+  * sample 0 is for continuous frequency which is used here
+  */
+
+  unsigned int k = length - (LENGTH_PSS_NR/2+1);
+
+  for (int i=0; i < LENGTH_PSS_NR; i++) {
+    synchroF_tmp[2*k] = primary_synchro[2*i];
+    synchroF_tmp[2*k+1] = primary_synchro[2*i+1];
+
+    k++;
+
+    if (k >= length) {
+      k++;
+      k-=length;
+    }
+  }
+
+  /* IFFT will give temporal signal of Pss */
+
+  idft = get_idft(length);
+
+  idft(synchroF_tmp,          /* complex input */
+       synchro_tmp,           /* complex output */
+       1);                 /* scaling factor */
+
+  /* then get final pss in time */
+  for (unsigned int i=0; i<length; i++) {
+    ((int32_t *)primary_synchro_time)[i] = ((int32_t *)synchro_tmp)[i];
+  }
+
+#ifdef DBG_PSS_NR
+
+  if (N_ID_2 == 0) {
+    char output_file[255];
+    char sequence_name[255];
+    sprintf(output_file, "%s%d_%d%s","pss_seq_t_", N_ID_2, length, ".m");
+    sprintf(sequence_name, "%s%d_%d","pss_seq_t_", N_ID_2, length);
+
+    printf("file %s sequence %s\n", output_file, sequence_name);
+
+    write_output(output_file, sequence_name, primary_synchro_time, length, 1, 1);
+  }
+
+#endif
+
+
+#if 0
+
+/* it allows checking that process of idft on a signal and then dft gives same signal with limited errors */
+
+  if ((N_ID_2 == 0) && (length == 256)) {
+
+    write_output("pss_f00.m","pss_f00",synchro_tmp,length,1,1);
+
+
+    bzero(synchroF_tmp, size);
+
+    void (*dft)(int16_t *,int16_t *, int) = get_dft(length);
+
+    /* get pss in the time domain by applying an inverse FFT */
+    dft(synchro_tmp,           /* complex input */
+        synchroF_tmp,          /* complex output */
+        1);                 /* scaling factor */
+
+    if ((N_ID_2 == 0) && (length == 256)) {
+      write_output("pss_f_0.m","pss_f_0",synchroF_tmp,length,1,1);
+    }
+
+    /* check Pss */
+    k = length - (LENGTH_PSS_NR/2);
+
+#define LIMIT_ERROR_FFT   (10)
+
+    for (int i=0; i < LENGTH_PSS_NR; i++) {
+      if (abs(synchroF_tmp[2*k] - primary_synchro[2*i]) > LIMIT_ERROR_FFT) {
+      printf("Pss Error[%d] Compute %d Reference %d \n", k, synchroF_tmp[2*k], primary_synchro[2*i]);
+      }
+    
+      if (abs(synchroF_tmp[2*k+1] - primary_synchro[2*i+1]) > LIMIT_ERROR_FFT) {
+        printf("Pss Error[%d] Compute %d Reference %d\n", (2*k+1), synchroF_tmp[2*k+1], primary_synchro[2*i+1]);
+      }
+
+      k++;
+
+      if (k >= length) {
+        k-=length;
+      }
+    }
+  }
+#endif
+}
+
+/*******************************************************************
+*
+* NAME :         init_context_pss_nr
+*
+* PARAMETERS :   structure NR_DL_FRAME_PARMS give frame parameters
+*
+* RETURN :       generate binary pss sequences (this is a m-sequence)
+*
+* DESCRIPTION :  3GPP TS 38.211 7.4.2.2 Primary synchronisation signal
+*                Sequence generation
+*
+*********************************************************************/
+
+void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue)
+{
+  int ofdm_symbol_size = frame_parms_ue->ofdm_symbol_size;
+  int sizePss = LENGTH_PSS_NR * IQ_SIZE;  /* complex value i & q signed 16 bits */
+  int size = ofdm_symbol_size * IQ_SIZE; /* i and q samples signed 16 bits */
+  int16_t *p = NULL;
+  int *q = NULL;
+
+  for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) {
+
+    p = malloc16(sizePss); /* pss in complex with alternatively i then q */
+    if (p != NULL) {
+      primary_synchro_nr[i] = p;
+      bzero( primary_synchro_nr[i], sizePss);
+    }
+    else {
+     msg("Fatal memory allocation problem \n");
+     assert(0);
+    }
+
+    p = malloc16(size);
+    if (p != NULL) {
+      primary_synchro_time_nr[i] = p;
+      bzero( primary_synchro_time_nr[i], size);
+    }
+    else {
+     msg("Fatal memory allocation problem \n");
+     assert(0);
+    }
+
+    size = LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*sizeof(int)*frame_parms_ue->samples_per_subframe;
+    q = malloc16(size);
+    if (q != NULL) {
+      pss_corr_ue[i] = q;
+      bzero( pss_corr_ue[i], size);
+    }
+    else {
+      msg("Fatal memory allocation problem \n");
+      assert(0);
+    }
+
+    generate_pss_nr(i, ofdm_symbol_size);
+  }
+}
+
+/*******************************************************************
+*
+* NAME :         free_context_pss_nr
+*
+* PARAMETERS :   none
+*
+* RETURN :       none
+*
+* DESCRIPTION :  free context related to pss
+*
+*********************************************************************/
+
+void free_context_pss_nr(void)
+{
+  for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) {
+
+    if (primary_synchro_time_nr[i] != NULL) {
+      free(primary_synchro_time_nr[i]);
+      primary_synchro_time_nr[i] = NULL;
+    }
+    else {
+      msg("Fatal memory deallocation problem \n");
+      assert(0);
+    }
+
+    if (primary_synchro_nr[i] != NULL) {
+      free(primary_synchro_nr[i]);
+      primary_synchro_nr[i] = NULL;
+    }
+    else {
+      msg("Fatal memory deallocation problem \n");
+      assert(0);
+    }
+
+    if (pss_corr_ue[i] != NULL) {
+      free(pss_corr_ue[i]);
+      pss_corr_ue[i] = NULL;
+    }
+    else {
+      msg("Fatal memory deallocation problem \n");
+      assert(0);
+    }
+  }
+}
+
+/*******************************************************************
+*
+* NAME :         init_context_synchro_nr
+*
+* PARAMETERS :   none
+*
+* RETURN :       generate context for pss and sss
+*
+* DESCRIPTION :  initialise contexts and buffers for synchronisation
+*
+*********************************************************************/
+
+void init_context_synchro_nr(NR_DL_FRAME_PARMS *frame_parms_ue)
+{
+#ifndef STATIC_SYNC_BUFFER
+
+  /* initialise global buffers for synchronisation */
+  synchroF_tmp = malloc16(SYNCF_TMP_SIZE);
+  if (synchroF_tmp == NULL) {
+    msg("Fatal memory allocation problem \n");
+    assert(0);
+  }
+
+  synchro_tmp = malloc16(SYNC_TMP_SIZE);
+  if (synchro_tmp == NULL) {
+    msg("Fatal memory allocation problem \n");
+    assert(0);
+  }
+
+#endif
+
+  init_context_pss_nr(frame_parms_ue);
+
+  init_context_sss_nr(AMP);
+}
+
+/*******************************************************************
+*
+* NAME :         free_context_synchro_nr
+*
+* PARAMETERS :   none
+*
+* RETURN :       free context for pss and sss
+*
+* DESCRIPTION :  deallocate memory of synchronisation
+*
+*********************************************************************/
+
+void free_context_synchro_nr(void)
+{
+#ifndef STATIC_SYNC_BUFFER
+
+  if (synchroF_tmp != NULL) {
+    free(synchroF_tmp);
+    synchroF_tmp = NULL;
+  }
+  else {
+    msg("Fatal memory deallocation problem \n");
+    assert(0);
+  }
+
+  if (synchro_tmp != NULL) {
+    free(synchro_tmp);
+    synchro_tmp = NULL;
+  }
+  else {
+    msg("Fatal memory deallocation problem \n");
+    assert(0);
+  }
+
+#endif
+
+  free_context_pss_nr();
+}
+
+/*******************************************************************
+*
+* NAME :         set_frame_context_pss_nr
+*
+* PARAMETERS :   configuration for UE with new FFT size
+*
+* RETURN :       0 if OK else error
+*
+* DESCRIPTION :  initialisation of UE contexts
+*
+*********************************************************************/
+
+void set_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_change)
+{
+  /* set new value according to rate_change */
+  frame_parms_ue->ofdm_symbol_size = (frame_parms_ue->ofdm_symbol_size / rate_change);
+  frame_parms_ue->samples_per_tti = (frame_parms_ue->samples_per_tti / rate_change);
+  frame_parms_ue->samples_per_subframe = (frame_parms_ue->samples_per_subframe / rate_change);
+
+  free_context_pss_nr();
+
+  /* pss reference have to be rebuild with new parameters ie ofdm symbol size */
+  init_context_synchro_nr(frame_parms_ue);
+
+#ifdef SYNCHRO_DECIMAT
+  set_pss_nr(frame_parms_ue->ofdm_symbol_size);
+#endif
+}
+
+/*******************************************************************
+*
+* NAME :         restore_frame_context_pss_nr
+*
+* PARAMETERS :   configuration for UE and eNB with new FFT size
+*
+* RETURN :       0 if OK else error
+*
+* DESCRIPTION :  initialisation of UE and eNode contexts
+*
+*********************************************************************/
+
+void restore_frame_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue, int rate_change)
+{
+  frame_parms_ue->ofdm_symbol_size = frame_parms_ue->ofdm_symbol_size * rate_change;
+  frame_parms_ue->samples_per_tti = frame_parms_ue->samples_per_tti * rate_change;
+  frame_parms_ue->samples_per_subframe = frame_parms_ue->samples_per_subframe * rate_change;
+
+  free_context_pss_nr();
+
+  /* pss reference have to be rebuild with new parameters ie ofdm symbol size */
+  init_context_synchro_nr(frame_parms_ue);
+#ifdef SYNCHRO_DECIMAT
+  set_pss_nr(frame_parms_ue->ofdm_symbol_size);
+#endif
+}
+
+/********************************************************************
+*
+* NAME :         decimation_synchro_nr
+*
+* INPUT :        UE context
+*                for first and second pss sequence
+*                - position of pss in the received UE buffer
+*                - number of pss sequence
+*
+* RETURN :      0 if OK else error
+*
+* DESCRIPTION :  detect pss sequences in the received UE buffer
+*
+********************************************************************/
+
+void decimation_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change, int **rxdata)
+{
+  NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms);
+  int samples_for_frame = LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti;
+
+#if TEST_SYNCHRO_TIMING_PSS
+
+  opp_enabled = 1;
+
+  start_meas(&generic_time[TIME_RATE_CHANGE]);
+
+#endif
+
+/* build with cic filter does not work properly. Performances are significantly deteriorated */
+#ifdef CIC_DECIMATOR
+
+  cic_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][0]), (int16_t *)&(rxdata[0][0]),
+                            samples_for_frame, rate_change, CIC_FILTER_STAGE_NUMBER, 0, FIR_RATE_CHANGE);
+#else
+
+  fir_decimator((int16_t *)&(PHY_vars_UE->common_vars.rxdata[0][0]), (int16_t *)&(rxdata[0][0]),
+                            samples_for_frame, rate_change, 0);
+
+#endif
+
+  set_frame_context_pss_nr(frame_parms, rate_change);
+
+#if TEST_SYNCHRO_TIMING_PSS
+
+  stop_meas(&generic_time[TIME_RATE_CHANGE]);
+
+  printf("Rate change execution duration %5.2f \n", generic_time[TIME_RATE_CHANGE].p_time/(cpuf*1000.0));
+
+#endif
+}
+
+/*******************************************************************
+*
+* NAME :         pss_synchro_nr
+*
+* PARAMETERS :   int rate_change
+*
+* RETURN :       position of detected pss
+*
+* DESCRIPTION :  pss search can be done with sampling decimation.*
+*
+*********************************************************************/
+
+int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int rate_change)
+{
+  NR_DL_FRAME_PARMS *frame_parms = &(PHY_vars_UE->frame_parms);
+  int synchro_position;
+  int **rxdata = NULL;
+
+#ifdef DBG_PSS_NR
+
+  int samples_for_frame = frame_parms->samples_per_subframe*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME;
+
+  write_output("rxdata0_rand.m","rxd0_rand", &PHY_vars_UE->common_vars.rxdata[0][0], samples_for_frame, 1, 1);
+
+#endif
+
+  if (rate_change != 1) {
+
+    rxdata = (int32_t**)malloc16(frame_parms->nb_antennas_rx*sizeof(int32_t*));
+
+    for (int aa=0; aa < frame_parms->nb_antennas_rx; aa++) {
+      rxdata[aa] = (int32_t*) malloc16_clear( (frame_parms->samples_per_subframe*10+2048)*sizeof(int32_t));
+    }
+#ifdef SYNCHRO_DECIMAT
+
+    decimation_synchro_nr(PHY_vars_UE, rate_change, rxdata);
+
+#endif
+  }
+  else {
+
+    rxdata = PHY_vars_UE->common_vars.rxdata;
+  }
+
+#ifdef DBG_PSS_NR
+
+  write_output("rxdata0_des.m","rxd0_des", &rxdata[0][0], samples_for_frame,1,1);
+
+#endif
+
+#if TEST_SYNCHRO_TIMING_PSS
+
+  opp_enabled = 1;
+
+  start_meas(&generic_time[TIME_PSS]);
+
+#endif
+
+#if 1
+
+  synchro_position = pss_search_time_nr(rxdata,
+                                        frame_parms,
+                                        (int *)&PHY_vars_UE->common_vars.eNb_id);
+
+#else
+
+  synchro_position = lte_sync_time(rxdata,
+                                          frame_parms,
+                                          (int *)&PHY_vars_UE->common_vars.eNb_id);
+#endif
+
+#if TEST_SYNCHRO_TIMING_PSS
+
+  stop_meas(&generic_time[TIME_PSS]);
+
+  printf("PSS execution duration %5.2f \n", generic_time[TIME_PSS].p_time/(cpuf*1000.0));
+
+#endif
+
+#ifdef SYNCHRO_DECIMAT
+
+  if (rate_change != 1) {
+
+    if (rxdata[0] != NULL) {
+
+      for (int aa=0;aa<frame_parms->nb_antennas_rx;aa++) {
+        free(rxdata[aa]);
+      }
+
+      free(rxdata);
+    }
+
+    restore_frame_context_pss_nr(frame_parms, rate_change);  
+  }
+#endif
+
+  return synchro_position;
+}
+
+static inline int abs32(int x)
+{
+  return (((int)((short*)&x)[0])*((int)((short*)&x)[0]) + ((int)((short*)&x)[1])*((int)((short*)&x)[1]));
+}
+
+/*******************************************************************
+*
+* NAME :         pss_search_time_nr
+*
+* PARAMETERS :   received buffer
+*                frame parameters
+*
+* RETURN :       position of detected pss
+*
+* DESCRIPTION :  Synchronisation on pss sequence is based on a time domain correlation between received samples and pss sequence
+*                A maximum likelihood detector finds the timing offset (position) that corresponds to the maximum correlation
+*                Length of received buffer should be a minimum of 2 frames (see TS 38.213 4.1 Cell search)
+*                Search pss in the received buffer is done each 4 samples which ensures a memory alignment to 128 bits (32 bits x 4).
+*                This is required by SIMD (single instruction Multiple Data) Extensions of Intel processors
+*                Correlation computation is based on a a dot product which is realized thank to SIMS extensions
+*
+*                                    (x frames)
+*     <--------------------------------------------------------------------------->
+*
+*
+*     -----------------------------------------------------------------------------
+*     |                      Received UE data buffer                              |
+*     ----------------------------------------------------------------------------
+*                -------------
+*     <--------->|    pss    |
+*      position  -------------
+*                ^
+*                |
+*            peak position
+*            given by maximum of correlation result
+*            position matches beginning of first ofdm symbol of pss sequence
+*
+*     Remark: memory position should be aligned on a multiple of 4 due to I & Q samples of int16
+*             An OFDM symbol is composed of x number of received samples depending of Rf front end sample rate.
+*
+*     I & Q storage in memory
+*
+*             First samples       Second  samples
+*     ------------------------- -------------------------  ...
+*     |     I1     |     Q1    |     I2     |     Q2    |
+*     ---------------------------------------------------  ...
+*     ^    16  bits   16 bits  ^
+*     |                        |
+*     ---------------------------------------------------  ...
+*     |         sample 1       |    sample   2          |
+*    ----------------------------------------------------  ...
+*     ^
+*
+*********************************************************************/
+
+#define DOT_PRODUCT_SCALING_SHIFT    (17)
+
+int pss_search_time_nr(int **rxdata, ///rx data in time domain
+                       NR_DL_FRAME_PARMS *frame_parms,
+                       int *eNB_id)
+{
+  unsigned int n, ar, peak_position, peak_value, pss_source;
+  int result;
+  int synchro_out;
+  unsigned int tmp[NUMBER_PSS_SEQUENCE];
+  unsigned int length = (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->ttis_per_subframe*frame_parms->samples_per_tti);  /* 1 frame for now, it should be 2 TODO_NR */
+
+  for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) {
+	  tmp[i] = 0;
+    if (pss_corr_ue[i] == NULL) {
+      msg("[SYNC TIME] pss_corr_ue[%d] not yet allocated! Exiting.\n", i);
+      return(-1);
+    }
+  }
+
+  peak_value = 0;
+  peak_position = 0;
+  pss_source = 0;
+
+  /* Search pss in the received buffer each 4 samples which ensures a memory alignment on 128 bits (32 bits x 4 ) */
+  /* This is required by SIMD (single instruction Multiple Data) Extensions of Intel processors. */
+  /* Correlation computation is based on a a dot product which is realized thank to SIMS extensions */
+  for (n=0; n < length; n+=4) {
+
+#ifdef RTAI_ENABLED
+
+    // This is necessary since the sync takes a long time and it seems to block all other threads thus screwing up RTAI. If we pause it for a little while during its execution we give RTAI a chance to catch up with its other tasks.
+    if ((n%frame_parms->samples_per_subframe == 0) && (n>0) && (openair_daq_vars.sync_state==0)) {
+#ifdef DEBUG_PHY
+      msg("[SYNC TIME] pausing for 1000ns, n=%d\n",n);
+#endif
+      rt_sleep(nano2count(1000));
+    }
+
+#endif
+
+    for (int pss_index = 0; pss_index < NUMBER_PSS_SEQUENCE; pss_index++) {
+
+      pss_corr_ue[pss_index][n] = 0; /* clean correlation for position n */
+
+      synchro_out = 0;
+
+      if ( n < (length - frame_parms->ofdm_symbol_size)) {
+
+        /* calculate dot product of primary_synchro_time_nr and rxdata[ar][n] (ar=0..nb_ant_rx) and store the sum in temp[n]; */
+        for (ar=0; ar<frame_parms->nb_antennas_rx; ar++) {
+
+          /* perform correlation of rx data and pss sequence ie it is a dot product */
+          result  = dot_product((short*)primary_synchro_time_nr[pss_index], (short*) &(rxdata[ar][n]), frame_parms->ofdm_symbol_size, DOT_PRODUCT_SCALING_SHIFT);
+
+          ((short*)pss_corr_ue[pss_index])[2*n] += ((short*) &result)[0];   /* real part */
+          ((short*)pss_corr_ue[pss_index])[2*n+1] += ((short*) &result)[1]; /* imaginary part */
+          ((short*)&synchro_out)[0] += ((short*) &result)[0];               /* real part */
+          ((short*)&synchro_out)[1] += ((short*) &result)[1];               /* imaginary part */
+        }
+      }
+
+      pss_corr_ue[pss_index][n] = abs32(pss_corr_ue[pss_index][n]);
+
+      /* calculate the absolute value of sync_corr[n] */
+      tmp[pss_index] = (abs32(synchro_out)) ;
+
+      if (tmp[pss_index] > peak_value) {
+        peak_value = tmp[pss_index];
+        peak_position = n;
+        pss_source = pss_index;
+
+        //printf("pss_index %d: n %6d peak_value %10d, synchro_out (% 6d,% 6d) \n", pss_index, n, abs32(synchro_out),((int16_t*)&synchro_out)[0],((int16_t*)&synchro_out)[1]);
+      }
+    }
+  }
+
+  *eNB_id = pss_source;
+
+  LOG_I(PHY,"[UE] nr_synchro_time: Sync source = %d, Peak found at pos %d, val = %d (%d dB)\n", pss_source, peak_position, peak_value, dB_fixed(peak_value)/2);
+
+//#ifdef DEBUG_PSS_NR
+
+#define  PSS_DETECTION_FLOOR_NR     (31)
+  if ((dB_fixed(peak_value)/2) > PSS_DETECTION_FLOOR_NR) {
+
+    printf("[UE] nr_synchro_time: Sync source = %d, Peak found at pos %d, val = %d (%d dB)\n", pss_source, peak_position, peak_value,dB_fixed(peak_value)/2);
+  }
+//#endif
+
+#ifdef DEBUG_PHY
+
+  if (debug_cnt == 0) {
+    write_output("pss_corr_ue0.m","pss_corr_ue0",pss_corr_ue[0],length,1,2);
+    write_output("pss_corr_ue1.m","pss_corr_ue1",pss_corr_ue[1],length,1,2);
+    write_output("pss_corr_ue2.m","pss_corr_ue2",pss_corr_ue[2],length,1,2);
+    write_output("rxdata0.m","rxd0",rxdata[0],length,1,1);
+  } else {
+    debug_cnt++;
+  }
+
+#endif
+
+  return(peak_position);
+}
+
diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c
new file mode 100644
index 0000000000000000000000000000000000000000..aba3c12636e3a675aa0c4b9ed4bcf2e9b09bba9a
--- /dev/null
+++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c
@@ -0,0 +1,488 @@
+/*
+ * 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
+ */
+
+/***********************************************************************
+*
+* FILENAME    :  srs_modulation_nr_nr.c
+*
+* MODULE      :
+*
+* DESCRIPTION :  function to set uplink reference symbols
+*                see TS 38211 6.4.1.4 Sounding reference signal
+*
+************************************************************************/
+
+#include <stdio.h>
+#include <math.h>
+
+#define DEFINE_VARIABLES_PHY_IMPLEMENTATION_DEFS_NR_H
+#include "PHY/impl_defs_nr.h"
+#undef DEFINE_VARIABLES_PHY_IMPLEMENTATION_DEFS_NR_H
+
+#include "PHY/defs_nr_UE.h"
+//#include "extern.h"
+#include "PHY/NR_REFSIG/ss_pbch_nr.h"
+#include "PHY/NR_REFSIG/dmrs_nr.h"
+#include "PHY/NR_REFSIG/ul_ref_seq_nr.h"
+
+#define DEFINE_VARIABLES_SRS_MODULATION_NR_H
+#include "PHY/NR_UE_TRANSPORT/srs_modulation_nr.h"
+#undef DEFINE_VARIABLES_SRS_MODULATION_NR_H
+
+/*******************************************************************
+*
+* NAME :         generate_srs
+*
+* PARAMETERS :   pointer to resource set
+*                pointer to transmit buffer
+*                amplitude scaling for this physical signal
+*                slot number of transmission
+* RETURN :       0  if srs sequence has been successfully generated
+*                -1 if sequence can not be properly generated
+*
+* DESCRIPTION :  generate/map srs symbol into transmit buffer
+*                see TS 38211 6.4.1.4 Sounding reference signal
+*
+*                FFS_TODO_NR
+*                Current supported configuration:
+*                - single resource per resource set
+*                - single port antenna
+*                - 1 symbol for SRS
+*                - no symbol offset
+*                - periodic mode
+*                - no hopping
+*                - no carrier switching
+*                - no antenna switching*
+*
+*********************************************************************/
+int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set,
+                        NR_DL_FRAME_PARMS *frame_parms,
+                        int32_t *txptr,
+                        int16_t amp,
+                        UE_nr_rxtx_proc_t *proc)
+{
+  uint8_t n_SRS_cs_max;
+  uint8_t u, v_nu;
+  uint32_t f_gh = 0;
+  SRS_Resource_t *p_SRS_Resource;
+  int frame_number = proc->frame_tx;
+  int slot_number = proc->nr_tti_tx;
+  uint16_t n_SRS, n_SRS_cs_i;
+  double alpha_i;
+  uint8_t K_TC_p;
+  uint16_t n_b[B_SRS_NUMBER], F_b, subcarrier;
+  uint8_t N_b, k_0_overbar_p;
+
+  if (p_srs_resource_set->p_srs_ResourceList[0] == NULL) {
+    LOG_E(PHY,"generate_srs: No resource associated with the SRS resource set!\n");
+    return (-1);
+  }
+  else {
+    if (p_srs_resource_set->number_srs_Resource <= MAX_NR_OF_SRS_RESOURCES_PER_SET) {
+      p_SRS_Resource = p_srs_resource_set->p_srs_ResourceList[0];
+    }
+    else {
+      LOG_E(PHY,"generate_srs: resource number of this resource set %d exceeds maximum supported value %d!\n", p_srs_resource_set->number_srs_Resource, MAX_NR_OF_SRS_RESOURCES_PER_SET);
+      return (-1);
+    }
+  }
+
+  if (p_srs_resource_set->resourceType != periodic) {
+    LOG_E(PHY,"generate_srs: only SRS periodic is supported up to now!\n");
+    return (-1);
+  }
+  /* get parameters from SRS resource configuration */
+  uint8_t B_SRS  = p_SRS_Resource->freqHopping_b_SRS;
+  uint8_t C_SRS  = p_SRS_Resource->freqHopping_c_SRS;
+  uint8_t b_hop = p_SRS_Resource->freqHopping_b_hop;
+  uint8_t K_TC = p_SRS_Resource->transmissionComb;
+  uint8_t K_TC_overbar = p_SRS_Resource->combOffset;    /* FFS_TODO_NR is this parameter for K_TC_overbar ?? */
+  uint8_t n_SRS_cs = p_SRS_Resource->cyclicShift;
+  uint8_t n_ID_SRS = p_SRS_Resource->sequenceId;
+  uint8_t n_shift = p_SRS_Resource->freqDomainPosition; /* it adjusts the SRS allocation to align with the common resource block grid in multiples of four */
+  uint8_t n_RRC = p_SRS_Resource->freqDomainShift;
+  uint8_t groupOrSequenceHopping = p_SRS_Resource->groupOrSequenceHopping;
+
+  uint8_t l_offset = p_SRS_Resource->resourceMapping_startPosition;
+
+  uint16_t T_SRS = srs_period[p_SRS_Resource->SRS_Periodicity];
+  uint16_t T_offset = p_SRS_Resource->SRS_Offset;;                   /* FFS_TODO_NR to check interface with RRC */
+  uint8_t R = p_SRS_Resource->resourceMapping_repetitionFactor;
+
+  /* TS 38.211 6.4.1.4.1 SRS resource */
+  uint8_t N_ap = (uint8_t)p_SRS_Resource->nrof_SrsPorts;            /* antenna port for transmission */
+  uint8_t N_symb_SRS = p_SRS_Resource->resourceMapping_nrofSymbols; /* consecutive OFDM symbols */
+  uint8_t l0 = N_SYMB_SLOT - 1 - l_offset;                          /* starting position in the time domain */
+  uint8_t k_0_p;                                                    /* frequency domain starting position */
+
+  if (N_ap != port1) {
+    LOG_E(PHY, "generate_srs: this number of antenna ports %d is not yet supported!\n", N_ap);
+    return (-1);
+  }
+  if (N_symb_SRS != 1) {
+    LOG_E(PHY, "generate_srs: this number of srs symbol  %d is not yet supported!\n", N_symb_SRS);
+  	return (-1);
+  }
+  if (groupOrSequenceHopping != neitherHopping) {
+    LOG_E(PHY, "generate_srs: sequence hopping is not yet supported!\n");
+    return (-1);
+  }
+  if (R == 0) {
+    LOG_E(PHY, "generate_srs: this parameter repetition factor %d is not consistent !\n", R);
+    return (-1);
+  }
+  else if (R > N_symb_SRS) {
+    LOG_E(PHY, "generate_srs: R %d can not be greater than N_symb_SRS %d !\n", R, N_symb_SRS);
+    return (-1);
+  }
+  /* see 38211 6.4.1.4.2 Sequence generation */
+  if (K_TC == 4) {
+    n_SRS_cs_max = 12;
+    // delta = 2;     /* delta = log2(K_TC) */
+  }
+  else if (K_TC == 2) {
+    n_SRS_cs_max = 8;
+    // delta = 1;     /* delta = log2(K_TC) */
+  }
+  else {
+	LOG_E(PHY, "generate_srs: SRS unknown value for K_TC %d !\n", K_TC);
+    return (-1);
+  }
+  if (n_SRS_cs >= n_SRS_cs_max) {
+    LOG_E(PHY, "generate_srs: inconsistent parameter n_SRS_cs %d >=  n_SRS_cs_max %d !\n", n_SRS_cs, n_SRS_cs_max);
+    return (-1);
+  }
+  if (T_SRS == 0) {
+    LOG_E(PHY, "generate_srs: inconsistent parameter T_SRS %d can not be equal to zero !\n", T_SRS);
+    return (-1);
+  }
+  else
+  {
+    int index = 0;
+    while (srs_periodicity[index] != T_SRS) {
+      index++;
+      if (index == SRS_PERIODICITY) {
+        LOG_E(PHY, "generate_srs: inconsistent parameter T_SRS %d not specified !\n", T_SRS);
+        return (-1);
+      }
+    }
+  }
+
+  uint16_t m_SRS_b = srs_bandwidth_config[C_SRS][B_SRS][0];     /* m_SRS_b is given by TS 38211 clause 6.4.1.4.3 */
+  uint16_t M_sc_b_SRS = m_SRS_b * N_SC_RB/K_TC;                 /* length of the sounding reference signal sequence */
+
+  /* for each antenna ports for transmission */
+  for (int p_index = 0; p_index < N_ap; p_index++) {
+
+  /* see TS 38.211 6.4.1.4.2 Sequence generation */
+
+    n_SRS_cs_i = (n_SRS_cs +  (n_SRS_cs_max * (SRS_antenna_port[p_index] - 1000)/N_ap))%n_SRS_cs_max;
+    alpha_i = 2 * M_PI * ((double)n_SRS_cs_i / (double)n_SRS_cs_max);
+
+    /* for each SRS symbol which should be managed by SRS configuration */
+    /* from TS 38.214 6.2.1.1 UE SRS frequency hopping procedure */
+    /* A UE may be configured to transmit an SRS resource on  adjacent symbols within the last six symbols of a slot, */
+    /* where all antenna ports of the SRS resource are mapped to each symbol of the resource */
+
+
+    uint8_t l = p_index;
+    if (l >= N_symb_SRS) {
+      LOG_E(PHY, "generate_srs: number of antenna ports %d and number of srs symbols %d are different !\n", N_ap, N_symb_SRS);
+    }
+
+    switch(groupOrSequenceHopping) {
+      case neitherHopping:
+      {
+        f_gh = 0;
+        v_nu = 0;
+        break;
+      }
+      case groupHopping:
+      {
+        uint8_t c_last_index = 8 * (slot_number * N_SYMB_SLOT + l0 + l) + 7; /* compute maximum value of the random sequence */
+        uint32_t *c_sequence =  calloc(c_last_index+1, sizeof(uint32_t));
+        uint32_t cinit = n_ID_SRS/30;
+        pseudo_random_sequence(c_last_index+1,  c_sequence, cinit);
+        for (int m = 0; m < 8; m++) {
+          f_gh += c_sequence[8 * (slot_number * N_SYMB_SLOT + l0 + l) + m]<<m;
+        }
+        free(c_sequence);
+        f_gh = f_gh%30;
+        v_nu = 0;
+        break;
+      }
+      case sequenceHopping:
+      {
+        f_gh = 0;
+        if (M_sc_b_SRS > 6 * N_SC_RB) {
+          uint8_t c_last_index = (slot_number * N_SYMB_SLOT + l0 + l); /* compute maximum value of the random sequence */
+          uint32_t *c_sequence =  calloc(c_last_index+1, sizeof(uint32_t));
+          uint32_t cinit = n_ID_SRS;
+          pseudo_random_sequence(c_last_index+1,  c_sequence, cinit);
+          v_nu = c_sequence[c_last_index];
+          free(c_sequence);
+        }
+        else {
+          v_nu = 0;
+        }
+        break;
+      }
+      default:
+      {
+        LOG_E(PHY, "generate_srs: unknown hopping setting %d !\n", groupOrSequenceHopping);
+        return (-1);
+      }
+    }
+
+    /* u is the sequence-group number defined in section 6.4.1.4.1 */
+    u = (f_gh + n_ID_SRS)%U_GROUP_NUMBER; /* 30 */
+
+    /* TS 38.211 6.4.1.4.3  Mapping to physical resources */
+
+    if((n_SRS_cs >= n_SRS_cs_max/2)&&(n_SRS_cs < n_SRS_cs_max)&&(N_ap == 4) && ((SRS_antenna_port[p_index] == 1001) || (SRS_antenna_port[p_index] == 1003))) {
+      K_TC_p = (K_TC_overbar + K_TC/2)%K_TC;
+    }
+    else {
+      K_TC_p = K_TC_overbar;
+    }
+
+    for (int b = 0; b <= B_SRS; b++) {
+      N_b = srs_bandwidth_config[C_SRS][b][1];
+      if (b_hop >= B_SRS) {
+        n_b[b] = (4 * n_RRC/m_SRS_b)%N_b; /* frequency hopping is disabled and the frequency position index n_b remains constant */
+      }
+      else {
+        if (b == b_hop) {
+          N_b = 1;
+        }
+        /* periodicity and offset */
+        if (p_srs_resource_set->resourceType == aperiodic) {
+          n_SRS = l/R;
+        }
+        else {
+          int8_t N_slot_frame = NR_NUMBER_OF_SUBFRAMES_PER_FRAME * frame_parms->ttis_per_subframe;
+          n_SRS = ((N_slot_frame*frame_number + slot_number - T_offset)/T_SRS)*(N_symb_SRS/R)+(l/R);
+        }
+
+        uint16_t product_N_b = 1;  /* for b_hop to b-1 */
+        for (unsigned int b_prime = b_hop; b_prime < B_SRS; b_prime++) {  /* product for b_hop to b-1 */
+          if (b_prime != b_hop) {
+            product_N_b *= srs_bandwidth_config[C_SRS][b_prime][1];
+          }
+        }
+
+        if (N_b & 1) {      /* Nb odd */
+          F_b = (N_b/2)*(n_SRS/product_N_b);
+        }
+        else {              /* Nb even */
+          uint16_t product_N_b_B_SRS = product_N_b;
+          product_N_b_B_SRS *= srs_bandwidth_config[C_SRS][B_SRS][1]; /* product for b_hop to b */
+          F_b = (N_b/2)*((n_SRS%product_N_b_B_SRS)/product_N_b) + ((n_SRS%product_N_b_B_SRS)/2*product_N_b);
+        }
+
+        if (b <= b_hop) {
+          n_b[b] = (4 * n_RRC/m_SRS_b)%N_b;
+        }
+        else {
+          n_b[b] = (F_b + (4 * n_RRC/m_SRS_b))%N_b;
+        }
+      }
+    }
+
+    k_0_overbar_p = n_shift * N_SC_RB + K_TC_p;
+
+    k_0_p = k_0_overbar_p; /* it is the frequency-domain starting position */
+
+    for (int b = 0; b <= B_SRS; b++) {
+      k_0_p += K_TC * M_sc_b_SRS * n_b[b];
+    }
+
+    subcarrier = (frame_parms->first_carrier_offset) + k_0_p;
+    if (subcarrier>frame_parms->ofdm_symbol_size) {
+      subcarrier -= frame_parms->ofdm_symbol_size;
+    }
+
+    /* find index of table which is for this srs length */
+    unsigned int M_sc_b_SRS_index = 0;
+    while((ul_allocated_re[M_sc_b_SRS_index] != M_sc_b_SRS) && (M_sc_b_SRS_index < SRS_SB_CONF)){
+      M_sc_b_SRS_index++;
+    }
+
+    if (ul_allocated_re[M_sc_b_SRS_index] != M_sc_b_SRS) {
+      LOG_E(PHY, "generate_srs: srs uplink allocation %d can not be found! \n", M_sc_b_SRS);
+      return (-1);
+    }
+
+#if 0
+
+    char output_file[255];
+    char sequence_name[255];
+    sprintf(output_file, "rv_seq_%d_%d_%d.m", u, v_nu, ul_allocated_re[M_sc_b_SRS_index]);
+    sprintf(sequence_name, "rv_seq_%d_%d_%d", u, v_nu, ul_allocated_re[M_sc_b_SRS_index]);
+    write_output(output_file, sequence_name,  rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index], ul_allocated_re[M_sc_b_SRS_index], 1, 1);
+
+#endif
+
+    for (int k=0; k < M_sc_b_SRS; k++) {
+
+      double real_shift = cos(alpha_i*k);
+      double imag_shift = sin(alpha_i*k);
+
+      /* cos(x + y) = cos(x)cos(y) - sin(x)sin(y) */
+      double real = ((real_shift*rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index][2*k]) - (imag_shift*rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index][2*k+1]))/sqrt(N_ap);
+      /* sin(x + y) = sin(x)cos(y) + cos(x)sin(y) */
+      double imag = ((imag_shift*rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index][2*k]) + (real_shift*rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index][2*k+1]))/sqrt(N_ap);
+
+      int32_t real_amp = ((int32_t)round((double) amp * real)) >> 15;
+      int32_t imag_amp = ((int32_t)round((double) amp * imag)) >> 15;
+
+#if 0
+      printf("subcarrier %5d srs[%3d] r: %4d i: %4d reference[%d][%d][%d] r: %6d i: %6d\n", subcarrier, k, real_amp, imag_amp,
+                                                                                            u, v_nu, M_sc_b_SRS_index,
+                                                                                            rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index][2*k],
+                                                                                            rv_ul_ref_sig[u][v_nu][M_sc_b_SRS_index][2*k+1]);
+#endif
+
+      txptr[subcarrier] = (real_amp & 0xFFFF) + ((imag_amp<<16)&0xFFFF0000);
+
+      subcarrier += (K_TC); /* subcarrier increment */
+
+      if (subcarrier >= frame_parms->ofdm_symbol_size)
+        subcarrier=subcarrier-frame_parms->ofdm_symbol_size;
+    }
+    /* process next symbol */
+    txptr = txptr + frame_parms->ofdm_symbol_size;
+  }
+
+  return (0);
+}
+
+/*******************************************************************
+*
+* NAME :         is_srs_period_nr
+*
+* PARAMETERS :   pointer to resource set
+*                pointer to transmit buffer
+*                amplitude scaling for this physical signal
+*                slot number of transmission
+* RETURN :        0  if it is a valid slot for transmitting srs
+*                -1 if srs should not be transmitted
+*
+* DESCRIPTION :  for periodic,
+*
+*********************************************************************/
+int is_srs_period_nr(SRS_Resource_t *p_SRS_Resource, NR_DL_FRAME_PARMS *frame_parms, int frame_tx, int slot_tx)
+{
+  uint16_t T_SRS = srs_period[p_SRS_Resource->SRS_Periodicity];
+  uint16_t T_offset = p_SRS_Resource->SRS_Offset; /* FFS_TODO_NR to check interface */
+
+  if (T_offset > T_SRS) {
+    LOG_E(PHY,"is_srs_occasion_nr: T_offset %d is greater than T_SRS %d!\n", T_offset, T_SRS);
+    return (-1);
+  }
+
+  int16_t N_slot_frame = NR_NUMBER_OF_SUBFRAMES_PER_FRAME * frame_parms->ttis_per_subframe;
+  if ((N_slot_frame*frame_tx + slot_tx - T_offset)%T_SRS == 0) {
+    return (0);
+  }
+  else {
+    return (-1);
+  }
+}
+
+/*******************************************************************
+*
+* NAME :         ue_srs_procedure_nr
+*
+* PARAMETERS :   pointer to ue context
+*                pointer to rxtx context*
+*
+* RETURN :        0 if it is a valid slot for transmitting srs
+*                -1 if srs should not be transmitted
+*
+* DESCRIPTION :  ue srs procedure
+*                send srs according to current configuration
+*
+*********************************************************************/
+int ue_srs_procedure_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t eNB_id)
+{
+  NR_DL_FRAME_PARMS *frame_parms = &(ue->frame_parms);
+  SRS_NR *p_srs_nr = &(ue->frame_parms.srs_nr);
+  SRS_ResourceSet_t *p_srs_resource_set = frame_parms->srs_nr.p_SRS_ResourceSetList[p_srs_nr->active_srs_Resource_Set];
+  int generate_srs = 0;
+
+  /* is there any resource set which has been configurated ? */
+  if (p_srs_nr->number_srs_Resource_Set != 0) {
+
+    /* what is the current active resource set ? */
+    if (p_srs_nr->active_srs_Resource_Set > MAX_NR_OF_SRS_RESOURCE_SET) {
+      LOG_W(PHY,"phy_procedures_UE_TX: srs active %d greater than maximum %d!\n", p_srs_nr->active_srs_Resource_Set, MAX_NR_OF_SRS_RESOURCE_SET);
+    }
+    else {
+      /* SRS resource set configurated ? */
+      if (p_srs_resource_set != NULL) {
+
+        SRS_Resource_t *p_srs_resource = frame_parms->srs_nr.p_SRS_ResourceSetList[p_srs_nr->active_srs_Resource_Set]->p_srs_ResourceList[0];
+
+        /* SRS resource configurated ? */
+        if (p_srs_resource != NULL) {
+          if (p_srs_resource_set->resourceType == periodic) {
+            if (is_srs_period_nr(p_srs_resource, frame_parms, proc->frame_tx, proc->nr_tti_tx) == 0) {
+              generate_srs = 1;
+            }
+          }
+        }
+        else {
+          LOG_W(PHY,"phy_procedures_UE_TX: no configurated srs resource!\n");
+        }
+      }
+    }
+  }
+  if (generate_srs == 1) {
+    int16_t txptr = AMP;
+    uint16_t nsymb = (ue->frame_parms.Ncp==0) ? 14:12;
+    uint16_t symbol_offset = (int)ue->frame_parms.ofdm_symbol_size*((proc->nr_tti_tx*nsymb)+(nsymb-1));
+    if (generate_srs_nr(p_srs_resource_set, frame_parms, &ue->common_vars.txdataF[eNB_id][symbol_offset], txptr, proc) == 0) {
+      return 0;
+    }
+    else
+    {
+      return (-1);
+    }
+  }
+  else {
+    return (-1);
+  }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h
new file mode 100644
index 0000000000000000000000000000000000000000..86fd7fcc917f5ada3eaff86d814198576d6ece62
--- /dev/null
+++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.h
@@ -0,0 +1,169 @@
+/*
+ * 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
+ */
+
+/***********************************************************************
+*
+* FILENAME    :  srs_modulation_nr.h
+*
+* MODULE      :
+*
+* DESCRIPTION :  function to generate uplink reference sequences
+*                see 3GPP TS 38.211 6.4.1.4 Sounding reference signal
+*
+************************************************************************/
+
+#ifndef SRS_MODULATION_NR_H
+#define SRS_MODULATION_NR_H
+
+#ifdef DEFINE_VARIABLES_SRS_MODULATION_NR_H
+#define EXTERN
+#define INIT_VARIABLES_SRS_MODULATION_NR_H
+#else
+#define EXTERN extern
+#undef INIT_VARIABLES_SRS_MODULATION_NR_H
+#endif
+
+
+/************** DEFINE ********************************************/
+
+#define C_SRS_NUMBER       (64)
+#define B_SRS_NUMBER       (4)
+
+/************** VARIABLES *****************************************/
+
+/* TS 38.211 Table 6.4.1.4.3-1: SRS bandwidth configuration */
+EXTERN const unsigned short srs_bandwidth_config[C_SRS_NUMBER][B_SRS_NUMBER][2]
+#ifdef INIT_VARIABLES_SRS_MODULATION_NR_H
+= {
+/*           B_SRS = 0    B_SRS = 1   B_SRS = 2    B_SRS = 3     */
+/* C SRS   m_srs0  N_0  m_srs1 N_1  m_srs2   N_2 m_srs3   N_3    */
+/* 0  */   { {   4,  1 },{   4,  1 },{   4,  1  },{   4,  1  } },
+/* 1  */   { {   8,  1 },{   4,  2 },{   4,  1  },{   4,  1  } },
+/* 2  */   { {  12,  1 },{   4,  3 },{   4,  1  },{   4,  1  } },
+/* 3  */   { {  16,  1 },{   4,  4 },{   4,  1  },{   4,  1  } },
+/* 4  */   { {  16,  1 },{   8,  2 },{   4,  2  },{   4,  1  } },
+/* 5  */   { {  20,  1 },{   4,  5 },{   4,  1  },{   4,  1  } },
+/* 6  */   { {  24,  1 },{   4,  6 },{   4,  1  },{   4,  1  } },
+/* 7  */   { {  24,  1 },{  12,  2 },{   4,  3  },{   4,  1  } },
+/* 8  */   { {  28,  1 },{   4,  7 },{   4,  1  },{   4,  1  } },
+/* 9  */   { {  32,  1 },{  16,  2 },{   8,  2  },{   4,  2  } },
+/* 10 */   { {  36,  1 },{  12,  3 },{   4,  3  },{   4,  1  } },
+/* 11 */   { {  40,  1 },{  20,  2 },{   4,  5  },{   4,  1  } },
+/* 12 */   { {  48,  1 },{  16,  3 },{   8,  2  },{   4,  2  } },
+/* 13 */   { {  48,  1 },{  24,  2 },{  12,  2  },{   4,  3  } },
+/* 14 */   { {  52,  1 },{   4, 13 },{   4,  1  },{   4,  1  } },
+/* 15 */   { {  56,  1 },{  28,  2 },{   4,  7  },{   4,  1  } },
+/* 16 */   { {  60,  1 },{  20,  3 },{   4,  5  },{   4,  1  } },
+/* 17 */   { {  64,  1 },{  32,  2 },{  16,  2  },{   4,  4  } },
+/* 18 */   { {  72,  1 },{  24,  3 },{  12,  2  },{   4,  3  } },
+/* 19 */   { {  72,  1 },{  36,  2 },{  12,  3  },{   4,  3  } },
+/* 20 */   { {  76,  1 },{   4, 19 },{   4,  1  },{   4,  1  } },
+/* 21 */   { {  80,  1 },{  40,  2 },{  20,  2  },{   4,  5  } },
+/* 22 */   { {  88,  1 },{  44,  2 },{   4, 11  },{   4,  1  } },
+/* 23 */   { {  96,  1 },{  32,  3 },{  16,  2  },{   4,  4  } },
+/* 24 */   { {  96,  1 },{  48,  2 },{  24,  2  },{   4,  6  } },
+/* 25 */   { { 104,  1 },{  52,  2 },{   4, 13  },{   4,  1  } },
+/* 26 */   { { 112,  1 },{  56,  2 },{  28,  2  },{   4,  7  } },
+/* 27 */   { { 120,  1 },{  60,  2 },{  20,  3  },{   4,  5  } },
+/* 28 */   { { 120,  1 },{  40,  3 },{   8,  5  },{   4,  2  } },
+/* 29 */   { { 120,  1 },{  24,  5 },{  12,  2  },{   4,  3  } },
+/* 30 */   { { 128,  1 },{  64,  2 },{  32,  2  },{   4,  8  } },
+/* 31 */   { { 128,  1 },{  64,  2 },{  16,  4  },{   4,  4  } },
+/* 32 */   { { 128,  1 },{  16,  8 },{   8,  2  },{   4,  2  } },
+/* 33 */   { { 132,  1 },{  44,  3 },{   4, 11  },{   4,  1  } },
+/* 34 */   { { 136,  1 },{  68,  2 },{   4, 17  },{   4,  1  } },
+/* 35 */   { { 144,  1 },{  72,  2 },{  36,  2  },{   4,  9  } },
+/* 36 */   { { 144,  1 },{  48,  3 },{  24,  2  },{  12,  2  } },
+/* 37 */   { { 144,  1 },{  48,  3 },{  16,  3  },{   4,  4  } },
+/* 38 */   { { 144,  1 },{  16,  9 },{   8,  2  },{   4,  2  } },
+/* 39 */   { { 152,  1 },{  76,  2 },{   4, 19  },{   4,  1  } },
+/* 40 */   { { 160,  1 },{  80,  2 },{  40,  2  },{   4, 10  } },
+/* 41 */   { { 160,  1 },{  80,  2 },{  20,  4  },{   4,  5  } },
+/* 42 */   { { 160,  1 },{  32,  5 },{  16,  2  },{   4,  4  } },
+/* 43 */   { { 168,  1 },{  84,  2 },{  28,  3  },{   4,  7  } },
+/* 44 */   { { 176,  1 },{  88,  2 },{  44,  2  },{   4, 11  } },
+/* 45 */   { { 184,  1 },{  92,  2 },{   4, 23  },{   4,  1  } },
+/* 46 */   { { 192,  1 },{  96,  2 },{  48,  2  },{   4, 12  } },
+/* 47 */   { { 192,  1 },{  96,  2 },{  24,  4  },{   4,  6  } },
+/* 48 */   { { 192,  1 },{  64,  3 },{  16,  4  },{   4,  4  } },
+/* 49 */   { { 192,  1 },{  24,  8 },{   8,  3  },{   4,  2  } },
+/* 50 */   { { 208,  1 },{ 104,  2 },{  52,  2  },{   4, 13  } },
+/* 51 */   { { 216,  1 },{ 108,  2 },{  36,  3  },{   4,  9  } },
+/* 52 */   { { 224,  1 },{ 112,  2 },{  56,  2  },{   4, 14  } },
+/* 53 */   { { 240,  1 },{ 120,  2 },{  60,  2  },{   4, 15  } },
+/* 54 */   { { 240,  1 },{  80,  3 },{  20,  4  },{   4,  5  } },
+/* 55 */   { { 240,  1 },{  48,  5 },{  16,  3  },{   8,  2  } },
+/* 56 */   { { 240,  1 },{  24, 10 },{  12,  2  },{   4,  3  } },
+/* 57 */   { { 256,  1 },{ 128,  2 },{  64,  2  },{   4, 16  } },
+/* 58 */   { { 256,  1 },{ 128,  2 },{  32,  4  },{   4,  8  } },
+/* 59 */   { { 256,  1 },{  16, 16 },{   8,  2  },{   4,  2  } },
+/* 60 */   { { 264,  1 },{ 132,  2 },{  44,  3  },{   4, 11  } },
+/* 61 */   { { 272,  1 },{ 136,  2 },{  68,  2  },{   4, 17  } },
+/* 62 */   { { 272,  1 },{  68,  4 },{   4, 17  },{   4,  1  } },
+/* 63 */   { { 272,  1 },{  16, 17 },{   8,  2  },{   4,  2  } },
+}
+#endif
+;
+
+#define SRS_PERIODICITY                 (17)
+
+EXTERN const uint16_t srs_periodicity[SRS_PERIODICITY]
+#ifdef INIT_VARIABLES_SRS_MODULATION_NR_H
+= { 1, 2, 4, 5, 8, 10, 16, 20, 32, 40, 64, 80, 160, 320, 640, 1280, 2560}
+#endif
+;
+
+/*************** FUNCTIONS *****************************************/
+
+/** \brief This function generates the sounding reference symbol (SRS) for the uplink according to 38.211 6.4.1.4 Sounding reference signal
+    @param frame_parms NR DL Frame parameters
+    @param txdataF pointer to the frequency domain TX signal
+    @param amp amplitude of generated signal
+    @param proc pointer to the transmit parameters
+    @returns 0 on success -1 on error with message */
+
+int32_t generate_srs_nr(SRS_ResourceSet_t *p_srs_resource_set,
+                        NR_DL_FRAME_PARMS *frame_parms,
+                        int32_t *txptr,
+                        int16_t amp,
+                        UE_nr_rxtx_proc_t *proc);
+
+/** \brief This function checks for periodic srs if srs should be transmitted in this slot
+ *  @param p_SRS_Resource pointer to active resource
+    @param frame_parms NR DL Frame parameters
+    @param txdataF pointer to the frequency domain TX signal
+    @returns 0 if srs should be transmitted -1 on error with message */
+
+int is_srs_period_nr(SRS_Resource_t *p_SRS_Resource,
+                     NR_DL_FRAME_PARMS *frame_parms,
+                     int frame_tx, int slot_tx);
+/** \brief This function processes srs configuration
+ *  @param ue context
+    @param rxtx context
+    @param current eNB identifier
+    @returns 0 if srs is transmitted -1 otherwise */
+
+int ue_srs_procedure_nr(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t eNB_id);
+
+#undef EXTERN
+#undef INIT_VARIABLES_SRS_MODULATION_NR_H
+
+#endif /* SRS_MODULATION_NR_H */
diff --git a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c
new file mode 100644
index 0000000000000000000000000000000000000000..41b9383a915518e4358f1b2ead56206eff2871d9
--- /dev/null
+++ b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c
@@ -0,0 +1,603 @@
+/*
+ * 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
+ */
+
+/**********************************************************************
+*
+* FILENAME    :  sss_nr.c
+*
+* MODULE      :  Functions for secundary synchronisation signal
+*
+* DESCRIPTION :  generation of sss
+*                3GPP TS 38.211 7.4.2.3 Secondary synchronisation signal
+*
+************************************************************************/
+
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+
+#include "PHY/defs_nr_UE.h"
+#include "PHY/MODULATION/modulation_UE.h"
+
+#include "PHY/NR_REFSIG/ss_pbch_nr.h"
+
+#define DEFINE_VARIABLES_SSS_NR_H
+#include "PHY/NR_REFSIG/sss_nr.h"
+#undef DEFINE_VARIABLES_SSS_NR_H
+
+/*******************************************************************
+*
+* NAME :         init_context_sss_nr
+*
+* PARAMETERS :   N_ID_2 : element 2 of physical layer cell identity
+*                value : { 0, 1, 2 }
+*
+* RETURN :       generate binary sss sequence (this is a m-sequence)
+*                d_sss is a third dimension array depending on
+*                Cell identity elements:
+*                - N_ID_1 : value from 0 to 335
+*                - N_ID_2 : value from 0 to 2
+*
+* DESCRIPTION :  3GPP TS 38.211 7.4.2.3 Secundary synchronisation signal
+*                Sequence generation
+*
+*********************************************************************/
+
+#define INITIAL_SSS_NR    (7)
+
+void init_context_sss_nr(int amp)
+{
+  int16_t x0[LENGTH_SSS_NR];
+  int16_t x1[LENGTH_SSS_NR];
+  int16_t dss_current;
+  int m0, m1;
+
+  const int x0_initial[INITIAL_SSS_NR] = { 1, 0, 0, 0, 0, 0, 0 };
+  const int x1_initial[INITIAL_SSS_NR] = { 1, 0, 0, 0, 0, 0, 0 };
+
+  for (int i=0; i < INITIAL_SSS_NR; i++) {
+    x0[i] = x0_initial[i];
+    x1[i] = x1_initial[i];
+  }
+
+  for (int i=0; i < (LENGTH_SSS_NR - INITIAL_SSS_NR); i++) {
+    x0[i+7] = (x0[i + 4] + x0[i])%(2);
+    x1[i+7] = (x1[i + 1] + x1[i])%(2);
+  }
+
+  for (int N_ID_2 = 0; N_ID_2 < N_ID_2_NUMBER; N_ID_2++) {
+
+    for (int N_ID_1 = 0; N_ID_1 < N_ID_1_NUMBER; N_ID_1++) {
+
+      m0 = 15*(N_ID_1/112) + (5*N_ID_2);
+      m1 = N_ID_1%112;
+
+      for (int n = 0; n < LENGTH_SSS_NR; n++) {
+
+        dss_current = (1 - 2*x0[(n + m0)%(LENGTH_SSS_NR)])*(1 - 2*x1[(n + m1)%(LENGTH_SSS_NR)]);
+
+      /* Modulation of SSS is a BPSK TS 36.211 chapter 5.1.2 BPSK */
+#if 1
+        d_sss[N_ID_2][N_ID_1][n]   = dss_current * amp;
+#else
+        (void) amp;
+        d_sss[N_ID_2][N_ID_1][n]   = (dss_current * SHRT_MAX)>>SCALING_PSS_NR;
+#endif
+      }
+    }
+  }
+
+#if 0
+  for (int i = 0; i < LENGTH_SSS_NR; i++) {
+    printf("sss ref[%i] : %d %d \n", i, d_sss[0][0][i], d_sss[0][0][i]);
+  }
+#endif
+}
+
+/*******************************************************************
+*
+* NAME :         insert_sss_nr
+*
+* PARAMETERS :   pointer to input buffer for which sss in inserted
+*                amp amplitude applied to input
+*                frame parameters for cell identity
+*
+* RETURN :       none
+*
+* DESCRIPTION :  Allow to generate a reference sss sequence according to cell identity
+*
+*********************************************************************/
+
+void insert_sss_nr(int16_t *sss_time,
+                   NR_DL_FRAME_PARMS *frame_parms)
+{
+  unsigned int ofdm_symbol_size = frame_parms->ofdm_symbol_size;
+  unsigned int size = ofdm_symbol_size * IQ_SIZE; /* i & q */
+
+  assert(size <= SYNCF_TMP_SIZE);
+  assert(size <= SYNC_TMP_SIZE);
+
+  bzero(synchroF_tmp, size);
+  bzero(synchro_tmp, size);
+
+  int Nid2 = GET_NID2(frame_parms->Nid_cell);
+  int Nid1 = GET_NID1(frame_parms->Nid_cell);
+
+  /* call of IDFT should be done with ordered input as below
+    *
+    *                n input samples
+    *  <------------------------------------------------>
+    *  0                                                n
+    *  are written into input buffer for IFFT in this order
+    *   -------------------------------------------------
+    *  |xxxxxxx                       N/2       xxxxxxxx|
+    *  --------------------------------------------------
+    *  ^      ^                 ^               ^          ^
+    *  |      |                 |               |          |
+    * n/2    end of            n=0            start of    n/2-1
+    *         sss                               sss
+    *
+    *                   Frequencies
+    *      positives                   negatives
+    * 0                 (+N/2)(-N/2)
+    * |-----------------------><-------------------------|
+    *
+    * sample 0 is for continuous frequency which is not used here
+    */
+
+  unsigned int k = ofdm_symbol_size - ((LENGTH_SSS_NR/2)+1);
+
+  /* SSS is directly mapped to subcarrier */
+  for (int i=0; i<LENGTH_SSS_NR; i++) {
+    synchroF_tmp[2*k] = d_sss[Nid2][Nid1][i];
+    synchroF_tmp[2*k+1] = 0;
+
+    k++;
+
+    if (k >= ofdm_symbol_size) {
+      k++;
+      k-=ofdm_symbol_size;
+    }
+  }
+
+  /* get sss in the frequency domain by applying an inverse FFT */
+  idft2048(synchroF_tmp,          /* complex input */
+           synchro_tmp,           /* complex output */
+   	       1);                 /* scaling factor */
+
+  /* then get final sss in time */
+  for (unsigned int i=0; i<ofdm_symbol_size; i++) {
+    ((int32_t *)sss_time)[i] = ((int32_t *)synchro_tmp)[i];
+  }
+}
+
+/*******************************************************************
+*
+* NAME :         pss_ch_est
+*
+* PARAMETERS :   none
+*
+* RETURN :       none
+*
+* DESCRIPTION :  pss channel estimation
+*
+*********************************************************************/
+
+int pss_ch_est_nr(PHY_VARS_NR_UE *ue,
+                  int32_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR],
+                  int32_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR])
+{
+  int16_t *pss;
+  int16_t *pss_ext2,*sss_ext2,*sss_ext3,tmp_re,tmp_im,tmp_re2,tmp_im2;
+  uint8_t aarx,i;
+  NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
+
+  pss = primary_synchro_nr[ue->common_vars.eNb_id];
+
+  sss_ext3 = (int16_t*)&sss_ext[0][0];
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+    sss_ext2 = (int16_t*)&sss_ext[aarx][0];
+    pss_ext2 = (int16_t*)&pss_ext[aarx][0];
+
+
+#if 0
+
+  int16_t *p = pss;
+
+  for (int i = 0; i < LENGTH_PSS_NR; i++) {
+    printf(" pss ref [%d]  %d  %d at address %p\n", i, p[2*i], p[2*i+1], &p[2*i]);
+    printf(" pss ext [%d]  %d  %d at address %p\n", i, pss_ext2[2*i], pss_ext2[2*i+1], &pss_ext2[2*i]);
+  }
+
+#endif
+
+#if 0
+
+  for (int i = 0; i < LENGTH_PSS_NR; i++) {
+    printf(" sss ext 2 [%d]  %d  %d at address %p\n", i, sss_ext2[2*i], sss_ext2[2*i+1], &sss_ext2[2*i]);
+    printf(" sss ref   [%d]  %d  %d at address %p\n", i, d_sss[0][0][i], d_sss[0][0][i], &d_sss[0][0][i]);
+  }
+
+#endif
+
+    for (i = 0; i < LENGTH_PSS_NR; i++) {
+
+      // This is H*(PSS) = R* \cdot PSS
+      tmp_re = (int16_t)(((pss_ext2[i*2] * (int32_t)pss[i*2])>>SCALING_CE_PSS_NR)   + ((pss_ext2[i*2+1] * (int32_t)pss[i*2+1])>>SCALING_CE_PSS_NR));
+      tmp_im = (int16_t)(((pss_ext2[i*2] * (int32_t)pss[i*2+1])>>SCALING_CE_PSS_NR) - ((pss_ext2[i*2+1] * (int32_t)pss[i*2])>>SCALING_CE_PSS_NR));
+      //printf("H*(%d,%d) : (%d,%d)\n",aarx,i,tmp_re,tmp_im);
+      //printf("pss(%d,%d) : (%d,%d)\n",aarx,i,pss[2*i],pss[2*i+1]);
+      //printf("pss_ext(%d,%d) : (%d,%d)\n",aarx,i,pss_ext2[2*i],pss_ext2[2*i+1]);
+
+      // This is R(SSS) \cdot H*(PSS)
+      tmp_re2 = (int16_t)(((tmp_re * (int32_t)sss_ext2[i*2])>>SCALING_CE_PSS_NR)    - ((tmp_im * (int32_t)sss_ext2[i*2+1]>>SCALING_CE_PSS_NR)));
+      tmp_im2 = (int16_t)(((tmp_re * (int32_t)sss_ext2[i*2+1])>>SCALING_CE_PSS_NR)  + ((tmp_im * (int32_t)sss_ext2[i*2]>>SCALING_CE_PSS_NR)));
+
+      // printf("SSSi(%d,%d) : (%d,%d)\n",aarx,i,sss_ext2[i<<1],sss_ext2[1+(i<<1)]);
+      // printf("SSSo(%d,%d) : (%d,%d)\n",aarx,i,tmp_re2,tmp_im2);
+      // MRC on RX antennas
+      if (aarx==0) {
+        sss_ext3[i<<1]      = tmp_re2;
+        sss_ext3[1+(i<<1)]  = tmp_im2;
+      } else {
+        sss_ext3[i<<1]      += tmp_re2;
+        sss_ext3[1+(i<<1)]  += tmp_im2;
+      }
+    }
+  }
+
+#if 0
+
+  for (int i = 0; i < LENGTH_PSS_NR; i++) {
+    printf(" sss ext 2 [%d]  %d  %d at address %p\n", i, sss_ext2[2*i], sss_ext2[2*i+1]);
+    printf(" sss ref   [%d]  %d  %d at address %p\n", i, d_sss[0][0][i], d_sss[0][0][i]);
+    printf(" sss ext 3 [%d]  %d  %d at address %p\n", i, sss_ext3[2*i], sss_ext3[2*i+1]);
+  }
+
+#endif
+
+  // sss_ext now contains the compensated SSS
+  return(0);
+}
+
+/*******************************************************************
+*
+* NAME :         do_pss_sss_extract
+*
+* PARAMETERS :   none
+*
+* RETURN :       none
+*
+* DESCRIPTION : it allows extracting sss from samples buffer
+*
+*********************************************************************/
+
+int do_pss_sss_extract_nr(PHY_VARS_NR_UE *ue,
+                          int32_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR],
+                          int32_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR],
+                          uint8_t doPss, uint8_t doSss,
+					      uint8_t subframe) // add flag to indicate extracting only PSS, only SSS, or both
+{
+  uint8_t aarx;
+  int32_t *pss_rxF,*pss_rxF_ext;
+  int32_t *sss_rxF,*sss_rxF_ext;
+  uint8_t pss_symbol, sss_symbol;
+  int32_t **rxdataF;
+  NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
+
+#if 1
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+    pss_symbol = PSS_SYMBOL_NB;  /* symbol position */
+    sss_symbol = SSS_SYMBOL_NB;
+
+    rxdataF  =  ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF;
+
+    unsigned int ofdm_symbol_size = frame_parms->ofdm_symbol_size;
+
+    pss_rxF  =  &rxdataF[aarx][pss_symbol*ofdm_symbol_size];
+    sss_rxF  =  &rxdataF[aarx][sss_symbol*ofdm_symbol_size];
+
+    pss_rxF_ext = &pss_ext[aarx][0];
+    sss_rxF_ext = &sss_ext[aarx][0];
+
+    unsigned int k = ofdm_symbol_size - ((LENGTH_PSS_NR/2)+1);
+
+    for (int i=0; i < LENGTH_PSS_NR; i++) {
+      if (doPss) {		  
+        pss_rxF_ext[i] = pss_rxF[k];
+      }
+
+      if (doSss) {
+        sss_rxF_ext[i] = sss_rxF[k];
+      }
+
+      k++;
+
+      if (k >= ofdm_symbol_size) {
+	    k++;
+        k-=ofdm_symbol_size;
+      }
+    }
+  }
+
+#if 0
+
+  int16_t *p = (int16_t *)sss_rxF_ext;
+
+  for (int i = 0; i < LENGTH_PSS_NR; i++) {
+    printf(" sss ext 2 [%d]  %d  %d at address %p\n", i, p[2*i], p[2*i+1], &p[2*i]);
+    printf(" sss ref   [%d]  %d  %d at address %p\n", i, d_sss[0][0][i], d_sss[0][0][i], &d_sss[0][0][i]);
+  }
+
+#endif
+
+#if 0
+
+  int16_t *p2 = (int16_t *)pss_rxF_ext;
+
+  for (int i = 0; i < LENGTH_PSS_NR; i++) {
+    printf(" pss_rxF_ext [%d]  %d  %d at address %p\n", i, p2[2*i], p2[2*i+1], &p2[2*i]);
+  }
+
+#endif
+
+#else
+
+  /* same method as LTE implementation */
+
+  uint16_t rb,nb_rb = N_RB_SS_PBCH_BLOCK;
+
+  int rx_offset = frame_parms->ofdm_symbol_size - (LENGTH_SSS_NR/2);
+
+  for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
+
+    pss_symbol = PSS_SYMBOL_NB;
+    sss_symbol = SSS_SYMBOL_NB;
+
+    rxdataF  =  ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF;
+    pss_rxF  =  &rxdataF[aarx][(rx_offset + (pss_symbol*(frame_parms->ofdm_symbol_size)))];
+    sss_rxF  =  &rxdataF[aarx][(rx_offset + (sss_symbol*(frame_parms->ofdm_symbol_size)))];
+
+    //printf("extract_rbs: symbol_mod=%d, rx_offset=%d, ch_offset=%d\n",symbol_mod,
+    //   (rx_offset + (symbol*(frame_parms->ofdm_symbol_size)))*2,
+    //   LTE_CE_OFFSET+ch_offset+(symbol_mod*(frame_parms->ofdm_symbol_size)));
+
+    pss_rxF_ext = &pss_ext[aarx][0];
+    sss_rxF_ext = &sss_ext[aarx][0];
+
+    for (rb=0; rb<nb_rb; rb++) {
+
+      for (int i=0; i<N_SC_RB; i++) {
+        if (doPss) {pss_rxF_ext[i] = pss_rxF[i];}
+        if (doSss) {sss_rxF_ext[i] = sss_rxF[i];}
+      }
+
+      pss_rxF += N_SC_RB;
+      sss_rxF += N_SC_RB;
+      pss_rxF_ext += N_SC_RB;
+      sss_rxF_ext += N_SC_RB;
+    }
+  }
+
+#endif
+
+  return(0);
+}
+
+/*******************************************************************
+*
+* NAME :         rx_sss_nr
+*
+* PARAMETERS :   none
+*
+* RETURN :       none
+*
+* DESCRIPTION :
+*
+*********************************************************************/
+
+int pss_sss_extract_nr(PHY_VARS_NR_UE *phy_vars_ue,
+                       int32_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR],
+                       int32_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR],
+					   uint8_t subframe)
+{
+  return do_pss_sss_extract_nr(phy_vars_ue, pss_ext, sss_ext, 1 /* doPss */, 1 /* doSss */, subframe);
+}
+
+/*******************************************************************
+*
+* NAME :         rx_sss_nr
+*
+* PARAMETERS :   none
+*
+* RETURN :       Set Nid_cell in ue context
+*
+* DESCRIPTION :  Determine element Nid1 of cell identity
+*                so Nid_cell in ue context is set according to Nid1 & Nid2
+*
+*********************************************************************/
+
+int rx_sss_nr(PHY_VARS_NR_UE *ue, int32_t *tot_metric,uint8_t *phase_max)
+{
+  uint8_t i;
+  int32_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR];
+  int32_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR];
+  uint8_t Nid2 = GET_NID2(ue->common_vars.eNb_id);
+  uint16_t Nid1;
+  uint8_t phase;
+  int16_t *sss;
+  NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms;
+  int32_t metric, metric_re;
+  int16_t *d;
+
+  /* slop_fep function works for lte and takes into account begining of frame with prefix for subframe 0 */
+  /* for NR this is not the case but slot_fep is still used for computing FFT of samples */
+  /* in order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */
+  /* symbol number are from beginning of SS/PBCH blocks as below:  */
+  /*    Signal            PSS  PBCH  SSS  PBCH                     */
+  /*    symbol number      0     1    2    3                       */
+  /* time samples in buffer rxdata are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */
+  /* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */
+
+  int nb_prefix_samples0 = frame_parms->nb_prefix_samples0;
+  frame_parms->nb_prefix_samples0 = 0;
+
+  // Do FFTs for SSS/PSS
+  // SSS
+  slot_fep_pbch(ue,
+           SSS_SYMBOL_NB,      // symbol number
+           0,                  // Ns slot number
+           ue->rx_offset,      // sample_offset of int16_t
+           0,                  // no_prefix
+           1);                 // reset frequency estimation
+
+  // PSS
+  slot_fep_pbch(ue,
+           PSS_SYMBOL_NB,
+           0,
+           ue->rx_offset,
+           0,
+           1);
+
+  frame_parms->nb_prefix_samples0 = nb_prefix_samples0;
+
+  // pss sss extraction
+  pss_sss_extract_nr(ue,
+                     pss_ext,
+                     sss_ext,
+                     0);          /* subframe */
+
+#ifdef DEBUG_PLOT_SSS
+
+  write_output("rxsig0.m","rxs0",&ue->common_vars.rxdata[0][0],ue->frame_parms.samples_per_tti,1,1);
+  write_output("rxdataF0.m","rxF0",&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[0]].rxdataF[0],frame_parms->ofdm_symbol_size,2,1);
+  write_output("pss_ext.m","pss_ext",pss_ext,LENGTH_PSS_NR,1,1);
+
+#endif
+
+#if 0
+
+  write_output("sss_ext.m","sss_ext",sss_ext,LENGTH_SSS_NR,1,1);
+  write_output("sss_ref.m","sss_ref", d_sss,LENGTH_SSS_NR,1,1);
+
+#endif
+
+#if 0
+  int16_t *p = (int16_t *)sss_ext[0];
+  int16_t *p2 = (int16_t *)pss_ext[0];
+
+  for (int i = 0; i < LENGTH_SSS_NR; i++) {
+    printf("sss ref  [%i] : %d %d \n", i, d_sss[0][0][i], d_sss[0][0][i]);
+    printf("sss ext  [%i] : %d %d \n", i, p[2*i], p[2*i+1]);
+
+    printf("pss ref [%i] : %d %d \n", i, primary_synchro_nr[0][2*i], primary_synchro_nr[0][2*i+1]);
+    printf("pss ext [%i] : %d %d \n", i, p2[2*i], p2[2*i+1]);
+  }
+#endif
+
+  // get conjugated channel estimate from PSS, H* = R* \cdot PSS
+  // and do channel estimation and compensation based on PSS
+
+  pss_ch_est_nr(ue,
+                pss_ext,
+                sss_ext);
+
+  // now do the SSS detection based on the precomputed sequences in PHY/LTE_TRANSPORT/sss.h
+  *tot_metric = INT_MIN;
+
+  sss = (int16_t*)&sss_ext[0][0];
+
+#if 0
+
+  /* simulate of a phase shift on the signal */
+
+  int phase_shift_index = 0;
+
+  phase_shift_samples(sss, LENGTH_SSS_NR, phase_re_nr[phase_shift_index], phase_im_nr[phase_shift_index]);
+
+#endif
+
+#if 0
+        int16_t *ps = (int16_t *)pss_ext;
+
+        for (int i = 0; i < LENGTH_SSS_NR; i++) {
+          printf("sss ref  [%i] : %d %d \n", i, d_sss[0][0][i], d_sss[0][0][i]);
+          printf("sss ext  [%i] : %d %d \n", i, sss[2*i], sss[2*i+1]);
+
+          printf("pss ref [%i] : %d %d \n", i, primary_synchro_nr[0][2*i], primary_synchro_nr[0][2*i+1]);
+          printf("pss ext [%i] : %d %d \n", i, ps[2*i], ps[2*i+1]);
+        }
+#endif
+
+  /* for phase evaluation, one uses an array of possible phase shifts */
+  /* then a correlation is done between received signal with a shift pĥase and the reference signal */
+  /* Computation of signal with shift phase is based on below formula */
+  /* cosinus cos(x + y) = cos(x)cos(y) - sin(x)sin(y) */
+  /* sinus   sin(x + y) = sin(x)cos(y) + cos(x)sin(y) */
+
+  for (phase=0; phase < PHASE_HYPOTHESIS_NUMBER; phase++) {  // phase offset between PSS and SSS
+    for (Nid1 = 0 ; Nid1 < N_ID_1_NUMBER; Nid1++) {          // all possible Nid1 values
+
+      metric = 0;
+      metric_re = 0;
+
+      d = (int16_t *)&d_sss[Nid2][Nid1];
+
+      // This is the inner product using one particular value of each unknown parameter
+      for (i=0; i < LENGTH_SSS_NR; i++) {
+
+        metric_re += d[i]*(((phase_re_nr[phase]*sss[2*i])>>SCALING_METRIC_SSS_NR) - ((phase_im_nr[phase]*sss[2*i+1])>>SCALING_METRIC_SSS_NR))
+                   + d[i]*(((phase_im_nr[phase]*sss[2*i])>>SCALING_METRIC_SSS_NR) + ((phase_re_nr[phase]*sss[2*i+1])>>SCALING_METRIC_SSS_NR));
+      }
+
+      metric = metric_re;
+
+      // if the current metric is better than the last save it
+      if (metric > *tot_metric) {
+        *tot_metric = metric;
+        ue->frame_parms.Nid_cell = Nid2+(3*Nid1);
+        *phase_max = phase;
+
+#ifdef DEBUG_SSS_NR
+
+        printf("(phase,Nid1) (%d,%d), metric_phase %d tot_metric %d, phase_max %d \n",phase, Nid1, metric, *tot_metric, *phase_max);
+
+#endif
+      }
+    }
+  }
+
+//#ifdef DEBUG_SSS_NR
+
+#define SSS_METRIC_FLOOR_NR   (30000)
+if (*tot_metric > SSS_METRIC_FLOOR_NR) {	
+    Nid2 = GET_NID2(frame_parms->Nid_cell);
+    Nid1 = GET_NID1(frame_parms->Nid_cell);
+    printf("Nid2 %d Nid1 %d tot_metric %d, phase_max %d \n", Nid2, Nid1, *tot_metric, *phase_max);
+}
+//#endif
+
+  return(0);
+}
diff --git a/openair1/PHY/TOOLS/lte_dfts.c b/openair1/PHY/TOOLS/lte_dfts.c
index 9a5a504ec41eea3d6f69ecf84ed20e5d03c0ed9f..6510461dfefcc6a77185735028f89b413cd0d714 100644
--- a/openair1/PHY/TOOLS/lte_dfts.c
+++ b/openair1/PHY/TOOLS/lte_dfts.c
@@ -41,7 +41,7 @@
 
 #define ONE_OVER_SQRT3_Q15 18919
 
-#include "PHY/sse_intrin.h"
+#include "../sse_intrin.h"
 
 #define print_shorts(s,x) printf("%s %d,%d,%d,%d,%d,%d,%d,%d\n",s,(x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5],(x)[6],(x)[7])
 #define print_shorts256(s,x) printf("%s %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",s,(x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5],(x)[6],(x)[7],(x)[8],(x)[9],(x)[10],(x)[11],(x)[12],(x)[13],(x)[14],(x)[15])
@@ -5523,24 +5523,142 @@ void dft1536(int16_t *input, int16_t *output, int scale)
 
 }
 
+#include "twiddle3072.h"
+
 // 1024 x 3
-void dft3072(int16_t *input, int16_t *output)
+void idft3072(int16_t *input, int16_t *output, int scale)
 {
+  int i,i2,j;
+  uint32_t tmp[3][1024] __attribute__((aligned(32)));
+  uint32_t tmpo[3][1024] __attribute__((aligned(32)));
+  simd_q15_t *y128p=(simd_q15_t*)output;
+  simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15);
 
+  for (i=0,j=0; i<1024; i++) {
+    tmp[0][i] = ((uint32_t *)input)[j++];
+    tmp[1][i] = ((uint32_t *)input)[j++];
+    tmp[2][i] = ((uint32_t *)input)[j++];
+  }
+
+  idft1024((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1);
+  idft1024((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1);
+  idft1024((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1);
+
+  /*
+  for (i=1; i<1024; i++) {
+    tmpo[0][i] = tmpo[0][i<<1];
+    tmpo[1][i] = tmpo[1][i<<1];
+    tmpo[2][i] = tmpo[2][i<<1];
+    }*/
+
+  //  write_output("in.m","in",input,3072,1,1);
+  //  write_output("out0.m","o0",tmpo[0],1024,1,1);
+  //  write_output("out1.m","o1",tmpo[1],1024,1,1);
+  //  write_output("out2.m","o2",tmpo[2],1024,1,1);
+
+
+  for (i=0,i2=0; i<2048; i+=8,i2+=4)  {
+    ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]),
+    (simd_q15_t*)(output+i),(simd_q15_t*)(output+2048+i),(simd_q15_t*)(output+4096+i),
+           (simd_q15_t*)(twa3072+i),(simd_q15_t*)(twb3072+i));
+  }
+
+  if (scale==1) {
+    for (i=0; i<48; i++) {
+      y128p[0]  = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128);
+      y128p[1]  = mulhi_int16(y128p[1],ONE_OVER_SQRT3_Q15_128);
+      y128p[2]  = mulhi_int16(y128p[2],ONE_OVER_SQRT3_Q15_128);
+      y128p[3]  = mulhi_int16(y128p[3],ONE_OVER_SQRT3_Q15_128);
+      y128p[4]  = mulhi_int16(y128p[4],ONE_OVER_SQRT3_Q15_128);
+      y128p[5]  = mulhi_int16(y128p[5],ONE_OVER_SQRT3_Q15_128);
+      y128p[6]  = mulhi_int16(y128p[6],ONE_OVER_SQRT3_Q15_128);
+      y128p[7]  = mulhi_int16(y128p[7],ONE_OVER_SQRT3_Q15_128);
+      y128p[8]  = mulhi_int16(y128p[8],ONE_OVER_SQRT3_Q15_128);
+      y128p[9]  = mulhi_int16(y128p[9],ONE_OVER_SQRT3_Q15_128);
+      y128p[10] = mulhi_int16(y128p[10],ONE_OVER_SQRT3_Q15_128);
+      y128p[11] = mulhi_int16(y128p[11],ONE_OVER_SQRT3_Q15_128);
+      y128p[12] = mulhi_int16(y128p[12],ONE_OVER_SQRT3_Q15_128);
+      y128p[13] = mulhi_int16(y128p[13],ONE_OVER_SQRT3_Q15_128);
+      y128p[14] = mulhi_int16(y128p[14],ONE_OVER_SQRT3_Q15_128);
+      y128p[15] = mulhi_int16(y128p[15],ONE_OVER_SQRT3_Q15_128);
+      y128p+=16;
+    }
+  }
+
+  _mm_empty();
+  _m_empty();
 }
 
-void idft3072(int16_t *input, int16_t *output)
+void dft3072(int16_t *input, int16_t *output, int scale)
 {
+  int i,i2,j;
+  uint32_t tmp[3][1024] __attribute__((aligned(32)));
+  uint32_t tmpo[3][1024] __attribute__((aligned(32)));
+  simd_q15_t *y128p=(simd_q15_t*)output;
+  simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15);
+
+  for (i=0,j=0; i<1024; i++) {
+    tmp[0][i] = ((uint32_t *)input)[j++];
+    tmp[1][i] = ((uint32_t *)input)[j++];
+    tmp[2][i] = ((uint32_t *)input)[j++];
+  }
 
+  dft1024((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1);
+  dft1024((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1);
+  dft1024((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1);
+
+  /*
+  for (i=1; i<1024; i++) {
+    tmpo[0][i] = tmpo[0][i<<1];
+    tmpo[1][i] = tmpo[1][i<<1];
+    tmpo[2][i] = tmpo[2][i<<1];
+    }*/
+
+  //  write_output("out0.m","o0",tmpo[0],1024,1,1);
+  //  write_output("out1.m","o1",tmpo[1],1024,1,1);
+  //  write_output("out2.m","o2",tmpo[2],1024,1,1);
+
+  for (i=0,i2=0; i<2048; i+=8,i2+=4) {
+    bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]),
+    (simd_q15_t*)(output+i),(simd_q15_t*)(output+2048+i),(simd_q15_t*)(output+4096+i),
+          (simd_q15_t*)(twa3072+i),(simd_q15_t*)(twb3072+i));
+  }
+
+  if (scale==1) {
+    for (i=0; i<48; i++) {
+      y128p[0]  = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128);
+      y128p[1]  = mulhi_int16(y128p[1],ONE_OVER_SQRT3_Q15_128);
+      y128p[2]  = mulhi_int16(y128p[2],ONE_OVER_SQRT3_Q15_128);
+      y128p[3]  = mulhi_int16(y128p[3],ONE_OVER_SQRT3_Q15_128);
+      y128p[4]  = mulhi_int16(y128p[4],ONE_OVER_SQRT3_Q15_128);
+      y128p[5]  = mulhi_int16(y128p[5],ONE_OVER_SQRT3_Q15_128);
+      y128p[6]  = mulhi_int16(y128p[6],ONE_OVER_SQRT3_Q15_128);
+      y128p[7]  = mulhi_int16(y128p[7],ONE_OVER_SQRT3_Q15_128);
+      y128p[8]  = mulhi_int16(y128p[8],ONE_OVER_SQRT3_Q15_128);
+      y128p[9]  = mulhi_int16(y128p[9],ONE_OVER_SQRT3_Q15_128);
+      y128p[10] = mulhi_int16(y128p[10],ONE_OVER_SQRT3_Q15_128);
+      y128p[11] = mulhi_int16(y128p[11],ONE_OVER_SQRT3_Q15_128);
+      y128p[12] = mulhi_int16(y128p[12],ONE_OVER_SQRT3_Q15_128);
+      y128p[13] = mulhi_int16(y128p[13],ONE_OVER_SQRT3_Q15_128);
+      y128p[14] = mulhi_int16(y128p[14],ONE_OVER_SQRT3_Q15_128);
+      y128p[15] = mulhi_int16(y128p[15],ONE_OVER_SQRT3_Q15_128);
+      y128p+=16;
+    }
+  }
+
+  _mm_empty();
+  _m_empty();
 }
 
 #include "twiddle6144.h"
 
-void idft6144(int16_t *input, int16_t *output)
+void idft6144(int16_t *input, int16_t *output, int scale)
 {
   int i,i2,j;
   uint32_t tmp[3][2048] __attribute__((aligned(32)));
   uint32_t tmpo[3][2048] __attribute__((aligned(32)));
+  simd_q15_t *y128p=(simd_q15_t*)output;
+  simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15);
 
   for (i=0,j=0; i<2048; i++) {
     tmp[0][i] = ((uint32_t *)input)[j++];
@@ -5570,6 +5688,28 @@ void idft6144(int16_t *input, int16_t *output)
 	   (simd_q15_t*)(twa6144+i),(simd_q15_t*)(twb6144+i));
   }
 
+  if (scale==1) {
+    for (i=0; i<96; i++) {
+      y128p[0]  = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128);
+      y128p[1]  = mulhi_int16(y128p[1],ONE_OVER_SQRT3_Q15_128);
+      y128p[2]  = mulhi_int16(y128p[2],ONE_OVER_SQRT3_Q15_128);
+      y128p[3]  = mulhi_int16(y128p[3],ONE_OVER_SQRT3_Q15_128);
+      y128p[4]  = mulhi_int16(y128p[4],ONE_OVER_SQRT3_Q15_128);
+      y128p[5]  = mulhi_int16(y128p[5],ONE_OVER_SQRT3_Q15_128);
+      y128p[6]  = mulhi_int16(y128p[6],ONE_OVER_SQRT3_Q15_128);
+      y128p[7]  = mulhi_int16(y128p[7],ONE_OVER_SQRT3_Q15_128);
+      y128p[8]  = mulhi_int16(y128p[8],ONE_OVER_SQRT3_Q15_128);
+      y128p[9]  = mulhi_int16(y128p[9],ONE_OVER_SQRT3_Q15_128);
+      y128p[10] = mulhi_int16(y128p[10],ONE_OVER_SQRT3_Q15_128);
+      y128p[11] = mulhi_int16(y128p[11],ONE_OVER_SQRT3_Q15_128);
+      y128p[12] = mulhi_int16(y128p[12],ONE_OVER_SQRT3_Q15_128);
+      y128p[13] = mulhi_int16(y128p[13],ONE_OVER_SQRT3_Q15_128);
+      y128p[14] = mulhi_int16(y128p[14],ONE_OVER_SQRT3_Q15_128);
+      y128p[15] = mulhi_int16(y128p[15],ONE_OVER_SQRT3_Q15_128);
+      y128p+=16;
+    }
+  }
+
   //  write_output("out.m","out",output,6144,1,1);
   _mm_empty();
   _m_empty();
@@ -5577,11 +5717,13 @@ void idft6144(int16_t *input, int16_t *output)
 }
 
 
-void dft6144(int16_t *input, int16_t *output)
+void dft6144(int16_t *input, int16_t *output, int scale)
 {
   int i,i2,j;
   uint32_t tmp[3][2048] __attribute__((aligned(32)));
   uint32_t tmpo[3][2048] __attribute__((aligned(32)));
+  simd_q15_t *y128p=(simd_q15_t*)output;
+  simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15);
 
   for (i=0,j=0; i<2048; i++) {
     tmp[0][i] = ((uint32_t *)input)[j++];
@@ -5609,6 +5751,28 @@ void dft6144(int16_t *input, int16_t *output)
           (simd_q15_t*)(twa6144+i),(simd_q15_t*)(twb6144+i));
   }
 
+  if (scale==1) {
+    for (i=0; i<96; i++) {
+      y128p[0]  = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128);
+      y128p[1]  = mulhi_int16(y128p[1],ONE_OVER_SQRT3_Q15_128);
+      y128p[2]  = mulhi_int16(y128p[2],ONE_OVER_SQRT3_Q15_128);
+      y128p[3]  = mulhi_int16(y128p[3],ONE_OVER_SQRT3_Q15_128);
+      y128p[4]  = mulhi_int16(y128p[4],ONE_OVER_SQRT3_Q15_128);
+      y128p[5]  = mulhi_int16(y128p[5],ONE_OVER_SQRT3_Q15_128);
+      y128p[6]  = mulhi_int16(y128p[6],ONE_OVER_SQRT3_Q15_128);
+      y128p[7]  = mulhi_int16(y128p[7],ONE_OVER_SQRT3_Q15_128);
+      y128p[8]  = mulhi_int16(y128p[8],ONE_OVER_SQRT3_Q15_128);
+      y128p[9]  = mulhi_int16(y128p[9],ONE_OVER_SQRT3_Q15_128);
+      y128p[10] = mulhi_int16(y128p[10],ONE_OVER_SQRT3_Q15_128);
+      y128p[11] = mulhi_int16(y128p[11],ONE_OVER_SQRT3_Q15_128);
+      y128p[12] = mulhi_int16(y128p[12],ONE_OVER_SQRT3_Q15_128);
+      y128p[13] = mulhi_int16(y128p[13],ONE_OVER_SQRT3_Q15_128);
+      y128p[14] = mulhi_int16(y128p[14],ONE_OVER_SQRT3_Q15_128);
+      y128p[15] = mulhi_int16(y128p[15],ONE_OVER_SQRT3_Q15_128);
+      y128p+=16;
+    }
+  }
+
   _mm_empty();
   _m_empty();
 
@@ -5701,9 +5865,9 @@ void dft18432(int16_t *input, int16_t *output) {
     tmp[2][i] = ((uint32_t *)input)[j++];
   }
 
-  dft6144((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]));
-  dft6144((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]));
-  dft6144((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]));
+  dft6144((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1);
+  dft6144((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1);
+  dft6144((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1);
 
   for (i=0,i2=0; i<12288; i+=8,i2+=4)  {
     bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]),
@@ -5727,9 +5891,9 @@ void idft18432(int16_t *input, int16_t *output) {
     tmp[2][i] = ((uint32_t *)input)[j++];
   }
 
-  idft6144((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]));
-  idft6144((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]));
-  idft6144((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]));
+  idft6144((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1);
+  idft6144((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1);
+  idft6144((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1);
 
   for (i=0,i2=0; i<12288; i+=8,i2+=4)  {
     ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),(simd_q15_t*)(&tmpo[2][i2]),
@@ -19147,6 +19311,33 @@ int main(int argc, char**argv)
   write_output("y1024.m","y1024",y,1024,1,1);
   write_output("x1024.m","x1024",x,1024,1,1);
 
+
+  memset((void*)x,0,1536*sizeof(int32_t));
+  for (i=2;i<1202;i++) {
+    if ((taus() & 1)==0)
+      ((int16_t*)x)[i] = 364;
+    else
+      ((int16_t*)x)[i] = -364;
+  }
+  for (i=2*(1536-600);i<3072;i++) {
+    if ((taus() & 1)==0)
+      ((int16_t*)x)[i] = 364;
+    else
+      ((int16_t*)x)[i] = -364;
+  }
+  reset_meas(&ts);
+
+  for (i=0; i<10000; i++) {
+    start_meas(&ts);
+    idft1536((int16_t *)x,(int16_t *)y,1);
+    stop_meas(&ts);
+  }
+
+  printf("\n\n1536-point(%f cycles)\n",(double)ts.diff/(double)ts.trials);
+  write_output("y1536.m","y1536",y,1536,1,1);
+  write_output("x1536.m","x1536",x,1536,1,1);
+
+
   memset((void*)x,0,2048*sizeof(int32_t));
   for (i=2;i<1202;i++) {
     if ((taus() & 1)==0)
@@ -19172,6 +19363,34 @@ int main(int argc, char**argv)
   write_output("y2048.m","y2048",y,2048,1,1);
   write_output("x2048.m","x2048",x,2048,1,1);
 
+// NR 80Mhz, 217 PRB, 3/4 sampling
+  memset((void*)x, 0, 3072*sizeof(int32_t));
+  for (i=2;i<2506;i++) {
+    if ((taus() & 1)==0)
+      ((int16_t*)x)[i] = 364;
+    else
+      ((int16_t*)x)[i] = -364;
+  }
+  for (i=2*(3072-1252);i<6144;i++) {
+    if ((taus() & 1)==0)
+      ((int16_t*)x)[i] = 364;
+    else
+      ((int16_t*)x)[i] = -364;
+  }
+
+  reset_meas(&ts);
+
+  for (i=0; i<10000; i++) {
+    start_meas(&ts);
+    idft3072((int16_t *)x,(int16_t *)y,1);
+    stop_meas(&ts);
+  }
+
+  printf("\n\n3072-point(%f cycles)\n",(double)ts.diff/(double)ts.trials);
+  write_output("y3072.m","y3072",y,3072,1,1);
+  write_output("x3072.m","x3072",x,3072,1,1);
+
+
   memset((void*)x,0,2048*sizeof(int32_t));
   for (i=2;i<2402;i++) {
     if ((taus() & 1)==0)
@@ -19197,6 +19416,33 @@ int main(int argc, char**argv)
   write_output("y4096.m","y4096",y,4096,1,1);
   write_output("x4096.m","x4096",x,4096,1,1);
 
+// NR 160Mhz, 434 PRB, 3/4 sampling
+  memset((void*)x, 0, 6144*sizeof(int32_t));
+  for (i=2;i<5010;i++) {
+    if ((taus() & 1)==0)
+      ((int16_t*)x)[i] = 364;
+    else
+      ((int16_t*)x)[i] = -364;
+  }
+  for (i=2*(6144-2504);i<12288;i++) {
+    if ((taus() & 1)==0)
+      ((int16_t*)x)[i] = 364;
+    else
+      ((int16_t*)x)[i] = -364;
+  }
+
+  reset_meas(&ts);
+
+  for (i=0; i<10000; i++) {
+    start_meas(&ts);
+    idft6144((int16_t *)x,(int16_t *)y,1);
+    stop_meas(&ts);
+  }
+
+  printf("\n\n6144-point(%f cycles)\n",(double)ts.diff/(double)ts.trials);
+  write_output("y6144.m","y6144",y,6144,1,1);
+  write_output("x6144.m","x6144",x,6144,1,1);
+
   memset((void*)x,0,8192*sizeof(int32_t));
   for (i=2;i<4802;i++) {
     if ((taus() & 1)==0)
diff --git a/openair1/PHY/TOOLS/tools_defs.h b/openair1/PHY/TOOLS/tools_defs.h
index e3b04babdc8f2320f3a319914fbaefbaa20f4a2a..a4266d2d0ef14af5ae10111608ae507ea3c9b5f0 100644
--- a/openair1/PHY/TOOLS/tools_defs.h
+++ b/openair1/PHY/TOOLS/tools_defs.h
@@ -174,25 +174,25 @@ This function performs optimized fixed-point radix-2 FFT/IFFT.
 
 void idft1536(int16_t *sigF,int16_t *sig,int scale);
 
-void idft6144(int16_t *sigF,int16_t *sig);
+void idft6144(int16_t *sigF,int16_t *sig, int scale);
 
 void idft12288(int16_t *sigF,int16_t *sig);
 
 void idft18432(int16_t *sigF,int16_t *sig);
 
-void idft3072(int16_t *sigF,int16_t *sig);
+void idft3072(int16_t *sigF,int16_t *sig, int scale);
 
 void idft24576(int16_t *sigF,int16_t *sig);
 
 void dft1536(int16_t *sigF,int16_t *sig,int scale);
 
-void dft6144(int16_t *sigF,int16_t *sig);
+void dft6144(int16_t *sigF,int16_t *sig, int scale);
 
 void dft12288(int16_t *sigF,int16_t *sig);
 
 void dft18432(int16_t *sigF,int16_t *sig);
 
-void dft3072(int16_t *sigF,int16_t *sig);
+void dft3072(int16_t *sigF,int16_t *sig, int scale);
 
 void dft24576(int16_t *sigF,int16_t *sig);
 
diff --git a/openair1/PHY/TOOLS/twiddle3072.h b/openair1/PHY/TOOLS/twiddle3072.h
new file mode 100644
index 0000000000000000000000000000000000000000..099ef574556542ce6e7ada9e57cd927248e9960b
--- /dev/null
+++ b/openair1/PHY/TOOLS/twiddle3072.h
@@ -0,0 +1,42 @@
+/*
+ * 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
+ */
+
+/* Twiddles generated with
+twa = floor(32767*exp(-sqrt(-1)*2*pi*(0:1023)/3072));
+twb = floor(32767*exp(-sqrt(-1)*2*pi*(0:2:2046)/3072));
+twa2 = zeros(1,2048);
+twb2 = zeros(1,2048);
+twa2(1:2:end) = real(twa);
+twa2(2:2:end) = imag(twa);
+twb2(1:2:end) = real(twb);
+twb2(2:2:end) = imag(twb);
+fd=fopen("twiddle_tmp.txt","w");
+fprintf(fd,"static int16_t twa3072[2048] = {");
+fprintf(fd,"%d,",twa2);
+fprintf(fd,"};\n");
+fprintf(fd,"static int16_t twb3072[2048] = {");
+fprintf(fd,"%d,",twb2);
+fprintf(fd,"};\n");
+fclose(fd);
+ */
+
+static int16_t twa3072[2048] = {32767,0,32766,-68,32766,-135,32766,-202,32765,-269,32765,-336,32764,-403,32763,-470,32762,-537,32761,-604,32760,-671,32758,-738,32757,-805,32755,-872,32753,-939,32751,-1006,32749,-1073,32747,-1140,32744,-1207,32742,-1274,32739,-1340,32736,-1407,32733,-1474,32730,-1541,32727,-1608,32724,-1675,32720,-1742,32717,-1809,32713,-1876,32709,-1943,32705,-2010,32701,-2077,32696,-2144,32692,-2210,32687,-2277,32683,-2344,32678,-2411,32673,-2478,32668,-2545,32662,-2611,32657,-2678,32651,-2745,32646,-2812,32640,-2879,32634,-2945,32628,-3012,32622,-3079,32615,-3146,32609,-3212,32602,-3279,32595,-3346,32588,-3412,32581,-3479,32574,-3546,32567,-3612,32559,-3679,32552,-3745,32544,-3812,32536,-3878,32528,-3945,32520,-4012,32512,-4078,32503,-4145,32495,-4211,32486,-4277,32477,-4344,32468,-4410,32459,-4477,32450,-4543,32441,-4609,32431,-4676,32422,-4742,32412,-4808,32402,-4875,32392,-4941,32382,-5007,32371,-5073,32361,-5140,32350,-5206,32340,-5272,32329,-5338,32318,-5404,32307,-5470,32295,-5536,32284,-5602,32273,-5668,32261,-5734,32249,-5800,32237,-5866,32225,-5932,32213,-5998,32201,-6064,32188,-6130,32176,-6196,32163,-6262,32150,-6327,32137,-6393,32124,-6459,32110,-6524,32097,-6590,32084,-6656,32070,-6721,32056,-6787,32042,-6852,32028,-6918,32014,-6983,31999,-7049,31985,-7114,31970,-7180,31956,-7245,31941,-7311,31926,-7376,31911,-7441,31895,-7506,31880,-7572,31864,-7637,31849,-7702,31833,-7767,31817,-7832,31801,-7897,31785,-7962,31768,-8027,31752,-8092,31735,-8157,31718,-8222,31701,-8287,31684,-8352,31667,-8416,31650,-8481,31633,-8546,31615,-8611,31597,-8675,31580,-8740,31562,-8804,31544,-8869,31525,-8933,31507,-8998,31489,-9062,31470,-9127,31451,-9191,31432,-9255,31413,-9320,31394,-9384,31375,-9448,31356,-9512,31336,-9576,31316,-9640,31297,-9704,31277,-9768,31257,-9832,31236,-9896,31216,-9960,31196,-10024,31175,-10088,31154,-10152,31134,-10215,31113,-10279,31092,-10343,31070,-10406,31049,-10470,31028,-10533,31006,-10597,30984,-10660,30962,-10723,30940,-10787,30918,-10850,30896,-10913,30874,-10976,30851,-11039,30828,-11102,30806,-11165,30783,-11228,30760,-11291,30737,-11354,30713,-11417,30690,-11480,30666,-11543,30643,-11605,30619,-11668,30595,-11731,30571,-11793,30547,-11856,30522,-11918,30498,-11981,30473,-12043,30449,-12105,30424,-12167,30399,-12230,30374,-12292,30349,-12354,30323,-12416,30298,-12478,30272,-12540,30247,-12602,30221,-12664,30195,-12725,30169,-12787,30142,-12849,30116,-12910,30090,-12972,30063,-13034,30036,-13095,30009,-13156,29983,-13218,29955,-13279,29928,-13340,29901,-13401,29873,-13463,29846,-13524,29818,-13585,29790,-13646,29762,-13707,29734,-13767,29706,-13828,29678,-13889,29649,-13950,29621,-14010,29592,-14071,29563,-14131,29534,-14192,29505,-14252,29476,-14312,29446,-14373,29417,-14433,29387,-14493,29358,-14553,29328,-14613,29298,-14673,29268,-14733,29238,-14793,29207,-14853,29177,-14912,29146,-14972,29116,-15031,29085,-15091,29054,-15150,29023,-15210,28992,-15269,28960,-15328,28929,-15388,28897,-15447,28866,-15506,28834,-15565,28802,-15624,28770,-15683,28738,-15741,28706,-15800,28673,-15859,28641,-15918,28608,-15976,28575,-16035,28543,-16093,28510,-16151,28477,-16210,28443,-16268,28410,-16326,28377,-16384,28343,-16442,28309,-16500,28275,-16558,28242,-16616,28208,-16673,28173,-16731,28139,-16789,28105,-16846,28070,-16904,28036,-16961,28001,-17018,27966,-17075,27931,-17133,27896,-17190,27861,-17247,27825,-17304,27790,-17361,27754,-17417,27719,-17474,27683,-17531,27647,-17587,27611,-17644,27575,-17700,27538,-17757,27502,-17813,27466,-17869,27429,-17925,27392,-17981,27355,-18037,27319,-18093,27281,-18149,27244,-18205,27207,-18261,27170,-18316,27132,-18372,27094,-18427,27057,-18483,27019,-18538,26981,-18593,26943,-18648,26905,-18703,26866,-18758,26828,-18813,26789,-18868,26751,-18923,26712,-18977,26673,-19032,26634,-19087,26595,-19141,26556,-19195,26516,-19250,26477,-19304,26437,-19358,26398,-19412,26358,-19466,26318,-19520,26278,-19574,26238,-19627,26198,-19681,26158,-19734,26117,-19788,26077,-19841,26036,-19895,25995,-19948,25954,-20001,25913,-20054,25872,-20107,25831,-20160,25790,-20213,25749,-20265,25707,-20318,25665,-20370,25624,-20423,25582,-20475,25540,-20528,25498,-20580,25456,-20632,25414,-20684,25371,-20736,25329,-20788,25286,-20839,25243,-20891,25201,-20943,25158,-20994,25115,-21046,25072,-21097,25029,-21148,24985,-21199,24942,-21250,24898,-21301,24855,-21352,24811,-21403,24767,-21454,24723,-21504,24679,-21555,24635,-21605,24591,-21656,24546,-21706,24502,-21756,24457,-21806,24413,-21856,24368,-21906,24323,-21956,24278,-22005,24233,-22055,24188,-22105,24143,-22154,24097,-22203,24052,-22253,24006,-22302,23961,-22351,23915,-22400,23869,-22449,23823,-22497,23777,-22546,23731,-22595,23685,-22643,23638,-22692,23592,-22740,23545,-22788,23499,-22836,23452,-22884,23405,-22932,23358,-22980,23311,-23028,23264,-23075,23217,-23123,23169,-23170,23122,-23218,23074,-23265,23027,-23312,22979,-23359,22931,-23406,22883,-23453,22835,-23500,22787,-23546,22739,-23593,22691,-23639,22642,-23686,22594,-23732,22545,-23778,22496,-23824,22448,-23870,22399,-23916,22350,-23962,22301,-24007,22252,-24053,22202,-24098,22153,-24144,22104,-24189,22054,-24234,22004,-24279,21955,-24324,21905,-24369,21855,-24414,21805,-24458,21755,-24503,21705,-24547,21655,-24592,21604,-24636,21554,-24680,21503,-24724,21453,-24768,21402,-24812,21351,-24856,21300,-24899,21249,-24943,21198,-24986,21147,-25030,21096,-25073,21045,-25116,20993,-25159,20942,-25202,20890,-25244,20838,-25287,20787,-25330,20735,-25372,20683,-25415,20631,-25457,20579,-25499,20527,-25541,20474,-25583,20422,-25625,20369,-25666,20317,-25708,20264,-25750,20212,-25791,20159,-25832,20106,-25873,20053,-25914,20000,-25955,19947,-25996,19894,-26037,19840,-26078,19787,-26118,19733,-26159,19680,-26199,19626,-26239,19573,-26279,19519,-26319,19465,-26359,19411,-26399,19357,-26438,19303,-26478,19249,-26517,19194,-26557,19140,-26596,19086,-26635,19031,-26674,18976,-26713,18922,-26752,18867,-26790,18812,-26829,18757,-26867,18702,-26906,18647,-26944,18592,-26982,18537,-27020,18482,-27058,18426,-27095,18371,-27133,18315,-27171,18260,-27208,18204,-27245,18148,-27282,18092,-27320,18036,-27356,17980,-27393,17924,-27430,17868,-27467,17812,-27503,17756,-27539,17699,-27576,17643,-27612,17586,-27648,17530,-27684,17473,-27720,17416,-27755,17360,-27791,17303,-27826,17246,-27862,17189,-27897,17132,-27932,17074,-27967,17017,-28002,16960,-28037,16903,-28071,16845,-28106,16788,-28140,16730,-28174,16672,-28209,16615,-28243,16557,-28276,16499,-28310,16441,-28344,16383,-28378,16325,-28411,16267,-28444,16209,-28478,16150,-28511,16092,-28544,16034,-28576,15975,-28609,15917,-28642,15858,-28674,15799,-28707,15740,-28739,15682,-28771,15623,-28803,15564,-28835,15505,-28867,15446,-28898,15387,-28930,15327,-28961,15268,-28993,15209,-29024,15149,-29055,15090,-29086,15030,-29117,14971,-29147,14911,-29178,14852,-29208,14792,-29239,14732,-29269,14672,-29299,14612,-29329,14552,-29359,14492,-29388,14432,-29418,14372,-29447,14311,-29477,14251,-29506,14191,-29535,14130,-29564,14070,-29593,14009,-29622,13949,-29650,13888,-29679,13827,-29707,13766,-29735,13706,-29763,13645,-29791,13584,-29819,13523,-29847,13462,-29874,13400,-29902,13339,-29929,13278,-29956,13217,-29984,13155,-30010,13094,-30037,13033,-30064,12971,-30091,12909,-30117,12848,-30143,12786,-30170,12724,-30196,12663,-30222,12601,-30248,12539,-30273,12477,-30299,12415,-30324,12353,-30350,12291,-30375,12229,-30400,12166,-30425,12104,-30450,12042,-30474,11980,-30499,11917,-30523,11855,-30548,11792,-30572,11730,-30596,11667,-30620,11604,-30644,11542,-30667,11479,-30691,11416,-30714,11353,-30738,11290,-30761,11227,-30784,11164,-30807,11101,-30829,11038,-30852,10975,-30875,10912,-30897,10849,-30919,10786,-30941,10722,-30963,10659,-30985,10596,-31007,10532,-31029,10469,-31050,10405,-31071,10342,-31093,10278,-31114,10214,-31135,10151,-31155,10087,-31176,10023,-31197,9959,-31217,9895,-31237,9831,-31258,9767,-31278,9703,-31298,9639,-31317,9575,-31337,9511,-31357,9447,-31376,9383,-31395,9319,-31414,9254,-31433,9190,-31452,9126,-31471,9061,-31490,8997,-31508,8932,-31526,8868,-31545,8803,-31563,8739,-31581,8674,-31598,8610,-31616,8545,-31634,8480,-31651,8415,-31668,8351,-31685,8286,-31702,8221,-31719,8156,-31736,8091,-31753,8026,-31769,7961,-31786,7896,-31802,7831,-31818,7766,-31834,7701,-31850,7636,-31865,7571,-31881,7505,-31896,7440,-31912,7375,-31927,7310,-31942,7244,-31957,7179,-31971,7113,-31986,7048,-32000,6982,-32015,6917,-32029,6851,-32043,6786,-32057,6720,-32071,6655,-32085,6589,-32098,6523,-32111,6458,-32125,6392,-32138,6326,-32151,6261,-32164,6195,-32177,6129,-32189,6063,-32202,5997,-32214,5931,-32226,5865,-32238,5799,-32250,5733,-32262,5667,-32274,5601,-32285,5535,-32296,5469,-32308,5403,-32319,5337,-32330,5271,-32341,5205,-32351,5139,-32362,5072,-32372,5006,-32383,4940,-32393,4874,-32403,4807,-32413,4741,-32423,4675,-32432,4608,-32442,4542,-32451,4476,-32460,4409,-32469,4343,-32478,4276,-32487,4210,-32496,4144,-32504,4077,-32513,4011,-32521,3944,-32529,3877,-32537,3811,-32545,3744,-32553,3678,-32560,3611,-32568,3545,-32575,3478,-32582,3411,-32589,3345,-32596,3278,-32603,3211,-32610,3145,-32616,3078,-32623,3011,-32629,2944,-32635,2878,-32641,2811,-32647,2744,-32652,2677,-32658,2610,-32663,2544,-32669,2477,-32674,2410,-32679,2343,-32684,2276,-32688,2209,-32693,2143,-32697,2076,-32702,2009,-32706,1942,-32710,1875,-32714,1808,-32718,1741,-32721,1674,-32725,1607,-32728,1540,-32731,1473,-32734,1406,-32737,1339,-32740,1273,-32743,1206,-32745,1139,-32748,1072,-32750,1005,-32752,938,-32754,871,-32756,804,-32758,737,-32759,670,-32761,603,-32762,536,-32763,469,-32764,402,-32765,335,-32766,268,-32766,201,-32767,134,-32767,67,-32767,0,-32767,-68,-32767,-135,-32767,-202,-32767,-269,-32766,-336,-32766,-403,-32765,-470,-32764,-537,-32763,-604,-32762,-671,-32761,-738,-32759,-805,-32758,-872,-32756,-939,-32754,-1006,-32752,-1073,-32750,-1140,-32748,-1207,-32745,-1274,-32743,-1340,-32740,-1407,-32737,-1474,-32734,-1541,-32731,-1608,-32728,-1675,-32725,-1742,-32721,-1809,-32718,-1876,-32714,-1943,-32710,-2010,-32706,-2077,-32702,-2144,-32697,-2210,-32693,-2277,-32688,-2344,-32684,-2411,-32679,-2478,-32674,-2545,-32669,-2611,-32663,-2678,-32658,-2745,-32652,-2812,-32647,-2879,-32641,-2945,-32635,-3012,-32629,-3079,-32623,-3146,-32616,-3212,-32610,-3279,-32603,-3346,-32596,-3412,-32589,-3479,-32582,-3546,-32575,-3612,-32568,-3679,-32560,-3745,-32553,-3812,-32545,-3878,-32537,-3945,-32529,-4012,-32521,-4078,-32513,-4145,-32504,-4211,-32496,-4277,-32487,-4344,-32478,-4410,-32469,-4477,-32460,-4543,-32451,-4609,-32442,-4676,-32432,-4742,-32423,-4808,-32413,-4875,-32403,-4941,-32393,-5007,-32383,-5073,-32372,-5140,-32362,-5206,-32351,-5272,-32341,-5338,-32330,-5404,-32319,-5470,-32308,-5536,-32296,-5602,-32285,-5668,-32274,-5734,-32262,-5800,-32250,-5866,-32238,-5932,-32226,-5998,-32214,-6064,-32202,-6130,-32189,-6196,-32177,-6262,-32164,-6327,-32151,-6393,-32138,-6459,-32125,-6524,-32111,-6590,-32098,-6656,-32085,-6721,-32071,-6787,-32057,-6852,-32043,-6918,-32029,-6983,-32015,-7049,-32000,-7114,-31986,-7180,-31971,-7245,-31957,-7311,-31942,-7376,-31927,-7441,-31912,-7506,-31896,-7572,-31881,-7637,-31865,-7702,-31850,-7767,-31834,-7832,-31818,-7897,-31802,-7962,-31786,-8027,-31769,-8092,-31753,-8157,-31736,-8222,-31719,-8287,-31702,-8352,-31685,-8416,-31668,-8481,-31651,-8546,-31634,-8611,-31616,-8675,-31598,-8740,-31581,-8804,-31563,-8869,-31545,-8933,-31526,-8998,-31508,-9062,-31490,-9127,-31471,-9191,-31452,-9255,-31433,-9320,-31414,-9384,-31395,-9448,-31376,-9512,-31357,-9576,-31337,-9640,-31317,-9704,-31298,-9768,-31278,-9832,-31258,-9896,-31237,-9960,-31217,-10024,-31197,-10088,-31176,-10152,-31155,-10215,-31135,-10279,-31114,-10343,-31093,-10406,-31071,-10470,-31050,-10533,-31029,-10597,-31007,-10660,-30985,-10723,-30963,-10787,-30941,-10850,-30919,-10913,-30897,-10976,-30875,-11039,-30852,-11102,-30829,-11165,-30807,-11228,-30784,-11291,-30761,-11354,-30738,-11417,-30714,-11480,-30691,-11543,-30667,-11605,-30644,-11668,-30620,-11731,-30596,-11793,-30572,-11856,-30548,-11918,-30523,-11981,-30499,-12043,-30474,-12105,-30450,-12167,-30425,-12230,-30400,-12292,-30375,-12354,-30350,-12416,-30324,-12478,-30299,-12540,-30273,-12602,-30248,-12664,-30222,-12725,-30196,-12787,-30170,-12849,-30143,-12910,-30117,-12972,-30091,-13034,-30064,-13095,-30037,-13156,-30010,-13218,-29984,-13279,-29956,-13340,-29929,-13401,-29902,-13463,-29874,-13524,-29847,-13585,-29819,-13646,-29791,-13707,-29763,-13767,-29735,-13828,-29707,-13889,-29679,-13950,-29650,-14010,-29622,-14071,-29593,-14131,-29564,-14192,-29535,-14252,-29506,-14312,-29477,-14373,-29447,-14433,-29418,-14493,-29388,-14553,-29359,-14613,-29329,-14673,-29299,-14733,-29269,-14793,-29239,-14853,-29208,-14912,-29178,-14972,-29147,-15031,-29117,-15091,-29086,-15150,-29055,-15210,-29024,-15269,-28993,-15328,-28961,-15388,-28930,-15447,-28898,-15506,-28867,-15565,-28835,-15624,-28803,-15683,-28771,-15741,-28739,-15800,-28707,-15859,-28674,-15918,-28642,-15976,-28609,-16035,-28576,-16093,-28544,-16151,-28511,-16210,-28478,-16268,-28444,-16326,-28411,};
+static int16_t twb3072[2048] = {32767,0,32766,-135,32765,-269,32764,-403,32762,-537,32760,-671,32757,-805,32753,-939,32749,-1073,32744,-1207,32739,-1340,32733,-1474,32727,-1608,32720,-1742,32713,-1876,32705,-2010,32696,-2144,32687,-2277,32678,-2411,32668,-2545,32657,-2678,32646,-2812,32634,-2945,32622,-3079,32609,-3212,32595,-3346,32581,-3479,32567,-3612,32552,-3745,32536,-3878,32520,-4012,32503,-4145,32486,-4277,32468,-4410,32450,-4543,32431,-4676,32412,-4808,32392,-4941,32371,-5073,32350,-5206,32329,-5338,32307,-5470,32284,-5602,32261,-5734,32237,-5866,32213,-5998,32188,-6130,32163,-6262,32137,-6393,32110,-6524,32084,-6656,32056,-6787,32028,-6918,31999,-7049,31970,-7180,31941,-7311,31911,-7441,31880,-7572,31849,-7702,31817,-7832,31785,-7962,31752,-8092,31718,-8222,31684,-8352,31650,-8481,31615,-8611,31580,-8740,31544,-8869,31507,-8998,31470,-9127,31432,-9255,31394,-9384,31356,-9512,31316,-9640,31277,-9768,31236,-9896,31196,-10024,31154,-10152,31113,-10279,31070,-10406,31028,-10533,30984,-10660,30940,-10787,30896,-10913,30851,-11039,30806,-11165,30760,-11291,30713,-11417,30666,-11543,30619,-11668,30571,-11793,30522,-11918,30473,-12043,30424,-12167,30374,-12292,30323,-12416,30272,-12540,30221,-12664,30169,-12787,30116,-12910,30063,-13034,30009,-13156,29955,-13279,29901,-13401,29846,-13524,29790,-13646,29734,-13767,29678,-13889,29621,-14010,29563,-14131,29505,-14252,29446,-14373,29387,-14493,29328,-14613,29268,-14733,29207,-14853,29146,-14972,29085,-15091,29023,-15210,28960,-15328,28897,-15447,28834,-15565,28770,-15683,28706,-15800,28641,-15918,28575,-16035,28510,-16151,28443,-16268,28377,-16384,28309,-16500,28242,-16616,28173,-16731,28105,-16846,28036,-16961,27966,-17075,27896,-17190,27825,-17304,27754,-17417,27683,-17531,27611,-17644,27538,-17757,27466,-17869,27392,-17981,27319,-18093,27244,-18205,27170,-18316,27094,-18427,27019,-18538,26943,-18648,26866,-18758,26789,-18868,26712,-18977,26634,-19087,26556,-19195,26477,-19304,26398,-19412,26318,-19520,26238,-19627,26158,-19734,26077,-19841,25995,-19948,25913,-20054,25831,-20160,25749,-20265,25665,-20370,25582,-20475,25498,-20580,25414,-20684,25329,-20788,25243,-20891,25158,-20994,25072,-21097,24985,-21199,24898,-21301,24811,-21403,24723,-21504,24635,-21605,24546,-21706,24457,-21806,24368,-21906,24278,-22005,24188,-22105,24097,-22203,24006,-22302,23915,-22400,23823,-22497,23731,-22595,23638,-22692,23545,-22788,23452,-22884,23358,-22980,23264,-23075,23169,-23170,23074,-23265,22979,-23359,22883,-23453,22787,-23546,22691,-23639,22594,-23732,22496,-23824,22399,-23916,22301,-24007,22202,-24098,22104,-24189,22004,-24279,21905,-24369,21805,-24458,21705,-24547,21604,-24636,21503,-24724,21402,-24812,21300,-24899,21198,-24986,21096,-25073,20993,-25159,20890,-25244,20787,-25330,20683,-25415,20579,-25499,20474,-25583,20369,-25666,20264,-25750,20159,-25832,20053,-25914,19947,-25996,19840,-26078,19733,-26159,19626,-26239,19519,-26319,19411,-26399,19303,-26478,19194,-26557,19086,-26635,18976,-26713,18867,-26790,18757,-26867,18647,-26944,18537,-27020,18426,-27095,18315,-27171,18204,-27245,18092,-27320,17980,-27393,17868,-27467,17756,-27539,17643,-27612,17530,-27684,17416,-27755,17303,-27826,17189,-27897,17074,-27967,16960,-28037,16845,-28106,16730,-28174,16615,-28243,16499,-28310,16383,-28378,16267,-28444,16150,-28511,16034,-28576,15917,-28642,15799,-28707,15682,-28771,15564,-28835,15446,-28898,15327,-28961,15209,-29024,15090,-29086,14971,-29147,14852,-29208,14732,-29269,14612,-29329,14492,-29388,14372,-29447,14251,-29506,14130,-29564,14009,-29622,13888,-29679,13766,-29735,13645,-29791,13523,-29847,13400,-29902,13278,-29956,13155,-30010,13033,-30064,12909,-30117,12786,-30170,12663,-30222,12539,-30273,12415,-30324,12291,-30375,12166,-30425,12042,-30474,11917,-30523,11792,-30572,11667,-30620,11542,-30667,11416,-30714,11290,-30761,11164,-30807,11038,-30852,10912,-30897,10786,-30941,10659,-30985,10532,-31029,10405,-31071,10278,-31114,10151,-31155,10023,-31197,9895,-31237,9767,-31278,9639,-31317,9511,-31357,9383,-31395,9254,-31433,9126,-31471,8997,-31508,8868,-31545,8739,-31581,8610,-31616,8480,-31651,8351,-31685,8221,-31719,8091,-31753,7961,-31786,7831,-31818,7701,-31850,7571,-31881,7440,-31912,7310,-31942,7179,-31971,7048,-32000,6917,-32029,6786,-32057,6655,-32085,6523,-32111,6392,-32138,6261,-32164,6129,-32189,5997,-32214,5865,-32238,5733,-32262,5601,-32285,5469,-32308,5337,-32330,5205,-32351,5072,-32372,4940,-32393,4807,-32413,4675,-32432,4542,-32451,4409,-32469,4276,-32487,4144,-32504,4011,-32521,3877,-32537,3744,-32553,3611,-32568,3478,-32582,3345,-32596,3211,-32610,3078,-32623,2944,-32635,2811,-32647,2677,-32658,2544,-32669,2410,-32679,2276,-32688,2143,-32697,2009,-32706,1875,-32714,1741,-32721,1607,-32728,1473,-32734,1339,-32740,1206,-32745,1072,-32750,938,-32754,804,-32758,670,-32761,536,-32763,402,-32765,268,-32766,134,-32767,0,-32767,-135,-32767,-269,-32766,-403,-32765,-537,-32763,-671,-32761,-805,-32758,-939,-32754,-1073,-32750,-1207,-32745,-1340,-32740,-1474,-32734,-1608,-32728,-1742,-32721,-1876,-32714,-2010,-32706,-2144,-32697,-2277,-32688,-2411,-32679,-2545,-32669,-2678,-32658,-2812,-32647,-2945,-32635,-3079,-32623,-3212,-32610,-3346,-32596,-3479,-32582,-3612,-32568,-3745,-32553,-3878,-32537,-4012,-32521,-4145,-32504,-4277,-32487,-4410,-32469,-4543,-32451,-4676,-32432,-4808,-32413,-4941,-32393,-5073,-32372,-5206,-32351,-5338,-32330,-5470,-32308,-5602,-32285,-5734,-32262,-5866,-32238,-5998,-32214,-6130,-32189,-6262,-32164,-6393,-32138,-6524,-32111,-6656,-32085,-6787,-32057,-6918,-32029,-7049,-32000,-7180,-31971,-7311,-31942,-7441,-31912,-7572,-31881,-7702,-31850,-7832,-31818,-7962,-31786,-8092,-31753,-8222,-31719,-8352,-31685,-8481,-31651,-8611,-31616,-8740,-31581,-8869,-31545,-8998,-31508,-9127,-31471,-9255,-31433,-9384,-31395,-9512,-31357,-9640,-31317,-9768,-31278,-9896,-31237,-10024,-31197,-10152,-31155,-10279,-31114,-10406,-31071,-10533,-31029,-10660,-30985,-10787,-30941,-10913,-30897,-11039,-30852,-11165,-30807,-11291,-30761,-11417,-30714,-11543,-30667,-11668,-30620,-11793,-30572,-11918,-30523,-12043,-30474,-12167,-30425,-12292,-30375,-12416,-30324,-12540,-30273,-12664,-30222,-12787,-30170,-12910,-30117,-13034,-30064,-13156,-30010,-13279,-29956,-13401,-29902,-13524,-29847,-13646,-29791,-13767,-29735,-13889,-29679,-14010,-29622,-14131,-29564,-14252,-29506,-14373,-29447,-14493,-29388,-14613,-29329,-14733,-29269,-14853,-29208,-14972,-29147,-15091,-29086,-15210,-29024,-15328,-28961,-15447,-28898,-15565,-28835,-15683,-28771,-15800,-28707,-15918,-28642,-16035,-28576,-16151,-28511,-16268,-28444,-16384,-28378,-16500,-28310,-16616,-28243,-16731,-28174,-16846,-28106,-16961,-28037,-17075,-27967,-17190,-27897,-17304,-27826,-17417,-27755,-17531,-27684,-17644,-27612,-17757,-27539,-17869,-27467,-17981,-27393,-18093,-27320,-18205,-27245,-18316,-27171,-18427,-27095,-18538,-27020,-18648,-26944,-18758,-26867,-18868,-26790,-18977,-26713,-19087,-26635,-19195,-26557,-19304,-26478,-19412,-26399,-19520,-26319,-19627,-26239,-19734,-26159,-19841,-26078,-19948,-25996,-20054,-25914,-20160,-25832,-20265,-25750,-20370,-25666,-20475,-25583,-20580,-25499,-20684,-25415,-20788,-25330,-20891,-25244,-20994,-25159,-21097,-25073,-21199,-24986,-21301,-24899,-21403,-24812,-21504,-24724,-21605,-24636,-21706,-24547,-21806,-24458,-21906,-24369,-22005,-24279,-22105,-24189,-22203,-24098,-22302,-24007,-22400,-23916,-22497,-23824,-22595,-23732,-22692,-23639,-22788,-23546,-22884,-23453,-22980,-23359,-23075,-23265,-23170,-23170,-23265,-23075,-23359,-22980,-23453,-22884,-23546,-22788,-23639,-22692,-23732,-22595,-23824,-22497,-23916,-22400,-24007,-22302,-24098,-22203,-24189,-22105,-24279,-22005,-24369,-21906,-24458,-21806,-24547,-21706,-24636,-21605,-24724,-21504,-24812,-21403,-24899,-21301,-24986,-21199,-25073,-21097,-25159,-20994,-25244,-20891,-25330,-20788,-25415,-20684,-25499,-20580,-25583,-20475,-25666,-20370,-25750,-20265,-25832,-20160,-25914,-20054,-25996,-19948,-26078,-19841,-26159,-19734,-26239,-19627,-26319,-19520,-26399,-19412,-26478,-19304,-26557,-19195,-26635,-19087,-26713,-18977,-26790,-18868,-26867,-18758,-26944,-18648,-27020,-18538,-27095,-18427,-27171,-18316,-27245,-18205,-27320,-18093,-27393,-17981,-27467,-17869,-27539,-17757,-27612,-17644,-27684,-17531,-27755,-17417,-27826,-17304,-27897,-17190,-27967,-17075,-28037,-16961,-28106,-16846,-28174,-16731,-28243,-16616,-28310,-16500,-28378,-16384,-28444,-16268,-28511,-16151,-28576,-16035,-28642,-15918,-28707,-15800,-28771,-15683,-28835,-15565,-28898,-15447,-28961,-15328,-29024,-15210,-29086,-15091,-29147,-14972,-29208,-14853,-29269,-14733,-29329,-14613,-29388,-14493,-29447,-14373,-29506,-14252,-29564,-14131,-29622,-14010,-29679,-13889,-29735,-13767,-29791,-13646,-29847,-13524,-29902,-13401,-29956,-13279,-30010,-13156,-30064,-13034,-30117,-12910,-30170,-12787,-30222,-12664,-30273,-12540,-30324,-12416,-30375,-12292,-30425,-12167,-30474,-12043,-30523,-11918,-30572,-11793,-30620,-11668,-30667,-11543,-30714,-11417,-30761,-11291,-30807,-11165,-30852,-11039,-30897,-10913,-30941,-10787,-30985,-10660,-31029,-10533,-31071,-10406,-31114,-10279,-31155,-10152,-31197,-10024,-31237,-9896,-31278,-9768,-31317,-9640,-31357,-9512,-31395,-9384,-31433,-9255,-31471,-9127,-31508,-8998,-31545,-8869,-31581,-8740,-31616,-8611,-31651,-8481,-31685,-8352,-31719,-8222,-31753,-8092,-31786,-7962,-31818,-7832,-31850,-7702,-31881,-7572,-31912,-7441,-31942,-7311,-31971,-7180,-32000,-7049,-32029,-6918,-32057,-6787,-32085,-6656,-32111,-6524,-32138,-6393,-32164,-6262,-32189,-6130,-32214,-5998,-32238,-5866,-32262,-5734,-32285,-5602,-32308,-5470,-32330,-5338,-32351,-5206,-32372,-5073,-32393,-4941,-32413,-4808,-32432,-4676,-32451,-4543,-32469,-4410,-32487,-4277,-32504,-4145,-32521,-4012,-32537,-3878,-32553,-3745,-32568,-3612,-32582,-3479,-32596,-3346,-32610,-3212,-32623,-3079,-32635,-2945,-32647,-2812,-32658,-2678,-32669,-2545,-32679,-2411,-32688,-2277,-32697,-2144,-32706,-2010,-32714,-1876,-32721,-1742,-32728,-1608,-32734,-1474,-32740,-1340,-32745,-1207,-32750,-1073,-32754,-939,-32758,-805,-32761,-671,-32763,-537,-32765,-403,-32766,-269,-32767,-135,-32767,-1,-32767,134,-32766,268,-32765,402,-32763,536,-32761,670,-32758,804,-32754,938,-32750,1072,-32745,1206,-32740,1339,-32734,1473,-32728,1607,-32721,1741,-32714,1875,-32706,2009,-32697,2143,-32688,2276,-32679,2410,-32669,2544,-32658,2677,-32647,2811,-32635,2944,-32623,3078,-32610,3211,-32596,3345,-32582,3478,-32568,3611,-32553,3744,-32537,3877,-32521,4011,-32504,4144,-32487,4276,-32469,4409,-32451,4542,-32432,4675,-32413,4807,-32393,4940,-32372,5072,-32351,5205,-32330,5337,-32308,5469,-32285,5601,-32262,5733,-32238,5865,-32214,5997,-32189,6129,-32164,6261,-32138,6392,-32111,6523,-32085,6655,-32057,6786,-32029,6917,-32000,7048,-31971,7179,-31942,7310,-31912,7440,-31881,7571,-31850,7701,-31818,7831,-31786,7961,-31753,8091,-31719,8221,-31685,8351,-31651,8480,-31616,8610,-31581,8739,-31545,8868,-31508,8997,-31471,9126,-31433,9254,-31395,9383,-31357,9511,-31317,9639,-31278,9767,-31237,9895,-31197,10023,-31155,10151,-31114,10278,-31071,10405,-31029,10532,-30985,10659,-30941,10786,-30897,10912,-30852,11038,-30807,11164,-30761,11290,-30714,11416,-30667,11542,-30620,11667,-30572,11792,-30523,11917,-30474,12042,-30425,12166,-30375,12291,-30324,12415,-30273,12539,-30222,12663,-30170,12786,-30117,12909,-30064,13033,-30010,13155,-29956,13278,-29902,13400,-29847,13523,-29791,13645,-29735,13766,-29679,13888,-29622,14009,-29564,14130,-29506,14251,-29447,14372,-29388,14492,-29329,14612,-29269,14732,-29208,14852,-29147,14971,-29086,15090,-29024,15209,-28961,15327,-28898,15446,-28835,15564,-28771,15682,-28707,15799,-28642,15917,-28576,16034,-28511,16150,-28444,16267,-28378,16383,-28310,16499,-28243,16615,-28174,16730,-28106,16845,-28037,16960,-27967,17074,-27897,17189,-27826,17303,-27755,17416,-27684,17530,-27612,17643,-27539,17756,-27467,17868,-27393,17980,-27320,18092,-27245,18204,-27171,18315,-27095,18426,-27020,18537,-26944,18647,-26867,18757,-26790,18867,-26713,18976,-26635,19086,-26557,19194,-26478,19303,-26399,19411,-26319,19519,-26239,19626,-26159,19733,-26078,19840,-25996,19947,-25914,20053,-25832,20159,-25750,20264,-25666,20369,-25583,20474,-25499,20579,-25415,20683,-25330,20787,-25244,20890,-25159,20993,-25073,21096,-24986,21198,-24899,21300,-24812,21402,-24724,21503,-24636,21604,-24547,21705,-24458,21805,-24369,21905,-24279,22004,-24189,22104,-24098,22202,-24007,22301,-23916,22399,-23824,22496,-23732,22594,-23639,22691,-23546,22787,-23453,22883,-23359,22979,-23265,23074,-23170,23169,-23075,23264,-22980,23358,-22884,23452,-22788,23545,-22692,23638,-22595,23731,-22497,23823,-22400,23915,-22302,24006,-22203,24097,-22105,24188,-22005,24278,-21906,24368,-21806,24457,-21706,24546,-21605,24635,-21504,24723,-21403,24811,-21301,24898,-21199,24985,-21097,25072,-20994,25158,-20891,25243,-20788,25329,-20684,25414,-20580,25498,-20475,25582,-20370,25665,-20265,25749,-20160,25831,-20054,25913,-19948,25995,-19841,26077,-19734,26158,-19627,26238,-19520,26318,-19412,26398,-19304,26477,-19195,26556,-19087,26634,-18977,26712,-18868,26789,-18758,26866,-18648,26943,-18538,27019,-18427,27094,-18316,27170,-18205,27244,-18093,27319,-17981,27392,-17869,27466,-17757,27538,-17644,27611,-17531,27683,-17417,27754,-17304,27825,-17190,27896,-17075,27966,-16961,28036,-16846,28105,-16731,28173,-16616,28242,-16500,28309,};
diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h
index 20f58409b1fbd9b7de8548d9025dfb5e03c91cef..9728d6b2d0726867e3a5ec57138c30eca6b5df82 100644
--- a/openair1/PHY/defs_gNB.h
+++ b/openair1/PHY/defs_gNB.h
@@ -320,7 +320,7 @@ typedef struct PHY_VARS_gNB_s {
   /// counter to average prach energh over first 100 prach opportunities
   int prach_energy_counter;
 
-  // PDSCH Varaibles
+  // PDSCH Variables
   PDSCH_CONFIG_DEDICATED pdsch_config_dedicated[NUMBER_OF_UE_MAX];
 
   // PUSCH Varaibles
diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h
index c4e83cc6a4243fe8350d192dbe28afcf196e8af3..bf8020ecdae251e1adcdab1453759d7f779eabe8 100644
--- a/openair1/PHY/defs_nr_UE.h
+++ b/openair1/PHY/defs_nr_UE.h
@@ -19,9 +19,9 @@
  *      contact@openairinterface.org
  */
 
-/*! \file PHY/defs_gNB.h
- \brief Top-level defines and structure definitions for gNB
- \author Guy De Souza
+/*! \file PHY/defs_nr_UE.h
+ \brief Top-level defines and structure definitions for nr ue
+ \author Guy De Souza, H. WANG
  \date 2018
  \version 0.1
  \company Eurecom
@@ -29,15 +29,1026 @@
  \note
  \warning
 */
-#ifndef __PHY_DEFS_GNB__H__
-#define __PHY_DEFS_GNB__H__
+#ifndef __PHY_DEFS_NR_UE__H__
+#define __PHY_DEFS_NR_UE__H__
 
 
 #include "defs_nr_common.h"
 
+#define _GNU_SOURCE 
+#include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <string.h>
+#include <math.h>
+#include "common_lib.h"
+#include "msc.h"
 
+//#include <complex.h>
+#include "assertions.h"
+#ifdef MEX
+# define msg mexPrintf
+#else
+# ifdef OPENAIR2
+#   if ENABLE_RAL
+#     include "collection/hashtable/hashtable.h"
+#     include "COMMON/ral_messages_types.h"
+#     include "UTIL/queue.h"
+#   endif
+#   include "log.h"
+#   define msg(aRGS...) LOG_D(PHY, ##aRGS)
+# else
+#   define msg printf
+# endif
+#endif
+//use msg in the real-time thread context
+#define msg_nrt printf
+//use msg_nrt in the non real-time context (for initialization, ...)
+#ifndef malloc16
+#  ifdef __AVX2__
+#    define malloc16(x) memalign(32,x)
+#  else
+#    define malloc16(x) memalign(16,x)
+#  endif
+#endif
+#define free16(y,x) free(y)
+#define bigmalloc malloc
+#define bigmalloc16 malloc16
+#define openair_free(y,x) free((y))
+#define PAGE_SIZE 4096
+
+//#define RX_NB_TH_MAX 3
+//#define RX_NB_TH 3
+
+
+//#ifdef SHRLIBDEV
+//extern int rxrescale;
+//#define RX_IQRESCALELEN rxrescale
+//#else
+//#define RX_IQRESCALELEN 15
+//#endif
+
+//! \brief Allocate \c size bytes of memory on the heap with alignment 16 and zero it afterwards.
+//! If no more memory is available, this function will terminate the program with an assertion error.
+/*static inline void* malloc16_clear( size_t size )
+{
+#ifdef __AVX2__
+  void* ptr = memalign(32, size);
+#else
+  void* ptr = memalign(16, size);
+#endif
+  DevAssert(ptr);
+  memset( ptr, 0, size );
+  return ptr;
+}*/
+
+
+
+#define PAGE_MASK 0xfffff000
+#define virt_to_phys(x) (x)
+
+#define openair_sched_exit() exit(-1)
+
+
+#define max(a,b)  ((a)>(b) ? (a) : (b))
+#define min(a,b)  ((a)<(b) ? (a) : (b))
+
+
+#define bzero(s,n) (memset((s),0,(n)))
+
+#define cmax(a,b)  ((a>b) ? (a) : (b))
+#define cmin(a,b)  ((a<b) ? (a) : (b))
+
+#define cmax3(a,b,c) ((cmax(a,b)>c) ? (cmax(a,b)) : (c))
+
+/// suppress compiler warning for unused arguments
+#define UNUSED(x) (void)x;
+
+
+#include "impl_defs_top.h"
+#include "impl_defs_nr.h"
+
+#include "PHY/TOOLS/time_meas.h"
+#include "PHY/CODING/coding_defs.h"
+#include "PHY/TOOLS/tools_defs.h"
+#include "platform_types.h"
+#include "NR_UE_TRANSPORT/nr_transport_ue.h"
+
+#if defined(UPGRADE_RAT_NR)
+
+#include "PHY/NR_REFSIG/ss_pbch_nr.h"
+
+#endif
+
+//#include "PHY/LTE_TRANSPORT/defs.h"
+#include <pthread.h>
+
+#include "targets/ARCH/COMMON/common_lib.h"
+
+
+
+/// Context data structure for RX/TX portion of subframe processing
+typedef struct {
+  /// index of the current UE RX/TX proc
+  int                  proc_id;
+  /// Component Carrier index
+  uint8_t              CC_id;
+  /// timestamp transmitted to HW
+  openair0_timestamp timestamp_tx;
+//#ifdef UE_NR_PHY_DEMO
+  /// NR TTI index within subframe_tx [0 .. ttis_per_subframe - 1] to act upon for transmission
+  int nr_tti_tx;
+  /// NR TTI index within subframe_rx [0 .. ttis_per_subframe - 1] to act upon for reception
+  int nr_tti_rx;
+//#endif
+  /// 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;
+
+  /// internal This variable is protected by ref mutex_fep_slot1.
+  //int instance_cnt_slot0_dl_processing;
+  int instance_cnt_slot1_dl_processing;
+  /// pthread descriptor fep_slot1 thread
+  //pthread_t pthread_slot0_dl_processing;
+  pthread_t pthread_slot1_dl_processing;
+  /// pthread attributes for fep_slot1 processing thread
+ // pthread_attr_t attr_slot0_dl_processing;
+  pthread_attr_t attr_slot1_dl_processing;
+  /// condition variable for UE fep_slot1 thread;
+  //pthread_cond_t cond_slot0_dl_processing;
+  pthread_cond_t cond_slot1_dl_processing;
+  /// mutex for UE synch thread
+  //pthread_mutex_t mutex_slot0_dl_processing;
+  pthread_mutex_t mutex_slot1_dl_processing;
+  //int instance_cnt_slot0_dl_processing;
+  int instance_cnt_dlsch_td;
+  /// pthread descriptor fep_slot1 thread
+  //pthread_t pthread_slot0_dl_processing;
+  pthread_t pthread_dlsch_td;
+  /// pthread attributes for fep_slot1 processing thread
+ // pthread_attr_t attr_slot0_dl_processing;
+  pthread_attr_t attr_dlsch_td;
+  /// condition variable for UE fep_slot1 thread;
+  //pthread_cond_t cond_slot0_dl_processing;
+  pthread_cond_t cond_dlsch_td;
+  /// mutex for UE synch thread
+  //pthread_mutex_t mutex_slot0_dl_processing;
+  pthread_mutex_t mutex_dlsch_td;
+  //
+  uint8_t chan_est_pilot0_slot1_available;
+  uint8_t chan_est_slot1_available;
+  uint8_t llr_slot1_available;
+  uint8_t dci_slot0_available;
+  uint8_t first_symbol_available;
+  uint8_t decoder_thread_available;
+  uint8_t decoder_main_available;
+  uint8_t decoder_switch;
+  int counter_decoder;
+  uint8_t channel_level;
+  int eNB_id;
+  int harq_pid;
+  int llr8_flag;
+  /// scheduling parameters for fep_slot1 thread
+  struct sched_param sched_param_fep_slot1;
+
+  int sub_frame_start;
+  int sub_frame_step;
+  unsigned long long gotIQs;
+  uint8_t decoder_thread_available1;
+  int instance_cnt_dlsch_td1;
+  /// pthread descriptor fep_slot1 thread
+  //pthread_t pthread_slot0_dl_processing;
+  pthread_t pthread_dlsch_td1;
+  /// pthread attributes for fep_slot1 processing thread
+ // pthread_attr_t attr_slot0_dl_processing;
+  pthread_attr_t attr_dlsch_td1;
+  /// condition variable for UE fep_slot1 thread;
+  //pthread_cond_t cond_slot0_dl_processing;
+  pthread_cond_t cond_dlsch_td1;
+  /// mutex for UE synch thread
+  //pthread_mutex_t mutex_slot0_dl_processing;
+  pthread_mutex_t mutex_dlsch_td1;
+  int dci_err_cnt;
+} UE_nr_rxtx_proc_t;
+
+/// Context data structure for eNB subframe processing
+typedef struct {
+  /// Component Carrier index
+  uint8_t              CC_id;
+  /// Last RX timestamp
+  openair0_timestamp timestamp_rx;
+  /// pthread attributes for main UE thread
+  pthread_attr_t attr_ue;
+  /// scheduling parameters for main UE thread
+  struct sched_param sched_param_ue;
+  /// pthread descriptor main UE thread
+  pthread_t pthread_ue;
+  /// \brief Instance count for synch thread.
+  /// \internal This variable is protected by \ref mutex_synch.
+  int instance_cnt_synch;
+  /// pthread attributes for synch processing thread
+  pthread_attr_t attr_synch;
+  /// scheduling parameters for synch thread
+  struct sched_param sched_param_synch;
+  /// pthread descriptor synch thread
+  pthread_t pthread_synch;
+  /// condition variable for UE synch thread;
+  pthread_cond_t cond_synch;
+  /// mutex for UE synch thread
+  pthread_mutex_t mutex_synch;
+  /// set of scheduling variables RXn-TXnp4 threads
+  UE_nr_rxtx_proc_t proc_rxtx[RX_NB_TH];
+} UE_nr_proc_t;
+
+#define debug_msg if (((mac_xface->frame%100) == 0) || (mac_xface->frame < 50)) msg
+
+typedef struct {
+  //unsigned int   rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];     //! estimated received signal power (linear)
+  //unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];  //! estimated received signal power (dB)
+  //unsigned short rx_avg_power_dB[NUMBER_OF_CONNECTED_eNB_MAX];              //! estimated avg received signal power (dB)
+
+  // RRC measurements
+  uint32_t rssi;
+  int n_adj_cells;
+  unsigned int adj_cell_id[6];
+  uint32_t rsrq[7];
+  uint32_t rsrp[7];
+  float rsrp_filtered[7]; // after layer 3 filtering
+  float rsrq_filtered[7];
+  // common measurements
+  //! estimated noise power (linear)
+  unsigned int   n0_power[NB_ANTENNAS_RX];
+  //! estimated noise power (dB)
+  unsigned short n0_power_dB[NB_ANTENNAS_RX];
+  //! total estimated noise power (linear)
+  unsigned int   n0_power_tot;
+  //! total estimated noise power (dB)
+  unsigned short n0_power_tot_dB;
+  //! average estimated noise power (linear)
+  unsigned int   n0_power_avg;
+  //! average estimated noise power (dB)
+  unsigned short n0_power_avg_dB;
+  //! total estimated noise power (dBm)
+  short n0_power_tot_dBm;
+
+  // UE measurements
+  //! estimated received spatial signal power (linear)
+  int            rx_spatial_power[NUMBER_OF_CONNECTED_eNB_MAX][2][2];
+  //! estimated received spatial signal power (dB)
+  unsigned short rx_spatial_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][2][2];
+
+  /// estimated received signal power (sum over all TX antennas)
+  //int            wideband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
+  int            rx_power[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
+  /// estimated received signal power (sum over all TX antennas)
+  //int            wideband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
+  unsigned short rx_power_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
+
+  /// estimated received signal power (sum over all TX/RX antennas)
+  int            rx_power_tot[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW
+  /// estimated received signal power (sum over all TX/RX antennas)
+  unsigned short rx_power_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX]; //NEW
+
+  //! estimated received signal power (sum of all TX/RX antennas, time average)
+  int            rx_power_avg[NUMBER_OF_CONNECTED_eNB_MAX];
+  //! estimated received signal power (sum of all TX/RX antennas, time average, in dB)
+  unsigned short rx_power_avg_dB[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  /// SINR (sum of all TX/RX antennas, in dB)
+  int            wideband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX];
+  /// SINR (sum of all TX/RX antennas, time average, in dB)
+  int            wideband_cqi_avg[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  //! estimated rssi (dBm)
+  short          rx_rssi_dBm[NUMBER_OF_CONNECTED_eNB_MAX];
+  //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation)
+  int            rx_correlation[NUMBER_OF_CONNECTED_eNB_MAX][2];
+  //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation)
+  int            rx_correlation_dB[NUMBER_OF_CONNECTED_eNB_MAX][2];
+
+  /// Wideband CQI (sum of all RX antennas, in dB, for precoded transmission modes (3,4,5,6), up to 4 spatial streams)
+  int            precoded_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX+1][4];
+  /// Subband CQI per RX antenna (= SINR)
+  int            subband_cqi[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX];
+  /// Total Subband CQI  (= SINR)
+  int            subband_cqi_tot[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX];
+  /// Subband CQI in dB (= SINR dB)
+  int            subband_cqi_dB[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX][NUMBER_OF_SUBBANDS_MAX];
+  /// Total Subband CQI
+  int            subband_cqi_tot_dB[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX];
+  /// Wideband PMI for each RX antenna
+  int            wideband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
+  /// Wideband PMI for each RX antenna
+  int            wideband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NB_ANTENNAS_RX];
+  ///Subband PMI for each RX antenna
+  int            subband_pmi_re[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX];
+  ///Subband PMI for each RX antenna
+  int            subband_pmi_im[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX][NB_ANTENNAS_RX];
+  /// chosen RX antennas (1=Rx antenna 1, 2=Rx antenna 2, 3=both Rx antennas)
+  unsigned char           selected_rx_antennas[NUMBER_OF_CONNECTED_eNB_MAX][NUMBER_OF_SUBBANDS_MAX];
+  /// Wideband Rank indication
+  unsigned char  rank[NUMBER_OF_CONNECTED_eNB_MAX];
+  /// Number of RX Antennas
+  unsigned char  nb_antennas_rx;
+  /// DLSCH error counter
+  // short          dlsch_errors;
+
+} PHY_NR_MEASUREMENTS;
+
+typedef struct {
+
+	  /// \brief Holds the received data in the frequency domain.
+	  /// - first index: rx antenna [0..nb_antennas_rx[
+	  /// - second index: symbol [0..28*ofdm_symbol_size[
+	  int32_t **rxdataF;
+
+	  /// \brief Hold the channel estimates in frequency domain.
+	  /// - first index: eNB id [0..6] (hard coded)
+	  /// - second index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+	  /// - third index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[
+	  int32_t **dl_ch_estimates[7];
+
+	  /// \brief Hold the channel estimates in time domain (used for tracking).
+	  /// - first index: eNB id [0..6] (hard coded)
+	  /// - second index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+	  /// - third index: samples? [0..2*ofdm_symbol_size[
+	  int32_t **dl_ch_estimates_time[7];
+}NR_UE_COMMON_PER_THREAD;
+
+typedef struct {
+  /// \brief Holds the transmit data in time domain.
+  /// For IFFT_FPGA this points to the same memory as PHY_vars->tx_vars[a].TX_DMA_BUFFER.
+  /// - first index: tx antenna [0..nb_antennas_tx[
+  /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES[
+  int32_t **txdata;
+  /// \brief Holds the transmit data in the frequency domain.
+  /// For IFFT_FPGA this points to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER.
+  /// - first index: tx antenna [0..nb_antennas_tx[
+  /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX[
+  int32_t **txdataF;
+
+  /// \brief Holds the received data in time domain.
+  /// Should point to the same memory as PHY_vars->rx_vars[a].RX_DMA_BUFFER.
+  /// - first index: rx antenna [0..nb_antennas_rx[
+  /// - second index: sample [0..FRAME_LENGTH_COMPLEX_SAMPLES+2048[
+  int32_t **rxdata;
+
+  NR_UE_COMMON_PER_THREAD common_vars_rx_data_per_thread[RX_NB_TH_MAX];
+
+  /// holds output of the sync correlator
+  int32_t *sync_corr;
+  /// estimated frequency offset (in radians) for all subcarriers
+  int32_t freq_offset;
+  /// eNb_id user is synched to
+  int32_t eNb_id;
+} NR_UE_COMMON;
+
+typedef struct {
+  /// \brief Received frequency-domain signal after extraction.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **rxdataF_ext;
+  /// \brief Received frequency-domain ue specific pilots.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..12*N_RB_DL[
+  int32_t **rxdataF_uespec_pilots;
+  /// \brief Received frequency-domain signal after extraction and channel compensation.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **rxdataF_comp0;
+  /// \brief Received frequency-domain signal after extraction and channel compensation for the second stream. For the SIC receiver we need to store the history of this for each harq process and round
+  /// - first index: ? [0..7] (hard coded) accessed via \c harq_pid
+  /// - second index: ? [0..7] (hard coded) accessed via \c round
+  /// - third index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - fourth index: ? [0..168*N_RB_DL[
+  int32_t **rxdataF_comp1[8][8];
+  /// \brief Downlink channel estimates extracted in PRBS.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **dl_ch_estimates_ext;
+  /// \brief Downlink cross-correlation of MIMO channel estimates (unquantized PMI) extracted in PRBS. For the SIC receiver we need to store the history of this for each harq process and round
+  /// - first index: ? [0..7] (hard coded) accessed via \c harq_pid
+  /// - second index: ? [0..7] (hard coded) accessed via \c round
+  /// - third index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - fourth index: ? [0..168*N_RB_DL[
+  int32_t **dl_ch_rho_ext[8][8];
+  /// \brief Downlink beamforming channel estimates in frequency domain.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[
+  int32_t **dl_bf_ch_estimates;
+  /// \brief Downlink beamforming channel estimates.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **dl_bf_ch_estimates_ext;
+  /// \brief Downlink cross-correlation of MIMO channel estimates (unquantized PMI) extracted in PRBS.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **dl_ch_rho2_ext;
+  /// \brief Downlink PMIs extracted in PRBS and grouped in subbands.
+  /// - first index: ressource block [0..N_RB_DL[
+  uint8_t *pmi_ext;
+  /// \brief Magnitude of Downlink Channel first layer (16QAM level/First 64QAM level).
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **dl_ch_mag0;
+  /// \brief Magnitude of Downlink Channel second layer (16QAM level/First 64QAM level).
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **dl_ch_mag1[8][8];
+  /// \brief Magnitude of Downlink Channel, first layer (2nd 64QAM level).
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **dl_ch_magb0;
+  /// \brief Magnitude of Downlink Channel second layer (2nd 64QAM level).
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **dl_ch_magb1[8][8];
+  /// \brief Cross-correlation of two eNB signals.
+  /// - first index: rx antenna [0..nb_antennas_rx[
+  /// - second index: symbol [0..]
+  int32_t **rho;
+  /// never used... always send dl_ch_rho_ext instead...
+  int32_t **rho_i;
+  /// \brief Pointers to llr vectors (2 TBs).
+  /// - first index: ? [0..1] (hard coded)
+  /// - second index: ? [0..1179743] (hard coded)
+  int16_t *llr[2];
+  /// \f$\log_2(\max|H_i|^2)\f$
+  int16_t log2_maxh;
+    /// \f$\log_2(\max|H_i|^2)\f$ //this is for TM3-4 layer1 channel compensation
+  int16_t log2_maxh0;
+    /// \f$\log_2(\max|H_i|^2)\f$ //this is for TM3-4 layer2 channel commpensation
+  int16_t log2_maxh1;
+  /// \brief LLR shifts for subband scaling.
+  /// - first index: ? [0..168*N_RB_DL[
+  uint8_t *llr_shifts;
+  /// \brief Pointer to LLR shifts.
+  /// - first index: ? [0..168*N_RB_DL[
+  uint8_t *llr_shifts_p;
+  /// \brief Pointers to llr vectors (128-bit alignment).
+  /// - first index: ? [0..0] (hard coded)
+  /// - second index: ? [0..]
+  int16_t **llr128;
+  /// \brief Pointers to llr vectors (128-bit alignment).
+  /// - first index: ? [0..0] (hard coded)
+  /// - second index: ? [0..]
+  int16_t **llr128_2ndstream;
+  //uint32_t *rb_alloc;
+  //uint8_t Qm[2];
+  //MIMO_mode_t mimo_mode;
+  // llr offset per ofdm symbol
+  uint32_t llr_offset[14];
+  // llr length per ofdm symbol
+  uint32_t llr_length[14];
+} NR_UE_PDSCH;
+
+typedef struct {
+  /// \brief Received frequency-domain signal after extraction.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..]
+  int32_t **rxdataF_ext;
+  /// \brief Received frequency-domain signal after extraction and channel compensation.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..]
+  double **rxdataF_comp;
+  /// \brief Downlink channel estimates extracted in PRBS.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..]
+  int32_t **dl_ch_estimates_ext;
+  ///  \brief Downlink cross-correlation of MIMO channel estimates (unquantized PMI) extracted in PRBS.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..]
+  double **dl_ch_rho_ext;
+  /// \brief Downlink PMIs extracted in PRBS and grouped in subbands.
+  /// - first index: ressource block [0..N_RB_DL[
+  uint8_t *pmi_ext;
+  /// \brief Magnitude of Downlink Channel (16QAM level/First 64QAM level).
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..]
+  double **dl_ch_mag;
+  /// \brief Magnitude of Downlink Channel (2nd 64QAM level).
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..]
+  double **dl_ch_magb;
+  /// \brief Cross-correlation of two eNB signals.
+  /// - first index: rx antenna [0..nb_antennas_rx[
+  /// - second index: ? [0..]
+  double **rho;
+  /// never used... always send dl_ch_rho_ext instead...
+  double **rho_i;
+  /// \brief Pointers to llr vectors (2 TBs).
+  /// - first index: ? [0..1] (hard coded)
+  /// - second index: ? [0..1179743] (hard coded)
+  int16_t *llr[2];
+  /// \f$\log_2(\max|H_i|^2)\f$
+  uint8_t log2_maxh;
+  /// \brief Pointers to llr vectors (128-bit alignment).
+  /// - first index: ? [0..0] (hard coded)
+  /// - second index: ? [0..]
+  int16_t **llr128;
+  //uint32_t *rb_alloc;
+  //uint8_t Qm[2];
+  //MIMO_mode_t mimo_mode;
+} NR_UE_PDSCH_FLP;
+
+typedef struct {
+  /// \brief Pointers to extracted PDCCH symbols in frequency-domain.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **rxdataF_ext;
+  /// \brief Pointers to extracted and compensated PDCCH symbols in frequency-domain.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **rxdataF_comp;
+  /// \brief Pointers to extracted channel estimates of PDCCH symbols.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **dl_ch_estimates_ext;
+  /// \brief Pointers to channel cross-correlation vectors for multi-eNB detection.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..168*N_RB_DL[
+  int32_t **dl_ch_rho_ext;
+  /// \brief Pointers to channel cross-correlation vectors for multi-eNB detection.
+  /// - first index: rx antenna [0..nb_antennas_rx[
+  /// - second index: ? [0..]
+  int32_t **rho;
+  /// \brief Pointer to llrs, 4-bit resolution.
+  /// - first index: ? [0..48*N_RB_DL[
+  uint16_t *llr;
+  /// \brief Pointer to llrs, 16-bit resolution.
+  /// - first index: ? [0..96*N_RB_DL[
+  uint16_t *llr16;
+  /// \brief \f$\overline{w}\f$ from 36-211.
+  /// - first index: ? [0..48*N_RB_DL[
+  uint16_t *wbar;
+  /// \brief PDCCH/DCI e-sequence (input to rate matching).
+  /// - first index: ? [0..96*N_RB_DL[
+  int8_t *e_rx;
+  /// number of PDCCH symbols in current subframe
+  uint8_t num_pdcch_symbols;
+  /// Allocated CRNTI for UE
+  uint16_t crnti;
+  /// 1: the allocated crnti is Temporary C-RNTI / 0: otherwise
+  uint8_t crnti_is_temporary;
+  /// Total number of PDU errors (diagnostic mode)
+  uint32_t dci_errors;
+  /// Total number of PDU received
+  uint32_t dci_received;
+  /// Total number of DCI False detection (diagnostic mode)
+  uint32_t dci_false;
+  /// Total number of DCI missed (diagnostic mode)
+  uint32_t dci_missed;
+  /// nCCE for PUCCH per subframe
+  uint8_t nCCE[10];
+  //Check for specific DCIFormat and AgregationLevel
+  uint8_t dciFormat;
+  uint8_t agregationLevel;
+} NR_UE_PDCCH;
+
+#define PBCH_A 24
+
+typedef struct {
+  /// \brief Pointers to extracted PBCH symbols in frequency-domain.
+  /// - first index: rx antenna [0..nb_antennas_rx[
+  /// - second index: ? [0..287] (hard coded)
+  int32_t **rxdataF_ext;
+  /// \brief Pointers to extracted and compensated PBCH symbols in frequency-domain.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..287] (hard coded)
+  int32_t **rxdataF_comp;
+  /// \brief Pointers to downlink channel estimates in frequency-domain extracted in PRBS.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..287] (hard coded)
+  int32_t **dl_ch_estimates_ext;
+  /// \brief Pointer to PBCH llrs.
+  /// - first index: ? [0..1919] (hard coded)
+  int8_t *llr;
+  /// \brief Pointer to PBCH decoded output.
+  /// - first index: ? [0..63] (hard coded)
+  uint8_t *decoded_output;
+  /// \brief Total number of PDU errors.
+  uint32_t pdu_errors;
+  /// \brief Total number of PDU errors 128 frames ago.
+  uint32_t pdu_errors_last;
+  /// \brief Total number of consecutive PDU errors.
+  uint32_t pdu_errors_conseq;
+  /// \brief FER (in percent) .
+  uint32_t pdu_fer;
+} NR_UE_PBCH;
+
+typedef struct {
+  int16_t amp;
+  int16_t *prachF;
+  int16_t *prach;
+} NR_UE_PRACH;
+
+/*typedef enum {
+  /// do not detect any DCIs in the current subframe
+  NO_DCI = 0x0,
+  /// detect only downlink DCIs in the current subframe
+  UL_DCI = 0x1,
+  /// detect only uplink DCIs in the current subframe
+  DL_DCI = 0x2,
+  /// detect both uplink and downlink DCIs in the current subframe
+  UL_DL_DCI = 0x3} nr_dci_detect_mode_t;*/
+
+typedef struct UE_NR_SCAN_INFO_s {
+  /// 10 best amplitudes (linear) for each pss signals
+  int32_t amp[3][10];
+  /// 10 frequency offsets (kHz) corresponding to best amplitudes, with respect do minimum DL frequency in the band
+  int32_t freq_offset_Hz[3][10];
+} UE_NR_SCAN_INFO_t;
+
+/// Top-level PHY Data Structure for UE
+typedef struct {
+  /// \brief Module ID indicator for this instance
+  uint8_t Mod_id;
+  /// \brief Component carrier ID for this PHY instance
+  uint8_t CC_id;
+  /// \brief Mapping of CC_id antennas to cards
+  openair0_rf_map      rf_map;
+  //uint8_t local_flag;
+  /// \brief Indicator of current run mode of UE (normal_txrx, rx_calib_ue, no_L2_connect, debug_prach)
+  runmode_t mode;
+  /// \brief Indicator that UE should perform band scanning
+  int UE_scan;
+  /// \brief Indicator that UE should perform coarse scanning around carrier
+  int UE_scan_carrier;
+  /// \brief Indicator that UE is synchronized to an eNB
+  int is_synchronized;
+  /// Data structure for UE process scheduling
+  UE_nr_proc_t proc;
+  /// Flag to indicate the UE shouldn't do timing correction at all
+  int no_timing_correction;
+  /// \brief Total gain of the TX chain (16-bit baseband I/Q to antenna)
+  uint32_t tx_total_gain_dB;
+  /// \brief Total gain of the RX chain (antenna to baseband I/Q) This is a function of rx_gain_mode (and the corresponding gain) and the rx_gain of the card.
+  uint32_t rx_total_gain_dB;
+  /// \brief Total gains with maximum RF gain stage (ExpressMIMO2/Lime)
+  uint32_t rx_gain_max[4];
+  /// \brief Total gains with medium RF gain stage (ExpressMIMO2/Lime)
+  uint32_t rx_gain_med[4];
+  /// \brief Total gains with bypassed RF gain stage (ExpressMIMO2/Lime)
+  uint32_t rx_gain_byp[4];
+  /// \brief Current transmit power
+  int16_t tx_power_dBm[10];
+  /// \brief Total number of REs in current transmission
+  int tx_total_RE[10];
+  /// \brief Maximum transmit power
+  int8_t tx_power_max_dBm;
+  /// \brief Number of eNB seen by UE
+  uint8_t n_connected_eNB;
+  /// \brief indicator that Handover procedure has been initiated
+  uint8_t ho_initiated;
+  /// \brief indicator that Handover procedure has been triggered
+  uint8_t ho_triggered;
+  /// \brief Measurement variables.
+  PHY_NR_MEASUREMENTS measurements;
+  NR_DL_FRAME_PARMS  frame_parms;
+  /// \brief Frame parame before ho used to recover if ho fails.
+  NR_DL_FRAME_PARMS  frame_parms_before_ho;
+  NR_UE_COMMON    common_vars;
+
+  // point to the current rxTx thread index
+  uint8_t current_thread_id[10];
 
+  NR_UE_PDSCH     *pdsch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX+1]; // two RxTx Threads
+  NR_UE_PDSCH_FLP *pdsch_vars_flp[NUMBER_OF_CONNECTED_eNB_MAX+1];
+  NR_UE_PDSCH     *pdsch_vars_SI[NUMBER_OF_CONNECTED_eNB_MAX+1];
+  NR_UE_PDSCH     *pdsch_vars_ra[NUMBER_OF_CONNECTED_eNB_MAX+1];
+  NR_UE_PDSCH     *pdsch_vars_p[NUMBER_OF_CONNECTED_eNB_MAX+1];
+  NR_UE_PDSCH     *pdsch_vars_MCH[NUMBER_OF_CONNECTED_eNB_MAX];
+  NR_UE_PBCH      *pbch_vars[NUMBER_OF_CONNECTED_eNB_MAX];
+  NR_UE_PDCCH     *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX];
+  NR_UE_PRACH     *prach_vars[NUMBER_OF_CONNECTED_eNB_MAX];
+  NR_UE_DLSCH_t   *dlsch[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_eNB_MAX][2]; // two RxTx Threads
+  NR_UE_ULSCH_t   *ulsch[NUMBER_OF_CONNECTED_eNB_MAX];
+  NR_UE_DLSCH_t   *dlsch_SI[NUMBER_OF_CONNECTED_eNB_MAX];
+  NR_UE_DLSCH_t   *dlsch_ra[NUMBER_OF_CONNECTED_eNB_MAX];
+  NR_UE_DLSCH_t   *dlsch_p[NUMBER_OF_CONNECTED_eNB_MAX];
+  NR_UE_DLSCH_t   *dlsch_MCH[NUMBER_OF_CONNECTED_eNB_MAX];
+  // This is for SIC in the UE, to store the reencoded data
+  LTE_eNB_DLSCH_t  *dlsch_eNB[NUMBER_OF_CONNECTED_eNB_MAX];
 
+  //Paging parameters
+  uint32_t              IMSImod1024;
+  uint32_t              PF;
+  uint32_t              PO;
 
+  // For abstraction-purposes only
+  uint8_t               sr[10];
+  uint8_t               pucch_sel[10];
+  uint8_t               pucch_payload[22];
 
+  UE_MODE_t        UE_mode[NUMBER_OF_CONNECTED_eNB_MAX];
+  /// cell-specific reference symbols
+  uint32_t lte_gold_table[7][20][2][14];
+
+#if defined(UPGRADE_RAT_NR)
+
+  /// demodulation reference signal for NR PBCH
+  uint32_t dmrs_pbch_bitmap_nr[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE];
+
+#endif
+
+  /// PBCH DMRS sequence
+  uint32_t nr_gold_pbch[2][64][NR_PBCH_DMRS_LENGTH_DWORD];
+
+  /// PDSCH DMRS
+  uint32_t nr_gold_pdsch[2][20][2][21];
+
+  /// PDCCH DMRS
+  uint32_t nr_gold_pdcch[10][3][42];
+
+  uint32_t X_u[64][839];
+
+  uint32_t high_speed_flag;
+  uint32_t perfect_ce;
+  int16_t ch_est_alpha;
+  int generate_ul_signal[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  UE_NR_SCAN_INFO_t scan_info[NB_BANDS_MAX];
+
+  char ulsch_no_allocation_counter[NUMBER_OF_CONNECTED_eNB_MAX];
+
+
+
+  unsigned char ulsch_Msg3_active[NUMBER_OF_CONNECTED_eNB_MAX];
+  uint32_t  ulsch_Msg3_frame[NUMBER_OF_CONNECTED_eNB_MAX];
+  unsigned char ulsch_Msg3_subframe[NUMBER_OF_CONNECTED_eNB_MAX];
+  PRACH_RESOURCES_t *prach_resources[NUMBER_OF_CONNECTED_eNB_MAX];
+  int turbo_iterations, turbo_cntl_iterations;
+  /// \brief ?.
+  /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded)
+  uint32_t total_TBS[NUMBER_OF_CONNECTED_eNB_MAX];
+  /// \brief ?.
+  /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded)
+  uint32_t total_TBS_last[NUMBER_OF_CONNECTED_eNB_MAX];
+  /// \brief ?.
+  /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded)
+  uint32_t bitrate[NUMBER_OF_CONNECTED_eNB_MAX];
+  /// \brief ?.
+  /// - first index: eNB [0..NUMBER_OF_CONNECTED_eNB_MAX[ (hard coded)
+  uint32_t total_received_bits[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_errors[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_errors_last[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_received[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_received_last[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_fer[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_SI_received[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_SI_errors[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_ra_received[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_ra_errors[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_p_received[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_p_errors[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_mch_received_sf[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_mch_received[NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_mcch_received[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_mtch_received[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_mcch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_mtch_errors[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_mcch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
+  int dlsch_mtch_trials[MAX_MBSFN_AREA][NUMBER_OF_CONNECTED_eNB_MAX];
+  int current_dlsch_cqi[NUMBER_OF_CONNECTED_eNB_MAX];
+  unsigned char first_run_timing_advance[NUMBER_OF_CONNECTED_eNB_MAX];
+  uint8_t               generate_prach;
+  uint8_t               prach_cnt;
+  uint8_t               prach_PreambleIndex;
+  //  uint8_t               prach_timer;
+  uint8_t               decode_SIB;
+  uint8_t               decode_MIB;
+  int              rx_offset; /// Timing offset
+  int              rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP
+  int              time_sync_cell;
+  int              timing_advance; ///timing advance signalled from eNB
+  int              hw_timing_advance;
+  int              N_TA_offset; ///timing offset used in TDD
+  /// Flag to tell if UE is secondary user (cognitive mode)
+  unsigned char    is_secondary_ue;
+  /// Flag to tell if secondary eNB has channel estimates to create NULL-beams from.
+  unsigned char    has_valid_precoder;
+  /// hold the precoder for NULL beam to the primary eNB
+  int              **ul_precoder_S_UE;
+  /// holds the maximum channel/precoder coefficient
+  char             log2_maxp;
+
+  /// if ==0 enables phy only test mode
+  int mac_enabled;
+
+  /// Flag to initialize averaging of PHY measurements
+  int init_averaging;
+
+  /// \brief sinr for all subcarriers of the current link (used only for abstraction).
+  /// - first index: ? [0..12*N_RB_DL[
+  double *sinr_dB;
+
+  /// \brief sinr for all subcarriers of first symbol for the CQI Calculation.
+  /// - first index: ? [0..12*N_RB_DL[
+  double *sinr_CQI_dB;
+
+  /// sinr_effective used for CQI calulcation
+  double sinr_eff;
+
+  /// N0 (used for abstraction)
+  double N0;
+
+  /// PDSCH Varaibles
+  PDSCH_CONFIG_DEDICATED pdsch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  /// PUSCH Varaibles
+  PUSCH_CONFIG_DEDICATED pusch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  /// PUSCH contention-based access vars
+  PUSCH_CA_CONFIG_DEDICATED  pusch_ca_config_dedicated[NUMBER_OF_eNB_MAX]; // lola
+
+  /// PUCCH variables
+
+  PUCCH_CONFIG_DEDICATED pucch_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  uint8_t ncs_cell[20][7];
+
+  /// UL-POWER-Control
+  UL_POWER_CONTROL_DEDICATED ul_power_control_dedicated[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  /// TPC
+  TPC_PDCCH_CONFIG tpc_pdcch_config_pucch[NUMBER_OF_CONNECTED_eNB_MAX];
+  TPC_PDCCH_CONFIG tpc_pdcch_config_pusch[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  /// CQI reporting
+  CQI_REPORT_CONFIG cqi_report_config[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  /// SRS Variables
+  SOUNDINGRS_UL_CONFIG_DEDICATED soundingrs_ul_config_dedicated[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  /// Scheduling Request Config
+  SCHEDULING_REQUEST_CONFIG scheduling_request_config[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  /// Transmission mode per eNB
+  uint8_t transmission_mode[NUMBER_OF_CONNECTED_eNB_MAX];
+
+  time_stats_t phy_proc[RX_NB_TH];
+  time_stats_t phy_proc_tx;
+  time_stats_t phy_proc_rx[RX_NB_TH];
+
+  uint32_t use_ia_receiver;
+
+  time_stats_t ofdm_mod_stats;
+  time_stats_t ulsch_encoding_stats;
+  time_stats_t ulsch_modulation_stats;
+  time_stats_t ulsch_segmentation_stats;
+  time_stats_t ulsch_rate_matching_stats;
+  time_stats_t ulsch_turbo_encoding_stats;
+  time_stats_t ulsch_interleaving_stats;
+  time_stats_t ulsch_multiplexing_stats;
+
+  time_stats_t generic_stat;
+  time_stats_t generic_stat_bis[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME];
+  time_stats_t ue_front_end_stat[RX_NB_TH];
+  time_stats_t ue_front_end_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME];
+  time_stats_t pdcch_procedures_stat[RX_NB_TH];
+  time_stats_t pdsch_procedures_stat[RX_NB_TH];
+  time_stats_t pdsch_procedures_per_slot_stat[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME];
+  time_stats_t dlsch_procedures_stat[RX_NB_TH];
+
+  time_stats_t ofdm_demod_stats;
+  time_stats_t dlsch_rx_pdcch_stats;
+  time_stats_t rx_dft_stats;
+  time_stats_t dlsch_channel_estimation_stats;
+  time_stats_t dlsch_freq_offset_estimation_stats;
+  time_stats_t dlsch_decoding_stats[2];
+  time_stats_t dlsch_demodulation_stats;
+  time_stats_t dlsch_rate_unmatching_stats;
+  time_stats_t dlsch_turbo_decoding_stats;
+  time_stats_t dlsch_deinterleaving_stats;
+  time_stats_t dlsch_llr_stats;
+  time_stats_t dlsch_llr_stats_parallelization[RX_NB_TH][LTE_SLOTS_PER_SUBFRAME];
+  time_stats_t dlsch_unscrambling_stats;
+  time_stats_t dlsch_rate_matching_stats;
+  time_stats_t dlsch_turbo_encoding_stats;
+  time_stats_t dlsch_interleaving_stats;
+  time_stats_t dlsch_tc_init_stats;
+  time_stats_t dlsch_tc_alpha_stats;
+  time_stats_t dlsch_tc_beta_stats;
+  time_stats_t dlsch_tc_gamma_stats;
+  time_stats_t dlsch_tc_ext_stats;
+  time_stats_t dlsch_tc_intl1_stats;
+  time_stats_t dlsch_tc_intl2_stats;
+  time_stats_t tx_prach;
+
+  /// RF and Interface devices per CC
+  openair0_device rfdevice;
+  time_stats_t dlsch_encoding_SIC_stats;
+  time_stats_t dlsch_scrambling_SIC_stats;
+  time_stats_t dlsch_modulation_SIC_stats;
+  time_stats_t dlsch_llr_stripping_unit_SIC_stats;
+  time_stats_t dlsch_unscrambling_SIC_stats;
+
+#if ENABLE_RAL
+  hash_table_t    *ral_thresholds_timed;
+  SLIST_HEAD(ral_thresholds_gen_poll_s, ral_threshold_phy_t) ral_thresholds_gen_polled[RAL_LINK_PARAM_GEN_MAX];
+  SLIST_HEAD(ral_thresholds_lte_poll_s, ral_threshold_phy_t) ral_thresholds_lte_polled[RAL_LINK_PARAM_LTE_MAX];
+#endif
+
+} PHY_VARS_NR_UE;
+
+/* this structure is used to pass both UE phy vars and
+ * proc to the function UE_thread_rxn_txnp4
+ */
+struct nr_rxtx_thread_data {
+  PHY_VARS_NR_UE    *UE;
+  UE_nr_rxtx_proc_t *proc;
+};
+
+void exit_fun(const char* s);
+
+/*static inline int wait_on_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) {
+
+  if (pthread_mutex_lock(mutex) != 0) {
+    LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name);
+    exit_fun("nothing to add");
+    return(-1);
+  }
+
+  while (*instance_cnt < 0) {
+    // most of the time the thread is waiting here
+    // proc->instance_cnt_rxtx is -1
+    pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again
+  }
+
+  if (pthread_mutex_unlock(mutex) != 0) {
+    LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for %s\n",name);
+    exit_fun("nothing to add");
+    return(-1);
+  }
+  return(0);
+}
+
+static inline int wait_on_busy_condition(pthread_mutex_t *mutex,pthread_cond_t *cond,int *instance_cnt,char *name) {
+
+  if (pthread_mutex_lock(mutex) != 0) {
+    LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name);
+    exit_fun("nothing to add");
+    return(-1);
+  }
+
+  while (*instance_cnt == 0) {
+    // most of the time the thread will skip this
+    // waits only if proc->instance_cnt_rxtx is 0
+    pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again
+  }
+
+  if (pthread_mutex_unlock(mutex) != 0) {
+    LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for %s\n",name);
+    exit_fun("nothing to add");
+    return(-1);
+  }
+  return(0);
+}
+
+static inline int release_thread(pthread_mutex_t *mutex,int *instance_cnt,char *name) {
+
+  if (pthread_mutex_lock(mutex) != 0) {
+    LOG_E( PHY, "[SCHED][eNB] error locking mutex for %s\n",name);
+    exit_fun("nothing to add");
+    return(-1);
+  }
+
+  *instance_cnt=*instance_cnt-1;
+
+  if (pthread_mutex_unlock(mutex) != 0) {
+    LOG_E( PHY, "[SCHED][eNB] error unlocking mutex for %s\n",name);
+    exit_fun("nothing to add");
+    return(-1);
+  }
+  return(0);
+}
+*/
+
+
+/*
+#include "PHY/INIT/defs.h"
+#include "PHY/LTE_REFSIG/defs.h"
+#include "PHY/MODULATION/defs.h"
+#include "PHY/LTE_TRANSPORT/proto.h"
+#include "PHY/LTE_ESTIMATION/defs.h"
+*/
+#include "SIMULATION/ETH_TRANSPORT/defs.h"
 #endif
diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h
index 65168dfb8c368cf4bbf98f4616e24290661b1965..c1c03570337b21a14e8bb520d2ff833ba16e5a8a 100644
--- a/openair1/PHY/defs_nr_common.h
+++ b/openair1/PHY/defs_nr_common.h
@@ -34,6 +34,8 @@
 #define __PHY_DEFS_NR_COMMON__H__
 
 #include "defs_common.h"
+#include "nfapi_nr_interface.h"
+#include "impl_defs_nr.h"
 #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
 
 #define nr_subframe_t lte_subframe_t
@@ -55,6 +57,8 @@
 #define NR_PBCH_DMRS_LENGTH 144
 #define NR_PBCH_DMRS_LENGTH_DWORD 5 // roundup(NR_PBCH_DMRS_LENGTH/32)
 
+#define NR_MAX_NUM_BWP 4
+
 typedef enum {
   NR_MU_0=0,
   NR_MU_1,
@@ -72,7 +76,26 @@ typedef enum{
   nr_ssb_type_E
 } nr_ssb_type_e;
 
+typedef struct NR_BWP_PARMS {
+  /// Associated numerology index
+  uint8_t numerology_index;
+  /// Freq domain location
+  uint8_t location;
+  /// Bandwidth in PRB
+  uint16_t N_RB;
+  /// Size of FFT/IFFT
+  uint16_t ofdm_symbol_size;
+} NR_BWP_PARMS;
+
 typedef struct NR_DL_FRAME_PARMS {
+  /// Number of resource blocks (RB) in DL
+  uint8_t N_RB_DL;
+  /// Number of resource blocks (RB) in UL
+  uint8_t N_RB_UL;
+  ///  total Number of Resource Block Groups: this is ceil(N_PRB/P)
+  uint8_t N_RBG;
+  /// Total Number of Resource Block Groups SubSets: this is P
+  uint8_t N_RBGS;
   /// EUTRA Band
   uint8_t eutra_band;
   /// DL carrier frequency
@@ -84,6 +107,13 @@ typedef struct NR_DL_FRAME_PARMS {
   /// RX attenuation
   uint32_t att_rx;
   ///  total Number of Resource Block Groups: this is ceil(N_PRB/P)
+  /// Frame type (0 FDD, 1 TDD)
+  lte_frame_type_t frame_type;
+  /// TDD subframe assignment (0-7) (default = 3) (254=RX only, 255=TX only)
+  uint8_t tdd_config;
+  /// TDD S-subframe configuration (0-9)
+  /// Cell ID
+  uint16_t Nid_cell;
   uint32_t subcarrier_spacing;
   /// 3/4 sampling
   uint8_t threequarter_fs;
@@ -101,14 +131,47 @@ typedef struct NR_DL_FRAME_PARMS {
   uint16_t slots_per_subframe;
   /// 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)
+  uint16_t symbols_per_tti;
   /// 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;
-
-    //SSB related params
+  /// Number of samples in a tti (same as subrame in LTE, depending on numerology in NR)
+  uint32_t samples_per_tti;
+  /// NR numerology index [0..5] as specified in 38.211 Section 4 (mu). 0=15khZ SCS, 1=30khZ, 2=60kHz, etc
+  uint8_t numerology_index;
+  /// NR number of ttis per subframe deduced from numerology (cf 38.211): 1, 2, 4, 8(not supported),16(not supported),32(not supported)
+  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
+  uint8_t nb_antennas_rx;
+  /// Number of common transmit antenna ports in eNodeB (1 or 2)
+  uint8_t nb_antenna_ports_eNB;
+  /// Cyclic Prefix for DL (0=Normal CP, 1=Extended CP)
+  lte_prefix_type_t Ncp;
+  /// shift of pilot position in one RB
+  uint8_t nushift;
+  /// SRS configuration from TS 38.331 RRC
+  SRS_NR srs_nr;
+
+  /// for NR TDD management
+  TDD_UL_DL_configCommon_t  *p_tdd_UL_DL_Configuration;
+
+  TDD_UL_DL_configCommon_t  *p_tdd_UL_DL_ConfigurationCommon2;
+
+  TDD_UL_DL_SlotConfig_t    *p_TDD_UL_DL_ConfigDedicated;
+
+  /// TDD configuration
+  uint16_t tdd_uplink_nr[MAX_NR_OF_SLOTS]; /* this is a bitmap of symbol of each slot given for 2 frames */
+
+   //SSB related params
   /// Start in Subcarrier index of the SSB block
   uint16_t ssb_start_subcarrier;
   /// SSB type
@@ -116,6 +179,11 @@ typedef struct NR_DL_FRAME_PARMS {
   /// PBCH polar encoder params
   t_nrPolar_params pbch_polar_params;
 
+   //BWP params
+  NR_BWP_PARMS initial_bwp_params_dl;
+  NR_BWP_PARMS initial_bwp_params_ul;
+
 } NR_DL_FRAME_PARMS;
 
+
 #endif
diff --git a/openair1/PHY/impl_defs_nr.h b/openair1/PHY/impl_defs_nr.h
new file mode 100644
index 0000000000000000000000000000000000000000..390949072ae720c79541a063fea7a8a485f5c92f
--- /dev/null
+++ b/openair1/PHY/impl_defs_nr.h
@@ -0,0 +1,345 @@
+/*
+ * 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
+ */
+
+/***********************************************************************
+*
+* FILENAME    :  impl_defs_nr.h
+*
+* MODULE      :
+*
+* DESCRIPTION :  NR Physical channel configuration and variable structure definitions
+*                This is an interface between ue physical layer and RRC message from network
+*                see TS 38.336 Radio Resource Control (RRC) protocol specification
+*
+************************************************************************/
+
+#ifndef PHY_IMPL_DEFS_NR_H
+#define PHY_IMPL_DEFS_NR_H
+
+#include "types.h"
+
+#ifdef DEFINE_VARIABLES_PHY_IMPLEMENTATION_DEFS_NR_H
+#define EXTERN
+#define INIT_VARIABLES_PHY_IMPLEMENTATION_DEFS_NR_H
+#else
+#define EXTERN  extern
+#undef INIT_VARIABLES_PHY_IMPLEMENTATION_DEFS_NR_H
+#endif
+
+#ifdef PHY_DBG_DEV_TST
+  #define PHY_DBG_DEV_TST_PRINTF(...)      printf(__VA_ARGS__)
+#else
+  #define PHY_DBG_DEV_TST_PRINTF(...)
+#endif
+
+/* to set for UE capabilities */
+#define MAX_NR_OF_SRS_RESOURCE_SET         (1)
+#define MAX_NR_OF_SRS_RESOURCES_PER_SET    (1)
+
+#define NR_NUMBER_OF_SUBFRAMES_PER_FRAME   (10)
+#define MAX_NROFSRS_PORTS                  (4)
+
+/* TS 38.211 Table 4.3.2-1: Number of OFDM symbols per slot, slots per frame, and slots per subframe for normal cyclic prefix */
+#define MU_NUMBER                          (5)
+EXTERN const uint8_t N_slot_subframe[MU_NUMBER]
+#ifdef INIT_VARIABLES_PHY_IMPLEMENTATION_DEFS_NR_H
+= { 1, 2, 4, 8, 16}
+#endif
+;
+
+/***********************************************************************
+*
+* FUNCTIONALITY    :  Time Division Duplex
+*
+* DESCRIPTION      :  interface for FDD/TDD configuration
+*
+************************************************************************/
+
+#define MAX_NR_OF_SLOTS                    (320)    /* maximum number of slots for tdd configuration which is periodic */
+
+#define NR_TDD_DOWNLINK_SLOT               (0x0000)
+#define NR_TDD_UPLINK_SLOT                 (0x3FFF) /* uplink bitmap for each symbol, there are 14 symbols per slots */
+#define NR_TDD_SET_ALL_SYMBOLS             (0x3FFF)
+
+#define FRAME_DURATION_MICRO_SEC           (10000)  /* frame duration in microsecond */
+
+typedef enum {
+  SLOT_DL = 0,
+  SLOT_UL = 1,
+} nr_slot_t;
+
+typedef enum {
+  ms0p5    = 500,                 /* duration is given in microsecond */
+  ms0p625  = 625,
+  ms1      = 1000,
+  ms1p25   = 1250,
+  ms2      = 2000,
+  ms2p5    = 2500,
+  ms5      = 5000,
+  ms10     = 10000,
+} dl_UL_TransmissionPeriodicity_t;
+
+typedef struct {
+  /// Reference SCS used to determine the time domain boundaries in the UL-DL pattern which must be common across all subcarrier specific
+  /// virtual carriers, i.e., independent of the actual subcarrier spacing using for data transmission.
+  /// Only the values 15 or 30 kHz  (<6GHz), 60 or 120 kHz (>6GHz) are applicable.
+  /// Corresponds to L1 parameter 'reference-SCS' (see 38.211, section FFS_Section)
+  /// \ subcarrier spacing
+  uint8_t referenceSubcarrierSpacing;
+  /// \ Periodicity of the DL-UL pattern. Corresponds to L1 parameter 'DL-UL-transmission-periodicity' (see 38.211, section FFS_Section)
+  dl_UL_TransmissionPeriodicity_t dl_UL_TransmissionPeriodicity;
+  /// \ Number of consecutive full DL slots at the beginning of each DL-UL pattern.
+  /// Corresponds to L1 parameter 'number-of-DL-slots' (see 38.211, Table 4.3.2-1)
+  uint8_t nrofDownlinkSlots;
+  /// \ Number of consecutive DL symbols in the beginning of the slot following the last full DL slot (as derived from nrofDownlinkSlots).
+  /// If the field is absent or released, there is no partial-downlink slot.
+  /// Corresponds to L1 parameter 'number-of-DL-symbols-common' (see 38.211, section FFS_Section).
+  uint8_t nrofDownlinkSymbols;
+  /// \ Number of consecutive full UL slots at the end of each DL-UL pattern.
+  /// Corresponds to L1 parameter 'number-of-UL-slots' (see 38.211, Table 4.3.2-1)
+  uint8_t nrofUplinkSlots;
+  /// \ Number of consecutive UL symbols in the end of the slot preceding the first full UL slot (as derived from nrofUplinkSlots).
+  /// If the field is absent or released, there is no partial-uplink slot.
+  /// Corresponds to L1 parameter 'number-of-UL-symbols-common' (see 38.211, section FFS_Section)
+  uint8_t nrofUplinkSymbols;
+  /// \ for setting a sequence
+  struct TDD_UL_DL_configCommon_t *p_next_TDD_UL_DL_configCommon_t;
+} TDD_UL_DL_configCommon_t;
+
+typedef struct {
+  /// \ Identifies a slot within a dl-UL-TransmissionPeriodicity (given in tdd-UL-DL-configurationCommon)
+  uint16_t slotIndex;
+  /// \ The direction (downlink or uplink) for the symbols in this slot. "allDownlink" indicates that all symbols in this slot are used
+  /// for downlink; "allUplink" indicates that all symbols in this slot are used for uplink; "explicit" indicates explicitly how many symbols
+  /// in the beginning and end of this slot are allocated to downlink and uplink, respectively.
+  /// Number of consecutive DL symbols in the beginning of the slot identified by slotIndex.
+  /// If the field is absent the UE assumes that there are no leading DL symbols.
+  /// Corresponds to L1 parameter 'number-of-DL-symbols-dedicated' (see 38.211, section FFS_Section)
+  uint16_t nrofDownlinkSymbols;
+  /// Number of consecutive UL symbols in the end of the slot identified by slotIndex.
+  /// If the field is absent the UE assumes that there are no trailing UL symbols.
+  /// Corresponds to L1 parameter 'number-of-UL-symbols-dedicated' (see 38.211, section FFS_Section)
+  uint16_t nrofUplinkSymbols;
+  /// \ for setting a sequence
+  struct TDD_UL_DL_SlotConfig_t *p_next_TDD_UL_DL_SlotConfig;
+} TDD_UL_DL_SlotConfig_t;
+
+/***********************************************************************
+*
+* FUNCTIONALITY    :  Sounding Reference Signal
+*
+* DESCRIPTION      :  interface description for managing uplink SRS signals from UE
+*                     SRS are generated by UE and transmit to network
+*                     depending on configuration
+*
+************************************************************************/
+
+EXTERN const int16_t SRS_antenna_port[MAX_NROFSRS_PORTS]
+#ifdef INIT_VARIABLES_PHY_IMPLEMENTATION_DEFS_NR_H
+= { 1000, 1001, 1002, 1003 }
+#endif
+;
+
+typedef enum {
+  port1           = 1,
+  port2           = 2,
+  port4           = 4
+} nrof_Srs_Ports_t;
+
+typedef enum {
+  neitherHopping  = 0,
+  groupHopping    = 1,
+  sequenceHopping = 2
+} groupOrSequenceHopping_t;
+
+typedef enum {
+  aperiodic       = 0,
+  semi_persistent = 1,
+  periodic        = 2
+} resourceType_t;
+
+typedef enum {
+  sl1    = 0,
+  sl2    = 1,
+  sl4    = 2,
+  sl5    = 3,
+  sl8    = 4,
+  sl10   = 5,
+  sl16   = 6,
+  sl20   = 7,
+  sl32   = 8,
+  sl40   = 9,
+  sl64   = 10,
+  sl80   = 11,
+  sl160  = 12,
+  sl320  = 13,
+  sl640  = 14,
+  sl1280 = 15,
+  sl2560 = 16
+} SRS_Periodicity_t;
+
+#define NB_SRS_PERIOD         (17)
+
+const uint16_t srs_period[NB_SRS_PERIOD]
+#ifdef INIT_VARIABLES_PHY_IMPLEMENTATION_DEFS_NR_H
+= { 1, 2, 4, 5, 8, 10, 16, 20, 32, 40, 64, 80, 160, 320, 640, 1280, 2560}
+#endif
+;
+
+/// SRS_Resource of SRS_Config information element from 38.331 RRC specifications
+typedef struct {
+  /// \brief srs resource identity.
+  uint8_t srs_ResourceId;
+  /// \brief number of srs ports.
+  nrof_Srs_Ports_t nrof_SrsPorts;
+  /// \brief index of prts port index.
+  uint8_t ptrs_PortIndex;
+  /// \brief srs transmission comb see parameter SRS-TransmissionComb 38.214 section &6.2.1.
+  uint8_t transmissionComb;
+  /// \brief comb offset.
+  uint8_t combOffset;
+  /// \brief cyclic shift configuration - see parameter SRS-CyclicShiftConfig 38.214 &6.2.1.
+  uint8_t cyclicShift;
+  /// \brief OFDM symbol location of the SRS resource within a slot.
+  // Corresponds to L1 parameter 'SRS-ResourceMapping' (see 38.214, section 6.2.1 and 38.211, section 6.4.1.4).
+  // startPosition (SRSSymbolStartPosition = 0..5; "0" refers to the last symbol, "1" refers to the second last symbol.
+  uint8_t resourceMapping_startPosition;
+  /// \brief number of OFDM symbols (N = 1, 2 or 4 per SRS resource).
+  uint8_t resourceMapping_nrofSymbols;
+  /// \brief RepetitionFactor (r = 1, 2 or 4).
+  uint8_t resourceMapping_repetitionFactor;
+  /// \brief Parameter(s) defining frequency domain position and configurable shift to align SRS allocation to 4 PRB grid.
+  // Corresponds to L1 parameter 'SRS-FreqDomainPosition' (see 38.214, section 6.2.1)
+  uint8_t  freqDomainPosition;    // INTEGER (0..67),
+  uint16_t freqDomainShift;       // INTEGER (0..268),
+  /// \brief Includes  parameters capturing SRS frequency hopping
+  // Corresponds to L1 parameter 'SRS-FreqHopping' (see 38.214, section 6.2.1)
+  uint8_t freqHopping_c_SRS;      // INTEGER (0..63),
+  uint8_t freqHopping_b_SRS;      // INTEGER (0..3),
+  uint8_t freqHopping_b_hop;      // INTEGER (0..3)
+  // Parameter(s) for configuring group or sequence hopping
+  // Corresponds to L1 parameter 'SRS-GroupSequenceHopping' see 38.211
+  groupOrSequenceHopping_t groupOrSequenceHopping;
+  /// \brief Time domain behavior of SRS resource configuration.
+  // Corresponds to L1 parameter 'SRS-ResourceConfigType' (see 38.214, section 6.2.1).
+  // For codebook based uplink transmission, the network configures SRS resources in the same resource set with the same
+  // time domain behavior on periodic, aperiodic and semi-persistent SRS
+  SRS_Periodicity_t SRS_Periodicity;
+  uint16_t          SRS_Offset;
+  /// \brief Sequence ID used to initialize psedo random group and sequence hopping.
+  // Corresponds to L1 parameter 'SRS-SequenceId' (see 38.214, section 6.2.1).
+  uint16_t sequenceId;            // BIT STRING (SIZE (10))
+  /// \brief Configuration of the spatial relation between a reference RS and the target SRS. Reference RS can be SSB/CSI-RS/SRS.
+  // Corresponds to L1 parameter 'SRS-SpatialRelationInfo' (see 38.214, section 6.2.1)
+  uint8_t spatialRelationInfo_ssb_Index;      // SSB-Index,
+  uint8_t spatialRelationInfo_csi_RS_Index;   // NZP-CSI-RS-ResourceId,
+  uint8_t spatialRelationInfo_srs_Id;         // SRS-ResourceId
+} SRS_Resource_t;
+
+typedef enum {
+  beamManagement     = 0,
+  codebook           = 1,
+  nonCodebook        = 2,
+  antennaSwitching   = 3,
+} SRS_resourceSet_usage_t;
+
+typedef enum {
+  sameAsFci2         = 0,
+  separateClosedLoop = 1
+} srs_PowerControlAdjustmentStates_t;
+
+typedef enum {
+  ssb_Index          = 0,
+  csi_RS_Index       = 1,
+} pathlossReferenceRS_t;
+
+// SRS_Config information element from 38.331 RRC specifications from 38.331 RRC specifications.
+typedef struct {
+  /// \brief The ID of this resource set. It is unique in the context of the BWP in which the parent SRS-Config is defined.
+  uint8_t srs_ResourceSetId;
+  /// \brief number of resources in the resource set
+  uint8_t number_srs_Resource;
+  /// \brief The IDs of the SRS-Resources used in this SRS-ResourceSet.
+  /// in fact this is an array of pointers to resource structures
+  SRS_Resource_t *p_srs_ResourceList[MAX_NR_OF_SRS_RESOURCES_PER_SET];
+  resourceType_t resourceType;
+  /// \brief The DCI "code point" upon which the UE shall transmit SRS according to this SRS resource set configuration.
+  // Corresponds to L1 parameter 'AperiodicSRS-ResourceTrigger' (see 38.214, section 6.1.1.2)
+  uint8_t aperiodicSRS_ResourceTrigger;		 // INTEGER (0..maxNrofSRS-TriggerStates-1) : [0:3]
+  /// \brief ID of CSI-RS resource associated with this SRS resource set. (see 38.214, section 6.1.1.2).
+  uint8_t NZP_CSI_RS_ResourceId;
+  /// \brief An offset in number of slots between the triggering DCI and the actual transmission of this SRS-ResourceSet.
+  // If the field is absent the UE applies no offset (value 0)
+  uint8_t aperiodic_slotOffset; // INTEGER (1..8)
+  /// \brief Indicates if the SRS resource set is used for beam management vs. used for either codebook based or non-codebook based transmission.
+  // Corresponds to L1 parameter 'SRS-SetUse' (see 38.214, section 6.2.1)
+  // FFS_CHECK: Isn't codebook/noncodebook already known from the ulTxConfig in the SRS-Config? If so, isn't the only distinction
+  // in the set between BeamManagement, AtennaSwitching and "Other”? Or what happens if SRS-Config=Codebook but a Set=NonCodebook?
+  SRS_resourceSet_usage_t usage;
+  /// \brief alpha value for SRS power control. Corresponds to L1 parameter 'alpha-srs' (see 38.213, section 7.3).
+  // When the field is absent the UE applies the value 1
+  uint8_t alpha;
+  /// \brief P0 value for SRS power control. The value is in dBm. Only even values (step size 2) are allowed.
+  // Corresponds to L1 parameter 'p0-srs' (see 38.213, section 7.3)
+  int8_t p0;          // INTEGER (-202..24)
+  /// \brief A reference signal (e.g. a CSI-RS config or a SSblock) to be used for SRS path loss estimation.
+  /// Corresponds to L1 parameter 'srs-pathlossReference-rs-config' (see 38.213, section 7.3)
+  pathlossReferenceRS_t pathlossReferenceRS_t;
+  uint8_t path_loss_SSB_Index;
+  uint8_t path_loss_NZP_CSI_RS_ResourceId;
+  /// \brief Indicates whether hsrs,c(i) = fc(i,1) or hsrs,c(i) = fc(i,2) (if twoPUSCH-PC-AdjustmentStates are configured)
+  /// or separate close loop is configured for SRS. This parameter is applicable only for Uls on which UE also transmits PUSCH.
+  /// If absent or release, the UE applies the value sameAs-Fci1
+  /// Corresponds to L1 parameter 'srs-pcadjustment-state-config' (see 38.213, section 7.3)
+  srs_PowerControlAdjustmentStates_t srs_PowerControlAdjustmentStates;
+} SRS_ResourceSet_t;
+
+typedef struct {
+  uint8_t active_srs_Resource_Set;  /* ue implementation specific */
+  uint8_t number_srs_Resource_Set;  /* ue implementation specific */
+  SRS_ResourceSet_t *p_SRS_ResourceSetList[MAX_NR_OF_SRS_RESOURCE_SET]; /* ue implementation specific */
+} SRS_NR;
+
+//#define RX_NB_TH_MAX 3
+//#define RX_NB_TH 3
+
+#define LTE_SLOTS_PER_SUBFRAME 2
+
+#define LTE_NUMBER_OF_SUBFRAMES_PER_FRAME 10
+#define LTE_SLOTS_PER_FRAME  20
+#define LTE_CE_FILTER_LENGTH 5
+#define LTE_CE_OFFSET LTE_CE_FILTER_LENGTH
+#define TX_RX_SWITCH_SYMBOL (NUMBER_OF_SYMBOLS_PER_FRAME>>1)
+#define PBCH_PDU_SIZE 3 //bytes
+
+#define PRACH_SYMBOL 3 //position of the UL PSS wrt 2nd slot of special subframe
+
+#define NUMBER_OF_FREQUENCY_GROUPS (lte_frame_parms->N_RB_DL)
+
+#define SSS_AMP 1148
+
+#define MAX_NUM_PHICH_GROUPS 56  //110 RBs Ng=2, p.60 36-212, Sec. 6.9
+
+#define MAX_MBSFN_AREA 8
+
+#undef EXTERN
+#undef INIT_VARIABLES_PHY_IMPLEMENTATION_DEFS_NR_H
+#endif /* PHY_IMPL_DEFS_NR_H */
diff --git a/openair1/PHY/phy_extern_nr_ue.h b/openair1/PHY/phy_extern_nr_ue.h
new file mode 100644
index 0000000000000000000000000000000000000000..a9694ea058d6278fb7b2564d5bc294ee958f5dd2
--- /dev/null
+++ b/openair1/PHY/phy_extern_nr_ue.h
@@ -0,0 +1,124 @@
+/*
+ * 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 __PHY_EXTERN_UE__H__
+#define __PHY_EXTERN_UE__H__
+
+#include "PHY/defs_nr_UE.h"
+#include "common/ran_context.h"
+
+extern  char* namepointer_chMag ;
+extern char* namepointer_log2;
+extern  char fmageren_name2[512];
+
+extern unsigned int RX_DMA_BUFFER[4][NB_ANTENNAS_RX];
+extern unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX];
+
+#include "PHY/LTE_TRANSPORT/transport_extern.h"
+
+extern int number_of_cards;
+
+
+#ifndef OCP_FRAMEWORK
+extern PHY_VARS_NR_UE ***PHY_vars_UE_g;
+extern NR_DL_FRAME_PARMS *lte_frame_parms_g;
+#else
+#define MAX_UE 10
+#define MAX_eNB 20
+
+extern PHY_VARS_NR_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs];
+#endif
+
+extern short primary_synch0[144];
+extern short primary_synch1[144];
+extern short primary_synch2[144];
+extern unsigned char primary_synch0_tab[72];
+extern unsigned char primary_synch1_tab[72];
+extern unsigned char primary_synch2_tab[72];
+extern int16_t *primary_synch0_time; //!< index: [0..ofdm_symbol_size*2[
+extern int16_t *primary_synch1_time; //!< index: [0..ofdm_symbol_size*2[
+extern int16_t *primary_synch2_time; //!< index: [0..ofdm_symbol_size*2[
+extern int *sync_corr_ue0; //!< index [0..10*samples_per_tti[
+extern int *sync_corr_ue1; //!< index [0..10*samples_per_tti[
+extern int *sync_corr_ue2; //!< index [0..10*samples_per_tti[
+
+extern int flagMag;
+//extern short **txdataF_rep_tmp;
+
+extern char mode_string[4][20];
+
+extern unsigned char NB_RU;
+
+#ifndef OPENAIR2
+extern unsigned char NB_eNB_INST;
+extern unsigned char NB_UE_INST;
+extern unsigned char NB_RN_INST;
+#endif
+
+extern unsigned int ULSCH_max_consecutive_errors;
+extern int flag_LA;
+extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX];
+extern double sinr_bler_map_up[MCS_COUNT][2][16];
+extern int table_length[MCS_COUNT];
+extern double sinr_to_cqi[4][16];
+extern int cqi_to_mcs[16];
+
+//for MU-MIMO abstraction using MIESM
+//this 2D arrarays contains SINR, MI and RBIR in rows 1, 2, and 3 respectively
+extern double MI_map_4qam[3][162];
+extern double MI_map_16qam[3][197];
+extern double MI_map_64qam[3][227];
+
+extern double beta1_dlsch_MI[6][MCS_COUNT];
+extern double beta2_dlsch_MI[6][MCS_COUNT];
+
+extern double q_qpsk[8];
+extern double q_qam16[8];
+extern double q_qam64[8];
+
+extern double p_qpsk[8];
+extern double p_qam16[8];
+extern double p_qam64[8];
+
+extern double beta1_dlsch[6][MCS_COUNT];
+extern double beta2_dlsch[6][MCS_COUNT];
+
+extern char eNB_functions[6][20];
+extern char eNB_timing[2][20];
+extern char ru_if_types[MAX_RU_IF_TYPES][20];
+
+extern int16_t unscrambling_lut[65536*16];
+extern uint8_t scrambling_lut[65536*16];
+
+extern unsigned short msrsb_6_40[8][4];
+extern unsigned short msrsb_41_60[8][4];
+extern unsigned short msrsb_61_80[8][4];
+extern unsigned short msrsb_81_110[8][4];
+extern unsigned short Nb_6_40[8][4];
+extern unsigned short Nb_41_60[8][4];
+extern unsigned short Nb_61_80[8][4];
+extern unsigned short Nb_81_110[8][4];
+
+extern uint16_t hundred_times_log10_NPRB[100];
+extern uint8_t alpha_lut[8];
+extern uint8_t max_turbo_iterations;
+#endif /*__PHY_EXTERN_H__ */
+
diff --git a/openair1/PHY/phy_vars_nr_ue.h b/openair1/PHY/phy_vars_nr_ue.h
new file mode 100644
index 0000000000000000000000000000000000000000..a179f509c61ad2169f1173b5fc862eb968585d19
--- /dev/null
+++ b/openair1/PHY/phy_vars_nr_ue.h
@@ -0,0 +1,150 @@
+/*
+ * 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 __PHY_VARS_NR_H__
+#define __PHY_VARS_NR_H__
+
+#include "PHY/types.h"
+#include "PHY/defs_nr_UE.h"
+#include "PHY/phy_vars_nr_ue.h"
+
+#include "common/ran_context.h"
+
+char* namepointer_chMag ;
+char fmageren_name2[512];
+char* namepointer_log2;
+
+
+#include "PHY/LTE_REFSIG/primary_synch.h"
+int16_t *primary_synch0_time;
+int16_t *primary_synch1_time;
+int16_t *primary_synch2_time;
+
+
+#include "PHY/CODING/coding_vars.h"
+
+//PHY_VARS *PHY_vars;
+#ifndef OCP_FRAMEWORK
+PHY_VARS_NR_UE ***PHY_vars_UE_g;
+LTE_DL_FRAME_PARMS *lte_frame_parms_g;
+#else
+PHY_VARS_NR_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]={NULL};
+
+#endif
+
+
+unsigned short rev[2048],rev_times4[8192],rev_half[1024];
+unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048],rev8192[8192];
+
+
+char mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"};
+
+
+
+#include "SIMULATION/ETH_TRANSPORT/vars.h"
+
+unsigned char NB_RU=0;
+
+#ifndef OPENAIR2
+unsigned char NB_eNB_INST=0;
+unsigned char NB_UE_INST=0;
+unsigned char NB_RN_INST=0;
+unsigned char NB_INST=0;
+#endif
+
+unsigned int ULSCH_max_consecutive_errors = 20;
+
+int number_of_cards;
+
+
+int flag_LA=0;
+int flagMag;
+//extern  channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX];
+//extern  double ABS_SINR_eff_BLER_table[MCS_COUNT][9][9];
+//extern  double ABS_beta[MCS_COUNT];odi
+double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX];
+int table_length[MCS_COUNT];
+//double sinr_bler_map_up[MCS_COUNT][2][16];
+
+//for MU-MIMO abstraction using MIESM
+//this 2D arrarays contains SINR, MI and RBIR in rows 1, 2, and 3 respectively
+double MI_map_4qam[3][162];
+double MI_map_16qam[3][197];
+double MI_map_64qam[3][227];
+
+// here the first index is for transmission mode 1, 2, 5 and 6 whereas the second index is for the 16 sinr vaues corresponding to 16 CQIs
+double sinr_to_cqi[4][16]= { {-2.5051, -2.5051, -1.7451, -0.3655, 1.0812, 2.4012, 3.6849, 6.6754, 8.3885, 8.7970, 12.0437, 14.4709, 15.7281,  17.2424,  17.2424, 17.2424},
+  {-2.2360, -2.2360, -1.3919, -0.0218, 1.5319,  2.9574,  4.3234, 6.3387, 8.9879, 9.5096, 12.6609, 14.0116, 16.4984, 18.1572, 18.1572, 18.1572},
+  {-1, -1.0000, -0.4198, -0.0140, 1.0362,  2.3520, 3.5793, 6.1136, 8.4836, 9.0858, 12.4723, 13.9128, 16.2054, 17.7392, 17.7392, 17.7392},
+  { -4.1057, -4.1057, -3.3768, -2.2916, -1.1392, 0.1236, 1.2849, 3.1933, 5.9298, 6.4052, 9.6245, 10.9414, 13.5166, 14.9545, 14.9545, 14.9545}
+};
+
+//int cqi_to_mcs[16]={0, 0, 1, 3, 5, 7, 9, 13, 15, 16, 20, 23, 25, 27, 27, 27};
+int cqi_to_mcs[16]= {0, 0, 1, 2, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 27, 28};
+
+//for SNR to MI conversion 7 th order Polynomial coeff
+double q_qam16[8]= {3.21151853033897e-10,5.55435952230651e-09,-2.30760065362117e-07,-6.25587743817859e-06,4.62251036452795e-06,0.00224150813158937,0.0393723140344367,0.245486379182639};
+double q_qpsk[8]= {1.94491167814437e-09,8.40494123817774e-08,4.75527131198034e-07,-2.48946285301621e-05,-0.000347614016158364,0.00209252225437100,0.0742986115462510,0.488297879889425};
+double q_qam64[8]= {2.25934026232206e-11,-1.45992206328306e-10,-3.70861183071900e-08,-1.22206071019319e-06,6.49115500399637e-06,0.00129828997837433,0.0259669554914859,0.166602901214898};
+
+//for MI to SNR conversion 7 th order Polynomial coeff
+double p_qpsk[8]= {5982.42405670359,-21568.1135917693,31293.9987036905,-23394.6795043871,9608.34750585489,-2158.15802349899,267.731968719036,-20.6145324295965};
+double p_qam16[8]= {7862.12690694170,-28510.3207048338,41542.2150287122,-31088.3036957379,12690.1982361016,-2785.66604739984,326.595462489375,-18.9911849872089};
+double p_qam64[8]= {8832.57933013696,-32119.1802555952,46914.2578990397,-35163.8150557183,14343.7419388853,-3126.61025510092,360.954930562237,-18.0358548533343};
+
+// ideal CE MIESM
+
+double beta1_dlsch_MI[6][MCS_COUNT] = { {1.1188, 0.3720, 0.3755, 0.9453, 0.5799, 0.5256, 0.5485, 0.5340, 0.5165, 0.5300, 0.6594, 0.5962, 0.4884, 0.4927, 0.3687, 0.4614, 0.4081, 0.2639,0.2935,0.2520,0.3709,0.2906,0.2612,0.2390}, {0.7138, 0.5533, 0.5533, 0.4828, 0.4998, 0.4843, 0.4942, 0.5323, 0.5142, 0.4756, 0.5792, 0.4167, 0.4445, 0.3942, 0.3789, 0.2756, 0.4456, 0.1650, 0.2254, 0.2353, 0.2097,0.2517,0.3242,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1},{1.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.7146, 0.4789, 0.5392, 0.5556, 0.4975, 0.4847, 0.4691, 0.5261, 0.5278, 0.4962, 0.4468, 0.4113, 0.4622, 0.4609, 0.3946, 0.3991, 0.3532, 0.2439, 0.1898, 0.2929, 0.2712, 0.3367, 0.3591, 0.2571}};
+double beta2_dlsch_MI[6][MCS_COUNT] = { {1.1293, 0.3707, 0.3722, 0.9310, 0.5808, 0.5265, 0.5404, 0.5279, 0.5210, 0.5226, 0.6438, 0.5827, 0.4804, 0.4830, 0.3638, 0.4506, 0.4107, 0.2547, 0.2797, 0.2413, 0.3351, 0.2750, 0.2568, 0.2273}, {0.7028, 0.5503, 0.5503, 0.4815, 0.5006, 0.4764, 0.4810, 0.5124, 0.4964, 0.4485, 0.5497, 0.3971, 0.4239, 0.3701, 0.3494, 0.2630, 0.4053, 0.1505, 0.2001,0.2024,0.1788,0.2124,0.2668,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1},{1.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.6980, 0.4694, 0.5379, 0.5483, 0.4982, 0.4737, 0.4611, 0.5051, 0.5020, 0.4672, 0.4357, 0.3957, 0.4389, 0.4344, 0.3645, 0.3661, 0.3301, 0.2179, 0.1730, 0.2536, 0.2389,0.2884,0.2936,0.2226}};
+
+//real CE MIESM
+/*
+double beta1_dlsch_MI[6][MCS_COUNT] = { {1.32955, 0.59522, 0.54024, 0.98698, 0.81305, 0.76976, 0.69258, 0.69713, 0.70546, 0.69111, 0.81904, 0.72664, 0.79491, 0.72562, 0.53980, 0.33134, 0.50550, 0.40602,0.40281,0.47012,0.50510,0.23540,0.32045,1}, {0.59632, 1.08475, 1.02431, 1.07020, 0.90170, 0.97719, 0.95464, 0.92764, 0.86721, 0.85986, 0.64558, 0.80631, 0.82673, 0.82888, 0.87122, 0.77245, 0.29771, 0.43477, 0.55321, 0.61027, 0.56111, 0.57292, 0.39737,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1,1},{1.808065416202085, 1.754544945430673,1.902272019362616, 1.790054645392961, 1.563204092967629, 1.585258289348813, 1.579349443720310, 1.570650121437345, 1.545055626608596, 1.362229442426877, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33, 1,1,1,1,1,1,1},{0.77532, 1.07544, 1.10571, 1.04099, 0.91638, 0.88644, 0.96405, 0.86709, 0.94066, 0.84430, 1.24478, 1.09665, 1.42604, 0.79541, 0.71847, 0.71604, 0.74561, 0.36431, 0.41536, 0.52175, 0.47096, 0.49977, 0.59728,1}};
+double beta2_dlsch_MI[6][MCS_COUNT] = { {1.36875, 0.59304, 0.53870, 0.98239, 0.81637, 0.76847, 0.69842, 0.69885, 0.69967, 0.69826, 0.82660, 0.70559, 0.78404, 0.70670, 0.55393, 0.36893, 0.52225, 0.39752, 0.40494, 0.46239, 0.49247,0.26900,0.34504,1}, {0.43775, 0.78208, 0.72875, 0.77458, 0.64485, 0.69174, 0.66097, 0.63289, 0.59652, 0.61175, 0.44551, 0.56047, 0.57314, 0.57553, 0.58849, 0.52159, 0.21241, 0.30139, 0.37373, 0.32029, 0.37067, 0.36706, 0.27118,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1},{1.079518113138858, 1.105622953570353, 1.031337449900606, 1.073342032668810, 1.242636589110353, 1.255054927783647, 1.291463834317768, 1.317048698347491, 1.354485054187984, 0.338534029291017, 1.85, 1.79, 1.65, 1.54, 1.46, 1.39, 1.33,1, 1,1,1,1,1,1},{0.54448, 0.73731, 0.79165, 0.74407, 0.68042, 0.64906, 0.71349, 0.62109, 0.65815, 0.60940, 0.90549, 0.78708, 1.03176, 0.58431, 0.53379, 0.51224, 0.52767, 0.26848, 0.29642, 0.36879, 0.34148, 0.35279,0.40633,1}};
+*/
+//ideal channel estimation values
+//double beta1_dlsch[6][MCS_COUNT] = { {2.3814, 0.4956, 0.5273, 1.1708, 0.8014, 0.7889, 0.8111, 0.8139, 0.8124, 0.8479, 1.9280, 1.9664, 2.3857, 2.5147, 2.4511, 3.0158, 2.8643, 5.3013, 5.8594, 6.5372, 7.8073, 7.8030, 7.5295, 7.1320}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}};
+//double beta2_dlsch[6][MCS_COUNT] = { {2.3639, 0.4952, 0.5207, 1.1572, 0.8026, 0.7864, 0.7996, 0.8034, 0.8200, 0.8367, 1.8701, 1.9212, 2.2947, 2.4472, 2.4091, 2.9479, 2.8973, 5.0591, 5.5134, 6.1483, 7.2166, 7.5177, 7.5704, 7.2248}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}};
+double beta1_dlsch[6][MCS_COUNT] = { {1.199175, 1.085656, 0.983872, 0.843789, 0.816093, 0.853078, 0.899236, 0.919665, 0.888673, 0.924181, 0.814176, 0.794108, 0.770653, 0.826266, 0.982043, 0.979621, 0.985176, 0.901741, 0.870311, 0.911303, 0.898923, 1.003359, 0.988535, 1.030639, 1.151038, 1.116939, 1.214118, 1.219148}, {0.5146, 0.5549, 0.7405, 0.6913, 0.7349, 0.7000, 0.7539, 0.7955, 0.8074, 0.7760, 1.8150, 1.6561, 1.9280, 2.3563, 2.6699, 2.3086, 3.1601, 4.5316, 5.2870, 6.0983, 6.5635, 7.7024, 9.9592, 6.6173}, {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1.79358, 1.17908, 2.02600, 1.72040, 1.58618, 1.59039, 1.68111, 1.67062, 1.64911, 1.33274, 4.87800, 3.58797, 3.72338, 5.35700, 2.81752, 1.93472, 2.23259, 1,1,1,1,1,1,1}, {0.4445, 0.5918, 0.7118, 0.7115, 0.7284, 0.7202, 0.7117, 0.8111, 0.8239, 0.7907, 1.8456, 1.8144, 2.3830, 2.6634, 2.6129, 2.8127, 2.7372, 4.9424, 4.8763, 6.8413, 7.1493, 9.4180, 10.1230, 8.9613}};
+double beta2_dlsch[6][MCS_COUNT] = { {0.534622, 0.596561, 0.500838, 0.471721, 0.548218, 0.547974, 0.924245, 0.836484, 0.776917, 0.879691, 0.875722, 0.666933, 0.666393, 0.755377, 1.074985, 1.080290, 1.010914, 0.790892, 0.793435, 0.860249, 0.901508, 0.967060, 0.951372, 1.011493, 1.106151, 1.117076, 1.209397, 1.227790}, {0.5113, 0.5600, 0.7359, 0.6860, 0.7344, 0.6902, 0.7315, 0.7660, 0.7817, 0.7315, 1.7268, 1.5912, 1.8519, 2.2115, 2.4580, 2.1879, 2.9015, 4.1543, 4.6986, 5.3193, 5.6319, 6.5640, 8.2421, 5.6393}, {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {0.79479, 0.52872, 0.90005, 0.77170, 0.73220, 0.72060, 0.75433, 0.75451, 0.75989, 0.67655, 1.68525, 1.31100, 1.46573, 1.99843, 1.57293, 1.62852, 2.10636, 1,1,1,1,1,1,1}, {0.4398, 0.5823, 0.7094, 0.7043, 0.7282, 0.7041, 0.6979, 0.7762, 0.7871, 0.7469, 1.7752, 1.7443, 2.2266, 2.4767, 2.4146, 2.6040, 2.5708, 4.4488, 4.4944, 5.9630, 6.3740, 8.1097, 8.4210, 7.8027}};
+
+//real channel estimation valus
+/*
+double beta1_dlsch[6][MCS_COUNT] = { {2.50200, 0.84047, 0.78195, 1.37929, 1.16871, 1.11906, 1.06303, 1.07447, 1.11403, 1.09223, 2.82502, 2.87556, 3.51254, 3.62920, 3.53638, 2.35980, 3.74126, 8.66532, 7.31772, 9.86882, 10.64939, 6.75208, 9.50664, 13.63057}, {0.92257, 1, 1.80445, 1.43175, 1.42093, 1.37381, 1.45392, 1.47255, 1.47451, 1.41235, 3.9079, 3.38557, 4.13059, 4.93355, 4.97277, 6.04951, 5.88896, 8.68076, 10.23746, 12.37069, 5.50538, 17.29612, 17.95050, 13.27095}, {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {1.79255, 1.88213, 4.44226, 2.25150, 1.93710, 2.18504, 2.57389, 1.94322, 1.78515, 2.09265, 2.37459, 1.74442, 1.74346, 1.19705, 1.56149, 1.59604, 1.6, 1,1,1,1,1,1,1}, {0.93374, 1.40389, 1.36670, 1.38679, 1.35707, 1.26353, 1.32360, 1.40164, 1.51843, 1.34863, 3.45839, 3.13726, 3.94768, 4.21966, 4.60750, 4.97894, 5.40755, 8.12814, 10.59221, 12.96427, 13.37323, 14.27206, 16.61779, 17.19656}};
+double beta2_dlsch[6][MCS_COUNT] = { {2.52163, 0.83231, 0.77472, 1.36536, 1.16829, 1.11186, 1.06287, 1.07292, 1.09946, 1.10650, 2.79174, 2.75655, 3.36651, 3.49011, 3.60903, 2.73517, 3.84009, 8.20312, 7.41739, 9.64081, 10.40911, 8.11765, 10.41923, 9.34300}, {0.67252, 0.8600, 1.28633, 1.01624, 1.03066, 0.97590, 1.02560, 1.01840, 1.00547, 0.97093, 2.72573, 2.33283, 2.86181, 3.40452, 3.47957, 4.08916, 3.97628, 6.14541, 7.11017, 8.42369, 4.04812, 11.42082, 11.57171, 9.28462}, {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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1,1}, {0.85784, 0.90361, 2.09766, 1.08385, 0.96300, 1.04432, 1.22763, 0.99249, 0.95544, 1.12333, 1.37924, 1.12913, 1.30644, 1.19253, 1.75488, 2.13813, 2.10636, 1,1,1,1,1,1,1}, {0.66288, 0.96402, 0.98545, 0.99386, 0.99981, 0.92678, 0.98978, 0.99600, 1.05538, 0.97777, 2.52504, 2.29338, 2.89631, 3.10812, 3.41916, 3.58671, 3.84166, 6.05254, 7.45821, 9.15812, 9.66330, 10.17852, 11.50519, 11.16299}};
+
+*/
+
+#ifdef OCP_FRAMEWORK
+#include <enums.h>
+#else
+char eNB_functions[6][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RAU_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5",};
+char eNB_timing[2][20]={"synch_to_ext_device","synch_to_other"};
+char ru_if_types[MAX_RU_IF_TYPES][20]={"local RF","IF5 RRU","IF5 Mobipass","IF4p5 RRU","IF1pp RRU"};
+#endif
+
+/// lookup table for unscrambling in RX
+int16_t unscrambling_lut[65536*16] __attribute__((aligned(32)));
+/// lookup table for scrambling in TX
+uint8_t scrambling_lut[65536*16] __attribute__((aligned(32)));
+
+uint8_t max_turbo_iterations=4;
+#endif /*__PHY_VARS_H__ */
diff --git a/openair1/SCHED_NR/phy_frame_config_nr.h b/openair1/SCHED_NR/phy_frame_config_nr.h
new file mode 100644
index 0000000000000000000000000000000000000000..80cf23b02672e0800edc78d4e29d11045b62bb40
--- /dev/null
+++ b/openair1/SCHED_NR/phy_frame_config_nr.h
@@ -0,0 +1,96 @@
+/*
+ * 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
+ */
+
+/***********************************************************************
+*
+* FILENAME    :  phy_frame_configuration_nr.h
+*
+* DESCRIPTION :  functions related to FDD/TDD configuration  for NR
+*                see TS 38.213 11.1 Slot configuration
+*                and TS 38.331 for RRC configuration
+*
+************************************************************************/
+
+#ifndef PHY_FRAME_CONFIG_NR_H
+#define PHY_FRAME_CONFIG_NR_H
+
+/************** DEFINE ********************************************/
+
+#define TDD_CONFIG_NB_FRAMES           (2)
+
+/*************** FUNCTIONS *****************************************/
+
+/** \brief This function processes tdd dedicated configuration for nr
+ *  @param frame_parms NR DL Frame parameters
+ *  @param dl_UL_TransmissionPeriodicity periodicity
+ *  @param nrofDownlinkSlots number of downlink slots
+ *  @param nrofDownlinkSymbols number of downlink symbols
+ *  @param nrofUplinkSlots number of uplink slots
+ *  @param nrofUplinkSymbols number of uplink symbols
+    @returns 0 if tdd dedicated configuration has been properly set or -1 on error with message */
+
+int set_tdd_config_nr(NR_DL_FRAME_PARMS *frame_parms, int dl_UL_TransmissionPeriodicity,
+                       int nrofDownlinkSlots, int nrofDownlinkSymbols,
+                       int nrofUplinkSlots,   int nrofUplinkSymbols);
+
+/** \brief This function adds a slot configuration to current dedicated configuration for nr
+ *  @param frame_parms NR DL Frame parameters
+ *  @param slotIndex
+ *  @param nrofDownlinkSymbols
+ *  @param nrofUplinkSymbols
+    @returns none */
+
+void add_tdd_dedicated_configuration_nr(NR_DL_FRAME_PARMS *frame_parms, int slotIndex,
+                                        int nrofDownlinkSymbols, int nrofUplinkSymbols);
+
+/** \brief This function processes tdd dedicated configuration for nr
+ *  @param frame_parms nr frame parameters
+ *  @param dl_UL_TransmissionPeriodicity periodicity
+ *  @param nrofDownlinkSlots number of downlink slots
+ *  @param nrofDownlinkSymbols number of downlink symbols
+ *  @param nrofUplinkSlots number of uplink slots
+ *  @param nrofUplinkSymbols number of uplink symbols
+    @returns 0 if tdd dedicated configuration has been properly set or -1 on error with message */
+
+int set_tdd_configuration_dedicated_nr(NR_DL_FRAME_PARMS *frame_parms);
+
+/** \brief This function checks nr slot direction : downlink or uplink
+ *  @param frame_parms NR DL Frame parameters
+ *  @param nr_frame : frame number
+ *  @param nr_tti   : slot number
+    @returns nr_slot_t : downlink or uplink */
+
+nr_slot_t slot_select_nr(NR_DL_FRAME_PARMS *frame_parms, int nr_frame, int nr_tti);
+
+/** \brief This function frees tdd configuration for nr
+ *  @param frame_parms NR DL Frame parameters
+    @returns none */
+
+void free_tdd_configuration_nr(NR_DL_FRAME_PARMS *frame_parms);
+
+/** \brief This function frees tdd dedicated configuration for nr
+ *  @param frame_parms NR DL Frame parameters
+    @returns none */
+
+void free_tdd_configuration_dedicated_nr(NR_DL_FRAME_PARMS *frame_parms);
+
+#endif  /* PHY_FRAME_CONFIG_NR_H */
+
diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c
index 27ff707441364af5b40e68644ed9342da08e5ef1..a212acc2c05a0911f87fabb7fd6e1efe8387ba62 100644
--- a/openair2/RRC/LTE/rrc_eNB.c
+++ b/openair2/RRC/LTE/rrc_eNB.c
@@ -839,7 +839,6 @@ rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s
       }
 
       for (i=0; i<NUMBER_OF_UE_MAX; i++) {
-
         dlsch = eNB_PHY->dlsch[i][0];
 
         if((dlsch != NULL) && (dlsch->rnti == rnti)) {
@@ -5336,7 +5335,7 @@ openair_rrc_eNB_init(
     for (int ue_id = 0; ue_id < NUMBER_OF_UE_MAX; ue_id++) {
       RC.rrc[ctxt.module_id]->carrier[CC_id].sizeof_paging[ue_id] = 0;
       RC.rrc[ctxt.module_id]->carrier[CC_id].paging[ue_id] = (uint8_t *) malloc16(256);
-
+      
     }
   }
   rrc_init_global_param();
diff --git a/targets/ARCH/ADRV9371_ZC706/USERSPACE/PROFILES/ue.band7.tm1.PRB100.NR40.adrv9371-zc706.ini b/targets/ARCH/ADRV9371_ZC706/USERSPACE/PROFILES/ue.band7.tm1.PRB100.NR40.adrv9371-zc706.ini
new file mode 100644
index 0000000000000000000000000000000000000000..8dfe8d658917d649a41e52926145f4465e9e4399
--- /dev/null
+++ b/targets/ARCH/ADRV9371_ZC706/USERSPACE/PROFILES/ue.band7.tm1.PRB100.NR40.adrv9371-zc706.ini
@@ -0,0 +1,89 @@
+[AD9371]
+ad9371-phy.in_voltage2_rf_port_select = OFF
+ad9371-phy.in_voltage2_hardwaregain = -156.000000 dB
+ad9371-phy.in_voltage2_temp_comp_gain = 0.00 dB
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.out_voltage0_lo_leakage_tracking_en = 0
+ad9371-phy.out_voltage0_hardwaregain = 0.000000 dB
+ad9371-phy.out_voltage0_quadrature_tracking_en = 1
+ad9371-phy.out_voltage1_hardwaregain = 0.000000 dB
+ad9371-phy.out_voltage1_lo_leakage_tracking_en = 0
+ad9371-phy.out_voltage1_quadrature_tracking_en = 1
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.out_altvoltage1_TX_LO_frequency = 2560000000
+ad9371-phy.out_altvoltage2_RX_SN_LO_frequency = 2680000000
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.in_voltage0_gain_control_mode = manual
+ad9371-phy.in_voltage0_quadrature_tracking_en = 1
+ad9371-phy.in_voltage0_hardwaregain = 30.000000 dB
+ad9371-phy.in_voltage0_temp_comp_gain = 0.00 dB
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.in_voltage1_quadrature_tracking_en = 1
+ad9371-phy.in_voltage1_hardwaregain = 30.000000 dB
+ad9371-phy.in_voltage1_temp_comp_gain = 0.00 dB
+ad9371-phy.in_voltage1_gain_control_mode = manual
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.out_altvoltage0_RX_LO_frequency = 2680000000
+ad9371-phy.calibrate_rx_qec_en = 0
+ad9371-phy.calibrate_tx_lol_en = 0
+ad9371-phy.calibrate_vswr_en = 0
+ad9371-phy.calibrate_tx_qec_en = 0
+ad9371-phy.calibrate_clgc_en = 0
+ad9371-phy.ensm_mode = radio_on
+ad9371-phy.calibrate_tx_lol_ext_en = 0
+ad9371-phy.calibrate_dpd_en = 0
+axi-ad9371-tx-hpc.out_altvoltage0_TX1_I_F1_phase = 90000
+axi-ad9371-tx-hpc.out_altvoltage0_TX1_I_F1_scale = 0.501160
+axi-ad9371-tx-hpc.out_altvoltage0_TX1_I_F1_frequency = 1999718
+axi-ad9371-tx-hpc.out_altvoltage0_TX1_I_F1_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage5_TX2_I_F2_phase = 90000
+axi-ad9371-tx-hpc.out_altvoltage5_TX2_I_F2_scale = 0.000000
+axi-ad9371-tx-hpc.out_altvoltage5_TX2_I_F2_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage5_TX2_I_F2_frequency = 1000327
+axi-ad9371-tx-hpc.out_altvoltage4_TX2_I_F1_frequency = 7999809
+axi-ad9371-tx-hpc.out_altvoltage4_TX2_I_F1_phase = 90000
+axi-ad9371-tx-hpc.out_altvoltage4_TX2_I_F1_scale = 0.251160
+axi-ad9371-tx-hpc.out_altvoltage4_TX2_I_F1_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage6_TX2_Q_F1_frequency = 7999809
+axi-ad9371-tx-hpc.out_altvoltage6_TX2_Q_F1_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage6_TX2_Q_F1_phase = 0
+axi-ad9371-tx-hpc.out_altvoltage6_TX2_Q_F1_scale = 0.251160
+axi-ad9371-tx-hpc.out_altvoltage3_TX1_Q_F2_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage3_TX1_Q_F2_phase = 0
+axi-ad9371-tx-hpc.out_altvoltage3_TX1_Q_F2_scale = 0.000000
+axi-ad9371-tx-hpc.out_altvoltage3_TX1_Q_F2_frequency = 19998117
+axi-ad9371-tx-hpc.out_altvoltage7_TX2_Q_F2_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage7_TX2_Q_F2_phase = 0
+axi-ad9371-tx-hpc.out_altvoltage7_TX2_Q_F2_scale = 0.000000
+axi-ad9371-tx-hpc.out_altvoltage7_TX2_Q_F2_frequency = 1000327
+axi-ad9371-tx-hpc.out_altvoltage2_TX1_Q_F1_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage2_TX1_Q_F1_phase = 0
+axi-ad9371-tx-hpc.out_altvoltage2_TX1_Q_F1_scale = 0.501160
+axi-ad9371-tx-hpc.out_altvoltage2_TX1_Q_F1_frequency = 1999718
+axi-ad9371-tx-hpc.out_altvoltage1_TX1_I_F2_frequency = 19998117
+axi-ad9371-tx-hpc.out_altvoltage1_TX1_I_F2_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage1_TX1_I_F2_phase = 90000
+axi-ad9371-tx-hpc.out_altvoltage1_TX1_I_F2_scale = 0.000000
+load_myk_profile_file = /targets/ARCH/ADRV9371_ZC706/USERSPACE/PROFILES/profileNR40MHz.txt
+dds_mode_tx1 = 1
+dds_mode_tx2 = 1
+dac_buf_filename = /usr/local/lib/osc/waveforms/LTE20.mat
+tx_channel_0 = 1
+tx_channel_1 = 1
+tx_channel_2 = 0
+tx_channel_3 = 0
+global_settings_show = 1
+tx_show = 1
+rx_show = 1
+obs_show = 1
+fpga_show = 1
+
+[ADRV9371_ZC706]
+# NO_DEBUG=0; DEBUG=1
+debug_mode = 0
+# 20MHz 40MHz 80MHz=1; 10MHz=2; 5MHz=4
+interpolation_decimation_factor = 1
+# is taken into account only if "ad9371-phy.in_voltage0_gain_control_mode = manual"
+rx_gain_offset = 43
diff --git a/targets/ARCH/ADRV9371_ZC706/USERSPACE/PROFILES/ue.band7.tm1.PRB100.NR80.adrv9371-zc706.ini b/targets/ARCH/ADRV9371_ZC706/USERSPACE/PROFILES/ue.band7.tm1.PRB100.NR80.adrv9371-zc706.ini
new file mode 100644
index 0000000000000000000000000000000000000000..007499c8ebe935e7534f27ba183f39ee2dde4fa8
--- /dev/null
+++ b/targets/ARCH/ADRV9371_ZC706/USERSPACE/PROFILES/ue.band7.tm1.PRB100.NR80.adrv9371-zc706.ini
@@ -0,0 +1,89 @@
+[AD9371]
+ad9371-phy.in_voltage2_rf_port_select = OFF
+ad9371-phy.in_voltage2_hardwaregain = -156.000000 dB
+ad9371-phy.in_voltage2_temp_comp_gain = 0.00 dB
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.out_voltage0_lo_leakage_tracking_en = 0
+ad9371-phy.out_voltage0_hardwaregain = 0.000000 dB
+ad9371-phy.out_voltage0_quadrature_tracking_en = 1
+ad9371-phy.out_voltage1_hardwaregain = 0.000000 dB
+ad9371-phy.out_voltage1_lo_leakage_tracking_en = 0
+ad9371-phy.out_voltage1_quadrature_tracking_en = 1
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.out_altvoltage1_TX_LO_frequency = 2560000000
+ad9371-phy.out_altvoltage2_RX_SN_LO_frequency = 2680000000
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.in_voltage0_gain_control_mode = manual
+ad9371-phy.in_voltage0_quadrature_tracking_en = 1
+ad9371-phy.in_voltage0_hardwaregain = 30.000000 dB
+ad9371-phy.in_voltage0_temp_comp_gain = 0.00 dB
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.in_voltage1_quadrature_tracking_en = 1
+ad9371-phy.in_voltage1_hardwaregain = 30.000000 dB
+ad9371-phy.in_voltage1_temp_comp_gain = 0.00 dB
+ad9371-phy.in_voltage1_gain_control_mode = manual
+ad9371-phy.in_voltage_rf_port_select_available = OFF INTERNALCALS OBS_SNIFFER SN_A SN_B SN_C ORX1_TX_LO ORX2_TX_LO ORX1_SN_LO ORX2_SN_LO
+ad9371-phy.out_altvoltage0_RX_LO_frequency = 2680000000
+ad9371-phy.calibrate_rx_qec_en = 0
+ad9371-phy.calibrate_tx_lol_en = 0
+ad9371-phy.calibrate_vswr_en = 0
+ad9371-phy.calibrate_tx_qec_en = 0
+ad9371-phy.calibrate_clgc_en = 0
+ad9371-phy.ensm_mode = radio_on
+ad9371-phy.calibrate_tx_lol_ext_en = 0
+ad9371-phy.calibrate_dpd_en = 0
+axi-ad9371-tx-hpc.out_altvoltage0_TX1_I_F1_phase = 90000
+axi-ad9371-tx-hpc.out_altvoltage0_TX1_I_F1_scale = 0.501160
+axi-ad9371-tx-hpc.out_altvoltage0_TX1_I_F1_frequency = 1999718
+axi-ad9371-tx-hpc.out_altvoltage0_TX1_I_F1_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage5_TX2_I_F2_phase = 90000
+axi-ad9371-tx-hpc.out_altvoltage5_TX2_I_F2_scale = 0.000000
+axi-ad9371-tx-hpc.out_altvoltage5_TX2_I_F2_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage5_TX2_I_F2_frequency = 1000327
+axi-ad9371-tx-hpc.out_altvoltage4_TX2_I_F1_frequency = 7999809
+axi-ad9371-tx-hpc.out_altvoltage4_TX2_I_F1_phase = 90000
+axi-ad9371-tx-hpc.out_altvoltage4_TX2_I_F1_scale = 0.251160
+axi-ad9371-tx-hpc.out_altvoltage4_TX2_I_F1_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage6_TX2_Q_F1_frequency = 7999809
+axi-ad9371-tx-hpc.out_altvoltage6_TX2_Q_F1_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage6_TX2_Q_F1_phase = 0
+axi-ad9371-tx-hpc.out_altvoltage6_TX2_Q_F1_scale = 0.251160
+axi-ad9371-tx-hpc.out_altvoltage3_TX1_Q_F2_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage3_TX1_Q_F2_phase = 0
+axi-ad9371-tx-hpc.out_altvoltage3_TX1_Q_F2_scale = 0.000000
+axi-ad9371-tx-hpc.out_altvoltage3_TX1_Q_F2_frequency = 19998117
+axi-ad9371-tx-hpc.out_altvoltage7_TX2_Q_F2_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage7_TX2_Q_F2_phase = 0
+axi-ad9371-tx-hpc.out_altvoltage7_TX2_Q_F2_scale = 0.000000
+axi-ad9371-tx-hpc.out_altvoltage7_TX2_Q_F2_frequency = 1000327
+axi-ad9371-tx-hpc.out_altvoltage2_TX1_Q_F1_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage2_TX1_Q_F1_phase = 0
+axi-ad9371-tx-hpc.out_altvoltage2_TX1_Q_F1_scale = 0.501160
+axi-ad9371-tx-hpc.out_altvoltage2_TX1_Q_F1_frequency = 1999718
+axi-ad9371-tx-hpc.out_altvoltage1_TX1_I_F2_frequency = 19998117
+axi-ad9371-tx-hpc.out_altvoltage1_TX1_I_F2_raw = 1
+axi-ad9371-tx-hpc.out_altvoltage1_TX1_I_F2_phase = 90000
+axi-ad9371-tx-hpc.out_altvoltage1_TX1_I_F2_scale = 0.000000
+load_myk_profile_file = /targets/ARCH/ADRV9371_ZC706/USERSPACE/PROFILES/profileNR80MHz.txt
+dds_mode_tx1 = 1
+dds_mode_tx2 = 1
+dac_buf_filename = /usr/local/lib/osc/waveforms/LTE20.mat
+tx_channel_0 = 1
+tx_channel_1 = 1
+tx_channel_2 = 0
+tx_channel_3 = 0
+global_settings_show = 1
+tx_show = 1
+rx_show = 1
+obs_show = 1
+fpga_show = 1
+
+[ADRV9371_ZC706]
+# NO_DEBUG=0; DEBUG=1
+debug_mode = 0
+# 20MHz 40MHz 80MHz=1; 10MHz=2; 5MHz=4
+interpolation_decimation_factor = 1
+# is taken into account only if "ad9371-phy.in_voltage0_gain_control_mode = manual"
+rx_gain_offset = 53
diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h
index 7460c4849bfa383048a100ef4184b562d5856f0e..e6f0d5d0f13e6d41b8ada32d42a69392259af807 100644
--- a/targets/ARCH/COMMON/common_lib.h
+++ b/targets/ARCH/COMMON/common_lib.h
@@ -211,6 +211,14 @@ typedef struct {
   int iq_rxrescale;
   //! Configuration file for LMS7002M
   char *configFilename;
+  //! remote IP/MAC addr for Ethernet interface
+  char *remote_addr;
+  //! remote port number for Ethernet interface
+  unsigned int remote_port;
+  //! local IP/MAC addr for Ethernet interface (eNB/BBU, UE)
+  char *my_addr;
+  //! local port number for Ethernet interface (eNB/BBU, UE)
+  unsigned int my_port;
 #if defined(USRP_REC_PLAY)
   unsigned short sf_mode;           // 1=record, 2=replay
   char           sf_filename[1024]; // subframes file path
diff --git a/targets/COMMON/threads_t.h b/targets/COMMON/threads_t.h
index ddc060e8c331328b9b8a3a564940df4fba896e80..99fb0d8cf449d225c0d771bbde630fb460cfe508 100644
--- a/targets/COMMON/threads_t.h
+++ b/targets/COMMON/threads_t.h
@@ -9,6 +9,12 @@ typedef struct threads_s {
     int slot1_proc_one;
     int slot1_proc_two;
     int slot1_proc_three;
+    int dlsch_td_one;
+	int dlsch_td_two;
+	int dlsch_td_three;
+	int dlsch_td1_one;
+	int dlsch_td1_two;
+	int dlsch_td1_three;
 } threads_t;
 
 #endif /* _THREADS_T_H_ */
diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ac0acef776eab4587da32c72ab81a8d5a6408197 100644
--- a/targets/RT/USER/nr-ue.c
+++ b/targets/RT/USER/nr-ue.c
@@ -0,0 +1,1106 @@
+/*
+ * 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 lte-ue.c
+ * \brief threads and support functions for real-time LTE UE target
+ * \author R. Knopp, F. Kaltenberger, Navid Nikaein
+ * \date 2015
+ * \version 0.1
+ * \company Eurecom
+ * \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr, navid.nikaein@eurecom.fr
+ * \note
+ * \warning
+ */
+#include "nr-uesoftmodem.h"
+
+#include "rt_wrapper.h"
+
+#include "LAYER2/MAC/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 "SCHED_NR/extern.h"
+//#ifndef NO_RAT_NR
+#include "SCHED_NR/phy_frame_config_nr.h"
+//#endif
+
+#include "../../../openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h"
+
+#include "UTIL/LOG/log_extern.h"
+#include "UTIL/OTG/otg_tx.h"
+#include "UTIL/OTG/otg_externs.h"
+#include "UTIL/MATH/oml.h"
+#include "UTIL/LOG/vcd_signal_dumper.h"
+#include "UTIL/OPT/opt.h"
+
+#include "T.h"
+
+extern double cpuf;
+
+#define FRAME_PERIOD    100000000ULL
+#define DAQ_PERIOD      66667ULL
+#define FIFO_PRIORITY   40
+
+typedef enum {
+    pss=0,
+    pbch=1,
+    si=2
+} sync_mode_t;
+
+void init_UE_threads(PHY_VARS_NR_UE *UE);
+void *UE_thread(void *arg);
+void init_UE(int nb_inst);
+
+int32_t **rxdata;
+int32_t **txdata;
+
+#define KHz (1000UL)
+#define MHz (1000*KHz)
+#define SAIF_ENABLED
+
+#ifdef SAIF_ENABLED
+uint64_t	g_ue_rx_thread_busy	= 0;
+#endif
+
+typedef struct eutra_band_s {
+    int16_t band;
+    uint32_t ul_min;
+    uint32_t ul_max;
+    uint32_t dl_min;
+    uint32_t dl_max;
+    lte_frame_type_t frame_type;
+} eutra_band_t;
+
+typedef struct band_info_s {
+    int nbands;
+    eutra_band_t band_info[100];
+} band_info_t;
+
+band_info_t bands_to_scan;
+
+static const eutra_band_t eutra_bands[] = {
+    { 1, 1920    * MHz, 1980    * MHz, 2110    * MHz, 2170    * MHz, FDD},
+    { 2, 1850    * MHz, 1910    * MHz, 1930    * MHz, 1990    * MHz, FDD},
+    { 3, 1710    * MHz, 1785    * MHz, 1805    * MHz, 1880    * MHz, FDD},
+    { 4, 1710    * MHz, 1755    * MHz, 2110    * MHz, 2155    * MHz, FDD},
+    { 5,  824    * MHz,  849    * MHz,  869    * MHz,  894    * MHz, FDD},
+    { 6,  830    * MHz,  840    * MHz,  875    * MHz,  885    * MHz, FDD},
+    { 7, 2500    * MHz, 2570    * MHz, 2620    * MHz, 2690    * MHz, FDD},
+    { 8,  880    * MHz,  915    * MHz,  925    * MHz,  960    * MHz, FDD},
+    { 9, 1749900 * KHz, 1784900 * KHz, 1844900 * KHz, 1879900 * KHz, FDD},
+    {10, 1710    * MHz, 1770    * MHz, 2110    * MHz, 2170    * MHz, FDD},
+    {11, 1427900 * KHz, 1452900 * KHz, 1475900 * KHz, 1500900 * KHz, FDD},
+    {12,  698    * MHz,  716    * MHz,  728    * MHz,  746    * MHz, FDD},
+    {13,  777    * MHz,  787    * MHz,  746    * MHz,  756    * MHz, FDD},
+    {14,  788    * MHz,  798    * MHz,  758    * MHz,  768    * MHz, FDD},
+    {17,  704    * MHz,  716    * MHz,  734    * MHz,  746    * MHz, FDD},
+    {20,  832    * MHz,  862    * MHz,  791    * MHz,  821    * MHz, FDD},
+    {22, 3510    * MHz, 3590    * MHz, 3410    * MHz, 3490    * MHz, FDD},
+    {33, 1900    * MHz, 1920    * MHz, 1900    * MHz, 1920    * MHz, TDD},
+    {34, 2010    * MHz, 2025    * MHz, 2010    * MHz, 2025    * MHz, TDD},
+    {35, 1850    * MHz, 1910    * MHz, 1850    * MHz, 1910    * MHz, TDD},
+    {36, 1930    * MHz, 1990    * MHz, 1930    * MHz, 1990    * MHz, TDD},
+    {37, 1910    * MHz, 1930    * MHz, 1910    * MHz, 1930    * MHz, TDD},
+    {38, 2570    * MHz, 2620    * MHz, 2570    * MHz, 2630    * MHz, TDD},
+    {39, 1880    * MHz, 1920    * MHz, 1880    * MHz, 1920    * MHz, TDD},
+    {40, 2300    * MHz, 2400    * MHz, 2300    * MHz, 2400    * MHz, TDD},
+    {41, 2496    * MHz, 2690    * MHz, 2496    * MHz, 2690    * MHz, TDD},
+    {42, 3400    * MHz, 3600    * MHz, 3400    * MHz, 3600    * MHz, TDD},
+    {43, 3600    * MHz, 3800    * MHz, 3600    * MHz, 3800    * MHz, TDD},
+    {44, 703    * MHz, 803    * MHz, 703    * MHz, 803    * MHz, TDD},
+};
+
+PHY_VARS_NR_UE* init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms,
+			  uint8_t UE_id,
+			  uint8_t abstraction_flag)
+
+{
+
+  PHY_VARS_NR_UE* ue;
+
+  if (frame_parms!=(NR_DL_FRAME_PARMS *)NULL) { // if we want to give initial frame parms, allocate the PHY_VARS_UE structure and put them in
+    ue = (PHY_VARS_NR_UE *)malloc(sizeof(PHY_VARS_NR_UE));
+    memset(ue,0,sizeof(PHY_VARS_NR_UE));
+    memcpy(&(ue->frame_parms), frame_parms, sizeof(NR_DL_FRAME_PARMS));
+  }
+  else ue = PHY_vars_UE_g[UE_id][0];
+
+  ue->Mod_id      = UE_id;
+  ue->mac_enabled = 1;
+  // initialize all signal buffers
+  init_nr_ue_signal(ue,1,abstraction_flag);
+  // intialize transport
+  //init_nr_ue_transport(ue,abstraction_flag);
+
+  return(ue);
+}
+
+void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char * name) {
+
+#ifdef DEADLINE_SCHEDULER
+    if (sched_runtime!=0) {
+        struct sched_attr attr= {0};
+        attr.size = sizeof(attr);
+        attr.sched_policy = SCHED_DEADLINE;
+        attr.sched_runtime  = sched_runtime;
+        attr.sched_deadline = sched_deadline;
+        attr.sched_period   = 0;
+        AssertFatal(sched_setattr(0, &attr, 0) == 0,
+                    "[SCHED] %s thread: sched_setattr failed %s \n", name, strerror(errno));
+        LOG_I(HW,"[SCHED][eNB] %s deadline thread %lu started on CPU %d\n",
+              name, (unsigned long)gettid(), sched_getcpu());
+    }
+
+#else
+    if (CPU_COUNT(cpuset) > 0)
+        AssertFatal( 0 == pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), cpuset), "");
+    struct sched_param sp;
+    sp.sched_priority = sched_fifo;
+    AssertFatal(pthread_setschedparam(pthread_self(),SCHED_FIFO,&sp)==0,
+                "Can't set thread priority, Are you root?\n");
+    /* Check the actual affinity mask assigned to the thread */
+    cpu_set_t *cset=CPU_ALLOC(CPU_SETSIZE);
+    if (0 == pthread_getaffinity_np(pthread_self(), CPU_ALLOC_SIZE(CPU_SETSIZE), cset)) {
+      char txt[512]={0};
+      for (int j = 0; j < CPU_SETSIZE; j++)
+        if (CPU_ISSET(j, cset))
+	  sprintf(txt+strlen(txt), " %d ", j);
+      printf("CPU Affinity of thread %s is %s\n", name, txt);
+    }
+    CPU_FREE(cset);
+#endif
+
+    // Lock memory from swapping. This is a process wide call (not constraint to this thread).
+    mlockall(MCL_CURRENT | MCL_FUTURE);
+    pthread_setname_np( pthread_self(), name );
+
+    // LTS: this sync stuff should be wrong
+    printf("waiting for sync (%s)\n",name);
+    pthread_mutex_lock(&sync_mutex);
+    printf("Locked sync_mutex, waiting (%s)\n",name);
+    while (sync_var<0)
+        pthread_cond_wait(&sync_cond, &sync_mutex);
+    pthread_mutex_unlock(&sync_mutex);
+    printf("started %s as PID: %ld\n",name, gettid());
+}
+
+void init_UE(int nb_inst)
+{
+  int inst;
+  for (inst=0; inst < nb_inst; inst++) {
+    //    UE->rfdevice.type      = NONE_DEV;
+    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);
+
+
+    AssertFatal(0 == pthread_create(&UE->proc.pthread_ue,
+                                    &UE->proc.attr_ue,
+                                    UE_thread,
+                                    (void*)UE), "");
+  }
+
+  printf("UE threads created by %ld\n", gettid());
+#if 0
+#if defined(ENABLE_USE_MME)
+  extern volatile int start_UE;
+  while (start_UE == 0) {
+    sleep(1);
+  }
+#endif
+#endif
+}
+
+/*!
+ * \brief This is the UE synchronize thread.
+ * It performs band scanning and synchonization.
+ * \param arg is a pointer to a \ref PHY_VARS_NR_UE structure.
+ * \returns a pointer to an int. The storage is not on the heap and must not be freed.
+ */
+static void *UE_thread_synch(void *arg) {
+    static int __thread UE_thread_synch_retval;
+    int i, hw_slot_offset;
+    PHY_VARS_NR_UE *UE = (PHY_VARS_NR_UE*) arg;
+    int current_band = 0;
+    int current_offset = 0;
+    sync_mode_t sync_mode = pbch;
+    int CC_id = UE->CC_id;
+    int freq_offset=0;
+    char threadname[128];
+
+    cpu_set_t cpuset;
+    CPU_ZERO(&cpuset);
+    if ( threads.iq != -1 )
+        CPU_SET(threads.iq, &cpuset);
+    // this thread priority must be lower that the main acquisition thread
+    sprintf(threadname, "sync UE %d\n", UE->Mod_id);
+    init_thread(100000, 500000, FIFO_PRIORITY-1, &cpuset, threadname);
+
+    UE->is_synchronized = 0;
+
+    if (UE->UE_scan == 0) {
+        int ind;
+        for ( ind=0;
+                ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]);
+                ind++) {
+            current_band = eutra_bands[ind].band;
+            LOG_D(PHY, "Scanning band %d, dl_min %"PRIu32", ul_min %"PRIu32"\n", current_band, eutra_bands[ind].dl_min,eutra_bands[ind].ul_min);
+            if ( eutra_bands[ind].dl_min <= downlink_frequency[0][0] && eutra_bands[ind].dl_max >= downlink_frequency[0][0] ) {
+                for (i=0; i<4; i++)
+                    uplink_frequency_offset[CC_id][i] = eutra_bands[ind].ul_min - eutra_bands[ind].dl_min;
+                break;
+            }
+        }
+        AssertFatal( ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]), "Can't find EUTRA band for frequency");
+
+        LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu32", UL %"PRIu32" (oai_exit %d, rx_num_channels %d)\n",
+               downlink_frequency[0][0], downlink_frequency[0][0]+uplink_frequency_offset[0][0],
+               oai_exit, openair0_cfg[0].rx_num_channels);
+
+        for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) {
+            openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i];
+            openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] =
+                downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i];
+            openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1;
+            if (uplink_frequency_offset[CC_id][i] != 0) //
+                openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_FDD;
+            else //FDD
+                openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_TDD;
+        }
+        sync_mode = pbch;
+
+    } else {
+        current_band=0;
+        for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) {
+            downlink_frequency[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[CC_id].dl_min;
+            uplink_frequency_offset[UE->rf_map.card][UE->rf_map.chain+i] =
+                bands_to_scan.band_info[CC_id].ul_min-bands_to_scan.band_info[CC_id].dl_min;
+            openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i];
+            openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] =
+                downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i];
+            openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;
+        }
+    }
+
+    //    AssertFatal(UE->rfdevice.trx_start_func(&UE->rfdevice) == 0, "Could not start the device\n");
+
+    while (oai_exit==0) {
+        AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
+        while (UE->proc.instance_cnt_synch < 0)
+            // the thread waits here most of the time
+            pthread_cond_wait( &UE->proc.cond_synch, &UE->proc.mutex_synch );
+        AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
+
+        switch (sync_mode) {
+        case pss:
+            LOG_I(PHY,"[SCHED][UE] Scanning band %d (%d), freq %u\n",bands_to_scan.band_info[current_band].band, current_band,bands_to_scan.band_info[current_band].dl_min+current_offset);
+            lte_sync_timefreq(UE,current_band,bands_to_scan.band_info[current_band].dl_min+current_offset);
+            current_offset += 20000000; // increase by 20 MHz
+
+            if (current_offset > bands_to_scan.band_info[current_band].dl_max-bands_to_scan.band_info[current_band].dl_min) {
+                current_band++;
+                current_offset=0;
+            }
+
+            if (current_band==bands_to_scan.nbands) {
+                current_band=0;
+                oai_exit=1;
+            }
+
+            for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) {
+                downlink_frequency[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[current_band].dl_min+current_offset;
+                uplink_frequency_offset[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[current_band].ul_min-bands_to_scan.band_info[0].dl_min + current_offset;
+
+                openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i];
+                openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i];
+                openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;
+                if (UE->UE_scan_carrier) {
+                    openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1;
+                }
+
+            }
+
+            break;
+
+        case pbch:
+
+#if DISABLE_LOG_X
+            printf("[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode);
+#else
+            LOG_I(PHY, "[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode);
+#endif
+            if (nr_initial_sync( UE, UE->mode ) == 0) {
+
+                hw_slot_offset = (UE->rx_offset<<1) / UE->frame_parms.samples_per_tti;
+                printf("Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %u, UL %u), UE_scan_carrier %d\n",
+                       hw_slot_offset,
+                       freq_offset,
+                       UE->rx_total_gain_dB,
+                       downlink_frequency[0][0]+freq_offset,
+                       downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset,
+                       UE->UE_scan_carrier );
+
+
+                    // rerun with new cell parameters and frequency-offset
+                    for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) {
+                        openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET;
+			if (UE->UE_scan_carrier == 1) {
+                        if (freq_offset >= 0)
+                            openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] += abs(UE->common_vars.freq_offset);
+                        else
+                            openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] -= abs(UE->common_vars.freq_offset);
+                        openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] =
+                            openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i]+uplink_frequency_offset[CC_id][i];
+                        downlink_frequency[CC_id][i] = openair0_cfg[CC_id].rx_freq[i];
+                        freq_offset=0;
+                    }
+	  }
+
+                    // reconfigure for potentially different bandwidth
+                    switch(UE->frame_parms.N_RB_DL) {
+                    case 6:
+                        openair0_cfg[UE->rf_map.card].sample_rate =1.92e6;
+                        openair0_cfg[UE->rf_map.card].rx_bw          =.96e6;
+                        openair0_cfg[UE->rf_map.card].tx_bw          =.96e6;
+                        //            openair0_cfg[0].rx_gain[0] -= 12;
+                        break;
+                    case 25:
+                        openair0_cfg[UE->rf_map.card].sample_rate =7.68e6;
+                        openair0_cfg[UE->rf_map.card].rx_bw          =2.5e6;
+                        openair0_cfg[UE->rf_map.card].tx_bw          =2.5e6;
+                        //            openair0_cfg[0].rx_gain[0] -= 6;
+                        break;
+                    case 50:
+                        openair0_cfg[UE->rf_map.card].sample_rate =15.36e6;
+                        openair0_cfg[UE->rf_map.card].rx_bw          =5.0e6;
+                        openair0_cfg[UE->rf_map.card].tx_bw          =5.0e6;
+                        //            openair0_cfg[0].rx_gain[0] -= 3;
+                        break;
+                    case 100:
+                        openair0_cfg[UE->rf_map.card].sample_rate=30.72e6;
+                        openair0_cfg[UE->rf_map.card].rx_bw=10.0e6;
+                        openair0_cfg[UE->rf_map.card].tx_bw=10.0e6;
+                        //            openair0_cfg[0].rx_gain[0] -= 0;
+                        break;
+                    }
+
+                    UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
+                    //UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]);
+                    //UE->rfdevice.trx_stop_func(&UE->rfdevice);
+                    // sleep(1);
+                    nr_init_frame_parms_ue(&UE->frame_parms);
+                    /*if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) {
+                        LOG_E(HW,"Could not start the device\n");
+                        oai_exit=1;
+                    }*/
+
+		if (UE->UE_scan_carrier == 1) {
+
+		  UE->UE_scan_carrier = 0;
+                } else {
+                    AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
+                    UE->is_synchronized = 1;
+                    AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
+
+                    if( UE->mode == rx_dump_frame ) {
+                        FILE *fd;
+                        if ((UE->proc.proc_rxtx[0].frame_rx&1) == 0) {  // this guarantees SIB1 is present
+                            if ((fd = fopen("rxsig_frame0.dat","w")) != NULL) {
+                                fwrite((void*)&UE->common_vars.rxdata[0][0],
+                                       sizeof(int32_t),
+                                       10*UE->frame_parms.samples_per_subframe,
+                                       fd);
+                                LOG_I(PHY,"Dummping Frame ... bye bye \n");
+                                fclose(fd);
+                                exit(0);
+                            } else {
+                                LOG_E(PHY,"Cannot open file for writing\n");
+                                exit(0);
+                            }
+                        } else {
+                            AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
+                            UE->is_synchronized = 0;
+                            AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
+
+                        }
+                    }
+                }
+            } else {
+                // initial sync failed
+                // calculate new offset and try again
+                if (UE->UE_scan_carrier == 1) {
+                    if (freq_offset >= 0)
+                        freq_offset += 100;
+                    freq_offset *= -1;
+
+                    if (abs(freq_offset) > 7500) {
+                        LOG_I( PHY, "[initial_sync] No cell synchronization found, abandoning\n" );
+                        FILE *fd;
+                        if ((fd = fopen("rxsig_frame0.dat","w"))!=NULL) {
+                            fwrite((void*)&UE->common_vars.rxdata[0][0],
+                                   sizeof(int32_t),
+                                   10*UE->frame_parms.samples_per_subframe,
+                                   fd);
+                            LOG_I(PHY,"Dummping Frame ... bye bye \n");
+                            fclose(fd);
+                            exit(0);
+                        }
+                        //mac_xface->macphy_exit("No cell synchronization found, abandoning"); new mac
+                        return &UE_thread_synch_retval; // not reached
+                    }
+                }
+#if DISABLE_LOG_X
+                printf("[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n",
+                       freq_offset,
+                       UE->rx_total_gain_dB,
+                       downlink_frequency[0][0]+freq_offset,
+                       downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset );
+#else
+                LOG_I(PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n",
+                       freq_offset,
+                       UE->rx_total_gain_dB,
+                       downlink_frequency[0][0]+freq_offset,
+                       downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset );
+#endif
+
+                for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) {
+                    openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+freq_offset;
+                    openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i]+freq_offset;
+                    openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET;
+                    if (UE->UE_scan_carrier==1)
+                        openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1;
+                }
+                UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
+            }// initial_sync=0
+            break;
+        case si:
+        default:
+            break;
+        }
+
+        AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
+        // indicate readiness
+        UE->proc.instance_cnt_synch--;
+        AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
+
+        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_THREAD_SYNCH, 0 );
+    }  // while !oai_exit
+
+    return &UE_thread_synch_retval;
+}
+
+/*!
+ * \brief This is the UE thread for RX subframe n and TX subframe n+4.
+ * This thread performs the phy_procedures_UE_RX() on every received slot.
+ * then, if TX is enabled it performs TX for n+4.
+ * \param arg is a pointer to a \ref PHY_VARS_NR_UE structure.
+ * \returns a pointer to an int. The storage is not on the heap and must not be freed.
+ */
+
+static void *UE_thread_rxn_txnp4(void *arg) {
+    static __thread int UE_thread_rxtx_retval;
+    struct nr_rxtx_thread_data *rtd = arg;
+    UE_nr_rxtx_proc_t *proc = rtd->proc;
+    PHY_VARS_NR_UE    *UE   = rtd->UE;
+    int ret;
+
+    //proc->counter_decoder = 0;
+    proc->instance_cnt_rxtx=-1;
+    proc->subframe_rx=proc->sub_frame_start;
+
+	proc->dci_err_cnt=0;
+    char threadname[256];
+    sprintf(threadname,"UE_%d_proc_%d", UE->Mod_id, proc->sub_frame_start);
+    cpu_set_t cpuset;
+    CPU_ZERO(&cpuset);
+    char timing_proc_name[256];
+    sprintf(timing_proc_name,"Delay to process sub-frame proc %d",proc->sub_frame_start);
+
+    if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.one != -1 )
+        CPU_SET(threads.one, &cpuset);
+    if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.two != -1 )
+        CPU_SET(threads.two, &cpuset);
+    if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.three != -1 )
+        CPU_SET(threads.three, &cpuset);
+            //CPU_SET(threads.three, &cpuset);
+    init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset,
+                threadname);
+
+    while (!oai_exit) {
+        if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) {
+          LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" );
+          exit_fun("nothing to add");
+        }
+        while (proc->instance_cnt_rxtx < 0) {
+          // most of the time, the thread is waiting here
+          pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx );
+        }
+        if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) {
+          LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXn_TXnp4\n" );
+          exit_fun("nothing to add");
+        }
+
+//        initRefTimes(t2);
+        initRefTimes(t3);
+        pickTime(current);
+//        updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)");
+
+#ifndef NO_RAT_NR
+        // Process Rx data for one sub-frame
+        nr_slot_t nr_slot ; //= slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx);
+
+        if (nr_slot == NR_TDD_DOWNLINK_SLOT) {
+#else
+        // Process Rx data for one sub-frame
+        lte_subframe_t sf_type = subframe_select( &UE->frame_parms, proc->subframe_rx);
+        if ((sf_type == SF_DL) ||
+                (UE->frame_parms.frame_type == FDD) ||
+                (sf_type == SF_S)) {
+
+            if (UE->frame_parms.frame_type == TDD) {
+                LOG_D(PHY, "%s,TDD%d,%s: calling UE_RX\n",
+                      threadname,
+                      UE->frame_parms.tdd_config,
+                      (sf_type==SF_DL? "SF_DL" :
+                       (sf_type==SF_UL? "SF_UL" :
+                        (sf_type==SF_S ? "SF_S"  : "UNKNOWN_SF_TYPE"))));
+            } else {
+                LOG_D(PHY, "%s,%s,%s: calling UE_RX\n",
+                      threadname,
+                      (UE->frame_parms.frame_type==FDD? "FDD":
+                       (UE->frame_parms.frame_type==TDD? "TDD":"UNKNOWN_DUPLEX_MODE")),
+                      (sf_type==SF_DL? "SF_DL" :
+                       (sf_type==SF_UL? "SF_UL" :
+                        (sf_type==SF_S ? "SF_S"  : "UNKNOWN_SF_TYPE"))));
+            }
+#endif
+#ifdef UE_SLOT_PARALLELISATION
+            phy_procedures_slot_parallelization_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL );
+#else
+            phy_procedures_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL );
+#endif
+        }
+
+#if UE_TIMING_TRACE
+        start_meas(&UE->generic_stat);
+#endif
+        if (UE->mac_enabled==1) {
+
+#ifdef NEW_MAC
+          ret = mac_xface->ue_scheduler(UE->Mod_id,
+                                          proc->frame_rx,
+                                          proc->subframe_rx,
+                                          proc->nr_tti_rx,
+                                          proc->frame_tx,
+                                          proc->subframe_tx,
+                                          proc->nr_tti_tx%(UE->frame_parms.ttis_per_subframe),
+#ifndef NO_RAT_NR
+                                          slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx),
+#else
+                                          subframe_select(&UE->frame_parms,proc->subframe_tx),
+#endif
+                                          0,
+                                          0/*FIXME CC_id*/);
+#endif
+
+/*#else
+            ret = mac_xface->ue_scheduler(UE->Mod_id,
+                                          proc->frame_rx,
+                                          proc->subframe_rx,
+                                          proc->frame_tx,
+                                          proc->subframe_tx,
+                                          subframe_select(&UE->frame_parms,proc->subframe_tx),
+                                          0,  */
+//                                          0/*FIXME CC_id*/);
+//#endif
+            if ( ret != CONNECTION_OK) {
+                char *txt;
+                switch (ret) {
+                case CONNECTION_LOST:
+                    txt="RRC Connection lost, returning to PRACH";
+                    break;
+                case PHY_RESYNCH:
+                    txt="RRC Connection lost, trying to resynch";
+                    break;
+                case RESYNCH:
+                    txt="return to PRACH and perform a contention-free access";
+                    break;
+                default:
+                    txt="UNKNOWN RETURN CODE";
+                };
+                LOG_E( PHY, "[UE %"PRIu8"] Frame %"PRIu32", subframe %u %s\n",
+                       UE->Mod_id, proc->frame_rx, proc->subframe_tx,txt );
+            }
+        }
+#if UE_TIMING_TRACE
+        stop_meas(&UE->generic_stat);
+#endif
+
+        // Prepare the future Tx data
+#if 1
+        if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
+                (UE->frame_parms.frame_type == FDD) )
+            if (UE->mode != loop_through_memory)
+                phy_procedures_UE_TX(UE,proc,0,0,UE->mode,no_relay);
+#endif
+
+        if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) &&
+                (UE->frame_parms.frame_type == TDD))
+            if (UE->mode != loop_through_memory)
+                phy_procedures_UE_S_TX(UE,0,0,no_relay);
+        updateTimes(current, &t3, 10000, timing_proc_name);
+
+        if (pthread_mutex_lock(&proc->mutex_rxtx) != 0) {
+          LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" );
+          exit_fun("noting to add");
+        }
+        proc->instance_cnt_rxtx--;
+        if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) {
+          LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXTX\n" );
+          exit_fun("noting to add");
+        }
+    }
+
+// thread finished
+    free(arg);
+    return &UE_thread_rxtx_retval;
+}
+
+/*!
+ * \brief This is the main UE thread.
+ * This thread controls the other three UE threads:
+ * - UE_thread_rxn_txnp4 (even subframes)
+ * - UE_thread_rxn_txnp4 (odd subframes)
+ * - UE_thread_synch
+ * \param arg unused
+ * \returns a pointer to an int. The storage is not on the heap and must not be freed.
+ */
+
+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;
+    void* rxp[NB_ANTENNAS_RX], *txp[NB_ANTENNAS_TX];
+    int start_rx_stream = 0;
+    int i;
+    char threadname[128];
+    int th_id;
+    UE->proc.proc_rxtx[0].counter_decoder = 0;
+    UE->proc.proc_rxtx[1].counter_decoder = 0;
+    UE->proc.proc_rxtx[2].counter_decoder = 0;
+
+    static uint8_t thread_idx = 0;
+
+    cpu_set_t cpuset;
+    CPU_ZERO(&cpuset);
+    if ( threads.iq != -1 )
+        CPU_SET(threads.iq, &cpuset);
+    init_thread(100000, 500000, FIFO_PRIORITY, &cpuset,
+                "UHD Threads");
+    if (oaisim_flag == 0)
+        AssertFatal(0== openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]), "");
+    UE->rfdevice.host_type = RAU_HOST;
+    sprintf(threadname, "Main UE %d", UE->Mod_id);
+    pthread_setname_np(pthread_self(), threadname);
+    init_UE_threads(UE);
+
+#ifdef NAS_UE
+    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
+
+    int tti_nr=-1;
+    //int cumulated_shift=0;
+    AssertFatal(UE->rfdevice.trx_start_func(&UE->rfdevice) == 0, "Could not start the device\n");
+    while (!oai_exit) {
+        AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
+        int instance_cnt_synch = UE->proc.instance_cnt_synch;
+        int is_synchronized    = UE->is_synchronized;
+        AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
+
+        if (is_synchronized == 0) {
+            if (instance_cnt_synch < 0) {  // we can invoke the synch
+                // grab 10 ms of signal and wakeup synch thread
+                for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
+                    rxp[i] = (void*)&UE->common_vars.rxdata[i][0];
+
+                if (UE->mode != loop_through_memory)
+                    AssertFatal( UE->frame_parms.samples_per_subframe*10 ==
+                                 UE->rfdevice.trx_read_func(&UE->rfdevice,
+                                                            &timestamp,
+                                                            rxp,
+                                                            UE->frame_parms.samples_per_subframe*10,
+                                                            UE->frame_parms.nb_antennas_rx), "");
+		AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
+                instance_cnt_synch = ++UE->proc.instance_cnt_synch;
+                if (instance_cnt_synch == 0) {
+                    AssertFatal( 0 == pthread_cond_signal(&UE->proc.cond_synch), "");
+                } else {
+                    LOG_E( PHY, "[SCHED][UE] UE sync thread busy!!\n" );
+                    exit_fun("nothing to add");
+                }
+		AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
+            } else {
+#if OAISIM
+              (void)dummy_rx; /* avoid gcc warnings */
+              usleep(500);
+#else
+                // grab 10 ms of signal into dummy buffer
+                if (UE->mode != loop_through_memory) {
+                    for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
+                        rxp[i] = (void*)&dummy_rx[i][0];
+                    for (int sf=0; sf<10; sf++)
+                        //	    printf("Reading dummy sf %d\n",sf);
+                          UE->rfdevice.trx_read_func(&UE->rfdevice,
+                                              &timestamp,
+                                              rxp,
+                                              UE->frame_parms.samples_per_subframe,
+                                              UE->frame_parms.nb_antennas_rx);
+                }
+#endif
+            }
+
+        } // UE->is_synchronized==0
+        else {
+            if (start_rx_stream==0) {
+                start_rx_stream=1;
+                if (UE->mode != loop_through_memory) {
+                    if (UE->no_timing_correction==0) {
+                        LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode);
+                        AssertFatal(UE->rx_offset ==
+                                    UE->rfdevice.trx_read_func(&UE->rfdevice,
+                                                               &timestamp,
+                                                               (void**)UE->common_vars.rxdata,
+                                                               UE->rx_offset,
+                                                               UE->frame_parms.nb_antennas_rx),"");
+                    }
+                    UE->rx_offset=0;
+                    UE->time_sync_cell=0;
+                    //UE->proc.proc_rxtx[0].frame_rx++;
+                    //UE->proc.proc_rxtx[1].frame_rx++;
+                    for (th_id=0; th_id < RX_NB_TH; th_id++) {
+                        UE->proc.proc_rxtx[th_id].frame_rx++;
+                    }
+
+                    // read in first symbol
+                    AssertFatal (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0 ==
+                                 UE->rfdevice.trx_read_func(&UE->rfdevice,
+                                                            &timestamp,
+                                                            (void**)UE->common_vars.rxdata,
+                                                            UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0,
+                                                            UE->frame_parms.nb_antennas_rx),"");
+                    slot_fep_pbch(UE,0, 0, 0, 0, 0);
+                } //UE->mode != loop_through_memory
+                else
+                    rt_sleep_ns(1000*1000);
+
+            } else {
+                tti_nr++;
+                tti_nr%=10*UE->frame_parms.ttis_per_subframe;
+                UE_nr_rxtx_proc_t *proc = &UE->proc.proc_rxtx[thread_idx];
+                // update thread index for received subframe
+                UE->current_thread_id[tti_nr] = thread_idx;
+
+                LOG_D(PHY,"Process TTI %d thread Idx %d \n", tti_nr, UE->current_thread_id[tti_nr]);
+
+                thread_idx++;
+                if(thread_idx>=RX_NB_TH)
+                    thread_idx = 0;
+
+
+                if (UE->mode != loop_through_memory) {
+                    for (i=0; i<UE->frame_parms.nb_antennas_rx; i++)
+                        rxp[i] = (void*)&UE->common_vars.rxdata[i][UE->frame_parms.ofdm_symbol_size+
+                                 UE->frame_parms.nb_prefix_samples0+
+                                 tti_nr*UE->frame_parms.samples_per_tti];
+                    for (i=0; i<UE->frame_parms.nb_antennas_tx; i++)
+                        txp[i] = (void*)&UE->common_vars.txdata[i][((tti_nr+2)%10*UE->frame_parms.ttis_per_subframe)*UE->frame_parms.samples_per_tti];
+
+                    int readBlockSize, writeBlockSize;
+                    if (tti_nr<(10*UE->frame_parms.ttis_per_subframe-1)) {
+                        readBlockSize=UE->frame_parms.samples_per_tti;
+                        writeBlockSize=UE->frame_parms.samples_per_tti;
+                    } else {
+                        // set TO compensation to zero
+                        UE->rx_offset_diff = 0;
+                        // compute TO compensation that should be applied for this frame
+                        if ( UE->rx_offset < 5*UE->frame_parms.samples_per_subframe  &&
+                                UE->rx_offset > 0 )
+                            UE->rx_offset_diff = -1 ;
+                        if ( UE->rx_offset > 5*UE->frame_parms.samples_per_subframe &&
+                                UE->rx_offset < 10*UE->frame_parms.samples_per_tti )
+                            UE->rx_offset_diff = 1;
+
+                        LOG_D(PHY,"AbsSubframe %d.%d TTI SET rx_off_diff to %d rx_offset %d \n",proc->frame_rx,tti_nr,UE->rx_offset_diff,UE->rx_offset);
+                        readBlockSize=UE->frame_parms.samples_per_tti -
+                                      UE->frame_parms.ofdm_symbol_size -
+                                      UE->frame_parms.nb_prefix_samples0 -
+                                      UE->rx_offset_diff;
+                        writeBlockSize=UE->frame_parms.samples_per_tti -
+                                       UE->rx_offset_diff;
+                    }
+
+                    AssertFatal(readBlockSize ==
+                                UE->rfdevice.trx_read_func(&UE->rfdevice,
+                                                           &timestamp,
+                                                           rxp,
+                                                           readBlockSize,
+                                                           UE->frame_parms.nb_antennas_rx),"");
+                    AssertFatal( writeBlockSize ==
+                                 UE->rfdevice.trx_write_func(&UE->rfdevice,
+                                         timestamp+
+                                         (2*UE->frame_parms.samples_per_tti) -
+                                         UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 -
+                                         openair0_cfg[0].tx_sample_advance,
+                                         txp,
+                                         writeBlockSize,
+                                         UE->frame_parms.nb_antennas_tx,
+                                         1),"");
+                    if( tti_nr==(10*UE->frame_parms.ttis_per_subframe-1)) {
+                        // read in first symbol of next frame and adjust for timing drift
+                        int first_symbols=writeBlockSize-readBlockSize;
+                        if ( first_symbols > 0 )
+                            AssertFatal(first_symbols ==
+                                        UE->rfdevice.trx_read_func(&UE->rfdevice,
+                                                                   &timestamp1,
+                                                                   (void**)UE->common_vars.rxdata,
+                                                                   first_symbols,
+                                                                   UE->frame_parms.nb_antennas_rx),"");
+                        if ( first_symbols <0 )
+                            LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols);
+                    }
+                    pickTime(gotIQs);
+                    // operate on thread sf mod 2
+                    AssertFatal(pthread_mutex_lock(&proc->mutex_rxtx) ==0,"");
+                    if(tti_nr == 0) {
+                        //UE->proc.proc_rxtx[0].frame_rx++;
+                        //UE->proc.proc_rxtx[1].frame_rx++;
+                        for (th_id=0; th_id < RX_NB_TH; th_id++) {
+                            UE->proc.proc_rxtx[th_id].frame_rx++;
+                        }
+#ifdef SAIF_ENABLED
+						if (!(proc->frame_rx%4000))
+						{
+							printf("frame_rx=%d rx_thread_busy=%ld - rate %8.3f\n",
+								proc->frame_rx, g_ue_rx_thread_busy,
+								(float)g_ue_rx_thread_busy/(proc->frame_rx*10+1)*100.0);
+							fflush(stdout);
+						}
+#endif
+                    }
+                    //UE->proc.proc_rxtx[0].gotIQs=readTime(gotIQs);
+                    //UE->proc.proc_rxtx[1].gotIQs=readTime(gotIQs);
+                    for (th_id=0; th_id < RX_NB_TH; th_id++) {
+                        UE->proc.proc_rxtx[th_id].gotIQs=readTime(gotIQs);
+                    }
+                    proc->nr_tti_rx=tti_nr;
+                    proc->nr_tti_tx=(tti_nr+4)%(10*UE->frame_parms.ttis_per_subframe);
+                    proc->subframe_rx=tti_nr>>((uint8_t)(log2 (UE->frame_parms.ttis_per_subframe)));
+                    proc->frame_tx = proc->frame_rx + (proc->subframe_rx>5?1:0);
+                    proc->subframe_tx=(proc->nr_tti_tx)>>((uint8_t)(log2 (UE->frame_parms.ttis_per_subframe)));
+                    proc->timestamp_tx = timestamp+
+                                         (4*UE->frame_parms.samples_per_tti)-
+                                         UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0;
+
+                    proc->instance_cnt_rxtx++;
+                    LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx);
+                    if (proc->instance_cnt_rxtx == 0) {
+                      if (pthread_cond_signal(&proc->cond_rxtx) != 0) {
+                        LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id);
+                        exit_fun("nothing to add");
+                      }
+                    } else {
+#ifdef SAIF_ENABLED
+						g_ue_rx_thread_busy++;
+#endif
+                      LOG_E( PHY, "[SCHED][UE %d] !! UE RX thread busy (IC %d)!!\n", UE->Mod_id, proc->instance_cnt_rxtx);
+                      if (proc->instance_cnt_rxtx > 4)
+                      {
+                        char exit_fun_string[256];
+                        sprintf(exit_fun_string,"[SCHED][UE %d] !!! UE instance_cnt_rxtx > 2 (IC %d) (Proc %d)!!",
+                        			UE->Mod_id, proc->instance_cnt_rxtx,
+                        			UE->current_thread_id[tti_nr]);
+          				printf("%s\n",exit_fun_string);
+          				fflush(stdout);
+          				sleep(1);
+                        exit_fun(exit_fun_string);
+                      }
+                    }
+
+                    AssertFatal (pthread_cond_signal(&proc->cond_rxtx) ==0 ,"");
+                    AssertFatal(pthread_mutex_unlock(&proc->mutex_rxtx) ==0,"");
+//                    initRefTimes(t1);
+//                    initStaticTime(lastTime);
+//                    updateTimes(lastTime, &t1, 20000, "Delay between two IQ acquisitions (case 1)");
+//                    pickStaticTime(lastTime);
+
+                } else {
+                    printf("Processing subframe %d",proc->subframe_rx);
+                    getchar();
+                }
+            } // start_rx_stream==1
+        } // UE->is_synchronized==1
+
+    } // while !oai_exit
+    return NULL;
+}
+
+/*!
+ * \brief Initialize the UE theads.
+ * Creates the UE threads:
+ * - UE_thread_rxtx0
+ * - UE_thread_rxtx1
+ * - UE_thread_synch
+ * - UE_thread_fep_slot0
+ * - UE_thread_fep_slot1
+ * - UE_thread_dlsch_proc_slot0
+ * - UE_thread_dlsch_proc_slot1
+ * and the locking between them.
+ */
+void init_UE_threads(PHY_VARS_NR_UE *UE) {
+    struct nr_rxtx_thread_data *rtd;
+
+    pthread_attr_init (&UE->proc.attr_ue);
+    pthread_attr_setstacksize(&UE->proc.attr_ue,8192);//5*PTHREAD_STACK_MIN);
+
+    pthread_mutex_init(&UE->proc.mutex_synch,NULL);
+    pthread_cond_init(&UE->proc.cond_synch,NULL);
+
+    // the threads are not yet active, therefore access is allowed without locking
+    int nb_threads=RX_NB_TH;
+    for (int i=0; i<nb_threads; i++) {
+        rtd = calloc(1, sizeof(struct nr_rxtx_thread_data));
+        if (rtd == NULL) abort();
+        rtd->UE = UE;
+        rtd->proc = &UE->proc.proc_rxtx[i];
+
+        pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_rxtx,NULL);
+        pthread_cond_init(&UE->proc.proc_rxtx[i].cond_rxtx,NULL);
+        UE->proc.proc_rxtx[i].sub_frame_start=i;
+        UE->proc.proc_rxtx[i].sub_frame_step=nb_threads;
+        printf("Init_UE_threads rtd %d proc %d nb_threads %d i %d\n",rtd->proc->sub_frame_start, UE->proc.proc_rxtx[i].sub_frame_start,nb_threads, i);
+        pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, UE_thread_rxn_txnp4, rtd);
+
+#ifdef UE_DLSCH_PARALLELISATION
+        pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_dlsch_td,NULL);
+        pthread_cond_init(&UE->proc.proc_rxtx[i].cond_dlsch_td,NULL);
+        pthread_create(&UE->proc.proc_rxtx[i].pthread_dlsch_td,NULL,dlsch_decoding_2thread0, rtd);
+        //thread 2
+        pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_dlsch_td1,NULL);
+        pthread_cond_init(&UE->proc.proc_rxtx[i].cond_dlsch_td1,NULL);
+        pthread_create(&UE->proc.proc_rxtx[i].pthread_dlsch_td1,NULL,dlsch_decoding_2thread1, rtd);
+#endif
+
+#ifdef UE_SLOT_PARALLELISATION
+        //pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot0_dl_processing,NULL);
+        //pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot0_dl_processing,NULL);
+        //pthread_create(&UE->proc.proc_rxtx[i].pthread_slot0_dl_processing,NULL,UE_thread_slot0_dl_processing, rtd);
+
+        pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_slot1_dl_processing,NULL);
+        pthread_cond_init(&UE->proc.proc_rxtx[i].cond_slot1_dl_processing,NULL);
+        pthread_create(&UE->proc.proc_rxtx[i].pthread_slot1_dl_processing,NULL,UE_thread_slot1_dl_processing, rtd);
+#endif
+
+    }
+    pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE);
+}
+
+
+#ifdef OPENAIR2
+void fill_ue_band_info(void) {
+
+    UE_EUTRA_Capability_t *UE_EUTRA_Capability = UE_rrc_inst[0].UECap->UE_EUTRA_Capability;
+    int i,j;
+
+    bands_to_scan.nbands = UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count;
+
+    for (i=0; i<bands_to_scan.nbands; i++) {
+
+        for (j=0; j<sizeof (eutra_bands) / sizeof (eutra_bands[0]); j++)
+            if (eutra_bands[j].band == UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->bandEUTRA) {
+                memcpy(&bands_to_scan.band_info[i],
+                       &eutra_bands[j],
+                       sizeof(eutra_band_t));
+
+                printf("Band %d (%lu) : DL %u..%u Hz, UL %u..%u Hz, Duplex %s \n",
+                       bands_to_scan.band_info[i].band,
+                       UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.array[i]->bandEUTRA,
+                       bands_to_scan.band_info[i].dl_min,
+                       bands_to_scan.band_info[i].dl_max,
+                       bands_to_scan.band_info[i].ul_min,
+                       bands_to_scan.band_info[i].ul_max,
+                       (bands_to_scan.band_info[i].frame_type==FDD) ? "FDD" : "TDD");
+                break;
+            }
+    }
+}
+#endif
+
+int setup_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg) {
+
+    int i, CC_id;
+    LTE_DL_FRAME_PARMS *frame_parms;
+    openair0_rf_map *rf_map;
+
+    for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+        rf_map = &phy_vars_ue[CC_id]->rf_map;
+
+        AssertFatal( phy_vars_ue[CC_id] !=0, "");
+        frame_parms = &(phy_vars_ue[CC_id]->frame_parms);
+
+        // replace RX signal buffers with mmaped HW versions
+        rxdata = (int32_t**)malloc16( frame_parms->nb_antennas_rx*sizeof(int32_t*) );
+        txdata = (int32_t**)malloc16( frame_parms->nb_antennas_tx*sizeof(int32_t*) );
+
+        for (i=0; i<frame_parms->nb_antennas_rx; i++) {
+            LOG_I(PHY, "Mapping UE CC_id %d, rx_ant %d, freq %u on card %d, chain %d\n",
+                  CC_id, i, downlink_frequency[CC_id][i], rf_map->card, rf_map->chain+i );
+            free( phy_vars_ue[CC_id]->common_vars.rxdata[i] );
+            rxdata[i] = (int32_t*)malloc16_clear( 307200*sizeof(int32_t) );
+            phy_vars_ue[CC_id]->common_vars.rxdata[i] = rxdata[i]; // what about the "-N_TA_offset" ? // N_TA offset for TDD
+        }
+
+        for (i=0; i<frame_parms->nb_antennas_tx; i++) {
+            LOG_I(PHY, "Mapping UE CC_id %d, tx_ant %d, freq %u on card %d, chain %d\n",
+                  CC_id, i, downlink_frequency[CC_id][i], rf_map->card, rf_map->chain+i );
+            free( phy_vars_ue[CC_id]->common_vars.txdata[i] );
+            txdata[i] = (int32_t*)malloc16_clear( 307200*sizeof(int32_t) );
+            phy_vars_ue[CC_id]->common_vars.txdata[i] = txdata[i];
+        }
+
+        // rxdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.rxdata[x]
+        // txdata[x] points now to the same memory region as phy_vars_ue[CC_id]->common_vars.txdata[x]
+        // be careful when releasing memory!
+        // because no "release_ue_buffers"-function is available, at least rxdata and txdata memory will leak (only some bytes)
+    }
+    return 0;
+}
+
diff --git a/targets/RT/USER/nr-uesoftmodem.c b/targets/RT/USER/nr-uesoftmodem.c
new file mode 100644
index 0000000000000000000000000000000000000000..c34c10044fabcf7534d7f964478c53fbdea75237
--- /dev/null
+++ b/targets/RT/USER/nr-uesoftmodem.c
@@ -0,0 +1,1327 @@
+/*
+ * 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
+ */
+
+
+#define _GNU_SOURCE             /* See feature_test_macros(7) */
+#include <sched.h>
+
+#include "T.h"
+#include "rt_wrapper.h"
+
+#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
+
+#include "assertions.h"
+#include "msc.h"
+
+#include "PHY/types.h"
+#include "PHY/defs_nr_UE.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
+//#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all
+
+#include "../../ARCH/COMMON/common_lib.h"
+#include "../../ARCH/ETHERNET/USERSPACE/LIB/if_defs.h"
+
+//#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_vars_nr_ue.h"
+#include "PHY/LTE_TRANSPORT/transport_vars.h"
+#include "SCHED/sched_common_vars.h"
+#include "PHY/MODULATION/modulation_vars.h"
+//#include "../../SIMU/USER/init_lte.h"
+
+#include "LAYER2/MAC/mac.h"
+#include "LAYER2/MAC/mac_vars.h"
+#include "LAYER2/MAC/mac_proto.h"
+#include "RRC/LTE/rrc_vars.h"
+#include "PHY_INTERFACE/phy_interface_vars.h"
+
+#ifdef SMBV
+#include "PHY/TOOLS/smbv.h"
+unsigned short config_frames[4] = {2,9,11,13};
+#endif
+#include "UTIL/LOG/log_extern.h"
+#include "UTIL/OTG/otg_tx.h"
+#include "UTIL/OTG/otg_externs.h"
+#include "UTIL/MATH/oml.h"
+#include "UTIL/LOG/vcd_signal_dumper.h"
+#include "UTIL/OPT/opt.h"
+#include "enb_config.h"
+//#include "PHY/TOOLS/time_meas.h"
+
+#ifndef OPENAIR2
+#include "UTIL/OTG/otg_vars.h"
+#endif
+
+#if defined(ENABLE_ITTI)
+#include "intertask_interface_init.h"
+#include "create_tasks.h"
+#endif
+
+#include "PHY/INIT/phy_init.h"
+#include "system.h"
+#include "stats.h"
+#ifdef XFORMS
+#include "PHY/TOOLS/lte_phy_scope.h"
+//#include "stats.h"
+// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0)
+// at eNB 0, an UL scope for every UE
+FD_lte_phy_scope_ue  *form_ue[NUMBER_OF_UE_MAX];
+FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
+FD_stats_form                  *form_stats=NULL,*form_stats_l2=NULL;
+char title[255];
+unsigned char                   scope_enb_num_ue = 2;
+static pthread_t                forms_thread; //xforms
+#endif //XFORMS
+#include "nr-uesoftmodem.h"
+
+RAN_CONTEXT_t RC;
+
+pthread_cond_t sync_cond;
+pthread_mutex_t sync_mutex;
+int sync_var=-1; //!< protected by mutex \ref sync_mutex.
+
+uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
+uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
+
+#if defined(ENABLE_ITTI)
+volatile int             start_eNB = 0;
+volatile int             start_UE = 0;
+#endif
+volatile int             oai_exit = 0;
+
+static clock_source_t clock_source = internal;
+static int wait_for_sync = 0;
+
+static char              UE_flag=0;
+unsigned int                    mmapped_dma=0;
+int                             single_thread_flag=1;
+
+static char                     threequarter_fs=0;
+
+uint32_t                 downlink_frequency[MAX_NUM_CCs][4];
+int32_t                  uplink_frequency_offset[MAX_NUM_CCs][4];
+
+
+static char                    *conf_config_file_name = NULL;
+#if defined(ENABLE_ITTI)
+static char                    *itti_dump_file = NULL;
+#endif
+
+int UE_scan = 1;
+int UE_scan_carrier = 0;
+runmode_t mode = normal_txrx;
+
+FILE *input_fd=NULL;
+
+
+#if MAX_NUM_CCs == 1
+rx_gain_t                rx_gain_mode[MAX_NUM_CCs][4] = {{max_gain,max_gain,max_gain,max_gain}};
+double tx_gain[MAX_NUM_CCs][4] = {{20,0,0,0}};
+double rx_gain[MAX_NUM_CCs][4] = {{110,0,0,0}};
+#else
+rx_gain_t                rx_gain_mode[MAX_NUM_CCs][4] = {{max_gain,max_gain,max_gain,max_gain},{max_gain,max_gain,max_gain,max_gain}};
+double tx_gain[MAX_NUM_CCs][4] = {{20,0,0,0},{20,0,0,0}};
+double rx_gain[MAX_NUM_CCs][4] = {{110,0,0,0},{20,0,0,0}};
+#endif
+
+double rx_gain_off = 0.0;
+
+double sample_rate=30.72e6;
+double bw = 10.0e6;
+
+static int                      tx_max_power[MAX_NUM_CCs]; /* =  {0,0}*/;
+
+char   rf_config_file[1024];
+
+int chain_offset=0;
+int phy_test = 0;
+uint8_t usim_test = 0;
+
+uint8_t dci_Format = 0;
+uint8_t agregation_Level =0xFF;
+
+uint8_t nb_antenna_tx = 1;
+uint8_t nb_antenna_rx = 1;
+
+char ref[128] = "internal";
+char channels[128] = "0";
+
+int codingw = 0;
+int fepw = 0;
+
+int                      		rx_input_level_dBm;
+static int                      online_log_messages=0;
+#ifdef XFORMS
+extern int                      otg_enabled;
+static char                     do_forms=0;
+#else
+int                             otg_enabled;
+#endif
+//int                             number_of_cards =   1;
+
+static NR_DL_FRAME_PARMS      *frame_parms[MAX_NUM_CCs];
+static nfapi_config_request_t *config[MAX_NUM_CCs];
+int16_t   node_synch_ref[MAX_NUM_CCs];
+
+uint32_t target_dl_mcs = 28; //maximum allowed mcs
+uint32_t target_ul_mcs = 20;
+uint32_t timing_advance = 0;
+uint8_t exit_missed_slots=1;
+uint64_t num_missed_slots=0; // counter for the number of missed slots
+
+extern PHY_VARS_NR_UE* init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms,
+			  uint8_t UE_id,
+			  uint8_t abstraction_flag);
+
+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;
+int16_t           hw_log_verbosity   = LOG_MED;
+int16_t           phy_log_level      = LOG_INFO;
+int16_t           phy_log_verbosity  = LOG_MED;
+int16_t           mac_log_level      = LOG_INFO;
+int16_t           mac_log_verbosity  = LOG_MED;
+int16_t           rlc_log_level      = LOG_INFO;
+int16_t           rlc_log_verbosity  = LOG_MED;
+int16_t           pdcp_log_level     = LOG_INFO;
+int16_t           pdcp_log_verbosity = LOG_MED;
+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;
+int16_t           gtpu_log_verbosity = LOG_MED;
+int16_t           udp_log_level      = LOG_DEBUG;
+int16_t           udp_log_verbosity  = LOG_MED;
+#endif
+#if defined (ENABLE_SECURITY)
+int16_t           osa_log_level      = LOG_INFO;
+int16_t           osa_log_verbosity  = LOG_MED;
+#endif
+
+char *rrh_UE_ip = "127.0.0.1";
+int rrh_UE_port = 51000;
+
+/* flag set by eNB conf file to specify if the radio head is local or remote (default option is local) */
+//uint8_t local_remote_radio = BBU_LOCAL_RADIO_HEAD;
+/* struct for ethernet specific parameters given in eNB conf file */
+//eth_params_t *eth_params;
+
+openair0_config_t openair0_cfg[MAX_CARDS];
+
+double cpuf;
+
+char uecap_xer[1024],uecap_xer_in=0;
+
+int oaisim_flag=0;
+int emulate_rf = 0;
+
+threads_t threads= {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
+
+/* forward declarations */
+void set_default_frame_parms(nfapi_config_request_t *config[MAX_NUM_CCs], NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]);
+
+
+/* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed
+ * this is very hackish - find a proper solution
+ */
+uint8_t abstraction_flag=0;
+
+/*---------------------BMC: timespec helpers -----------------------------*/
+
+struct timespec min_diff_time = { .tv_sec = 0, .tv_nsec = 0 };
+struct timespec max_diff_time = { .tv_sec = 0, .tv_nsec = 0 };
+
+struct timespec clock_difftime(struct timespec start, struct timespec end) {
+    struct timespec temp;
+    if ((end.tv_nsec-start.tv_nsec)<0) {
+        temp.tv_sec = end.tv_sec-start.tv_sec-1;
+        temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec;
+    } else {
+        temp.tv_sec = end.tv_sec-start.tv_sec;
+        temp.tv_nsec = end.tv_nsec-start.tv_nsec;
+    }
+    return temp;
+}
+
+void print_difftimes(void) {
+#ifdef DEBUG
+    printf("difftimes min = %lu ns ; max = %lu ns\n", min_diff_time.tv_nsec, max_diff_time.tv_nsec);
+#else
+    LOG_I(HW,"difftimes min = %lu ns ; max = %lu ns\n", min_diff_time.tv_nsec, max_diff_time.tv_nsec);
+#endif
+}
+
+void update_difftimes(struct timespec start, struct timespec end) {
+    struct timespec diff_time = { .tv_sec = 0, .tv_nsec = 0 };
+    int             changed = 0;
+    diff_time = clock_difftime(start, end);
+    if ((min_diff_time.tv_nsec == 0) || (diff_time.tv_nsec < min_diff_time.tv_nsec)) {
+        min_diff_time.tv_nsec = diff_time.tv_nsec;
+        changed = 1;
+    }
+    if ((max_diff_time.tv_nsec == 0) || (diff_time.tv_nsec > max_diff_time.tv_nsec)) {
+        max_diff_time.tv_nsec = diff_time.tv_nsec;
+        changed = 1;
+    }
+#if 1
+    if (changed) print_difftimes();
+#endif
+}
+
+/*------------------------------------------------------------------------*/
+
+unsigned int build_rflocal(int txi, int txq, int rxi, int rxq) {
+    return (txi + (txq<<6) + (rxi<<12) + (rxq<<18));
+}
+unsigned int build_rfdc(int dcoff_i_rxfe, int dcoff_q_rxfe) {
+    return (dcoff_i_rxfe + (dcoff_q_rxfe<<8));
+}
+
+#if !defined(ENABLE_ITTI)
+void signal_handler(int sig) {
+    void *array[10];
+    size_t size;
+
+    if (sig==SIGSEGV) {
+        // get void*'s for all entries on the stack
+        size = backtrace(array, 10);
+
+        // print out all the frames to stderr
+        fprintf(stderr, "Error: signal %d:\n", sig);
+        backtrace_symbols_fd(array, size, 2);
+        exit(-1);
+    } else {
+        printf("trying to exit gracefully...\n");
+        oai_exit = 1;
+    }
+}
+#endif
+#define KNRM  "\x1B[0m"
+#define KRED  "\x1B[31m"
+#define KGRN  "\x1B[32m"
+#define KBLU  "\x1B[34m"
+#define RESET "\033[0m"
+
+void help (void) {
+  printf (KGRN "Usage:\n");
+  printf("  sudo -E lte-softmodem [options]\n");
+  printf("  sudo -E ./lte-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.exmimo2.openEPC.conf -S -V -m 26 -t 16 -x 1 --ulsch-max-errors 100 -W\n\n");
+  printf("Options:\n");
+  printf("  --rf-config-file Configuration file for front-end (e.g. LMS7002M)\n");
+  printf("  --ulsch-max-errors set the max ULSCH erros\n");
+  printf("  --calib-ue-rx set UE RX calibration\n");
+  printf("  --calib-ue-rx-med \n");
+  printf("  --calib-ue-rxbyp\n");
+  printf("  --debug-ue-prach run normal prach power ramping, but don't continue random-access\n");
+  printf("  --calib-prach-tx run normal prach with maximum power, but don't continue random-access\n");
+  printf("  --no-L2-connect bypass L2 and upper layers\n");
+  printf("  --ue-rxgain set UE RX gain\n");
+  printf("  --ue-rxgain-off external UE amplifier offset\n");
+  printf("  --ue-txgain set UE TX gain\n");
+  printf("  --ue-nb-ant-rx  set UE number of rx antennas\n");
+  printf("  --ue-scan-carrier set UE to scan around carrier\n");
+  printf("  --dlsch-demod-shift dynamic shift for LLR compuation for TM3/4 (default 0)\n");
+  printf("  --loop-memory get softmodem (UE) to loop through memory instead of acquiring from HW\n");
+  printf("  --mmapped-dma sets flag for improved EXMIMO UE performance\n");  
+  printf("  --external-clock tells hardware to use an external clock reference\n");
+  printf("  --usim-test use XOR autentication algo in case of test usim mode\n"); 
+  printf("  --single-thread-disable. Disables single-thread mode in lte-softmodem\n"); 
+  printf("  --AgregationLevel Choose the agregation level used by tghe eNB for the OAI use 1, it will save some time of processing the pdcch\n");
+  printf("  --DCIformat choose the DCI format, be careful when using this option(for the moment only valid for SISO DCI format 1)\n");
+  printf("  -A Set timing_advance\n");
+  printf("  -C Set the downlink frequency for all component carriers\n");
+  printf("  -d Enable soft scope and L1 and L2 stats (Xforms)\n");
+  printf("  -F Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n");
+  printf("  -g Set the global log level, valide options: (9:trace, 8/7:debug, 6:info, 4:warn, 3:error)\n");
+  printf("  -G Set the global log verbosity \n");
+  printf("  -h provides this help message!\n");
+  printf("  -K Generate ITTI analyzser logs (similar to wireshark logs but with more details)\n");
+  printf("  -m Set the maximum downlink MCS\n");
+  printf("  -O eNB configuration file (located in targets/PROJECTS/GENERIC-LTE-EPC/CONF\n");
+  printf("  -q Enable processing timing measurement of lte softmodem on per subframe basis \n");
+  printf("  -r Set the PRB, valid values: 6, 25, 50, 100  \n");    
+  printf("  -S Skip the missed slots/subframes \n");    
+  printf("  -t Set the maximum uplink MCS\n");
+  printf("  -T Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n");
+  printf("  -U Set the lte softmodem as a UE\n");
+  printf("  -W Enable L2 wireshark messages on localhost \n");
+  printf("  -V Enable VCD (generated file will be located atopenair_dump_eNB.vcd, read it with target/RT/USER/eNB.gtkw\n");
+  printf("  -x Set the transmission mode, valid options: 1 \n");
+  printf("  -E Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n");
+#if T_TRACER
+    printf("  --T_port [port]    use given port\n");
+    printf("  --T_nowait         don't wait for tracer, start immediately\n");
+    printf("  --T_dont_fork      to ease debugging with gdb\n");
+#endif
+    printf(RESET);
+    fflush(stdout);
+}
+
+void exit_fun(const char* s) {
+    int CC_id;
+
+    if (s != NULL) {
+        printf("%s %s() Exiting OAI softmodem: %s\n",__FILE__, __FUNCTION__, s);
+    }
+
+    oai_exit = 1;
+
+    for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+
+            if (PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func)
+                PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][CC_id]->rfdevice);
+    }
+
+#if defined(ENABLE_ITTI)
+    sleep(1); //allow lte-softmodem threads to exit first
+    itti_terminate_tasks (TASK_UNKNOWN);
+#endif
+}
+
+#ifdef XFORMS
+
+
+void reset_stats(FL_OBJECT *button, long arg) {
+    int i,j,k;
+    /*PHY_VARS_eNB *phy_vars_eNB = PHY_vars_eNB_g[0][0];
+
+    for (i=0; i<NUMBER_OF_UE_MAX; i++) {
+        for (k=0; k<8; k++) { //harq_processes
+            for (j=0; j<phy_vars_eNB->dlsch[i][0]->Mlimit; j++) {
+                phy_vars_eNB->UE_stats[i].dlsch_NAK[k][j]=0;
+                phy_vars_eNB->UE_stats[i].dlsch_ACK[k][j]=0;
+                phy_vars_eNB->UE_stats[i].dlsch_trials[k][j]=0;
+            }
+
+            phy_vars_eNB->UE_stats[i].dlsch_l2_errors[k]=0;
+            phy_vars_eNB->UE_stats[i].ulsch_errors[k]=0;
+            phy_vars_eNB->UE_stats[i].ulsch_consecutive_errors=0;
+
+            for (j=0; j<phy_vars_eNB->ulsch[i]->Mlimit; j++) {
+                phy_vars_eNB->UE_stats[i].ulsch_decoding_attempts[k][j]=0;
+                phy_vars_eNB->UE_stats[i].ulsch_decoding_attempts_last[k][j]=0;
+                phy_vars_eNB->UE_stats[i].ulsch_round_errors[k][j]=0;
+                phy_vars_eNB->UE_stats[i].ulsch_round_fer[k][j]=0;
+            }
+        }
+
+        phy_vars_eNB->UE_stats[i].dlsch_sliding_cnt=0;
+        phy_vars_eNB->UE_stats[i].dlsch_NAK_round0=0;
+        phy_vars_eNB->UE_stats[i].dlsch_mcs_offset=0;
+    }*/
+}
+
+static void *scope_thread(void *arg) {
+    char stats_buffer[16384];
+# ifdef ENABLE_XFORMS_WRITE_STATS
+    FILE *UE_stats, *eNB_stats;
+# endif
+    int len = 0;
+    struct sched_param sched_param;
+    int UE_id, CC_id;
+    int ue_cnt=0;
+
+    sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1;
+    sched_setscheduler(0, SCHED_FIFO,&sched_param);
+
+    printf("Scope thread has priority %d\n",sched_param.sched_priority);
+
+# ifdef ENABLE_XFORMS_WRITE_STATS
+
+  UE_stats  = fopen("UE_stats.txt", "w");
+
+#endif
+
+    while (!oai_exit) {
+        if (UE_flag==1) {
+            //len = dump_ue_stats (PHY_vars_UE_g[0][0], &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0],stats_buffer, 0, mode,rx_input_level_dBm);
+            //fl_set_object_label(form_stats->stats_text, stats_buffer);
+            fl_clear_browser(form_stats->stats_text);
+            fl_add_browser_line(form_stats->stats_text, stats_buffer);
+
+            /*phy_scope_UE(form_ue[0],
+                         PHY_vars_UE_g[0][0],
+                         0,
+                         0,7);*/
+
+        }
+
+        //printf("doing forms\n");
+        //usleep(100000); // 100 ms
+        sleep(1);
+    }
+
+    //  printf("%s",stats_buffer);
+
+# ifdef ENABLE_XFORMS_WRITE_STATS
+
+        if (UE_stats) {
+            rewind (UE_stats);
+            fwrite (stats_buffer, 1, len, UE_stats);
+            fclose (UE_stats);
+        }
+
+# endif
+
+    pthread_exit((void*)arg);
+}
+#endif
+
+
+
+
+#if defined(ENABLE_ITTI)
+void *l2l1_task(void *arg) {
+    MessageDef *message_p = NULL;
+    int         result;
+
+    itti_set_task_real_time(TASK_L2L1);
+    itti_mark_task_ready(TASK_L2L1);
+
+
+  do {
+    // Wait for a message
+    itti_receive_msg (TASK_L2L1, &message_p);
+
+    switch (ITTI_MSG_ID(message_p)) {
+    case TERMINATE_MESSAGE:
+            oai_exit=1;
+            itti_exit_task ();
+            break;
+
+        case ACTIVATE_MESSAGE:
+            start_UE = 1;
+            break;
+
+        case DEACTIVATE_MESSAGE:
+            start_UE = 0;
+            break;
+
+        case MESSAGE_TEST:
+            LOG_I(EMU, "Received %s\n", ITTI_MSG_NAME(message_p));
+            break;
+
+        default:
+            LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p));
+            break;
+        }
+
+        result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p);
+        AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
+    } while(!oai_exit);
+
+    return NULL;
+}
+#endif
+
+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_config_request_t *config[MAX_NUM_CCs];
+
+	  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);
+
+	  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);
+	  }
+
+	  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");
+	  }
+
+	  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 ( !(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 defined(OAI_USRP) || defined(CPRIGW) || defined(OAI_ADRV9371_ZC706)
+    int clock_src;
+#endif
+
+}
+
+#if T_TRACER
+int T_wait = 1;       /* by default we wait for the tracer */
+int T_port = 2021;    /* default port to listen to to wait for the tracer */
+int T_dont_fork = 0;  /* default is to fork, see 'T_init' to understand */
+#endif
+
+  void set_default_frame_parms(nfapi_config_request_t *config[MAX_NUM_CCs], NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
+
+  int CC_id;
+
+  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+        frame_parms[CC_id] = (NR_DL_FRAME_PARMS*) malloc(sizeof(NR_DL_FRAME_PARMS));
+        /* Set some default values that may be overwritten while reading options */
+        frame_parms[CC_id] = (NR_DL_FRAME_PARMS*) malloc(sizeof(NR_DL_FRAME_PARMS));
+        config[CC_id] = (nfapi_config_request_t*) malloc(sizeof(nfapi_config_request_t));
+        config[CC_id]->subframe_config.numerology_index_mu.value =1;
+        config[CC_id]->subframe_config.duplex_mode.value = 1; //FDD
+        config[CC_id]->subframe_config.dl_cyclic_prefix_type.value = 0; //NORMAL
+        config[CC_id]->rf_config.dl_channel_bandwidth.value = 106;
+        config[CC_id]->rf_config.ul_channel_bandwidth.value = 106;
+        config[CC_id]->rf_config.tx_antenna_ports.value = 1;
+        config[CC_id]->rf_config.rx_antenna_ports.value = 1;
+        config[CC_id]->sch_config.physical_cell_id.value = 0;
+
+        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]->Ncp                 = NORMAL;
+        //frame_parms[CC_id]->Ncp_UL              = NORMAL;
+        frame_parms[CC_id]->Nid_cell            = 0;
+        //frame_parms[CC_id]->num_MBSFN_config    = 0;
+        frame_parms[CC_id]->nb_antenna_ports_eNB  = 1;
+        frame_parms[CC_id]->nb_antennas_tx      = 1;
+        frame_parms[CC_id]->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[CC_id]->numerology_index	= 0;
+        frame_parms[CC_id]->ttis_per_subframe	= 1;
+        frame_parms[CC_id]->slots_per_tti		= 2;
+
+        downlink_frequency[CC_id][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 set_default_frame_parms_single(nfapi_config_request_t *config, NR_DL_FRAME_PARMS *frame_parms) {
+
+  //int CC_id;
+
+  //for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+        frame_parms = (NR_DL_FRAME_PARMS*) malloc(sizeof(NR_DL_FRAME_PARMS));
+        /* Set some default values that may be overwritten while reading options */
+        frame_parms = (NR_DL_FRAME_PARMS*) malloc(sizeof(NR_DL_FRAME_PARMS));
+        config = (nfapi_config_request_t*) malloc(sizeof(nfapi_config_request_t));
+        config->subframe_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             = 100;
+        frame_parms->N_RB_UL             = 100;
+        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() {
+
+    int card;
+    int i;
+
+    for (card=0; card<MAX_CARDS; card++) {
+
+        openair0_cfg[card].mmapped_dma=mmapped_dma;
+        openair0_cfg[card].configFilename = NULL;
+
+        if(frame_parms[0]->N_RB_DL == 100) {
+	  if (numerology==0) {
+            if (frame_parms[0]->threequarter_fs) {
+                openair0_cfg[card].sample_rate=23.04e6;
+                openair0_cfg[card].samples_per_frame = 230400;
+                openair0_cfg[card].tx_bw = 10e6;
+                openair0_cfg[card].rx_bw = 10e6;
+            } else {
+                openair0_cfg[card].sample_rate=30.72e6;
+                openair0_cfg[card].samples_per_frame = 307200;
+                openair0_cfg[card].tx_bw = 10e6;
+                openair0_cfg[card].rx_bw = 10e6;
+            }
+	  } else if (numerology==1) {
+	    openair0_cfg[card].sample_rate=61.44e6;
+	    openair0_cfg[card].samples_per_frame = 307200;
+	    openair0_cfg[card].tx_bw = 20e6;
+	    openair0_cfg[card].rx_bw = 20e6;
+	  } else if (numerology==2) {
+	    openair0_cfg[card].sample_rate=122.88e6;
+	    openair0_cfg[card].samples_per_frame = 307200;
+	    openair0_cfg[card].tx_bw = 40e6;
+	    openair0_cfg[card].rx_bw = 40e6;
+	  } else {
+	    LOG_E(PHY,"Unsupported numerology!\n");
+	    exit(-1);
+	  }
+        } else if(frame_parms[0]->N_RB_DL == 50) {
+            openair0_cfg[card].sample_rate=15.36e6;
+            openair0_cfg[card].samples_per_frame = 153600;
+            openair0_cfg[card].tx_bw = 5e6;
+            openair0_cfg[card].rx_bw = 5e6;
+        } else if (frame_parms[0]->N_RB_DL == 25) {
+            openair0_cfg[card].sample_rate=7.68e6;
+            openair0_cfg[card].samples_per_frame = 76800;
+            openair0_cfg[card].tx_bw = 2.5e6;
+            openair0_cfg[card].rx_bw = 2.5e6;
+        } else if (frame_parms[0]->N_RB_DL == 6) {
+            openair0_cfg[card].sample_rate=1.92e6;
+            openair0_cfg[card].samples_per_frame = 19200;
+            openair0_cfg[card].tx_bw = 1.5e6;
+            openair0_cfg[card].rx_bw = 1.5e6;
+        }
+
+            if (frame_parms[0]->frame_type==TDD)
+              openair0_cfg[card].duplex_mode = duplex_mode_TDD;
+            else //FDD
+              openair0_cfg[card].duplex_mode = duplex_mode_FDD;
+
+            printf("HW: Configuring card %d, nb_antennas_tx/rx %d/%d\n",card,
+        	   PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx,
+        	   PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx);
+            openair0_cfg[card].Mod_id = 0;
+
+            openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL;
+
+            openair0_cfg[card].clock_source = clock_source;
+
+
+            openair0_cfg[card].tx_num_channels=min(2,PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_tx);
+            openair0_cfg[card].rx_num_channels=min(2,PHY_vars_UE_g[0][0]->frame_parms.nb_antennas_rx);
+
+            for (i=0; i<4; i++) {
+
+              if (i<openair0_cfg[card].tx_num_channels)
+        	openair0_cfg[card].tx_freq[i] = downlink_frequency[0][i]+uplink_frequency_offset[0][i];
+              else
+        	openair0_cfg[card].tx_freq[i]=0.0;
+
+              if (i<openair0_cfg[card].rx_num_channels)
+        	openair0_cfg[card].rx_freq[i] = downlink_frequency[0][i];
+              else
+        	openair0_cfg[card].rx_freq[i]=0.0;
+
+              openair0_cfg[card].autocal[i] = 1;
+              openair0_cfg[card].tx_gain[i] = tx_gain[0][i];
+              openair0_cfg[card].rx_gain[i] = PHY_vars_UE_g[0][0]->rx_total_gain_dB - rx_gain_off;
+
+
+              openair0_cfg[card].configFilename = rf_config_file;
+              printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n",
+        	     card,i, openair0_cfg[card].tx_gain[i],
+        	     openair0_cfg[card].rx_gain[i],
+        	     openair0_cfg[card].tx_freq[i],
+        	     openair0_cfg[card].rx_freq[i]);
+            }
+
+
+  }
+}
+
+int main( int argc, char **argv ) {
+    int i,j,k,aa,re;
+#if defined (XFORMS)
+    void *status;
+#endif
+
+    int CC_id;
+    uint8_t  abstraction_flag=0;
+    uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2;
+
+#if defined (XFORMS)
+    int ret;
+#endif
+
+    start_background_system();
+    if ( load_configmodule(argc,argv) == NULL) {
+      exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
+    } 
+
+#ifdef DEBUG_CONSOLE
+    setvbuf(stdout, NULL, _IONBF, 0);
+    setvbuf(stderr, NULL, _IONBF, 0);
+#endif
+
+    PHY_VARS_NR_UE *UE[MAX_NUM_CCs];
+    UE[0] = malloc(sizeof(PHY_VARS_NR_UE*));
+    //UE[1] = (PHY_VARS_NR_UE *)malloc(sizeof(PHY_VARS_NR_UE));
+
+    mode = normal_txrx;
+    memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS);
+
+    memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs);
+
+    set_latency_target();
+
+    // set default parameters
+    set_default_frame_parms(config,frame_parms);
+
+    // initialize logging
+    logInit();
+
+    // get options and fill parameters from configuration file
+    get_options (argc, argv); //Command-line options, enb_properties
+
+#if T_TRACER
+    T_init(T_port, T_wait, T_dont_fork);
+#endif
+
+    // initialize the log (see log.h for details)
+    //set_glog(glog_level, glog_verbosity);
+
+    //randominit (0);
+    set_taus_seed (0);
+
+        printf("configuring for UE\n");
+
+        set_comp_log(HW,      LOG_DEBUG,  LOG_HIGH, 1);
+        set_comp_log(PHY,     LOG_DEBUG,   LOG_HIGH, 1);
+        set_comp_log(MAC,     LOG_DEBUG,   LOG_HIGH, 1);
+        set_comp_log(RLC,     LOG_INFO,   LOG_HIGH | FLAG_THREAD, 1);
+        set_comp_log(PDCP,    LOG_INFO,   LOG_HIGH, 1);
+        set_comp_log(OTG,     LOG_INFO,   LOG_HIGH, 1);
+        set_comp_log(RRC,     LOG_DEBUG,   LOG_HIGH, 1);
+#if defined(ENABLE_ITTI)
+        set_comp_log(EMU,     LOG_INFO,   LOG_MED, 1);
+# if defined(ENABLE_USE_MME)
+        set_comp_log(NAS,     LOG_INFO,   LOG_HIGH, 1);
+# endif
+#endif
+
+    if (ouput_vcd)
+        VCD_SIGNAL_DUMPER_INIT("/tmp/openair_dump_UE.vcd");
+
+    //if (opp_enabled ==1) {
+    //    reset_opp_meas();
+    //}
+    cpuf=get_cpu_freq_GHz();
+
+#if defined(ENABLE_ITTI)
+
+    log_set_instance_type (LOG_INSTANCE_UE);
+
+    itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file);
+
+    // initialize mscgen log after ITTI
+    MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
+#endif
+
+    if (opt_type != OPT_NONE) {
+        radio_type_t radio_type;
+
+        if (frame_parms[0]->frame_type == FDD)
+            radio_type = RADIO_TYPE_FDD;
+        else
+            radio_type = RADIO_TYPE_TDD;
+
+        if (init_opt(in_path, in_ip, NULL, radio_type) == -1)
+            LOG_E(OPT,"failed to run OPT \n");
+    }
+
+#ifdef PDCP_USE_NETLINK
+    netlink_init();
+#if defined(PDCP_USE_NETLINK_QUEUES)
+    pdcp_netlink_init();
+#endif
+#endif
+
+#if !defined(ENABLE_ITTI)
+    // to make a graceful exit when ctrl-c is pressed
+    signal(SIGSEGV, signal_handler);
+    signal(SIGINT, signal_handler);
+#endif
+
+
+  check_clock();
+
+#ifndef PACKAGE_VERSION
+#  define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"
+#endif
+
+  LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
+
+  // init the parameters
+  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+
+
+      frame_parms[CC_id]->nb_antennas_tx     = nb_antenna_tx;
+      frame_parms[CC_id]->nb_antennas_rx     = nb_antenna_rx;
+      frame_parms[CC_id]->nb_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(config[CC_id],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]);
+  }
+
+
+
+  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+        //init prach for openair1 test
+        // prach_fmt = get_prach_fmt(frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, frame_parms->frame_type);
+        // N_ZC = (prach_fmt <4)?839:139;
+    }
+
+        /*NB_UE_INST=1;
+        NB_INST=1;
+        PHY_vars_UE_g = malloc(sizeof(PHY_VARS_NR_UE**));
+        PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_NR_UE*)*MAX_NUM_CCs);*/
+
+        for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+        	NB_UE_INST=1;
+        	        NB_INST=1;
+        	        PHY_vars_UE_g = malloc(sizeof(PHY_VARS_NR_UE**));
+        	        PHY_vars_UE_g[0] = malloc(sizeof(PHY_VARS_NR_UE*)*MAX_NUM_CCs);
+
+            printf("PHY_vars_UE_g[0][%d] = %p\n",CC_id,UE[CC_id]);
+
+            printf("frame_parms %d\n",frame_parms[CC_id]->ofdm_symbol_size);
+
+            PHY_vars_UE_g[0][CC_id] = init_nr_ue_vars(frame_parms[CC_id], 0,abstraction_flag);
+            UE[CC_id] = PHY_vars_UE_g[0][CC_id];
+
+            if (phy_test==1)
+                UE[CC_id]->mac_enabled = 0;
+            else
+                UE[CC_id]->mac_enabled = 1;
+
+            if (UE[CC_id]->mac_enabled == 0) {  //set default UL parameters for testing mode
+                for (i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) {
+                	//UE[CC_id]->pusch_config_dedicated[i] = malloc(sizeof(PUSCH_CONFIG_DEDICATED));
+
+                    //UE[CC_id]->scheduling_request_config[i] = malloc(sizeof(SCHEDULING_REQUEST_CONFIG));
+
+                    /*UE[CC_id]->pusch_config_dedicated[i].betaOffset_ACK_Index = beta_ACK;
+                    UE[CC_id]->pusch_config_dedicated[i].betaOffset_RI_Index  = beta_RI;
+                    UE[CC_id]->pusch_config_dedicated[i].betaOffset_CQI_Index = beta_CQI;
+
+                    UE[CC_id]->scheduling_request_config[i].sr_PUCCH_ResourceIndex = 0;
+                    UE[CC_id]->scheduling_request_config[i].sr_ConfigIndex = 7+(0%3);
+                    UE[CC_id]->scheduling_request_config[i].dsr_TransMax = sr_n4;*/
+                }
+            }
+
+            UE[CC_id]->UE_scan = UE_scan;
+            UE[CC_id]->UE_scan_carrier = UE_scan_carrier;
+            UE[CC_id]->mode    = mode;
+            printf("UE[%d]->mode = %d\n",CC_id,mode);
+
+            for (uint8_t i=0; i<RX_NB_TH_MAX; i++) {
+                //UE[CC_id]->pdcch_vars[i][0]->agregationLevel = agregation_Level;
+                //UE[CC_id]->pdcch_vars[i][0]->dciFormat     = dci_Format;
+            }
+
+            /*compute_prach_seq(&UE[CC_id]->frame_parms.prach_config_common,
+                              UE[CC_id]->frame_parms.frame_type,
+                              UE[CC_id]->X_u);*/
+
+            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;
+            }
+            else
+            {
+                //UE[CC_id]->pdcch_vars[0][0]->crnti = 0x1235;
+                //UE[CC_id]->pdcch_vars[1][0]->crnti = 0x1235;
+            }
+
+	    rx_gain[CC_id][0] = 81;
+	    tx_max_power[CC_id] = -40;
+
+            UE[CC_id]->rx_total_gain_dB =  (int)rx_gain[CC_id][0] + rx_gain_off;
+            UE[CC_id]->tx_power_max_dBm = tx_max_power[CC_id];
+
+            if (frame_parms[CC_id]->frame_type==FDD) {
+                UE[CC_id]->N_TA_offset = 0;
+            } else {
+                if (frame_parms[CC_id]->N_RB_DL == 100)
+                    UE[CC_id]->N_TA_offset = 624;
+                else if (frame_parms[CC_id]->N_RB_DL == 50)
+                    UE[CC_id]->N_TA_offset = 624/2;
+                else if (frame_parms[CC_id]->N_RB_DL == 25)
+                    UE[CC_id]->N_TA_offset = 624/4;
+            }
+
+        }
+
+        //  printf("tx_max_power = %d -> amp %d\n",tx_max_power[0],get_tx_amp(tx_max_poHwer,tx_max_power));
+  
+
+    fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx);
+    cpuf=get_cpu_freq_GHz();
+
+
+    //dump_frame_parms(frame_parms[0]);
+
+    init_openair0();
+
+
+
+#ifndef DEADLINE_SCHEDULER
+
+    /* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */
+
+    cpu_set_t cpuset;
+    int s;
+    char cpu_affinity[1024];
+    CPU_ZERO(&cpuset);
+#ifdef CPU_AFFINITY
+    if (get_nprocs() > 2) {
+        CPU_SET(0, &cpuset);
+        s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
+        if (s != 0) {
+            perror( "pthread_setaffinity_np");
+            exit_fun("Error setting processor affinity");
+        }
+        LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n");
+    }
+#endif
+
+  /* Check the actual affinity mask assigned to the thread */
+  s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
+  if (s != 0) {
+    perror( "pthread_getaffinity_np");
+    exit_fun("Error getting processor affinity ");
+  }
+  memset(cpu_affinity, 0 , sizeof(cpu_affinity));
+  for (int j = 0; j < CPU_SETSIZE; j++) {
+    if (CPU_ISSET(j, &cpuset)) {
+      char temp[1024];
+      sprintf(temp, " CPU_%d ", j);
+      strcat(cpu_affinity, temp);
+    }
+  }
+  LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity);
+#endif
+
+    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");
+        mac_xface = malloc(sizeof(MAC_xface));
+        l2_init(frame_parms[0],eMBMS_active,(uecap_xer_in==1)?uecap_xer:NULL,
+                0,// cba_group_active
+                0); // HO flag
+        mac_xface->macphy_exit = &exit_fun;
+    } else if (node_function[0] == NGFI_RRU_IF4p5) { // Initialize PRACH in this case
+
+    }*/
+
+
+
+#if defined(ENABLE_ITTI)
+
+        // don't create if node doesn't connect to RRC/S1/GTP
+        /*if (create_tasks(1) < 0) {
+            printf("cannot create ITTI tasks\n");
+            exit(-1); // need a softer mode
+        }*/
+
+    printf("ITTI tasks created\n");
+#endif
+
+    /*if (phy_test==0) {
+        if (UE_flag==1) {
+            printf("Filling UE band info\n");
+            fill_ue_band_info();
+            mac_xface->dl_phy_sync_success (0, 0, 0, 1);
+        } else if (node_function[0]>NGFI_RRU_IF4p5)
+            mac_xface->mrbch_phy_sync_failure (0, 0, 0);
+    }*/
+
+
+
+    mlockall(MCL_CURRENT | MCL_FUTURE);
+
+    pthread_cond_init(&sync_cond,NULL);
+    pthread_mutex_init(&sync_mutex, NULL);
+
+#ifdef XFORMS
+    int UE_id;
+
+  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);
+
+            /*
+            if (openair_daq_vars.use_ia_receiver) {
+                   fl_set_button(form_ue[UE_id]->button_0,1);
+                   fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver ON");
+            } else {
+                   fl_set_button(form_ue[UE_id]->button_0,0);
+                   fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF");
+            }*/
+            fl_set_button(form_ue[UE_id]->button_0,0);
+            fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF");
+        
+
+        ret = pthread_create(&forms_thread, NULL, scope_thread, NULL);
+
+        if (ret == 0)
+            pthread_setname_np( forms_thread, "xforms" );
+
+        printf("Scope thread created, ret=%d\n",ret);
+    }
+
+#endif
+
+    rt_sleep_ns(10*100000000ULL);
+
+
+
+    // start the main thread
+   //if (UE_flag == 1) {
+        init_UE(1);
+        number_of_cards = 1;
+
+    for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+      PHY_vars_UE_g[0][CC_id]->rf_map.card=0;
+      PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+chain_offset;
+    }
+   //}
+
+    // connect the TX/RX buffers
+    if (UE_flag==1) {
+
+        for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+
+
+#if defined(OAI_USRP) || defined(OAI_ADRV9371_ZC706)
+            UE[CC_id]->hw_timing_advance = timing_advance;
+#else
+      UE[CC_id]->hw_timing_advance = 160;
+#endif
+    }
+	if (setup_ue_buffers(UE,&openair0_cfg[0])!=0) {
+            printf("Error setting up eNB buffer\n");
+            exit(-1);
+        }
+
+
+
+        if (input_fd) {
+            printf("Reading in from file to antenna buffer %d\n",0);
+            if (fread(UE[0]->common_vars.rxdata[0],
+                      sizeof(int32_t),
+                      frame_parms[0]->samples_per_subframe*10,
+                      input_fd) != frame_parms[0]->samples_per_subframe*10)
+                printf("error reading from file\n");
+        }
+        //p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX;
+    }
+    sleep(3);
+
+
+    printf("Sending sync to all threads\n");
+
+    pthread_mutex_lock(&sync_mutex);
+    sync_var=0;
+    pthread_cond_broadcast(&sync_cond);
+    pthread_mutex_unlock(&sync_mutex);
+
+    // wait for end of program
+    printf("TYPE <CTRL-C> TO TERMINATE\n");
+    //getchar();
+
+#if defined(ENABLE_ITTI)
+    printf("Entering ITTI signals handler\n");
+    itti_wait_tasks_end();
+    oai_exit=1;
+#else
+
+    while (oai_exit==0)
+        rt_sleep_ns(100000000ULL);
+
+#endif
+
+  // stop threads
+#ifdef XFORMS
+  printf("waiting for XFORMS thread\n");
+
+  if (do_forms==1) {
+    pthread_join(forms_thread,&status);
+    fl_hide_form(form_stats->stats_form);
+    fl_free_form(form_stats->stats_form);
+    fl_hide_form(form_ue[0]->lte_phy_scope_ue);
+    fl_free_form(form_ue[0]->lte_phy_scope_ue);
+  }
+
+#endif
+
+  printf("stopping MODEM threads\n");
+
+  pthread_cond_destroy(&sync_cond);
+  pthread_mutex_destroy(&sync_mutex);
+
+
+    // *** Handle per CC_id openair0
+        if (PHY_vars_UE_g[0][0]->rfdevice.trx_end_func)
+            PHY_vars_UE_g[0][0]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][0]->rfdevice);
+
+    if (ouput_vcd)
+        VCD_SIGNAL_DUMPER_CLOSE();
+
+    if (opt_enabled == 1)
+        terminate_opt();
+
+    logClean();
+
+    return 0;
+}
diff --git a/targets/RT/USER/nr-uesoftmodem.h b/targets/RT/USER/nr-uesoftmodem.h
new file mode 100644
index 0000000000000000000000000000000000000000..9b85ed401d72b0e18ff5673ea53445467e2a8c32
--- /dev/null
+++ b/targets/RT/USER/nr-uesoftmodem.h
@@ -0,0 +1,260 @@
+#ifndef NR_UESOFTMODEM_H
+#define NR_UESOFTMODEM_H
+
+#define _GNU_SOURCE
+#include <execinfo.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <linux/sched.h>
+#include "rt_wrapper.h"
+#include <sched.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syscall.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/sysinfo.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <sys/sysinfo.h>
+#include "rt_wrapper.h"
+#include "../../ARCH/COMMON/common_lib.h"
+#undef MALLOC
+#include "assertions.h"
+#include "msc.h"
+#include "PHY/types.h"
+#include "PHY/defs_nr_UE.h"
+#include "SIMULATION/ETH_TRANSPORT/proto.h"
+
+#if defined(ENABLE_ITTI)
+#if defined(ENABLE_USE_MME)
+#include "s1ap_eNB.h"
+#ifdef PDCP_USE_NETLINK
+#include "SIMULATION/ETH_TRANSPORT/proto.h"
+#endif
+#endif
+#endif
+
+/* help strings definition for command line options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */
+#define CONFIG_HLP_RFCFGF        "Configuration file for front-end (e.g. LMS7002M)\n"
+#define CONFIG_HLP_ULMAXE        "set the eNodeB max ULSCH erros\n"
+#define CONFIG_HLP_CALUER        "set UE RX calibration\n"
+#define CONFIG_HLP_CALUERM       ""
+#define CONFIG_HLP_CALUERB       ""
+#define CONFIG_HLP_DBGUEPR       "UE run normal prach power ramping, but don't continue random-access\n"
+#define CONFIG_HLP_CALPRACH      "UE run normal prach with maximum power, but don't continue random-access\n"
+#define CONFIG_HLP_NOL2CN        "bypass L2 and upper layers\n"
+#define CONFIG_HLP_UERXG         "set UE RX gain\n"
+#define CONFIG_HLP_UERXGOFF      "external UE amplifier offset\n"
+#define CONFIG_HLP_UETXG         "set UE TX gain\n"
+#define CONFIG_HLP_UENANTR       "set UE number of rx antennas\n"
+#define CONFIG_HLP_UENANTT       "set UE number of tx antennas\n"
+#define CONFIG_HLP_UESCAN        "set UE to scan around carrier\n"
+#define CONFIG_HLP_DUMPFRAME     "dump UE received frame to rxsig_frame0.dat and exit\n"
+#define CONFIG_HLP_DLSHIFT       "dynamic shift for LLR compuation for TM3/4 (default 0)\n"
+#define CONFIG_HLP_UELOOP        "get softmodem (UE) to loop through memory instead of acquiring from HW\n"
+#define CONFIG_HLP_PHYTST        "test UE phy layer, mac disabled\n"
+#define CONFIG_HLP_DMAMAP        "sets flag for improved EXMIMO UE performance\n"
+#define CONFIG_HLP_EXCCLK        "tells hardware to use an external clock reference\n"
+#define CONFIG_HLP_USIM          "use XOR autentication algo in case of test usim mode\n"
+#define CONFIG_HLP_NOSNGLT       "Disables single-thread mode in lte-softmodem\n"
+#define CONFIG_HLP_TADV          "Set timing_advance\n"
+#define CONFIG_HLP_DLF           "Set the downlink frequency for all component carriers\n"
+#define CONFIG_HLP_CHOFF         "Channel id offset\n"
+#define CONFIG_HLP_SOFTS         "Enable soft scope and L1 and L2 stats (Xforms)\n"
+#define CONFIG_HLP_EXMCAL        "Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n"
+#define CONFIG_HLP_ITTIL         "Generate ITTI analyzser logs (similar to wireshark logs but with more details)\n"
+#define CONFIG_HLP_DLMCS         "Set the maximum downlink MCS\n"
+#define CONFIG_HLP_STMON         "Enable processing timing measurement of lte softmodem on per subframe basis \n"
+#define CONFIG_HLP_PRB           "Set the PRB, valid values: 6, 25, 50, 100  \n"
+#define CONFIG_HLP_MSLOTS        "Skip the missed slots/subframes \n"
+#define CONFIG_HLP_ULMCS         "Set the maximum uplink MCS\n"
+#define CONFIG_HLP_TDD           "Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n"
+#define CONFIG_HLP_UE            "Set the lte softmodem as a UE\n"
+#define CONFIG_HLP_L2MONW        "Enable L2 wireshark messages on localhost \n"
+#define CONFIG_HLP_L2MONP        "Enable L2 pcap  messages on localhost \n"
+#define CONFIG_HLP_VCD           "Enable VCD (generated file will is named openair_dump_eNB.vcd, read it with target/RT/USER/eNB.gtkw\n"
+#define CONFIG_HLP_TQFS          "Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n"
+#define CONFIG_HLP_TPORT         "tracer port\n"
+#define CONFIG_HLP_NOTWAIT       "don't wait for tracer, start immediately\n"
+#define CONFIG_HLP_TNOFORK       "to ease debugging with gdb\n"
+
+#define CONFIG_HLP_NUMEROLOGY    "adding numerology for 5G\n"
+#define CONFIG_HLP_CODINGW       "coding worker thread enable(disable by defult)\n"
+#define CONFIG_HLP_FEPW          "FEP worker thread enabled(disable by defult)\n"
+#define CONFIG_HLP_EMULATE_RF    "Emulated RF enabled(disable by defult)\n"
+
+#define CONFIG_HLP_DISABLNBIOT   "disable nb-iot, even if defined in config\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                                                                                 */
+
+
+/*------------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                            command line parameters defining UE running mode                                              */
+/*   optname                     helpstr                paramflags                      XXXptr        defXXXval         type       numelt   */
+/*------------------------------------------------------------------------------------------------------------------------------------------*/
+#define CMDLINE_UEMODEPARAMS_DESC {  \
+{"calib-ue-rx",                 CONFIG_HLP_CALUER,     0,		 iptr:&rx_input_level_dBm,   defintval:0,	 TYPE_INT,   0},    \
+{"calib-ue-rx-med",             CONFIG_HLP_CALUERM,    0,		 iptr:&rx_input_level_dBm,   defintval:0,	 TYPE_INT,   0},    \
+{"calib-ue-rx-byp",             CONFIG_HLP_CALUERB,    0,		 iptr:&rx_input_level_dBm,   defintval:0,	 TYPE_INT,   0},    \
+{"debug-ue-prach",              CONFIG_HLP_DBGUEPR,    PARAMFLAG_BOOL,   uptr:NULL,		     defuintval:1,	 TYPE_INT,   0},    \
+{"no-L2-connect",               CONFIG_HLP_NOL2CN,     PARAMFLAG_BOOL,   uptr:NULL,		     defuintval:1,	 TYPE_INT,   0},    \
+{"calib-prach-tx",              CONFIG_HLP_CALPRACH,   PARAMFLAG_BOOL,   uptr:NULL,		     defuintval:1,	 TYPE_INT,   0},    \
+{"loop-memory",                 CONFIG_HLP_UELOOP,     0,		 strptr:&loopfile,	     defstrval:"iqs.in", TYPE_STRING,0},    \
+{"ue-dump-frame",               CONFIG_HLP_DUMPFRAME,  PARAMFLAG_BOOL,   iptr:&dumpframe,	     defintval:0,	 TYPE_INT,   0},    \
+}
+#define CMDLINE_CALIBUERX_IDX                   0
+#define CMDLINE_CALIBUERXMED_IDX                1
+#define CMDLINE_CALIBUERXBYP_IDX                2
+#define CMDLINE_DEBUGUEPRACH_IDX                3
+#define CMDLINE_NOL2CONNECT_IDX                 4
+#define CMDLINE_CALIBPRACHTX_IDX                5
+#define CMDLINE_MEMLOOP_IDX                     6
+#define CMDLINE_DUMPMEMORY_IDX                  7
+/*------------------------------------------------------------------------------------------------------------------------------------------*/
+
+
+/*--------------------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                            command line parameters specific to UE                                                                */
+/*   optname                     helpstr             paramflags                      XXXptr                  defXXXval       type          numelt   */
+/*--------------------------------------------------------------------------------------------------------------------------------------------------*/
+#define CMDLINE_UEPARAMS_DESC {  \
+{"ue-rxgain",        	       CONFIG_HLP_UERXG,      0,		dblptr:&(rx_gain[0][0]),	    defdblval:0,    TYPE_DOUBLE,   0},     \
+{"ue-rxgain-off",    	       CONFIG_HLP_UERXGOFF,   0,		dblptr:&rx_gain_off,		    defdblval:0,    TYPE_DOUBLE,   0},     \
+{"ue-txgain",        	       CONFIG_HLP_UETXG,      0,		dblptr:&(tx_gain[0][0]),	    defdblval:0,    TYPE_DOUBLE,   0},     \
+{"ue-nb-ant-rx",     	       CONFIG_HLP_UENANTR,    0,		u8ptr:&nb_antenna_rx,		    defuintval:1,   TYPE_UINT8,    0},     \
+{"ue-nb-ant-tx",     	       CONFIG_HLP_UENANTT,    0,		u8ptr:&nb_antenna_tx,		    defuintval:1,   TYPE_UINT8,    0},     \
+{"ue-scan-carrier",  	       CONFIG_HLP_UESCAN,     PARAMFLAG_BOOL,	iptr:&UE_scan_carrier,  	    defintval:0,    TYPE_INT,	   0},     \
+{"ue-max-power",     	       NULL,		      0,		iptr:&(tx_max_power[0]),	    defintval:90,   TYPE_INT,	   0},     \
+{"r"  ,                        CONFIG_HLP_PRB,        0,                u8ptr:&(frame_parms[0]->N_RB_DL),   defintval:25,   TYPE_UINT8,    0},     \
+{"dlsch-demod-shift",     	 CONFIG_HLP_DLSHIFT,	0,		  iptr:(int32_t *)&dlsch_demod_shift,	defintval:0,			   TYPE_INT,	  0},			   \
+}
+
+#define DEFAULT_DLF 2680000000
+
+/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                            command line parameters common to eNodeB and UE                                                                                */
+/*   optname                     helpstr                paramflags                      XXXptr                  defXXXval                            type           numelt   */
+/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+#define CMDLINE_PARAMS_DESC {  \
+{"rf-config-file",          CONFIG_HLP_RFCFGF,      0,                      strptr:(char **)&rf_config_file,    defstrval:NULL,                 TYPE_STRING,    sizeof(rf_config_file)}, \
+{"ulsch-max-errors",        CONFIG_HLP_ULMAXE,      0,                      uptr:&ULSCH_max_consecutive_errors, defuintval:0,                   TYPE_UINT,      0},                     \
+{"phy-test",                CONFIG_HLP_PHYTST,      PARAMFLAG_BOOL,         iptr:&phy_test,                     defintval:0,                    TYPE_INT,       0},                     \
+{"usim-test",               CONFIG_HLP_USIM,        PARAMFLAG_BOOL,         u8ptr:&usim_test,                   defintval:0,                    TYPE_UINT8,     0},                     \
+{"mmapped-dma",             CONFIG_HLP_DMAMAP,      PARAMFLAG_BOOL,         uptr:&mmapped_dma,                  defintval:0,                    TYPE_INT,       0},                     \
+{"external-clock",          CONFIG_HLP_EXCCLK,      PARAMFLAG_BOOL,         uptr:&clock_source,                 defintval:0,                    TYPE_INT,       0},                     \
+{"wait-for-sync",           NULL,                   PARAMFLAG_BOOL,         iptr:&wait_for_sync,                defintval:0,                    TYPE_INT,       0},                     \
+{"single-thread-disable",   CONFIG_HLP_NOSNGLT,     PARAMFLAG_BOOL,         iptr:&single_thread_flag,           defintval:1,                    TYPE_INT,       0},                     \
+{"threadIQ",                NULL,                   0,                      iptr:&(threads.iq),                 defintval:1,                    TYPE_INT,       0},                     \
+{"threadOneSubframe",       NULL,                   0,                      iptr:&(threads.one),                defintval:1,                    TYPE_INT,       0},                     \
+{"threadTwoSubframe",       NULL,                   0,                      iptr:&(threads.two),                defintval:1,                    TYPE_INT,       0},                     \
+{"threadThreeSubframe",     NULL,                   0,                      iptr:&(threads.three),              defintval:1,                    TYPE_INT,       0},                     \
+{"threadSlot1ProcOne",      NULL,                   0,                      iptr:&(threads.slot1_proc_one),     defintval:1,                    TYPE_INT,       0},                     \
+{"threadSlot1ProcTwo",      NULL,                   0,                      iptr:&(threads.slot1_proc_two),     defintval:1,                    TYPE_INT,       0},                     \
+{"dlsch-demod-shift",       CONFIG_HLP_DLSHIFT,     0,                      iptr:(int32_t *)&dlsch_demod_shift, defintval:0,                    TYPE_INT,       0},                     \
+{"A" ,                      CONFIG_HLP_TADV,        0,                      uptr:&timing_advance,               defintval:0,                    TYPE_UINT,      0},                     \
+{"C" ,                      CONFIG_HLP_DLF,         0,                      uptr:&(downlink_frequency[0][0]),   defuintval:2680000000,          TYPE_UINT,      0},                     \
+{"a" ,                      CONFIG_HLP_CHOFF,       0,                      iptr:&chain_offset,                 defintval:0,                    TYPE_INT,       0},                     \
+{"d" ,                      CONFIG_HLP_SOFTS,       PARAMFLAG_BOOL,         uptr:(uint32_t *)&do_forms,         defintval:0,                    TYPE_INT8,      0},                     \
+{"E" ,                      CONFIG_HLP_TQFS,        PARAMFLAG_BOOL,         i8ptr:&threequarter_fs,             defintval:0,                    TYPE_INT8,      0},                     \
+{"K" ,                      CONFIG_HLP_ITTIL,       PARAMFLAG_NOFREE,       strptr:&itti_dump_file,             defstrval:"/tmp/itti.dump",     TYPE_STRING,    0},                     \
+{"m" ,                      CONFIG_HLP_DLMCS,       0,                      uptr:&target_dl_mcs,                defintval:0,                    TYPE_UINT,      0},                     \
+{"t" ,                      CONFIG_HLP_ULMCS,       0,                      uptr:&target_ul_mcs,                defintval:0,                    TYPE_UINT,      0},                     \
+{"W" ,                      CONFIG_HLP_L2MONW,      0,                      strptr:(char **)&in_ip,             defstrval:"127.0.0.1",          TYPE_STRING,    sizeof(in_ip)},         \
+{"P" ,                      CONFIG_HLP_L2MONP,      0,                      strptr:(char **)&in_path,           defstrval:"/tmp/oai_opt.pcap",  TYPE_STRING,    sizeof(in_path)},       \
+{"V" ,                      CONFIG_HLP_VCD,         PARAMFLAG_BOOL,         iptr:&ouput_vcd,                    defintval:0,                    TYPE_INT,       0},                     \
+{"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},                     \
+{"numerology" ,             CONFIG_HLP_NUMEROLOGY,  PARAMFLAG_BOOL,         iptr:&numerology,                   defintval:0,                    TYPE_INT,       0},                     \
+{"emulate-rf" ,             CONFIG_HLP_EMULATE_RF,  PARAMFLAG_BOOL,         iptr:&emulate_rf,                   defintval:0,                    TYPE_INT,       0},                     \
+{"codingw" ,                CONFIG_HLP_CODINGW,     PARAMFLAG_BOOL,         iptr:&codingw,                      defintval:0,                    TYPE_INT,       0},                     \
+{"fepw" ,                   CONFIG_HLP_FEPW,        PARAMFLAG_BOOL,         iptr:&fepw,                         defintval:0,                    TYPE_INT,       0},                     \
+{"nbiot-disable",           CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL,         iptr:&nonbiotflag,			defintval:0,			TYPE_INT,	0} \
+}
+
+#define CONFIG_HLP_FLOG          "Enable online log \n"
+#define CONFIG_HLP_LOGL          "Set the global log level, valide options: (9:trace, 8/7:debug, 6:info, 4:warn, 3:error)\n"
+#define CONFIG_HLP_LOGV          "Set the global log verbosity \n"
+#define CONFIG_HLP_TELN          "Start embedded telnet server \n"
+/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                            command line parameters for LOG utility                                                                                        */
+/*   optname                     helpstr                paramflags                      XXXptr                  defXXXval                            type           numelt   */
+/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+#define CMDLINE_LOGPARAMS_DESC {  \
+{"R" ,  		  	 CONFIG_HLP_FLOG,	0,                uptr:&online_log_messages,		defintval:1,			   TYPE_INT,	  0},			   \
+{"g" ,  		  	 CONFIG_HLP_LOGL,	0,		  uptr:&glog_level,			defintval:0,			   TYPE_UINT,     0},			   \
+{"G" ,                           CONFIG_HLP_LOGV,	0,		  uptr:&glog_verbosity,		        defintval:0,			   TYPE_UINT16,   0},			   \
+{"telnetsrv",    		 CONFIG_HLP_TELN,	PARAMFLAG_BOOL,	  uptr:&start_telnetsrv,		defintval:0,			   TYPE_UINT,     0},			   \
+}
+#define CMDLINE_ONLINELOG_IDX     0
+#define CMDLINE_GLOGLEVEL_IDX     1
+#define CMDLINE_GLOGVERBO_IDX     2
+#define CMDLINE_STARTTELN_IDX     3
+
+
+extern int T_port;
+extern int T_nowait;
+extern int T_dont_fork;
+
+/*------------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                            command line parameters for TTRACE utility                                                    */
+/*   optname                     helpstr                paramflags           XXXptr           defXXXval         type       numelt           */
+/*------------------------------------------------------------------------------------------------------------------------------------------*/
+#define CMDLINE_TTRACEPARAMS_DESC {  \
+{"T_port",                     CONFIG_HLP_TPORT,      0,		iptr:&T_port,	     defintval:0,	TYPE_INT,   0},	   \
+{"T_nowait",                   CONFIG_HLP_NOTWAIT,    PARAMFLAG_BOOL,	iptr:&T_nowait,      defintval:0,	TYPE_INT,   0},	   \
+{"T_dont_fork",                CONFIG_HLP_TNOFORK,    PARAMFLAG_BOOL,	iptr:&T_dont_fork,   defintval:1,	TYPE_INT,   0},	   \
+}
+
+
+/***************************************************************************************************************************************/
+
+extern pthread_cond_t sync_cond;
+extern pthread_mutex_t sync_mutex;
+extern int sync_var;
+
+
+extern uint32_t          downlink_frequency[MAX_NUM_CCs][4];
+extern int32_t           uplink_frequency_offset[MAX_NUM_CCs][4];
+
+extern int rx_input_level_dBm;
+extern uint8_t exit_missed_slots;
+extern uint64_t num_missed_slots; // counter for the number of missed slots
+
+extern int oaisim_flag;
+extern volatile int  oai_exit;
+
+extern openair0_config_t openair0_cfg[MAX_CARDS];
+extern pthread_cond_t sync_cond;
+extern pthread_mutex_t sync_mutex;
+extern int sync_var;
+extern int transmission_mode;
+extern double cpuf;
+
+#if defined(ENABLE_ITTI)
+extern volatile int             start_eNB;
+extern volatile int             start_UE;
+#endif
+
+#include "threads_t.h"
+extern threads_t threads;
+
+extern void exit_fun(const char* s);
+
+// In nr-ue.c
+extern int setup_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg);
+extern void fill_ue_band_info(void);
+extern void init_UE(int);
+extern void init_thread(int sched_runtime, int sched_deadline, int sched_fifo, cpu_set_t *cpuset, char * name);
+extern void reset_opp_meas(void);
+extern void print_opp_meas(void);
+
+#endif