From 02dc4ba8ce0ff8936df6580f5cf71e4fffa5653a Mon Sep 17 00:00:00 2001
From: "NCTU OpinConnect Terng-Yin Hsu/WEI-YING,LIN" <tyhsu@cs.nctu.edu.tw>
Date: Wed, 13 May 2020 22:27:36 +0800
Subject: [PATCH] configured LDPC on CPU and GPU

---
 .../gnb.band78.tm1.106PRB.usrpn300.conf       |  339 +-
 ci-scripts/main.py                            |   11 +-
 ci-scripts/oai-ci-vm-tool                     |    2 +-
 ci-scripts/runTestOnVM.sh                     |   96 +-
 ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml   |    6 +-
 cmake_targets/CMakeLists.txt                  |  141 +-
 cmake_targets/autotests/test_case_list.xml    |   49 +-
 cmake_targets/build_oai                       |    4 +
 cmake_targets/tools/build_helper              |    4 +-
 common/config/config_userapi.c                |    4 +-
 common/ran_context.h                          |    4 +-
 common/utils/LOG/vcd_signal_dumper.c          |    3 +-
 common/utils/LOG/vcd_signal_dumper.h          |    1 +
 common/utils/T/T_defs.h                       |    2 +-
 common/utils/T/T_messages.txt                 |    5 +
 common/utils/telnetsrv/telnetsrv.c            |   20 +-
 executables/nr-gnb.c                          |  396 +-
 executables/nr-ru.c                           |  356 +-
 executables/nr-softmodem-common.h             |    3 +-
 executables/nr-softmodem.c                    |  122 +-
 executables/nr-softmodem.h                    |    2 +-
 executables/nr-ue.c                           |  386 +-
 executables/nr-uesoftmodem.c                  |   93 +-
 executables/nr-uesoftmodem.h                  |   14 +-
 executables/softmodem-common.c                |    2 +-
 executables/softmodem-common.h                |    6 +-
 nfapi/oai_integration/nfapi_vnf.c             |   10 +-
 .../nfapi/public_inc/fapi_nr_ue_constants.h   |    7 +-
 .../nfapi/public_inc/fapi_nr_ue_interface.h   |  255 +-
 .../nfapi/public_inc/nfapi_nr_interface.h     |  296 +-
 .../nfapi/public_inc/nfapi_nr_interface_scf.h |  642 ++-
 .../vnf/public_inc/nfapi_vnf_interface.h      |    5 +-
 nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c   |    2 +-
 openair1/PHY/CODING/TESTBENCH/ldpctest.c      |   42 +-
 openair1/PHY/CODING/TESTBENCH/polartest.c     |    2 +-
 openair1/PHY/CODING/coding_defs.h             |    6 +-
 .../PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h |   14 +-
 .../CODING/nrLDPC_decoder/nrLDPC_decoder.c    |    6 +-
 .../CODING/nrLDPC_decoder/nrLDPC_decoder.h    |   46 -
 .../PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h   |  201 -
 .../PHY/CODING/nrLDPC_decoder/nrLDPC_init.h   |    2 +-
 .../CODING/nrLDPC_decoder/nrLDPC_init_mem.h   |    1 -
 .../PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h  |   21 +-
 .../PHY/CODING/nrLDPC_decoder/nrLDPC_types.h  |    5 +-
 .../nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu  |   10 -
 .../nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.h   |   14 +-
 .../CODING/nrLDPC_decoder_LYC/nrLDPC_defs.h   |   12 +-
 openair1/PHY/CODING/nrLDPC_encoder/defs.h     |   54 -
 .../PHY/CODING/nrLDPC_encoder/ldpc_encoder.c  |  246 +-
 .../PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c |   10 +-
 .../ldpc_generate_coefficient.c               |  242 +-
 .../PHY/CODING/nrPolar_tools/nr_polar_defs.h  |    4 +-
 openair1/PHY/CODING/nr_compute_tbs.c          |  151 -
 openair1/PHY/CODING/nr_polar_init.c           |   14 +-
 openair1/PHY/CODING/nr_rate_matching.c        |  360 +-
 openair1/PHY/CODING/nr_segmentation.c         |   16 +-
 openair1/PHY/INIT/lte_parms.c                 |    2 +
 openair1/PHY/INIT/nr_init.c                   |  459 +-
 openair1/PHY/INIT/nr_init_ru.c                |   21 +-
 openair1/PHY/INIT/nr_init_ue.c                |   94 +-
 openair1/PHY/INIT/nr_parms.c                  |  321 +-
 openair1/PHY/INIT/phy_init.h                  |    7 +-
 openair1/PHY/MODULATION/modulation_UE.h       |    6 +
 openair1/PHY/MODULATION/nr_modulation.c       |    7 +-
 openair1/PHY/MODULATION/slot_fep_nr.c         |  200 +-
 .../NR_ESTIMATION/nr_ul_channel_estimation.c  |   34 +-
 openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h |   14 +-
 openair1/PHY/NR_REFSIG/dmrs_nr.c              |   15 +-
 openair1/PHY/NR_REFSIG/dmrs_nr.h              |    3 +-
 openair1/PHY/NR_REFSIG/nr_gold.c              |   66 +-
 openair1/PHY/NR_REFSIG/nr_gold_ue.c           |    4 +-
 openair1/PHY/NR_REFSIG/nr_refsig.h            |    2 +-
 openair1/PHY/NR_TRANSPORT/nr_dci.c            |  312 +-
 openair1/PHY/NR_TRANSPORT/nr_dci.h            |   20 +-
 openair1/PHY/NR_TRANSPORT/nr_dci_tools.c      |  507 +-
 openair1/PHY/NR_TRANSPORT/nr_dlsch.c          |  244 +-
 openair1/PHY/NR_TRANSPORT/nr_dlsch.h          |   41 +-
 openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c   |  248 +-
 openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c    |   60 +-
 openair1/PHY/NR_TRANSPORT/nr_pbch.c           |   31 +-
 openair1/PHY/NR_TRANSPORT/nr_pss.c            |    4 +-
 openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c       |   12 +-
 openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h       |    4 +-
 openair1/PHY/NR_TRANSPORT/nr_sss.c            |    4 +-
 openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c      |  183 +-
 openair1/PHY/NR_TRANSPORT/nr_transport.h      |   31 +-
 .../NR_TRANSPORT/nr_transport_common_proto.h  |   20 +-
 .../PHY/NR_TRANSPORT/nr_transport_proto.h     |   26 +-
 openair1/PHY/NR_TRANSPORT/nr_ulsch.h          |    9 +-
 openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c |  217 +-
 .../PHY/NR_TRANSPORT/nr_ulsch_demodulation.c  |  350 +-
 .../nr_dl_channel_estimation.c                |   19 +-
 openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h |    7 +-
 .../PHY/NR_UE_ESTIMATION/nr_ue_measurements.c |  633 +--
 openair1/PHY/NR_UE_TRANSPORT/dci_nr.c         | 1659 +-----
 openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c   | 1018 +---
 .../PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c   |  281 +-
 .../NR_UE_TRANSPORT/nr_dlsch_demodulation.c   |  210 +-
 .../nr_dlsch_llr_computation.c                |   14 +-
 .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c     |   29 +-
 openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c        |   20 +-
 openair1/PHY/NR_UE_TRANSPORT/nr_prach.c       | 1335 ++---
 openair1/PHY/NR_UE_TRANSPORT/nr_prach.h       |  891 ----
 .../NR_UE_TRANSPORT/nr_transport_proto_ue.h   |   88 +-
 .../PHY/NR_UE_TRANSPORT/nr_transport_ue.h     |   20 +-
 .../PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c     |  123 +-
 openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c    |  148 +-
 openair1/PHY/NR_UE_TRANSPORT/pss_nr.c         |    6 +-
 openair1/PHY/NR_UE_TRANSPORT/sss_nr.c         |    2 +-
 openair1/PHY/TOOLS/Makefile                   |    8 +-
 openair1/PHY/TOOLS/lte_dfts.c                 |  114 +-
 openair1/PHY/TOOLS/nr_phy_scope.c             |  107 +-
 openair1/PHY/TOOLS/nr_phy_scope.h             |    1 +
 openair1/PHY/TOOLS/tools_defs.h               |   17 +-
 openair1/PHY/defs_RU.h                        |    4 +
 openair1/PHY/defs_common.h                    |    5 +
 openair1/PHY/defs_gNB.h                       |  211 +-
 openair1/PHY/defs_nr_UE.h                     |   87 +-
 openair1/PHY/defs_nr_common.h                 |   82 +-
 openair1/PHY/impl_defs_nr.h                   |   76 +-
 openair1/PHY/impl_defs_top.h                  |    4 +-
 openair1/SCHED_NR/fapi_nr_l1.c                |  177 +-
 openair1/SCHED_NR/fapi_nr_l1.h                |   11 +-
 openair1/SCHED_NR/nr_ru_procedures.c          |  312 +-
 openair1/SCHED_NR/phy_frame_config_nr.h       |    4 +-
 openair1/SCHED_NR/phy_procedures_nr_common.c  |    9 -
 openair1/SCHED_NR/phy_procedures_nr_gNB.c     |  335 +-
 openair1/SCHED_NR/sched_nr.h                  |   16 +-
 openair1/SCHED_NR_UE/defs.h                   |    3 +-
 openair1/SCHED_NR_UE/fapi_nr_ue_l1.c          |   87 +-
 openair1/SCHED_NR_UE/phy_frame_config_nr.c    |  342 --
 openair1/SCHED_NR_UE/phy_frame_config_nr.h    |   12 -
 openair1/SCHED_NR_UE/phy_procedures_nr_ue.c   |  703 ++-
 .../SCHED_NR_UE/pucch_power_control_ue_nr.c   |   23 +-
 openair1/SCHED_NR_UE/pucch_uci_ue_nr.c        |   18 +-
 openair1/SCHED_UE/phy_procedures_lte_ue.c     |    2 +-
 .../SIMULATION/ETH_TRANSPORT/netlink_init.c   |   20 +-
 openair1/SIMULATION/ETH_TRANSPORT/proto.h     |    2 +-
 openair1/SIMULATION/LTE_PHY/prachsim.c        |    4 +-
 openair1/SIMULATION/NR_PHY/dlschsim.c         |   47 +-
 openair1/SIMULATION/NR_PHY/dlsim.c            |  827 +--
 .../SIMULATION/NR_PHY/nr_dummy_functions.c    |    2 +-
 openair1/SIMULATION/NR_PHY/nr_unitary_defs.h  |  168 +
 openair1/SIMULATION/NR_PHY/pbchsim.c          |  117 +-
 openair1/SIMULATION/NR_PHY/pucchsim.c         |   12 +-
 openair1/SIMULATION/NR_PHY/ulschsim.c         |   61 +-
 openair1/SIMULATION/NR_PHY/ulsim.c            |  232 +-
 .../NR_UE_PHY/unit_tests/src/pss_util_test.c  |    2 +-
 openair2/COMMON/platform_constants.h          |    9 +-
 openair2/COMMON/rrc_messages_types.h          |  193 +-
 openair2/COMMON/s1ap_messages_types.h         |   19 +-
 openair2/COMMON/x2ap_messages_def.h           |    5 +
 openair2/COMMON/x2ap_messages_types.h         |  114 +-
 openair2/ENB_APP/enb_config.c                 |    7 +-
 openair2/ENB_APP/enb_paramdef.h               |    3 +
 openair2/GNB_APP/RRC_nr_paramsvalues.h        |  379 +-
 openair2/GNB_APP/gnb_app.c                    |   30 +-
 openair2/GNB_APP/gnb_config.c                 | 2779 ++--------
 openair2/GNB_APP/gnb_config.h                 |    1 +
 openair2/GNB_APP/gnb_paramdef.h               |  686 +--
 openair2/LAYER2/MAC/eNB_scheduler_ulsch.c     |   55 +-
 openair2/LAYER2/MAC/ue_procedures.c           |    2 +-
 openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c |  686 ++-
 openair2/LAYER2/NR_MAC_UE/config_ue.c         |  435 +-
 openair2/LAYER2/NR_MAC_UE/mac_defs.h          |  178 +-
 openair2/LAYER2/NR_MAC_UE/mac_proto.h         |   89 +-
 openair2/LAYER2/NR_MAC_UE/main_ue_nr.c        |   16 +-
 openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c  | 4559 ++++++++++-------
 openair2/LAYER2/NR_MAC_gNB/config.c           |  415 +-
 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c    |  139 +-
 .../LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c     |   92 +-
 .../LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c | 1165 +++--
 .../NR_MAC_gNB/gNB_scheduler_primitives.c     | 1152 ++++-
 .../LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c   |   13 +-
 openair2/LAYER2/NR_MAC_gNB/mac_proto.h        |  140 +-
 openair2/LAYER2/NR_MAC_gNB/main.c             |  110 +-
 openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h       |  177 +-
 openair2/LAYER2/PDCP_v10.1.0/pdcp.c           |    6 +-
 openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c      |    6 +-
 openair2/NR_PHY_INTERFACE/NR_IF_Module.c      |  208 +-
 openair2/NR_PHY_INTERFACE/NR_IF_Module.h      |   10 +-
 openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c   |  115 +-
 openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h   |    6 +-
 openair2/PHY_INTERFACE/phy_stub_UE.c          | 1727 ++++---
 openair2/RRC/LTE/MESSAGES/asn1_msg.c          |   92 +
 openair2/RRC/LTE/MESSAGES/asn1_msg.h          |    7 +
 openair2/RRC/LTE/rrc_defs.h                   |    6 +-
 openair2/RRC/LTE/rrc_eNB.c                    |  319 +-
 openair2/RRC/LTE/rrc_proto.h                  |    6 +
 openair2/RRC/NR/L2_nr_interface.c             |    2 +-
 openair2/RRC/NR/MESSAGES/asn1_msg.c           |  651 +--
 openair2/RRC/NR/MESSAGES/asn1_msg.h           |   37 +-
 openair2/RRC/NR/nr_rrc_config.c               |  136 -
 openair2/RRC/NR/nr_rrc_defs.h                 |   56 +-
 openair2/RRC/NR/nr_rrc_proto.h                |   35 +
 openair2/RRC/NR/rrc_gNB.c                     |  249 +-
 openair2/RRC/NR_UE/main_ue.c                  |    9 +-
 openair2/RRC/NR_UE/rrc_UE.c                   |  115 +-
 openair2/RRC/NR_UE/rrc_defs.h                 |    7 +-
 openair2/RRC/NR_UE/rrc_proto.h                |    4 +-
 openair2/X2AP/x2ap_eNB.c                      |  107 +-
 openair2/X2AP/x2ap_eNB_decoder.c              |   18 +-
 openair2/X2AP/x2ap_eNB_encoder.c              |    4 +-
 openair2/X2AP/x2ap_eNB_generate_messages.c    |  663 ++-
 openair2/X2AP/x2ap_eNB_generate_messages.h    |   11 +-
 openair2/X2AP/x2ap_eNB_handler.c              |  560 +-
 openair2/X2AP/x2ap_ids.h                      |    3 +-
 openair3/NAS/COMMON/UTIL/nas_log.h            |    9 +-
 openair3/NAS/UE/EMM/SecurityModeControl.c     |    2 +-
 openair3/NAS/UE/nas_itti_messaging.c          |    4 +-
 openair3/NAS/UE/nas_itti_messaging.h          |    2 +-
 openair3/UTILS/conversions.h                  |   10 +-
 targets/ARCH/COMMON/common_lib.c              |   35 +-
 targets/ARCH/COMMON/common_lib.h              |   18 +
 targets/ARCH/COMMON/record_player.h           |   15 +-
 targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp  |   67 +-
 targets/ARCH/iqplayer/iqplayer_lib.c          |   14 +-
 targets/ARCH/rfsimulator/simulator.c          |    2 +-
 targets/COMMON/openairinterface5g_limits.h    |   10 -
 .../CONF/gnb.band78.tm1.106PRB.usrpn300.conf  |  346 +-
 .../CONF/gnb.band78.tm1.106PRB.usrpx300.conf  |  340 +-
 .../CONF/gnb.band78.tm1.217PRB.usrpn300.conf  |  355 +-
 .../CONF/gnb.band78.tm1.217PRB.usrpx300.conf  |  340 +-
 .../CONF/gnb.band78.tm1.273PRB.usrpn300.conf  |  328 +-
 .../CONF/gnb.band78.tm1.beamw.usrpn300.conf   |  291 --
 targets/RT/USER/lte-ru.c                      |   14 +-
 targets/RT/USER/lte-softmodem.c               |    2 +-
 targets/RT/USER/lte-softmodem.h               |    2 +-
 targets/RT/USER/lte-ue.c                      |   81 +-
 targets/RT/USER/lte-uesoftmodem.c             |    2 +-
 230 files changed, 18879 insertions(+), 21345 deletions(-)
 delete mode 100644 openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h
 delete mode 100644 openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h
 delete mode 100644 openair1/PHY/CODING/nrLDPC_encoder/defs.h
 delete mode 100644 openair1/PHY/CODING/nr_compute_tbs.c
 delete mode 100644 openair1/PHY/NR_UE_TRANSPORT/nr_prach.h
 delete mode 100644 openair1/SCHED_NR_UE/phy_frame_config_nr.c
 delete mode 100644 targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.beamw.usrpn300.conf

diff --git a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf
index e71bb00ffbe..d92804ae444 100644
--- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf
+++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf
@@ -21,183 +21,166 @@ gNBs =
 
     ////////// Physical parameters:
 
-    component_carriers = (
-      {
-      node_function                                                 = "3GPP_gNODEB";
-      node_timing                                                   = "synch_to_ext_device";
-      node_synch_ref                                                = 0;
-      frame_type                                                    = "TDD";
-      DL_prefix_type                                                = "NORMAL";
-      UL_prefix_type                                                = "NORMAL";
-      eutra_band                                                    = 78;
-      downlink_frequency                                            = 3510000000L;
-      uplink_frequency_offset                                       = -120000000;
-      Nid_cell                                                      = 0;
-      N_RB_DL                                                       = 106;
-      nb_antenna_ports                                              = 1;
-      nb_antennas_tx                                                = 1;
-      nb_antennas_rx                                                = 1;
-      tx_gain                                                       = 90;
-      rx_gain                                                       = 125;
-      MIB_subCarrierSpacingCommon                                   = 30;
-      MIB_ssb_SubcarrierOffset                                      = 0;
-      MIB_dmrs_TypeA_Position                                       = 2;
-      pdcch_ConfigSIB1                                              = 0;
-      SIB1_frequencyOffsetSSB                                       = "khz5";
-      SIB1_ssb_PeriodicityServingCell                               = 5;
-      SIB1_ss_PBCH_BlockPower                                       = -60;
-      absoluteFrequencySSB                                          = 0;
-      DL_FreqBandIndicatorNR                                        = 15;
-      DL_absoluteFrequencyPointA                                    = 15;
-      DL_offsetToCarrier                                            = 15;
-      DL_SCS_SubcarrierSpacing                                      = "kHz30";
-      DL_SCS_SpecificCarrier_k0                                     = 0;
-      DL_carrierBandwidth                                           = 15;
-      DL_locationAndBandwidth                                       = 15;
-      DL_BWP_SubcarrierSpacing                                      = "kHz30";
-      DL_BWP_prefix_type                                            = "NORMAL";
-      UL_FreqBandIndicatorNR                                        = 15;
-      UL_absoluteFrequencyPointA                                    = 13;
-      UL_additionalSpectrumEmission                                 = 3;
-      UL_p_Max                                                      = -1;
-      UL_frequencyShift7p5khz                                       = "TRUE";
-      UL_offsetToCarrier                                            = 10;
-      UL_SCS_SubcarrierSpacing                                      = "kHz30";
-      UL_SCS_SpecificCarrier_k0                                     = 0;
-      UL_carrierBandwidth                                           = 15;
-      UL_locationAndBandwidth                                       = 15;
-      UL_BWP_SubcarrierSpacing                                      = "kHz30";
-      UL_BWP_prefix_type                                            = "NORMAL";
-      UL_timeAlignmentTimerCommon                                   = "infinity";
-      ServingCellConfigCommon_n_TimingAdvanceOffset                 = "n0"
-      ServingCellConfigCommon_ssb_PositionsInBurst_PR               = 0x01;
-      ServingCellConfigCommon_ssb_periodicityServingCell            = 10;
-      ServingCellConfigCommon_dmrs_TypeA_Position                   = 2;
-      NIA_SubcarrierSpacing                                         = "kHz15"; 
-      ServingCellConfigCommon_ss_PBCH_BlockPower                    = -60;
-      referenceSubcarrierSpacing                                    = "kHz15";
-      dl_UL_TransmissionPeriodicity                                 = "ms0p5";
-      nrofDownlinkSlots                                             = 10;
-      nrofDownlinkSymbols                                           = 10;
-      nrofUplinkSlots                                               = 10;
-      nrofUplinkSymbols                                             = 10;
-      rach_totalNumberOfRA_Preambles                                = 63;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice         = "oneEighth";
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth      = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth      = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf        = 16;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one            = 24;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two            = 32;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four           = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight          = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen        = 2;
-      rach_groupBconfigured                                         = "ENABLE";
-      rach_ra_Msg3SizeGroupA                                        = 56;
-      rach_messagePowerOffsetGroupB                                 = "dB0";
-      rach_numberOfRA_PreamblesGroupA                               = 32;
-      rach_ra_ContentionResolutionTimer                             = 8;
-      rsrp_ThresholdSSB                                             = 64;
-      rsrp_ThresholdSSB_SUL                                         = 64;
-      prach_RootSequenceIndex_choice                                = "l839";
-      prach_RootSequenceIndex_l839                                  = 0;
-      prach_RootSequenceIndex_l139                                  = 0;
-      prach_msg1_SubcarrierSpacing                                  = "kHz30";
-      restrictedSetConfig                                           = "unrestrictedSet";
-      msg3_transformPrecoding                                       = "ENABLE";
-      prach_ConfigurationIndex                                      = 10;
-      prach_msg1_FDM                                                = "one";
-      prach_msg1_FrequencyStart                                     = 10;
-      zeroCorrelationZoneConfig                                     = 10;
-      preambleReceivedTargetPower                                   = -150;
-      preambleTransMax                                              = 6;
-      powerRampingStep                                              = "dB0";
-      ra_ResponseWindow                                             = 8;
-      groupHoppingEnabledTransformPrecoding                         = "ENABLE";
-      msg3_DeltaPreamble                                            = 0;
-      p0_NominalWithGrant                                           = 0;
-      PUSCH_TimeDomainResourceAllocation_k2                         = 0;
-      PUSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PUSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      pucch_ResourceCommon                                          = 0;
-      pucch_GroupHopping                                            = "neither";
-      hoppingId                                                     = 0;
-      p0_nominal                                                    = -30;
-      PDSCH_TimeDomainResourceAllocation_k0                         = 2;
-      PDSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PDSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      rateMatchPatternId                                            = 0;
-      RateMatchPattern_patternType                                  = "bitmaps";
-      symbolsInResourceBlock                                        = "oneSlot";
-      periodicityAndPattern                                         = 2;
-      RateMatchPattern_controlResourceSet                           = 5;
-      RateMatchPattern_subcarrierSpacing                            = "kHz30";
-      RateMatchPattern_mode                                         = "dynamic";
-      controlResourceSetZero                                        = 0;
-      searchSpaceZero                                               = 0;
-      searchSpaceSIB1                                               = 10;
-      searchSpaceOtherSystemInformation                             = 10;
-      pagingSearchSpace                                             = 10;
-      ra_SearchSpace                                                = 10;
-      PDCCH_common_controlResourceSetId                             = 5;
-      PDCCH_common_ControlResourceSet_duration                      = 2;
-      PDCCH_cce_REG_MappingType                                     = "nonInterleaved";
-      PDCCH_reg_BundleSize                                          = 3;
-      PDCCH_interleaverSize                                         = 3;
-      PDCCH_shiftIndex                                              = 10;  
-      PDCCH_precoderGranularity                                     = "sameAsREG-bundle";
-      PDCCH_TCI_StateId                                             = 32;
-      tci_PresentInDCI                                              = "ENABLE";
-      PDCCH_DMRS_ScramblingID                                       = 0;
-      SearchSpaceId                                                 = 10;
-      commonSearchSpaces_controlResourceSetId                       = 5;
-      SearchSpace_monitoringSlotPeriodicityAndOffset_choice         = "sl1";
-      SearchSpace_monitoringSlotPeriodicityAndOffset_value          = 0;
-      SearchSpace_duration                                          = 2;
-      SearchSpace_nrofCandidates_aggregationLevel1                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel2                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel4                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel8                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel16                 = 0;
-      SearchSpace_searchSpaceType                                   = "common";
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16    = 1; 
-      Common_dci_Format2_3_monitoringPeriodicity                    = 1;
-      Common_dci_Format2_3_nrofPDCCH_Candidates                     = 1;
-      ue_Specific__dci_Formats                                      = "formats0-0-And-1-0";
-      RateMatchPatternLTE_CRS_carrierFreqDL                         = 6;
-      RateMatchPatternLTE_CRS_carrierBandwidthDL                    = 6;
-      RateMatchPatternLTE_CRS_nrofCRS_Ports                         = 1;
-      RateMatchPatternLTE_CRS_v_Shift                               = 0;
-      RateMatchPatternLTE_CRS_radioframeAllocationPeriod            = 1;
-      RateMatchPatternLTE_CRS_radioframeAllocationOffset            = 0;
-      RateMatchPatternLTE_CRS_subframeAllocation_choice             = "oneFrame";
-      }
-    );
-
-
-    srb1_parameters :
+    ssb_SubcarrierOffset                                      = 0;
+    pdsch_AntennaPorts                                        = 1;
+	
+    servingCellConfigCommon = (
     {
-        # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
-        timer_poll_retransmit    = 80;
+ #spCellConfigCommon
 
-        # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
-        timer_reordering         = 35;
+      physCellId                                                    = 0;
 
-        # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
-        timer_status_prohibit    = 0;
+#  downlinkConfigCommon
+    #frequencyInfoDL
+      # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP)
+      absoluteFrequencySSB                                          = 641032;
+      dl_frequencyBand                                                 = 78;
+      # this is 3600 MHz
+      dl_absoluteFrequencyPointA                                       = 640000;
+      #scs-SpecificCarrierList
+        dl_offstToCarrier                                              = 0;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        dl_subcarrierSpacing                                           = 1;
+        dl_carrierBandwidth                                            = 106;
+     #initialDownlinkBWP
+      #genericParameters
+        # this is RBstart=0,L=50 (275*(L-1))+RBstart
+        initialDLBWPlocationAndBandwidth                                        = 13475;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialDLBWPsubcarrierSpacing                                           = 1;
+      #pdcch-ConfigCommon
+        initialDLBWPcontrolResourceSetZero                                      = 12;
+        initialDLBWPsearchSpaceZero                                             = 0;
+      #pdsch-ConfigCommon
+        #pdschTimeDomainAllocationList (up to 16 entries)
+             initialDLBWPk0_0                    = 0;
+             #initialULBWPmappingType
+	     #0=typeA,1=typeB
+             initialDLBWPmappingType_0           = 0;
+             #this is SS=2,L=3
+             initialDLBWPstartSymbolAndLength_0  = 40;
 
-        # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
-        poll_pdu                 =  4;
+             initialDLBWPk0_1                    = 0;
+             initialDLBWPmappingType_1           = 0;
+             #this is SS=2,L=12 
+             initialDLBWPstartSymbolAndLength_1  = 53;
 
-        # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
-        poll_byte                =  99999;
+             initialDLBWPk0_2                    = 0;
+             initialDLBWPmappingType_2           = 0;
+             #this is SS=1,L=12 
+             initialDLBWPstartSymbolAndLength_2  = 54;
+  #uplinkConfigCommon 
+     #frequencyInfoUL
+      ul_frequencyBand                                                 = 78;
+      #scs-SpecificCarrierList
+      ul_offstToCarrier                                              = 0;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      ul_subcarrierSpacing                                           = 1;
+      ul_carrierBandwidth                                            = 106;
+      pMax                                                          = 20;
+     #initialUplinkBWP
+      #genericParameters
+        initialULBWPlocationAndBandwidth                                        = 13475;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialULBWPsubcarrierSpacing                                           = 1;
+      #rach-ConfigCommon
+        #rach-ConfigGeneric
+          prach_ConfigurationIndex                                  = 98;
+#prach_msg1_FDM
+#0 = one, 1=two, 2=four, 3=eight
+          prach_msg1_FDM                                            = 0;
+          prach_msg1_FrequencyStart                                 = 0;
+          zeroCorrelationZoneConfig                                 = 13;
+          preambleReceivedTargetPower                               = -118;
+#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200)
+          preambleTransMax                                          = 6;
+#powerRampingStep
+# 0=dB0,1=dB2,2=dB4,3=dB6
+        powerRampingStep                                            = 1;
+#ra_ReponseWindow
+#1,2,4,8,10,20,40,80
+        ra_ResponseWindow                                           = 4;
+#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR
+#0=oneeighth,1=onefourth,2=half,3=one,4=two,5=four,6=eight,7=sixteen
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR                = 3;
+#oneHalf (0..15) 4,8,12,16,...60,64
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB                   = 15;
+#ra_ContentionResolutionTimer
+#(0..7) 8,16,24,32,40,48,56,64
+        ra_ContentionResolutionTimer                                = 7;
+        rsrp_ThresholdSSB                                           = 19;
+#prach-RootSequenceIndex_PR
+#0 = 839, 1 = 139
+        prach_RootSequenceIndex_PR                                  = 1;
+        prach_RootSequenceIndex                                     = 1;
+        # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex
+        #  
+        msg1_SubcarrierSpacing                                      = 1,
+
+# restrictedSetConfig
+# 0=unrestricted, 1=restricted type A, 2=restricted type B
+        restrictedSetConfig                                         = 0,
+      # pusch-ConfigCommon (up to 16 elements)
+        initialULBWPk2_0                      = 2;
+        initialULBWPmappingType_0             = 1
+        # this is SS=0 L=11
+        initialULBWPstartSymbolAndLength_0    = 55;
+ 	
+	initialULBWPk2_1                      = 2;
+        initialULBWPmappingType_1             = 1;
+        # this is SS=0 L=12
+        initialULBWPstartSymbolAndLength_1    = 69;
+
+
+        msg3_DeltaPreamble                                          = 1;
+        p0_NominalWithGrant                                         =-90;
+
+# pucch-ConfigCommon setup :
+# pucchGroupHopping
+# 0 = neither, 1= group hopping, 2=sequence hopping
+        pucchGroupHopping                                           = 0;
+        hoppingId                                                   = 40;
+        p0_nominal                                                  = -90;
+# ssb_PositionsInBurs_BitmapPR
+# 1=short, 2=medium, 3=long
+      ssb_PositionsInBurst_PR                                       = 2;
+      ssb_PositionsInBurst_Bitmap                                   = 1;
+
+# ssb_periodicityServingCell
+# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 
+      ssb_periodicityServingCell                                    = 2;
+
+# dmrs_TypeA_position
+# 0 = pos2, 1 = pos3
+      dmrs_TypeA_Position                                           = 0;
+
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      subcarrierSpacing                                             = 1;
+
+
+  #tdd-UL-DL-ConfigurationCommon
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      referenceSubcarrierSpacing                                    = 1;
+      # pattern1 
+      # dl_UL_TransmissionPeriodicity
+      # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10
+      dl_UL_TransmissionPeriodicity                                 = 6;
+      nrofDownlinkSlots                                             = 7;
+      nrofDownlinkSymbols                                           = 6;
+      nrofUplinkSlots                                               = 2;
+      nrofUplinkSymbols                                             = 4;
+
+  ssPBCH_BlockPower                                             = 10;
+  }
+
+  );
 
-        # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
-        max_retx_threshold       =  4;
-    }
 
     # ------- SCTP definitions
     SCTP :
@@ -254,8 +237,8 @@ RUs = (
          max_pdschReferenceSignalPower = -27;
          max_rxgain                    = 114;
          eNB_instances  = [0];
-	 sdr_addrs = "addr=192.168.20.2,second_addr=192.168.10.2,mgmt_addr=192.168.20.2,clock_source=external,time_source=external";
-
+	 sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2";
+         clock_src = "external";
     }
 );  
 
@@ -268,16 +251,6 @@ THREAD_STRUCT = (
   }
 );
 
-NETWORK_CONTROLLER :
-{
-    FLEXRAN_ENABLED        = "no";
-    FLEXRAN_INTERFACE_NAME = "lo";
-    FLEXRAN_IPV4_ADDRESS   = "127.0.0.1";
-    FLEXRAN_PORT           = 2210;
-    FLEXRAN_CACHE          = "/mnt/oai_agent_cache";
-    FLEXRAN_AWAIT_RECONF   = "no";
-};
-
      log_config :
      {
        global_log_level                      ="info";
diff --git a/ci-scripts/main.py b/ci-scripts/main.py
index 95360cae8f9..21d51105f85 100644
--- a/ci-scripts/main.py
+++ b/ci-scripts/main.py
@@ -1044,6 +1044,12 @@ class SSHConnection():
 			logging.debug('Found a N3xx device --> resetting it')
 		self.command('cd ' + self.UESourceCodePath, '\$', 5)
 		# Initialize_OAI_UE_args usually start with -C and followed by the location in repository
+		# in case of NR-UE, we may have rrc_config_path (Temporary?)
+		modifiedUeOptions = str(self.Initialize_OAI_UE_args)
+		if self.air_interface == 'nr':
+			result = re.search('--rrc_config_path ', modifiedUeOptions)
+			if result is not None:
+				modifiedUeOptions = modifiedUeOptions.replace('rrc_config_path ', 'rrc_config_path ' + self.UESourceCodePath + '/')
 		self.command('source oaienv', '\$', 5)
 		self.command('cd cmake_targets/ran_build/build', '\$', 5)
 		if self.air_interface == 'lte':
@@ -1058,7 +1064,7 @@ class SSHConnection():
 					self.command('sed -e "s#93#92#" -e "s#8baf473f2f8fd09487cccbd7097c6862#fec86ba6eb707ed08905757b1bb44b8f#" -e "s#e734f8734007d6c5ce7a0508809e7e9c#C42449363BBAD02B66D16BC975D77CC1#" ../../../openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf > ../../../openair3/NAS/TOOLS/ci-ue_eurecom_test_sfr.conf', '\$', 5)
 				self.command('echo ' + self.UEPassword + ' | sudo -S rm -Rf .u*', '\$', 5)
 				self.command('echo ' + self.UEPassword + ' | sudo -S ../../../targets/bin/conf2uedata -c ../../../openair3/NAS/TOOLS/ci-ue_eurecom_test_sfr.conf -o .', '\$', 5)
-		self.command('echo "ulimit -c unlimited && ./'+ self.air_interface +'-uesoftmodem ' + self.Initialize_OAI_UE_args + '" > ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh', '\$', 5)
+		self.command('echo "ulimit -c unlimited && ./'+ self.air_interface +'-uesoftmodem ' + modifiedUeOptions + '" > ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh', '\$', 5)
 		self.command('chmod 775 ./my-lte-uesoftmodem-run' + str(self.UE_instance) + '.sh', '\$', 5)
 		self.command('echo ' + self.UEPassword + ' | sudo -S rm -Rf ' + self.UESourceCodePath + '/cmake_targets/ue_' + self.testCase_id + '.log', '\$', 5)
 		self.UELogFile = 'ue_' + self.testCase_id + '.log'
@@ -1105,6 +1111,9 @@ class SSHConnection():
 				if result is not None:
 					self.command('echo ' + self.UEPassword + ' | sudo -S killall --signal=SIGINT -r *-uesoftmodem', '\$', 4)
 					time.sleep(3)
+				outterLoopCounter = outterLoopCounter - 1
+				if (outterLoopCounter == 0):
+					doOutterLoop = False
 				continue
 			if self.air_interface == 'nr':
 				fullSyncStatus = True
diff --git a/ci-scripts/oai-ci-vm-tool b/ci-scripts/oai-ci-vm-tool
index 485c22902ea..9d6349077f0 100755
--- a/ci-scripts/oai-ci-vm-tool
+++ b/ci-scripts/oai-ci-vm-tool
@@ -182,7 +182,7 @@ function variant__v2__basic_sim {
 }
 
 function variant__v3__phy_sim {
-    NB_PATTERN_FILES=12
+    NB_PATTERN_FILES=13
     BUILD_OPTIONS="--phy_simulators"
     VM_MEMORY=8192
     VM_DISK=20
diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh
index d46ed07bbb2..502c1a5d479 100755
--- a/ci-scripts/runTestOnVM.sh
+++ b/ci-scripts/runTestOnVM.sh
@@ -613,8 +613,11 @@ function start_epc {
         echo "############################################################"
         echo "echo \"cd /opt/hss_sim0609\"" > $LOC_EPC_VM_CMDS
         echo "cd /opt/hss_sim0609" >> $LOC_EPC_VM_CMDS
-        echo "echo \"sudo daemon --unsafe --name=simulated_hss --chdir=/opt/hss_sim0609 ./starthss_real\"" >> $LOC_EPC_VM_CMDS
-        echo "sudo daemon --unsafe --name=simulated_hss --chdir=/opt/hss_sim0609 ./starthss_real" >> $LOC_EPC_VM_CMDS
+        echo "sudo rm -f hss.log" >> $LOC_EPC_VM_CMDS
+        #echo "echo \"sudo daemon --unsafe --name=simulated_hss --chdir=/opt/hss_sim0609 ./starthss_real\"" >> $LOC_EPC_VM_CMDS
+        #echo "sudo daemon --unsafe --name=simulated_hss --chdir=/opt/hss_sim0609 ./starthss_real" >> $LOC_EPC_VM_CMDS
+        echo "echo \"screen -dm -S simulated_hss ./starthss_real\"" >> $LOC_EPC_VM_CMDS
+        echo "sudo su -c \"screen -dm -S simulated_hss ./starthss_real\"" >> $LOC_EPC_VM_CMDS
 
         echo "echo \"cd /opt/ltebox/tools/\"" >> $LOC_EPC_VM_CMDS
         echo "cd /opt/ltebox/tools/" >> $LOC_EPC_VM_CMDS
@@ -870,9 +873,9 @@ function start_l2_sim_ue {
     echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1
     if [ $LOC_S1_CONFIGURATION -eq 0 ]
     then
-        echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --L2-emul 3 --num-ues $LOC_NB_UES --nums_ue_thread $LOC_NB_UES --nokrnmod 1 --log_config.global_log_options level,nocolor --noS1\" > ./my-lte-softmodem-run.sh " >> $1
+        echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --L2-emul 3 --num-ues $LOC_NB_UES --nums_ue_thread 1 --nokrnmod 1 --log_config.global_log_options level,nocolor --noS1\" > ./my-lte-softmodem-run.sh " >> $1
     else
-        echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --L2-emul 3 --num-ues $LOC_NB_UES --nums_ue_thread $LOC_NB_UES --nokrnmod 1 --log_config.global_log_options level,nocolor\" > ./my-lte-softmodem-run.sh " >> $1
+        echo "echo \"ulimit -c unlimited && ./lte-uesoftmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --L2-emul 3 --num-ues $LOC_NB_UES --nums_ue_thread 1 --nokrnmod 1 --log_config.global_log_options level,nocolor\" > ./my-lte-softmodem-run.sh " >> $1
     fi
     echo "chmod 775 ./my-lte-softmodem-run.sh" >> $1
     echo "cat ./my-lte-softmodem-run.sh" >> $1
@@ -905,8 +908,9 @@ function start_l2_sim_ue {
     else
         echo "L2-SIM UE is sync'ed w/ eNB"
     fi
-    local max_interfaces_to_check=1
-    if [ $LOC_S1_CONFIGURATION -eq 0 ]; then max_interfaces_to_check=$LOC_NB_UES; fi
+    local max_interfaces_to_check=$LOC_NB_UES
+    #local max_interfaces_to_check=1
+    #if [ $LOC_S1_CONFIGURATION -eq 0 ]; then max_interfaces_to_check=$LOC_NB_UES; fi
     local j="1"
     while [ $j -le $max_interfaces_to_check ]
     do
@@ -1195,7 +1199,7 @@ function start_rf_sim_gnb {
     echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1
     if [ $LOC_S1_CONFIGURATION -eq 0 ]
     then
-        echo "echo \"RFSIMULATOR=server ./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --noS1 --nokrnmod 1 --rfsim\" > ./my-nr-softmodem-run.sh " >> $1
+        echo "echo \"RFSIMULATOR=server ./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --noS1 --nokrnmod 1 --rfsim --phy-test\" > ./my-nr-softmodem-run.sh " >> $1
     fi
     echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1
     echo "cat ./my-nr-softmodem-run.sh" >> $1
@@ -1270,7 +1274,7 @@ function start_rf_sim_nr_ue {
     echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1
     if [ $LOC_S1_CONFIGURATION -eq 0 ]
     then
-        echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR}  ./nr-uesoftmodem --numerology 1 -C ${LOC_FREQUENCY}000000 -r $LOC_PRB --nokrnmod 1 --rfsim --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1
+        echo "echo \"RFSIMULATOR=${LOC_GNB_VM_IP_ADDR}  ./nr-uesoftmodem --nokrnmod 1 --rfsim --phy-test --rrc_config_path /home/ubuntu/tmp/ci-scripts/rrc-files --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1
     fi
     echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1
     echo "cat ./my-nr-softmodem-run.sh" >> $1
@@ -1281,7 +1285,7 @@ function start_rf_sim_nr_ue {
     rm $1
 
     local i="0"
-    echo "egrep -c \"rfsimulator: Success\" /home/ubuntu/tmp/cmake_targets/log/$LOC_LOG_FILE" > $1
+    echo "egrep -c \"Initial sync: pbch decoded sucessfully\" /home/ubuntu/tmp/cmake_targets/log/$LOC_LOG_FILE" > $1
     while [ $i -lt 10 ]
     do
         sleep 5
@@ -2214,15 +2218,41 @@ function run_test_on_vm {
 
                 if [ $S1_NOS1_CFG -eq 1 ]
                 then
-                    get_ue_ip_addr $UE_VM_CMDS $UE_VM_IP_ADDR 1
 
                     echo "############################################################"
                     echo "${CN_CONFIG} : Pinging the EPC from UE(s)"
                     echo "############################################################"
-                    PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_epc.log
-                    ping_epc_ip_addr $UE_VM_CMDS $UE_VM_IP_ADDR $REAL_EPC_IP_ADDR $PING_LOG_FILE 1 0
-                    scp -o StrictHostKeyChecking=no ubuntu@$UE_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC
-                    check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20
+                    echo " --- Sequentially ---"
+                    local j="1"
+                    while [ $j -le $INT_NB_UES ]
+                    do
+                        PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_epc_seq_from_ue${j}.log
+                        ping_epc_ip_addr $UE_VM_CMDS $UE_VM_IP_ADDR $REAL_EPC_IP_ADDR $PING_LOG_FILE ${j} 0
+                        scp -o StrictHostKeyChecking=no ubuntu@$UE_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC
+                        check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20
+                        j=$[$j+1]
+                    done
+                    if [ $INT_NB_UES -gt 1 ]
+                    then
+                        echo " --- In parallel ---"
+                        j="1"
+                        while [ $j -le $INT_NB_UES ]
+                        do
+                            PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_epc_para_from_ue${j}.log
+                            ping_epc_ip_addr $UE_VM_CMDS $UE_VM_IP_ADDR $REAL_EPC_IP_ADDR $PING_LOG_FILE ${j} 1
+                            j=$[$j+1]
+                        done
+                        sleep 25
+                        j="1"
+                        while [ $j -le $INT_NB_UES ]
+                        do
+                            PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_epc_para_from_ue${j}.log
+                            scp -o StrictHostKeyChecking=no ubuntu@$UE_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC
+                            tail -3 $ARCHIVES_LOC/$PING_LOG_FILE
+                            check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20
+                            j=$[$j+1]
+                        done
+                    fi
                 else
                     get_enb_noS1_ip_addr $ENB_VM_CMDS $ENB_VM_IP_ADDR
 
@@ -2267,10 +2297,38 @@ function run_test_on_vm {
                     echo "############################################################"
                     echo "${CN_CONFIG} : Pinging the UE(s) from EPC"
                     echo "############################################################"
-                    PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_ue.log
-                    ping_ue_ip_addr $EPC_VM_CMDS $EPC_VM_IP_ADDR $UE_IP_ADDR $PING_LOG_FILE 0
-                    scp -o StrictHostKeyChecking=no ubuntu@$EPC_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC
-                    check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20
+                    echo " --- Sequentially ---"
+                    local j="1"
+                    while [ $j -le $INT_NB_UES ]
+                    do
+                        get_ue_ip_addr $UE_VM_CMDS $UE_VM_IP_ADDR $j
+                        PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_from_epc_seq_ue${j}.log
+                        ping_ue_ip_addr $EPC_VM_CMDS $EPC_VM_IP_ADDR $UE_IP_ADDR $PING_LOG_FILE 0
+                        scp -o StrictHostKeyChecking=no ubuntu@$EPC_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC
+                        check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20
+                        j=$[$j+1]
+                    done
+                    if [ $INT_NB_UES -gt 1 ]
+                    then
+                        echo " --- In parallel ---"
+                        j="1"
+                        while [ $j -le $INT_NB_UES ]
+                        do
+                            get_ue_ip_addr $UE_VM_CMDS $UE_VM_IP_ADDR $j
+                            PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_from_epc_para_ue${j}.log
+                            ping_ue_ip_addr $EPC_VM_CMDS $EPC_VM_IP_ADDR $UE_IP_ADDR $PING_LOG_FILE 1
+                            j=$[$j+1]
+                        done
+                        sleep 25
+                        j="1"
+                        while [ $j -le $INT_NB_UES ]
+                        do
+                            PING_LOG_FILE=${TMODE}_${BW}MHz_${UES}users_${CN_CONFIG}_ping_from_epc_para_ue${j}.log
+                            scp -o StrictHostKeyChecking=no ubuntu@$EPC_VM_IP_ADDR:/home/ubuntu/$PING_LOG_FILE $ARCHIVES_LOC
+                            check_ping_result $ARCHIVES_LOC/$PING_LOG_FILE 20
+                            j=$[$j+1]
+                        done
+                    fi
                 else
                     echo "############################################################"
                     echo "${CN_CONFIG} : Pinging the UE(s) from eNB"
@@ -2310,7 +2368,7 @@ function run_test_on_vm {
                     fi
                 fi
 
-                if [ $S1_NOS1_CFG -eq 2 ]
+                if [ $S1_NOS1_CFG -eq 0 ]
                 then
                     get_enb_noS1_ip_addr $ENB_VM_CMDS $ENB_VM_IP_ADDR
                     echo "############################################################"
diff --git a/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml b/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml
index 03220ec2865..f3e80c576ac 100644
--- a/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml
+++ b/ci-scripts/xml_files/gnb_nr_ue_usrp_run.xml
@@ -24,7 +24,7 @@
         <htmlTabRef>run-oai-gnb-nr-ue</htmlTabRef>
         <htmlTabName>Run-gNB-and-NR-UE</htmlTabName>
         <htmlTabIcon>tasks</htmlTabIcon>	
-	<repeatCount>4</repeatCount>
+	<repeatCount>2</repeatCount>
 	<TestCaseRequestedList>
 090101 000001 090102 000002 090108 090109
 	</TestCaseRequestedList>
@@ -33,7 +33,7 @@
         <testCase id="090101">
                 <class>Initialize_eNB</class>
                 <desc>Initialize gNB USRP</desc>
-		<Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf</Initialize_eNB_args>
+		<Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test</Initialize_eNB_args>
 		<air_interface>NR</air_interface>
         </testCase>
 
@@ -52,7 +52,7 @@
         <testCase id="090102">
                 <class>Initialize_OAI_UE</class>
                 <desc>Initialize NR UE USRP</desc>
-		<Initialize_OAI_UE_args>-C 3510000000 --numerology 1 -r 106 --phy-test --usrp-args "addr=192.168.30.2,clock_source=external,time_source=external" --threadoffset 16</Initialize_OAI_UE_args>
+		<Initialize_OAI_UE_args>--phy-test --usrp-args "addr=192.168.30.2,second_addr=192.168.50.2,clock_source=external,time_source=external" --threadoffset 16 --rrc_config_path ci-scripts/rrc-files</Initialize_OAI_UE_args>
 		<air_interface>NR</air_interface>
         </testCase>
 
diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index a7d8a34ffcf..72c7d319db4 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -146,7 +146,7 @@ endfunction()
 
 #set(CMAKE_BUILD_TYPE "Debug")
 if (CMAKE_BUILD_TYPE STREQUAL "")
-   set(CMAKE_BUILD_TYPE "Release")
+   set(CMAKE_BUILD_TYPE "RelWithDebInfo")
 endif()
 message("CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")
 add_list_string_option(CMAKE_BUILD_TYPE "RelWithDebInfo" "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." Debug Release RelWithDebInfo MinSizeRel)
@@ -245,6 +245,7 @@ set (FIRMWARE_VERSION "No svn information")
 add_definitions("-DFIRMWARE_VERSION=\"${FIRMWARE_VERSION}\"")
 add_definitions("-DPACKAGE_VERSION=\"Branch: ${GIT_BRANCH} Abrev. Hash: ${GIT_COMMIT_HASH} Date: ${GIT_COMMIT_DATE}\"")
 add_definitions("-DPACKAGE_BUGREPORT=\"openair4g-devel@lists.eurecom.fr\"")
+#add_definitions("-DEMIT_ASN_DEBUG=1")
 
 
 # Debug related options
@@ -330,7 +331,7 @@ set (NR_RRC_ASN1_VERSION "NR_Rel15" )
 make_version(NR_RRC_VERSION 15 6 0)
 set (NR_RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/NR/MESSAGES/asn1c/ASN1_files/nr-rrc-15.6.0.asn1)
 add_definitions(-DNR_RRC_VERSION=${NR_RRC_VERSION})
-set (NR_RRC_FULL_DIR ${asn1_generated_dir}/${NR_RRC_ASN1_VERSION})
+set (NR_RRC_FULL_DIR ${asn1_generated_dir}/RRC_${NR_RRC_ASN1_VERSION})
 
 # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
 execute_process(COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${NR_RRC_FULL_DIR}" "${NR_RRC_GRAMMAR}" "NR_" "-findirect-choice"
@@ -1199,6 +1200,8 @@ set(SCHED_NR_SRC
   ${OPENAIR1_DIR}/SCHED_NR/fapi_nr_l1.c
   ${OPENAIR1_DIR}/SCHED_NR/phy_procedures_nr_common.c
   ${OPENAIR1_DIR}/SCHED_NR/phy_procedures_nr_gNB.c
+  ${OPENAIR1_DIR}/SCHED_NR/nr_prach_procedures.c
+  ${OPENAIR1_DIR}/SCHED_NR/phy_frame_config_nr.c
 )
 add_library(SCHED_NR_LIB ${SCHED_NR_SRC})
 
@@ -1224,7 +1227,7 @@ set(SCHED_SRC_NR_UE
   ${OPENAIR1_DIR}/SCHED_NR_UE/phy_procedures_nr_ue.c
   ${OPENAIR1_DIR}/SCHED_NR/phy_procedures_nr_common.c
   ${OPENAIR1_DIR}/SCHED_NR_UE/fapi_nr_ue_l1.c 
-  ${OPENAIR1_DIR}/SCHED_NR_UE/phy_frame_config_nr.c
+  ${OPENAIR1_DIR}/SCHED_NR/phy_frame_config_nr.c
   ${OPENAIR1_DIR}/SCHED_NR_UE/harq_nr.c
   ${OPENAIR1_DIR}/SCHED_NR_UE/pucch_uci_ue_nr.c
   ${OPENAIR1_DIR}/SCHED_NR_UE/pucch_power_control_ue_nr.c 
@@ -1317,15 +1320,36 @@ set(PHY_SMALLBLOCKSRC
 set(PHY_TURBOIF
   ${OPENAIR1_DIR}/PHY/CODING/coding_load.c
 )
-set(PHY_LDPCSRC
+
+set(PHY_LDPC_ORIG_SRC
   ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c
   ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu
   ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder.c
-  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c
-  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c
 )
 
+set(PHY_LDPC_OPTIM_SRC
+  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c
+  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim.c
+)
+set(PHY_LDPC_OPTIM8SEG_SRC
+  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c
+  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8seg.c
+)
+set(PHY_LDPC_OPTIM8SEGMULTI_SRC
+  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c
+  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder_optim8segmulti.c
+)
+set(PHY_NR_CODINGIF
+  ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_load.c;
+)
+
+add_library(ldpc_orig MODULE ${PHY_LDPC_ORIG_SRC} )
+add_library(ldpc_optim MODULE ${PHY_LDPC_OPTIM_SRC} )
+add_library(ldpc_optim8seg MODULE ${PHY_LDPC_OPTIM8SEG_SRC} )
+add_library(ldpc MODULE ${PHY_LDPC_OPTIM8SEGMULTI_SRC} )
+
 add_library(coding MODULE ${PHY_TURBOSRC} )
+
 set(PHY_SRC_COMMON
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci_tools_common.c
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/lte_mcs.c
@@ -1353,7 +1377,6 @@ set(PHY_SRC_COMMON
   ${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_ul_ref.c
   ${OPENAIR1_DIR}/PHY/CODING/lte_segmentation.c
   ${OPENAIR1_DIR}/PHY/CODING/nr_segmentation.c
-  ${OPENAIR1_DIR}/PHY/CODING/nr_compute_tbs.c
   ${OPENAIR1_DIR}/PHY/CODING/nr_rate_matching.c
   ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte.c
   ${OPENAIR1_DIR}/PHY/CODING/ccoding_byte_lte.c
@@ -1466,6 +1489,11 @@ set(PHY_SRC_UE
   ${OPENAIR1_DIR}/PHY/INIT/lte_init_ue.c
   )
 
+  set(PHY_NR_SRC_COMMON
+  ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_prach_common.c
+  ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_dci_tools_common.c
+  )
+
   set(PHY_NR_SRC
   ${OPENAIR1_DIR}/PHY/INIT/nr_init.c
   ${OPENAIR1_DIR}/PHY/INIT/nr_parms.c
@@ -1482,11 +1510,13 @@ set(PHY_SRC_UE
   ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_ulsch.c
   ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_tbs_tools.c
   ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_sch_dmrs.c
+  ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_prach.c
   ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_ulsch_llr_computation.c
   ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_dmrs_rx.c
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold.c
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/dmrs_nr.c
+  ${OPENAIR1_DIR}/PHY/NR_REFSIG/ptrs_nr.c
   ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/filt16a_32.c
   ${OPENAIR1_DIR}/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c
   ${OPENAIR1_DIR}/PHY/NR_ESTIMATION/nr_adjust_sync_gNB.c
@@ -1504,10 +1534,9 @@ set(PHY_SRC_UE
   ${OPENAIR1_DIR}/PHY/TOOLS/lut.c
   ${PHY_POLARSRC}
   ${PHY_SMALLBLOCKSRC}
-  ${PHY_LDPCSRC}
+  ${PHY_NR_CODINGIF}
   ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/pucch_rx.c 
   )
-
   set(PHY_NR_UE_SRC
   ${OPENAIR1_DIR}/PHY/INIT/nr_parms.c
   ${OPENAIR1_DIR}/PHY/MODULATION/nr_modulation.c
@@ -1522,6 +1551,7 @@ set(PHY_SRC_UE
   ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
   ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c
   ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_tbs_tools.c
+  ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_prach_common.c
   ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_sch_dmrs.c
   ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/
   ${OPENAIR1_DIR}/PHY/NR_UE_TRANSPORT/nr_prach.c
@@ -1533,6 +1563,7 @@ set(PHY_SRC_UE
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/ul_ref_seq_nr.c
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_dmrs_rx.c
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/dmrs_nr.c
+  ${OPENAIR1_DIR}/PHY/NR_REFSIG/ptrs_nr.c
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold_ue.c
   ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/filt16a_32.c
   ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
@@ -1555,7 +1586,7 @@ set(PHY_SRC_UE
   #  ${OPENAIR1_DIR}/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c
   ${PHY_POLARSRC}
   ${PHY_SMALLBLOCKSRC}
-  ${PHY_LDPCSRC}
+  ${PHY_NR_CODINGIF}
   )
 
 
@@ -1578,6 +1609,7 @@ add_library(PHY ${PHY_SRC})
 add_dependencies(PHY rrc_flag)
 add_library(PHY_UE ${PHY_SRC_UE})
 add_dependencies(PHY_UE rrc_flag)
+add_library(PHY_NR_COMMON ${PHY_NR_SRC_COMMON})
 add_library(PHY_NR ${PHY_NR_SRC})
 add_library(PHY_NR_UE ${PHY_NR_UE_SRC})
 
@@ -1677,6 +1709,7 @@ set(L2_SRC
   ${PDCP_DIR}/pdcp_netlink.c
 #  ${RRC_DIR}/rrc_UE.c
   ${RRC_DIR}/rrc_eNB.c
+  ${RRC_DIR}/rrc_eNB_endc.c
   ${RRC_DIR}/rrc_eNB_S1AP.c
   ${RRC_DIR}/rrc_eNB_M2AP.c
   ${RRC_DIR}/rrc_eNB_UE_context.c
@@ -1696,6 +1729,10 @@ set(L2_NR_SRC
   ${NR_RRC_DIR}/nr_rrc_common.c
   ${NR_RRC_DIR}/L2_nr_interface.c
   ${NR_RRC_DIR}/nr_rrc_config.c
+  ${NR_RRC_DIR}/rrc_gNB_nsa.c
+  ${NR_RRC_DIR}/rrc_gNB_internode.c
+  ${NR_RRC_DIR}/rrc_gNB_reconfig.c
+  ${NR_RRC_DIR}/rrc_gNB_UE_context.c
   )
 
 set(L2_SRC_UE
@@ -1784,6 +1821,7 @@ set (MAC_NR_SRC_UE
   ${NR_UE_MAC_DIR}/mac_vars.c
   ${NR_UE_MAC_DIR}/main_ue_nr.c
   ${NR_UE_MAC_DIR}/nr_ue_procedures.c
+  ${NR_UE_MAC_DIR}/nr_ue_dci_configuration.c
 )
 
 set (ENB_APP_SRC
@@ -1844,7 +1882,7 @@ add_dependencies(L2_UE rrc_flag s1ap_flag x2_flag)
 
 add_library( NR_L2_UE ${NR_L2_SRC_UE} ${MAC_NR_SRC_UE} )
 
-add_library( MAC_NR_COMMON ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c )
+add_library( MAC_NR_COMMON ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c ${OPENAIR2_DIR}/LAYER2/NR_MAC_gNB/nr_compute_tbs_common.c)
 
 include_directories("${OPENAIR2_DIR}/NR_UE_PHY_INTERFACE")
 include_directories("${OPENAIR2_DIR}/LAYER2/NR_MAC_UE")
@@ -2484,7 +2522,7 @@ add_dependencies(lte-softmodem rrc_flag s1ap_flag x2_flag oai_iqplayer)
 
 target_link_libraries (lte-softmodem
   -Wl,--start-group
-  RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB 
+  RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB 
   PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7
   ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB}
   -Wl,--end-group z dl)
@@ -2588,6 +2626,7 @@ add_executable(nr-softmodem
   ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
   ${OPENAIR_DIR}/common/utils/utils.c
   ${OPENAIR_DIR}/common/utils/system.c
+  ${OPENAIR_DIR}/common/utils/nr/nr_common.c
   ${GTPU_need_ITTI}
   ${XFORMS_SOURCE_NR}
   ${T_SOURCE}
@@ -2597,7 +2636,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
+  UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_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 NR_RRC_LIB 
   S1AP_LIB S1AP_ENB L2 L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
   X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB}
@@ -2608,7 +2647,7 @@ target_link_libraries (nr-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LI
 target_link_libraries (nr-softmodem ${LIB_LMS_LIBRARIES})
 target_link_libraries (nr-softmodem ${T_LIB})
 
-
+add_dependencies( nr-softmodem ldpc_orig ldpc_optim ldpc_optim8seg ldpc )
 # nr-uesoftmodem is  UE implementation
 #######################################
 
@@ -2624,11 +2663,13 @@ add_executable(nr-uesoftmodem
   ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
   ${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c
   ${OPENAIR2_DIR}/RRC/NAS/nas_config.c
+  ${OPENAIR2_DIR}/LAYER2/NR_MAC_COMMON/nr_mac_common.c
   ${OPENAIR2_DIR}/RRC/NAS/rb_config.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
+  ${OPENAIR_DIR}/common/utils/nr/nr_common.c
   ${XFORMS_SOURCE_NR}
   ${T_SOURCE}
   ${UTIL_SRC}
@@ -2640,7 +2681,7 @@ target_link_libraries (nr-uesoftmodem
   -Wl,--start-group
   RRC_LIB NR_RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB
   ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} 
-  PHY_COMMON PHY_UE PHY_NR_UE PHY_RU LFDS L2_UE NR_L2_UE MAC_NR_COMMON S1AP_LIB S1AP_ENB
+  PHY_COMMON PHY_NR_COMMON PHY_UE PHY_NR_UE PHY_RU LFDS L2_UE NR_L2_UE MAC_NR_COMMON S1AP_LIB S1AP_ENB
   NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
   -Wl,--end-group z dl)
 
@@ -2649,7 +2690,7 @@ target_link_libraries (nr-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_
 target_link_libraries (nr-uesoftmodem ${LIB_LMS_LIBRARIES})
 target_link_libraries (nr-uesoftmodem ${T_LIB})
 
-
+add_dependencies( nr-uesoftmodem ldpc_orig ldpc_optim ldpc_optim8seg ldpc )
 
 # USIM process
 #################
@@ -2696,25 +2737,33 @@ target_link_libraries (dlsim_tm4
 
 add_executable(polartest 
   ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/polartest.c
+  ${OPENAIR_DIR}/common/utils/backtrace.c
+  ${OPENAIR_DIR}/common/utils/nr/nr_common.c
   ${OPENAIR_DIR}/common/utils/system.c
   ${T_SOURCE}
   ${SHLIB_LOADER_SOURCES}
   )
 target_link_libraries(polartest
-  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE CONFIG_LIB -Wl,--end-group
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_COMMON PHY_NR_UE CONFIG_LIB -Wl,--end-group
   m pthread ${ATLAS_LIBRARIES} dl
   )
 
 add_executable(smallblocktest 
   ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/smallblocktest.c
+  ${OPENAIR_DIR}/common/utils/backtrace.c
+  ${OPENAIR_DIR}/common/utils/nr/nr_common.c
+  ${OPENAIR_DIR}/common/utils/system.c
   ${T_SOURCE}
   ${SHLIB_LOADER_SOURCES}
-  )
+)
+
+
 target_link_libraries(smallblocktest
-  -Wl,--start-group UTIL SIMU PHY_NR CONFIG_LIB -Wl,--end-group
+  -Wl,--start-group UTIL SIMU PHY_NR PHY_COMMON PHY_NR_COMMON CONFIG_LIB -Wl,--end-group
   m pthread ${ATLAS_LIBRARIES} dl
   )
 
+<<<<<<< HEAD
 ###################################################
 # For CUDA library 
 ###################################################
@@ -2723,15 +2772,26 @@ CUDA_ADD_LIBRARY(LDPC_CU
   )
 
 cuda_add_executable(ldpctest
+=======
+add_executable(ldpctest  
+  ${PHY_NR_CODINGIF}
+>>>>>>> origin/develop
   ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c
   ${T_SOURCE}
   ${SHLIB_LOADER_SOURCES}
   )
+<<<<<<< HEAD
 
 target_link_libraries(ldpctest -ldl
   -Wl,--start-group 
   LDPC_CU UTIL SIMU PHY_NR CONFIG_LIB 
   -Wl,--end-group
+=======
+add_dependencies( ldpctest ldpc_orig ldpc_optim ldpc_optim8seg ldpc ) 
+
+target_link_libraries(ldpctest
+  -Wl,--start-group UTIL SIMU PHY_NR PHY_COMMON PHY_NR_COMMON CONFIG_LIB -Wl,--end-group
+>>>>>>> origin/develop
   m pthread ${ATLAS_LIBRARIES} dl
   )
 #add_executable(ldpctest  
@@ -2752,7 +2812,7 @@ add_executable(nr_dlschsim
   ${SHLIB_LOADER_SOURCES}
   )
 target_link_libraries(nr_dlschsim 
-  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
   m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl
   )
 
@@ -2764,35 +2824,50 @@ add_executable(nr_pbchsim
   ${SHLIB_LOADER_SOURCES}
   )
 target_link_libraries(nr_pbchsim
-  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
   m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl
   )
 
 #PUCCH ---> Prashanth
 add_executable(nr_pucchsim  
   ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pucchsim.c 
+  ${OPENAIR_DIR}/common/utils/backtrace.c
+  ${OPENAIR_DIR}/common/utils/nr/nr_common.c
   ${OPENAIR_DIR}/common/utils/system.c
   ${UTIL_SRC}
   ${T_SOURCE}
   ${SHLIB_LOADER_SOURCES}
   )
 target_link_libraries(nr_pucchsim
-  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
   m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl
   )
-#PUCCH ---> Prashanth
 
 add_executable(nr_dlsim
   ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c
   ${OPENAIR_DIR}/common/utils/system.c
+  ${OPENAIR_DIR}/common/utils/nr/nr_common.c
+  ${OPENAIR_DIR}/executables/softmodem-common.c
   ${UTIL_SRC}
   ${T_SOURCE}
   ${SHLIB_LOADER_SOURCES}
   )   
 target_link_libraries(nr_dlsim
-  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group
   m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl
   )
+target_compile_definitions(nr_dlsim PUBLIC -DPHYSICAL_SIMULATOR)
+
+add_executable(nr_prachsim
+  ${OPENAIR1_DIR}/SIMULATION/NR_PHY/prachsim.c 
+  ${OPENAIR_DIR}/common/utils/system.c
+  ${OPENAIR_DIR}/common/utils/nr/nr_common.c
+  ${OPENAIR1_DIR}/SCHED_NR/phy_procedures_nr_common.c
+  ${UTIL_SRC}
+  ${T_SOURCE}
+  ${SHLIB_LOADER_SOURCES})
+target_link_libraries(nr_prachsim  
+   -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_RU PHY_NR_UE MAC_NR_COMMON SCHED_NR_LIB SCHED_NR_UE_LIB RRC_LIB NR_RRC_LIB L2_NR CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl)
 
 add_executable(nr_ulschsim
   ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c
@@ -2802,22 +2877,24 @@ add_executable(nr_ulschsim
   ${SHLIB_LOADER_SOURCES}
   )
 target_link_libraries(nr_ulschsim
-  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
   m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl
   )
 
 add_executable(nr_ulsim
   ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulsim.c
   ${OPENAIR_DIR}/common/utils/system.c
+  ${OPENAIR_DIR}/common/utils/nr/nr_common.c
+  ${OPENAIR_DIR}/executables/softmodem-common.c
   ${UTIL_SRC}
   ${T_SOURCE}
   ${SHLIB_LOADER_SOURCES}
   )
 target_link_libraries(nr_ulsim
-  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_COMMON PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group
   m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl
   )
-
+target_compile_definitions(nr_ulsim PUBLIC -DPHYSICAL_SIMULATOR)
 
 foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim)
   
@@ -2832,9 +2909,10 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr
     ${NFAPI_USER_DIR}/nfapi.c
     )
   target_link_libraries (${myExe}
-    -Wl,--start-group SIMU UTIL SCHED_LIB SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY PHY_UE PHY_RU LFDS ${ITTI_LIB} LFDS7 -Wl,--end-group
+    -Wl,--start-group SIMU UTIL SCHED_LIB SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_NR_COMMON PHY PHY_UE PHY_RU LFDS ${ITTI_LIB} LFDS7 -Wl,--end-group
     pthread m rt ${CONFIG_LIB} ${ATLAS_LIBRARIES}  ${XFORMS_LIBRARIES} ${T_LIB} dl
     )
+   
 endforeach(myExe)
 
 add_executable(test_epc_generate_scenario
@@ -2865,7 +2943,7 @@ add_executable(test_epc_play_scenario
   )
 target_include_directories(test_epc_play_scenario PUBLIC /usr/local/share/asn1c)
 target_link_libraries (test_epc_play_scenario
-  -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY_COMMON PHY PHY_UE LFDS ${ITTI_LIB} ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIB}
+  -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY_NR_COMMON PHY_COMMON PHY PHY_UE LFDS ${ITTI_LIB} ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIB}
   )
 
 
@@ -2909,9 +2987,10 @@ if (${T_TRACER})
         coding FLPT_MSG ASYNC_IF FLEXRAN_AGENT HASHTABLE MSC UTIL OMG_SUMO
         SECU_OSA SECU_CN SCHED_LIB SCHED_NR_LIB SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB default_sched remote_sched RAL
         NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB
-        PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_UE PHY_RU PHY_MEX
+        PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX
         L2 L2_LTE L2_NR L2_UE NR_L2_UE MAC_NR_COMMON MAC_NR MAC_UE_NR
-        CN_UTILS GTPV1U SCTP_CLIENT MME_APP UDP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU SIMU_ETH OPENAIR0_LIB)
+        CN_UTILS GTPV1U SCTP_CLIENT MME_APP UDP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU SIMU_ETH OPENAIR0_LIB
+        ldpc_orig ldpc_optim ldpc_optim8seg ldpc)
     if (TARGET ${i})
       add_dependencies(${i} generate_T)
     endif()
diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml
index c4f15c3a167..b3954db1fd2 100644
--- a/cmake_targets/autotests/test_case_list.xml
+++ b/cmake_targets/autotests/test_case_list.xml
@@ -1082,32 +1082,31 @@
       <desc>nr_dlsim Test cases. (Test1: 106 PRB),
                                  (Test2: 217 PRB),
                                  (Test3: 273 PRB),
-                                 (Test4: 106 PRB 12 CSET-Offset),
-                                 (Test5: 217 PRB 48 CSET-Offset),
-                                 (Test6: 106 PRB 25 PDSCH-Offset),
-                                 (Test7: 106 PRB 51 PDSCH-Offset),
-                                 (Test8: 217 PRB 100 PDSCH-PRBs),
-                                 (Test9: 217 PRB 80 PDSCH-Offset),
-                                 (Test10: 217 PRB 100 PDSCH-PRBs 110 PDSCH-Offset),
-                                 (Test11: 106 PRBs 50 PDSCH-PRBs MCS Index 28</desc>
+                                 (Test4: 106 PRB 25 PDSCH-Offset),
+                                 (Test5: 106 PRB 51 PDSCH-Offset),
+                                 (Test6: 217 PRB 100 PDSCH-PRBs),
+                                 (Test7: 217 PRB 80 PDSCH-Offset),
+                                 (Test8: 217 PRB 100 PDSCH-PRBs 110 PDSCH-Offset),
+                                 (Test9: 106 PRBs 50 PDSCH-PRBs MCS Index 27)
+                                 (Test10: 106 PRBs 50 PDSCH-PRBs MCS Index 16)</desc>
       <pre_compile_prog></pre_compile_prog>
       <compile_prog>$OPENAIR_DIR/cmake_targets/build_oai</compile_prog>
       <compile_prog_args> --phy_simulators  -c </compile_prog_args>
       <pre_exec>$OPENAIR_DIR/cmake_targets/autotests/tools/free_mem.bash</pre_exec>
       <pre_exec_args></pre_exec_args>
       <main_exec> $OPENAIR_DIR/targets/bin/nr_dlsim.Rel15</main_exec>
-      <main_exec_args>-n100 -R106 -b106
-		              -n100 -R217 -b217
-		              -n100 -R273 -b273
-                  -n100 -R106 -o12
-                  -n100 -R217 -o48
-                  -n100 -R106 -a25
-                  -n100 -R106 -a51
-                  -n100 -R217 -b100
-                  -n100 -R217 -a80
-                  -n100 -R217 -a110 -b100
-                  -n100 -e28</main_exec_args>
-      <tags>nr_dlsim.test1 nr_dlsim.test2 nr_dlsim.test3 nr_dlsim.test4 nr_dlsim.test5 nr_dlsim.test6 nr_dlsim.test7 nr_dlsim.test8 nr_dlsim.test9 nr_dlsim.test10 nr_dlsim.test11</tags>
+      <main_exec_args>-n100 -R106 -b106 -s5
+		  -n100 -R217 -b217 -s5
+		  -n100 -R273 -b273 -s5
+                  -n100 -R106 -a25 -s5
+                  -n100 -R106 -a51 -s5
+                  -n100 -R217 -b100 -s5
+                  -n100 -R217 -a80 -s5
+                  -n100 -R217 -a110 -s5 -b100
+                  -n100 -e27 -s30 
+                  -n100 -e16 -s10 
+      </main_exec_args>
+      <tags>nr_dlsim.test1 nr_dlsim.test2 nr_dlsim.test3 nr_dlsim.test4 nr_dlsim.test5 nr_dlsim.test6 nr_dlsim.test7 nr_dlsim.test8 nr_dlsim.test9 nr_dlsim.test10 </tags>
       <search_expr_true>PDSCH test OK</search_expr_true>
       <search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false>
       <nruns>3</nruns>
@@ -1249,11 +1248,11 @@
       <pre_exec>$OPENAIR_DIR/cmake_targets/autotests/tools/free_mem.bash</pre_exec>
       <pre_exec_args></pre_exec_args>
       <main_exec> $OPENAIR_DIR/targets/bin/nr_ulsim.Rel15</main_exec>
-      <main_exec_args>-f100 -m9 -r106 -s10
-                      -f100 -m16 -s20
-                      -f100 -m28 -s30
-                      -f100 -m9 -R217 -r217 -s10
-                      -f100 -m9 -R273 -r273 -s10</main_exec_args>
+      <main_exec_args>-n100 -m9 -r106 -s0
+                      -n100 -m16 -s10
+                      -n100 -m28 -s20
+                      -n100 -m9 -R217 -r217 -s0
+                      -n100 -m9 -R273 -r273 -s0</main_exec_args>
       <tags>nr_ulsim.test1 nr_ulsim.test2 nr_ulsim.test3 nr_ulsim.test4 nr_ulsim.test5</tags>
       <search_expr_true>PUSCH test OK</search_expr_true>
       <search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false>
diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai
index 829c4a0f6be..78769ed8d43 100755
--- a/cmake_targets/build_oai
+++ b/cmake_targets/build_oai
@@ -697,8 +697,12 @@ function main() {
   if [ "$SIMUS_PHY" = "1" ] ; then
     echo_info "Compiling physical unitary tests simulators"
     # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim
+<<<<<<< HEAD
 #simlist="dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim"
 simlist="ldpctest"
+=======
+    simlist="dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim"
+>>>>>>> origin/develop
     for f in $simlist ; do
       compilations \
         phy_simulators $f \
diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper
index 6ed17649cc9..818b1fd79c7 100755
--- a/cmake_targets/tools/build_helper
+++ b/cmake_targets/tools/build_helper
@@ -102,8 +102,8 @@ check_supported_distribution() {
         "ubuntu14.04") return 0 ;;
         "fedora24")    return 0 ;;
         "rhel7")       return 0 ;;
-	"rhel7.6")     return 0 ;;
-	"rhel7.7")     return 0 ;;
+        "rhel7.6")     return 0 ;;
+        "rhel7.7")     return 0 ;;
         "centos7")     return 0 ;;
     esac
     return 1
diff --git a/common/config/config_userapi.c b/common/config/config_userapi.c
index 67fdc2c920c..33d64088284 100644
--- a/common/config/config_userapi.c
+++ b/common/config/config_userapi.c
@@ -45,7 +45,8 @@
 
 configmodule_interface_t *config_get_if(void) {
   if (cfgptr == NULL) {
-    CONFIG_PRINTF_ERROR("[CONFIG] %s %d config module not initialized\n",__FILE__,__LINE__);
+  	if (isLogInitDone())
+       LOG_W(ENB_APP,"[CONFIG] %s %d config module not initialized\n",__FILE__,__LINE__);
   }
 
   return cfgptr;
@@ -223,7 +224,6 @@ int config_get(paramdef_t *params, int numparams, char *prefix) {
   }
 
   configmodule_interface_t *cfgif = config_get_if();
-
   if (cfgif != NULL) {
     ret = config_get_if()->get(params, numparams, prefix);
 
diff --git a/common/ran_context.h b/common/ran_context.h
index abe482c7420..8262f5dd55e 100644
--- a/common/ran_context.h
+++ b/common/ran_context.h
@@ -85,8 +85,6 @@ typedef struct {
   int nb_nr_L1_inst;  
   /// Number of Component Carriers per instance in this node
   int *nb_L1_CC;
-  /// Number of NR Component Carriers per instance in this node
-  int *nb_nr_L1_CC;
   /// Number of RU instances in this node
   int nb_RU;
   /// FlexRAN context variables
@@ -94,7 +92,7 @@ typedef struct {
   /// eNB context variables
   struct PHY_VARS_eNB_s ***eNB;
   /// gNB context variables
-  struct PHY_VARS_gNB_s ***gNB;
+  struct PHY_VARS_gNB_s **gNB;
   /// NB_IoT L1 context variables
   struct PHY_VARS_eNB_NB_IoT_s **L1_NB_IoT;
   /// RRC context variables
diff --git a/common/utils/LOG/vcd_signal_dumper.c b/common/utils/LOG/vcd_signal_dumper.c
index 9327b6e77a1..0043eb32380 100644
--- a/common/utils/LOG/vcd_signal_dumper.c
+++ b/common/utils/LOG/vcd_signal_dumper.c
@@ -514,7 +514,8 @@ const char* eurecomFunctionsNames[] = {
   /*NR softmodem signal*/
   "wakeup_txfh",
   "gNB_thread_rxtx0",
-  "gNB_thread_rxtx1"
+  "gNB_thread_rxtx1",
+  "ru_thread_tx_wait"
 };
 
 struct vcd_module_s vcd_modules[] = {
diff --git a/common/utils/LOG/vcd_signal_dumper.h b/common/utils/LOG/vcd_signal_dumper.h
index 9383b39b1ee..20588bb8286 100644
--- a/common/utils/LOG/vcd_signal_dumper.h
+++ b/common/utils/LOG/vcd_signal_dumper.h
@@ -507,6 +507,7 @@ typedef enum {
   VCD_SIGNAL_DUMPER_FUNCTIONS_WAKEUP_TXFH,
   VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PROC_RXTX0,
   VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PROC_RXTX1,
+  VCD_SIGNAL_DUMPER_FUNCTIONS_RU_TX_WAIT,
 
   VCD_SIGNAL_DUMPER_FUNCTIONS_END
 } vcd_signal_dump_functions;
diff --git a/common/utils/T/T_defs.h b/common/utils/T/T_defs.h
index b59fae2a0c3..4cb4bf2bbaf 100644
--- a/common/utils/T/T_defs.h
+++ b/common/utils/T/T_defs.h
@@ -73,7 +73,7 @@ typedef struct {
 } T_cache_t;
 
 /* number of VCD functions (to be kept up to date! see in T_messages.txt) */
-#define VCD_NUM_FUNCTIONS (247)
+#define VCD_NUM_FUNCTIONS (248)
 
 /* number of VCD variables (to be kept up to date! see in T_messages.txt) */
 #define VCD_NUM_VARIABLES (186)
diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt
index 387257d145e..f8b746669c8 100644
--- a/common/utils/T/T_messages.txt
+++ b/common/utils/T/T_messages.txt
@@ -3378,3 +3378,8 @@ ID = VCD_FUNCTION_gNB_PROC_RXTX1
     GROUP = ALL:VCD:ENB:VCD_FUNCTION
     FORMAT = int,value
     VCD_NAME = gNB_thread_rxtx1
+ID = VCD_FUNCTION_RU_TX_WAIT
+    DESC = VCD function RU_TX_WAIT
+    GROUP = ALL:VCD:ENB:VCD_FUNCTION
+    FORMAT = int,value
+    VCD_NAME = ru_thread_tx_wait
diff --git a/common/utils/telnetsrv/telnetsrv.c b/common/utils/telnetsrv/telnetsrv.c
index 10163b22b5c..06a5d350c75 100644
--- a/common/utils/telnetsrv/telnetsrv.c
+++ b/common/utils/telnetsrv/telnetsrv.c
@@ -377,6 +377,14 @@ int setgetvar(int moduleindex,char getorset,char *params) {
             client_printf("%hi\n",*(short *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
             break;
 
+          case TELNET_VARTYPE_INT8:
+            client_printf("%i\n",(int)(*(int8_t *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr)));
+            break;
+            
+          case TELNET_VARTYPE_UINT:
+            client_printf("%u\n",*(unsigned int *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
+            break;
+            
           case TELNET_VARTYPE_DOUBLE:
             client_printf("%g\n",*(double *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
             break;
@@ -405,7 +413,17 @@ int setgetvar(int moduleindex,char getorset,char *params) {
             *(short *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr) = (short)strtol(varval,NULL,0);
             client_printf("%hi\n",*(short *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
             break;
-
+            
+          case TELNET_VARTYPE_INT8:
+            *(char *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr) = (char)strtol(varval,NULL,0);
+            client_printf("%i\n",*(int *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
+            break;
+            
+          case TELNET_VARTYPE_UINT:
+            *(unsigned int *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr) = (unsigned int)strtol(varval,NULL,0);
+            client_printf("%u\n",*(unsigned int *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
+            break;
+ 
           case TELNET_VARTYPE_DOUBLE:
             *(double *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr) = strtod(varval,NULL);
             client_printf("%g\n",*(double *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c
index fc012b0ab24..e03700e4f52 100644
--- a/executables/nr-gnb.c
+++ b/executables/nr-gnb.c
@@ -101,8 +101,8 @@ extern openair0_config_t openair0_cfg[MAX_CARDS];
 
 extern int transmission_mode;
 
-uint16_t sl_ahead=6;
-uint16_t sf_ahead=6;
+extern uint16_t sf_ahead;
+extern uint16_t sl_ahead;
 //pthread_t                       main_gNB_thread;
 
 time_stats_t softmodem_stats_mt; // main thread
@@ -144,10 +144,14 @@ extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset);
 
 
 static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_tx, int slot_tx, char *thread_name) {
+
+  sl_ahead = sf_ahead*gNB->frame_parms.slots_per_subframe;
+  nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
+
   start_meas(&softmodem_stats_rxtx_sf);
 
   // *******************************************************************
-
+  // NFAPI not yet supported for NR - this code has to be revised
   if (nfapi_mode == 1) {
     // I am a PNF and I need to let nFAPI know that we have a (sub)frame tick
     //add_subframe(&frame, &subframe, 4);
@@ -173,20 +177,18 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t
             frame_tx, slot_tx);
     }
   }
-
-  /// NR disabling
   // ****************************************
-  // Common RX procedures subframe n
+
   T(T_GNB_PHY_DL_TICK, T_INT(gNB->Mod_id), T_INT(frame_tx), T_INT(slot_tx));
-/*
+
+  /*
   // if this is IF5 or 3GPP_gNB
   if (gNB && gNB->RU_list && gNB->RU_list[0] && gNB->RU_list[0]->function < NGFI_RAU_IF4p5) {
     wakeup_prach_gNB(gNB,NULL,proc->frame_rx,proc->slot_rx);
   }
+  */
 
-  // UE-specific RX processing for subframe n
-  if (nfapi_mode == 0 || nfapi_mode == 1) */
-
+  // Call the scheduler
   pthread_mutex_lock(&gNB->UL_INFO_mutex);
   gNB->UL_INFO.frame     = frame_rx;
   gNB->UL_INFO.slot      = slot_rx;
@@ -194,22 +196,30 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t
   gNB->UL_INFO.CC_id     = gNB->CC_id;
   gNB->if_inst->NR_UL_indication(&gNB->UL_INFO);
   pthread_mutex_unlock(&gNB->UL_INFO_mutex);
+  
+  // RX processing
+  int tx_slot_type         = nr_slot_select(cfg,frame_tx,slot_tx);
+  int rx_slot_type         = nr_slot_select(cfg,frame_rx,slot_rx);
+
+  if (rx_slot_type == NR_UPLINK_SLOT || rx_slot_type == NR_MIXED_SLOT) {
+    // UE-specific RX processing for subframe n
+    // TODO: check if this is correct for PARALLEL_RU_L1_TRX_SPLIT
+    phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx);
+  }
+
+  if (oai_exit) return(-1);
 
-  /// end
   // *****************************************
-  // TX processing for subframe n+sl_ahead
+  // TX processing for subframe n+sf_ahead
   // run PHY TX procedures the one after the other for all CCs to avoid race conditions
   // (may be relaxed in the future for performance reasons)
   // *****************************************
-  //if (wait_CCs(proc)<0) return(-1);
-
-  if (oai_exit) return(-1);
-
-  //if (slot_rx == NR_UPLINK_SLOT || gNB->frame_parms.frame_type == FDD) 
-    phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx);
+  
+  if (tx_slot_type == NR_DOWNLINK_SLOT || tx_slot_type == NR_MIXED_SLOT) {
 
-  if(get_thread_parallel_conf() != PARALLEL_RU_L1_TRX_SPLIT) {
-    phy_procedures_gNB_TX(gNB, frame_tx,slot_tx, 1);
+    if(get_thread_parallel_conf() != PARALLEL_RU_L1_TRX_SPLIT) {
+      phy_procedures_gNB_TX(gNB, frame_tx,slot_tx, 1);
+    }
   }
 
   stop_meas( &softmodem_stats_rxtx_sf );
@@ -388,14 +398,15 @@ void gNB_top(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, char *string, struct
   RU_proc_t *ru_proc=&ru->proc;
   proc->frame_rx    = frame_rx;
   proc->slot_rx = slot_rx;
+  sl_ahead = sf_ahead*fp->slots_per_subframe;
 
   if (!oai_exit) {
     T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->slot_rx));
-    L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sl_ahead*fp->samples_per_slot);
+    L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_subframe);
     L1_proc->frame_rx     = ru_proc->frame_rx;
     L1_proc->slot_rx      = ru_proc->tti_rx;
-    L1_proc->frame_tx     = (L1_proc->slot_rx > (fp->slots_per_frame-1-sl_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx;
-    L1_proc->slot_tx      = (L1_proc->slot_rx + sl_ahead)%fp->slots_per_frame;
+    L1_proc->frame_tx     = (L1_proc->slot_rx > (fp->slots_per_frame-1-(fp->slots_per_subframe*sf_ahead))) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx;
+    L1_proc->slot_tx      = (L1_proc->slot_rx + (fp->slots_per_subframe*sf_ahead))%fp->slots_per_frame;
 
     if (rxtx(gNB,L1_proc->frame_rx,L1_proc->slot_rx,L1_proc->frame_tx,L1_proc->slot_tx,string) < 0) LOG_E(PHY,"gNB %d CC_id %d failed during execution\n",gNB->Mod_id,gNB->CC_id);
 
@@ -558,7 +569,7 @@ int wakeup_rxtx(PHY_VARS_gNB *gNB,RU_t *ru) {
     abstime.tv_sec  += 1;
   }
 
-  // wake up TX for subframe n+sl_ahead
+  // wake up TX for subframe n+sf_ahead
   // lock the TX mutex and make sure the thread is ready
   AssertFatal((ret=pthread_mutex_timedlock(&L1_proc->mutex, &abstime)) == 0,"mutex_lock returns %d\n", ret);
 
@@ -574,15 +585,15 @@ int wakeup_rxtx(PHY_VARS_gNB *gNB,RU_t *ru) {
   // TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired 
   // transmitted timestamp of the next TX slot (first).
   // The last (TS_rx mod samples_per_frame) was n*samples_per_tti, 
-  // we want to generate subframe (n+sl_ahead), so TS_tx = TX_rx+sl_ahead*samples_per_tti,
-  // and proc->slot_tx = proc->slot_rx+sl_ahead
-  L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sl_ahead*fp->samples_per_slot);
+  // we want to generate subframe (n+sf_ahead), so TS_tx = TX_rx+sf_ahead*samples_per_tti,
+  // and proc->slot_tx = proc->slot_rx+sf_ahead
+  L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_subframe);
   L1_proc->frame_rx     = ru_proc->frame_rx;
   L1_proc->slot_rx  = ru_proc->tti_rx;
-  L1_proc->frame_tx     = (L1_proc->slot_rx > (fp->slots_per_frame-1-sl_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx;
-  L1_proc->slot_tx  = (L1_proc->slot_rx + sl_ahead)%fp->slots_per_frame;
+  L1_proc->frame_tx = (L1_proc->slot_rx > (fp->slots_per_frame-1-(fp->slots_per_subframe*sf_ahead))) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx;
+  L1_proc->slot_tx  = (L1_proc->slot_rx + (fp->slots_per_subframe*sf_ahead))%fp->slots_per_frame;
 
-  LOG_D(PHY,"wakeupL1: passing parameter IC = %d, RX: %d.%d, TX: %d.%d to L1 sl_ahead = %d\n", L1_proc->instance_cnt, L1_proc->frame_rx, L1_proc->slot_rx, L1_proc->frame_tx, L1_proc->slot_tx, sl_ahead);
+  LOG_D(PHY,"wakeupL1: passing parameter IC = %d, RX: %d.%d, TX: %d.%d to L1 sf_ahead = %d\n", L1_proc->instance_cnt, L1_proc->frame_rx, L1_proc->slot_rx, L1_proc->frame_tx, L1_proc->slot_tx, sf_ahead);
 
   pthread_mutex_unlock( &L1_proc->mutex );
 
@@ -719,64 +730,62 @@ static void* process_stats_thread(void* param) {
 
 void init_gNB_proc(int inst) {
   int i=0;
-  int CC_id;
+  int CC_id = 0;
   PHY_VARS_gNB *gNB;
   gNB_L1_proc_t *proc;
   gNB_L1_rxtx_proc_t *L1_proc,*L1_proc_tx;
-  LOG_I(PHY,"%s(inst:%d) RC.nb_nr_CC[inst]:%d \n",__FUNCTION__,inst,RC.nb_nr_CC[inst]);
-
-  for (CC_id=0; CC_id<RC.nb_nr_CC[inst]; CC_id++) {
-    gNB = RC.gNB[inst][CC_id];
+//  LOG_I(PHY,"%s(inst:%d) RC.nb_nr_CC[inst]:%d \n",__FUNCTION__,inst,RC.nb_nr_CC[inst]);
+  gNB = RC.gNB[inst];
 #ifndef OCP_FRAMEWORK
-    LOG_I(PHY,"Initializing gNB processes instance:%d CC_id %d \n",inst,CC_id);
+  LOG_I(PHY,"Initializing gNB processes instance:%d CC_id %d \n",inst,CC_id);
 #endif
-    proc = &gNB->proc;
-    L1_proc                        = &proc->L1_proc;
-    L1_proc_tx                     = &proc->L1_proc_tx;
-    L1_proc->instance_cnt          = -1;
-    L1_proc_tx->instance_cnt       = -1;
-    L1_proc->instance_cnt_RUs      = 0;
-    L1_proc_tx->instance_cnt_RUs   = 0;
-    proc->instance_cnt_prach       = -1;
-    proc->instance_cnt_asynch_rxtx = -1;
-    proc->CC_id                    = CC_id;
-    proc->first_rx                 =1;
-    proc->first_tx                 =1;
-    proc->RU_mask                  =0;
-    proc->RU_mask_tx               = (1<<gNB->num_RU)-1;
-    proc->RU_mask_prach            =0;
-    pthread_mutex_init( &gNB->UL_INFO_mutex, NULL);
-    pthread_mutex_init( &L1_proc->mutex, NULL);
-    pthread_mutex_init( &L1_proc_tx->mutex, NULL);
-    pthread_cond_init( &L1_proc->cond, NULL);
-    pthread_cond_init( &L1_proc_tx->cond, NULL);
-    pthread_mutex_init( &proc->mutex_prach, NULL);
-    pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL);
-    pthread_mutex_init( &proc->mutex_RU,NULL);
-    pthread_mutex_init( &proc->mutex_RU_tx,NULL);
-    pthread_mutex_init( &proc->mutex_RU_PRACH,NULL);
-    pthread_cond_init( &proc->cond_prach, NULL);
-    pthread_cond_init( &proc->cond_asynch_rxtx, NULL);
-    LOG_I(PHY,"gNB->single_thread_flag:%d\n", gNB->single_thread_flag);
-
-    if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) {
-      threadCreate( &L1_proc->pthread, gNB_L1_thread, gNB, "L1_proc", -1, OAI_PRIORITY_RT );
-      threadCreate( &L1_proc_tx->pthread, gNB_L1_thread_tx, gNB,"L1_proc_tx", -1, OAI_PRIORITY_RT);
-    }
-
-    if(opp_enabled == 1) threadCreate(&proc->L1_stats_thread, process_stats_thread,(void *)gNB, "time_meas", -1, OAI_PRIORITY_RT_LOW);
-    //pthread_create( &proc->pthread_prach, attr_prach, gNB_thread_prach, gNB );
-    char name[16];
-
-    if (gNB->single_thread_flag==0) {
-      snprintf( name, sizeof(name), "L1 %d", i );
-      pthread_setname_np( L1_proc->pthread, name );
-      snprintf( name, sizeof(name), "L1TX %d", i );
-      pthread_setname_np( L1_proc_tx->pthread, name );
-    }
-
-    AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach);
+  
+  proc = &gNB->proc;
+  L1_proc                        = &proc->L1_proc;
+  L1_proc_tx                     = &proc->L1_proc_tx;
+  L1_proc->instance_cnt          = -1;
+  L1_proc_tx->instance_cnt       = -1;
+  L1_proc->instance_cnt_RUs      = 0;
+  L1_proc_tx->instance_cnt_RUs   = 0;
+  proc->instance_cnt_prach       = -1;
+  proc->instance_cnt_asynch_rxtx = -1;
+  proc->CC_id                    = CC_id;
+  proc->first_rx                 =1;
+  proc->first_tx                 =1;
+  proc->RU_mask                  =0;
+  proc->RU_mask_tx               = (1<<gNB->num_RU)-1;
+  proc->RU_mask_prach            =0;
+  pthread_mutex_init( &gNB->UL_INFO_mutex, NULL);
+  pthread_mutex_init( &L1_proc->mutex, NULL);
+  pthread_mutex_init( &L1_proc_tx->mutex, NULL);
+  pthread_cond_init( &L1_proc->cond, NULL);
+  pthread_cond_init( &L1_proc_tx->cond, NULL);
+  pthread_mutex_init( &proc->mutex_prach, NULL);
+  pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL);
+  pthread_mutex_init( &proc->mutex_RU,NULL);
+  pthread_mutex_init( &proc->mutex_RU_tx,NULL);
+  pthread_mutex_init( &proc->mutex_RU_PRACH,NULL);
+  pthread_cond_init( &proc->cond_prach, NULL);
+  pthread_cond_init( &proc->cond_asynch_rxtx, NULL);
+  LOG_I(PHY,"gNB->single_thread_flag:%d\n", gNB->single_thread_flag);
+  
+  if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) {
+    threadCreate( &L1_proc->pthread, gNB_L1_thread, gNB, "L1_proc", -1, OAI_PRIORITY_RT );
+    threadCreate( &L1_proc_tx->pthread, gNB_L1_thread_tx, gNB,"L1_proc_tx", -1, OAI_PRIORITY_RT);
   }
+  
+  if(opp_enabled == 1) threadCreate(&proc->L1_stats_thread, process_stats_thread,(void *)gNB, "time_meas", -1, OAI_PRIORITY_RT_LOW);
+  //pthread_create( &proc->pthread_prach, attr_prach, gNB_thread_prach, gNB );
+  char name[16];
+  
+  if (gNB->single_thread_flag==0) {
+    snprintf( name, sizeof(name), "L1 %d", i );
+    pthread_setname_np( L1_proc->pthread, name );
+    snprintf( name, sizeof(name), "L1TX %d", i );
+    pthread_setname_np( L1_proc_tx->pthread, name );
+  }
+  
+  AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach);
 
   /* setup PHY proc TX sync mechanism */
   pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL);
@@ -795,52 +804,51 @@ void kill_gNB_proc(int inst) {
   gNB_L1_proc_t *proc;
   gNB_L1_rxtx_proc_t *L1_proc, *L1_proc_tx;
 
-  for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    gNB=RC.gNB[inst][CC_id];
-    proc = &gNB->proc;
-    L1_proc     = &proc->L1_proc;
-    L1_proc_tx  = &proc->L1_proc_tx;
-    LOG_I(PHY, "Killing TX CC_id %d inst %d\n", CC_id, inst );
-
-    if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) {
-      pthread_mutex_lock(&L1_proc->mutex);
-      L1_proc->instance_cnt = 0;
-      pthread_cond_signal(&L1_proc->cond);
-      pthread_mutex_unlock(&L1_proc->mutex);
-      pthread_mutex_lock(&L1_proc_tx->mutex);
-      L1_proc_tx->instance_cnt = 0;
-      pthread_cond_signal(&L1_proc_tx->cond);
-      pthread_mutex_unlock(&L1_proc_tx->mutex);
-    }
-
-    proc->instance_cnt_prach = 0;
-    pthread_cond_signal( &proc->cond_prach );
-    pthread_cond_signal( &proc->cond_asynch_rxtx );
-    pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx);
-    //    LOG_D(PHY, "joining pthread_prach\n");
-    //    pthread_join( proc->pthread_prach, (void**)&status );
-    LOG_I(PHY, "Destroying prach mutex/cond\n");
-    pthread_mutex_destroy( &proc->mutex_prach );
-    pthread_cond_destroy( &proc->cond_prach );
-    LOG_I(PHY, "Destroying UL_INFO mutex\n");
-    pthread_mutex_destroy(&gNB->UL_INFO_mutex);
-
-    if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) {
-      LOG_I(PHY, "Joining L1_proc mutex/cond\n");
-      pthread_join( L1_proc->pthread, (void **)&status );
-      LOG_I(PHY, "Joining L1_proc_tx mutex/cond\n");
-      pthread_join( L1_proc_tx->pthread, (void **)&status );
-    }
-
-    LOG_I(PHY, "Destroying L1_proc mutex/cond\n");
-    pthread_mutex_destroy( &L1_proc->mutex );
-    pthread_cond_destroy( &L1_proc->cond );
-    LOG_I(PHY, "Destroying L1_proc_tx mutex/cond\n");
-    pthread_mutex_destroy( &L1_proc_tx->mutex );
-    pthread_cond_destroy( &L1_proc_tx->cond );
-    pthread_mutex_destroy( &proc->mutex_RU );
-    pthread_mutex_destroy( &proc->mutex_RU_tx );
+  gNB=RC.gNB[inst];
+  proc = &gNB->proc;
+  L1_proc     = &proc->L1_proc;
+  L1_proc_tx  = &proc->L1_proc_tx;
+  LOG_I(PHY, "Killing TX inst %d\n",inst );
+  
+  if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) {
+    pthread_mutex_lock(&L1_proc->mutex);
+    L1_proc->instance_cnt = 0;
+    pthread_cond_signal(&L1_proc->cond);
+    pthread_mutex_unlock(&L1_proc->mutex);
+    pthread_mutex_lock(&L1_proc_tx->mutex);
+    L1_proc_tx->instance_cnt = 0;
+    pthread_cond_signal(&L1_proc_tx->cond);
+    pthread_mutex_unlock(&L1_proc_tx->mutex);
   }
+  
+  proc->instance_cnt_prach = 0;
+  pthread_cond_signal( &proc->cond_prach );
+  pthread_cond_signal( &proc->cond_asynch_rxtx );
+  pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx);
+  //    LOG_D(PHY, "joining pthread_prach\n");
+  //    pthread_join( proc->pthread_prach, (void**)&status );
+  LOG_I(PHY, "Destroying prach mutex/cond\n");
+  pthread_mutex_destroy( &proc->mutex_prach );
+  pthread_cond_destroy( &proc->cond_prach );
+  LOG_I(PHY, "Destroying UL_INFO mutex\n");
+  pthread_mutex_destroy(&gNB->UL_INFO_mutex);
+  
+  if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) {
+    LOG_I(PHY, "Joining L1_proc mutex/cond\n");
+    pthread_join( L1_proc->pthread, (void **)&status );
+    LOG_I(PHY, "Joining L1_proc_tx mutex/cond\n");
+    pthread_join( L1_proc_tx->pthread, (void **)&status );
+  }
+  
+  LOG_I(PHY, "Destroying L1_proc mutex/cond\n");
+  pthread_mutex_destroy( &L1_proc->mutex );
+  pthread_cond_destroy( &L1_proc->cond );
+  LOG_I(PHY, "Destroying L1_proc_tx mutex/cond\n");
+  pthread_mutex_destroy( &L1_proc_tx->mutex );
+  pthread_cond_destroy( &L1_proc_tx->cond );
+  pthread_mutex_destroy( &proc->mutex_RU );
+  pthread_mutex_destroy( &proc->mutex_RU_tx );
+  
 }
 
 
@@ -872,48 +880,41 @@ void print_opp_meas(void) {
 
 /// eNB kept in function name for nffapi calls, TO FIX
 void init_eNB_afterRU(void) {
-  int inst,CC_id,ru_id,i,aa;
+  int inst,ru_id,i,aa;
   PHY_VARS_gNB *gNB;
   LOG_I(PHY,"%s() RC.nb_nr_inst:%d\n", __FUNCTION__, RC.nb_nr_inst);
 
   for (inst=0; inst<RC.nb_nr_inst; inst++) {
-    LOG_I(PHY,"RC.nb_nr_CC[inst]:%d\n", RC.nb_nr_CC[inst]);
-
-    for (CC_id=0; CC_id<RC.nb_nr_CC[inst]; CC_id++) {
-      LOG_I(PHY,"RC.nb_nr_CC[inst:%d][CC_id:%d]:%p\n", inst, CC_id, RC.gNB[inst][CC_id]);
-      gNB                                  =  RC.gNB[inst][CC_id];
-      phy_init_nr_gNB(gNB,0,0);
-
-      // map antennas and PRACH signals to gNB RX
-      if (0) AssertFatal(gNB->num_RU>0,"Number of RU attached to gNB %d is zero\n",gNB->Mod_id);
-
-      LOG_I(PHY,"Mapping RX ports from %d RUs to gNB %d\n",gNB->num_RU,gNB->Mod_id);
-      //LOG_I(PHY,"Overwriting gNB->prach_vars.rxsigF[0]:%p\n", gNB->prach_vars.rxsigF[0]);
-      //      gNB->prach_vars.rxsigF[0] = (int16_t **)malloc16(64*sizeof(int16_t *));
-      LOG_I(PHY,"gNB->num_RU:%d\n", gNB->num_RU);
-
-      for (ru_id=0,aa=0; ru_id<gNB->num_RU; ru_id++) {
-        AssertFatal(gNB->RU_list[ru_id]->common.rxdataF!=NULL,
-                    "RU %d : common.rxdataF is NULL\n",
-                    gNB->RU_list[ru_id]->idx);
-        AssertFatal(gNB->RU_list[ru_id]->prach_rxsigF!=NULL,
-                    "RU %d : prach_rxsigF is NULL\n",
-                    gNB->RU_list[ru_id]->idx);
-
-        for (i=0; i<gNB->RU_list[ru_id]->nb_rx; aa++,i++) {
-          LOG_I(PHY,"Attaching RU %d antenna %d to gNB antenna %d\n",gNB->RU_list[ru_id]->idx,i,aa);
-	  //          gNB->prach_vars.rxsigF[0][aa]    =  gNB->RU_list[ru_id]->prach_rxsigF[i];
-          gNB->common_vars.rxdataF[aa]     =  gNB->RU_list[ru_id]->common.rxdataF[i];
-        }
+    LOG_I(PHY,"RC.nb_nr_CC[inst:%d]:%p\n", inst, RC.gNB[inst]);
+    gNB                                  =  RC.gNB[inst];
+    phy_init_nr_gNB(gNB,0,0);
+
+    // map antennas and PRACH signals to gNB RX
+    if (0) AssertFatal(gNB->num_RU>0,"Number of RU attached to gNB %d is zero\n",gNB->Mod_id);
+
+    LOG_I(PHY,"Mapping RX ports from %d RUs to gNB %d\n",gNB->num_RU,gNB->Mod_id);
+    LOG_I(PHY,"gNB->num_RU:%d\n", gNB->num_RU);
+
+    for (ru_id=0,aa=0; ru_id<gNB->num_RU; ru_id++) {
+      AssertFatal(gNB->RU_list[ru_id]->common.rxdataF!=NULL,
+		  "RU %d : common.rxdataF is NULL\n",
+		  gNB->RU_list[ru_id]->idx);
+      AssertFatal(gNB->RU_list[ru_id]->prach_rxsigF!=NULL,
+		  "RU %d : prach_rxsigF is NULL\n",
+		  gNB->RU_list[ru_id]->idx);
+      
+      for (i=0; i<gNB->RU_list[ru_id]->nb_rx; aa++,i++) {
+	LOG_I(PHY,"Attaching RU %d antenna %d to gNB antenna %d\n",gNB->RU_list[ru_id]->idx,i,aa);
+	gNB->prach_vars.rxsigF[aa]    =  gNB->RU_list[ru_id]->prach_rxsigF[i];
+	gNB->common_vars.rxdataF[aa]     =  gNB->RU_list[ru_id]->common.rxdataF[i];
       }
-
-      /* TODO: review this code, there is something wrong.
-       * In monolithic mode, we come here with nb_antennas_rx == 0
-       * (not tested in other modes).
-       */
-      //init_precoding_weights(RC.gNB[inst][CC_id]);
     }
 
+    /* TODO: review this code, there is something wrong.
+     * In monolithic mode, we come here with nb_antennas_rx == 0
+     * (not tested in other modes).
+     */
+    //init_precoding_weights(RC.gNB[inst]);
     init_gNB_proc(inst);
   }
 
@@ -926,50 +927,51 @@ void init_eNB_afterRU(void) {
 }
 
 void init_gNB(int single_thread_flag,int wait_for_sync) {
-  int CC_id;
+
   int inst;
   PHY_VARS_gNB *gNB;
-  LOG_I(PHY,"[nr-softmodem.c] gNB structure about to be allocated RC.nb_nr_L1_inst:%d RC.nb_nr_L1_CC[0]:%d\n",RC.nb_nr_L1_inst,RC.nb_nr_L1_CC[0]);
 
-  if (RC.gNB == NULL) RC.gNB = (PHY_VARS_gNB ***) malloc(RC.nb_nr_L1_inst*sizeof(PHY_VARS_gNB **));
+  if (RC.gNB == NULL) {
+    RC.gNB = (PHY_VARS_gNB **) malloc((1+RC.nb_nr_L1_inst)*sizeof(PHY_VARS_gNB *));
+    for (inst=0; inst<RC.nb_nr_L1_inst; inst++) {
+      RC.gNB[inst] = (PHY_VARS_gNB *) malloc(sizeof(PHY_VARS_gNB));
+      memset((void*)RC.gNB[inst],0,sizeof(PHY_VARS_gNB));
+    }
+  }
 
-  LOG_I(PHY,"[lte-softmodem.c] gNB structure RC.gNB allocated\n");
+  LOG_I(PHY,"gNB L1 structure RC.gNB allocated @ %p\n",RC.gNB);
 
   for (inst=0; inst<RC.nb_nr_L1_inst; inst++) {
-    if (RC.gNB[inst] == NULL) RC.gNB[inst] = (PHY_VARS_gNB **) malloc(RC.nb_nr_CC[inst]*sizeof(PHY_VARS_gNB *));
-
-    for (CC_id=0; CC_id<RC.nb_nr_L1_CC[inst]; CC_id++) {
-      if (RC.gNB[inst][CC_id] == NULL) RC.gNB[inst][CC_id] = (PHY_VARS_gNB *) malloc(sizeof(PHY_VARS_gNB));
-
-      gNB                     = RC.gNB[inst][CC_id];
-      gNB->abstraction_flag   = 0;
-      gNB->single_thread_flag = single_thread_flag;
-      /*nr_polar_init(&gNB->nrPolar_params,
-                NR_POLAR_PBCH_MESSAGE_TYPE,
-          NR_POLAR_PBCH_PAYLOAD_BITS,
-          NR_POLAR_PBCH_AGGREGATION_LEVEL);*/
-      LOG_I(PHY,"Initializing gNB %d CC_id %d single_thread_flag:%d\n",inst,CC_id,single_thread_flag);
+
+    LOG_I(PHY,"[lte-softmodem.c] gNB structure RC.gNB[%d] allocated @ %p\n",inst,RC.gNB[inst]);
+    gNB                     = RC.gNB[inst];
+    gNB->abstraction_flag   = 0;
+    gNB->single_thread_flag = single_thread_flag;
+    /*nr_polar_init(&gNB->nrPolar_params,
+      NR_POLAR_PBCH_MESSAGE_TYPE,
+      NR_POLAR_PBCH_PAYLOAD_BITS,
+      NR_POLAR_PBCH_AGGREGATION_LEVEL);*/
+    LOG_I(PHY,"Initializing gNB %d single_thread_flag:%d\n",inst,gNB->single_thread_flag);
 #ifndef OCP_FRAMEWORK
-      LOG_I(PHY,"Initializing gNB %d CC_id %d\n",inst,CC_id);
+    LOG_I(PHY,"Initializing gNB %d\n",inst);
 #endif
-      LOG_I(PHY,"Registering with MAC interface module\n");
-      AssertFatal((gNB->if_inst         = NR_IF_Module_init(inst))!=NULL,"Cannot register interface");
-      gNB->if_inst->NR_Schedule_response   = nr_schedule_response;
-      gNB->if_inst->NR_PHY_config_req      = nr_phy_config_request;
-      memset((void *)&gNB->UL_INFO,0,sizeof(gNB->UL_INFO));
-      memset((void *)&gNB->UL_tti_req,0,sizeof(nfapi_nr_ul_tti_request_t));
-      //memset((void *)&gNB->Sched_INFO,0,sizeof(gNB->Sched_INFO));
-      LOG_I(PHY,"Setting indication lists\n");
-      gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list   = gNB->rx_pdu_list;
-      gNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list = gNB->crc_pdu_list;
-      gNB->UL_INFO.sr_ind.sr_indication_body.sr_pdu_list = gNB->sr_pdu_list;
-      gNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = gNB->harq_pdu_list;
-      gNB->UL_INFO.cqi_ind.cqi_pdu_list = gNB->cqi_pdu_list;
-      gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list;
-      
-      gNB->prach_energy_counter = 0;
-    }
+
+    LOG_I(PHY,"Registering with MAC interface module (before %p)\n",gNB->if_inst);
+    AssertFatal((gNB->if_inst         = NR_IF_Module_init(inst))!=NULL,"Cannot register interface");
+    LOG_I(PHY,"Registering with MAC interface module (after %p)\n",gNB->if_inst);
+    gNB->if_inst->NR_Schedule_response   = nr_schedule_response;
+    gNB->if_inst->NR_PHY_config_req      = nr_phy_config_request;
+    memset((void *)&gNB->UL_INFO,0,sizeof(gNB->UL_INFO));
+    LOG_I(PHY,"Setting indication lists\n");
+    gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list   = gNB->rx_pdu_list;
+    gNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list = gNB->crc_pdu_list;
+    gNB->UL_INFO.sr_ind.sr_indication_body.sr_pdu_list = gNB->sr_pdu_list;
+    gNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = gNB->harq_pdu_list;
+    gNB->UL_INFO.cqi_ind.cqi_pdu_list = gNB->cqi_pdu_list;
+    gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list;
+    gNB->prach_energy_counter = 0;
   }
+  
 
   LOG_I(PHY,"[nr-softmodem.c] gNB structure allocated\n");
 }
diff --git a/executables/nr-ru.c b/executables/nr-ru.c
index 0003cf770de..fe109884629 100644
--- a/executables/nr-ru.c
+++ b/executables/nr-ru.c
@@ -50,6 +50,7 @@
 #include <execinfo.h>
 #include <getopt.h>
 #include <sys/sysinfo.h>
+#include <math.h>
 
 #undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
 
@@ -130,7 +131,8 @@ void configure_rru(int idx, void *arg);
 int attach_rru(RU_t *ru);
 int connect_rau(RU_t *ru);
 
-extern uint16_t sl_ahead;
+uint16_t sf_ahead;
+uint16_t sl_ahead;
 
 extern int emulate_rf;
 extern int numerology;
@@ -296,29 +298,24 @@ int connect_rau(RU_t *ru)
 /* Southbound Fronthaul functions, RCC/RAU                   */
 
 // southbound IF5 fronthaul for 16-bit OAI format
-static inline void fh_if5_south_out(RU_t *ru, int frame, int slot, uint64_t timestamp)
+void fh_if5_south_out(RU_t *ru, int frame, int slot, uint64_t timestamp)
 {
   if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff );
 
   send_IF5(ru, timestamp, slot, &ru->seqno, IF5_RRH_GW_DL);
 }
 
-// southbound IF5 fronthaul for Mobipass packet format
-static inline void fh_if5_mobipass_south_out(RU_t *ru, int frame, int slot, uint64_t timestamp)
-{
-  if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff );
-
-  send_IF5(ru, timestamp, slot, &ru->seqno, IF5_MOBIPASS);
-}
-
 // southbound IF4p5 fronthaul
-static inline void fh_if4p5_south_out(RU_t *ru, int frame, int slot, uint64_t timestamp)
+void fh_if4p5_south_out(RU_t *ru, int frame, int slot, uint64_t timestamp)
 {
+  nfapi_nr_config_request_scf_t *cfg = &ru->gNB_list[0]->gNB_config;
   if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff );
 
   LOG_D(PHY,"Sending IF4p5 for frame %d subframe %d\n",ru->proc.frame_tx,ru->proc.tti_tx);
 
-  if (nr_slot_select(&ru->gNB_list[0]->gNB_config,ru->proc.tti_tx,frame)!=SF_UL) send_IF4p5(ru,frame, slot, IF4p5_PDLFFT);
+
+  if ((nr_slot_select(cfg,ru->proc.frame_tx,ru->proc.tti_tx)&NR_DOWNLINK_SLOT) > 0)
+    send_IF4p5(ru,frame, slot, IF4p5_PDLFFT);
 }
 
 /*************************************************************/
@@ -332,8 +329,9 @@ void fh_if5_south_in(RU_t *ru,
   NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms;
   RU_proc_t *proc = &ru->proc;
   recv_IF5(ru, &proc->timestamp_rx, *tti, IF5_RRH_GW_UL);
-  proc->frame_rx    = (proc->timestamp_rx / (fp->samples_per_slot*20))&1023;
-  proc->tti_rx = (proc->timestamp_rx / fp->samples_per_slot)%20;
+  proc->frame_rx    = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023;
+  uint32_t idx_sf = proc->timestamp_rx / fp->samples_per_subframe;
+  proc->tti_rx = (idx_sf * fp->slots_per_subframe + (int)round((float)(proc->timestamp_rx % fp->samples_per_subframe) / fp->samples_per_slot0))%(fp->slots_per_frame);
 
   if (proc->first_rx == 0) {
     if (proc->tti_rx != *tti) {
@@ -391,12 +389,12 @@ void fh_if4p5_south_in(RU_t *ru,
   } while(proc->symbol_mask[sl] != symbol_mask_full);
 
   //caculate timestamp_rx, timestamp_tx based on frame and subframe
-  proc->tti_rx  = sl;
-  proc->frame_rx     = f;
-  proc->timestamp_rx = ((proc->frame_rx * fp->slots_per_frame)  + proc->tti_rx ) * fp->samples_per_slot ;
+  proc->tti_rx   = sl;
+  proc->frame_rx = f;
+  proc->timestamp_rx = (proc->frame_rx * fp->samples_per_subframe * 10)  + fp->get_samples_slot_timestamp(proc->tti_rx, fp, 0);
   //  proc->timestamp_tx = proc->timestamp_rx +  (4*fp->samples_per_subframe);
-  proc->tti_tx  = (sl+sl_ahead)%fp->slots_per_frame;
-  proc->frame_tx     = (sl>(fp->slots_per_frame-sl_ahead)) ? (f+1)&1023 : f;
+  proc->tti_tx   = (sl+(fp->slots_per_subframe*sf_ahead))%fp->slots_per_frame;
+  proc->frame_tx = (sl>(fp->slots_per_frame-1-(fp->slots_per_subframe*sf_ahead))) ? (f+1)&1023 : f;
 
   if (proc->first_rx == 0) {
     if (proc->tti_rx != *slot) {
@@ -503,8 +501,9 @@ void fh_if5_north_asynch_in(RU_t *ru,int *frame,int *slot) {
   openair0_timestamp timestamp_tx;
   recv_IF5(ru, &timestamp_tx, *slot, IF5_RRH_GW_DL);
   //      printf("Received subframe %d (TS %llu) from RCC\n",tti_tx,timestamp_tx);
-  tti_tx = (timestamp_tx/fp->samples_per_slot)%fp->slots_per_frame;
-  frame_tx    = (timestamp_tx/(fp->samples_per_slot*fp->slots_per_frame))&1023;
+  frame_tx    = (timestamp_tx / (fp->samples_per_subframe*10))&1023;
+  uint32_t idx_sf = timestamp_tx / fp->samples_per_subframe;
+  tti_tx = (idx_sf * fp->slots_per_subframe + (int)round((float)(timestamp_tx % fp->samples_per_subframe) / fp->samples_per_slot0))%(fp->slots_per_frame);
 
   if (proc->first_tx != 0) {
     *slot = tti_tx;
@@ -520,7 +519,7 @@ void fh_if5_north_asynch_in(RU_t *ru,int *frame,int *slot) {
 
 void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *slot) {
   NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms;
-  nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config;
+  nfapi_nr_config_request_scf_t *cfg = &ru->gNB_list[0]->gNB_config;
   RU_proc_t *proc        = &ru->proc;
   uint16_t packet_type;
   uint32_t symbol_number,symbol_mask,symbol_mask_full=0;
@@ -533,10 +532,10 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *slot) {
   do {
     recv_IF4p5(ru, &frame_tx, &slot_tx, &packet_type, &symbol_number);
 
-    if ((nr_slot_select(cfg,slot_tx,frame_tx) == SF_DL) && (symbol_number == 0)) start_meas(&ru->rx_fhaul);
+    if (((nr_slot_select(cfg,frame_tx,slot_tx) & NR_DOWNLINK_SLOT) > 0) && (symbol_number == 0)) start_meas(&ru->rx_fhaul);
 
-    LOG_D(PHY,"subframe %d (%d): frame %d, subframe %d, symbol %d\n",
-          *slot,nr_slot_select(cfg,*slot,*frame),frame_tx,slot_tx,symbol_number);
+    LOG_D(PHY,"slot %d (%d): frame %d, slot %d, symbol %d\n",
+          *slot,nr_slot_select(cfg,frame_tx,*slot),frame_tx,slot_tx,symbol_number);
 
     if (proc->first_tx != 0) {
       *frame         = frame_tx;
@@ -555,14 +554,14 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *slot) {
     } else AssertFatal(1==0,"Illegal IF4p5 packet type (should only be IF4p5_PDLFFT%d\n",packet_type);
   } while (symbol_mask != symbol_mask_full);
 
-  if (nr_slot_select(cfg,slot_tx,frame_tx) == SF_DL) stop_meas(&ru->rx_fhaul);
+  if ((nr_slot_select(cfg,frame_tx,slot_tx) & NR_DOWNLINK_SLOT)>0) stop_meas(&ru->rx_fhaul);
 
-  proc->tti_tx  = slot_tx;
-  proc->frame_tx     = frame_tx;
+  proc->tti_tx = slot_tx;
+  proc->frame_tx = frame_tx;
 
   if ((frame_tx == 0)&&(slot_tx == 0)) proc->frame_tx_unwrap += 1024;
 
-  proc->timestamp_tx = ((((uint64_t)frame_tx + (uint64_t)proc->frame_tx_unwrap) * fp->slots_per_frame) + (uint64_t)slot_tx) * (uint64_t)fp->samples_per_slot;
+  proc->timestamp_tx = (((uint64_t)frame_tx + (uint64_t)proc->frame_tx_unwrap) * fp->samples_per_subframe * 10) + fp->get_samples_slot_timestamp(slot_tx, fp, 0);
   LOG_D(PHY,"RU %d/%d TST %llu, frame %d, subframe %d\n",ru->idx,0,(long long unsigned int)proc->timestamp_tx,frame_tx,slot_tx);
 
   // dump VCD output for first RU in list
@@ -604,7 +603,7 @@ void fh_if4p5_north_out(RU_t *ru) {
   stop_meas(&ru->tx_fhaul);
 }
 
-static void *emulatedRF_thread(void *param) {
+void *emulatedRF_thread(void *param) {
   RU_proc_t *proc = (RU_proc_t *) param;
   int microsec = 500; // length of time to sleep, in miliseconds
   struct timespec req = {0};
@@ -629,26 +628,27 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
   void *rxp[ru->nb_rx];
   unsigned int rxs;
   int i;
+  uint32_t samples_per_slot = fp->get_samples_per_slot(*slot,fp);
   openair0_timestamp ts,old_ts;
   AssertFatal(*slot<fp->slots_per_frame && *slot>=0, "slot %d is illegal (%d)\n",*slot,fp->slots_per_frame);
 
   for (i=0; i<ru->nb_rx; i++)
-    rxp[i] = (void *)&ru->common.rxdata[i][*slot*fp->samples_per_slot];
+    rxp[i] = (void *)&ru->common.rxdata[i][fp->get_samples_slot_timestamp(*slot,fp,0)];
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 );
   old_ts = proc->timestamp_rx;
-  LOG_D(PHY,"Reading %d samples for slot %d (%p)\n",fp->samples_per_slot,*slot,rxp[0]);
+  LOG_D(PHY,"Reading %d samples for slot %d (%p)\n",samples_per_slot,*slot,rxp[0]);
 
   if(emulate_rf) {
     wait_on_condition(&proc->mutex_emulateRF,&proc->cond_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread");
     release_thread(&proc->mutex_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread");
-    rxs = fp->samples_per_slot;
+    rxs = samples_per_slot;
     ts = old_ts + rxs;
   } else {
     rxs = ru->rfdevice.trx_read_func(&ru->rfdevice,
                                      &ts,
                                      rxp,
-                                     fp->samples_per_slot,
+                                     samples_per_slot,
                                      ru->nb_rx);
   }
 
@@ -658,21 +658,22 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
 
   //AssertFatal(rxs == fp->samples_per_subframe,
   //"rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_subframe,rxs);
-  if (rxs != fp->samples_per_slot) LOG_E(PHY, "rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_slot,rxs);
+  if (rxs != samples_per_slot) LOG_E(PHY, "rx_rf: Asked for %d samples, got %d from USRP\n",samples_per_slot,rxs);
 
   if (proc->first_rx == 1) {
     ru->ts_offset = proc->timestamp_rx;
     proc->timestamp_rx = 0;
   } else {
-    if (proc->timestamp_rx - old_ts != fp->samples_per_slot) {
-      LOG_D(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - fp->samples_per_slot,ru->ts_offset);
-      ru->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_slot);
+    if (proc->timestamp_rx - old_ts != fp->get_samples_per_slot((*slot-1)%fp->slots_per_frame,fp)) {
+      LOG_D(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - samples_per_slot,ru->ts_offset);
+      ru->ts_offset += (proc->timestamp_rx - old_ts - samples_per_slot);
       proc->timestamp_rx = ts-ru->ts_offset;
     }
   }
 
-  proc->frame_rx     = (proc->timestamp_rx / (fp->samples_per_slot*fp->slots_per_frame))&1023;
-  proc->tti_rx       = (proc->timestamp_rx / fp->samples_per_slot)%fp->slots_per_frame;
+  proc->frame_rx    = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023;
+  uint32_t idx_sf = proc->timestamp_rx / fp->samples_per_subframe;
+  proc->tti_rx = (idx_sf * fp->slots_per_subframe + (int)round((float)(proc->timestamp_rx % fp->samples_per_subframe) / fp->samples_per_slot0))%(fp->slots_per_frame);
   // synchronize first reception to frame 0 subframe 0
   LOG_D(PHY,"RU %d/%d TS %llu (off %d), frame %d, slot %d.%d / %d\n",
         ru->idx,
@@ -688,7 +689,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
 
   if (proc->first_rx == 0) {
     if (proc->tti_rx != *slot) {
-      LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->tti_rx %d, subframe %d)\n",(long long unsigned int)proc->timestamp_rx,proc->tti_rx,*slot);
+      LOG_E(PHY,"Received Timestamp (%llu) doesn't correspond to the time we think it is (proc->tti_rx %d, slot %d)\n",(long long unsigned int)proc->timestamp_rx,proc->tti_rx,*slot);
       exit_fun("Exiting");
     }
 
@@ -705,7 +706,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
   //printf("timestamp_rx %lu, frame %d(%d), subframe %d(%d)\n",ru->timestamp_rx,proc->frame_rx,frame,proc->tti_rx,subframe);
   VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff );
 
-  if (rxs != fp->samples_per_slot) {
+  if (rxs != samples_per_slot) {
     //exit_fun( "problem receiving samples" );
     LOG_E(PHY, "problem receiving samples\n");
   }
@@ -715,69 +716,83 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
 void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { 
   RU_proc_t *proc = &ru->proc;
   NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms;
-  //nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config;
+  nfapi_nr_config_request_scf_t *cfg = &ru->gNB_list[0]->gNB_config;
   void *txp[ru->nb_tx];
   unsigned int txs;
-  int i;
+  int i,txsymb;
   T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(frame), T_INT(slot),
-    T_INT(0), T_BUFFER(&ru->common.txdata[0][slot * fp->samples_per_slot], fp->samples_per_slot * 4));
-  int sf_extension = 0;
-  //nr_subframe_t SF_type     = nr_slot_select(cfg,slot%fp->slots_per_frame,frame);
-
-  if ((slot == 0) ||
-      (slot == 1) || IS_SOFTMODEM_RFSIM ) {
-    int siglen=fp->samples_per_slot;
-    int flags;
-    if (slot==0)
-      flags = 2;
-    else if (slot==1)
-      flags=3;
-    else
-      flags=4;
-
-    /*
-        if (SF_type == SF_S) {
-          siglen = fp->dl_symbols_in_S_subframe*(fp->ofdm_symbol_size+fp->nb_prefix_samples0);
-          flags=3; // end of burst
-        }
-        if ((fp->frame_type == TDD) &&
-      (SF_type == SF_DL)&&
-      (prevSF_type == SF_UL) &&
-      (nextSF_type == SF_DL)) {
-          flags = 2; // start of burst
-          sf_extension = ru->N_TA_offset<<1;
-        }
-
-        if ((cfg->subframe_config.duplex_mode == TDD) &&
-      (SF_type == SF_DL)&&
-      (prevSF_type == SF_UL) &&
-      (nextSF_type == SF_UL)) {
-          flags = 4; // start of burst and end of burst (only one DL SF between two UL)
-          sf_extension = ru->N_TA_offset<<1;
-        } */
-    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, frame );
-    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, slot );
+    T_INT(0), T_BUFFER(&ru->common.txdata[0][fp->get_samples_slot_timestamp(slot,fp,0)], fp->samples_per_subframe * 4));
+
+  int slot_type         = nr_slot_select(cfg,frame,slot%fp->slots_per_frame);
+  int prevslot_type     = nr_slot_select(cfg,frame,(slot+(fp->slots_per_frame-1))%fp->slots_per_frame);
+  int nextslot_type     = nr_slot_select(cfg,frame,(slot+1)%fp->slots_per_frame);
+  int sf_extension  = 0;                 //sf_extension = ru->sf_extension;
+  int siglen=fp->get_samples_per_slot(slot,fp);
+  int flags=1;
+
+  //nr_subframe_t SF_type     = nr_slot_select(cfg,slot%fp->slots_per_frame);
+  if (slot_type == NR_DOWNLINK_SLOT || slot_type == NR_MIXED_SLOT || IS_SOFTMODEM_RFSIM) {
+
+    if(slot_type == NR_MIXED_SLOT) {
+      txsymb = 0;
+      for(int symbol_count =0;symbol_count<NR_NUMBER_OF_SYMBOLS_PER_SLOT;symbol_count++) {
+        if (cfg->tdd_table.max_tdd_periodicity_list[slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value==0)
+          txsymb++;
+      }
+      AssertFatal(txsymb>0,"illegal txsymb %d\n",txsymb);
+      if(slot%(fp->slots_per_subframe/2))
+        siglen = txsymb * (fp->ofdm_symbol_size + fp->nb_prefix_samples);
+      else
+        siglen = (fp->ofdm_symbol_size + fp->nb_prefix_samples0) + (txsymb - 1) * (fp->ofdm_symbol_size + fp->nb_prefix_samples);
+               //+ ru->end_of_burst_delay;
+      flags=3; // end of burst
+    }
 
-    for (i=0; i<ru->nb_tx; i++){
-      txp[i] = (void *)&ru->common.txdata[i][(slot*fp->samples_per_slot)-sf_extension];
+    if (cfg->cell_config.frame_duplex_type.value == TDD &&
+        slot_type == NR_DOWNLINK_SLOT &&
+        prevslot_type == NR_UPLINK_SLOT) {
+      flags = 2; // start of burst
     }
 
+    if (cfg->cell_config.frame_duplex_type.value == TDD &&
+        slot_type == NR_DOWNLINK_SLOT &&
+        nextslot_type == NR_UPLINK_SLOT) {
+      flags = 3; // end of burst
+    }
 
-    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp-ru->openair0_cfg.tx_sample_advance)&0xffffffff );
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 );
-    // prepare tx buffer pointers
-    start_meas(&ru->tx_fhaul);
-    txs = ru->rfdevice.trx_write_func(&ru->rfdevice,
-                                      timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension,
-                                      txp,
-                                      siglen+sf_extension,
-                                      ru->nb_tx,
-                                      flags);
-    stop_meas(&ru->tx_fhaul);
-    LOG_D(PHY,"[TXPATH] RU %d tx_rf, writing to TS %llu, frame %d, unwrapped_frame %d, subframe %d\n",ru->idx,
-          (long long unsigned int)timestamp,frame,proc->frame_tx_unwrap,slot);
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 );
-    AssertFatal(txs ==  siglen+sf_extension,"TX : Timeout (sent %u/%d)\n", txs, siglen);
+    if (fp->freq_range==nr_FR2) {
+      // the beam index is written in bits 8-10 of the flags
+      // bit 11 enables the gpio programming
+      int beam=0;
+      if (slot==0) beam = 11; //3 for boresight & 8 to enable
+      /*
+      if (slot==0 || slot==40) beam=0&8;
+      if (slot==10 || slot==50) beam=1&8;
+      if (slot==20 || slot==60) beam=2&8;
+      if (slot==30 || slot==70) beam=3&8;
+      */
+      flags |= beam<<8;
+    }
+    
+    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_WRITE_FLAGS, flags ); 
+    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, frame );
+    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, slot );
+    for (i=0; i<ru->nb_tx; i++)
+      txp[i] = (void *)&ru->common.txdata[i][fp->get_samples_slot_timestamp(slot,fp,0)-sf_extension];
+    
+      VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp-ru->openair0_cfg.tx_sample_advance)&0xffffffff );
+      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 );
+      // prepare tx buffer pointers
+      txs = ru->rfdevice.trx_write_func(&ru->rfdevice,
+					timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension,
+					txp,
+					siglen+sf_extension,
+					ru->nb_tx,
+					flags);
+      LOG_D(PHY,"[TXPATH] RU %d tx_rf, writing to TS %llu, frame %d, unwrapped_frame %d, slot %d\n",ru->idx,
+	    (long long unsigned int)timestamp,frame,proc->frame_tx_unwrap,slot);
+      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 );
+      AssertFatal(txs ==  siglen+sf_extension,"TX : Timeout (sent %u/%d)\n", txs, siglen);
   }
 }
 
@@ -789,11 +804,12 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) {
  * \param param is a \ref gNB_L1_proc_t structure which contains the info what to process.
  * \returns a pointer to an int. The storage is not on the heap and must not be freed.
  */
-static void *ru_thread_asynch_rxtx( void *param ) {
+void *ru_thread_asynch_rxtx( void *param ) {
   static int ru_thread_asynch_rxtx_status;
   RU_t *ru         = (RU_t *)param;
   RU_proc_t *proc  = &ru->proc;
-  int subframe=0, frame=0;
+  nfapi_nr_config_request_scf_t *cfg = &ru->gNB_list[0]->gNB_config;
+  int slot=0, frame=0;
   // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe
   wait_sync("ru_thread_asynch_rxtx");
   // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe
@@ -803,22 +819,20 @@ static void *ru_thread_asynch_rxtx( void *param ) {
 
   while (!oai_exit) {
 
-    if (subframe==9) {
-      subframe=0;
+    if (slot==ru->nr_frame_parms->slots_per_frame) {
+      slot=0;
       frame++;
       frame&=1023;
     } else {
-      subframe++;
+      slot++;
     }
 
     LOG_D(PHY,"ru_thread_asynch_rxtx: Waiting on incoming fronthaul\n");
 
-    // asynchronous receive from south (Mobipass)
-    if (ru->fh_south_asynch_in) ru->fh_south_asynch_in(ru,&frame,&subframe);
     // asynchronous receive from north (RRU IF4/IF5)
-    else if (ru->fh_north_asynch_in) {
-      if (nr_slot_select(&ru->gNB_list[0]->gNB_config,subframe,frame)!=SF_UL)
-        ru->fh_north_asynch_in(ru,&frame,&subframe);
+    if (ru->fh_north_asynch_in) {
+      if ((nr_slot_select(cfg,frame,slot) & NR_DOWNLINK_SLOT)>0)
+        ru->fh_north_asynch_in(ru,&frame,&slot);
     } else AssertFatal(1==0,"Unknown function in ru_thread_asynch_rxtx\n");
   }
 
@@ -834,7 +848,7 @@ static void *ru_thread_asynch_rxtx( void *param ) {
  * \param param is a \ref RU_proc_t structure which contains the info what to process.
  * \returns a pointer to an int. The storage is not on the heap and must not be freed.
  */
-static void *ru_thread_prach( void *param ) {
+void *ru_thread_prach( void *param ) {
   static int ru_thread_prach_status;
   RU_t *ru        = (RU_t *)param;
   RU_proc_t *proc = (RU_proc_t *)&ru->proc;
@@ -1004,7 +1018,7 @@ void wakeup_gNB_L1s(RU_t *ru) {
   }
 }
 
-static inline int wakeup_prach_ru(RU_t *ru) {
+int wakeup_prach_ru(RU_t *ru) {
   struct timespec wait;
   wait.tv_sec=0;
   wait.tv_nsec=5000000L;
@@ -1039,10 +1053,10 @@ static inline int wakeup_prach_ru(RU_t *ru) {
 void fill_rf_config(RU_t *ru, char *rf_config_file) {
   int i;
   NR_DL_FRAME_PARMS *fp   = ru->nr_frame_parms;
-  nfapi_nr_config_request_t *gNB_config = &ru->gNB_list[0]->gNB_config; //tmp index
+  nfapi_nr_config_request_scf_t *gNB_config = &ru->gNB_list[0]->gNB_config; //tmp index
   openair0_config_t *cfg   = &ru->openair0_cfg;
-  int N_RB = gNB_config->rf_config.dl_carrier_bandwidth.value;
-  int mu = gNB_config->subframe_config.numerology_index_mu.value;
+  int mu = gNB_config->ssb_config.scs_common.value;
+  int N_RB = gNB_config->carrier_config.dl_grid_size[gNB_config->ssb_config.scs_common.value].value;
 
   if (mu == NR_MU_0) { //or if LTE
     if(N_RB == 100) {
@@ -1111,11 +1125,23 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) {
     } else {
       AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",N_RB,mu);
     }
+  } else if (mu == NR_MU_3) {
+    if (N_RB == 66) {
+      cfg->sample_rate = 122.88e6;
+      cfg->samples_per_frame = 1228800;
+      cfg->tx_bw = 100e6;
+      cfg->rx_bw = 100e6;
+    } else if(N_RB == 32) {
+      cfg->sample_rate=61.44e6;
+      cfg->samples_per_frame = 614400;
+      cfg->tx_bw = 50e6;
+      cfg->rx_bw = 50e6;
+    }
   } else {
     AssertFatal(0 == 1,"Numerology %d not supported for the moment\n",mu);
   }
 
-  if (gNB_config->subframe_config.duplex_mode.value==TDD)
+  if (gNB_config->cell_config.frame_duplex_type.value==TDD)
     cfg->duplex_mode = duplex_mode_TDD;
   else //FDD
     cfg->duplex_mode = duplex_mode_FDD;
@@ -1126,8 +1152,14 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) {
   cfg->rx_num_channels=ru->nb_rx;
 
   for (i=0; i<ru->nb_tx; i++) {
-    cfg->tx_freq[i] = (double)fp->dl_CarrierFreq;
-    cfg->rx_freq[i] = (double)fp->ul_CarrierFreq;
+    if (ru->if_frequency == 0) {
+      cfg->tx_freq[i] = (double)fp->dl_CarrierFreq;
+      cfg->rx_freq[i] = (double)fp->ul_CarrierFreq;
+    }
+    else {
+      cfg->tx_freq[i] = (double)ru->if_frequency;
+      cfg->rx_freq[i] = (double)(ru->if_frequency+fp->ul_CarrierFreq-fp->dl_CarrierFreq);
+    }
     cfg->tx_gain[i] = ru->att_tx;
     cfg->rx_gain[i] = ru->max_rxgain-ru->att_rx;
     cfg->configFilename = rf_config_file;
@@ -1199,7 +1231,7 @@ int setup_RU_buffers(RU_t *ru) {
   return(0);
 }
 
-static void *ru_stats_thread(void *param) {
+void *ru_stats_thread(void *param) {
   RU_t               *ru      = (RU_t *)param;
   wait_sync("ru_stats_thread");
 
@@ -1230,7 +1262,7 @@ static void *ru_stats_thread(void *param) {
   return(NULL);
 }
 
-static void *ru_thread_tx( void *param ) {
+void *ru_thread_tx( void *param ) {
   RU_t               *ru      = (RU_t *)param;
   RU_proc_t          *proc    = &ru->proc;
   NR_DL_FRAME_PARMS  *fp      = ru->nr_frame_parms;
@@ -1250,7 +1282,10 @@ static void *ru_thread_tx( void *param ) {
 
     LOG_D(PHY,"ru_thread_tx: Waiting for TX processing\n");
     // wait until eNBs are finished subframe RX n and TX n+4
+
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RU_TX_WAIT, 1 );
     wait_on_condition(&proc->mutex_gNBs,&proc->cond_gNBs,&proc->instance_cnt_gNBs,"ru_thread_tx");
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RU_TX_WAIT, 0 );
 
     ret = pthread_mutex_lock(&proc->mutex_gNBs);
     AssertFatal(ret == 0,"mutex_lock return %d\n",ret);
@@ -1345,12 +1380,12 @@ static void *ru_thread_tx( void *param ) {
         // the thread can now be woken up
         if (L1_proc->instance_cnt_RUs == -1) {
           L1_proc->instance_cnt_RUs = 0;
+          VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_UE,L1_proc->instance_cnt_RUs);
           AssertFatal(pthread_cond_signal(&L1_proc->cond_RUs) == 0,
                        "ERROR pthread_cond_signal for gNB_L1_thread\n");
         } //else AssertFatal(1==0,"gNB TX thread is not ready\n");
         ret = pthread_mutex_unlock(&L1_proc->mutex_RUs_tx);
         AssertFatal(ret == 0,"mutex_unlock returns %d\n",ret);
-        VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_UE,L1_proc->instance_cnt_RUs);
       }
     }
   }
@@ -1359,7 +1394,7 @@ static void *ru_thread_tx( void *param ) {
   return 0;
 }
 
-static void *ru_thread( void *param ) {
+void *ru_thread( void *param ) {
   static int ru_thread_status;
   RU_t               *ru      = (RU_t *)param;
   RU_proc_t          *proc    = &ru->proc;
@@ -1372,6 +1407,8 @@ static void *ru_thread( void *param ) {
   int                i = 0;
   int                aa;
 
+  nfapi_nr_config_request_scf_t *cfg = &ru->gNB_list[0]->gNB_config;
+  
   // set default return value
   ru_thread_status = 0;
   // set default return value
@@ -1417,6 +1454,7 @@ static void *ru_thread( void *param ) {
     }
   }
 
+  sf_ahead = (uint16_t) ceil((float)6/(0x01<<fp->numerology_index));
   LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx);
   pthread_mutex_lock(&RC.ru_mutex);
   RC.ru_mask &= ~(1<<ru->idx);
@@ -1468,12 +1506,12 @@ static void *ru_thread( void *param ) {
     if (ru->fh_south_in) ru->fh_south_in(ru,&frame,&slot);
     else AssertFatal(1==0, "No fronthaul interface at south port");
 
-    LOG_D(PHY,"AFTER fh_south_in - SFN/SL:%d%d RU->proc[RX:%d.%d TX:%d.%d] RC.gNB[0][0]:[RX:%d%d TX(SFN):%d]\n",
+    LOG_D(PHY,"AFTER fh_south_in - SFN/SL:%d%d RU->proc[RX:%d.%d TX:%d.%d] RC.gNB[0]:[RX:%d%d TX(SFN):%d]\n",
           frame,slot,
           proc->frame_rx,proc->tti_rx,
           proc->frame_tx,proc->tti_tx,
-          RC.gNB[0][0]->proc.frame_rx,RC.gNB[0][0]->proc.slot_rx,
-          RC.gNB[0][0]->proc.frame_tx);
+          RC.gNB[0]->proc.frame_rx,RC.gNB[0]->proc.slot_rx,
+	  RC.gNB[0]->proc.frame_tx);
     /*
           LOG_D(PHY,"RU thread (do_prach %d, is_prach_subframe %d), received frame %d, subframe %d\n",
               ru->do_prach,
@@ -1490,19 +1528,21 @@ static void *ru_thread( void *param ) {
 
     // do RX front-end processing (frequency-shift, dft) if needed
 
-    if (proc->tti_rx == NR_UPLINK_SLOT || fp->frame_type == FDD) {
+    int slot_type = nr_slot_select(cfg,proc->frame_rx,proc->tti_rx);
+    if (slot_type == NR_UPLINK_SLOT || slot_type == NR_MIXED_SLOT) {
+    //if (proc->tti_rx==8) {
 
       if (ru->feprx) ru->feprx(ru,proc->tti_rx);
-
+      //LOG_M("rxdata.m","rxs",ru->common.rxdata[0],1228800,1,1);
+
+      LOG_D(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx);
+      LOG_D(PHY,"Copying rxdataF from RU to gNB\n");
+      
+      for (aa=0;aa<ru->nb_rx;aa++)
+	memcpy((void*)RC.gNB[0]->common_vars.rxdataF[aa],
+	       (void*)ru->common.rxdataF[aa], fp->symbols_per_slot*fp->ofdm_symbol_size*sizeof(int32_t));
     }
 
-    LOG_D(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx);
-    LOG_D(PHY,"Copying rxdataF from RU to gNB\n");
-
-    for (aa=0;aa<ru->nb_rx;aa++)
-      memcpy((void*)RC.gNB[0][0]->common_vars.rxdataF[aa],
-         (void*)ru->common.rxdataF[aa], fp->symbols_per_slot*fp->ofdm_symbol_size*sizeof(int32_t));
-
     // At this point, all information for subframe has been received on FH interface
 
     // wakeup all gNB processes waiting for this RU
@@ -1814,19 +1854,19 @@ int check_capabilities(RU_t *ru,RRU_capabilities_t *cap)
   FH_fmt_options_t fmt = cap->FH_fmt;
   int i;
   int found_band=0;
-  LOG_I(PHY,"RRU %d, num_bands %d, looking for band %d\n",ru->idx,cap->num_bands,ru->nr_frame_parms->eutra_band);
+  LOG_I(PHY,"RRU %d, num_bands %d, looking for band %d\n",ru->idx,cap->num_bands,ru->nr_frame_parms->nr_band);
 
   for (i=0; i<cap->num_bands; i++) {
     LOG_I(PHY,"band %d on RRU %d\n",cap->band_list[i],ru->idx);
 
-    if (ru->nr_frame_parms->eutra_band == cap->band_list[i]) {
+    if (ru->nr_frame_parms->nr_band == cap->band_list[i]) {
       found_band=1;
       break;
     }
   }
 
   if (found_band == 0) {
-    LOG_I(PHY,"Couldn't find target EUTRA band %d on RRU %d\n",ru->nr_frame_parms->eutra_band,ru->idx);
+    LOG_I(PHY,"Couldn't find target NR band %d on RRU %d\n",ru->nr_frame_parms->nr_band,ru->idx);
     return(-1);
   }
 
@@ -1871,7 +1911,7 @@ void configure_ru(int idx,
   RU_t               *ru           = RC.ru[idx];
   RRU_config_t       *config       = (RRU_config_t *)arg;
   RRU_capabilities_t *capabilities = (RRU_capabilities_t *)arg;
-  nfapi_nr_config_request_t *gNB_config = &ru->gNB_list[0]->gNB_config;
+  nfapi_nr_config_request_scf_t *gNB_config = &ru->gNB_list[0]->gNB_config;
   int ret;
   LOG_I(PHY, "Received capabilities from RRU %d\n",idx);
 
@@ -1883,19 +1923,19 @@ void configure_ru(int idx,
   ru->nb_tx                      = capabilities->nb_tx[0];
   ru->nb_rx                      = capabilities->nb_rx[0];
   // Pass configuration to RRU
-  LOG_I(PHY, "Using %s fronthaul (%d), band %d \n",ru_if_formats[ru->if_south],ru->if_south,ru->nr_frame_parms->eutra_band);
+  LOG_I(PHY, "Using %s fronthaul (%d), band %d \n",ru_if_formats[ru->if_south],ru->if_south,ru->nr_frame_parms->nr_band);
   // wait for configuration
   config->FH_fmt                 = ru->if_south;
   config->num_bands              = 1;
-  config->band_list[0]           = ru->nr_frame_parms->eutra_band;
+  config->band_list[0]           = ru->nr_frame_parms->nr_band;
   config->tx_freq[0]             = ru->nr_frame_parms->dl_CarrierFreq;
   config->rx_freq[0]             = ru->nr_frame_parms->ul_CarrierFreq;
   //config->tdd_config[0]          = ru->nr_frame_parms->tdd_config;
   //config->tdd_config_S[0]        = ru->nr_frame_parms->tdd_config_S;
   config->att_tx[0]              = ru->att_tx;
   config->att_rx[0]              = ru->att_rx;
-  config->N_RB_DL[0]             = gNB_config->rf_config.dl_carrier_bandwidth.value;
-  config->N_RB_UL[0]             = gNB_config->rf_config.ul_carrier_bandwidth.value;
+  config->N_RB_DL[0]             = gNB_config->carrier_config.dl_grid_size[gNB_config->ssb_config.scs_common.value].value;
+  config->N_RB_UL[0]             = gNB_config->carrier_config.dl_grid_size[gNB_config->ssb_config.scs_common.value].value;
   config->threequarter_fs[0]     = ru->nr_frame_parms->threequarter_fs;
   /*  if (ru->if_south==REMOTE_IF4p5) {
       config->prach_FreqOffset[0]  = ru->nr_frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset;
@@ -1910,22 +1950,23 @@ void configure_rru(int idx,
                    void *arg) {
   RRU_config_t *config     = (RRU_config_t *)arg;
   RU_t         *ru         = RC.ru[idx];
-  nfapi_nr_config_request_t *gNB_config = &ru->gNB_list[0]->gNB_config;
-  ru->nr_frame_parms->eutra_band                                          = config->band_list[0];
+  nfapi_nr_config_request_scf_t *gNB_config = &ru->gNB_list[0]->gNB_config;
+  ru->nr_frame_parms->nr_band                                             = config->band_list[0];
   ru->nr_frame_parms->dl_CarrierFreq                                      = config->tx_freq[0];
   ru->nr_frame_parms->ul_CarrierFreq                                      = config->rx_freq[0];
 
   if (ru->nr_frame_parms->dl_CarrierFreq == ru->nr_frame_parms->ul_CarrierFreq) {
-    gNB_config->subframe_config.duplex_mode.value                         = TDD;
+    gNB_config->cell_config.frame_duplex_type.value                       = TDD;
     //ru->nr_frame_parms->tdd_config                                        = config->tdd_config[0];
     //ru->nr_frame_parms->tdd_config_S                                      = config->tdd_config_S[0];
   } else
-    gNB_config->subframe_config.duplex_mode.value                         = FDD;
+    gNB_config->cell_config.frame_duplex_type.value                       = FDD;
 
   ru->att_tx                                                              = config->att_tx[0];
   ru->att_rx                                                              = config->att_rx[0];
-  gNB_config->rf_config.dl_carrier_bandwidth.value                        = config->N_RB_DL[0];
-  gNB_config->rf_config.ul_carrier_bandwidth.value                        = config->N_RB_UL[0];
+  int mu = gNB_config->ssb_config.scs_common.value;
+  gNB_config->carrier_config.dl_grid_size[mu].value                       = config->N_RB_DL[0];
+  gNB_config->carrier_config.dl_grid_size[mu].value                       = config->N_RB_UL[0];
   ru->nr_frame_parms->threequarter_fs                                     = config->threequarter_fs[0];
 
   //ru->nr_frame_parms->pdsch_config_common.referenceSignalPower                 = ru->max_pdschReferenceSignalPower-config->att_tx[0];
@@ -2117,8 +2158,6 @@ void set_function_spec_param(RU_t *ru) {
   } // switch on interface type
 }
 
-extern void RCconfig_RU(void);
-
 void init_NR_RU(char *rf_config_file)
 {
   int ru_id;
@@ -2137,10 +2176,6 @@ void init_NR_RU(char *rf_config_file)
   RCconfig_RU();
   LOG_I(PHY,"number of L1 instances %d, number of RU %d, number of CPU cores %d\n",RC.nb_nr_L1_inst,RC.nb_RU,get_nprocs());
 
-  if (RC.nb_nr_CC != 0)
-    for (i=0; i<RC.nb_nr_L1_inst; i++)
-      for (CC_id=0; CC_id<RC.nb_nr_CC[i]; CC_id++) RC.gNB[i][CC_id]->num_RU=0;
-
   LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU);
 
   for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
@@ -2153,11 +2188,11 @@ void init_NR_RU(char *rf_config_file)
     // NOTE: multiple CC_id are not handled here yet!
 
     if (ru->num_gNB > 0) {
-      LOG_D(PHY, "%s() RC.ru[%d].num_gNB:%d ru->gNB_list[0]:%p RC.gNB[0][0]:%p rf_config_file:%s\n", __FUNCTION__, ru_id, ru->num_gNB, ru->gNB_list[0], RC.gNB[0][0], ru->rf_config_file);
+      LOG_D(PHY, "%s() RC.ru[%d].num_gNB:%d ru->gNB_list[0]:%p RC.gNB[0]:%p rf_config_file:%s\n", __FUNCTION__, ru_id, ru->num_gNB, ru->gNB_list[0], RC.gNB[0], ru->rf_config_file);
 
       if (ru->gNB_list[0] == 0) {
         LOG_E(PHY,"%s() DJP - ru->gNB_list ru->num_gNB are not initialized - so do it manually\n", __FUNCTION__);
-        ru->gNB_list[0] = RC.gNB[0][0];
+        ru->gNB_list[0] = RC.gNB[0];
         ru->num_gNB=1;
         //
         // DJP - feptx_prec() / feptx_ofdm() parses the gNB_list (based on num_gNB) and copies the txdata_F to txdata in RU
@@ -2167,7 +2202,7 @@ void init_NR_RU(char *rf_config_file)
       }
     }
 
-    gNB_RC           = RC.gNB[0][0];
+    gNB_RC           = RC.gNB[0];
     gNB0             = ru->gNB_list[0];
     fp               = ru->nr_frame_parms;
     LOG_D(PHY, "RU FUnction:%d ru->if_south:%d\n", ru->function, ru->if_south);
@@ -2239,7 +2274,7 @@ void RCconfig_RU(void)
       else
         RC.ru[j]->num_gNB                           = 0;
 
-      for (i=0; i<RC.ru[j]->num_gNB; i++) RC.ru[j]->gNB_list[i] = RC.gNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0];
+      for (i=0; i<RC.ru[j]->num_gNB; i++) RC.ru[j]->gNB_list[i] = RC.gNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]];
 
       if (config_isparamset(RUParamList.paramarray[j], RU_SDR_ADDRS)) {
         RC.ru[j]->openair0_cfg.sdr_addrs = strdup(*(RUParamList.paramarray[j][RU_SDR_ADDRS].strptr));
@@ -2332,18 +2367,14 @@ void RCconfig_RU(void)
           RC.ru[j]->if_south                     = REMOTE_IF4p5;
           RC.ru[j]->function                     = NGFI_RAU_IF4p5;
           RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF4p5_MODE;
-        } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw_if5_mobipass") == 0) {
-          RC.ru[j]->if_south                     = REMOTE_IF5;
-          RC.ru[j]->function                     = NGFI_RAU_IF5;
-          RC.ru[j]->if_timing                    = synch_to_other;
-          RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF5_MOBIPASS;
-        }
+        } 
       }  /* strcmp(local_rf, "yes") != 0 */
 
       RC.ru[j]->nb_tx                             = *(RUParamList.paramarray[j][RU_NB_TX_IDX].uptr);
       RC.ru[j]->nb_rx                             = *(RUParamList.paramarray[j][RU_NB_RX_IDX].uptr);
       RC.ru[j]->att_tx                            = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr);
       RC.ru[j]->att_rx                            = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr);
+      RC.ru[j]->if_frequency                      = *(RUParamList.paramarray[j][RU_IF_FREQUENCY].u64ptr);
 
       if (config_isparamset(RUParamList.paramarray[j], RU_BF_WEIGHTS_LIST_IDX)) {
         RC.ru[j]->nb_bfw = RUParamList.paramarray[j][RU_BF_WEIGHTS_LIST_IDX].numelt;
@@ -2359,3 +2390,4 @@ void RCconfig_RU(void)
 
   return;
 }
+
diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h
index e6aafafeb99..ccb3f28d98e 100644
--- a/executables/nr-softmodem-common.h
+++ b/executables/nr-softmodem-common.h
@@ -83,6 +83,7 @@
 #define CONFIG_HLP_TNOFORK       "to ease debugging with gdb\n"
 #define CONFIG_HLP_DISABLNBIOT   "disable nb-iot, even if defined in config\n"
 #define CONFIG_HLP_DISABLETIMECORR   "disable UE timing correction\n"
+#define CONFIG_HLP_RRC_CFG_PATH   "path for RRC configuration\n"
 
 #define CONFIG_HLP_NUMEROLOGY    "adding numerology for 5G\n"
 #define CONFIG_HLP_EMULATE_RF    "Emulated RF enabled(disable by defult)\n"
@@ -126,7 +127,7 @@ extern pthread_mutex_t sync_mutex;
 extern int sync_var;
 
 
-extern uint32_t downlink_frequency[MAX_NUM_CCs][4];
+extern uint64_t downlink_frequency[MAX_NUM_CCs][4];
 extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
 
 extern int rx_input_level_dBm;
diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c
index df6c48d8665..04c515e556b 100644
--- a/executables/nr-softmodem.c
+++ b/executables/nr-softmodem.c
@@ -84,6 +84,7 @@ unsigned short config_frames[4] = {2,9,11,13};
 #include "executables/softmodem-common.h"
 #include "executables/thread-common.h"
 #include "NB_IoT_interface.h"
+#include "x2ap_eNB.h"
 
 short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT] = {0,0,16384,16384,-16384,-16384,16384,16384,16384,-16384,-16384,16384,-16384,-16384,7327,7327,7327,21981,21981,7327,21981,21981,7327,-7327,7327,-21981,21981,-7327,21981,-21981,-7327,7327,-7327,21981,-21981,7327,-21981,21981,-7327,-7327,-7327,-21981,-21981,-7327,-21981,-21981,10726,10726,10726,3576,3576,10726,3576,3576,10726,17876,10726,25027,3576,17876,3576,25027,17876,10726,17876,3576,25027,10726,25027,3576,17876,17876,17876,25027,25027,17876,25027,25027,10726,-10726,10726,-3576,3576,-10726,3576,-3576,10726,-17876,10726,-25027,3576,-17876,3576,-25027,17876,-10726,17876,-3576,25027,-10726,25027,-3576,17876,-17876,17876,-25027,25027,-17876,25027,-25027,-10726,10726,-10726,3576,-3576,10726,-3576,3576,-10726,17876,-10726,25027,-3576,17876,-3576,25027,-17876,10726,-17876,3576,-25027,10726,-25027,3576,-17876,17876,-17876,25027,-25027,17876,-25027,25027,-10726,-10726,-10726,-3576,-3576,-10726,-3576,-3576,-10726,-17876,-10726,-25027,-3576,-17876,-3576,-25027,-17876,-10726,-17876,-3576,-25027,-10726,-25027,-3576,-17876,-17876,-17876,-25027,-25027,-17876,-25027,-25027,8886,8886,8886,12439,12439,8886,12439,12439,8886,5332,8886,1778,12439,5332,12439,1778,5332,8886,5332,12439,1778,8886,1778,12439,5332,5332,5332,1778,1778,5332,1778,1778,8886,19547,8886,15993,12439,19547,12439,15993,8886,23101,8886,26655,12439,23101,12439,26655,5332,19547,5332,15993,1778,19547,1778,15993,5332,23101,5332,26655,1778,23101,1778,26655,19547,8886,19547,12439,15993,8886,15993,12439,19547,5332,19547,1778,15993,5332,15993,1778,23101,8886,23101,12439,26655,8886,26655,12439,23101,5332,23101,1778,26655,5332,26655,1778,19547,19547,19547,15993,15993,19547,15993,15993,19547,23101,19547,26655,15993,23101,15993,26655,23101,19547,23101,15993,26655,19547,26655,15993,23101,23101,23101,26655,26655,23101,26655,26655,8886,-8886,8886,-12439,12439,-8886,12439,-12439,8886,-5332,8886,-1778,12439,-5332,12439,-1778,5332,-8886,5332,-12439,1778,-8886,1778,-12439,5332,-5332,5332,-1778,1778,-5332,1778,-1778,8886,-19547,8886,-15993,12439,-19547,12439,-15993,8886,-23101,8886,-26655,12439,-23101,12439,-26655,5332,-19547,5332,-15993,1778,-19547,1778,-15993,5332,-23101,5332,-26655,1778,-23101,1778,-26655,19547,-8886,19547,-12439,15993,-8886,15993,-12439,19547,-5332,19547,-1778,15993,-5332,15993,-1778,23101,-8886,23101,-12439,26655,-8886,26655,-12439,23101,-5332,23101,-1778,26655,-5332,26655,-1778,19547,-19547,19547,-15993,15993,-19547,15993,-15993,19547,-23101,19547,-26655,15993,-23101,15993,-26655,23101,-19547,23101,-15993,26655,-19547,26655,-15993,23101,-23101,23101,-26655,26655,-23101,26655,-26655,-8886,8886,-8886,12439,-12439,8886,-12439,12439,-8886,5332,-8886,1778,-12439,5332,-12439,1778,-5332,8886,-5332,12439,-1778,8886,-1778,12439,-5332,5332,-5332,1778,-1778,5332,-1778,1778,-8886,19547,-8886,15993,-12439,19547,-12439,15993,-8886,23101,-8886,26655,-12439,23101,-12439,26655,-5332,19547,-5332,15993,-1778,19547,-1778,15993,-5332,23101,-5332,26655,-1778,23101,-1778,26655,-19547,8886,-19547,12439,-15993,8886,-15993,12439,-19547,5332,-19547,1778,-15993,5332,-15993,1778,-23101,8886,-23101,12439,-26655,8886,-26655,12439,-23101,5332,-23101,1778,-26655,5332,-26655,1778,-19547,19547,-19547,15993,-15993,19547,-15993,15993,-19547,23101,-19547,26655,-15993,23101,-15993,26655,-23101,19547,-23101,15993,-26655,19547,-26655,15993,-23101,23101,-23101,26655,-26655,23101,-26655,26655,-8886,-8886,-8886,-12439,-12439,-8886,-12439,-12439,-8886,-5332,-8886,-1778,-12439,-5332,-12439,-1778,-5332,-8886,-5332,-12439,-1778,-8886,-1778,-12439,-5332,-5332,-5332,-1778,-1778,-5332,-1778,-1778,-8886,-19547,-8886,-15993,-12439,-19547,-12439,-15993,-8886,-23101,-8886,-26655,-12439,-23101,-12439,-26655,-5332,-19547,-5332,-15993,-1778,-19547,-1778,-15993,-5332,-23101,-5332,-26655,-1778,-23101,-1778,-26655,-19547,-8886,-19547,-12439,-15993,-8886,-15993,-12439,-19547,-5332,-19547,-1778,-15993,-5332,-15993,-1778,-23101,-8886,-23101,-12439,-26655,-8886,-26655,-12439,-23101,-5332,-23101,-1778,-26655,-5332,-26655,-1778,-19547,-19547,-19547,-15993,-15993,-19547,-15993,-15993,-19547,-23101,-19547,-26655,-15993,-23101,-15993,-26655,-23101,-19547,-23101,-15993,-26655,-19547,-26655,-15993,-23101,-23101,-23101,-26655,-26655,-23101,-26655,-26655};
 
@@ -109,7 +110,7 @@ int single_thread_flag=1;
 
 static int8_t threequarter_fs=0;
 
-uint32_t downlink_frequency[MAX_NUM_CCs][4];
+uint64_t downlink_frequency[MAX_NUM_CCs][4];
 int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
 
 //Temp fix for inexistent NR upper layer
@@ -200,7 +201,7 @@ char uecap_xer_in=0;
 uint8_t abstraction_flag=0;
 
 /* forward declarations */
-void set_default_frame_parms(nfapi_nr_config_request_t *config[MAX_NUM_CCs], NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]);
+void set_default_frame_parms(nfapi_nr_config_request_scf_t *config[MAX_NUM_CCs], NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]);
 
 /*---------------------BMC: timespec helpers -----------------------------*/
 
@@ -385,6 +386,18 @@ int create_gNB_tasks(uint32_t gnb_nb) {
       LOG_E(GNB_APP, "Create task for gNB APP failed\n");
       return -1;
     }
+    if(itti_create_task(TASK_SCTP, sctp_eNB_task, NULL) < 0){
+    	LOG_E(SCTP, "Create task for SCTP failed\n");
+    	return -1;
+    }
+    if (is_x2ap_enabled()) {
+    	if(itti_create_task(TASK_X2AP, x2ap_task, NULL) < 0){
+    		LOG_E(X2AP, "Create task for X2AP failed\n");
+    	}
+    }
+    else {
+    	LOG_I(X2AP, "X2AP is disabled.\n");
+    }
   }
 
   /*
@@ -453,18 +466,18 @@ static void get_options(void) {
 }
 
 
-void set_default_frame_parms(nfapi_nr_config_request_t *config[MAX_NUM_CCs],
-		                     NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs])
+void set_default_frame_parms(nfapi_nr_config_request_scf_t *config[MAX_NUM_CCs],
+		             NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs])
 {
   for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
     frame_parms[CC_id] = (NR_DL_FRAME_PARMS *) malloc(sizeof(NR_DL_FRAME_PARMS));
-    config[CC_id] = (nfapi_nr_config_request_t *) malloc(sizeof(nfapi_nr_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_carrier_bandwidth.value = 106;
-    config[CC_id]->rf_config.ul_carrier_bandwidth.value = 106;
-    config[CC_id]->sch_config.physical_cell_id.value = 0;
+    config[CC_id] = (nfapi_nr_config_request_scf_t *) malloc(sizeof(nfapi_nr_config_request_scf_t));
+    config[CC_id]->ssb_config.scs_common.value = 1;
+    config[CC_id]->cell_config.frame_duplex_type.value = 1; //FDD
+    //config[CC_id]->subframe_config.dl_cyclic_prefix_type.value = 0; //NORMAL
+    config[CC_id]->carrier_config.dl_grid_size[1].value = 106;
+    config[CC_id]->carrier_config.ul_grid_size[1].value = 106;
+    config[CC_id]->cell_config.phy_cell_id.value = 0;
     ///dl frequency to be filled in
     /*  //Set some default values that may be overwritten while reading options
         frame_parms[CC_id]->frame_type          = FDD;
@@ -476,7 +489,7 @@ void set_default_frame_parms(nfapi_nr_config_request_t *config[MAX_NUM_CCs],
         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_antenna_ports_gNB  = 1;
         frame_parms[CC_id]->nb_antennas_tx      = 1;
         frame_parms[CC_id]->nb_antennas_rx      = 1;
 
@@ -553,8 +566,8 @@ void init_openair0(void) {
       openair0_cfg[card].duplex_mode = duplex_mode_FDD;
 
     printf("HW: Configuring card %d, nb_antennas_tx/rx %d/%d\n",card,
-     RC.gNB[0][0]->gNB_config.rf_config.tx_antenna_ports.value,
-     RC.gNB[0][0]->gNB_config.rf_config.tx_antenna_ports.value );
+     RC.gNB[0]->gNB_config.rf_config.tx_antenna_ports.value,
+     RC.gNB[0]->gNB_config.rf_config.tx_antenna_ports.value );
     openair0_cfg[card].Mod_id = 0;
 
     openair0_cfg[card].num_rb_dl=config[0]->rf_config.dl_carrier_bandwidth.value;
@@ -562,8 +575,8 @@ void init_openair0(void) {
     openair0_cfg[card].clock_source = clock_source;
 
 
-    openair0_cfg[card].tx_num_channels=min(2,RC.gNB[0][0]->gNB_config.rf_config.tx_antenna_ports.value );
-    openair0_cfg[card].rx_num_channels=min(2,RC.gNB[0][0]->gNB_config.rf_config.tx_antenna_ports.value );
+    openair0_cfg[card].tx_num_channels=min(2,RC.gNB[0]->gNB_config.rf_config.tx_antenna_ports.value );
+    openair0_cfg[card].rx_num_channels=min(2,RC.gNB[0]->gNB_config.rf_config.tx_antenna_ports.value );
 
     for (i=0; i<4; i++) {
 
@@ -579,7 +592,7 @@ void init_openair0(void) {
 
       openair0_cfg[card].autocal[i] = 1;
       openair0_cfg[card].tx_gain[i] = tx_gain[0][i];
-      openair0_cfg[card].rx_gain[i] = RC.gNB[0][0]->rx_total_gain_dB;
+      openair0_cfg[card].rx_gain[i] = RC.gNB[0]->rx_total_gain_dB;
 
 
       openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file;
@@ -608,7 +621,7 @@ void wait_RUs(void) {
 }
 
 void wait_gNBs(void) {
-  int i,j;
+  int i;
   int waiting=1;
 
   while (waiting==1) {
@@ -617,13 +630,10 @@ void wait_gNBs(void) {
     waiting=0;
 
     for (i=0; i<RC.nb_nr_L1_inst; i++) {
-      printf("RC.nb_nr_L1_CC[%d]:%d\n", i, RC.nb_nr_L1_CC[i]);
 
-      for (j=0; j<RC.nb_nr_L1_CC[i]; j++) {
-        if (RC.gNB[i][j]->configured==0) {
-          waiting=1;
-          break;
-        }
+      if (RC.gNB[i]->configured==0) {
+	waiting=1;
+	break;
       }
     }
   }
@@ -682,10 +692,9 @@ int stop_L1L2(module_id_t gnb_id) {
   kill_NR_RU_proc(gnb_id);
   oai_exit = 0;
 
-  for (int cc_id = 0; cc_id < RC.nb_nr_CC[gnb_id]; cc_id++) {
-    //free_transport(RC.gNB[gnb_id][cc_id]);
-    phy_free_nr_gNB(RC.gNB[gnb_id][cc_id]);
-  }
+    //free_transport(RC.gNB[gnb_id]);
+  phy_free_nr_gNB(RC.gNB[gnb_id]);
+
 
   nr_phy_free_RU(RC.ru[gnb_id]);
   free_lte_top();
@@ -703,14 +712,13 @@ int restart_L1L2(module_id_t gnb_id) {
   /* block threads */
   sync_var = -1;
 
-  for (cc_id = 0; cc_id < RC.nb_nr_L1_CC[gnb_id]; cc_id++) {
-    RC.gNB[gnb_id][cc_id]->configured = 0;
-  }
+  RC.gNB[gnb_id]->configured = 0;
+  
 
   RC.ru_mask |= (1 << ru->idx);
   /* copy the changed frame parameters to the RU */
   /* TODO this should be done for all RUs associated to this gNB */
-  memcpy(&ru->nr_frame_parms, &RC.gNB[gnb_id][0]->frame_parms, sizeof(NR_DL_FRAME_PARMS));
+  memcpy(&ru->nr_frame_parms, &RC.gNB[gnb_id]->frame_parms, sizeof(NR_DL_FRAME_PARMS));
   set_function_spec_param(RC.ru[gnb_id]);
   LOG_I(GNB_APP, "attempting to create ITTI tasks\n");
 
@@ -784,9 +792,10 @@ void init_pdcp(void) {
   }*/
 }
 
+
 int main( int argc, char **argv )
 {
-  int i, ru_id, CC_id = 0;
+  int ru_id, CC_id = 0;
   start_background_system();
 
   ///static configuration for NR at the moment
@@ -859,11 +868,13 @@ if(!IS_SOFTMODEM_NOS1)
   }
 
   /* Start the agent. If it is turned off in the configuration, it won't start */
+  /*
   RCconfig_nr_flexran();
 
   for (i = 0; i < RC.nb_nr_L1_inst; i++) {
     flexran_agent_start(i);
   }
+*/
 
   // init UE_PF_PO and mutex lock
   pthread_mutex_init(&ue_pf_po_mutex, NULL);
@@ -871,38 +882,8 @@ if(!IS_SOFTMODEM_NOS1)
   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_l2 = create_form_stats_form();
-    fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats");
-    form_stats = create_form_stats_form();
-    fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats");
-
-    for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) {
-      for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-        form_gnb[CC_id][UE_id] = create_phy_scope_gnb();
-        sprintf (title, "LTE UL SCOPE eNB for CC_id %d, UE %d",CC_id,UE_id);
-        fl_show_form (form_gnb[CC_id][UE_id]->phy_scope_gnb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title);
-
-        if (otg_enabled) {
-          fl_set_button(form_gnb[CC_id][UE_id]->button_0,1);
-          fl_set_object_label(form_gnb[CC_id][UE_id]->button_0,"DL Traffic ON");
-        } else {
-          fl_set_button(form_gnb[CC_id][UE_id]->button_0,0);
-          fl_set_object_label(form_gnb[CC_id][UE_id]->button_0,"DL Traffic OFF");
-        }
-      } // CC_id
-    } // UE_id
 
-    threadCreate(&forms_thread, scope_thread, NULL, "scope", -1, OAI_PRIORITY_RT_LOW);
-    printf("Scope thread created, ret=%d\n",ret);
-  }
-
-#endif*/
-  usleep(10*1000);
+  usleep(1000);
 
   if (nfapi_mode) {
     printf("NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n");
@@ -972,6 +953,13 @@ if(!IS_SOFTMODEM_NOS1)
   // once all RUs are ready initialize the rest of the gNBs ((dependence on final RU parameters after configuration)
   printf("ALL RUs ready - init gNBs\n");
 
+  if (do_forms==1) {
+    scopeParms_t p;
+    p.argc=&argc;
+    p.argv=argv;
+    startScope(&p);
+  }
+
   if (nfapi_mode != 1 && nfapi_mode != 2) {
     printf("Not NFAPI mode - call init_eNB_afterRU()\n");
     init_eNB_afterRU();
@@ -1028,10 +1016,8 @@ if(!IS_SOFTMODEM_NOS1)
   /* release memory used by the RU/gNB threads (incomplete), after all
    * threads have been stopped (they partially use the same memory) */
   for (int inst = 0; inst < NB_gNB_INST; inst++) {
-    for (int cc_id = 0; cc_id < RC.nb_nr_CC[inst]; cc_id++) {
-      //free_transport(RC.gNB[inst][cc_id]);
-      phy_free_nr_gNB(RC.gNB[inst][cc_id]);
-    }
+      //free_transport(RC.gNB[inst]);
+      phy_free_nr_gNB(RC.gNB[inst]);
   }
 
   for (int inst = 0; inst < NB_RU; inst++) {
diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h
index 20316bff2e5..27e3ba1e3e3 100644
--- a/executables/nr-softmodem.h
+++ b/executables/nr-softmodem.h
@@ -22,7 +22,7 @@
     {"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},        \
     {"A" ,                    CONFIG_HLP_TADV,        0,                uptr:&timing_advance,               defintval:0,                   TYPE_UINT,   0},        \
-    {"C" ,                    CONFIG_HLP_DLF,         0,                uptr:&(downlink_frequency[0][0]),   defuintval:DEFAULT_DLF,        TYPE_UINT,   0},        \
+    {"C" ,                    CONFIG_HLP_DLF,         0,                u64ptr:&(downlink_frequency[0][0]), defuintval:DEFAULT_DLF,        TYPE_UINT64, 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},        \
diff --git a/executables/nr-ue.c b/executables/nr-ue.c
index b4af0f68eac..131710ee020 100644
--- a/executables/nr-ue.c
+++ b/executables/nr-ue.c
@@ -136,14 +136,12 @@ typedef enum {
 } sync_mode_t;
 
 
-PHY_VARS_NR_UE *init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms,
-                                uint8_t UE_id,
-                                uint8_t abstraction_flag)
-
+void init_nr_ue_vars(PHY_VARS_NR_UE *ue,
+                     NR_DL_FRAME_PARMS *frame_parms,
+                     uint8_t UE_id,
+                     uint8_t abstraction_flag)
 {
-  PHY_VARS_NR_UE *ue;
-  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));
 
   ue->Mod_id      = UE_id;
@@ -153,7 +151,6 @@ PHY_VARS_NR_UE *init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms,
   init_nr_ue_signal(ue,1,abstraction_flag);
   // intialize transport
   init_nr_ue_transport(ue,abstraction_flag);
-  return(ue);
 }
 
 /*!
@@ -175,22 +172,19 @@ static void UE_synch(void *arg) {
   int freq_offset=0;
   UE->is_synchronized = 0;
 
-
   if (UE->UE_scan == 0) {
-    get_band(downlink_frequency[CC_id][0], &UE->frame_parms.eutra_band,   &uplink_frequency_offset[CC_id][0], &UE->frame_parms.frame_type);
-    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],
+    LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu64", UL %"PRIu64" (oai_exit %d, rx_num_channels %d)\n",
+           UE->frame_parms.dl_CarrierFreq, UE->frame_parms.ul_CarrierFreq,
            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].rx_freq[UE->rf_map.chain+i] = UE->frame_parms.dl_CarrierFreq;
+      openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = UE->frame_parms.ul_CarrierFreq;
       openair0_cfg[UE->rf_map.card].autocal[UE->rf_map.chain+i] = 1;
 
-      if (uplink_frequency_offset[CC_id][i] != 0) //
+      if (UE->frame_parms.frame_type == FDD) 
         openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_FDD;
-      else //FDD
+      else 
         openair0_cfg[UE->rf_map.card].duplex_mode = duplex_mode_TDD;
     }
 
@@ -248,13 +242,14 @@ static void UE_synch(void *arg) {
 
       if (nr_initial_sync( &syncD->proc, UE, UE->mode,2) == 0) {
         freq_offset = UE->common_vars.freq_offset; // frequency offset computed with pss in initial sync
-        hw_slot_offset = (UE->rx_offset<<1) / UE->frame_parms.samples_per_slot;
-        LOG_I(PHY,"Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %u, UL %u), UE_scan_carrier %d\n",
+        hw_slot_offset = ((UE->rx_offset<<1) / UE->frame_parms.samples_per_subframe * UE->frame_parms.slots_per_subframe) +
+                         round((float)((UE->rx_offset<<1) % UE->frame_parms.samples_per_subframe)/UE->frame_parms.samples_per_slot0);
+        LOG_I(PHY,"Got synch: hw_slot_offset %d, carrier off %d Hz, rxgain %d (DL %lu, UL %lu), 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->frame_parms.dl_CarrierFreq+freq_offset,
+              UE->frame_parms.ul_CarrierFreq+freq_offset,
               UE->UE_scan_carrier );
 
         // rerun with new cell parameters and frequency-offset
@@ -267,8 +262,8 @@ static void UE_synch(void *arg) {
             openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] -= abs(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];
+            openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i]+(UE->frame_parms.ul_CarrierFreq-UE->frame_parms.dl_CarrierFreq);
+          UE->frame_parms.dl_CarrierFreq = openair0_cfg[CC_id].rx_freq[i];
         }
 
         // reconfigure for potentially different bandwidth
@@ -300,6 +295,12 @@ static void UE_synch(void *arg) {
             openair0_cfg[UE->rf_map.card].tx_bw=10.0e6;
             //            openair0_cfg[0].rx_gain[0] -= 0;
             break;
+
+          case 66:
+            openair0_cfg[UE->rf_map.card].sample_rate=122.88e6;
+            openair0_cfg[UE->rf_map.card].rx_bw=100.e6;
+            openair0_cfg[UE->rf_map.card].tx_bw=100.e6;
+            break;
         }
 
         if (UE->mode != loop_through_memory) {
@@ -327,15 +328,15 @@ static void UE_synch(void *arg) {
             freq_offset += 100;
 
           freq_offset *= -1;
-          LOG_I(PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n",
+          LOG_I(PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %lu, UL %lu)\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 );
+                UE->frame_parms.dl_CarrierFreq+freq_offset,
+                UE->frame_parms.ul_CarrierFreq+freq_offset );
 
           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_freq[UE->rf_map.chain+i] = UE->frame_parms.dl_CarrierFreq+freq_offset;
+            openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] = UE->frame_parms.ul_CarrierFreq+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)
@@ -355,45 +356,43 @@ static void UE_synch(void *arg) {
   }
 }
 
-void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) {
-
-  nr_dcireq_t dcireq;
-  nr_scheduled_response_t scheduled_response;
+void processSlotTX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) {
   uint32_t nb_rb, start_rb;
   uint8_t nb_symb_sch, start_symbol, mcs, precod_nbr_layers, harq_pid, rvidx;
   uint16_t n_rnti;
 
-  // Process Rx data for one sub-frame
-  if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_DOWNLINK_SLOT) {
-    //TODO: all of this has to be moved to the MAC!!!
+  nr_dcireq_t dcireq;
+  nr_scheduled_response_t scheduled_response;
+
+  // program PUSCH. this should actually be done by the MAC upon reception of an UL DCI
+  if (proc->nr_tti_tx == 8 || UE->frame_parms.frame_type == FDD){
+
     dcireq.module_id = UE->Mod_id;
     dcireq.gNB_index = 0;
     dcireq.cc_id     = 0;
     dcireq.frame     = proc->frame_rx;
     dcireq.slot      = proc->nr_tti_rx;
-    nr_ue_dcireq(&dcireq); //to be replaced with function pointer later
 
-    scheduled_response.dl_config = &dcireq.dl_config_req;
+    scheduled_response.dl_config = NULL;
     scheduled_response.ul_config = &dcireq.ul_config_req;
     scheduled_response.tx_request = NULL;
     scheduled_response.module_id = UE->Mod_id;
     scheduled_response.CC_id     = 0;
     scheduled_response.frame = proc->frame_rx;
     scheduled_response.slot  = proc->nr_tti_rx;
-
     //--------------------------Temporary configuration-----------------------------//
     n_rnti = 0x1234;
     nb_rb = 50;
     start_rb = 0;
     nb_symb_sch = 12;
-    start_symbol = 0;
+    start_symbol = 2;
     precod_nbr_layers = 1;
     mcs = 9;
     harq_pid = 0;
     rvidx = 0;
-  //------------------------------------------------------------------------------//
+    //------------------------------------------------------------------------------//
 
-    scheduled_response.ul_config->sfn_slot = NR_UPLINK_SLOT;
+    scheduled_response.ul_config->slot = 8;
     scheduled_response.ul_config->number_pdus = 1;
     scheduled_response.ul_config->ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
     scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.rnti = n_rnti;
@@ -406,8 +405,53 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) {
     scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.rv = rvidx;
     scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = precod_nbr_layers;
     scheduled_response.ul_config->ul_config_list[0].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = harq_pid;
+
+    nr_ue_scheduled_response(&scheduled_response);
+    
+    if (UE->mode != loop_through_memory) {
+      uint8_t thread_id = PHY_vars_UE_g[UE->Mod_id][0]->current_thread_id[proc->nr_tti_tx];
+      phy_procedures_nrUE_TX(UE,proc,0,thread_id);
+    }
+  }
+}
+
+void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) {
+
+  nr_dcireq_t dcireq;
+  nr_scheduled_response_t scheduled_response;
+  uint8_t  ssb_period = UE->nrUE_config.ssb_table.ssb_period; 
+
+  //program DCI for slot 1
+  //TODO: all of this has to be moved to the MAC!!!
+  if (proc->nr_tti_rx == NR_DOWNLINK_SLOT || UE->frame_parms.frame_type == FDD){
+    dcireq.module_id = UE->Mod_id;
+    dcireq.gNB_index = 0;
+    dcireq.cc_id     = 0;
+    dcireq.frame     = proc->frame_rx;
+    dcireq.slot      = proc->nr_tti_rx;
+    nr_ue_dcireq(&dcireq); //to be replaced with function pointer later
+
+    // we should have received a DL DCI here, so configure DL accordingly
+    scheduled_response.dl_config = &dcireq.dl_config_req;
+    scheduled_response.ul_config = NULL;
+    scheduled_response.tx_request = NULL;
+    scheduled_response.module_id = UE->Mod_id;
+    scheduled_response.CC_id     = 0;
+    if (!((proc->frame_rx)%(1<<(ssb_period-1)))) {
+      if(proc->frame_rx > dcireq.dl_config_req.sfn)
+        UE->frame_gap = proc->frame_rx - dcireq.dl_config_req.sfn;
+      if(proc->frame_rx < dcireq.dl_config_req.sfn)
+        UE->frame_gap = dcireq.dl_config_req.sfn - proc->frame_rx;
+      proc->frame_rx = dcireq.dl_config_req.sfn;
+    }
+    scheduled_response.frame = proc->frame_rx;
+    scheduled_response.slot = proc->nr_tti_rx;
+
     nr_ue_scheduled_response(&scheduled_response);
+  }
 
+  // Process Rx data for one sub-frame
+  if ( proc->nr_tti_rx >=0 && proc->nr_tti_rx <= 1 ) {
 #ifdef UE_SLOT_PARALLELISATION
     phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL );
 #else
@@ -416,14 +460,15 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) {
     LOG_D(PHY,"phy_procedures_nrUE_RX: slot:%d, time %lu\n", proc->nr_tti_rx, (rdtsc()-a)/3500);
     //printf(">>> nr_ue_pdcch_procedures ended\n");
 #endif
-  if(IS_SOFTMODEM_NOS1){ //&& proc->nr_tti_rx==1
-	  //Hardcoded rnti value
-	  protocol_ctxt_t ctxt;
-	  PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE->Mod_id, ENB_FLAG_NO,
-                                   0x1234, proc->frame_rx,
-                                   proc->nr_tti_rx, 0);
-	  pdcp_run(&ctxt);
-  }
+
+    if(IS_SOFTMODEM_NOS1){ //&& proc->nr_tti_rx==1
+      //Hardcoded rnti value
+      protocol_ctxt_t ctxt;
+      PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE->Mod_id, ENB_FLAG_NO,
+				     0x1234, proc->frame_rx,
+				     proc->nr_tti_rx, 0);
+      pdcp_run(&ctxt);
+    }
   }
 
   
@@ -458,11 +503,10 @@ typedef struct processingData_s {
 }  processingData_t;
 
 void UE_processing(void *arg) {
-  uint8_t thread_id;
   processingData_t *rxtxD=(processingData_t *) arg;
   UE_nr_rxtx_proc_t *proc = &rxtxD->proc;
   PHY_VARS_NR_UE    *UE   = rxtxD->UE;
-  processSlotRX(UE, proc);
+
   uint8_t gNB_id = 0;
 
   // params for UL time alignment procedure
@@ -472,18 +516,6 @@ void UE_processing(void *arg) {
   int slot_tx = proc->nr_tti_tx;
   int frame_tx = proc->frame_tx;
 
-  //printf(">>> mac ended\n");
-  // Prepare the future Tx data
-/*
-#ifndef NO_RAT_NR
-
-  if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_UPLINK_SLOT)
-#else
-  if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) ||
-      (UE->frame_parms.frame_type == FDD) )
-#endif
-*/
-
   /* UL time alignment
   // If the current tx frame and slot match the TA configuration in ul_time_alignment
   // then timing advance is processed and set to be applied in the next UL transmission */
@@ -500,80 +532,60 @@ void UE_processing(void *arg) {
     }
   }
 
-  if (proc->nr_tti_tx == NR_UPLINK_SLOT || UE->frame_parms.frame_type == FDD){
-
-    thread_id = PHY_vars_UE_g[UE->Mod_id][0]->current_thread_id[proc->nr_tti_tx];
-
-
-    if (UE->mode != loop_through_memory)
-      phy_procedures_nrUE_TX(UE,proc,gNB_id,thread_id);
-
-  }
-
-  //phy_procedures_UE_TX(UE,proc,0,0,UE->mode,no_relay);
-
-#if 0
+  processSlotRX(UE, proc);
 
-  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);
+  processSlotTX(UE, proc);
 
-#endif
 }
 
-void readFrame(PHY_VARS_NR_UE *UE,  openair0_timestamp *timestamp) {
-  void *rxp[NB_ANTENNAS_RX];
+void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockSize) {
   void *dummy_tx[UE->frame_parms.nb_antennas_tx];
 
   for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
-    dummy_tx[i]=malloc16_clear(UE->frame_parms.samples_per_subframe*4);
+    dummy_tx[i]=malloc16_clear(writeBlockSize*4);
 
-  for(int x=0; x<20; x++) {  // two frames for initial sync
-    for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
-      rxp[i] = ((void *)&UE->common_vars.rxdata[i][0]) + 4*x*UE->frame_parms.samples_per_subframe;
-
-    AssertFatal( UE->frame_parms.samples_per_subframe ==
-                 UE->rfdevice.trx_read_func(&UE->rfdevice,
-                                            timestamp,
-                                            rxp,
-                                            UE->frame_parms.samples_per_subframe,
-                                            UE->frame_parms.nb_antennas_rx), "");
-  }
+  AssertFatal( writeBlockSize ==
+               UE->rfdevice.trx_write_func(&UE->rfdevice,
+               timestamp,
+               dummy_tx,
+               writeBlockSize,
+               UE->frame_parms.nb_antennas_tx,
+               4),"");
 
   for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
     free(dummy_tx[i]);
 }
 
-void trashFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
-  void *dummy_tx[UE->frame_parms.nb_antennas_tx];
+void readFrame(PHY_VARS_NR_UE *UE,  openair0_timestamp *timestamp, bool toTrash) {
 
-  for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
-    dummy_tx[i]=malloc16_clear(UE->frame_parms.samples_per_subframe*4);
-
-  void *dummy_rx[UE->frame_parms.nb_antennas_rx];
-
-  for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
-    dummy_rx[i]=malloc16(UE->frame_parms.samples_per_subframe*4);
-
-  for (int sf=0; sf<NR_NUMBER_OF_SUBFRAMES_PER_FRAME; sf++) {
-    //      printf("Reading dummy sf %d\n",sf);
-    UE->rfdevice.trx_read_func(&UE->rfdevice,
-                               timestamp,
-                               dummy_rx,
-                               UE->frame_parms.samples_per_subframe,
-                               UE->frame_parms.nb_antennas_rx);
-    if (IS_SOFTMODEM_RFSIM ) {
-	 usleep(1000); // slow down, as would do actual rf to let cpu for the synchro thread
+  void *rxp[NB_ANTENNAS_RX];
+
+  for(int x=0; x<20; x++) {  // two frames for initial sync
+    for (int slot=0; slot<UE->frame_parms.slots_per_subframe; slot ++ ) {
+      for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) {
+        if (toTrash)
+          rxp[i]=malloc16(UE->frame_parms.get_samples_per_slot(slot,&UE->frame_parms)*4);
+        else
+          rxp[i] = ((void *)&UE->common_vars.rxdata[i][0]) +
+                   4*((x*UE->frame_parms.samples_per_subframe)+
+                   UE->frame_parms.get_samples_slot_timestamp(slot,&UE->frame_parms,0));
+      }
+        
+      AssertFatal( UE->frame_parms.get_samples_per_slot(slot,&UE->frame_parms) ==
+                   UE->rfdevice.trx_read_func(&UE->rfdevice,
+                   timestamp,
+                   rxp,
+                   UE->frame_parms.get_samples_per_slot(slot,&UE->frame_parms),
+                   UE->frame_parms.nb_antennas_rx), "");
+
+      if (IS_SOFTMODEM_RFSIM)
+        dummyWrite(UE,*timestamp, UE->frame_parms.get_samples_per_slot(slot,&UE->frame_parms));
+      if (toTrash)
+        for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
+          free(rxp[i]);
     }
   }
 
-  for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
-    free(dummy_tx[i]);
-
-  for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
-    free(dummy_rx[i]);
 }
 
 void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
@@ -581,22 +593,21 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
     LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode);
     void *dummy_tx[UE->frame_parms.nb_antennas_tx];
 
-    for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
-      dummy_tx[i]=malloc16_clear(UE->frame_parms.samples_per_subframe*4);
-
+    *timestamp += UE->frame_parms.get_samples_per_slot(1,&UE->frame_parms);
     for ( int size=UE->rx_offset ; size > 0 ; size -= UE->frame_parms.samples_per_subframe ) {
       int unitTransfer=size>UE->frame_parms.samples_per_subframe ? UE->frame_parms.samples_per_subframe : size ;
+      // we write before read becasue gNB waits for UE to write and both executions halt
+      // this happens here as the read size is samples_per_subframe which is very much larger than samp_per_slot
+      if (IS_SOFTMODEM_RFSIM) dummyWrite(UE,*timestamp, unitTransfer);
       AssertFatal(unitTransfer ==
                   UE->rfdevice.trx_read_func(&UE->rfdevice,
                                              timestamp,
                                              (void **)UE->common_vars.rxdata,
                                              unitTransfer,
                                              UE->frame_parms.nb_antennas_rx),"");
+      *timestamp += unitTransfer; // this does not affect the read but needed for RFSIM write
     }
 
-    for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
-      free(dummy_tx[i]);
-
 }
 
 int computeSamplesShift(PHY_VARS_NR_UE *UE) {
@@ -622,6 +633,22 @@ int computeSamplesShift(PHY_VARS_NR_UE *UE) {
   return 0;
 }
 
+static inline int get_firstSymSamp(uint16_t slot, NR_DL_FRAME_PARMS *fp) {
+  if (fp->numerology_index == 0)
+    return fp->nb_prefix_samples0 + fp->ofdm_symbol_size;
+  int num_samples = (slot%(fp->slots_per_subframe/2)) ? fp->nb_prefix_samples : fp->nb_prefix_samples0;
+  num_samples += fp->ofdm_symbol_size;
+  return num_samples;
+}
+
+static inline int get_readBlockSize(uint16_t slot, NR_DL_FRAME_PARMS *fp) {
+  int rem_samples = fp->get_samples_per_slot(slot, fp) - get_firstSymSamp(slot, fp);
+  int next_slot_first_symbol = 0;
+  if (slot < (fp->slots_per_frame-1))
+    next_slot_first_symbol = get_firstSymSamp(slot+1, fp);
+  return rem_samples + next_slot_first_symbol;
+}
+
 void *UE_thread(void *arg) {
   //this thread should be over the processing thread to keep in real time
   PHY_VARS_NR_UE *UE = (PHY_VARS_NR_UE *) arg;
@@ -629,7 +656,6 @@ void *UE_thread(void *arg) {
   openair0_timestamp timestamp;
   void *rxp[NB_ANTENNAS_RX], *txp[NB_ANTENNAS_TX];
   int start_rx_stream = 0;
-  const uint16_t table_sf_slot[20] = {0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9};
   AssertFatal(0== openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]), "");
   UE->rfdevice.host_type = RAU_HOST;
   AssertFatal(UE->rfdevice.trx_start_func(&UE->rfdevice) == 0, "Could not start the device\n");
@@ -639,13 +665,14 @@ void *UE_thread(void *arg) {
   int thread_idx=0;
   notifiedFIFO_t freeBlocks;
   initNotifiedFIFO_nothreadSafe(&freeBlocks);
+  NR_UE_MAC_INST_t *mac = get_mac_inst(0);
 
   for (int i=0; i<RX_NB_TH+1; i++)  // RX_NB_TH working + 1 we are making to be pushed
     pushNotifiedFIFO_nothreadSafe(&freeBlocks,
                                   newNotifiedFIFO_elt(sizeof(processingData_t), 0,&nf,UE_processing));
 
   bool syncRunning=false;
-  const int nb_slot_frame = 10*UE->frame_parms.slots_per_subframe;
+  const int nb_slot_frame = UE->frame_parms.slots_per_frame;
   int absolute_slot=0, decoded_frame_rx=INT_MAX, trashed_frames=0;
 
   while (!oai_exit) {
@@ -656,11 +683,11 @@ void *UE_thread(void *arg) {
         syncRunning=false;
         syncData_t *tmp=(syncData_t *)NotifiedFifoData(res);
         // shift the frame index with all the frames we trashed meanwhile we perform the synch search
-        decoded_frame_rx=(tmp->proc.decoded_frame_rx+trashed_frames) % MAX_FRAME_NUMBER;
+        decoded_frame_rx=(tmp->proc.decoded_frame_rx + (!UE->init_sync_frame) + trashed_frames) % MAX_FRAME_NUMBER;
         delNotifiedFIFO_elt(res);
       } else {
-        trashFrame(UE, &timestamp);
-        trashed_frames++;
+        readFrame(UE, &timestamp, true);
+        trashed_frames+=2;
         continue;
       }
     }
@@ -668,7 +695,7 @@ void *UE_thread(void *arg) {
     AssertFatal( !syncRunning, "At this point synchronization can't be running\n");
 
     if (!UE->is_synchronized) {
-      readFrame(UE, &timestamp);
+      readFrame(UE, &timestamp, false);
       notifiedFIFO_elt_t *Msg=newNotifiedFIFO_elt(sizeof(syncData_t),0,&nf,UE_synch);
       syncData_t *syncMsg=(syncData_t *)NotifiedFifoData(Msg);
       syncMsg->UE=UE;
@@ -695,7 +722,7 @@ void *UE_thread(void *arg) {
       // and we shifted above to the first slot of next frame
       decoded_frame_rx++;
       // we do ++ first in the regular processing, so it will be begin of frame;
-      absolute_slot=decoded_frame_rx*nb_slot_frame + nb_slot_frame -1;
+      absolute_slot=decoded_frame_rx*nb_slot_frame -1;
       continue;
     }
 
@@ -715,11 +742,11 @@ void *UE_thread(void *arg) {
     curMsg->UE->current_thread_id[slot_nr] = thread_idx;
     curMsg->proc.CC_id = 0;
     curMsg->proc.nr_tti_rx= slot_nr;
-    curMsg->proc.subframe_rx=table_sf_slot[slot_nr];
+    curMsg->proc.subframe_rx=slot_nr/(nb_slot_frame/10);
     curMsg->proc.nr_tti_tx = (absolute_slot + DURATION_RX_TO_TX) % nb_slot_frame;
     curMsg->proc.subframe_tx=curMsg->proc.nr_tti_rx;
-    curMsg->proc.frame_rx = ( absolute_slot/nb_slot_frame ) % MAX_FRAME_NUMBER;
-    curMsg->proc.frame_tx = ( (absolute_slot + DURATION_RX_TO_TX) /nb_slot_frame ) % MAX_FRAME_NUMBER;
+    curMsg->proc.frame_rx = ((absolute_slot/nb_slot_frame)+UE->frame_gap) % MAX_FRAME_NUMBER;
+    curMsg->proc.frame_tx = (((absolute_slot+DURATION_RX_TO_TX)/nb_slot_frame)+UE->frame_gap) % MAX_FRAME_NUMBER;
     curMsg->proc.decoded_frame_rx=-1;
     //LOG_I(PHY,"Process slot %d thread Idx %d total gain %d\n", slot_nr, thread_idx, UE->rx_total_gain_dB);
 
@@ -732,26 +759,25 @@ void *UE_thread(void *arg) {
     }*/
 #endif
 
+    int firstSymSamp = get_firstSymSamp(slot_nr, &UE->frame_parms);
     for (int 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+
-               slot_nr*UE->frame_parms.samples_per_slot];
+      rxp[i] = (void *)&UE->common_vars.rxdata[i][firstSymSamp+
+               UE->frame_parms.get_samples_slot_timestamp(slot_nr,&UE->frame_parms,0)];
 
     for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
-      txp[i] = (void *)&UE->common_vars.txdata[i][((curMsg->proc.nr_tti_rx + DURATION_RX_TO_TX)%nb_slot_frame)*UE->frame_parms.samples_per_slot];
+      txp[i] = (void *)&UE->common_vars.txdata[i][UE->frame_parms.get_samples_slot_timestamp(
+               ((curMsg->proc.nr_tti_rx + DURATION_RX_TO_TX)%nb_slot_frame),&UE->frame_parms,0)];
 
     int readBlockSize, writeBlockSize;
 
     if (slot_nr<(nb_slot_frame - 1)) {
-      readBlockSize=UE->frame_parms.samples_per_slot;
-      writeBlockSize=UE->frame_parms.samples_per_slot;
+      readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms);
+      writeBlockSize=UE->frame_parms.get_samples_per_slot(curMsg->proc.nr_tti_tx,&UE->frame_parms);
     } else {
       UE->rx_offset_diff = computeSamplesShift(UE);
-      readBlockSize=UE->frame_parms.samples_per_slot -
-                    UE->frame_parms.ofdm_symbol_size -
-                    UE->frame_parms.nb_prefix_samples0 -
+      readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms) -
                     UE->rx_offset_diff;
-      writeBlockSize=UE->frame_parms.samples_per_slot -
+      writeBlockSize=UE->frame_parms.get_samples_per_slot(curMsg->proc.nr_tti_tx,&UE->frame_parms) -
                      UE->rx_offset_diff;
     }
 
@@ -762,33 +788,20 @@ void *UE_thread(void *arg) {
                                            readBlockSize,
                                            UE->frame_parms.nb_antennas_rx),"");
 
-if (slot_nr == (20+NR_UPLINK_SLOT-DURATION_RX_TO_TX - 1)%20)
     AssertFatal( writeBlockSize ==
                  UE->rfdevice.trx_write_func(&UE->rfdevice,
                      timestamp+
-                     (DURATION_RX_TO_TX*UE->frame_parms.samples_per_slot) -
-                     UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0 -
+                     UE->frame_parms.get_samples_slot_timestamp(slot_nr,
+                     &UE->frame_parms,DURATION_RX_TO_TX) - firstSymSamp -
                      openair0_cfg[0].tx_sample_advance,
                      txp,
                      writeBlockSize,
                      UE->frame_parms.nb_antennas_tx,
-                     2),"");
-
-if (slot_nr == (20+NR_UPLINK_SLOT-DURATION_RX_TO_TX)%20)
-    AssertFatal( writeBlockSize ==
-                 UE->rfdevice.trx_write_func(&UE->rfdevice,
-                     timestamp+
-                     (DURATION_RX_TO_TX*UE->frame_parms.samples_per_slot) -
-                     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,
-                     3),"");
+                     1),"");
 
     if( slot_nr==(nb_slot_frame-1)) {
       // read in first symbol of next frame and adjust for timing drift
-      int first_symbols=writeBlockSize-readBlockSize;
+      int first_symbols=UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0; // first symbol of every frames
 
       if ( first_symbols > 0 )
         AssertFatal(first_symbols ==
@@ -802,8 +815,9 @@ if (slot_nr == (20+NR_UPLINK_SLOT-DURATION_RX_TO_TX)%20)
     }
 
     curMsg->proc.timestamp_tx = timestamp+
-                                (DURATION_RX_TO_TX*UE->frame_parms.samples_per_slot)-
-                                UE->frame_parms.ofdm_symbol_size-UE->frame_parms.nb_prefix_samples0;
+                                UE->frame_parms.get_samples_slot_timestamp(slot_nr,
+                                &UE->frame_parms,DURATION_RX_TO_TX) - firstSymSamp;
+
     notifiedFIFO_elt_t *res;
 
     while (nbSlotProcessing >= RX_NB_TH) {
@@ -812,7 +826,8 @@ if (slot_nr == (20+NR_UPLINK_SLOT-DURATION_RX_TO_TX)%20)
         processingData_t *tmp=(processingData_t *)res->msgData;
 
         if (tmp->proc.decoded_frame_rx != -1)
-          decoded_frame_rx=tmp->proc.decoded_frame_rx;
+          decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx);
+          //decoded_frame_rx=tmp->proc.decoded_frame_rx;
 
         pushNotifiedFIFO_nothreadSafe(&freeBlocks,res);
       }
@@ -838,7 +853,8 @@ if (slot_nr == (20+NR_UPLINK_SLOT-DURATION_RX_TO_TX)%20)
       processingData_t *tmp=(processingData_t *)res->msgData;
 
       if (tmp->proc.decoded_frame_rx != -1)
-        decoded_frame_rx=tmp->proc.decoded_frame_rx;
+        decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx);
+        //decoded_frame_rx=tmp->proc.decoded_frame_rx;
 
       pushNotifiedFIFO_nothreadSafe(&freeBlocks,res);
     }
@@ -847,30 +863,27 @@ if (slot_nr == (20+NR_UPLINK_SLOT-DURATION_RX_TO_TX)%20)
   return NULL;
 }
 
-void init_NR_UE(int nb_inst) {
+void init_NR_UE(int nb_inst, char* rrc_config_path) {
   int inst;
   NR_UE_MAC_INST_t *mac_inst;
+  NR_UE_RRC_INST_t* rrc_inst;
+  
+  for (inst=0; inst < nb_inst; inst++) {
+    AssertFatal((rrc_inst = nr_l3_init_ue(rrc_config_path)) != NULL, "can not initialize RRC module\n");
+    AssertFatal((mac_inst = nr_l2_init_ue(rrc_inst)) != NULL, "can not initialize L2 module\n");
+    AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initialize IF module\n");
+  }
+}
+
+void init_NR_UE_threads(int nb_inst) {
+  int inst;
+
   pthread_t threads[nb_inst];
 
   for (inst=0; inst < nb_inst; inst++) {
     PHY_VARS_NR_UE *UE = PHY_vars_UE_g[inst][0];
-    AssertFatal((UE->if_inst = nr_ue_if_module_init(inst)) != NULL, "can not initial IF module\n");
-    nr_l3_init_ue();
-    nr_l2_init_ue();
-    mac_inst = get_mac_inst(inst);
-    mac_inst->if_module = UE->if_inst;
-    // Initial bandwidth part configuration -- full carrier bandwidth
-    mac_inst->initial_bwp_dl.bwp_id = 0;
-    mac_inst->initial_bwp_dl.location = 0;
-    mac_inst->initial_bwp_dl.scs = UE->frame_parms.subcarrier_spacing;
-    mac_inst->initial_bwp_dl.N_RB = UE->frame_parms.N_RB_DL;
-    mac_inst->initial_bwp_dl.cyclic_prefix = UE->frame_parms.Ncp;
-    mac_inst->initial_bwp_ul.bwp_id = 0;
-    mac_inst->initial_bwp_ul.location = 0;
-    mac_inst->initial_bwp_ul.scs = UE->frame_parms.subcarrier_spacing;
-    mac_inst->initial_bwp_ul.N_RB = UE->frame_parms.N_RB_UL;
-    mac_inst->initial_bwp_ul.cyclic_prefix = UE->frame_parms.Ncp;
-    LOG_I(PHY,"Initializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]);
+
+    LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]);
     threadCreate(&threads[inst], UE_thread, (void *)UE, "UEthread", -1, OAI_PRIORITY_RT_MAX);
 
 #ifdef UE_DLSCH_PARALLELISATION
@@ -879,8 +892,6 @@ void init_NR_UE(int nb_inst) {
 #endif
 
   }
-
-  printf("UE threads created by %ld\n", gettid());
 }
 
 /* HACK: this function is needed to compile the UE
@@ -895,4 +906,3 @@ int8_t find_dlsch(uint16_t rnti,
 }
 
 void multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP) {}
-
diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c
index e0cb3803654..53e407923fd 100644
--- a/executables/nr-uesoftmodem.c
+++ b/executables/nr-uesoftmodem.c
@@ -133,7 +133,7 @@ static double            snr_dB=20;
 
 int                      threequarter_fs=0;
 
-uint32_t                 downlink_frequency[MAX_NUM_CCs][4];
+uint64_t                 downlink_frequency[MAX_NUM_CCs][4];
 int32_t                  uplink_frequency_offset[MAX_NUM_CCs][4];
 //int32_t					 uplink_counter = 0;
 
@@ -221,6 +221,8 @@ tpool_t *Tpool_dl;
 
 char *usrp_args=NULL;
 
+char *rrc_config_path=NULL;
+
 /* forward declarations */
 void set_default_frame_parms(NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]);
 
@@ -472,7 +474,7 @@ void set_default_frame_parms(NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
   for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
     /* Set some default values that may be overwritten while reading options */
     frame_parms[CC_id] = (NR_DL_FRAME_PARMS *) calloc(sizeof(NR_DL_FRAME_PARMS),1);
-    frame_parms[CC_id]->eutra_band          = 78;
+    frame_parms[CC_id]->nr_band          = 78;
     frame_parms[CC_id]->frame_type          = FDD;
     frame_parms[CC_id]->tdd_config          = 3;
     //frame_parms[CC_id]->tdd_config_S        = 0;
@@ -482,7 +484,7 @@ void set_default_frame_parms(NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
     //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_antenna_ports_gNB  = 1;
     frame_parms[CC_id]->nb_antennas_tx      = 1;
     frame_parms[CC_id]->nb_antennas_rx      = 1;
     //frame_parms[CC_id]->nushift             = 0;
@@ -500,8 +502,25 @@ void init_openair0(void) {
   for (card=0; card<MAX_CARDS; card++) {
     openair0_cfg[card].configFilename = NULL;
     openair0_cfg[card].threequarter_fs = frame_parms[0]->threequarter_fs;
+    numerology = frame_parms[0]->numerology_index;
 
-    if(frame_parms[0]->N_RB_DL == 217) {
+    if(frame_parms[0]->N_RB_DL == 66) {
+      if (numerology==3) {
+          openair0_cfg[card].sample_rate=122.88e6;
+          openair0_cfg[card].samples_per_frame = 1228800;
+        } else {
+          LOG_E(PHY,"Unsupported numerology! FR2 supports only 120KHz SCS for now.\n");
+          exit(-1);
+        }
+    }else if(frame_parms[0]->N_RB_DL == 32) {
+      if (numerology==3) {
+          openair0_cfg[card].sample_rate=61.44e6;
+          openair0_cfg[card].samples_per_frame = 614400;
+        } else {
+          LOG_E(PHY,"Unsupported numerology! FR2 supports only 120KHz SCS for now.\n");
+          exit(-1);
+        }
+    }else if(frame_parms[0]->N_RB_DL == 217) {
       if (numerology==1) {
         if (frame_parms[0]->threequarter_fs) {
           openair0_cfg[card].sample_rate=92.16e6;
@@ -584,12 +603,12 @@ void init_openair0(void) {
 
     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];
+        openair0_cfg[card].tx_freq[i] = frame_parms[0]->ul_CarrierFreq;
       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];
+        openair0_cfg[card].rx_freq[i] = frame_parms[0]->dl_CarrierFreq;
       else
         openair0_cfg[card].rx_freq[i]=0.0;
 
@@ -669,13 +688,20 @@ int main( int argc, char **argv ) {
   itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
 
   init_opt() ;
-  if(IS_SOFTMODEM_NOS1)
-	  init_pdcp();
+  load_nrLDPClib();
 
   if (ouput_vcd) {
     vcd_signal_dumper_init("/tmp/openair_dump_nrUE.vcd");
   }
 
+  #ifndef PACKAGE_VERSION
+#  define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"
+#endif
+  LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
+
+  init_NR_UE(1,rrc_config_path);
+  if(IS_SOFTMODEM_NOS1)
+	  init_pdcp();
 /*
 #ifdef PDCP_USE_NETLINK
   netlink_init();
@@ -684,38 +710,45 @@ int main( int argc, char **argv ) {
 #endif
 #endif
 */
-  #ifndef PACKAGE_VERSION
-#  define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"
-#endif
-  LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
 
-  // init the parameters
+  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 (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+    printf("frame_parms %d\n",frame_parms[CC_id]->ofdm_symbol_size);
     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
+    frame_parms[CC_id]->nb_antenna_ports_gNB = 1; //initial value overwritten by initial sync later
     frame_parms[CC_id]->threequarter_fs = threequarter_fs;
     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);
-    get_band(downlink_frequency[CC_id][0], &frame_parms[CC_id]->eutra_band,   &uplink_frequency_offset[CC_id][0], &frame_parms[CC_id]->frame_type);
-  }
 
-  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);
+    PHY_vars_UE_g[0][CC_id] = (PHY_VARS_NR_UE *)malloc(sizeof(PHY_VARS_NR_UE));
 
-  for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    printf("frame_parms %hu\n",frame_parms[CC_id]->ofdm_symbol_size);
-    nr_init_frame_parms_ue(frame_parms[CC_id],numerology,NORMAL,frame_parms[CC_id]->N_RB_DL,(frame_parms[CC_id]->N_RB_DL-20)>>1,0);
-    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];
+    memset(UE[CC_id],0,sizeof(PHY_VARS_NR_UE));
+
+    NR_UE_MAC_INST_t *mac = get_mac_inst(0);
+    if(mac->if_module != NULL && mac->if_module->phy_config_request != NULL)
+      mac->if_module->phy_config_request(&mac->phy_config);
 
+    fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config;
+    nr_init_frame_parms_ue(frame_parms[CC_id],nrUE_config,NORMAL);
+    
+    // Overwrite DL frequency (for FR2 testing)
+    if (downlink_frequency[0][0]!=0)
+      frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0];
+   
+    init_nr_ue_vars(UE[CC_id],frame_parms[CC_id],0,abstraction_flag);
 
     if (get_softmodem_params()->phy_test==1)
       UE[CC_id]->mac_enabled = 0;
     else
       UE[CC_id]->mac_enabled = 1;
 
+    UE[CC_id]->mac_enabled = 1;
+    UE[CC_id]->if_inst = nr_ue_if_module_init(0);
     UE[CC_id]->UE_scan = UE_scan;
     UE[CC_id]->UE_scan_carrier = UE_scan_carrier;
     UE[CC_id]->UE_fo_compensation = UE_fo_compensation;
@@ -723,13 +756,6 @@ int main( int argc, char **argv ) {
     UE[CC_id]->no_timing_correction = UE_no_timing_correction;
     printf("UE[%d]->mode = %d\n",CC_id,mode);
 
-    for (uint8_t i=0; i<RX_NB_TH_MAX; i++) {
-      if (UE[CC_id]->mac_enabled == 1)
-        UE[CC_id]->pdcch_vars[i][0]->crnti = 0x1234;
-      else
-        UE[CC_id]->pdcch_vars[i][0]->crnti = 0x1235;
-    }
-
     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];
 
@@ -764,11 +790,14 @@ int main( int argc, char **argv ) {
 #else
     PHY_vars_UE_g[0][CC_id]->hw_timing_advance = 160;
 #endif
+
   }
 
+  init_NR_UE_threads(1);
+  printf("UE threads created by %ld\n", gettid());
+  
   // wait for end of program
   printf("TYPE <CTRL-C> TO TERMINATE\n");
-  init_NR_UE(1);
 
   while(true)
     sleep(3600);
diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h
index 38c4c1b6076..7fad43e897c 100644
--- a/executables/nr-uesoftmodem.h
+++ b/executables/nr-uesoftmodem.h
@@ -54,8 +54,6 @@
     {"usrp-args",                CONFIG_HLP_USRP_ARGS,   0,              strptr:(char **)&usrp_args,         defstrval:"type=b200", TYPE_STRING,   0}      \
   }
 
-#define DEFAULT_DLF 2680000000
-
 /*----------------------------------------------------------------------------------------------------------------------------------------------------*/
 /*                                            command line parameters common to eNodeB and UE                                                         */
 /*   optname                helpstr                 paramflags      XXXptr                                 defXXXval              type         numelt */
@@ -65,7 +63,7 @@
   {"single-thread-disable", CONFIG_HLP_NOSNGLT,     PARAMFLAG_BOOL, iptr:&single_thread_flag,              defintval:1,           TYPE_INT,    0}, \
   {"nr-dlsch-demod-shift",  CONFIG_HLP_DLSHIFT,     0,              iptr:(int32_t *)&nr_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}, \
+  {"C" ,                    CONFIG_HLP_DLF,         0,              u64ptr:&(downlink_frequency[0][0]),    defuintval:0,TYPE_UINT64, 0}, \
   {"a" ,                    CONFIG_HLP_CHOFF,       0,              iptr:&chain_offset,                    defintval:0,           TYPE_INT,    0}, \
   {"d" ,                    CONFIG_HLP_SOFTS,       PARAMFLAG_BOOL, uptr:&do_forms,                        defintval:0,           TYPE_INT,    0}, \
   {"E" ,                    CONFIG_HLP_TQFS,        PARAMFLAG_BOOL, iptr:&threequarter_fs,                 defintval:0,           TYPE_INT,    0}, \
@@ -74,13 +72,14 @@
   {"q" ,                    CONFIG_HLP_STMON,       PARAMFLAG_BOOL, iptr:&opp_enabled,                     defintval:0,           TYPE_INT,    0}, \
   {"T" ,                    CONFIG_HLP_TDD,         PARAMFLAG_BOOL, iptr:&tddflag,                         defintval:0,           TYPE_INT,    0}, \
   {"V" ,                    CONFIG_HLP_VCD,         PARAMFLAG_BOOL, iptr:&vcdflag,                         defintval:0,           TYPE_INT,    0}, \
-  {"numerology" ,           CONFIG_HLP_NUMEROLOGY,  PARAMFLAG_BOOL, iptr:&numerology,                      defintval:0,           TYPE_INT,    0}, \
+  {"numerology" ,           CONFIG_HLP_NUMEROLOGY,  0,              iptr:&numerology,                      defintval:0,           TYPE_INT,    0}, \
   {"emulate-rf" ,           CONFIG_HLP_EMULATE_RF,  PARAMFLAG_BOOL, iptr:&emulate_rf,                      defintval:0,           TYPE_INT,    0}, \
   {"parallel-config",       CONFIG_HLP_PARALLEL_CMD,0,              strptr:(char **)&parallel_config,      defstrval:NULL,        TYPE_STRING, 0}, \
   {"worker-config",         CONFIG_HLP_WORKER_CMD,  0,              strptr:(char **)&worker_config,        defstrval:NULL,        TYPE_STRING, 0}, \
   {"s" ,                    CONFIG_HLP_SNR,         0,              dblptr:&snr_dB,                        defdblval:25,          TYPE_DOUBLE, 0}, \
   {"nbiot-disable",         CONFIG_HLP_DISABLNBIOT, PARAMFLAG_BOOL, iptr:&nonbiotflag,                     defintval:0,           TYPE_INT,    0}, \
-  {"ue-timing-correction-disable", CONFIG_HLP_DISABLETIMECORR, PARAMFLAG_BOOL, iptr:&UE_no_timing_correction, defintval:0,        TYPE_INT,    0}  \
+  {"ue-timing-correction-disable", CONFIG_HLP_DISABLETIMECORR, PARAMFLAG_BOOL, iptr:&UE_no_timing_correction, defintval:0,        TYPE_INT,    0}, \
+  {"rrc_config_path",       CONFIG_HLP_RRC_CFG_PATH,0,              strptr:(char **)&rrc_config_path,      defstrval:"./",        TYPE_STRING, 0} \
 }
 
 
@@ -92,11 +91,12 @@ extern int T_dont_fork;
 // In nr-ue.c
 extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg);
 extern void fill_ue_band_info(void);
-extern void init_NR_UE(int);
+extern void init_NR_UE(int, char*);
+extern void init_NR_UE_threads(int);
 extern void reset_opp_meas(void);
 extern void print_opp_meas(void);
 void *UE_thread(void *arg);
-PHY_VARS_NR_UE *init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag);
+void init_nr_ue_vars(PHY_VARS_NR_UE *ue, NR_DL_FRAME_PARMS *frame_parms, uint8_t UE_id, uint8_t abstraction_flag);
 extern tpool_t *Tpool;
 extern tpool_t *Tpool_dl;
 #endif
diff --git a/executables/softmodem-common.c b/executables/softmodem-common.c
index 0c4032c41ba..f714fa2bd4b 100644
--- a/executables/softmodem-common.c
+++ b/executables/softmodem-common.c
@@ -144,7 +144,6 @@ void get_common_options(uint32_t execmask) {
 
   if(worker_config != NULL)   set_worker_conf(worker_config);
 }
-
 void softmodem_printresources(int sig, telnet_printfunc_t pf) {
    struct rusage usage;
    struct timespec stop;
@@ -204,3 +203,4 @@ void set_softmodem_sighandler(void) {
   signal(SIGTERM, signal_handler);
   signal(SIGABRT, signal_handler);	
 }
+
diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h
index c9a24577dc5..cfed951469e 100644
--- a/executables/softmodem-common.h
+++ b/executables/softmodem-common.h
@@ -108,7 +108,7 @@ extern "C"
     {"clock",                CONFIG_HLP_CLK,          0,              uptr:&CLOCK_SOURCE,                 defintval:0,           TYPE_UINT,   0},                     \
     {"wait-for-sync",        NULL,                    PARAMFLAG_BOOL, iptr:&WAIT_FOR_SYNC,                defintval:0,           TYPE_INT,    0},                     \
     {"single-thread-enable", CONFIG_HLP_NOSNGLT,      PARAMFLAG_BOOL, iptr:&SINGLE_THREAD_FLAG,           defintval:0,           TYPE_INT,    0},                     \
-    {"C" ,                   CONFIG_HLP_DLF,          0,              uptr:&(downlink_frequency[0][0]),   defuintval:2680000000, TYPE_UINT,   0},                     \
+    {"C" ,                   CONFIG_HLP_DLF,          0,              u64ptr:&(downlink_frequency[0][0]), defuintval:0, TYPE_UINT64,   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},                     \
     {"q" ,                   CONFIG_HLP_STMON,        PARAMFLAG_BOOL, iptr:&opp_enabled,                  defintval:0,           TYPE_INT,    0},                     \
@@ -189,7 +189,7 @@ extern "C"
 
 typedef struct {
   uint64_t       optmask;
-  THREAD_STRUCT  thread_struct;
+  //THREAD_STRUCT  thread_struct;
   char           rf_config_file[1024];
   int            phy_test;
   uint8_t        usim_test;
@@ -212,7 +212,7 @@ extern void get_common_options(uint32_t execmask);
 extern char *get_softmodem_function(uint64_t *sofmodemfunc_mask_ptr);
 #define SOFTMODEM_RTSIGNAL  (SIGRTMIN+1)
 extern void set_softmodem_sighandler(void);
-extern uint32_t downlink_frequency[MAX_NUM_CCs][4];
+extern uint64_t downlink_frequency[MAX_NUM_CCs][4];
 #ifdef __cplusplus
 }
 #endif
diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c
index a0574221f5b..7ab8be5746c 100644
--- a/nfapi/oai_integration/nfapi_vnf.c
+++ b/nfapi/oai_integration/nfapi_vnf.c
@@ -31,7 +31,7 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
-#include "nfapi_nr_interface.h"
+#include "nfapi_nr_interface_scf.h"
 #include "nfapi_vnf_interface.h"
 #include "nfapi.h"
 #include "vendor_ext.h"
@@ -1169,7 +1169,7 @@ int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) {
   return retval;
 }
 
-int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_config_request_t *dl_config_req)
+int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_tti_request_t *dl_config_req)
 {
   nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
 
@@ -1177,9 +1177,9 @@ int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_config_request_t *dl_config_req)
 
   int retval = nfapi_vnf_p7_nr_dl_config_req(p7_config, dl_config_req);
 
-  dl_config_req->dl_config_request_body.number_dci                          = 0;
-  dl_config_req->dl_config_request_body.number_pdu                          = 0;
-  dl_config_req->dl_config_request_body.number_pdsch_rnti                   = 0;
+  dl_config_req->dl_tti_request_body.nPDUs                          = 0;
+  dl_config_req->dl_tti_request_body.nGroup                       = 0;
+
 
   if (retval!=0) {
     LOG_E(PHY, "%s() Problem sending retval:%d\n", __FUNCTION__, retval);
diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h
index babcc6404f2..cbcd26c3e35 100644
--- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h
+++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_constants.h
@@ -8,6 +8,9 @@
 #define FAPI_NR_MAX_NUM_ZP_CSI_RS_RESOURCE_PER_SET 16
 #define FAPI_NR_MAX_NUM_CANDIDATE_BEAMS            16
 #define FAPI_NR_MAX_RA_OCCASION_PER_CSIRS          64
+// Constants Defined in 38.213
+#define FAPI_NR_MAX_CORESET_PER_BWP                3
+#define FAPI_NR_MAX_SS_PER_CORESET                 10
 
 
 /// RX_IND
@@ -41,8 +44,8 @@
 #define FAPI_NR_DL_CONFIG_TYPE_DLSCH 0x02
 
 
-#define CCE_REG_MAPPING_TYPE_INTERLEAVED 0x01
-#define CCE_REG_MAPPING_TYPE_NON_INTERLEAVED 0x02
+#define FAPI_NR_CCE_REG_MAPPING_TYPE_INTERLEAVED 0x01
+#define FAPI_NR_CCE_REG_MAPPING_TYPE_NON_INTERLEAVED 0x02
 
 #define PRECODER_GRANULARITY_SAME_AS_REG_BUNDLE 0x01
 #define PRECODER_GRANULARITY_ALL_CONTIGUOUS_RBS 0x02
diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h
index 838e52dadae..576144e1df9 100644
--- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h
+++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h
@@ -1,5 +1,4 @@
-/*
- * Copyright 2017 Cisco Systems, Inc.
+/*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.
@@ -32,77 +31,7 @@
   typedef signed char		   int8_t;
 */
 
-typedef struct {
-  uint8_t identifier_dci_formats          ; // 0  IDENTIFIER_DCI_FORMATS:
-  uint8_t carrier_ind                     ; // 1  CARRIER_IND: 0 or 3 bits, as defined in Subclause x.x of [5, TS38.213]
-  uint8_t sul_ind_0_1                     ; // 2  SUL_IND_0_1:
-  uint8_t slot_format_ind                 ; // 3  SLOT_FORMAT_IND: size of DCI format 2_0 is configurable by higher layers up to 128 bits, according to Subclause 11.1.1 of [5, TS 38.213]
-  uint8_t pre_emption_ind                 ; // 4  PRE_EMPTION_IND: size of DCI format 2_1 is configurable by higher layers up to 126 bits, according to Subclause 11.2 of [5, TS 38.213]. Each pre-emption indication is 14 bits
-  uint8_t block_number                    ; // 5  BLOCK_NUMBER: starting position of a block is determined by the parameter startingBitOfFormat2_3
-  uint8_t close_loop_ind                  ; // 6  CLOSE_LOOP_IND:
-  uint8_t bandwidth_part_ind              ; // 7  BANDWIDTH_PART_IND:
-  uint8_t short_message_ind               ; // 8  SHORT_MESSAGE_IND:
-  uint8_t short_messages                  ; // 9  SHORT_MESSAGES:
-  uint16_t freq_dom_resource_assignment_UL; // 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered
-  //    (NOTE 1) If DCI format 0_0 is monitored in common search space
-  //    and if the number of information bits in the DCI format 0_0 prior to padding
-  //    is larger than the payload size of the DCI format 1_0 monitored in common search space
-  //    the bitwidth of the frequency domain resource allocation field in the DCI format 0_0
-  //    is reduced such that the size of DCI format 0_0 equals to the size of the DCI format 1_0
-  uint16_t freq_dom_resource_assignment_DL; // 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
-  uint8_t time_dom_resource_assignment    ; // 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
-  //    where I the number of entries in the higher layer parameter pusch-AllocationList
-  uint8_t vrb_to_prb_mapping              ; // 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
-  uint8_t prb_bundling_size_ind           ; // 14 PRB_BUNDLING_SIZE_IND:0 bit if the higher layer parameter PRB_bundling is not configured or is set to 'static', or 1 bit if the higher layer parameter PRB_bundling is set to 'dynamic' according to Subclause 5.1.2.3 of [6, TS 38.214]
-  uint8_t rate_matching_ind               ; // 15 RATE_MATCHING_IND: 0, 1, or 2 bits according to higher layer parameter rate-match-PDSCH-resource-set
-  uint8_t zp_csi_rs_trigger               ; // 16 ZP_CSI_RS_TRIGGER:
-  uint8_t freq_hopping_flag               ; // 17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0
-  uint8_t tb1_mcs                         ; // 18 TB1_MCS:
-  uint8_t tb1_ndi                         ; // 19 TB1_NDI:
-  uint8_t tb1_rv                          ; // 20 TB1_RV:
-  uint8_t tb2_mcs                         ; // 21 TB2_MCS:
-  uint8_t tb2_ndi                         ; // 22 TB2_NDI:
-  uint8_t tb2_rv                          ; // 23 TB2_RV:
-  uint8_t mcs                             ; // 24 MCS:
-  uint8_t ndi                             ; // 25 NDI:
-  uint8_t rv                              ; // 26 RV:
-  uint8_t harq_process_number             ; // 27 HARQ_PROCESS_NUMBER:
-  uint8_t dai                             ; // 28 DAI: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
-  //    2 if one serving cell is configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 bits are the counter DAI
-  //    0 otherwise
-  uint8_t first_dai                       ; // 29 FIRST_DAI: (1 or 2 bits) 1 bit for semi-static HARQ-ACK
-  uint8_t second_dai                      ; // 30 SECOND_DAI: (0 or 2 bits) 2 bits for dynamic HARQ-ACK codebook with two HARQ-ACK sub-codebooks
-  uint8_t tb_scaling                      ; // 31 TB_SCALING:
-  uint8_t tpc_pusch                       ; // 32 TPC_PUSCH:
-  uint8_t tpc_pucch                       ; // 33 TPC_PUCCH:
-  uint8_t pucch_resource_ind              ; // 34 PUCCH_RESOURCE_IND:
-  uint8_t pdsch_to_harq_feedback_time_ind ; // 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND:
-  uint8_t srs_resource_ind                ; // 36 SRS_RESOURCE_IND:
-  uint8_t precod_nbr_layers               ; // 37 PRECOD_NBR_LAYERS:
-  uint8_t antenna_ports                   ; // 38 ANTENNA_PORTS:
-  uint8_t tci                             ; // 39 TCI: 0 bit if higher layer parameter tci-PresentInDCI is not enabled; otherwise 3 bits
-  uint8_t srs_request                     ; // 40 SRS_REQUEST:
-  uint8_t tpc_cmd                         ; // 41 TPC_CMD:
-  uint8_t csi_request                     ; // 42 CSI_REQUEST:
-  uint8_t cbgti                           ; // 43 CBGTI: 0, 2, 4, 6, or 8 bits determined by higher layer parameter maxCodeBlockGroupsPerTransportBlock for the PDSCH
-  uint8_t cbgfi                           ; // 44 CBGFI: 0 or 1 bit determined by higher layer parameter codeBlockGroupFlushIndicator
-  uint8_t ptrs_dmrs                       ; // 45 PTRS_DMRS:
-  uint8_t beta_offset_ind                 ; // 46 BETA_OFFSET_IND:
-  uint8_t dmrs_seq_ini                    ; // 47 DMRS_SEQ_INI: 1 bit if the cell has two ULs and the number of bits for DCI format 1_0 before padding
-  //    is larger than the number of bits for DCI format 0_0 before padding; 0 bit otherwise
-  uint8_t ul_sch_ind                      ; // 48 UL_SCH_IND:  value of "1" indicates UL-SCH shall be transmitted on the PUSCH and a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH
-  uint16_t padding_nr_dci                 ; // 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space
-  //    and if the number of information bits in the DCI format 0_0 prior to padding
-  //    is less than the payload size of the DCI format 1_0 monitored in common search space
-  //    zeros shall be appended to the DCI format 0_0
-  //    until the payload size equals that of the DCI format 1_0
-  uint8_t sul_ind_0_0                     ; // 50 SUL_IND_0_0:
-  uint8_t ra_preamble_index               ; // 51 RA_PREAMBLE_INDEX:
-  uint8_t sul_ind_1_0                     ; // 52 SUL_IND_1_0:
-  uint8_t ss_pbch_index                   ; // 53 SS_PBCH_INDEX
-  uint8_t prach_mask_index                ; // 54 PRACH_MASK_INDEX
-  uint8_t reserved_nr_dci                 ; // 55 RESERVED_NR_DCI
-} fapi_nr_dci_pdu_rel15_t;
+
 
 
 
@@ -121,16 +50,14 @@ typedef struct {
 
 typedef struct {
   /// frequency_domain_resource;
-  //uint32_t rb_start;
-  //uint32_t rb_end;
-  uint64_t frequency_domain_resource;
-  uint16_t rb_offset;
-
+  uint8_t frequency_domain_resource[6];
+  uint8_t StartSymbolIndex;
   uint8_t duration;
-  uint8_t cce_reg_mapping_type;                   //  interleaved or noninterleaved
-  uint8_t cce_reg_interleaved_reg_bundle_size;    //  valid if CCE to REG mapping type is interleaved type
-  uint8_t cce_reg_interleaved_interleaver_size;   //  valid if CCE to REG mapping type is interleaved type
-  uint8_t cce_reg_interleaved_shift_index;        //  valid if CCE to REG mapping type is interleaved type
+  uint8_t CceRegMappingType; //  interleaved or noninterleaved
+  uint8_t RegBundleSize;     //  valid if CCE to REG mapping type is interleaved type
+  uint8_t InterleaverSize;   //  valid if CCE to REG mapping type is interleaved type
+  uint8_t ShiftIndex;        //  valid if CCE to REG mapping type is interleaved type
+  uint8_t CoreSetType;
   uint8_t precoder_granularity;
   uint16_t pdcch_dmrs_scrambling_id;
 
@@ -155,13 +82,16 @@ typedef struct {
   int n_CCE;
   // N_CCE is L, or number of CCEs for DCI
   int N_CCE;
-  fapi_nr_dci_pdu_rel15_t dci;
+  uint8_t payloadSize;
+  uint8_t payloadBits[16];
+  //fapi_nr_dci_pdu_rel15_t dci;
 } fapi_nr_dci_indication_pdu_t;
 
 
 ///
 typedef struct {
-  uint32_t sfn_slot;
+  uint16_t SFN;
+  uint8_t slot;
   uint16_t number_of_dcis;
   fapi_nr_dci_indication_pdu_t dci_list[10];
 } fapi_nr_dci_indication_t;
@@ -199,7 +129,8 @@ typedef struct {
 ///
 #define NFAPI_RX_IND_MAX_PDU 100
 typedef struct {
-  uint32_t sfn_slot;
+  uint16_t sfn;
+  uint16_t slot;
   uint16_t number_pdus;
   fapi_nr_rx_indication_body_t rx_indication_body[NFAPI_RX_IND_MAX_PDU];
 } fapi_nr_rx_indication_t;
@@ -218,7 +149,8 @@ typedef struct {
 
 ///
 typedef struct {
-  uint32_t sfn_slot;
+  uint16_t sfn;
+  uint16_t slot;
   fapi_nr_tx_config_t tx_config;
   uint16_t number_of_pdus;
   fapi_nr_tx_request_body_t *tx_request_body;
@@ -374,7 +306,8 @@ typedef struct {
 } fapi_nr_ul_config_request_pdu_t;
 
 typedef struct {
-  uint32_t sfn_slot;
+  uint16_t sfn;
+  uint16_t slot;
   uint8_t number_pdus;
   fapi_nr_ul_config_request_pdu_t ul_config_list[FAPI_NR_UL_CONFIG_LIST_NUM];
 } fapi_nr_ul_config_request_t;
@@ -382,16 +315,15 @@ typedef struct {
 
 typedef struct {
   uint16_t rnti;
-  
+  uint16_t BWPSize;
+  uint16_t BWPStart;
+  uint8_t SubcarrierSpacing;
   fapi_nr_coreset_t coreset;
-  uint16_t N_RB_BWP;
-  uint32_t duration;
-  uint8_t number_of_candidates[5];    //  aggregation level 1, 2, 4, 8, 16 
-  uint16_t monitoring_symbols_within_slot;
-  //  DCI foramt-specific
-  uint8_t format_2_0_number_of_candidates[5];    //  aggregation level 1, 2, 4, 8, 16
-  uint8_t format_2_3_monitorying_periodicity;
-  uint8_t format_2_3_number_of_candidates;
+  uint8_t number_of_candidates;
+  uint16_t CCE[64];
+  uint8_t L[64];
+  uint8_t dci_length;
+  uint8_t dci_format;
 } fapi_nr_dl_config_dci_dl_pdu_rel15_t;
 
 typedef struct {
@@ -404,12 +336,16 @@ typedef struct{
 typedef enum{vrb_to_prb_mapping_non_interleaved = 0, vrb_to_prb_mapping_interleaved = 1} vrb_to_prb_mapping_t;
 //typedef fapi_nr_dci_pdu_rel15_t fapi_nr_dl_config_dlsch_pdu_rel15_t;
 typedef struct {
-  uint8_t bandwidth_part_ind;
+  uint16_t BWPSize;
+  uint16_t BWPStart;
+  uint8_t SubcarrierSpacing;  
   uint16_t number_rbs;
   uint16_t start_rb;
   uint8_t frame_offset;
   uint16_t number_symbols;
   uint16_t start_symbol;
+  uint16_t dlDmrsSymbPos;  
+  uint8_t dmrsConfigType;
   uint8_t prb_bundling_size_ind;
   uint8_t rate_matching_ind;
   uint8_t zp_csi_rs_trigger;
@@ -450,7 +386,8 @@ typedef struct {
 } fapi_nr_dl_config_request_pdu_t;
 
 typedef struct {
-  uint32_t sfn_slot;
+  uint16_t sfn;
+  uint16_t slot;
   uint8_t number_pdus;
   fapi_nr_dl_config_request_pdu_t dl_config_list[FAPI_NR_DL_CONFIG_LIST_NUM];
 } fapi_nr_dl_config_request_t;
@@ -544,20 +481,6 @@ typedef struct {
   uint8_t p0_nominal;
 } fapi_nr_pucch_config_common_t;
 
-typedef struct {
-
-  uint8_t subcarrier_spacing_common;
-  uint8_t ssb_subcarrier_offset;
-  uint8_t dmrs_type_a_position;
-  uint8_t pdcch_config_sib1;
-  uint8_t cell_barred;
-  uint8_t intra_frequency_reselection;
-
-  uint16_t system_frame_number;
-  uint8_t ssb_index;
-  uint8_t half_frame_bit;
-} fapi_nr_pbch_config_t;
-
 typedef struct {
         
   fapi_nr_pdcch_config_common_t pdcch_config_common;
@@ -907,10 +830,115 @@ typedef struct {
 #define FAPI_NR_CONFIG_REQUEST_MASK_DL_BWP_DEDICATED    0x08
 #define FAPI_NR_CONFIG_REQUEST_MASK_UL_BWP_DEDICATED    0x10
 
+typedef struct 
+{
+  uint16_t dl_bandwidth;//Carrier bandwidth for DL in MHz [38.104, sec 5.3.2] Values: 5, 10, 15, 20, 25, 30, 40,50, 60, 70, 80,90,100,200,400
+  uint32_t dl_frequency; //Absolute frequency of DL point A in KHz [38.104, sec5.2 and 38.211 sec 4.4.4.2] Value: 450000 -> 52600000
+  uint16_t dl_k0[5];//𝑘_{0}^{𝜇} for each of the numerologies [38.211, sec 5.3.1] Value: 0 ->23699
+  uint16_t dl_grid_size[5];//Grid size 𝑁_{𝑔𝑟𝑖𝑑}^{𝑠𝑖𝑧𝑒,𝜇} for each of the numerologies [38.211, sec 4.4.2] Value: 0->275 0 = this numerology not used
+  uint16_t num_tx_ant;//Number of Tx antennas
+  uint16_t uplink_bandwidth;//Carrier bandwidth for UL in MHz. [38.104, sec 5.3.2] Values: 5, 10, 15, 20, 25, 30, 40,50, 60, 70, 80,90,100,200,400
+  uint32_t uplink_frequency;//Absolute frequency of UL point A in KHz [38.104, sec5.2 and 38.211 sec 4.4.4.2] Value: 450000 -> 52600000
+  uint16_t ul_k0[5];//𝑘0 𝜇 for each of the numerologies [38.211, sec 5.3.1] Value: : 0 ->23699
+  uint16_t ul_grid_size[5];//Grid size 𝑁𝑔𝑟𝑖𝑑 𝑠𝑖𝑧𝑒,𝜇 for each of the numerologies [38.211, sec 4.4.2]. Value: 0->275 0 = this numerology not used
+  uint16_t num_rx_ant;//
+  uint8_t  frequency_shift_7p5khz;//Indicates presence of 7.5KHz frequency shift. Value: 0 = false 1 = true
+
+} fapi_nr_ue_carrier_config_t; 
+
+typedef struct 
+{
+  uint8_t phy_cell_id;//Physical Cell ID, 𝑁_{𝐼𝐷}^{𝑐𝑒𝑙𝑙} [38.211, sec 7.4.2.1] Value: 0 ->1007
+  uint8_t frame_duplex_type;//Frame duplex type Value: 0 = FDD 1 = TDD
+
+} fapi_nr_cell_config_t;
+
+typedef struct 
+{
+  uint32_t ss_pbch_power;//SSB Block Power Value: TBD (-60..50 dBm)
+  uint8_t  bch_payload;//Defines option selected for generation of BCH payload, see Table 3-13 (v0.0.011 Value: 0: MAC generates the full PBCH payload 1: PHY generates the timing PBCH bits 2: PHY generates the full PBCH payload
+  uint8_t  scs_common;//subcarrierSpacing for common, used for initial access and broadcast message. [38.211 sec 4.2] Value:0->3
+
+} fapi_nr_ssb_config_t;
+
+typedef struct 
+{
+  uint32_t ssb_mask;//Bitmap for actually transmitted SSB. MSB->LSB of first 32 bit number corresponds to SSB 0 to SSB 31 MSB->LSB of second 32 bit number corresponds to SSB 32 to SSB 63 Value for each bit: 0: not transmitted 1: transmitted
+
+} fapi_nr_ssb_mask_size_2_t;
+
+typedef struct 
+{
+  int8_t beam_id[64];//BeamID for each SSB in SsbMask. For example, if SSB mask bit 26 is set to 1, then BeamId[26] will be used to indicate beam ID of SSB 26. Value: from 0 to 63
+
+} fapi_nr_ssb_mask_size_64_t;
+
+typedef struct 
+{
+  uint16_t ssb_offset_point_a;//Offset of lowest subcarrier of lowest resource block used for SS/PBCH block. Given in PRB [38.211, section 4.4.4.2] Value: 0->2199
+  uint8_t  beta_pss;//PSS EPRE to SSS EPRE in a SS/PBCH block [38.213, sec 4.1] Values: 0 = 0dB
+  uint8_t  ssb_period;//SSB periodicity in msec Value: 0: ms5 1: ms10 2: ms20 3: ms40 4: ms80 5: ms160
+  uint8_t  ssb_subcarrier_offset;//ssbSubcarrierOffset or 𝑘𝑆𝑆𝐵 (38.211, section 7.4.3.1) Value: 0->31
+  uint32_t MIB;//MIB payload, where the 24 MSB are used and represent the MIB in [38.331 MIB IE] and represent 0 1 2 3 1 , , , ,..., A− a a a a a [38.212, sec 7.1.1]
+  fapi_nr_ssb_mask_size_2_t ssb_mask_list[2];
+  fapi_nr_ssb_mask_size_64_t* ssb_beam_id_list;//64
+  uint8_t  ss_pbch_multiple_carriers_in_a_band;//0 = disabled 1 = enabled
+  uint8_t  multiple_cells_ss_pbch_in_a_carrier;//Indicates that multiple cells will be supported in a single carrier 0 = disabled 1 = enabled
+
+} fapi_nr_ssb_table_t;
+
+typedef struct 
+{
+  uint8_t slot_config;//For each symbol in each slot a uint8_t value is provided indicating: 0: DL slot 1: UL slot 2: Guard slot
+
+} fapi_nr_max_num_of_symbol_per_slot_t;
+
+typedef struct 
+{
+  fapi_nr_max_num_of_symbol_per_slot_t* max_num_of_symbol_per_slot_list;
+
+} fapi_nr_max_tdd_periodicity_t;
+
+typedef struct 
+{
+  uint8_t tdd_period;//DL UL Transmission Periodicity. Value:0: ms0p5 1: ms0p625 2: ms1 3: ms1p25 4: ms2 5: ms2p5 6: ms5 7: ms10 8: ms3 9: ms4
+  fapi_nr_max_tdd_periodicity_t* max_tdd_periodicity_list;
+
+} fapi_nr_tdd_table_t;
+
+typedef struct 
+{
+  uint8_t  num_prach_fd_occasions;
+  uint16_t prach_root_sequence_index;//Starting logical root sequence index, 𝑖, equivalent to higher layer parameter prach-RootSequenceIndex [38.211, sec 6.3.3.1] Value: 0 -> 837
+  uint8_t  num_root_sequences;//Number of root sequences for a particular FD occasion that are required to generate the necessary number of preambles
+  uint16_t k1;//Frequency offset (from UL bandwidth part) for each FD. [38.211, sec 6.3.3.2] Value: from 0 to 272
+  uint8_t  prach_zero_corr_conf;//PRACH Zero CorrelationZone Config which is used to dervive 𝑁𝑐𝑠 [38.211, sec 6.3.3.1] Value: from 0 to 15
+  uint8_t  num_unused_root_sequences;//Number of unused sequences available for noise estimation per FD occasion. At least one unused root sequence is required per FD occasion.
+  uint8_t* unused_root_sequences_list;//Unused root sequence or sequences per FD occasion. Required for noise estimation.
+
+} fapi_nr_num_prach_fd_occasions_t;
+
+typedef struct 
+{
+  uint8_t prach_sequence_length;//RACH sequence length. Only short sequence length is supported for FR2. [38.211, sec 6.3.3.1] Value: 0 = Long sequence 1 = Short sequence
+  uint8_t prach_sub_c_spacing;//Subcarrier spacing of PRACH. [38.211 sec 4.2] Value:0->4
+  uint8_t restricted_set_config;//PRACH restricted set config Value: 0: unrestricted 1: restricted set type A 2: restricted set type B
+  uint8_t num_prach_fd_occasions;//Corresponds to the parameter 𝑀 in [38.211, sec 6.3.3.2] which equals the higher layer parameter msg1FDM Value: 1,2,4,8
+  fapi_nr_num_prach_fd_occasions_t* num_prach_fd_occasions_list;
+  uint8_t ssb_per_rach;//SSB-per-RACH-occasion Value: 0: 1/8 1:1/4, 2:1/2 3:1 4:2 5:4, 6:8 7:16
+  uint8_t prach_multiple_carriers_in_a_band;//0 = disabled 1 = enabled
+
+} fapi_nr_prach_config_t;
+
 typedef struct {
   uint32_t config_mask;
 
-  fapi_nr_pbch_config_t pbch_config;  //  MIB
+  fapi_nr_ue_carrier_config_t carrier_config;
+  fapi_nr_cell_config_t cell_config;
+  fapi_nr_ssb_config_t ssb_config;
+  fapi_nr_ssb_table_t ssb_table;
+  fapi_nr_tdd_table_t tdd_table;
+  fapi_nr_prach_config_t prach_config;
 
   fapi_nr_dl_bwp_common_config_t     dl_bwp_common;
   fapi_nr_dl_bwp_dedicated_config_t  dl_bwp_dedicated;
@@ -921,3 +949,4 @@ typedef struct {
 } fapi_nr_config_request_t;
 
 #endif
+
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 a6cb7262a4f..5fe1c53a546 100644
--- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h
+++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h
@@ -11,43 +11,16 @@
 
 #include "nfapi_interface.h"
 
-
 #define NFAPI_NR_MAX_NB_CCE_AGGREGATION_LEVELS 5
 #define NFAPI_NR_MAX_NB_TCI_STATES_PDCCH 64
 #define NFAPI_NR_MAX_NB_CORESETS 12
 #define NFAPI_NR_MAX_NB_SEARCH_SPACES 40
 
-// Extension to the generic structures for single tlv values
-typedef struct {
-	nfapi_tl_t tl;
-	int32_t value;
-} nfapi_int32_tlv_t;
 
-typedef struct {
-	nfapi_tl_t tl;
-	uint32_t value;
-} nfapi_uint32_tlv_t;
 
-/*typedef struct {
-	nfapi_tl_t tl;
-	int64_t value;
-} nfapi_int64_tlv_t;*/
+// nFAPI enums
 
-typedef struct {
-	nfapi_tl_t tl;
-	uint64_t value;
-} nfapi_uint64_tlv_t;
 
-// nFAPI enums
-typedef enum {
-  NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE = 0,
-  NFAPI_NR_DL_CONFIG_BCH_PDU_TYPE,
-  NFAPI_NR_DL_CONFIG_DLSCH_PDU_TYPE,
-  NFAPI_NR_DL_CONFIG_PCH_PDU_TYPE,
-  NFAPI_NR_DL_CONFIG_NBCH_PDU_TYPE,
-  NFAPI_NR_DL_CONFIG_NPDCCH_PDU_TYPE,
-  NFAPI_NR_DL_CONFIG_NDLSCH_PDU_TYPE
-} nfapi_nr_dl_config_pdu_type_e;
 
 //These TLVs are used exclusively by nFAPI
 typedef struct
@@ -106,37 +79,6 @@ typedef struct
 
 // P5 Message Structures
 
-typedef struct{
-  nfapi_tl_t tl;
-  uint16_t  corset_ID;                           ///// L1 parameter 'CORESET-ID'
-  uint16_t  freq_dom;                       ///// L1 parameter 'CORESET-freq-dom'
-  uint16_t  duration;                                       ///// L1 parameter 'CORESET-time-duration'
-  uint16_t  reg_type;                            ///// L1 parameter 'CORESET-CCE-REG-mapping-type'
-  uint16_t  reg_bundlesize;                                 ///// L1 parameter 'CORESET-REG-bundle-size'
-  uint16_t  interleaversize;                                ///// L1 parameter 'CORESET-interleaver-size'
-  uint16_t  shiftindex;                                     ///// L1 parameter 'CORESET-shift-index'
-  uint16_t  precodergranularity;                            ///// L1 parameter 'CORESET-precoder-granuality'
-  uint16_t  tci_stateId;                                    ///// L1 parameter 'TCI-StatesPDCCH'
-  uint16_t  tci_present;                               ///// L1 parameter 'TCI-PresentInDCI'
-  uint16_t  dmrs_scramblingID;                        ///// L1 parameter 'PDCCH-DMRS-Scrambling-ID'
-} nfapi_nr_ControlResourcesSet_t;
-
-typedef struct{
-  nfapi_tl_t tl;
-  nfapi_nr_ControlResourcesSet_t coreset;
-  uint16_t  monitoringSlotPeriodicityAndOffset;             ///// L1 parameters 'Montoring-periodicity-PDCCH-slot'
-  uint16_t  monitoringSymbolsWithinSlot;                    ///// L1 parameter 'Montoring-symbols-PDCCH-within-slot'
-  uint16_t  nrofCand_aggLevel1;                             ///// L1 parameter 'Aggregation-level-1'
-  uint16_t  nrofCand_aggLevel2;                             ///// L1 parameter 'Aggregation-level-2'
-  uint16_t  nrofCand_aggLevel4;                             ///// L1 parameter 'Aggregation-level-4'
-  uint16_t  nrofCand_aggLevel8;                             ///// L1 parameter 'Aggregation-level-8'
-  uint16_t  nrofCand_aggLevel16;                            ///// L1 parameter 'Aggregation-level-16'
-  uint16_t  sfi_agg_fmt2_0;    ///// L1 parameters 'SFI-Num-PDCCH-cand' and 'SFI-Aggregation-Level'
-  uint16_t  monitoringperiodicity_fmt2_3;        ///// L1 parameter 'SRS-monitoring-periodicity'
-  uint16_t  nrof_candidates_fmt_2_3;         ///// L1 parameter 'SRS-Num-PDCCH-cand'
-} nfapi_nr_SearchSpace_t;
-
-
 typedef struct {
   nfapi_uint16_tlv_t  numerology_index_mu;
   nfapi_uint16_tlv_t  duplex_mode;
@@ -154,10 +96,6 @@ typedef struct {
 typedef struct {
   nfapi_uint16_tlv_t  dl_carrier_bandwidth;
   nfapi_uint16_tlv_t  ul_carrier_bandwidth;
-  nfapi_uint16_tlv_t  dl_bwp_subcarrierspacing;
-  nfapi_uint16_tlv_t  ul_bwp_subcarrierspacing;
-  nfapi_uint16_tlv_t  dl_locationandbandwidth;
-  nfapi_uint16_tlv_t  ul_locationandbandwidth;
   nfapi_uint16_tlv_t  dl_absolutefrequencypointA;
   nfapi_uint16_tlv_t  ul_absolutefrequencypointA;
   nfapi_uint16_tlv_t  dl_offsettocarrier;
@@ -173,6 +111,8 @@ typedef struct {
 #define NFAPI_NR_RF_CONFIG_UL_CARRIER_BANDWIDTH_TAG 0x500B
 #define NFAPI_NR_RF_CONFIG_DL_SUBCARRIERSPACING_TAG 0x500C
 #define NFAPI_NR_RF_CONFIG_UL_SUBCARRIERSPACING_TAG 0x500D
+#define NFAPI_NR_RF_CONFIG_DL_OFFSETTOCARRIER_TAG   0x500E
+#define NFAPI_NR_RF_CONFIG_UL_OFFSETTOCARRIER_TAG   0x500F
 
 typedef struct {
   nfapi_uint16_tlv_t  physical_cell_id;
@@ -183,9 +123,25 @@ typedef struct {
   nfapi_uint16_tlv_t  ssb_periodicity;
   nfapi_uint16_tlv_t  ss_pbch_block_power;
   nfapi_uint16_tlv_t  n_ssb_crb;
-  nfapi_uint16_tlv_t  rmsi_pdcch_config;
 } nfapi_nr_sch_config_t;
 
+typedef struct {
+  nfapi_uint16_tlv_t  dl_bandwidth;
+  nfapi_uint16_tlv_t  ul_bandwidth;
+  nfapi_uint16_tlv_t  dl_offset;
+  nfapi_uint16_tlv_t  ul_offset;
+  nfapi_uint16_tlv_t  dl_subcarrierSpacing;
+  nfapi_uint16_tlv_t  ul_subcarrierSpacing;
+} nfapi_nr_initialBWP_config_t;
+
+#define NFAPI_INITIALBWP_DL_BANDWIDTH_TAG          0x5010
+#define NFAPI_INITIALBWP_DL_OFFSET_TAG             0x5011
+#define NFAPI_INITIALBWP_DL_SUBCARRIERSPACING_TAG  0x5012
+#define NFAPI_INITIALBWP_UL_BANDWIDTH_TAG          0x5013
+#define NFAPI_INITIALBWP_UL_OFFSET_TAG             0x5014
+#define NFAPI_INITIALBWP_UL_SUBCARRIERSPACING_TAG  0x5015
+
+
 #define NFAPI_NR_SCH_CONFIG_PHYSICAL_CELL_ID_TAG 0x501E
 #define NFAPI_NR_SCH_CONFIG_HALF_FRAME_INDEX_TAG 0x501F
 #define NFAPI_NR_SCH_CONFIG_SSB_SUBCARRIER_OFFSET_TAG 0x5020
@@ -193,25 +149,15 @@ typedef struct {
 #define NFAPI_NR_SCH_CONFIG_SSB_PERIODICITY 0x5022
 #define NFAPI_NR_SCH_CONFIG_SS_PBCH_BLOCK_POWER 0x5023
 #define NFAPI_NR_SCH_CONFIG_N_SSB_CRB 0x5024
+#define NFAPI_NR_PDSCH_CONFIG_MAXALLOCATIONS 16
+#define NFAPI_NR_PUSCH_CONFIG_MAXALLOCATIONS 16
 
 typedef struct {
-  nfapi_uint16_tlv_t  data_scrambling_id;
-  nfapi_uint16_tlv_t  dmrs_typeA_position;
-  nfapi_uint16_tlv_t  dmrs_additional_position;
-  nfapi_uint16_tlv_t  dmrs_type;
-  nfapi_uint16_tlv_t  dmrs_max_length;
-  nfapi_uint16_tlv_t  mapping_type;
-  nfapi_uint16_tlv_t  resource_allocation;
-  nfapi_uint16_tlv_t  time_allocation_list;
-  nfapi_uint16_tlv_t  mcs_table;
-  nfapi_uint16_tlv_t  aggregation_factor;
-  nfapi_uint16_tlv_t  prb_bundling_type;
-  nfapi_uint16_tlv_t  rbg_size;
-  nfapi_uint16_tlv_t  vrb_to_prb_interleaver;
-  nfapi_uint16_tlv_t  code_block_groug_transmission;
-  nfapi_uint16_tlv_t  x_overhead;
-  nfapi_uint16_tlv_t  max_dci_codewords;
-  
+  nfapi_uint16_tlv_t  dmrs_TypeA_Position;
+  nfapi_uint16_tlv_t  num_PDSCHTimeDomainResourceAllocations;
+  nfapi_uint16_tlv_t  PDSCHTimeDomainResourceAllocation_k0[NFAPI_NR_PDSCH_CONFIG_MAXALLOCATIONS];         
+  nfapi_uint16_tlv_t  PDSCHTimeDomainResourceAllocation_mappingType[NFAPI_NR_PDSCH_CONFIG_MAXALLOCATIONS]; 
+  nfapi_uint16_tlv_t  PDSCHTimeDomainResourceAllocation_startSymbolAndLength[NFAPI_NR_PDSCH_CONFIG_MAXALLOCATIONS];
 } nfapi_nr_pdsch_config_t;
 #define NFAPI_NR_PDSCH_CONFIG_TAG
 
@@ -221,43 +167,64 @@ typedef struct {
   nfapi_uint16_tlv_t  prach_msg1_SubcarrierSpacing;                                   ///// L1 parameter 'prach-Msg1SubcarrierSpacing'
   nfapi_uint16_tlv_t  restrictedSetConfig;
   nfapi_uint16_tlv_t  msg3_transformPrecoding;                                        ///// L1 parameter 'msg3-tp'
+  nfapi_uint16_tlv_t  ssb_perRACH_OccasionAndCB_PreamblesPerSSB;
+  nfapi_uint16_tlv_t  ra_ContentionResolutionTimer;
+  nfapi_uint16_tlv_t  rsrp_ThresholdSSB;
   /////////////////--------------------NR RACH-ConfigGeneric--------------------/////////////////
   nfapi_uint16_tlv_t  prach_ConfigurationIndex;                                       ///// L1 parameter 'PRACHConfigurationIndex'
   nfapi_uint16_tlv_t  prach_msg1_FDM;                                                 ///// L1 parameter 'prach-FDM'
   nfapi_uint16_tlv_t  prach_msg1_FrequencyStart;                                      ///// L1 parameter 'prach-frequency-start'
   nfapi_uint16_tlv_t  zeroCorrelationZoneConfig;
   nfapi_uint16_tlv_t  preambleReceivedTargetPower;
+  nfapi_uint16_tlv_t  preambleTransMax;
+  nfapi_uint16_tlv_t  powerRampingStep;
+  nfapi_uint16_tlv_t  ra_ResponseWindow;
 } nfapi_nr_rach_config_t;
 
 typedef struct {
   nfapi_uint16_tlv_t  groupHoppingEnabledTransformPrecoding;                          ///// L1 parameter 'Group-hopping-enabled-Transform-precoding'
   nfapi_uint16_tlv_t  msg3_DeltaPreamble;                                             ///// L1 parameter 'Delta-preamble-msg3' 
   nfapi_uint16_tlv_t  p0_NominalWithGrant;                                            ///// L1 parameter 'p0-nominal-pusch-withgrant'
-  nfapi_uint16_tlv_t  TimeDomainResourceAllocation_k2;                                ///// L1 parameter 'K2' 
-  nfapi_uint16_tlv_t  TimeDomainResourceAllocation_mappingType;                       ///// L1 parameter 'Mapping-type'
+  nfapi_uint16_tlv_t  dmrs_TypeA_Position;
+  nfapi_uint16_tlv_t  num_PUSCHTimeDomainResourceAllocations;
+  nfapi_uint16_tlv_t  PUSCHTimeDomainResourceAllocation_k2[NFAPI_NR_PUSCH_CONFIG_MAXALLOCATIONS];                                ///// L1 parameter 'K2' 
+  nfapi_uint16_tlv_t  PUSCHTimeDomainResourceAllocation_mappingType[NFAPI_NR_PUSCH_CONFIG_MAXALLOCATIONS];                       ///// L1 parameter 'Mapping-type'
+  nfapi_uint16_tlv_t  PUSCHTimeDomainResourceAllocation_startSymbolAndLength[NFAPI_NR_PUSCH_CONFIG_MAXALLOCATIONS];
 } nfapi_nr_pusch_config_t;
 
 typedef struct {
+  uint8_t pucch_resource_common;
   nfapi_uint16_tlv_t  pucch_GroupHopping;                                             ///// L1 parameter 'PUCCH-GroupHopping' 
   nfapi_uint16_tlv_t  p0_nominal;                                                     ///// L1 parameter 'p0-nominal-pucch'
 } nfapi_nr_pucch_config_t;
 
 
+
 typedef struct {
   nfapi_tl_t tl;
-  nfapi_nr_SearchSpace_t           sib1searchSpace;
-  nfapi_nr_SearchSpace_t           sibssearchSpace; 
-  nfapi_nr_SearchSpace_t           ra_SearchSpace;
+
+  nfapi_uint16_tlv_t  controlResourceSetZero;
+  nfapi_uint16_tlv_t  searchSpaceZero;
+  
+  //  nfapi_nr_SearchSpace_t           sib1searchSpace;
+  //  nfapi_nr_SearchSpace_t           sibssearchSpace; 
+  //  nfapi_nr_SearchSpace_t           ra_SearchSpace;
 }nfapi_nr_pdcch_config_t;
 
 typedef struct {
 //NR TDD-UL-DL-ConfigCommon                ///// L1 parameter 'UL-DL-configuration-common'
-  nfapi_uint16_tlv_t  subcarrierspacing;                                     ///// L1 parameter 'reference-SCS'
+  nfapi_uint16_tlv_t  referenceSubcarrierSpacing;                                     ///// L1 parameter 'reference-SCS'
   nfapi_uint16_tlv_t  dl_ul_periodicity;                                  ///// L1 parameter 'DL-UL-transmission-periodicity'
   nfapi_uint16_tlv_t  nrofDownlinkSlots;                                              ///// L1 parameter 'number-of-DL-slots'
   nfapi_uint16_tlv_t  nrofDownlinkSymbols;                                            ///// L1 parameter 'number-of-DL-symbols-common'
   nfapi_uint16_tlv_t  nrofUplinkSlots;                                                ///// L1 parameter 'number-of-UL-slots'
   nfapi_uint16_tlv_t  nrofUplinkSymbols;                                              ///// L1 parameter 'number-of-UL-symbols-common'
+  nfapi_uint16_tlv_t  Pattern2Present;
+  nfapi_uint16_tlv_t  Pattern2_dl_ul_periodicity;                                  ///// L1 parameter 'DL-UL-transmission-periodicity'
+  nfapi_uint16_tlv_t  Pattern2_nrofDownlinkSlots;                                              ///// L1 parameter 'number-of-DL-slots'
+  nfapi_uint16_tlv_t  Pattern2_nrofDownlinkSymbols;                                            ///// L1 parameter 'number-of-DL-symbols-common'
+  nfapi_uint16_tlv_t  Pattern2_nrofUplinkSlots;                                                ///// L1 parameter 'number-of-UL-slots'
+  nfapi_uint16_tlv_t  Pattern2_nrofUplinkSymbols;                                              ///// L1 parameter 'number-of-UL-symbols-common'
 } nfapi_nr_tdd_ul_dl_config_t;
 
 typedef struct {
@@ -287,6 +254,7 @@ typedef struct {
   nfapi_nr_subframe_config_t                subframe_config;
   nfapi_nr_rf_config_t                      rf_config;
   nfapi_nr_sch_config_t                     sch_config;
+  nfapi_nr_initialBWP_config_t              initialBWP_config;
   nfapi_nr_pdsch_config_t                   pdsch_config;
   nfapi_nr_rach_config_t                    rach_config;
   nfapi_nr_pusch_config_t                   pusch_config;
@@ -426,13 +394,9 @@ typedef enum {
   NFAPI_NR_MCS_TABLE_QAM256
 } nfapi_nr_pdsch_mcs_table_e;
 
-typedef enum {
-  NFAPI_NR_DMRS_TYPE1=0,
-  NFAPI_NR_DMRS_TYPE2
-} nfapi_nr_dmrs_type_e;
-
 // P7 Sub Structures
 
+/*
 typedef struct {
 
 nfapi_tl_t tl;
@@ -495,9 +459,12 @@ uint16_t reserved; //1_0/C-RNTI:10 bits, 1_0/P-RNTI: 6 bits, 1_0/SI-&RA-RNTI: 16
 uint16_t padding;
 
 } nfapi_nr_dl_config_dci_dl_pdu_rel15_t;
-
+*/
 //#define NFAPI_NR_DL_CONFIG_REQUEST_DCI_DL_PDU_REL15_TAG 0x????
 
+
+
+/*
 typedef struct{
   nfapi_tl_t tl;
   uint8_t  coreset_id;
@@ -532,11 +499,13 @@ typedef struct{
   uint16_t  number_of_candidates[NFAPI_NR_MAX_NB_CCE_AGGREGATION_LEVELS];
 } nfapi_nr_search_space_t;
 
+
 typedef struct {
   nfapi_tl_t tl;
   uint16_t rnti;
   uint8_t rnti_type;
   uint8_t dci_format;
+  uint16_t cce_index;
   /// Number of CRB in BWP that this DCI configures 
   uint16_t n_RB_BWP;
   uint8_t config_type;
@@ -561,118 +530,7 @@ typedef struct {
   nfapi_bf_vector_t   bf_vector;
 } nfapi_nr_dl_config_pdcch_parameters_rel15_t;
 
-typedef struct {
-  nfapi_tl_t tl;
-  uint16_t length;
-  int16_t  pdu_index;
-  uint16_t transmission_power;
-} nfapi_nr_dl_config_bch_pdu_rel15_t;
-#define NFAPI_NR_DL_CONFIG_REQUEST_BCH_PDU_REL15_TAG 0x5025
-
-typedef struct {
-  nfapi_nr_dl_config_bch_pdu_rel15_t bch_pdu_rel15;
-} nfapi_nr_dl_config_bch_pdu;
-
-typedef struct {
-  nfapi_tl_t tl;
-  uint16_t length;
-  uint8_t pdu_index;
-  uint16_t rnti;
-  uint16_t nb_mod_symbols;
-  uint8_t time_allocation_type;
-  uint8_t freq_allocation_type;
-  uint16_t start_prb;
-  uint16_t n_prb;
-  uint8_t start_symbol;
-  uint8_t nb_symbols;
-  uint8_t mcs_idx;
-  uint8_t mcs_table;
-  uint8_t ndi;
-  uint8_t nb_codewords;
-  uint8_t nb_layers;
-  uint16_t coding_rate;
-  uint8_t modulation;
-  uint8_t modulation_order;
-  uint32_t transport_block_size;
-  uint8_t nb_re_dmrs;
-  uint8_t time_alloc_list_flag;
-  uint8_t time_alloc_list;
-  uint8_t rbg_list;
-  uint8_t virtual_resource_block_assignment_flag;
-  uint32_t resource_block_coding;
-  uint8_t redundancy_version;
-  uint8_t transport_blocks;
-  uint8_t transmission_scheme;
-  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 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_nr_dl_config_dlsch_pdu_rel15_t;
-#define NFAPI_NR_DL_CONFIG_REQUEST_DLSCH_PDU_REL15_TAG
-
-typedef struct {
-	nfapi_nr_dl_config_dlsch_pdu_rel15_t dlsch_pdu_rel15;
-} nfapi_nr_dl_config_dlsch_pdu;
-
-typedef struct {
-  nfapi_tl_t tl;
-  nfapi_nr_search_space_t           pagingSearchSpace;
-  nfapi_nr_coreset_t   pagingControlResourceSets;
-}nfapi_nr_dl_config_pch_pdu_rel15_t;
-
-typedef struct {
-  
-} nfapi_nr_dl_config_nbch_pdu_rel15_t;
-
-typedef struct {
-  
-} nfapi_nr_dl_config_npdcch_pdu_rel15_t;
-
-typedef struct {
-  
-} nfapi_nr_dl_config_ndlsch_pdu_rel15_t;
-
-typedef struct {
-  nfapi_nr_dl_config_dci_dl_pdu_rel15_t     dci_dl_pdu_rel15;
-  nfapi_nr_dl_config_pdcch_parameters_rel15_t pdcch_params_rel15;
-} nfapi_nr_dl_config_dci_dl_pdu;
-
-
-typedef struct {
-  uint8_t pdu_type;
-  uint8_t pdu_size;
-
-  union {
-  nfapi_nr_dl_config_dci_dl_pdu             dci_dl_pdu;
-  nfapi_nr_dl_config_bch_pdu_rel15_t        bch_pdu_rel15;
-  nfapi_nr_dl_config_dlsch_pdu              dlsch_pdu;
-  nfapi_nr_dl_config_pch_pdu_rel15_t        pch_pdu_rel15;
-  nfapi_nr_dl_config_nbch_pdu_rel15_t       nbch_pdu_rel15;
-  nfapi_nr_dl_config_npdcch_pdu_rel15_t     npdcch_pdu_rel15;
-  nfapi_nr_dl_config_ndlsch_pdu_rel15_t     ndlsch_pdu_rel15;
-  };
-} nfapi_nr_dl_config_request_pdu_t;
- 
-typedef struct {
-  nfapi_tl_t tl;
-  uint8_t   number_dci;
-  uint8_t   number_pdu;
-  uint8_t   number_pdsch_rnti;
-  nfapi_nr_dl_config_request_pdu_t *dl_config_pdu_list;
-} nfapi_nr_dl_config_request_body_t;
-
-typedef struct {
-  nfapi_p7_message_header_t header;
-  uint16_t sfn_sf;
-  nfapi_nr_dl_config_request_body_t dl_config_request_body;
-  nfapi_vendor_extension_tlv_t vendor_extension;
-} nfapi_nr_dl_config_request_t;
+*/
 
 
 typedef enum {nr_pusch_freq_hopping_disabled = 0 , 
@@ -711,9 +569,37 @@ typedef struct {
     uint8_t beta_offset_ind;
 } nfapi_nr_ul_config_ulsch_pdu_rel15_t;
 
+
+
+
+
 typedef struct {
   uint16_t rnti;
   nfapi_nr_ul_config_ulsch_pdu_rel15_t ulsch_pdu_rel15;
 } nfapi_nr_ul_config_ulsch_pdu;
 
+typedef struct {
+  uint8_t pdu_type;
+  uint8_t pdu_size;
+
+  union {
+    //    nfapi_nr_ul_config_uci_pdu uci_pdu;
+    nfapi_nr_ul_config_ulsch_pdu ulsch_pdu;
+    //    nfapi_nr_ul_config_srs_pdu srs_pdu;
+  };
+} nfapi_nr_ul_config_request_pdu_t;
+
+typedef struct {
+  nfapi_tl_t tl;
+  uint8_t   number_pdu;
+  nfapi_nr_ul_config_request_pdu_t *ul_config_pdu_list;
+} nfapi_nr_ul_config_request_body_t;
+
+typedef struct {
+  nfapi_p7_message_header_t header;
+  uint16_t sfn_sf;
+  nfapi_nr_ul_config_request_body_t ul_config_request_body;
+  nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_nr_ul_config_request_t;
+
 #endif
diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h
index 1eea6474f30..f69c928ed27 100644
--- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h
+++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h
@@ -22,7 +22,6 @@
 #define NFAPI_MAX_NUM_GROUPS 8
 #define NFAPI_MAX_NUM_CB 8
 
-/*
 // Extension to the generic structures for single tlv values
 typedef struct {
 	nfapi_tl_t tl;
@@ -33,7 +32,34 @@ typedef struct {
 	nfapi_tl_t tl;
 	uint32_t value;
 } nfapi_uint32_tlv_t;
-*/
+
+typedef struct {
+	nfapi_tl_t tl;
+	int64_t value;
+} nfapi_int64_tlv_t;
+
+typedef struct {
+	nfapi_tl_t tl;
+	uint64_t value;
+} nfapi_uint64_tlv_t;
+
+typedef enum {
+  NFAPI_NR_DMRS_TYPE1=0,
+  NFAPI_NR_DMRS_TYPE2
+} nfapi_nr_dmrs_type_e;
+
+
+typedef struct {
+  /// Value: 0 -> 1, 0: Payload is carried directly in the value field, 1: Pointer to payload is in the value field 
+  uint16_t tag; 
+  /// Length of the actual payload in bytes, without the padding bytes Value: 0 → 65535
+  uint16_t length;
+  union { 
+    uint32_t *ptr;
+    uint32_t direct[16384];
+  } value;
+} nfapi_nr_tx_data_request_tlv_t;
+
 
 // 2019.8
 // SCF222_5G-FAPI_PHY_SPI_Specificayion.pdf Section 3.2
@@ -67,12 +93,6 @@ typedef enum {
 
 //3.3.1 PARAM
 
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t value;
-
-} nfapi_nr_param_tlv_t;
-
 //same with nfapi_param_request_t
 typedef struct {
 	nfapi_p4_p5_message_header_t header;
@@ -85,12 +105,12 @@ typedef enum {
 
 } nfapi_nr_param_errors_e;
 
-typedef struct {
+/*typedef struct {
   nfapi_nr_param_errors_e error_code;
   //Number of TLVs contained in the message body.
   uint8_t number_of_tlvs;
   nfapi_nr_param_tlv_t TLV;
-} nfapi_nr_param_response_t;
+} nfapi_nr_param_response_t;*/
 
 
 //PARAM and CONFIG TLVs are used in the PARAM and CONFIG message exchanges, respectively
@@ -100,7 +120,7 @@ typedef struct {
 
 //table 3-9
 
-#define NFAPI_NR_PARAM_TLV_RELEASE_CAPABILITY_TAG 0x0001
+#define  NFAPI_NR_PARAM_TLV_RELEASE_CAPABILITY_TAG 0x0001
 #define  NFAPI_NR_PARAM_TLV_PHY_STATE_TAG         0x0002
 #define  NFAPI_NR_PARAM_TLV_SKIP_BLANK_DL_CONFIG_TAG 0x0003
 #define  NFAPI_NR_PARAM_TLV_SKIP_BLANK_UL_CONFIG_TAG 0x0004
@@ -157,123 +177,113 @@ typedef struct {
 
 typedef struct 
 {
-  uint16_t release_capability; //TAG 0x0001
-  uint16_t phy_state;
-  uint8_t  skip_blank_dl_config;
-  uint8_t  skip_blank_ul_config;
-  uint16_t num_config_tlvs_to_report;
-  nfapi_nr_param_tlv_t* config_tlvs_to_report_list;
+  nfapi_uint16_tlv_t release_capability; //TAG 0x0001
+  nfapi_uint16_tlv_t phy_state;
+  nfapi_uint8_tlv_t  skip_blank_dl_config;
+  nfapi_uint8_tlv_t  skip_blank_ul_config;
+  nfapi_uint16_tlv_t num_config_tlvs_to_report;
+  nfapi_uint8_tlv_t* config_tlvs_to_report_list;
 } nfapi_nr_cell_param_t;
 
 //table 3-10 Carrier parameters
 typedef struct 
 {
-  uint8_t  cyclic_prefix;//TAG 0x0006
-  uint8_t  supported_subcarrier_spacings_dl;
-  uint16_t supported_bandwidth_dl;
-  uint8_t  supported_subcarrier_spacings_ul;
-  uint16_t supported_bandwidth_ul;
+  nfapi_uint8_tlv_t  cyclic_prefix;//TAG 0x0006
+  nfapi_uint16_tlv_t  supported_subcarrier_spacings_dl;
+  nfapi_uint16_tlv_t supported_bandwidth_dl;
+  nfapi_uint8_tlv_t  supported_subcarrier_spacings_ul;
+  nfapi_uint16_tlv_t supported_bandwidth_ul;
   
 } nfapi_nr_carrier_param_t;
 
 //table 3-11 PDCCH parameters
 typedef struct 
 {
-  uint8_t  cce_mapping_type;
-  uint8_t  coreset_outside_first_3_of_ofdm_syms_of_slot;
-  uint8_t  coreset_precoder_granularity_coreset;
-  uint8_t  pdcch_mu_mimo;
-  uint8_t  pdcch_precoder_cycling;
-  uint8_t  max_pdcch_per_slot;//TAG 0x0010
+  nfapi_uint8_tlv_t  cce_mapping_type;
+  nfapi_uint8_tlv_t  coreset_outside_first_3_of_ofdm_syms_of_slot;
+  nfapi_uint8_tlv_t  coreset_precoder_granularity_coreset;
+  nfapi_uint8_tlv_t  pdcch_mu_mimo;
+  nfapi_uint8_tlv_t  pdcch_precoder_cycling;
+  nfapi_uint8_tlv_t  max_pdcch_per_slot;//TAG 0x0010
 
 } nfapi_nr_pdcch_param_t;
 
 //table 3-12 PUCCH parameters
 typedef struct 
 {
-  uint8_t pucch_formats;
-  uint8_t max_pucchs_per_slot;
+  nfapi_uint8_tlv_t pucch_formats;
+  nfapi_uint8_tlv_t max_pucchs_per_slot;
 
 } nfapi_nr_pucch_param_t;
 
 //table 3-13 PDSCH parameters
 typedef struct 
 {
-  uint8_t pdsch_mapping_type;
-  uint8_t pdsch_allocation_types;
-  uint8_t pdsch_vrb_to_prb_mapping;
-  uint8_t pdsch_cbg;
-  uint8_t pdsch_dmrs_config_types;
-  uint8_t pdsch_dmrs_max_length;
-  uint8_t pdsch_dmrs_additional_pos;
-  uint8_t max_pdsch_tbs_per_slot;
-  uint8_t max_number_mimo_layers_pdsch;
-  uint8_t supported_max_modulation_order_dl;
-  uint8_t max_mu_mimo_users_dl;
-  uint8_t pdsch_data_in_dmrs_symbols;
-  uint8_t premption_support;//TAG 0x001F
-  uint8_t pdsch_non_slot_support;
+  nfapi_uint8_tlv_t pdsch_mapping_type;
+  nfapi_uint8_tlv_t pdsch_allocation_types;
+  nfapi_uint8_tlv_t pdsch_vrb_to_prb_mapping;
+  nfapi_uint8_tlv_t pdsch_cbg;
+  nfapi_uint8_tlv_t pdsch_dmrs_config_types;
+  nfapi_uint8_tlv_t pdsch_dmrs_max_length;
+  nfapi_uint8_tlv_t pdsch_dmrs_additional_pos;
+  nfapi_uint8_tlv_t max_pdsch_tbs_per_slot;
+  nfapi_uint8_tlv_t max_number_mimo_layers_pdsch;
+  nfapi_uint8_tlv_t supported_max_modulation_order_dl;
+  nfapi_uint8_tlv_t max_mu_mimo_users_dl;
+  nfapi_uint8_tlv_t pdsch_data_in_dmrs_symbols;
+  nfapi_uint8_tlv_t premption_support;//TAG 0x001F
+  nfapi_uint8_tlv_t pdsch_non_slot_support;
 
 } nfapi_nr_pdsch_param_t;
 
 //table 3-14
 typedef struct 
 {
-  uint8_t uci_mux_ulsch_in_pusch;
-  uint8_t uci_only_pusch;
-  uint8_t pusch_frequency_hopping;
-  uint8_t pusch_dmrs_config_types;
-  uint8_t pusch_dmrs_max_len;
-  uint8_t pusch_dmrs_additional_pos;
-  uint8_t pusch_cbg;
-  uint8_t pusch_mapping_type;
-  uint8_t pusch_allocation_types;
-  uint8_t pusch_vrb_to_prb_mapping;
-  //uint8 ? ↓ see table 3-14
-  uint8_t pusch_max_ptrs_ports;
-  uint8_t max_pduschs_tbs_per_slot;
-  uint8_t max_number_mimo_layers_non_cb_pusch;
-  uint8_t supported_modulation_order_ul;
-  uint8_t max_mu_mimo_users_ul;
-  uint8_t dfts_ofdm_support;
-  uint8_t pusch_aggregation_factor;//TAG 0x0031
+  nfapi_uint8_tlv_t uci_mux_ulsch_in_pusch;
+  nfapi_uint8_tlv_t uci_only_pusch;
+  nfapi_uint8_tlv_t pusch_frequency_hopping;
+  nfapi_uint8_tlv_t pusch_dmrs_config_types;
+  nfapi_uint8_tlv_t pusch_dmrs_max_len;
+  nfapi_uint8_tlv_t pusch_dmrs_additional_pos;
+  nfapi_uint8_tlv_t pusch_cbg;
+  nfapi_uint8_tlv_t pusch_mapping_type;
+  nfapi_uint8_tlv_t pusch_allocation_types;
+  nfapi_uint8_tlv_t pusch_vrb_to_prb_mapping;
+  nfapi_uint8_tlv_t pusch_max_ptrs_ports;
+  nfapi_uint8_tlv_t max_pduschs_tbs_per_slot;
+  nfapi_uint8_tlv_t max_number_mimo_layers_non_cb_pusch;
+  nfapi_uint8_tlv_t supported_modulation_order_ul;
+  nfapi_uint8_tlv_t max_mu_mimo_users_ul;
+  nfapi_uint8_tlv_t dfts_ofdm_support;
+  nfapi_uint8_tlv_t pusch_aggregation_factor;//TAG 0x0031
 
 } nfapi_nr_pusch_param_t;
 
 //table 3-15
 typedef struct 
 {
-  uint8_t prach_long_formats;
-  uint8_t prach_short_formats;
-  uint8_t prach_restricted_sets;
-  uint8_t max_prach_fd_occasions_in_a_slot;
-
+  nfapi_uint8_tlv_t prach_long_formats;
+  nfapi_uint8_tlv_t prach_short_formats;
+  nfapi_uint8_tlv_t prach_restricted_sets;
+  nfapi_uint8_tlv_t max_prach_fd_occasions_in_a_slot;
 } nfapi_nr_prach_param_t;
 
 //table 3-16
 typedef struct 
 {
-  uint8_t rssi_measurement_support;
+  nfapi_uint8_tlv_t rssi_measurement_support;
 } nfapi_nr_measurement_param_t;
 
 //-------------------------------------------//
 //3.3.2 CONFIG
-typedef struct {
-	nfapi_tl_t tl;
-	uint16_t value;
-} nfapi_nr_config_tlv_t;
 
-typedef struct {
-	uint8_t number_of_tlvs;
-	nfapi_nr_config_tlv_t tlv;
-} nfapi_nr_config_request_scf_t;
 
 typedef enum {
   NFAPI_NR_CONFIG_MSG_OK = 0,
-	NFAPI_NR_CONFIG_MSG_INVALID_CONFIG  //The configuration provided has missing mandatory TLVs, or TLVs that are invalid or unsupported in this state.
+  NFAPI_NR_CONFIG_MSG_INVALID_CONFIG  //The configuration provided has missing mandatory TLVs, or TLVs that are invalid or unsupported in this state.
 } nfapi_nr_config_errors_e;
 
-typedef struct {
+/*typedef struct {
 	nfapi_nr_config_errors_e error_code;
   uint8_t number_of_invalid_tlvs_that_can_only_be_configured_in_idle;
   uint8_t unmber_of_missing_tlvs;
@@ -283,7 +293,7 @@ typedef struct {
   nfapi_nr_config_tlv_t* tlv_invalid_running_list;
   nfapi_nr_config_tlv_t* tlv_missing_list;
 
-} nfapi_nr_config_response_t;
+} nfapi_nr_config_response_t;*/
 
 //nfapi_nr_config_tlv_format_t carrier config ~ precoding config:
 
@@ -336,34 +346,34 @@ typedef struct {
 //table 3-21
 typedef struct 
 {
-  uint16_t dl_bandwidth;//Carrier bandwidth for DL in MHz [38.104, sec 5.3.2] Values: 5, 10, 15, 20, 25, 30, 40,50, 60, 70, 80,90,100,200,400
-  uint32_t dl_frequency; //Absolute frequency of DL point A in KHz [38.104, sec5.2 and 38.211 sec 4.4.4.2] Value: 450000 -> 52600000
-  uint16_t dl_k0[5];//𝑘_{0}^{𝜇} for each of the numerologies [38.211, sec 5.3.1] Value: 0 ->23699
-  uint16_t dl_grid_size[5];//Grid size 𝑁_{𝑔𝑟𝑖𝑑}^{𝑠𝑖𝑧𝑒,𝜇} for each of the numerologies [38.211, sec 4.4.2] Value: 0->275 0 = this numerology not used
-  uint16_t num_tx_ant;//Number of Tx antennas
-  uint16_t uplink_bandwidth;//Carrier bandwidth for UL in MHz. [38.104, sec 5.3.2] Values: 5, 10, 15, 20, 25, 30, 40,50, 60, 70, 80,90,100,200,400
-  uint32_t uplink_frequency;//Absolute frequency of UL point A in KHz [38.104, sec5.2 and 38.211 sec 4.4.4.2] Value: 450000 -> 52600000
-  uint16_t ul_k0[5];//𝑘0 𝜇 for each of the numerologies [38.211, sec 5.3.1] Value: : 0 ->23699
-  uint16_t ul_grid_size[5];//Grid size 𝑁𝑔𝑟𝑖𝑑 𝑠𝑖𝑧𝑒,𝜇 for each of the numerologies [38.211, sec 4.4.2]. Value: 0->275 0 = this numerology not used
-  uint16_t num_rx_ant;//
-  uint8_t  frequency_shift_7p5khz;//Indicates presence of 7.5KHz frequency shift. Value: 0 = false 1 = true
+  nfapi_uint16_tlv_t dl_bandwidth;//Carrier bandwidth for DL in MHz [38.104, sec 5.3.2] Values: 5, 10, 15, 20, 25, 30, 40,50, 60, 70, 80,90,100,200,400
+  nfapi_uint32_tlv_t dl_frequency; //Absolute frequency of DL point A in KHz [38.104, sec5.2 and 38.211 sec 4.4.4.2] Value: 450000 -> 52600000
+  nfapi_uint16_tlv_t dl_k0[5];//𝑘_{0}^{𝜇} for each of the numerologies [38.211, sec 5.3.1] Value: 0 ->23699
+  nfapi_uint16_tlv_t dl_grid_size[5];//Grid size 𝑁_{𝑔𝑟𝑖𝑑}^{𝑠𝑖𝑧𝑒,𝜇} for each of the numerologies [38.211, sec 4.4.2] Value: 0->275 0 = this numerology not used
+  nfapi_uint16_tlv_t num_tx_ant;//Number of Tx antennas
+  nfapi_uint16_tlv_t uplink_bandwidth;//Carrier bandwidth for UL in MHz. [38.104, sec 5.3.2] Values: 5, 10, 15, 20, 25, 30, 40,50, 60, 70, 80,90,100,200,400
+  nfapi_uint32_tlv_t uplink_frequency;//Absolute frequency of UL point A in KHz [38.104, sec5.2 and 38.211 sec 4.4.4.2] Value: 450000 -> 52600000
+  nfapi_uint16_tlv_t ul_k0[5];//𝑘0 𝜇 for each of the numerologies [38.211, sec 5.3.1] Value: : 0 ->23699
+  nfapi_uint16_tlv_t ul_grid_size[5];//Grid size 𝑁𝑔𝑟𝑖𝑑 𝑠𝑖𝑧𝑒,𝜇 for each of the numerologies [38.211, sec 4.4.2]. Value: 0->275 0 = this numerology not used
+  nfapi_uint16_tlv_t num_rx_ant;//
+  nfapi_uint8_tlv_t  frequency_shift_7p5khz;//Indicates presence of 7.5KHz frequency shift. Value: 0 = false 1 = true
 
 } nfapi_nr_carrier_config_t; 
 
 //table 3-22
 typedef struct 
 {
-  uint8_t phy_cell_id;//Physical Cell ID, 𝑁_{𝐼𝐷}^{𝑐𝑒𝑙𝑙} [38.211, sec 7.4.2.1] Value: 0 ->1007
-  uint8_t frame_duplex_type;//Frame duplex type Value: 0 = FDD 1 = TDD
+  nfapi_uint8_tlv_t phy_cell_id;//Physical Cell ID, 𝑁_{𝐼𝐷}^{𝑐𝑒𝑙𝑙} [38.211, sec 7.4.2.1] Value: 0 ->1007
+  nfapi_uint8_tlv_t frame_duplex_type;//Frame duplex type Value: 0 = FDD 1 = TDD
 
 } nfapi_nr_cell_config_t;
 
 //table 3-23
 typedef struct 
 {
-  uint32_t ss_pbch_power;//SSB Block Power Value: TBD (-60..50 dBm)
-  uint8_t  bch_payload;//Defines option selected for generation of BCH payload, see Table 3-13 (v0.0.011 Value: 0: MAC generates the full PBCH payload 1: PHY generates the timing PBCH bits 2: PHY generates the full PBCH payload
-  uint8_t  scs_common;//subcarrierSpacing for common, used for initial access and broadcast message. [38.211 sec 4.2] Value:0->3
+  nfapi_uint32_tlv_t ss_pbch_power;//SSB Block Power Value: TBD (-60..50 dBm)
+  nfapi_uint8_tlv_t  bch_payload;//Defines option selected for generation of BCH payload, see Table 3-13 (v0.0.011 Value: 0: MAC generates the full PBCH payload 1: PHY generates the timing PBCH bits 2: PHY generates the full PBCH payload
+  nfapi_uint8_tlv_t  scs_common;//subcarrierSpacing for common, used for initial access and broadcast message. [38.211 sec 4.2] Value:0->3
 
 } nfapi_nr_ssb_config_t;
 
@@ -375,51 +385,51 @@ typedef struct
 typedef struct 
 {
   uint8_t  num_prach_fd_occasions;
-  uint16_t prach_root_sequence_index;//Starting logical root sequence index, 𝑖, equivalent to higher layer parameter prach-RootSequenceIndex [38.211, sec 6.3.3.1] Value: 0 -> 837
-  uint8_t  num_root_sequences;//Number of root sequences for a particular FD occasion that are required to generate the necessary number of preambles
-  uint16_t k1;//Frequency offset (from UL bandwidth part) for each FD. [38.211, sec 6.3.3.2] Value: from 0 to 272
-  uint8_t  prach_zero_corr_conf;//PRACH Zero CorrelationZone Config which is used to dervive 𝑁𝑐𝑠 [38.211, sec 6.3.3.1] Value: from 0 to 15
-  uint8_t  num_unused_root_sequences;//Number of unused sequences available for noise estimation per FD occasion. At least one unused root sequence is required per FD occasion.
-  uint8_t* unused_root_sequences_list;//Unused root sequence or sequences per FD occasion. Required for noise estimation.
+  nfapi_uint16_tlv_t prach_root_sequence_index;//Starting logical root sequence index, 𝑖, equivalent to higher layer parameter prach-RootSequenceIndex [38.211, sec 6.3.3.1] Value: 0 -> 837
+  nfapi_uint8_tlv_t  num_root_sequences;//Number of root sequences for a particular FD occasion that are required to generate the necessary number of preambles
+  nfapi_uint16_tlv_t k1;//Frequency offset (from UL bandwidth part) for each FD. [38.211, sec 6.3.3.2] Value: from 0 to 272
+  nfapi_uint8_tlv_t  prach_zero_corr_conf;//PRACH Zero CorrelationZone Config which is used to dervive 𝑁𝑐𝑠 [38.211, sec 6.3.3.1] Value: from 0 to 15
+  nfapi_uint8_tlv_t  num_unused_root_sequences;//Number of unused sequences available for noise estimation per FD occasion. At least one unused root sequence is required per FD occasion.
+  nfapi_uint8_tlv_t* unused_root_sequences_list;//Unused root sequence or sequences per FD occasion. Required for noise estimation.
 
 } nfapi_nr_num_prach_fd_occasions_t;
 
 typedef struct 
 {
-  uint8_t prach_sequence_length;//RACH sequence length. Long or Short sequence length. Only short sequence length is supported for FR2. [38.211, sec 6.3.3.1] Value: 0 = Long sequence 1 = Short sequence
-  uint8_t prach_sub_c_spacing;//Subcarrier spacing of PRACH. [38.211 sec 4.2] Value:0->4
-  uint8_t restricted_set_config;//PRACH restricted set config Value: 0: unrestricted 1: restricted set type A 2: restricted set type B
-  uint8_t num_prach_fd_occasions;//Number of RACH frequency domain occasions. Corresponds to the parameter 𝑀 in [38.211, sec 6.3.3.2] which equals the higher layer parameter msg1FDM Value: 1,2,4,8
+  nfapi_uint8_tlv_t prach_sequence_length;//RACH sequence length. Only short sequence length is supported for FR2. [38.211, sec 6.3.3.1] Value: 0 = Long sequence 1 = Short sequence
+  nfapi_uint8_tlv_t prach_sub_c_spacing;//Subcarrier spacing of PRACH. [38.211 sec 4.2] Value:0->4
+  nfapi_uint8_tlv_t restricted_set_config;//PRACH restricted set config Value: 0: unrestricted 1: restricted set type A 2: restricted set type B
+  nfapi_uint8_tlv_t num_prach_fd_occasions;//Corresponds to the parameter 𝑀 in [38.211, sec 6.3.3.2] which equals the higher layer parameter msg1FDM Value: 1,2,4,8
   nfapi_nr_num_prach_fd_occasions_t* num_prach_fd_occasions_list;
-  uint8_t ssb_per_rach;//SSB-per-RACH-occasion Value: 0: 1/8 1:1/4, 2:1/2 3:1 4:2 5:4, 6:8 7:16
-  uint8_t prach_multiple_carriers_in_a_band;//0 = disabled 1 = enabled
+  nfapi_uint8_tlv_t ssb_per_rach;//SSB-per-RACH-occasion Value: 0: 1/8 1:1/4, 2:1/2 3:1 4:2 5:4, 6:8 7:16
+  nfapi_uint8_tlv_t prach_multiple_carriers_in_a_band;//0 = disabled 1 = enabled
 
 } nfapi_nr_prach_config_t;
 
 //table 3-25
 typedef struct 
 {
-  uint32_t ssb_mask;//Bitmap for actually transmitted SSB. MSB->LSB of first 32 bit number corresponds to SSB 0 to SSB 31 MSB->LSB of second 32 bit number corresponds to SSB 32 to SSB 63 Value for each bit: 0: not transmitted 1: transmitted
+  nfapi_uint32_tlv_t ssb_mask;//Bitmap for actually transmitted SSB. MSB->LSB of first 32 bit number corresponds to SSB 0 to SSB 31 MSB->LSB of second 32 bit number corresponds to SSB 32 to SSB 63 Value for each bit: 0: not transmitted 1: transmitted
 
 } nfapi_nr_ssb_mask_size_2_t;
 
 typedef struct 
 {
-  uint8_t beam_id[64];//BeamID for each SSB in SsbMask. For example, if SSB mask bit 26 is set to 1, then BeamId[26] will be used to indicate beam ID of SSB 26. Value: from 0 to 63
+  nfapi_uint8_tlv_t beam_id[64];//BeamID for each SSB in SsbMask. For example, if SSB mask bit 26 is set to 1, then BeamId[26] will be used to indicate beam ID of SSB 26. Value: from 0 to 63
 
 } nfapi_nr_ssb_mask_size_64_t;
 
 typedef struct 
 {
-  uint16_t ssb_offset_point_a;//Offset of lowest subcarrier of lowest resource block used for SS/PBCH block. Given in PRB [38.211, section 4.4.4.2] Value: 0->2199
-  uint8_t  beta_pss;//PSS EPRE to SSS EPRE in a SS/PBCH block [38.213, sec 4.1] Values: 0 = 0dB
-  uint8_t  ssb_period;//SSB periodicity in msec Value: 0: ms5 1: ms10 2: ms20 3: ms40 4: ms80 5: ms160
-  uint8_t  ssb_subcarrier_offset;//ssbSubcarrierOffset or 𝑘𝑆𝑆𝐵 (38.211, section 7.4.3.1) Value: 0->31
-  uint32_t MIB;//MIB payload, where the 24 MSB are used and represent the MIB in [38.331 MIB IE] and represent 0 1 2 3 1 , , , ,..., A− a a a a a [38.212, sec 7.1.1]
-  nfapi_nr_ssb_mask_size_2_t* ssb_mask_size_2_list;//2
-  nfapi_nr_ssb_mask_size_64_t* ssb_mask_size_64_list;//64
-  uint8_t  ss_pbch_multiple_carriers_in_a_band;//0 = disabled 1 = enabled
-  uint8_t  multiple_cells_ss_pbch_in_a_carrier;//Indicates that multiple cells will be supported in a single carrier 0 = disabled 1 = enabled
+  nfapi_uint16_tlv_t ssb_offset_point_a;//Offset of lowest subcarrier of lowest resource block used for SS/PBCH block. Given in PRB [38.211, section 4.4.4.2] Value: 0->2199
+  nfapi_uint8_tlv_t  beta_pss;//PSS EPRE to SSS EPRE in a SS/PBCH block [38.213, sec 4.1] Values: 0 = 0dB
+  nfapi_uint8_tlv_t  ssb_period;//SSB periodicity in msec Value: 0: ms5 1: ms10 2: ms20 3: ms40 4: ms80 5: ms160
+  nfapi_uint8_tlv_t  ssb_subcarrier_offset;//ssbSubcarrierOffset or 𝑘𝑆𝑆𝐵 (38.211, section 7.4.3.1) Value: 0->31
+  nfapi_uint32_tlv_t MIB;//MIB payload, where the 24 MSB are used and represent the MIB in [38.331 MIB IE] and represent 0 1 2 3 1 , , , ,..., A− a a a a a [38.212, sec 7.1.1]
+  nfapi_nr_ssb_mask_size_2_t ssb_mask_list[2];
+  nfapi_nr_ssb_mask_size_64_t* ssb_beam_id_list;//64
+  nfapi_uint8_tlv_t  ss_pbch_multiple_carriers_in_a_band;//0 = disabled 1 = enabled
+  nfapi_uint8_tlv_t  multiple_cells_ss_pbch_in_a_carrier;//Indicates that multiple cells will be supported in a single carrier 0 = disabled 1 = enabled
 
 } nfapi_nr_ssb_table_t;
 
@@ -428,7 +438,7 @@ typedef struct
 //? 
 typedef struct 
 {
-  uint8_t slot_config;//For each symbol in each slot a uint8_t value is provided indicating: 0: DL slot 1: UL slot 2: Guard slot
+  nfapi_uint8_tlv_t slot_config;//For each symbol in each slot a uint8_t value is provided indicating: 0: DL slot 1: UL slot 2: Guard slot
 
 } nfapi_nr_max_num_of_symbol_per_slot_t;
 
@@ -440,7 +450,7 @@ typedef struct
 
 typedef struct 
 {
-  uint8_t tdd_period;//DL UL Transmission Periodicity. Value:0: ms0p5 1: ms0p625 2: ms1 3: ms1p25 4: ms2 5: ms2p5 6: ms5 7: ms10 
+  nfapi_uint8_tlv_t tdd_period;//DL UL Transmission Periodicity. Value:0: ms0p5 1: ms0p625 2: ms1 3: ms1p25 4: ms2 5: ms2p5 6: ms5 7: ms10 8: ms3 9: ms4
   nfapi_nr_max_tdd_periodicity_t* max_tdd_periodicity_list;
 
 } nfapi_nr_tdd_table_t;
@@ -448,10 +458,23 @@ typedef struct
 //table 3-27
 typedef struct 
 {
-  uint8_t rssi_measurement;//RSSI measurement unit. See Table 3-16 for RSSI definition. Value: 0: Do not report RSSI 1: dBm 2: dBFS
+  nfapi_uint8_tlv_t rssi_measurement;//RSSI measurement unit. See Table 3-16 for RSSI definition. Value: 0: Do not report RSSI 1: dBm 2: dBFS
 
 } nfapi_nr_measurement_config_t;
 
+
+typedef struct {
+  uint8_t num_tlv;
+  nfapi_nr_carrier_config_t     carrier_config;
+  nfapi_nr_cell_config_t        cell_config;
+  nfapi_nr_ssb_config_t         ssb_config;
+  nfapi_nr_prach_config_t       prach_config;
+  nfapi_nr_ssb_table_t          ssb_table;
+  nfapi_nr_tdd_table_t          tdd_table;
+  nfapi_nr_measurement_config_t measurement_config;
+} nfapi_nr_config_request_scf_t;
+
+
 //------------------------------//
 //3.3.3 START
 
@@ -573,17 +596,29 @@ typedef struct
 
 }nfapi_nr_tx_precoding_and_beamforming_number_of_prgs_t;
 
+/*
 //table 3-43
 typedef struct 
 {
-  uint16_t num_prgs;/*Number of PRGs spanning this allocation.
-Value : 1->275 */
-  uint16_t prg_size;/*Size in RBs of a precoding resource block group (PRG) – to which same precoding and digital beamforming gets applied. Value: 1->275 */
+  uint16_t num_prgs;//Number of PRGs spanning this allocation. Value : 1->275 
+  uint16_t prg_size;//Size in RBs of a precoding resource block group (PRG) – to which same precoding and digital beamforming gets applied. Value: 1->275
   //watchout: dig_bf_interfaces here, in table 3-53 it's dig_bf_interface
   uint8_t  dig_bf_interfaces;//Number of STD ant ports (parallel streams) feeding into the digBF Value: 0->255
   nfapi_nr_tx_precoding_and_beamforming_number_of_prgs_t* prgs_list;//
 
 }nfapi_nr_tx_precoding_and_beamforming_t;
+*/
+
+typedef struct {
+  /// Number of PRGs spanning this allocation. Value : 1->275
+  uint16_t numPRGs;
+  /// Size in RBs of a precoding resource block group (PRG) – to which same precoding and digital beamforming gets applied. Value: 1->275
+  uint16_t prgSize;
+  /// Number of STD ant ports (parallel streams) feeding into the digBF Value: 0->255
+  uint8_t digBFInterfaces;
+  uint16_t PMIdx[275];
+  uint16_t *beamIdx[275];
+} nfapi_nr_tx_precoding_and_beamforming_t;
 
 //table 3-37 
 
@@ -606,33 +641,154 @@ SSB/PBCH EPRE to PDCCH and PDCCH DMRS EPRE [TS38.213, sec 4.1] Value :0->17 */
 
 } nfapi_nr_dl_dci_pdu_t;
 
-//table 3-36
-typedef struct
-{
-  uint16_t bwp_size;//Bandwidth part size [TS38.213 sec12]. Number of contiguous PRBs allocated to the BWP Value: 1->275
-  uint16_t bwp_start;//bandwidth part start RB index from reference CRB [TS38.213 sec 12] Value: 0->274
-  uint8_t  subcarrier_spacing;//subcarrierSpacing [TS38.211 sec 4.2] Value:0->4
-  uint8_t  cyclic_prefix;//Cyclic prefix type [TS38.211 sec 4.2] 0: Normal; 1: Extended
-  //Coreset [TS38.211 sec 7.3.2.2]
-  uint8_t start_symbol_index;//Starting OFDM symbol for the CORESET Value: 0->13
-  uint8_t duration_symbols;/* Contiguous time duration of the CORESET in number of symbols. Corresponds to L1 parameter 𝑁𝑠𝑦𝑚𝑏 𝐶𝑂𝑅𝐸𝑆𝐸𝑇 [TS38.211 sec 7.3.2.2] Value: 1,2,3*/
-  uint8_t freq_domain_resource[6];/* Frequency domain resources. This is a bitmap defining non-overlapping groups of 6 PRBs in ascending order. [TS38.213 10.1]. Also, corresponds to L1 parameter N^{CORESET}_{RB} [TS38.211 sec 7.3.2.2]
-  Bitmap of uint8 array. 45 bits.*/
-  uint8_t cce_reg_mapping_type;/*CORESET-CCE-to-REG-mapping-type [TS38.211 sec 7.3.2.2] 0: non-interleaved 1: interleaved */
-  uint8_t reg_bundle_size;/*The number of REGs in a bundle. Must be 6 for
-cceRegMappingType = nonInterleaved. For cceRegMappingType = interleaved, must belong to {2,6} if duration = 1,2 and must belong to {3,6} if
-duration = 3. Corresponds to parameter L. [TS38.211 sec 7.3.2.2] Value: 2,3,6 */
-  uint8_t interleaver_size;//The interleaver size. For interleaved mapping belongs to {2,3,6} and for non-interleaved mapping is NA. Corresponds to parameter R. [TS38.211 sec 7.3.2.2] Value: 2,3,6
-  uint8_t core_set_type;//[TS38.211 sec 7.3.2.2 and sec 7.4.1.3.2] 0: CORESET is configured by the PBCH or SIB1 (subcarrier 0 of CRB0 for DMRS mapping) 1: otherwise (subcarrier 0 of CORESET)
-  uint16_t shift_index;//[TS38.211 sec 7.3.2.2] Not applicable for non-interleaved mapping. For interleaved mapping and a PDCCH transmitted in a CORESET configured by the PBCH or SIB1 this should be set to phy cell ID. Value: 10 bits Otherwise, for interleaved mapping this is set to 0-> max num of PRBs. Value 0-> 275
-  uint8_t precoder_granularity;//Granularity of precoding [TS38.211 sec 7.3.2.2] 0: sameAsRegBundle 1: allContiguousRBs
-  uint16_t num_dl_dci;//Number of DCIs in this CORESET. Value: 0->MaxDciPerSlot
-  nfapi_nr_dl_dci_pdu_t* dl_dci_list;
-
-} nfapi_nr_pdcch_pdu_t;
+typedef struct {
+  /// Number of PRGs spanning this allocation. Value : 1->275
+  uint16_t numPRGs;
+  /// Size in RBs of a precoding resource block group (PRG) – to which same precoding and digital beamforming gets applied. Value: 1->275
+  uint16_t prgSize;
+  /// Number of STD ant ports (parallel streams) feeding into the digBF Value: 0->255
+  uint8_t digBFInterfaces;
+  uint16_t PMIdx[275];
+  uint16_t *beamIdx[275];
+} nr_beamforming_t;
+
+#define MAX_DCI_CORESET 8
+#define DCI_PAYLOAD_BYTE_LEN 8
 
-//for pdsch_pdu:
+typedef struct {
+  ///Bandwidth part size [TS38.213 sec12]. Number of contiguous PRBs allocated to the BWP,Value: 1->275
+  uint16_t BWPSize;
+  ///bandwidth part start RB index from reference CRB, [TS38.213 sec 12], Value: 0->274
+  uint16_t BWPStart;
+  ///subcarrierSpacing [TS38.211 sec 4.2], Value:0->4
+  uint8_t SubcarrierSpacing;
+  ///Cyclic prefix type [TS38.211 sec 4.2], 0: Normal; 1: Extended
+  uint8_t CyclicPrefix;
+  ///Starting OFDM symbol for the CORESET, Value: 0->13
+  uint8_t StartSymbolIndex;
+///Contiguous time duration of the CORESET in number of symbols. Corresponds to L1 parameter 𝑁𝑠𝑦𝑚𝑏_𝐶𝑂𝑅𝐸𝑆𝐸𝑇 [TS38.211 sec 7.3.2.2] Value: 1,2,3
+  uint8_t DurationSymbols; 
+  ///Frequency domain resources. This is a bitmap defining non-overlapping groups of 6 PRBs in ascending order. [TS38.213 10.1]. Also, corresponds to L1 parameter CORE SET RB N [TS38.211 sec 7.3.2.2] Bitmap of uint8 array. 45 bits.
+  uint8_t FreqDomainResource[6];
+  ///CORESET-CCE-to-REG-mapping-type [TS38.211 sec 7.3.2.2] 0: non-interleaved 1: interleaved
+  uint8_t CceRegMappingType;
+  ///The number of REGs in a bundle. Must be 6 for cceRegMappingType = nonInterleaved. For cceRegMappingType = interleaved, must belong to {2,6} if duration = 1,2 and must belong to {3,6} if duration = 3. Corresponds to parameter L. [TS38.211 sec 7.3.2.2] Value: 2,3,6
+  uint8_t RegBundleSize;
+  ///The interleaver size. For interleaved mapping belongs to {2,3,6} and for non-interleaved mapping is NA. Corresponds to parameter R. [TS38.211 sec 7.3.2.2] Value: 2,3,6 CoreSetType
+  uint8_t InterleaverSize; 
+  ///[TS38.211 sec 7.3.2.2 and sec 7.4.1.3.2] 0: CORESET is configured by the PBCH or SIB1 (subcarrier 0 of CRB0 for DMRS mapping) 1: otherwise (subcarrier 0 of CORESET)
+  uint8_t CoreSetType;
+  ///[TS38.211 sec 7.3.2.2] Not applicable for non-interleaved mapping. For interleaved mapping and a PDCCH transmitted in a CORESET configured by the PBCH or SIB1 this should be set to phy cell ID. Value: 10 bits Otherwise, for interleaved mapping this is set to 0-> max num of PRBs. Value 0-> 275
+  uint16_t ShiftIndex;
+  ///Granularity of precoding [TS38.211 sec 7.3.2.2] Field Type Description 0: sameAsRegBundle 1: allContiguousRBs
+  uint8_t precoderGranularity;
+  ///Number of DCIs in this CORESET.Value: 0->MaxDciPerSlot
+  uint16_t numDlDci;
+  ///The RNTI used for identifying the UE when receiving the PDU Value: 1 -> 65535.
+  uint16_t RNTI[MAX_DCI_CORESET];
+  ///For a UE-specific search space it equals the higher-layer parameter PDCCH-DMRSScrambling-ID if configured, otherwise it should be set to the phy cell ID. [TS38.211, sec 7.3.2.3] Value: 0->65535
+  uint16_t ScramblingId[MAX_DCI_CORESET];
+  ///For a UE-specific search space where PDCCH-DMRSScrambling- ID is configured This param equals the CRNTI. Otherwise, it should be set to 0. [TS38.211, sec 7.3.2.3] Value: 0 -> 65535 
+  uint16_t ScramblingRNTI[MAX_DCI_CORESET];
+  ///CCE start Index used to send the DCI Value: 0->135
+  uint8_t CceIndex[MAX_DCI_CORESET];
+  ///Aggregation level used [TS38.211, sec 7.3.2.1] Value: 1,2,4,8,16
+  uint8_t AggregationLevel[MAX_DCI_CORESET];
+  ///Precoding and Beamforming structure See Table 3-43
+  nfapi_nr_tx_precoding_and_beamforming_t precodingAndBeamforming[MAX_DCI_CORESET];
+  ///PDCCH power value used for PDCCH Format 1_0 with CRC scrambled by SI-RNTI, PI-RNTI or RA-RNTI. This is ratio of SSB/PBCH EPRE to PDCCH and PDCCH DMRS EPRE [TS38.213, sec 4.1] Value :0->17 Report title: 5G FAPI: PHY API Specification Issue date: 29 June 2019 Version: 222.10.17 68 Field Type Description representing -8 to 8 dB in 1dB steps
+  uint8_t beta_PDCCH_1_0[MAX_DCI_CORESET];
+  ///PDCCH power value used for all other PDCCH Formats. This is ratio of SSB/PBCH block EPRE to PDCCH and PDCCH DMRS EPRE [TS38.214, sec 4.1] Values: 0: -3dB,1: 0dB,2: 3dB,3: 6dB
+  uint8_t   powerControlOffsetSS[MAX_DCI_CORESET];
+///The total DCI length (in bits) including padding bits [TS38.212 sec 7.3.1] Range 0->DCI_PAYLOAD_BTYE_LEN*8
+  uint16_t  PayloadSizeBits[MAX_DCI_CORESET];
+  ///DCI payload, where the actual size is defined by PayloadSizeBits. The bit order is as following bit0-bit7 are mapped to first byte of MSB - LSB  
+  uint8_t  Payload[MAX_DCI_CORESET][DCI_PAYLOAD_BYTE_LEN]; 
+}  nfapi_nr_dl_tti_pdcch_pdu_rel15_t;
 
+typedef struct {
+  uint16_t pduBitmap;
+  uint16_t rnti;
+  uint16_t pduIndex;
+  // BWP  [TS38.213 sec 12]
+  /// Bandwidth part size [TS38.213 sec12]. Number of contiguous PRBs allocated to the BWP, Value: 1->275
+  uint16_t BWPSize;
+  /// bandwidth part start RB index from reference CRB [TS38.213 sec 12],Value: 0->274
+  uint16_t BWPStart;
+  /// subcarrierSpacing [TS38.211 sec 4.2], Value:0->4
+  uint8_t SubcarrierSpacing;
+  /// Cyclic prefix type [TS38.211 sec 4.2], 0: Normal; 1: Extended
+  uint8_t CyclicPrefix;
+  // Codeword information
+  /// Number of code words for this RNTI (UE), Value: 1 -> 2
+  uint8_t NrOfCodewords;
+  /// Target coding rate [TS38.212 sec 5.4.2.1 and 38.214 sec 5.1.3.1]. This is the number of information bits per 1024 coded bits expressed in 0.1 bit units
+  uint16_t targetCodeRate[2]; 
+  /// QAM modulation [TS38.212 sec 5.4.2.1 and 38.214 sec 5.1.3.1], Value: 2,4,6,8
+  uint8_t qamModOrder[2];
+  ///  MCS index [TS38.214, sec 5.1.3.1], should match value sent in DCI Value : 0->31
+  uint8_t mcsIndex[2];
+  /// MCS-Table-PDSCH [TS38.214, sec 5.1.3.1] 0: notqam256, 1: qam256, 2: qam64LowSE
+  uint8_t mcsTable[2];   
+  /// Redundancy version index [TS38.212, Table 5.4.2.1-2 and 38.214, Table 5.1.2.1-2], should match value sent in DCI Value : 0->3
+  uint8_t rvIndex[2];
+  /// Transmit block size (in bytes) [TS38.214 sec 5.1.3.2], Value: 0->65535
+  uint32_t TBSize[2];
+  /// dataScramblingIdentityPdsch [TS38.211, sec 7.3.1.1], It equals the higher-layer parameter Datascrambling-Identity if configured and the RNTI equals the C-RNTI, otherwise L2 needs to set it to physical cell id. Value: 0->65535
+  uint16_t dataScramblingId;
+  /// Number of layers [TS38.211, sec 7.3.1.3]. Value : 1->8
+  uint8_t nrOfLayers;
+  /// PDSCH transmission schemes [TS38.214, sec5.1.1] 0: Up to 8 transmission layers
+  uint8_t transmissionScheme;
+  /// Reference point for PDSCH DMRS "k" - used for tone mapping [TS38.211, sec 7.4.1.1.2] Resource block bundles [TS38.211, sec 7.3.1.6] Value: 0 -> 1 If 0, the 0 reference point for PDSCH DMRS is at Point A [TS38.211 sec 4.4.4.2]. Resource block bundles generated per sub-bullets 2 and 3 in [TS38.211, sec 7.3.1.6]. For sub-bullet 2, the start of bandwidth part must be set to the start of actual bandwidth part +NstartCORESET and the bandwidth of the bandwidth part must be set to the bandwidth of the initial bandwidth part. If 1, the DMRS reference point is at the lowest VRB/PRB of the allocation. Resource block bundles generated per sub-bullets 1 [TS38.211, sec 7.3.1.6]
+  uint8_t refPoint;
+  // DMRS  [TS38.211 sec 7.4.1.1]
+  /// DMRS symbol positions [TS38.211, sec 7.4.1.1.2 and Tables 7.4.1.1.2-3 and 7.4.1.1.2-4] Bitmap occupying the 14 LSBs with: bit 0: first symbol and for each bit 0: no DMRS 1: DMRS
+  uint16_t dlDmrsSymbPos;  
+  /// DL DMRS config type [TS38.211, sec 7.4.1.1.2] 0: type 1,  1: type 2
+  uint8_t dmrsConfigType;
+  /// DL-DMRS-Scrambling-ID [TS38.211, sec 7.4.1.1.2 ] If provided by the higher-layer and the PDSCH is scheduled by PDCCH with CRC scrambled by CRNTI or CS-RNTI, otherwise, L2 should set this to physical cell id. Value: 0->65535
+  uint16_t dlDmrsScramblingId;
+  /// DMRS sequence initialization [TS38.211, sec 7.4.1.1.2]. Should match what is sent in DCI 1_1, otherwise set to 0. Value : 0->1
+  uint8_t SCID;
+  /// Number of DM-RS CDM groups without data [TS38.212 sec 7.3.1.2.2] [TS38.214 Table 4.1-1] it determines the ratio of PDSCH EPRE to DM-RS EPRE. Value: 1->3
+  uint8_t numDmrsCdmGrpsNoData;
+  /// DMRS ports. [TS38.212 7.3.1.2.2] provides description between DCI 1-1 content and DMRS ports. Bitmap occupying the 11 LSBs with: bit 0: antenna port 1000 bit 11: antenna port 1011 and for each bit 0: DMRS port not used 1: DMRS port used
+  uint16_t dmrsPorts;
+  // Pdsch Allocation in frequency domain [TS38.214, sec 5.1.2.2]
+  /// Resource Allocation Type [TS38.214, sec 5.1.2.2] 0: Type 0, 1: Type 1
+  uint8_t resourceAlloc;
+  /// For resource alloc type 0. TS 38.212 V15.0.x, 7.3.1.2.2 bitmap of RBs, 273 rounded up to multiple of 32. This bitmap is in units of VRBs. LSB of byte 0 of the bitmap represents the first RB of the bwp 
+  uint8_t rbBitmap[36];
+  /// For resource allocation type 1. [TS38.214, sec 5.1.2.2.2] The starting resource block within the BWP for this PDSCH. Value: 0->274
+  uint16_t rbStart;
+  /// For resource allocation type 1. [TS38.214, sec 5.1.2.2.2] The number of resource block within for this PDSCH. Value: 1->275
+  uint16_t rbSize;
+  /// VRB-to-PRB-mapping [TS38.211, sec 7.3.1.6] 0: non-interleaved 1: interleaved with RB size 2 2: Interleaved with RB size 4
+  uint8_t VRBtoPRBMapping;
+  // Resource Allocation in time domain [TS38.214, sec 5.1.2.1]
+  /// Start symbol index of PDSCH mapping from the start of the slot, S. [TS38.214, Table 5.1.2.1-1] Value: 0->13
+  uint8_t StartSymbolIndex;
+  /// PDSCH duration in symbols, L [TS38.214, Table 5.1.2.1-1] Value: 1->14
+  uint8_t NrOfSymbols;
+  // PTRS [TS38.214, sec 5.1.6.3]
+  /// PT-RS antenna ports [TS38.214, sec 5.1.6.3] [TS38.211, table 7.4.1.2.2-1] Bitmap occupying the 6 LSBs with: bit 0: antenna port 1000 bit 5: antenna port 1005 and for each bit 0: PTRS port not used 1: PTRS port used
+  uint8_t PTRSPortIndex ;
+  /// PT-RS time density [TS38.214, table 5.1.6.3-1] 0: 1 1: 2 2: 4
+  uint8_t PTRSTimeDensity;
+  /// PT-RS frequency density [TS38.214, table 5.1.6.3-2] 0: 2 1: 4
+  uint8_t PTRSFreqDensity;
+  /// PT-RS resource element offset [TS38.211, table 7.4.1.2.2-1] Value: 0->3
+  uint8_t PTRSReOffset;
+  ///  PT-RS-to-PDSCH EPRE ratio [TS38.214, table 4.1-2] Value :0->3
+  uint8_t nEpreRatioOfPDSCHToPTRS;
+  // Beamforming
+  nfapi_nr_tx_precoding_and_beamforming_t precodingAndBeamforming;
+}nfapi_nr_dl_tti_pdsch_pdu_rel15_t;
+
+
+//for pdsch_pdu:
+/*
 typedef struct
 {
   uint16_t target_code_rate;//
@@ -692,31 +848,32 @@ typedef struct
   uint32_t dl_tb_crc;//TB CRC: to be used in the last CB, applicable only if last CB is present
 
 } nfapi_nr_dlsch_pdu_t;
+*/
 
 //for csi-rs_pdu:
 
 //table 3-39
 typedef struct
 {
-uint16_t bwp_size;//
-uint16_t bwp_start;//
-uint8_t  subcarrier_spacing;//
-uint8_t  cyclic_prefix;//
-uint16_t start_rb;
-uint16_t nr_of_rbs;
-uint8_t  csi_type;//Value: 0:TRS 1:CSI-RS NZP 2:CSI-RS ZP
-uint8_t  row;//Row entry into the CSI Resource location table. [TS38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1] Value: 1-18
-uint16_t freq_domain;//Value: Up to the 12 LSBs, actual size is determined by the Row parameter
-uint8_t  symb_l0;//The time domain location l0 and firstOFDMSymbolInTimeDomain Value: 0->13
-uint8_t  symb_l1;//
-uint8_t  cdm_type;
-uint8_t  freq_density;//The density field, p and comb offset (for dot5).0: dot5 (even RB), 1: dot5 (odd RB), 2: one, 3: three
-uint16_t scramb_id;//ScramblingID of the CSI-RS [TS38.214, sec 5.2.2.3.1] Value: 0->1023
-//tx power info
-uint8_t  power_control_offset;//Ratio of PDSCH EPRE to NZP CSI-RSEPRE Value :0->23 representing -8 to 15 dB in 1dB steps
-uint8_t  power_control_offset_ss;//Ratio of SSB/PBCH block EPRE to NZP CSI-RS EPRES 0: -3dB, 1: 0dB, 2: 3dB, 3: 6dB
-
-} nfapi_nr_csi_rs_pdu_t;
+  uint16_t bwp_size;//
+  uint16_t bwp_start;//
+  uint8_t  subcarrier_spacing;//
+  uint8_t  cyclic_prefix;//
+  uint16_t start_rb;
+  uint16_t nr_of_rbs;
+  uint8_t  csi_type;//Value: 0:TRS 1:CSI-RS NZP 2:CSI-RS ZP
+  uint8_t  row;//Row entry into the CSI Resource location table. [TS38.211, sec 7.4.1.5.3 and table 7.4.1.5.3-1] Value: 1-18
+  uint16_t freq_domain;//Value: Up to the 12 LSBs, actual size is determined by the Row parameter
+  uint8_t  symb_l0;//The time domain location l0 and firstOFDMSymbolInTimeDomain Value: 0->13
+  uint8_t  symb_l1;//
+  uint8_t  cdm_type;
+  uint8_t  freq_density;//The density field, p and comb offset (for dot5).0: dot5 (even RB), 1: dot5 (odd RB), 2: one, 3: three
+  uint16_t scramb_id;//ScramblingID of the CSI-RS [TS38.214, sec 5.2.2.3.1] Value: 0->1023
+  //tx power info
+  uint8_t  power_control_offset;//Ratio of PDSCH EPRE to NZP CSI-RSEPRE Value :0->23 representing -8 to 15 dB in 1dB steps
+  uint8_t  power_control_offset_ss;//Ratio of SSB/PBCH block EPRE to NZP CSI-RS EPRES 0: -3dB, 1: 0dB, 2: 3dB, 3: 6dB
+
+} nfapi_nr_dl_tti_csi_rs_pdu_rel15_t;
 
 //for ssb_pdu: 
 
@@ -743,27 +900,85 @@ typedef struct
 
 } nfapi_nr_bch_payload_t;
 
-typedef struct
-{
-  uint16_t phys_cell_id;//0~1007
-  uint8_t  beta_pss;//PSS EPRE to SSS EPRE in a SS/PBCH block 0 = 0dB 1 = 3dB
-  uint8_t  ssb_block_index;//SS/PBCH block index within a SSB burst set. Required for PBCH DMRS scrambling. Value: 0->63 (Lmax)
-  uint8_t  ssb_subcarrier_offset;//
-  uint16_t ssb_offset_point_a;//Offset of lowest subcarrier of lowest resource block used for SS/PBCH block. Value: 0->2199
-  uint8_t  bch_payload_flag;//A value indicating how the BCH payload is generated. This should match the PARAM/CONFIG TLVs. Value: 0: MAC generates the full PBCH payload, see Table 3-41, where bchPayload has 31 bits 1: PHY generates the timing PBCH bits, see Table 3-41, where the bchPayload has 24 bits 2: PHY generates the full PBCH payload
-  nfapi_nr_bch_payload_t bch_payload;
+typedef struct {
+  /// Physical Cell ID Value 0~>1007
+  uint16_t PhysCellId;
+  ///PSS EPRE to SSS EPRE in a SS/PBCH block 0 = 0dB 1 = 3dB
+  uint8_t  BetaPss;
+  ///SS/PBCH block index within a SSB burst set. Required for PBCH DMRS scrambling. Value: 0->63 (Lmax)
+  uint8_t  SsbBlockIndex;
+  /// ssbSubcarrierOffset or 𝑘𝑆𝑆𝐵 (TS38.211, section 7.4.3.1) Value: 0->31
+  uint8_t  SsbSubcarrierOffset;
+  ///Offset of lowest subcarrier of lowest resource block used for SS/PBCH block. Value: 0->2199
+  uint16_t ssbOffsetPointA;
+  /// A value indicating how the BCH payload is generated. This should match the PARAM/CONFIG TLVs. Value: 0: MAC generates the full PBCH payload, see Table 3-41, where bchPayload has 31 bits 1: PHY generates the timing PBCH bits, see Table 3-41, where the bchPayload has 24 bits 2: PHY generates the full PBCH payload
+  uint8_t  bchPayloadFlag;
+  uint32_t bchPayload;
   nfapi_nr_tx_precoding_and_beamforming_t precoding_and_beamforming;
+} nfapi_nr_dl_tti_ssb_pdu_rel15_t;
+
+typedef struct {
+  nfapi_nr_dl_tti_ssb_pdu_rel15_t ssb_pdu_rel15;
+} nfapi_nr_dl_tti_ssb_pdu;
+
+typedef struct {
+  nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_rs_pdu_rel15;
+} nfapi_nr_dl_tti_csi_rs_pdu;
+
+typedef struct {
+  nfapi_nr_dl_tti_pdsch_pdu_rel15_t pdsch_pdu_rel15;
+} nfapi_nr_dl_tti_pdsch_pdu;
 
-} nfapi_nr_ssb_pdu_t;
+typedef struct {
+  nfapi_nr_dl_tti_pdcch_pdu_rel15_t pdcch_pdu_rel15;
+} nfapi_nr_dl_tti_pdcch_pdu;
+
+typedef struct {
+  uint16_t PDUType;
+  uint16_t PDUSize;
+
+  union {
+  nfapi_nr_dl_tti_pdcch_pdu      pdcch_pdu;
+  nfapi_nr_dl_tti_pdsch_pdu      pdsch_pdu;
+  nfapi_nr_dl_tti_csi_rs_pdu     csi_rs_pdu;
+  nfapi_nr_dl_tti_ssb_pdu        ssb_pdu;
+  };
+} nfapi_nr_dl_tti_request_pdu_t;
+
+#define NFAPI_NR_MAX_DL_TTI_PDUS 32 
+typedef struct {
+  /// Number of PDUs that are included in this message. All PDUs in the message are numbered in order. Value 0 -> 255
+  uint8_t nPDUs;
+  /// Number of UEs in the Group included in this message. Value 0 -> 255
+  uint8_t nGroup;
+  /// List containing PDUs
+  nfapi_nr_dl_tti_request_pdu_t dl_tti_pdu_list[NFAPI_NR_MAX_DL_TTI_PDUS];
+  /// Number of UE in this group. For SU-MIMO, one group includes one UE only. For MU-MIMO, one group includes up to 12 UEs. Value 1 -> 12
+  uint8_t nUe[256];
+  /// This value is an index for number of PDU identified by nPDU in this message Value: 0 -> 255
+  uint8_t PduIdx[256][12];
+} nfapi_nr_dl_tti_request_body_t;
 
+typedef struct {
+  nfapi_p7_message_header_t header;
+  /// System Frame Number (0-1023)
+  uint16_t SFN;
+  /// Slot number (0-319)
+  uint16_t Slot;
+  nfapi_nr_dl_tti_request_body_t dl_tti_request_body;
+  nfapi_vendor_extension_tlv_t vendor_extension;
+} nfapi_nr_dl_tti_request_t;
+
+/*
 typedef struct
 {
-  nfapi_nr_pdcch_pdu_t* pdcch_pdu;
-  nfapi_nr_dlsch_pdu_t* dlsch_pdu;//pdsch_pdu;
-  nfapi_nr_csi_rs_pdu_t* csi_rs_pdu;
-  nfapi_nr_ssb_pdu_t* ssb_pdu;
+  nfapi_nr_dl_tti_pdcch_pdu* pdcch_pdu;
+  nfapi_nr_dl_tti_pdsch_pdu* pdsch_pdu;
+  nfapi_nr_dl_tti_csi_rs_pdu_t* csi_rs_pdu;
+  nfapi_nr_dl_tti_ssb_pdu_t* ssb_pdu;
 } nfapi_nr_dl_pdu_configuration_t;
-
+*/
+  /*
 typedef struct 
 {
   uint16_t pdu_type;//0: PDCCH PDU 1: PDSCH PDU 2: CSI-RS PDU 3: SSB PDU, 
@@ -771,6 +986,7 @@ typedef struct
   nfapi_nr_dl_pdu_configuration_t* dl_pdu_configuration;
 
 } nfapi_nr_dl_tti_request_number_of_pdus_t;
+  
 
 typedef struct 
 {
@@ -795,9 +1011,10 @@ typedef struct {
   nfapi_nr_dl_tti_request_number_of_groups_t* groups_list;
 
 } nfapi_nr_dl_tti_request_t;
+*/
 
 // Section 3.4.3 ul_tti_request
-
+  
 //for prach_pdu:
 typedef struct
 {
@@ -905,10 +1122,10 @@ typedef struct
   uint16_t data_scrambling_id;
   uint8_t  nrOfLayers;
   //DMRS
-  uint8_t  ul_dmrs_symb_pos;
+  uint16_t  ul_dmrs_symb_pos;
   uint8_t  dmrs_config_type;
   uint16_t ul_dmrs_scrambling_id;
-  uint8_t  scid;//
+  uint8_t  scid;
   uint8_t  num_dmrs_cdm_grps_no_data;
   uint16_t dmrs_ports;//DMRS ports. [TS38.212 7.3.1.1.2] provides description between DCI 0-1 content and DMRS ports. Bitmap occupying the 11 LSBs with: bit 0: antenna port 1000 bit 11: antenna port 1011 and for each bit 0: DMRS port not used 1: DMRS port used
   //Pusch Allocation in frequency domain [TS38.214, sec 6.1.2.2]
@@ -1015,6 +1232,13 @@ typedef struct
 
 //
 
+typedef enum {
+  NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE  = 0,
+  NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE  = 1,
+  NFAPI_NR_DL_TTI_CSI_RS_PDU_TYPE = 2,
+  NFAPI_NR_DL_TTI_SSB_PDU_TYPE    = 3,
+} nfapi_nr_dl_tti_pdu_type_e;
+
 typedef enum {
   NFAPI_NR_UL_CONFIG_PRACH_PDU_TYPE=0,
   NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE,
@@ -1050,8 +1274,8 @@ typedef struct
 } nfapi_nr_ul_tti_request_number_of_groups_t;
 
 typedef struct {
-	uint16_t sfn; //0->1023   
-  uint16_t slot;//0->319
+  uint16_t SFN; //0->1023   
+  uint16_t Slot;//0->319
   uint8_t n_pdus;//Number of PDUs that are included in this message. All PDUs in the message are numbered in order. Value 0 -> 255
   uint8_t  rach_present;//Indicates if a RACH PDU will be included in this message. 0: no RACH in this slot 1: RACH in this slot
   uint8_t  n_ulsch;//Number of ULSCH PDUs that are included in this message.
@@ -1059,13 +1283,13 @@ typedef struct {
   uint8_t n_group;//Number of UE Groups included in this message. Value 0 -> 8
   nfapi_nr_ul_tti_request_number_of_pdus_t pdus_list[NFAPI_MAX_NUM_UL_PDU];
   nfapi_nr_ul_tti_request_number_of_groups_t groups_list[NFAPI_MAX_NUM_GROUPS];
-
 } nfapi_nr_ul_tti_request_t;
 
 //3.4.4 ul_dci_request
 
 //table 3-54
 
+/*
 typedef struct 
 {
   uint16_t pdu_type;//0: PDCCH PDU 
@@ -1082,6 +1306,25 @@ typedef struct
   nfapi_nr_ul_dci_request_number_of_pdus_t* pdu_list;
 
 } nfapi_nr_ul_dci_request_t;
+*/
+
+  // normally one PDU per coreset per BWP
+#define NFAPI_NR_MAX_UL_DCI_PDUS 4
+
+typedef struct {
+  /// only possible value 0: PDCCH PDU
+  uint16_t PDUType;
+  ///Size of the PDU control information (in bytes). This length value includes the 4 bytes required for the PDU type and PDU size parameters. Value 0 -> 65535
+  uint16_t PDUSize;
+  nfapi_nr_dl_tti_pdcch_pdu pdcch_pdu;
+} nfapi_nr_ul_dci_request_pdus_t;
+
+typedef struct {
+  uint16_t SFN;
+  uint16_t Slot;
+  uint8_t  numPdus;
+  nfapi_nr_ul_dci_request_pdus_t ul_dci_pdu_list[NFAPI_NR_MAX_UL_DCI_PDUS];
+} nfapi_nr_ul_dci_request_t;
 
 //3.4.5 slot_errors
 typedef enum {
@@ -1098,6 +1341,7 @@ typedef enum {
 
 } nfapi_nr_slot_errors_dl_tti_e;
 
+
 typedef enum {
 	NFAPI_NR_SLOT_UL_DCI_MSG_INVALID_STATE,
   NFAPI_NR_SLOT_UL_DCI_MSG_INVALID_SFN,
@@ -1108,23 +1352,23 @@ typedef enum {
 //3.4.6 tx_data_request
 
 //table 3-58
-
+#define NFAPI_NR_MAX_TX_REQUEST_TLV 2
 typedef struct
 {
-  uint16_t pdu_length;
-  uint16_t pdu_index;
-  uint32_t num_tlv;
-  //! fixme
-  nfapi_int32_tlv_t* tlvs; //nfapi_int32_tlv_t tlvs[num_tlv]
+  uint16_t PDU_length;
+  uint16_t PDU_index;
+  uint32_t num_TLV;
+  nfapi_nr_tx_data_request_tlv_t TLVs[NFAPI_NR_MAX_TX_REQUEST_TLV]; 
 
 } nfapi_nr_pdu_t;
 
+#define NFAPI_NR_MAX_TX_REQUEST_PDUS 16
 typedef struct
 {
-  uint16_t sfn;
-  uint16_t slot;
-  uint16_t number_of_pdus;
-  nfapi_nr_pdu_t* pdu_list;
+  uint16_t SFN;
+  uint16_t Slot;
+  uint16_t Number_of_PDUs;
+  nfapi_nr_pdu_t pdu_list[NFAPI_NR_MAX_TX_REQUEST_PDUS];
 
 } nfapi_nr_tx_data_request_t;
 
diff --git a/nfapi/open-nFAPI/vnf/public_inc/nfapi_vnf_interface.h b/nfapi/open-nFAPI/vnf/public_inc/nfapi_vnf_interface.h
index 5d463afdaea..5abf6b75c39 100644
--- a/nfapi/open-nFAPI/vnf/public_inc/nfapi_vnf_interface.h
+++ b/nfapi/open-nFAPI/vnf/public_inc/nfapi_vnf_interface.h
@@ -18,7 +18,8 @@
 #define _NFAPI_VNF_INTERFACE_H_
 
 #include "nfapi_interface.h"
-#include "nfapi_nr_interface.h"
+#include "nfapi_nr_interface_scf.h"
+
 #include "debug.h"
 
 #include "netinet/in.h"
@@ -938,7 +939,7 @@ int nfapi_vnf_p7_del_pnf(nfapi_vnf_p7_config_t* config, int phy_id);
  *  may be released after this function call has returned or at a later pointer
  */
 int nfapi_vnf_p7_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_dl_config_request_t* req);
-int nfapi_vnf_p7_nr_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_nr_dl_config_request_t* req);
+int nfapi_vnf_p7_nr_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_nr_dl_tti_request_t* req);
 
 /*! Send the UL_CONFIG.request
  *  \param config A pointer to the vnf p7 configuration
diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c
index 8b601224835..35bd5e4c1b8 100644
--- a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c
+++ b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c
@@ -482,7 +482,7 @@ int nfapi_vnf_p7_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_dl_config_re
 	return vnf_p7_pack_and_send_p7_msg(vnf_p7, &req->header);
 }
 
-int nfapi_vnf_p7_nr_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_nr_dl_config_request_t* req)
+int nfapi_vnf_p7_nr_dl_config_req(nfapi_vnf_p7_config_t* config, nfapi_nr_dl_tti_request_t* req)
 {
 	//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s(config:%p req:%p)\n", __FUNCTION__, config, req);
 
diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c
index 3d3e920216e..732cc75d6c1 100644
--- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c
+++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c
@@ -18,6 +18,17 @@
  * For more information about the OpenAirInterface (OAI) Software Alliance:
  *      contact@openairinterface.org
  */
+// add GPU mode (-G 1)
+
+ /*! \file PHY/CODING/TESTBENCH/ldpctest.c
+ * \brief Merge remote-tracking branch 'origin/develop' into NCTU_OpinConnect_LDPC
+ * \author NCTU OpinConnect Terng-Yin Hsu,WEI-YING,LIN
+ * \email tyhsu@cs.nctu.edu.tw
+ * \date 13-05-2020
+ * \version 
+ * \note
+ * \warning
+ */
 
 #include <stdlib.h>
 #include <math.h>
@@ -104,7 +115,8 @@ int test_ldpc(short No_iteration,
               unsigned int *crc_misses,
               time_stats_t *time_optim,
               time_stats_t *time_decoder,
-              n_iter_stats_t *dec_iter)
+              n_iter_stats_t *dec_iter,
+			  short run_cuda)
 {
   //clock initiate
   //time_stats_t time,time_optim,tinput,tprep,tparity,toutput, time_decoder;
@@ -401,15 +413,21 @@ int test_ldpc(short No_iteration,
       // decoder supports BG2, Z=128 & 256
       //esimated_output=ldpc_decoder(channel_output_fixed, block_length, No_iteration, (double)((float)nom_rate/(float)denom_rate));
       ///nrLDPC_decoder(&decParams, channel_output_fixed, estimated_output, NULL);
-#ifdef __NR_LDPC_DECODER_LYC__H__
+//#ifdef __NR_LDPC_DECODER_LYC__H__RUN__
+		if(run_cuda){
+		  printf("run ldpc by cuda\n");
     	  start_meas(time_decoder);
 		  n_iter = nrLDPC_decoder_LYC(&decParams, (int8_t*)channel_output_fixed[j], (int8_t*)estimated_output[j], block_length, time_decoder);
 		  stop_meas(time_decoder);
-#else		  	  
+		}  
+//#else	
+        else{	
+		  printf("run ldpc by cpu\n");
     	  start_meas(time_decoder);
 		  n_iter = nrLDPC_decoder(&decParams, (int8_t*)channel_output_fixed[j], (int8_t*)estimated_output[j], p_nrLDPC_procBuf, p_decoder_profiler);
 		  stop_meas(time_decoder);
-#endif      
+		}  
+//#endif      
       }
 
       //for (i=(Kb+nrows) * Zc-5;i<(Kb+nrows) * Zc;i++)
@@ -512,7 +530,7 @@ int main(int argc, char *argv[])
   unsigned int errors, errors_bit, crc_misses;
   double errors_bit_uncoded;
   short block_length=8448; // decoder supports length: 1201 -> 1280, 2401 -> 2560
-
+  short run_cuda = 0;
   short No_iteration=5;
   int n_segments=1;
   //double rate=0.333;
@@ -534,7 +552,7 @@ int main(int argc, char *argv[])
 
   short BG=0,Zc,Kb;
 
-  while ((c = getopt (argc, argv, "q:r:s:S:l:n:d:i:t:u:h")) != -1)
+  while ((c = getopt (argc, argv, "q:r:s:S:l:n:d:i:t:u:h:G:")) != -1)
     switch (c)
     {
       case 'q':
@@ -544,7 +562,10 @@ int main(int argc, char *argv[])
       case 'r':
         nom_rate = atoi(optarg);
         break;
-
+	  case 'G':
+        run_cuda = atoi(optarg);
+        break;
+		
       case 'd':
         denom_rate = atoi(optarg);
         break;
@@ -576,6 +597,7 @@ int main(int argc, char *argv[])
       case 'u':
         test_uncoded = atoi(optarg);
         break;
+		
 
       case 'h':
             default:
@@ -594,6 +616,7 @@ int main(int argc, char *argv[])
               printf("-t SNR simulation step, Default: 0.1\n");
               printf("-i Max decoder iterations, Default: 5\n");
               printf("-u Set SNR per coded bit, Default: 0\n");
+			  printf("-G set 1 to run cuda for ldpc \n");
               exit(1);
               break;
     }
@@ -603,7 +626,7 @@ int main(int argc, char *argv[])
   printf("block length %d: \n", block_length);
   printf("n_trials %d: \n", n_trials);
   printf("SNR0 %f: \n", SNR0);
-
+  
 
 
 
@@ -677,7 +700,8 @@ int main(int argc, char *argv[])
                                 &crc_misses,
                                 time_optim,
                                 time_decoder,
-                                dec_iter);
+                                dec_iter,
+								run_cuda);
 
     printf("SNR %f, BLER %f (%u/%d)\n", SNR, (float)decoded_errors[i]/(float)n_trials, decoded_errors[i], n_trials);
     printf("SNR %f, BER %f (%u/%d)\n", SNR, (float)errors_bit/(float)n_trials/(float)block_length/(double)n_segments, decoded_errors[i], n_trials);
diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c
index 7fcaa0646ca..806d8de28ce 100644
--- a/openair1/PHY/CODING/TESTBENCH/polartest.c
+++ b/openair1/PHY/CODING/TESTBENCH/polartest.c
@@ -175,7 +175,7 @@ if (logFlag){
   double channelOutput[coderLength];  //add noise
   int16_t channelOutput_int16[coderLength];
 
-  t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level);
+  t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level, 1, NULL);
 
 #ifdef DEBUG_DCI_POLAR_PARAMS
   uint32_t dci_pdu[4];
diff --git a/openair1/PHY/CODING/coding_defs.h b/openair1/PHY/CODING/coding_defs.h
index 540fd3b2635..9b111309cdc 100644
--- a/openair1/PHY/CODING/coding_defs.h
+++ b/openair1/PHY/CODING/coding_defs.h
@@ -481,6 +481,8 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm,
                           uint8_t *w,
                           uint8_t *e,
                           uint8_t C,
+			  uint32_t F,
+			  uint32_t Foffset,
                           uint8_t rvidx,
                           uint32_t E);
 
@@ -493,7 +495,9 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm,
                              uint8_t C,
                              uint8_t rvidx,
                              uint8_t clear,
-                             uint32_t E);
+                             uint32_t E,
+			     uint32_t F,
+			     uint32_t Foffset);
 
 decoder_if_t phy_threegpplte_turbo_decoder;
 decoder_if_t phy_threegpplte_turbo_decoder8;
diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h
index a3d829883dc..db9d6e4119c 100644
--- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h
+++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_cnProc.h
@@ -88,23 +88,29 @@ static inline void nrLDPC_cnProc_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf* p_pr
             // Set of results pointer to correct BN address
             p_cnProcBufResBit = p_cnProcBufRes + (j*bitOffsetInGroup);
 
+            __m256i *pj0 = &p_cnProcBuf[lut_idxCnProcG3[j][0]];
+            __m256i *pj1 = &p_cnProcBuf[lut_idxCnProcG3[j][1]];
+
             // Loop over CNs
             for (i=0; i<M; i++)
             {
                 // Abs and sign of 32 CNs (first BN)
-                ymm0 = p_cnProcBuf[lut_idxCnProcG3[j][0] + i];
+	      //                ymm0 = p_cnProcBuf[lut_idxCnProcG3[j][0] + i];
+	        ymm0 = pj0[i];
                 sgn  = _mm256_sign_epi8(*p_ones, ymm0);
                 min  = _mm256_abs_epi8(ymm0);
 
                 // 32 CNs of second BN
-                ymm0 = p_cnProcBuf[lut_idxCnProcG3[j][1] + i];
+		//  ymm0 = p_cnProcBuf[lut_idxCnProcG3[j][1] + i];
+		ymm0 = pj1[i];
                 min  = _mm256_min_epu8(min, _mm256_abs_epi8(ymm0));
                 sgn  = _mm256_sign_epi8(sgn, ymm0);
 
                 // Store result
                 min = _mm256_min_epu8(min, *p_maxLLR); // 128 in epi8 is -127
-                *p_cnProcBufResBit = _mm256_sign_epi8(min, sgn);
-                p_cnProcBufResBit++;
+                //*p_cnProcBufResBit = _mm256_sign_epi8(min, sgn);
+                //p_cnProcBufResBit++;
+		p_cnProcBufResBit[i]=_mm256_sign_epi8(min, sgn);
             }
         }
     }
diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c
index 442864bb068..dbf671fdfb1 100644
--- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c
+++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c
@@ -31,7 +31,7 @@
 
 #include <stdint.h>
 #include <immintrin.h>
-#include "nrLDPC_defs.h"
+#include "nrLDPCdecoder_defs.h"
 #include "nrLDPC_types.h"
 #include "nrLDPC_init.h"
 #include "nrLDPC_mPass.h"
@@ -39,7 +39,7 @@
 #include "nrLDPC_bnProc.h"
 
 #define NR_LDPC_ENABLE_PARITY_CHECK
-//#define NR_LDPC_PROFILER_DETAIL
+#define NR_LDPC_PROFILER_DETAIL
 
 #ifdef NR_LDPC_DEBUG_MODE
 #include "nrLDPC_tools/nrLDPC_debug.h"
@@ -47,7 +47,7 @@
 
 static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, uint32_t numLLR, t_nrLDPC_lut* p_lut, t_nrLDPC_dec_params* p_decParams, t_nrLDPC_time_stats* p_profiler);
 
-int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, t_nrLDPC_time_stats* p_profiler)
+int32_t nrLDPC_decod(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, t_nrLDPC_procBuf* p_procBuf, t_nrLDPC_time_stats* p_profiler)
 {
     uint32_t numLLR;
     uint32_t numIter = 0;
diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h
deleted file mode 100644
index 4d2401db831..00000000000
--- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The OpenAirInterface Software Alliance licenses this file to You under
- * the OAI Public License, Version 1.1  (the "License"); you may not use this file
- * except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.openairinterface.org/?page_id=698
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *-------------------------------------------------------------------------------
- * For more information about the OpenAirInterface (OAI) Software Alliance:
- *      contact@openairinterface.org
- */
-
-/*!\file nrLDPC_decoder.h
- * \brief Defines the LDPC decoder core prototypes
- * \author Sebastian Wagner (TCL Communications) Email: <mailto:sebastian.wagner@tcl.com>
- * \date 27-03-2018
- * \version 1.0
- * \note
- * \warning
- */
-
-#ifndef __NR_LDPC_DECODER__H__
-#define __NR_LDPC_DECODER__H__
-
-#include "nrLDPC_types.h"
-#include "nrLDPC_init_mem.h"
-
-/**
-   \brief LDPC decoder
-   \param p_decParams LDPC decoder parameters
-   \param p_llr Input LLRs
-   \param p_llrOut Output vector
-   \param p_profiler LDPC profiler statistics
-*/
-int32_t nrLDPC_decoder(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_llrOut, t_nrLDPC_procBuf* p_procBuf, t_nrLDPC_time_stats* p_profiler);
-
-#endif
diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h
deleted file mode 100644
index 940d842550e..00000000000
--- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_defs.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The OpenAirInterface Software Alliance licenses this file to You under
- * the OAI Public License, Version 1.1  (the "License"); you may not use this file
- * except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.openairinterface.org/?page_id=698
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *-------------------------------------------------------------------------------
- * For more information about the OpenAirInterface (OAI) Software Alliance:
- *      contact@openairinterface.org
- */
-
-/*!\file nrLDPC_defs.h
- * \brief Defines all constants and buffers for the LDPC decoder
- * \author Sebastian Wagner (TCL Communications) Email: <mailto:sebastian.wagner@tcl.com>
- * \date 27-03-2018
- * \version 1.0
- * \note
- * \warning
- */
-
-#ifndef __NR_LDPC_DEFS__H__
-#define __NR_LDPC_DEFS__H__
-
-// ==============================================================================
-// DEFINES
-
-/** Maximum lifting size */
-#define NR_LDPC_ZMAX 384
-
-/** Number of columns in BG1 */
-#define NR_LDPC_NCOL_BG1 68
-/** Number of rows in BG1 */
-#define NR_LDPC_NROW_BG1 46
-/** Number of edges/entries in BG1 */
-#define NR_LDPC_NUM_EDGE_BG1 316
-/** Number of check node (CN) groups in BG1
- A CN group is defined by its number of connected bit nodes. */
-#define NR_LDPC_NUM_CN_GROUPS_BG1 9
-/** First column in BG1 that is connected to only a single CN */
-#define NR_LDPC_START_COL_PARITY_BG1 26
-
-/** Number of columns in BG1 for rate 1/3 = 22/(68-2) */
-#define NR_LDPC_NCOL_BG1_R13 NR_LDPC_NCOL_BG1
-/** Number of columns in BG1 for rate 2/3 = 22/(35-2) */
-#define NR_LDPC_NCOL_BG1_R23 35
-/** Number of columns in BG1 for rate 8/9 ~ 22/(27-2) */
-#define NR_LDPC_NCOL_BG1_R89 27
-
-/** Number of bit node (BN) groups in BG1 for rate 1/3
- A BN group is defined by its number of connected CNs. */
-#define NR_LDPC_NUM_BN_GROUPS_BG1_R13 30
-/** Number of bit node (BN) groups in BG1 for rate 2/3 */
-#define NR_LDPC_NUM_BN_GROUPS_BG1_R23 8
-/** Number of bit node (BN) groups in BG1 for rate 8/9 */
-#define NR_LDPC_NUM_BN_GROUPS_BG1_R89 5
-
-/** Number of columns in BG2 */
-#define NR_LDPC_NCOL_BG2 52
-/** Number of rows in BG2 */
-#define NR_LDPC_NROW_BG2 42
-/** Number of edges/entries in BG2 */
-#define NR_LDPC_NUM_EDGE_BG2 197
-/** Number of check node (CN) groups in BG2
- A CN group is defined by its number of connected bit nodes. */
-#define NR_LDPC_NUM_CN_GROUPS_BG2 6
-/** First column in BG2 that is connected to only a single CN */
-#define NR_LDPC_START_COL_PARITY_BG2 14
-
-/** Number of columns in BG2 for rate 1/5 = 10/(52-2) */
-#define NR_LDPC_NCOL_BG2_R15 NR_LDPC_NCOL_BG2
-/** Number of columns in BG2 for rate 1/3 = 10/(32-2) */
-#define NR_LDPC_NCOL_BG2_R13 32
-/** Number of columns in BG2 for rate 2/3 = 10/(17-2) */
-#define NR_LDPC_NCOL_BG2_R23 17
-
-/** Number of bit node (BN) groups in BG2 for rate 1/5
- A BN group is defined by its number of connected CNs. */
-#define NR_LDPC_NUM_BN_GROUPS_BG2_R15 23
-/** Number of bit node (BN) groups in BG2 for rate 1/3 */
-#define NR_LDPC_NUM_BN_GROUPS_BG2_R13 10
-/** Number of bit node (BN) groups in BG2 for rate 2/3 */
-#define NR_LDPC_NUM_BN_GROUPS_BG2_R23  6
-
-/** Worst case size of the CN processing buffer */
-#define NR_LDPC_SIZE_CN_PROC_BUF NR_LDPC_NUM_EDGE_BG1*NR_LDPC_ZMAX
-/** Worst case size of the BN processing buffer */
-#define NR_LDPC_SIZE_BN_PROC_BUF NR_LDPC_NUM_EDGE_BG1*NR_LDPC_ZMAX
-
-/** Maximum number of possible input LLR = NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX */
-#define NR_LDPC_MAX_NUM_LLR 26112
-
-// ==============================================================================
-// GLOBAL CONSTANT VARIABLES
-
-/** Start addresses for the cnProcBuf for each CN group in BG1*/
-static const uint32_t lut_startAddrCnGroups_BG1[NR_LDPC_NUM_CN_GROUPS_BG1] = {0, 1152, 8832, 43392, 61824, 75264, 81408, 88320, 92160};
-/** Start addresses for the cnProcBuf for each CN group in BG2*/
-static const uint32_t lut_startAddrCnGroups_BG2[NR_LDPC_NUM_CN_GROUPS_BG2] = {0, 6912, 37632, 54912, 61824, 67968};
-
-/** Number of BNs of CN group for BG1.
-  E.g. 10 means that there is a CN group where every CN is connected to 10 BNs */
-static const uint8_t lut_numBnInCnGroups_BG1_R13[NR_LDPC_NUM_CN_GROUPS_BG1] = {3, 4,  5, 6, 7, 8, 9, 10, 19};
-/** Number of rows/CNs in every CN group for rate = 1/3 BG1, e.g. 5 rows of CNs connected to 4 BNs */
-static const uint8_t lut_numCnInCnGroups_BG1_R13[NR_LDPC_NUM_CN_GROUPS_BG1] = {1, 5, 18, 8, 5, 2, 2,  1,  4};
-/** Number of rows/CNs in every CN group for rate = 2/3 BG1, e.g. 3 rows of CNs connected to 7 BNs */
-static const uint8_t lut_numCnInCnGroups_BG1_R23[NR_LDPC_NUM_CN_GROUPS_BG1] = {1, 0,  0, 0, 3, 2, 2,  1,  4};
-/** Number of rows/CNs in every CN group for rate = 8/9 BG1, e.g. 4 rows of CNs connected to 19 BNs */
-static const uint8_t lut_numCnInCnGroups_BG1_R89[NR_LDPC_NUM_CN_GROUPS_BG1] = {1, 0,  0, 0, 0, 0, 0,  0,  4};
-
-/** Number of connected BNs for every column in BG1 rate = 1/3, e.g. in first column all BNs are connected to 30 CNs */
-static const uint8_t lut_numEdgesPerBn_BG1_R13[NR_LDPC_START_COL_PARITY_BG1] = {30, 28, 7, 11, 9, 4, 8, 12, 8, 7, 12, 10, 12, 11, 10, 7, 10, 10, 13, 7, 8, 11, 12, 5, 6, 6};
-/** Number of connected BNs for every column in BG1 rate = 2/3, e.g. in first column all BNs are connected to 12 CNs */
-static const uint8_t lut_numEdgesPerBn_BG1_R23[NR_LDPC_START_COL_PARITY_BG1] = {12, 11, 4,  5, 5, 3, 4,  5, 5, 3,  6,  6,  6,  6,  5, 3,  6,  5,  6, 4, 5,  6,  6, 3, 3, 2};
-/** Number of connected BNs for every column in BG1 rate = 8/9, e.g. in first column all BNs are connected to 5 CNs */
-static const uint8_t lut_numEdgesPerBn_BG1_R89[NR_LDPC_START_COL_PARITY_BG1] = {5,   4, 3,  3, 3, 3, 3,  3, 3, 3,  3,  3,  3,  3,  3, 3,  3,  3,  3, 3, 3,  3,  3, 2, 2, 2};
-
-/** Number of BNs of CN group for BG2.
-  E.g. 3 means that there is a CN group where every CN is connected to 3 BNs */
-static const uint8_t lut_numBnInCnGroups_BG2_R15[NR_LDPC_NUM_CN_GROUPS_BG2] = {3,  4, 5, 6, 8, 10};
-/** Number of rows/CNs in every CN group for rate = 1/5 BG2, e.g. 6 rows of CNs connected to 3 BNs */
-static const uint8_t lut_numCnInCnGroups_BG2_R15[NR_LDPC_NUM_CN_GROUPS_BG2] = {6, 20, 9, 3, 2, 2};
-/** Number of rows/CNs in every CN group for rate = 1/3 BG2, e.g. 8 rows of CNs connected to 4 BNs */
-static const uint8_t lut_numCnInCnGroups_BG2_R13[NR_LDPC_NUM_CN_GROUPS_BG2] = {0,  8, 7, 3, 2, 2};
-/** Number of rows/CNs in every CN group for rate = 2/3 BG2, e.g. 1 row of CNs connected to 4 BNs */
-static const uint8_t lut_numCnInCnGroups_BG2_R23[NR_LDPC_NUM_CN_GROUPS_BG2] = {0,  1, 0, 2, 2, 2};
-
-/** Number of connected BNs for every column in BG2 rate = 1/5, e.g. in first column all BNs are connected to 22 CNs */
-static const uint8_t lut_numEdgesPerBn_BG2_R15[NR_LDPC_START_COL_PARITY_BG2] = {22, 23, 10, 5, 5, 14, 7, 13, 6, 8, 9, 16, 9, 12};
-/** Number of connected BNs for every column in BG2 rate = 1/3, e.g. in first column all BNs are connected to 14 CNs */
-static const uint8_t lut_numEdgesPerBn_BG2_R13[NR_LDPC_START_COL_PARITY_BG2] = {14, 16,  2, 4, 4,  6, 6,  8, 6, 6, 6, 13, 5,  7};
-/** Number of connected BNs for every column in BG2 rate = 2/3, e.g. in first column all BNs are connected to 6 CNs */
-static const uint8_t lut_numEdgesPerBn_BG2_R23[NR_LDPC_START_COL_PARITY_BG2] = { 6,  5,  2, 3, 3,  4, 3,  4, 3, 4, 3,  5, 2,  2};
-
-// Number of groups for bit node processing
-/** Number of connected CNs for every column/BN in BG1 for rate = 1/3, Worst case is BG1 with up to 30 CNs connected to one BN
-  E.g. 42 parity BNs connected to single CN */
-                                                                            // BG1: 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
-static const uint8_t lut_numBnInBnGroups_BG1_R13[NR_LDPC_NUM_BN_GROUPS_BG1_R13] = {42, 0, 0, 1, 1, 2, 4, 3, 1, 4, 3, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1};
-/** Number of connected CNs for every column/BN in BG1 for rate = 2/3 */
-static const uint8_t lut_numBnInBnGroups_BG1_R23[NR_LDPC_NUM_BN_GROUPS_BG1_R13] = { 9, 1, 5, 3, 7, 8, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-/** Number of connected CNs for every column/BN in BG1 for rate = 8/9 */
-static const uint8_t lut_numBnInBnGroups_BG1_R89[NR_LDPC_NUM_BN_GROUPS_BG1_R13] = { 1, 3,21, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
-/** Number of connected CNs for every column/BN in BG2 for rate = 1/5, Worst case is BG1 with up to 30 CNs connected to one BN
-  E.g. 38 parity BNs connected to single CN */
-                                                                            // BG2: 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
-static const uint8_t lut_numBnInBnGroups_BG2_R15[NR_LDPC_NUM_BN_GROUPS_BG1_R13] = {38, 0, 0, 0, 2, 1, 1, 1, 2, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0};
-/** Number of connected CNs for every column/BN in BG2 for rate = 1/3 */
-static const uint8_t lut_numBnInBnGroups_BG2_R13[NR_LDPC_NUM_BN_GROUPS_BG1_R13] = {18, 1, 0, 2, 1, 5, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-/** Number of connected CNs for every column/BN in BG2 for rate = 2/3 */
-static const uint8_t lut_numBnInBnGroups_BG2_R23[NR_LDPC_NUM_BN_GROUPS_BG1_R13] = { 3, 3, 5, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
-// Start addresses for the bnProcBuf for each BN group
-// BG1
-/** Start address for every BN group within the BN processing buffer for BG1 rate = 1/3 */
-static const uint32_t lut_startAddrBnGroups_BG1_R13[NR_LDPC_NUM_BN_GROUPS_BG1_R13] = {0, 16128, 17664, 19584, 24192, 34944, 44160, 47616, 62976, 75648, 94080, 99072, 109824};
-/** Start address for every BN group within the BN processing buffer for BG1 rate = 2/3 */
-static const uint32_t lut_startAddrBnGroups_BG1_R23[NR_LDPC_NUM_BN_GROUPS_BG1_R23] = {0, 3456, 4224, 9984, 14592, 28032, 46464, 50688};
-/** Start address for every BN group within the BN processing buffer for BG1 rate = 8/9 */
-static const uint32_t lut_startAddrBnGroups_BG1_R89[NR_LDPC_NUM_BN_GROUPS_BG1_R89] = {0, 384, 2688, 26880, 28416};
-
-/** Start address for every BN group within the LLR processing buffer for BG1 rate = 1/3 */
-static const uint16_t lut_startAddrBnGroupsLlr_BG1_R13[NR_LDPC_NUM_BN_GROUPS_BG1_R13] = {0, 16128, 16512, 16896, 17664, 19200, 20352, 20736, 22272, 23424, 24960, 25344, 25728};
-/** Start address for every BN group within the LLR processing buffer for BG1 rate = 2/3 */
-static const uint16_t lut_startAddrBnGroupsLlr_BG1_R23[NR_LDPC_NUM_BN_GROUPS_BG1_R23] = {0, 3456, 3840, 5760, 6912, 9600, 12672, 13056};
-/** Start address for every BN group within the LLR processing buffer for BG1 rate = 8/9 */
-static const uint16_t lut_startAddrBnGroupsLlr_BG1_R89[NR_LDPC_NUM_BN_GROUPS_BG1_R89] = {0, 384, 1536, 9600, 9984};
-
-// BG2
-/** Start address for every BN group within the BN processing buffer for BG2 rate = 1/5 */
-static const uint32_t lut_startAddrBnGroups_BG2_R15[NR_LDPC_NUM_BN_GROUPS_BG2_R15] = {0, 14592, 18432, 20736, 23424, 26496, 33408, 37248, 41856, 46848, 52224, 58368, 66816};
-/** Start address for every BN group within the BN processing buffer for BG2 rate = 1/3 */
-static const uint32_t lut_startAddrBnGroups_BG2_R13[NR_LDPC_NUM_BN_GROUPS_BG2_R13] = {0, 6912, 7680, 10752, 12672, 24192, 26880, 29952, 34944, 40320};
-/** Start address for every BN group within the BN processing buffer for BG2 rate = 2/3 */
-static const uint32_t lut_startAddrBnGroups_BG2_R23[NR_LDPC_NUM_BN_GROUPS_BG2_R23] = {0, 1152, 3456, 9216, 13824, 17664};
-
-/** Start address for every BN group within the LLR processing buffer for BG2 rate = 1/5 */
-static const uint16_t lut_startAddrBnGroupsLlr_BG2_R15[NR_LDPC_NUM_BN_GROUPS_BG2_R15] = {0, 14592, 15360, 15744, 16128, 16512, 17280, 17664, 18048, 18432, 18816, 19200, 19584};
-/** Start address for every BN group within the LLR processing buffer for BG2 rate = 1/3 */
-static const uint16_t lut_startAddrBnGroupsLlr_BG2_R13[NR_LDPC_NUM_BN_GROUPS_BG2_R13] = {0, 6912, 7296, 8064, 8448, 10368, 10752, 11136, 11520, 11904};
-/** Start address for every BN group within the LLR processing buffer for BG2 rate = 2/3 */
-static const uint16_t lut_startAddrBnGroupsLlr_BG2_R23[NR_LDPC_NUM_BN_GROUPS_BG2_R23] = {0,  1152,  2304,  4224,  5376, 6144};
-
-/** Vector of 32 '1' in int8 for application with AVX2 */
-static const int8_t ones256_epi8[32] __attribute__ ((aligned(32))) = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
-/** Vector of 32 '0' in int8 for application with AVX2 */
-static const int8_t zeros256_epi8[32] __attribute__ ((aligned(32))) = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-/** Vector of 32 '127' in int8 for application with AVX2 */
-static const int8_t maxLLR256_epi8[32] __attribute__ ((aligned(32))) = {127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127};
-
-#endif
diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init.h
index 82462c6d95a..ea031dc2dae 100644
--- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init.h
+++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init.h
@@ -32,7 +32,7 @@
 #define __NR_LDPC_INIT__H__
 
 #include "nrLDPC_lut.h"
-#include "nrLDPC_defs.h"
+#include "nrLDPCdecoder_defs.h"
 
 /**
    \brief Initializes the decoder and sets correct LUTs
diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h
index bdaa118e1f3..3292c0debef 100644
--- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h
+++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_init_mem.h
@@ -32,7 +32,6 @@
 #define __NR_LDPC_INIT_MEM__H__
 
 #include <stdlib.h>
-#include "nrLDPC_defs.h"
 #include "nrLDPC_types.h"
 
 #ifndef malloc32_clear
diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h
index 66715618d05..10b45ac0e78 100644
--- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h
+++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h
@@ -32,7 +32,7 @@
 #define __NR_LDPC_MPASS__H__
 
 #include <string.h>
-#include "nrLDPC_defs.h"
+#include "nrLDPCdecoder_defs.h"
 
 /**
    \brief Circular memcpy
@@ -521,7 +521,6 @@ static inline void nrLDPC_cn2bnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<3; j++)
     {
         p_cnProcBufRes = &cnProcBufRes[lut_startAddrCnGroups[0] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[0]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG3[j][i] + lut_bnPosBnProcBuf_CNG3[j][i]*Z;
@@ -673,7 +672,6 @@ static inline void nrLDPC_cn2bnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<3; j++)
     {
         p_cnProcBufRes = &cnProcBufRes[lut_startAddrCnGroups[0] + j*bitOffsetInGroup];
-
         nrLDPC_inv_circ_memcpy(&bnProcBuf[lut_startAddrBnProcBuf_CNG3[j][0]],p_cnProcBufRes,Z,lut_circShift_CNG3[j][0]);
     }
 
@@ -867,7 +865,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<2; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[0] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[0]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG3[j][i] + lut_bnPosBnProcBuf_CNG3[j][i]*Z;
@@ -884,7 +881,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<3; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[1] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[1]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG4[j][i] + lut_bnPosBnProcBuf_CNG4[j][i]*Z;
@@ -901,7 +897,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<4; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[2] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[2]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG5[j][i] + lut_bnPosBnProcBuf_CNG5[j][i]*Z;
@@ -918,7 +913,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<5; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[3] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[3]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG6[j][i] + lut_bnPosBnProcBuf_CNG6[j][i]*Z;
@@ -931,7 +925,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     // CN group with 8 BNs
 
     bitOffsetInGroup = lut_numCnInCnGroups_BG2_R15[4]*NR_LDPC_ZMAX;
-
     for (j=0; j<8; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[4] + j*bitOffsetInGroup];
@@ -952,7 +945,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<10; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[5] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[5]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG10[j][i] + lut_bnPosBnProcBuf_CNG10[j][i]*Z;
@@ -962,6 +954,7 @@ static inline void nrLDPC_bn2cnProcBuf_BG2(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     }
 }
 
+
 /**
    \brief Copies the values in the BN processing results buffer to their corresponding place in the CN processing buffer for BG1.
    \param p_lut Pointer to decoder LUTs
@@ -1019,10 +1012,9 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
 
     bitOffsetInGroup = lut_numCnInCnGroups_BG1_R13[0]*NR_LDPC_ZMAX;
 
-    for (j=0; j<2; j++)
+    for (j=0;j<2; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[0] + j*bitOffsetInGroup];
-
         nrLDPC_circ_memcpy(p_cnProcBuf, &bnProcBufRes[lut_startAddrBnProcBuf_CNG3[j][0]], Z, lut_circShift_CNG3[j][0]);
     }
 
@@ -1034,7 +1026,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<3; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[1] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[1]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG4[j][i] + lut_bnPosBnProcBuf_CNG4[j][i]*Z;
@@ -1051,7 +1042,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<4; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[2] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[2]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG5[j][i] + lut_bnPosBnProcBuf_CNG5[j][i]*Z;
@@ -1068,7 +1058,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<5; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[3] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[3]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG6[j][i] + lut_bnPosBnProcBuf_CNG6[j][i]*Z;
@@ -1102,7 +1091,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<7; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[5] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[5]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG8[j][i] + lut_bnPosBnProcBuf_CNG8[j][i]*Z;
@@ -1119,7 +1107,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<8; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[6] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[6]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG9[j][i] + lut_bnPosBnProcBuf_CNG9[j][i]*Z;
@@ -1136,7 +1123,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<9; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[7] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[7]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG10[j][i] + lut_bnPosBnProcBuf_CNG10[j][i]*Z;
@@ -1153,7 +1139,6 @@ static inline void nrLDPC_bn2cnProcBuf_BG1(t_nrLDPC_lut* p_lut, t_nrLDPC_procBuf
     for (j=0; j<19; j++)
     {
         p_cnProcBuf = &cnProcBuf[lut_startAddrCnGroups[8] + j*bitOffsetInGroup];
-
         for (i=0; i<lut_numCnInCnGroups[8]; i++)
         {
             idxBn = lut_startAddrBnProcBuf_CNG19[j][i] + lut_bnPosBnProcBuf_CNG19[j][i]*Z;
diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h
index 34322a77805..e5b99246d53 100644
--- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h
+++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h
@@ -32,8 +32,7 @@
 #define __NR_LDPC_TYPES__H__
 
 #include "PHY/TOOLS/time_meas.h"
-#include "nrLDPC_defs.h"
-
+#include "nrLDPCdecoder_defs.h"
 // ==============================================================================
 // TYPES
 
@@ -103,4 +102,6 @@ typedef struct nrLDPC_procBuf {
     int8_t* llrProcBuf; /**< LLR processing buffer */
 } t_nrLDPC_procBuf;
 
+
+
 #endif
diff --git a/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu b/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu
index 1b9ef4f1eb2..e48cee7fb92 100644
--- a/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu
+++ b/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu
@@ -1,13 +1,3 @@
- /*! \file PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu
- * \brief LDPC implementation on Quadro p5000 by NCTU OpinCommect
- * \author NCTU OpinConnect Terng-Yin Hsu/Yu-Chi Liang/Kai-Tai Yang/Yan-Bo Lin 
- * \email tyhsu@cs.nctu.edu.tw
- * \date 13-05-2020
- * \version 
- * \note
- * \warning
- */
-
 #include <stdio.h>
 #include <unistd.h>
 #include <cuda_runtime.h>
diff --git a/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.h b/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.h
index c9eb7855954..5602ccecdd0 100644
--- a/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.h
+++ b/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.h
@@ -4,23 +4,13 @@
 #include "nrLDPC_types.h"
 #include "nrLDPC_init_mem.h"
 
-/*! \file PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.h
- * \brief LDPC implementation on Quadro p5000 by NCTU OpinCommect
- * \author NCTU OpinConnect Terng-Yin Hsu/Yu-Chi Liang/Kai-Tai Yang/Yan-Bo Lin 
- * \email tyhsu@cs.nctu.edu.tw
- * \date 13-05-2020
- * \version 
- * \note
- * \warning
- */
-
-/**
+/***
    \brief LDPC decoder
    \param p_decParams LDPC decoder parameters
    \param p_llr Input LLRs
    \param p_llrOut Output vector
    \param p_profiler LDPC profiler statistics
-*/
+****/
 
 int32_t nrLDPC_decoder_LYC(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out, int block_length, time_stats_t *time_decoder);
 
diff --git a/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_defs.h b/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_defs.h
index 541ab25ea6c..de17d8be07d 100644
--- a/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_defs.h
+++ b/openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_defs.h
@@ -19,16 +19,6 @@
  *      contact@openairinterface.org
  */
 
-/*! \file PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_defs.h
- * \brief LDPC implementation on Quadro p5000 by NCTU OpinCommect
- * \author NCTU OpinConnect Terng-Yin Hsu/Yu-Chi Liang/Kai-Tai Yang/Yan-Bo Lin 
- * \email tyhsu@cs.nctu.edu.tw
- * \date 13-05-2020
- * \version 
- * \note
- * \warning
- */
-
 /*!\file nrLDPC_defs.h
  * \brief Defines all constants and buffers for the LDPC decoder
  * \author Sebastian Wagner (TCL Communications) Email: <mailto:sebastian.wagner@tcl.com>
@@ -36,7 +26,7 @@
  * \version 1.0
  * \note
  * \warning
- */
+* */
 
 #ifndef __NR_LDPC_DEFS__H__
 #define __NR_LDPC_DEFS__H__
diff --git a/openair1/PHY/CODING/nrLDPC_encoder/defs.h b/openair1/PHY/CODING/nrLDPC_encoder/defs.h
deleted file mode 100644
index 85cb852fe50..00000000000
--- a/openair1/PHY/CODING/nrLDPC_encoder/defs.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The OpenAirInterface Software Alliance licenses this file to You under
- * the OAI Public License, Version 1.1  (the "License"); you may not use this file
- * except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.openairinterface.org/?page_id=698
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *-------------------------------------------------------------------------------
- * For more information about the OpenAirInterface (OAI) Software Alliance:
- *      contact@openairinterface.org
- */
-
-/*!\file defs.h
- * \brief LDPC encoder forward declarations
- * \author Florian Kaltenberger, Raymond Knopp, Kien le Trung (Eurecom)
- * \email openair_tech@eurecom.fr
- * \date 27-03-2018
- * \version 1.0
- * \note
- * \warning
- */
-
-#include "PHY/TOOLS/time_meas.h"
-
-/*ldpc_encoder.c*/
-int encode_parity_check_part_orig(unsigned char *c,unsigned char *d, short BG,short Zc,short Kb,short block_length);
-
-/*ldpc_encoder2.c*/
-void encode_parity_check_part_optim(uint8_t *c,uint8_t *d, short BG,short Zc,short Kb);
-int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,int Zc,int Kb,short block_length,short BG,time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput);
-int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_input,int Zc,int Kb,short block_length,short BG,int n_segments,time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput);
-int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **channel_input,int Zc,int Kb,short block_length, short BG, int n_segments,unsigned int macro_num, time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput);
-
-/*ldpc_generate_coefficient.c*/
-int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,int Zc,int Kb,short block_length,short BG,unsigned char gen_code);
-
-/*
-int encode_parity_check_part(unsigned char *c,unsigned char *d, short BG,short Zc,short Kb);
-int encode_parity_check_part_orig(unsigned char *c,unsigned char *d, short BG,short Zc,short Kb,short block_length);
-int ldpc_encoder(unsigned char *test_input,unsigned char *channel_input,short block_length, double rate);
-int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,short block_length,int nom_rate,int denom_rate,unsigned char gen_code);
-int ldpc_encoder_multi_segment(unsigned char **test_input,unsigned char **channel_input,short block_length,double rate,uint8_t n_segments);
-int ldpc_encoder_optim(unsigned char *test_input,unsigned char *channel_input,short block_length,int nom_rate,int denom_rate,time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput);
-int ldpc_encoder_optim_8seg(unsigned char **test_input,unsigned char **channel_input,short block_length,int nom_rate,int denom_rate,int n_segments,time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput);
-*/
diff --git a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder.c b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder.c
index 6ded22d8cab..76f92574bad 100644
--- a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder.c
+++ b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder.c
@@ -37,77 +37,247 @@
 #include <string.h>
 #include <types.h>
 #include "defs.h"
+#include "assertions.h"
+#include "openair1/PHY/CODING/nrLDPC_defs.h"
+#include "ldpc_generate_coefficient.c"
 
-short *choose_generator_matrix(short BG,short Zc);
-extern short no_shift_values_BG1[1012],pointer_shift_values_BG1[1012],no_shift_values_BG2[2109],pointer_shift_values_BG2[2019];
 
-int encode_parity_check_part_orig(unsigned char *c,unsigned char *d, short BG,short Zc,short Kb,short block_length)
+int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,int Zc,int Kb,short block_length, short BG,unsigned char gen_code)
 {
-  short *Gen_shift_values=choose_generator_matrix(BG,Zc);
-  short *no_shift_values, *pointer_shift_values;
-  int no_punctured_columns;
-  short nrows,ncols,rate=3;
-  int i1,i2,i3,i4,i5,temp_prime;
+  unsigned char c[22*384]; //padded input, unpacked, max size
+  unsigned char d[68*384]; //coded output, unpacked, max size
   unsigned char channel_temp,temp;
+  short *Gen_shift_values, *no_shift_values, *pointer_shift_values;
 
+  short nrows = 46;//parity check bits
+  short ncols = 22;//info bits
+
+
+  int i,i1,i2,i3,i4,i5,temp_prime,var;
+  int no_punctured_columns,removed_bit,rate=3;
+  int nind=0;
+  int indlist[1000];
+  int indlist2[1000];
+
+  //determine number of bits in codeword
+  //if (block_length>3840)
+     if (BG==1)
+       {
+         nrows=46; //parity check bits
+         ncols=22; //info bits
+         rate=3;
+       }
+       //else if (block_length<=3840)
+      else if	(BG==2)
+       {
+         //BG=2;
+         nrows=42; //parity check bits
+         ncols=10; // info bits
+         rate=5;
+         }
+
+  Gen_shift_values=choose_generator_matrix(BG,Zc);
+  if (Gen_shift_values==NULL) {
+    printf("ldpc_encoder_orig: could not find generator matrix\n");
+    return(-1);
+  }
+
+  //printf("ldpc_encoder_orig: BG %d, Zc %d, Kb %d\n",BG, Zc, Kb);
+
+  // load base graph of generator matrix
   if (BG==1)
   {
     no_shift_values=(short *) no_shift_values_BG1;
     pointer_shift_values=(short *) pointer_shift_values_BG1;
-      nrows=46; //parity check bits
-      ncols=22; //info bits
-      rate=3;
   }
   else if (BG==2)
   {
     no_shift_values=(short *) no_shift_values_BG2;
     pointer_shift_values=(short *) pointer_shift_values_BG2;
-      nrows=42; //parity check bits
-      ncols=10; //info bits
-      rate=5;
   }
   else {
-    printf("problem with BG\n");
-    return(-1);
+    AssertFatal(0,"BG %d is not supported yet\n",BG);
   }
-
-
+  
   no_punctured_columns=(int)((nrows-2)*Zc+block_length-block_length*rate)/Zc;
+  removed_bit=(nrows-no_punctured_columns-2) * Zc+block_length-(block_length*rate);
+  //printf("%d\n",no_punctured_columns);
+  //printf("%d\n",removed_bit);
+  // unpack input
+  memset(c,0,sizeof(unsigned char) * ncols * Zc);
+  memset(d,0,sizeof(unsigned char) * nrows * Zc);
+
+  for (i=0; i<block_length; i++)
+  {
+    //c[i] = test_input[i/8]<<(i%8);
+    //c[i]=c[i]>>7&1;
+    c[i]=(test_input[i/8]&(128>>(i&7)))>>(7-(i&7));
+  }
 
-  //printf("no_punctured_columns = %d\n",no_punctured_columns);
+  // parity check part
 
-  for (i2=0; i2 < Zc; i2++)
+  if (gen_code==1)
   {
-    //t=Kb*Zc+i2;
+    char fname[100];
+    sprintf(fname,"ldpc_BG%d_Zc%d_byte.c",BG,Zc);
+    FILE *fd=fopen(fname,"w");
+    AssertFatal(fd!=NULL,"cannot open %s\n",fname);
+    sprintf(fname,"ldpc_BG%d_Zc%d_16bit.c",BG,Zc);
+    FILE *fd2=fopen(fname,"w");
+    AssertFatal(fd2!=NULL,"cannot open %s\n",fname);
 
-    //rotate matrix here
-    for (i5=0; i5 < Kb; i5++)
-    {
-      temp = c[i5*Zc];
-      memmove(&c[i5*Zc], &c[i5*Zc+1], (Zc-1)*sizeof(unsigned char));
-      c[i5*Zc+Zc-1] = temp;
+    int shift;
+    char data_type[100];
+    char xor_command[100];
+    int mask;
+
+
+
+
+    fprintf(fd,"#include \"PHY/sse_intrin.h\"\n");
+    fprintf(fd2,"#include \"PHY/sse_intrin.h\"\n");
+
+    if ((Zc&31)==0) {
+      shift=5; // AVX2 - 256-bit SIMD
+      mask=31;
+      strcpy(data_type,"__m256i");
+      strcpy(xor_command,"_mm256_xor_si256");
     }
+    else if ((Zc&15)==0) {
+      shift=4; // SSE4 - 128-bit SIMD
+      mask=15;
+      strcpy(data_type,"__m128i");
+      strcpy(xor_command,"_mm_xor_si128");
 
-    // calculate each row in base graph
-    for (i1=0; i1 < nrows-no_punctured_columns; i1++)
+    }
+    else if ((Zc&7)==0) {
+      shift=3; // MMX  - 64-bit SIMD
+      mask=7;
+      strcpy(data_type,"__m64");
+      strcpy(xor_command,"_mm_xor_si64"); 
+    }
+    else {
+      shift=0;                 // no SIMD
+      mask=0;
+      strcpy(data_type,"uint8_t");
+      strcpy(xor_command,"scalar_xor");
+      fprintf(fd,"#define scalar_xor(a,b) ((a)^(b))\n");
+      fprintf(fd2,"#define scalar_xor(a,b) ((a)^(b))\n");
+    }
+    fprintf(fd,"// generated code for Zc=%d, byte encoding\n",Zc);
+    fprintf(fd2,"// generated code for Zc=%d, 16bit encoding\n",Zc);
+    fprintf(fd,"static inline void ldpc_BG%d_Zc%d_byte(uint8_t *c,uint8_t *d) {\n",BG,Zc);
+    fprintf(fd2,"static inline void ldpc_BG%d_Zc%d_16bit(uint16_t *c,uint16_t *d) {\n",BG,Zc);
+    fprintf(fd,"  %s *csimd=(%s *)c,*dsimd=(%s *)d;\n\n",data_type,data_type,data_type);
+    fprintf(fd2,"  %s *csimd=(%s *)c,*dsimd=(%s *)d;\n\n",data_type,data_type,data_type);
+    fprintf(fd,"  %s *c2,*d2;\n\n",data_type);
+    fprintf(fd2,"  %s *c2,*d2;\n\n",data_type);
+    fprintf(fd,"  int i2;\n");
+    fprintf(fd2,"  int i2;\n");
+    fprintf(fd,"  for (i2=0; i2<%d; i2++) {\n",Zc>>shift);
+    if (shift > 0)
+      fprintf(fd2,"  for (i2=0; i2<%d; i2++) {\n",Zc>>(shift-1));
+    for (i2=0; i2 < 1; i2++)
     {
-      channel_temp=0;
-      for (i3=0; i3 < Kb; i3++)
+      //t=Kb*Zc+i2;
+    
+      // calculate each row in base graph
+     
+
+      fprintf(fd,"     c2=&csimd[i2];\n");
+      fprintf(fd,"     d2=&dsimd[i2];\n");
+      fprintf(fd2,"     c2=&csimd[i2];\n");
+      fprintf(fd2,"     d2=&dsimd[i2];\n");
+
+      for (i1=0; i1 < nrows; i1++)
+
       {
-        temp_prime=i1 * ncols + i3;
+        channel_temp=0;
+        fprintf(fd,"\n//row: %d\n",i1);
+        fprintf(fd2,"\n//row: %d\n",i1);
+	fprintf(fd,"     d2[%d]=",(Zc*i1)>>shift);
+	fprintf(fd2,"     d2[%d]=",(Zc*i1)>>(shift-1));
+
+        nind=0;
 
-        for (i4=0; i4 < no_shift_values[temp_prime]; i4++)
+        for (i3=0; i3 < ncols; i3++)
         {
-          channel_temp = channel_temp ^ c[ i3*Zc + Gen_shift_values[ pointer_shift_values[temp_prime]+i4 ] ];
+          temp_prime=i1 * ncols + i3;
+
+
+	  for (i4=0; i4 < no_shift_values[temp_prime]; i4++)
+	    {
+	          
+	      var=(int)((i3*Zc + (Gen_shift_values[ pointer_shift_values[temp_prime]+i4 ]+1)%Zc)/Zc);
+	      int index =var*2*Zc + (i3*Zc + (Gen_shift_values[ pointer_shift_values[temp_prime]+i4 ]+1)%Zc) % Zc;
+	      
+	      indlist[nind] = ((index&mask)*((2*Zc)>>shift)*Kb)+(index>>shift);
+	      indlist2[nind++] = ((index&(mask>>1))*((2*Zc)>>(shift-1))*Kb)+(index>>(shift-1));
+	      
+	    }
+	  
+
         }
+	for (i4=0;i4<nind-1;i4++) {
+	  fprintf(fd,"%s(c2[%d],",xor_command,indlist[i4]);
+	  fprintf(fd2,"%s(c2[%d],",xor_command,indlist2[i4]);
+	}
+	fprintf(fd,"c2[%d]",indlist[i4]);
+	fprintf(fd2,"c2[%d]",indlist2[i4]);
+	for (i4=0;i4<nind-1;i4++) { fprintf(fd,")"); fprintf(fd2,")"); }
+	fprintf(fd,";\n");
+	fprintf(fd2,";\n");
+
       }
-      d[i2+i1*Zc]=channel_temp;
-      //channel_input[t+i1*Zc]=channel_temp;
+      fprintf(fd,"  }\n}\n");
+      fprintf(fd2,"  }\n}\n");
     }
+    fclose(fd);
+    fclose(fd2);
   }
-  return(0);
-}
+  else if(gen_code==0)
+  {
+    for (i2=0; i2 < Zc; i2++)
+    {
+      //t=Kb*Zc+i2;
 
+      //rotate matrix here
+      for (i5=0; i5 < Kb; i5++)
+      {
+        temp = c[i5*Zc];
+        memmove(&c[i5*Zc], &c[i5*Zc+1], (Zc-1)*sizeof(unsigned char));
+        c[i5*Zc+Zc-1] = temp;
+      }
 
+      // calculate each row in base graph
+      for (i1=0; i1 < nrows-no_punctured_columns; i1++)
+      {
+        channel_temp=0;
+
+        for (i3=0; i3 < Kb; i3++)
+        {
+          temp_prime=i1 * ncols + i3;
+
+          for (i4=0; i4 < no_shift_values[temp_prime]; i4++)
+          {
+            channel_temp = channel_temp ^ c[ i3*Zc + Gen_shift_values[ pointer_shift_values[temp_prime]+i4 ] ];
+          }
+        }
+
+        d[i2+i1*Zc]=channel_temp;
+        //channel_input[t+i1*Zc]=channel_temp;
+      }
+    }
+  }
+
+  // information part and puncture columns
+  memcpy(&channel_input[0], &c[2*Zc], (block_length-2*Zc)*sizeof(unsigned char));
+  memcpy(&channel_input[block_length-2*Zc], &d[0], ((nrows-no_punctured_columns) * Zc-removed_bit)*sizeof(unsigned char));
+  //memcpy(channel_input,c,Kb*Zc*sizeof(unsigned char));
+  return 0;
+}
 
 
+int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc,int Kb,short block_length, short BG, encoder_implemparams_t *impp) {
+  return ldpc_encoder_orig(test_input[0],channel_input[0],Zc,Kb,block_length,BG,impp->gen_code);
+}
\ No newline at end of file
diff --git a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c
index ef207b6cdcd..5ab55514cec 100644
--- a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c
+++ b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c
@@ -487,10 +487,10 @@ int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **cha
 
   
   macro_segment = 8*macro_num;
-  // macro_segment_end = (n_segments > 8*(macro_num+1)) ? 8*(macro_num+1) : n_segments;
-  macro_segment_end = macro_segment + (n_segments > 8 ? 8 : n_segments);
-  ///printf("macro_segment: %d\n", macro_segment);
-  ///printf("macro_segment_end: %d\n", macro_segment_end );
+  macro_segment_end = (n_segments > 8*(macro_num+1)) ? 8*(macro_num+1) : n_segments;
+  //macro_segment_end = macro_segment + (n_segments > 8 ? 8 : n_segments);
+  //printf("macro_segment: %d\n", macro_segment);
+  //printf("macro_segment_end: %d\n", macro_segment_end );
 
 #ifdef __AVX2__
   __m256i shufmask = _mm256_set_epi64x(0x0303030303030303, 0x0202020202020202,0x0101010101010101, 0x0000000000000000);
@@ -564,7 +564,7 @@ int ldpc_encoder_optim_8seg_multi(unsigned char **test_input,unsigned char **cha
   for (i=0; i<block_length>>5; i++) {
     c256 = _mm256_and_si256(_mm256_cmpeq_epi8(_mm256_andnot_si256(_mm256_shuffle_epi8(_mm256_set1_epi32(((uint32_t*)test_input[macro_segment])[i]), shufmask),andmask),zero256),masks[0]);
     //for (j=1; j<n_segments; j++) {
-    for (j=macro_segment+1; j < macro_segment_end; j++) {    
+    for (j=macro_segment+1; j < macro_segment_end; j++) {
       c256 = _mm256_or_si256(_mm256_and_si256(_mm256_cmpeq_epi8(_mm256_andnot_si256(_mm256_shuffle_epi8(_mm256_set1_epi32(((uint32_t*)test_input[j])[i]), shufmask),andmask),zero256),masks[j-macro_segment]),c256);
     }
     ((__m256i *)c)[i] = c256;
diff --git a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c
index 5988c9067d0..3d26a190639 100644
--- a/openair1/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c
+++ b/openair1/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c
@@ -35,9 +35,8 @@
 #include <string.h>
 #include "Gen_shift_value.h"
 #include "assertions.h"
-#include "defs.h"
 
-short *choose_generator_matrix(short BG,short Zc)
+static inline short *choose_generator_matrix(short BG,short Zc)
 {
   short *Gen_shift_values = NULL;
 
@@ -361,237 +360,70 @@ short *choose_generator_matrix(short BG,short Zc)
   return Gen_shift_values;
 }
 
-int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,int Zc,int Kb,short block_length, short BG,unsigned char gen_code)
+static inline int encode_parity_check_part_orig(unsigned char *c,unsigned char *d, short BG,short Zc,short Kb,short block_length)
 {
-  unsigned char c[22*384]; //padded input, unpacked, max size
-  unsigned char d[68*384]; //coded output, unpacked, max size
+  short *Gen_shift_values=choose_generator_matrix(BG,Zc);
+  short *no_shift_values, *pointer_shift_values;
+  int no_punctured_columns;
+  short nrows,ncols,rate=3;
+  int i1,i2,i3,i4,i5,temp_prime;
   unsigned char channel_temp,temp;
-  short *Gen_shift_values, *no_shift_values, *pointer_shift_values;
-
-  short nrows = 46;//parity check bits
-  short ncols = 22;//info bits
-
-
-  int i,i1,i2,i3,i4,i5,temp_prime,var;
-  int no_punctured_columns,removed_bit,rate=3;
-  int nind=0;
-  int indlist[1000];
-  int indlist2[1000];
-
-  //determine number of bits in codeword
-  //if (block_length>3840)
-     if (BG==1)
-       {
-         nrows=46; //parity check bits
-         ncols=22; //info bits
-         rate=3;
-       }
-       //else if (block_length<=3840)
-      else if	(BG==2)
-       {
-         //BG=2;
-         nrows=42; //parity check bits
-         ncols=10; // info bits
-         rate=5;
-         }
-
-  Gen_shift_values=choose_generator_matrix(BG,Zc);
-  if (Gen_shift_values==NULL) {
-    printf("ldpc_encoder_orig: could not find generator matrix\n");
-    return(-1);
-  }
-
-  //printf("ldpc_encoder_orig: BG %d, Zc %d, Kb %d\n",BG, Zc, Kb);
 
-  // load base graph of generator matrix
   if (BG==1)
   {
     no_shift_values=(short *) no_shift_values_BG1;
     pointer_shift_values=(short *) pointer_shift_values_BG1;
+      nrows=46; //parity check bits
+      ncols=22; //info bits
+      rate=3;
   }
   else if (BG==2)
   {
     no_shift_values=(short *) no_shift_values_BG2;
     pointer_shift_values=(short *) pointer_shift_values_BG2;
+      nrows=42; //parity check bits
+      ncols=10; //info bits
+      rate=5;
   }
   else {
-    AssertFatal(0,"BG %d is not supported yet\n",BG);
-  }
-  
-  no_punctured_columns=(int)((nrows-2)*Zc+block_length-block_length*rate)/Zc;
-  removed_bit=(nrows-no_punctured_columns-2) * Zc+block_length-(block_length*rate);
-  //printf("%d\n",no_punctured_columns);
-  //printf("%d\n",removed_bit);
-  // unpack input
-  memset(c,0,sizeof(unsigned char) * ncols * Zc);
-  memset(d,0,sizeof(unsigned char) * nrows * Zc);
-
-  for (i=0; i<block_length; i++)
-  {
-    //c[i] = test_input[i/8]<<(i%8);
-    //c[i]=c[i]>>7&1;
-    c[i]=(test_input[i/8]&(128>>(i&7)))>>(7-(i&7));
+    printf("problem with BG\n");
+    return(-1);
   }
 
-  // parity check part
-
-  if (gen_code==1)
-  {
-    char fname[100];
-    sprintf(fname,"ldpc_BG%d_Zc%d_byte.c",BG,Zc);
-    FILE *fd=fopen(fname,"w");
-    AssertFatal(fd!=NULL,"cannot open %s\n",fname);
-    sprintf(fname,"ldpc_BG%d_Zc%d_16bit.c",BG,Zc);
-    FILE *fd2=fopen(fname,"w");
-    AssertFatal(fd2!=NULL,"cannot open %s\n",fname);
-
-    int shift;
-    char data_type[100];
-    char xor_command[100];
-    int mask;
-
-
 
+  no_punctured_columns=(int)((nrows-2)*Zc+block_length-block_length*rate)/Zc;
 
-    fprintf(fd,"#include \"PHY/sse_intrin.h\"\n");
-    fprintf(fd2,"#include \"PHY/sse_intrin.h\"\n");
+  //printf("no_punctured_columns = %d\n",no_punctured_columns);
 
-    if ((Zc&31)==0) {
-      shift=5; // AVX2 - 256-bit SIMD
-      mask=31;
-      strcpy(data_type,"__m256i");
-      strcpy(xor_command,"_mm256_xor_si256");
-    }
-    else if ((Zc&15)==0) {
-      shift=4; // SSE4 - 128-bit SIMD
-      mask=15;
-      strcpy(data_type,"__m128i");
-      strcpy(xor_command,"_mm_xor_si128");
+  for (i2=0; i2 < Zc; i2++)
+  {
+    //t=Kb*Zc+i2;
 
-    }
-    else if ((Zc&7)==0) {
-      shift=3; // MMX  - 64-bit SIMD
-      mask=7;
-      strcpy(data_type,"__m64");
-      strcpy(xor_command,"_mm_xor_si64"); 
-    }
-    else {
-      shift=0;                 // no SIMD
-      mask=0;
-      strcpy(data_type,"uint8_t");
-      strcpy(xor_command,"scalar_xor");
-      fprintf(fd,"#define scalar_xor(a,b) ((a)^(b))\n");
-      fprintf(fd2,"#define scalar_xor(a,b) ((a)^(b))\n");
-    }
-    fprintf(fd,"// generated code for Zc=%d, byte encoding\n",Zc);
-    fprintf(fd2,"// generated code for Zc=%d, 16bit encoding\n",Zc);
-    fprintf(fd,"static inline void ldpc_BG%d_Zc%d_byte(uint8_t *c,uint8_t *d) {\n",BG,Zc);
-    fprintf(fd2,"static inline void ldpc_BG%d_Zc%d_16bit(uint16_t *c,uint16_t *d) {\n",BG,Zc);
-    fprintf(fd,"  %s *csimd=(%s *)c,*dsimd=(%s *)d;\n\n",data_type,data_type,data_type);
-    fprintf(fd2,"  %s *csimd=(%s *)c,*dsimd=(%s *)d;\n\n",data_type,data_type,data_type);
-    fprintf(fd,"  %s *c2,*d2;\n\n",data_type);
-    fprintf(fd2,"  %s *c2,*d2;\n\n",data_type);
-    fprintf(fd,"  int i2;\n");
-    fprintf(fd2,"  int i2;\n");
-    fprintf(fd,"  for (i2=0; i2<%d; i2++) {\n",Zc>>shift);
-    if (shift > 0)
-      fprintf(fd2,"  for (i2=0; i2<%d; i2++) {\n",Zc>>(shift-1));
-    for (i2=0; i2 < 1; i2++)
+    //rotate matrix here
+    for (i5=0; i5 < Kb; i5++)
     {
-      //t=Kb*Zc+i2;
-    
-      // calculate each row in base graph
-     
-
-      fprintf(fd,"     c2=&csimd[i2];\n");
-      fprintf(fd,"     d2=&dsimd[i2];\n");
-      fprintf(fd2,"     c2=&csimd[i2];\n");
-      fprintf(fd2,"     d2=&dsimd[i2];\n");
-
-      for (i1=0; i1 < nrows; i1++)
-
-      {
-        channel_temp=0;
-        fprintf(fd,"\n//row: %d\n",i1);
-        fprintf(fd2,"\n//row: %d\n",i1);
-	fprintf(fd,"     d2[%d]=",(Zc*i1)>>shift);
-	fprintf(fd2,"     d2[%d]=",(Zc*i1)>>(shift-1));
-
-        nind=0;
-
-        for (i3=0; i3 < ncols; i3++)
-        {
-          temp_prime=i1 * ncols + i3;
-
-
-	  for (i4=0; i4 < no_shift_values[temp_prime]; i4++)
-	    {
-	          
-	      var=(int)((i3*Zc + (Gen_shift_values[ pointer_shift_values[temp_prime]+i4 ]+1)%Zc)/Zc);
-	      int index =var*2*Zc + (i3*Zc + (Gen_shift_values[ pointer_shift_values[temp_prime]+i4 ]+1)%Zc) % Zc;
-	      
-	      indlist[nind] = ((index&mask)*((2*Zc)>>shift)*Kb)+(index>>shift);
-	      indlist2[nind++] = ((index&(mask>>1))*((2*Zc)>>(shift-1))*Kb)+(index>>(shift-1));
-	      
-	    }
-	  
-
-        }
-	for (i4=0;i4<nind-1;i4++) {
-	  fprintf(fd,"%s(c2[%d],",xor_command,indlist[i4]);
-	  fprintf(fd2,"%s(c2[%d],",xor_command,indlist2[i4]);
-	}
-	fprintf(fd,"c2[%d]",indlist[i4]);
-	fprintf(fd2,"c2[%d]",indlist2[i4]);
-	for (i4=0;i4<nind-1;i4++) { fprintf(fd,")"); fprintf(fd2,")"); }
-	fprintf(fd,";\n");
-	fprintf(fd2,";\n");
-
-      }
-      fprintf(fd,"  }\n}\n");
-      fprintf(fd2,"  }\n}\n");
+      temp = c[i5*Zc];
+      memmove(&c[i5*Zc], &c[i5*Zc+1], (Zc-1)*sizeof(unsigned char));
+      c[i5*Zc+Zc-1] = temp;
     }
-    fclose(fd);
-    fclose(fd2);
-  }
-  else if(gen_code==0)
-  {
-    for (i2=0; i2 < Zc; i2++)
-    {
-      //t=Kb*Zc+i2;
-
-      //rotate matrix here
-      for (i5=0; i5 < Kb; i5++)
-      {
-        temp = c[i5*Zc];
-        memmove(&c[i5*Zc], &c[i5*Zc+1], (Zc-1)*sizeof(unsigned char));
-        c[i5*Zc+Zc-1] = temp;
-      }
 
-      // calculate each row in base graph
-      for (i1=0; i1 < nrows-no_punctured_columns; i1++)
+    // calculate each row in base graph
+    for (i1=0; i1 < nrows-no_punctured_columns; i1++)
+    {
+      channel_temp=0;
+      for (i3=0; i3 < Kb; i3++)
       {
-        channel_temp=0;
+        temp_prime=i1 * ncols + i3;
 
-        for (i3=0; i3 < Kb; i3++)
+        for (i4=0; i4 < no_shift_values[temp_prime]; i4++)
         {
-          temp_prime=i1 * ncols + i3;
-
-          for (i4=0; i4 < no_shift_values[temp_prime]; i4++)
-          {
-            channel_temp = channel_temp ^ c[ i3*Zc + Gen_shift_values[ pointer_shift_values[temp_prime]+i4 ] ];
-          }
+          channel_temp = channel_temp ^ c[ i3*Zc + Gen_shift_values[ pointer_shift_values[temp_prime]+i4 ] ];
         }
-
-        d[i2+i1*Zc]=channel_temp;
-        //channel_input[t+i1*Zc]=channel_temp;
       }
+      d[i2+i1*Zc]=channel_temp;
+      //channel_input[t+i1*Zc]=channel_temp;
     }
   }
-
-  // information part and puncture columns
-  memcpy(&channel_input[0], &c[2*Zc], (block_length-2*Zc)*sizeof(unsigned char));
-  memcpy(&channel_input[block_length-2*Zc], &d[0], ((nrows-no_punctured_columns) * Zc-removed_bit)*sizeof(unsigned char));
-  //memcpy(channel_input,c,Kb*Zc*sizeof(unsigned char));
-  return 0;
+  return(0);
 }
+
diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
index a130484c8e2..6e01a05d0f9 100644
--- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
+++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
@@ -187,7 +187,9 @@ void nr_polar_print_polarParams(t_nrPolar_params *polarParams);
 
 t_nrPolar_params *nr_polar_params (int8_t messageType,
                                    uint16_t messageLength,
-                                   uint8_t aggregation_level);
+                                   uint8_t aggregation_level,
+				   int decoder_flag,
+				   t_nrPolar_params **polarList_ext);
 
 uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level);
 
diff --git a/openair1/PHY/CODING/nr_compute_tbs.c b/openair1/PHY/CODING/nr_compute_tbs.c
deleted file mode 100644
index 055f697f41d..00000000000
--- a/openair1/PHY/CODING/nr_compute_tbs.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The OpenAirInterface Software Alliance licenses this file to You under
- * the OAI Public License, Version 1.1  (the "License"); you may not use this file
- * except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.openairinterface.org/?page_id=698
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *-------------------------------------------------------------------------------
- * For more information about the OpenAirInterface (OAI) Software Alliance:
- *      contact@openairinterface.org
- */
-
-/* file: nr_compute_tbs.c
-   purpose: Compute NR TBS
-   author: Hongzhi WANG (TCL)
-*/
-#include "PHY/defs_nr_UE.h"
-#define INDEX_MAX_TBS_TABLE (93)
-
-//Table 5.1.2.2-2
-uint16_t Tbstable_nr[INDEX_MAX_TBS_TABLE] = {24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,208,224,240,256,272,288,304,320,336,352,368,384,408,432,456,480,504,528,552,576,608,640,672,704,736,768,808,848,888,928,984,1032,1064,1128,1160,1192,1224,1256,1288,1320,1352,1416,1480,1544,1608,1672,1736,1800,1864,1928,2024,2088,2152,2216,2280,2408,2472,2536,2600,2664,2728,2792,2856,2976,3104,3240,3368,3496,3624,3752,3824};
-
-uint16_t NPRB_LBRM[7] = {32,66,107,135,162,217,273};
-
-uint32_t nr_compute_tbs(uint16_t Qm,
-                        uint16_t R,
-			uint16_t nb_rb,
-			uint16_t nb_symb_sch,
-			uint16_t nb_dmrs_prb,
-                        uint16_t nb_rb_oh,
-			uint8_t Nl)
-{
-
-    uint16_t nbp_re, nb_re;
-    uint32_t nr_tbs=0;
-    uint32_t Ninfo, Np_info, C;
-    uint8_t n, scale;
-
-    nbp_re = NR_NB_SC_PER_RB * nb_symb_sch - nb_dmrs_prb - nb_rb_oh;
-
-    nb_re = min(156, nbp_re) * nb_rb;
-    
-    scale = (R>1024)?11:10;
-
-    // Intermediate number of information bits
-    Ninfo = (nb_re * R * Qm * Nl)>>scale;
-
-    if (Ninfo <=3824) {
-    	n = max(3, floor(log2(Ninfo)) - 6);
-        Np_info = max(24, (Ninfo>>n)<<n);
-        for (int i=0; i<INDEX_MAX_TBS_TABLE; i++) {
-        	if (Tbstable_nr[i] >= Np_info){
-        		nr_tbs = Tbstable_nr[i];
-        		break;
-        	}
-        }
-    }
-    else {
-    	n = log2(Ninfo-24)-5;
-        Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1<<n)))<<n);
-
-        if (R <= 256) { 
-            C = CEILIDIV((Np_info+24),3816);
-            nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24;
-        }
-        else {
-            if (Np_info > 8424){
-                C = CEILIDIV((Np_info+24),8424);
-                nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24;
-            }
-            else {
-            	nr_tbs = ((CEILIDIV((Np_info+24),8))<<3) - 24;
-            }
-
-        }
-
-    }
-    //printf("Ninfo %d nbp_re %d nb_re %d Qm %d, R %d, tbs %d\n", Ninfo, nbp_re, nb_re, Qm, R, nr_tbs);
-    return nr_tbs;
-}
-
-
-//tbslbrm calculation according to 5.4.2.1 of 38.212
-uint32_t nr_compute_tbslbrm(uint16_t table,
-			    uint16_t nb_rb,
-		            uint8_t Nl,
-                            uint8_t C)
-{
-
-  uint16_t R, nb_re;
-  uint16_t nb_rb_lbrm=0;
-  uint8_t Qm;
-  int i;
-  uint32_t nr_tbs=0;
-  uint32_t Ninfo, Np_info;
-  uint8_t n;
-
-  for (i=0; i<7; i++) {
-      	if (NPRB_LBRM[i] >= nb_rb){
-     		nb_rb_lbrm = NPRB_LBRM[i];
-       		break;
-       	}
-  }
-
-  Qm = ((table == 1)? 8 : 6);
-  R = 948;
-  nb_re = 156 * nb_rb_lbrm;
-
-  // Intermediate number of information bits
-  Ninfo = (nb_re * R * Qm * Nl)>>10;
-
-  if (Ninfo <=3824) {
-    	n = max(3, floor(log2(Ninfo)) - 6);
-        Np_info = max(24, (Ninfo>>n)<<n);
-        for (int i=0; i<INDEX_MAX_TBS_TABLE; i++) {
-        	if (Tbstable_nr[i] >= Np_info){
-        		nr_tbs = Tbstable_nr[i];
-        		break;
-        	}
-        }
-  }
-  else {
-    	n = log2(Ninfo-24)-5;
-        Np_info = max(3840, (ROUNDIDIV((Ninfo-24),(1<<n)))<<n);
-
-        if (R <= 256) { 
-            nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24;
-        }
-        else {
-            if (Np_info > 8424){
-                nr_tbs = (C<<3)*CEILIDIV((Np_info+24),(C<<3)) - 24;
-            }
-            else {
-            	nr_tbs = ((CEILIDIV((Np_info+24),8))<<3) - 24;
-            }
-
-        }
-
-  }
-  return nr_tbs;
-
-}
diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c
index efc78d91fd9..f6a06b3f7fc 100644
--- a/openair1/PHY/CODING/nr_polar_init.c
+++ b/openair1/PHY/CODING/nr_polar_init.c
@@ -40,7 +40,8 @@ static int intcmp(const void *p1,const void *p2) {
 static void nr_polar_init(t_nrPolar_params * *polarParams,
                           int8_t messageType,
                           uint16_t messageLength,
-                          uint8_t aggregation_level) {
+                          uint8_t aggregation_level,
+			  int decoder_flag) {
   t_nrPolar_params *currentPtr = *polarParams;
   uint16_t aggregation_prime = nr_polar_aggregation_prime(aggregation_level);
 
@@ -150,7 +151,7 @@ static void nr_polar_init(t_nrPolar_params * *polarParams,
                                          newPolarInitNode->i_bil,
                                          newPolarInitNode->encoderLength);
     free(J);
-    build_decoder_tree(newPolarInitNode);
+    if (decoder_flag == 1) build_decoder_tree(newPolarInitNode);
     build_polar_tables(newPolarInitNode);
     init_polar_deinterleaver_table(newPolarInitNode);
     //printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes);
@@ -183,10 +184,13 @@ void nr_polar_print_polarParams(t_nrPolar_params *polarParams) {
 
 t_nrPolar_params *nr_polar_params (int8_t messageType,
                                    uint16_t messageLength,
-                                   uint8_t aggregation_level) {
+                                   uint8_t aggregation_level,
+	 		           int decoding_flag,
+				   t_nrPolar_params **polarList_ext) {
   static t_nrPolar_params *polarList = NULL;
-  nr_polar_init(&polarList, messageType,messageLength,aggregation_level);
-  t_nrPolar_params *polarParams=polarList;
+  nr_polar_init(polarList_ext != NULL ? polarList_ext : &polarList, 
+		messageType,messageLength,aggregation_level,decoding_flag);
+  t_nrPolar_params *polarParams=polarList_ext != NULL ? *polarList_ext : polarList;
   const int tag=messageType * messageLength * nr_polar_aggregation_prime(aggregation_level);
 
   while (polarParams != NULL) {
diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c
index 9d50b4678be..0cffc2d8520 100644
--- a/openair1/PHY/CODING/nr_rate_matching.c
+++ b/openair1/PHY/CODING/nr_rate_matching.c
@@ -32,23 +32,281 @@
 
 uint8_t index_k0[2][4] = {{0,17,33,56},{0,13,25,43}};
 
-
 void nr_interleaving_ldpc(uint32_t E, uint8_t Qm, uint8_t *e,uint8_t *f)
 {
   uint32_t EQm;
 
   EQm = E/Qm;
   memset(f,0,E*sizeof(uint8_t));
+  uint8_t *e0,*e1,*e2,*e3,*e4,*e5,*e6,*e7;
+  uint8_t *fp;
+#if 0 //def __AVX2__
+  __m256i tmp0,tmp1,tmp2,tmp0b,tmp1b,tmp3,tmp4,tmp5;
+  __m256i *e0_256,*e1_256,*e2_256,*e3_256,*e4_256,*e5_256,*e6_256,*e7_256;
+
+  __m256i *f_256=(__m256i *)f;
+
+  uint8_t *fp2;
+  switch(Qm) {
+  case 2:
+    e0=e;
+    e1=e0+EQm;
+    e0_256=(__m256i *)e0;
+    e1_256=(__m256i *)e1;
+    for (int k=0,j=0;j<EQm>>5;j++,k+=2) {
+      f_256[k]   = _mm256_unpacklo_epi8(e0_256[j],e1_256[j]);
+      f_256[k+1] = _mm256_unpackhi_epi8(e0_256[j],e1_256[j]); 
+    }
+    break;
+  case 4:
+    e0=e;
+    e1=e0+EQm;
+    e2=e1+EQm;
+    e3=e2+EQm;
+    e0_256=(__m256i *)e0;
+    e1_256=(__m256i *)e1;
+    e2_256=(__m256i *)e2;
+    e3_256=(__m256i *)e3;
+    for (int k=0,j=0;j<EQm>>5;j++,k+=4) {
+      tmp0   = _mm256_unpacklo_epi8(e0_256[j],e1_256[j]); // e0(i) e1(i) e0(i+1) e1(i+1) .... e0(i+15) e1(i+15)
+      tmp1   = _mm256_unpacklo_epi8(e2_256[j],e3_256[j]); // e2(i) e3(i) e2(i+1) e3(i+1) .... e2(i+15) e3(i+15)
+      f_256[k]   = _mm256_unpacklo_epi8(tmp0,tmp1);   // e0(i) e1(i) e2(i) e3(i) ... e0(i+7) e1(i+7) e2(i+7) e3(i+7)
+      f_256[k+1] = _mm256_unpackhi_epi8(tmp0,tmp1);   // e0(i+8) e1(i+8) e2(i+8) e3(i+8) ... e0(i+15) e1(i+15) e2(i+15) e3(i+15)
+      tmp0   = _mm256_unpackhi_epi8(e0_256[j],e1_256[j]); // e0(i+16) e1(i+16) e0(i+17) e1(i+17) .... e0(i+31) e1(i+31)
+      tmp1   = _mm256_unpackhi_epi8(e2_256[j],e3_256[j]); // e2(i+16) e3(i+16) e2(i+17) e3(i+17) .... e2(i+31) e3(i+31)
+      f_256[k+2] = _mm256_unpacklo_epi8(tmp0,tmp1);
+      f_256[k+3] = _mm256_unpackhi_epi8(tmp0,tmp1); 
+    }
+    break;
+  case 6:
+    e0=e;
+    e1=e0+EQm;
+    e2=e1+EQm;
+    e3=e2+EQm;
+    e4=e3+EQm;
+    e5=e4+EQm;
+    e0_256=(__m256i *)e0;
+    e1_256=(__m256i *)e1;
+    e2_256=(__m256i *)e2;
+    e3_256=(__m256i *)e3;
+    e4_256=(__m256i *)e4;
+    e5_256=(__m256i *)e5;
+
+    for (int j=0,k=0;j<EQm>>5;j++,k+=192) {
+      fp  = f+k;
+      fp2 = fp+96;
+
+      tmp0   = _mm256_unpacklo_epi8(e0_256[j],e1_256[j]); // e0(i) e1(i) e0(i+1) e1(i+1) .... e0(i+15) e1(i+15)
+      tmp1   = _mm256_unpacklo_epi8(e2_256[j],e3_256[j]); // e2(i) e3(i) e2(i+1) e3(i+1) .... e2(i+15) e3(i+15)
+      tmp0b  = _mm256_unpacklo_epi16(tmp0,tmp1); // e0(i) e1(i) e2(i) e3(i) ... e0(i+7) e1(i+7) e2(i+7) e3(i+7)
+      tmp1b  = _mm256_unpackhi_epi16(tmp0,tmp1); // e0(i+8) e1(i+8) e2(i+8) e3(i+8) ... e0(i+15) e1(i+15) e2(i+15) e3(i+15)
+      tmp0   = _mm256_unpacklo_epi8(e4_256[j],e5_256[j]); // e4(i) e5(i) e4(i+1) e5(i+1) .... e4(i+15) e5(i+15)
+      *((uint32_t*)fp)      = _mm256_extract_epi32(tmp0b,0);
+      *((uint16_t*)(fp+4))  = _mm256_extract_epi16(tmp0,0);
+      *((uint32_t*)(fp+6))  = _mm256_extract_epi32(tmp0b,1);
+      *((uint16_t*)(fp+10)) = _mm256_extract_epi16(tmp0,1);
+      *((uint32_t*)(fp+12)) = _mm256_extract_epi32(tmp0b,2);
+      *((uint16_t*)(fp+16)) = _mm256_extract_epi16(tmp0,2);
+      *((uint32_t*)(fp+18)) = _mm256_extract_epi32(tmp0b,3);
+      *((uint16_t*)(fp+22)) = _mm256_extract_epi16(tmp0,3);
+      *((uint32_t*)(fp+24)) = _mm256_extract_epi32(tmp0b,4);
+      *((uint16_t*)(fp+26)) = _mm256_extract_epi16(tmp0,4);
+      *((uint32_t*)(fp+30)) = _mm256_extract_epi32(tmp0b,5);
+      *((uint16_t*)(fp+34)) = _mm256_extract_epi16(tmp0,5);
+      *((uint32_t*)(fp+36)) = _mm256_extract_epi32(tmp0,6);
+      *((uint16_t*)(fp+40)) = _mm256_extract_epi16(tmp0,6);
+      *((uint32_t*)(fp+42)) = _mm256_extract_epi32(tmp0b,7);
+      *((uint16_t*)(fp+46)) = _mm256_extract_epi16(tmp0,7);
+
+      *((uint32_t*)(fp+48)) = _mm256_extract_epi32(tmp1b,0);
+      *((uint16_t*)(fp+52)) = _mm256_extract_epi16(tmp0,8);
+      *((uint32_t*)(fp+56)) = _mm256_extract_epi32(tmp1b,1);
+      *((uint16_t*)(fp+60)) = _mm256_extract_epi16(tmp0,9);
+      *((uint32_t*)(fp+62)) = _mm256_extract_epi32(tmp1b,2);
+      *((uint16_t*)(fp+66)) = _mm256_extract_epi16(tmp0,10);
+      *((uint32_t*)(fp+68)) = _mm256_extract_epi32(tmp1b,3);
+      *((uint16_t*)(fp+72)) = _mm256_extract_epi16(tmp0,11);
+      *((uint32_t*)(fp+74)) = _mm256_extract_epi32(tmp1b,4);
+      *((uint16_t*)(fp+76)) = _mm256_extract_epi16(tmp0,12);
+      *((uint32_t*)(fp+80)) = _mm256_extract_epi32(tmp1b,5);
+      *((uint16_t*)(fp+82)) = _mm256_extract_epi16(tmp0,13);
+      *((uint32_t*)(fp+86)) = _mm256_extract_epi32(tmp1b,6);
+      *((uint16_t*)(fp+90)) = _mm256_extract_epi16(tmp0,14);
+      *((uint32_t*)(fp+92)) = _mm256_extract_epi32(tmp1b,7);
+      *((uint16_t*)(fp+94)) = _mm256_extract_epi16(tmp0,15);
+
+      tmp0   = _mm256_unpackhi_epi8(e0_256[j],e1_256[j]); // e0(i+16) e1(i+16) e0(i+17) e1(i+17) .... e0(i+31) e1(i+31)
+      tmp1   = _mm256_unpackhi_epi8(e2_256[j],e3_256[j]); // e2(i+16) e3(i+16) e2(i+17) e3(i+17) .... e2(i+31) e3(i+31)
+      tmp0b  = _mm256_unpacklo_epi16(tmp0,tmp1); // e0(i+16) e1(i+16) e2(i+16) e3(i+16) ... e0(i+23) e1(i+23) e2(i+23) e3(i+23)
+      tmp1b  = _mm256_unpackhi_epi16(tmp0,tmp1); // e0(i+24) e1(i+24) e2(i+24) e3(i+24) ... e0(i+31) e1(i+31) e2(i+31) e3(i+31)
+      tmp0   = _mm256_unpackhi_epi8(e4_256[j],e5_256[j]); // e4(i+16) e5(i+16) e4(i+17) e5(i+17) .... e4(i+31) e5(i+31)
+      *((uint32_t*)fp2)      = _mm256_extract_epi32(tmp0b,0);
+      *((uint16_t*)(fp2+4))  = _mm256_extract_epi16(tmp0,0);
+      *((uint32_t*)(fp2+6))  = _mm256_extract_epi32(tmp0b,1);
+      *((uint16_t*)(fp2+10)) = _mm256_extract_epi16(tmp0,1);
+      *((uint32_t*)(fp2+12)) = _mm256_extract_epi32(tmp0b,2);
+      *((uint16_t*)(fp2+16)) = _mm256_extract_epi16(tmp0,2);
+      *((uint32_t*)(fp2+18)) = _mm256_extract_epi32(tmp0b,3);
+      *((uint16_t*)(fp2+22)) = _mm256_extract_epi16(tmp0,3);
+      *((uint32_t*)(fp2+24)) = _mm256_extract_epi32(tmp0b,4);
+      *((uint16_t*)(fp2+26)) = _mm256_extract_epi16(tmp0,4);
+      *((uint32_t*)(fp2+30)) = _mm256_extract_epi32(tmp0b,5);
+      *((uint16_t*)(fp2+34)) = _mm256_extract_epi16(tmp0,5);
+      *((uint32_t*)(fp2+36)) = _mm256_extract_epi32(tmp0,6);
+      *((uint16_t*)(fp2+40)) = _mm256_extract_epi16(tmp0,6);
+      *((uint32_t*)(fp2+42)) = _mm256_extract_epi32(tmp0b,7);
+      *((uint16_t*)(fp2+46)) = _mm256_extract_epi16(tmp0,7);
+
+      *((uint32_t*)(fp2+48)) = _mm256_extract_epi32(tmp1b,0);
+      *((uint16_t*)(fp2+52)) = _mm256_extract_epi16(tmp0,8);
+      *((uint32_t*)(fp2+56)) = _mm256_extract_epi32(tmp1b,1);
+      *((uint16_t*)(fp2+60)) = _mm256_extract_epi16(tmp0,9);
+      *((uint32_t*)(fp2+62)) = _mm256_extract_epi32(tmp1b,2);
+      *((uint16_t*)(fp2+66)) = _mm256_extract_epi16(tmp0,10);
+      *((uint32_t*)(fp2+68)) = _mm256_extract_epi32(tmp1b,3);
+      *((uint16_t*)(fp2+72)) = _mm256_extract_epi16(tmp0,11);
+      *((uint32_t*)(fp2+74)) = _mm256_extract_epi32(tmp1b,4);
+      *((uint16_t*)(fp2+76)) = _mm256_extract_epi16(tmp0,12);
+      *((uint32_t*)(fp2+80)) = _mm256_extract_epi32(tmp1b,5);
+      *((uint16_t*)(fp2+82)) = _mm256_extract_epi16(tmp0,13);
+      *((uint32_t*)(fp2+86)) = _mm256_extract_epi32(tmp1b,6);
+      *((uint16_t*)(fp2+90)) = _mm256_extract_epi16(tmp0,14);
+      *((uint32_t*)(fp2+92)) = _mm256_extract_epi32(tmp1b,7);
+      *((uint16_t*)(fp2+94)) = _mm256_extract_epi16(tmp0,15);
+    }
+    break;
+  case 8:
+    e0=e;
+    e1=e0+EQm;
+    e2=e1+EQm;
+    e3=e2+EQm;
+    e4=e3+EQm;
+    e5=e4+EQm;
+    e6=e5+EQm;
+    e7=e6+EQm;
+
+    e0_256=(__m256i *)e0;
+    e1_256=(__m256i *)e1;
+    e2_256=(__m256i *)e2;
+    e3_256=(__m256i *)e3;
+    e4_256=(__m256i *)e4;
+    e5_256=(__m256i *)e5;
+    e6_256=(__m256i *)e6;
+    e7_256=(__m256i *)e7;
+    for (int k=0,j=0;j<EQm>>5;j++,k+=8) {
+      tmp0   = _mm256_unpacklo_epi8(e0_256[j],e1_256[j]); // e0(i) e1(i) e0(i+1) e1(i+1) .... e0(i+15) e1(i+15)
+      tmp1   = _mm256_unpacklo_epi8(e2_256[j],e3_256[j]); // e2(i) e3(i) e2(i+1) e3(i+1) .... e2(i+15) e3(i+15)
+      tmp2   = _mm256_unpacklo_epi8(e4_256[j],e5_256[j]); // e4(i) e5(i) e4(i+1) e5(i+1) .... e4(i+15) e5(i+15)
+      tmp3   = _mm256_unpacklo_epi8(e6_256[j],e7_256[j]); // e6(i) e7(i) e6(i+1) e7(i+1) .... e6(i+15) e7(i+15)
+      tmp4   = _mm256_unpacklo_epi16(tmp0,tmp1);  // e0(i) e1(i) e2(i) e3(i) ... e0(i+7) e1(i+7) e2(i+7) e3(i+7)
+      tmp5   = _mm256_unpacklo_epi16(tmp2,tmp3);  // e4(i) e5(i) e6(i) e7(i) ... e4(i+7) e5(i+7) e6(i+7) e7(i+7)
+      f_256[k]   = _mm256_unpacklo_epi16(tmp4,tmp5);  // e0(i) e1(i) e2(i) e3(i) e4(i) e5(i) e6(i) e7(i)... e0(i+3) e1(i+3) e2(i+3) e3(i+3) e4(i+3) e5(i+3) e6(i+3) e7(i+3))
+      f_256[k+1] = _mm256_unpackhi_epi16(tmp4,tmp5);  // e0(i+4) e1(i+4) e2(i+4) e3(i+4) e4(i+4) e5(i+4) e6(i+4) e7(i+4)... e0(i+7) e1(i+7) e2(i+7) e3(i+7) e4(i+7) e5(i+7) e6(i+7) e7(i+7))
+
+      tmp4   = _mm256_unpackhi_epi16(tmp0,tmp1);  // e0(i+8) e1(i+8) e2(i+8) e3(i+8) ... e0(i+15) e1(i+15) e2(i+15) e3(i+15)
+      tmp5   = _mm256_unpackhi_epi16(tmp2,tmp3);  // e4(i+8) e5(i+8) e6(i+8) e7(i+8) ... e4(i+15) e5(i+15) e6(i+15) e7(i+15)
+      f_256[k+2]   = _mm256_unpacklo_epi16(tmp4,tmp5);  // e0(i+8) e1(i+8) e2(i+8) e3(i+8) e4(i+8) e5(i+8) e6(i+8) e7(i+8)... e0(i+11) e1(i+11) e2(i+11) e3(i+11) e4(i+11) e5(i+11) e6(i+11) e7(i+11))
+      f_256[k+3] = _mm256_unpackhi_epi16(tmp4,tmp5);  // e0(i+12) e1(i+12) e2(i+12) e3(i+12) e4(i+12) e5(i+12) e6(i+12) e7(i+12)... e0(i+15) e1(i+15) e2(i+15) e3(i+15) e4(i+15) e5(i+15) e6(i+15) e7(i+15))
+
+      tmp0   = _mm256_unpackhi_epi8(e0_256[j],e1_256[j]); // e0(i+16) e1(i+16) e0(i+17) e1(i+17) .... e0(i+31) e1(i+31)
+      tmp1   = _mm256_unpackhi_epi8(e2_256[j],e3_256[j]); // e2(i+16) e3(i+16) e2(i+17) e3(i+17) .... e2(i+31) e3(i+31)
+      tmp2   = _mm256_unpackhi_epi8(e4_256[j],e5_256[j]); // e4(i+16) e5(i+16) e4(i+17) e5(i+17) .... e4(i+31) e5(i+31)
+      tmp3   = _mm256_unpackhi_epi8(e6_256[j],e7_256[j]); // e6(i+16) e7(i+16) e6(i+17) e7(i+17) .... e6(i+31) e7(i+31)
+      tmp4   = _mm256_unpacklo_epi16(tmp0,tmp1);  // e0(i+!6) e1(i+16) e2(i+16) e3(i+16) ... e0(i+23) e1(i+23) e2(i+23) e3(i+23)
+      tmp5   = _mm256_unpacklo_epi16(tmp2,tmp3);  // e4(i+16) e5(i+16) e6(i+16) e7(i+16) ... e4(i+23) e5(i+23) e6(i+23) e7(i+23)
+      f_256[k+4] = _mm256_unpacklo_epi16(tmp4,tmp5);  // e0(i+16) e1(i+16) e2(i+16) e3(i+16) e4(i+16) e5(i+16) e6(i+16) e7(i+16)... e0(i+19) e1(i+19) e2(i+19) e3(i+19) e4(i+19) e5(i+19) e6(i+19) e7(i+19))
+      f_256[k+5] = _mm256_unpackhi_epi16(tmp4,tmp5);  // e0(i+20) e1(i+20) e2(i+20) e3(i+20) e4(i+20) e5(i+20) e6(i+20) e7(i+20)... e0(i+23) e1(i+23) e2(i+23) e3(i+23) e4(i+23) e5(i+23) e6(i+23) e7(i+23))
+
+      tmp4   = _mm256_unpackhi_epi16(tmp0,tmp1);  // e0(i+24) e1(i+24) e2(i+24) e3(i+24) ... e0(i+31) e1(i+31) e2(i+31) e3(i+31)
+      tmp5   = _mm256_unpackhi_epi16(tmp2,tmp3);  // e4(i+24) e5(i+24) e6(i+24) e7(i+24) ... e4(i+31) e5(i+31) e6(i+31) e7(i+31)
+      f_256[k+6] = _mm256_unpacklo_epi16(tmp4,tmp5);  // e0(i+24) e1(i+24) e2(i+24) e3(i+24) e4(i+24) e5(i+24) e6(i+24) e7(i+24)... e0(i+27) e1(i+27) e2(i+27) e3(i+27) e4(i+27) e5(i+27) e6(i+27) e7(i+27))
+      f_256[k+7] = _mm256_unpackhi_epi16(tmp4,tmp5);  // e0(i+28) e1(i+28) e2(i+28) e3(i+28) e4(i+28) e5(i+28) e6(i+28) e7(i+28)... e0(i+31) e1(i+31) e2(i+31) e3(i+31) e4(i+31) e5(i+31) e6(i+31) e7(i+31))
+    }
+    break;
+  default: AssertFatal(1==0,"Should be here!\n");
+  }
 
-  for (int j = 0; j< EQm; j++){
-	  for (int i = 0; i< Qm; i++){
+#else
+  //original unoptimized loops
+    /*
+    for (int j = 0; j< EQm; j++,j2+=2){
+      for (int i = 0; i< Qm; i++){
 		  f[(i+j*Qm)] = e[(i*EQm + j)];
 	  }
+    }
+    */
+
+  int j2=0;
+  fp=f;
+  switch (Qm) {
+  case 2:
+    e0=e;
+    e1=e0+EQm;
+    for (int j = 0; j< EQm; j++,j2+=2){
+      fp=&f[j2];
+      fp[0] = e0[j];
+      fp[1] = e1[j];
+    }
+    break;
+  case 4:
+    e0=e;
+    e1=e0+EQm;
+    e2=e1+EQm;
+    e3=e2+EQm;
+    for (int j = 0; j< EQm; j++,j2+=4){
+      fp=&f[j2];
+      fp[0] = e0[j];
+      fp[1] = e1[j];
+      fp[2] = e2[j];
+      fp[3] = e3[j];
+    }
+    break;
+  case 6:
+    e0=e;
+    e1=e0+EQm;
+    e2=e1+EQm;
+    e3=e2+EQm;
+    e4=e3+EQm;
+    e5=e4+EQm;
+    fp = f;
+    for (int j = 0; j< EQm; j++){
+      *fp++ = e0[j];
+      *fp++ = e1[j];
+      *fp++ = e2[j];
+      *fp++ = e3[j];
+      *fp++ = e4[j];
+      *fp++ = e5[j];
+    }
+    break;
+  case 8:
+    e0=e;
+    e1=e0+EQm;
+    e2=e1+EQm;
+    e3=e2+EQm;
+    e4=e3+EQm;
+    e5=e4+EQm;
+    e6=e5+EQm;
+    e7=e6+EQm;
+    for (int j = 0; j< EQm; j++,j2+=8){
+      fp=&f[j2];
+      fp[0] = e0[j];
+      fp[1] = e1[j];
+      fp[2] = e2[j];
+      fp[3] = e3[j];
+      fp[4] = e4[j];
+      fp[5] = e5[j];
+      fp[6] = e6[j];
+      fp[7] = e7[j];
+    }
+    break;
+  default: AssertFatal(1==0,"Should never be here!\n");
   }
-
+#endif
 }
 
 
+
+
 void nr_deinterleaving_ldpc(uint32_t E, uint8_t Qm, int16_t *e,int16_t *f)
 {
 
@@ -71,10 +329,12 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm,
                           uint8_t *w,
                           uint8_t *e,
                           uint8_t C,
+			  uint32_t F,
+			  uint32_t Foffset,
                           uint8_t rvidx,
                           uint32_t E)
 {
-  uint32_t Ncb,ind,k,Nref,N;
+  uint32_t Ncb,ind,k=0,Nref,N;
 
   if (C==0) {
     printf("nr_rate_matching: invalid parameters (C %d\n",C);
@@ -94,21 +354,36 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm,
   ind = (index_k0[BG-1][rvidx]*Ncb/N)*Z;
 
 #ifdef RM_DEBUG
-  printf("nr_rate_matching_ldpc: E %d, k0 %d, Ncb %d, rvidx %d\n", E, ind, Ncb, rvidx);
+  printf("nr_rate_matching_ldpc: E %d, F %d, Foffset %d, k0 %d, Ncb %d, rvidx %d\n", E, F, Foffset,ind, Ncb, rvidx);
 #endif
+  AssertFatal(Foffset <= E,"Foffset %d > E %d\n",Foffset,E); 
+  AssertFatal(Foffset <= Ncb,"Foffset %d > Ncb %d\n",Foffset,Ncb); 
 
-  k=0;
+  if (ind >= Foffset && ind < (F+Foffset)) ind = F+Foffset;
 
-  for (; (ind<Ncb)&&(k<E); ind++) {
+  if (ind < Foffset) { // case where we have some bits before the filler and the rest after
+    memcpy((void*)e,(void*)(w+ind),Foffset-ind);
 
-#ifdef RM_DEBUG
-    printf("RM_TX k%d Ind: %d (%d)\n",k,ind,w[ind]);
-#endif
+    if (E + F <= Ncb) { // E+F doesn't contain all coded bits
+      memcpy((void*)(e+Foffset-ind),(void*)(w+Foffset+F-ind),E-Foffset+ind);
+      k=E;
+    }
+    else {
+      memcpy((void*)(e+Foffset-ind),(void*)(w+Foffset+F),Ncb-Foffset-F);
+      k=Ncb-F-ind;
+    }
+  }
+  else {
+    if (E + F <= Ncb-ind) { //E+F doesn't contain all coded bits
+      memcpy((void*)(e+Foffset-ind),(void*)(w+Foffset+F-ind),E-Foffset+ind);
+      k=E;
+    }
+    else {
 
-    if (w[ind] != NR_NULL) e[k++]=w[ind];
+    }
   }
 
-  while(k<E) {
+  while(k<E) { // case where we do repetitions (low mcs)
     for (ind=0; (ind<Ncb)&&(k<E); ind++) {
 
 #ifdef RM_DEBUG
@@ -132,7 +407,9 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm,
                              uint8_t C,
                              uint8_t rvidx,
                              uint8_t clear,
-                             uint32_t E)
+                             uint32_t E,
+			     uint32_t F,
+			     uint32_t Foffset)
 {
   uint32_t Ncb,ind,k,Nref,N;
 
@@ -156,53 +433,60 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm,
   }
 
   ind = (index_k0[BG-1][rvidx]*Ncb/N)*Z;
+  AssertFatal(Foffset <= E,"Foffset %d > E %d\n",Foffset,E); 
+  AssertFatal(Foffset <= Ncb,"Foffset %d > Ncb %d\n",Foffset,Ncb); 
 
 #ifdef RM_DEBUG
   printf("nr_rate_matching_ldpc_rx: Clear %d, E %d, k0 %d, Ncb %d, rvidx %d\n", clear, E, ind, Ncb, rvidx);
 #endif
 
-  if (clear==1)
-    memset(w,0,Ncb*sizeof(int16_t));
+  if (clear==1) memset(w,0,Ncb*sizeof(int16_t));
 
   k=0;
 
-  for (; (ind<Ncb)&&(k<E); ind++) {
-    if (soft_input[ind] != NR_NULL) {
-      w[ind] += soft_input[k++];
+  if (ind < Foffset)
+    for (; (ind<Foffset)&&(k<E); ind++) {
 #ifdef RM_DEBUG
-      printf("RM_RX k%d Ind: %d (%d)\n",k-1,ind,w[ind]);
+      printf("RM_RX k%d Ind %d(before filler): %d (%d)=>",k,ind,w[ind],soft_input[k]);
 #endif
-    }
-
+      w[ind]+=soft_input[k++];
 #ifdef RM_DEBUG
-    else {
-      printf("RM_RX Ind: %d NULL %d\n",ind,nulled);
-      nulled++;
+      printf("%d\n",w[ind]);
+#endif
     }
+  if (ind >= Foffset && ind < Foffset+F) ind=Foffset+F;
 
+  for (; (ind<Ncb)&&(k<E); ind++) {
+#ifdef RM_DEBUG
+    printf("RM_RX k%d Ind %d(after filler) %d (%d)=>",k,ind,w[ind],soft_input[k]);
+#endif
+      w[ind] += soft_input[k++];
+#ifdef RM_DEBUG
+      printf("%d\n",w[ind]);
 #endif
   }
 
-  if (rvidx !=0){
   while(k<E) {
-    for (ind=0; (ind<Ncb)&&(k<E); ind++) {
-      if (soft_input[ind] != NR_NULL) {
-        w[ind] += soft_input[k++];
+    for (ind=0; (ind<Foffset)&&(k<E); ind++) {
 #ifdef RM_DEBUG
-        printf("RM_RX k%d Ind: %d (%d)(soft in %d)\n",k-1,ind,w[ind],soft_input[k-1]);
+      printf("RM_RX k%d Ind %d(before filler) %d(%d)=>",k,ind,w[ind],soft_input[k]);
 #endif
-      }
-
+      w[ind]+=soft_input[k++];
 #ifdef RM_DEBUG
-      else {
-        printf("RM_RX Ind: %d NULL %d\n",ind,nulled);
-        nulled++;
-      }
-
+      printf("%d\n",w[ind]);
+#endif
+    }
+    for (ind=Foffset+F; (ind<Ncb)&&(k<E); ind++) {
+#ifdef RM_DEBUG
+      printf("RM_RX (after filler) k%d Ind: %d (%d)(soft in %d)=>",k,ind,w[ind],soft_input[k]);
+#endif
+      w[ind] += soft_input[k++];
+#ifdef RM_DEBUG
+      printf("%d\n",w[ind]);
 #endif
     }
   }
-  }
+
 
   return 0;
 }
diff --git a/openair1/PHY/CODING/nr_segmentation.c b/openair1/PHY/CODING/nr_segmentation.c
index 90586e24d4a..1d80a83131c 100644
--- a/openair1/PHY/CODING/nr_segmentation.c
+++ b/openair1/PHY/CODING/nr_segmentation.c
@@ -30,13 +30,13 @@
 //#define DEBUG_SEGMENTATION
 
 int32_t nr_segmentation(unsigned char *input_buffer,
-                     unsigned char **output_buffers,
-                     unsigned int B,
-                     unsigned int *C,
-                     unsigned int *K,
-                     unsigned int *Zout, // [hna] Zout is Zc
-                     unsigned int *F,
-                     uint8_t BG)
+                        unsigned char **output_buffers,
+                        unsigned int B,
+                        unsigned int *C,
+                        unsigned int *K,
+                        unsigned int *Zout, // [hna] Zout is Zc
+                        unsigned int *F,
+                        uint8_t BG)
 {
 
   unsigned int L,Bprime,Z,r,Kcb,Kb,k,s,crc,Kprime;
@@ -63,7 +63,7 @@ int32_t nr_segmentation(unsigned char *input_buffer,
 #endif
   }
 
-  if ((*C)>MAX_NUM_DLSCH_SEGMENTS) {
+  if ((*C)>MAX_NUM_NR_DLSCH_SEGMENTS) {
     LOG_E(PHY,"nr_segmentation.c: too many segments %d, B %d, L %d, Bprime %d\n",*C,B,L,Bprime);
     return(-1);
   }
diff --git a/openair1/PHY/INIT/lte_parms.c b/openair1/PHY/INIT/lte_parms.c
index a3ca8421b37..12a5646df65 100644
--- a/openair1/PHY/INIT/lte_parms.c
+++ b/openair1/PHY/INIT/lte_parms.c
@@ -161,6 +161,8 @@ int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,
 
   if (frame_parms->frame_type == TDD) set_S_config(frame_parms);
 
+  frame_parms->samples_per_subframe=frame_parms->samples_per_tti;
+  frame_parms->samples_per_slot=frame_parms->samples_per_tti>>1;
   //  frame_parms->tdd_config=3;
   return(0);
 }
diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c
index f0ad3cbaaec..1c0d5a6acad 100644
--- a/openair1/PHY/INIT/nr_init.c
+++ b/openair1/PHY/INIT/nr_init.c
@@ -31,6 +31,7 @@
 #include "TDD-Config.h"
 #include "MBSFN-SubframeConfigList.h"*/
 #include "openair1/PHY/defs_RU.h"
+#include "openair1/PHY/CODING/nrLDPC_extern.h"
 #include "LAYER2/NR_MAC_gNB/mac_proto.h"
 #include "assertions.h"
 #include <math.h>
@@ -43,34 +44,30 @@
 
 /*
 extern uint32_t from_nrarfcn(int nr_bandP,uint32_t dl_nrarfcn);
-extern int32_t get_nr_uldl_offset(int nr_bandP);*/
+
+extern int32_t get_nr_uldl_offset(int nr_bandP);
 extern openair0_config_t openair0_cfg[MAX_CARDS];
+*/
+
+int l1_north_init_gNB() {
+
+  if (RC.nb_nr_L1_inst > 0 &&  RC.gNB != NULL) {
 
-int l1_north_init_gNB()
-{
-  if (RC.nb_nr_L1_inst > 0 && RC.nb_nr_L1_CC != NULL && RC.gNB != NULL) {
     AssertFatal(RC.nb_nr_L1_inst>0,"nb_nr_L1_inst=%d\n",RC.nb_nr_L1_inst);
-    AssertFatal(RC.nb_nr_L1_CC!=NULL,"nb_nr_L1_CC is null\n");
     AssertFatal(RC.gNB!=NULL,"RC.gNB is null\n");
     LOG_I(PHY,"%s() RC.nb_nr_L1_inst:%d\n", __FUNCTION__, RC.nb_nr_L1_inst);
 
     for (int i=0; i<RC.nb_nr_L1_inst; i++) {
       AssertFatal(RC.gNB[i]!=NULL,"RC.gNB[%d] is null\n",i);
-      AssertFatal(RC.nb_nr_L1_CC[i]>0,"RC.nb_nr_L1_CC[%d]=%d\n",i,RC.nb_nr_L1_CC[i]);
-      LOG_I(PHY,"%s() RC.nb_nr_L1_CC[%d]:%d\n", __FUNCTION__, i,  RC.nb_nr_L1_CC[i]);
-
-      for (int j=0; j<RC.nb_nr_L1_CC[i]; j++) {
-        AssertFatal(RC.gNB[i][j]!=NULL,"RC.gNB[%d][%d] is null\n",i,j);
 
-        if ((RC.gNB[i][j]->if_inst =  NR_IF_Module_init(i))<0) return(-1);
-
-        LOG_I(PHY,"%s() RC.gNB[%d][%d] installing callbacks\n", __FUNCTION__, i,  j);
-        RC.gNB[i][j]->if_inst->NR_PHY_config_req    = nr_phy_config_request;
-        RC.gNB[i][j]->if_inst->NR_Schedule_response = nr_schedule_response;
-      }
+      if ((RC.gNB[i]->if_inst =  NR_IF_Module_init(i))<0) return(-1);
+      
+      LOG_I(PHY,"%s() RC.gNB[%d] installing callbacks\n", __FUNCTION__, i);
+      RC.gNB[i]->if_inst->NR_PHY_config_req = nr_phy_config_request;
+      RC.gNB[i]->if_inst->NR_Schedule_response = nr_schedule_response;
     }
   } else {
-    LOG_I(PHY,"%s() Not installing PHY callbacks - RC.nb_nr_L1_inst:%d RC.nb_nr_L1_CC:%p RC.gNB:%p\n", __FUNCTION__, RC.nb_nr_L1_inst, RC.nb_nr_L1_CC, RC.gNB);
+    LOG_I(PHY,"%s() Not installing PHY callbacks - RC.nb_nr_L1_inst:%d RC.gNB:%p\n", __FUNCTION__, RC.nb_nr_L1_inst, RC.gNB);
   }
 
   return(0);
@@ -82,19 +79,20 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
                     unsigned char abstraction_flag) {
   // shortcuts
   NR_DL_FRAME_PARMS *const fp       = &gNB->frame_parms;
-  nfapi_nr_config_request_t *cfg    = &gNB->gNB_config;
+  nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
   NR_gNB_COMMON *const common_vars  = &gNB->common_vars;
+  NR_gNB_PRACH *const prach_vars   = &gNB->prach_vars;
   NR_gNB_PUSCH **const pusch_vars   = gNB->pusch_vars;
   /*LTE_eNB_SRS *const srs_vars       = gNB->srs_vars;
   LTE_eNB_PRACH *const prach_vars   = &gNB->prach_vars;*/
 
   int i;
+  int Ptx=cfg->carrier_config.num_tx_ant.value;
+  int Prx=cfg->carrier_config.num_rx_ant.value;
 
+  AssertFatal(Ptx>0 && Ptx<9,"Ptx %d is not supported\n",Ptx);
+  AssertFatal(Prx>0 && Prx<9,"Prx %d is not supported\n",Prx);
   LOG_I(PHY,"[gNB %d] %s() About to wait for gNB to be configured\n", gNB->Mod_id, __FUNCTION__);
-  gNB->total_dlsch_bitrate = 0;
-  gNB->total_transmitted_bits = 0;
-  gNB->total_system_throughput = 0;
-  gNB->check_for_MUMIMO_transmissions=0;
 
   while(gNB->configured == 0) usleep(10000);
 
@@ -115,6 +113,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
   LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_gNB][MOD %02"PRIu8"][]\n", gNB->Mod_id);
   crcTableInit();
   init_dfts();
+  load_nrLDPClib();
   // PBCH DMRS gold sequences generation
   nr_init_pbch_dmrs(gNB);
   //PDCCH DMRS init
@@ -132,7 +131,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
     }
   }
 
-  nr_init_pdcch_dmrs(gNB, cfg->sch_config.physical_cell_id.value);
+  nr_init_pdcch_dmrs(gNB, cfg->cell_config.phy_cell_id.value);
   nr_init_pbch_interleaver(gNB->nr_pbch_interleaver);
   //PDSCH DMRS init
   gNB->nr_gold_pdsch_dmrs = (uint32_t ****)malloc16(fp->slots_per_frame*sizeof(uint32_t ***));
@@ -153,39 +152,53 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
     }
   }
 
-  //------------- config PUSCH DMRS parameters(to be updated from RRC)--------------//
-  gNB->dmrs_UplinkConfig.pusch_dmrs_type = pusch_dmrs_type1;
-  gNB->dmrs_UplinkConfig.pusch_dmrs_AdditionalPosition = pusch_dmrs_pos0;
-  gNB->dmrs_UplinkConfig.pusch_maxLength = pusch_len1;
-  //--------------------------------------------------------------------------------//
 
-  nr_init_pdsch_dmrs(gNB, cfg->sch_config.physical_cell_id.value);
+  nr_init_pdsch_dmrs(gNB, cfg->cell_config.phy_cell_id.value);
 
-  // default values until overwritten by RRCConnectionReconfiguration
+  //PUSCH DMRS init
+  gNB->nr_gold_pusch_dmrs = (uint32_t ****)malloc16(2*sizeof(uint32_t ***));
+  uint32_t ****pusch_dmrs = gNB->nr_gold_pusch_dmrs;
 
-  for (i=0;i<MAX_NR_OF_UL_ALLOCATIONS;i++){
-    gNB->pusch_config.pusch_TimeDomainResourceAllocation[i] = (PUSCH_TimeDomainResourceAllocation_t *)malloc16(sizeof(PUSCH_TimeDomainResourceAllocation_t));
-    gNB->pusch_config.pusch_TimeDomainResourceAllocation[i]->mappingType = typeB;
+  for(int nscid=0; nscid<2; nscid++) {
+    pusch_dmrs[nscid] = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t **));
+    AssertFatal(pusch_dmrs[nscid]!=NULL, "NR init: pusch_dmrs for nscid %d - malloc failed\n", nscid);
+
+    for (int slot=0; slot<fp->slots_per_frame; slot++) {
+      pusch_dmrs[nscid][slot] = (uint32_t **)malloc16(fp->symbols_per_slot*sizeof(uint32_t *));
+      AssertFatal(pusch_dmrs[nscid][slot]!=NULL, "NR init: pusch_dmrs for slot %d - malloc failed\n", slot);
+
+      for (int symb=0; symb<fp->symbols_per_slot; symb++) {
+        pusch_dmrs[nscid][slot][symb] = (uint32_t *)malloc16(NR_MAX_PUSCH_DMRS_INIT_LENGTH_DWORD*sizeof(uint32_t));
+        AssertFatal(pusch_dmrs[nscid][slot][symb]!=NULL, "NR init: pusch_dmrs for slot %d symbol %d - malloc failed\n", slot, symb);
+      }
+    }
   }
 
+  uint32_t Nid_pusch[2] = {cfg->cell_config.phy_cell_id.value,cfg->cell_config.phy_cell_id.value};
+  nr_gold_pusch(gNB, &Nid_pusch[0]);
+
   /// Transport init necessary for NR synchro
   init_nr_transport(gNB);
 
-  gNB->first_run_I0_measurements = 1; ///This flag used to be static. With multiple gNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here.
-  common_vars->rxdata  = (int32_t **)malloc16(15*sizeof(int32_t*));
-  common_vars->txdataF = (int32_t **)malloc16(15*sizeof(int32_t*));
-  common_vars->rxdataF = (int32_t **)malloc16(15*sizeof(int32_t*));
+  gNB->first_run_I0_measurements = 1;
 
-  for (i=0;i<15;i++){
-      common_vars->txdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t)); // [hna] samples_per_frame without CP
-      common_vars->rxdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t));
-      common_vars->rxdata[i] = (int32_t*)malloc16_clear(fp->samples_per_frame*sizeof(int32_t));
+  common_vars->rxdata  = (int32_t **)malloc16(Prx*sizeof(int32_t*));
+  common_vars->txdataF = (int32_t **)malloc16(Ptx*sizeof(int32_t*));
+  common_vars->rxdataF = (int32_t **)malloc16(Prx*sizeof(int32_t*));
 
+  for (i=0;i<Ptx;i++){
+      common_vars->txdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t)); // [hna] samples_per_frame without CP
       LOG_D(PHY,"[INIT] common_vars->txdataF[%d] = %p (%lu bytes)\n",
-            i,common_vars->txdataF[i],
-            fp->samples_per_frame_wCP*sizeof(int32_t));
+	    i,common_vars->txdataF[i],
+	    fp->samples_per_frame_wCP*sizeof(int32_t));
+      
+  }
+  for (i=0;i<Prx;i++){
+    common_vars->rxdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t));
+    common_vars->rxdata[i] = (int32_t*)malloc16_clear(fp->samples_per_frame*sizeof(int32_t));
   }
 
+
   // Channel estimates for SRS
 /*
   for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
@@ -207,112 +220,76 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
   for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
     srs_vars[UE_id].srs = (int32_t *)malloc16_clear(2*fp->ofdm_symbol_size*sizeof(int32_t));
   }
-
+*/
   // PRACH
   prach_vars->prachF = (int16_t *)malloc16_clear( 1024*2*sizeof(int16_t) );
-  // assume maximum of 64 RX antennas for PRACH receiver
-  prach_vars->prach_ifft[0]    = (int32_t **)malloc16_clear(64*sizeof(int32_t *));
-
-  for (i=0; i<64; i++) prach_vars->prach_ifft[0][i]    = (int32_t *)malloc16_clear(1024*2*sizeof(int32_t));
-
-  prach_vars->rxsigF[0]        = (int16_t **)malloc16_clear(64*sizeof(int16_t *));
-*/
-
-  for (int UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
-    //FIXME
-    pusch_vars[UE_id] = (NR_gNB_PUSCH *)malloc16_clear( sizeof(NR_gNB_PUSCH) );
-    pusch_vars[UE_id]->rxdataF_ext           = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
-    pusch_vars[UE_id]->rxdataF_ext2          = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
-    pusch_vars[UE_id]->ul_ch_estimates       = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
-    pusch_vars[UE_id]->ul_ch_estimates_ext   = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
-    pusch_vars[UE_id]->ul_ch_estimates_time  = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
-    pusch_vars[UE_id]->rxdataF_comp          = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
-    pusch_vars[UE_id]->ul_ch_mag0             = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
-    pusch_vars[UE_id]->ul_ch_magb0            = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
-    pusch_vars[UE_id]->ul_ch_mag             = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
-    pusch_vars[UE_id]->ul_ch_magb            = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
-    pusch_vars[UE_id]->rho                   = (int32_t **)malloc16_clear( fp->nb_antennas_rx*sizeof(int32_t*) );
-
-    for (i=0; i<fp->nb_antennas_rx; i++) {
-      // RK 2 times because of output format of FFT!
-      // FIXME We should get rid of this
-      pusch_vars[UE_id]->rxdataF_ext[i]           = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot );
-      pusch_vars[UE_id]->rxdataF_ext2[i]          = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot );
-      pusch_vars[UE_id]->ul_ch_estimates[i]       = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot );
-      pusch_vars[UE_id]->ul_ch_estimates_ext[i]   = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot );
-      pusch_vars[UE_id]->ul_ch_estimates_time[i]  = (int32_t *)malloc16_clear( 2*sizeof(int32_t)*fp->ofdm_symbol_size );
-      pusch_vars[UE_id]->rxdataF_comp[i]          = (int32_t *)malloc16_clear( sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12*fp->symbols_per_slot );
-      pusch_vars[UE_id]->ul_ch_mag0[i]             = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 );
-      pusch_vars[UE_id]->ul_ch_magb0[i]            = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 );
-      pusch_vars[UE_id]->ul_ch_mag[i]             = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 );
-      pusch_vars[UE_id]->ul_ch_magb[i]            = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*cfg->rf_config.ul_carrier_bandwidth.value*12 );
-      pusch_vars[UE_id]->rho[i]                   = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->N_RB_UL*12*7*2) );
+  prach_vars->rxsigF = (int16_t **)malloc16_clear(Prx*sizeof(int16_t*));
+  /* 
+  for (i=0;i<Prx;i++){
+    prach_vars->rxsigF[i] = (int16_t *)malloc16_clear( 1024*2*sizeof(int16_t) );
+  }
+  */
+  prach_vars->prach_ifft       = (int32_t *)malloc16_clear(1024*2*sizeof(int32_t));
+
+  int N_RB_UL = cfg->carrier_config.ul_grid_size[cfg->ssb_config.scs_common.value].value;
+
+  printf("Before ULSCH init : %p\n",gNB->dlsch[0][0]->harq_processes[0]);
+  for (int ULSCH_id=0; ULSCH_id<NUMBER_OF_NR_ULSCH_MAX; ULSCH_id++) {
+    printf("ULSCH_id %d : %p\n",ULSCH_id,gNB->dlsch[0][0]->harq_processes[0]);
+    pusch_vars[ULSCH_id] = (NR_gNB_PUSCH *)malloc16_clear( sizeof(NR_gNB_PUSCH) );
+    pusch_vars[ULSCH_id]->rxdataF_ext           = (int32_t **)malloc16(Prx*sizeof(int32_t *) );
+    pusch_vars[ULSCH_id]->rxdataF_ext2          = (int32_t **)malloc16(Prx*sizeof(int32_t *) );
+    pusch_vars[ULSCH_id]->ul_ch_estimates       = (int32_t **)malloc16(Prx*sizeof(int32_t *) );
+    pusch_vars[ULSCH_id]->ul_ch_estimates_ext   = (int32_t **)malloc16(Prx*sizeof(int32_t *) );
+    pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates     = (int32_t **)malloc16(Prx*sizeof(int32_t *) );
+    pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext = (int32_t **)malloc16(Prx*sizeof(int32_t *) );
+    pusch_vars[ULSCH_id]->ul_ch_estimates_time  = (int32_t **)malloc16(Prx*sizeof(int32_t *) );
+    pusch_vars[ULSCH_id]->rxdataF_comp          = (int32_t **)malloc16(Prx*sizeof(int32_t *) );
+    pusch_vars[ULSCH_id]->ul_ch_mag0             = (int32_t **)malloc16(Prx*sizeof(int32_t *) );
+    pusch_vars[ULSCH_id]->ul_ch_magb0            = (int32_t **)malloc16(Prx*sizeof(int32_t *) );
+    pusch_vars[ULSCH_id]->ul_ch_mag             = (int32_t **)malloc16(Prx*sizeof(int32_t *) );
+    pusch_vars[ULSCH_id]->ul_ch_magb            = (int32_t **)malloc16(Prx*sizeof(int32_t *) );
+    pusch_vars[ULSCH_id]->rho                   = (int32_t **)malloc16_clear(Prx*sizeof(int32_t*) );
+
+    printf("ULSCH_id %d (before rx antenna alloc) : %p\n",ULSCH_id,gNB->dlsch[0][0]->harq_processes[0]);
+    for (i=0; i<Prx; i++) {
+      pusch_vars[ULSCH_id]->rxdataF_ext[i]           = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot );
+      pusch_vars[ULSCH_id]->rxdataF_ext2[i]          = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot );
+      pusch_vars[ULSCH_id]->ul_ch_estimates[i]       = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot );
+      pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i]   = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot );
+      pusch_vars[ULSCH_id]->ul_ch_estimates_time[i]  = (int32_t *)malloc16_clear( 2*sizeof(int32_t)*fp->ofdm_symbol_size );
+      pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates[i]       = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot ); // max intensity in freq is 1 sc every 2 RBs
+      pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext[i]   = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2*fp->symbols_per_slot );
+      pusch_vars[ULSCH_id]->rxdataF_comp[i]          = (int32_t *)malloc16_clear( sizeof(int32_t)*N_RB_UL*12*fp->symbols_per_slot );
+      pusch_vars[ULSCH_id]->ul_ch_mag0[i]             = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 );
+      pusch_vars[ULSCH_id]->ul_ch_magb0[i]            = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 );
+      pusch_vars[ULSCH_id]->ul_ch_mag[i]             = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 );
+      pusch_vars[ULSCH_id]->ul_ch_magb[i]            = (int32_t *)malloc16_clear( fp->symbols_per_slot*sizeof(int32_t)*N_RB_UL*12 );
+      pusch_vars[ULSCH_id]->rho[i]                   = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->N_RB_UL*12*7*2) );
     }
-
-    pusch_vars[UE_id]->llr = (int16_t *)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); // [hna] 6144 is LTE and (8*((3*8*6144)+12)) is not clear 
-  } //UE_id
+    printf("ULSCH_id %d (before llr alloc) : %p\n",ULSCH_id,gNB->dlsch[0][0]->harq_processes[0]);
+    pusch_vars[ULSCH_id]->llr = (int16_t *)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); // [hna] 6144 is LTE and (8*((3*8*6144)+12)) is not clear
+    printf("ULSCH_id %d (after llr alloc) : %p\n",ULSCH_id,gNB->dlsch[0][0]->harq_processes[0]); 
+  } //ulsch_id
 /*
-  for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++)
-    gNB->UE_stats_ptr[UE_id] = &gNB->UE_stats[UE_id];
+  for (ulsch_id=0; ulsch_id<NUMBER_OF_UE_MAX; ulsch_id++)
+    gNB->UE_stats_ptr[ulsch_id] = &gNB->UE_stats[ulsch_id];
 */
-  gNB->pdsch_config_dedicated->p_a = dB0; //defaul value until overwritten by RRCConnectionReconfiguration
+  printf("After ULSCH init : %p\n",gNB->dlsch[0][0]->harq_processes[0]);
   return (0);
 }
-/*
-void phy_config_request(PHY_Config_t *phy_config) {
-
-  uint8_t Mod_id              = phy_config->Mod_id;
-  int CC_id                   = phy_config->CC_id;
-  nfapi_nr_config_request_t *cfg = phy_config->cfg;
-
-  NR_DL_FRAME_PARMS *fp;
-  PHICH_RESOURCE_t phich_resource_table[4]={oneSixth,half,one,two};
-  int                 eutra_band     = cfg->nfapi_config.rf_bands.rf_band[0];
-  int                 dl_Bandwidth   = cfg->rf_config.dl_carrier_bandwidth.value;
-  int                 ul_Bandwidth   = cfg->rf_config.ul_carrier_bandwidth.value;
-  int                 Nid_cell       = cfg->sch_config.physical_cell_id.value;
-  int                 Ncp            = cfg->subframe_config.dl_cyclic_prefix_type.value;
-  int                 p_eNB          = cfg->rf_config.tx_antenna_ports.value;
-  uint32_t            dl_CarrierFreq = cfg->nfapi_config.earfcn.value;
-
-  LOG_I(PHY,"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d, N_RB_UL %d, Nid_cell %d,gNB_tx_antenna_ports %d,Ncp %d,DL freq %u)\n",
-  Mod_id, CC_id, eutra_band, dl_Bandwidth, ul_Bandwidth, Nid_cell, p_eNB,Ncp,dl_CarrierFreq );
-
-  AssertFatal(RC.gNB != NULL, "PHY instance pointer doesn't exist\n");
-  AssertFatal(RC.gNB[Mod_id] != NULL, "PHY instance %d doesn't exist\n",Mod_id);
-  AssertFatal(RC.gNB[Mod_id][CC_id] != NULL, "PHY instance %d, CCid %d doesn't exist\n",Mod_id,CC_id);
-
-
-  if (RC.gNB[Mod_id][CC_id]->configured == 1)
-  {
-    LOG_E(PHY,"Already eNB already configured, do nothing\n");
-    return;
-  }
-
-  RC.gNB[Mod_id][CC_id]->mac_enabled     = 1;
-
-  fp = &RC.gNB[Mod_id][CC_id]->frame_parms;
-
-  fp->threequarter_fs                    = 0;
-
-  nr_init_frame_parms(fp,1);
-
-  RC.gNB[Mod_id][CC_id]->configured                                   = 1;
-  LOG_I(PHY,"gNB %d/%d configured\n",Mod_id,CC_id);
-}*/
-
 
 void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
 {
   //NR_DL_FRAME_PARMS* const fp       = &gNB->frame_parms;
-  //nfapi_nr_config_request_t *cfg       = &gNB->gNB_config;
   NR_gNB_COMMON *const common_vars  = &gNB->common_vars;
   NR_gNB_PUSCH **const pusch_vars   = gNB->pusch_vars;
   /*LTE_eNB_SRS *const srs_vars        = gNB->srs_vars;
   LTE_eNB_PRACH *const prach_vars    = &gNB->prach_vars;*/
   uint32_t ***pdcch_dmrs             = gNB->nr_gold_pdcch_dmrs;
+  int Ptx=gNB->gNB_config.carrier_config.num_tx_ant.value;
 
-  for (int i = 0; i < 15; i++) {
+  for (int i = 0; i < Ptx; i++) {
     free_and_zero(common_vars->txdataF[i]);
     /* rxdataF[i] is not allocated -> don't free */
   }
@@ -344,36 +321,40 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
   free_and_zero(prach_vars->prach_ifft[0]);
   free_and_zero(prach_vars->rxsigF[0]);
 */
-  for (int UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
+  for (int ULSCH_id=0; ULSCH_id<NUMBER_OF_NR_ULSCH_MAX; ULSCH_id++) {
     for (int i = 0; i < 2; i++) {
-      free_and_zero(pusch_vars[UE_id]->rxdataF_ext[i]);
-      free_and_zero(pusch_vars[UE_id]->rxdataF_ext2[i]);
-      free_and_zero(pusch_vars[UE_id]->ul_ch_estimates[i]);
-      free_and_zero(pusch_vars[UE_id]->ul_ch_estimates_ext[i]);
-      free_and_zero(pusch_vars[UE_id]->ul_ch_estimates_time[i]);
-      free_and_zero(pusch_vars[UE_id]->rxdataF_comp[i]);
-      free_and_zero(pusch_vars[UE_id]->ul_ch_mag0[i]);
-      free_and_zero(pusch_vars[UE_id]->ul_ch_magb0[i]);
-      free_and_zero(pusch_vars[UE_id]->ul_ch_mag[i]);
-      free_and_zero(pusch_vars[UE_id]->ul_ch_magb[i]);
-      free_and_zero(pusch_vars[UE_id]->rho[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext2[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_time[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->rxdataF_comp[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->ul_ch_mag0[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->ul_ch_magb0[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->ul_ch_mag[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->ul_ch_magb[i]);
+      free_and_zero(pusch_vars[ULSCH_id]->rho[i]);
     }
 
-    free_and_zero(pusch_vars[UE_id]->rxdataF_ext);
-    free_and_zero(pusch_vars[UE_id]->rxdataF_ext2);
-    free_and_zero(pusch_vars[UE_id]->ul_ch_estimates);
-    free_and_zero(pusch_vars[UE_id]->ul_ch_estimates_ext);
-    free_and_zero(pusch_vars[UE_id]->ul_ch_estimates_time);
-    free_and_zero(pusch_vars[UE_id]->rxdataF_comp);
-    free_and_zero(pusch_vars[UE_id]->ul_ch_mag0);
-    free_and_zero(pusch_vars[UE_id]->ul_ch_magb0);
-    free_and_zero(pusch_vars[UE_id]->ul_ch_mag);
-    free_and_zero(pusch_vars[UE_id]->ul_ch_magb);
-    free_and_zero(pusch_vars[UE_id]->rho);
-
-    free_and_zero(pusch_vars[UE_id]->llr);
-    free_and_zero(pusch_vars[UE_id]);
-  } //UE_id
+    free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext);
+    free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext2);
+    free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates);
+    free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_ext);
+    free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates);
+    free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext);
+    free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_time);
+    free_and_zero(pusch_vars[ULSCH_id]->rxdataF_comp);
+    free_and_zero(pusch_vars[ULSCH_id]->ul_ch_mag0);
+    free_and_zero(pusch_vars[ULSCH_id]->ul_ch_magb0);
+    free_and_zero(pusch_vars[ULSCH_id]->ul_ch_mag);
+    free_and_zero(pusch_vars[ULSCH_id]->ul_ch_magb);
+    free_and_zero(pusch_vars[ULSCH_id]->rho);
+
+    free_and_zero(pusch_vars[ULSCH_id]->llr);
+    free_and_zero(pusch_vars[ULSCH_id]);
+  } //ULSCH_id
 /*
   for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) gNB->UE_stats_ptr[UE_id] = NULL;
 */
@@ -396,103 +377,127 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,
                                uint64_t position_in_burst)
 {
   NR_DL_FRAME_PARMS *fp                                   = &gNB->frame_parms;
-  nfapi_nr_config_request_t *gNB_config                   = &gNB->gNB_config;
+  nfapi_nr_config_request_scf_t *gNB_config               = &gNB->gNB_config;
   //overwrite for new NR parameters
-  gNB_config->nfapi_config.rf_bands.rf_band[0]            = 78;
-  gNB_config->nfapi_config.nrarfcn.value                  = 620000;
-  gNB_config->subframe_config.numerology_index_mu.value   = mu;
-  gNB_config->subframe_config.duplex_mode.value           = TDD;
-  gNB_config->rf_config.dl_carrier_bandwidth.value        = N_RB_DL;
-  gNB_config->rf_config.ul_carrier_bandwidth.value        = N_RB_UL;
-  gNB_config->sch_config.half_frame_index.value           = 0;
-  gNB_config->sch_config.ssb_subcarrier_offset.value      = 0;
-  gNB_config->sch_config.n_ssb_crb.value                  = (N_RB_DL-20);
-  gNB_config->sch_config.ssb_subcarrier_offset.value      = 0;
-  gNB_config->sch_config.physical_cell_id.value           = Nid_cell;
-  gNB_config->sch_config.ssb_scg_position_in_burst.value  = position_in_burst;
-  gNB_config->subframe_config.dl_cyclic_prefix_type.value = (fp->Ncp == NORMAL) ? NFAPI_CP_NORMAL : NFAPI_CP_EXTENDED;
+
+  uint64_t rev_burst=0;
+  for (int i=0; i<64; i++)
+    rev_burst |= (((position_in_burst>>(63-i))&0x01)<<i);
+
+  gNB_config->cell_config.phy_cell_id.value             = Nid_cell;
+  gNB_config->ssb_config.scs_common.value               = mu;
+  gNB_config->ssb_table.ssb_subcarrier_offset.value     = 0;
+  gNB_config->ssb_table.ssb_offset_point_a.value        = (N_RB_DL-20)>>1;
+  gNB_config->ssb_table.ssb_mask_list[1].ssb_mask.value = (rev_burst)&(0xFFFFFFFF);
+  gNB_config->ssb_table.ssb_mask_list[0].ssb_mask.value = (rev_burst>>32)&(0xFFFFFFFF);
+  gNB_config->cell_config.frame_duplex_type.value       = TDD;
+  gNB_config->ssb_table.ssb_period.value		= 1; //10ms
+  gNB_config->carrier_config.dl_grid_size[mu].value     = N_RB_DL;
+  gNB_config->carrier_config.ul_grid_size[mu].value     = N_RB_UL;
+  gNB_config->carrier_config.num_tx_ant.value           = fp->nb_antennas_tx;
+  gNB_config->carrier_config.num_rx_ant.value           = fp->nb_antennas_rx;
+
+  gNB_config->tdd_table.tdd_period.value = 0;
+  //gNB_config->subframe_config.dl_cyclic_prefix_type.value = (fp->Ncp == NORMAL) ? NFAPI_CP_NORMAL : NFAPI_CP_EXTENDED;
 
   gNB->mac_enabled   = 1;
   fp->dl_CarrierFreq = 3500000000;//from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value);
   fp->ul_CarrierFreq = 3500000000;//fp->dl_CarrierFreq - (get_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000);
+  fp->nr_band = 78;
   fp->threequarter_fs= 0;
+
+  gNB_config->carrier_config.dl_bandwidth.value = config_bandwidth(mu, N_RB_DL, fp->nr_band);
+
   nr_init_frame_parms(gNB_config, fp);
   gNB->configured    = 1;
   LOG_I(PHY,"gNB configured\n");
 }
 
 
-void nr_phy_config_request(NR_PHY_Config_t *phy_config)
-{
-  uint8_t Mod_id                                        = phy_config->Mod_id;
-  int     CC_id                                         = phy_config->CC_id;
-  NR_DL_FRAME_PARMS         *fp                         = &RC.gNB[Mod_id][CC_id]->frame_parms;
-  nfapi_nr_config_request_t *gNB_config                 = &RC.gNB[Mod_id][CC_id]->gNB_config;
-  gNB_config->nfapi_config.rf_bands.rf_band[0]          = phy_config->cfg->nfapi_config.rf_bands.rf_band[0]; //22
-  gNB_config->nfapi_config.nrarfcn.value                = phy_config->cfg->nfapi_config.nrarfcn.value; //6600
-  gNB_config->subframe_config.numerology_index_mu.value = phy_config->cfg->subframe_config.numerology_index_mu.value;//1
-  gNB_config->rf_config.dl_carrier_bandwidth.value      = phy_config->cfg->rf_config.dl_carrier_bandwidth.value;//106;
-  gNB_config->rf_config.ul_carrier_bandwidth.value      = phy_config->cfg->rf_config.ul_carrier_bandwidth.value;//106;
-  gNB_config->sch_config.half_frame_index.value         = 0;
-  gNB_config->sch_config.ssb_subcarrier_offset.value    = phy_config->cfg->sch_config.ssb_subcarrier_offset.value;//0;
-  gNB_config->sch_config.n_ssb_crb.value                = (phy_config->cfg->rf_config.dl_carrier_bandwidth.value-20);
-  gNB_config->sch_config.physical_cell_id.value         = phy_config->cfg->sch_config.physical_cell_id.value;
-  gNB_config->sch_config.ssb_scg_position_in_burst.value= phy_config->cfg->sch_config.ssb_scg_position_in_burst.value;
-  gNB_config->sch_config.ssb_periodicity.value		    = phy_config->cfg->sch_config.ssb_periodicity.value;
-
-  if (phy_config->cfg->subframe_config.duplex_mode.value == 0) {
-    gNB_config->subframe_config.duplex_mode.value    = FDD;
+void nr_phy_config_request(NR_PHY_Config_t *phy_config) {
+  uint8_t Mod_id = phy_config->Mod_id;
+  NR_DL_FRAME_PARMS *fp = &RC.gNB[Mod_id]->frame_parms;
+  nfapi_nr_config_request_scf_t *gNB_config = &RC.gNB[Mod_id]->gNB_config;
+
+  /*
+  gNB_config->cell_config.phy_cell_id.value             = phy_config->cfg->cell_config.phy_cell_id.value;
+  gNB_config->carrier_config.dl_frequency.value         = phy_config->cfg->carrier_config.dl_frequency.value;
+  gNB_config->carrier_config.uplink_frequency.value     = phy_config->cfg->carrier_config.uplink_frequency.value;
+  gNB_config->ssb_config.scs_common.value               = phy_config->cfg->ssb_config.scs_common.value;
+  gNB_config->carrier_config.dl_bandwidth.value         = phy_config->cfg->carrier_config.dl_bandwidth.value;
+  gNB_config->carrier_config.uplink_bandwidth.value     = phy_config->cfg->carrier_config.uplink_bandwidth.value;
+  gNB_config->ssb_table.ssb_subcarrier_offset.value     = phy_config->cfg->ssb_table.ssb_subcarrier_offset.value;
+  gNB_config->ssb_table.ssb_offset_point_a.value        = phy_config->cfg->ssb_table.ssb_offset_point_a.value;
+  gNB_config->ssb_table.ssb_mask_list[0].ssb_mask.value = phy_config->cfg->ssb_table.ssb_mask_list[0].ssb_mask.value;
+  gNB_config->ssb_table.ssb_mask_list[1].ssb_mask.value = phy_config->cfg->ssb_table.ssb_mask_list[1].ssb_mask.value;
+  gNB_config->ssb_table.ssb_period.value		= phy_config->cfg->ssb_table.ssb_period.value;
+  for (int i=0; i<5; i++) {
+    gNB_config->carrier_config.dl_grid_size[i].value    = phy_config->cfg->carrier_config.dl_grid_size[i].value;
+    gNB_config->carrier_config.ul_grid_size[i].value    = phy_config->cfg->carrier_config.ul_grid_size[i].value;
+    gNB_config->carrier_config.dl_k0[i].value           = phy_config->cfg->carrier_config.dl_k0[i].value;
+    gNB_config->carrier_config.ul_k0[i].value           = phy_config->cfg->carrier_config.ul_k0[i].value;
+  }
+
+
+  if (phy_config->cfg->cell_config.frame_duplex_type.value == 0) {
+    gNB_config->cell_config.frame_duplex_type.value = FDD;
   } else {
-    gNB_config->subframe_config.duplex_mode.value    = TDD;
+    gNB_config->cell_config.frame_duplex_type.value = TDD;
   }
 
-  RC.gNB[Mod_id][CC_id]->mac_enabled     = 1;
-  fp->dl_CarrierFreq = from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value);
-  get_band(fp->dl_CarrierFreq, &gNB_config->nfapi_config.rf_bands.rf_band[0], &uplink_frequency_offset[CC_id][0], &fp->frame_type);
-  fp->ul_CarrierFreq = fp->dl_CarrierFreq + uplink_frequency_offset[CC_id][0];
-  fp->threequarter_fs                    = openair0_cfg[0].threequarter_fs;
-  LOG_I(PHY,"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d, N_RB_UL %d, Nid_cell %d,DL freq %u, UL freq %u)\n",
+  memcpy((void*)&gNB_config->prach_config,(void*)&phy_config->cfg->prach_config,sizeof(phy_config->cfg->prach_config));
+  memcpy((void*)&gNB_config->tdd_table,(void*)&phy_config->cfg->tdd_table,sizeof(phy_config->cfg->tdd_table));
+  */
+  memcpy((void*)gNB_config,phy_config->cfg,sizeof(*phy_config->cfg));
+  RC.gNB[Mod_id]->mac_enabled     = 1;
+
+  uint64_t dl_bw_khz = (12*gNB_config->carrier_config.dl_grid_size[gNB_config->ssb_config.scs_common.value].value)*(15<<gNB_config->ssb_config.scs_common.value);
+  fp->dl_CarrierFreq = ((dl_bw_khz>>1) + gNB_config->carrier_config.dl_frequency.value)*1000 ;
+
+  int32_t dlul_offset = 0;
+  lte_frame_type_t frame_type = 0;
+  
+  get_band(fp->dl_CarrierFreq,&fp->nr_band,&dlul_offset,&frame_type);
+
+  uint64_t ul_bw_khz = (12*gNB_config->carrier_config.ul_grid_size[gNB_config->ssb_config.scs_common.value].value)*(15<<gNB_config->ssb_config.scs_common.value);
+  fp->ul_CarrierFreq = ((ul_bw_khz>>1) + gNB_config->carrier_config.uplink_frequency.value)*1000 ;
+
+  AssertFatal(fp->ul_CarrierFreq==(fp->dl_CarrierFreq+dlul_offset), "Disagreement in uplink frequency for band %d\n", fp->nr_band);
+  
+  fp->threequarter_fs = openair0_cfg[0].threequarter_fs;
+  LOG_I(PHY,"Configuring MIB for instance %d, : (Nid_cell %d,DL freq %llu, UL freq %llu)\n",
         Mod_id,
-        CC_id,
-        gNB_config->nfapi_config.rf_bands.rf_band[0],
-        gNB_config->rf_config.dl_carrier_bandwidth.value,
-        gNB_config->rf_config.ul_carrier_bandwidth.value,
-        gNB_config->sch_config.physical_cell_id.value,
-        fp->dl_CarrierFreq,
-        fp->ul_CarrierFreq);
+        gNB_config->cell_config.phy_cell_id.value,
+        (unsigned long long)fp->dl_CarrierFreq,
+        (unsigned long long)fp->ul_CarrierFreq);
 
   nr_init_frame_parms(gNB_config, fp);
+  
 
-  if (RC.gNB[Mod_id][CC_id]->configured == 1) {
+  if (RC.gNB[Mod_id]->configured == 1) {
     LOG_E(PHY,"Already gNB already configured, do nothing\n");
     return;
   }
 
-  RC.gNB[Mod_id][CC_id]->configured     = 1;
-  LOG_I(PHY,"gNB %d/%d configured\n",Mod_id,CC_id);
+  RC.gNB[Mod_id]->configured     = 1;
+  LOG_I(PHY,"gNB %d configured\n",Mod_id);
 }
 
 void init_nr_transport(PHY_VARS_gNB *gNB) {
   int i;
   int j;
   NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
-  nfapi_nr_config_request_t *cfg = &gNB->gNB_config;
+  nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
   LOG_I(PHY, "Initialise nr transport\n");
+  uint16_t grid_size = cfg->carrier_config.dl_grid_size[fp->numerology_index].value;
 
   for (i=0; i<NUMBER_OF_NR_DLSCH_MAX; i++) {
 
     LOG_I(PHY,"Allocating Transport Channel Buffers for DLSCH %d/%d\n",i,NUMBER_OF_NR_DLSCH_MAX);
 
     for (j=0; j<2; j++) {
-      gNB->dlsch[i][j] = new_gNB_dlsch(1,16,NSOFT,0,fp,cfg);
-
-      if (!gNB->dlsch[i][j]) {
-        LOG_E(PHY,"Can't get gNB dlsch structures for UE %d \n", i);
-        exit(-1);
-      }/* else {
-        gNB->dlsch[i][j]->rnti=0;
-        LOG_D(PHY,"dlsch[%d][%d] => %p rnti:%d\n",i,j,gNB->dlsch[i][j], gNB->dlsch[i][j]->rnti);
-      }*/
+      gNB->dlsch[i][j] = new_gNB_dlsch(fp,1,16,NSOFT,0,grid_size);
+      AssertFatal(gNB->dlsch[i][j]!=NULL,"Can't initialize dlsch %d \n", i);
     }
   }
 
@@ -519,8 +524,8 @@ void init_nr_transport(PHY_VARS_gNB *gNB) {
       rel15_ul->rnti                           = 0x1234;
       rel15_ul->ulsch_pdu_rel15.start_rb       = 0;
       rel15_ul->ulsch_pdu_rel15.number_rbs     = 50;
-      rel15_ul->ulsch_pdu_rel15.start_symbol   = 0;
-      rel15_ul->ulsch_pdu_rel15.number_symbols = 14;
+      rel15_ul->ulsch_pdu_rel15.start_symbol   = 2;
+      rel15_ul->ulsch_pdu_rel15.number_symbols = 12;
       rel15_ul->ulsch_pdu_rel15.length_dmrs    = gNB->dmrs_UplinkConfig.pusch_maxLength;
       rel15_ul->ulsch_pdu_rel15.Qm             = 2;
       rel15_ul->ulsch_pdu_rel15.R              = 679;
@@ -534,18 +539,8 @@ void init_nr_transport(PHY_VARS_gNB *gNB) {
 
   }
 
-  gNB->dlsch_SI  = new_gNB_dlsch(1,8,NSOFT, 0, fp, cfg);
-  LOG_D(PHY,"gNB %d.%d : SI %p\n",gNB->Mod_id,gNB->CC_id,gNB->dlsch_SI);
-  gNB->dlsch_ra  = new_gNB_dlsch(1,8,NSOFT, 0, fp, cfg);
-  LOG_D(PHY,"gNB %d.%d : RA %p\n",gNB->Mod_id,gNB->CC_id,gNB->dlsch_ra);
   gNB->rx_total_gain_dB=130;
 
-  for(i=0; i<NUMBER_OF_NR_UE_MAX; i++)
-    gNB->mu_mimo_mode[i].dl_pow_off = 2;
 
-  gNB->check_for_total_transmissions = 0;
-  gNB->check_for_MUMIMO_transmissions = 0;
-  gNB->FULL_MUMIMO_transmissions = 0;
-  gNB->check_for_SUMIMO_transmissions = 0;
   //fp->pucch_config_common.deltaPUCCH_Shift = 1;
 }
diff --git a/openair1/PHY/INIT/nr_init_ru.c b/openair1/PHY/INIT/nr_init_ru.c
index e8828d805c9..2dcf035866e 100644
--- a/openair1/PHY/INIT/nr_init_ru.c
+++ b/openair1/PHY/INIT/nr_init_ru.c
@@ -41,6 +41,13 @@ int nr_phy_init_RU(RU_t *ru) {
 
   LOG_I(PHY,"Initializing RU signal buffers (if_south %s) nb_tx %d\n",ru_if_types[ru->if_south],ru->nb_tx);
 
+  nfapi_nr_config_request_scf_t *cfg;
+  ru->nb_log_antennas=0;
+  for (int n=0;n<RC.nb_nr_L1_inst;n++) {
+    cfg = &RC.gNB[n]->gNB_config;
+    if (cfg->carrier_config.num_tx_ant.value > ru->nb_log_antennas) ru->nb_log_antennas = cfg->carrier_config.num_tx_ant.value;   
+  }
+  AssertFatal(ru->nb_log_antennas > 0 && ru->nb_log_antennas < 13, "ru->nb_log_antennas %d ! \n",ru->nb_log_antennas);
   if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so allocate memory for time-domain signals 
     // Time-domain signals
     ru->common.txdata        = (int32_t**)malloc16(ru->nb_tx*sizeof(int32_t*));
@@ -75,8 +82,8 @@ int nr_phy_init_RU(RU_t *ru) {
   
 
     // allocate precoding input buffers (TX)
-    ru->common.txdataF = (int32_t **)malloc16(15*sizeof(int32_t*));
-    for(i=0; i< 15; ++i)  ru->common.txdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t)); // [hna] samples_per_frame without CP
+    ru->common.txdataF = (int32_t **)malloc16(ru->nb_tx*sizeof(int32_t*));
+    for(i=0; i< ru->nb_tx; ++i)  ru->common.txdataF[i] = (int32_t*)malloc16_clear(fp->samples_per_frame_wCP*sizeof(int32_t)); // [hna] samples_per_frame without CP
 
     // allocate IFFT input buffers (TX)
     ru->common.txdataF_BF = (int32_t **)malloc16(ru->nb_tx*sizeof(int32_t*));
@@ -98,7 +105,6 @@ int nr_phy_init_RU(RU_t *ru) {
     //    AssertFatal(ru->nb_rx <= sizeof(ru->prach_rxsigF) / sizeof(ru->prach_rxsigF[0]),
     //		"nb_antennas_rx too large");
     ru->prach_rxsigF = (int16_t**)malloc(ru->nb_rx * sizeof(int16_t*));
-    for (j=0;j<4;j++) ru->prach_rxsigF_br[j] = (int16_t**)malloc(ru->nb_rx * sizeof(int16_t*));
 
     for (i=0; i<ru->nb_rx; i++) {
       ru->prach_rxsigF[i] = (int16_t*)malloc16_clear( fp->ofdm_symbol_size*12*2*sizeof(int16_t) );
@@ -111,8 +117,8 @@ int nr_phy_init_RU(RU_t *ru) {
     LOG_E(PHY,"[INIT] %s() RC.nb_nr_L1_inst:%d \n", __FUNCTION__, RC.nb_nr_L1_inst);
     
     int beam_count = 0;
-    if (ru->nb_tx>1) {
-      for (p=0;p<fp->Lmax;p++) {
+    if (ru->nb_log_antennas>1) {
+      for (p=0;p<ru->nb_log_antennas;p++) {
         if ((fp->L_ssb >> p) & 0x01)
           beam_count++;
       }
@@ -120,7 +126,7 @@ int nr_phy_init_RU(RU_t *ru) {
     
       int l_ind = 0;
       for (i=0; i<RC.nb_nr_L1_inst; i++) {
-        for (p=0;p<fp->Lmax;p++) {
+        for (p=0;p<ru->nb_log_antennas;p++) {
           if ((fp->L_ssb >> p) & 0x01)  {
 	    ru->beam_weights[i][p] = (int32_t **)malloc16_clear(ru->nb_tx*sizeof(int32_t*));
 	    for (j=0; j<ru->nb_tx; j++) {
@@ -177,9 +183,6 @@ void nr_phy_free_RU(RU_t *ru)
     for (i = 0; i < ru->nb_rx; i++) {
       free_and_zero(ru->prach_rxsigF[i]);
     }
-    for (j = 0; j < 4; j++) free_and_zero(ru->prach_rxsigF_br[j]);
-    free_and_zero(ru->prach_rxsigF);
-    /* ru->prach_rxsigF_br is not allocated -> don't free */
 
     for (i = 0; i < RC.nb_nr_L1_inst; i++) {
       for (p = 0; p < 15; p++) {
diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c
index 461f441b2cb..4ed5be2119e 100644
--- a/openair1/PHY/INIT/nr_init_ue.c
+++ b/openair1/PHY/INIT/nr_init_ue.c
@@ -651,17 +651,16 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
   int i,j,k,l,slot,symb,q;
   int eNB_id;
   int th_id;
-  int n_ssb_crb=(fp->N_RB_DL-20);
-  int k_ssb=0;
   uint32_t ****pusch_dmrs;
   uint16_t N_n_scid[2] = {0,1}; // [HOTFIX] This is a temporary implementation of scramblingID0 and scramblingID1 which are given by DMRS-UplinkConfig
   int n_scid;
   abstraction_flag = 0;
   fp->nb_antennas_tx = 1;
   fp->nb_antennas_rx=1;
+  dmrs_UplinkConfig_t *dmrs_Uplink_Config = &ue->pusch_config.dmrs_UplinkConfig;
+  ptrs_UplinkConfig_t *ptrs_Uplink_Config = &ue->pusch_config.dmrs_UplinkConfig.ptrs_UplinkConfig;
   printf("Initializing UE vars (abstraction %"PRIu8") for eNB TXant %"PRIu8", UE RXant %"PRIu8"\n",abstraction_flag,fp->nb_antennas_tx,fp->nb_antennas_rx);
   //LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_UE][MOD %02u][]\n", ue->Mod_id+NB_eNB_INST);
-  nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,fp->N_RB_DL,n_ssb_crb,k_ssb);
   phy_init_nr_top(ue);
   // 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]" );
@@ -711,9 +710,9 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
   }
 
   //------------- config DMRS parameters--------------//
-  ue->dmrs_UplinkConfig.pusch_dmrs_type = pusch_dmrs_type1;
-  ue->dmrs_UplinkConfig.pusch_dmrs_AdditionalPosition = pusch_dmrs_pos0;
-  ue->dmrs_UplinkConfig.pusch_maxLength = pusch_len1;
+  dmrs_Uplink_Config->pusch_dmrs_type = pusch_dmrs_type1;
+  dmrs_Uplink_Config->pusch_dmrs_AdditionalPosition = pusch_dmrs_pos0;
+  dmrs_Uplink_Config->pusch_maxLength = pusch_len1;
   //-------------------------------------------------//
   ue->dmrs_DownlinkConfig.pdsch_dmrs_type = pdsch_dmrs_type1;
   ue->dmrs_DownlinkConfig.pdsch_dmrs_AdditionalPosition = pdsch_dmrs_pos0;
@@ -743,6 +742,23 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
   ///////////
   ////////////////////////////////////////////////////////////////////////////////////////////
 
+  /////////////////////////PUSCH PTRS init/////////////////////////
+  ///////////
+
+  ue->ptrs_configured = 0; // flag to be toggled by RCC
+
+  //------------- config PTRS parameters--------------//
+  ptrs_Uplink_Config->timeDensity.ptrs_mcs1 = 0; // setting MCS values to 0 indicate abscence of time_density field in the configuration
+  ptrs_Uplink_Config->timeDensity.ptrs_mcs2 = 0;
+  ptrs_Uplink_Config->timeDensity.ptrs_mcs3 = 0;
+  ptrs_Uplink_Config->frequencyDensity.n_rb0 = 0;     // setting N_RB values to 0 indicate abscence of frequency_density field in the configuration
+  ptrs_Uplink_Config->frequencyDensity.n_rb1 = 0;
+  ptrs_Uplink_Config->resourceElementOffset = 0;
+  //-------------------------------------------------//
+
+  ///////////
+  ////////////////////////////////////////////////////////////////////////////////////////////
+
   for (i=0; i<10; i++)
     ue->tx_power_dBm[i]=-127;
 
@@ -933,7 +949,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
   ue->init_averaging = 1;
 
   // default value until overwritten by RRCConnectionReconfiguration
-  if (fp->nb_antenna_ports_eNB==2)
+  if (fp->nb_antenna_ports_gNB==2)
     ue->pdsch_config_dedicated->p_a = dBm3;
   else
     ue->pdsch_config_dedicated->p_a = dB0;
@@ -944,7 +960,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
   // enable MIB/SIB decoding by default
   ue->decode_MIB = 1;
   ue->decode_SIB = 1;
-  ue->ssb_periodicity = 5; // initialization of ssb periodicity to 5ms according to TS38.213 section 4.1
   init_prach_tables(839);
   return 0;
 }
@@ -963,7 +978,7 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue,
 
     ue->dlsch_SI[i]  = new_nr_ue_dlsch(1,1,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag);
     ue->dlsch_ra[i]  = new_nr_ue_dlsch(1,1,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag);
-    ue->transmission_mode[i] = ue->frame_parms.nb_antenna_ports_eNB==1 ? 1 : 2;
+    ue->transmission_mode[i] = ue->frame_parms.nb_antenna_ports_gNB==1 ? 1 : 2;
   }
 
   //ue->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1;
@@ -990,51 +1005,54 @@ void phy_init_nr_top(PHY_VARS_NR_UE *ue) {
 
 void set_default_frame_parms_single(nfapi_nr_config_request_t *config,
                                     NR_DL_FRAME_PARMS *frame_parms) {
-  //int CC_id;
-  //for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-  /* 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_nr_config_request_t *) malloc(sizeof(nfapi_nr_config_request_t));
+        /* 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_nr_config_request_t*) malloc(sizeof(nfapi_nr_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_carrier_bandwidth.value = 106;
-  config->rf_config.ul_carrier_bandwidth.value = 106;
+  config->rf_config.dl_carrier_bandwidth.value = 100;
+  config->rf_config.ul_carrier_bandwidth.value = 100;
   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->N_RB_DL             = 106;
+  frame_parms->N_RB_UL             = 106;
   frame_parms->Ncp                 = NORMAL;
   //frame_parms[CC_id]->Ncp_UL              = NORMAL;
   frame_parms->Nid_cell            = 0;
   //frame_parms[CC_id]->num_MBSFN_config    = 0;
-  frame_parms->nb_antenna_ports_eNB  = 1;
+  frame_parms->nb_antenna_ports_gNB  = 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;*/
+    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;
-  //}
+  frame_parms->numerology_index	= 0;
+  frame_parms->ttis_per_subframe	= 1;
+  frame_parms->slots_per_tti		= 2;
+  
+  
 }
diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c
index a5475a15555..c3fe9c54b1b 100644
--- a/openair1/PHY/INIT/nr_parms.c
+++ b/openair1/PHY/INIT/nr_parms.c
@@ -21,16 +21,20 @@
 
 #include "phy_init.h"
 #include "common/utils/LOG/log.h"
+#include "LAYER2/NR_MAC_gNB/mac_proto.h"
 
 /// Subcarrier spacings in Hz indexed by numerology index
 uint32_t nr_subcarrier_spacing[MAX_NUM_SUBCARRIER_SPACING] = {15e3, 30e3, 60e3, 120e3, 240e3};
-uint16_t nr_slots_per_subframe[MAX_NUM_SUBCARRIER_SPACING] = {1, 2, 4, 16, 32};
+uint16_t nr_slots_per_subframe[MAX_NUM_SUBCARRIER_SPACING] = {1, 2, 4, 8, 16};
 
 
-int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp, uint8_t i_ssb, uint8_t half_frame_index)
+
+int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp)
 {
 
   int mu = fp->numerology_index;
+  uint8_t half_frame_index = fp->half_frame_bit;
+  uint8_t i_ssb = fp->ssb_index;
   int symbol = 0;
   uint8_t n, n_temp;
   nr_ssb_type_e type = fp->ssb_type;
@@ -79,62 +83,8 @@ int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp, uint8_t i_ssb, uint8_t half_f
   return symbol;
 }
 
-int nr_is_ssb_slot(nfapi_nr_config_request_t *cfg, int slot, int frame)
-{
-
-  uint8_t n_hf;
-  uint16_t p,mu,hf_slots;
-  uint64_t ssb_map;
-  int rel_slot;
-
-  mu = cfg->subframe_config.numerology_index_mu.value;
-
-  ssb_map = cfg->sch_config.ssb_scg_position_in_burst.value;
-  p = cfg->sch_config.ssb_periodicity.value;
-  n_hf = cfg->sch_config.half_frame_index.value;
-
-  // if SSB periodicity is 5ms, they are transmitted in both half frames
-  if ( (p>10) && (frame%(p/10)) )  
-    return 0;
-  else {
-    hf_slots = (10<<mu)>>1; // number of slots per half frame
-    // if SSB periodicity is 5ms, they are transmitted in both half frames
-    if ( p == 5) {
-      if (slot<hf_slots) 
-      n_hf=0;
-    else
-      n_hf=1;
-  }
-
-  // to set a effective slot number between 0 to 9 in the half frame where the SSB is supposed to be
-    rel_slot = (n_hf)? (slot-hf_slots) : slot;
-
-
-    return ( ((ssb_map >> rel_slot*2) & 0x01) || ((ssb_map >> (1+rel_slot*2)) & 0x01) ); 
-  }
-}
-
-
-int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
-			 int mu,
-			 int Ncp,
-			 int N_RB_DL)
-
+void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, uint16_t bw)
 {
-
-#if DISABLE_LOG_X
-  printf("Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, N_RB_DL, Ncp);
-#else
-  LOG_I(PHY,"Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, N_RB_DL, Ncp);
-#endif
-
-  if (Ncp == NFAPI_CP_EXTENDED)
-    AssertFatal(mu == NR_MU_2,"Invalid cyclic prefix %d for numerology index %d\n", Ncp, mu);
-
-  fp->numerology_index = mu;
-  fp->Ncp = Ncp;
-  fp->N_RB_DL = N_RB_DL;
-
   switch(mu) {
 
     case NR_MU_0: //15kHz scs
@@ -148,24 +98,22 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
       fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_1];
 
       // selection of SS block pattern according to TS 38101-1 Table 5.4.3.3-1 for SCS 30kHz
-      if (fp->eutra_band == 5 || fp->eutra_band == 66) 
-	      fp->ssb_type = nr_ssb_type_B;
+      if (fp->nr_band == 5 || fp->nr_band == 66) 
+        fp->ssb_type = nr_ssb_type_B;
       else{  
-      	if (fp->eutra_band == 41 || ( fp->eutra_band > 76 && fp->eutra_band < 80) )
-		fp->ssb_type = nr_ssb_type_C;
+      	if (fp->nr_band == 41 || ( fp->nr_band > 76 && fp->nr_band < 80) )
+	  fp->ssb_type = nr_ssb_type_C;
 	else
-		AssertFatal(1==0,"NR Operating Band n%d not available for SS block SCS with mu=%d\n", fp->eutra_band, mu);
+	  AssertFatal(1==0,"NR Operating Band n%d not available for SS block SCS with mu=%d\n", fp->nr_band, mu);
       }
 
-      switch(N_RB_DL){
-        case 11:
-        case 24:
-        case 38:
-        case 78:
-        case 51:
-        case 65:
-
-        case 106: //40 MHz
+      switch(bw){
+        case 5:
+        case 15:
+        case 20:
+        case 25:
+        case 30:
+        case 40: //40 MHz
           if (fp->threequarter_fs) {
             fp->ofdm_symbol_size = 1536;
             fp->first_carrier_offset = 900; //1536 - ( (106*12) / 2 )
@@ -180,11 +128,11 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
           }
           break;
 
-        case 133:
-        case 162:
-        case 189:
+        case 50:
+        case 60:
+        case 70:
 
-        case 217: //80 MHz
+        case 80: //80 MHz
           if (fp->threequarter_fs) {
             fp->ofdm_symbol_size = 3072;
             fp->first_carrier_offset = 1770; //3072 - ( (217*12) / 2 )
@@ -199,22 +147,22 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
 	  }
           break;
 
-        case 245:
-	  AssertFatal(fp->threequarter_fs==0,"3/4 sampling impossible for N_RB %d and MU %d\n",N_RB_DL,mu); 
+        case 90:
+	  AssertFatal(fp->threequarter_fs==0,"3/4 sampling impossible for %d MHz band and MU %d\n",bw,mu); 
 	  fp->ofdm_symbol_size = 4096;
 	  fp->first_carrier_offset = 2626; //4096 - ( (245*12) / 2 )
 	  fp->nb_prefix_samples0 = 352;
 	  fp->nb_prefix_samples = 288;
 	  break;
-        case 273:
-	  AssertFatal(fp->threequarter_fs==0,"3/4 sampling impossible for N_RB %d and MU %d\n",N_RB_DL,mu); 
+        case 100:
+	  AssertFatal(fp->threequarter_fs==0,"3/4 sampling impossible for %d MHz band and MU %d\n",bw,mu); 
 	  fp->ofdm_symbol_size = 4096;
 	  fp->first_carrier_offset = 2458; //4096 - ( (273*12) / 2 )
 	  fp->nb_prefix_samples0 = 352;
 	  fp->nb_prefix_samples = 288;
 	  break;
       default:
-        AssertFatal(1==0,"Number of resource blocks %d undefined for mu %d, frame parms = %p\n", N_RB_DL, mu, fp);
+        AssertFatal(1==0,"%d MHz band undefined for mu %d, frame parms = %p\n", bw, mu, fp);
       }
       break;
 
@@ -222,21 +170,21 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
       fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_2];
       fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_2];
 
-      switch(N_RB_DL){ //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:
+      switch(bw){ //FR1 bands only
+        case 10:
+        case 15:
+        case 20:
+        case 25:
+        case 30:
+        case 40:
+        case 50:
+        case 60:
+        case 70:
+        case 80:
+        case 90:
+        case 100:
       default:
-        AssertFatal(1==0,"Number of resource blocks %d undefined for mu %d, frame parms = %p\n", N_RB_DL, mu, fp);
+        AssertFatal(1==0,"%d MHz band undefined for mu %d, frame parms = %p\n", bw, mu, fp);
       }
       break;
 
@@ -244,6 +192,22 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
       fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_3];
       fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_3];
       fp->ssb_type = nr_ssb_type_D;
+      switch(bw){
+        case 100:
+          fp->ofdm_symbol_size = 1024;
+          fp->first_carrier_offset = 628; //1024 - ( (66*12) / 2 )
+          fp->nb_prefix_samples0 = 136;
+          fp->nb_prefix_samples = 72;
+          break;
+        case 50:
+          fp->ofdm_symbol_size = 512;
+          fp->first_carrier_offset = 320; //1024 - ( (66*12) / 2 )
+          fp->nb_prefix_samples0 = 68;
+          fp->nb_prefix_samples = 36;
+          break;
+      default:
+        AssertFatal(1==0,"%d MHz band undefined for mu %d, frame parms = %p\n", bw, mu, fp);
+      }
       break;
 
     case NR_MU_4:
@@ -255,10 +219,63 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
   default:
     AssertFatal(1==0,"Invalid numerology index %d", mu);
   }
+}
+
+uint32_t get_samples_per_slot(int slot, NR_DL_FRAME_PARMS* fp)
+{
+  uint32_t samp_count;
+
+  if(fp->numerology_index == 0)
+    samp_count = fp->samples_per_subframe;
+  else
+    samp_count = (slot%(fp->slots_per_subframe/2)) ? fp->samples_per_slotN0 : fp->samples_per_slot0;
+
+  return samp_count;
+}
+
+uint32_t get_samples_slot_timestamp(int slot, NR_DL_FRAME_PARMS* fp, uint8_t sl_ahead)
+{
+  uint32_t samp_count = 0;
+
+  if(!sl_ahead) {
+    for(uint8_t idx_slot = 0; idx_slot < slot; idx_slot++)
+      samp_count += fp->get_samples_per_slot(idx_slot, fp);
+  } else {
+    for(uint8_t idx_slot = slot; idx_slot < slot+sl_ahead; idx_slot++)
+      samp_count += fp->get_samples_per_slot(idx_slot, fp);
+  }
+  return samp_count;
+}
+
+int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg,
+                        NR_DL_FRAME_PARMS *fp)
+{
+
+  fp->frame_type = cfg->cell_config.frame_duplex_type.value;
+  fp->L_ssb = (((uint64_t) cfg->ssb_table.ssb_mask_list[0].ssb_mask.value)<<32) | cfg->ssb_table.ssb_mask_list[1].ssb_mask.value ;
+  fp->N_RB_DL = cfg->carrier_config.dl_grid_size[cfg->ssb_config.scs_common.value].value;
+  fp->N_RB_UL = cfg->carrier_config.ul_grid_size[cfg->ssb_config.scs_common.value].value;
+
+  int Ncp = NFAPI_CP_NORMAL;
+  int mu = cfg!= NULL ?  cfg->ssb_config.scs_common.value : 0;
+
+#if DISABLE_LOG_X
+  printf("Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, fp->N_RB_DL, Ncp);
+#else
+  LOG_I(PHY,"Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, fp->N_RB_DL, Ncp);
+#endif
+
+  if (Ncp == NFAPI_CP_EXTENDED)
+    AssertFatal(mu == NR_MU_2,"Invalid cyclic prefix %d for numerology index %d\n", Ncp, mu);
+
+  fp->half_frame_bit = 0;  // half frame bit initialized to 0 here
+  fp->numerology_index = mu;
+
+  set_scs_parameters(fp, mu, cfg->carrier_config.dl_bandwidth.value);
 
   fp->slots_per_frame = 10* fp->slots_per_subframe;
 
-  fp->nb_antenna_ports_eNB = 1; // default value until overwritten by RRCConnectionReconfiguration
+  fp->nb_antenna_ports_gNB = 1; // default value until overwritten by RRCConnectionReconfiguration
   fp->nb_antennas_rx = 1; // default value until overwritten by RRCConnectionReconfiguration
   fp->nb_antennas_tx = 1; // default value until overwritten by RRCConnectionReconfiguration
 
@@ -266,12 +283,17 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
   fp->samples_per_subframe_wCP = fp->ofdm_symbol_size * fp->symbols_per_slot * fp->slots_per_subframe;
   fp->samples_per_frame_wCP = 10 * fp->samples_per_subframe_wCP;
   fp->samples_per_slot_wCP = fp->symbols_per_slot*fp->ofdm_symbol_size; 
-  fp->samples_per_slot = fp->nb_prefix_samples0 + ((fp->symbols_per_slot-1)*fp->nb_prefix_samples) + (fp->symbols_per_slot*fp->ofdm_symbol_size); 
-  fp->samples_per_subframe = (fp->samples_per_subframe_wCP + (fp->nb_prefix_samples0 * fp->slots_per_subframe) +
-                                      (fp->nb_prefix_samples * fp->slots_per_subframe * (fp->symbols_per_slot - 1)));
+  fp->samples_per_slotN0 = (fp->nb_prefix_samples + fp->ofdm_symbol_size) * fp->symbols_per_slot;
+  fp->samples_per_slot0 = fp->nb_prefix_samples0 + ((fp->symbols_per_slot-1)*fp->nb_prefix_samples) + (fp->symbols_per_slot*fp->ofdm_symbol_size); 
+  fp->samples_per_subframe = (fp->nb_prefix_samples0 + fp->ofdm_symbol_size) * 2 + 
+                             (fp->nb_prefix_samples + fp->ofdm_symbol_size) * (fp->symbols_per_slot * fp->slots_per_subframe - 2); 
+  fp->get_samples_per_slot = &get_samples_per_slot;
+  fp->get_samples_slot_timestamp = &get_samples_slot_timestamp;
   fp->samples_per_frame = 10 * fp->samples_per_subframe;
   fp->freq_range = (fp->dl_CarrierFreq < 6e9)? nr_FR1 : nr_FR2;
 
+  fp->Ncp = Ncp;
+
   // definition of Lmax according to ts 38.213 section 4.1
   if (fp->dl_CarrierFreq < 6e9) {
     if(fp->frame_type && (fp->ssb_type==2))
@@ -283,35 +305,92 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
   }
 
   fp->N_ssb = 0;
-  for (int p=0; p<fp->Lmax; p++)
+  int num_tx_ant = (cfg == NULL) ? fp->Lmax : cfg->carrier_config.num_tx_ant.value;
+
+  for (int p=0; p<num_tx_ant; p++)
     fp->N_ssb += ((fp->L_ssb >> p) & 0x01);
 
   return 0;
-}
 
-int nr_init_frame_parms(nfapi_nr_config_request_t* config,
-                        NR_DL_FRAME_PARMS *fp)
-{
-
-  fp->eutra_band = config->nfapi_config.rf_bands.rf_band[0];
-  fp->frame_type = config->subframe_config.duplex_mode.value;
-  fp->L_ssb = config->sch_config.ssb_scg_position_in_burst.value;
-  return nr_init_frame_parms0(fp,
-			      config->subframe_config.numerology_index_mu.value,
-			      config->subframe_config.dl_cyclic_prefix_type.value,
-			      config->rf_config.dl_carrier_bandwidth.value);
 }
 
 int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp,
-			   int mu, 
-			   int Ncp,
-			   int N_RB_DL,
-			   int n_ssb_crb,
-			   int ssb_subcarrier_offset) 
+			   fapi_nr_config_request_t* config, 
+			   int Ncp) 
 {
-  /*n_ssb_crb and ssb_subcarrier_offset are given in 15kHz SCS*/
-  nr_init_frame_parms0(fp,mu,Ncp,N_RB_DL);
-  fp->ssb_start_subcarrier = (12 * n_ssb_crb + ssb_subcarrier_offset)/(1<<mu);
+
+  uint64_t dl_bw_khz = (12*config->carrier_config.dl_grid_size[config->ssb_config.scs_common])*(15<<config->ssb_config.scs_common);
+  fp->dl_CarrierFreq = ((dl_bw_khz>>1) + config->carrier_config.dl_frequency)*1000 ;
+
+  uint64_t ul_bw_khz = (12*config->carrier_config.ul_grid_size[config->ssb_config.scs_common])*(15<<config->ssb_config.scs_common);
+  fp->ul_CarrierFreq = ((ul_bw_khz>>1) + config->carrier_config.uplink_frequency)*1000 ;
+
+  fp->numerology_index = config->ssb_config.scs_common;
+  fp->N_RB_UL = config->carrier_config.ul_grid_size[fp->numerology_index];
+  fp->N_RB_DL = config->carrier_config.dl_grid_size[fp->numerology_index];
+
+  int32_t uplink_frequency_offset = 0;
+
+  get_band(fp->dl_CarrierFreq, &fp->nr_band, &uplink_frequency_offset, &fp->frame_type);
+
+  AssertFatal(fp->frame_type==config->cell_config.frame_duplex_type, "Invalid duplex type in config request file for band %d\n", fp->nr_band);
+  AssertFatal(fp->ul_CarrierFreq==(fp->dl_CarrierFreq+uplink_frequency_offset), "Disagreement in uplink frequency for band %d\n", fp->nr_band);
+
+#if DISABLE_LOG_X
+  printf("Initializing UE frame parms for mu %d, N_RB %d, Ncp %d\n",fp->numerology_index, fp->N_RB_DL, Ncp);
+#else
+  LOG_I(PHY,"Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",fp->numerology_index, fp->N_RB_DL, Ncp);
+#endif
+
+  if (Ncp == NFAPI_CP_EXTENDED)
+    AssertFatal(fp->numerology_index == NR_MU_2,"Invalid cyclic prefix %d for numerology index %d\n", Ncp, fp->numerology_index);
+
+  fp->Ncp = Ncp;
+
+  set_scs_parameters(fp,fp->numerology_index,config->carrier_config.dl_bandwidth);
+
+  fp->slots_per_frame = 10* fp->slots_per_subframe;
+
+  fp->nb_antenna_ports_gNB = 1; // default value until overwritten by RRCConnectionReconfiguration
+  fp->nb_antennas_rx = 1; // default value until overwritten by RRCConnectionReconfiguration
+  fp->nb_antennas_tx = 1; // default value until overwritten by RRCConnectionReconfiguration
+
+  fp->symbols_per_slot = ((Ncp == NORMAL)? 14 : 12); // to redefine for different slot formats
+  fp->samples_per_subframe_wCP = fp->ofdm_symbol_size * fp->symbols_per_slot * fp->slots_per_subframe;
+  fp->samples_per_frame_wCP = 10 * fp->samples_per_subframe_wCP;
+  fp->samples_per_slot_wCP = fp->symbols_per_slot*fp->ofdm_symbol_size; 
+  fp->samples_per_slotN0 = (fp->nb_prefix_samples + fp->ofdm_symbol_size) * fp->symbols_per_slot;
+  fp->samples_per_slot0 = fp->nb_prefix_samples0 + ((fp->symbols_per_slot-1)*fp->nb_prefix_samples) + (fp->symbols_per_slot*fp->ofdm_symbol_size); 
+  fp->samples_per_subframe = (fp->nb_prefix_samples0 + fp->ofdm_symbol_size) * 2 + 
+                             (fp->nb_prefix_samples + fp->ofdm_symbol_size) * (fp->symbols_per_slot * fp->slots_per_subframe - 2); 
+  fp->get_samples_per_slot = &get_samples_per_slot;
+  fp->get_samples_slot_timestamp = &get_samples_slot_timestamp;
+  fp->samples_per_frame = 10 * fp->samples_per_subframe;
+  fp->freq_range = (fp->dl_CarrierFreq < 6e9)? nr_FR1 : nr_FR2;
+
+  uint8_t sco = 0;
+  if (((fp->freq_range == nr_FR1) && (config->ssb_table.ssb_subcarrier_offset<24)) ||
+      ((fp->freq_range == nr_FR2) && (config->ssb_table.ssb_subcarrier_offset<12)) )
+    sco = config->ssb_table.ssb_subcarrier_offset;
+
+  fp->ssb_start_subcarrier = (12 * config->ssb_table.ssb_offset_point_a + sco);
+
+  // definition of Lmax according to ts 38.213 section 4.1
+  if (fp->dl_CarrierFreq < 6e9) {
+    if(fp->frame_type && (fp->ssb_type==2))
+      fp->Lmax = (fp->dl_CarrierFreq < 2.4e9)? 4 : 8;
+    else
+      fp->Lmax = (fp->dl_CarrierFreq < 3e9)? 4 : 8;
+  } else {
+    fp->Lmax = 64;
+  }
+
+  fp->L_ssb = (((uint64_t) config->ssb_table.ssb_mask_list[1].ssb_mask)<<32) | config->ssb_table.ssb_mask_list[1].ssb_mask;
+  
+  fp->N_ssb = 0;
+  for (int p=0; p<fp->Lmax; p++)
+    fp->N_ssb += ((fp->L_ssb >> p) & 0x01);
+
   return 0;
 }
 
@@ -326,8 +405,8 @@ void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp)
   LOG_I(PHY,"fp->samples_per_frame_wCP=%d\n",fp->samples_per_frame_wCP);
   LOG_I(PHY,"fp->samples_per_subframe=%d\n",fp->samples_per_subframe);
   LOG_I(PHY,"fp->samples_per_frame=%d\n",fp->samples_per_frame);
-  LOG_I(PHY,"fp->dl_CarrierFreq=%u\n",fp->dl_CarrierFreq);
-  LOG_I(PHY,"fp->ul_CarrierFreq=%u\n",fp->ul_CarrierFreq);
+  LOG_I(PHY,"fp->dl_CarrierFreq=%lu\n",fp->dl_CarrierFreq);
+  LOG_I(PHY,"fp->ul_CarrierFreq=%lu\n",fp->ul_CarrierFreq);
 }
 
 
diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h
index 05d3b6c73ff..1862d5f8e00 100644
--- a/openair1/PHY/INIT/phy_init.h
+++ b/openair1/PHY/INIT/phy_init.h
@@ -392,10 +392,9 @@ void phy_config_update_sib13_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_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp, uint8_t i_ssb, uint8_t half_frame_index);
-int nr_is_ssb_slot(nfapi_nr_config_request_t *cfg, int slot, int frame);
-int nr_init_frame_parms(nfapi_nr_config_request_t *config, NR_DL_FRAME_PARMS *frame_parms);
-int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms,int mu,int Ncp,int N_RB_DL,int n_ssb_crb,int ssb_subcarrier_offset);
+int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp);
+int nr_init_frame_parms(nfapi_nr_config_request_scf_t *config, NR_DL_FRAME_PARMS *frame_parms);
+int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms,fapi_nr_config_request_t *config,int Ncp);
 int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB,uint8_t abstraction_flag);
 void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag);
 void nr_dump_frame_parms(NR_DL_FRAME_PARMS *frame_parms);
diff --git a/openair1/PHY/MODULATION/modulation_UE.h b/openair1/PHY/MODULATION/modulation_UE.h
index 1199a91baa0..228299095f7 100644
--- a/openair1/PHY/MODULATION/modulation_UE.h
+++ b/openair1/PHY/MODULATION/modulation_UE.h
@@ -54,6 +54,12 @@ int nr_slot_fep(PHY_VARS_NR_UE *phy_vars_ue,
              int sample_offset,
              int no_prefix);
 
+int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue,
+                          unsigned char symbol,
+                          unsigned char Ns,
+                          int sample_offset,
+                          int no_prefix);
+
 int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue,
                    unsigned char l,
                    int subframe,
diff --git a/openair1/PHY/MODULATION/nr_modulation.c b/openair1/PHY/MODULATION/nr_modulation.c
index 57bca9e2ec1..5c8fce3c386 100644
--- a/openair1/PHY/MODULATION/nr_modulation.c
+++ b/openair1/PHY/MODULATION/nr_modulation.c
@@ -51,9 +51,10 @@ void nr_modulation(uint32_t *in,
 }
 
 void nr_layer_mapping(int16_t **mod_symbs,
-                         uint8_t n_layers,
-                         uint16_t n_symbs,
-                         int16_t **tx_layers) {
+		      uint8_t n_layers,
+		      uint16_t n_symbs,
+		      int16_t **tx_layers) {
+  LOG_D(PHY,"Doing layer mapping for %d layers, %d symbols\n",n_layers,n_symbs);
 
   switch (n_layers) {
 
diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c
index 11aaf1f78e9..f2e5d24badb 100644
--- a/openair1/PHY/MODULATION/slot_fep_nr.c
+++ b/openair1/PHY/MODULATION/slot_fep_nr.c
@@ -46,6 +46,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
   unsigned char aa;
   unsigned int nb_prefix_samples;
   unsigned int nb_prefix_samples0;
+  unsigned int abs_symbol;
   if (ue->is_synchronized) {
     nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
     nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0);
@@ -109,7 +110,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
   if (no_prefix) {
     slot_offset = frame_parms->ofdm_symbol_size * (frame_parms->symbols_per_slot) * (Ns);
   } else {
-    slot_offset = (frame_parms->samples_per_slot) * (Ns);
+    slot_offset = frame_parms->get_samples_slot_timestamp(Ns,frame_parms,0);
   }
 
   /*if (l<0 || l>=7-frame_parms->Ncp) {
@@ -117,15 +118,15 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
     return(-1);
     }*/
 
-  if (Ns<0 || Ns>=20) {
-    printf("slot_fep: Ns must be between 0 and 19\n");
+  if (Ns<0 || Ns>(frame_parms->slots_per_frame-1)) {
+    printf("slot_fep: Ns must be between 0 and %d\n",frame_parms->slots_per_frame-1);
     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]].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 - SOFFSET;
+    rx_offset = sample_offset + slot_offset - SOFFSET;
     // Align with 256 bit
     //    rx_offset = rx_offset&0xfffffff8;
 
@@ -135,8 +136,16 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
     		ue->proc.proc_rxtx[(Ns)&1].frame_rx, Ns, symbol, nb_prefix_samples, nb_prefix_samples0, slot_offset, sample_offset, rx_offset, frame_length_samples);
 #endif
 
-    if (symbol==0) {
+    abs_symbol = Ns * frame_parms->symbols_per_slot + symbol;
+    
+    for (int idx_symb = Ns*frame_parms->symbols_per_slot; idx_symb < abs_symbol; idx_symb++)
+      rx_offset += (idx_symb%(0x7<<frame_parms->numerology_index)) ? nb_prefix_samples : nb_prefix_samples0;
 
+    rx_offset += frame_parms->ofdm_symbol_size * symbol;
+
+    if (abs_symbol%(0x7<<frame_parms->numerology_index)) {
+
+      rx_offset += nb_prefix_samples;
       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],
@@ -161,9 +170,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
       }
     } else {
 
-      rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*symbol;
-      //                  + (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1);
-
+      rx_offset += nb_prefix_samples0;
       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],
@@ -197,6 +204,181 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
   }
 
 
+#ifdef DEBUG_FEP
+  printf("slot_fep: done\n");
+#endif
+  return(0);
+}
+
+int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue,
+                unsigned char symbol,
+                unsigned char Ns,
+                int sample_offset,
+                int no_prefix)
+{
+  NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
+  NR_UE_COMMON *common_vars   = &ue->common_vars;
+  unsigned char aa;
+  unsigned int nb_prefix_samples;
+  unsigned int nb_prefix_samples0;
+  unsigned int abs_symbol;
+  if (ue->is_synchronized) {
+    nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
+    nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0);
+  }
+  else {
+    nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
+    nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
+  }
+  //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;
+
+
+  void (*dft)(int16_t *,int16_t *, int);
+  int tmp_dft_in[8192] __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;
+
+  case 3072:
+    dft = dft3072;
+    break;
+
+  case 4096:
+    dft = dft4096;
+    break;
+
+  case 8192:
+    dft = dft8192;
+    break;
+
+  default:
+    printf("unsupported ofdm symbol size \n");
+    assert(0);
+  }
+
+  if (no_prefix) {
+    slot_offset = frame_parms->ofdm_symbol_size * (frame_parms->symbols_per_slot) * (Ns);
+  } else {
+    slot_offset = frame_parms->get_samples_slot_timestamp(Ns,frame_parms,0);
+  }
+
+  /*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>(frame_parms->slots_per_frame-1)) {
+    printf("slot_fep: Ns must be between 0 and %d\n",frame_parms->slots_per_frame-1);
+    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]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],0,frame_parms->ofdm_symbol_size*sizeof(int));
+
+    rx_offset = sample_offset + slot_offset - SOFFSET;
+    // Align with 256 bit
+    //    rx_offset = rx_offset&0xfffffff8;
+
+#ifdef DEBUG_FEP
+      //  if (ue->frame <100)
+    /*LOG_I(PHY,*/printf("slot_fep: frame %d: slot %d, symbol %d, nb_prefix_samples %u, nb_prefix_samples0 %u, slot_offset %u, sample_offset %d,rx_offset %u, frame_length_samples %u\n",
+    		ue->proc.proc_rxtx[(Ns)&1].frame_rx, Ns, symbol, nb_prefix_samples, nb_prefix_samples0, slot_offset, sample_offset, rx_offset, frame_length_samples);
+#endif
+
+    abs_symbol = Ns * frame_parms->symbols_per_slot + symbol;
+    
+    for (int idx_symb = Ns*frame_parms->symbols_per_slot; idx_symb < abs_symbol; idx_symb++)
+      rx_offset += (abs_symbol%(0x7<<frame_parms->numerology_index)) ? nb_prefix_samples : nb_prefix_samples0;
+
+    rx_offset += frame_parms->ofdm_symbol_size * symbol;
+
+    if (abs_symbol%(0x7<<frame_parms->numerology_index)) {
+
+      rx_offset += nb_prefix_samples;
+      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_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]].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],
+            (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
+#if UE_TIMING_TRACE
+        stop_meas(&ue->rx_dft_stats);
+#endif
+      }
+    } else {
+
+      rx_offset += nb_prefix_samples0;
+      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_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]].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],
+            (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].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 %u\n", ue->proc.proc_rxtx[(Ns)&1].frame_rx, symbol, rx_offset);
+    #endif
+  }
+
+
 #ifdef DEBUG_FEP
   printf("slot_fep: done\n");
 #endif
@@ -258,7 +440,7 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
       break;
   }
   
-  slot_offset   = Ns * frame_parms->samples_per_slot;
+  slot_offset   = frame_parms->get_samples_slot_timestamp(Ns,frame_parms,0);
 
   
   if(symbol == 0)
diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c
index ab6ccd929bc..0d7732599fc 100644
--- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c
+++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c
@@ -31,22 +31,19 @@
 
 
 int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
-                                uint8_t gNB_offset,
                                 unsigned char Ns,
                                 unsigned short p,
                                 unsigned char symbol,
                                 unsigned short bwp_start_subcarrier,
-                                unsigned short nb_rb_pusch,
-                                dmrs_UplinkConfig_t *dmrs_UplinkConfig)
-{
+                                nfapi_nr_pusch_pdu_t *pusch_pdu) {
+
   int pilot[3280] __attribute__((aligned(16)));
   unsigned char aarx;
   unsigned short k;
   unsigned int pilot_cnt,re_cnt;
   int16_t ch[2],ch_r[2],ch_l[2],*pil,*rxF,*ul_ch;
   int16_t *fl,*fm,*fr,*fml,*fmr,*fmm,*fdcl,*fdcr,*fdclh,*fdcrh;
-  int ch_offset,symbol_offset, length_dmrs, UE_id = 0;
-  unsigned short n_idDMRS[2] = {0,1}; //to update from pusch config
+  int ch_offset,symbol_offset, UE_id = 0;
   int32_t **ul_ch_estimates_time =  gNB->pusch_vars[UE_id]->ul_ch_estimates_time;
   __m128i *ul_ch_128;
 
@@ -71,9 +68,11 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
   k = bwp_start_subcarrier;
   int re_offset = k;
 
+  uint16_t nb_rb_pusch = pusch_pdu->rb_size;
+
 /*
 #ifdef DEBUG_CH
-  printf("PUSCH Channel Estimation : gNB_offset %d ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n", gNB_offset,ch_offset,symbol_offset,gNB->frame_parms.ofdm_symbol_size,
+  printf("PUSCH Channel Estimation : ch_offset %d, symbol_offset %d OFDM size %d, Ncp=%d, l=%d, Ns=%d, k=%d symbol %d\n", ,ch_offset,symbol_offset,gNB->frame_parms.ofdm_symbol_size,
          gNB->frame_parms.Ncp,l,Ns,k, symbol);
 #endif
 */
@@ -117,21 +116,17 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
 
   //------------------generate DMRS------------------//
 
-  length_dmrs = gNB->dmrs_UplinkConfig.pusch_maxLength;
-
-  nr_gold_pusch(gNB, symbol, n_idDMRS, length_dmrs);
-
-  nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch[gNB_offset][Ns][0], &pilot[0], 1000, 0, nb_rb_pusch, dmrs_UplinkConfig->pusch_dmrs_type);
+  nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch_dmrs[pusch_pdu->scid][Ns][symbol], &pilot[0], 1000, 0, nb_rb_pusch, pusch_pdu->dmrs_config_type);
 
   //------------------------------------------------//
 
   for (aarx=0; aarx<gNB->frame_parms.nb_antennas_rx; aarx++) {
 
-      pil   = (int16_t *)&pilot[0];
-      rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)];
-      ul_ch = (int16_t *)&ul_ch_estimates[aarx][ch_offset];
+    pil   = (int16_t *)&pilot[0];
+    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)];
+    ul_ch = (int16_t *)&ul_ch_estimates[aarx][ch_offset];
 
-      memset(ul_ch,0,4*(gNB->frame_parms.ofdm_symbol_size));
+    memset(ul_ch,0,4*(gNB->frame_parms.ofdm_symbol_size));
 
 #ifdef DEBUG_PUSCH
     printf("ch est pilot addr %p RB_DL %d\n",&pilot[0], gNB->frame_parms.N_RB_UL);
@@ -141,8 +136,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
 #endif
     //if ((gNB->frame_parms.N_RB_UL&1)==0) {
 
-
-    if (dmrs_UplinkConfig->pusch_dmrs_type == pusch_dmrs_type1){
+    if (pusch_pdu->dmrs_config_type == pusch_dmrs_type1){
 
       // Treat first 2 pilots specially (left edge)
       ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
@@ -237,10 +231,10 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
       }
       
       // Treat first 2 pilots specially (right edge)
-	  ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
+      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_PUSCH
-    printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
+      printf("pilot %u : 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(fm,
                                          ch,
diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h
index cc84f2292c6..a7789c92249 100644
--- a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h
+++ b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h
@@ -39,14 +39,12 @@
 \param nb_rb_pusch, number of allocated RBs for this UE
 */
 
- int32_t nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
-                                     uint8_t gNB_offset,
-				                     unsigned char Ns,
-				                     unsigned short p,
-				                     unsigned char symbol,
-				                     unsigned short bwp_start_subcarrier,
-				                     unsigned short nb_rb_pusch,
-				                     dmrs_UplinkConfig_t *dmrs_UplinkConfig);
+int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
+                                unsigned char Ns,
+                                unsigned short p,
+                                unsigned char symbol,
+                                unsigned short bwp_start_subcarrier,
+                                nfapi_nr_pusch_pdu_t *pusch_pdu);
 
 int nr_est_timing_advance_pusch(PHY_VARS_gNB* phy_vars_gNB, int UE_id);
 
diff --git a/openair1/PHY/NR_REFSIG/dmrs_nr.c b/openair1/PHY/NR_REFSIG/dmrs_nr.c
index 67118f35a93..ed37a79d0f2 100644
--- a/openair1/PHY/NR_REFSIG/dmrs_nr.c
+++ b/openair1/PHY/NR_REFSIG/dmrs_nr.c
@@ -128,22 +128,21 @@ uint8_t is_dmrs_symbol(uint8_t l,
                        uint16_t n,
                        uint8_t delta,
                        uint8_t duration_in_symbols,
-                       dmrs_UplinkConfig_t *dmrs_UplinkConfig,
-                       uint8_t mapping_type,
+                       uint8_t dmrs_type,
                        uint16_t ofdm_symbol_size) {
 
-  uint8_t is_dmrs_freq, is_dmrs_time, dmrs_type, l0;
+  uint8_t is_dmrs_freq, is_dmrs_time, l0;
   int32_t l_prime_mask;
-  pusch_dmrs_AdditionalPosition_t additional_pos;
+  pusch_dmrs_AdditionalPosition_t additional_pos = pusch_dmrs_pos0;
+  pusch_maxLength_t pusch_maxLength = pusch_len1;
+  uint8_t mapping_type = typeB;
 
   is_dmrs_freq = 0;
   is_dmrs_time = 0;
-  dmrs_type = dmrs_UplinkConfig->pusch_dmrs_type;
-  additional_pos = dmrs_UplinkConfig->pusch_dmrs_AdditionalPosition;
 
 
   l0 = get_l0_ul(mapping_type, 2);
-  l_prime_mask = get_l_prime(duration_in_symbols, mapping_type, additional_pos, dmrs_UplinkConfig->pusch_maxLength);
+  l_prime_mask = get_l_prime(duration_in_symbols, mapping_type, additional_pos, pusch_maxLength);
 
   if (k == ((start_sc+get_dmrs_freq_idx_ul(n, k_prime, delta, dmrs_type))%ofdm_symbol_size))
     is_dmrs_freq = 1;
@@ -157,7 +156,7 @@ uint8_t is_dmrs_symbol(uint8_t l,
   } else if ( (l==l0) || (((l_prime_mask>>l)&1) == 1 && l!=0) )
     is_dmrs_time = 1;
 
-  if (dmrs_UplinkConfig->pusch_maxLength == pusch_len2){
+  if (pusch_maxLength == pusch_len2){
 
     if (((l_prime_mask>>(l-1))&1) == 1 && l!=0 && l!=1)
       is_dmrs_time = 1;
diff --git a/openair1/PHY/NR_REFSIG/dmrs_nr.h b/openair1/PHY/NR_REFSIG/dmrs_nr.h
index de77a8a6ced..f1dfffff8b5 100644
--- a/openair1/PHY/NR_REFSIG/dmrs_nr.h
+++ b/openair1/PHY/NR_REFSIG/dmrs_nr.h
@@ -66,8 +66,7 @@ uint8_t is_dmrs_symbol(uint8_t l,
                        uint16_t n,
                        uint8_t delta,
                        uint8_t duration_in_symbols,
-                       dmrs_UplinkConfig_t *dmrs_UplinkConfig,
-                       uint8_t mapping_type,
+                       uint8_t dmrs_type,
                        uint16_t ofdm_symbol_size);
 
 #undef EXTERN
diff --git a/openair1/PHY/NR_REFSIG/nr_gold.c b/openair1/PHY/NR_REFSIG/nr_gold.c
index 48fcd04a0f1..472d03e6490 100644
--- a/openair1/PHY/NR_REFSIG/nr_gold.c
+++ b/openair1/PHY/NR_REFSIG/nr_gold.c
@@ -26,11 +26,11 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB)
   unsigned int x1, x2;
   uint16_t Nid, i_ssb, i_ssb2;
   unsigned char Lmax, l, n_hf, N_hf;
-  nfapi_nr_config_request_t *cfg = &gNB->gNB_config;
+  nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
   NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
   uint8_t reset;
 
-  Nid = cfg->sch_config.physical_cell_id.value;
+  Nid = cfg->cell_config.phy_cell_id.value;
 
   Lmax = fp->Lmax;
   N_hf = (Lmax == 4)? 2:1;
@@ -65,7 +65,7 @@ void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid)
     for (uint8_t symb=0; symb<fp->symbols_per_slot; symb++) {
 
       reset = 1;
-      x2 = ((1<<17) * (14*slot+symb+1) * ((Nid<<1)+1) + (Nid<<1));
+      x2 = ((1<<17) * (14*slot+symb+1) * ((Nid<<1)+1)) + (Nid<<1);
 
       for (uint32_t n=0; n<NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD; n++) {
         pdcch_dmrs[slot][symb][n] = lte_gold_generic(&x1, &x2, reset);
@@ -91,6 +91,7 @@ void nr_init_pdsch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid)
     for (uint8_t symb=0; symb<fp->symbols_per_slot; symb++) {
         reset = 1;
         x2 = ((1<<17) * (fp->symbols_per_slot*slot+symb+1) * ((N_n_scid[n_scid]<<1)+1) +((N_n_scid[n_scid]<<1)+n_scid));
+	LOG_D(PHY,"DMRS slot %d, symb %d x2 %x\n",slot,symb,x2);
         for (uint32_t n=0; n<NR_MAX_PDSCH_DMRS_INIT_LENGTH_DWORD; n++) {
           pdsch_dmrs[slot][symb][0][n] = lte_gold_generic(&x1, &x2, reset);
           reset = 0;
@@ -103,57 +104,28 @@ void nr_init_pdsch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid)
 }
 
 
-void nr_gold_pusch(PHY_VARS_gNB* gNB, unsigned short lbar,unsigned short *n_idDMRS, unsigned short length_dmrs)
-{
+void nr_gold_pusch(PHY_VARS_gNB* gNB, uint32_t *Nid) {
 
-  unsigned char ns,l;
-  unsigned int n,x1,x2,x2tmp0;
-  int nscid;
+  unsigned char ns;
+  unsigned int n,x1,x2;
+  int nscid, reset;
   unsigned int nid;
-
-  /// to be updated from higher layer
-  //unsigned short lbar = 0;
+  NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
+  unsigned short l;
 
   for (nscid=0; nscid<2; nscid++) {
-    if (n_idDMRS)
-      nid = n_idDMRS[nscid];
-    else
-      nid = gNB->frame_parms.Nid_cell;
-      
-      //printf("gold pdsch nid %d lbar %d\n",nid,lbar);
-
-    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)+nscid)%(1<<31);  //cinit
-        
-                //printf("ns %d gold pdsch x2 %d\n",ns,x2);
-
-        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);
-        }
+    nid = Nid[nscid];
+    for (ns=0; ns<fp->slots_per_frame; ns++) {
+      for (l=0; l<fp->symbols_per_slot; l++) {
+        reset = 1;
+        x2 = ((1<<17) * (fp->symbols_per_slot*ns+l+1) * ((nid<<1)+1) +((nid<<1)+nscid));
+        LOG_D(PHY,"DMRS slot %d, symb %d x2 %x\n",ns,l,x2);
 
         for (n=0; n<NR_MAX_PUSCH_DMRS_INIT_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);
-          gNB->nr_gold_pusch[nscid][ns][l][n] = x1^x2;
-            // if ((ns==2)&&(l==0))
-            //printf("n=%d : c %x\n",n,x1^x2);
+          gNB->nr_gold_pusch_dmrs[nscid][ns][l][n] = lte_gold_generic(&x1, &x2, reset);
+          reset = 0;
         }
-
       }
     }
   }
-}
\ No newline at end of file
+}
diff --git a/openair1/PHY/NR_REFSIG/nr_gold_ue.c b/openair1/PHY/NR_REFSIG/nr_gold_ue.c
index 9793899dd43..39ab13b1f1e 100644
--- a/openair1/PHY/NR_REFSIG/nr_gold_ue.c
+++ b/openair1/PHY/NR_REFSIG/nr_gold_ue.c
@@ -100,7 +100,7 @@ void nr_gold_pdcch(PHY_VARS_NR_UE* ue,
           x2 = (x2>>1) ^ (x2>>2) ^ (x2>>3) ^ (x2>>4);
           x2 = x2 ^ (x2<<31) ^ (x2<<30) ^ (x2<<29) ^ (x2<<28);
           ue->nr_gold_pdcch[0][ns][l][n] = x1^x2;
-            //printf("n=%d : c %x\n",n,x1^x2);
+	  // if (ns==1 && l==0) printf("n=%d : c %x\n",n,x1^x2);
         }
       }
     }
@@ -133,7 +133,7 @@ void nr_gold_pdsch(PHY_VARS_NR_UE* ue,
 
     	x2tmp0 = ((14*ns+(lbar+l)+1)*((nid<<1)+1))<<17;
         x2 = (x2tmp0+(nid<<1)+nscid)%(1<<31);  //cinit
-        
+	LOG_D(PHY,"UE DMRS slot %d, symb %d, lbar %d, x2 %x, nscid %d\n",ns,l,lbar,x2,nscid);
                 //printf("ns %d gold pdsch x2 %d\n",ns,x2);
 
         x1 = 1+ (1<<31);
diff --git a/openair1/PHY/NR_REFSIG/nr_refsig.h b/openair1/PHY/NR_REFSIG/nr_refsig.h
index 754edfef64c..5af0e880999 100644
--- a/openair1/PHY/NR_REFSIG/nr_refsig.h
+++ b/openair1/PHY/NR_REFSIG/nr_refsig.h
@@ -39,7 +39,7 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB);
 void nr_init_pdcch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid);
 void nr_init_pdsch_dmrs(PHY_VARS_gNB* gNB, uint32_t Nid);
 
-void nr_gold_pusch(PHY_VARS_gNB* gNB, unsigned short lbar,unsigned short *n_idDMRS, unsigned short length_dmrs);
+void nr_gold_pusch(PHY_VARS_gNB* gNB, uint32_t *Nid);
 
 int nr_pusch_dmrs_rx(PHY_VARS_gNB *gNB,
                      unsigned int Ns,
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c
index 06e3948b64d..d62687bd9c4 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dci.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c
@@ -42,8 +42,7 @@
 
 uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format,
                          nfapi_nr_rnti_type_e rnti_type,
-                         uint16_t N_RB,
-                         nfapi_nr_config_request_t *config) {
+                         uint16_t N_RB) {
   uint16_t size = 0;
 
   switch(format) {
@@ -52,7 +51,7 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format,
       /// fixed: Format identifier 1, Hop flag 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2 Time Domain assgnmt 4 --20
       size += 20;
       size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment -- hopping scenario to be updated
-      size += nr_get_dci_size(NFAPI_NR_DL_DCI_FORMAT_1_0, rnti_type, N_RB, config) - size; // Padding to match 1_0 size
+      size += nr_get_dci_size(NFAPI_NR_DL_DCI_FORMAT_1_0, rnti_type, N_RB) - size; // Padding to match 1_0 size
       // UL/SUL indicator assumed to be 0
       break;
 
@@ -138,7 +137,6 @@ void nr_pdcch_scrambling(uint32_t *in,
   uint32_t x1, x2, s=0;
   reset = 1;
   x2 = (n_RNTI<<16) + Nid;
-
   for (int i=0; i<size; i++) {
     if ((i&0x1f)==0) {
       s = lte_gold_generic(&x1, &x2, reset);
@@ -151,193 +149,179 @@ void nr_pdcch_scrambling(uint32_t *in,
     }
 
     (*out) ^= ((((*in)>>(i&0x1f))&1) ^ ((s>>(i&0x1f))&1))<<(i&0x1f);
-    //printf("nr_pdcch_scrambling: in %d seq 0x%08x => out %d\n",((*in)>>(i&0x1f))&1,s,((*out)>>(i&0x1f))&1);
   }
 }
 
-uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc,
+
+uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu,
+			    nfapi_nr_ul_dci_request_pdus_t    *ul_dci_pdu,
                             uint32_t **gold_pdcch_dmrs,
                             int32_t *txdataF,
                             int16_t amp,
-                            NR_DL_FRAME_PARMS frame_parms,
-                            nfapi_nr_config_request_t config) {
+                            NR_DL_FRAME_PARMS frame_parms) {
+
   int16_t mod_dmrs[NR_MAX_CSET_DURATION][NR_MAX_PDCCH_DMRS_LENGTH>>1]; // 3 for the max coreset duration
   uint16_t cset_start_sc;
   uint8_t cset_start_symb, cset_nsymb;
   int k,l,k_prime,dci_idx, dmrs_idx;
-  nr_cce_t cce;
-  nr_reg_t reg;
-  nr_reg_t reg_mapping_list[NR_MAX_PDCCH_AGG_LEVEL*NR_NB_REG_PER_CCE];
-  nfapi_nr_dl_config_pdcch_parameters_rel15_t pdcch_params = dci_alloc.pdcch_params;
-
-  /*The coreset is initialised
-  * in frequency: the first subcarrier is obtained by adding the first CRB overlapping the SSB and the rb_offset for coreset 0
-  * or the rb_offset for other coresets
-  * in time: by its first slot and its first symbol*/
-  if (pdcch_params.config_type == NFAPI_NR_CSET_CONFIG_MIB_SIB1) {
-    cset_start_sc = frame_parms.first_carrier_offset + (frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB +
-                    pdcch_params.rb_offset)*NR_NB_SC_PER_RB;
-  } else
-    cset_start_sc = frame_parms.first_carrier_offset + pdcch_params.rb_offset*NR_NB_SC_PER_RB;
-
-  cset_start_symb = pdcch_params.first_symbol;
-  cset_nsymb = pdcch_params.n_symb;
-  dci_idx = 0;
-  LOG_D(PHY, "Coreset starting subcarrier %d on symbol %d (%d symbols)\n", cset_start_sc, cset_start_symb, cset_nsymb);
-  // DMRS length is per OFDM symbol
-  uint32_t dmrs_length = (pdcch_params.precoder_granularity == NFAPI_NR_CSET_ALL_CONTIGUOUS_RBS)?
-                         (pdcch_params.n_rb*6) : (dci_alloc.L*36/cset_nsymb); //2(QPSK)*3(per RB)*6(REG per CCE)
-  uint32_t encoded_length = dci_alloc.L*108; //2(QPSK)*9(per RB)*6(REG per CCE)
-  LOG_D(PHY, "DMRS length per symbol %d\t DCI encoded length %d\n", dmrs_length, encoded_length);
-  dmrs_length += pdcch_params.rb_offset*6; // To accommodate more DMRS symbols in case of rb offset
-
-  /// DMRS QPSK modulation
-  for (int symb=cset_start_symb; symb<cset_start_symb + pdcch_params.n_symb; symb++) {
-   
-    nr_modulation(gold_pdcch_dmrs[symb], dmrs_length, DMRS_MOD_ORDER, mod_dmrs[symb]); //Qm = 2 as DMRS is QPSK modulated
+  /*First iteration: single DCI*/
 
-#ifdef DEBUG_PDCCH_DMRS
+  nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15=NULL;
 
-    for (int i=0; i<dmrs_length>>1; i++)
-        printf("symb %d i %d gold seq 0x%08x mod_dmrs %d %d\n", symb, i,
-               gold_pdcch_dmrs[symb][i>>5], mod_dmrs[symb][i<<1], mod_dmrs[symb][(i<<1)+1] );
 
-#endif
-  }
+  // find coreset descriptor
+    
+  int rb_offset;
+  int n_rb;
 
-  /// DCI payload processing
-  // CRC attachment + Scrambling + Channel coding + Rate matching
-  uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD];
-  uint16_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti:0;
-  uint16_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)?
-                 pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value;
-  t_nrPolar_params *currentPtr = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, dci_alloc.L);
-  polar_encoder_fast(dci_alloc.dci_pdu, encoder_output, pdcch_params.rnti, 1, currentPtr);
-#ifdef DEBUG_CHANNEL_CODING
-  printf("polar rnti %d\n",pdcch_params.rnti);
-  printf("DCI PDU: [0]->0x%lx \t [1]->0x%lx\n",
-         dci_alloc.dci_pdu[0], dci_alloc.dci_pdu[1]);
-  printf("Encoded Payload (length:%d dwords):\n", encoded_length>>5);
+  AssertFatal(pdcch_pdu!=NULL || ul_dci_pdu!=NULL,"At least one pointer has to be !NULL\n");
+  AssertFatal(pdcch_pdu==NULL || ul_dci_pdu==NULL,"Can't handle both DL and UL DCI in same slot\n");
+
+
+  if (pdcch_pdu) pdcch_pdu_rel15 = &pdcch_pdu->pdcch_pdu_rel15;
+  else if (ul_dci_pdu) pdcch_pdu_rel15 = &ul_dci_pdu->pdcch_pdu.pdcch_pdu_rel15;
 
-  for (int i=0; i<encoded_length>>5; i++)
-    printf("[%d]->0x%08x \t", i,encoder_output[i]);
+  get_coreset_rballoc(pdcch_pdu_rel15->FreqDomainResource,&n_rb,&rb_offset);
 
-  printf("\n");
+  // compute rb_offset and n_prb based on frequency allocation
+
+  if (pdcch_pdu_rel15->CoreSetType == NFAPI_NR_CSET_CONFIG_MIB_SIB1) {
+    cset_start_sc = frame_parms.first_carrier_offset + (frame_parms.ssb_start_subcarrier/NR_NB_SC_PER_RB +
+							rb_offset)*NR_NB_SC_PER_RB;
+  } else
+    cset_start_sc = frame_parms.first_carrier_offset + rb_offset*NR_NB_SC_PER_RB;
+
+  for (int d=0;d<pdcch_pdu_rel15->numDlDci;d++) {
+    /*The coreset is initialised
+     * in frequency: the first subcarrier is obtained by adding the first CRB overlapping the SSB and the rb_offset for coreset 0
+     * or the rb_offset for other coresets
+     * in time: by its first slot and its first symbol*/
+
+    cset_start_symb = pdcch_pdu_rel15->StartSymbolIndex;
+    cset_nsymb = pdcch_pdu_rel15->DurationSymbols;
+    dci_idx = 0;
+    LOG_D(PHY, "Coreset rb_offset %d, nb_rb %d\n",rb_offset,n_rb);
+    LOG_D(PHY, "Coreset starting subcarrier %d on symbol %d (%d symbols)\n", cset_start_sc, cset_start_symb, cset_nsymb);
+    // DMRS length is per OFDM symbol
+    AssertFatal(pdcch_pdu_rel15->CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED,
+		"Interleaved CCE REG MAPPING not supported\n");
+    uint32_t dmrs_length = (pdcch_pdu_rel15->CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED)?
+      (n_rb*6) : (pdcch_pdu_rel15->AggregationLevel[d]*36/cset_nsymb); //2(QPSK)*3(per RB)*6(REG per CCE)
+    uint32_t encoded_length = pdcch_pdu_rel15->AggregationLevel[d]*108; //2(QPSK)*9(per RB)*6(REG per CCE)
+    LOG_D(PHY, "DMRS length per symbol %d\t DCI encoded length %d (precoder_granularity %d,reg_mapping %d)\n", dmrs_length, encoded_length,pdcch_pdu_rel15->precoderGranularity,pdcch_pdu_rel15->CceRegMappingType);
+    dmrs_length += rb_offset*6; // To accommodate more DMRS symbols in case of rb offset
+      
+    /// DMRS QPSK modulation
+    for (int symb=cset_start_symb; symb<cset_start_symb + pdcch_pdu_rel15->DurationSymbols; symb++) {
+      
+      nr_modulation(gold_pdcch_dmrs[symb], dmrs_length, DMRS_MOD_ORDER, mod_dmrs[symb]); //Qm = 2 as DMRS is QPSK modulated
+      
+#ifdef DEBUG_PDCCH_DMRS
+      
+      for (int i=0; i<dmrs_length>>1; i++)
+	printf("symb %d i %d gold seq 0x%08x mod_dmrs %d %d\n", symb, i,
+	       gold_pdcch_dmrs[symb][i>>5], mod_dmrs[symb][i<<1], mod_dmrs[symb][(i<<1)+1] );
+      
+#endif
+    }
+    
+    /// DCI payload processing
+    // CRC attachment + Scrambling + Channel coding + Rate matching
+    uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD];
+    uint16_t n_RNTI = pdcch_pdu_rel15->RNTI[d];
+    uint16_t Nid    = pdcch_pdu_rel15->ScramblingId[d];
+    
+    t_nrPolar_params *currentPtr = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, 
+						   pdcch_pdu_rel15->PayloadSizeBits[d], 
+						   pdcch_pdu_rel15->AggregationLevel[d],
+						   0,NULL);
+    polar_encoder_fast((uint64_t*)pdcch_pdu_rel15->Payload[d], encoder_output, n_RNTI,1,currentPtr);
+#ifdef DEBUG_CHANNEL_CODING
+    printf("polar rnti %x,length %d, L %d\n",n_RNTI, pdcch_pdu_rel15->PayloadSizeBits[d],pdcch_pdu_rel15->AggregationLevel[d]);
+    printf("DCI PDU: [0]->0x%lx \t [1]->0x%lx\n",
+	   ((uint64_t*)pdcch_pdu_rel15->Payload[d])[0], ((uint64_t*)pdcch_pdu_rel15->Payload[d])[1]);
+    printf("Encoded Payload (length:%d dwords):\n", encoded_length>>5);
+    
+    for (int i=0; i<encoded_length>>5; i++)
+      printf("[%d]->0x%08x \t", i,encoder_output[i]);    
+
+    printf("\n");
 #endif
-  /// Scrambling
-  uint32_t scrambled_output[NR_MAX_DCI_SIZE_DWORD]= {0};
-  nr_pdcch_scrambling(encoder_output, encoded_length, Nid, n_RNTI, scrambled_output);
+    /// Scrambling
+    uint32_t scrambled_output[NR_MAX_DCI_SIZE_DWORD]= {0};
+    nr_pdcch_scrambling(encoder_output, encoded_length, Nid, n_RNTI, scrambled_output);
 #ifdef DEBUG_CHANNEL_CODING
-  printf("scrambled output: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\t [4]->0x%08x\t [5]->0x%08x\t \
+    printf("scrambled output: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\t [4]->0x%08x\t [5]->0x%08x\t \
 [6]->0x%08x \t [7]->0x%08x \t [8]->0x%08x \t [9]->0x%08x\t [10]->0x%08x\t [11]->0x%08x\n",
-         scrambled_output[0], scrambled_output[1], scrambled_output[2], scrambled_output[3], scrambled_output[4],scrambled_output[5],
-         scrambled_output[6], scrambled_output[7], scrambled_output[8], scrambled_output[9], scrambled_output[10],scrambled_output[11] );
+	   scrambled_output[0], scrambled_output[1], scrambled_output[2], scrambled_output[3], scrambled_output[4],scrambled_output[5],
+	   scrambled_output[6], scrambled_output[7], scrambled_output[8], scrambled_output[9], scrambled_output[10],scrambled_output[11] );
 #endif
-  /// QPSK modulation
-  int16_t mod_dci[NR_MAX_DCI_SIZE>>1];
-  nr_modulation(scrambled_output, encoded_length, DMRS_MOD_ORDER, mod_dci); //Qm = 2 as DMRS is QPSK modulated
+    /// QPSK modulation
+    int16_t mod_dci[NR_MAX_DCI_SIZE>>1];
+    nr_modulation(scrambled_output, encoded_length, DMRS_MOD_ORDER, mod_dci); //Qm = 2 as DMRS is QPSK modulated
 #ifdef DEBUG_DCI
-
-  for (int i=0; i<encoded_length>>1; i++)
-    printf("i %d mod_dci %d %d\n", i, mod_dci[i<<1], mod_dci[(i<<1)+1] );
-
+    
+    for (int i=0; i<encoded_length>>1; i++)
+      printf("i %d mod_dci %d %d\n", i, mod_dci[i<<1], mod_dci[(i<<1)+1] );
+    
 #endif
-
-  /// Resource mapping
-
-  if (cset_start_sc >= frame_parms.ofdm_symbol_size)
-    cset_start_sc -= frame_parms.ofdm_symbol_size;
-
-  /*Reorder REG list for a freq first mapping*/
-  uint8_t nb_regs = dci_alloc.L*NR_NB_REG_PER_CCE;
-
-  for (int cce_idx=0; cce_idx<dci_alloc.L; cce_idx++) {
-    cce = dci_alloc.cce_list[cce_idx];
-
-    for (int reg_idx=0; reg_idx<NR_NB_REG_PER_CCE; reg_idx++) {
-      reg = cce.reg_list[reg_idx];
-      reg_mapping_list[reg_idx+cce_idx*NR_NB_REG_PER_CCE] = reg;
-    }
-  }
-
-
-  if (pdcch_params.precoder_granularity == NFAPI_NR_CSET_ALL_CONTIGUOUS_RBS) {
-    /*in this case the DMRS are mapped on all the coreset*/
-    for (l=cset_start_symb; l<cset_start_symb+ cset_nsymb; l++) {
-
+    
+    /// Resource mapping
+    
+    if (cset_start_sc >= frame_parms.ofdm_symbol_size)
+      cset_start_sc -= frame_parms.ofdm_symbol_size;
+    
+    /*Reorder REG list for a freq first mapping*/
+    uint8_t nb_regs = pdcch_pdu_rel15->AggregationLevel[d]*NR_NB_REG_PER_CCE;
+    uint8_t reg_idx0 = pdcch_pdu_rel15->CceIndex[d]*NR_NB_REG_PER_CCE;
+
+    /*Mapping the encoded DCI along with the DMRS */
+    for (int reg_idx=reg_idx0; reg_idx<(nb_regs+reg_idx0); reg_idx++) {
+      k = cset_start_sc + (12*reg_idx/cset_nsymb);
+      
+      if (k >= frame_parms.ofdm_symbol_size)
+	k -= frame_parms.ofdm_symbol_size;
+      
+      l = cset_start_symb + ((reg_idx/cset_nsymb)%cset_nsymb);
+      
       // dmrs index depends on reference point for k according to 38.211 7.4.1.3.2
-      if (pdcch_params.config_type == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG)
-        dmrs_idx = 0;
+      if (pdcch_pdu_rel15->CoreSetType == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG)
+	dmrs_idx = (reg_idx/cset_nsymb)*3;
       else
-        dmrs_idx = pdcch_params.rb_offset*3;
-
-      k = cset_start_sc + 1;
-
-      while (dmrs_idx<3*pdcch_params.n_rb) {
-        ((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1]       = ((amp>>1) * mod_dmrs[l][dmrs_idx<<1]) >> 15;
-        ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = ((amp>>1) * mod_dmrs[l][(dmrs_idx<<1) + 1]) >> 15;
+	dmrs_idx = ((reg_idx/cset_nsymb)+rb_offset)*3;
+      
+      k_prime = 0;
+      
+      for (int m=0; m<NR_NB_SC_PER_RB; m++) {
+	if ( m == (k_prime<<2)+1) { // DMRS if not already mapped
+	  if (pdcch_pdu_rel15->CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED) {
+	    ((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1]       = (2*amp * mod_dmrs[l][dmrs_idx<<1]) >> 15;
+	    ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (2*amp * mod_dmrs[l][(dmrs_idx<<1) + 1]) >> 15;
 #ifdef DEBUG_PDCCH_DMRS
-        printf("symbol %d position %d => (%d,%d)\n",l,k,((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1],
-               ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1)+1]);
+	    printf("PDCCH DMRS: l %d position %d => (%d,%d)\n",l,k,((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1],
+		   ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1)+1]);
 #endif
-        k+=4;
-
-        if (k >= frame_parms.ofdm_symbol_size)
-          k -= frame_parms.ofdm_symbol_size;
-
-        dmrs_idx++;
-      }
-    }
-  }
-
-  /*Now mapping the encoded DCI based on newly constructed REG list
-   * and the DMRS for the precoder granularity same as REG bundle*/
-  for (int reg_idx=0; reg_idx<nb_regs; reg_idx++) {
-    reg = reg_mapping_list[reg_idx];
-    k = cset_start_sc + reg.start_sc_idx;
-
-    if (k >= frame_parms.ofdm_symbol_size)
-      k -= frame_parms.ofdm_symbol_size;
-
-    l = cset_start_symb + reg.symb_idx;
-
-    // dmrs index depends on reference point for k according to 38.211 7.4.1.3.2
-    if (pdcch_params.config_type == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG)
-      dmrs_idx = (reg.reg_idx/cset_nsymb)*3;
-    else
-      dmrs_idx = ((reg.reg_idx/cset_nsymb)+pdcch_params.rb_offset)*3;
-
-    k_prime = 0;
-
-    for (int m=0; m<NR_NB_SC_PER_RB; m++) {
-      if ( m == (k_prime<<2)+1) { // DMRS if not already mapped
-        if (pdcch_params.precoder_granularity == NFAPI_NR_CSET_SAME_AS_REG_BUNDLE) {
-          ((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1]       = ((amp>>1) * mod_dmrs[l][dmrs_idx<<1]) >> 15;
-          ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = ((amp>>1) * mod_dmrs[l][(dmrs_idx<<1) + 1]) >> 15;
-#ifdef DEBUG_PDCCH_DMRS
-          printf("l %d position %d => (%d,%d)\n",l,k,((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1],
-                 ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1)+1]);
-#endif
-          dmrs_idx++;
-        }
-
-        k_prime++;
-      } else { // DCI payload
-        ((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1]       = (amp * mod_dci[dci_idx<<1]) >> 15;
-        ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (amp * mod_dci[(dci_idx<<1) + 1]) >> 15;
+	    dmrs_idx++;
+	  }
+	  
+	  k_prime++;
+	} else { // DCI payload
+	  ((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1]       = (amp * mod_dci[dci_idx<<1]) >> 15;
+	  ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1) + 1] = (amp * mod_dci[(dci_idx<<1) + 1]) >> 15;
 #ifdef DEBUG_DCI
-        printf("l %d position %d => (%d,%d)\n",l,k,((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1],
-               ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1)+1]);
+	  printf("PDCCH: l %d position %d => (%d,%d)\n",l,k,((int16_t *)txdataF)[(l*frame_parms.ofdm_symbol_size + k)<<1],
+		 ((int16_t *)txdataF)[((l*frame_parms.ofdm_symbol_size + k)<<1)+1]);
 #endif
-        dci_idx++;
-      }
-
-      k++;
-
-      if (k >= frame_parms.ofdm_symbol_size)
-        k -= frame_parms.ofdm_symbol_size;
-    }
-  }
-
+	  dci_idx++;
+	}
+	
+	k++;
+	
+	if (k >= frame_parms.ofdm_symbol_size)
+	  k -= frame_parms.ofdm_symbol_size;
+      } // m
+    } // reg_idx
+  } // for (int d=0;d<pdcch_pdu_rel15->numDlDci;d++)
   return 0;
 }
+
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h
index d1a0eb7a23e..047139aa633 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dci.h
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h
@@ -27,15 +27,14 @@
 
 uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format,
                          nfapi_nr_rnti_type_e rnti_type,
-                         uint16_t N_RB,
-                         nfapi_nr_config_request_t *config);
+                         uint16_t N_RB);
 
-uint8_t nr_generate_dci_top(NR_gNB_DCI_ALLOC_t dci_alloc,
+uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu,
+			    nfapi_nr_ul_dci_request_pdus_t *ul_dci_pdu,
                             uint32_t **gold_pdcch_dmrs,
                             int32_t *txdataF,
                             int16_t amp,
-                            NR_DL_FRAME_PARMS frame_parms,
-                            nfapi_nr_config_request_t config);
+                            NR_DL_FRAME_PARMS frame_parms);
 
 void nr_pdcch_scrambling(uint32_t *in,
                          uint32_t size,
@@ -45,11 +44,14 @@ void nr_pdcch_scrambling(uint32_t *in,
 
 void nr_fill_dci(PHY_VARS_gNB *gNB,
                  int frame,
-                 int slot,
-                 NR_gNB_DCI_ALLOC_t *dci_alloc,
-                 nfapi_nr_dl_config_dci_dl_pdu *pdu);
+                 int slot);
 
-void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t *dci_alloc, uint16_t n_shift, uint8_t m);
+void nr_fill_ul_dci(PHY_VARS_gNB *gNB,
+		    int frame,
+		    int slot);
 
+void nr_fill_cce_list(PHY_VARS_gNB *gNB, uint8_t m);
+
+void get_coreset_rballoc(uint8_t *FreqDomainResource,int *n_rb,int *rb_offset);
 
 #endif //__PHY_NR_TRANSPORT_DCI__H
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c
index c33e5fd34b1..ccec73d40e9 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c
@@ -36,11 +36,14 @@
 
 #include "nr_dlsch.h"
 
-void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m) {
+/*
+  Original version to keep code for Y that needs to be moved to MAC
+
+void nr_fill_cce_list(PHY_VARS_gNB *gNB, uint16_t n_shift, uint8_t m) {
 
   nr_cce_t* cce;
   nr_reg_t* reg;
-  nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params = &dci_alloc->pdcch_params;
+  nfapi_nr_dl_config_pdcch_pdu_rel15_t* pdcch_pdu = gNB->pdcch_pdu.pdcch;
 
   uint8_t L = dci_alloc->L;
   uint8_t bsize = pdcch_params->reg_bundle_size;
@@ -54,7 +57,7 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m
     AssertFatal(L>=4, "Invalid aggregation level for SIB1 configured PDCCH %d\n", L);
 
   N_cce = N_reg / NR_NB_REG_PER_CCE;
-  /*Max number of candidates per aggregation level -- SIB1 configured search space only*/
+  //Max number of candidates per aggregation level -- SIB1 configured search space only
   M_s_max = (L==4)?4:(L==8)?2:1;
 
   if (pdcch_params->search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_COMMON)
@@ -113,6 +116,84 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m
   }
 }
 
+*/
+
+void nr_fill_cce_list(PHY_VARS_gNB *gNB, uint8_t m) {
+
+  nr_cce_t* cce;
+  nr_reg_t* reg;
+  nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu_rel15 = &gNB->pdcch_pdu->pdcch_pdu_rel15;
+  int bsize = pdcch_pdu_rel15->RegBundleSize;
+  int R = pdcch_pdu_rel15->InterleaverSize;
+  int n_shift = pdcch_pdu_rel15->ShiftIndex;
+
+
+  //Max number of candidates per aggregation level -- SIB1 configured search space only
+
+
+  int n_rb,rb_offset;
+
+  get_coreset_rballoc(pdcch_pdu_rel15->FreqDomainResource,&n_rb,&rb_offset);
+
+
+  int N_reg = n_rb * pdcch_pdu_rel15->DurationSymbols;
+  int C;
+
+  for (int d=0;d<pdcch_pdu_rel15->numDlDci;d++) {
+    int  L = pdcch_pdu_rel15->AggregationLevel[d];
+
+    if (pdcch_pdu_rel15->CoreSetType == NFAPI_NR_CSET_CONFIG_MIB_SIB1)
+      AssertFatal(L>=4, "Invalid aggregation level for SIB1 configured PDCCH %d\n", L);
+    
+    if (pdcch_pdu_rel15->CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) {
+      uint16_t assertFatalCond = (N_reg%(bsize*R));
+      AssertFatal(assertFatalCond == 0,"CCE to REG interleaving: Invalid configuration leading to non integer C (N_reg %us, bsize %d R %d)\n",N_reg, bsize, R);
+      C = N_reg/(bsize*R);
+    }
+    
+    LOG_D(PHY, "CCE list generation for candidate %d: bundle size %d ilv size %d CceIndex %d\n", m, bsize, R, pdcch_pdu_rel15->CceIndex[d]);
+    for (uint8_t cce_idx=0; cce_idx<L; cce_idx++) {
+      cce = &gNB->cce_list[d][cce_idx];
+      cce->cce_idx = pdcch_pdu_rel15->CceIndex[d] + cce_idx;
+      LOG_D(PHY, "cce_idx %d\n", cce->cce_idx);
+      
+      if (pdcch_pdu_rel15->CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) {
+	LOG_D(PHY, "Interleaved CCE to REG mapping\n");
+	uint8_t j = cce->cce_idx, j_prime;
+	uint8_t r,c,idx;
+	
+	for (uint8_t bundle_idx=0; bundle_idx<NR_NB_REG_PER_CCE/bsize; bundle_idx++) {
+	  j_prime = 6*j/bsize + bundle_idx;
+	  r = j_prime%R;
+	  c = (j_prime-r)/R;
+	  idx = (r*C + c + n_shift)%(N_reg/bsize);
+	  LOG_D(PHY, "bundle idx = %d \n j = %d \t j_prime = %d \t r = %d \t c = %d\n", idx, j , j_prime, r, c);
+	  
+	  for (uint8_t reg_idx=0; reg_idx<bsize; reg_idx++) {
+	    reg = &cce->reg_list[reg_idx];
+	    reg->reg_idx = bsize*idx + reg_idx;
+	    reg->start_sc_idx = (reg->reg_idx/pdcch_pdu_rel15->DurationSymbols) * NR_NB_SC_PER_RB;
+	    reg->symb_idx = reg->reg_idx % pdcch_pdu_rel15->DurationSymbols;
+	    LOG_D(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx);
+	  }
+	}
+      }
+      else { // NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED
+	LOG_D(PHY, "Non interleaved CCE to REG mapping\n");
+	for (uint8_t reg_idx=0; reg_idx<NR_NB_REG_PER_CCE; reg_idx++) {
+	  reg = &cce->reg_list[reg_idx];
+	  reg->reg_idx = cce->cce_idx*NR_NB_REG_PER_CCE + reg_idx;
+	  reg->start_sc_idx = (reg->reg_idx/pdcch_pdu_rel15->DurationSymbols) * NR_NB_SC_PER_RB;
+	  reg->symb_idx = reg->reg_idx % pdcch_pdu_rel15->DurationSymbols;
+	  LOG_D(PHY, "reg %d symbol %d start subcarrier %d\n", reg->reg_idx, reg->symb_idx, reg->start_sc_idx);
+	}
+	
+      }
+      
+    }
+  }
+}
+
 /*static inline uint64_t dci_field(uint64_t field, uint8_t size) {
   uint64_t ret = 0;
   for (int i=0; i<size; i++)
@@ -122,394 +203,60 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m
 
 void nr_fill_dci(PHY_VARS_gNB *gNB,
                  int frame,
-                 int slot,
-                 NR_gNB_DCI_ALLOC_t *dci_alloc,
-                 nfapi_nr_dl_config_dci_dl_pdu *pdcch_pdu) {
+                 int slot) {
 
-  uint8_t n_shift;
+  nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &gNB->pdcch_pdu->pdcch_pdu_rel15;
+  NR_gNB_DLSCH_t *dlsch; 
 
+  for (int i=0;i<pdcch_pdu_rel15->numDlDci;i++) {
 
-  uint64_t *dci_pdu = (uint64_t*)dci_alloc->dci_pdu;
-  memset((void*)dci_pdu,0,2*sizeof(uint64_t));
-  nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &pdcch_pdu->dci_dl_pdu_rel15;
-  nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &pdcch_pdu->pdcch_params_rel15;
+    uint64_t *dci_pdu = (uint64_t*)pdcch_pdu_rel15->Payload[i];
 
 
-  nfapi_nr_config_request_t *cfg = &gNB->gNB_config;
-  NR_gNB_DLSCH_t *dlsch; 
+    int dlsch_id = find_nr_dlsch(pdcch_pdu_rel15->RNTI[i],gNB,SEARCH_EXIST_OR_FREE);
+    if( (dlsch_id<0) || (dlsch_id>=NUMBER_OF_NR_DLSCH_MAX) ){
+      LOG_E(PHY,"illegal dlsch_id found!!! rnti %04x dlsch_id %d\n",(unsigned int)pdcch_pdu_rel15->RNTI[i],dlsch_id);
+      return;
+    }
+    
+    dlsch = gNB->dlsch[dlsch_id][0];
+    int harq_pid = 0;//extract_harq_pid(i,pdu_rel15);
+
+    dlsch->slot_tx[slot]             = 1;
+    dlsch->harq_ids[frame%2][slot]   = harq_pid;
+    AssertFatal(harq_pid < 8 && harq_pid >= 0,
+		"illegal harq_pid %d\n",harq_pid);
+    
+    dlsch->harq_mask                |= (1<<harq_pid);
+    dlsch->rnti                      = pdcch_pdu_rel15->RNTI[i];
+    
+    nr_fill_cce_list(gNB,0);  
+    /*
+    LOG_D(PHY, "DCI PDU: [0]->0x%lx \t [1]->0x%lx \n",dci_pdu[0], dci_pdu[1]);
+    LOG_D(PHY, "DCI type %d payload (size %d) generated on candidate %d\n", dci_alloc->pdcch_params.dci_format, dci_alloc->size, cand_idx);
+    */
 
+  }
 
-  uint16_t N_RB = params_rel15->n_RB_BWP;
-  uint8_t fsize=0, pos=0, cand_idx=0;
+}
+void nr_fill_ul_dci(PHY_VARS_gNB *gNB,
+		    int frame,
+		    int slot) {
 
+  nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &gNB->ul_dci_pdu->pdcch_pdu.pdcch_pdu_rel15;
 
 
-  int dlsch_id = find_nr_dlsch(params_rel15->rnti,gNB,SEARCH_EXIST_OR_FREE);
-  if( (dlsch_id<0) || (dlsch_id>=NUMBER_OF_NR_DLSCH_MAX) ){
-    LOG_E(PHY,"illegal dlsch_id found!!! rnti %04x dlsch_id %d\n",params_rel15->rnti,dlsch_id);
-    return;
-  }
+  for (int i=0;i<pdcch_pdu_rel15->numDlDci;i++) {
 
-  dlsch = gNB->dlsch[dlsch_id][0];
-
-  dlsch->slot_tx[slot]             = 1;
-  dlsch->harq_ids[frame%2][slot]   = pdu_rel15->harq_pid;
-  AssertFatal(pdu_rel15->harq_pid < 8 && pdu_rel15->harq_pid >= 0,
-	      "illegal harq_pid %d\n",pdu_rel15->harq_pid);
-
-  dlsch->harq_mask                |= (1<<pdu_rel15->harq_pid);
-  dlsch->rnti                      = params_rel15->rnti;
-
-  dci_alloc->L = 8;
-  memcpy((void*)&dci_alloc->pdcch_params, (void*)params_rel15, sizeof(nfapi_nr_dl_config_pdcch_parameters_rel15_t));
-  dci_alloc->size = nr_get_dci_size(dci_alloc->pdcch_params.dci_format,
-				    dci_alloc->pdcch_params.rnti_type,
-				    N_RB,
-				    cfg);
-
-  AssertFatal(dci_alloc->size<=64, "DCI sizes above 64 bits not yet supported");
-  n_shift = (dci_alloc->pdcch_params.config_type == NFAPI_NR_CSET_CONFIG_MIB_SIB1)?
-    cfg->sch_config.physical_cell_id.value : dci_alloc->pdcch_params.shift_index;
-  nr_fill_cce_list(dci_alloc, n_shift, cand_idx);
-
-  /// Payload generation
-  switch(params_rel15->dci_format) {
-
-
-  case NFAPI_NR_DL_DCI_FORMAT_1_0:
-    switch(params_rel15->rnti_type) {
-    case NFAPI_NR_RNTI_RA:
-
-      // Freq domain assignment
-      fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
-      pos=fsize;
-      *dci_pdu |= ((pdu_rel15->frequency_domain_assignment&((1<<fsize)-1)) << (dci_alloc->size-pos));
-#ifdef DEBUG_FILL_DCI
-      printf("frequency-domain assignment %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->frequency_domain_assignment,fsize,dci_alloc->size-pos,*dci_pdu);
-#endif
-      // Time domain assignment
-      pos+=4;
-      *dci_pdu |= (((uint64_t)pdu_rel15->time_domain_assignment&0xf) << (dci_alloc->size-pos));
-#ifdef DEBUG_FILL_DCI
-      printf("time-domain assignment %d  (3 bits)=> %d (0x%lx)\n",pdu_rel15->time_domain_assignment,dci_alloc->size-pos,*dci_pdu);
-#endif
-      // VRB to PRB mapping
-
-      pos++;
-      *dci_pdu |= ((uint64_t)pdu_rel15->vrb_to_prb_mapping&0x1)<<(dci_alloc->size-pos);
-#ifdef DEBUG_FILL_DCI
-      printf("vrb to prb mapping %d  (1 bits)=> %d (0x%lx)\n",pdu_rel15->vrb_to_prb_mapping,dci_alloc->size-pos,*dci_pdu);
-#endif
-      // MCS
-      pos+=5;
-      *dci_pdu |= ((uint64_t)pdu_rel15->mcs&0x1f)<<(dci_alloc->size-pos);
-#ifdef DEBUG_FILL_DCI
-      printf("mcs %d  (5 bits)=> %d (0x%lx)\n",pdu_rel15->mcs,dci_alloc->size-pos,*dci_pdu);
-#endif
-      // TB scaling
-      pos+=2;
-      *dci_pdu |= ((uint64_t)pdu_rel15->tb_scaling&0x3)<<(dci_alloc->size-pos);
-#ifdef DEBUG_FILL_DCI
-      printf("tb_scaling %d  (2 bits)=> %d (0x%lx)\n",pdu_rel15->tb_scaling,dci_alloc->size-pos,*dci_pdu);
-#endif
-      break;
-
-    case NFAPI_NR_RNTI_C:
-
-      // indicating a DL DCI format 1bit
-      pos++;
-      *dci_pdu |= ((uint64_t)pdu_rel15->format_indicator&1)<<(dci_alloc->size-pos);
-#ifdef DEBUG_FILL_DCI
-      printf("Format indicator %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->format_indicator,1,dci_alloc->size-pos,*dci_pdu);
-#endif
-
-      // Freq domain assignment (275rb >> fsize = 16)
-      fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
-      pos+=fsize;
-      *dci_pdu |= (((uint64_t)pdu_rel15->frequency_domain_assignment&((1<<fsize)-1)) << (dci_alloc->size-pos));
-
-#ifdef DEBUG_FILL_DCI
-      printf("Freq domain assignment %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->frequency_domain_assignment,fsize,dci_alloc->size-pos,*dci_pdu);
-#endif
-
-  uint16_t is_ra = 1;
-  for (int i=0; i<fsize; i++)
-    if (!((pdu_rel15->frequency_domain_assignment>>i)&1)) {
-      is_ra = 0;
-      break;
-    }
-  if (is_ra) //fsize are all 1  38.212 p86
-	{
-	  // ra_preamble_index 6 bits
-	  pos+=6;
-	  *dci_pdu |= ((pdu_rel15->ra_preamble_index&0x3f)<<(dci_alloc->size-pos));
-
-	  // UL/SUL indicator  1 bit
-	  pos++;
-	  *dci_pdu |= (pdu_rel15->ul_sul_indicator&1)<<(dci_alloc->size-pos);
-
-	  // SS/PBCH index  6 bits
-	  pos+=6;
-	  *dci_pdu |= ((pdu_rel15->ss_pbch_index&0x3f)<<(dci_alloc->size-pos));
-
-	  //  prach_mask_index  4 bits
-	  pos+=4;
-	  *dci_pdu |= ((pdu_rel15->prach_mask_index&0xf)<<(dci_alloc->size-pos));
-
-	}  //end if
-
-      else {
-
-	// Time domain assignment 4bit
-
-	pos+=4;
-	*dci_pdu |= ((pdu_rel15->time_domain_assignment&0xf) << (dci_alloc->size-pos));
-#ifdef DEBUG_FILL_DCI
-      printf("Time domain assignment %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->time_domain_assignment,4,dci_alloc->size-pos,*dci_pdu);
-#endif
-
-	// VRB to PRB mapping  1bit
-	pos++;
-	*dci_pdu |= (pdu_rel15->vrb_to_prb_mapping&1)<<(dci_alloc->size-pos);
-#ifdef DEBUG_FILL_DCI
-      printf("VRB to PRB %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->vrb_to_prb_mapping,1,dci_alloc->size-pos,*dci_pdu);
-#endif
-
-	// MCS 5bit  //bit over 32, so dci_pdu ++
-	pos+=5;
-	*dci_pdu |= (pdu_rel15->mcs&0x1f)<<(dci_alloc->size-pos);
-#ifdef DEBUG_FILL_DCI
-      printf("MCS %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->mcs,5,dci_alloc->size-pos,*dci_pdu);
-#endif
-
-	// New data indicator 1bit
-	pos++;
-	*dci_pdu |= (pdu_rel15->ndi&1)<<(dci_alloc->size-pos);
-#ifdef DEBUG_FILL_DCI
-      printf("NDI %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->ndi,1,dci_alloc->size-pos,*dci_pdu);
-#endif
-
-	// Redundancy version  2bit
-	pos+=2;
-	*dci_pdu |= (pdu_rel15->rv&0x3)<<(dci_alloc->size-pos);
-#ifdef DEBUG_FILL_DCI
-      printf("RV %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->rv,2,dci_alloc->size-pos,*dci_pdu);
-#endif
-
-	// HARQ process number  4bit
-	pos+=4;
-	*dci_pdu  |= ((pdu_rel15->harq_pid&0xf)<<(dci_alloc->size-pos));
-#ifdef DEBUG_FILL_DCI
-      printf("HARQ_PID %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->harq_pid,4,dci_alloc->size-pos,*dci_pdu);
-#endif
-
-	// Downlink assignment index  2bit
-	pos+=2;
-	*dci_pdu |= ((pdu_rel15->dai&3)<<(dci_alloc->size-pos));
-#ifdef DEBUG_FILL_DCI
-      printf("DAI %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->dai,2,dci_alloc->size-pos,*dci_pdu);
-#endif
-
-	// TPC command for scheduled PUCCH  2bit
-	pos+=2;
-	*dci_pdu |= ((pdu_rel15->tpc&3)<<(dci_alloc->size-pos));
-#ifdef DEBUG_FILL_DCI
-      printf("TPC %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->tpc,2,dci_alloc->size-pos,*dci_pdu);
-#endif
-
-	// PUCCH resource indicator  3bit
-	pos+=3;
-	*dci_pdu |= ((pdu_rel15->pucch_resource_indicator&0x7)<<(dci_alloc->size-pos));
-#ifdef DEBUG_FILL_DCI
-      printf("PUCCH RI %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->pucch_resource_indicator,3,dci_alloc->size-pos,*dci_pdu);
-#endif
-
-	// PDSCH-to-HARQ_feedback timing indicator 3bit
-	pos+=3;
-	*dci_pdu |= ((pdu_rel15->pdsch_to_harq_feedback_timing_indicator&0x7)<<(dci_alloc->size-pos));
-#ifdef DEBUG_FILL_DCI
-      printf("PDSCH to HARQ TI %d (%d bits)=> %d (0x%lx)\n",pdu_rel15->pdsch_to_harq_feedback_timing_indicator,3,dci_alloc->size-pos,*dci_pdu);
-#endif
-
-      } //end else
-      break;
-
-    case NFAPI_NR_RNTI_P:
-
-      // Short Messages Indicator – 2 bits
-      for (int i=0; i<2; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->short_messages_indicator>>(1-i))&1)<<(dci_alloc->size-pos++);
-      // Short Messages – 8 bits
-      for (int i=0; i<8; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->short_messages>>(7-i))&1)<<(dci_alloc->size-pos++);
-      // Freq domain assignment 0-16 bit
-      fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
-      for (int i=0; i<fsize; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_alloc->size-pos++);
-      // Time domain assignment 4 bit
-      for (int i=0; i<4; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_alloc->size-pos++);
-      // VRB to PRB mapping 1 bit
-      *dci_pdu |= ((uint64_t)pdu_rel15->vrb_to_prb_mapping&1)<<(dci_alloc->size-pos++);
-      // MCS 5 bit
-      for (int i=0; i<5; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->mcs>>(4-i))&1)<<(dci_alloc->size-pos++);
-
-      // TB scaling 2 bit
-      for (int i=0; i<2; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->tb_scaling>>(1-i))&1)<<(dci_alloc->size-pos++);
-
-
-      break;
-
-    case NFAPI_NR_RNTI_SI:
-      // Freq domain assignment 0-16 bit
-      fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
-      for (int i=0; i<fsize; i++)
-	*dci_pdu |= ((pdu_rel15->frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_alloc->size-pos++);
-      // Time domain assignment 4 bit
-      for (int i=0; i<4; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_alloc->size-pos++);
-      // VRB to PRB mapping 1 bit
-      *dci_pdu |= ((uint64_t)pdu_rel15->vrb_to_prb_mapping&1)<<(dci_alloc->size-pos++);
-      // MCS 5bit  //bit over 32, so dci_pdu ++
-      for (int i=0; i<5; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->mcs>>(4-i))&1)<<(dci_alloc->size-pos++);
-      // Redundancy version  2bit
-      for (int i=0; i<2; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->rv>>(1-i))&1)<<(dci_alloc->size-pos++);
-
-      break;
-
-    case NFAPI_NR_RNTI_TC:
-      // indicating a DL DCI format 1bit
-      *dci_pdu |= ((uint64_t)pdu_rel15->format_indicator&1)<<(dci_alloc->size-pos++);
-      // Freq domain assignment 0-16 bit
-      fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
-      for (int i=0; i<fsize; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_alloc->size-pos++);
-      // Time domain assignment 4 bit
-      for (int i=0; i<4; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_alloc->size-pos++);
-      // VRB to PRB mapping 1 bit
-      *dci_pdu |= ((uint64_t)pdu_rel15->vrb_to_prb_mapping&1)<<(dci_alloc->size-pos++);
-      // MCS 5bit  //bit over 32, so dci_pdu ++
-      for (int i=0; i<5; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->mcs>>(4-i))&1)<<(dci_alloc->size-pos++);
-      // New data indicator 1bit
-      *dci_pdu |= ((uint64_t)pdu_rel15->ndi&1)<<(dci_alloc->size-pos++);
-      // Redundancy version  2bit
-      for (int i=0; i<2; i++)
-	*dci_pdu |= (((uint64_t)pdu_rel15->rv>>(1-i))&1)<<(dci_alloc->size-pos++);
-      // HARQ process number  4bit
-      for (int i=0; i<4; i++)
-	*dci_pdu  |= (((uint64_t)pdu_rel15->harq_pid>>(3-i))&1)<<(dci_alloc->size-pos++);
-
-      // Downlink assignment index – 2 bits
-      for (int i=0; i<2; i++)
-	*dci_pdu  |= (((uint64_t)pdu_rel15->dai>>(1-i))&1)<<(dci_alloc->size-pos++);
-
-      // TPC command for scheduled PUCCH – 2 bits
-      for (int i=0; i<2; i++)
-	*dci_pdu  |= (((uint64_t)pdu_rel15->tpc>>(1-i))&1)<<(dci_alloc->size-pos++);
-
-
-      //      LOG_D(PHY, "DCI PDU: [0]->0x%08llx \t [1]->0x%08llx \t [2]->0x%08llx \t [3]->0x%08llx\n",
-      //	    dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]);
-
-
-      // PDSCH-to-HARQ_feedback timing indicator – 3 bits
-      for (int i=0; i<3; i++)
-	*dci_pdu  |= (((uint64_t)pdu_rel15->pdsch_to_harq_feedback_timing_indicator>>(2-i))&1)<<(dci_alloc->size-pos++);
-
-      break;
-    }
-    break;
-
-  case NFAPI_NR_UL_DCI_FORMAT_0_0:
-    switch(params_rel15->rnti_type)
-      {
-      case NFAPI_NR_RNTI_C:
-	// indicating a DL DCI format 1bit
-	*dci_pdu |= ((uint64_t)pdu_rel15->format_indicator&1)<<(dci_alloc->size-pos++);
-	// Freq domain assignment  max 16 bit
-	fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
-	for (int i=0; i<fsize; i++)
-	  *dci_pdu |= ((pdu_rel15->frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_alloc->size-pos++);
-	// Time domain assignment 4bit
-	for (int i=0; i<4; i++)
-	  *dci_pdu |= (((uint64_t)pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_alloc->size-pos++);
-	// Frequency hopping flag – 1 bit
-	*dci_pdu |= ((uint64_t)pdu_rel15->frequency_hopping_flag&1)<<(dci_alloc->size-pos++);
-	// MCS  5 bit
-	for (int i=0; i<5; i++)
-          *dci_pdu |= (((uint64_t)pdu_rel15->mcs>>(4-i))&1)<<(dci_alloc->size-pos++);
-	// New data indicator 1bit
-	*dci_pdu |= ((uint64_t)pdu_rel15->ndi&1)<<(dci_alloc->size-pos++);
-	// Redundancy version  2bit
-	for (int i=0; i<2; i++)
-	  *dci_pdu |= (((uint64_t)pdu_rel15->rv>>(1-i))&1)<<(dci_alloc->size-pos++);
-	// HARQ process number  4bit
-	for (int i=0; i<4; i++)
-	  *dci_pdu  |= (((uint64_t)pdu_rel15->harq_pid>>(3-i))&1)<<(dci_alloc->size-pos++);
-
-	// TPC command for scheduled PUSCH – 2 bits
-        for (int i=0; i<2; i++)
-          *dci_pdu |= (((uint64_t)pdu_rel15->tpc>>(1-i))&1)<<(dci_alloc->size-pos++);
-
-	// Padding bits
-        for(int a = pos;a<32;a++)
-          *dci_pdu |= ((uint64_t)pdu_rel15->padding&1)<<(dci_alloc->size-pos++);
-
-	// UL/SUL indicator – 1 bit
-        if (cfg->pucch_config.pucch_GroupHopping.value)
-          *dci_pdu |= ((uint64_t)pdu_rel15->ul_sul_indicator&1)<<(dci_alloc->size-pos++);
-
-	break;
-
-      case NFAPI_NR_RNTI_TC:
-
-	// indicating a DL DCI format 1bit
-	*dci_pdu |= (pdu_rel15->format_indicator&1)<<(dci_alloc->size-pos++);
-	// Freq domain assignment  max 16 bit
-	fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
-	for (int i=0; i<fsize; i++)
-	  *dci_pdu |= ((pdu_rel15->frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_alloc->size-pos++);
-	// Time domain assignment 4bit
-	for (int i=0; i<4; i++)
-	  *dci_pdu |= (((uint64_t)pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_alloc->size-pos++);
-	// Frequency hopping flag – 1 bit
-	*dci_pdu |= ((uint64_t)pdu_rel15->frequency_hopping_flag&1)<<(dci_alloc->size-pos++);
-	// MCS  5 bit
-	for (int i=0; i<5; i++)
-          *dci_pdu |= (((uint64_t)pdu_rel15->mcs>>(4-i))&1)<<(dci_alloc->size-pos++);
-	// New data indicator 1bit
-	*dci_pdu |= ((uint64_t)pdu_rel15->ndi&1)<<(dci_alloc->size-pos++);
-	// Redundancy version  2bit
-	for (int i=0; i<2; i++)
-          *dci_pdu |= (((uint64_t)pdu_rel15->rv>>(1-i))&1)<<(dci_alloc->size-pos++);
-	// HARQ process number  4bit
-	for (int i=0; i<4; i++)
-          *dci_pdu  |= (((uint64_t)pdu_rel15->harq_pid>>(3-i))&1)<<(dci_alloc->size-pos++);
-
-        // TPC command for scheduled PUSCH – 2 bits
-        for (int i=0; i<2; i++)
-          *dci_pdu |= (((uint64_t)pdu_rel15->tpc>>(1-i))&1)<<(dci_alloc->size-pos++);
-
-        // Padding bits
-        for(int a = pos;a<32;a++)
-	  *dci_pdu |= ((uint64_t)pdu_rel15->padding&1)<<(dci_alloc->size-pos++);
-
-        // UL/SUL indicator – 1 bit
-        if (cfg->pucch_config.pucch_GroupHopping.value)
-	  *dci_pdu |= ((uint64_t)pdu_rel15->ul_sul_indicator&1)<<(dci_alloc->size-pos++);
-
-        break;
-      }
-    break;
-  }
+    uint64_t *dci_pdu = (uint64_t*)pdcch_pdu_rel15->Payload[i];
 
-  LOG_D(PHY, "DCI PDU: [0]->0x%lx \t [1]->0x%lx \n",dci_pdu[0], dci_pdu[1]);
-  LOG_D(PHY, "DCI type %d payload (size %d) generated on candidate %d\n", dci_alloc->pdcch_params.dci_format, dci_alloc->size, cand_idx);
+    // if there's no DL DCI then generate CCE list
+    if (gNB->pdcch_pdu) nr_fill_cce_list(gNB,0);  
+    /*
+    LOG_D(PHY, "DCI PDU: [0]->0x%lx \t [1]->0x%lx \n",dci_pdu[0], dci_pdu[1]);
+    LOG_D(PHY, "DCI type %d payload (size %d) generated on candidate %d\n", dci_alloc->pdcch_params.dci_format, dci_alloc->size, cand_idx);
+    */
+
+  }
 
 }
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
index 7502d5d4a49..4518280f6b5 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
@@ -65,178 +65,230 @@ void nr_pdsch_codeword_scrambling(uint8_t *in,
 
 }
 
+void nr_pdsch_codeword_scrambling_optim(uint8_t *in,
+					uint32_t size,
+					uint8_t q,
+					uint32_t Nid,
+					uint32_t n_RNTI,
+					uint32_t* out) {
+  
+  uint32_t x1, x2, s=0,in32;
+
+  x2 = (n_RNTI<<15) + (q<<14) + Nid;
+
+  s=lte_gold_generic(&x1, &x2, 1);
+
+#if defined(__AVX2__)
+  for (int i=0; i<((size>>5)+((size&0x1f) > 0 ? 1 : 0)); i++) {
+    in32=_mm256_movemask_epi8(_mm256_slli_epi16(((__m256i*)in)[i],7));
+    out[i]=(in32^s);
+    //    printf("in[%d] %x => %x\n",i,in32,out[i]);
+    s=lte_gold_generic(&x1, &x2, 0);
+  }
+#elif defined(__SSE4__)
+  _m128i *in128;
+  for (int i=0; i<((size>>5)+((size&0x1f) > 0 ? 1 : 0)); i++) {
+    in128=&((__m128i*)in)[i<<1];
+    ((uint16_t*)&in32)[0] = _mm128_movemask_epi8(_mm256_slli_epi16(in128[0],7));
+    ((uint16_t*)&in32)[1] = _mm128_movemask_epi8(_mm256_slli_epi16(in128[1],7));
+    out[i]=(in32^s);
+    s=lte_gold_generic(&x1, &x2, 0);
+  }
+  //#elsif defined(__arm__) || defined(__aarch64)
+  
+#else 
+  nr_pdsch_codeword_scrambling(in,
+			       size,
+			       q,
+			       Nid,
+			       n_RNTI,
+			       out);
+#endif
+}
+
 
 uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch,
-                          NR_gNB_DCI_ALLOC_t *dci_alloc,
                           uint32_t ***pdsch_dmrs,
                           int32_t** txdataF,
                           int16_t amp,
                           int     frame,
                           uint8_t slot,
                           NR_DL_FRAME_PARMS *frame_parms,
-                          nfapi_nr_config_request_t *config,
+			  int xOverhead,
                           time_stats_t *dlsch_encoding_stats,
                           time_stats_t *dlsch_scrambling_stats,
-                          time_stats_t *dlsch_modulation_stats) {
+                          time_stats_t *dlsch_modulation_stats,
+			  time_stats_t *tinput,
+			  time_stats_t *tprep,
+			  time_stats_t *tparity,
+			  time_stats_t *toutput,
+			  time_stats_t *dlsch_rate_matching_stats,
+			  time_stats_t *dlsch_interleaving_stats,
+			  time_stats_t *dlsch_segmentation_stats) {
 
-  NR_DL_gNB_HARQ_t *harq = dlsch->harq_processes[dci_alloc->harq_pid];
-  nfapi_nr_dl_config_dlsch_pdu_rel15_t *rel15 = &harq->dlsch_pdu.dlsch_pdu_rel15;
-  nfapi_nr_dl_config_pdcch_parameters_rel15_t pdcch_params = dci_alloc->pdcch_params;
+  int harq_pid = 0;
+  NR_DL_gNB_HARQ_t *harq = dlsch->harq_processes[harq_pid];
+  nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &harq->pdsch_pdu.pdsch_pdu_rel15;
   uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5];
   int16_t **mod_symbs = (int16_t**)dlsch->mod_symbs;
   int16_t **tx_layers = (int16_t**)dlsch->txdataF;
   int8_t Wf[2], Wt[2], l0, l_prime[2], delta;
-  uint16_t nb_symbols = rel15->nb_mod_symbols;
-  uint8_t Qm = rel15->modulation_order;
-  uint32_t encoded_length = nb_symbols*Qm;
 
+  uint8_t dmrs_Type = rel15->dmrsConfigType;
+  int nb_re_dmrs = (dmrs_Type== NFAPI_NR_DMRS_TYPE1) ? 6:4;
+  uint16_t n_dmrs = ((rel15->rbSize+rel15->rbStart)*nb_re_dmrs)<<1;
+  int16_t mod_dmrs[n_dmrs<<1];
+
+  uint16_t nb_re = ((12*rel15->NrOfSymbols)-nb_re_dmrs-xOverhead)*rel15->rbSize*rel15->NrOfCodewords;
+  uint8_t Qm = rel15->qamModOrder[0];
+  uint32_t encoded_length = nb_re*Qm;
 
   /// CRC, coding, interleaving and rate matching
   AssertFatal(harq->pdu!=NULL,"harq->pdu is null\n");
   start_meas(dlsch_encoding_stats);
-  nr_dlsch_encoding(harq->pdu, frame, slot, dlsch, frame_parms);
+  nr_dlsch_encoding(harq->pdu, frame, slot, dlsch, frame_parms,tinput,tprep,tparity,toutput,
+		    dlsch_rate_matching_stats,
+		    dlsch_interleaving_stats,
+		    dlsch_segmentation_stats);
   stop_meas(dlsch_encoding_stats);
 #ifdef DEBUG_DLSCH
-printf("PDSCH encoding:\nPayload:\n");
-for (int i=0; i<harq->B>>7; i++) {
-  for (int j=0; j<16; j++)
-    printf("0x%02x\t", harq->pdu[(i<<4)+j]);
+  printf("PDSCH encoding:\nPayload:\n");
+  for (int i=0; i<harq->B>>7; i++) {
+    for (int j=0; j<16; j++)
+      printf("0x%02x\t", harq->pdu[(i<<4)+j]);
+    printf("\n");
+  }
+  printf("\nEncoded payload:\n");
+  for (int i=0; i<encoded_length>>3; i++) {
+    for (int j=0; j<8; j++)
+      printf("%d", harq->f[(i<<3)+j]);
+    printf("\t");
+  }
   printf("\n");
-}
-printf("\nEncoded payload:\n");
-for (int i=0; i<encoded_length>>3; i++) {
-  for (int j=0; j<8; j++)
-    printf("%d", harq->f[(i<<3)+j]);
-  printf("\t");
-}
-printf("\n");
 #endif
 
+
+
   /// scrambling
   start_meas(dlsch_scrambling_stats);
-  for (int q=0; q<rel15->nb_codewords; q++)
+  for (int q=0; q<rel15->NrOfCodewords; q++)
     memset((void*)scrambled_output[q], 0, (encoded_length>>5)*sizeof(uint32_t));
-  uint16_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? \
-  ((pdcch_params.scrambling_id==0)?pdcch_params.rnti:0) : 0;
-  uint16_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? \
-  pdcch_params.scrambling_id : config->sch_config.physical_cell_id.value;
-  for (int q=0; q<rel15->nb_codewords; q++)
-    nr_pdsch_codeword_scrambling(harq->f,
-                                 encoded_length,
-                                 q,
-                                 Nid,
-                                 n_RNTI,
-                                 scrambled_output[q]);
-
+  for (int q=0; q<rel15->NrOfCodewords; q++)
+    nr_pdsch_codeword_scrambling_optim(harq->f,
+				       encoded_length,
+				       q,
+				       rel15->dlDmrsScramblingId,
+				       rel15->rnti,
+				       scrambled_output[q]);
+  
   stop_meas(dlsch_scrambling_stats);
 #ifdef DEBUG_DLSCH
-printf("PDSCH scrambling:\n");
-for (int i=0; i<encoded_length>>8; i++) {
-  for (int j=0; j<8; j++)
-    printf("0x%08x\t", scrambled_output[0][(i<<3)+j]);
-  printf("\n");
-}
+  printf("PDSCH scrambling:\n");
+  for (int i=0; i<encoded_length>>8; i++) {
+    for (int j=0; j<8; j++)
+      printf("0x%08x\t", scrambled_output[0][(i<<3)+j]);
+    printf("\n");
+  }
 #endif
  
   /// Modulation
   start_meas(dlsch_modulation_stats);
-  for (int q=0; q<rel15->nb_codewords; q++)
+  for (int q=0; q<rel15->NrOfCodewords; q++)
     nr_modulation(scrambled_output[q],
                          encoded_length,
                          Qm,
                          mod_symbs[q]);
   stop_meas(dlsch_modulation_stats);
 #ifdef DEBUG_DLSCH
-printf("PDSCH Modulation: Qm %d(%d)\n", Qm, nb_symbols);
-for (int i=0; i<nb_symbols>>3; i++) {
-  for (int j=0; j<8; j++) {
-    printf("%d %d\t", mod_symbs[0][((i<<3)+j)<<1], mod_symbs[0][(((i<<3)+j)<<1)+1]);
+  printf("PDSCH Modulation: Qm %d(%d)\n", Qm, nb_re);
+  for (int i=0; i<nb_re>>3; i++) {
+    for (int j=0; j<8; j++) {
+      printf("%d %d\t", mod_symbs[0][((i<<3)+j)<<1], mod_symbs[0][(((i<<3)+j)<<1)+1]);
+    }
+    printf("\n");
   }
-  printf("\n");
-}
 #endif
 
 
   /// Layer mapping
   nr_layer_mapping(mod_symbs,
-                         rel15->nb_layers,
-                         nb_symbols,
-                         tx_layers);
+		   rel15->nrOfLayers,
+		   nb_re,
+		   tx_layers);
 #ifdef DEBUG_DLSCH
-printf("Layer mapping (%d layers):\n", rel15->nb_layers);
-for (int l=0; l<rel15->nb_layers; l++)
-  for (int i=0; i<(nb_symbols/rel15->nb_layers)>>3; i++) {
-    for (int j=0; j<8; j++) {
-      printf("%d %d\t", tx_layers[l][((i<<3)+j)<<1], tx_layers[l][(((i<<3)+j)<<1)+1]);
+  printf("Layer mapping (%d layers):\n", rel15->nrOfLayers);
+  for (int l=0; l<rel15->nrOfLayers; l++)
+    for (int i=0; i<(nb_re/rel15->nrOfLayers)>>3; i++) {
+      printf("layer %d, Re %d..%d : ",l,i<<3,(i<<3)+7);
+      for (int j=0; j<8; j++) {
+	printf("l%d %d\t", tx_layers[l][((i<<3)+j)<<1], tx_layers[l][(((i<<3)+j)<<1)+1]);
+      }
+      printf("\n");
     }
-    printf("\n");
-  }
 #endif
 
   /// Antenna port mapping
-    //to be moved to init phase potentially, for now tx_layers 1-8 are mapped on antenna ports 1000-1007
-
+  //to be moved to init phase potentially, for now tx_layers 1-8 are mapped on antenna ports 1000-1007
+  
   /// DMRS QPSK modulation
-  uint16_t n_dmrs = ((rel15->n_prb+rel15->start_prb)*rel15->nb_re_dmrs)<<1;
-  int16_t mod_dmrs[n_dmrs<<1];
-  uint8_t dmrs_type = config->pdsch_config.dmrs_type.value;
-  uint8_t mapping_type = config->pdsch_config.mapping_type.value;
-
-  l0 = get_l0(mapping_type, 2);//config->pdsch_config.dmrs_typeA_position.value);
+  
+  
+  l0 = get_l0(rel15->dlDmrsSymbPos);
   nr_modulation(pdsch_dmrs[l0][0], n_dmrs, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated
-
+  
 #ifdef DEBUG_DLSCH
-printf("DMRS modulation (single symbol %d, %d symbols, type %d):\n", l0, n_dmrs>>1, dmrs_type);
-for (int i=0; i<n_dmrs>>4; i++) {
-  for (int j=0; j<8; j++) {
-    printf("%d %d\t", mod_dmrs[((i<<3)+j)<<1], mod_dmrs[(((i<<3)+j)<<1)+1]);
+  printf("DMRS modulation (single symbol %d, %d symbols, type %d):\n", l0, n_dmrs>>1, dmrs_Type);
+  for (int i=0; i<n_dmrs>>4; i++) {
+    for (int j=0; j<8; j++) {
+      printf("%d %d\t", mod_dmrs[((i<<3)+j)<<1], mod_dmrs[(((i<<3)+j)<<1)+1]);
+    }
+    printf("\n");
   }
-  printf("\n");
-}
 #endif
-
-
+  
+  
   /// Resource mapping
-
+  
   // Non interleaved VRB to PRB mapping
-  uint16_t start_sc = frame_parms->first_carrier_offset + rel15->start_prb*NR_NB_SC_PER_RB;
+  uint16_t start_sc = frame_parms->first_carrier_offset + rel15->rbStart*NR_NB_SC_PER_RB;
   if (start_sc >= frame_parms->ofdm_symbol_size)
     start_sc -= frame_parms->ofdm_symbol_size;
 
 #ifdef DEBUG_DLSCH_MAPPING
- printf("PDSCH resource mapping started (start SC %d\tstart symbol %d\tN_PRB %d\tnb_symbols %d)\n",
-	start_sc, rel15->start_symbol, rel15->n_prb, rel15->nb_symbols);
+  printf("PDSCH resource mapping started (start SC %d\tstart symbol %d\tN_PRB %d\tnb_re %d,nb_layers %d)\n",
+	 start_sc, rel15->StartSymbolIndex, rel15->rbSize, nb_re,rel15->nrOfLayers);
 #endif
-  for (int ap=0; ap<rel15->nb_layers; ap++) {
+  for (int ap=0; ap<rel15->nrOfLayers; ap++) {
 
     // DMRS params for this ap
-    get_Wt(Wt, ap, dmrs_type);
-    get_Wf(Wf, ap, dmrs_type);
-    delta = get_delta(ap, dmrs_type);
+    get_Wt(Wt, ap, dmrs_Type);
+    get_Wf(Wf, ap, dmrs_Type);
+    delta = get_delta(ap, dmrs_Type);
     l_prime[0] = 0; // single symbol ap 0
     uint8_t dmrs_symbol = l0+l_prime[0];
 #ifdef DEBUG_DLSCH_MAPPING
-printf("DMRS params for ap %d: Wt %d %d \t Wf %d %d \t delta %d \t l_prime %d \t l0 %d\tDMRS symbol %d\n",
-ap, Wt[0], Wt[1], Wf[0], Wf[1], delta, l_prime[0], l0, dmrs_symbol);
+    printf("DMRS Type %d params for ap %d: Wt %d %d \t Wf %d %d \t delta %d \t l_prime %d \t l0 %d\tDMRS symbol %d\n",
+	   1+dmrs_Type,ap, Wt[0], Wt[1], Wf[0], Wf[1], delta, l_prime[0], l0, dmrs_symbol);
 #endif
     uint8_t k_prime=0;
     uint16_t m=0, n=0, dmrs_idx=0, k=0;
+
     int txdataF_offset = (slot%2)*frame_parms->samples_per_slot_wCP;
-    if (dmrs_type == NFAPI_NR_DMRS_TYPE1) // another if condition to be included to check pdsch config type (reference of k)
-      dmrs_idx = rel15->start_prb*6;
+    if (dmrs_Type == NFAPI_NR_DMRS_TYPE1) // another if condition to be included to check pdsch config type (reference of k)
+      dmrs_idx = rel15->rbStart*6;
     else
-      dmrs_idx = rel15->start_prb*4;
+      dmrs_idx = rel15->rbStart*4;
 
-    for (int l=rel15->start_symbol; l<rel15->start_symbol+rel15->nb_symbols; l++) {
+    for (int l=rel15->StartSymbolIndex; l<rel15->StartSymbolIndex+rel15->NrOfSymbols; l++) {
       k = start_sc;
-      for (int i=0; i<rel15->n_prb*NR_NB_SC_PER_RB; i++) {
-        if ((l == dmrs_symbol) && (k == ((start_sc+get_dmrs_freq_idx(n, k_prime, delta, dmrs_type))%(frame_parms->ofdm_symbol_size)))) {
+      for (int i=0; i<rel15->rbSize*NR_NB_SC_PER_RB; i++) {
+        if ((l == dmrs_symbol) && (k == ((start_sc+get_dmrs_freq_idx(n, k_prime, delta, dmrs_Type))%(frame_parms->ofdm_symbol_size)))) {
           ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (Wt[l_prime[0]]*Wf[k_prime]*amp*mod_dmrs[dmrs_idx<<1]) >> 15;
           ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (Wt[l_prime[0]]*Wf[k_prime]*amp*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15;
 #ifdef DEBUG_DLSCH_MAPPING
-printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d\n",
-dmrs_idx, l, k, k_prime, n, ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)],
-((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]);
+	  printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d\n",
+		 dmrs_idx, l, k, k_prime, n, ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)],
+		 ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]);
 #endif
           dmrs_idx++;
           k_prime++;
@@ -249,9 +301,9 @@ dmrs_idx, l, k, k_prime, n, ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol
           ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (amp * tx_layers[ap][m<<1]) >> 15;
           ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (amp * tx_layers[ap][(m<<1) + 1]) >> 15;
 #ifdef DEBUG_DLSCH_MAPPING
-printf("m %d\t l %d \t k %d \t txdataF: %d %d\n",
+	  printf("m %d\t l %d \t k %d \t txdataF: %d %d\n",
 m, l, k, ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)],
-((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]);
+		 ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]);
 #endif
           m++;
         }
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h
index 77d5c6802f7..f48905b68cb 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h
@@ -36,10 +36,10 @@
 #include "PHY/defs_gNB.h"
 
 void nr_get_time_domain_allocation_type(nfapi_nr_config_request_t config,
-                                        nfapi_nr_dl_config_dci_dl_pdu dci_pdu,
-                                        nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu);
+                                        nfapi_nr_dl_tti_pdcch_pdu dci_pdu,
+                                        nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu);
 
-void nr_check_time_alloc(uint8_t S, uint8_t L, nfapi_nr_config_request_t config);
+void nr_check_time_alloc(uint8_t S, uint8_t L,nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15,nfapi_nr_config_request_t *cfg);
 
 uint16_t get_RIV(uint16_t rb_start, uint16_t L, uint16_t N_RB);
 
@@ -51,7 +51,10 @@ void nr_get_rbg_parms(NR_BWP_PARMS* bwp, uint8_t config_type);
 
 void nr_get_rbg_list(uint32_t bitmap, uint8_t n_rbg, uint8_t* rbg_list);
 
-void nr_get_PRG_parms(NR_BWP_PARMS* bwp, NR_gNB_DCI_ALLOC_t dci_alloc, uint8_t prb_bundling_type);
+
+uint8_t nr_get_Qm(uint8_t Imcs, uint8_t table_idx);
+
+uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx);
 
 void nr_pdsch_codeword_scrambling(uint8_t *in,
                                   uint32_t size,
@@ -63,24 +66,31 @@ void nr_pdsch_codeword_scrambling(uint8_t *in,
 void nr_fill_dlsch(PHY_VARS_gNB *gNB,
                    int frame,
                    int slot,
-                   nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu,
+                   nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
                    unsigned char *sdu); 
 
 uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch,
-                          NR_gNB_DCI_ALLOC_t *dci_alloc,
                           uint32_t ***pdsch_dmrs,
                           int32_t** txdataF,
                           int16_t amp,
                           int frame,
                           uint8_t slot,
                           NR_DL_FRAME_PARMS *frame_parms,
-                          nfapi_nr_config_request_t *config,
+			  int xOverhead,
                           time_stats_t *dlsch_encoding_stats,
                           time_stats_t *dlsch_scrambling_stats,
-                          time_stats_t *dlsch_modulation_stats);
+                          time_stats_t *dlsch_modulation_stats,
+			  time_stats_t *tinput,
+			  time_stats_t *tprep,
+			  time_stats_t *tparity,
+			  time_stats_t *toutput,
+			  time_stats_t *dlsch_rate_matching_stats,
+			  time_stats_t *dlsch_interleaving_stats,
+			  time_stats_t *dlsch_segmentation_stats);
+
 
 
-void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr);
+void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr,uint16_t N_RB);
 
 void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch);
 
@@ -89,9 +99,16 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch);
 int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type);
 
 int nr_dlsch_encoding(unsigned char *a,int frame,
-                     uint8_t slot,
-                     NR_gNB_DLSCH_t *dlsch,
-                     NR_DL_FRAME_PARMS* frame_parms);
+		      uint8_t slot,
+		      NR_gNB_DLSCH_t *dlsch,
+		      NR_DL_FRAME_PARMS* frame_parms,
+		      time_stats_t *tinput,
+		      time_stats_t *tprep,
+		      time_stats_t *tparity,
+		      time_stats_t *toutput,
+		      time_stats_t *dlsch_rate_matching_stats,
+		      time_stats_t *dlsch_interleaving_stats,
+		      time_stats_t *dlsch_segmentation_stats);
 
 
 void nr_emulate_dlsch_payload(uint8_t* payload, uint16_t size);
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
index dae55862249..856a7863f43 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
@@ -35,12 +35,12 @@
 #include "PHY/CODING/coding_extern.h"
 #include "PHY/CODING/coding_defs.h"
 #include "PHY/CODING/lte_interleaver_inline.h"
-#include "PHY/CODING/nrLDPC_encoder/defs.h"
+#include "PHY/CODING/nrLDPC_extern.h"
 #include "PHY/NR_TRANSPORT/nr_transport.h"
 #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
 #include "PHY/NR_TRANSPORT/nr_dlsch.h"
+#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h"
 #include "SCHED_NR/sched_nr.h"
-#include "defs.h"
 #include "common/utils/LOG/vcd_signal_dumper.h"
 #include "common/utils/LOG/log.h"
 #include <syscall.h>
@@ -48,43 +48,71 @@
 //#define DEBUG_DLSCH_CODING
 //#define DEBUG_DLSCH_FREE 1
 
-void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr)
+
+void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr,uint16_t N_RB)
 {
   int i;
   int r;
-  
+
   NR_gNB_DLSCH_t *dlsch = *dlschptr;
+
+  uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS;  //number of segments to be allocated
   if (dlsch) {
+
+    if (N_RB != 273) {
+      a_segments = a_segments*N_RB;
+      a_segments = a_segments/273;
+    }  
+
+    uint16_t dlsch_bytes = a_segments*1056;  // allocated bytes per segment
+
+
 #ifdef DEBUG_DLSCH_FREE
-    printf("Freeing dlsch %p\n",dlsch);
+    LOG_D(PHY,"Freeing dlsch %p\n",dlsch);
 #endif
 
     for (i=0; i<dlsch->Mdlharq; i++) {
 #ifdef DEBUG_DLSCH_FREE
-      printf("Freeing dlsch process %d\n",i);
+      LOG_D(PHY,"Freeing dlsch process %d\n",i);
 #endif
 
       if (dlsch->harq_processes[i]) {
 #ifdef DEBUG_DLSCH_FREE
-        printf("Freeing dlsch process %d (%p)\n",i,dlsch->harq_processes[i]);
+        LOG_D(PHY,"Freeing dlsch process %d (%p)\n",i,dlsch->harq_processes[i]);
 #endif
 
         if (dlsch->harq_processes[i]->b) {
-          free16(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES); //this should be MAX_NR_DLSCH_PAYLOAD_BYTES
+          free16(dlsch->harq_processes[i]->b,dlsch_bytes);
           dlsch->harq_processes[i]->b = NULL;
 #ifdef DEBUG_DLSCH_FREE
-          printf("Freeing dlsch process %d b (%p)\n",i,dlsch->harq_processes[i]->b);
+          LOG_D(PHY,"Freeing dlsch process %d b (%p)\n",i,dlsch->harq_processes[i]->b);
+#endif
+        }
+
+        if (dlsch->harq_processes[i]->e) {
+          free16(dlsch->harq_processes[i]->e,14*N_RB*12*8);
+          dlsch->harq_processes[i]->e = NULL;
+#ifdef DEBUG_DLSCH_FREE
+          printf("Freeing dlsch process %d e (%p)\n",i,dlsch->harq_processes[i]->e);
 #endif
         }
 
+        if (dlsch->harq_processes[i]->f) {
+          free16(dlsch->harq_processes[i]->f,14*N_RB*12*8);
+          dlsch->harq_processes[i]->f = NULL;
 #ifdef DEBUG_DLSCH_FREE
-        printf("Freeing dlsch process %d c (%p)\n",i,dlsch->harq_processes[i]->c);
+          printf("Freeing dlsch process %d f (%p)\n",i,dlsch->harq_processes[i]->f);
 #endif
+        }
 
-        for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++) {
+#ifdef DEBUG_DLSCH_FREE
+        LOG_D(PHY,"Freeing dlsch process %d c (%p)\n",i,dlsch->harq_processes[i]->c);
+#endif
+
+        for (r=0; r<a_segments; r++) {
 
 #ifdef DEBUG_DLSCH_FREE
-          printf("Freeing dlsch process %d c[%d] (%p)\n",i,r,dlsch->harq_processes[i]->c[r]);
+          LOG_D(PHY,"Freeing dlsch process %d c[%d] (%p)\n",i,r,dlsch->harq_processes[i]->c[r]);
 #endif
 
           if (dlsch->harq_processes[i]->c[r]) {
@@ -108,31 +136,27 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr)
 
 }
 
-NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
+NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
+                              unsigned char Kmimo,
                               unsigned char Mdlharq,
                               uint32_t Nsoft,
-                              uint8_t abstraction_flag,
-                              NR_DL_FRAME_PARMS *frame_parms,
-                              nfapi_nr_config_request_t *config)
+                              uint8_t  abstraction_flag,
+                              uint16_t N_RB)
 {
 
   NR_gNB_DLSCH_t *dlsch;
   unsigned char exit_flag = 0,i,r,aa,layer;
   int re;
-  unsigned char bw_scaling =1;
-  uint16_t N_RB = config->rf_config.dl_carrier_bandwidth.value;
+  uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS;  //number of segments to be allocated
 
-  switch (N_RB) {
+  if (N_RB != 273) {
+    a_segments = a_segments*N_RB;
+    a_segments = a_segments/273;
+  }  
 
-  case 106:
-    bw_scaling =2;
-    break;
-
-  default:
-    bw_scaling =1;
-    break;
-  }
+  uint16_t dlsch_bytes = a_segments*1056;  // allocated bytes per segment
 
+  
   dlsch = (NR_gNB_DLSCH_t *)malloc16(sizeof(NR_gNB_DLSCH_t));
 
   if (dlsch) {
@@ -145,12 +169,12 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
     for (layer=0; layer<NR_MAX_NB_LAYERS; layer++) {
       dlsch->ue_spec_bf_weights[layer] = (int32_t**)malloc16(64*sizeof(int32_t*));
 
-       for (aa=0; aa<64; aa++) {
+      for (aa=0; aa<64; aa++) {
          dlsch->ue_spec_bf_weights[layer][aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t));
          for (re=0;re<OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES; re++) {
            dlsch->ue_spec_bf_weights[layer][aa][re] = 0x00007fff;
          }
-       }
+      }
 
       dlsch->txdataF[layer] = (int32_t *)malloc16((NR_MAX_PDSCH_ENCODED_LENGTH/NR_MAX_NB_LAYERS)*sizeof(int32_t)); // NR_MAX_NB_LAYERS is already included in NR_MAX_PDSCH_ENCODED_LENGTH
     }
@@ -171,31 +195,31 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
 
     for (i=0; i<Mdlharq; i++) {
       dlsch->harq_processes[i] = (NR_DL_gNB_HARQ_t *)malloc16(sizeof(NR_DL_gNB_HARQ_t));
-      LOG_T(PHY, "Required mem size %d (bw scaling %d), dlsch->harq_processes[%d] %p\n",
-    		  MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling,bw_scaling, i,dlsch->harq_processes[i]);
+      LOG_T(PHY, "Required mem size %d  dlsch->harq_processes[%d] %p\n",
+    		  dlsch_bytes, i,dlsch->harq_processes[i]);
 
       if (dlsch->harq_processes[i]) {
         bzero(dlsch->harq_processes[i],sizeof(NR_DL_gNB_HARQ_t));
         //    dlsch->harq_processes[i]->first_tx=1;
-        dlsch->harq_processes[i]->b = (unsigned char*)malloc16(MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling);
-        dlsch->harq_processes[i]->pdu = (uint8_t*)malloc16(MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling);
+        dlsch->harq_processes[i]->b = (unsigned char*)malloc16(dlsch_bytes);
+        dlsch->harq_processes[i]->pdu = (uint8_t*)malloc16(dlsch_bytes);
         if (dlsch->harq_processes[i]->pdu) {
-          bzero(dlsch->harq_processes[i]->pdu,MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling);
-          nr_emulate_dlsch_payload(dlsch->harq_processes[i]->pdu, (MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling)>>3);
+          bzero(dlsch->harq_processes[i]->pdu,dlsch_bytes);
+          nr_emulate_dlsch_payload(dlsch->harq_processes[i]->pdu, (dlsch_bytes)>>3);
         } else {
-          printf("Can't allocate PDU\n");
+          LOG_D(PHY,"Can't allocate PDU\n");
           exit_flag=1;
         }
 
         if (dlsch->harq_processes[i]->b) {
-          bzero(dlsch->harq_processes[i]->b,MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling);
+          bzero(dlsch->harq_processes[i]->b,dlsch_bytes);
         } else {
-          printf("Can't get b\n");
+          LOG_D(PHY,"Can't get b\n");
           exit_flag=1;
         }
 
         if (abstraction_flag==0) {
-          for (r=0; r<MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling; r++) {
+          for (r=0; r<a_segments; r++) {
             // account for filler in first segment and CRCs for multiple segment case
             // [hna] 8448 is the maximum CB size in NR
             //       68*348 = 68*(maximum size of Zc)
@@ -205,19 +229,33 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
             if (dlsch->harq_processes[i]->c[r]) {
               bzero(dlsch->harq_processes[i]->c[r],8448);
             } else {
-              printf("Can't get c\n");
+              LOG_D(PHY,"Can't get c\n");
               exit_flag=2;
             }
             if (dlsch->harq_processes[i]->d[r]) {
               bzero(dlsch->harq_processes[i]->d[r],(3*8448));
             } else {
-              printf("Can't get d\n");
+              LOG_D(PHY,"Can't get d\n");
               exit_flag=2;
             }
           }
+          dlsch->harq_processes[i]->e = (uint8_t*)malloc16(14*N_RB*12*8);
+          if (dlsch->harq_processes[i]->e) {
+            bzero(dlsch->harq_processes[i]->e,14*N_RB*12*8);
+          } else {
+            printf("Can't get e\n");
+            exit_flag=1;
+          }
+          dlsch->harq_processes[i]->f = (uint8_t*)malloc16(14*N_RB*12*8);
+          if (dlsch->harq_processes[i]->f) {
+            bzero(dlsch->harq_processes[i]->f,14*N_RB*12*8);
+          } else {
+            printf("Can't get f\n");
+            exit_flag=1;
+          }
         }
       } else {
-        printf("Can't get harq_p %d\n",i);
+        LOG_D(PHY,"Can't get harq_p %d\n",i);
         exit_flag=3;
       }
     }
@@ -233,7 +271,9 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
 
   LOG_D(PHY,"new_gNB_dlsch exit flag %d, size of  %ld\n",
 	exit_flag, sizeof(NR_gNB_DLSCH_t));
-  free_gNB_dlsch(&dlsch);
+
+  free_gNB_dlsch(&dlsch,N_RB);
+
   return(NULL);
 
 
@@ -261,7 +301,7 @@ void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch)
         dlsch->harq_processes[i]->round  = 0;
 
 	for (j=0; j<96; j++)
-	  for (r=0; r<MAX_NUM_DLSCH_SEGMENTS; r++)
+	  for (r=0; r<MAX_NUM_NR_DLSCH_SEGMENTS; r++)
 	    if (dlsch->harq_processes[i]->d[r])
 	      dlsch->harq_processes[i]->d[r][j] = NR_NULL;
 
@@ -274,59 +314,54 @@ int nr_dlsch_encoding(unsigned char *a,
                       int frame,
                       uint8_t slot,
                       NR_gNB_DLSCH_t *dlsch,
-                      NR_DL_FRAME_PARMS* frame_parms)
+                      NR_DL_FRAME_PARMS* frame_parms,
+		      time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput,
+		      time_stats_t *dlsch_rate_matching_stats,time_stats_t *dlsch_interleaving_stats,
+		      time_stats_t *dlsch_segmentation_stats)
 {
 
   unsigned int G;
   unsigned int crc=1;
-  uint8_t harq_pid = dlsch->harq_ids[frame&2][slot];
+  uint8_t harq_pid = dlsch->harq_ids[frame%2][slot];
   AssertFatal(harq_pid<8 && harq_pid>=0,"illegal harq_pid %d\b",harq_pid);
-  nfapi_nr_dl_config_dlsch_pdu_rel15_t rel15 = dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15;
-  uint16_t nb_rb = rel15.n_prb;
-  uint8_t nb_symb_sch = rel15.nb_symbols;
+  nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->harq_processes[harq_pid]->pdsch_pdu.pdsch_pdu_rel15;
+  uint16_t nb_rb = rel15->rbSize;
+  uint8_t nb_symb_sch = rel15->NrOfSymbols;
   uint32_t A, Z, Kb, F=0;
   uint32_t *Zc = &Z;
-  uint8_t mod_order = rel15.modulation_order;
+  uint8_t mod_order = rel15->qamModOrder[0];
   uint16_t Kr=0,r;
   uint32_t r_offset=0;
-  //uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS];
   uint8_t BG=1;
   uint32_t E;
   uint8_t Ilbrm = 1;
   uint32_t Tbslbrm = 950984; //max tbs
-  uint8_t nb_re_dmrs = rel15.nb_re_dmrs;
-  uint16_t R=rel15.coding_rate;
-  uint16_t length_dmrs = 1;
+  uint8_t nb_re_dmrs = rel15->dmrsConfigType==NFAPI_NR_DMRS_TYPE1 ? 6:4;
+  uint16_t length_dmrs = get_num_dmrs(rel15->dlDmrsSymbPos);
+  uint16_t R=rel15->targetCodeRate[0];
   float Coderate = 0.0;
   uint8_t Nl = 4;
 
-  /*
-  uint8_t *channel_input[MAX_NUM_DLSCH_SEGMENTS]; //unsigned char
-  for(j=0;j<MAX_NUM_DLSCH_SEGMENTS;j++) {
-    channel_input[j] = (unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
-  }
-  */
-  
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN);
 
-  A = rel15.transport_block_size;
+  A = rel15->TBSize[0]<<3;
 
-  G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,rel15.nb_layers);
+  G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,rel15->nrOfLayers);
 
   LOG_D(PHY,"dlsch coding A %d G %d mod_order %d\n", A,G, mod_order);
 
   //  if (dlsch->harq_processes[harq_pid]->Ndi == 1) {  // this is a new packet
   if (dlsch->harq_processes[harq_pid]->round == 0) {  // this is a new packet
 #ifdef DEBUG_DLSCH_CODING
-  printf("encoding thinks this is a new packet \n");
+  LOG_D(PHY,"encoding thinks this is a new packet \n");
 #endif
-    /*
+  /*    
     int i;
-    printf("dlsch (tx): \n");
+    LOG_D(PHY,"dlsch (tx): \n");
     for (i=0;i<(A>>3);i++)
-      printf("%02x.",a[i]);
-    printf("\n");
-    */
+      LOG_D(PHY,"%02x\n",a[i]);
+    LOG_D(PHY,"\n");
+  */
 
     if (A > 3824) {
       // Add 24-bit crc (polynomial A) to payload
@@ -340,7 +375,7 @@ int nr_dlsch_encoding(unsigned char *a,
       dlsch->harq_processes[harq_pid]->B = A+24;
       //    dlsch->harq_processes[harq_pid]->b = a;
    
-      AssertFatal((A/8)+4 <= MAX_DLSCH_PAYLOAD_BYTES,"A %d is too big (A/8+4 = %d > %d)\n",A,(A/8)+4,MAX_DLSCH_PAYLOAD_BYTES);
+      AssertFatal((A/8)+4 <= MAX_NR_DLSCH_PAYLOAD_BYTES,"A %d is too big (A/8+4 = %d > %d)\n",A,(A/8)+4,MAX_NR_DLSCH_PAYLOAD_BYTES);
 
       memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4);  // why is this +4 if the CRC is only 3 bytes?
     }
@@ -355,7 +390,7 @@ int nr_dlsch_encoding(unsigned char *a,
       dlsch->harq_processes[harq_pid]->B = A+16;
       //    dlsch->harq_processes[harq_pid]->b = a;
    
-      AssertFatal((A/8)+3 <= MAX_DLSCH_PAYLOAD_BYTES,"A %d is too big (A/8+3 = %d > %d)\n",A,(A/8)+3,MAX_DLSCH_PAYLOAD_BYTES);
+      AssertFatal((A/8)+3 <= MAX_NR_DLSCH_PAYLOAD_BYTES,"A %d is too big (A/8+3 = %d > %d)\n",A,(A/8)+3,MAX_NR_DLSCH_PAYLOAD_BYTES);
 
       memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+3);  // using 3 bytes to mimic the case of 24 bit crc
     }
@@ -369,6 +404,7 @@ int nr_dlsch_encoding(unsigned char *a,
     else
 		BG = 1;
 
+    start_meas(dlsch_segmentation_stats);
     Kb = nr_segmentation(dlsch->harq_processes[harq_pid]->b,
 		         dlsch->harq_processes[harq_pid]->c,
 		         dlsch->harq_processes[harq_pid]->B,
@@ -377,7 +413,7 @@ int nr_dlsch_encoding(unsigned char *a,
 		         Zc, 
 		         &dlsch->harq_processes[harq_pid]->F,
                          BG);
-
+    stop_meas(dlsch_segmentation_stats);
     F = dlsch->harq_processes[harq_pid]->F;
 
     Kr = dlsch->harq_processes[harq_pid]->K;
@@ -392,21 +428,28 @@ int nr_dlsch_encoding(unsigned char *a,
       //d_tmp[r] = &dlsch->harq_processes[harq_pid]->d[r][0];
       //channel_input[r] = &dlsch->harq_processes[harq_pid]->d[r][0];
 #ifdef DEBUG_DLSCH_CODING
-      printf("Encoder: B %d F %d \n",dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->F);
-      printf("start ldpc encoder segment %d/%d\n",r,dlsch->harq_processes[harq_pid]->C);
-      printf("input %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->c[r][0], dlsch->harq_processes[harq_pid]->c[r][1], dlsch->harq_processes[harq_pid]->c[r][2],dlsch->harq_processes[harq_pid]->c[r][3], dlsch->harq_processes[harq_pid]->c[r][4]);
+      LOG_D(PHY,"Encoder: B %d F %d \n",dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->F);
+      LOG_D(PHY,"start ldpc encoder segment %d/%d\n",r,dlsch->harq_processes[harq_pid]->C);
+      LOG_D(PHY,"input %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->c[r][0], dlsch->harq_processes[harq_pid]->c[r][1], dlsch->harq_processes[harq_pid]->c[r][2],dlsch->harq_processes[harq_pid]->c[r][3], dlsch->harq_processes[harq_pid]->c[r][4]);
       for (int cnt =0 ; cnt < 22*(*Zc)/8; cnt ++){
-      printf("%d ", dlsch->harq_processes[harq_pid]->c[r][cnt]);
+      LOG_D(PHY,"%d ", dlsch->harq_processes[harq_pid]->c[r][cnt]);
       }
-      printf("\n");
+      LOG_D(PHY,"\n");
 
 #endif
       //ldpc_encoder_orig((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],dlsch->harq_processes[harq_pid]->d[r],*Zc,Kb,Kr,BG,0);
       //ldpc_encoder_optim((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],(unsigned char*)&dlsch->harq_processes[harq_pid]->d[r][0],*Zc,Kb,Kr,BG,NULL,NULL,NULL,NULL);
     }
+    encoder_implemparams_t impp;
+    impp.n_segments=dlsch->harq_processes[harq_pid]->C;
+    impp.tprep = tprep;
+    impp.tinput = tinput;
+    impp.tparity = tparity;
+    impp.toutput = toutput;
 
     for(int j=0;j<(dlsch->harq_processes[harq_pid]->C/8+1);j++) {
-      ldpc_encoder_optim_8seg_multi(dlsch->harq_processes[harq_pid]->c,dlsch->harq_processes[harq_pid]->d,*Zc,Kb,Kr,BG,dlsch->harq_processes[harq_pid]->C,j,NULL,NULL,NULL,NULL);
+      impp.macro_num=j;
+      nrLDPC_encoder(dlsch->harq_processes[harq_pid]->c,dlsch->harq_processes[harq_pid]->d,*Zc,Kb,Kr,BG,&impp);
     }
 
 
@@ -419,34 +462,40 @@ int nr_dlsch_encoding(unsigned char *a,
 
   for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) {
 
-    if (dlsch->harq_processes[harq_pid]->F>0) {
+    if (F>0) {
       for (int k=(Kr-F-2*(*Zc)); k<Kr-2*(*Zc); k++) {
+	// writing into positions d[r][k-2Zc] as in clause 5.3.2 step 2) in 38.212
         dlsch->harq_processes[harq_pid]->d[r][k] = NR_NULL;
 	//if (k<(Kr-F+8))
 	//printf("r %d filler bits [%d] = %d \n", r,k, dlsch->harq_processes[harq_pid]->d[r][k]);
       }
     }
 
-#ifdef DEBUG_DLSCH_CODING
-    printf("Rate Matching, Code segment %d (coded bits (G) %u, unpunctured/repeated bits per code segment %d, mod_order %d, nb_rb %d)...\n",
-        r,
-        G,
-        Kr*3,
-        mod_order,nb_rb);
-#endif
+
 
 #ifdef DEBUG_DLSCH_CODING
-  printf("rvidx in encoding = %d\n", rel15.redundancy_version);
+  LOG_D(PHY,"rvidx in encoding = %d\n", rel15->rvIndex[0]);
 #endif
 
-    E = nr_get_E(G, dlsch->harq_processes[harq_pid]->C, mod_order, rel15.nb_layers, r);
+    E = nr_get_E(G, dlsch->harq_processes[harq_pid]->C, mod_order, rel15->nrOfLayers, r);
+
+    //#ifdef DEBUG_DLSCH_CODING
+    LOG_D(PHY,"Rate Matching, Code segment %d/%d (coded bits (G) %u, E %d, Filler bits %d, Filler offset %d mod_order %d, nb_rb %d)...\n",
+	  r,
+	  dlsch->harq_processes[harq_pid]->C,
+	  G,
+	  E,
+	  F,
+	  Kr-F-2*(*Zc),
+	  mod_order,nb_rb);
 
     // for tbslbrm calculation according to 5.4.2.1 of 38.212
-    if (rel15.nb_layers < Nl)
-      Nl = rel15.nb_layers;
+    if (rel15->nrOfLayers < Nl)
+      Nl = rel15->nrOfLayers;
 
-    Tbslbrm = nr_compute_tbslbrm(rel15.mcs_table,nb_rb,Nl,dlsch->harq_processes[harq_pid]->C);
+    Tbslbrm = nr_compute_tbslbrm(rel15->mcsTable[0],nb_rb,Nl,dlsch->harq_processes[harq_pid]->C);
 
+    start_meas(dlsch_rate_matching_stats);
     nr_rate_matching_ldpc(Ilbrm,
                           Tbslbrm,
                           BG,
@@ -454,19 +503,22 @@ int nr_dlsch_encoding(unsigned char *a,
                           dlsch->harq_processes[harq_pid]->d[r],
                           dlsch->harq_processes[harq_pid]->e+r_offset,
                           dlsch->harq_processes[harq_pid]->C,
-                          rel15.redundancy_version,
+                          F,
+                          Kr-F-2*(*Zc),
+                          rel15->rvIndex[0],
                           E);
-
+    stop_meas(dlsch_rate_matching_stats);
 #ifdef DEBUG_DLSCH_CODING
     for (int i =0; i<16; i++)
       printf("output ratematching e[%d]= %d r_offset %u\n", i,dlsch->harq_processes[harq_pid]->e[i+r_offset], r_offset);
 #endif
 
-	nr_interleaving_ldpc(E,
-			     mod_order,
-			     dlsch->harq_processes[harq_pid]->e+r_offset,
-			     dlsch->harq_processes[harq_pid]->f+r_offset);
-
+    start_meas(dlsch_interleaving_stats);
+    nr_interleaving_ldpc(E,
+			 mod_order,
+			 dlsch->harq_processes[harq_pid]->e+r_offset,
+			 dlsch->harq_processes[harq_pid]->f+r_offset);
+    stop_meas(dlsch_interleaving_stats);
 
 #ifdef DEBUG_DLSCH_CODING
     for (int i =0; i<16; i++)
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c
index 9736e97e34c..2e6fc707bdc 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c
@@ -27,6 +27,7 @@
 * \company Eurecom
 * \email: desouza@eurecom.fr
 * \note
+
 * \warning
 */
 
@@ -46,6 +47,7 @@ uint8_t nr_pdsch_default_time_alloc_C_L[15] = {2,2,2,2,2,4,4,4,4,4,7,12,11,6,6};
 
   /// Time domain allocation routines
 
+/*
 void nr_get_time_domain_allocation_type(nfapi_nr_config_request_t config,
                                         nfapi_nr_dl_config_dci_dl_pdu dci_pdu,
                                         nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu) {
@@ -73,9 +75,9 @@ void nr_get_time_domain_allocation_type(nfapi_nr_config_request_t config,
 
     case NFAPI_NR_RNTI_RA:
     case NFAPI_NR_RNTI_TC:
-      /*AssertFatal(dci_alloc.pdcch_params.common_search_space_type == NFAPI_NR_COMMON_SEARCH_SPACE_TYPE_1,
-      "Invalid common search space type %d for RNTI %d, expected %d\n",dci_alloc.pdcch_params.common_search_space_type,
-      NFAPI_NR_COMMON_SEARCH_SPACE_TYPE_1, dci_alloc.rnti_type);*/
+      //AssertFatal(dci_alloc.pdcch_params.common_search_space_type == NFAPI_NR_COMMON_SEARCH_SPACE_TYPE_1,
+      //"Invalid common search space type %d for RNTI %d, expected %d\n",dci_alloc.pdcch_params.common_search_space_type,
+      //NFAPI_NR_COMMON_SEARCH_SPACE_TYPE_1, dci_alloc.rnti_type);
       *alloc_type = (alloc_list_flag) ? NFAPI_NR_PDSCH_TIME_DOMAIN_ALLOC_TYPE_ALLOC_LIST : NFAPI_NR_PDSCH_TIME_DOMAIN_ALLOC_TYPE_DEFAULT_A;
       break;
 
@@ -94,6 +96,7 @@ void nr_get_time_domain_allocation_type(nfapi_nr_config_request_t config,
   }
 }
 
+
 uint16_t get_SLIV(uint8_t S, uint8_t L) {
   return ( (uint16_t)(((L-1)<=7)? (14*(L-1)+S) : (14*(15-L)+(13-S))) );
 }
@@ -104,26 +107,26 @@ static inline uint8_t get_K0(uint8_t row_idx, uint8_t time_alloc_type) {
   ((row_idx==6)||(row_idx==7)||(row_idx==15))? 1 : 0);
 }
 
-/*ideally combine the calculation of L in the same function once the right struct is defined*/
-uint8_t nr_get_S(uint8_t row_idx, uint8_t CP, uint8_t time_alloc_type, uint8_t dmrs_typeA_position) {
+// ideally combine the calculation of L in the same function once the right struct is defined
+uint8_t nr_get_S(uint8_t row_idx, uint8_t CP, uint8_t time_alloc_type, uint8_t dmrs_TypeA_Position) {
 
   uint8_t idx;
   //uint8_t S;
 
   switch(time_alloc_type) {
     case NFAPI_NR_PDSCH_TIME_DOMAIN_ALLOC_TYPE_DEFAULT_A:
-      idx = (row_idx>7)? (row_idx+6) : (((row_idx-1)<<1)-1+((dmrs_typeA_position==2)?0:1));
+      idx = (row_idx>7)? (row_idx+6) : (((row_idx-1)<<1)-1+((dmrs_TypeA_Position==2)?0:1));
       return ((CP==NFAPI_CP_NORMAL)?nr_pdsch_default_time_alloc_A_S_nCP[idx] : nr_pdsch_default_time_alloc_A_S_eCP[idx]);
       break;
 
     case NFAPI_NR_PDSCH_TIME_DOMAIN_ALLOC_TYPE_DEFAULT_B:
-      idx = (row_idx<14)? (row_idx-1) : (row_idx == 14)? row_idx-1+((dmrs_typeA_position==2)?0:1) : 15;
+      idx = (row_idx<14)? (row_idx-1) : (row_idx == 14)? row_idx-1+((dmrs_TypeA_Position==2)?0:1) : 15;
       return (nr_pdsch_default_time_alloc_B_S[idx]);
       break;
 
     case NFAPI_NR_PDSCH_TIME_DOMAIN_ALLOC_TYPE_DEFAULT_C:
       AssertFatal((row_idx!=6)&&(row_idx!=7)&&(row_idx<17), "Invalid row index %d in %s %s\n", row_idx, __FUNCTION__, __FILE__);
-      idx = (row_idx<6)? (row_idx-1) : (row_idx<14)? (row_idx-3) : (row_idx == 14)? row_idx-3+((dmrs_typeA_position==2)?0:1) : (row_idx-2);
+      idx = (row_idx<6)? (row_idx-1) : (row_idx<14)? (row_idx-3) : (row_idx == 14)? row_idx-3+((dmrs_TypeA_Position==2)?0:1) : (row_idx-2);
       break;
 
   default:
@@ -132,16 +135,17 @@ uint8_t nr_get_S(uint8_t row_idx, uint8_t CP, uint8_t time_alloc_type, uint8_t d
   return 0; // temp warning fix
 }
 
-void nr_check_time_alloc(uint8_t S, uint8_t L, nfapi_nr_config_request_t config) {
 
-  switch (config.subframe_config.dl_cyclic_prefix_type.value) {
+void nr_check_time_alloc(uint8_t S, uint8_t L,nfapi_nr_dl_config_dlsch_pdu_rel15_t *rel15,nfapi_nr_config_request_t *cfg) {
+
+  switch (cfg->subframe_config.dl_cyclic_prefix_type.value) {
     case NFAPI_CP_NORMAL:
-      if (config.pdsch_config.mapping_type.value == NFAPI_NR_PDSCH_MAPPING_TYPE_A) {
+      if (rel15->mapping_type == NFAPI_NR_PDSCH_MAPPING_TYPE_A) {
         AssertFatal(S<4, "Invalid value of S(%d) for mapping type A and normal CP\n", S);
 
         if (S==3)
-          AssertFatal(config.pdsch_config.mapping_type.value == 3, "Invalid S %d for dmrs_typeA_position %d\n",
-          S, config.pdsch_config.dmrs_typeA_position.value);
+          AssertFatal(rel15->dmrs_TypeA_Position == 3, "Invalid S %d for dmrs_TypeA_Position %d\n",
+          S, rel15->dmrs_TypeA_Position);
 
         AssertFatal((L>2)&&(L<15), "Invalid L %d for mapping type A and normal CP\n", L);
 
@@ -157,12 +161,12 @@ void nr_check_time_alloc(uint8_t S, uint8_t L, nfapi_nr_config_request_t config)
       break;
 
     case NFAPI_CP_EXTENDED:
-      if (config.pdsch_config.mapping_type.value == NFAPI_NR_PDSCH_MAPPING_TYPE_A) {
+      if (rel15->mapping_type == NFAPI_NR_PDSCH_MAPPING_TYPE_A) {
         AssertFatal(S<4, "Invalid value of S(%d) for mapping type A and extended CP\n", S);
 
         if (S==3)
-          AssertFatal(config.pdsch_config.dmrs_typeA_position.value == 3, "Invalid S %d for dmrs_typeA_position %d\n",
-          S, config.pdsch_config.dmrs_typeA_position.value);
+          AssertFatal(rel15->dmrs_TypeA_Position == 3, "Invalid S %d for dmrs_TypeA_Position %d\n",
+          S, rel15->dmrs_TypeA_Position);
 
         AssertFatal((L>2)&&(L<13), "Invalid L %d for mapping type A and extended CP\n", L);
 
@@ -241,6 +245,7 @@ void nr_get_PRG_parms(NR_BWP_PARMS* bwp, NR_gNB_DCI_ALLOC_t dci_alloc, uint8_t p
   LOG_I(PHY, "PRG parameters for BWP %d location %d N_RB %d:\n", bwp->bwp_id, bwp->location, bwp->N_RB);
   LOG_I(PHY, "P_prime %d\t start size %d\t endsize %d\t N_PRG %d\n", prg_parms->P_prime, prg_parms->start_size, prg_parms->end_size, prg_parms->N_PRG);
 }
+*/
 
   /// Payload emulation
 void nr_emulate_dlsch_payload(uint8_t* pdu, uint16_t size) {
@@ -292,10 +297,10 @@ int16_t find_nr_ulsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type) {
 void nr_fill_dlsch(PHY_VARS_gNB *gNB,
                    int frame,
                    int slot,
-                   nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu,
+                   nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
                    uint8_t *sdu) {
 
-  nfapi_nr_dl_config_dlsch_pdu_rel15_t *rel15 = &dlsch_pdu->dlsch_pdu_rel15;
+  nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &pdsch_pdu->pdsch_pdu_rel15;
  
   int dlsch_id = find_nr_dlsch(rel15->rnti,gNB,SEARCH_EXIST);
   AssertFatal( (dlsch_id>=0) && (dlsch_id<NUMBER_OF_NR_DLSCH_MAX),
@@ -303,7 +308,8 @@ void nr_fill_dlsch(PHY_VARS_gNB *gNB,
   NR_gNB_DLSCH_t  *dlsch = gNB->dlsch[dlsch_id][0];
   NR_DL_gNB_HARQ_t **harq  = dlsch->harq_processes;
   /// DLSCH struct
-  memcpy((void*)&harq[dlsch->harq_ids[frame%2][slot]]->dlsch_pdu, (void*)dlsch_pdu, sizeof(nfapi_nr_dl_config_dlsch_pdu));
+  memcpy((void*)&harq[dlsch->harq_ids[frame%2][slot]]->pdsch_pdu, (void*)pdsch_pdu, sizeof(nfapi_nr_dl_tti_pdsch_pdu));
+  gNB->num_pdsch_rnti++;
   AssertFatal(sdu!=NULL,"sdu is null\n");
   harq[dlsch->harq_ids[frame%2][slot]]->pdu = sdu;
 
@@ -327,23 +333,9 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB,
   ulsch->harq_mask |= 1<<harq_pid;
   ulsch->harq_process_id[slot] = harq_pid;
 
-  nfapi_nr_ul_config_ulsch_pdu *rel15_ul = &ulsch->harq_processes[harq_pid]->ulsch_pdu;
+  memcpy((void*)&ulsch->harq_processes[harq_pid]->ulsch_pdu, (void*)ulsch_pdu, sizeof(nfapi_nr_pusch_pdu_t));
 
   LOG_D(PHY,"Initializing nFAPI for ULSCH, UE %d, harq_pid %d\n",ulsch_id,harq_pid);
- 
-  
-  //FK this is still a bad hack. We need to replace the L1 FAPI structures with the new scf ones as well.
-  rel15_ul->rnti                           = ulsch_pdu->rnti;
-  rel15_ul->ulsch_pdu_rel15.start_rb       = ulsch_pdu->rb_start;
-  rel15_ul->ulsch_pdu_rel15.number_rbs     = ulsch_pdu->rb_size;
-  rel15_ul->ulsch_pdu_rel15.start_symbol   = ulsch_pdu->start_symbol_index;
-  rel15_ul->ulsch_pdu_rel15.number_symbols = ulsch_pdu->nr_of_symbols;
-  rel15_ul->ulsch_pdu_rel15.length_dmrs    = gNB->dmrs_UplinkConfig.pusch_maxLength;
-  rel15_ul->ulsch_pdu_rel15.Qm             = ulsch_pdu->qam_mod_order;
-  rel15_ul->ulsch_pdu_rel15.mcs            = ulsch_pdu->mcs_index;
-  rel15_ul->ulsch_pdu_rel15.rv             = ulsch_pdu->pusch_data.rv_index;
-  rel15_ul->ulsch_pdu_rel15.n_layers       = ulsch_pdu->nrOfLayers;
-  rel15_ul->ulsch_pdu_rel15.R              = ulsch_pdu->target_code_rate;
 
 }
 
diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c
index af83c17fc1c..b6a4787193e 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c
@@ -50,13 +50,13 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
                           int32_t *txdataF,
                           int16_t amp,
                           uint8_t ssb_start_symbol,
-                          nfapi_nr_config_request_t *config,
+                          nfapi_nr_config_request_scf_t *config,
                           NR_DL_FRAME_PARMS *frame_parms) {
   int k,l;
   //int16_t a;
   int16_t mod_dmrs[NR_PBCH_DMRS_LENGTH<<1];
   uint8_t idx=0;
-  uint8_t nushift = config->sch_config.physical_cell_id.value &3;
+  uint8_t nushift = config->cell_config.phy_cell_id.value &3;
   LOG_D(PHY, "PBCH DMRS mapping started at symbol %d shift %d\n", ssb_start_symbol+1, nushift);
 
   /// QPSK modulation
@@ -220,16 +220,14 @@ void nr_init_pbch_interleaver(uint8_t *interleaver) {
 }
 
 int nr_generate_pbch(NR_gNB_PBCH *pbch,
-                     uint8_t *pbch_pdu,
+		     nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
                      uint8_t *interleaver,
                      int32_t *txdataF,
                      int16_t amp,
                      uint8_t ssb_start_symbol,
                      uint8_t n_hf,
-                     uint8_t Lmax,
-                     uint8_t ssb_index,
                      int sfn,
-                     nfapi_nr_config_request_t *config,
+                     nfapi_nr_config_request_scf_t *config,
                      NR_DL_FRAME_PARMS *frame_parms) {
   int k,l,m;
   //int16_t a;
@@ -243,17 +241,18 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
   ///Payload generation
   memset((void *)pbch, 0, sizeof(NR_gNB_PBCH));
   pbch->pbch_a=0;
-
+  uint8_t ssb_index = frame_parms->ssb_index;
+  uint8_t *pbch_pdu = (uint8_t*)&ssb_pdu->ssb_pdu_rel15.bchPayload;
+  uint8_t Lmax = frame_parms->Lmax;
   for (int i=0; i<NR_PBCH_PDU_BITS; i++)
-    pbch->pbch_a |= ((pbch_pdu[2-(i>>3)]>>(7-(i&7)))&1)<<i;
-
-#ifdef DEBUG_PBCH_ENCODING
+    pbch->pbch_a |= ((pbch_pdu[i>>3]>>(7-(i&7)))&1)<<i;
 
+  #ifdef DEBUG_PBCH_ENCODING
   for (int i=0; i<3; i++)
     printf("pbch_pdu[%d]: 0x%02x\n", i, pbch_pdu[i]);
 
   printf("PBCH payload = 0x%08x\n",pbch->pbch_a);
-#endif
+  #endif
 
   // Extra byte generation
   for (int i=0; i<4; i++)
@@ -265,7 +264,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
     for (int i=0; i<3; i++)
       pbch->pbch_a |= ((ssb_index>>(5-i))&1)<<(29+i); // resp. 6th, 5th and 4th bits of ssb_index
   else
-    pbch->pbch_a |= ((config->sch_config.ssb_subcarrier_offset.value>>4)&1)<<29; //MSB of k_SSB (bit index 4)
+    pbch->pbch_a |= ((config->ssb_table.ssb_subcarrier_offset.value>>4)&1)<<29; //MSB of k_SSB (bit index 4)
 
   LOG_D(PHY,"After extra byte: pbch_a = 0x%08x\n",pbch->pbch_a);
 
@@ -287,7 +286,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
   M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3);
   nushift = (((sfn>>2)&1)<<1) ^ ((sfn>>1)&1);
   pbch->pbch_a_prime = 0;
-  nr_pbch_scrambling(pbch, (uint32_t)config->sch_config.physical_cell_id.value, nushift, M, NR_POLAR_PBCH_PAYLOAD_BITS, 0, unscrambling_mask);
+  nr_pbch_scrambling(pbch, (uint32_t)config->cell_config.phy_cell_id.value, nushift, M, NR_POLAR_PBCH_PAYLOAD_BITS, 0, unscrambling_mask);
 #ifdef DEBUG_PBCH_ENCODING
   printf("Payload scrambling: nushift %d M %d sfn3 %d sfn2 %d\n", nushift, M, (sfn>>2)&1, (sfn>>1)&1);
   printf("pbch_a_prime: 0x%08x\n", pbch->pbch_a_prime);
@@ -299,7 +298,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
 
   /// CRC, coding and rate matching
   polar_encoder_fast (&a_reversed, (uint32_t *)pbch->pbch_e, 0, 0,
-                      nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL)
+                      nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL,0,NULL)
                      );
 #ifdef DEBUG_PBCH_ENCODING
   printf("Channel coding:\n");
@@ -312,7 +311,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
   /// Scrambling
   M =  NR_POLAR_PBCH_E;
   nushift = (Lmax==4)? ssb_index&3 : ssb_index&7;
-  nr_pbch_scrambling(pbch, (uint32_t)config->sch_config.physical_cell_id.value, nushift, M, NR_POLAR_PBCH_E, 1, 0);
+  nr_pbch_scrambling(pbch, (uint32_t)config->cell_config.phy_cell_id.value, nushift, M, NR_POLAR_PBCH_E, 1, 0);
 #ifdef DEBUG_PBCH_ENCODING
   printf("Scrambling:\n");
 
@@ -333,7 +332,7 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
   }
 
   /// Resource mapping
-  nushift = config->sch_config.physical_cell_id.value &3;
+  nushift = config->cell_config.phy_cell_id.value &3;
   // PBCH modulated symbols are mapped  within the SSB block on symbols 1, 2, 3 excluding the subcarriers used for the PBCH DMRS
   ///symbol 1  [0:239] -- 180 mod symbols
   k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier;
diff --git a/openair1/PHY/NR_TRANSPORT/nr_pss.c b/openair1/PHY/NR_TRANSPORT/nr_pss.c
index e0d7b6ae33e..be9e011e60c 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_pss.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_pss.c
@@ -28,7 +28,7 @@ int nr_generate_pss(  int16_t *d_pss,
                       int32_t *txdataF,
                       int16_t amp,
                       uint8_t ssb_start_symbol,
-                      nfapi_nr_config_request_t* config,
+                      nfapi_nr_config_request_scf_t* config,
                       NR_DL_FRAME_PARMS *frame_parms)
 {
   int i,k,l,m;
@@ -36,7 +36,7 @@ int nr_generate_pss(  int16_t *d_pss,
   int16_t x[NR_PSS_LENGTH];
   const int x_initial[7] = {0, 1, 1 , 0, 1, 1, 1};
 
-  uint8_t Nid2 = config->sch_config.physical_cell_id.value % 3;
+  uint8_t Nid2 = config->cell_config.phy_cell_id.value % 3;
 
   /// Sequence generation
   for (i=0; i < 7; i++)
diff --git a/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c b/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c
index 63922c8c65d..04045380eb5 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.c
@@ -84,8 +84,14 @@ uint16_t get_dmrs_freq_idx(uint16_t n, uint8_t k_prime, uint8_t delta, uint8_t d
   return dmrs_idx;
 }
 
-uint8_t get_l0(uint8_t mapping_type, uint8_t dmrs_typeA_position) {
-
-  return ((mapping_type==NFAPI_NR_PDSCH_MAPPING_TYPE_A)?dmrs_typeA_position:0);
+uint8_t get_l0(uint16_t dlDmrsSymbPos) {
 
+  uint16_t mask=dlDmrsSymbPos;
+  int l0;
+  for (l0=0;l0<14;l0++) {
+    if ((mask&1) == 1) break;
+    mask>>=1;
+  }
+  AssertFatal(l0 < 4,"impossible l0 %d\n",l0);
+  return (l0);
 }
diff --git a/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h b/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h
index 8278742a489..2b25464b849 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h
+++ b/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h
@@ -48,6 +48,6 @@ uint8_t get_delta(uint8_t ap, uint8_t config);
 
 uint16_t get_dmrs_freq_idx(uint16_t n, uint8_t k_prime, uint8_t delta, uint8_t dmrs_type);
 
-uint8_t get_l0(uint8_t mapping_type, uint8_t dmrs_typeA_position);
+uint8_t get_l0(uint16_t dlDmrsSymbPos);
 
-#endif
+#endif
\ No newline at end of file
diff --git a/openair1/PHY/NR_TRANSPORT/nr_sss.c b/openair1/PHY/NR_TRANSPORT/nr_sss.c
index 154aca9ffec..7d8b551d7ca 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_sss.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_sss.c
@@ -27,7 +27,7 @@ int nr_generate_sss(  int16_t *d_sss,
                       int32_t *txdataF,
                       int16_t amp,
                       uint8_t ssb_start_symbol,
-                      nfapi_nr_config_request_t* config,
+                      nfapi_nr_config_request_scf_t* config,
                       NR_DL_FRAME_PARMS *frame_parms)
 {
   int i,k,l;
@@ -39,7 +39,7 @@ int nr_generate_sss(  int16_t *d_sss,
   const int x1_initial[7] = { 1, 0, 0, 0, 0, 0, 0 };
 
   /// Sequence generation
-  Nid = config->sch_config.physical_cell_id.value;
+  Nid = config->cell_config.phy_cell_id.value;
   Nid2 = Nid % 3;
   Nid1 = (Nid - Nid2)/3;
 
diff --git a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c
index 10ac17acabe..ea8e39488e3 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c
@@ -33,187 +33,6 @@
 #include "nr_transport_common_proto.h"
 #include "PHY/CODING/coding_defs.h"
 
-//Table 5.1.3.1-1 of 38.214
-uint16_t Table_51311[29][2] = {{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},{4,340},{4,378},{4,434},{4,490},{4,553},{4,616},
-		{4,658},{6,438},{6,466},{6,517},{6,567},{6,616},{6,666},{6,719},{6,772},{6,822},{6,873}, {6,910}, {6,948}};
-
-//Table 5.1.3.1-2 of 38.214
-// Imcs values 20 and 26 have been multiplied by 2 to avoid the floating point
-uint16_t Table_51312[28][2] = {{2,120},{2,193},{2,308},{2,449},{2,602},{4,378},{4,434},{4,490},{4,553},{4,616},{4,658},{6,466},{6,517},{6,567},{6,616},{6,666},
-		{6,719},{6,772},{6,822},{6,873},{8,1365},{8,711},{8,754},{8,797},{8,841},{8,885},{8,1833},{8,948}};
-
-//Table 5.1.3.1-3 of 38.214
-uint16_t Table_51313[29][2] = {{2,30},{2,40},{2,50},{2,64},{2,78},{2,99},{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{4,340},
-		{4,378},{4,434},{4,490},{4,553},{4,616},{6,438},{6,466},{6,517},{6,567},{6,616},{6,666}, {6,719}, {6,772}};
-
-//Table 6.1.4.1-1 of 38.214 TODO fix for tp-pi2BPSK
-uint16_t Table_61411[28][2] = {{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},{4,340},{4,378},{4,434},{4,490},{4,553},{4,616},
-		{4,658},{6,466},{6,517},{6,567},{6,616},{6,666},{6,719},{6,772},{6,822},{6,873}, {6,910}, {6,948}};
-
-//Table 6.1.4.1-2 of 38.214 TODO fix for tp-pi2BPSK
-uint16_t Table_61412[28][2] = {{2,30},{2,40},{2,50},{2,64},{2,78},{2,99},{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},
-		{4,378},{4,434},{4,490},{4,553},{4,616},{4,658},{4,699},{4,772},{6,567},{6,616},{6,666}, {6,772}};
-
-
-uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx) {
-  switch(table_idx) {
-    case 0:
-      return (Table_51311[Imcs][0]);
-    break;
-
-    case 1:
-      return (Table_51312[Imcs][0]);
-    break;
-
-    case 2:
-      return (Table_51313[Imcs][0]);
-    break;
-
-    default:
-      AssertFatal(0, "Invalid MCS table index %d (expected in range [1,3])\n", table_idx);
-  }
-}
-
-uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx) {
-  switch(table_idx) {
-    case 0:
-      return (Table_51311[Imcs][1]);
-    break;
-
-    case 1:
-      return (Table_51312[Imcs][1]);
-    break;
-
-    case 2:
-      return (Table_51313[Imcs][1]);
-    break;
-
-    default:
-      AssertFatal(0, "Invalid MCS table index %d (expected in range [1,3])\n", table_idx);
-  }
-}
-
-uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx) {
-  switch(table_idx) {
-    case 0:
-      return (Table_51311[Imcs][0]);
-    break;
-
-    case 1:
-      return (Table_51312[Imcs][0]);
-    break;
-
-    case 2:
-      return (Table_51313[Imcs][0]);
-    break;
-
-    case 3:
-      return (Table_61411[Imcs][0]);
-    break;
-
-    case 4:
-      return (Table_61412[Imcs][0]);
-    break;
-
-    default:
-      AssertFatal(0, "Invalid MCS table index %d (expected in range [1,2])\n", table_idx);
-  }
-}
-
-uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx) {
-  switch(table_idx) {
-    case 0:
-      return (Table_51311[Imcs][1]);
-    break;
-
-    case 1:
-      return (Table_51312[Imcs][1]);
-    break;
-
-    case 2:
-      return (Table_51313[Imcs][1]);
-    break;
-
-    case 3:
-      return (Table_61411[Imcs][1]);
-    break;
-
-    case 4:
-      return (Table_61412[Imcs][1]);
-    break;
-
-    default:
-      AssertFatal(0, "Invalid MCS table index %d (expected in range [1,2])\n", table_idx);
-  }
-}
-
-static inline uint8_t is_codeword_disabled(uint8_t format, uint8_t Imcs, uint8_t rv) {
-  return ((format==NFAPI_NR_DL_DCI_FORMAT_1_1)&&(Imcs==26)&&(rv==1));
-}
-
-static inline uint8_t get_table_idx(uint8_t mcs_table, uint8_t dci_format, uint8_t rnti_type, uint8_t ss_type) {
-  if ((mcs_table == NFAPI_NR_MCS_TABLE_QAM256) && (dci_format == NFAPI_NR_DL_DCI_FORMAT_1_1) && ((rnti_type==NFAPI_NR_RNTI_C)||(rnti_type==NFAPI_NR_RNTI_CS)))
-    return 2;
-  else if ((mcs_table == NFAPI_NR_MCS_TABLE_QAM64_LOW_SE) && (rnti_type!=NFAPI_NR_RNTI_new) && (rnti_type==NFAPI_NR_RNTI_C) && (ss_type==NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC))
-    return 3;
-  else if (rnti_type==NFAPI_NR_RNTI_new)
-    return 3;
-  else if ((mcs_table == NFAPI_NR_MCS_TABLE_QAM256) && (rnti_type==NFAPI_NR_RNTI_CS) && (dci_format == NFAPI_NR_DL_DCI_FORMAT_1_1))
-    return 2; // Condition mcs_table not configured in sps_config necessary here but not yet implemented
-  /*else if((mcs_table == NFAPI_NR_MCS_TABLE_QAM64_LOW_SE) &&  (rnti_type==NFAPI_NR_RNTI_CS))
-   *  table_idx = 3;
-   * Note: the commented block refers to the case where the mcs_table is from sps_config*/
-  else
-    return 1;
-}
-
-void nr_get_tbs_dl(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu,
-                   nfapi_nr_dl_config_dci_dl_pdu dci_pdu,
-                   nfapi_nr_config_request_t config) {
-
-  LOG_D(MAC, "TBS calculation\n");
-
-  nfapi_nr_dl_config_pdcch_parameters_rel15_t params_rel15 = dci_pdu.pdcch_params_rel15;
-  nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_rel15 = &dlsch_pdu->dlsch_pdu_rel15;
-  uint8_t rnti_type = params_rel15.rnti_type;
-  uint16_t N_PRB_oh = ((rnti_type==NFAPI_NR_RNTI_SI)||(rnti_type==NFAPI_NR_RNTI_RA)||(rnti_type==NFAPI_NR_RNTI_P))? 0 : \
-  (config.pdsch_config.x_overhead.value);
-  uint8_t N_PRB_DMRS = (config.pdsch_config.dmrs_type.value == NFAPI_NR_DMRS_TYPE1)?6:4; //This only works for antenna port 1000
-  uint8_t N_sh_symb = dlsch_rel15->nb_symbols;
-  uint8_t Imcs = dlsch_rel15->mcs_idx;
-  uint16_t N_RE_prime = NR_NB_SC_PER_RB*N_sh_symb - N_PRB_DMRS - N_PRB_oh;
-  LOG_D(MAC, "N_RE_prime %d for %d symbols %d DMRS per PRB and %d overhead\n", N_RE_prime, N_sh_symb, N_PRB_DMRS, N_PRB_oh);
-
-  uint16_t R;
-  uint32_t TBS=0;
-  uint8_t table_idx, Qm;
-
-  /*uint8_t mcs_table = config.pdsch_config.mcs_table.value;
-  uint8_t ss_type = params_rel15.search_space_type;
-  uint8_t dci_format = params_rel15.dci_format;
-  get_table_idx(mcs_table, dci_format, rnti_type, ss_type);*/
-  table_idx = 0;
-  R = nr_get_code_rate_dl(Imcs, table_idx);
-  Qm = nr_get_Qm_dl(Imcs, table_idx);
-
-  TBS = nr_compute_tbs(Qm,
-                       R,
-		       dlsch_rel15->n_prb,
-		       N_sh_symb,
-		       N_PRB_DMRS,
-		       N_PRB_oh,
-		       dlsch_rel15->nb_layers);
-
-  dlsch_rel15->coding_rate = R;
-  dlsch_rel15->modulation_order = Qm;
-  dlsch_rel15->transport_block_size = TBS;
-  dlsch_rel15->nb_re_dmrs = N_PRB_DMRS;
-  dlsch_rel15->nb_mod_symbols = N_RE_prime*dlsch_rel15->n_prb*dlsch_rel15->nb_codewords;
-  dlsch_rel15->mcs_table = table_idx;
-
-  LOG_D(MAC, "TBS %d : N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d R %d Qm %d table %d nb_symbols %d\n",
-  TBS, N_PRB_DMRS, N_sh_symb, N_PRB_oh, R, Qm, table_idx, dlsch_rel15->nb_mod_symbols);
-}
 
 uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Qm, uint8_t Nl) {
 	uint32_t G;
@@ -227,7 +46,7 @@ uint32_t nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r) {
 
   AssertFatal(Nl>0,"Nl is 0\n");
   AssertFatal(Qm>0,"Qm is 0\n");
-
+  LOG_D(PHY,"nr_get_E : (G %d, C %d, Qm %d, Nl %d, r %d)\n",G, C, Qm, Nl, r);
   if (r <= Cprime - ((G/(Nl*Qm))%Cprime) - 1)
       E = Nl*Qm*(G/(Nl*Qm*Cprime));
   else
diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport.h b/openair1/PHY/NR_TRANSPORT/nr_transport.h
index 23413f591c2..be738750588 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_transport.h
+++ b/openair1/PHY/NR_TRANSPORT/nr_transport.h
@@ -23,6 +23,7 @@
 #define __NR_TRANSPORT__H__
 
 #include "PHY/defs_gNB.h"
+#include "LAYER2/NR_MAC_gNB/mac_proto.h"
 
 #define NR_PBCH_PDU_BITS 24
 
@@ -36,7 +37,7 @@ int nr_generate_pss(  int16_t *d_pss,
                       int32_t *txdataF,
                       int16_t amp,
                       uint8_t ssb_start_symbol,
-                      nfapi_nr_config_request_t *config,
+                      nfapi_nr_config_request_scf_t *config,
                       NR_DL_FRAME_PARMS *frame_parms);
 
 /*!
@@ -49,7 +50,7 @@ int nr_generate_sss(  int16_t *d_sss,
                       int32_t *txdataF,
                       int16_t amp,
                       uint8_t ssb_start_symbol,
-                      nfapi_nr_config_request_t *config,
+                      nfapi_nr_config_request_scf_t *config,
                       NR_DL_FRAME_PARMS *frame_parms);
 
 /*!
@@ -62,7 +63,7 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
                           int32_t *txdataF,
                           int16_t amp,
                           uint8_t ssb_start_symbol,
-                          nfapi_nr_config_request_t *config,
+                          nfapi_nr_config_request_scf_t *config,
                           NR_DL_FRAME_PARMS *frame_parms);
 
 /*!
@@ -85,16 +86,14 @@ void nr_pbch_scrambling(NR_gNB_PBCH *pbch,
 @returns 0 on success
  */
 int nr_generate_pbch(NR_gNB_PBCH *pbch,
-                     uint8_t *pbch_pdu,
+		     nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
                      uint8_t *interleaver,
                      int32_t *txdataF,
                      int16_t amp,
                      uint8_t ssb_start_symbol,
                      uint8_t n_hf,
-                     uint8_t Lmax,
-                     uint8_t ssb_index,
                      int sfn,
-                     nfapi_nr_config_request_t *config,
+                     nfapi_nr_config_request_scf_t *config,
                      NR_DL_FRAME_PARMS *frame_parms);
 
 /*!
@@ -105,11 +104,23 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
  */
 void nr_init_pbch_interleaver(uint8_t *interleaver);
 
-NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
+NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
+                              unsigned char Kmimo,
                               unsigned char Mdlharq,
                               uint32_t Nsoft,
                               uint8_t abstraction_flag,
-                              NR_DL_FRAME_PARMS *frame_parms,
-                              nfapi_nr_config_request_t *config);
+                              uint16_t N_RB);
+
+void rx_nr_prach(PHY_VARS_gNB *gNB,
+		 int frame,
+		 int subframe,
+		 uint16_t *max_preamble,
+		 uint16_t *max_preamble_energy,
+		 uint16_t *max_preamble_delay
+		 );
+
+void rx_nr_prach_ru(RU_t *ru,
+		    int frame,
+		    int subframe);
 
 #endif /*__NR_TRANSPORT__H__*/
diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h
index 6a88203f8c0..762346048f9 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h
+++ b/openair1/PHY/NR_TRANSPORT/nr_transport_common_proto.h
@@ -23,7 +23,7 @@
 /*! \file PHY/NR_TRANSPORT/nr_transport_common_proto.h
 * \brief Some support routines
 * \author
-* \date 2018
+* \date 2019
 * \version 0.1
 * \company Eurecom
 * \email:
@@ -36,29 +36,13 @@
 
 #include "PHY/defs_nr_common.h"
 
-#define MAX_NUM_NR_DLSCH_SEGMENTS 16
-#define MAX_NUM_NR_ULSCH_SEGMENTS MAX_NUM_NR_DLSCH_SEGMENTS
-
-#define MAX_NR_DLSCH_PAYLOAD_BYTES (MAX_NUM_NR_DLSCH_SEGMENTS*1056)
-#define MAX_NR_ULSCH_PAYLOAD_BYTES (MAX_NUM_NR_ULSCH_SEGMENTS*1056)
-
-#define MAX_NUM_NR_CHANNEL_BITS (14*273*12*6)  // 14 symbols, 273 RB
-#define MAX_NUM_NR_RE (14*273*12)
 
 #define NR_PUSCH_x 2 // UCI placeholder bit TS 38.212 V15.4.0 subclause 5.3.3.1
 #define NR_PUSCH_y 3 // UCI placeholder bit 
 
-/** \brief Computes Q based on I_MCS PDSCH and table_idx for downlink. Implements MCS Tables from 38.214. */
-uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx);
-uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx);
 
-/** \brief Computes Q based on I_MCS PDSCH and table_idx for uplink. Implements MCS Tables from 38.214. */
-uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx);
-uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx);
 
-void nr_get_tbs_dl(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu,
-                   nfapi_nr_dl_config_dci_dl_pdu dci_pdu,
-                   nfapi_nr_config_request_t config);
+
 
 /** \brief Computes available bits G. */
 uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch, uint8_t nb_re_dmrs, uint16_t length_dmrs, uint8_t Qm, uint8_t Nl);
diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h
index 4c8d8650e3a..9ce56421fc4 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h
+++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h
@@ -65,20 +65,12 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
     @param is_dmrs_symbol, flag to indicate wether this OFDM symbol contains DMRS symbols or not.
 
 */
-void nr_ulsch_extract_rbs_single(int **rxdataF,
-                                 int **ul_ch_estimates,
-                                 int **rxdataF_ext,
-                                 int **ul_ch_estimates_ext,
-                                 uint32_t rxdataF_ext_offset,
-                                 // unsigned int *rb_alloc, [hna] Resource Allocation Type 1 is assumed only for the moment
+void nr_ulsch_extract_rbs_single(int32_t **rxdataF,
+                                 NR_gNB_PUSCH *pusch_vars,
                                  unsigned char symbol,
-                                 unsigned short start_rb,
-                                 unsigned short nb_rb_pusch,
-                                 NR_DL_FRAME_PARMS *frame_parms,
-                                 uint8_t dmrs_symbol,
-                                 uint16_t number_symbols,
-                                 uint8_t mapping_type,
-                                 dmrs_UplinkConfig_t *dmrs_UplinkConfig);
+                                 uint8_t is_dmrs_symbol,
+                                 nfapi_nr_pusch_pdu_t *pusch_pdu,
+                                 NR_DL_FRAME_PARMS *frame_parms);
 
 void nr_ulsch_scale_channel(int32_t **ul_ch_estimates_ext,
                             NR_DL_FRAME_PARMS *frame_parms,
@@ -212,3 +204,11 @@ uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx);
 uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx);
 
 uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx);
+
+void rx_nr_prach(PHY_VARS_gNB *gNB,
+		 int frame,
+		 int subframe,
+		 uint16_t *max_preamble,
+		 uint16_t *max_preamble_energy,
+		 uint16_t *max_preamble_delay
+		 );
diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h
index 76a2b2b0753..7ff52ae6925 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h
+++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h
@@ -32,9 +32,9 @@
 
 #include "PHY/defs_gNB.h"
 
-void free_gNB_ulsch(NR_gNB_ULSCH_t **ulsch);
+void free_gNB_ulsch(NR_gNB_ULSCH_t **ulsch,uint8_t N_RB_UL);
 
-NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag);
+NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint16_t N_RB_UL, uint8_t abstraction_flag);
 
 
 /*! \brief Perform PUSCH decoding. TS 38.212 V15.4.0 subclause 6.2
@@ -53,12 +53,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
                            uint8_t UE_id,
                            short *ulsch_llr,
                            NR_DL_FRAME_PARMS *frame_parms,
+                           nfapi_nr_pusch_pdu_t *pusch_pdu,
                            uint32_t frame,
-                           uint16_t nb_symb_sch,
-                           uint16_t nb_re_dmrs,
                            uint8_t nr_tti_rx,
                            uint8_t harq_pid,
-                           uint8_t is_crnti);
+                           uint32_t G);
 
 
 /*! \brief Perform PUSCH unscrambling. TS 38.211 V15.4.0 subclause 6.3.1.1
diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c
index 3945439a45b..e8a961360f4 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c
@@ -37,8 +37,7 @@
 #include "PHY/CODING/coding_extern.h"
 #include "PHY/CODING/coding_defs.h"
 #include "PHY/CODING/lte_interleaver_inline.h"
-#include "PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h"
-#include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h"
+#include "PHY/CODING/nrLDPC_extern.h"
 #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
 #include "PHY/NR_TRANSPORT/nr_ulsch.h"
 #include "PHY/NR_TRANSPORT/nr_dlsch.h"
@@ -58,29 +57,45 @@ static uint64_t nb_error_decod =0;
 
 //extern double cpuf;
 
-void free_gNB_ulsch(NR_gNB_ULSCH_t **ulschptr) {
+void free_gNB_ulsch(NR_gNB_ULSCH_t **ulschptr,uint8_t N_RB_UL)
+{
+
   int i,r;
+  uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS;  //number of segments to be allocated
   NR_gNB_ULSCH_t *ulsch = *ulschptr;
 
   if (ulsch) {
+    if (N_RB_UL != 273) {
+      a_segments = a_segments*N_RB_UL;
+      a_segments = a_segments/273;
+    }  
+
+    uint16_t ulsch_bytes = a_segments*1056;  // allocated bytes per segment
+
     for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) {
 
       if (ulsch->harq_processes[i]) {
         if (ulsch->harq_processes[i]->b) {
-          free16(ulsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES);
+          free16(ulsch->harq_processes[i]->b,ulsch_bytes);
           ulsch->harq_processes[i]->b = NULL;
         }
-        for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS; r++) {
+        for (r=0; r<a_segments; r++) {
           free16(ulsch->harq_processes[i]->c[r],(8448)*sizeof(uint8_t));
           ulsch->harq_processes[i]->c[r] = NULL;
         }
-        for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS; r++) {
+        for (r=0; r<a_segments; r++) {
           if (ulsch->harq_processes[i]->d[r]) {
             free16(ulsch->harq_processes[i]->d[r],(68*384)*sizeof(int16_t));
             ulsch->harq_processes[i]->d[r] = NULL;
           }
         }
-        for (r=0; r<(MAX_NUM_NR_ULSCH_SEGMENTS); r++) {
+        for (r=0; r<a_segments; r++) {
+          if (ulsch->harq_processes[i]->w[r]) {
+            free16(ulsch->harq_processes[i]->w[r],(3*(6144+64))*sizeof(int16_t));
+            ulsch->harq_processes[i]->w[r] = NULL;
+          }
+        }
+        for (r=0; r<a_segments; r++) {
           if (ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]){
             nrLDPC_free_mem(ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]);
             ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL;
@@ -96,23 +111,20 @@ void free_gNB_ulsch(NR_gNB_ULSCH_t **ulschptr) {
 }
 
 
-NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag)
+NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint16_t N_RB_UL, uint8_t abstraction_flag)
 {
 
   NR_gNB_ULSCH_t *ulsch;
   uint8_t exit_flag = 0,i,r;
-  unsigned char bw_scaling =1;
-
-  switch (N_RB_UL) {
-    case 106:
-      bw_scaling =2;
-    break;
+  uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS;  //number of segments to be allocated
 
-    default:
-      bw_scaling =1;
-    break;
+  if (N_RB_UL != 273) {
+    a_segments = a_segments*N_RB_UL;
+    a_segments = a_segments/273;
   }
 
+  uint16_t ulsch_bytes = a_segments*1056;  // allocated bytes per segment
+
   ulsch = (NR_gNB_ULSCH_t *)malloc16(sizeof(NR_gNB_ULSCH_t));
 
   if (ulsch) {
@@ -130,15 +142,15 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8
 
         memset(ulsch->harq_processes[i],0,sizeof(NR_UL_gNB_HARQ_t));
 
-        ulsch->harq_processes[i]->b = (uint8_t*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling);
+        ulsch->harq_processes[i]->b = (uint8_t*)malloc16(ulsch_bytes);
 
         if (ulsch->harq_processes[i]->b)
-          memset(ulsch->harq_processes[i]->b,0,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling);
+          memset(ulsch->harq_processes[i]->b,0,ulsch_bytes);
         else
           exit_flag=3;
 
         if (abstraction_flag == 0) {
-          for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling; r++) {
+          for (r=0; r<a_segments; r++) {
 
             ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
 
@@ -155,6 +167,13 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8
               memset(ulsch->harq_processes[i]->d[r],0,(68*384)*sizeof(int16_t));
             else
               exit_flag=2;
+
+            ulsch->harq_processes[i]->w[r] = (int16_t*)malloc16((3*(6144+64))*sizeof(int16_t));
+
+            if (ulsch->harq_processes[i]->w[r])
+              memset(ulsch->harq_processes[i]->w[r],0,(3*(6144+64))*sizeof(int16_t));
+            else
+              exit_flag=2;
           }
         }
       } else {
@@ -165,9 +184,8 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8
     if (exit_flag==0)
       return(ulsch);
   }
-
   printf("new_gNB_ulsch with size %zu: exit_flag = %hhu\n",sizeof(NR_UL_gNB_HARQ_t), exit_flag);
-  free_gNB_ulsch(&ulsch);
+  free_gNB_ulsch(&ulsch,N_RB_UL);
   return(NULL);
 }
 
@@ -263,7 +281,7 @@ void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch)
         /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled
         //uint8_t h[MAX_NUM_CHANNEL_BITS];
         /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
-        //int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)];
+        //int16_t w[MAX_NUM_NR_ULSCH_SEGMENTS][3*(6144+64)];
       }
     }
   }
@@ -277,15 +295,13 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
                            uint8_t UE_id,
                            short *ulsch_llr,
                            NR_DL_FRAME_PARMS *frame_parms,
+                           nfapi_nr_pusch_pdu_t *pusch_pdu,
                            uint32_t frame,
-                           uint16_t nb_symb_sch,
-                           uint16_t nb_re_dmrs,
                            uint8_t nr_tti_rx,
                            uint8_t harq_pid,
-                           uint8_t is_crnti)
-{
+                           uint32_t G) {
+
   uint32_t A,E;
-  uint32_t G;
   uint32_t ret, offset;
   int32_t no_iteration_ldpc, length_dec;
   uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0;
@@ -299,7 +315,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
 
   NR_gNB_ULSCH_t                       *ulsch                 = phy_vars_gNB->ulsch[UE_id][0];
   NR_UL_gNB_HARQ_t                     *harq_process          = ulsch->harq_processes[harq_pid];
-  nfapi_nr_ul_config_ulsch_pdu_rel15_t *nfapi_ulsch_pdu_rel15 = &harq_process->ulsch_pdu.ulsch_pdu_rel15;
   
   t_nrLDPC_dec_params decParams;
   t_nrLDPC_dec_params* p_decParams    = &decParams;
@@ -319,13 +334,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
   double   Coderate = 0.0;
   
   // ------------------------------------------------------------------
-  uint16_t nb_rb          = nfapi_ulsch_pdu_rel15->number_rbs;
-  uint16_t number_symbols = nfapi_ulsch_pdu_rel15->number_symbols;
-  uint8_t Qm              = nfapi_ulsch_pdu_rel15->Qm;
-  uint16_t R               = nfapi_ulsch_pdu_rel15->R;
-  uint8_t mcs             = nfapi_ulsch_pdu_rel15->mcs;
-  uint8_t n_layers        = nfapi_ulsch_pdu_rel15->n_layers;
-  uint8_t length_dmrs     = nfapi_ulsch_pdu_rel15->length_dmrs;
+  uint16_t nb_rb          = pusch_pdu->rb_size;
+  uint8_t Qm              = pusch_pdu->qam_mod_order;
+  uint16_t R              = pusch_pdu->target_code_rate;
+  uint8_t mcs             = pusch_pdu->mcs_index;
+  uint8_t n_layers        = pusch_pdu->nrOfLayers;
   // ------------------------------------------------------------------
 
   uint32_t i,j;
@@ -345,19 +358,20 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
   }
 
   // harq_process->trials[nfapi_ulsch_pdu_rel15->round]++;
-  harq_process->TBS = nr_compute_tbs(Qm, R, nb_rb, number_symbols, nb_re_dmrs*length_dmrs, 0, n_layers);
+  harq_process->TBS = pusch_pdu->pusch_data.tb_size;
 
-  A   = harq_process->TBS;
+  A   = (harq_process->TBS)<<3;
   ret = ulsch->max_ldpc_iterations + 1;
 
-  G = nr_get_G(nb_rb, number_symbols, nb_re_dmrs, length_dmrs, Qm, n_layers);
-
-  LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d, nb_re_dmrs %d, Qm %d, n_layers %d\n",harq_pid,A,G, mcs, n_layers, nb_symb_sch,nb_rb, nb_re_dmrs, Qm, n_layers);
+  LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, n_layers %d\n",harq_pid,A,G, mcs, n_layers, nb_rb, Qm, n_layers);
 
   if (harq_process->round == 0) {
 
     // This is a new packet, so compute quantities regarding segmentation
-    harq_process->B = A+24;
+    if (A > 3824)
+      harq_process->B = A+24;
+    else
+      harq_process->B = A+16;
 
     if (R<1024)
       Coderate = (float) R /(float) 1024;
@@ -394,20 +408,20 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
     }
   }
 
-    // [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F)
-    nr_segmentation(NULL,
-                    NULL,
-                    harq_process->B,
-                    &harq_process->C,
-                    &harq_process->K,
-                    &harq_process->Z, // [hna] Z is Zc
-                    &harq_process->F,
-                    p_decParams->BG);
+  // [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F)
+  nr_segmentation(NULL,
+                  NULL,
+                  harq_process->B,
+                  &harq_process->C,
+                  &harq_process->K,
+                  &harq_process->Z, // [hna] Z is Zc
+                  &harq_process->F,
+                  p_decParams->BG);
 
 #ifdef DEBUG_ULSCH_DECODING
     printf("ulsch decoding nr segmentation Z %d\n", harq_process->Z);
     if (!frame%100)
-      printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, harq_process->Z, harq_process->Nl);
+      printf("K %d C %d Z %d\n", harq_process->K, harq_process->C, harq_process->Z);
 #endif
   }
   p_decParams->Z = harq_process->Z;
@@ -419,21 +433,15 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
   err_flag = 0;
   r_offset = 0;
 
-  unsigned char bw_scaling =1;
-
-  switch (frame_parms->N_RB_UL) {
-
-    case 106:
-      bw_scaling =2;
-      break;
+  uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS;  //number of segments to be allocated
 
-    default:
-      bw_scaling =1;
-      break;
+  if (nb_rb != 273) {
+    a_segments = a_segments*nb_rb;
+    a_segments = a_segments/273;
   }
 
-  if (harq_process->C > MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling) {
-    LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling);
+  if (harq_process->C > a_segments) {
+    LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,a_segments);
     return (ulsch->max_ldpc_iterations + 1);
   }
 #ifdef DEBUG_ULSCH_DECODING
@@ -448,7 +456,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
   K_bytes_F = Kr_bytes-(harq_process->F>>3);
 
   for (r=0; r<harq_process->C; r++) {
-    E = nr_get_E(G, harq_process->C, nfapi_ulsch_pdu_rel15->Qm, nfapi_ulsch_pdu_rel15->n_layers, r);
+    E = nr_get_E(G, harq_process->C, Qm, n_layers, r);
 
 #if gNB_TIMING_TRACE
     start_meas(ulsch_deinterleaving_stats);
@@ -461,7 +469,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
     //////////////////////////// ulsch_llr =====> harq_process->e //////////////////////////////
 
     nr_deinterleaving_ldpc(E,
-                           nfapi_ulsch_pdu_rel15->Qm,
+                           Qm,
                            harq_process->e[r],
                            ulsch_llr+r_offset);
 
@@ -481,10 +489,10 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
           harq_pid,r, G,
           Kr*3,
           harq_process->TBS,
-          nfapi_ulsch_pdu_rel15->Qm,
-          nfapi_ulsch_pdu_rel15->number_rbs,
-          nfapi_ulsch_pdu_rel15->n_layers,
-          nfapi_ulsch_pdu_rel15->rv,
+          Qm,
+          nb_rb,
+          n_layers,
+          pusch_pdu->pusch_data.rv_index,
           harq_process->round);
 #endif
     //////////////////////////////////////////////////////////////////////////////////////////
@@ -496,7 +504,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
 
     ///////////////////////// harq_process->e =====> harq_process->d /////////////////////////
 
-    Tbslbrm = nr_compute_tbslbrm(0,nb_rb,nfapi_ulsch_pdu_rel15->n_layers,harq_process->C);
+    Tbslbrm = nr_compute_tbslbrm(0,nb_rb,n_layers,harq_process->C);
 
     if (nr_rate_matching_ldpc_rx(Ilbrm,
                                  Tbslbrm,
@@ -505,9 +513,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
                                  harq_process->d[r],
                                  harq_process->e[r],
                                  harq_process->C,
-                                 nfapi_ulsch_pdu_rel15->rv,
+                                 pusch_pdu->pusch_data.rv_index,
                                  (harq_process->round==0)?1:0,
-                                 E)==-1) {
+                                 E,
+				 harq_process->F,
+				 Kr-harq_process->F-2*(p_decParams->Z))==-1) {
 #if gNB_TIMING_TRACE
       stop_meas(ulsch_rate_unmatching_stats);
 #endif
@@ -540,7 +550,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
 
     //    printf("done\n");
     if (harq_process->C == 1) {
-      crc_type = CRC24_A;
+      if (A > 3824)
+        crc_type = CRC24_A;
+      else
+        crc_type = CRC16;
+
       length_dec = harq_process->B;
     }
     else {
@@ -565,7 +579,9 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
       }
 
       AssertFatal(kc!=255,"");
-      for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++) {
+      j+=(harq_process->F>>3);
+      //      for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++) {
+      for (i=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++) {
         pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j]));
       }
     
@@ -637,7 +653,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
   int32_t tti_rx_prev = nr_tti_rx - 1;
   if (tti_rx_prev < 0) {
     frame_rx_prev--;
-    tti_rx_prev += 10*frame_parms->ttis_per_subframe;
+    tti_rx_prev += frame_parms->slots_per_frame;
   }
   frame_rx_prev = frame_rx_prev%1024;
 
@@ -661,13 +677,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
       ulsch->harq_mask &= ~(1 << harq_pid);
     }
 
-    if(is_crnti) {
-      LOG_D(PHY,"[gNB %d] ULSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n",
-            phy_vars_gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->status,harq_process->round,ulsch->Mlimit,harq_process->TBS);
-    }
+    //  LOG_D(PHY,"[gNB %d] ULSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n",
+       //     phy_vars_gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->status,harq_process->round,ulsch->Mlimit,harq_process->TBS);
 
     harq_process->handled  = 1;
-    return (ulsch->max_ldpc_iterations + 1);
+    ret = ulsch->max_ldpc_iterations + 1;
 
   } else {
 
@@ -684,31 +698,28 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
     // harq_process->harq_ack.harq_id = harq_pid;
     // harq_process->harq_ack.send_harq_status = 1;
 
-    if(is_crnti)
-    {
-      LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d (pid %d, round %d, TBS %d)\n",phy_vars_gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->round,harq_process->TBS);
-    }
-  }
-
-  // Reassembly of Transport block here
-  offset = 0;
-  Kr = harq_process->K;
-  Kr_bytes = Kr>>3;
-
-  for (r=0; r<harq_process->C; r++) {
-
-    memcpy(harq_process->b+offset,
-           harq_process->c[r],
-           Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0));
-
-    offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0));
+    //  LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for nr_tti_rx %d (pid %d, round %d, TBS %d)\n",phy_vars_gNB->Mod_id,nr_tti_rx,harq_pid,harq_process->round,harq_process->TBS);
 
+    // Reassembly of Transport block here
+    offset = 0;
+    Kr = harq_process->K;
+    Kr_bytes = Kr>>3;
+    
+    for (r=0; r<harq_process->C; r++) {
+      
+      memcpy(harq_process->b+offset,
+	     harq_process->c[r],
+	     Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0));
+      
+      offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0));
+      
 #ifdef DEBUG_ULSCH_DECODING
-    printf("Segment %u : Kr = %u bytes\n", r, Kr_bytes);
-    printf("copied %d bytes to b sequence (harq_pid %d)\n", (Kr_bytes - (harq_process->F>>3)-((harq_process->C>1)?3:0)), harq_pid);
-    printf("b[0] = %x, c[%d] = %x\n", harq_process->b[offset], harq_process->F>>3, harq_process->c[r]);
+      printf("Segment %u : Kr = %u bytes\n", r, Kr_bytes);
+      printf("copied %d bytes to b sequence (harq_pid %d)\n", (Kr_bytes - (harq_process->F>>3)-((harq_process->C>1)?3:0)), harq_pid);
+      printf("b[0] = %x, c[%d] = %x\n", harq_process->b[offset], harq_process->F>>3, harq_process->c[r]);
 #endif
-
+      
+    }
   }
 
 #ifdef DEBUG_ULSCH_DECODING
diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c
index eb35fd7dc6a..bce8ddcc291 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c
@@ -4,6 +4,7 @@
 #include "PHY/impl_defs_top.h"
 #include "PHY/NR_TRANSPORT/nr_sch_dmrs.h"
 #include "PHY/NR_REFSIG/dmrs_nr.h"
+#include "PHY/NR_REFSIG/ptrs_nr.h"
 #include "PHY/NR_ESTIMATION/nr_ul_estimation.h"
 #include "PHY/defs_nr_common.h"
 
@@ -221,77 +222,97 @@ void nr_idft(uint32_t *z, uint32_t Msc_PUSCH)
 
 }
 
-void nr_ulsch_extract_rbs_single(int **rxdataF,
-                                 int **ul_ch_estimates,
-                                 int **rxdataF_ext,
-                                 int **ul_ch_estimates_ext,
-                                 uint32_t rxdataF_ext_offset,
-                                 // unsigned int *rb_alloc, [hna] Resource Allocation Type 1 is assumed only for the moment
+
+void nr_ulsch_extract_rbs_single(int32_t **rxdataF,
+                                 NR_gNB_PUSCH *pusch_vars,
                                  unsigned char symbol,
-                                 unsigned short start_rb,
-                                 unsigned short nb_rb_pusch,
-                                 NR_DL_FRAME_PARMS *frame_parms,
-                                 uint8_t dmrs_symbol,
-                                 uint16_t number_symbols,
-                                 uint8_t mapping_type,
-                                 dmrs_UplinkConfig_t *dmrs_UplinkConfig)
+                                 uint8_t is_dmrs_symbol,
+                                 nfapi_nr_pusch_pdu_t *pusch_pdu,
+                                 NR_DL_FRAME_PARMS *frame_parms)
 {
   unsigned short start_re, re, nb_re_pusch;
   unsigned char aarx;
+  uint8_t K_ptrs;
   uint32_t rxF_ext_index = 0;
   uint32_t ul_ch0_ext_index = 0;
   uint32_t ul_ch0_index = 0;
-  uint8_t is_dmrs_symbol_flag, k_prime;
-  uint16_t n=0;
-
+  uint32_t ul_ch0_ptrs_ext_index = 0;
+  uint32_t ul_ch0_ptrs_index = 0;
+  uint8_t is_ptrs_symbol_flag,k_prime;
+  uint16_t n=0, num_ptrs_symbols;
   int16_t *rxF,*rxF_ext;
   int *ul_ch0,*ul_ch0_ext;
+  int *ul_ch0_ptrs,*ul_ch0_ptrs_ext;
+  uint16_t n_rnti = pusch_pdu->rnti;
+  uint8_t delta = 0;
 
 #ifdef DEBUG_RB_EXT
 
   printf("--------------------symbol = %d-----------------------\n", symbol);
-  printf("--------------------ch_ext_index = %d-----------------------\n", symbol*NR_NB_SC_PER_RB * nb_rb_pusch);
+  printf("--------------------ch_ext_index = %d-----------------------\n", symbol*NR_NB_SC_PER_RB * pusch_pdu->rb_size);
 
 #endif
   
-  start_re = (frame_parms->first_carrier_offset + (start_rb * NR_NB_SC_PER_RB))%frame_parms->ofdm_symbol_size;
-  
-  nb_re_pusch = NR_NB_SC_PER_RB * nb_rb_pusch;
-  is_dmrs_symbol_flag = 0;
+  uint8_t is_dmrs_re;
+  start_re = (frame_parms->first_carrier_offset + (pusch_pdu->rb_start * NR_NB_SC_PER_RB))%frame_parms->ofdm_symbol_size;
+  nb_re_pusch = NR_NB_SC_PER_RB * pusch_pdu->rb_size;
+  is_ptrs_symbol_flag = 0;
+  num_ptrs_symbols = 0;
+
+  K_ptrs = (pusch_pdu->pusch_ptrs.ptrs_freq_density)?4:2;
 
   for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) {
     
     rxF       = (int16_t *)&rxdataF[aarx][symbol * frame_parms->ofdm_symbol_size];
-    rxF_ext   = (int16_t *)&rxdataF_ext[aarx][symbol * nb_re_pusch]; // [hna] rxdataF_ext isn't contiguous in order to solve an alignment problem ib llr computation in case of mod_order = 4, 6
+    rxF_ext   = (int16_t *)&pusch_vars->rxdataF_ext[aarx][symbol * nb_re_pusch]; // [hna] rxdataF_ext isn't contiguous in order to solve an alignment problem ib llr computation in case of mod_order = 4, 6
+
+    ul_ch0     = &pusch_vars->ul_ch_estimates[aarx][pusch_vars->dmrs_symbol*frame_parms->ofdm_symbol_size]; // update channel estimates if new dmrs symbol are available
+
+    ul_ch0_ext = &pusch_vars->ul_ch_estimates_ext[aarx][symbol*nb_re_pusch];
 
-    ul_ch0     = &ul_ch_estimates[aarx][dmrs_symbol*frame_parms->ofdm_symbol_size]; // update channel estimates if new dmrs symbol are available
+    ul_ch0_ptrs     = &pusch_vars->ul_ch_ptrs_estimates[aarx][pusch_vars->ptrs_symbol_index*frame_parms->ofdm_symbol_size]; // update channel estimates if new dmrs symbol are available
 
-    ul_ch0_ext = &ul_ch_estimates_ext[aarx][symbol*nb_re_pusch];
+    ul_ch0_ptrs_ext = &pusch_vars->ul_ch_ptrs_estimates_ext[aarx][symbol*nb_re_pusch];
 
     n = 0;
     k_prime = 0;
 
     for (re = 0; re < nb_re_pusch; re++) {
 
-      is_dmrs_symbol_flag =  is_dmrs_symbol(symbol,
-                                            (start_re + re)%frame_parms->ofdm_symbol_size,
-                                            start_re,
-                                            k_prime,
-                                            n,
-                                            0,
-                                            number_symbols,
-                                            dmrs_UplinkConfig,
-                                            mapping_type,
-                                            frame_parms->ofdm_symbol_size);
+      if (is_dmrs_symbol)
+        is_dmrs_re = (re == get_dmrs_freq_idx_ul(n, k_prime, delta, pusch_pdu->dmrs_config_type));
+      else
+        is_dmrs_re = 0;
+
+      if ( ((pusch_pdu->pdu_bit_map)>>2)& 0x01 ) {
+        is_ptrs_symbol_flag = is_ptrs_symbol(symbol,
+                                             (start_re + re)%frame_parms->ofdm_symbol_size,
+                                             n_rnti,
+                                             pusch_pdu->rb_size,
+                                             pusch_pdu->nr_of_symbols,
+                                             aarx,
+                                             K_ptrs,
+                                             pusch_vars->ptrs_symbols,
+                                             start_re,
+                                             frame_parms->ofdm_symbol_size,
+                                             pusch_pdu->dmrs_config_type,
+                                             pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset);
+
+        if (is_ptrs_symbol_flag == 1)
+          num_ptrs_symbols++;
+
+      }
+
   #ifdef DEBUG_RB_EXT
       printf("re = %d, is_dmrs_symbol_flag = %d, symbol = %d\n", re, is_dmrs_symbol_flag, symbol);
   #endif
 
-      if ( is_dmrs_symbol_flag == 0 ) {
+      if ( is_dmrs_re == 0 && is_ptrs_symbol_flag == 0) {
 
         rxF_ext[rxF_ext_index]     = (rxF[ ((start_re + re)*2)      % (frame_parms->ofdm_symbol_size*2)]);
         rxF_ext[rxF_ext_index + 1] = (rxF[(((start_re + re)*2) + 1) % (frame_parms->ofdm_symbol_size*2)]);
         ul_ch0_ext[ul_ch0_ext_index] = ul_ch0[ul_ch0_index];
+        ul_ch0_ptrs_ext[ul_ch0_ptrs_ext_index] = ul_ch0_ptrs[ul_ch0_ptrs_index];
 
   #ifdef DEBUG_RB_EXT
         printf("rxF_ext[%d] = %d\n", rxF_ext_index, rxF_ext[rxF_ext_index]);
@@ -299,6 +320,7 @@ void nr_ulsch_extract_rbs_single(int **rxdataF,
   #endif
 
         ul_ch0_ext_index++;
+        ul_ch0_ptrs_ext_index++;
         rxF_ext_index +=2;
       } else {
         k_prime++;
@@ -306,8 +328,12 @@ void nr_ulsch_extract_rbs_single(int **rxdataF,
         n+=(k_prime)?0:1;
       }
       ul_ch0_index++;
+      ul_ch0_ptrs_index++;
     }
   }
+
+  pusch_vars->ptrs_sc_per_ofdm_symbol = num_ptrs_symbols;
+
 }
 
 void nr_ulsch_scale_channel(int **ul_ch_estimates_ext,
@@ -334,7 +360,7 @@ void nr_ulsch_scale_channel(int **ul_ch_estimates_ext,
 
   ch_amp128 = _mm_set1_epi16(ch_amp); // Q3.13
 
-  for (aatx=0; aatx < frame_parms->nb_antenna_ports_eNB; aatx++) {
+  for (aatx=0; aatx < frame_parms->nb_antenna_ports_gNB; aatx++) {
     for (aarx=0; aarx < frame_parms->nb_antennas_rx; aarx++) {
 
       ul_ch128 = (__m128i *)&ul_ch_estimates_ext[aarx][symbol*nb_rb*NR_NB_SC_PER_RB];
@@ -420,7 +446,7 @@ void nr_ulsch_channel_level(int **ul_ch_estimates_ext,
 
   symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
 
-  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++)
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_gNB; aatx++)
     for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
       //clear average level
       avg128U = vdupq_n_s32(0);
@@ -436,7 +462,7 @@ void nr_ulsch_channel_level(int **ul_ch_estimates_ext,
         avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[2], ul_ch128[2]));
         avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[3], ul_ch128[3]));
 
-        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
+        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_gNB!=1)) {
           ul_ch128+=4;
         } else {
           avg128U = vqaddq_s32(avg128U, vmull_s16(ul_ch128[4], ul_ch128[4]));
@@ -469,18 +495,17 @@ void nr_ulsch_channel_level(int **ul_ch_estimates_ext,
 }
 
 void nr_ulsch_channel_compensation(int **rxdataF_ext,
-                                int **ul_ch_estimates_ext,
-                                int **ul_ch_mag,
-                                int **ul_ch_magb,
-                                int **rxdataF_comp,
-                                int **rho,
-                                NR_DL_FRAME_PARMS *frame_parms,
-                                unsigned char symbol,
-                                uint8_t is_dmrs_symbol,
-                                unsigned char mod_order,
-                                unsigned short nb_rb,
-                                unsigned char output_shift)
-{
+                                   int **ul_ch_estimates_ext,
+                                   int **ul_ch_mag,
+                                   int **ul_ch_magb,
+                                   int **rxdataF_comp,
+                                   int **rho,
+                                   NR_DL_FRAME_PARMS *frame_parms,
+                                   unsigned char symbol,
+                                   uint8_t is_dmrs_symbol,
+                                   unsigned char mod_order,
+                                   unsigned short nb_rb,
+                                   unsigned char output_shift) {
 
 #ifdef DEBUG_CH_COMP
   int16_t *rxF, *ul_ch;
@@ -782,7 +807,7 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext,
   symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
 
   if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
-    if (frame_parms->nb_antenna_ports_eNB==1) { // 10 out of 12 so don't reduce size
+    if (frame_parms->nb_antenna_ports_gNB==1) { // 10 out of 12 so don't reduce size
       nb_rb=1+(5*nb_rb/6);
     }
     else {
@@ -790,7 +815,7 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext,
     }
   }
 
-  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) {
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_gNB; aatx++) {
     if (mod_order == 4) {
       QAM_amp128  = vmovq_n_s16(QAM16_n1);  // 2/sqrt(10)
       QAM_amp128b = vmovq_n_s16(0);
@@ -1001,139 +1026,150 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
                  unsigned char harq_pid)
 {
 
-  uint8_t first_symbol_flag, aarx, aatx, dmrs_symbol_flag; // dmrs_symbol_flag, a flag to indicate DMRS REs in current symbol
-  NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
-  nfapi_nr_ul_config_ulsch_pdu_rel15_t *rel15_ul = &gNB->ulsch[UE_id][0]->harq_processes[harq_pid]->ulsch_pdu.ulsch_pdu_rel15;
+  uint8_t first_symbol_flag, aarx, aatx, dmrs_symbol_flag, ptrs_symbol_flag; // dmrs_symbol_flag, a flag to indicate DMRS REs in current symbol
   uint32_t nb_re_pusch, bwp_start_subcarrier;
-  uint8_t mapping_type;
+  uint8_t L_ptrs = 0; // PTRS parameter
   int avgs;
   int avg[4];
+  NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
+  nfapi_nr_pusch_pdu_t *rel15_ul = &gNB->ulsch[UE_id][0]->harq_processes[harq_pid]->ulsch_pdu;
 
   dmrs_symbol_flag = 0;
+  ptrs_symbol_flag = 0;
   first_symbol_flag = 0;
-  mapping_type = gNB->pusch_config.pusch_TimeDomainResourceAllocation[0]->mappingType;
+  gNB->pusch_vars[UE_id]->ptrs_sc_per_ofdm_symbol = 0;
+
+  if(symbol == rel15_ul->start_symbol_index){
+    gNB->pusch_vars[UE_id]->rxdataF_ext_offset = 0;
+    gNB->pusch_vars[UE_id]->dmrs_symbol = 0;
+    gNB->pusch_vars[UE_id]->cl_done = 0;
+    gNB->pusch_vars[UE_id]->ptrs_symbols = 0;
+    first_symbol_flag = 1;
+
+    if ( ((rel15_ul->pdu_bit_map)>>2)& 0x01 ) {  // if there is ptrs pdu
+      L_ptrs = 1<<(rel15_ul->pusch_ptrs.ptrs_time_density);
+
+      set_ptrs_symb_idx(&gNB->pusch_vars[UE_id]->ptrs_symbols,
+                        rel15_ul->nr_of_symbols,
+                        rel15_ul->start_symbol_index,
+                        rel15_ul->dmrs_config_type,
+                        L_ptrs,
+                        1, // only dmrs of length 1 is currently supported
+                        frame_parms->ofdm_symbol_size);
+    }
+  }
 
-  if (mapping_type == typeB) {
+  bwp_start_subcarrier = (rel15_ul->rb_start*NR_NB_SC_PER_RB + frame_parms->first_carrier_offset) % frame_parms->ofdm_symbol_size;
 
-    if(symbol == rel15_ul->start_symbol){
-      gNB->pusch_vars[UE_id]->rxdataF_ext_offset = 0;
-      gNB->pusch_vars[UE_id]->dmrs_symbol = 0;
-      first_symbol_flag = 1;
-    }
+  dmrs_symbol_flag = ((rel15_ul->ul_dmrs_symb_pos)>>symbol)&0x01;
 
-    bwp_start_subcarrier = (rel15_ul->start_rb*NR_NB_SC_PER_RB + frame_parms->first_carrier_offset) % frame_parms->ofdm_symbol_size;
+  if (dmrs_symbol_flag == 1){
+    nb_re_pusch = rel15_ul->rb_size * ((rel15_ul->dmrs_config_type==pusch_dmrs_type1)?6:8);
+    gNB->pusch_vars[UE_id]->dmrs_symbol = symbol;
+  } else {
+    nb_re_pusch = rel15_ul->rb_size * NR_NB_SC_PER_RB;
+  }
 
-    dmrs_symbol_flag = is_dmrs_symbol(symbol,
-                                      0,
+  if ( ((rel15_ul->pdu_bit_map)>>2)& 0x01 ) {  // if there is ptrs pdu
+    ptrs_symbol_flag = is_ptrs_symbol(symbol,
                                       0,
+                                      rel15_ul->rnti,
+                                      rel15_ul->rb_size,
+                                      rel15_ul->nr_of_symbols,
                                       0,
+                                      (rel15_ul->pusch_ptrs.ptrs_freq_density)?4:2,
+                                      gNB->pusch_vars[UE_id]->ptrs_symbols,
                                       0,
-                                      0,
-                                      rel15_ul->number_symbols,
-                                      &gNB->dmrs_UplinkConfig,
-                                      mapping_type,
-                                      frame_parms->ofdm_symbol_size);
-
-    if (dmrs_symbol_flag == 1){
-      nb_re_pusch = rel15_ul->number_rbs * ((gNB->dmrs_UplinkConfig.pusch_dmrs_type==pusch_dmrs_type1)?6:8);
-      gNB->pusch_vars[UE_id]->dmrs_symbol = symbol;
-    } else {
-        nb_re_pusch = rel15_ul->number_rbs * NR_NB_SC_PER_RB;
-    }
-
+                                      frame_parms->ofdm_symbol_size,
+                                      rel15_ul->dmrs_config_type,
+                                      rel15_ul->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset);
+  }
 
-    //----------------------------------------------------------
-    //--------------------- Channel estimation ---------------------
-    //----------------------------------------------------------
+  if (ptrs_symbol_flag == 1){
+    gNB->pusch_vars[UE_id]->ptrs_symbol_index = symbol;
+  }
 
-    if (dmrs_symbol_flag == 1)
-      nr_pusch_channel_estimation(gNB,
-                                  0,
-                                  nr_tti_rx,
-                                  0, // p
-                                  symbol,
-                                  bwp_start_subcarrier,
-                                  rel15_ul->number_rbs,
-                                  &gNB->dmrs_UplinkConfig);
 
-    //----------------------------------------------------------
-    //--------------------- RBs extraction ---------------------
-    //----------------------------------------------------------
+  //----------------------------------------------------------
+  //--------------------- Channel estimation ---------------------
+  //----------------------------------------------------------
 
-    nr_ulsch_extract_rbs_single(gNB->common_vars.rxdataF,
-                                gNB->pusch_vars[UE_id]->ul_ch_estimates,
-                                gNB->pusch_vars[UE_id]->rxdataF_ext,
-                                gNB->pusch_vars[UE_id]->ul_ch_estimates_ext,
-                                gNB->pusch_vars[UE_id]->rxdataF_ext_offset,
-                                // rb_alloc, [hna] Resource Allocation Type 1 is assumed only for the moment
+  if (dmrs_symbol_flag == 1)
+    nr_pusch_channel_estimation(gNB,
+                                nr_tti_rx,
+                                0, // p
                                 symbol,
-                                rel15_ul->start_rb,
-                                rel15_ul->number_rbs,
-                                frame_parms,
-                                gNB->pusch_vars[UE_id]->dmrs_symbol,
-                                rel15_ul->number_symbols,
-                                mapping_type,
-                                &gNB->dmrs_UplinkConfig);
+                                bwp_start_subcarrier,
+                                rel15_ul);
+
+  //----------------------------------------------------------
+  //--------------------- RBs extraction ---------------------
+  //----------------------------------------------------------
+
+  nr_ulsch_extract_rbs_single(gNB->common_vars.rxdataF,
+                              gNB->pusch_vars[UE_id],
+                              symbol,
+                              dmrs_symbol_flag,
+                              rel15_ul,
+                              frame_parms);
+
+  nr_ulsch_scale_channel(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext,
+                         frame_parms,
+                         gNB->ulsch[UE_id],
+                         symbol,
+                         dmrs_symbol_flag,
+                         rel15_ul->rb_size,
+                         rel15_ul->dmrs_config_type);
+
 
-    nr_ulsch_scale_channel(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext,
+  if (first_symbol_flag==1) {
+
+    nr_ulsch_channel_level(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext,
                            frame_parms,
-                           gNB->ulsch[UE_id],
+                           avg,
                            symbol,
-                           dmrs_symbol_flag,
-                           rel15_ul->number_rbs,
-                           gNB->dmrs_UplinkConfig.pusch_dmrs_type);
-
-    if (first_symbol_flag==1) {
+                           nb_re_pusch,
+                           rel15_ul->rb_size);
+     avgs = 0;
 
-       nr_ulsch_channel_level(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext,
-                             frame_parms,
-                             avg,
-                             symbol,
-                             nb_re_pusch,
-                             rel15_ul->number_rbs);
-       avgs = 0;
+     for (aatx=0;aatx<frame_parms->nb_antennas_tx;aatx++)
+       for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++)
+         avgs = cmax(avgs,avg[(aatx<<1)+aarx]);
 
-       for (aatx=0;aatx<frame_parms->nb_antennas_tx;aatx++)
-         for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++)
-           avgs = cmax(avgs,avg[(aatx<<1)+aarx]);
+     gNB->pusch_vars[UE_id]->log2_maxh = (log2_approx(avgs)/2)+1;
 
-       gNB->pusch_vars[UE_id]->log2_maxh = (log2_approx(avgs)/2)+1;
+  }
 
-    }
+  nr_ulsch_channel_compensation(gNB->pusch_vars[UE_id]->rxdataF_ext,
+                                gNB->pusch_vars[UE_id]->ul_ch_estimates_ext,
+                                gNB->pusch_vars[UE_id]->ul_ch_mag0,
+                                gNB->pusch_vars[UE_id]->ul_ch_magb0,
+                                gNB->pusch_vars[UE_id]->rxdataF_comp,
+                                (frame_parms->nb_antennas_tx>1) ? gNB->pusch_vars[UE_id]->rho : NULL,
+                                frame_parms,
+                                symbol,
+                                dmrs_symbol_flag,
+                                rel15_ul->qam_mod_order,
+                                rel15_ul->rb_size,
+                                gNB->pusch_vars[UE_id]->log2_maxh);
 
-    nr_ulsch_channel_compensation(gNB->pusch_vars[UE_id]->rxdataF_ext,
-                                  gNB->pusch_vars[UE_id]->ul_ch_estimates_ext,
-                                  gNB->pusch_vars[UE_id]->ul_ch_mag0,
-                                  gNB->pusch_vars[UE_id]->ul_ch_magb0,
-                                  gNB->pusch_vars[UE_id]->rxdataF_comp,
-                                  (frame_parms->nb_antennas_tx>1) ? gNB->pusch_vars[UE_id]->rho : NULL,
-                                  frame_parms,
-                                  symbol,
-                                  dmrs_symbol_flag,
-                                  rel15_ul->Qm,
-                                  rel15_ul->number_rbs,
-                                  gNB->pusch_vars[UE_id]->log2_maxh);
-
-  #ifdef NR_SC_FDMA
-    nr_idft(&((uint32_t*)gNB->pusch_vars[UE_id]->rxdataF_ext[0])[symbol * rel15_ul->number_rbs * NR_NB_SC_PER_RB], nb_re_pusch);
-  #endif
+#ifdef NR_SC_FDMA
+  nr_idft(&((uint32_t*)gNB->pusch_vars[UE_id]->rxdataF_ext[0])[symbol * rel15_ul->rb_size * NR_NB_SC_PER_RB], nb_re_pusch);
+#endif
 
-    //----------------------------------------------------------
-    //-------------------- LLRs computation --------------------
-    //----------------------------------------------------------
+  //----------------------------------------------------------
+  //-------------------- LLRs computation --------------------
+  //----------------------------------------------------------
 
-    nr_ulsch_compute_llr(&gNB->pusch_vars[UE_id]->rxdataF_comp[0][symbol * rel15_ul->number_rbs * NR_NB_SC_PER_RB],
-                         gNB->pusch_vars[UE_id]->ul_ch_mag0,
-                         gNB->pusch_vars[UE_id]->ul_ch_magb0,
-                         &gNB->pusch_vars[UE_id]->llr[gNB->pusch_vars[UE_id]->rxdataF_ext_offset * rel15_ul->Qm],
-                         rel15_ul->number_rbs,
-                         nb_re_pusch,
-                         symbol,
-                         rel15_ul->Qm);
+  nr_ulsch_compute_llr(&gNB->pusch_vars[UE_id]->rxdataF_comp[0][symbol * rel15_ul->rb_size * NR_NB_SC_PER_RB],
+                       gNB->pusch_vars[UE_id]->ul_ch_mag0,
+                       gNB->pusch_vars[UE_id]->ul_ch_magb0,
+                       &gNB->pusch_vars[UE_id]->llr[gNB->pusch_vars[UE_id]->rxdataF_ext_offset * rel15_ul->qam_mod_order],
+                       rel15_ul->rb_size,
+                       nb_re_pusch,
+                       symbol,
+                       rel15_ul->qam_mod_order);
 
-    gNB->pusch_vars[UE_id]->rxdataF_ext_offset = gNB->pusch_vars[UE_id]->rxdataF_ext_offset +  nb_re_pusch;
-  } else {
-    LOG_E(PHY, "PUSCH mapping type A is not supported \n");
-  }
+  gNB->pusch_vars[UE_id]->rxdataF_ext_offset = gNB->pusch_vars[UE_id]->rxdataF_ext_offset +  nb_re_pusch - gNB->pusch_vars[UE_id]->ptrs_sc_per_ofdm_symbol;
   
 }
diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
index 09dadabaa50..be5c754bebf 100644
--- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
+++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
@@ -206,9 +206,6 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
   int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr;
   int ch_offset,symbol_offset;
   //int slot_pbch;
-  //fapi_nr_pbch_config_t *pbch_config = &ue->nrUE_config.pbch_config;
-  // initialized to 5ms in nr_init_ue for scenarios where UE is not configured (otherwise acquired by cell configuration from gNB or LTE)
-  //uint8_t ssb_periodicity = 10;// ue->ssb_periodicity;
 
   //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1];
 
@@ -452,7 +449,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
     {
         // do ifft of channel estimate
         for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++)
-            for (p=0; p<ue->frame_parms.nb_antenna_ports_eNB; p++) {
+            for (p=0; p<ue->frame_parms.nb_antenna_ports_gNB; p++) {
                 if (ue->pbch_vars[eNB_offset]->dl_ch_estimates[(p<<1)+aarx])
                 {
   		LOG_D(PHY,"Channel Impulse Computation Slot %d ThreadId %d Symbol %d ch_offset %d\n", Ns, ue->current_thread_id[Ns], symbol, ch_offset);
@@ -475,7 +472,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
                                 unsigned short coreset_start_subcarrier,
                                 unsigned short nb_rb_coreset)
 {
-  int pilot[200] __attribute__((aligned(16)));
+
   unsigned char aarx;
   unsigned short k;
   unsigned int pilot_cnt;
@@ -484,12 +481,9 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
 
   //uint16_t Nid_cell = (eNB_offset == 0) ? ue->frame_parms.Nid_cell : ue->measurements.adj_cell_id[eNB_offset-1];
 
-  uint8_t nushift;
   int **dl_ch_estimates  =ue->pdcch_vars[ue->current_thread_id[Ns]][eNB_offset]->dl_ch_estimates;
   int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF;
 
-  nushift = 1;
-  ue->frame_parms.nushift = nushift;
 
   if (ue->high_speed_flag == 0) // use second channel estimate position for temporary storage
     ch_offset     = ue->frame_parms.ofdm_symbol_size ;
@@ -510,14 +504,15 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
   fr = filt16a_r1;
 
 
-  // generate pilot 
+  // generate pilot
+  int pilot[nb_rb_coreset * 3] __attribute__((aligned(16))); 
   nr_pdcch_dmrs_rx(ue,eNB_offset,Ns,ue->nr_gold_pdcch[eNB_offset][Ns][symbol], &pilot[0],2000,nb_rb_coreset);
 
 
   for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
 
     pil   = (int16_t *)&pilot[0];
-    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)];
+    rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+1)];
     dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
 
     memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size));
@@ -588,7 +583,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
 
         if (k >= ue->frame_parms.ofdm_symbol_size){
 	  k-=ue->frame_parms.ofdm_symbol_size;
-	  rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+nushift)];}
+	  rxF   = (int16_t *)&rxdataF[aarx][(symbol_offset+k+1)];}
 
         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);
@@ -622,7 +617,7 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
         ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
 
 #ifdef DEBUG_PDCCH
-	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]);
+	printf("pilot %d : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
 #endif
 
         multadd_real_vector_complex_scalar(fr,
diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h
index ba328e39ec2..af06f9a98f3 100644
--- a/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h
+++ b/openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h
@@ -90,11 +90,6 @@ void phy_adjust_gain_nr(PHY_VARS_NR_UE *ue,
                         uint32_t rx_power_fil_dB,
                         uint8_t eNB_id);
 
-/*! \brief Function to return the path-loss based on the UE cell-specific reference signal strength and transmission power of eNB
-@param Mod_id Module ID for UE
-@param eNB_index Index of eNB on which to act
-@returns Path loss in dB
- */
-int16_t nr_get_PL(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
+int16_t get_nr_PL(PHY_VARS_NR_UE *ue,uint8_t gNB_index);
 
 #endif
diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c
index ac9713fec27..aa1e2b5ade0 100644
--- a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c
+++ b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c
@@ -19,8 +19,6 @@
  *      contact@openairinterface.org
  */
 
-// this function fills the PHY_vars->PHY_measurement structure
-
 #include "PHY/defs_nr_UE.h"
 #include "PHY/phy_extern_nr_ue.h"
 #include "common/utils/LOG/log.h"
@@ -57,649 +55,28 @@ void print_ints(char *s,int *x)
 }
 #endif
 
-int16_t nr_get_PL(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index)
+int16_t get_nr_PL(PHY_VARS_NR_UE *ue,uint8_t gNB_index)
 {
 
-  PHY_VARS_NR_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
   /*
-  int RSoffset;
-
-
   if (ue->frame_parms.mode1_flag == 1)
     RSoffset = 6;
   else
     RSoffset = 3;
   */
 
- /* LOG_D(PHY,"nr_get_PL : rsrp %f dBm/RE (%f), eNB power %d dBm/RE\n", 
+ /* LOG_D(PHY,"get_nr_PL : rsrp %f dBm/RE (%f), eNB power %d dBm/RE\n", 
         (1.0*dB_fixed_times10(ue->measurements.rsrp[eNB_index])-(10.0*ue->rx_total_gain_dB))/10.0,
         10*log10((double)ue->measurements.rsrp[eNB_index]),
         ue->frame_parms.pdsch_config_common.referenceSignalPower);*/
 
-  return((int16_t)(((10*ue->rx_total_gain_dB) -
-                    dB_fixed_times10(ue->measurements.rsrp[eNB_index]))/10));
+  return((int16_t)(((10*ue->rx_total_gain_dB) - dB_fixed_times10(ue->measurements.rsrp[gNB_index]))/10));
                     //        dB_fixed_times10(RSoffset*12*ue_g[Mod_id][CC_id]->frame_parms.N_RB_DL) +
                     //(ue->frame_parms.pdsch_config_common.referenceSignalPower*10))/10));
 }
 
 
-#if 0
-uint8_t get_n_adj_cells (module_id_t Mod_id,uint8_t CC_id)
-{
-
-  PHY_VARS_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
-
-  if (ue)
-    return ue->measurements.n_adj_cells;
-  else
-    return 0;
-}
-
-uint32_t get_rx_total_gain_dB (module_id_t Mod_id,uint8_t CC_id)
-{
-
-  PHY_VARS_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
-
-  if (ue)
-    return ue->rx_total_gain_dB;
-
-  return 0xFFFFFFFF;
-}
-uint32_t get_RSSI (module_id_t Mod_id,uint8_t CC_id)
-{
-
-  PHY_VARS_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
-
-  if (ue)
-    return ue->measurements.rssi;
-
-  return 0xFFFFFFFF;
-}
-double get_RSRP(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index)
-{
-
-  AssertFatal(PHY_vars_UE_g!=NULL,"PHY_vars_UE_g is null\n");
-  AssertFatal(PHY_vars_UE_g[Mod_id]!=NULL,"PHY_vars_UE_g[%d] is null\n",Mod_id);
-  AssertFatal(PHY_vars_UE_g[Mod_id][CC_id]!=NULL,"PHY_vars_UE_g[%d][%d] is null\n",Mod_id,CC_id);
-
-  PHY_VARS_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
-
-  if (ue)
-    return ((dB_fixed_times10(ue->measurements.rsrp[eNB_index]))/10.0-
-	    get_rx_total_gain_dB(Mod_id,0) -
-	    10*log10(ue->frame_parms.N_RB_DL*12));
-  return -140.0;
-}
-
-uint32_t get_RSRQ(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index)
-{
-
-  PHY_VARS_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
-
-  if (ue)
-    return ue->measurements.rsrq[eNB_index];
-
-  return 0xFFFFFFFF;
-}
-
-int8_t set_RSRP_filtered(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index,float rsrp)
-{
-
-  PHY_VARS_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
-
-  if (ue) {
-    ue->measurements.rsrp_filtered[eNB_index]=rsrp;
-    return 0;
-  }
-
-  LOG_W(PHY,"[UE%d] could not set the rsrp\n",Mod_id);
-  return -1;
-}
-
-int8_t set_RSRQ_filtered(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index,float rsrq)
-{
-
-  PHY_VARS_UE *ue = PHY_vars_UE_g[Mod_id][CC_id];
-
-  if (ue) {
-    ue->measurements.rsrq_filtered[eNB_index]=rsrq;
-    return 0;
-  }
-
-  LOG_W(PHY,"[UE%d] could not set the rsrq\n",Mod_id);
-  return -1;
-
-}
-#endif
-
-#if 0
-void ue_rrc_measurements(PHY_VARS_UE *ue,
-    uint8_t slot,
-    uint8_t abstraction_flag)
-{
-
-  uint8_t subframe = slot>>1;
-  int aarx,rb;
-  uint8_t pss_symb;
-  uint8_t sss_symb;
-
-  int32_t **rxdataF;
-  int16_t *rxF,*rxF_pss,*rxF_sss;
-
-  uint16_t Nid_cell = ue->frame_parms.Nid_cell;
-  uint8_t eNB_offset,nu,l,nushift,k;
-  uint16_t off;
-  uint8_t previous_thread_id = ue->current_thread_id[subframe]==0 ? (RX_NB_TH-1):(ue->current_thread_id[subframe]-1);
-
-   //uint8_t isPss; // indicate if this is a slot for extracting PSS
-  //uint8_t isSss; // indicate if this is a slot for extracting SSS
-  //int32_t pss_ext[4][72]; // contain the extracted 6*12 REs for mapping the PSS
-  //int32_t sss_ext[4][72]; // contain the extracted 6*12 REs for mapping the SSS
-  //int32_t (*xss_ext)[72]; // point to either pss_ext or sss_ext for common calculation
-  //int16_t *re,*im; // real and imag part of each 32-bit xss_ext[][] value
-
-  //LOG_I(PHY,"UE RRC MEAS Start Subframe %d Frame Type %d slot %d \n",subframe,ue->frame_parms.frame_type,slot);
-  for (eNB_offset = 0; eNB_offset<1+ue->measurements.n_adj_cells; eNB_offset++) {
-
-    if (eNB_offset==0) {
-      ue->measurements.rssi = 0;
-      //ue->measurements.n0_power_tot = 0;
-
-      if (abstraction_flag == 0) {
-        if ( ((ue->frame_parms.frame_type == FDD) && ((subframe == 0) || (subframe == 5))) ||
-             ((ue->frame_parms.frame_type == TDD) && ((subframe == 1) || (subframe == 6)))
-                )
-        {  // FDD PSS/SSS, compute noise in DTX REs
-          if (ue->frame_parms.Ncp == NORMAL) {
-            for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
-          if(ue->frame_parms.frame_type == FDD)
-          {
-	      rxF_sss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[aarx][(5*ue->frame_parms.ofdm_symbol_size)];
-	      rxF_pss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[aarx][(6*ue->frame_parms.ofdm_symbol_size)];
-          }
-          else
-          {
-              rxF_sss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[previous_thread_id].rxdataF[aarx][(13*ue->frame_parms.ofdm_symbol_size)];
-              rxF_pss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[aarx][(2*ue->frame_parms.ofdm_symbol_size)];
-          }
-              //-ve spectrum from SSS
-
-              //+ve spectrum from SSS
-              ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+70]*rxF_sss[2+70])+((int32_t)rxF_sss[2+69]*rxF_sss[2+69]));
-              ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+68]*rxF_sss[2+68])+((int32_t)rxF_sss[2+67]*rxF_sss[2+67]));
-              ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+66]*rxF_sss[2+66])+((int32_t)rxF_sss[2+65]*rxF_sss[2+65]));
-              //              ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+64]*rxF_sss[2+64])+((int32_t)rxF_sss[2+63]*rxF_sss[2+63]));
-              //              printf("sssp32 %d\n",ue->measurements.n0_power[aarx]);
-              //+ve spectrum from PSS
-              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+70]*rxF_pss[2+70])+((int32_t)rxF_pss[2+69]*rxF_pss[2+69]));
-              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+68]*rxF_pss[2+68])+((int32_t)rxF_pss[2+67]*rxF_pss[2+67]));
-              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+66]*rxF_pss[2+66])+((int32_t)rxF_pss[2+65]*rxF_pss[2+65]));
-          //              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+64]*rxF_pss[2+64])+((int32_t)rxF_pss[2+63]*rxF_pss[2+63]));
-          //          printf("pss32 %d\n",ue->measurements.n0_power[aarx]);              //-ve spectrum from PSS
-              if(ue->frame_parms.frame_type == FDD)
-              {
-                  rxF_sss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[aarx][(6*ue->frame_parms.ofdm_symbol_size)];
-                  rxF_pss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[aarx][(7*ue->frame_parms.ofdm_symbol_size)];
-              }
-              else
-              {
-                  rxF_sss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[previous_thread_id].rxdataF[aarx][(14*ue->frame_parms.ofdm_symbol_size)];
-                  rxF_pss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[aarx][(3*ue->frame_parms.ofdm_symbol_size)];
-              }
-          //              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-72]*rxF_pss[-72])+((int32_t)rxF_pss[-71]*rxF_pss[-71]));
-          //          printf("pssm36 %d\n",ue->measurements.n0_power[aarx]);
-              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-70]*rxF_pss[-70])+((int32_t)rxF_pss[-69]*rxF_pss[-69]));
-              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-68]*rxF_pss[-68])+((int32_t)rxF_pss[-67]*rxF_pss[-67]));
-              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-66]*rxF_pss[-66])+((int32_t)rxF_pss[-65]*rxF_pss[-65]));
-
-              ue->measurements.n0_power[aarx] = (((int32_t)rxF_sss[-70]*rxF_sss[-70])+((int32_t)rxF_sss[-69]*rxF_sss[-69]));
-              ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[-68]*rxF_sss[-68])+((int32_t)rxF_sss[-67]*rxF_sss[-67]));
-              ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[-66]*rxF_sss[-66])+((int32_t)rxF_sss[-65]*rxF_sss[-65]));
-
-          //              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-64]*rxF_pss[-64])+((int32_t)rxF_pss[-63]*rxF_pss[-63]));
-          //          printf("pssm32 %d\n",ue->measurements.n0_power[aarx]);
-              ue->measurements.n0_power_dB[aarx] = (unsigned short) dB_fixed(ue->measurements.n0_power[aarx]/12);
-              ue->measurements.n0_power_tot /*+=*/ = ue->measurements.n0_power[aarx];
-        }
-
-            //LOG_I(PHY,"Subframe %d RRC UE MEAS Noise Level %d \n", subframe, ue->measurements.n0_power_tot);
-
-        ue->measurements.n0_power_tot_dB = (unsigned short) dB_fixed(ue->measurements.n0_power_tot/(12*aarx));
-        ue->measurements.n0_power_tot_dBm = ue->measurements.n0_power_tot_dB - ue->rx_total_gain_dB - dB_fixed(ue->frame_parms.ofdm_symbol_size);
-        } else {
-            LOG_E(PHY, "Not yet implemented: noise power calculation when prefix length == EXTENDED\n");
-        }
-        }
-        else if ((ue->frame_parms.frame_type == TDD) &&
-                 ((subframe == 1) || (subframe == 6))) {  // TDD PSS/SSS, compute noise in DTX REs // 2016-09-29 wilson fix incorrect noise power calculation
-
-
-          pss_symb = 2;
-          sss_symb = ue->frame_parms.symbols_per_tti-1;
-          if (ue->frame_parms.Ncp==NORMAL) {
-            for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
-
-                rxdataF  =  ue->common_vars.common_vars_rx_data_per_thread[(ue->current_thread_id[subframe])].rxdataF;
-                rxF_pss  = (int16_t *) &rxdataF[aarx][((pss_symb*(ue->frame_parms.ofdm_symbol_size)))];
-
-                rxdataF  =  ue->common_vars.common_vars_rx_data_per_thread[previous_thread_id].rxdataF;
-                rxF_sss  = (int16_t *) &rxdataF[aarx][((sss_symb*(ue->frame_parms.ofdm_symbol_size)))];
-
-                //-ve spectrum from SSS
-            //          printf("slot %d: SSS DTX: %d,%d, non-DTX %d,%d\n",slot,rxF_pss[-72],rxF_pss[-71],rxF_pss[-36],rxF_pss[-35]);
-
-            //              ue->measurements.n0_power[aarx] = (((int32_t)rxF_pss[-72]*rxF_pss[-72])+((int32_t)rxF_pss[-71]*rxF_pss[-71]));
-            //          printf("sssn36 %d\n",ue->measurements.n0_power[aarx]);
-                ue->measurements.n0_power[aarx] = (((int32_t)rxF_pss[-70]*rxF_pss[-70])+((int32_t)rxF_pss[-69]*rxF_pss[-69]));
-                ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-68]*rxF_pss[-68])+((int32_t)rxF_pss[-67]*rxF_pss[-67]));
-                ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-66]*rxF_pss[-66])+((int32_t)rxF_pss[-65]*rxF_pss[-65]));
-            //              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-64]*rxF_pss[-64])+((int32_t)rxF_pss[-63]*rxF_pss[-63]));
-            //          printf("sssm32 %d\n",ue->measurements.n0_power[aarx]);
-                //+ve spectrum from SSS
-            ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+70]*rxF_sss[2+70])+((int32_t)rxF_sss[2+69]*rxF_sss[2+69]));
-                ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+68]*rxF_sss[2+68])+((int32_t)rxF_sss[2+67]*rxF_sss[2+67]));
-                ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+66]*rxF_sss[2+66])+((int32_t)rxF_sss[2+65]*rxF_sss[2+65]));
-            //          ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+64]*rxF_sss[2+64])+((int32_t)rxF_sss[2+63]*rxF_sss[2+63]));
-            //          printf("sssp32 %d\n",ue->measurements.n0_power[aarx]);
-                //+ve spectrum from PSS
-                ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+70]*rxF_pss[2+70])+((int32_t)rxF_pss[2+69]*rxF_pss[2+69]));
-                ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+68]*rxF_pss[2+68])+((int32_t)rxF_pss[2+67]*rxF_pss[2+67]));
-                ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+66]*rxF_pss[2+66])+((int32_t)rxF_pss[2+65]*rxF_pss[2+65]));
-            //              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+64]*rxF_pss[2+64])+((int32_t)rxF_pss[2+63]*rxF_pss[2+63]));
-            //          printf("pss32 %d\n",ue->measurements.n0_power[aarx]);              //-ve spectrum from PSS
-                rxF_pss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[aarx][(7*ue->frame_parms.ofdm_symbol_size)];
-            //              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-72]*rxF_pss[-72])+((int32_t)rxF_pss[-71]*rxF_pss[-71]));
-            //          printf("pssm36 %d\n",ue->measurements.n0_power[aarx]);
-                ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-70]*rxF_pss[-70])+((int32_t)rxF_pss[-69]*rxF_pss[-69]));
-                ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-68]*rxF_pss[-68])+((int32_t)rxF_pss[-67]*rxF_pss[-67]));
-                ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-66]*rxF_pss[-66])+((int32_t)rxF_pss[-65]*rxF_pss[-65]));
-            //              ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-64]*rxF_pss[-64])+((int32_t)rxF_pss[-63]*rxF_pss[-63]));
-            //          printf("pssm32 %d\n",ue->measurements.n0_power[aarx]);
-                ue->measurements.n0_power_dB[aarx] = (unsigned short) dB_fixed(ue->measurements.n0_power[aarx]/12);
-                ue->measurements.n0_power_tot /*+=*/ = ue->measurements.n0_power[aarx];
-        }
-
-        ue->measurements.n0_power_tot_dB = (unsigned short) dB_fixed(ue->measurements.n0_power_tot/(12*aarx));
-        ue->measurements.n0_power_tot_dBm = ue->measurements.n0_power_tot_dB - ue->rx_total_gain_dB - dB_fixed(ue->frame_parms.ofdm_symbol_size);
-
-        //LOG_I(PHY,"Subframe %d RRC UE MEAS Noise Level %d \n", subframe, ue->measurements.n0_power_tot);
-
-          }
-        }
-      }
-    }
-    // recompute nushift with eNB_offset corresponding to adjacent eNB on which to perform channel estimation
-    //    printf("[PHY][UE %d] Frame %d slot %d Doing ue_rrc_measurements rsrp/rssi (Nid_cell %d, Nid2 %d, nushift %d, eNB_offset %d)\n",ue->Mod_id,ue->frame,slot,Nid_cell,Nid2,nushift,eNB_offset);
-    if (eNB_offset > 0)
-      Nid_cell = ue->measurements.adj_cell_id[eNB_offset-1];
-
-
-    nushift =  Nid_cell%6;
-
-
-
-    ue->measurements.rsrp[eNB_offset] = 0;
-
-
-    if (abstraction_flag == 0) {
-
-      // compute RSRP using symbols 0 and 4-frame_parms->Ncp
-
-      for (l=0,nu=0; l<=(4-ue->frame_parms.Ncp); l+=(4-ue->frame_parms.Ncp),nu=3) {
-        k = (nu + nushift)%6;
-	//#ifdef DEBUG_MEAS_RRC
-        LOG_D(PHY,"[UE %d] Frame %d subframe %d Doing ue_rrc_measurements rsrp/rssi (Nid_cell %d, nushift %d, eNB_offset %d, k %d, l %d)\n",ue->Mod_id,ue->proc.proc_rxtx[subframe&1].frame_rx,subframe,Nid_cell,nushift,
-              eNB_offset,k,l);
-	//#endif
-
-        for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
-          rxF = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[aarx][(l*ue->frame_parms.ofdm_symbol_size)];
-          off  = (ue->frame_parms.first_carrier_offset+k)<<1;
-
-          if (l==(4-ue->frame_parms.Ncp)) {
-            for (rb=0; rb<ue->frame_parms.N_RB_DL; rb++) {
-
-              //    printf("rb %d, off %d, off2 %d\n",rb,off,off2);
-
-              ue->measurements.rsrp[eNB_offset] += (((int32_t)(rxF[off])*rxF[off])+((int32_t)(rxF[off+1])*rxF[off+1]));
-              //        printf("rb %d, off %d : %d\n",rb,off,((((int32_t)rxF[off])*rxF[off])+((int32_t)(rxF[off+1])*rxF[off+1])));
-              //              if ((ue->frame_rx&0x3ff) == 0)
-              //                printf("rb %d, off %d : %d\n",rb,off,((rxF[off]*rxF[off])+(rxF[off+1]*rxF[off+1])));
-
-
-              off+=12;
-
-              if (off>=(ue->frame_parms.ofdm_symbol_size<<1))
-                off = (1+k)<<1;
-
-              ue->measurements.rsrp[eNB_offset] += (((int32_t)(rxF[off])*rxF[off])+((int32_t)(rxF[off+1])*rxF[off+1]));
-              //    printf("rb %d, off %d : %d\n",rb,off,(((int32_t)(rxF[off])*rxF[off])+((int32_t)(rxF[off+1])*rxF[off+1])));
-              /*
-                if ((ue->frame_rx&0x3ff) == 0)
-                printf("rb %d, off %d : %d\n",rb,off,((rxF[off]*rxF[off])+(rxF[off+1]*rxF[off+1])));
-              */
-              off+=12;
-
-              if (off>=(ue->frame_parms.ofdm_symbol_size<<1))
-                off = (1+k)<<1;
-
-            }
-
-            /*
-            if ((eNB_offset==0)&&(l==0)) {
-            for (i=0;i<6;i++,off2+=4)
-            ue->measurements.rssi += ((rxF[off2]*rxF[off2])+(rxF[off2+1]*rxF[off2+1]));
-            if (off2==(ue->frame_parms.ofdm_symbol_size<<2))
-            off2=4;
-            for (i=0;i<6;i++,off2+=4)
-            ue->measurements.rssi += ((rxF[off2]*rxF[off2])+(rxF[off2+1]*rxF[off2+1]));
-            }
-            */
-            //    printf("slot %d, rb %d => rsrp %d, rssi %d\n",slot,rb,ue->measurements.rsrp[eNB_offset],ue->measurements.rssi);
-          }
-        }
-      }
-
-      // 2 RE per PRB
-      //      ue->measurements.rsrp[eNB_offset]/=(24*ue->frame_parms.N_RB_DL);
-      ue->measurements.rsrp[eNB_offset]/=(2*ue->frame_parms.N_RB_DL*ue->frame_parms.ofdm_symbol_size);
-      //      LOG_I(PHY,"eNB: %d, RSRP: %d \n",eNB_offset,ue->measurements.rsrp[eNB_offset]);
-      if (eNB_offset == 0) {
-        //  ue->measurements.rssi/=(24*ue->frame_parms.N_RB_DL);
-        //  ue->measurements.rssi*=rx_power_correction;
-        //  ue->measurements.rssi=ue->measurements.rsrp[0]*24/2;
-        ue->measurements.rssi=ue->measurements.rsrp[0]*(12*ue->frame_parms.N_RB_DL);
-      }
-
-      if (ue->measurements.rssi>0)
-        ue->measurements.rsrq[eNB_offset] = 100*ue->measurements.rsrp[eNB_offset]*ue->frame_parms.N_RB_DL/ue->measurements.rssi;
-      else
-        ue->measurements.rsrq[eNB_offset] = -12000;
-
-      //((200*ue->measurements.rsrq[eNB_offset]) + ((1024-200)*100*ue->measurements.rsrp[eNB_offset]*ue->frame_parms.N_RB_DL/ue->measurements.rssi))>>10;
-    } else { // Do abstraction of RSRP and RSRQ
-      ue->measurements.rssi = ue->measurements.rx_power_avg[0];
-      // dummay value for the moment
-      ue->measurements.rsrp[eNB_offset] = -93 ;
-      ue->measurements.rsrq[eNB_offset] = 3;
-
-    }
-
-    //#ifdef DEBUG_MEAS_RRC
-
-    //    if (slot == 0) {
-
-      if (eNB_offset == 0)
-	
-        LOG_D(PHY,"[UE %d] Frame %d, subframe %d RRC Measurements => rssi %3.1f dBm (digital: %3.1f dB, gain %d), N0 %d dBm\n",ue->Mod_id,
-              ue->proc.proc_rxtx[subframe&1].frame_rx,subframe,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);
-
-      LOG_D(PHY,"[UE %d] Frame %d, subframe %d RRC Measurements (idx %d, Cell id %d) => rsrp: %3.1f dBm/RE (%d), rsrq: %3.1f dB\n",
-            ue->Mod_id,
-            ue->proc.proc_rxtx[subframe&1].frame_rx,subframe,eNB_offset,
-            (eNB_offset>0) ? ue->measurements.adj_cell_id[eNB_offset-1] : ue->frame_parms.Nid_cell,
-            10*log10(ue->measurements.rsrp[eNB_offset])-ue->rx_total_gain_dB,
-            ue->measurements.rsrp[eNB_offset],
-            (10*log10(ue->measurements.rsrq[eNB_offset])));
-      //LOG_D(PHY,"RSRP_total_dB: %3.2f \n",(dB_fixed_times10(ue->measurements.rsrp[eNB_offset])/10.0)-ue->rx_total_gain_dB-dB_fixed(ue->frame_parms.N_RB_DL*12));
-
-      //LOG_D(PHY,"RSRP_dB: %3.2f \n",(dB_fixed_times10(ue->measurements.rsrp[eNB_offset])/10.0));
-      //LOG_D(PHY,"gain_loss_dB: %d \n",ue->rx_total_gain_dB);
-      //LOG_D(PHY,"gain_fixed_dB: %d \n",dB_fixed(ue->frame_parms.N_RB_DL*12));
-
-      //    }
-
-      //#endif
-  }
-
-}
-#endif
-
-#if 0
-void conjch0_mult_ch1(int *ch0,
-                      int *ch1,
-                      int32_t *ch0conj_ch1,
-                      unsigned short nb_rb,
-                      unsigned char output_shift0)
-{
-  //This function is used to compute multiplications in Hhermitian * H matrix
-  unsigned short rb;
-  __m128i *dl_ch0_128,*dl_ch1_128, *ch0conj_ch1_128, mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3;
-
-  dl_ch0_128 = (__m128i *)ch0;
-  dl_ch1_128 = (__m128i *)ch1;
-
-  ch0conj_ch1_128 = (__m128i *)ch0conj_ch1;
-
-  for (rb=0; rb<3*nb_rb; rb++) {
-
-    mmtmpD0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch1_128[0]);
-    mmtmpD1 = _mm_shufflelo_epi16(dl_ch0_128[0],_MM_SHUFFLE(2,3,0,1));
-    mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
-    mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]);
-    mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch1_128[0]);
-    mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift0);
-    mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift0);
-    mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
-    mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
-
-    ch0conj_ch1_128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
-
-#ifdef DEBUG_RANK_EST
-    printf("\n Computing conjugates \n");
-    print_shorts("ch0:",(int16_t*)&dl_ch0_128[0]);
-    print_shorts("ch1:",(int16_t*)&dl_ch1_128[0]);
-    print_shorts("pack:",(int16_t*)&ch0conj_ch1_128[0]);
-#endif
-
-    dl_ch0_128+=1;
-    dl_ch1_128+=1;
-    ch0conj_ch1_128+=1;
-  }
-  _mm_empty();
-  _m_empty();
-}
-
-void construct_HhH_elements(int *ch0conj_ch0, //00_00
-                            int *ch1conj_ch1,//01_01
-                            int *ch2conj_ch2,//11_11
-                            int *ch3conj_ch3,//10_10
-                            int *ch0conj_ch1,//00_01
-                            int *ch1conj_ch0,//01_00
-                            int *ch2conj_ch3,//10_11
-                            int *ch3conj_ch2,//11_10
-                            int32_t *after_mf_00,
-                            int32_t *after_mf_01,
-                            int32_t *after_mf_10,
-                            int32_t *after_mf_11,
-                            unsigned short nb_rb)
-{
-  unsigned short rb;
-  __m128i *ch0conj_ch0_128, *ch1conj_ch1_128, *ch2conj_ch2_128, *ch3conj_ch3_128;
-  __m128i *ch0conj_ch1_128, *ch1conj_ch0_128, *ch2conj_ch3_128, *ch3conj_ch2_128;
-  __m128i *after_mf_00_128, *after_mf_01_128, *after_mf_10_128, *after_mf_11_128;
-
-  ch0conj_ch0_128 = (__m128i *)ch0conj_ch0;
-  ch1conj_ch1_128 = (__m128i *)ch1conj_ch1;
-  ch2conj_ch2_128 = (__m128i *)ch2conj_ch2;
-  ch3conj_ch3_128 = (__m128i *)ch3conj_ch3;
-  ch0conj_ch1_128 = (__m128i *)ch0conj_ch1;
-  ch1conj_ch0_128 = (__m128i *)ch1conj_ch0;
-  ch2conj_ch3_128 = (__m128i *)ch2conj_ch3;
-  ch3conj_ch2_128 = (__m128i *)ch3conj_ch2;
-  after_mf_00_128 = (__m128i *)after_mf_00;
-  after_mf_01_128 = (__m128i *)after_mf_01;
-  after_mf_10_128 = (__m128i *)after_mf_10;
-  after_mf_11_128 = (__m128i *)after_mf_11;
-
-  for (rb=0; rb<3*nb_rb; rb++) {
-
-    after_mf_00_128[0] =_mm_adds_epi16(ch0conj_ch0_128[0],ch3conj_ch3_128[0]);// _mm_adds_epi32(ch0conj_ch0_128[0], ch3conj_ch3_128[0]); //00_00 + 10_10
-    after_mf_11_128[0] =_mm_adds_epi16(ch1conj_ch1_128[0], ch2conj_ch2_128[0]); //01_01 + 11_11
-    after_mf_01_128[0] =_mm_adds_epi16(ch0conj_ch1_128[0], ch2conj_ch3_128[0]);//00_01 + 10_11
-    after_mf_10_128[0] =_mm_adds_epi16(ch1conj_ch0_128[0], ch3conj_ch2_128[0]);//01_00 + 11_10
-
-#ifdef DEBUG_RANK_EST
-    printf(" \n construct_HhH_elements \n");
-    print_shorts("ch0conj_ch0_128:",(int16_t*)&ch0conj_ch0_128[0]);
-    print_shorts("ch1conj_ch1_128:",(int16_t*)&ch1conj_ch1_128[0]);
-    print_shorts("ch2conj_ch2_128:",(int16_t*)&ch2conj_ch2_128[0]);
-    print_shorts("ch3conj_ch3_128:",(int16_t*)&ch3conj_ch3_128[0]);
-    print_shorts("ch0conj_ch1_128:",(int16_t*)&ch0conj_ch1_128[0]);
-    print_shorts("ch1conj_ch0_128:",(int16_t*)&ch1conj_ch0_128[0]);
-    print_shorts("ch2conj_ch3_128:",(int16_t*)&ch2conj_ch3_128[0]);
-    print_shorts("ch3conj_ch2_128:",(int16_t*)&ch3conj_ch2_128[0]);
-    print_shorts("after_mf_00_128:",(int16_t*)&after_mf_00_128[0]);
-    print_shorts("after_mf_01_128:",(int16_t*)&after_mf_01_128[0]);
-    print_shorts("after_mf_10_128:",(int16_t*)&after_mf_10_128[0]);
-    print_shorts("after_mf_11_128:",(int16_t*)&after_mf_11_128[0]);
-#endif
-
-    ch0conj_ch0_128+=1;
-    ch1conj_ch1_128+=1;
-    ch2conj_ch2_128+=1;
-    ch3conj_ch3_128+=1;
-    ch0conj_ch1_128+=1;
-    ch1conj_ch0_128+=1;
-    ch2conj_ch3_128+=1;
-    ch3conj_ch2_128+=1;
-
-    after_mf_00_128+=1;
-    after_mf_01_128+=1;
-    after_mf_10_128+=1;
-    after_mf_11_128+=1;
-  }
-  _mm_empty();
-  _m_empty();
-}
-
-
-void squared_matrix_element(int32_t *Hh_h_00,
-                            int32_t *Hh_h_00_sq,
-                            unsigned short nb_rb)
-{
-   unsigned short rb;
-  __m128i *Hh_h_00_128,*Hh_h_00_sq_128;
 
-  Hh_h_00_128 = (__m128i *)Hh_h_00;
-  Hh_h_00_sq_128 = (__m128i *)Hh_h_00_sq;
-
-  for (rb=0; rb<3*nb_rb; rb++) {
-
-    Hh_h_00_sq_128[0] = _mm_madd_epi16(Hh_h_00_128[0],Hh_h_00_128[0]);
-
-#ifdef DEBUG_RANK_EST
-    printf("\n Computing squared_matrix_element \n");
-    print_shorts("Hh_h_00_128:",(int16_t*)&Hh_h_00_128[0]);
-    print_ints("Hh_h_00_sq_128:",(int32_t*)&Hh_h_00_sq_128[0]);
-#endif
-
-    Hh_h_00_sq_128+=1;
-    Hh_h_00_128+=1;
-  }
-  _mm_empty();
-  _m_empty();
-}
-
-
-
-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,
-             unsigned short nb_rb)
-
-{
-  unsigned short rb;
-  __m128i *after_mf_00_128,*after_mf_01_128, *after_mf_10_128, *after_mf_11_128, ad_re_128, bc_re_128;
-  __m128i *det_fin_128, det_128;
-
-  after_mf_00_128 = (__m128i *)after_mf_00;
-  after_mf_01_128 = (__m128i *)after_mf_01;
-  after_mf_10_128 = (__m128i *)after_mf_10;
-  after_mf_11_128 = (__m128i *)after_mf_11;
-
-  det_fin_128 = (__m128i *)det_fin;
-
-  for (rb=0; rb<3*nb_rb; rb++) {
-
-    ad_re_128 = _mm_madd_epi16(after_mf_00_128[0],after_mf_11_128[0]);
-    bc_re_128 = _mm_madd_epi16(after_mf_01_128[0],after_mf_01_128[0]);
-    det_128 = _mm_sub_epi32(ad_re_128, bc_re_128);
-    det_fin_128[0] = _mm_abs_epi32(det_128);
-
-#ifdef DEBUG_RANK_EST
-    printf("\n Computing denominator \n");
-    print_shorts("after_mf_00_128:",(int16_t*)&after_mf_00_128[0]);
-    print_shorts("after_mf_01_128:",(int16_t*)&after_mf_01_128[0]);
-    print_shorts("after_mf_10_128:",(int16_t*)&after_mf_10_128[0]);
-    print_shorts("after_mf_11_128:",(int16_t*)&after_mf_11_128[0]);
-    print_ints("ad_re_128:",(int32_t*)&ad_re_128);
-    print_ints("bc_re_128:",(int32_t*)&bc_re_128);
-    print_ints("det_fin_128:",(int32_t*)&det_fin_128[0]);
-#endif
-
-    det_fin_128+=1;
-    after_mf_00_128+=1;
-    after_mf_01_128+=1;
-    after_mf_10_128+=1;
-    after_mf_11_128+=1;
-  }
-  _mm_empty();
-  _m_empty();
-}
-
-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)
-
-{
-  unsigned short rb;
-  __m128i *h_h_00_sq_128, *h_h_01_sq_128, *h_h_10_sq_128, *h_h_11_sq_128;
-  __m128i *num_fin_128, sq_a_plus_sq_d_128, sq_b_plus_sq_c_128;
-
-  h_h_00_sq_128 = (__m128i *)Hh_h_00_sq;
-  h_h_01_sq_128 = (__m128i *)Hh_h_01_sq;
-  h_h_10_sq_128 = (__m128i *)Hh_h_10_sq;
-  h_h_11_sq_128 = (__m128i *)Hh_h_11_sq;
-
-  num_fin_128 = (__m128i *)num_fin;
-
-  for (rb=0; rb<3*nb_rb; rb++) {
-
-    sq_a_plus_sq_d_128 = _mm_add_epi32(h_h_00_sq_128[0],h_h_11_sq_128[0]);
-    sq_b_plus_sq_c_128 = _mm_add_epi32(h_h_01_sq_128[0],h_h_10_sq_128[0]);
-    num_fin_128[0] = _mm_add_epi32(sq_a_plus_sq_d_128, sq_b_plus_sq_c_128);
-
-#ifdef DEBUG_RANK_EST
-    printf("\n Computing numerator \n");
-    print_ints("h_h_00_sq_128:",(int32_t*)&h_h_00_sq_128[0]);
-    print_ints("h_h_01_sq_128:",(int32_t*)&h_h_01_sq_128[0]);
-    print_ints("h_h_10_sq_128:",(int32_t*)&h_h_10_sq_128[0]);
-    print_ints("h_h_11_sq_128:",(int32_t*)&h_h_11_sq_128[0]);
-    print_shorts("sq_a_plus_sq_d_128:",(int16_t*)&sq_a_plus_sq_d_128);
-    print_shorts("sq_b_plus_sq_c_128:",(int16_t*)&sq_b_plus_sq_c_128);
-    print_shorts("num_fin_128:",(int16_t*)&num_fin_128[0]);
-#endif
-
-    num_fin_128+=1;
-    h_h_00_sq_128+=1;
-    h_h_01_sq_128+=1;
-    h_h_10_sq_128+=1;
-    h_h_11_sq_128+=1;
-  }
-  _mm_empty();
-  _m_empty();
-}
-
-#endif
 
 void nr_ue_measurements(PHY_VARS_NR_UE *ue,
                          unsigned int subframe_offset,
@@ -735,7 +112,7 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue,
 
   for (eNB_id=0; eNB_id<ue->n_connected_eNB; eNB_id++) {
     for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
-      for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) {
+      for (aatx=0; aatx<frame_parms->nb_antenna_ports_gNB; aatx++) {
         ue->measurements.rx_spatial_power[eNB_id][aatx][aarx] =
           (signal_energy_nodc(&ue->pdsch_vars[ue->current_thread_id[subframe]][0]->dl_ch_estimates[eNB_id][ch_offset],
                               (50*12)));
@@ -816,4 +193,4 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue,
   _mm_empty();
   _m_empty();
 #endif
-}
+}
\ No newline at end of file
diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
index 69077f02768..ef22b61260b 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c
@@ -39,13 +39,12 @@
 #include "PHY/phy_extern_nr_ue.h"
 #include "PHY/CODING/coding_extern.h"
 #include "PHY/sse_intrin.h"
+#include "PHY/NR_TRANSPORT/nr_dci.h"
 
 #include "assertions.h"
 #include "T.h"
 
-//#define DEBUG_DCI_ENCODING 1
 //#define DEBUG_DCI_DECODING 1
-//#define DEBUG_PHY
 
 //#define NR_LTE_PDCCH_DCI_SWITCH
 #define NR_PDCCH_DCI_RUN              // activates new nr functions
@@ -61,7 +60,6 @@
 #endif
 #define NR_NBR_CORESET_ACT_BWP 3      // The number of CoreSets per BWP is limited to 3 (including initial CORESET: ControlResourceId 0)
 #define NR_NBR_SEARCHSPACE_ACT_BWP 10 // The number of SearSpaces per BWP is limited to 10 (including initial SEARCHSPACE: SearchSpaceId 0)
-#define PDCCH_TEST_POLAR_TEMP_FIX
 
 
 #ifdef LOG_I
@@ -152,7 +150,7 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr,
 
     for (int i=0; i<9; i++) {
       z[index_z + i] = llr[index_llr + i];
-      LOG_DDD("[reg=%d,bundle_j=%d] z[%d]=(%d,%d) <-> \t[f_reg=%d,fbundle_j=%d] llr[%d]=(%d,%d) \n",
+      LOG_D(PHY,"[reg=%d,bundle_j=%d] z[%d]=(%d,%d) <-> \t[f_reg=%d,fbundle_j=%d] llr[%d]=(%d,%d) \n",
              reg,bundle_j,(index_z + i),*(int16_t *) &z[index_z + i],*(1 + (int16_t *) &z[index_z + i]),
              f_reg,f_bundle_j,(index_llr + i),*(int16_t *) &llr[index_llr + i], *(1 + (int16_t *) &llr[index_llr + i]));
     }
@@ -305,9 +303,8 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF,
                                  int32_t **rxdataF_ext,
                                  int32_t **dl_ch_estimates_ext,
                                  uint8_t symbol,
-                                 uint32_t high_speed_flag,
                                  NR_DL_FRAME_PARMS *frame_parms,
-                                 uint64_t coreset_freq_dom,
+                                 uint8_t *coreset_freq_dom,
                                  uint32_t coreset_nbr_rb,
                                  uint32_t n_BWP_start) {
   /*
@@ -328,27 +325,18 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF,
   // after removing the 3 DMRS RE, the RB contains 9 RE with PDCCH
 #define NBR_RE_PER_RB_WITHOUT_DMRS         9
   uint16_t c_rb, nb_rb = 0;
-  // this variable will be incremented by 1 each time a bit set to '0' is found in coreset_freq_dom bitmap
-  uint16_t offset_discontiguous=0;
   //uint8_t rb_count_bit;
-  uint8_t i, j, aarx, bitcnt_coreset_freq_dom=0;
+  uint8_t i, j, aarx;
   int32_t *dl_ch0, *dl_ch0_ext, *rxF, *rxF_ext;
 
-  c_rb = n_BWP_start; // c_rb is the common resource block: RB within the BWP
 #ifdef DEBUG_DCI_DECODING
   uint8_t symbol_mod = (symbol >= (7 - frame_parms->Ncp)) ? symbol - (7 - frame_parms->Ncp) : symbol;
   LOG_I(PHY, "extract_rbs_single: symbol_mod %d\n",symbol_mod);
 #endif
 
   for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) {
-    if (high_speed_flag == 1) {
-      dl_ch0 = &dl_ch_estimates[aarx][(symbol * (frame_parms->ofdm_symbol_size))];
-      LOG_DDD("dl_ch0 = &dl_ch_estimates[aarx = (%d)][ (symbol * (frame_parms->ofdm_symbol_size (%d))) = (%d)]\n",
-             aarx,frame_parms->ofdm_symbol_size,(symbol * (frame_parms->ofdm_symbol_size)));
-    } else {
-      dl_ch0 = &dl_ch_estimates[aarx][0];
-      LOG_DDD("dl_ch0 = &dl_ch_estimates[aarx = (%d)][0]\n",aarx);
-    }
+    dl_ch0 = &dl_ch_estimates[aarx][0];
+    LOG_DDD("dl_ch0 = &dl_ch_estimates[aarx = (%d)][0]\n",aarx);
 
     dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITH_DMRS)];
     LOG_DDD("dl_ch0_ext = &dl_ch_estimates_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 9) = (%d)]\n",
@@ -356,10 +344,7 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF,
     rxF_ext = &rxdataF_ext[aarx][symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITH_DMRS)];
     LOG_DDD("rxF_ext = &rxdataF_ext[aarx = (%d)][symbol * (frame_parms->N_RB_DL * 9) = (%d)]\n",
            aarx,symbol * (coreset_nbr_rb * NBR_RE_PER_RB_WITH_DMRS));
-    LOG_DDD("(for symbol=%d, aarx=%d), symbol_mod=%d, nushiftmod3=%d \n",
-    symbol,aarx,
-    (symbol >= (7 - frame_parms->Ncp)) ? symbol - (7 - frame_parms->Ncp) : symbol,
-    frame_parms->nushift % 3);
+
     /*
      * The following for loop handles treatment of PDCCH contained in table rxdataF (in frequency domain)
      * In NR the PDCCH IQ symbols are contained within RBs in the CORESET defined by higher layers which is located within the BWP
@@ -377,25 +362,15 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF,
      * then the IQ symbol is going to be found at the position 0+c_rb-N_RB_DL/2 in rxdataF and
      * we have to point the pointer at (1+c_rb-N_RB_DL/2) in rxdataF
      */
-    LOG_DDD("n_BWP_start=%u, coreset_nbr_rb=%u\n",n_BWP_start,coreset_nbr_rb);
-
-    for (c_rb = n_BWP_start; c_rb < (n_BWP_start + coreset_nbr_rb + (BIT_TO_NBR_RB_CORESET_FREQ_DOMAIN * offset_discontiguous)); c_rb++) {
-      //c_rb_tmp = 0;
-      if (((c_rb - n_BWP_start) % BIT_TO_NBR_RB_CORESET_FREQ_DOMAIN)==0) {
-        bitcnt_coreset_freq_dom ++;
-
-        while ((((coreset_freq_dom & 0x1FFFFFFFFFFF) >> (CORESET_FREQ_DOMAIN_BITMAP_SIZE - (n_BWP_start/BIT_TO_NBR_RB_CORESET_FREQ_DOMAIN) - bitcnt_coreset_freq_dom)) & 0x1)== 0) { // 46 -> 45 is number of bits in coreset_freq_dom
-          // next 6 RB are not part of the CORESET within the BWP as bit in coreset_freq_dom is set to 0
-          bitcnt_coreset_freq_dom ++;
-          //c_rb_tmp = c_rb_tmp + 6;
-          c_rb = c_rb + BIT_TO_NBR_RB_CORESET_FREQ_DOMAIN;
-          offset_discontiguous ++;
-          LOG_DDD("we entered here as coreset_freq_dom=%lx (bit %d) is 0, coreset_freq_domain is discontiguous\n",coreset_freq_dom,
-                 (46 - bitcnt_coreset_freq_dom));
-        }
-      }
 
-      //c_rb = c_rb + c_rb_tmp;
+    LOG_DDD("n_BWP_start=%d, coreset_nbr_rb=%d\n",n_BWP_start,coreset_nbr_rb);
+    int c_rb_by6;
+    c_rb = n_BWP_start;
+    for (int rb=0;rb<coreset_nbr_rb;rb++,c_rb++) {
+      c_rb_by6 = c_rb/6;
+      // skip zeros in frequency domain bitmap
+      while ((coreset_freq_dom[c_rb_by6>>3] & (1<<(c_rb_by6&7))) == 0) c_rb+=6;
+
       LOG_DDD("c_rb=%d\n",c_rb);
       rxF=NULL;
 
@@ -423,45 +398,30 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF,
       if ((c_rb < (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)) {
         //if RB to be treated is lower than middle system bandwidth then rxdataF pointed at (offset + c_br + symbol * ofdm_symbol_size): odd case
         rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))];
-        LOG_DDD("in odd case c_rb (%d) is lower or equal than half N_RB_DL -> rxF = &rxdataF[aarx = (%d)][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n",
+#ifdef NR_PDCCH_DCI_DEBUG
+        LOG_D(PHY,"in odd case c_rb (%d) is lower or equal than half N_RB_DL -> rxF = &rxdataF[aarx = (%d)][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n",
                c_rb,aarx,(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))));
+#endif
       }
 
       if ((c_rb > (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)) {
         // number of RBs is odd  and   c_rb is higher than half system bandwidth + 1
         // if these conditions are true the pointer has to be situated at the 1st part of the rxdataF just after the first IQ symbols of the RB containing DC
         rxF = &rxdataF[aarx][(12*(c_rb - (frame_parms->N_RB_DL>>1)) - 6 + (symbol * (frame_parms->ofdm_symbol_size)))]; // we point at the 1st part of the rxdataF in symbol
-        LOG_DDD("in odd case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][(12*(c_rb - frame_parms->N_RB_DL) - 5 + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n",
+#ifdef NR_PDCCH_DCI_DEBUG
+        LOG_D(PHY,"in odd case c_rb (%d) is higher than half N_RB_DL (not DC) -> rxF = &rxdataF[aarx = (%d)][(12*(c_rb - frame_parms->N_RB_DL) - 5 + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n",
                c_rb,aarx,(12*(c_rb - (frame_parms->N_RB_DL>>1)) - 6 + (symbol * (frame_parms->ofdm_symbol_size))));
+#endif
       }
 
       if ((c_rb == (frame_parms->N_RB_DL >> 1)) && ((frame_parms->N_RB_DL & 1) != 0)) { // treatment of RB containing the DC
         // if odd number RBs in system bandwidth and first RB to be treated is higher than middle system bandwidth (around DC)
         // we have to treat the RB in two parts: first part from i=0 to 5, the data is at the end of rxdataF (pointing at the end of the table)
         rxF = &rxdataF[aarx][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size)))];
-        LOG_DDD("in odd case c_rb (%d) is half N_RB_DL + 1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n",
+#ifdef NR_PDCCH_DCI_DEBUG
+        LOG_D(PHY,"in odd case c_rb (%d) is half N_RB_DL + 1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))) = (%d)]\n",
                c_rb,aarx,(frame_parms->first_carrier_offset + 12 * c_rb + (symbol * (frame_parms->ofdm_symbol_size))));
-        /*if (symbol_mod > 300) { // this if is going to be removed as DM-RS signals are present in all symbols of PDCCH
-          for (i = 0; i < 6; i++) {
-        dl_ch0_ext[i] = dl_ch0[i];
-        rxF_ext[i] = rxF[i];
-          }
-          rxF = &rxdataF[aarx][(symbol * (frame_parms->ofdm_symbol_size))]; // we point at the 1st part of the rxdataF in symbol
-          #ifdef NR_PDCCH_DCI_DEBUG
-        LOG_DDD("in odd case c_rb (%d) is half N_RB_DL +1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][(symbol * (frame_parms->ofdm_symbol_size)) = (%d)]\n",
-        c_rb,aarx,(symbol * (frame_parms->ofdm_symbol_size)));
-          #endif
-          for (; i < 12; i++) {
-        dl_ch0_ext[i] = dl_ch0[i];
-        rxF_ext[i] = rxF[(1 + i - 6)];
-          }
-          nb_rb++;
-          dl_ch0_ext += 12;
-          rxF_ext += 12;
-          dl_ch0 += 12;
-          rxF += 7;
-          c_rb++;
-          } else {*/
+#endif
         j = 0;
 
         for (i = 0; i < 6; i++) { //treating first part of the RB note that i=5 would correspond to DC. We treat it in NR
@@ -474,9 +434,10 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF,
 
         // then we point at the begining of the symbol part of rxdataF do process second part of RB
         rxF = &rxdataF[aarx][((symbol * (frame_parms->ofdm_symbol_size)))]; // we point at the 1st part of the rxdataF in symbol
-        LOG_DDD("in odd case c_rb (%d) is half N_RB_DL +1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][(symbol * (frame_parms->ofdm_symbol_size)) = (%d)]\n",
+#ifdef NR_PDCCH_DCI_DEBUG
+        LOG_D(PHY,"in odd case c_rb (%d) is half N_RB_DL +1 we treat DC case -> rxF = &rxdataF[aarx = (%d)][(symbol * (frame_parms->ofdm_symbol_size)) = (%d)]\n",
                c_rb,aarx,(symbol * (frame_parms->ofdm_symbol_size)));
-
+#endif
         for (; i < 12; i++) {
           if ((i != 9)) {
             dl_ch0_ext[j] = dl_ch0[i];
@@ -494,33 +455,27 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF,
         //n_BWP_start++; // We have to increment this variable here to be consequent in the for loop afterwards
         //}
       } else { // treatment of any RB that does not contain the DC
-        /*if (symbol_mod > 300) {
-          memcpy(dl_ch0_ext, dl_ch0, 12 * sizeof(int32_t));
-          for (i = 0; i < 12; i++) {
-        rxF_ext[i] = rxF[i];
-          }
-          nb_rb++;
-          dl_ch0_ext += 12;
-          rxF_ext += 12;
-          dl_ch0 += 12;
-          //rxF += 12;
-        } else {*/
         j = 0;
 
         for (i = 0; i < 12; i++) {
           if ((i != 1) && (i != 5) && (i != 9)) {
             rxF_ext[j] = rxF[i];
-            LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d)\n",
+#ifdef NR_PDCCH_DCI_DEBUG
+            LOG_D(PHY,"RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d)\n",
                    c_rb, i, j, *(short *) &rxF_ext[j],*(1 + (short *) &rxF_ext[j]), i,
                    *(short *) &rxF[i], *(1 + (short *) &rxF[i]));
+#endif
             dl_ch0_ext[j] = dl_ch0[i];
+
             //LOG_DDD("ch %d => dl_ch0(%d,%d)\n", i, *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i]));
             //printf("\t-> dl_ch0[%d] => dl_ch0_ext[%d](%d,%d)\n", i,j, *(short *) &dl_ch0[i], *(1 + (short*) &dl_ch0[i]));
             j++;
           } else {
-            LOG_DDD("RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t\t <==> DM-RS PDCCH, this is a pilot symbol\n",
+#ifdef NR_PDCCH_DCI_DEBUG
+            LOG_D(PHY,"RB[c_rb %d] \t RE[re %d] => rxF_ext[%d]=(%d,%d)\t rxF[%d]=(%d,%d) \t\t <==> DM-RS PDCCH, this is a pilot symbol\n",
                    c_rb, i, j, *(short *) &rxF_ext[j], *(1 + (short *) &rxF_ext[j]), i,
                    *(short *) &rxF[i], *(1 + (short *) &rxF[i]));
+#endif
           }
         }
 
@@ -704,203 +659,118 @@ void pdcch_siso(NR_DL_FRAME_PARMS *frame_parms,
 }
 #endif
 
-
-
-
-
 #ifdef NR_PDCCH_DCI_RUN
 int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue,
-                    uint32_t frame,
-                    uint8_t nr_tti_rx,
-                    uint8_t eNB_id,
-                    MIMO_mode_t mimo_mode,
-                    uint32_t high_speed_flag,
-                    uint8_t is_secondary_ue,
-                    int nb_coreset_active,
-                    uint16_t symbol_mon,
-                    NR_SEARCHSPACE_TYPE_t searchSpaceType) {
+		    uint32_t frame,
+		    uint32_t slot) {
+
   NR_UE_COMMON *common_vars      = &ue->common_vars;
   NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
-  NR_UE_PDCCH **pdcch_vars       = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]];
-  NR_UE_PDCCH *pdcch_vars2       = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id];
-  int do_common;
-
-  if (searchSpaceType == common) do_common=1;
-
-  if (searchSpaceType == ue_specific) do_common=0;
+  NR_UE_PDCCH *pdcch_vars        = ue->pdcch_vars[ue->current_thread_id[slot]][0];
+  fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15;
 
   uint8_t log2_maxh, aarx;
   int32_t avgs;
   int32_t avgP[4];
-  // number of RB (1 symbol) or REG (12 RE) in one CORESET: higher-layer parameter CORESET-freq-dom
-  // (bit map 45 bits: each bit indicates 6 RB in CORESET -> 1 bit MSB indicates PRB 0..6 are part of CORESET)
-  uint64_t coreset_freq_dom                                 = pdcch_vars2->coreset[nb_coreset_active].frequencyDomainResources;
-  // number of symbols in CORESET: higher-layer parameter CORESET-time-dur {1,2,3}
-  int coreset_time_dur                                      = pdcch_vars2->coreset[nb_coreset_active].duration;
-  // depends on higher-layer parameter CORESET-shift-index {0,1,...,274}
-  int n_shift                                               = pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.shiftIndex;
-  // higher-layer parameter CORESET-REG-bundle-size (for non-interleaved L = 6 / for interleaved L {2,6})
-  NR_UE_CORESET_REG_bundlesize_t reg_bundle_size_L          = pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.reg_bundlesize;
-  // higher-layer parameter CORESET-interleaver-size {2,3,6}
-  NR_UE_CORESET_interleaversize_t coreset_interleaver_size_R= pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.interleaversize;
-  //NR_UE_CORESET_precoder_granularity_t precoder_granularity = pdcch_vars2->coreset[nb_coreset_active].precoderGranularity;
-  //int tci_statesPDCCH                                       = pdcch_vars2->coreset[nb_coreset_active].tciStatesPDCCH;
-  //int tci_present                                           = pdcch_vars2->coreset[nb_coreset_active].tciPresentInDCI;
-  uint16_t pdcch_DMRS_scrambling_id                         = pdcch_vars2->coreset[nb_coreset_active].pdcchDMRSScramblingID;
-  // The UE can be assigned 4 different BWP but only one active at a time.
-  // For each BWP the number of CORESETs is limited to 3 (including initial CORESET Id=0 -> ControlResourceSetId (0..maxNrofControlReourceSets-1) (0..12-1)
-  //uint32_t n_BWP_start = 0;
-  //uint32_t n_rb_offset = 0;
-  uint32_t n_rb_offset                                      = pdcch_vars2->coreset[nb_coreset_active].rb_offset/*+(int)floor(frame_parms->ssb_start_subcarrier/NR_NB_SC_PER_RB)*/;
-  // start time position for CORESET
-  // parameter symbol_mon is a 14 bits bitmap indicating monitoring symbols within a slot
-  uint8_t start_symbol = 0;
-
-  // at the moment we are considering that the PDCCH is always starting at symbol 0 of current slot
-  // the following code to initialize start_symbol must be activated once we implement PDCCH demapping on symbol not equal to 0 (considering symbol_mon)
-  for (int i=0; i < 14; i++) {
-    if (((symbol_mon >> (i+1))&0x1) != 0) {
-      start_symbol = i;
-      i=14;
-    }
-  }
-
-  LOG_DD("symbol_mon=(%u) and start_symbol=(%u)\n",symbol_mon,start_symbol);
-  LOG_DD("coreset_freq_dom=(%lu) n_rb_offset=(%u) coreset_time_dur=(%d) n_shift=(%d) reg_bundle_size_L=(%d) coreset_interleaver_size_R=(%d) scrambling_ID=(%d) \n",
-         coreset_freq_dom,n_rb_offset,coreset_time_dur,n_shift,reg_bundle_size_L,coreset_interleaver_size_R,pdcch_DMRS_scrambling_id);
-  //
-  // according to 38.213 v15.1.0: a PDCCH monitoring pattern within a slot,
-  // indicating first symbol(s) of the control resource set within a slot
-  // for PDCCH monitoring, by higher layer parameter monitoringSymbolsWithinSlot
-  //
-  // at the moment we do not implement this and start_symbol is always 0
-  // note that the bitmap symbol_mon may indicate several monitoring times within a same slot (symbols 0..13)
-  // this may lead to a modification in ue scheduler
-  // indicates the number of active CORESETs for the current BWP to decode PDCCH: max is 3 (this variable is not useful here, to be removed)
-  //uint8_t  coreset_nbr_act;
-  // indicates the number of REG contained in the PDCCH (number of RBs * number of symbols, in CORESET)
-  uint32_t coreset_nbr_rb = 0;
-  // for (int j=0; j < coreset_nbr_act; j++) {
-  // for each active CORESET (max number of active CORESETs in a BWP is 3),
-  // we calculate the number of RB for each CORESET bitmap
-  LOG_DD("coreset_freq_dom=(%lu)\n",coreset_freq_dom);
-  int i; //for each bit in the coreset_freq_dom bitmap
-
-  for (i = 0; i < 45; i++) {
-    // this loop counts each bit of the bit map coreset_freq_dom, and increments nbr_RB_coreset for each bit set to '1'
-    if (((coreset_freq_dom & 0x1FFFFFFFFFFF) >> i) & 0x1) coreset_nbr_rb++;
-  }
-
-  coreset_nbr_rb = 6 * coreset_nbr_rb; // coreset_nbr_rb has to be multiplied by 6 to indicate the number of PRB or REG(=12 RE) within the CORESET
-  LOG_DD("coreset_freq_dom=(%lu,%lx), coreset_nbr_rb=%u\n", coreset_freq_dom,coreset_freq_dom,coreset_nbr_rb);
-  LOG_DD("coreset_nbr_rb=%u, coreset_nbr_reg=%u, coreset_C=(%u/(%d*%d))=%u\n",
-         coreset_nbr_rb, 
-	 coreset_time_dur * coreset_nbr_rb,
-	 coreset_time_dur * coreset_nbr_rb,
-	 reg_bundle_size_L,coreset_interleaver_size_R,
-	(uint32_t)((coreset_time_dur * coreset_nbr_rb) / (reg_bundle_size_L * coreset_interleaver_size_R)) );
-
-  for (int s = start_symbol; s < (start_symbol + coreset_time_dur); s++) {
-    LOG_DD("we enter nr_pdcch_extract_rbs_single(is_secondary_ue=%d) to remove DM-RS PDCCH\n",
-           is_secondary_ue);
-    LOG_DD("in nr_pdcch_extract_rbs_single(rxdataF -> rxdataF_ext || dl_ch_estimates -> dl_ch_estimates_ext)\n");
-    nr_pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF,
-                                pdcch_vars[eNB_id]->dl_ch_estimates,
-                                pdcch_vars[eNB_id]->rxdataF_ext,
-                                pdcch_vars[eNB_id]->dl_ch_estimates_ext,
-                                s,
-                                high_speed_flag,
-                                frame_parms,
-                                coreset_freq_dom,
-                                coreset_nbr_rb,
-                                n_rb_offset);
-    LOG_DD("we enter nr_pdcch_channel_level(avgP=%d) => compute channel level based on ofdm symbol 0, pdcch_vars[eNB_id]->dl_ch_estimates_ext\n",*avgP);
-    LOG_DD("in nr_pdcch_channel_level(dl_ch_estimates_ext -> dl_ch_estimates_ext)\n");
-    // compute channel level based on ofdm symbol 0
-    nr_pdcch_channel_level(pdcch_vars[eNB_id]->dl_ch_estimates_ext,
-                        frame_parms,
-                        avgP,
-                        coreset_nbr_rb);
-    avgs = 0;
-
-    for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++)
-      avgs = cmax(avgs, avgP[aarx]);
-
-    log2_maxh = (log2_approx(avgs) / 2) + 5;  //+frame_parms->nb_antennas_rx;
+  for (int i=0;i<pdcch_vars->nb_search_space;i++) {
+
+    rel15 = &pdcch_vars->pdcch_config[i];
+    int n_rb,rb_offset;
+    get_coreset_rballoc(rel15->coreset.frequency_domain_resource,&n_rb,&rb_offset);
+    for (int s=rel15->coreset.StartSymbolIndex; s<(rel15->coreset.StartSymbolIndex+rel15->coreset.duration); s++) {
+      LOG_D(PHY,"in nr_pdcch_extract_rbs_single(rxdataF -> rxdataF_ext || dl_ch_estimates -> dl_ch_estimates_ext)\n");
+
+      nr_pdcch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[slot]].rxdataF,
+				  pdcch_vars->dl_ch_estimates,
+				  pdcch_vars->rxdataF_ext,
+				  pdcch_vars->dl_ch_estimates_ext,
+				  s,
+				  frame_parms,
+				  rel15->coreset.frequency_domain_resource,
+				  n_rb,
+				  rel15->BWPStart);
+
+      LOG_D(PHY,"we enter nr_pdcch_channel_level(avgP=%d) => compute channel level based on ofdm symbol 0, pdcch_vars[eNB_id]->dl_ch_estimates_ext\n",*avgP);
+      LOG_D(PHY,"in nr_pdcch_channel_level(dl_ch_estimates_ext -> dl_ch_estimates_ext)\n");
+      // compute channel level based on ofdm symbol 0
+      nr_pdcch_channel_level(pdcch_vars->dl_ch_estimates_ext,
+                             frame_parms,
+                             avgP,
+                             n_rb);
+      avgs = 0;
+
+      for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++)
+        avgs = cmax(avgs, avgP[aarx]);
+
+      log2_maxh = (log2_approx(avgs) / 2) + 5;  //+frame_parms->nb_antennas_rx;
 #ifdef UE_DEBUG_TRACE
-    LOG_D(PHY,"nr_tti_rx %d: pdcch log2_maxh = %d (%d,%d)\n",nr_tti_rx,log2_maxh,avgP[0],avgs);
+      LOG_D(PHY,"slot %d: pdcch log2_maxh = %d (%d,%d)\n",slot,log2_maxh,avgP[0],avgs);
 #endif
 #if T_TRACER
-    T(T_UE_PHY_PDCCH_ENERGY, T_INT(eNB_id), T_INT(0), T_INT(frame%1024), T_INT(nr_tti_rx),
-      T_INT(avgP[0]), T_INT(avgP[1]), T_INT(avgP[2]), T_INT(avgP[3]));
+      T(T_UE_PHY_PDCCH_ENERGY, T_INT(0), T_INT(0), T_INT(frame%1024), T_INT(slot),
+	    T_INT(avgP[0]), T_INT(avgP[1]), T_INT(avgP[2]), T_INT(avgP[3]));
 #endif
-    LOG_DD("we enter nr_pdcch_channel_compensation(log2_maxh=%d)\n",log2_maxh);
-    LOG_DD("in nr_pdcch_channel_compensation(rxdataF_ext x dl_ch_estimates_ext -> rxdataF_comp)\n");
-    // compute LLRs for ofdm symbol 0 only
-    nr_pdcch_channel_compensation(pdcch_vars[eNB_id]->rxdataF_ext,
-                                  pdcch_vars[eNB_id]->dl_ch_estimates_ext,
-                                  pdcch_vars[eNB_id]->rxdataF_comp,
-                                  NULL,
-                                  frame_parms,
-                                  s,
-                                  log2_maxh,
-                                  coreset_nbr_rb); // log2_maxh+I0_shift
-#ifdef DEBUG_PHY
-
-    if (nr_tti_rx==5)
-      write_output("rxF_comp_d.m","rxF_c_d",&pdcch_vars[eNB_id]->rxdataF_comp[0][s*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);
+      LOG_D(PHY,"we enter nr_pdcch_channel_compensation(log2_maxh=%d)\n",log2_maxh);
+      LOG_D(PHY,"in nr_pdcch_channel_compensation(rxdataF_ext x dl_ch_estimates_ext -> rxdataF_comp)\n");
+      // compute LLRs for ofdm symbol 0 only
+      nr_pdcch_channel_compensation(pdcch_vars->rxdataF_ext,
+                                    pdcch_vars->dl_ch_estimates_ext,
+                                    pdcch_vars->rxdataF_comp,
+                                    NULL,
+                                    frame_parms,
+                                    s,
+                                    log2_maxh,
+                                    n_rb); // log2_maxh+I0_shift
+      if (frame_parms->nb_antennas_rx > 1) {
+        LOG_D(PHY,"we enter nr_pdcch_detection_mrc(frame_parms->nb_antennas_rx=%d)\n", frame_parms->nb_antennas_rx);
+        nr_pdcch_detection_mrc(frame_parms, pdcch_vars->rxdataF_comp,s);
+      }
 
+      LOG_D(PHY,"we enter nr_pdcch_llr(for symbol %d), pdcch_vars[eNB_id]->rxdataF_comp ---> pdcch_vars[eNB_id]->llr \n",s);
+      LOG_D(PHY,"in nr_pdcch_llr(rxdataF_comp -> llr)\n");
+      nr_pdcch_llr(frame_parms,
+                   pdcch_vars->rxdataF_comp,
+                   pdcch_vars->llr,
+                   s,
+                   n_rb);
+#if T_TRACER
+    
+      //  T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL),
+      //  T_INT(n_pdcch_symbols),
+      //  T_BUFFER(pdcch_vars[eNB_id]->rxdataF_comp, frame_parms->N_RB_DL*12*n_pdcch_symbols* 4));
+    
+#endif
+#ifdef DEBUG_DCI_DECODING
+      printf("demapping: slot %d, mi %d\n",slot,get_mi(frame_parms,slot));
 #endif
-
-    if (frame_parms->nb_antennas_rx > 1) {
-      LOG_DD("we enter nr_pdcch_detection_mrc(frame_parms->nb_antennas_rx=%d)\n",
-             frame_parms->nb_antennas_rx);
-      nr_pdcch_detection_mrc(frame_parms, pdcch_vars[eNB_id]->rxdataF_comp,s);
     }
 
-    LOG_DD("we enter nr_pdcch_llr(for symbol %d), pdcch_vars[eNB_id]->rxdataF_comp ---> pdcch_vars[eNB_id]->llr \n",s);
-    LOG_DD("in nr_pdcch_llr(rxdataF_comp -> llr)\n");
-    nr_pdcch_llr(frame_parms,
-                 pdcch_vars[eNB_id]->rxdataF_comp,
-                 pdcch_vars[eNB_id]->llr,
-                 s,
-                 coreset_nbr_rb);
-#if T_TRACER
+    LOG_D(PHY,"we enter nr_pdcch_demapping_deinterleaving()\n");
+    nr_pdcch_demapping_deinterleaving((uint32_t *) pdcch_vars->llr,
+                                      (uint32_t *) pdcch_vars->e_rx,
+                                      frame_parms,
+                                      rel15->coreset.duration,
+                                      n_rb,
+                                      rel15->coreset.RegBundleSize,
+                                      rel15->coreset.InterleaverSize,
+                                      rel15->coreset.ShiftIndex);
     /*
-      T(T_UE_PHY_PDCCH_IQ, T_INT(frame_parms->N_RB_DL), T_INT(frame_parms->N_RB_DL),
-      T_INT(n_pdcch_symbols),
-      T_BUFFER(pdcch_vars[eNB_id]->rxdataF_comp, frame_parms->N_RB_DL*12*n_pdcch_symbols* 4));
+    nr_pdcch_unscrambling(rel15->rnti,
+                          frame_parms,
+                          slot,
+                          pdcch_vars->e_rx,
+                          rel15->coreset.duration*n_rb*9*2,
+                          // get_nCCE(n_pdcch_symbols, frame_parms, mi) * 72,
+                          rel15->coreset.pdcch_dmrs_scrambling_id);
     */
-#endif
-#ifdef DEBUG_DCI_DECODING
-    printf("demapping: nr_tti_rx %d, mi %d, tdd_config %d\n",nr_tti_rx,get_mi(frame_parms,nr_tti_rx),frame_parms->tdd_config);
-#endif
-  }
+    LOG_D(PHY,"we end nr_pdcch_unscrambling()\n");
+    LOG_D(PHY,"Ending nr_rx_pdcch() function\n");
 
-  LOG_DD("we enter nr_pdcch_demapping_deinterleaving()\n");
-  nr_pdcch_demapping_deinterleaving((uint32_t *) pdcch_vars[eNB_id]->llr,
-                                    (uint32_t *) pdcch_vars[eNB_id]->e_rx,
-                                    frame_parms,
-                                    coreset_time_dur,
-                                    coreset_nbr_rb,
-                                    reg_bundle_size_L,
-                                    coreset_interleaver_size_R,
-                                    n_shift);
-  nr_pdcch_unscrambling(pdcch_vars[eNB_id]->crnti,
-                        frame_parms,
-                        nr_tti_rx,
-                        pdcch_vars[eNB_id]->e_rx,
-                        coreset_time_dur*coreset_nbr_rb*9*2,
-                        // get_nCCE(n_pdcch_symbols, frame_parms, mi) * 72,
-                        pdcch_DMRS_scrambling_id,
-                        do_common);
-  LOG_DD("we end nr_pdcch_unscrambling()\n");
-  LOG_DD("Ending nr_rx_pdcch() function\n");
+  }
   return (0);
 }
-#endif
-
 
+#endif
 
 void pdcch_scrambling(NR_DL_FRAME_PARMS *frame_parms,
                       uint8_t nr_tti_rx,
@@ -929,64 +799,29 @@ void pdcch_scrambling(NR_DL_FRAME_PARMS *frame_parms,
 
 #ifdef NR_PDCCH_DCI_RUN
 
-void nr_pdcch_unscrambling(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_tti_rx,
-                           int16_t *z, uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common) {
+void nr_pdcch_unscrambling(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t slot,
+                           int16_t *z, int16_t *z2,uint32_t length, uint16_t pdcch_DMRS_scrambling_id) {
   int i;
   uint8_t reset;
   uint32_t x1, x2, s = 0;
   uint16_t n_id; //{0,1,...,65535}
   uint32_t n_rnti;
   reset = 1;
-
   // x1 is set in first call to lte_gold_generic
   //do_common=1;
-  if (do_common) {
-    n_id = frame_parms->Nid_cell;
-    n_rnti = 0;
-  } else {
     n_id = pdcch_DMRS_scrambling_id;
     n_rnti = (uint32_t)crnti;
-  }
 
-  //x2 = ((n_rnti * (1 << 16)) + n_id)%(1 << 31);
-  //uint32_t puissance_2_16 = ((1<<16)*n_rnti)+n_id;
-  //uint32_t puissance_2_31= (1<<30)*2;
-  //uint32_t calc_x2=puissance_2_16%puissance_2_31;
   x2 = (((1<<16)*n_rnti)+n_id); //mod 2^31 is implicit //this is c_init in 38.211 v15.1.0 Section 7.3.2.3
-  //  x2 = (nr_tti_rx << 9) + frame_parms->Nid_cell; //this is c_init in 36.211 Sec 6.8.2
-  //LOG_DDD(" (c_init=%d, n_id=%d, n_rnti=%d, length=%d)\n",x2,n_id,n_rnti,length);
 
   for (i = 0; i < length; i++) {
     if ((i & 0x1f) == 0) {
       s = lte_gold_generic(&x1, &x2, reset);
-      //LOG_DDD("lte_gold[%d]=%x\n",i,s);
       reset = 0;
     }
 
-    /*
-    #ifdef NR_PDCCH_DCI_DEBUG
-    if (i%2 == 0) LOG_DDD(" unscrambling %d : scrambled_z=%d, => ",
-       i,*(char*) &z[(int)floor(i/2)]);
-    if (i%2 == 1) LOG_DDD(" unscrambling %d : scrambled_z=%d, => ",
-       i,*(1 + (char*) &z[(int)floor(i/2)]));
-    #endif
-    if (((s >> (i % 32)) & 1) == 1){
-      if (i%2 == 0) *(char*) &z[(int)floor(i/2)] = -(*(char*) &z[(int)floor(i/2)]);
-      if (i%2 == 1) *(1 + (char*) &z[(int)floor(i/2)]) = -(*(1 + (char*) &z[(int)floor(i/2)]));
-    }
-    //llr[i] = -llr[i];
-    //llr[i] = (-1)*llr[i];
-    #ifdef NR_PDCCH_DCI_DEBUG
-    if (i%2 == 0) printf("unscrambled_z=%d\n",*(char*) &z[(int)floor(i/2)]);
-    if (i%2 == 1) printf("unscrambled_z=%d\n",*(1 + (char*) &z[(int)floor(i/2)]));
-    #endif
-    */
-    LOG_DDD(" unscrambling %d : scrambled_z=%d, => ",
-           i,z[i]);
-
-    if (((s >> (i % 32)) & 1) == 1) z[i] = -z[i];
-
-    LOG_DDD("unscrambled_z=%d\n",z[i]);
+    if (((s >> (i % 32)) & 1) == 1) z2[i] = -z[i];
+    else z2[i]=z[i];
   }
 }
 
@@ -994,6 +829,56 @@ void nr_pdcch_unscrambling(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8
 
 
 #ifdef NR_PDCCH_DCI_RUN
+uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
+				  int frame,
+				  int slot,
+				  fapi_nr_dci_indication_t *dci_ind) {
+
+  NR_UE_PDCCH *pdcch_vars        = ue->pdcch_vars[ue->current_thread_id[slot]][0];
+  fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15;
+  for (int i=0;i<pdcch_vars->nb_search_space;i++) {
+
+    rel15 = &pdcch_vars->pdcch_config[i];
+    int dci_length = rel15->dci_length;
+    int16_t tmp_e[16*108];
+
+    for (int j=0;j<rel15->number_of_candidates;j++) {
+      LOG_D(PHY,"Trying DCI candidate %d, CCE %d (%d), L %d\n",j,rel15->CCE[j],rel15->CCE[j]*9*6*2,rel15->L[j]);
+      int CCEind = rel15->CCE[j];
+      int L = rel15->L[j];
+      uint64_t dci_estimation[2]= {0};
+      const t_nrPolar_params *currentPtrDCI=nr_polar_params(1, dci_length, L,1,&ue->polarList);
+
+      nr_pdcch_unscrambling(rel15->rnti,
+			    &ue->frame_parms,
+			    slot,
+			    &pdcch_vars->e_rx[CCEind*108],
+			    tmp_e,
+			    L*108,
+			    // get_nCCE(n_pdcch_symbols, frame_parms, mi) * 72,
+			    rel15->coreset.pdcch_dmrs_scrambling_id);
+
+      uint16_t crc = polar_decoder_int16(tmp_e,
+                                         dci_estimation,
+                                         1,
+                                         currentPtrDCI);
+      LOG_D(PHY,"Decoded crc %x\n",crc);
+      if (crc == rel15->rnti) {
+	dci_ind->SFN = frame;
+	dci_ind->slot = slot;
+	dci_ind->dci_list[dci_ind->number_of_dcis].rnti        = rel15->rnti;
+	dci_ind->dci_list[dci_ind->number_of_dcis].n_CCE       = CCEind;
+	dci_ind->dci_list[dci_ind->number_of_dcis].dci_format  = rel15->dci_format;
+	dci_ind->dci_list[dci_ind->number_of_dcis].payloadSize = dci_length;
+	memcpy((void*)dci_ind->dci_list[dci_ind->number_of_dcis].payloadBits,(void*)dci_estimation,8);
+	dci_ind->number_of_dcis++;
+      }
+    }
+  }
+  return(dci_ind->number_of_dcis);
+}
+
+/*
 void nr_dci_decoding_procedure0(int s,
                                 int p,
                                 int coreset_time_dur,
@@ -1056,24 +941,24 @@ void nr_dci_decoding_procedure0(int s,
   //   (1 bit set to '1' corresponds to 6 RB and 1 CCE = 6 RB)
   LOG_DDD("nCCE[%d]=%d\n",p,nCCE[p]);
 
-  /*  if (nCCE > get_nCCE(3, frame_parms, 1)) {
-  LOG_D(PHY,
-  "skip DCI decoding: nCCE=%d > get_nCCE(3,frame_parms,1)=%d\n",
-  nCCE, get_nCCE(3, frame_parms, 1));
-  return;
-  }
+  //  if (nCCE > get_nCCE(3, frame_parms, 1)) {
+  //LOG_D(PHY,
+  //"skip DCI decoding: nCCE=%d > get_nCCE(3,frame_parms,1)=%d\n",
+  //nCCE, get_nCCE(3, frame_parms, 1));
+  //return;
+ // }
 
-  if (nCCE < L2) {
-  LOG_D(PHY, "skip DCI decoding: nCCE=%d < L2=%d\n", nCCE, L2);
-  return;
-  }
+//  if (nCCE < L2) {
+//  LOG_D(PHY, "skip DCI decoding: nCCE=%d < L2=%d\n", nCCE, L2);
+//  return;
+//  }
+
+//  if (mode == NO_DCI) {
+//  LOG_D(PHY, "skip DCI decoding: expect no DCIs at nr_tti_rx %d\n",
+//  nr_tti_rx);
+//  return;
+//  }
 
-  if (mode == NO_DCI) {
-  LOG_D(PHY, "skip DCI decoding: expect no DCIs at nr_tti_rx %d\n",
-  nr_tti_rx);
-  return;
-  }
-  */
   if (do_common == 1) {
     Yk = 0;
 
@@ -1146,9 +1031,9 @@ void nr_dci_decoding_procedure0(int s,
   }
 
   LOG_DDD("L2(%d) | nCCE[%d](%d) | Yk(%u) | nb_candidates(%u)\n", L2, p, nCCE[p], Yk, nb_candidates);
-  /*  for (CCEind=0;
-      CCEind<nCCE2;
-      CCEind+=(1<<L)) {*/
+  //  for (CCEind=0;
+  //    CCEind<nCCE2;
+  //    CCEind+=(1<<L)) {
   //  if (nb_candidates * L2 > nCCE[p])
   //    nb_candidates = nCCE[p] / L2;
   // In the next code line there is maybe a bug. The spec is not comparing Table 10.1-2 with nb_candidates, but with total number of candidates for all s and all p
@@ -1225,35 +1110,35 @@ void nr_dci_decoding_procedure0(int s,
       //      for (int m=0; m < (nCCE[p]*6*9*2); m++)
       LOG_DDD("(polar decoding)-> polar intput (with coreset_time_dur=%d, coreset_nbr_rb=%d, p=%d, CCEind=%u): \n",
              coreset_time_dur,coreset_nbr_rb,p,CCEind);
-      /*
-      int reg_p=0,reg_e=0;
-      for (int m=0; m < (L2*6); m++){
-      reg_p = (((int)floor(m/coreset_time_dur))+((m%coreset_time_dur)*(L2*6/coreset_time_dur)))*9*2;
-      reg_e = m*9*2;
-      for (int i=0; i<9*2; i++){
+      
+      //int reg_p=0,reg_e=0;
+      //for (int m=0; m < (L2*6); m++){
+      //reg_p = (((int)floor(m/coreset_time_dur))+((m%coreset_time_dur)*(L2*6/coreset_time_dur)))*9*2;
+      //reg_e = m*9*2;
+      //for (int i=0; i<9*2; i++){
       //polar_input[reg_p+i] = (pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]>0) ? (1.0):(-1.0);
-      polar_input[reg_e+i] = (pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]>0) ? (1/sqrt(2)):((-1)/sqrt(2));
+      //polar_input[reg_e+i] = (pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]>0) ? (1/sqrt(2)):((-1)/sqrt(2));
       //printf("\t m=%d \tpolar_input[%d]=%lf <-> e_rx[%d]=%d\n",m,reg_e+i,polar_input[reg_e+i],
       //        ((CCEind*9*6*2) + reg_e + i),pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]);
       //printf("\t m=%d \tpolar_input[%d]=%lf <-> e_rx[%d]=%d\n",m,reg_p+i,polar_input[reg_p+i],
       //        ((CCEind*9*6*2) + reg_e + i),pdcch_vars[eNB_id]->e_rx[((CCEind*9*6*2) + reg_e + i)]);
-      }
-      }
+      //}
+      //}
 
-      #ifdef NR_PDCCH_DCI_DEBUG
-      printf("\n");
-      int j=0;
-      uint32_t polar_hex[27] = {0};
-      for (int i=0; i<L2*9*6*2; i++){2
-      if ((i%32 == 0) && (i!=0)) j++;
+      //#ifdef NR_PDCCH_DCI_DEBUG
+      //printf("\n");
+      //int j=0;
+      //uint32_t polar_hex[27] = {0};
+      //for (int i=0; i<L2*9*6*2; i++){2
+      //if ((i%32 == 0) && (i!=0)) j++;
       //polar_hex[j] = (polar_hex[j]<<1) + ((polar_input[i]==-1)? 1:0);
-      polar_hex[j] = polar_hex[j] + (((polar_input[i]==((-1)/sqrt(2)))?1:0)<<(i%32));
-      }
-      for (j=0;j<27;j++) LOG_DDD("polar_hex[%d]=%x\n",j,polar_hex[j]);
-      #endif
-      */
+      //polar_hex[j] = polar_hex[j] + (((polar_input[i]==((-1)/sqrt(2)))?1:0)<<(i%32));
+      //}
+      //for (j=0;j<27;j++) LOG_DDD("polar_hex[%d]=%x\n",j,polar_hex[j]);
+      //#endif
+      
       uint64_t dci_estimation[2]= {0};
-      const t_nrPolar_params *currentPtrDCI=nr_polar_params(1, sizeof_bits, L2);
+      const t_nrPolar_params *currentPtrDCI=nr_polar_params(1, sizeof_bits, L2,1);
       decoderState = polar_decoder_int16(&pdcch_vars[eNB_id]->e_rx[CCEind*9*6*2],
                                          dci_estimation,
                                          1,
@@ -1412,42 +1297,42 @@ void nr_dci_decoding_procedure0(int s,
         // store first nCCE of group for PUCCH transmission of ACK/NAK
         pdcch_vars[eNB_id]->nCCE[nr_tti_rx] = CCEind;
 
-        /*        if (crc == si_rnti) {
-                dci_alloc[*dci_cnt].format = format_si;
-                *dci_cnt = *dci_cnt + 1;
-                } else if (crc == p_rnti) {
-                dci_alloc[*dci_cnt].format = format_p;
-                *dci_cnt = *dci_cnt + 1;
-                } else if (crc == ra_rnti) {
-                dci_alloc[*dci_cnt].format = format_ra;
-                // store first nCCE of group for PUCCH transmission of ACK/NAK
-                pdcch_vars[eNB_id]->nCCE[nr_tti_rx] = CCEind;
-                *dci_cnt = *dci_cnt + 1;
-                } else if (crc == pdcch_vars[eNB_id]->crnti) {
-
-                if ((mode & UL_DCI) && (format_c == format0)
-                && ((dci_decoded_output[current_thread_id][0] & 0x80)
-                == 0)) { // check if pdu is format 0 or 1A
-                if (*format0_found == 0) {
-                dci_alloc[*dci_cnt].format = format0;
-                *format0_found = 1;
-                *dci_cnt = *dci_cnt + 1;
-                pdcch_vars[eNB_id]->nCCE[nr_tti_rx] = CCEind;
-                }
-                } else if (format_c == format0) { // this is a format 1A DCI
-                dci_alloc[*dci_cnt].format = format1A;
-                *dci_cnt = *dci_cnt + 1;
-                pdcch_vars[eNB_id]->nCCE[nr_tti_rx] = CCEind;
-                } else {
-                // store first nCCE of group for PUCCH transmission of ACK/NAK
-                if (*format_c_found == 0) {
-                dci_alloc[*dci_cnt].format = format_c;
-                *dci_cnt = *dci_cnt + 1;
-                *format_c_found = 1;
-                pdcch_vars[eNB_id]->nCCE[nr_tti_rx] = CCEind;
-                }
-                }
-                }*/
+        //        if (crc == si_rnti) {
+        //        dci_alloc[*dci_cnt].format = format_si;
+        //        *dci_cnt = *dci_cnt + 1;
+        //        } else if (crc == p_rnti) {
+        //        dci_alloc[*dci_cnt].format = format_p;
+        //        *dci_cnt = *dci_cnt + 1;
+        //        } else if (crc == ra_rnti) {
+        //        dci_alloc[*dci_cnt].format = format_ra;
+        //        // store first nCCE of group for PUCCH transmission of ACK/NAK
+        //        pdcch_vars[eNB_id]->nCCE[nr_tti_rx] = CCEind;
+        //        *dci_cnt = *dci_cnt + 1;
+        //        } else if (crc == pdcch_vars[eNB_id]->crnti) {
+
+        //        if ((mode & UL_DCI) && (format_c == format0)
+        //        && ((dci_decoded_output[current_thread_id][0] & 0x80)
+        //        == 0)) { // check if pdu is format 0 or 1A
+        //        if (*format0_found == 0) {
+        //        dci_alloc[*dci_cnt].format = format0;
+        //        *format0_found = 1;
+        //        *dci_cnt = *dci_cnt + 1;
+        //        pdcch_vars[eNB_id]->nCCE[nr_tti_rx] = CCEind;
+        //        }
+        //        } else if (format_c == format0) { // this is a format 1A DCI
+        //        dci_alloc[*dci_cnt].format = format1A;
+        //        *dci_cnt = *dci_cnt + 1;
+        //        pdcch_vars[eNB_id]->nCCE[nr_tti_rx] = CCEind;
+        //        } else {
+        //        // store first nCCE of group for PUCCH transmission of ACK/NAK
+        //        if (*format_c_found == 0) {
+        //        dci_alloc[*dci_cnt].format = format_c;
+        //        *dci_cnt = *dci_cnt + 1;
+        //        *format_c_found = 1;
+        //        pdcch_vars[eNB_id]->nCCE[nr_tti_rx] = CCEind;
+        //        }
+        //        }
+        //        }
         //LOG_I(PHY,"DCI decoding CRNTI  [format: %d, nCCE[nr_tti_rx: %d]: %d ], AggregationLevel %d \n",format_c, nr_tti_rx, pdcch_vars[eNB_id]->nCCE[nr_tti_rx],L2);
         //  memcpy(&dci_alloc[*dci_cnt].dci_pdu[0],dci_decoded_output,sizeof_bytes);
         switch (1 << L) {
@@ -1484,1045 +1369,30 @@ void nr_dci_decoding_procedure0(int s,
       printf("\n");
     }
 
-    /*
-      if ( agregationLevel != 0xFF &&
-      (format_c == format0 && m==0 && si_rnti != SI_RNTI))
-      {
-      //Only valid for OAI : Save some processing time when looking for DCI format0. From the log we see the DCI only on candidate 0.
-      return;
-      }
-    */
+    
+    //  if ( agregationLevel != 0xFF &&
+    //  (format_c == format0 && m==0 && si_rnti != SI_RNTI))
+    //  {
+    //  //Only valid for OAI : Save some processing time when looking for DCI format0. From the log we see the DCI only on candidate 0.
+    //  return;
+    //  }
+    
   } // candidate loop
 
   LOG_DDD("end candidate loop\n");
 }
-
-#endif
-
-
-
-
-
-/*void dci_decoding_procedure0(NR_UE_PDCCH **pdcch_vars,
-  int do_common,
-  dci_detect_mode_t mode,
-  uint8_t nr_tti_rx,
-  DCI_ALLOC_t *dci_alloc,
-  int16_t eNB_id,
-  uint8_t current_thread_id,
-  NR_DL_FRAME_PARMS *frame_parms,
-  uint8_t mi,
-  uint16_t si_rnti,
-  uint16_t ra_rnti,
-  uint16_t p_rnti,
-  uint8_t L,
-  uint8_t format_si,
-  uint8_t format_p,
-  uint8_t format_ra,
-  uint8_t format_c,
-  uint8_t sizeof_bits,
-  uint8_t sizeof_bytes,
-  uint8_t *dci_cnt,
-  uint8_t *format0_found,
-  uint8_t *format_c_found,
-  uint32_t *CCEmap0,
-  uint32_t *CCEmap1,
-  uint32_t *CCEmap2)
-  {
-
-  uint16_t crc,CCEind,nCCE;
-  uint32_t *CCEmap=NULL,CCEmap_mask=0;
-  int L2=(1<<L);
-  unsigned int Yk,nb_candidates = 0,i,m;
-  unsigned int CCEmap_cand;
-  #ifdef NR_PDCCH_DCI_DEBUG
-  LOG_DDD("\n");
-  #endif
-  nCCE = get_nCCE(pdcch_vars[eNB_id]->num_pdcch_symbols,frame_parms,mi);
-
-  if (nCCE > get_nCCE(3,frame_parms,1)) {
-  LOG_D(PHY,"skip DCI decoding: nCCE=%d > get_nCCE(3,frame_parms,1)=%d\n", nCCE, get_nCCE(3,frame_parms,1));
-  return;
-  }
-
-  if (nCCE<L2) {
-  LOG_D(PHY,"skip DCI decoding: nCCE=%d < L2=%d\n", nCCE, L2);
-  return;
-  }
-
-  if (mode == NO_DCI) {
-  LOG_D(PHY, "skip DCI decoding: expect no DCIs at nr_tti_rx %d\n", nr_tti_rx);
-  return;
-  }
-
-  if (do_common == 1) {
-  nb_candidates = (L2==4) ? 4 : 2;
-  Yk=0;
-  } else {
-  // Find first available in ue specific search space
-  // according to procedure in Section 9.1.1 of 36.213 (v. 8.6)
-  // compute Yk
-  Yk = (unsigned int)pdcch_vars[eNB_id]->crnti;
-
-  for (i=0; i<=nr_tti_rx; i++)
-  Yk = (Yk*39827)%65537;
-
-  Yk = Yk % (nCCE/L2);
-
-  switch (L2) {
-  case 1:
-  case 2:
-  nb_candidates = 6;
-  break;
-
-  case 4:
-  case 8:
-  nb_candidates = 2;
-  break;
-
-  default:
-  DevParam(L2, do_common, eNB_id);
-  break;
-  }
-  }
-
-  //  for (CCEind=0;
-  //     CCEind<nCCE2;
-  //     CCEind+=(1<<L)) {
-
-  if (nb_candidates*L2 > nCCE)
-  nb_candidates = nCCE/L2;
-
-  for (m=0; m<nb_candidates; m++) {
-
-  CCEind = (((Yk+m)%(nCCE/L2))*L2);
-
-  if (CCEind<32)
-  CCEmap = CCEmap0;
-  else if (CCEind<64)
-  CCEmap = CCEmap1;
-  else if (CCEind<96)
-  CCEmap = CCEmap2;
-  else {
-  LOG_E(PHY,"Illegal CCEind %d (Yk %d, m %d, nCCE %d, L2 %d\n",CCEind,Yk,m,nCCE,L2);
-  mac_xface->macphy_exit("Illegal CCEind\n");
-  return; // not reached
-  }
-
-  switch (L2) {
-  case 1:
-  CCEmap_mask = (1<<(CCEind&0x1f));
-  break;
-
-  case 2:
-  CCEmap_mask = (3<<(CCEind&0x1f));
-  break;
-
-  case 4:
-  CCEmap_mask = (0xf<<(CCEind&0x1f));
-  break;
-
-  case 8:
-  CCEmap_mask = (0xff<<(CCEind&0x1f));
-  break;
-
-  default:
-  LOG_E( PHY, "Illegal L2 value %d\n", L2 );
-  mac_xface->macphy_exit( "Illegal L2\n" );
-  return; // not reached
-  }
-
-  CCEmap_cand = (*CCEmap)&CCEmap_mask;
-
-  // CCE is not allocated yet
-
-  if (CCEmap_cand == 0) {
-  #ifdef DEBUG_DCI_DECODING
-
-  if (do_common == 1)
-  LOG_I(PHY,"[DCI search nPdcch %d - common] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x)\n",
-  pdcch_vars[eNB_id]->num_pdcch_symbols,m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask);
-  else
-  LOG_I(PHY,"[DCI search nPdcch %d - ue spec] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x) format %d\n",
-  pdcch_vars[eNB_id]->num_pdcch_symbols,m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask,format_c);
-
-  #endif
-
-  dci_decoding(sizeof_bits,
-  L,
-  &pdcch_vars[eNB_id]->e_rx[CCEind*72],
-  &dci_decoded_output[current_thread_id][0]);
-
-  //  for (i=0;i<3+(sizeof_bits>>3);i++)
-  //  printf("dci_decoded_output[%d] => %x\n",i,dci_decoded_output[i]);
-
-  crc = (crc16(&dci_decoded_output[current_thread_id][0],sizeof_bits)>>16) ^ extract_crc(&dci_decoded_output[current_thread_id][0],sizeof_bits);
-  #ifdef DEBUG_DCI_DECODING
-  printf("crc =>%x\n",crc);
-  #endif
-
-  if (((L>1) && ((crc == si_rnti)|| (crc == p_rnti)|| (crc == ra_rnti)))||
-  (crc == pdcch_vars[eNB_id]->crnti))   {
-  dci_alloc[*dci_cnt].dci_length = sizeof_bits;
-  dci_alloc[*dci_cnt].rnti       = crc;
-  dci_alloc[*dci_cnt].L          = L;
-  dci_alloc[*dci_cnt].firstCCE   = CCEind;
-
-  //printf("DCI FOUND !!! crc =>%x,  sizeof_bits %d, sizeof_bytes %d \n",crc, sizeof_bits, sizeof_bytes);
-  if (sizeof_bytes<=4) {
-  dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][0];
-  dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][1];
-  dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][2];
-  dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][3];
-  #ifdef DEBUG_DCI_DECODING
-  printf("DCI => %x,%x,%x,%x\n",dci_decoded_output[current_thread_id][0],
-  dci_decoded_output[current_thread_id][1],
-  dci_decoded_output[current_thread_id][2],
-  dci_decoded_output[current_thread_id][3]);
-  #endif
-  } else {
-  dci_alloc[*dci_cnt].dci_pdu[7] = dci_decoded_output[current_thread_id][0];
-  dci_alloc[*dci_cnt].dci_pdu[6] = dci_decoded_output[current_thread_id][1];
-  dci_alloc[*dci_cnt].dci_pdu[5] = dci_decoded_output[current_thread_id][2];
-  dci_alloc[*dci_cnt].dci_pdu[4] = dci_decoded_output[current_thread_id][3];
-  dci_alloc[*dci_cnt].dci_pdu[3] = dci_decoded_output[current_thread_id][4];
-  dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[current_thread_id][5];
-  dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[current_thread_id][6];
-  dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[current_thread_id][7];
-  #ifdef DEBUG_DCI_DECODING
-  printf("DCI => %x,%x,%x,%x,%x,%x,%x,%x\n",
-  dci_decoded_output[current_thread_id][0],dci_decoded_output[current_thread_id][1],dci_decoded_output[current_thread_id][2],dci_decoded_output[current_thread_id][3],
-  dci_decoded_output[current_thread_id][4],dci_decoded_output[current_thread_id][5],dci_decoded_output[current_thread_id][6],dci_decoded_output[current_thread_id][7]);
-  #endif
-  }
-
-  if (crc==si_rnti) {
-  dci_alloc[*dci_cnt].format     = format_si;
-  *dci_cnt = *dci_cnt+1;
-  } else if (crc==p_rnti) {
-  dci_alloc[*dci_cnt].format     = format_p;
-  *dci_cnt = *dci_cnt+1;
-  } else if (crc==ra_rnti) {
-  dci_alloc[*dci_cnt].format     = format_ra;
-  // store first nCCE of group for PUCCH transmission of ACK/NAK
-  pdcch_vars[eNB_id]->nCCE[nr_tti_rx]=CCEind;
-  *dci_cnt = *dci_cnt+1;
-  } else if (crc==pdcch_vars[eNB_id]->crnti) {
-
-  if ((mode&UL_DCI)&&(format_c == format0)&&((dci_decoded_output[current_thread_id][0]&0x80)==0)) {// check if pdu is format 0 or 1A
-  if (*format0_found == 0) {
-  dci_alloc[*dci_cnt].format     = format0;
-  *format0_found = 1;
-  *dci_cnt = *dci_cnt+1;
-  pdcch_vars[eNB_id]->nCCE[nr_tti_rx]=CCEind;
-  }
-  } else if (format_c == format0) { // this is a format 1A DCI
-  dci_alloc[*dci_cnt].format     = format1A;
-  *dci_cnt = *dci_cnt+1;
-  pdcch_vars[eNB_id]->nCCE[nr_tti_rx]=CCEind;
-  } else {
-  // store first nCCE of group for PUCCH transmission of ACK/NAK
-  if (*format_c_found == 0) {
-  dci_alloc[*dci_cnt].format     = format_c;
-  *dci_cnt = *dci_cnt+1;
-  *format_c_found = 1;
-  pdcch_vars[eNB_id]->nCCE[nr_tti_rx]=CCEind;
-  }
-  }
-  }
-
-  //LOG_I(PHY,"DCI decoding CRNTI  [format: %d, nCCE[nr_tti_rx: %d]: %d ], AggregationLevel %d \n",format_c, nr_tti_rx, pdcch_vars[eNB_id]->nCCE[nr_tti_rx],L2);
-  //  memcpy(&dci_alloc[*dci_cnt].dci_pdu[0],dci_decoded_output,sizeof_bytes);
-
-
-
-  switch (1<<L) {
-  case 1:
-  *CCEmap|=(1<<(CCEind&0x1f));
-  break;
-
-  case 2:
-  *CCEmap|=(1<<(CCEind&0x1f));
-  break;
-
-  case 4:
-  *CCEmap|=(1<<(CCEind&0x1f));
-  break;
-
-  case 8:
-  *CCEmap|=(1<<(CCEind&0x1f));
-  break;
-  }
-
-  #ifdef DEBUG_DCI_DECODING
-  LOG_I(PHY,"[DCI search] Found DCI %d rnti %x Aggregation %d length %d format %s in CCE %d (CCEmap %x) candidate %d / %d \n",
-  *dci_cnt,crc,1<<L,sizeof_bits,dci_format_strings[dci_alloc[*dci_cnt-1].format],CCEind,*CCEmap,m,nb_candidates );
-  dump_dci(frame_parms,&dci_alloc[*dci_cnt-1]);
-
-  #endif
-  return;
-  } // rnti match
-  }  // CCEmap_cand == 0
-
-  //  if ( agregationLevel != 0xFF &&
-  //        (format_c == format0 && m==0 && si_rnti != SI_RNTI))
-  //    {
-  //      //Only valid for OAI : Save some processing time when looking for DCI format0. From the log we see the DCI only on candidate 0.
-  //      return;
-  //    }
-
-  } // candidate loop
-  }
-
-  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 nr_tti_rx)
-  {
-
-  uint8_t  dci_cnt=0,old_dci_cnt=0;
-  uint32_t CCEmap0=0,CCEmap1=0,CCEmap2=0;
-  NR_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]];
-  NR_DL_FRAME_PARMS *frame_parms  = &ue->frame_parms;
-  uint8_t mi = get_mi(&ue->frame_parms,nr_tti_rx);
-  uint16_t ra_rnti=99;
-  uint8_t format0_found=0,format_c_found=0;
-  uint8_t tmode = ue->transmission_mode[eNB_id];
-  uint8_t frame_type = frame_parms->frame_type;
-  uint8_t format0_size_bits=0,format0_size_bytes=0;
-  uint8_t format1_size_bits=0,format1_size_bytes=0;
-  dci_detect_mode_t mode = dci_detect_mode_select(&ue->frame_parms,nr_tti_rx);
-
-  switch (frame_parms->N_RB_DL) {
-  case 6:
-  if (frame_type == TDD) {
-  format0_size_bits  = sizeof_DCI0_1_5MHz_TDD_1_6_t;
-  format0_size_bytes = sizeof(DCI0_1_5MHz_TDD_1_6_t);
-  format1_size_bits  = sizeof_DCI1_1_5MHz_TDD_t;
-  format1_size_bytes = sizeof(DCI1_1_5MHz_TDD_t);
-
-  } else {
-  format0_size_bits  = sizeof_DCI0_1_5MHz_FDD_t;
-  format0_size_bytes = sizeof(DCI0_1_5MHz_FDD_t);
-  format1_size_bits  = sizeof_DCI1_1_5MHz_FDD_t;
-  format1_size_bytes = sizeof(DCI1_1_5MHz_FDD_t);
-  }
-
-  break;
-
-  case 25:
-  default:
-  if (frame_type == TDD) {
-  format0_size_bits  = sizeof_DCI0_5MHz_TDD_1_6_t;
-  format0_size_bytes = sizeof(DCI0_5MHz_TDD_1_6_t);
-  format1_size_bits  = sizeof_DCI1_5MHz_TDD_t;
-  format1_size_bytes = sizeof(DCI1_5MHz_TDD_t);
-  } else {
-  format0_size_bits  = sizeof_DCI0_5MHz_FDD_t;
-  format0_size_bytes = sizeof(DCI0_5MHz_FDD_t);
-  format1_size_bits  = sizeof_DCI1_5MHz_FDD_t;
-  format1_size_bytes = sizeof(DCI1_5MHz_FDD_t);
-  }
-
-  break;
-
-  case 50:
-  if (frame_type == TDD) {
-  format0_size_bits  = sizeof_DCI0_10MHz_TDD_1_6_t;
-  format0_size_bytes = sizeof(DCI0_10MHz_TDD_1_6_t);
-  format1_size_bits  = sizeof_DCI1_10MHz_TDD_t;
-  format1_size_bytes = sizeof(DCI1_10MHz_TDD_t);
-
-  } else {
-  format0_size_bits  = sizeof_DCI0_10MHz_FDD_t;
-  format0_size_bytes = sizeof(DCI0_10MHz_FDD_t);
-  format1_size_bits  = sizeof_DCI1_10MHz_FDD_t;
-  format1_size_bytes = sizeof(DCI1_10MHz_FDD_t);
-  }
-
-  break;
-
-  case 100:
-  if (frame_type == TDD) {
-  format0_size_bits  = sizeof_DCI0_20MHz_TDD_1_6_t;
-  format0_size_bytes = sizeof(DCI0_20MHz_TDD_1_6_t);
-  format1_size_bits  = sizeof_DCI1_20MHz_TDD_t;
-  format1_size_bytes = sizeof(DCI1_20MHz_TDD_t);
-  } else {
-  format0_size_bits  = sizeof_DCI0_20MHz_FDD_t;
-  format0_size_bytes = sizeof(DCI0_20MHz_FDD_t);
-  format1_size_bits  = sizeof_DCI1_20MHz_FDD_t;
-  format1_size_bytes = sizeof(DCI1_20MHz_FDD_t);
-  }
-
-  break;
-  }
-
-  if (ue->prach_resources[eNB_id])
-  ra_rnti = ue->prach_resources[eNB_id]->ra_RNTI;
-
-  // Now check UE_SPEC format0/1A ue_spec search spaces at aggregation 8
-  dci_decoding_procedure0(pdcch_vars,0,mode,
-  nr_tti_rx,
-  dci_alloc,
-  eNB_id,
-  ue->current_thread_id[nr_tti_rx],
-  frame_parms,
-  mi,
-  ((ue->decode_SIB == 1) ? SI_RNTI : 0),
-  ra_rnti,
-  P_RNTI,
-  agregationLevel,
-  format1A,
-  format1A,
-  format1A,
-  format0,
-  format0_size_bits,
-  format0_size_bytes,
-  &dci_cnt,
-  &format0_found,
-  &format_c_found,
-  &CCEmap0,
-  &CCEmap1,
-  &CCEmap2);
-
-  if ((CCEmap0==0xffff)||
-  ((format0_found==1)&&(format_c_found==1)))
-  return(dci_cnt);
-
-  if (DCIFormat == 1)
-  {
-  if ((tmode < 3) || (tmode == 7)) {
-  //printf("Crnti decoding frame param agregation %d DCI %d \n",agregationLevel,DCIFormat);
-
-  // Now check UE_SPEC format 1 search spaces at aggregation 1
-
-  //printf("[DCI search] Format 1/1A aggregation 1\n");
-
-  old_dci_cnt=dci_cnt;
-  dci_decoding_procedure0(pdcch_vars,0,mode,nr_tti_rx,
-  dci_alloc,
-  eNB_id,
-  ue->current_thread_id[nr_tti_rx],
-  frame_parms,
-  mi,
-  ((ue->decode_SIB == 1) ? SI_RNTI : 0),
-  ra_rnti,
-  P_RNTI,
-  0,
-  format1A,
-  format1A,
-  format1A,
-  format1,
-  format1_size_bits,
-  format1_size_bytes,
-  &dci_cnt,
-  &format0_found,
-  &format_c_found,
-  &CCEmap0,
-  &CCEmap1,
-  &CCEmap2);
-
-  if ((CCEmap0==0xffff) ||
-  (format_c_found==1))
-  return(dci_cnt);
-
-  if (dci_cnt>old_dci_cnt)
-  return(dci_cnt);
-
-  //printf("Crnti 1 decoding frame param agregation %d DCI %d \n",agregationLevel,DCIFormat);
-
-  }
-  else
-  {
-  AssertFatal(0,"Other Transmission mode not yet coded\n");
-  }
-  }
-  else
-  {
-  AssertFatal(0,"DCI format %d not yet implemented \n",DCIFormat);
-  }
-
-  return(dci_cnt);
-
-  }
 */
-
-#ifdef NR_PDCCH_DCI_RUN
-
-uint16_t nr_dci_format_size (PHY_VARS_NR_UE *ue,
-                             uint16_t eNB_id,
-                             uint8_t nr_tti_rx,
-                             int p,
-                             crc_scrambled_t crc_scrambled,
-                             uint16_t n_RB_ULBWP,
-                             uint16_t n_RB_DLBWP,
-                             uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS],
-                             uint8_t format) {
-  LOG_DDD("crc_scrambled=%d, n_RB_ULBWP=%d, n_RB_DLBWP=%d\n",crc_scrambled,n_RB_ULBWP,n_RB_DLBWP);
-  /*
-   * function nr_dci_format_size calculates and returns the size in bits of a determined format
-   * it also returns an bi-dimensional array 'dci_fields_sizes' with x rows and y columns, where:
-   * x is the number of fields defined in TS 38.212 subclause 7.3.1 (Each field is mapped in the order in which it appears in the description in the specification)
-   * y is the number of formats
-   *   e.g.: dci_fields_sizes[10][0] contains the size in bits of the field FREQ_DOM_RESOURCE_ASSIGNMENT_UL for format 0_0
-   */
-  // pdsch_config contains the PDSCH-Config IE is used to configure the UE specific PDSCH parameters (TS 38.331)
-  PDSCH_Config_t pdsch_config       = ue->PDSCH_Config;
-  // pusch_config contains the PUSCH-Config IE is used to configure the UE specific PUSCH parameters (TS 38.331)
-  PUSCH_Config_t pusch_config       = ue->pusch_config;
-  PUCCH_Config_t pucch_config_dedicated       = ue->pucch_config_dedicated_nr[eNB_id];
-  crossCarrierSchedulingConfig_t crossCarrierSchedulingConfig = ue->crossCarrierSchedulingConfig;
-  dmrs_UplinkConfig_t dmrs_UplinkConfig = ue->dmrs_UplinkConfig;
-  dmrs_DownlinkConfig_t dmrs_DownlinkConfig = ue->dmrs_DownlinkConfig;
-  csi_MeasConfig_t csi_MeasConfig = ue->csi_MeasConfig;
-  PUSCH_ServingCellConfig_t PUSCH_ServingCellConfig= ue->PUSCH_ServingCellConfig;
-  PDSCH_ServingCellConfig_t PDSCH_ServingCellConfig= ue->PDSCH_ServingCellConfig;
-  NR_UE_PDCCH *pdcch_vars2 = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id];
-  // 1  CARRIER_IN
-  // crossCarrierSchedulingConfig from higher layers, variable crossCarrierSchedulingConfig indicates if 'cross carrier scheduling' is enabled or not:
-  //      if No cross carrier scheduling: number of bits for CARRIER_IND is 0
-  //      if Cross carrier scheduling: number of bits for CARRIER_IND is 3
-  // The IE CrossCarrierSchedulingConfig is used to specify the configuration when the cross-carrier scheduling is used in a cell
-  uint8_t crossCarrierSchedulingConfig_ind = 0;
-
-  if (crossCarrierSchedulingConfig.schedulingCellInfo.other.cif_InSchedulingCell !=0 ) crossCarrierSchedulingConfig_ind=1;
-
-  // 2  SUL_IND_0_1, // 40 SRS_REQUEST, // 50 SUL_IND_0_0
-  // UL/SUL indicator (TS 38.331, supplementary uplink is indicated in higher layer parameter ServCellAdd-SUL from IE ServingCellConfig and ServingCellConfigCommon):
-  // 0 bit for UEs not configured with SUL in the cell or UEs configured with SUL in the cell but only PUCCH carrier in the cell is configured for PUSCH transmission
-  // 1 bit for UEs configured with SUL in the cell as defined in Table 7.3.1.1.1-1
-  // sul_ind indicates whether SUL is configured in cell or not
-  uint8_t sul_ind=ue->supplementaryUplink.supplementaryUplink; // this value will be 0 or 1 depending on higher layer parameter ServCellAdd-SUL. FIXME!!!
-  // 7  BANDWIDTH_PART_IND
-  // number of UL BWPs configured by higher layers
-  uint8_t n_UL_BWP_RRC=1; // initialized to 1 but it has to be initialized by higher layers FIXME!!!
-  n_UL_BWP_RRC = ((n_UL_BWP_RRC > 3)?n_UL_BWP_RRC:(n_UL_BWP_RRC+1));
-  // number of DL BWPs configured by higher layers
-  uint8_t n_DL_BWP_RRC=1; // initialized to 1 but it has to be initialized by higher layers FIXME!!!
-  n_DL_BWP_RRC = ((n_DL_BWP_RRC > 3)?n_DL_BWP_RRC:(n_DL_BWP_RRC+1));
-  // 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL
-  // if format0_0, only resource allocation type 1 is allowed
-  // if format0_1, then resource allocation type 0 can be configured and N_RBG is defined in TS 38.214 subclause 6.1.2.2.1
-  // for PUSCH hopping with resource allocation type 1
-  //      n_UL_hopping = 1 if the higher layer parameter frequencyHoppingOffsetLists contains two  offset values
-  //      n_UL_hopping = 2 if the higher layer parameter frequencyHoppingOffsetLists contains four offset values
-  uint8_t n_UL_hopping=pusch_config.n_frequencyHoppingOffsetLists;
-
-  if (n_UL_hopping == 2) {
-    n_UL_hopping = 1;
-  } else if (n_UL_hopping == 4) {
-    n_UL_hopping = 2;
-  } else {
-    n_UL_hopping = 0;
-  }
-
-  ul_resourceAllocation_t ul_resource_allocation_type = pusch_config.ul_resourceAllocation;
-  uint8_t ul_res_alloc_type_0 = 0;
-  uint8_t ul_res_alloc_type_1 = 0;
-
-  if (ul_resource_allocation_type == ul_resourceAllocationType0) ul_res_alloc_type_0 = 1;
-
-  if (ul_resource_allocation_type == ul_resourceAllocationType1) ul_res_alloc_type_1 = 1;
-
-  if (ul_resource_allocation_type == ul_dynamicSwitch) {
-    ul_res_alloc_type_0 = 1;
-    ul_res_alloc_type_1 = 1;
-  }
-
-  uint8_t n_bits_freq_dom_res_assign_ul=0,n_ul_RGB_tmp;
-
-  if (ul_res_alloc_type_0 == 1) { // implementation of Table 6.1.2.2.1-1 TC 38.214 subclause 6.1.2.2.1
-    // config1: PUSCH-Config IE contains rbg-Size ENUMERATED {config1 config2}
-    ul_rgb_Size_t config = pusch_config.ul_rgbSize;
-    uint8_t nominal_RBG_P               = (config==ul_rgb_config1?2:4);
-
-    if (n_RB_ULBWP > 36)  nominal_RBG_P = (config==ul_rgb_config1?4:8);
-
-    if (n_RB_ULBWP > 72)  nominal_RBG_P = (config==ul_rgb_config1?8:16);
-
-    if (n_RB_ULBWP > 144) nominal_RBG_P = 16;
-
-    n_bits_freq_dom_res_assign_ul = (uint8_t)ceil((n_RB_ULBWP+(0%nominal_RBG_P))/nominal_RBG_P);                                   //FIXME!!! what is 0???
-    n_ul_RGB_tmp = n_bits_freq_dom_res_assign_ul;
-  }
-
-  if (ul_res_alloc_type_1 == 1) n_bits_freq_dom_res_assign_ul = (uint8_t)(ceil(log2(n_RB_ULBWP*(n_RB_ULBWP+1)/2)))-n_UL_hopping;
-
-  if ((ul_res_alloc_type_0 == 1) && (ul_res_alloc_type_1 == 1))
-    n_bits_freq_dom_res_assign_ul = ((n_bits_freq_dom_res_assign_ul>n_ul_RGB_tmp)?(n_bits_freq_dom_res_assign_ul+1):(n_ul_RGB_tmp+1));
-
-  // 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL
-  // if format1_0, only resource allocation type 1 is allowed
-  // if format1_1, then resource allocation type 0 can be configured and N_RBG is defined in TS 38.214 subclause 5.1.2.2.1
-  dl_resourceAllocation_t dl_resource_allocation_type = pdsch_config.dl_resourceAllocation;
-  uint8_t dl_res_alloc_type_0 = 0;
-  uint8_t dl_res_alloc_type_1 = 0;
-
-  if (dl_resource_allocation_type == dl_resourceAllocationType0) dl_res_alloc_type_0 = 1;
-
-  if (dl_resource_allocation_type == dl_resourceAllocationType1) dl_res_alloc_type_1 = 1;
-
-  if (dl_resource_allocation_type == dl_dynamicSwitch) {
-    dl_res_alloc_type_0 = 1;
-    dl_res_alloc_type_1 = 1;
-  }
-
-  uint8_t n_bits_freq_dom_res_assign_dl=0,n_dl_RGB_tmp;
-
-  if (dl_res_alloc_type_0 == 1) { // implementation of Table 5.1.2.2.1-1 TC 38.214 subclause 6.1.2.2.1
-    // config1: PDSCH-Config IE contains rbg-Size ENUMERATED {config1, config2}
-    dl_rgb_Size_t config = pdsch_config.dl_rgbSize;
-    uint8_t nominal_RBG_P               = (config==dl_rgb_config1?2:4);
-
-    if (n_RB_DLBWP > 36)  nominal_RBG_P = (config==dl_rgb_config1?4:8);
-
-    if (n_RB_DLBWP > 72)  nominal_RBG_P = (config==dl_rgb_config1?8:16);
-
-    if (n_RB_DLBWP > 144) nominal_RBG_P = 16;
-
-    n_bits_freq_dom_res_assign_dl = (uint8_t)ceil((n_RB_DLBWP+(0%nominal_RBG_P))/nominal_RBG_P);                                     //FIXME!!! what is 0???
-    n_dl_RGB_tmp = n_bits_freq_dom_res_assign_dl;
-  }
-
-  if (dl_res_alloc_type_1 == 1) n_bits_freq_dom_res_assign_dl = (uint8_t)(ceil(log2(n_RB_DLBWP*(n_RB_DLBWP+1)/2)));
-
-  if ((dl_res_alloc_type_0 == 1) && (dl_res_alloc_type_1 == 1))
-    n_bits_freq_dom_res_assign_dl = ((n_bits_freq_dom_res_assign_dl>n_dl_RGB_tmp)?(n_bits_freq_dom_res_assign_dl+1):(n_dl_RGB_tmp+1));
-
-  // 12 TIME_DOM_RESOURCE_ASSIGNMENT
-  uint8_t pusch_alloc_list = pusch_config.n_push_alloc_list;
-  uint8_t pdsch_alloc_list = pdsch_config.n_pdsh_alloc_list;
-  // 14 PRB_BUNDLING_SIZE_IND:0 bit if the higher layer parameter PRB_bundling is not configured or is set to 'static', or 1 bit if the higher layer parameter PRB_bundling is set to 'dynamic' according to Subclause 5.1.2.3 of [6, TS 38.214]
-  static_bundleSize_t static_prb_BundlingType = pdsch_config.prbBundleType.staticBundling;
-  bundleSizeSet1_t dynamic_prb_BundlingType1  = pdsch_config.prbBundleType.dynamicBundlig.bundleSizeSet1;
-  bundleSizeSet2_t dynamic_prb_BundlingType2  = pdsch_config.prbBundleType.dynamicBundlig.bundleSizeSet2;
-  uint8_t prb_BundlingType_size=0;
-
-  if ((static_prb_BundlingType==st_n4)||(static_prb_BundlingType==st_wideband)) prb_BundlingType_size=0;
-
-  if ((dynamic_prb_BundlingType1==dy_1_n4)||(dynamic_prb_BundlingType1==dy_1_wideband)||(dynamic_prb_BundlingType1==dy_1_n2_wideband)||(dynamic_prb_BundlingType1==dy_1_n4_wideband)||
-      (dynamic_prb_BundlingType2==dy_2_n4)||(dynamic_prb_BundlingType2==dy_2_wideband)) prb_BundlingType_size=1;
-
-  // 15 RATE_MATCHING_IND FIXME!!!
-  // according to TS 38.212: Rate matching indicator – 0, 1, or 2 bits according to higher layer parameter rateMatchPattern
-  uint8_t rateMatching_bits = pdsch_config.n_rateMatchPatterns;
-  // 16 ZP_CSI_RS_TRIGGER FIXME!!!
-  // 0, 1, or 2 bits as defined in Subclause 5.1.4.2 of [6, TS 38.214].
-  // is the number of ZP CSI-RS resource sets in the higher layer parameter zp-CSI-RS-Resource
-  uint8_t n_zp_bits = pdsch_config.n_zp_CSI_RS_ResourceId;
-  // 17 FREQ_HOPPING_FLAG
-  // freqHopping is defined by higher layer parameter frequencyHopping from IE PUSCH-Config. Values are ENUMERATED{mode1, mode2}
-  frequencyHopping_t f_hopping = pusch_config.frequencyHopping;
-  uint8_t freqHopping = 0;
-
-  if ((f_hopping==f_hop_mode1)||(f_hopping==f_hop_mode2)) freqHopping = 1;
-
-  // 28 DAI
-  pdsch_HARQ_ACK_Codebook_t pdsch_HARQ_ACK_Codebook = pdsch_config.pdsch_HARQ_ACK_Codebook;
-  uint8_t n_dai = 0;
-  uint8_t n_serving_cell_dl = 1; // this is hardcoded to 1 as we need to get this value from RRC higher layers parameters. FIXME!!!
-
-  if ((pdsch_HARQ_ACK_Codebook == dynamic) && (n_serving_cell_dl == 1)) n_dai = 2;
-
-  if ((pdsch_HARQ_ACK_Codebook == dynamic) && (n_serving_cell_dl > 1))  n_dai = 4;
-
-  // 29 FIRST_DAI
-  uint8_t codebook_HARQ_ACK = 0;           // We need to get this value to calculate number of bits of fields 1st DAI and 2nd DAI.
-
-  if (pdsch_HARQ_ACK_Codebook == semiStatic) codebook_HARQ_ACK = 1;
-
-  if (pdsch_HARQ_ACK_Codebook == dynamic) codebook_HARQ_ACK = 2;
-
-  // 30 SECOND_DAI
-  uint8_t n_HARQ_ACK_sub_codebooks = 0;   // We need to get this value to calculate number of bits of fields 1st DAI and 2nd DAI. FIXME!!!
-  // 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND
-  uint8_t pdsch_harq_t_ind = (uint8_t)ceil(log2(pucch_config_dedicated.dl_DataToUL_ACK[0]));
-  // 36 SRS_RESOURCE_IND
-  // n_SRS is the number of configured SRS resources in the SRS resource set associated with the higher layer parameter usage of value 'codeBook' or 'nonCodeBook'
-  // from SRS_ResourceSet_t type we should get the information of the usage parameter (with possible values beamManagement, codebook, nonCodebook, antennaSwitching)
-  // at frame_parms->srs_nr->p_SRS_ResourceSetList[]->usage
-  uint8_t n_SRS = ue->srs.number_srs_Resource_Set;
-  // 37 PRECOD_NBR_LAYERS
-  // 38 ANTENNA_PORTS
-  txConfig_t txConfig = pusch_config.txConfig;
-  transformPrecoder_t transformPrecoder = pusch_config.transformPrecoder;
-  codebookSubset_t codebookSubset = pusch_config.codebookSubset;
-  uint8_t maxRank = pusch_config.maxRank;
-  uint8_t num_antenna_ports = 1; // this is hardcoded. We need to get the real value FIXME!!!
-  uint8_t precond_nbr_layers_bits = 0;
-  uint8_t antenna_ports_bits_ul = 0;
-
-  // searching number of bits at tables 7.3.1.1.2-2/3/4/5 from TS 38.212 subclause 7.3.1.1.2
-  if (txConfig == txConfig_codebook) {
-    if (num_antenna_ports == 4) {
-      if ((transformPrecoder == transformPrecoder_disabled) && ((maxRank == 2)||(maxRank == 3)||(maxRank == 4))) { // Table 7.3.1.1.2-2
-        if (codebookSubset == codebookSubset_fullyAndPartialAndNonCoherent) precond_nbr_layers_bits=6;
-
-        if (codebookSubset == codebookSubset_partialAndNonCoherent) precond_nbr_layers_bits=5;
-
-        if (codebookSubset == codebookSubset_nonCoherent) precond_nbr_layers_bits=4;
-      }
-
-      if (((transformPrecoder == transformPrecoder_enabled)||(transformPrecoder == transformPrecoder_disabled)) && (maxRank == 1)) { // Table 7.3.1.1.2-3
-        if (codebookSubset == codebookSubset_fullyAndPartialAndNonCoherent) precond_nbr_layers_bits=5;
-
-        if (codebookSubset == codebookSubset_partialAndNonCoherent) precond_nbr_layers_bits=4;
-
-        if (codebookSubset == codebookSubset_nonCoherent) precond_nbr_layers_bits=2;
-      }
-    }
-
-    if (num_antenna_ports == 2) {
-      if ((transformPrecoder == transformPrecoder_disabled) && (maxRank == 2)) { // Table 7.3.1.1.2-4
-        if (codebookSubset == codebookSubset_fullyAndPartialAndNonCoherent) precond_nbr_layers_bits=4;
-
-        if (codebookSubset == codebookSubset_nonCoherent) precond_nbr_layers_bits=2;
-      }
-
-      if (((transformPrecoder == transformPrecoder_enabled)||(transformPrecoder == transformPrecoder_disabled)) && (maxRank == 1)) { // Table 7.3.1.1.2-5
-        if (codebookSubset == codebookSubset_fullyAndPartialAndNonCoherent) precond_nbr_layers_bits=3;
-
-        if (codebookSubset == codebookSubset_nonCoherent) precond_nbr_layers_bits=1;
-      }
-    }
-  }
-
-  if (txConfig == txConfig_nonCodebook) {
-  }
-
-  // searching number of bits at tables 7.3.1.1.2-6/7/8/9/10/11/12/13/14/15/16/17/18/19
-  if((dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)) {
-    if ((transformPrecoder == transformPrecoder_enabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len1)) antenna_ports_bits_ul = 2;
-
-    if ((transformPrecoder == transformPrecoder_enabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len2)) antenna_ports_bits_ul = 4;
-
-    if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len1)) antenna_ports_bits_ul = 3;
-
-    if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len2)) antenna_ports_bits_ul = 4;
-  }
-
-  if((dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type2)) {
-    if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len1)) antenna_ports_bits_ul = 4;
-
-    if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len2)) antenna_ports_bits_ul = 5;
-  }
-
-  // for format 1_1 number of bits as defined by Tables 7.3.1.2.2-1/2/3/4
-  uint8_t antenna_ports_bits_dl = 0;
-
-  if((dmrs_DownlinkConfig.pdsch_dmrs_type == pdsch_dmrs_type1) && (dmrs_DownlinkConfig.pdsch_maxLength == pdsch_len1)) antenna_ports_bits_dl = 4; // Table 7.3.1.2.2-1
-
-  if((dmrs_DownlinkConfig.pdsch_dmrs_type == pdsch_dmrs_type1) && (dmrs_DownlinkConfig.pdsch_maxLength == pdsch_len2)) antenna_ports_bits_dl = 5; // Table 7.3.1.2.2-2
-
-  if((dmrs_DownlinkConfig.pdsch_dmrs_type == pdsch_dmrs_type2) && (dmrs_DownlinkConfig.pdsch_maxLength == pdsch_len1)) antenna_ports_bits_dl = 5; // Table 7.3.1.2.2-3
-
-  if((dmrs_DownlinkConfig.pdsch_dmrs_type == pdsch_dmrs_type2) && (dmrs_DownlinkConfig.pdsch_maxLength == pdsch_len2)) antenna_ports_bits_dl = 6; // Table 7.3.1.2.2-4
-
-  // 39 TCI
-  uint8_t tci_bits=0;
-
-  if (pdcch_vars2->coreset[p].tciPresentInDCI == tciPresentInDCI_enabled) tci_bits=3;
-
-  // 42 CSI_REQUEST
-  // reportTriggerSize is defined in the CSI-MeasConfig IE (TS 38.331).
-  // Size of CSI request field in DCI (bits). Corresponds to L1 parameter 'ReportTriggerSize' (see 38.214, section 5.2)
-  uint8_t reportTriggerSize = csi_MeasConfig.reportTriggerSize; // value from 0..6
-  // 43 CBGTI
-  // for format 0_1
-  uint8_t maxCodeBlockGroupsPerTransportBlock = 0;
-
-  if (PUSCH_ServingCellConfig.maxCodeBlockGroupsPerTransportBlock != 0)
-    maxCodeBlockGroupsPerTransportBlock = (uint8_t)PUSCH_ServingCellConfig.maxCodeBlockGroupsPerTransportBlock;
-
-  // for format 1_1, as defined in Subclause 5.1.7 of [6, TS38.214]
-  uint8_t maxCodeBlockGroupsPerTransportBlock_dl = 0;
-
-  if (PDSCH_ServingCellConfig.maxCodeBlockGroupsPerTransportBlock_dl != 0)
-    maxCodeBlockGroupsPerTransportBlock_dl = pdsch_config.maxNrofCodeWordsScheduledByDCI; // FIXME!!!
-
-  // 44 CBGFI
-  uint8_t cbgfi_bit = PDSCH_ServingCellConfig.codeBlockGroupFlushIndicator;
-  // 45 PTRS_DMRS
-  // 0 bit if PTRS-UplinkConfig is not configured and transformPrecoder=disabled, or if transformPrecoder=enabled, or if maxRank=1
-  // 2 bits otherwise
-  uint8_t ptrs_dmrs_bits=0; //FIXME!!!
-  // 46 BETA_OFFSET_IND
-  // at IE PUSCH-Config, beta_offset indicator – 0 if the higher layer parameter betaOffsets = semiStatic; otherwise 2 bits
-  // uci-OnPUSCH
-  // Selection between and configuration of dynamic and semi-static beta-offset. If the field is absent or released, the UE applies the value 'semiStatic' and the BetaOffsets
-  uint8_t betaOffsets = 0;
-
-  if (pusch_config.uci_onPusch.betaOffset_type == betaOffset_semiStatic);
-
-  if (pusch_config.uci_onPusch.betaOffset_type == betaOffset_dynamic) betaOffsets = 2;
-
-  // 47 DMRS_SEQ_INI
-  uint8_t dmrs_seq_ini_bits_ul = 0;
-  uint8_t dmrs_seq_ini_bits_dl = 0;
-
-  //1 bit if both scramblingID0 and scramblingID1 are configured in DMRS-UplinkConfig
-  if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.scramblingID0 != 0) && (dmrs_UplinkConfig.scramblingID1 != 0)) dmrs_seq_ini_bits_ul = 1;
-
-  //1 bit if both scramblingID0 and scramblingID1 are configured in DMRS-DownlinkConfig
-  if ((dmrs_DownlinkConfig.scramblingID0 != 0) && (dmrs_DownlinkConfig.scramblingID0 != 0)) dmrs_seq_ini_bits_dl = 1;
-
-  /*
-   * For format 2_2
-   *
-   * This format supports power control commands for semi-persistent scheduling.
-   * As we can already support power control commands dynamically with formats 0_0/0_1 (TPC PUSCH) and 1_0/1_1 (TPC PUCCH)
-   *
-   * This format will be implemented in the future FIXME!!!
-   *
-   */
-  // 5  BLOCK_NUMBER: The parameter tpc-PUSCH or tpc-PUCCH provided by higher layers determines the index to the block number for an UL of a cell
-  // The following fields are defined for each block: Closed loop indicator and TPC command
-  // 6  CLOSE_LOOP_IND
-  // 41 TPC_CMD
-  uint8_t tpc_cmd_bit_2_2 = 2;
-  /*
-   * For format 2_3
-   *
-   * This format is used for power control of uplink sounding reference signals for devices which have not coupled SRS power control to the PUSCH power control
-   * either because independent control is desirable or because the device is configured without PUCCH and PUSCH
-   *
-   * This format will be implemented in the future FIXME!!!
-   *
-   */
-  // 40 SRS_REQUEST
-  // 41 TPC_CMD
-  uint8_t tpc_cmd_bit_2_3 = 0;
-  uint8_t dci_field_size_table [NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = { // This table contains the number of bits for each field (row) contained in each dci format (column).
-    // The values of the variables indicate field sizes in number of bits
-    //Format0_0                     Format0_1                      Format1_0                      Format1_1             Formats2_0/1/2/3
-    {
-      1,                             1,                             (((crc_scrambled == _p_rnti) || (crc_scrambled == _si_rnti) || (crc_scrambled == _ra_rnti)) ? 0:1),
-      1,                             0,0,0,0
-    }, // 0  IDENTIFIER_DCI_FORMATS:
-    {
-      0,                             ((crossCarrierSchedulingConfig_ind == 0) ? 0:3),
-      0,                             ((crossCarrierSchedulingConfig_ind == 0) ? 0:3),
-      0,0,0,0
-    }, // 1  CARRIER_IND: 0 or 3 bits, as defined in Subclause x.x of [5, TS38.213]
-    {0,                             (sul_ind == 0)?0:1,            0,                             0,                             0,0,0,0}, // 2  SUL_IND_0_1:
-    {0,                             0,                             0,                             0,                             1,0,0,0}, // 3  SLOT_FORMAT_IND: size of DCI format 2_0 is configurable by higher layers up to 128 bits, according to Subclause 11.1.1 of [5, TS 38.213]
-    {0,                             0,                             0,                             0,                             0,1,0,0}, // 4  PRE_EMPTION_IND: size of DCI format 2_1 is configurable by higher layers up to 126 bits, according to Subclause 11.2 of [5, TS 38.213]. Each pre-emption indication is 14 bits
-    {0,                             0,                             0,                             0,                             0,0,0,0}, // 5  BLOCK_NUMBER: starting position of a block is determined by the parameter startingBitOfFormat2_3
-    {0,                             0,                             0,                             0,                             0,0,1,0}, // 6  CLOSE_LOOP_IND
-    {
-      0,                             (uint8_t)ceil(log2(n_UL_BWP_RRC)),
-      0,                             (uint8_t)ceil(log2(n_DL_BWP_RRC)),
-      0,0,0,0
-    }, // 7  BANDWIDTH_PART_IND:
-    {
-      0,                             0,                             ((crc_scrambled == _p_rnti) ? 2:0),
-      0,                             0,0,0,0
-    }, // 8  SHORT_MESSAGE_IND 2 bits if crc scrambled with P-RNTI
-    {
-      0,                             0,                             ((crc_scrambled == _p_rnti) ? 8:0),
-      0,                             0,0,0,0
-    }, // 9  SHORT_MESSAGES 8 bit8 if crc scrambled with P-RNTI
-    {
-      (uint8_t)(ceil(log2(n_RB_ULBWP*(n_RB_ULBWP+1)/2)))-n_UL_hopping,
-      n_bits_freq_dom_res_assign_ul,
-      0,                             0,                             0,0,0,0
-    }, // 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered
-    //    (NOTE 1) If DCI format 0_0 is monitored in common search space
-    //    and if the number of information bits in the DCI format 0_0 prior to padding
-    //    is larger than the payload size of the DCI format 1_0 monitored in common search space
-    //    the bitwidth of the frequency domain resource allocation field in the DCI format 0_0
-    //    is reduced such that the size of DCI format 0_0 equals to the size of the DCI format 1_0
-    {
-      0,                             0,                             (uint8_t)ceil(log2(n_RB_DLBWP*(n_RB_DLBWP+1)/2)),
-      n_bits_freq_dom_res_assign_dl,
-      0,0,0,0
-    }, // 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
-    {
-      4,                             (uint8_t)log2(pusch_alloc_list),
-      4,                             (uint8_t)log2(pdsch_alloc_list),
-      0,0,0,0
-    }, // 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
-    //    where I the number of entries in the higher layer parameter pusch-AllocationList
-    {
-      0,                             0,                             1,                             (((dl_res_alloc_type_0==1) &&(dl_res_alloc_type_1==0))?0:1),
-      0,0,0,0
-    }, // 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
-    {0,                             0,                             0,                             prb_BundlingType_size,         0,0,0,0}, // 14 PRB_BUNDLING_SIZE_IND:0 bit if the higher layer parameter PRB_bundling is not configured or is set to 'static', or 1 bit if the higher layer parameter PRB_bundling is set to 'dynamic' according to Subclause 5.1.2.3 of [6, TS 38.214]
-    {0,                             0,                             0,                             rateMatching_bits,             0,0,0,0}, // 15 RATE_MATCHING_IND: 0, 1, or 2 bits according to higher layer parameter rate-match-PDSCH-resource-set
-    {0,                             0,                             0,                             n_zp_bits,                     0,0,0,0}, // 16 ZP_CSI_RS_TRIGGER:
-    {
-      1,                             (((ul_res_alloc_type_0==1) &&(ul_res_alloc_type_1==0))||(freqHopping == 0))?0:1,
-      0,                             0,                             0,0,0,0
-    }, // 17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0
-    {0,                             0,                             0,                             5,                             0,0,0,0}, // 18 TB1_MCS:
-    {0,                             0,                             0,                             1,                             0,0,0,0}, // 19 TB1_NDI:
-    {0,                             0,                             0,                             2,                             0,0,0,0}, // 20 TB1_RV:
-    {0,                             0,                             0,                             5,                             0,0,0,0}, // 21 TB2_MCS:
-    {0,                             0,                             0,                             1,                             0,0,0,0}, // 22 TB2_NDI:
-    {0,                             0,                             0,                             2,                             0,0,0,0}, // 23 TB2_RV:
-    {5,                             5,                             5,                             0,                             0,0,0,0}, // 24 MCS:
-    {1,                             1,                             (crc_scrambled == _c_rnti)?1:0,0,                             0,0,0,0}, // 25 NDI:
-    {
-      2,                             2,                             (((crc_scrambled == _c_rnti) || (crc_scrambled == _si_rnti)) ? 2:0),
-      0,                             0,0,0,0
-    }, // 26 RV:
-    {4,                             4,                             (crc_scrambled == _c_rnti)?4:0,4,                             0,0,0,0}, // 27 HARQ_PROCESS_NUMBER:
-    {0,                             0,                             (crc_scrambled == _c_rnti)?2:0,n_dai,                         0,0,0,0}, // 28 DAI: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
-    //    2 if one serving cell is configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 bits are the counter DAI
-    //    0 otherwise
-    {0,                             codebook_HARQ_ACK,             0,                             0,                             0,0,0,0}, // 29 FIRST_DAI: (1 or 2 bits) 1 bit for semi-static HARQ-ACK // 2 bits for dynamic HARQ-ACK codebook with single HARQ-ACK codebook
-    {
-      0,                             (((codebook_HARQ_ACK == 2) &&(n_HARQ_ACK_sub_codebooks==2))?2:0),
-      0,                             0,                             0,0,0,0
-    }, // 30 SECOND_DAI: (0 or 2 bits) 2 bits for dynamic HARQ-ACK codebook with two HARQ-ACK sub-codebooks // 0 bits otherwise
-    {
-      0,                             0,                             (((crc_scrambled == _p_rnti) || (crc_scrambled == _ra_rnti)) ? 2:0),
-      0,                             0,0,0,0
-    }, // 31 TB_SCALING
-    {2,                             2,                             0,                             0,                             0,0,0,0}, // 32 TPC_PUSCH:
-    {0,                             0,                             (crc_scrambled == _c_rnti)?2:0,2,                             0,0,0,0}, // 33 TPC_PUCCH:
-    {0,                             0,                             (crc_scrambled == _c_rnti)?3:0,3,                             0,0,0,0}, // 34 PUCCH_RESOURCE_IND:
-    {0,                             0,                             (crc_scrambled == _c_rnti)?3:0,pdsch_harq_t_ind,              0,0,0,0}, // 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND:
-    {0,                             (uint8_t)log2(n_SRS),          0,                             0,                             0,0,0,0}, // 36 SRS_RESOURCE_IND:
-    {0,                             precond_nbr_layers_bits,       0,                             0,                             0,0,0,0}, // 37 PRECOD_NBR_LAYERS:
-    {0,                             antenna_ports_bits_ul,         0,                             antenna_ports_bits_dl,         0,0,0,0}, // 38 ANTENNA_PORTS:
-    {0,                             0,                             0,                             tci_bits,                      0,0,0,0}, // 39 TCI: 0 bit if higher layer parameter tci-PresentInDCI is not enabled; otherwise 3 bits
-    {0,                             (sul_ind == 0)?2:3,            0,                             (sul_ind == 0)?2:3,            0,0,0,2}, // 40 SRS_REQUEST:
-    {
-      0,                             0,                             0,                             0,                             0,0,tpc_cmd_bit_2_2,
-      tpc_cmd_bit_2_3
-    },
-    // 41 TPC_CMD:
-    {0,                             reportTriggerSize,             0,                             0,                             0,0,0,0}, // 42 CSI_REQUEST:
-    {
-      0,                             maxCodeBlockGroupsPerTransportBlock,
-      0,                             maxCodeBlockGroupsPerTransportBlock_dl,
-      0,0,0,0
-    }, // 43 CBGTI: 0, 2, 4, 6, or 8 bits determined by higher layer parameter maxCodeBlockGroupsPerTransportBlock for the PDSCH
-    {0,                             0,                             0,                             cbgfi_bit,                     0,0,0,0}, // 44 CBGFI: 0 or 1 bit determined by higher layer parameter codeBlockGroupFlushIndicator
-    {0,                             ptrs_dmrs_bits,                0,                             0,                             0,0,0,0}, // 45 PTRS_DMRS:
-    {0,                             betaOffsets,                   0,                             0,                             0,0,0,0}, // 46 BETA_OFFSET_IND:
-    {0,                             dmrs_seq_ini_bits_ul,          0,                             dmrs_seq_ini_bits_dl,          0,0,0,0}, // 47 DMRS_SEQ_INI: 1 bit if the cell has two ULs and the number of bits for DCI format 1_0 before padding
-    //    is larger than the number of bits for DCI format 0_0 before padding; 0 bit otherwise
-    {0,                             1,                             0,                             0,                             0,0,0,0}, // 48 UL_SCH_IND: value of "1" indicates UL-SCH shall be transmitted on the PUSCH and a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH
-    {0,                             0,                             0,                             0,                             0,0,0,0}, // 49 PADDING_NR_DCI:
-    //    (NOTE 2) If DCI format 0_0 is monitored in common search space
-    //    and if the number of information bits in the DCI format 0_0 prior to padding
-    //    is less than the payload size of the DCI format 1_0 monitored in common search space
-    //    zeros shall be appended to the DCI format 0_0
-    //    until the payload size equals that of the DCI format 1_0
-    {(sul_ind == 0)?0:1,            0,                             0,                             0,                             0,0,0,0}, // 50 SUL_IND_0_0:
-    {0,                             0,                             0,                             0,                             0,0,0,0}, // 51 RA_PREAMBLE_INDEX (random access procedure initiated by a PDCCH order not implemented, FIXME!!!)
-    {0,                             0,                             0,                             0,                             0,0,0,0}, // 52 SUL_IND_1_0 (random access procedure initiated by a PDCCH order not implemented, FIXME!!!)
-    {0,                             0,                             0,                             0,                             0,0,0,0}, // 53 SS_PBCH_INDEX (random access procedure initiated by a PDCCH order not implemented, FIXME!!!)
-    {0,                             0,                             0,                             0,                             0,0,0,0}, // 54 PRACH_MASK_INDEX (random access procedure initiated by a PDCCH order not implemented, FIXME!!!)
-    {
-      0,                             0,                             ((crc_scrambled == _p_rnti)?6:(((crc_scrambled == _si_rnti) || (crc_scrambled == _ra_rnti))?16:0)),
-      0,                             0,0,0,0
-    }  // 55 RESERVED_NR_DCI
-  };
-  // NOTE 1: adjustments in freq_dom_resource_assignment_UL to be done if necessary
-  // NOTE 2: adjustments in padding to be done if necessary
-  uint8_t dci_size [8] = {0,0,0,0,0,0,0,0}; // will contain size for each format
-
-  for (int i=0 ; i<NBR_NR_FORMATS ; i++) {
-    //#ifdef NR_PDCCH_DCI_DEBUG
-    //  LOG_DDD("i=%d, j=%d\n", i, j);
-    //#endif
-    for (int j=0; j<NBR_NR_DCI_FIELDS; j++) {
-      dci_size [i] = dci_size [i] + dci_field_size_table[j][i]; // dci_size[i] contains the size in bits of the dci pdu format i
-      //if (i==(int)format-15) {                                  // (int)format-15 indicates the position of each format in the table (e.g. format1_0=17 -> position in table is 2)
-      dci_fields_sizes[j][i] = dci_field_size_table[j][i];       // dci_fields_sizes[j] contains the sizes of each field (j) for a determined format i
-      //}
-    }
-
-    LOG_DDD("(nr_dci_format_size) dci_size[%d]=%d for n_RB_ULBWP=%d\n",
-           i,dci_size[i],n_RB_ULBWP);
-  }
-
-  LOG_DDD("(nr_dci_format_size) dci_fields_sizes[][] = { \n");
-
-#ifdef NR_PDCCH_DCI_DEBUG
-  for (int j=0; j<NBR_NR_DCI_FIELDS; j++) {
-    printf("\t\t");
-
-    for (int i=0; i<NBR_NR_FORMATS ; i++) printf("%d\t",dci_fields_sizes[j][i]);
-
-    printf("\n");
-  }
-
-  printf(" }\n");
 #endif
-  LOG_DNL("(nr_dci_format_size) dci_size[0_0]=%d, dci_size[0_1]=%d, dci_size[1_0]=%d, dci_size[1_1]=%d,\n",dci_size[0],dci_size[1],dci_size[2],dci_size[3]);
-
-  //UL/SUL indicator format0_0 (TS 38.212 subclause 7.3.1.1.1)
-  // - 1 bit if the cell has two ULs and the number of bits for DCI format 1_0 before padding is larger than the number of bits for DCI format 0_0 before padding;
-  // - 0 bit otherwise.
-  // The UL/SUL indicator, if present, locates in the last bit position of DCI format 0_0, after the padding bit(s)
-  if ((dci_field_size_table[SUL_IND_0_0][0] == 1) && (dci_size[0] > dci_size[2])) {
-    dci_field_size_table[SUL_IND_0_0][0] = 0;
-    dci_size[0]=dci_size[0]-1;
-  }
 
-  //  if ((format == format0_0) || (format == format1_0)) {
-  // According to Section 7.3.1.1.1 in TS 38.212
-  // If DCI format 0_0 is monitored in common search space and if the number of information bits in the DCI format 0_0 prior to padding
-  // is less than the payload size of the DCI format 1_0 monitored in common search space for scheduling the same serving cell,
-  // zeros shall be appended to the DCI format 0_0 until the payload size equals that of the DCI format 1_0.
-  if (dci_size[0] < dci_size[2]) { // '0' corresponding to index for format0_0 and '2' corresponding to index of format1_0
-    //if (format == format0_0) {
-    dci_fields_sizes[PADDING_NR_DCI][0] = dci_size[2] - dci_size[0];
-    dci_size[0] = dci_size[2];
-    LOG_DDD("(nr_dci_format_size) new dci_size[format0_0]=%d\n",dci_size[0]);
-    //}
-  }
 
-  // If DCI format 0_0 is monitored in common search space and if the number of information bits in the DCI format 0_0 prior to padding
-  // is larger than the payload size of the DCI format 1_0 monitored in common search space for scheduling the same serving cell,
-  // the bitwidth of the frequency domain resource allocation field in the DCI format 0_0 is reduced
-  // such that the size of DCI format 0_0 equals to the size of the DCI format 1_0..
-  if (dci_size[0] > dci_size[2]) {
-    //if (format == format0_0) {
-    dci_fields_sizes[FREQ_DOM_RESOURCE_ASSIGNMENT_UL][0] -= (dci_size[0] - dci_size[2]);
-    dci_size[0] = dci_size[2];
-    LOG_DDD("(nr_dci_format_size) new dci_size[format0_0]=%d\n",dci_size[0]);
-    //}
-  }
 
-  /*
-   * TS 38.212 subclause 7.3.1.1.2
-   * For a UE configured with SUL in a cell:
-   * if PUSCH is configured to be transmitted on both the SUL and the non-SUL of the cell and
-   *              if the number of information bits in format 0_1 for the SUL
-   * is not equal to the number of information bits in format 0_1 for the non-SUL,
-   * zeros shall be appended to smaller format 0_1 until the payload size equals that of the larger format 0_1
-   *
-   * Not implemented. FIXME!!!
-   *
-   */
-  //  }
-  LOG_DDD("(nr_dci_format_size) dci_fields_sizes[][] = { \n");
 
-#ifdef NR_PDCCH_DCI_DEBUG
-  for (int j=0; j<NBR_NR_DCI_FIELDS; j++) {
-    printf("\t\t");
 
-    for (int i=0; i<NBR_NR_FORMATS ; i++) printf("%d\t",dci_fields_sizes[j][i]);
 
-    printf("\n");
-  }
 
-  printf(" }\n");
-#endif
-  return dci_size[format];
-}
 
-#endif
+#if 0
 
-#ifdef NR_PDCCH_DCI_RUN
 
 uint8_t nr_dci_decoding_procedure(int s,
                                   int p,
@@ -2851,6 +1721,3 @@ uint8_t nr_dci_decoding_procedure(int s,
 }
 
 #endif
-
-
-
diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c
index df79abefcde..347c9c2ab90 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c
@@ -53,924 +53,11 @@
 //#define DEBUG_DCI
 #define NR_PDCCH_DCI_TOOLS
 //#define NR_PDCCH_DCI_TOOLS_DEBUG
-#ifdef NR_PDCCH_DCI_TOOLS_DEBUG
-#define LOG_DCI_D(a...) printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) ->" a)
-#else 
-#define LOG_DCI_D(a...)
-#endif
-#define LOG_DCI_PARM(a...) LOG_D(PHY,"\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci)" a)
-
-typedef unsigned __int128 uint128_t;
-
-int8_t nr_delta_PUSCH_abs[4] = {-4,-1,1,4};
-int8_t nr_delta_PUSCH_acc[4] = {-1,0,1,3};
-int8_t *nr_delta_PUCCH_lut = nr_delta_PUSCH_acc;
-
-
-
-#ifdef NR_PDCCH_DCI_TOOLS
-
-uint16_t nr_dci_field(uint64_t dci_pdu[2],
-                      uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS],
-                      uint8_t dci_field) {
-  int dci_size=0;
-
-  for (int i=0; i<NBR_NR_DCI_FIELDS; i++) dci_size+=dci_fields_sizes[i];
-
-  AssertFatal(dci_size<65,"DCI has %d > 64 bits, not supported for now\n",
-              dci_size);
-  uint16_t first_bit_position = dci_size;
-
-  for (int i=0; i<=dci_field ; i++) {
-    first_bit_position = first_bit_position - dci_fields_sizes[i];
-  }
-
-  /*uint16_t tmp1 = ((*dci_pdu>>first_bit_position)&((1<<dci_fields_sizes[dci_field])-1));
-  uint16_t tmp2 = 0;
-  for (int i=0; i<dci_fields_sizes[dci_field]; i++)
-    tmp2 |= ((tmp1>>i)&1)<<(dci_fields_sizes[dci_field]-i-1);*/
-  return ((uint16_t)(*dci_pdu>>first_bit_position)&((1<<dci_fields_sizes[dci_field])-1));
-}
-
-int nr_extract_dci_info(PHY_VARS_NR_UE *ue,
-                        uint8_t eNB_id,
-                        lte_frame_type_t frame_type,
-                        uint8_t dci_length,
-                        uint16_t rnti,
-                        uint64_t dci_pdu[2],
-                        fapi_nr_dci_pdu_rel15_t *nr_pdci_info_extracted,
-                        uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS],
-                        NR_DCI_format_t dci_format,
-                        uint8_t nr_tti_rx,
-                        uint16_t n_RB_ULBWP,
-                        uint16_t n_RB_DLBWP,
-                        uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES]) {
-  /*
-   * This function will extract the different elements of the dci pdu and interpret the values extracted to update correctly the parameters in:
-   *                                                NR_DL_UE_HARQ_t *pdlsch0_harq,
-   *                                                NR_UE_DLSCH_t *pdlsch0,
-   *
-   * We need to know the dci length and the dci_fields_sizes (array containing each field size in number of bits)
-   * In order to get the value of a specific field we will proceed as follows (let's have a look to an example:
-   * If the length of the pdu is 38 bits and the content of the dci_pdu is 0x3A8900789A (pdu is 11 1010 1000 1001 0000 0000 0111 1000 1001 1010)
-   * If the dci_fields_sizes is {0 0 1 0 0 0 0 0 0 13 0 1 0 0 0 0 0 0 0 0 0 0 5 1 2 4 2 0 0 0 2 3 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...}
-   * This means:
-   *             number bits for carrier_ind field is 0
-   *             number bits for sul_ind_0_1 field is 0
-   *             number bits for identifier_dci_formats field is 0
-   *             number bits for slot_format_ind field is 0
-   *             number bits for pre_emption_ind field is 0
-   *             ...
-   *             number bits for freq_dom_resource_assignment_DL field is 13
-   *             ...
-   *             number bits for padding is 0
-   * In order to extract the information of (e.g.) freq_dom_resource_assignment_DL field,
-   * we will do a left-shift of 1 position (because previous to this field, and according to the dci_fields_sizes array, there is only one non-empty field of size 1 bit) -> (1 1010 1000 1001 0000 0000 0111 1000 1001 1010 0)
-   * then we will do a right-shit of dci_length-13 positions -> (1 1010 1000 1001). And this is the content of the freq_dom_resource_assignment_DL field
-   *
-   *
-   * At the moment we have implemented the following formats:
-   *
-   * Format 0_0, that contains the following fields according to Specification 38.212 V15.1.1 Section 7.3.1
-   *  with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI
-   *    0  IDENTIFIER_DCI_FORMATS:
-   *    10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered
-   *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
-   *    17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0
-   *    24 MCS:
-   *    25 NDI:
-   *    26 RV:
-   *    27 HARQ_PROCESS_NUMBER:
-   *    32 TPC_PUSCH:
-   *    49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space
-   *    50 SUL_IND_0_0:
-   *
-   * Format 0_1, that contains the following fields
-   *  with CRC scrambled by C-RNTI or CS-RNTI or SP-CSI-RNTI or new-RNTI
-   *    0  IDENTIFIER_DCI_FORMATS:
-   *    1  CARRIER_IND
-   *    2  SUL_IND_0_1
-   *    7  BANDWIDTH_PART_IND
-   *    10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered
-   *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
-   *    17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0
-   *    24 MCS:
-   *    25 NDI:
-   *    26 RV:
-   *    27 HARQ_PROCESS_NUMBER:
-   *    29 FIRST_DAI
-   *    30 SECOND_DAI
-   *    32 TPC_PUSCH:
-   *    36 SRS_RESOURCE_IND:
-   *    37 PRECOD_NBR_LAYERS:
-   *    38 ANTENNA_PORTS:
-   *    40 SRS_REQUEST:
-   *    42 CSI_REQUEST:
-   *    43 CBGTI
-   *    45 PTRS_DMRS
-   *    46 BETA_OFFSET_IND
-   *    47 DMRS_SEQ_INI
-   *    48 UL_SCH_IND
-   *    49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space
-   *
-   * Format 1_0, that contains the following fields
-   *  with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI
-   *    0  IDENTIFIER_DCI_FORMATS:
-   *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
-   *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
-   *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
-   *    24 MCS:
-   *    25 NDI:
-   *    26 RV:
-   *    27 HARQ_PROCESS_NUMBER:
-   *    28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
-   *    33 TPC_PUCCH:
-   *    34 PUCCH_RESOURCE_IND:
-   *    35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND:
-   *    55 RESERVED_NR_DCI
-   *
-   *    If the CRC of the DCI format 1_0 is scrambled by C-RNTI and the "Frequency domain resource assignment" field are of all ones,
-   *    the DCI format 1_0 is for random access procedure initiated by a PDCCH order.
-   *    This is not implemented, but the fields are already included: FIXME!!!
-   *
-   *  with CRC scrambled by P-RNTI
-   *    8  SHORT_MESSAGE_IND
-   *    9  SHORT_MESSAGES
-   *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
-   *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
-   *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
-   *    24 MCS:
-   *    31 TB_SCALING
-   *    55 RESERVED_NR_DCI
-   *
-   *  with CRC scrambled by SI-RNTI
-   *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
-   *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
-   *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
-   *    24 MCS:
-   *    26 RV:
-   *    55 RESERVED_NR_DCI
-   *
-   *  with CRC scrambled by RA-RNTI
-   *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
-   *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
-   *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
-   *    24 MCS:
-   *    31 TB_SCALING
-   *    55 RESERVED_NR_DCI
-   *
-   *  with CRC scrambled by TC-RNTI
-   *    0  IDENTIFIER_DCI_FORMATS:
-   *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
-   *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
-   *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
-   *    24 MCS:
-   *    25 NDI:
-   *    26 RV:
-   *    27 HARQ_PROCESS_NUMBER:
-   *    28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
-   *    33 TPC_PUCCH:
-   *
-   * Format 1_1, that contains the following fields
-   *  with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI
-   *    0  IDENTIFIER_DCI_FORMATS:
-   *    1  CARRIER_IND:
-   *    7  BANDWIDTH_PART_IND:
-   *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
-   *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
-   *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
-   *    14 PRB_BUNDLING_SIZE_IND:
-   *    15 RATE_MATCHING_IND:
-   *    16 ZP_CSI_RS_TRIGGER:
-   *    18 TB1_MCS:
-   *    19 TB1_NDI:
-   *    20 TB1_RV:
-   *    21 TB2_MCS:
-   *    22 TB2_NDI:
-   *    23 TB2_RV:
-   *    27 HARQ_PROCESS_NUMBER:
-   *    28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
-   *    33 TPC_PUCCH:
-   *    34 PUCCH_RESOURCE_IND:
-   *    35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND:
-   *    38 ANTENNA_PORTS:
-   *    39 TCI:
-   *    40 SRS_REQUEST:
-   *    43 CBGTI:
-   *    44 CBGFI:
-   *    47 DMRS_SEQ_INI:
-   *
-   * We have not implemented the following formats:
-   *
-   * Format 2_0
-   * Used for notifying the slot format
-   *
-   * Format 2_1
-   * Used for notifying the PRB(s) and OFDM symbol(s) where UE may assume no transmission is intended for the UE
-   *
-   * Format 2_2
-   * This format supports power control commands for semi-persistent scheduling.
-   * As we can already support power control commands dynamically with formats 0_0/0_1 (TPC PUSCH) and 1_0/1_1 (TPC PUCCH)
-   * This format will be implemented in the future FIXME!!!
-   *
-   * Format 2_3
-   * This format is used for power control of uplink sounding reference signals for devices which have not coupled SRS power control to the PUSCH power control
-   * either because independent control is desirable or because the device is configured without PUCCH and PUSCH
-   * This format will be implemented in the future FIXME!!!
-   *
-   */
-  uint8_t dci_fields_sizes_format[NBR_NR_DCI_FIELDS] = {0};
-
-  for (int m=0; m<NBR_NR_DCI_FIELDS; m++) dci_fields_sizes_format[m]=dci_fields_sizes[m][dci_format];
-
-  //  uint64_t pdu_bitmap = 0xFFFFFFFFFFFFFFFF;
-  //  uint128_t pdu_bitmap = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
-  //#define DCI_MAX_SIZE 128
-  //  pdu_bitmap = (pdu_bitmap << (DCI_MAX_SIZE - dci_length)) >> (DCI_MAX_SIZE - dci_length); // this variable will help to remove the bits of other fields when left-switching
-  uint8_t dci_field=0;
-  //  uint8_t sizes_count=0;
-  //  uint8_t left_shift=0;
-  LOG_DCI_D("Entering function nr_extract_dci_info() with dci_pdu=%lx %lx dci_length=%d\n",
-            dci_pdu[0],dci_pdu[1], dci_length);
-  LOG_DCI_D("for format %d, dci_fields_sizes {",dci_format);
-#ifdef NR_PDCCH_DCI_TOOLS_DEBUG
-
-  for (int i=0; i<NBR_NR_DCI_FIELDS; i++) printf("%d ",dci_fields_sizes[i][dci_format]);
-
-  printf("}\n");
-#endif
-
-  //  uint8_t  prev_ndi = pdlsch0_harq->DCINdi;
-
-  /*
-   * Some dci fields need to be interpreted before the others.
-   */
-  if (dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format] != 0) { // E.g: 27 HARQ_PROCESS_NUMBER (27 is the position in dci_fields_sizes array for field HARQ_PROCESS_NUMBER)
-    //for (int i=0; i<=HARQ_PROCESS_NUMBER; i++) left_shift = left_shift + dci_fields_sizes[i][dci_format];
-    nr_pdci_info_extracted->harq_process_number = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,HARQ_PROCESS_NUMBER);
-    //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[HARQ_PROCESS_NUMBER][dci_format]));
-    //left_shift = 0;
-    LOG_DCI_D("nr_pdci_info_extracted->harq_process_number=%x\n",nr_pdci_info_extracted->harq_process_number);
-  }
-
-  /*
-    if ((dci_format == format1_0) || (dci_format == format1_1)) {
-      if (rnti==crc_scrambled_values[_SI_RNTI_]) {
-        ue->dlsch_SI[eNB_id]->active = 1;
-      } else if (rnti==crc_scrambled_values[_P_RNTI_]) {
-        ue->dlsch_p[eNB_id]->active  = 1;
-      } else if (rnti==crc_scrambled_values[_RA_RNTI_]) {
-        ue->dlsch_ra[eNB_id]->active = 1;
-      } else {
-        pdlsch0->active          = 1;
-      }
-      pdlsch0->rnti              = rnti;
-      pdlsch0_harq->codeword     = 0;
-      pdlsch0_harq->Nl           = 1;
-  //  pdlsch0_harq->mimo_mode    = frame_parms->mode1_flag == 1 ?SISO : ALAMOUTI;
-      pdlsch0_harq->dl_power_off = 1; //no power offset
-
-      if ((rnti==crc_scrambled_values[_SI_RNTI_]) || (rnti==crc_scrambled_values[_P_RNTI_]) || (rnti==crc_scrambled_values[_RA_RNTI_])) {
-        pdlsch0_harq->round    = 0;
-        pdlsch0_harq->status   = ACTIVE;
-      } else {
-      }
-    }
-  */
-  for (dci_field=0; dci_field<NBR_NR_DCI_FIELDS; dci_field++) {
-    //left_shift = left_shift + dci_fields_sizes[dci_field][dci_format];
-    if (dci_fields_sizes[dci_field][dci_format] != 0) {
-      //sizes_count = dci_fields_sizes[dci_field][dci_format];
-      LOG_DCI_D("dci_fields_sizes[%d][%d] = %d\n",dci_field,dci_format,dci_fields_sizes[dci_field][dci_format]);
 
-      switch (dci_field) {
-        case IDENTIFIER_DCI_FORMATS: // 0  IDENTIFIER_DCI_FORMATS: (field defined for format0_0,format0_1,format1_0,format1_1,format2_0,format2_1,format2_2,format2_3)
-          // if format 0_0: The value of this bit field is always set to 0, indicating an UL DCI format (TS38.212 Section 7.3.1.1.1)
-          // if format 1_0: The value of this bit field is always set to 1, indicating a  DL DCI format (TS38.212 Section 7.3.1.2.1)
-          nr_pdci_info_extracted->identifier_dci_formats           = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->identifier_dci_formats=%x\n",nr_pdci_info_extracted->identifier_dci_formats);
-          break;
 
-        case CARRIER_IND: // 1  CARRIER_IND: (field defined for -,format0_1,-,format1_1,-,-,-,-)
-          // 0 or 3 bits, as defined in Subclause x.x of [5, TS38.213]
-          nr_pdci_info_extracted->carrier_ind                      = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->carrier_ind=%x\n",nr_pdci_info_extracted->carrier_ind);
-          break;
-
-        case SUL_IND_0_1: // 2  SUL_IND_0_1: (field defined for -,format0_1,-,-,-,-,-,-)
-          nr_pdci_info_extracted->sul_ind_0_1                      = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->sul_ind_0_1=%x\n",nr_pdci_info_extracted->sul_ind_0_1);
-          break;
-
-        case SLOT_FORMAT_IND: // 3  SLOT_FORMAT_IND: (field defined for -,-,-,-,format2_0,-,-,-)
-          // size of DCI format 2_0 is configurable by higher layers up to 128 bits, according to Subclause 11.1.1 of [5, TS 38.213]
-          nr_pdci_info_extracted->slot_format_ind                  = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->slot_format_ind=%x\n",nr_pdci_info_extracted->slot_format_ind);
-          break;
-
-        case PRE_EMPTION_IND: // 4  PRE_EMPTION_IND: (field defined for -,-,-,-,-,format2_1,-,-)
-          // size of DCI format 2_1 is configurable by higher layers up to 126 bits, according to Subclause 11.2 of [5, TS 38.213]. Each pre-emption indication is 14 bits
-          nr_pdci_info_extracted->pre_emption_ind                  = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->pre_emption_ind=%x\n",nr_pdci_info_extracted->pre_emption_ind);
-          break;
-
-        case BLOCK_NUMBER: // 5  BLOCK_NUMBER: (field defined for -,-,-,-,-,-,-,format2_3)
-          // starting position of a block is determined by the parameter startingBitOfFormat2_3
-          nr_pdci_info_extracted->block_number                     = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->block_number=%x\n",nr_pdci_info_extracted->block_number);
-          break;
-
-        case CLOSE_LOOP_IND: // 6  CLOSE_LOOP_IND: (field defined for -,-,-,-,-,-,format2_2,-)
-          // The parameter xxx provided by higher layers determines the index to the TPC command number for an UL of a cell. Each TPC command number is 2 bits
-          nr_pdci_info_extracted->close_loop_ind                   = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->close_loop_ind=%x\n",nr_pdci_info_extracted->close_loop_ind);
-          break;
-
-        case BANDWIDTH_PART_IND: // 7  BANDWIDTH_PART_IND: (field defined for -,format0_1,-,format1_1,-,-,-,-)
-          nr_pdci_info_extracted->bandwidth_part_ind               = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->bandwidth_part_ind=%x\n",nr_pdci_info_extracted->bandwidth_part_ind);
-          break;
-
-        case SHORT_MESSAGE_IND: // 8  SHORT_MESSAGE_IND: (field defined for -,-,format1_0,format1_1,-,-,-,-)
-          nr_pdci_info_extracted->short_message_ind                = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->short_message_ind=%x\n",nr_pdci_info_extracted->short_message_ind);
-          break;
-
-        case SHORT_MESSAGES: // 9  SHORT_MESSAGES: (field defined for -,-,format1_0,format1_1,-,-,-,-)
-          nr_pdci_info_extracted->short_messages                   = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->short_messages=%x\n",nr_pdci_info_extracted->short_messages);
-          break;
-
-        case FREQ_DOM_RESOURCE_ASSIGNMENT_UL: // 10  FREQ_DOM_RESOURCE_ASSIGNMENT_UL: (field defined for format0_0,format0_1,-,-,-,-,-,-)
-          // PUSCH hopping with resource allocation type 1 not considered
-          // According to 38.214 V15.1.0 Section 6.1.2.2 Two uplink resource allocation schemes, type 0 and type 1, are supported.
-          // The UE shall assume that when the scheduling PDCCH is received with DCI format 0_0, then uplink resource allocation type 1 is used.
-          nr_pdci_info_extracted->freq_dom_resource_assignment_UL  = (uint16_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          /*if (dci_format == format0_1){ // uplink resource allocation type 0 or 1 can be used
-          }
-          if (dci_format == format0_0){ // only uplink resource allocation type 1
-                // At the moment we are supporting only format 1_0 (and not format 1_1), so we only support resource allocation type 1 (and not type 0).
-                // For resource allocation type 1, the resource allocation field consists of a resource indication value (RIV):
-                // RIV = n_RB_ULBWP * (l_RB - 1) + start_RB                                  if (l_RB - 1) <= floor (n_RB_ULBWP/2)
-                // RIV = n_RB_ULBWP * (n_RB_ULBWP - l_RB + 1) + (n_RB_ULBWP - 1 - start_RB)  if (l_RB - 1)  > floor (n_RB_ULBWP/2)
-            // the following two expressions apply only if (l_RB - 1) <= floor (n_RB_ULBWP/2)
-            l_RB = floor(nr_pdci_info_extracted->freq_dom_resource_assignment_DL/n_RB_ULBWP) + 1;
-            start_RB = nr_pdci_info_extracted->freq_dom_resource_assignment_DL%n_RB_ULBWP;
-            // if (l_RB - 1)  > floor (n_RB_ULBWP/2) we need to recalculate them using the following lines
-            tmp_RIV = n_RB_ULBWP * (l_RB - 1) + start_RB;
-            if (tmp_RIV != nr_pdci_info_extracted->freq_dom_resource_assignment_DL) { // then (l_RB - 1)  > floor (n_RB_ULBWP/2) and we need to recalculate l_RB and start_RB
-              l_RB = n_RB_ULBWP - l_RB + 2;
-              start_RB = n_RB_ULBWP - start_RB - 1;
-            }
-            ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->first_rb = start_RB;
-            ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->nb_rb    = l_RB;
-          }*/
-          LOG_DCI_D("nr_pdci_info_extracted->freq_dom_resource_assignment_UL=%x\n",nr_pdci_info_extracted->freq_dom_resource_assignment_UL);
-          //LOG_DCI_D("l_RB=%d, start_RB=%d, n_RB_DLBWP=%d\n",l_RB,start_RB,n_RB_ULBWP);
-          break;
-
-        case FREQ_DOM_RESOURCE_ASSIGNMENT_DL: // 11  FREQ_DOM_RESOURCE_ASSIGNMENT_DL: (field defined for -,-,format1_0,format1_1,-,-,-,-)
-          // According to 38.214 V15.1.0 Section 5.1.2.2 Two downlink resource allocation schemes, type 0 and type 1, are supported.
-          // The UE shall assume that when the scheduling grant is received with DCI format 1_0, then downlink resource allocation type 1 is used.
-          nr_pdci_info_extracted->freq_dom_resource_assignment_DL  = (uint16_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          /*if (dci_format == format1_1){ // uplink resource allocation type 0 or 1 can be used
-          }
-          if (dci_format == format1_0){ // only uplink resource allocation type 1
-                // At the moment we are supporting only format 0_0 (and not format 0_1), so we only support resource allocation type 1 (and not type 0).
-                // For resource allocation type 1, the resource allocation field consists of a resource indication value (RIV):
-                // RIV = n_RB_DLBWP * (l_RB - 1) + start_RB                                  if (l_RB - 1) <= floor (n_RB_DLBWP/2)
-                // RIV = n_RB_DLBWP * (n_RB_DLBWP - l_RB + 1) + (n_RB_DLBWP - 1 - start_RB)  if (l_RB - 1)  > floor (n_RB_DLBWP/2)
-            // the following two expressions apply only if (l_RB - 1) <= floor (n_RB_DLBWP/2)
-            l_RB = floor(nr_pdci_info_extracted->freq_dom_resource_assignment_DL/n_RB_DLBWP) + 1;
-            start_RB = nr_pdci_info_extracted->freq_dom_resource_assignment_DL%n_RB_DLBWP;
-            // if (l_RB - 1)  > floor (n_RB_DLBWP/2) we need to recalculate them using the following lines
-            tmp_RIV = n_RB_DLBWP * (l_RB - 1) + start_RB;
-            if (tmp_RIV != nr_pdci_info_extracted->freq_dom_resource_assignment_DL) { // then (l_RB - 1)  > floor (n_RB_DLBWP/2) and we need to recalculate l_RB and start_RB
-              l_RB = n_RB_DLBWP - l_RB + 2;
-              start_RB = n_RB_DLBWP - start_RB - 1;
-            }
-            pdlsch0_harq->nb_rb = l_RB;
-            pdlsch0->current_harq_pid = nr_pdci_info_extracted->harq_process_number;
-            pdlsch0->active           = 1;
-            pdlsch0->rnti             = rnti;
-          }*/
-          LOG_DCI_D("nr_pdci_info_extracted->freq_dom_resource_assignment_DL=%x, RIV = %d\n",nr_pdci_info_extracted->freq_dom_resource_assignment_DL,nr_pdci_info_extracted->freq_dom_resource_assignment_DL);
-          //LOG_DCI_D("l_RB=%d, start_RB=%d, n_RB_DLBWP=%d\n",l_RB,start_RB,n_RB_DLBWP);
-          /*
-           * According to TC 38.212 Subclause 7.3.1.2.1 (V15.2.0) (not implemented FIXME!!!)
-           * If the CRC of the DCI format 1_0 is scrambled by C-RNTI
-           * and the "Frequency domain resource assignment" field are of all ones,
-           * the DCI format 1_0 is for random access procedure initiated by a PDCCH order,
-           * with all remaining fields set as follows:
-           * - Random Access Preamble index (6 bits)
-           * - UL/SUL indicator (1 bit)
-           * - SS/PBCH index (6 bits)
-           * - PRACH Mask index (4 bits)
-           * - Reserved bits (10 bits)
-           *
-           */
-          /*
-          * The following commented code is used to verify that l_RB and start_RB are correctly calculated
-          *
-          *
-          printf("\ns_RB\t");
-          n_RB_DLBWP = 20;
-          for (int k = 0 ; k < n_RB_DLBWP; k++) printf("%d\t",k);
-          printf("\nl_RB");
-          for (int j = 1 ; j <= n_RB_DLBWP; j++){ // l_RB
-           printf("\n%d\t",j);
-           for (int i = 0 ; i < n_RB_DLBWP; i++) { // start_RB
-             if ((j-1) <= (floor(n_RB_DLBWP/2)) && ((j+i) <= n_RB_DLBWP)) {
-               tmp_RIV = n_RB_DLBWP * (j - 1) + i;
-               l_RB = floor(tmp_RIV/n_RB_DLBWP) + 1;
-               start_RB = tmp_RIV%n_RB_DLBWP;
-               printf("%d(%d,%d)  ",tmp_RIV,l_RB,start_RB);
-             }
-             if ((j-1) >  (floor(n_RB_DLBWP/2)) && ((j+i) <= n_RB_DLBWP)) {
-               tmp_RIV = n_RB_DLBWP * (n_RB_DLBWP - j + 1) + (n_RB_DLBWP - 1 - i);
-               //l_RB = floor(tmp_RIV/n_RB_DLBWP) + 1;
-               //start_RB = tmp_RIV%n_RB_DLBWP;
-               l_RB = n_RB_DLBWP - (floor(tmp_RIV/n_RB_DLBWP) + 1) + 2;
-               start_RB = n_RB_DLBWP - (tmp_RIV%n_RB_DLBWP) - 1;
-               printf("%d*(%d,%d)  ",tmp_RIV,l_RB,start_RB);
-             }
-           }
-          }*/
-          break;
-
-        case TIME_DOM_RESOURCE_ASSIGNMENT: // 12 TIME_DOM_RESOURCE_ASSIGNMENT: (field defined for format0_0,format0_1,format1_0,format1_1,-,-,-,-)
-          // 0, 1, 2, 3, or 4 bits as defined in:
-          //         Subclause 6.1.2.1 of [6, TS 38.214] for formats format0_0,format0_1
-          //         Subclause 5.1.2.1 of [6, TS 38.214] for formats format1_0,format1_1
-          // The bitwidth for this field is determined as log2(I) bits,
-          // where I the number of entries in the higher layer parameter pusch-AllocationList
-          nr_pdci_info_extracted->time_dom_resource_assignment     = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          /*if (dci_format == format0_0 || dci_format == format0_1){ // Subclause 6.1.2.1 of [6, TS 38.214]
-            k_offset = table_6_1_2_1_1_2_time_dom_res_alloc_A[nr_pdci_info_extracted->time_dom_resource_assignment][0];
-            sliv_S   = table_6_1_2_1_1_2_time_dom_res_alloc_A[nr_pdci_info_extracted->time_dom_resource_assignment][1];
-            sliv_L   = table_6_1_2_1_1_2_time_dom_res_alloc_A[nr_pdci_info_extracted->time_dom_resource_assignment][2];
-            // k_offset = table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][0];
-            // sliv_S   = table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][1];
-            // sliv_L   = table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][2];
-
-          }
-          if (dci_format == format1_0 || dci_format == format1_1){ // Subclause 5.1.2.1 of [6, TS 38.214]
-            // the Time domain resource assignment field of the DCI provides a row index of a higher layer configured table pdsch-symbolAllocation
-            // FIXME! To clarify which parameters to update after reception of row index
-            k_offset = table_5_1_2_1_1_2_time_dom_res_alloc_A[nr_pdci_info_extracted->time_dom_resource_assignment][0];
-            sliv_S   = table_5_1_2_1_1_2_time_dom_res_alloc_A[nr_pdci_info_extracted->time_dom_resource_assignment][1];
-            sliv_L   = table_5_1_2_1_1_2_time_dom_res_alloc_A[nr_pdci_info_extracted->time_dom_resource_assignment][2];
-            // k_offset = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][0];
-            // sliv_S   = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][1];
-            // sliv_L   = table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[nr_pdci_info_extracted->time_dom_resource_assignment][2];
-            // k_offset = table_5_1_2_1_1_4_time_dom_res_alloc_B[nr_pdci_info_extracted->time_dom_resource_assignment][0];
-            // sliv_S   = table_5_1_2_1_1_4_time_dom_res_alloc_B[nr_pdci_info_extracted->time_dom_resource_assignment][1];
-            // sliv_L   = table_5_1_2_1_1_4_time_dom_res_alloc_B[nr_pdci_info_extracted->time_dom_resource_assignment][2];
-            // k_offset = table_5_1_2_1_1_5_time_dom_res_alloc_C[nr_pdci_info_extracted->time_dom_resource_assignment][0];
-            // sliv_S   = table_5_1_2_1_1_5_time_dom_res_alloc_C[nr_pdci_info_extracted->time_dom_resource_assignment][1];
-            // sliv_L   = table_5_1_2_1_1_5_time_dom_res_alloc_C[nr_pdci_info_extracted->time_dom_resource_assignment][2];
-          }*/
-          LOG_DCI_D("nr_pdci_info_extracted->time_dom_resource_assignment=%x\n",nr_pdci_info_extracted->time_dom_resource_assignment);
-          break;
-
-        case VRB_TO_PRB_MAPPING: // 13 VRB_TO_PRB_MAPPING: (field defined for -,format0_1,format1_0,format1_1,-,-,-,-)
-          //0 bit if resource allocation type 0
-          //1 bit if resource allocation type 1
-          //Table 7.3.1.1.2-33: VRB-to-PRB mapping
-          // 0  Non-interleaved
-          // 1  Interleaved
-          nr_pdci_info_extracted->vrb_to_prb_mapping               = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //if (nr_pdci_info_extracted->vrb_to_prb_mapping == 0) { // Non-interleaved
-          //} else { // Interleaved
-          // format 0_1 defined in TS 38.211 Section 6.3.1.7
-          // formats 1_0 and 1_1 not defined yet
-          //}
-          LOG_DCI_D("nr_pdci_info_extracted->vrb_to_prb_mapping=%x\n",nr_pdci_info_extracted->vrb_to_prb_mapping);
-          break;
-
-        case PRB_BUNDLING_SIZE_IND: // 14 PRB_BUNDLING_SIZE_IND: (field defined for -,-,-,format1_1,-,-,-,-)
-          // 0 bit if the higher layer parameter PRB_bundling is not configured or is set to 'static', or 1 bit if the higher layer parameter PRB_bundling is set to 'dynamic' according to Subclause 5.1.2.3 of [6, TS 38.214]
-          nr_pdci_info_extracted->prb_bundling_size_ind            = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->prb_bundling_size_ind=%x\n",nr_pdci_info_extracted->prb_bundling_size_ind);
-          break;
-
-        case RATE_MATCHING_IND: // 15 RATE_MATCHING_IND: (field defined for -,-,-,format1_1,-,-,-,-)
-          // 0, 1, or 2 bits according to higher layer parameter rate-match-PDSCH-resource-set
-          nr_pdci_info_extracted->rate_matching_ind                = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->rate_matching_ind=%x\n",nr_pdci_info_extracted->rate_matching_ind);
-          break;
-
-        case ZP_CSI_RS_TRIGGER: // 16 ZP_CSI_RS_TRIGGER: (field defined for -,-,-,format1_1,-,-,-,-)
-          nr_pdci_info_extracted->zp_csi_rs_trigger                = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->zp_csi_rs_trigger=%x\n",nr_pdci_info_extracted->zp_csi_rs_trigger);
-          break;
-
-        case FREQ_HOPPING_FLAG: // 17 FREQ_HOPPING_FLAG: (field defined for format0_0,format0_1,-,-,-,-,-,-)
-          // 0 bit if only resource allocation type 0
-          // 1 bit otherwise, only applicable to resource allocation type 1, as defined in Subclause 6.3 of [6, TS 38.214]
-          nr_pdci_info_extracted->freq_hopping_flag                = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //if (nr_pdci_info_extracted->freq_hopping_flag != 0) { // PUSCH frequency hopping is performed     (only resource allocation type 1)
-          //} else {                                              // PUSCH frequency hopping is not performed (only resource allocation type 1)
-          // At the moment PUSCH hopping is not implemented. We are considering that the bit is present and the value is '0'
-          //}
-          LOG_DCI_D("nr_pdci_info_extracted->freq_hopping_flag=%x\n",nr_pdci_info_extracted->freq_hopping_flag);
-          break;
-
-        case TB1_MCS: // 18 TB1_MCS: (field defined for -,-,-,format1_1,-,-,-,-)
-          nr_pdci_info_extracted->tb1_mcs                          = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //if (nr_pdci_info_extracted->mcs < 29) pdlsch0_harq->mcs  = nr_pdci_info_extracted->tb1_mcs;
-          LOG_DCI_D("nr_pdci_info_extracted->tb1_mcs=%x\n",nr_pdci_info_extracted->tb1_mcs);
-          break;
-
-        case TB1_NDI: // 19 TB1_NDI: (field defined for -,-,-,format1_1,-,-,-,-)
-          nr_pdci_info_extracted->tb1_ndi                          = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //pdlsch0_harq->DCINdi = nr_pdci_info_extracted->tb1_ndi;
-          LOG_DCI_D("nr_pdci_info_extracted->tb1_ndi=%x\n",nr_pdci_info_extracted->tb1_ndi);
-          break;
-
-        case TB1_RV: // 20 TB1_RV: (field defined for -,-,-,format1_1,-,-,-,-)
-          nr_pdci_info_extracted->tb1_rv                           = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //pdlsch0_harq->rvidx  = nr_pdci_info_extracted->tb1_rv;
-          LOG_DCI_D("nr_pdci_info_extracted->tb1_rv=%x\n",nr_pdci_info_extracted->tb1_rv);
-          break;
-
-        case TB2_MCS: // 21 TB2_MCS: (field defined for -,-,-,format1_1,-,-,-,-)
-          nr_pdci_info_extracted->tb2_mcs                          = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //if (nr_pdci_info_extracted->mcs < 29) pdlsch0_harq->mcs  = nr_pdci_info_extracted->tb2_mcs;
-          LOG_DCI_D("nr_pdci_info_extracted->tb2_mcs=%x\n",nr_pdci_info_extracted->tb2_mcs);
-          break;
-
-        case TB2_NDI: // 22 TB2_NDI: (field defined for -,-,-,format1_1,-,-,-,-)
-          nr_pdci_info_extracted->tb2_ndi                          = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //pdlsch0_harq->DCINdi = nr_pdci_info_extracted->tb2_ndi;
-          LOG_DCI_D("nr_pdci_info_extracted->tb2_ndi=%x\n",nr_pdci_info_extracted->tb2_ndi);
-          break;
-
-        case TB2_RV: // 23 TB2_RV: (field defined for -,-,-,format1_1,-,-,-,-)
-          nr_pdci_info_extracted->tb2_rv                           = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //pdlsch0_harq->rvidx  = nr_pdci_info_extracted->tb2_rv;
-          LOG_DCI_D("nr_pdci_info_extracted->tb2_rv=%x\n",nr_pdci_info_extracted->tb2_rv);
-          break;
-
-        case MCS: // 24 MCS: (field defined for format0_0,format0_1,format1_0,-,-,-,-,-)
-          nr_pdci_info_extracted->mcs                              = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //if (nr_pdci_info_extracted->mcs < 29) {
-          //  if (dci_format == format0_0 || dci_format == format0_1)
-          //    ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->mcs = nr_pdci_info_extracted->mcs;
-          //  else
-          //    pdlsch0_harq->mcs = nr_pdci_info_extracted->mcs;
-          //} else {
-          //  return(0);
-          //}
-          LOG_DCI_D("nr_pdci_info_extracted->mcs=%x\n",nr_pdci_info_extracted->mcs);
-          break;
-
-        case NDI: // 25 NDI: (field defined for format0_0,format0_1,format1_0,-,-,-,-,-)
-          nr_pdci_info_extracted->ndi                              = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //if (dci_format == format0_0 || dci_format == format0_1) {
-          //  ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi = nr_pdci_info_extracted->ndi;
-          //  if (ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->first_tx==1) {
-          //    ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->first_tx=0;
-          //    ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi= nr_pdci_info_extracted->ndi;
-          //    ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->round = 0;
-          //  } else {
-          //    if (ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi != nr_pdci_info_extracted->ndi) { // new SDU opportunity
-          //      ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi= nr_pdci_info_extracted->ndi;
-          //     ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->round = 0;
-          //    }
-          //  }
-          //} else {
-          //  if (rnti == crc_scrambled_values[_TC_RNTI_]) { //fix for standalone Contention Resolution Id
-          //    pdlsch0_harq->DCINdi = (uint8_t)-1;
-          //  } else {
-          //    if ((prev_ndi != nr_pdci_info_extracted->ndi) || (pdlsch0_harq->first_tx==1)) {
-          //      pdlsch0_harq->round    = 0;
-          //      pdlsch0_harq->first_tx = 0;
-          //      pdlsch0_harq->status   = ACTIVE;
-          //    }
-          //    pdlsch0_harq->DCINdi = nr_pdci_info_extracted->ndi;
-          //  }
-          //}
-          LOG_DCI_D("nr_pdci_info_extracted->ndi=%x\n",nr_pdci_info_extracted->ndi);
-          break;
-
-        case RV: // 26 RV: (field defined for format0_0,format0_1,format1_0,-,-,-,-,-)
-          nr_pdci_info_extracted->rv                               = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //if (dci_format == format0_0 || dci_format == format0_1)
-          //  ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->rvidx = nr_pdci_info_extracted->rv;
-          //else
-          //  pdlsch0_harq->rvidx = nr_pdci_info_extracted->rv;
-          //if ((prev_ndi == nr_pdci_info_extracted->ndi) && (pdlsch0_harq->rvidx != 0)) { // NDI has not been toggled but rv was increased by eNB: retransmission
-          //  if (pdlsch0_harq->status == SCH_IDLE) {
-          // packet was actually decoded in previous transmission (ACK was missed by eNB)
-          // however, the round is not a good check as it might have been decoded in a retransmission prior to this one.
-          // skip pdsch decoding and report ack
-          //    pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.ack = 1;
-          //    pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.send_harq_status;
-#if 0
-          //    pdlsch0->active       = 0;
-          //    pdlsch0->harq_ack[nr_tti_rx].ack = 1;
-          //    pdlsch0->harq_ack[nr_tti_rx].harq_id = nr_pdci_info_extracted->harq_process_number;
-          //    pdlsch0->harq_ack[nr_tti_rx].send_harq_status = 1;
-#endif
-          // } else { // normal retransmission, nothing special to do
-          // }
-          //} else {
-          //  pdlsch0_harq->status   = ACTIVE;
-          //}
-          LOG_DCI_D("nr_pdci_info_extracted->rv=%x\n",nr_pdci_info_extracted->rv);
-          break;
 
-        case HARQ_PROCESS_NUMBER: // 27 HARQ_PROCESS_NUMBER: (field defined for format0_0,format0_1,format1_0,format1_1,-,-,-,-)
-          nr_pdci_info_extracted->harq_process_number              = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //pdlsch0->current_harq_pid = nr_pdci_info_extracted->harq_process_number;
-          LOG_DCI_D("nr_pdci_info_extracted->harq_process_number=%x\n",nr_pdci_info_extracted->harq_process_number);
-          break;
 
-        case DAI_: // 28 DAI_: (field defined for -,-,format1_0,format1_1,-,-,-,-)
-          // For format1_0: 2 bits as defined in Subclause 9.1.3 at TS 38.213
-          // For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
-          // 2 if one serving cell is configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 bits are the counter DAI
-          // 0 otherwise
-          nr_pdci_info_extracted->dai                              = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.vDAI_DL = nr_pdci_info_extracted->dai+1;
-          //pdlsch0->harq_ack[nr_tti_rx].vDAI_DL = nr_pdci_info_extracted->dai+1;
-          LOG_DCI_D("nr_pdci_info_extracted->dai=%x\n",nr_pdci_info_extracted->dai);
-          break;
 
-        case FIRST_DAI: // 29 FIRST_DAI: (field defined for -,format0_1,-,-,-,-,-,-)
-          // (1 or 2 bits) 1 bit for semi-static HARQ-ACK
-          nr_pdci_info_extracted->first_dai                        = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->first_dai=%x\n",nr_pdci_info_extracted->first_dai);
-          break;
-
-        case SECOND_DAI: // 30 SECOND_DAI: (field defined for -,format0_1,-,-,-,-,-,-)
-          // (0 or 2 bits) 2 bits for dynamic HARQ-ACK codebook with two HARQ-ACK sub-codebooks
-          nr_pdci_info_extracted->second_dai                       = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->second_dai=%x\n",nr_pdci_info_extracted->second_dai);
-          break;
-
-        case TB_SCALING: // 31 TB_SCALING: (field defined for -,format0_1,-,-,-,-,-,-)
-          // (0 or 2 bits) 2 bits for dynamic HARQ-ACK codebook with two HARQ-ACK sub-codebooks
-          nr_pdci_info_extracted->tb_scaling                       = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->tb_scaling=%x\n",nr_pdci_info_extracted->tb_scaling);
-          break;
-
-        case TPC_PUSCH: // 32 TPC_PUSCH: (field defined for format0_0,format0_1,-,-,-,-,-,-)
-          // defined in Subclause 7.1.1 TS 38.213
-          nr_pdci_info_extracted->tpc_pusch                        = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->TPC = nr_pdci_info_extracted->tpc_pusch;
-          //if (ue->ul_power_control_dedicated[eNB_id].accumulationEnabled == 1) {
-          //  ulsch0->f_pusch += nr_delta_PUSCH_acc[ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->TPC];
-          //} else {
-          //  ulsch0->f_pusch  = nr_delta_PUSCH_abs[ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->TPC];
-          //}
-          LOG_DCI_D("nr_pdci_info_extracted->tpc_pusch=%x\n",nr_pdci_info_extracted->tpc_pusch);
-          break;
-
-        case TPC_PUCCH: // 33 TPC_PUCCH: (field defined for -,-,format1_0,format1_1,-,-,-,-)
-          // defined in Subclause 7.2.1 TS 38.213
-          nr_pdci_info_extracted->tpc_pucch                        = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          //pdlsch0_harq->delta_PUCCH  = nr_delta_PUCCH_lut[nr_pdci_info_extracted->tpc_pucch &3];
-          LOG_DCI_D("nr_pdci_info_extracted->tpc_pucch=%x\n",nr_pdci_info_extracted->tpc_pucch);
-          break;
-
-        case PUCCH_RESOURCE_IND: // 34 PUCCH_RESOURCE_IND: (field defined for -,-,format1_0,format1_1,-,-,-,-)
-          // defined in Subclause 9.2.3 TS 38.213
-          // PUCCH_RESOURCE_IND points to PUCCH-ResourceId, but PUCCH-ResourceId is not defined yet
-          nr_pdci_info_extracted->pucch_resource_ind               = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->pucch_resource_ind=%x\n",nr_pdci_info_extracted->pucch_resource_ind);
-          break;
-
-        case PDSCH_TO_HARQ_FEEDBACK_TIME_IND: // 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND: (field defined for -,-,format1_0,format1_1,-,-,-,-)
-          // defined in Subclause 9.2.3 TS 38.213
-          // PDSCH_TO_HARQ_FEEDBACK_TIME_IND points to DL-data-DL-acknowledgement, but DL-data-DL-acknowledgement is not defined yet
-          nr_pdci_info_extracted->pdsch_to_harq_feedback_time_ind  = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->pdsch_to_harq_feedback_time_ind=%x\n",nr_pdci_info_extracted->pdsch_to_harq_feedback_time_ind);
-          break;
-
-        case SRS_RESOURCE_IND: // 36 SRS_RESOURCE_IND: (field defined for -,format0_1,-,-,-,-,-,-)
-          nr_pdci_info_extracted->srs_resource_ind                 = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->srs_resource_ind=%x\n",nr_pdci_info_extracted->srs_resource_ind);
-          break;
-
-        case PRECOD_NBR_LAYERS: // 37 PRECOD_NBR_LAYERS: (field defined for -,format0_1,-,-,-,-,-,-)
-          nr_pdci_info_extracted->precod_nbr_layers                = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->precod_nbr_layers=%x\n",nr_pdci_info_extracted->precod_nbr_layers);
-          break;
-
-        case ANTENNA_PORTS: // 38 ANTENNA_PORTS: (field defined for -,format0_1,-,format1_1,-,-,-,-)
-          nr_pdci_info_extracted->antenna_ports                    = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->antenna_ports=%x\n",nr_pdci_info_extracted->antenna_ports);
-          break;
-
-        case TCI: // 39 TCI: (field defined for -,-,-,format1_1,-,-,-,-)
-          // 0 bit if higher layer parameter tci-PresentInDCI is not enabled; otherwise 3 bits
-          nr_pdci_info_extracted->tci                              = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->tci=%x\n",nr_pdci_info_extracted->tci);
-          break;
-
-        case SRS_REQUEST: // 40 SRS_REQUEST: (field defined for -,format0_1,-,format1_1,-,-,-,format2_3)
-          nr_pdci_info_extracted->srs_request                      = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->srs_request=%x\n",nr_pdci_info_extracted->srs_request);
-          break;
-
-        case TPC_CMD: // 41 TPC_CMD: (field defined for -,-,-,-,-,-,-,format2_3)
-          nr_pdci_info_extracted->tpc_cmd         = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->tpc_cmd=%x\n",nr_pdci_info_extracted->tpc_cmd);
-          break;
-
-        case CSI_REQUEST: // 42 CSI_REQUEST: (field defined for -,format0_1,-,-,-,-,-,-)
-          nr_pdci_info_extracted->csi_request                      = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->csi_request=%x\n",nr_pdci_info_extracted->csi_request);
-          break;
-
-        case CBGTI: // 43 CBGTI: (field defined for -,format0_1,-,format1_1,-,-,-,-)
-          // 0, 2, 4, 6, or 8 bits determined by higher layer parameter maxCodeBlockGroupsPerTransportBlock for the PDSCH
-          nr_pdci_info_extracted->cbgti                            = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->cbgti=%x\n",nr_pdci_info_extracted->cbgti);
-          break;
-
-        case CBGFI: // 44 CBGFI: (field defined for -,-,-,format1_1,-,-,-,-)
-          // 0 or 1 bit determined by higher layer parameter codeBlockGroupFlushIndicator
-          nr_pdci_info_extracted->cbgfi                            = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->cbgfi=%x\n",nr_pdci_info_extracted->cbgfi);
-          break;
-
-        case PTRS_DMRS: // 45 PTRS_DMRS: (field defined for -,format0_1,-,-,-,-,-,-)
-          nr_pdci_info_extracted->ptrs_dmrs                        = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->ptrs_dmrs=%x\n",nr_pdci_info_extracted->ptrs_dmrs);
-          break;
-
-        case BETA_OFFSET_IND: // 46 BETA_OFFSET_IND: (field defined for -,format0_1,-,-,-,-,-,-)
-          nr_pdci_info_extracted->beta_offset_ind                  = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->beta_offset_ind=%x\n",nr_pdci_info_extracted->beta_offset_ind);
-          break;
-
-        case DMRS_SEQ_INI: // 47 DMRS_SEQ_INI: (field defined for -,format0_1,-,format1_1,-,-,-,-)
-          // 1 bit if the cell has two ULs and the number of bits for DCI format 1_0 before padding is larger than the number of bits for DCI format 0_0 before padding; 0 bit otherwise
-          nr_pdci_info_extracted->dmrs_seq_ini                     = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->dmrs_seq_ini=%x\n",nr_pdci_info_extracted->dmrs_seq_ini);
-          break;
-
-        case UL_SCH_IND: // 48 UL_SCH_IND: (field defined for -,format0_1,-,-,-,-,-,-)
-          // value of "1" indicates UL-SCH shall be transmitted on the PUSCH and a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH
-          nr_pdci_info_extracted->ul_sch_ind                     = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->dmrs_seq_ini=%x\n",nr_pdci_info_extracted->ul_sch_ind);
-          break;
-
-        case PADDING_NR_DCI: // 49 PADDING_NR_DCI: (field defined for format0_0,-,format1_0,-,-,-,-,-)
-          // (Note 2) If DCI format 0_0 is monitored in common search space
-          nr_pdci_info_extracted->padding_nr_dci                 = (uint16_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->padding=%x\n",nr_pdci_info_extracted->padding_nr_dci);
-          break;
-
-        case SUL_IND_0_0: // 50 SUL_IND_0_0: (field defined for format0_0,-,-,-,-,-,-,-)
-          nr_pdci_info_extracted->sul_ind_0_0                    = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->sul_ind_0_0=%x\n",nr_pdci_info_extracted->sul_ind_0_0);
-          break;
-
-        case RA_PREAMBLE_INDEX: // 51 RA_PREAMBLE_INDEX: (field defined for format0_0,-,-,-,-,-,-,-)
-          nr_pdci_info_extracted->ra_preamble_index              = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->ra_preamble_index=%x\n",nr_pdci_info_extracted->ra_preamble_index);
-          break;
-
-        case SUL_IND_1_0: // 52 SUL_IND_1_0: (field defined for -,-,format1_0,-,-,-,-,-)
-          nr_pdci_info_extracted->sul_ind_1_0                    = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->sul_ind_1_0=%x\n",nr_pdci_info_extracted->sul_ind_1_0);
-          break;
-
-        case SS_PBCH_INDEX: // 53 SS_PBCH_INDEX: (field defined for -,-,format1_0,-,-,-,-,-)
-          nr_pdci_info_extracted->ss_pbch_index                  = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->ss_pbch_index=%x\n",nr_pdci_info_extracted->ss_pbch_index);
-          break;
-
-        case PRACH_MASK_INDEX: // 54 PRACH_MASK_INDEX: (field defined for -,-,-,format1_0,-,-,-,-)
-          nr_pdci_info_extracted->prach_mask_index               = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->prach_mask_index=%x\n",nr_pdci_info_extracted->prach_mask_index);
-          break;
-
-        case RESERVED_NR_DCI: // 55 RESERVED_NR_DCI: (field defined for -,-,-,format1_0,-,-,-,-)
-          nr_pdci_info_extracted->reserved_nr_dci                = (uint8_t)nr_dci_field(dci_pdu,dci_fields_sizes_format,dci_field);
-          //(((((*(uint128_t *)dci_pdu)  << (left_shift - dci_fields_sizes[dci_field][dci_format]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format]));
-          LOG_DCI_D("nr_pdci_info_extracted->reserved_nr_dci=%x\n",nr_pdci_info_extracted->reserved_nr_dci);
-          break;
-      }
-    }
-  }
-
-  LOG_DCI_D("Ending function nr_extract_dci_info()\n");
-  return(1);
-}
-
-#endif
-
-#ifdef NR_PDCCH_DCI_TOOLS
-
-int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue,
-    uint8_t eNB_id,
-    int frame,
-    uint8_t nr_tti_rx,
-    uint64_t dci_pdu[2],
-    uint16_t rnti,
-    uint8_t dci_length,
-    NR_DCI_format_t dci_format,
-    NR_DL_FRAME_PARMS *frame_parms,
-    PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
-    uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS],
-    uint16_t n_RB_ULBWP,
-    uint16_t n_RB_DLBWP,
-    uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES],
-    fapi_nr_dci_pdu_rel15_t *nr_dci_info_extracted) {
-  /*
-   * Note only format0_0 and format1_0 are implemented
-   */
-  uint8_t frame_type=frame_parms->frame_type;
-  uint8_t status=0;
-  LOG_DCI_PARM("dci_format=%d, rnti=%d, dci_length=%d, dci_pdu[0]=0x%lx, dci_pdu[1]=0x%lx\n",dci_format,rnti,dci_length,dci_pdu[0],
-        dci_pdu[1]);
-  memset(nr_dci_info_extracted,0,sizeof(*nr_dci_info_extracted));
-  LOG_DCI_PARM("Entering function nr_extract_dci_info(dci_format=%d) \n",dci_format);
-  status = nr_extract_dci_info(ue,
-                               eNB_id,
-                               frame_type,
-                               dci_length,
-                               rnti,
-                               dci_pdu,
-                               nr_dci_info_extracted,//&nr_dci_info_extracted,
-                               dci_fields_sizes,
-                               dci_format,
-                               nr_tti_rx,
-                               n_RB_ULBWP,
-                               n_RB_DLBWP,
-                               crc_scrambled_values);
-
-  if(status == 0) {
-    LOG_DCI_PARM("bad DCI %d !!! \n",dci_format);
-    return(-1);
-  }
-
-  LOG_DCI_PARM("Ending function nr_extract_dci_info()\n");
-  //fill
-  return(0);
-}
-
-#endif
 
 uint8_t nr_subframe2harq_pid(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t nr_tti_rx) {
   /*
@@ -984,77 +71,14 @@ uint8_t nr_subframe2harq_pid(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8
   uint8_t ret = 255;
   uint8_t subframe = nr_tti_rx>>((int)(log2 (frame_parms->ttis_per_subframe)));
 
+  AssertFatal(1==0,"Not ready for this ...\n");
   if (frame_parms->frame_type == FDD) {
     ret = (((frame<<1)+nr_tti_rx)&7);
   } else {
-    switch (frame_parms->tdd_config) {
-      case 1:
-        if ((subframe==2) ||
-            (subframe==3) ||
-            (subframe==7) ||
-            (subframe==8))
-          switch (subframe) {
-            case 2:
-            case 3:
-              ret = (subframe-2);
-              break;
-
-            case 7:
-            case 8:
-              ret = (subframe-5);
-              break;
 
-            default:
-              LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config);
-              ret = (255);
-              break;
-          }
-
-        break;
-
-      case 2:
-        if ((subframe!=2) && (subframe!=7)) {
-          LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config);
-          //mac_xface->macphy_exit("subframe2_harq_pid, Illegal subframe");
-          ret = (255);
-        }
-
-        ret = (subframe/7);
-        break;
-
-      case 3:
-        if ((subframe<2) || (subframe>4)) {
-          LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config);
-          ret = (255);
-        }
-
-        ret = (subframe-2);
-        break;
-
-      case 4:
-        if ((subframe<2) || (subframe>3)) {
-          LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config);
-          ret = (255);
-        }
-
-        ret = (subframe-2);
-        break;
-
-      case 5:
-        if (subframe!=2) {
-          LOG_E(PHY,"subframe2_harq_pid, Illegal subframe %d for TDD mode %d\n",subframe,frame_parms->tdd_config);
-          ret = (255);
-        }
-
-        ret = (subframe-2);
-        break;
-
-      default:
-        LOG_E(PHY,"subframe2_harq_pid, Unsupported TDD mode %d\n",frame_parms->tdd_config);
-        ret = (255);
-    }
   }
 
+
   if (ret == 255) {
     LOG_E(PHY, "invalid harq_pid(%d) at SFN/SF = %d/%d\n", ret, frame, subframe);
     //mac_xface->macphy_exit("invalid harq_pid");
@@ -1063,48 +87,14 @@ uint8_t nr_subframe2harq_pid(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8
   return ret;
 }
 
-
 uint8_t nr_pdcch_alloc2ul_subframe(NR_DL_FRAME_PARMS *frame_parms,uint8_t n) {
-  uint8_t ul_subframe = 255;
 
-  if ((frame_parms->frame_type == TDD) &&
-      (frame_parms->tdd_config == 1) &&
-      ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5
-    ul_subframe = ((n+6)%10);
-  else if ((frame_parms->frame_type == TDD) &&
-           (frame_parms->tdd_config == 6) &&
-           ((n==0)||(n==1)||(n==5)||(n==6)))
-    ul_subframe = ((n+7)%10);
-  else if ((frame_parms->frame_type == TDD) &&
-           (frame_parms->tdd_config == 6) &&
-           (n==9)) // tdd_config 6 SF 9
-    ul_subframe = ((n+5)%10);
-  else
-    ul_subframe = ((n+4)%10);
+  AssertFatal(1==0,"Not ready for this\n");
 
-  LOG_D(PHY, "subframe %d: PUSCH subframe = %d\n", n, ul_subframe);
-  return ul_subframe;
 }
 
 uint32_t nr_pdcch_alloc2ul_frame(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n) {
-  uint32_t ul_frame = 255;
 
-  if ((frame_parms->frame_type == TDD) &&
-      (frame_parms->tdd_config == 1) &&
-      ((n==1)||(n==6))) // tdd_config 0,1 SF 1,5
-    ul_frame = (frame + (n==1 ? 0 : 1));
-  else if ((frame_parms->frame_type == TDD) &&
-           (frame_parms->tdd_config == 6) &&
-           ((n==0)||(n==1)||(n==5)||(n==6)))
-    ul_frame = (frame + (n>=5 ? 1 : 0));
-  else if ((frame_parms->frame_type == TDD) &&
-           (frame_parms->tdd_config == 6) &&
-           (n==9)) // tdd_config 6 SF 9
-    ul_frame = (frame+1);
-  else
-    ul_frame = (frame+(n>=6 ? 1 : 0));
+  AssertFatal(1==0,"Not ready for this\n");
 
-  LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n", frame, n, ul_frame);
-  return ul_frame;
 }
-
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
index b3a95e313e1..00167507ce5 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
@@ -41,12 +41,11 @@
 #include "SCHED_NR_UE/defs.h"
 #include "SIMULATION/TOOLS/sim.h"
 #include "executables/nr-uesoftmodem.h"
-#include "PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h"
-#include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h"
+#include "PHY/CODING/nrLDPC_extern.h"
 //#define DEBUG_DLSCH_DECODING
 //#define ENABLE_PHY_PAYLOAD_DEBUG 1
 
-#define OAI_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX
+//#define OAI_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX
 
 static uint64_t nb_total_decod =0;
 static uint64_t nb_error_decod =0;
@@ -57,31 +56,46 @@ int nbDlProcessing =0;
 
 //extern double cpuf;
 
-void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr)
+void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr,uint8_t N_RB_DL)
 {
 
   int i,r;
+  uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS;  //number of segments to be allocated
   NR_UE_DLSCH_t *dlsch=*dlschptr;
+
   if (dlsch) {
+    if (N_RB_DL != 273) {
+      a_segments = a_segments*N_RB_DL;
+      a_segments = a_segments/273;
+    }  
+ 
+    uint16_t dlsch_bytes = a_segments*1056;  // allocated bytes per segment
+
     for (i=0; i<dlsch->Mdlharq; i++) {
       if (dlsch->harq_processes[i]) {
         if (dlsch->harq_processes[i]->b) {
-          free16(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES);
+          free16(dlsch->harq_processes[i]->b,dlsch_bytes);
           dlsch->harq_processes[i]->b = NULL;
         }
 
-        for (r=0; r<MAX_NUM_NR_DLSCH_SEGMENTS; r++) {
+        for (r=0; r<a_segments; r++) {
           free16(dlsch->harq_processes[i]->c[r],1056);
           dlsch->harq_processes[i]->c[r] = NULL;
         }
 
-        for (r=0; r<MAX_NUM_NR_DLSCH_SEGMENTS; r++)
+        for (r=0; r<a_segments; r++)
           if (dlsch->harq_processes[i]->d[r]) {
-            free16(dlsch->harq_processes[i]->d[r],(3*8448)*sizeof(short));
+            free16(dlsch->harq_processes[i]->d[r],(5*8448)*sizeof(short));
             dlsch->harq_processes[i]->d[r] = NULL;
           }
         
-        for (r=0; r<(MAX_NUM_NR_DLSCH_SEGMENTS); r++) {
+        for (r=0; r<a_segments; r++)
+          if (dlsch->harq_processes[i]->w[r]) {
+            free16(dlsch->harq_processes[i]->w[r],(5*8448)*sizeof(short));
+            dlsch->harq_processes[i]->w[r] = NULL;
+          }
+
+        for (r=0; r<a_segments; r++) {
           if (dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]){
             nrLDPC_free_mem(dlsch->harq_processes[i]->p_nrLDPC_procBuf[r]);
             dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL;
@@ -98,31 +112,20 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr)
   }
 }
 
-NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_ldpc_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag)
+NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_ldpc_iterations,uint16_t N_RB_DL, uint8_t abstraction_flag)
 {
 
   NR_UE_DLSCH_t *dlsch;
   uint8_t exit_flag = 0,i,r;
 
-  unsigned char bw_scaling =1;
-
-  switch (N_RB_DL) {
-  case 6:
-    bw_scaling =16;
-    break;
+  uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS;  //number of segments to be allocated
 
-  case 25:
-    bw_scaling =4;
-    break;
+  if (N_RB_DL != 273) {
+    a_segments = a_segments*N_RB_DL;
+    a_segments = (a_segments/273)+1;
+  }  
 
-  case 50:
-    bw_scaling =2;
-    break;
-
-  default:
-    bw_scaling =1;
-    break;
-  }
+  uint16_t dlsch_bytes = a_segments*1056;  // allocated bytes per segment
 
   dlsch = (NR_UE_DLSCH_t *)malloc16(sizeof(NR_UE_DLSCH_t));
 
@@ -141,15 +144,15 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint
       if (dlsch->harq_processes[i]) {
         memset(dlsch->harq_processes[i],0,sizeof(NR_DL_UE_HARQ_t));
         dlsch->harq_processes[i]->first_tx=1;
-        dlsch->harq_processes[i]->b = (uint8_t*)malloc16(MAX_DLSCH_PAYLOAD_BYTES/bw_scaling);
+        dlsch->harq_processes[i]->b = (uint8_t*)malloc16(dlsch_bytes);
 
         if (dlsch->harq_processes[i]->b)
-          memset(dlsch->harq_processes[i]->b,0,MAX_DLSCH_PAYLOAD_BYTES/bw_scaling);
+          memset(dlsch->harq_processes[i]->b,0,dlsch_bytes);
         else
           exit_flag=3;
 
         if (abstraction_flag == 0) {
-          for (r=0; r<MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling; r++) { 
+          for (r=0; r<a_segments; r++) { 
             dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
             dlsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(1056);
 
@@ -158,10 +161,17 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint
             else
               exit_flag=2;
 
-            dlsch->harq_processes[i]->d[r] = (short*)malloc16((3*8448)*sizeof(short));
+            dlsch->harq_processes[i]->d[r] = (short*)malloc16((5*8448)*sizeof(short));
 
             if (dlsch->harq_processes[i]->d[r])
-              memset(dlsch->harq_processes[i]->d[r],0,(3*8448)*sizeof(short));
+              memset(dlsch->harq_processes[i]->d[r],0,(5*8448)*sizeof(short));
+            else
+              exit_flag=2;
+
+            dlsch->harq_processes[i]->w[r] = (short*)malloc16((5*8448)*sizeof(short));
+
+            if (dlsch->harq_processes[i]->w[r])
+              memset(dlsch->harq_processes[i]->w[r],0,(5*8448)*sizeof(short));
             else
               exit_flag=2;
           }
@@ -176,7 +186,7 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint
   }
 
   printf("new_ue_dlsch with size %zu: exit_flag = %u\n",sizeof(NR_DL_UE_HARQ_t), exit_flag);
-  free_nr_ue_dlsch(&dlsch);
+  free_nr_ue_dlsch(&dlsch,N_RB_DL);
 
   return(NULL);
 }
@@ -228,7 +238,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
   int32_t no_iteration_ldpc, length_dec;
   uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0;
   uint8_t crc_type;
-  int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32)));
+  int8_t llrProcBuf[NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32)));
   t_nrLDPC_dec_params decParams;
   t_nrLDPC_dec_params* p_decParams = &decParams;
   t_nrLDPC_time_stats procTime;
@@ -239,20 +249,24 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
     return(dlsch->max_ldpc_iterations + 1);
   }
   t_nrLDPC_procBuf** p_nrLDPC_procBuf = harq_process->p_nrLDPC_procBuf;
+
     
   int16_t z [68*384];
   int8_t l [68*384];
   //__m128i l;
   //int16_t inv_d [68*384];
   uint8_t kc;
-  uint8_t Ilbrm = 1;
-  uint32_t Tbslbrm; //= 950984;
-  uint16_t nb_rb; //= 30;
-  double Coderate; //= 0.0;
-  //nfapi_nr_config_request_t *cfg = &phy_vars_ue->nrUE_config;
-  //uint8_t dmrs_type = cfg->pdsch_config.dmrs_type.value;
-  uint8_t nb_re_dmrs = 6; //(dmrs_type==NFAPI_NR_DMRS_TYPE1)?6:4;
-  uint16_t length_dmrs = 1; //cfg->pdsch_config.dmrs_max_length.value;
+  uint8_t Ilbrm = 0;
+
+  uint32_t Tbslbrm;// = 950984;
+  uint16_t nb_rb;// = 30;
+  double Coderate;// = 0.0;
+
+  uint8_t dmrs_Type = harq_process->dmrsConfigType;
+  AssertFatal(dmrs_Type == 1 || dmrs_Type == 2,"Illegal dmrs_type %d\n",dmrs_Type);
+  uint8_t nb_re_dmrs = (dmrs_Type==1)?6:4;
+  uint16_t dmrs_length = get_num_dmrs(harq_process->dlDmrsSymbPos);
+  AssertFatal(dmrs_length == 1 || dmrs_length == 2,"Illegal dmrs_length %d\n",dmrs_length);
 
   uint32_t i,j;
 
@@ -304,16 +318,16 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
 
   uint16_t nb_rb_oh = 0; // it was not computed at UE side even before and set to 0 in nr_compute_tbs
 
-  harq_process->TBS = nr_compute_tbs(harq_process->Qm,harq_process->R,nb_rb,nb_symb_sch,nb_re_dmrs*length_dmrs, nb_rb_oh, harq_process->Nl);
+  harq_process->TBS = nr_compute_tbs(harq_process->Qm,harq_process->R,nb_rb,nb_symb_sch,nb_re_dmrs*dmrs_length, nb_rb_oh, harq_process->Nl);
 
   A = harq_process->TBS;
   ret = dlsch->max_ldpc_iterations + 1;
   dlsch->last_iteration_cnt = ret;
  
-  harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, harq_process->Qm,harq_process->Nl);
+  harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, dmrs_length, harq_process->Qm,harq_process->Nl);
   G = harq_process->G;
 
-  LOG_I(PHY,"DLSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb);
+  LOG_D(PHY,"DLSCH Decoding, harq_pid %d TBS %d G %d nb_re_dmrs %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, nb_re_dmrs,harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb);
 
   if ((harq_process->R)<1024)
     Coderate = (float) (harq_process->R) /(float) 1024;
@@ -388,20 +402,15 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
   err_flag = 0;
   r_offset = 0;
 
-  unsigned char bw_scaling =1;
-
-  switch (frame_parms->N_RB_DL) {
-    case 106:
-      bw_scaling =2;
-      break;
+  uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS;  //number of segments to be allocated
 
-    default:
-      bw_scaling =1;
-      break;
-  }
+  if (nb_rb != 273) {
+    a_segments = a_segments*nb_rb;
+    a_segments = a_segments/273;
+  }  
 
-  if (harq_process->C > MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling) {
-    LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling);
+  if (harq_process->C > a_segments) {
+    LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,a_segments);
     return((1+dlsch->max_ldpc_iterations));
   }
 
@@ -427,6 +436,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
 
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_DEINTERLEAVING, VCD_FUNCTION_IN);
 
+
     nr_deinterleaving_ldpc(E,
                            harq_process->Qm,
                            harq_process->w[r], // [hna] w is e
@@ -445,9 +455,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
     start_meas(dlsch_rate_unmatching_stats);
 #endif
 
-#ifdef DEBUG_DLSCH_DECODING
-    LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n",
-          harq_pid,r, G,
+    LOG_D(PHY,"HARQ_PID %d Rate Matching Segment %d (coded bits %d,E %d, F %d,unpunctured/repeated bits %d, TBS %d, mod_order %d, nb_rb %d, Nl %d, rv %d, round %d)...\n",
+          harq_pid,r, G,E,harq_process->F,
           Kr*3,
           harq_process->TBS,
           harq_process->Qm,
@@ -455,7 +464,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
           harq_process->Nl,
           harq_process->rvidx,
           harq_process->round);
-#endif
+
 
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_RATE_MATCHING, VCD_FUNCTION_IN);
 
@@ -464,6 +473,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
     else
       Tbslbrm = nr_compute_tbslbrm(harq_process->mcs_table,nb_rb,4,harq_process->C);
 
+
     if (nr_rate_matching_ldpc_rx(Ilbrm,
                                  Tbslbrm,
                                  p_decParams->BG,
@@ -473,7 +483,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
                                  harq_process->C,
                                  harq_process->rvidx,
                                  (harq_process->round==0)?1:0,
-                                 E)==-1) {
+                                 E,
+                                 harq_process->F,
+                                 Kr-harq_process->F-2*(p_decParams->Z))==-1) {
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_RATE_MATCHING, VCD_FUNCTION_OUT);
 #if UE_TIMING_TRACE
       stop_meas(dlsch_rate_unmatching_stats);
@@ -487,6 +499,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
 #endif
     }
 
+
     //for (int i =0; i<16; i++)
     //      printf("rx output ratematching d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset);
 
@@ -495,12 +508,12 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
 #ifdef DEBUG_DLSCH_DECODING
     if (r==0) {
       write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0);
-      write_output("decoder_in.m","dec",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,0);
+      write_output("decoder_in.m","dec",&harq_process->d[0][0],E,1,0);
     }
 
     printf("decoder input(segment %u) :",r);
     int i;
-    for (i=0;i<(3*8*Kr_bytes)+12;i++)
+    for (i=0;i<E;i++)
       printf("%d : %d\n",i,harq_process->d[r][i]);
     printf("\n");
 #endif
@@ -531,18 +544,21 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
 
       //LOG_E(PHY,"AbsSubframe %d.%d Start LDPC segment %d/%d A %d ",frame%1024,nr_tti_rx,r,harq_process->C-1, A);
 
-      printf("harq process dr iteration %d\n", p_decParams->numMaxIter);
+      //printf("harq process dr iteration %d\n", p_decParams->numMaxIter);
 
       memset(pv,0,2*harq_process->Z*sizeof(int16_t));
       //memset(pl,0,2*p_decParams->Z*sizeof(int8_t));
       memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t));
 
+
       for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F; i++, j++)
       {
         pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j]));
       }
-
-      for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++)
+      // Kbytes_F = Kr_bytes - F>>3
+      j+=(harq_process->F>>3);
+      //      for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++)
+      for (i=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++,j++)
       {
         pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j]));
       }
@@ -552,6 +568,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
         pl[j] = _mm_packs_epi16(pv[i],pv[i+1]);
       }
 
+
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_LDPC, VCD_FUNCTION_IN);
 
       no_iteration_ldpc = nrLDPC_decoder(p_decParams,
@@ -559,21 +576,21 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
                            llrProcBuf,
                            p_nrLDPC_procBuf[r],
                            p_procTime);
-
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_LDPC, VCD_FUNCTION_OUT);
 
       // Fixme: correct type is unsigned, but nrLDPC_decoder and all called behind use signed int
       if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) {
-        printf("\x1B[34m" "Segment %u CRC OK\n\033[0m",r);
+        LOG_D(PHY,"Segment %u CRC OK\n\033[0m",r);
         //Temporary hack
         no_iteration_ldpc = dlsch->max_ldpc_iterations;
         ret = no_iteration_ldpc;
       }
       else {
-        printf("\x1B[33m" "Segment %d CRC NOK\n",r);
+        LOG_D(PHY,"CRC NOK\n\033[0m");
         ret = 1 + dlsch->max_ldpc_iterations;
       }
 
+
       nb_total_decod++;
       if (no_iteration_ldpc > dlsch->max_ldpc_iterations){
         nb_error_decod++;
@@ -615,7 +632,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
 
 
     if ((err_flag == 0) && (ret>=(1+dlsch->max_ldpc_iterations))) {// a Code segment is in error so break;
-      LOG_I(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1);
+      LOG_D(PHY,"AbsSubframe %d.%d CRC failed, segment %d/%d \n",frame%1024,nr_tti_rx,r,harq_process->C-1);
       err_flag = 1;
     }
   }
@@ -630,7 +647,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
 
   if (err_flag == 1) {
 //#if UE_DEBUG_TRACE
-    LOG_I(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n",
+    LOG_D(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n",
         phy_vars_ue->Mod_id, frame, nr_tti_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs,Kr,r,harq_process->round);
 //#endif
     harq_process->harq_ack.ack = 0;
@@ -647,15 +664,15 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
 
     if(is_crnti)
     {
-    LOG_I(PHY,"[UE %d] DLSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n",
+    LOG_D(PHY,"[UE %d] DLSCH: Setting NACK for nr_tti_rx %d (pid %d, pid status %d, round %d/Max %d, TBS %d)\n",
                phy_vars_ue->Mod_id,nr_tti_rx,harq_pid,harq_process->status,harq_process->round,dlsch->Mdlharq,harq_process->TBS);
     }
 
     return((1 + dlsch->max_ldpc_iterations));
   } else {
 //#if UE_DEBUG_TRACE
-      LOG_I(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d TBS %d mcs %d nb_rb %d harq_process->round %d\n",
-           phy_vars_ue->Mod_id,nr_tti_rx,harq_process->TBS,harq_process->mcs,harq_process->nb_rb, harq_process->round);
+    LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d TBS %d mcs %d nb_rb %d harq_process->round %d\n",
+	  phy_vars_ue->Mod_id,nr_tti_rx,harq_process->TBS,harq_process->mcs,harq_process->nb_rb, harq_process->round);
 //#endif
 
     harq_process->status = SCH_IDLE;
@@ -664,12 +681,12 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
     harq_process->harq_ack.harq_id = harq_pid;
     harq_process->harq_ack.send_harq_status = 1;
     
-    //LOG_I(PHY,"[UE %d] DLSCH: Setting ACK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d)\n",
+    //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d)\n",
       //  phy_vars_ue->Mod_id, frame, subframe, harq_pid, harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs);
 
     if(is_crnti)
     {
-    LOG_I(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d (pid %d, round %d, TBS %d)\n",phy_vars_ue->Mod_id,nr_tti_rx,harq_pid,harq_process->round,harq_process->TBS);
+    LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d (pid %d, round %d, TBS %d)\n",phy_vars_ue->Mod_id,nr_tti_rx,harq_pid,harq_process->round,harq_process->TBS);
     }
     //LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for subframe %d (pid %d, round %d)\n",phy_vars_ue->Mod_id,subframe,harq_pid,harq_process->round);
 
@@ -691,8 +708,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
   for (r=0; r<harq_process->C; r++) {
 
     memcpy(harq_process->b+offset,
-             harq_process->c[r],
-             Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0));
+	   harq_process->c[r],
+	   Kr_bytes- - (harq_process->F>>3) -((harq_process->C>1)?3:0));
     offset += (Kr_bytes - (harq_process->F>>3) - ((harq_process->C>1)?3:0));
 
 #ifdef DEBUG_DLSCH_DECODING
@@ -752,7 +769,6 @@ uint32_t  nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
   uint32_t A,E;
   uint32_t G;
   uint32_t ret,offset;
-  //short dummy_w[MAX_NUM_DLSCH_SEGMENTS][3*(8448+64)];
   uint32_t r,r_offset=0,Kr=8424,Kr_bytes,err_flag=0,K_bytes_F;
   uint8_t crc_type;
   //UE_rxtx_proc_t *proc = &phy_vars_ue->proc;
@@ -765,7 +781,7 @@ uint32_t  nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
   t_nrLDPC_dec_params* p_decParams = &decParams;
   t_nrLDPC_time_stats procTime;
   t_nrLDPC_time_stats* p_procTime =&procTime ;
-  int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32)));
+  int8_t llrProcBuf[NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32)));
     if (!harq_process) {
     printf("dlsch_decoding.c: NULL harq_process pointer\n");
     return(dlsch->max_ldpc_iterations);
@@ -782,10 +798,12 @@ uint32_t  nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
   uint32_t Tbslbrm = 950984;
   uint16_t nb_rb = 30;
   double Coderate = 0.0;
+  uint8_t dmrs_type = harq_process->dmrsConfigType;
   //nfapi_nr_config_request_t *cfg = &phy_vars_ue->nrUE_config;
   //uint8_t dmrs_type = cfg->pdsch_config.dmrs_type.value;
-  uint8_t nb_re_dmrs = 6; //(dmrs_type==NFAPI_NR_DMRS_TYPE1)?6:4;
-  uint16_t length_dmrs = 1; //cfg->pdsch_config.dmrs_max_length.value;
+
+  uint8_t nb_re_dmrs = (dmrs_type==1)?6:4;
+  uint16_t length_dmrs = get_num_dmrs(harq_process->dlDmrsSymbPos); 
 
   uint32_t i,j;
 //  int nbDlProcessing =0;
@@ -841,14 +859,14 @@ uint32_t  nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
 
   A = harq_process->TBS;
 
-  ret = dlsch->max_ldpc_iterations;
+  ret = dlsch->max_ldpc_iterations + 1;
+  dlsch->last_iteration_cnt = ret;
 
   harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, harq_process->Qm,harq_process->Nl);
 
   G = harq_process->G;
 
-  LOG_D(PHY,"DLSCH Decoding main, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb);
-
+  LOG_D(PHY,"DLSCH Decoding main, harq_pid %d TBS %d G %d, nb_re_dmrs %d, length_dmrs %d  mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, nb_re_dmrs, length_dmrs, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb);
 
   proc->decoder_main_available = 1;
   proc->decoder_thread_available = 0;
@@ -910,9 +928,10 @@ uint32_t  nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
                       &harq_process->F,
                       p_decParams->BG);
 
-      p_decParams->Z = harq_process->Z;
 
     }
+    
+    p_decParams->Z = harq_process->Z;
 
   //printf("coderate %f kc %d \n", Coderate, kc);
   p_decParams->numMaxIter = dlsch->max_ldpc_iterations;
@@ -921,20 +940,15 @@ uint32_t  nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
   err_flag = 0;
   r_offset = 0;
 
-  unsigned char bw_scaling =1;
-
-  switch (frame_parms->N_RB_DL) {
-  case 106:
-    bw_scaling =2;
-    break;
+  uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS;  //number of segments to be allocated
 
-  default:
-    bw_scaling =1;
-    break;
-  }
+  if (nb_rb != 273) {
+    a_segments = a_segments*nb_rb;
+    a_segments = a_segments/273;
+  }  
 
-  if (harq_process->C > MAX_NUM_DLSCH_SEGMENTS/bw_scaling) {
-    LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_DLSCH_SEGMENTS/bw_scaling);
+  if (harq_process->C > a_segments) {
+    LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,a_segments);
     return((1+dlsch->max_ldpc_iterations));
   }
 #ifdef DEBUG_DLSCH_DECODING
@@ -1050,7 +1064,9 @@ uint32_t  nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
                                  harq_process->C,
                                  harq_process->rvidx,
                                  (harq_process->round==0)?1:0,
-                                 E)==-1) {
+                                 E,
+				 harq_process->F,
+				 Kr-harq_process->F-2*(p_decParams->Z))==-1) {
 #if UE_TIMING_TRACE
       stop_meas(dlsch_rate_unmatching_stats);
 #endif
@@ -1109,7 +1125,7 @@ uint32_t  nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
 
     if (err_flag == 0) {
 /*
-        LOG_I(PHY, "LDPC algo Kr=%d cb_cnt=%d C=%d nbRB=%d crc_type %d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d maxIter %d\n",
+        LOG_D(PHY, "LDPC algo Kr=%d cb_cnt=%d C=%d nbRB=%d crc_type %d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d maxIter %d\n",
                             Kr,r,harq_process->C,harq_process->nb_rb,crc_type,A,harq_process->TBS,
                             harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round,dlsch->max_ldpc_iterations);
 */
@@ -1133,11 +1149,13 @@ uint32_t  nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
         pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j]));
       }
 
-      for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++)
+      j+=(harq_process->F>>3);
+      //      for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++)
+      for (i=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++,j++)
       {
         pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j]));
       }
-
+      
       for (i=0, j=0; j < ((kc*p_decParams->Z)>>4);  i+=2, j++)
       {
         pl[j] = _mm_packs_epi16(pv[i],pv[i+1]);
@@ -1222,7 +1240,7 @@ uint32_t  nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
 
   if (err_flag == 1) {
 #if UE_DEBUG_TRACE
-    LOG_I(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n",
+    LOG_D(PHY,"[UE %d] DLSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d, mcs %d) Kr %d r %d harq_process->round %d\n",
         phy_vars_ue->Mod_id, frame, nr_tti_rx, harq_pid,harq_process->status, harq_process->round,harq_process->TBS,harq_process->mcs,Kr,r,harq_process->round);
 #endif
     harq_process->harq_ack.ack = 0;
@@ -1246,7 +1264,7 @@ uint32_t  nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
     return((1+dlsch->max_ldpc_iterations));
   } else {
 #if UE_DEBUG_TRACE
-      LOG_I(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d TBS %d mcs %d nb_rb %d\n",
+      LOG_D(PHY,"[UE %d] DLSCH: Setting ACK for nr_tti_rx %d TBS %d mcs %d nb_rb %d\n",
            phy_vars_ue->Mod_id,nr_tti_rx,harq_process->TBS,harq_process->mcs,harq_process->nb_rb);
 #endif
 
@@ -1336,7 +1354,7 @@ void nr_dlsch_decoding_process(void *arg)
     t_nrLDPC_dec_params* p_decParams = &decParams;
     t_nrLDPC_time_stats procTime;
     t_nrLDPC_time_stats* p_procTime =&procTime ;
-    int8_t llrProcBuf[OAI_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32)));
+    int8_t llrProcBuf[NR_LDPC_MAX_NUM_LLR] __attribute__ ((aligned(32)));
     t_nrLDPC_procBuf* p_nrLDPC_procBuf; 
     int16_t z [68*384];
     int8_t l [68*384];
@@ -1372,7 +1390,6 @@ void nr_dlsch_decoding_process(void *arg)
   uint32_t A,E;
   uint32_t G;
   uint32_t ret,offset;
-//  short dummy_w[MAX_NUM_DLSCH_SEGMENTS][3*(8448+64)];
   uint32_t r,r_offset=0,Kr,Kr_bytes,err_flag=0,K_bytes_F;
   uint8_t crc_type;
   uint8_t C,Cprime;
@@ -1425,7 +1442,7 @@ void nr_dlsch_decoding_process(void *arg)
   harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, harq_process->Qm,harq_process->Nl);
   G = harq_process->G;
 
-  LOG_I(PHY,"DLSCH Decoding process, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb);
+  LOG_D(PHY,"DLSCH Decoding process, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch,nb_rb);
 
   if ((harq_process->R)<1024)
     Coderate = (float) (harq_process->R) /(float) 1024;
@@ -1465,7 +1482,7 @@ void nr_dlsch_decoding_process(void *arg)
   }    
 
   harq_process->round  =0;
-  if (harq_process->round == 0) {
+ // if (harq_process->round == 0) {
     // This is a new packet, so compute quantities regarding segmentation
 	if (A > 3824)
 	  harq_process->B = A+24;
@@ -1483,7 +1500,7 @@ void nr_dlsch_decoding_process(void *arg)
 
     p_decParams->Z = harq_process->Z;
 
-    }
+   // }
     
     //printf("round %d Z %d K %d BG %d\n", harq_process->round, p_decParams->Z, harq_process->K, p_decParams->BG);
 
@@ -1501,20 +1518,15 @@ void nr_dlsch_decoding_process(void *arg)
   //r_offset = 0;
 
   /*
-  unsigned char bw_scaling =1;
+  uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS;  //number of segments to be allocated
 
-  switch (frame_parms->N_RB_DL) {
-  case 106:
-    bw_scaling =2;
-    break;
+  if (nb_rb != 273) {
+    a_segments = a_segments*nb_rb;
+    a_segments = a_segments/273;
+  }  
 
-  default:
-    bw_scaling =1;
-    break;
-  }
-
-  if (harq_process->C > MAX_NUM_DLSCH_SEGMENTS/bw_scaling) {
-    LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_DLSCH_SEGMENTS/bw_scaling);
+  if (harq_process->C > a_segments) {
+    LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,a_segments);
     return((1+dlsch->max_ldpc_iterations));
   }*/
 #ifdef DEBUG_DLSCH_DECODING
@@ -1595,7 +1607,9 @@ void nr_dlsch_decoding_process(void *arg)
                                  harq_process->C,
                                  harq_process->rvidx,
                                  (harq_process->round==0)?1:0,
-                                 E)==-1) {
+                                 E,
+				 harq_process->F,
+				 Kr-harq_process->F-2*(p_decParams->Z))==-1) {
 #if UE_TIMING_TRACE
       stop_meas(dlsch_rate_unmatching_stats);
 #endif
@@ -1644,7 +1658,7 @@ void nr_dlsch_decoding_process(void *arg)
 
     if (err_flag == 0) {
 /*
-        LOG_I(PHY, "turbo algo Kr=%d cb_cnt=%d C=%d nbRB=%d crc_type %d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d maxIter %d\n",
+        LOG_D(PHY, "turbo algo Kr=%d cb_cnt=%d C=%d nbRB=%d crc_type %d TBSInput=%d TBSHarq=%d TBSplus24=%d mcs=%d Qm=%d RIV=%d round=%d maxIter %d\n",
                             Kr,r,harq_process->C,harq_process->nb_rb,crc_type,A,harq_process->TBS,
                             harq_process->B,harq_process->mcs,harq_process->Qm,harq_process->rvidx,harq_process->round,dlsch->max_ldpc_iterations);
 */
@@ -1656,10 +1670,11 @@ void nr_dlsch_decoding_process(void *arg)
         start_meas(dlsch_turbo_decoding_stats);
 #endif
 //      LOG_D(PHY,"AbsSubframe %d.%d Start turbo segment %d/%d \n",frame%1024,subframe,r,harq_process->C-1);
-
-        /*for (int cnt =0; cnt < (kc-2)*p_decParams->Z; cnt++){
+/*
+        for (int cnt =0; cnt < (kc-2)*p_decParams->Z; cnt++){
               inv_d[cnt] = (1)*harq_process->d[r][cnt];
-              }*/
+              }
+*/
 
         memset(pv,0,2*p_decParams->Z*sizeof(int16_t));
         //memset(pl,0,2*p_decParams->Z*sizeof(int8_t));
@@ -1670,9 +1685,11 @@ void nr_dlsch_decoding_process(void *arg)
           pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j]));
         }
 
-        for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++)
+        j+=(harq_process->F>>3);
+        //      for (i=Kr_bytes,j=K_bytes_F-((2*p_decParams->Z)>>3); i < ((kc*p_decParams->Z)>>3); i++, j++)
+        for (i=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++,j++)
         {
-          pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j]));
+         pv[i]= _mm_loadu_si128((__m128i*)(&harq_process->d[r][8*j]));
         }
 
         for (i=0, j=0; j < ((kc*p_decParams->Z)>>4);  i+=2, j++)
@@ -1688,16 +1705,16 @@ void nr_dlsch_decoding_process(void *arg)
 
         // Fixme: correct type is unsigned, but nrLDPC_decoder and all called behind use signed int
         if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) {
-          printf("Segment %u CRC OK\n",r);
+          LOG_D(PHY,"Segment %u CRC OK\n",r);
           ret = 2;
         }
         else {
-          printf("Segment %d CRC NOK\n",r);
+          LOG_D(PHY,"Segment %u CRC NOK\n",r);
           ret = 1+dlsch->max_ldpc_iterations;
         }
 
     if (no_iteration_ldpc > 10)
-      printf("Error number of iteration LPDC %d\n", no_iteration_ldpc);
+      LOG_D(PHY,"Error number of iteration LPDC %d\n", no_iteration_ldpc);
     //else
       //printf("OK number of iteration LPDC %d\n", no_iteration_ldpc);
 
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c
index 1089c085421..c704efdb1fd 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c
@@ -101,16 +101,16 @@ static void nr_dlsch_layer_demapping(int16_t **llr_cw,
 				     int16_t **llr_layers);
 
 int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
-             PDSCH_t type,
-             unsigned char eNB_id,
-             unsigned char eNB_id_i, //if this == ue->n_connected_eNB, we assume MU interference
-             uint32_t frame,
-             uint8_t nr_tti_rx,
-             unsigned char symbol,
-             unsigned char first_symbol_flag,
-             RX_type_t rx_type,
-             unsigned char i_mod,
-             unsigned char harq_pid)
+		PDSCH_t type,
+		unsigned char eNB_id,
+		unsigned char eNB_id_i, //if this == ue->n_connected_eNB, we assume MU interference
+		uint32_t frame,
+		uint8_t nr_tti_rx,
+		unsigned char symbol,
+		unsigned char first_symbol_flag,
+		RX_type_t rx_type,
+		unsigned char i_mod,
+		unsigned char harq_pid)
 {
 
   NR_UE_COMMON *common_vars  = &ue->common_vars;
@@ -151,7 +151,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
   //int16_t  *pllr_symbol_cw1_deint;
   uint32_t llr_offset_symbol;
   //uint16_t bundle_L = 2;
-  uint8_t l0 =2, pilots=0;
+  uint8_t pilots=0;
   uint16_t n_tx=1, n_rx=1;
   int32_t median[16];
   uint32_t len;
@@ -234,7 +234,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
 
   start_rb = dlsch0_harq->start_rb;
   nb_rb_pdsch =  dlsch0_harq->nb_rb;
-  l0 = dlsch0_harq->start_symbol;
 
   DevAssert(dlsch0_harq);
   round = dlsch0_harq->round;
@@ -286,9 +285,9 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
   printf("Demod  dlsch0_harq->pmi_alloc %d\n",  dlsch0_harq->pmi_alloc);
 #endif
 
-  pilots = (symbol==l0) ? 1 : 0;
+  pilots = ((1<<symbol)&dlsch0_harq->dlDmrsSymbPos)>0 ? 1 : 0;
 
-  if (frame_parms->nb_antenna_ports_eNB>1 && beamforming_mode==0) {
+  if (frame_parms->nb_antenna_ports_gNB>1 && beamforming_mode==0) {
 #ifdef DEBUG_DLSCH_MOD
     LOG_I(PHY,"dlsch: using pmi %x (%p)\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),dlsch[0]);
 #endif
@@ -297,19 +296,19 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
     start_meas(&ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot]);
 #endif
     nb_rb = nr_dlsch_extract_rbs_dual(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF,
-    							   pdsch_vars[eNB_id]->dl_ch_estimates,
-                                   pdsch_vars[eNB_id]->rxdataF_ext,
-                                   pdsch_vars[eNB_id]->dl_ch_estimates_ext,
-                                   dlsch0_harq->pmi_alloc,
-                                   pdsch_vars[eNB_id]->pmi_ext,
-                                   symbol,
-								   pilots,
-								   start_rb,
-								   nb_rb_pdsch,
-                                   nr_tti_rx,
-                                   ue->high_speed_flag,
-                                   frame_parms,
-                                   dlsch0_harq->mimo_mode);
+				      pdsch_vars[eNB_id]->dl_ch_estimates,
+				      pdsch_vars[eNB_id]->rxdataF_ext,
+				      pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+				      dlsch0_harq->pmi_alloc,
+				      pdsch_vars[eNB_id]->pmi_ext,
+				      symbol,
+				      pilots,
+				      start_rb,
+				      nb_rb_pdsch,
+				      nr_tti_rx,
+				      ue->high_speed_flag,
+				      frame_parms,
+				      dlsch0_harq->mimo_mode);
 #ifdef DEBUG_DLSCH_MOD
       printf("dlsch: using pmi %lx, pmi_ext ",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc));
        for (rb=0;rb<nb_rb;rb++)
@@ -349,21 +348,21 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
                                        frame_parms,
                                        dlsch0_harq->mimo_mode);
     }
-  } else if (beamforming_mode==0) { //else if nb_antennas_ports_eNB==1 && beamforming_mode == 0
+  } else if (beamforming_mode==0) { //else if nb_antennas_ports_gNB==1 && beamforming_mode == 0
 		  //printf("start nr dlsch extract nr_tti_rx %d thread id %d \n", nr_tti_rx, ue->current_thread_id[nr_tti_rx]);
     nb_rb = nr_dlsch_extract_rbs_single(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF,
-                                     pdsch_vars[eNB_id]->dl_ch_estimates,
-                                     pdsch_vars[eNB_id]->rxdataF_ext,
-                                     pdsch_vars[eNB_id]->dl_ch_estimates_ext,
-                                     dlsch0_harq->pmi_alloc,
-                                     pdsch_vars[eNB_id]->pmi_ext,
-                                     symbol,
-									 pilots,
-									 start_rb,
-									 nb_rb_pdsch,
-                                     nr_tti_rx,
-                                     ue->high_speed_flag,
-                                     frame_parms);
+					pdsch_vars[eNB_id]->dl_ch_estimates,
+					pdsch_vars[eNB_id]->rxdataF_ext,
+					pdsch_vars[eNB_id]->dl_ch_estimates_ext,
+					dlsch0_harq->pmi_alloc,
+					pdsch_vars[eNB_id]->pmi_ext,
+					symbol,
+					pilots,
+					start_rb,
+					nb_rb_pdsch,
+					nr_tti_rx,
+					ue->high_speed_flag,
+					frame_parms);
 
   } /*else if(beamforming_mode>7) {
     LOG_W(PHY,"dlsch_demodulation: beamforming mode not supported yet.\n");
@@ -375,31 +374,31 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
     return(-1);
   }
 
-  len = (symbol==l0)? (nb_rb*6):(nb_rb*12);
-
+  len = (pilots==1)? (nb_rb*6):(nb_rb*12);
+  
 #if UE_TIMING_TRACE
-    stop_meas(&ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot]);
+  stop_meas(&ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot]);
 #if DISABLE_LOG_X
-    printf("[AbsSFN %u.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",
-    		frame,nr_tti_rx,slot,symbol,ue->high_speed_flag,type,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0));
+  printf("[AbsSFN %u.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",
+	 frame,nr_tti_rx,slot,symbol,ue->high_speed_flag,type,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0));
 #else
-    LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",
-    		frame,nr_tti_rx,slot,symbol,ue->high_speed_flag,type,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0));
+  LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d Flag %d type %d: Pilot/Data extraction %5.2f \n",
+	frame,nr_tti_rx,slot,symbol,ue->high_speed_flag,type,ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot].p_time/(cpuf*1000.0));
 #endif
 #endif
-
+  
 #if UE_TIMING_TRACE
-    start_meas(&ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot]);
+  start_meas(&ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot]);
 #endif
-  n_tx = frame_parms->nb_antenna_ports_eNB;
+  n_tx = frame_parms->nb_antenna_ports_gNB;
   n_rx = frame_parms->nb_antennas_rx;
-
+  
   nr_dlsch_scale_channel(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
-                      frame_parms,
-                      dlsch,
-                      symbol,
-					  pilots,
-                      nb_rb);
+			 frame_parms,
+			 dlsch,
+			 symbol,
+			 pilots,
+			 nb_rb);
 
 #if UE_TIMING_TRACE
     stop_meas(&ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot]);
@@ -417,17 +416,17 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
     if (beamforming_mode==0){
       if (dlsch0_harq->mimo_mode<NR_DUALSTREAM) {
         nr_dlsch_channel_level(pdsch_vars[eNB_id]->dl_ch_estimates_ext,
-                           frame_parms,
-                           avg,
-                           symbol,
-						   len,
-                           nb_rb);
+			       frame_parms,
+			       avg,
+			       symbol,
+			       len,
+			       nb_rb);
         avgs = 0;
-        for (aatx=0;aatx<frame_parms->nb_antenna_ports_eNB;aatx++)
+        for (aatx=0;aatx<frame_parms->nb_antenna_ports_gNB;aatx++)
           for (aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++)
             avgs = cmax(avgs,avg[(aatx<<1)+aarx]);
 
-        pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2)+1;
+        pdsch_vars[eNB_id]->log2_maxh = (log2_approx(avgs)/2)+3;
      }
      else if (dlsch0_harq->mimo_mode == NR_DUALSTREAM)
      {
@@ -450,14 +449,14 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
 
      }
     }
-#ifdef UE_DEBUG_TRACE
-    LOG_I(PHY,"[DLSCH] AbsSubframe %d.%d log2_maxh = %d [log2_maxh0 %d log2_maxh1 %d] (%d,%d)\n",
-            frame%1024,nr_tti_rx, pdsch_vars[eNB_id]->log2_maxh,
-                                                 pdsch_vars[eNB_id]->log2_maxh0,
-                                                 pdsch_vars[eNB_id]->log2_maxh1,
-                                                 avg[0],avgs);
+    //#ifdef UE_DEBUG_TRACE
+    LOG_D(PHY,"[DLSCH] AbsSubframe %d.%d log2_maxh = %d [log2_maxh0 %d log2_maxh1 %d] (%d,%d)\n",
+	  frame%1024,nr_tti_rx, pdsch_vars[eNB_id]->log2_maxh,
+	  pdsch_vars[eNB_id]->log2_maxh0,
+	  pdsch_vars[eNB_id]->log2_maxh1,
+	  avg[0],avgs);
     //LOG_D(PHY,"[DLSCH] mimo_mode = %d\n", dlsch0_harq->mimo_mode);
-#endif
+    //#endif
 
     //wait until pdcch is decoded
     //proc->channel_level = 1;
@@ -648,13 +647,14 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
 #endif
 
 #if UE_TIMING_TRACE
+
     start_meas(&ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot]);
 #endif
   //printf("LLR dlsch0_harq->Qm %d rx_type %d cw0 %d cw1 %d symbol %d \n",dlsch0_harq->Qm,rx_type,codeword_TB0,codeword_TB1,symbol);
   // compute LLRs
   // -> // compute @pointer where llrs should filled for this ofdm-symbol
 
-  pdsch_vars[eNB_id]->llr_offset[l0-1] = 0;
+    if (first_symbol_flag==1) pdsch_vars[eNB_id]->llr_offset[symbol-1] = 0;
   llr_offset_symbol = pdsch_vars[eNB_id]->llr_offset[symbol-1];
   //pllr_symbol_cw0_deint  = (int8_t*)pdsch_vars[eNB_id]->llr[0];
   //pllr_symbol_cw1_deint  = (int8_t*)pdsch_vars[eNB_id]->llr[1];
@@ -1148,7 +1148,7 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext,
   __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b;
   QAM_amp128b = _mm_setzero_si128();
 
-  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) {
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_gNB; aatx++) {
     if (mod_order == 4) {
       QAM_amp128 = _mm_set1_epi16(QAM16_n1);  // 2/sqrt(10)
       QAM_amp128b = _mm_setzero_si128();
@@ -1400,7 +1400,7 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext,
   symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
 
   if ((symbol_mod == 0) || (symbol_mod == (4-frame_parms->Ncp))) {
-    if (frame_parms->nb_antenna_ports_eNB==1) { // 10 out of 12 so don't reduce size
+    if (frame_parms->nb_antenna_ports_gNB==1) { // 10 out of 12 so don't reduce size
       nb_rb=1+(5*nb_rb/6);
     }
     else {
@@ -1408,7 +1408,7 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext,
     }
   }
 
-  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) {
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_gNB; aatx++) {
     if (mod_order == 4) {
       QAM_amp128  = vmovq_n_s16(QAM16_n1);  // 2/sqrt(10)
       QAM_amp128b = vmovq_n_s16(0);
@@ -1789,11 +1789,11 @@ void nr_dlsch_channel_compensation_core(int **rxdataF_ext,
 
 
 void nr_dlsch_scale_channel(int **dl_ch_estimates_ext,
-                         NR_DL_FRAME_PARMS *frame_parms,
-                         NR_UE_DLSCH_t **dlsch_ue,
-                         uint8_t symbol,
-						 uint8_t pilots,
-                         unsigned short nb_rb)
+			    NR_DL_FRAME_PARMS *frame_parms,
+			    NR_UE_DLSCH_t **dlsch_ue,
+			    uint8_t symbol,
+			    uint8_t pilots,
+			    unsigned short nb_rb)
 {
 
 #if defined(__x86_64__)||defined(__i386__)
@@ -1809,14 +1809,14 @@ void nr_dlsch_scale_channel(int **dl_ch_estimates_ext,
 
   // Determine scaling amplitude based the symbol
 
-ch_amp = 1024*8; //((pilots) ? (dlsch_ue[0]->sqrt_rho_b) : (dlsch_ue[0]->sqrt_rho_a));
+  ch_amp = 1024*8; //((pilots) ? (dlsch_ue[0]->sqrt_rho_b) : (dlsch_ue[0]->sqrt_rho_a));
 
     LOG_D(PHY,"Scaling PDSCH Chest in OFDM symbol %d by %d, pilots %d nb_rb %d NCP %d symbol %d\n",symbol,ch_amp,pilots,nb_rb,frame_parms->Ncp,symbol);
    // printf("Scaling PDSCH Chest in OFDM symbol %d by %d\n",symbol_mod,ch_amp);
 
   ch_amp128 = _mm_set1_epi16(ch_amp); // Q3.13
 
-  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) {
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_gNB; aatx++) {
     for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
 
       dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*nb_rb*12];
@@ -1849,11 +1849,11 @@ ch_amp = 1024*8; //((pilots) ? (dlsch_ue[0]->sqrt_rho_b) : (dlsch_ue[0]->sqrt_rh
 
 //compute average channel_level on each (TX,RX) antenna pair
 void nr_dlsch_channel_level(int **dl_ch_estimates_ext,
-                         NR_DL_FRAME_PARMS *frame_parms,
-                         int32_t *avg,
-                         uint8_t symbol,
-						 uint32_t len,
-                         unsigned short nb_rb)
+			    NR_DL_FRAME_PARMS *frame_parms,
+			    int32_t *avg,
+			    uint8_t symbol,
+			    uint32_t len,
+			    unsigned short nb_rb)
 {
 
 #if defined(__x86_64__)||defined(__i386__)
@@ -1864,10 +1864,11 @@ void nr_dlsch_channel_level(int **dl_ch_estimates_ext,
 
   //nb_rb*nre = y * 2^x
   int16_t x = factor2(len);
+  //x = (x>4) ? 4 : x;
   int16_t y = (len)>>x;
-  //printf("nb_rb*nre = %d = %d * 2^(%d)\n",nb_rb*nre,y,x);
+  //printf("len = %d = %d * 2^(%d)\n",len,y,x);
 
-  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++)
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_gNB; aatx++)
     for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
       //clear average level
       avg128D = _mm_setzero_si128();
@@ -1876,29 +1877,10 @@ void nr_dlsch_channel_level(int **dl_ch_estimates_ext,
       dl_ch128=(__m128i *)&dl_ch_estimates_ext[(aatx<<1)+aarx][symbol*nb_rb*12];
 
       for (rb=0;rb<nb_rb;rb++) {
-        //      printf("rb %d : ",rb);
-        //      print_shorts("ch",&dl_ch128[0]);
 	avg128D = _mm_add_epi32(avg128D,_mm_srai_epi16(_mm_madd_epi16(dl_ch128[0],dl_ch128[0]),x));
 	avg128D = _mm_add_epi32(avg128D,_mm_srai_epi16(_mm_madd_epi16(dl_ch128[1],dl_ch128[1]),x));
-
-        //avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[0],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[0], coeff128),15)));
-        //avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[1],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[1], coeff128),15)));
-
-	    /*if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
-          dl_ch128+=2;
-        }
-        else {*/
-	  avg128D = _mm_add_epi32(avg128D,_mm_srai_epi16(_mm_madd_epi16(dl_ch128[2],dl_ch128[2]),x));
-          //avg128D = _mm_add_epi32(avg128D,_mm_madd_epi16(dl_ch128[2],_mm_srai_epi16(_mm_mulhi_epi16(dl_ch128[2], coeff128),15)));
-          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]);
-          }
-        */
+	avg128D = _mm_add_epi32(avg128D,_mm_srai_epi16(_mm_madd_epi16(dl_ch128[2],dl_ch128[2]),x));
+	dl_ch128+=3;
       }
 
       avg[(aatx<<1)+aarx] =(((int32_t*)&avg128D)[0] +
@@ -1920,7 +1902,7 @@ void nr_dlsch_channel_level(int **dl_ch_estimates_ext,
 
   symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
 
-  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++)
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_gNB; aatx++)
     for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
       //clear average level
       avg128D = vdupq_n_s32(0);
@@ -1936,7 +1918,7 @@ void nr_dlsch_channel_level(int **dl_ch_estimates_ext,
         avg128D = vqaddq_s32(avg128D,vmull_s16(dl_ch128[2],dl_ch128[2]));
         avg128D = vqaddq_s32(avg128D,vmull_s16(dl_ch128[3],dl_ch128[3]));
 
-        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_eNB!=1)) {
+        if (((symbol_mod == 0) || (symbol_mod == (frame_parms->Ncp-1)))&&(frame_parms->nb_antenna_ports_gNB!=1)) {
           dl_ch128+=4;
         } else {
           avg128D = vqaddq_s32(avg128D,vmull_s16(dl_ch128[4],dl_ch128[4]));
@@ -2030,7 +2012,7 @@ void nr_dlsch_channel_level_median(int **dl_ch_estimates_ext,
   int32x4_t norm128D;
   int16x4_t *dl_ch128;
 
-  for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++){
+  for (aatx=0; aatx<frame_parms->nb_antenna_ports_gNB; aatx++){
     for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
       max = 0;
       min = 0;
@@ -2602,7 +2584,7 @@ void dump_dlsch2(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t nr_tti_rx,unsigned int *
     write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*nsymb,1,1);
   }
 
-  if (ue->frame_parms.nb_antenna_ports_eNB == 2) {
+  if (ue->frame_parms.nb_antenna_ports_gNB == 2) {
     sprintf(fname,"dlsch%d_ch_r%d_ext10.m",eNB_id,round);
     sprintf(vname,"dl%d_ch_r%d_ext10",eNB_id,round);
     write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb,1,1);
@@ -2636,7 +2618,7 @@ void dump_dlsch2(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t nr_tti_rx,unsigned int *
   sprintf(fname,"dlsch%d_rxF_r%d_comp0.m",eNB_id,round);
   sprintf(vname,"dl%d_rxF_r%d_comp0",eNB_id,round);
   write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_comp0[0],12*N_RB_DL*nsymb,1,1);
-  if (ue->frame_parms.nb_antenna_ports_eNB == 2) {
+  if (ue->frame_parms.nb_antenna_ports_gNB == 2) {
     sprintf(fname,"dlsch%d_rxF_r%d_comp1.m",eNB_id,round);
     sprintf(vname,"dl%d_rxF_r%d_comp1",eNB_id,round);
     write_output(fname,vname,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_comp1[harq_pid][round][0],12*N_RB_DL*nsymb,1,1);
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c
index 35458f330f4..ce1c0df156a 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c
@@ -980,7 +980,7 @@ void nr_dlsch_64qam_llr_SIC(NR_DL_FRAME_PARMS *frame_parms,
 
     if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
       amp_tmp = 0x1fff;//dlsch0->sqrt_rho_b; already taken into account
-      if (frame_parms->nb_antenna_ports_eNB!=1)
+      if (frame_parms->nb_antenna_ports_gNB!=1)
         len = nb_rb*8 - (2*pbch_pss_sss_adjust/3);
       else
         len = nb_rb*10 - (5*pbch_pss_sss_adjust/6);
@@ -1379,7 +1379,7 @@ int nr_dlsch_qpsk_16qam_llr(NR_DL_FRAME_PARMS *frame_parms,
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->nb_antenna_ports_eNB!=1)
+    if (frame_parms->nb_antenna_ports_gNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -1661,7 +1661,7 @@ int nr_dlsch_qpsk_64qam_llr(NR_DL_FRAME_PARMS *frame_parms,
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->nb_antenna_ports_eNB!=1)
+    if (frame_parms->nb_antenna_ports_gNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -2427,7 +2427,7 @@ int nr_dlsch_16qam_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms,
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->nb_antenna_ports_eNB!=1)
+    if (frame_parms->nb_antenna_ports_gNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -3602,7 +3602,7 @@ int nr_dlsch_16qam_64qam_llr(NR_DL_FRAME_PARMS *frame_parms,
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->nb_antenna_ports_eNB!=1)
+    if (frame_parms->nb_antenna_ports_gNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -5164,7 +5164,7 @@ int nr_dlsch_64qam_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms,
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->nb_antenna_ports_eNB!=1)
+    if (frame_parms->nb_antenna_ports_gNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
@@ -6707,7 +6707,7 @@ int nr_dlsch_64qam_16qam_llr(NR_DL_FRAME_PARMS *frame_parms,
 
   if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) {
     // if symbol has pilots
-    if (frame_parms->nb_antenna_ports_eNB!=1)
+    if (frame_parms->nb_antenna_ports_gNB!=1)
       // in 2 antenna ports we have 8 REs per symbol per RB
       len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3);
     else
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c
index fc4fff1c409..61748a8e562 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c
@@ -176,7 +176,7 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini
   
   if (ret==0) {
     
-    frame_parms->nb_antenna_ports_eNB = 1; //pbch_tx_ant;
+    frame_parms->nb_antenna_ports_gNB = 1; //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);
@@ -213,17 +213,8 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode,
   NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
   int ret=-1;
   int rx_power=0; //aarx,
-  //nfapi_nr_config_request_t* config;
-
-  int n_ssb_crb=(fp->N_RB_DL-20);
-  // First try TDD normal prefix, mu 1
-  fp->Ncp=NORMAL;
-  fp->frame_type=TDD;
-  // FK: added N_RB_DL paramter here as this function shares code with the gNB where it is needed. We should rewrite this function for the UE. 
-  nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,fp->N_RB_DL,n_ssb_crb,0);
-  LOG_D(PHY,"nr_initial sync ue RB_DL %d\n", fp->N_RB_DL);
-
 
+  LOG_D(PHY,"nr_initial sync ue RB_DL %d\n", fp->N_RB_DL);
 
   /*   Initial synchronisation
    *
@@ -264,7 +255,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode,
 	double s_time = 1/(1.0e3*fp->samples_per_subframe);  // sampling time
 	double off_angle = -2*M_PI*s_time*(ue->common_vars.freq_offset);  // offset rotation angle compensation per sample
 
-	int start = ue->ssb_offset;  // start for offset correction is at ssb_offset (pss time position)
+	int start = is*fp->samples_per_frame+ue->ssb_offset;  // start for offset correction is at ssb_offset (pss time position)
   	int end = start + 4*(fp->ofdm_symbol_size + fp->nb_prefix_samples);  // loop over samples in 4 symbols (ssb size), including prefix  
 
 	for(int n=start; n<end; n++){  	
@@ -290,10 +281,10 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode,
     /* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */
 
       for(int i=0; i<4;i++)
-        nr_slot_fep(ue,
+        nr_slot_fep_init_sync(ue,
 	            i,
 	            0,
-	            ue->ssb_offset,
+	            is*fp->samples_per_frame+ue->ssb_offset,
 	            0);
 
 #ifdef DEBUG_INITIAL_SYNCH
@@ -312,7 +303,13 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode,
         // sync at symbol ue->symbol_offset
         // computing the offset wrt the beginning of the frame
         sync_pos_frame = (fp->ofdm_symbol_size + fp->nb_prefix_samples0)+((ue->symbol_offset)-1)*(fp->ofdm_symbol_size + fp->nb_prefix_samples);
-        ue->rx_offset = ue->ssb_offset - sync_pos_frame;
+
+        if (ue->ssb_offset < sync_pos_frame)
+          ue->rx_offset = fp->samples_per_frame - sync_pos_frame + ue->ssb_offset;
+        else
+          ue->rx_offset = ue->ssb_offset - sync_pos_frame;
+
+        ue->init_sync_frame = is;
       }   
 
       nr_gold_pdcch(ue,0, 2);
@@ -406,7 +403,7 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode,
 	  fp->N_RB_DL,
 	  fp->phich_config_common.phich_duration,
 	  phich_string[fp->phich_config_common.phich_resource],
-	  fp->nb_antenna_ports_eNB);*/
+	  fp->nb_antenna_ports_gNB);*/
 
 #if defined(OAI_USRP) || defined(EXMIMO) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
     LOG_I(PHY, "[UE %d] Measured Carrier Frequency %.0f Hz (offset %d Hz)\n",
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c
index 0e7bedfb78d..60306d8e53b 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c
@@ -430,7 +430,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
   //uint32_t pbch_a_prime;
   int16_t *pbch_e_rx;
   uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output;
-  uint8_t nushift,n_hf,ssb_index;
+  uint8_t nushift;
   uint16_t M;
   uint8_t Lmax=frame_parms->Lmax; 
   //uint16_t crc;
@@ -538,7 +538,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
   uint32_t unscrambling_mask = (Lmax==64)?0x100006D:0x1000041;
   nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0);
   //polar decoding de-rate matching
-  const t_nrPolar_params *currentPtr = nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
+  const t_nrPolar_params *currentPtr = nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL,1,&ue->polarList);
   decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&nr_ue_pbch_vars->pbch_a_prime,0,currentPtr);
 
   if(decoderState) return(decoderState);
@@ -578,15 +578,21 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
   for (int i=0; i<3; i++)
     decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff);
 
-  n_hf = ((nr_ue_pbch_vars->xtra_byte>>4)&0x01); // computing the half frame index from the extra byte
+  frame_parms->half_frame_bit = ((nr_ue_pbch_vars->xtra_byte>>4)&0x01); // computing the half frame index from the extra byte
 
-  ssb_index = i_ssb;  // ssb index corresponds to i_ssb for Lmax = 4,8
+  frame_parms->ssb_index = i_ssb;  // ssb index corresponds to i_ssb for Lmax = 4,8
   if (Lmax == 64) {   // for Lmax = 64 ssb index 4th,5th and 6th bits are in extra byte
     for (int i=0; i<3; i++)
-      ssb_index += (((nr_ue_pbch_vars->xtra_byte>>(7-i))&0x01)<<(3+i));
+      frame_parms->ssb_index += (((nr_ue_pbch_vars->xtra_byte>>(7-i))&0x01)<<(3+i));
   }
 
-  ue->symbol_offset = nr_get_ssb_start_symbol(frame_parms, ssb_index, n_hf);
+  ue->symbol_offset = nr_get_ssb_start_symbol(frame_parms);
+
+  uint8_t frame_number_4lsb = 0;
+  for (int i=0; i<4; i++)
+    frame_number_4lsb |= ((nr_ue_pbch_vars->xtra_byte>>i)&1)<<(3-i);
+
+  proc->decoded_frame_rx = frame_number_4lsb;
 
 #ifdef DEBUG_PBCH
   printf("xtra_byte %x payload %x\n", nr_ue_pbch_vars->xtra_byte, payload);
@@ -602,7 +608,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
     
   dl_indication.rx_ind = &rx_ind; //  hang on rx_ind instance
   dl_indication.dci_ind = NULL; 
-  dl_indication.proc=proc;        // needed to signal back the frame number -> FIXME
+  dl_indication.proc=proc;
   dl_indication.module_id=0;
   dl_indication.cc_id=proc->CC_id;
 
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c
index f4f4ac89266..f4071190247 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c
@@ -30,20 +30,11 @@
  * \warning
  */
 #include "PHY/sse_intrin.h"
-//#include "PHY/defs_common.h"
-//#include "PHY/phy_extern.h"
-//#include "PHY/phy_extern_ue.h"
 #include "common/utils/LOG/vcd_signal_dumper.h"
 
-//#include "PHY/defs.h"
 #include "PHY/impl_defs_nr.h"
-//#include "PHY/defs_nr_common.h"
 #include "PHY/defs_nr_UE.h"
-#include "PHY/NR_UE_TRANSPORT/nr_prach.h"
 #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h"
-//#include "PHY/extern.h"
-//#include "LAYER2/MAC/extern.h"
-//#include "PHY/NR_UE_TRANSPORT/pucch_nr.h"
 
 #include "common/utils/LOG/log.h"
 #include "common/utils/LOG/vcd_signal_dumper.h"
@@ -52,514 +43,27 @@
 
 
 
-#define NR_PRACH_DEBUG 1
 
+extern uint16_t NCS_unrestricted_delta_f_RA_125[16];
+extern uint16_t NCS_restricted_TypeA_delta_f_RA_125[15];
+extern uint16_t NCS_restricted_TypeB_delta_f_RA_125[13];
+extern uint16_t NCS_unrestricted_delta_f_RA_5[16];
+extern uint16_t NCS_restricted_TypeA_delta_f_RA_5[16];
+extern uint16_t NCS_restricted_TypeB_delta_f_RA_5[14];
+extern uint16_t NCS_unrestricted_delta_f_RA_15[16];
+extern uint16_t prach_root_sequence_map_0_3[838];
+extern uint16_t prach_root_sequence_map_abc[138];
+extern int64_t table_6_3_3_2_2_prachConfig_Index [256][9];
+extern int64_t table_6_3_3_2_3_prachConfig_Index [256][9];
+extern int64_t table_6_3_3_2_4_prachConfig_Index [256][10];
+extern uint16_t nr_du[838];
+extern int16_t nr_ru[2*839];
 
 
 
-void dump_nr_prach_config(NR_DL_FRAME_PARMS *frame_parms,uint8_t subframe)
-{
-
-  FILE *fd;
-
-  fd = fopen("prach_config.txt","w");
-  fprintf(fd,"prach_config: subframe          = %d\n",subframe);
-  fprintf(fd,"prach_config: N_RB_UL           = %d\n",frame_parms->N_RB_UL);
-  fprintf(fd,"prach_config: frame_type        = %s\n",(frame_parms->frame_type==1) ? "TDD":"FDD");
-
-  if(frame_parms->frame_type==1) fprintf(fd,"prach_config: tdd_config        = %d\n",frame_parms->tdd_config);
-
-  fprintf(fd,"prach_config: rootSequenceIndex = %d\n",frame_parms->prach_config_common.rootSequenceIndex);
-  fprintf(fd,"prach_config: prach_ConfigIndex = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex);
-  fprintf(fd,"prach_config: Ncs_config        = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig);
-  fprintf(fd,"prach_config: highSpeedFlag     = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.highSpeedFlag);
-  fprintf(fd,"prach_config: n_ra_prboffset    = %d\n",frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset);
-  fclose(fd);
-
-}
-
-// This function computes the du
-void nr_fill_du(uint8_t prach_fmt)
-{
-
-  uint16_t iu,u,p;
-  uint16_t N_ZC;
-  uint16_t *prach_root_sequence_map;
-
-  if (prach_fmt<4) {
-    N_ZC = 839;
-    prach_root_sequence_map = prach_root_sequence_map_0_3;
-  } else {
-    N_ZC = 139;
-    prach_root_sequence_map = prach_root_sequence_map_abc;
-  }
-
-  for (iu=0; iu<(N_ZC-1); iu++) {
-
-    u=prach_root_sequence_map[iu];
-    p=1;
-
-    while (((u*p)%N_ZC)!=1)
-      p++;
-
-    nr_du[u] = ((p<(N_ZC>>1)) ? p : (N_ZC-p));
-  }
-
-}
-
-#if 0
-uint8_t get_num_prach_tdd(module_id_t Mod_id)
-{
-  NR_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][0]->frame_parms;
-  return(tdd_preamble_map[fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex][fp->tdd_config].num_prach);
-}
-
-uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index)
-{
-  NR_DL_FRAME_PARMS *fp = &PHY_vars_UE_g[Mod_id][0]->frame_parms;
-  return(tdd_preamble_map[fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex][fp->tdd_config].map[tdd_map_index].f_ra);
-}
-#endif
-
-uint16_t get_nr_prach_fmt(uint8_t prach_ConfigIndex)
-{
-  //return (table_6_3_3_2_2_prachConfig_Index[prach_ConfigIndex][0]); // if using table 6.3.3.2-2: Random access configurations for FR1 and paired spectrum/supplementary uplink
-  return (table_6_3_3_2_3_prachConfig_Index[prach_ConfigIndex][0]); // if using table 6.3.3.2-3: Random access configurations for FR1 and unpaired spectrum
-  // For FR2 not implemented. FIXME
-}
-
-#if 0
-uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type)
-{
-
-  if (frame_type == FDD) // FDD
-    return(prach_ConfigIndex>>4);
-
-  else {
-    if (prach_ConfigIndex < 20)
-      return (0);
-
-    if (prach_ConfigIndex < 30)
-      return (1);
-
-    if (prach_ConfigIndex < 40)
-      return (2);
-
-    if (prach_ConfigIndex < 48)
-      return (3);
-    else
-      return (4);
-  }
-}
-
-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, uint16_t prach_fmt)
-{
-  lte_frame_type_t frame_type         = frame_parms->frame_type;
-  uint8_t tdd_config         = frame_parms->tdd_config;
-
-  uint8_t n_ra_prb;
-  uint8_t f_ra,t1_ra;
-  uint8_t Nsp=2;
-
-  if (frame_type == TDD) { // TDD
-
-    if (tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach==0) {
-      LOG_E(PHY, "Illegal prach_ConfigIndex %"PRIu8"", prach_ConfigIndex);
-      return(-1);
-    }
-
-    // adjust n_ra_prboffset for frequency multiplexing (p.36 36.211)
-    f_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[tdd_mapindex].f_ra;
 
-    if (prach_fmt < 4) {
-      if ((f_ra&1) == 0) {
-        n_ra_prb = n_ra_prboffset + 6*(f_ra>>1);
-      } else {
-        n_ra_prb = frame_parms->N_RB_UL - 6 - n_ra_prboffset + 6*(f_ra>>1);
-      }
-    } else {
-      if ((tdd_config >2) && (tdd_config<6))
-        Nsp = 2;
-
-      t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra;
-
-      if ((((Nf&1)*(2-Nsp)+t1_ra)&1) == 0) {
-        n_ra_prb = 6*f_ra;
-      } else {
-        n_ra_prb = frame_parms->N_RB_UL - 6*(f_ra+1);
-      }
-    }
-  }
-  else { //FDD
-    n_ra_prb = n_ra_prboffset;
-  }
-  return(n_ra_prb);
-}
-#endif //0
-
-int is_nr_prach_subframe(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t subframe) {
 
-  uint8_t prach_ConfigIndex  = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
-/*
-  // For FR1 paired
-  if (((frame%table_6_3_3_2_2_prachConfig_Index[prach_ConfigIndex][2]) == table_6_3_3_2_2_prachConfig_Index[prach_ConfigIndex][3]) &&
-      ((table_6_3_3_2_2_prachConfig_Index[prach_ConfigIndex][4]&(1<<subframe)) == 1)) {
-    // using table 6.3.3.2-2: Random access configurations for FR1 and paired spectrum/supplementary uplink
-    return(1);
-  } else {
-    return(0);
-  }
-*/
-  // For FR1 unpaired
-  if (((frame%table_6_3_3_2_3_prachConfig_Index[prach_ConfigIndex][2]) == table_6_3_3_2_3_prachConfig_Index[prach_ConfigIndex][3]) &&
-      ((table_6_3_3_2_3_prachConfig_Index[prach_ConfigIndex][4]&(1<<subframe)) == 1)) {
-    // using table 6.3.3.2-2: Random access configurations for FR1 and unpaired
-    return(1);
-  } else {
-    return(0);
-  }
-/*
-  // For FR2: FIXME
-  if ((((frame%table_6_3_3_2_4_prachConfig_Index[prach_ConfigIndex][2]) == table_6_3_3_2_4_prachConfig_Index[prach_ConfigIndex][3]) ||
-       ((frame%table_6_3_3_2_4_prachConfig_Index[prach_ConfigIndex][2]) == table_6_3_3_2_4_prachConfig_Index[prach_ConfigIndex][4]))
-       &&
-       ((table_6_3_3_2_4_prachConfig_Index[prach_ConfigIndex][5]&(1<<subframe)) == 1)) {
-    // using table 6.3.3.2-2: Random access configurations for FR1 and unpaired
-    return(1);
-  } else {
-    return(0);
-  }
-*/
-}
 
-#if 0
-int is_prach_subframe0(NR_DL_FRAME_PARMS *frame_parms,uint8_t prach_ConfigIndex,uint32_t frame, uint8_t subframe)
-{
-  //  uint8_t prach_ConfigIndex  = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
-  uint8_t tdd_config         = frame_parms->tdd_config;
-  uint8_t t0_ra;
-  uint8_t t1_ra;
-  uint8_t t2_ra;
-
-  int prach_mask = 0;
-
-  if (frame_parms->frame_type == FDD) { //FDD
-    //implement Table 5.7.1-2 from 36.211 (Rel-10, p.41)
-    if ((((frame&1) == 1) && (subframe < 9)) ||
-        (((frame&1) == 0) && (subframe == 9)))  // This is an odd frame, ignore even-only PRACH frames
-      if (((prach_ConfigIndex&0xf)<3) || // 0,1,2,16,17,18,32,33,34,48,49,50
-          ((prach_ConfigIndex&0x1f)==18) || // 18,50
-          ((prach_ConfigIndex&0xf)==15))   // 15,47
-        return(0);
-
-    switch (prach_ConfigIndex&0x1f) {
-    case 0:
-    case 3:
-      if (subframe==1) prach_mask = 1;
-      break;
-
-    case 1:
-    case 4:
-      if (subframe==4) prach_mask = 1;
-      break;
-
-    case 2:
-    case 5:
-      if (subframe==7) prach_mask = 1;
-      break;
-
-    case 6:
-      if ((subframe==1) || (subframe==6)) prach_mask=1;
-      break;
-
-    case 7:
-      if ((subframe==2) || (subframe==7)) prach_mask=1;
-      break;
-
-    case 8:
-      if ((subframe==3) || (subframe==8)) prach_mask=1;
-      break;
-
-    case 9:
-      if ((subframe==1) || (subframe==4) || (subframe==7)) prach_mask=1;
-      break;
-
-    case 10:
-      if ((subframe==2) || (subframe==5) || (subframe==8)) prach_mask=1;
-      break;
-
-    case 11:
-      if ((subframe==3) || (subframe==6) || (subframe==9)) prach_mask=1;
-      break;
-
-    case 12:
-      if ((subframe&1)==0) prach_mask=1;
-      break;
-
-    case 13:
-      if ((subframe&1)==1) prach_mask=1;
-      break;
-
-    case 14:
-      prach_mask=1;
-      break;
-
-    case 15:
-      if (subframe==9) prach_mask=1;
-      break;
-    }
-  } else { // TDD
-
-    AssertFatal(prach_ConfigIndex<64,
-		"Illegal prach_ConfigIndex %d for ",prach_ConfigIndex);
-    AssertFatal(tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach>0,
-		"Illegal prach_ConfigIndex %d for ",prach_ConfigIndex);
-
-    t0_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t0_ra;
-    t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra;
-    t2_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t2_ra;
-#ifdef PRACH_DEBUG
-    LOG_I(PHY,"[PRACH] Checking for PRACH format (ConfigIndex %d) in TDD subframe %d (%d,%d,%d)\n",
-          prach_ConfigIndex,
-          subframe,
-          t0_ra,t1_ra,t2_ra);
-#endif
-
-    if ((((t0_ra == 1) && ((frame &1)==0))||  // frame is even and PRACH is in even frames
-         ((t0_ra == 2) && ((frame &1)==1))||  // frame is odd and PRACH is in odd frames
-         (t0_ra == 0)) &&                                // PRACH is in all frames
-        (((subframe<5)&&(t1_ra==0)) ||                   // PRACH is in 1st half-frame
-         (((subframe>4)&&(t1_ra==1))))) {                // PRACH is in 2nd half-frame
-      if ((prach_ConfigIndex<48) &&                          // PRACH only in normal UL subframe
-	  (((subframe%5)-2)==t2_ra)) prach_mask=1;
-      else if ((prach_ConfigIndex>47) && (((subframe%5)-1)==t2_ra)) prach_mask=1;      // PRACH can be in UpPTS
-    }
-  }
-
-  return(prach_mask);
-}
-
-int is_prach_subframe(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t subframe) {
-  
-  uint8_t prach_ConfigIndex  = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
-  int prach_mask             = is_prach_subframe0(frame_parms,prach_ConfigIndex,frame,subframe);
-
-  int i;
-
-  for (i=0;i<4;i++) {
-    if (frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[i] == 1) 
-      prach_mask|=(is_prach_subframe0(frame_parms,frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[i],frame,subframe)<<(i+1));
-  }
-  return(prach_mask);
-}
-#endif //0
-
-void compute_nr_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])
-{
-
-  // Compute DFT of x_u => X_u[k] = x_u(inv(u)*k)^* X_u[k] = exp(j\pi u*inv(u)*k*(inv(u)*k+1)/N_ZC)
-  unsigned int k,inv_u,i,NCS=0,num_preambles;
-  int N_ZC;
-  uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type);
-  uint16_t *prach_root_sequence_map;
-  uint16_t u, preamble_offset;
-  uint16_t n_shift_ra,n_shift_ra_bar, d_start,numshift;
-  uint8_t not_found;
-
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_COMPUTE_PRACH, VCD_FUNCTION_IN);
-
-#ifdef PRACH_DEBUG
-  LOG_I(PHY,"compute_prach_seq: NCS_config %d, prach_fmt %d\n",zeroCorrelationZoneConfig, prach_fmt);
-#endif
-
-  AssertFatal(prach_fmt<4,
-	      "PRACH sequence is only precomputed for prach_fmt<4 (have %"PRIu8")\n", prach_fmt );
-  N_ZC = (prach_fmt < 4) ? 839 : 139;
-  //init_prach_tables(N_ZC); //moved to phy_init_lte_ue/eNB, since it takes to long in real-time
-
-  if (prach_fmt < 4) {
-    prach_root_sequence_map = prach_root_sequence_map_0_3;
-  } else {
-    // FIXME cannot be reached
-    prach_root_sequence_map = prach_root_sequence_map_abc;
-  }
-
-
-#ifdef PRACH_DEBUG
-  LOG_I( PHY, "compute_prach_seq: done init prach_tables\n" );
-#endif
-
-
-
-
-  int restricted_Type = 0; //this is hardcoded ('0' for restricted_TypeA; and '1' for restricted_TypeB). FIXME
-  if (highSpeedFlag== 0) {
-
-#ifdef PRACH_DEBUG
-    LOG_I(PHY,"Low speed prach : NCS_config %d\n",zeroCorrelationZoneConfig);
-#endif
-
-    AssertFatal(zeroCorrelationZoneConfig<=15,
-		"FATAL, Illegal Ncs_config for unrestricted format %"PRIu8"\n", zeroCorrelationZoneConfig );
-    if (prach_fmt<3)  NCS = NCS_unrestricted_delta_f_RA_125[zeroCorrelationZoneConfig];
-    if (prach_fmt==3) NCS = NCS_unrestricted_delta_f_RA_5[zeroCorrelationZoneConfig];
-    if (prach_fmt>3)  NCS = NCS_unrestricted_delta_f_RA_15[zeroCorrelationZoneConfig];
-
-    num_preambles = (NCS==0) ? 64 : ((64*NCS)/N_ZC);
-
-    if (NCS>0) num_preambles++;
-
-    preamble_offset = 0;
-  } else {
-
-#ifdef PRACH_DEBUG
-    LOG_I( PHY, "high speed prach : NCS_config %"PRIu8"\n", zeroCorrelationZoneConfig );
-#endif
-
-    AssertFatal(zeroCorrelationZoneConfig<=14,
-		"FATAL, Illegal Ncs_config for restricted format %"PRIu8"\n", zeroCorrelationZoneConfig );
-    if (prach_fmt<3){
-        if (restricted_Type == 0) NCS = NCS_restricted_TypeA_delta_f_RA_125[zeroCorrelationZoneConfig]; // for TypeA, this is hardcoded. FIXME
-        if (restricted_Type == 1) NCS = NCS_restricted_TypeB_delta_f_RA_125[zeroCorrelationZoneConfig]; // for TypeB, this is hardcoded. FIXME
-    }
-    if (prach_fmt==3){
-        if (restricted_Type == 0) NCS = NCS_restricted_TypeA_delta_f_RA_5[zeroCorrelationZoneConfig]; // for TypeA, this is hardcoded. FIXME
-        if (restricted_Type == 1) NCS = NCS_restricted_TypeB_delta_f_RA_5[zeroCorrelationZoneConfig]; // for TypeB, this is hardcoded. FIXME
-    }
-    if (prach_fmt>3){
-
-    }
-    //NCS = NCS_restricted[zeroCorrelationZoneConfig];
-    nr_fill_du(prach_fmt);
-
-    num_preambles = 64; // compute ZC sequence for 64 possible roots
-    // find first non-zero shift root (stored in preamble_offset)
-    not_found = 1;
-    preamble_offset = 0;
-
-    while (not_found == 1) {
-      // current root depending on rootSequenceIndex
-      int index = (rootSequenceIndex + preamble_offset) % N_ZC;
-
-      if (prach_fmt<4) {
-        // prach_root_sequence_map points to prach_root_sequence_map0_3
-        DevAssert( index < sizeof(prach_root_sequence_map_0_3) / sizeof(prach_root_sequence_map_0_3[0]) );
-      } else {
-        // prach_root_sequence_map points to prach_root_sequence_map4
-        DevAssert( index < sizeof(prach_root_sequence_map_abc) / sizeof(prach_root_sequence_map_abc[0]) );
-      }
-
-      u = prach_root_sequence_map[index];
-
-      uint16_t n_group_ra = 0;
-
-      if ( (nr_du[u]<(N_ZC/3)) && (nr_du[u]>=NCS) ) {
-        n_shift_ra     = nr_du[u]/NCS;
-        d_start        = (nr_du[u]<<1) + (n_shift_ra * NCS);
-        n_group_ra     = N_ZC/d_start;
-        n_shift_ra_bar = max(0,(N_ZC-(nr_du[u]<<1)-(n_group_ra*d_start))/N_ZC);
-      } else if  ( (nr_du[u]>=(N_ZC/3)) && (nr_du[u]<=((N_ZC - NCS)>>1)) ) {
-        n_shift_ra     = (N_ZC - (nr_du[u]<<1))/NCS;
-        d_start        = N_ZC - (nr_du[u]<<1) + (n_shift_ra * NCS);
-        n_group_ra     = nr_du[u]/d_start;
-        n_shift_ra_bar = min(n_shift_ra,max(0,(nr_du[u]- (n_group_ra*d_start))/NCS));
-      } else {
-        n_shift_ra     = 0;
-        n_shift_ra_bar = 0;
-      }
-
-      // This is the number of cyclic shifts for the current root u
-      numshift = (n_shift_ra*n_group_ra) + n_shift_ra_bar;
-
-      // skip to next root and recompute parameters if numshift==0
-      if (numshift>0)
-        not_found = 0;
-      else
-        preamble_offset++;
-    }
-  }
-
-#ifdef PRACH_DEBUG
-
-  if (NCS>0)
-    LOG_I( PHY, "Initializing %u preambles for PRACH (NCS_config %"PRIu8", NCS %u, N_ZC/NCS %u)\n",
-           num_preambles, zeroCorrelationZoneConfig, NCS, N_ZC/NCS );
-
-#endif
-
-  for (i=0; i<num_preambles; i++) {
-    int index = (rootSequenceIndex+i+preamble_offset) % N_ZC;
-
-    if (prach_fmt<4) {
-      // prach_root_sequence_map points to prach_root_sequence_map0_3
-      DevAssert( index < sizeof(prach_root_sequence_map_0_3) / sizeof(prach_root_sequence_map_0_3[0]) );
-    } else {
-      // prach_root_sequence_map points to prach_root_sequence_map4
-      DevAssert( index < sizeof(prach_root_sequence_map_abc) / sizeof(prach_root_sequence_map_abc[0]) );
-    }
-
-    u = prach_root_sequence_map[index];
-
-    inv_u = nr_ZC_inv[u]; // multiplicative inverse of u
-
-
-    // X_u[0] stores the first ZC sequence where the root u has a non-zero number of shifts
-    // for the unrestricted case X_u[0] is the first root indicated by the rootSequenceIndex
-
-    for (k=0; k<N_ZC; k++) {
-      // 420 is the multiplicative inverse of 2 (required since ru is exp[j 2\pi n])
-      X_u[i][k] = ((uint32_t*)nr_ru)[(((k*(1+(inv_u*k)))%N_ZC)*420)%N_ZC];
-    }
-  }
-
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_UE_COMPUTE_PRACH, VCD_FUNCTION_OUT);
-
-}
-
-void init_nr_prach_tables(int N_ZC)
-{
-
-  int i,m;
-
-  // Compute the modular multiplicative inverse 'iu' of u s.t. iu*u = 1 mod N_ZC
-  nr_ZC_inv[0] = 0;
-  nr_ZC_inv[1] = 1;
-
-  for (i=2; i<N_ZC; i++) {
-    for (m=2; m<N_ZC; m++)
-      if (((i*m)%N_ZC) == 1) {
-        nr_ZC_inv[i] = m;
-        break;
-      }
-
-#ifdef PRACH_DEBUG
-
-    if (i<16)
-      printf("i %d : inv %d\n",i,nr_ZC_inv[i]);
-
-#endif
-  }
-
-  // Compute quantized roots of unity
-  for (i=0; i<N_ZC; i++) {
-    nr_ru[i<<1]     = (int16_t)(floor(32767.0*cos(2*M_PI*(double)i/N_ZC)));
-    nr_ru[1+(i<<1)] = (int16_t)(floor(32767.0*sin(2*M_PI*(double)i/N_ZC)));
-#ifdef PRACH_DEBUG
-
-    if (i<16)
-      printf("i %d : runity %d,%d\n",i,nr_ru[i<<1],nr_ru[1+(i<<1)]);
-
-#endif
-  }
-}
 
 
 int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, uint16_t Nf )
@@ -567,32 +71,30 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
 
   //lte_frame_type_t frame_type         = ue->frame_parms.frame_type;
   //uint8_t tdd_config         = ue->frame_parms.tdd_config;
-  uint16_t rootSequenceIndex = ue->frame_parms.prach_config_common.rootSequenceIndex;
-  uint8_t prach_ConfigIndex  = ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
-  uint8_t Ncs_config         = ue->frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig;
-  uint8_t restricted_set     = ue->frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag;
-  //uint8_t n_ra_prboffset     = ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset;
+  NR_DL_FRAME_PARMS *fp=&ue->frame_parms;
+  uint16_t rootSequenceIndex = fp->prach_config_common.rootSequenceIndex;
+  uint8_t prach_ConfigIndex  = fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
+  uint8_t Ncs_config         = fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig;
+  uint8_t restricted_set     = fp->prach_config_common.prach_ConfigInfo.highSpeedFlag;
   uint8_t preamble_index     = ue->prach_resources[eNB_id]->ra_PreambleIndex;
   //uint8_t tdd_mapindex       = ue->prach_resources[eNB_id]->ra_TDD_map_index;
   int16_t *prachF           = ue->prach_vars[eNB_id]->prachF;
-  static int16_t prach_tmp[45600*4] __attribute__((aligned(32)));
+  int16_t prach_tmp[98304*2*4] __attribute__((aligned(32)));
   int16_t *prach            = prach_tmp;
   int16_t *prach2;
   int16_t amp               = ue->prach_vars[eNB_id]->amp;
   int16_t Ncp;
-  uint8_t n_ra_prb;
   uint16_t NCS=0;
   uint16_t *prach_root_sequence_map;
   uint16_t preamble_offset,preamble_shift;
   uint16_t preamble_index0,n_shift_ra,n_shift_ra_bar;
   uint16_t d_start,numshift;
 
-  uint16_t prach_fmt = get_nr_prach_fmt(prach_ConfigIndex);
+  uint16_t prach_fmt = get_nr_prach_fmt(prach_ConfigIndex,fp->frame_type,fp->freq_range);
   //uint8_t Nsp=2;
   //uint8_t f_ra,t1_ra;
   uint16_t N_ZC = (prach_fmt<4)?839:139;
   uint8_t not_found;
-  int k;
   int16_t *Xu;
   uint16_t u;
   int32_t Xu_re,Xu_im;
@@ -601,9 +103,9 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
   int i, prach_len=0;
   uint16_t first_nonzero_root_idx=0;
 
-#if defined(EXMIMO) || defined(OAI_USRP)
-  prach_start =  (ue->rx_offset+subframe*ue->frame_parms.samples_per_tti-ue->hw_timing_advance-ue->N_TA_offset);
-#ifdef PRACH_DEBUG
+#if defined(OAI_USRP)
+  prach_start =  (ue->rx_offset+subframe*fp->samples_per_subframe-ue->hw_timing_advance-ue->N_TA_offset);
+#ifdef NR_PRACH_DEBUG
     LOG_I(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id,
         prach_start,
         ue->rx_offset,
@@ -612,14 +114,14 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
 #endif
 
   if (prach_start<0)
-    prach_start+=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME);
+    prach_start+=(fp->samples_per_subframe*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME);
 
-  if (prach_start>=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME))
-    prach_start-=(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME);
+  if (prach_start>=(fp->samples_per_subframe*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME))
+    prach_start-=(fp->samples_per_subframe*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME);
 
 #else //normal case (simulation)
-  prach_start = subframe*ue->frame_parms.samples_per_tti-ue->N_TA_offset;
-  LOG_I(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id,
+  prach_start = subframe*fp->samples_per_subframe-ue->N_TA_offset;
+  LOG_D(PHY,"[UE %d] prach_start %d, rx_offset %d, hw_timing_advance %d, N_TA_offset %d\n", ue->Mod_id,
     prach_start,
     ue->rx_offset,
     ue->hw_timing_advance,
@@ -657,47 +159,8 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
     NCS = NCS_unrestricted_delta_f_RA_15[Ncs_config];
   }
 
-  n_ra_prb = ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset;
-//  n_ra_prb = get_nr_prach_prb_offset(&(ue->frame_parms),
-//                                     ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex,
-//                                     ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset,
-//                                     tdd_mapindex,
-//                                     Nf,
-//                                     prach_fmt);
   prach_root_sequence_map = (prach_fmt<4) ? prach_root_sequence_map_0_3 : prach_root_sequence_map_abc;
 
-  /*
-  // this code is not part of get_prach_prb_offset
-  if (frame_type == TDD) { // TDD
-
-    if (tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach==0) {
-      LOG_E( PHY, "[PHY][UE %"PRIu8"] Illegal prach_ConfigIndex %"PRIu8" for ", ue->Mod_id, prach_ConfigIndex );
-    }
-
-    // adjust n_ra_prboffset for frequency multiplexing (p.36 36.211)
-    f_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[tdd_mapindex].f_ra;
-
-    if (prach_fmt < 4) {
-      if ((f_ra&1) == 0) {
-        n_ra_prb = n_ra_prboffset + 6*(f_ra>>1);
-      } else {
-        n_ra_prb = ue->frame_parms.N_RB_UL - 6 - n_ra_prboffset + 6*(f_ra>>1);
-      }
-    } else {
-      if ((tdd_config >2) && (tdd_config<6))
-        Nsp = 2;
-
-      t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra;
-
-      if ((((Nf&1)*(2-Nsp)+t1_ra)&1) == 0) {
-        n_ra_prb = 6*f_ra;
-      } else {
-        n_ra_prb = ue->frame_parms.N_RB_UL - 6*(f_ra+1);
-      }
-    }
-  }
-  */
-
   // This is the relative offset (for unrestricted case) in the root sequence table (5.7.2-4 from 36.211) for the given preamble index
   preamble_offset = ((NCS==0)? preamble_index : (preamble_index/(N_ZC/NCS)));
 
@@ -707,7 +170,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
     preamble_shift *= NCS;
   } else { // This is the high-speed case
 
-#ifdef PRACH_DEBUG
+#ifdef NR_PRACH_DEBUG
     LOG_I(PHY,"[UE %d] High-speed mode, NCS_config %d\n",ue->Mod_id,Ncs_config);
 #endif
 
@@ -766,36 +229,75 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
   }
 
   // now generate PRACH signal
-#ifdef PRACH_DEBUG
+#ifdef NR_PRACH_DEBUG
 
   if (NCS>0)
-    LOG_I(PHY,"Generate PRACH for RootSeqIndex %d, Preamble Index %d, NCS %d (NCS_config %d, N_ZC/NCS %d) n_ra_prb %d: Preamble_offset %d, Preamble_shift %d\n",
-          rootSequenceIndex,preamble_index,NCS,Ncs_config,N_ZC/NCS,n_ra_prb,
+    LOG_D(PHY,"Generate PRACH for RootSeqIndex %d, Preamble Index %d, PRACH Format %x, prach_ConfigIndex %d, NCS %d (NCS_config %d, N_ZC/NCS %d): Preamble_offset %d, Preamble_shift %d\n",
+          rootSequenceIndex,preamble_index,prach_fmt,prach_ConfigIndex,NCS,Ncs_config,N_ZC/NCS,
           preamble_offset,preamble_shift);
 
 #endif
 
   //  nsymb = (frame_parms->Ncp==0) ? 14:12;
   //  subframe_offset = (unsigned int)frame_parms->ofdm_symbol_size*subframe*nsymb;
+  int kbar = 1;
+  int K    = 24;
+  if (prach_fmt == 3) { 
+    K=4;
+    kbar=10;
+  }
+  else if (prach_fmt > 3) {
+    // Note: Assumes that PRACH SCS is same as PUSCH SCS
+    K=1;
+    kbar=2;
+  }
+  int n_ra_prb            = fp->prach_config_common.prach_ConfigInfo.msg1_frequencystart;
+  int k                   = (12*n_ra_prb) - 6*fp->N_RB_UL;
+
+  k = (12*n_ra_prb) - 6*fp->N_RB_UL;
 
-  k = (12*n_ra_prb) - 6*ue->frame_parms.N_RB_UL;
+  if (k<0) k+=fp->ofdm_symbol_size;
 
-  if (k<0)
-    k+=ue->frame_parms.ofdm_symbol_size;
+  k*=K;
+  k+=kbar;
 
-  k*=12;
-  k+=13;
+  LOG_D(PHY,"placing prach in position %d\n",k);
+  k*=2;
 
   Xu = (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx];
 
-  /*
-    k+=(12*ue->frame_parms.first_carrier_offset);
-    if (k>(12*ue->frame_parms.ofdm_symbol_size))
-    k-=(12*ue->frame_parms.ofdm_symbol_size);
-  */
-  k*=2;
+  /********************************************************
+   *
+   * In function init_prach_tables:
+   * to compute quantized roots of unity ru(n) = 32767 * exp j*[ (2 * PI * n) / N_ZC ]
+   *
+   * In compute_prach_seq:
+   * to calculate Xu = DFT xu = xu (inv_u*k) * Xu[0] (This is a Zadoff-Chou sequence property: DFT ZC sequence is another ZC sequence)
+   *
+   * In generate_prach:
+   * to do the cyclic-shifted DFT by multiplying Xu[k] * ru[k*preamble_shift] as:
+   * If X[k] = DFT x(n) -> X_shifted[k] = DFT x(n+preamble_shift) = X[k] * exp -j*[ (2*PI*k*preamble_shift) / N_ZC ]
+   *
+   *********************************************************/
+
+  AssertFatal(prach_fmt>3,"prach_fmt<=3: Fix this for other formats\n");
+  int dftlen=2048;
+  if (fp->N_RB_UL >= 137) dftlen=4096;
+  if (fp->threequarter_fs==1) dftlen=(3*dftlen)/4;
 
-  switch (ue->frame_parms.N_RB_UL) {
+  for (offset=0,offset2=0; offset<N_ZC; offset++,offset2+=preamble_shift) {
+
+    if (offset2 >= N_ZC)
+      offset2 -= N_ZC;
+
+    Xu_re = (((int32_t)Xu[offset<<1]*amp)>>15);
+    Xu_im = (((int32_t)Xu[1+(offset<<1)]*amp)>>15);
+    prachF[k++]= ((Xu_re*nr_ru[offset2<<1]) - (Xu_im*nr_ru[1+(offset2<<1)]))>>15;
+    prachF[k++]= ((Xu_im*nr_ru[offset2<<1]) + (Xu_re*nr_ru[1+(offset2<<1)]))>>15;
+    if (k==dftlen) k=0;
+  }
+
+  switch (fp->N_RB_UL) {
   case 6:
     memset((void*)prachF,0,4*1536);
     break;
@@ -817,7 +319,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
     break;
 
   case 100:
-    if (ue->frame_parms.threequarter_fs == 0)
+    if (fp->threequarter_fs == 0)
       memset((void*)prachF,0,4*24576);
     else
       memset((void*)prachF,0,4*18432);
@@ -828,34 +330,6 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
     break;
 }
 
-  /********************************************************
-   *
-   * In function init_prach_tables:
-   * to compute quantized roots of unity ru(n) = 32767 * exp j*[ (2 * PI * n) / N_ZC ]
-   *
-   * In compute_prach_seq:
-   * to calculate Xu = DFT xu = xu (inv_u*k) * Xu[0] (This is a Zadoff-Chou sequence property: DFT ZC sequence is another ZC sequence)
-   *
-   * In generate_prach:
-   * to do the cyclic-shifted DFT by multiplying Xu[k] * ru[k*preamble_shift] as:
-   * If X[k] = DFT x(n) -> X_shifted[k] = DFT x(n+preamble_shift) = X[k] * exp -j*[ (2*PI*k*preamble_shift) / N_ZC ]
-   *
-   *********************************************************/
-
-  for (offset=0,offset2=0; offset<N_ZC; offset++,offset2+=preamble_shift) {
-
-    if (offset2 >= N_ZC)
-      offset2 -= N_ZC;
-
-    Xu_re = (((int32_t)Xu[offset<<1]*amp)>>15);
-    Xu_im = (((int32_t)Xu[1+(offset<<1)]*amp)>>15);
-    prachF[k++]= ((Xu_re*nr_ru[offset2<<1]) - (Xu_im*nr_ru[1+(offset2<<1)]))>>15;
-    prachF[k++]= ((Xu_im*nr_ru[offset2<<1]) + (Xu_re*nr_ru[1+(offset2<<1)]))>>15;
-
-    if (k==(12*2*ue->frame_parms.ofdm_symbol_size))
-      k=0;
-  }
-
   int mu = 1; // numerology is hardcoded. FIXME!!!
   switch (prach_fmt) {
   case 0:
@@ -863,7 +337,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
     break;
 
   case 1:
-    Ncp = 21024;
+    Ncp = 2*21024;
     break;
 
   case 2:
@@ -914,254 +388,415 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
     Ncp = 3168;
     break;
   }
-#if 0 // code for LTE
-  switch (prach_fmt) {
-  case 0:
-    Ncp = 3168;
-    break;
 
-  case 1:
-  case 3:
-    Ncp = 21024;
-    break;
-
-  case 2:
-    Ncp = 6240;
-    break;
 
-  case 4:
-    Ncp = 448;
-    break;
-
-  default:
-    Ncp = 3168;
-    break;
-  }
-
-  switch (ue->frame_parms.N_RB_UL) {
-  case 6:
-    Ncp>>=4;
-    prach+=4; // makes prach2 aligned to 128-bit
-    break;
-
-  case 15:
-    Ncp>>=3;
-    break;
-
-  case 25:
-    Ncp>>=2;
-    break;
-
-  case 50:
-    Ncp>>=1;
-    break;
-
-  case 75:
-    Ncp=(Ncp*3)>>2;
-    break;
-  }
-#endif
-  if (ue->frame_parms.threequarter_fs == 1)
-    Ncp=(Ncp*3)>>2;
-
-  prach2 = prach+(Ncp<<1);
-
-  // do IDFT
-  switch (ue->frame_parms.N_RB_UL) {
-  case 6:
-    if (prach_fmt == 4) {
-      idft256(prachF,prach2,1);
-      memmove( prach, prach+512, Ncp<<2 );
-      prach_len = 256+Ncp;
-    } else {
-      idft1536(prachF,prach2,1);
-      memmove( prach, prach+3072, Ncp<<2 );
-      prach_len = 1536+Ncp;
-
-      if (prach_fmt>1) {
-        memmove( prach2+3072, prach2, 6144 );
-        prach_len = 2*1536+Ncp;
+  if (fp->N_RB_UL <= 100)
+    AssertFatal(1==0,"N_RB_UL %d not supported for NR PRACH yet\n",fp->N_RB_UL);
+  else if (fp->N_RB_UL < 137) { // 46.08 or 61.44 Ms/s
+    if (fp->threequarter_fs==0) { //61.44 Ms/s  
+      Ncp<<=1;
+      // This is after cyclic prefix (Ncp<<1 samples for 30.72 Ms/s, Ncp<<2 samples for 61.44 Ms/s
+      prach2 = prach+(Ncp<<1);
+      if (prach_fmt == 0) { //24576 samples @ 30.72 Ms/s, 49152 samples @ 61.44 Ms/s
+	idft49152(prachF,prach2,1);
+	// here we have |empty | Prach49152|
+	memmove(prach,prach+(49152<<1),(Ncp<<3));
+	// here we have |Prefix | Prach49152|
+	prach_len = 49152+Ncp;
+	dftlen=49152;
       }
-    }
-
-    break;
-
-  case 15:
-    if (prach_fmt == 4) {
-      idft512(prachF,prach2,1);
-      //TODO: account for repeated format in dft output
-      memmove( prach, prach+1024, Ncp<<2 );
-      prach_len = 512+Ncp;
-    } else {
-      idft3072(prachF,prach2,1);
-      memmove( prach, prach+6144, Ncp<<2 );
-      prach_len = 3072+Ncp;
-
-      if (prach_fmt>1) {
-        memmove( prach2+6144, prach2, 12288 );
-        prach_len = 2*3072+Ncp;
+      else if (prach_fmt == 1) { //24576 samples @ 30.72 Ms/s, 49152 samples @ 61.44 Ms/s
+	idft49152(prachF,prach2,1);
+	memmove(prach2+(49152<<1),prach2,(49152<<2));
+	// here we have |empty | Prach49152 | Prach49152|
+	memmove(prach,prach+(49152<<2),(Ncp<<3));
+	// here we have |Prefix | Prach49152 | Prach49152|
+	prach_len = (49152*2)+Ncp;
+	dftlen=49152;
       }
-    }
-
-    break;
-
-  case 25:
-  default:
-    if (prach_fmt == 4) {
-      idft1024(prachF,prach2,1);
-      memmove( prach, prach+2048, Ncp<<2 );
-      prach_len = 1024+Ncp;
-    } else {
-      idft6144(prachF,prach2,1);
-      /*for (i=0;i<6144*2;i++)
-      prach2[i]<<=1;*/
-      memmove( prach, prach+12288, Ncp<<2 );
-      prach_len = 6144+Ncp;
-
-      if (prach_fmt>1) {
-        memmove( prach2+12288, prach2, 24576 );
-        prach_len = 2*6144+Ncp;
+      else if (prach_fmt == 2) { //24576 samples @ 30.72 Ms/s, 49152 samples @ 61.44 Ms/s
+	idft49152(prachF,prach2,1);
+	memmove(prach2+(49152<<1),prach2,(49152<<2));
+	// here we have |empty | Prach49152 | Prach49152| empty49152 | empty49152
+	memmove(prach2+(49152<<2),prach2,(49152<<3));
+	// here we have |empty | Prach49152 | Prach49152| Prach49152 | Prach49152
+	memmove(prach,prach+(49152<<3),(Ncp<<3));
+	// here we have |Prefix | Prach49152 | Prach49152| Prach49152 | Prach49152
+	prach_len = (49152*4)+Ncp;
+	dftlen=49152;
       }
-    }
-
-    break;
-
-  case 50:
-    if (prach_fmt == 4) {
-      idft2048(prachF,prach2,1);
-      memmove( prach, prach+4096, Ncp<<2 );
-      prach_len = 2048+Ncp;
-    } else {
-      idft12288(prachF,prach2,1);
-      memmove( prach, prach+24576, Ncp<<2 );
-      prach_len = 12288+Ncp;
-
-      if (prach_fmt>1) {
-        memmove( prach2+24576, prach2, 49152 );
-        prach_len = 2*12288+Ncp;
+      else if (prach_fmt == 3) { // //6144 samples @ 30.72 Ms/s, 12288 samples @ 61.44 Ms/s
+	idft12288(prachF,prach2,1);
+	memmove(prach2+(12288<<1),prach2,(12288<<2));
+	// here we have |empty | Prach12288 | Prach12288| empty12288 | empty12288
+	memmove(prach2+(12288<<2),prach2,(12288<<3));
+	// here we have |empty | Prach12288 | Prach12288| Prach12288 | Prach12288
+	memmove(prach,prach+(12288<<3),(Ncp<<3));
+	// here we have |Prefix | Prach12288 | Prach12288| Prach12288 | Prach12288
+	prach_len = (12288*4)+Ncp;
+	dftlen=12288;
       }
-    }
-
-    break;
-
-  case 75:
-    if (prach_fmt == 4) {
-      idft3072(prachF,prach2,1);
-      //TODO: account for repeated format in dft output
-      memmove( prach, prach+6144, Ncp<<2 );
-      prach_len = 3072+Ncp;
-    } else {
-      idft18432(prachF,prach2,1);
-      memmove( prach, prach+36864, Ncp<<2 );
-      prach_len = 18432+Ncp;
-
-      if (prach_fmt>1) {
-        memmove( prach2+36834, prach2, 73728 );
-        prach_len = 2*18432+Ncp;
+      else if (prach_fmt == 0xa1 || prach_fmt == 0xb1 || prach_fmt == 0xc0) {
+	prach2 = prach+(Ncp<<1);
+	idft2048(prachF,prach2,1);
+	dftlen=2048;
+	// here we have |empty | Prach2048 |
+	if (prach_fmt != 0xc0) {
+	  memmove(prach2+(2048<<1),prach2,(2048<<2));
+	  prach_len = (2048*2)+Ncp;
+	}
+	else prach_len = (2048*1)+Ncp;
+	memmove(prach,prach+(2048<<1),(Ncp<<2));
+	// here we have |Prefix | Prach2048 | Prach2048 (if ! 0xc0)  | 
+      }
+      else if (prach_fmt == 0xa2 || prach_fmt == 0xb2) { // 6x2048
+	idft2048(prachF,prach2,1);
+	dftlen=2048;
+	// here we have |empty | Prach2048 |
+	memmove(prach2+(2048<<1),prach2,(2048<<2));
+	// here we have |empty | Prach2048 | Prach2048| empty2048 | empty2048 | 
+	memmove(prach2+(2048<<2),prach2,(2048<<3));
+	// here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | 
+	memmove(prach,prach+(2048<<1),(Ncp<<2));
+	// here we have |Prefix | Prach2048 |
+	prach_len = (2048*4)+Ncp; 
+      }
+      else if (prach_fmt == 0xa3 || prach_fmt == 0xb3) { // 6x2048
+	prach2 = prach+(Ncp<<1);
+	idft2048(prachF,prach2,1);
+	dftlen=2048;
+	// here we have |empty | Prach2048 |
+	memmove(prach2+(2048<<1),prach2,(2048<<2));
+	// here we have |empty | Prach2048 | Prach2048| empty2048 | empty2048 | empty2048 | empty2048
+	memmove(prach2+(2048<<2),prach2,(2048<<3));
+	// here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | empty2048 | empty2048
+	memmove(prach2+((2048<<1)*3),prach2,(2048<<3));
+	// here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048
+	memmove(prach,prach+(2048<<1),(Ncp<<2));
+	// here we have |Prefix | Prach2048 |
+	prach_len = (2048*6)+Ncp; 
+      }
+      else if (prach_fmt == 0xb4) { // 12x2048
+	idft2048(prachF,prach2,1);
+	dftlen=2048;
+	// here we have |empty | Prach2048 |
+	memmove(prach2+(2048<<1),prach2,(2048<<2));
+	// here we have |empty | Prach2048 | Prach2048| empty2048 | empty2048 | empty2048 | empty2048
+	memmove(prach2+(2048<<2),prach2,(2048<<3));
+	// here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | empty2048 | empty2048
+	memmove(prach2+(2048<<3),prach2,(2048<<3));
+	// here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048
+	memmove(prach2+(2048<<1)*6,prach2,(2048<<2)*6);
+	// here we have |empty | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048 | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048|
+	memmove(prach,prach+(2048<<1),(Ncp<<2));
+	// here we have |Prefix | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048 | Prach2048 | Prach2048| Prach2048 | Prach2048 | Prach2048 | Prach2048|
+	prach_len = (2048*12)+Ncp;
+      }
+      
+    }
+    else {     // 46.08 Ms/s
+      Ncp = (Ncp*3)/2;
+      prach2 = prach+(Ncp<<1);
+      if (prach_fmt == 0) {
+	idft36864(prachF,prach2,1);
+	dftlen=36864;
+	// here we have |empty | Prach73728|
+	memmove(prach,prach+(36864<<1),(Ncp<<2));
+	// here we have |Prefix | Prach73728|
+	prach_len = (36864*1)+Ncp;
+      }
+      else if (prach_fmt == 1) {
+	idft36864(prachF,prach2,1);
+	dftlen=36864;
+	memmove(prach2+(36864<<1),prach2,(36864<<2));
+	// here we have |empty | Prach73728 | Prach73728|
+	memmove(prach,prach+(36864<<2),(Ncp<<2));
+	// here we have |Prefix | Prach73728 | Prach73728|
+	prach_len = (36864*2)+Ncp;
+      }
+      if (prach_fmt == 2) {
+	idft36864(prachF,prach2,1);
+	dftlen=36864;
+	memmove(prach2+(36864<<1),prach2,(36864<<2));
+	// here we have |empty | Prach73728 | Prach73728| empty73728 | empty73728
+	memmove(prach2+(36864<<2),prach2,(36864<<3));
+	// here we have |empty | Prach73728 | Prach73728| Prach73728 | Prach73728
+	memmove(prach,prach+(36864<<3),(Ncp<<2));
+	// here we have |Prefix | Prach73728 | Prach73728| Prach73728 | Prach73728
+	prach_len = (36864*4)+Ncp;
+      }
+      else if (prach_fmt == 3) {
+	idft9216(prachF,prach2,1);
+	dftlen=36864;
+	memmove(prach2+(9216<<1),prach2,(9216<<2));
+	// here we have |empty | Prach9216 | Prach9216| empty9216 | empty9216
+	memmove(prach2+(9216<<2),prach2,(9216<<3));
+	// here we have |empty | Prach9216 | Prach9216| Prach9216 | Prach9216
+	memmove(prach,prach+(9216<<3),(Ncp<<2));
+	// here we have |Prefix | Prach9216 | Prach9216| Prach9216 | Prach9216
+	prach_len = (9216*4)+Ncp;
+      }
+      else if (prach_fmt == 0xa1 || prach_fmt == 0xb1 || prach_fmt == 0xc0) {
+	idft1536(prachF,prach2,1);
+	dftlen=1536;
+	// here we have |empty | Prach1536 |
+	if (prach_fmt != 0xc0)
+	  memmove(prach2+(1536<<1),prach2,(1536<<2));
+	memmove(prach,prach+(1536<<1),(Ncp<<2));
+	// here we have |Prefix | Prach1536 | Prach1536 (if ! 0xc0)  | 
+	prach_len = (1536*2)+Ncp;
       }
+      else if (prach_fmt == 0xa2 || prach_fmt == 0xb2) { // 6x1536
+	idft1536(prachF,prach2,1);
+	dftlen=1536;
+	// here we have |empty | Prach1536 |
+	memmove(prach2+(1536<<1),prach2,(1536<<2));
+	// here we have |empty | Prach1536 | Prach1536| empty1536 | empty1536 |
+	memmove(prach2+(1536<<2),prach2,(1536<<3));
+	// here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 |
+	memmove(prach,prach+(1536<<1),(Ncp<<2));
+	// here we have |Prefix | Prach1536 |
+	prach_len = (1536*4)+Ncp; 
+      }
+      else if (prach_fmt == 0xa3 || prach_fmt == 0xb3) { // 6x1536
+	idft1536(prachF,prach2,1);
+	dftlen=1536;
+	// here we have |empty | Prach1536 |
+	memmove(prach2+(1536<<1),prach2,(1536<<2));
+	// here we have |empty | Prach1536 | Prach1536| empty1536 | empty1536 | empty1536 | empty1536
+	memmove(prach2+(1536<<2),prach2,(1536<<3));
+	// here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | empty1536 | empty1536
+	memmove(prach2+((1536<<1)*3),prach2,(1536<<3));
+	// here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536
+	memmove(prach,prach+(1536<<1),(Ncp<<2));
+	// here we have |Prefix | Prach1536 | 
+	prach_len = (1536*6)+Ncp; 
+      }
+      else if (prach_fmt == 0xb4) { // 12x1536
+	idft1536(prachF,prach2,1);
+	dftlen=1536;
+	// here we have |empty | Prach1536 |
+	memmove(prach2+(1536<<1),prach2,(1536<<2));
+	// here we have |empty | Prach1536 | Prach1536| empty1536 | empty1536 | empty1536 | empty1536
+	memmove(prach2+(1536<<2),prach2,(1536<<3));
+	// here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | empty1536 | empty1536
+	memmove(prach2+(1536<<3),prach2,(1536<<3));
+	// here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536
+	memmove(prach2+(1536<<1)*6,prach2,(1536<<2)*6);
+	// here we have |empty | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536 | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536|
+	memmove(prach,prach+(1536<<1),(Ncp<<2));
+	// here we have |Prefix | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536 | Prach1536 | Prach1536| Prach1536 | Prach1536 | Prach1536 | Prach1536|
+	prach_len = (1536*12)+Ncp; 
+      }      
     }
+  }
+  else if (fp->N_RB_UL <= 273) {// 92.16 or 122.88 Ms/s
+    if (fp->threequarter_fs==0) { //122.88 Ms/s
+      Ncp<<=2;
+      prach2 = prach+(Ncp<<1);
+      if (prach_fmt == 0) { //24576 samples @ 30.72 Ms/s, 98304 samples @ 122.88 Ms/s
+	idft98304(prachF,prach2,1);
+	dftlen=98304;
+	// here we have |empty | Prach98304|
+	memmove(prach,prach+(98304<<1),(Ncp<<2));
+	// here we have |Prefix | Prach98304|
+	prach_len = (98304*1)+Ncp;
+      }
+      else if (prach_fmt == 1) {
+	idft98304(prachF,prach2,1);
+	dftlen=98304;
+	memmove(prach2+(98304<<1),prach2,(98304<<2));
+	// here we have |empty | Prach98304 | Prach98304|
+	memmove(prach,prach+(98304<<2),(Ncp<<2));
+	// here we have |Prefix | Prach98304 | Prach98304|
+	prach_len = (98304*2)+Ncp;
+      }
+      else if (prach_fmt == 2) {
+	idft98304(prachF,prach2,1);
+	dftlen=98304;
+	memmove(prach2+(98304<<1),prach2,(98304<<2));
+	// here we have |empty | Prach98304 | Prach98304| empty98304 | empty98304
+	memmove(prach2+(98304<<2),prach2,(98304<<3));
+	// here we have |empty | Prach98304 | Prach98304| Prach98304 | Prach98304
+	memmove(prach,prach+(98304<<3),(Ncp<<2));
+	// here we have |Prefix | Prach98304 | Prach98304| Prach98304 | Prach98304
+	prach_len = (98304*4)+Ncp;
+      }
+      else if (prach_fmt == 3) { // 4x6144, Ncp 3168
+	idft24576(prachF,prach2,1);
+	dftlen=24576;
+	memmove(prach2+(24576<<1),prach2,(24576<<2));
+	// here we have |empty | Prach24576 | Prach24576| empty24576 | empty24576
+	memmove(prach2+(24576<<2),prach2,(24576<<3));
+	// here we have |empty | Prach24576 | Prach24576| Prach24576 | Prach24576
+	memmove(prach,prach+(24576<<3),(Ncp<<2));
+	// here we have |Prefix | Prach24576 | Prach24576| Prach24576 | Prach24576
+	prach_len = (24576*4)+(Ncp<<1);
+      }
+      else if (prach_fmt == 0xa1 || prach_fmt == 0xb1 || prach_fmt == 0xc0) {
+	idft4096(prachF,prach2,1);
+	dftlen=4096;
+	// here we have |empty | Prach4096 |
+	if (prach_fmt != 0xc0) {
+	  memmove(prach2+(4096<<1),prach2,(4096<<2));
+	  prach_len = (4096*2)+Ncp; 
+	}
+	else 	prach_len = (4096*1)+Ncp; 
+	memmove(prach,prach+(4096<<1),(Ncp<<2));
+	// here we have |Prefix | Prach4096 | Prach4096 (if ! 0xc0)  | 
 
-    break;
-
-  case 100:
-    if (ue->frame_parms.threequarter_fs == 0) {
-      if (prach_fmt == 4) {
-        idft4096(prachF,prach2,1);
-        memmove( prach, prach+8192, Ncp<<2 );
-        prach_len = 4096+Ncp;
-      } else {
-        idft24576(prachF,prach2,1);
-        memmove( prach, prach+49152, Ncp<<2 );
-        prach_len = 24576+Ncp;
-        if (prach_fmt>1) {
-          memmove( prach2+49152, prach2, 98304 );
-          prach_len = 2* 24576+Ncp;
-        }
+      }
+      else if (prach_fmt == 0xa2 || prach_fmt == 0xb2) { // 4x4096
+	idft4096(prachF,prach2,1);
+	dftlen=4096;
+	// here we have |empty | Prach4096 |
+	memmove(prach2+(4096<<1),prach2,(4096<<2));
+	// here we have |empty | Prach4096 | Prach4096| empty4096 | empty4096 |
+	memmove(prach2+(4096<<2),prach2,(4096<<3));
+	// here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 |
+	memmove(prach,prach+(4096<<1),(Ncp<<2));
+	// here we have |Prefix | Prach4096 |
+	prach_len = (4096*4)+Ncp;  
+      }
+      else if (prach_fmt == 0xa3 || prach_fmt == 0xb3) { // 6x4096
+	idft4096(prachF,prach2,1);
+	dftlen=4096;
+	// here we have |empty | Prach4096 |
+	memmove(prach2+(4096<<1),prach2,(4096<<2));
+	// here we have |empty | Prach4096 | Prach4096| empty4096 | empty4096 | empty4096 | empty4096
+	memmove(prach2+(4096<<2),prach2,(4096<<3));
+	// here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | empty4096 | empty4096
+	memmove(prach2+((4096<<1)*3),prach2,(4096<<3));
+	// here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096
+	memmove(prach,prach+(4096<<1),(Ncp<<2));
+	// here we have |Prefix | Prach4096 | 
+	prach_len = (4096*6)+Ncp; 
+      }
+      else if (prach_fmt == 0xb4) { // 12x4096
+	idft4096(prachF,prach2,1);
+	dftlen=4096;
+	// here we have |empty | Prach4096 |
+	memmove(prach2+(4096<<1),prach2,(4096<<2));
+	// here we have |empty | Prach4096 | Prach4096| empty4096 | empty4096 | empty4096 | empty4096
+	memmove(prach2+(4096<<2),prach2,(4096<<3));
+	// here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | empty4096 | empty4096
+	memmove(prach2+(4096<<3),prach2,(4096<<3));
+	// here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096
+	memmove(prach2+(4096<<1)*6,prach2,(4096<<2)*6);
+	// here we have |empty | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096 | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096|
+	memmove(prach,prach+(4096<<1),(Ncp<<2));
+	// here we have |Prefix | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096 | Prach4096 | Prach4096| Prach4096 | Prach4096 | Prach4096 | Prach4096|
+	prach_len = (4096*12)+Ncp; 
       }
     }
-    else {
-      if (prach_fmt == 4) {
-        idft3072(prachF,prach2,1);
-        //TODO: account for repeated format in dft output
-        memmove( prach, prach+6144, Ncp<<2 );
-        prach_len = 3072+Ncp;
-      } else {
-        idft18432(prachF,prach2,1);
-        memmove( prach, prach+36864, Ncp<<2 );
-        prach_len = 18432+Ncp;
-        printf("Generated prach for 100 PRB, 3/4 sampling\n");
-        if (prach_fmt>1) {
-          memmove( prach2+36834, prach2, 73728 );
-          prach_len = 2*18432+Ncp;
-        }
+    else {     // 92.16 Ms/s
+      Ncp = (Ncp*3);
+      prach2 = prach+(Ncp<<1);
+      if (prach_fmt == 0) {
+	idft73728(prachF,prach2,1);
+	dftlen=73728;
+	// here we have |empty | Prach73728|
+	memmove(prach,prach+(73728<<1),(Ncp<<4));
+	// here we have |Prefix | Prach73728|
+	prach_len = (73728*1)+Ncp;
+      }
+      else if (prach_fmt == 1) {
+	idft73728(prachF,prach2,1);
+	dftlen=73728;
+	memmove(prach2+(73728<<1),prach2,(73728<<2));
+	// here we have |empty | Prach73728 | Prach73728|
+	memmove(prach,prach+(73728<<2),(Ncp<<4));
+	// here we have |Prefix | Prach73728 | Prach73728|
+	prach_len = (73728*2)+Ncp;
+      }
+      if (prach_fmt == 2) {
+	idft73728(prachF,prach2,1);
+	dftlen=73728;
+	memmove(prach2+(73728<<1),prach2,(73728<<2));
+	// here we have |empty | Prach73728 | Prach73728| empty73728 | empty73728
+	memmove(prach2+(73728<<2),prach2,(73728<<3));
+	// here we have |empty | Prach73728 | Prach73728| Prach73728 | Prach73728
+	memmove(prach,prach+(73728<<3),(Ncp<<4));
+	// here we have |Prefix | Prach73728 | Prach73728| Prach73728 | Prach73728
+	prach_len = (73728*4)+Ncp;
+      }
+      else if (prach_fmt == 3) {
+	idft18432(prachF,prach2,1);
+	dftlen=18432;
+	memmove(prach2+(18432<<1),prach2,(18432<<2));
+	// here we have |empty | Prach18432 | Prach18432| empty18432 | empty18432
+	memmove(prach2+(18432<<2),prach2,(18432<<3));
+	// here we have |empty | Prach18432 | Prach18432| Prach18432 | Prach18432
+	memmove(prach,prach+(18432<<3),(Ncp<<4));
+	// here we have |Prefix | Prach18432 | Prach18432| Prach18432 | Prach18432
+	prach_len = (18432*4)+Ncp;
+      }
+      else if (prach_fmt == 0xa1 || prach_fmt == 0xb1 || prach_fmt == 0xc0) {
+	idft3072(prachF,prach2,1);
+	dftlen=3072;
+	// here we have |empty | Prach3072 |
+	if (prach_fmt != 0xc0) {
+	  memmove(prach2+(3072<<1),prach2,(3072<<2));
+	  prach_len = (3072*2)+Ncp;
+	} 
+	else 	  prach_len = (3072*1)+Ncp;
+	memmove(prach,prach+(3072<<1),(Ncp<<2));
+	// here we have |Prefix | Prach3072 | Prach3072 (if ! 0xc0)  | 
+      }
+      else if (prach_fmt == 0xa3 || prach_fmt == 0xb3) { // 6x3072
+	idft3072(prachF,prach2,1);
+	dftlen=3072;
+	// here we have |empty | Prach3072 |
+	memmove(prach2+(3072<<1),prach2,(3072<<2));
+	// here we have |empty | Prach3072 | Prach3072| empty3072 | empty3072 | empty3072 | empty3072
+	memmove(prach2+(3072<<2),prach2,(3072<<3));
+	// here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | empty3072 | empty3072
+	memmove(prach2+((3072<<1)*3),prach2,(3072<<3));
+	// here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072
+	memmove(prach,prach+(3072<<1),(Ncp<<2));
+	// here we have |Prefix | Prach3072 | 
+	prach_len = (3072*6)+Ncp;
+      }
+      else if (prach_fmt == 0xa2 || prach_fmt == 0xb2) { // 4x3072
+	idft3072(prachF,prach2,1);
+	dftlen=3072;
+	// here we have |empty | Prach3072 |
+	memmove(prach2+(3072<<1),prach2,(3072<<2));
+	// here we have |empty | Prach3072 | Prach3072| empty3072 | empty3072 |
+	memmove(prach2+(3072<<2),prach2,(3072<<3));
+	// here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 |
+	memmove(prach,prach+(3072<<1),(Ncp<<2));
+	// here we have |Prefix | Prach3072 | 
+	prach_len = (3072*4)+Ncp;
+      }
+      else if (prach_fmt == 0xb4) { // 12x3072
+	idft3072(prachF,prach2,1);
+	dftlen=3072;
+	// here we have |empty | Prach3072 |
+	memmove(prach2+(3072<<1),prach2,(3072<<2));
+	// here we have |empty | Prach3072 | Prach3072| empty3072 | empty3072 | empty3072 | empty3072
+	memmove(prach2+(3072<<2),prach2,(3072<<3));
+	// here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | empty3072 | empty3072
+	memmove(prach2+(3072<<3),prach2,(3072<<3));
+	// here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072
+	memmove(prach2+(3072<<1)*6,prach2,(3072<<2)*6);
+	// here we have |empty | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072 | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072|
+	memmove(prach,prach+(3072<<1),(Ncp<<2));
+	// here we have |Prefix | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072 | Prach3072 | Prach3072| Prach3072 | Prach3072 | Prach3072 | Prach3072|
+	prach_len = (3072*12)+Ncp;
       }
     }
-    break;
+  }    
+
 
-  case 106:
-    if (prach_fmt == 0) {
-      idft24576(prachF,prach2,1);
-      memmove(prach, prach+49152, Ncp<<2);
-      prach_len = 24576+Ncp;
-    }
-    if (prach_fmt == 1) {
-      idft24576(prachF,prach2,1);
-      memmove(prach2+49152, prach2, 98304);
-      memmove(prach, prach+49152, Ncp<<2);
-      prach_len = 2 * 24576 + Ncp;
-    }
-    if (prach_fmt == 2) {
-      idft24576(prachF,prach2,1);
-      memmove(prach2+49152, prach2, 98304);
-      memmove(prach2+98304, prach2, 98304);
-      memmove(prach, prach+49152, Ncp<<2);
-      prach_len = 4 * 24576 + Ncp;
-    }
-    if (prach_fmt == 3) {
-      idft6144(prachF,prach2,1);
-      memmove(prach2+6144, prach2, 12288);
-      memmove(prach2+12288, prach2, 12288);
-      memmove(prach, prach+12288, Ncp<<2);
-      prach_len = 4 * 6144 + Ncp;
-    }
-// For FR2
-    if (prach_fmt == 0xa1) { // we consider numderology mu = 1
-      idft1024(prachF,prach2,1);
-      memmove(prach2+2048, prach2, 4096);
-      memmove(prach, prach+2048, Ncp<<2);
-      prach_len = 2 * 1024 + Ncp;
-    }
-#if 0
-    if (prach_fmt == 0xa2) {
-    }
-    if (prach_fmt == 0xa3) {
-    }
-    if (prach_fmt == 0xb1) {
-    }
-    if (prach_fmt == 0xb2) {
-    }
-    if (prach_fmt == 0xb3) {
-    }
-    if (prach_fmt == 0xb4) {
-    }
-    if (prach_fmt == 0xc0) {
-    }
-    if (prach_fmt == 0xc2) {
-    }
-#endif
-    break;
-  }
 
-  //LOG_I(PHY,"prach_len=%d\n",prach_len);
 
-//  AssertFatal(prach_fmt<4,
-//	      "prach_fmt4 not fully implemented" );
-#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
+#if defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
   int j;
-  int overflow = prach_start + prach_len - LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*ue->frame_parms.samples_per_tti;
-  LOG_I( PHY, "prach_start=%d, overflow=%d\n", prach_start, overflow );
+  int overflow = prach_start + prach_len - LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_subframe;
+  LOG_D( PHY, "prach_start=%d, overflow=%d\n", prach_start, overflow );
 
-  for (i=prach_start,j=0; i<min(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME,prach_start+prach_len); i++,j++) {
+  for (i=prach_start,j=0; i<min(fp->samples_per_subframe*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME,prach_start+prach_len); i++,j++) {
     ((int16_t*)ue->common_vars.txdata[0])[2*i] = prach[2*j];
     ((int16_t*)ue->common_vars.txdata[0])[2*i+1] = prach[2*j+1];
   }
@@ -1170,24 +805,14 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
     ((int16_t*)ue->common_vars.txdata[0])[2*i] = prach[2*j];
     ((int16_t*)ue->common_vars.txdata[0])[2*i+1] = prach[2*j+1];
   }
-#if defined(EXMIMO)
-  // handle switch before 1st TX subframe, guarantee that the slot prior to transmission is switch on
-  for (k=prach_start - (ue->frame_parms.samples_per_tti>>1) ; k<prach_start ; k++) {
-    if (k<0)
-      ue->common_vars.txdata[0][k+ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE;
-    else if (k>(ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME))
-      ue->common_vars.txdata[0][k-ue->frame_parms.samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE;
-    else
-      ue->common_vars.txdata[0][k] &= 0xFFFEFFFE;
-  }
-#endif
 #else
 
+  LOG_D( PHY, "prach_start=%d\n", prach_start);
+
   for (i=0; i<prach_len; i++) {
     ((int16_t*)(&ue->common_vars.txdata[0][prach_start]))[2*i] = prach[2*i];
     ((int16_t*)(&ue->common_vars.txdata[0][prach_start]))[2*i+1] = prach[2*i+1];
   }
-
 #endif
 
 
@@ -1195,7 +820,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
 #if defined(PRACH_WRITE_OUTPUT_DEBUG)
   LOG_M("prach_txF0.m","prachtxF0",prachF,prach_len-Ncp,1,1);
   LOG_M("prach_tx0.m","prachtx0",prach+(Ncp<<1),prach_len-Ncp,1,1);
-  LOG_M("txsig.m","txs",(int16_t*)(&ue->common_vars.txdata[0][0]),2*ue->frame_parms.samples_per_tti,1,1);
+  LOG_M("txsig.m","txs",(int16_t*)(&ue->common_vars.txdata[0][prach_start]),fp->samples_per_subframe,1,1);
   exit(-1);
 #endif
 
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.h b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.h
deleted file mode 100644
index 1e2b7580358..00000000000
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.h
+++ /dev/null
@@ -1,891 +0,0 @@
-/*
- * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The OpenAirInterface Software Alliance licenses this file to You under
- * the OAI Public License, Version 1.1  (the "License"); you may not use this file
- * except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.openairinterface.org/?page_id=698
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *-------------------------------------------------------------------------------
- * For more information about the OpenAirInterface (OAI) Software Alliance:
- *      contact@openairinterface.org
- */
-
-/*! \file PHY/LTE_TRANSPORT/prach_common.c
- * \brief Common routines for UE/eNB PRACH physical channel V8.6 2009-03
- * \author Agustin Mico Pereperez
- * \date 2018
- * \version 0.1
- * \company 
- * \email: 
- * \note
- * \warning
- */
-
-int16_t nr_ru[2*839]; // quantized roots of unity
-uint32_t nr_ZC_inv[839]; // multiplicative inverse for roots u
-uint16_t nr_du[838];
-
-/*************************************
-* The following tables defined for NR
-**************************************/
-// Table 6.3.3.1-5 (38.211) NCS for preamble formats with delta_f_RA = 1.25 KHz
-uint16_t NCS_unrestricted_delta_f_RA_125[16] = {0,13,15,18,22,26,32,38,46,59,76,93,119,167,279,419};
-uint16_t NCS_restricted_TypeA_delta_f_RA_125[15]   = {15,18,22,26,32,38,46,55,68,82,100,128,158,202,237}; // high-speed case set Type A
-uint16_t NCS_restricted_TypeB_delta_f_RA_125[13]   = {15,18,22,26,32,38,46,55,68,82,100,118,137}; // high-speed case set Type B
-
-// Table 6.3.3.1-6 (38.211) NCS for preamble formats with delta_f_RA = 5 KHz
-uint16_t NCS_unrestricted_delta_f_RA_5[16] = {0,13,26,33,38,41,49,55,64,76,93,119,139,209,279,419};
-uint16_t NCS_restricted_TypeA_delta_f_RA_5[16]   = {36,57,72,81,89,94,103,112,121,132,137,152,173,195,216,237}; // high-speed case set Type A
-uint16_t NCS_restricted_TypeB_delta_f_RA_5[14]   = {36,57,60,63,65,68,71,77,81,85,97,109,122,137}; // high-speed case set Type B
-
-// Table 6.3.3.1-7 (38.211) NCS for preamble formats with delta_f_RA = 15 * 2mu KHz where mu = {0,1,2,3}
-uint16_t NCS_unrestricted_delta_f_RA_15[16] = {0,2,4,6,8,10,12,13,15,17,19,23,27,34,46,69};
-
-//Table 6.3.3.1-3: Mapping from logical index i to sequence number u for preamble formats with L_RA = 839
-uint16_t prach_root_sequence_map_0_3[838] = {
-129, 710, 140, 699, 120, 719, 210, 629, 168, 671, 84 , 755, 105, 734, 93 , 746, 70 , 769, 60 , 779,
-2  , 837, 1  , 838, 56 , 783, 112, 727, 148, 691, 80 , 759, 42 , 797, 40 , 799, 35 , 804, 73 , 766,
-146, 693, 31 , 808, 28 , 811, 30 , 809, 27 , 812, 29 , 810, 24 , 815, 48 , 791, 68 , 771, 74 , 765,
-178, 661, 136, 703, 86 , 753, 78 , 761, 43 , 796, 39 , 800, 20 , 819, 21 , 818, 95 , 744, 202, 637,
-190, 649, 181, 658, 137, 702, 125, 714, 151, 688, 217, 622, 128, 711, 142, 697, 122, 717, 203, 636,
-118, 721, 110, 729, 89 , 750, 103, 736, 61 , 778, 55 , 784, 15 , 824, 14 , 825, 12 , 827, 23 , 816,
-34 , 805, 37 , 802, 46 , 793, 207, 632, 179, 660, 145, 694, 130, 709, 223, 616, 228, 611, 227, 612,
-132, 707, 133, 706, 143, 696, 135, 704, 161, 678, 201, 638, 173, 666, 106, 733, 83 , 756, 91 , 748,
-66 , 773, 53 , 786, 10 , 829, 9  , 830, 7  , 832, 8  , 831, 16 , 823, 47 , 792, 64 , 775, 57 , 782,
-104, 735, 101, 738, 108, 731, 208, 631, 184, 655, 197, 642, 191, 648, 121, 718, 141, 698, 149, 690,
-216, 623, 218, 621, 152, 687, 144, 695, 134, 705, 138, 701, 199, 640, 162, 677, 176, 663, 119, 720,
-158, 681, 164, 675, 174, 665, 171, 668, 170, 669, 87 , 752, 169, 670, 88 , 751, 107, 732, 81 , 758,
-82 , 757, 100, 739, 98 , 741, 71 , 768, 59 , 780, 65 , 774, 50 , 789, 49 , 790, 26 , 813, 17 , 822,
-13 , 826, 6  , 833, 5  , 834, 33 , 806, 51 , 788, 75 , 764, 99 , 740, 96 , 743, 97 , 742, 166, 673,
-172, 667, 175, 664, 187, 652, 163, 676, 185, 654, 200, 639, 114, 725, 189, 650, 115, 724, 194, 645,
-195, 644, 192, 647, 182, 657, 157, 682, 156, 683, 211, 628, 154, 685, 123, 716, 139, 700, 212, 627,
-153, 686, 213, 626, 215, 624, 150, 689, 225, 614, 224, 615, 221, 618, 220, 619, 127, 712, 147, 692,
-124, 715, 193, 646, 205, 634, 206, 633, 116, 723, 160, 679, 186, 653, 167, 672, 79 , 760, 85 , 754,
-77 , 762, 92 , 747, 58 , 781, 62 , 777, 69 , 770, 54 , 785, 36 , 803, 32 , 807, 25 , 814, 18 , 821,
-11 , 828, 4  , 835, 3  , 836, 19 , 820, 22 , 817, 41 , 798, 38 , 801, 44 , 795, 52 , 787, 45 , 794,
-63 , 776, 67 , 772, 72 , 767, 76 , 763, 94 , 745, 102, 737, 90 , 749, 109, 730, 165, 674, 111, 728,
-209, 630, 204, 635, 117, 722, 188, 651, 159, 680, 198, 641, 113, 726, 183, 656, 180, 659, 177, 662,
-196, 643, 155, 684, 214, 625, 126, 713, 131, 708, 219, 620, 222, 617, 226, 613, 230, 609, 232, 607,
-262, 577, 252, 587, 418, 421, 416, 423, 413, 426, 411, 428, 376, 463, 395, 444, 283, 556, 285, 554,
-379, 460, 390, 449, 363, 476, 384, 455, 388, 451, 386, 453, 361, 478, 387, 452, 360, 479, 310, 529,
-354, 485, 328, 511, 315, 524, 337, 502, 349, 490, 335, 504, 324, 515, 323, 516, 320, 519, 334, 505,
-359, 480, 295, 544, 385, 454, 292, 547, 291, 548, 381, 458, 399, 440, 380, 459, 397, 442, 369, 470,
-377, 462, 410, 429, 407, 432, 281, 558, 414, 425, 247, 592, 277, 562, 271, 568, 272, 567, 264, 575,
-259, 580, 237, 602, 239, 600, 244, 595, 243, 596, 275, 564, 278, 561, 250, 589, 246, 593, 417, 422,
-248, 591, 394, 445, 393, 446, 370, 469, 365, 474, 300, 539, 299, 540, 364, 475, 362, 477, 298, 541,
-312, 527, 313, 526, 314, 525, 353, 486, 352, 487, 343, 496, 327, 512, 350, 489, 326, 513, 319, 520,
-332, 507, 333, 506, 348, 491, 347, 492, 322, 517, 330, 509, 338, 501, 341, 498, 340, 499, 342, 497,
-301, 538, 366, 473, 401, 438, 371, 468, 408, 431, 375, 464, 249, 590, 269, 570, 238, 601, 234, 605,
-257, 582, 273, 566, 255, 584, 254, 585, 245, 594, 251, 588, 412, 427, 372, 467, 282, 557, 403, 436,
-396, 443, 392, 447, 391, 448, 382, 457, 389, 450, 294, 545, 297, 542, 311, 528, 344, 495, 345, 494,
-318, 521, 331, 508, 325, 514, 321, 518, 346, 493, 339, 500, 351, 488, 306, 533, 289, 550, 400, 439,
-378, 461, 374, 465, 415, 424, 270, 569, 241, 598, 231, 608, 260, 579, 268, 571, 276, 563, 409, 430,
-398, 441, 290, 549, 304, 535, 308, 531, 358, 481, 316, 523, 293, 546, 288, 551, 284, 555, 368, 471,
-253, 586, 256, 583, 263, 576, 242, 597, 274, 565, 402, 437, 383, 456, 357, 482, 329, 510, 317, 522,
-307, 532, 286, 553, 287, 552, 266, 573, 261, 578, 236, 603, 303, 536, 356, 483, 355, 484, 405, 434,
-404, 435, 406, 433, 235, 604, 267, 572, 302, 537, 309, 530, 265, 574, 233, 606, 367, 472, 296, 543,
-336, 503, 305, 534, 373, 466, 280, 559, 279, 560, 419, 420, 240, 599, 258, 581, 229, 610
-};
-// Table 6.3.3.1-4: Mapping from logical index i to sequence number u for preamble formats with L_RA = 139
-uint16_t prach_root_sequence_map_abc[138] = {
-1 , 138, 2 , 137, 3 , 136, 4 , 135, 5 , 134, 6 , 133, 7 , 132, 8 , 131, 9 , 130, 10, 129,
-11, 128, 12, 127, 13, 126, 14, 125, 15, 124, 16, 123, 17, 122, 18, 121, 19, 120, 20, 119,
-21, 118, 22, 117, 23, 116, 24, 115, 25, 114, 26, 113, 27, 112, 28, 111, 29, 110, 30, 109,
-31, 108, 32, 107, 33, 106, 34, 105, 35, 104, 36, 103, 37, 102, 38, 101, 39, 100, 40, 99 ,
-41, 98 , 42, 97 , 43, 96 , 44, 95 , 45, 94 , 46, 93 , 47, 92 , 48, 91 , 49, 90 , 50, 89 ,
-51, 88 , 52, 87 , 53, 86 , 54, 85 , 55, 84 , 56, 83 , 57, 82 , 58, 81 , 59, 80 , 60, 79 ,
-61, 78 , 62, 77 , 63, 76 , 64, 75 , 65, 74 , 66, 73 , 67, 72 , 68, 71 , 69, 70
-};
-
-// Table 6.3.3.2-2: Random access configurations for FR1 and paired spectrum/supplementary uplink
-// the column 5, (SFN_nbr is a bitmap where we set bit to '1' in the position of the subframe where the RACH can be sent.
-// E.g. in row 4, and column 5 we have set value 512 ('1000000000') which means RACH can be sent at subframe 9.
-// E.g. in row 20 and column 5 we have set value 66  ('0001000010') which means RACH can be sent at subframe 1 or 6
-int64_t table_6_3_3_2_2_prachConfig_Index [256][9] = {
-//format,   format,       x,          y,        SFN_nbr,   star_symb,   slots_sfn,    occ_slot,  duration
-{0,          -1,          16,         1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{0,          -1,          16,         1,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{0,          -1,          16,         1,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{0,          -1,          16,         1,          512,        0,         -1,         -1,          0},          // (subframe number)           9
-{0,          -1,          8,          1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{0,          -1,          8,          1,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{0,          -1,          8,          1,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{0,          -1,          8,          1,          512,        0,         -1,         -1,          0},          // (subframe number)           9
-{0,          -1,          4,          1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{0,          -1,          4,          1,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{0,          -1,          4,          1,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{0,          -1,          4,          1,          512,        0,         -1,         -1,          0},          // (subframe number)           9
-{0,          -1,          2,          1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{0,          -1,          2,          1,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{0,          -1,          2,          1,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{0,          -1,          2,          1,          512,        0,         -1,         -1,          0},          // (subframe number)           9
-{0,          -1,          1,          0,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{0,          -1,          1,          0,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{0,          -1,          1,          0,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{0,          -1,          1,          0,          66,         0,         -1,         -1,          0},          // (subframe number)           1,6
-{0,          -1,          1,          0,          132,        0,         -1,         -1,          0},          // (subframe number)           2,7
-{0,          -1,          1,          0,          264,        0,         -1,         -1,          0},          // (subframe number)           3,8
-{0,          -1,          1,          0,          146,        0,         -1,         -1,          0},          // (subframe number)           1,4,7
-{0,          -1,          1,          0,          292,        0,         -1,         -1,          0},          // (subframe number)           2,5,8
-{0,          -1,          1,          0,          584,        0,         -1,         -1,          0},          // (subframe number)           3, 6, 9
-{0,          -1,          1,          0,          341,        0,         -1,         -1,          0},          // (subframe number)           0,2,4,6,8
-{0,          -1,          1,          0,          682,        0,         -1,         -1,          0},          // (subframe number)           1,3,5,7,9
-{0,          -1,          1,          0,          1023,       0,         -1,         -1,          0},          // (subframe number)           0,1,2,3,4,5,6,7,8,9
-{1,          -1,          16,         1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{1,          -1,          16,         1,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{1,          -1,          16,         1,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{1,          -1,          16,         1,          512,        0,         -1,         -1,          0},          // (subframe number)           9
-{1,          -1,          8,          1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{1,          -1,          8,          1,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{1,          -1,          8,          1,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{1,          -1,          8,          1,          512,        0,         -1,         -1,          0},          // (subframe number)           9
-{1,          -1,          4,          1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{1,          -1,          4,          1,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{1,          -1,          4,          1,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{1,          -1,          4,          1,          512,        0,         -1,         -1,          0},          // (subframe number)           9
-{1,          -1,          2,          1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{1,          -1,          2,          1,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{1,          -1,          2,          1,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{1,          -1,          2,          1,          512,        0,         -1,         -1,          0},          // (subframe number)           9
-{1,          -1,          1,          0,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{1,          -1,          1,          0,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{1,          -1,          1,          0,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{1,          -1,          1,          0,          66,         0,         -1,         -1,          0},          // (subframe number)           1,6
-{1,          -1,          1,          0,          132,        0,         -1,         -1,          0},          // (subframe number)           2,7
-{1,          -1,          1,          0,          264,        0,         -1,         -1,          0},          // (subframe number)           3,8
-{1,          -1,          1,          0,          146,        0,         -1,         -1,          0},          // (subframe number)           1,4,7
-{1,          -1,          1,          0,          292,        0,         -1,         -1,          0},          // (subframe number)           2,5,8
-{1,          -1,          1,          0,          584,        0,         -1,         -1,          0},          // (subframe number)           3,6,9
-{2,          -1,          16,         1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{2,          -1,          8,          1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{2,          -1,          4,          0,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{2,          -1,          2,          0,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{2,          -1,          2,          0,          32,         0,         -1,         -1,          0},          // (subframe number)           5
-{2,          -1,          1,          0,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{2,          -1,          1,          0,          32,         0,         -1,         -1,          0},          // (subframe number)           5
-{3,          -1,          16,         1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{3,          -1,          16,         1,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{3,          -1,          16,         1,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{3,          -1,          16,         1,          512,        0,         -1,         -1,          0},          // (subframe number)           9
-{3,          -1,          8,          1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{3,          -1,          8,          1,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{3,          -1,          8,          1,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{3,          -1,          4,          1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{3,          -1,          4,          1,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{3,          -1,          4,          1,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{3,          -1,          4,          1,          512,        0,         -1,         -1,          0},          // (subframe number)           9
-{3,          -1,          2,          1,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{3,          -1,          2,          1,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{3,          -1,          2,          1,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{3,          -1,          2,          1,          512,        0,         -1,         -1,          0},          // (subframe number)           9
-{3,          -1,          1,          0,          2,          0,         -1,         -1,          0},          // (subframe number)           1
-{3,          -1,          1,          0,          16,         0,         -1,         -1,          0},          // (subframe number)           4
-{3,          -1,          1,          0,          128,        0,         -1,         -1,          0},          // (subframe number)           7
-{3,          -1,          1,          0,          66,         0,         -1,         -1,          0},          // (subframe number)           1,6
-{3,          -1,          1,          0,          132,        0,         -1,         -1,          0},          // (subframe number)           2,7
-{3,          -1,          1,          0,          264,        0,         -1,         -1,          0},          // (subframe number)           3,8
-{3,          -1,          1,          0,          146,        0,         -1,         -1,          0},          // (subframe number)           1,4,7
-{3,          -1,          1,          0,          292,        0,         -1,         -1,          0},          // (subframe number)           2,5,8
-{3,          -1,          1,          0,          584,        0,         -1,         -1,          0},          // (subframe number)           3, 6, 9
-{3,          -1,          1,          0,          341,        0,         -1,         -1,          0},          // (subframe number)           0,2,4,6,8
-{3,          -1,          1,          0,          682,        0,         -1,         -1,          0},          // (subframe number)           1,3,5,7,9
-{3,          -1,          1,          0,          1023,       0,         -1,         -1,          0},          // (subframe number)           0,1,2,3,4,5,6,7,8,9
-{0xa1,       -1,          16,         0,          528,        0,          1,          6,          2},          // (subframe number)           4,9
-{0xa1,       -1,          16,         1,          16,         0,          2,          6,          2},          // (subframe number)           4
-{0xa1,       -1,          8,          0,          528,        0,          1,          6,          2},          // (subframe number)           4,9
-{0xa1,       -1,          8,          1,          16,         0,          2,          6,          2},          // (subframe number)           4
-{0xa1,       -1,          4,          0,          528,        0,          1,          6,          2},          // (subframe number)           4,9
-{0xa1,       -1,          4,          1,          528,        0,          1,          6,          2},          // (subframe number)           4,9
-{0xa1,       -1,          4,          0,          16,         0,          2,          6,          2},          // (subframe number)           4
-{0xa1,       -1,          2,          0,          528,        0,          1,          6,          2},          // (subframe number)           4,9
-{0xa1,       -1,          2,          0,          2,          0,          2,          6,          2},          // (subframe number)           1
-{0xa1,       -1,          2,          0,          16,         0,          2,          6,          2},          // (subframe number)           4
-{0xa1,       -1,          2,          0,          128,        0,          2,          6,          2},          // (subframe number)           7
-{0xa1,       -1,          1,          0,          16,         0,          1,          6,          2},          // (subframe number)           4
-{0xa1,       -1,          1,          0,          66,         0,          1,          6,          2},          // (subframe number)           1,6
-{0xa1,       -1,          1,          0,          528,        0,          1,          6,          2},          // (subframe number)           4,9
-{0xa1,       -1,          1,          0,          2,          0,          2,          6,          2},          // (subframe number)           1
-{0xa1,       -1,          1,          0,          128,        0,          2,          6,          2},          // (subframe number)           7
-{0xa1,       -1,          1,          0,          132,        0,          2,          6,          2},          // (subframe number)           2,7
-{0xa1,       -1,          1,          0,          146,        0,          2,          6,          2},          // (subframe number)           1,4,7
-{0xa1,       -1,          1,          0,          341,        0,          2,          6,          2},          // (subframe number)           0,2,4,6,8
-{0xa1,       -1,          1,          0,          1023,       0,          2,          6,          2},          // (subframe number)           0,1,2,3,4,5,6,7,8,9
-{0xa1,       -1,          1,          0,          682,        0,          2,          6,          2},          // (subframe number)           1,3,5,7,9
-{0xa1,       0xb1,        2,          0,          528,        0,          1,          7,          2},          // (subframe number)           4,9
-{0xa1,       0xb1,        2,          0,          16,         0,          2,          7,          2},          // (subframe number)           4
-{0xa1,       0xb1,        1,          0,          16,         0,          1,          7,          2},          // (subframe number)           4
-{0xa1,       0xb1,        1,          0,          66,         0,          1,          7,          2},          // (subframe number)           1,6
-{0xa1,       0xb1,        1,          0,          528,        0,          1,          7,          2},          // (subframe number)           4,9
-{0xa1,       0xb1,        1,          0,          2,          0,          2,          7,          2},          // (subframe number)           1
-{0xa1,       0xb1,        1,          0,          128,        0,          2,          7,          2},          // (subframe number)           7
-{0xa1,       0xb1,        1,          0,          146,        0,          2,          7,          2},          // (subframe number)           1,4,7
-{0xa1,       0xb1,        1,          0,          341,        0,          2,          7,          2},          // (subframe number)           0,2,4,6,8
-{0xa2,       -1,          16,         1,          580,        0,          1,          3,          4},          // (subframe number)           2,6,9
-{0xa2,       -1,          16,         1,          16,         0,          2,          3,          4},          // (subframe number)           4
-{0xa2,       -1,          8,          1,          580,        0,          1,          3,          4},          // (subframe number)           2,6,9
-{0xa2,       -1,          8,          1,          16,         0,          2,          3,          4},          // (subframe number)           4
-{0xa2,       -1,          4,          0,          580,        0,          1,          3,          4},          // (subframe number)           2,6,9
-{0xa2,       -1,          4,          0,          16,         0,          2,          3,          4},          // (subframe number)           4
-{0xa2,       -1,          2,          1,          580,        0,          1,          3,          4},          // (subframe number)           2,6,9
-{0xa2,       -1,          2,          0,          2,          0,          2,          3,          4},          // (subframe number)           1
-{0xa2,       -1,          2,          0,          16,         0,          2,          3,          4},          // (subframe number)           4
-{0xa2,       -1,          2,          0,          128,        0,          2,          3,          4},          // (subframe number)           7
-{0xa2,       -1,          1,          0,          16,         0,          1,          3,          4},          // (subframe number)           4
-{0xa2,       -1,          1,          0,          66,         0,          1,          3,          4},          // (subframe number)           1,6
-{0xa2,       -1,          1,          0,          528,        0,          1,          3,          4},          // (subframe number)           4,9
-{0xa2,       -1,          1,          0,          2,          0,          2,          3,          4},          // (subframe number)           1
-{0xa2,       -1,          1,          0,          128,        0,          2,          3,          4},          // (subframe number)           7
-{0xa2,       -1,          1,          0,          132,        0,          2,          3,          4},          // (subframe number)           2,7
-{0xa2,       -1,          1,          0,          146,        0,          2,          3,          4},          // (subframe number)           1,4,7
-{0xa2,       -1,          1,          0,          341,        0,          2,          3,          4},          // (subframe number)           0,2,4,6,8
-{0xa2,       -1,          1,          0,          1023,       0,          2,          3,          4},          // (subframe number)           0,1,2,3,4,5,6,7,8,9
-{0xa2,       -1,          1,          0,          682,        0,          2,          3,          4},          // (subframe number)           1,3,5,7,9
-{0xa2,       0xb2,        2,          1,          580,        0,          1,          3,          4},          // (subframe number)           2,6,9
-{0xa2,       0xb2,        2,          0,          16,         0,          2,          3,          4},          // (subframe number)           4
-{0xa2,       0xb2,        1,          0,          16,         0,          1,          3,          4},          // (subframe number)           4
-{0xa2,       0xb2,        1,          0,          66,         0,          1,          3,          4},          // (subframe number)           1,6
-{0xa2,       0xb2,        1,          0,          528,        0,          1,          3,          4},          // (subframe number)           4,9
-{0xa2,       0xb2,        1,          0,          2,          0,          2,          3,          4},          // (subframe number)           1
-{0xa2,       0xb2,        1,          0,          128,        0,          2,          3,          4},          // (subframe number)           7
-{0xa2,       0xb2,        1,          0,          146,        0,          2,          3,          4},          // (subframe number)           1,4,7
-{0xa2,       0xb2,        1,          0,          341,        0,          2,          3,          4},          // (subframe number)           0,2,4,6,8
-{0xa2,       0xb2,        1,          0,          1023,       0,          2,          3,          4},          // (subframe number)           0,1,2,3,4,5,6,7,8,9
-{0xa3,       -1,          16,         1,          528,        0,          1,          2,          6},          // (subframe number)           4,9
-{0xa3,       -1,          16,         1,          16,         0,          2,          2,          6},          // (subframe number)           4
-{0xa3,       -1,          8,          1,          528,        0,          1,          2,          6},          // (subframe number)           4,9
-{0xa3,       -1,          8,          1,          16,         0,          2,          2,          6},          // (subframe number)           4
-{0xa3,       -1,          4,          0,          528,        0,          1,          2,          6},          // (subframe number)           4,9
-{0xa3,       -1,          4,          0,          16,         0,          2,          2,          6},          // (subframe number)           4
-{0xa3,       -1,          2,          1,          580,        0,          2,          2,          6},          // (subframe number)           2,6,9
-{0xa3,       -1,          2,          0,          2,          0,          2,          2,          6},          // (subframe number)           1
-{0xa3,       -1,          2,          0,          16,         0,          2,          2,          6},          // (subframe number)           4
-{0xa3,       -1,          2,          0,          128,        0,          2,          2,          6},          // (subframe number)           7
-{0xa3,       -1,          1,          0,          16,         0,          1,          2,          6},          // (subframe number)           4
-{0xa3,       -1,          1,          0,          66,         0,          1,          2,          6},          // (subframe number)           1,6
-{0xa3,       -1,          1,          0,          528,        0,          1,          2,          6},          // (subframe number)           4,9
-{0xa3,       -1,          1,          0,          2,          0,          2,          2,          6},          // (subframe number)           1
-{0xa3,       -1,          1,          0,          128,        0,          2,          2,          6},          // (subframe number)           7
-{0xa3,       -1,          1,          0,          132,        0,          2,          2,          6},          // (subframe number)           2,7
-{0xa3,       -1,          1,          0,          146,        0,          2,          2,          6},          // (subframe number)           1,4,7
-{0xa3,       -1,          1,          0,          341,        0,          2,          2,          6},          // (subframe number)           0,2,4,6,8
-{0xa3,       -1,          1,          0,          1023,       0,          2,          2,          6},          // (subframe number)           0,1,2,3,4,5,6,7,8,9
-{0xa3,       -1,          1,          0,          682,        0,          2,          2,          6},          // (subframe number)           1,3,5,7,9
-{0xa3,       0xb3,        2,          1,          580,        0,          2,          2,          6},          // (subframe number)           2,6,9
-{0xa3,       0xb3,        2,          0,          16,         0,          2,          2,          6},          // (subframe number)           4
-{0xa3,       0xb3,        1,          0,          16,         0,          1,          2,          6},          // (subframe number)           4
-{0xa3,       0xb3,        1,          0,          66,         0,          1,          2,          6},          // (subframe number)           1,6
-{0xa3,       0xb3,        1,          0,          528,        0,          1,          2,          6},          // (subframe number)           4,9
-{0xa3,       0xb3,        1,          0,          2,          0,          2,          2,          6},          // (subframe number)           1
-{0xa3,       0xb3,        1,          0,          128,        0,          2,          2,          6},          // (subframe number)           7
-{0xa3,       0xb3,        1,          0,          146,        0,          2,          2,          6},          // (subframe number)           1,4,7
-{0xa3,       0xb3,        1,          0,          341,        0,          2,          2,          6},          // (subframe number)           0,2,4,6,8
-{0xa3,       0xb3,        1,          0,          1023,       0,          2,          2,          6},          // (subframe number)           0,1,2,3,4,5,6,7,8,9
-{0xb1,       -1,          16,         0,          528,        0,          1,          7,          2},          // (subframe number)           4,9
-{0xb1,       -1,          16,         1,          16,         0,          2,          7,          2},          // (subframe number)           4
-{0xb1,       -1,          8,          0,          528,        0,          1,          7,          2},          // (subframe number)           4,9
-{0xb1,       -1,          8,          1,          16,         0,          2,          7,          2},          // (subframe number)           4
-{0xb1,       -1,          4,          0,          528,        0,          1,          7,          2},          // (subframe number)           4,9
-{0xb1,       -1,          4,          1,          528,        0,          1,          7,          2},          // (subframe number)           4,9
-{0xb1,       -1,          4,          0,          16,         0,          2,          7,          2},          // (subframe number)           4
-{0xb1,       -1,          2,          0,          528,        0,          1,          7,          2},          // (subframe number)           4,9
-{0xb1,       -1,          2,          0,          2,          0,          2,          7,          2},          // (subframe number)           1
-{0xb1,       -1,          2,          0,          16,         0,          2,          7,          2},          // (subframe number)           4
-{0xb1,       -1,          2,          0,          128,        0,          2,          7,          2},          // (subframe number)           7
-{0xb1,       -1,          1,          0,          16,         0,          1,          7,          2},          // (subframe number)           4
-{0xb1,       -1,          1,          0,          66,         0,          1,          7,          2},          // (subframe number)           1,6
-{0xb1,       -1,          1,          0,          528,        0,          1,          7,          2},          // (subframe number)           4,9
-{0xb1,       -1,          1,          0,          2,          0,          2,          7,          2},          // (subframe number)           1
-{0xb1,       -1,          1,          0,          128,        0,          2,          7,          2},          // (subframe number)           7
-{0xb1,       -1,          1,          0,          132,        0,          2,          7,          2},          // (subframe number)           2,7
-{0xb1,       -1,          1,          0,          146,        0,          2,          7,          2},          // (subframe number)           1,4,7
-{0xb1,       -1,          1,          0,          341,        0,          2,          7,          2},          // (subframe number)           0,2,4,6,8
-{0xb1,       -1,          1,          0,          1023,       0,          2,          7,          2},          // (subframe number)           0,1,2,3,4,5,6,7,8,9
-{0xb1,       -1,          1,          0,          682,        0,          2,          7,          2},          // (subframe number)           1,3,5,7,9
-{0xb4,       -1,          16,         0,          528,        0,          2,          1,          12},         // (subframe number)           4,9
-{0xb4,       -1,          16,         1,          16,         0,          2,          1,          12},         // (subframe number)           4
-{0xb4,       -1,          8,          0,          528,        0,          2,          1,          12},         // (subframe number)           4,9
-{0xb4,       -1,          8,          1,          16,         0,          2,          1,          12},         // (subframe number)           4
-{0xb4,       -1,          4,          0,          528,        0,          2,          1,          12},         // (subframe number)           4,9
-{0xb4,       -1,          4,          0,          16,         0,          2,          1,          12},         // (subframe number)           4
-{0xb4,       -1,          4,          1,          528,        0,          2,          1,          12},         // (subframe number)           4,9
-{0xb4,       -1,          2,          0,          528,        0,          2,          1,          12},         // (subframe number)           4,9
-{0xb4,       -1,          2,          0,          2,          0,          2,          1,          12},         // (subframe number)           1
-{0xb4,       -1,          2,          0,          16,         0,          2,          1,          12},         // (subframe number)           4
-{0xb4,       -1,          2,          0,          128,        0,          2,          1,          12},         // (subframe number)           7
-{0xb4,       -1,          1,          0,          2,          0,          2,          1,          12},         // (subframe number)           1
-{0xb4,       -1,          1,          0,          16,         0,          2,          1,          12},         // (subframe number)           4
-{0xb4,       -1,          1,          0,          128,        0,          2,          1,          12},         // (subframe number)           7
-{0xb4,       -1,          1,          0,          66,         0,          2,          1,          12},         // (subframe number)           1,6
-{0xb4,       -1,          1,          0,          132,        0,          2,          1,          12},         // (subframe number)           2,7
-{0xb4,       -1,          1,          0,          528,        0,          2,          1,          12},         // (subframe number)           4,9
-{0xb4,       -1,          1,          0,          146,        0,          2,          1,          12},         // (subframe number)           1,4,7
-{0xb4,       -1,          1,          0,          341,        0,          2,          1,          12},         // (subframe number)           0,2,4,6,8
-{0xb4,       -1,          1,          0,          1023,       0,          2,          1,          12},         // (subframe number)           0,1,2,3,4,5,6,7,8,9
-{0xb4,       -1,          1,          0,          682,        0,          2,          1,          12},         // (subframe number)           1,3,5,7,9
-{0xc0,       -1,          8,          1,          16,         0,          2,          7,          2},          // (subframe number)           4
-{0xc0,       -1,          4,          1,          528,        0,          1,          7,          2},          // (subframe number)           4,9
-{0xc0,       -1,          4,          0,          16,         0,          2,          7,          2},          // (subframe number)           4
-{0xc0,       -1,          2,          0,          528,        0,          1,          7,          2},          // (subframe number)           4,9
-{0xc0,       -1,          2,          0,          2,          0,          2,          7,          2},          // (subframe number)           1
-{0xc0,       -1,          2,          0,          16,         0,          2,          7,          2},          // (subframe number)           4
-{0xc0,       -1,          2,          0,          128,        0,          2,          7,          2},          // (subframe number)           7
-{0xc0,       -1,          1,          0,          16,         0,          1,          7,          2},          // (subframe number)           4
-{0xc0,       -1,          1,          0,          66,         0,          1,          7,          2},          // (subframe number)           1,6
-{0xc0,       -1,          1,          0,          528,        0,          1,          7,          2},          // (subframe number)           4,9
-{0xc0,       -1,          1,          0,          2,          0,          2,          7,          2},          // (subframe number)           1
-{0xc0,       -1,          1,          0,          128,        0,          2,          7,          2},          // (subframe number)           7
-{0xc0,       -1,          1,          0,          132,        0,          2,          7,          2},          // (subframe number)           2,7
-{0xc0,       -1,          1,          0,          146,        0,          2,          7,          2},          // (subframe number)           1,4,7
-{0xc0,       -1,          1,          0,          341,        0,          2,          7,          2},          // (subframe number)           0,2,4,6,8
-{0xc0,       -1,          1,          0,          1023,       0,          2,          7,          2},          // (subframe number)           0,1,2,3,4,5,6,7,8,9
-{0xc0,       -1,          1,          0,          682,        0,          2,          7,          2},          // (subframe number)           1,3,5,7,9
-{0xc2,       -1,          16,         1,          528,        0,          1,          2,          6},          // (subframe number)           4,9
-{0xc2,       -1,          16,         1,          16,         0,          2,          2,          6},          // (subframe number)           4
-{0xc2,       -1,          8,          1,          528,        0,          1,          2,          6},          // (subframe number)           4,9
-{0xc2,       -1,          8,          1,          16,         0,          2,          2,          6},          // (subframe number)           4
-{0xc2,       -1,          4,          0,          528,        0,          1,          2,          6},          // (subframe number)           4,9
-{0xc2,       -1,          4,          0,          16,         0,          2,          2,          6},          // (subframe number)           4
-{0xc2,       -1,          2,          1,          580,        0,          2,          2,          6},          // (subframe number)           2,6,9
-{0xc2,       -1,          2,          0,          2,          0,          2,          2,          6},          // (subframe number)           1
-{0xc2,       -1,          2,          0,          16,         0,          2,          2,          6},          // (subframe number)           4
-{0xc2,       -1,          2,          0,          128,        0,          2,          2,          6},          // (subframe number)           7
-{0xc2,       -1,          1,          0,          16,         0,          1,          2,          6},          // (subframe number)           4
-{0xc2,       -1,          1,          0,          66,         0,          1,          2,          6},          // (subframe number)           1,6
-{0xc2,       -1,          1,          0,          528,        0,          1,          2,          6},          // (subframe number)           4,9
-{0xc2,       -1,          1,          0,          2,          0,          2,          2,          6},          // (subframe number)           1
-{0xc2,       -1,          1,          0,          128,        0,          2,          2,          6},          // (subframe number)           7
-{0xc2,       -1,          1,          0,          132,        0,          2,          2,          6},          // (subframe number)           2,7
-{0xc2,       -1,          1,          0,          146,        0,          2,          2,          6},          // (subframe number)           1,4,7
-{0xc2,       -1,          1,          0,          341,        0,          2,          2,          6},          // (subframe number)           0,2,4,6,8
-{0xc2,       -1,          1,          0,          1023,       0,          2,          2,          6},          // (subframe number)           0,1,2,3,4,5,6,7,8,9
-{0xc2,       -1,          1,          0,          682,        0,          2,          2,          6}                    // (subframe number)           1,3,5,7,9
-};
-// Table 6.3.3.2-3: Random access configurations for FR1 and unpaired spectrum
-int64_t table_6_3_3_2_3_prachConfig_Index [256][9] = {
-//format,     format,      x,         y,     SFN_nbr,   star_symb,   slots_sfn,  occ_slot,  duration
-{0,            -1,         16,        1,         512,         0,        -1,        -1,         0},         // (subrame number 9)
-{0,            -1,         8,         1,         512,         0,        -1,        -1,         0},         // (subrame number 9)
-{0,            -1,         4,         1,         512,         0,        -1,        -1,         0},         // (subrame number 9)
-{0,            -1,         2,         0,         512,         0,        -1,        -1,         0},         // (subrame number 9)
-{0,            -1,         2,         1,         512,         0,        -1,        -1,         0},         // (subrame number 9)
-{0,            -1,         2,         0,         16,          0,        -1,        -1,         0},         // (subrame number 4)
-{0,            -1,         2,         1,         16,          0,        -1,        -1,         0},         // (subrame number 4)
-{0,            -1,         1,         0,         512,         0,        -1,        -1,         0},         // (subrame number 9)
-{0,            -1,         1,         0,         256,         0,        -1,        -1,         0},         // (subrame number 8)
-{0,            -1,         1,         0,         128,         0,        -1,        -1,         0},         // (subrame number 7)
-{0,            -1,         1,         0,         64,          0,        -1,        -1,         0},         // (subrame number 6)
-{0,            -1,         1,         0,         32,          0,        -1,        -1,         0},         // (subrame number 5)
-{0,            -1,         1,         0,         16,          0,        -1,        -1,         0},         // (subrame number 4)
-{0,            -1,         1,         0,         8,           0,        -1,        -1,         0},         // (subrame number 3)
-{0,            -1,         1,         0,         4,           0,        -1,        -1,         0},         // (subrame number 2)
-{0,            -1,         1,         0,         66,          0,        -1,        -1,         0},         // (subrame number 1,6)
-{0,            -1,         1,         0,         66,          7,        -1,        -1,         0},         // (subrame number 1,6)
-{0,            -1,         1,         0,         528,         0,        -1,        -1,         0},         // (subrame number 4,9)
-{0,            -1,         1,         0,         264,         0,        -1,        -1,         0},         // (subrame number 3,8)
-{0,            -1,         1,         0,         132,         0,        -1,        -1,         0},         // (subrame number 2,7)
-{0,            -1,         1,         0,         768,         0,        -1,        -1,         0},         // (subrame number 8,9)
-{0,            -1,         1,         0,         784,         0,        -1,        -1,         0},         // (subrame number 4,8,9)
-{0,            -1,         1,         0,         536,         0,        -1,        -1,         0},         // (subrame number 3,4,9)
-{0,            -1,         1,         0,         896,         0,        -1,        -1,         0},         // (subrame number 7,8,9)
-{0,            -1,         1,         0,         792,         0,        -1,        -1,         0},         // (subrame number 3,4,8,9)
-{0,            -1,         1,         0,         960,         0,        -1,        -1,         0},         // (subrame number 6,7,8,9)
-{0,            -1,         1,         0,         594,         0,        -1,        -1,         0},         // (subrame number 1,4,6,9)
-{0,            -1,         1,         0,         682,         0,        -1,        -1,         0},         // (subrame number 1,3,5,7,9)
-{1,            -1,         16,        1,         128,         0,        -1,        -1,         0},         // (subrame number 7)
-{1,            -1,         8,         1,         128,         0,        -1,        -1,         0},         // (subrame number 7)
-{1,            -1,         4,         1,         128,         0,        -1,        -1,         0},         // (subrame number 7)
-{1,            -1,         2,         0,         128,         0,        -1,        -1,         0},         // (subrame number 7)
-{1,            -1,         2,         1,         128,         0,        -1,        -1,         0},         // (subrame number 7)
-{1,            -1,         1,         0,         128,         0,        -1,        -1,         0},         // (subrame number 7)
-{2,            -1,         16,        1,         64,          0,        -1,        -1,         0},         // (subrame number 6)
-{2,            -1,         8,         1,         64,          0,        -1,        -1,         0},         // (subrame number 6)
-{2,            -1,         4,         1,         64,          0,        -1,        -1,         0},         // (subrame number 6)
-{2,            -1,         2,         0,         64,          7,        -1,        -1,         0},         // (subrame number 6)
-{2,            -1,         2,         1,         64,          7,        -1,        -1,         0},         // (subrame number 6)
-{2,            -1,         1,         0,         64,          7,        -1,        -1,         0},         // (subrame number 6)
-{3,            -1,         16,        1,         512,         0,        -1,        -1,         0},         // (subrame number 9)
-{3,            -1,         8,         1,         512,         0,        -1,        -1,         0},         // (subrame number 9)
-{3,            -1,         4,         1,         512,         0,        -1,        -1,         0},         // (subrame number 9)
-{3,            -1,         2,         0,         512,         0,        -1,        -1,         0},         // (subrame number 9)
-{3,            -1,         2,         1,         512,         0,        -1,        -1,         0},         // (subrame number 9)
-{3,            -1,         2,         0,         16,          0,        -1,        -1,         0},         // (subrame number 4)
-{3,            -1,         2,         1,         16,          0,        -1,        -1,         0},         // (subrame number 4)
-{3,            -1,         1,         0,         512,         0,        -1,        -1,         0},         // (subrame number 9)
-{3,            -1,         1,         0,         256,         0,        -1,        -1,         0},         // (subrame number 8)
-{3,            -1,         1,         0,         128,         0,        -1,        -1,         0},         // (subrame number 7)
-{3,            -1,         1,         0,         64,          0,        -1,        -1,         0},         // (subrame number 6)
-{3,            -1,         1,         0,         32,          0,        -1,        -1,         0},         // (subrame number 5)
-{3,            -1,         1,         0,         16,          0,        -1,        -1,         0},         // (subrame number 4)
-{3,            -1,         1,         0,         8,           0,        -1,        -1,         0},         // (subrame number 3)
-{3,            -1,         1,         0,         4,           0,        -1,        -1,         0},         // (subrame number 2)
-{3,            -1,         1,         0,         66,          0,        -1,        -1,         0},         // (subrame number 1,6)
-{3,            -1,         1,         0,         66,          7,        -1,        -1,         0},         // (subrame number 1,6)
-{3,            -1,         1,         0,         528,         0,        -1,        -1,         0},         // (subrame number 4,9)
-{3,            -1,         1,         0,         264,         0,        -1,        -1,         0},         // (subrame number 3,8)
-{3,            -1,         1,         0,         132,         0,        -1,        -1,         0},         // (subrame number 2,7)
-{3,            -1,         1,         0,         768,         0,        -1,        -1,         0},         // (subrame number 8,9)
-{3,            -1,         1,         0,         784,         0,        -1,        -1,         0},         // (subrame number 4,8,9)
-{3,            -1,         1,         0,         536,         0,        -1,        -1,         0},         // (subrame number 3,4,9)
-{3,            -1,         1,         0,         896,         0,        -1,        -1,         0},         // (subrame number 7,8,9)
-{3,            -1,         1,         0,         792,         0,        -1,        -1,         0},         // (subrame number 3,4,8,9)
-{3,            -1,         1,         0,         594,         0,        -1,        -1,         0},         // (subrame number 1,4,6,9)
-{3,            -1,         1,         0,         682,         0,        -1,        -1,         0},         // (subrame number 1,3,5,7,9)
-{0xa1,         -1,         16,        1,         512,         0,         2,         6,         2},         // (subrame number 9)
-{0xa1,         -1,         8,         1,         512,         0,         2,         6,         2},         // (subrame number 9)
-{0xa1,         -1,         4,         1,         512,         0,         1,         6,         2},         // (subrame number 9)
-{0xa1,         -1,         2,         1,         512,         0,         1,         6,         2},         // (subrame number 9)
-{0xa1,         -1,         2,         1,         528,         7,         1,         3,         2},         // (subrame number 4,9)
-{0xa1,         -1,         2,         1,         640,         7,         1,         3,         2},         // (subrame number 7,9)
-{0xa1,         -1,         2,         1,         640,         0,         1,         6,         2},         // (subrame number 7,9)
-{0xa1,         -1,         2,         1,         768,         0,         2,         6,         2},         // (subrame number 8,9)
-{0xa1,         -1,         2,         1,         528,         0,         2,         6,         2},         // (subrame number 4,9)
-{0xa1,         -1,         2,         1,         924,         0,         1,         6,         2},         // (subrame number 2,3,4,7,8,9)
-{0xa1,         -1,         1,         0,         512,         0,         2,         6,         2},         // (subrame number 9)
-{0xa1,         -1,         1,         0,         512,         7,         1,         3,         2},         // (subrame number 9)
-{0xa1,         -1,         1,         0,         512,         0,         1,         6,         2},         // (subrame number 9)
-{0xa1,         -1,         1,         0,         768,         0,         2,         6,         2},         // (subrame number 8,9)
-{0xa1,         -1,         1,         0,         528,         0,         1,         6,         2},         // (subrame number 4,9)
-{0xa1,         -1,         1,         0,         640,         7,         1,         3,         2},         // (subrame number 7,9)
-{0xa1,         -1,         1,         0,         792,         0,         1,         6,         2},         // (subrame number 3,4,8,9)
-{0xa1,         -1,         1,         0,         792,         0,         2,         6,         2},         // (subrame number 3,4,8,9)
-{0xa1,         -1,         1,         0,         682,         0,         1,         6,         2},         // (subrame number 1,3,5,7,9)
-{0xa1,         -1,         1,         0,         1023,        7,         1,         3,         2},         // (subrame number 0,1,2,3,4,5,6,7,8,9)
-{0xa2,         -1,         16,        1,         512,         0,         2,         3,         4},         // (subrame number 9)
-{0xa2,         -1,         8,         1,         512,         0,         2,         3,         4},         // (subrame number 9)
-{0xa2,         -1,         4,         1,         512,         0,         1,         3,         4},         // (subrame number 9)
-{0xa2,         -1,         2,         1,         640,         0,         1,         3,         4},         // (subrame number 7,9)
-{0xa2,         -1,         2,         1,         768,         0,         2,         3,         4},         // (subrame number 8,9)
-{0xa2,         -1,         2,         1,         640,         9,         1,         1,         4},         // (subrame number 7,9)
-{0xa2,         -1,         2,         1,         528,         9,         1,         1,         4},         // (subrame number 4,9)
-{0xa2,         -1,         2,         1,         528,         0,         2,         3,         4},         // (subrame number 4,9)
-{0xa2,         -1,         16,        1,         924,         0,         1,         3,         4},         // (subrame number 2,3,4,7,8,9)
-{0xa2,         -1,         1,         0,         4,           0,         1,         3,         4},         // (subrame number 2)
-{0xa2,         -1,         1,         0,         128,         0,         1,         3,         4},         // (subrame number 7)
-{0xa2,         -1,         2,         1,         512,         0,         1,         3,         4},         // (subrame number 9)
-{0xa2,         -1,         1,         0,         512,         0,         2,         3,         4},         // (subrame number 9)
-{0xa2,         -1,         1,         0,         512,         9,         1,         1,         4},         // (subrame number 9)
-{0xa2,         -1,         1,         0,         512,         0,         1,         3,         4},         // (subrame number 9)
-{0xa2,         -1,         1,         0,         132,         0,         1,         3,         4},         // (subrame number 2,7)
-{0xa2,         -1,         1,         0,         768,         0,         2,         3,         4},         // (subrame number 8,9)
-{0xa2,         -1,         1,         0,         528,         0,         1,         3,         4},         // (subrame number 4,9)
-{0xa2,         -1,         1,         0,         640,         9,         1,         1,         4},         // (subrame number 7,9)
-{0xa2,         -1,         1,         0,         792,         0,         1,         3,         4},         // (subrame number 3,4,8,9)
-{0xa2,         -1,         1,         0,         792,         0,         2,         3,         4},         // (subrame number 3,4,8,9)
-{0xa2,         -1,         1,         0,         682,         0,         1,         3,         4},         // (subrame number 1,3,5,7,9)
-{0xa2,         -1,         1,         0,         1023,        9,         1,         1,         4},         // (subrame number 0,1,2,3,4,5,6,7,8,9)
-{0xa3,         -1,         16,        1,         512,         0,         2,         2,         6},         // (subrame number 9)
-{0xa3,         -1,         8,         1,         512,         0,         2,         2,         6},         // (subrame number 9)
-{0xa3,         -1,         4,         1,         512,         0,         1,         2,         6},         // (subrame number 9)
-{0xa3,         -1,         2,         1,         528,         7,         1,         1,         6},         // (subrame number 4,9)
-{0xa3,         -1,         2,         1,         640,         7,         1,         1,         6},         // (subrame number 7,9)
-{0xa3,         -1,         2,         1,         640,         0,         1,         2,         6},         // (subrame number 7,9)
-{0xa3,         -1,         2,         1,         528,         0,         2,         2,         6},         // (subrame number 4,9)
-{0xa3,         -1,         2,         1,         768,         0,         2,         2,         6},         // (subrame number 8,9)
-{0xa3,         -1,         2,         1,         924,         0,         1,         2,         6},         // (subrame number 2,3,4,7,8,9)
-{0xa3,         -1,         1,         0,         4,           0,         1,         2,         6},         // (subrame number 2)
-{0xa3,         -1,         1,         0,         128,         0,         1,         2,         6},         // (subrame number 7)
-{0xa3,         -1,         2,         1,         512,         0,         1,         2,         6},         // (subrame number 9)
-{0xa3,         -1,         1,         0,         512,         0,         2,         2,         6},         // (subrame number 9)
-{0xa3,         -1,         1,         0,         512,         7,         1,         1,         6},         // (subrame number 9)
-{0xa3,         -1,         1,         0,         512,         0,         1,         2,         6},         // (subrame number 9)
-{0xa3,         -1,         1,         0,         132,         0,         1,         2,         6},         // (subrame number 2,7)
-{0xa3,         -1,         1,         0,         768,         0,         2,         2,         6},         // (subrame number 8,9)
-{0xa3,         -1,         1,         0,         528,         0,         1,         2,         6},         // (subrame number 4,9)
-{0xa3,         -1,         1,         0,         640,         7,         1,         1,         6},         // (subrame number 7,9)
-{0xa3,         -1,         1,         0,         792,         0,         1,         2,         6},         // (subrame number 3,4,8,9)
-{0xa3,         -1,         1,         0,         792,         0,         2,         2,         6},         // (subrame number 3,4,8,9)
-{0xa3,         -1,         1,         0,         682,         0,         1,         2,         6},         // (subrame number 1,3,5,7,9)
-{0xa3,         -1,         1,         0,         1023,        7,         1,         1,         6},         // (subrame number 0,1,2,3,4,5,6,7,8,9)
-{0xb1,         -1,         4,         1,         512,         2,         1,         6,         2},         // (subrame number 9)
-{0xb1,         -1,         2,         1,         512,         2,         1,         6,         2},         // (subrame number 9)
-{0xb1,         -1,         2,         1,         640,         2,         1,         6,         2},         // (subrame number 7,9)
-{0xb1,         -1,         2,         1,         528,         8,         1,         3,         2},         // (subrame number 4,9)
-{0xb1,         -1,         2,         1,         528,         2,         2,         6,         2},         // (subrame number 4,9)
-{0xb1,         -1,         1,         0,         512,         2,         2,         6,         2},         // (subrame number 9)
-{0xb1,         -1,         1,         0,         512,         8,         1,         3,         2},         // (subrame number 9)
-{0xb1,         -1,         1,         0,         512,         2,         1,         6,         2},         // (subrame number 9)
-{0xb1,         -1,         1,         0,         768,         2,         2,         6,         2},         // (subrame number 8,9)
-{0xb1,         -1,         1,         0,         528,         2,         1,         6,         2},         // (subrame number 4,9)
-{0xb1,         -1,         1,         0,         640,         8,         1,         3,         2},         // (subrame number 7,9)
-{0xb1,         -1,         1,         0,         682,         2,         1,         6,         2},         // (subrame number 1,3,5,7,9)
-{0xb4,         -1,         16,        1,         512,         0,         2,         1,         12},        // (subrame number 9)
-{0xb4,         -1,         8,         1,         512,         0,         2,         1,         12},        // (subrame number 9)
-{0xb4,         -1,         4,         1,         512,         2,         1,         1,         12},        // (subrame number 9)
-{0xb4,         -1,         2,         1,         512,         0,         1,         1,         12},        // (subrame number 9)
-{0xb4,         -1,         2,         1,         512,         2,         1,         1,         12},        // (subrame number 9)
-{0xb4,         -1,         2,         1,         640,         2,         1,         1,         12},        // (subrame number 7,9)
-{0xb4,         -1,         2,         1,         528,         2,         1,         1,         12},        // (subrame number 4,9)
-{0xb4,         -1,         2,         1,         528,         0,         2,         1,         12},        // (subrame number 4,9)
-{0xb4,         -1,         2,         1,         768,         0,         2,         1,         12},        // (subrame number 8,9)
-{0xb4,         -1,         2,         1,         924,         0,         1,         1,         12},        // (subrame number 2,3,4,7,8,9)
-{0xb4,         -1,         1,         0,         2,           0,         1,         1,         12},        // (subrame number 1)
-{0xb4,         -1,         1,         0,         4,           0,         1,         1,         12},        // (subrame number 2)
-{0xb4,         -1,         1,         0,         16,          0,         1,         1,         12},        // (subrame number 4)
-{0xb4,         -1,         1,         0,         128,         0,         1,         1,         12},        // (subrame number 7)
-{0xb4,         -1,         1,         0,         512,         0,         1,         1,         12},        // (subrame number 9)
-{0xb4,         -1,         1,         0,         512,         2,         1,         1,         12},        // (subrame number 9)
-{0xb4,         -1,         1,         0,         512,         0,         2,         1,         12},        // (subrame number 9)
-{0xb4,         -1,         1,         0,         528,         2,         1,         1,         12},        // (subrame number 4,9)
-{0xb4,         -1,         1,         0,         640,         2,         1,         1,         12},        // (subrame number 7,9)
-{0xb4,         -1,         1,         0,         768,         0,         2,         1,         12},        // (subrame number 8,9)
-{0xb4,         -1,         1,         0,         792,         2,         1,         1,         12},        // (subrame number 3,4,8,9)
-{0xb4,         -1,         1,         0,         682,         2,         1,         1,         12},        // (subrame number 1,3,5,7,9)
-{0xb4,         -1,         1,         0,         1023,        0,         2,         1,         12},        // (subrame number 0,1,2,3,4,5,6,7,8,9)
-{0xb4,         -1,         1,         0,         1023,        2,         1,         1,         12},        // (subrame number 0,1,2,3,4,5,6,7,8,9)
-{0xc0,         -1,         16,        1,         512,         2,         2,         6,         2},         // (subrame number 9)
-{0xc0,         -1,         8,         1,         512,         2,         2,         6,         2},         // (subrame number 9)
-{0xc0,         -1,         4,         1,         512,         2,         1,         6,         2},         // (subrame number 9)
-{0xc0,         -1,         2,         1,         512,         2,         1,         6,         2},         // (subrame number 9)
-{0xc0,         -1,         2,         1,         768,         2,         2,         6,         2},         // (subrame number 8,9)
-{0xc0,         -1,         2,         1,         640,         2,         1,         6,         2},         // (subrame number 7,9)
-{0xc0,         -1,         2,         1,         640,         8,         1,         3,         2},         // (subrame number 7,9)
-{0xc0,         -1,         2,         1,         528,         8,         1,         3,         2},         // (subrame number 4,9)
-{0xc0,         -1,         2,         1,         528,         2,         2,         6,         2},         // (subrame number 4,9)
-{0xc0,         -1,         2,         1,         924,         2,         1,         6,         2},         // (subrame number 2,3,4,7,8,9)
-{0xc0,         -1,         1,         0,         512,         2,         2,         6,         2},         // (subrame number 9)
-{0xc0,         -1,         1,         0,         512,         8,         1,         3,         2},         // (subrame number 9)
-{0xc0,         -1,         1,         0,         512,         2,         1,         6,         2},         // (subrame number 9)
-{0xc0,         -1,         1,         0,         768,         2,         2,         6,         2},         // (subrame number 8,9)
-{0xc0,         -1,         1,         0,         528,         2,         1,         6,         2},         // (subrame number 4,9)
-{0xc0,         -1,         1,         0,         640,         8,         1,         3,         2},         // (subrame number 7,9)
-{0xc0,         -1,         1,         0,         792,         2,         1,         6,         2},         // (subrame number 3,4,8,9)
-{0xc0,         -1,         1,         0,         792,         2,         2,         6,         2},         // (subrame number 3,4,8,9)
-{0xc0,         -1,         1,         0,         682,         2,         1,         6,         2},         // (subrame number 1,3,5,7,9)
-{0xc0,         -1,         1,         0,         1023,        8,         1,         3,         2},         // (subrame number 0,1,2,3,4,5,6,7,8,9)
-{0xc2,         -1,         16,        1,         512,         2,         2,         2,         6},         // (subrame number 9)
-{0xc2,         -1,         8,         1,         512,         2,         2,         2,         6},         // (subrame number 9)
-{0xc2,         -1,         4,         1,         512,         2,         1,         2,         6},         // (subrame number 9)
-{0xc2,         -1,         2,         1,         512,         2,         1,         2,         6},         // (subrame number 9)
-{0xc2,         -1,         2,         1,         768,         2,         2,         2,         6},         // (subrame number 8,9)
-{0xc2,         -1,         2,         1,         640,         2,         1,         2,         6},         // (subrame number 7,9)
-{0xc2,         -1,         2,         1,         640,         8,         1,         1,         6},         // (subrame number 7,9)
-{0xc2,         -1,         2,         1,         528,         8,         1,         1,         6},         // (subrame number 4,9)
-{0xc2,         -1,         2,         1,         528,         2,         2,         2,         6},         // (subrame number 4,9)
-{0xc2,         -1,         2,         1,         924,         2,         1,         2,         6},         // (subrame number 2,3,4,7,8,9)
-{0xc2,         -1,         8,         1,         512,         8,         2,         1,         6},         // (subrame number 9)
-{0xc2,         -1,         4,         1,         512,         8,         1,         1,         6},         // (subrame number 9)
-{0xc2,         -1,         1,         0,         512,         2,         2,         2,         6},         // (subrame number 9)
-{0xc2,         -1,         1,         0,         512,         8,         1,         1,         6},         // (subrame number 9)
-{0xc2,         -1,         1,         0,         512,         2,         1,         2,         6},         // (subrame number 9)
-{0xc2,         -1,         1,         0,         768,         2,         2,         2,         6},         // (subrame number 8,9)
-{0xc2,         -1,         1,         0,         528,         2,         1,         2,         6},         // (subrame number 4,9)
-{0xc2,         -1,         1,         0,         640,         8,         1,         1,         6},         // (subrame number 7,9)
-{0xc2,         -1,         1,         0,         792,         2,         1,         2,         6},         // (subrame number 3,4,8,9)
-{0xc2,         -1,         1,         0,         792,         2,         2,         2,         6},         // (subrame number 3,4,8,9)
-{0xc2,         -1,         1,         0,         682,         2,         1,         2,         6},         // (subrame number 1,3,5,7,9)
-{0xc2,         -1,         1,         0,         1023,        8,         1,         1,         6},         // (subrame number 0,1,2,3,4,5,6,7,8,9)
-{0xa1,         0xb1,       2,         1,         512,         2,         1,         6,         2},         // (subrame number 9)
-{0xa1,         0xb1,       2,         1,         528,         8,         1,         3,         2},         // (subrame number 4,9)
-{0xa1,         0xb1,       2,         1,         640,         8,         1,         3,         2},         // (subrame number 7,9)
-{0xa1,         0xb1,       2,         1,         640,         2,         1,         6,         2},         // (subrame number 7,9)
-{0xa1,         0xb1,       2,         1,         528,         2,         2,         6,         2},         // (subrame number 4,9)
-{0xa1,         0xb1,       2,         1,         768,         2,         2,         6,         2},         // (subrame number 8,9)
-{0xa1,         0xb1,       1,         0,         512,         2,         2,         6,         2},         // (subrame number 9)
-{0xa1,         0xb1,       1,         0,         512,         8,         1,         3,         2},         // (subrame number 9)
-{0xa1,         0xb1,       1,         0,         512,         2,         1,         6,         2},         // (subrame number 9)
-{0xa1,         0xb1,       1,         0,         768,         2,         2,         6,         2},         // (subrame number 8,9)
-{0xa1,         0xb1,       1,         0,         528,         2,         1,         6,         2},         // (subrame number 4,9)
-{0xa1,         0xb1,       1,         0,         640,         8,         1,         3,         2},         // (subrame number 7,9)
-{0xa1,         0xb1,       1,         0,         792,         2,         2,         6,         2},         // (subrame number 3,4,8,9)
-{0xa1,         0xb1,       1,         0,         682,         2,         1,         6,         2},         // (subrame number 1,3,5,7,9)
-{0xa1,         0xb1,       1,         0,         1023,        8,         1,         3,         2},         // (subrame number 0,1,2,3,4,5,6,7,8,9)
-{0xa2,         0xb2,       2,         1,         512,         0,         1,         3,         4},         // (subrame number 9)
-{0xa2,         0xb2,       2,         1,         528,         6,         1,         2,         4},         // (subrame number 4,9)
-{0xa2,         0xb2,       2,         1,         640,         6,         1,         2,         4},         // (subrame number 7,9)
-{0xa2,         0xb2,       2,         1,         528,         0,         2,         3,         4},         // (subrame number 4,9)
-{0xa2,         0xb2,       2,         1,         768,         0,         2,         3,         4},         // (subrame number 8,9)
-{0xa2,         0xb2,       1,         0,         512,         0,         2,         3,         4},         // (subrame number 9)
-{0xa2,         0xb2,       1,         0,         512,         6,         1,         2,         4},         // (subrame number 9)
-{0xa2,         0xb2,       1,         0,         512,         0,         1,         3,         4},         // (subrame number 9)
-{0xa2,         0xb2,       1,         0,         768,         0,         2,         3,         4},         // (subrame number 8,9)
-{0xa2,         0xb2,       1,         0,         528,         0,         1,         3,         4},         // (subrame number 4,9)
-{0xa2,         0xb2,       1,         0,         640,         6,         1,         2,         4},         // (subrame number 7,9)
-{0xa2,         0xb2,       1,         0,         792,         0,         1,         3,         4},         // (subrame number 3,4,8,9)
-{0xa2,         0xb2,       1,         0,         792,         0,         2,         3,         4},         // (subrame number 3,4,8,9)
-{0xa2,         0xb2,       1,         0,         682,         0,         1,         3,         4},         // (subrame number 1,3,5,7,9)
-{0xa2,         0xb2,       1,         0,         1023,        6,         1,         2,         4},         // (subrame number 0,1,2,3,4,5,6,7,8,9)
-{0xa3,         0xb3,       2,         1,         512,         0,         1,         2,         6},         // (subrame number 9)
-{0xa3,         0xb3,       2,         1,         528,         2,         1,         2,         6},         // (subrame number 4,9)
-{0xa3,         0xb3,       2,         1,         640,         0,         1,         2,         6},         // (subrame number 7,9)
-{0xa3,         0xb3,       2,         1,         640,         2,         1,         2,         6},         // (subrame number 7,9)
-{0xa3,         0xb3,       2,         1,         528,         0,         2,         2,         6},         // (subrame number 4,9)
-{0xa3,         0xb3,       2,         1,         768,         0,         2,         2,         6},         // (subrame number 8,9)
-{0xa3,         0xb3,       1,         0,         512,         0,         2,         2,         6},         // (subrame number 9)
-{0xa3,         0xb3,       1,         0,         512,         2,         1,         2,         6},         // (subrame number 9)
-{0xa3,         0xb3,       1,         0,         512,         0,         1,         2,         6},         // (subrame number 9)
-{0xa3,         0xb3,       1,         0,         768,         0,         2,         2,         6},         // (subrame number 8,9)
-{0xa3,         0xb3,       1,         0,         528,         0,         1,         2,         6},         // (subrame number 4,9)
-{0xa3,         0xb3,       1,         0,         640,         2,         1,         2,         6},         // (subrame number 7,9)
-{0xa3,         0xb3,       1,         0,         792,         0,         2,         2,         6},         // (subrame number 3,4,8,9)
-{0xa3,         0xb3,       1,         0,         682,         0,         1,         2,         6},         // (subrame number 1,3,5,7,9)
-{0xa3,         0xb3,       1,         0,         1023,        2,         1,         2,         6}          // (subrame number 0,1,2,3,4,5,6,7,8,9)
-};
-// Table 6.3.3.2-4: Random access configurations for FR2 and unpaired spectrum
-int64_t table_6_3_3_2_4_prachConfig_Index [256][10] = {
-//format,      format,       x,          y,           y,              SFN_nbr,       star_symb,   slots_sfn,  occ_slot,  duration
-{0xa1,          -1,          16,         1,          -1,          567489872400,          0,          2,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          -1,          16,         1,          -1,          586406201480,          0,          1,          6,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa1,          -1,          8,          1,           2,          550293209600,          0,          2,          6,          2},          // (subframe number :9,19,29,39)
-{0xa1,          -1,          8,          1,          -1,          567489872400,          0,          2,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          -1,          8,          1,          -1,          586406201480,          0,          1,          6,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa1,          -1,          4,          1,          -1,          567489872400,          0,          1,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          -1,          4,          1,          -1,          567489872400,          0,          2,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          -1,          4,          1,          -1,          586406201480,          0,          1,          6,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa1,          -1,          2,          1,          -1,          551911719040,          0,          2,          6,          2},          // (subframe number :7,15,23,31,39)
-{0xa1,          -1,          2,          1,          -1,          567489872400,          0,          1,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          -1,          2,          1,          -1,          567489872400,          0,          2,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          -1,          2,          1,          -1,          586406201480,          0,          1,          6,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa1,          -1,          1,          0,          -1,          549756338176,          7,          1,          3,          2},          // (subframe number :19,39)
-{0xa1,          -1,          1,          0,          -1,          168,                   0,          1,          6,          2},          // (subframe number :3,5,7)
-{0xa1,          -1,          1,          0,          -1,          567489331200,          7,          1,          3,          2},          // (subframe number :24,29,34,39)
-{0xa1,          -1,          1,          0,          -1,          550293209600,          7,          2,          3,          2},          // (subframe number :9,19,29,39)
-{0xa1,          -1,          1,          0,          -1,          687195422720,          0,          1,          6,          2},          // (subframe number :17,19,37,39)
-{0xa1,          -1,          1,          0,          -1,          550293209600,          0,          2,          6,          2},          // (subframe number :9,19,29,39)
-{0xa1,          -1,          1,          0,          -1,          567489872400,          0,          1,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          -1,          1,          0,          -1,          567489872400,          7,          1,          3,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          -1,          1,          0,          -1,          10920,                 7,          1,          3,          2},          // (subframe number :3,5,7,9,11,13)
-{0xa1,          -1,          1,          0,          -1,          586405642240,          7,          1,          3,          2},          // (subframe number :23,27,31,35,39)
-{0xa1,          -1,          1,          0,          -1,          551911719040,          0,          1,          6,          2},          // (subframe number :7,15,23,31,39)
-{0xa1,          -1,          1,          0,          -1,          586405642240,          0,          1,          6,          2},          // (subframe number :23,27,31,35,39)
-{0xa1,          -1,          1,          0,          -1,          965830828032,          7,          2,          3,          2},          // (subframe number :13,14,15, 29,30,31,37,38,39)
-{0xa1,          -1,          1,          0,          -1,          586406201480,          7,          1,          3,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa1,          -1,          1,          0,          -1,          586406201480,          0,          1,          6,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa1,          -1,          1,          0,          -1,          733007751850,          0,          1,          6,          2},          // (subframe number :1,3,5,7,…,37,39)
-{0xa1,          -1,          1,          0,          -1,          1099511627775,         7,          1,          3,          2},          // (subframe number :0,1,2,…,39)
-{0xa2,          -1,          16,         1,          -1,          567489872400,          0,          2,          3,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          -1,          16,         1,          -1,          586406201480,          0,          1,          3,          4},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa2,          -1,          8,          1,          -1,          567489872400,          0,          2,          3,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          -1,          8,          1,          -1,          586406201480,          0,          1,          3,          4},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa2,          -1,          8,          1,           2,          550293209600,          0,          2,          3,          4},          // (subframe number :9,19,29,39)
-{0xa2,          -1,          4,          1,          -1,          567489872400,          0,          1,          3,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          -1,          4,          1,          -1,          567489872400,          0,          2,          3,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          -1,          4,          1,          -1,          586406201480,          0,          1,          3,          4},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa2,          -1,          2,          1,          -1,          551911719040,          0,          2,          3,          4},          // (subframe number :7,15,23,31,39)
-{0xa2,          -1,          2,          1,          -1,          567489872400,          0,          1,          3,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          -1,          2,          1,          -1,          567489872400,          0,          2,          3,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          -1,          2,          1,          -1,          586406201480,          0,          1,          3,          4},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa2,          -1,          1,          0,          -1,          549756338176,          5,          1,          2,          4},          // (subframe number :19,39)
-{0xa2,          -1,          1,          0,          -1,          168,                   0,          1,          3,          4},          // (subframe number :3,5,7)
-{0xa2,          -1,          1,          0,          -1,          567489331200,          5,          1,          2,          4},          // (subframe number :24,29,34,39)
-{0xa2,          -1,          1,          0,          -1,          550293209600,          5,          2,          2,          4},          // (subframe number :9,19,29,39)
-{0xa2,          -1,          1,          0,          -1,          687195422720,          0,          1,          3,          4},          // (subframe number :17,19,37,39)
-{0xa2,          -1,          1,          0,          -1,          550293209600,          0,          2,          3,          4},          // (subframe number :9, 19, 29, 39)
-{0xa2,          -1,          1,          0,          -1,          551911719040,          0,          1,          3,          4},          // (subframe number :7,15,23,31,39)
-{0xa2,          -1,          1,          0,          -1,          586405642240,          5,          1,          2,          4},          // (subframe number :23,27,31,35,39)
-{0xa2,          -1,          1,          0,          -1,          586405642240,          0,          1,          3,          4},          // (subframe number :23,27,31,35,39)
-{0xa2,          -1,          1,          0,          -1,          10920,                 5,          1,          2,          4},          // (subframe number :3,5,7,9,11,13)
-{0xa2,          -1,          1,          0,          -1,          10920,                 0,          1,          3,          4},          // (subframe number :3,5,7,9,11,13)
-{0xa2,          -1,          1,          0,          -1,          567489872400,          5,          1,          2,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          -1,          1,          0,          -1,          567489872400,          0,          1,          3,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          -1,          1,          0,          -1,          965830828032,          5,          2,          2,          4},          // (subframe number :13,14,15, 29,30,31,37,38,39)
-{0xa2,          -1,          1,          0,          -1,          586406201480,          5,          1,          2,          4},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa2,          -1,          1,          0,          -1,          586406201480,          0,          1,          3,          4},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa2,          -1,          1,          0,          -1,          733007751850,          0,          1,          3,          4},          // (subframe number :1,3,5,7,…,37,39)
-{0xa2,          -1,          1,          0,          -1,          1099511627775,         5,          1,          2,          4},          // (subframe number :0,1,2,…,39)
-{0xa3,          -1,          16,         1,          -1,          567489872400,          0,          2,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          -1,          16,         1,          -1,          586406201480,          0,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa3,          -1,          8,          1,          -1,          567489872400,          0,          2,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          -1,          8,          1,          -1,          586406201480,          0,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa3,          -1,          8,          1,           2,          550293209600,          0,          2,          2,          6},          // (subframe number :9,19,29,39)
-{0xa3,          -1,          4,          1,          -1,          567489872400,          0,          1,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          -1,          4,          1,          -1,          567489872400,          0,          2,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          -1,          4,          1,          -1,          586406201480,          0,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa3,          -1,          2,          1,          -1,          567489872400,          0,          1,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          -1,          2,          1,          -1,          567489872400,          0,          2,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          -1,          2,          1,          -1,          586406201480,          0,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa3,          -1,          1,          0,          -1,          549756338176,          7,          1,          1,          6},          // (subframe number :19,39)
-{0xa3,          -1,          1,          0,          -1,          168,                   0,          1,          2,          6},          // (subframe number :3,5,7)
-{0xa3,          -1,          1,          0,          -1,          10752,                 2,          1,          2,          6},          // (subframe number :9,11,13)
-{0xa3,          -1,          1,          0,          -1,          567489331200,          7,          1,          1,          6},          // (subframe number :24,29,34,39)
-{0xa3,          -1,          1,          0,          -1,          550293209600,          7,          2,          1,          6},          // (subframe number :9,19,29,39)
-{0xa3,          -1,          1,          0,          -1,          687195422720,          0,          1,          2,          6},          // (subframe number :17,19,37,39)
-{0xa3,          -1,          1,          0,          -1,          550293209600,          0,          2,          2,          6},          // (subframe number :9,19,29,39)
-{0xa3,          -1,          1,          0,          -1,          551911719040,          0,          1,          2,          6},          // (subframe number :7,15,23,31,39)
-{0xa3,          -1,          1,          0,          -1,          586405642240,          7,          1,          1,          6},          // (subframe number :23,27,31,35,39)
-{0xa3,          -1,          1,          0,          -1,          586405642240,          0,          1,          2,          6},          // (subframe number :23,27,31,35,39)
-{0xa3,          -1,          1,          0,          -1,          10920,                 0,          1,          2,          6},          // (subframe number :3,5,7,9,11,13)
-{0xa3,          -1,          1,          0,          -1,          10920,                 7,          1,          1,          6},          // (subframe number :3,5,7,9,11,13)
-{0xa3,          -1,          1,          0,          -1,          567489872400,          0,          1,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          -1,          1,          0,          -1,          567489872400,          7,          1,          1,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          -1,          1,          0,          -1,          965830828032,          7,          2,          1,          6},          // (subframe number :13,14,15, 29,30,31,37,38,39)
-{0xa3,          -1,          1,          0,          -1,          586406201480,          7,          1,          1,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa3,          -1,          1,          0,          -1,          586406201480,          0,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa3,          -1,          1,          0,          -1,          733007751850,          0,          1,          2,          6},          // (subframe number :1,3,5,7,…,37,39)
-{0xa3,          -1,          1,          0,          -1,          1099511627775,         7,          1,          1,          6},          // (subframe number :0,1,2,…,39)
-{0xb1,          -1,          16,         1,          -1,          567489872400,          2,          2,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xb1,          -1,          8,          1,          -1,          567489872400,          2,          2,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xb1,          -1,          8,          1,           2,          550293209600,          2,          2,          6,          2},          // (subframe number :9,19,29,39)
-{0xb1,          -1,          4,          1,          -1,          567489872400,          2,          2,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xb1,          -1,          2,          1,          -1,          567489872400,          2,          2,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xb1,          -1,          2,          1,          -1,          586406201480,          2,          1,          6,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xb1,          -1,          1,          0,          -1,          549756338176,          8,          1,          3,          2},          // (subframe number :19,39)
-{0xb1,          -1,          1,          0,          -1,          168,                   2,          1,          6,          2},          // (subframe number :3,5,7)
-{0xb1,          -1,          1,          0,          -1,          567489331200,          8,          1,          3,          2},          // (subframe number :24,29,34,39)
-{0xb1,          -1,          1,          0,          -1,          550293209600,          8,          2,          3,          2},          // (subframe number :9,19,29,39)
-{0xb1,          -1,          1,          0,          -1,          687195422720,          2,          1,          6,          2},          // (subframe number :17,19,37,39)
-{0xb1,          -1,          1,          0,          -1,          550293209600,          2,          2,          6,          2},          // (subframe number :9,19,29,39)
-{0xb1,          -1,          1,          0,          -1,          551911719040,          2,          1,          6,          2},          // (subframe number :7,15,23,31,39)
-{0xb1,          -1,          1,          0,          -1,          586405642240,          8,          1,          3,          2},          // (subframe number :23,27,31,35,39)
-{0xb1,          -1,          1,          0,          -1,          586405642240,          2,          1,          6,          2},          // (subframe number :23,27,31,35,39)
-{0xb1,          -1,          1,          0,          -1,          10920,                 8,          1,          3,          2},          // (subframe number :3,5,7,9,11,13)
-{0xb1,          -1,          1,          0,          -1,          567489872400,          8,          1,          3,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xb1,          -1,          1,          0,          -1,          567489872400,          2,          1,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xb1,          -1,          1,          0,          -1,          586406201480,          8,          1,          3,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xb1,          -1,          1,          0,          -1,          965830828032,          8,          2,          3,          2},          // (subframe number :13,14,15, 29,30,31,37,38,39)
-{0xb1,          -1,          1,          0,          -1,          586406201480,          2,          1,          6,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xb1,          -1,          1,          0,          -1,          733007751850,          2,          1,          6,          2},          // (subframe number :1,3,5,7,…,37,39)
-{0xb1,          -1,          1,          0,          -1,          1099511627775,         8,          1,          3,          2},          // (subframe number :0,1,2,…,39)
-{0xb4,          -1,          16,         1,           2,          567489872400,          0,          2,          1,          12},         // (subframe number :4,9,14,19,24,29,34,39)
-{0xb4,          -1,          16,         1,           2,          586406201480,          0,          1,          1,          12},         // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xb4,          -1,          8,          1,           2,          567489872400,          0,          2,          1,          12},         // (subframe number :4,9,14,19,24,29,34,39)
-{0xb4,          -1,          8,          1,           2,          586406201480,          0,          1,          1,          12},         // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xb4,          -1,          8,          1,           2,          550293209600,          0,          2,          1,          12},         // (subframe number :9,19,29,39)
-{0xb4,          -1,          4,          1,          -1,          567489872400,          0,          1,          1,          12},         // (subframe number :4,9,14,19,24,29,34,39)
-{0xb4,          -1,          4,          1,          -1,          567489872400,          0,          2,          1,          12},         // (subframe number :4,9,14,19,24,29,34,39)
-{0xb4,          -1,          4,          1,           2,          586406201480,          0,          1,          1,          12},         // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xb4,          -1,          2,          1,          -1,          551911719040,          2,          2,          1,          12},         // (subframe number :7,15,23,31,39)
-{0xb4,          -1,          2,          1,          -1,          567489872400,          0,          1,          1,          12},         // (subframe number :4,9,14,19,24,29,34,39)
-{0xb4,          -1,          2,          1,          -1,          567489872400,          0,          2,          1,          12},         // (subframe number :4,9,14,19,24,29,34,39)
-{0xb4,          -1,          2,          1,          -1,          586406201480,          0,          1,          1,          12},         // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xb4,          -1,          1,          0,          -1,          549756338176,          2,          2,          1,          12},         // (subframe number :19, 39)
-{0xb4,          -1,          1,          0,          -1,          687195422720,          0,          1,          1,          12},         // (subframe number :17, 19, 37, 39)
-{0xb4,          -1,          1,          0,          -1,          567489331200,          2,          1,          1,          12},         // (subframe number :24,29,34,39)
-{0xb4,          -1,          1,          0,          -1,          550293209600,          2,          2,          1,          12},         // (subframe number :9,19,29,39)
-{0xb4,          -1,          1,          0,          -1,          550293209600,          0,          2,          1,          12},         // (subframe number :9,19,29,39)
-{0xb4,          -1,          1,          0,          -1,          551911719040,          0,          1,          1,          12},         // (subframe number :7,15,23,31,39)
-{0xb4,          -1,          1,          0,          -1,          551911719040,          0,          2,          1,          12},         // (subframe number :7,15,23,31,39)
-{0xb4,          -1,          1,          0,          -1,          586405642240,          0,          1,          1,          12},         // (subframe number :23,27,31,35,39)
-{0xb4,          -1,          1,          0,          -1,          586405642240,          2,          2,          1,          12},         // (subframe number :23,27,31,35,39)
-{0xb4,          -1,          1,          0,          -1,          698880,                0,          1,          1,          12},         // (subframe number :9,11,13,15,17,19)
-{0xb4,          -1,          1,          0,          -1,          10920,                 2,          1,          1,          12},         // (subframe number :3,5,7,9,11,13)
-{0xb4,          -1,          1,          0,          -1,          567489872400,          0,          1,          1,          12},         // (subframe number :4,9,14,19,24,29,34,39)
-{0xb4,          -1,          1,          0,          -1,          567489872400,          2,          2,          1,          12},         // (subframe number :4,9,14,19,24,29,34,39)
-{0xb4,          -1,          1,          0,          -1,          965830828032,          2,          2,          1,          12},         // (subframe number :13,14,15, 29,30,31,37,38,39)
-{0xb4,          -1,          1,          0,          -1,          586406201480,          0,          1,          1,          12},         // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xb4,          -1,          1,          0,          -1,          586406201480,          2,          1,          1,          12},         // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xb4,          -1,          1,          0,          -1,          44739240,              2,          1,          1,          12},         // (subframe number :3, 5, 7, …, 23,25)
-{0xb4,          -1,          1,          0,          -1,          44739240,              0,          2,          1,          12},         // (subframe number :3, 5, 7, …, 23,25)
-{0xb4,          -1,          1,          0,          -1,          733007751850,          0,          1,          1,          12},         // (subframe number :1,3,5,7,…,37,39)
-{0xb4,          -1,          1,          0,          -1,          1099511627775,         2,          1,          1,          12},         // (subframe number :0, 1, 2,…, 39)
-{0xc0,          -1,          16,         1,          -1,          567489872400,          0,          2,          7,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc0,          -1,          16,         1,          -1,          586406201480,          0,          1,          7,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xc0,          -1,          8,          1,          -1,          567489872400,          0,          1,          7,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc0,          -1,          8,          1,          -1,          586406201480,          0,          1,          7,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xc0,          -1,          8,          1,           2,          550293209600,          0,          2,          7,          2},          // (subframe number :9,19,29,39)
-{0xc0,          -1,          4,          1,          -1,          567489872400,          0,          1,          7,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc0,          -1,          4,          1,          -1,          567489872400,          0,          2,          7,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc0,          -1,          4,          1,          -1,          586406201480,          0,          1,          7,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xc0,          -1,          2,          1,          -1,          551911719040,          0,          2,          7,          2},          // (subframe number :7,15,23,31,39)
-{0xc0,          -1,          2,          1,          -1,          567489872400,          0,          1,          7,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc0,          -1,          2,          1,          -1,          567489872400,          0,          2,          7,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc0,          -1,          2,          1,          -1,          586406201480,          0,          1,          7,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xc0,          -1,          1,          0,          -1,          549756338176,          8,          1,          3,          2},          // (subframe number :19,39)
-{0xc0,          -1,          1,          0,          -1,          168,                   0,          1,          7,          2},          // (subframe number :3,5,7)
-{0xc0,          -1,          1,          0,          -1,          567489331200,          8,          1,          3,          2},          // (subframe number :24,29,34,39)
-{0xc0,          -1,          1,          0,          -1,          550293209600,          8,          2,          3,          2},          // (subframe number :9,19,29,39)
-{0xc0,          -1,          1,          0,          -1,          687195422720,          0,          1,          7,          2},          // (subframe number :17,19,37,39)
-{0xc0,          -1,          1,          0,          -1,          550293209600,          0,          2,          7,          2},          // (subframe number :9,19,29,39)
-{0xc0,          -1,          1,          0,          -1,          586405642240,          8,          1,          3,          2},          // (subframe number :23,27,31,35,39)
-{0xc0,          -1,          1,          0,          -1,          551911719040,          0,          1,          7,          2},          // (subframe number :7,15,23,31,39)
-{0xc0,          -1,          1,          0,          -1,          586405642240,          0,          1,          7,          2},          // (subframe number :23,27,31,35,39)
-{0xc0,          -1,          1,          0,          -1,          10920,                 8,          1,          3,          2},          // (subframe number :3,5,7,9,11,13)
-{0xc0,          -1,          1,          0,          -1,          567489872400,          8,          1,          3,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc0,          -1,          1,          0,          -1,          567489872400,          0,          1,          7,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc0,          -1,          1,          0,          -1,          965830828032,          8,          2,          3,          2},          // (subframe number :13,14,15, 29,30,31,37,38,39)
-{0xc0,          -1,          1,          0,          -1,          586406201480,          8,          1,          3,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xc0,          -1,          1,          0,          -1,          586406201480,          0,          1,          7,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xc0,          -1,          1,          0,          -1,          733007751850,          0,          1,          7,          2},          // (subframe number :1,3,5,7,…,37,39)
-{0xc0,          -1,          1,          0,          -1,          1099511627775,         8,          1,          3,          2},          // (subframe number :0,1,2,…,39)
-{0xc2,          -1,          16,         1,          -1,          567489872400,          0,          2,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc2,          -1,          16,         1,          -1,          586406201480,          0,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xc2,          -1,          8,          1,          -1,          567489872400,          0,          2,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc2,          -1,          8,          1,          -1,          586406201480,          0,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xc2,          -1,          8,          1,           2,          550293209600,          0,          2,          2,          6},          // (subframe number :9,19,29,39)
-{0xc2,          -1,          4,          1,          -1,          567489872400,          0,          1,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc2,          -1,          4,          1,          -1,          567489872400,          0,          2,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc2,          -1,          4,          1,          -1,          586406201480,          0,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xc2,          -1,          2,          1,          -1,          551911719040,          2,          2,          2,          6},          // (subframe number :7,15,23,31,39)
-{0xc2,          -1,          2,          1,          -1,          567489872400,          0,          1,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc2,          -1,          2,          1,          -1,          567489872400,          0,          2,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc2,          -1,          2,          1,          -1,          586406201480,          0,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xc2,          -1,          1,          0,          -1,          549756338176,          2,          1,          2,          6},          // (subframe number :19,39)
-{0xc2,          -1,          1,          0,          -1,          168,                   0,          1,          2,          6},          // (subframe number :3,5,7)
-{0xc2,          -1,          1,          0,          -1,          567489331200,          7,          1,          1,          6},          // (subframe number :24,29,34,39)
-{0xc2,          -1,          1,          0,          -1,          550293209600,          7,          2,          1,          6},          // (subframe number :9,19,29,39)
-{0xc2,          -1,          1,          0,          -1,          687195422720,          0,          1,          2,          6},          // (subframe number :17,19,37,39)
-{0xc2,          -1,          1,          0,          -1,          550293209600,          2,          2,          2,          6},          // (subframe number :9,19,29,39)
-{0xc2,          -1,          1,          0,          -1,          551911719040,          2,          1,          2,          6},          // (subframe number :7,15,23,31,39)
-{0xc2,          -1,          1,          0,          -1,          10920,                 7,          1,          1,          6},          // (subframe number :3,5,7,9,11,13)
-{0xc2,          -1,          1,          0,          -1,          586405642240,          7,          2,          1,          6},          // (subframe number :23,27,31,35,39)
-{0xc2,          -1,          1,          0,          -1,          586405642240,          0,          1,          2,          6},          // (subframe number :23,27,31,35,39)
-{0xc2,          -1,          1,          0,          -1,          567489872400,          7,          2,          1,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc2,          -1,          1,          0,          -1,          567489872400,          2,          1,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xc2,          -1,          1,          0,          -1,          965830828032,          7,          2,          1,          6},          // (subframe number :13,14,15, 29,30,31,37,38,39)
-{0xc2,          -1,          1,          0,          -1,          586406201480,          7,          1,          1,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xc2,          -1,          1,          0,          -1,          586406201480,          0,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xc2,          -1,          1,          0,          -1,          733007751850,          0,          1,          2,          6},          // (subframe number :1,3,5,7,…,37,39)
-{0xc2,          -1,          1,          0,          -1,          1099511627775,         7,          1,          1,          6},          // (subframe number :0,1,2,…,39)
-{0xa1,          0xb1,        16,         1,          -1,          567489872400,          2,          1,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          0xb1,        16,         1,          -1,          586406201480,          2,          1,          6,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa1,          0xb1,        8,          1,          -1,          567489872400,          2,          1,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          0xb1,        8,          1,          -1,          586406201480,          2,          1,          6,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa1,          0xb1,        4,          1,          -1,          567489872400,          2,          1,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          0xb1,        4,          1,          -1,          586406201480,          2,          1,          6,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa1,          0xb1,        2,          1,          -1,          567489872400,          2,          1,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          0xb1,        1,          0,          -1,          549756338176,          8,          1,          3,          2},          // (subframe number :19,39)
-{0xa1,          0xb1,        1,          0,          -1,          550293209600,          8,          1,          3,          2},          // (subframe number :9,19,29,39)
-{0xa1,          0xb1,        1,          0,          -1,          687195422720,          2,          1,          6,          2},          // (subframe number :17,19,37,39)
-{0xa1,          0xb1,        1,          0,          -1,          550293209600,          2,          2,          6,          2},          // (subframe number :9,19,29,39)
-{0xa1,          0xb1,        1,          0,          -1,          586405642240,          8,          1,          3,          2},          // (subframe number :23,27,31,35,39)
-{0xa1,          0xb1,        1,          0,          -1,          551911719040,          2,          1,          6,          2},          // (subframe number :7,15,23,31,39)
-{0xa1,          0xb1,        1,          0,          -1,          586405642240,          2,          1,          6,          2},          // (subframe number :23,27,31,35,39)
-{0xa1,          0xb1,        1,          0,          -1,          567489872400,          8,          1,          3,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          0xb1,        1,          0,          -1,          567489872400,          2,          1,          6,          2},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa1,          0xb1,        1,          0,          -1,          586406201480,          2,          1,          6,          2},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa1,          0xb1,        1,          0,          -1,          733007751850,          2,          1,          6,          2},          // (subframe number :1,3,5,7,…,37,39)
-{0xa2,          0xb2,        16,         1,          -1,          567489872400,          2,          1,          3,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          0xb2,        16,         1,          -1,          586406201480,          2,          1,          3,          4},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa2,          0xb2,        8,          1,          -1,          567489872400,          2,          1,          3,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          0xb2,        8,          1,          -1,          586406201480,          2,          1,          3,          4},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa2,          0xb2,        4,          1,          -1,          567489872400,          2,          1,          3,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          0xb2,        4,          1,          -1,          586406201480,          2,          1,          3,          4},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa2,          0xb2,        2,          1,          -1,          567489872400,          2,          1,          3,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          0xb2,        1,          0,          -1,          549756338176,          6,          1,          2,          4},          // (subframe number :19,39)
-{0xa2,          0xb2,        1,          0,          -1,          550293209600,          6,          1,          2,          4},          // (subframe number :9,19,29,39)
-{0xa2,          0xb2,        1,          0,          -1,          687195422720,          2,          1,          3,          4},          // (subframe number :17,19,37,39)
-{0xa2,          0xb2,        1,          0,          -1,          550293209600,          2,          2,          3,          4},          // (subframe number :9,19,29,39)
-{0xa2,          0xb2,        1,          0,          -1,          586405642240,          6,          1,          2,          4},          // (subframe number :23,27,31,35,39)
-{0xa2,          0xb2,        1,          0,          -1,          551911719040,          2,          1,          3,          4},          // (subframe number :7,15,23,31,39)
-{0xa2,          0xb2,        1,          0,          -1,          586405642240,          2,          1,          3,          4},          // (subframe number :23,27,31,35,39)
-{0xa2,          0xb2,        1,          0,          -1,          567489872400,          6,          1,          2,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          0xb2,        1,          0,          -1,          567489872400,          2,          1,          3,          4},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa2,          0xb2,        1,          0,          -1,          586406201480,          2,          1,          3,          4},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa2,          0xb2,        1,          0,          -1,          733007751850,          2,          1,          3,          4},          // (subframe number :1,3,5,7,…,37,39)
-{0xa3,          0xb3,        16,         1,          -1,          567489872400,          2,          1,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          0xb3,        16,         1,          -1,          586406201480,          2,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa3,          0xb3,        8,          1,          -1,          567489872400,          2,          1,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          0xb3,        8,          1,          -1,          586406201480,          2,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa3,          0xb3,        4,          1,          -1,          567489872400,          2,          1,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          0xb3,        4,          1,          -1,          586406201480,          2,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa3,          0xb3,        2,          1,          -1,          567489872400,          2,          1,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          0xb3,        1,          0,          -1,          549756338176,          2,          1,          2,          6},          // (subframe number :19,39)
-{0xa3,          0xb3,        1,          0,          -1,          550293209600,          2,          1,          2,          6},          // (subframe number :9,19,29,39)
-{0xa3,          0xb3,        1,          0,          -1,          687195422720,          2,          1,          2,          6},          // (subframe number :17,19,37,39)
-{0xa3,          0xb3,        1,          0,          -1,          550293209600,          2,          2,          2,          6},          // (subframe number :9,19,29,39)
-{0xa3,          0xb3,        1,          0,          -1,          551911719040,          2,          1,          2,          6},          // (subframe number :7,15,23,31,39)
-{0xa3,          0xb3,        1,          0,          -1,          586405642240,          2,          1,          2,          6},          // (subframe number :23,27,31,35,39)
-{0xa3,          0xb3,        1,          0,          -1,          586405642240,          2,          2,          2,          6},          // (subframe number :23,27,31,35,39)
-{0xa3,          0xb3,        1,          0,          -1,          567489872400,          2,          1,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          0xb3,        1,          0,          -1,          567489872400,          2,          2,          2,          6},          // (subframe number :4,9,14,19,24,29,34,39)
-{0xa3,          0xb3,        1,          0,          -1,          586406201480,          2,          1,          2,          6},          // (subframe number :3,7,11,15,19,23,27,31,35,39)
-{0xa3,          0xb3,        1,          0,          -1,          733007751850,          2,          1,          2,          6}           // (subframe number :1,3,5,7,…,37,39)
-};
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h
index 348774b08ac..35fe8bc8992 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h
@@ -47,7 +47,8 @@
     \brief This function frees memory allocated for a particular DLSCH at UE
     @param dlsch Pointer to DLSCH to be removed
 */
-void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlsch);
+void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlsch,uint8_t N_RB_DL);
+
 
 /** \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
@@ -58,13 +59,12 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlsch);
     @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_nr_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);
-
+NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint16_t N_RB_DL, uint8_t abstraction_flag);
 
-void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulsch);
 
+void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulsch,unsigned char N_RB_UL);
 
-NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, uint8_t abstraction_flag);
+NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids, uint8_t abstraction_flag);
 
 void fill_UE_dlsch_MCH(PHY_VARS_NR_UE *ue,int mcs,int ndi,int rvidx,int eNB_id);
 
@@ -1114,6 +1114,7 @@ void *nr_dlsch_decoding_2thread0(void *arg);
 
 void *nr_dlsch_decoding_2thread1(void *arg);
 
+
 void nr_dlsch_unscrambling(int16_t* llr,
 			   uint32_t size,
 			   uint8_t q,
@@ -1125,17 +1126,10 @@ uint32_t dlsch_decoding_emul(PHY_VARS_NR_UE *phy_vars_ue,
                              PDSCH_t dlsch_id,
                              uint8_t eNB_id);
 
-
 int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue,
                     uint32_t frame,
-                    uint8_t nr_tti_rx,
-                    uint8_t eNB_id,
-                    MIMO_mode_t mimo_mode,
-                    uint32_t high_speed_flag,
-                    uint8_t is_secondary_ue,
-                    int nb_coreset_active,
-                    uint16_t symbol_mon,
-                    NR_SEARCHSPACE_TYPE_t searchSpaceType);
+                    uint32_t slot);
+
 
 /*! \brief Extract PSS and SSS resource elements
   @param phy_vars_ue Pointer to UE variables
@@ -1545,10 +1539,9 @@ uint8_t get_num_pdcch_symbols(uint8_t num_dci,DCI_ALLOC_t *dci_alloc,NR_DL_FRAME
 
 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 nr_pdcch_unscrambling(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t slot,
+                           int16_t *z, int16_t *z2,uint32_t length, uint16_t pdcch_DMRS_scrambling_id);
+
 
 
 
@@ -1712,46 +1705,14 @@ uint8_t get_prach_prb_offset(NR_DL_FRAME_PARMS *frame_parms,
 			     uint8_t n_ra_prboffset,
 			     uint8_t tdd_mapindex, uint16_t Nf);
 
-void nr_pdcch_unscrambling(uint16_t crnti, NR_DL_FRAME_PARMS *frame_parms, uint8_t nr_tti_rx,
-			   int16_t *z, uint32_t length, uint16_t pdcch_DMRS_scrambling_id, int do_common);
-
 
 uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t reset);
 
-uint8_t nr_dci_decoding_procedure(int s,
-                                  int p,
-                                  PHY_VARS_NR_UE *ue,
-                                  NR_DCI_ALLOC_t *dci_alloc,
-                                  NR_SEARCHSPACE_TYPE_t searchSpacetype,
-                                  int16_t eNB_id,
-                                  uint8_t nr_tti_rx,
-                                  uint8_t dci_fields_sizes_cnt[MAX_NR_DCI_DECODED_SLOT][NBR_NR_DCI_FIELDS][NBR_NR_FORMATS],
-                                  uint16_t n_RB_ULBWP,
-                                  uint16_t n_RB_DLBWP,
-                                  crc_scrambled_t *crc_scrambled,
-                                  format_found_t *format_found,
-                                  uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES]);
-
-int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue,
-        uint8_t eNB_id,
-        int frame,
-        uint8_t nr_tti_rx,
-        uint64_t dci_pdu[2],
-        uint16_t rnti,
-        uint8_t dci_length,
-        NR_DCI_format_t dci_format,
-        NR_UE_PDCCH *pdcch_vars,
-        NR_UE_PDSCH *pdsch_vars,
-        NR_UE_DLSCH_t **dlsch,
-        NR_UE_ULSCH_t *ulsch,
-        NR_DL_FRAME_PARMS *frame_parms,
-        PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
-        uint8_t beamforming_mode,
-        uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS],
-        uint16_t n_RB_ULBWP,
-        uint16_t n_RB_DLBWP,
-        uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES],
-	NR_DCI_INFO_EXTRACTED_t *nr_dci_info_extracted);
+uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
+				  int frame,
+				  int slot,
+				  fapi_nr_dci_indication_t *dci_ind);
+
 
 /** \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)
@@ -1795,20 +1756,11 @@ uint32_t  nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
 			    uint8_t is_crnti,
 			    uint8_t llr8_flag);
 
-int nr_extract_dci_info(PHY_VARS_NR_UE *ue,
-			uint8_t eNB_id,
-			lte_frame_type_t frame_type,
-			uint8_t dci_length,
-			uint16_t rnti,
-			uint64_t dci_pdu[2],
-			fapi_nr_dci_pdu_rel15_t *nr_pdci_info_extracted,
-			uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS],
-			NR_DCI_format_t dci_format,
-			uint8_t nr_tti_rx,
-			uint16_t n_RB_ULBWP,
-			uint16_t n_RB_DLBWP,
-			uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES]);
+
+
+int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, uint16_t Nf );
 
 void *dlsch_thread(void *arg);
 /**@}*/
 #endif
+
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
index 39b037a6005..fb560f229d2 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
@@ -42,6 +42,8 @@
 #include "UTIL/LISTS/list.h"
 #endif
 
+#include "LAYER2/NR_MAC_gNB/mac_proto.h"
+
 //#include "../LTE_TRANSPORT/transport_common.h"
 
 // structures below implement 36-211 and 36-212
@@ -127,9 +129,9 @@ typedef struct {
   /// LDPC-code outputs
   uint8_t *d[MAX_NUM_NR_ULSCH_SEGMENTS];
   /// LDPC-code outputs (TS 36.212 V15.4.0, Sec 5.3.2 p. 17)
-  uint8_t e[MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32))); 
+  uint8_t *e; 
   /// Rate matching (Interleaving) outputs (TS 36.212 V15.4.0, Sec 5.4.2.2 p. 30)
-  uint8_t f[MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32))); 
+  uint8_t *f; 
   /// Number of code segments
   uint32_t C;
   /// Number of bits in code segments
@@ -240,6 +242,8 @@ typedef struct {
   int16_t Po_SRS;
   /// num active cba group
   uint8_t num_active_cba_groups;
+  /// bit mask of PT-RS ofdm symbol indicies
+  uint16_t ptrs_symbols;
   /// num dci found for cba
   //uint8_t num_cba_dci[10];
   /// allocated CBA RNTI
@@ -278,13 +282,13 @@ typedef struct {
   /// MIMO mode for this DLSCH
   MIMO_nrmode_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_NR_DLSCH_SEGMENTS][3*8448];
+  int16_t *w[MAX_NUM_NR_DLSCH_SEGMENTS];
   /// 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_NR_DLSCH_SEGMENTS][3*8448];
   /// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
   int16_t *d[MAX_NUM_NR_DLSCH_SEGMENTS];
   /// LDPC processing buffers
-  t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_DLSCH_SEGMENTS];
+  t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_NR_DLSCH_SEGMENTS];
   /// Number of code segments 
   uint32_t C;
   /// Number of bits in code segments
@@ -299,12 +303,20 @@ typedef struct {
   int8_t delta_PUCCH;
   /// Number of soft channel bits
   uint32_t G;
+  /// Start PRB of BWP
+  uint16_t BWPStart;
+  /// Number of PRBs in BWP
+  uint16_t BWPSize;
   /// Current Number of RBs
   uint16_t nb_rb;
   /// Starting RB number
   uint16_t start_rb;
   /// Number of Symbols
   uint16_t nb_symbols;
+  /// DMRS symbol positions
+  uint16_t dlDmrsSymbPos;
+  /// DMRS Configuration Type
+  uint8_t dmrsConfigType;
   /// Starting Symbol number
   uint16_t start_symbol;
   /// Current subband PMI allocation
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c
index 2eb6dcd7fe6..55bac905208 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c
@@ -36,13 +36,14 @@
 #include "PHY/CODING/coding_defs.h"
 #include "PHY/CODING/coding_extern.h"
 #include "PHY/CODING/lte_interleaver_inline.h"
-#include "PHY/CODING/nrLDPC_encoder/defs.h"
+#include "PHY/CODING/nrLDPC_extern.h"
 #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h"
 #include "common/utils/LOG/vcd_signal_dumper.h"
+#include "LAYER2/NR_MAC_gNB/mac_proto.h"
 
 
+void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr,unsigned char N_RB_UL)
 
-void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr)
 {
   int i, r;
   NR_UE_ULSCH_t *ulsch = *ulschptr;
@@ -52,18 +53,35 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr)
     printf("Freeing ulsch %p\n",ulsch);
 #endif
 
+  uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS;  //number of segments to be allocated
+
+  if (N_RB_UL != 273) {
+    a_segments = a_segments*N_RB_UL;
+    a_segments = a_segments/273;
+  }  
+
+  uint16_t ulsch_bytes = a_segments*1056;  // allocated bytes per segment
+
     for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) {
       if (ulsch->harq_processes[i]) {
 
         if (ulsch->harq_processes[i]->a) {
-          free16(ulsch->harq_processes[i]->a,MAX_NR_ULSCH_PAYLOAD_BYTES);
+          free16(ulsch->harq_processes[i]->a,ulsch_bytes);
           ulsch->harq_processes[i]->a = NULL;
         }
         if (ulsch->harq_processes[i]->b) {
-          free16(ulsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES);
+          free16(ulsch->harq_processes[i]->b,ulsch_bytes);
           ulsch->harq_processes[i]->b = NULL;
         }
-        for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS; r++) {
+        if (ulsch->harq_processes[i]->e) {
+          free16(ulsch->harq_processes[i]->e,14*N_RB_UL*12*8);
+          ulsch->harq_processes[i]->e = NULL;
+        }
+        if (ulsch->harq_processes[i]->f) {
+          free16(ulsch->harq_processes[i]->f,14*N_RB_UL*12*8);
+          ulsch->harq_processes[i]->f = NULL;
+        }
+        for (r=0; r<a_segments; r++) {
           if (ulsch->harq_processes[i]->c[r]) {
             free16(ulsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768);
             ulsch->harq_processes[i]->c[r] = NULL;
@@ -87,24 +105,20 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr)
 }
 
 
-NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL,
+NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL,
                                int number_of_harq_pids,
                                uint8_t abstraction_flag)
 {
   NR_UE_ULSCH_t *ulsch;
   unsigned char exit_flag = 0,i,r;
-  unsigned char bw_scaling =1;
+  uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS;  //number of segments to be allocated
 
-  switch (N_RB_UL) {
+  if (N_RB_UL != 273) {
+    a_segments = a_segments*N_RB_UL;
+    a_segments = a_segments/273;
+  }  
 
-  case 106:
-    bw_scaling =2;
-    break;
-
-  default:
-    bw_scaling =1;
-    break;
-  }
+  uint16_t ulsch_bytes = a_segments*1056;  // allocated bytes per segment
 
   ulsch = (NR_UE_ULSCH_t *)malloc16(sizeof(NR_UE_ULSCH_t));
 
@@ -124,25 +138,25 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL,
       //      printf("ulsch->harq_processes[%d] %p\n",i,ulsch->harq_processes[i]);
       if (ulsch->harq_processes[i]) {
         memset(ulsch->harq_processes[i], 0, sizeof(NR_UL_UE_HARQ_t));
-        ulsch->harq_processes[i]->b = (uint8_t*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling);
-        ulsch->harq_processes[i]->a = (unsigned char*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling);
+        ulsch->harq_processes[i]->b = (uint8_t*)malloc16(ulsch_bytes);
+        ulsch->harq_processes[i]->a = (unsigned char*)malloc16(ulsch_bytes);
 
         if (ulsch->harq_processes[i]->a) {
-          bzero(ulsch->harq_processes[i]->a,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling);
+          bzero(ulsch->harq_processes[i]->a,ulsch_bytes);
         } else {
           printf("Can't allocate PDU\n");
           exit_flag=1;
         }
 
         if (ulsch->harq_processes[i]->b)
-          bzero(ulsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling);
+          bzero(ulsch->harq_processes[i]->b,ulsch_bytes);
         else {
           LOG_E(PHY,"Can't get b\n");
           exit_flag=1;
         }
 
         if (abstraction_flag==0) {
-          for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling; r++) {
+          for (r=0; r<a_segments; r++) {
             // account for filler in first segment and CRCs for multiple segment case
             ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448);
             ulsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output
@@ -160,6 +174,20 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL,
               exit_flag=2;
             }
           }
+          ulsch->harq_processes[i]->e = (uint8_t*)malloc16(14*N_RB_UL*12*8);
+          if (ulsch->harq_processes[i]->e) {
+            bzero(ulsch->harq_processes[i]->e,14*N_RB_UL*12*8);
+          } else {
+            printf("Can't get e\n");
+            exit_flag=1;
+          }
+          ulsch->harq_processes[i]->f = (uint8_t*)malloc16(14*N_RB_UL*12*8);
+          if (ulsch->harq_processes[i]->f) {
+            bzero(ulsch->harq_processes[i]->f,14*N_RB_UL*12*8);
+          } else {
+            printf("Can't get f\n");
+            exit_flag=1;
+          }
         }
 
         ulsch->harq_processes[i]->subframe_scheduling_flag = 0;
@@ -180,7 +208,7 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL,
   }
 
   LOG_E(PHY,"new_ue_ulsch exit flag, size of  %d ,   %zu\n",exit_flag, sizeof(LTE_UE_ULSCH_t));
-  free_nr_ue_ulsch(&ulsch);
+  free_nr_ue_ulsch(&ulsch,N_RB_UL);
   return(NULL);
 
 
@@ -240,13 +268,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
 ///////////
 /////////////////////////////////////////////////////////////////////////////////////////  
 
-  /*
-  uint8_t *channel_input[MAX_NUM_DLSCH_SEGMENTS]; //unsigned char
-  for(j=0;j<MAX_NUM_DLSCH_SEGMENTS;j++) {
-    channel_input[j] = (unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
-  }
-  */
-  
+
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN);
 
   LOG_D(PHY,"ulsch coding nb_rb %d nb_symb_sch %d nb_re_dmrs %d, length_dmrs %d, harq_process->Nl = %d\n", nb_rb,nb_symb_sch, nb_re_dmrs,length_dmrs, harq_process->Nl);
@@ -270,17 +292,35 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
       printf("%02x.",a[i]);
     printf("\n");
     */
-    // Add 24-bit crc (polynomial A) to payload
-    crc = crc24a(harq_process->a,A)>>8;
-    harq_process->a[A>>3] = ((uint8_t*)&crc)[2];
-    harq_process->a[1+(A>>3)] = ((uint8_t*)&crc)[1];
-    harq_process->a[2+(A>>3)] = ((uint8_t*)&crc)[0];
-    //printf("CRC %x (A %d)\n",crc,A);
-    //printf("a0 %d a1 %d a2 %d\n", a[A>>3], a[1+(A>>3)], a[2+(A>>3)]);
+    if (A > 3824) {
+      // Add 24-bit crc (polynomial A) to payload
+      crc = crc24a(harq_process->a,A)>>8;
+      harq_process->a[A>>3] = ((uint8_t*)&crc)[2];
+      harq_process->a[1+(A>>3)] = ((uint8_t*)&crc)[1];
+      harq_process->a[2+(A>>3)] = ((uint8_t*)&crc)[0];
+      //printf("CRC %x (A %d)\n",crc,A);
+      //printf("a0 %d a1 %d a2 %d\n", a[A>>3], a[1+(A>>3)], a[2+(A>>3)]);
+
+      harq_process->B = A+24;
+
+      AssertFatal((A/8)+4 <= MAX_NR_ULSCH_PAYLOAD_BYTES,"A %d is too big (A/8+4 = %d > %d)\n",A,(A/8)+4,MAX_NR_ULSCH_PAYLOAD_BYTES);
 
-    harq_process->B = A+24;
+      memcpy(harq_process->b,harq_process->a,(A/8)+4);
+    }
+    else {
+      // Add 16-bit crc (polynomial A) to payload
+      crc = crc16(harq_process->a,A)>>16;
+      harq_process->a[A>>3] = ((uint8_t*)&crc)[1];
+      harq_process->a[1+(A>>3)] = ((uint8_t*)&crc)[0];
+      //printf("CRC %x (A %d)\n",crc,A);
+      //printf("a0 %d a1 %d \n", a[A>>3], a[1+(A>>3)]);
+
+      harq_process->B = A+16;
 
-    memcpy(harq_process->b,harq_process->a,(A/8)+4);
+      AssertFatal((A/8)+3 <= MAX_NR_ULSCH_PAYLOAD_BYTES,"A %d is too big (A/8+3 = %d > %d)\n",A,(A/8)+3,MAX_NR_ULSCH_PAYLOAD_BYTES);
+
+      memcpy(harq_process->b,harq_process->a,(A/8)+3);  // using 3 bytes to mimic the case of 24 bit crc
+    }
 
 ///////////
 ///////////////////////////////////////////////////////////////////////////
@@ -353,8 +393,11 @@ opp_enabled=0;
       printf("%d \n",  harq_process->d[0][cnt]);
       }
       printf("\n");*/
+    encoder_implemparams_t impp;
+    impp.n_segments=harq_process->C;
+    impp.macro_num=0;
 
-    ldpc_encoder_optim_8seg(harq_process->c,harq_process->d,*pz,Kb,Kr,BG,harq_process->C,NULL,NULL,NULL,NULL);
+    nrLDPC_encoder(harq_process->c,harq_process->d,*pz,Kb,Kr,BG,&impp);
 
     //stop_meas(te_stats);
     //printf("end ldpc encoder -- output\n");
@@ -405,6 +448,8 @@ opp_enabled=0;
                           harq_process->d[r],
                           harq_process->e+r_offset,
                           harq_process->C,
+			  F,
+                          Kr-F-2*(*pz),
                           harq_process->rvidx,
                           E);
 
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
index b912834f9d7..f1d4a304f97 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
@@ -31,6 +31,7 @@
 */
 #include <stdint.h>
 #include "PHY/NR_REFSIG/dmrs_nr.h"
+#include "PHY/NR_REFSIG/ptrs_nr.h"
 #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h"
 #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h"
 #include "PHY/MODULATION/nr_modulation.h"
@@ -105,27 +106,28 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
   int32_t **txdataF;
   uint16_t start_sc, start_rb;
   int8_t Wf[2], Wt[2], l_prime[2], delta;
-  uint16_t n_dmrs, code_rate, number_dmrs_symbols;
+  uint16_t n_dmrs, code_rate, number_dmrs_symbols, k;
   uint8_t dmrs_type;
-  uint8_t mapping_type;
   int ap, start_symbol, Nid_cell, i;
   int sample_offsetF, N_RE_prime, N_PRB_oh;
   uint16_t n_rnti;
   uint8_t data_existing =0;
+  uint8_t L_ptrs, K_ptrs; // PTRS parameters
+  uint16_t beta_ptrs; // PTRS parameter related to power control
 
   NR_UE_ULSCH_t *ulsch_ue;
   NR_UL_UE_HARQ_t *harq_process_ul_ue;
   NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms;
   NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][gNB_id];
   uint8_t ulsch_input_buffer[MAX_ULSCH_PAYLOAD_BYTES];
+  ptrs_UplinkConfig_t *ptrs_Uplink_Config = &UE->pusch_config.dmrs_UplinkConfig.ptrs_UplinkConfig;
 
   num_of_codewords = 1; // tmp assumption
   n_rnti = 0x1234;
   Nid_cell = 0;
   N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig
   number_dmrs_symbols = 0;
-
-  mapping_type = UE->pusch_config.pusch_TimeDomainResourceAllocation[0]->mappingType;
+  uint8_t mapping_type = UE->pusch_config.pusch_TimeDomainResourceAllocation[0]->mappingType;
 
   for (cwd_index = 0;cwd_index < num_of_codewords; cwd_index++) {
 
@@ -135,23 +137,23 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
     start_symbol = harq_process_ul_ue->start_symbol;
 
     for (i = start_symbol; i < start_symbol + harq_process_ul_ue->number_of_symbols; i++)
-      number_dmrs_symbols += is_dmrs_symbol(i,
+      number_dmrs_symbols += is_dmrs_symbol((mapping_type)?i-start_symbol:i,
                                             0,
                                             0,
                                             0,
                                             0,
                                             0,
                                             harq_process_ul_ue->number_of_symbols,
-                                            &UE->dmrs_UplinkConfig,
-                                            mapping_type,
+                                            UE->pusch_config.dmrs_UplinkConfig.pusch_dmrs_type,
                                             frame_parms->ofdm_symbol_size);
 
-    ulsch_ue->length_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength;
+    ulsch_ue->length_dmrs = number_dmrs_symbols; // pusch.MaxLenght is redundant here as number_dmrs_symbols
+                                                 // contains all dmrs symbols even for double symbol dmrs
     ulsch_ue->rnti        = n_rnti;
     ulsch_ue->Nid_cell    = Nid_cell;
-    ulsch_ue->nb_re_dmrs  = ((UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4)*number_dmrs_symbols;
+    ulsch_ue->nb_re_dmrs  = ((UE->pusch_config.dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4);
 
-    N_RE_prime = NR_NB_SC_PER_RB*harq_process_ul_ue->number_of_symbols - ulsch_ue->nb_re_dmrs - N_PRB_oh;
+    N_RE_prime = NR_NB_SC_PER_RB*harq_process_ul_ue->number_of_symbols - ulsch_ue->nb_re_dmrs*number_dmrs_symbols - N_PRB_oh;
 
     harq_process_ul_ue->num_of_mod_symbols = N_RE_prime*harq_process_ul_ue->nb_rb*num_of_codewords;
 
@@ -172,6 +174,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
     // to be removed later when MAC is ready
 
     if (harq_process_ul_ue != NULL){
+      data_existing = 0;
 
     	if (IS_SOFTMODEM_NOS1){
     		data_existing = nr_ue_get_sdu(UE->Mod_id, UE->CC_id, frame,
@@ -189,31 +192,22 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
     				printf("\n");
 				#endif
     		}
-    		//Random traffic to be transmitted if there is no IP traffic available for this Tx opportunity
-    		else{
-    			//Use zeros for the header bytes in noS1 mode, in order to make sure that the LCID is not valid
-    			//and block this traffic from being forwarded to the upper layers at the gNB
-    			uint16_t payload_offset = 5;
-    			LOG_D(PHY, "Random data to be tranmsitted: \n");
-    			//Give the header bytes some dummy value in order to block the random packet at the MAC layer of the receiver
-    			for (i = 0; i<payload_offset; i++)
-    				harq_process_ul_ue->a[i] = 0;
-
-    			for (i = payload_offset; i < harq_process_ul_ue->TBS / 8; i++) {
-    				harq_process_ul_ue->a[i] = (unsigned char) rand();
-    				//printf(" input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
-    				}
-    		}
-    	}
-        //else if(uplink_counter == 0){ //if(!IS_SOFTMODEM_NOS1){
-    	else{
-        	LOG_D(PHY, "Random data to be tranmsitted: \n");
-        	for (i = 0; i < harq_process_ul_ue->TBS / 8; i++) {
-        		harq_process_ul_ue->a[i] = (unsigned char) rand();
-        		//printf(" input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
-        	}
-        	//uplink_counter++;
+      }
+      //Random traffic to be transmitted if there is no IP traffic available for this Tx opportunity
+      if (!IS_SOFTMODEM_NOS1 || !data_existing) {
+        //Use zeros for the header bytes in noS1 mode, in order to make sure that the LCID is not valid
+        //and block this traffic from being forwarded to the upper layers at the gNB
+        uint16_t payload_offset = 5;
+        LOG_D(PHY, "Random data to be tranmsitted: \n");
+        //Give the header bytes some dummy value in order to block the random packet at the MAC layer of the receiver
+        for (i = 0; i<payload_offset; i++)
+          harq_process_ul_ue->a[i] = 0;
+
+        for (i = payload_offset; i < harq_process_ul_ue->TBS / 8; i++) {
+          harq_process_ul_ue->a[i] = (unsigned char) rand();
+          //printf(" input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
         }
+      }
     } else {
       LOG_E(PHY, "[phy_procedures_nrUE_TX] harq_process_ul_ue is NULL !!\n");
       return;
@@ -275,12 +269,41 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
   /////////////////////////DMRS Modulation/////////////////////////
   ///////////
   pusch_dmrs = UE->nr_gold_pusch_dmrs[slot];
-  n_dmrs = (harq_process_ul_ue->nb_rb*ulsch_ue->nb_re_dmrs);
+  n_dmrs = (harq_process_ul_ue->nb_rb*ulsch_ue->nb_re_dmrs*ulsch_ue->length_dmrs);
   int16_t mod_dmrs[n_dmrs<<1];
-  dmrs_type = UE->dmrs_UplinkConfig.pusch_dmrs_type;
+  dmrs_type = UE->pusch_config.dmrs_UplinkConfig.pusch_dmrs_type;
   ///////////
   ////////////////////////////////////////////////////////////////////////
 
+
+  /////////////////////////PTRS parameters' initialization/////////////////////////
+  ///////////
+
+  int16_t mod_ptrs[(harq_process_ul_ue->nb_rb/2)*(NR_SYMBOLS_PER_SLOT-1)*2]; // assume maximum number of PTRS per pusch allocation
+  K_ptrs = 0; // just to avoid a warning
+
+  if (UE->ptrs_configured == 1) {
+
+    K_ptrs = get_K_ptrs(ptrs_Uplink_Config, harq_process_ul_ue->nb_rb);
+
+    L_ptrs = get_L_ptrs(ptrs_Uplink_Config, harq_process_ul_ue->mcs);
+
+    beta_ptrs = 1; // temp value until power control is implemented
+
+    ulsch_ue->ptrs_symbols = 0;
+
+    set_ptrs_symb_idx(&ulsch_ue->ptrs_symbols,
+                      harq_process_ul_ue->number_of_symbols,
+                      start_symbol,
+                      dmrs_type,
+                      L_ptrs,
+                      ulsch_ue->length_dmrs,
+                      frame_parms->ofdm_symbol_size);
+  }
+
+  ///////////
+  ////////////////////////////////////////////////////////////////////////////////
+
   /////////////////////////ULSCH layer mapping/////////////////////////
   ///////////
 
@@ -306,15 +329,14 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
 
   for (l = start_symbol; l < start_symbol + harq_process_ul_ue->number_of_symbols; l++) {
 
-    is_dmrs = is_dmrs_symbol(l,
+    is_dmrs = is_dmrs_symbol((mapping_type)?l-start_symbol:l,
                              0,
                              0,
                              0,
                              0,
                              0,
                              harq_process_ul_ue->number_of_symbols,
-                             &UE->dmrs_UplinkConfig,
-                             mapping_type,
+                             dmrs_type,
                              frame_parms->ofdm_symbol_size);
 
     if (is_dmrs == 1)
@@ -357,35 +379,54 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
     
 
     uint8_t k_prime=0;
-    uint8_t is_dmrs;
-    uint16_t m=0, n=0, dmrs_idx=0, k=0;
+    uint8_t is_dmrs, is_ptrs;
+    uint8_t l_ref;
+    uint16_t m=0, n=0, dmrs_idx=0, ptrs_idx = 0;
 
     for (l=start_symbol; l<start_symbol+harq_process_ul_ue->number_of_symbols; l++) {
 
       k = start_sc;
       n = 0;
       dmrs_idx = 0;
+      l_ref = (mapping_type) ? l-start_symbol : l;
 
       for (i=0; i<harq_process_ul_ue->nb_rb*NR_NB_SC_PER_RB; i++) {
 
         sample_offsetF = l*frame_parms->ofdm_symbol_size + k;
 
         is_dmrs = 0;
+        is_ptrs = 0;
 
-        is_dmrs = is_dmrs_symbol(l,
+        is_dmrs = is_dmrs_symbol(l_ref,
                                  k,
                                  start_sc,
                                  k_prime,
                                  n,
                                  delta,
                                  harq_process_ul_ue->number_of_symbols,
-                                 &UE->dmrs_UplinkConfig,
-                                 mapping_type,
+                                 dmrs_type,
                                  frame_parms->ofdm_symbol_size);
 
+        if (UE->ptrs_configured == 1){
+          is_ptrs = is_ptrs_symbol(l,
+                                   k,
+                                   ulsch_ue->rnti,
+                                   harq_process_ul_ue->nb_rb,
+                                   harq_process_ul_ue->number_of_symbols,
+                                   ap,
+                                   K_ptrs,
+                                   ulsch_ue->ptrs_symbols,
+                                   start_sc,
+                                   frame_parms->ofdm_symbol_size,
+                                   UE->pusch_config.dmrs_UplinkConfig.pusch_dmrs_type,
+                                   ptrs_Uplink_Config->resourceElementOffset);
+        }
+
         if (is_dmrs == 1) {
 
-          nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated
+          if (k == start_sc){
+            nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated
+          }
 
           ((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[dmrs_idx<<1]) >> 15;
           ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (Wt[l_prime[0]]*Wf[k_prime]*AMP*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15;
@@ -401,9 +442,19 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
           k_prime++;
           k_prime&=1;
           n+=(k_prime)?0:1;
-        }
 
-        else {
+        }  else if (is_ptrs == 1) {
+
+          if (k == start_sc){
+            nr_modulation(pusch_dmrs[l][0], harq_process_ul_ue->nb_rb/2, DMRS_MOD_ORDER, mod_ptrs);
+          }
+
+          ((int16_t*)txdataF[ap])[(sample_offsetF)<<1] = (beta_ptrs*AMP*mod_ptrs[ptrs_idx<<1]) >> 15;
+          ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = (beta_ptrs*AMP*mod_ptrs[(ptrs_idx<<1) + 1]) >> 15;
+
+          ptrs_idx++;
+
+          } else {
 
           ((int16_t*)txdataF[ap])[(sample_offsetF)<<1]       = ((int16_t *) ulsch_ue->y)[m<<1];
           ((int16_t*)txdataF[ap])[((sample_offsetF)<<1) + 1] = ((int16_t *) ulsch_ue->y)[(m<<1) + 1];
@@ -454,7 +505,7 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE,
   timing_advance = 0;
 #endif
 
-  tx_offset = slot*frame_parms->samples_per_slot - timing_advance;
+  tx_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0) - timing_advance;
 
   if (tx_offset < 0)
     tx_offset += frame_parms->samples_per_frame;
@@ -484,6 +535,7 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE,
            frame_parms);
       }
     }
+
   ///////////
   ////////////////////////////////////////////////////
   return 0;
diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c
index b13cd008b58..e8eceb77a6d 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c
@@ -880,7 +880,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
 
           /* perform correlation of rx data and pss sequence ie it is a dot product */
           result  = dot_product64((short*)primary_synchro_time_nr[pss_index], 
-				  (short*) &(rxdata[ar][n])+(is*frame_parms->samples_per_frame), 
+				  (short*) &(rxdata[ar][n+is*frame_parms->samples_per_frame]), 
 				  frame_parms->ofdm_symbol_size, 
 				  shift);
 	  pss_corr_ue[pss_index][n] += abs64(result);
@@ -914,13 +914,13 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
 	  int64_t result1,result2;
 	  // Computing cross-correlation at peak on half the symbol size for first half of data
 	  result1  = dot_product64((short*)primary_synchro_time_nr[pss_source], 
-				  (short*) &(rxdata[0][peak_position])+(is*frame_parms->samples_per_frame), 
+				  (short*) &(rxdata[0][peak_position+is*frame_parms->samples_per_frame]), 
 				  frame_parms->ofdm_symbol_size>>1, 
 				  shift);
 	  // Computing cross-correlation at peak on half the symbol size for data shifted by half symbol size 
 	  // as it is real and complex it is necessary to shift by a value equal to symbol size to obtain such shift
 	  result2  = dot_product64((short*)primary_synchro_time_nr[pss_source]+(frame_parms->ofdm_symbol_size), 
-				  (short*) &(rxdata[0][peak_position])+(frame_parms->ofdm_symbol_size+(is*frame_parms->samples_per_frame)), 
+				  (short*) &(rxdata[0][peak_position+is*frame_parms->samples_per_frame])+frame_parms->ofdm_symbol_size, 
 				  frame_parms->ofdm_symbol_size>>1, 
 				  shift);
 
diff --git a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c
index 3d368229568..44d500b0b7e 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/sss_nr.c
@@ -341,7 +341,7 @@ int do_pss_sss_extract_nr(PHY_VARS_NR_UE *ue,
     pss_rxF_ext = &pss_ext[aarx][0];
     sss_rxF_ext = &sss_ext[aarx][0];
 
-    unsigned int k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier + 56; 
+    unsigned int k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier + 56;
     if (k>= frame_parms->ofdm_symbol_size) k-=frame_parms->ofdm_symbol_size;
 
     for (int i=0; i < LENGTH_PSS_NR; i++) {
diff --git a/openair1/PHY/TOOLS/Makefile b/openair1/PHY/TOOLS/Makefile
index 870bcfe318d..c71717dc878 100644
--- a/openair1/PHY/TOOLS/Makefile
+++ b/openair1/PHY/TOOLS/Makefile
@@ -2,13 +2,15 @@ lte_dfts_sse4: lte_dfts.c
 	gcc-7 -O3 -std=gnu99 -msse4.1 -o lte_dfts_sse4 lte_dfts.c time_meas.c  ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR_HOME -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR -I$$OPENAIR2_DIR/COMMON -I$$OPENAIR_HOME/common/utils -I$$OPENAIR_HOME/common/utils/T -DMR_MAIN -DNB_ANTENNAS_RX=1 -lm -lpthread # -DD256STATS #-DD64STATS
 
 lte_dfts_avx2: lte_dfts.c
-	gcc -O2 -std=gnu99 -mavx2 -g -ggdb -o lte_dfts_avx2 lte_dfts.c time_meas.c ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR_HOME -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR -I$$OPENAIR2_DIR/COMMON -I$$OPENAIR_HOME/common/utils -DMR_MAIN -DNB_ANTENNAS_RX=1 -lm -lpthread # -DD256STATS #-DD64STATS
+	gcc -O2 -std=gnu99 -mavx2 -g -ggdb -o lte_dfts_avx2 lte_dfts.c time_meas.c ../../SIMULATION/TOOLS/taus.c $$OPENAIR_HOME/common/utils/backtrace.c -I$$OPENAIR_HOME -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR -I$$OPENAIR2_DIR/COMMON -I$$OPENAIR_HOME/common/utils -I$$OPENAIR_HOME/common/utils/T -DMR_MAIN -DNB_ANTENNAS_RX=1 -lm -lpthread # -DD256STATS #-DD64STATS
 
 lte_dfts_avx2.s: lte_dfts.c
-	gcc -O2 -std=gnu99 -mavx2 -S lte_dfts.c time_meas.c ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR_HOME -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR -I$$OPENAIR2_DIR/COMMON -I$$OPENAIR_HOME/common/utils -DMR_MAIN -DNB_ANTENNAS_RX=1 -lm -lpthread # -DD256STATS #-DD64STATS
+	gcc -O2 -std=gnu99 -mavx2 -S lte_dfts.c time_meas.c ../../SIMULATION/TOOLS/taus.c $$OPENAIR_HOME/common/utils/backtrace.c -I$$OPENAIR_HOME -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR -I$$OPENAIR2_DIR/COMMON -I$$OPENAIR_HOME/common/utils -I$$OPENAIR_HOME/common/utils/T -DMR_MAIN -DNB_ANTENNAS_RX=1 -lm -lpthread # -DD256STATS #-DD64STATS
+
 
 lte_dfts_sse4.s: lte_dfts.c
-	gcc -O2 -std=gnu99 -msse4.1 -S lte_dfts.c time_meas.c ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR_HOME -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR -I$$OPENAIR2_DIR/COMMON -I$$OPENAIR_HOME/common/utils -DMR_MAIN -DNB_ANTENNAS_RX=1 -lm # -DD256STATS #-DD64STATS
+	gcc -O2 -std=gnu99 -msse4.1 -S lte_dfts.c time_meas.c ../../SIMULATION/TOOLS/taus.c $$OPENAIR_HOME/common/utils/backtrace.c -I$$OPENAIR_HOME -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR2_DIR -I$$OPENAIR2_DIR/COMMON -I$$OPENAIR_HOME/common/utils -I$$OPENAIR_HOME/common/utils/T -DMR_MAIN -DNB_ANTENNAS_RX=1 -lm -lpthread # -DD256STATS #-DD64STATS
+
 
 dft_cycles_avx2: lte_dfts_avx2
 	./lte_dfts_avx2 | egrep cycles
diff --git a/openair1/PHY/TOOLS/lte_dfts.c b/openair1/PHY/TOOLS/lte_dfts.c
index 59369a3bc0f..2de8653ab39 100644
--- a/openair1/PHY/TOOLS/lte_dfts.c
+++ b/openair1/PHY/TOOLS/lte_dfts.c
@@ -2573,7 +2573,7 @@ const static int16_t tw64c[96] __attribute__((aligned(32))) = {
 #define simd256_q15_t __m256i
 #define shiftright_int16_simd256(a,shift) _mm256_srai_epi16(a,shift)
 #define set1_int16_simd256(a) _mm256_set1_epi16(a);
-#define mulhi_int16_simd256(a,b) _mm256_slli_epi16(_mm256_mulhi_epi16(a,b),1);
+#define mulhi_int16_simd256(a,b) _mm256_mulhrs_epi16(a,b); //_mm256_slli_epi16(_mm256_mulhi_epi16(a,b),1);
 #endif
 
 #elif defined(__arm__)
@@ -4836,22 +4836,22 @@ void idft4096(int16_t *x,int16_t *y,int scale)
   if (scale>0) {
 
     for (i=0; i<64; i++) {
-      y128[0]  = shiftright_int16(y128[0],1);
-      y128[1]  = shiftright_int16(y128[1],1);
-      y128[2]  = shiftright_int16(y128[2],1);
-      y128[3]  = shiftright_int16(y128[3],1);
-      y128[4]  = shiftright_int16(y128[4],1);
-      y128[5]  = shiftright_int16(y128[5],1);
-      y128[6]  = shiftright_int16(y128[6],1);
-      y128[7]  = shiftright_int16(y128[7],1);
-      y128[8]  = shiftright_int16(y128[8],1);
-      y128[9]  = shiftright_int16(y128[9],1);
-      y128[10] = shiftright_int16(y128[10],1);
-      y128[11] = shiftright_int16(y128[11],1);
-      y128[12] = shiftright_int16(y128[12],1);
-      y128[13] = shiftright_int16(y128[13],1);
-      y128[14] = shiftright_int16(y128[14],1);
-      y128[15] = shiftright_int16(y128[15],1);
+      y128[0]  = shiftright_int16(y128[0],scale);
+      y128[1]  = shiftright_int16(y128[1],scale);
+      y128[2]  = shiftright_int16(y128[2],scale);
+      y128[3]  = shiftright_int16(y128[3],scale);
+      y128[4]  = shiftright_int16(y128[4],scale);
+      y128[5]  = shiftright_int16(y128[5],scale);
+      y128[6]  = shiftright_int16(y128[6],scale);
+      y128[7]  = shiftright_int16(y128[7],scale);
+      y128[8]  = shiftright_int16(y128[8],scale);
+      y128[9]  = shiftright_int16(y128[9],scale);
+      y128[10] = shiftright_int16(y128[10],scale);
+      y128[11] = shiftright_int16(y128[11],scale);
+      y128[12] = shiftright_int16(y128[12],scale);
+      y128[13] = shiftright_int16(y128[13],scale);
+      y128[14] = shiftright_int16(y128[14],scale);
+      y128[15] = shiftright_int16(y128[15],scale);
 
       y128+=16;
     }
@@ -5692,6 +5692,18 @@ void dft6144(int16_t *input, int16_t *output,int scale)
 
 }
 
+int16_t twa9216[6144] __attribute__((aligned(32)));
+int16_t twb9216[6144] __attribute__((aligned(32)));
+// 3072 x 3
+void dft9216(int16_t *input, int16_t *output,int scale) {
+
+  AssertFatal(1==0,"Need to do this ..\n");
+}
+
+void idft9216(int16_t *input, int16_t *output,int scale) {
+
+  AssertFatal(1==0,"Need to do this ..\n");
+}
 
 int16_t twa12288[8192] __attribute__((aligned(32)));
 int16_t twb12288[8192] __attribute__((aligned(32)));
@@ -6042,6 +6054,59 @@ void idft24576(int16_t *input, int16_t *output,int scale)
   }
 }
 
+int16_t twa36864[24576] __attribute__((aligned(32)));
+int16_t twb36884[24576] __attribute__((aligned(32)));
+// 12288 x 3
+void dft36864(int16_t *input, int16_t *output,int scale) {
+
+  AssertFatal(1==0,"Need to do this ..\n");
+}
+void idft36864(int16_t *input, int16_t *output,int scale) {
+
+  AssertFatal(1==0,"Need to do this ..\n");
+}
+
+int16_t twa49152[32768] __attribute__((aligned(32)));
+int16_t twb49152[32768] __attribute__((aligned(32)));
+// 16384 x 3
+void dft49152(int16_t *input, int16_t *output,int scale) {
+
+  AssertFatal(1==0,"Need to do this ..\n");
+}
+
+void idft49152(int16_t *input, int16_t *output,int scale) {
+
+  AssertFatal(1==0,"Need to do this ..\n");
+}
+
+int16_t twa73728[49152] __attribute__((aligned(32)));
+int16_t twb73728[49152] __attribute__((aligned(32)));
+// 24576 x 3
+void dft73728(int16_t *input, int16_t *output,int scale) {
+
+  AssertFatal(1==0,"Need to do this ..\n");
+}
+
+void idft73728(int16_t *input, int16_t *output,int scale) {
+
+  AssertFatal(1==0,"Need to do this ..\n");
+}
+
+
+int16_t twa98304[49152] __attribute__((aligned(32)));
+int16_t twb98304[49152] __attribute__((aligned(32)));
+// 32768 x 3
+void dft98304(int16_t *input, int16_t *output,int scale) {
+
+  AssertFatal(1==0,"Need to do this ..\n");
+}
+
+void idft98304(int16_t *input, int16_t *output,int scale) {
+
+  AssertFatal(1==0,"Need to do this ..\n");
+}
+
+ 
 ///  THIS SECTION IS FOR ALL PUSCH DFTS (i.e. radix 2^a * 3^b * 4^c * 5^d)
 ///  They use twiddles for 4-way parallel DFTS (i.e. 4 DFTS with interleaved input/output)
 
@@ -8526,6 +8591,8 @@ void dft1200(int16_t *x,int16_t *y,unsigned char scale_flag)
 
 }
 
+//#define round trunc
+
 void init_rad4(int N,int16_t *tw) {
 
   int16_t *twa = tw;
@@ -8695,6 +8762,8 @@ void init_dfts(void)
   init_rad4_rep(1200,twa1200,twb1200,twc1200);
 }
 
+//#undef round
+
 #ifdef MR_MAIN
 #include <string.h>
 #include <stdio.h>
@@ -8862,9 +8931,9 @@ int main(int argc, char**argv)
 
   time_stats_t ts;
 #ifdef __AVX2__
-  simd256_q15_t x[4096],y[4096],tw0,tw1,tw2,tw3;
+  simd256_q15_t x[4096],x2[4096],y[4096],tw0,tw1,tw2,tw3;
 #else
-  simd_q15_t x[8192],y[8192],tw0,tw1,tw2,tw3;
+  simd_q15_t x[8192],x2[8192],y[8192],tw0,tw1,tw2,tw3;
 #endif
   int i;
   simd_q15_t *x128=(simd_q15_t*)x,*y128=(simd_q15_t*)y;
@@ -9351,8 +9420,8 @@ int main(int argc, char**argv)
   write_output("x3072.m","x3072",x,3072,1,1);
 
 
-  memset((void*)x,0,2048*sizeof(int32_t));
-  for (i=2;i<2402;i++) {
+  memset((void*)x,0,4096*sizeof(int32_t));
+  for (i=0;i<2400;i++) {
     if ((taus() & 1)==0)
       ((int16_t*)x)[i] = 364;
     else
@@ -9376,6 +9445,9 @@ int main(int argc, char**argv)
   LOG_M("y4096.m","y4096",y,4096,1,1);
   LOG_M("x4096.m","x4096",x,4096,1,1);
 
+  dft4096((int16_t *)y,(int16_t *)x2,1);
+  LOG_M("x4096_2.m","x4096_2",x2,4096,1,1);
+
 // NR 160Mhz, 434 PRB, 3/4 sampling
   memset((void*)x, 0, 6144*sizeof(int32_t));
   for (i=2;i<5010;i++) {
diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c
index 66ac4158722..40803c30f4f 100644
--- a/openair1/PHY/TOOLS/nr_phy_scope.c
+++ b/openair1/PHY/TOOLS/nr_phy_scope.c
@@ -152,36 +152,36 @@ FD_phy_scope_gnb *create_phy_scope_gnb( void )
 
 void phy_scope_gNB(FD_phy_scope_gnb *form,
                    PHY_VARS_gNB *phy_vars_gnb,
+		   RU_t *phy_vars_ru,
                    int UE_id)
 {
-  int i,i2,arx,atx,ind,k;
+  int i, arx; //int i,i2,arx,atx,ind,k;
   NR_DL_FRAME_PARMS *frame_parms = &phy_vars_gnb->frame_parms;
   int nsymb_ce = 12*frame_parms->N_RB_UL*frame_parms->symbols_per_tti;
   uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx;
   uint8_t nb_antennas_tx = 1; // frame_parms->nb_antennas_tx; // in LTE Rel. 8 and 9 only a single transmit antenna is assumed at the UE
-  int16_t **rxsig_t;
-  int16_t **chest_t=NULL;
-  int16_t **chest_f=NULL;
-  int16_t *pusch_llr=NULL;
-  int32_t *pusch_comp=NULL;
-  int32_t *pucch1_comp=NULL;
-  int32_t *pucch1_thres=NULL;
-  int32_t *pucch1ab_comp=NULL;
-  float Re,Im,ymax;
+  int16_t **rxsig_t, **rxsig_f;
+  // int16_t **chest_t=NULL;
+  // int16_t **chest_f=NULL;
+  // int16_t *pusch_llr=NULL;
+  // int32_t *pusch_comp=NULL;
+  // int32_t *pucch1_comp=NULL;
+  // int32_t *pucch1_thres=NULL;
+  // int32_t *pucch1ab_comp=NULL;
+  // float Re,Im,ymax;
   float *llr, *bit;
-  float I[nsymb_ce*2], Q[nsymb_ce*2];
-  float I_pucch[10240],Q_pucch[10240],A_pucch[10240],B_pucch[10240],C_pucch[10240];
-  float rxsig_t_dB[nb_antennas_rx][FRAME_LENGTH_COMPLEX_SAMPLES];
-  float chest_t_abs[nb_antennas_rx][frame_parms->ofdm_symbol_size];
-  float *chest_f_abs;
-  float time[FRAME_LENGTH_COMPLEX_SAMPLES];
-  float time2[2048];
-  float freq[nsymb_ce*nb_antennas_rx*nb_antennas_tx];
-  uint32_t total_dlsch_bitrate = phy_vars_gnb->total_dlsch_bitrate;
+  // float I[nsymb_ce*2], Q[nsymb_ce*2];
+  // float I_pucch[10240],Q_pucch[10240],A_pucch[10240],B_pucch[10240],C_pucch[10240];
+  float *rxsig_t_dB[nb_antennas_rx];
+  float *rxsig_f_dB[nb_antennas_rx];
+  float time[frame_parms->samples_per_frame];
+  // float freq[nsymb_ce*nb_antennas_rx*nb_antennas_tx];
+  // uint32_t total_dlsch_bitrate = phy_vars_gnb->total_dlsch_bitrate;
   int coded_bits_per_codeword = 0;
-  uint8_t harq_pid; // in TDD config 3 it is sf-2, i.e., can be 0,1,2
+  // uint8_t harq_pid; // in TDD config 3 it is sf-2, i.e., can be 0,1,2
   int Qm = 2;
 
+  /*
   if (!RC.nrmac[0]->UE_list.active[UE_id])
     return;
   
@@ -191,14 +191,18 @@ void phy_scope_gNB(FD_phy_scope_gnb *form,
       //Qm = cmax(phy_vars_gnb->ulsch[UE_id][0]->harq_processes->Qm,Qm);
     }
   }
-
+  */
   coded_bits_per_codeword = frame_parms->N_RB_UL*12*Qm*frame_parms->symbols_per_tti;
 
-  chest_f_abs = (float*) calloc(nsymb_ce*nb_antennas_rx*nb_antennas_tx,sizeof(float));
+  for (arx=0; arx<nb_antennas_rx; arx++) {
+    rxsig_t_dB[arx] = (float*) calloc(frame_parms->samples_per_frame,sizeof(float));
+    rxsig_f_dB[arx] = (float*) calloc(frame_parms->samples_per_slot_wCP,sizeof(float));
+  }
   llr = (float*) calloc(coded_bits_per_codeword,sizeof(float)); // init to zero
   bit = malloc(coded_bits_per_codeword*sizeof(float));
 
-  rxsig_t = (int16_t**) phy_vars_gnb->common_vars.rxdata;
+  rxsig_t = (int16_t**) phy_vars_ru->common.rxdata;
+  rxsig_f = (int16_t**) phy_vars_ru->common.rxdataF;
   //chest_t = (int16_t**) phy_vars_gnb->pusch_vars[UE_id]->drs_ch_estimates_time[eNB_id];
   /*  chest_t = (int16_t**) phy_vars_gnb->srs_vars[UE_id].srs_ch_estimates;
   chest_f = (int16_t**) phy_vars_gnb->pusch_vars[UE_id]->drs_ch_estimates;
@@ -212,25 +216,26 @@ void phy_scope_gNB(FD_phy_scope_gnb *form,
   // Received signal in time domain of receive antenna 0
   if (rxsig_t != NULL) {
     if (rxsig_t[0] != NULL) {
-      for (i=0; i<FRAME_LENGTH_COMPLEX_SAMPLES; i++) {
+      for (i=0; i<frame_parms->samples_per_frame; i++) {
         rxsig_t_dB[0][i] = 10*log10(1.0+(float) ((rxsig_t[0][2*i])*(rxsig_t[0][2*i])+(rxsig_t[0][2*i+1])*(rxsig_t[0][2*i+1])));
         time[i] = (float) i;
       }
 
-      fl_set_xyplot_data(form->rxsig_t,time,rxsig_t_dB[0],FRAME_LENGTH_COMPLEX_SAMPLES,"","","");
+      fl_set_xyplot_data(form->rxsig_t,time,rxsig_t_dB[0],frame_parms->samples_per_frame,"","","");
     }
 
     for (arx=1; arx<nb_antennas_rx; arx++) {
       if (rxsig_t[arx] != NULL) {
-        for (i=0; i<FRAME_LENGTH_COMPLEX_SAMPLES; i++) {
+        for (i=0; i<frame_parms->samples_per_frame; i++) {
           rxsig_t_dB[arx][i] = 10*log10(1.0+(float) ((rxsig_t[arx][2*i])*(rxsig_t[arx][2*i])+(rxsig_t[arx][2*i+1])*(rxsig_t[arx][2*i+1])));
         }
 
-        fl_add_xyplot_overlay(form->rxsig_t,arx,time,rxsig_t_dB[arx],FRAME_LENGTH_COMPLEX_SAMPLES,rx_antenna_colors[arx]);
+        fl_add_xyplot_overlay(form->rxsig_t,arx,time,rxsig_t_dB[arx],frame_parms->samples_per_frame,rx_antenna_colors[arx]);
       }
     }
   }
 
+  /*
   // Channel Impulse Response
   if (chest_t != NULL) {
     ymax = 0;
@@ -268,12 +273,22 @@ void phy_scope_gNB(FD_phy_scope_gnb *form,
     //        fl_get_xyplot_ybounds(form->chest_t,&ymin,&ymax);
     fl_set_xyplot_ybounds(form->chest_t,0,ymax);
   }
-
+  */
+  
   // Channel Frequency Response
-  if (chest_f != NULL) {
-    ind = 0;
+  if (rxsig_f != NULL) {
+    if (rxsig_f[0] != NULL) {
+      for (i=0; i<frame_parms->samples_per_slot_wCP; i++) {
+        rxsig_f_dB[0][i] = 10*log10(1.0+(float) ((rxsig_f[0][2*i])*(rxsig_f[0][2*i])+(rxsig_f[0][2*i+1])*(rxsig_f[0][2*i+1])));
+        time[i] = (float) i;
+      }
+
+      fl_set_xyplot_data(form->chest_t,time,rxsig_f_dB[0],frame_parms->samples_per_slot_wCP,"","","");
+    }
+  }
+  
+  /*
 
-    for (atx=0; atx<nb_antennas_tx; atx++) {
       for (arx=0; arx<nb_antennas_rx; arx++) {
         if (chest_f[(atx<<1)+arx] != NULL) {
           for (k=0; k<nsymb_ce; k++) {
@@ -364,18 +379,19 @@ void phy_scope_gNB(FD_phy_scope_gnb *form,
   memmove( tput_enb[UE_id], &tput_enb[UE_id][1], (TPUT_WINDOW_LENGTH-1)*sizeof(float) );
 
   tput_time_enb[UE_id][TPUT_WINDOW_LENGTH-1]  = (float) 0;
-  tput_enb[UE_id][TPUT_WINDOW_LENGTH-1] = ((float) total_dlsch_bitrate)/1000.0;
+//  tput_enb[UE_id][TPUT_WINDOW_LENGTH-1] = ((float) total_dlsch_bitrate)/1000.0;
 
   fl_set_xyplot_data(form->pusch_tput,tput_time_enb[UE_id],tput_enb[UE_id],TPUT_WINDOW_LENGTH,"","","");
 
   //    fl_get_xyplot_ybounds(form->pusch_tput,&ymin,&ymax);
   //    fl_set_xyplot_ybounds(form->pusch_tput,0,ymax);
 
+  */
+  
   fl_check_forms();
 
   free(llr);
   free(bit);
-  free(chest_f_abs);
 }
 
 FD_phy_scope_nrue *create_phy_scope_nrue( void )
@@ -492,7 +508,7 @@ void phy_scope_nrUE(FD_phy_scope_nrue *form,
   //int nsymb_ce = frame_parms->ofdm_symbol_size;//*frame_parms->symbols_per_tti;
   int samples_per_frame = frame_parms->samples_per_frame;
   uint8_t nb_antennas_rx = frame_parms->nb_antennas_rx;
-  uint8_t nb_antennas_tx = frame_parms->nb_antenna_ports_eNB;
+  uint8_t nb_antennas_tx = frame_parms->nb_antenna_ports_gNB;
   int16_t **rxsig_t;
   float **rxsig_t_dB;
   float *time;
@@ -863,11 +879,10 @@ typedef struct {
 
 // current status is that every UE has a DL scope for a SINGLE eNB (gnb_id=0)
 // at eNB 0, an UL scope for every UE
-//FD_phy_scope_gnb             *form_gnb[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
-static FD_phy_scope_gnb        *form_gnb[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
+FD_phy_scope_gnb             *form_gnb[NUMBER_OF_UE_MAX];
 //FD_stats_form                  *form_stats=NULL,*form_stats_l2=NULL;
 //char                            title[255];
-unsigned char                   scope_enb_num_ue = 2;
+unsigned char                   scope_enb_num_ue = 1;
 //static pthread_t                forms_thread; //xforms
 
 
@@ -896,7 +911,7 @@ void reset_stats_gNB(FL_OBJECT *button,
 
 
 static void *scope_thread_gNB(void *arg) {
-  int UE_id, CC_id;
+  int UE_id;
   int ue_cnt=0;
 //# ifdef ENABLE_XFORMS_WRITE_STATS
 //  FILE *gNB_stats = fopen("gNB_stats.txt", "w");
@@ -906,13 +921,11 @@ static void *scope_thread_gNB(void *arg) {
     ue_cnt=0;
     
     for(UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
-      for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
         if ((ue_cnt<scope_enb_num_ue)) {
           //this function needs to be written
-          phy_scope_gNB(form_gnb[CC_id][ue_cnt], RC.gNB[0][CC_id], UE_id);
+          phy_scope_gNB(form_gnb[ue_cnt], RC.gNB[0], RC.ru[0], UE_id);
           ue_cnt++;
         }
-      }
     }
     sleep(1);
   }
@@ -956,17 +969,17 @@ void startScope(scopeParms_t * p) {
   FD_stats_form *form_stats=NULL,*form_stats_l2=NULL;
   char title[255];
   fl_initialize (p->argc, p->argv, NULL, 0, 0);
+  /*
   form_stats_l2 = create_form_stats_form();
   fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats");
   form_stats = create_form_stats_form();
   fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats");
-
+  */
+  
   for(int UE_id=0; UE_id<scope_enb_num_ue; UE_id++) {
-    for(int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-      form_gnb[CC_id][UE_id] = create_phy_scope_gnb();
-      sprintf (title, "LTE UL SCOPE eNB for CC_id %d, UE %d",CC_id,UE_id);
-      fl_show_form (form_gnb[CC_id][UE_id]->phy_scope_gnb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title);
-    } // CC_id
+    form_gnb[UE_id] = create_phy_scope_gnb();
+    sprintf (title, "LTE UL SCOPE eNB for UE %d",UE_id);
+    fl_show_form (form_gnb[UE_id]->phy_scope_gnb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title);
   } // UE_id
 
   pthread_t forms_thread;
diff --git a/openair1/PHY/TOOLS/nr_phy_scope.h b/openair1/PHY/TOOLS/nr_phy_scope.h
index 770006d2344..aaee08a554b 100644
--- a/openair1/PHY/TOOLS/nr_phy_scope.h
+++ b/openair1/PHY/TOOLS/nr_phy_scope.h
@@ -78,6 +78,7 @@ FD_phy_scope_nrue * create_phy_scope_nrue( void );
 
 void phy_scope_gNB(FD_phy_scope_gnb *form,
                    PHY_VARS_gNB *phy_vars_gnb,
+		   RU_t *phy_vars_ru,
                    int UE_id);
 
 
diff --git a/openair1/PHY/TOOLS/tools_defs.h b/openair1/PHY/TOOLS/tools_defs.h
index 5ba956fd395..d753b501b6e 100644
--- a/openair1/PHY/TOOLS/tools_defs.h
+++ b/openair1/PHY/TOOLS/tools_defs.h
@@ -36,8 +36,6 @@ extern "C" {
 #include <stdint.h>
 #include "PHY/sse_intrin.h"
 
-#define CEILIDIV(a,b) ((a+b-1)/b)
-#define ROUNDIDIV(a,b) (((a<<1)+b)/(b<<1))
 
 struct complex {
   double x;
@@ -205,6 +203,21 @@ void dft18432(int16_t *sigF,int16_t *sig,int scale);
 
 void dft24576(int16_t *sigF,int16_t *sig,int scale);
 
+void dft49152(int16_t *sigF,int16_t *sig,int scale);
+void idft49152(int16_t *sigF,int16_t *sig,int scale);
+
+void dft9216(int16_t *sigF,int16_t *sig,int scale);
+void idft9216(int16_t *sigF,int16_t *sig,int scale);
+
+void dft36864(int16_t *sigF,int16_t *sig,int scale);
+void idft36864(int16_t *sigF,int16_t *sig,int scale);
+
+void dft98304(int16_t *sigF,int16_t *sig,int scale);
+void idft98304(int16_t *sigF,int16_t *sig,int scale);
+
+void dft73728(int16_t *sigF,int16_t *sig,int scale);
+void idft73728(int16_t *sigF,int16_t *sig,int scale);
+
 
 /*!\fn int32_t rotate_cpx_vector(int16_t *x,int16_t *alpha,int16_t *y,uint32_t N,uint16_t output_shift)
 This function performs componentwise multiplication of a vector with a complex scalar.
diff --git a/openair1/PHY/defs_RU.h b/openair1/PHY/defs_RU.h
index 94afeed12f4..10496ced20d 100644
--- a/openair1/PHY/defs_RU.h
+++ b/openair1/PHY/defs_RU.h
@@ -468,6 +468,8 @@ typedef struct RU_t_s {
   int nb_rx;
   /// number of TX paths on device
   int nb_tx;
+  /// number of logical antennas at TX beamformer input
+  int nb_log_antennas;
   /// maximum PDSCH RS EPRE
   int max_pdschReferenceSignalPower;
   /// maximum RX gain
@@ -604,6 +606,8 @@ typedef struct RU_t_s {
   int wakeup_L1_sleeptime;
   /// maximum number of sleeps
   int wakeup_L1_sleep_cnt_max;
+  /// DL IF frequency in Hz
+  uint64_t if_frequency;
 } RU_t;
 
 
diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h
index 93dc8d6bd51..f52558b6320 100644
--- a/openair1/PHY/defs_common.h
+++ b/openair1/PHY/defs_common.h
@@ -85,6 +85,7 @@
 #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 NR_NUMBER_OF_SYMBOLS_PER_SLOT 14
 
 #define PRACH_SYMBOL 3 //position of the UL PSS wrt 2nd slot of special subframe
 
@@ -635,6 +636,10 @@ typedef struct LTE_DL_FRAME_PARMS {
   uint16_t first_carrier_offset_khz_1dot25;
   /// Number of samples in a subframe
   uint32_t samples_per_tti;
+  /// Number of samples in a subframe
+  uint32_t samples_per_subframe;
+  /// Number of samples in a slot
+  uint32_t samples_per_slot;
   /// 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 OFDM symbols in DL portion of S-subframe
diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h
index 3c0f0db8dae..b5a24ca7938 100644
--- a/openair1/PHY/defs_gNB.h
+++ b/openair1/PHY/defs_gNB.h
@@ -40,7 +40,7 @@
 #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
 #include "PHY/impl_defs_top.h"
 #include "PHY/defs_common.h"
-#include "PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h"
+#include "PHY/CODING/nrLDPC_extern.h"
 #include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h"
 
 #define MAX_NUM_RU_PER_gNB MAX_NUM_RU_PER_eNB
@@ -61,29 +61,6 @@ typedef struct {
 } NR_PBCH_parms_t;
 
 
-typedef struct {
-  /// Length of DCI payload in bits
-  uint16_t size;
-  /// Aggregation level
-  uint8_t L;
-  /// HARQ PID
-  uint8_t harq_pid;
-  /// PDCCH parameters
-  nfapi_nr_dl_config_pdcch_parameters_rel15_t pdcch_params;
-  /// CCE list
-  nr_cce_t cce_list[NR_MAX_PDCCH_AGG_LEVEL];
-  /// DCI pdu
-  uint64_t dci_pdu[2];
-} NR_gNB_DCI_ALLOC_t;
-
-
-typedef struct {
-  uint8_t     num_dci;
-  uint8_t     num_pdsch_rnti;
-  NR_gNB_DCI_ALLOC_t dci_alloc[256];
-} NR_gNB_PDCCH;
-
-
 typedef enum {
   NR_SCH_IDLE,
   NR_ACTIVE,
@@ -94,7 +71,7 @@ typedef enum {
 
 typedef struct {
   /// Nfapi DLSCH PDU
-  nfapi_nr_dl_config_dlsch_pdu dlsch_pdu;
+  nfapi_nr_dl_tti_pdsch_pdu pdsch_pdu;
   /// pointer to pdu from MAC interface (this is "a" in 36.212)
   uint8_t *pdu;
   /// The payload + CRC size in bits, "B" from 36-212
@@ -112,11 +89,11 @@ typedef struct {
   /// MIMO mode for this DLSCH
   MIMO_mode_t mimo_mode;
   /// Concatenated sequences
-  uint8_t e[MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32)));
+  uint8_t *e;
   /// LDPC-code outputs
   uint8_t *d[MAX_NUM_NR_DLSCH_SEGMENTS];
   /// Interleaver outputs
-  uint8_t f[MAX_NUM_NR_CHANNEL_BITS] __attribute__((aligned(32)));
+  uint8_t *f;
   /// Number of code segments
   uint32_t C;
   /// Number of bits in "small" code segments
@@ -171,10 +148,21 @@ typedef struct {
   int16_t sqrt_rho_b;
 } NR_gNB_DLSCH_t;
 
+typedef struct {
+  /// \brief ?.
+  /// first index: ? [0..1023] (hard coded)
+  int16_t *prachF;
+  /// \brief ?.
+  /// second index: rx antenna [0..63] (hard coded) \note Hard coded array size indexed by \c nb_antennas_rx.
+  /// third index: frequency-domain sample [0..ofdm_symbol_size*12[
+  int16_t **rxsigF;
+  /// \brief local buffer to compute prach_ifft
+  int32_t *prach_ifft;
+} NR_gNB_PRACH;
 
 typedef struct {
   /// Nfapi ULSCH PDU
-  nfapi_nr_ul_config_ulsch_pdu ulsch_pdu;
+  nfapi_nr_pusch_pdu_t ulsch_pdu;
   /// Frame where current HARQ round was sent
   uint32_t frame;
   /// Subframe where current HARQ round was sent
@@ -285,7 +273,7 @@ typedef struct {
   /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled
   uint8_t h[MAX_NUM_CHANNEL_BITS];
   /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
-  int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)];
+  int16_t *w[MAX_NUM_NR_ULSCH_SEGMENTS];
   //////////////////////////////////////////////////////////////
 } NR_UL_gNB_HARQ_t;
 
@@ -375,6 +363,14 @@ typedef struct {
   /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
   /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[
   int32_t **ul_ch_estimates_ext;
+  /// \brief Hold the PTRS phase estimates in frequency domain.
+  /// - first index: rx antenna id [0..nb_antennas_rx[
+  /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[
+  int32_t **ul_ch_ptrs_estimates;
+  /// \brief Uplink phase estimates extracted in PRBS.
+  /// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
+  /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[
+  int32_t **ul_ch_ptrs_estimates_ext;
   /// \brief Holds the compensated signal.
   /// - first index: rx antenna id [0..nb_antennas_rx[
   /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[
@@ -414,8 +410,16 @@ typedef struct {
   /// \brief llr values.
   /// - first index: ? [0..1179743] (hard coded)
   int16_t *llr;
-  // DMRS symbol index, to be updated every DMRS symbol within a slot.
+  /// DMRS symbol index, to be updated every DMRS symbol within a slot.
   uint8_t dmrs_symbol;
+  // PTRS symbol index, to be updated every PTRS symbol within a slot.
+  uint8_t ptrs_symbol_index;
+  /// bit mask of PT-RS ofdm symbol indicies
+  uint16_t ptrs_symbols;
+  // PTRS subcarriers per OFDM symbol
+  uint16_t ptrs_sc_per_ofdm_symbol;
+  /// flag to verify if channel level computation is done
+  uint8_t cl_done;
 } NR_gNB_PUSCH;
 
 
@@ -612,7 +616,7 @@ typedef struct PHY_VARS_gNB_s {
   int                  rx_total_gain_dB;
   int                  (*nr_start_if)(struct RU_t_s *ru, struct PHY_VARS_gNB_s *gNB);
   uint8_t              local_flag;
-  nfapi_nr_config_request_t  gNB_config;
+  nfapi_nr_config_request_scf_t  gNB_config;
   NR_DL_FRAME_PARMS    frame_parms;
   PHY_MEASUREMENTS_gNB measurements;
   NR_IF_Module_t       *if_inst;
@@ -637,21 +641,21 @@ typedef struct PHY_VARS_gNB_s {
   //Sched_Rsp_t         Sched_INFO;
   nfapi_nr_ul_tti_request_t     UL_tti_req;
   
-  NR_gNB_PDCCH        pdcch_vars;
-  NR_gNB_PBCH         pbch;
+  nfapi_nr_dl_tti_pdcch_pdu    *pdcch_pdu;
+  nfapi_nr_ul_dci_request_pdus_t  *ul_dci_pdu;
+  nfapi_nr_dl_tti_ssb_pdu      ssb_pdu;
 
-  NR_gNB_COMMON       common_vars;
-  NR_gNB_PUSCH       *pusch_vars[NUMBER_OF_UE_MAX];
+  int num_pdsch_rnti;
+  NR_gNB_PBCH         pbch;
+  nr_cce_t           cce_list[MAX_DCI_CORESET][NR_MAX_PDCCH_AGG_LEVEL];
+  NR_gNB_COMMON      common_vars;
+  NR_gNB_PRACH       prach_vars;
+  NR_gNB_PUSCH       *pusch_vars[NUMBER_OF_NR_ULSCH_MAX];
   NR_gNB_DLSCH_t     *dlsch[NUMBER_OF_NR_DLSCH_MAX][2];    // Nusers times two spatial streams
   NR_gNB_ULSCH_t     *ulsch[NUMBER_OF_NR_ULSCH_MAX][2];  // [Nusers times][2 codewords] 
   NR_gNB_DLSCH_t     *dlsch_SI,*dlsch_ra,*dlsch_p;
   NR_gNB_DLSCH_t     *dlsch_PCH;
-/*
-  LTE_eNB_UE_stats    UE_stats[NUMBER_OF_UE_MAX];
-  LTE_eNB_UE_stats   *UE_stats_ptr[NUMBER_OF_UE_MAX];
-*/
   uint8_t pbch_configured;
-  uint8_t pbch_pdu[4]; //PBCH_PDU_SIZE
   char gNB_generate_rar;
 
   /// NR synchronization sequences
@@ -669,12 +673,15 @@ typedef struct PHY_VARS_gNB_s {
 
   /// PDSCH DMRS sequence
   uint32_t ****nr_gold_pdsch_dmrs;
-  
+
   /// PUSCH DMRS
-  uint32_t nr_gold_pusch[2][20][2][NR_MAX_PUSCH_DMRS_INIT_LENGTH_DWORD];
+  uint32_t ****nr_gold_pusch_dmrs;
 
   /// Indicator set to 0 after first SR
-  uint8_t first_sr[NUMBER_OF_UE_MAX];
+  uint8_t first_sr[NUMBER_OF_NR_SR_MAX];
+
+  /// PRACH root sequence
+  uint32_t X_u[64][839];
 
   uint32_t max_peak_val;
 
@@ -685,7 +692,6 @@ typedef struct PHY_VARS_gNB_s {
   /// N0 (used for abstraction)
   double N0;
 
-  unsigned char first_run_timing_advance[NUMBER_OF_UE_MAX];
   unsigned char first_run_I0_measurements;
 
 
@@ -703,96 +709,29 @@ typedef struct PHY_VARS_gNB_s {
   /// counter to average prach energh over first 100 prach opportunities
   int prach_energy_counter;
 
-  // PDSCH Variables
-  PDSCH_CONFIG_DEDICATED pdsch_config_dedicated[NUMBER_OF_UE_MAX];
-
-  // PUSCH Varaibles
-  PUSCH_CONFIG_DEDICATED pusch_config_dedicated[NUMBER_OF_UE_MAX];
-
-  PUSCH_Config_t pusch_config;
-
-  // PUCCH variables
-  PUCCH_CONFIG_DEDICATED pucch_config_dedicated[NUMBER_OF_UE_MAX];
-
-  // UL-POWER-Control
-  UL_POWER_CONTROL_DEDICATED ul_power_control_dedicated[NUMBER_OF_UE_MAX];
-
-  // TPC
-  TPC_PDCCH_CONFIG tpc_pdcch_config_pucch[NUMBER_OF_UE_MAX];
-  TPC_PDCCH_CONFIG tpc_pdcch_config_pusch[NUMBER_OF_UE_MAX];
-
-  // CQI reporting
-  CQI_REPORT_CONFIG cqi_report_config[NUMBER_OF_UE_MAX];
-
-  // SRS Variables
-  SOUNDINGRS_UL_CONFIG_DEDICATED soundingrs_ul_config_dedicated[NUMBER_OF_UE_MAX];
-
-  dmrs_UplinkConfig_t dmrs_UplinkConfig;
-
-  dmrs_DownlinkConfig_t dmrs_DownlinkConfig;
-
-  uint8_t ncs_cell[20][7];
-
-  // Scheduling Request Config
-  SCHEDULING_REQUEST_CONFIG scheduling_request_config[NUMBER_OF_UE_MAX];
-
-  // Transmission mode per UE
-  uint8_t transmission_mode[NUMBER_OF_UE_MAX];
-
-  /// cba_last successful reception for each group, used for collision detection
-  uint8_t cba_last_reception[4];
-
-  // Pointers for active physicalConfigDedicated to be applied in current slot
-  struct PhysicalConfigDedicated *physicalConfigDedicated[NUMBER_OF_UE_MAX];
-
-
-  uint32_t rb_mask_ul[4];
-
-  /// Information regarding TM5
-  MU_MIMO_mode mu_mimo_mode[NUMBER_OF_UE_MAX];
-
-
-  /// target_ue_dl_mcs : only for debug purposes
-  uint32_t target_ue_dl_mcs;
-  /// target_ue_ul_mcs : only for debug purposes
-  uint32_t target_ue_ul_mcs;
-  /// target_ue_dl_rballoc : only for debug purposes
-  uint32_t ue_dl_rb_alloc;
-  /// target ul PRBs : only for debug
-  uint32_t ue_ul_nb_rb;
-
-  ///check for Total Transmissions
-  uint32_t check_for_total_transmissions;
-
-  ///check for MU-MIMO Transmissions
-  uint32_t check_for_MUMIMO_transmissions;
-
-  ///check for SU-MIMO Transmissions
-  uint32_t check_for_SUMIMO_transmissions;
-
-  ///check for FULL MU-MIMO Transmissions
-  uint32_t  FULL_MUMIMO_transmissions;
-
-  /// Counter for total bitrate, bits and throughput in downlink
-  uint32_t total_dlsch_bitrate;
-  uint32_t total_transmitted_bits;
-  uint32_t total_system_throughput;
-
-  int hw_timing_advance;
-
+  /*
   time_stats_t phy_proc;
+  */
   time_stats_t phy_proc_tx;
+  /*
   time_stats_t phy_proc_rx;
+  */
   time_stats_t rx_prach;
-
+  /*
   time_stats_t ofdm_mod_stats;
+  */
   time_stats_t dlsch_encoding_stats;
   time_stats_t dlsch_modulation_stats;
   time_stats_t dlsch_scrambling_stats;
+  time_stats_t tinput;
+  time_stats_t tprep;
+  time_stats_t tparity;
+  time_stats_t toutput;
+  
   time_stats_t dlsch_rate_matching_stats;
-  time_stats_t dlsch_turbo_encoding_stats;
   time_stats_t dlsch_interleaving_stats;
-
+  time_stats_t dlsch_segmentation_stats;
+  /*
   time_stats_t rx_dft_stats;
   time_stats_t ulsch_channel_estimation_stats;
   time_stats_t ulsch_freq_offset_estimation_stats;
@@ -803,29 +742,7 @@ typedef struct PHY_VARS_gNB_s {
   time_stats_t ulsch_deinterleaving_stats;
   time_stats_t ulsch_demultiplexing_stats;
   time_stats_t ulsch_llr_stats;
-  time_stats_t ulsch_tc_init_stats;
-  time_stats_t ulsch_tc_alpha_stats;
-  time_stats_t ulsch_tc_beta_stats;
-  time_stats_t ulsch_tc_gamma_stats;
-  time_stats_t ulsch_tc_ext_stats;
-  time_stats_t ulsch_tc_intl1_stats;
-  time_stats_t ulsch_tc_intl2_stats;
-
-#ifdef LOCALIZATION
-  /// time state for localization
-  time_stats_t localization_stats;
-#endif
-
-  int32_t pucch1_stats_cnt[NUMBER_OF_UE_MAX][10];
-  int32_t pucch1_stats[NUMBER_OF_UE_MAX][10*1024];
-  int32_t pucch1_stats_thres[NUMBER_OF_UE_MAX][10*1024];
-  int32_t pucch1ab_stats_cnt[NUMBER_OF_UE_MAX][10];
-  int32_t pucch1ab_stats[NUMBER_OF_UE_MAX][2*10*1024];
-  int32_t pusch_stats_rb[NUMBER_OF_UE_MAX][10240];
-  int32_t pusch_stats_round[NUMBER_OF_UE_MAX][10240];
-  int32_t pusch_stats_mcs[NUMBER_OF_UE_MAX][10240];
-  int32_t pusch_stats_bsr[NUMBER_OF_UE_MAX][10240];
-  int32_t pusch_stats_BO[NUMBER_OF_UE_MAX][10240];
+  */
 } PHY_VARS_gNB;
 
 #endif
diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h
index d72979262c3..6f6c5ac8e9a 100644
--- a/openair1/PHY/defs_nr_UE.h
+++ b/openair1/PHY/defs_nr_UE.h
@@ -45,6 +45,7 @@
 #include <math.h>
 #include "common_lib.h"
 #include "msc.h"
+#include "fapi_nr_ue_interface.h"
 
 //#include <complex.h>
 #include "assertions.h"
@@ -470,65 +471,7 @@ typedef struct {
 #ifdef NR_PDCCH_DEFS_NR_UE
 
 #define MAX_NR_DCI_DECODED_SLOT     10    // This value is not specified
-#define NBR_NR_FORMATS              8     // The number of formats is 8 (0_0, 0_1, 1_0, 1_1, 2_0, 2_1, 2_2, 2_3)
-#define NBR_NR_DCI_FIELDS           56    // The number of different dci fields defined in TS 38.212 subclause 7.3.1
-
-#define IDENTIFIER_DCI_FORMATS           0
-#define CARRIER_IND                      1
-#define SUL_IND_0_1                      2
-#define SLOT_FORMAT_IND                  3
-#define PRE_EMPTION_IND                  4
-#define BLOCK_NUMBER                     5
-#define CLOSE_LOOP_IND                   6
-#define BANDWIDTH_PART_IND               7
-#define SHORT_MESSAGE_IND                8
-#define SHORT_MESSAGES                   9
-#define FREQ_DOM_RESOURCE_ASSIGNMENT_UL 10
-#define FREQ_DOM_RESOURCE_ASSIGNMENT_DL 11
-#define TIME_DOM_RESOURCE_ASSIGNMENT    12
-#define VRB_TO_PRB_MAPPING              13
-#define PRB_BUNDLING_SIZE_IND           14
-#define RATE_MATCHING_IND               15
-#define ZP_CSI_RS_TRIGGER               16
-#define FREQ_HOPPING_FLAG               17
-#define TB1_MCS                         18
-#define TB1_NDI                         19
-#define TB1_RV                          20
-#define TB2_MCS                         21
-#define TB2_NDI                         22
-#define TB2_RV                          23
-#define MCS                             24
-#define NDI                             25
-#define RV                              26
-#define HARQ_PROCESS_NUMBER             27
-#define DAI_                            28
-#define FIRST_DAI                       29
-#define SECOND_DAI                      30
-#define TB_SCALING                      31
-#define TPC_PUSCH                       32
-#define TPC_PUCCH                       33
-#define PUCCH_RESOURCE_IND              34
-#define PDSCH_TO_HARQ_FEEDBACK_TIME_IND 35
-#define SRS_RESOURCE_IND                36
-#define PRECOD_NBR_LAYERS               37
-#define ANTENNA_PORTS                   38
-#define TCI                             39
-#define SRS_REQUEST                     40
-#define TPC_CMD                         41
-#define CSI_REQUEST                     42
-#define CBGTI                           43
-#define CBGFI                           44
-#define PTRS_DMRS                       45
-#define BETA_OFFSET_IND                 46
-#define DMRS_SEQ_INI                    47
-#define UL_SCH_IND                      48
-#define PADDING_NR_DCI                  49
-#define SUL_IND_0_0                     50
-#define RA_PREAMBLE_INDEX               51
-#define SUL_IND_1_0                     52
-#define SS_PBCH_INDEX                   53
-#define PRACH_MASK_INDEX                54
-#define RESERVED_NR_DCI                 55
+
 
 
 typedef enum {
@@ -759,12 +702,6 @@ typedef struct {
   /// \brief PDCCH/DCI e-sequence (input to rate matching).
   /// - first index: ? [0..96*N_RB_DL[
   int16_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
@@ -773,11 +710,14 @@ typedef struct {
   uint32_t dci_false;
   /// Total number of DCI missed (diagnostic mode)
   uint32_t dci_missed;
-  /// nCCE for PUCCH per subframe
+  /// nCCE for PDCCH per subframe
   uint8_t nCCE[10];
   //Check for specific DCIFormat and AgregationLevel
   uint8_t dciFormat;
   uint8_t agregationLevel;
+  int nb_search_space;
+  fapi_nr_dl_config_dci_dl_pdu_rel15_t pdcch_config[FAPI_NR_MAX_SS_PER_CORESET];
+  /*
 #ifdef NR_PDCCH_DEFS_NR_UE
   int nb_searchSpaces;
   // CORESET structure, where maximum number of CORESETs to be handled is 3 (according to 38.331 V15.1.0)
@@ -788,7 +728,7 @@ typedef struct {
 
   int n_RB_BWP[NR_NBR_SEARCHSPACE_ACT_BWP];
   uint32_t nb_search_space;
-#endif
+  #endif*/
 } NR_UE_PDCCH;
 
 #define PBCH_A 24
@@ -940,9 +880,10 @@ typedef struct {
 
   nr_ue_if_module_t *if_inst;
 
-  //nfapi_nr_config_request_t  nrUE_config; <-- don't use config type for gNB!!!
   fapi_nr_config_request_t nrUE_config;
 
+  uint16_t frame_gap;
+
   // the following structures are not part of PHY_vars_UE anymore as it is not thread safe. They are now on the stack of the functions that actually need them
   
   //nr_downlink_indication_t dl_indication;
@@ -957,8 +898,9 @@ typedef struct {
   //fapi_nr_dci_indication_t dci_ind;
 
   // point to the current rxTx thread index
-  uint8_t current_thread_id[40];
+  uint8_t current_thread_id[NR_MAX_SLOTS_PER_FRAME];
 
+  t_nrPolar_params *polarList;
   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];
@@ -1012,6 +954,9 @@ typedef struct {
   /// PUSCH DMRS sequence
   uint32_t ****nr_gold_pusch_dmrs;
 
+  /// flag to indicate if PTRS is configured
+  uint8_t ptrs_configured;
+
   uint32_t X_u[64][839];
 
   uint32_t high_speed_flag;
@@ -1064,12 +1009,13 @@ typedef struct {
   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               generate_nr_prach;
   uint8_t               prach_cnt;
   uint8_t               prach_PreambleIndex;
   //  uint8_t               prach_timer;
   uint8_t               decode_SIB;
   uint8_t               decode_MIB;
-  uint8_t	   ssb_periodicity;
+  uint8_t               init_sync_frame;
   /// temporary offset during cell search prior to MIB decoding
   int              ssb_offset;
   uint16_t	   symbol_offset; // offset in terms of symbols for detected ssb in sync
@@ -1143,7 +1089,6 @@ typedef struct {
 
   crossCarrierSchedulingConfig_t crossCarrierSchedulingConfig;
   supplementaryUplink_t supplementaryUplink;
-  dmrs_UplinkConfig_t dmrs_UplinkConfig;
   dmrs_DownlinkConfig_t dmrs_DownlinkConfig;
   csi_MeasConfig_t csi_MeasConfig;
   PUSCH_ServingCellConfig_t PUSCH_ServingCellConfig;
diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h
index 048e48ae458..ccc79b7d47a 100644
--- a/openair1/PHY/defs_nr_common.h
+++ b/openair1/PHY/defs_nr_common.h
@@ -35,7 +35,7 @@
 
 #include "PHY/impl_defs_top.h"
 #include "defs_common.h"
-#include "nfapi_nr_interface.h"
+#include "nfapi_nr_interface_scf.h"
 #include "impl_defs_nr.h"
 #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
 
@@ -102,6 +102,15 @@
 #define NR_MAX_PUSCH_ENCODED_LENGTH NR_MAX_PDSCH_ENCODED_LENGTH
 #define NR_MAX_PDSCH_TBS 3824
 
+#define MAX_NUM_NR_DLSCH_SEGMENTS 34
+#define MAX_NR_DLSCH_PAYLOAD_BYTES (MAX_NUM_NR_DLSCH_SEGMENTS*1056)
+
+#define MAX_NUM_NR_ULSCH_SEGMENTS MAX_NUM_NR_DLSCH_SEGMENTS
+#define MAX_NR_ULSCH_PAYLOAD_BYTES (MAX_NUM_NR_ULSCH_SEGMENTS*1056)
+
+#define MAX_NUM_NR_CHANNEL_BITS (14*273*12*8)  // 14 symbols, 273 RB
+#define MAX_NUM_NR_RE (14*273*12)
+
 typedef enum {
   NR_MU_0=0,
   NR_MU_1,
@@ -190,35 +199,43 @@ typedef struct {
 } nr_cce_t;
 
 
-/// PRACH-ConfigInfo from 36.331 RRC spec
+/// PRACH-ConfigInfo from 38.331 RRC spec
 typedef struct {
-  /// Parameter: prach-ConfigurationIndex, see TS 36.211 (5.7.1). \vr{[0..63]}
+  /// Parameter: prach-ConfigurationIndex, see TS 38.211 (6.3.3.2). 
   uint8_t prach_ConfigIndex;
-  /// Parameter: High-speed-flag, see TS 36.211 (5.7.2). \vr{[0..1]} 1 corresponds to Restricted set and 0 to Unrestricted set.
+  /// Parameter: High-speed-flag, see TS 38.211 (6.3.3.1). 1 corresponds to Restricted set and 0 to Unrestricted set.
   uint8_t highSpeedFlag;
-  /// Parameter: \f$N_\text{CS}\f$, see TS 36.211 (5.7.2). \vr{[0..15]}\n Refer to table 5.7.2-2 for preamble format 0..3 and to table 5.7.2-3 for preamble format 4.
+  /// Restricted Set Config (type A=0 , type B=1) TS 38.211 (6.3.3.1)
+  uint8_t restrictedSetConfig;
+  /// 38.211 (NCS 38.211 6.3.3.1). 
   uint8_t zeroCorrelationZoneConfig;
-  /// Parameter: prach-FrequencyOffset, see TS 36.211 (5.7.1). \vr{[0..94]}\n For TDD the value range is dependent on the value of \ref prach_ConfigIndex.
-  uint8_t prach_FreqOffset;
+  /// see TS 38.211 (6.3.3.2). 
+  uint8_t msg1_frequencystart;
 } NR_PRACH_CONFIG_INFO;
 
 /// PRACH-ConfigSIB or PRACH-Config
 typedef struct {
-  /// Parameter: RACH_ROOT_SEQUENCE, see TS 36.211 (5.7.1). \vr{[0..837]}
+  /// Parameter: prach-rootSequenceIndex, see TS 38.211 (6.3.3.2).
   uint16_t rootSequenceIndex;
-  /// prach_Config_enabled=1 means enabled. \vr{[0..1]}
+  /// prach_Config_enabled=1 means enabled.}
   uint8_t prach_Config_enabled;
   /// PRACH Configuration Information
   NR_PRACH_CONFIG_INFO prach_ConfigInfo;
 } NR_PRACH_CONFIG_COMMON;
 
-typedef struct NR_DL_FRAME_PARMS {
+typedef struct NR_DL_FRAME_PARMS NR_DL_FRAME_PARMS;
+
+typedef uint32_t (*get_samples_per_slot_t)(int slot, NR_DL_FRAME_PARMS* fp);
+
+typedef uint32_t (*get_samples_slot_timestamp_t)(int slot, NR_DL_FRAME_PARMS* fp, uint8_t sl_ahead);
+
+struct NR_DL_FRAME_PARMS {
   /// frequency range
   nr_frequency_range_e freq_range;
-  /// Placeholder to replace overlapping fields below
-  nfapi_nr_rf_config_t rf_config;
+  //  /// Placeholder to replace overlapping fields below
+  //  nfapi_nr_rf_config_t rf_config;
   /// Placeholder to replace SSB overlapping fields below
-  nfapi_nr_sch_config_t sch_config;
+  //  nfapi_nr_sch_config_t sch_config;
   /// Number of resource blocks (RB) in DL
   int N_RB_DL;
   /// Number of resource blocks (RB) in UL
@@ -227,12 +244,12 @@ typedef struct NR_DL_FRAME_PARMS {
   uint8_t N_RBG;
   /// Total Number of Resource Block Groups SubSets: this is P
   uint8_t N_RBGS;
-  /// EUTRA Band
-  uint16_t eutra_band;
+  /// NR Band
+  uint16_t nr_band;
   /// DL carrier frequency
-  uint32_t dl_CarrierFreq;
+  uint64_t dl_CarrierFreq;
   /// UL carrier frequency
-  uint32_t ul_CarrierFreq;
+  uint64_t ul_CarrierFreq;
   /// TX attenuation
   uint32_t att_tx;
   /// RX attenuation
@@ -240,11 +257,10 @@ typedef struct NR_DL_FRAME_PARMS {
   ///  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;
+  /// subcarrier spacing (15,30,60,120)
   uint32_t subcarrier_spacing;
   /// 3/4 sampling
   uint8_t threequarter_fs;
@@ -260,12 +276,18 @@ typedef struct NR_DL_FRAME_PARMS {
   uint16_t symbols_per_slot;
   /// Number of slots per subframe
   uint16_t slots_per_subframe;
-    /// Number of slots per frame
+  /// Number of slots per frame
   uint16_t slots_per_frame;
   /// Number of samples in a subframe
   uint32_t samples_per_subframe;
-  /// Number of samples in a slot
-  uint32_t samples_per_slot;
+  /// Number of samples in current slot
+  get_samples_per_slot_t get_samples_per_slot;
+  /// Number of samples before slot
+  get_samples_slot_timestamp_t get_samples_slot_timestamp;
+  /// Number of samples in 0th and center slot of a subframe
+  uint32_t samples_per_slot0;
+  /// Number of samples in other slots of the subframe
+  uint32_t samples_per_slotN0;
   /// 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
@@ -290,7 +312,7 @@ typedef struct NR_DL_FRAME_PARMS {
   /// 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;
+  uint8_t nb_antenna_ports_gNB;
   /// PRACH_CONFIG
   NR_PRACH_CONFIG_COMMON prach_config_common;
   /// Cyclic Prefix for DL (0=Normal CP, 1=Extended CP)
@@ -299,17 +321,20 @@ typedef struct NR_DL_FRAME_PARMS {
   uint8_t nushift;
   /// SRS configuration from TS 38.331 RRC
   SRS_NR srs_nr;
-
+  /// Power used by SSB in order to estimate signal strength and path loss
+  int ss_PBCH_BlockPower;
   /// 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_UL_DL_SlotConfig_t *p_TDD_UL_DL_ConfigDedicated;
 
   /// TDD configuration
   uint16_t tdd_uplink_nr[2*NR_MAX_SLOTS_PER_FRAME]; /* this is a bitmap of symbol of each slot given for 2 frames */
 
+  uint8_t half_frame_bit;
+
   //SSB related params
   /// Start in Subcarrier index of the SSB block
   uint16_t ssb_start_subcarrier;
@@ -321,10 +346,12 @@ typedef struct NR_DL_FRAME_PARMS {
   uint64_t L_ssb;
   /// Total number of SSB transmitted
   uint8_t N_ssb;
+  /// SSB index
+  uint8_t ssb_index;
   /// PBCH polar encoder params
   t_nrPolar_params pbch_polar_params;
 
-} NR_DL_FRAME_PARMS;
+};
 
 #define KHz (1000UL)
 #define MHz (1000*KHz)
@@ -335,8 +362,9 @@ typedef struct nr_bandentry_s {
   uint64_t ul_max;
   uint64_t dl_min;
   uint64_t dl_max;
-  uint64_t N_OFFs_DL;
   uint64_t step_size;
+  uint64_t N_OFFs_DL;
+  uint8_t deltaf_raster;
 } nr_bandentry_t;
 
 typedef struct nr_band_info_s {
diff --git a/openair1/PHY/impl_defs_nr.h b/openair1/PHY/impl_defs_nr.h
index 6e13973dd9e..44f2e314ea6 100644
--- a/openair1/PHY/impl_defs_nr.h
+++ b/openair1/PHY/impl_defs_nr.h
@@ -67,33 +67,10 @@ EXTERN const uint8_t N_slot_subframe[MU_NUMBER]
 #endif
 ;
 
-//#define RX_NB_TH_MAX 3
-//#define RX_NB_TH 3
-
-#if 0
-#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)
-
-#endif
 
 #define  NB_DL_DATA_TO_UL_ACK              (8) /* size of table TS 38.213 Table 9.2.3-1 */
 
+
 /***********************************************************************
 *
 * FUNCTIONALITY    :  System information type 1
@@ -120,15 +97,11 @@ SystemInformationBlockType1_nr_t;
 #define NR_TDD_SET_ALL_SYMBOLS             (0x3FFF)
 
 #define NR_DOWNLINK_SLOT                   (0x01)
-#define NR_UPLINK_SLOT                     (0x03)
+#define NR_UPLINK_SLOT                     (0x02)
+#define NR_MIXED_SLOT                      (0x03)
 
 #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,
@@ -140,7 +113,7 @@ typedef enum {
   ms10     = 10000,
 } dl_UL_TransmissionPeriodicity_t;
 
-typedef struct {
+typedef struct TDD_UL_DL_configCommon_s {
   /// 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.
@@ -164,7 +137,7 @@ typedef struct {
   /// 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;
+  struct TDD_UL_DL_configCommon_s *p_next;
 } TDD_UL_DL_configCommon_t;
 
 typedef struct {
@@ -363,9 +336,9 @@ typedef struct {
 
 /***********************************************************************
 *
-* FUNCTIONALITY    :  Packed Downlink Shared Channel PDSCH
+* FUNCTIONALITY    :  Physical Downlink Shared Channel PDSCH
 *
-* DESCRIPTION      :  interface description for PSCH configuration
+* DESCRIPTION      :  interface description for PSDCH configuration
 *
 ************************************************************************/
 
@@ -510,9 +483,6 @@ typedef struct {
   uint8_t         startSymbolAndLength;
 } PUSCH_TimeDomainResourceAllocation_t;
 ////////////////////////////////////////////////////////////////////////////////################################
-typedef struct { // The IE PTRS-UplinkConfig is used to configure uplink Phase-Tracking-Reference-Signals (PTRS)
-
-} ptrs_UplinkConfig_t;
 typedef enum{
   maxCodeBlockGroupsPerTransportBlock_n2 = 2,
   maxCodeBlockGroupsPerTransportBlock_n4 = 4,
@@ -530,8 +500,8 @@ typedef enum {
   pdsch_dmrs_type2 = 2
 } pdsch_dmrs_type_t;
 typedef enum {
-  pusch_dmrs_type1 = 1,
-  pusch_dmrs_type2 = 2
+  pusch_dmrs_type1 = 0,
+  pusch_dmrs_type2 = 1
 } pusch_dmrs_type_t;
 typedef enum {
   pdsch_dmrs_pos0 = 0,
@@ -544,6 +514,12 @@ typedef enum {
   pusch_dmrs_pos2 = 2,
   pusch_dmrs_pos3 = 3,
 } pusch_dmrs_AdditionalPosition_t;
+typedef enum {
+  offset00 = 0,
+  offset01 = 1,
+  offset10 = 2,
+  offset11 = 3,
+} ptrs_resource_elementoffset_t;
 typedef enum {
   pdsch_len1 = 1,
   pdsch_len2 = 2
@@ -552,6 +528,22 @@ typedef enum {
   pusch_len1 = 1,
   pusch_len2 = 2
 } pusch_maxLength_t;
+typedef struct {
+  uint8_t ptrs_mcs1;
+  uint8_t ptrs_mcs2;
+  uint8_t ptrs_mcs3;
+} ptrs_time_density_t;
+typedef struct {
+  uint16_t n_rb0;
+  uint16_t n_rb1;
+} ptrs_frequency_density_t;
+typedef struct { // The IE PTRS-UplinkConfig is used to configure uplink Phase-Tracking-Reference-Signals (PTRS)
+  uint8_t  num_ptrs_ports;
+  ptrs_resource_elementoffset_t resourceElementOffset;
+  ptrs_time_density_t  timeDensity;
+  ptrs_frequency_density_t  frequencyDensity;
+  uint32_t  ul_ptrs_power;
+} ptrs_UplinkConfig_t;
 typedef struct { // The IE DMRS-DownlinkConfig is used to configure downlink demodulation reference signals for PDSCH
   pdsch_dmrs_type_t pdsch_dmrs_type;
   pdsch_dmrs_AdditionalPosition_t pdsch_dmrs_AdditionalPosition;
@@ -563,6 +555,7 @@ typedef struct { // The IE DMRS-UplinkConfig is used to configure uplink demodul
   pusch_dmrs_type_t pusch_dmrs_type;
   pusch_dmrs_AdditionalPosition_t pusch_dmrs_AdditionalPosition;
   pusch_maxLength_t pusch_maxLength;
+  ptrs_UplinkConfig_t ptrs_UplinkConfig;
   uint16_t scramblingID0;
   uint16_t scramblingID1;
 } dmrs_UplinkConfig_t;
@@ -647,6 +640,10 @@ typedef struct {
  * resourceAllocation
  */
   ul_resourceAllocation_t ul_resourceAllocation;
+/*
+ * DMRS-Uplinkconfig
+ */
+  dmrs_UplinkConfig_t dmrs_UplinkConfig;
 /*
  * rgb_Size
  */
@@ -1112,6 +1109,7 @@ typedef struct {
   SchedulingRequestResourceConfig_t  *sr_ResourceConfig[MAX_NR_OF_SR_CONFIG_PER_CELL_GROUP];
 } scheduling_request_config_t;
 
+
 #undef EXTERN
 #undef INIT_VARIABLES_PHY_IMPLEMENTATION_DEFS_NR_H
 #endif /* PHY_IMPL_DEFS_NR_H */
diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h
index 88a02c45c7f..a4607d31067 100644
--- a/openair1/PHY/impl_defs_top.h
+++ b/openair1/PHY/impl_defs_top.h
@@ -149,10 +149,10 @@
 #define OFDM_SYMBOL_SIZE_BYTES0 (OFDM_SYMBOL_SIZE_SAMPLES0*2)
 #define OFDM_SYMBOL_SIZE_BYTES_NO_PREFIX (OFDM_SYMBOL_SIZE_SAMPLES_NO_PREFIX*2)
 
-#define SLOT_LENGTH_BYTES (frame_parms->samples_per_tti<<1) // 4 bytes * samples_per_tti/2
+#define SLOT_LENGTH_BYTES (frame_parms->samples_per_slot) // 4 bytes * samples_per_tti/2
 #define SLOT_LENGTH_BYTES_NO_PREFIX (OFDM_SYMBOL_SIZE_BYTES_NO_PREFIX * NUMBER_OF_OFDM_SYMBOLS_PER_SLOT)
 
-#define FRAME_LENGTH_COMPLEX_SAMPLES (frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)
+#define FRAME_LENGTH_COMPLEX_SAMPLES (frame_parms->samples_per_subframe*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)
 #define FRAME_LENGTH_SAMPLES (FRAME_LENGTH_COMPLEX_SAMPLES*2)
 #define FRAME_LENGTH_SAMPLES_NO_PREFIX (NUMBER_OF_SYMBOLS_PER_FRAME*OFDM_SYMBOL_SIZE_SAMPLES_NO_PREFIX)
 #define FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX (FRAME_LENGTH_SAMPLES_NO_PREFIX/2)
diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c
index 270ab5772cc..5c145a32302 100644
--- a/openair1/SCHED_NR/fapi_nr_l1.c
+++ b/openair1/SCHED_NR/fapi_nr_l1.c
@@ -34,28 +34,21 @@
 #include "PHY/NR_TRANSPORT/nr_dlsch.h"
 #include "PHY/NR_TRANSPORT/nr_dci.h"
 
-int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_config_request_t *dl_config_req);
-int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req);
 
 extern uint8_t nfapi_mode;
 
-void handle_nr_nfapi_bch_pdu(PHY_VARS_gNB *gNB,
-                             nfapi_nr_dl_config_request_pdu_t *dl_config_pdu,
-                             uint8_t *sdu)
+void handle_nr_nfapi_ssb_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
+                             nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu)
 {
 
-  AssertFatal(dl_config_pdu->bch_pdu_rel15.length == 3, "BCH PDU has length %d != 3\n",
-              dl_config_pdu->bch_pdu_rel15.length);
+  AssertFatal(dl_tti_pdu->ssb_pdu.ssb_pdu_rel15.bchPayloadFlag== 1, "bchPayloadFlat %d != 1\n",
+              dl_tti_pdu->ssb_pdu.ssb_pdu_rel15.bchPayloadFlag);
 
-  LOG_D(PHY,"pbch_pdu[0]: %x,pbch_pdu[1]: %x,gNB->pbch_pdu[2]: %x\n",sdu[0],sdu[1],sdu[2]);
-  gNB->pbch_pdu[0] = sdu[2];
-  gNB->pbch_pdu[1] = sdu[1];
-  gNB->pbch_pdu[2] = sdu[0];
-
-  // adjust transmit amplitude here based on NFAPI info
+  LOG_I(PHY,"%d.%d : pbch_pdu: %x\n",frame,slot,dl_tti_pdu->ssb_pdu.ssb_pdu_rel15.bchPayload);
+  memcpy((void*)&gNB->ssb_pdu,&dl_tti_pdu->ssb_pdu,sizeof(dl_tti_pdu->ssb_pdu));
 }
 
-/*void handle_nr_nfapi_dlsch_pdu(PHY_VARS_gNB *gNB,int frame,int subframe,gNB_L1_rxtx_proc_t *proc,
+/*void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int subframe,gNB_L1_rxtx_proc_t *proc,
                             uint8_t codeword_index,
                             uint8_t *sdu)
 {
@@ -85,7 +78,7 @@ void handle_nr_nfapi_bch_pdu(PHY_VARS_gNB *gNB,
     //AssertFatal(sdu!=NULL,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n",
     //            frame,subframe,
     //            proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid,
-    //            dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index,dlsch0_harq->round,dlsch0_harq->frame,dlsch0_harq->subframe,dlsch0_harq->pdu,dlsch0_harq->mcs,dlsch0_harq->ndi,dlsch0_harq->pdsch_start);
+    //            dl_tti_pdu->pdsch_pdu.pdsch_pdu_rel8.pdu_index,dlsch0_harq->round,dlsch0_harq->frame,dlsch0_harq->subframe,dlsch0_harq->pdu,dlsch0_harq->mcs,dlsch0_harq->ndi,dlsch0_harq->pdsch_start);
     if (codeword_index == 0) dlsch0_harq->pdu                    = sdu;
     else                     dlsch1_harq->pdu                    = sdu;
     LOG_I(PHY, "SFN/SF: %d/%d DLSCH PDU filled \n",frame, subframe);
@@ -94,29 +87,43 @@ void handle_nr_nfapi_bch_pdu(PHY_VARS_gNB *gNB,
 }*/
 
 
-void handle_nfapi_nr_dci_dl_pdu(PHY_VARS_gNB *gNB,
-                                int frame, int slot,
-                                nfapi_nr_dl_config_dci_dl_pdu *dci_dl_pdu) {
-  int idx                        = slot&1;
-  NR_gNB_PDCCH *pdcch_vars       = &gNB->pdcch_vars;
+void handle_nfapi_nr_pdcch_pdu(PHY_VARS_gNB *gNB,
+			       int frame, int slot,
+			       nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu) {
 
-  LOG_D(PHY,"Frame %d, Slot %d: DCI processing - populating pdcch_vars->dci_alloc[%d] proc:slot_tx:%d idx:%d pdcch_vars->num_dci:%d\n",frame,slot, pdcch_vars->num_dci, slot, idx, pdcch_vars->num_dci);
+  LOG_D(PHY,"Frame %d, Slot %d: DCI processing - proc:slot_tx:%d pdcch_pdu_rel15->numDlDci:%d\n",frame,slot, slot, pdcch_pdu->pdcch_pdu_rel15.numDlDci);
 
   // copy dci configuration into gNB structure
-  nr_fill_dci(gNB,frame,slot,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],dci_dl_pdu);
+  gNB->pdcch_pdu = pdcch_pdu;
+
+  nr_fill_dci(gNB,frame,slot);
+
 
 
-  LOG_D(PHY,"Frame %d, Slot %d: DCI processing - populated pdcch_vars->dci_alloc[%d] proc:slot_tx:%d idx:%d pdcch_vars->num_dci:%d\n",frame,slot, pdcch_vars->num_dci, slot, idx, pdcch_vars->num_dci);
 }
 
+void handle_nfapi_nr_ul_dci_pdu(PHY_VARS_gNB *gNB,
+			       int frame, int slot,
+			       nfapi_nr_ul_dci_request_pdus_t *ul_dci_request_pdu) {
+
+  LOG_D(PHY,"Frame %d, Slot %d: UL DCI processing - proc:slot_tx:%d pdcch_pdu_rel15->numDlDci:%d\n",frame,slot, slot, ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15.numDlDci);
+
+  // copy dci configuration into gNB structure
+  gNB->ul_dci_pdu = ul_dci_request_pdu;
+
+  nr_fill_ul_dci(gNB,frame,slot);
+
+
 
-void handle_nr_nfapi_dlsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
-                            nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu,
+}
+
+void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
+                            nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
                             uint8_t *sdu)
 {
 
 
-  nr_fill_dlsch(gNB,frame,slot,dlsch_pdu,sdu);
+  nr_fill_dlsch(gNB,frame,slot,pdsch_pdu,sdu);
 
 }
 
@@ -125,99 +132,75 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){
   PHY_VARS_gNB *gNB;
   // copy data from L2 interface into L1 structures
   module_id_t                   Mod_id       = Sched_INFO->module_id;
-  uint8_t                       CC_id        = Sched_INFO->CC_id;
-  nfapi_nr_dl_config_request_t  *DL_req      = Sched_INFO->DL_req;
-  nfapi_tx_request_t            *TX_req      = Sched_INFO->TX_req;
+  nfapi_nr_dl_tti_request_t     *DL_req      = Sched_INFO->DL_req;
+  nfapi_nr_tx_data_request_t    *TX_req      = Sched_INFO->TX_req;
   nfapi_nr_ul_tti_request_t     *UL_tti_req  = Sched_INFO->UL_tti_req;
+  nfapi_nr_ul_dci_request_t     *UL_dci_req  = Sched_INFO->UL_dci_req;
   frame_t                       frame        = Sched_INFO->frame;
   sub_frame_t                   slot         = Sched_INFO->slot;
 
   AssertFatal(RC.gNB!=NULL,"RC.gNB is null\n");
   AssertFatal(RC.gNB[Mod_id]!=NULL,"RC.gNB[%d] is null\n",Mod_id);
-  AssertFatal(RC.gNB[Mod_id][CC_id]!=NULL,"RC.gNB[%d][%d] is null\n",Mod_id,CC_id);
 
-  gNB         = RC.gNB[Mod_id][CC_id];
+  gNB         = RC.gNB[Mod_id];
 
-  uint8_t number_dl_pdu             = DL_req->dl_config_request_body.number_pdu;
-  //uint8_t number_ul_pdu             = UL_tti_req->n_pdus;
+  uint8_t number_dl_pdu             = DL_req->dl_tti_request_body.nPDUs;
+  //  uint8_t number_ul_pdu             = 0;
+  uint8_t number_ul_dci_pdu         = (UL_dci_req==NULL) ? 0 : UL_dci_req->numPdus;
 
-  nfapi_nr_dl_config_request_pdu_t *dl_config_pdu;
- 
-  int i;
+  //  if (UL_tti_req != NULL) number_ul_pdu = UL_tti_req->n_pdus;
 
-  LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SF:%04d%d DL_req:SFN/SF:%04d%d:dl_pdu:%d tx_req:SFN/SF:%04d%d:pdus:%d \n",
+  LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SLOT:%04d%d DL_req:SFN/SLO:%04d%d:dl_pdu:%d tx_req:SFN/SLOT:%04d%d:pdus:%d;\n",
         frame,slot,
-        NFAPI_SFNSF2SFN(DL_req->sfn_sf),NFAPI_SFNSF2SF(DL_req->sfn_sf),number_dl_pdu,
-        NFAPI_SFNSF2SFN(TX_req->sfn_sf),NFAPI_SFNSF2SF(TX_req->sfn_sf),TX_req->tx_request_body.number_of_pdus);
-
-  int do_oai =0;
-  int dont_send =0;
-  gNB->pdcch_vars.num_dci = 0;
-  gNB->pdcch_vars.num_pdsch_rnti = 0;
-
-  gNB->pdcch_vars.num_dci=0;
-
-  for (i=0;i<number_dl_pdu;i++) {
-    dl_config_pdu = &DL_req->dl_config_request_body.dl_config_pdu_list[i];
-    LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_config_pdu->pdu_type);
-    switch (dl_config_pdu->pdu_type) {
-      case NFAPI_NR_DL_CONFIG_BCH_PDU_TYPE:
-        AssertFatal(dl_config_pdu->bch_pdu_rel15.pdu_index < TX_req->tx_request_body.number_of_pdus,
-                    "bch_pdu_rel8.pdu_index>=TX_req->number_of_pdus (%d>%d)\n",
-                    dl_config_pdu->bch_pdu_rel15.pdu_index,
-                    TX_req->tx_request_body.number_of_pdus);
-        gNB->pbch_configured=1;
-        do_oai=1;
-
-        handle_nr_nfapi_bch_pdu(gNB,
-                                dl_config_pdu,
-                                TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->bch_pdu_rel15.pdu_index].segments[0].segment_data);
+        DL_req->SFN,DL_req->Slot,number_dl_pdu,
+        TX_req->SFN,TX_req->Slot,TX_req->Number_of_PDUs);
+
+  int pdcch_received=0;
+  gNB->num_pdsch_rnti=0;
+  gNB->pdcch_pdu = NULL;
+  gNB->pbch_configured=0;
+
+  for (int i=0;i<number_dl_pdu;i++) {
+    nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdu = &DL_req->dl_tti_request_body.dl_tti_pdu_list[i];
+    LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_tti_pdu->PDUType);
+    switch (dl_tti_pdu->PDUType) {
+      case NFAPI_NR_DL_TTI_SSB_PDU_TYPE:
+	gNB->pbch_configured=1;
+
+        handle_nr_nfapi_ssb_pdu(gNB,frame,slot,
+                                dl_tti_pdu);
+
       break;
 
-      case NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE:
-        handle_nfapi_nr_dci_dl_pdu(gNB,
-                                   frame, slot,
-                                   &dl_config_pdu->dci_dl_pdu);
-        gNB->pdcch_vars.num_dci++;
-        gNB->pdcch_vars.num_pdsch_rnti++;
-        do_oai=1;
+      case NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE:
+	AssertFatal(pdcch_received == 0, "pdcch_received is not 0, we can only handle one PDCCH PDU per slot\n");
+        handle_nfapi_nr_pdcch_pdu(gNB,
+				  frame, slot,
+				  &dl_tti_pdu->pdcch_pdu);
+ 
+	pdcch_received = 1;
+
       break;
-      case NFAPI_NR_DL_CONFIG_DLSCH_PDU_TYPE:
+      case NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE:
 
       {
-        nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu_rel15 = &dl_config_pdu->dlsch_pdu.dlsch_pdu_rel15;
-        uint16_t pdu_index = dlsch_pdu_rel15->pdu_index;
-        uint16_t tx_pdus = TX_req->tx_request_body.number_of_pdus;
-        uint16_t invalid_pdu = pdu_index == -1;
-        uint8_t *sdu = invalid_pdu ? NULL : pdu_index >= tx_pdus ? NULL : TX_req->tx_request_body.tx_pdu_list[pdu_index].segments[0].segment_data;
-
-        AssertFatal(sdu!=NULL,"sdu is null, pdu_index %d, tx_pdus %d\n",pdu_index,tx_pdus);
-        handle_nr_nfapi_dlsch_pdu(gNB,frame,slot,&dl_config_pdu->dlsch_pdu, sdu);
-        do_oai=1;
+        nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdu->pdsch_pdu.pdsch_pdu_rel15;
+        uint16_t pduIndex = pdsch_pdu_rel15->pduIndex;
+	AssertFatal(TX_req->pdu_list[pduIndex].num_TLV == 1, "TX_req->pdu_list[%d].num_TLV %d != 1\n",
+		    pduIndex,TX_req->pdu_list[pduIndex].num_TLV);
+        uint8_t *sdu = (uint8_t *)TX_req->pdu_list[pduIndex].TLVs[0].value.direct;
+        handle_nr_nfapi_pdsch_pdu(gNB,frame,slot,&dl_tti_pdu->pdsch_pdu, sdu);
       }
     }
   }
 
-  memcpy(&gNB->UL_tti_req,UL_tti_req,sizeof(nfapi_nr_ul_tti_request_t));
+  if (UL_tti_req!=NULL) memcpy(&gNB->UL_tti_req,UL_tti_req,sizeof(nfapi_nr_ul_tti_request_t));
   
-  /*
-  // this is done in phy_procedures_gNB_uespec_RX now
-  for (i=0;i<number_ul_pdu;i++) {
-    LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,UL_tti_req->pdus_list[i].pdu_type);
-    switch (UL_tti_req->pdus_list[i].pdu_type) {
-    case NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE:
-      {
-        nfapi_nr_pusch_pdu_t  *pusch_pdu = &UL_tti_req->pdus_list[0].pusch_pdu;
-	nr_fill_ulsch(gNB,frame,slot,pusch_pdu);
-      }
-    }
+  for (int i=0;i<number_ul_dci_pdu;i++) {
+    handle_nfapi_nr_ul_dci_pdu(gNB,
+			      frame, slot,
+			      &UL_dci_req->ul_dci_pdu_list[i]);
   }
-  */
-  
-  if (nfapi_mode && do_oai && !dont_send) {
-    oai_nfapi_tx_req(Sched_INFO->TX_req);
 
-    oai_nfapi_nr_dl_config_req(Sched_INFO->DL_req); // DJP - .dl_config_request_body.dl_config_pdu_list[0]); // DJP - FIXME TODO - yuk - only copes with 1 pdu
-  }
 
 }
diff --git a/openair1/SCHED_NR/fapi_nr_l1.h b/openair1/SCHED_NR/fapi_nr_l1.h
index 60d9e55b1f1..07509b3bb7b 100644
--- a/openair1/SCHED_NR/fapi_nr_l1.h
+++ b/openair1/SCHED_NR/fapi_nr_l1.h
@@ -34,15 +34,16 @@
 #include "PHY/phy_extern.h"
 #include "SCHED_NR/sched_nr.h"
 #include "nfapi_nr_interface.h"
+#include "nfapi_nr_interface_scf.h"
 
 void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO);
 
-void handle_nfapi_nr_dci_dl_pdu(PHY_VARS_gNB *gNB,
-                                int frame, int subframe,
-                                nfapi_nr_dl_config_dci_dl_pdu *dcl_dl_pdu);
+void handle_nfapi_nr_pdcch_pdu(PHY_VARS_gNB *gNB,
+			       int frame, int subframe,
+			       nfapi_nr_dl_tti_pdcch_pdu *dcl_dl_pdu);
 
-void handle_nr_nfapi_dlsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
-                            nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu,
+void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
+			       nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
                             uint8_t *sdu);
 
 void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id, uint8_t harq_pid);
diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c
index 70f6630aa7c..aefeec43e2d 100644
--- a/openair1/SCHED_NR/nr_ru_procedures.c
+++ b/openair1/SCHED_NR/nr_ru_procedures.c
@@ -66,167 +66,197 @@ void nr_feptx0(RU_t *ru,int tti_tx,int first_symbol, int num_symbols, int aa) {
 
   //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM+(first_symbol!=0?1:0) , 1 );
 
-  slot_offset  = slot*fp->samples_per_slot;
+  slot_offset  = fp->get_samples_slot_timestamp(slot,fp,0);
   slot_offsetF = first_symbol*fp->ofdm_symbol_size;
 
+  int abs_first_symbol = slot*fp->symbols_per_slot;
 
-  if (first_symbol>0) slot_offset += (fp->ofdm_symbol_size*first_symbol) + (fp->nb_prefix_samples0) + (fp->nb_prefix_samples*(first_symbol-1));
+  for (uint16_t idx_sym=abs_first_symbol; idx_sym<abs_first_symbol+first_symbol; idx_sym++)
+    slot_offset += (idx_sym%(0x7<<fp->numerology_index)) ? fp->nb_prefix_samples : fp->nb_prefix_samples0;
 
-  LOG_D(PHY,"SFN/SF:RU:TX:%d/%d Generating slot %d (first_symbol %d num_symbols %d)\n",ru->proc.frame_tx, ru->proc.tti_tx,slot,first_symbol,num_symbols);
+  slot_offset += fp->ofdm_symbol_size*first_symbol;
 
-  if (fp->Ncp == 1) {
+  LOG_D(PHY,"SFN/SF:RU:TX:%d/%d Generating slot %d (first_symbol %d num_symbols %d)\n",ru->proc.frame_tx, ru->proc.tti_tx,slot,first_symbol,num_symbols);
+  
+  if (fp->Ncp == 1)
     PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_offsetF],
                  (int*)&ru->common.txdata[aa][slot_offset],
                  fp->ofdm_symbol_size,
                  num_symbols,
                  fp->nb_prefix_samples,
                  CYCLIC_PREFIX);
-  }
   else {
-    if (first_symbol==0) {
-      PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_offsetF],
-                   (int*)&ru->common.txdata[aa][slot_offset],
-                   fp->ofdm_symbol_size,
-                   1,
-                   fp->nb_prefix_samples0,
-                   CYCLIC_PREFIX);
-      PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_offsetF+fp->ofdm_symbol_size],
-                   (int*)&ru->common.txdata[aa][slot_offset+fp->nb_prefix_samples0+fp->ofdm_symbol_size],
-                   fp->ofdm_symbol_size,
-                   num_symbols-1,
-                   fp->nb_prefix_samples,
-                   CYCLIC_PREFIX);
+    if (fp->numerology_index != 0) {
+
+      if (!(slot%(fp->slots_per_subframe/2))&&(first_symbol==0)) {
+        PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_offsetF],
+                     (int*)&ru->common.txdata[aa][slot_offset],
+                     fp->ofdm_symbol_size,
+                     1,
+                     fp->nb_prefix_samples0,
+                     CYCLIC_PREFIX);
+        PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_offsetF+fp->ofdm_symbol_size],
+                     (int*)&ru->common.txdata[aa][slot_offset+fp->nb_prefix_samples0+fp->ofdm_symbol_size],
+                     fp->ofdm_symbol_size,
+                     num_symbols-1,
+                     fp->nb_prefix_samples,
+                     CYCLIC_PREFIX);
+      }
+      else {
+        PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_offsetF],
+                     (int*)&ru->common.txdata[aa][slot_offset],
+                     fp->ofdm_symbol_size,
+                     num_symbols,
+                     fp->nb_prefix_samples,
+                     CYCLIC_PREFIX);
+      }
     }
+
     else {
-      PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_offsetF],
-                   (int*)&ru->common.txdata[aa][slot_offset],
-                   fp->ofdm_symbol_size,
-                   num_symbols,
-                   fp->nb_prefix_samples,
-                   CYCLIC_PREFIX);
+      for (uint16_t idx_sym=abs_first_symbol; idx_sym<abs_first_symbol+num_symbols; idx_sym++) {
+        if (idx_sym%0x7) {
+          PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_offsetF],
+                       (int*)&ru->common.txdata[aa][slot_offset],
+                       fp->ofdm_symbol_size,
+                       1,
+                       fp->nb_prefix_samples,
+                       CYCLIC_PREFIX);
+          slot_offset += fp->nb_prefix_samples+fp->ofdm_symbol_size;
+        }
+        else {
+          PHY_ofdm_mod(&ru->common.txdataF_BF[aa][slot_offsetF],
+                       (int*)&ru->common.txdata[aa][slot_offset],
+                       fp->ofdm_symbol_size,
+                       1,
+                       fp->nb_prefix_samples0,
+                       CYCLIC_PREFIX);
+          slot_offset += fp->nb_prefix_samples0+fp->ofdm_symbol_size;
+        }
+      }
     }
   }
+
+        
   //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM+(first_symbol!=0?1:0), 0);
 }
 
 void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx) {
 
-  nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config;
+  nfapi_nr_config_request_scf_t *cfg = &ru->gNB_list[0]->gNB_config;
   RU_proc_t  *proc  = &ru->proc;
   RU_feptx_t *feptx = proc->feptx;
 
   PHY_VARS_gNB *gNB;
   NR_DL_FRAME_PARMS *fp   = ru->nr_frame_parms;
-
+  
   int slot = tti_tx;
+
   int i    = 0;
   int j    = 0;//symbol
-  int aa   = 0;//logical antenna number
+  int aa   = 0;//physical antenna number
   int ret  = 0;
-  int nb_antenna_ports = fp->L_ssb;
   int ofdm_mask_full   = (1<<(ru->nb_tx*2))-1;
   int txdataF_offset   = ((tti_tx%2)*fp->samples_per_slot_wCP);
 
-  if (nr_slot_select(cfg,slot,frame_tx) == SF_UL) return;
-  for (aa=0; aa<fp->Lmax; aa++) {
-    memset(ru->common.txdataF[aa],0,fp->samples_per_slot_wCP*sizeof(int32_t));
-  }
+  if (nr_slot_select(cfg,frame_tx,slot) == NR_UPLINK_SLOT) return;
+  for (aa=0; aa<ru->nb_tx; aa++) memset(ru->common.txdataF[aa],0,fp->samples_per_slot_wCP*sizeof(int32_t));
 
   start_meas(&ru->ofdm_total_stats);
-  if(ru->num_gNB != 0){//L1 RU on same machine
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 1 );
-    for(j=0; j<2; ++j){//half slot 
-      for(i=0; i<ru->nb_tx; ++i){
-        if(j == 0){
-          AssertFatal((ret=pthread_mutex_lock(&feptx[i].mutex_feptx))==0,"mutex_lock return %d\n",ret);
-          feptx[i].aa                      = i;
-          feptx[i].index                   = i;
-          feptx[i].ru                      = ru;
-          feptx[i].symbol                  = 0;
-          feptx[i].slot                    = slot;
-          feptx[i].nb_antenna_ports        = nb_antenna_ports;
-          feptx[i].instance_cnt_feptx      = 0;
-          AssertFatal(pthread_cond_signal(&feptx[i].cond_feptx) == 0,"ERROR pthread_cond_signal for feptx_ofdm_thread\n");
-          AssertFatal((ret=pthread_mutex_unlock(&feptx[i].mutex_feptx))==0,"mutex_lock returns %d\n",ret);
-        }//first half
-        else{
-          AssertFatal((ret=pthread_mutex_lock(&feptx[i+ru->nb_tx].mutex_feptx))==0,"mutex_lock return %d\n",ret);
-          feptx[i+ru->nb_tx].aa                      = i;
-          feptx[i+ru->nb_tx].index                   = i+ru->nb_tx;
-          feptx[i+ru->nb_tx].ru                      = ru;
-          feptx[i+ru->nb_tx].symbol                  = fp->symbols_per_slot>>1;
-          feptx[i+ru->nb_tx].slot                    = slot;
-          feptx[i+ru->nb_tx].nb_antenna_ports        = nb_antenna_ports;
-          feptx[i+ru->nb_tx].instance_cnt_feptx      = 0;
-          AssertFatal(pthread_cond_signal(&feptx[i+ru->nb_tx].cond_feptx) == 0,"ERROR pthread_cond_signal for feptx_ofdm_thread\n");
-          AssertFatal((ret=pthread_mutex_unlock(&feptx[i+ru->nb_tx].mutex_feptx))==0,"mutex_lock returns %d\n",ret);
-        }//second half
-      }//physical antenna
-    }//half slot
-  }//if L1 RU on same machine
-  else{//(RU only machine)
-    for(j=0; j<fp->symbols_per_slot; ++j){
-
-      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC+j , 1);
-      start_meas(&ru->txdataF_copy_stats);
-      if (ru->num_gNB == 1){
-        gNB = ru->gNB_list[0];
-        cfg = &gNB->gNB_config;
-
-        for(i=0; i<nb_antenna_ports; ++i){
-          memcpy((void*)&ru->common.txdataF[i][j*fp->ofdm_symbol_size],
-           (void*)&gNB->common_vars.txdataF[i][j*fp->ofdm_symbol_size + txdataF_offset],
-           fp->ofdm_symbol_size*sizeof(int32_t));
-        }
-
-      }//num_gNB == 1
-      stop_meas(&ru->txdataF_copy_stats);
-      VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC+j , 0);
 
+  //if (nr_slot_select(cfg,frame_tx,slot)==NR_DOWNLINK_SLOT) {
+    if(ru->num_gNB != 0){//L1 RU on same machine
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 1 );
-
-      if (nr_slot_select(cfg,slot,frame_tx)==SF_DL) {
-        // If this is not an S-tti
+      for(j=0; j<2; ++j){//half slot 
         for(i=0; i<ru->nb_tx; ++i){
-          if(j%2 == 0){
-            while(feptx[i].instance_cnt_feptx != -1){
-              usleep(5);
-            }
+          if(j == 0){
             AssertFatal((ret=pthread_mutex_lock(&feptx[i].mutex_feptx))==0,"mutex_lock return %d\n",ret);
             feptx[i].aa                      = i;
             feptx[i].index                   = i;
             feptx[i].ru                      = ru;
-            feptx[i].symbol                  = j;
+            feptx[i].symbol                  = 0;
             feptx[i].slot                    = slot;
-            feptx[i].nb_antenna_ports        = nb_antenna_ports;
+            feptx[i].nb_antenna_ports        = ru->nb_tx;
             feptx[i].instance_cnt_feptx      = 0;
             AssertFatal(pthread_cond_signal(&feptx[i].cond_feptx) == 0,"ERROR pthread_cond_signal for feptx_ofdm_thread\n");
             AssertFatal((ret=pthread_mutex_unlock(&feptx[i].mutex_feptx))==0,"mutex_lock returns %d\n",ret);
-          }
+          }//first half
           else{
-            while(feptx[i+ru->nb_tx].instance_cnt_feptx != -1){
-              usleep(5);
-            }
             AssertFatal((ret=pthread_mutex_lock(&feptx[i+ru->nb_tx].mutex_feptx))==0,"mutex_lock return %d\n",ret);
             feptx[i+ru->nb_tx].aa                      = i;
             feptx[i+ru->nb_tx].index                   = i+ru->nb_tx;
             feptx[i+ru->nb_tx].ru                      = ru;
-            feptx[i+ru->nb_tx].symbol                  = j;
+            feptx[i+ru->nb_tx].symbol                  = fp->symbols_per_slot>>1;
             feptx[i+ru->nb_tx].slot                    = slot;
-            feptx[i+ru->nb_tx].nb_antenna_ports        = nb_antenna_ports;
+            feptx[i+ru->nb_tx].nb_antenna_ports        = ru->nb_tx;
             feptx[i+ru->nb_tx].instance_cnt_feptx      = 0;
             AssertFatal(pthread_cond_signal(&feptx[i+ru->nb_tx].cond_feptx) == 0,"ERROR pthread_cond_signal for feptx_ofdm_thread\n");
             AssertFatal((ret=pthread_mutex_unlock(&feptx[i+ru->nb_tx].mutex_feptx))==0,"mutex_lock returns %d\n",ret);
+          }//second half
+        }//physical antenna
+      }//half slot
+    }//if L1 RU on same machine
+    else{//(RU only machine)
+      for(j=0; j<fp->symbols_per_slot; ++j){
+
+        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC+j , 1);
+        start_meas(&ru->txdataF_copy_stats);
+        if (ru->num_gNB == 1){
+          gNB = ru->gNB_list[0];
+          cfg = &gNB->gNB_config;
+
+          for(i=0; i<ru->nb_tx; ++i){
+            memcpy((void*)&ru->common.txdataF[i][j*fp->ofdm_symbol_size],
+                   (void*)&gNB->common_vars.txdataF[i][j*fp->ofdm_symbol_size + txdataF_offset],
+                   fp->ofdm_symbol_size*sizeof(int32_t));
           }
-        }
-       
-      }//if == SF_DL
-      else {
-        proc->feptx_mask = ofdm_mask_full;
-      }
-    }//j<fp->symbols_per_slot
-  }//else (RU only machine)
 
+        }//num_gNB == 1
+        stop_meas(&ru->txdataF_copy_stats);
+        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC+j , 0);
+
+        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 1 );
+
+        if (nr_slot_select(cfg,slot,frame_tx)==SF_DL) {
+          // If this is not an S-tti
+          for(i=0; i<ru->nb_tx; ++i){
+            if(j%2 == 0){
+              while(feptx[i].instance_cnt_feptx != -1){
+                usleep(5);
+              }
+              AssertFatal((ret=pthread_mutex_lock(&feptx[i].mutex_feptx))==0,"mutex_lock return %d\n",ret);
+              feptx[i].aa                      = i;
+              feptx[i].index                   = i;
+              feptx[i].ru                      = ru;
+              feptx[i].symbol                  = j;
+              feptx[i].slot                    = slot;
+              feptx[i].nb_antenna_ports        = ru->nb_tx;
+              feptx[i].instance_cnt_feptx      = 0;
+              AssertFatal(pthread_cond_signal(&feptx[i].cond_feptx) == 0,"ERROR pthread_cond_signal for feptx_ofdm_thread\n");
+              AssertFatal((ret=pthread_mutex_unlock(&feptx[i].mutex_feptx))==0,"mutex_lock returns %d\n",ret);
+            }
+            else{
+              while(feptx[i+ru->nb_tx].instance_cnt_feptx != -1){
+                usleep(5);
+              }
+              AssertFatal((ret=pthread_mutex_lock(&feptx[i+ru->nb_tx].mutex_feptx))==0,"mutex_lock return %d\n",ret);
+              feptx[i+ru->nb_tx].aa                      = i;
+              feptx[i+ru->nb_tx].index                   = i+ru->nb_tx;
+              feptx[i+ru->nb_tx].ru                      = ru;
+              feptx[i+ru->nb_tx].symbol                  = j;
+              feptx[i+ru->nb_tx].slot                    = slot;
+              feptx[i+ru->nb_tx].nb_antenna_ports        = ru->nb_tx;
+              feptx[i+ru->nb_tx].instance_cnt_feptx      = 0;
+              AssertFatal(pthread_cond_signal(&feptx[i+ru->nb_tx].cond_feptx) == 0,"ERROR pthread_cond_signal for feptx_ofdm_thread\n");
+              AssertFatal((ret=pthread_mutex_unlock(&feptx[i+ru->nb_tx].mutex_feptx))==0,"mutex_lock returns %d\n",ret);
+            }
+          }
+        }//if == SF_DL
+        else {
+          proc->feptx_mask = ofdm_mask_full;
+        }
+      }//j<fp->symbols_per_slot
+    }//else (RU only machine)
+  //}
   // wait all process to finish
   AssertFatal((ret=pthread_mutex_lock(&proc->mutex_feptx))==0,"mutex_lock return %d\n",ret);
   while (proc->feptx_mask != ofdm_mask_full) {
@@ -256,14 +286,13 @@ static void *nr_feptx_thread(void *param) {
   int ofdm_mask_full;
   int txdataF_offset;
   int32_t *txdataF;
-
-
   while (!oai_exit) {
-
     ret = 0;
     if (wait_on_condition(&feptx->mutex_feptx,&feptx->cond_feptx,&feptx->instance_cnt_feptx,"NR feptx thread")<0) break;
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM+feptx->index+1 , 1 );
 
+    AssertFatal(feptx->ru->nb_log_antennas>0 && feptx->ru->nb_log_antennas < 13,"ru->nb_log_antennas is %d\n", feptx->ru->nb_log_antennas);
+
     ru    = feptx->ru;
     slot  = feptx->slot;
     aa    = feptx->aa;
@@ -278,15 +307,10 @@ static void *nr_feptx_thread(void *param) {
       ////////////precoding////////////
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC+feptx->index+1 , 1);
       start_meas(&ru->precoding_stats);
-      if (ru->nb_tx == 1) {
-        AssertFatal(fp->N_ssb==ru->nb_tx,"Attempting to transmit %d SSB while Nb_tx = %d",fp->N_ssb,ru->nb_tx);
-        for (int p=0; p<fp->Lmax; p++) {
-          if ((fp->L_ssb >> p) & 0x01){
+      if (ru->nb_tx == 1 && ru->nb_log_antennas == 1) {
             memcpy((void*)&ru->common.txdataF_BF[0][l*fp->ofdm_symbol_size],
-                 (void*)&ru->gNB_list[0]->common_vars.txdataF[p][txdataF_offset + l*fp->ofdm_symbol_size],
+                 (void*)&ru->gNB_list[0]->common_vars.txdataF[0][txdataF_offset + l*fp->ofdm_symbol_size],
                  (fp->samples_per_slot_wCP>>1)*sizeof(int32_t));
-          }
-        }
       }
       else {
         bw  = ru->beam_weights[0];
@@ -324,15 +348,10 @@ static void *nr_feptx_thread(void *param) {
     else{
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC+feptx->index+1 , 1);
       start_meas(&ru->precoding_stats);
-      if (ru->nb_tx == 1) {
-        AssertFatal(fp->N_ssb==ru->nb_tx,"Attempting to transmit %d SSB while Nb_tx = %d",fp->N_ssb,ru->nb_tx);
-        for (int p=0; p<fp->Lmax; p++) {
-          if ((fp->L_ssb >> p) & 0x01){
+      if (ru->nb_tx == 1 && ru->nb_log_antennas) {
             memcpy((void*)&ru->common.txdataF_BF[0][l*fp->ofdm_symbol_size],
-                 (void*)&ru->common.txdataF[p][l*fp->ofdm_symbol_size],
+                 (void*)&ru->common.txdataF[0][l*fp->ofdm_symbol_size],
                  fp->ofdm_symbol_size*sizeof(int32_t));
-          }
-        }
       }
       else {
         bw  = ru->beam_weights[0];
@@ -374,30 +393,32 @@ static void *nr_feptx_thread(void *param) {
 // seems to be hardcoded to numerology 1 (2 slots=1 subframe)
 void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx) {
      
+  nfapi_nr_config_request_scf_t *cfg = &ru->gNB_list[0]->gNB_config;
   NR_DL_FRAME_PARMS *fp=ru->nr_frame_parms;
-  nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config;
+  int cyclic_prefix_type = NFAPI_CP_NORMAL;
 
   unsigned int aa=0;
   int slot_sizeF = (fp->ofdm_symbol_size)*
-                   ((cfg->subframe_config.dl_cyclic_prefix_type.value == 1) ? 12 : 14);
+                   ((cyclic_prefix_type == 1) ? 12 : 14);
   int slot = tti_tx;
-  int *txdata = &ru->common.txdata[aa][slot*fp->samples_per_slot];
+  int *txdata = &ru->common.txdata[aa][fp->get_samples_slot_timestamp(slot,fp,0)];
 
-  if (nr_slot_select(cfg,slot, frame_tx) == SF_UL) return;
+  if (nr_slot_select(cfg,frame_tx,slot) == NR_UPLINK_SLOT) return;
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 1 );
   start_meas(&ru->ofdm_mod_stats);
 
+
     //    LOG_D(HW,"Frame %d: Generating slot %d\n",frame,next_slot);
 
-    nr_feptx0(ru,slot,0,fp->symbols_per_slot,aa);
+  nr_feptx0(ru,slot,0,NR_NUMBER_OF_SYMBOLS_PER_SLOT,aa);
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 0 );
   stop_meas(&ru->ofdm_mod_stats);
 
   LOG_D(PHY,"feptx_ofdm (TXPATH): frame %d, slot %d: txp (time %p) %d dB, txp (freq) %d dB\n",
-	frame_tx,slot,txdata,dB_fixed(signal_energy((int32_t*)txdata,fp->samples_per_slot)),
-	dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF)));
+	frame_tx,slot,txdata,dB_fixed(signal_energy((int32_t*)txdata,fp->get_samples_per_slot(
+  slot,fp))),dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF)));
 
 }
 
@@ -420,39 +441,36 @@ void nr_init_feptx_thread(RU_t *ru) {
 }
 
 
-void nr_feptx_prec(RU_t *ru,int frame,int tti_tx) {
+void nr_feptx_prec(RU_t *ru,int frame_tx,int tti_tx) {
 
   int l,aa;
   PHY_VARS_gNB **gNB_list = ru->gNB_list,*gNB;
   NR_DL_FRAME_PARMS *fp   = ru->nr_frame_parms;
-  nfapi_nr_config_request_t *cfg;
+  nfapi_nr_config_request_scf_t *cfg = &ru->gNB_list[0]->gNB_config;
   int32_t ***bw;
   int i=0;
+  int slot_tx = tti_tx;
+  int txdataF_offset   = ((tti_tx%2)*fp->samples_per_slot_wCP);
 
   start_meas(&ru->precoding_stats);
+  AssertFatal(ru->nb_log_antennas > 0,"ru->nb_log_antennas is 0!\n");
   if (ru->num_gNB == 1){
     gNB = gNB_list[0];
-    cfg = &gNB->gNB_config;
-    if (nr_slot_select(cfg,tti_tx,frame) == SF_UL) return;
 
-    for(i=0; i<fp->Lmax; ++i)
+    if (nr_slot_select(cfg,frame_tx,slot_tx) == NR_UPLINK_SLOT) return;
+
+    for(i=0; i<ru->nb_log_antennas; ++i)
       memcpy((void*)ru->common.txdataF[i],
-           (void*)gNB->common_vars.txdataF[i],
+           (void*)&gNB->common_vars.txdataF[i][txdataF_offset],
            fp->samples_per_slot_wCP*sizeof(int32_t));
 
-    if (ru->nb_tx == 1) {
+    if (ru->nb_tx == 1 && ru->nb_log_antennas == 1) {
     
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC , 1);
 
-      AssertFatal(fp->N_ssb==ru->nb_tx,"Attempting to transmit %d SSB while Nb_tx = %d",fp->N_ssb,ru->nb_tx);
-
-      for (int p=0; p<fp->Lmax; p++) {
-        if ((fp->L_ssb >> p) & 0x01){
-          memcpy((void*)ru->common.txdataF_BF[0],
-                 (void*)ru->common.txdataF[p],
-                 fp->samples_per_slot_wCP*sizeof(int32_t));
-        }
-      }
+      memcpy((void*)ru->common.txdataF_BF[0],
+             (void*)ru->common.txdataF[0],
+             fp->samples_per_slot_wCP*sizeof(int32_t));
 
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC , 0);
     }// if (ru->nb_tx == 1)
@@ -467,7 +485,7 @@ void nr_feptx_prec(RU_t *ru,int frame,int tti_tx) {
                             tti_tx,
                             l,
                             aa,
-                            fp->Lmax);
+                            ru->nb_log_antennas);
         }// for (aa=0;aa<ru->nb_tx;aa++)
       }// for (l=0;l<fp->symbols_per_slot;l++)
     }// if (ru->nb_tx == 1)
@@ -563,7 +581,7 @@ void nr_fep_full_2thread(RU_t *ru, int slot) {
   // NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms;
 
   // if ((fp->frame_type == TDD) &&
-     // (subframe_select(fp,proc->tti_rx) != SF_UL)) return;
+     // (subframe_select(fp,proc->tti_rx) != NR_UPLINK_SLOT)) return;
 
   if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 );
 
@@ -622,7 +640,7 @@ void nr_fep_full(RU_t *ru, int slot) {
   NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms;
 
   // if ((fp->frame_type == TDD) && 
-     // (subframe_select(fp,proc->tti_rx) != SF_UL)) return;
+     // (subframe_select(fp,proc->tti_rx) != NR_UPLINK_SLOT)) return;
 
   start_meas(&ru->ofdm_demod_stats);
   if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 );
diff --git a/openair1/SCHED_NR/phy_frame_config_nr.h b/openair1/SCHED_NR/phy_frame_config_nr.h
index 80cf23b0267..d1ec5c80d8b 100644
--- a/openair1/SCHED_NR/phy_frame_config_nr.h
+++ b/openair1/SCHED_NR/phy_frame_config_nr.h
@@ -47,7 +47,7 @@
  *  @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 set_tdd_config_nr(nfapi_nr_config_request_scf_t *cfg, int mu,
                        int nrofDownlinkSlots, int nrofDownlinkSymbols,
                        int nrofUplinkSlots,   int nrofUplinkSymbols);
 
@@ -78,7 +78,7 @@ int set_tdd_configuration_dedicated_nr(NR_DL_FRAME_PARMS *frame_parms);
  *  @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);
+nr_slot_t nr_slot_select(nfapi_nr_config_request_scf_t *cfg, int nr_frame, int nr_tti);
 
 /** \brief This function frees tdd configuration for nr
  *  @param frame_parms NR DL Frame parameters
diff --git a/openair1/SCHED_NR/phy_procedures_nr_common.c b/openair1/SCHED_NR/phy_procedures_nr_common.c
index f027c62ba0c..8d1f6155690 100755
--- a/openair1/SCHED_NR/phy_procedures_nr_common.c
+++ b/openair1/SCHED_NR/phy_procedures_nr_common.c
@@ -33,12 +33,3 @@
 #include "sched_nr.h"
 #include "PHY/INIT/phy_init.h"
 
-nr_subframe_t nr_slot_select(nfapi_nr_config_request_t *cfg, unsigned char slot, int frame)
-{
-  if (cfg->subframe_config.duplex_mode.value == FDD || slot == NR_DOWNLINK_SLOT || nr_is_ssb_slot(cfg,slot,frame)==1)
-    return(SF_DL);
-  else if (slot == NR_UPLINK_SLOT)
-    return (SF_UL);
-
-  return -1;
-}
diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c
index fb6d1a6c37c..d9a7ee3c69a 100644
--- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c
+++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c
@@ -49,103 +49,78 @@
 
 #include "intertask_interface.h"
 
-extern uint8_t nfapi_mode;
-/*
-int return_ssb_type(nfapi_config_request_t *cfg)
-{
-  int mu = cfg->subframe_config.numerology_index_mu.value;
-  nr_ssb_type_e ssb_type;
-
-  switch(mu) {
-
-  case NR_MU_0:
-    ssb_type = nr_ssb_type_A;
-    break;
-
-  case NR_MU_1:
-    ssb_type = nr_ssb_type_B;
-    break;
+uint8_t SSB_Table[38]={0,2,4,6,8,10,12,14,254,254,16,18,20,22,24,26,28,30,254,254,32,34,36,38,40,42,44,46,254,254,48,50,52,54,56,58,60,62};
 
-  case NR_MU_3:
-    ssb_type = nr_ssb_type_D;
-    break;
-
-  case NR_MU_4:
-    ssb_type = nr_ssb_type_E;
-    break;
-
-  default:
-    AssertFatal(0==1, "Invalid numerology index %d for the synchronization block\n", mu);
-  }
-
-  LOG_D(PHY, "SSB type %d\n", ssb_type);
-  return ssb_type;
-
-}*/
+extern uint8_t nfapi_mode;
 
+void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_scf_t *cfg, NR_DL_FRAME_PARMS *fp) {
 
+  uint8_t sco = 0;
+  if (((fp->freq_range == nr_FR1) && (cfg->ssb_table.ssb_subcarrier_offset.value<24)) ||
+      ((fp->freq_range == nr_FR2) && (cfg->ssb_table.ssb_subcarrier_offset.value<12)) )
+    sco = cfg->ssb_table.ssb_subcarrier_offset.value;
 
-void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp) {
-  fp->ssb_start_subcarrier = (12 * cfg->sch_config.n_ssb_crb.value + cfg->sch_config.ssb_subcarrier_offset.value)/(1<<cfg->subframe_config.numerology_index_mu.value);
-  LOG_D(PHY, "SSB first subcarrier %d (%d,%d)\n", fp->ssb_start_subcarrier,cfg->sch_config.n_ssb_crb.value,cfg->sch_config.ssb_subcarrier_offset.value);
+  fp->ssb_start_subcarrier = (12 * cfg->ssb_table.ssb_offset_point_a.value + sco);
+  LOG_D(PHY, "SSB first subcarrier %d (%d,%d)\n", fp->ssb_start_subcarrier,cfg->ssb_table.ssb_offset_point_a.value,sco);
 }
 
 void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) {
+
   NR_DL_FRAME_PARMS *fp=&gNB->frame_parms;
-  nfapi_nr_config_request_t *cfg = &gNB->gNB_config;
+  nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
   int **txdataF = gNB->common_vars.txdataF;
-  uint8_t *pbch_pdu=&gNB->pbch_pdu[0];
   uint8_t ssb_index, n_hf;
-  int ssb_start_symbol, rel_slot;
+  uint16_t ssb_start_symbol, rel_slot;
   int txdataF_offset = (slot%2)*fp->samples_per_slot_wCP;
-  uint16_t slots_per_hf = fp->slots_per_frame / 2;
+  uint16_t slots_per_hf = (fp->slots_per_frame)>>1;
 
-  n_hf = cfg->sch_config.half_frame_index.value;
+  n_hf = fp->half_frame_bit;
 
   // if SSB periodicity is 5ms, they are transmitted in both half frames
-  if ( cfg->sch_config.ssb_periodicity.value == 5) {
+  if ( cfg->ssb_table.ssb_period.value == 0) {
     if (slot<slots_per_hf)
       n_hf=0;
     else
       n_hf=1;
   }
 
-  // to set a effective slot number between 0 to 9 in the half frame where the SSB is supposed to be
+  // to set a effective slot number in the half frame where the SSB is supposed to be
   rel_slot = (n_hf)? (slot-slots_per_hf) : slot; 
 
   LOG_D(PHY,"common_signal_procedures: frame %d, slot %d\n",frame,slot);
 
-  if(rel_slot<slots_per_hf && rel_slot>=0)  {
-     for (int i=0; i<2; i++)  {  // max two SSB per frame
-     
-	ssb_index = i + 2*rel_slot; // computing the ssb_index
-	if ((fp->L_ssb >> ssb_index) & 0x01)  { // generating the ssb only if the bit of L_ssb at current ssb index is 1
+  if(rel_slot<38 && rel_slot>=0)  { // there is no SSB beyond slot 37
+
+    for (int i=0; i<2; i++)  {  // max two SSB per frame
+      
+      ssb_index = i + SSB_Table[rel_slot]; // computing the ssb_index
+
+      if ((ssb_index<64) && ((fp->L_ssb >> (63-ssb_index)) & 0x01))  { // generating the ssb only if the bit of L_ssb at current ssb index is 1
+        fp->ssb_index = ssb_index;
+        int ssb_start_symbol_abs = nr_get_ssb_start_symbol(fp); // computing the starting symbol for current ssb
+	ssb_start_symbol = ssb_start_symbol_abs % fp->symbols_per_slot;  // start symbol wrt slot
+
+	nr_set_ssb_first_subcarrier(cfg, fp);  // setting the first subcarrier
+	
+	LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol);
+	nr_generate_pss(gNB->d_pss, &txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp);
+	nr_generate_sss(gNB->d_sss, &txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp);
 	
-	  int ssb_start_symbol_abs = nr_get_ssb_start_symbol(fp, ssb_index, n_hf); // computing the starting symbol for current ssb
-	  ssb_start_symbol = ssb_start_symbol_abs % 14;  // start symbol wrt slot
-
-	  nr_set_ssb_first_subcarrier(cfg, fp);  // setting the first subcarrier
-	  
-	  // it is supposed that each logical antenna port correspont to a different beam so each SSB is stored into its own index of txdataF
-    	  LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol);
-    	  nr_generate_pss(gNB->d_pss, &txdataF[ssb_index][txdataF_offset], AMP, ssb_start_symbol, cfg, fp);
-    	  nr_generate_sss(gNB->d_sss, &txdataF[ssb_index][txdataF_offset], AMP, ssb_start_symbol, cfg, fp);
-
-	  if (fp->Lmax == 4)
-	    nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],&txdataF[ssb_index][txdataF_offset], AMP, ssb_start_symbol, cfg, fp);
-	  else
-	    nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[0][ssb_index],&txdataF[ssb_index][txdataF_offset], AMP, ssb_start_symbol, cfg, fp);
-
-    	  nr_generate_pbch(&gNB->pbch,
-                      pbch_pdu,
-                      gNB->nr_pbch_interleaver,
-                      &txdataF[ssb_index][txdataF_offset],
-                      AMP,
-                      ssb_start_symbol,
-                      n_hf,fp->Lmax,ssb_index,
-                      frame, cfg, fp);
-	}
-     }
+        if (cfg->carrier_config.num_tx_ant.value <= 4)
+	  nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index&7],&txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp);
+        else
+	  nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[0][ssb_index&7],&txdataF[0][txdataF_offset], AMP, ssb_start_symbol, cfg, fp);
+	
+	nr_generate_pbch(&gNB->pbch,
+	                 &gNB->ssb_pdu,
+	                 gNB->nr_pbch_interleaver,
+			 &txdataF[0][txdataF_offset],
+			 AMP,
+			 ssb_start_symbol,
+			 n_hf, frame, cfg, fp);
+
+      }
+    }
   }
 }
 
@@ -153,64 +128,71 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
                            int frame,int slot,
                            int do_meas) {
   int aa;
-  uint8_t num_dci=0,num_pdsch_rnti;
   NR_DL_FRAME_PARMS *fp=&gNB->frame_parms;
-  nfapi_nr_config_request_t *cfg = &gNB->gNB_config;
+  nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
   int offset = gNB->CC_id;
-  uint8_t ssb_frame_periodicity;  // every how many frames SSB are generated
+  uint8_t ssb_frame_periodicity = 1;  // every how many frames SSB are generated
   int txdataF_offset = (slot%2)*fp->samples_per_slot_wCP;
 
-  if (cfg->sch_config.ssb_periodicity.value < 20)
-    ssb_frame_periodicity = 1;
-  else 
-    ssb_frame_periodicity = (cfg->sch_config.ssb_periodicity.value)/10 ;  // 10ms is the frame length
+  
+  
+  if (cfg->ssb_table.ssb_period.value > 1) 
+    ssb_frame_periodicity = 1 <<(cfg->ssb_table.ssb_period.value -1) ; 
 
-  if ((cfg->subframe_config.duplex_mode.value == TDD) && (nr_slot_select(cfg,slot,frame)==SF_UL)) return;
+  if ((cfg->cell_config.frame_duplex_type.value == TDD) &&
+      (nr_slot_select(cfg,frame,slot) == NR_UPLINK_SLOT)) return;
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+offset,1);
 
   if (do_meas==1) start_meas(&gNB->phy_proc_tx);
 
   // clear the transmit data array for the current subframe
-  for (aa=0; aa<fp->Lmax; aa++) {
+  for (aa=0; aa<cfg->carrier_config.num_tx_ant.value; aa++) {
     memset(&gNB->common_vars.txdataF[aa][txdataF_offset],0,fp->samples_per_slot_wCP*sizeof(int32_t));
   }
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_COMMON_TX,1);
   if (nfapi_mode == 0 || nfapi_mode == 1) { 
-    if (!(frame%ssb_frame_periodicity))  // generate SSB only for given frames according to SSB periodicity
+    if ((!(frame%ssb_frame_periodicity)))  // generate SSB only for given frames according to SSB periodicity
       nr_common_signal_procedures(gNB,frame, slot);
   }
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_COMMON_TX,0);
 
-  num_dci = gNB->pdcch_vars.num_dci;
-  num_pdsch_rnti = gNB->pdcch_vars.num_pdsch_rnti;
-
-  for (int i=0; i<num_dci; i++) {
-    LOG_D(PHY, "[gNB %d] Frame %d slot %d \
-    Calling nr_generate_dci_top (number of DCI %d)\n", gNB->Mod_id, frame, slot, num_dci);
 
+  if (gNB->pdcch_pdu || gNB->ul_dci_pdu) {
+    LOG_D(PHY, "[gNB %d] Frame %d slot %d Calling nr_generate_dci_top (number of UL/DL DCI %d/%d)\n",
+	  gNB->Mod_id, frame, slot,
+	  gNB->ul_dci_pdu==NULL?0:gNB->ul_dci_pdu->pdcch_pdu.pdcch_pdu_rel15.numDlDci,
+	  gNB->pdcch_pdu==NULL?0:gNB->pdcch_pdu->pdcch_pdu_rel15.numDlDci);
+  
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,1);
 
-    nr_generate_dci_top(gNB->pdcch_vars.dci_alloc[i],
-                        gNB->nr_gold_pdcch_dmrs[slot],
-                        &gNB->common_vars.txdataF[0][txdataF_offset],  // hardcoded to beam 0
-                        AMP, *fp, *cfg);
-
+    nr_generate_dci_top(gNB->pdcch_pdu,
+			gNB->ul_dci_pdu,
+			gNB->nr_gold_pdcch_dmrs[slot],
+			&gNB->common_vars.txdataF[0][txdataF_offset],
+			AMP, *fp);
+  
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,0);
   }
-      
-  for (int i=0; i<num_pdsch_rnti; i++) {
+ 
+  LOG_D(PHY, "PDSCH generation started (%d)\n", gNB->num_pdsch_rnti);
+  for (int i=0; i<gNB->num_pdsch_rnti; i++) {
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,1);
-    LOG_D(PHY, "PDSCH generation started (%d)\n", num_pdsch_rnti);
     nr_generate_pdsch(gNB->dlsch[i][0],
-		      &gNB->pdcch_vars.dci_alloc[i],
 		      gNB->nr_gold_pdsch_dmrs[slot],
 		      gNB->common_vars.txdataF,
-		      AMP, frame, slot, fp, cfg,
+		      AMP, frame, slot, fp, 0,
 		      &gNB->dlsch_encoding_stats,
 		      &gNB->dlsch_scrambling_stats,
-		      &gNB->dlsch_modulation_stats);
+		      &gNB->dlsch_modulation_stats,
+		      &gNB->tinput,
+		      &gNB->tprep,
+		      &gNB->tparity,
+		      &gNB->toutput,
+		      &gNB->dlsch_rate_matching_stats,
+		      &gNB->dlsch_interleaving_stats,
+		      &gNB->dlsch_segmentation_stats);
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_DLSCH,0);
   }
 
@@ -218,86 +200,84 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
 }
 
 
-void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int UE_id, uint8_t harq_pid)
+
+/*
+
+  if ((cfg->subframe_config.duplex_mode.value == TDD) && 
+      ((nr_slot_select(fp,frame,slot)&NR_DOWNLINK_SLOT)==SF_DL)) return;
+
+  //  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX,1);
+
+
+  if (do_prach_rx(fp,frame,slot)) L1_nr_prach_procedures(gNB,frame,slot/fp->slots_per_subframe);
+*/
+
+void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH_id, uint8_t harq_pid)
 {
-  NR_DL_FRAME_PARMS                    *frame_parms           = &gNB->frame_parms;
-  nfapi_nr_ul_config_ulsch_pdu         *rel15_ul              = &gNB->ulsch[UE_id][0]->harq_processes[harq_pid]->ulsch_pdu;
-  nfapi_nr_ul_config_ulsch_pdu_rel15_t *nfapi_ulsch_pdu_rel15 = &rel15_ul->ulsch_pdu_rel15;
+  NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
+  nfapi_nr_pusch_pdu_t *pusch_pdu = &gNB->ulsch[ULSCH_id][0]->harq_processes[harq_pid]->ulsch_pdu;
   
   uint8_t ret;
   uint8_t l, number_dmrs_symbols = 0;
-  uint8_t mapping_type;
   uint32_t G;
-  int Nid_cell = 0; // [hna] shouldn't be a local variable (should be signaled)
   uint16_t start_symbol, number_symbols, nb_re_dmrs;
 
-  mapping_type = gNB->pusch_config.pusch_TimeDomainResourceAllocation[0]->mappingType;
-
-  start_symbol = nfapi_ulsch_pdu_rel15->start_symbol;
-  number_symbols = nfapi_ulsch_pdu_rel15->number_symbols;
+  start_symbol = pusch_pdu->start_symbol_index;
+  number_symbols = pusch_pdu->nr_of_symbols;
 
   for (l = start_symbol; l < start_symbol + number_symbols; l++)
-      number_dmrs_symbols += is_dmrs_symbol(l,
-                                            0,
-                                            0,
-                                            0,
-                                            0,
-                                            0,
-                                            number_symbols,
-                                            &gNB->dmrs_UplinkConfig,
-                                            mapping_type,
-                                            frame_parms->ofdm_symbol_size);
-
-  nb_re_dmrs = ((gNB->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)?6:4)*number_dmrs_symbols;
-
-  G = nr_get_G(nfapi_ulsch_pdu_rel15->number_rbs,
+      number_dmrs_symbols += ((pusch_pdu->ul_dmrs_symb_pos)>>l)&0x01;
+
+  nb_re_dmrs = ((pusch_pdu->dmrs_config_type == pusch_dmrs_type1)?6:4);
+
+  G = nr_get_G(pusch_pdu->rb_size,
                number_symbols,
                nb_re_dmrs,
-               nfapi_ulsch_pdu_rel15->length_dmrs,
-               nfapi_ulsch_pdu_rel15->Qm,
-               nfapi_ulsch_pdu_rel15->n_layers);
+               number_dmrs_symbols, // number of dmrs symbols irrespective of single or double symbol dmrs
+               pusch_pdu->qam_mod_order,
+               pusch_pdu->nrOfLayers);
 
 
   //----------------------------------------------------------
   //------------------- ULSCH unscrambling -------------------
   //----------------------------------------------------------
 
-  nr_ulsch_unscrambling(gNB->pusch_vars[UE_id]->llr,
+  nr_ulsch_unscrambling(gNB->pusch_vars[ULSCH_id]->llr,
                         G,
                         0,
-                        Nid_cell,
-                        rel15_ul->rnti);
+                        pusch_pdu->data_scrambling_id,
+                        pusch_pdu->rnti);
 
   //----------------------------------------------------------
   //--------------------- ULSCH decoding ---------------------
   //----------------------------------------------------------
 
   ret = nr_ulsch_decoding(gNB,
-                    UE_id,
-                    gNB->pusch_vars[UE_id]->llr,
-                    frame_parms,
-                    frame_rx,
-                    number_symbols,
-                    nb_re_dmrs,
-                    slot_rx,
-                    harq_pid,
-                    0);
+                          ULSCH_id,
+                          gNB->pusch_vars[ULSCH_id]->llr,
+                          frame_parms,
+                          pusch_pdu,
+                          frame_rx,
+                          slot_rx,
+                          harq_pid,
+                          G);
+
         
-  if (ret > gNB->ulsch[UE_id][0]->max_ldpc_iterations)
-    LOG_I(PHY, "ULSCH in error\n");
-  //gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->b
-  else if(gNB->ulsch[UE_id][0]->harq_processes[harq_pid]->b!=NULL){
+  if (ret > gNB->ulsch[ULSCH_id][0]->max_ldpc_iterations)
+    LOG_I(PHY, "ULSCH %d in error\n",ULSCH_id);
+  //gNB->ulsch[ULSCH_id+1][0]->harq_processes[harq_pid]->b
+  else if(gNB->ulsch[ULSCH_id][0]->harq_processes[harq_pid]->b!=NULL){
 	  LOG_I(PHY, "ULSCH received ok \n");
-	  if(IS_SOFTMODEM_NOS1){ //&& gNB->ulsch[UE_id][0]->rnti == 0x1234
-		  nr_fill_crc_indication (gNB,frame_rx, slot_rx, UE_id, 0);
-		  nr_fill_rx_indication(gNB, frame_rx, slot_rx, UE_id, harq_pid);
+	  if(IS_SOFTMODEM_NOS1){ //&& gNB->ulsch[ULSCH_id][0]->rnti == 0x1234
+	    nr_fill_crc_indication(gNB,frame_rx, slot_rx, ULSCH_id, 0);
+	    nr_fill_rx_indication(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid);
 	  }
   }
 
 }
 
 
-void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id, uint8_t harq_pid)
+void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, uint8_t harq_pid)
 {
   // --------------------
   // [hna] TO BE CLEANED
@@ -308,32 +288,33 @@ void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id,
   int timing_advance_update;
   int sync_pos;
 
-  NR_gNB_ULSCH_t                       *ulsch                 = gNB->ulsch[UE_id][0];
+  uint16_t mu = gNB->frame_parms.numerology_index;
+  // pthread_mutex_lock(&gNB->UL_INFO_mutex);
+  NR_gNB_ULSCH_t                       *ulsch                 = gNB->ulsch[ULSCH_id][0];
   NR_UL_gNB_HARQ_t                     *harq_process          = ulsch->harq_processes[harq_pid];
 
-  uint16_t mu = gNB->gNB_config.subframe_config.numerology_index_mu.value;
-
  pthread_mutex_lock(&gNB->UL_INFO_mutex);
 
  gNB->UL_INFO.rx_ind.sfn_sf                    = frame<<4| slot_rx;
  gNB->UL_INFO.rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG;
- gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list->rx_indication_rel8.length = gNB->ulsch[UE_id][0]->harq_processes[harq_pid]->TBS>>3;
+ gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list->rx_indication_rel8.length = gNB->ulsch[ULSCH_id][0]->harq_processes[harq_pid]->TBS;
 
  pdu                                    = &gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list[gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus];
 
- //pdu->rx_ue_information.handle          = gNB->ulsch[UE_id+1][0]->handle;
+ //pdu->rx_ue_information.handle          = gNB->ulsch[ULSCH_id+1][0]->handle;
  pdu->rx_ue_information.tl.tag          = NFAPI_RX_UE_INFORMATION_TAG;
- pdu->rx_ue_information.rnti            = gNB->ulsch[UE_id][0]->rnti;
+ pdu->rx_ue_information.rnti            = gNB->ulsch[ULSCH_id][0]->rnti;
  pdu->rx_indication_rel8.tl.tag         = NFAPI_RX_INDICATION_REL8_TAG;
  pdu->rx_indication_rel8.offset         = 1;   // DJP - I dont understand - but broken unless 1 ????  0;  // filled in at the end of the UL_INFO formation
- pdu->data                              = harq_process->b;//gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->b;
+ pdu->data                              = harq_process->b;//gNB->ulsch[ULSCH_id+1][0]->harq_processes[harq_pid]->b;
   // estimate timing advance for MAC
-  sync_pos                               = nr_est_timing_advance_pusch(gNB, UE_id);
+  sync_pos                               = nr_est_timing_advance_pusch(gNB, ULSCH_id);
   timing_advance_update                  = sync_pos; // - gNB->frame_parms.nb_prefix_samples/4; //to check
   // printf("\x1B[33m" "timing_advance_update = %d\n" "\x1B[0m", timing_advance_update);
 
-  //pdu->data                              = gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->b;
-  sync_pos                               = nr_est_timing_advance_pusch(gNB, UE_id); // estimate timing advance for MAC
+
+  //  pdu->data                              = gNB->ulsch[ULSCH_id+1][0]->harq_processes[harq_pid]->b;
+  sync_pos                               = nr_est_timing_advance_pusch(gNB, ULSCH_id); // estimate timing advance for MAC
   timing_advance_update                  = sync_pos * (1 << mu);                    // scale by the used scs numerology
 
   // scale the 16 factor in N_TA calculation in 38.213 section 4.2 according to the used FFT size
@@ -342,6 +323,7 @@ void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id,
     case 217: timing_advance_update /= 32; break;
     case 245: timing_advance_update /= 32; break;
     case 273: timing_advance_update /= 32; break;
+    case 66:  timing_advance_update /= 12; break;
     default: abort();
   }
 
@@ -356,7 +338,7 @@ void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id,
   pdu->rx_indication_rel8.timing_advance = timing_advance_update;
 
   // estimate UL_CQI for MAC (from antenna port 0 only)
-  int SNRtimes10 = dB_fixed_times10(gNB->pusch_vars[UE_id]->ulsch_power[0]) - 300;//(10*gNB->measurements.n0_power_dB[0]);
+  int SNRtimes10 = dB_fixed_times10(gNB->pusch_vars[ULSCH_id]->ulsch_power[0]) - 300;//(10*gNB->measurements.n0_power_dB[0]);
 
   if      (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0;
   else if (SNRtimes10 >  635) pdu->rx_indication_rel8.ul_cqi=255;
@@ -372,7 +354,7 @@ void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id,
   pthread_mutex_unlock(&gNB->UL_INFO_mutex);
 }
 
-void nr_fill_crc_indication (PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id,  uint8_t crc_flag) {
+void nr_fill_crc_indication (PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id,  uint8_t crc_flag) {
   pthread_mutex_lock(&gNB->UL_INFO_mutex);
   nfapi_crc_indication_pdu_t *pdu =   &gNB->UL_INFO. crc_ind.crc_indication_body.crc_pdu_list[gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs];
   gNB->UL_INFO.crc_ind.sfn_sf                         = frame<<4 | slot_rx;
@@ -381,7 +363,7 @@ void nr_fill_crc_indication (PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_i
   pdu->instance_length = 0;     // don't know what to do with this
   //  pdu->rx_ue_information.handle                       = handle;
   pdu->rx_ue_information.tl.tag                       = NFAPI_RX_UE_INFORMATION_TAG;
-  pdu->rx_ue_information.rnti                         = gNB->ulsch[UE_id][0]->rnti;
+  pdu->rx_ue_information.rnti                         = gNB->ulsch[ULSCH_id][0]->rnti;
   pdu->crc_indication_rel8.tl.tag                     = NFAPI_CRC_INDICATION_REL8_TAG;
   pdu->crc_indication_rel8.crc_flag                   = crc_flag;
   gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs++;
@@ -420,24 +402,25 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx)
 
   for (int i = 0; i < num_pusch_pdu; i++) {
     switch (UL_tti_req->pdus_list[i].pdu_type) {
-    case NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE:
-      {
-	LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE\n",frame_rx,slot_rx);
+    case NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE:{
+      LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE\n",frame_rx,slot_rx);
 
-	nfapi_nr_pusch_pdu_t  *pusch_pdu = &UL_tti_req->pdus_list[0].pusch_pdu;
-	nr_fill_ulsch(gNB,frame_rx,slot_rx,pusch_pdu);
-	
-	uint8_t UE_id =  find_nr_ulsch(pusch_pdu->rnti,gNB,SEARCH_EXIST);
-	uint8_t harq_pid = pusch_pdu->pusch_data.harq_process_id;
-	uint8_t symbol_start = pusch_pdu->start_symbol_index;
-	uint8_t symbol_end = symbol_start + pusch_pdu->nr_of_symbols;
-	
-	for(uint8_t symbol = symbol_start; symbol < symbol_end; symbol++) {
-	  nr_rx_pusch(gNB, UE_id, frame_rx, slot_rx, symbol, harq_pid);
-	}
-	//LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[UE_id]->rxdataF_comp[0],6900,1,1);
-	//LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[UE_id]->rxdataF_ext[0],6900,1,1);
-	nr_ulsch_procedures(gNB, frame_rx, slot_rx, UE_id, harq_pid);
+      nfapi_nr_pusch_pdu_t  *pusch_pdu = &UL_tti_req->pdus_list[0].pusch_pdu;
+      nr_fill_ulsch(gNB,frame_rx,slot_rx,pusch_pdu);
+      
+      uint8_t ULSCH_id =  find_nr_ulsch(pusch_pdu->rnti,gNB,SEARCH_EXIST);
+      uint8_t harq_pid = pusch_pdu->pusch_data.harq_process_id;
+      uint8_t symbol_start = pusch_pdu->start_symbol_index;
+      uint8_t symbol_end = symbol_start + pusch_pdu->nr_of_symbols;
+      
+      for(uint8_t symbol = symbol_start; symbol < symbol_end; symbol++) {
+        nr_rx_pusch(gNB, ULSCH_id, frame_rx, slot_rx, symbol, harq_pid);
+      }
+      //LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[0]->rxdataF_comp[0],6900,1,1);
+      //LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[0]->rxdataF_ext[0],6900,1,1);
+      nr_ulsch_procedures(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid);
+      nr_fill_rx_indication(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid);  // indicate SDU to MAC
+      nr_fill_crc_indication(gNB, frame_rx, slot_rx, ULSCH_id, 0);
       }
     }
   }
diff --git a/openair1/SCHED_NR/sched_nr.h b/openair1/SCHED_NR/sched_nr.h
index 5b53aa919a5..5f54539b717 100644
--- a/openair1/SCHED_NR/sched_nr.h
+++ b/openair1/SCHED_NR/sched_nr.h
@@ -32,10 +32,10 @@
 #include "PHY_INTERFACE/phy_interface.h"
 #include "SCHED/sched_eNB.h"
 #include "PHY/NR_TRANSPORT/nr_dci.h"
+#include "phy_frame_config_nr.h"
 
 
-nr_slot_t nr_slot_select (nfapi_nr_config_request_t *cfg, unsigned char slot, int frame);
-void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp);
+void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_scf_t *cfg, NR_DL_FRAME_PARMS *fp);
 void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, int frame_tx, int slot_tx, int do_meas);
 void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx);
 void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx);
@@ -54,16 +54,4 @@ void nr_fep_full_2thread(RU_t *ru, int slot);
 void feptx_prec(RU_t *ru,int frame_tx,int tti_tx);
 int nr_phy_init_RU(RU_t *ru);
 
-void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params,
-				  nr_scs_e scs_common,
-				  nr_scs_e pdcch_scs,
-				  nr_frequency_range_e freq_range,
-				  uint8_t rmsi_pdcch_config,
-				  uint8_t ssb_idx,
-                  uint8_t k_ssb,
-                  uint16_t sfn_ssb,
-                  uint8_t n_ssb,
-				  uint16_t nb_slots_per_frame,
-				  uint16_t N_RB);
-
 #endif
diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h
index 7a4a5524831..e34ce2b6deb 100644
--- a/openair1/SCHED_NR_UE/defs.h
+++ b/openair1/SCHED_NR_UE/defs.h
@@ -376,11 +376,10 @@ void nr_compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsP
 void set_tx_harq_id(NR_UE_ULSCH_t *ulsch, int harq_pid, int slot_tx);
 int get_tx_harq_id(NR_UE_ULSCH_t *ulsch, int slot_tx);
 
-int is_pbch_in_slot(fapi_nr_pbch_config_t *pbch_config, int frame, int slot, int periodicity, uint16_t slots_per_frame);
+int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp);
 
 /*@}*/
 
 
 #endif
 
-
diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c
index 1b61260d10e..69876159d63 100644
--- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c
+++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c
@@ -51,10 +51,9 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response)
     uint8_t cc_id = scheduled_response->CC_id;
     uint32_t i;
     int slot = scheduled_response->slot; 	
-    
     // Note: we have to handle the thread IDs for this. To be revisited completely.
     uint8_t thread_id = PHY_vars_UE_g[module_id][cc_id]->current_thread_id[slot];
-    NR_UE_PDCCH *pdcch_vars2 = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[thread_id][0];
+    NR_UE_PDCCH *pdcch_vars = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[thread_id][0];
     NR_UE_DLSCH_t *dlsch0 = PHY_vars_UE_g[module_id][cc_id]->dlsch[thread_id][0][0];
     NR_UE_ULSCH_t *ulsch0 = PHY_vars_UE_g[module_id][cc_id]->ulsch[thread_id][0][0];
     //NR_DL_FRAME_PARMS frame_parms = PHY_vars_UE_g[module_id][cc_id]->frame_parms;
@@ -66,40 +65,14 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response)
     if(scheduled_response->dl_config != NULL){
       fapi_nr_dl_config_request_t *dl_config = scheduled_response->dl_config;
 
+      LOG_D(PHY,"Received %d DL pdus\n",dl_config->number_pdus);
+      pdcch_vars->nb_search_space = 0;
       for(i=0; i<dl_config->number_pdus; ++i){
 	if(dl_config->dl_config_list[i].pdu_type == FAPI_NR_DL_CONFIG_TYPE_DCI){
-	  pdcch_vars2->nb_search_space = pdcch_vars2->nb_search_space + 1;
-	  fapi_nr_dl_config_dci_dl_pdu_rel15_t *dci_config = &dl_config->dl_config_list[i].dci_config_pdu.dci_config_rel15;
-             
-	  pdcch_vars2->n_RB_BWP[i] = dci_config->N_RB_BWP;
-	  pdcch_vars2->searchSpace[i].monitoringSymbolWithinSlot = dci_config->monitoring_symbols_within_slot;
-                    
-	  pdcch_vars2->searchSpace[i].nrofCandidates_aggrlevel1  = dci_config->number_of_candidates[0];
-	  pdcch_vars2->searchSpace[i].nrofCandidates_aggrlevel2  = dci_config->number_of_candidates[1];
-	  pdcch_vars2->searchSpace[i].nrofCandidates_aggrlevel4  = dci_config->number_of_candidates[2];
-	  pdcch_vars2->searchSpace[i].nrofCandidates_aggrlevel8  = dci_config->number_of_candidates[3];
-	  pdcch_vars2->searchSpace[i].nrofCandidates_aggrlevel16 = dci_config->number_of_candidates[4];
-
-	  pdcch_vars2->coreset[i].duration = dci_config->coreset.duration;
-                    
-	  pdcch_vars2->coreset[i].frequencyDomainResources = dci_config->coreset.frequency_domain_resource;
-	  pdcch_vars2->coreset[i].rb_offset = dci_config->coreset.rb_offset;
-
-	  if(dci_config->coreset.cce_reg_mapping_type == CCE_REG_MAPPING_TYPE_INTERLEAVED){
-	    pdcch_vars2->coreset[i].cce_reg_mappingType.shiftIndex = dci_config->coreset.cce_reg_interleaved_shift_index;
-	    pdcch_vars2->coreset[i].cce_reg_mappingType.reg_bundlesize = dci_config->coreset.cce_reg_interleaved_reg_bundle_size;
-	    pdcch_vars2->coreset[i].cce_reg_mappingType.interleaversize = dci_config->coreset.cce_reg_interleaved_interleaver_size;
-	  }else{  //CCE_REG_MAPPING_TYPE_NON_INTERLEAVED
-	    pdcch_vars2->coreset[i].cce_reg_mappingType.shiftIndex = 0;
-	    pdcch_vars2->coreset[i].cce_reg_mappingType.reg_bundlesize = 6;
-	    pdcch_vars2->coreset[i].cce_reg_mappingType.interleaversize = 1;
-	  }
-                    
-	  pdcch_vars2->coreset[i].precoderGranularity = dci_config->coreset.precoder_granularity;
-	  //pdcch_vars2->coreset[i].tciStatesPDCCH;
-	  //pdcch_vars2->coreset[i].tciPresentInDCI;
-	  pdcch_vars2->coreset[i].pdcchDMRSScramblingID = dci_config->coreset.pdcch_dmrs_scrambling_id;
-
+	  fapi_nr_dl_config_dci_dl_pdu_rel15_t *pdcch_config = &dl_config->dl_config_list[i].dci_config_pdu.dci_config_rel15;
+	  memcpy((void*)&pdcch_vars->pdcch_config[pdcch_vars->nb_search_space],(void*)pdcch_config,sizeof(*pdcch_config));
+	  pdcch_vars->nb_search_space = pdcch_vars->nb_search_space + 1;
+	  LOG_D(PHY,"Number of DCI SearchSpaces %d\n",pdcch_vars->nb_search_space);
 	}else{  //FAPI_NR_DL_CONFIG_TYPE_DLSCH
 	  //  dlsch config pdu
 
@@ -113,11 +86,14 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response)
                     
 	  NR_DL_UE_HARQ_t *dlsch0_harq = dlsch0->harq_processes[current_harq_pid];
 
-                    
+	  dlsch0_harq->BWPStart = dlsch_config_pdu->BWPStart;
+	  dlsch0_harq->BWPSize = dlsch_config_pdu->BWPSize;
 	  dlsch0_harq->nb_rb = dlsch_config_pdu->number_rbs;
 	  dlsch0_harq->start_rb = dlsch_config_pdu->start_rb;
 	  dlsch0_harq->nb_symbols = dlsch_config_pdu->number_symbols;
 	  dlsch0_harq->start_symbol = dlsch_config_pdu->start_symbol;
+	  dlsch0_harq->dlDmrsSymbPos = dlsch_config_pdu->dlDmrsSymbPos;
+	  dlsch0_harq->dmrsConfigType = dlsch_config_pdu->dmrsConfigType;
 	  dlsch0_harq->mcs = dlsch_config_pdu->mcs;
 	  dlsch0_harq->DCINdi = dlsch_config_pdu->ndi;
 	  dlsch0_harq->rvidx = dlsch_config_pdu->rv;
@@ -132,7 +108,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response)
 	}
       }
     }else{
-      pdcch_vars2->nb_search_space = 0;
+      pdcch_vars->nb_search_space = 0;
     }
 
     if(scheduled_response->ul_config != NULL){
@@ -218,43 +194,10 @@ int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config){
 
   fapi_nr_config_request_t *nrUE_config = &PHY_vars_UE_g[phy_config->Mod_id][phy_config->CC_id]->nrUE_config;
   
-  if(phy_config != NULL){
-    if(phy_config->config_req.config_mask & FAPI_NR_CONFIG_REQUEST_MASK_PBCH){
-      LOG_I(MAC,"[L1][IF module][PHY CONFIG]\n");
-      LOG_I(MAC,"subcarrier spacing:          %d\n", phy_config->config_req.pbch_config.subcarrier_spacing_common);
-      LOG_I(MAC,"ssb carrier offset:          %d\n", phy_config->config_req.pbch_config.ssb_subcarrier_offset);
-      LOG_I(MAC,"dmrs type A position:        %d\n", phy_config->config_req.pbch_config.dmrs_type_a_position);
-      LOG_I(MAC,"pdcch config sib1:           %d\n", phy_config->config_req.pbch_config.pdcch_config_sib1);
-      LOG_I(MAC,"cell barred:                 %d\n", phy_config->config_req.pbch_config.cell_barred);
-      LOG_I(MAC,"intra frequency reselection: %d\n", phy_config->config_req.pbch_config.intra_frequency_reselection);
-      LOG_I(MAC,"system frame number:         %d\n", phy_config->config_req.pbch_config.system_frame_number);
-      LOG_I(MAC,"ssb index:                   %d\n", phy_config->config_req.pbch_config.ssb_index);
-      LOG_I(MAC,"half frame bit:              %d\n", phy_config->config_req.pbch_config.half_frame_bit);
-      LOG_I(MAC,"-------------------------------\n");
-
-      memcpy(&nrUE_config->pbch_config,&phy_config->config_req.pbch_config,sizeof(fapi_nr_pbch_config_t));
-      
-    }
-        
-    if(phy_config->config_req.config_mask & FAPI_NR_CONFIG_REQUEST_MASK_DL_BWP_COMMON){
-            
-    }
-
-    if(phy_config->config_req.config_mask & FAPI_NR_CONFIG_REQUEST_MASK_UL_BWP_COMMON){
-            
-    }
-
-    if(phy_config->config_req.config_mask & FAPI_NR_CONFIG_REQUEST_MASK_DL_BWP_DEDICATED){
-            
-    }
-
-    if(phy_config->config_req.config_mask & FAPI_NR_CONFIG_REQUEST_MASK_UL_BWP_DEDICATED){
-            
-    }
-  }
+  if(phy_config != NULL)
+      memcpy(nrUE_config,&phy_config->config_req,sizeof(fapi_nr_config_request_t));
     
-  
-
   return 0;
 }
 
+
diff --git a/openair1/SCHED_NR_UE/phy_frame_config_nr.c b/openair1/SCHED_NR_UE/phy_frame_config_nr.c
deleted file mode 100644
index fc1c459ba4e..00000000000
--- a/openair1/SCHED_NR_UE/phy_frame_config_nr.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The OpenAirInterface Software Alliance licenses this file to You under
- * the OAI Public License, Version 1.1  (the "License"); you may not use this file
- * except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.openairinterface.org/?page_id=698
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *-------------------------------------------------------------------------------
- * For more information about the OpenAirInterface (OAI) Software Alliance:
- *      contact@openairinterface.org
- */
-
-/***********************************************************************
-*
-* FILENAME    :  phy_frame_configuration_nr.c
-*
-* DESCRIPTION :  functions related to FDD/TDD configuration for NR
-*                see TS 38.213 11.1 Slot configuration
-*                and TS 38.331 for RRC configuration
-*
-************************************************************************/
-
-#include "SCHED_NR_UE/defs.h"
-#include "PHY/defs_nr_UE.h"
-#include "SCHED_NR_UE/phy_frame_config_nr.h"
-
-/*******************************************************************
-*
-* NAME :         set_tdd_configuration
-*
-* PARAMETERS :   pointer to frame configuration
-*
-* OUTPUT:        table of uplink symbol for each slot for 2 frames
-*
-* RETURN :       0 if tdd has been properly configurated
-*                -1 tdd configuration can not be done
-*
-* DESCRIPTION :  generate bit map for uplink symbol for each slot for several frames
-*                see TS 38.213 11.1 Slot configuration
-*
-*********************************************************************/
-
-int set_tdd_config_nr(NR_DL_FRAME_PARMS *frame_parms, int dl_UL_TransmissionPeriodicity,
-                       int nrofDownlinkSlots, int nrofDownlinkSymbols,
-                       int nrofUplinkSlots,   int nrofUplinkSymbols)
-{
-  TDD_UL_DL_configCommon_t  *p_tdd_ul_dl_configuration;
-  int slot_number = 0;
-  int nb_slots_to_set = TDD_CONFIG_NB_FRAMES*(frame_parms->ttis_per_subframe * LTE_NUMBER_OF_SUBFRAMES_PER_FRAME);
-
-  /* allocate buffer for configuration structure */
-  p_tdd_ul_dl_configuration = calloc( 1, sizeof(TDD_UL_DL_configCommon_t));
-
-  if (p_tdd_ul_dl_configuration == NULL) {
-    printf("Error test_frame_configuration: memory allocation problem \n");
-    assert(0);
-  }
-  else {
-    frame_parms->frame_type = TDD;
-  }
-
-  p_tdd_ul_dl_configuration->dl_UL_TransmissionPeriodicity = dl_UL_TransmissionPeriodicity;
-  p_tdd_ul_dl_configuration->nrofDownlinkSlots   = nrofDownlinkSlots;
-  p_tdd_ul_dl_configuration->nrofDownlinkSymbols = nrofDownlinkSymbols;
-  p_tdd_ul_dl_configuration->nrofUplinkSlots     = nrofUplinkSlots;
-  p_tdd_ul_dl_configuration->nrofUplinkSymbols   = nrofUplinkSymbols;
-
-  frame_parms->p_tdd_UL_DL_Configuration = p_tdd_ul_dl_configuration;
-
-  int nb_periods_per_frame = (FRAME_DURATION_MICRO_SEC/dl_UL_TransmissionPeriodicity);
-
-  int nb_slots_per_period = (frame_parms->ttis_per_subframe * LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)/nb_periods_per_frame;
-
-  if (nb_slots_per_period != (nrofDownlinkSlots + nrofUplinkSlots)) {
-    LOG_E(PHY,"set_tdd_configuration_nr: given period is inconsistent with current tdd configuration \n");
-    return (-1);
-  }
-
-  while(slot_number != nb_slots_to_set) {
-
-    for (int number_of_slot = 0; number_of_slot < nrofDownlinkSlots; number_of_slot++) {
-      frame_parms->tdd_uplink_nr[slot_number] = NR_TDD_DOWNLINK_SLOT;
-      slot_number++;
-    }
-
-    if (p_tdd_ul_dl_configuration->nrofDownlinkSymbols != 0) {
-      LOG_E(PHY,"set_tdd_configuration_nr: downlink symbol for slot is not supported for tdd configuration \n");
-      return (-1);
-    }
-
-    for (int number_of_slot = 0; number_of_slot < nrofUplinkSlots; number_of_slot++) {
-      frame_parms->tdd_uplink_nr[slot_number] = NR_TDD_UPLINK_SLOT;
-      slot_number++;
-    }
-
-    if (p_tdd_ul_dl_configuration->nrofUplinkSymbols != 0) {
-      LOG_E(PHY,"set_tdd_configuration_nr: uplink symbol for slot is not supported for tdd configuration \n");
-      return (-1);
-    }
-  }
-
-  if (frame_parms->p_tdd_UL_DL_ConfigurationCommon2 != NULL) {
-    LOG_E(PHY,"set_tdd_configuration_nr: additionnal tdd configuration 2 is not supported for tdd configuration \n");
-    return (-1);
-  }
-
-  return (0);
-}
-
-/*******************************************************************
-*
-* NAME :         add_tdd_dedicated_configuration_nr
-*
-* PARAMETERS :   pointer to frame configuration
-*
-* OUTPUT:        table of uplink symbol for each slot for several frames
-*
-* RETURN :       0 if tdd has been properly configurated
-*                -1 tdd configuration can not be done
-*
-* DESCRIPTION :  generate bit map for uplink symbol for each slot for several frames
-*                see TS 38.213 11.1 Slot configuration
-*
-*********************************************************************/
-
-void add_tdd_dedicated_configuration_nr(NR_DL_FRAME_PARMS *frame_parms, int slotIndex, int nrofDownlinkSymbols, int nrofUplinkSymbols)
-{
-  TDD_UL_DL_SlotConfig_t *p_TDD_UL_DL_ConfigDedicated = frame_parms->p_TDD_UL_DL_ConfigDedicated;
-  TDD_UL_DL_SlotConfig_t *p_previous_TDD_UL_DL_ConfigDedicated;
-  int next = 0;
-
-  while (p_TDD_UL_DL_ConfigDedicated != NULL) {
-    p_previous_TDD_UL_DL_ConfigDedicated = p_TDD_UL_DL_ConfigDedicated;
-    p_TDD_UL_DL_ConfigDedicated = (TDD_UL_DL_SlotConfig_t *)(p_TDD_UL_DL_ConfigDedicated->p_next_TDD_UL_DL_SlotConfig);
-    next = 1;
-  }
-
-  p_TDD_UL_DL_ConfigDedicated = calloc( 1, sizeof(TDD_UL_DL_SlotConfig_t));
-  //printf("allocate pt %p \n", p_TDD_UL_DL_ConfigDedicated);
-  if (p_TDD_UL_DL_ConfigDedicated == NULL) {
-    printf("Error test_frame_configuration: memory allocation problem \n");
-    assert(0);
-  }
-
-  if (next == 0) {
-    frame_parms->p_TDD_UL_DL_ConfigDedicated = p_TDD_UL_DL_ConfigDedicated;
-  }
-  else {
-    p_previous_TDD_UL_DL_ConfigDedicated->p_next_TDD_UL_DL_SlotConfig = (struct TDD_UL_DL_SlotConfig_t *)p_TDD_UL_DL_ConfigDedicated;
-  }
-
-  p_TDD_UL_DL_ConfigDedicated->slotIndex = slotIndex;
-  p_TDD_UL_DL_ConfigDedicated->nrofDownlinkSymbols = nrofDownlinkSymbols;
-  p_TDD_UL_DL_ConfigDedicated->nrofUplinkSymbols = nrofUplinkSymbols;
-}
-
-/*******************************************************************
-*
-* NAME :         set_tdd_configuration_dedicated_nr
-*
-* PARAMETERS :   pointer to frame configuration
-*
-* OUTPUT:        table of uplink symbol for each slot for several frames
-*
-* RETURN :       0 if tdd has been properly configurated
-*                -1 tdd configuration can not be done
-*
-* DESCRIPTION :  generate bit map for uplink symbol for each slot for several frames
-*                see TS 38.213 11.1 Slot configuration
-*
-*********************************************************************/
-
-int set_tdd_configuration_dedicated_nr(NR_DL_FRAME_PARMS *frame_parms)
-{
-  TDD_UL_DL_SlotConfig_t *p_current_TDD_UL_DL_SlotConfig;
-
-  p_current_TDD_UL_DL_SlotConfig = frame_parms->p_TDD_UL_DL_ConfigDedicated;
-
-  NR_TST_PHY_PRINTF("\nSet tdd dedicated configuration\n ");
-
-  while(p_current_TDD_UL_DL_SlotConfig != NULL) {
-    int slot_index = p_current_TDD_UL_DL_SlotConfig->slotIndex;
-    if (slot_index < TDD_CONFIG_NB_FRAMES*(frame_parms->ttis_per_subframe * LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)) {
-      if (p_current_TDD_UL_DL_SlotConfig->nrofDownlinkSymbols != 0) {
-        if (p_current_TDD_UL_DL_SlotConfig->nrofDownlinkSymbols == NR_TDD_SET_ALL_SYMBOLS) {
-          if (p_current_TDD_UL_DL_SlotConfig->nrofUplinkSymbols == 0) {
-            frame_parms->tdd_uplink_nr[slot_index] = NR_TDD_DOWNLINK_SLOT;
-            NR_TST_PHY_PRINTF(" DL[%d] ", slot_index);
-          }
-          else {
-            LOG_E(PHY,"set_tdd_configuration_dedicated_nr: tdd downlink & uplink symbol configuration is not supported \n");
-            return (-1);
-          }
-        }
-        else {
-          LOG_E(PHY,"set_tdd_configuration_dedicated_nr: tdd downlink symbol configuration is not supported \n");
-          return (-1);
-        }
-      }
-      else if (p_current_TDD_UL_DL_SlotConfig->nrofUplinkSymbols != 0) {
-        if (p_current_TDD_UL_DL_SlotConfig->nrofUplinkSymbols == NR_TDD_SET_ALL_SYMBOLS) {
-          frame_parms->tdd_uplink_nr[slot_index] = NR_TDD_UPLINK_SLOT;
-          NR_TST_PHY_PRINTF(" UL[%d] ", slot_index);
-        }
-        else {
-          LOG_E(PHY,"set_tdd_configuration_dedicated_nr: tdd uplink symbol configuration is not supported \n");
-          return (-1);
-        }
-      }
-      else {
-        LOG_E(PHY,"set_tdd_configuration_dedicated_nr: no tdd symbol configuration is specified \n");
-        return (-1);
-      }
-    }
-    else {
-      LOG_E(PHY,"set_tdd_configuration_dedicated_nr: tdd slot index exceeds maximum value \n");
-      return (-1);
-    }
-
-    p_current_TDD_UL_DL_SlotConfig = (TDD_UL_DL_SlotConfig_t *)(p_current_TDD_UL_DL_SlotConfig->p_next_TDD_UL_DL_SlotConfig);
-  }
-  NR_TST_PHY_PRINTF("\n");
-  return (0);
-}
-
-/*******************************************************************
-*
-* NAME :         set_tdd_configuration
-*
-* PARAMETERS :   pointer to tdd common configuration
-*                pointer to tdd common configuration2
-*                pointer to tdd dedicated configuration
-*
-* OUTPUT:        table of uplink symbol for each slot for 2 frames
-*
-* RETURN :       0  if srs sequence has been successfully generated
-*                -1 if sequence can not be properly generated
-*
-* DESCRIPTION :  generate bit map for uplink symbol for each slot for 2 frames
-*                see TS 38.213 11.1 Slot configuration
-*
-*********************************************************************/
-
-int slot_select_nr(NR_DL_FRAME_PARMS *frame_parms, int nr_frame, int nr_tti)
-{
-  /* for FFD all slot can be considered as an uplink */
-  if (frame_parms->frame_type == FDD) {
-    return (NR_UPLINK_SLOT | NR_DOWNLINK_SLOT );
-  }
-
-  if (nr_frame%2 == 0) {
-    if (frame_parms->tdd_uplink_nr[nr_tti] == NR_TDD_UPLINK_SLOT) {
-      return (NR_UPLINK_SLOT);
-    }
-    else {
-      return (NR_DOWNLINK_SLOT);
-    }
-  }
-  else if ((frame_parms->tdd_uplink_nr[(frame_parms->ttis_per_subframe * LTE_NUMBER_OF_SUBFRAMES_PER_FRAME) + nr_tti] == NR_TDD_UPLINK_SLOT)) {
-    return (NR_UPLINK_SLOT);
-  }
-  else {
-    return (NR_DOWNLINK_SLOT);
-  }
-}
-
-/*******************************************************************
-*
-* NAME :         free_tdd_configuration_nr
-*
-* PARAMETERS :   pointer to frame configuration
-*
-* RETURN :       none
-*
-* DESCRIPTION :  free structure related to tdd configuration
-*
-*********************************************************************/
-
-void free_tdd_configuration_nr(NR_DL_FRAME_PARMS *frame_parms)
-{
-  TDD_UL_DL_configCommon_t *p_tdd_UL_DL_Configuration = frame_parms->p_tdd_UL_DL_Configuration;
-
-  free_tdd_configuration_dedicated_nr(frame_parms);
-
-  if (p_tdd_UL_DL_Configuration != NULL) {
-    frame_parms->p_tdd_UL_DL_Configuration = NULL;
-    free(p_tdd_UL_DL_Configuration);
-  }
-
-  for (int number_of_slot = 0; number_of_slot < NR_MAX_SLOTS_PER_FRAME; number_of_slot++) {
-    frame_parms->tdd_uplink_nr[number_of_slot] = NR_TDD_DOWNLINK_SLOT;
-  }
-}
-
-/*******************************************************************
-*
-* NAME :         free_tdd_configuration_dedicated_nr
-*
-* PARAMETERS :   pointer to frame configuration
-*
-* RETURN :       none
-*
-* DESCRIPTION :  free structure related to tdd dedicated configuration
-*
-*********************************************************************/
-
-void free_tdd_configuration_dedicated_nr(NR_DL_FRAME_PARMS *frame_parms)
-{
-  TDD_UL_DL_SlotConfig_t *p_current_TDD_UL_DL_ConfigDedicated = frame_parms->p_TDD_UL_DL_ConfigDedicated;
-  TDD_UL_DL_SlotConfig_t *p_next_TDD_UL_DL_ConfigDedicated;
-  int next = 0;
-  if (p_current_TDD_UL_DL_ConfigDedicated != NULL) {
-    do {
-      if (p_current_TDD_UL_DL_ConfigDedicated->p_next_TDD_UL_DL_SlotConfig != NULL) {
-        next = 1;
-        p_next_TDD_UL_DL_ConfigDedicated =  (TDD_UL_DL_SlotConfig_t *)(p_current_TDD_UL_DL_ConfigDedicated->p_next_TDD_UL_DL_SlotConfig);
-        p_current_TDD_UL_DL_ConfigDedicated->p_next_TDD_UL_DL_SlotConfig = NULL;
-        //printf("free pt %p \n", p_current_TDD_UL_DL_ConfigDedicated);
-        free(p_current_TDD_UL_DL_ConfigDedicated);
-        p_current_TDD_UL_DL_ConfigDedicated = p_next_TDD_UL_DL_ConfigDedicated;
-      }
-      else {
-        if (p_current_TDD_UL_DL_ConfigDedicated != NULL) {
-          frame_parms->p_TDD_UL_DL_ConfigDedicated = NULL;
-          //printf("free pt %p \n", p_current_TDD_UL_DL_ConfigDedicated);
-          free(p_current_TDD_UL_DL_ConfigDedicated);
-          next = 0;
-        }
-      }
-    } while (next);
-  }
-}
-
diff --git a/openair1/SCHED_NR_UE/phy_frame_config_nr.h b/openair1/SCHED_NR_UE/phy_frame_config_nr.h
index 429dff221b1..a939584584b 100644
--- a/openair1/SCHED_NR_UE/phy_frame_config_nr.h
+++ b/openair1/SCHED_NR_UE/phy_frame_config_nr.h
@@ -36,18 +36,6 @@
 
 /*************** 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
diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
index d0272b5dd7f..509f4b60213 100644
--- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
+++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
@@ -49,7 +49,7 @@
 //#include <sched.h>
 //#include "targets/RT/USER/nr-softmodem.h"
 #include "PHY/NR_UE_ESTIMATION/nr_estimation.h"
-
+#include "PHY/NR_TRANSPORT/nr_dci.h"
 #ifdef EMOS
 #include "SCHED/phy_procedures_emos.h"
 #endif
@@ -87,30 +87,15 @@ char nr_mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"};
 extern double cpuf;
 
 
+
 int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue,
                     uint32_t frame,
-                    uint8_t nr_tti_rx,
-                    uint8_t eNB_id,
-                    MIMO_mode_t mimo_mode,
-                    uint32_t high_speed_flag,
-                    uint8_t is_secondary_ue,
-                    int nb_coreset_active,
-                    uint16_t symbol_mon,
-                    NR_SEARCHSPACE_TYPE_t searchSpaceType);
-
-uint8_t nr_dci_decoding_procedure(int s,
-                                  int p,
-                                  PHY_VARS_NR_UE *ue,
-                                  NR_DCI_ALLOC_t *dci_alloc,
-                                  NR_SEARCHSPACE_TYPE_t searchSpacetype,
-                                  int16_t eNB_id,
-                                  uint8_t nr_tti_rx,
-                                  uint8_t dci_fields_sizes_cnt[MAX_NR_DCI_DECODED_SLOT][NBR_NR_DCI_FIELDS][NBR_NR_FORMATS],
-                                  uint16_t n_RB_ULBWP,
-                                  uint16_t n_RB_DLBWP,
-                                  crc_scrambled_t *crc_scrambled,
-                                  format_found_t *format_found,
-                                  uint16_t crc_scrambled_values[TOTAL_NBR_SCRAMBLED_VALUES]);
+                    uint32_t slot);
+
+uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
+				  int frame,
+				  int nr_tti_rx,
+				  fapi_nr_dci_indication_t *dci_ind);
 
 /*
 int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue,
@@ -136,7 +121,7 @@ int nr_generate_ue_ul_dlsch_params_from_dci(PHY_VARS_NR_UE *ue,
 */
 
 #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
-extern uint32_t downlink_frequency[MAX_NUM_CCs][4];
+extern uint64_t downlink_frequency[MAX_NUM_CCs][4];
 #endif
 
 
@@ -1404,137 +1389,6 @@ void ulsch_common_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_
 
 }
 
-void ue_prach_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode) {
-
-  int frame_tx = proc->frame_tx;
-  int nr_tti_tx = proc->nr_tti_tx;
-  int prach_power;
-  PRACH_RESOURCES_t prach_resources_local;
-
-  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_IN);
-
-  ue->generate_prach=0;
-
-  if (ue->mac_enabled==0){
-    ue->prach_resources[eNB_id] = &prach_resources_local;
-    prach_resources_local.ra_RNTI = 0xbeef;
-    prach_resources_local.ra_PreambleIndex = 0;
-  }
-
-  if (ue->mac_enabled==1){
-    // ask L2 for RACH transport
-    if ((mode != rx_calib_ue) && (mode != rx_calib_ue_med) && (mode != rx_calib_ue_byp) && (mode != no_L2_connect) ) {
-      LOG_D(PHY,"Getting PRACH resources\n");
-      //ue->prach_resources[eNB_id] = mac_xface->ue_get_rach(ue->Mod_id,
-      ue->CC_id,
-	frame_tx,
-	eNB_id,
-	nr_tti_tx);
-    LOG_D(PHY,"Got prach_resources for eNB %d address %p, RRCCommon %p\n",eNB_id,ue->prach_resources[eNB_id],UE_mac_inst[ue->Mod_id].radioResourceConfigCommon);
-    LOG_D(PHY,"Prach resources %p\n",ue->prach_resources[eNB_id]);
-  }
-}
-
-if (ue->prach_resources[eNB_id]!=NULL) {
-
-  ue->generate_prach=1;
-  ue->prach_cnt=0;
-#ifdef SMBV
-  ue->prach_resources[eNB_id]->ra_PreambleIndex = 19;
-#endif
-#ifdef OAI_EMU
-  ue->prach_PreambleIndex=ue->prach_resources[eNB_id]->ra_PreambleIndex;
-#endif
-
-  if (abstraction_flag == 0) {
-
-    LOG_I(PHY,"mode %d\n",mode);
-
-    if ((ue->mac_enabled==1) && (mode != calib_prach_tx)) {
-      ue->tx_power_dBm[nr_tti_tx] = ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+nr_get_PL(ue->Mod_id,ue->CC_id,eNB_id);
-    }
-    else {
-      ue->tx_power_dBm[nr_tti_tx] = ue->tx_power_max_dBm;
-      ue->prach_resources[eNB_id]->ra_PreambleIndex = 19;
-    }
-
-    LOG_I(PHY,"[UE  %d][RAPROC] Frame %d, nr_tti_rx %d : Generating PRACH, preamble %d,PL %d,  P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, PRACH TDD Resource index %d, RA-RNTI %d\n",
-	  ue->Mod_id,
-	  frame_tx,
-	  nr_tti_tx,
-	  ue->prach_resources[eNB_id]->ra_PreambleIndex,
-	  nr_get_PL(ue->Mod_id,ue->CC_id,eNB_id),
-	  ue->tx_power_dBm[nr_tti_tx],
-	  ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER,
-	  ue->prach_resources[eNB_id]->ra_TDD_map_index,
-	  ue->prach_resources[eNB_id]->ra_RNTI);
-
-    ue->tx_total_RE[nr_tti_tx] = 96;
-
-#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
-    ue->prach_vars[eNB_id]->amp = nr_get_tx_amp(ue->tx_power_dBm[nr_tti_tx],
-					     ue->tx_power_max_dBm,
-					     ue->frame_parms.N_RB_UL,
-					     6);
-#else
-    ue->prach_vars[eNB_id]->amp = AMP;
-#endif
-    if ((mode == calib_prach_tx) && (((proc->frame_tx&0xfffe)%100)==0))
-      LOG_D(PHY,"[UE  %d][RAPROC] Frame %d, nr_tti_rx %d : PRACH TX power %d dBm, amp %d\n",
-	    ue->Mod_id,
-	    proc->frame_rx,
-	    proc->nr_tti_tx,
-	    ue->tx_power_dBm[nr_tti_tx],
-	    ue->prach_vars[eNB_id]->amp);
-
-
-    //      start_meas(&ue->tx_prach);
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GENERATE_PRACH, VCD_FUNCTION_IN);
-    prach_power = generate_prach(ue,eNB_id,nr_tti_tx,frame_tx);
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GENERATE_PRACH, VCD_FUNCTION_OUT);
-    //      stop_meas(&ue->tx_prach);
-    LOG_D(PHY,"[UE  %d][RAPROC] PRACH PL %d dB, power %d dBm, digital power %d dB (amp %d)\n",
-	  ue->Mod_id,
-	  nr_get_PL(ue->Mod_id,ue->CC_id,eNB_id),
-	  ue->tx_power_dBm[nr_tti_tx],
-	  dB_fixed(prach_power),
-	  ue->prach_vars[eNB_id]->amp);
-  } else {
-    UE_transport_info[ue->Mod_id][ue->CC_id].cntl.prach_flag=1;
-    UE_transport_info[ue->Mod_id][ue->CC_id].cntl.prach_id=ue->prach_resources[eNB_id]->ra_PreambleIndex;
-  }
-
-  if (ue->mac_enabled==1){
-    //mac_xface->Msg1_transmitted(ue->Mod_id,
-    ue->CC_id,
-      frame_tx,
-      eNB_id);
- }
-
-LOG_I(PHY,"[UE  %d][RAPROC] Frame %d, nr_tti_rx %d: Generating PRACH (eNB %d) preamble index %d for UL, TX power %d dBm (PL %d dB), l3msg \n",
-      ue->Mod_id,frame_tx,nr_tti_tx,eNB_id,
-      ue->prach_resources[eNB_id]->ra_PreambleIndex,
-      ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+nr_get_PL(ue->Mod_id,ue->CC_id,eNB_id),
-      nr_get_PL(ue->Mod_id,ue->CC_id,eNB_id));
-
-}
-
-
-// if we're calibrating the PRACH kill the pointer to its resources so that the RA protocol doesn't continue
-if (mode == calib_prach_tx)
-  ue->prach_resources[eNB_id]=NULL;
-
-LOG_D(PHY,"[UE %d] frame %d nr_tti_rx %d : generate_prach %d, prach_cnt %d\n",
-      ue->Mod_id,frame_tx,nr_tti_tx,ue->generate_prach,ue->prach_cnt);
-
-ue->prach_cnt++;
-
-if (ue->prach_cnt==3)
-  ue->generate_prach=0;
-
-VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_OUT);
-}
-
 #endif
 
 
@@ -1547,6 +1401,8 @@ void nr_process_timing_advance(module_id_t Mod_id, uint8_t CC_id, uint8_t ta_com
 
   // scale the 16 factor in N_TA calculation in 38.213 section 4.2 according to the used FFT size
   switch (bwp_ul_NB_RB) {
+    case 32:  bw_scaling =  4; break;
+    case 66:  bw_scaling =  8; break;
     case 106: bw_scaling = 16; break;
     case 217: bw_scaling = 32; break;
     case 245: bw_scaling = 32; break;
@@ -1932,7 +1788,7 @@ if (abstraction_flag == 0) {
 #endif
 #if T_TRACER
   T(T_UE_PHY_PUSCH_TX_POWER, T_INT(eNB_id),T_INT(Mod_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx),T_INT(ue->tx_power_dBm[nr_tti_tx]),
-    T_INT(tx_amp),T_INT(ue->ulsch[eNB_id]->f_pusch),T_INT(nr_get_PL(Mod_id,0,eNB_id)),T_INT(nb_rb));
+    T_INT(tx_amp),T_INT(ue->ulsch[eNB_id]->f_pusch),T_INT(get_nr_PL(Mod_id,0,eNB_id)),T_INT(nb_rb));
 #endif
 
 #ifdef UE_DEBUG_TRACE
@@ -2307,7 +2163,7 @@ void ue_pucch_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_
 #endif
 #if T_TRACER
       T(T_UE_PHY_PUCCH_TX_POWER, T_INT(eNB_id),T_INT(Mod_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx),T_INT(ue->tx_power_dBm[nr_tti_tx]),
-	T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->g_pucch),T_INT(nr_get_PL(ue->Mod_id,ue->CC_id,eNB_id)));
+	T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->g_pucch),T_INT(get_nr_PL(ue->Mod_id,ue->CC_id,eNB_id)));
 #endif
 
 #ifdef UE_DEBUG_TRACE
@@ -2415,7 +2271,7 @@ void ue_pucch_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_
 #endif
 #if T_TRACER
       T(T_UE_PHY_PUCCH_TX_POWER, T_INT(eNB_id),T_INT(Mod_id), T_INT(frame_tx%1024), T_INT(nr_tti_tx),T_INT(ue->tx_power_dBm[nr_tti_tx]),
-	T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->g_pucch),T_INT(nr_get_PL(ue->Mod_id,ue->CC_id,eNB_id)));
+	T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][eNB_id][0]->g_pucch),T_INT(get_nr_PL(ue->Mod_id,ue->CC_id,eNB_id)));
 #endif
 #ifdef UE_DEBUG_TRACE
       LOG_I(PHY,"[UE  %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2 (RI or CQI), Po_PUCCH %d, isShortenPucch %d, amp %d\n",
@@ -2508,7 +2364,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,
                                 gNB_id,
                                 &ue->frame_parms);
 
-
+  //LOG_M("txdata.m","txs",ue->common_vars.txdata[0],1228800,1,1);
 
 
 /*
@@ -2537,6 +2393,136 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,
 }
 
 
+void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode) {
+
+  int frame_tx = proc->frame_tx;
+  int nr_tti_tx = proc->nr_tti_tx;
+  int prach_power;
+  uint16_t preamble_tx=50;
+  PRACH_RESOURCES_t prach_resources;
+
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_IN);
+
+  ue->generate_nr_prach=0;
+ if (ue->mac_enabled==0){
+    ue->prach_resources[eNB_id] = &prach_resources;
+ ue->prach_resources[eNB_id]->ra_PreambleIndex = preamble_tx;
+  ue->prach_resources[eNB_id]->ra_TDD_map_index = 0;
+ }
+
+  if (ue->mac_enabled==1){
+
+    // ask L2 for RACH transport
+    if ((mode != rx_calib_ue) && (mode != rx_calib_ue_med) && (mode != rx_calib_ue_byp) && (mode != no_L2_connect) ) {
+      LOG_D(PHY,"Getting PRACH resources\n");
+      //ue->prach_resources[eNB_id] = mac_xface->ue_get_rach(ue->Mod_id,ue->CC_id,frame_tx,eNB_id,nr_tti_tx);   
+   // LOG_D(PHY,"Got prach_resources for eNB %d address %p, RRCCommon %p\n",eNB_id,ue->prach_resources[eNB_id],UE_mac_inst[ue->Mod_id].radioResourceConfigCommon);  
+   // LOG_D(PHY,"Prach resources %p\n",ue->prach_resources[eNB_id]);
+  }
+}
+
+if (ue->prach_resources[eNB_id]!=NULL) {
+
+  ue->generate_nr_prach=1;
+  ue->prach_cnt=0;
+#ifdef SMBV
+ue->prach_resources[eNB_id]->ra_PreambleIndex = preamble_tx;
+#endif
+
+#ifdef OAI_EMU
+  ue->prach_PreambleIndex=ue->prach_resources[eNB_id]->ra_PreambleIndex;
+#endif
+
+  if (abstraction_flag == 0) {
+
+    LOG_I(PHY,"mode %d\n",mode);
+
+    if ((ue->mac_enabled==1) && (mode != calib_prach_tx)) {
+
+      ue->tx_power_dBm[nr_tti_tx] = ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+get_nr_PL(ue,eNB_id);
+    }
+    else {
+      ue->tx_power_dBm[nr_tti_tx] = ue->tx_power_max_dBm;
+      ue->prach_resources[eNB_id]->ra_PreambleIndex = preamble_tx; 
+    }
+
+   LOG_I(PHY,"[UE  %d][RAPROC] Frame %d, nr_tti_rx %d : Generating PRACH, preamble %d,PL %d,  P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, PRACH TDD Resource index %d, RA-RNTI %d\n",
+	  ue->Mod_id,
+	  frame_tx,
+	  nr_tti_tx,
+	  ue->prach_resources[eNB_id]->ra_PreambleIndex,
+	  get_nr_PL(ue,eNB_id),
+	  ue->tx_power_dBm[nr_tti_tx],
+	  ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER,
+	  ue->prach_resources[eNB_id]->ra_TDD_map_index,
+	  ue->prach_resources[eNB_id]->ra_RNTI);
+
+    ue->tx_total_RE[nr_tti_tx] = 96;
+
+#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_ADRV9371_ZC706)
+    ue->prach_vars[eNB_id]->amp = get_tx_amp(ue->tx_power_dBm[nr_tti_tx],
+					     ue->tx_power_max_dBm,
+					     ue->frame_parms.N_RB_UL,
+					     6);
+#else
+   ue->prach_vars[eNB_id]->amp = AMP;
+#endif
+   if ((mode == calib_prach_tx) && (((proc->frame_tx&0xfffe)%100)==0))
+      LOG_D(PHY,"[UE  %d][RAPROC] Frame %d, nr_tti_rx %d : PRACH TX power %d dBm, amp %d\n",
+	    ue->Mod_id,
+	    proc->frame_rx,
+	    proc->nr_tti_tx,
+	    ue->tx_power_dBm[nr_tti_tx],
+	    ue->prach_vars[eNB_id]->amp);
+
+
+   //       start_meas(&ue->tx_prach);
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GENERATE_PRACH, VCD_FUNCTION_IN);
+
+//    prach_power = generate_nr_prach(ue,eNB_id,nr_tti_tx,frame_tx);
+prach_power = generate_nr_prach(ue,0,9,0); //subframe number hardcoded according to the simulator
+
+    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GENERATE_PRACH, VCD_FUNCTION_OUT);
+    //      stop_meas(&ue->tx_prach);
+    LOG_D(PHY,"[UE  %d][RAPROC] PRACH PL %d dB, power %d dBm, digital power %d dB (amp %d)\n",
+	  ue->Mod_id,
+	  get_nr_PL(ue,eNB_id),
+	  ue->tx_power_dBm[nr_tti_tx],
+	  dB_fixed(prach_power),
+	  ue->prach_vars[eNB_id]->amp);
+  }/* else {
+    UE_transport_info[ue->Mod_id][ue->CC_id].cntl.prach_flag=1;
+    UE_transport_info[ue->Mod_id][ue->CC_id].cntl.prach_id=ue->prach_resources[eNB_id]->ra_PreambleIndex;
+  }*/ // commented for compiling as abstraction flag is 0
+
+  if (ue->mac_enabled==1){
+    //mac_xface->Msg1_transmitted(ue->Mod_id,ue->CC_id,frame_tx,eNB_id);
+ }
+
+LOG_I(PHY,"[UE  %d][RAPROC] Frame %d, nr_tti_rx %d: Generating PRACH (eNB %d) preamble index %d for UL, TX power %d dBm (PL %d dB), l3msg \n",
+      ue->Mod_id,frame_tx,nr_tti_tx,eNB_id,
+      ue->prach_resources[eNB_id]->ra_PreambleIndex,
+      ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+get_nr_PL(ue,eNB_id),
+      get_nr_PL(ue,eNB_id));
+
+}
+
+
+// if we're calibrating the PRACH kill the pointer to its resources so that the RA protocol doesn't continue
+if (mode == calib_prach_tx)
+  ue->prach_resources[eNB_id]=NULL;
+
+LOG_D(PHY,"[UE %d] frame %d nr_tti_rx %d : generate_nr_prach %d, prach_cnt %d\n",
+      ue->Mod_id,frame_tx,nr_tti_tx,ue->generate_nr_prach,ue->prach_cnt);
+
+ue->prach_cnt++;
+
+if (ue->prach_cnt==3)
+  ue->generate_nr_prach=0;
+
+VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_OUT);
+}
+
 /*
 void phy_procedures_UE_S_TX(PHY_VARS_NR_UE *ue,uint8_t eNB_id,uint8_t abstraction_flag,relaying_type_t r_type)
 {
@@ -2579,14 +2565,14 @@ void nr_ue_measurement_procedures(uint16_t l,    // symbol index of each slot [0
   if (l==2) {
     // UE measurements on symbol 0
       LOG_D(PHY,"Calling measurements nr_tti_rx %d, rxdata %p\n",nr_tti_rx,ue->common_vars.rxdata);
-
+/*
       nr_ue_measurements(ue,
 			  0,
 			  0,
 			  0,
 			  0,
 			  nr_tti_rx);
-			  
+*/			  
 			  //(nr_tti_rx*frame_parms->samples_per_tti+ue->rx_offset)%(frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)
 
 #if T_TRACER
@@ -2704,9 +2690,9 @@ void restart_phy(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc, uint8_t eNB_id,uint
 #endif //(0)
 
 void nr_ue_pbch_procedures(uint8_t eNB_id,
-						   PHY_VARS_NR_UE *ue,
-						   UE_nr_rxtx_proc_t *proc,
-						   uint8_t abstraction_flag)
+			   PHY_VARS_NR_UE *ue,
+			   UE_nr_rxtx_proc_t *proc,
+			   uint8_t abstraction_flag)
 {
   //  int i;
   //int pbch_tx_ant=0;
@@ -2728,7 +2714,7 @@ void nr_ue_pbch_procedures(uint8_t eNB_id,
 		   ue->pbch_vars[eNB_id],
 		   &ue->frame_parms,
 		   eNB_id,
-		   ue->nrUE_config.pbch_config.ssb_index,
+		   (ue->frame_parms.ssb_index)&7,
 		   SISO,
 		   ue->high_speed_flag);
 
@@ -2809,10 +2795,15 @@ unsigned int nr_get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb
 
 #ifdef NR_PDCCH_SCHED
 
-int nr_ue_pdcch_procedures(uint8_t eNB_id,
-						   PHY_VARS_NR_UE *ue,
-						   UE_nr_rxtx_proc_t *proc)
+int nr_ue_pdcch_procedures(uint8_t gNB_id,
+			   PHY_VARS_NR_UE *ue,
+			   UE_nr_rxtx_proc_t *proc)
 {
+  int frame_rx = proc->frame_rx;
+  int nr_tti_rx = proc->nr_tti_rx;
+  unsigned int dci_cnt=0;
+
+  /*
   //  unsigned int dci_cnt=0, i;  //removed for nr_ue_pdcch_procedures and added in the loop for nb_coreset_active
 #ifdef NR_PDCCH_SCHED_DEBUG
   printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_ue_pdcch_procedures() \n");
@@ -2821,10 +2812,10 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,
   int frame_rx = proc->frame_rx;
   int nr_tti_rx = proc->nr_tti_rx;
   NR_DCI_ALLOC_t dci_alloc_rx[8];
-  /*
-  uint8_t next1_thread_id = ue->current_thread_id[nr_tti_rx]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[nr_tti_rx]+1);
-  uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1);
-  */
+  
+  //uint8_t next1_thread_id = ue->current_thread_id[nr_tti_rx]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[nr_tti_rx]+1);
+  //uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1);
+  
 
   // table dci_fields_sizes_cnt contains dci_fields_sizes for each time a dci is decoded in the slot
   // each element represents the size in bits for each dci field, for each decoded dci -> [dci_cnt-1]
@@ -2834,14 +2825,14 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,
 
   int nb_searchspace_active=0;
   NR_UE_PDCCH **pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]];
-  NR_UE_PDCCH *pdcch_vars2 = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id];
+  NR_UE_PDCCH *pdcch_vars2 = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id];
   // s in TS 38.212 Subclause 10.1, for each active BWP the UE can deal with 10 different search spaces
   // Higher layers have updated the number of searchSpaces with are active in the current slot and this value is stored in variable nb_searchspace_total
   int nb_searchspace_total = pdcch_vars2->nb_search_space;
 
-  pdcch_vars[eNB_id]->crnti = 0x1234; //to be check how to set when using loop memory
+  pdcch_vars[gNB_id]->crnti = 0x1234; //to be check how to set when using loop memory
 
-  uint16_t c_rnti=pdcch_vars[eNB_id]->crnti;
+  uint16_t c_rnti=pdcch_vars[gNB_id]->crnti;
   uint16_t cs_rnti=0,new_rnti=0,tc_rnti=0;
   uint16_t p_rnti=P_RNTI;
   uint16_t si_rnti=SI_RNTI;
@@ -2877,22 +2868,22 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,
   for (nb_searchspace_active=0; nb_searchspace_active<nb_searchspace_total; nb_searchspace_active++){
     int nb_coreset_active=nb_searchspace_active;
     //int do_pdcch_monitoring_current_slot=1; // this variable can be removed and fapi is handling
-    /*
-     * The following code has been removed as it is handled by higher layers (fapi)
-     *
+    
+     // The following code has been removed as it is handled by higher layers (fapi)
+     //
      // Verify that monitoring is required at the slot nr_tti_rx. We will run pdcch procedure only if do_pdcch_monitoring_current_slot=1
      // For Type0-PDCCH searchspace, we need to calculate the monitoring slot from Tables 13-1 .. 13-15 in TS 38.213 Subsection 13
-     NR_UE_SLOT_PERIOD_OFFSET_t sl_period_offset_mon = pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSlotPeriodicityAndOffset;
-     if (sl_period_offset_mon == nr_sl1) {
-     do_pdcch_monitoring_current_slot=1; // PDCCH monitoring in every slot
-     } else if (nr_tti_rx%(uint16_t)sl_period_offset_mon == pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSlotPeriodicityAndOffset_offset) {
-     do_pdcch_monitoring_current_slot=1; // PDCCH monitoring in every monitoringSlotPeriodicityAndOffset slot with offset
-     }*/
-    /*
-     * FIXME
-     * For PDCCH monitoring when overlap with SS/PBCH according to 38.213 v15.1.0 Section 10
-     * To be implemented LATER !!!
-     */
+     //NR_UE_SLOT_PERIOD_OFFSET_t sl_period_offset_mon = pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSlotPeriodicityAndOffset;
+     //if (sl_period_offset_mon == nr_sl1) {
+     //do_pdcch_monitoring_current_slot=1; // PDCCH monitoring in every slot
+     //} else if (nr_tti_rx%(uint16_t)sl_period_offset_mon == pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSlotPeriodicityAndOffset_offset) {
+     //do_pdcch_monitoring_current_slot=1; // PDCCH monitoring in every monitoringSlotPeriodicityAndOffset slot with offset
+     //}
+    
+     // FIXME
+     // For PDCCH monitoring when overlap with SS/PBCH according to 38.213 v15.1.0 Section 10
+     // To be implemented LATER !!!
+     
     //int _offset,_index,_M;
     //int searchSpace_id                              = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceId;
 
@@ -2912,11 +2903,11 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,
       // at the moment we will not take into consideration this variable and we will consider that the OFDM symbol offset is always the first OFDM in a symbol
       uint16_t symbol_within_slot_mon                 = pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSymbolWithinSlot;
       // get the remaining parameters describing the current SEARCHSPACE:     // FIXME! To be defined where we get this information from
-      /*NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1         = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1;
-      NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L2         = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel2;
-      NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L4         = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel4;
-      NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L8         = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel8;
-      NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16        = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16;*/
+      //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1         = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1;
+      //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L2         = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel2;
+      //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L4         = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel4;
+      //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L8         = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel8;
+      //NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16        = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16;
                                                                                                   // FIXME! A table of five enum elements
       // searchSpaceType indicates whether this is a common search space or a UE-specific search space
       //int searchSpaceType                             = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceType.type;
@@ -2926,27 +2917,27 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,
                 searchSpaceType);
       #endif
 
-      /*while ((searchSpace_coreset_id != pdcch_vars2->coreset[nb_coreset_active].controlResourceSetId) && (nb_coreset_active<nb_coreset_total)) {
+      //while ((searchSpace_coreset_id != pdcch_vars2->coreset[nb_coreset_active].controlResourceSetId) && (nb_coreset_active<nb_coreset_total)) {
         // we need to identify the CORESET associated to the active searchSpace
-        nb_coreset_active++;
+        //nb_coreset_active++;
       if (nb_coreset_active >= nb_coreset_total) return 0; // the coreset_id could not be found. There is a problem
-      }*/
+      }
 
 
-    /*
-     * we do not need these parameters yet
-     *
+    
+     //we do not need these parameters yet
+    
      // get the parameters describing the current CORESET
-     int coreset_duration                                      = pdcch_vars2->coreset[nb_coreset_active].duration;
-     uint64_t coreset_freq_dom                                 = pdcch_vars2->coreset[nb_coreset_active].frequencyDomainResources;
-     int coreset_shift_index                                   = pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.shiftIndex;
-     NR_UE_CORESET_REG_bundlesize_t coreset_bundlesize         = pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.reg_bundlesize;
-     NR_UE_CORESET_interleaversize_t coreset_interleaversize   = pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.interleaversize;
-     NR_UE_CORESET_precoder_granularity_t precoder_granularity = pdcch_vars2->coreset[nb_coreset_active].precoderGranularity;
-     int tci_statesPDCCH                                       = pdcch_vars2->coreset[nb_coreset_active].tciStatesPDCCH;
-     int tci_present                                           = pdcch_vars2->coreset[nb_coreset_active].tciPresentInDCI;
-     uint16_t pdcch_DMRS_scrambling_id                         = pdcch_vars2->coreset[nb_coreset_active].pdcchDMRSScramblingID;
-    */
+     //int coreset_duration                                      = pdcch_vars2->coreset[nb_coreset_active].duration;
+     //uint64_t coreset_freq_dom                                 = pdcch_vars2->coreset[nb_coreset_active].frequencyDomainResources;
+     //int coreset_shift_index                                   = pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.shiftIndex;
+    // NR_UE_CORESET_REG_bundlesize_t coreset_bundlesize         = pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.reg_bundlesize;
+    // NR_UE_CORESET_interleaversize_t coreset_interleaversize   = pdcch_vars2->coreset[nb_coreset_active].cce_reg_mappingType.interleaversize;
+    // NR_UE_CORESET_precoder_granularity_t precoder_granularity = pdcch_vars2->coreset[nb_coreset_active].precoderGranularity;
+    // int tci_statesPDCCH                                       = pdcch_vars2->coreset[nb_coreset_active].tciStatesPDCCH;
+    // int tci_present                                           = pdcch_vars2->coreset[nb_coreset_active].tciPresentInDCI;
+    // uint16_t pdcch_DMRS_scrambling_id                         = pdcch_vars2->coreset[nb_coreset_active].pdcchDMRSScramblingID;
+    
 
     // A set of PDCCH candidates for a UE to monitor is defined in terms of PDCCH search spaces.
     // Searchspace types:
@@ -2972,14 +2963,14 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,
 
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_IN);
 #ifdef NR_PDCCH_SCHED_DEBUG
-      printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_rx_pdcch with eNB_id=%d (nb_coreset_active=%d, (symbol_within_slot_mon&0x3FFF)=%d, searchSpaceType=%d)\n",
-                  eNB_id,nb_coreset_active,(symbol_within_slot_mon&0x3FFF),
+      printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_rx_pdcch with gNB_id=%d (nb_coreset_active=%d, (symbol_within_slot_mon&0x3FFF)=%d, searchSpaceType=%d)\n",
+                  gNB_id,nb_coreset_active,(symbol_within_slot_mon&0x3FFF),
                   searchSpaceType);
 #endif
         nr_rx_pdcch(ue,
                     proc->frame_rx,
                     nr_tti_rx,
-                    eNB_id,
+                    gNB_id,
                     //(ue->frame_parms.mode1_flag == 1) ? SISO : ALAMOUTI,
                     SISO,
                     ue->high_speed_flag,
@@ -2993,108 +2984,51 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,
                   searchSpaceType);
 #endif
 
-        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_OUT);
-        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_IN);
+  */
+  
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_IN);
+  nr_rx_pdcch(ue,
+	      proc->frame_rx,
+	      nr_tti_rx);  
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_OUT);
+  
 
-        crc_scrambled_t crc_scrambled;
-        format_found_t format_found=255;
-        
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_IN);
 
 #ifdef NR_PDCCH_SCHED_DEBUG
-	printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_dci_decoding_procedure with eNB_id=%d (n_RB_ULBWP=%d, n_RB_DLBWP=%d, searchSpaceType=%d, nb_searchspace_active=%d, nb_coreset_active=%d)\n",
-	       eNB_id,
-	       pdcch_vars2->n_RB_BWP[nb_searchspace_active],
-	       pdcch_vars2->n_RB_BWP[nb_searchspace_active],
-	       searchSpaceType,
-	       nb_searchspace_active,
-	       nb_coreset_active);
-	
+  printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_dci_decoding_procedure with (nb_searchspace_active=%d)\n",
+	 pdcch_vars->nb_search_space);
 #endif
-	
 
-	dci_cnt += nr_dci_decoding_procedure(nb_searchspace_active,
-					     nb_coreset_active,
-					     ue,
-					     &dci_alloc_rx[dci_cnt],
-					     searchSpaceType,  // if we're in PUSCH don't listen to common search space,
-					     // later when we need paging or RA during connection, update this ...
-					     eNB_id,
-					     nr_tti_rx,
-					     dci_fields_sizes_cnt,
-					     pdcch_vars2->n_RB_BWP[nb_searchspace_active],
-					     pdcch_vars2->n_RB_BWP[nb_searchspace_active],
-					     &crc_scrambled,
-					     &format_found,
-					     crc_scrambled_values);
+  fapi_nr_dci_indication_t dci_ind;
+  nr_downlink_indication_t dl_indication;
+  memset((void*)&dci_ind,0,sizeof(dci_ind));
+  memset((void*)&dl_indication,0,sizeof(dl_indication));
+  dci_cnt = nr_dci_decoding_procedure(ue,
+				      proc->frame_rx,
+				      nr_tti_rx,
+				      &dci_ind);
+
 #ifdef NR_PDCCH_SCHED_DEBUG
-	printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%u\n",dci_cnt);
+  LOG_I(PHY,"<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Ending function nr_dci_decoding_procedure() -> dci_cnt=%u\n",dci_cnt);
 #endif
+  
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_OUT);
+  //LOG_D(PHY,"[UE  %d][PUSCH] Frame %d nr_tti_rx %d PHICH RX\n",ue->Mod_id,frame_rx,nr_tti_rx);
+
+  for (int i=0; i<dci_cnt; i++) {
+    LOG_D(PHY,"[UE  %d] AbsSubFrame %d.%d, Mode %s: DCI found %i --> rnti %x : format %d\n",
+	  ue->Mod_id,frame_rx%1024,nr_tti_rx,nr_mode_string[ue->UE_mode[gNB_id]],
+	  i,
+	  dci_ind.dci_list[i].rnti,
+	  dci_ind.dci_list[i].dci_format);
+  }
+  ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][gNB_id]->dci_received += dci_cnt;
 
-        VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_OUT);
-        //LOG_D(PHY,"[UE  %d][PUSCH] Frame %d nr_tti_rx %d PHICH RX\n",ue->Mod_id,frame_rx,nr_tti_rx);
-
+  dci_ind.number_of_dcis = dci_cnt;
     /*
-    uint8_t *nCCE_current = &ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->nCCE[nr_tti_rx];
-    uint8_t *nCCE_dest = &ue->pdcch_vars[next1_thread_id][eNB_id]->nCCE[nr_tti_rx];
-    uint8_t *nCCE_dest1 = &ue->pdcch_vars[next2_thread_id][eNB_id]->nCCE[nr_tti_rx];
-    memcpy(nCCE_dest, nCCE_current, sizeof(uint8_t));
-    memcpy(nCCE_dest1, nCCE_current, sizeof(uint8_t));
-
-    LOG_D(PHY,"current_thread %d next1_thread %d next2_thread %d \n", ue->current_thread_id[nr_tti_rx], next1_thread_id, next2_thread_id);
-    */
-
-    LOG_D(PHY,"[UE  %d] AbsSubFrame %d.%d, Mode %s: DCI found %i --> rnti %x / crnti %x : format %d\n",
-	  ue->Mod_id,frame_rx%1024,nr_tti_rx,nr_mode_string[ue->UE_mode[eNB_id]],
-	  dci_cnt,
-	  dci_alloc_rx[0].rnti,
-	  ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->crnti,
-	  dci_alloc_rx[0].format );
-    ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dci_received += dci_cnt;
-
-#ifdef EMOS
-    //emos_dump_UE.dci_cnt[nr_tti_rx] = dci_cnt;
-#endif
-
-    dci_ind.number_of_dcis = dci_cnt;
-
     for (int i=0; i<dci_cnt; i++) {
-      /*
-       * This is the NR part
-       */
-      if ((dci_alloc_rx[i].format == format0_0)){
-      }
-      
-      if (dci_alloc_rx[i].format == format1_0) {
-	if ((dci_alloc_rx[i].rnti != crc_scrambled_values[_P_RNTI_]) &&
-	    (dci_alloc_rx[i].rnti != crc_scrambled_values[_SI_RNTI_]) &&
-	    (dci_alloc_rx[i].rnti != crc_scrambled_values[_RA_RNTI_]))
-	  ue->dlsch_received[eNB_id]++;
-	
-	if (dci_alloc_rx[i].rnti == crc_scrambled_values[_SI_RNTI_])
-	  ue->dlsch_SI_received[eNB_id]++;
-	if (dci_alloc_rx[i].rnti == crc_scrambled_values[_P_RNTI_])
-	  ue->dlsch_p_received[eNB_id]++;
-	if (dci_alloc_rx[i].rnti == crc_scrambled_values[_RA_RNTI_])
-	  ue->dlsch_ra_received[eNB_id]++;
-      }
       
-      if ((dci_alloc_rx[i].format == format2_0)){
-      }
-      if ((dci_alloc_rx[i].format == format2_1)){
-      }
-      if ((dci_alloc_rx[i].format == format2_2)){
-      }
-      if ((dci_alloc_rx[i].format == format2_3)){
-      }
-      if ((dci_alloc_rx[i].format == format0_1)){ // This format not implemented at a first time. FIXME
-      }
-      if ((dci_alloc_rx[i].format == format1_1)){ // This format not implemented at a first time. FIXME
-      }
-      
-	uint8_t status=0;
-	
-	LOG_D(PHY,"<-NR_PDCCH_PHY_PROCEDURES_UE (nr_ue_pdcch_procedures)-> dci_format=%d, rnti=%d, dci_length=%d, dci_pdu[0]=0x%lx, dci_pdu[1]=0x%lx\n",dci_alloc_rx[i].format,dci_alloc_rx[i].rnti,dci_alloc_rx[i].dci_length,dci_alloc_rx[i].dci_pdu[0],dci_alloc_rx[i].dci_pdu[1]);
-	
 	memset(&dci_ind.dci_list[i].dci,0,sizeof(fapi_nr_dci_pdu_rel15_t));
 	
 	dci_ind.dci_list[i].rnti = dci_alloc_rx[i].rnti;
@@ -3103,7 +3037,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,
 	dci_ind.dci_list[i].N_CCE = (int)dci_alloc_rx[i].L;
 	
 	status = nr_extract_dci_info(ue,
-				     eNB_id,
+				     gNB_id,
 				     ue->frame_parms.frame_type,
 				     dci_alloc_rx[i].dci_length,
 				     dci_alloc_rx[i].rnti,
@@ -3123,36 +3057,15 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,
 	
 	LOG_D(PHY,"<-NR_PDCCH_PHY_PROCEDURES_UE (nr_ue_pdcch_procedures)-> Ending function nr_extract_dci_info()\n");
 	
-	/*
-       nr_generate_ue_ul_dlsch_params_from_dci(ue,
-					       eNB_id,
-					       frame_rx,
-					       nr_tti_rx,
-					       dci_alloc_rx[i].dci_pdu,
-					       dci_alloc_rx[i].rnti,
-					       dci_alloc_rx[i].dci_length,
-					       dci_alloc_rx[i].format,
-					       ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id],
-					       ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id],
-					       ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id],
-					       ue->ulsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0],
-					       &ue->frame_parms,
-					       ue->pdsch_config_dedicated,
-					       ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id],
-					       dci_fields_sizes_cnt[i],
-					       pdcch_vars2->n_RB_BWP[nb_searchspace_active],
-					       pdcch_vars2->n_RB_BWP[nb_searchspace_active],
-					       crc_scrambled_values,
-					       &nr_dci_info_extracted);
-  */
 
         
       } // end for loop dci_cnt
+    */
 
     // fill dl_indication message
     dl_indication.module_id = ue->Mod_id;
     dl_indication.cc_id = ue->CC_id;
-    dl_indication.gNB_index = eNB_id;
+    dl_indication.gNB_index = gNB_id;
     dl_indication.frame = frame_rx;
     dl_indication.slot = nr_tti_rx;
     dl_indication.rx_ind = NULL; //no data, only dci for now
@@ -3164,10 +3077,8 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,
 #if UE_TIMING_TRACE
   stop_meas(&ue->dlsch_rx_pdcch_stats);
 #endif
+    
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PDCCH_PROCEDURES, VCD_FUNCTION_OUT);
-
-
-  } // end for loop nb_searchspace_active
   return(dci_cnt);
 }
 #endif // NR_PDCCH_SCHED
@@ -3365,25 +3276,31 @@ void nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB
 
   if (!dlsch1)  {
     int harq_pid = dlsch0->current_harq_pid;
+    uint16_t BWPStart       = dlsch0->harq_processes[harq_pid]->BWPStart;
+    //    uint16_t BWPSize        = dlsch0->harq_processes[harq_pid]->BWPSize;
     uint16_t pdsch_start_rb = dlsch0->harq_processes[harq_pid]->start_rb;
     uint16_t pdsch_nb_rb =  dlsch0->harq_processes[harq_pid]->nb_rb;
     uint16_t s0 =  dlsch0->harq_processes[harq_pid]->start_symbol;
     uint16_t s1 =  dlsch0->harq_processes[harq_pid]->nb_symbols;
 
-    LOG_D(PHY,"[UE %d] PDSCH type %d active in nr_tti_rx %d, harq_pid %d, rb_start %d, nb_rb %d, symbol_start %d, nb_symbols %d\n",ue->Mod_id,pdsch,nr_tti_rx,harq_pid,pdsch_start_rb,pdsch_nb_rb,s0,s1);
-
-    for (m = s0; m < (s1 + s0); m++) {
+    LOG_D(PHY,"[UE %d] PDSCH type %d active in nr_tti_rx %d, harq_pid %d, rb_start %d, nb_rb %d, symbol_start %d, nb_symbols %d, DMRS mask %x\n",ue->Mod_id,pdsch,nr_tti_rx,harq_pid,pdsch_start_rb,pdsch_nb_rb,s0,s1,dlsch0->harq_processes[harq_pid]->dlDmrsSymbPos);
 
-      if (m==s0)
+    // do channel estimation for first DMRS only
+    for (m = s0; m < 3; m++) {
+      if (((1<<m)&dlsch0->harq_processes[harq_pid]->dlDmrsSymbPos) > 0) {
 	nr_pdsch_channel_estimation(ue,
 				    0 /*eNB_id*/,
 				    nr_tti_rx,
 				    0 /*p*/,
 				    m,
-				    ue->frame_parms.first_carrier_offset+pdsch_start_rb*12,
+				    ue->frame_parms.first_carrier_offset+(BWPStart + pdsch_start_rb)*12,
 				    pdsch_nb_rb);
-      
-
+	LOG_D(PHY,"Channel Estimation in symbol %d\n",m);
+	break;
+      }
+    }
+    for (m = s0; m < (s1 + s0); m++) {
+ 
       dual_stream_UE = 0;
       eNB_id_i = eNB_id+1;
       i_mod = 0;
@@ -3797,7 +3714,7 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
 
       LOG_D(PHY," ------ end ldpc decoder for AbsSubframe %d.%d ------  \n", frame_rx, nr_tti_rx);
 
-      LOG_I(PHY, "harq_pid: %d, TBS expected dlsch0: %d, TBS expected dlsch1: %d  \n",harq_pid, dlsch0->harq_processes[harq_pid]->TBS, dlsch1->harq_processes[harq_pid]->TBS);
+      LOG_D(PHY, "harq_pid: %d, TBS expected dlsch0: %d, TBS expected dlsch1: %d  \n",harq_pid, dlsch0->harq_processes[harq_pid]->TBS, dlsch1->harq_processes[harq_pid]->TBS);
       
       if(ret<dlsch0->max_ldpc_iterations+1){
       // fill dl_indication message
@@ -3861,6 +3778,8 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
 
         // scale the 16 factor in N_TA calculation in 38.213 section 4.2 according to the used FFT size
         switch (ue->frame_parms.N_RB_DL) {
+          case 32:  bw_scaling =  4; break;
+          case 66:  bw_scaling =  8; break;
           case 106: bw_scaling = 16; break;
           case 217: bw_scaling = 32; break;
           case 245: bw_scaling = 32; break;
@@ -4243,20 +4162,20 @@ void *UE_thread_slot1_dl_processing(void *arg) {
 #endif
 
 
-int is_pbch_in_slot(fapi_nr_pbch_config_t *pbch_config, int frame, int slot, int periodicity, uint16_t slots_per_frame)  {
+int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_FRAME_PARMS *fp)  {
 
-  int ssb_slot_decoded = (pbch_config->ssb_index)/2;
+  int ssb_slot_decoded = (fp->ssb_index>>1) + ((fp->ssb_index>>4)<<1); //slot in which the decoded SSB can be found
 
-  if (periodicity == 5) {  
+  if (config->ssb_table.ssb_period == 0) {  
     // check for pbch in corresponding slot each half frame
-    if (pbch_config->half_frame_bit)
-      return(slot == ssb_slot_decoded || slot == ssb_slot_decoded - slots_per_frame/2);
+    if (fp->half_frame_bit)
+      return(slot == ssb_slot_decoded || slot == ssb_slot_decoded - fp->slots_per_frame/2);
     else
-      return(slot == ssb_slot_decoded || slot == ssb_slot_decoded + slots_per_frame/2);
+      return(slot == ssb_slot_decoded || slot == ssb_slot_decoded + fp->slots_per_frame/2);
   }
   else {
     // if the current frame is supposed to contain ssb
-    if (!((frame-(pbch_config->system_frame_number))%(periodicity/10)))
+    if (!(frame%(1<<(config->ssb_table.ssb_period-1))))
       return(slot == ssb_slot_decoded);
     else
       return 0;
@@ -4275,14 +4194,14 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
   int slot_pbch;
   NR_UE_PDCCH *pdcch_vars  = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0];
   NR_UE_DLSCH_t   **dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id];
+  fapi_nr_config_request_t *cfg = &ue->nrUE_config;
   uint8_t harq_pid = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->current_harq_pid;
   NR_DL_UE_HARQ_t *dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
   uint16_t nb_symb_sch = dlsch0_harq->nb_symbols;
   uint16_t start_symb_sch = dlsch0_harq->start_symbol;
-  uint8_t nb_symb_pdcch = pdcch_vars->coreset[0].duration;
-  uint8_t ssb_periodicity = 10;// ue->ssb_periodicity; // initialized to 5ms in nr_init_ue for scenarios where UE is not configured (otherwise acquired by cell configuration from gNB or LTE)
+  uint8_t nb_symb_pdcch = pdcch_vars->nb_search_space > 0 ? pdcch_vars->pdcch_config[0].coreset.duration : 0;
   uint8_t dci_cnt = 0;
-  fapi_nr_pbch_config_t *pbch_config = &ue->nrUE_config.pbch_config;
+  NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
   
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN);
   
@@ -4293,22 +4212,13 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
   uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1);
   */
 
-  uint8_t coreset_start=0, coreset_start_set=0;
-  uint16_t coreset_count = 0;
-  uint64_t coreset_freq_dom  = pdcch_vars->coreset[0].frequencyDomainResources;
-  for (int i = 0; i < 45; i++) {
-    if (((coreset_freq_dom & 0x1FFFFFFFFFFF) >> (44-i)) & 0x1) {
-      if (!coreset_start_set) {
-        coreset_start = i;
-        coreset_start_set = 1;
-      }
-      coreset_count++;
-    }
-  }
-  uint16_t coreset_nb_rb = 6 * coreset_count;
-  uint16_t coreset_start_rb = 6 * coreset_start;
+
+  int coreset_nb_rb=0;
+  int coreset_start_rb=0;
+  if (pdcch_vars->nb_search_space > 0)
+    get_coreset_rballoc(pdcch_vars->pdcch_config[0].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb);
   
-  slot_pbch = is_pbch_in_slot(pbch_config, frame_rx, nr_tti_rx, ssb_periodicity, ue->frame_parms.slots_per_frame);
+  slot_pbch = is_pbch_in_slot(cfg, frame_rx, nr_tti_rx, fp);
 
   // looking for pbch only in slot where it is supposed to be
   if ((ue->decode_MIB == 1) && slot_pbch)
@@ -4318,7 +4228,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
       for (int i=1; i<4; i++) {
 
 	nr_slot_fep(ue,
-		    (ue->symbol_offset+i)%(ue->frame_parms.symbols_per_slot),
+		    (ue->symbol_offset+i)%(fp->symbols_per_slot),
 		    nr_tti_rx,
 		    0,
 		    0);
@@ -4326,7 +4236,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
 #if UE_TIMING_TRACE
   	start_meas(&ue->dlsch_channel_estimation_stats);
 #endif
-   	nr_pbch_channel_estimation(ue,0,nr_tti_rx,(ue->symbol_offset+i)%(ue->frame_parms.symbols_per_slot),i-1,(pbch_config->ssb_index)&7,pbch_config->half_frame_bit);
+   	nr_pbch_channel_estimation(ue,0,nr_tti_rx,(ue->symbol_offset+i)%(fp->symbols_per_slot),i-1,(fp->ssb_index)&7,fp->half_frame_bit);
 #if UE_TIMING_TRACE
   	stop_meas(&ue->dlsch_channel_estimation_stats);
 #endif
@@ -4336,12 +4246,12 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
 
       if (ue->no_timing_correction==0) {
         LOG_I(PHY,"start adjust sync slot = %d no timing %d\n", nr_tti_rx, ue->no_timing_correction);
-        nr_adjust_synch_ue(&ue->frame_parms,
-      		             ue,
-  						 eNB_id,
-  						 nr_tti_rx,
-  						 0,
-  						 16384);
+        nr_adjust_synch_ue(fp,
+      		           ue,
+  			   eNB_id,
+  			   nr_tti_rx,
+  			   0,
+  			   16384);
       }
     }
 
@@ -4361,12 +4271,16 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
 				0,
 				0);
 
-    nr_pdcch_channel_estimation(ue,
-    		                    0,
-								nr_tti_rx,
-								l,
-								ue->frame_parms.first_carrier_offset+coreset_start_rb*12,
-								coreset_nb_rb);
+    // note: this only works if RBs for PDCCH are contigous!
+    LOG_D(PHY,"pdcch_channel_estimation: first_carrier_offset %d, BWPStart %d, coreset_start_rb %d\n",
+	  fp->first_carrier_offset,pdcch_vars->pdcch_config[0].BWPStart,coreset_start_rb);
+    if (coreset_nb_rb > 0)
+      nr_pdcch_channel_estimation(ue,
+				  0,
+				  nr_tti_rx,
+				  l,
+				  fp->first_carrier_offset+(pdcch_vars->pdcch_config[0].BWPStart + coreset_start_rb)*12,
+				  coreset_nb_rb);
     
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT);
 #if UE_TIMING_TRACE
@@ -4382,7 +4296,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
 
   if (dci_cnt > 0) {
 
-    LOG_I(PHY,"[UE  %d] Frame %d, nr_tti_rx %d: found %d DCIs\n",ue->Mod_id,frame_rx,nr_tti_rx,dci_cnt);
+    LOG_D(PHY,"[UE  %d] Frame %d, nr_tti_rx %d: found %d DCIs\n",ue->Mod_id,frame_rx,nr_tti_rx,dci_cnt);
 
   } else {
     LOG_D(PHY,"[UE  %d] Frame %d, nr_tti_rx %d: No DCIs found\n",ue->Mod_id,frame_rx,nr_tti_rx);
@@ -4394,7 +4308,11 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
     LOG_D(PHY," ------ --> PDSCH ChannelComp/LLR Frame.slot %d.%d ------  \n", frame_rx%1024, nr_tti_rx);
     //to update from pdsch config
     start_symb_sch = dlsch0_harq->start_symbol;
-    nr_gold_pdsch(ue,start_symb_sch,0, 1);
+    int symb_dmrs=-1;
+    for (int i=0;i<4;i++) if (((1<<i)&dlsch0_harq->dlDmrsSymbPos) > 0) {symb_dmrs=i;break;}
+    AssertFatal(symb_dmrs>=0,"no dmrs in 0..3\n");
+    LOG_D(PHY,"Initializing dmrs for symb %d DMRS mask %x\n",symb_dmrs,dlsch0_harq->dlDmrsSymbPos);
+    nr_gold_pdsch(ue,symb_dmrs,0, 1);
 
     nb_symb_sch = dlsch0_harq->nb_symbols;
     
@@ -4430,11 +4348,11 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
     nr_ue_measurement_procedures(2,ue,proc,eNB_id,nr_tti_rx,mode);
 
     /*
-    write_output("rxF.m","rxF",&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],ue->frame_parms.ofdm_symbol_size*14,1,1);
-    write_output("rxF_ch.m","rxFch",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates[0][0],ue->frame_parms.ofdm_symbol_size*14,1,1);
+    write_output("rxF.m","rxF",&ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],fp->ofdm_symbol_size*14,1,1);
+    write_output("rxF_ch.m","rxFch",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates[0][0],fp->ofdm_symbol_size*14,1,1);
     write_output("rxF_ch_ext.m","rxFche",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->dl_ch_estimates_ext[0][2*50*12],50*12,1,1);
     write_output("rxF_ext.m","rxFe",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_ext[0][0],50*12*14,1,1);
-    write_output("rxF_comp.m","rxFc",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_comp0[0][0],ue->frame_parms.N_RB_DL*12*14,1,1);
+    write_output("rxF_comp.m","rxFc",&ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->rxdataF_comp0[0][0],fp->N_RB_DL*12*14,1,1);
     write_output("rxF_llr.m","rxFllr",ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->llr[0],(nb_symb_sch-1)*50*12+50*6,1,0);
     */
     
@@ -4483,7 +4401,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
   // do procedures for C-RNTI
   if (ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->active == 1) {
     
-	  LOG_I(PHY, "DLSCH data reception at nr_tti_rx: %d \n \n", nr_tti_rx);
+    LOG_D(PHY, "DLSCH data reception at nr_tti_rx: %d \n \n", nr_tti_rx);
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN);
 
 #if UE_TIMING_TRACE
@@ -4525,16 +4443,16 @@ start_meas(&ue->generic_stat);
        //write_output("decoder_llr.m","decllr",dlsch_llr,G,1,0);
        //write_output("llr.m","llr",  &ue->pdsch_vars[eNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0);
 
-       write_output("rxdataF0_current.m"    , "rxdataF0", &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1);
-       //write_output("rxdataF0_previous.m"    , "rxdataF0_prev_sss", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1);
+       write_output("rxdataF0_current.m"    , "rxdataF0", &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].rxdataF[0][0],14*fp->ofdm_symbol_size,1,1);
+       //write_output("rxdataF0_previous.m"    , "rxdataF0_prev_sss", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*fp->ofdm_symbol_size,1,1);
 
-       //write_output("rxdataF0_previous.m"    , "rxdataF0_prev", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1);
+       //write_output("rxdataF0_previous.m"    , "rxdataF0_prev", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*fp->ofdm_symbol_size,1,1);
 
-       write_output("dl_ch_estimates.m", "dl_ch_estimates_sfn5", &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[0][0][0],14*ue->frame_parms.ofdm_symbol_size,1,1);
-       write_output("dl_ch_estimates_ext.m", "dl_ch_estimatesExt_sfn5", &ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->dl_ch_estimates_ext[0][0],14*ue->frame_parms.N_RB_DL*12,1,1);
-       write_output("rxdataF_comp00.m","rxdataF_comp00",         &ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->rxdataF_comp0[0][0],14*ue->frame_parms.N_RB_DL*12,1,1);
-       //write_output("magDLFirst.m", "magDLFirst", &phy_vars_ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->dl_ch_mag0[0][0],14*frame_parms->N_RB_DL*12,1,1);
-       //write_output("magDLSecond.m", "magDLSecond", &phy_vars_ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->dl_ch_magb0[0][0],14*frame_parms->N_RB_DL*12,1,1);
+       write_output("dl_ch_estimates.m", "dl_ch_estimates_sfn5", &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[nr_tti_rx]].dl_ch_estimates[0][0][0],14*fp->ofdm_symbol_size,1,1);
+       write_output("dl_ch_estimates_ext.m", "dl_ch_estimatesExt_sfn5", &ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->dl_ch_estimates_ext[0][0],14*fp->N_RB_DL*12,1,1);
+       write_output("rxdataF_comp00.m","rxdataF_comp00",         &ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->rxdataF_comp0[0][0],14*fp->N_RB_DL*12,1,1);
+       //write_output("magDLFirst.m", "magDLFirst", &phy_vars_ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->dl_ch_mag0[0][0],14*fp->N_RB_DL*12,1,1);
+       //write_output("magDLSecond.m", "magDLSecond", &phy_vars_ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][0]->dl_ch_magb0[0][0],14*fp->N_RB_DL*12,1,1);
 
        AssertFatal (0,"");
   }
@@ -4716,3 +4634,4 @@ uint8_t nr_is_ri_TXOp(PHY_VARS_NR_UE *ue,
   else
     return(0);
 }
+
diff --git a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c
index d388d6877be..9632291e671 100644
--- a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c
+++ b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c
@@ -70,17 +70,17 @@
 
 int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue,
                               uint8_t gNB_id,
-							  UE_nr_rxtx_proc_t *proc,
-							  pucch_format_nr_t pucch_format,
-							  int nb_of_prbs,
-							  int N_sc_ctrl_RB,
-							  int N_symb_PUCCH,
-							  int O_UCI,
-							  int O_SR,
-							  int O_CSI,
-							  int O_ACK,
+                              UE_nr_rxtx_proc_t *proc,
+                              pucch_format_nr_t pucch_format,
+                              int nb_of_prbs,
+                              int N_sc_ctrl_RB,
+                              int N_symb_PUCCH,
+                              int O_UCI,
+                              int O_SR,
+                              int O_CSI,
+                              int O_ACK,
                               int O_CRC,
-							  int n_HARQ_ACK) {
+                              int n_HARQ_ACK) {
 
   int16_t P_O_NOMINAL_PUCCH = ue->pucch_config_common_nr[gNB_id].p0_nominal;
   PUCCH_PowerControl_t *power_config = &ue->pucch_config_dedicated_nr[gNB_id].pucch_PowerControl;
@@ -104,7 +104,7 @@ int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue,
 
   int P_O_PUCCH = P_O_NOMINAL_PUCCH + P_O_UE_PUCCH;
 
-  int16_t PL = nr_get_PL(ue->Mod_id, ue->CC_id, gNB_id); /* LTE function because NR path loss not yet implemented FFS TODO NR */
+  int16_t PL = get_nr_PL(ue, gNB_id); /* LTE function because NR path loss not yet implemented FFS TODO NR */
 
   int16_t delta_F_PUCCH =  power_config->deltaF_PUCCH_f[pucch_format];
 
@@ -215,3 +215,4 @@ int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue,
 
   return (pucch_power);
 }
+
diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c
index 512db60510d..326c617dfb5 100644
--- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c
+++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c
@@ -1,5 +1,4 @@
-/*
- * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
+/* 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
@@ -213,11 +212,11 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
 
       /* sr_payload = 1 means that this is a positive SR, sr_payload = 0 means that it is a negative SR */
       sr_payload = nr_ue_get_SR(Mod_id,
-                            CC_id,
-                            frame_tx,
-                            gNB_id,
-                            ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][gNB_id]->crnti,
-                            nr_tti_tx); // nr_tti_rx used for meas gap
+				CC_id,
+				frame_tx,
+				gNB_id,
+				0,//ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][gNB_id]->crnti,
+				nr_tti_tx); // nr_tti_rx used for meas gap
     }
     else {
       sr_payload = 1;
@@ -592,7 +591,7 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
     case pucch_format2_nr:
     {
       nr_generate_pucch2(ue,
-                         ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][gNB_id]->crnti,
+                         0,//ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][gNB_id]->crnti,
                          ue->common_vars.txdataF,
                          &ue->frame_parms,
                          &ue->pucch_config_dedicated[gNB_id],
@@ -610,7 +609,7 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
     case pucch_format4_nr:
     {
       nr_generate_pucch3_4(ue,
-                           ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][gNB_id]->crnti,
+                           0,//ue->pdcch_vars[ue->current_thread_id[proc->nr_tti_rx]][gNB_id]->crnti,
                            ue->common_vars.txdataF,
                            &ue->frame_parms,
                            format,
@@ -1216,3 +1215,4 @@ void set_csi_nr(int csi_status, uint32_t csi_payload)
   }
 }
 
+
diff --git a/openair1/SCHED_UE/phy_procedures_lte_ue.c b/openair1/SCHED_UE/phy_procedures_lte_ue.c
index 6d92beaddfa..e0ea4ef2b28 100644
--- a/openair1/SCHED_UE/phy_procedures_lte_ue.c
+++ b/openair1/SCHED_UE/phy_procedures_lte_ue.c
@@ -74,7 +74,7 @@ extern double cpuf;
 void Msg1_transmitted(module_id_t module_idP, uint8_t CC_id, frame_t frameP, uint8_t eNB_id);
 void Msg3_transmitted(module_id_t module_idP, uint8_t CC_id, frame_t frameP, uint8_t eNB_id);
 
-extern uint32_t downlink_frequency[MAX_NUM_CCs][4];
+extern uint64_t downlink_frequency[MAX_NUM_CCs][4];
 
 void get_dumpparam(PHY_VARS_UE *ue,
                    UE_rxtx_proc_t *proc,
diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c
index dfb5578ba60..9b4aba46c39 100644
--- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c
+++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c
@@ -58,7 +58,7 @@ struct iovec nas_iov_rx = {nl_rx_buf, sizeof(nl_rx_buf)};
 
 int nas_sock_fd[MAX_MOBILES_PER_ENB];
 
-int nas_sock_mbms_fd[8];
+int nas_sock_mbms_fd;
 
 struct msghdr nas_msg_tx;
 struct msghdr nas_msg_rx;
@@ -95,21 +95,20 @@ static int tun_alloc(char *dev) {
 }
 
 
-int netlink_init_mbms_tun(char *ifprefix, int num_if) {
+int netlink_init_mbms_tun(char *ifprefix) {
   int ret;
   char ifname[64];
 
-  int i= num_if-1;
-    sprintf(ifname, "oaitun_%.3s%d",ifprefix,i+1);
-    nas_sock_mbms_fd[i] = tun_alloc(ifname);
+    sprintf(ifname, "oaitun_%.3s1",ifprefix); // added "1": for historical reasons
+    nas_sock_mbms_fd = tun_alloc(ifname);
 
-    if (nas_sock_mbms_fd[i] == -1) {
+    if (nas_sock_mbms_fd == -1) {
       printf("[NETLINK] Error opening socket %s (%d:%s)\n",ifname,errno, strerror(errno));
       exit(1);
     }
 
-    printf("[NETLINK]Opened socket %s with fd %d\n",ifname,nas_sock_mbms_fd[i]);
-    ret = fcntl(nas_sock_mbms_fd[i],F_SETFL,O_NONBLOCK);
+    printf("[NETLINK]Opened socket %s with fd %d\n",ifname,nas_sock_mbms_fd);
+    ret = fcntl(nas_sock_mbms_fd,F_SETFL,O_NONBLOCK);
 
     if (ret == -1) {
       printf("[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno));
@@ -123,7 +122,7 @@ int netlink_init_mbms_tun(char *ifprefix, int num_if) {
     nas_src_addr.nl_family = AF_NETLINK;
     nas_src_addr.nl_pid = 1;//getpid();  /* self pid */
     nas_src_addr.nl_groups = 0;  /* not in mcast groups */
-    ret = bind(nas_sock_mbms_fd[i], (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr));
+    ret = bind(nas_sock_mbms_fd, (struct sockaddr *)&nas_src_addr, sizeof(nas_src_addr));
     memset(&nas_dest_addr, 0, sizeof(nas_dest_addr));
     nas_dest_addr.nl_family = AF_NETLINK;
     nas_dest_addr.nl_pid = 0;   /* For Linux Kernel */
@@ -165,7 +164,8 @@ int netlink_init_tun(char *ifprefix, int num_if) {
       exit(1);
     }
 
-    printf("[NETLINK]Opened socket %s with fd %d\n",ifname,nas_sock_fd[i]);
+    printf("[NETLINK]Opened socket %s with fd nas_sock_fd[%d]=%d\n",
+           ifname, i, nas_sock_fd[i]);
     ret = fcntl(nas_sock_fd[i],F_SETFL,O_NONBLOCK);
 
     if (ret == -1) {
diff --git a/openair1/SIMULATION/ETH_TRANSPORT/proto.h b/openair1/SIMULATION/ETH_TRANSPORT/proto.h
index 02f7925d93f..e6159199d40 100644
--- a/openair1/SIMULATION/ETH_TRANSPORT/proto.h
+++ b/openair1/SIMULATION/ETH_TRANSPORT/proto.h
@@ -63,6 +63,6 @@ void clear_eNB_transport_info(uint8_t);
 void clear_UE_transport_info(uint8_t);
 int netlink_init(void);
 int netlink_init_tun(char *ifsuffix, int num_if);
-int netlink_init_mbms_tun(char *ifsuffix, int num_if);
+int netlink_init_mbms_tun(char *ifsuffix);
 
 #endif /* EMU_PROTO_H_ */
diff --git a/openair1/SIMULATION/LTE_PHY/prachsim.c b/openair1/SIMULATION/LTE_PHY/prachsim.c
index 0771917bfba..c997aa76393 100644
--- a/openair1/SIMULATION/LTE_PHY/prachsim.c
+++ b/openair1/SIMULATION/LTE_PHY/prachsim.c
@@ -22,8 +22,8 @@
 #include <string.h>
 #include <math.h>
 #include <unistd.h>
-#include "SIMULATION/TOOLS/defs.h"
-#include "SIMULATION/RF/defs.h"
+#include "SIMULATION/TOOLS/sim.h"
+#include "SIMULATION/RF/rf.h"
 #include "PHY/types.h"
 #include "PHY/defs.h"
 #include "PHY/vars.h"
diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c
index 6000c2e7bb8..80b26c0bbde 100644
--- a/openair1/SIMULATION/NR_PHY/dlschsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlschsim.c
@@ -59,6 +59,8 @@ double cpuf;
 uint8_t nfapi_mode = 0;
 uint16_t NB_UE_INST = 1;
 
+
+
 // needed for some functions
 PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } };
 uint16_t n_rnti = 0x1234;
@@ -90,14 +92,13 @@ int main(int argc, char **argv)
 	//char input_val_str[50],input_val_str2[50];
 	//uint16_t NB_RB=25;
 	SCM_t channel_model = AWGN;  //Rayleigh1_anticorr;
-	uint16_t N_RB_DL = 106, mu = 1;
+	uint16_t N_RB_DL = 106, mu = 1; 
 	//unsigned char frame_type = 0;
 	unsigned char pbch_phase = 0;
 	int frame = 0, slot = 0;
 	int frame_length_complex_samples;
 	//int frame_length_complex_samples_no_prefix;
 	NR_DL_FRAME_PARMS *frame_parms;
-	//nfapi_nr_config_request_t *gNB_config;
 	uint8_t Kmimo = 0;
 	uint32_t Nsoft = 0;
 	double sigma;
@@ -341,10 +342,9 @@ int main(int argc, char **argv)
 		exit(-1);
 	}
 
-	RC.gNB = (PHY_VARS_gNB ** *) malloc(sizeof(PHY_VARS_gNB **));
-	RC.gNB[0] = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *));
-	RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB));
-	gNB = RC.gNB[0][0];
+	RC.gNB = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *));
+	RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB));
+	gNB = RC.gNB[0];
 	//gNB_config = &gNB->gNB_config;
 	frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
 	frame_parms->nb_antennas_tx = n_tx;
@@ -423,7 +423,7 @@ int main(int argc, char **argv)
 	UE->dlsch_ra[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0);
 	unsigned char harq_pid = 0; //dlsch->harq_ids[subframe];
 	NR_gNB_DLSCH_t *dlsch = gNB->dlsch[0][0];
-	nfapi_nr_dl_config_dlsch_pdu_rel15_t *rel15 = &dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15;
+	nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->harq_processes[harq_pid]->pdsch_pdu.pdsch_pdu_rel15;
 	//time_stats_t *rm_stats, *te_stats, *i_stats;
 	uint8_t is_crnti = 0, llr8_flag = 0;
 	unsigned int TBS = 8424;
@@ -445,13 +445,16 @@ int main(int argc, char **argv)
 	TBS = nr_compute_tbs(mod_order,rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, Nl);
 	printf("available bits %u TBS %u mod_order %d\n", available_bits, TBS, mod_order);
 	//dlsch->harq_ids[subframe]= 0;
-	rel15->n_prb = nb_rb;
-	rel15->nb_symbols = nb_symb_sch;
-	rel15->modulation_order = mod_order;
-	rel15->nb_layers = Nl;
-	rel15->nb_re_dmrs = nb_re_dmrs;
-	rel15->transport_block_size = TBS;
-  rel15->coding_rate = rate;
+	rel15->rbSize         = nb_rb;
+	rel15->NrOfSymbols    = nb_symb_sch;
+	rel15->qamModOrder[0] = mod_order;
+	rel15->nrOfLayers     = Nl;
+	rel15->TBSize[0]      = TBS>>3;
+        rel15->targetCodeRate[0] = rate;
+        rel15->NrOfCodewords = 1;
+        rel15->dmrsConfigType = NFAPI_NR_DMRS_TYPE1;
+	rel15->dlDmrsSymbPos = 4;
+	rel15->mcsIndex[0] = Imcs;
 	double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc
 	short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384);
 	short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384);
@@ -472,6 +475,8 @@ int main(int argc, char **argv)
 	harq_process->Qm = mod_order;
 	harq_process->rvidx = rvidx;
 	harq_process->R = rate;
+        harq_process->dmrsConfigType = 1;
+	harq_process->dlDmrsSymbPos = 4;
 	printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch);
 	unsigned char *test_input;
 	test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8);
@@ -491,7 +496,7 @@ int main(int argc, char **argv)
 	//printf("crc32: [0]->0x%08x\n",crc24c(test_input, 32));
 	// generate signal
 	if (input_fd == NULL) {
-		nr_dlsch_encoding(test_input, frame, slot, dlsch, frame_parms);
+		nr_dlsch_encoding(test_input, frame, slot, dlsch, frame_parms,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
 	}
 
 	for (SNR = snr0; SNR < snr1; SNR += snr_step) {
@@ -525,9 +530,11 @@ int main(int argc, char **argv)
 				//printf("channel_output_fixed[%d]: %d\n",i,channel_output_fixed[i]);
 
 				//channel_output_fixed[i] = (char)quantize(1,channel_output_fixed[i],qbits);
-
-				//if (i<16)   printf("channel_output_fixed[%d] = %d\n",i,channel_output_fixed[i]);
-
+/*
+				if (i<16)   printf("input[%d] %f => channel_output_fixed[%d] = %d\n",
+						   i,modulated_input[i],
+						   i,channel_output_fixed[i]);
+*/
 				//Uncoded BER
 				if (channel_output_fixed[i] < 0)
 					channel_output_uncoded[i] = 1;  //QPSK demod
@@ -621,9 +628,9 @@ int main(int argc, char **argv)
 
 	for (i = 0; i < 2; i++) {
 		printf("gNB %d\n", i);
-		free_gNB_dlsch(&(gNB->dlsch[0][i]));
+		free_gNB_dlsch(&(gNB->dlsch[0][i]),N_RB_DL);
 		printf("UE %d\n", i);
-		free_nr_ue_dlsch(&(UE->dlsch[0][0][i]));
+		free_nr_ue_dlsch(&(UE->dlsch[0][0][i]),N_RB_DL);
 	}
 
 	for (i = 0; i < 2; i++) {
diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c
index 60b79c17c20..ebcedbaeb09 100644
--- a/openair1/SIMULATION/NR_PHY/dlsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlsim.c
@@ -51,11 +51,23 @@
 #include "SCHED_NR_UE/fapi_nr_ue_l1.h"
 #include "NR_PHY_INTERFACE/NR_IF_Module.h"
 #include "NR_UE_PHY_INTERFACE/NR_IF_Module.h"
+
+#include "LAYER2/NR_MAC_UE/mac_proto.h"
+//#include "LAYER2/NR_MAC_gNB/mac_proto.h"
+//#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
+#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h"
+#include "NR_asn_constant.h"
 #include "RRC/NR/MESSAGES/asn1_msg.h"
 #include "openair1/SIMULATION/RF/rf.h"
 #include "openair1/SIMULATION/TOOLS/sim.h"
 #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h"
-#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
+//#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
+
+#include "NR_RRCReconfiguration.h"
+#define inMicroS(a) (((double)(a))/(cpu_freq_GHz*1000.0))
+#include "SIMULATION/LTE_PHY/common_sim.h"
+
+
 
 PHY_VARS_gNB *gNB;
 PHY_VARS_NR_UE *UE;
@@ -63,28 +75,64 @@ RAN_CONTEXT_t RC;
 int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
 
 double cpuf;
+
+int sf_ahead=4 ;
+int sl_ahead=0;
 uint8_t nfapi_mode = 0;
 uint16_t NB_UE_INST = 1;
+uint64_t downlink_frequency[MAX_NUM_CCs][4];
+
+// dummy functions
+int dummy_nr_ue_ul_indication(nr_uplink_indication_t *ul_info)              { return(0);  }
+
+void pdcp_run (const protocol_ctxt_t *const  ctxt_pP) { return;}
+
+int8_t nr_mac_rrc_data_ind_ue(const module_id_t     module_id,
+			      const int             CC_id,
+			      const uint8_t         gNB_index,
+			      const int8_t          channel,
+			      const uint8_t*        pduP,
+			      const sdu_size_t      pdu_len)
+{
+  return 0;
+}
 
-//Dummy Functions
-lte_subframe_t subframe_select(LTE_DL_FRAME_PARMS *frame_parms, unsigned char subframe) {return(SF_DL);}
-//int rlc_module_init (int enb) {return(0);}
-void pdcp_layer_init (void) {}
-boolean_t pdcp_data_ind( const protocol_ctxt_t *const ctxt_pP, const srb_flag_t   srb_flagP, const MBMS_flag_t  MBMS_flagP, const rb_id_t      rb_idP,
-						 const sdu_size_t   sdu_buffer_sizeP, mem_block_t *const sdu_buffer_pP)
-{return (0);}
-
-int rrc_init_nr_global_param (void) {return(0);}
-void config_common(int Mod_idP,int CC_idP,int Nid_cell,int nr_bandP,uint64_t SSB_positions,uint16_t ssb_periodicity,uint64_t dl_CarrierFreqP,uint32_t dl_BandwidthP);
-int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, const uint8_t gNB_index,
-                              const int8_t channel, const uint8_t* pduP, const sdu_size_t pdu_len) {return(0);}
-uint64_t get_softmodem_optmask(void) {return 0;}
-void nr_ip_over_LTE_DRB_preconfiguration(void){}
 
+void pdcp_layer_init(void) {}
+boolean_t
+pdcp_data_ind(
+  const protocol_ctxt_t *const ctxt_pP,
+  const srb_flag_t   srb_flagP,
+  const MBMS_flag_t  MBMS_flagP,
+  const rb_id_t      rb_idP,
+  const sdu_size_t   sdu_buffer_sizeP,
+  mem_block_t *const sdu_buffer_pP
+) { return(false);}
+
+int rrc_init_nr_global_param(void){return(0);}
+
+void config_common(int Mod_idP,
+                   int pdsch_AntennaPorts, 
+		   NR_ServingCellConfigCommon_t *scc
+		   );
+
+int generate_dlsch_header(unsigned char *mac_header,
+                          unsigned char num_sdus,
+                          unsigned short *sdu_lengths,
+                          unsigned char *sdu_lcids,
+                          unsigned char drx_cmd,
+                          unsigned short timing_advance_cmd,
+                          unsigned char *ue_cont_res_id,
+                          unsigned char short_padding,
+                          unsigned short post_padding){return 0;}
+void nr_ip_over_LTE_DRB_preconfiguration(void){}
 
 // needed for some functions
 openair0_config_t openair0_cfg[MAX_CARDS];
 
+
+
+
 int main(int argc, char **argv)
 {
   char c;
@@ -106,8 +154,6 @@ int main(int argc, char **argv)
   int trial, n_trials = 1, n_errors = 0, n_false_positive = 0;
   //int n_errors2, n_alamouti;
   uint8_t transmission_mode = 1,n_tx=1,n_rx=1;
-  uint16_t Nid_cell=0;
-  uint64_t SSB_positions=0x01;
 
   channel_desc_t *gNB2UE;
   //uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0;
@@ -124,37 +170,26 @@ int main(int argc, char **argv)
   //double pbch_sinr;
   //int pbch_tx_ant;
   int N_RB_DL=106,mu=1;
-  nfapi_nr_dl_config_dlsch_pdu_rel15_t dlsch_config;
-  dlsch_config.start_prb = 0;
-  dlsch_config.n_prb = 50;
-  dlsch_config.start_symbol = 2;
-  dlsch_config.nb_symbols = 9;
-  dlsch_config.mcs_idx = 9;
-
-  uint16_t ssb_periodicity = 10;
+  nfapi_nr_dl_tti_pdsch_pdu_rel15_t dlsch_config;
 
   //unsigned char frame_type = 0;
-  unsigned char pbch_phase = 0;
 
   int frame=0,slot=1;
   int frame_length_complex_samples;
   int frame_length_complex_samples_no_prefix;
-  int slot_length_complex_samples_no_prefix;
   NR_DL_FRAME_PARMS *frame_parms;
-  nfapi_nr_config_request_t *gNB_config;
   UE_nr_rxtx_proc_t UE_proc;
   NR_Sched_Rsp_t Sched_INFO;
   gNB_MAC_INST *gNB_mac;
   NR_UE_MAC_INST_t *UE_mac;
-
-  int ret;
+  int cyclic_prefix_type = NFAPI_CP_NORMAL;
   int run_initial_sync=0;
   int do_pdcch_flag=1;
 
-  uint16_t cset_offset = 0;
-  int loglvl=OAILOG_WARNING;
+  int loglvl=OAILOG_INFO;
 
   float target_error_rate = 0.01;
+  int css_flag=0;
 
   cpuf = get_cpu_freq_GHz();
 
@@ -164,17 +199,21 @@ int main(int argc, char **argv)
 
   randominit(0);
 
-  while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:M:N:F:GR:dP:IL:o:a:b:c:j:e:")) != -1) {
+  int mcsIndex_set=0,rbStart_set=0,rbSize_set=0;
+  int print_perf             = 0;
+
+  FILE *scg_fd=NULL;
+  
+  while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:M:N:F:GR:dPIL:Ea:b:e:m:")) != -1) {
     switch (c) {
-    /*case 'f':
-      write_output_file=1;
-      output_fd = fopen(optarg,"w");
+    case 'f':
+      scg_fd = fopen(optarg,"r");
 
-      if (output_fd==NULL) {
+      if (scg_fd==NULL) {
         printf("Error opening %s\n",optarg);
         exit(-1);
       }
-      break;*/
+      break;
 
     /*case 'd':
       frame_type = 1;
@@ -290,14 +329,6 @@ int main(int argc, char **argv)
 
       break;
 
-    case 'M':
-      SSB_positions = atoi(optarg);
-      break;
-
-    case 'N':
-      Nid_cell = atoi(optarg);
-      break;
-
     case 'R':
       N_RB_DL = atoi(optarg);
       break;
@@ -313,44 +344,43 @@ int main(int argc, char **argv)
       break;
 
     case 'P':
-      pbch_phase = atoi(optarg);
-
-      if (pbch_phase>3)
-        printf("Illegal PBCH phase (0-3) got %d\n",pbch_phase);
-
+      print_perf=1;
+      opp_enabled=1;
       break;
       
     case 'I':
       run_initial_sync=1;
       target_error_rate=0.1;
+      slot = 0;
       break;
 
     case 'L':
       loglvl = atoi(optarg);
       break;
 
-    case 'o':
-      cset_offset = atoi(optarg);
-      break;
+
+    case 'E':
+	css_flag=1;
+	break;
+
 
     case 'a':
-      dlsch_config.start_prb = atoi(optarg);
+      dlsch_config.rbStart = atoi(optarg);
+      rbStart_set=1;
       break;
 
     case 'b':
-      dlsch_config.n_prb = atoi(optarg);
-      break;
-
-    case 'c':
-      dlsch_config.start_symbol = atoi(optarg);
+      dlsch_config.rbSize = atoi(optarg);
+      rbSize_set=1;
       break;
 
-    case 'j':
-      dlsch_config.nb_symbols = atoi(optarg);
+    case 'e':
+      dlsch_config.mcsIndex[0] = atoi(optarg);
+      mcsIndex_set=1;
       break;
 
-    case 'e':
-      dlsch_config.mcs_idx = atoi(optarg);
+    case 'm':
+      mu = atoi(optarg);
       break;
 
     default:
@@ -365,19 +395,17 @@ int main(int argc, char **argv)
       printf("-S Ending SNR, runs from SNR0 to SNR1\n");
       printf("-t Delay spread for multipath channel\n");
       printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n");
-      printf("-x Transmission mode (1,2,6 for the moment)\n");
-      printf("-y Number of TX antennas used in eNB\n");
+      printf("-y Number of TX antennas used in gNB\n");
       printf("-z Number of RX antennas used in UE\n");
-      //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n");
-      //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n");
-      printf("-M Multiple SSB positions in burst\n");
-      printf("-N Nid_cell\n");
+      //printf("-i Relative strength of first intefering gNB (in dB) - cell_id mod 3 = 1\n");
+      //printf("-j Relative strength of second intefering gNB (in dB) - cell_id mod 3 = 2\n");
       printf("-R N_RB_DL\n");
       printf("-O oversampling factor (1,2,4,8,16)\n");
       printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n");
       //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n");
-      //printf("-f Output filename (.txt format) for Pe/SNR results\n");
+      printf("-f raw file containing RRC configuration (generated by gNB)\n");
       printf("-F Input filename (.txt format) for RX conformance testing\n");
+      printf("-E used CSS scheduler\n");
       printf("-o CORESET offset\n");
       printf("-a Start PRB for PDSCH\n");
       printf("-b Number of PRB for PDSCH\n");
@@ -388,35 +416,110 @@ int main(int argc, char **argv)
       break;
     }
   }
-
+  
   logInit();
   set_glog(loglvl);
   T_stdout = 1;
 
+  get_softmodem_params()->phy_test = 1;
+  
   if (snr1set==0)
     snr1 = snr0+10;
 
-  printf("Initializing gNodeB for mu %d, N_RB_DL %d\n",mu,N_RB_DL);
 
-  RC.gNB = (PHY_VARS_gNB***) malloc(sizeof(PHY_VARS_gNB **));
-  RC.gNB[0] = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *));
-  RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB));
-  memset(RC.gNB[0][0],0,sizeof(PHY_VARS_gNB));
+  RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *));
+  RC.gNB[0] = (PHY_VARS_gNB*) malloc(sizeof(PHY_VARS_gNB ));
+  memset(RC.gNB[0],0,sizeof(PHY_VARS_gNB));
 
-  gNB = RC.gNB[0][0];
-  gNB_config = &gNB->gNB_config;
+  gNB = RC.gNB[0];
   frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
   frame_parms->nb_antennas_tx = n_tx;
   frame_parms->nb_antennas_rx = n_rx;
   frame_parms->N_RB_DL = N_RB_DL;
   frame_parms->N_RB_UL = N_RB_DL;
 
+  RC.nb_nr_macrlc_inst = 1;
+  RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int));
+  for (i = 0; i < RC.nb_nr_macrlc_inst; i++)
+    RC.nb_nr_mac_CC[i] = 1;
+  mac_top_init_gNB();
+  gNB_mac = RC.nrmac[0];
+  gNB_RRC_INST rrc;
+  memset((void*)&rrc,0,sizeof(rrc));
+
+  /*
+  // read in SCGroupConfig
+  AssertFatal(scg_fd != NULL,"no reconfig.raw file\n");
+  char buffer[1024];
+  int msg_len=fread(buffer,1,1024,scg_fd);
+  NR_RRCReconfiguration_t *NR_RRCReconfiguration;
+
+  printf("Decoding NR_RRCReconfiguration (%d bytes)\n",msg_len);
+  asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
+						  &asn_DEF_NR_RRCReconfiguration,
+						  (void **)&NR_RRCReconfiguration,
+						  (uint8_t *)buffer,
+						  msg_len); 
+  
+  if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
+    AssertFatal(1==0,"NR_RRCReConfiguration decode error\n");
+    // free the memory
+    SEQUENCE_free( &asn_DEF_NR_RRCReconfiguration, NR_RRCReconfiguration, 1 );
+    exit(-1);
+  }      
+  fclose(scg_fd);
+
+  AssertFatal(NR_RRCReconfiguration->criticalExtensions.present == NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration,"wrong NR_RRCReconfiguration->criticalExstions.present type\n");
+
+  NR_RRCReconfiguration_IEs_t *reconfig_ies = NR_RRCReconfiguration->criticalExtensions.choice.rrcReconfiguration;
+  NR_CellGroupConfig_t *secondaryCellGroup;
+  dec_rval = uper_decode_complete( NULL,
+				   &asn_DEF_NR_CellGroupConfig,
+				   (void **)&secondaryCellGroup,
+				   (uint8_t *)reconfig_ies->secondaryCellGroup->buf,
+				   reconfig_ies->secondaryCellGroup->size); 
+  
+  if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
+    AssertFatal(1==0,"NR_CellGroupConfig decode error\n");
+    // free the memory
+    SEQUENCE_free( &asn_DEF_NR_CellGroupConfig, secondaryCellGroup, 1 );
+    exit(-1);
+  }      
+  
+  NR_ServingCellConfigCommon_t *scc = secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
+  */
+
+
+  rrc.carrier.servingcellconfigcommon = calloc(1,sizeof(*rrc.carrier.servingcellconfigcommon));
+
+  NR_ServingCellConfigCommon_t *scc = rrc.carrier.servingcellconfigcommon;
+  NR_CellGroupConfig_t *secondaryCellGroup=calloc(1,sizeof(*secondaryCellGroup));
+  prepare_scc(rrc.carrier.servingcellconfigcommon);
+  uint64_t ssb_bitmap;
+  fill_scc(rrc.carrier.servingcellconfigcommon,&ssb_bitmap,N_RB_DL,N_RB_DL,mu,mu);
+
+  fill_default_secondaryCellGroup(scc,
+				  secondaryCellGroup,
+				  0,
+				  1,
+				  n_tx,
+				  0);
+  fix_scc(scc,ssb_bitmap);
+
+  xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup);
+
+  AssertFatal((gNB->if_inst         = NR_IF_Module_init(0))!=NULL,"Cannot register interface");
+  gNB->if_inst->NR_PHY_config_req      = nr_phy_config_request;
+  // common configuration
+  rrc_mac_config_req_gNB(0,0,1,scc,0,0,NULL);
+  // UE dedicated configuration
+  rrc_mac_config_req_gNB(0,0,1,NULL,1,secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup);
+  phy_init_nr_gNB(gNB,0,0);
+  N_RB_DL = gNB->frame_parms.N_RB_DL;
   // stub to configure frame_parms
-  nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions);
+  //  nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions);
   // call MAC to configure common parameters
 
-  phy_init_nr_gNB(gNB,0,0);
-  mac_top_init_gNB();
 
   double fs,bw;
 
@@ -436,6 +539,14 @@ int main(int argc, char **argv)
     fs = 61.44e6;
     bw = 40e6;
   }
+  else if (mu == 3 && N_RB_DL == 66) {
+    fs = 122.88e6;
+    bw = 100e6;
+  }
+  else if (mu == 3 && N_RB_DL == 32) {
+    fs = 61.44e6;
+    bw = 50e6;
+  }
   else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL);
 
   gNB2UE = new_channel_desc_scm(n_tx,
@@ -454,7 +565,6 @@ int main(int argc, char **argv)
 
   frame_length_complex_samples = frame_parms->samples_per_subframe*NR_NUMBER_OF_SUBFRAMES_PER_FRAME;
   frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP*NR_NUMBER_OF_SUBFRAMES_PER_FRAME;
-  slot_length_complex_samples_no_prefix = frame_parms->samples_per_slot_wCP;
 
   s_re = malloc(2*sizeof(double*));
   s_im = malloc(2*sizeof(double*));
@@ -510,21 +620,9 @@ int main(int argc, char **argv)
   nr_gold_pbch(UE);
   nr_gold_pdcch(UE,0,2);
 
-  RC.nb_nr_macrlc_inst = 1;
-  RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int));
-  for (i = 0; i < RC.nb_nr_macrlc_inst; i++)
-    RC.nb_nr_mac_CC[i] = 1;
-  mac_top_init_gNB();
-  gNB_mac = RC.nrmac[0];
-
-  config_common(0,0,Nid_cell,78,SSB_positions,ssb_periodicity,(uint64_t)3640000000L,N_RB_DL);
-  config_nr_mib(0,0,1,kHz30,0,0,0,0,0);
-
-  nr_l2_init_ue();
+  nr_l2_init_ue(NULL);
   UE_mac = get_mac_inst(0);
   
-  UE->pdcch_vars[0][0]->crnti = 0x1234;
-
   UE->if_inst = nr_ue_if_module_init(0);
   UE->if_inst->scheduled_response = nr_ue_scheduled_response;
   UE->if_inst->phy_config_request = nr_ue_phy_config_request;
@@ -534,309 +632,250 @@ int main(int argc, char **argv)
 
   UE_mac->if_module = nr_ue_if_module_init(0);
   
-  unsigned int available_bits;
+  unsigned int available_bits=0;
   unsigned char *estimated_output_bit;
   unsigned char *test_input_bit;
   unsigned int errors_bit    = 0;
   uint32_t errors_scrambling = 0;
 
+
   test_input_bit       = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
   estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
   
-  uint16_t rb_offset_count = cset_offset/6;
-  set_cset_offset(rb_offset_count);
   // generate signal
-  if (input_fd==NULL) {
-    gNB->pbch_configured = 1;
-    for (int i=0;i<4;i++) gNB->pbch_pdu[i]=i+1;
-
-    nr_schedule_uss_dlsch_phytest(0,frame,slot,&dlsch_config);
-    Sched_INFO.module_id = 0;
-    Sched_INFO.CC_id     = 0;
-    Sched_INFO.frame     = frame;
-    Sched_INFO.slot      = slot;
-    Sched_INFO.DL_req    = &gNB_mac->DL_req[0];
-    Sched_INFO.UL_tti_req    = &gNB_mac->UL_tti_req[0];
-    Sched_INFO.HI_DCI0_req  = NULL;
-    Sched_INFO.TX_req    = &gNB_mac->TX_req[0];
-    nr_schedule_response(&Sched_INFO);
-
-    phy_procedures_gNB_TX(gNB,frame,slot,0);
-    
-    //nr_common_signal_procedures (gNB,frame,subframe);
-    int txdataF_offset = (slot%2) * frame_parms->samples_per_slot_wCP;
-
-    LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1);
-    if (gNB->frame_parms.nb_antennas_tx>1)
-      LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);
-
-    int tx_offset = slot*frame_parms->samples_per_slot;
-    printf("samples_per_slot_wCP = %d\n", frame_parms->samples_per_slot_wCP);
-
-    //TODO: loop over slots
-    for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) {
-      if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) {
-	PHY_ofdm_mod(&gNB->common_vars.txdataF[aa][txdataF_offset],
-		     &txdata[aa][tx_offset],
-		     frame_parms->ofdm_symbol_size,
-		     12,
-		     frame_parms->nb_prefix_samples,
-		     CYCLIC_PREFIX);
-      } else {
-	nr_normal_prefix_mod(&gNB->common_vars.txdataF[aa][txdataF_offset],
-			     &txdata[aa][tx_offset],
-			     14,
-			     frame_parms);
-      }
-    }
-  } else {
-    printf("Reading %d samples from file to antenna buffer %d\n",frame_length_complex_samples,0);
-    
-    if (fread(txdata[0],
-	      sizeof(int32_t),
-	      frame_length_complex_samples,
-	      input_fd) != frame_length_complex_samples) {
-      printf("error reading from file\n");
-      //exit(-1);
-    }
-  }
-
-  LOG_M("txsig0.m","txs0", txdata[0],frame_length_complex_samples,1,1);
-  if (gNB->frame_parms.nb_antennas_tx>1)
-    LOG_M("txsig1.m","txs1", txdata[1],frame_length_complex_samples,1,1);
-
-  if (output_fd) 
-    fwrite(txdata[0],sizeof(int32_t),frame_length_complex_samples,output_fd);
-
-  int txlev = signal_energy(&txdata[0][5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0],
-			    frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples);
+  AssertFatal(input_fd==NULL,"Not ready for input signal file\n");
+  gNB->pbch_configured = 1;
+  gNB->ssb_pdu.ssb_pdu_rel15.bchPayload=0x001234;
+  
+  if (mcsIndex_set==0) dlsch_config.mcsIndex[0]=9;
+  
+  if (rbStart_set==0) dlsch_config.rbStart=0;
+  if (rbSize_set==0) dlsch_config.rbSize=N_RB_DL-dlsch_config.rbStart;
 
-  //  printf("txlev %d (%f)\n",txlev,10*log10(txlev));
+  //Configure UE
+  rrc.carrier.MIB = (uint8_t*) malloc(4);
+  rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0);
 
-  for (i=0; i<frame_length_complex_samples; i++) {
-    for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
-      r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]);
-      r_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]);
-    }
-  }
+  nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib,secondaryCellGroup->spCellConfig);
 
 
-  //Configure UE
-  rrc_gNB_carrier_data_t carrier;
-  uint32_t pdcch_ConfigSIB1     = 0;
-  uint32_t ssb_SubcarrierOffset = 0;
-  carrier.MIB = (uint8_t*) malloc(4);
-  carrier.sizeof_MIB = do_MIB_NR(&carrier,0,ssb_SubcarrierOffset,pdcch_ConfigSIB1,30,2);
-
-  nr_rrc_mac_config_req_ue(0,0,0,carrier.mib.message.choice.mib,NULL,NULL,NULL);
-
-  // Initial bandwidth part configuration -- full carrier bandwidth
-  UE_mac->initial_bwp_dl.bwp_id = 0;
-  UE_mac->initial_bwp_dl.location = 0;
-  UE_mac->initial_bwp_dl.scs = UE->frame_parms.subcarrier_spacing;
-  UE_mac->initial_bwp_dl.N_RB = UE->frame_parms.N_RB_DL;
-  UE_mac->initial_bwp_dl.cyclic_prefix = UE->frame_parms.Ncp;
-  
-  fapi_nr_dl_config_request_t *dl_config = &UE_mac->dl_config_request; 
-  //  Type0 PDCCH search space
-  dl_config->number_pdus =  1;
-  dl_config->dl_config_list[0].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.rnti = 0x1234;	
-  
-  uint64_t mask = 0x0;
-  uint16_t num_rbs=24;
-  uint16_t rb_offset=gNB->pdcch_vars.dci_alloc[0].pdcch_params.rb_offset;
-  uint16_t cell_id=0;
-  uint16_t num_symbols=2;
-  for(i=0; i<(num_rbs/6); ++i){   //  38.331 Each bit corresponds a group of 6 RBs
-    mask = mask >> 1;
-    mask = mask | 0x100000000000;
-  }
-  uint16_t UE_rb_offset_count = rb_offset/6;
-  mask = mask >> UE_rb_offset_count;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.frequency_domain_resource = mask;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.rb_offset = rb_offset;  //  additional parameter other than coreset
+  nr_dcireq_t dcireq;
+  nr_scheduled_response_t scheduled_response;
+  memset((void*)&dcireq,0,sizeof(dcireq));
+  memset((void*)&scheduled_response,0,sizeof(scheduled_response));
+  dcireq.module_id = 0;
+  dcireq.gNB_index = 0;
+  dcireq.cc_id     = 0;
   
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.duration = num_symbols;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_mapping_type =CCE_REG_MAPPING_TYPE_NON_INTERLEAVED;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_interleaved_reg_bundle_size = 0;   //  L 38.211 7.3.2.2
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_interleaved_interleaver_size = 0;  //  R 38.211 7.3.2.2
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_interleaved_shift_index = cell_id;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.precoder_granularity = PRECODER_GRANULARITY_SAME_AS_REG_BUNDLE;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.pdcch_dmrs_scrambling_id = cell_id;
+  scheduled_response.dl_config = &dcireq.dl_config_req;
+  scheduled_response.ul_config = &dcireq.ul_config_req;
+  scheduled_response.tx_request = NULL;
+  scheduled_response.module_id = 0;
+  scheduled_response.CC_id     = 0;
+  scheduled_response.frame = frame;
+  scheduled_response.slot  = slot;
   
-  uint32_t number_of_search_space_per_slot=1;
-  uint32_t first_symbol_index=0;
-  uint32_t search_space_duration=0;  //  element of search space
-  uint32_t coreset_duration;  //  element of coreset
-  
-  coreset_duration = num_symbols * number_of_search_space_per_slot;
-  
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[0] = table_38213_10_1_1_c2[0];
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[1] = table_38213_10_1_1_c2[1];
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[2] = table_38213_10_1_1_c2[2];   //  CCE aggregation level = 4
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[3] = table_38213_10_1_1_c2[3];   //  CCE aggregation level = 8
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[4] = table_38213_10_1_1_c2[4];   //  CCE aggregation level = 16
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.duration = search_space_duration;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.monitoring_symbols_within_slot = (0x3fff << first_symbol_index) & (0x3fff >> (14-coreset_duration-first_symbol_index)) & 0x3fff;
-
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.N_RB_BWP = N_RB_DL;
-
-  UE_mac->scheduled_response.dl_config = dl_config;
-  UE_mac->scheduled_response.ul_config = NULL;
-  UE_mac->scheduled_response.tx_request = NULL;
-  UE_mac->scheduled_response.module_id = 0;
-  UE_mac->scheduled_response.CC_id = 0;
-  UE_mac->scheduled_response.frame = frame;
-  UE_mac->scheduled_response.slot = slot;
-
-  UE_mac->phy_config.config_req.pbch_config.system_frame_number = frame;
-  UE_mac->phy_config.config_req.pbch_config.ssb_index = 0;
-  UE_mac->phy_config.config_req.pbch_config.half_frame_bit = 0;
 
   nr_ue_phy_config_request(&UE_mac->phy_config);
 
   for (SNR = snr0; SNR < snr1; SNR += .2) {
 
+    varArray_t *table_tx=initVarArray(1000,sizeof(double));
+    reset_meas(&gNB->phy_proc_tx); // total gNB tx
+    reset_meas(&gNB->dlsch_scrambling_stats);
+    reset_meas(&gNB->dlsch_interleaving_stats);
+    reset_meas(&gNB->dlsch_rate_matching_stats);
+    reset_meas(&gNB->dlsch_segmentation_stats);
+    reset_meas(&gNB->dlsch_modulation_stats);
+    reset_meas(&gNB->dlsch_encoding_stats);
+    reset_meas(&gNB->tinput);
+    reset_meas(&gNB->tprep);
+    reset_meas(&gNB->tparity);
+    reset_meas(&gNB->toutput);  
+
     n_errors = 0;
     //n_errors2 = 0;
     //n_alamouti = 0;
-
+    errors_scrambling=0;
     n_false_positive = 0;
     for (trial = 0; trial < n_trials; trial++) {
 
       errors_bit = 0;
       //multipath channel
       //multipath_channel(gNB2UE,s_re,s_im,r_re,r_im,frame_length_complex_samples,0);
+
+      memset(RC.nrmac[0]->cce_list[1][0],0,MAX_NUM_CCE*sizeof(int));
+      clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot);
+      if (css_flag == 0) nr_schedule_uss_dlsch_phytest(0,frame,slot,&dlsch_config);
+      else               nr_schedule_css_dlsch_phytest(0,frame,slot);
+      
+      
+      Sched_INFO.module_id = 0;
+      Sched_INFO.CC_id     = 0;
+      Sched_INFO.frame     = frame;
+      Sched_INFO.slot      = slot;
+      Sched_INFO.DL_req    = &gNB_mac->DL_req[0];
+      Sched_INFO.UL_tti_req    = &gNB_mac->UL_tti_req[0];
+      Sched_INFO.UL_dci_req  = NULL;
+      Sched_INFO.TX_req    = &gNB_mac->TX_req[0];
+      nr_schedule_response(&Sched_INFO);
+      
+      if (run_initial_sync)
+        nr_common_signal_procedures(gNB,frame,slot);
+      else
+        phy_procedures_gNB_TX(gNB,frame,slot,0);
+          
+      int txdataF_offset = (slot%2) * frame_parms->samples_per_slot_wCP;
+      
+      if (n_trials==1) {
+	LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1);
+	if (gNB->frame_parms.nb_antennas_tx>1)
+	  LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);
+      }
+      int tx_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);
+      if (n_trials==1) printf("samples_per_slot_wCP = %d\n", frame_parms->samples_per_slot_wCP);
+      
+      //TODO: loop over slots
+      for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) {
+	
+	if (cyclic_prefix_type == 1) {
+	  PHY_ofdm_mod(&gNB->common_vars.txdataF[aa][txdataF_offset],
+		       &txdata[aa][tx_offset],
+		       frame_parms->ofdm_symbol_size,
+		       12,
+		       frame_parms->nb_prefix_samples,
+		       CYCLIC_PREFIX);
+	} else {
+	  nr_normal_prefix_mod(&gNB->common_vars.txdataF[aa][txdataF_offset],
+			       &txdata[aa][tx_offset],
+			       14,
+			       frame_parms);
+	}
+      }
+     
+      if (n_trials==1) {
+	LOG_M("txsig0.m","txs0", txdata[0],frame_length_complex_samples,1,1);
+	if (gNB->frame_parms.nb_antennas_tx>1)
+	  LOG_M("txsig1.m","txs1", txdata[1],frame_length_complex_samples,1,1);
+      }
+      if (output_fd) 
+	fwrite(txdata[0],sizeof(int32_t),frame_length_complex_samples,output_fd);
+      
+      int txlev = signal_energy(&txdata[0][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)+5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0],
+				frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples);
+      
+      //  if (n_trials==1) printf("txlev %d (%f)\n",txlev,10*log10((double)txlev));
+      
+      for (i=(frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)); 
+	   i<(frame_parms->get_samples_slot_timestamp(slot+1,frame_parms,0)); 
+	   i++) {
+	for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
+	  r_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]);
+	  r_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]);
+	}
+      }
+      
+      NR_gNB_DLSCH_t *gNB_dlsch = gNB->dlsch[0][0];
+      nfapi_nr_dl_tti_pdsch_pdu_rel15_t rel15 = gNB_dlsch->harq_processes[0]->pdsch_pdu.pdsch_pdu_rel15;
       
       //AWGN
-      sigma2_dB = 10 * log10((double)txlev) - SNR;
+      sigma2_dB = 10 * log10((double)txlev * ((double)UE->frame_parms.ofdm_symbol_size/(12*rel15.rbSize))) - SNR;
       sigma2    = pow(10, sigma2_dB/10);
-      // printf("sigma2 %f (%f dB)\n",sigma2,sigma2_dB);
-
-      for (i=0; i<frame_length_complex_samples; i++) {
+      if (n_trials==1) printf("sigma2 %f (%f dB), txlev %f (factor %f)\n",sigma2,sigma2_dB,10*log10((double)txlev),(double)(double)UE->frame_parms.ofdm_symbol_size/(12*rel15.rbSize));
+      
+      for (i=frame_parms->get_samples_slot_timestamp(slot,frame_parms,0); 
+	   i<frame_parms->get_samples_slot_timestamp(slot+1,frame_parms,0);
+	   i++) {
 	for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
 	  ((short*) UE->common_vars.rxdata[aa])[2*i]   = (short) ((r_re[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
 	  ((short*) UE->common_vars.rxdata[aa])[2*i+1] = (short) ((r_im[aa][i] + sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
 	}
       }
-
-      if (n_trials == 1) {
-
-        LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0], frame_length_complex_samples, 1, 1);
-        if (UE->frame_parms.nb_antennas_rx>1)
-          LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1], frame_length_complex_samples, 1, 1);
-
+      
+      UE->rx_offset=0;
+      UE_proc.frame_rx = frame;
+      UE_proc.nr_tti_rx= slot;
+      UE_proc.subframe_rx = slot;
+      
+      dcireq.frame     = frame;
+      dcireq.slot      = slot;
+      
+      nr_ue_dcireq(&dcireq); //to be replaced with function pointer later
+      nr_ue_scheduled_response(&scheduled_response);
+      
+      phy_procedures_nrUE_RX(UE,
+			     &UE_proc,
+			     0,
+			     do_pdcch_flag,
+			     normal_txrx);
+      
+      if (UE->dlsch[UE->current_thread_id[slot]][0][0]->last_iteration_cnt >= 
+	  UE->dlsch[UE->current_thread_id[slot]][0][0]->max_ldpc_iterations+1)
+	n_errors++;
+      
+      //----------------------------------------------------------
+      //---------------------- count errors ----------------------
+      //----------------------------------------------------------
+      
+      
+      
+      NR_UE_DLSCH_t *dlsch0 = UE->dlsch[UE->current_thread_id[UE_proc.nr_tti_rx]][0][0];
+      
+      int harq_pid = dlsch0->current_harq_pid;
+      NR_DL_UE_HARQ_t *UE_harq_process = dlsch0->harq_processes[harq_pid];
+      
+      NR_UE_PDSCH **pdsch_vars = UE->pdsch_vars[UE->current_thread_id[UE_proc.nr_tti_rx]];
+      int16_t *UE_llr = pdsch_vars[0]->llr[0];
+      
+      
+      uint32_t TBS         = rel15.TBSize[0];
+      uint16_t length_dmrs = 1;
+      uint16_t nb_rb       = rel15.rbSize;
+      uint8_t  nb_re_dmrs  = rel15.dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6 : 4;
+      uint8_t  mod_order   = rel15.qamModOrder[0];
+      uint8_t  nb_symb_sch = rel15.NrOfSymbols;
+      
+      available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, rel15.nrOfLayers);
+      
+      for (i = 0; i < available_bits; i++) {
+	
+	if(((gNB_dlsch->harq_processes[harq_pid]->f[i] == 0) && (UE_llr[i] <= 0)) || 
+	   ((gNB_dlsch->harq_processes[harq_pid]->f[i] == 1) && (UE_llr[i] >= 0)))
+	  {
+	    if(errors_scrambling == 0) {
+	      LOG_D(PHY,"\n");
+	      LOG_D(PHY,"First bit in error in unscrambling = %d\n",i);
+	    }
+	    errors_scrambling++;
+	  }
+	
       }
-
-      if (UE->is_synchronized == 0) {
-
-        UE_nr_rxtx_proc_t proc = {0};
-        ret = nr_initial_sync(&proc, UE, normal_txrx, 1);
-        printf("nr_initial_sync1 returns %d\n", ret);
-
-        if (ret < 0) 
-          n_errors++;
-
-      } else { // UE->is_synchronized != 0
-
-        UE->rx_offset       = 0;
-        UE_proc.frame_rx    = frame;
-        UE_proc.nr_tti_rx   = slot;
-        UE_proc.subframe_rx = slot;
-
-        nr_ue_scheduled_response(&UE_mac->scheduled_response);
-
-        printf("Running phy procedures UE RX %d.%d\n", frame, slot);
-
-        phy_procedures_nrUE_RX(UE,
-                               &UE_proc,
-                               0,
-                               do_pdcch_flag,
-                               normal_txrx);
-
-        if (n_trials == 1) {
-
-          LOG_M("rxsigF0.m","rxsF0", UE->common_vars.common_vars_rx_data_per_thread[0].rxdataF[0], slot_length_complex_samples_no_prefix, 1, 1);
-          if (UE->frame_parms.nb_antennas_rx > 1)
-            LOG_M("rxsigF1.m","rxsF1", UE->common_vars.common_vars_rx_data_per_thread[0].rxdataF[1], slot_length_complex_samples_no_prefix, 1, 1);
-
-        }
-
-        if (UE->dlsch[UE->current_thread_id[slot]][0][0]->last_iteration_cnt >= 
-	    UE->dlsch[UE->current_thread_id[slot]][0][0]->max_ldpc_iterations+1)
-          n_errors++;
-
-        //----------------------------------------------------------
-        //---------------------- count errors ----------------------
-        //----------------------------------------------------------
-        
-        NR_gNB_DLSCH_t *gNB_dlsch = gNB->dlsch[0][0];
-
-        NR_UE_DLSCH_t *dlsch0 = UE->dlsch[UE->current_thread_id[UE_proc.nr_tti_rx]][0][0];
-        int harq_pid = dlsch0->current_harq_pid;
-        NR_DL_UE_HARQ_t *UE_harq_process = dlsch0->harq_processes[harq_pid];
-        
-        NR_UE_PDSCH **pdsch_vars = UE->pdsch_vars[UE->current_thread_id[UE_proc.nr_tti_rx]];
-        int16_t *UE_llr = pdsch_vars[0]->llr[0];
-
-        nfapi_nr_dl_config_dlsch_pdu_rel15_t rel15 = gNB_dlsch->harq_processes[harq_pid]->dlsch_pdu.dlsch_pdu_rel15;
-        uint32_t TBS         = rel15.transport_block_size;
-        uint16_t length_dmrs = 1;
-        uint16_t nb_rb       = rel15.n_prb;
-        uint8_t  nb_re_dmrs  = rel15.nb_re_dmrs;
-        uint8_t  mod_order   = rel15.modulation_order;
-        uint8_t  nb_symb_sch = rel15.nb_symbols;
-        
-        available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, rel15.nb_layers);
-        
-        printf("\n");
-        printf("available_bits = %u\n", available_bits);
-  
-        for (i = 0; i < available_bits; i++) {
-          
-          if(((gNB_dlsch->harq_processes[harq_pid]->f[i] == 0) && (UE_llr[i] <= 0)) || 
-             ((gNB_dlsch->harq_processes[harq_pid]->f[i] == 1) && (UE_llr[i] >= 0)))
-          {
-            if(errors_scrambling == 0) {
-              printf("\n");
-              printf("First bit in error in unscrambling = %d\n",i);
-            }
-            errors_scrambling++;
-          }
-  
-        }
-  
-        for (i = 0; i < TBS; i++) {
-  
-          estimated_output_bit[i] = (UE_harq_process->b[i/8] & (1 << (i & 7))) >> (i & 7);
-          test_input_bit[i]       = (gNB_dlsch->harq_processes[harq_pid]->b[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments
-  
-          if (estimated_output_bit[i] != test_input_bit[i]) {
-            if(errors_bit == 0)
-              printf("First bit in error in decoding = %d\n",i);
-            errors_bit++;
-          }
-          
-        }
-  
-        ////////////////////////////////////////////////////////////
-  
-        if (errors_scrambling > 0) {
-          if (n_trials == 1)
-            printf("errors_scrambling = %u (trial %d)\n", errors_scrambling, trial);
-        }
-  
-        if (errors_bit > 0) {
-          n_false_positive++;
-          if (n_trials == 1)
-            printf("errors_bit = %u (trial %d)\n", errors_bit, trial);
-        }
-
-        printf("\n");
-
-      } // if (UE->is_synchronized == 0)
-
+      for (i = 0; i < TBS; i++) {
+	
+	estimated_output_bit[i] = (UE_harq_process->b[i/8] & (1 << (i & 7))) >> (i & 7);
+	test_input_bit[i]       = (gNB_dlsch->harq_processes[harq_pid]->b[i / 8] & (1 << (i & 7))) >> (i & 7); // Further correct for multiple segments
+	
+	if (estimated_output_bit[i] != test_input_bit[i]) {
+	  if(errors_bit == 0)
+	    LOG_D(PHY,"First bit in error in decoding = %d (errors scrambling %d)\n",i,errors_scrambling);
+	  errors_bit++;
+	}
+	
+      }
+      
+      ////////////////////////////////////////////////////////////
+      
+      if (errors_scrambling > 0) {
+	if (n_trials == 1)
+	  printf("errors_scrambling = %d/%d (trial %d)\n", errors_scrambling, available_bits,trial);
+      }
+      
+      if (errors_bit > 0) {
+	n_false_positive++;
+	if (n_trials == 1)
+	  printf("errors_bit = %u (trial %d)\n", errors_bit, trial);
+      }
+      
     } // noise trials
 
     printf("*****************************************\n");
@@ -844,15 +883,75 @@ int main(int argc, char **argv)
            (float) n_errors / (float) n_trials);
     printf("*****************************************\n");
     printf("\n");
-
-    printf("SNR %f : n_errors (negative CRC) = %d/%d\n", SNR, n_errors, n_trials);
+    printf("SNR %f : n_errors (negative CRC) = %d/%d, Channel BER %e\n", SNR, n_errors, n_trials,(double)errors_scrambling/available_bits/n_trials);
     printf("\n");
 
+    if (n_trials == 1) {
+      
+      LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0], frame_length_complex_samples, 1, 1);
+      if (UE->frame_parms.nb_antennas_rx>1)
+	LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1], frame_length_complex_samples, 1, 1);
+      LOG_M("chestF0.m","chF0",UE->pdsch_vars[0][0]->dl_ch_estimates_ext,N_RB_DL*12*14,1,1);
+      write_output("rxF_comp.m","rxFc",&UE->pdsch_vars[0][0]->rxdataF_comp0[0][0],N_RB_DL*12*14,1,1);
+      break;
+    }
+
     if ((float)n_errors/(float)n_trials <= target_error_rate) {
       printf("PDSCH test OK\n");
       break;
     }
 
+
+    if (print_perf==1) {
+      printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, TBS %d, Kr %d (Zc %d))\n",
+	     1000>>*scc->ssbSubcarrierSpacing,dlsch_config.rbSize,dlsch_config.mcsIndex[0],
+	     gNB->dlsch[0][0]->harq_processes[0]->pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3,
+	     gNB->dlsch[0][0]->harq_processes[0]->K,
+	     gNB->dlsch[0][0]->harq_processes[0]->K/((gNB->dlsch[0][0]->harq_processes[0]->pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3)>3824?22:10));
+      printDistribution(&gNB->phy_proc_tx,table_tx,"PHY proc tx");
+      printStatIndent2(&gNB->dlsch_encoding_stats,"DLSCH encoding time");
+      printStatIndent3(&gNB->dlsch_segmentation_stats,"DLSCH segmentation time");
+      printStatIndent3(&gNB->tinput,"DLSCH LDPC input processing time");
+      printStatIndent3(&gNB->tprep,"DLSCH LDPC input preparation time");
+      printStatIndent3(&gNB->tparity,"DLSCH LDPC parity generation time");
+      printStatIndent3(&gNB->toutput,"DLSCH LDPC output generation time");
+      printStatIndent3(&gNB->dlsch_rate_matching_stats,"DLSCH Rate Mataching time");
+      printStatIndent3(&gNB->dlsch_interleaving_stats,  "DLSCH Interleaving time");
+      printStatIndent2(&gNB->dlsch_modulation_stats,"DLSCH modulation time");
+      printStatIndent2(&gNB->dlsch_scrambling_stats,  "DLSCH scrambling time");
+
+
+      printf("\nUE RX function statistics (per %d us slot)\n",1000>>*scc->ssbSubcarrierSpacing);
+      /*
+      printDistribution(&phy_proc_rx_tot, table_rx,"Total PHY proc rx");
+      printStatIndent(&ue_front_end_tot,"Front end processing");
+      printStatIndent(&dlsch_llr_tot,"rx_pdsch processing");
+      printStatIndent2(&pdsch_procedures_tot,"pdsch processing");
+      printStatIndent2(&dlsch_procedures_tot,"dlsch processing");
+      printStatIndent2(&UE->crnti_procedures_stats,"C-RNTI processing");
+      printStatIndent(&UE->ofdm_demod_stats,"ofdm demodulation");
+      printStatIndent(&UE->dlsch_channel_estimation_stats,"DLSCH channel estimation time");
+      printStatIndent(&UE->dlsch_freq_offset_estimation_stats,"DLSCH frequency offset estimation time");
+      printStatIndent(&dlsch_decoding_tot, "DLSCH Decoding time ");
+      printStatIndent(&UE->dlsch_unscrambling_stats,"DLSCH unscrambling time");
+      printStatIndent(&UE->dlsch_rate_unmatching_stats,"DLSCH Rate Unmatching");
+      printf("|__ DLSCH Turbo Decoding(%d bits), avg iterations: %.1f       %.2f us (%d cycles, %d trials)\n",
+	     UE->dlsch[UE->current_thread_id[subframe]][0][0]->harq_processes[0]->Cminus ?
+	     UE->dlsch[UE->current_thread_id[subframe]][0][0]->harq_processes[0]->Kminus :
+	     UE->dlsch[UE->current_thread_id[subframe]][0][0]->harq_processes[0]->Kplus,
+	     UE->dlsch_tc_intl1_stats.trials/(double)UE->dlsch_tc_init_stats.trials,
+	     (double)UE->dlsch_turbo_decoding_stats.diff/UE->dlsch_turbo_decoding_stats.trials*timeBase,
+	     (int)((double)UE->dlsch_turbo_decoding_stats.diff/UE->dlsch_turbo_decoding_stats.trials),
+	     UE->dlsch_turbo_decoding_stats.trials);
+      printStatIndent2(&UE->dlsch_tc_init_stats,"init");
+      printStatIndent2(&UE->dlsch_tc_alpha_stats,"alpha");
+      printStatIndent2(&UE->dlsch_tc_beta_stats,"beta");
+      printStatIndent2(&UE->dlsch_tc_gamma_stats,"gamma");
+      printStatIndent2(&UE->dlsch_tc_ext_stats,"ext");
+      printStatIndent2(&UE->dlsch_tc_intl1_stats,"turbo internal interleaver");
+      printStatIndent2(&UE->dlsch_tc_intl2_stats,"intl2+HardDecode+CRC");
+      */
+    }
   } // NSR
 
   for (i = 0; i < 2; i++) {
@@ -878,5 +977,5 @@ int main(int argc, char **argv)
     fclose(input_fd);
 
   return(n_errors);
-
+  
 }
diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c
index ae47b11b2f0..c9253aeedf5 100644
--- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c
+++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c
@@ -2,7 +2,7 @@ int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req)             { re
 int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req)                            { return(0);  }
 int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req)       { return(0);  }
 int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req)       { return(0);  }
-int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_config_request_t *dl_config_req) { return(0);  }
+//int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_config_request_t *dl_config_req) { return(0);  }
 int32_t get_uldl_offset(int nr_bandP)                                       { return(0);  }
 NR_IF_Module_t *NR_IF_Module_init(int Mod_id)                               {return(NULL);}
 int dummy_nr_ue_dl_indication(nr_downlink_indication_t *dl_info)            { return(0);  }
diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
index 78596cc792a..c7a30f826e7 100644
--- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
+++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
@@ -55,4 +55,172 @@ signed char quantize(double D, double x, unsigned char B) {
   return ((char) qxd);
 }
 
+void fill_scc(NR_ServingCellConfigCommon_t *scc,uint64_t *ssb_bitmap,int N_RB_DL,int N_RB_UL,int mu_dl,int mu_ul) {
+
+  *scc->physCellId=0;							\
+  //  *scc->n_TimingAdvanceOffset=NR_ServingCellConfigCommon__n_TimingAdvanceOffset_n0;
+  *scc->ssb_periodicityServingCell=NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms20;
+  scc->dmrs_TypeA_Position=NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2;
+  *scc->ssbSubcarrierSpacing=NR_SubcarrierSpacing_kHz30;
+  *scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB=641032;
+  *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]=78;
+  scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA=640000;
+  scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier=0;
+  scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=NR_SubcarrierSpacing_kHz30;
+
+  scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth=N_RB_DL;
+  scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth=13036;
+  scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing=mu_dl;//NR_SubcarrierSpacing_kHz30;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=12;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero=0;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[0]->k0=0;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[0]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[0]->startSymbolAndLength=40;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[1]->k0=0;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[1]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[1]->startSymbolAndLength=53;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[2]->k0=0;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[2]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[2]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[3]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[3]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[3]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[4]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[4]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[4]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[5]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[5]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[5]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[6]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[6]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[6]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[7]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[7]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[7]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[8]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[8]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[8]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[9]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[9]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[9]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[10]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[10]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[10]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[11]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[11]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[11]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[12]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[12]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[12]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[13]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[13]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[13]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[14]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[14]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[14]->startSymbolAndLength=54;
+  *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[15]->k0=-1;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[15]->mappingType=NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[15]->startSymbolAndLength=54;
+  *scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]=78;
+  *scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA=-1;
+  scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier=0;
+  scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing=NR_SubcarrierSpacing_kHz30;
+  scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth=N_RB_UL;
+  *scc->uplinkConfigCommon->frequencyInfoUL->p_Max=20;
+  scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth=13036;
+  scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing=mu_ul;//NR_SubcarrierSpacing_kHz30;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.prach_ConfigurationIndex=98;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FDM=NR_RACH_ConfigGeneric__msg1_FDM_one;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FrequencyStart=0;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.zeroCorrelationZoneConfig=13;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleReceivedTargetPower=-118;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleTransMax=NR_RACH_ConfigGeneric__preambleTransMax_n10;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.powerRampingStep=NR_RACH_ConfigGeneric__powerRampingStep_dB2;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.ra_ResponseWindow=NR_RACH_ConfigGeneric__ra_ResponseWindow_sl20;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present=NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one=NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n64;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ra_ContentionResolutionTimer=NR_RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
+  *scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rsrp_ThresholdSSB=19;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present=NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l139=0;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->restrictedSetConfig=NR_RACH_ConfigCommon__restrictedSetConfig_unrestrictedSet;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->k2=2;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[1]->k2=2;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[1]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[1]->startSymbolAndLength=69;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[2]->k2=2;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[2]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[2]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[3]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[3]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[3]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[4]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[4]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[4]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[5]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[5]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[5]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[6]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[6]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[6]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[7]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[7]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[7]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[8]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[8]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[8]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[9]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[9]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[9]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[10]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[10]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[10]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[11]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[11]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[11]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[12]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[12]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[12]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[13]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[13]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[13]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[14]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[14]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[14]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[15]->k2=33;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[15]->mappingType=NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[15]->startSymbolAndLength=55;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble=1;
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->p0_NominalWithGrant=-90;
+ scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_GroupHopping=NR_PUCCH_ConfigCommon__pucch_GroupHopping_neither; 
+ *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->hoppingId=40;
+ *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->p0_nominal=-90;
+ scc->ssb_PositionsInBurst->present=NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap;
+ *ssb_bitmap=0xff;
+ scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing=NR_SubcarrierSpacing_kHz30;
+ scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity=NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5;
+ scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots=7;
+ scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols=6;
+ scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots=2;
+ scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols=4;
+ scc->tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity=321;
+
+ scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots=-1;
+ scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSymbols=-1;
+ scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofUplinkSlots=-1;
+ scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofUplinkSymbols=-1;
+ scc->ss_PBCH_BlockPower=20;
+ *scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing=-1;
+}
+
+void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap);
+void prepare_scc(NR_ServingCellConfigCommon_t *scc);
+s1ap_eNB_config_t s1ap_config;
+uint32_t s1ap_generate_eNB_id(void) {return 0;}
+void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port) { return;}
+void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port) { return;}
+
+
 #endif
diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c
index 58bf213e3ac..99ca466fee4 100644
--- a/openair1/SIMULATION/NR_PHY/pbchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pbchsim.c
@@ -62,6 +62,50 @@ uint16_t NB_UE_INST = 1;
 openair0_config_t openair0_cfg[MAX_CARDS];
 uint64_t get_softmodem_optmask(void) {return 0;}
 
+void nr_phy_config_request_sim_pbchsim(PHY_VARS_gNB *gNB,
+                               int N_RB_DL,
+                               int N_RB_UL,
+                               int mu,
+                               int Nid_cell,
+                               uint64_t position_in_burst)
+{
+  NR_DL_FRAME_PARMS *fp                                   = &gNB->frame_parms;
+  nfapi_nr_config_request_scf_t *gNB_config               = &gNB->gNB_config;
+  //overwrite for new NR parameters
+
+  uint64_t rev_burst=0;
+  for (int i=0; i<64; i++)
+    rev_burst |= (((position_in_burst>>(63-i))&0x01)<<i);
+
+  gNB_config->cell_config.phy_cell_id.value             = Nid_cell;
+  gNB_config->ssb_config.scs_common.value               = mu;
+  gNB_config->ssb_table.ssb_subcarrier_offset.value     = 0;
+  gNB_config->ssb_table.ssb_offset_point_a.value        = (N_RB_DL-20)>>1;
+  gNB_config->ssb_table.ssb_mask_list[1].ssb_mask.value = (rev_burst)&(0xFFFFFFFF);
+  gNB_config->ssb_table.ssb_mask_list[0].ssb_mask.value = (rev_burst>>32)&(0xFFFFFFFF);
+  gNB_config->cell_config.frame_duplex_type.value       = TDD;
+  gNB_config->ssb_table.ssb_period.value		= 1; //10ms
+  gNB_config->carrier_config.dl_grid_size[mu].value     = N_RB_DL;
+  gNB_config->carrier_config.ul_grid_size[mu].value     = N_RB_UL;
+  gNB_config->carrier_config.num_tx_ant.value           = fp->nb_antennas_tx;
+  gNB_config->carrier_config.num_rx_ant.value           = fp->nb_antennas_rx;
+
+  gNB_config->tdd_table.tdd_period.value = 0;
+  //gNB_config->subframe_config.dl_cyclic_prefix_type.value = (fp->Ncp == NORMAL) ? NFAPI_CP_NORMAL : NFAPI_CP_EXTENDED;
+
+  gNB->mac_enabled   = 1;
+  fp->dl_CarrierFreq = 3500000000;//from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value);
+  fp->ul_CarrierFreq = 3500000000;//fp->dl_CarrierFreq - (get_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000);
+  if (mu>2) fp->nr_band = 257;
+  else fp->nr_band = 78;
+  fp->threequarter_fs= 0;
+
+  gNB_config->carrier_config.dl_bandwidth.value = config_bandwidth(mu, N_RB_DL, fp->nr_band);
+
+  nr_init_frame_parms(gNB_config, fp);
+  gNB->configured    = 1;
+  LOG_I(PHY,"gNB configured\n");
+}
 int main(int argc, char **argv)
 {
   char c;
@@ -112,7 +156,6 @@ int main(int argc, char **argv)
   int frame_length_complex_samples;
   int frame_length_complex_samples_no_prefix;
   NR_DL_FRAME_PARMS *frame_parms;
-  nfapi_nr_config_request_t *gNB_config;
 
   int ret, payload_ret=0;
   int run_initial_sync=0;
@@ -129,7 +172,7 @@ int main(int argc, char **argv)
 
   randominit(0);
 
-  while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:o:s:S:t:x:y:z:M:N:F:GR:dP:IL:")) != -1) {
+  while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:o:s:S:t:x:y:z:M:N:F:GR:dP:IL:m:")) != -1) {
     switch (c) {
     /*case 'f':
       write_output_file=1;
@@ -304,6 +347,10 @@ int main(int argc, char **argv)
       loglvl = atoi(optarg);
       break;
 
+    case 'm':
+      mu = atoi(optarg);
+      break;
+
     default:
     case 'h':
       printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n",
@@ -312,6 +359,7 @@ int main(int argc, char **argv)
       //printf("-p Use extended prefix mode\n");
       //printf("-d Use TDD\n");
       printf("-n Number of frames to simulate\n");
+      printf("-m Numerology index\n");
       printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB.  If n_frames is 1 then just SNR is simulated\n");
       printf("-S Ending SNR, runs from SNR0 to SNR1\n");
       printf("-t Delay spread for multipath channel\n");
@@ -344,26 +392,27 @@ int main(int argc, char **argv)
 
   printf("Initializing gNodeB for mu %d, N_RB_DL %d\n",mu,N_RB_DL);
 
-  RC.gNB = (PHY_VARS_gNB***) malloc(sizeof(PHY_VARS_gNB **));
-  RC.gNB[0] = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *));
-  RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB));
-  gNB = RC.gNB[0][0];
-  gNB_config = &gNB->gNB_config;
+  RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *));
+  RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB));
+  gNB = RC.gNB[0];
   frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
   frame_parms->nb_antennas_tx = n_tx;
   frame_parms->nb_antennas_rx = n_rx;
   frame_parms->N_RB_DL = N_RB_DL;
-  frame_parms->N_RB_UL = N_RB_DL;
   frame_parms->Nid_cell = Nid_cell;
   frame_parms->nushift = Nid_cell%4;
   frame_parms->ssb_type = nr_ssb_type_C;
 
-  nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions);
+  nr_phy_config_request_sim_pbchsim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions);
   phy_init_nr_gNB(gNB,0,0);
+  nr_set_ssb_first_subcarrier(&gNB->gNB_config,frame_parms);
 
-  uint8_t n_hf = gNB_config->sch_config.half_frame_index.value;
+  uint8_t n_hf = 0;
+  int cyclic_prefix_type = NFAPI_CP_NORMAL;
 
-  double fs,bw,scs,eps;
+  double fs, eps;
+  double scs = 30000;
+  double bw = 100e6;
   
   switch (mu) {
     case 1:
@@ -387,8 +436,17 @@ int main(int argc, char **argv)
 	}
 	else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL);
 	break;
-  }
+  
 
+    case 3:
+      scs = 120000;
+      if (N_RB_DL == 66) {
+        fs = 122.88e6;
+        bw = 100e6;
+      }
+      else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL);
+      break;
+  }
   // cfo with respect to sub-carrier spacing
   eps = cfo/scs;
 
@@ -470,27 +528,28 @@ int main(int argc, char **argv)
   // generate signal
   if (input_fd==NULL) {
     gNB->pbch_configured = 1;
-    for (int i=0;i<4;i++) gNB->pbch_pdu[i]=i+1;
+ 
+    gNB->ssb_pdu.ssb_pdu_rel15.bchPayload = 0;
 
     for (int slot=0;slot<frame_parms->slots_per_frame;slot++) {
     	for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++)
     		memset(gNB->common_vars.txdataF[aa],0,frame_parms->samples_per_slot_wCP*sizeof(int32_t));
       
     	nr_common_signal_procedures (gNB,frame,slot);
-      
+
     	for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) {
-    		if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) {
+    		if (cyclic_prefix_type == 1) {
     			PHY_ofdm_mod(gNB->common_vars.txdataF[aa],
-    					&txdata[aa][slot*frame_parms->samples_per_slot],
-						frame_parms->ofdm_symbol_size,
-						12,
-						frame_parms->nb_prefix_samples,
-						CYCLIC_PREFIX);
+    			             &txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)],
+				     frame_parms->ofdm_symbol_size,
+				     12,
+				     frame_parms->nb_prefix_samples,
+				     CYCLIC_PREFIX);
     		} else {
     			nr_normal_prefix_mod(gNB->common_vars.txdataF[aa],
-    					&txdata[aa][slot*frame_parms->samples_per_slot],
-						14,
-						frame_parms);
+    			                     &txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)],
+			                     14,
+			                     frame_parms);
     		}
     	}
     }
@@ -578,7 +637,6 @@ int main(int argc, char **argv)
 	if (gNB->frame_parms.nb_antennas_tx>1)
 	  LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1],frame_parms->samples_per_frame,1,1);
       }
-
       if (UE->is_synchronized == 0) {
 	UE_nr_rxtx_proc_t proc={0};
 	ret = nr_initial_sync(&proc, UE, normal_txrx,1);
@@ -589,8 +647,10 @@ int main(int argc, char **argv)
 	UE->rx_offset=0;
 	uint8_t ssb_index = 0;
         while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++;  // to select the first transmitted ssb
-	UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms, ssb_index, n_hf);
-        int ssb_slot = (ssb_index/2)+(n_hf*frame_parms->slots_per_frame);
+        frame_parms->ssb_index = ssb_index;
+	UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms);
+
+        int ssb_slot = (ssb_index>>1)+(n_hf*frame_parms->slots_per_frame);
 	for (int i=UE->symbol_offset+1; i<UE->symbol_offset+4; i++) {
 	  nr_slot_fep(UE,
 	  	      i%frame_parms->symbols_per_slot,
@@ -618,11 +678,10 @@ int main(int argc, char **argv)
 	  uint8_t gNB_xtra_byte=0;
 	  for (int i=0; i<8; i++)
 	    gNB_xtra_byte |= ((gNB->pbch.pbch_a>>(31-i))&1)<<(7-i);
-
+ 
 	  payload_ret = (UE->pbch_vars[0]->xtra_byte == gNB_xtra_byte);
 	  for (i=0;i<3;i++){
-	    payload_ret += (UE->pbch_vars[0]->decoded_output[i] == gNB->pbch_pdu[2-i]);
-	    //printf("pdu byte %d gNB: 0x%02x UE: 0x%02x\n",i,gNB->pbch_pdu[i], UE->rx_ind.rx_indication_body->mib_pdu.pdu[i]); 
+	    payload_ret += (UE->pbch_vars[0]->decoded_output[i] == (gNB->ssb_pdu.ssb_pdu_rel15.bchPayload>>(8*i)));
 	  } 
 	  //printf("xtra byte gNB: 0x%02x UE: 0x%02x\n",gNB_xtra_byte, UE->rx_ind.rx_indication_body->mib_pdu.additional_bits);
 	  //printf("ret %d\n", payload_ret);
diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c
index 6d590a24584..445c45693ed 100644
--- a/openair1/SIMULATION/NR_PHY/pucchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pucchsim.c
@@ -304,10 +304,11 @@ int main(int argc, char **argv)
 
   printf("Initializing gNodeB for mu %d, N_RB_DL %d\n",mu,N_RB_DL);
 
-  RC.gNB = (PHY_VARS_gNB***) malloc(sizeof(PHY_VARS_gNB **));
-  RC.gNB[0] = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *));
-  RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB));
-  gNB = RC.gNB[0][0];
+
+  RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *));
+  RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB));
+  gNB = RC.gNB[0];
+
   frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
   frame_parms->nb_antennas_tx = n_tx;
   frame_parms->nb_antennas_rx = n_rx;
@@ -315,6 +316,9 @@ int main(int argc, char **argv)
   frame_parms->N_RB_UL = N_RB_DL;
   frame_parms->Nid_cell = Nid_cell;
 
+  nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
+  cfg->carrier_config.num_tx_ant.value = n_tx;
+  cfg->carrier_config.num_rx_ant.value = n_rx;
   nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions);
   phy_init_nr_gNB(gNB,0,0);
 
diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c
index f2783605fe5..48ea26da8f0 100644
--- a/openair1/SIMULATION/NR_PHY/ulschsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulschsim.c
@@ -232,9 +232,9 @@ int main(int argc, char **argv)
         break;
 
       case 'R':
-        N_RB_DL = atoi(optarg);
+        N_RB_UL = atoi(optarg);
 #ifdef DEBUG_NR_ULSCHSIM
-        printf("N_RB_DL (-R) = %d\n", N_RB_DL);
+        printf("N_RB_UL (-R) = %d\n", N_RB_UL);
 #endif
         break;
 
@@ -292,7 +292,7 @@ int main(int argc, char **argv)
           //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n");
           printf("-M Multiple SSB positions in burst\n");
           printf("-N Nid_cell\n");
-          printf("-R N_RB_DL\n");
+          printf("-R N_RB_UL\n");
           printf("-F Input filename (.txt format) for RX conformance testing\n");
           printf("-m\n");
           printf("-l\n");
@@ -327,10 +327,11 @@ int main(int argc, char **argv)
     exit(-1);
   }
 
-  RC.gNB = (PHY_VARS_gNB ** *) malloc(sizeof(PHY_VARS_gNB **));
-  RC.gNB[0] = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *));
-  RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB));
-  gNB = RC.gNB[0][0];
+
+  RC.gNB = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *));
+  RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB));
+  gNB = RC.gNB[0];
+  //gNB_config = &gNB->gNB_config;
 
   frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
   frame_parms->nb_antennas_tx = n_tx;
@@ -338,10 +339,11 @@ int main(int argc, char **argv)
   frame_parms->N_RB_DL = N_RB_DL;
   frame_parms->N_RB_UL = N_RB_UL;
   frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL;
-
   crcTableInit();
 
-  nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell, SSB_positions);
+  memcpy(&gNB->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS));
+
+  nr_phy_config_request_sim(gNB, N_RB_UL, N_RB_UL, mu, Nid_cell, SSB_positions);
 
   phy_init_nr_gNB(gNB, 0, 0);
 
@@ -369,7 +371,6 @@ int main(int argc, char **argv)
   }
 
   unsigned char harq_pid = 0;
-  uint8_t is_crnti = 0;
   unsigned int TBS = 8424;
   unsigned int available_bits;
   uint8_t nb_re_dmrs = 6;
@@ -383,7 +384,7 @@ int main(int argc, char **argv)
 
   NR_gNB_ULSCH_t *ulsch_gNB = gNB->ulsch[UE_id][0];
   NR_UL_gNB_HARQ_t *harq_process_gNB = ulsch_gNB->harq_processes[harq_pid];
-  nfapi_nr_ul_config_ulsch_pdu_rel15_t *rel15_ul = &harq_process_gNB->ulsch_pdu.ulsch_pdu_rel15;
+  nfapi_nr_pusch_pdu_t *rel15_ul = &harq_process_gNB->ulsch_pdu;
 
   NR_UE_ULSCH_t *ulsch_ue = UE->ulsch[0][0][0];
 
@@ -395,14 +396,15 @@ int main(int argc, char **argv)
   printf("\nAvailable bits %u TBS %u mod_order %d\n", available_bits, TBS, mod_order);
 
   /////////// setting rel15_ul parameters ///////////
-  rel15_ul->number_rbs     = nb_rb;
-  rel15_ul->number_symbols = nb_symb_sch;
-  rel15_ul->Qm             = mod_order;
-  rel15_ul->mcs            = Imcs;
-  rel15_ul->rv             = rvidx;
-  rel15_ul->n_layers       = Nl;
-  rel15_ul->length_dmrs    = length_dmrs;
-  rel15_ul->R              = code_rate;
+  rel15_ul->rb_size             = nb_rb;
+  rel15_ul->nr_of_symbols       = nb_symb_sch;
+  rel15_ul->qam_mod_order       = mod_order;
+  rel15_ul->mcs_index           = Imcs;
+  rel15_ul->pusch_data.rv_index = rvidx;
+  rel15_ul->nrOfLayers          = Nl;
+  //rel15_ul->length_dmrs       = length_dmrs;
+  rel15_ul->target_code_rate    = code_rate;
+  rel15_ul->pusch_data.tb_size  = TBS>>3;
   ///////////////////////////////////////////////////
 
   double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc
@@ -516,16 +518,24 @@ int main(int argc, char **argv)
         if (channel_output_uncoded[i] != ulsch_ue->harq_processes[harq_pid]->f[i])
           errors_bit_uncoded = errors_bit_uncoded + 1;
       }
-
+/*
       printf("errors bits uncoded %u\n", errors_bit_uncoded);
       printf("\n");
+*/
 #ifdef DEBUG_CODER
       printf("\n");
       exit(-1);
 #endif
 
-      ret = nr_ulsch_decoding(gNB, UE_id, channel_output_fixed, frame_parms,
-                              frame, nb_symb_sch, nb_re_dmrs, subframe, harq_pid, is_crnti);
+     uint32_t G = nr_get_G(rel15_ul->rb_size,
+                           rel15_ul->nr_of_symbols,
+                           nb_re_dmrs,
+                           1, // FIXME only single dmrs is implemented 
+                           rel15_ul->qam_mod_order,
+                           rel15_ul->nrOfLayers);
+
+      ret = nr_ulsch_decoding(gNB, UE_id, channel_output_fixed, frame_parms, rel15_ul,
+                              frame, subframe, harq_pid, G);
 
       if (ret > ulsch_gNB->max_ldpc_iterations)
         n_errors++;
@@ -541,13 +551,13 @@ int main(int argc, char **argv)
           errors_bit++;
         }
       }
-
+/*
       if (errors_bit > 0) {
         n_false_positive++;
         if (n_trials == 1)
           printf("errors_bit %u (trial %d)\n", errors_bit, trial);
       }
-      printf("\n");
+      printf("\n");*/
     }
     
     printf("*****************************************\n");
@@ -557,7 +567,7 @@ int main(int argc, char **argv)
     printf("*****************************************\n");
     printf("\n");
 
-    if (errors_bit == 0) {
+    if (n_errors == 0) {
       printf("PUSCH test OK\n");
       printf("\n");
       break;
@@ -565,6 +575,7 @@ int main(int argc, char **argv)
     printf("\n");
   }
 
+
   if (output_fd)
     fclose(output_fd);
 
diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c
index adfb09ea6ee..2adc67501a5 100644
--- a/openair1/SIMULATION/NR_PHY/ulsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulsim.c
@@ -52,7 +52,7 @@
 #include "openair1/SIMULATION/TOOLS/sim.h"
 #include "openair1/SIMULATION/RF/rf.h"
 #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h"
-#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
+#include "openair2/RRC/NR/MESSAGES/asn1_msg.h"
 #include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
 #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h"
 
@@ -63,20 +63,39 @@ PHY_VARS_NR_UE *UE;
 RAN_CONTEXT_t RC;
 int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
 
+int sf_ahead=4 ;
+int sl_ahead=0;
 double cpuf;
 uint8_t nfapi_mode = 0;
 uint16_t NB_UE_INST = 1;
+uint64_t downlink_frequency[MAX_NUM_CCs][4];
+
 
-// dummy functions
 int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, const uint8_t gNB_index,
                               const int8_t channel, const uint8_t* pduP, const sdu_size_t pdu_len) { return 0; }
-uint64_t get_softmodem_optmask(void) {return 0;}
-//int rlc_module_init (int enb) {return(0);}
+int generate_dlsch_header(unsigned char *mac_header,
+                          unsigned char num_sdus,
+                          unsigned short *sdu_lengths,
+                          unsigned char *sdu_lcids,
+                          unsigned char drx_cmd,
+                          unsigned short timing_advance_cmd,
+                          unsigned char *ue_cont_res_id,
+                          unsigned char short_padding,
+                          unsigned short post_padding){return 0;}
 void pdcp_layer_init (void) {}
-boolean_t pdcp_data_ind( const protocol_ctxt_t *const ctxt_pP, const srb_flag_t   srb_flagP, const MBMS_flag_t  MBMS_flagP, const rb_id_t      rb_idP,
-						 const sdu_size_t   sdu_buffer_sizeP, mem_block_t *const sdu_buffer_pP)
-{return (0);}
+boolean_t pdcp_data_ind(
+  const protocol_ctxt_t *const ctxt_pP,
+  const srb_flag_t   srb_flagP,
+  const MBMS_flag_t  MBMS_flagP,
+  const rb_id_t      rb_idP,
+  const sdu_size_t   sdu_buffer_sizeP,
+  mem_block_t *const sdu_buffer_pP
+) { return(false);}
+
+void pdcp_run (const protocol_ctxt_t *const  ctxt_pP) { return;}
 void nr_ip_over_LTE_DRB_preconfiguration(void){}
+int rrc_init_nr_global_param(void){return(0);}
+
 
 // needed for some functions
 uint16_t n_rnti = 0x1234;
@@ -88,9 +107,9 @@ int main(int argc, char **argv)
   int i,sf;
   double SNR, snr0 = -2.0, snr1 = 2.0;
   double sigma, sigma_dB;
-  double snr_step = 0.1;
+  double snr_step = 1;
   uint8_t snr1set = 0;
-  int slot = 0;
+  int slot = 0, frame = 0;
   FILE *output_fd = NULL;
   //uint8_t write_output_file = 0;
   int trial, n_trials = 1, n_errors = 0, n_false_positive = 0, delay = 0;
@@ -104,8 +123,7 @@ int main(int argc, char **argv)
   SCM_t channel_model = AWGN;  //Rayleigh1_anticorr;
   uint16_t N_RB_DL = 106, N_RB_UL = 106, mu = 1;
   //unsigned char frame_type = 0;
-  int number_of_frames = 1;
-  int frame_length_complex_samples;
+  int frame_length_complex_samples,frame_length_complex_samples_no_prefix;
   NR_DL_FRAME_PARMS *frame_parms;
   int loglvl = OAILOG_WARNING;
   uint64_t SSB_positions=0x01;
@@ -121,11 +139,13 @@ int main(int argc, char **argv)
   int32_t txlev;
   int start_rb = 0;
   int UE_id =0; // [hna] only works for UE_id = 0 because NUMBER_OF_NR_UE_MAX is set to 1 (phy_init_nr_gNB causes segmentation fault)
-
+  float target_error_rate = 0.01;
+  
   cpuf = get_cpu_freq_GHz();
 
 
   UE_nr_rxtx_proc_t UE_proc;
+  FILE *scg_fd=NULL;
 
 
   if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0 ) {
@@ -147,19 +167,14 @@ int main(int argc, char **argv)
         break;
 
       case 'f':
-        number_of_frames = atoi(optarg);
-        break;
+         scg_fd = fopen(optarg, "r");
 
-      /*case 'f':
-         write_output_file = 1;
-         output_fd = fopen(optarg, "w");
-
-         if (output_fd == NULL) {
+         if (scg_fd == NULL) {
              printf("Error opening %s\n", optarg);
              exit(-1);
          }
 
-         break;*/
+         break;
 
       case 'g':
         switch ((char) *optarg) {
@@ -316,10 +331,10 @@ int main(int argc, char **argv)
           //printf("-x Transmission mode (1,2,6 for the moment)\n");
           printf("-y Number of TX antennas used in eNB\n");
           printf("-z Number of RX antennas used in UE\n");
-
           printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n");
           //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n");
           printf("-F Input filename (.txt format) for RX conformance testing\n");
+	  printf("-G raw file containing RRC configuration (generated by gNB)\n");
           printf("-M Multiple SSB positions in burst\n");
           printf("-N Nid_cell\n");
           printf("-O oversampling factor (1,2,4,8,16)\n");
@@ -334,6 +349,8 @@ int main(int argc, char **argv)
   set_glog(loglvl);
   T_stdout = 1;
 
+  get_softmodem_params()->phy_test = 1;
+    
   if (snr1set == 0)
     snr1 = snr0 + 10;
 
@@ -347,16 +364,16 @@ int main(int argc, char **argv)
     exit(-1);
   }
 
-  RC.gNB = (PHY_VARS_gNB ** *) malloc(sizeof(PHY_VARS_gNB **));
-  RC.gNB[0] = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *));
-  RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB));
-  gNB = RC.gNB[0][0];
+  RC.gNB = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *));
+  RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB));
+  gNB = RC.gNB[0];
   //gNB_config = &gNB->gNB_config;
 
   //memset((void *)&gNB->UL_INFO,0,sizeof(gNB->UL_INFO));
   gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list = (nfapi_rx_indication_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_rx_indication_pdu_t));
+  gNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list = (nfapi_crc_indication_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_crc_indication_pdu_t));
   gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus = 0;
-
+  gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs = 0;
   frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
   frame_parms->nb_antennas_tx = n_tx;
   frame_parms->nb_antennas_rx = n_rx;
@@ -364,15 +381,48 @@ int main(int argc, char **argv)
   frame_parms->N_RB_UL = N_RB_UL;
   frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL;
 
-  crcTableInit();
-
-  nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_UL, mu, Nid_cell, SSB_positions);
-
-  phy_init_nr_gNB(gNB, 0, 0);
-  //init_eNB_afterRU();
+  RC.nb_nr_macrlc_inst = 1;
+  RC.nb_nr_mac_CC = (int*)malloc(RC.nb_nr_macrlc_inst*sizeof(int));
+  for (i = 0; i < RC.nb_nr_macrlc_inst; i++)
+    RC.nb_nr_mac_CC[i] = 1;
+  mac_top_init_gNB();
+  gNB_MAC_INST* gNB_mac = RC.nrmac[0];
+  gNB_RRC_INST rrc;
+  memset((void*)&rrc,0,sizeof(rrc));
+
+  rrc.carrier.servingcellconfigcommon = calloc(1,sizeof(*rrc.carrier.servingcellconfigcommon));
+
+  NR_ServingCellConfigCommon_t *scc = rrc.carrier.servingcellconfigcommon;
+  NR_CellGroupConfig_t *secondaryCellGroup=calloc(1,sizeof(*secondaryCellGroup));
+  prepare_scc(rrc.carrier.servingcellconfigcommon);
+  uint64_t ssb_bitmap;
+  fill_scc(rrc.carrier.servingcellconfigcommon,&ssb_bitmap,N_RB_DL,N_RB_DL,mu,mu);
+
+  fill_default_secondaryCellGroup(scc,
+				  secondaryCellGroup,
+				  0,
+				  1,
+				  n_tx,
+				  0);
+  fix_scc(scc,ssb_bitmap);
+
+  xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup);
+
+  AssertFatal((gNB->if_inst         = NR_IF_Module_init(0))!=NULL,"Cannot register interface");
+  gNB->if_inst->NR_PHY_config_req      = nr_phy_config_request;
+  // common configuration
+  rrc_mac_config_req_gNB(0,0,1,scc,0,0,NULL);
+  // UE dedicated configuration
+  rrc_mac_config_req_gNB(0,0,1,NULL,1,secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup);
+  phy_init_nr_gNB(gNB,0,0);
+  N_RB_DL = gNB->frame_parms.N_RB_DL;
+
+  //crcTableInit();
+
+  //nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_UL, mu, Nid_cell, SSB_positions);
 
   frame_length_complex_samples = frame_parms->samples_per_subframe;
-  //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP;
+  frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP;
 
   //configure UE
   UE = malloc(sizeof(PHY_VARS_NR_UE));
@@ -389,7 +439,9 @@ int main(int argc, char **argv)
   }
 
   //nr_init_frame_parms_ue(&UE->frame_parms);
-  //init_nr_ue_transport(UE, 0);
+  init_nr_ue_transport(UE, 0);
+
+  /*
   for (sf = 0; sf < 2; sf++) {
     for (i = 0; i < 2; i++) {
 
@@ -399,9 +451,29 @@ int main(int argc, char **argv)
           printf("Can't get ue ulsch structures\n");
           exit(-1);
         }
-
     }
   }
+  */
+  
+  nr_l2_init_ue(NULL);
+  NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0);
+  
+  UE->if_inst = nr_ue_if_module_init(0);
+  UE->if_inst->scheduled_response = nr_ue_scheduled_response;
+  UE->if_inst->phy_config_request = nr_ue_phy_config_request;
+  UE->if_inst->dl_indication = nr_ue_dl_indication;
+  UE->if_inst->ul_indication = nr_ue_ul_indication;
+  
+  UE_mac->if_module = nr_ue_if_module_init(0);
+
+  //Configure UE
+  rrc.carrier.MIB = (uint8_t*) malloc(4);
+  rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0);
+
+  nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib,secondaryCellGroup->spCellConfig);
+
+  nr_ue_phy_config_request(&UE_mac->phy_config);
+
 
   unsigned char harq_pid = 0;
 
@@ -416,7 +488,6 @@ int main(int argc, char **argv)
   unsigned char *test_input_bit;
   uint32_t errors_decoding   = 0;
   uint32_t errors_scrambling = 0;
-  uint32_t is_frame_in_error = 0;
 
   test_input_bit       = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
   estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
@@ -428,7 +499,7 @@ int main(int argc, char **argv)
   uint16_t number_dmrs_symbols = 0;
   unsigned int available_bits;
   uint8_t nb_re_dmrs;
-  uint8_t length_dmrs = UE->dmrs_UplinkConfig.pusch_maxLength;
+  uint8_t length_dmrs = UE->pusch_config.dmrs_UplinkConfig.pusch_maxLength;
   unsigned char mod_order;
   uint16_t code_rate;
 
@@ -440,12 +511,11 @@ int main(int argc, char **argv)
                                             0,
                                             0,
                                             nb_symb_sch,
-                                            &UE->dmrs_UplinkConfig,
-                                            UE->pusch_config.pusch_TimeDomainResourceAllocation[0]->mappingType,
+                                            UE->pusch_config.dmrs_UplinkConfig.pusch_dmrs_type,
                                             frame_parms->ofdm_symbol_size);
 
   mod_order      = nr_get_Qm_ul(Imcs, 0);
-  nb_re_dmrs     = ((UE->dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1) ? 6 : 4) * number_dmrs_symbols;
+  nb_re_dmrs     = ((UE->pusch_config.dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1) ? 6 : 4) * number_dmrs_symbols;
   code_rate      = nr_get_code_rate_ul(Imcs, 0);
   available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, mod_order, 1);
   TBS            = nr_compute_tbs(mod_order, code_rate, nb_rb, nb_symb_sch, nb_re_dmrs*length_dmrs, 0, precod_nbr_layers);
@@ -454,13 +524,6 @@ int main(int argc, char **argv)
 
   for (SNR = snr0; SNR < snr1; SNR += snr_step) {
 
-    printf("-------------------\n");
-    printf("SNR %f\n", SNR);
-    printf("-------------------\n");
-
-    is_frame_in_error = 0;
-    for (int frame = 0; frame < number_of_frames; frame++) {
-
       UE_proc.nr_tti_tx = slot;
       UE_proc.frame_tx = frame;
 
@@ -481,8 +544,8 @@ int main(int argc, char **argv)
       ///////////////////////////////////////////////////
       */
 
-      UL_tti_req->sfn = frame;
-      UL_tti_req->slot = slot;
+      UL_tti_req->SFN = frame;
+      UL_tti_req->Slot = slot;
       UL_tti_req->n_pdus = 1;
       UL_tti_req->pdus_list[0].pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE;
       UL_tti_req->pdus_list[0].pdu_size = sizeof(nfapi_nr_pusch_pdu_t);
@@ -512,7 +575,7 @@ int main(int argc, char **argv)
       pusch_pdu->pusch_data.rv_index = 0;
       pusch_pdu->pusch_data.harq_process_id = 0;
       pusch_pdu->pusch_data.new_data_indicator = 0;
-      pusch_pdu->pusch_data.tb_size = TBS;
+      pusch_pdu->pusch_data.tb_size = TBS>>3;
       pusch_pdu->pusch_data.num_cb = 0;
 
 
@@ -526,7 +589,7 @@ int main(int argc, char **argv)
       scheduled_response.ul_config = &ul_config;
       scheduled_response.dl_config = NULL;
 
-      ul_config.sfn_slot = slot;
+      ul_config.slot = slot;
       ul_config.number_pdus = 1;
       ul_config.ul_config_list[0].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
       ul_config.ul_config_list[0].ulsch_config_pdu.rnti = n_rnti;
@@ -550,11 +613,12 @@ int main(int argc, char **argv)
 
       phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0);
 
-      //LOG_M("txsig0.m","txs0", UE->common_vars.txdata[0],frame_length_complex_samples,1,1);
+      if (n_trials==1)
+	LOG_M("txsig0.m","txs0", UE->common_vars.txdata[0],frame_length_complex_samples,1,1);
 
       ///////////
       ////////////////////////////////////////////////////
-      tx_offset = slot*frame_parms->samples_per_slot;
+      tx_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);
 
       txlev = signal_energy_amp_shift(&UE->common_vars.txdata[0][tx_offset + 5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0],
               frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples);
@@ -587,13 +651,21 @@ int main(int argc, char **argv)
         //----------------------------------------------------------
         //------------------- gNB phy procedures -------------------
         //----------------------------------------------------------
+        gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus = 0;
+        gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs = 0;
+
         phy_procedures_gNB_common_RX(gNB, frame, slot);
 
-	//LOG_M("rxsigF0.m","rxsF0",gNB->common_vars.rxdataF[0],frame_length_complex_samples_no_prefix,1,1);
+	if (n_trials==1)
+	  LOG_M("rxsigF0.m","rxsF0",gNB->common_vars.rxdataF[0],frame_length_complex_samples_no_prefix,1,1);
 
         phy_procedures_gNB_uespec_RX(gNB, frame, slot);
         ////////////////////////////////////////////////////////////
 
+	if (gNB->ulsch[0][0]->last_iteration_cnt >= 
+	    gNB->ulsch[0][0]->max_ldpc_iterations+1)
+	  n_errors++;
+
         //----------------------------------------------------------
         //----------------- count and print errors -----------------
         //----------------------------------------------------------
@@ -603,14 +675,15 @@ int main(int argc, char **argv)
           if(((ulsch_ue[0]->g[i] == 0) && (gNB->pusch_vars[UE_id]->llr[i] <= 0)) ||
              ((ulsch_ue[0]->g[i] == 1) && (gNB->pusch_vars[UE_id]->llr[i] >= 0)))
           {
-            if(errors_scrambling == 0)
-              printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i);
+            /*if(errors_scrambling == 0)
+              printf("\x1B[34m" "[frame %d][trial %d]\t1st bit in error in unscrambling = %d\n" "\x1B[0m", frame, trial, i);*/
             errors_scrambling++;
           }
         }
 
         if (errors_scrambling > 0) {
-          printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %d\n" "\x1B[0m", frame, trial, errors_scrambling);
+	  if (n_trials==1)
+	    printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in unscrambling = %d\n" "\x1B[0m", frame, trial, errors_scrambling);
         }
 
         for (i = 0; i < TBS; i++) {
@@ -619,38 +692,39 @@ int main(int argc, char **argv)
           test_input_bit[i]       = (ulsch_ue[0]->harq_processes[harq_pid]->b[i/8] & (1 << (i & 7))) >> (i & 7);
 
           if (estimated_output_bit[i] != test_input_bit[i]) {
-            if(errors_decoding == 0)
-              printf("\x1B[34m""[frame %d][trial %d]\t1st bit in error in decoding     = %d\n" "\x1B[0m", frame, trial, i);
+            /*if(errors_decoding == 0)
+              printf("\x1B[34m""[frame %d][trial %d]\t1st bit in error in decoding     = %d\n" "\x1B[0m", frame, trial, i);*/
             errors_decoding++;
           }
         }
 
         if (errors_decoding > 0) {
-          is_frame_in_error = 1;
           n_false_positive++;
-          printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding     = %d\n" "\x1B[0m", frame, trial, errors_decoding);
-        } else {
-          is_frame_in_error = 0;
-          break;
-        }
-        ////////////////////////////////////////////////////////////
-      } // trial loop
+	  if (n_trials==1)
+	    printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding     = %d\n" "\x1B[0m", frame, trial, errors_decoding);
+        } 
 
-      if (is_frame_in_error == 1)
-        break;
-    } // frame loop
+      } // trial loop
 
-    if(is_frame_in_error == 0)
-      break;
+      printf("*****************************************\n");
+      printf("SNR %f: n_errors (negative CRC) = %d/%d, false_positive %d/%d, errors_scrambling %d/%d\n", SNR, n_errors, n_trials, n_false_positive, n_trials, errors_scrambling, n_trials);
+      printf("\n");
+      printf("SNR %f: Channel BLER %e, Channel BER %e\n", SNR,(double)n_errors/n_trials,(double)errors_scrambling/available_bits/n_trials);
+      printf("*****************************************\n");
+      printf("\n");
+
+      if(n_trials==1)
+	break;
+
+      if ((float)n_errors/(float)n_trials <= target_error_rate) {
+	printf("*************\n");
+	printf("PUSCH test OK\n");
+	printf("*************\n");
+	break;
+      }
+      
   } // SNR loop
 
-  if(is_frame_in_error == 0) {
-    printf("\n");
-    printf("*************\n");
-    printf("PUSCH test OK\n");
-    printf("*************\n");
-  }
-
   printf("\n");
 
   free(test_input_bit);
diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.c
index 3d5d483be88..fa8b49842f5 100644
--- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.c
+++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/pss_util_test.c
@@ -237,7 +237,7 @@ int init_test(unsigned char N_tx, unsigned char N_rx, unsigned char transmission
   frame_parms->nb_antennas_tx       = N_tx;
   frame_parms->nb_antennas_rx       = N_rx;
   frame_parms->frame_type           = frame_type;
-  frame_parms->nb_antenna_ports_eNB = 1;
+  frame_parms->nb_antenna_ports_gNB = 1;
   frame_parms->threequarter_fs      = 0;
   frame_parms->numerology_index     = NUMEROLOGY_INDEX_MAX_NR;
   int mu = 1;
diff --git a/openair2/COMMON/platform_constants.h b/openair2/COMMON/platform_constants.h
index 581ff39527b..7a7e984aca0 100644
--- a/openair2/COMMON/platform_constants.h
+++ b/openair2/COMMON/platform_constants.h
@@ -62,6 +62,7 @@
 // overwrite the previous deinitions
 
 #    define MAX_MODULES                NB_MODULES_MAX
+#define MAX_NR_RRC_UE_CONTEXTS 64
 
 #ifndef UE_EXPANSION
   // TODO:L2 FAPI simulator.
@@ -83,7 +84,7 @@
     #else
       #define MAX_MOBILES_PER_ENB         4
       #define MAX_MOBILES_PER_ENB_NB_IoT  4
-      #define MAX_MOBILES_PER_GNB         4
+      #define MAX_MOBILES_PER_GNB         2//16
       #define MAX_eNB                      2
       #define MAX_gNB                      2
     #endif
@@ -96,8 +97,10 @@
   #define MAX_gNB                      2
 #endif
 
-#define NUMBER_OF_NR_DLSCH_MAX 4
-#define NUMBER_OF_NR_ULSCH_MAX 4
+#define NUMBER_OF_NR_DLSCH_MAX 2//16
+#define NUMBER_OF_NR_ULSCH_MAX 2//16
+#define NUMBER_OF_NR_SR_MAX 16
+
 
 #define MAX_MANAGED_ENB_PER_MOBILE  2
 #define MAX_MANAGED_GNB_PER_MOBILE  2
diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h
index 6c62d59d6d5..68e1753448b 100644
--- a/openair2/COMMON/rrc_messages_types.h
+++ b/openair2/COMMON/rrc_messages_types.h
@@ -41,7 +41,7 @@
 #include "LTE_SL-PeriodComm-r12.h"
 #include "LTE_SL-DiscResourcePool-r12.h"
 #include "NR_RACH-ConfigCommon.h"
-
+#include "NR_ServingCellConfigCommon.h"
 //-------------------------------------------------------------------------------------------//
 // Messages for RRC logging
 #if defined(DISABLE_ITTI_XER_PRINT)
@@ -400,194 +400,9 @@ typedef struct NRRrcConfigurationReq_s {
   uint16_t                mcc[PLMN_LIST_MAX_SIZE];
   uint16_t                mnc[PLMN_LIST_MAX_SIZE];
   uint8_t                 mnc_digit_length[PLMN_LIST_MAX_SIZE];
-  int16_t                 nb_cc;
-  lte_frame_type_t        frame_type[MAX_NUM_CCs];
-  uint8_t                 tdd_config[MAX_NUM_CCs];
-  uint8_t                 tdd_config_s[MAX_NUM_CCs];
-  lte_prefix_type_t       DL_prefix_type[MAX_NUM_CCs];
-  lte_prefix_type_t       UL_prefix_type[MAX_NUM_CCs];
-  int16_t                 nr_band[MAX_NUM_CCs];
-  uint64_t                downlink_frequency[MAX_NUM_CCs];
-  int32_t                 uplink_frequency_offset[MAX_NUM_CCs];
-  int16_t                 Nid_cell[MAX_NUM_CCs];// for testing, change later
-  int16_t                 N_RB_DL[MAX_NUM_CCs];// for testing, change later
-  int                     nb_antenna_ports[MAX_NUM_CCs];
-
-  ///NR
-  //MIB
-  long                    MIB_subCarrierSpacingCommon[MAX_NUM_CCs];
-  uint32_t                MIB_ssb_SubcarrierOffset[MAX_NUM_CCs];
-  long                    MIB_dmrs_TypeA_Position[MAX_NUM_CCs];
-  uint32_t                pdcch_ConfigSIB1[MAX_NUM_CCs];
-
-  //SIB1
-  long                    SIB1_frequencyOffsetSSB[MAX_NUM_CCs];
-  long                    SIB1_ssb_PeriodicityServingCell[MAX_NUM_CCs];
-  long                    SIB1_ss_PBCH_BlockPower[MAX_NUM_CCs];
-  //NR FrequencyInfoDL
-  long                    absoluteFrequencySSB[MAX_NUM_CCs];
-  long                    DL_FreqBandIndicatorNR[MAX_NUM_CCs];
-  long                    DL_absoluteFrequencyPointA[MAX_NUM_CCs];
-
-  //NR DL SCS-SpecificCarrier
-  long                    DL_offsetToCarrier[MAX_NUM_CCs];
-  long                    DL_SCS_SubcarrierSpacing[MAX_NUM_CCs];
-  long                    DL_carrierBandwidth[MAX_NUM_CCs];
-
-  //NR BWP-DownlinkCommon
-  uint32_t                DL_locationAndBandwidth[MAX_NUM_CCs];
-  long                    DL_BWP_SubcarrierSpacing[MAX_NUM_CCs];
-  lte_prefix_type_t       DL_BWP_prefix_type[MAX_NUM_CCs];
-
-  //NR FrequencyInfoUL
-  long                    UL_FreqBandIndicatorNR[MAX_NUM_CCs];
-  long                    UL_absoluteFrequencyPointA[MAX_NUM_CCs];
-  long                    UL_additionalSpectrumEmission[MAX_NUM_CCs];
-  long                    UL_p_Max[MAX_NUM_CCs];
-  long                    UL_frequencyShift7p5khz[MAX_NUM_CCs];
-
-  //NR UL SCS-SpecificCarrier
-  uint32_t                UL_offsetToCarrier[MAX_NUM_CCs];
-  long                    UL_SCS_SubcarrierSpacing[MAX_NUM_CCs];
-  uint32_t                UL_carrierBandwidth[MAX_NUM_CCs];
-
-  // NR BWP-UplinkCommon
-  uint32_t                UL_locationAndBandwidth[MAX_NUM_CCs];
-  long                    UL_BWP_SubcarrierSpacing[MAX_NUM_CCs];
-  lte_prefix_type_t       UL_BWP_prefix_type[MAX_NUM_CCs];
-  long                    UL_timeAlignmentTimerCommon[MAX_NUM_CCs];
-  long                    ServingCellConfigCommon_n_TimingAdvanceOffset[MAX_NUM_CCs];
-  uint64_t                ServingCellConfigCommon_ssb_PositionsInBurst_PR[MAX_NUM_CCs];
-  long                    ServingCellConfigCommon_ssb_periodicityServingCell[MAX_NUM_CCs]; //ServingCellConfigCommon
-  long                    ServingCellConfigCommon_dmrs_TypeA_Position[MAX_NUM_CCs];        //ServingCellConfigCommon
-  long                    NIA_SubcarrierSpacing[MAX_NUM_CCs];      //ServingCellConfigCommon Used only for non-initial access
-  long                    ServingCellConfigCommon_ss_PBCH_BlockPower[MAX_NUM_CCs];         //ServingCellConfigCommon
-
-
-  //NR TDD-UL-DL-ConfigCommon
-  long                    referenceSubcarrierSpacing[MAX_NUM_CCs];
-  long                    dl_UL_TransmissionPeriodicity[MAX_NUM_CCs];
-  long                    nrofDownlinkSlots[MAX_NUM_CCs];
-  long                    nrofDownlinkSymbols[MAX_NUM_CCs];
-  long                    nrofUplinkSlots[MAX_NUM_CCs];
-  long                    nrofUplinkSymbols[MAX_NUM_CCs];
-
-  //NR RACH-ConfigCommon
-  long                    rach_totalNumberOfRA_Preambles[MAX_NUM_CCs];
-  long                    rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[MAX_NUM_CCs];
-  long                    rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[MAX_NUM_CCs];
-  long                    rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[MAX_NUM_CCs];
-  long                    rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[MAX_NUM_CCs];
-  long                    rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[MAX_NUM_CCs];
-  long                    rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[MAX_NUM_CCs];
-  uint32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four[MAX_NUM_CCs];
-  uint32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight[MAX_NUM_CCs];
-  uint32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen[MAX_NUM_CCs];
-  BOOLEAN_t               rach_groupBconfigured[MAX_NUM_CCs];
-  long                    rach_ra_Msg3SizeGroupA[MAX_NUM_CCs];
-  e_NR_RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB                    rach_messagePowerOffsetGroupB[MAX_NUM_CCs];
-  long                    rach_numberOfRA_PreamblesGroupA[MAX_NUM_CCs];
-  long                    rach_ra_ContentionResolutionTimer[MAX_NUM_CCs];
-  long                    rsrp_ThresholdSSB[MAX_NUM_CCs];
-  long                    rsrp_ThresholdSSB_SUL[MAX_NUM_CCs];
-  long                    prach_RootSequenceIndex_choice[MAX_NUM_CCs];
-  uint32_t                prach_RootSequenceIndex_l839[MAX_NUM_CCs];
-  uint32_t                prach_RootSequenceIndex_l139[MAX_NUM_CCs];
-  long                    prach_msg1_SubcarrierSpacing[MAX_NUM_CCs];
-  long                    restrictedSetConfig[MAX_NUM_CCs];
-  long                    msg3_transformPrecoding[MAX_NUM_CCs];
-  //ssb-perRACH-OccasionAndCB-PreamblesPerSSB not sure
-
-  //NR RACH-ConfigGeneric
-  uint32_t                prach_ConfigurationIndex[MAX_NUM_CCs];
-  long                    prach_msg1_FDM[MAX_NUM_CCs];
-  long                    prach_msg1_FrequencyStart[MAX_NUM_CCs];
-  uint32_t                zeroCorrelationZoneConfig[MAX_NUM_CCs];
-  long                    preambleReceivedTargetPower[MAX_NUM_CCs];
-  long                    preambleTransMax[MAX_NUM_CCs];
-  long                    powerRampingStep[MAX_NUM_CCs];
-  long                    ra_ResponseWindow[MAX_NUM_CCs];
-
-  //NR PUSCH-ConfigCommon
-  BOOLEAN_t               groupHoppingEnabledTransformPrecoding[MAX_NUM_CCs];
-  long                    msg3_DeltaPreamble[MAX_NUM_CCs];
-  long                    p0_NominalWithGrant[MAX_NUM_CCs];
-
-  ///NR PUSCH-TimeDomainResourceAllocation
-  uint32_t                PUSCH_TimeDomainResourceAllocation_k2[MAX_NUM_CCs];
-  long                    PUSCH_TimeDomainResourceAllocation_mappingType[MAX_NUM_CCs];
-  uint32_t                PUSCH_TimeDomainResourceAllocation_startSymbolAndLength[MAX_NUM_CCs];
-
-  //NR PUCCH-ConfigCommon
-  uint32_t                pucch_ResourceCommon[MAX_NUM_CCs];
-  long                    pucch_GroupHopping[MAX_NUM_CCs];
-  uint32_t                hoppingId[MAX_NUM_CCs];
-  long                    p0_nominal[MAX_NUM_CCs];
-
-  //NR PDSCH-ConfigCOmmon
-  //NR PDSCH-TimeDomainResourceAllocation
-  uint32_t                PDSCH_TimeDomainResourceAllocation_k0[MAX_NUM_CCs];
-  long                    PDSCH_TimeDomainResourceAllocation_mappingType[MAX_NUM_CCs];
-  long                    PDSCH_TimeDomainResourceAllocation_startSymbolAndLength[MAX_NUM_CCs];
-
-  //NR RateMatchPattern  is used to configure one rate matching pattern for PDSCH
-  long                    rateMatchPatternId[MAX_NUM_CCs];
-  long                    RateMatchPattern_patternType[MAX_NUM_CCs];
-  long                    symbolsInResourceBlock[MAX_NUM_CCs];
-  long                    periodicityAndPattern[MAX_NUM_CCs];
-  long                    RateMatchPattern_controlResourceSet[MAX_NUM_CCs]; ///ControlResourceSetId
-  long                    RateMatchPattern_subcarrierSpacing[MAX_NUM_CCs];
-  long                    RateMatchPattern_mode[MAX_NUM_CCs];
-
-  //NR PDCCH-ConfigCommon
-  uint32_t                controlResourceSetZero[MAX_NUM_CCs];
-  uint32_t                searchSpaceZero[MAX_NUM_CCs];
-  long                    searchSpaceSIB1[MAX_NUM_CCs];
-  long                    searchSpaceOtherSystemInformation[MAX_NUM_CCs];
-  long                    pagingSearchSpace[MAX_NUM_CCs];
-  long                    ra_SearchSpace[MAX_NUM_CCs];
-  //NR PDCCH-ConfigCommon commonControlResourcesSets
-  long                    PDCCH_common_controlResourceSetId[MAX_NUM_CCs];
-  long                    PDCCH_common_ControlResourceSet_duration[MAX_NUM_CCs];
-  long                    PDCCH_cce_REG_MappingType[MAX_NUM_CCs];
-  long                    PDCCH_reg_BundleSize[MAX_NUM_CCs];
-  long                    PDCCH_interleaverSize[MAX_NUM_CCs];
-  long                    PDCCH_shiftIndex[MAX_NUM_CCs];
-  long                    PDCCH_precoderGranularity[MAX_NUM_CCs]; //Corresponds to L1 parameter 'CORESET-precoder-granuality'
-  long                    PDCCH_TCI_StateId[MAX_NUM_CCs];
-  BOOLEAN_t               tci_PresentInDCI[MAX_NUM_CCs];
-  uint32_t                PDCCH_DMRS_ScramblingID[MAX_NUM_CCs];
-
-  //NR PDCCH-ConfigCommon commonSearchSpaces
-  long                    SearchSpaceId[MAX_NUM_CCs];
-  long                    commonSearchSpaces_controlResourceSetId[MAX_NUM_CCs];
-  long                    SearchSpace_monitoringSlotPeriodicityAndOffset_choice[MAX_NUM_CCs];
-  uint32_t                SearchSpace_monitoringSlotPeriodicityAndOffset_value[MAX_NUM_CCs];
-  uint32_t                SearchSpace_duration[MAX_NUM_CCs];
-  long                    SearchSpace_nrofCandidates_aggregationLevel1[MAX_NUM_CCs];
-  long                    SearchSpace_nrofCandidates_aggregationLevel2[MAX_NUM_CCs];
-  long                    SearchSpace_nrofCandidates_aggregationLevel4[MAX_NUM_CCs];
-  long                    SearchSpace_nrofCandidates_aggregationLevel8[MAX_NUM_CCs];
-  long                    SearchSpace_nrofCandidates_aggregationLevel16[MAX_NUM_CCs];
-  long                    SearchSpace_searchSpaceType[MAX_NUM_CCs];
-  long                    Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1[MAX_NUM_CCs];
-  long                    Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2[MAX_NUM_CCs];
-  long                    Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4[MAX_NUM_CCs];
-  long                    Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8[MAX_NUM_CCs];
-  long                    Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16[MAX_NUM_CCs];
-  long                    Common_dci_Format2_3_monitoringPeriodicity[MAX_NUM_CCs];
-  long                    Common_dci_Format2_3_nrofPDCCH_Candidates[MAX_NUM_CCs];
-  long                    ue_Specific__dci_Formats[MAX_NUM_CCs];
-
-  //RateMatchPatternLTE-CRS
-  uint32_t                RateMatchPatternLTE_CRS_carrierFreqDL[MAX_NUM_CCs];
-  long                    RateMatchPatternLTE_CRS_carrierBandwidthDL[MAX_NUM_CCs];
-  long                    RateMatchPatternLTE_CRS_nrofCRS_Ports[MAX_NUM_CCs];
-  long                    RateMatchPatternLTE_CRS_v_Shift[MAX_NUM_CCs];
-  long                    RateMatchPatternLTE_CRS_radioframeAllocationPeriod[MAX_NUM_CCs];
-  uint32_t                RateMatchPatternLTE_CRS_radioframeAllocationOffset[MAX_NUM_CCs];
-  long                    RateMatchPatternLTE_CRS_subframeAllocation_choice[MAX_NUM_CCs];
-
+  NR_ServingCellConfigCommon_t *scc;
+  int                          ssb_SubcarrierOffset;
+  int                          pdsch_AntennaPorts;
 } gNB_RrcConfigurationReq;
 
 
diff --git a/openair2/COMMON/s1ap_messages_types.h b/openair2/COMMON/s1ap_messages_types.h
index 2615494d3b6..aa718dbcf88 100644
--- a/openair2/COMMON/s1ap_messages_types.h
+++ b/openair2/COMMON/s1ap_messages_types.h
@@ -81,7 +81,8 @@
 #ifndef OCP_FRAMEWORK
 typedef enum cell_type_e {
   CELL_MACRO_ENB,
-  CELL_HOME_ENB
+  CELL_HOME_ENB,
+  CELL_MACRO_GNB
 } cell_type_t;
 
 typedef enum paging_drx_e {
@@ -272,6 +273,22 @@ typedef struct e_rab_setup_s {
   uint32_t gtp_teid;
 } e_rab_setup_t;
 
+typedef struct e_rab_tobe_added_s {
+  /* Unique e_rab_id for the UE. */
+  uint8_t e_rab_id;
+
+  /* Unique drb_ID for the UE. */
+  uint8_t drb_ID;
+
+  /* The transport layer address for the IP packets */
+  transport_layer_addr_t eNB_addr;
+
+  /* S-GW Tunnel endpoint identifier */
+  uint32_t gtp_teid;
+} e_rab_tobe_added_t;
+
+
+
 typedef struct e_rab_tobeswitched_s {
   /* Unique e_rab_id for the UE. */
   uint8_t e_rab_id;
diff --git a/openair2/COMMON/x2ap_messages_def.h b/openair2/COMMON/x2ap_messages_def.h
index 6c2d56a9420..8438fd1037c 100644
--- a/openair2/COMMON/x2ap_messages_def.h
+++ b/openair2/COMMON/x2ap_messages_def.h
@@ -50,3 +50,8 @@ MESSAGE_DEF(X2AP_UE_CONTEXT_RELEASE             , MESSAGE_PRIORITY_MED, x2ap_ue_
 
 /*Senb bearer addition messages X2AP <-> RRC */
 MESSAGE_DEF(X2AP_SENB_ADDITION_REQ              , MESSAGE_PRIORITY_MED, x2ap_senb_addition_req_t         , x2ap_senb_addition_req)
+
+/*SGnb bearer addition messages X2AP <-> RRC */
+MESSAGE_DEF(X2AP_ENDC_SGNB_ADDITION_REQ              , MESSAGE_PRIORITY_MED, x2ap_ENDC_sgnb_addition_req_t         , x2ap_ENDC_sgnb_addition_req)
+MESSAGE_DEF(X2AP_ENDC_SGNB_ADDITION_REQ_ACK              , MESSAGE_PRIORITY_MED, x2ap_ENDC_sgnb_addition_req_ACK_t         , x2ap_ENDC_sgnb_addition_req_ACK)
+MESSAGE_DEF(X2AP_ENDC_SGNB_RECONF_COMPLETE              , MESSAGE_PRIORITY_MED, x2ap_ENDC_reconf_complete_t         , x2ap_ENDC_sgnb_reconf_complete)
diff --git a/openair2/COMMON/x2ap_messages_types.h b/openair2/COMMON/x2ap_messages_types.h
index e502191d2b9..ed3470a7d6b 100644
--- a/openair2/COMMON/x2ap_messages_types.h
+++ b/openair2/COMMON/x2ap_messages_types.h
@@ -28,16 +28,19 @@
 //-------------------------------------------------------------------------------------------//
 // Defines to access message fields.
 
-#define X2AP_REGISTER_ENB_REQ(mSGpTR)           	(mSGpTR)->ittiMsg.x2ap_register_enb_req
-#define X2AP_SETUP_REQ(mSGpTR)                  	(mSGpTR)->ittiMsg.x2ap_setup_req
-#define X2AP_SETUP_RESP(mSGpTR)                 	(mSGpTR)->ittiMsg.x2ap_setup_resp
-#define X2AP_HANDOVER_REQ(mSGpTR)               	(mSGpTR)->ittiMsg.x2ap_handover_req
-#define X2AP_HANDOVER_REQ_ACK(mSGpTR)           	(mSGpTR)->ittiMsg.x2ap_handover_req_ack
-#define X2AP_REGISTER_ENB_CNF(mSGpTR)           	(mSGpTR)->ittiMsg.x2ap_register_enb_cnf
-#define X2AP_DEREGISTERED_ENB_IND(mSGpTR)       	(mSGpTR)->ittiMsg.x2ap_deregistered_enb_ind
-#define X2AP_UE_CONTEXT_RELEASE(mSGpTR)         	(mSGpTR)->ittiMsg.x2ap_ue_context_release
-#define X2AP_HANDOVER_CANCEL(mSGpTR)            	(mSGpTR)->ittiMsg.x2ap_handover_cancel
-#define X2AP_SENB_ADDITION_REQ(mSGpTR)              (mSGpTR)->ittiMsg.x2ap_senb_addition_req
+#define X2AP_REGISTER_ENB_REQ(mSGpTR)           		(mSGpTR)->ittiMsg.x2ap_register_enb_req
+#define X2AP_SETUP_REQ(mSGpTR)                  		(mSGpTR)->ittiMsg.x2ap_setup_req
+#define X2AP_SETUP_RESP(mSGpTR)                 		(mSGpTR)->ittiMsg.x2ap_setup_resp
+#define X2AP_HANDOVER_REQ(mSGpTR)               		(mSGpTR)->ittiMsg.x2ap_handover_req
+#define X2AP_HANDOVER_REQ_ACK(mSGpTR)           		(mSGpTR)->ittiMsg.x2ap_handover_req_ack
+#define X2AP_REGISTER_ENB_CNF(mSGpTR)           		(mSGpTR)->ittiMsg.x2ap_register_enb_cnf
+#define X2AP_DEREGISTERED_ENB_IND(mSGpTR)       		(mSGpTR)->ittiMsg.x2ap_deregistered_enb_ind
+#define X2AP_UE_CONTEXT_RELEASE(mSGpTR)         		(mSGpTR)->ittiMsg.x2ap_ue_context_release
+#define X2AP_HANDOVER_CANCEL(mSGpTR)            		(mSGpTR)->ittiMsg.x2ap_handover_cancel
+#define X2AP_SENB_ADDITION_REQ(mSGpTR)              	(mSGpTR)->ittiMsg.x2ap_senb_addition_req
+#define X2AP_ENDC_SGNB_ADDITION_REQ(mSGpTR)         	(mSGpTR)->ittiMsg.x2ap_ENDC_sgnb_addition_req
+#define X2AP_ENDC_SGNB_ADDITION_REQ_ACK(mSGpTR)         (mSGpTR)->ittiMsg.x2ap_ENDC_sgnb_addition_req_ACK
+#define X2AP_ENDC_SGNB_RECONF_COMPLETE(mSGpTR)          (mSGpTR)->ittiMsg.x2ap_ENDC_sgnb_reconf_complete
 
 #define X2AP_MAX_NB_ENB_IP_ADDRESS 2
 
@@ -66,6 +69,13 @@ typedef enum {
   X2AP_TX2_RELOC_OVERALL_TIMEOUT
 } x2ap_handover_cancel_cause_t;
 
+typedef enum {
+	X2AP_RECONF_RESPONSE_SUCCESS,
+	X2AP_RECONF_RESPONSE_REJECT
+	/* Extensions may appear below */
+
+} x2ap_sgNB_reconf_response_information_t;
+
 typedef struct x2ap_handover_cancel_s {
   int rnti;
   x2ap_handover_cancel_cause_t cause;
@@ -286,7 +296,7 @@ typedef struct x2ap_senb_addition_req_ack_s {
 
   int MeNB_UE_X2_id;
 
-  int SeNB_UE_X2_id;
+  int SgNB_UE_X2_id;
 
   uint8_t nb_sCG_e_rabs_tobeadded;
 
@@ -303,4 +313,86 @@ typedef struct x2ap_senb_addition_req_ack_s {
 
 } x2ap_senb_addition_req_ack_t;
 
+typedef struct x2ap_ENDC_sgnb_addition_req_s {
+  int ue_x2_id;
+
+  /* used for RRC->X2AP in source eNB */
+  int rnti;
+
+  security_capabilities_t security_capabilities;
+
+  /* SgNB Security Key */
+  uint8_t      kgnb[32];
+
+  /*next_hop_chaining_coun */
+  long int     kgnb_ncc;
+
+  /* UE aggregate maximum bitrate */
+  ambr_t ue_ambr;
+
+  uint8_t nb_e_rabs_tobeadded;
+
+ /* list of e_rab to be added by RRC layers */
+  e_rab_tobe_added_t e_rabs_tobeadded[S1AP_MAX_E_RAB];
+
+  /* list of e_rab to be setup by RRC layers */
+  e_rab_t  e_rab_param[S1AP_MAX_E_RAB];
+
+  x2ap_lastvisitedcell_info_t lastvisitedcell_info;
+
+  uint8_t rrc_buffer[4096 /* arbitrary, big enough */];
+  int rrc_buffer_size;
+
+  int target_assoc_id;
+
+  	/*long int pDCPatSgNB = X2AP_EN_DC_ResourceConfiguration__pDCPatSgNB_present;
+  	long int mCGresources = X2AP_EN_DC_ResourceConfiguration__mCGresources_not_present;
+  	long int sCGresources = X2AP_EN_DC_ResourceConfiguration__sCGresources_not_present;*/
+
+
+} x2ap_ENDC_sgnb_addition_req_t;
+
+typedef struct x2ap_ENDC_sgnb_addition_req_ACK_s {
+  int MeNB_ue_x2_id;
+
+  int SgNB_ue_x2_id;
+
+  /* used for X2AP->RRC in source eNB */
+  int rnti;
+
+  uint8_t nb_e_rabs_admitted_tobeadded;
+
+ /* list of e_rab to be added by RRC layers */
+  e_rab_tobe_added_t e_rabs_admitted_tobeadded[S1AP_MAX_E_RAB];
+
+  /* list of e_rab to be setup by RRC layers */
+  e_rab_t  e_rab_param[S1AP_MAX_E_RAB];
+
+  x2ap_lastvisitedcell_info_t lastvisitedcell_info;
+
+  uint8_t rrc_buffer[4096 /* arbitrary, big enough */];
+  int rrc_buffer_size;
+
+  int target_assoc_id;
+
+  	/*long int pDCPatSgNB = X2AP_EN_DC_ResourceConfiguration__pDCPatSgNB_present;
+  	long int mCGresources = X2AP_EN_DC_ResourceConfiguration__mCGresources_not_present;
+  	long int sCGresources = X2AP_EN_DC_ResourceConfiguration__sCGresources_not_present;*/
+
+
+} x2ap_ENDC_sgnb_addition_req_ACK_t;
+
+typedef struct x2ap_ENDC_reconf_complete_s {
+  int MeNB_ue_x2_id;
+
+  int SgNB_ue_x2_id;
+
+  x2ap_sgNB_reconf_response_information_t reconf_response;
+
+  uint8_t rrc_buffer[4096 /* arbitrary, big enough */];
+  int rrc_buffer_size;
+
+} x2ap_ENDC_reconf_complete_t;
+
+
 #endif /* X2AP_MESSAGES_TYPES_H_ */
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index 02a3faf6694..6dcc5747468 100644
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -2389,6 +2389,11 @@ int RCconfig_S1(
               S1AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_ENB;
             } else  if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) {
               S1AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB;
+              // Temporary option to be able to parse an eNB configuration file which is treated as gNB from
+              // the X2AP layer and test the setup of an ENDC X2AP connection. To be removed when we are ready to
+              // parse an actual gNB configuration file wrt. the X2AP parameters instead.
+            } else  if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_GNB") == 0) {
+              S1AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_GNB;
             } else {
               AssertFatal(0,
                           "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
@@ -2618,7 +2623,7 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) {
               X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_ENB;
             } else  if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) {
               X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB;
-            } else {
+            }else {
               AssertFatal (0,
                            "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
                            RC.config_file_name, i, *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr));
diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h
index 373dbf9a4e5..f91c7056c59 100644
--- a/openair2/ENB_APP/enb_paramdef.h
+++ b/openair2/ENB_APP/enb_paramdef.h
@@ -94,6 +94,7 @@ typedef enum {
 #define CONFIG_STRING_RU_END_OF_BURST_DELAY       "end_of_burst_delay"
 #define CONFIG_STRING_RU_OTA_SYNC_ENABLE          "ota_sync_enabled"
 #define CONFIG_STRING_RU_BF_WEIGHTS_LIST          "bf_weights"
+#define CONFIG_STRING_RU_IF_FREQUENCY             "if_freq"
 
 #define RU_LOCAL_IF_NAME_IDX          0
 #define RU_LOCAL_ADDRESS_IDX          1
@@ -120,6 +121,7 @@ typedef enum {
 #define RU_END_OF_BURST_DELAY_IDX     22
 #define RU_OTA_SYNC_ENABLE_IDX        23
 #define RU_BF_WEIGHTS_LIST_IDX        24
+#define RU_IF_FREQUENCY               25
 
 /*-----------------------------------------------------------------------------------------------------------------------------------------*/
 /*                                            RU configuration parameters                                                                  */
@@ -151,6 +153,7 @@ typedef enum {
     {CONFIG_STRING_RU_END_OF_BURST_DELAY,          NULL,       0,       uptr:NULL,       defuintval:400,          TYPE_UINT,        0}, \
     {CONFIG_STRING_RU_OTA_SYNC_ENABLE,             NULL,       0,       strptr:NULL,     defstrval:"no",          TYPE_STRING,      0}, \
     {CONFIG_STRING_RU_BF_WEIGHTS_LIST,             NULL,       0,       iptr:NULL,       defintarrayval:DEFBFW,   TYPE_INTARRAY,    0}, \
+    {CONFIG_STRING_RU_IF_FREQUENCY,                NULL,       0,       u64ptr:NULL,     defuintval:0,            TYPE_UINT64,      0}, \
   }
 
 /*---------------------------------------------------------------------------------------------------------------------------------------*/
diff --git a/openair2/GNB_APP/RRC_nr_paramsvalues.h b/openair2/GNB_APP/RRC_nr_paramsvalues.h
index 687851116cf..82873f22b4b 100644
--- a/openair2/GNB_APP/RRC_nr_paramsvalues.h
+++ b/openair2/GNB_APP/RRC_nr_paramsvalues.h
@@ -32,63 +32,358 @@
 
 #ifndef __NR_RRC_PARAMSVALUES__H__
 #define __NR_RRC_PARAMSVALUES__H__
+
+#include "common/config/config_paramdesc.h"
+#include "NR_ServingCellConfigCommon.h"
+
 /*    cell configuration section name */
 #define GNB_CONFIG_STRING_GNB_LIST                              "gNBs"
-/* component carriers configuration section name */   
-#define GNB_CONFIG_STRING_COMPONENT_CARRIERS                    "component_carriers"     
+#define GNB_CONFIG_STRING_SSBSUBCARRIEROFFSET                   "ssb_SubcarrierOffset"
+#define GNB_CONFIG_STRING_PDSCHANTENNAPORTS                     "pdsch_AntennaPorts"
+#define GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON               "servingCellConfigCommon"
+#define GNB_CONFIG_STRING_PHYSCELLID                            "physCellId"
+#define GNB_CONFIG_STRING_NTIMINGADVANCEOFFSET                  "n_TimingAdvanceOffset"
+#define GNB_CONFIG_STRING_SUBCARRIERSPACING                     "subcarrierSpacing"
+#define GNB_CONFIG_STRING_ABSOLUTEFREQUENCYSSB                  "absoluteFrequencySSB"
+#define GNB_CONFIG_STRING_DLFREQUENCYBAND                       "dl_frequencyBand"
+#define GNB_CONFIG_STRING_DLABSOLUEFREQUENCYPOINTA              "dl_absoluteFrequencyPointA"
+#define GNB_CONFIG_STRING_DLOFFSETTOCARRIER                     "dl_offstToCarrier"
+#define GNB_CONFIG_STRING_DLSUBCARRIERSPACING                   "dl_subcarrierSpacing"
+#define GNB_CONFIG_STRING_DLCARRIERBANDWIDTH                    "dl_carrierBandwidth"
+
+#define GNB_CONFIG_STRING_INITIALDLBWPLOCATIONANDBANDWIDTH      "initialDLBWPlocationAndBandwidth"
+#define GNB_CONFIG_STRING_INITIALDLBWPSUBCARRIERSPACING         "initialDLBWPsubcarrierSpacing"
+#define GNB_CONFIG_STRING_INITIALDLBWPCYCLICPREFIX              "initialDLBWPcyclicPrefix"
+
+#define GNB_CONFIG_STRING_INITIALDLBWPCONTROLRESOURCESETZERO    "initialDLBWPcontrolResourceSetZero"
+#define GNB_CONFIG_STRING_INITIALDLBWPSEARCHSPACEZERO           "initialDLBWPsearchSpaceZero"
+
+
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_0                      "initialDLBWPk0_0"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_0             "initialDLBWPmappingType_0"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_0    "initialDLBWPstartSymbolAndLength_0"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_1                      "initialDLBWPk0_1"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_1             "initialDLBWPmappingType_1"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_1    "initialDLBWPstartSymbolAndLength_1"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_2                      "initialDLBWPk0_2"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_2             "initialDLBWPmappingType_2"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_2    "initialDLBWPstartSymbolAndLength_2"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_3                      "initialDLBWPk0_3"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_3             "initialDLBWPmappingType_3"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_3    "initialDLBWPstartSymbolAndLength_3"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_4                      "initialDLBWPk0_4"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_4             "initialDLBWPmappingType_4"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_4    "initialDLBWPstartSymbolAndLength_4"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_5                      "initialDLBWPk0_5"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_5             "initialDLBWPmappingType_5"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_5    "initialDLBWPstartSymbolAndLength_5"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_6                      "initialDLBWPk0_6"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_6             "initialDLBWPmappingType_6"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_6    "initialDLBWPstartSymbolAndLength_6"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_7                      "initialDLBWPk0_7"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_7             "initialDLBWPmappingType_7"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_7    "initialDLBWPstartSymbolAndLength_7"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_8                      "initialDLBWPk0_8"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_8             "initialDLBWPmappingType_8"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_8    "initialDLBWPstartSymbolAndLength_8"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_9                      "initialDLBWPk0_9"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_9             "initialDLBWPmappingType_9"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_9    "initialDLBWPstartSymbolAndLength_9"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_10                     "initialDLBWPk0_10"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_10            "initialDLBWPmappingType_10"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_10   "initialDLBWPstartSymbolAndLength_10"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_11                     "initialDLBWPk0_11"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_11            "initialDLBWPmappingType_11"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_11   "initialDLBWPstartSymbolAndLength_11"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_12                     "initialDLBWPk0_12"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_12            "initialDLBWPmappingType_12"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_12   "initialDLBWPstartSymbolAndLength_12"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_13                     "initialDLBWPk0_13"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_13            "initialDLBWPmappingType_13"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_13   "initialDLBWPstartSymbolAndLength_13"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_14                     "initialDLBWPk0_14"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_14            "initialDLBWPmappingType_14"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_14   "initialDLBWPstartSymbolAndLength_14"
+#define GNB_CONFIG_STRING_INITIALDLBWPK0_15                     "initialDLBWPk0_15"
+#define GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_15            "initialDLBWPmappingType_15"
+#define GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_15   "initialDLBWPstartSymbolAndLength_15"
+
+#define GNB_CONFIG_STRING_ULFREQUENCYBAND                       "ul_frequencyBand"
+#define GNB_CONFIG_STRING_ULABSOLUEFREQUENCYPOINTA              "ul_absoluteFrequencyPointA"
+#define GNB_CONFIG_STRING_ULOFFSETTOCARRIER                     "ul_offstToCarrier"
+#define GNB_CONFIG_STRING_ULSUBCARRIERSPACING                   "ul_subcarrierSpacing"
+#define GNB_CONFIG_STRING_ULCARRIERBANDWIDTH                    "ul_carrierBandwidth"
+
+#define GNB_CONFIG_STRING_INITIALULBWPLOCATIONANDBANDWIDTH      "initialULBWPlocationAndBandwidth"
+#define GNB_CONFIG_STRING_INITIALULBWPSUBCARRIERSPACING         "initialULBWPsubcarrierSpacing"
+
+#define GNB_CONFIG_STRING_PMAX                                  "pMax"
+#define GNB_CONFIG_STRING_PRACHCONFIGURATIONINDEX               "prach_ConfigurationIndex"
+#define GNB_CONFIG_STRING_PRACHMSG1FDM                          "prach_msg1_FDM"
+#define GNB_CONFIG_STRING_PRACHMSG1FREQUENCYSTART               "prach_msg1_FrequencyStart"
+#define GNB_CONFIG_STRING_ZEROCORRELATIONZONECONFIG             "zeroCorrelationZoneConfig"
+#define GNB_CONFIG_STRING_PREAMBLERECEIVEDTARGETPOWER           "preambleReceivedTargetPower"
+#define GNB_CONFIG_STRING_PREAMBLETRANSMAX                      "preambleTransMax"
+#define GNB_CONFIG_STRING_POWERRAMPINGSTEP                      "powerRampingStep"
+#define GNB_CONFIG_STRING_RARESPONSEWINDOW                      "ra_ResponseWindow"
+#define GNB_CONFIG_STRING_SSBPERRACHOCCASIONANDCBPREAMBLESPERSSBPR   "ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR"
+#define GNB_CONFIG_STRING_SSBPERRACHOCCASIONANDCBPREAMBLESPERSSB     "ssb_perRACH_OccasionAndCB_PreamblesPerSSB"
+#define GNB_CONFIG_STRING_RACONTENTIONRESOLUTIONTIMER                    "ra_ContentionResolutionTimer"                     
+#define GNB_CONFIG_STRING_RSRPTHRESHOLDSSB                               "rsrp_ThresholdSSB"                                
+#define GNB_CONFIG_STRING_PRACHROOTSEQUENCEINDEXPR                     "prach_RootSequenceIndex_PR"                     
+#define GNB_CONFIG_STRING_PRACHROOTSEQUENCEINDEX                     "prach_RootSequenceIndex"                     
+#define GNB_CONFIG_STRING_MSG1SUBCARRIERSPACING                          "msg1_SubcarrierSpacing"                           
+#define GNB_CONFIG_STRING_RESTRICTEDSETCONFIG                            "restrictedSetConfig"                              
+#define GNB_CONFIG_STRING_PUSCHTIMEDOMAINALLOCATIONLIST                  "puschTimeDomainAllocationList"
+#define GNB_CONFIG_STRING_MSG3DELTAPREABMLE                              "msg3_DeltaPreamble"
+#define GNB_CONFIG_STRING_P0NOMINALWITHGRANT                             "p0_NominalWithGrant"
+#define GNB_CONFIG_STRING_PUCCHGROUPHOPPING                              "pucchGroupHopping"
+#define GNB_CONFIG_STRING_HOPPINGID                                      "hoppingId"
+#define GNB_CONFIG_STRING_P0NOMINAL                                      "p0_nominal"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_0                      "initialULBWPk2_0"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_0             "initialULBWPmappingType_0"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_0    "initialULBWPstartSymbolAndLength_0"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_1                      "initialULBWPk2_1"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_1             "initialULBWPmappingType_1"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_1    "initialULBWPstartSymbolAndLength_1"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_2                      "initialULBWPk2_2"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_2             "initialULBWPmappingType_2"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_2    "initialULBWPstartSymbolAndLength_2"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_3                      "initialULBWPk2_3"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_3             "initialULBWPmappingType_3"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_3    "initialULBWPstartSymbolAndLength_3"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_4                      "initialULBWPk2_4"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_4             "initialULBWPmappingType_4"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_4    "initialULBWPstartSymbolAndLength_4"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_5                      "initialULBWPk2_5"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_5             "initialULBWPmappingType_5"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_5    "initialULBWPstartSymbolAndLength_5"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_6                      "initialULBWPk2_6"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_6             "initialULBWPmappingType_6"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_6    "initialULBWPstartSymbolAndLength_6"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_7                      "initialULBWPk2_7"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_7             "initialULBWPmappingType_7"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_7    "initialULBWPstartSymbolAndLength_7"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_8                      "initialULBWPk2_8"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_8             "initialULBWPmappingType_8"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_8    "initialULBWPstartSymbolAndLength_8"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_9                      "initialULBWPk2_9"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_9             "initialULBWPmappingType_9"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_9    "initialULBWPstartSymbolAndLength_9"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_10                     "initialULBWPk2_10"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_10            "initialULBWPmappingType_10"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_10   "initialULBWPstartSymbolAndLength_10"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_11                     "initialULBWPk2_11"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_11            "initialULBWPmappingType_11"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_11   "initialULBWPstartSymbolAndLength_11"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_12                     "initialULBWPk2_12"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_12            "initialULBWPmappingType_12"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_12   "initialULBWPstartSymbolAndLength_12"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_13                     "initialULBWPk2_13"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_13            "initialULBWPmappingType_13"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_13   "initialULBWPstartSymbolAndLength_13"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_14                     "initialULBWPk2_14"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_14            "initialULBWPmappingType_14"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_14   "initialULBWPstartSymbolAndLength_14"
+#define GNB_CONFIG_STRING_INITIALULBWPK2_15                     "initialULBWPk2_15"
+#define GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_15            "initialULBWPmappingType_15"
+#define GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_15   "initialULBWPstartSymbolAndLength_15"
 
-#define GNB_CONFIG_STRING_FRAME_TYPE                            "frame_type"
-#define GNB_CONFIG_STRING_DL_PREFIX_TYPE                        "DL_prefix_type"
-#define GNB_CONFIG_STRING_UL_PREFIX_TYPE                        "UL_prefix_type"
-#define GNB_CONFIG_STRING_NR_BAND                               "nr_band"
-#define GNB_CONFIG_STRING_DOWNLINK_FREQUENCY                    "downlink_frequency"
-#define GNB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET               "uplink_frequency_offset"
-#define GNB_CONFIG_STRING_NID_CELL                              "Nid_cell"
-#define GNB_CONFIG_STRING_N_RB_DL                               "N_RB_DL"
 
-#define FRAMETYPE_OKVALUES                                      {"FDD","TDD"}
-#define FRAMETYPE_MODVALUES                                     { FDD, TDD} 
+#define GNB_CONFIG_STRING_SSBPOSITIONSINBURSTPR                          "ssb_PositionsInBurst_PR"
+#define GNB_CONFIG_STRING_SSBPOSITIONSINBURST                            "ssb_PositionsInBurst_Bitmap"
+#define GNB_CONFIG_STRING_SSBPERIODICITYSERVINGCELL                      "ssb_periodicityServingCell"
+#define GNB_CONFIG_STRING_DMRSTYPEAPOSITION                              "dmrs_TypeA_Position"
+#define GNB_CONFIG_STRING_REFERENCESUBCARRIERSPACING                     "referenceSubcarrierSpacing"
+#define GNB_CONFIG_STRING_DLULTRANSMISSIONPERIODICITY                    "dl_UL_TransmissionPeriodicity"
+#define GNB_CONFIG_STRING_NROFDOWNLINKSLOTS                              "nrofDownlinkSlots"
+#define GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS                            "nrofDownlinkSymbols"
+#define GNB_CONFIG_STRING_NROFUPLINKSLOTS                                "nrofUplinkSlots"
+#define GNB_CONFIG_STRING_NROFUPLINKSYMBOLS                              "nrofUplinkSymbols"
+#define GNB_CONFIG_STRING_DLULTRANSMISSIONPERIODICITY2                   "dl_UL_TransmissionPeriodicity2"
+#define GNB_CONFIG_STRING_NROFDOWNLINKSLOTS2                             "nrofDownlinkSlots2"
+#define GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS2                           "nrofDownlinkSymbols2"
+#define GNB_CONFIG_STRING_NROFUPLINKSLOTS2                               "nrofUplinkSlots2"
+#define GNB_CONFIG_STRING_NROFUPLINKSYMBOLS2                             "nrofUplinkSymbols2"
+#define GNB_CONFIG_STRING_SSPBCHBLOCKPOWER                               "ssPBCH_BlockPower"
 
-#define TDDCFG(A)                                               TDD_Config__subframeAssignment_ ## A
-#define TDDCONFIG_OKRANGE                                       { TDDCFG(sa0), TDDCFG(sa6)}   
 
-#define TDDCFGS(A)                                              TDD_Config__specialSubframePatterns_ ## A
-#define TDDCONFIGS_OKRANGE                                      { TDDCFGS(ssp0), TDDCFGS(ssp8)}   
+#define CARRIERBANDWIDTH_OKVALUES {11,18,24,25,31,32,38,51,52,65,66,78,79,93,106,107,121,132,133,135,160,162,189,216,217,245,264,270,273}
 
-#define PREFIX_OKVALUES                                         {"NORMAL","EXTENDED"}
-#define PREFIX_MODVALUES                                        { NORMAL, EXTENDED} 
+/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                     Serving Cell Config Common configuration parameters                                                                                                     */
+/*   optname                                                   helpstr   paramflags    XXXptr                                        defXXXval                    type         numelt  */
+/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
 
-#define PREFIXUL_OKVALUES                                       {"NORMAL","EXTENDED"}
-#define PREFIXUL_MODVALUES                                      { NORMAL, EXTENDED} 
+#define GNB_CONFIG_PHYSCELLID_IDX 0
+#define GNB_CONFIG_ABSOLUTEFREQUENCYSSB_IDX 5
+#define GNB_CONFIG_DLFREQUENCYBAND_IDX 6
+#define GNB_CONFIG_ABSOLUTEFREQUENCYPOINTA_IDX 7
+#define GNB_CONFIG_DLCARRIERBANDWIDTH_IDX 10
 
-#define NRBDL_OKVALUES                                          {6,15,25,50,75,100}
 
-#define NRUETIMER_T300_OKVALUES                                 {100,200,300,400,600,1000,1500,2000}
-#define NRUETT300(A)                                            NR_UE_TimersAndConstants__t300_ ## A
-#define NRUETIMER_T300_MODVALUES                                { NRUETT300(ms100), NRUETT300(ms200), NRUETT300(ms300), NRUETT300(ms400), NRUETT300(ms600), NRUETT300(ms1000), NRUETT300(ms1500), NRUETT300(ms2000)}
+#define SSBPARAMS_DESC {{GNB_CONFIG_STRING_SSBSUBCARRIEROFFSET,NULL,0,iptr:&ssb_SubcarrierOffset,defintval:0,TYPE_INT,0}}
+#define PDSCHANTENNAPARAMS_DESC {{GNB_CONFIG_STRING_PDSCHANTENNAPORTS,NULL,0,iptr:&pdsch_AntennaPorts,defintval:1,TYPE_INT,0}}
 
-#define NRUETIMER_T301_OKVALUES                                 {100,200,300,400,600,1000,1500,2000}
-#define NRUETT301(A)                                            NR_UE_TimersAndConstants__t301_ ## A
-#define NRUETIMER_T301_MODVALUES                                { NRUETT301(ms100), NRUETT301(ms200), NRUETT301(ms300), NRUETT301(ms400), NRUETT301(ms600), NRUETT301(ms1000), NRUETT301(ms1500), NRUETT301(ms2000)}
+#define SCCPARAMS_DESC(scc) { \
+{GNB_CONFIG_STRING_PHYSCELLID,NULL,0,i64ptr:scc->physCellId,defint64val:0,TYPE_INT64,0/*0*/}, \
+{GNB_CONFIG_STRING_NTIMINGADVANCEOFFSET,NULL,0,i64ptr:scc->n_TimingAdvanceOffset,defint64val:NR_ServingCellConfigCommon__n_TimingAdvanceOffset_n0,TYPE_INT64,0/*1*/},\
+{GNB_CONFIG_STRING_SSBPERIODICITYSERVINGCELL,NULL,0,i64ptr:scc->ssb_periodicityServingCell,defint64val:NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms20,TYPE_INT64,0/*2*/},\
+{GNB_CONFIG_STRING_DMRSTYPEAPOSITION,NULL,0,i64ptr:&scc->dmrs_TypeA_Position,defint64val:NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2,TYPE_INT64,0/*3*/},\
+{GNB_CONFIG_STRING_SUBCARRIERSPACING,NULL,0,i64ptr:scc->ssbSubcarrierSpacing,defint64val:NR_SubcarrierSpacing_kHz30,TYPE_INT64,0/*4*/},\
+{GNB_CONFIG_STRING_ABSOLUTEFREQUENCYSSB,NULL,0,i64ptr:scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB,defint64val:660960,TYPE_INT64,0/*5*/},\
+{GNB_CONFIG_STRING_DLFREQUENCYBAND,NULL,0,i64ptr:scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0],defint64val:78,TYPE_INT64,0/*6*/},\
+{GNB_CONFIG_STRING_DLABSOLUEFREQUENCYPOINTA,NULL,0,i64ptr:&scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA,defint64val:660000,TYPE_INT64,0/*7*/},\
+{GNB_CONFIG_STRING_DLOFFSETTOCARRIER,NULL,0,i64ptr:&scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier,defint64val:0,TYPE_INT64,0/*8*/},\
+{GNB_CONFIG_STRING_DLSUBCARRIERSPACING,NULL,0,i64ptr:&scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing,defint64val:NR_SubcarrierSpacing_kHz30,TYPE_INT64,0/*9*/},\
+{GNB_CONFIG_STRING_DLCARRIERBANDWIDTH,NULL,0,i64ptr:&scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,defint64val:217,TYPE_INT64,0 /*10*/}, \
+{GNB_CONFIG_STRING_INITIALDLBWPLOCATIONANDBANDWIDTH,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,defint64val:13036,TYPE_INT64,0/*11*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSUBCARRIERSPACING,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing,defint64val:NR_SubcarrierSpacing_kHz30,TYPE_INT64,0/*12*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPCONTROLRESOURCESETZERO,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero,defint64val:12,TYPE_INT64,0/*13*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSEARCHSPACEZERO,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero,defint64val:0,TYPE_INT64,0/*14*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_0,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[0]->k0,defint64val:-1,TYPE_INT64,0/*15*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_0,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[0]->mappingType,defint64val:-1,TYPE_INT64,0/*16*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_0,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[0]->startSymbolAndLength,defint64val:-1,TYPE_INT64,0/*17*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_1,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[1]->k0,defint64val:-1,TYPE_INT64,0/*18*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_1,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[1]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*19*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_0,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[1]->startSymbolAndLength,defint64val:53,TYPE_INT64,0/*20*/}, \
+{GNB_CONFIG_STRING_INITIALDLBWPK0_2,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[2]->k0,defint64val:-1,TYPE_INT64,0/*21*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_2,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[2]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*22*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_2,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[2]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*23*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_3,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[3]->k0,defint64val:-1,TYPE_INT64,0/*24*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_3,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[3]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*25*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_3,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[3]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*26*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_4,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[4]->k0,defint64val:-1,TYPE_INT64,0/*27*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_4,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[4]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*28*/}, \
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_4,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[4]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*29*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_5,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[5]->k0,defint64val:-1,TYPE_INT64,0/*30*/},	\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_5,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[5]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*31*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_5,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[5]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*32*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_6,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[6]->k0,defint64val:-1,TYPE_INT64,0/*33*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_6,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[6]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*34*/}, \
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_6,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[6]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*35*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_7,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[7]->k0,defint64val:-1,TYPE_INT64,0/*36*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_7,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[7]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*37*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_7,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[7]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*38*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_8,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[8]->k0,defint64val:-1,TYPE_INT64,0/*39*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_8,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[8]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*40*/}, \
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_8,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[8]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*41*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_9,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[9]->k0,defint64val:-1,TYPE_INT64,0/*42*/}, \
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_9,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[9]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*43*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_9,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[9]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*44*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_10,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[10]->k0,defint64val:-1,TYPE_INT64,0/*45*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_10,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[10]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*46*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_10,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[10]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*47*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_11,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[11]->k0,defint64val:-1,TYPE_INT64,0/*48*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_11,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[11]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*49*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_11,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[11]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*50*/},	\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_12,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[12]->k0,defint64val:-1,TYPE_INT64,0/*51*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_12,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[12]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*52*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_12,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[12]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*53*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_13,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[13]->k0,defint64val:-1,TYPE_INT64,0/*54*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_13,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[13]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*55*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_13,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[13]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*56*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_14,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[14]->k0,defint64val:-1,TYPE_INT64,0/*57*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_14,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[14]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*58*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_14,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[14]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*59*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPK0_15,NULL,0,i64ptr:scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[15]->k0,defint64val:-1,TYPE_INT64,0/*60*/}, \
+{GNB_CONFIG_STRING_INITIALDLBWPMAPPINGTYPE_15,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[15]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA,TYPE_INT64,0/*61*/},\
+{GNB_CONFIG_STRING_INITIALDLBWPSTARTSYMBOLANDLENGTH_15,NULL,0,i64ptr:&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[15]->startSymbolAndLength,defint64val:54,TYPE_INT64,0/*62*/},\
+{GNB_CONFIG_STRING_ULFREQUENCYBAND,NULL,0,i64ptr:scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0],defint64val:-1,TYPE_INT64,0/*63*/},\
+{GNB_CONFIG_STRING_ULABSOLUEFREQUENCYPOINTA,NULL,0,i64ptr:scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA,defint64val:-1,TYPE_INT64,0/*64*/},\
+{GNB_CONFIG_STRING_ULOFFSETTOCARRIER,NULL,0,i64ptr:&scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier,defint64val:0,TYPE_INT64,0/*65*/},\
+{GNB_CONFIG_STRING_ULSUBCARRIERSPACING,NULL,0,i64ptr:&scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing,defint64val:NR_SubcarrierSpacing_kHz30,TYPE_INT64,0/*66*/},\
+{GNB_CONFIG_STRING_ULCARRIERBANDWIDTH,NULL,0,i64ptr:&scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,defint64val:217,TYPE_INT64,0/*67*/},\
+{GNB_CONFIG_STRING_PMAX,NULL,0,i64ptr:scc->uplinkConfigCommon->frequencyInfoUL->p_Max,defint64val:20,TYPE_INT64,0/*68*/},\
+{GNB_CONFIG_STRING_INITIALULBWPLOCATIONANDBANDWIDTH,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth,defint64val:13036,TYPE_INT64,0/*69*/},\
+{GNB_CONFIG_STRING_INITIALULBWPSUBCARRIERSPACING,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing,defint64val:NR_SubcarrierSpacing_kHz30,TYPE_INT64,0 /*70*/}, \
+{GNB_CONFIG_STRING_PRACHCONFIGURATIONINDEX,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.prach_ConfigurationIndex,defint64val:98,TYPE_INT64,0/*71*/},\
+{GNB_CONFIG_STRING_PRACHMSG1FDM,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FDM,defint64val:NR_RACH_ConfigGeneric__msg1_FDM_one,TYPE_INT64,0/*72*/},\
+{GNB_CONFIG_STRING_PRACHMSG1FREQUENCYSTART,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FrequencyStart,defint64val:0,TYPE_INT64,0/*73*/},\
+{GNB_CONFIG_STRING_ZEROCORRELATIONZONECONFIG,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.zeroCorrelationZoneConfig,defint64val:13,TYPE_INT64,0/*74*/},\
+{GNB_CONFIG_STRING_PREAMBLERECEIVEDTARGETPOWER,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleReceivedTargetPower,defintval:-118,TYPE_INT64,0/*75*/},\
+{GNB_CONFIG_STRING_PREAMBLETRANSMAX,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleTransMax,defint64val:NR_RACH_ConfigGeneric__preambleTransMax_n10,TYPE_INT64,0/*76*/},\
+{GNB_CONFIG_STRING_POWERRAMPINGSTEP,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.powerRampingStep,defint64val:NR_RACH_ConfigGeneric__powerRampingStep_dB2,TYPE_INT64,0/*77*/},\
+{GNB_CONFIG_STRING_RARESPONSEWINDOW,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.ra_ResponseWindow,defint64val:NR_RACH_ConfigGeneric__ra_ResponseWindow_sl20,TYPE_INT64,0/*78*/},\
+{GNB_CONFIG_STRING_SSBPERRACHOCCASIONANDCBPREAMBLESPERSSBPR,NULL,0,uptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present,defuintval:NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one,TYPE_UINT,0/*79*/},\
+{GNB_CONFIG_STRING_SSBPERRACHOCCASIONANDCBPREAMBLESPERSSB,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one,defint64val:NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n64,TYPE_INT64,0 /*80*/}, \
+{GNB_CONFIG_STRING_RACONTENTIONRESOLUTIONTIMER,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ra_ContentionResolutionTimer,defint64val:NR_RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64,TYPE_INT64,0/*81*/},\
+{GNB_CONFIG_STRING_RSRPTHRESHOLDSSB,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rsrp_ThresholdSSB,defint64val:19,TYPE_INT64,0/*82*/},\
+{GNB_CONFIG_STRING_PRACHROOTSEQUENCEINDEXPR,NULL,0,uptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present,defuintval:NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139,TYPE_UINT,0/*83*/},\
+{GNB_CONFIG_STRING_PRACHROOTSEQUENCEINDEX,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l139,defint64val:0,TYPE_INT64,0/*84*/},\
+{GNB_CONFIG_STRING_MSG1SUBCARRIERSPACING,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->restrictedSetConfig,defintval:NR_RACH_ConfigCommon__restrictedSetConfig_unrestrictedSet,TYPE_INT64,0/*85*/}, \
+{GNB_CONFIG_STRING_INITIALULBWPK2_0,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->k2,defint64val:-1,TYPE_INT64,0/*86*/},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_0,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,/*87*/},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_0,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->startSymbolAndLength,defint64val:55,TYPE_INT64,0/*88*/},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_1,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[1]->k2,defint64val:-1,TYPE_INT64,0/*89*/}, \
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_1,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[1]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_1,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[1]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_2,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[2]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_2,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[2]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_2,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[2]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_3,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[3]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_3,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[3]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_3,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[3]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_4,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[4]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_4,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[4]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0 /*99*/}, \
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_4,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[4]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_5,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[5]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_5,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[5]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_5,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[5]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_6,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[6]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_6,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[6]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_6,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[6]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_7,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[7]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_7,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[7]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_7,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[7]->startSymbolAndLength,defint64val:53,TYPE_INT64,0/*109*/}, \
+{GNB_CONFIG_STRING_INITIALULBWPK2_8,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[8]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_8,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[8]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_8,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[8]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_9,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[9]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_9,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[9]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_9,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[9]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_10,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[10]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_10,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[10]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_10,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[10]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_11,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[11]->k2,defint64val:-1,TYPE_INT64,0/*119*/},	\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_11,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[11]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_11,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[11]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_12,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[12]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_12,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[12]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_12,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[12]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_13,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[13]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_13,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[13]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_13,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[13]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_14,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[14]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_14,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[14]->mappingType,defint64val:NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0 /*129*/}, \
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_14,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[14]->startSymbolAndLength,defint64val:55,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPK2_15,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[15]->k2,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPMAPPINGTYPE_15,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[15]->mappingType,defint64val:NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_INITIALULBWPSTARTSYMBOLANDLENGTH_15,NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[15]->startSymbolAndLength,defint64val:53,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_MSG3DELTAPREABMLE, NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble,defint64val:1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_P0NOMINALWITHGRANT, NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->p0_NominalWithGrant,defint64val:1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_PUCCHGROUPHOPPING, NULL,0,i64ptr:&scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_GroupHopping,defint64val:NR_PUCCH_ConfigCommon__pucch_GroupHopping_neither,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_HOPPINGID, NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->hoppingId,defint64val:40,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_P0NOMINAL, NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->p0_nominal,defint64val:1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_SSBPOSITIONSINBURSTPR,NULL,0,uptr:&scc->ssb_PositionsInBurst->present,defuintval:NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap,TYPE_UINT,0/*139*/}, \
+{GNB_CONFIG_STRING_SSBPOSITIONSINBURST,NULL,0,u64ptr:&ssb_bitmap,defintval:0xff,TYPE_UINT64,0}, \
+{GNB_CONFIG_STRING_REFERENCESUBCARRIERSPACING,NULL,0,i64ptr:&scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing,defint64val:NR_SubcarrierSpacing_kHz30,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_DLULTRANSMISSIONPERIODICITY,NULL,0,i64ptr:&scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity,defint64val:NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms0p5,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_NROFDOWNLINKSLOTS,NULL,0,i64ptr:&scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots,defint64val:7,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS,NULL,0,i64ptr:&scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols,defint64val:6,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_NROFUPLINKSLOTS,NULL,0,i64ptr:&scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots,defint64val:2,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_NROFUPLINKSYMBOLS,NULL,0,i64ptr:&scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols,defint64val:4,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_DLULTRANSMISSIONPERIODICITY2,NULL,0,i64ptr:&scc->tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity,defintval:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_NROFDOWNLINKSLOTS2,NULL,0,i64ptr:&scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS2,NULL,0,i64ptr:&scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSymbols,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_NROFUPLINKSLOTS2,NULL,0,i64ptr:&scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofUplinkSlots,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_NROFUPLINKSYMBOLS2,NULL,0,i64ptr:&scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofUplinkSymbols,defint64val:-1,TYPE_INT64,0},\
+{GNB_CONFIG_STRING_SSPBCHBLOCKPOWER,NULL,0,i64ptr:&scc->ss_PBCH_BlockPower,defint64val:20,TYPE_INT64,0}, \
+{GNB_CONFIG_STRING_MSG1SUBCARRIERSPACING,NULL,0,i64ptr:scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing,defintval:-1,TYPE_INT64,0/*86*/}}
 
-#define NRUETIMER_T310_OKVALUES                                 {0,50,100,200,500,1000,2000}
-#define NRUETT310(A)                                            NR_UE_TimersAndConstants__t310_ ## A
-#define NRUETIMER_T310_MODVALUES                                { NRUETT310(ms0), NRUETT310(ms50), NRUETT310(ms100), NRUETT310(ms200), NRUETT310(ms500), NRUETT310(ms1000), NRUETT310(ms2000)}
 
-#define NRUETIMER_T311_OKVALUES                                 {1000,3000,5000,10000,15000,20000,30000}
-#define NRUETT311(A)                                            NR_UE_TimersAndConstants__t311_ ## A
-#define NRUETIMER_T311_MODVALUES                                { NRUETT311(ms1000), NRUETT311(ms3000), NRUETT311(ms5000), NRUETT311(ms10000), NRUETT311(ms15000), NRUETT311(ms20000), NRUETT311(ms30000)}
 
-#define NRUETIMER_T319_OKVALUES                                 {100,200,300,400,600,1000,1500,2000}
-#define NRUETT319(A)                                            NR_UE_TimersAndConstants__t319_ ## A
-#define NRUETIMER_T319_MODVALUES                                { NRUETT319(ms100), NRUETT319(ms200), NRUETT319(ms300), NRUETT319(ms400), NRUETT319(ms600), NRUETT319(ms1000), NRUETT319(ms1500), NRUETT319(ms2000}
 
-#define NRUETIMER_N310_OKVALUES                                 {1,2,3,4,6,8,10,20}
-#define NRUETN310(A)                                            NR_UE_TimersAndConstants__n310_ ## A
-#define NRUETIMER_N310_MODVALUES                                { NRUETN310(n1), NRUETN310(n2), NRUETN310(n3), NRUETN310(n4), NRUETN310(n6), NRUETN310(n8), NRUETN310(n10), NRUETN310(n20)}
 
-#define NRUETIMER_N311_OKVALUES                                 {1,2,3,4,5,6,8,10}
-#define NRUETN311(A)                                            NR_UE_TimersAndConstants__n311_ ## A
-#define NRUETIMER_N311_MODVALUES                                { NRUETN311(n1), NRUETN311(n2), NRUETN311(n3), NRUETN311(n4), NRUETN311(n5), NRUETN311(n6), NRUETN311(n8), NRUETN311(n10)}
 
 #endif
diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c
index e6f84a8d130..f11e302771d 100644
--- a/openair2/GNB_APP/gnb_app.c
+++ b/openair2/GNB_APP/gnb_app.c
@@ -37,6 +37,7 @@
 
 #include "common/utils/LOG/log.h"
 
+#include "x2ap_eNB.h"
 #include "intertask_interface.h"
 #include "s1ap_eNB.h"
 #include "sctp_eNB_task.h"
@@ -45,13 +46,10 @@
 
 extern unsigned char NB_gNB_INST;
 
-
 extern RAN_CONTEXT_t RC;
 
 #define GNB_REGISTER_RETRY_DELAY 10
 
-
-
 /*------------------------------------------------------------------------------*/
 static void configure_nr_rrc(uint32_t gnb_id)
 {
@@ -106,13 +104,34 @@ static uint32_t gNB_app_register(uint32_t gnb_id_start, uint32_t gnb_id_end)//,
 }
 */
 
+/*------------------------------------------------------------------------------*/
+static uint32_t gNB_app_register_x2(uint32_t gnb_id_start, uint32_t gnb_id_end) {
+  uint32_t         gnb_id;
+  MessageDef      *msg_p;
+  uint32_t         register_gnb_x2_pending = 0;
+
+  for (gnb_id = gnb_id_start; (gnb_id < gnb_id_end) ; gnb_id++) {
+    {
+      msg_p = itti_alloc_new_message (TASK_GNB_APP, X2AP_REGISTER_ENB_REQ);
+      LOG_I(X2AP, "GNB_ID: %d \n", gnb_id);
+      RCconfig_NR_X2(msg_p, gnb_id);
+      itti_send_msg_to_task (TASK_X2AP, ENB_MODULE_ID_TO_INSTANCE(gnb_id), msg_p);
+      register_gnb_x2_pending++;
+    }
+  }
+
+  return register_gnb_x2_pending;
+}
+
 
 /*------------------------------------------------------------------------------*/
 void *gNB_app_task(void *args_p)
 {
+
   uint32_t                        gnb_nb = RC.nb_nr_inst; 
   uint32_t                        gnb_id_start = 0;
   uint32_t                        gnb_id_end = gnb_id_start + gnb_nb;
+  uint32_t                        x2_register_gnb_pending = 0;
   uint32_t                        gnb_id;
   MessageDef                      *msg_p           = NULL;
   const char                      *msg_name        = NULL;
@@ -149,6 +168,11 @@ void *gNB_app_task(void *args_p)
     configure_nr_rrc(gnb_id);
   }
 
+  if (is_x2ap_enabled() ) { //&& !NODE_IS_DU(RC.rrc[0]->node_type)
+	  LOG_I(X2AP, "X2AP enabled \n");
+	  x2_register_gnb_pending = gNB_app_register_x2 (gnb_id_start, gnb_id_end);
+  }
+
   if (EPC_MODE_ENABLED) {
   /* Try to register each gNB */
   //registered_gnb = 0;
diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c
index 7061423ba68..93555170726 100644
--- a/openair2/GNB_APP/gnb_config.c
+++ b/openair2/GNB_APP/gnb_config.c
@@ -55,6 +55,7 @@
 //#include "RRC_config_tools.h"
 #include "gnb_paramdef.h"
 #include "LAYER2/NR_MAC_gNB/mac_proto.h"
+#include "NR_asn_constant.h"
 #include "executables/thread-common.h"
 #include "NR_SCS-SpecificCarrier.h"
 #include "NR_TDD-UL-DL-ConfigCommon.h"
@@ -74,9 +75,219 @@
 
 extern uint16_t sf_ahead;
 
-extern int config_check_band_frequencies(int ind, int16_t band, uint32_t downlink_frequency,
+extern int config_check_band_frequencies(int ind, int16_t band, uint64_t downlink_frequency,
                                          int32_t uplink_frequency_offset, uint32_t  frame_type);
 
+void prepare_scc(NR_ServingCellConfigCommon_t *scc) {
+
+  NR_FreqBandIndicatorNR_t                        *dl_frequencyBandList,*ul_frequencyBandList;
+  struct NR_SCS_SpecificCarrier                   *dl_scs_SpecificCarrierList,*ul_scs_SpecificCarrierList;
+  struct NR_PDSCH_TimeDomainResourceAllocation    *bwp_dl_timedomainresourceallocation;
+  struct NR_PUSCH_TimeDomainResourceAllocation    *pusch_configcommontimedomainresourceallocation;
+  //  struct NR_RateMatchPattern                      *ratematchpattern;
+  //  NR_RateMatchPatternId_t                         *ratematchpatternid;
+  //  NR_TCI_StateId_t                                *TCI_StateId;
+  //  struct NR_ControlResourceSet                    *bwp_dl_controlresourceset;
+  //  NR_SearchSpace_t                                *bwp_dl_searchspace;
+
+  scc->physCellId                                = CALLOC(1,sizeof(NR_PhysCellId_t));
+  scc->downlinkConfigCommon                      = CALLOC(1,sizeof(struct NR_DownlinkConfigCommon));
+  scc->downlinkConfigCommon->frequencyInfoDL     = CALLOC(1,sizeof(struct NR_FrequencyInfoDL));
+  scc->downlinkConfigCommon->initialDownlinkBWP  = CALLOC(1,sizeof(struct NR_BWP_DownlinkCommon));
+  scc->uplinkConfigCommon                        = CALLOC(1,sizeof(struct NR_UplinkConfigCommon));
+  scc->uplinkConfigCommon->frequencyInfoUL       = CALLOC(1,sizeof(struct NR_FrequencyInfoUL));
+  scc->uplinkConfigCommon->initialUplinkBWP      = CALLOC(1,sizeof(struct NR_BWP_UplinkCommon));
+  //scc->supplementaryUplinkConfig       = CALLOC(1,sizeof(struct NR_UplinkConfigCommon));  
+  scc->ssb_PositionsInBurst                      = CALLOC(1,sizeof(struct NR_ServingCellConfigCommon__ssb_PositionsInBurst));
+  scc->ssb_periodicityServingCell                = CALLOC(1,sizeof(long));
+  //  scc->rateMatchPatternToAddModList              = CALLOC(1,sizeof(struct NR_ServingCellConfigCommon__rateMatchPatternToAddModList));
+  //  scc->rateMatchPatternToReleaseList             = CALLOC(1,sizeof(struct NR_ServingCellConfigCommon__rateMatchPatternToReleaseList));
+  scc->ssbSubcarrierSpacing                      = CALLOC(1,sizeof(NR_SubcarrierSpacing_t));
+  scc->tdd_UL_DL_ConfigurationCommon             = CALLOC(1,sizeof(struct NR_TDD_UL_DL_ConfigCommon));
+  scc->tdd_UL_DL_ConfigurationCommon->pattern2   = CALLOC(1,sizeof(struct NR_TDD_UL_DL_Pattern));
+  
+  scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB     = CALLOC(1,sizeof(NR_ARFCN_ValueNR_t));
+  
+  dl_frequencyBandList              = CALLOC(1,sizeof(NR_FreqBandIndicatorNR_t));
+  dl_scs_SpecificCarrierList        = CALLOC(1,sizeof(struct NR_SCS_SpecificCarrier));
+
+  ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list,dl_frequencyBandList);  
+  ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list,dl_scs_SpecificCarrierList);		   		   
+  //  scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.cyclicPrefix    = CALLOC(1,sizeof(long));
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon                = CALLOC(1,sizeof(struct NR_SetupRelease_PDCCH_ConfigCommon));
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->present=NR_SetupRelease_PDCCH_ConfigCommon_PR_setup; 
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup  = CALLOC(1,sizeof(struct NR_PDCCH_ConfigCommon));
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero    = CALLOC(1,sizeof(long));
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero           = CALLOC(1,sizeof(long));
+  //  scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet  = CALLOC(1,sizeof(struct NR_ControlResourceSet));
+
+  //  scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList     = CALLOC(1,sizeof(struct NR_PDCCH_ConfigCommon__commonSearchSpaceList));
+  //  scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1                    = CALLOC(1,sizeof(NR_SearchSpaceId_t));
+  //  scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation  = CALLOC(1,sizeof(NR_SearchSpaceId_t));
+  //  scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->pagingSearchSpace                  = CALLOC(1,sizeof(NR_SearchSpaceId_t));
+  //  scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace                     = CALLOC(1,sizeof(NR_SearchSpaceId_t));
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon                 = CALLOC(1,sizeof(struct NR_SetupRelease_PDSCH_ConfigCommon));
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->present        = NR_SetupRelease_PDSCH_ConfigCommon_PR_setup;
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup   = CALLOC(1,sizeof(struct NR_PDSCH_ConfigCommon));
+  scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = CALLOC(1,sizeof(struct NR_PDSCH_TimeDomainResourceAllocationList));
+  //
+  for (int i=0;i<NR_maxNrofDL_Allocations;i++) {
+    bwp_dl_timedomainresourceallocation = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t));
+    bwp_dl_timedomainresourceallocation->k0  = CALLOC(1,sizeof(long));
+    *bwp_dl_timedomainresourceallocation->k0=0;
+    ASN_SEQUENCE_ADD(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list,
+		     bwp_dl_timedomainresourceallocation);
+  }
+
+  ul_frequencyBandList              = CALLOC(1,sizeof(NR_FreqBandIndicatorNR_t));
+  scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList          = CALLOC(1,sizeof(struct NR_MultiFrequencyBandListNR));
+  ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list,ul_frequencyBandList);
+
+  scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA    = CALLOC(1,sizeof(NR_ARFCN_ValueNR_t));
+  //  scc->uplinkConfigCommon->frequencyInfoUL->additionalSpectrumEmission = CALLOC(1,sizeof(NR_AdditionalSpectrumEmission_t));
+  scc->uplinkConfigCommon->frequencyInfoUL->p_Max                      = CALLOC(1,sizeof(NR_P_Max_t));
+  //  scc->uplinkConfigCommon->frequencyInfoUL->frequencyShift7p5khz       = CALLOC(1,sizeof(long));
+  
+  //  scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.cyclicPrefix    = CALLOC(1,sizeof(long));
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon                 = CALLOC(1,sizeof(NR_SetupRelease_RACH_ConfigCommon_t));
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->present = NR_SetupRelease_RACH_ConfigCommon_PR_setup;
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup   = CALLOC(1,sizeof(struct NR_RACH_ConfigCommon));
+  //  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->totalNumberOfRA_Preambles                  = CALLOC(1,sizeof(long));
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB  = CALLOC(1,sizeof(struct NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
+  //  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->groupBconfigured                           = CALLOC(1,sizeof(struct NR_RACH_ConfigCommon__groupBconfigured));
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rsrp_ThresholdSSB            = CALLOC(1,sizeof(NR_RSRP_Range_t));
+  //  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rsrp_ThresholdSSB_SUL        = CALLOC(1,sizeof(NR_RSRP_Range_t));
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing       = CALLOC(1,sizeof(NR_SubcarrierSpacing_t));
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder       = CALLOC(1,sizeof(long));
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon                 = CALLOC(1,sizeof(NR_SetupRelease_PUSCH_ConfigCommon_t)); 
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->present        = NR_SetupRelease_PUSCH_ConfigCommon_PR_setup;
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup   = CALLOC(1,sizeof(struct NR_PUSCH_ConfigCommon));
+
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->groupHoppingEnabledTransformPrecoding = CALLOC(1,sizeof(long));
+  
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList  = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocationList));
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble              = CALLOC(1,sizeof(long));
+  scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->p0_NominalWithGrant             = CALLOC(1,sizeof(long));
+  
+  scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon                                                = CALLOC(1,sizeof(struct NR_SetupRelease_PUCCH_ConfigCommon)); 
+  scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->present= NR_SetupRelease_PUCCH_ConfigCommon_PR_setup;
+  scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup                                  = CALLOC(1,sizeof(struct NR_PUCCH_ConfigCommon));
+  scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->p0_nominal                      = CALLOC(1,sizeof(long));
+  scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon            = CALLOC(1,sizeof(long));
+  scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->hoppingId                       = CALLOC(1,sizeof(long));
+
+  //  scc->ssb_PositionsInBurst->choice.shortBitmap.buf  = MALLOC(1);
+  //  scc->ssb_PositionsInBurst->choice.mediumBitmap.buf = MALLOC(1);
+  //  scc->ssb_PositionsInBurst->choice.longBitmap.buf   = MALLOC(8);
+  
+
+  ul_scs_SpecificCarrierList  = CALLOC(1,sizeof(struct NR_SCS_SpecificCarrier));
+  ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list,ul_scs_SpecificCarrierList);
+
+  for (int i=0;i<NR_maxNrofUL_Allocations;i++) {
+    pusch_configcommontimedomainresourceallocation      = CALLOC(1,sizeof(struct NR_PUSCH_TimeDomainResourceAllocation));
+    pusch_configcommontimedomainresourceallocation->k2  = CALLOC(1,sizeof(long));
+    *pusch_configcommontimedomainresourceallocation->k2=0;
+    ASN_SEQUENCE_ADD(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,pusch_configcommontimedomainresourceallocation); 
+  }
+  //ratematchpattern                              = CALLOC(1,sizeof(struct NR_RateMatchPattern));
+  //ratematchpattern->patternType.choice.bitmaps  = CALLOC(1,sizeof(struct NR_RateMatchPattern__patternType__bitmaps));
+  //ratematchpattern->patternType.choice.bitmaps->resourceBlocks.buf = MALLOC(35);
+  //ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.oneSlot.buf   = MALLOC(2);
+  //ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.twoSlots.buf  = MALLOC(4);
+  //ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern                       = CALLOC(1,sizeof(struct NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern));
+  //ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n2.buf        = MALLOC(1);
+  //ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n4.buf        = MALLOC(1);
+  //ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n5.buf        = MALLOC(1);
+  //ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n8.buf        = MALLOC(1);
+  //ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n10.buf       = MALLOC(2);
+  //ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n20.buf       = MALLOC(3);
+  //ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n40.buf       = MALLOC(5);
+  //ratematchpattern->subcarrierSpacing           = CALLOC(1,sizeof(NR_SubcarrierSpacing_t));
+  //ratematchpatternid                            = CALLOC(1,sizeof(NR_RateMatchPatternId_t));
+  
+}
+
+
+void fix_scc(NR_ServingCellConfigCommon_t *scc,uint64_t ssbmap) {
+
+  int ssbmaplen = (int)scc->ssb_PositionsInBurst->present;
+  uint8_t curr_bit;
+
+  AssertFatal(ssbmaplen==NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap || ssbmaplen==NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap || ssbmaplen==NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_longBitmap, "illegal ssbmaplen %d\n",ssbmaplen);
+
+  // changing endianicity of ssbmap and filling the ssb_PositionsInBurst buffers
+  if(ssbmaplen==NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap){
+    scc->ssb_PositionsInBurst->choice.shortBitmap.size = 1;
+    scc->ssb_PositionsInBurst->choice.shortBitmap.bits_unused = 4;
+    scc->ssb_PositionsInBurst->choice.shortBitmap.buf = CALLOC(1,1);
+    scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0] = 0;
+    for (int i=0; i<8; i++) {
+      if (i<scc->ssb_PositionsInBurst->choice.shortBitmap.bits_unused)
+        curr_bit = 0;
+      else
+        curr_bit = (ssbmap>>(7-i))&0x01;
+      scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0] |= curr_bit<<i;   
+    }
+  }else if(ssbmaplen==NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap){
+	  scc->ssb_PositionsInBurst->choice.mediumBitmap.size = 1;
+	  scc->ssb_PositionsInBurst->choice.mediumBitmap.bits_unused = 0;
+    scc->ssb_PositionsInBurst->choice.mediumBitmap.buf = CALLOC(1,1);
+    scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0] = 0;
+    for (int i=0; i<8; i++)
+      scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0] |= (((ssbmap>>(7-i))&0x01)<<i); 
+  }else {
+    scc->ssb_PositionsInBurst->choice.longBitmap.size = 8;
+    scc->ssb_PositionsInBurst->choice.longBitmap.bits_unused = 0;
+    scc->ssb_PositionsInBurst->choice.longBitmap.buf = CALLOC(1,8);
+    for (int j=0; j<8; j++) {
+       scc->ssb_PositionsInBurst->choice.longBitmap.buf[7-j] = 0;
+       curr_bit = (ssbmap>>(j<<3))&(0xff);
+       for (int i=0; i<8; i++)
+         scc->ssb_PositionsInBurst->choice.longBitmap.buf[7-j] |= (((curr_bit>>(7-i))&0x01)<<i);
+    }
+  }
+
+  // fix UL absolute frequency
+  if ((int)*scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA==-1) {
+     free(scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA);
+     scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA = NULL;
+  }
+
+  // fix libconfig (asn1c uses long) 
+  scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleReceivedTargetPower-=((long)1<<32); 
+  *scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->p0_NominalWithGrant-=((long)1<<32);
+  *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->p0_nominal-=((long)1<<32);
+
+  // fix DL and UL Allocation lists
+  
+  for (int i=scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count-1;i>=0;i--) {
+    printf("Checking element %d : %ld\n",i,*scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0);
+    if (*scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0>32) {
+      printf("removing pdsch_TimeDomainAllocationList element %d\n",i);
+      free(scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0);
+      asn_sequence_del(&scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list,i,1); 
+      printf("List size now %d\n",scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count);
+    }
+  }
+
+  for (int i=scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.count-1;i>=0;i--) {
+    if (*scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[i]->k2>32) {
+      free(scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[i]->k2);
+      asn_sequence_del(&scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,i,1); 
+    }
+  }
+  if (scc->tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity > 320 ) {
+    free(scc->tdd_UL_DL_ConfigurationCommon->pattern2);
+    scc->tdd_UL_DL_ConfigurationCommon->pattern2=NULL;
+  }
+
+  if ((int)*scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing == -1) {
+    free(scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing);
+    scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing=NULL;
+  }
+}
+
 void RCconfig_nr_flexran()
 {
   uint16_t  i;
@@ -85,91 +296,9 @@ void RCconfig_nr_flexran()
   /* this will possibly truncate the cell id (RRC assumes int32_t).
    * Both Nid_cell and gnb_id are signed in RRC case, but we use unsigned for
    * the bitshifting to work properly */
-  int32_t   Nid_cell = 0;
   uint16_t  Nid_cell_tr = 0;
   uint32_t  gnb_id = 0;
 
-  /*
-   * the only reason for all these variables is, that they are "hard-encoded"
-   * into the CCPARAMS_DESC macro and we need it for the Nid_cell variable ...
-   */
-  char      *frame_type, *DL_prefix_type, *UL_prefix_type, *SIB1_frequencyOffsetSSB,
-            *DL_SCS_SubcarrierSpacing, *DL_BWP_SubcarrierSpacing, *DL_BWP_prefix_type,
-            *UL_frequencyShift7p5khz, *UL_SCS_SubcarrierSpacing, *UL_BWP_SubcarrierSpacing,
-            *UL_BWP_prefix_type, *UL_timeAlignmentTimerCommon, 
-            *ServingCellConfigCommon_n_TimingAdvanceOffset,
-            *NIA_SubcarrierSpacing, *referenceSubcarrierSpacing, *dl_UL_TransmissionPeriodicity,
-            *rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,
-            *rach_groupBconfigured, *rach_messagePowerOffsetGroupB, 
-            *prach_RootSequenceIndex_choice, *prach_msg1_SubcarrierSpacing,
-            *restrictedSetConfig, *msg3_transformPrecoding, *prach_msg1_FDM,
-            *powerRampingStep, *groupHoppingEnabledTransformPrecoding,
-            *PUSCH_TimeDomainResourceAllocation_mappingType, *pucch_GroupHopping,
-            *PDSCH_TimeDomainResourceAllocation_mappingType, *RateMatchPattern_patternType,
-            *symbolsInResourceBlock, *RateMatchPattern_subcarrierSpacing, *RateMatchPattern_mode,
-            *PDCCH_cce_REG_MappingType, *PDCCH_precoderGranularity,
-            *tci_PresentInDCI, *SearchSpace_monitoringSlotPeriodicityAndOffset_choice,
-            *SearchSpace_searchSpaceType, *ue_Specific__dci_Formats,
-            *RateMatchPatternLTE_CRS_subframeAllocation_choice;
-
-  uint64_t  downlink_frequency, ServingCellConfigCommon_ssb_PositionsInBurst_PR;
-
-  int32_t   nr_band, uplink_frequency_offset, N_RB_DL, nb_antenna_ports,
-            MIB_subCarrierSpacingCommon, MIB_ssb_SubcarrierOffset, MIB_dmrs_TypeA_Position,
-            pdcch_ConfigSIB1, SIB1_ssb_PeriodicityServingCell, SIB1_ss_PBCH_BlockPower,
-            absoluteFrequencySSB, DL_FreqBandIndicatorNR,
-            DL_absoluteFrequencyPointA, DL_offsetToCarrier,
-            DL_carrierBandwidth, DL_locationAndBandwidth, UL_FreqBandIndicatorNR,
-            UL_absoluteFrequencyPointA, UL_additionalSpectrumEmission, UL_p_Max,
-            UL_offsetToCarrier, UL_carrierBandwidth,
-            UL_locationAndBandwidth, ServingCellConfigCommon_ssb_periodicityServingCell,
-            ServingCellConfigCommon_dmrs_TypeA_Position, ServingCellConfigCommon_ss_PBCH_BlockPower,
-            nrofDownlinkSlots, nrofDownlinkSymbols, nrofUplinkSlots, nrofUplinkSymbols,
-            rach_totalNumberOfRA_Preambles, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth,
-            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth,
-            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf,
-            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one,
-            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two,
-            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four,
-            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight,
-            rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen,
-            rach_ra_Msg3SizeGroupA, rach_numberOfRA_PreamblesGroupA, rach_ra_ContentionResolutionTimer,
-            rsrp_ThresholdSSB, rsrp_ThresholdSSB_SUL, prach_RootSequenceIndex_l839,
-            prach_RootSequenceIndex_l139, prach_ConfigurationIndex, prach_msg1_FrequencyStart,
-            zeroCorrelationZoneConfig, preambleReceivedTargetPower, preambleTransMax,
-            ra_ResponseWindow, msg3_DeltaPreamble, p0_NominalWithGrant,
-            PUSCH_TimeDomainResourceAllocation_k2,
-            PUSCH_TimeDomainResourceAllocation_startSymbolAndLength,
-            pucch_ResourceCommon, hoppingId, p0_nominal, PDSCH_TimeDomainResourceAllocation_k0,
-            PDSCH_TimeDomainResourceAllocation_startSymbolAndLength,
-            rateMatchPatternId, periodicityAndPattern, RateMatchPattern_controlResourceSet,
-            controlResourceSetZero, searchSpaceZero,
-            searchSpaceSIB1, searchSpaceOtherSystemInformation, pagingSearchSpace,
-            ra_SearchSpace, PDCCH_common_controlResourceSetId,
-            PDCCH_common_ControlResourceSet_duration, PDCCH_reg_BundleSize, PDCCH_interleaverSize,
-            PDCCH_shiftIndex, PDCCH_TCI_StateId, PDCCH_DMRS_ScramblingID,
-            SearchSpaceId, commonSearchSpaces_controlResourceSetId,
-            SearchSpace_monitoringSlotPeriodicityAndOffset_value,
-            SearchSpace_duration,
-            SearchSpace_nrofCandidates_aggregationLevel1,
-            SearchSpace_nrofCandidates_aggregationLevel2,
-            SearchSpace_nrofCandidates_aggregationLevel4,
-            SearchSpace_nrofCandidates_aggregationLevel8,
-            SearchSpace_nrofCandidates_aggregationLevel16,
-            Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1,
-            Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2,
-            Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4,
-            Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8,
-            Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16,
-            Common_dci_Format2_3_monitoringPeriodicity,
-            Common_dci_Format2_3_nrofPDCCH_Candidates,
-            RateMatchPatternLTE_CRS_carrierFreqDL,
-            RateMatchPatternLTE_CRS_carrierBandwidthDL,
-            RateMatchPatternLTE_CRS_nrofCRS_Ports,
-            RateMatchPatternLTE_CRS_v_Shift,
-            RateMatchPatternLTE_CRS_radioframeAllocationPeriod,
-            RateMatchPatternLTE_CRS_radioframeAllocationOffset
-            ;
 
   /* get number of gNBs */
   paramdef_t GNBSParams[] = GNBSPARAMS_DESC;
@@ -180,15 +309,6 @@ void RCconfig_nr_flexran()
   paramdef_t GNBParams[]  = GNBPARAMS_DESC;
   paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST, NULL, 0};
 
-  /* for Nid_cell */
-  checkedparam_t config_check_CCparams[] = NRCCPARAMS_CHECK;
-  paramdef_t CCsParams[] = NRCCPARAMS_DESC;
-  paramlist_def_t CCsParamList = {GNB_CONFIG_STRING_COMPONENT_CARRIERS, NULL, 0};
-  /* map parameter checking array instances to parameter definition array instances */
-  for (int I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) {
-    CCsParams[I].chkPptr = &(config_check_CCparams[I]);
-  }
-
   paramdef_t flexranParams[] = FLEXRANPARAMS_DESC;
   config_get(flexranParams, sizeof(flexranParams)/sizeof(paramdef_t), CONFIG_STRING_NETWORK_CONTROLLER_CONFIG);
 
@@ -231,12 +351,6 @@ void RCconfig_nr_flexran()
 
     /* cell ID */
     sprintf(aprefix, "%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, i);
-    config_getlist(&CCsParamList, NULL, 0, aprefix);
-    if (CCsParamList.numelt > 0) {
-      sprintf(aprefix, "%s.[%i].%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, i, GNB_CONFIG_STRING_COMPONENT_CARRIERS, 0);
-      config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix);
-      Nid_cell_tr = (uint16_t) Nid_cell;
-    }
 
     RC.flexran[i]->mod_id   = i;
     RC.flexran[i]->agent_id = (((uint64_t)i) << 48) | (((uint64_t)gnb_id) << 16) | ((uint64_t)Nid_cell_tr);
@@ -259,16 +373,15 @@ void RCconfig_nr_flexran()
 }
 
 void RCconfig_NR_L1(void) {
-  int               i,j;
+  int j;
   paramdef_t L1_Params[] = L1PARAMS_DESC;
   paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST,NULL,0};
 
 
   if (RC.gNB == NULL) {
-    RC.gNB                       = (PHY_VARS_gNB ***)malloc((1+NUMBER_OF_gNB_MAX)*sizeof(PHY_VARS_gNB**));
+    RC.gNB                       = (PHY_VARS_gNB **)malloc((1+NUMBER_OF_gNB_MAX)*sizeof(PHY_VARS_gNB*));
     LOG_I(NR_PHY,"RC.gNB = %p\n",RC.gNB);
-    memset(RC.gNB,0,(1+NUMBER_OF_gNB_MAX)*sizeof(PHY_VARS_gNB**));
-    RC.nb_nr_L1_CC = malloc((1+RC.nb_nr_L1_inst)*sizeof(int));
+    memset(RC.gNB,0,(1+NUMBER_OF_gNB_MAX)*sizeof(PHY_VARS_gNB*));
   }
 
   config_getlist( &L1_ParamList,L1_Params,sizeof(L1_Params)/sizeof(paramdef_t), NULL);
@@ -276,35 +389,25 @@ void RCconfig_NR_L1(void) {
   if (L1_ParamList.numelt > 0) {
 
     for (j = 0; j < RC.nb_nr_L1_inst; j++) {
-      RC.nb_nr_L1_CC[j] = *(L1_ParamList.paramarray[j][L1_CC_IDX].uptr);
 
       if (RC.gNB[j] == NULL) {
-        RC.gNB[j]                       = (PHY_VARS_gNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_gNB*));
+        RC.gNB[j]                       = (PHY_VARS_gNB *)malloc(sizeof(PHY_VARS_gNB));
         LOG_I(NR_PHY,"RC.gNB[%d] = %p\n",j,RC.gNB[j]);
-        memset(RC.gNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_gNB*));
-      }
-
-      for (i=0;i<RC.nb_nr_L1_CC[j];i++) {
-        if (RC.gNB[j][i] == NULL) {
-          RC.gNB[j][i] = (PHY_VARS_gNB *)malloc(sizeof(PHY_VARS_gNB));
-          memset((void*)RC.gNB[j][i],0,sizeof(PHY_VARS_gNB));
-          LOG_I(PHY,"RC.eNB[%d][%d] = %p\n",j,i,RC.gNB[j][i]);
-          RC.gNB[j][i]->Mod_id  = j;
-          RC.gNB[j][i]->CC_id   = i;
-        }
+        memset(RC.gNB[j],0,sizeof(PHY_VARS_gNB));
+	RC.gNB[j]->Mod_id  = j;
       }
 
       if(strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) {
         //sf_ahead = 2; // Need 4 subframe gap between RX and TX
       }else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) {
-        RC.gNB[j][0]->eth_params_n.local_if_name            = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr));
-        RC.gNB[j][0]->eth_params_n.my_addr                  = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr));
-        RC.gNB[j][0]->eth_params_n.remote_addr              = strdup(*(L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr));
-        RC.gNB[j][0]->eth_params_n.my_portc                 = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr);
-        RC.gNB[j][0]->eth_params_n.remote_portc             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_IDX].iptr);
-        RC.gNB[j][0]->eth_params_n.my_portd                 = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr);
-        RC.gNB[j][0]->eth_params_n.remote_portd             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr);
-        RC.gNB[j][0]->eth_params_n.transp_preference        = ETH_UDP_MODE;
+        RC.gNB[j]->eth_params_n.local_if_name            = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr));
+        RC.gNB[j]->eth_params_n.my_addr                  = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr));
+        RC.gNB[j]->eth_params_n.remote_addr              = strdup(*(L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr));
+        RC.gNB[j]->eth_params_n.my_portc                 = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr);
+        RC.gNB[j]->eth_params_n.remote_portc             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_IDX].iptr);
+        RC.gNB[j]->eth_params_n.my_portd                 = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr);
+        RC.gNB[j]->eth_params_n.remote_portd             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr);
+        RC.gNB[j]->eth_params_n.transp_preference        = ETH_UDP_MODE;
 
         //sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2
 
@@ -322,7 +425,7 @@ void RCconfig_NR_L1(void) {
 
         mac_top_init_gNB();
 
-        configure_nfapi_pnf(RC.gNB[j][0]->eth_params_n.remote_addr, RC.gNB[j][0]->eth_params_n.remote_portc, RC.gNB[j][0]->eth_params_n.my_addr, RC.gNB[j][0]->eth_params_n.my_portd, RC.gNB[j][0]->eth_params_n     .remote_portd);
+        configure_nfapi_pnf(RC.gNB[j]->eth_params_n.remote_addr, RC.gNB[j]->eth_params_n.remote_portc, RC.gNB[j]->eth_params_n.my_addr, RC.gNB[j]->eth_params_n.my_portd, RC.gNB[j]->eth_params_n     .remote_portd);
       }else { // other midhaul
       } 
     }// for (j = 0; j < RC.nb_nr_L1_inst; j++)
@@ -335,26 +438,13 @@ void RCconfig_NR_L1(void) {
 
     j = 0;
 
-    RC.nb_nr_L1_CC = malloc((1+RC.nb_nr_L1_inst)*sizeof(int)); // DJP - 1 lot then???
-
-    RC.nb_nr_L1_CC[j]=1; // DJP - hmmm
 
     if (RC.gNB[j] == NULL) {
-      RC.gNB[j]                       = (PHY_VARS_gNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_gNB**));
+      RC.gNB[j] = (PHY_VARS_gNB *)malloc(sizeof(PHY_VARS_gNB));
+      memset((void*)RC.gNB[j],0,sizeof(PHY_VARS_gNB));
       LOG_I(PHY,"RC.gNB[%d] = %p\n",j,RC.gNB[j]);
-      memset(RC.gNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_gNB***));
-    }
-
-    for (i=0;i<RC.nb_nr_L1_CC[j];i++) {
-      if (RC.gNB[j][i] == NULL) {
-        RC.gNB[j][i] = (PHY_VARS_gNB *)malloc(sizeof(PHY_VARS_gNB));
-        memset((void*)RC.gNB[j][i],0,sizeof(PHY_VARS_gNB));
-        LOG_I(PHY,"RC.gNB[%d][%d] = %p\n",j,i,RC.gNB[j][i]);
-        RC.gNB[j][i]->Mod_id  = j;
-        RC.gNB[j][i]->CC_id   = i;
-      }
-    } // END for (i=0;i<RC.nb_nr_L1_CC[j];i++)
-  
+      RC.gNB[j]->Mod_id  = j;
+    }   
   }
 }
 
@@ -421,218 +511,28 @@ void RCconfig_nr_macrlc() {
 void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
 
   int                    num_gnbs                                                      = 0;
-  int                    num_component_carriers                                        = 0;
-  int                    j,k                                                           = 0;
+  char aprefix[MAX_OPTNAME_SIZE*2 + 8];
   int32_t                gnb_id                                                        = 0;
-
-  int                    nb_cc                                                         = 0;
-  char*                  frame_type                                                    = NULL;
-  char*                  DL_prefix_type                                                = NULL;
-  char*                  UL_prefix_type                                                = NULL;
-
-  int32_t                nr_band                                                       = 0;
-  uint64_t               downlink_frequency                                            = 0;
-  int32_t                uplink_frequency_offset                                       = 0;
-  int32_t                Nid_cell                                                      = 0;
-  int32_t                N_RB_DL                                                       = 0;
-  int32_t                nb_antenna_ports                                              = 0;
-
-  ///NR
-  //MIB
-  int32_t                MIB_subCarrierSpacingCommon                                   = 0;
-  int32_t                MIB_ssb_SubcarrierOffset                                      = 0;
-  int32_t                MIB_dmrs_TypeA_Position                                       = 0;
-  int32_t                pdcch_ConfigSIB1                                              = 0;
-
-  //SIB1
-  char*                  SIB1_frequencyOffsetSSB                                       = NULL; 
-  int32_t                SIB1_ssb_PeriodicityServingCell                               = 0;
-  int32_t                SIB1_ss_PBCH_BlockPower                                       = 0;
-  //DownlinkConfigCommon
-  //NR FrequencyInfoDL
-  int32_t                absoluteFrequencySSB                                          = 0;
-  int32_t                DL_FreqBandIndicatorNR                                        = 0;
-  int32_t                DL_absoluteFrequencyPointA                                    = 0;
-
-  //NR DL SCS-SpecificCarrier
-  int32_t                DL_offsetToCarrier                                            = 0;
-  char*                  DL_SCS_SubcarrierSpacing                                      = 0;
-  int32_t                DL_carrierBandwidth                                           = 0;
-
-  // NR BWP-DownlinkCommon
-  int32_t                DL_locationAndBandwidth                                       = 0;
-  char*                  DL_BWP_SubcarrierSpacing                                      = 0;
-  char*                  DL_BWP_prefix_type                                            = NULL;  
-  
-  //NR FrequencyInfoUL
-  int32_t                UL_FreqBandIndicatorNR                                        = 0;
-  int32_t                UL_absoluteFrequencyPointA                                    = 0;
-  int32_t                UL_additionalSpectrumEmission                                 = 0;
-  int32_t                UL_p_Max                                                      = 0;
-  char*                  UL_frequencyShift7p5khz                                       = 0;
-
-  //NR UL SCS-SpecificCarrier
-  int32_t                UL_offsetToCarrier                                            = 0;
-  char*                  UL_SCS_SubcarrierSpacing                                      = 0;
-  int32_t                UL_carrierBandwidth                                           = 0;
-
-  // NR BWP-UplinkCommon
-  int32_t                UL_locationAndBandwidth                                       = 0;
-  char*                  UL_BWP_SubcarrierSpacing                                      = 0;
-  char*                  UL_BWP_prefix_type                                            = NULL; 
-  char*                  UL_timeAlignmentTimerCommon                                   = 0;
-  
-  char*                  ServingCellConfigCommon_n_TimingAdvanceOffset                 = 0;
-  uint64_t               ServingCellConfigCommon_ssb_PositionsInBurst_PR               = 0;
-  int32_t                ServingCellConfigCommon_ssb_periodicityServingCell            = 0;
-  int32_t                ServingCellConfigCommon_dmrs_TypeA_Position                   = 0;
-  char*                  NIA_SubcarrierSpacing                                         = 0; 
-  int32_t                ServingCellConfigCommon_ss_PBCH_BlockPower                    = 0;
-
-  //NR TDD-UL-DL-ConfigCommon
-  char*                  referenceSubcarrierSpacing                                    = 0;
-  char*                  dl_UL_TransmissionPeriodicity                                 = 0;
-  int32_t                nrofDownlinkSlots                                             = 0;
-  int32_t                nrofDownlinkSymbols                                           = 0;
-  int32_t                nrofUplinkSlots                                               = 0;
-  int32_t                nrofUplinkSymbols                                             = 0;
-
-  //NR RACH-ConfigCommon
-  int32_t                rach_totalNumberOfRA_Preambles                                = 0;
-  char*                  rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice         = 0;
-  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth      = 0;
-  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth      = 0;
-  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf        = 0;
-  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one            = 0;
-  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two            = 0;
-  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four           = 0;
-  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight          = 0;
-  int32_t                rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen        = 0;
-  char*                  rach_groupBconfigured                                         = NULL;
-  int32_t                rach_ra_Msg3SizeGroupA                                        = 0;
-  char*                  rach_messagePowerOffsetGroupB                                 = NULL;
-  int32_t                rach_numberOfRA_PreamblesGroupA                               = 0;
-  int32_t                rach_ra_ContentionResolutionTimer                             = 0;
-  int32_t                rsrp_ThresholdSSB                                             = 0;
-  int32_t                rsrp_ThresholdSSB_SUL                                         = 0;
-  char*                  prach_RootSequenceIndex_choice                                = NULL;
-  int32_t                prach_RootSequenceIndex_l839                                  = 0;
-  int32_t                prach_RootSequenceIndex_l139                                  = 0;
-  char*                  prach_msg1_SubcarrierSpacing                                  = NULL;
-  char*                  restrictedSetConfig                                           = NULL;
-  char*                  msg3_transformPrecoding                                       = NULL;
-  //ssb-perRACH-OccasionAndCB-PreamblesPerSSB not sure
-
-  //NR RACH-ConfigGeneric
-  int32_t                prach_ConfigurationIndex                                      = 0;
-  char*                  prach_msg1_FDM                                                = NULL;
-  int32_t                prach_msg1_FrequencyStart                                     = 0;
-  int32_t                zeroCorrelationZoneConfig                                     = 0;
-  int32_t                preambleReceivedTargetPower                                   = 0;
-  int32_t                preambleTransMax                                              = 0;
-  char*                  powerRampingStep                                              = NULL;
-  int32_t                ra_ResponseWindow                                             = 0;
-
-  //PUSCH-ConfigCommon
-  char*                  groupHoppingEnabledTransformPrecoding                         = NULL;
-  int32_t                msg3_DeltaPreamble                                            = 0;
-  int32_t                p0_NominalWithGrant                                           = 0;
-
-  ///PUSCH-TimeDomainResourceAllocation
-  int32_t                PUSCH_TimeDomainResourceAllocation_k2                         = 0;
-  char*                  PUSCH_TimeDomainResourceAllocation_mappingType                = NULL;
-  int32_t                PUSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-
-  //PUCCH-ConfigCommon
-  int32_t                pucch_ResourceCommon                                          = 0;
-  char*                  pucch_GroupHopping                                            = NULL;
-  int32_t                hoppingId                                                     = 0;
-  int32_t                p0_nominal                                                    = 0;
-
-  //PDSCH-ConfigCOmmon
-  //PDSCH-TimeDomainResourceAllocation
-  int32_t                PDSCH_TimeDomainResourceAllocation_k0                         = 0;
-  char*                  PDSCH_TimeDomainResourceAllocation_mappingType                = NULL;
-  int32_t                PDSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-
-  //RateMatchPattern  is used to configure one rate matching pattern for PDSCH
-  int32_t                rateMatchPatternId                                            = 0;
-  char*                  RateMatchPattern_patternType                                  = NULL;
-  char*                  symbolsInResourceBlock                                        = NULL;
-  int32_t                periodicityAndPattern                                         = 0;
-  int32_t                RateMatchPattern_controlResourceSet                           = 0;
-  char*                  RateMatchPattern_subcarrierSpacing                            = NULL;
-  char*                  RateMatchPattern_mode                                         = NULL;
-
-  //PDCCH-ConfigCommon
-  int32_t                controlResourceSetZero                                        = 0;
-  int32_t                searchSpaceZero                                               = 0;
-  int32_t                searchSpaceSIB1                                               = 0;
-  int32_t                searchSpaceOtherSystemInformation                             = 0;
-  int32_t                pagingSearchSpace                                             = 0;
-  int32_t                ra_SearchSpace                                                = 0;
-  
-  //NR PDCCH-ConfigCommon commonControlResourcesSets
-  int32_t                PDCCH_common_controlResourceSetId                             = 0;
-  int32_t                PDCCH_common_ControlResourceSet_duration                      = 0;
-  char*                  PDCCH_cce_REG_MappingType                                     = NULL;
-  int32_t                PDCCH_reg_BundleSize                                          = 0;
-  int32_t                PDCCH_interleaverSize                                         = 0;
-  int32_t                PDCCH_shiftIndex                                              = 0;  
-  char*                  PDCCH_precoderGranularity                                     = NULL;
-  int32_t                PDCCH_TCI_StateId                                             = 0;
-  char*                  tci_PresentInDCI                                              = NULL;
-  int32_t                PDCCH_DMRS_ScramblingID                                       = 0;
-
-  //NR PDCCH-ConfigCommon commonSearchSpaces
-  int32_t                SearchSpaceId                                                 = 0;
-  int32_t                commonSearchSpaces_controlResourceSetId                       = 0;
-  char*                  SearchSpace_monitoringSlotPeriodicityAndOffset_choice         = NULL;
-  int32_t                SearchSpace_monitoringSlotPeriodicityAndOffset_value          = 0;
-  int32_t                SearchSpace_duration                                          = 0;
-  int32_t                SearchSpace_nrofCandidates_aggregationLevel1                  = 0;
-  int32_t                SearchSpace_nrofCandidates_aggregationLevel2                  = 0;
-  int32_t                SearchSpace_nrofCandidates_aggregationLevel4                  = 0;
-  int32_t                SearchSpace_nrofCandidates_aggregationLevel8                  = 0;
-  int32_t                SearchSpace_nrofCandidates_aggregationLevel16                 = 0;
-  char*                  SearchSpace_searchSpaceType                                   = NULL;
-  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1     = 0;
-  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2     = 0;
-  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4     = 0;
-  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8     = 0;
-  int32_t                Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16    = 0; 
-  int32_t                Common_dci_Format2_3_monitoringPeriodicity                    = 0;
-  int32_t                Common_dci_Format2_3_nrofPDCCH_Candidates                     = 0;
-  char*                  ue_Specific__dci_Formats                                      = NULL;
-  //NR  RateMatchPatternLTE-CRS
-  int32_t                RateMatchPatternLTE_CRS_carrierFreqDL                         = 0;
-  int32_t                RateMatchPatternLTE_CRS_carrierBandwidthDL                    = 0;
-  int32_t                RateMatchPatternLTE_CRS_nrofCRS_Ports                         = 0;
-  int32_t                RateMatchPatternLTE_CRS_v_Shift                               = 0;
-  int32_t                RateMatchPatternLTE_CRS_radioframeAllocationPeriod            = 0;
-  int32_t                RateMatchPatternLTE_CRS_radioframeAllocationOffset            = 0;
-  char*                  RateMatchPatternLTE_CRS_subframeAllocation_choice             = NULL;
-
-
-  /*int32_t                srb1_timer_poll_retransmit    = 0;
-  int32_t                srb1_timer_reordering         = 0;
-  int32_t                srb1_timer_status_prohibit    = 0;
-  int32_t                srb1_poll_pdu                 = 0;
-  int32_t                srb1_poll_byte                = 0;
-  int32_t                srb1_max_retx_threshold       = 0;*/
-
-  //int32_t             my_int;
-
+  int k;
   paramdef_t GNBSParams[] = GNBSPARAMS_DESC;
   ////////// Identification parameters
   paramdef_t GNBParams[]  = GNBPARAMS_DESC;
   paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0};
-  ////////// Physical parameters
-  //checkedparam_t config_check_CCparams[] = NRCCPARAMS_CHECK;
-  paramdef_t CCsParams[] = NRCCPARAMS_DESC;
-  paramlist_def_t CCsParamList = {GNB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0};
-  
-  //paramdef_t SRB1Params[] = GNBSRB1PARAMS_DESC;
+
+  NR_ServingCellConfigCommon_t *scc = calloc(1,sizeof(NR_ServingCellConfigCommon_t));
+  int ssb_SubcarrierOffset = 31;
+  int pdsch_AntennaPorts = 1;
+  uint64_t ssb_bitmap=0xff;
+  memset((void*)scc,0,sizeof(NR_ServingCellConfigCommon_t));
+  prepare_scc(scc);
+  paramdef_t SCCsParams[] = SCCPARAMS_DESC(scc);
+  paramlist_def_t SCCsParamList = {GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON, NULL, 0};
+  paramdef_t SSBsParams[] = SSBPARAMS_DESC;
+  paramlist_def_t SSBsParamList = {GNB_CONFIG_STRING_SSBSUBCARRIEROFFSET, NULL, 0};
+  paramdef_t PDSCHANTENNAParams[] = PDSCHANTENNAPARAMS_DESC;
+  paramlist_def_t PDSCHANTENNAParamList = {GNB_CONFIG_STRING_PDSCHANTENNAPORTS, NULL, 0};
+   ////////// Physical parameters
+
 
   /* get global parameters, defined outside any section in the config file */
  
@@ -659,9 +559,12 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
   */
 
   if (num_gnbs>0) {
+
+
+
     // Output a list of all gNBs. ////////// Identification parameters
     config_getlist( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),NULL); 
-
+    
     if (GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr == NULL) {
     // Calculate a default gNB ID
       if (EPC_MODE_ENABLED) { 
@@ -672,13 +575,33 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
         gnb_id = i;
       }
     } else {
-        gnb_id = *(GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr);
+      gnb_id = *(GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr);
     }
 
-    printf("NRRRC %u: Southbound Transport %s\n",i,*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr));
-
+    sprintf(aprefix, "%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, 0);
+    config_getlist(&SSBsParamList, NULL, 0, aprefix);
+    if (SSBsParamList.numelt > 0) config_get(SSBsParams,sizeof(SSBsParams)/sizeof(paramdef_t),aprefix);
+
+    config_getlist(&PDSCHANTENNAParamList, NULL, 0, aprefix);
+    if (PDSCHANTENNAParamList.numelt > 0) config_get(PDSCHANTENNAParams,sizeof(PDSCHANTENNAParams)/sizeof(paramdef_t),aprefix);
+
+
+    config_getlist(&SCCsParamList, NULL, 0, aprefix);
+    if (SCCsParamList.numelt > 0) {    
+      sprintf(aprefix, "%s.[%i].%s.[%i]", GNB_CONFIG_STRING_GNB_LIST,0,GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON, 0);
+      config_get( SCCsParams,sizeof(SCCsParams)/sizeof(paramdef_t),aprefix);  
+      LOG_I(RRC,"Read in ServingCellConfigCommon (PhysCellId %d, ABSFREQSSB %d, DLBand %d, ABSFREQPOINTA %d, DLBW %d,RACH_TargetReceivedPower %d\n",
+	    (int)*scc->physCellId,
+	    (int)*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB,
+	    (int)*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0],
+	    (int)scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA,
+	    (int)scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,
+	    (int)scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleReceivedTargetPower);
+      fix_scc(scc,ssb_bitmap);
+    }
+    printf("NRRRC %d: Southbound Transport %s\n",i,*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr));
     if (strcmp(*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr), "local_mac") == 0) {
-  
+      
     } else if (strcmp(*(GNBParamList.paramarray[i][GNB_TRANSPORT_S_PREFERENCE_IDX].strptr), "cudu") == 0) {
       rrc->eth_params_s.local_if_name            = strdup(*(GNBParamList.paramarray[i][GNB_LOCAL_S_IF_NAME_IDX].strptr));
       rrc->eth_params_s.my_addr                  = strdup(*(GNBParamList.paramarray[i][GNB_LOCAL_S_ADDRESS_IDX].strptr));
@@ -690,16 +613,18 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
       rrc->eth_params_s.transp_preference        = ETH_UDP_MODE;
     } else { // other midhaul
     }       
-
+    
     // search if in active list
-
+    
     for (k=0; k <num_gnbs ; k++) {
       if (strcmp(GNBSParams[GNB_ACTIVE_GNBS_IDX].strlistptr[k], *(GNBParamList.paramarray[i][GNB_GNB_NAME_IDX].strptr) )== 0) {
-        
+	
         char gnbpath[MAX_OPTNAME_SIZE + 8];
         sprintf(gnbpath,"%s.[%i]",GNB_CONFIG_STRING_GNB_LIST,k);
 
+	
         paramdef_t PLMNParams[] = GNBPLMNPARAMS_DESC;
+
         paramlist_def_t PLMNParamList = {GNB_CONFIG_STRING_PLMN_LIST, NULL, 0};
         /* map parameter checking array instances to parameter definition array instances */
         checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK;
@@ -738,1924 +663,15 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
 	
         // Parse optional physical parameters
         sprintf(gnbpath,"%s.[%i]",GNB_CONFIG_STRING_GNB_LIST,k),
-        config_getlist( &CCsParamList,NULL,0,gnbpath); 
-    
-        LOG_I(NR_RRC,"num component carriers %d \n", num_component_carriers); 
-
-        if ( CCsParamList.numelt> 0) {
-          
-          char ccspath[MAX_OPTNAME_SIZE*2 + 16];
-
-          for (j = 0; j < CCsParamList.numelt ;j++) {
-            
-            sprintf(ccspath,"%s.%s.[%i]",gnbpath,GNB_CONFIG_STRING_COMPONENT_CARRIERS,j);
-            config_get( CCsParams,sizeof(CCsParams)/sizeof(paramdef_t),ccspath);        
- 
-            nb_cc++;
-
-            // NRRRC_CONFIGURATION_REQ (msg_p).tdd_config[j] = tdd_config;
-            // AssertFatal (tdd_config <= TDD_Config__subframeAssignment_sa6,
-            //             "Failed to parse gNB configuration file %s, gnb %d illegal tdd_config %d (should be 0-%d)!",
-            //             RC.config_file_name, i, tdd_config, TDD_Config__subframeAssignment_sa6);
-        
-            // NRRRC_CONFIGURATION_REQ (msg_p).tdd_config_s[j] = tdd_config_s;
-            // AssertFatal (tdd_config_s <= TDD_Config__specialSubframePatterns_ssp8,
-            //             "Failed to parse gNB configuration file %s, gnb %d illegal tdd_config_s %d (should be 0-%d)!",
-            //             RC.config_file_name, i, tdd_config_s, TDD_Config__specialSubframePatterns_ssp8);
-
-            if (!DL_prefix_type){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
-                           RC.config_file_name, i, GNB_CONFIG_STRING_DL_PREFIX_TYPE);
-            }else if (strcmp(DL_prefix_type, "NORMAL") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_prefix_type[j] = NORMAL;
-            }else if (strcmp(DL_prefix_type, "EXTENDED") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_prefix_type[j] = EXTENDED;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_prefix_type choice: NORMAL or EXTENDED !\n",
-                           RC.config_file_name, i, DL_prefix_type);
-            }
-
-            if (!UL_prefix_type){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
-                           RC.config_file_name, i, GNB_CONFIG_STRING_UL_PREFIX_TYPE);
-            }else if (strcmp(UL_prefix_type, "NORMAL") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_prefix_type[j] = NORMAL;
-            }else if (strcmp(UL_prefix_type, "EXTENDED") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_prefix_type[j] = EXTENDED;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_prefix_type choice: NORMAL or EXTENDED !\n",
-                           RC.config_file_name, i, UL_prefix_type);
-            }            
-
-            NRRRC_CONFIGURATION_REQ (msg_p).nr_band[j] = nr_band;
-            NRRRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint64_t) downlink_frequency;
-            NRRRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) uplink_frequency_offset;
-            NRRRC_CONFIGURATION_REQ (msg_p).Nid_cell[j]= Nid_cell;
-
-            if (Nid_cell>503) {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n",
-                           RC.config_file_name, i, Nid_cell);
-            }
-        
-            NRRRC_CONFIGURATION_REQ (msg_p).N_RB_DL[j]= N_RB_DL;
-            //if(N_RB_DL == 217)      sf_ahead = 2;
-            //else if(N_RB_DL == 106) sf_ahead = 4;
-            if ((N_RB_DL != 273) && (N_RB_DL != 217) && (N_RB_DL != 106))
-	      AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for N_RB_DL choice: 106, 217 !\n", RC.config_file_name, i, N_RB_DL);
-            
-            /*
-            if ((N_RB_DL!=6) && (N_RB_DL!=15) && (N_RB_DL!=25) && (N_RB_DL!=50) && (N_RB_DL!=75) && (N_RB_DL!=100)) {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n",
-                           RC.config_file_name, i, N_RB_DL);
-            }
-            */
-        
-            if (strcmp(frame_type, "FDD") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).frame_type[j] = FDD;
-            }else  if (strcmp(frame_type, "TDD") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).frame_type[j] = TDD;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
-                           RC.config_file_name, i, frame_type);
-            }
-
-            if (!DL_prefix_type){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
-                           RC.config_file_name, i, GNB_CONFIG_STRING_DL_PREFIX_TYPE);
-            }else if (strcmp(DL_prefix_type, "NORMAL") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_prefix_type[j] = NORMAL;
-            }else  if (strcmp(DL_prefix_type, "EXTENDED") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_prefix_type[j] = EXTENDED;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_prefix_type choice: NORMAL or EXTENDED !\n",
-                           RC.config_file_name, i, DL_prefix_type);
-            }
-
-            if (!UL_prefix_type){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
-                           RC.config_file_name, i, GNB_CONFIG_STRING_UL_PREFIX_TYPE);
-            }else if (strcmp(UL_prefix_type, "NORMAL") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_prefix_type[j] = NORMAL;
-            }else  if (strcmp(UL_prefix_type, "EXTENDED") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_prefix_type[j] = EXTENDED;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_prefix_type choice: NORMAL or EXTENDED !\n",
-                           RC.config_file_name, i, UL_prefix_type);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).nr_band[j] = nr_band;
-            NRRRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint64_t) downlink_frequency;
-            NRRRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) uplink_frequency_offset;
-        
-            if (config_check_band_frequencies(j,
-              NRRRC_CONFIGURATION_REQ (msg_p).nr_band[j],
-              NRRRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j],
-              NRRRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j],
-              NRRRC_CONFIGURATION_REQ (msg_p).frame_type[j])) {
-               AssertFatal(0, "error calling enb_check_band_frequencies\n");
-            }
-
-            if ((nb_antenna_ports <1) || (nb_antenna_ports > 2)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, enb %d unknown value \"%d\" for nb_antenna_ports choice: 1..2 !\n",
-                           RC.config_file_name, i, nb_antenna_ports);
-            }
-            NRRRC_CONFIGURATION_REQ (msg_p).nb_antenna_ports[j] = nb_antenna_ports;
-
-
-            ////////////////////////////////////////////////////////////////////////////////
-            //---------------------------NR--------Configuration--------------------------//
-            ////////////////////////////////////////////////////////////////////////////////
-            /////////////////////////////////MIB///////////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).MIB_subCarrierSpacingCommon[j] = MIB_subCarrierSpacingCommon;
-            if ((MIB_subCarrierSpacingCommon !=15) && (MIB_subCarrierSpacingCommon !=30) && (MIB_subCarrierSpacingCommon !=60) && (MIB_subCarrierSpacingCommon !=120)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for MIB_subCarrierSpacingCommon choice: 15,30,60,120 !\n",
-                           RC.config_file_name, i, MIB_subCarrierSpacingCommon);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).MIB_ssb_SubcarrierOffset[j] = MIB_ssb_SubcarrierOffset;
-            if ((MIB_ssb_SubcarrierOffset <0) || (MIB_ssb_SubcarrierOffset > 15)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for MIB_ssb_SubcarrierOffset choice: 1..23 !\n",
-                           RC.config_file_name, i, MIB_ssb_SubcarrierOffset);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).MIB_dmrs_TypeA_Position[j] = MIB_dmrs_TypeA_Position;
-            if ((MIB_dmrs_TypeA_Position !=2) && (MIB_dmrs_TypeA_Position !=3)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for MIB_dmrs_TypeA_Position choice:2,3 !\n",
-                           RC.config_file_name, i, MIB_dmrs_TypeA_Position);
-            }          
-
-            NRRRC_CONFIGURATION_REQ (msg_p).pdcch_ConfigSIB1[j] = pdcch_ConfigSIB1;
-            if ((pdcch_ConfigSIB1 <0) || (pdcch_ConfigSIB1 > 255)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for pdcch_ConfigSIB1 choice: 0..3279165 !\n",
-                           RC.config_file_name, i, pdcch_ConfigSIB1);
-            }
-            
-            ////////////////////////////////SIB1//////////////////////////////
-
-            if (strcmp(SIB1_frequencyOffsetSSB , "khz-5") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).SIB1_frequencyOffsetSSB[j] = -5;                    
-            }else if (strcmp(SIB1_frequencyOffsetSSB , "khz5") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).SIB1_frequencyOffsetSSB[j] = 5;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for SIB1_frequencyOffsetSSB !\n",
-                           RC.config_file_name, i, SIB1_frequencyOffsetSSB);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).SIB1_ssb_PeriodicityServingCell[j] = SIB1_ssb_PeriodicityServingCell;
-            if ((SIB1_ssb_PeriodicityServingCell !=5)  && 
-                (SIB1_ssb_PeriodicityServingCell !=10) && 
-                (SIB1_ssb_PeriodicityServingCell !=20) && 
-                (SIB1_ssb_PeriodicityServingCell !=40) &&
-                (SIB1_ssb_PeriodicityServingCell !=80) &&
-                (SIB1_ssb_PeriodicityServingCell !=160)  ){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SIB1_ssb_PeriodicityServingCell choice: 5,10,20,40,80,160 !\n",
-                           RC.config_file_name, i, SIB1_ssb_PeriodicityServingCell);
-            }            
-
-            NRRRC_CONFIGURATION_REQ (msg_p).SIB1_ss_PBCH_BlockPower[j] = SIB1_ss_PBCH_BlockPower;
-            if ((SIB1_ss_PBCH_BlockPower < -60) || (SIB1_ss_PBCH_BlockPower > 50)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SIB1_ss_PBCH_BlockPower choice: -60..50 !\n",
-              RC.config_file_name, i, SIB1_ss_PBCH_BlockPower);
-            }
-
-            ////////////////////////////////NR FrequencyInfoDL//////////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).absoluteFrequencySSB[j] = absoluteFrequencySSB;
-            if ((absoluteFrequencySSB <0) || (absoluteFrequencySSB > 3279165)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for absoluteFrequencySSB choice: 0..3279165 !\n",
-                           RC.config_file_name, i, absoluteFrequencySSB);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).DL_FreqBandIndicatorNR[j] = DL_FreqBandIndicatorNR;
-            if ((DL_FreqBandIndicatorNR <1) || (DL_FreqBandIndicatorNR > 1024)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_FreqBandIndicatorNR choice: 1..1024 !\n",
-                           RC.config_file_name, i, DL_FreqBandIndicatorNR);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).DL_absoluteFrequencyPointA[j] = DL_absoluteFrequencyPointA;
-            if ((DL_absoluteFrequencyPointA <0) || (DL_absoluteFrequencyPointA > 3279165)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_absoluteFrequencyPointA choice: 0..3279165 !\n",
-                           RC.config_file_name, i, DL_absoluteFrequencyPointA);
-            }            
-            
-
-            /////////////////////////////////NR DL SCS-SpecificCarrier///////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).DL_offsetToCarrier[j] = DL_offsetToCarrier;
-            if ((DL_offsetToCarrier <0) || (DL_offsetToCarrier > 2199)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_offsetToCarrier choice: 0..11 !\n",
-                           RC.config_file_name, i, DL_offsetToCarrier);
-            }
-
-            if (strcmp(DL_SCS_SubcarrierSpacing,"kHz15")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz15;
-            }else if (strcmp(DL_SCS_SubcarrierSpacing,"kHz30")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz30;
-            }else if (strcmp(DL_SCS_SubcarrierSpacing,"kHz60")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz60;
-            }else if (strcmp(DL_SCS_SubcarrierSpacing,"kHz120")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz120;
-            }else if (strcmp(DL_SCS_SubcarrierSpacing,"kHz240")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz240;
-            }else { 
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_SCS_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
-                           RC.config_file_name, i, DL_SCS_SubcarrierSpacing);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).DL_carrierBandwidth[j] = DL_carrierBandwidth;
-            if ((DL_carrierBandwidth <1) || (DL_carrierBandwidth > 275)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_carrierBandwidth choice: 1..275 !\n",
-              RC.config_file_name, i, DL_carrierBandwidth);
-            }
-
-            /////////////////////////////////NR BWP-DownlinkCommon///////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).DL_locationAndBandwidth[j] = DL_locationAndBandwidth;
-            if ((DL_locationAndBandwidth <0) || (DL_locationAndBandwidth > 37949)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for DL_locationAndBandwidth choice: 0..11 !\n",
-              RC.config_file_name, i, DL_locationAndBandwidth);
-            }
-
-            if (strcmp(DL_BWP_SubcarrierSpacing,"kHz15")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz15;
-            }else if (strcmp(DL_BWP_SubcarrierSpacing,"kHz30")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz30;
-            }else if (strcmp(DL_BWP_SubcarrierSpacing,"kHz60")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz60;
-            }else if (strcmp(DL_BWP_SubcarrierSpacing,"kHz120")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz120;
-            }else if (strcmp(DL_BWP_SubcarrierSpacing,"kHz240")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz240;
-            }else { 
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_BWP_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
-                           RC.config_file_name, i, DL_BWP_SubcarrierSpacing);
-            }
-
-            if (!DL_BWP_prefix_type){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
-                           RC.config_file_name, i, GNB_CONFIG_STRING_DL_PREFIX_TYPE);
-            }else if (strcmp(DL_BWP_prefix_type, "NORMAL") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_prefix_type[j] = NORMAL;
-            }else if (strcmp(DL_BWP_prefix_type, "EXTENDED") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).DL_BWP_prefix_type[j] = EXTENDED;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for DL_BWP_prefix_type choice: NORMAL or EXTENDED !\n",
-                           RC.config_file_name, i, DL_BWP_prefix_type);
-            }                        
-
-            /////////////////////////////////NR FrequencyInfoUL//////////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).UL_FreqBandIndicatorNR[j] = UL_FreqBandIndicatorNR;
-            if ((UL_FreqBandIndicatorNR <1) || (UL_FreqBandIndicatorNR > 1024)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_FreqBandIndicatorNR choice: 1..1024 !\n",
-                           RC.config_file_name, i, UL_FreqBandIndicatorNR);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).UL_absoluteFrequencyPointA[j] = UL_absoluteFrequencyPointA;
-            if ((UL_absoluteFrequencyPointA <0) || (UL_absoluteFrequencyPointA > 3279165)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_absoluteFrequencyPointA choice: 0..3279165 !\n",
-                           RC.config_file_name, i, UL_absoluteFrequencyPointA);
-            }       
-
-            NRRRC_CONFIGURATION_REQ (msg_p).UL_additionalSpectrumEmission[j] = UL_additionalSpectrumEmission;
-            if ((UL_additionalSpectrumEmission <0) || (UL_additionalSpectrumEmission > 7)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_additionalSpectrumEmission choice: 0..7 !\n",
-                           RC.config_file_name, i, UL_additionalSpectrumEmission);
-            }            
-
-            NRRRC_CONFIGURATION_REQ (msg_p).UL_p_Max[j] = UL_p_Max;
-            if ((UL_p_Max <-30) || (UL_p_Max > 33)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_p_Max choice: -30..33 !\n",
-              RC.config_file_name, i, UL_p_Max);
-            }
-
-            if (strcmp(UL_frequencyShift7p5khz,"TRUE") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_frequencyShift7p5khz[j] = NR_FrequencyInfoUL__frequencyShift7p5khz_true; //enum true = 0
-            }else{
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_frequencyShift7p5khz[j] = 1;//false               
-            } 
-
-            /////////////////////////////////NR UL SCS-SpecificCarrier///////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).UL_offsetToCarrier[j] = UL_offsetToCarrier;
-            if ((UL_offsetToCarrier <0) || (UL_offsetToCarrier > 2199)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_offsetToCarrier choice: 0..11 !\n",
-              RC.config_file_name, i, UL_offsetToCarrier);
-            }
-
-            if (strcmp(UL_SCS_SubcarrierSpacing,"kHz15")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz15;
-            }else if (strcmp(UL_SCS_SubcarrierSpacing,"kHz30")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz30;
-            }else if (strcmp(UL_SCS_SubcarrierSpacing,"kHz60")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz60;
-            }else if (strcmp(UL_SCS_SubcarrierSpacing,"kHz120")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz120;
-            }else if (strcmp(UL_SCS_SubcarrierSpacing,"kHz240")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_SCS_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz240;
-            }else { AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_SCS_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
-              RC.config_file_name, i, UL_SCS_SubcarrierSpacing);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).UL_carrierBandwidth[j] = UL_carrierBandwidth;
-            if ((UL_carrierBandwidth <1) || (UL_carrierBandwidth > 275)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_carrierBandwidth choice: 1..275 !\n",
-              RC.config_file_name, i, UL_carrierBandwidth);
-            }
-
-            /////////////////////////////////NR BWP-UplinkCommon///////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).UL_locationAndBandwidth[j] = UL_locationAndBandwidth;
-            if ((UL_locationAndBandwidth <0) || (UL_locationAndBandwidth > 37949)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for UL_locationAndBandwidth choice: 0..11 !\n",
-              RC.config_file_name, i, UL_locationAndBandwidth);
-            }
-
-            if (strcmp(UL_BWP_SubcarrierSpacing,"kHz15")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz15;
-            }else if (strcmp(UL_BWP_SubcarrierSpacing,"kHz30")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz30;
-            }else if (strcmp(UL_BWP_SubcarrierSpacing,"kHz60")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz60;
-            }else if (strcmp(UL_BWP_SubcarrierSpacing,"kHz120")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz120;
-            }else if (strcmp(UL_BWP_SubcarrierSpacing,"kHz240")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz240;
-            }else { 
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_BWP_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
-                           RC.config_file_name, i, UL_BWP_SubcarrierSpacing);
-            }
-
-            if (!UL_BWP_prefix_type){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d define %s: NORMAL,EXTENDED!\n",
-                           RC.config_file_name, i, GNB_CONFIG_STRING_DL_PREFIX_TYPE);
-            }else if (strcmp(UL_BWP_prefix_type, "NORMAL") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_prefix_type[j] = NORMAL;
-            }else if (strcmp(UL_BWP_prefix_type, "EXTENDED") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_BWP_prefix_type[j] = EXTENDED;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_BWP_prefix_type choice: NORMAL or EXTENDED !\n",
-                           RC.config_file_name, i, UL_BWP_prefix_type);
-            }  
-
-            if (strcmp(UL_timeAlignmentTimerCommon,"ms500")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms500;
-            }else if (strcmp(UL_timeAlignmentTimerCommon,"ms750")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms750;
-            }else if (strcmp(UL_timeAlignmentTimerCommon,"ms1280")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms1280;
-            }else if (strcmp(UL_timeAlignmentTimerCommon,"ms1920")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms1920;
-            }else if (strcmp(UL_timeAlignmentTimerCommon,"ms2560")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms2560;
-            }else if (strcmp(UL_timeAlignmentTimerCommon,"ms5120")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms5120;
-            }else if (strcmp(UL_timeAlignmentTimerCommon,"ms10240")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_ms10240;
-            }else if (strcmp(UL_timeAlignmentTimerCommon,"infinity")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).UL_timeAlignmentTimerCommon[j] = NR_TimeAlignmentTimer_infinity;
-            }else { 
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for UL_timeAlignmentTimerCommon choice: ms500,ms750,ms1280,ms1920,ms2560,ms5120,ms10240,infinity!\n",
-                           RC.config_file_name, i, UL_timeAlignmentTimerCommon);
-            }
-
-            if (strcmp(ServingCellConfigCommon_n_TimingAdvanceOffset,"n0")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_n_TimingAdvanceOffset[j] = NR_ServingCellConfigCommon__n_TimingAdvanceOffset_n0;
-            }else if (strcmp(ServingCellConfigCommon_n_TimingAdvanceOffset,"n25600")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_n_TimingAdvanceOffset[j] = NR_ServingCellConfigCommon__n_TimingAdvanceOffset_n25600;
-            }else if (strcmp(ServingCellConfigCommon_n_TimingAdvanceOffset,"n39936")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_n_TimingAdvanceOffset[j] = NR_ServingCellConfigCommon__n_TimingAdvanceOffset_n39936;
-            }else { 
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for ServingCellConfigCommon_n_TimingAdvanceOffset choice n0,n25600,n39936!\n",
-                           RC.config_file_name, i, ServingCellConfigCommon_n_TimingAdvanceOffset);
-            }        
-
-
-	    uint64_t t_freq;
-	    if(nr_band == 41 || (nr_band > 76 && nr_band < 80))
-		t_freq = 2400000000;
-	    else
-		t_freq = 3000000000;
-		
-            if (downlink_frequency<t_freq && (ServingCellConfigCommon_ssb_PositionsInBurst_PR > 15))
-		AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unvalid value \"%ld\" for ssb_PositionsInBurst at DL frequency %ld !\n",
-                           RC.config_file_name, i, ServingCellConfigCommon_ssb_PositionsInBurst_PR, downlink_frequency);
-	    else {
-		if(downlink_frequency<6000000000 && (ServingCellConfigCommon_ssb_PositionsInBurst_PR > 255))
-			AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unvalid value \"%ld\" for ssb_PositionsInBurst at DL frequency %ld !\n",
-                           RC.config_file_name, i, ServingCellConfigCommon_ssb_PositionsInBurst_PR, downlink_frequency);
-		else
-			NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = ServingCellConfigCommon_ssb_PositionsInBurst_PR;
-	    }
-
-            switch (ServingCellConfigCommon_ssb_periodicityServingCell) {
-              case 5:
-                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms5;
-                break;
-
-              case 10:
-                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms10;
-                break;
-
-              case 20:
-                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms20;
-                break;
-              
-              case 40:
-                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms40;
-                break;
-                          
-              case 80:
-                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms80;
-                break;
-
-              case 160:
-                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_periodicityServingCell[j] =  NR_ServingCellConfigCommon__ssb_periodicityServingCell_ms160;
-                break;
-
-               default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ServingCellConfigCommon_ssb_periodicityServingCell choice: -6,0,6 !\n",
-                             RC.config_file_name, i, ServingCellConfigCommon_ssb_periodicityServingCell);
-                break;
-            }
-
-            switch (ServingCellConfigCommon_dmrs_TypeA_Position) {
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_dmrs_TypeA_Position[j] =  NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2;
-                break;
-
-              case 3:
-                NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_dmrs_TypeA_Position[j] =  NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos3;
-                break;
-
-               default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ServingCellConfigCommon_dmrs_TypeA_Position choice: 2,3 !\n",
-                             RC.config_file_name, i, ServingCellConfigCommon_dmrs_TypeA_Position);
-                break;
-            }
-
-            if (strcmp(NIA_SubcarrierSpacing,"kHz15")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).NIA_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz15;
-            }else if (strcmp(NIA_SubcarrierSpacing,"kHz30")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).NIA_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz30;
-            }else if (strcmp(NIA_SubcarrierSpacing,"kHz60")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).NIA_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz60;
-            }else if (strcmp(NIA_SubcarrierSpacing,"kHz120")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).NIA_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz120;
-            }else if (strcmp(NIA_SubcarrierSpacing,"kHz240")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).NIA_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz240;
-            }else { AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for NIA_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
-              RC.config_file_name, i, NIA_SubcarrierSpacing);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ss_PBCH_BlockPower[j] = ServingCellConfigCommon_ss_PBCH_BlockPower;
-            if ((ServingCellConfigCommon_ss_PBCH_BlockPower < -60) || (ServingCellConfigCommon_ss_PBCH_BlockPower > 50)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ServingCellConfigCommon_ss_PBCH_BlockPower choice: 0..11 !\n",
-              RC.config_file_name, i, ServingCellConfigCommon_ss_PBCH_BlockPower);
-            }
-
-            /////////////////////////////////NR TDD-UL-DL-ConfigCommon///////////////////////////
-            if (strcmp(referenceSubcarrierSpacing,"kHz15")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).referenceSubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz15;
-            }else if (strcmp(referenceSubcarrierSpacing,"kHz30")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).referenceSubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz30;
-            }else if (strcmp(referenceSubcarrierSpacing,"kHz60")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).referenceSubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz60;
-            }else if (strcmp(referenceSubcarrierSpacing,"kHz120")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).referenceSubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz120;
-            }else if (strcmp(referenceSubcarrierSpacing,"kHz240")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).referenceSubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz240;
-            }else { 
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for referenceSubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
-                  RC.config_file_name, i, referenceSubcarrierSpacing);
-            }
-
-            if (strcmp(dl_UL_TransmissionPeriodicity,"ms0p5")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms0p5;
-            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms0p625")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms0p625;
-            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms1")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms1;
-            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms1p25")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms1p25;
-            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms2")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2;
-            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms2p5")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2p5;
-            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms5")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5;
-            }else if (strcmp(dl_UL_TransmissionPeriodicity,"ms10")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).dl_UL_TransmissionPeriodicity[j] = NR_TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms10;
-            }else { 
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for dl_UL_TransmissionPeriodicity choice: minusinfinity,ms0p5,ms0p625,ms1,ms1p25,ms2,ms2p5,ms5,ms10 !\n",
-                           RC.config_file_name, i, dl_UL_TransmissionPeriodicity);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).nrofDownlinkSlots[j] = nrofDownlinkSlots;
-            if ((nrofDownlinkSlots < 0) || (nrofDownlinkSlots > 320)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for nrofDownlinkSlots choice: 0..320 !\n",
-                           RC.config_file_name, i, nrofDownlinkSlots);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).nrofDownlinkSymbols[j] = nrofDownlinkSymbols;
-            if ((nrofDownlinkSymbols < 0) || (nrofDownlinkSymbols > 13)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for nrofDownlinkSymbols choice: 0..13 !\n",
-                           RC.config_file_name, i, nrofDownlinkSymbols);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).nrofUplinkSlots[j] = nrofUplinkSlots;
-            if ((nrofUplinkSlots < 0) || (nrofUplinkSlots > 320)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for nrofUplinkSlots choice: 0..320 !\n",
-                           RC.config_file_name, i, nrofUplinkSlots);
-            }
- 
-            NRRRC_CONFIGURATION_REQ (msg_p).nrofUplinkSymbols[j] = nrofUplinkSymbols;
-            if ((nrofUplinkSymbols < 0) || (nrofUplinkSymbols > 13)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for nrofUplinkSymbols choice: 0..13 !\n",
-                           RC.config_file_name, i, nrofUplinkSymbols);
-            }
-
-            /////////////////////////////////NR RACH-ConfigCommon///////////////////////////
-
-            NRRRC_CONFIGURATION_REQ (msg_p).rach_totalNumberOfRA_Preambles[j] = rach_totalNumberOfRA_Preambles;
-            if ((rach_totalNumberOfRA_Preambles <1) || (rach_totalNumberOfRA_Preambles>63)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_numberOfRA_Preambles choice: 1..63 !\n",
-                           RC.config_file_name, i, rach_totalNumberOfRA_Preambles);
-            }
-
-            if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"oneEighth")==0) {
-              
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneEighth;
-              switch (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth){
-                case 4:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n4;
-                  break;
-                case 8:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n8;
-                  break;
-                case 12:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n12;
-                  break;
-                case 16:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n16;
-                  break;
-                case 20:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n20;
-                  break;
-                case 24:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n24;
-                  break;
-                case 28:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n28;
-                  break;
-                case 32:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n32;
-                  break;
-                case 36:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n36;
-                  break;
-                case 40:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n40;
-                  break;
-                case 44:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n44;
-                  break;
-                case 48:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n48;
-                  break;
-                case 52:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n52;
-                  break;
-                case 56:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n56;
-                  break;
-                case 60:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n60;
-                  break;
-                case 64:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneEighth_n64;
-                  break;
-                default:
-                  AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth choice: 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64!\n",
-                               RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth);
-                  break;
-              }//End oneEighth
-
-            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"oneFourth")==0) {
-              
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneFourth;
-              switch (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth){
-                case 4:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n4;
-                  break;
-                case 8:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n8;
-                  break;
-                case 12:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n12;
-                  break;
-                case 16:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n16;
-                  break;
-                case 20:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n20;
-                  break;
-                case 24:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n24;
-                  break;
-                case 28:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n28;
-                  break;
-                case 32:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n32;
-                  break;
-                case 36:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n36;
-                  break;
-                case 40:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n40;
-                  break;
-                case 44:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n44;
-                  break;
-                case 48:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n48;
-                  break;
-                case 52:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n52;
-                  break;
-                case 56:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n56;
-                  break;
-                case 60:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n60;
-                  break;
-                case 64:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneFourth_n64;
-                  break;
-                default:
-                  AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth choice: 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64!\n",
-                               RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth);
-                  break;
-              }//End oneFourth
-
-            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"oneHalf")==0) {
-              
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneHalf;
-              switch (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf){
-                case 4:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n4;
-                  break;
-                case 8:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n8;
-                  break;
-                case 12:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n12;
-                  break;
-                case 16:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n16;
-                  break;
-                case 20:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n20;
-                  break;
-                case 24:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n24;
-                  break;
-                case 28:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n28;
-                  break;
-                case 32:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n32;
-                  break;
-                case 36:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n36;
-                  break;
-                case 40:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n40;
-                  break;
-                case 44:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n44;
-                  break;
-                case 48:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n48;
-                  break;
-                case 52:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n52;
-                  break;
-                case 56:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n56;
-                  break;
-                case 60:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n60;
-                  break;
-                case 64:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__oneHalf_n64;
-                  break;
-                default:
-                  AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf choice: 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64!\n",
-                               RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf);
-                  break;
-              }//End oneHalf
-
-            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"one")==0) {
-              
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
-              switch (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one){
-                case 4:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n4;
-                  break;
-                case 8:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n8;
-                  break;
-                case 12:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n12;
-                  break;
-                case 16:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n16;
-                  break;
-                case 20:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n20;
-                  break;
-                case 24:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n24;
-                  break;
-                case 28:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n28;
-                  break;
-                case 32:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n32;
-                  break;
-                case 36:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n36;
-                  break;
-                case 40:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n40;
-                  break;
-                case 44:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n44;
-                  break;
-                case 48:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n48;
-                  break;
-                case 52:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n52;
-                  break;
-                case 56:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n56;
-                  break;
-                case 60:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n60;
-                  break;
-                case 64:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__one_n64;
-                  break;
-                default:
-                  AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one choice: 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64!\n",
-                               RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one);
-                  break;
-              }//End one
-
-            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"two")==0) {
-              
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_two;
-              switch (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one){
-                case 4:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n4;
-                  break;
-                case 8:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n8;
-                  break;
-                case 12:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n12;
-                  break;
-                case 16:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n16;
-                  break;
-                case 20:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n20;
-                  break;
-                case 24:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n24;
-                  break;
-                case 28:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n28;
-                  break;
-                case 32:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB__two_n32;
-                  break;
-                default:
-                  AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two choice: 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64!\n",
-                               RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two);
-                  break;
-              }//End two
-
-            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"four")==0) {
-              
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_four;
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four[j] = rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four;
-              if ((rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four < 1) || (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four > 16)){
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four choice: 1..16 !\n",
-                             RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four);
-              }//End four
-
-            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"eight")==0) {
-              
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_eight;
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight[j] = rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight;
-              if ((rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight < 1) || (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight > 8)){
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight choice: 1..8 !\n",
-                             RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight);
-              }//End eight 
-
-            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"sixteen")==0) {
-              
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_sixteen;    
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen[j] = rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen;
-              if ((rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen < 1) || (rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen > 4)){
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen choice: 1..4 !\n",
-                             RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen);
-              }//End sixteen
-
-            }else if (strcmp(rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,"NOTHING")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[j] = NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_NOTHING;    
-            }else { 
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice: oneEighth,oneFourth,oneHalf,one,two,four,eight,sixteen !\n",
-                           RC.config_file_name, i, rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice);
-            }
-
-            if (strcmp(rach_groupBconfigured , "ENABLE") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_groupBconfigured [j] = TRUE;
-
-              switch (rach_ra_Msg3SizeGroupA) {
-                case 56:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = NR_RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b56;
-                  break;
-                case 144:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = NR_RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b144;
-                  break;
-                case 208:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = NR_RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b208;
-                  break;
-                case 256:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = NR_RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b256;
-                  break;
-                case 282:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = NR_RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b282;
-                  break;
-                case 480:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = NR_RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b480;
-                  break;
-                case 640:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = NR_RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b640;
-                  break;
-                case 800:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = NR_RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b800;
-                  break;
-                case 1000:
-                  NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_Msg3SizeGroupA[j] = NR_RACH_ConfigCommon__groupBconfigured__ra_Msg3SizeGroupA_b1000;
-                  break;
-                default:
-                  AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ra_Msg3SizeGroupA choice: 56,144,208,256,282,480,640,800,1000!\n",
-                               RC.config_file_name, i, rach_ra_Msg3SizeGroupA);
-                  break;
-              }// End switch (rach_ra_Msg3SizeGroupA)
-
-              if (strcmp(rach_messagePowerOffsetGroupB,"minusinfinity")==0) {
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = NR_RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_minusinfinity;
-              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB0")==0) {
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = NR_RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB0;
-              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB5")==0) {
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = NR_RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB5;
-              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB8")==0) {
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = NR_RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB8;
-              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB10")==0) {
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = NR_RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB10;
-              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB12")==0) {
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = NR_RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB12;
-              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB15")==0) {
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = NR_RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB15;
-              }else if (strcmp(rach_messagePowerOffsetGroupB,"dB18")==0) {
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_messagePowerOffsetGroupB[j] = NR_RACH_ConfigCommon__groupBconfigured__messagePowerOffsetGroupB_dB18;
-              }else{
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for rach_messagePowerOffsetGroupB choice: minusinfinity,dB0,dB5,dB8,dB10,dB12,dB15,dB18!\n",
-                             RC.config_file_name, i, rach_messagePowerOffsetGroupB);
-              }// End if (strcmp(rach_messagePowerOffsetGroupB,"minusinfinity")==0)
-
-              NRRRC_CONFIGURATION_REQ (msg_p).rach_numberOfRA_PreamblesGroupA[j] = rach_numberOfRA_PreamblesGroupA;
-              if ((rach_numberOfRA_PreamblesGroupA <1) || (rach_numberOfRA_PreamblesGroupA>64)){
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_numberOfRA_PreamblesGroupA choice: 1..63 !\n",
-                             RC.config_file_name, i, rach_numberOfRA_PreamblesGroupA);
-              }
-
-            }// End if (strcmp(rach_groupBconfigured , "ENABLE") == 0) 
-
-            switch (rach_ra_ContentionResolutionTimer) {
-              case 8:
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = NR_RACH_ConfigCommon__ra_ContentionResolutionTimer_sf8;
-                break;
-              case 16:
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = NR_RACH_ConfigCommon__ra_ContentionResolutionTimer_sf16;
-                break;
-              case 24:
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = NR_RACH_ConfigCommon__ra_ContentionResolutionTimer_sf24;
-                break;
-              case 32:
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = NR_RACH_ConfigCommon__ra_ContentionResolutionTimer_sf32;
-                break;
-              case 40:
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = NR_RACH_ConfigCommon__ra_ContentionResolutionTimer_sf40;
-                break;
-              case 48:
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = NR_RACH_ConfigCommon__ra_ContentionResolutionTimer_sf48;
-                break;
-              case 56:
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = NR_RACH_ConfigCommon__ra_ContentionResolutionTimer_sf56;
-                break;
-              case 64:
-                NRRRC_CONFIGURATION_REQ (msg_p).rach_ra_ContentionResolutionTimer[j] = NR_RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rach_ra_ContentionResolutionTimer choice: 8,16,24,32,40,48,56,64!\n",
-                             RC.config_file_name, i, rach_ra_ContentionResolutionTimer);
-                break;
-            }// End switch (rach_ra_ContentionResolutionTimer)
-
-            
-            NRRRC_CONFIGURATION_REQ (msg_p).rsrp_ThresholdSSB[j] = rsrp_ThresholdSSB;
-            if ((rsrp_ThresholdSSB <0) || (rsrp_ThresholdSSB>124)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rsrp_ThresholdSSB choice: 0..124 !\n",
-                           RC.config_file_name, i, rsrp_ThresholdSSB);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).rsrp_ThresholdSSB_SUL[j] = rsrp_ThresholdSSB_SUL;
-            if ((rsrp_ThresholdSSB_SUL <0) || (rsrp_ThresholdSSB_SUL>124)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rsrp_ThresholdSSB_SUL choice: 0..124 !\n",
-                           RC.config_file_name, i, rsrp_ThresholdSSB_SUL);
-            }
-
-            if (strcmp(prach_RootSequenceIndex_choice , "l839") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_RootSequenceIndex_choice[j] = NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839;
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_RootSequenceIndex_l839[j] = prach_RootSequenceIndex_l839;              
-            }else if (strcmp(prach_RootSequenceIndex_choice , "l139") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_RootSequenceIndex_choice[j] = NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_RootSequenceIndex_l139[j] = prach_RootSequenceIndex_l139;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for prach_RootSequenceIndex_choice !\n",
-                           RC.config_file_name, i, prach_RootSequenceIndex_choice);
-            }
-
-            if (strcmp(prach_msg1_SubcarrierSpacing,"kHz15")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz15;
-            }else if (strcmp(prach_msg1_SubcarrierSpacing,"kHz30")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz30;
-            }else if (strcmp(prach_msg1_SubcarrierSpacing,"kHz60")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz60;
-            }else if (strcmp(prach_msg1_SubcarrierSpacing,"kHz120")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz120;
-            }else if (strcmp(prach_msg1_SubcarrierSpacing,"kHz240")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_SubcarrierSpacing[j] = NR_SubcarrierSpacing_kHz240;
-            }else { 
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for prach_msg1_SubcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
-                           RC.config_file_name, i, prach_msg1_SubcarrierSpacing);
-            }
-
-            if (strcmp(restrictedSetConfig , "unrestrictedSet") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).restrictedSetConfig[j] = NR_RACH_ConfigCommon__restrictedSetConfig_unrestrictedSet;                    
-            }else if (strcmp(restrictedSetConfig , "restrictedSetTypeA") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).restrictedSetConfig[j] = NR_RACH_ConfigCommon__restrictedSetConfig_restrictedSetTypeA;
-            }else if (strcmp(restrictedSetConfig , "restrictedSetTypeB") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).restrictedSetConfig[j] = NR_RACH_ConfigCommon__restrictedSetConfig_restrictedSetTypeB;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for restrictedSetConfig !\n",
-                           RC.config_file_name, i, restrictedSetConfig);
-            }
-
-            if (strcmp(msg3_transformPrecoding , "ENABLE") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).msg3_transformPrecoding[j] = TRUE;
-            }
-
-            ////////////////////////////////NR RACH-ConfigGeneric//////////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).prach_ConfigurationIndex[j] = prach_ConfigurationIndex;
-            if ((prach_ConfigurationIndex <0) || (prach_ConfigurationIndex>255)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for prach_ConfigurationIndex choice: 0..255 !\n",
-                           RC.config_file_name, i, prach_ConfigurationIndex);
-            }
-
-            if (strcmp(prach_msg1_FDM , "one") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_FDM[j] = NR_RACH_ConfigGeneric__msg1_FDM_one;                    
-            }else if (strcmp(prach_msg1_FDM , "two") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_FDM[j] = NR_RACH_ConfigGeneric__msg1_FDM_two;
-            }else if (strcmp(prach_msg1_FDM , "four") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_FDM[j] = NR_RACH_ConfigGeneric__msg1_FDM_four;
-            }else if (strcmp(prach_msg1_FDM , "eight") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_FDM[j] = NR_RACH_ConfigGeneric__msg1_FDM_eight;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for prach_msg1_FDM !\n",
-                           RC.config_file_name, i, prach_msg1_FDM);
-            }            
-            
-            NRRRC_CONFIGURATION_REQ (msg_p).prach_msg1_FrequencyStart[j] = prach_msg1_FrequencyStart;
-            if ((prach_msg1_FrequencyStart <0) || (prach_msg1_FrequencyStart>274)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for prach_msg1_FrequencyStart choice: 0..274 !\n",
-                           RC.config_file_name, i, prach_msg1_FrequencyStart);
-            }           
-
-            NRRRC_CONFIGURATION_REQ (msg_p).zeroCorrelationZoneConfig[j] = zeroCorrelationZoneConfig;
-            if ((zeroCorrelationZoneConfig <0) || (zeroCorrelationZoneConfig>15)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for zeroCorrelationZoneConfig choice: 0..15 !\n",
-                           RC.config_file_name, i, zeroCorrelationZoneConfig);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).preambleReceivedTargetPower[j] = preambleReceivedTargetPower;
-            if ((preambleReceivedTargetPower <-200) || (preambleReceivedTargetPower>-74)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for preambleReceivedTargetPower choice: -200..-74 !\n",
-                           RC.config_file_name, i, preambleReceivedTargetPower);
-            }
-
-            switch (preambleTransMax) {
-              case 3:
-                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  NR_RACH_ConfigGeneric__preambleTransMax_n3;
-                break;
-              case 4:
-                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  NR_RACH_ConfigGeneric__preambleTransMax_n4;
-                break;
-              case 5:
-                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  NR_RACH_ConfigGeneric__preambleTransMax_n5;
-                break;
-              case 6:
-                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  NR_RACH_ConfigGeneric__preambleTransMax_n6;
-                break;
-              case 7:
-                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  NR_RACH_ConfigGeneric__preambleTransMax_n7;
-                break;
-              case 8:
-                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  NR_RACH_ConfigGeneric__preambleTransMax_n8;
-                break;
-              case 10:
-                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  NR_RACH_ConfigGeneric__preambleTransMax_n10;
-                break;
-              case 20:
-                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  NR_RACH_ConfigGeneric__preambleTransMax_n20;
-                break;
-              case 50:
-                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  NR_RACH_ConfigGeneric__preambleTransMax_n50;
-                break;
-              case 100:
-                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  NR_RACH_ConfigGeneric__preambleTransMax_n100;
-                break;
-              case 200:
-                NRRRC_CONFIGURATION_REQ (msg_p).preambleTransMax[j] =  NR_RACH_ConfigGeneric__preambleTransMax_n200;
-                break;
-               default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for preambleTransMax choice: 3,4,5,6,7,8,10,20,50,100,200 !\n",
-                             RC.config_file_name, i, preambleTransMax);
-                break;
-            }            
-
-            if (strcmp(powerRampingStep , "dB0") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).powerRampingStep[j] = NR_RACH_ConfigGeneric__powerRampingStep_dB0;                    
-            }else if (strcmp(powerRampingStep , "dB2") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).powerRampingStep[j] = NR_RACH_ConfigGeneric__powerRampingStep_dB2;
-            }else if (strcmp(powerRampingStep , "dB4") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).powerRampingStep[j] = NR_RACH_ConfigGeneric__powerRampingStep_dB4;
-            }else if (strcmp(powerRampingStep , "dB6") == 0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).powerRampingStep[j] = NR_RACH_ConfigGeneric__powerRampingStep_dB6;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for powerRampingStep !\n",
-                           RC.config_file_name, i, powerRampingStep);
-            }
-
-            switch (ra_ResponseWindow) {
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  NR_RACH_ConfigGeneric__ra_ResponseWindow_sl1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  NR_RACH_ConfigGeneric__ra_ResponseWindow_sl2;
-                break;
-              case 4:
-                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  NR_RACH_ConfigGeneric__ra_ResponseWindow_sl4;
-                break;
-              case 8:
-                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  NR_RACH_ConfigGeneric__ra_ResponseWindow_sl8;
-                break;
-              case 10:
-                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  NR_RACH_ConfigGeneric__ra_ResponseWindow_sl10;
-                break;
-              case 20:
-                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  NR_RACH_ConfigGeneric__ra_ResponseWindow_sl20;
-                break;
-              case 40:
-                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  NR_RACH_ConfigGeneric__ra_ResponseWindow_sl40;
-                break;
-              case 80:
-                NRRRC_CONFIGURATION_REQ (msg_p).ra_ResponseWindow[j] =  NR_RACH_ConfigGeneric__ra_ResponseWindow_sl80;
-                break;
-               default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ra_ResponseWindow choice: 1,2,4,8,10,20,40,80 !\n",
-                             RC.config_file_name, i, ra_ResponseWindow);
-                break;
-            }  
-
-            /////////////////////////////////NR PUSCH-ConfigCommon///////////////////////////
-            if (strcmp(groupHoppingEnabledTransformPrecoding , "ENABLE") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).groupHoppingEnabledTransformPrecoding[j] =  TRUE;
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).msg3_DeltaPreamble[j] = msg3_DeltaPreamble;
-            if ((msg3_DeltaPreamble <-1) || (msg3_DeltaPreamble>6)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for msg3_DeltaPreamble choice: -1..6 !\n",
-                           RC.config_file_name, i, msg3_DeltaPreamble);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).p0_NominalWithGrant[j] = p0_NominalWithGrant;
-            if ((p0_NominalWithGrant <-202) || (p0_NominalWithGrant>24)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for p0_NominalWithGrant choice: -202..24 !\n",
-                           RC.config_file_name, i, p0_NominalWithGrant);
-            }
-
-            /////////////////////////////////NR PUSCH-TimeDomainResourceAllocation///////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).PUSCH_TimeDomainResourceAllocation_k2[j] = PUSCH_TimeDomainResourceAllocation_k2;
-            if ((PUSCH_TimeDomainResourceAllocation_k2 <0) || (PUSCH_TimeDomainResourceAllocation_k2>32)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PUSCH_TimeDomainResourceAllocation_k2 choice: 0..7 !\n",
-                           RC.config_file_name, i, PUSCH_TimeDomainResourceAllocation_k2);
-            }
-
-            if (strcmp(PUSCH_TimeDomainResourceAllocation_mappingType , "typeA") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).PUSCH_TimeDomainResourceAllocation_mappingType[j] =  NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
-            }else if (strcmp(PUSCH_TimeDomainResourceAllocation_mappingType , "typeB") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).PUSCH_TimeDomainResourceAllocation_mappingType[j] =  NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeB;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for PUSCH_TimeDomainResourceAllocation_mappingType !\n",
-                           RC.config_file_name, i, PUSCH_TimeDomainResourceAllocation_mappingType);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).PUSCH_TimeDomainResourceAllocation_startSymbolAndLength[j] = PUSCH_TimeDomainResourceAllocation_startSymbolAndLength;
-            if ((PUSCH_TimeDomainResourceAllocation_startSymbolAndLength <0) || (PUSCH_TimeDomainResourceAllocation_startSymbolAndLength>127)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PUSCH_TimeDomainResourceAllocation_startSymbolAndLength choice: 0..127 !\n",
-                           RC.config_file_name, i, PUSCH_TimeDomainResourceAllocation_startSymbolAndLength);
-            }
-
-            /////////////////////////////////NR PUCCH-ConfigCommon///////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).pucch_ResourceCommon[j] = pucch_ResourceCommon;
-            if ((pucch_ResourceCommon <0) || (pucch_ResourceCommon>15)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for pucch_ResourceCommon choice: 0..15 !\n",
-                           RC.config_file_name, i, pucch_ResourceCommon);
-            }
-
-            if (strcmp(pucch_GroupHopping , "neither") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).pucch_GroupHopping[j] =  NR_PUCCH_ConfigCommon__pucch_GroupHopping_neither;
-            }else if (strcmp(pucch_GroupHopping , "enable") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).pucch_GroupHopping[j] =  NR_PUCCH_ConfigCommon__pucch_GroupHopping_enable;
-            }else if (strcmp(pucch_GroupHopping , "disable") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).pucch_GroupHopping[j] =  NR_PUCCH_ConfigCommon__pucch_GroupHopping_disable;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for pucch_GroupHopping !\n",
-                           RC.config_file_name, i, pucch_GroupHopping);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).hoppingId[j] = hoppingId;
-            if ((hoppingId <0) || (hoppingId>1024)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for hoppingId choice: 0..1024 !\n",
-                           RC.config_file_name, i, hoppingId);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).p0_nominal[j] = p0_nominal;
-            if ((p0_nominal <-202) || (p0_nominal>24)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for p0_nominal choice: -202..24 !\n",
-                           RC.config_file_name, i, p0_nominal);
-            }
-
-            //////////////////////////////////NR PDSCH-TimeDomainResourceAllocation///////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).PDSCH_TimeDomainResourceAllocation_k0[j] = PDSCH_TimeDomainResourceAllocation_k0;
-            if ((PDSCH_TimeDomainResourceAllocation_k0 <1) || (PDSCH_TimeDomainResourceAllocation_k0>3)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDSCH_TimeDomainResourceAllocation_k0 choice: 0..7 !\n",
-                           RC.config_file_name, i, PDSCH_TimeDomainResourceAllocation_k0);
-            }
-
-            if (strcmp(PDSCH_TimeDomainResourceAllocation_mappingType , "typeA") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).PDSCH_TimeDomainResourceAllocation_mappingType[j] =  NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
-            }else if (strcmp(PDSCH_TimeDomainResourceAllocation_mappingType , "typeB") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).PDSCH_TimeDomainResourceAllocation_mappingType[j] =  NR_PDSCH_TimeDomainResourceAllocation__mappingType_typeB;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for PDSCH_TimeDomainResourceAllocation_mappingType !\n",
-                           RC.config_file_name, i, PDSCH_TimeDomainResourceAllocation_mappingType);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).PDSCH_TimeDomainResourceAllocation_startSymbolAndLength[j] = PDSCH_TimeDomainResourceAllocation_startSymbolAndLength;
-            if ((PDSCH_TimeDomainResourceAllocation_startSymbolAndLength <0) || (PDSCH_TimeDomainResourceAllocation_startSymbolAndLength>127)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDSCH_TimeDomainResourceAllocation_startSymbolAndLength choice: 0..127 !\n",
-                           RC.config_file_name, i, PDSCH_TimeDomainResourceAllocation_startSymbolAndLength);
-            }
-
-            //////////////////////////////////NR RateMatchPattern///////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).rateMatchPatternId[j] = rateMatchPatternId;
-            if ((rateMatchPatternId <0) || (rateMatchPatternId>3)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for rateMatchPatternId choice: 0..3 !\n",
-                           RC.config_file_name, i, rateMatchPatternId);
-            }
-
-            if (strcmp(RateMatchPattern_patternType , "NOTHING") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_patternType[j] =  NR_RateMatchPattern__patternType_PR_NOTHING;
-            }else if (strcmp(RateMatchPattern_patternType , "bitmaps") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_patternType[j] =  NR_RateMatchPattern__patternType_PR_bitmaps;
-            }else if (strcmp(RateMatchPattern_patternType , "controlResourceSet") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_patternType[j] =  NR_RateMatchPattern__patternType_PR_controlResourceSet;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for RateMatchPattern_patternType !\n",
-                           RC.config_file_name, i, RateMatchPattern_patternType);
-            }
-
-            if (strcmp(symbolsInResourceBlock , "NOTHING") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).symbolsInResourceBlock[j] =  NR_RateMatchPattern__patternType__bitmaps__symbolsInResourceBlock_PR_NOTHING;
-            }else if (strcmp(symbolsInResourceBlock , "oneSlot") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).symbolsInResourceBlock[j] =  NR_RateMatchPattern__patternType__bitmaps__symbolsInResourceBlock_PR_oneSlot;
-            }else if (strcmp(symbolsInResourceBlock , "twoSlots") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).symbolsInResourceBlock[j] =  NR_RateMatchPattern__patternType__bitmaps__symbolsInResourceBlock_PR_twoSlots;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for symbolsInResourceBlock !\n",
-                           RC.config_file_name, i, symbolsInResourceBlock);
-            }
-
-            switch(periodicityAndPattern){
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n2;
-                break;
-              case 4:
-                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n4;
-                break;
-              case 5:
-                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n5;
-                break;
-              case 8:
-                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n8;
-                break;
-              case 10:
-                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n10;
-                break;
-              case 20:
-                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n20;
-                break;
-              case 40:
-                NRRRC_CONFIGURATION_REQ (msg_p).periodicityAndPattern[j] =  NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n40;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for periodicityAndPattern choice: 2,4,5,8,10,20,40 !\n",
-                             RC.config_file_name, i, periodicityAndPattern);
-                break;
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_controlResourceSet[j] = RateMatchPattern_controlResourceSet;
-            if ((RateMatchPattern_controlResourceSet <0) || (RateMatchPattern_controlResourceSet>11)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPattern_controlResourceSet choice: 0..3 !\n",
-                           RC.config_file_name, i, RateMatchPattern_controlResourceSet);
-            }
-
-            if (strcmp(RateMatchPattern_subcarrierSpacing,"kHz15")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_subcarrierSpacing[j] = NR_SubcarrierSpacing_kHz15;
-            }else if (strcmp(RateMatchPattern_subcarrierSpacing,"kHz30")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_subcarrierSpacing[j] = NR_SubcarrierSpacing_kHz30;
-            }else if (strcmp(RateMatchPattern_subcarrierSpacing,"kHz60")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_subcarrierSpacing[j] = NR_SubcarrierSpacing_kHz60;
-            }else if (strcmp(RateMatchPattern_subcarrierSpacing,"kHz120")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_subcarrierSpacing[j] = NR_SubcarrierSpacing_kHz120;
-            }else if (strcmp(RateMatchPattern_subcarrierSpacing,"kHz240")==0) {
-              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_subcarrierSpacing[j] = NR_SubcarrierSpacing_kHz240;
-            }else { 
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for RateMatchPattern_subcarrierSpacing choice: minusinfinity,kHz15,kHz30,kHz60,kHz120,kHz240!\n",
-                           RC.config_file_name, i, RateMatchPattern_subcarrierSpacing);
-            }            
-            
-            if (strcmp(RateMatchPattern_mode , "dynamic") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_mode[j] =  NR_RateMatchPattern__dummy_dynamic;
-            }else if (strcmp(RateMatchPattern_mode , "semiStatic") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPattern_mode[j] =  NR_RateMatchPattern__dummy_semiStatic;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for RateMatchPattern_mode !\n",
-                           RC.config_file_name, i, RateMatchPattern_mode);
-            }
-
-            //////////////////////////////////NR PDCCH-ConfigCommon///////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).controlResourceSetZero[j] = controlResourceSetZero;
-            if ((controlResourceSetZero <0) || (controlResourceSetZero>15)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for controlResourceSetZero choice: 0..15 !\n",
-                           RC.config_file_name, i, controlResourceSetZero);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).searchSpaceZero[j] = searchSpaceZero;
-            if ((searchSpaceZero <0) || (searchSpaceZero>15)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for searchSpaceZero choice: 0..15 !\n",
-                           RC.config_file_name, i, searchSpaceZero);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).searchSpaceSIB1[j] = searchSpaceSIB1;
-            if ((searchSpaceSIB1 <0) || (searchSpaceSIB1>39)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for searchSpaceSIB1 choice: 0..39 !\n",
-                           RC.config_file_name, i, searchSpaceSIB1);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).searchSpaceOtherSystemInformation[j] = searchSpaceOtherSystemInformation;
-            if ((searchSpaceOtherSystemInformation <0) || (searchSpaceOtherSystemInformation>39)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for searchSpaceOtherSystemInformation choice: 0..39 !\n",
-                           RC.config_file_name, i, searchSpaceOtherSystemInformation);
-            }            
-
-            NRRRC_CONFIGURATION_REQ (msg_p).pagingSearchSpace[j] = pagingSearchSpace;
-            if ((pagingSearchSpace <0) || (pagingSearchSpace>39)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for pagingSearchSpace choice: 0..39 !\n",
-                           RC.config_file_name, i, pagingSearchSpace);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).ra_SearchSpace[j] = ra_SearchSpace;
-            if ((ra_SearchSpace <0) || (ra_SearchSpace>39)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for ra_SearchSpace choice: 0..39 !\n",
-                           RC.config_file_name, i, ra_SearchSpace);
-            }
-
-            //////////////////////////////////NR PDCCH commonControlResourcesSets///////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_common_controlResourceSetId[j] = PDCCH_common_controlResourceSetId;
-            if ((PDCCH_common_controlResourceSetId <0) || (PDCCH_common_controlResourceSetId>11)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_common_controlResourceSetId choice: 0..11 !\n",
-                           RC.config_file_name, i, PDCCH_common_controlResourceSetId);
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_common_ControlResourceSet_duration[j] = PDCCH_common_ControlResourceSet_duration;
-            if ((PDCCH_common_ControlResourceSet_duration <0) || (PDCCH_common_ControlResourceSet_duration>3)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_common_ControlResourceSet_duration choice: 0..11 !\n",
-                           RC.config_file_name, i, PDCCH_common_ControlResourceSet_duration);
-            }            
-            
-            if (strcmp(PDCCH_cce_REG_MappingType , "NOTHING") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_cce_REG_MappingType[j] =  NR_ControlResourceSet__cce_REG_MappingType_PR_NOTHING;
-            }else if (strcmp(PDCCH_cce_REG_MappingType , "interleaved") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_cce_REG_MappingType[j] =  NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved;
-            }else if (strcmp(PDCCH_cce_REG_MappingType , "nonInterleaved") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_cce_REG_MappingType[j] =  NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for PDCCH_cce_REG_MappingType !\n",
-                           RC.config_file_name, i, PDCCH_cce_REG_MappingType);
-            }
-
-            switch(PDCCH_reg_BundleSize){
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_reg_BundleSize[j] =  NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n2;
-                break;
-              case 3:
-                NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_reg_BundleSize[j] =  NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n3;
-                break;
-              case 6:
-                NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_reg_BundleSize[j] =  NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_reg_BundleSize choice: 2,3,6 !\n",
-                             RC.config_file_name, i, PDCCH_reg_BundleSize);
-                break;
-            }            
-
-            switch(PDCCH_interleaverSize){
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_interleaverSize[j] =  NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n2;
-                break;
-              case 3:
-                NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_interleaverSize[j] =  NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n3;
-                break;
-              case 6:
-                NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_interleaverSize[j] =  NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_interleaverSize choice: 2,3,6 !\n",
-                             RC.config_file_name, i, PDCCH_interleaverSize);
-                break;
-            }               
-
-            NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_shiftIndex[j] = PDCCH_shiftIndex;
-            if ((PDCCH_shiftIndex <0) || (PDCCH_shiftIndex>274)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_shiftIndex choice: 0..274 !\n",
-                           RC.config_file_name, i, PDCCH_shiftIndex);
-            }
-
-            if (strcmp(PDCCH_precoderGranularity , "sameAsREG-bundle") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_precoderGranularity[j] =  NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle;
-            }else if (strcmp(PDCCH_precoderGranularity , "allContiguousRBs") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_precoderGranularity[j] =  NR_ControlResourceSet__precoderGranularity_allContiguousRBs;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for PDCCH_precoderGranularity !\n",
-                           RC.config_file_name, i, PDCCH_precoderGranularity);
-            }            
-
-            NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_TCI_StateId[j] = PDCCH_TCI_StateId;
-            if ((PDCCH_TCI_StateId <0) || (PDCCH_TCI_StateId>63)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_TCI_StateId choice: 0..63 !\n",
-                           RC.config_file_name, i, PDCCH_TCI_StateId);
-            }
-
-            if (strcmp(tci_PresentInDCI , "ENABLE") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).tci_PresentInDCI[j] = TRUE;
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).PDCCH_DMRS_ScramblingID[j] = PDCCH_DMRS_ScramblingID;
-            if ((PDCCH_DMRS_ScramblingID <0) || (PDCCH_DMRS_ScramblingID>65535)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for PDCCH_DMRS_ScramblingID choice: 0..65535 !\n",
-                           RC.config_file_name, i, PDCCH_DMRS_ScramblingID);
-            }
-
-            //////////////////////////////////NR PDCCH commonSearchSpaces///////////////////////////
-            NRRRC_CONFIGURATION_REQ (msg_p).SearchSpaceId[j] = SearchSpaceId;
-            if ((SearchSpaceId <0) || (SearchSpaceId>39)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpaceId choice: 0..39 !\n",
-                           RC.config_file_name, i, SearchSpaceId);
-            }            
-
-            NRRRC_CONFIGURATION_REQ (msg_p).commonSearchSpaces_controlResourceSetId[j] = commonSearchSpaces_controlResourceSetId;
-            if ((commonSearchSpaces_controlResourceSetId <0) || (commonSearchSpaces_controlResourceSetId>11)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for commonSearchSpaces_controlResourceSetId choice: 0..11 !\n",
-                           RC.config_file_name, i, commonSearchSpaces_controlResourceSetId);
-            }
-
-            if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl1") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
-              
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_value[j] = 0;                 
-
-            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl2") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2;
-              
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_value[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_value;
-              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_value <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_value>1)){
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_value choice: 0..1 !\n",
-                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_value);
-              }   
-
-            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl4") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4;
-            
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_value[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_value;
-              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_value <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_value>3)){
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_value choice: 0..3 !\n",
-                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_value);
-              }                 
-
-            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl5") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5;
-            
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_value[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_value;
-              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_value <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_value>4)){
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_value choice: 0..4 !\n",
-                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_value);
-              }   
-
-            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl8") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8;
-            
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_value[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_value;
-              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_value <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_value>7)){
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_value choice: 0..7 !\n",
-                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_value);
-              }   
-
-            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl10") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10;
-            
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_value[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_value;
-              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_value <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_value>9)){
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_value choice: 0..9 !\n",
-                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_value);
-              } 
-
-            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl16") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16;
-            
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_value[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_value;
-              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_value <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_value>15)){
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_value choice: 0..15 !\n",
-                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_value);
-              } 
-
-            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl20") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20;
-            
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_value[j] = SearchSpace_monitoringSlotPeriodicityAndOffset_value;
-              if ((SearchSpace_monitoringSlotPeriodicityAndOffset_value <0) || (SearchSpace_monitoringSlotPeriodicityAndOffset_value>19)){
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_monitoringSlotPeriodicityAndOffset_value choice: 0..19 !\n",
-                             RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_value);
-              } 
-
-            }else if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "UNABLE") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_monitoringSlotPeriodicityAndOffset_choice[j] =  NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_NOTHING;
-            
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for SearchSpace_monitoringSlotPeriodicityAndOffset_choice !\n",
-                           RC.config_file_name, i, SearchSpace_monitoringSlotPeriodicityAndOffset_choice);
-            }// End if (strcmp(SearchSpace_monitoringSlotPeriodicityAndOffset_choice , "sl1")
-
-            NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_duration[j] = SearchSpace_duration;
-            if ((SearchSpace_duration <2) || (SearchSpace_duration>2559)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_duration choice: 2..2559 !\n",
-                           RC.config_file_name, i, SearchSpace_duration);
-            }
-
-            switch(SearchSpace_nrofCandidates_aggregationLevel1){
-              case 0:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel1_n0;
-                break;
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel1_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel1_n2;
-                break;
-              case 3:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel1_n3;
-                break;
-              case 4:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel1_n4;
-                break;
-              case 5:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel1_n5;
-                break;
-              case 6:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel1_n6;
-                break;
-              case 8:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel1[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel1_n8;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_nrofCandidates_aggregationLevel1 choice: 0,1,2,3,4,5,6,8 !\n",
-                             RC.config_file_name, i, SearchSpace_nrofCandidates_aggregationLevel1);
-                break;
-            }  
-
-            switch(SearchSpace_nrofCandidates_aggregationLevel2){
-              case 0:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel2_n0;
-                break;
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel2_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel2_n2;
-                break;
-              case 3:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel2_n3;
-                break;
-              case 4:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel2_n4;
-                break;
-              case 5:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel2_n5;
-                break;
-              case 6:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel2_n6;
-                break;
-              case 8:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel2[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel2_n8;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_nrofCandidates_aggregationLevel2 choice: 0,1,2,3,4,5,6,8 !\n",
-                             RC.config_file_name, i, SearchSpace_nrofCandidates_aggregationLevel2);
-                break;
-            }  
-
-            switch(SearchSpace_nrofCandidates_aggregationLevel4){
-              case 0:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel4_n0;
-                break;
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel4_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel4_n2;
-                break;
-              case 3:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel4_n3;
-                break;
-              case 4:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel4_n4;
-                break;
-              case 5:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel4_n5;
-                break;
-              case 6:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel4_n6;
-                break;
-              case 8:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel4[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel4_n8;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_nrofCandidates_aggregationLevel4 choice: 0,1,2,3,4,5,6,8 !\n",
-                             RC.config_file_name, i, SearchSpace_nrofCandidates_aggregationLevel4);
-                break;
-            }
-
-            switch(SearchSpace_nrofCandidates_aggregationLevel8){
-              case 0:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel8_n0;
-                break;
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel8_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel8_n2;
-                break;
-              case 3:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel8_n3;
-                break;
-              case 4:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel8_n4;
-                break;
-              case 5:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel8_n5;
-                break;
-              case 6:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel8_n6;
-                break;
-              case 8:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel8[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel8_n8;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_nrofCandidates_aggregationLevel8 choice: 0,1,2,3,4,5,6,8 !\n",
-                             RC.config_file_name, i, SearchSpace_nrofCandidates_aggregationLevel8);
-                break;
-            }
-
-            switch(SearchSpace_nrofCandidates_aggregationLevel16){
-              case 0:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel16_n0;
-                break;
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel16_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel16_n2;
-                break;
-              case 3:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel16_n3;
-                break;
-              case 4:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel16_n4;
-                break;
-              case 5:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel16_n5;
-                break;
-              case 6:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel16_n6;
-                break;
-              case 8:
-                NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_nrofCandidates_aggregationLevel16[j] =  NR_SearchSpace__nrofCandidates__aggregationLevel16_n8;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for SearchSpace_nrofCandidates_aggregationLevel16 choice: 0,1,2,3,4,5,6,8 !\n",
-                             RC.config_file_name, i, SearchSpace_nrofCandidates_aggregationLevel16);
-                break;
-            }
-
-            if (strcmp(SearchSpace_searchSpaceType , "NOTHING") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_searchSpaceType[j] =  NR_SearchSpace__searchSpaceType_PR_NOTHING;
-            }else if (strcmp(SearchSpace_searchSpaceType , "common") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_searchSpaceType[j] =  NR_SearchSpace__searchSpaceType_PR_common;
-            }else if (strcmp(SearchSpace_searchSpaceType , "ue_Specific") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).SearchSpace_searchSpaceType[j] =  NR_SearchSpace__searchSpaceType_PR_ue_Specific;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for SearchSpace_searchSpaceType !\n",
-                           RC.config_file_name, i, SearchSpace_searchSpaceType);
-            }
-
-            switch(Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1){
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel1_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel1_n2;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1 choice: 1,2 !\n",
-                             RC.config_file_name, i, Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1);
-                break;
-            }
-
-            switch(Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2){
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel2_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel2_n2;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2 choice: 1,2 !\n",
-                             RC.config_file_name, i, Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2);
-                break;
-            }
-
-            switch(Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4){
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel4_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel4_n2;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4 choice: 1,2 !\n",
-                             RC.config_file_name, i, Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4);
-                break;
-            }
-
-            switch(Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8){
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel8_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel8_n2;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8 choice: 1,2 !\n",
-                             RC.config_file_name, i, Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8);
-                break;
-            }
-
-            switch(Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16){
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel16_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_0__nrofCandidates_SFI__aggregationLevel16_n2;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16 choice: 1,2 !\n",
-                             RC.config_file_name, i, Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16);
-                break;
-            }
-
-            switch(Common_dci_Format2_3_monitoringPeriodicity){
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_3__dummy1_sl1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_3__dummy1_sl2;
-                break;
-              case 4:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_3__dummy1_sl4;
-                break;
-              case 5:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_3__dummy1_sl5;
-                break;
-              case 8:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_3__dummy1_sl8;
-                break;
-              case 10:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_3__dummy1_sl10;
-                break;
-              case 16:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_3__dummy1_sl16;
-                break;
-              case 20:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_monitoringPeriodicity[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_3__dummy1_sl20;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_3_dummy1 choice: 1,2,4,5,8,10,16,20 !\n",
-                             RC.config_file_name, i, Common_dci_Format2_3_monitoringPeriodicity);
-                break;
-            }
-
-            switch(Common_dci_Format2_3_nrofPDCCH_Candidates){
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_nrofPDCCH_Candidates[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_3__dummy2_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).Common_dci_Format2_3_nrofPDCCH_Candidates[j] =  NR_SearchSpace__searchSpaceType__common__dci_Format2_3__dummy2_n2;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for Common_dci_Format2_3_nrofPDCCH_Candidates choice: 1,2 !\n",
-                             RC.config_file_name, i, Common_dci_Format2_3_nrofPDCCH_Candidates);
-                break;
-            }
-
-            if (strcmp(ue_Specific__dci_Formats , "formats0-0-And-1-0") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).ue_Specific__dci_Formats[j] =  NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_0_And_1_0;
-            }else if (strcmp(ue_Specific__dci_Formats , "formats0-1-And-1-1") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).ue_Specific__dci_Formats[j] =  NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for ue_Specific__dci_Formats !\n",
-                           RC.config_file_name, i, ue_Specific__dci_Formats);
-            }
-
-            //////////////////////////////////NR RateMatchPatternLTE-CRS///////////////////////////
-
-            NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierFreqDL[j] = RateMatchPatternLTE_CRS_carrierFreqDL;
-            if ((RateMatchPatternLTE_CRS_carrierFreqDL <0) || (RateMatchPatternLTE_CRS_carrierFreqDL>16383)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_carrierFreqDL choice: 0..16383 !\n",
-                           RC.config_file_name, i, RateMatchPatternLTE_CRS_carrierFreqDL);
-            }
-
-
-            switch(RateMatchPatternLTE_CRS_carrierBandwidthDL){
-              case 6:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] =  NR_RateMatchPatternLTE_CRS__carrierBandwidthDL_n6;
-                break;
-              case 15:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] =  NR_RateMatchPatternLTE_CRS__carrierBandwidthDL_n15;
-                break;
-              case 25:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] =  NR_RateMatchPatternLTE_CRS__carrierBandwidthDL_n25;
-                break;
-              case 50:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] =  NR_RateMatchPatternLTE_CRS__carrierBandwidthDL_n50;
-                break;
-              case 75:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] =  NR_RateMatchPatternLTE_CRS__carrierBandwidthDL_n75;
-                break;
-              case 100:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_carrierBandwidthDL[j] =  NR_RateMatchPatternLTE_CRS__carrierBandwidthDL_n100;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_carrierBandwidthDL choice: 6,15,25,50,75,100 !\n",
-                             RC.config_file_name, i, RateMatchPatternLTE_CRS_carrierBandwidthDL);
-                break;
-            }
-
-            switch(RateMatchPatternLTE_CRS_nrofCRS_Ports){
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_nrofCRS_Ports[j] =  NR_RateMatchPatternLTE_CRS__nrofCRS_Ports_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_nrofCRS_Ports[j] =  NR_RateMatchPatternLTE_CRS__nrofCRS_Ports_n2;
-                break;
-              case 4:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_nrofCRS_Ports[j] =  NR_RateMatchPatternLTE_CRS__nrofCRS_Ports_n4;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_nrofCRS_Ports choice: 1,2,4 !\n",
-                             RC.config_file_name, i, RateMatchPatternLTE_CRS_nrofCRS_Ports);
-                break;
-            }
-
-            switch(RateMatchPatternLTE_CRS_v_Shift){
-              case 0:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_v_Shift[j] =  NR_RateMatchPatternLTE_CRS__v_Shift_n0;
-                break;
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_v_Shift[j] =  NR_RateMatchPatternLTE_CRS__v_Shift_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_v_Shift[j] =  NR_RateMatchPatternLTE_CRS__v_Shift_n2;
-                break;
-              case 3:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_v_Shift[j] =  NR_RateMatchPatternLTE_CRS__v_Shift_n3;
-                break;
-              case 4:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_v_Shift[j] =  NR_RateMatchPatternLTE_CRS__v_Shift_n4;
-                break;
-              case 5:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_v_Shift[j] =  NR_RateMatchPatternLTE_CRS__v_Shift_n5;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_v_Shift choice: 0,1,2,3,4,5 !\n",
-                             RC.config_file_name, i, RateMatchPatternLTE_CRS_v_Shift);
-                break;
-            }
-
-            switch(RateMatchPatternLTE_CRS_radioframeAllocationPeriod){
-              case 1:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationPeriod[j] =  NR_EUTRA_MBSFN_SubframeConfig__radioframeAllocationPeriod_n1;
-                break;
-              case 2:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationPeriod[j] =  NR_EUTRA_MBSFN_SubframeConfig__radioframeAllocationPeriod_n2;
-                break;
-              case 4:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationPeriod[j] =  NR_EUTRA_MBSFN_SubframeConfig__radioframeAllocationPeriod_n4;
-                break;
-              case 8:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationPeriod[j] =  NR_EUTRA_MBSFN_SubframeConfig__radioframeAllocationPeriod_n8;
-                break;
-              case 16:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationPeriod[j] =  NR_EUTRA_MBSFN_SubframeConfig__radioframeAllocationPeriod_n16;
-                break;
-              case 32:
-                NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationPeriod[j] =  NR_EUTRA_MBSFN_SubframeConfig__radioframeAllocationPeriod_n32;
-                break;
-              default:
-                AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_radioframeAllocationPeriod choice: 1,2,4,8,16,32 !\n",
-                             RC.config_file_name, i, RateMatchPatternLTE_CRS_radioframeAllocationPeriod);
-                break;
-            }
-
-            NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_radioframeAllocationOffset[j] = RateMatchPatternLTE_CRS_radioframeAllocationOffset;
-            if ((RateMatchPatternLTE_CRS_radioframeAllocationOffset <0) || (RateMatchPatternLTE_CRS_radioframeAllocationOffset>7)){
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%d\" for RateMatchPatternLTE_CRS_radioframeAllocationOffset choice: 0..7 !\n",
-                           RC.config_file_name, i, RateMatchPatternLTE_CRS_radioframeAllocationOffset);
-            }
-
-            if (strcmp(RateMatchPatternLTE_CRS_subframeAllocation_choice , "oneFrame") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_subframeAllocation_choice[j] =  NR_EUTRA_MBSFN_SubframeConfig__subframeAllocation1_PR_oneFrame;
-            }else if (strcmp(RateMatchPatternLTE_CRS_subframeAllocation_choice , "fourFrames") == 0){
-              NRRRC_CONFIGURATION_REQ (msg_p).RateMatchPatternLTE_CRS_subframeAllocation_choice[j] =  NR_EUTRA_MBSFN_SubframeConfig__subframeAllocation1_PR_fourFrames;
-            }else {
-              AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for RateMatchPatternLTE_CRS_subframeAllocation_choice !\n",
-                           RC.config_file_name, i, RateMatchPatternLTE_CRS_subframeAllocation_choice);
-            }
-
-
-          }//End for (j = 0; j < CCsParamList.numelt ;j++)
-
-        }//End if ( CCsParamList.numelt> 0) 
-
-      }//End for (k=0; k <num_gnbs ; k++)
 
+        printf("SSB SCO %d\n",ssb_SubcarrierOffset);
+	NRRRC_CONFIGURATION_REQ (msg_p).ssb_SubcarrierOffset = ssb_SubcarrierOffset;
+        printf("pdsch_AntennaPorts %d\n",pdsch_AntennaPorts);
+	NRRRC_CONFIGURATION_REQ (msg_p).pdsch_AntennaPorts = pdsch_AntennaPorts;
+	NRRRC_CONFIGURATION_REQ (msg_p).scc = scc;	   
+	  
+      }//
     }//End for (k=0; k <num_gnbs ; k++)
-
-
   }//End if (num_gnbs>0)
 
 
@@ -2961,12 +977,9 @@ void NRRCConfig(void) {
   paramlist_def_t L1ParamList     = {CONFIG_STRING_L1_LIST,NULL,0};
   paramlist_def_t RUParamList     = {CONFIG_STRING_RU_LIST,NULL,0};
   paramdef_t GNBSParams[]         = GNBSPARAMS_DESC;
-  paramlist_def_t CCsParamList    = {GNB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0};
   
   char aprefix[MAX_OPTNAME_SIZE*2 + 8];  
   
-
-
 /* get global parameters, defined outside any section in the config file */
  
   LOG_I(GNB_APP, "Getting GNBSParams\n");
@@ -2974,28 +987,204 @@ void NRRCConfig(void) {
   config_get( GNBSParams,sizeof(GNBSParams)/sizeof(paramdef_t),NULL); 
   RC.nb_nr_inst = GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt;
  
-  if (RC.nb_nr_inst > 0) {
-    RC.nb_nr_CC = (int *)malloc((1+RC.nb_nr_inst)*sizeof(int));
-    for (int i=0;i<RC.nb_nr_inst;i++) {
-      sprintf(aprefix,"%s.[%i]",GNB_CONFIG_STRING_GNB_LIST,i);
-      config_getlist( &CCsParamList,NULL,0, aprefix);
-      RC.nb_nr_CC[i]   = CCsParamList.numelt;
-    }
-  }
-
 
 	// Get num MACRLC instances
-    config_getlist( &MACRLCParamList,NULL,0, NULL);
-    RC.nb_macrlc_inst  = MACRLCParamList.numelt;
-    // Get num L1 instances
-    config_getlist( &L1ParamList,NULL,0, NULL);
-    RC.nb_nr_L1_inst = L1ParamList.numelt;
-
-    // Get num RU instances
-    config_getlist( &RUParamList,NULL,0, NULL);  
-    RC.nb_RU     = RUParamList.numelt; 
- 
-    RCconfig_nr_parallel();
+  config_getlist( &MACRLCParamList,NULL,0, NULL);
+  RC.nb_macrlc_inst  = MACRLCParamList.numelt;
+  // Get num L1 instances
+  config_getlist( &L1ParamList,NULL,0, NULL);
+  RC.nb_nr_L1_inst = L1ParamList.numelt;
+  
+  // Get num RU instances
+  config_getlist( &RUParamList,NULL,0, NULL);  
+  RC.nb_RU     = RUParamList.numelt; 
+  
+  RCconfig_nr_parallel();
+    
+
+}
+
+int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i) {
+  int   J, l;
+  char *address = NULL;
+  char *cidr    = NULL;
+
+  //int                    num_gnbs                                                      = 0;
+  //int                    num_component_carriers                                        = 0;
+  int                    j,k                                                           = 0;
+  int32_t                gnb_id                                                        = 0;
 
+  paramdef_t GNBSParams[] = GNBSPARAMS_DESC;
+  paramdef_t GNBParams[]  = GNBPARAMS_DESC;
+  paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0};
+  /* get global parameters, defined outside any section in the config file */
+  config_get( GNBSParams,sizeof(GNBSParams)/sizeof(paramdef_t),NULL);
+
+  //paramlist_def_t SCCsParamList = {GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON, NULL, 0};
+
+  AssertFatal(i < GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt,
+              "Failed to parse config file %s, %uth attribute %s \n",
+              RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS);
+
+  if (GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt > 0) {
+    // Output a list of all gNBs.
+    config_getlist( &GNBParamList,GNBParams,sizeof(GNBParams)/sizeof(paramdef_t),NULL);
+
+    if (GNBParamList.numelt > 0) {
+      for (k = 0; k < GNBParamList.numelt; k++) {
+        if (GNBParamList.paramarray[k][GNB_GNB_ID_IDX].uptr == NULL) {
+          // Calculate a default eNB ID
+          if (EPC_MODE_ENABLED) {
+            uint32_t hash;
+            hash = s1ap_generate_eNB_id ();
+            gnb_id = k + (hash & 0xFFFF8);
+          } else {
+            gnb_id = k;
+          }
+        } else {
+          gnb_id = *(GNBParamList.paramarray[k][GNB_GNB_ID_IDX].uptr);
+        }
+
+        // search if in active list
+        for (j = 0; j < GNBSParams[GNB_ACTIVE_GNBS_IDX].numelt; j++) {
+          if (strcmp(GNBSParams[GNB_ACTIVE_GNBS_IDX].strlistptr[j], *(GNBParamList.paramarray[k][GNB_GNB_NAME_IDX].strptr)) == 0) {
+            paramdef_t PLMNParams[] = GNBPLMNPARAMS_DESC;
+            paramlist_def_t PLMNParamList = {GNB_CONFIG_STRING_PLMN_LIST, NULL, 0};
+            /* map parameter checking array instances to parameter definition array instances */
+            checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK;
+
+            for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I)
+              PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]);
+
+            paramdef_t X2Params[]  = X2PARAMS_DESC;
+            paramlist_def_t X2ParamList = {ENB_CONFIG_STRING_TARGET_ENB_X2_IP_ADDRESS,NULL,0};
+            paramdef_t SCTPParams[]  = GNBSCTPPARAMS_DESC;
+            paramdef_t NETParams[]  =  GNBNETPARAMS_DESC;
+            /* TODO: fix the size - if set lower we have a crash (MAX_OPTNAME_SIZE was 64 when this code was written) */
+            /* this is most probably a problem with the config module */
+            char aprefix[MAX_OPTNAME_SIZE*80 + 8];
+            sprintf(aprefix,"%s.[%i]",GNB_CONFIG_STRING_GNB_LIST,k);
+            /* Some default/random parameters */
+            X2AP_REGISTER_ENB_REQ (msg_p).eNB_id = gnb_id;
+
+            if (strcmp(*(GNBParamList.paramarray[k][GNB_CELL_TYPE_IDX].strptr), "CELL_MACRO_GNB") == 0) {
+              X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_GNB;
+            }else {
+              AssertFatal (0,
+                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
+                           RC.config_file_name, i, *(GNBParamList.paramarray[k][GNB_CELL_TYPE_IDX].strptr));
+            }
 
+            X2AP_REGISTER_ENB_REQ (msg_p).eNB_name         = strdup(*(GNBParamList.paramarray[k][GNB_GNB_NAME_IDX].strptr));
+            X2AP_REGISTER_ENB_REQ (msg_p).tac              = *GNBParamList.paramarray[k][GNB_TRACKING_AREA_CODE_IDX].uptr;
+            config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix);
+
+            if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6)
+              AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n",
+                          PLMNParamList.numelt);
+
+            if (PLMNParamList.numelt > 1)
+              LOG_W(X2AP, "X2AP currently handles only one PLMN, ignoring the others!\n");
+
+            X2AP_REGISTER_ENB_REQ (msg_p).mcc = *PLMNParamList.paramarray[0][GNB_MOBILE_COUNTRY_CODE_IDX].uptr;
+            X2AP_REGISTER_ENB_REQ (msg_p).mnc = *PLMNParamList.paramarray[0][GNB_MOBILE_NETWORK_CODE_IDX].uptr;
+            X2AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length = *PLMNParamList.paramarray[0][GNB_MNC_DIGIT_LENGTH].u8ptr;
+            AssertFatal(X2AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length == 3
+                        || X2AP_REGISTER_ENB_REQ(msg_p).mnc < 100,
+                        "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n",
+                        X2AP_REGISTER_ENB_REQ(msg_p).mnc);
+
+            X2AP_REGISTER_ENB_REQ (msg_p).num_cc = 1;
+            J = 0;
+            X2AP_REGISTER_ENB_REQ (msg_p).eutra_band[J] = 78; //ccparams_nr_x2.nr_band; //78
+            X2AP_REGISTER_ENB_REQ (msg_p).downlink_frequency[J] = 3600000000; //ccparams_nr_x2.downlink_frequency; //3600000000
+            X2AP_REGISTER_ENB_REQ (msg_p).uplink_frequency_offset[J] = 0; //(unsigned int) ccparams_nr_x2.uplink_frequency_offset; //0
+            X2AP_REGISTER_ENB_REQ (msg_p).Nid_cell[J]= 0; //ccparams_nr_x2.Nid_cell; //0
+            X2AP_REGISTER_ENB_REQ (msg_p).N_RB_DL[J]= 106; //ccparams_nr_x2.N_RB_DL; //106
+
+            X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = TDD;
+
+            //Temp out
+            /*X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_DL[J] = to_earfcn_DL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency, ccparams_lte.N_RB_DL);
+              X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_UL[J] = to_earfcn_UL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency + ccparams_lte.uplink_frequency_offset, ccparams_lte.N_RB_DL);*/
+
+            sprintf(aprefix,"%s.[%i]",GNB_CONFIG_STRING_GNB_LIST,k);
+            config_getlist( &X2ParamList,X2Params,sizeof(X2Params)/sizeof(paramdef_t),aprefix);
+            AssertFatal(X2ParamList.numelt <= X2AP_MAX_NB_ENB_IP_ADDRESS,
+                        "value of X2ParamList.numelt %d must be lower than X2AP_MAX_NB_ENB_IP_ADDRESS %d value: reconsider to increase X2AP_MAX_NB_ENB_IP_ADDRESS\n",
+                        X2ParamList.numelt,X2AP_MAX_NB_ENB_IP_ADDRESS);
+            X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 = 0;
+
+            for (l = 0; l < X2ParamList.numelt; l++) {
+              X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 += 1;
+              strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4_address,*(X2ParamList.paramarray[l][ENB_X2_IPV4_ADDRESS_IDX].strptr));
+              strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6_address,*(X2ParamList.paramarray[l][ENB_X2_IPV6_ADDRESS_IDX].strptr));
+
+              if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) {
+                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1;
+                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 0;
+              } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv6") == 0) {
+                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 0;
+                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1;
+              } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "no") == 0) {
+                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1;
+                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1;
+              }
+            }
+
+            // timers
+            {
+              int t_reloc_prep = 0;
+              int tx2_reloc_overall = 0;
+              paramdef_t p[] = {
+                { "t_reloc_prep", "t_reloc_prep", 0, iptr:&t_reloc_prep, defintval:0, TYPE_INT, 0 },
+                { "tx2_reloc_overall", "tx2_reloc_overall", 0, iptr:&tx2_reloc_overall, defintval:0, TYPE_INT, 0 }
+              };
+              config_get(p, sizeof(p)/sizeof(paramdef_t), aprefix);
+
+              if (t_reloc_prep <= 0 || t_reloc_prep > 10000 ||
+                  tx2_reloc_overall <= 0 || tx2_reloc_overall > 20000) {
+                LOG_E(X2AP, "timers in configuration file have wrong values. We must have [0 < t_reloc_prep <= 10000] and [0 < tx2_reloc_overall <= 20000]\n");
+                exit(1);
+              }
+
+              X2AP_REGISTER_ENB_REQ (msg_p).t_reloc_prep = t_reloc_prep;
+              X2AP_REGISTER_ENB_REQ (msg_p).tx2_reloc_overall = tx2_reloc_overall;
+            }
+            // SCTP SETTING
+            X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS;
+            X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams  = SCTP_IN_STREAMS;
+
+            if (EPC_MODE_ENABLED) {
+              sprintf(aprefix,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,k,GNB_CONFIG_STRING_SCTP_CONFIG);
+              config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix);
+              X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[GNB_SCTP_INSTREAMS_IDX].uptr);
+              X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[GNB_SCTP_OUTSTREAMS_IDX].uptr);
+            }
+
+            sprintf(aprefix,"%s.[%i].%s",GNB_CONFIG_STRING_GNB_LIST,k,GNB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
+            // NETWORK_INTERFACES
+            config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix);
+            X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C = (uint32_t)*(NETParams[GNB_PORT_FOR_X2C_IDX].uptr);
+
+            //temp out
+            if ((NETParams[GNB_IPV4_ADDR_FOR_X2C_IDX].strptr == NULL) || (X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C == 0)) {
+              LOG_E(RRC,"Add eNB IPv4 address and/or port for X2C in the CONF file!\n");
+              exit(1);
+            }
+
+            cidr = *(NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr);
+            address = strtok(cidr, "/");
+            X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv6 = 0;
+            X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4 = 1;
+            strcpy(X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4_address, address);
+          }
+        }
+      }
+    }
+  }
+
+  return 0;
 }
+
+
diff --git a/openair2/GNB_APP/gnb_config.h b/openair2/GNB_APP/gnb_config.h
index 8320c5ccdcd..e2588d9e4df 100644
--- a/openair2/GNB_APP/gnb_config.h
+++ b/openair2/GNB_APP/gnb_config.h
@@ -103,6 +103,7 @@ extern void NRRCConfig(void);
 
 void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc);
 int RCconfig_NR_S1(MessageDef *msg_p, uint32_t i);
+int RCconfig_NR_X2(MessageDef *msg_p, uint32_t i);
 
 #endif /* GNB_CONFIG_H_ */
 /** @} */
diff --git a/openair2/GNB_APP/gnb_paramdef.h b/openair2/GNB_APP/gnb_paramdef.h
index 5b97796f8a4..2d9ecb8c8a5 100644
--- a/openair2/GNB_APP/gnb_paramdef.h
+++ b/openair2/GNB_APP/gnb_paramdef.h
@@ -111,6 +111,29 @@ typedef enum {
 #define GNB_CONFIG_STRING_LOCAL_S_PORTD                 "local_s_portd"
 #define GNB_CONFIG_STRING_REMOTE_S_PORTD                "remote_s_portd"
 
+typedef struct ccparams_nr_x2 {
+  char             *frame_type;
+  int32_t           tdd_config;
+  int32_t           tdd_config_s;
+  int32_t           nr_band;
+  long long int     downlink_frequency;
+  int32_t           uplink_frequency_offset;
+  int32_t           Nid_cell;
+  int32_t           N_RB_DL;
+  } ccparams_nr_x2_t;
+
+
+#define CCPARAMS_NR_X2_DESC(ccparams) {         \
+    {ENB_CONFIG_STRING_FRAME_TYPE,                                   NULL,   0,           strptr:&ccparams.frame_type,                             defstrval:"TDD",           TYPE_STRING,     0},  \
+    {ENB_CONFIG_STRING_TDD_CONFIG,                                   NULL,   0,           iptr:&ccparams.tdd_config,                               defintval:3,               TYPE_UINT,       0},  \
+    {ENB_CONFIG_STRING_TDD_CONFIG_S,                                 NULL,   0,           iptr:&ccparams.tdd_config_s,                             defintval:0,               TYPE_UINT,       0},  \
+    {ENB_CONFIG_STRING_EUTRA_BAND,                                   NULL,   0,           iptr:&ccparams.nr_band,                               defintval:78,               TYPE_UINT,       0},  \
+    {ENB_CONFIG_STRING_DOWNLINK_FREQUENCY,                           NULL,   0,           i64ptr:(int64_t *)&ccparams.downlink_frequency,          defint64val:3600000000,    TYPE_UINT64,     0},  \
+    {ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET,                      NULL,   0,           iptr:&ccparams.uplink_frequency_offset,                  defintval:0,      TYPE_INT,        0},  \
+    {ENB_CONFIG_STRING_NID_CELL,                                     NULL,   0,           iptr:&ccparams.Nid_cell,                                 defintval:0,               TYPE_UINT,       0},  \
+    {ENB_CONFIG_STRING_N_RB_DL,                                      NULL,   0,           iptr:&ccparams.N_RB_DL,                                  defintval:106,              TYPE_UINT,       0}  \
+}
+
 /*-----------------------------------------------------------------------------------------------------------------------------------------*/
 /*                                            cell configuration parameters                                                                */
 /*   optname                                   helpstr   paramflags    XXXptr        defXXXval                   type           numelt     */
@@ -197,661 +220,8 @@ typedef enum {
 
 
 
-/* component carries configuration parameters name */
-
-#define GNB_CONFIG_STRING_NB_ANT_PORTS                                                 "nb_antenna_ports"
-#define GNB_CONFIG_STRING_NB_ANT_TX                                                    "nb_antennas_tx"
-#define GNB_CONFIG_STRING_NB_ANT_RX                                                    "nb_antennas_rx"
-#define GNB_CONFIG_STRING_TX_GAIN                                                      "tx_gain"
-#define GNB_CONFIG_STRING_RX_GAIN                                                      "rx_gain"
-
-  ///NR
-  //MIB
-#define GNB_CONFIG_STRING_MIB_SUBCARRIERSPACINGCOMMON                                  "MIB_subCarrierSpacingCommon"
-#define GNB_CONFIG_STRING_MIB_SSB_SUBCARRIEROFFSET                                     "MIB_ssb_SubcarrierOffset"
-#define GNB_CONFIG_STRING_MIB_DMRS_TYPEA_POSITION                                      "MIB_dmrs_TypeA_Position"
-#define GNB_CONFIG_STRING_PDCCH_CONFIGSIB1                                             "pdcch_ConfigSIB1"
-
-  //SIB1
-#define GNB_CONFIG_STRING_SIB1_FREQUENCYOFFSETSSB                                      "SIB1_frequencyOffsetSSB"
-#define GNB_CONFIG_STRING_SIB1_SSB_PERIODICITYSERVINGCELL                              "SIB1_ssb_PeriodicityServingCell"
-#define GNB_CONFIG_STRING_SIB1_SS_PBCH_BLOCKPOWER                                      "SIB1_ss_PBCH_BlockPower"
-  //NR FREQUENCYINFODL
-#define GNB_CONFIG_STRING_ABSOLUTEFREQUENCYSSB                                         "absoluteFrequencySSB"
-#define GNB_CONFIG_STRING_DL_FREQBANDINDICATORNR                                       "DL_FreqBandIndicatorNR"
-#define GNB_CONFIG_STRING_DL_ABSOLUTEFREQUENCYPOINTA                                   "DL_absoluteFrequencyPointA"
-
-  //NR DL SCS-SPECIFICCARRIER
-#define GNB_CONFIG_STRING_DL_OFFSETTOCARRIER                                           "DL_offsetToCarrier"
-#define GNB_CONFIG_STRING_DL_SCS_SUBCARRIERSPACING                                     "DL_SCS_SubcarrierSpacing"
-#define GNB_CONFIG_STRING_DL_CARRIERBANDWIDTH                                          "DL_carrierBandwidth"
-
-  // NR BWP-DOWNLINKCOMMON
-#define GNB_CONFIG_STRING_DL_LOCATIONANDBANDWIDTH                                      "DL_locationAndBandwidth"
-#define GNB_CONFIG_STRING_DL_BWP_SUBCARRIERSPACING                                     "DL_BWP_SubcarrierSpacing"
-#define GNB_CONFIG_STRING_DL_BWP_PREFIX_TYPE                                           "DL_BWP_prefix_type"
-
-  //NR FREQUENCYINFOUL
-#define GNB_CONFIG_STRING_UL_FREQBANDINDICATORNR                                       "UL_FreqBandIndicatorNR"
-#define GNB_CONFIG_STRING_UL_ABSOLUTEFREQUENCYPOINTA                                   "UL_absoluteFrequencyPointA"
-#define GNB_CONFIG_STRING_UL_ADDITIONALSPECTRUMEMISSION                                "UL_additionalSpectrumEmission"
-#define GNB_CONFIG_STRING_UL_P_MAX                                                     "UL_p_Max"
-#define GNB_CONFIG_STRING_UL_FREQUENCYSHIFT7P5KHZ                                      "UL_frequencyShift7p5khz"
-
-  //NR UL SCS-SPECIFICCARRIER
-#define GNB_CONFIG_STRING_UL_OFFSETTOCARRIER                                           "UL_offsetToCarrier"
-#define GNB_CONFIG_STRING_UL_SCS_SUBCARRIERSPACING                                     "UL_SCS_SubcarrierSpacing"
-#define GNB_CONFIG_STRING_UL_CARRIERBANDWIDTH                                          "UL_carrierBandwidth"
-
-  // NR BWP-UPLINKCOMMON
-#define GNB_CONFIG_STRING_UL_LOCATIONANDBANDWIDTH                                      "UL_locationAndBandwidth"
-#define GNB_CONFIG_STRING_UL_BWP_SUBCARRIERSPACING                                     "UL_BWP_SubcarrierSpacing"
-#define GNB_CONFIG_STRING_UL_BWP_PREFIX_TYPE                                           "UL_BWP_prefix_type"
-#define GNB_CONFIG_STRING_UL_TIMEALIGNMENTTIMERCOMMON                                  "UL_timeAlignmentTimerCommon"
-
-#define GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_N_TIMINGADVANCEOFFSET                "ServingCellConfigCommon_n_TimingAdvanceOffset"
-#define GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_POSITIONSINBURST_PR              "ServingCellConfigCommon_ssb_PositionsInBurst_PR"
-#define GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_PERIODICITYSERVINGCELL           "ServingCellConfigCommon_ssb_periodicityServingCell"
-#define GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_DMRS_TYPEA_POSITION                  "ServingCellConfigCommon_dmrs_TypeA_Position"
-#define GNB_CONFIG_STRING_NIA_SUBCARRIERSPACING                                        "NIA_SubcarrierSpacing"
-#define GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SS_PBCH_BLOCKPOWER                   "ServingCellConfigCommon_ss_PBCH_BlockPower"
-
-
-  //NR TDD-UL-DL-CONFIGCOMMON
-#define GNB_CONFIG_STRING_REFERENCESUBCARRIERSPACING                                   "referenceSubcarrierSpacing"
-#define GNB_CONFIG_STRING_DL_UL_TRANSMISSIONPERIODICITY                                "dl_UL_TransmissionPeriodicity"
-#define GNB_CONFIG_STRING_NROFDOWNLINKSLOTS                                            "nrofDownlinkSlots"
-#define GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS                                          "nrofDownlinkSymbols"
-#define GNB_CONFIG_STRING_NROFUPLINKSLOTS                                              "nrofUplinkSlots"
-#define GNB_CONFIG_STRING_NROFUPLINKSYMBOLS                                            "nrofUplinkSymbols"
-
-  //NR RACH-CONFIGCOMMON
-#define GNB_CONFIG_STRING_RACH_TOTALNUMBEROFRA_PREAMBLES                               "rach_totalNumberOfRA_Preambles"
-#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_CHOICE        "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice"
-#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEEIGHTH     "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth"
-#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEFOURTH     "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth"
-#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEHALF       "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf"
-#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONE           "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one"
-#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_TWO           "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two"
-#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_FOUR          "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four"
-#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_EIGHT         "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight"
-#define GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_SIXTEEN       "rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen"
-#define GNB_CONFIG_STRING_RACH_GROUPBCONFIGURED                                        "rach_groupBconfigured"
-#define GNB_CONFIG_STRING_RACH_RA_MSG3SIZEGROUPA                                       "rach_ra_Msg3SizeGroupA"
-#define GNB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB                                "rach_messagePowerOffsetGroupB"
-#define GNB_CONFIG_STRING_RACH_NUMBEROFRA_PREAMBLESGROUPA                              "rach_numberOfRA_PreamblesGroupA"
-#define GNB_CONFIG_STRING_RACH_RA_CONTENTIONRESOLUTIONTIMER                            "rach_ra_ContentionResolutionTimer"
-#define GNB_CONFIG_STRING_RSRP_THRESHOLDSSB                                            "rsrp_ThresholdSSB"
-#define GNB_CONFIG_STRING_RSRP_THRESHOLDSSB_SUL                                        "rsrp_ThresholdSSB_SUL"
-#define GNB_CONFIG_STRING_PRACH_ROOTSEQUENCEINDEX_CHOICE                               "prach_RootSequenceIndex_choice"
-#define GNB_CONFIG_STRING_PRACH_ROOTSEQUENCEINDEX_L839                                 "prach_RootSequenceIndex_l839"
-#define GNB_CONFIG_STRING_PRACH_ROOTSEQUENCEINDEX_L139                                 "prach_RootSequenceIndex_l139"
-#define GNB_CONFIG_STRING_PRACH_MSG1_SUBCARRIERSPACING                                 "prach_msg1_SubcarrierSpacing"
-#define GNB_CONFIG_STRING_RESTRICTEDSETCONFIG                                          "restrictedSetConfig"
-#define GNB_CONFIG_STRING_MSG3_TRANSFORMPRECODING                                      "msg3_transformPrecoding"
-  //SSB-PERRACH-OCCASIONANDCB-PREAMBLESPERSSB NOT SURE
-
-  //NR RACH-CONFIGGENERIC
-#define GNB_CONFIG_STRING_PRACH_CONFIGURATIONINDEX                                     "prach_ConfigurationIndex"
-#define GNB_CONFIG_STRING_PRACH_MSG1_FDM                                               "prach_msg1_FDM"
-#define GNB_CONFIG_STRING_PRACH_MSG1_FREQUENCYSTART                                    "prach_msg1_FrequencyStart"
-#define GNB_CONFIG_STRING_ZEROCORRELATIONZONECONFIG                                    "zeroCorrelationZoneConfig"
-#define GNB_CONFIG_STRING_PREAMBLERECEIVEDTARGETPOWER                                  "preambleReceivedTargetPower"
-#define GNB_CONFIG_STRING_PREAMBLETRANSMAX                                             "preambleTransMax"
-#define GNB_CONFIG_STRING_POWERRAMPINGSTEP                                             "powerRampingStep"
-#define GNB_CONFIG_STRING_RA_RESPONSEWINDOW                                            "ra_ResponseWindow"
-
-  //PUSCH-CONFIGCOMMON
-#define GNB_CONFIG_STRING_GROUPHOPPINGENABLEDTRANSFORMPRECODING                        "groupHoppingEnabledTransformPrecoding"
-#define GNB_CONFIG_STRING_MSG3_DELTAPREAMBLE                                           "msg3_DeltaPreamble"
-#define GNB_CONFIG_STRING_P0_NOMINALWITHGRANT                                          "p0_NominalWithGrant"
-
-  ///PUSCH-TIMEDOMAINRESOURCEALLOCATION
-#define GNB_CONFIG_STRING_PUSCH_TIMEDOMAINRESOURCEALLOCATION_K2                        "PUSCH_TimeDomainResourceAllocation_k2"
-#define GNB_CONFIG_STRING_PUSCH_TIMEDOMAINRESOURCEALLOCATION_MAPPINGTYPE               "PUSCH_TimeDomainResourceAllocation_mappingType"
-#define GNB_CONFIG_STRING_PUSCH_TIMEDOMAINRESOURCEALLOCATION_STARTSYMBOLANDLENGTH      "PUSCH_TimeDomainResourceAllocation_startSymbolAndLength"
-
-  //PUCCH-CONFIGCOMMON
-#define GNB_CONFIG_STRING_PUCCH_RESOURCECOMMON                                         "pucch_ResourceCommon"
-#define GNB_CONFIG_STRING_PUCCH_GROUPHOPPING                                           "pucch_GroupHopping"
-#define GNB_CONFIG_STRING_HOPPINGID                                                    "hoppingId"
-#define GNB_CONFIG_STRING_P0_NOMINAL                                                   "p0_nominal"
-
-  //PDSCH-CONFIGCOMMON
-  //PDSCH-TIMEDOMAINRESOURCEALLOCATION
-#define GNB_CONFIG_STRING_PDSCH_TIMEDOMAINRESOURCEALLOCATION_K0                        "PDSCH_TimeDomainResourceAllocation_k0"
-#define GNB_CONFIG_STRING_PDSCH_TIMEDOMAINRESOURCEALLOCATION_MAPPINGTYPE               "PDSCH_TimeDomainResourceAllocation_mappingType"
-#define GNB_CONFIG_STRING_PDSCH_TIMEDOMAINRESOURCEALLOCATION_STARTSYMBOLANDLENGTH      "PDSCH_TimeDomainResourceAllocation_startSymbolAndLength"
-  //RATEMATCHPATTERN  IS USED TO CONFIGURE ONE RATE MATCHING PATTERN FOR PDSCH
-#define GNB_CONFIG_STRING_RATEMATCHPATTERNID                                           "rateMatchPatternId"
-#define GNB_CONFIG_STRING_RATEMATCHPATTERN_PATTERNTYPE                                 "RateMatchPattern_patternType"
-#define GNB_CONFIG_STRING_SYMBOLSINRESOURCEBLOCK                                       "symbolsInResourceBlock"
-#define GNB_CONFIG_STRING_PERIODICITYANDPATTERN                                        "periodicityAndPattern"
-#define GNB_CONFIG_STRING_RATEMATCHPATTERN_CONTROLRESOURCESET                          "RateMatchPattern_controlResourceSet"
-#define GNB_CONFIG_STRING_RATEMATCHPATTERN_SUBCARRIERSPACING                           "RateMatchPattern_subcarrierSpacing"
-#define GNB_CONFIG_STRING_RATEMATCHPATTERN_MODE                                        "RateMatchPattern_mode"
-
-  //PDCCH-CONFIGCOMMON
-#define GNB_CONFIG_STRING_CONTROLRESOURCESETZERO                                       "controlResourceSetZero"
-#define GNB_CONFIG_STRING_SEARCHSPACEZERO                                              "searchSpaceZero"
-#define GNB_CONFIG_STRING_SEARCHSPACESIB1                                              "searchSpaceSIB1"
-#define GNB_CONFIG_STRING_SEARCHSPACEOTHERSYSTEMINFORMATION                            "searchSpaceOtherSystemInformation"
-#define GNB_CONFIG_STRING_PAGINGSEARCHSPACE                                            "pagingSearchSpace"
-#define GNB_CONFIG_STRING_RA_SEARCHSPACE                                               "ra_SearchSpace"
-  //NR PDCCH-CONFIGCOMMON COMMONCONTROLRESOURCESSETS
-#define GNB_CONFIG_STRING_PDCCH_COMMON_CONTROLRESOURCESETID                            "PDCCH_common_controlResourceSetId"
-#define GNB_CONFIG_STRING_PDCCH_COMMON_CONTROLRESOURCESET_DURATION                     "PDCCH_common_ControlResourceSet_duration"
-#define GNB_CONFIG_STRING_PDCCH_CCE_REG_MAPPINGTYPE                                    "PDCCH_cce_REG_MappingType"
-#define GNB_CONFIG_STRING_PDCCH_REG_BUNDLESIZE                                         "PDCCH_reg_BundleSize"
-#define GNB_CONFIG_STRING_PDCCH_INTERLEAVERSIZE                                        "PDCCH_interleaverSize"
-#define GNB_CONFIG_STRING_PDCCH_SHIFTINDEX                                             "PDCCH_shiftIndex"
-#define GNB_CONFIG_STRING_PDCCH_PRECODERGRANULARITY                                    "PDCCH_precoderGranularity"
-#define GNB_CONFIG_STRING_PDCCH_TCI_STATEID                                            "PDCCH_TCI_StateId"
-#define GNB_CONFIG_STRING_TCI_PRESENTINDCI                                             "tci_PresentInDCI"
-#define GNB_CONFIG_STRING_PDCCH_DMRS_SCRAMBLINGID                                      "pdcch_DMRS_ScramblingID"
-
-  //NR PDCCH-ConfigCommon commonSearchSpaces
-#define GNB_CONFIG_STRING_SEARCHSPACEID                                                "SearchSpaceId"
-#define GNB_CONFIG_STRING_COMMONSEARCHSPACES_CONTROLRESOURCESETID                      "commonSearchSpaces_controlResourceSetId"
-#define GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_CHOICE        "SearchSpace_monitoringSlotPeriodicityAndOffset_choice"
-#define GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_VALUE         "SearchSpace_monitoringSlotPeriodicityAndOffset_value"
-#define GNB_CONFIG_STRING_SEARCHSPACE_DURATION                                         "SearchSpace_duration"
-#define GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL1                 "SearchSpace_nrofCandidates_aggregationLevel1"
-#define GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL2                 "SearchSpace_nrofCandidates_aggregationLevel2"
-#define GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL4                 "SearchSpace_nrofCandidates_aggregationLevel4"
-#define GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL8                 "SearchSpace_nrofCandidates_aggregationLevel8"
-#define GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL16                "SearchSpace_nrofCandidates_aggregationLevel16"
-#define GNB_CONFIG_STRING_SEARCHSPACE_SEARCHSPACETYPE                                  "SearchSpace_searchSpaceType"
-#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL1    "Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1"
-#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL2    "Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2"
-#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL4    "Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4"
-#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL8    "Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8"
-#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL16   "Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16"
-#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_3_MONITORINGPERIODICITY                   "Common_dci_Format2_3_monitoringPeriodicity"
-#define GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_3_NROFPDCCH_CANDIDATES                    "Common_dci_Format2_3_nrofPDCCH_Candidates"
-#define GNB_CONFIG_STRING_UE_SPECIFIC__DCI_FORMATS                                     "ue_Specific__dci_Formats"
-#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_CARRIERFREQDL                        "RateMatchPatternLTE_CRS_carrierFreqDL"
-#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_CARRIERBANDWIDTHDL                   "RateMatchPatternLTE_CRS_carrierBandwidthDL"
-#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_NROFCRS_PORTS                        "RateMatchPatternLTE_CRS_nrofCRS_Ports"
-#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_V_SHIFT                              "RateMatchPatternLTE_CRS_v_Shift"
-#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_RADIOFRAMEALLOCATIONPERIOD           "RateMatchPatternLTE_CRS_radioframeAllocationPeriod"
-#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_RADIOFRAMEALLOCATIONOFFSET           "RateMatchPatternLTE_CRS_radioframeAllocationOffset"
-#define GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_SUBFRAMEALLOCATION_CHOICE            "RateMatchPatternLTE_CRS_subframeAllocation_choice"
-
-/* init for checkedparam_t structure */
-
-#define NRCCPARAMS_CHECK  {                                     \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-             { .s5= {NULL }} ,                 \
-}
 
 
-/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/*                                                                             component carriers configuration parameters                                                                                                                           */
-/*   optname                                                                        helpstr   paramflags    XXXptr                                                                  defXXXval                       type         numelt  checked_param  */
-/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-#define NRCCPARAMS_DESC { \
-{GNB_CONFIG_STRING_FRAME_TYPE,                                                       NULL,        0,        strptr:&frame_type,                                                     defstrval:"TDD",                TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_DL_PREFIX_TYPE,                                                   NULL,        0,        strptr:&DL_prefix_type,                                                 defstrval:"NORMAL",             TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_UL_PREFIX_TYPE,                                                   NULL,        0,        strptr:&UL_prefix_type,                                                 defstrval:"NORMAL",             TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_NR_BAND,                                                       NULL,        0,        iptr:&nr_band,                                                       defintval:78,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_DOWNLINK_FREQUENCY,                                               NULL,        0,        i64ptr:(int64_t *)&downlink_frequency,                                  defint64val:3600000000,         TYPE_UINT64,     0},  \
-{GNB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET,                                          NULL,        0,        iptr:&uplink_frequency_offset,                                          defintval:0,                    TYPE_INT,        0},  \
-{GNB_CONFIG_STRING_NID_CELL,                                                         NULL,        0,        iptr:&Nid_cell,                                                         defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_N_RB_DL,                                                          NULL,        0,        iptr:&N_RB_DL,                                                          defintval:25,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_NB_ANT_PORTS,                                                     NULL,        0,        iptr:&nb_antenna_ports,                                                 defintval:15,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_MIB_SUBCARRIERSPACINGCOMMON,                                      NULL,        0,        iptr:&MIB_subCarrierSpacingCommon,                                      defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_MIB_SSB_SUBCARRIEROFFSET,                                         NULL,        0,        iptr:&MIB_ssb_SubcarrierOffset,                                         defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_MIB_DMRS_TYPEA_POSITION,                                          NULL,        0,        iptr:&MIB_dmrs_TypeA_Position,                                          defintval:2,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PDCCH_CONFIGSIB1,                                                 NULL,        0,        iptr:&pdcch_ConfigSIB1,                                                 defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SIB1_FREQUENCYOFFSETSSB,                                          NULL,        0,        strptr:&SIB1_frequencyOffsetSSB,                                        defstrval:"khz5",               TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_SIB1_SSB_PERIODICITYSERVINGCELL,                                  NULL,        0,        iptr:&SIB1_ssb_PeriodicityServingCell,                                  defintval:5,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SIB1_SS_PBCH_BLOCKPOWER,                                          NULL,        0,        iptr:&SIB1_ss_PBCH_BlockPower,                                          defintval:-60,                  TYPE_INT,        0},  \
-{GNB_CONFIG_STRING_ABSOLUTEFREQUENCYSSB,                                             NULL,        0,        iptr:&absoluteFrequencySSB,                                             defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_DL_FREQBANDINDICATORNR,                                           NULL,        0,        iptr:&DL_FreqBandIndicatorNR,                                           defintval:15,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_DL_ABSOLUTEFREQUENCYPOINTA,                                       NULL,        0,        iptr:&DL_absoluteFrequencyPointA,                                       defintval:15,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_DL_OFFSETTOCARRIER,                                               NULL,        0,        iptr:&DL_offsetToCarrier,                                               defintval:15,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_DL_SCS_SUBCARRIERSPACING,                                         NULL,        0,        strptr:&DL_SCS_SubcarrierSpacing,                                       defstrval:"kHz15",              TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_DL_CARRIERBANDWIDTH,                                              NULL,        0,        iptr:&DL_carrierBandwidth,                                              defintval:15,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_DL_LOCATIONANDBANDWIDTH,                                          NULL,        0,        iptr:&DL_locationAndBandwidth,                                          defintval:15,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_DL_BWP_SUBCARRIERSPACING,                                         NULL,        0,        strptr:&DL_BWP_SubcarrierSpacing,                                       defstrval:"kHz15",              TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_DL_BWP_PREFIX_TYPE,                                               NULL,        0,        strptr:&DL_BWP_prefix_type,                                             defstrval:"NORMAL",             TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_UL_FREQBANDINDICATORNR,                                           NULL,        0,        iptr:&UL_FreqBandIndicatorNR,                                           defintval:15,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_UL_ABSOLUTEFREQUENCYPOINTA,                                       NULL,        0,        iptr:&UL_absoluteFrequencyPointA,                                       defintval:13,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_UL_ADDITIONALSPECTRUMEMISSION,                                    NULL,        0,        iptr:&UL_additionalSpectrumEmission,                                    defintval:3,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_UL_P_MAX,                                                         NULL,        0,        iptr:&UL_p_Max,                                                         defintval:-1,                   TYPE_INT,        0},  \
-{GNB_CONFIG_STRING_UL_FREQUENCYSHIFT7P5KHZ,                                          NULL,        0,        strptr:&UL_frequencyShift7p5khz,                                        defstrval:"TRUE",               TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_UL_OFFSETTOCARRIER,                                               NULL,        0,        iptr:&UL_offsetToCarrier,                                               defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_UL_SCS_SUBCARRIERSPACING,                                         NULL,        0,        strptr:&UL_SCS_SubcarrierSpacing,                                       defstrval:"kHz15",              TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_UL_CARRIERBANDWIDTH,                                              NULL,        0,        iptr:&UL_carrierBandwidth,                                              defintval:15,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_UL_LOCATIONANDBANDWIDTH,                                          NULL,        0,        iptr:&UL_locationAndBandwidth,                                          defintval:15,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_UL_BWP_SUBCARRIERSPACING,                                         NULL,        0,        strptr:&UL_BWP_SubcarrierSpacing,                                       defstrval:"kHz15",              TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_UL_BWP_PREFIX_TYPE,                                               NULL,        0,        strptr:&UL_BWP_prefix_type,                                             defstrval:"NORMAL",             TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_UL_TIMEALIGNMENTTIMERCOMMON,                                      NULL,        0,        strptr:&UL_timeAlignmentTimerCommon,                                    defstrval:"infinity",           TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_N_TIMINGADVANCEOFFSET,                    NULL,        0,        strptr:&ServingCellConfigCommon_n_TimingAdvanceOffset,                  defstrval:"n0",                 TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_POSITIONSINBURST_PR,                  NULL,        0,        i64ptr:(int64_t *)&ServingCellConfigCommon_ssb_PositionsInBurst_PR,                                  defint64val:0,         TYPE_UINT64,     0},  \
-{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_PERIODICITYSERVINGCELL,               NULL,        0,        iptr:&ServingCellConfigCommon_ssb_periodicityServingCell,               defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_DMRS_TYPEA_POSITION,                      NULL,        0,        iptr:&ServingCellConfigCommon_dmrs_TypeA_Position,                      defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_NIA_SUBCARRIERSPACING,                                            NULL,        0,        strptr:&NIA_SubcarrierSpacing,                                          defstrval:"kHz15",              TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SS_PBCH_BLOCKPOWER,                       NULL,        0,        iptr:&ServingCellConfigCommon_ss_PBCH_BlockPower,                       defintval:-60,                  TYPE_INT,        0},  \
-{GNB_CONFIG_STRING_REFERENCESUBCARRIERSPACING,                                       NULL,        0,        strptr:&referenceSubcarrierSpacing,                                     defstrval:"kHz15",              TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_DL_UL_TRANSMISSIONPERIODICITY,                                    NULL,        0,        strptr:&dl_UL_TransmissionPeriodicity,                                  defstrval:"ms0p5",              TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_NROFDOWNLINKSLOTS,                                                NULL,        0,        iptr:&nrofDownlinkSlots,                                                defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_NROFDOWNLINKSYMBOLS,                                              NULL,        0,        iptr:&nrofDownlinkSymbols,                                              defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_NROFUPLINKSLOTS,                                                  NULL,        0,        iptr:&nrofUplinkSlots,                                                  defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_NROFUPLINKSYMBOLS,                                                NULL,        0,        iptr:&nrofUplinkSymbols,                                                defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RACH_TOTALNUMBEROFRA_PREAMBLES,                                   NULL,        0,        iptr:&rach_totalNumberOfRA_Preambles,                                   defintval:63,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_CHOICE,            NULL,        0,        strptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,          defstrval:"oneEighth",          TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEEIGHTH,         NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth,         defintval:4,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEFOURTH,         NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth,         defintval:8,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEHALF,           NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf,           defintval:16,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONE,               NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one,               defintval:24,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_TWO,               NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two,               defintval:32,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_FOUR,              NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four,              defintval:8,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_EIGHT,             NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight,             defintval:4,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_SIXTEEN,           NULL,        0,        iptr:&rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen,           defintval:2,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RACH_GROUPBCONFIGURED,                                            NULL,        0,        strptr:&rach_groupBconfigured,                                          defstrval:"ENABLE",             TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_RACH_RA_MSG3SIZEGROUPA,                                           NULL,        0,        iptr:&rach_ra_Msg3SizeGroupA,                                           defintval:56,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RACH_MESSAGEPOWEROFFSETGROUPB,                                    NULL,        0,        strptr:&rach_messagePowerOffsetGroupB,                                  defstrval:"dB0",                TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_RACH_NUMBEROFRA_PREAMBLESGROUPA,                                  NULL,        0,        iptr:&rach_numberOfRA_PreamblesGroupA,                                  defintval:32,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RACH_RA_CONTENTIONRESOLUTIONTIMER,                                NULL,        0,        iptr:&rach_ra_ContentionResolutionTimer,                                defintval:8,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RSRP_THRESHOLDSSB,                                                NULL,        0,        iptr:&rsrp_ThresholdSSB,                                                defintval:64,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RSRP_THRESHOLDSSB_SUL,                                            NULL,        0,        iptr:&rsrp_ThresholdSSB_SUL,                                            defintval:64,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PRACH_ROOTSEQUENCEINDEX_CHOICE,                                   NULL,        0,        strptr:&prach_RootSequenceIndex_choice,                                 defstrval:"l839",               TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_PRACH_ROOTSEQUENCEINDEX_L839,                                     NULL,        0,        iptr:&prach_RootSequenceIndex_l839,                                     defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PRACH_ROOTSEQUENCEINDEX_L139,                                     NULL,        0,        iptr:&prach_RootSequenceIndex_l139,                                     defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PRACH_MSG1_SUBCARRIERSPACING,                                     NULL,        0,        strptr:&prach_msg1_SubcarrierSpacing,                                   defstrval:"kHz15",              TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_RESTRICTEDSETCONFIG,                                              NULL,        0,        strptr:&restrictedSetConfig,                                            defstrval:"unrestrictedSet",    TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_MSG3_TRANSFORMPRECODING,                                          NULL,        0,        strptr:&msg3_transformPrecoding,                                        defstrval:"ENABLE",             TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_PRACH_CONFIGURATIONINDEX,                                         NULL,        0,        iptr:&prach_ConfigurationIndex,                                         defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PRACH_MSG1_FDM,                                                   NULL,        0,        strptr:&prach_msg1_FDM,                                                 defstrval:"one",                TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_PRACH_MSG1_FREQUENCYSTART,                                        NULL,        0,        iptr:&prach_msg1_FrequencyStart,                                        defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_ZEROCORRELATIONZONECONFIG,                                        NULL,        0,        iptr:&zeroCorrelationZoneConfig,                                        defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PREAMBLERECEIVEDTARGETPOWER,                                      NULL,        0,        iptr:&preambleReceivedTargetPower,                                      defintval:-150,                 TYPE_INT,        0},  \
-{GNB_CONFIG_STRING_PREAMBLETRANSMAX,                                                 NULL,        0,        iptr:&preambleTransMax,                                                 defintval:6,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_POWERRAMPINGSTEP,                                                 NULL,        0,        strptr:&powerRampingStep,                                               defstrval:"dB0",                TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_RA_RESPONSEWINDOW,                                                NULL,        0,        iptr:&ra_ResponseWindow,                                                defintval:8,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_GROUPHOPPINGENABLEDTRANSFORMPRECODING,                            NULL,        0,        strptr:&groupHoppingEnabledTransformPrecoding,                          defstrval:"ENABLE",             TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_MSG3_DELTAPREAMBLE,                                               NULL,        0,        iptr:&msg3_DeltaPreamble,                                               defintval:0,                    TYPE_INT,        0},  \
-{GNB_CONFIG_STRING_P0_NOMINALWITHGRANT,                                              NULL,        0,        iptr:&p0_NominalWithGrant,                                              defintval:0,                    TYPE_INT,        0},  \
-{GNB_CONFIG_STRING_PUSCH_TIMEDOMAINRESOURCEALLOCATION_K2,                            NULL,        0,        iptr:&PUSCH_TimeDomainResourceAllocation_k2,                            defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PUSCH_TIMEDOMAINRESOURCEALLOCATION_MAPPINGTYPE,                   NULL,        0,        strptr:&PUSCH_TimeDomainResourceAllocation_mappingType,                 defstrval:"typeA",              TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_PUSCH_TIMEDOMAINRESOURCEALLOCATION_STARTSYMBOLANDLENGTH,          NULL,        0,        iptr:&PUSCH_TimeDomainResourceAllocation_startSymbolAndLength,          defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PUCCH_RESOURCECOMMON,                                             NULL,        0,        iptr:&pucch_ResourceCommon,                                             defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PUCCH_GROUPHOPPING,                                               NULL,        0,        strptr:&pucch_GroupHopping,                                             defstrval:"neither",            TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_HOPPINGID,                                                        NULL,        0,        iptr:&hoppingId,                                                        defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_P0_NOMINAL,                                                       NULL,        0,        iptr:&p0_nominal,                                                       defintval:-30,                  TYPE_INT,        0},  \
-{GNB_CONFIG_STRING_PDSCH_TIMEDOMAINRESOURCEALLOCATION_K0,                            NULL,        0,        iptr:&PDSCH_TimeDomainResourceAllocation_k0,                            defintval:2,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PDSCH_TIMEDOMAINRESOURCEALLOCATION_MAPPINGTYPE,                   NULL,        0,        strptr:&PDSCH_TimeDomainResourceAllocation_mappingType,                 defstrval:"typeA",              TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_PDSCH_TIMEDOMAINRESOURCEALLOCATION_STARTSYMBOLANDLENGTH,          NULL,        0,        iptr:&PDSCH_TimeDomainResourceAllocation_startSymbolAndLength,          defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RATEMATCHPATTERNID,                                               NULL,        0,        iptr:&rateMatchPatternId,                                               defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RATEMATCHPATTERN_PATTERNTYPE,                                     NULL,        0,        strptr:&RateMatchPattern_patternType,                                   defstrval:"bitmaps",            TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_SYMBOLSINRESOURCEBLOCK,                                           NULL,        0,        strptr:&symbolsInResourceBlock,                                         defstrval:"oneSlot",            TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_PERIODICITYANDPATTERN,                                            NULL,        0,        iptr:&periodicityAndPattern,                                            defintval:2,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RATEMATCHPATTERN_CONTROLRESOURCESET,                              NULL,        0,        iptr:&RateMatchPattern_controlResourceSet,                              defintval:5,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RATEMATCHPATTERN_SUBCARRIERSPACING,                               NULL,        0,        strptr:&RateMatchPattern_subcarrierSpacing,                             defstrval:"kHz15",              TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_RATEMATCHPATTERN_MODE,                                            NULL,        0,        strptr:&RateMatchPattern_mode,                                          defstrval:"dynamic",            TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_CONTROLRESOURCESETZERO,                                           NULL,        0,        iptr:&controlResourceSetZero,                                           defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SEARCHSPACEZERO,                                                  NULL,        0,        iptr:&searchSpaceZero,                                                  defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SEARCHSPACESIB1,                                                  NULL,        0,        iptr:&searchSpaceSIB1,                                                  defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SEARCHSPACEOTHERSYSTEMINFORMATION,                                NULL,        0,        iptr:&searchSpaceOtherSystemInformation,                                defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PAGINGSEARCHSPACE,                                                NULL,        0,        iptr:&pagingSearchSpace,                                                defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RA_SEARCHSPACE,                                                   NULL,        0,        iptr:&ra_SearchSpace,                                                   defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PDCCH_COMMON_CONTROLRESOURCESETID,                                NULL,        0,        iptr:&PDCCH_common_controlResourceSetId,                                defintval:5,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PDCCH_COMMON_CONTROLRESOURCESET_DURATION,                         NULL,        0,        iptr:&PDCCH_common_ControlResourceSet_duration,                         defintval:2,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PDCCH_CCE_REG_MAPPINGTYPE,                                        NULL,        0,        strptr:&PDCCH_cce_REG_MappingType,                                      defstrval:"nonInterleaved",     TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_PDCCH_REG_BUNDLESIZE,                                             NULL,        0,        iptr:&PDCCH_reg_BundleSize,                                             defintval:3,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PDCCH_INTERLEAVERSIZE,                                            NULL,        0,        iptr:&PDCCH_interleaverSize,                                            defintval:3,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PDCCH_SHIFTINDEX,                                                 NULL,        0,        iptr:&PDCCH_shiftIndex,                                                 defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_PDCCH_PRECODERGRANULARITY,                                        NULL,        0,        strptr:&PDCCH_precoderGranularity,                                      defstrval:"sameAsREG-bundle",   TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_PDCCH_TCI_STATEID,                                                NULL,        0,        iptr:&PDCCH_TCI_StateId,                                                defintval:32,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_TCI_PRESENTINDCI,                                                 NULL,        0,        strptr:&tci_PresentInDCI,                                               defstrval:"ENABLE",             TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_PDCCH_DMRS_SCRAMBLINGID,                                          NULL,        0,        iptr:&PDCCH_DMRS_ScramblingID,                                          defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SEARCHSPACEID,                                                    NULL,        0,        iptr:&SearchSpaceId,                                                    defintval:10,                   TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_COMMONSEARCHSPACES_CONTROLRESOURCESETID,                          NULL,        0,        iptr:&commonSearchSpaces_controlResourceSetId,                          defintval:5,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_CHOICE,            NULL,        0,        strptr:&SearchSpace_monitoringSlotPeriodicityAndOffset_choice,          defstrval:"sl1",                TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_VALUE,             NULL,        0,        iptr:&SearchSpace_monitoringSlotPeriodicityAndOffset_value,             defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SEARCHSPACE_DURATION,                                             NULL,        0,        iptr:&SearchSpace_duration,                                             defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL1,                     NULL,        0,        iptr:&SearchSpace_nrofCandidates_aggregationLevel1,                     defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL2,                     NULL,        0,        iptr:&SearchSpace_nrofCandidates_aggregationLevel2,                     defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL4,                     NULL,        0,        iptr:&SearchSpace_nrofCandidates_aggregationLevel4,                     defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL8,                     NULL,        0,        iptr:&SearchSpace_nrofCandidates_aggregationLevel8,                     defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL16,                    NULL,        0,        iptr:&SearchSpace_nrofCandidates_aggregationLevel16,                    defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_SEARCHSPACE_SEARCHSPACETYPE,                                      NULL,        0,        strptr:&SearchSpace_searchSpaceType,                                    defstrval:"common",             TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL1,        NULL,        0,        iptr:&Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1,        defintval:1,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL2,        NULL,        0,        iptr:&Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2,        defintval:1,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL4,        NULL,        0,        iptr:&Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4,        defintval:1,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL8,        NULL,        0,        iptr:&Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8,        defintval:1,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL16,       NULL,        0,        iptr:&Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16,       defintval:1,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_3_MONITORINGPERIODICITY,                       NULL,        0,        iptr:&Common_dci_Format2_3_monitoringPeriodicity,                       defintval:1,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_COMMON_DCI_FORMAT2_3_NROFPDCCH_CANDIDATES,                        NULL,        0,        iptr:&Common_dci_Format2_3_nrofPDCCH_Candidates,                        defintval:1,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_UE_SPECIFIC__DCI_FORMATS,                                         NULL,        0,        strptr:&ue_Specific__dci_Formats,                                       defstrval:"formats0-0-And-1-0", TYPE_STRING,     0},  \
-{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_CARRIERFREQDL,                            NULL,        0,        iptr:&RateMatchPatternLTE_CRS_carrierFreqDL,                            defintval:6,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_CARRIERBANDWIDTHDL,                       NULL,        0,        iptr:&RateMatchPatternLTE_CRS_carrierBandwidthDL,                       defintval:6,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_NROFCRS_PORTS,                            NULL,        0,        iptr:&RateMatchPatternLTE_CRS_nrofCRS_Ports,                            defintval:1,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_V_SHIFT,                                  NULL,        0,        iptr:&RateMatchPatternLTE_CRS_v_Shift,                                  defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_RADIOFRAMEALLOCATIONPERIOD,               NULL,        0,        iptr:&RateMatchPatternLTE_CRS_radioframeAllocationPeriod,               defintval:1,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_RADIOFRAMEALLOCATIONOFFSET,               NULL,        0,        iptr:&RateMatchPatternLTE_CRS_radioframeAllocationOffset,               defintval:0,                    TYPE_UINT,       0},  \
-{GNB_CONFIG_STRING_RATEMATCHPATTERNLTE_CRS_SUBFRAMEALLOCATION_CHOICE,                NULL,        0,        strptr:&RateMatchPatternLTE_CRS_subframeAllocation_choice,              defstrval:"oneFrame",           TYPE_STRING,     0},  \
-}
-
-
-/* component carries configuration parameters name */
-#define GNB_CONFIG_FRAME_TYPE_IDX                                                   0
-#define GNB_CONFIG_DL_PREFIX_TYPE_IDX                                               1
-#define GNB_CONFIG_UL_PREFIX_TYPE_IDX                                               2
-#define GNB_CONFIG_NR_BAND_IDX                                                      3
-#define GNB_CONFIG_DOWNLINK_FREQUENCY_IDX                                           4
-#define GNB_CONFIG_UPLINK_FREQUENCY_OFFSET_IDX                                      5
-#define GNB_CONFIG_NID_CELL_IDX                                                     6
-#define GNB_CONFIG_N_RB_DL_IDX                                                      7
-#define GNB_CONFIG_NB_ANT_PORTS_IDX                                                 8
-#define GNB_CONFIG_NB_ANT_TX_IDX                                                    9
-#define GNB_CONFIG_NB_ANT_RX_IDX                                                    10
-#define GNB_CONFIG_TX_GAIN_IDX                                                      11
-#define GNB_CONFIG_RX_GAIN_IDX                                                      12
-#define GNB_CONFIG_MIB_SUBCARRIERSPACINGCOMMON_IDX                                  13
-#define GNB_CONFIG_MIB_SSB_SUBCARRIEROFFSET_IDX                                     14
-#define GNB_CONFIG_MIB_DMRS_TYPEA_POSITION_IDX                                      15
-#define GNB_CONFIG_PDCCH_CONFIGSIB1_IDX                                             16
-#define GNB_CONFIG_SIB1_FREQUENCYOFFSETSSB_IDX                                      17
-#define GNB_CONFIG_SIB1_SSB_PERIODICITYSERVINGCELL_IDX                              18
-#define GNB_CONFIG_SIB1_SS_PBCH_BLOCKPOWER_IDX                                      19
-#define GNB_CONFIG_ABSOLUTEFREQUENCYSSB_IDX                                         20
-#define GNB_CONFIG_DL_FREQBANDINDICATORNR_IDX                                       22
-#define GNB_CONFIG_DL_ABSOLUTEFREQUENCYPOINTA_IDX                                   23
-#define GNB_CONFIG_DL_OFFSETTOCARRIER_IDX                                           24
-#define GNB_CONFIG_DL_SUBCARRIERSPACING_IDX                                         25
-#define GNB_CONFIG_DL_CARRIERBANDWIDTH_IDX                                          27
-#define GNB_CONFIG_DL_LOCATIONANDBANDWIDTH_IDX                                      28
-#define GNB_CONFIG_DL_BWP_SUBCARRIERSPACING_IDX                                     29
-#define GNB_CONFIG_DL_BWP_PREFIX_TYPE_IDX                                           30
-#define GNB_CONFIG_UL_FREQBANDINDICATORNR_IDX                                       31
-#define GNB_CONFIG_UL_ABSOLUTEFREQUENCYPOINTA_IDX                                   32
-#define GNB_CONFIG_UL_ADDITIONALSPECTRUMEMISSION_IDX                                33
-#define GNB_CONFIG_UL_P_MAX_IDX                                                     34
-#define GNB_CONFIG_UL_FREQUENCYSHIFT7P5KHZ_IDX                                      35
-#define GNB_CONFIG_UL_OFFSETTOCARRIER_IDX                                           36
-#define GNB_CONFIG_UL_SCS_SUBCARRIERSPACING_IDX                                     37
-#define GNB_CONFIG_UL_CARRIERBANDWIDTH_IDX                                          39
-#define GNB_CONFIG_UL_LOCATIONANDBANDWIDTH_IDX                                      41
-#define GNB_CONFIG_UL_BWP_SUBCARRIERSPACING_IDX                                     42
-#define GNB_CONFIG_UL_BWP_PREFIX_TYPE_IDX                                           43
-#define GNB_CONFIG_TIMEALIGNMENTTIMERCOMMON_IDX                                     44
-#define GNB_CONFIG_SERVINGCELLCONFIGCOMMON_N_TIMINGADVANCEOFFSET_IDX
-#define GNB_CONFIG_SERVINGCELLCONFIGCOMMON_SSB_POSITIONSINBURST_PR_IDX              45
-#define GNB_CONFIG_SERVINGCELLCONFIGCOMMON_SSB_PERIODICITYSERVINGCELL_IDX           46
-#define GNB_CONFIG_SERVINGCELLCONFIGCOMMON_DMRS_TYPEA_POSITION_IDX                  47
-#define GNB_CONFIG_NIA_SUBCARRIERSPACING_IDX                                        48
-#define GNB_CONFIG_SERVINGCELLCONFIGCOMMON_SS_PBCH_BLOCKPOWER_IDX                   49
-#define GNB_CONFIG_REFERENCESUBCARRIERSPACING_IDX                                   50
-#define GNB_CONFIG_DL_UL_TRANSMISSIONPERIODICITY_IDX                                51
-#define GNB_CONFIG_NROFDOWNLINKSLOTS_IDX                                            52
-#define GNB_CONFIG_NROFDOWNLINKSYMBOLS_IDX                                          53
-#define GNB_CONFIG_NROFUPLINKSLOTS_IDX                                              54
-#define GNB_CONFIG_NROFUPLINKSYMBOLS_IDX                                            55
-#define GNB_CONFIG_RACH_TOTALNUMBEROFRA_PREAMBLES_IDX                               56
-#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_CHOICE_IDX        57
-#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEEIGHTH_IDX     58
-#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEFOURTH_IDX     59
-#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONEHALF_IDX       60
-#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_ONE_IDX           61
-#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_TWO_IDX           62
-#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_FOUR_IDX          63
-#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_EIGHT_IDX         64
-#define GNB_CONFIG_RACH_SSB_PERRACH_OCCASIONANDCB_PREAMBLESPERSSB_SIXTEEN_IDX       65
-#define GNB_CONFIG_RACH_GROUPBCONFIGURED_IDX                                        66
-#define GNB_CONFIG_RACH_RA_MSG3SIZEGROUPA_IDX                                       67
-#define GNB_CONFIG_RACH_MESSAGEPOWEROFFSETGROUPB_IDX                                68
-#define GNB_CONFIG_RACH_NUMBEROFRA_PREAMBLESGROUPA_IDX                              69
-#define GNB_CONFIG_RACH_RA_CONTENTIONRESOLUTIONTIMER_IDX                            70
-#define GNB_CONFIG_RSRP_THRESHOLDSSB_IDX                                            71
-#define GNB_CONFIG_RSRP_THRESHOLDSSB_SUL_IDX                                        72
-#define GNB_CONFIG_PRACH_ROOTSEQUENCEINDEX_CHOICE_IDX                               73
-#define GNB_CONFIG_PRACH_ROOTSEQUENCEINDEX_L839_IDX                                 74
-#define GNB_CONFIG_PRACH_ROOTSEQUENCEINDEX_L139_IDX                                 75
-#define GNB_CONFIG_PRACH_MSG1_SUBCARRIERSPACING_IDX                                 76
-#define GNB_CONFIG_RESTRICTEDSETCONFIG_IDX                                          77
-#define GNB_CONFIG_MSG3_TRANSFORMPRECODING_IDX                                      78
-#define GNB_CONFIG_PRACH_CONFIGURATIONINDEX_IDX                                     79
-#define GNB_CONFIG_PRACH_MSG1_FDM_IDX                                               80
-#define GNB_CONFIG_PRACH_MSG1_FREQUENCYSTART_IDX                                    81
-#define GNB_CONFIG_ZEROCORRELATIONZONECONFIG_IDX                                    82
-#define GNB_CONFIG_PREAMBLERECEIVEDTARGETPOWER_IDX                                  83
-#define GNB_CONFIG_PREAMBLETRANSMAX_IDX                                             84
-#define GNB_CONFIG_POWERRAMPINGSTEP_IDX                                             85
-#define GNB_CONFIG_RA_RESPONSEWINDOW_IDX                                            86
-#define GNB_CONFIG_GROUPHOPPINGENABLEDTRANSFORMPRECODING_IDX                        87
-#define GNB_CONFIG_MSG3_DELTAPREAMBLE_IDX                                           88
-#define GNB_CONFIG_P0_NOMINALWITHGRANT_IDX                                          89
-#define GNB_CONFIG_PUSCH_TIMEDOMAINRESOURCEALLOCATION_K2_IDX                        90
-#define GNB_CONFIG_PUSCH_TIMEDOMAINRESOURCEALLOCATION_MAPPINGTYPE_IDX               91
-#define GNB_CONFIG_PUSCH_TIMEDOMAINRESOURCEALLOCATION_STARTSYMBOLANDLENGTH_IDX      92
-#define GNB_CONFIG_PUCCH_RESOURCECOMMON_IDX                                         93
-#define GNB_CONFIG_PUCCH_GROUPHOPPING_IDX                                           94
-#define GNB_CONFIG_HOPPINGID_IDX                                                    95
-#define GNB_CONFIG_P0_NOMINAL_IDX                                                   96
-#define GNB_CONFIG_PDSCH_TIMEDOMAINRESOURCEALLOCATION_K0_IDX                        97
-#define GNB_CONFIG_PDSCH_TIMEDOMAINRESOURCEALLOCATION_MAPPINGTYPE_IDX               98
-#define GNB_CONFIG_PDSCH_TIMEDOMAINRESOURCEALLOCATION_STARTSYMBOLANDLENGTH          
-#define GNB_CONFIG_RATEMATCHPATTERNID_IDX                                           99
-#define GNB_CONFIG_RATEMATCHPATTERN_PATTERNTYPE_IDX                                 100
-#define GNB_CONFIG_SYMBOLSINRESOURCEBLOCK_IDX                                       101
-#define GNB_CONFIG_PERIODICITYANDPATTERN_IDX                                        102
-#define GNB_CONFIG_RATEMATCHPATTERN_CONTROLRESOURCESET_IDX                          103
-#define GNB_CONFIG_RATEMATCHPATTERN_SUBCARRIERSPACING_IDX                           104
-#define GNB_CONFIG_RATEMATCHPATTERN_MODE_IDX                                        105
-#define GNB_CONFIG_CONTROLRESOURCESETZERO_IDX                                       106
-#define GNB_CONFIG_SEARCHSPACEZERO_IDX                                              107
-#define GNB_CONFIG_SEARCHSPACESIB1_IDX                                              108
-#define GNB_CONFIG_SEARCHSPACEOTHERSYSTEMINFORMATION_IDX                            109
-#define GNB_CONFIG_PAGINGSEARCHSPACE_IDX                                            110
-#define GNB_CONFIG_RA_SEARCHSPACE_IDX                                               111
-#define GNB_CONFIG_PDCCH_COMMON_CONTROLRESOURCESETID_IDX                            112
-#define GNB_CONFIG_PDCCH_COMMON_CONTROLRESOURCESET_DURATION_IDX                     113
-#define GNB_CONFIG_PDCCH_CCE_REG_MAPPINGTYPE_IDX                                    114
-#define GNB_CONFIG_PDCCH_REG_BUNDLESIZE_IDX                                         115
-#define GNB_CONFIG_PDCCH_INTERLEAVERSIZE_IDX                                        116
-#define GNB_CONFIG_PDCCH_SHIFTINDEX_IDX                                             117
-#define GNB_CONFIG_PDCCH_PRECODERGRANULARITY_IDX                                    118
-#define GNB_CONFIG_PDCCH_TCI_STATEID_IDX                                            119
-#define GNB_CONFIG_TCI_PRESENTINDCI_IDX                                             120
-#define GNB_CONFIG_PDCCH_DMRS_SCRAMBLINGID_IDX                                      121
-#define GNB_CONFIG_SEARCHSPACEID_IDX                                                122
-#define GNB_CONFIG_COMMONSEARCHSPACES_CONTROLRESOURCESETID_IDX                      123
-#define GNB_CONFIG_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_CHOICE_IDX        124
-#define GNB_CONFIG_SEARCHSPACE_MONITORINGSLOTPERIODICITYANDOFFSET_VALUE_IDX         125
-#define GNB_CONFIG_SEARCHSPACE_DURATION_IDX                                         126
-#define GNB_CONFIG_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL1_IDX                 127
-#define GNB_CONFIG_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL2_IDX                 128
-#define GNB_CONFIG_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL4_IDX                 129
-#define GNB_CONFIG_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL8_IDX                 130
-#define GNB_CONFIG_SEARCHSPACE_NROFCANDIDATES_AGGREGATIONLEVEL16_IDX                131
-#define GNB_CONFIG_SEARCHSPACE_SEARCHSPACETYPE_IDX                                  132
-#define GNB_CONFIG_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL1_IDX    133
-#define GNB_CONFIG_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL2_IDX    134
-#define GNB_CONFIG_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL4_IDX    135
-#define GNB_CONFIG_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL8_IDX    136
-#define GNB_CONFIG_COMMON_DCI_FORMAT2_0_NROFCANDIDATES_SFI_AGGREGATIONLEVEL16_IDX   137
-#define GNB_CONFIG_COMMON_DCI_FORMAT2_3_MONITORINGPERIODICITY_IDX                   138
-#define GNB_CONFIG_COMMON_DCI_FORMAT2_3_NROFPDCCH_CANDIDATES_IDX                    139
-#define GNB_CONFIG_UE_SPECIFIC__DCI_FORMATS_IDX                                     140
-#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_CARRIERFREQDL_IDX                        141
-#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_CARRIERBANDWIDTHDL_IDX                   142
-#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_NROFCRS_PORTS_IDX                        143
-#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_V_SHIFT_IDX                              144
-#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_RADIOFRAMEALLOCATIONPERIOD_IDX           145
-#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_RADIOFRAMEALLOCATIONOFFSET_IDX           146
-#define GNB_CONFIG_RATEMATCHPATTERNLTE_CRS_SUBFRAMEALLOCATION_CHOICE_IDX            147
-
-
-/*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/* SRB1 configuration parameters section name */
-#define GNB_CONFIG_STRING_SRB1                                          "srb1_parameters"
-
-/* SRB1 configuration parameters names   */
-#define GNB_CONFIG_STRING_SRB1_TIMER_POLL_RETRANSMIT                    "timer_poll_retransmit"
-#define GNB_CONFIG_STRING_SRB1_TIMER_REORDERING                         "timer_reordering"
-#define GNB_CONFIG_STRING_SRB1_TIMER_STATUS_PROHIBIT                    "timer_status_prohibit"
-#define GNB_CONFIG_STRING_SRB1_POLL_PDU                                 "poll_pdu"
-#define GNB_CONFIG_STRING_SRB1_POLL_BYTE                                "poll_byte"
-#define GNB_CONFIG_STRING_SRB1_MAX_RETX_THRESHOLD                       "max_retx_threshold"
-
-/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/*                                            SRB1 configuration parameters                                                                                  */
-/*   optname                                          helpstr   paramflags    XXXptr                             defXXXval         type           numelt     */
-/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
-#define GNBSRB1PARAMS_DESC {                                                                                                \
-{GNB_CONFIG_STRING_SRB1_TIMER_POLL_RETRANSMIT,         NULL,   0,            iptr:&srb1_timer_poll_retransmit,   defintval:80,     TYPE_UINT,      0},       \
-{GNB_CONFIG_STRING_SRB1_TIMER_REORDERING,              NULL,   0,            iptr:&srb1_timer_reordering,        defintval:35,     TYPE_UINT,      0},       \
-{GNB_CONFIG_STRING_SRB1_TIMER_STATUS_PROHIBIT,         NULL,   0,            iptr:&srb1_timer_status_prohibit,   defintval:0,      TYPE_UINT,      0},       \
-{GNB_CONFIG_STRING_SRB1_POLL_PDU,                      NULL,   0,            iptr:&srb1_poll_pdu,                defintval:4,      TYPE_UINT,      0},       \
-{GNB_CONFIG_STRING_SRB1_POLL_BYTE,                     NULL,   0,            iptr:&srb1_poll_byte,               defintval:99999,  TYPE_UINT,      0},       \
-{GNB_CONFIG_STRING_SRB1_MAX_RETX_THRESHOLD,            NULL,   0,            iptr:&srb1_max_retx_threshold,      defintval:4,      TYPE_UINT,      0}        \
-}
-/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
-
 /* MME configuration parameters section name */
 #define GNB_CONFIG_STRING_MME_IP_ADDRESS                "mme_ip_address"
 
@@ -913,6 +283,8 @@ typedef enum {
 #define GNB_INTERFACE_NAME_FOR_S1U_IDX             2
 #define GNB_IPV4_ADDR_FOR_S1U_IDX                  3
 #define GNB_PORT_FOR_S1U_IDX                       4
+#define GNB_IPV4_ADDR_FOR_X2C_IDX      			   5
+#define GNB_PORT_FOR_X2C_IDX         			   6
 
 /* S1 interface configuration parameters names   */
 #define GNB_CONFIG_STRING_GNB_INTERFACE_NAME_FOR_S1_MME "GNB_INTERFACE_NAME_FOR_S1_MME"
@@ -921,6 +293,10 @@ typedef enum {
 #define GNB_CONFIG_STRING_GNB_IPV4_ADDR_FOR_S1U         "GNB_IPV4_ADDRESS_FOR_S1U"
 #define GNB_CONFIG_STRING_GNB_PORT_FOR_S1U              "GNB_PORT_FOR_S1U"
 
+/* X2 interface configuration parameters names */
+#define GNB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_X2C	        "GNB_IPV4_ADDRESS_FOR_X2C"
+#define GNB_CONFIG_STRING_ENB_PORT_FOR_X2C				"GNB_PORT_FOR_X2C"
+
 /*--------------------------------------------------------------------------------------------------------------------------------------------------*/
 /*                                            S1 interface configuration parameters                                                                 */
 /*   optname                                            helpstr   paramflags    XXXptr              defXXXval             type           numelt     */
@@ -930,7 +306,9 @@ typedef enum {
 {GNB_CONFIG_STRING_GNB_IPV4_ADDRESS_FOR_S1_MME,          NULL,      0,         strptr:NULL,         defstrval:NULL,      TYPE_STRING,      0},      \
 {GNB_CONFIG_STRING_GNB_INTERFACE_NAME_FOR_S1U,           NULL,      0,         strptr:NULL,         defstrval:NULL,      TYPE_STRING,      0},      \
 {GNB_CONFIG_STRING_GNB_IPV4_ADDR_FOR_S1U,                NULL,      0,         strptr:NULL,         defstrval:NULL,      TYPE_STRING,      0},      \
-{GNB_CONFIG_STRING_GNB_PORT_FOR_S1U,                     NULL,      0,         uptr:NULL,           defintval:2152L,     TYPE_UINT,        0}       \
+{GNB_CONFIG_STRING_GNB_PORT_FOR_S1U,                     NULL,      0,         uptr:NULL,           defintval:2152L,     TYPE_UINT,        0},      \
+{GNB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_X2C,                NULL,      0,         strptr:NULL,         defstrval:NULL,      TYPE_STRING,      0},      \
+{GNB_CONFIG_STRING_ENB_PORT_FOR_X2C,                     NULL,      0,         uptr:NULL,           defintval:0L,        TYPE_UINT,        0}      \
 }   
 
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index d240e35a87f..7c3b536de21 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -1496,38 +1496,33 @@ schedule_ulsch_rnti(module_id_t   module_idP,
 
           if (status >= RRC_CONNECTED && UE_sched_ctrl_ptr->cqi_req_timer > 30) {
             if (UE_sched_ctrl_ptr->cqi_received == 0) {
-              if (NFAPI_MODE != NFAPI_MONOLITHIC) {
-                cqi_req = 0;
-              } else {
-                cqi_req = 1;
-                LOG_D(MAC,"Setting CQI_REQ (timer %d)\n",UE_sched_ctrl_ptr->cqi_req_timer);
-
-                /* TDD: to be safe, do not ask CQI in special Subframes:36.213/7.2.3 CQI definition */
-                if (cc[CC_id].tdd_Config) {
-                  switch (cc[CC_id].tdd_Config->subframeAssignment) {
-                    case 1:
-                      if(subframeP == 1 || subframeP == 6) {
-                        cqi_req=0;
-                      }
-
-                      break;
-
-                    case 3:
-                      if(subframeP == 1) {
-                        cqi_req=0;
-                      }
-
-                      break;
-
-                    default:
-                      LOG_E(MAC," TDD config not supported\n");
-                      break;
-                  }
+              cqi_req = 1;
+              LOG_D(MAC,
+                    "Setting CQI_REQ (timer %d)\n",
+                    UE_sched_ctrl_ptr->cqi_req_timer);
+
+              /* TDD: to be safe, do not ask CQI in special
+               * Subframes:36.213/7.2.3 CQI definition */
+              if (cc[CC_id].tdd_Config) {
+                switch (cc[CC_id].tdd_Config->subframeAssignment) {
+                  case 1:
+                    if (subframeP == 1 || subframeP == 6)
+                      cqi_req = 0;
+                    break;
+
+                  case 3:
+                    if (subframeP == 1)
+                      cqi_req = 0;
+                    break;
+
+                  default:
+                    LOG_E(MAC, " TDD config not supported\n");
+                    break;
                 }
+              }
 
-                if(cqi_req == 1) {
-                  UE_sched_ctrl_ptr->cqi_req_flag |= 1 << sched_subframeP;
-                }
+              if (cqi_req == 1) {
+                UE_sched_ctrl_ptr->cqi_req_flag |= 1 << sched_subframeP;
               }
             } else {
               LOG_D(MAC,"Clearing CQI request timer\n");
diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c
index 8518cba14c2..12058519152 100644
--- a/openair2/LAYER2/MAC/ue_procedures.c
+++ b/openair2/LAYER2/MAC/ue_procedures.c
@@ -2158,7 +2158,7 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
   if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)) {
     if(NFAPI_MODE==NFAPI_UE_STUB_PNF) {
       //Substitute with a static value for the MAC layer abstraction (phy_stub mode)
-      phr_p->PH = 40;
+      phr_p->PH = 60;
     } else {
       phr_p->PH = get_phr_mapping(module_idP, CC_id, eNB_index);
     }
diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c
index 495cbb1eaa1..ae231641943 100644
--- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c
+++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c
@@ -20,7 +20,7 @@
  */
 
 /*! \file nr_mac_common.c
- * \brief Common MAC functions for NR UE and gNB
+ * \brief Common MAC/PHY functions for NR UE and gNB
  * \author  Florian Kaltenberger and Raymond Knopp
  * \date 2019
  * \version 0.1
@@ -33,43 +33,55 @@
 #include "LAYER2/NR_MAC_gNB/mac_proto.h"
 
 nr_bandentry_t nr_bandtable[] = {
-  {1,  1920000, 1980000, 2110000, 2170000, 20, 422000},
-  {2,  1850000, 1910000, 1930000, 1990000, 20, 386000},
-  {3,  1710000, 1785000, 1805000, 1880000, 20, 361000},
-  {5,   824000,  849000,  869000,  894000, 20, 173800},
-  {7,  2500000, 2570000, 2620000, 2690000, 20, 524000},
-  {8,   880000,  915000,  925000,  960000, 20, 185000},
-  {12,  698000,  716000,  728000,  746000, 20, 145800},
-  {20,  832000,  862000,  791000,  821000, 20, 158200},
-  {25, 1850000, 1915000, 1930000, 1995000, 20, 386000},
-  {28,  703000,  758000,  758000,  813000, 20, 151600},
-  {34, 2010000, 2025000, 2010000, 2025000, 20, 402000},
-  {38, 2570000, 2620000, 2570000, 2630000, 20, 514000},
-  {39, 1880000, 1920000, 1880000, 1920000, 20, 376000},
-  {40, 2300000, 2400000, 2300000, 2400000, 20, 460000},
-  {41, 2496000, 2690000, 2496000, 2690000,  3, 499200},
-  {50, 1432000, 1517000, 1432000, 1517000, 20, 286400},
-  {51, 1427000, 1432000, 1427000, 1432000, 20, 285400},
-  {66, 1710000, 1780000, 2110000, 2200000, 20, 422000},
-  {70, 1695000, 1710000, 1995000, 2020000, 20, 399000},
-  {71,  663000,  698000,  617000,  652000, 20, 123400},
-  {74, 1427000, 1470000, 1475000, 1518000, 20, 295000},
-  {75,     000,     000, 1432000, 1517000, 20, 286400},
-  {76,     000,     000, 1427000, 1432000, 20, 285400},
-  {77, 3300000, 4200000, 3300000, 4200000,  1, 620000},
-  {78, 3300000, 3800000, 3300000, 3800000,  1, 620000},
-  {79, 4400000, 5000000, 4400000, 5000000,  2, 693334},
-  {80, 1710000, 1785000,     000,     000, 20, 342000},
-  {81,  860000,  915000,     000,     000, 20, 176000},
-  {82,  832000,  862000,     000,     000, 20, 166400},
-  {83,  703000,  748000,     000,     000, 20, 140600},
-  {84, 1920000, 1980000,     000,     000, 20, 384000},
-  {86, 1710000, 1785000,     000,     000, 20, 342000}
+  {1,   1920000, 1980000, 2110000, 2170000, 20, 422000, 100},
+  {2,   1850000, 1910000, 1930000, 1990000, 20, 386000, 100},
+  {3,   1710000, 1785000, 1805000, 1880000, 20, 361000, 100},
+  {5,    824000,  849000,  869000,  894000, 20, 173800, 100},
+  {7,   2500000, 2570000, 2620000, 2690000, 20, 524000, 100},
+  {8,    880000,  915000,  925000,  960000, 20, 185000, 100},
+  {12,   698000,  716000,  728000,  746000, 20, 145800, 100},
+  {20,   832000,  862000,  791000,  821000, 20, 158200, 100},
+  {25,  1850000, 1915000, 1930000, 1995000, 20, 386000, 100},
+  {28,   703000,  758000,  758000,  813000, 20, 151600, 100},
+  {34,  2010000, 2025000, 2010000, 2025000, 20, 402000, 100},
+  {38,  2570000, 2620000, 2570000, 2630000, 20, 514000, 100},
+  {39,  1880000, 1920000, 1880000, 1920000, 20, 376000, 100},
+  {40,  2300000, 2400000, 2300000, 2400000, 20, 460000, 100},
+  {41,  2496000, 2690000, 2496000, 2690000,  3, 499200,  15},
+  {41,  2496000, 2690000, 2496000, 2690000,  6, 499200,  30},
+  {50,  1432000, 1517000, 1432000, 1517000, 20, 286400, 100},
+  {51,  1427000, 1432000, 1427000, 1432000, 20, 285400, 100},
+  {66,  1710000, 1780000, 2110000, 2200000, 20, 422000, 100},
+  {70,  1695000, 1710000, 1995000, 2020000, 20, 399000, 100},
+  {71,   663000,  698000,  617000,  652000, 20, 123400, 100},
+  {74,  1427000, 1470000, 1475000, 1518000, 20, 295000, 100},
+  {75,      000,     000, 1432000, 1517000, 20, 286400, 100},
+  {76,      000,     000, 1427000, 1432000, 20, 285400, 100},
+  {77,  3300000, 4200000, 3300000, 4200000,  1, 620000,  15},
+  {77,  3300000, 4200000, 3300000, 4200000,  2, 620000,  30},
+  {78,  3300000, 3800000, 3300000, 3800000,  1, 620000,  15},
+  {78,  3300000, 3800000, 3300000, 3800000,  2, 620000,  30},
+  {79,  4400000, 5000000, 4400000, 5000000,  1, 693334,  15},
+  {79,  4400000, 5000000, 4400000, 5000000,  2, 693334,  30},
+  {80,  1710000, 1785000,     000,     000, 20, 342000, 100},
+  {81,   860000,  915000,     000,     000, 20, 176000, 100},
+  {82,   832000,  862000,     000,     000, 20, 166400, 100},
+  {83,   703000,  748000,     000,     000, 20, 140600, 100},
+  {84,  1920000, 1980000,     000,     000, 20, 384000, 100},
+  {86,  1710000, 1785000,     000,     000, 20, 342000, 100},
+  {257,26500000,29500000,26500000,29500000,  1,2054166,  60},
+  {257,26500000,29500000,26500000,29500000,  2,2054167, 120},
+  {258,24250000,27500000,24250000,27500000,  1,2016667,  60},
+  {258,24250000,27500000,24250000,27500000,  2,2016667, 120},
+  {260,37000000,40000000,37000000,40000000,  1,2229166,  60},
+  {260,37000000,40000000,37000000,40000000,  2,2229167, 120},
+  {261,27500000,28350000,27500000,28350000,  1,2070833,  60},
+  {261,27500000,28350000,27500000,28350000,  2,2070833, 120}
 };
 
 #define NR_BANDTABLE_SIZE (sizeof(nr_bandtable)/sizeof(nr_bandentry_t))
 
-void get_band(uint32_t downlink_frequency,
+void get_band(uint64_t downlink_frequency,
               uint16_t *current_band,
               int32_t *current_offset,
               lte_frame_type_t *current_type)
@@ -91,40 +103,157 @@ void get_band(uint32_t downlink_frequency,
       if ( nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz ) {
 
         center_frequency_khz = (nr_bandtable[ind].dl_max + nr_bandtable[ind].dl_min)/2;
-
         if (abs(dl_freq_khz - center_frequency_khz) < center_freq_diff_khz){
-
           *current_band = nr_bandtable[ind].band;
-	        *current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000;
+	  *current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000;
           center_freq_diff_khz = abs(dl_freq_khz - center_frequency_khz);
 
-	        if (*current_offset == 0)
-	          *current_type = TDD;
-	        else
-	          *current_type = FDD;
+	  if (*current_offset == 0)
+	    *current_type = TDD;
+	  else
+	    *current_type = FDD;
         }
       }
     }
 
-    LOG_I( PHY, "DL frequency %"PRIu32": band %d, frame_type %d, UL frequency %"PRIu32"\n",
+    LOG_I( PHY, "DL frequency %"PRIu64": band %d, frame_type %d, UL frequency %"PRIu64"\n",
          downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset);
 
     AssertFatal(*current_band != 0,
-	    "Can't find EUTRA band for frequency %u\n", downlink_frequency);
+	    "Can't find EUTRA band for frequency %lu\n", downlink_frequency);
+}
+
+uint16_t config_bandwidth(int mu, int nb_rb, int nr_band)
+{
+
+  if (nr_band < 100)  { //FR1
+   switch(mu) {
+    case 0 :
+      if (nb_rb<=25)
+        return 5; 
+      if (nb_rb<=52)
+        return 10;
+      if (nb_rb<=79)
+        return 15;
+      if (nb_rb<=106)
+        return 20;
+      if (nb_rb<=133)
+        return 25;
+      if (nb_rb<=160)
+        return 30;
+      if (nb_rb<=216)
+        return 40;
+      if (nb_rb<=270)
+        return 50;
+      AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
+      break;
+    case 1 :
+      if (nb_rb<=11)
+        return 5; 
+      if (nb_rb<=24)
+        return 10;
+      if (nb_rb<=38)
+        return 15;
+      if (nb_rb<=51)
+        return 20;
+      if (nb_rb<=65)
+        return 25;
+      if (nb_rb<=78)
+        return 30;
+      if (nb_rb<=106)
+        return 40;
+      if (nb_rb<=133)
+        return 50;
+      if (nb_rb<=162)
+        return 60;
+      if (nb_rb<=189)
+        return 70;
+      if (nb_rb<=217)
+        return 80;
+      if (nb_rb<=245)
+        return 90;
+      if (nb_rb<=273)
+        return 100;
+      AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
+      break;
+    case 2 :
+      if (nb_rb<=11)
+        return 10; 
+      if (nb_rb<=18)
+        return 15;
+      if (nb_rb<=24)
+        return 20;
+      if (nb_rb<=31)
+        return 25;
+      if (nb_rb<=38)
+        return 30;
+      if (nb_rb<=51)
+        return 40;
+      if (nb_rb<=65)
+        return 50;
+      if (nb_rb<=79)
+        return 60;
+      if (nb_rb<=93)
+        return 70;
+      if (nb_rb<=107)
+        return 80;
+      if (nb_rb<=121)
+        return 90;
+      if (nb_rb<=135)
+        return 100;
+      AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
+      break;
+    default:
+      AssertFatal(1==0,"Numerology %d undefined for band %d in FR1\n", mu,nr_band);
+   }
+  }
+  else {
+   switch(mu) {
+    case 2 :
+      if (nb_rb<=66)
+        return 50;
+      if (nb_rb<=132)
+        return 100;
+      if (nb_rb<=264)
+        return 200;
+      AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
+      break;
+    case 3 :
+      if (nb_rb<=32)
+        return 50;
+      if (nb_rb<=66)
+        return 100;
+      if (nb_rb<=132)
+        return 200;
+      if (nb_rb<=264)
+        return 400;
+      AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
+      break;
+    default:
+      AssertFatal(1==0,"Numerology %d undefined for band %d in FR1\n", mu,nr_band);
+   }
+  }
+
 }
 
 uint32_t to_nrarfcn(int nr_bandP,
                     uint64_t dl_CarrierFreq,
+                    uint8_t scs_index,
                     uint32_t bw)
 {
   uint64_t dl_CarrierFreq_by_1k = dl_CarrierFreq / 1000;
   int bw_kHz = bw / 1000;
-
+  int scs_khz = 15<<scs_index;
   int i;
+  uint32_t nrarfcn, delta_arfcn;
 
   LOG_I(MAC,"Searching for nr band %d DL Carrier frequency %llu bw %u\n",nr_bandP,(long long unsigned int)dl_CarrierFreq,bw);
-  AssertFatal(nr_bandP < 86, "nr_band %d > 86\n", nr_bandP);
-  for (i = 0; i < 30 && nr_bandtable[i].band != nr_bandP; i++);
+  AssertFatal(nr_bandP <= 261, "nr_band %d > 260\n", nr_bandP);
+  for (i = 0; i < NR_BANDTABLE_SIZE && nr_bandtable[i].band != nr_bandP; i++);
+
+  // selection of correct Deltaf raster according to SCS
+  if ( (nr_bandtable[i].deltaf_raster != 100) && (nr_bandtable[i].deltaf_raster != scs_khz))
+   i++;
 
   AssertFatal(dl_CarrierFreq_by_1k >= nr_bandtable[i].dl_min,
         "Band %d, bw %u : DL carrier frequency %llu kHz < %llu\n",
@@ -135,31 +264,57 @@ uint32_t to_nrarfcn(int nr_bandP,
 	      nr_bandP, (long long unsigned int)dl_CarrierFreq,bw, (long long unsigned int)dl_CarrierFreq_by_1k,
 	      (long long unsigned int)(nr_bandtable[i].dl_max - bw_kHz));
  
-  int deltaFglobal;
+  int deltaFglobal = 60;
 
-  if (dl_CarrierFreq < 3e9) deltaFglobal = 5;
-  else                      deltaFglobal = 15;
+  if (dl_CarrierFreq < 3e9) deltaFglobal = 15;
+  if (dl_CarrierFreq < 24.25e9) deltaFglobal = 5;
 
   // This is equation before Table 5.4.2.1-1 in 38101-1-f30
   // F_REF=F_REF_Offs + deltaF_Global(N_REF-NREF_REF_Offs)
-  return (((dl_CarrierFreq_by_1k - nr_bandtable[i].dl_min)/deltaFglobal) +
-	  nr_bandtable[i].N_OFFs_DL);
+  nrarfcn =  (((dl_CarrierFreq_by_1k - nr_bandtable[i].dl_min)/deltaFglobal)+nr_bandtable[i].N_OFFs_DL);
+
+  delta_arfcn = nrarfcn - nr_bandtable[i].N_OFFs_DL;
+  if(delta_arfcn%(nr_bandtable[i].step_size)!=0)
+    AssertFatal(1==0,"dl_CarrierFreq %lu corresponds to %u which is not on the raster for step size %lu",
+                dl_CarrierFreq,nrarfcn,nr_bandtable[i].step_size);
+
+  return nrarfcn;
 }
 
 
 uint64_t from_nrarfcn(int nr_bandP,
+                      uint8_t scs_index,
                       uint32_t dl_nrarfcn)
 {
   int i;
-  int deltaFglobal;
+  int deltaFglobal = 5;
+  int scs_khz = 15<<scs_index;
+  uint32_t delta_arfcn;
 
-  if (nr_bandP < 77 || nr_bandP > 79) deltaFglobal = 5;
-  else                                deltaFglobal = 15;
+  if (dl_nrarfcn > 599999 && dl_nrarfcn < 2016667)
+    deltaFglobal = 15; 
+  if (dl_nrarfcn > 2016666 && dl_nrarfcn < 3279166)
+    deltaFglobal = 60; 
   
-  AssertFatal(nr_bandP < 87, "nr_band %d > 86\n", nr_bandP);
-  for (i = 0; i < 31 && nr_bandtable[i].band != nr_bandP; i++);
-  AssertFatal(dl_nrarfcn>=nr_bandtable[i].N_OFFs_DL,"dl_nrarfcn %u < N_OFFs_DL %llu\n",dl_nrarfcn, (long long unsigned int)nr_bandtable[i].N_OFFs_DL);
+  AssertFatal(nr_bandP <= 261, "nr_band %d > 260\n", nr_bandP);
+  for (i = 0; i < NR_BANDTABLE_SIZE && nr_bandtable[i].band != nr_bandP; i++);
+  AssertFatal(dl_nrarfcn>=nr_bandtable[i].N_OFFs_DL,"dl_nrarfcn %u < N_OFFs_DL[%d] %llu\n",dl_nrarfcn, nr_bandtable[i].band,(long long unsigned int)nr_bandtable[i].N_OFFs_DL);
  
+  // selection of correct Deltaf raster according to SCS
+  if ( (nr_bandtable[i].deltaf_raster != 100) && (nr_bandtable[i].deltaf_raster != scs_khz))
+   i++;
+
+  delta_arfcn = dl_nrarfcn - nr_bandtable[i].N_OFFs_DL;
+  if(delta_arfcn%(nr_bandtable[i].step_size)!=0)
+    AssertFatal(1==0,"dl_nrarfcn %u is not on the raster for step size %lu",dl_nrarfcn,nr_bandtable[i].step_size);
+
+  LOG_I(PHY,"Computing dl_frequency (pointA %llu => %llu (dlmin %llu, nr_bandtable[%d].N_OFFs_DL %llu))\n",
+	(unsigned long long)dl_nrarfcn,
+	(unsigned long long)(1000*(nr_bandtable[i].dl_min + (dl_nrarfcn - nr_bandtable[i].N_OFFs_DL) * deltaFglobal)),
+	(unsigned long long)nr_bandtable[i].dl_min,
+	i,
+	(unsigned long long)nr_bandtable[i].N_OFFs_DL); 
+
   return 1000*(nr_bandtable[i].dl_min + (dl_nrarfcn - nr_bandtable[i].N_OFFs_DL) * deltaFglobal);
 }
 
@@ -174,3 +329,420 @@ int32_t get_nr_uldl_offset(int nr_bandP)
 
   return (nr_bandtable[i].dl_min - nr_bandtable[i].ul_min);
 }
+
+
+void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
+		   int x_overhead) {
+
+  LOG_D(MAC, "TBS calculation\n");
+
+  nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_rel15 = &pdsch_pdu->pdsch_pdu_rel15;
+  uint16_t N_PRB_oh = x_overhead;
+  uint8_t N_PRB_DMRS = (pdsch_rel15->dmrsConfigType == NFAPI_NR_DMRS_TYPE1)?6:4; //This only works for antenna port 1000
+  uint8_t N_sh_symb = pdsch_rel15->NrOfSymbols;
+  uint8_t Imcs = pdsch_rel15->mcsIndex[0];
+  uint16_t N_RE_prime = NR_NB_SC_PER_RB*N_sh_symb - N_PRB_DMRS - N_PRB_oh;
+  LOG_D(MAC, "N_RE_prime %d for %d symbols %d DMRS per PRB and %d overhead\n", N_RE_prime, N_sh_symb, N_PRB_DMRS, N_PRB_oh);
+
+  uint16_t R;
+  uint32_t TBS=0;
+  uint8_t table_idx, Qm;
+
+  /*uint8_t mcs_table = config.pdsch_config.mcs_table.value;
+  uint8_t ss_type = params_rel15.search_space_type;
+  uint8_t dci_format = params_rel15.dci_format;
+  get_table_idx(mcs_table, dci_format, rnti_type, ss_type);*/
+  table_idx = 0;
+  R = nr_get_code_rate_dl(Imcs, table_idx);
+  Qm = nr_get_Qm_dl(Imcs, table_idx);
+
+  TBS = nr_compute_tbs(Qm,
+                       R,
+		       pdsch_rel15->rbSize,
+		       N_sh_symb,
+		       N_PRB_DMRS,
+		       N_PRB_oh,
+		       pdsch_rel15->nrOfLayers)>>3;
+
+  pdsch_rel15->targetCodeRate[0] = R;
+  pdsch_rel15->qamModOrder[0] = Qm;
+  pdsch_rel15->TBSize[0] = TBS;
+  //  pdsch_rel15->nb_mod_symbols = N_RE_prime*pdsch_rel15->n_prb*pdsch_rel15->nb_codewords;
+  pdsch_rel15->mcsTable[0] = table_idx;
+
+  LOG_D(MAC, "TBS %d bytes: N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d R %d Qm %d table %d nb_symbols %d\n",
+  TBS, N_PRB_DMRS, N_sh_symb, N_PRB_oh, R, Qm, table_idx,N_RE_prime*pdsch_rel15->rbSize*pdsch_rel15->NrOfCodewords );
+}
+
+//Table 5.1.3.1-1 of 38.214
+uint16_t Table_51311[29][2] = {{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},{4,340},{4,378},{4,434},{4,490},{4,553},{4,616},
+		{4,658},{6,438},{6,466},{6,517},{6,567},{6,616},{6,666},{6,719},{6,772},{6,822},{6,873}, {6,910}, {6,948}};
+
+//Table 5.1.3.1-2 of 38.214
+// Imcs values 20 and 26 have been multiplied by 2 to avoid the floating point
+uint16_t Table_51312[28][2] = {{2,120},{2,193},{2,308},{2,449},{2,602},{4,378},{4,434},{4,490},{4,553},{4,616},{4,658},{6,466},{6,517},{6,567},{6,616},{6,666},
+		{6,719},{6,772},{6,822},{6,873},{8,1365},{8,711},{8,754},{8,797},{8,841},{8,885},{8,1833},{8,948}};
+
+//Table 5.1.3.1-3 of 38.214
+uint16_t Table_51313[29][2] = {{2,30},{2,40},{2,50},{2,64},{2,78},{2,99},{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{4,340},
+		{4,378},{4,434},{4,490},{4,553},{4,616},{6,438},{6,466},{6,517},{6,567},{6,616},{6,666}, {6,719}, {6,772}};
+
+//Table 6.1.4.1-1 of 38.214 TODO fix for tp-pi2BPSK
+uint16_t Table_61411[28][2] = {{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},{4,340},{4,378},{4,434},{4,490},{4,553},{4,616},
+		{4,658},{6,466},{6,517},{6,567},{6,616},{6,666},{6,719},{6,772},{6,822},{6,873}, {6,910}, {6,948}};
+
+//Table 6.1.4.1-2 of 38.214 TODO fix for tp-pi2BPSK
+uint16_t Table_61412[28][2] = {{2,30},{2,40},{2,50},{2,64},{2,78},{2,99},{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},
+		{4,378},{4,434},{4,490},{4,553},{4,616},{4,658},{4,699},{4,772},{6,567},{6,616},{6,666}, {6,772}};
+
+
+
+uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx) {
+  switch(table_idx) {
+    case 0:
+      return (Table_51311[Imcs][0]);
+    break;
+
+    case 1:
+      return (Table_51312[Imcs][0]);
+    break;
+
+    case 2:
+      return (Table_51313[Imcs][0]);
+    break;
+
+    default:
+      AssertFatal(0, "Invalid MCS table index %d (expected in range [1,3])\n", table_idx);
+  }
+}
+
+uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx) {
+  switch(table_idx) {
+    case 0:
+      return (Table_51311[Imcs][1]);
+    break;
+
+    case 1:
+      return (Table_51312[Imcs][1]);
+    break;
+
+    case 2:
+      return (Table_51313[Imcs][1]);
+    break;
+
+    default:
+      AssertFatal(0, "Invalid MCS table index %d (expected in range [1,3])\n", table_idx);
+  }
+}
+
+uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx) {
+  switch(table_idx) {
+    case 0:
+      return (Table_51311[Imcs][0]);
+    break;
+
+    case 1:
+      return (Table_51312[Imcs][0]);
+    break;
+
+    case 2:
+      return (Table_51313[Imcs][0]);
+    break;
+
+    case 3:
+      return (Table_61411[Imcs][0]);
+    break;
+
+    case 4:
+      return (Table_61412[Imcs][0]);
+    break;
+
+    default:
+      AssertFatal(0, "Invalid MCS table index %d (expected in range [1,2])\n", table_idx);
+  }
+}
+
+uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx) {
+  switch(table_idx) {
+    case 0:
+      return (Table_51311[Imcs][1]);
+    break;
+
+    case 1:
+      return (Table_51312[Imcs][1]);
+    break;
+
+    case 2:
+      return (Table_51313[Imcs][1]);
+    break;
+
+    case 3:
+      return (Table_61411[Imcs][1]);
+    break;
+
+    case 4:
+      return (Table_61412[Imcs][1]);
+    break;
+
+    default:
+      AssertFatal(0, "Invalid MCS table index %d (expected in range [1,2])\n", table_idx);
+  }
+}
+
+static inline uint8_t is_codeword_disabled(uint8_t format, uint8_t Imcs, uint8_t rv) {
+  return ((format==NFAPI_NR_DL_DCI_FORMAT_1_1)&&(Imcs==26)&&(rv==1));
+}
+
+static inline uint8_t get_table_idx(uint8_t mcs_table, uint8_t dci_format, uint8_t rnti_type, uint8_t ss_type) {
+  if ((mcs_table == NFAPI_NR_MCS_TABLE_QAM256) && (dci_format == NFAPI_NR_DL_DCI_FORMAT_1_1) && ((rnti_type==NFAPI_NR_RNTI_C)||(rnti_type==NFAPI_NR_RNTI_CS)))
+    return 2;
+  else if ((mcs_table == NFAPI_NR_MCS_TABLE_QAM64_LOW_SE) && (rnti_type!=NFAPI_NR_RNTI_new) && (rnti_type==NFAPI_NR_RNTI_C) && (ss_type==NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC))
+    return 3;
+  else if (rnti_type==NFAPI_NR_RNTI_new)
+    return 3;
+  else if ((mcs_table == NFAPI_NR_MCS_TABLE_QAM256) && (rnti_type==NFAPI_NR_RNTI_CS) && (dci_format == NFAPI_NR_DL_DCI_FORMAT_1_1))
+    return 2; // Condition mcs_table not configured in sps_config necessary here but not yet implemented
+  /*else if((mcs_table == NFAPI_NR_MCS_TABLE_QAM64_LOW_SE) &&  (rnti_type==NFAPI_NR_RNTI_CS))
+   *  table_idx = 3;
+   * Note: the commented block refers to the case where the mcs_table is from sps_config*/
+  else
+    return 1;
+}
+
+int get_num_dmrs(uint16_t dmrs_mask ) {
+
+  int num_dmrs=0;
+
+  for (int i=0;i<16;i++) num_dmrs+=((dmrs_mask>>i)&1);
+  return(num_dmrs);
+}
+
+uint16_t nr_dci_size(nr_dci_format_t format,
+		     nr_rnti_type_t rnti_type,
+		     uint16_t N_RB) {
+
+  uint16_t size = 0;
+
+  switch(format) {
+    /*Only sizes for 0_0 and 1_0 are correct at the moment*/
+    case NR_UL_DCI_FORMAT_0_0:
+      /// fixed: Format identifier 1, Hop flag 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2 Time Domain assgnmt 4 --20
+      size += 20;
+      size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment -- hopping scenario to be updated
+      size += nr_dci_size(NR_DL_DCI_FORMAT_1_0, rnti_type, N_RB) - size; // Padding to match 1_0 size
+      // UL/SUL indicator assumed to be 0
+      break;
+
+    case NR_UL_DCI_FORMAT_0_1:
+      /// fixed: Format identifier 1, MCS 5, NDI 1, RV 2, HARQ PID 4, PUSCH TPC 2, SRS request 2 --17
+      size += 17;
+      // Carrier indicator
+      // 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_DL_DCI_FORMAT_1_0:
+      /// fixed: Format identifier 1, VRB2PRB 1, MCS 5, NDI 1, RV 2, HARQ PID 4, DAI 2, PUCCH TPC 2, PUCCH RInd 3, PDSCH to HARQ TInd 3 Time Domain assgnmt 4 -- 28
+      size += 28;
+      size += (uint8_t)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); // Freq domain assignment
+      break;
+
+    case NR_DL_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_DL_DCI_FORMAT_2_0:
+      break;
+
+    case NR_DL_DCI_FORMAT_2_1:
+      break;
+
+    case NR_DL_DCI_FORMAT_2_2:
+      break;
+
+    case NR_DL_DCI_FORMAT_2_3:
+      break;
+
+    default:
+      AssertFatal(1==0, "Invalid NR DCI format %d\n", format);
+  }
+
+  return size;
+}
+
+int tdd_period_to_num[8] = {500,625,1000,1250,2000,2500,5000,10000};
+
+int is_nr_DL_slot(NR_ServingCellConfigCommon_t *scc,slot_t slot) {
+
+  int period,period1,period2=0;
+
+  if (scc->tdd_UL_DL_ConfigurationCommon==NULL) return(1);
+
+  if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1 &&
+      scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530)
+    period1 = 3000+*scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530;
+  else
+    period1 = tdd_period_to_num[scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity];
+			       
+  if (scc->tdd_UL_DL_ConfigurationCommon->pattern2) {
+    if (scc->tdd_UL_DL_ConfigurationCommon->pattern2->ext1 &&
+	scc->tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530)
+      period2 = 3000+*scc->tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530;
+    else
+      period2 = tdd_period_to_num[scc->tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity];
+  }    
+  period = period1+period2;
+  int scs=scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing;
+  int slots=period*(1<<scs)/1000;
+  int slots1=period1*(1<<scs)/1000;
+  int slot_in_period = slot % slots;
+  if (slot_in_period < slots1) return(slot_in_period <= scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots ? 1 : 0);
+  else return(slot_in_period <= slots1+scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots ? 1 : 0);    
+}
+
+int is_nr_UL_slot(NR_ServingCellConfigCommon_t *scc,slot_t slot) {
+
+  int period,period1,period2=0;
+
+  if (scc->tdd_UL_DL_ConfigurationCommon==NULL) return(1);
+
+  if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1 &&
+      scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530)
+    period1 = 3000+*scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530;
+  else
+    period1 = tdd_period_to_num[scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity];
+			       
+  if (scc->tdd_UL_DL_ConfigurationCommon->pattern2) {
+    if (scc->tdd_UL_DL_ConfigurationCommon->pattern2->ext1 &&
+	scc->tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530)
+      period2 = 3000+*scc->tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530;
+    else
+      period2 = tdd_period_to_num[scc->tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity];
+  }    
+  period = period1+period2;
+  int scs=scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing;
+  int slots=period*(1<<scs)/1000;
+  int slots1=period1*(1<<scs)/1000;
+  int slot_in_period = slot % slots;
+  if (slot_in_period < slots1) return(slot_in_period >= scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots ? 1 : 0);
+  else return(slot_in_period >= slots1+scc->tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots ? 1 : 0);    
+}
+
+int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols) {
+
+  int l0;
+  if (dmrs_TypeA_Position == NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2) l0=2;
+  else if (dmrs_TypeA_Position == NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos3) l0=3;
+  else AssertFatal(1==0,"Illegal dmrs_TypeA_Position %d\n",(int)dmrs_TypeA_Position);
+  if (pdsch_Config == NULL) { // Initial BWP
+    return(1<<l0);
+  }
+  else {
+    if (pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA &&
+	pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->present == NR_SetupRelease_DMRS_DownlinkConfig_PR_setup) {
+      // Relative to start of slot
+      NR_DMRS_DownlinkConfig_t *dmrs_config = (NR_DMRS_DownlinkConfig_t *)pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup;
+      AssertFatal(NrOfSymbols>1 && NrOfSymbols < 15,"Illegal NrOfSymbols %d\n",NrOfSymbols);
+      int pos2=0;
+      if (dmrs_config->maxLength == NULL) {
+	// this is Table 7.4.1.1.2-3: PDSCH DM-RS positions l for single-symbol DM-RS
+	if (dmrs_config->dmrs_AdditionalPosition == NULL) pos2=1;
+	else if (dmrs_config->dmrs_AdditionalPosition && *dmrs_config->dmrs_AdditionalPosition == NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0 )
+	  return(1<<l0);
+	
+	
+	switch (NrOfSymbols) {
+	case 2 :
+	case 3 :
+	case 4 :
+	case 5 :
+	case 6 :
+	case 7 :
+	  AssertFatal(1==0,"Incoompatible NrOfSymbols %d and dmrs_Additional_Position %d\n",
+		      NrOfSymbols,(int)*dmrs_config->dmrs_AdditionalPosition);
+	  break;
+	case 8 :
+	case 9:
+	  return(1<<l0 | 1<<7);
+	  break;
+	case 10:
+	case 11:
+	  if (*dmrs_config->dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1)
+	    return(1<<l0 | 1<<9);
+	  else
+	    return(1<<l0 | 1<<6 | 1<<9);
+	  break;
+	case 12:
+	  if (*dmrs_config->dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1)
+	    return(1<<l0 | 1<<9);
+	  else if (pos2==1)
+	    return(1<<l0 | 1<<6 | 1<<9);
+	  else if (*dmrs_config->dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos3)
+	    return(1<<l0 | 1<<5 | 1<<8 | 1<<11);
+	  break;
+	case 13:
+	case 14:
+	  if (*dmrs_config->dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1)
+	    return(1<<l0 | 1<<11);
+	  else if (pos2==1)
+	    return(1<<l0 | 1<<7 | 1<<11);
+	  else if (*dmrs_config->dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos3)
+	    return(1<<l0 | 1<<5 | 1<<8 | 1<<11);
+	  break;
+	}
+      }
+      else {
+	// Table 7.4.1.1.2-4: PDSCH DM-RS positions l for double-symbol DM-RS.
+	AssertFatal(NrOfSymbols>3,"Illegal NrOfSymbols %d for len2 DMRS\n",NrOfSymbols);
+	if (NrOfSymbols < 10) return(1<<l0);
+	if (NrOfSymbols < 13 && *dmrs_config->dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<<l0);
+	if (NrOfSymbols < 13 && *dmrs_config->dmrs_AdditionalPosition!=NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<<l0 | 1<<8);
+	if (*dmrs_config->dmrs_AdditionalPosition!=NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<<l0);
+	if (*dmrs_config->dmrs_AdditionalPosition!=NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1) return(1<<l0 | 1<<10);
+      }
+    }
+    else if (pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB &&
+	     pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->present == NR_SetupRelease_DMRS_DownlinkConfig_PR_setup) {
+      // Relative to start of PDSCH resource
+      AssertFatal(1==0,"TypeB DMRS not supported yet\n");
+    }
+  }
+  AssertFatal(1==0,"Shouldn't get here\n");
+  return(-1);
+}
diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c
index 7378b58ab68..c9830230349 100755
--- a/openair2/LAYER2/NR_MAC_UE/config_ue.c
+++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c
@@ -35,133 +35,340 @@
 
 #include "NR_MAC-CellGroupConfig.h"
 
+#include "../NR_MAC_gNB/nr_mac_common.h"
+#include "SCHED_NR/phy_frame_config_nr.h"
+
+int set_tdd_config_nr_ue(fapi_nr_config_request_t *cfg,
+                         int mu,
+                         int nrofDownlinkSlots, int nrofDownlinkSymbols,
+                         int nrofUplinkSlots,   int nrofUplinkSymbols) {
+
+  int slot_number = 0;
+  int nb_periods_per_frame;
+  int nb_slots_to_set = TDD_CONFIG_NB_FRAMES*(1<<mu)*NR_NUMBER_OF_SUBFRAMES_PER_FRAME;
+
+  switch(cfg->tdd_table.tdd_period) {
+    case 0:
+      nb_periods_per_frame = 20; // 10ms/0p5ms
+      break;
+
+    case 1:
+      nb_periods_per_frame = 16; // 10ms/0p625ms
+      break;
+
+    case 2:
+      nb_periods_per_frame = 10; // 10ms/1ms
+      break;
+
+    case 3:
+      nb_periods_per_frame = 8; // 10ms/1p25ms
+      break;
+
+    case 4:
+      nb_periods_per_frame = 5; // 10ms/2ms
+      break;
+
+    case 5:
+      nb_periods_per_frame = 4; // 10ms/2p5ms
+      break;
+
+    case 6:
+      nb_periods_per_frame = 2; // 10ms/5ms
+      break;
+
+    case 7:
+      nb_periods_per_frame = 1; // 10ms/10ms
+      break;
+
+    default:
+      AssertFatal(1==0,"Undefined tdd period %d\n", cfg->tdd_table.tdd_period);
+  }
+
+  int nb_slots_per_period = ((1<<mu) * NR_NUMBER_OF_SUBFRAMES_PER_FRAME)/nb_periods_per_frame;
+
+  if ( (nrofDownlinkSymbols + nrofUplinkSymbols) == 0 )
+    AssertFatal(nb_slots_per_period == (nrofDownlinkSlots + nrofUplinkSlots),
+                "set_tdd_configuration_nr: given period is inconsistent with current tdd configuration, nrofDownlinkSlots %d, nrofUplinkSlots %d, nb_slots_per_period %d \n",
+                nrofDownlinkSlots,nrofUplinkSlots,nb_slots_per_period);
+  else {
+    AssertFatal(nrofDownlinkSymbols + nrofUplinkSymbols < 14,"illegal symbol configuration DL %d, UL %d\n",nrofDownlinkSymbols,nrofUplinkSymbols);
+    AssertFatal(nb_slots_per_period == (nrofDownlinkSlots + nrofUplinkSlots + 1),
+                "set_tdd_configuration_nr: given period is inconsistent with current tdd configuration, nrofDownlinkSlots %d, nrofUplinkSlots %d, nrofMixed slots 1, nb_slots_per_period %d \n",
+                nrofDownlinkSlots,nrofUplinkSlots,nb_slots_per_period);
+  }
+
+  cfg->tdd_table.max_tdd_periodicity_list = (fapi_nr_max_tdd_periodicity_t *) malloc(nb_slots_to_set*sizeof(fapi_nr_max_tdd_periodicity_t));
+
+  for(int memory_alloc =0 ; memory_alloc<nb_slots_to_set; memory_alloc++)
+    cfg->tdd_table.max_tdd_periodicity_list[memory_alloc].max_num_of_symbol_per_slot_list = (fapi_nr_max_num_of_symbol_per_slot_t *) malloc(NR_NUMBER_OF_SYMBOLS_PER_SLOT*sizeof(
+          fapi_nr_max_num_of_symbol_per_slot_t));
+
+  while(slot_number != nb_slots_to_set) {
+    if(nrofDownlinkSlots != 0) {
+      for (int number_of_symbol = 0; number_of_symbol < nrofDownlinkSlots*NR_NUMBER_OF_SYMBOLS_PER_SLOT; number_of_symbol++) {
+        cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[number_of_symbol%NR_NUMBER_OF_SYMBOLS_PER_SLOT].slot_config= 0;
+
+        if((number_of_symbol+1)%NR_NUMBER_OF_SYMBOLS_PER_SLOT == 0)
+          slot_number++;
+      }
+    }
+
+    if (nrofDownlinkSymbols != 0 || nrofUplinkSymbols != 0) {
+      for(int number_of_symbol =0; number_of_symbol < nrofDownlinkSymbols; number_of_symbol++) {
+        cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[number_of_symbol].slot_config= 0;
+      }
+
+      for(int number_of_symbol = nrofDownlinkSymbols; number_of_symbol < NR_NUMBER_OF_SYMBOLS_PER_SLOT-nrofUplinkSymbols; number_of_symbol++) {
+        cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[number_of_symbol].slot_config= 2;
+      }
+
+      for(int number_of_symbol = NR_NUMBER_OF_SYMBOLS_PER_SLOT-nrofUplinkSymbols; number_of_symbol < NR_NUMBER_OF_SYMBOLS_PER_SLOT; number_of_symbol++) {
+        cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[number_of_symbol].slot_config= 1;
+      }
+
+      slot_number++;
+    }
+
+    if(nrofUplinkSlots != 0) {
+      for (int number_of_symbol = 0; number_of_symbol < nrofUplinkSlots*NR_NUMBER_OF_SYMBOLS_PER_SLOT; number_of_symbol++) {
+        cfg->tdd_table.max_tdd_periodicity_list[slot_number].max_num_of_symbol_per_slot_list[number_of_symbol%NR_NUMBER_OF_SYMBOLS_PER_SLOT].slot_config= 1;
+
+        if((number_of_symbol+1)%NR_NUMBER_OF_SYMBOLS_PER_SLOT == 0)
+          slot_number++;
+      }
+    }
+  }
+
+  return (0);
+}
+
+
+void config_common_ue(NR_UE_MAC_INST_t *mac,
+		      module_id_t       module_id,
+		      int               cc_idP) {
+
+  fapi_nr_config_request_t        *cfg = &mac->phy_config.config_req;
+  NR_ServingCellConfigCommon_t    *scc = mac->scc;
+  int i;
+
+    mac->phy_config.Mod_id = module_id;
+    mac->phy_config.CC_id = cc_idP;    
+  
+  // carrier config
+
+  LOG_I(MAC,"UE Config Common\n");  
+
+  cfg->carrier_config.dl_bandwidth = config_bandwidth(scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing,
+                                                      scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,
+                                                      *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]);
+
+  cfg->carrier_config.dl_frequency = from_nrarfcn(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0],
+                                                  *scc->ssbSubcarrierSpacing,
+                                                  scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA)/1000; // freq in kHz
+
+  for (i=0; i<5; i++) {
+    if (i==scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing) {
+      cfg->carrier_config.dl_grid_size[i] = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+      cfg->carrier_config.dl_k0[i] = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier;
+    }
+    else {
+      cfg->carrier_config.dl_grid_size[i] = 0;
+      cfg->carrier_config.dl_k0[i] = 0;
+    }
+  }
+
+  cfg->carrier_config.uplink_bandwidth = config_bandwidth(scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing,
+                                                          scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,
+                                                          *scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]);
+
+  int UL_pointA;
+  if (scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA == NULL)
+    UL_pointA = scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA;
+  else
+    UL_pointA = *scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA; 
+
+  cfg->carrier_config.uplink_frequency = from_nrarfcn(*scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0],
+                                                      *scc->ssbSubcarrierSpacing,
+                                                      UL_pointA)/1000; // freq in kHz
+
+
+  for (i=0; i<5; i++) {
+    if (i==scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing) {
+      cfg->carrier_config.ul_grid_size[i] = scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+      cfg->carrier_config.ul_k0[i] = scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier;
+    }
+    else {
+      cfg->carrier_config.ul_grid_size[i] = 0;
+      cfg->carrier_config.ul_k0[i] = 0;
+    }
+  }
+
+
+  // cell config
+
+  cfg->cell_config.phy_cell_id = *scc->physCellId;
+  cfg->cell_config.frame_duplex_type = 1;
+
+
+  // SSB config
+  cfg->ssb_config.ss_pbch_power = scc->ss_PBCH_BlockPower;
+  cfg->ssb_config.scs_common = *scc->ssbSubcarrierSpacing;
+
+  // SSB Table config
+  int scs_scaling = 1<<(cfg->ssb_config.scs_common);
+  if (scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA < 600000)
+    scs_scaling = scs_scaling*3;
+  if (scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA > 2016666)
+    scs_scaling = scs_scaling>>2;
+  uint32_t absolute_diff = (*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA);
+  cfg->ssb_table.ssb_offset_point_a = absolute_diff/(12*scs_scaling) - 10;
+  cfg->ssb_table.ssb_period = *scc->ssb_periodicityServingCell;
+  cfg->ssb_table.ssb_subcarrier_offset = 0; // TODO currently not in RRC?
+
+  switch (scc->ssb_PositionsInBurst->present) {
+    case 1 :
+      cfg->ssb_table.ssb_mask_list[0].ssb_mask = scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0]<<24;
+      cfg->ssb_table.ssb_mask_list[1].ssb_mask = 0;
+      break;
+    case 2 :
+      cfg->ssb_table.ssb_mask_list[0].ssb_mask = scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0]<<24;
+      cfg->ssb_table.ssb_mask_list[1].ssb_mask = 0;
+      break;
+    case 3 :
+      cfg->ssb_table.ssb_mask_list[0].ssb_mask = 0;
+      cfg->ssb_table.ssb_mask_list[1].ssb_mask = 0;
+      for (i=0; i<4; i++) {
+        cfg->ssb_table.ssb_mask_list[0].ssb_mask += (scc->ssb_PositionsInBurst->choice.longBitmap.buf[i+4]<<i*8);
+        cfg->ssb_table.ssb_mask_list[1].ssb_mask += (scc->ssb_PositionsInBurst->choice.longBitmap.buf[i]<<i*8);
+      }
+      break;
+    default:
+      AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", scc->ssb_PositionsInBurst->present);
+  }
+
+  // TDD Table Configuration
+  if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1 == NULL)
+    cfg->tdd_table.tdd_period = scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity;
+  else {
+    AssertFatal(scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530 != NULL,
+		"scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530 is null\n");
+    cfg->tdd_table.tdd_period = *scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530;
+  }
+  LOG_I(MAC,"Setting TDD configuration period to %d\n",cfg->tdd_table.tdd_period);
+  if(cfg->cell_config.frame_duplex_type == TDD){
+    int return_tdd = set_tdd_config_nr_ue(cfg,
+		     scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing,
+                     scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots,
+                     scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols,
+                     scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots,
+                     scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols
+                     );
+
+    if (return_tdd !=0)
+      LOG_E(PHY,"TDD configuration can not be done\n");
+    else
+      LOG_I(PHY,"TDD has been properly configurated\n");
+  }
+
+
+}
+
 int nr_rrc_mac_config_req_ue(
     module_id_t                     module_id,
     int                             cc_idP,
     uint8_t                         gNB_index,
     NR_MIB_t                        *mibP,
-    NR_MAC_CellGroupConfig_t        *mac_cell_group_configP,
-    NR_PhysicalCellGroupConfig_t    *phy_cell_group_configP,
-    NR_SpCellConfig_t               *spcell_configP ){
+    //    NR_ServingCellConfigCommon_t    *sccP,
+    //    NR_MAC_CellGroupConfig_t        *mac_cell_group_configP,
+    //    NR_PhysicalCellGroupConfig_t    *phy_cell_group_configP,
+    NR_SpCellConfig_t               *spCell_ConfigP ){
 
     NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
 
-//    NR_ServingCellConfig_t *serving_cell_config = spcell_configP->spCellConfigDedicated;
-//  TODO do something FAPI-like P5 L1/L2 config interface in config_si, config_mib, etc.
+    //    NR_ServingCellConfig_t *serving_cell_config = spcell_configP->spCellConfigDedicated;
+    //  TODO do something FAPI-like P5 L1/L2 config interface in config_si, config_mib, etc.
+
 
     if(mibP != NULL){
-        mac->mib = mibP;    //  update by every reception
+      mac->mib = mibP;    //  update by every reception
     }
+    
+    
+    if(spCell_ConfigP != NULL ){
+      mac->servCellIndex = *spCell_ConfigP->servCellIndex;
+      if (spCell_ConfigP->reconfigurationWithSync) {
+	mac->scc = spCell_ConfigP->reconfigurationWithSync->spCellConfigCommon;
+	config_common_ue(mac,module_id,cc_idP);
+	mac->crnti = spCell_ConfigP->reconfigurationWithSync->newUE_Identity;
+	LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti);
+      }
+      mac->scd = spCell_ConfigP->spCellConfigDedicated;
 
-    if(mac_cell_group_configP != NULL){
-        if(mac_cell_group_configP->drx_Config != NULL ){
-            switch(mac_cell_group_configP->drx_Config->present){
-                case NR_SetupRelease_DRX_Config_PR_NOTHING:
-                    break;
-                case NR_SetupRelease_DRX_Config_PR_release:
-                    mac->drx_Config = NULL;
-                    break;
-                case NR_SetupRelease_DRX_Config_PR_setup:
-                    mac->drx_Config = mac_cell_group_configP->drx_Config->choice.setup;
-                    break;
-                default:
-                    break;
-            }
-        }
-
-        if(mac_cell_group_configP->schedulingRequestConfig != NULL ){
-            mac->schedulingRequestConfig = mac_cell_group_configP->schedulingRequestConfig;
-        }
-
-        if(mac_cell_group_configP->bsr_Config != NULL ){
-            mac->bsr_Config = mac_cell_group_configP->bsr_Config;
-        }
-
-        if(mac_cell_group_configP->tag_Config != NULL ){
-            mac->tag_Config = mac_cell_group_configP->tag_Config;
-        }
-
-        if(mac_cell_group_configP->phr_Config != NULL ){
-            switch(mac_cell_group_configP->phr_Config->present){
-                case NR_SetupRelease_PHR_Config_PR_NOTHING:
-                    break;
-                case NR_SetupRelease_PHR_Config_PR_release:
-                    mac->phr_Config = NULL;
-                    break;
-                case NR_SetupRelease_PHR_Config_PR_setup:
-                    mac->phr_Config = mac_cell_group_configP->phr_Config->choice.setup;
-                    break;
-                default:
-                    break;
-            }
-            
-        }
-
-        if(phy_cell_group_configP->cs_RNTI != NULL ){
-            switch(phy_cell_group_configP->cs_RNTI->present){
-                case NR_SetupRelease_RNTI_Value_PR_NOTHING:
-                    break;
-                case NR_SetupRelease_RNTI_Value_PR_release:
-                    mac->cs_RNTI = NULL;
-                    break;
-                case NR_SetupRelease_RNTI_Value_PR_setup:
-                    mac->cs_RNTI = &phy_cell_group_configP->cs_RNTI->choice.setup;
-                    break;
-                default:
-                    break;
-            }
-            
-        }
+      /*      
+      if(mac_cell_group_configP != NULL){
+	if(mac_cell_group_configP->drx_Config != NULL ){
+	  switch(mac_cell_group_configP->drx_Config->present){
+	  case NR_SetupRelease_DRX_Config_PR_NOTHING:
+	    break;
+	  case NR_SetupRelease_DRX_Config_PR_release:
+	    mac->drx_Config = NULL;
+	    break;
+	  case NR_SetupRelease_DRX_Config_PR_setup:
+	    mac->drx_Config = mac_cell_group_configP->drx_Config->choice.setup;
+	    break;
+	  default:
+	    break;
+	  }
+	}
 	
-    }
+	if(mac_cell_group_configP->schedulingRequestConfig != NULL ){
+	  mac->schedulingRequestConfig = mac_cell_group_configP->schedulingRequestConfig;
+	}
+	
+	if(mac_cell_group_configP->bsr_Config != NULL ){
+	  mac->bsr_Config = mac_cell_group_configP->bsr_Config;
+	}
+	
+	if(mac_cell_group_configP->tag_Config != NULL ){
+	  mac->tag_Config = mac_cell_group_configP->tag_Config;
+	}
+	
+	if(mac_cell_group_configP->phr_Config != NULL ){
+	  switch(mac_cell_group_configP->phr_Config->present){
+	  case NR_SetupRelease_PHR_Config_PR_NOTHING:
+	    break;
+	  case NR_SetupRelease_PHR_Config_PR_release:
+	    mac->phr_Config = NULL;
+	    break;
+	  case NR_SetupRelease_PHR_Config_PR_setup:
+	    mac->phr_Config = mac_cell_group_configP->phr_Config->choice.setup;
+	    break;
+	  default:
+	    break;
+	  }        
+	}
+      }
+      
+      
+      if(phy_cell_group_configP != NULL ){
+	if(phy_cell_group_configP->cs_RNTI != NULL ){
+	  switch(phy_cell_group_configP->cs_RNTI->present){
+	  case NR_SetupRelease_RNTI_Value_PR_NOTHING:
+	    break;
+	  case NR_SetupRelease_RNTI_Value_PR_release:
+	    mac->cs_RNTI = NULL;
+	    break;
+	  case NR_SetupRelease_RNTI_Value_PR_setup:
+	    mac->cs_RNTI = &phy_cell_group_configP->cs_RNTI->choice.setup;
+	    break;
+	  default:
+	    break;
+	  }
+	}
+      }
+      */
+    }   
     
-    if(phy_cell_group_configP != NULL ){
-        //config_phy(phy_cell_group_config, NULL);
-    }
-
-//  TODO check
-#if 0
-    if(serving_cell_config_configP != NULL ){
-        //config_phy(NULL, spcell_config);
-        mac->servCellIndex = spcell_config->servCellIndex;
-    }
-
-
-    if(serving_cell_config != NULL ){
-        if(serving_cell_config->tdd_UL_DL_ConfigurationDedicated != NULL ){
-            mac->tdd_UL_DL_ConfigurationDedicated = serving_cell_config->tdd_UL_DL_ConfigurationDedicated;
-        }
-        
-        if(spcell_config->initialDownlinkBWP != NULL ){
-            mac->init_DL_BWP = spcell_config->initialDownlinkBWP;
-        }
-        
-        //  storage list of DL BWP config. TODO should be modify to maintain(add/release) a list inside MAC instance, this implementation just use for one-shot RRC configuration setting.
-        if(spcell_config->downlinkBWP_ToAddModList != NULL ){
-            mac->BWP_Downlink_list = spcell_config->downlinkBWP_ToAddModList->list;
-            mac->BWP_Downlink_count = spcell_config->downlinkBWP_ToAddModList->count;
-        }
-        
-        if(spcell_config->bwp_InactivityTimer != NULL ){
-            mac->bwp_InactivityTimer = spcell_config->bwp_InactivityTimer;
-        } 
-
-        if(spcell_config->defaultDownlinkBWP_Id != NULL ){
-            mac->defaultDownlinkBWP_Id = spcell_config->defaultDownlinkBWP_Id;
-        }
-
-        if(spcell_config->pdsch_ServingCellConfig != NULL ){
-            mac->pdsch_ServingCellConfig = spcell_config->pdsch_ServingCellConfig;
-        }
-
-        if(spcell_config->csi_MeasConfig != NULL ){
-            mac->csi_MeasConfig = spcell_config->csi_MeasConfig;
-        }
-
-        spcell_config->tag_Id = spcell_config.tag_Id;
-    }
-#endif
-    //scell config not yet
-
     return 0;
+
 }
diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h
index b97d4696e7f..405ea95eb11 100755
--- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h
+++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h
@@ -50,6 +50,7 @@
 #include "NR_ServingCellConfig.h"
 #include "fapi_nr_ue_interface.h"
 #include "NR_IF_Module.h"
+#include "../NR_MAC_gNB/nr_mac_common.h"
 #include "PHY/defs_nr_common.h"
 #include "openair2/LAYER2/NR_MAC_COMMON/nr_mac.h"
 
@@ -129,33 +130,48 @@ typedef struct {
 } NR_UE_SCHEDULING_INFO;
 
 
+#define MAX_NUM_BWP 2
+
+typedef enum {
+  RA_IDLE=0,
+  WAIT_RAR=1,
+  WAIT_CONTENTION_RESOLUTION=2
+} RA_state_t;
 /*!\brief Top level UE MAC structure */
 typedef struct {
-  
+
+  NR_ServingCellConfigCommon_t    *scc;
+  NR_ServingCellConfig_t          *scd;
+  int                             servCellIndex;
   ////  MAC config
-  NR_DRX_Config_t    	       *drx_Config;
-  NR_SchedulingRequestConfig_t *schedulingRequestConfig;
-  NR_BSR_Config_t    	       *bsr_Config;
-  NR_TAG_Config_t              *tag_Config;
-  NR_PHR_Config_t              *phr_Config;
-  NR_RNTI_Value_t              *cs_RNTI;
-  NR_MIB_t                     *mib;
-  
+  NR_DRX_Config_t    	          *drx_Config;
+  NR_SchedulingRequestConfig_t    *schedulingRequestConfig;
+  NR_BSR_Config_t    	          *bsr_Config;
+  NR_TAG_Config_t	          *tag_Config;
+  NR_PHR_Config_t	          *phr_Config;
+  NR_RNTI_Value_t 	          *cs_RNTI;
+  NR_MIB_t 	                  *mib;
+
+  NR_BWP_Downlink_t               *DLbwp[MAX_NUM_BWP];
+  NR_BWP_Uplink_t                 *ULbwp[MAX_NUM_BWP];
+  NR_ControlResourceSet_t         *coreset[MAX_NUM_BWP][FAPI_NR_MAX_CORESET_PER_BWP];
+  NR_SearchSpace_t                *SSpace[MAX_NUM_BWP][FAPI_NR_MAX_CORESET_PER_BWP][FAPI_NR_MAX_SS_PER_CORESET];
+
   ///     Type0-PDCCH seach space
   fapi_nr_dl_config_dci_dl_pdu_rel15_t type0_pdcch_dci_config;
   uint32_t type0_pdcch_ss_mux_pattern;
   SFN_C_TYPE type0_pdcch_ss_sfn_c;
   uint32_t type0_pdcch_ss_n_c;
   uint32_t type0_pdcch_consecutive_slots;
-  
-  ///     Random access parameter
+  /// state of RA procedure
+  RA_state_t ra_state;
+  ///     RA-rnti
   uint16_t ra_rnti;
+  ///     Temporary CRNTI
+  uint16_t t_crnti;
+  ///     CRNTI
   uint16_t crnti;
 
-   //BWP params
-  NR_BWP_PARMS initial_bwp_dl;
-  NR_BWP_PARMS initial_bwp_ul;
-
   ////	FAPI-like interface message
   fapi_nr_tx_request_t tx_request;
   fapi_nr_ul_config_request_t ul_config_request;
@@ -204,7 +220,139 @@ typedef enum frequency_range_e {
     FR2
 } frequency_range_t;
 
+typedef struct {
+  uint8_t identifier_dci_formats          ; // 0  IDENTIFIER_DCI_FORMATS:
+  uint8_t carrier_ind                     ; // 1  CARRIER_IND: 0 or 3 bits, as defined in Subclause x.x of [5, TS38.213]
+  uint8_t sul_ind_0_1                     ; // 2  SUL_IND_0_1:
+  uint8_t slot_format_ind                 ; // 3  SLOT_FORMAT_IND: size of DCI format 2_0 is configurable by higher layers up to 128 bits, according to Subclause 11.1.1 of [5, TS 38.213]
+  uint8_t pre_emption_ind                 ; // 4  PRE_EMPTION_IND: size of DCI format 2_1 is configurable by higher layers up to 126 bits, according to Subclause 11.2 of [5, TS 38.213]. Each pre-emption indication is 14 bits
+  uint8_t block_number                    ; // 5  BLOCK_NUMBER: starting position of a block is determined by the parameter startingBitOfFormat2_3
+  uint8_t close_loop_ind                  ; // 6  CLOSE_LOOP_IND:
+  uint8_t bandwidth_part_ind              ; // 7  BANDWIDTH_PART_IND:
+  uint8_t short_message_ind               ; // 8  SHORT_MESSAGE_IND:
+  uint8_t short_messages                  ; // 9  SHORT_MESSAGES:
+  uint16_t freq_dom_resource_assignment_UL; // 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered
+  //    (NOTE 1) If DCI format 0_0 is monitored in common search space
+  //    and if the number of information bits in the DCI format 0_0 prior to padding
+  //    is larger than the payload size of the DCI format 1_0 monitored in common search space
+  //    the bitwidth of the frequency domain resource allocation field in the DCI format 0_0
+  //    is reduced such that the size of DCI format 0_0 equals to the size of the DCI format 1_0
+  uint16_t freq_dom_resource_assignment_DL; // 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
+  uint8_t time_dom_resource_assignment    ; // 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
+  //    where I the number of entries in the higher layer parameter pusch-AllocationList
+  uint8_t vrb_to_prb_mapping              ; // 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
+  uint8_t prb_bundling_size_ind           ; // 14 PRB_BUNDLING_SIZE_IND:0 bit if the higher layer parameter PRB_bundling is not configured or is set to 'static', or 1 bit if the higher layer parameter PRB_bundling is set to 'dynamic' according to Subclause 5.1.2.3 of [6, TS 38.214]
+  uint8_t rate_matching_ind               ; // 15 RATE_MATCHING_IND: 0, 1, or 2 bits according to higher layer parameter rate-match-PDSCH-resource-set
+  uint8_t zp_csi_rs_trigger               ; // 16 ZP_CSI_RS_TRIGGER:
+  uint8_t freq_hopping_flag               ; // 17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0
+  uint8_t tb1_mcs                         ; // 18 TB1_MCS:
+  uint8_t tb1_ndi                         ; // 19 TB1_NDI:
+  uint8_t tb1_rv                          ; // 20 TB1_RV:
+  uint8_t tb2_mcs                         ; // 21 TB2_MCS:
+  uint8_t tb2_ndi                         ; // 22 TB2_NDI:
+  uint8_t tb2_rv                          ; // 23 TB2_RV:
+  uint8_t mcs                             ; // 24 MCS:
+  uint8_t ndi                             ; // 25 NDI:
+  uint8_t rv                              ; // 26 RV:
+  uint8_t harq_process_number             ; // 27 HARQ_PROCESS_NUMBER:
+  uint8_t dai                             ; // 28 DAI: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
+  //    2 if one serving cell is configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 bits are the counter DAI
+  //    0 otherwise
+  uint8_t first_dai                       ; // 29 FIRST_DAI: (1 or 2 bits) 1 bit for semi-static HARQ-ACK
+  uint8_t second_dai                      ; // 30 SECOND_DAI: (0 or 2 bits) 2 bits for dynamic HARQ-ACK codebook with two HARQ-ACK sub-codebooks
+  uint8_t tb_scaling                      ; // 31 TB_SCALING:
+  uint8_t tpc_pusch                       ; // 32 TPC_PUSCH:
+  uint8_t tpc_pucch                       ; // 33 TPC_PUCCH:
+  uint8_t pucch_resource_ind              ; // 34 PUCCH_RESOURCE_IND:
+  uint8_t pdsch_to_harq_feedback_time_ind ; // 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND:
+  uint8_t srs_resource_ind                ; // 36 SRS_RESOURCE_IND:
+  uint8_t precod_nbr_layers               ; // 37 PRECOD_NBR_LAYERS:
+  uint8_t antenna_ports                   ; // 38 ANTENNA_PORTS:
+  uint8_t tci                             ; // 39 TCI: 0 bit if higher layer parameter tci-PresentInDCI is not enabled; otherwise 3 bits
+  uint8_t srs_request                     ; // 40 SRS_REQUEST:
+  uint8_t tpc_cmd                         ; // 41 TPC_CMD:
+  uint8_t csi_request                     ; // 42 CSI_REQUEST:
+  uint8_t cbgti                           ; // 43 CBGTI: 0, 2, 4, 6, or 8 bits determined by higher layer parameter maxCodeBlockGroupsPerTransportBlock for the PDSCH
+  uint8_t cbgfi                           ; // 44 CBGFI: 0 or 1 bit determined by higher layer parameter codeBlockGroupFlushIndicator
+  uint8_t ptrs_dmrs                       ; // 45 PTRS_DMRS:
+  uint8_t beta_offset_ind                 ; // 46 BETA_OFFSET_IND:
+  uint8_t dmrs_seq_ini                    ; // 47 DMRS_SEQ_INI: 1 bit if the cell has two ULs and the number of bits for DCI format 1_0 before padding
+  //    is larger than the number of bits for DCI format 0_0 before padding; 0 bit otherwise
+  uint8_t ul_sch_ind                      ; // 48 UL_SCH_IND:  value of "1" indicates UL-SCH shall be transmitted on the PUSCH and a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH
+  uint16_t padding_nr_dci                 ; // 49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space
+  //    and if the number of information bits in the DCI format 0_0 prior to padding
+  //    is less than the payload size of the DCI format 1_0 monitored in common search space
+  //    zeros shall be appended to the DCI format 0_0
+  //    until the payload size equals that of the DCI format 1_0
+  uint8_t sul_ind_0_0                     ; // 50 SUL_IND_0_0:
+  uint8_t ra_preamble_index               ; // 51 RA_PREAMBLE_INDEX:
+  uint8_t sul_ind_1_0                     ; // 52 SUL_IND_1_0:
+  uint8_t ss_pbch_index                   ; // 53 SS_PBCH_INDEX
+  uint8_t prach_mask_index                ; // 54 PRACH_MASK_INDEX
+  uint8_t reserved_nr_dci                 ; // 55 RESERVED_NR_DCI
+} nr_dci_pdu_rel15_t;
+
 #define NUM_SLOT_FRAME 10
 
+#define NBR_NR_FORMATS              8     // The number of formats is 8 (0_0, 0_1, 1_0, 1_1, 2_0, 2_1, 2_2, 2_3)
+#define NBR_NR_DCI_FIELDS           56    // The number of different dci fields defined in TS 38.212 subclause 7.3.1
+
+#define IDENTIFIER_DCI_FORMATS           0
+#define CARRIER_IND                      1
+#define SUL_IND_0_1                      2
+#define SLOT_FORMAT_IND                  3
+#define PRE_EMPTION_IND                  4
+#define BLOCK_NUMBER                     5
+#define CLOSE_LOOP_IND                   6
+#define BANDWIDTH_PART_IND               7
+#define SHORT_MESSAGE_IND                8
+#define SHORT_MESSAGES                   9
+#define FREQ_DOM_RESOURCE_ASSIGNMENT_UL 10
+#define FREQ_DOM_RESOURCE_ASSIGNMENT_DL 11
+#define TIME_DOM_RESOURCE_ASSIGNMENT    12
+#define VRB_TO_PRB_MAPPING              13
+#define PRB_BUNDLING_SIZE_IND           14
+#define RATE_MATCHING_IND               15
+#define ZP_CSI_RS_TRIGGER               16
+#define FREQ_HOPPING_FLAG               17
+#define TB1_MCS                         18
+#define TB1_NDI                         19
+#define TB1_RV                          20
+#define TB2_MCS                         21
+#define TB2_NDI                         22
+#define TB2_RV                          23
+#define MCS                             24
+#define NDI                             25
+#define RV                              26
+#define HARQ_PROCESS_NUMBER             27
+#define DAI_                            28
+#define FIRST_DAI                       29
+#define SECOND_DAI                      30
+#define TB_SCALING                      31
+#define TPC_PUSCH                       32
+#define TPC_PUCCH                       33
+#define PUCCH_RESOURCE_IND              34
+#define PDSCH_TO_HARQ_FEEDBACK_TIME_IND 35
+#define SRS_RESOURCE_IND                36
+#define PRECOD_NBR_LAYERS               37
+#define ANTENNA_PORTS                   38
+#define TCI                             39
+#define SRS_REQUEST                     40
+#define TPC_CMD                         41
+#define CSI_REQUEST                     42
+#define CBGTI                           43
+#define CBGFI                           44
+#define PTRS_DMRS                       45
+#define BETA_OFFSET_IND                 46
+#define DMRS_SEQ_INI                    47
+#define UL_SCH_IND                      48
+#define PADDING_NR_DCI                  49
+#define SUL_IND_0_0                     50
+#define RA_PREAMBLE_INDEX               51
+#define SUL_IND_1_0                     52
+#define SS_PBCH_INDEX                   53
+#define PRACH_MASK_INDEX                54
+#define RESERVED_NR_DCI                 55
+
 /*@}*/
 #endif /*__LAYER2_MAC_DEFS_H__ */
diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h
index 65f9a325fd8..36d285e320e 100755
--- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h
+++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h
@@ -20,7 +20,7 @@
  */
 
 /* \file proto.h
- * \brief MAC functions prototypes for eNB and UE
+ * \brief MAC functions prototypes for gNB and UE
  * \author R. Knopp, K.H. HSU
  * \date 2018
  * \version 0.1
@@ -35,7 +35,9 @@
 
 #include "mac_defs.h"
 #include "mac.h"
-#include <openair1/PHY/defs_nr_UE.h>
+#include "PHY/defs_nr_UE.h"
+#include "RRC/NR_UE/rrc_defs.h"
+
 
 /**\brief decode mib pdu in NR_UE, from if_module ul_ind with P7 tx_ind message
    \param module_id      module id
@@ -47,7 +49,6 @@
    \param pdu_length     length of pdu
    \param cell_id        cell id */
 int8_t nr_ue_decode_mib(
-    UE_nr_rxtx_proc_t *proc,
     module_id_t module_id, 
     int cc_id, 
     uint8_t gNB_index, 
@@ -63,20 +64,18 @@ int8_t nr_ue_decode_mib(
    \param cc_id                     component carrier id
    \param gNB_index                 gNB index
    \param mibP                      pointer to RRC message MIB
-   \param mac_cell_group_configP    pointer to RRC message MAC-related in cell group config 
-   \param phy_cell_group_configP    pointer to RRC message PHY-related in cell group config
+   \param sccP                      pointer to ServingCellConfigCommon structure,
    \param spcell_configP            pointer to RRC message serving cell config*/
-int nr_rrc_mac_config_req_ue( 
-    module_id_t module_id, 
-    int cc_id, 
-    uint8_t gNB_index, 
-    NR_MIB_t *mibP, 
-    NR_MAC_CellGroupConfig_t *mac_cell_group_configP, 
-    NR_PhysicalCellGroupConfig_t *phy_cell_group_configP, 
-    NR_SpCellConfig_t *spcell_configP );
-   
+int nr_rrc_mac_config_req_ue(
+    module_id_t                     module_id,
+    int                             cc_idP,
+    uint8_t                         gNB_index,
+    NR_MIB_t                        *mibP,
+    //NR_ServingCellConfigCommon_t    *sccP,
+    NR_SpCellConfig_t               *spCell_ConfigP);
+
 /**\brief initialization NR UE MAC instance(s), total number of MAC instance based on NB_NR_UE_MAC_INST*/
-int nr_l2_init_ue(void);
+NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst);
 
 /**\brief fetch MAC instance by module_id, within 0 - (NB_NR_UE_MAC_INST-1)
    \param module_id index of MAC instance(s)*/
@@ -116,7 +115,8 @@ uint32_t ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP,
 
 int8_t nr_ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe);
 
-int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format);
+int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr_dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format);
+int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_index,fapi_nr_dci_indication_pdu_t *dci);
 
 uint32_t get_ssb_frame(uint32_t test);
 uint32_t get_ssb_slot(uint32_t ssb_index);
@@ -130,38 +130,45 @@ uint32_t mr_ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, uint8_t
 @param module_idP Instance id of UE in machine
 @param CC_id Component Carrier index
 @param frameP Current Rx frame
-@param ttiP Current Rx tti subframe
+@param slotP Current Rx slot
 @param pdu Pointer to the MAC PDU
 @param pdu_len Length of the MAC PDU
-@param eNB_id Index of eNB that UE is attached to
+@param gNB_id Index of gNB that UE is attached to
+@param ul_time_alignment of struct handling the timing advance parameters
 @returns void
 */
-void nr_ue_send_sdu(module_id_t module_idP,uint8_t CC_id, frame_t frameP, uint8_t ttiP,
-                    uint8_t * pdu, uint16_t pdu_len, uint8_t gNB_index, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment);
-
-void nr_ue_process_mac_pdu(
-    module_id_t module_idP,
-    uint8_t CC_id,
-    frame_t frameP,
-    uint8_t *pduP, 
-    uint16_t mac_pdu_len,
-    uint8_t eNB_index,
-    NR_UL_TIME_ALIGNMENT_t *ul_time_alignment);
+void nr_ue_send_sdu(module_id_t module_idP, 
+                    uint8_t CC_id,
+                    frame_t frameP,
+                    int slotP,
+                    uint8_t * pdu,
+                    uint16_t pdu_len,
+                    uint8_t gNB_index,
+                    NR_UL_TIME_ALIGNMENT_t *ul_time_alignment);
+
+void nr_ue_process_mac_pdu(module_id_t module_idP,
+                           uint8_t CC_id,
+                           frame_t frameP,
+                           uint8_t *pduP, 
+                           uint16_t mac_pdu_len,
+                           uint8_t gNB_index,
+                           NR_UL_TIME_ALIGNMENT_t *ul_time_alignment);
 
 int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_indication_t *dci_ind, void *pduP, uint32_t pdu_len);
 
-uint8_t nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
-           sub_frame_t subframe, uint8_t eNB_index,
-           uint8_t *ulsch_buffer, uint16_t buflen, uint8_t *access_mode);
-
-uint16_t
-nr_generate_ulsch_pdu(uint8_t *mac_pdu,
-					  uint8_t *sdus_payload,
-                      uint8_t num_sdus,
-                      uint16_t *sdu_lengths,
-                      uint8_t *sdu_lcids,
-                      uint16_t *crnti,
-                      uint16_t buflen);
+void ue_dci_configuration(NR_UE_MAC_INST_t *mac,fapi_nr_dl_config_request_t *dl_config,int frame,int slot);
+
+void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
+                         int dci_format,
+                         uint8_t dci_length,
+                         uint16_t rnti,
+                         uint64_t *dci_pdu,
+                         nr_dci_pdu_rel15_t *nr_pdci_info_extracted);
+
+
+int set_tdd_config_nr_ue(fapi_nr_config_request_t *cfg, int mu,
+                         int nrofDownlinkSlots, int nrofDownlinkSymbols,
+                         int nrofUplinkSlots,   int nrofUplinkSymbols);
 
 #endif
 /** @}*/
diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
index c29f75cd012..61f9ab601e9 100644
--- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
+++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
@@ -43,8 +43,7 @@
 
 static NR_UE_MAC_INST_t *nr_ue_mac_inst; 
 
-int
-nr_l2_init_ue(void)
+NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst)
 {
     //LOG_I(MAC, "[MAIN] MAC_INIT_GLOBAL_PARAM IN...\n");
 
@@ -52,17 +51,20 @@ nr_l2_init_ue(void)
     
     //init mac here
     nr_ue_mac_inst = (NR_UE_MAC_INST_t *)malloc(sizeof(NR_UE_MAC_INST_t)*NB_NR_UE_MAC_INST);
-    
-    if (IS_SOFTMODEM_NOS1){
+    if (rrc_inst) {
+      nr_rrc_mac_config_req_ue(0,0,0,NULL,rrc_inst->cell_group_config->spCellConfig);
+      
+      if (IS_SOFTMODEM_NOS1){
         if (rlc_module_init(0) != 0) {
-    		LOG_I(RLC, "Problem at RLC initiation \n");
+	  LOG_I(RLC, "Problem at RLC initiation \n");
     	}
     	pdcp_layer_init();
     	nr_ip_over_LTE_DRB_preconfiguration();
+      }
     }
+    else LOG_I(MAC,"Running without RRC instance\n");
 
-
-    return (1);
+    return (nr_ue_mac_inst);
 }
 
 NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id){
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
index 2df700e031a..58b312038a2 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
@@ -33,8 +33,11 @@
 
 /* MAC related headers */
 #include "mac_proto.h"
+#include "mac_defs.h"
 #include "LAYER2/NR_MAC_COMMON/nr_mac.h"
 #include "mac_extern.h"
+#include "common/utils/nr/nr_common.h"
+
 //#include "LAYER2/MAC/mac_vars.h" // TODO Note that mac_vars.h is not NR specific and this should be updated
                                  // also, the use of the same should be updated in nr-softmodem and nr-uesoftmodem
 
@@ -60,186 +63,185 @@
 //int mbms_rab_id = 2047;
 
 //#define ENABLE_MAC_PAYLOAD_DEBUG 1
+#define DEBUG_EXTRACT_DCI 1
 
 extern void mac_rlc_data_ind     (
-  const module_id_t         module_idP,
-  const rnti_t              rntiP,
-  const eNB_index_t         eNB_index,
-  const frame_t             frameP,
-  const eNB_flag_t          enb_flagP,
-  const MBMS_flag_t         MBMS_flagP,
-  const logical_chan_id_t   channel_idP,
-  char                     *buffer_pP,
-  const tb_size_t           tb_sizeP,
-  num_tb_t                  num_tbP,
-  crc_t                    *crcs_pP);
+				  const module_id_t         module_idP,
+				  const rnti_t              rntiP,
+				  const eNB_index_t         eNB_index,
+				  const frame_t             frameP,
+				  const eNB_flag_t          enb_flagP,
+				  const MBMS_flag_t         MBMS_flagP,
+				  const logical_chan_id_t   channel_idP,
+				  char                     *buffer_pP,
+				  const tb_size_t           tb_sizeP,
+				  num_tb_t                  num_tbP,
+				  crc_t                    *crcs_pP);
 
 
 uint32_t get_ssb_slot(uint32_t ssb_index){
-    //  this function now only support f <= 3GHz
-    return ssb_index & 0x3 ;
+  //  this function now only support f <= 3GHz
+  return ssb_index & 0x3 ;
 
-    //  return first_symbol(case, freq, ssb_index) / 14
+  //  return first_symbol(case, freq, ssb_index) / 14
 }
 
 uint8_t table_9_2_2_1[16][8]={
-{0,12,2, 0, 0,3,0,0},
-{0,12,2, 0, 0,4,8,0},
-{0,12,2, 3, 0,4,8,0},
-{1,10,4, 0, 0,6,0,0},
-{1,10,4, 0, 0,3,6,9},
-{1,10,4, 2, 0,3,6,9},
-{1,10,4, 4, 0,3,6,9},
-{1,4, 10,0, 0,6,0,0},
-{1,4, 10,0, 0,3,6,9},
-{1,4, 10,2, 0,3,6,9},
-{1,4, 10,4, 0,3,6,9},
-{1,0, 14,0, 0,6,0,0},
-{1,0, 14,0, 0,3,6,9},
-{1,0, 14,2, 0,3,6,9},
-{1,0, 14,4, 0,3,6,9},
-{1,0, 14,26,0,3,0,0}
+  {0,12,2, 0, 0,3,0,0},
+  {0,12,2, 0, 0,4,8,0},
+  {0,12,2, 3, 0,4,8,0},
+  {1,10,4, 0, 0,6,0,0},
+  {1,10,4, 0, 0,3,6,9},
+  {1,10,4, 2, 0,3,6,9},
+  {1,10,4, 4, 0,3,6,9},
+  {1,4, 10,0, 0,6,0,0},
+  {1,4, 10,0, 0,3,6,9},
+  {1,4, 10,2, 0,3,6,9},
+  {1,4, 10,4, 0,3,6,9},
+  {1,0, 14,0, 0,6,0,0},
+  {1,0, 14,0, 0,3,6,9},
+  {1,0, 14,2, 0,3,6,9},
+  {1,0, 14,4, 0,3,6,9},
+  {1,0, 14,26,0,3,0,0}
 };
 
 
 int8_t nr_ue_process_dlsch(module_id_t module_id,
-		                   int cc_id,
-						   uint8_t gNB_index,
-						   fapi_nr_dci_indication_t *dci_ind,
-						   void *pduP,
-						   uint32_t pdu_len)
+			   int cc_id,
+			   uint8_t gNB_index,
+			   fapi_nr_dci_indication_t *dci_ind,
+			   void *pduP,
+			   uint32_t pdu_len)
 {
-    NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
-    fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request;
-    //fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request;
-    nr_phy_config_t *phy_config = &mac->phy_config;
-
-    //ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti;
-    // First we need to verify if DCI ind contains a ul-sch to be perfomred. If it does, we will handle a PUSCH in the UL_CONFIG_REQ.
+  NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
+  fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request;
+  //fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request;
+  nr_phy_config_t *phy_config = &mac->phy_config;
+
+  //ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti;
+  // First we need to verify if DCI ind contains a ul-sch to be perfomred. If it does, we will handle a PUSCH in the UL_CONFIG_REQ.
+  ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUCCH;
+  for (int i=0; i<10; i++) {
+    if(dci_ind!=NULL){
+      if (dci_ind->dci_list[i].dci_format < 2) ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
+    }
+  }
+  if (ul_config->ul_config_list[ul_config->number_pdus].pdu_type == FAPI_NR_UL_CONFIG_TYPE_PUSCH) {
+    // fill in the elements in config request inside P5 message
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.bandwidth_part_ind = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.number_rbs = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.start_rb = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.frame_offset = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.number_symbols = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.start_symbol = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.pusch_freq_hopping = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.mcs = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.ndi = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.rv = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.accumulated_delta_PUSCH = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.absolute_delta_PUSCH = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.tpmi = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.n_dmrs_cdm_groups = 0;
+    for (int i=0;i<4;i++) ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.dmrs_ports[i]=0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.n_front_load_symb = 0;
+    //ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.srs_config = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.csi_reportTriggerSize = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.maxCodeBlockGroupsPerTransportBlock = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.ptrs_dmrs_association_port = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.beta_offset_ind = 0;
+  } else { // If DCI ind is not format 0_0 or 0_1, we will handle a PUCCH in the UL_CONFIG_REQ
     ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUCCH;
-    for (int i=0; i<10; i++) {
-    	if(dci_ind!=NULL){
-    		if (dci_ind->dci_list[i].dci_format < 2) ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
-    	}
+    // If we handle PUCCH common
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.format              = table_9_2_2_1[phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_resource_common][0];              /* format   0    1    2    3    4    */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.initialCyclicShift  = table_9_2_2_1[phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_resource_common][4];  /*          x    x                   */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSymbols         = table_9_2_2_1[phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_resource_common][2];         /*          x    x    x    x    x    */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.startingSymbolIndex = table_9_2_2_1[phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_resource_common][1]; /*          x    x    x    x    x    */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.timeDomainOCC = 0;       /*               x                   */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofPRBs = 0;            /*                    x    x         */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.startingPRB         = table_9_2_2_1[phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_resource_common][3];         /*                                     maxNrofPhysicalResourceBlocks  = 275 */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.occ_length = 0;          /*                              x    */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.occ_Index = 0;           /*                              x    */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.intraSlotFrequencyHopping = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.secondHopPRB = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pucch_GroupHopping  = phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_group_hopping;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.hoppingId           = phy_config->config_req.ul_bwp_common.pucch_config_common.hopping_id;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_nominal          = phy_config->config_req.ul_bwp_common.pucch_config_common.p0_nominal;
+    for (int i=0;i<NUMBER_PUCCH_FORMAT_NR;i++) ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.deltaF_PUCCH_f[i] = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Id = 0;     /* INTEGER (1..8)     */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Value = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.twoPUCCH_PC_AdjustmentStates = 0;
+    // If we handle PUCCH dedicated
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.format              = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].format;              /* format   0    1    2    3    4    */
+    switch (ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.format){
+    case pucch_format1_nr:
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.inter_slot_frequency_hopping;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS            = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.additional_dmrs;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate               = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.max_code_rate;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots                 = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.number_of_slots;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK                   = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.pi2bpsk;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI  = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.simultaneous_harq_ack_csi;
+      break;
+    case pucch_format2_nr:
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.inter_slot_frequency_hopping;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS            = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.additional_dmrs;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate               = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.max_code_rate;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots                 = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.number_of_slots;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK                   = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.pi2bpsk;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI  = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.simultaneous_harq_ack_csi;
+      break;
+    case pucch_format3_nr:
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.inter_slot_frequency_hopping;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS            = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.additional_dmrs;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate               = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.max_code_rate;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots                 = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.number_of_slots;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK                   = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.pi2bpsk;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI  = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.simultaneous_harq_ack_csi;
+      break;
+    case pucch_format4_nr:
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.inter_slot_frequency_hopping;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS            = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.additional_dmrs;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate               = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.max_code_rate;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots                 = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.number_of_slots;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK                   = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.pi2bpsk;
+      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI  = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.simultaneous_harq_ack_csi;
+      break;
+    default:
+      break;
     }
-    if (ul_config->ul_config_list[ul_config->number_pdus].pdu_type == FAPI_NR_UL_CONFIG_TYPE_PUSCH) {
-        // fill in the elements in config request inside P5 message
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.bandwidth_part_ind = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.number_rbs = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.start_rb = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.frame_offset = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.number_symbols = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.start_symbol = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.pusch_freq_hopping = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.mcs = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.ndi = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.rv = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.harq_process_nbr = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.accumulated_delta_PUSCH = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.absolute_delta_PUSCH = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.n_layers = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.tpmi = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.n_dmrs_cdm_groups = 0;
-      for (int i=0;i<4;i++) ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.dmrs_ports[i]=0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.n_front_load_symb = 0;
-      //ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.srs_config = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.csi_reportTriggerSize = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.maxCodeBlockGroupsPerTransportBlock = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.ptrs_dmrs_association_port = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15.beta_offset_ind = 0;
-    } else { // If DCI ind is not format 0_0 or 0_1, we will handle a PUCCH in the UL_CONFIG_REQ
-      ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUCCH;
-      // If we handle PUCCH common
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.format              = table_9_2_2_1[phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_resource_common][0];              /* format   0    1    2    3    4    */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.initialCyclicShift  = table_9_2_2_1[phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_resource_common][4];  /*          x    x                   */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSymbols         = table_9_2_2_1[phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_resource_common][2];         /*          x    x    x    x    x    */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.startingSymbolIndex = table_9_2_2_1[phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_resource_common][1]; /*          x    x    x    x    x    */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.timeDomainOCC = 0;       /*               x                   */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofPRBs = 0;            /*                    x    x         */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.startingPRB         = table_9_2_2_1[phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_resource_common][3];         /*                                     maxNrofPhysicalResourceBlocks  = 275 */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.occ_length = 0;          /*                              x    */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.occ_Index = 0;           /*                              x    */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.intraSlotFrequencyHopping = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.secondHopPRB = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pucch_GroupHopping  = phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_group_hopping;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.hoppingId           = phy_config->config_req.ul_bwp_common.pucch_config_common.hopping_id;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_nominal          = phy_config->config_req.ul_bwp_common.pucch_config_common.p0_nominal;
-      for (int i=0;i<NUMBER_PUCCH_FORMAT_NR;i++) ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.deltaF_PUCCH_f[i] = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Id = 0;     /* INTEGER (1..8)     */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Value = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.twoPUCCH_PC_AdjustmentStates = 0;
-      // If we handle PUCCH dedicated
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.format              = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].format;              /* format   0    1    2    3    4    */
-      switch (ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.format){
-        case pucch_format1_nr:
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.inter_slot_frequency_hopping;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS            = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.additional_dmrs;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate               = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.max_code_rate;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots                 = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.number_of_slots;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK                   = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.pi2bpsk;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI  = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format1.simultaneous_harq_ack_csi;
-        break;
-        case pucch_format2_nr:
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.inter_slot_frequency_hopping;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS            = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.additional_dmrs;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate               = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.max_code_rate;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots                 = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.number_of_slots;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK                   = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.pi2bpsk;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI  = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format2.simultaneous_harq_ack_csi;
-        break;
-        case pucch_format3_nr:
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.inter_slot_frequency_hopping;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS            = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.additional_dmrs;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate               = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.max_code_rate;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots                 = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.number_of_slots;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK                   = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.pi2bpsk;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI  = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format3.simultaneous_harq_ack_csi;
-        break;
-        case pucch_format4_nr:
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.interslotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.inter_slot_frequency_hopping;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.additionalDMRS            = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.additional_dmrs;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.maxCodeRate               = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.max_code_rate;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSlots                 = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.number_of_slots;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pi2PBSK                   = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.pi2bpsk;
-            ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.simultaneousHARQ_ACK_CSI  = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.format4.simultaneous_harq_ack_csi;
-        break;
-        default:
-        break;
-      }
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.initialCyclicShift        = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].initial_cyclic_shift;  /*          x    x                   */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSymbols               = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].number_of_symbols;         /*          x    x    x    x    x    */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.startingSymbolIndex       = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].starting_symbol_index; /*          x    x    x    x    x    */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.timeDomainOCC             = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].time_domain_occ;       /*               x                   */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofPRBs                  = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].number_of_prbs;            /*                    x    x         */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.startingPRB               = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].starting_prb;         /*                                     maxNrofPhysicalResourceBlocks  = 275 */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.occ_length                = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].occ_length;          /*                              x    */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.occ_Index                 = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].occ_index;           /*                              x    */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.intraSlotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].intra_slot_frequency_hopping;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.secondHopPRB              = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].second_hop_prb;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pucch_GroupHopping        = phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_group_hopping;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.hoppingId                 = phy_config->config_req.ul_bwp_common.pucch_config_common.hopping_id;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_nominal                = phy_config->config_req.ul_bwp_common.pucch_config_common.p0_nominal;
-      for (int i=0;i<NUMBER_PUCCH_FORMAT_NR; i++) ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.deltaF_PUCCH_f[i] = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Id = 0;     /* INTEGER (1..8)     */
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Value = 0;
-      ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.twoPUCCH_PC_AdjustmentStates = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.initialCyclicShift        = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].initial_cyclic_shift;  /*          x    x                   */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofSymbols               = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].number_of_symbols;         /*          x    x    x    x    x    */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.startingSymbolIndex       = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].starting_symbol_index; /*          x    x    x    x    x    */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.timeDomainOCC             = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].time_domain_occ;       /*               x                   */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.nrofPRBs                  = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].number_of_prbs;            /*                    x    x         */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.startingPRB               = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].starting_prb;         /*                                     maxNrofPhysicalResourceBlocks  = 275 */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.occ_length                = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].occ_length;          /*                              x    */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.occ_Index                 = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].occ_index;           /*                              x    */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.intraSlotFrequencyHopping = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].intra_slot_frequency_hopping;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.secondHopPRB              = phy_config->config_req.ul_bwp_dedicated.pucch_config_dedicated.multi_csi_pucch_resources[0].second_hop_prb;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.pucch_GroupHopping        = phy_config->config_req.ul_bwp_common.pucch_config_common.pucch_group_hopping;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.hoppingId                 = phy_config->config_req.ul_bwp_common.pucch_config_common.hopping_id;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_nominal                = phy_config->config_req.ul_bwp_common.pucch_config_common.p0_nominal;
+    for (int i=0;i<NUMBER_PUCCH_FORMAT_NR; i++) ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.deltaF_PUCCH_f[i] = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Id = 0;     /* INTEGER (1..8)     */
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.p0_PUCCH_Value = 0;
+    ul_config->ul_config_list[ul_config->number_pdus].pucch_config_pdu.twoPUCCH_PC_AdjustmentStates = 0;
 
-    }
-    if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){
-        mac->if_module->scheduled_response(&mac->scheduled_response);
-    }
-    return 0;
+  }
+  if(mac->if_module != NULL && mac->if_module->scheduled_response != NULL){
+    mac->if_module->scheduled_response(&mac->scheduled_response);
+  }
+  return 0;
 }
 
-
-int8_t nr_ue_decode_mib(UE_nr_rxtx_proc_t *proc,
-                        module_id_t module_id,
+int8_t nr_ue_decode_mib(module_id_t module_id,
                         int cc_id,
                         uint8_t gNB_index,
                         uint8_t extra_bits,	//	8bits 38.212 c7.1.1
@@ -248,490 +250,1061 @@ int8_t nr_ue_decode_mib(UE_nr_rxtx_proc_t *proc,
                         void *pduP,
                         uint16_t cell_id)
 {
-    LOG_I(MAC,"[L2][MAC] decode mib\n");
+  LOG_I(MAC,"[L2][MAC] decode mib\n");
 
-	NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
+  NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
 
-    nr_mac_rrc_data_ind_ue( module_id, cc_id, gNB_index, NR_BCCH_BCH, (uint8_t *) pduP, 3 );    //  fixed 3 bytes MIB PDU
+  nr_mac_rrc_data_ind_ue( module_id, cc_id, gNB_index, NR_BCCH_BCH, (uint8_t *) pduP, 3 );    //  fixed 3 bytes MIB PDU
     
-    AssertFatal(mac->mib != NULL, "nr_ue_decode_mib() mac->mib == NULL\n");
-    //if(mac->mib != NULL){
-	    uint16_t frame = (mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused);
-	    uint16_t frame_number_4lsb = 0;
-      for (int i=0; i<4; i++)
-        frame_number_4lsb |= ((extra_bits>>i)&1)<<(3-i);
-	    uint8_t half_frame_bit = ( extra_bits >> 4 ) & 0x1;               //	extra bits[4]
-	    uint8_t ssb_subcarrier_offset_msb = ( extra_bits >> 5 ) & 0x1;    //	extra bits[5]
-	    
-	    uint8_t ssb_subcarrier_offset = (uint8_t)mac->mib->ssb_SubcarrierOffset;
-
-	    //uint32_t ssb_index = 0;    //  TODO: ssb_index should obtain from L1 in case Lssb != 64
-
-	    frame = frame << 4;
-	    frame = frame | frame_number_4lsb;
-
-	    if(ssb_length == 64){
-	    	ssb_index = ssb_index & (( extra_bits >> 2 ) & 0x1C );    //	{ extra_bits[5:7], ssb_index[2:0] }
-	    }else{
-			if(ssb_subcarrier_offset_msb){
-			    ssb_subcarrier_offset = ssb_subcarrier_offset | 0x10;
-			}
-	    }
+  AssertFatal(mac->mib != NULL, "nr_ue_decode_mib() mac->mib == NULL\n");
+  //if(mac->mib != NULL){
+  uint16_t frame = (mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused);
+  uint16_t frame_number_4lsb = 0;
+  for (int i=0; i<4; i++)
+    frame_number_4lsb |= ((extra_bits>>i)&1)<<(3-i);
+  uint8_t half_frame_bit = ( extra_bits >> 4 ) & 0x1;               //	extra bits[4]
+  uint8_t ssb_subcarrier_offset_msb = ( extra_bits >> 5 ) & 0x1;    //	extra bits[5]
+  uint8_t ssb_subcarrier_offset = (uint8_t)mac->mib->ssb_SubcarrierOffset;
+
+  //uint32_t ssb_index = 0;    //  TODO: ssb_index should obtain from L1 in case Lssb != 64
+
+  frame = frame << 4;
+  frame = frame | frame_number_4lsb;
+
+  if(ssb_length == 64){
+    ssb_index = ssb_index & (( extra_bits >> 2 ) & 0x1C );    //	{ extra_bits[5:7], ssb_index[2:0] }
+  }else{
+    if(ssb_subcarrier_offset_msb){
+      ssb_subcarrier_offset = ssb_subcarrier_offset | 0x10;
+    }
+  }
 
 #ifdef DEBUG_MIB
-		LOG_I(MAC,"system frame number(6 MSB bits): %d\n",  mac->mib->systemFrameNumber.buf[0]);
-		LOG_I(MAC,"system frame number(with LSB): %d\n", (int)frame);
-		LOG_I(MAC,"subcarrier spacing (0=15or60, 1=30or120): %d\n", (int)mac->mib->subCarrierSpacingCommon);
-		LOG_I(MAC,"ssb carrier offset(with MSB):  %d\n", (int)ssb_subcarrier_offset);
-		LOG_I(MAC,"dmrs type A position (0=pos2,1=pos3): %d\n", (int)mac->mib->dmrs_TypeA_Position);
-		LOG_I(MAC,"pdcch config sib1:             %d\n", (int)mac->mib->pdcch_ConfigSIB1);
-		LOG_I(MAC,"cell barred (0=barred,1=notBarred): %d\n", (int)mac->mib->cellBarred);
-		LOG_I(MAC,"intra frequency reselection (0=allowed,1=notAllowed): %d\n", (int)mac->mib->intraFreqReselection);
-		LOG_I(MAC,"half frame bit(extra bits):    %d\n", (int)half_frame_bit);
-		LOG_I(MAC,"ssb index(extra bits):         %d\n", (int)ssb_index);
+  LOG_I(MAC,"system frame number(6 MSB bits): %d\n",  mac->mib->systemFrameNumber.buf[0]);
+  LOG_I(MAC,"system frame number(with LSB): %d\n", (int)frame);
+  LOG_I(MAC,"subcarrier spacing (0=15or60, 1=30or120): %d\n", (int)mac->mib->subCarrierSpacingCommon);
+  LOG_I(MAC,"ssb carrier offset(with MSB):  %d\n", (int)ssb_subcarrier_offset);
+  LOG_I(MAC,"dmrs type A position (0=pos2,1=pos3): %d\n", (int)mac->mib->dmrs_TypeA_Position);
+  LOG_I(MAC,"pdcch config sib1:             %d\n", (int)mac->mib->pdcch_ConfigSIB1);
+  LOG_I(MAC,"cell barred (0=barred,1=notBarred): %d\n", (int)mac->mib->cellBarred);
+  LOG_I(MAC,"intra frequency reselection (0=allowed,1=notAllowed): %d\n", (int)mac->mib->intraFreqReselection);
+  LOG_I(MAC,"half frame bit(extra bits):    %d\n", (int)half_frame_bit);
+  LOG_I(MAC,"ssb index(extra bits):         %d\n", (int)ssb_index);
 #endif
 
-	    subcarrier_spacing_t scs_ssb = scs_30kHz;      //  default for 
-        //const uint32_t scs_index = 0;
-        const uint32_t num_slot_per_frame = 20;
-	    subcarrier_spacing_t scs_pdcch;
+  subcarrier_spacing_t scs_ssb = scs_30kHz;      //  default for 
+  //const uint32_t scs_index = 0;
+  const uint32_t num_slot_per_frame = 20;
+  subcarrier_spacing_t scs_pdcch;
 
-        //  assume carrier frequency < 6GHz
-        if(mac->mib->subCarrierSpacingCommon == NR_MIB__subCarrierSpacingCommon_scs15or60){
-            scs_pdcch = scs_15kHz;
-        }else{  //NR_MIB__subCarrierSpacingCommon_scs30or120
-            scs_pdcch = scs_30kHz;
-        }
+  //  assume carrier frequency < 6GHz
+  if(mac->mib->subCarrierSpacingCommon == NR_MIB__subCarrierSpacingCommon_scs15or60){
+    scs_pdcch = scs_15kHz;
+  }else{  //NR_MIB__subCarrierSpacingCommon_scs30or120
+    scs_pdcch = scs_30kHz;
+  }
 
-	channel_bandwidth_t min_channel_bw = bw_10MHz;  //  deafult for testing
+  channel_bandwidth_t min_channel_bw = bw_10MHz;  //  deafult for testing
 	    
-        uint32_t is_condition_A = (ssb_subcarrier_offset == 0);   //  38.213 ch.13
-        frequency_range_t frequency_range = FR1;
-        uint32_t index_4msb = (mac->mib->pdcch_ConfigSIB1.controlResourceSetZero);
-        uint32_t index_4lsb = (mac->mib->pdcch_ConfigSIB1.searchSpaceZero);
-        int32_t num_rbs = -1;
-        int32_t num_symbols = -1;
-        int32_t rb_offset = -1;
-        //LOG_I(MAC,"<<<<<<<<<configSIB1 %d index_4msb %d index_4lsb %d scs_ssb %d scs_pdcch %d switch %d ",
-        //mac->mib->pdcch_ConfigSIB1,index_4msb,index_4lsb,scs_ssb,scs_pdcch, (scs_ssb << 5)|scs_pdcch);
-
-        //  type0-pdcch coreset
-	    switch( (scs_ssb << 5)|scs_pdcch ){
-            case (scs_15kHz << 5) | scs_15kHz :
-                AssertFatal(index_4msb < 15, "38.213 Table 13-1 4 MSB out of range\n");
-                mac->type0_pdcch_ss_mux_pattern = 1;
-                num_rbs     = table_38213_13_1_c2[index_4msb];
-                num_symbols = table_38213_13_1_c3[index_4msb];
-                rb_offset   = table_38213_13_1_c4[index_4msb];
-                break;
-
-	        case (scs_15kHz << 5) | scs_30kHz:
-                AssertFatal(index_4msb < 14, "38.213 Table 13-2 4 MSB out of range\n");
-                mac->type0_pdcch_ss_mux_pattern = 1;
-                num_rbs     = table_38213_13_2_c2[index_4msb];
-                num_symbols = table_38213_13_2_c3[index_4msb];
-                rb_offset   = table_38213_13_2_c4[index_4msb];
-                break;
+  uint32_t is_condition_A = (ssb_subcarrier_offset == 0);   //  38.213 ch.13
+  frequency_range_t frequency_range = FR1;
+  uint32_t index_4msb = (mac->mib->pdcch_ConfigSIB1.controlResourceSetZero);
+  uint32_t index_4lsb = (mac->mib->pdcch_ConfigSIB1.searchSpaceZero);
+  int32_t num_rbs = -1;
+  int32_t num_symbols = -1;
+  int32_t rb_offset = -1;
+  //LOG_I(MAC,"<<<<<<<<<configSIB1 %d index_4msb %d index_4lsb %d scs_ssb %d scs_pdcch %d switch %d ",
+  //mac->mib->pdcch_ConfigSIB1,index_4msb,index_4lsb,scs_ssb,scs_pdcch, (scs_ssb << 5)|scs_pdcch);
+
+  //  type0-pdcch coreset
+  switch( (scs_ssb << 5)|scs_pdcch ){
+  case (scs_15kHz << 5) | scs_15kHz :
+    AssertFatal(index_4msb < 15, "38.213 Table 13-1 4 MSB out of range\n");
+    mac->type0_pdcch_ss_mux_pattern = 1;
+    num_rbs     = table_38213_13_1_c2[index_4msb];
+    num_symbols = table_38213_13_1_c3[index_4msb];
+    rb_offset   = table_38213_13_1_c4[index_4msb];
+    break;
+
+  case (scs_15kHz << 5) | scs_30kHz:
+    AssertFatal(index_4msb < 14, "38.213 Table 13-2 4 MSB out of range\n");
+    mac->type0_pdcch_ss_mux_pattern = 1;
+    num_rbs     = table_38213_13_2_c2[index_4msb];
+    num_symbols = table_38213_13_2_c3[index_4msb];
+    rb_offset   = table_38213_13_2_c4[index_4msb];
+    break;
+
+  case (scs_30kHz << 5) | scs_15kHz:
+    if((min_channel_bw & bw_5MHz) | (min_channel_bw & bw_10MHz)){
+      AssertFatal(index_4msb < 9, "38.213 Table 13-3 4 MSB out of range\n");
+      mac->type0_pdcch_ss_mux_pattern = 1;
+      num_rbs     = table_38213_13_3_c2[index_4msb];
+      num_symbols = table_38213_13_3_c3[index_4msb];
+      rb_offset   = table_38213_13_3_c4[index_4msb];
+    }else if(min_channel_bw & bw_40MHz){
+      AssertFatal(index_4msb < 9, "38.213 Table 13-5 4 MSB out of range\n");
+      mac->type0_pdcch_ss_mux_pattern = 1;
+      num_rbs     = table_38213_13_5_c2[index_4msb];
+      num_symbols = table_38213_13_5_c3[index_4msb];
+      rb_offset   = table_38213_13_5_c4[index_4msb];
+    }else{ ; }
+
+    break;
+
+  case (scs_30kHz << 5) | scs_30kHz:
+    if((min_channel_bw & bw_5MHz) | (min_channel_bw & bw_10MHz)){
+      mac->type0_pdcch_ss_mux_pattern = 1;
+      num_rbs     = table_38213_13_4_c2[index_4msb];
+      num_symbols = table_38213_13_4_c3[index_4msb];
+      rb_offset   = table_38213_13_4_c4[index_4msb];
+      LOG_I(MAC,"<<<<<<<<<index_4msb %d num_rbs %d num_symb %d rb_offset %d\n",index_4msb,num_rbs,num_symbols,rb_offset );
+    }else if(min_channel_bw & bw_40MHz){
+      AssertFatal(index_4msb < 10, "38.213 Table 13-6 4 MSB out of range\n");
+      mac->type0_pdcch_ss_mux_pattern = 1;
+      num_rbs     = table_38213_13_6_c2[index_4msb];
+      num_symbols = table_38213_13_6_c3[index_4msb];
+      rb_offset   = table_38213_13_6_c4[index_4msb];
+    }else{ ; }
+    break;
+
+  case (scs_120kHz << 5) | scs_60kHz:
+    AssertFatal(index_4msb < 12, "38.213 Table 13-7 4 MSB out of range\n");
+    if(index_4msb & 0x7){
+      mac->type0_pdcch_ss_mux_pattern = 1;
+    }else if(index_4msb & 0x18){
+      mac->type0_pdcch_ss_mux_pattern = 2;
+    }else{ ; }
+
+    num_rbs     = table_38213_13_7_c2[index_4msb];
+    num_symbols = table_38213_13_7_c3[index_4msb];
+    if(!is_condition_A && (index_4msb == 8 || index_4msb == 10)){
+      rb_offset   = table_38213_13_7_c4[index_4msb] - 1;
+    }else{
+      rb_offset   = table_38213_13_7_c4[index_4msb];
+    }
+    break;
+
+  case (scs_120kHz << 5) | scs_120kHz:
+    AssertFatal(index_4msb < 8, "38.213 Table 13-8 4 MSB out of range\n");
+    if(index_4msb & 0x3){
+      mac->type0_pdcch_ss_mux_pattern = 1;
+    }else if(index_4msb & 0x0c){
+      mac->type0_pdcch_ss_mux_pattern = 3;
+    }
 
-            case (scs_30kHz << 5) | scs_15kHz:
-                if((min_channel_bw & bw_5MHz) | (min_channel_bw & bw_10MHz)){
-                    AssertFatal(index_4msb < 9, "38.213 Table 13-3 4 MSB out of range\n");
-                    mac->type0_pdcch_ss_mux_pattern = 1;
-                    num_rbs     = table_38213_13_3_c2[index_4msb];
-                    num_symbols = table_38213_13_3_c3[index_4msb];
-                    rb_offset   = table_38213_13_3_c4[index_4msb];
-                }else if(min_channel_bw & bw_40MHz){
-                    AssertFatal(index_4msb < 9, "38.213 Table 13-5 4 MSB out of range\n");
-                    mac->type0_pdcch_ss_mux_pattern = 1;
-                    num_rbs     = table_38213_13_5_c2[index_4msb];
-                    num_symbols = table_38213_13_5_c3[index_4msb];
-                    rb_offset   = table_38213_13_5_c4[index_4msb];
-                }else{ ; }
+    num_rbs     = table_38213_13_8_c2[index_4msb];
+    num_symbols = table_38213_13_8_c3[index_4msb];
+    if(!is_condition_A && (index_4msb == 4 || index_4msb == 6)){
+      rb_offset   = table_38213_13_8_c4[index_4msb] - 1;
+    }else{
+      rb_offset   = table_38213_13_8_c4[index_4msb];
+    }
+    break;
+
+  case (scs_240kHz << 5) | scs_60kHz:
+    AssertFatal(index_4msb < 4, "38.213 Table 13-9 4 MSB out of range\n");
+    mac->type0_pdcch_ss_mux_pattern = 1;
+    num_rbs     = table_38213_13_9_c2[index_4msb];
+    num_symbols = table_38213_13_9_c3[index_4msb];
+    rb_offset   = table_38213_13_9_c4[index_4msb];
+    break;
+
+  case (scs_240kHz << 5) | scs_120kHz:
+    AssertFatal(index_4msb < 8, "38.213 Table 13-10 4 MSB out of range\n");
+    if(index_4msb & 0x3){
+      mac->type0_pdcch_ss_mux_pattern = 1;
+    }else if(index_4msb & 0x0c){
+      mac->type0_pdcch_ss_mux_pattern = 2;
+    }
+    num_rbs     = table_38213_13_10_c2[index_4msb];
+    num_symbols = table_38213_13_10_c3[index_4msb];
+    if(!is_condition_A && (index_4msb == 4 || index_4msb == 6)){
+      rb_offset   = table_38213_13_10_c4[index_4msb]-1;
+    }else{
+      rb_offset   = table_38213_13_10_c4[index_4msb];
+    }
+                
+    break;
 
-                break;
+  default:
+    break;
+  }
 
-            case (scs_30kHz << 5) | scs_30kHz:
-                if((min_channel_bw & bw_5MHz) | (min_channel_bw & bw_10MHz)){
-                    mac->type0_pdcch_ss_mux_pattern = 1;
-                    num_rbs     = table_38213_13_4_c2[index_4msb];
-                    num_symbols = table_38213_13_4_c3[index_4msb];
-                    rb_offset   = table_38213_13_4_c4[index_4msb];
-                    LOG_I(MAC,"<<<<<<<<<index_4msb %d num_rbs %d num_symb %d rb_offset %d\n",index_4msb,num_rbs,num_symbols,rb_offset );
-                }else if(min_channel_bw & bw_40MHz){
-                    AssertFatal(index_4msb < 10, "38.213 Table 13-6 4 MSB out of range\n");
-                    mac->type0_pdcch_ss_mux_pattern = 1;
-                    num_rbs     = table_38213_13_6_c2[index_4msb];
-                    num_symbols = table_38213_13_6_c3[index_4msb];
-                    rb_offset   = table_38213_13_6_c4[index_4msb];
-                }else{ ; }
-                break;
+  AssertFatal(num_rbs != -1, "Type0 PDCCH coreset num_rbs undefined");
+  AssertFatal(num_symbols != -1, "Type0 PDCCH coreset num_symbols undefined");
+  AssertFatal(rb_offset != -1, "Type0 PDCCH coreset rb_offset undefined");
+        
+  //uint32_t cell_id = 0;   //  obtain from L1 later
+
+  //mac->type0_pdcch_dci_config.coreset.rb_start = rb_offset;
+  //mac->type0_pdcch_dci_config.coreset.rb_end = rb_offset + num_rbs - 1;
+  uint64_t mask = 0x0;
+  uint8_t i;
+  for(i=0; i<(num_rbs/6); ++i){   //  38.331 Each bit corresponds a group of 6 RBs
+    mask = mask >> 1;
+    mask = mask | 0x100000000000;
+  }
+  //LOG_I(MAC,">>>>>>>>mask %x num_rbs %d rb_offset %d\n", mask, num_rbs, rb_offset);
+  /*
+    mac->type0_pdcch_dci_config.coreset.frequency_domain_resource = mask;
+    mac->type0_pdcch_dci_config.coreset.rb_offset = rb_offset;  //  additional parameter other than coreset
+
+    //mac->type0_pdcch_dci_config.type0_pdcch_coreset.duration = num_symbols;
+    mac->type0_pdcch_dci_config.coreset.cce_reg_mapping_type = CCE_REG_MAPPING_TYPE_INTERLEAVED;
+    mac->type0_pdcch_dci_config.coreset.cce_reg_interleaved_reg_bundle_size = 6;   //  L 38.211 7.3.2.2
+    mac->type0_pdcch_dci_config.coreset.cce_reg_interleaved_interleaver_size = 2;  //  R 38.211 7.3.2.2
+    mac->type0_pdcch_dci_config.coreset.cce_reg_interleaved_shift_index = cell_id;
+    mac->type0_pdcch_dci_config.coreset.precoder_granularity = PRECODER_GRANULARITY_SAME_AS_REG_BUNDLE;
+    mac->type0_pdcch_dci_config.coreset.pdcch_dmrs_scrambling_id = cell_id;
+  */
 
-            case (scs_120kHz << 5) | scs_60kHz:
-                AssertFatal(index_4msb < 12, "38.213 Table 13-7 4 MSB out of range\n");
-                if(index_4msb & 0x7){
-                    mac->type0_pdcch_ss_mux_pattern = 1;
-                }else if(index_4msb & 0x18){
-                    mac->type0_pdcch_ss_mux_pattern = 2;
-                }else{ ; }
-
-                num_rbs     = table_38213_13_7_c2[index_4msb];
-                num_symbols = table_38213_13_7_c3[index_4msb];
-                if(!is_condition_A && (index_4msb == 8 || index_4msb == 10)){
-                    rb_offset   = table_38213_13_7_c4[index_4msb] - 1;
-                }else{
-                    rb_offset   = table_38213_13_7_c4[index_4msb];
-                }
-                break;
 
-            case (scs_120kHz << 5) | scs_120kHz:
-                AssertFatal(index_4msb < 8, "38.213 Table 13-8 4 MSB out of range\n");
-                if(index_4msb & 0x3){
-                    mac->type0_pdcch_ss_mux_pattern = 1;
-                }else if(index_4msb & 0x0c){
-                    mac->type0_pdcch_ss_mux_pattern = 3;
-                }
+  // type0-pdcch search space
+  float big_o;
+  float big_m;
+  uint32_t temp;
+  SFN_C_TYPE sfn_c=SFN_C_IMPOSSIBLE;   //  only valid for mux=1
+  uint32_t n_c=UINT_MAX;
+  uint32_t number_of_search_space_per_slot=UINT_MAX;
+  uint32_t first_symbol_index=UINT_MAX;
+  uint32_t search_space_duration;  //  element of search space
+  uint32_t coreset_duration;  //  element of coreset
+  //  38.213 table 10.1-1
+
+  /// MUX PATTERN 1
+  if(mac->type0_pdcch_ss_mux_pattern == 1 && frequency_range == FR1){
+    big_o = table_38213_13_11_c1[index_4lsb];
+    number_of_search_space_per_slot = table_38213_13_11_c2[index_4lsb];
+    big_m = table_38213_13_11_c3[index_4lsb];
+
+    temp = (uint32_t)(big_o*pow(2, scs_pdcch)) + (uint32_t)(ssb_index*big_m);
+    n_c = temp / num_slot_per_frame;
+    if((temp/num_slot_per_frame) & 0x1){
+      sfn_c = SFN_C_MOD_2_EQ_1;
+    }else{
+      sfn_c = SFN_C_MOD_2_EQ_0;
+    }
 
-                num_rbs     = table_38213_13_8_c2[index_4msb];
-                num_symbols = table_38213_13_8_c3[index_4msb];
-                if(!is_condition_A && (index_4msb == 4 || index_4msb == 6)){
-                    rb_offset   = table_38213_13_8_c4[index_4msb] - 1;
-                }else{
-                    rb_offset   = table_38213_13_8_c4[index_4msb];
-                }
-                break;
+    if((index_4lsb == 1 || index_4lsb == 3 || index_4lsb == 5 || index_4lsb == 7) && (ssb_index&1)){
+      first_symbol_index = num_symbols;
+    }else{
+      first_symbol_index = table_38213_13_11_c4[index_4lsb];
+    }
+    //  38.213 chapter 13: over two consecutive slots
+    search_space_duration = 2;
+  }
 
-            case (scs_240kHz << 5) | scs_60kHz:
-                AssertFatal(index_4msb < 4, "38.213 Table 13-9 4 MSB out of range\n");
-                mac->type0_pdcch_ss_mux_pattern = 1;
-                num_rbs     = table_38213_13_9_c2[index_4msb];
-                num_symbols = table_38213_13_9_c3[index_4msb];
-                rb_offset   = table_38213_13_9_c4[index_4msb];
-                break;
+  if(mac->type0_pdcch_ss_mux_pattern == 1 && frequency_range == FR2){
+    big_o = table_38213_13_12_c1[index_4lsb];
+    number_of_search_space_per_slot = table_38213_13_11_c2[index_4lsb];
+    big_m = table_38213_13_12_c3[index_4lsb];
+
+    if((index_4lsb == 1 || index_4lsb == 3 || index_4lsb == 5 || index_4lsb == 10) && (ssb_index&1)){
+      first_symbol_index = 7;
+    }else if((index_4lsb == 6 || index_4lsb == 7 || index_4lsb == 8 || index_4lsb == 11) && (ssb_index&1)){
+      first_symbol_index = num_symbols;
+    }else{
+      first_symbol_index = 0;
+    }
+    //  38.213 chapter 13: over two consecutive slots
+    search_space_duration = 2;
+  }
 
-            case (scs_240kHz << 5) | scs_120kHz:
-                AssertFatal(index_4msb < 8, "38.213 Table 13-10 4 MSB out of range\n");
-                if(index_4msb & 0x3){
-                    mac->type0_pdcch_ss_mux_pattern = 1;
-                }else if(index_4msb & 0x0c){
-                    mac->type0_pdcch_ss_mux_pattern = 2;
-                }
-                num_rbs     = table_38213_13_10_c2[index_4msb];
-                num_symbols = table_38213_13_10_c3[index_4msb];
-                if(!is_condition_A && (index_4msb == 4 || index_4msb == 6)){
-                    rb_offset   = table_38213_13_10_c4[index_4msb]-1;
-                }else{
-                    rb_offset   = table_38213_13_10_c4[index_4msb];
-                }
+  /// MUX PATTERN 2
+  if(mac->type0_pdcch_ss_mux_pattern == 2){
+            
+    if((scs_ssb == scs_120kHz) && (scs_pdcch == scs_60kHz)){
+      //  38.213 Table 13-13
+      AssertFatal(index_4lsb == 0, "38.213 Table 13-13 4 LSB out of range\n");
+      //  PDCCH monitoring occasions (SFN and slot number) same as SSB frame-slot
+      //                sfn_c = SFN_C_EQ_SFN_SSB;
+      n_c = get_ssb_slot(ssb_index);
+      switch(ssb_index & 0x3){    //  ssb_index(i) mod 4
+      case 0: 
+	first_symbol_index = 0;
+	break;
+      case 1: 
+	first_symbol_index = 1;
+	break;
+      case 2: 
+	first_symbol_index = 6;
+	break;
+      case 3: 
+	first_symbol_index = 7;
+	break;
+      default: break; 
+      }
                 
-                break;
+    }else if((scs_ssb == scs_240kHz) && (scs_pdcch == scs_120kHz)){
+      //  38.213 Table 13-14
+      AssertFatal(index_4lsb == 0, "38.213 Table 13-14 4 LSB out of range\n");
+      //  PDCCH monitoring occasions (SFN and slot number) same as SSB frame-slot
+      //                sfn_c = SFN_C_EQ_SFN_SSB;
+      n_c = get_ssb_slot(ssb_index);
+      switch(ssb_index & 0x7){    //  ssb_index(i) mod 8
+      case 0: 
+	first_symbol_index = 0;
+	break;
+      case 1: 
+	first_symbol_index = 1;
+	break;
+      case 2: 
+	first_symbol_index = 2;
+	break;
+      case 3: 
+	first_symbol_index = 3;
+	break;
+      case 4: 
+	first_symbol_index = 12;
+	n_c = get_ssb_slot(ssb_index) - 1;
+	break;
+      case 5: 
+	first_symbol_index = 13;
+	n_c = get_ssb_slot(ssb_index) - 1;
+	break;
+      case 6: 
+	first_symbol_index = 0;
+	break;
+      case 7: 
+	first_symbol_index = 1;
+	break;
+      default: break; 
+      }
+    }else{ ; }
+    //  38.213 chapter 13: over one slot
+    search_space_duration = 1;
+  }
 
-	        default:
-	            break;
-	    }
+  /// MUX PATTERN 3
+  if(mac->type0_pdcch_ss_mux_pattern == 3){
+    if((scs_ssb == scs_120kHz) && (scs_pdcch == scs_120kHz)){
+      //  38.213 Table 13-15
+      AssertFatal(index_4lsb == 0, "38.213 Table 13-15 4 LSB out of range\n");
+      //  PDCCH monitoring occasions (SFN and slot number) same as SSB frame-slot
+      //                sfn_c = SFN_C_EQ_SFN_SSB;
+      n_c = get_ssb_slot(ssb_index);
+      switch(ssb_index & 0x3){    //  ssb_index(i) mod 4
+      case 0: 
+	first_symbol_index = 4;
+	break;
+      case 1: 
+	first_symbol_index = 8;
+	break;
+      case 2: 
+	first_symbol_index = 2;
+	break;
+      case 3: 
+	first_symbol_index = 6;
+	break;
+      default: break; 
+      }
+    }else{ ; }
+    //  38.213 chapter 13: over one slot
+    search_space_duration = 1;
+  }
 
-        AssertFatal(num_rbs != -1, "Type0 PDCCH coreset num_rbs undefined");
-        AssertFatal(num_symbols != -1, "Type0 PDCCH coreset num_symbols undefined");
-        AssertFatal(rb_offset != -1, "Type0 PDCCH coreset rb_offset undefined");
-        
-        //uint32_t cell_id = 0;   //  obtain from L1 later
-
-        //mac->type0_pdcch_dci_config.coreset.rb_start = rb_offset;
-        //mac->type0_pdcch_dci_config.coreset.rb_end = rb_offset + num_rbs - 1;
-        uint64_t mask = 0x0;
-        uint8_t i;
-        for(i=0; i<(num_rbs/6); ++i){   //  38.331 Each bit corresponds a group of 6 RBs
-            mask = mask >> 1;
-            mask = mask | 0x100000000000;
-        }
-        //LOG_I(MAC,">>>>>>>>mask %x num_rbs %d rb_offset %d\n", mask, num_rbs, rb_offset);
-        mac->type0_pdcch_dci_config.coreset.frequency_domain_resource = mask;
-        mac->type0_pdcch_dci_config.coreset.rb_offset = rb_offset;  //  additional parameter other than coreset
-
-        //mac->type0_pdcch_dci_config.type0_pdcch_coreset.duration = num_symbols;
-        mac->type0_pdcch_dci_config.coreset.cce_reg_mapping_type = CCE_REG_MAPPING_TYPE_INTERLEAVED;
-        mac->type0_pdcch_dci_config.coreset.cce_reg_interleaved_reg_bundle_size = 6;   //  L 38.211 7.3.2.2
-        mac->type0_pdcch_dci_config.coreset.cce_reg_interleaved_interleaver_size = 2;  //  R 38.211 7.3.2.2
-        mac->type0_pdcch_dci_config.coreset.cce_reg_interleaved_shift_index = cell_id;
-        mac->type0_pdcch_dci_config.coreset.precoder_granularity = PRECODER_GRANULARITY_SAME_AS_REG_BUNDLE;
-        mac->type0_pdcch_dci_config.coreset.pdcch_dmrs_scrambling_id = cell_id;
-
-        // type0-pdcch search space
-        float big_o;
-        float big_m;
-        uint32_t temp;
-        SFN_C_TYPE sfn_c = SFN_C_IMPOSSIBLE; // only valid for mux=1
-        uint32_t n_c = UINT_MAX;
-        uint32_t number_of_search_space_per_slot = UINT_MAX;
-        uint32_t first_symbol_index = UINT_MAX;
-        uint32_t search_space_duration; // element of search space
-        uint32_t coreset_duration;      // element of coreset
+  AssertFatal(number_of_search_space_per_slot!=UINT_MAX,"");
+  coreset_duration = num_symbols * number_of_search_space_per_slot;
+  /*
+    mac->type0_pdcch_dci_config.number_of_candidates[0] = table_38213_10_1_1_c2[0];
+    mac->type0_pdcch_dci_config.number_of_candidates[1] = table_38213_10_1_1_c2[1];
+    mac->type0_pdcch_dci_config.number_of_candidates[2] = table_38213_10_1_1_c2[2];   //  CCE aggregation level = 4
+    mac->type0_pdcch_dci_config.number_of_candidates[3] = table_38213_10_1_1_c2[3];   //  CCE aggregation level = 8
+    mac->type0_pdcch_dci_config.number_of_candidates[4] = table_38213_10_1_1_c2[4];   //  CCE aggregation level = 16
+    mac->type0_pdcch_dci_config.duration = search_space_duration;
+    mac->type0_pdcch_dci_config.coreset.duration = coreset_duration;   //  coreset
+    AssertFatal(first_symbol_index!=UINT_MAX,"");
+    mac->type0_pdcch_dci_config.monitoring_symbols_within_slot = (0x3fff << first_symbol_index) & (0x3fff >> (14-coreset_duration-first_symbol_index)) & 0x3fff;
+  */
+  AssertFatal(sfn_c!=SFN_C_IMPOSSIBLE,"");
+  AssertFatal(n_c!=UINT_MAX,"");
+  mac->type0_pdcch_ss_sfn_c = sfn_c;
+  mac->type0_pdcch_ss_n_c = n_c;
         
-        //  38.213 table 10.1-1
-
-        /// MUX PATTERN 1
-        if(mac->type0_pdcch_ss_mux_pattern == 1 && frequency_range == FR1){
-            big_o = table_38213_13_11_c1[index_4lsb];
-            number_of_search_space_per_slot = table_38213_13_11_c2[index_4lsb];
-            big_m = table_38213_13_11_c3[index_4lsb];
-
-            temp = (uint32_t)(big_o*pow(2, scs_pdcch)) + (uint32_t)(ssb_index*big_m);
-            n_c = temp / num_slot_per_frame;
-            if((temp/num_slot_per_frame) & 0x1){
-                sfn_c = SFN_C_MOD_2_EQ_1;
-            }else{
-                sfn_c = SFN_C_MOD_2_EQ_0;
-            }
-
-            if((index_4lsb == 1 || index_4lsb == 3 || index_4lsb == 5 || index_4lsb == 7) && (ssb_index&1)){
-                first_symbol_index = num_symbols;
-            }else{
-                first_symbol_index = table_38213_13_11_c4[index_4lsb];
-            }
-            //  38.213 chapter 13: over two consecutive slots
-            search_space_duration = 2;
-        }
+  // fill in the elements in config request inside P5 message
+  mac->phy_config.Mod_id = module_id;
+  mac->phy_config.CC_id = cc_id;
 
-        if(mac->type0_pdcch_ss_mux_pattern == 1 && frequency_range == FR2){
-            big_o = table_38213_13_12_c1[index_4lsb];
-            number_of_search_space_per_slot = table_38213_13_11_c2[index_4lsb];
-            big_m = table_38213_13_12_c3[index_4lsb];
-
-            if((index_4lsb == 1 || index_4lsb == 3 || index_4lsb == 5 || index_4lsb == 10) && (ssb_index&1)){
-                first_symbol_index = 7;
-            }else if((index_4lsb == 6 || index_4lsb == 7 || index_4lsb == 8 || index_4lsb == 11) && (ssb_index&1)){
-                first_symbol_index = num_symbols;
-            }else{
-                first_symbol_index = 0;
-            }
-            //  38.213 chapter 13: over two consecutive slots
-            search_space_duration = 2;
-        }
+  mac->dl_config_request.sfn = frame;
+  mac->dl_config_request.slot = (ssb_index>>1) + ((ssb_index>>4)<<1); // not valid for 240kHz SCS 
 
-        /// MUX PATTERN 2
-        if(mac->type0_pdcch_ss_mux_pattern == 2){
-            
-            if((scs_ssb == scs_120kHz) && (scs_pdcch == scs_60kHz)){
-                //  38.213 Table 13-13
-                AssertFatal(index_4lsb == 0, "38.213 Table 13-13 4 LSB out of range\n");
-                //  PDCCH monitoring occasions (SFN and slot number) same as SSB frame-slot
-                //sfn_c = SFN_C_EQ_SFN_SSB;
-                n_c = get_ssb_slot(ssb_index);
-                switch(ssb_index & 0x3){    //  ssb_index(i) mod 4
-                    case 0: 
-                        first_symbol_index = 0;
-                        break;
-                    case 1: 
-                        first_symbol_index = 1;
-                        break;
-                    case 2: 
-                        first_symbol_index = 6;
-                        break;
-                    case 3: 
-                        first_symbol_index = 7;
-                        break;
-                    default: break; 
-                }
-                
-            }else if((scs_ssb == scs_240kHz) && (scs_pdcch == scs_120kHz)){
-                //  38.213 Table 13-14
-                AssertFatal(index_4lsb == 0, "38.213 Table 13-14 4 LSB out of range\n");
-                //  PDCCH monitoring occasions (SFN and slot number) same as SSB frame-slot
-                //sfn_c = SFN_C_EQ_SFN_SSB;
-                n_c = get_ssb_slot(ssb_index);
-                switch(ssb_index & 0x7){    //  ssb_index(i) mod 8
-                    case 0: 
-                        first_symbol_index = 0;
-                        break;
-                    case 1: 
-                        first_symbol_index = 1;
-                        break;
-                    case 2: 
-                        first_symbol_index = 2;
-                        break;
-                    case 3: 
-                        first_symbol_index = 3;
-                        break;
-                    case 4: 
-                        first_symbol_index = 12;
-                        n_c = get_ssb_slot(ssb_index) - 1;
-                        break;
-                    case 5: 
-                        first_symbol_index = 13;
-                        n_c = get_ssb_slot(ssb_index) - 1;
-                        break;
-                    case 6: 
-                        first_symbol_index = 0;
-                        break;
-                    case 7: 
-                        first_symbol_index = 1;
-                        break;
-                    default: break; 
-                }
-            }else{ ; }
-            //  38.213 chapter 13: over one slot
-            search_space_duration = 1;
-        }
-
-        /// MUX PATTERN 3
-        if(mac->type0_pdcch_ss_mux_pattern == 3){
-            if((scs_ssb == scs_120kHz) && (scs_pdcch == scs_120kHz)){
-                //  38.213 Table 13-15
-                AssertFatal(index_4lsb == 0, "38.213 Table 13-15 4 LSB out of range\n");
-                //  PDCCH monitoring occasions (SFN and slot number) same as SSB frame-slot
-                //sfn_c = SFN_C_EQ_SFN_SSB;
-                n_c = get_ssb_slot(ssb_index);
-                switch(ssb_index & 0x3){    //  ssb_index(i) mod 4
-                    case 0: 
-                        first_symbol_index = 4;
-                        break;
-                    case 1: 
-                        first_symbol_index = 8;
-                        break;
-                    case 2: 
-                        first_symbol_index = 2;
-                        break;
-                    case 3: 
-                        first_symbol_index = 6;
-                        break;
-                    default: break; 
-                }
-            }else{ ; }
-            //  38.213 chapter 13: over one slot
-            search_space_duration = 1;
-        }
+  //}
+  return 0;
 
-	AssertFatal(number_of_search_space_per_slot!=UINT_MAX,"");
-        coreset_duration = num_symbols * number_of_search_space_per_slot;
-
-        mac->type0_pdcch_dci_config.number_of_candidates[0] = table_38213_10_1_1_c2[0];
-        mac->type0_pdcch_dci_config.number_of_candidates[1] = table_38213_10_1_1_c2[1];
-        mac->type0_pdcch_dci_config.number_of_candidates[2] = table_38213_10_1_1_c2[2];   //  CCE aggregation level = 4
-        mac->type0_pdcch_dci_config.number_of_candidates[3] = table_38213_10_1_1_c2[3];   //  CCE aggregation level = 8
-        mac->type0_pdcch_dci_config.number_of_candidates[4] = table_38213_10_1_1_c2[4];   //  CCE aggregation level = 16
-        mac->type0_pdcch_dci_config.duration = search_space_duration;
-        mac->type0_pdcch_dci_config.coreset.duration = coreset_duration;   //  coreset
-	AssertFatal(first_symbol_index!=UINT_MAX,"");
-        mac->type0_pdcch_dci_config.monitoring_symbols_within_slot = (0x3fff << first_symbol_index) & (0x3fff >> (14-coreset_duration-first_symbol_index)) & 0x3fff;
-
-	AssertFatal(sfn_c!=SFN_C_IMPOSSIBLE,"");
-	AssertFatal(n_c!=UINT_MAX,"");
-        mac->type0_pdcch_ss_sfn_c = sfn_c;
-        mac->type0_pdcch_ss_n_c = n_c;
-        
-	    // fill in the elements in config request inside P5 message
-        mac->phy_config.Mod_id = module_id;
-        mac->phy_config.CC_id = cc_id;
-
-	    mac->phy_config.config_req.pbch_config.system_frame_number = frame;    //  after calculation
-	    mac->phy_config.config_req.pbch_config.subcarrier_spacing_common = mac->mib->subCarrierSpacingCommon;
-	    mac->phy_config.config_req.pbch_config.ssb_subcarrier_offset = ssb_subcarrier_offset;  //  after calculation
-	    mac->phy_config.config_req.pbch_config.dmrs_type_a_position = mac->mib->dmrs_TypeA_Position;
-	    mac->phy_config.config_req.pbch_config.pdcch_config_sib1 = (mac->mib->pdcch_ConfigSIB1.controlResourceSetZero) * 16 + (mac->mib->pdcch_ConfigSIB1.searchSpaceZero);
-	    mac->phy_config.config_req.pbch_config.cell_barred = mac->mib->cellBarred;
-	    mac->phy_config.config_req.pbch_config.intra_frequency_reselection = mac->mib->intraFreqReselection;
-	    mac->phy_config.config_req.pbch_config.half_frame_bit = half_frame_bit;
-	    mac->phy_config.config_req.pbch_config.ssb_index = ssb_index;
-	    mac->phy_config.config_req.config_mask |= FAPI_NR_CONFIG_REQUEST_MASK_PBCH;
-
-	    if(mac->if_module != NULL && mac->if_module->phy_config_request != NULL){
-		mac->if_module->phy_config_request(&mac->phy_config);
-	    }
-	    proc->decoded_frame_rx=frame;
-    //}
-    return 0;
 }
 
 
 //  TODO: change to UE parameter, scs: 15KHz, slot duration: 1ms
 uint32_t get_ssb_frame(uint32_t test){
-	return test;
+  return test;
 }
 
 // Performs :
 // 1. TODO: Call RRC for link status return to PHY
 // 2. TODO: Perform SR/BSR procedures for scheduling feedback
 // 3. TODO: Perform PHR procedures
-NR_UE_L2_STATE_t nr_ue_scheduler(
-    const module_id_t module_id,
-    const uint8_t gNB_index,
-    const int cc_id,
-    const frame_t rx_frame,
-    const slot_t rx_slot,
-    const int32_t ssb_index,
-    const frame_t tx_frame,
-    const slot_t tx_slot ){
-
-    uint32_t search_space_mask = 0;
-    NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
+NR_UE_L2_STATE_t nr_ue_scheduler(const module_id_t module_id,
+				 const uint8_t gNB_index,
+				 const int cc_id,
+				 const frame_t rx_frame,
+				 const slot_t rx_slot,
+				 const int32_t ssb_index,
+				 const frame_t tx_frame,
+				 const slot_t tx_slot ){
+
+  uint32_t search_space_mask = 0;
+  NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
+
+  fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request;
     
-    //  check type0 from 38.213 13
-    if(ssb_index != -1){
-
-        if(mac->type0_pdcch_ss_mux_pattern == 1){
-            //	38.213 chapter 13
-            if((mac->type0_pdcch_ss_sfn_c == SFN_C_MOD_2_EQ_0) && !(rx_frame & 0x1) && (rx_slot == mac->type0_pdcch_ss_n_c)){
-            	search_space_mask = search_space_mask | type0_pdcch;
-                mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.duration;
-            }
-            if((mac->type0_pdcch_ss_sfn_c == SFN_C_MOD_2_EQ_1) &&  (rx_frame & 0x1) && (rx_slot == mac->type0_pdcch_ss_n_c)){
-            	search_space_mask = search_space_mask | type0_pdcch;
-                mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.duration;
-            }
-        }
-        if(mac->type0_pdcch_ss_mux_pattern == 2){
-            //	38.213 Table 13-13, 13-14
-            if((rx_frame == get_ssb_frame(rx_frame)) && (rx_slot == mac->type0_pdcch_ss_n_c)){
-                search_space_mask = search_space_mask | type0_pdcch;
-                mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.duration;
-            }
-        }
-        if(mac->type0_pdcch_ss_mux_pattern == 3){
-        	//	38.213 Table 13-15
-            if((rx_frame == get_ssb_frame(rx_frame)) && (rx_slot == mac->type0_pdcch_ss_n_c)){
-                search_space_mask = search_space_mask | type0_pdcch;
-                mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.duration;
-            }
-        }
-    }
-
-    fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request;
-    //  Type0 PDCCH search space
+  //  check type0 from 38.213 13 if we have no CellGroupConfig
+  if ( mac->scd == NULL) {
+    if( ssb_index != -1){
+	
+      if(mac->type0_pdcch_ss_mux_pattern == 1){
+	//	38.213 chapter 13
+	if((mac->type0_pdcch_ss_sfn_c == SFN_C_MOD_2_EQ_0) && !(rx_frame & 0x1) && (rx_slot == mac->type0_pdcch_ss_n_c)){
+	  search_space_mask = search_space_mask | type0_pdcch;
+	  mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.coreset.duration;
+	}
+	if((mac->type0_pdcch_ss_sfn_c == SFN_C_MOD_2_EQ_1) &&  (rx_frame & 0x1) && (rx_slot == mac->type0_pdcch_ss_n_c)){
+	  search_space_mask = search_space_mask | type0_pdcch;
+	  mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.coreset.duration;
+	}
+      }
+      if(mac->type0_pdcch_ss_mux_pattern == 2){
+	//	38.213 Table 13-13, 13-14
+	if((rx_frame == get_ssb_frame(rx_frame)) && (rx_slot == mac->type0_pdcch_ss_n_c)){
+	  search_space_mask = search_space_mask | type0_pdcch;
+	  mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.coreset.duration;
+	}
+      }
+      if(mac->type0_pdcch_ss_mux_pattern == 3){
+	//	38.213 Table 13-15
+	if((rx_frame == get_ssb_frame(rx_frame)) && (rx_slot == mac->type0_pdcch_ss_n_c)){
+	  search_space_mask = search_space_mask | type0_pdcch;
+	  mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_dci_config.coreset.duration;
+	}
+      }
+    } // ssb_index != -1
+      
+      //  Type0 PDCCH search space
     if((search_space_mask & type0_pdcch) || ( mac->type0_pdcch_consecutive_slots != 0 )){
-        mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_consecutive_slots - 1;
-
-        dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15 = mac->type0_pdcch_dci_config;
-        dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI;
+      mac->type0_pdcch_consecutive_slots = mac->type0_pdcch_consecutive_slots - 1;
+	
+      dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15 = mac->type0_pdcch_dci_config;
+      dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI;
     	
-	/*
-    	dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.rnti = 0xaaaa;	//	to be set
-    	dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = 106;	//	to be set
-
+      /*
+	dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.rnti = 0xaaaa;	//	to be set
+	dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = 106;	//	to be set
+	  
 	LOG_I(MAC,"nr_ue_scheduler Type0 PDCCH with rnti %x, BWP %d\n",
-	       dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.rnti,
-	       dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP);  
-	*/   
-        dl_config->number_pdus = dl_config->number_pdus + 1;
+	dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.rnti,
+	dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP);  
+      */   
+      dl_config->number_pdus = dl_config->number_pdus + 1;
     }
+  }
+  else { // get PDCCH configuration(s) from SCGConfig
+      
 
-    if(search_space_mask & type0a_pdcch){
-    }
+	
+
+    // get Coreset and SearchSpace Information from spCellConfigDedicated
+    
+	
+	
+    /*
+      if(search_space_mask & type0a_pdcch){
+      }
+      
+      if(search_space_mask & type1_pdcch){
+      }
+      
+      if(search_space_mask & type2_pdcch){
+      }
+      
+      if(search_space_mask & type3_pdcch){
+      }
+    */
+  }
+
+
+  mac->scheduled_response.dl_config = dl_config;
+    
+
+  return UE_CONNECTION_OK;
+}
+
+#if 0
+uint16_t nr_dci_format_size (PHY_VARS_NR_UE *ue,
+                             uint8_t slot,
+                             int p,
+                             crc_scrambled_t crc_scrambled,
+                             uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS],
+                             uint8_t format) {
+  LOG_DDD("crc_scrambled=%d, n_RB_ULBWP=%d, n_RB_DLBWP=%d\n",crc_scrambled,n_RB_ULBWP,n_RB_DLBWP);
+  /*
+   * function nr_dci_format_size calculates and returns the size in bits of a determined format
+   * it also returns an bi-dimensional array 'dci_fields_sizes' with x rows and y columns, where:
+   * x is the number of fields defined in TS 38.212 subclause 7.3.1 (Each field is mapped in the order in which it appears in the description in the specification)
+   * y is the number of formats
+   *   e.g.: dci_fields_sizes[10][0] contains the size in bits of the field FREQ_DOM_RESOURCE_ASSIGNMENT_UL for format 0_0
+   */
+  // pdsch_config contains the PDSCH-Config IE is used to configure the UE specific PDSCH parameters (TS 38.331)
+  PDSCH_Config_t pdsch_config       = ue->PDSCH_Config;
+  // pusch_config contains the PUSCH-Config IE is used to configure the UE specific PUSCH parameters (TS 38.331)
+  PUSCH_Config_t pusch_config       = ue->pusch_config;
+  PUCCH_Config_t pucch_config_dedicated       = ue->pucch_config_dedicated_nr[eNB_id];
+  crossCarrierSchedulingConfig_t crossCarrierSchedulingConfig = ue->crossCarrierSchedulingConfig;
+  dmrs_UplinkConfig_t dmrs_UplinkConfig = ue->dmrs_UplinkConfig;
+  dmrs_DownlinkConfig_t dmrs_DownlinkConfig = ue->dmrs_DownlinkConfig;
+  csi_MeasConfig_t csi_MeasConfig = ue->csi_MeasConfig;
+  PUSCH_ServingCellConfig_t PUSCH_ServingCellConfig= ue->PUSCH_ServingCellConfig;
+  PDSCH_ServingCellConfig_t PDSCH_ServingCellConfig= ue->PDSCH_ServingCellConfig;
+  NR_UE_PDCCH *pdcch_vars2 = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id];
+  // 1  CARRIER_IN
+  // crossCarrierSchedulingConfig from higher layers, variable crossCarrierSchedulingConfig indicates if 'cross carrier scheduling' is enabled or not:
+  //      if No cross carrier scheduling: number of bits for CARRIER_IND is 0
+  //      if Cross carrier scheduling: number of bits for CARRIER_IND is 3
+  // The IE CrossCarrierSchedulingConfig is used to specify the configuration when the cross-carrier scheduling is used in a cell
+  uint8_t crossCarrierSchedulingConfig_ind = 0;
+
+  if (crossCarrierSchedulingConfig.schedulingCellInfo.other.cif_InSchedulingCell !=0 ) crossCarrierSchedulingConfig_ind=1;
+
+  // 2  SUL_IND_0_1, // 40 SRS_REQUEST, // 50 SUL_IND_0_0
+  // UL/SUL indicator (TS 38.331, supplementary uplink is indicated in higher layer parameter ServCellAdd-SUL from IE ServingCellConfig and ServingCellConfigCommon):
+  // 0 bit for UEs not configured with SUL in the cell or UEs configured with SUL in the cell but only PUCCH carrier in the cell is configured for PUSCH transmission
+  // 1 bit for UEs configured with SUL in the cell as defined in Table 7.3.1.1.1-1
+  // sul_ind indicates whether SUL is configured in cell or not
+  uint8_t sul_ind=ue->supplementaryUplink.supplementaryUplink; // this value will be 0 or 1 depending on higher layer parameter ServCellAdd-SUL. FIXME!!!
+  // 7  BANDWIDTH_PART_IND
+  // number of UL BWPs configured by higher layers
+  uint8_t n_UL_BWP_RRC=1; // initialized to 1 but it has to be initialized by higher layers FIXME!!!
+  n_UL_BWP_RRC = ((n_UL_BWP_RRC > 3)?n_UL_BWP_RRC:(n_UL_BWP_RRC+1));
+  // number of DL BWPs configured by higher layers
+  uint8_t n_DL_BWP_RRC=1; // initialized to 1 but it has to be initialized by higher layers FIXME!!!
+  n_DL_BWP_RRC = ((n_DL_BWP_RRC > 3)?n_DL_BWP_RRC:(n_DL_BWP_RRC+1));
+  // 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL
+  // if format0_0, only resource allocation type 1 is allowed
+  // if format0_1, then resource allocation type 0 can be configured and N_RBG is defined in TS 38.214 subclause 6.1.2.2.1
+  // for PUSCH hopping with resource allocation type 1
+  //      n_UL_hopping = 1 if the higher layer parameter frequencyHoppingOffsetLists contains two  offset values
+  //      n_UL_hopping = 2 if the higher layer parameter frequencyHoppingOffsetLists contains four offset values
+  uint8_t n_UL_hopping=pusch_config.n_frequencyHoppingOffsetLists;
+
+  if (n_UL_hopping == 2) {
+    n_UL_hopping = 1;
+  } else if (n_UL_hopping == 4) {
+    n_UL_hopping = 2;
+  } else {
+    n_UL_hopping = 0;
+  }
+
+  ul_resourceAllocation_t ul_resource_allocation_type = pusch_config.ul_resourceAllocation;
+  uint8_t ul_res_alloc_type_0 = 0;
+  uint8_t ul_res_alloc_type_1 = 0;
+
+  if (ul_resource_allocation_type == ul_resourceAllocationType0) ul_res_alloc_type_0 = 1;
+
+  if (ul_resource_allocation_type == ul_resourceAllocationType1) ul_res_alloc_type_1 = 1;
+
+  if (ul_resource_allocation_type == ul_dynamicSwitch) {
+    ul_res_alloc_type_0 = 1;
+    ul_res_alloc_type_1 = 1;
+  }
+
+  uint8_t n_bits_freq_dom_res_assign_ul=0,n_ul_RGB_tmp;
+
+  if (ul_res_alloc_type_0 == 1) { // implementation of Table 6.1.2.2.1-1 TC 38.214 subclause 6.1.2.2.1
+    // config1: PUSCH-Config IE contains rbg-Size ENUMERATED {config1 config2}
+    ul_rgb_Size_t config = pusch_config.ul_rgbSize;
+    uint8_t nominal_RBG_P               = (config==ul_rgb_config1?2:4);
+
+    if (n_RB_ULBWP > 36)  nominal_RBG_P = (config==ul_rgb_config1?4:8);
+
+    if (n_RB_ULBWP > 72)  nominal_RBG_P = (config==ul_rgb_config1?8:16);
 
-    if(search_space_mask & type1_pdcch){
+    if (n_RB_ULBWP > 144) nominal_RBG_P = 16;
+
+    n_bits_freq_dom_res_assign_ul = (uint8_t)ceil((n_RB_ULBWP+(0%nominal_RBG_P))/nominal_RBG_P);                                   //FIXME!!! what is 0???
+    n_ul_RGB_tmp = n_bits_freq_dom_res_assign_ul;
+  }
+
+  if (ul_res_alloc_type_1 == 1) n_bits_freq_dom_res_assign_ul = (uint8_t)(ceil(log2(n_RB_ULBWP*(n_RB_ULBWP+1)/2)))-n_UL_hopping;
+
+  if ((ul_res_alloc_type_0 == 1) && (ul_res_alloc_type_1 == 1))
+    n_bits_freq_dom_res_assign_ul = ((n_bits_freq_dom_res_assign_ul>n_ul_RGB_tmp)?(n_bits_freq_dom_res_assign_ul+1):(n_ul_RGB_tmp+1));
+
+  // 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL
+  // if format1_0, only resource allocation type 1 is allowed
+  // if format1_1, then resource allocation type 0 can be configured and N_RBG is defined in TS 38.214 subclause 5.1.2.2.1
+  dl_resourceAllocation_t dl_resource_allocation_type = pdsch_config.dl_resourceAllocation;
+  uint8_t dl_res_alloc_type_0 = 0;
+  uint8_t dl_res_alloc_type_1 = 0;
+
+  if (dl_resource_allocation_type == dl_resourceAllocationType0) dl_res_alloc_type_0 = 1;
+
+  if (dl_resource_allocation_type == dl_resourceAllocationType1) dl_res_alloc_type_1 = 1;
+
+  if (dl_resource_allocation_type == dl_dynamicSwitch) {
+    dl_res_alloc_type_0 = 1;
+    dl_res_alloc_type_1 = 1;
+  }
+
+  uint8_t n_bits_freq_dom_res_assign_dl=0,n_dl_RGB_tmp;
+
+  if (dl_res_alloc_type_0 == 1) { // implementation of Table 5.1.2.2.1-1 TC 38.214 subclause 6.1.2.2.1
+    // config1: PDSCH-Config IE contains rbg-Size ENUMERATED {config1, config2}
+    dl_rgb_Size_t config = pdsch_config.dl_rgbSize;
+    uint8_t nominal_RBG_P               = (config==dl_rgb_config1?2:4);
+
+    if (n_RB_DLBWP > 36)  nominal_RBG_P = (config==dl_rgb_config1?4:8);
+
+    if (n_RB_DLBWP > 72)  nominal_RBG_P = (config==dl_rgb_config1?8:16);
+
+    if (n_RB_DLBWP > 144) nominal_RBG_P = 16;
+
+    n_bits_freq_dom_res_assign_dl = (uint8_t)ceil((n_RB_DLBWP+(0%nominal_RBG_P))/nominal_RBG_P);                                     //FIXME!!! what is 0???
+    n_dl_RGB_tmp = n_bits_freq_dom_res_assign_dl;
+  }
+
+  if (dl_res_alloc_type_1 == 1) n_bits_freq_dom_res_assign_dl = (uint8_t)(ceil(log2(n_RB_DLBWP*(n_RB_DLBWP+1)/2)));
+
+  if ((dl_res_alloc_type_0 == 1) && (dl_res_alloc_type_1 == 1))
+    n_bits_freq_dom_res_assign_dl = ((n_bits_freq_dom_res_assign_dl>n_dl_RGB_tmp)?(n_bits_freq_dom_res_assign_dl+1):(n_dl_RGB_tmp+1));
+
+  // 12 TIME_DOM_RESOURCE_ASSIGNMENT
+  uint8_t pusch_alloc_list = pusch_config.n_push_alloc_list;
+  uint8_t pdsch_alloc_list = pdsch_config.n_pdsh_alloc_list;
+  // 14 PRB_BUNDLING_SIZE_IND:0 bit if the higher layer parameter PRB_bundling is not configured or is set to 'static', or 1 bit if the higher layer parameter PRB_bundling is set to 'dynamic' according to Subclause 5.1.2.3 of [6, TS 38.214]
+  static_bundleSize_t static_prb_BundlingType = pdsch_config.prbBundleType.staticBundling;
+  bundleSizeSet1_t dynamic_prb_BundlingType1  = pdsch_config.prbBundleType.dynamicBundlig.bundleSizeSet1;
+  bundleSizeSet2_t dynamic_prb_BundlingType2  = pdsch_config.prbBundleType.dynamicBundlig.bundleSizeSet2;
+  uint8_t prb_BundlingType_size=0;
+
+  if ((static_prb_BundlingType==st_n4)||(static_prb_BundlingType==st_wideband)) prb_BundlingType_size=0;
+
+  if ((dynamic_prb_BundlingType1==dy_1_n4)||(dynamic_prb_BundlingType1==dy_1_wideband)||(dynamic_prb_BundlingType1==dy_1_n2_wideband)||(dynamic_prb_BundlingType1==dy_1_n4_wideband)||
+      (dynamic_prb_BundlingType2==dy_2_n4)||(dynamic_prb_BundlingType2==dy_2_wideband)) prb_BundlingType_size=1;
+
+  // 15 RATE_MATCHING_IND FIXME!!!
+  // according to TS 38.212: Rate matching indicator – 0, 1, or 2 bits according to higher layer parameter rateMatchPattern
+  uint8_t rateMatching_bits = pdsch_config.n_rateMatchPatterns;
+  // 16 ZP_CSI_RS_TRIGGER FIXME!!!
+  // 0, 1, or 2 bits as defined in Subclause 5.1.4.2 of [6, TS 38.214].
+  // is the number of ZP CSI-RS resource sets in the higher layer parameter zp-CSI-RS-Resource
+  uint8_t n_zp_bits = pdsch_config.n_zp_CSI_RS_ResourceId;
+  // 17 FREQ_HOPPING_FLAG
+  // freqHopping is defined by higher layer parameter frequencyHopping from IE PUSCH-Config. Values are ENUMERATED{mode1, mode2}
+  frequencyHopping_t f_hopping = pusch_config.frequencyHopping;
+  uint8_t freqHopping = 0;
+
+  if ((f_hopping==f_hop_mode1)||(f_hopping==f_hop_mode2)) freqHopping = 1;
+
+  // 28 DAI
+  pdsch_HARQ_ACK_Codebook_t pdsch_HARQ_ACK_Codebook = pdsch_config.pdsch_HARQ_ACK_Codebook;
+  uint8_t n_dai = 0;
+  uint8_t n_serving_cell_dl = 1; // this is hardcoded to 1 as we need to get this value from RRC higher layers parameters. FIXME!!!
+
+  if ((pdsch_HARQ_ACK_Codebook == dynamic) && (n_serving_cell_dl == 1)) n_dai = 2;
+
+  if ((pdsch_HARQ_ACK_Codebook == dynamic) && (n_serving_cell_dl > 1))  n_dai = 4;
+
+  // 29 FIRST_DAI
+  uint8_t codebook_HARQ_ACK = 0;           // We need to get this value to calculate number of bits of fields 1st DAI and 2nd DAI.
+
+  if (pdsch_HARQ_ACK_Codebook == semiStatic) codebook_HARQ_ACK = 1;
+
+  if (pdsch_HARQ_ACK_Codebook == dynamic) codebook_HARQ_ACK = 2;
+
+  // 30 SECOND_DAI
+  uint8_t n_HARQ_ACK_sub_codebooks = 0;   // We need to get this value to calculate number of bits of fields 1st DAI and 2nd DAI. FIXME!!!
+  // 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND
+  uint8_t pdsch_harq_t_ind = (uint8_t)ceil(log2(pucch_config_dedicated.dl_DataToUL_ACK[0]));
+  // 36 SRS_RESOURCE_IND
+  // n_SRS is the number of configured SRS resources in the SRS resource set associated with the higher layer parameter usage of value 'codeBook' or 'nonCodeBook'
+  // from SRS_ResourceSet_t type we should get the information of the usage parameter (with possible values beamManagement, codebook, nonCodebook, antennaSwitching)
+  // at frame_parms->srs_nr->p_SRS_ResourceSetList[]->usage
+  uint8_t n_SRS = ue->srs.number_srs_Resource_Set;
+  // 37 PRECOD_NBR_LAYERS
+  // 38 ANTENNA_PORTS
+  txConfig_t txConfig = pusch_config.txConfig;
+  transformPrecoder_t transformPrecoder = pusch_config.transformPrecoder;
+  codebookSubset_t codebookSubset = pusch_config.codebookSubset;
+  uint8_t maxRank = pusch_config.maxRank;
+  uint8_t num_antenna_ports = 1; // this is hardcoded. We need to get the real value FIXME!!!
+  uint8_t precond_nbr_layers_bits = 0;
+  uint8_t antenna_ports_bits_ul = 0;
+
+  // searching number of bits at tables 7.3.1.1.2-2/3/4/5 from TS 38.212 subclause 7.3.1.1.2
+  if (txConfig == txConfig_codebook) {
+    if (num_antenna_ports == 4) {
+      if ((transformPrecoder == transformPrecoder_disabled) && ((maxRank == 2)||(maxRank == 3)||(maxRank == 4))) { // Table 7.3.1.1.2-2
+        if (codebookSubset == codebookSubset_fullyAndPartialAndNonCoherent) precond_nbr_layers_bits=6;
+
+        if (codebookSubset == codebookSubset_partialAndNonCoherent) precond_nbr_layers_bits=5;
+
+        if (codebookSubset == codebookSubset_nonCoherent) precond_nbr_layers_bits=4;
+      }
+
+      if (((transformPrecoder == transformPrecoder_enabled)||(transformPrecoder == transformPrecoder_disabled)) && (maxRank == 1)) { // Table 7.3.1.1.2-3
+        if (codebookSubset == codebookSubset_fullyAndPartialAndNonCoherent) precond_nbr_layers_bits=5;
+
+        if (codebookSubset == codebookSubset_partialAndNonCoherent) precond_nbr_layers_bits=4;
+
+        if (codebookSubset == codebookSubset_nonCoherent) precond_nbr_layers_bits=2;
+      }
     }
 
-    if(search_space_mask & type2_pdcch){
+    if (num_antenna_ports == 2) {
+      if ((transformPrecoder == transformPrecoder_disabled) && (maxRank == 2)) { // Table 7.3.1.1.2-4
+        if (codebookSubset == codebookSubset_fullyAndPartialAndNonCoherent) precond_nbr_layers_bits=4;
+
+        if (codebookSubset == codebookSubset_nonCoherent) precond_nbr_layers_bits=2;
+      }
+
+      if (((transformPrecoder == transformPrecoder_enabled)||(transformPrecoder == transformPrecoder_disabled)) && (maxRank == 1)) { // Table 7.3.1.1.2-5
+        if (codebookSubset == codebookSubset_fullyAndPartialAndNonCoherent) precond_nbr_layers_bits=3;
+
+        if (codebookSubset == codebookSubset_nonCoherent) precond_nbr_layers_bits=1;
+      }
     }
+  }
+
+  if (txConfig == txConfig_nonCodebook) {
+  }
+
+  // searching number of bits at tables 7.3.1.1.2-6/7/8/9/10/11/12/13/14/15/16/17/18/19
+  if((dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type1)) {
+    if ((transformPrecoder == transformPrecoder_enabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len1)) antenna_ports_bits_ul = 2;
+
+    if ((transformPrecoder == transformPrecoder_enabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len2)) antenna_ports_bits_ul = 4;
+
+    if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len1)) antenna_ports_bits_ul = 3;
+
+    if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len2)) antenna_ports_bits_ul = 4;
+  }
+
+  if((dmrs_UplinkConfig.pusch_dmrs_type == pusch_dmrs_type2)) {
+    if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len1)) antenna_ports_bits_ul = 4;
+
+    if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.pusch_maxLength == pusch_len2)) antenna_ports_bits_ul = 5;
+  }
+
+  // for format 1_1 number of bits as defined by Tables 7.3.1.2.2-1/2/3/4
+  uint8_t antenna_ports_bits_dl = 0;
+
+  if((dmrs_DownlinkConfig.pdsch_dmrs_type == pdsch_dmrs_type1) && (dmrs_DownlinkConfig.pdsch_maxLength == pdsch_len1)) antenna_ports_bits_dl = 4; // Table 7.3.1.2.2-1
+
+  if((dmrs_DownlinkConfig.pdsch_dmrs_type == pdsch_dmrs_type1) && (dmrs_DownlinkConfig.pdsch_maxLength == pdsch_len2)) antenna_ports_bits_dl = 5; // Table 7.3.1.2.2-2
+
+  if((dmrs_DownlinkConfig.pdsch_dmrs_type == pdsch_dmrs_type2) && (dmrs_DownlinkConfig.pdsch_maxLength == pdsch_len1)) antenna_ports_bits_dl = 5; // Table 7.3.1.2.2-3
+
+  if((dmrs_DownlinkConfig.pdsch_dmrs_type == pdsch_dmrs_type2) && (dmrs_DownlinkConfig.pdsch_maxLength == pdsch_len2)) antenna_ports_bits_dl = 6; // Table 7.3.1.2.2-4
+
+  // 39 TCI
+  uint8_t tci_bits=0;
+
+  if (pdcch_vars2->coreset[p].tciPresentInDCI == tciPresentInDCI_enabled) tci_bits=3;
+
+  // 42 CSI_REQUEST
+  // reportTriggerSize is defined in the CSI-MeasConfig IE (TS 38.331).
+  // Size of CSI request field in DCI (bits). Corresponds to L1 parameter 'ReportTriggerSize' (see 38.214, section 5.2)
+  uint8_t reportTriggerSize = csi_MeasConfig.reportTriggerSize; // value from 0..6
+  // 43 CBGTI
+  // for format 0_1
+  uint8_t maxCodeBlockGroupsPerTransportBlock = 0;
 
-    if(search_space_mask & type3_pdcch){
+  if (PUSCH_ServingCellConfig.maxCodeBlockGroupsPerTransportBlock != 0)
+    maxCodeBlockGroupsPerTransportBlock = (uint8_t)PUSCH_ServingCellConfig.maxCodeBlockGroupsPerTransportBlock;
+
+  // for format 1_1, as defined in Subclause 5.1.7 of [6, TS38.214]
+  uint8_t maxCodeBlockGroupsPerTransportBlock_dl = 0;
+
+  if (PDSCH_ServingCellConfig.maxCodeBlockGroupsPerTransportBlock_dl != 0)
+    maxCodeBlockGroupsPerTransportBlock_dl = pdsch_config.maxNrofCodeWordsScheduledByDCI; // FIXME!!!
+
+  // 44 CBGFI
+  uint8_t cbgfi_bit = PDSCH_ServingCellConfig.codeBlockGroupFlushIndicator;
+  // 45 PTRS_DMRS
+  // 0 bit if PTRS-UplinkConfig is not configured and transformPrecoder=disabled, or if transformPrecoder=enabled, or if maxRank=1
+  // 2 bits otherwise
+  uint8_t ptrs_dmrs_bits=0; //FIXME!!!
+  // 46 BETA_OFFSET_IND
+  // at IE PUSCH-Config, beta_offset indicator – 0 if the higher layer parameter betaOffsets = semiStatic; otherwise 2 bits
+  // uci-OnPUSCH
+  // Selection between and configuration of dynamic and semi-static beta-offset. If the field is absent or released, the UE applies the value 'semiStatic' and the BetaOffsets
+  uint8_t betaOffsets = 0;
+
+  if (pusch_config.uci_onPusch.betaOffset_type == betaOffset_semiStatic);
+
+  if (pusch_config.uci_onPusch.betaOffset_type == betaOffset_dynamic) betaOffsets = 2;
+
+  // 47 DMRS_SEQ_INI
+  uint8_t dmrs_seq_ini_bits_ul = 0;
+  uint8_t dmrs_seq_ini_bits_dl = 0;
+
+  //1 bit if both scramblingID0 and scramblingID1 are configured in DMRS-UplinkConfig
+  if ((transformPrecoder == transformPrecoder_disabled) && (dmrs_UplinkConfig.scramblingID0 != 0) && (dmrs_UplinkConfig.scramblingID1 != 0)) dmrs_seq_ini_bits_ul = 1;
+
+  //1 bit if both scramblingID0 and scramblingID1 are configured in DMRS-DownlinkConfig
+  if ((dmrs_DownlinkConfig.scramblingID0 != 0) && (dmrs_DownlinkConfig.scramblingID0 != 0)) dmrs_seq_ini_bits_dl = 1;
+
+  /*
+   * For format 2_2
+   *
+   * This format supports power control commands for semi-persistent scheduling.
+   * As we can already support power control commands dynamically with formats 0_0/0_1 (TPC PUSCH) and 1_0/1_1 (TPC PUCCH)
+   *
+   * This format will be implemented in the future FIXME!!!
+   *
+   */
+  // 5  BLOCK_NUMBER: The parameter tpc-PUSCH or tpc-PUCCH provided by higher layers determines the index to the block number for an UL of a cell
+  // The following fields are defined for each block: Closed loop indicator and TPC command
+  // 6  CLOSE_LOOP_IND
+  // 41 TPC_CMD
+  uint8_t tpc_cmd_bit_2_2 = 2;
+  /*
+   * For format 2_3
+   *
+   * This format is used for power control of uplink sounding reference signals for devices which have not coupled SRS power control to the PUSCH power control
+   * either because independent control is desirable or because the device is configured without PUCCH and PUSCH
+   *
+   * This format will be implemented in the future FIXME!!!
+   *
+   */
+  // 40 SRS_REQUEST
+  // 41 TPC_CMD
+  uint8_t tpc_cmd_bit_2_3 = 0;
+  uint8_t dci_field_size_table [NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = { // This table contains the number of bits for each field (row) contained in each dci format (column).
+    // The values of the variables indicate field sizes in number of bits
+    //Format0_0                     Format0_1                      Format1_0                      Format1_1             Formats2_0/1/2/3
+    {
+      1,                             1,                             (((crc_scrambled == _p_rnti) || (crc_scrambled == _si_rnti) || (crc_scrambled == _ra_rnti)) ? 0:1),
+      1,                             0,0,0,0
+    }, // 0  IDENTIFIER_DCI_FORMATS:
+    {
+      0,                             ((crossCarrierSchedulingConfig_ind == 0) ? 0:3),
+      0,                             ((crossCarrierSchedulingConfig_ind == 0) ? 0:3),
+      0,0,0,0
+    }, // 1  CARRIER_IND: 0 or 3 bits, as defined in Subclause x.x of [5, TS38.213]
+    {0,                             (sul_ind == 0)?0:1,            0,                             0,                             0,0,0,0}, // 2  SUL_IND_0_1:
+    {0,                             0,                             0,                             0,                             1,0,0,0}, // 3  SLOT_FORMAT_IND: size of DCI format 2_0 is configurable by higher layers up to 128 bits, according to Subclause 11.1.1 of [5, TS 38.213]
+    {0,                             0,                             0,                             0,                             0,1,0,0}, // 4  PRE_EMPTION_IND: size of DCI format 2_1 is configurable by higher layers up to 126 bits, according to Subclause 11.2 of [5, TS 38.213]. Each pre-emption indication is 14 bits
+    {0,                             0,                             0,                             0,                             0,0,0,0}, // 5  BLOCK_NUMBER: starting position of a block is determined by the parameter startingBitOfFormat2_3
+    {0,                             0,                             0,                             0,                             0,0,1,0}, // 6  CLOSE_LOOP_IND
+    {
+      0,                             (uint8_t)ceil(log2(n_UL_BWP_RRC)),
+      0,                             (uint8_t)ceil(log2(n_DL_BWP_RRC)),
+      0,0,0,0
+    }, // 7  BANDWIDTH_PART_IND:
+    {
+      0,                             0,                             ((crc_scrambled == _p_rnti) ? 2:0),
+      0,                             0,0,0,0
+    }, // 8  SHORT_MESSAGE_IND 2 bits if crc scrambled with P-RNTI
+    {
+      0,                             0,                             ((crc_scrambled == _p_rnti) ? 8:0),
+      0,                             0,0,0,0
+    }, // 9  SHORT_MESSAGES 8 bit8 if crc scrambled with P-RNTI
+    {
+      (uint8_t)(ceil(log2(n_RB_ULBWP*(n_RB_ULBWP+1)/2)))-n_UL_hopping,
+      n_bits_freq_dom_res_assign_ul,
+      0,                             0,                             0,0,0,0
+    }, // 10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered
+    //    (NOTE 1) If DCI format 0_0 is monitored in common search space
+    //    and if the number of information bits in the DCI format 0_0 prior to padding
+    //    is larger than the payload size of the DCI format 1_0 monitored in common search space
+    //    the bitwidth of the frequency domain resource allocation field in the DCI format 0_0
+    //    is reduced such that the size of DCI format 0_0 equals to the size of the DCI format 1_0
+    {
+      0,                             0,                             (uint8_t)ceil(log2(n_RB_DLBWP*(n_RB_DLBWP+1)/2)),
+      n_bits_freq_dom_res_assign_dl,
+      0,0,0,0
+    }, // 11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
+    {
+      4,                             (uint8_t)log2(pusch_alloc_list),
+      4,                             (uint8_t)log2(pdsch_alloc_list),
+      0,0,0,0
+    }, // 12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
+    //    where I the number of entries in the higher layer parameter pusch-AllocationList
+    {
+      0,                             0,                             1,                             (((dl_res_alloc_type_0==1) &&(dl_res_alloc_type_1==0))?0:1),
+      0,0,0,0
+    }, // 13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
+    {0,                             0,                             0,                             prb_BundlingType_size,         0,0,0,0}, // 14 PRB_BUNDLING_SIZE_IND:0 bit if the higher layer parameter PRB_bundling is not configured or is set to 'static', or 1 bit if the higher layer parameter PRB_bundling is set to 'dynamic' according to Subclause 5.1.2.3 of [6, TS 38.214]
+    {0,                             0,                             0,                             rateMatching_bits,             0,0,0,0}, // 15 RATE_MATCHING_IND: 0, 1, or 2 bits according to higher layer parameter rate-match-PDSCH-resource-set
+    {0,                             0,                             0,                             n_zp_bits,                     0,0,0,0}, // 16 ZP_CSI_RS_TRIGGER:
+    {
+      1,                             (((ul_res_alloc_type_0==1) &&(ul_res_alloc_type_1==0))||(freqHopping == 0))?0:1,
+      0,                             0,                             0,0,0,0
+    }, // 17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0
+    {0,                             0,                             0,                             5,                             0,0,0,0}, // 18 TB1_MCS:
+    {0,                             0,                             0,                             1,                             0,0,0,0}, // 19 TB1_NDI:
+    {0,                             0,                             0,                             2,                             0,0,0,0}, // 20 TB1_RV:
+    {0,                             0,                             0,                             5,                             0,0,0,0}, // 21 TB2_MCS:
+    {0,                             0,                             0,                             1,                             0,0,0,0}, // 22 TB2_NDI:
+    {0,                             0,                             0,                             2,                             0,0,0,0}, // 23 TB2_RV:
+    {5,                             5,                             5,                             0,                             0,0,0,0}, // 24 MCS:
+    {1,                             1,                             (crc_scrambled == _c_rnti)?1:0,0,                             0,0,0,0}, // 25 NDI:
+    {
+      2,                             2,                             (((crc_scrambled == _c_rnti) || (crc_scrambled == _si_rnti)) ? 2:0),
+      0,                             0,0,0,0
+    }, // 26 RV:
+    {4,                             4,                             (crc_scrambled == _c_rnti)?4:0,4,                             0,0,0,0}, // 27 HARQ_PROCESS_NUMBER:
+    {0,                             0,                             (crc_scrambled == _c_rnti)?2:0,n_dai,                         0,0,0,0}, // 28 DAI: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
+    //    2 if one serving cell is configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 bits are the counter DAI
+    //    0 otherwise
+    {0,                             codebook_HARQ_ACK,             0,                             0,                             0,0,0,0}, // 29 FIRST_DAI: (1 or 2 bits) 1 bit for semi-static HARQ-ACK // 2 bits for dynamic HARQ-ACK codebook with single HARQ-ACK codebook
+    {
+      0,                             (((codebook_HARQ_ACK == 2) &&(n_HARQ_ACK_sub_codebooks==2))?2:0),
+      0,                             0,                             0,0,0,0
+    }, // 30 SECOND_DAI: (0 or 2 bits) 2 bits for dynamic HARQ-ACK codebook with two HARQ-ACK sub-codebooks // 0 bits otherwise
+    {
+      0,                             0,                             (((crc_scrambled == _p_rnti) || (crc_scrambled == _ra_rnti)) ? 2:0),
+      0,                             0,0,0,0
+    }, // 31 TB_SCALING
+    {2,                             2,                             0,                             0,                             0,0,0,0}, // 32 TPC_PUSCH:
+    {0,                             0,                             (crc_scrambled == _c_rnti)?2:0,2,                             0,0,0,0}, // 33 TPC_PUCCH:
+    {0,                             0,                             (crc_scrambled == _c_rnti)?3:0,3,                             0,0,0,0}, // 34 PUCCH_RESOURCE_IND:
+    {0,                             0,                             (crc_scrambled == _c_rnti)?3:0,pdsch_harq_t_ind,              0,0,0,0}, // 35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND:
+    {0,                             (uint8_t)log2(n_SRS),          0,                             0,                             0,0,0,0}, // 36 SRS_RESOURCE_IND:
+    {0,                             precond_nbr_layers_bits,       0,                             0,                             0,0,0,0}, // 37 PRECOD_NBR_LAYERS:
+    {0,                             antenna_ports_bits_ul,         0,                             antenna_ports_bits_dl,         0,0,0,0}, // 38 ANTENNA_PORTS:
+    {0,                             0,                             0,                             tci_bits,                      0,0,0,0}, // 39 TCI: 0 bit if higher layer parameter tci-PresentInDCI is not enabled; otherwise 3 bits
+    {0,                             (sul_ind == 0)?2:3,            0,                             (sul_ind == 0)?2:3,            0,0,0,2}, // 40 SRS_REQUEST:
+    {
+      0,                             0,                             0,                             0,                             0,0,tpc_cmd_bit_2_2,
+      tpc_cmd_bit_2_3
+    },
+    // 41 TPC_CMD:
+    {0,                             reportTriggerSize,             0,                             0,                             0,0,0,0}, // 42 CSI_REQUEST:
+    {
+      0,                             maxCodeBlockGroupsPerTransportBlock,
+      0,                             maxCodeBlockGroupsPerTransportBlock_dl,
+      0,0,0,0
+    }, // 43 CBGTI: 0, 2, 4, 6, or 8 bits determined by higher layer parameter maxCodeBlockGroupsPerTransportBlock for the PDSCH
+    {0,                             0,                             0,                             cbgfi_bit,                     0,0,0,0}, // 44 CBGFI: 0 or 1 bit determined by higher layer parameter codeBlockGroupFlushIndicator
+    {0,                             ptrs_dmrs_bits,                0,                             0,                             0,0,0,0}, // 45 PTRS_DMRS:
+    {0,                             betaOffsets,                   0,                             0,                             0,0,0,0}, // 46 BETA_OFFSET_IND:
+    {0,                             dmrs_seq_ini_bits_ul,          0,                             dmrs_seq_ini_bits_dl,          0,0,0,0}, // 47 DMRS_SEQ_INI: 1 bit if the cell has two ULs and the number of bits for DCI format 1_0 before padding
+    //    is larger than the number of bits for DCI format 0_0 before padding; 0 bit otherwise
+    {0,                             1,                             0,                             0,                             0,0,0,0}, // 48 UL_SCH_IND: value of "1" indicates UL-SCH shall be transmitted on the PUSCH and a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH
+    {0,                             0,                             0,                             0,                             0,0,0,0}, // 49 PADDING_NR_DCI:
+    //    (NOTE 2) If DCI format 0_0 is monitored in common search space
+    //    and if the number of information bits in the DCI format 0_0 prior to padding
+    //    is less than the payload size of the DCI format 1_0 monitored in common search space
+    //    zeros shall be appended to the DCI format 0_0
+    //    until the payload size equals that of the DCI format 1_0
+    {(sul_ind == 0)?0:1,            0,                             0,                             0,                             0,0,0,0}, // 50 SUL_IND_0_0:
+    {0,                             0,                             0,                             0,                             0,0,0,0}, // 51 RA_PREAMBLE_INDEX (random access procedure initiated by a PDCCH order not implemented, FIXME!!!)
+    {0,                             0,                             0,                             0,                             0,0,0,0}, // 52 SUL_IND_1_0 (random access procedure initiated by a PDCCH order not implemented, FIXME!!!)
+    {0,                             0,                             0,                             0,                             0,0,0,0}, // 53 SS_PBCH_INDEX (random access procedure initiated by a PDCCH order not implemented, FIXME!!!)
+    {0,                             0,                             0,                             0,                             0,0,0,0}, // 54 PRACH_MASK_INDEX (random access procedure initiated by a PDCCH order not implemented, FIXME!!!)
+    {
+      0,                             0,                             ((crc_scrambled == _p_rnti)?6:(((crc_scrambled == _si_rnti) || (crc_scrambled == _ra_rnti))?16:0)),
+      0,                             0,0,0,0
+    }  // 55 RESERVED_NR_DCI
+  };
+  // NOTE 1: adjustments in freq_dom_resource_assignment_UL to be done if necessary
+  // NOTE 2: adjustments in padding to be done if necessary
+  uint8_t dci_size [8] = {0,0,0,0,0,0,0,0}; // will contain size for each format
+
+  for (int i=0 ; i<NBR_NR_FORMATS ; i++) {
+    //#ifdef NR_PDCCH_DCI_DEBUG
+    //  LOG_DDD("i=%d, j=%d\n", i, j);
+    //#endif
+    for (int j=0; j<NBR_NR_DCI_FIELDS; j++) {
+      dci_size [i] = dci_size [i] + dci_field_size_table[j][i]; // dci_size[i] contains the size in bits of the dci pdu format i
+      //if (i==(int)format-15) {                                  // (int)format-15 indicates the position of each format in the table (e.g. format1_0=17 -> position in table is 2)
+      dci_fields_sizes[j][i] = dci_field_size_table[j][i];       // dci_fields_sizes[j] contains the sizes of each field (j) for a determined format i
+      //}
     }
 
+    LOG_DDD("(nr_dci_format_size) dci_size[%d]=%d for n_RB_ULBWP=%d\n",
+	    i,dci_size[i],n_RB_ULBWP);
+  }
 
-    mac->scheduled_response.dl_config = dl_config;
-    
+  LOG_DDD("(nr_dci_format_size) dci_fields_sizes[][] = { \n");
+
+#ifdef NR_PDCCH_DCI_DEBUG
+  for (int j=0; j<NBR_NR_DCI_FIELDS; j++) {
+    printf("\t\t");
 
-	return UE_CONNECTION_OK;
+    for (int i=0; i<NBR_NR_FORMATS ; i++) printf("%d\t",dci_fields_sizes[j][i]);
+
+    printf("\n");
+  }
+
+  printf(" }\n");
+#endif
+  LOG_DNL("(nr_dci_format_size) dci_size[0_0]=%d, dci_size[0_1]=%d, dci_size[1_0]=%d, dci_size[1_1]=%d,\n",dci_size[0],dci_size[1],dci_size[2],dci_size[3]);
+
+  //UL/SUL indicator format0_0 (TS 38.212 subclause 7.3.1.1.1)
+  // - 1 bit if the cell has two ULs and the number of bits for DCI format 1_0 before padding is larger than the number of bits for DCI format 0_0 before padding;
+  // - 0 bit otherwise.
+  // The UL/SUL indicator, if present, locates in the last bit position of DCI format 0_0, after the padding bit(s)
+  if ((dci_field_size_table[SUL_IND_0_0][0] == 1) && (dci_size[0] > dci_size[2])) {
+    dci_field_size_table[SUL_IND_0_0][0] = 0;
+    dci_size[0]=dci_size[0]-1;
+  }
+
+  //  if ((format == format0_0) || (format == format1_0)) {
+  // According to Section 7.3.1.1.1 in TS 38.212
+  // If DCI format 0_0 is monitored in common search space and if the number of information bits in the DCI format 0_0 prior to padding
+  // is less than the payload size of the DCI format 1_0 monitored in common search space for scheduling the same serving cell,
+  // zeros shall be appended to the DCI format 0_0 until the payload size equals that of the DCI format 1_0.
+  if (dci_size[0] < dci_size[2]) { // '0' corresponding to index for format0_0 and '2' corresponding to index of format1_0
+    //if (format == format0_0) {
+    dci_fields_sizes[PADDING_NR_DCI][0] = dci_size[2] - dci_size[0];
+    dci_size[0] = dci_size[2];
+    LOG_DDD("(nr_dci_format_size) new dci_size[format0_0]=%d\n",dci_size[0]);
+    //}
+  }
+
+  // If DCI format 0_0 is monitored in common search space and if the number of information bits in the DCI format 0_0 prior to padding
+  // is larger than the payload size of the DCI format 1_0 monitored in common search space for scheduling the same serving cell,
+  // the bitwidth of the frequency domain resource allocation field in the DCI format 0_0 is reduced
+  // such that the size of DCI format 0_0 equals to the size of the DCI format 1_0..
+  if (dci_size[0] > dci_size[2]) {
+    //if (format == format0_0) {
+    dci_fields_sizes[FREQ_DOM_RESOURCE_ASSIGNMENT_UL][0] -= (dci_size[0] - dci_size[2]);
+    dci_size[0] = dci_size[2];
+    LOG_DDD("(nr_dci_format_size) new dci_size[format0_0]=%d\n",dci_size[0]);
+    //}
+  }
+
+  /*
+   * TS 38.212 subclause 7.3.1.1.2
+   * For a UE configured with SUL in a cell:
+   * if PUSCH is configured to be transmitted on both the SUL and the non-SUL of the cell and
+   *              if the number of information bits in format 0_1 for the SUL
+   * is not equal to the number of information bits in format 0_1 for the non-SUL,
+   * zeros shall be appended to smaller format 0_1 until the payload size equals that of the larger format 0_1
+   *
+   * Not implemented. FIXME!!!
+   *
+   */
+  //  }
+  LOG_DDD("(nr_dci_format_size) dci_fields_sizes[][] = { \n");
+
+#ifdef NR_PDCCH_DCI_DEBUG
+  for (int j=0; j<NBR_NR_DCI_FIELDS; j++) {
+    printf("\t\t");
+
+    for (int i=0; i<NBR_NR_FORMATS ; i++) printf("%d\t",dci_fields_sizes[j][i]);
+
+    printf("\n");
+  }
+
+  printf(" }\n");
+#endif
+  return dci_size[format];
 }
 
+#endif
+
 //////////////
 /*
  * This code contains all the functions needed to process all dci fields.
@@ -743,549 +1316,544 @@ NR_UE_L2_STATE_t nr_ue_scheduler(
 // next four columns contain table 7.3.1.1.2-4: Precoding information and number of layers, for 2 antenna ports, if transformPrecoder=disabled and maxRank = 2
 // next four columns contain table 7.3.1.1.2-5: Precoding information and number of layers, for 2 antenna ports, if transformPrecoder= enabled, or if transformPrecoder= disabled and maxRank = 1
 uint8_t table_7_3_1_1_2_2_3_4_5[64][20] = {
-{1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0},
-{1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1},
-{1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  2,  0,  2,  0,  1,  2,  0,  0},
-{1,  3,  1,  3,  1,  3,  1,  3,  1,  3,  1,  3,  1,  2,  0,  0,  1,  3,  0,  0},
-{2,  0,  2,  0,  2,  0,  1,  4,  1,  4,  0,  0,  1,  3,  0,  0,  1,  4,  0,  0},
-{2,  1,  2,  1,  2,  1,  1,  5,  1,  5,  0,  0,  1,  4,  0,  0,  1,  5,  0,  0},
-{2,  2,  2,  2,  2,  2,  1,  6,  1,  6,  0,  0,  1,  5,  0,  0,  0,  0,  0,  0},
-{2,  3,  2,  3,  2,  3,  1,  7,  1,  7,  0,  0,  2,  1,  0,  0,  0,  0,  0,  0},
-{2,  4,  2,  4,  2,  4,  1,  8,  1,  8,  0,  0,  2,  2,  0,  0,  0,  0,  0,  0},
-{2,  5,  2,  5,  2,  5,  1,  9,  1,  9,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{3,  0,  3,  0,  3,  0,  1,  10, 1,  10, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{4,  0,  4,  0,  4,  0,  1,  11, 1,  11, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  4,  1,  4,  0,  0,  1,  12, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  5,  1,  5,  0,  0,  1,  13, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  6,  1,  6,  0,  0,  1,  14, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  7,  1,  7,  0,  0,  1,  15, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  8,  1,  8,  0,  0,  1,  16, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  9,  1,  9,  0,  0,  1,  17, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  10, 1,  10, 0,  0,  1,  18, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  11, 1,  11, 0,  0,  1,  19, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  6,  2,  6,  0,  0,  1,  20, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  7,  2,  7,  0,  0,  1,  21, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  8,  2,  8,  0,  0,  1,  22, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  9,  2,  9,  0,  0,  1,  23, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  10, 2,  10, 0,  0,  1,  24, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  11, 2,  11, 0,  0,  1,  25, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  12, 2,  12, 0,  0,  1,  26, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  13, 2,  13, 0,  0,  1,  27, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{3,  1,  3,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{3,  2,  3,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{4,  1,  4,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{4,  2,  4,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  12, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  13, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  14, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  15, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  16, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  17, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  18, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  19, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  20, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  21, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  22, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  23, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  24, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  25, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  26, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{1,  27, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  14, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  15, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  16, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  17, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  18, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  19, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  20, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{2,  21, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{3,  3,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{3,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{3,  5,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{3,  6,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{4,  3,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{4,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
-{0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
+  {1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0},
+  {1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1},
+  {1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  1,  2,  2,  0,  2,  0,  1,  2,  0,  0},
+  {1,  3,  1,  3,  1,  3,  1,  3,  1,  3,  1,  3,  1,  2,  0,  0,  1,  3,  0,  0},
+  {2,  0,  2,  0,  2,  0,  1,  4,  1,  4,  0,  0,  1,  3,  0,  0,  1,  4,  0,  0},
+  {2,  1,  2,  1,  2,  1,  1,  5,  1,  5,  0,  0,  1,  4,  0,  0,  1,  5,  0,  0},
+  {2,  2,  2,  2,  2,  2,  1,  6,  1,  6,  0,  0,  1,  5,  0,  0,  0,  0,  0,  0},
+  {2,  3,  2,  3,  2,  3,  1,  7,  1,  7,  0,  0,  2,  1,  0,  0,  0,  0,  0,  0},
+  {2,  4,  2,  4,  2,  4,  1,  8,  1,  8,  0,  0,  2,  2,  0,  0,  0,  0,  0,  0},
+  {2,  5,  2,  5,  2,  5,  1,  9,  1,  9,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {3,  0,  3,  0,  3,  0,  1,  10, 1,  10, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {4,  0,  4,  0,  4,  0,  1,  11, 1,  11, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  4,  1,  4,  0,  0,  1,  12, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  5,  1,  5,  0,  0,  1,  13, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  6,  1,  6,  0,  0,  1,  14, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  7,  1,  7,  0,  0,  1,  15, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  8,  1,  8,  0,  0,  1,  16, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  9,  1,  9,  0,  0,  1,  17, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  10, 1,  10, 0,  0,  1,  18, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  11, 1,  11, 0,  0,  1,  19, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  6,  2,  6,  0,  0,  1,  20, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  7,  2,  7,  0,  0,  1,  21, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  8,  2,  8,  0,  0,  1,  22, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  9,  2,  9,  0,  0,  1,  23, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  10, 2,  10, 0,  0,  1,  24, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  11, 2,  11, 0,  0,  1,  25, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  12, 2,  12, 0,  0,  1,  26, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  13, 2,  13, 0,  0,  1,  27, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {3,  1,  3,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {3,  2,  3,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {4,  1,  4,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {4,  2,  4,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  12, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  13, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  14, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  15, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  16, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  17, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  18, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  19, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  20, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  21, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  22, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  23, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  24, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  25, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  26, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {1,  27, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  14, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  15, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  16, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  17, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  18, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  19, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  20, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {2,  21, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {3,  3,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {3,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {3,  5,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {3,  6,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {4,  3,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {4,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
+  {0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0}
 };
 uint8_t table_7_3_1_1_2_12[14][3] = {
-{1,0,1},
-{1,1,1},
-{2,0,1},
-{2,1,1},
-{2,2,1},
-{2,3,1},
-{2,0,2},
-{2,1,2},
-{2,2,2},
-{2,3,2},
-{2,4,2},
-{2,5,2},
-{2,6,2},
-{2,7,2}
+  {1,0,1},
+  {1,1,1},
+  {2,0,1},
+  {2,1,1},
+  {2,2,1},
+  {2,3,1},
+  {2,0,2},
+  {2,1,2},
+  {2,2,2},
+  {2,3,2},
+  {2,4,2},
+  {2,5,2},
+  {2,6,2},
+  {2,7,2}
 };
 uint8_t table_7_3_1_1_2_13[10][4] = {
-{1,0,1,1},
-{2,0,1,1},
-{2,2,3,1},
-{2,0,2,1},
-{2,0,1,2},
-{2,2,3,2},
-{2,4,5,2},
-{2,6,7,2},
-{2,0,4,2},
-{2,2,6,2}
+  {1,0,1,1},
+  {2,0,1,1},
+  {2,2,3,1},
+  {2,0,2,1},
+  {2,0,1,2},
+  {2,2,3,2},
+  {2,4,5,2},
+  {2,6,7,2},
+  {2,0,4,2},
+  {2,2,6,2}
 };
 uint8_t table_7_3_1_1_2_14[3][5] = {
-{2,0,1,2,1},
-{2,0,1,4,2},
-{2,2,3,6,2}
+  {2,0,1,2,1},
+  {2,0,1,4,2},
+  {2,2,3,6,2}
 };
 uint8_t table_7_3_1_1_2_15[4][6] = {
-{2,0,1,2,3,1},
-{2,0,1,4,5,2},
-{2,2,3,6,7,2},
-{2,0,2,4,6,2}
+  {2,0,1,2,3,1},
+  {2,0,1,4,5,2},
+  {2,2,3,6,7,2},
+  {2,0,2,4,6,2}
 };
 uint8_t table_7_3_1_1_2_16[12][2] = {
-{1,0},
-{1,1},
-{2,0},
-{2,1},
-{2,2},
-{2,3},
-{3,0},
-{3,1},
-{3,2},
-{3,3},
-{3,4},
-{3,5}
+  {1,0},
+  {1,1},
+  {2,0},
+  {2,1},
+  {2,2},
+  {2,3},
+  {3,0},
+  {3,1},
+  {3,2},
+  {3,3},
+  {3,4},
+  {3,5}
 };
 uint8_t table_7_3_1_1_2_17[7][3] = {
-{1,0,1},
-{2,0,1},
-{2,2,3},
-{3,0,1},
-{3,2,3},
-{3,4,5},
-{2,0,2}
+  {1,0,1},
+  {2,0,1},
+  {2,2,3},
+  {3,0,1},
+  {3,2,3},
+  {3,4,5},
+  {2,0,2}
 };
 uint8_t table_7_3_1_1_2_18[3][4] = {
-{2,0,1,2},
-{3,0,1,2},
-{3,3,4,5}
+  {2,0,1,2},
+  {3,0,1,2},
+  {3,3,4,5}
 };
 uint8_t table_7_3_1_1_2_19[2][5] = {
-{2,0,1,2,3},
-{3,0,1,2,3}
+  {2,0,1,2,3},
+  {3,0,1,2,3}
 };
 uint8_t table_7_3_1_1_2_20[28][3] = {
-{1,0,1},
-{1,1,1},
-{2,0,1},
-{2,1,1},
-{2,2,1},
-{2,3,1},
-{3,0,1},
-{3,1,1},
-{3,2,1},
-{3,3,1},
-{3,4,1},
-{3,5,1},
-{3,0,2},
-{3,1,2},
-{3,2,2},
-{3,3,2},
-{3,4,2},
-{3,5,2},
-{3,6,2},
-{3,7,2},
-{3,8,2},
-{3,9,2},
-{3,10,2},
-{3,11,2},
-{1,0,2},
-{1,1,2},
-{1,6,2},
-{1,7,2}
+  {1,0,1},
+  {1,1,1},
+  {2,0,1},
+  {2,1,1},
+  {2,2,1},
+  {2,3,1},
+  {3,0,1},
+  {3,1,1},
+  {3,2,1},
+  {3,3,1},
+  {3,4,1},
+  {3,5,1},
+  {3,0,2},
+  {3,1,2},
+  {3,2,2},
+  {3,3,2},
+  {3,4,2},
+  {3,5,2},
+  {3,6,2},
+  {3,7,2},
+  {3,8,2},
+  {3,9,2},
+  {3,10,2},
+  {3,11,2},
+  {1,0,2},
+  {1,1,2},
+  {1,6,2},
+  {1,7,2}
 };
 uint8_t table_7_3_1_1_2_21[19][4] = {
-{1,0,1,1},
-{2,0,1,1},
-{2,2,3,1},
-{3,0,1,1},
-{3,2,3,1},
-{3,4,5,1},
-{2,0,2,1},
-{3,0,1,2},
-{3,2,3,2},
-{3,4,5,2},
-{3,6,7,2},
-{3,8,9,2},
-{3,10,11,2},
-{1,0,1,2},
-{1,6,7,2},
-{2,0,1,2},
-{2,2,3,2},
-{2,6,7,2},
-{2,8,9,2}
+  {1,0,1,1},
+  {2,0,1,1},
+  {2,2,3,1},
+  {3,0,1,1},
+  {3,2,3,1},
+  {3,4,5,1},
+  {2,0,2,1},
+  {3,0,1,2},
+  {3,2,3,2},
+  {3,4,5,2},
+  {3,6,7,2},
+  {3,8,9,2},
+  {3,10,11,2},
+  {1,0,1,2},
+  {1,6,7,2},
+  {2,0,1,2},
+  {2,2,3,2},
+  {2,6,7,2},
+  {2,8,9,2}
 };
 uint8_t table_7_3_1_1_2_22[6][5] = {
-{2,0,1,2,1},
-{3,0,1,2,1},
-{3,3,4,5,1},
-{3,0,1,6,2},
-{3,2,3,8,2},
-{3,4,5,10,2}
+  {2,0,1,2,1},
+  {3,0,1,2,1},
+  {3,3,4,5,1},
+  {3,0,1,6,2},
+  {3,2,3,8,2},
+  {3,4,5,10,2}
 };
 uint8_t table_7_3_1_1_2_23[5][6] = {
-{2,0,1,2,3,1},
-{3,0,1,2,3,1},
-{3,0,1,6,7,2},
-{3,2,3,8,9,2},
-{3,4,5,10,11,2}
+  {2,0,1,2,3,1},
+  {3,0,1,2,3,1},
+  {3,0,1,6,7,2},
+  {3,2,3,8,9,2},
+  {3,4,5,10,11,2}
 };
 uint8_t table_7_3_2_3_3_1[12][5] = {
-{1,0,0,0,0},
-{1,1,0,0,0},
-{1,0,1,0,0},
-{2,0,0,0,0},
-{2,1,0,0,0},
-{2,2,0,0,0},
-{2,3,0,0,0},
-{2,0,1,0,0},
-{2,2,3,0,0},
-{2,0,1,2,0},
-{2,0,1,2,3},
-{2,0,2,0,0}
+  {1,0,0,0,0},
+  {1,1,0,0,0},
+  {1,0,1,0,0},
+  {2,0,0,0,0},
+  {2,1,0,0,0},
+  {2,2,0,0,0},
+  {2,3,0,0,0},
+  {2,0,1,0,0},
+  {2,2,3,0,0},
+  {2,0,1,2,0},
+  {2,0,1,2,3},
+  {2,0,2,0,0}
 };
 uint8_t table_7_3_2_3_3_2_oneCodeword[31][6] = {
-{1,0,0,0,0,1},
-{1,1,0,0,0,1},
-{1,0,1,0,0,1},
-{2,0,0,0,0,1},
-{2,1,0,0,0,1},
-{2,2,0,0,0,1},
-{2,3,0,0,0,1},
-{2,0,1,0,0,1},
-{2,2,3,0,0,1},
-{2,0,1,2,0,1},
-{2,0,1,2,3,1},
-{2,0,2,0,0,1},
-{2,0,0,0,0,2},
-{2,1,0,0,0,2},
-{2,2,0,0,0,2},
-{2,3,0,0,0,2},
-{2,4,0,0,0,2},
-{2,5,0,0,0,2},
-{2,6,0,0,0,2},
-{2,7,0,0,0,2},
-{2,0,1,0,0,2},
-{2,2,3,0,0,2},
-{2,4,5,0,0,2},
-{2,6,7,0,0,2},
-{2,0,4,0,0,2},
-{2,2,6,0,0,2},
-{2,0,1,4,0,2},
-{2,2,3,6,0,2},
-{2,0,1,4,5,2},
-{2,2,3,6,7,2},
-{2,0,2,4,6,2}
+  {1,0,0,0,0,1},
+  {1,1,0,0,0,1},
+  {1,0,1,0,0,1},
+  {2,0,0,0,0,1},
+  {2,1,0,0,0,1},
+  {2,2,0,0,0,1},
+  {2,3,0,0,0,1},
+  {2,0,1,0,0,1},
+  {2,2,3,0,0,1},
+  {2,0,1,2,0,1},
+  {2,0,1,2,3,1},
+  {2,0,2,0,0,1},
+  {2,0,0,0,0,2},
+  {2,1,0,0,0,2},
+  {2,2,0,0,0,2},
+  {2,3,0,0,0,2},
+  {2,4,0,0,0,2},
+  {2,5,0,0,0,2},
+  {2,6,0,0,0,2},
+  {2,7,0,0,0,2},
+  {2,0,1,0,0,2},
+  {2,2,3,0,0,2},
+  {2,4,5,0,0,2},
+  {2,6,7,0,0,2},
+  {2,0,4,0,0,2},
+  {2,2,6,0,0,2},
+  {2,0,1,4,0,2},
+  {2,2,3,6,0,2},
+  {2,0,1,4,5,2},
+  {2,2,3,6,7,2},
+  {2,0,2,4,6,2}
 };
 uint8_t table_7_3_2_3_3_2_twoCodeword[4][10] = {
-{2,0,1,2,3,4,0,0,0,2},
-{2,0,1,2,3,4,6,0,0,2},
-{2,0,1,2,3,4,5,6,0,2},
-{2,0,1,2,3,4,5,6,7,2}
+  {2,0,1,2,3,4,0,0,0,2},
+  {2,0,1,2,3,4,6,0,0,2},
+  {2,0,1,2,3,4,5,6,0,2},
+  {2,0,1,2,3,4,5,6,7,2}
 };
 uint8_t table_7_3_2_3_3_3_oneCodeword[24][5] = {
-{1,0,0,0,0},
-{1,1,0,0,0},
-{1,0,1,0,0},
-{2,0,0,0,0},
-{2,1,0,0,0},
-{2,2,0,0,0},
-{2,3,0,0,0},
-{2,0,1,0,0},
-{2,2,3,0,0},
-{2,0,1,2,0},
-{2,0,1,2,3},
-{3,0,0,0,0},
-{3,1,0,0,0},
-{3,2,0,0,0},
-{3,3,0,0,0},
-{3,4,0,0,0},
-{3,5,0,0,0},
-{3,0,1,0,0},
-{3,2,3,0,0},
-{3,4,5,0,0},
-{3,0,1,2,0},
-{3,3,4,5,0},
-{3,0,1,2,3},
-{2,0,2,0,0}
+  {1,0,0,0,0},
+  {1,1,0,0,0},
+  {1,0,1,0,0},
+  {2,0,0,0,0},
+  {2,1,0,0,0},
+  {2,2,0,0,0},
+  {2,3,0,0,0},
+  {2,0,1,0,0},
+  {2,2,3,0,0},
+  {2,0,1,2,0},
+  {2,0,1,2,3},
+  {3,0,0,0,0},
+  {3,1,0,0,0},
+  {3,2,0,0,0},
+  {3,3,0,0,0},
+  {3,4,0,0,0},
+  {3,5,0,0,0},
+  {3,0,1,0,0},
+  {3,2,3,0,0},
+  {3,4,5,0,0},
+  {3,0,1,2,0},
+  {3,3,4,5,0},
+  {3,0,1,2,3},
+  {2,0,2,0,0}
 };
 uint8_t table_7_3_2_3_3_3_twoCodeword[2][7] = {
-{3,0,1,2,3,4,0},
-{3,0,1,2,3,4,5}
+  {3,0,1,2,3,4,0},
+  {3,0,1,2,3,4,5}
 };
 uint8_t table_7_3_2_3_3_4_oneCodeword[58][6] = {
-{1,0,0,0,0,1},
-{1,1,0,0,0,1},
-{1,0,1,0,0,1},
-{2,0,0,0,0,1},
-{2,1,0,0,0,1},
-{2,2,0,0,0,1},
-{2,3,0,0,0,1},
-{2,0,1,0,0,1},
-{2,2,3,0,0,1},
-{2,0,1,2,0,1},
-{2,0,1,2,3,1},
-{3,0,0,0,0,1},
-{3,1,0,0,0,1},
-{3,2,0,0,0,1},
-{3,3,0,0,0,1},
-{3,4,0,0,0,1},
-{3,5,0,0,0,1},
-{3,0,1,0,0,1},
-{3,2,3,0,0,1},
-{3,4,5,0,0,1},
-{3,0,1,2,0,1},
-{3,3,4,5,0,1},
-{3,0,1,2,3,1},
-{2,0,2,0,0,1},
-{3,0,0,0,0,2},
-{3,1,0,0,0,2},
-{3,2,0,0,0,2},
-{3,3,0,0,0,2},
-{3,4,0,0,0,2},
-{3,5,0,0,0,2},
-{3,6,0,0,0,2},
-{3,7,0,0,0,2},
-{3,8,0,0,0,2},
-{3,9,0,0,0,2},
-{3,10,0,0,0,2},
-{3,11,0,0,0,2},
-{3,0,1,0,0,2},
-{3,2,3,0,0,2},
-{3,4,5,0,0,2},
-{3,6,7,0,0,2},
-{3,8,9,0,0,2},
-{3,10,11,0,0,2},
-{3,0,1,6,0,2},
-{3,2,3,8,0,2},
-{3,4,5,10,0,2},
-{3,0,1,6,7,2},
-{3,2,3,8,9,2},
-{3,4,5,10,11,2},
-{1,0,0,0,0,2},
-{1,1,0,0,0,2},
-{1,6,0,0,0,2},
-{1,7,0,0,0,2},
-{1,0,1,0,0,2},
-{1,6,7,0,0,2},
-{2,0,1,0,0,2},
-{2,2,3,0,0,2},
-{2,6,7,0,0,2},
-{2,8,9,0,0,2}
+  {1,0,0,0,0,1},
+  {1,1,0,0,0,1},
+  {1,0,1,0,0,1},
+  {2,0,0,0,0,1},
+  {2,1,0,0,0,1},
+  {2,2,0,0,0,1},
+  {2,3,0,0,0,1},
+  {2,0,1,0,0,1},
+  {2,2,3,0,0,1},
+  {2,0,1,2,0,1},
+  {2,0,1,2,3,1},
+  {3,0,0,0,0,1},
+  {3,1,0,0,0,1},
+  {3,2,0,0,0,1},
+  {3,3,0,0,0,1},
+  {3,4,0,0,0,1},
+  {3,5,0,0,0,1},
+  {3,0,1,0,0,1},
+  {3,2,3,0,0,1},
+  {3,4,5,0,0,1},
+  {3,0,1,2,0,1},
+  {3,3,4,5,0,1},
+  {3,0,1,2,3,1},
+  {2,0,2,0,0,1},
+  {3,0,0,0,0,2},
+  {3,1,0,0,0,2},
+  {3,2,0,0,0,2},
+  {3,3,0,0,0,2},
+  {3,4,0,0,0,2},
+  {3,5,0,0,0,2},
+  {3,6,0,0,0,2},
+  {3,7,0,0,0,2},
+  {3,8,0,0,0,2},
+  {3,9,0,0,0,2},
+  {3,10,0,0,0,2},
+  {3,11,0,0,0,2},
+  {3,0,1,0,0,2},
+  {3,2,3,0,0,2},
+  {3,4,5,0,0,2},
+  {3,6,7,0,0,2},
+  {3,8,9,0,0,2},
+  {3,10,11,0,0,2},
+  {3,0,1,6,0,2},
+  {3,2,3,8,0,2},
+  {3,4,5,10,0,2},
+  {3,0,1,6,7,2},
+  {3,2,3,8,9,2},
+  {3,4,5,10,11,2},
+  {1,0,0,0,0,2},
+  {1,1,0,0,0,2},
+  {1,6,0,0,0,2},
+  {1,7,0,0,0,2},
+  {1,0,1,0,0,2},
+  {1,6,7,0,0,2},
+  {2,0,1,0,0,2},
+  {2,2,3,0,0,2},
+  {2,6,7,0,0,2},
+  {2,8,9,0,0,2}
 };
 uint8_t table_7_3_2_3_3_4_twoCodeword[6][10] = {
-{3,0,1,2,3,4,0,0,0,1},
-{3,0,1,2,3,4,5,0,0,1},
-{2,0,1,2,3,6,0,0,0,2},
-{2,0,1,2,3,6,8,0,0,2},
-{2,0,1,2,3,6,7,8,0,2},
-{2,0,1,2,3,6,7,8,9,2}
+  {3,0,1,2,3,4,0,0,0,1},
+  {3,0,1,2,3,4,5,0,0,1},
+  {2,0,1,2,3,6,0,0,0,2},
+  {2,0,1,2,3,6,8,0,0,2},
+  {2,0,1,2,3,6,7,8,0,2},
+  {2,0,1,2,3,6,7,8,9,2}
 };
-int8_t nr_ue_process_dci_freq_dom_resource_assignment(
-  fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu,
-  fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu,
-  uint16_t n_RB_ULBWP,
-  uint16_t n_RB_DLBWP,
-  uint16_t riv
-){
-  uint16_t l_RB;
-  uint16_t start_RB;
-  uint16_t tmp_RIV;
+int8_t nr_ue_process_dci_freq_dom_resource_assignment(fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu,
+						      fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu,
+						      uint16_t n_RB_ULBWP,
+						      uint16_t n_RB_DLBWP,
+						      uint16_t riv
+						      ){
 
-/*
- * TS 38.214 subclause 5.1.2.2 Resource allocation in frequency domain (downlink)
- * when the scheduling grant is received with DCI format 1_0, then downlink resource allocation type 1 is used
- */
-  if(dlsch_config_pdu != NULL){
   /*
-   * TS 38.214 subclause 5.1.2.2.1 Downlink resource allocation type 0
+   * TS 38.214 subclause 5.1.2.2 Resource allocation in frequency domain (downlink)
+   * when the scheduling grant is received with DCI format 1_0, then downlink resource allocation type 1 is used
    */
-  /*
-   * TS 38.214 subclause 5.1.2.2.2 Downlink resource allocation type 1
-   */
-    // For resource allocation type 1, the resource allocation field consists of a resource indication value (RIV):
-    // RIV = n_RB_DLBWP * (l_RB - 1) + start_RB                                  if (l_RB - 1) <= floor (n_RB_DLBWP/2)
-    // RIV = n_RB_DLBWP * (n_RB_DLBWP - l_RB + 1) + (n_RB_DLBWP - 1 - start_RB)  if (l_RB - 1)  > floor (n_RB_DLBWP/2)
-    // the following two expressions apply only if (l_RB - 1) <= floor (n_RB_DLBWP/2)
-    l_RB = floor(riv/n_RB_DLBWP) + 1;
-    start_RB = riv%n_RB_DLBWP;
-    // if (l_RB - 1)  > floor (n_RB_DLBWP/2) we need to recalculate them using the following lines
-    tmp_RIV = n_RB_DLBWP * (l_RB - 1) + start_RB;
-    if ((tmp_RIV != riv) || ((start_RB+l_RB)>n_RB_DLBWP)) { // then (l_RB - 1)  > floor (n_RB_DLBWP/2) and we need to recalculate l_RB and start_RB
-      l_RB = n_RB_DLBWP - l_RB + 2;
-      start_RB = n_RB_DLBWP - start_RB - 1;
-    }
-    dlsch_config_pdu->number_rbs = l_RB;
-    dlsch_config_pdu->start_rb = start_RB;
+  if(dlsch_config_pdu != NULL){
+
+    /*
+     * TS 38.214 subclause 5.1.2.2.1 Downlink resource allocation type 0
+     */
+    /*
+     * TS 38.214 subclause 5.1.2.2.2 Downlink resource allocation type 1
+     */
+    dlsch_config_pdu->number_rbs = NRRIV2BW(riv,n_RB_DLBWP);
+    dlsch_config_pdu->start_rb   = NRRIV2PRBOFFSET(riv,n_RB_DLBWP);
+
   }
   if(ulsch_config_pdu != NULL){
-/*
- * TS 38.214 subclause 6.1.2.2 Resource allocation in frequency domain (uplink)
- */
-  /*
-   * TS 38.214 subclause 6.1.2.2.1 Uplink resource allocation type 0
-   */
-  /*
-   * TS 38.214 subclause 6.1.2.2.2 Uplink resource allocation type 1
-   */
-    // For resource allocation type 1, the resource allocation field consists of a resource indication value (RIV):
-    // RIV = n_RB_ULBWP * (l_RB - 1) + start_RB                                  if (l_RB - 1) <= floor (n_RB_ULBWP/2)
-    // RIV = n_RB_ULBWP * (n_RB_ULBWP - l_RB + 1) + (n_RB_ULBWP - 1 - start_RB)  if (l_RB - 1)  > floor (n_RB_ULBWP/2)
-    // the following two expressions apply only if (l_RB - 1) <= floor (n_RB_ULBWP/2)
-    l_RB = floor(riv/n_RB_ULBWP) + 1;
-    start_RB = riv%n_RB_ULBWP;
-    // if (l_RB - 1)  > floor (n_RB_ULBWP/2) we need to recalculate them using the following lines
-    tmp_RIV = n_RB_ULBWP * (l_RB - 1) + start_RB;
-    if (tmp_RIV != riv) { // then (l_RB - 1)  > floor (n_RB_ULBWP/2) and we need to recalculate l_RB and start_RB
-        l_RB = n_RB_ULBWP - l_RB + 2;
-        start_RB = n_RB_ULBWP - start_RB - 1;
-    }
-    ulsch_config_pdu->number_rbs = l_RB;
-    ulsch_config_pdu->start_rb = start_RB;
+    /*
+     * TS 38.214 subclause 6.1.2.2 Resource allocation in frequency domain (uplink)
+     */
+    /*
+     * TS 38.214 subclause 6.1.2.2.1 Uplink resource allocation type 0
+     */
+    /*
+     * TS 38.214 subclause 6.1.2.2.2 Uplink resource allocation type 1
+     */
+
+    ulsch_config_pdu->number_rbs = NRRIV2BW(riv,n_RB_ULBWP);
+    ulsch_config_pdu->start_rb   = NRRIV2PRBOFFSET(riv,n_RB_ULBWP);
   }
   return 0;
 }
 
-int8_t nr_ue_process_dci_time_dom_resource_assignment(
-  fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu,
-  fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu,
-  uint8_t time_domain_ind,
-  long dmrs_typeA_pos //0=pos2,1=pos3
-){
+int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac,
+						      fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu,
+						      fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu,
+						      uint8_t time_domain_ind
+						      ){
+  int dmrs_typeA_pos = mac->scc->dmrs_TypeA_Position;
   uint8_t k_offset=0;
   uint8_t sliv_S=0;
   uint8_t sliv_L=0;
   uint8_t table_5_1_2_1_1_2_time_dom_res_alloc_A[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1
-  {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?12:11}, // row index 1
-  {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?10:9},  // row index 2
-  {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?9:8},   // row index 3
-  {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?7:6},   // row index 4
-  {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?5:4},   // row index 5
-  {0,(dmrs_typeA_pos == 0)?9:10,(dmrs_typeA_pos == 0)?4:4},   // row index 6
-  {0,(dmrs_typeA_pos == 0)?4:6, (dmrs_typeA_pos == 0)?4:4},   // row index 7
-  {0,5,7},  // row index 8
-  {0,5,2},  // row index 9
-  {0,9,2},  // row index 10
-  {0,12,2}, // row index 11
-  {0,1,13}, // row index 12
-  {0,1,6},  // row index 13
-  {0,2,4},  // row index 14
-  {0,4,7},  // row index 15
-  {0,8,4}   // row index 16
+    {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?12:11}, // row index 1
+    {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?10:9},  // row index 2
+    {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?9:8},   // row index 3
+    {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?7:6},   // row index 4
+    {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?5:4},   // row index 5
+    {0,(dmrs_typeA_pos == 0)?9:10,(dmrs_typeA_pos == 0)?4:4},   // row index 6
+    {0,(dmrs_typeA_pos == 0)?4:6, (dmrs_typeA_pos == 0)?4:4},   // row index 7
+    {0,5,7},  // row index 8
+    {0,5,2},  // row index 9
+    {0,9,2},  // row index 10
+    {0,12,2}, // row index 11
+    {0,1,13}, // row index 12
+    {0,1,6},  // row index 13
+    {0,2,4},  // row index 14
+    {0,4,7},  // row index 15
+    {0,8,4}   // row index 16
   };
   /*uint8_t table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1
-  {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?6:5},   // row index 1
-  {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?10:9},  // row index 2
-  {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?9:8},   // row index 3
-  {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?7:6},   // row index 4
-  {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?5:4},   // row index 5
-  {0,(dmrs_typeA_pos == 0)?6:8, (dmrs_typeA_pos == 0)?4:2},   // row index 6
-  {0,(dmrs_typeA_pos == 0)?4:6, (dmrs_typeA_pos == 0)?4:4},   // row index 7
-  {0,5,6},  // row index 8
-  {0,5,2},  // row index 9
-  {0,9,2},  // row index 10
-  {0,10,2}, // row index 11
-  {0,1,11}, // row index 12
-  {0,1,6},  // row index 13
-  {0,2,4},  // row index 14
-  {0,4,6},  // row index 15
-  {0,8,4}   // row index 16
-  };*/
+    {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?6:5},   // row index 1
+    {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?10:9},  // row index 2
+    {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?9:8},   // row index 3
+    {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?7:6},   // row index 4
+    {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?5:4},   // row index 5
+    {0,(dmrs_typeA_pos == 0)?6:8, (dmrs_typeA_pos == 0)?4:2},   // row index 6
+    {0,(dmrs_typeA_pos == 0)?4:6, (dmrs_typeA_pos == 0)?4:4},   // row index 7
+    {0,5,6},  // row index 8
+    {0,5,2},  // row index 9
+    {0,9,2},  // row index 10
+    {0,10,2}, // row index 11
+    {0,1,11}, // row index 12
+    {0,1,6},  // row index 13
+    {0,2,4},  // row index 14
+    {0,4,6},  // row index 15
+    {0,8,4}   // row index 16
+    };*/
   /*uint8_t table_5_1_2_1_1_4_time_dom_res_alloc_B[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1
-  {0,2,2},  // row index 1
-  {0,4,2},  // row index 2
-  {0,6,2},  // row index 3
-  {0,8,2},  // row index 4
-  {0,10,2}, // row index 5
-  {1,2,2},  // row index 6
-  {1,4,2},  // row index 7
-  {0,2,4},  // row index 8
-  {0,4,4},  // row index 9
-  {0,6,4},  // row index 10
-  {0,8,4},  // row index 11
-  {0,10,4}, // row index 12
-  {0,2,7},  // row index 13
-  {0,(dmrs_typeA_pos == 0)?2:3,(dmrs_typeA_pos == 0)?12:11},  // row index 14
-  {1,2,4},  // row index 15
-  {0,0,0}   // row index 16
-  };*/
+    {0,2,2},  // row index 1
+    {0,4,2},  // row index 2
+    {0,6,2},  // row index 3
+    {0,8,2},  // row index 4
+    {0,10,2}, // row index 5
+    {1,2,2},  // row index 6
+    {1,4,2},  // row index 7
+    {0,2,4},  // row index 8
+    {0,4,4},  // row index 9
+    {0,6,4},  // row index 10
+    {0,8,4},  // row index 11
+    {0,10,4}, // row index 12
+    {0,2,7},  // row index 13
+    {0,(dmrs_typeA_pos == 0)?2:3,(dmrs_typeA_pos == 0)?12:11},  // row index 14
+    {1,2,4},  // row index 15
+    {0,0,0}   // row index 16
+    };*/
   /*uint8_t table_5_1_2_1_1_5_time_dom_res_alloc_C[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1
-  {0,2,2},  // row index 1
-  {0,4,2},  // row index 2
-  {0,6,2},  // row index 3
-  {0,8,2},  // row index 4
-  {0,10,2}, // row index 5
-  {0,0,0},  // row index 6
-  {0,0,0},  // row index 7
-  {0,2,4},  // row index 8
-  {0,4,4},  // row index 9
-  {0,6,4},  // row index 10
-  {0,8,4},  // row index 11
-  {0,10,4}, // row index 12
-  {0,2,7},  // row index 13
-  {0,(dmrs_typeA_pos == 0)?2:3,(dmrs_typeA_pos == 0)?12:11},  // row index 14
-  {0,0,6},  // row index 15
-  {0,2,6}   // row index 16
-  };*/
+    {0,2,2},  // row index 1
+    {0,4,2},  // row index 2
+    {0,6,2},  // row index 3
+    {0,8,2},  // row index 4
+    {0,10,2}, // row index 5
+    {0,0,0},  // row index 6
+    {0,0,0},  // row index 7
+    {0,2,4},  // row index 8
+    {0,4,4},  // row index 9
+    {0,6,4},  // row index 10
+    {0,8,4},  // row index 11
+    {0,10,4}, // row index 12
+    {0,2,7},  // row index 13
+    {0,(dmrs_typeA_pos == 0)?2:3,(dmrs_typeA_pos == 0)?12:11},  // row index 14
+    {0,0,6},  // row index 15
+    {0,2,6}   // row index 16
+    };*/
   uint8_t mu_pusch = 1;
   // definition table j Table 6.1.2.1.1-4
   uint8_t j = (mu_pusch==3)?3:(mu_pusch==2)?2:1;
   uint8_t table_6_1_2_1_1_2_time_dom_res_alloc_A[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1
-  {j,  0,14}, // row index 1
-  {j,  0,12}, // row index 2
-  {j,  0,10}, // row index 3
-  {j,  2,10}, // row index 4
-  {j,  4,10}, // row index 5
-  {j,  4,8},  // row index 6
-  {j,  4,6},  // row index 7
-  {j+1,0,14}, // row index 8
-  {j+1,0,12}, // row index 9
-  {j+1,0,10}, // row index 10
-  {j+2,0,14}, // row index 11
-  {j+2,0,12}, // row index 12
-  {j+2,0,10}, // row index 13
-  {j,  8,6},  // row index 14
-  {j+3,0,14}, // row index 15
-  {j+3,0,10}  // row index 16
+    {j,  0,14}, // row index 1
+    {j,  0,12}, // row index 2
+    {j,  0,10}, // row index 3
+    {j,  2,10}, // row index 4
+    {j,  4,10}, // row index 5
+    {j,  4,8},  // row index 6
+    {j,  4,6},  // row index 7
+    {j+1,0,14}, // row index 8
+    {j+1,0,12}, // row index 9
+    {j+1,0,10}, // row index 10
+    {j+2,0,14}, // row index 11
+    {j+2,0,12}, // row index 12
+    {j+2,0,10}, // row index 13
+    {j,  8,6},  // row index 14
+    {j+3,0,14}, // row index 15
+    {j+3,0,10}  // row index 16
   };
   /*uint8_t table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1
-  {j,  0,8},  // row index 1
-  {j,  0,12}, // row index 2
-  {j,  0,10}, // row index 3
-  {j,  2,10}, // row index 4
-  {j,  4,4},  // row index 5
-  {j,  4,8},  // row index 6
-  {j,  4,6},  // row index 7
-  {j+1,0,8},  // row index 8
-  {j+1,0,12}, // row index 9
-  {j+1,0,10}, // row index 10
-  {j+2,0,6},  // row index 11
-  {j+2,0,12}, // row index 12
-  {j+2,0,10}, // row index 13
-  {j,  8,4},  // row index 14
-  {j+3,0,8},  // row index 15
-  {j+3,0,10}  // row index 16
-  };*/
+    {j,  0,8},  // row index 1
+    {j,  0,12}, // row index 2
+    {j,  0,10}, // row index 3
+    {j,  2,10}, // row index 4
+    {j,  4,4},  // row index 5
+    {j,  4,8},  // row index 6
+    {j,  4,6},  // row index 7
+    {j+1,0,8},  // row index 8
+    {j+1,0,12}, // row index 9
+    {j+1,0,10}, // row index 10
+    {j+2,0,6},  // row index 11
+    {j+2,0,12}, // row index 12
+    {j+2,0,10}, // row index 13
+    {j,  8,4},  // row index 14
+    {j+3,0,8},  // row index 15
+    {j+3,0,10}  // row index 16
+    };*/
 
-/*
- * TS 38.214 subclause 5.1.2.1 Resource allocation in time domain (downlink)
- */
+  /*
+   * TS 38.214 subclause 5.1.2.1 Resource allocation in time domain (downlink)
+   */
   if(dlsch_config_pdu != NULL){
+    NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL;
+    if (mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList)
+      pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList->choice.setup;
+    else if (mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList)
+      pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList;
+    if (pdsch_TimeDomainAllocationList) {
+
+      AssertFatal(pdsch_TimeDomainAllocationList->list.count > time_domain_ind,
+		  "time_domain_ind %d >= pdsch->TimeDomainAllocationList->list.count %d\n",
+		  time_domain_ind,pdsch_TimeDomainAllocationList->list.count);
+      int startSymbolAndLength = pdsch_TimeDomainAllocationList->list.array[time_domain_ind]->startSymbolAndLength;
+      int S,L;
+      SLIV2SL(startSymbolAndLength,&S,&L);
+      dlsch_config_pdu->start_symbol=S;
+      dlsch_config_pdu->number_symbols=L;
+      dlsch_config_pdu->frame_offset = pdsch_TimeDomainAllocationList->list.array[time_domain_ind]->k0!=NULL ?
+	*pdsch_TimeDomainAllocationList->list.array[time_domain_ind]->k0 : 
+	0;
+    }
+    else {// Default configuration from tables
       k_offset = table_5_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind-1][0];
       sliv_S   = table_5_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind-1][1];
       sliv_L   = table_5_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind-1][2];
@@ -1301,10 +1869,30 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(
       dlsch_config_pdu->frame_offset = k_offset;
       dlsch_config_pdu->number_symbols = sliv_L;
       dlsch_config_pdu->start_symbol = sliv_S;
+    }
   }	/*
- * TS 38.214 subclause 6.1.2.1 Resource allocation in time domain (uplink)
- */
+	 * TS 38.214 subclause 6.1.2.1 Resource allocation in time domain (uplink)
+	 */
   if(ulsch_config_pdu != NULL){
+    NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL;
+    if (mac->ULbwp[0]->bwp_Dedicated->pusch_Config)
+      pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList->choice.setup;
+	
+    if (pusch_TimeDomainAllocationList) {
+      AssertFatal(pusch_TimeDomainAllocationList->list.count > time_domain_ind,
+		  "time_domain_ind %d >= pdsch->TimeDomainAllocationList->list.count %d\n",
+		  time_domain_ind,pusch_TimeDomainAllocationList->list.count);
+      int startSymbolAndLength = pusch_TimeDomainAllocationList->list.array[time_domain_ind]->startSymbolAndLength;
+      int S,L;
+      SLIV2SL(startSymbolAndLength,&S,&L);
+      ulsch_config_pdu->start_symbol=S;
+      ulsch_config_pdu->number_symbols=L;
+      ulsch_config_pdu->frame_offset = pusch_TimeDomainAllocationList->list.array[time_domain_ind]->k2!=NULL ?
+	*pusch_TimeDomainAllocationList->list.array[time_domain_ind]->k2 : 
+	 mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing < NR_SubcarrierSpacing_kHz60 ? 1 :
+	mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing < NR_SubcarrierSpacing_kHz120 ? 2 : 3;
+    }
+    else {
       k_offset = table_6_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind-1][0];
       sliv_S   = table_6_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind-1][1];
       sliv_L   = table_6_1_2_1_1_2_time_dom_res_alloc_A[time_domain_ind-1][2];
@@ -1314,766 +1902,786 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(
       ulsch_config_pdu->frame_offset = k_offset;
       ulsch_config_pdu->number_symbols = sliv_L;
       ulsch_config_pdu->start_symbol = sliv_S;
+    }
   }
   return 0;
 }
 //////////////
+int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_index,fapi_nr_dci_indication_pdu_t *dci) {
 
-int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format){
-
-    NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
-    fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request;
-    fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request;
-    
-    //const uint16_t n_RB_DLBWP = dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP; //make sure this has been set
-    const uint16_t n_RB_DLBWP = mac->initial_bwp_dl.N_RB;
-    const uint16_t n_RB_ULBWP = mac->initial_bwp_ul.N_RB;
+  NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
+  nr_dci_pdu_rel15_t dci_pdu_rel15;
 
-    LOG_I(MAC,"nr_ue_process_dci at MAC layer with dci_format=%d (DL BWP %d, UL BWP %d)\n",dci_format,n_RB_DLBWP,n_RB_ULBWP);
+  LOG_D(MAC,"Received dci indication (rnti %x,dci format %d,n_CCE %d,payloadSize %d,payload %llx)\n",
+	dci->rnti,dci->dci_format,dci->n_CCE,dci->payloadSize,*(unsigned long long*)dci->payloadBits);
 
-    switch(dci_format){
-        case format0_0:
-/*
- *  with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI
- *    0  IDENTIFIER_DCI_FORMATS:
- *    10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered
- *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
- *    17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0
- *    24 MCS:
- *    25 NDI:
- *    26 RV:
- *    27 HARQ_PROCESS_NUMBER:
- *    32 TPC_PUSCH:
- *    49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space
- *    50 SUL_IND_0_0:
- */
-            ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
-            ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti;
-            fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu_0_0 = &ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15;
-        /* IDENTIFIER_DCI_FORMATS */
-        /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */
-            nr_ue_process_dci_freq_dom_resource_assignment(ulsch_config_pdu_0_0,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL);
-        /* TIME_DOM_RESOURCE_ASSIGNMENT */
-            nr_ue_process_dci_time_dom_resource_assignment(ulsch_config_pdu_0_0,NULL,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position);
-        /* FREQ_HOPPING_FLAG */
-            if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.resource_allocation != 0) &&
-                (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.frequency_hopping !=0))
-              ulsch_config_pdu_0_0->pusch_freq_hopping = (dci->freq_hopping_flag == 0)? pusch_freq_hopping_disabled:pusch_freq_hopping_enabled;
-        /* MCS */
-            ulsch_config_pdu_0_0->mcs = dci->mcs;
-        /* NDI */
-            ulsch_config_pdu_0_0->ndi = dci->ndi;
-        /* RV */
-            ulsch_config_pdu_0_0->rv = dci->rv;
-        /* HARQ_PROCESS_NUMBER */
-            ulsch_config_pdu_0_0->harq_process_nbr = dci->harq_process_number;
-        /* TPC_PUSCH */
-            // according to TS 38.213 Table Table 7.1.1-1
-            if (dci->tpc_pusch == 0) {
-              ulsch_config_pdu_0_0->accumulated_delta_PUSCH = -1;
-              ulsch_config_pdu_0_0->absolute_delta_PUSCH = -4;
-            }
-            if (dci->tpc_pusch == 1) {
-              ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 0;
-              ulsch_config_pdu_0_0->absolute_delta_PUSCH = -1;
-            }
-            if (dci->tpc_pusch == 2) {
-              ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 1;
-              ulsch_config_pdu_0_0->absolute_delta_PUSCH = 1;
-            }
-            if (dci->tpc_pusch == 3) {
-              ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 3;
-              ulsch_config_pdu_0_0->absolute_delta_PUSCH = 4;
-            }
-        /* SUL_IND_0_0 */ // To be implemented, FIXME!!!
-
-            ul_config->number_pdus = ul_config->number_pdus + 1;
-            break;
+  nr_extract_dci_info(mac,dci->dci_format,dci->payloadSize,dci->rnti,(uint64_t *)dci->payloadBits,&dci_pdu_rel15);
+  nr_ue_process_dci(module_id, cc_id, gNB_index, &dci_pdu_rel15, dci->rnti, dci->dci_format);
+}
 
-        case format0_1:
-/*
- *  with CRC scrambled by C-RNTI or CS-RNTI or SP-CSI-RNTI or new-RNTI
- *    0  IDENTIFIER_DCI_FORMATS:
- *    1  CARRIER_IND
- *    2  SUL_IND_0_1
- *    7  BANDWIDTH_PART_IND
- *    10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered
- *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
- *    17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0
- *    24 MCS:
- *    25 NDI:
- *    26 RV:
- *    27 HARQ_PROCESS_NUMBER:
- *    29 FIRST_DAI
- *    30 SECOND_DAI
- *    32 TPC_PUSCH:
- *    36 SRS_RESOURCE_IND:
- *    37 PRECOD_NBR_LAYERS:
- *    38 ANTENNA_PORTS:
- *    40 SRS_REQUEST:
- *    42 CSI_REQUEST:
- *    43 CBGTI
- *    45 PTRS_DMRS
- *    46 BETA_OFFSET_IND
- *    47 DMRS_SEQ_INI
- *    48 UL_SCH_IND
- *    49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space
- */
-            ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
-            ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti;
-            fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu_0_1 = &ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15;
-        /* IDENTIFIER_DCI_FORMATS */
-        /* CARRIER_IND */
-        /* SUL_IND_0_1 */
-        /* BANDWIDTH_PART_IND */
-            ulsch_config_pdu_0_1->bandwidth_part_ind = dci->bandwidth_part_ind;
-        /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */
-            nr_ue_process_dci_freq_dom_resource_assignment(ulsch_config_pdu_0_1,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL);
-        /* TIME_DOM_RESOURCE_ASSIGNMENT */
-            nr_ue_process_dci_time_dom_resource_assignment(ulsch_config_pdu_0_1,NULL,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position);
-        /* FREQ_HOPPING_FLAG */
-            if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.resource_allocation != 0) &&
-                (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.frequency_hopping !=0))
-              ulsch_config_pdu_0_1->pusch_freq_hopping = (dci->freq_hopping_flag == 0)? pusch_freq_hopping_disabled:pusch_freq_hopping_enabled;
-        /* MCS */
-            ulsch_config_pdu_0_1->mcs = dci->mcs;
-        /* NDI */
-            ulsch_config_pdu_0_1->ndi = dci->ndi;
-        /* RV */
-            ulsch_config_pdu_0_1->rv = dci->rv;
-        /* HARQ_PROCESS_NUMBER */
-            ulsch_config_pdu_0_1->harq_process_nbr = dci->harq_process_number;
-        /* FIRST_DAI */ //To be implemented, FIXME!!!
-        /* SECOND_DAI */ //To be implemented, FIXME!!!
-        /* TPC_PUSCH */
-            // according to TS 38.213 Table Table 7.1.1-1
-            if (dci->tpc_pusch == 0) {
-              ulsch_config_pdu_0_1->accumulated_delta_PUSCH = -1;
-              ulsch_config_pdu_0_1->absolute_delta_PUSCH = -4;
-            }
-            if (dci->tpc_pusch == 1) {
-              ulsch_config_pdu_0_1->accumulated_delta_PUSCH = 0;
-              ulsch_config_pdu_0_1->absolute_delta_PUSCH = -1;
-            }
-            if (dci->tpc_pusch == 2) {
-              ulsch_config_pdu_0_1->accumulated_delta_PUSCH = 1;
-              ulsch_config_pdu_0_1->absolute_delta_PUSCH = 1;
-            }
-            if (dci->tpc_pusch == 3) {
-              ulsch_config_pdu_0_1->accumulated_delta_PUSCH = 3;
-              ulsch_config_pdu_0_1->absolute_delta_PUSCH = 4;
-            }
-        /* SRS_RESOURCE_IND */
-            //FIXME!!
-        /* PRECOD_NBR_LAYERS */
-            if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.tx_config == tx_config_nonCodebook));
-              // 0 bits if the higher layer parameter txConfig = nonCodeBook
-            if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.tx_config == tx_config_codebook)){
-              uint8_t n_antenna_port = 0; //FIXME!!!
-              if (n_antenna_port == 1); // 1 antenna port and the higher layer parameter txConfig = codebook 0 bits
-              if (n_antenna_port == 4){ // 4 antenna port and the higher layer parameter txConfig = codebook
-                // Table 7.3.1.1.2-2: transformPrecoder=disabled and maxRank = 2 or 3 or 4
-                if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled)
-                     && ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 2) ||
-                         (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 3) ||
-                         (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 4))){
-                    if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_fullyAndPartialAndNonCoherent) {
-                      ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][0];
-                      ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][1];
-                    }
-                    if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_partialAndNonCoherent){
-                      ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][2];
-                      ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][3];
-                    }
-                    if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){
-                      ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][4];
-                      ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][5];
-                    }
-                }
-                // Table 7.3.1.1.2-3: transformPrecoder= enabled, or transformPrecoder=disabled and maxRank = 1
-                if (((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled)
-                  || (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled))
-                  && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 1)){
-                  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_fullyAndPartialAndNonCoherent) {
-                    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][6];
-                    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][7];
-                  }
-                  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_partialAndNonCoherent){
-                    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][8];
-                    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][9];
-                  }
-                  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){
-                    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][10];
-                    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][11];
-                  }
-                }
-              }
-              if (n_antenna_port == 4){ // 2 antenna port and the higher layer parameter txConfig = codebook
-                // Table 7.3.1.1.2-4: transformPrecoder=disabled and maxRank = 2
-                if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled)
-                  && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 2)){
-                  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_fullyAndPartialAndNonCoherent) {
-                    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][12];
-                    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][13];
-                  }
-                  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){
-                    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][14];
-                    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][15];
-                  }
-                }
-                // Table 7.3.1.1.2-5: transformPrecoder= enabled, or transformPrecoder= disabled and maxRank = 1
-                if (((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled)
-                  || (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled))
-                  && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 1)){
-                  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_fullyAndPartialAndNonCoherent) {
-                    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][16];
-                    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][17];
-                  }
-                  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){
-                    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][18];
-                    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][19];
-                  }
-                }
-              }
-            }
-        /* ANTENNA_PORTS */
-            uint8_t rank=0; // We need to initialize rank FIXME!!!
-            if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled) &&
-            (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 1) &&
-            (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 1)) { // tables 7.3.1.1.2-6
-              ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2;
-              ulsch_config_pdu_0_1->dmrs_ports[0] = dci->antenna_ports;
-            }
-            if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled) &&
-            (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 1) &&
-            (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 2)) { // tables 7.3.1.1.2-7
-              ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2;
-              ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 3)?(dci->antenna_ports-4):(dci->antenna_ports);
-              ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 3)?2:1;
-            }
-            if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) &&
-            (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 1) &&
-            (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 1)) { // tables 7.3.1.1.2-8/9/10/11
-              if (rank == 1){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 1)?2:1;
-                ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports-2):(dci->antenna_ports);
-              }
-              if (rank == 2){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 0)?2:1;
-                ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports > 2 ?0:2):0;
-                ulsch_config_pdu_0_1->dmrs_ports[1] = (dci->antenna_ports > 1)?(dci->antenna_ports > 2 ?2:3):1;
-              }
-              if (rank == 3){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2;
-                ulsch_config_pdu_0_1->dmrs_ports[0] = 0;
-                ulsch_config_pdu_0_1->dmrs_ports[1] = 1;
-                ulsch_config_pdu_0_1->dmrs_ports[2] = 2;
-              }
-              if (rank == 4){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2;
-                ulsch_config_pdu_0_1->dmrs_ports[0] = 0;
-                ulsch_config_pdu_0_1->dmrs_ports[1] = 1;
-                ulsch_config_pdu_0_1->dmrs_ports[2] = 2;
-                ulsch_config_pdu_0_1->dmrs_ports[3] = 3;
-              }
-            }
-            if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) &&
-            (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 1) &&
-            (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 2)) { // tables 7.3.1.1.2-12/13/14/15
-              if (rank == 1){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 1)?2:1;
-                ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports > 5 ?(dci->antenna_ports-6):(dci->antenna_ports-2)):dci->antenna_ports;
-                ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 6)?2:1;
-              }
-              if (rank == 2){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 0)?2:1;
-                ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_13[dci->antenna_ports][1];
-                ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_13[dci->antenna_ports][2];
-                ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 3)?2:1;
-              }
-              if (rank == 3){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2;
-                ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_14[dci->antenna_ports][1];
-                ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_14[dci->antenna_ports][2];
-                ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_14[dci->antenna_ports][3];
-                ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 1)?2:1;
-              }
-              if (rank == 4){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2;
-                ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_15[dci->antenna_ports][1];
-                ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_15[dci->antenna_ports][2];
-                ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_15[dci->antenna_ports][3];
-                ulsch_config_pdu_0_1->dmrs_ports[3] = table_7_3_1_1_2_15[dci->antenna_ports][4];
-                ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 1)?2:1;
-              }
-            }
-            if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) &&
-            (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 2) &&
-            (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 1)) { // tables 7.3.1.1.2-16/17/18/19
-              if (rank == 1){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 1)?((dci->antenna_ports > 5)?3:2):1;
-                ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports > 5 ?(dci->antenna_ports-6):(dci->antenna_ports-2)):dci->antenna_ports;
-              }
-              if (rank == 2){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 0)?((dci->antenna_ports > 2)?3:2):1;
-                ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_17[dci->antenna_ports][1];
-                ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_17[dci->antenna_ports][2];
-              }
-              if (rank == 3){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 0)?3:2;
-                ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_18[dci->antenna_ports][1];
-                ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_18[dci->antenna_ports][2];
-                ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_18[dci->antenna_ports][3];
-              }
-              if (rank == 4){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = dci->antenna_ports + 2;
-                ulsch_config_pdu_0_1->dmrs_ports[0] = 0;
-                ulsch_config_pdu_0_1->dmrs_ports[1] = 1;
-                ulsch_config_pdu_0_1->dmrs_ports[2] = 2;
-                ulsch_config_pdu_0_1->dmrs_ports[3] = 3;
-              }
-            }
-            if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) &&
-            (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 2) &&
-            (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 2)) { // tables 7.3.1.1.2-20/21/22/23
-              if (rank == 1){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = table_7_3_1_1_2_20[dci->antenna_ports][0];
-                ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_20[dci->antenna_ports][1];
-                ulsch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_20[dci->antenna_ports][2];
-              }
-              if (rank == 2){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = table_7_3_1_1_2_21[dci->antenna_ports][0];
-                ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_21[dci->antenna_ports][1];
-                ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_21[dci->antenna_ports][2];
-                ulsch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_21[dci->antenna_ports][3];
-              }
-              if (rank == 3){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = table_7_3_1_1_2_22[dci->antenna_ports][0];
-                ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_22[dci->antenna_ports][1];
-                ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_22[dci->antenna_ports][2];
-                ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_22[dci->antenna_ports][3];
-                ulsch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_22[dci->antenna_ports][4];
-                }
-              if (rank == 4){
-                ulsch_config_pdu_0_1->n_dmrs_cdm_groups = table_7_3_1_1_2_23[dci->antenna_ports][0];
-                ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_23[dci->antenna_ports][1];
-                ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_23[dci->antenna_ports][2];
-                ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_23[dci->antenna_ports][3];
-                ulsch_config_pdu_0_1->dmrs_ports[3] = table_7_3_1_1_2_23[dci->antenna_ports][4];
-                ulsch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_23[dci->antenna_ports][5];
-              }
-            }
-        /* SRS_REQUEST */
-            // if SUL is supported in the cell, there is an additional bit in thsi field and the value of this bit represents table 7.1.1.1-1 TS 38.212 FIXME!!!
-            ulsch_config_pdu_0_1->srs_config.aperiodicSRS_ResourceTrigger = (dci->srs_request & 0x11); // as per Table 7.3.1.1.2-24 TS 38.212
-        /* CSI_REQUEST */
-            ulsch_config_pdu_0_1->csi_reportTriggerSize = dci->csi_request;
-        /* CBGTI */
-            ulsch_config_pdu_0_1->maxCodeBlockGroupsPerTransportBlock = dci->cbgti;
-        /* PTRS_DMRS */
-            if (((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) &&
-                 (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.ptrs_uplink_config == 0)) ||
-                ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled) &&
-                 (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 1))){
-            } else {
-              ulsch_config_pdu_0_1->ptrs_dmrs_association_port = dci->ptrs_dmrs;
-            }
-        /* BETA_OFFSET_IND */
-            // Table 9.3-3 in [5, TS 38.213]
-            ulsch_config_pdu_0_1->beta_offset_ind = dci->beta_offset_ind;
-        /* DMRS_SEQ_INI */
-            // FIXME!!
-        /* UL_SCH_IND */
-            // A value of "1" indicates UL-SCH shall be transmitted on the PUSCH and
-            // a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH
-
-            ul_config->number_pdus = ul_config->number_pdus + 1;
-            break;
+int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr_dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format){
 
-        case format1_0: 
-/*
- *  with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI
- *    0  IDENTIFIER_DCI_FORMATS:
- *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
- *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
- *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
- *    24 MCS:
- *    25 NDI:
- *    26 RV:
- *    27 HARQ_PROCESS_NUMBER:
- *    28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
- *    33 TPC_PUCCH:
- *    34 PUCCH_RESOURCE_IND:
- *    35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND:
- *    55 RESERVED_NR_DCI
- *  with CRC scrambled by P-RNTI
- *    8  SHORT_MESSAGE_IND
- *    9  SHORT_MESSAGES
- *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
- *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
- *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
- *    24 MCS:
- *    31 TB_SCALING
- *    55 RESERVED_NR_DCI
- *  with CRC scrambled by SI-RNTI
- *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
- *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
- *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
- *    24 MCS:
- *    26 RV:
- *    55 RESERVED_NR_DCI
- *  with CRC scrambled by RA-RNTI
- *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
- *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
- *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
- *    24 MCS:
- *    31 TB_SCALING
- *    55 RESERVED_NR_DCI
- *  with CRC scrambled by TC-RNTI
- *    0  IDENTIFIER_DCI_FORMATS:
- *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
- *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
- *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
- *    24 MCS:
- *    25 NDI:
- *    26 RV:
- *    27 HARQ_PROCESS_NUMBER:
- *    28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
- *    33 TPC_PUCCH:
- */
-            dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti;
-            //fapi_nr_dl_config_dlsch_pdu_rel15_t dlsch_config_pdu_1_0 = dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15;
-            fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_0 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15;
-        /* IDENTIFIER_DCI_FORMATS */
-        /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */
-           nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_0,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL);
-        /* TIME_DOM_RESOURCE_ASSIGNMENT */
-            nr_ue_process_dci_time_dom_resource_assignment(NULL,dlsch_config_pdu_1_0,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position);
-        /* VRB_TO_PRB_MAPPING */
-            dlsch_config_pdu_1_0->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping == 0) ? vrb_to_prb_mapping_non_interleaved:vrb_to_prb_mapping_interleaved;
-        /* MCS */
-            dlsch_config_pdu_1_0->mcs = dci->mcs;
-       /* NDI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/
-            dlsch_config_pdu_1_0->ndi = dci->ndi;
-        /* RV (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/
-            dlsch_config_pdu_1_0->rv = dci->rv;
-        /* HARQ_PROCESS_NUMBER (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/
-            dlsch_config_pdu_1_0->harq_process_nbr = dci->harq_process_number;
-        /* DAI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/
-            dlsch_config_pdu_1_0->dai = dci ->dai;
-        /* TB_SCALING (only if CRC scrambled by P-RNTI or RA-RNTI) */
-            // according to TS 38.214 Table 5.1.3.2-3
-            if (dci->tb_scaling == 0) dlsch_config_pdu_1_0->scaling_factor_S = 1;
-            if (dci->tb_scaling == 1) dlsch_config_pdu_1_0->scaling_factor_S = 0.5;
-            if (dci->tb_scaling == 2) dlsch_config_pdu_1_0->scaling_factor_S = 0.25;
-            if (dci->tb_scaling == 3) dlsch_config_pdu_1_0->scaling_factor_S = 0; // value not defined in table
-        /* TPC_PUCCH (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/
-            // according to TS 38.213 Table 7.2.1-1
-            if (dci->tpc_pucch == 0) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = -1;
-            if (dci->tpc_pucch == 1) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 0;
-            if (dci->tpc_pucch == 2) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 1;
-            if (dci->tpc_pucch == 3) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 3;
-        /* PUCCH_RESOURCE_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/
-            //if (dci->pucch_resource_ind == 0) dlsch_config_pdu_1_0->pucch_resource_id = 1; //pucch-ResourceId obtained from the 1st value of resourceList FIXME!!!
-            //if (dci->pucch_resource_ind == 1) dlsch_config_pdu_1_0->pucch_resource_id = 2; //pucch-ResourceId obtained from the 2nd value of resourceList FIXME!!
-            //if (dci->pucch_resource_ind == 2) dlsch_config_pdu_1_0->pucch_resource_id = 3; //pucch-ResourceId obtained from the 3rd value of resourceList FIXME!!
-            //if (dci->pucch_resource_ind == 3) dlsch_config_pdu_1_0->pucch_resource_id = 4; //pucch-ResourceId obtained from the 4th value of resourceList FIXME!!
-            //if (dci->pucch_resource_ind == 4) dlsch_config_pdu_1_0->pucch_resource_id = 5; //pucch-ResourceId obtained from the 5th value of resourceList FIXME!!
-            //if (dci->pucch_resource_ind == 5) dlsch_config_pdu_1_0->pucch_resource_id = 6; //pucch-ResourceId obtained from the 6th value of resourceList FIXME!!
-            //if (dci->pucch_resource_ind == 6) dlsch_config_pdu_1_0->pucch_resource_id = 7; //pucch-ResourceId obtained from the 7th value of resourceList FIXME!!
-            //if (dci->pucch_resource_ind == 7) dlsch_config_pdu_1_0->pucch_resource_id = 8; //pucch-ResourceId obtained from the 8th value of resourceList FIXME!!
-            dlsch_config_pdu_1_0->pucch_resource_id = dci->pucch_resource_ind;
-        /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/
-            dlsch_config_pdu_1_0->pdsch_to_harq_feedback_time_ind = dci->pdsch_to_harq_feedback_time_ind;
-
-            LOG_D(MAC,"(nr_ue_procedures.c) rnti=%d dl_config->number_pdus=%d\n",
-                    dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti,
-                    dl_config->number_pdus);
-            LOG_D(MAC,"(nr_ue_procedures.c) frequency_domain_resource_assignment=%d \t number_rbs=%d \t start_rb=%d\n",
-                    dci->freq_dom_resource_assignment_DL,
-                    dlsch_config_pdu_1_0->number_rbs,
-                    dlsch_config_pdu_1_0->start_rb);
-            LOG_D(MAC,"(nr_ue_procedures.c) time_domain_resource_assignment=%d \t number_symbols=%d \t start_symbol=%d\n",
-                    dci->time_dom_resource_assignment,
-                    dlsch_config_pdu_1_0->number_symbols,
-                    dlsch_config_pdu_1_0->start_symbol);
-            LOG_D(MAC,"(nr_ue_procedures.c) vrb_to_prb_mapping=%d \n>>> mcs=%d\n>>> ndi=%d\n>>> rv=%d\n>>> harq_process_nbr=%d\n>>> dai=%d\n>>> scaling_factor_S=%f\n>>> tpc_pucch=%d\n>>> pucch_res_ind=%d\n>>> pdsch_to_harq_feedback_time_ind=%d\n",
-                  dlsch_config_pdu_1_0->vrb_to_prb_mapping,
-                  dlsch_config_pdu_1_0->mcs,
-                  dlsch_config_pdu_1_0->ndi,
-                  dlsch_config_pdu_1_0->rv,
-                  dlsch_config_pdu_1_0->harq_process_nbr,
-                  dlsch_config_pdu_1_0->dai,
-                  dlsch_config_pdu_1_0->scaling_factor_S,
-                  dlsch_config_pdu_1_0->accumulated_delta_PUCCH,
-                  dlsch_config_pdu_1_0->pucch_resource_id,
-                  dlsch_config_pdu_1_0->pdsch_to_harq_feedback_time_ind);
-
-            dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH;
-	    dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = n_RB_DLBWP;
+  NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
+  fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request;
+  fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request;
+    
+  //const uint16_t n_RB_DLBWP = dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP; //make sure this has been set
+  AssertFatal(mac->DLbwp[0]!=NULL,"DLbwp[0] should not be zero here!\n");
+  AssertFatal(mac->ULbwp[0]!=NULL,"DLbwp[0] should not be zero here!\n");
+
+  const uint16_t n_RB_DLBWP = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275);
+  const uint16_t n_RB_ULBWP = NRRIV2BW(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275);
+
+  LOG_D(MAC,"nr_ue_process_dci at MAC layer with dci_format=%d (DL BWP %d, UL BWP %d)\n",dci_format,n_RB_DLBWP,n_RB_ULBWP);
+
+  NR_PDSCH_Config_t *pdsch_config=mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup;
+
+  switch(dci_format){
+  case NR_UL_DCI_FORMAT_0_0:
+    /*
+     *  with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI
+     *    0  IDENTIFIER_DCI_FORMATS:
+     *    10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered
+     *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
+     *    17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0
+     *    24 MCS:
+     *    25 NDI:
+     *    26 RV:
+     *    27 HARQ_PROCESS_NUMBER:
+     *    32 TPC_PUSCH:
+     *    49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space
+     *    50 SUL_IND_0_0:
+     */
+    ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti;
+    fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu_0_0 = &ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15;
+    /* IDENTIFIER_DCI_FORMATS */
+    /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */
+    nr_ue_process_dci_freq_dom_resource_assignment(ulsch_config_pdu_0_0,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL);
+    /* TIME_DOM_RESOURCE_ASSIGNMENT */
+    nr_ue_process_dci_time_dom_resource_assignment(mac,
+						   ulsch_config_pdu_0_0,NULL,
+						   dci->time_dom_resource_assignment);
+
+    /* FREQ_HOPPING_FLAG */
+    if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.resource_allocation != 0) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.frequency_hopping !=0))
+      ulsch_config_pdu_0_0->pusch_freq_hopping = (dci->freq_hopping_flag == 0)? pusch_freq_hopping_disabled:pusch_freq_hopping_enabled;
+    /* MCS */
+    ulsch_config_pdu_0_0->mcs = dci->mcs;
+    /* NDI */
+    ulsch_config_pdu_0_0->ndi = dci->ndi;
+    /* RV */
+    ulsch_config_pdu_0_0->rv = dci->rv;
+    /* HARQ_PROCESS_NUMBER */
+    ulsch_config_pdu_0_0->harq_process_nbr = dci->harq_process_number;
+    /* TPC_PUSCH */
+    // according to TS 38.213 Table Table 7.1.1-1
+    if (dci->tpc_pusch == 0) {
+      ulsch_config_pdu_0_0->accumulated_delta_PUSCH = -1;
+      ulsch_config_pdu_0_0->absolute_delta_PUSCH = -4;
+    }
+    if (dci->tpc_pusch == 1) {
+      ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 0;
+      ulsch_config_pdu_0_0->absolute_delta_PUSCH = -1;
+    }
+    if (dci->tpc_pusch == 2) {
+      ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 1;
+      ulsch_config_pdu_0_0->absolute_delta_PUSCH = 1;
+    }
+    if (dci->tpc_pusch == 3) {
+      ulsch_config_pdu_0_0->accumulated_delta_PUSCH = 3;
+      ulsch_config_pdu_0_0->absolute_delta_PUSCH = 4;
+    }
+    /* SUL_IND_0_0 */ // To be implemented, FIXME!!!
+
+    ul_config->number_pdus = ul_config->number_pdus + 1;
+    break;
+
+  case NR_UL_DCI_FORMAT_0_1:
+    /*
+     *  with CRC scrambled by C-RNTI or CS-RNTI or SP-CSI-RNTI or new-RNTI
+     *    0  IDENTIFIER_DCI_FORMATS:
+     *    1  CARRIER_IND
+     *    2  SUL_IND_0_1
+     *    7  BANDWIDTH_PART_IND
+     *    10 FREQ_DOM_RESOURCE_ASSIGNMENT_UL: PUSCH hopping with resource allocation type 1 not considered
+     *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 6.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
+     *    17 FREQ_HOPPING_FLAG: 0 bit if only resource allocation type 0
+     *    24 MCS:
+     *    25 NDI:
+     *    26 RV:
+     *    27 HARQ_PROCESS_NUMBER:
+     *    29 FIRST_DAI
+     *    30 SECOND_DAI
+     *    32 TPC_PUSCH:
+     *    36 SRS_RESOURCE_IND:
+     *    37 PRECOD_NBR_LAYERS:
+     *    38 ANTENNA_PORTS:
+     *    40 SRS_REQUEST:
+     *    42 CSI_REQUEST:
+     *    43 CBGTI
+     *    45 PTRS_DMRS
+     *    46 BETA_OFFSET_IND
+     *    47 DMRS_SEQ_INI
+     *    48 UL_SCH_IND
+     *    49 PADDING_NR_DCI: (Note 2) If DCI format 0_0 is monitored in common search space
+     */
+    ul_config->ul_config_list[ul_config->number_pdus].pdu_type = FAPI_NR_UL_CONFIG_TYPE_PUSCH;
+    ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti;
+    fapi_nr_ul_config_pusch_pdu_rel15_t *ulsch_config_pdu_0_1 = &ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.ulsch_pdu_rel15;
+    /* IDENTIFIER_DCI_FORMATS */
+    /* CARRIER_IND */
+    /* SUL_IND_0_1 */
+    /* BANDWIDTH_PART_IND */
+    ulsch_config_pdu_0_1->bandwidth_part_ind = dci->bandwidth_part_ind;
+    /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */
+    nr_ue_process_dci_freq_dom_resource_assignment(ulsch_config_pdu_0_1,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL);
+    /* TIME_DOM_RESOURCE_ASSIGNMENT */
+    nr_ue_process_dci_time_dom_resource_assignment(mac,ulsch_config_pdu_0_1,NULL,
+						   dci->time_dom_resource_assignment);
+    /* FREQ_HOPPING_FLAG */
+    if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.resource_allocation != 0) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.frequency_hopping !=0))
+      ulsch_config_pdu_0_1->pusch_freq_hopping = (dci->freq_hopping_flag == 0)? pusch_freq_hopping_disabled:pusch_freq_hopping_enabled;
+    /* MCS */
+    ulsch_config_pdu_0_1->mcs = dci->mcs;
+    /* NDI */
+    ulsch_config_pdu_0_1->ndi = dci->ndi;
+    /* RV */
+    ulsch_config_pdu_0_1->rv = dci->rv;
+    /* HARQ_PROCESS_NUMBER */
+    ulsch_config_pdu_0_1->harq_process_nbr = dci->harq_process_number;
+    /* FIRST_DAI */ //To be implemented, FIXME!!!
+    /* SECOND_DAI */ //To be implemented, FIXME!!!
+    /* TPC_PUSCH */
+    // according to TS 38.213 Table Table 7.1.1-1
+    if (dci->tpc_pusch == 0) {
+      ulsch_config_pdu_0_1->accumulated_delta_PUSCH = -1;
+      ulsch_config_pdu_0_1->absolute_delta_PUSCH = -4;
+    }
+    if (dci->tpc_pusch == 1) {
+      ulsch_config_pdu_0_1->accumulated_delta_PUSCH = 0;
+      ulsch_config_pdu_0_1->absolute_delta_PUSCH = -1;
+    }
+    if (dci->tpc_pusch == 2) {
+      ulsch_config_pdu_0_1->accumulated_delta_PUSCH = 1;
+      ulsch_config_pdu_0_1->absolute_delta_PUSCH = 1;
+    }
+    if (dci->tpc_pusch == 3) {
+      ulsch_config_pdu_0_1->accumulated_delta_PUSCH = 3;
+      ulsch_config_pdu_0_1->absolute_delta_PUSCH = 4;
+    }
+    /* SRS_RESOURCE_IND */
+    //FIXME!!
+    /* PRECOD_NBR_LAYERS */
+    if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.tx_config == tx_config_nonCodebook));
+    // 0 bits if the higher layer parameter txConfig = nonCodeBook
+    if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.tx_config == tx_config_codebook)){
+      uint8_t n_antenna_port = 0; //FIXME!!!
+      if (n_antenna_port == 1); // 1 antenna port and the higher layer parameter txConfig = codebook 0 bits
+      if (n_antenna_port == 4){ // 4 antenna port and the higher layer parameter txConfig = codebook
+	// Table 7.3.1.1.2-2: transformPrecoder=disabled and maxRank = 2 or 3 or 4
+	if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled)
+	    && ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 2) ||
+		(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 3) ||
+		(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 4))){
+	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_fullyAndPartialAndNonCoherent) {
+	    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][0];
+	    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][1];
+	  }
+	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_partialAndNonCoherent){
+	    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][2];
+	    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][3];
+	  }
+	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){
+	    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][4];
+	    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][5];
+	  }
+	}
+	// Table 7.3.1.1.2-3: transformPrecoder= enabled, or transformPrecoder=disabled and maxRank = 1
+	if (((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled)
+	     || (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled))
+	    && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 1)){
+	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_fullyAndPartialAndNonCoherent) {
+	    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][6];
+	    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][7];
+	  }
+	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_partialAndNonCoherent){
+	    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][8];
+	    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][9];
+	  }
+	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){
+	    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][10];
+	    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][11];
+	  }
+	}
+      }
+      if (n_antenna_port == 4){ // 2 antenna port and the higher layer parameter txConfig = codebook
+	// Table 7.3.1.1.2-4: transformPrecoder=disabled and maxRank = 2
+	if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled)
+	    && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 2)){
+	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_fullyAndPartialAndNonCoherent) {
+	    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][12];
+	    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][13];
+	  }
+	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){
+	    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][14];
+	    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][15];
+	  }
+	}
+	// Table 7.3.1.1.2-5: transformPrecoder= enabled, or transformPrecoder= disabled and maxRank = 1
+	if (((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled)
+	     || (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled))
+	    && (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 1)){
+	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_fullyAndPartialAndNonCoherent) {
+	    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][16];
+	    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][17];
+	  }
+	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){
+	    ulsch_config_pdu_0_1->n_layers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][18];
+	    ulsch_config_pdu_0_1->tpmi     = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][19];
+	  }
+	}
+      }
+    }
+    /* ANTENNA_PORTS */
+    uint8_t rank=0; // We need to initialize rank FIXME!!!
+    if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 1) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 1)) { // tables 7.3.1.1.2-6
+      ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2;
+      ulsch_config_pdu_0_1->dmrs_ports[0] = dci->antenna_ports;
+    }
+    if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 1) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 2)) { // tables 7.3.1.1.2-7
+      ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2;
+      ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 3)?(dci->antenna_ports-4):(dci->antenna_ports);
+      ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 3)?2:1;
+    }
+    if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 1) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 1)) { // tables 7.3.1.1.2-8/9/10/11
+      if (rank == 1){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 1)?2:1;
+	ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports-2):(dci->antenna_ports);
+      }
+      if (rank == 2){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 0)?2:1;
+	ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports > 2 ?0:2):0;
+	ulsch_config_pdu_0_1->dmrs_ports[1] = (dci->antenna_ports > 1)?(dci->antenna_ports > 2 ?2:3):1;
+      }
+      if (rank == 3){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2;
+	ulsch_config_pdu_0_1->dmrs_ports[0] = 0;
+	ulsch_config_pdu_0_1->dmrs_ports[1] = 1;
+	ulsch_config_pdu_0_1->dmrs_ports[2] = 2;
+      }
+      if (rank == 4){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2;
+	ulsch_config_pdu_0_1->dmrs_ports[0] = 0;
+	ulsch_config_pdu_0_1->dmrs_ports[1] = 1;
+	ulsch_config_pdu_0_1->dmrs_ports[2] = 2;
+	ulsch_config_pdu_0_1->dmrs_ports[3] = 3;
+      }
+    }
+    if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 1) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 2)) { // tables 7.3.1.1.2-12/13/14/15
+      if (rank == 1){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 1)?2:1;
+	ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports > 5 ?(dci->antenna_ports-6):(dci->antenna_ports-2)):dci->antenna_ports;
+	ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 6)?2:1;
+      }
+      if (rank == 2){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 0)?2:1;
+	ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_13[dci->antenna_ports][1];
+	ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_13[dci->antenna_ports][2];
+	ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 3)?2:1;
+      }
+      if (rank == 3){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2;
+	ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_14[dci->antenna_ports][1];
+	ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_14[dci->antenna_ports][2];
+	ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_14[dci->antenna_ports][3];
+	ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 1)?2:1;
+      }
+      if (rank == 4){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = 2;
+	ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_15[dci->antenna_ports][1];
+	ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_15[dci->antenna_ports][2];
+	ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_15[dci->antenna_ports][3];
+	ulsch_config_pdu_0_1->dmrs_ports[3] = table_7_3_1_1_2_15[dci->antenna_ports][4];
+	ulsch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 1)?2:1;
+      }
+    }
+    if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 2) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 1)) { // tables 7.3.1.1.2-16/17/18/19
+      if (rank == 1){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 1)?((dci->antenna_ports > 5)?3:2):1;
+	ulsch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports > 5 ?(dci->antenna_ports-6):(dci->antenna_ports-2)):dci->antenna_ports;
+      }
+      if (rank == 2){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 0)?((dci->antenna_ports > 2)?3:2):1;
+	ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_17[dci->antenna_ports][1];
+	ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_17[dci->antenna_ports][2];
+      }
+      if (rank == 3){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = (dci->antenna_ports > 0)?3:2;
+	ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_18[dci->antenna_ports][1];
+	ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_18[dci->antenna_ports][2];
+	ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_18[dci->antenna_ports][3];
+      }
+      if (rank == 4){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = dci->antenna_ports + 2;
+	ulsch_config_pdu_0_1->dmrs_ports[0] = 0;
+	ulsch_config_pdu_0_1->dmrs_ports[1] = 1;
+	ulsch_config_pdu_0_1->dmrs_ports[2] = 2;
+	ulsch_config_pdu_0_1->dmrs_ports[3] = 3;
+      }
+    }
+    if ((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.dmrs_type == 2) &&
+	(mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.max_length == 2)) { // tables 7.3.1.1.2-20/21/22/23
+      if (rank == 1){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = table_7_3_1_1_2_20[dci->antenna_ports][0];
+	ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_20[dci->antenna_ports][1];
+	ulsch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_20[dci->antenna_ports][2];
+      }
+      if (rank == 2){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = table_7_3_1_1_2_21[dci->antenna_ports][0];
+	ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_21[dci->antenna_ports][1];
+	ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_21[dci->antenna_ports][2];
+	ulsch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_21[dci->antenna_ports][3];
+      }
+      if (rank == 3){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = table_7_3_1_1_2_22[dci->antenna_ports][0];
+	ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_22[dci->antenna_ports][1];
+	ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_22[dci->antenna_ports][2];
+	ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_22[dci->antenna_ports][3];
+	ulsch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_22[dci->antenna_ports][4];
+      }
+      if (rank == 4){
+	ulsch_config_pdu_0_1->n_dmrs_cdm_groups = table_7_3_1_1_2_23[dci->antenna_ports][0];
+	ulsch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_23[dci->antenna_ports][1];
+	ulsch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_23[dci->antenna_ports][2];
+	ulsch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_23[dci->antenna_ports][3];
+	ulsch_config_pdu_0_1->dmrs_ports[3] = table_7_3_1_1_2_23[dci->antenna_ports][4];
+	ulsch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_23[dci->antenna_ports][5];
+      }
+    }
+    /* SRS_REQUEST */
+    // if SUL is supported in the cell, there is an additional bit in thsi field and the value of this bit represents table 7.1.1.1-1 TS 38.212 FIXME!!!
+    ulsch_config_pdu_0_1->srs_config.aperiodicSRS_ResourceTrigger = (dci->srs_request & 0x11); // as per Table 7.3.1.1.2-24 TS 38.212
+    /* CSI_REQUEST */
+    ulsch_config_pdu_0_1->csi_reportTriggerSize = dci->csi_request;
+    /* CBGTI */
+    ulsch_config_pdu_0_1->maxCodeBlockGroupsPerTransportBlock = dci->cbgti;
+    /* PTRS_DMRS */
+    if (((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_disabled) &&
+	 (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.dmrs_ul_for_pusch_mapping_type_a.ptrs_uplink_config == 0)) ||
+	((mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.transform_precoder == transform_precoder_enabled) &&
+	 (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.max_rank == 1))){
+    } else {
+      ulsch_config_pdu_0_1->ptrs_dmrs_association_port = dci->ptrs_dmrs;
+    }
+    /* BETA_OFFSET_IND */
+    // Table 9.3-3 in [5, TS 38.213]
+    ulsch_config_pdu_0_1->beta_offset_ind = dci->beta_offset_ind;
+    /* DMRS_SEQ_INI */
+    // FIXME!!
+    /* UL_SCH_IND */
+    // A value of "1" indicates UL-SCH shall be transmitted on the PUSCH and
+    // a value of "0" indicates UL-SCH shall not be transmitted on the PUSCH
+
+    ul_config->number_pdus = ul_config->number_pdus + 1;
+    break;
+
+  case NR_DL_DCI_FORMAT_1_0:
+    /*
+     *  with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI
+     *    0  IDENTIFIER_DCI_FORMATS:
+     *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
+     *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
+     *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
+     *    24 MCS:
+     *    25 NDI:
+     *    26 RV:
+     *    27 HARQ_PROCESS_NUMBER:
+     *    28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
+     *    33 TPC_PUCCH:
+     *    34 PUCCH_RESOURCE_IND:
+     *    35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND:
+     *    55 RESERVED_NR_DCI
+     *  with CRC scrambled by P-RNTI
+     *    8  SHORT_MESSAGE_IND
+     *    9  SHORT_MESSAGES
+     *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
+     *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
+     *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
+     *    24 MCS:
+     *    31 TB_SCALING
+     *    55 RESERVED_NR_DCI
+     *  with CRC scrambled by SI-RNTI
+     *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
+     *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
+     *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
+     *    24 MCS:
+     *    26 RV:
+     *    55 RESERVED_NR_DCI
+     *  with CRC scrambled by RA-RNTI
+     *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
+     *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
+     *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
+     *    24 MCS:
+     *    31 TB_SCALING
+     *    55 RESERVED_NR_DCI
+     *  with CRC scrambled by TC-RNTI
+     *    0  IDENTIFIER_DCI_FORMATS:
+     *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
+     *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
+     *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
+     *    24 MCS:
+     *    25 NDI:
+     *    26 RV:
+     *    27 HARQ_PROCESS_NUMBER:
+     *    28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
+     *    33 TPC_PUCCH:
+     */
+
+    dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti;
+    //fapi_nr_dl_config_dlsch_pdu_rel15_t dlsch_config_pdu_1_0 = dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15;
+    fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_0 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15;
+    dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275);
+    dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275);
+    dlsch_config_pdu_1_0->SubcarrierSpacing = mac->DLbwp[0]->bwp_Common->genericParameters.subcarrierSpacing;
+    /* IDENTIFIER_DCI_FORMATS */
+    /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */
+    nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_0,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL);
+    /* TIME_DOM_RESOURCE_ASSIGNMENT */
+    nr_ue_process_dci_time_dom_resource_assignment(mac,NULL,dlsch_config_pdu_1_0,
+						   dci->time_dom_resource_assignment);
+
+    /* dmrs symbol positions*/
+    dlsch_config_pdu_1_0->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config,
+							 mac->scc->dmrs_TypeA_Position,
+							 dlsch_config_pdu_1_0->number_symbols);
+    dlsch_config_pdu_1_0->dmrsConfigType = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 1 : 2;
+    /* VRB_TO_PRB_MAPPING */
+    dlsch_config_pdu_1_0->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping == 0) ? vrb_to_prb_mapping_non_interleaved:vrb_to_prb_mapping_interleaved;
+    /* MCS */
+    dlsch_config_pdu_1_0->mcs = dci->mcs;
+    /* NDI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/
+    dlsch_config_pdu_1_0->ndi = dci->ndi;
+    /* RV (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/
+    dlsch_config_pdu_1_0->rv = dci->rv;
+    /* HARQ_PROCESS_NUMBER (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/
+    dlsch_config_pdu_1_0->harq_process_nbr = dci->harq_process_number;
+    /* DAI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/
+    dlsch_config_pdu_1_0->dai = dci ->dai;
+    /* TB_SCALING (only if CRC scrambled by P-RNTI or RA-RNTI) */
+    // according to TS 38.214 Table 5.1.3.2-3
+    if (dci->tb_scaling == 0) dlsch_config_pdu_1_0->scaling_factor_S = 1;
+    if (dci->tb_scaling == 1) dlsch_config_pdu_1_0->scaling_factor_S = 0.5;
+    if (dci->tb_scaling == 2) dlsch_config_pdu_1_0->scaling_factor_S = 0.25;
+    if (dci->tb_scaling == 3) dlsch_config_pdu_1_0->scaling_factor_S = 0; // value not defined in table
+    /* TPC_PUCCH (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/
+    // according to TS 38.213 Table 7.2.1-1
+    if (dci->tpc_pucch == 0) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = -1;
+    if (dci->tpc_pucch == 1) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 0;
+    if (dci->tpc_pucch == 2) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 1;
+    if (dci->tpc_pucch == 3) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 3;
+    /* PUCCH_RESOURCE_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/
+    //if (dci->pucch_resource_ind == 0) dlsch_config_pdu_1_0->pucch_resource_id = 1; //pucch-ResourceId obtained from the 1st value of resourceList FIXME!!!
+    //if (dci->pucch_resource_ind == 1) dlsch_config_pdu_1_0->pucch_resource_id = 2; //pucch-ResourceId obtained from the 2nd value of resourceList FIXME!!
+    //if (dci->pucch_resource_ind == 2) dlsch_config_pdu_1_0->pucch_resource_id = 3; //pucch-ResourceId obtained from the 3rd value of resourceList FIXME!!
+    //if (dci->pucch_resource_ind == 3) dlsch_config_pdu_1_0->pucch_resource_id = 4; //pucch-ResourceId obtained from the 4th value of resourceList FIXME!!
+    //if (dci->pucch_resource_ind == 4) dlsch_config_pdu_1_0->pucch_resource_id = 5; //pucch-ResourceId obtained from the 5th value of resourceList FIXME!!
+    //if (dci->pucch_resource_ind == 5) dlsch_config_pdu_1_0->pucch_resource_id = 6; //pucch-ResourceId obtained from the 6th value of resourceList FIXME!!
+    //if (dci->pucch_resource_ind == 6) dlsch_config_pdu_1_0->pucch_resource_id = 7; //pucch-ResourceId obtained from the 7th value of resourceList FIXME!!
+    //if (dci->pucch_resource_ind == 7) dlsch_config_pdu_1_0->pucch_resource_id = 8; //pucch-ResourceId obtained from the 8th value of resourceList FIXME!!
+    dlsch_config_pdu_1_0->pucch_resource_id = dci->pucch_resource_ind;
+    /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/
+    dlsch_config_pdu_1_0->pdsch_to_harq_feedback_time_ind = dci->pdsch_to_harq_feedback_time_ind;
+
+    LOG_D(MAC,"(nr_ue_procedures.c) rnti=%d dl_config->number_pdus=%d\n",
+	  dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti,
+	  dl_config->number_pdus);
+    LOG_D(MAC,"(nr_ue_procedures.c) frequency_domain_resource_assignment=%d \t number_rbs=%d \t start_rb=%d\n",
+	  dci->freq_dom_resource_assignment_DL,
+	  dlsch_config_pdu_1_0->number_rbs,
+	  dlsch_config_pdu_1_0->start_rb);
+    LOG_D(MAC,"(nr_ue_procedures.c) time_domain_resource_assignment=%d \t number_symbols=%d \t start_symbol=%d\n",
+	  dci->time_dom_resource_assignment,
+	  dlsch_config_pdu_1_0->number_symbols,
+	  dlsch_config_pdu_1_0->start_symbol);
+    LOG_D(MAC,"(nr_ue_procedures.c) vrb_to_prb_mapping=%d \n>>> mcs=%d\n>>> ndi=%d\n>>> rv=%d\n>>> harq_process_nbr=%d\n>>> dai=%d\n>>> scaling_factor_S=%f\n>>> tpc_pucch=%d\n>>> pucch_res_ind=%d\n>>> pdsch_to_harq_feedback_time_ind=%d\n",
+	  dlsch_config_pdu_1_0->vrb_to_prb_mapping,
+	  dlsch_config_pdu_1_0->mcs,
+	  dlsch_config_pdu_1_0->ndi,
+	  dlsch_config_pdu_1_0->rv,
+	  dlsch_config_pdu_1_0->harq_process_nbr,
+	  dlsch_config_pdu_1_0->dai,
+	  dlsch_config_pdu_1_0->scaling_factor_S,
+	  dlsch_config_pdu_1_0->accumulated_delta_PUCCH,
+	  dlsch_config_pdu_1_0->pucch_resource_id,
+	  dlsch_config_pdu_1_0->pdsch_to_harq_feedback_time_ind);
+
+    dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH;
+    //	    dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = n_RB_DLBWP;
 	    
-            LOG_D(MAC,"(nr_ue_procedures.c) pdu_type=%d\n\n",dl_config->dl_config_list[dl_config->number_pdus].pdu_type);
+    LOG_D(MAC,"(nr_ue_procedures.c) pdu_type=%d\n\n",dl_config->dl_config_list[dl_config->number_pdus].pdu_type);
             
-            dl_config->number_pdus = dl_config->number_pdus + 1;
-            break;
-
-        case format1_1:        
-/*
- *  with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI
- *    0  IDENTIFIER_DCI_FORMATS:
- *    1  CARRIER_IND:
- *    7  BANDWIDTH_PART_IND:
- *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
- *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
- *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
- *    14 PRB_BUNDLING_SIZE_IND:
- *    15 RATE_MATCHING_IND:
- *    16 ZP_CSI_RS_TRIGGER:
- *    18 TB1_MCS:
- *    19 TB1_NDI:
- *    20 TB1_RV:
- *    21 TB2_MCS:
- *    22 TB2_NDI:
- *    23 TB2_RV:
- *    27 HARQ_PROCESS_NUMBER:
- *    28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
- *    33 TPC_PUCCH:
- *    34 PUCCH_RESOURCE_IND:
- *    35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND:
- *    38 ANTENNA_PORTS:
- *    39 TCI:
- *    40 SRS_REQUEST:
- *    43 CBGTI:
- *    44 CBGFI:
- *    47 DMRS_SEQ_INI:
- */
-            dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH;
-            dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti;
-            fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_1 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15;
-        /* IDENTIFIER_DCI_FORMATS */
-        /* CARRIER_IND */
-        /* BANDWIDTH_PART_IND */
-            dlsch_config_pdu_1_1->bandwidth_part_ind = dci->bandwidth_part_ind;
-        /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */
-            nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_1,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL);
-        /* TIME_DOM_RESOURCE_ASSIGNMENT */
-            nr_ue_process_dci_time_dom_resource_assignment(NULL,dlsch_config_pdu_1_1,dci->time_dom_resource_assignment,mac->mib->dmrs_TypeA_Position);
-        /* VRB_TO_PRB_MAPPING */
-            if (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.resource_allocation != 0)
-              dlsch_config_pdu_1_1->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping == 0) ? vrb_to_prb_mapping_non_interleaved:vrb_to_prb_mapping_interleaved;
-        /* PRB_BUNDLING_SIZE_IND */
-            dlsch_config_pdu_1_1->prb_bundling_size_ind = dci->prb_bundling_size_ind;
-        /* RATE_MATCHING_IND */
-            dlsch_config_pdu_1_1->rate_matching_ind = dci->rate_matching_ind;
-        /* ZP_CSI_RS_TRIGGER */
-            dlsch_config_pdu_1_1->zp_csi_rs_trigger = dci->zp_csi_rs_trigger;
-        /* MCS (for transport block 1)*/
-            dlsch_config_pdu_1_1->mcs = dci->tb1_mcs;
-        /* NDI (for transport block 1)*/
-            dlsch_config_pdu_1_1->ndi = dci->tb1_ndi;
-        /* RV (for transport block 1)*/
-            dlsch_config_pdu_1_1->rv = dci->tb1_rv;
-        /* MCS (for transport block 2)*/
-            dlsch_config_pdu_1_1->tb2_mcs = dci->tb2_mcs;
-        /* NDI (for transport block 2)*/
-            dlsch_config_pdu_1_1->tb2_ndi = dci->tb2_ndi;
-        /* RV (for transport block 2)*/
-            dlsch_config_pdu_1_1->tb2_rv = dci->tb2_rv;
-        /* HARQ_PROCESS_NUMBER */
-            dlsch_config_pdu_1_1->harq_process_nbr = dci->harq_process_number;
-        /* DAI */
-            dlsch_config_pdu_1_1->dai = dci ->dai;
-        /* TPC_PUCCH */
-            // according to TS 38.213 Table 7.2.1-1
-            if (dci->tpc_pucch == 0) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = -1;
-            if (dci->tpc_pucch == 1) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 0;
-            if (dci->tpc_pucch == 2) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 1;
-            if (dci->tpc_pucch == 3) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 3;
-        /* PUCCH_RESOURCE_IND */
-            if (dci->pucch_resource_ind == 0) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 1st value of resourceList FIXME!!!
-            if (dci->pucch_resource_ind == 1) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 2nd value of resourceList FIXME!!
-            if (dci->pucch_resource_ind == 2) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 3rd value of resourceList FIXME!!
-            if (dci->pucch_resource_ind == 3) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 4th value of resourceList FIXME!!
-            if (dci->pucch_resource_ind == 4) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 5th value of resourceList FIXME!!
-            if (dci->pucch_resource_ind == 5) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 6th value of resourceList FIXME!!
-            if (dci->pucch_resource_ind == 6) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 7th value of resourceList FIXME!!
-            if (dci->pucch_resource_ind == 7) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 8th value of resourceList FIXME!!
-        /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */
-            // according to TS 38.213 Table 9.2.3-1
-            dlsch_config_pdu_1_1-> pdsch_to_harq_feedback_time_ind = mac->phy_config.config_req.ul_bwp_dedicated.pucch_config_dedicated.dl_data_to_ul_ack[dci->pdsch_to_harq_feedback_time_ind];
-        /* ANTENNA_PORTS */
-            uint8_t n_codewords = 1; // FIXME!!!
-            if ((mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.dmrs_type == 1) &&
-                (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.max_length == 1)){
-            // Table 7.3.1.2.2-1: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=1
-              dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_1[dci->antenna_ports][0];
-              dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_1[dci->antenna_ports][1];
-              dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_1[dci->antenna_ports][2];
-              dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_1[dci->antenna_ports][3];
-              dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_1[dci->antenna_ports][4];
-            }
-            if ((mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.dmrs_type == 1) &&
-                (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.max_length == 2)){
-            // Table 7.3.1.2.2-2: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=2
-              if (n_codewords == 1) {
-                dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][0];
-                dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][1];
-                dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][2];
-                dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][3];
-                dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][4];
-                dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][5];
-              }
-              if (n_codewords == 1) {
-                dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][0];
-                dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][1];
-                dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][2];
-                dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][3];
-                dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][4];
-                dlsch_config_pdu_1_1->dmrs_ports[4]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][5];
-                dlsch_config_pdu_1_1->dmrs_ports[5]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][6];
-                dlsch_config_pdu_1_1->dmrs_ports[6]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][7];
-                dlsch_config_pdu_1_1->dmrs_ports[7]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][8];
-                dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][9];
-              }
-            }
-            if ((mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.dmrs_type == 2) &&
-                (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.max_length == 1)){
-            // Table 7.3.1.2.2-3: Antenna port(s) (1000 + DMRS port), dmrs-Type=2, maxLength=1
-                if (n_codewords == 1) {
-                  dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][0];
-                  dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][1];
-                  dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][2];
-                  dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][3];
-                  dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][4];
-                }
-                if (n_codewords == 1) {
-                  dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][0];
-                  dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][1];
-                  dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][2];
-                  dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][3];
-                  dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][4];
-                  dlsch_config_pdu_1_1->dmrs_ports[4]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][5];
-                  dlsch_config_pdu_1_1->dmrs_ports[5]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][6];
-                }
-            }
-            if ((mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.dmrs_type == 2) &&
-                (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.max_length == 2)){
-            // Table 7.3.1.2.2-4: Antenna port(s) (1000 + DMRS port), dmrs-Type=2, maxLength=2
-                if (n_codewords == 1) {
-                  dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][0];
-                  dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][1];
-                  dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][2];
-                  dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][3];
-                  dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][4];
-                  dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][5];
-                }
-                if (n_codewords == 1) {
-                  dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][0];
-                  dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][1];
-                  dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][2];
-                  dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][3];
-                  dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][4];
-                  dlsch_config_pdu_1_1->dmrs_ports[4]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][5];
-                  dlsch_config_pdu_1_1->dmrs_ports[5]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][6];
-                  dlsch_config_pdu_1_1->dmrs_ports[6]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][7];
-                  dlsch_config_pdu_1_1->dmrs_ports[7]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][8];
-                  dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][9];
-                }
-            }
-        /* TCI */
-            if (mac->dl_config_request.dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.tci_present_in_dci == 1){
-              // 0 bit if higher layer parameter tci-PresentInDCI is not enabled
-              // otherwise 3 bits as defined in Subclause 5.1.5 of [6, TS38.214]
-              dlsch_config_pdu_1_1->tci_state = dci->tci;
-            }
-        /* SRS_REQUEST */
-            // if SUL is supported in the cell, there is an additional bit in this field and the value of this bit represents table 7.1.1.1-1 TS 38.212 FIXME!!!
-            dlsch_config_pdu_1_1->srs_config.aperiodicSRS_ResourceTrigger = (dci->srs_request & 0x11); // as per Table 7.3.1.1.2-24 TS 38.212
-        /* CBGTI */
-            dlsch_config_pdu_1_1->cbgti = dci->cbgti;
-        /* CBGFI */
-            dlsch_config_pdu_1_1->codeBlockGroupFlushIndicator = dci->cbgfi;
-        /* DMRS_SEQ_INI */
-            //FIXME!!!
-
-	    dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = n_RB_DLBWP;
+    dl_config->number_pdus = dl_config->number_pdus + 1;
+    break;
+
+  case NR_DL_DCI_FORMAT_1_1:        
+    /*
+     *  with CRC scrambled by C-RNTI or CS-RNTI or new-RNTI
+     *    0  IDENTIFIER_DCI_FORMATS:
+     *    1  CARRIER_IND:
+     *    7  BANDWIDTH_PART_IND:
+     *    11 FREQ_DOM_RESOURCE_ASSIGNMENT_DL:
+     *    12 TIME_DOM_RESOURCE_ASSIGNMENT: 0, 1, 2, 3, or 4 bits as defined in Subclause 5.1.2.1 of [6, TS 38.214]. The bitwidth for this field is determined as log2(I) bits,
+     *    13 VRB_TO_PRB_MAPPING: 0 bit if only resource allocation type 0
+     *    14 PRB_BUNDLING_SIZE_IND:
+     *    15 RATE_MATCHING_IND:
+     *    16 ZP_CSI_RS_TRIGGER:
+     *    18 TB1_MCS:
+     *    19 TB1_NDI:
+     *    20 TB1_RV:
+     *    21 TB2_MCS:
+     *    22 TB2_NDI:
+     *    23 TB2_RV:
+     *    27 HARQ_PROCESS_NUMBER:
+     *    28 DAI_: For format1_1: 4 if more than one serving cell are configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 MSB bits are the counter DAI and the 2 LSB bits are the total DAI
+     *    33 TPC_PUCCH:
+     *    34 PUCCH_RESOURCE_IND:
+     *    35 PDSCH_TO_HARQ_FEEDBACK_TIME_IND:
+     *    38 ANTENNA_PORTS:
+     *    39 TCI:
+     *    40 SRS_REQUEST:
+     *    43 CBGTI:
+     *    44 CBGFI:
+     *    47 DMRS_SEQ_INI:
+     */
+    dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH;
+    dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti;
+    fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_1 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15;
+    /* IDENTIFIER_DCI_FORMATS */
+    /* CARRIER_IND */
+    /* BANDWIDTH_PART_IND */
+    //    dlsch_config_pdu_1_1->bandwidth_part_ind = dci->bandwidth_part_ind;
+    /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */
+    nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_1,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL);
+    /* TIME_DOM_RESOURCE_ASSIGNMENT */
+    nr_ue_process_dci_time_dom_resource_assignment(mac,NULL,dlsch_config_pdu_1_1,
+						   dci->time_dom_resource_assignment);
+    /* VRB_TO_PRB_MAPPING */
+    if (mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.resource_allocation != 0)
+      dlsch_config_pdu_1_1->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping == 0) ? vrb_to_prb_mapping_non_interleaved:vrb_to_prb_mapping_interleaved;
+    /* PRB_BUNDLING_SIZE_IND */
+    dlsch_config_pdu_1_1->prb_bundling_size_ind = dci->prb_bundling_size_ind;
+    /* RATE_MATCHING_IND */
+    dlsch_config_pdu_1_1->rate_matching_ind = dci->rate_matching_ind;
+    /* ZP_CSI_RS_TRIGGER */
+    dlsch_config_pdu_1_1->zp_csi_rs_trigger = dci->zp_csi_rs_trigger;
+    /* MCS (for transport block 1)*/
+    dlsch_config_pdu_1_1->mcs = dci->tb1_mcs;
+    /* NDI (for transport block 1)*/
+    dlsch_config_pdu_1_1->ndi = dci->tb1_ndi;
+    /* RV (for transport block 1)*/
+    dlsch_config_pdu_1_1->rv = dci->tb1_rv;
+    /* MCS (for transport block 2)*/
+    dlsch_config_pdu_1_1->tb2_mcs = dci->tb2_mcs;
+    /* NDI (for transport block 2)*/
+    dlsch_config_pdu_1_1->tb2_ndi = dci->tb2_ndi;
+    /* RV (for transport block 2)*/
+    dlsch_config_pdu_1_1->tb2_rv = dci->tb2_rv;
+    /* HARQ_PROCESS_NUMBER */
+    dlsch_config_pdu_1_1->harq_process_nbr = dci->harq_process_number;
+    /* DAI */
+    dlsch_config_pdu_1_1->dai = dci ->dai;
+    /* TPC_PUCCH */
+    // according to TS 38.213 Table 7.2.1-1
+    if (dci->tpc_pucch == 0) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = -1;
+    if (dci->tpc_pucch == 1) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 0;
+    if (dci->tpc_pucch == 2) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 1;
+    if (dci->tpc_pucch == 3) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 3;
+    /* PUCCH_RESOURCE_IND */
+    if (dci->pucch_resource_ind == 0) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 1st value of resourceList FIXME!!!
+    if (dci->pucch_resource_ind == 1) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 2nd value of resourceList FIXME!!
+    if (dci->pucch_resource_ind == 2) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 3rd value of resourceList FIXME!!
+    if (dci->pucch_resource_ind == 3) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 4th value of resourceList FIXME!!
+    if (dci->pucch_resource_ind == 4) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 5th value of resourceList FIXME!!
+    if (dci->pucch_resource_ind == 5) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 6th value of resourceList FIXME!!
+    if (dci->pucch_resource_ind == 6) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 7th value of resourceList FIXME!!
+    if (dci->pucch_resource_ind == 7) dlsch_config_pdu_1_1->pucch_resource_id = 0; //pucch-ResourceId obtained from the 8th value of resourceList FIXME!!
+    /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */
+    // according to TS 38.213 Table 9.2.3-1
+    dlsch_config_pdu_1_1-> pdsch_to_harq_feedback_time_ind = mac->phy_config.config_req.ul_bwp_dedicated.pucch_config_dedicated.dl_data_to_ul_ack[dci->pdsch_to_harq_feedback_time_ind];
+    /* ANTENNA_PORTS */
+    uint8_t n_codewords = 1; // FIXME!!!
+    if ((mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.dmrs_type == 1) &&
+	(mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.max_length == 1)){
+      // Table 7.3.1.2.2-1: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=1
+      dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_1[dci->antenna_ports][0];
+      dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_1[dci->antenna_ports][1];
+      dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_1[dci->antenna_ports][2];
+      dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_1[dci->antenna_ports][3];
+      dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_1[dci->antenna_ports][4];
+    }
+    if ((mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.dmrs_type == 1) &&
+	(mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.max_length == 2)){
+      // Table 7.3.1.2.2-2: Antenna port(s) (1000 + DMRS port), dmrs-Type=1, maxLength=2
+      if (n_codewords == 1) {
+	dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][0];
+	dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][1];
+	dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][2];
+	dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][3];
+	dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][4];
+	dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports][5];
+      }
+      if (n_codewords == 1) {
+	dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][0];
+	dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][1];
+	dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][2];
+	dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][3];
+	dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][4];
+	dlsch_config_pdu_1_1->dmrs_ports[4]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][5];
+	dlsch_config_pdu_1_1->dmrs_ports[5]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][6];
+	dlsch_config_pdu_1_1->dmrs_ports[6]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][7];
+	dlsch_config_pdu_1_1->dmrs_ports[7]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][8];
+	dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports][9];
+      }
+    }
+    if ((mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.dmrs_type == 2) &&
+	(mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.max_length == 1)){
+      // Table 7.3.1.2.2-3: Antenna port(s) (1000 + DMRS port), dmrs-Type=2, maxLength=1
+      if (n_codewords == 1) {
+	dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][0];
+	dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][1];
+	dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][2];
+	dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][3];
+	dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports][4];
+      }
+      if (n_codewords == 1) {
+	dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][0];
+	dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][1];
+	dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][2];
+	dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][3];
+	dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][4];
+	dlsch_config_pdu_1_1->dmrs_ports[4]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][5];
+	dlsch_config_pdu_1_1->dmrs_ports[5]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports][6];
+      }
+    }
+    if ((mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.dmrs_type == 2) &&
+	(mac->phy_config.config_req.dl_bwp_dedicated.pdsch_config_dedicated.dmrs_dl_for_pdsch_mapping_type_a.max_length == 2)){
+      // Table 7.3.1.2.2-4: Antenna port(s) (1000 + DMRS port), dmrs-Type=2, maxLength=2
+      if (n_codewords == 1) {
+	dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][0];
+	dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][1];
+	dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][2];
+	dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][3];
+	dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][4];
+	dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports][5];
+      }
+      if (n_codewords == 1) {
+	dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][0];
+	dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][1];
+	dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][2];
+	dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][3];
+	dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][4];
+	dlsch_config_pdu_1_1->dmrs_ports[4]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][5];
+	dlsch_config_pdu_1_1->dmrs_ports[5]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][6];
+	dlsch_config_pdu_1_1->dmrs_ports[6]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][7];
+	dlsch_config_pdu_1_1->dmrs_ports[7]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][8];
+	dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports][9];
+      }
+    }
+    /* TCI */
+    if (mac->dl_config_request.dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.tci_present_in_dci == 1){
+      // 0 bit if higher layer parameter tci-PresentInDCI is not enabled
+      // otherwise 3 bits as defined in Subclause 5.1.5 of [6, TS38.214]
+      dlsch_config_pdu_1_1->tci_state = dci->tci;
+    }
+    /* SRS_REQUEST */
+    // if SUL is supported in the cell, there is an additional bit in this field and the value of this bit represents table 7.1.1.1-1 TS 38.212 FIXME!!!
+    dlsch_config_pdu_1_1->srs_config.aperiodicSRS_ResourceTrigger = (dci->srs_request & 0x11); // as per Table 7.3.1.1.2-24 TS 38.212
+    /* CBGTI */
+    dlsch_config_pdu_1_1->cbgti = dci->cbgti;
+    /* CBGFI */
+    dlsch_config_pdu_1_1->codeBlockGroupFlushIndicator = dci->cbgfi;
+    /* DMRS_SEQ_INI */
+    //FIXME!!!
+
+    //	    dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = n_RB_DLBWP;
 	    
-            dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH;
-            LOG_D(MAC,"(nr_ue_procedures.c) pdu_type=%d\n\n",dl_config->dl_config_list[dl_config->number_pdus].pdu_type);
+    dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH;
+    LOG_D(MAC,"(nr_ue_procedures.c) pdu_type=%d\n\n",dl_config->dl_config_list[dl_config->number_pdus].pdu_type);
             
-            dl_config->number_pdus = dl_config->number_pdus + 1;
+    dl_config->number_pdus = dl_config->number_pdus + 1;
 
-            break;
+    break;
 
-        case format2_0:        
-            break;
+  case NR_DL_DCI_FORMAT_2_0:
+    break;
 
-        case format2_1:        
-            break;
+  case NR_DL_DCI_FORMAT_2_1:        
+    break;
 
-        case format2_2:        
-            break;
+  case NR_DL_DCI_FORMAT_2_2:        
+    break;
 
-        case format2_3:
-            break;
+  case NR_DL_DCI_FORMAT_2_3:
+    break;
 
-        default: 
-            break;
-    }
+  default: 
+    break;
+  }
 
 
-    if(rnti == SI_RNTI){
+  if(rnti == SI_RNTI){
 
-    }else if(rnti == mac->ra_rnti){
+    //    }else if(rnti == mac->ra_rnti){
 
-    }else if(rnti == P_RNTI){
+  }else if(rnti == P_RNTI){
 
-    }else{  //  c-rnti
+  }else{  //  c-rnti
 
-        ///  check if this is pdcch order 
-        //dci->random_access_preamble_index;
-        //dci->ss_pbch_index;
-        //dci->prach_mask_index;
+    ///  check if this is pdcch order 
+    //dci->random_access_preamble_index;
+    //dci->ss_pbch_index;
+    //dci->prach_mask_index;
 
-        ///  else normal DL-SCH grant
-    }
-    return 0;
+    ///  else normal DL-SCH grant
+  }
+  return 0;
 }
 
 int8_t nr_ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe){
 
-    return 0;
+  return 0;
 }
 
 void nr_ue_send_sdu(module_id_t module_idP,
                     uint8_t CC_id,
                     frame_t frameP,
-                    uint8_t ttiP,
+                    int slotP,
                     uint8_t * pdu, uint16_t pdu_len, uint8_t gNB_index,
                     NR_UL_TIME_ALIGNMENT_t *ul_time_alignment){
 
-  LOG_D(MAC, "Handling PDU frame %d slot %d\n", frameP, ttiP);
+  LOG_D(MAC, "Handling PDU frame %d slot %d\n", frameP, slotP);
 
   uint8_t * pduP = pdu;
   NR_UE_MAC_INST_t *UE_mac_inst = get_mac_inst(module_idP);
 
-  /*
-  #if UE_TIMING_TRACE
-    start_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu);
-  #endif
-  */
-
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN);
 
   //LOG_D(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]);
 
-  if (opt_enabled) {
-    trace_pdu(DIRECTION_DOWNLINK, pduP, pdu_len, module_idP, WS_C_RNTI,
-    (int)(UE_mac_inst[module_idP].cs_RNTI), frameP, ttiP, 0, 0); //subframeP
-    LOG_D(OPT, "[UE %d][DLSCH] Frame %d trace pdu for rnti %p  with size %d\n",
-      module_idP, frameP, UE_mac_inst[module_idP].cs_RNTI, pdu_len);
-    }
-
   /*
   #ifdef DEBUG_HEADER_PARSING
     LOG_D(MAC, "[UE %d] ue_send_sdu : Frame %d gNB_index %d : num_ce %d num_sdu %d\n",
@@ -2098,21 +2706,366 @@ void nr_ue_send_sdu(module_id_t module_idP,
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT);
 
-  /*
-  #if UE_TIMING_TRACE
-    stop_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu);
-  #endif
-  */
 }
 
-void nr_ue_process_mac_pdu(
-    module_id_t module_idP,
-    uint8_t CC_id,
-    frame_t frameP,
-    uint8_t *pduP, 
-    uint16_t mac_pdu_len,
-    uint8_t gNB_index,
-    NR_UL_TIME_ALIGNMENT_t *ul_time_alignment){
+void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
+			 int dci_format,
+			 uint8_t dci_size,
+			 uint16_t rnti,
+			 uint64_t *dci_pdu,
+			 nr_dci_pdu_rel15_t *dci_pdu_rel15) {
+  int rnti_type=-1;
+
+  if       (rnti == mac->ra_rnti) rnti_type = NR_RNTI_RA;
+  else if (rnti == mac->crnti)    rnti_type = NR_RNTI_C;
+  else if (rnti == mac->t_crnti)  rnti_type = NR_RNTI_TC;
+  else if (rnti == 0xFFFE)        rnti_type = NR_RNTI_P;
+  else if (rnti == 0xFFFF)        rnti_type = NR_RNTI_SI;
+
+  AssertFatal(rnti_type!=-1,"no identified/handled rnti\n");
+  AssertFatal(mac->DLbwp[0] != NULL, "DLbwp[0] shouldn't be null here!\n");
+  AssertFatal(mac->ULbwp[0] != NULL, "ULbwp[0] shouldn't be null here!\n");
+  int N_RB = (mac->scd != NULL) ? 
+    NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275) :
+    NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,275);
+  int N_RB_UL = (mac->scd != NULL) ? 
+    NRRIV2BW(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275) :
+    NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth,275);
+
+  int pos=0;
+  int fsize=0;
+  switch(dci_format) {
+
+  case NR_DL_DCI_FORMAT_1_0:
+    switch(rnti_type) {
+    case NR_RNTI_RA:
+      // Freq domain assignment
+      fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+      pos=fsize;
+      dci_pdu_rel15->freq_dom_resource_assignment_DL = *dci_pdu>>(dci_size-pos)&((1<<fsize)-1);
+#ifdef DEBUG_EXTRACT_DCI
+      LOG_D(MAC,"frequency-domain assignment %d (%d bits) N_RB_BWP %d=> %d (0x%lx)\n",dci_pdu_rel15->freq_dom_resource_assignment_DL,fsize,N_RB,dci_size-pos,*dci_pdu);
+#endif
+      // Time domain assignment
+      pos+=4;
+      dci_pdu_rel15->time_dom_resource_assignment = (*dci_pdu >> (dci_size-pos))&0xf;
+#ifdef DEBUG_EXTRACT_DCI
+      LOG_D(MAC,"time-domain assignment %d  (3 bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_dom_resource_assignment,dci_size-pos,*dci_pdu);
+#endif
+      // VRB to PRB mapping
+	
+      pos++;
+      dci_pdu_rel15->vrb_to_prb_mapping = (*dci_pdu>>(dci_size-pos))&0x1;
+#ifdef DEBUG_EXTRACT_DCI
+      LOG_D(MAC,"vrb to prb mapping %d  (1 bits)=> %d (0x%lx)\n",dci_pdu_rel15->vrb_to_prb_mapping,dci_size-pos,*dci_pdu);
+#endif
+      // MCS
+      pos+=5;
+      dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f;
+#ifdef DEBUG_EXTRACT_DCI
+      LOG_D(MAC,"mcs %d  (5 bits)=> %d (0x%lx)\n",dci_pdu_rel15->mcs,dci_size-pos,*dci_pdu);
+#endif
+      // TB scaling
+      pos+=2;
+      dci_pdu_rel15->tb_scaling = (*dci_pdu>>(dci_size-pos))&0x3;
+#ifdef DEBUG_EXTRACT_DCI
+      LOG_D(MAC,"tb_scaling %d  (2 bits)=> %d (0x%lx)\n",dci_pdu_rel15->tb_scaling,dci_size-pos,*dci_pdu);
+#endif
+      break;
+  	
+    case NR_RNTI_C:
+	
+      // indicating a DL DCI format 1bit
+      pos++;
+      dci_pdu_rel15->identifier_dci_formats = (*dci_pdu>>(dci_size-pos))&1;
+#ifdef DEBUG_EXTRACT_DCI
+      LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->identifier_dci_formats,1,N_RB,dci_size-pos,*dci_pdu);
+#endif
+  	
+      // Freq domain assignment (275rb >> fsize = 16)
+      fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+      pos+=fsize;
+      dci_pdu_rel15->freq_dom_resource_assignment_DL = (*dci_pdu>>(dci_size-pos))&((1<<fsize)-1);
+  	
+#ifdef DEBUG_EXTRACT_DCI
+      LOG_D(MAC,"Freq domain assignment %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->freq_dom_resource_assignment_DL,fsize,dci_size-pos,*dci_pdu);
+#endif
+    	
+      uint16_t is_ra = 1;
+      for (int i=0; i<fsize; i++)
+	if (!((dci_pdu_rel15->freq_dom_resource_assignment_DL>>i)&1)) {
+	  is_ra = 0;
+	  break;
+	}
+      if (is_ra) //fsize are all 1  38.212 p86
+	{
+	  // ra_preamble_index 6 bits
+	  pos+=6;
+	  dci_pdu_rel15->ra_preamble_index = (*dci_pdu>>(dci_size-pos))&0x3f;
+	    
+	  // UL/SUL indicator  1 bit
+	  pos++;
+	  dci_pdu_rel15->sul_ind_0_1 = (*dci_pdu>>(dci_size-pos))&1;
+	    
+	  // SS/PBCH index  6 bits
+	  pos+=6;
+	  dci_pdu_rel15->ss_pbch_index = (*dci_pdu>>(dci_size-pos))&0x3f;
+	    
+	  //  prach_mask_index  4 bits
+	  pos+=4;
+	  dci_pdu_rel15->prach_mask_index = (*dci_pdu>>(dci_size-pos))&0xf;
+	    
+	}  //end if
+      else {
+	  
+	// Time domain assignment 4bit
+		  
+	pos+=4;
+	dci_pdu_rel15->time_dom_resource_assignment = (*dci_pdu>>(dci_size-pos))&0xf;
+#ifdef DEBUG_EXTRACT_DCI
+	LOG_D(MAC,"Time domain assignment %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_dom_resource_assignment,4,dci_size-pos,*dci_pdu);
+#endif
+	  
+	// VRB to PRB mapping  1bit
+	pos++;
+	dci_pdu_rel15->vrb_to_prb_mapping = (*dci_pdu>>(dci_size-pos))&1;
+#ifdef DEBUG_EXTRACT_DCI
+	LOG_D(MAC,"VRB to PRB %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->vrb_to_prb_mapping,1,dci_size-pos,*dci_pdu);
+#endif
+	
+	// MCS 5bit  //bit over 32, so dci_pdu ++
+	pos+=5;
+	dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f;
+#ifdef DEBUG_EXTRACT_DCI
+	LOG_D(MAC,"MCS %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->mcs,5,dci_size-pos,*dci_pdu);
+#endif
+	  
+	// New data indicator 1bit
+	pos++;
+	dci_pdu_rel15->ndi = (*dci_pdu>>(dci_size-pos))&1;
+#ifdef DEBUG_EXTRACT_DCI
+	LOG_D(MAC,"NDI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->ndi,1,dci_size-pos,*dci_pdu);
+#endif      
+	  
+	// Redundancy version  2bit
+	pos+=2;
+	dci_pdu_rel15->rv = (*dci_pdu>>(dci_size-pos))&0x3;
+#ifdef DEBUG_EXTRACT_DCI
+	LOG_D(MAC,"RV %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->rv,2,dci_size-pos,*dci_pdu);
+#endif
+	  
+	// HARQ process number  4bit
+	pos+=4;
+	dci_pdu_rel15->harq_process_number  = (*dci_pdu>>(dci_size-pos))&0xf;
+#ifdef DEBUG_EXTRACT_DCI
+	LOG_D(MAC,"HARQ_PID %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->harq_process_number,4,dci_size-pos,*dci_pdu);
+#endif
+	  
+	// Downlink assignment index  2bit
+	pos+=2;
+	dci_pdu_rel15->dai = (*dci_pdu>>(dci_size-pos))&3;
+#ifdef DEBUG_EXTRACT_DCI
+	LOG_D(MAC,"DAI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->dai,2,dci_size-pos,*dci_pdu);
+#endif
+	  
+	// TPC command for scheduled PUCCH  2bit
+	pos+=2;
+	dci_pdu_rel15->tpc_pucch = (*dci_pdu>>(dci_size-pos))&3;
+#ifdef DEBUG_EXTRACT_DCI
+	LOG_D(MAC,"TPC %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->tpc_pucch,2,dci_size-pos,*dci_pdu);
+#endif
+	  
+	// PUCCH resource indicator  3bit
+	pos+=3;
+	dci_pdu_rel15->pucch_resource_ind = (*dci_pdu>>(dci_size-pos))&0x7;
+#ifdef DEBUG_EXTRACT_DCI
+	LOG_D(MAC,"PUCCH RI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->pucch_resource_ind,3,dci_size-pos,*dci_pdu);
+#endif
+	  
+	// PDSCH-to-HARQ_feedback timing indicator 3bit
+	pos+=3;
+	dci_pdu_rel15->pdsch_to_harq_feedback_time_ind = (*dci_pdu>>(dci_size-pos))&0x7;
+#ifdef DEBUG_EXTRACT_DCI
+	LOG_D(MAC,"PDSCH to HARQ TI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->pdsch_to_harq_feedback_time_ind,3,dci_size-pos,*dci_pdu);
+#endif
+	  
+      } //end else
+      break;
+    	
+    case NR_RNTI_P:
+      /*
+      // Short Messages Indicator – 2 bits
+      for (int i=0; i<2; i++)
+      dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages_indicator>>(1-i))&1)<<(dci_size-pos++);
+      // Short Messages – 8 bits
+      for (int i=0; i<8; i++)
+      *dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages>>(7-i))&1)<<(dci_size-pos++);
+      // Freq domain assignment 0-16 bit
+      fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+      for (int i=0; i<fsize; i++)
+      *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_size-pos++);
+      // Time domain assignment 4 bit
+      for (int i=0; i<4; i++)
+      *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_size-pos++);
+      // VRB to PRB mapping 1 bit
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping&1)<<(dci_size-pos++);
+      // MCS 5 bit
+      for (int i=0; i<5; i++)
+      *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs>>(4-i))&1)<<(dci_size-pos++);
+	
+      // TB scaling 2 bit
+      for (int i=0; i<2; i++)
+      *dci_pdu |= (((uint64_t)dci_pdu_rel15->tb_scaling>>(1-i))&1)<<(dci_size-pos++);
+      */	
+	
+      break;
+  	
+    case NR_RNTI_SI:
+      /*
+      // Freq domain assignment 0-16 bit
+      fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+      for (int i=0; i<fsize; i++)
+      *dci_pdu |= ((dci_pdu_rel15->frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_size-pos++);
+      // Time domain assignment 4 bit
+      for (int i=0; i<4; i++)
+      *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_size-pos++);
+      // VRB to PRB mapping 1 bit
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping&1)<<(dci_size-pos++);
+      // MCS 5bit  //bit over 32, so dci_pdu ++
+      for (int i=0; i<5; i++)
+      *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs>>(4-i))&1)<<(dci_size-pos++);
+      // Redundancy version  2bit
+      for (int i=0; i<2; i++)
+      *dci_pdu |= (((uint64_t)dci_pdu_rel15->rv>>(1-i))&1)<<(dci_size-pos++);
+      */	
+      break;
+	
+    case NR_RNTI_TC:
+      // indicating a DL DCI format 1bit
+      pos++;
+      dci_pdu_rel15->identifier_dci_formats = (*dci_pdu>>(dci_size-pos))&1;
+      // Freq domain assignment 0-16 bit
+      fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+      pos+=fsize;
+      dci_pdu_rel15->freq_dom_resource_assignment_DL = (*dci_pdu>>(dci_size-pos))&((1<<fsize)-1);
+      // Time domain assignment 4 bit
+      pos+=4;
+      dci_pdu_rel15->time_dom_resource_assignment = (*dci_pdu>>(dci_size-pos))&0xf;
+      // VRB to PRB mapping 1 bit
+      dci_pdu_rel15->vrb_to_prb_mapping = (*dci_pdu>>(dci_size-pos))&1;
+      // MCS 5bit  //bit over 32, so dci_pdu ++
+      pos+=5;
+      dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f;
+      // New data indicator 1bit
+      dci_pdu_rel15->ndi = (*dci_pdu>>(dci_size-pos))&1;
+      // Redundancy version  2bit
+      pos+=2;
+      dci_pdu_rel15->rv = (*dci_pdu>>(dci_size-pos))&3;
+      // HARQ process number  4bit
+      pos+=4;
+      dci_pdu_rel15->harq_process_number = (*dci_pdu>>(dci_size-pos))&0xf;
+      // Downlink assignment index – 2 bits
+      pos+=2;
+      dci_pdu_rel15->dai = (*dci_pdu>>(dci_size-pos))&3;
+      // TPC command for scheduled PUCCH – 2 bits
+      pos+=2;
+      dci_pdu_rel15->tpc_pucch  = (*dci_pdu>>(dci_size-pos))&3;
+      // PDSCH-to-HARQ_feedback timing indicator – 3 bits
+      pos+=3;
+      dci_pdu_rel15->pdsch_to_harq_feedback_time_ind = (*dci_pdu>>(dci_size-pos))&7;
+       
+      break;
+    }
+    break;
+  
+  case NR_UL_DCI_FORMAT_0_0:
+    switch(rnti_type)
+      {
+      case NR_RNTI_C:
+	// indicating a DL DCI format 1bit
+	dci_pdu_rel15->identifier_dci_formats = (*dci_pdu>>(dci_size-pos))&1;
+	// Freq domain assignment  max 16 bit
+	fsize = (int)ceil( log2( (N_RB_UL*(N_RB_UL+1))>>1 ) );
+	pos+=fsize;
+	dci_pdu_rel15->freq_dom_resource_assignment_UL = (*dci_pdu>>(dci_size-pos))&((1<<fsize)-1);
+	// Time domain assignment 4bit
+	pos+=4;
+	dci_pdu_rel15->time_dom_resource_assignment = (*dci_pdu>>(dci_size-pos))&0xf;
+	// Frequency hopping flag – 1 bit
+	pos++;
+	dci_pdu_rel15->freq_hopping_flag= (*dci_pdu>>(dci_size-pos))&1;
+	// MCS  5 bit
+	pos+=5;
+	dci_pdu_rel15->mcs= (*dci_pdu>>(dci_size-pos))&0x1f;
+	// New data indicator 1bit
+	pos++;
+	dci_pdu_rel15->ndi= (*dci_pdu>>(dci_size-pos))&1;
+	// Redundancy version  2bit
+	pos+=2;
+	dci_pdu_rel15->rv= (*dci_pdu>>(dci_size-pos))&3;
+	// HARQ process number  4bit
+	pos+=4;
+	dci_pdu_rel15->harq_process_number = (*dci_pdu>>(dci_size-pos))&0xf;
+	// TPC command for scheduled PUSCH – 2 bits
+	pos+=2;
+	dci_pdu_rel15->tpc_pusch = (*dci_pdu>>(dci_size-pos))&3;
+	// UL/SUL indicator – 1 bit
+	/* commented for now (RK): need to get this from BWP descriptor
+	   if (cfg->pucch_config.pucch_GroupHopping.value)
+	   dci_pdu->= ((uint64_t)*dci_pdu>>(dci_size-pos)ul_sul_indicator&1)<<(dci_size-pos++);
+	*/
+	break;
+	
+      case NR_RNTI_TC:
+	/*	
+	// indicating a DL DCI format 1bit
+	dci_pdu->= (*dci_pdu>>(dci_size-pos)format_indicator&1)<<(dci_size-pos++);
+	// Freq domain assignment  max 16 bit
+	fsize = (int)ceil( log2( (N_RB_UL*(N_RB_UL+1))>>1 ) );
+	for (int i=0; i<fsize; i++)
+	dci_pdu->= ((*dci_pdu>>(dci_size-pos)frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_size-pos++);
+	// Time domain assignment 4bit
+	for (int i=0; i<4; i++)
+	dci_pdu->= (((uint64_t)*dci_pdu>>(dci_size-pos)time_domain_assignment>>(3-i))&1)<<(dci_size-pos++);
+	// Frequency hopping flag – 1 bit
+	dci_pdu->= ((uint64_t)*dci_pdu>>(dci_size-pos)frequency_hopping_flag&1)<<(dci_size-pos++);
+	// MCS  5 bit
+	for (int i=0; i<5; i++)
+	dci_pdu->= (((uint64_t)*dci_pdu>>(dci_size-pos)mcs>>(4-i))&1)<<(dci_size-pos++);
+	// New data indicator 1bit
+	dci_pdu->= ((uint64_t)*dci_pdu>>(dci_size-pos)ndi&1)<<(dci_size-pos++);
+	// Redundancy version  2bit
+	for (int i=0; i<2; i++)
+	dci_pdu->= (((uint64_t)*dci_pdu>>(dci_size-pos)rv>>(1-i))&1)<<(dci_size-pos++);
+	// HARQ process number  4bit
+	for (int i=0; i<4; i++)
+	*dci_pdu  |= (((uint64_t)*dci_pdu>>(dci_size-pos)harq_pid>>(3-i))&1)<<(dci_size-pos++);
+	
+	// TPC command for scheduled PUSCH – 2 bits
+	for (int i=0; i<2; i++)
+	dci_pdu->= (((uint64_t)*dci_pdu>>(dci_size-pos)tpc>>(1-i))&1)<<(dci_size-pos++);
+	*/	
+	// UL/SUL indicator – 1 bit
+	/*
+	  commented for now (RK): need to get this information from BWP descriptor
+	  if (cfg->pucch_config.pucch_GroupHopping.value)
+	  dci_pdu->= ((uint64_t)dci_pdu_rel15->ul_sul_indicator&1)<<(dci_size-pos++);
+	*/
+	break;
+	
+      }
+    break;
+  }
+}
+
+
+void nr_ue_process_mac_pdu(module_id_t module_idP,
+                           uint8_t CC_id,
+                           frame_t frameP,
+                           uint8_t *pduP, 
+                           uint16_t mac_pdu_len,
+                           uint8_t gNB_index,
+                           NR_UL_TIME_ALIGNMENT_t *ul_time_alignment){
 
     // This function is adapting code from the old
     // parse_header(...) and ue_send_sdu(...) functions of OAI LTE
@@ -2151,9 +3104,9 @@ void nr_ue_process_mac_pdu(
     //  R: Reserved bit, set to zero.
     
     while (!done && pdu_len > 0){
-        mac_ce_len = 0;
-        mac_subheader_len = 1; //  default to fixed-length subheader = 1-oct
-        mac_sdu_len = 0;
+        mac_ce_len = 0x0000;
+        mac_subheader_len = 0x0001; //  default to fixed-length subheader = 1-oct
+        mac_sdu_len = 0x0000;
         rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pdu_ptr)->LCID;
 
         switch(rx_lcid){
diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c
index 438dd24ecfe..c911fbd56a6 100644
--- a/openair2/LAYER2/NR_MAC_gNB/config.c
+++ b/openair2/LAYER2/NR_MAC_gNB/config.c
@@ -41,8 +41,10 @@
 #include "NR_ServingCellConfigCommon.h"
 
 #include "LAYER2/NR_MAC_gNB/mac_proto.h"
+#include "SCHED_NR/phy_frame_config_nr.h"
 
 #include "NR_MIB.h"
+#include "nr_mac_common.h"
 
 extern RAN_CONTEXT_t RC;
 //extern int l2_init_gNB(void);
@@ -50,170 +52,323 @@ extern void mac_top_init_gNB(void);
 extern uint8_t nfapi_mode;
 
 
-void config_nr_mib(int Mod_idP, 
-                int CC_idP,
-                int p_gNBP,
-                int subCarrierSpacingCommon, 
-                uint32_t ssb_SubcarrierOffset,
-                int dmrs_TypeA_Position,
-                uint32_t pdcch_ConfigSIB1,
-                int cellBarred,
-                int intraFreqReselection
-                ){
-  nfapi_nr_config_request_t *cfg = &RC.nrmac[Mod_idP]->config[CC_idP];
+void config_common(int Mod_idP, int pdsch_AntennaPorts, NR_ServingCellConfigCommon_t *scc) {
 
-  cfg->num_tlv=0;
-  
-  cfg->rf_config.dl_subcarrierspacing.value  = subCarrierSpacingCommon;
+  nfapi_nr_config_request_scf_t *cfg = &RC.nrmac[Mod_idP]->config[0];
+  RC.nrmac[Mod_idP]->common_channels[0].ServingCellConfigCommon = scc;
+  int i;
+
+  // Carrier configuration
 
-  cfg->rf_config.dl_subcarrierspacing.tl.tag = NFAPI_NR_RF_CONFIG_DL_SUBCARRIERSPACING_TAG;
+  cfg->carrier_config.dl_bandwidth.value = config_bandwidth(scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing,
+                                                            scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,
+                                                            *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]);
+  cfg->carrier_config.dl_bandwidth.tl.tag   = NFAPI_NR_CONFIG_DL_BANDWIDTH_TAG; //temporary
   cfg->num_tlv++;
-  
-  cfg->rf_config.ul_subcarrierspacing.value  = subCarrierSpacingCommon;
-  cfg->rf_config.ul_subcarrierspacing.tl.tag = NFAPI_NR_RF_CONFIG_UL_SUBCARRIERSPACING_TAG;
+  LOG_I(PHY,"%s() dl_BandwidthP:%d\n", __FUNCTION__, cfg->carrier_config.dl_bandwidth.value);
+
+  cfg->carrier_config.dl_frequency.value = from_nrarfcn(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0],
+                                                        *scc->ssbSubcarrierSpacing,
+                                                        scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA)/1000; // freq in kHz
+  cfg->carrier_config.dl_frequency.tl.tag = NFAPI_NR_CONFIG_DL_FREQUENCY_TAG;
   cfg->num_tlv++;
 
-  cfg->sch_config.ssb_subcarrier_offset.value = ssb_SubcarrierOffset;
-  cfg->sch_config.ssb_subcarrier_offset.tl.tag = NFAPI_NR_SCH_CONFIG_SSB_SUBCARRIER_OFFSET_TAG;
-  cfg->num_tlv++; 
-}
+  for (i=0; i<5; i++) {
+    if (i==scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing) {
+      cfg->carrier_config.dl_grid_size[i].value = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+      cfg->carrier_config.dl_k0[i].value = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier;
+      cfg->carrier_config.dl_grid_size[i].tl.tag = NFAPI_NR_CONFIG_DL_GRID_SIZE_TAG;
+      cfg->carrier_config.dl_k0[i].tl.tag = NFAPI_NR_CONFIG_DL_K0_TAG;
+      cfg->num_tlv++;
+      cfg->num_tlv++;
+    }
+    else {
+      cfg->carrier_config.dl_grid_size[i].value = 0;
+      cfg->carrier_config.dl_k0[i].value = 0;
+    }
+  }
 
-void config_common(int Mod_idP, 
-                   int CC_idP,
-				   int cellid,
-                   int nr_bandP,
-                   uint64_t ssb_pattern,
-				   uint16_t ssb_periodicity,
-				   uint64_t dl_CarrierFreqP,
-                   uint32_t dl_BandwidthP)
-{
-  nfapi_nr_config_request_t *cfg = &RC.nrmac[Mod_idP]->config[CC_idP];
+  cfg->carrier_config.uplink_bandwidth.value = config_bandwidth(scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing,
+                                                                scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,
+                                                                *scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]);
+  cfg->carrier_config.uplink_bandwidth.tl.tag   = NFAPI_NR_CONFIG_UPLINK_BANDWIDTH_TAG; //temporary
+  cfg->num_tlv++;
+  LOG_I(PHY,"%s() dl_BandwidthP:%d\n", __FUNCTION__, cfg->carrier_config.uplink_bandwidth.value);
+
+  int UL_pointA;
+  if (scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA == NULL)
+    UL_pointA = scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA;
+  else
+    UL_pointA = *scc->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA; 
+
+  cfg->carrier_config.uplink_frequency.value = from_nrarfcn(*scc->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0],
+                                                            *scc->ssbSubcarrierSpacing,
+                                                            UL_pointA)/1000; // freq in kHz
+  cfg->carrier_config.uplink_frequency.tl.tag = NFAPI_NR_CONFIG_UPLINK_FREQUENCY_TAG;
+  cfg->num_tlv++;
 
-  int mu = 1;
+  for (i=0; i<5; i++) {
+    if (i==scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing) {
+      cfg->carrier_config.ul_grid_size[i].value = scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+      cfg->carrier_config.ul_k0[i].value = scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier;
+      cfg->carrier_config.ul_grid_size[i].tl.tag = NFAPI_NR_CONFIG_UL_GRID_SIZE_TAG;
+      cfg->carrier_config.ul_k0[i].tl.tag = NFAPI_NR_CONFIG_UL_K0_TAG;
+      cfg->num_tlv++;
+      cfg->num_tlv++;
+    }
+    else {
+      cfg->carrier_config.ul_grid_size[i].value = 0;
+      cfg->carrier_config.ul_k0[i].value = 0;
+    }
+  }
 
-  cfg->sch_config.physical_cell_id.value = cellid;
-  cfg->sch_config.ssb_scg_position_in_burst.value = ssb_pattern;
-  cfg->sch_config.ssb_periodicity.value = ssb_periodicity;
 
-  // FDD
-  cfg->subframe_config.duplex_mode.value                          = 1;
-  cfg->subframe_config.duplex_mode.tl.tag = NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG;
-  cfg->num_tlv++;
-  
-  /// In NR DL and UL will be different band
-  cfg->nfapi_config.rf_bands.number_rf_bands       = 1;
-  cfg->nfapi_config.rf_bands.rf_band[0]            = nr_bandP;  
-  cfg->nfapi_config.rf_bands.tl.tag = NFAPI_PHY_RF_BANDS_TAG;
+  // Cell configuration
+  cfg->cell_config.phy_cell_id.value = *scc->physCellId;
+  cfg->cell_config.phy_cell_id.tl.tag = NFAPI_NR_CONFIG_PHY_CELL_ID_TAG;
   cfg->num_tlv++;
 
-  cfg->nfapi_config.nrarfcn.value                   = to_nrarfcn(nr_bandP,dl_CarrierFreqP,dl_BandwidthP*180000*(1+mu));
-  cfg->nfapi_config.nrarfcn.tl.tag = NFAPI_NR_NFAPI_NRARFCN_TAG;
+  cfg->cell_config.frame_duplex_type.value = 1;
+  cfg->cell_config.frame_duplex_type.tl.tag = NFAPI_NR_CONFIG_FRAME_DUPLEX_TYPE_TAG;
   cfg->num_tlv++;
 
-  cfg->subframe_config.numerology_index_mu.value = mu;
-  //cfg->subframe_config.tl.tag = 
-  //cfg->num_tlv++;
 
-  cfg->rf_config.dl_carrier_bandwidth.value    = dl_BandwidthP;
-  cfg->rf_config.dl_carrier_bandwidth.tl.tag   = NFAPI_RF_CONFIG_DL_CHANNEL_BANDWIDTH_TAG; //temporary
+  // SSB configuration
+  cfg->ssb_config.ss_pbch_power.value = scc->ss_PBCH_BlockPower;
+  cfg->ssb_config.ss_pbch_power.tl.tag = NFAPI_NR_CONFIG_SS_PBCH_POWER_TAG;
   cfg->num_tlv++;
-  LOG_I(PHY,"%s() dl_BandwidthP:%d\n", __FUNCTION__, dl_BandwidthP);
 
-  cfg->rf_config.ul_carrier_bandwidth.value    = dl_BandwidthP;
-  cfg->rf_config.ul_carrier_bandwidth.tl.tag   = NFAPI_RF_CONFIG_UL_CHANNEL_BANDWIDTH_TAG;  //temporary
+  cfg->ssb_config.scs_common.value = *scc->ssbSubcarrierSpacing;
+  cfg->ssb_config.scs_common.tl.tag = NFAPI_NR_CONFIG_SCS_COMMON_TAG;
   cfg->num_tlv++;
 
-  //cfg->sch_config.half_frame_index.value = 0; Fix in PHY
-  //cfg->sch_config.n_ssb_crb.value = 86;       Fix in PHY
+  // PRACH configuration
 
-}
+  cfg->prach_config.prach_sequence_length.value = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present;
+  cfg->prach_config.prach_sequence_length.tl.tag = NFAPI_NR_CONFIG_PRACH_SEQUENCE_LENGTH_TAG;
+  cfg->num_tlv++;  
 
-/*void config_servingcellconfigcommon(){
+  if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing)
+    cfg->prach_config.prach_sub_c_spacing.value = *scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing;
+  else 
+    cfg->prach_config.prach_sub_c_spacing.value = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing;
+  cfg->prach_config.prach_sub_c_spacing.tl.tag = NFAPI_NR_CONFIG_PRACH_SUB_C_SPACING_TAG;
+  cfg->num_tlv++;
 
-}*/
+  cfg->prach_config.restricted_set_config.value = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->restrictedSetConfig;
+  cfg->prach_config.restricted_set_config.tl.tag = NFAPI_NR_CONFIG_RESTRICTED_SET_CONFIG_TAG;
+  cfg->num_tlv++;
 
-int rrc_mac_config_req_gNB(module_id_t Mod_idP, 
-                           int CC_idP,
-						   int cellid,
-                           int p_gNB,
-                           int nr_bandP,
-						   uint64_t ssb_pattern,
-                           uint16_t ssb_enum_periodicity,
-                           uint64_t dl_CarrierFreqP,
-                           int dl_BandwidthP,
-                           NR_BCCH_BCH_Message_t *mib,
-                           NR_ServingCellConfigCommon_t *servingcellconfigcommon)
-{
-  uint16_t ssb_periodicity=0;
-
-  switch (ssb_enum_periodicity) {
-    case 0:
-      ssb_periodicity = 5;
+  switch (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FDM) {
+    case 0 :
+      cfg->prach_config.num_prach_fd_occasions.value = 1;
       break;
-    case 1:
-      ssb_periodicity = 10;
+    case 1 :
+      cfg->prach_config.num_prach_fd_occasions.value = 2;
       break;
-    case 2:
-      ssb_periodicity = 20;
+    case 2 :
+      cfg->prach_config.num_prach_fd_occasions.value = 4;
       break;
-    case 3:
-      ssb_periodicity = 40;
+    case 3 :
+      cfg->prach_config.num_prach_fd_occasions.value = 8;
       break;
-    case 4:
-      ssb_periodicity = 80;
+    default:
+      AssertFatal(1==0,"msg1 FDM identifier %ld undefined (0,1,2,3) \n", scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FDM);
+  } 
+  cfg->prach_config.num_prach_fd_occasions.tl.tag = NFAPI_NR_CONFIG_NUM_PRACH_FD_OCCASIONS_TAG;
+  cfg->num_tlv++;
+
+  cfg->prach_config.num_prach_fd_occasions_list = (nfapi_nr_num_prach_fd_occasions_t *) malloc(cfg->prach_config.num_prach_fd_occasions.value*sizeof(nfapi_nr_num_prach_fd_occasions_t));
+  for (i=0; i<cfg->prach_config.num_prach_fd_occasions.value; i++) {
+    cfg->prach_config.num_prach_fd_occasions_list[i].num_prach_fd_occasions = i;
+    if (cfg->prach_config.prach_sequence_length.value)
+      cfg->prach_config.num_prach_fd_occasions_list[i].prach_root_sequence_index.value = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l139; 
+    else
+      cfg->prach_config.num_prach_fd_occasions_list[i].prach_root_sequence_index.value = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l839;
+    cfg->prach_config.num_prach_fd_occasions_list[i].prach_root_sequence_index.tl.tag = NFAPI_NR_CONFIG_PRACH_ROOT_SEQUENCE_INDEX_TAG;
+    cfg->num_tlv++;
+    cfg->prach_config.num_prach_fd_occasions_list[i].k1.value = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FrequencyStart;
+    cfg->prach_config.num_prach_fd_occasions_list[i].k1.tl.tag = NFAPI_NR_CONFIG_K1_TAG;
+    cfg->num_tlv++;
+    cfg->prach_config.num_prach_fd_occasions_list[i].prach_zero_corr_conf.value = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.zeroCorrelationZoneConfig;
+    cfg->prach_config.num_prach_fd_occasions_list[i].prach_zero_corr_conf.tl.tag = NFAPI_NR_CONFIG_PRACH_ZERO_CORR_CONF_TAG;
+    cfg->num_tlv++;
+    //cfg->prach_config.num_prach_fd_occasions_list[i].num_unused_root_sequences.value = ???
+  }
+
+  cfg->prach_config.ssb_per_rach.value = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present;
+  cfg->prach_config.ssb_per_rach.tl.tag = NFAPI_NR_CONFIG_SSB_PER_RACH_TAG;
+  cfg->num_tlv++;
+ 
+  // SSB Table Configuration
+  int scs_scaling = 1<<(cfg->ssb_config.scs_common.value);
+  if (scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA < 600000)
+    scs_scaling = scs_scaling*3;
+  if (scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA > 2016666)
+    scs_scaling = scs_scaling>>2;
+  uint32_t absolute_diff = (*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA);
+  uint16_t sco = absolute_diff%(12*scs_scaling);
+  AssertFatal(sco==0,"absoluteFrequencySSB has a subcarrier offset of %d while it should be alligned with CRBs\n",sco);
+  cfg->ssb_table.ssb_offset_point_a.value = absolute_diff/(12*scs_scaling) - 10; //absoluteFrequencySSB is the central frequency of SSB which is made by 20RBs in total
+  cfg->ssb_table.ssb_offset_point_a.tl.tag = NFAPI_NR_CONFIG_SSB_OFFSET_POINT_A_TAG;
+  cfg->num_tlv++;
+  cfg->ssb_table.ssb_period.value = *scc->ssb_periodicityServingCell;
+  cfg->ssb_table.ssb_period.tl.tag = NFAPI_NR_CONFIG_SSB_PERIOD_TAG;
+  cfg->num_tlv++;
+
+  switch (scc->ssb_PositionsInBurst->present) {
+    case 1 :
+      cfg->ssb_table.ssb_mask_list[0].ssb_mask.value = scc->ssb_PositionsInBurst->choice.shortBitmap.buf[0]<<24;
+      cfg->ssb_table.ssb_mask_list[1].ssb_mask.value = 0;
       break;
-    case 5:
-      ssb_periodicity = 160;
+    case 2 :
+      cfg->ssb_table.ssb_mask_list[0].ssb_mask.value = scc->ssb_PositionsInBurst->choice.mediumBitmap.buf[0]<<24;
+      cfg->ssb_table.ssb_mask_list[1].ssb_mask.value = 0;
       break;
-  }      
-
-  if( mib != NULL ){
-    config_nr_mib(Mod_idP, 
-               CC_idP,
-               p_gNB, 
-               mib->message.choice.mib->subCarrierSpacingCommon,
-               mib->message.choice.mib->ssb_SubcarrierOffset,
-               mib->message.choice.mib->dmrs_TypeA_Position,
-               mib->message.choice.mib->pdcch_ConfigSIB1.controlResourceSetZero * 16 + mib->message.choice.mib->pdcch_ConfigSIB1.searchSpaceZero,
-               mib->message.choice.mib->cellBarred,
-               mib->message.choice.mib->intraFreqReselection
-               );
-  }// END if( mib != NULL )
-
-
-  if( servingcellconfigcommon != NULL ){
-    config_common(Mod_idP, 
-                  CC_idP,
-				  cellid,
-                  nr_bandP,
-				  ssb_pattern,
-                  ssb_periodicity,
-                  dl_CarrierFreqP,
-                  dl_BandwidthP
-                  );  
-  }//END if( servingcellconfigcommon != NULL )
-
-  LOG_E(MAC, "%s() %s:%d RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req);
-
-  // if in nFAPI mode 
-  if ( (nfapi_mode == 1 || nfapi_mode == 2) && (RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req == NULL) ){
-    while(RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req == NULL) {
-      // DJP AssertFatal(RC.nrmac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n");
-      usleep(100 * 1000);
-      printf("Waiting for PHY_config_req\n");
-    }
+    case 3 :
+      cfg->ssb_table.ssb_mask_list[0].ssb_mask.value = 0;
+      cfg->ssb_table.ssb_mask_list[1].ssb_mask.value = 0;
+      for (i=0; i<4; i++) {
+        cfg->ssb_table.ssb_mask_list[0].ssb_mask.value += (scc->ssb_PositionsInBurst->choice.longBitmap.buf[i+4]<<i*8);
+        cfg->ssb_table.ssb_mask_list[1].ssb_mask.value += (scc->ssb_PositionsInBurst->choice.longBitmap.buf[i]<<i*8);
+      }
+      break;
+    default:
+      AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", scc->ssb_PositionsInBurst->present);
+  }
+
+  cfg->ssb_table.ssb_mask_list[0].ssb_mask.tl.tag = NFAPI_NR_CONFIG_SSB_MASK_TAG;
+  cfg->num_tlv++;
+
+  cfg->carrier_config.num_tx_ant.value = pdsch_AntennaPorts;
+  AssertFatal(pdsch_AntennaPorts > 0 && pdsch_AntennaPorts < 13, "pdsch_AntennaPorts in 1...12\n");
+  cfg->carrier_config.num_tx_ant.tl.tag = NFAPI_NR_CONFIG_NUM_TX_ANT_TAG;
+  int num_ssb=0;
+  for (int i=0;i<32;i++) {
+    num_ssb += (cfg->ssb_table.ssb_mask_list[0].ssb_mask.value>>i)&1;
+    num_ssb += (cfg->ssb_table.ssb_mask_list[1].ssb_mask.value>>i)&1;
+  } 
+
+  cfg->carrier_config.num_rx_ant.value = cfg->carrier_config.num_tx_ant.value;
+  cfg->carrier_config.num_rx_ant.tl.tag = NFAPI_NR_CONFIG_NUM_RX_ANT_TAG;
+  LOG_I(MAC,"Set TX/RX antenna number to %d (num ssb %d: %x,%x)\n",cfg->carrier_config.num_tx_ant.value,num_ssb,cfg->ssb_table.ssb_mask_list[0].ssb_mask.value,cfg->ssb_table.ssb_mask_list[1].ssb_mask.value);
+  AssertFatal(cfg->carrier_config.num_tx_ant.value > 0,"carrier_config.num_tx_ant.value %d !\n",cfg->carrier_config.num_tx_ant.value );
+  cfg->num_tlv++;
+  cfg->num_tlv++;
+
+  // TDD Table Configuration
+  //cfg->tdd_table.tdd_period.value = scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity;
+  cfg->tdd_table.tdd_period.tl.tag = NFAPI_NR_CONFIG_TDD_PERIOD_TAG;
+  cfg->num_tlv++;
+  if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1 == NULL)
+    cfg->tdd_table.tdd_period.value = scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity;
+  else {
+    AssertFatal(scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530 != NULL,
+		"scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530 is null\n");
+    cfg->tdd_table.tdd_period.value = *scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530;
+  }
+  LOG_I(MAC,"Setting TDD configuration period to %d\n",cfg->tdd_table.tdd_period.value);
+  if(cfg->cell_config.frame_duplex_type.value == TDD){
+    int return_tdd = set_tdd_config_nr(cfg,
+		    scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing,
+                    scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots,
+                    scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols,
+                    scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots,
+                    scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols
+                  );
+
+  if (return_tdd !=0){
+     LOG_E(PHY,"TDD configuration can not be done\n");
   }
+  else LOG_I(PHY,"TDD has been properly configurated\n");
+  }
+
+
+/*
+  // PDCCH-ConfigCommon
+  cfg->pdcch_config.controlResourceSetZero.value = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero;
+  cfg->pdcch_config.searchSpaceZero.value = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero;
+
+  // PDSCH-ConfigCommon
+  cfg->pdsch_config.num_PDSCHTimeDomainResourceAllocations.value = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count;
+  cfg->pdsch_config.dmrs_TypeA_Position.value = scc->dmrs_TypeA_Position;
+  AssertFatal(cfg->pdsch_config.num_PDSCHTimeDomainResourceAllocations.value<=NFAPI_NR_PDSCH_CONFIG_MAXALLOCATIONS,"illegal TimeDomainAllocation count %d\n",cfg->pdsch_config.num_PDSCHTimeDomainResourceAllocations.value);
+  for (int i=0;i<cfg->pdsch_config.num_PDSCHTimeDomainResourceAllocations.value;i++) {
+    cfg->pdsch_config.PDSCHTimeDomainResourceAllocation_k0[i].value=*scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0;
+    cfg->pdsch_config.PDSCHTimeDomainResourceAllocation_mappingType[i].value=scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->mappingType;
+    cfg->pdsch_config.PDSCHTimeDomainResourceAllocation_startSymbolAndLength[i].value=scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength;
+  }
+
+  // PUSCH-ConfigCommon
+  cfg->pusch_config.num_PUSCHTimeDomainResourceAllocations.value = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.count;
+  cfg->pusch_config.dmrs_TypeA_Position.value = scc->dmrs_TypeA_Position+2;
+  AssertFatal(cfg->pusch_config.num_PUSCHTimeDomainResourceAllocations.value<=NFAPI_NR_PUSCH_CONFIG_MAXALLOCATIONS,"illegal TimeDomainAllocation count %d\n",cfg->pusch_config.num_PUSCHTimeDomainResourceAllocations.value);
+  for (int i=0;i<cfg->pusch_config.num_PUSCHTimeDomainResourceAllocations.value;i++) {
+    cfg->pusch_config.PUSCHTimeDomainResourceAllocation_k2[i].value=*scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[0]->k2;
+  }*/
+
 
-  if (servingcellconfigcommon != NULL){
+}
+
+
+int rrc_mac_config_req_gNB(module_id_t Mod_idP, 
+			   int ssb_SubcarrierOffset,
+                           int pdsch_AntennaPorts,
+                           NR_ServingCellConfigCommon_t *scc,
+			   int add_ue,
+			   uint32_t rnti,
+			   NR_CellGroupConfig_t *secondaryCellGroup
+                           ){
+
+  if (scc != NULL ) {
+    AssertFatal((scc->ssb_PositionsInBurst->present > 0) && (scc->ssb_PositionsInBurst->present < 4), "SSB Bitmap type %d is not valid\n",scc->ssb_PositionsInBurst->present);
+
+    LOG_I(MAC,"Configuring common parameters from NR ServingCellConfig\n");
+
+    config_common(Mod_idP,
+                  pdsch_AntennaPorts, 
+		  scc);
+    LOG_E(MAC, "%s() %s:%d RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req);
+  
+    // if in nFAPI mode 
+    if ( (nfapi_mode == 1 || nfapi_mode == 2) && (RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req == NULL) ){
+      while(RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req == NULL) {
+	// DJP AssertFatal(RC.nrmac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n");
+	usleep(100 * 1000);
+	printf("Waiting for PHY_config_req\n");
+      }
+    }
+  
+  
     NR_PHY_Config_t phycfg;
     phycfg.Mod_id = Mod_idP;
-    phycfg.CC_id  = CC_idP;
-    phycfg.cfg    = &RC.nrmac[Mod_idP]->config[CC_idP];
-      
+    phycfg.CC_id  = 0;
+    phycfg.cfg    = &RC.nrmac[Mod_idP]->config[0];
+
+    phycfg.cfg->ssb_table.ssb_subcarrier_offset.value = ssb_SubcarrierOffset;
+    phycfg.cfg->ssb_table.ssb_subcarrier_offset.tl.tag = NFAPI_NR_CONFIG_SSB_SUBCARRIER_OFFSET_TAG;
+    phycfg.cfg->num_tlv++;
+
     if (RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req) RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req(&phycfg); 
-      
-    VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT);
   }
+  
+  if (secondaryCellGroup) {
+
+    NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list;
+    int UE_id;
+    if (add_ue == 1) {
+      UE_id = add_new_nr_ue(Mod_idP,rnti);
+      UE_list->secondaryCellGroup[UE_id] = secondaryCellGroup;
+      LOG_I(PHY,"Added new UE_id %d/%x with initial secondaryCellGroup\n",UE_id,rnti);
+    }
+    else { // secondaryCellGroup has been updated
+      UE_id = find_nr_UE_id(Mod_idP,rnti);
+      UE_list->secondaryCellGroup[UE_id] = secondaryCellGroup;
+      LOG_I(PHY,"Modified UE_id %d/%x with secondaryCellGroup\n",UE_id,rnti);
+    }
+  }
+  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT);
+  
     
   return(0);
 
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
index d08b8211ee2..e5840d9cd19 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
@@ -57,11 +57,7 @@
 
 #include "intertask_interface.h"
 
-#include "assertions.h"
-#include <openair1/PHY/LTE_TRANSPORT/transport_proto.h>
-
-#define ENABLE_MAC_PAYLOAD_DEBUG
-#define DEBUG_eNB_SCHEDULER 1
+#include "executables/softmodem-common.h"
 
 uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 };
 
@@ -70,30 +66,33 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB,
                                 frame_t frameP,
                                 sub_frame_t slotP){
 
-  nfapi_nr_dl_config_request_t    *DL_req = &gNB->DL_req[0];
-  nfapi_nr_ul_tti_request_t          *UL_tti_req = &gNB->UL_tti_req[0];
-  nfapi_hi_dci0_request_t   *     HI_DCI0_req = &gNB->HI_DCI0_req[0];
-  nfapi_tx_request_t              *TX_req = &gNB->TX_req[0];
+  nfapi_nr_dl_tti_request_t    *DL_req = &gNB->DL_req[0];
+  nfapi_nr_ul_tti_request_t    *UL_tti_req = &gNB->UL_tti_req[0];
+  nfapi_nr_ul_dci_request_t    *UL_dci_req = &gNB->UL_dci_req[0];
+  nfapi_nr_tx_data_request_t   *TX_req = &gNB->TX_req[0];
 
   gNB->pdu_index[CC_idP] = 0;
 
   if (nfapi_mode==0 || nfapi_mode == 1) { // monolithic or PNF
 
-    DL_req[CC_idP].dl_config_request_body.number_dci                          = 0;
-    DL_req[CC_idP].dl_config_request_body.number_pdu                          = 0;
-    DL_req[CC_idP].dl_config_request_body.number_pdsch_rnti                   = 0;
-    //DL_req[CC_idP].dl_config_request_body.transmission_power_pcfich           = 6000;
-
-    HI_DCI0_req[CC_idP].hi_dci0_request_body.sfnsf                            = slotP + (frameP<<7);
-    HI_DCI0_req[CC_idP].hi_dci0_request_body.number_of_dci                    = 0;
+    DL_req[CC_idP].SFN                                   = frameP;
+    DL_req[CC_idP].Slot                                  = slotP;
+    DL_req[CC_idP].dl_tti_request_body.nPDUs             = 0;
+    DL_req[CC_idP].dl_tti_request_body.nGroup            = 0;
+    //DL_req[CC_idP].dl_tti_request_body.transmission_power_pcfich           = 6000;
 
+    UL_dci_req[CC_idP].SFN                         = frameP;
+    UL_dci_req[CC_idP].Slot                        = slotP;
+    UL_dci_req[CC_idP].numPdus                     = 0;
 
+    UL_tti_req[CC_idP].SFN                         = frameP;
+    UL_tti_req[CC_idP].Slot                        = slotP;
     UL_tti_req[CC_idP].n_pdus                      = 0;
     UL_tti_req[CC_idP].n_ulsch                     = 0;
     UL_tti_req[CC_idP].n_ulcch                     = 0;
     UL_tti_req[CC_idP].n_group                     = 0;
 
-    TX_req[CC_idP].tx_request_body.number_of_pdus                 = 0;
+    TX_req[CC_idP].Number_of_PDUs                  = 0;
 
   }
 }
@@ -105,7 +104,7 @@ void check_nr_ul_failure(module_id_t module_idP,
                          sub_frame_t slotP) {
 
   UE_list_t                     *UE_list  = &RC.nrmac[module_idP]->UE_list;
-  nfapi_nr_dl_config_request_t  *DL_req   = &RC.nrmac[module_idP]->DL_req[0];
+  nfapi_nr_dl_dci_request_t  *DL_req   = &RC.nrmac[module_idP]->DL_req[0];
   uint16_t                      rnti      = UE_RNTI(module_idP, UE_id);
   NR_COMMON_channels_t          *cc       = RC.nrmac[module_idP]->common_channels;
 
@@ -118,11 +117,11 @@ void check_nr_ul_failure(module_id_t module_idP,
       UE_list->UE_sched_ctrl[UE_id].ra_pdcch_order_sent = 1;
 
       // add a format 1A dci for this UE to request an RA procedure (only one UE per subframe)
-      nfapi_nr_dl_config_request_pdu_t *dl_config_pdu                    = &DL_req[CC_id].dl_config_request_body.dl_config_pdu_list[DL_req[CC_id].dl_config_request_body.number_pdu];
-      memset((void *) dl_config_pdu, 0,sizeof(nfapi_dl_config_request_pdu_t));
+      nfapi_nr_dl_dci_request_pdu_t *dl_config_pdu                    = &DL_req[CC_id].dl_tti_request_body.dl_config_pdu_list[DL_req[CC_id].dl_tti_request_body.number_pdu];
+      memset((void *) dl_config_pdu, 0,sizeof(nfapi_dl_dci_request_pdu_t));
       dl_config_pdu->pdu_type                                         = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE;
       dl_config_pdu->pdu_size                                         = (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu));
-      dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag                = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG;
+      dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag                = NFAPI_DL_DCI_REQUEST_DCI_DL_PDU_REL8_TAG;
       dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format            = NFAPI_DL_DCI_FORMAT_1A;
       dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level     = get_aggregation(get_bw_index(module_idP, CC_id),
                       UE_list->UE_sched_ctrl[UE_id].
@@ -135,9 +134,9 @@ void check_nr_ul_failure(module_id_t module_idP,
       "illegal dl_Bandwidth %d\n",
       (int) cc[CC_id].mib->message.dl_Bandwidth);
       dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = nr_pdcch_order_table[cc[CC_id].mib->message.dl_Bandwidth];
-      DL_req[CC_id].dl_config_request_body.number_dci++;
-      DL_req[CC_id].dl_config_request_body.number_pdu++;
-      DL_req[CC_id].dl_config_request_body.tl.tag                      = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
+      DL_req[CC_id].dl_tti_request_body.number_dci++;
+      DL_req[CC_id].dl_tti_request_body.number_pdu++;
+      DL_req[CC_id].dl_tti_request_body.tl.tag                      = NFAPI_DL_TTI_REQUEST_BODY_TAG;
       LOG_I(MAC,
       "UE %d rnti %x: sending PDCCH order for RAPROC (failure timer %d), resource_block_coding %d \n",
       UE_id, rnti,
@@ -258,6 +257,19 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram
 }
 */
 
+/*
+void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) {
+
+  gNB_MAC_INST *gNB = RC.nrmac[module_idP];
+
+  // schedule PRACH for iniital BWP 
+
+  if (is_initialBWP_prach_subframe(frameP,subframeP)<0) return;
+ 
+  // fill FAPI
+}
+*/
+
 /*
 void copy_nr_ulreq(module_id_t module_idP, frame_t frameP, sub_frame_t slotP)
 {
@@ -266,9 +278,7 @@ void copy_nr_ulreq(module_id_t module_idP, frame_t frameP, sub_frame_t slotP)
 
   for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
 
-    nfapi_ul_config_request_t *ul_req_tmp             = &mac->UL_req_tmp[CC_id][slotP];
-    nfapi_ul_config_request_t *ul_req                 = &mac->UL_req[CC_id];
-    nfapi_ul_config_request_pdu_t *ul_req_pdu         = ul_req->ul_config_request_body.ul_config_pdu_list;
+    nfapi_ul_config_request_t *ul_req                 = &mac->UL_tti_req[CC_id];
 
     *ul_req = *ul_req_tmp;
 
@@ -294,23 +304,30 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
                                sub_frame_t slot_rxP,
                                frame_t frame_txP,
                                sub_frame_t slot_txP){
+
+  //printf("gNB_dlsch_ulsch_scheduler frameRX %d slotRX %d frameTX %d slotTX %d\n",frame_rxP,slot_rxP,frame_txP,slot_txP);
 			       
   protocol_ctxt_t   ctxt;
-
-  int CC_id, i = -1, UE_id = 0;
+  PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frame_txP, slot_txP,module_idP);
+  int CC_id, UE_id = 0;
   gNB_MAC_INST *gNB = RC.nrmac[module_idP];
-  UE_list_t *UE_list = &gNB->UE_list;
-  rnti_t rnti;
+  NR_UE_list_t *UE_list = &gNB->UE_list;
   UE_sched_ctrl_t *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
   NR_COMMON_channels_t *cc = gNB->common_channels;
 
   start_meas(&RC.nrmac[module_idP]->eNB_scheduler);
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN);
 
+  pdcp_run(&ctxt);
+  //rrc_rx_tx(&ctxt, CC_id);
+
   RC.nrmac[module_idP]->frame    = frame_rxP;
   RC.nrmac[module_idP]->slot     = slot_rxP;
 
+  // Check if there are downlink symbols in the slot, 
+  if (is_nr_DL_slot(cc->ServingCellConfigCommon,slot_txP)) {
 
+  memset(RC.nrmac[module_idP]->cce_list[1][0],0,MAX_NUM_CCE*sizeof(int));
   for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
     //mbsfn_status[CC_id] = 0;
 
@@ -322,55 +339,26 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
   }
 
   // refresh UE list based on UEs dropped by PHY in previous subframe
+  /*
   for (i = 0; i < MAX_MOBILES_PER_GNB; i++) {
-    if (0 /*UE_list->active[i]*/) {
+    if (UE_list->active[i]) {
 
       nfapi_nr_config_request_t *cfg = &RC.nrmac[module_idP]->config[CC_id];
-
-      nfapi_nr_coreset_t coreset = RC.nrmac[module_idP]->coreset[CC_id][1];
-      nfapi_nr_search_space_t search_space = RC.nrmac[module_idP]->search_space[CC_id][1];
-
-      if (nr_is_dci_opportunity(search_space,
-                                    coreset,
-                                    frame_txP,
-                                    slot_txP,
-                                    *cfg)){
-          nr_schedule_uss_dlsch_phytest(module_idP, frame_txP, slot_txP, NULL);
-          }
-
-      rnti = UE_RNTI(module_idP, i);
-      CC_id = UE_PCCID(module_idP, i);
-      //int spf = get_spf(cfg);
-  
-      if (((frame_txP&127) == 0) && (slot_txP == 0)) {
-        LOG_I(MAC,
-        "UE  rnti %x : %s, PHR %d dB DL CQI %d PUSCH SNR %d PUCCH SNR %d\n",
-        rnti,
-        UE_list->UE_sched_ctrl[i].ul_out_of_sync ==
-        0 ? "in synch" : "out of sync",
-        UE_list->UE_template[CC_id][i].phr_info,
-        UE_list->UE_sched_ctrl[i].dl_cqi[CC_id],
-        (UE_list->UE_sched_ctrl[i].pusch_snr[CC_id] - 128) / 2,
-        (UE_list->UE_sched_ctrl[i].pucch1_snr[CC_id] - 128) / 2);
-      }
+      
+      
+      rnti = 0;//UE_RNTI(module_idP, i);
+      CC_id = 0;//UE_PCCID(module_idP, i);
       
     } //END if (UE_list->active[i])
   } //END for (i = 0; i < MAX_MOBILES_PER_GNB; i++)
+  */
   
-  PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES,NOT_A_RNTI, frame_txP, slot_txP,module_idP);
-  
-  pdcp_run(&ctxt);
-
-  //rrc_rx_tx(&ctxt, CC_id);
-
   // This schedules MIB
   if((slot_txP == 0) && (frame_txP & 7) == 0){
     schedule_nr_mib(module_idP, frame_txP, slot_txP);
   }
 
-  // Phytest scheduling
- 
-  // TODO once RACH is available, start ta_timer when UE is connected
+  // TbD once RACH is available, start ta_timer when UE is connected
   if (ue_sched_ctl->ta_timer) ue_sched_ctl->ta_timer--;
 
   if (ue_sched_ctl->ta_timer == 0) {
@@ -384,11 +372,8 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
     gNB->ta_len = 2;
   }
 
-  if (slot_rxP == NR_UPLINK_SLOT){
-    nr_schedule_uss_ulsch_phytest(&RC.nrmac[module_idP]->UL_tti_req[0], frame_rxP, slot_rxP);
-  }
-  
-  if (slot_txP == NR_DOWNLINK_SLOT){
+  // Phytest scheduling
+  if (get_softmodem_params()->phy_test && slot_txP==1){
     nr_schedule_uss_dlsch_phytest(module_idP, frame_txP, slot_txP,NULL);
     // resetting ta flag
     gNB->ta_len = 0;
@@ -400,6 +385,14 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
     allocate_CCEs(module_idP, CC_id, subframeP, 0);
   */
 
+  } //is_nr_DL_slot
+
+  if (is_nr_UL_slot(cc->ServingCellConfigCommon,slot_rxP)) { 
+    if (get_softmodem_params()->phy_test && slot_rxP==8){
+      nr_schedule_uss_ulsch_phytest(module_idP, frame_rxP, slot_rxP);
+    }
+  }
+
   stop_meas(&RC.nrmac[module_idP]->eNB_scheduler);
   
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT);
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c
index 409ba1d6d2e..2a36425faef 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c
@@ -60,23 +60,20 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){
   gNB_MAC_INST *gNB = RC.nrmac[module_idP];
   NR_COMMON_channels_t *cc;
   
-  nfapi_nr_dl_config_request_t      *dl_config_request;
-  nfapi_nr_dl_config_request_body_t *dl_req;
-  nfapi_nr_dl_config_request_pdu_t  *dl_config_pdu;
-  nfapi_tx_request_pdu_t            *TX_req;
+  nfapi_nr_dl_tti_request_t      *dl_tti_request;
+  nfapi_nr_dl_tti_request_body_t *dl_req;
+  nfapi_nr_dl_tti_request_pdu_t  *dl_config_pdu;
 
   int mib_sdu_length;
   int CC_id;
 
-  uint16_t sfn_sf = frameP << 7 | slotP;
-
   AssertFatal(slotP == 0, "Subframe must be 0\n");
   AssertFatal((frameP & 7) == 0, "Frame must be a multiple of 8\n");
 
   for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
 
-    dl_config_request = &gNB->DL_req[CC_id];
-    dl_req = &dl_config_request->dl_config_request_body;
+    dl_tti_request = &gNB->DL_req[CC_id];
+    dl_req = &dl_tti_request->dl_tti_request_body;
     cc = &gNB->common_channels[CC_id];
 
     mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 1, &cc->MIB_pdu.payload[0]); // not used in this case
@@ -85,38 +82,61 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP){
 
     if (mib_sdu_length > 0) {
 
-      LOG_D(MAC, "Frame %d, slot %d: Adding BCH PDU in position %d (length %d)\n", frameP, slotP, dl_req->number_pdu, mib_sdu_length);
+      LOG_I(MAC, "Frame %d, slot %d: Adding BCH PDU in position %d (length %d)\n", frameP, slotP, dl_req->nPDUs, mib_sdu_length);
 
       if ((frameP & 1023) < 80){
-        LOG_D(MAC,"[gNB %d] Frame %d : MIB->BCH  CC_id %d, Received %d bytes\n",module_idP, frameP, CC_id, mib_sdu_length);
+        LOG_I(MAC,"[gNB %d] Frame %d : MIB->BCH  CC_id %d, Received %d bytes\n",module_idP, frameP, CC_id, mib_sdu_length);
       }
 
-      dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
-      memset((void *) dl_config_pdu, 0,sizeof(nfapi_nr_dl_config_request_pdu_t));
-      dl_config_pdu->pdu_type      = NFAPI_NR_DL_CONFIG_BCH_PDU_TYPE;
-      dl_config_pdu->pdu_size      =2 + sizeof(nfapi_nr_dl_config_bch_pdu_rel15_t);
-      dl_config_pdu->bch_pdu_rel15.tl.tag             = NFAPI_NR_DL_CONFIG_REQUEST_BCH_PDU_REL15_TAG;
-      dl_config_pdu->bch_pdu_rel15.length             = mib_sdu_length;
-      dl_config_pdu->bch_pdu_rel15.pdu_index          = gNB->pdu_index[CC_id];
-      dl_config_pdu->bch_pdu_rel15.transmission_power = 6000;
-      dl_req->tl.tag                            = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
-      dl_req->number_pdu++;
-      dl_config_request->header.message_id = NFAPI_DL_CONFIG_REQUEST;
-      dl_config_request->sfn_sf = sfn_sf;
-
-      LOG_D(MAC, "gNB->DL_req[0].number_pdu %d (%p)\n", dl_req->number_pdu, &dl_req->number_pdu);
-      // DL request
-
-      TX_req = &gNB->TX_req[CC_id].tx_request_body.tx_pdu_list[gNB->TX_req[CC_id].tx_request_body.number_of_pdus];
-      TX_req->pdu_length = 3;
-      TX_req->pdu_index = gNB->pdu_index[CC_id]++;
-      TX_req->num_segments = 1;
-      TX_req->segments[0].segment_length = 3;
-      TX_req->segments[0].segment_data = cc[CC_id].MIB_pdu.payload;
-      gNB->TX_req[CC_id].tx_request_body.number_of_pdus++;
-      gNB->TX_req[CC_id].sfn_sf = sfn_sf;
-      gNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG;
-      gNB->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST;
+      dl_config_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs];
+      memset((void *) dl_config_pdu, 0,sizeof(nfapi_nr_dl_tti_request_pdu_t));
+      dl_config_pdu->PDUType      = NFAPI_NR_DL_TTI_SSB_PDU_TYPE;
+      dl_config_pdu->PDUSize      =2 + sizeof(nfapi_nr_dl_tti_ssb_pdu_rel15_t);
+
+      AssertFatal(cc->ServingCellConfigCommon->physCellId!=NULL,"cc->ServingCellConfigCommon->physCellId is null\n");
+      dl_config_pdu->ssb_pdu.ssb_pdu_rel15.PhysCellId          = *cc->ServingCellConfigCommon->physCellId;
+      dl_config_pdu->ssb_pdu.ssb_pdu_rel15.BetaPss             = 0;
+      dl_config_pdu->ssb_pdu.ssb_pdu_rel15.SsbBlockIndex       = 0;
+      AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon!=NULL,"scc->downlinkConfigCommonL is null\n");
+      AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL!=NULL,"scc->downlinkConfigCommon->frequencyInfoDL is null\n");
+      AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB!=NULL,"scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB is null\n");
+      AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.count==1,"Frequency Band list does not have 1 element (%d)\n",cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.count);
+      AssertFatal(cc->ServingCellConfigCommon->ssbSubcarrierSpacing,"ssbSubcarrierSpacing is null\n");
+      AssertFatal(cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0],"band is null\n");
+      long band = *cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0];
+      uint32_t ssb_offset0 = *cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - cc->ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA;
+      int ratio;
+      switch (*cc->ServingCellConfigCommon->ssbSubcarrierSpacing) {
+      case NR_SubcarrierSpacing_kHz15:
+	AssertFatal(band <= 79, "Band %ld is not possible for SSB with 15 kHz SCS\n",band);
+	if (band<77) // below 3GHz
+	  ratio=3; // NRARFCN step is 5 kHz
+	else
+	  ratio=1; // NRARFCN step is 15 kHz
+	break;
+      case NR_SubcarrierSpacing_kHz30:
+	AssertFatal(band <= 79, "Band %ld is not possible for SSB with 15 kHz SCS\n",band);
+	if (band<77) // below 3GHz
+	  ratio=6; // NRARFCN step is 5 kHz
+	else
+	  ratio=2; // NRARFCN step is 15 kHz
+	break;
+      case NR_SubcarrierSpacing_kHz120:
+	AssertFatal(band >= 257, "Band %ld is not possible for SSB with 120 kHz SCS\n",band);
+	ratio=2; // NRARFCN step is 15 kHz
+	break;
+      case NR_SubcarrierSpacing_kHz240:
+	AssertFatal(band >= 257, "Band %ld is not possible for SSB with 240 kHz SCS\n",band);
+	ratio=4; // NRARFCN step is 15 kHz
+	break;
+      default:
+        AssertFatal(1==0,"SCS %ld not allowed for SSB \n", *cc->ServingCellConfigCommon->ssbSubcarrierSpacing);
+      }
+      dl_config_pdu->ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset = 0; //kSSB
+      dl_config_pdu->ssb_pdu.ssb_pdu_rel15.ssbOffsetPointA     = ssb_offset0/(ratio*12) - 10; // absoluteFrequencySSB is the center of SSB
+      dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayloadFlag      = 1;
+      dl_config_pdu->ssb_pdu.ssb_pdu_rel15.bchPayload          = (*(uint32_t*)cc->MIB_pdu.payload) & ((1<<24)-1);
+      dl_req->nPDUs++;
     }
   }
 }
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
index 03795a8c092..1e0fd8d9a22 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
@@ -31,15 +31,32 @@
 #include "nr_mac_gNB.h"
 #include "SCHED_NR/sched_nr.h"
 #include "mac_proto.h"
+#include "nr_mac_common.h"
 #include "PHY/NR_TRANSPORT/nr_dlsch.h"
 #include "PHY/NR_TRANSPORT/nr_dci.h"
 #include "executables/nr-softmodem.h"
 #include "LAYER2/NR_MAC_COMMON/nr_mac.h"
 #include "executables/softmodem-common.h"
+#include "common/utils/nr/nr_common.h"
+#include "NR_SCS-SpecificCarrier.h"
+#include "NR_TDD-UL-DL-ConfigCommon.h"
+#include "NR_FrequencyInfoUL.h"
+#include "NR_RACH-ConfigGeneric.h"
+#include "NR_RACH-ConfigCommon.h"
+#include "NR_PUSCH-TimeDomainResourceAllocation.h"
+#include "NR_PUSCH-ConfigCommon.h"
+#include "NR_PUCCH-ConfigCommon.h"
+#include "NR_PDSCH-TimeDomainResourceAllocation.h"
+#include "NR_PDSCH-ConfigCommon.h"
+#include "NR_RateMatchPattern.h"
+#include "NR_RateMatchPatternLTE-CRS.h"
+#include "NR_SearchSpace.h"
+#include "NR_ControlResourceSet.h"
+
 extern RAN_CONTEXT_t RC;
 //#define ENABLE_MAC_PAYLOAD_DEBUG 1
 
-uint8_t mac_pdu[MAX_NR_DLSCH_PAYLOAD_BYTES];
+//uint8_t mac_pdu[MAX_NR_DLSCH_PAYLOAD_BYTES];
 
 /*Scheduling of DLSCH with associated DCI in common search space
  * current version has only a DCI for type 1 PDCCH for C_RNTI*/
@@ -47,488 +64,776 @@ void nr_schedule_css_dlsch_phytest(module_id_t   module_idP,
                                    frame_t       frameP,
                                    sub_frame_t   slotP) {
   uint8_t  CC_id;
-  gNB_MAC_INST                        *nr_mac      = RC.nrmac[module_idP];
-  NR_COMMON_channels_t                *cc          = nr_mac->common_channels;
-  nfapi_nr_dl_config_request_body_t   *dl_req;
-  nfapi_nr_dl_config_request_pdu_t  *dl_config_dci_pdu;
-  nfapi_nr_dl_config_request_pdu_t  *dl_config_dlsch_pdu;
-  nfapi_tx_request_pdu_t            *TX_req;
-  nfapi_nr_config_request_t *cfg = &nr_mac->config[0];
+  gNB_MAC_INST                      *nr_mac      = RC.nrmac[module_idP];
+  NR_COMMON_channels_t              *cc = &nr_mac->common_channels[0];
+  nfapi_nr_dl_tti_request_body_t    *dl_req;
+  nfapi_nr_dl_tti_request_pdu_t     *dl_tti_pdcch_pdu;
+  nfapi_nr_dl_tti_request_pdu_t     *dl_tti_pdsch_pdu;
+  nfapi_nr_pdu_t        *TX_req;
+
   uint16_t rnti = 0x1234;
-  uint16_t sfn_sf = frameP << 7 | slotP;
-  int dl_carrier_bandwidth = cfg->rf_config.dl_carrier_bandwidth.value;
-  // everything here is hard-coded to 30 kHz
-  int scs = get_dlscs(cfg);
-  int slots_per_frame = get_spf(cfg);
+  
+  //  int time_domain_assignment,k0;
+
+  NR_ServingCellConfigCommon_t *scc=cc->ServingCellConfigCommon;
+
+  int dlBWP_carrier_bandwidth = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,275);
+
+  
+  /*
+  int scs               = scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing;
+  
+  int slots_per_frame   = 10*(1<<scs);
+
+  int FR                = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0] >= 257 ? nr_FR2 : nr_FR1;
+  */
 
   for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    LOG_D(MAC, "Scheduling common search space DCI type 1 for CC_id %d\n",CC_id);
-    dl_req = &nr_mac->DL_req[CC_id].dl_config_request_body;
-    dl_config_dci_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
-    memset((void *)dl_config_dci_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t));
-    dl_config_dci_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE;
-    dl_config_dci_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dci_dl_pdu));
-    dl_config_dlsch_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu+1];
-    memset((void *)dl_config_dlsch_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t));
-    dl_config_dlsch_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DLSCH_PDU_TYPE;
-    dl_config_dlsch_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dlsch_pdu));
-    nfapi_nr_dl_config_dci_dl_pdu_rel15_t *dci_dl_pdu_rel15 = &dl_config_dci_pdu->dci_dl_pdu.dci_dl_pdu_rel15;
-    nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &dl_config_dci_pdu->dci_dl_pdu.pdcch_params_rel15;
-    nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu_rel15 = &dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15;
-    dlsch_pdu_rel15->start_prb = 0;
-    dlsch_pdu_rel15->n_prb = 50;
-    dlsch_pdu_rel15->start_symbol = 2;
-    dlsch_pdu_rel15->nb_symbols = 8;
-    dlsch_pdu_rel15->rnti = rnti;
-    dlsch_pdu_rel15->nb_layers =1;
-    dlsch_pdu_rel15->nb_codewords = 1;
-    dlsch_pdu_rel15->mcs_idx = 9;
-    dlsch_pdu_rel15->ndi = 1;
-    dlsch_pdu_rel15->redundancy_version = 0;
-    nr_configure_css_dci_initial(params_rel15,
-                                 scs, scs, nr_FR1, 0, 0, 0,
-                                 sfn_sf, slotP,
-                                 slots_per_frame,
-                                 dl_carrier_bandwidth);
-    params_rel15->first_slot = 0;
-    dci_dl_pdu_rel15->frequency_domain_assignment = get_RIV(dlsch_pdu_rel15->start_prb, dlsch_pdu_rel15->n_prb, cfg->rf_config.dl_carrier_bandwidth.value);
-    dci_dl_pdu_rel15->time_domain_assignment = 3; // row index used here instead of SLIV
-    dci_dl_pdu_rel15->vrb_to_prb_mapping = 1;
-    dci_dl_pdu_rel15->mcs = 9;
-    dci_dl_pdu_rel15->tb_scaling = 1;
-    dci_dl_pdu_rel15->ra_preamble_index = 25;
-    dci_dl_pdu_rel15->format_indicator = 1;
-    dci_dl_pdu_rel15->ndi = 1;
-    dci_dl_pdu_rel15->rv = 0;
-    dci_dl_pdu_rel15->harq_pid = 0;
-    dci_dl_pdu_rel15->dai = 2;
-    dci_dl_pdu_rel15->tpc = 2;
-    dci_dl_pdu_rel15->pucch_resource_indicator = 7;
-    dci_dl_pdu_rel15->pdsch_to_harq_feedback_timing_indicator = 7;
+    LOG_D(MAC, "Scheduling common search space DCI type 1 dlBWP BW.firstRB %d.%d\n",
+	  dlBWP_carrier_bandwidth,
+	  NRRIV2PRBOFFSET(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,275));
+    
+    
+    dl_req = &nr_mac->DL_req[CC_id].dl_tti_request_body;
+    dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs];
+    memset((void*)dl_tti_pdcch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t));
+    dl_tti_pdcch_pdu->PDUType = NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE;
+    dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu));
+    
+    dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs+1];
+    memset((void *)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t));
+    dl_tti_pdsch_pdu->PDUType = NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE;
+    dl_tti_pdsch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdsch_pdu));
+
+    
+    //    nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15;
+    nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15;
+    
+    pdsch_pdu_rel15->pduBitmap = 0;
+    pdsch_pdu_rel15->rnti = rnti;
+    pdsch_pdu_rel15->pduIndex = 0;
+
+    // BWP
+    pdsch_pdu_rel15->BWPSize  = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,275);
+    pdsch_pdu_rel15->BWPStart = NRRIV2PRBOFFSET(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,275);
+    pdsch_pdu_rel15->SubcarrierSpacing = scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing;
+    pdsch_pdu_rel15->CyclicPrefix = 0;
+    pdsch_pdu_rel15->NrOfCodewords = 1;
+    int mcsIndex = 9;
+    pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcsIndex,0);
+    pdsch_pdu_rel15->qamModOrder[0] = 2;
+    pdsch_pdu_rel15->mcsIndex[0] = mcsIndex;
+    pdsch_pdu_rel15->mcsTable[0] = 0;
+    pdsch_pdu_rel15->rvIndex[0] = 0;
+    pdsch_pdu_rel15->dataScramblingId = *scc->physCellId;
+    pdsch_pdu_rel15->nrOfLayers = 1;    
+    pdsch_pdu_rel15->transmissionScheme = 0;
+    pdsch_pdu_rel15->refPoint = 0; // Point A
+    
+    pdsch_pdu_rel15->dmrsConfigType = 0; // Type 1 by default for InitialBWP
+    pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId;
+    pdsch_pdu_rel15->SCID = 0;
+    pdsch_pdu_rel15->numDmrsCdmGrpsNoData = 1;
+    pdsch_pdu_rel15->dmrsPorts = 1;
+    pdsch_pdu_rel15->resourceAlloc = 1;
+    pdsch_pdu_rel15->rbStart = 0;
+    pdsch_pdu_rel15->rbSize = 6;
+    pdsch_pdu_rel15->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP
+    // choose shortest PDSCH
+    int startSymbolAndLength=0;
+    int StartSymbolIndex=-1,NrOfSymbols=14;
+    int StartSymbolIndex_tmp,NrOfSymbols_tmp;
+
+    for (int i=0;
+	 i<scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count;
+	 i++) {
+      startSymbolAndLength = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength;
+      SLIV2SL(startSymbolAndLength,&StartSymbolIndex_tmp,&NrOfSymbols_tmp);
+      if (NrOfSymbols_tmp < NrOfSymbols) {
+	NrOfSymbols = NrOfSymbols_tmp;
+        StartSymbolIndex = StartSymbolIndex_tmp;
+	//	k0 = *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0;
+	//	time_domain_assignment = i;
+      }
+    }
+    AssertFatal(StartSymbolIndex>=0,"StartSymbolIndex is negative\n");
+    pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex;
+    pdsch_pdu_rel15->NrOfSymbols      = NrOfSymbols;
+    pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(NULL,
+						    scc->dmrs_TypeA_Position,
+						    NrOfSymbols);
+
+    /*
+    AssertFatal(k0==0,"k0 is not zero for Initial DL BWP TimeDomain Alloc\n");
+    nr_configure_css_dci_initial(pdcch_pdu_rel15,
+				 scs, 
+				 scs, 
+				 FR, 
+				 0, 
+				 0, 
+				 0,
+				 sfn_sf, slotP,
+				 slots_per_frame,
+				 dlBWP_carrier_bandwidth);
+    
+    
+    pdu_rel15->frequency_domain_assignment = PRBalloc_to_locationandbandwidth0(pdsch_pdu_rel15->rbSize, 
+                                                                               pdsch_pdu_rel15->rbStart, 
+                                                                               dlBWP_carrier_bandwidth);
+    pdu_rel15->time_domain_assignment = time_domain_assignment;
+    
+    pdu_rel15->vrb_to_prb_mapping = 1;
+    pdu_rel15->mcs = 9;
+    pdu_rel15->tb_scaling = 1;
+    
+    pdu_rel15->ra_preamble_index = 25;
+    pdu_rel15->format_indicator = 1;
+    pdu_rel15->ndi = 1;
+    pdu_rel15->rv = 0;
+    pdu_rel15->harq_pid = 0;
+    pdu_rel15->dai = 2;
+    pdu_rel15->tpc = 2;
+    pdu_rel15->pucch_resource_indicator = 7;
+    pdu_rel15->pdsch_to_harq_feedback_timing_indicator = 7;
+    
     LOG_D(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n",
-          dci_dl_pdu_rel15->frequency_domain_assignment,
-          dci_dl_pdu_rel15->time_domain_assignment,
-          dci_dl_pdu_rel15->vrb_to_prb_mapping,
-          dci_dl_pdu_rel15->mcs,
-          dci_dl_pdu_rel15->tb_scaling,
-          dci_dl_pdu_rel15->ndi,
-          dci_dl_pdu_rel15->rv);
+	  pdu_rel15->frequency_domain_assignment,
+	  pdu_rel15->time_domain_assignment,
+	  pdu_rel15->vrb_to_prb_mapping,
+	  pdu_rel15->mcs,
+	  pdu_rel15->tb_scaling,
+	  pdu_rel15->ndi,
+	  pdu_rel15->rv);
+    
     params_rel15->rnti = rnti;
     params_rel15->rnti_type = NFAPI_NR_RNTI_C;
     params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0;
     //params_rel15->aggregation_level = 1;
-    LOG_D(MAC, "DCI type 1 params: rmsi_pdcch_config %d, rnti %d, rnti_type %d, dci_format %d\n \
+    LOG_D(MAC, "DCI type 1 params: rnti %x, rnti_type %d, dci_format %d\n \
                 coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d  \n \
                 ss params : nb_ss_sets_per_slot %d, first symb %d, nb_slots %d, sfn_mod2 %d, first slot %d\n",
-          0,
-          params_rel15->rnti,
-          params_rel15->rnti_type,
-          params_rel15->dci_format,
-          params_rel15->mux_pattern,
-          params_rel15->n_rb,
-          params_rel15->n_symb,
-          params_rel15->rb_offset,
-          params_rel15->nb_ss_sets_per_slot,
-          params_rel15->first_symbol,
-          params_rel15->nb_slots,
-          params_rel15->sfn_mod2,
-          params_rel15->first_slot);
-    nr_get_tbs_dl(&dl_config_dlsch_pdu->dlsch_pdu, dl_config_dci_pdu->dci_dl_pdu, *cfg);
+	  params_rel15->rnti,
+	  params_rel15->rnti_type,
+	  params_rel15->dci_format,
+	  params_rel15->mux_pattern,
+	  params_rel15->n_rb,
+	  params_rel15->n_symb,
+	  params_rel15->rb_offset,
+	  params_rel15->nb_ss_sets_per_slot,
+	  params_rel15->first_symbol,
+	  params_rel15->nb_slots,
+	  params_rel15->sfn_mod2,
+	  params_rel15->first_slot);
+    nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, dl_tti_dci_pdu->dci_dl_pdu,0);
     LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d\n",
-          dlsch_pdu_rel15->start_prb,
-          dlsch_pdu_rel15->n_prb,
-          dlsch_pdu_rel15->start_symbol,
-          dlsch_pdu_rel15->nb_symbols,
-          dlsch_pdu_rel15->nb_layers,
-          dlsch_pdu_rel15->nb_codewords,
-          dlsch_pdu_rel15->mcs_idx);
-    dl_req->number_dci++;
-    dl_req->number_pdsch_rnti++;
-    dl_req->number_pdu+=2;
-    TX_req = &nr_mac->TX_req[CC_id].tx_request_body.tx_pdu_list[nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus];
-    TX_req->pdu_length = 6;
-    TX_req->pdu_index = nr_mac->pdu_index[CC_id]++;
-    TX_req->num_segments = 1;
-    TX_req->segments[0].segment_length = 8;
-    TX_req->segments[0].segment_data   = &cc[CC_id].RAR_pdu.payload[0];
-    nr_mac->TX_req[CC_id].tx_request_body.number_of_pdus++;
-    nr_mac->TX_req[CC_id].sfn_sf = sfn_sf;
-    nr_mac->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG;
-    nr_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST;
+	  pdsch_pdu_rel15->rbStart,
+	  pdsch_pdu_rel15->rbSize,
+	  pdsch_pdu_rel15->StartSymbolIndex,
+	  pdsch_pdu_rel15->NrOfSymbols,
+	  pdsch_pdu_rel15->nrOfLayers,
+	  pdsch_pdu_rel15->NrOfCodewords,
+	  pdsch_pdu_rel15->mcsIndex[0]);
+    */
+    
+    dl_req->nPDUs+=2;
+    
+    TX_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs];
+    TX_req->PDU_length = 6;
+    TX_req->PDU_index = nr_mac->pdu_index[CC_id]++;
+    TX_req->num_TLV = 1;
+    TX_req->TLVs[0].length = 8;
+    memcpy((void*)&TX_req->TLVs[0].value.direct[0],(void*)&cc[CC_id].RAR_pdu.payload[0],TX_req->TLVs[0].length);
+    nr_mac->TX_req[CC_id].Number_of_PDUs++;
+    nr_mac->TX_req[CC_id].SFN=frameP;
+    nr_mac->TX_req[CC_id].Slot=slotP;
   }
 }
 
-int configure_fapi_dl_pdu(nfapi_nr_dl_config_request_body_t *dl_req,
-                          nfapi_nr_config_request_t *cfg,
-                          nfapi_nr_coreset_t *coreset,
-                          nfapi_nr_search_space_t *search_space,
-                          nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config){
-  nfapi_nr_dl_config_request_pdu_t  *dl_config_dci_pdu;
-  nfapi_nr_dl_config_request_pdu_t  *dl_config_dlsch_pdu;
-  uint16_t rnti = 0x1234;
-  int dl_carrier_bandwidth = cfg->rf_config.dl_carrier_bandwidth.value;
-  dl_config_dci_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
-  memset((void *)dl_config_dci_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t));
-  dl_config_dci_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DCI_DL_PDU_TYPE;
-  dl_config_dci_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dci_dl_pdu));
-  dl_config_dlsch_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu+1];
-  memset((void *)dl_config_dlsch_pdu,0,sizeof(nfapi_nr_dl_config_request_pdu_t));
-  dl_config_dlsch_pdu->pdu_type = NFAPI_NR_DL_CONFIG_DLSCH_PDU_TYPE;
-  dl_config_dlsch_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_nr_dl_config_dlsch_pdu));
-  nfapi_nr_dl_config_dci_dl_pdu_rel15_t *pdu_rel15 = &dl_config_dci_pdu->dci_dl_pdu.dci_dl_pdu_rel15;
-  nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &dl_config_dci_pdu->dci_dl_pdu.pdcch_params_rel15;
-  nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu_rel15 = &dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15;
-  dlsch_pdu_rel15->start_prb = 0;
-  dlsch_pdu_rel15->n_prb = 50;
-  dlsch_pdu_rel15->start_symbol = 2;
-  dlsch_pdu_rel15->nb_symbols = 9;
-  dlsch_pdu_rel15->rnti = rnti;
-  dlsch_pdu_rel15->nb_layers =1;
-  dlsch_pdu_rel15->nb_codewords = 1;
-  dlsch_pdu_rel15->mcs_idx = 9;
-  dlsch_pdu_rel15->ndi = 1;
-  dlsch_pdu_rel15->redundancy_version = 0;
-
-  if (dlsch_config != NULL) {
-    dlsch_pdu_rel15->start_prb = dlsch_config->start_prb;
-    dlsch_pdu_rel15->n_prb = dlsch_config->n_prb;
-    dlsch_pdu_rel15->start_symbol = dlsch_config->start_symbol;
-    dlsch_pdu_rel15->nb_symbols = dlsch_config->nb_symbols;
-    dlsch_pdu_rel15->mcs_idx = dlsch_config->mcs_idx;
-  }
+int configure_fapi_dl_pdu(int Mod_idP,
+                          int *CCEIndex,
+                          nfapi_nr_dl_tti_request_body_t *dl_req,
+                          uint8_t *mcsIndex,
+                          uint16_t *rbSize,
+                          uint16_t *rbStart) {
+
+
+  gNB_MAC_INST                        *nr_mac  = RC.nrmac[Mod_idP];
+  NR_COMMON_channels_t                *cc      = nr_mac->common_channels;
+  NR_ServingCellConfigCommon_t        *scc     = cc->ServingCellConfigCommon;
+  
+  nfapi_nr_dl_tti_request_pdu_t  *dl_tti_pdcch_pdu;
+  nfapi_nr_dl_tti_request_pdu_t  *dl_tti_pdsch_pdu;
+  int TBS, bwp_id = 1, UE_id = 0;
+  NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list;
+
+
+  NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
+  AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
+	      "downlinkBWP_ToAddModList has %d BWP!\n",
+	      secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
+  NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1];
+
+
+  dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs];
+  memset((void*)dl_tti_pdcch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t));
+  dl_tti_pdcch_pdu->PDUType = NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE;
+  dl_tti_pdcch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu));
+  
+  dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs+1];
+  memset((void*)dl_tti_pdsch_pdu,0,sizeof(nfapi_nr_dl_tti_request_pdu_t));
+  dl_tti_pdsch_pdu->PDUType = NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE;
+  dl_tti_pdsch_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdsch_pdu));
+
+  nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15;
+  nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15;
+
+
+  pdsch_pdu_rel15->pduBitmap = 0;
+  pdsch_pdu_rel15->rnti = UE_list->rnti[UE_id];
+  pdsch_pdu_rel15->pduIndex = 0;
+
+  // BWP
+  pdsch_pdu_rel15->BWPSize  = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275);
+  pdsch_pdu_rel15->BWPStart = NRRIV2PRBOFFSET(bwp->bwp_Common->genericParameters.locationAndBandwidth,275);
+  pdsch_pdu_rel15->SubcarrierSpacing = bwp->bwp_Common->genericParameters.subcarrierSpacing;
+  if (bwp->bwp_Common->genericParameters.cyclicPrefix) pdsch_pdu_rel15->CyclicPrefix = *bwp->bwp_Common->genericParameters.cyclicPrefix;
+  else pdsch_pdu_rel15->CyclicPrefix=0;
+
+  pdsch_pdu_rel15->NrOfCodewords = 1;
+  int mcs = (mcsIndex!=NULL) ? *mcsIndex : 9;
+  pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(mcs,0);
+  pdsch_pdu_rel15->qamModOrder[0] = 2;
+  pdsch_pdu_rel15->mcsIndex[0] = mcs;
+  pdsch_pdu_rel15->mcsTable[0] = 0;
+  pdsch_pdu_rel15->rvIndex[0] = 0;
+  pdsch_pdu_rel15->dataScramblingId = *scc->physCellId;
+  pdsch_pdu_rel15->nrOfLayers = 1;    
+  pdsch_pdu_rel15->transmissionScheme = 0;
+  pdsch_pdu_rel15->refPoint = 0; // Point A
+    
+  pdsch_pdu_rel15->dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1;  
+  pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId;
+  pdsch_pdu_rel15->SCID = 0;
+  pdsch_pdu_rel15->numDmrsCdmGrpsNoData = 1;
+  pdsch_pdu_rel15->dmrsPorts = 1;
+  pdsch_pdu_rel15->resourceAlloc = 1;
+  pdsch_pdu_rel15->rbStart = (rbStart!=NULL) ? *rbStart : 0;
+  pdsch_pdu_rel15->rbSize = (rbSize!=NULL) ? *rbSize : pdsch_pdu_rel15->BWPSize;
+  pdsch_pdu_rel15->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP
+    // choose shortest PDSCH
+  int startSymbolAndLength=0;
+  int time_domain_assignment=2;
+  int StartSymbolIndex,NrOfSymbols;
+
+  AssertFatal(time_domain_assignment<bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count,"time_domain_assignment %d>=%d\n",time_domain_assignment,bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count);
+  startSymbolAndLength = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength;
+  SLIV2SL(startSymbolAndLength,&StartSymbolIndex,&NrOfSymbols);
+  pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex;
+  pdsch_pdu_rel15->NrOfSymbols      = NrOfSymbols;
+ 
+  //  k0 = *bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0;
+  pdsch_pdu_rel15->dlDmrsSymbPos    = fill_dmrs_mask(bwp->bwp_Dedicated->pdsch_Config->choice.setup,
+						     scc->dmrs_TypeA_Position,
+						     pdsch_pdu_rel15->NrOfSymbols);
+
+  dci_pdu_rel15_t dci_pdu_rel15[MAX_DCI_CORESET];
+  
+  dci_pdu_rel15[0].frequency_domain_assignment = PRBalloc_to_locationandbandwidth0(pdsch_pdu_rel15->rbSize, 
+										   pdsch_pdu_rel15->rbStart, 
+										   NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275));
+  dci_pdu_rel15[0].time_domain_assignment = time_domain_assignment; // row index used here instead of SLIV;
+  dci_pdu_rel15[0].vrb_to_prb_mapping = 1;
+  dci_pdu_rel15[0].mcs = pdsch_pdu_rel15->mcsIndex[0];
+  dci_pdu_rel15[0].tb_scaling = 1;
+  
+  dci_pdu_rel15[0].ra_preamble_index = 25;
+  dci_pdu_rel15[0].format_indicator = 1;
+  dci_pdu_rel15[0].ndi = 1;
+  dci_pdu_rel15[0].rv = 0;
+  dci_pdu_rel15[0].harq_pid = 0;
+  dci_pdu_rel15[0].dai = 2;
+  dci_pdu_rel15[0].tpc = 2;
+  dci_pdu_rel15[0].pucch_resource_indicator = 7;
+  dci_pdu_rel15[0].pdsch_to_harq_feedback_timing_indicator = 7;
+  
+  LOG_D(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d (%d,%d,%d), time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n",
+	dci_pdu_rel15[0].frequency_domain_assignment,
+	pdsch_pdu_rel15->rbStart, 
+	pdsch_pdu_rel15->rbSize,	
+	NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275),
+	dci_pdu_rel15[0].time_domain_assignment,
+	dci_pdu_rel15[0].vrb_to_prb_mapping,
+	dci_pdu_rel15[0].mcs,
+	dci_pdu_rel15[0].tb_scaling,
+	dci_pdu_rel15[0].ndi, 
+	dci_pdu_rel15[0].rv);
+    
+  nr_configure_pdcch(pdcch_pdu_rel15,
+		     1, // ue-specific
+		     scc,
+		     bwp);
+  
+  pdcch_pdu_rel15->numDlDci = 1;
+  pdcch_pdu_rel15->AggregationLevel[0] = 4;  
+  pdcch_pdu_rel15->RNTI[0]=UE_list->rnti[0];
+  pdcch_pdu_rel15->CceIndex[0] = CCEIndex[0];
+  pdcch_pdu_rel15->beta_PDCCH_1_0[0]=0;
+  pdcch_pdu_rel15->powerControlOffsetSS[0]=1;
+  
+  int dci_formats[2];
+  int rnti_types[2];
+  
+  dci_formats[0]  = NR_DL_DCI_FORMAT_1_0;
+  rnti_types[0]   = NR_RNTI_C;
+
+  pdcch_pdu_rel15->PayloadSizeBits[0]=nr_dci_size(dci_formats[0],rnti_types[0],pdcch_pdu_rel15->BWPSize);
+  fill_dci_pdu_rel15(pdcch_pdu_rel15,&dci_pdu_rel15[0],dci_formats,rnti_types);
+
+  LOG_D(MAC, "DCI params: rnti %d, rnti_type %d, dci_format %d\n \
+	                      coreset params: FreqDomainResource %llx, start_symbol %d  n_symb %d\n",
+	pdcch_pdu_rel15->RNTI[0],
+	rnti_types[0],
+	dci_formats[0],
+	(unsigned long long)pdcch_pdu_rel15->FreqDomainResource,
+	pdcch_pdu_rel15->StartSymbolIndex,
+	pdcch_pdu_rel15->DurationSymbols);
+
+  int x_Overhead = 0; // should be 0 for initialBWP
+  nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, x_Overhead);
+
+  // Hardcode it for now
+  TBS = dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15.TBSize[0];
+  LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d startSymbolAndLength %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d TBS: %d\n",
+	pdsch_pdu_rel15->rbStart,
+	pdsch_pdu_rel15->rbSize,
+	startSymbolAndLength,
+	pdsch_pdu_rel15->StartSymbolIndex,
+	pdsch_pdu_rel15->NrOfSymbols,
+	pdsch_pdu_rel15->nrOfLayers,
+	pdsch_pdu_rel15->NrOfCodewords,
+	pdsch_pdu_rel15->mcsIndex[0],
+	TBS);
+
+  return TBS; //Return TBS in bytes
+}
+
+void config_uldci(NR_BWP_Uplink_t *ubwp,nfapi_nr_pusch_pdu_t *pusch_pdu,nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, dci_pdu_rel15_t *dci_pdu_rel15, int *dci_formats, int *rnti_types) {
+
+  dci_pdu_rel15->frequency_domain_assignment = PRBalloc_to_locationandbandwidth0(pusch_pdu->rb_size, 
+										 pusch_pdu->rb_start, 
+										 NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275));
+
+  dci_pdu_rel15->time_domain_assignment = 2; // row index used here instead of SLIV;
+  dci_pdu_rel15->frequency_hopping_flag = 0;
+  dci_pdu_rel15->mcs = 9;
+  
+  dci_pdu_rel15->format_indicator = 0;
+  dci_pdu_rel15->ndi = 1;
+  dci_pdu_rel15->rv = 0;
+  dci_pdu_rel15->harq_pid = 0;
+  dci_pdu_rel15->tpc = 2;
+  
+  LOG_D(MAC, "[gNB scheduler phytest] ULDCI type 0 payload: PDCCH CCEIndex %d, freq_alloc %d, time_alloc %d, freq_hop_flag %d, mcs %d tpc %d ndi %d rv %d\n",
+	pdcch_pdu_rel15->CceIndex[pdcch_pdu_rel15->numDlDci],
+	dci_pdu_rel15->frequency_domain_assignment,
+	dci_pdu_rel15->time_domain_assignment,
+	dci_pdu_rel15->frequency_hopping_flag,
+	dci_pdu_rel15->mcs,
+	dci_pdu_rel15->tpc,
+	dci_pdu_rel15->ndi, 
+	dci_pdu_rel15->rv);
+  
+  dci_formats[pdcch_pdu_rel15->numDlDci] = NR_UL_DCI_FORMAT_0_0;
+  rnti_types[pdcch_pdu_rel15->numDlDci]  = NR_RNTI_C;
+  pdcch_pdu_rel15->numDlDci++;
 
-  nr_configure_dci_from_pdcch_config(params_rel15,
-                                     coreset,
-                                     search_space,
-                                     *cfg,
-                                     dl_carrier_bandwidth);
-  pdu_rel15->frequency_domain_assignment = get_RIV(dlsch_pdu_rel15->start_prb, dlsch_pdu_rel15->n_prb, cfg->rf_config.dl_carrier_bandwidth.value);
-  pdu_rel15->time_domain_assignment = 3; // row index used here instead of SLIV;
-  pdu_rel15->vrb_to_prb_mapping = 1;
-  pdu_rel15->mcs = dlsch_pdu_rel15->mcs_idx;
-  pdu_rel15->tb_scaling = 1;
-  pdu_rel15->ra_preamble_index = 25;
-  pdu_rel15->format_indicator = 1;
-  pdu_rel15->ndi = 1;
-  pdu_rel15->rv = 0;
-  pdu_rel15->harq_pid = 0;
-  pdu_rel15->dai = 2;
-  pdu_rel15->tpc = 2;
-  pdu_rel15->pucch_resource_indicator = 7;
-  pdu_rel15->pdsch_to_harq_feedback_timing_indicator = 7;
-  LOG_D(MAC, "[gNB scheduler phytest] DCI type 1 payload: freq_alloc %d, time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d ndi %d rv %d\n",
-        pdu_rel15->frequency_domain_assignment,
-        pdu_rel15->time_domain_assignment,
-        pdu_rel15->vrb_to_prb_mapping,
-        pdu_rel15->mcs,
-        pdu_rel15->tb_scaling,
-        pdu_rel15->ndi,
-        pdu_rel15->rv);
-  params_rel15->rnti = rnti;
-  params_rel15->rnti_type = NFAPI_NR_RNTI_C;
-  params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0;
-  //params_rel15->aggregation_level = 1;
-  LOG_D(MAC, "DCI params: rnti %d, rnti_type %d, dci_format %d, config type %d\n \
-	                      coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d  \n \
-	                      ss params : first symb %d, ss type %d\n",
-        params_rel15->rnti,
-        params_rel15->rnti_type,
-        params_rel15->config_type,
-        params_rel15->dci_format,
-        params_rel15->mux_pattern,
-        params_rel15->n_rb,
-        params_rel15->n_symb,
-        params_rel15->rb_offset,
-        params_rel15->first_symbol,
-        params_rel15->search_space_type);
-
-  nr_get_tbs_dl(&dl_config_dlsch_pdu->dlsch_pdu, dl_config_dci_pdu->dci_dl_pdu, *cfg);
-
-  return dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15.transport_block_size/8;
 }
+    
 
-void configure_fapi_dl_Tx(nfapi_nr_dl_config_request_body_t *dl_req,
-                          nfapi_tx_request_pdu_t *tx_req,
+void configure_fapi_dl_Tx(module_id_t Mod_idP,
+                          frame_t       frameP,
+                          sub_frame_t   slotP,
+                          nfapi_nr_dl_tti_request_body_t *dl_req,
+                          nfapi_nr_pdu_t *tx_req,
                           int tbs_bytes,
                           int16_t pdu_index){
-  nfapi_nr_dl_config_request_pdu_t  *dl_config_dlsch_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu + 1];
-  nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_pdu_rel15 = &dl_config_dlsch_pdu->dlsch_pdu.dlsch_pdu_rel15;
+
+  int CC_id = 0;
+
+  nfapi_nr_dl_tti_request_pdu_t  *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs+1];
+  nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu_rel15 = &dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15;
+  gNB_MAC_INST *nr_mac  = RC.nrmac[Mod_idP];
 
   LOG_D(MAC, "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d nb_layers %d nb_codewords %d mcs %d TBS (bytes): %d\n",
-        dlsch_pdu_rel15->start_prb,
-        dlsch_pdu_rel15->n_prb,
-        dlsch_pdu_rel15->start_symbol,
-        dlsch_pdu_rel15->nb_symbols,
-        dlsch_pdu_rel15->nb_layers,
-        dlsch_pdu_rel15->nb_codewords,
-        dlsch_pdu_rel15->mcs_idx,
+        pdsch_pdu_rel15->rbStart,
+        pdsch_pdu_rel15->rbSize,
+        pdsch_pdu_rel15->StartSymbolIndex,
+        pdsch_pdu_rel15->NrOfSymbols,
+        pdsch_pdu_rel15->nrOfLayers,
+        pdsch_pdu_rel15->NrOfCodewords,
+        pdsch_pdu_rel15->mcsIndex[0],
         tbs_bytes);
 
-  dl_req->number_dci++;
-  dl_req->number_pdsch_rnti++;
-  dl_req->number_pdu+=2;
+  dl_req->nPDUs+=2;
+
+  tx_req->PDU_length = pdsch_pdu_rel15->TBSize[0];
+  tx_req->PDU_index  = nr_mac->pdu_index[0]++;
+  tx_req->num_TLV = 1;
+  tx_req->TLVs[0].length = tbs_bytes +2;
 
-  tx_req->pdu_length = tbs_bytes;
-  tx_req->pdu_index = pdu_index++;
-  tx_req->num_segments = 1;
-  //tx_req->segments[0].segment_length = 8;
-  tx_req->segments[0].segment_length = tbs_bytes + 2;
-  tx_req->segments[0].segment_data = mac_pdu;
+  memcpy((void*)&tx_req->TLVs[0].value.direct[0], (void*)&nr_mac->UE_list.DLSCH_pdu[0][0].payload[0], tbs_bytes);;
+
+  nr_mac->TX_req[CC_id].Number_of_PDUs++;
+  nr_mac->TX_req[CC_id].SFN = frameP;
+  nr_mac->TX_req[CC_id].Slot = slotP;
 }
 
 void nr_schedule_uss_dlsch_phytest(module_id_t   module_idP,
                                    frame_t       frameP,
                                    sub_frame_t   slotP,
-                                   nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config) {
+                                   nfapi_nr_dl_tti_pdsch_pdu_rel15_t *dlsch_config){
+
+  LOG_D(MAC, "In nr_schedule_uss_dlsch_phytest \n");
+
+  int post_padding = 0, ta_len = 0, header_length_total = 0, sdu_length_total = 0, num_sdus = 0;
+  int lcid, offset, i, header_length_last, TBS_bytes;
+  int UE_id = 0, CCEIndex = -1, CC_id = 0;
 
   gNB_MAC_INST *gNB_mac = RC.nrmac[module_idP];
-  nfapi_nr_dl_config_request_body_t *dl_req;
-  nfapi_tx_request_pdu_t *tx_req;
+  //NR_COMMON_channels_t                *cc           = nr_mac->common_channels;
+  //NR_ServingCellConfigCommon_t *scc=cc->ServingCellConfigCommon;
+  nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body;
+  nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[gNB_mac->TX_req[CC_id].Number_of_PDUs];
+
   mac_rlc_status_resp_t rlc_status;
-  nfapi_nr_config_request_t *cfg = &gNB_mac->config[0];
 
+  NR_UE_list_t *UE_list = &gNB_mac->UE_list;
+ 
+  if (UE_list->num_UEs ==0) return;
+ 
   unsigned char sdu_lcids[NB_RB_MAX] = {0};
   uint16_t sdu_lengths[NB_RB_MAX] = {0};
-
-  int post_padding = 0, ta_len = 0, header_length_total = 0, sdu_length_total = 0, num_sdus = 0;
-  int CC_id, lcid, offset, i, header_length_last, TBS_bytes;
-
-  int UE_id = 0; 
-  uint16_t rnti = 0x1234;
-  uint16_t sfn_sf = frameP << 7 | slotP;
+  uint16_t rnti = UE_list->rnti[UE_id];
 
   uint8_t mac_sdus[MAX_NR_DLSCH_PAYLOAD_BYTES];
-
-  for (CC_id = 0; CC_id < RC.nb_nr_mac_CC[module_idP]; CC_id++) {
-
-    LOG_D(MAC, "Scheduling UE specific search space DCI type 1 for UE_id %d CC_id %d frame %d slot %d\n", UE_id, CC_id, frameP, slotP);
-
-    dl_req = &gNB_mac->DL_req[CC_id].dl_config_request_body;
-    tx_req = &gNB_mac->TX_req[CC_id].tx_request_body.tx_pdu_list[gNB_mac->TX_req[CC_id].tx_request_body.number_of_pdus];
-    ta_len = gNB_mac->ta_len;
-
-    TBS_bytes = configure_fapi_dl_pdu(dl_req, cfg, &gNB_mac->coreset[CC_id][1], &gNB_mac->search_space[CC_id][1], dlsch_config);
-
-    //The --NOS1 use case currently schedules DLSCH transmissions only when there is IP traffic arriving
-    //through the LTE stack
-    if (IS_SOFTMODEM_NOS1){
-
-      for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) {
-        LOG_D(MAC, "[gNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (TBS %d bytes, len %d)\n",
-          module_idP, frameP, lcid, TBS_bytes, TBS_bytes - ta_len - header_length_total - sdu_length_total - 3);
-
-        if (TBS_bytes - ta_len - header_length_total - sdu_length_total - 3 > 0) {
-          rlc_status = mac_rlc_status_ind(module_idP,
-                                          rnti,
-                                          module_idP,
-                                          frameP,
-                                          slotP,
-                                          ENB_FLAG_YES,
-                                          MBMS_FLAG_NO,
-                                          lcid,
-                                          TBS_bytes - ta_len - header_length_total - sdu_length_total - 3,
-                                          0,
-                                          0);
-
-          if (rlc_status.bytes_in_buffer > 0) {
-            LOG_D(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d), TBS_bytes: %d \n \n",
-              module_idP, frameP, TBS_bytes - ta_len - header_length_total - sdu_length_total - 3,
-              lcid, header_length_total, TBS_bytes);
-
-            sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
-                                                     rnti,
-                                                     module_idP,
-                                                     frameP,
-                                                     ENB_FLAG_YES,
-                                                     MBMS_FLAG_NO,
-                                                     lcid,
-                                                     TBS_bytes,
-                                                     (char *)&mac_sdus[sdu_length_total],
-                                                     0,
-                                                     0);
-
-            LOG_D(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", module_idP, sdu_lengths[num_sdus], lcid);
-
-            sdu_lcids[num_sdus] = lcid;
-            sdu_length_total += sdu_lengths[num_sdus];
-            header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128);
-            header_length_total += header_length_last;
-
-            num_sdus++;
-
-            //ue_sched_ctl->uplane_inactivity_timer = 0;
-          }
-        } else { // no TBS_bytes left
-        break;
+  
+  LOG_D(MAC, "Scheduling UE specific search space DCI type 1\n");
+
+  ta_len = gNB_mac->ta_len;
+
+  CCEIndex = allocate_nr_CCEs(gNB_mac,
+                              1, // bwp_id
+                              0, // coreset_id
+                              4, // aggregation,
+                              1, // search_space, 0 common, 1 ue-specific
+                              UE_id,
+                              0); // m
+
+  if (CCEIndex == -1) return;
+
+  AssertFatal(CCEIndex>0,"CCEIndex is negative\n");
+  int CCEIndices[2];
+  CCEIndices[0] = CCEIndex;
+
+  TBS_bytes = configure_fapi_dl_pdu(module_idP,
+                                    CCEIndices,
+                                    dl_req, 
+                                    dlsch_config!=NULL ? dlsch_config->mcsIndex : NULL,
+                                    dlsch_config!=NULL ? &dlsch_config->rbSize : NULL,
+                                    dlsch_config!=NULL ? &dlsch_config->rbStart : NULL);
+ 
+  //The --NOS1 use case currently schedules DLSCH transmissions only when there is IP traffic arriving
+  //through the LTE stack
+  if (IS_SOFTMODEM_NOS1){
+
+    for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) {
+
+      // TODO: check if the lcid is active
+
+      LOG_D(MAC, "[gNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (TBS %d bytes, len %d)\n",
+        module_idP, frameP, lcid, TBS_bytes, TBS_bytes - ta_len - header_length_total - sdu_length_total - 3);
+
+      if (TBS_bytes - ta_len - header_length_total - sdu_length_total - 3 > 0) {
+        rlc_status = mac_rlc_status_ind(module_idP,
+                                        rnti,
+                                        module_idP,
+                                        frameP,
+                                        slotP,
+                                        ENB_FLAG_YES,
+                                        MBMS_FLAG_NO,
+                                        lcid,
+                                        TBS_bytes - ta_len - header_length_total - sdu_length_total - 3,
+                                        0,
+                                        0);
+
+        if (rlc_status.bytes_in_buffer > 0) {
+
+          LOG_D(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d), TBS_bytes: %d \n \n",
+            module_idP, frameP, TBS_bytes - ta_len - header_length_total - sdu_length_total - 3,
+            lcid, header_length_total, TBS_bytes);
+
+          sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
+                                                   rnti,
+                                                   module_idP,
+                                                   frameP,
+                                                   ENB_FLAG_YES,
+                                                   MBMS_FLAG_NO,
+                                                   lcid,
+                                                   TBS_bytes,
+                                                   (char *)&mac_sdus[sdu_length_total],
+                                                   0,
+                                                   0);
+
+          LOG_D(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", module_idP, sdu_lengths[num_sdus], lcid);
+
+          sdu_lcids[num_sdus] = lcid;
+          sdu_length_total += sdu_lengths[num_sdus];
+          header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128);
+          header_length_total += header_length_last;
+
+          num_sdus++;
+
+          //ue_sched_ctl->uplane_inactivity_timer = 0;
         }
+      } else { // no TBS_bytes left
+      break;
       }
+    }
 
-    } //if (IS_SOFTMODEM_NOS1)
-    else {
-      //When the --NOS1 option is not enabled, DLSCH transmissions with random data
-      //occur every time that the current function is called (dlsch phytest mode)
+  } //if (IS_SOFTMODEM_NOS1)
+  else {
 
-      // fill dlsch_buffer with random data
-      for (i = 0; i < TBS_bytes; i++){
-        mac_sdus[i] = (unsigned char) rand(); //i&0xFF;
-      }
+    //When the --NOS1 option is not enabled, DLSCH transmissions with random data
+    //occur every time that the current function is called (dlsch phytest mode)
 
-      //Sending SDUs with size 1
-      //Initialize elements of sdu_lcids and sdu_lengths
-      sdu_lcids[0] = 0x05; // DRB
-      sdu_lengths[0] = TBS_bytes - ta_len - 3;
-      header_length_total += 2 + (sdu_lengths[0] >= 128);
-      sdu_length_total += sdu_lengths[0];
-      num_sdus +=1;
-    } // else IS_SOFTMODEM_NOS1
-
-    // there is at least one SDU or TA command
-    // if (num_sdus > 0 ){
-    if (ta_len + sdu_length_total + header_length_total > 0) {
-
-      // Check if there is data from RLC or CE
-      if (TBS_bytes >= 2 + header_length_total + sdu_length_total + ta_len) {
-        // we have to consider padding
-        // padding param currently not in use
-        //padding = TBS_bytes - header_length_total - sdu_length_total - ta_len - 1;
-        post_padding = 1;
-      } else {
-        //padding = 0;
-        post_padding = 0;
-      }
+    LOG_D(MAC,"Configuring DL_TX in %d.%d\n", frameP, slotP);
+
+    // fill dlsch_buffer with random data
+    for (i = 0; i < TBS_bytes; i++){
+      //mac_sdus[i] = (unsigned char) rand(); 
+      ((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i] = (unsigned char) (lrand48()&0xff);
+    }
 
-      offset = nr_generate_dlsch_pdu(module_idP,
-                                     (unsigned char *) mac_sdus,
-                                     (unsigned char *) mac_pdu,
-                                     num_sdus, //num_sdus
-                                     sdu_lengths,
-                                     sdu_lcids,
-                                     255, // no drx
-                                     NULL, // contention res id
-                                     post_padding);
-
-      // Padding: fill remainder of DLSCH with 0
-      if (post_padding > 0){
-        for (int j = 0; j < (TBS_bytes - offset); j++)
-          mac_pdu[offset + j] = 0;
+    //Sending SDUs with size 1
+    //Initialize elements of sdu_lcids and sdu_lengths
+    sdu_lcids[0] = 0x05; // DRB
+    sdu_lengths[0] = TBS_bytes - ta_len - 3;
+    header_length_total += 2 + (sdu_lengths[0] >= 128);
+    sdu_length_total += sdu_lengths[0];
+    num_sdus +=1;
+
+    #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
+    if (frameP%100 == 0){
+      LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n", frameP, slotP, TBS_bytes);
+      for(int i = 0; i < 10; i++) {
+        LOG_I(MAC, "%x. ", ((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0])[i]);
       }
+    }
+    #endif
+
+  } // else IS_SOFTMODEM_NOS1
+
+  // there is at least one SDU or TA command
+  // if (num_sdus > 0 ){
+  if (ta_len + sdu_length_total + header_length_total > 0) {
+
+    // Check if there is data from RLC or CE
+    if (TBS_bytes >= 2 + header_length_total + sdu_length_total + ta_len) {
+      // we have to consider padding
+      // padding param currently not in use
+      //padding = TBS_bytes - header_length_total - sdu_length_total - ta_len - 1;
+      post_padding = 1;
+    } else {
+      //padding = 0;
+      post_padding = 0;
+    }
 
-      configure_fapi_dl_Tx(dl_req, tx_req, TBS_bytes, gNB_mac->pdu_index[CC_id]);
-
-      gNB_mac->TX_req[CC_id].tx_request_body.number_of_pdus++;
-      gNB_mac->TX_req[CC_id].sfn_sf = sfn_sf;
-      gNB_mac->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG;
-      gNB_mac->TX_req[CC_id].header.message_id = NFAPI_TX_REQUEST;
-
-      if(IS_SOFTMODEM_NOS1){
-        #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
-          LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n \n", frameP, slotP, TBS_bytes);
-          for(int i = 0; i < 10; i++) { // TBS_bytes dlsch_pdu_rel15->transport_block_size/8 6784/8
-            LOG_I(MAC, "%x. ", mac_payload[i]);
-          }
-        #endif
-      } else {
-        #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
-        if (frameP%100 == 0){
-          LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n", frameP, slotP, TBS_bytes);
-          for(int i = 0; i < 10; i++) {
-            LOG_I(MAC, "%x. ", mac_payload[i]);
-          }
+    offset = nr_generate_dlsch_pdu(module_idP,
+                                   (unsigned char *) mac_sdus,
+                                   (unsigned char *) gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0], //(unsigned char *) mac_pdu,
+                                   num_sdus, //num_sdus
+                                   sdu_lengths,
+                                   sdu_lcids,
+                                   255, // no drx
+                                   NULL, // contention res id
+                                   post_padding);
+
+    // Padding: fill remainder of DLSCH with 0
+    if (post_padding > 0){
+      for (int j = 0; j < (TBS_bytes - offset); j++)
+        gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0][offset + j] = 0; // mac_pdu[offset + j] = 0;
+    }
+
+    configure_fapi_dl_Tx(module_idP, frameP, slotP, dl_req, tx_req, TBS_bytes, gNB_mac->pdu_index[CC_id]);
+
+    if(IS_SOFTMODEM_NOS1){
+      #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
+        LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n \n", frameP, slotP, TBS_bytes);
+        for(int i = 0; i < 10; i++) { // TBS_bytes dlsch_pdu_rel15->transport_block_size/8 6784/8
+          LOG_I(MAC, "%x. ", mac_payload[i]);
+        }
+      #endif
+    } else {
+      #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
+      if (frameP%100 == 0){
+        LOG_I(MAC, "Printing first 10 payload bytes at the gNB side, Frame: %d, slot: %d, TBS size: %d \n", frameP, slotP, TBS_bytes);
+        for(int i = 0; i < 10; i++) {
+          LOG_I(MAC, "%x. ", ((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[CC_id][0][0].payload[0])[i]); //LOG_I(MAC, "%x. ", mac_payload[i]);
         }
-        #endif
       }
+      #endif
     }
-    else {  // There is no data from RLC or MAC header, so don't schedule
-    }
-  } // CC_id loop
+  }
+  else {  // There is no data from RLC or MAC header, so don't schedule
+  }
+
 }
 
 
-void nr_schedule_uss_ulsch_phytest(nfapi_nr_ul_tti_request_t *UL_tti_req,
+void nr_schedule_uss_ulsch_phytest(int Mod_idP,
                                    frame_t       frameP,
                                    sub_frame_t   slotP) {
-  //gNB_MAC_INST                      *nr_mac      = RC.nrmac[module_idP];
-  //nfapi_nr_ul_tti_request_t         *UL_tti_req;
-  uint16_t rnti = 0x1234;
 
-  for (uint8_t CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    LOG_D(MAC, "Scheduling UE specific PUSCH for CC_id %d\n",CC_id);
-    //UL_tti_req = &nr_mac->UL_tti_req[CC_id];
-    UL_tti_req->sfn = frameP;
-    UL_tti_req->slot = slotP;
-    UL_tti_req->n_pdus = 1;
-    UL_tti_req->pdus_list[0].pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE;
-    UL_tti_req->pdus_list[0].pdu_size = sizeof(nfapi_nr_pusch_pdu_t);
-    nfapi_nr_pusch_pdu_t  *pusch_pdu = &UL_tti_req->pdus_list[0].pusch_pdu;
-    memset(pusch_pdu,0,sizeof(nfapi_nr_pusch_pdu_t));
-    /*
-    // original configuration
-        rel15_ul->rnti                           = 0x1234;
-        rel15_ul->ulsch_pdu_rel15.start_rb       = 30;
-        rel15_ul->ulsch_pdu_rel15.number_rbs     = 50;
-        rel15_ul->ulsch_pdu_rel15.start_symbol   = 2;
-        rel15_ul->ulsch_pdu_rel15.number_symbols = 12;
-        rel15_ul->ulsch_pdu_rel15.nb_re_dmrs     = 6;
-        rel15_ul->ulsch_pdu_rel15.length_dmrs    = 1;
-        rel15_ul->ulsch_pdu_rel15.Qm             = 2;
-        rel15_ul->ulsch_pdu_rel15.mcs            = 9;
-        rel15_ul->ulsch_pdu_rel15.rv             = 0;
-        rel15_ul->ulsch_pdu_rel15.n_layers       = 1;
-    */
-    pusch_pdu->pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA;
-    pusch_pdu->rnti = rnti;
-    pusch_pdu->handle = 0; //not yet used
-    //BWP related paramters - we don't yet use them as the PHY only uses one default BWP
-    //pusch_pdu->bwp_size;
-    //pusch_pdu->bwp_start;
-    //pusch_pdu->subcarrier_spacing;
-    //pusch_pdu->cyclic_prefix;
-    //pusch information always include
-    //this informantion seems to be redundant. with hthe mcs_index and the modulation table, the mod_order and target_code_rate can be determined.
-    pusch_pdu->mcs_index = 9;
-    pusch_pdu->mcs_table = 0; //0: notqam256 [TS38.214, table 5.1.3.1-1] - corresponds to nr_target_code_rate_table1 in PHY
-    pusch_pdu->target_code_rate = nr_get_code_rate_ul(pusch_pdu->mcs_index,pusch_pdu->mcs_table) ;
-    pusch_pdu->qam_mod_order = nr_get_Qm_ul(pusch_pdu->mcs_index,pusch_pdu->mcs_table) ;
-    pusch_pdu->transform_precoding = 0;
-    pusch_pdu->data_scrambling_id = 0; //It equals the higher-layer parameter Data-scrambling-Identity if configured and the RNTI equals the C-RNTI, otherwise L2 needs to set it to physical cell id.;
-    pusch_pdu->nrOfLayers = 1;
-    //DMRS
-    pusch_pdu->ul_dmrs_symb_pos = 1;
-    pusch_pdu->dmrs_config_type = 0;  //dmrs-type 1 (the one with a single DMRS symbol in the beginning)
-    pusch_pdu->ul_dmrs_scrambling_id =  0; //If provided and the PUSCH is not a msg3 PUSCH, otherwise, L2 should set this to physical cell id.
-    pusch_pdu->scid = 0; //DMRS sequence initialization [TS38.211, sec 6.4.1.1.1]. Should match what is sent in DCI 0_1, otherwise set to 0.
-    //pusch_pdu->num_dmrs_cdm_grps_no_data;
-    //pusch_pdu->dmrs_ports; //DMRS ports. [TS38.212 7.3.1.1.2] provides description between DCI 0-1 content and DMRS ports. Bitmap occupying the 11 LSBs with: bit 0: antenna port 1000 bit 11: antenna port 1011 and for each bit 0: DMRS port not used 1: DMRS port used
-    //Pusch Allocation in frequency domain [TS38.214, sec 6.1.2.2]
-    pusch_pdu->resource_alloc = 1; //type 1
-    //pusch_pdu->rb_bitmap;// for ressource alloc type 0
-    pusch_pdu->rb_start = 0;
-    pusch_pdu->rb_size = 50;
-    pusch_pdu->vrb_to_prb_mapping = 0;
-    pusch_pdu->frequency_hopping = 0;
-    //pusch_pdu->tx_direct_current_location;//The uplink Tx Direct Current location for the carrier. Only values in the value range of this field between 0 and 3299, which indicate the subcarrier index within the carrier corresponding 1o the numerology of the corresponding uplink BWP and value 3300, which indicates "Outside the carrier" and value 3301, which indicates "Undetermined position within the carrier" are used. [TS38.331, UplinkTxDirectCurrentBWP IE]
-    pusch_pdu->uplink_frequency_shift_7p5khz = 0;
-    //Resource Allocation in time domain
-    pusch_pdu->start_symbol_index = 0;
-    pusch_pdu->nr_of_symbols = 12;
-    //Optional Data only included if indicated in pduBitmap
-    pusch_pdu->pusch_data.rv_index = 0;
-    pusch_pdu->pusch_data.harq_process_id = 0;
-    pusch_pdu->pusch_data.new_data_indicator = 0;
-    pusch_pdu->pusch_data.tb_size = nr_compute_tbs(pusch_pdu->mcs_index,
-						   pusch_pdu->target_code_rate,
-						   pusch_pdu->rb_size,
-						   pusch_pdu->nr_of_symbols,
-						   6, //nb_re_dmrs - not sure where this is coming from - its not in the FAPI
-						   0, //nb_rb_oh
-						   pusch_pdu->nrOfLayers = 1);
-    pusch_pdu->pusch_data.num_cb = 0; //CBG not supported
-    //pusch_pdu->pusch_data.cb_present_and_position;
-    //pusch_pdu->pusch_uci;
-    //pusch_pdu->pusch_ptrs;
-    //pusch_pdu->dfts_ofdm;
-    //beamforming
-    //pusch_pdu->beamforming; //not used for now
-  }
+  gNB_MAC_INST                      *nr_mac    = RC.nrmac[Mod_idP];
+  NR_COMMON_channels_t                  *cc    = nr_mac->common_channels;
+  NR_ServingCellConfigCommon_t         *scc    = cc->ServingCellConfigCommon;
+
+  int bwp_id=1;
+
+  int UE_id = 0;
+  NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list;
+  AssertFatal(UE_list->active[UE_id] >=0,"Cannot find UE_id %d is not active\n",UE_id);
+
+  NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
+  AssertFatal(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
+	      "downlinkBWP_ToAddModList has %d BWP!\n",
+	      secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
+  NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1];
+  NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1];
+  nfapi_nr_ul_tti_request_t *UL_tti_req = &RC.nrmac[Mod_idP]->UL_tti_req[0];
+  nfapi_nr_ul_dci_request_t *UL_dci_req = &RC.nrmac[Mod_idP]->UL_dci_req[0];
+
+
+  uint16_t rnti = UE_list->rnti[UE_id];
+  nfapi_nr_ul_dci_request_pdus_t  *ul_dci_request_pdu;
+
+  UL_tti_req->SFN = frameP;
+  UL_tti_req->Slot = slotP;
+  UL_tti_req->n_pdus = 1;
+  UL_tti_req->pdus_list[0].pdu_type = NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE;
+  UL_tti_req->pdus_list[0].pdu_size = sizeof(nfapi_nr_pusch_pdu_t);
+  nfapi_nr_pusch_pdu_t  *pusch_pdu = &UL_tti_req->pdus_list[0].pusch_pdu;
+  memset(pusch_pdu,0,sizeof(nfapi_nr_pusch_pdu_t));
+  
+  LOG_D(MAC, "Scheduling UE specific PUSCH\n");
+  //UL_tti_req = &nr_mac->UL_tti_req[CC_id];
+  /*
+  // original configuration
+  rel15_ul->rnti                           = 0x1234;
+  rel15_ul->ulsch_pdu_rel15.start_rb       = 30;
+  rel15_ul->ulsch_pdu_rel15.number_rbs     = 50;
+  rel15_ul->ulsch_pdu_rel15.start_symbol   = 2;
+  rel15_ul->ulsch_pdu_rel15.number_symbols = 12;
+  rel15_ul->ulsch_pdu_rel15.nb_re_dmrs     = 6;
+  rel15_ul->ulsch_pdu_rel15.length_dmrs    = 1;
+  rel15_ul->ulsch_pdu_rel15.Qm             = 2;
+  rel15_ul->ulsch_pdu_rel15.mcs            = 9;
+  rel15_ul->ulsch_pdu_rel15.rv             = 0;
+  rel15_ul->ulsch_pdu_rel15.n_layers       = 1;
+  */
+  pusch_pdu->pdu_bit_map = PUSCH_PDU_BITMAP_PUSCH_DATA;
+  pusch_pdu->rnti = rnti;
+  pusch_pdu->handle = 0; //not yet used
+  
+  pusch_pdu->bwp_size  = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275);
+  pusch_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275);
+  pusch_pdu->subcarrier_spacing = ubwp->bwp_Common->genericParameters.subcarrierSpacing;
+  pusch_pdu->cyclic_prefix = 0;
+  //pusch information always include
+  //this informantion seems to be redundant. with hthe mcs_index and the modulation table, the mod_order and target_code_rate can be determined.
+  pusch_pdu->mcs_index = 9;
+  pusch_pdu->mcs_table = 0; //0: notqam256 [TS38.214, table 5.1.3.1-1] - corresponds to nr_target_code_rate_table1 in PHY
+  pusch_pdu->target_code_rate = nr_get_code_rate_ul(pusch_pdu->mcs_index,pusch_pdu->mcs_table) ;
+  pusch_pdu->qam_mod_order = nr_get_Qm_ul(pusch_pdu->mcs_index,pusch_pdu->mcs_table) ;
+  pusch_pdu->transform_precoding = 0;
+  pusch_pdu->data_scrambling_id = 0; //It equals the higher-layer parameter Data-scrambling-Identity if configured and the RNTI equals the C-RNTI, otherwise L2 needs to set it to physical cell id.;
+  pusch_pdu->nrOfLayers = 1;
+  //DMRS
+  pusch_pdu->ul_dmrs_symb_pos = 1<<2; //for now the gnb assumes dmrs in the first symbol of the scheduled pusch resource
+  pusch_pdu->dmrs_config_type = 0;  //dmrs-type 1 (the one with a single DMRS symbol in the beginning)
+  pusch_pdu->ul_dmrs_scrambling_id =  0; //If provided and the PUSCH is not a msg3 PUSCH, otherwise, L2 should set this to physical cell id.
+  pusch_pdu->scid = 0; //DMRS sequence initialization [TS38.211, sec 6.4.1.1.1]. Should match what is sent in DCI 0_1, otherwise set to 0.
+  //pusch_pdu->num_dmrs_cdm_grps_no_data;
+  //pusch_pdu->dmrs_ports; //DMRS ports. [TS38.212 7.3.1.1.2] provides description between DCI 0-1 content and DMRS ports. Bitmap occupying the 11 LSBs with: bit 0: antenna port 1000 bit 11: antenna port 1011 and for each bit 0: DMRS port not used 1: DMRS port used
+  //Pusch Allocation in frequency domain [TS38.214, sec 6.1.2.2]
+  pusch_pdu->resource_alloc = 1; //type 1
+  //pusch_pdu->rb_bitmap;// for ressource alloc type 0
+  pusch_pdu->rb_start = 0;
+  pusch_pdu->rb_size = 50;
+  pusch_pdu->vrb_to_prb_mapping = 0;
+  pusch_pdu->frequency_hopping = 0;
+  //pusch_pdu->tx_direct_current_location;//The uplink Tx Direct Current location for the carrier. Only values in the value range of this field between 0 and 3299, which indicate the subcarrier index within the carrier corresponding 1o the numerology of the corresponding uplink BWP and value 3300, which indicates "Outside the carrier" and value 3301, which indicates "Undetermined position within the carrier" are used. [TS38.331, UplinkTxDirectCurrentBWP IE]
+  pusch_pdu->uplink_frequency_shift_7p5khz = 0;
+  //Resource Allocation in time domain
+  pusch_pdu->start_symbol_index = 2;
+  pusch_pdu->nr_of_symbols = 12;
+  //Optional Data only included if indicated in pduBitmap
+  pusch_pdu->pusch_data.rv_index = 0;
+  pusch_pdu->pusch_data.harq_process_id = 0;
+  pusch_pdu->pusch_data.new_data_indicator = 0;
+  pusch_pdu->pusch_data.tb_size = nr_compute_tbs(pusch_pdu->qam_mod_order,
+						 pusch_pdu->target_code_rate,
+						 pusch_pdu->rb_size,
+						 pusch_pdu->nr_of_symbols,
+						 6, //nb_re_dmrs - not sure where this is coming from - its not in the FAPI
+						 0, //nb_rb_oh
+						 pusch_pdu->nrOfLayers)>>3;
+  pusch_pdu->pusch_data.num_cb = 0; //CBG not supported
+  //pusch_pdu->pusch_data.cb_present_and_position;
+  //pusch_pdu->pusch_uci;
+  //pusch_pdu->pusch_ptrs;
+  //pusch_pdu->dfts_ofdm;
+  //beamforming
+  //pusch_pdu->beamforming; //not used for now
+
+
+  ul_dci_request_pdu = &UL_dci_req->ul_dci_pdu_list[UL_dci_req->numPdus];
+  memset((void*)ul_dci_request_pdu,0,sizeof(nfapi_nr_ul_dci_request_pdus_t));
+  ul_dci_request_pdu->PDUType = NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE;
+  ul_dci_request_pdu->PDUSize = (uint8_t)(2+sizeof(nfapi_nr_dl_tti_pdcch_pdu));
+  nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = &ul_dci_request_pdu->pdcch_pdu.pdcch_pdu_rel15;
+
+  int dci_formats[2];
+  int rnti_types[2];
+
+  int CCEIndex = allocate_nr_CCEs(nr_mac,
+				  1, // bwp_id
+				  0, // coreset_id
+				  4, // aggregation,
+				  1, // search_space, 0 common, 1 ue-specific
+				  UE_id,
+				  0); // m
+
+  dci_formats[0]  = NR_UL_DCI_FORMAT_0_0;
+  rnti_types[0]   = NR_RNTI_C;
+  LOG_D(MAC,"Configuring ULDCI/PDCCH in %d.%d\n", frameP,slotP);
+  nr_configure_pdcch(pdcch_pdu_rel15,
+		     1, // ue-specific,
+		     scc,
+		     bwp);
+
+  
+  dci_pdu_rel15_t dci_pdu_rel15[MAX_DCI_CORESET];
+
+  AssertFatal(CCEIndex>=0,"CCEIndex is negative \n");
+  pdcch_pdu_rel15->CceIndex[pdcch_pdu_rel15->numDlDci] = CCEIndex;
+
+  LOG_D(PHY,"CCEIndex %d\n",pdcch_pdu_rel15->CceIndex[pdcch_pdu_rel15->numDlDci]);
+
+  config_uldci(ubwp,pusch_pdu,pdcch_pdu_rel15, &dci_pdu_rel15[0], dci_formats, rnti_types);
+  
+  pdcch_pdu_rel15->PayloadSizeBits[0]=nr_dci_size(dci_formats[0],rnti_types[0],pdcch_pdu_rel15->BWPSize);
+  fill_dci_pdu_rel15(pdcch_pdu_rel15,&dci_pdu_rel15[0],dci_formats,rnti_types);
+  
 }
 
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
index d95819d1e78..93768558823 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
@@ -39,6 +39,7 @@
 #include "LAYER2/NR_MAC_gNB/mac_proto.h"
 #include "common/utils/LOG/log.h"
 #include "common/utils/LOG/vcd_signal_dumper.h"
+#include "common/utils/nr/nr_common.h"
 #include "UTIL/OPT/opt.h"
 #include "OCG.h"
 #include "OCG_extern.h"
@@ -53,10 +54,16 @@
 #include "intertask_interface.h"
 
 #include "T.h"
+#include "NR_PDCCH-ConfigCommon.h"
+#include "NR_ControlResourceSet.h"
+#include "NR_SearchSpace.h"
+
+#include "nfapi_nr_interface.h"
 
 #define ENABLE_MAC_PAYLOAD_DEBUG
 #define DEBUG_gNB_SCHEDULER 1
 
+
 #include "common/ran_context.h"
 
 extern RAN_CONTEXT_t RC;
@@ -122,29 +129,88 @@ static inline uint8_t get_max_cces(uint8_t scs) {
   return (nr_max_number_of_cces_per_slot[scs]);
 } 
 
-int is_nr_UL_slot(NR_COMMON_channels_t * ccP, int slot){
+int allocate_nr_CCEs(gNB_MAC_INST *nr_mac,
+		     int bwp_id,
+		     int coreset_id,
+		     int aggregation,
+		     int search_space, // 0 common, 1 ue-specific
+		     int UE_id,
+		     int m
+		     ) {
+  // uncomment these when we allocate for common search space
+  //  NR_COMMON_channels_t                *cc      = nr_mac->common_channels;
+  //  NR_ServingCellConfigCommon_t        *scc     = cc->ServingCellConfigCommon;
+
+  NR_UE_list_t *UE_list = &nr_mac->UE_list;
+
+  NR_BWP_Downlink_t *bwp;
+  NR_CellGroupConfig_t *secondaryCellGroup;
+
+  NR_ControlResourceSet_t *coreset;
+
+  if (search_space == 1) {
+    AssertFatal(UE_list->active[UE_id] >=0,"UE_id %d is not active\n",UE_id);
+    secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
+    bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1];
+    coreset = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[coreset_id];
+  }
+  else {
+    AssertFatal(1==0,"Add code for common search space\n");
+  }
+
+  int *cce_list = nr_mac->cce_list[bwp_id][coreset_id];
+
+
+  int n_rb=0;
+  for (int i=0;i<6;i++)
+    for (int j=0;j<8;j++) {
+      n_rb+=((coreset->frequencyDomainResources.buf[i]>>j)&1);
+    }
+  n_rb*=6;
+
+  uint16_t N_reg = n_rb * coreset->duration;
+  uint16_t Y=0, N_cce, M_s_max, n_CI=0;
+  uint16_t n_RNTI = search_space == 1 ? UE_list->rnti[UE_id]:0;
+  uint32_t A[3]={39827,39829,39839};
+
+  N_cce = N_reg / NR_NB_REG_PER_CCE;
+
+  M_s_max = (aggregation==4)?4:(aggregation==8)?2:1;
+
+  if (search_space == 1) {
+    Y = (A[0]*n_RNTI)%65537; // Candidate 0, antenna port 0
+  }
+  int first_cce = aggregation * (( Y + (m*N_cce)/(aggregation*M_s_max) + n_CI ) % CEILIDIV(N_cce,aggregation));
+
+  for (int i=0;i<aggregation;i++) 
+    if (cce_list[first_cce+i] != 0) return(-1);
+  
+  for (int i=0;i<aggregation;i++) cce_list[first_cce+i] = 1;
+
+  return(first_cce);
 
-    return (0);
 }
 
-void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params,
+void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
 				  nr_scs_e scs_common,
 				  nr_scs_e pdcch_scs,
 				  nr_frequency_range_e freq_range,
 				  uint8_t rmsi_pdcch_config,
 				  uint8_t ssb_idx,
-          uint8_t k_ssb,
-          uint16_t sfn_ssb,
-          uint8_t n_ssb, /*slot index overlapping the corresponding SSB index*/
+				  uint8_t k_ssb,
+				  uint16_t sfn_ssb,
+				  uint8_t n_ssb, /*slot index overlapping the corresponding SSB index*/
 				  uint16_t nb_slots_per_frame,
 				  uint16_t N_RB)
 {
-  uint8_t O, M;
-  uint8_t ss_idx = rmsi_pdcch_config&0xf;
-  uint8_t cset_idx = (rmsi_pdcch_config>>4)&0xf;
-  uint8_t mu = scs_common;
-  uint8_t O_scale=0, M_scale=0; // used to decide if the values of O and M need to be divided by 2
-
+  //  uint8_t O, M;
+  //  uint8_t ss_idx = rmsi_pdcch_config&0xf;
+  //  uint8_t cset_idx = (rmsi_pdcch_config>>4)&0xf;
+  //  uint8_t mu = scs_common;
+  //  uint8_t O_scale=0, M_scale=0; // used to decide if the values of O and M need to be divided by 2
+
+  AssertFatal(1==0,"todo\n");
+  /*
   /// Coreset params
   switch(scs_common) {
 
@@ -153,18 +219,18 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* p
       switch(pdcch_scs) {
         case kHz15:
           AssertFatal(cset_idx<15,"Coreset index %d reserved for scs kHz15/kHz15\n", cset_idx);
-          pdcch_params->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
-          pdcch_params->n_rb = (cset_idx < 6)? 24 : (cset_idx < 12)? 48 : 96;
-          pdcch_params->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_15_15[cset_idx];
-          pdcch_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0_scs_15_15[cset_idx];
+          pdcch_pdu->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
+          pdcch_pdu->n_rb = (cset_idx < 6)? 24 : (cset_idx < 12)? 48 : 96;
+          pdcch_pdu->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_15_15[cset_idx];
+          pdcch_pdu->rb_offset = nr_coreset_rb_offset_pdcch_type_0_scs_15_15[cset_idx];
         break;
 
         case kHz30:
           AssertFatal(cset_idx<14,"Coreset index %d reserved for scs kHz15/kHz30\n", cset_idx);
-          pdcch_params->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
-          pdcch_params->n_rb = (cset_idx < 8)? 24 : 48;
-          pdcch_params->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_15_30[cset_idx];
-          pdcch_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0_scs_15_15[cset_idx];
+          pdcch_pdu->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
+          pdcch_pdu->n_rb = (cset_idx < 8)? 24 : 48;
+          pdcch_pdu->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_15_30[cset_idx];
+          pdcch_pdu->rb_offset = nr_coreset_rb_offset_pdcch_type_0_scs_15_15[cset_idx];
         break;
 
         default:
@@ -179,17 +245,17 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* p
         switch(pdcch_scs) {
           case kHz15:
             AssertFatal(cset_idx<9,"Coreset index %d reserved for scs kHz30/kHz15\n", cset_idx);
-            pdcch_params->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
-            pdcch_params->n_rb = (cset_idx < 10)? 48 : 96;
-            pdcch_params->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_30_15_b40Mhz[cset_idx];
-            pdcch_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0_scs_30_15_b40Mhz[cset_idx];
+            pdcch_pdu->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
+            pdcch_pdu->n_rb = (cset_idx < 10)? 48 : 96;
+            pdcch_pdu->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_30_15_b40Mhz[cset_idx];
+            pdcch_pdu->rb_offset = nr_coreset_rb_offset_pdcch_type_0_scs_30_15_b40Mhz[cset_idx];
           break;
 
           case kHz30:
-            pdcch_params->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
-            pdcch_params->n_rb = (cset_idx < 6)? 24 : 48;
-            pdcch_params->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_30_30_b40Mhz[cset_idx];
-            pdcch_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0_scs_30_30_b40Mhz[cset_idx];
+            pdcch_pdu->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
+            pdcch_pdu->n_rb = (cset_idx < 6)? 24 : 48;
+            pdcch_pdu->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_30_30_b40Mhz[cset_idx];
+            pdcch_pdu->rb_offset = nr_coreset_rb_offset_pdcch_type_0_scs_30_30_b40Mhz[cset_idx];
           break;
 
           default:
@@ -201,18 +267,18 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* p
         switch(pdcch_scs) {
           case kHz15:
             AssertFatal(cset_idx<9,"Coreset index %d reserved for scs kHz30/kHz15\n", cset_idx);
-            pdcch_params->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
-            pdcch_params->n_rb = (cset_idx < 3)? 48 : 96;
-            pdcch_params->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_30_15_a40Mhz[cset_idx];
-            pdcch_params->rb_offset = nr_coreset_rb_offset_pdcch_type_0_scs_30_15_a40Mhz[cset_idx];
+            pdcch_pdu->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
+            pdcch_pdu->n_rb = (cset_idx < 3)? 48 : 96;
+            pdcch_pdu->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_30_15_a40Mhz[cset_idx];
+            pdcch_pdu->rb_offset = nr_coreset_rb_offset_pdcch_type_0_scs_30_15_a40Mhz[cset_idx];
           break;
 
           case kHz30:
             AssertFatal(cset_idx<10,"Coreset index %d reserved for scs kHz30/kHz30\n", cset_idx);
-            pdcch_params->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
-            pdcch_params->n_rb = (cset_idx < 4)? 24 : 48;
-            pdcch_params->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_30_30_a40Mhz[cset_idx];
-            pdcch_params->rb_offset =  nr_coreset_rb_offset_pdcch_type_0_scs_30_30_a40Mhz[cset_idx];
+            pdcch_pdu->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
+            pdcch_pdu->n_rb = (cset_idx < 4)? 24 : 48;
+            pdcch_pdu->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_30_30_a40Mhz[cset_idx];
+            pdcch_pdu->rb_offset =  nr_coreset_rb_offset_pdcch_type_0_scs_30_30_a40Mhz[cset_idx];
           break;
 
           default:
@@ -225,19 +291,19 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* p
       switch(pdcch_scs) {
         case kHz60:
           AssertFatal(cset_idx<12,"Coreset index %d reserved for scs kHz120/kHz60\n", cset_idx);
-          pdcch_params->mux_pattern = (cset_idx < 8)?NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1 : NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE2;
-          pdcch_params->n_rb = (cset_idx < 6)? 48 : (cset_idx < 8)? 96 : (cset_idx < 10)? 48 : 96;
-          pdcch_params->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_120_60[cset_idx];
-          pdcch_params->rb_offset = (nr_coreset_rb_offset_pdcch_type_0_scs_120_60[cset_idx]>0)?nr_coreset_rb_offset_pdcch_type_0_scs_120_60[cset_idx] :
+          pdcch_pdu->mux_pattern = (cset_idx < 8)?NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1 : NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE2;
+          pdcch_pdu->n_rb = (cset_idx < 6)? 48 : (cset_idx < 8)? 96 : (cset_idx < 10)? 48 : 96;
+          pdcch_pdu->n_symb = nr_coreset_nsymb_pdcch_type_0_scs_120_60[cset_idx];
+          pdcch_pdu->rb_offset = (nr_coreset_rb_offset_pdcch_type_0_scs_120_60[cset_idx]>0)?nr_coreset_rb_offset_pdcch_type_0_scs_120_60[cset_idx] :
           (k_ssb == 0)? -41 : -42;
         break;
 
         case kHz120:
           AssertFatal(cset_idx<8,"Coreset index %d reserved for scs kHz120/kHz120\n", cset_idx);
-          pdcch_params->mux_pattern = (cset_idx < 4)?NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1 : NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE3;
-          pdcch_params->n_rb = (cset_idx < 2)? 24 : (cset_idx < 4)? 48 : (cset_idx < 6)? 24 : 48;
-          pdcch_params->n_symb = (cset_idx == 2)? 1 : 2;
-          pdcch_params->rb_offset = (nr_coreset_rb_offset_pdcch_type_0_scs_120_120[cset_idx]>0)? nr_coreset_rb_offset_pdcch_type_0_scs_120_120[cset_idx] :
+          pdcch_pdu->mux_pattern = (cset_idx < 4)?NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1 : NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE3;
+          pdcch_pdu->n_rb = (cset_idx < 2)? 24 : (cset_idx < 4)? 48 : (cset_idx < 6)? 24 : 48;
+          pdcch_pdu->n_symb = (cset_idx == 2)? 1 : 2;
+          pdcch_pdu->rb_offset = (nr_coreset_rb_offset_pdcch_type_0_scs_120_120[cset_idx]>0)? nr_coreset_rb_offset_pdcch_type_0_scs_120_120[cset_idx] :
           (k_ssb == 0)? -20 : -21;
         break;
 
@@ -250,18 +316,18 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* p
     switch(pdcch_scs) {
       case kHz60:
         AssertFatal(cset_idx<4,"Coreset index %d reserved for scs kHz240/kHz60\n", cset_idx);
-        pdcch_params->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
-        pdcch_params->n_rb = 96;
-        pdcch_params->n_symb = (cset_idx < 2)? 1 : 2;
-        pdcch_params->rb_offset = (cset_idx&1)? 16 : 0;
+        pdcch_pdu->mux_pattern = NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1;
+        pdcch_pdu->n_rb = 96;
+        pdcch_pdu->n_symb = (cset_idx < 2)? 1 : 2;
+        pdcch_pdu->rb_offset = (cset_idx&1)? 16 : 0;
       break;
 
       case kHz120:
         AssertFatal(cset_idx<8,"Coreset index %d reserved for scs kHz240/kHz120\n", cset_idx);
-        pdcch_params->mux_pattern = (cset_idx < 4)? NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1 : NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE2;
-        pdcch_params->n_rb = (cset_idx < 4)? 48 : (cset_idx < 6)? 24 : 48;
-        pdcch_params->n_symb = ((cset_idx==2)||(cset_idx==3))? 2 : 1;
-        pdcch_params->rb_offset = (nr_coreset_rb_offset_pdcch_type_0_scs_240_120[cset_idx]>0)? nr_coreset_rb_offset_pdcch_type_0_scs_240_120[cset_idx] :
+        pdcch_pdu->mux_pattern = (cset_idx < 4)? NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1 : NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE2;
+        pdcch_pdu->n_rb = (cset_idx < 4)? 48 : (cset_idx < 6)? 24 : 48;
+        pdcch_pdu->n_symb = ((cset_idx==2)||(cset_idx==3))? 2 : 1;
+        pdcch_pdu->rb_offset = (nr_coreset_rb_offset_pdcch_type_0_scs_240_120[cset_idx]>0)? nr_coreset_rb_offset_pdcch_type_0_scs_240_120[cset_idx] :
         (k_ssb == 0)? -41 : -42;
       break;
 
@@ -276,29 +342,29 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* p
   }
 
   /// Search space params
-  switch(pdcch_params->mux_pattern) {
+  switch(pdcch_pdu->mux_pattern) {
 
     case NFAPI_NR_SSB_AND_CSET_MUX_PATTERN_TYPE1:
       if (freq_range == nr_FR1) {
         O = nr_ss_param_O_type_0_mux1_FR1[ss_idx];
-        pdcch_params->nb_ss_sets_per_slot = nr_ss_sets_per_slot_type_0_FR1[ss_idx];
+        pdcch_pdu->nb_ss_sets_per_slot = nr_ss_sets_per_slot_type_0_FR1[ss_idx];
         M = nr_ss_param_M_type_0_mux1_FR1[ss_idx];
         M_scale = nr_ss_scale_M_mux1_FR1[ss_idx];
-        pdcch_params->first_symbol = (ss_idx < 8)? ( (ssb_idx&1)? pdcch_params->n_symb : 0 ) : nr_ss_first_symb_idx_type_0_mux1_FR1[ss_idx - 8];
+        pdcch_pdu->first_symbol = (ss_idx < 8)? ( (ssb_idx&1)? pdcch_pdu->n_symb : 0 ) : nr_ss_first_symb_idx_type_0_mux1_FR1[ss_idx - 8];
       }
 
       else {
         AssertFatal(ss_idx<14 ,"Invalid search space index for multiplexing type 1 and FR2 %d\n", ss_idx);
         O = nr_ss_param_O_type_0_mux1_FR2[ss_idx];
         O_scale = nr_ss_scale_O_mux1_FR2[ss_idx];
-        pdcch_params->nb_ss_sets_per_slot = nr_ss_sets_per_slot_type_0_FR2[ss_idx];
+        pdcch_pdu->nb_ss_sets_per_slot = nr_ss_sets_per_slot_type_0_FR2[ss_idx];
         M = nr_ss_param_M_type_0_mux1_FR2[ss_idx];
         M_scale = nr_ss_scale_M_mux1_FR2[ss_idx];
-        pdcch_params->first_symbol = (ss_idx < 12)? ( (ss_idx&1)? 7 : 0 ) : 0;
+        pdcch_pdu->first_symbol = (ss_idx < 12)? ( (ss_idx&1)? 7 : 0 ) : 0;
       }
-      pdcch_params->nb_slots = 2;
-      pdcch_params->sfn_mod2 = (CEILIDIV( (((O<<mu)>>O_scale) + ((ssb_idx*M)>>M_scale)), nb_slots_per_frame ) & 1)? 1 : 0;
-      pdcch_params->first_slot = (((O<<mu)>>O_scale) + ((ssb_idx*M)>>M_scale)) % nb_slots_per_frame;
+      pdcch_pdu->nb_slots = 2;
+      pdcch_pdu->sfn_mod2 = (CEILIDIV( (((O<<mu)>>O_scale) + ((ssb_idx*M)>>M_scale)), nb_slots_per_frame ) & 1)? 1 : 0;
+      pdcch_pdu->first_slot = (((O<<mu)>>O_scale) + ((ssb_idx*M)>>M_scale)) % nb_slots_per_frame;
 
     break;
 
@@ -307,14 +373,14 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* p
       "Invalid scs_common/pdcch_scs combination %d/%d for Mux type 2\n", scs_common, pdcch_scs );
       AssertFatal(ss_idx==0, "Search space index %d reserved for scs_common/pdcch_scs combination %d/%d", ss_idx, scs_common, pdcch_scs);
 
-      pdcch_params->nb_slots = 1;
+      pdcch_pdu->nb_slots = 1;
 
       if ((scs_common==kHz120)&&(pdcch_scs==kHz60)) {
-        pdcch_params->first_symbol = nr_ss_first_symb_idx_scs_120_60_mux2[ssb_idx&3];
-        // Missing in pdcch_params sfn_C and n_C here and in else case
+        pdcch_pdu->first_symbol = nr_ss_first_symb_idx_scs_120_60_mux2[ssb_idx&3];
+        // Missing in pdcch_pdu sfn_C and n_C here and in else case
       }
       else {
-        pdcch_params->first_symbol = ((ssb_idx&7)==4)?12 : ((ssb_idx&7)==4)?13 : nr_ss_first_symb_idx_scs_240_120_set1_mux2[ssb_idx&7]; //???
+        pdcch_pdu->first_symbol = ((ssb_idx&7)==4)?12 : ((ssb_idx&7)==4)?13 : nr_ss_first_symb_idx_scs_240_120_set1_mux2[ssb_idx&7]; //???
       }
 
     break;
@@ -324,159 +390,919 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* p
       "Invalid scs_common/pdcch_scs combination %d/%d for Mux type 3\n", scs_common, pdcch_scs );
       AssertFatal(ss_idx==0, "Search space index %d reserved for scs_common/pdcch_scs combination %d/%d", ss_idx, scs_common, pdcch_scs);
 
-      pdcch_params->first_symbol = nr_ss_first_symb_idx_scs_120_120_mux3[ssb_idx&3];
+      pdcch_pdu->first_symbol = nr_ss_first_symb_idx_scs_120_120_mux3[ssb_idx&3];
 
     break;
 
     default:
-      AssertFatal(1==0, "Invalid SSB and coreset multiplexing pattern %d\n", pdcch_params->mux_pattern);
+      AssertFatal(1==0, "Invalid SSB and coreset multiplexing pattern %d\n", pdcch_pdu->mux_pattern);
   }
-  pdcch_params->config_type = NFAPI_NR_CSET_CONFIG_MIB_SIB1;
-  pdcch_params->cr_mapping_type = NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED;
-  pdcch_params->precoder_granularity = NFAPI_NR_CSET_SAME_AS_REG_BUNDLE;
-  pdcch_params->reg_bundle_size = 6;
-  pdcch_params->interleaver_size = 2;
+  pdcch_pdu->config_type = NFAPI_NR_CSET_CONFIG_MIB_SIB1;
+  pdcch_pdu->cr_mapping_type = NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED;
+  pdcch_pdu->precoder_granularity = NFAPI_NR_CSET_SAME_AS_REG_BUNDLE;
+  pdcch_pdu->reg_bundle_size = 6;
+  pdcch_pdu->interleaver_size = 2;
   // set initial banwidth part to full bandwidth
-  pdcch_params->n_RB_BWP = N_RB;
+  pdcch_pdu->n_RB_BWP = N_RB;
 
+  */
 
 }
 
-void nr_configure_dci_from_pdcch_config(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params,
-                                            nfapi_nr_coreset_t* coreset,
-                                            nfapi_nr_search_space_t* search_space,
-                                            nfapi_nr_config_request_t cfg,
-                                            uint16_t N_RB) {
-/// coreset
-
-  //ControlResourceSetId
-  pdcch_params->config_type = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG;
+void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
+			int ss_type,
+			NR_ServingCellConfigCommon_t *scc,
+			NR_BWP_Downlink_t *bwp){
   
-  //frequencyDomainResources
-  uint8_t count=0, start=0, start_set=0;
-  uint64_t bitmap = coreset->frequency_domain_resources;
-  for (int i=0; i<45; i++)
-    if ((bitmap>>(44-i))&1) {
-      count++;
-      if (!start_set) {
+  if (bwp) { // This is not the InitialBWP
+    /// coreset
+    
+    //ControlResourceSetId
+    //  pdcch_pdu->config_type = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG;
+    AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList!=NULL,
+		"controlResourceSetToAddModList is null\n");
+    AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count>0,
+		"controlResourceSetToAddModList is empty\n");
+    NR_ControlResourceSet_t *coreset0 = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[0];
+    
+    
+    pdcch_pdu->BWPSize  = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275);
+    pdcch_pdu->BWPStart = NRRIV2PRBOFFSET(bwp->bwp_Common->genericParameters.locationAndBandwidth,275);
+    pdcch_pdu->SubcarrierSpacing = bwp->bwp_Common->genericParameters.subcarrierSpacing;
+    pdcch_pdu->CyclicPrefix = (bwp->bwp_Common->genericParameters.cyclicPrefix==NULL) ? 0 : *bwp->bwp_Common->genericParameters.cyclicPrefix;
+    
+    pdcch_pdu->DurationSymbols  = coreset0->duration;
+    
+    //frequencyDomainResources
+    /*    uint8_t count=0, start=0, start_set=0;
+    // find coreset descriptor
+    
+    uint64_t bitmap = (((uint64_t)coreset0->frequencyDomainResources.buf[0])<<37)|
+	(((uint64_t)coreset0->frequencyDomainResources.buf[1])<<29)|
+	(((uint64_t)coreset0->frequencyDomainResources.buf[2])<<21)|
+	(((uint64_t)coreset0->frequencyDomainResources.buf[3])<<13)|
+	(((uint64_t)coreset0->frequencyDomainResources.buf[4])<<5)|
+	(((uint64_t)coreset0->frequencyDomainResources.buf[5])>>3);
+	
+	for (int i=0; i<45; i++)
+	if ((bitmap>>(44-i))&1) {
+	count++;
+	if (!start_set) {
         start = i;
         start_set = 1;
-      }
+	}
+	}
+	pdcch_pdu->rb_offset = 6*start;
+	pdcch_pdu->n_rb = 6*count;
+    */
+    for (int i=0;i<6;i++)
+      pdcch_pdu->FreqDomainResource[i] = coreset0->frequencyDomainResources.buf[i];
+    //duration
+    
+    
+    //cce-REG-MappingType
+    pdcch_pdu->CceRegMappingType = coreset0->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved?
+      NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED : NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED;
+    if (pdcch_pdu->CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) {
+      pdcch_pdu->RegBundleSize = (coreset0->cce_REG_MappingType.choice.interleaved->reg_BundleSize == NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6) ? 6 : (2+coreset0->cce_REG_MappingType.choice.interleaved->reg_BundleSize);
+      pdcch_pdu->InterleaverSize = (coreset0->cce_REG_MappingType.choice.interleaved->interleaverSize==NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n6) ? 6 : (2+coreset0->cce_REG_MappingType.choice.interleaved->interleaverSize);
+      AssertFatal(scc->physCellId != NULL,"scc->physCellId is null\n");
+      pdcch_pdu->ShiftIndex = coreset0->cce_REG_MappingType.choice.interleaved->shiftIndex != NULL ? *coreset0->cce_REG_MappingType.choice.interleaved->shiftIndex : *scc->physCellId;
+    }
+    else {
+      pdcch_pdu->RegBundleSize = 0;
+      pdcch_pdu->InterleaverSize = 0;
+      pdcch_pdu->ShiftIndex = 0;
     }
-  pdcch_params->rb_offset = 6*start;
-  pdcch_params->n_rb = 6*count;
-
-  //duration
-  pdcch_params->n_symb = coreset->duration;
 
-  //cce-REG-MappingType
-  pdcch_params->cr_mapping_type = coreset->cce_reg_mapping_type;
-  if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) {
-    pdcch_params->reg_bundle_size = coreset->reg_bundle_size;
-    pdcch_params->interleaver_size = coreset->interleaver_size;
-  }
-  else {
-    pdcch_params->reg_bundle_size = 0;
-    pdcch_params->interleaver_size = 0;
+    pdcch_pdu->CoreSetType = 1; 
+    
+    //precoderGranularity
+    pdcch_pdu->precoderGranularity = coreset0->precoderGranularity;
+    
+    //TCI states
+    // 
+    /*
+    //TCI present
+    if (coreset0->tci_PresentInDCI != NULL) {
+    AssertFatal(coreset0->tci_StatesPDCCH_ToAddList != NULL,"tci_StatesPDCCH_ToAddList is null\n");
+    AssertFatal(coreset0->tci_StatesPDCCH_ToAddList->list.count>0,"TCI state list is empty\n");
+    for (int i=0;i<coreset0->tci_StatesPDCCH_ToAddList->list.count;i++) {
+    
+    }
+    */
+    
+    for (int i=0;i<pdcch_pdu->numDlDci;i++) {
+      //pdcch-DMRS-ScramblingID
+      AssertFatal(coreset0->pdcch_DMRS_ScramblingID != NULL,"coreset0->pdcch_DMRS_ScramblingID is null\n");
+      pdcch_pdu->ScramblingId[i] = *coreset0->pdcch_DMRS_ScramblingID;
+    }    
+    
+    /// SearchSpace
+    
+    // first symbol
+    //AssertFatal(pdcch_scs==kHz15, "PDCCH SCS above 15kHz not allowed if a symbol above 2 is monitored");
+    int sps = bwp->bwp_Common->genericParameters.cyclicPrefix == NULL ? 14 : 12;
+    
+    AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList!=NULL,"searchPsacesToAddModList is null\n");
+    AssertFatal(bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count>0,
+		"searchPsacesToAddModList is empty\n");
+    NR_SearchSpace_t *ss;
+    int found=0;
+    int target_ss = NR_SearchSpace__searchSpaceType_PR_common;
+    if (ss_type == 1) { 
+      target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific;
+    } 
+    
+    for (int i=0;i<bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.count;i++) {
+      ss=bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[i];
+      AssertFatal(ss->controlResourceSetId != NULL,"ss->controlResourceSetId is null\n");
+      AssertFatal(ss->searchSpaceType != NULL,"ss->searchSpaceType is null\n");
+      if (*ss->controlResourceSetId == coreset0->controlResourceSetId && 
+	  ss->searchSpaceType->present == target_ss) {
+	found=1;
+	break;
+      }
+    }
+    AssertFatal(found==1,"Couldn't find a searchspace corresponding to coreset0\n");
+    AssertFatal(ss->monitoringSymbolsWithinSlot!=NULL,"ss->monitoringSymbolsWithinSlot is null\n");
+    AssertFatal(ss->monitoringSymbolsWithinSlot->buf!=NULL,"ss->monitoringSymbolsWithinSlot->buf is null\n");
+    
+    // for SPS=14 8 MSBs in positions 13 downto 6,  
+    uint16_t monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | 
+      (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
+    
+    for (int i=0; i<sps; i++)
+      if ((monitoringSymbolsWithinSlot>>(sps-1-i))&1) {
+	pdcch_pdu->StartSymbolIndex=i;
+	break;
+      }
   }
 
-  //shift index
-  pdcch_params->shift_index = coreset->shift_index;
+  else { // this is for InitialBWP
+    AssertFatal(1==0,"Fill in InitialBWP PDCCH configuration\n");
+  }
+}
 
-  //precoderGranularity
-  pdcch_params->precoder_granularity = coreset->precoder_granularity;
 
-  //TCI states
-  // PDCCH params does not yet include information about TCI and QCL (needed for DCI 1.1 and 0.1)
 
-  //pdcch-DMRS-ScramblingID
-  pdcch_params->scrambling_id = coreset->dmrs_scrambling_id;
+void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
+			dci_pdu_rel15_t *dci_pdu_rel15,
+			int *dci_formats,
+			int *rnti_types
+			) {
   
-
-/// SearchSpace
-
-  // first symbol
-  //AssertFatal(pdcch_scs==kHz15, "PDCCH SCS above 15kHz not allowed if a symbol above 2 is monitored");
-  int sps = get_symbolsperslot(&cfg);
-
-  for (int i=0; i<sps; i++)
-    if ((search_space->monitoring_symbols_in_slot>>(sps-1-i))&1) {
-      pdcch_params->first_symbol=i;
+  uint16_t N_RB = pdcch_pdu_rel15->BWPSize;
+  uint8_t fsize=0, pos=0;
+
+  for (int d=0;d<pdcch_pdu_rel15->numDlDci;d++) {
+
+    uint64_t *dci_pdu = (uint64_t *)pdcch_pdu_rel15->Payload[d];
+    AssertFatal(pdcch_pdu_rel15->PayloadSizeBits[d]<=64, "DCI sizes above 64 bits not yet supported");
+
+    int dci_size = pdcch_pdu_rel15->PayloadSizeBits[d];
+    
+    /// Payload generation
+    switch(dci_formats[d]) {
+    case NR_DL_DCI_FORMAT_1_0:
+      switch(rnti_types[d]) {
+      case NR_RNTI_RA:
+	// Freq domain assignment
+	fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+	pos=fsize;
+	*dci_pdu |= ((dci_pdu_rel15->frequency_domain_assignment&((1<<fsize)-1)) << (dci_size-pos));
+	LOG_D(MAC,"frequency-domain assignment %d (%d bits) N_RB_BWP %d=> %d (0x%lx)\n",dci_pdu_rel15->frequency_domain_assignment,fsize,N_RB,dci_size-pos,*dci_pdu);
+	// Time domain assignment
+	pos+=4;
+	*dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment&0xf) << (dci_size-pos));
+	LOG_D(MAC,"time-domain assignment %d  (3 bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_domain_assignment,dci_size-pos,*dci_pdu);
+	// VRB to PRB mapping
+	
+	pos++;
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping&0x1)<<(dci_size-pos);
+	LOG_D(MAC,"vrb to prb mapping %d  (1 bits)=> %d (0x%lx)\n",dci_pdu_rel15->vrb_to_prb_mapping,dci_size-pos,*dci_pdu);
+	// MCS
+	pos+=5;
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs&0x1f)<<(dci_size-pos);
+	LOG_D(MAC,"mcs %d  (5 bits)=> %d (0x%lx)\n",dci_pdu_rel15->mcs,dci_size-pos,*dci_pdu);
+	// TB scaling
+	pos+=2;
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->tb_scaling&0x3)<<(dci_size-pos);
+	LOG_D(MAC,"tb_scaling %d  (2 bits)=> %d (0x%lx)\n",dci_pdu_rel15->tb_scaling,dci_size-pos,*dci_pdu);
+	break;
+	
+      case NR_RNTI_C:
+	
+	// indicating a DL DCI format 1bit
+	pos++;
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator&1)<<(dci_size-pos);
+	LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,N_RB,dci_size-pos,*dci_pdu);
+	
+	// Freq domain assignment (275rb >> fsize = 16)
+	fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+	pos+=fsize;
+	*dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment&((1<<fsize)-1)) << (dci_size-pos));
+	
+	LOG_D(MAC,"Freq domain assignment %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->frequency_domain_assignment,fsize,dci_size-pos,*dci_pdu);
+	
+	uint16_t is_ra = 1;
+	for (int i=0; i<fsize; i++)
+	  if (!((dci_pdu_rel15->frequency_domain_assignment>>i)&1)) {
+	    is_ra = 0;
+	    break;
+	  }
+	if (is_ra) //fsize are all 1  38.212 p86
+	  {
+	    // ra_preamble_index 6 bits
+	    pos+=6;
+	    *dci_pdu |= ((dci_pdu_rel15->ra_preamble_index&0x3f)<<(dci_size-pos));
+	    
+	    // UL/SUL indicator  1 bit
+	    pos++;
+	    *dci_pdu |= (dci_pdu_rel15->ul_sul_indicator&1)<<(dci_size-pos);
+	    
+	    // SS/PBCH index  6 bits
+	    pos+=6;
+	    *dci_pdu |= ((dci_pdu_rel15->ss_pbch_index&0x3f)<<(dci_size-pos));
+	    
+	    //  prach_mask_index  4 bits
+	    pos+=4;
+	    *dci_pdu |= ((dci_pdu_rel15->prach_mask_index&0xf)<<(dci_size-pos));
+	    
+	  }  //end if
+	
+	else {
+	  
+	  // Time domain assignment 4bit
+	  
+	  pos+=4;
+	  *dci_pdu |= ((dci_pdu_rel15->time_domain_assignment&0xf) << (dci_size-pos));
+	  LOG_D(MAC,"Time domain assignment %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_domain_assignment,4,dci_size-pos,*dci_pdu);
+	  
+	  // VRB to PRB mapping  1bit
+	  pos++;
+	  *dci_pdu |= (dci_pdu_rel15->vrb_to_prb_mapping&1)<<(dci_size-pos);
+	  LOG_D(MAC,"VRB to PRB %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->vrb_to_prb_mapping,1,dci_size-pos,*dci_pdu);
+	  
+	  // MCS 5bit  //bit over 32, so dci_pdu ++
+	  pos+=5;
+	  *dci_pdu |= (dci_pdu_rel15->mcs&0x1f)<<(dci_size-pos);
+	  LOG_D(MAC,"MCS %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->mcs,5,dci_size-pos,*dci_pdu);
+	  
+	  // New data indicator 1bit
+	  pos++;
+	  *dci_pdu |= (dci_pdu_rel15->ndi&1)<<(dci_size-pos);
+	  LOG_D(MAC,"NDI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->ndi,1,dci_size-pos,*dci_pdu);
+	  
+	  // Redundancy version  2bit
+	  pos+=2;
+	  *dci_pdu |= (dci_pdu_rel15->rv&0x3)<<(dci_size-pos);
+	  LOG_D(MAC,"RV %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->rv,2,dci_size-pos,*dci_pdu);
+	  
+	  // HARQ process number  4bit
+	  pos+=4;
+	  *dci_pdu  |= ((dci_pdu_rel15->harq_pid&0xf)<<(dci_size-pos));
+	  LOG_D(MAC,"HARQ_PID %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->harq_pid,4,dci_size-pos,*dci_pdu);
+	  
+	  // Downlink assignment index  2bit
+	  pos+=2;
+	  *dci_pdu |= ((dci_pdu_rel15->dai&3)<<(dci_size-pos));
+	  LOG_D(MAC,"DAI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->dai,2,dci_size-pos,*dci_pdu);
+	  
+	  // TPC command for scheduled PUCCH  2bit
+	  pos+=2;
+	  *dci_pdu |= ((dci_pdu_rel15->tpc&3)<<(dci_size-pos));
+	  LOG_D(MAC,"TPC %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->tpc,2,dci_size-pos,*dci_pdu);
+	  
+	  // PUCCH resource indicator  3bit
+	  pos+=3;
+	  *dci_pdu |= ((dci_pdu_rel15->pucch_resource_indicator&0x7)<<(dci_size-pos));
+	  LOG_D(MAC,"PUCCH RI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->pucch_resource_indicator,3,dci_size-pos,*dci_pdu);
+	  
+	  // PDSCH-to-HARQ_feedback timing indicator 3bit
+	  pos+=3;
+	  *dci_pdu |= ((dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator&0x7)<<(dci_size-pos));
+	  LOG_D(MAC,"PDSCH to HARQ TI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator,3,dci_size-pos,*dci_pdu);
+	  
+	} //end else
+	break;
+	
+      case NR_RNTI_P:
+	
+	// Short Messages Indicator – 2 bits
+	for (int i=0; i<2; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages_indicator>>(1-i))&1)<<(dci_size-pos++);
+	// Short Messages – 8 bits
+	for (int i=0; i<8; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages>>(7-i))&1)<<(dci_size-pos++);
+	// Freq domain assignment 0-16 bit
+	fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+	for (int i=0; i<fsize; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_size-pos++);
+	// Time domain assignment 4 bit
+	for (int i=0; i<4; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_size-pos++);
+	// VRB to PRB mapping 1 bit
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping&1)<<(dci_size-pos++);
+	// MCS 5 bit
+	for (int i=0; i<5; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs>>(4-i))&1)<<(dci_size-pos++);
+	
+	// TB scaling 2 bit
+	for (int i=0; i<2; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->tb_scaling>>(1-i))&1)<<(dci_size-pos++);
+	
+	
+	break;
+	
+      case NR_RNTI_SI:
+	// Freq domain assignment 0-16 bit
+	fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+	for (int i=0; i<fsize; i++)
+	  *dci_pdu |= ((dci_pdu_rel15->frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_size-pos++);
+	// Time domain assignment 4 bit
+	for (int i=0; i<4; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_size-pos++);
+	// VRB to PRB mapping 1 bit
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping&1)<<(dci_size-pos++);
+	// MCS 5bit  //bit over 32, so dci_pdu ++
+	for (int i=0; i<5; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs>>(4-i))&1)<<(dci_size-pos++);
+	// Redundancy version  2bit
+	for (int i=0; i<2; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->rv>>(1-i))&1)<<(dci_size-pos++);
+	
+	break;
+	
+      case NR_RNTI_TC:
+	// indicating a DL DCI format 1bit
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator&1)<<(dci_size-pos++);
+	// Freq domain assignment 0-16 bit
+	fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+	for (int i=0; i<fsize; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_size-pos++);
+	// Time domain assignment 4 bit
+	for (int i=0; i<4; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_size-pos++);
+	// VRB to PRB mapping 1 bit
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping&1)<<(dci_size-pos++);
+	// MCS 5bit  //bit over 32, so dci_pdu ++
+	for (int i=0; i<5; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs>>(4-i))&1)<<(dci_size-pos++);
+	// New data indicator 1bit
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi&1)<<(dci_size-pos++);
+	// Redundancy version  2bit
+	for (int i=0; i<2; i++)
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->rv>>(1-i))&1)<<(dci_size-pos++);
+	// HARQ process number  4bit
+	for (int i=0; i<4; i++)
+	  *dci_pdu  |= (((uint64_t)dci_pdu_rel15->harq_pid>>(3-i))&1)<<(dci_size-pos++);
+	
+	// Downlink assignment index – 2 bits
+	for (int i=0; i<2; i++)
+	  *dci_pdu  |= (((uint64_t)dci_pdu_rel15->dai>>(1-i))&1)<<(dci_size-pos++);
+	
+	// TPC command for scheduled PUCCH – 2 bits
+	for (int i=0; i<2; i++)
+	  *dci_pdu  |= (((uint64_t)dci_pdu_rel15->tpc>>(1-i))&1)<<(dci_size-pos++);
+	
+	
+	//      LOG_D(MAC, "DCI PDU: [0]->0x%08llx \t [1]->0x%08llx \t [2]->0x%08llx \t [3]->0x%08llx\n",
+	//	    dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]);
+	
+	
+	// PDSCH-to-HARQ_feedback timing indicator – 3 bits
+	for (int i=0; i<3; i++)
+	  *dci_pdu  |= (((uint64_t)dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator>>(2-i))&1)<<(dci_size-pos++);
+	
+	break;
+      }
+      break;
+      
+    case NR_UL_DCI_FORMAT_0_0:
+      switch(rnti_types[d])
+	{
+	case NR_RNTI_C:
+	  // indicating a DL DCI format 1bit
+	  *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator&1)<<(dci_size-pos++);
+	  // Freq domain assignment  max 16 bit
+	  fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+	  for (int i=0; i<fsize; i++)
+	    *dci_pdu |= ((dci_pdu_rel15->frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_size-pos++);
+	  // Time domain assignment 4bit
+	  for (int i=0; i<4; i++)
+	    *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_size-pos++);
+	  // Frequency hopping flag – 1 bit
+	  *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_hopping_flag&1)<<(dci_size-pos++);
+	  // MCS  5 bit
+	  for (int i=0; i<5; i++)
+	    *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs>>(4-i))&1)<<(dci_size-pos++);
+	  // New data indicator 1bit
+	  *dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi&1)<<(dci_size-pos++);
+	  // Redundancy version  2bit
+	  for (int i=0; i<2; i++)
+	    *dci_pdu |= (((uint64_t)dci_pdu_rel15->rv>>(1-i))&1)<<(dci_size-pos++);
+	  // HARQ process number  4bit
+	  for (int i=0; i<4; i++)
+	    *dci_pdu  |= (((uint64_t)dci_pdu_rel15->harq_pid>>(3-i))&1)<<(dci_size-pos++);
+	  
+	  // TPC command for scheduled PUSCH – 2 bits
+	  for (int i=0; i<2; i++)
+	    *dci_pdu |= (((uint64_t)dci_pdu_rel15->tpc>>(1-i))&1)<<(dci_size-pos++);
+	  
+	  // Padding bits
+	  for(int a = pos;a<32;a++)
+	    *dci_pdu |= ((uint64_t)dci_pdu_rel15->padding&1)<<(dci_size-pos++);
+	  
+	  // UL/SUL indicator – 1 bit
+	  /* commented for now (RK): need to get this from BWP descriptor
+	  if (cfg->pucch_config.pucch_GroupHopping.value)
+	    *dci_pdu |= ((uint64_t)dci_pdu_rel15->ul_sul_indicator&1)<<(dci_size-pos++);
+	    */
+	  break;
+	  
+	case NFAPI_NR_RNTI_TC:
+	  
+	  // indicating a DL DCI format 1bit
+	  *dci_pdu |= (dci_pdu_rel15->format_indicator&1)<<(dci_size-pos++);
+	  // Freq domain assignment  max 16 bit
+	  fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+	  for (int i=0; i<fsize; i++)
+	    *dci_pdu |= ((dci_pdu_rel15->frequency_domain_assignment>>(fsize-i-1))&1)<<(dci_size-pos++);
+	  // Time domain assignment 4bit
+	  for (int i=0; i<4; i++)
+	    *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment>>(3-i))&1)<<(dci_size-pos++);
+	  // Frequency hopping flag – 1 bit
+	  *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_hopping_flag&1)<<(dci_size-pos++);
+	  // MCS  5 bit
+	  for (int i=0; i<5; i++)
+	    *dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs>>(4-i))&1)<<(dci_size-pos++);
+	  // New data indicator 1bit
+	  *dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi&1)<<(dci_size-pos++);
+	  // Redundancy version  2bit
+	  for (int i=0; i<2; i++)
+	    *dci_pdu |= (((uint64_t)dci_pdu_rel15->rv>>(1-i))&1)<<(dci_size-pos++);
+	  // HARQ process number  4bit
+	  for (int i=0; i<4; i++)
+	    *dci_pdu  |= (((uint64_t)dci_pdu_rel15->harq_pid>>(3-i))&1)<<(dci_size-pos++);
+	  
+	  // TPC command for scheduled PUSCH – 2 bits
+	  for (int i=0; i<2; i++)
+	    *dci_pdu |= (((uint64_t)dci_pdu_rel15->tpc>>(1-i))&1)<<(dci_size-pos++);
+	  
+	  // Padding bits
+	  for(int a = pos;a<32;a++)
+	    *dci_pdu |= ((uint64_t)dci_pdu_rel15->padding&1)<<(dci_size-pos++);
+	  
+	  // UL/SUL indicator – 1 bit
+	  /*
+	    commented for now (RK): need to get this information from BWP descriptor
+	    if (cfg->pucch_config.pucch_GroupHopping.value)
+	    *dci_pdu |= ((uint64_t)dci_pdu_rel15->ul_sul_indicator&1)<<(dci_size-pos++);
+	    */
+	  break;
+	  
+	    }
       break;
     }
-
-  //searchSpaceType
-  pdcch_params->search_space_type = search_space->search_space_type;
-
-  pdcch_params->n_RB_BWP = N_RB;
+  }
 }
 
-int nr_is_dci_opportunity(nfapi_nr_search_space_t search_space,
-                                nfapi_nr_coreset_t coreset,
-                                uint16_t frame,
-                                uint16_t slot,
-                                nfapi_nr_config_request_t cfg) {
-
-  AssertFatal(search_space.coreset_id==coreset.coreset_id, "Invalid association of coreset(%d) and search space(%d)\n",
-  search_space.search_space_id, coreset.coreset_id);
-
-  uint8_t is_dci_opportunity=0;
-  uint16_t Ks=search_space.slot_monitoring_periodicity;
-  uint16_t Os=search_space.slot_monitoring_offset;
-  uint8_t Ts=search_space.duration;
-
-  if (((frame*get_spf(&cfg) + slot - Os)%Ks)<Ts)
+  
+    /*
+      int nr_is_dci_opportunity(nfapi_nr_search_space_t search_space,
+      nfapi_nr_coreset_t coreset,
+      uint16_t frame,
+      uint16_t slot,
+      nfapi_nr_config_request_scf_t cfg) {
+      
+      AssertFatal(search_space.coreset_id==coreset.coreset_id, "Invalid association of coreset(%d) and search space(%d)\n",
+      search_space.search_space_id, coreset.coreset_id);
+      
+      uint8_t is_dci_opportunity=0;
+      uint16_t Ks=search_space.slot_monitoring_periodicity;
+      uint16_t Os=search_space.slot_monitoring_offset;
+      uint8_t Ts=search_space.duration;
+      
+      if (((frame*get_spf(&cfg) + slot - Os)%Ks)<Ts)
     is_dci_opportunity=1;
 
   return is_dci_opportunity;
 }
+*/
 
-int get_dlscs(nfapi_nr_config_request_t *cfg) {
-
-  return(cfg->rf_config.dl_subcarrierspacing.value);
-}
+int get_spf(nfapi_nr_config_request_scf_t *cfg) {
 
-
-int get_ulscs(nfapi_nr_config_request_t *cfg) {
-
-  return(cfg->rf_config.ul_subcarrierspacing.value);
-} 
-
-int get_spf(nfapi_nr_config_request_t *cfg) {
-
-  int mu = cfg->rf_config.dl_subcarrierspacing.value;
+  int mu = cfg->ssb_config.scs_common.value;
   AssertFatal(mu>=0&&mu<4,"Illegal scs %d\n",mu);
 
   return(10 * (1<<mu));
 } 
 
-int to_absslot(nfapi_nr_config_request_t *cfg,int frame,int slot) {
+int to_absslot(nfapi_nr_config_request_scf_t *cfg,int frame,int slot) {
 
   return(get_spf(cfg)*frame) + slot; 
 
 }
 
-int get_symbolsperslot(nfapi_nr_config_request_t *cfg) {
 
-  return ((cfg->subframe_config.dl_cyclic_prefix_type.value==NFAPI_CP_EXTENDED)?12:14);
+int extract_startSymbol(int startSymbolAndLength) {
+  int tmp = startSymbolAndLength/14;
+  int tmp2 = startSymbolAndLength%14;
 
+  if (tmp > 0 && tmp < (14-tmp2)) return(tmp2);
+  else                            return(13-tmp2);
 }
 
-int find_nrUE_id(module_id_t mod_idP, rnti_t rntiP) {
-  
+int extract_length(int startSymbolAndLength) {
+  int tmp = startSymbolAndLength/14;
+  int tmp2 = startSymbolAndLength%14;
+
+  if (tmp > 0 && tmp < (14-tmp2)) return(tmp);
+  else                            return(15-tmp2);
+}
+
+/*
+ * Dump the UL or DL UE_list into LOG_T(MAC)
+ */
+void
+dump_nr_ue_list(NR_UE_list_t *listP,
+             int ul_flag)
+//------------------------------------------------------------------------------
+{
+  if (ul_flag == 0) {
+    for (int j = listP->head; j >= 0; j = listP->next[j]) {
+      LOG_T(MAC, "DL list node %d => %d\n",
+            j,
+            listP->next[j]);
+    }
+  } else {
+    for (int j = listP->head_ul; j >= 0; j = listP->next_ul[j]) {
+      LOG_T(MAC, "UL list node %d => %d\n",
+            j,
+            listP->next_ul[j]);
+    }
+  }
+
+  return;
+}
+
+int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP)
+//------------------------------------------------------------------------------
+{
   int UE_id;
-  UE_list_t *UE_list = &RC.nrmac[mod_idP]->UE_list;
+  NR_UE_list_t *UE_list = &RC.nrmac[mod_idP]->UE_list;
 
   for (UE_id = 0; UE_id < MAX_MOBILES_PER_GNB; UE_id++) {
     if (UE_list->active[UE_id] == TRUE) {
-      if (UE_list->UE_template[nrUE_PCCID(mod_idP, UE_id)][UE_id].rnti == rntiP) {
+      if (UE_list->rnti[UE_id] == rntiP) {
         return UE_id;
       }
     }
   }
+
   return -1;
 }
 
-int nrUE_PCCID(module_id_t mod_idP, int ue_idP) {
-  return (RC.nrmac[mod_idP]->UE_list.pCC_id[ue_idP]);
+int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){
+
+  int UE_id;
+  int i;
+  NR_UE_list_t *UE_list = &RC.nrmac[mod_idP]->UE_list;
+  LOG_I(MAC, "[gNB %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n",
+        mod_idP,
+        rntiP,
+        UE_list->avail,
+        UE_list->num_UEs);
+  dump_nr_ue_list(UE_list, 0);
+
+  for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
+    if (UE_list->active[i] == TRUE)
+      continue;
+
+    UE_id = i;
+    UE_list->num_UEs++;
+    UE_list->active[UE_id] = TRUE;
+    UE_list->rnti[UE_id] = rntiP;
+    memset((void *) &UE_list->UE_sched_ctrl[UE_id],
+           0,
+           sizeof(NR_UE_sched_ctrl_t));
+    LOG_I(MAC, "gNB %d] Add NR UE_id %d : rnti %x\n",
+          mod_idP,
+          UE_id,
+          rntiP);
+    dump_nr_ue_list(UE_list,
+		    0);
+    return (UE_id);
+  }
+
+  // printf("MAC: cannot add new UE for rnti %x\n", rntiP);
+  LOG_E(MAC, "error in add_new_ue(), could not find space in UE_list, Dumping UE list\n");
+  dump_nr_ue_list(UE_list,
+		  0);
+  return -1;
+}
+
+/*void fill_nfapi_coresets_and_searchspaces(NR_CellGroupConfig_t *cg,
+					  nfapi_nr_coreset_t *coreset,
+					  nfapi_nr_search_space_t *search_space) {
+
+  nfapi_nr_coreset_t *cs;
+  nfapi_nr_search_space_t *ss;
+  NR_ServingCellConfigCommon_t *scc=cg->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
+  AssertFatal(cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1,
+	      "downlinkBWP_ToAddModList has %d BWP!\n",
+	      cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count);
+
+  NR_BWP_Downlink_t *bwp=cg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[0];
+  struct NR_PDCCH_Config__controlResourceSetToAddModList *coreset_list = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList;
+  AssertFatal(coreset_list->list.count>0,
+	      "cs list has 0 elements\n");
+  for (int i=0;i<coreset_list->list.count;i++) {
+    NR_ControlResourceSet_t *coreset_i=coreset_list->list.array[i];
+    cs = coreset + coreset_i->controlResourceSetId;
+      
+    cs->coreset_id = coreset_i->controlResourceSetId;
+    AssertFatal(coreset_i->frequencyDomainResources.size <=8 && coreset_i->frequencyDomainResources.size>0,
+		"coreset_i->frequencyDomainResources.size=%d\n",
+		(int)coreset_i->frequencyDomainResources.size);
+  
+    for (int f=0;f<coreset_i->frequencyDomainResources.size;f++)
+      ((uint8_t*)&cs->frequency_domain_resources)[coreset_i->frequencyDomainResources.size-1-f]=coreset_i->frequencyDomainResources.buf[f];
+    
+    cs->frequency_domain_resources>>=coreset_i->frequencyDomainResources.bits_unused;
+    
+    cs->duration = coreset_i->duration;
+    // Need to add information about TCI_StateIDs
+
+    if (coreset_i->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved)
+      cs->cce_reg_mapping_type = NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED;
+    else {
+      cs->cce_reg_mapping_type = NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED;
+
+      if (coreset_i->cce_REG_MappingType.choice.interleaved->reg_BundleSize==NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6)
+	cs->reg_bundle_size = 6;
+      else cs->reg_bundle_size = 2+coreset_i->cce_REG_MappingType.choice.interleaved->reg_BundleSize;
+
+      if (coreset_i->cce_REG_MappingType.choice.interleaved->interleaverSize==NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n6)
+	cs->interleaver_size = 6;
+      else cs->interleaver_size = 2+coreset_i->cce_REG_MappingType.choice.interleaved->interleaverSize;
+
+      if (coreset_i->cce_REG_MappingType.choice.interleaved->shiftIndex)
+	cs->shift_index = *coreset_i->cce_REG_MappingType.choice.interleaved->shiftIndex;
+      else cs->shift_index = 0;
+    }
+    
+    if (coreset_i->precoderGranularity == NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle)
+      cs->precoder_granularity = NFAPI_NR_CSET_SAME_AS_REG_BUNDLE;
+    else cs->precoder_granularity = NFAPI_NR_CSET_ALL_CONTIGUOUS_RBS;
+    if (coreset_i->tci_PresentInDCI == NULL) cs->tci_present_in_dci = 0;
+    else                                     cs->tci_present_in_dci = 1;
+
+    if (coreset_i->tci_PresentInDCI == NULL) cs->dmrs_scrambling_id = 0;
+    else                                     cs->dmrs_scrambling_id = *coreset_i->tci_PresentInDCI;
+  }
+
+  struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList;
+  AssertFatal(commonSearchSpaceList->list.count>0,
+	      "common SearchSpace list has 0 elements\n");
+  // Common searchspace list
+  for (int i=0;i<commonSearchSpaceList->list.count;i++) {
+    NR_SearchSpace_t *searchSpace_i=commonSearchSpaceList->list.array[i];  
+    ss=search_space + searchSpace_i->searchSpaceId;
+    if (searchSpace_i->controlResourceSetId) ss->coreset_id = *searchSpace_i->controlResourceSetId;
+    switch(searchSpace_i->monitoringSlotPeriodicityAndOffset->present) {
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL1;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL2;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl2;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL4;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl4;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL5;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl5;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL8;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl8;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL10;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl10;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL16;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl16;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL20;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl20;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL40;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl40;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL80;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl80;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL160;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl160;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL320;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl320;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL640;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl640;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL1280;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl1280;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL2560;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl2560;
+      break;
+    default:
+      AssertFatal(1==0,"Shouldn't get here\n");
+      break;    
+    }
+    if (searchSpace_i->duration) ss->duration = *searchSpace_i->duration;
+    else                         ss->duration = 1;
+
+
+    AssertFatal(searchSpace_i->monitoringSymbolsWithinSlot->size == 2,
+		"ss_i->monitoringSymbolsWithinSlot = %d != 2\n",
+		(int)searchSpace_i->monitoringSymbolsWithinSlot->size);
+    ((uint8_t*)&ss->monitoring_symbols_in_slot)[1] = searchSpace_i->monitoringSymbolsWithinSlot->buf[0];
+    ((uint8_t*)&ss->monitoring_symbols_in_slot)[0] = searchSpace_i->monitoringSymbolsWithinSlot->buf[1];
+
+    AssertFatal(searchSpace_i->nrofCandidates!=NULL,"searchSpace_%d->nrofCandidates is null\n",(int)searchSpace_i->searchSpaceId);
+    if (searchSpace_i->nrofCandidates->aggregationLevel1 == NR_SearchSpace__nrofCandidates__aggregationLevel1_n8)
+      ss->number_of_candidates[0] = 8;
+    else ss->number_of_candidates[0] = searchSpace_i->nrofCandidates->aggregationLevel1;
+    if (searchSpace_i->nrofCandidates->aggregationLevel2 == NR_SearchSpace__nrofCandidates__aggregationLevel2_n8)
+      ss->number_of_candidates[1] = 8;
+    else ss->number_of_candidates[1] = searchSpace_i->nrofCandidates->aggregationLevel2;
+    if (searchSpace_i->nrofCandidates->aggregationLevel4 == NR_SearchSpace__nrofCandidates__aggregationLevel4_n8)
+      ss->number_of_candidates[2] = 8;
+    else ss->number_of_candidates[2] = searchSpace_i->nrofCandidates->aggregationLevel4;
+    if (searchSpace_i->nrofCandidates->aggregationLevel8 == NR_SearchSpace__nrofCandidates__aggregationLevel8_n8)
+      ss->number_of_candidates[3] = 8;
+    else ss->number_of_candidates[3] = searchSpace_i->nrofCandidates->aggregationLevel8;
+    if (searchSpace_i->nrofCandidates->aggregationLevel16 == NR_SearchSpace__nrofCandidates__aggregationLevel16_n8)
+      ss->number_of_candidates[4] = 8;
+    else ss->number_of_candidates[4] = searchSpace_i->nrofCandidates->aggregationLevel16;      
+
+    AssertFatal(searchSpace_i->searchSpaceType->present==NR_SearchSpace__searchSpaceType_PR_common,
+		"searchspace %d is not common\n",(int)searchSpace_i->searchSpaceId);
+    AssertFatal(searchSpace_i->searchSpaceType->choice.common!=NULL,
+		"searchspace %d common is null\n",(int)searchSpace_i->searchSpaceId);
+    ss->search_space_type = NFAPI_NR_SEARCH_SPACE_TYPE_COMMON;
+    if (searchSpace_i->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)
+      ss->css_formats_0_0_and_1_0 = 1;
+    if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_0) {
+      ss->css_format_2_0 = 1;
+      // add aggregation info
+    }
+    if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_1)
+      ss->css_format_2_1 = 1;
+    if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_2)
+      ss->css_format_2_2 = 1;
+    if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_3)
+      ss->css_format_2_3 = 1;
+  }
+
+  struct NR_PDCCH_Config__searchSpacesToAddModList *dedicatedSearchSpaceList = bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList;
+  AssertFatal(dedicatedSearchSpaceList->list.count>0,
+	      "Dedicated Search Space list has 0 elements\n");
+  // Dedicated searchspace list
+  for (int i=0;i<dedicatedSearchSpaceList->list.count;i++) {
+    NR_SearchSpace_t *searchSpace_i=dedicatedSearchSpaceList->list.array[i];  
+    ss=search_space + searchSpace_i->searchSpaceId;
+    ss->search_space_id = searchSpace_i->searchSpaceId;
+    if (searchSpace_i->controlResourceSetId) ss->coreset_id = *searchSpace_i->controlResourceSetId;
+    switch(searchSpace_i->monitoringSlotPeriodicityAndOffset->present) {
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL1;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL2;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl2;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL4;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl4;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL5;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl5;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL8;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl8;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL10;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl10;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL16;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl16;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL20;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl20;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL40;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl40;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL80;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl80;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL160;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl160;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL320;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl320;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL640;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl640;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL1280;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl1280;
+      break;
+    case NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560:
+      ss->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL2560;
+      ss->slot_monitoring_offset = searchSpace_i->monitoringSlotPeriodicityAndOffset->choice.sl2560;
+      break;
+    default:
+      AssertFatal(1==0,"Shouldn't get here\n");
+      break;    
+    }
+    if (searchSpace_i->duration) ss->duration = *searchSpace_i->duration;
+    else                         ss->duration = 1;
+    
+    
+    AssertFatal(searchSpace_i->monitoringSymbolsWithinSlot->size == 2,
+		"ss_i->monitoringSymbolsWithinSlot = %d != 2\n",
+		(int)searchSpace_i->monitoringSymbolsWithinSlot->size);
+    ((uint8_t*)&ss->monitoring_symbols_in_slot)[1] = searchSpace_i->monitoringSymbolsWithinSlot->buf[0];
+    ((uint8_t*)&ss->monitoring_symbols_in_slot)[0] = searchSpace_i->monitoringSymbolsWithinSlot->buf[1];
+    
+    AssertFatal(searchSpace_i->nrofCandidates!=NULL,"searchSpace_%d->nrofCandidates is null\n",(int)searchSpace_i->searchSpaceId);
+    if (searchSpace_i->nrofCandidates->aggregationLevel1 == NR_SearchSpace__nrofCandidates__aggregationLevel1_n8)
+      ss->number_of_candidates[0] = 8;
+    else ss->number_of_candidates[0] = searchSpace_i->nrofCandidates->aggregationLevel1;
+    if (searchSpace_i->nrofCandidates->aggregationLevel2 == NR_SearchSpace__nrofCandidates__aggregationLevel2_n8)
+      ss->number_of_candidates[1] = 8;
+    else ss->number_of_candidates[1] = searchSpace_i->nrofCandidates->aggregationLevel2;
+    if (searchSpace_i->nrofCandidates->aggregationLevel4 == NR_SearchSpace__nrofCandidates__aggregationLevel4_n8)
+      ss->number_of_candidates[2] = 8;
+    else ss->number_of_candidates[2] = searchSpace_i->nrofCandidates->aggregationLevel4;
+    if (searchSpace_i->nrofCandidates->aggregationLevel8 == NR_SearchSpace__nrofCandidates__aggregationLevel8_n8)
+      ss->number_of_candidates[3] = 8;
+    else ss->number_of_candidates[3] = searchSpace_i->nrofCandidates->aggregationLevel8;
+    if (searchSpace_i->nrofCandidates->aggregationLevel16 == NR_SearchSpace__nrofCandidates__aggregationLevel16_n8)
+      ss->number_of_candidates[4] = 8;
+    else ss->number_of_candidates[4] = searchSpace_i->nrofCandidates->aggregationLevel16;      
+    
+    if (searchSpace_i->searchSpaceType->present==NR_SearchSpace__searchSpaceType_PR_ue_Specific && searchSpace_i->searchSpaceType->choice.ue_Specific!=NULL) {
+      
+      ss->search_space_type = NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC;
+      
+      ss->uss_dci_formats = searchSpace_i->searchSpaceType->choice.ue_Specific-> dci_Formats;
+      
+    } else if (searchSpace_i->searchSpaceType->present==NR_SearchSpace__searchSpaceType_PR_common && searchSpace_i->searchSpaceType->choice.common!=NULL) {
+      ss->search_space_type = NFAPI_NR_SEARCH_SPACE_TYPE_COMMON;
+      
+      if (searchSpace_i->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)
+	ss->css_formats_0_0_and_1_0 = 1;
+      if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_0) {
+	ss->css_format_2_0 = 1;
+	// add aggregation info
+      }
+      if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_1)
+	ss->css_format_2_1 = 1;
+      if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_2)
+	ss->css_format_2_2 = 1;
+      if (searchSpace_i->searchSpaceType->choice.common->dci_Format2_3)
+	ss->css_format_2_3 = 1;
+    }
+  }
 }
+*/
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
index 95ae4a8e303..ade52006273 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
@@ -222,7 +222,10 @@ void nr_process_mac_pdu(
         pdu_ptr += ( mac_subheader_len + mac_ce_len + mac_sdu_len );
         pdu_len -= ( mac_subheader_len + mac_ce_len + mac_sdu_len );
 
-        AssertFatal(pdu_len >= 0, "[MAC] nr_process_mac_pdu, residual mac pdu length < 0!\n");
+        if (pdu_len < 0) {
+          LOG_E(MAC, "%s() residual mac pdu length < 0!\n", __func__);
+          return;
+        }
     }
 }
 
@@ -241,20 +244,18 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
                const uint8_t ul_cqi){
   int current_rnti = 0, UE_id = -1, harq_pid = 0;
   gNB_MAC_INST *gNB_mac = NULL;
-  UE_list_t *UE_list = NULL;
+  NR_UE_list_t *UE_list = NULL;
   UE_sched_ctrl_t *UE_scheduling_control = NULL;
 
   current_rnti = rntiP;
-  UE_id = find_nrUE_id(gnb_mod_idP, current_rnti);
+  UE_id = find_nr_UE_id(gnb_mod_idP, current_rnti);
   gNB_mac = RC.nrmac[gnb_mod_idP];
   UE_list = &gNB_mac->UE_list;
 
-  UE_id = 0;
-
   if (UE_id != -1) {
     UE_scheduling_control = &(UE_list->UE_sched_ctrl[UE_id]);
 
-    LOG_D(MAC, "[eNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu round %d from PHY (rnti %x, UE_id %d) ul_cqi %d\n",
+    LOG_D(MAC, "[gNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu round %d from PHY (rnti %x, UE_id %d) ul_cqi %d\n",
           gnb_mod_idP,
           harq_pid,
           CC_idP,
diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
index 744f1a22249..d55a188817d 100644
--- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
+++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
@@ -40,27 +40,18 @@ void set_cset_offset(uint16_t);
 void mac_top_init_gNB(void);
 
 void config_common(int Mod_idP,
-                   int CC_idP,
-                   int Nid_cell,
-                   int nr_bandP,
-                   uint64_t ssb_pattern,
-                   uint16_t ssb_periodicity,
-                   uint64_t dl_CarrierFreqP,
-                   uint32_t dl_BandwidthP);
+                   int pdsch_AntennaPorts,
+		   NR_ServingCellConfigCommon_t *scc
+		   );
 
 int rrc_mac_config_req_gNB(module_id_t Mod_idP, 
-                           int CC_id,
-                           int cellid,
-                           int p_gNB,
-                           int nr_bandP,
-                           uint64_t ssb_pattern,
-                           uint16_t ssb_periodicity,
-                           uint64_t dl_CarrierFreqP,
-                           int dl_BandwidthP,
-                           NR_BCCH_BCH_Message_t *mib,
-                           NR_ServingCellConfigCommon_t *servingcellconfigcommon);
-
-int  is_nr_UL_slot(NR_COMMON_channels_t * ccP, int slotP);
+			   int ssb_SubcarrierOffset,
+                           int pdsch_AntennaPorts,
+                           NR_ServingCellConfigCommon_t *scc,
+			   int nsa_flag,
+			   uint32_t rnti,
+			   NR_CellGroupConfig_t *secondaryCellGroup
+                           );
 
 void clear_nr_nfapi_information(gNB_MAC_INST * gNB, 
                                 int CC_idP,
@@ -89,27 +80,33 @@ void nr_schedule_css_dlsch_phytest(module_id_t   module_idP,
                                    frame_t       frameP,
                                    sub_frame_t   subframeP);
 
-int configure_fapi_dl_pdu(nfapi_nr_dl_config_request_body_t *dl_req,
-                          nfapi_nr_config_request_t *cfg,
-                          nfapi_nr_coreset_t* coreset,
-                          nfapi_nr_search_space_t* search_space,
-                          nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config);
+int configure_fapi_dl_pdu(int Mod_id,
+                         int *CCEIndeces,
+                         nfapi_nr_dl_tti_request_body_t *dl_req,
+                         uint8_t *mcsIndex,
+                         uint16_t *rbSize,
+                         uint16_t *rbStart);
+
+void config_uldci(NR_BWP_Uplink_t *ubwp,nfapi_nr_pusch_pdu_t *pusch_pdu,nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15, dci_pdu_rel15_t *dci_pdu_rel15, int *dci_formats, int *rnti_types);
 
-void configure_fapi_dl_Tx(nfapi_nr_dl_config_request_body_t *dl_req,
-                          nfapi_tx_request_pdu_t *tx_req,
+void configure_fapi_dl_Tx(module_id_t Mod_idP,
+                          frame_t       frameP,
+                          sub_frame_t   slotP,
+                          nfapi_nr_dl_tti_request_body_t *dl_req,
+                          nfapi_nr_pdu_t *tx_req,
                           int tbs_bytes,
                           int16_t pdu_index);
 
 void nr_schedule_uss_dlsch_phytest(module_id_t   module_idP,
                                    frame_t       frameP,
                                    sub_frame_t   slotP,
-                                   nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config);
+                                   nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_config);
 
-void nr_schedule_uss_ulsch_phytest(nfapi_nr_ul_tti_request_t *UL_tti_req,
+void nr_schedule_uss_ulsch_phytest(int Mod_idP,
                                    frame_t       frameP,
                                    sub_frame_t   slotP);
   
-void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params,
+void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
                                   nr_scs_e scs_common,
                                   nr_scs_e pdcch_scs,
                                   nr_frequency_range_e freq_range,
@@ -120,40 +117,75 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* p
                                   uint8_t n_ssb,
                                   uint16_t nb_slots_per_frame,
                                   uint16_t N_RB);
-
+/*
 int nr_is_dci_opportunity(nfapi_nr_search_space_t search_space,
                           nfapi_nr_coreset_t coreset,
                           uint16_t frame,
                           uint16_t slot,
-                          nfapi_nr_config_request_t cfg);
+                          nfapi_nr_config_request_scf_t cfg);
+*/
 
-void nr_configure_dci_from_pdcch_config(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params,
-                                        nfapi_nr_coreset_t* coreset,
-                                        nfapi_nr_search_space_t* search_space,
-                                        nfapi_nr_config_request_t cfg,
-                                        uint16_t N_RB);
+void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
+                        int ss_type,
+                        NR_ServingCellConfigCommon_t *scc,
+                        NR_BWP_Downlink_t *bwp);
 
-int get_dlscs(nfapi_nr_config_request_t *cfg);
+void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
+                        dci_pdu_rel15_t *dci_pdu_rel15,
+                        int *dci_formats,
+                        int *rnti_types);
 
-int get_ulscs(nfapi_nr_config_request_t *cfg);
+int get_spf(nfapi_nr_config_request_scf_t *cfg);
 
-int get_spf(nfapi_nr_config_request_t *cfg);
+int to_absslot(nfapi_nr_config_request_scf_t *cfg,int frame,int slot);
 
-int to_absslot(nfapi_nr_config_request_t *cfg,int frame,int slot);
+void get_band(uint64_t downlink_frequency, uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type);
 
-int get_symbolsperslot(nfapi_nr_config_request_t *cfg);
+void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
+		   int x_overhead);
+/** \brief Computes Q based on I_MCS PDSCH and table_idx for downlink. Implements MCS Tables from 38.214. */
+uint8_t nr_get_Qm_dl(uint8_t Imcs, uint8_t table_idx);
+uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx);
 
-void get_band(uint32_t downlink_frequency, uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type);
+/** \brief Computes Q based on I_MCS PDSCH and table_idx for uplink. Implements MCS Tables from 38.214. */
+uint8_t nr_get_Qm_ul(uint8_t Imcs, uint8_t table_idx);
+uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx);
 
-uint64_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn);
+int NRRIV2BW(int locationAndBandwidth,int N_RB);
 
-uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint32_t bw);
+int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB);
 
-int32_t get_nr_uldl_offset(int nr_bandP);
+void dump_nr_ue_list(NR_UE_list_t *listP, int ul_flag);
+
+int find_nr_UE_id(module_id_t mod_idP, rnti_t rntiP);
+
+int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP);
 
-int find_nrUE_id(module_id_t mod_idP, rnti_t rntiP);
+int get_num_dmrs(uint16_t dmrs_mask );
 
-int nrUE_PCCID(module_id_t mod_idP, int ue_idP);
+uint16_t nr_dci_size(nr_dci_format_t format,
+                         nr_rnti_type_t rnti_type,
+                         uint16_t N_RB);
+
+int allocate_nr_CCEs(gNB_MAC_INST *nr_mac,
+                     int bwp_id,
+                     int coreset_id,
+                     int aggregation,
+                     int search_space, // 0 common, 1 ue-specific
+                     int UE_id,
+                     int m
+                     );
+
+int is_nr_DL_slot(NR_ServingCellConfigCommon_t *scc,slot_t slotP);
+int is_nr_UL_slot(NR_ServingCellConfigCommon_t *scc,slot_t slotP);
+
+int get_dlscs(nfapi_nr_config_request_t *cfg);
+
+int get_ulscs(nfapi_nr_config_request_t *cfg);
+
+int get_symbolsperslot(nfapi_nr_config_request_t *cfg);
+
+int32_t get_nr_uldl_offset(int nr_bandP);
 
 void config_nr_mib(int Mod_idP, 
                    int CC_idP,
@@ -183,12 +215,12 @@ void nr_process_mac_pdu(
 @param ul_cqi Uplink CQI estimate after this pdu (SNR quantized to 8 bits, -64 ... 63.5 dB in .5dB steps)
 */
 void nr_rx_sdu(const module_id_t gnb_mod_idP,
-      const int CC_idP,
-      const frame_t frameP,
-      const sub_frame_t subframeP,
-      const rnti_t rntiP,
-      uint8_t * sduP,
-      const uint16_t sdu_lenP,
-      const uint16_t timing_advance, const uint8_t ul_cqi);
+               const int CC_idP,
+               const frame_t frameP,
+               const sub_frame_t subframeP,
+               const rnti_t rntiP,
+               uint8_t * sduP,
+               const uint16_t sdu_lenP,
+               const uint16_t timing_advance, const uint8_t ul_cqi);
 
 #endif /*__LAYER2_NR_MAC_PROTO_H__*/
diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c
index fcc3581b84f..9e8415776b6 100644
--- a/openair2/LAYER2/NR_MAC_gNB/main.c
+++ b/openair2/LAYER2/NR_MAC_gNB/main.c
@@ -44,43 +44,12 @@
 
 extern RAN_CONTEXT_t RC;
 
-void set_cset_offset(uint16_t offset_bits) {
-  RC.nrmac[0]->coreset[0][1].frequency_domain_resources >>= offset_bits;
-}
-
-void nr_init_coreset(nfapi_nr_coreset_t *coreset) {
-
-  coreset->coreset_id = 1;
-  coreset->frequency_domain_resources = 0x1E0000000000;//0x1FFFE0000000; // 96 RB starting from CRB0
-  coreset->duration = 2;
-  coreset->cce_reg_mapping_type = NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED;
-  coreset->reg_bundle_size = 6;
-  coreset->interleaver_size = 2;
-  coreset->precoder_granularity = NFAPI_NR_CSET_SAME_AS_REG_BUNDLE;
-  coreset->tci_present_in_dci = 0;
-  coreset->dmrs_scrambling_id = 0;
-}
-
-void nr_init_search_space(nfapi_nr_search_space_t *search_space)
-{
-  search_space->search_space_id = 1;
-  search_space->coreset_id = 1;
-  search_space->search_space_type = NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC;
-  search_space->duration = 5;
-  search_space->slot_monitoring_periodicity = NFAPI_NR_SS_PERIODICITY_SL10;
-  search_space->slot_monitoring_offset = 1;
-  search_space->monitoring_symbols_in_slot = 0x3000; // 14 bits field
-  search_space->css_formats_0_0_and_1_0 = 1;
-  search_space->uss_dci_formats = 0; // enum to be defined-- formats 0.0 and 1.0
-  for (int i=0; i<NFAPI_NR_MAX_NB_CCE_AGGREGATION_LEVELS; i++)
-    search_space->number_of_candidates[i] = 4; // TODO
-}
 
 void mac_top_init_gNB(void)
 {
-  module_id_t     i,j;
+  module_id_t     i;
   int             list_el;
-  UE_list_t       *UE_list;
+  NR_UE_list_t    *UE_list;
   gNB_MAC_INST    *nrmac;
 
   LOG_I(MAC, "[MAIN] Init function start:nb_nr_macrlc_inst=%d\n",RC.nb_nr_macrlc_inst);
@@ -88,58 +57,41 @@ void mac_top_init_gNB(void)
   if (RC.nb_nr_macrlc_inst > 0) {
 
     RC.nrmac = (gNB_MAC_INST **) malloc16(RC.nb_nr_macrlc_inst *sizeof(gNB_MAC_INST *));
-
+    
     AssertFatal(RC.nrmac != NULL,"can't ALLOCATE %zu Bytes for %d gNB_MAC_INST with size %zu \n",
                 RC.nb_nr_macrlc_inst * sizeof(gNB_MAC_INST *),
                 RC.nb_nr_macrlc_inst, sizeof(gNB_MAC_INST));
 
     for (i = 0; i < RC.nb_nr_macrlc_inst; i++) {
-        RC.nrmac[i] = (gNB_MAC_INST *) malloc16(sizeof(gNB_MAC_INST));
-
-        AssertFatal(RC.nrmac != NULL,"can't ALLOCATE %zu Bytes for %d gNB_MAC_INST with size %zu \n",
-                    RC.nb_nr_macrlc_inst * sizeof(gNB_MAC_INST *),
-                    RC.nb_nr_macrlc_inst, sizeof(gNB_MAC_INST));
-
-        LOG_D(MAC,"[MAIN] ALLOCATE %zu Bytes for %d gNB_MAC_INST @ %p\n",sizeof(gNB_MAC_INST), RC.nb_nr_macrlc_inst, RC.mac);
 
-        bzero(RC.nrmac[i], sizeof(gNB_MAC_INST));
-
-        RC.nrmac[i]->Mod_id = i;
-
-        RC.nrmac[i]->tag = (NR_TAG_t*)malloc(sizeof(NR_TAG_t));
-        memset((void*)RC.nrmac[i]->tag,0,sizeof(NR_TAG_t));
-
-
-        for (j = 0; j < MAX_NUM_CCs; j++) {
-          RC.nrmac[i]->DL_req[j].dl_config_request_body.dl_config_pdu_list = RC.nrmac[i]->dl_config_pdu_list[j];
-
-	  //FK changed UL_req to UL_tti_req, which does not contain a pointer to the pdu_list
-          //RC.nrmac[i]->UL_req[j].ul_config_request_body.ul_config_pdu_list = RC.nrmac[i]->ul_config_pdu_list[j];
-          
-          //for (int k = 0; k < 10; k++)
-          //  RC.nrmac[i]->UL_req_tmp[j][k].ul_config_request_body.ul_config_pdu_list =RC.nrmac[i]->ul_config_pdu_list_tmp[j][k];
+      RC.nrmac[i] = (gNB_MAC_INST *) malloc16(sizeof(gNB_MAC_INST));
+      
+      AssertFatal(RC.nrmac != NULL,"can't ALLOCATE %zu Bytes for %d gNB_MAC_INST with size %zu \n",
+                  RC.nb_nr_macrlc_inst * sizeof(gNB_MAC_INST *),
+                  RC.nb_nr_macrlc_inst, sizeof(gNB_MAC_INST));
+      
+      LOG_D(MAC,"[MAIN] ALLOCATE %zu Bytes for %d gNB_MAC_INST @ %p\n",sizeof(gNB_MAC_INST), RC.nb_nr_macrlc_inst, RC.mac);
+      
+      bzero(RC.nrmac[i], sizeof(gNB_MAC_INST));
+      
+      RC.nrmac[i]->Mod_id = i;
+
+      RC.nrmac[i]->tag = (NR_TAG_t*)malloc(sizeof(NR_TAG_t));
+      memset((void*)RC.nrmac[i]->tag,0,sizeof(NR_TAG_t));
         
-	  RC.nrmac[i]->HI_DCI0_req[j].hi_dci0_request_body.hi_dci0_pdu_list = RC.nrmac[i]->hi_dci0_pdu_list[j];
-	  RC.nrmac[i]->TX_req[j].tx_request_body.tx_pdu_list =                RC.nrmac[i]->tx_request_pdu[j];
-	  RC.nrmac[i]->ul_handle = 0;
-
-	  // Init PDCCH structures
-	  nr_init_coreset(&RC.nrmac[i]->coreset[j][1]);
-	  nr_init_search_space(&RC.nrmac[i]->search_space[j][1]);
-        }
-
+      RC.nrmac[i]->ul_handle = 0;
 
     }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++)
 
-  AssertFatal(rlc_module_init(1) == 0,"Could not initialize RLC layer\n");
+    AssertFatal(rlc_module_init(1) == 0,"Could not initialize RLC layer\n");
 
-  // These should be out of here later
-  pdcp_layer_init();
+    // These should be out of here later
+    pdcp_layer_init();
 
-  if(IS_SOFTMODEM_NOS1)
-	  nr_ip_over_LTE_DRB_preconfiguration();
+    if(IS_SOFTMODEM_NOS1)
+      nr_ip_over_LTE_DRB_preconfiguration();
 
-  rrc_init_nr_global_param();
+    rrc_init_nr_global_param();
 
   }else {
     RC.nrmac = NULL;
@@ -150,25 +102,23 @@ void mac_top_init_gNB(void)
 
     nrmac = RC.nrmac[i];
     nrmac->if_inst = NR_IF_Module_init(i);
-
+    
     UE_list = &nrmac->UE_list;
     UE_list->num_UEs = 0;
     UE_list->head = -1;
     UE_list->head_ul = -1;
     UE_list->avail = 0;
 
-    for (list_el = 0; list_el < MAX_MOBILES_PER_ENB - 1; list_el++) {
-      UE_list->next[list_el] = list_el + 1;
+    for (list_el = 0; list_el < MAX_MOBILES_PER_GNB - 1; list_el++) {
+       UE_list->next[list_el] = list_el + 1;
       UE_list->next_ul[list_el] = list_el + 1;
+      UE_list->active[list_el] = FALSE;
     }
 
     UE_list->next[list_el] = -1;
     UE_list->next_ul[list_el] = -1;
-    /*memset(UE_list->DLSCH_pdu, 0, sizeof(UE_list->DLSCH_pdu));
-    memset(UE_list->UE_template, 0, sizeof(UE_list->UE_template));
-    memset(UE_list->eNB_UE_stats, 0, sizeof(UE_list->eNB_UE_stats));
-    memset(UE_list->UE_sched_ctrl, 0, sizeof(UE_list->UE_sched_ctrl));
-    memset(UE_list->active, 0, sizeof(UE_list->active));*/
+    UE_list->active[list_el] = FALSE;
   }
 
+  srand48(0);
 }
diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
index 1f00203dcc6..5bc320d5e2e 100644
--- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
+++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
@@ -47,7 +47,6 @@
 #include "NR_ServingCellConfigCommon.h"
 #include "NR_MeasConfig.h"
 
-#include "nfapi_nr_interface.h"
 #include "nfapi_nr_interface_scf.h"
 #include "NR_PHY_INTERFACE/NR_IF_Module.h"
 
@@ -60,44 +59,71 @@
 #include "PHY/TOOLS/time_meas.h"
 #include "targets/ARCH/COMMON/common_lib.h"
 
+#include "nr_mac_common.h"
+
+#define MAX_NUM_BWP 2
+#define MAX_NUM_CORESET 2
+#define MAX_NUM_CCE 90
 
 #include "NR_TAG.h"
 
 /*! \brief gNB common channels */
 typedef struct {
-    int physCellId;
-    int p_gNB;
-    int Ncp;
-    int nr_band;
-    uint32_t dl_CarrierFreq;
-    NR_BCCH_BCH_Message_t *mib;
-    NR_TDD_UL_DL_ConfigCommon_t *tdd_Config;
-    NR_ARFCN_ValueEUTRA_t ul_CarrierFreq;
-    long ul_Bandwidth;
-    /// Outgoing MIB PDU for PHY
-    MIB_PDU MIB_pdu;
-    /// Outgoing BCCH pdu for PHY
-    BCCH_PDU BCCH_pdu;
-    /// Outgoing BCCH DCI allocation
-    uint32_t BCCH_alloc_pdu;
-    /// Outgoing CCCH pdu for PHY
-    CCCH_PDU CCCH_pdu;
-    /// Outgoing PCCH DCI allocation
-    uint32_t PCCH_alloc_pdu;
-    /// Outgoing PCCH pdu for PHY
-    PCCH_PDU PCCH_pdu;
-    /// Outgoing RAR pdu for PHY
-    RAR_PDU RAR_pdu;
-    /// Template for RA computations
-    RA_t ra[NB_RA_PROC_MAX];
-    /// VRB map for common channels
-    uint8_t vrb_map[100];
-    /// VRB map for common channels and retransmissions by PHICH
-    uint8_t vrb_map_UL[100];
-    /// number of subframe allocation pattern available for MBSFN sync area
-    uint8_t num_sf_allocation_pattern;
+  int physCellId;
+  int p_gNB;
+  int Ncp;
+  int nr_band;
+  uint64_t dl_CarrierFreq;
+  NR_BCCH_BCH_Message_t *mib;
+  NR_ServingCellConfigCommon_t *ServingCellConfigCommon;
+  NR_ARFCN_ValueEUTRA_t ul_CarrierFreq;
+  long ul_Bandwidth;
+  /// Outgoing MIB PDU for PHY
+  MIB_PDU MIB_pdu;
+  /// Outgoing BCCH pdu for PHY
+  BCCH_PDU BCCH_pdu;
+  /// Outgoing BCCH DCI allocation
+  uint32_t BCCH_alloc_pdu;
+  /// Outgoing CCCH pdu for PHY
+  CCCH_PDU CCCH_pdu;
+  /// Outgoing PCCH DCI allocation
+  uint32_t PCCH_alloc_pdu;
+  /// Outgoing PCCH pdu for PHY
+  PCCH_PDU PCCH_pdu;
+  /// Outgoing RAR pdu for PHY
+  RAR_PDU RAR_pdu;
+  /// Template for RA computations
+  RA_t ra[NB_RA_PROC_MAX];
+  /// VRB map for common channels
+  uint8_t vrb_map[100];
+  /// VRB map for common channels and retransmissions by PHICH
+  uint8_t vrb_map_UL[100];
+  /// number of subframe allocation pattern available for MBSFN sync area
+  uint8_t num_sf_allocation_pattern;
 } NR_COMMON_channels_t;
 
+/*! \brief scheduling control information set through an API (not used)*/
+typedef struct {
+  int dummy;
+} NR_UE_sched_ctrl_t;
+
+/*! \brief UE list used by eNB to order UEs/CC for scheduling*/
+typedef struct {
+
+  DLSCH_PDU DLSCH_pdu[4][MAX_MOBILES_PER_GNB];
+  /// scheduling control info
+  UE_sched_ctrl_t UE_sched_ctrl[MAX_MOBILES_PER_GNB];
+  int next[MAX_MOBILES_PER_GNB];
+  int head;
+  int next_ul[MAX_MOBILES_PER_GNB];
+  int head_ul;
+  int avail;
+  int num_UEs;
+  boolean_t active[MAX_MOBILES_PER_GNB];
+  rnti_t rnti[MAX_MOBILES_PER_GNB];
+  NR_CellGroupConfig_t *secondaryCellGroup[MAX_MOBILES_PER_GNB];
+} NR_UE_list_t;
+
 /*! \brief top level eNB MAC structure */
 typedef struct gNB_MAC_INST_s {
   /// Ethernet parameters for northbound midhaul interface
@@ -124,28 +150,17 @@ typedef struct gNB_MAC_INST_s {
   uint16_t pdu_index[NFAPI_CC_MAX];
 
   /// NFAPI Config Request Structure
-  nfapi_nr_config_request_t         config[NFAPI_CC_MAX];
+  nfapi_nr_config_request_scf_t     config[NFAPI_CC_MAX];
   /// NFAPI DL Config Request Structure
-  nfapi_nr_dl_config_request_t      DL_req[NFAPI_CC_MAX];
+  nfapi_nr_dl_tti_request_t         DL_req[NFAPI_CC_MAX];
   /// NFAPI UL TTI Request Structure (this is from the new SCF specs)
   nfapi_nr_ul_tti_request_t         UL_tti_req[NFAPI_CC_MAX];
-  /// Preallocated DL pdu list
-  nfapi_nr_dl_config_request_pdu_t  dl_config_pdu_list[NFAPI_CC_MAX][MAX_NUM_DL_PDU];
-  /// Preallocated HI_DCI0 pdu list
-  nfapi_hi_dci0_request_pdu_t       hi_dci0_pdu_list[NFAPI_CC_MAX][MAX_NUM_HI_DCI0_PDU];
   /// NFAPI HI/DCI0 Config Request Structure
-  nfapi_hi_dci0_request_t           HI_DCI0_req[NFAPI_CC_MAX];
-  /// Prealocated TX pdu list
-  nfapi_tx_request_pdu_t            tx_request_pdu[NFAPI_CC_MAX][MAX_NUM_TX_REQUEST_PDU];
+  nfapi_nr_ul_dci_request_t         UL_dci_req[NFAPI_CC_MAX];
   /// NFAPI DL PDU structure
-  nfapi_tx_request_t                TX_req[NFAPI_CC_MAX];
-  /// NFAPI coreset structure
-  nfapi_nr_coreset_t                coreset[NFAPI_CC_MAX][NFAPI_NR_MAX_NB_CORESETS];
-  /// NFAPI search space structure
-  nfapi_nr_search_space_t           search_space[NFAPI_CC_MAX][NFAPI_NR_MAX_NB_SEARCH_SPACES];
+  nfapi_nr_tx_data_request_t        TX_req[NFAPI_CC_MAX];
 
-  /// this is an LTE structure and needs to be urgenly updated
-  UE_list_t UE_list;
+  NR_UE_list_t UE_list;
 
   /// UL handle
   uint32_t ul_handle;
@@ -171,6 +186,72 @@ typedef struct gNB_MAC_INST_s {
   time_stats_t rx_ulsch_sdu;  // include rlc_data_ind
   /// processing time of eNB PCH scheduler
   time_stats_t schedule_pch;
+  /// CCE lists
+  int cce_list[MAX_NUM_BWP][MAX_NUM_CORESET][MAX_NUM_CCE];
 } gNB_MAC_INST;
 
+typedef struct {
+
+
+uint8_t format_indicator; //1 bit
+uint16_t frequency_domain_assignment; //up to 16 bits
+uint8_t time_domain_assignment; // 4 bits
+uint8_t frequency_hopping_flag; //1 bit
+
+uint8_t ra_preamble_index; //6 bits
+uint8_t ss_pbch_index; //6 bits
+uint8_t prach_mask_index; //4 bits
+
+uint8_t vrb_to_prb_mapping; //0 or 1 bit
+uint8_t mcs; //5 bits
+uint8_t ndi; //1 bit
+uint8_t rv; //2 bits
+uint8_t harq_pid; //4 bits
+uint8_t dai; //0, 2 or 4 bits
+uint8_t dai1; //1 or 2 bits
+uint8_t dai2; //0 or 2 bits
+uint8_t tpc; //2 bits
+uint8_t pucch_resource_indicator; //3 bits
+uint8_t pdsch_to_harq_feedback_timing_indicator; //0, 1, 2 or 3 bits
+
+uint8_t short_messages_indicator; //2 bits
+uint8_t short_messages; //8 bits
+uint8_t tb_scaling; //2 bits
+
+uint8_t carrier_indicator; //0 or 3 bits
+uint8_t bwp_indicator; //0, 1 or 2 bits
+uint8_t prb_bundling_size_indicator; //0 or 1 bits
+uint8_t rate_matching_indicator; //0, 1 or 2 bits
+uint8_t zp_csi_rs_trigger; //0, 1 or 2 bits
+uint8_t transmission_configuration_indication; //0 or 3 bits
+uint8_t srs_request; //2 bits
+uint8_t cbgti; //CBG Transmission Information: 0, 2, 4, 6 or 8 bits
+uint8_t cbgfi; //CBG Flushing Out Information: 0 or 1 bit
+uint8_t dmrs_sequence_initialization; //0 or 1 bit
+
+uint8_t srs_resource_indicator;
+uint8_t precoding_information;
+uint8_t csi_request;
+uint8_t ptrs_dmrs_association;
+uint8_t beta_offset_indicator; //0 or 2 bits
+
+uint8_t slot_format_indicator_count;
+uint8_t *slot_format_indicators;
+
+uint8_t pre_emption_indication_count;
+uint16_t *pre_emption_indications; //14 bit
+
+uint8_t block_number_count;
+uint8_t *block_numbers;
+
+uint8_t ul_sul_indicator; //0 or 1 bit
+uint8_t antenna_ports;
+
+uint16_t reserved; //1_0/C-RNTI:10 bits, 1_0/P-RNTI: 6 bits, 1_0/SI-&RA-RNTI: 16 bits
+uint16_t padding;
+
+} dci_pdu_rel15_t;
+
+
+
 #endif /*__LAYER2_NR_MAC_GNB_H__ */
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
index 254d741ae89..b0e6143de1e 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
@@ -2299,14 +2299,14 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) {
       netlink_init_tun("ue",num_if);
       if (IS_SOFTMODEM_NOS1)
     	  nas_config(1, 1, 2, "ue");
-      netlink_init_mbms_tun("uem",num_if);
+      netlink_init_mbms_tun("uem");
       nas_config_mbms(1, 2, 2, "uem");
       LOG_I(PDCP, "UE pdcp will use tun interface\n");
     } else if(ENB_NAS_USE_TUN) {
       netlink_init_tun("enb",1);
       nas_config(1, 1, 1, "enb");
       if(pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT){
-      	netlink_init_mbms_tun("enm",1);
+        netlink_init_mbms_tun("enm");
       	nas_config_mbms(1, 2, 1, "enm"); 
       	LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n");
       }
@@ -2318,7 +2318,7 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) {
   }else{
          if(pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT){
              LOG_W(PDCP, "ENB pdcp will use tun interface for MBMS\n");
-            netlink_init_mbms_tun("enm",1);
+            netlink_init_mbms_tun("enm");
              nas_config_mbms_s1(1, 2, 1, "enm"); 
          }else
              LOG_E(PDCP, "ENB pdcp will not use tun interface\n");
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
index a441ff220ed..d203408e550 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
@@ -77,7 +77,7 @@ extern struct iovec nas_iov_rx;
 
 extern int nas_sock_fd[MAX_MOBILES_PER_ENB];
 
-extern int nas_sock_mbms_fd[8];
+extern int nas_sock_mbms_fd;
 
 extern int mbms_rab_id;
 
@@ -133,7 +133,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const  ctxt_pP) {
     } else if (UE_NAS_USE_TUN) {
       //ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite );
        if(rb_id == mbms_rab_id){
-       ret = write(nas_sock_mbms_fd[0], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite );
+       ret = write(nas_sock_mbms_fd, &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite );
        LOG_I(PDCP,"[PDCP_FIFOS] ret %d TRIED TO PUSH MBMS DATA TO rb_id %d handle %d sizeToWrite %d\n",ret,rb_id,nas_sock_fd[ctxt_pP->module_id],sizeToWrite);
         }
        else
@@ -299,7 +299,7 @@ int pdcp_fifo_read_input_mbms_sdus_fromtun (const protocol_ctxt_t *const  ctxt_p
   do {
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_MBMS_FIFO_READ, 1 );
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_MBMS_FIFO_READ_BUFFER, 1 );
-    len = read(UE_NAS_USE_TUN?nas_sock_mbms_fd[0]:nas_sock_mbms_fd[0], &nl_rx_buf, NL_MAX_PAYLOAD);
+    len = read(nas_sock_mbms_fd, &nl_rx_buf, NL_MAX_PAYLOAD);
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_MBMS_FIFO_READ_BUFFER, 0 );
 
     if (len<=0) continue;
diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c
index 3ca64f9648b..91c75ac67fd 100644
--- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c
+++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c
@@ -51,106 +51,100 @@ extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind);
 extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind);
 extern uint8_t nfapi_mode;
 extern uint16_t sf_ahead;
+extern uint16_t sl_ahead;
 
 void handle_nr_rach(NR_UL_IND_t *UL_info) {
   if (UL_info->rach_ind.rach_indication_body.number_of_preambles>0) {
     AssertFatal(UL_info->rach_ind.rach_indication_body.number_of_preambles==1,"More than 1 preamble not supported\n");
     UL_info->rach_ind.rach_indication_body.number_of_preambles=0;
     LOG_D(MAC,"UL_info[Frame %d, Slot %d] Calling initiate_ra_proc RACH:SFN/SF:%d\n",UL_info->frame,UL_info->slot, NFAPI_SFNSF2DEC(UL_info->rach_ind.sfn_sf));
+    /*
     initiate_ra_proc(UL_info->module_id,
-                     UL_info->CC_id,
-                     NFAPI_SFNSF2SFN(UL_info->rach_ind.sfn_sf),
-                     NFAPI_SFNSF2SF(UL_info->rach_ind.sfn_sf),
-                     UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble,
-                     UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance,
-                     UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti,0
-                    );
-  }
 
-  if (UL_info->rach_ind_br.rach_indication_body.number_of_preambles>0) {
-    AssertFatal(UL_info->rach_ind_br.rach_indication_body.number_of_preambles<5,"More than 4 preambles not supported\n");
-
-    for (int i=0; i<UL_info->rach_ind_br.rach_indication_body.number_of_preambles; i++) {
-      AssertFatal(UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type>0,
-                  "Got regular PRACH preamble, not BL/CE\n");
-      LOG_D(MAC,"Frame %d, Slot %d Calling initiate_ra_proc (CE_level %d)\n",UL_info->frame,UL_info->slot,
-            UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type-1);
-      initiate_ra_proc(UL_info->module_id,
-                       UL_info->CC_id,
-                       UL_info->frame,
-                       UL_info->slot,
-                       UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.preamble,
-                       UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.timing_advance,
-                       UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.rnti,
-                       UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type);
-    }
+    		         UL_info->CC_id,
+					 NFAPI_SFNSF2SFN(UL_info->rach_ind.sfn_sf),
+					 NFAPI_SFNSF2SF(UL_info->rach_ind.sfn_sf),
+					 UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble,
+					 UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance,
+					 UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti
+#if (NR_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) || (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+//#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+                    ,0
+#endif
 
-    UL_info->rach_ind_br.rach_indication_body.number_of_preambles=0;
+         );
+    */
   }
+
 }
 
 void handle_nr_sr(NR_UL_IND_t *UL_info) {
-  if (nfapi_mode == 1) { // PNF
-    if (UL_info->sr_ind.sr_indication_body.number_of_srs>0) {
-      oai_nfapi_sr_indication(&UL_info->sr_ind);
+
+
+  if (nfapi_mode == 1)  // PNF
+  {
+    if (UL_info->sr_ind.sr_indication_body.number_of_srs>0)
+    {
+      //      oai_nfapi_sr_indication(&UL_info->sr_ind);
     }
-  } else {
-    for (int i=0; i<UL_info->sr_ind.sr_indication_body.number_of_srs; i++)
+  }
+  else
+  {
+
+    /*
+    for (int i=0;i<UL_info->sr_ind.sr_indication_body.number_of_srs;i++)
       SR_indication(UL_info->module_id,
-                    UL_info->CC_id,
-                    UL_info->frame,
-                    UL_info->slot,
-                    UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].rx_ue_information.rnti,
-                    UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].ul_cqi_information.ul_cqi);
+          UL_info->CC_id,
+          UL_info->frame,
+          UL_info->slot,
+          UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].rx_ue_information.rnti,
+          UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].ul_cqi_information.ul_cqi);*/
+
+
+
   }
 
   UL_info->sr_ind.sr_indication_body.number_of_srs=0;
 }
 
 void handle_nr_cqi(NR_UL_IND_t *UL_info) {
-  if (nfapi_mode == 1) {
-    if (UL_info->cqi_ind.number_of_cqis>0) {
-      LOG_D(PHY,"UL_info->cqi_ind.number_of_cqis:%d\n", UL_info->cqi_ind.number_of_cqis);
-      nfapi_cqi_indication_t ind;
-      ind.header.message_id = NFAPI_RX_CQI_INDICATION;
-      ind.sfn_sf = UL_info->frame<<4 | UL_info->slot;
-      ind.cqi_indication_body = UL_info->cqi_ind;
-      oai_nfapi_cqi_indication(&ind);
-      UL_info->cqi_ind.number_of_cqis=0;
-    }
-  } else {
-    for (int i=0; i<UL_info->cqi_ind.number_of_cqis; i++)
-      cqi_indication(UL_info->module_id,
-                     UL_info->CC_id,
-                     UL_info->frame,
-                     UL_info->slot,
-                     UL_info->cqi_ind.cqi_pdu_list[i].rx_ue_information.rnti,
-                     &UL_info->cqi_ind.cqi_pdu_list[i].cqi_indication_rel9,
-                     UL_info->cqi_ind.cqi_raw_pdu_list[i].pdu,
-                     &UL_info->cqi_ind.cqi_pdu_list[i].ul_cqi_information);
 
+    /*
+    for (int i=0;i<UL_info->cqi_ind.number_of_cqis;i++) 
+      cqi_indication(UL_info->module_id,
+          UL_info->CC_id,
+          UL_info->frame,
+          UL_info->slot,
+          UL_info->cqi_ind.cqi_pdu_list[i].rx_ue_information.rnti,
+          &UL_info->cqi_ind.cqi_pdu_list[i].cqi_indication_rel9,
+          UL_info->cqi_ind.cqi_raw_pdu_list[i].pdu,
+          &UL_info->cqi_ind.cqi_pdu_list[i].ul_cqi_information);
+    */
     UL_info->cqi_ind.number_of_cqis=0;
-  }
+
 }
 
 void handle_nr_harq(NR_UL_IND_t *UL_info) {
   if (nfapi_mode == 1 && UL_info->harq_ind.harq_indication_body.number_of_harqs>0) { // PNF
     //LOG_D(PHY, "UL_info->harq_ind.harq_indication_body.number_of_harqs:%d Send to VNF\n", UL_info->harq_ind.harq_indication_body.number_of_harqs);
-    int retval = oai_nfapi_harq_indication(&UL_info->harq_ind);
+    /*    int retval = oai_nfapi_harq_indication(&UL_info->harq_ind);
 
     if (retval!=0) {
       LOG_E(PHY, "Failed to encode NFAPI HARQ_IND retval:%d\n", retval);
     }
-
+    */
     UL_info->harq_ind.harq_indication_body.number_of_harqs = 0;
-  } else {
-    for (int i=0; i<UL_info->harq_ind.harq_indication_body.number_of_harqs; i++)
+  }
+  else
+  {
+    /*
+    for (int i=0;i<UL_info->harq_ind.harq_indication_body.number_of_harqs;i++)
       harq_indication(UL_info->module_id,
-                      UL_info->CC_id,
-                      NFAPI_SFNSF2SFN(UL_info->harq_ind.sfn_sf),
-                      NFAPI_SFNSF2SF(UL_info->harq_ind.sfn_sf),
-                      &UL_info->harq_ind.harq_indication_body.harq_pdu_list[i]);
-
+          UL_info->CC_id,
+          NFAPI_SFNSF2SFN(UL_info->harq_ind.sfn_sf),
+          NFAPI_SFNSF2SF(UL_info->harq_ind.sfn_sf),
+          &UL_info->harq_ind.harq_indication_body.harq_pdu_list[i]);
+    */
     UL_info->harq_ind.harq_indication_body.number_of_harqs=0;
   }
 }
@@ -159,17 +153,18 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) {
   if(nfapi_mode == 1) {
     if (UL_info->crc_ind.crc_indication_body.number_of_crcs>0) {
       //LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.number_of_crcs:%d CRC_IND:SFN/SF:%d\n", UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf));
-      oai_nfapi_crc_indication(&UL_info->crc_ind);
+      //      oai_nfapi_crc_indication(&UL_info->crc_ind);
+
       UL_info->crc_ind.crc_indication_body.number_of_crcs = 0;
     }
 
     if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0) {
       //LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf));
-      oai_nfapi_rx_ind(&UL_info->rx_ind);
+      //      oai_nfapi_rx_ind(&UL_info->rx_ind);
       UL_info->rx_ind.rx_indication_body.number_of_pdus = 0;
     }
   } else {
-    // printf("UL_info->rx_ind.rx_indication_body.number_of_pdus %d UL_info->crc_ind.crc_indication_body.number_of_crcs %d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->crc_ind.crc_indication_body.number_of_crcs);
+
     if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0 && UL_info->crc_ind.crc_indication_body.number_of_crcs>0) {
       for (int i=0; i<UL_info->rx_ind.rx_indication_body.number_of_pdus; i++) {
         for (int j=0; j<UL_info->crc_ind.crc_indication_body.number_of_crcs; j++) {
@@ -182,27 +177,28 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) {
             LOG_D(PHY, "UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].crc_indication_rel8.crc_flag:%d\n", j, UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag);
 
             if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag == 1) { // CRC error indication
-              LOG_I(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->slot);
+              LOG_D(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->slot);
+
               nr_rx_sdu(UL_info->module_id,
-                     UL_info->CC_id,
-                     NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
-                     NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->slot,
-                     UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti,
-                     (uint8_t *)NULL,
-                     UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length,
-                     UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
-                     UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
+                        UL_info->CC_id,
+                        NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
+                        NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->slot,
+                        UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti,
+                        (uint8_t *)NULL,
+                        UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length,
+                        UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
+                        UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
             } else {
-              LOG_D(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC ok), received length: %d \n",UL_info->frame,UL_info->slot, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length);
+              LOG_D(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC ok) \n",UL_info->frame,UL_info->slot);
               nr_rx_sdu(UL_info->module_id,
-                     UL_info->CC_id,
-                     NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
-                     NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->slot,
-                     UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti,
-                     UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].data,
-                     UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length,
-                     UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
-                     UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
+                        UL_info->CC_id,
+                        NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
+                        NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->slot,
+                        UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti,
+                        UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].data,
+                        UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length,
+                        UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
+                        UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
             }
             //printf("rx_indication_rel8.timing_advance %d\n", UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance);
             break;
@@ -259,35 +255,37 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) {
   handle_nr_cqi(UL_info);
   handle_nr_harq(UL_info);
   // clear HI prior to handling ULSCH
-  mac->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_hi                     = 0;
+  mac->UL_dci_req[CC_id].numPdus = 0;
   handle_nr_ulsch(UL_info);
 
   if (nfapi_mode != 1) {
     if (ifi->CC_mask == ((1<<MAX_NUM_CCs)-1)) {
       /*
       eNB_dlsch_ulsch_scheduler(module_id,
-          (UL_info->frame+((UL_info->slot>(9-sf_ahead))?1:0)) % 1024,
-          (UL_info->slot+sf_ahead)%10);
+          (UL_info->frame+((UL_info->slot>(9-sl_ahead))?1:0)) % 1024,
+          (UL_info->slot+sl_ahead)%10);
       */
-      nfapi_nr_config_request_t *cfg = &mac->config[CC_id];
+      nfapi_nr_config_request_scf_t *cfg = &mac->config[CC_id];
       int spf = get_spf(cfg);
       gNB_dlsch_ulsch_scheduler(module_id,
 				UL_info->frame,
 				UL_info->slot,
-				(UL_info->frame+((UL_info->slot>(spf-1-sf_ahead))?1:0)) % 1024,
-				(UL_info->slot+sf_ahead)%spf);
+				(UL_info->frame+((UL_info->slot>(spf-1-sl_ahead))?1:0)) % 1024,
+				(UL_info->slot+sl_ahead)%spf);
       
       ifi->CC_mask            = 0;
       sched_info->module_id   = module_id;
       sched_info->CC_id       = CC_id;
-      sched_info->frame       = (UL_info->frame + ((UL_info->slot>(spf-1-sf_ahead)) ? 1 : 0)) % 1024;
-      sched_info->slot        = (UL_info->slot+sf_ahead)%spf;
+      sched_info->frame       = (UL_info->frame + ((UL_info->slot>(spf-1-sl_ahead)) ? 1 : 0)) % 1024;
+      sched_info->slot        = (UL_info->slot+sl_ahead)%spf;
       sched_info->DL_req      = &mac->DL_req[CC_id];
-      sched_info->HI_DCI0_req = &mac->HI_DCI0_req[CC_id];
+      sched_info->UL_dci_req  = &mac->UL_dci_req[CC_id];
 
-      if ((mac->common_channels[CC_id].tdd_Config==NULL) ||
-          (is_nr_UL_slot(&mac->common_channels[CC_id],(sched_info->slot+sf_ahead)%spf)>0))
+      if ((mac->common_channels[CC_id].ServingCellConfigCommon->tdd_UL_DL_ConfigurationCommon==NULL) ||
+          (is_nr_UL_slot(mac->common_channels[CC_id].ServingCellConfigCommon,UL_info->slot)>0)) {
+	//printf("NR_UL_indication: this is an UL slot. UL_info: frame %d, slot %d. UL_tti_req: frame %d, slot %d\n",UL_info->frame,UL_info->slot,mac->UL_tti_req[CC_id].SFN,mac->UL_tti_req[CC_id].Slot);
         sched_info->UL_tti_req      = &mac->UL_tti_req[CC_id];
+      }
       else
         sched_info->UL_tti_req      = NULL;
 
@@ -304,18 +302,24 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) {
         ifi->NR_Schedule_response(sched_info);
       }
 
-      LOG_D(PHY,"NR_Schedule_response: SFN_SF:%d%d dl_pdus:%d\n",sched_info->frame,sched_info->slot,sched_info->DL_req->dl_config_request_body.number_pdu);
+      LOG_D(PHY,"NR_Schedule_response: SFN_SF:%d%d dl_pdus:%d\n",
+	    sched_info->frame,
+	    sched_info->slot,
+	    sched_info->DL_req->dl_tti_request_body.nPDUs);
     }
   }
 }
 
 NR_IF_Module_t *NR_IF_Module_init(int Mod_id) {
   AssertFatal(Mod_id<MAX_MODULES,"Asking for Module %d > %d\n",Mod_id,MAX_IF_MODULES);
-  LOG_D(PHY,"Installing callbacks for IF_Module - UL_indication\n");
+  LOG_I(PHY,"Installing callbacks for IF_Module - UL_indication\n");
 
   if (if_inst[Mod_id]==NULL) {
-    if_inst[Mod_id] = (NR_IF_Module_t *)malloc(sizeof(NR_IF_Module_t));
-    memset((void *)if_inst[Mod_id],0,sizeof(NR_IF_Module_t));
+    if_inst[Mod_id] = (NR_IF_Module_t*)malloc(sizeof(NR_IF_Module_t));
+    memset((void*)if_inst[Mod_id],0,sizeof(NR_IF_Module_t));
+
+    LOG_I(MAC,"Allocating shared L1/L2 interface structure for instance %d @ %p\n",Mod_id,if_inst[Mod_id]);
+
     if_inst[Mod_id]->CC_mask=0;
     if_inst[Mod_id]->NR_UL_indication = NR_UL_indication;
     AssertFatal(pthread_mutex_init(&if_inst[Mod_id]->if_mutex,NULL)==0,
diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h
index 898197cc30a..14355781d01 100644
--- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h
+++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h
@@ -100,19 +100,19 @@ typedef struct {
   /// slot
   slot_t slot;
   /// nFAPI DL Config Request
-  nfapi_nr_dl_config_request_t *DL_req;
+  nfapi_nr_dl_tti_request_t *DL_req;
   /// nFAPI UL Config Request
   nfapi_nr_ul_tti_request_t *UL_tti_req;
-  /// nFAPI HI_DCI Request
-  nfapi_hi_dci0_request_t *HI_DCI0_req;
+  /// nFAPI UL_DCI Request
+  nfapi_nr_ul_dci_request_t *UL_dci_req;
   /// Pointers to DL SDUs
-  nfapi_tx_request_t *TX_req;
+  nfapi_nr_tx_data_request_t *TX_req;
 } NR_Sched_Rsp_t;
 
 typedef struct {
   uint8_t Mod_id;
   int CC_id;
-  nfapi_nr_config_request_t *cfg;
+  nfapi_nr_config_request_scf_t *cfg;
 } NR_PHY_Config_t;
 
 typedef struct NR_IF_Module_s {
diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
index 494baefc29d..64a814bcdb9 100644
--- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
+++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
@@ -45,17 +45,16 @@
 static nr_ue_if_module_t *nr_ue_if_module_inst[MAX_IF_MODULES];
 
 //  L2 Abstraction Layer
-int handle_bcch_bch(UE_nr_rxtx_proc_t *proc, module_id_t module_id, int cc_id, unsigned int gNB_index, uint8_t *pduP, unsigned int additional_bits, uint32_t ssb_index, uint32_t ssb_length, uint16_t cell_id){
-
-  return nr_ue_decode_mib( proc,
-		           module_id,
-			   cc_id,
-			   gNB_index,
-			   additional_bits,
-			   ssb_length,  //  Lssb = 64 is not support    
-			   ssb_index,
-			   pduP, 
-			   cell_id);
+int handle_bcch_bch(module_id_t module_id, int cc_id, unsigned int gNB_index, uint8_t *pduP, unsigned int additional_bits, uint32_t ssb_index, uint32_t ssb_length, uint16_t cell_id){
+
+  return nr_ue_decode_mib(module_id,
+			  cc_id,
+			  gNB_index,
+			  additional_bits,
+			  ssb_length,  //  Lssb = 64 is not support    
+			  ssb_index,
+			  pduP, 
+			  cell_id);
 
 }
 
@@ -65,22 +64,23 @@ int handle_bcch_dlsch(module_id_t module_id, int cc_id, unsigned int gNB_index,
   return 0;
 }
 //  L2 Abstraction Layer
-int handle_dci(module_id_t module_id, int cc_id, unsigned int gNB_index, fapi_nr_dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_type){
+int handle_dci(module_id_t module_id, int cc_id, unsigned int gNB_index, fapi_nr_dci_indication_pdu_t *dci){
 
   //printf("handle_dci: rnti %x,dci_type %d\n",rnti,dci_type);
-  return nr_ue_process_dci(module_id, cc_id, gNB_index, dci, rnti, dci_type);
+  return nr_ue_process_dci_indication_pdu(module_id, cc_id, gNB_index, dci);
 
 }
 //  L2 Abstraction Layer
 int8_t handle_dlsch (module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_indication_t *dci_ind, uint8_t *pduP, uint32_t pdu_len, frame_t frame, int slot, NR_UL_TIME_ALIGNMENT_t *ul_time_alignment){
 
+  LOG_D(MAC, "handle_dlsch at MAC layer \n");
   //if (IS_SOFTMODEM_NOS1 || IS_SOFTMODEM_RFSIM)
   // sdu should be processed even when is S1 mode because data and timing advance updates are transmitted by the UE
-    nr_ue_send_sdu(module_id, cc_id, frame, slot,
-                   pduP,
-                   pdu_len,
-                   gNB_index,
-                   ul_time_alignment);
+  nr_ue_send_sdu(module_id, cc_id, frame, slot,
+                 pduP,
+                 pdu_len,
+                 gNB_index,
+                 ul_time_alignment);
 
   return 0;
   /*
@@ -157,15 +157,12 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
     LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][DCI_IND]\n");
     for(i=0; i<dl_info->dci_ind->number_of_dcis; ++i){
       LOG_D(MAC,">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n",i,dl_info->dci_ind->number_of_dcis);
-      fapi_nr_dci_pdu_rel15_t *dci = &dl_info->dci_ind->dci_list[i].dci;
+      //      fapi_nr_dci_pdu_rel15_t *dci = &dl_info->dci_ind->dci_list[i].dci;
 
-      ret_mask |= (handle_dci(
-			      dl_info->module_id,
-			      dl_info->cc_id,
-			      dl_info->gNB_index,
-			      dci, 
-			      (dl_info->dci_ind->dci_list+i)->rnti, 
-			      (dl_info->dci_ind->dci_list+i)->dci_format)) << FAPI_NR_DCI_IND;
+      ret_mask |= (handle_dci(dl_info->module_id,
+                              dl_info->cc_id,
+                              dl_info->gNB_index,
+                              dl_info->dci_ind->dci_list+i)<< FAPI_NR_DCI_IND);
 
       AssertFatal( nr_ue_if_module_inst[module_id] != NULL, "IF module is void!\n" );
       nr_ue_if_module_inst[module_id]->scheduled_response(&mac->scheduled_response);
@@ -211,28 +208,22 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
 	}*/
 
       //(dl_info->dci_list+i)->rnti
-            
-            
-
-
     }
   }
 
   if(dl_info->rx_ind != NULL){
-    LOG_I(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], Number of PDUs: %d \n", dl_info->rx_ind->number_pdus);
+    LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], Number of PDUs: %d \n", dl_info->rx_ind->number_pdus);
     for(i=0; i<dl_info->rx_ind->number_pdus; ++i){
       switch(dl_info->rx_ind->rx_indication_body[i].pdu_type){
       case FAPI_NR_RX_PDU_TYPE_MIB:
-	ret_mask |= (handle_bcch_bch( dl_info->proc,
-				     dl_info->module_id, dl_info->cc_id, dl_info->gNB_index,
+	ret_mask |= (handle_bcch_bch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index,
 				     (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.pdu,
 				     (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.additional_bits,
 				     (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.ssb_index,
 				     (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.ssb_length,
 				     (dl_info->rx_ind->rx_indication_body+i)->mib_pdu.cell_id )) << FAPI_NR_RX_PDU_TYPE_MIB;
-    	  LOG_I(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], MIB case Number of PDUs: %d \n", dl_info->rx_ind->number_pdus);
-	/*ret_mask |= (handle_bcch_bch( dl_info->proc,
-					     dl_info->module_id, dl_info->cc_id, dl_info->gNB_index,
+    	  LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], MIB case Number of PDUs: %d \n", dl_info->rx_ind->number_pdus);
+	/*ret_mask |= (handle_bcch_bch(      dl_info->module_id, dl_info->cc_id, dl_info->gNB_index,
 					     dl_info->rx_ind->rx_indication_body[i].mib_pdu.pdu,
 					     dl_info->rx_ind->rx_indication_body[i].mib_pdu.additional_bits,
 					     dl_info->rx_ind->rx_indication_body[i].mib_pdu.ssb_index,
@@ -249,9 +240,9 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
 	//                    ret_mask |= (0) << FAPI_NR_RX_PDU_TYPE_DLSCH;
 	ret_mask |= (handle_dlsch(dl_info->module_id, dl_info->cc_id, dl_info->gNB_index, dl_info->dci_ind,
 				  (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu,
-				  (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu_length, dl_info->frame, dl_info->slot,ul_time_alignment)) << FAPI_NR_RX_PDU_TYPE_DLSCH;
+				  (dl_info->rx_ind->rx_indication_body+i)->pdsch_pdu.pdu_length, dl_info->frame, dl_info->slot, ul_time_alignment)) << FAPI_NR_RX_PDU_TYPE_DLSCH;
 
-    	  LOG_I(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], DLSCH case Number of PDUs: %d \n", dl_info->rx_ind->number_pdus);
+    	  LOG_D(MAC,"[L2][IF MODULE][DL INDICATION][RX_IND], DLSCH case Number of PDUs: %d \n", dl_info->rx_ind->number_pdus);
 
 	  /*
 	  // dl_config structure just stores what was received - not really needed
@@ -310,49 +301,11 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq) {
   
   fapi_nr_dl_config_request_t *dl_config=&dcireq->dl_config_req;
   NR_UE_MAC_INST_t *UE_mac = get_mac_inst(0);
-  
-  //  Type0 PDCCH search space
-  dl_config->number_pdus =  1;
-  dl_config->dl_config_list[0].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.rnti = 0x1234;	//	to be set
-  
-  uint64_t mask = 0x0;
-  uint16_t num_rbs=24;
-  uint16_t rb_offset=0;
-  uint16_t cell_id=0;
-  uint16_t num_symbols=2;
-  for(int i=0; i<(num_rbs/6); ++i){   //  38.331 Each bit corresponds a group of 6 RBs
-    mask = mask >> 1;
-    mask = mask | 0x100000000000;
-  }
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.frequency_domain_resource = mask;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.rb_offset = rb_offset;  //  additional parameter other than coreset
-  
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.duration = num_symbols;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_mapping_type =CCE_REG_MAPPING_TYPE_NON_INTERLEAVED;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_interleaved_reg_bundle_size = 0;   //  L 38.211 7.3.2.2
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_interleaved_interleaver_size = 0;  //  R 38.211 7.3.2.2
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.cce_reg_interleaved_shift_index = cell_id;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.precoder_granularity = PRECODER_GRANULARITY_SAME_AS_REG_BUNDLE;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.coreset.pdcch_dmrs_scrambling_id = cell_id;
-  
-  uint32_t number_of_search_space_per_slot=1;
-  uint32_t first_symbol_index=0;
-  uint32_t search_space_duration=0;  //  element of search space
-  uint32_t coreset_duration;  //  element of coreset
-  
-  coreset_duration = num_symbols * number_of_search_space_per_slot;
-  
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[0] = table_38213_10_1_1_c2[0];
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[1] = table_38213_10_1_1_c2[1];
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[2] = table_38213_10_1_1_c2[2];   //  CCE aggregation level = 4
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[3] = table_38213_10_1_1_c2[3];   //  CCE aggregation level = 8
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.number_of_candidates[4] = table_38213_10_1_1_c2[4];   //  CCE aggregation level = 16
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.duration = search_space_duration;
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.monitoring_symbols_within_slot = (0x3fff << first_symbol_index) & (0x3fff >> (14-coreset_duration-first_symbol_index)) & 0x3fff;
-
-  dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15.N_RB_BWP = UE_mac->initial_bwp_dl.N_RB;
 
-  
+  dl_config->sfn=UE_mac->dl_config_request.sfn;
+  dl_config->slot=UE_mac->dl_config_request.slot;
+  dl_config->number_pdus=0;
+ 
+  ue_dci_configuration(UE_mac,dl_config,dcireq->frame,dcireq->slot); 
   return 0;
 }
diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h
index e46ae2103fd..0784e715846 100755
--- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h
+++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h
@@ -106,8 +106,6 @@ typedef struct {
     int CC_id;
     /// frame
     frame_t frame;
-    /// subframe
-    sub_frame_t subframe;
     /// slot
     int slot;
 
@@ -215,7 +213,7 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq);
    \param ssb_index       SSB index within 0 - (L_ssb-1) corresponding to 38.331 ch.13 parameter i
    \param ssb_length      corresponding to L1 parameter L_ssb 
    \param cell_id         cell id */
-int handle_bcch_bch(UE_nr_rxtx_proc_t *proc, module_id_t module_id, int cc_id, unsigned int gNB_index, uint8_t *pduP, unsigned int additional_bits, uint32_t ssb_index, uint32_t ssb_length, uint16_t cell_id);
+int handle_bcch_bch(module_id_t module_id, int cc_id, unsigned int gNB_index, uint8_t *pduP, unsigned int additional_bits, uint32_t ssb_index, uint32_t ssb_length, uint16_t cell_id);
 
 //  TODO check
 /**\brief handle BCCH-DL-SCH message from dl_indication
@@ -223,7 +221,7 @@ int handle_bcch_bch(UE_nr_rxtx_proc_t *proc, module_id_t module_id, int cc_id, u
    \param pduP      pointer to pdu*/
 int handle_bcch_dlsch(module_id_t module_id, int cc_id, unsigned int gNB_index, uint32_t sibs_mask, uint8_t *pduP, uint32_t pdu_len);
 
-int handle_dci(module_id_t module_id, int cc_id, unsigned int gNB_index, fapi_nr_dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_type);
+int handle_dci(module_id_t module_id, int cc_id, unsigned int gNB_index, fapi_nr_dci_indication_pdu_t *dci);
 
 #endif
 
diff --git a/openair2/PHY_INTERFACE/phy_stub_UE.c b/openair2/PHY_INTERFACE/phy_stub_UE.c
index 14974c2e158..bf2bbf74295 100644
--- a/openair2/PHY_INTERFACE/phy_stub_UE.c
+++ b/openair2/PHY_INTERFACE/phy_stub_UE.c
@@ -1,14 +1,29 @@
+/*
+ * 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 "openair1/PHY/defs.h"
-//#include "openair2/PHY_INTERFACE/IF_Module.h"
-//#include "openair1/PHY/extern.h"
 #include "openair2/LAYER2/MAC/mac_extern.h"
 #include "openair2/LAYER2/MAC/mac.h"
 #include "openair2/LAYER2/MAC/mac_proto.h"
-//#include "openair2/LAYER2/MAC/vars.h"
 #include "openair1/SCHED_UE/sched_UE.h"
 #include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h"
-//#include "common/ran_context.h"
 #include "openair2/PHY_INTERFACE/phy_stub_UE.h"
 #include "openair2/ENB_APP/L1_paramdef.h"
 #include "openair2/ENB_APP/enb_paramdef.h"
@@ -16,14 +31,12 @@
 #include "common/config/config_load_configmodule.h"
 #include "common/config/config_userapi.h"
 
-//#define DEADLINE_SCHEDULER 1
-
-
-extern int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind);
-extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind);
 extern int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind);
-void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port);
-
+void configure_nfapi_pnf(char *vnf_ip_addr,
+                         int vnf_p5_port,
+                         char *pnf_ip_addr,
+                         int pnf_p7_port,
+                         int vnf_p7_port);
 
 UL_IND_t *UL_INFO = NULL;
 nfapi_tx_request_pdu_t* tx_request_pdu_list = NULL;
@@ -31,8 +44,6 @@ nfapi_dl_config_request_t* dl_config_req = NULL;
 nfapi_ul_config_request_t* ul_config_req = NULL;
 nfapi_hi_dci0_request_t* hi_dci0_req = NULL;
 
-//extern uint8_t nfapi_pnf;
-//UL_IND_t *UL_INFO;
 extern nfapi_tx_request_pdu_t* tx_request_pdu[1023][10][10];
 //extern int timer_subframe;
 //extern int timer_frame;
@@ -42,1010 +53,1057 @@ extern uint16_t sf_ahead;
 void Msg1_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id);
 void Msg3_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id);
 
+void fill_rx_indication_UE_MAC(module_id_t Mod_id,
+                               int frame,
+                               int subframe,
+                               UL_IND_t *UL_INFO,
+                               uint8_t *ulsch_buffer,
+                               uint16_t buflen,
+                               uint16_t rnti,
+                               int index) {
+  nfapi_rx_indication_pdu_t *pdu;
+  int timing_advance_update;
+
+  pthread_mutex_lock(&fill_ul_mutex.rx_mutex);
+
+  UL_INFO->rx_ind.sfn_sf = frame << 4 | subframe;
+  UL_INFO->rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG;
+  UL_INFO->rx_ind.vendor_extension = ul_config_req->vendor_extension;
+
+  pdu = &UL_INFO->rx_ind.rx_indication_body
+             .rx_pdu_list[UL_INFO->rx_ind.rx_indication_body.number_of_pdus];
+  // pdu = &UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[index];
+
+  // pdu->rx_ue_information.handle          = eNB->ulsch[UE_id]->handle;
+  pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG;
+  pdu->rx_ue_information.rnti = rnti;
+  pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG;
+  pdu->rx_indication_rel8.length = buflen;
+  pdu->rx_indication_rel8.offset = 1;
+  pdu->rx_indication_rel9.tl.tag = NFAPI_RX_INDICATION_REL9_TAG;
+  pdu->rx_indication_rel9.timing_advance_r9 = 0;
+
+  // ulsch_buffer is necessary to keep its value.
+  pdu->data = malloc(buflen);
+  memcpy(pdu->data, ulsch_buffer, buflen);
+  // estimate timing advance for MAC
+  timing_advance_update = 0; // Don't know what to put here
+  pdu->rx_indication_rel8.timing_advance = timing_advance_update;
 
+  int SNRtimes10 = 640;
 
-void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND_t* UL_INFO, uint8_t *ulsch_buffer, uint16_t buflen, uint16_t rnti, int index)
-{
-	  nfapi_rx_indication_pdu_t *pdu;
-
-	  int timing_advance_update;
-
-
-	  // pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
-	  // change for mutiple UE's simulation.
-	  pthread_mutex_lock(&fill_ul_mutex.rx_mutex);
-
-
-	  UL_INFO->rx_ind.sfn_sf                    = frame<<4| subframe;
-	  UL_INFO->rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG;
-	  UL_INFO->rx_ind.vendor_extension		     = ul_config_req->vendor_extension;
-
-
-	  pdu                                    = &UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[UL_INFO->rx_ind.rx_indication_body.number_of_pdus];
-	  //pdu                                    = &UL_INFO->rx_ind.rx_indication_body.rx_pdu_list[index];
-
-	  //  pdu->rx_ue_information.handle          = eNB->ulsch[UE_id]->handle;
-	  pdu->rx_ue_information.tl.tag          = NFAPI_RX_UE_INFORMATION_TAG;
-	  pdu->rx_ue_information.rnti            = rnti;
-	  pdu->rx_indication_rel8.tl.tag         = NFAPI_RX_INDICATION_REL8_TAG;
-	  //pdu->rx_indication_rel8.length         = eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS>>3;
-	  pdu->rx_indication_rel8.length         = buflen;
-	  pdu->rx_indication_rel8.offset         = 1;   // DJP - I dont understand - but broken unless 1 ????  0;  // filled in at the end of the UL_INFO formation
-
-	  // ulsch_buffer is necessary to keep its value.
-	  //pdu->data                              = ulsch_buffer;
-	  pdu->data = malloc(buflen);
-	  memcpy(pdu->data,ulsch_buffer,buflen);
-	  // estimate timing advance for MAC
-	  //sync_pos                               = lte_est_timing_advance_pusch(eNB,UE_id);
-	  timing_advance_update                  = 0;  // Don't know what to put here
-	  pdu->rx_indication_rel8.timing_advance = timing_advance_update;
-
-		  int SNRtimes10 = 640;
-
-	  if      (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0;
-	  else if (SNRtimes10 >  635) pdu->rx_indication_rel8.ul_cqi=255;
-	  else                        pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5;
-
-
-	  UL_INFO->rx_ind.rx_indication_body.number_of_pdus++;
-	  UL_INFO->rx_ind.sfn_sf = frame<<4 | subframe;
-	  // pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
-	  // change for mutiple UE's simulation.
-	  pthread_mutex_unlock(&fill_ul_mutex.rx_mutex);
-
+  if (SNRtimes10 < -640)
+    pdu->rx_indication_rel8.ul_cqi = 0;
+  else if (SNRtimes10 > 635)
+    pdu->rx_indication_rel8.ul_cqi = 255;
+  else
+    pdu->rx_indication_rel8.ul_cqi = (640 + SNRtimes10) / 5;
 
+  UL_INFO->rx_ind.rx_indication_body.number_of_pdus++;
+  UL_INFO->rx_ind.sfn_sf = frame << 4 | subframe;
+  pthread_mutex_unlock(&fill_ul_mutex.rx_mutex);
 }
 
-void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint16_t rnti) {
-
-
-  // change for mutiple UE's simulation.
-  //pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
+void fill_sr_indication_UE_MAC(int Mod_id,
+                               int frame,
+                               int subframe,
+                               UL_IND_t *UL_INFO,
+                               uint16_t rnti) {
   pthread_mutex_lock(&fill_ul_mutex.sr_mutex);
 
-  nfapi_sr_indication_t       *sr_ind = &UL_INFO->sr_ind;
-  nfapi_sr_indication_body_t  *sr_ind_body =    &sr_ind->sr_indication_body;
-  nfapi_sr_indication_pdu_t *pdu =   &sr_ind_body->sr_pdu_list[sr_ind_body->number_of_srs];
-  UL_INFO->sr_ind.vendor_extension		     = ul_config_req->vendor_extension;
+  nfapi_sr_indication_t *sr_ind = &UL_INFO->sr_ind;
+  nfapi_sr_indication_body_t *sr_ind_body = &sr_ind->sr_indication_body;
+  nfapi_sr_indication_pdu_t *pdu = &sr_ind_body->sr_pdu_list[sr_ind_body->number_of_srs];
+  UL_INFO->sr_ind.vendor_extension = ul_config_req->vendor_extension;
 
-  //nfapi_sr_indication_pdu_t *pdu =   &UL_INFO->sr_ind.sr_indication_body.sr_pdu_list[UL_INFO->rx_ind.rx_indication_body.number_of_pdus];
-
-  sr_ind->sfn_sf = frame<<4|subframe;
+  sr_ind->sfn_sf = frame << 4 | subframe;
   sr_ind->header.message_id = NFAPI_RX_SR_INDICATION;
 
   sr_ind_body->tl.tag = NFAPI_SR_INDICATION_BODY_TAG;
 
-  pdu->instance_length                                = 0; // don't know what to do with this
+  pdu->instance_length = 0; // don't know what to do with this
   //  pdu->rx_ue_information.handle                       = handle;
-  pdu->rx_ue_information.tl.tag                       = NFAPI_RX_UE_INFORMATION_TAG;
-  pdu->rx_ue_information.rnti                         = rnti; //UE_mac_inst[Mod_id].crnti
-
-
-  // dependency from PHY not sure how to substitute this. Should we hardcode it?
-  //int SNRtimes10 = dB_fixed_times10(stat) - 200;//(10*eNB->measurements.n0_power_dB[0]);
-  int SNRtimes10 = 640;
+  pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG;
+  pdu->rx_ue_information.rnti = rnti; // UE_mac_inst[Mod_id].crnti
 
   pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG;
-
-
-  if      (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0;
-  else if (SNRtimes10 >  635) pdu->ul_cqi_information.ul_cqi=255;
-  else                        pdu->ul_cqi_information.ul_cqi=(640+SNRtimes10)/5;
   pdu->ul_cqi_information.channel = 0;
 
-  //UL_INFO->rx_ind.rx_indication_body.number_of_pdus++;
+  int SNRtimes10 = 640;
+  if (SNRtimes10 < -640)
+    pdu->ul_cqi_information.ul_cqi = 0;
+  else if (SNRtimes10 > 635)
+    pdu->ul_cqi_information.ul_cqi = 255;
+  else
+    pdu->ul_cqi_information.ul_cqi = (640 + SNRtimes10) / 5;
+
+  // UL_INFO->rx_ind.rx_indication_body.number_of_pdus++;
   sr_ind_body->number_of_srs++;
-  // change for mutiple UE's simulation.
-  // pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
   pthread_mutex_unlock(&fill_ul_mutex.sr_mutex);
 }
 
-
-void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t crc_flag, int index, uint16_t rnti) {
-
-  // change for mutiple UE's simulation.
-  //pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
+void fill_crc_indication_UE_MAC(int Mod_id,
+                                int frame,
+                                int subframe,
+                                UL_IND_t *UL_INFO,
+                                uint8_t crc_flag,
+                                int index,
+                                uint16_t rnti) {
   pthread_mutex_lock(&fill_ul_mutex.crc_mutex);
 
-  // REMEMBER HAVE EXCHANGED THE FOLLOWING TWO LINES HERE!
-  nfapi_crc_indication_pdu_t *pdu =   &UL_INFO->crc_ind.crc_indication_body.crc_pdu_list[UL_INFO->crc_ind.crc_indication_body.number_of_crcs];
+  nfapi_crc_indication_pdu_t *pdu =
+      &UL_INFO->crc_ind.crc_indication_body
+           .crc_pdu_list[UL_INFO->crc_ind.crc_indication_body.number_of_crcs];
 
-  UL_INFO->crc_ind.sfn_sf                    = frame<<4| subframe;
-  UL_INFO->crc_ind.vendor_extension		     = ul_config_req->vendor_extension;
-  UL_INFO->crc_ind.header.message_id              = NFAPI_CRC_INDICATION;
+  UL_INFO->crc_ind.sfn_sf = frame << 4 | subframe;
+  UL_INFO->crc_ind.vendor_extension = ul_config_req->vendor_extension;
+  UL_INFO->crc_ind.header.message_id = NFAPI_CRC_INDICATION;
   UL_INFO->crc_ind.crc_indication_body.tl.tag = NFAPI_CRC_INDICATION_BODY_TAG;
 
-  pdu->instance_length                                = 0; // don't know what to do with this
-  //  pdu->rx_ue_information.handle                       = handle;
-  pdu->rx_ue_information.tl.tag                       = NFAPI_RX_UE_INFORMATION_TAG;
+  pdu->instance_length = 0;
+  pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG;
 
-  //pdu->rx_ue_information.rnti                         = UE_mac_inst[Mod_id].crnti;
-  pdu->rx_ue_information.rnti                         = rnti;
-  pdu->crc_indication_rel8.tl.tag                     = NFAPI_CRC_INDICATION_REL8_TAG;
-  pdu->crc_indication_rel8.crc_flag                   = crc_flag;
+  pdu->rx_ue_information.rnti = rnti;
+  pdu->crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG;
+  pdu->crc_indication_rel8.crc_flag = crc_flag;
 
   UL_INFO->crc_ind.crc_indication_body.number_of_crcs++;
 
-  LOG_D(PHY, "%s() rnti:%04x pdus:%d\n", __FUNCTION__, pdu->rx_ue_information.rnti, UL_INFO->crc_ind.crc_indication_body.number_of_crcs);
+  LOG_D(PHY,
+        "%s() rnti:%04x pdus:%d\n",
+        __FUNCTION__,
+        pdu->rx_ue_information.rnti,
+        UL_INFO->crc_ind.crc_indication_body.number_of_crcs);
 
-  // change for mutiple UE's simulation.
-  // pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
   pthread_mutex_unlock(&fill_ul_mutex.crc_mutex);
 }
 
-void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t ra_PreambleIndex, uint16_t ra_RNTI) {
-
-	LOG_D(MAC, "fill_rach_indication_UE_MAC 1 \n");
-
-	// change for mutiple UE's simulation.
-	// pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
-	pthread_mutex_lock(&fill_ul_mutex.rach_mutex);
-
-	// memory allocation and free memory of UL_INFO are done in UE_phy_stub_single_thread_rxn_txnp4.
-	// UL_INFO = (UL_IND_t*)malloc(sizeof(UL_IND_t));
-
-	    UL_INFO->rach_ind.rach_indication_body.number_of_preambles                 = 1;
-
-	    //eNB->UL_INFO.rach_ind.preamble_list                       = &eNB->preamble_list[0];
-	    UL_INFO->rach_ind.header.message_id                         = NFAPI_RACH_INDICATION;
-	    UL_INFO->rach_ind.sfn_sf                                    = frame<<4 | subframe;
-	    UL_INFO->rach_ind.vendor_extension							= NULL;
-
-	    UL_INFO->rach_ind.rach_indication_body.tl.tag                              = NFAPI_RACH_INDICATION_BODY_TAG;
-
-
-	    UL_INFO->rach_ind.rach_indication_body.preamble_list = (nfapi_preamble_pdu_t*)malloc(UL_INFO->rach_ind.rach_indication_body.number_of_preambles*sizeof(nfapi_preamble_pdu_t));
-	    UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.tl.tag   		= NFAPI_PREAMBLE_REL8_TAG;
-	    UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance = 0; // Not sure about that
-
-	    //The two following should get extracted from the call to get_prach_resources().
-	    UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble = ra_PreambleIndex;
-	    UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti 	  = ra_RNTI;
-	    //UL_INFO->rach_ind.rach_indication_body.number_of_preambles++;
-
-
-	    UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel13.rach_resource_type = 0;
-	    UL_INFO->rach_ind.rach_indication_body.preamble_list[0].instance_length					 = 0;
-
-
-	          LOG_E(PHY,"\n\n\n\nDJP - this needs to be sent to VNF **********************************************\n\n\n\n");
-	          LOG_E(PHY,"UE Filling NFAPI indication for RACH : TA %d, Preamble %d, rnti %x, rach_resource_type %d\n",
-	        	  UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance,
-	        	  UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble,
-	        	  UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti,
-	        	  UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel13.rach_resource_type);
-
-	          // This function is currently defined only in the nfapi-RU-RAU-split so we should call it when we merge
-	          // with that branch.
-	          oai_nfapi_rach_ind(&UL_INFO->rach_ind);
-	          free(UL_INFO->rach_ind.rach_indication_body.preamble_list);
-
-	         // memory allocation and free memory of UL_INFO are done in UE_phy_stub_single_thread_rxn_txnp4.
-	          //free(UL_INFO);
-
-	        //}
-	      // change for mutiple UE's simulation.
-	      // pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
-	      pthread_mutex_unlock(&fill_ul_mutex.rach_mutex);
-
+void fill_rach_indication_UE_MAC(int Mod_id,
+                                 int frame,
+                                 int subframe,
+                                 UL_IND_t *UL_INFO,
+                                 uint8_t ra_PreambleIndex,
+                                 uint16_t ra_RNTI) {
+  LOG_D(MAC, "fill_rach_indication_UE_MAC 1 \n");
+
+  pthread_mutex_lock(&fill_ul_mutex.rach_mutex);
+
+  UL_INFO->rach_ind.rach_indication_body.number_of_preambles = 1;
+
+  UL_INFO->rach_ind.header.message_id = NFAPI_RACH_INDICATION;
+  UL_INFO->rach_ind.sfn_sf = frame << 4 | subframe;
+  UL_INFO->rach_ind.vendor_extension = NULL;
+
+  UL_INFO->rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG;
+
+  const int np = UL_INFO->rach_ind.rach_indication_body.number_of_preambles;
+  UL_INFO->rach_ind.rach_indication_body.preamble_list =
+      calloc(np, sizeof(nfapi_preamble_pdu_t));
+  UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.tl.tag =
+      NFAPI_PREAMBLE_REL8_TAG;
+  UL_INFO->rach_ind.rach_indication_body.preamble_list[0]
+      .preamble_rel8.timing_advance = 0; // Not sure about that
+
+  // The two following should get extracted from the call to
+  // get_prach_resources().
+  UL_INFO->rach_ind.rach_indication_body.preamble_list[0]
+      .preamble_rel8.preamble = ra_PreambleIndex;
+  UL_INFO->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti =
+      ra_RNTI;
+  // UL_INFO->rach_ind.rach_indication_body.number_of_preambles++;
+
+  UL_INFO->rach_ind.rach_indication_body.preamble_list[0]
+      .preamble_rel13.rach_resource_type = 0;
+  UL_INFO->rach_ind.rach_indication_body.preamble_list[0].instance_length = 0;
+
+  LOG_I(PHY,
+        "UE Filling NFAPI indication for RACH : TA %d, Preamble %d, rnti %x, "
+        "rach_resource_type %d\n",
+        UL_INFO->rach_ind.rach_indication_body.preamble_list[0]
+            .preamble_rel8.timing_advance,
+        UL_INFO->rach_ind.rach_indication_body.preamble_list[0]
+            .preamble_rel8.preamble,
+        UL_INFO->rach_ind.rach_indication_body.preamble_list[0]
+            .preamble_rel8.rnti,
+        UL_INFO->rach_ind.rach_indication_body.preamble_list[0]
+            .preamble_rel13.rach_resource_type);
+
+  // This function is currently defined only in the nfapi-RU-RAU-split so we
+  // should call it when we merge with that branch.
+  oai_nfapi_rach_ind(&UL_INFO->rach_ind);
+  free(UL_INFO->rach_ind.rach_indication_body.preamble_list);
+
+  pthread_mutex_unlock(&fill_ul_mutex.rach_mutex);
 }
 
-void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, uint16_t frame,uint8_t subframe, UL_IND_t *UL_INFO, uint16_t rnti) {
-
-	// change for mutiple UE's simulation.
-	//pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
-	pthread_mutex_lock(&fill_ul_mutex.cqi_mutex);
-	nfapi_cqi_indication_pdu_t *pdu         = &UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list[UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis];
-	nfapi_cqi_indication_raw_pdu_t *raw_pdu = &UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list[UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis];
-
-	pdu->rx_ue_information.tl.tag          = NFAPI_RX_UE_INFORMATION_TAG;
-	pdu->rx_ue_information.rnti = rnti;
-	// Since we assume that CRC flag is always 0 (ACK) I guess that data_offset should always be 0.
-	pdu->cqi_indication_rel9.data_offset = 0;
-
-	// by default set O to rank 1 value
-	//pdu->cqi_indication_rel9.length = (ulsch_harq->Or1>>3) + ((ulsch_harq->Or1&7) > 0 ? 1 : 0);
-	//  Not useful field for our case
-	pdu->cqi_indication_rel9.tl.tag = NFAPI_CQI_INDICATION_REL9_TAG;
-	pdu->cqi_indication_rel9.length = 0;
-	pdu->cqi_indication_rel9.ri[0]  = 0;
-
-
-	pdu->cqi_indication_rel9.timing_advance = 0;
-  pdu->cqi_indication_rel9.number_of_cc_reported = 1;
+void fill_ulsch_cqi_indication_UE_MAC(int Mod_id,
+                                      uint16_t frame,
+                                      uint8_t subframe,
+                                      UL_IND_t *UL_INFO,
+                                      uint16_t rnti) {
+  pthread_mutex_lock(&fill_ul_mutex.cqi_mutex);
+  nfapi_cqi_indication_pdu_t *pdu =
+      &UL_INFO->cqi_ind.cqi_indication_body
+           .cqi_pdu_list[UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis];
+  nfapi_cqi_indication_raw_pdu_t *raw_pdu =
+      &UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list
+           [UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis];
+
+  UL_INFO->cqi_ind.sfn_sf = frame << 4 | subframe;
+  // because of nfapi_vnf.c:733, set message id to 0, not
+  // NFAPI_RX_CQI_INDICATION;
+  UL_INFO->cqi_ind.header.message_id = 0;
+  UL_INFO->cqi_ind.cqi_indication_body.tl.tag = NFAPI_CQI_INDICATION_BODY_TAG;
+
+  pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG;
+  pdu->rx_ue_information.rnti = rnti;
+  // Since we assume that CRC flag is always 0 (ACK) I guess that data_offset
+  // should always be 0.
+  pdu->cqi_indication_rel8.data_offset = 0;
+
+  pdu->cqi_indication_rel8.tl.tag = NFAPI_CQI_INDICATION_REL8_TAG;
+  pdu->cqi_indication_rel8.length = 1;
+  pdu->cqi_indication_rel8.ri = 0;
+
+  pdu->cqi_indication_rel8.timing_advance = 0;
+  // pdu->cqi_indication_rel8.number_of_cc_reported = 1;
+  pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG;
   pdu->ul_cqi_information.channel = 1; // PUSCH
 
-  // Not sure how to substitute this. This should be the actual CQI value? So can
-  // we hardcode it to a specific value?
-  //memcpy((void*)raw_pdu->pdu,ulsch_harq->o,pdu->cqi_indication_rel9.length);
-  raw_pdu->pdu[0] = 7;
-
-
+  // eNB_scheduler_primitives.c:4839: the upper four bits seem to be the CQI
+  const int cqi = 15;
+  raw_pdu->pdu[0] = cqi << 4;
 
   UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis++;
-  // change for mutiple UE's simulation.
-  //pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
   pthread_mutex_unlock(&fill_ul_mutex.cqi_mutex);
 }
 
-void fill_ulsch_harq_indication_UE_MAC(int Mod_id, int frame,int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_ulsch_harq_information *harq_information, uint16_t rnti)
-{
-
-  // change for mutiple UE's simulation.
-  //pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
+void fill_ulsch_harq_indication_UE_MAC(
+    int Mod_id,
+    int frame,
+    int subframe,
+    UL_IND_t *UL_INFO,
+    nfapi_ul_config_ulsch_harq_information *harq_information,
+    uint16_t rnti) {
   pthread_mutex_lock(&fill_ul_mutex.harq_mutex);
 
-  nfapi_harq_indication_pdu_t *pdu =   &UL_INFO->harq_ind.harq_indication_body.harq_pdu_list[UL_INFO->harq_ind.harq_indication_body.number_of_harqs];
-  int i;
+  nfapi_harq_indication_pdu_t *pdu =
+      &UL_INFO->harq_ind.harq_indication_body.harq_pdu_list
+           [UL_INFO->harq_ind.harq_indication_body.number_of_harqs];
 
   UL_INFO->harq_ind.header.message_id = NFAPI_HARQ_INDICATION;
-  UL_INFO->harq_ind.sfn_sf = frame<<4|subframe;
-  UL_INFO->harq_ind.vendor_extension		     = ul_config_req->vendor_extension;
+  UL_INFO->harq_ind.sfn_sf = frame << 4 | subframe;
+  UL_INFO->harq_ind.vendor_extension = ul_config_req->vendor_extension;
 
-  UL_INFO->harq_ind.harq_indication_body.tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG;
+  UL_INFO->harq_ind.harq_indication_body.tl.tag =
+      NFAPI_HARQ_INDICATION_BODY_TAG;
 
-  pdu->instance_length                                = 0; // don't know what to do with this
+  pdu->instance_length = 0; // don't know what to do with this
   //  pdu->rx_ue_information.handle                       = handle;
-  pdu->rx_ue_information.tl.tag                       = NFAPI_RX_UE_INFORMATION_TAG;
-  pdu->rx_ue_information.rnti                         = rnti;
+  pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG;
+  pdu->rx_ue_information.rnti = rnti;
 
   // For now we consider only FDD
-  //if (eNB->frame_parms.frame_type == FDD) {
-    pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG;
-    pdu->harq_indication_fdd_rel13.mode = 0;
-    pdu->harq_indication_fdd_rel13.number_of_ack_nack = harq_information->harq_information_rel10.harq_size;
+  // if (eNB->frame_parms.frame_type == FDD) {
+  pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG;
+  pdu->harq_indication_fdd_rel13.mode = 0;
+  pdu->harq_indication_fdd_rel13.number_of_ack_nack =
+      harq_information->harq_information_rel10.harq_size;
 
-    // Could this be wrong? Is the number_of_ack_nack field equivalent to O_ACK?
-    //pdu->harq_indication_fdd_rel13.number_of_ack_nack = ulsch_harq->O_ACK;
+  // Could this be wrong? Is the number_of_ack_nack field equivalent to O_ACK?
+  // pdu->harq_indication_fdd_rel13.number_of_ack_nack = ulsch_harq->O_ACK;
 
-    for (i=0;i<harq_information->harq_information_rel10.harq_size;i++) {
-
-      pdu->harq_indication_fdd_rel13.harq_tb_n[i] = 1; // Assuming always an ACK (No NACK or DTX)
-
-    }
+  for (int i = 0; i < harq_information->harq_information_rel10.harq_size; i++) {
+    pdu->harq_indication_fdd_rel13.harq_tb_n[i] = 1; // Assume always ACK (No NACK or DTX)
+  }
 
   UL_INFO->harq_ind.harq_indication_body.number_of_harqs++;
-  // change for mutiple UE's simulation.
-  //pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
-  pthread_mutex_unlock(&fill_ul_mutex.harq_mutex);}
-
+  pthread_mutex_unlock(&fill_ul_mutex.harq_mutex);
+}
 
 void fill_uci_harq_indication_UE_MAC(int Mod_id,
 			      int frame,
 			      int subframe,
 			      UL_IND_t *UL_INFO,
 			      nfapi_ul_config_harq_information *harq_information,
-			      uint16_t rnti
-			      /*uint8_t tdd_mapping_mode,
-			      uint16_t tdd_multiplexing_mask*/) {
-
-
-  // change for mutiple UE's simulation.
-  //pthread_mutex_lock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
+			      uint16_t rnti) {
   pthread_mutex_lock(&fill_ul_mutex.harq_mutex);
 
-  nfapi_harq_indication_t *ind       = &UL_INFO->harq_ind;
+  nfapi_harq_indication_t *ind = &UL_INFO->harq_ind;
   nfapi_harq_indication_body_t *body = &ind->harq_indication_body;
-  nfapi_harq_indication_pdu_t *pdu =   &body->harq_pdu_list[UL_INFO->harq_ind.harq_indication_body.number_of_harqs];
+  nfapi_harq_indication_pdu_t *pdu =
+      &body->harq_pdu_list[UL_INFO->harq_ind.harq_indication_body
+                               .number_of_harqs];
 
-  UL_INFO->harq_ind.vendor_extension		     = ul_config_req->vendor_extension;
+  UL_INFO->harq_ind.vendor_extension = ul_config_req->vendor_extension;
 
-  ind->sfn_sf = frame<<4|subframe;
+  ind->sfn_sf = frame << 4 | subframe;
   ind->header.message_id = NFAPI_HARQ_INDICATION;
 
   body->tl.tag = NFAPI_HARQ_INDICATION_BODY_TAG;
-  pdu->rx_ue_information.tl.tag                       = NFAPI_RX_UE_INFORMATION_TAG;
+  pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG;
 
-  pdu->instance_length                                = 0; // don't know what to do with this
-  //  pdu->rx_ue_information.handle                       = handle;
-  pdu->rx_ue_information.rnti                         = rnti;
+  pdu->instance_length = 0; // don't know what to do with this
+  pdu->rx_ue_information.rnti = rnti;
 
   pdu->ul_cqi_information.tl.tag = NFAPI_UL_CQI_INFORMATION_TAG;
 
   int SNRtimes10 = 640;
 
-
-  if      (SNRtimes10 < -640) pdu->ul_cqi_information.ul_cqi=0;
-  else if (SNRtimes10 >  635) pdu->ul_cqi_information.ul_cqi=255;
-  else                        pdu->ul_cqi_information.ul_cqi=(640+SNRtimes10)/5;
+  if (SNRtimes10 < -640)
+    pdu->ul_cqi_information.ul_cqi = 0;
+  else if (SNRtimes10 > 635)
+    pdu->ul_cqi_information.ul_cqi = 255;
+  else
+    pdu->ul_cqi_information.ul_cqi = (640 + SNRtimes10) / 5;
   pdu->ul_cqi_information.channel = 0;
-  if(harq_information->harq_information_rel9_fdd.tl.tag == NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG){
-      if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0) &&
-          (harq_information->harq_information_rel9_fdd.harq_size == 1)) {
-
-      pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG;
+  if (harq_information->harq_information_rel9_fdd.tl.tag
+      == NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL9_FDD_TAG) {
+    if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0)
+        && (harq_information->harq_information_rel9_fdd.harq_size == 1)) {
+      pdu->harq_indication_fdd_rel13.tl.tag =
+          NFAPI_HARQ_INDICATION_FDD_REL13_TAG;
       pdu->harq_indication_fdd_rel13.mode = 0;
       pdu->harq_indication_fdd_rel13.number_of_ack_nack = 1;
 
-      //AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]);
-      pdu->harq_indication_fdd_rel13.harq_tb_n[0] = 1; // Assuming always an ACK (No NACK or DTX)
-
+      // AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4,
+      // "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]);
+      pdu->harq_indication_fdd_rel13.harq_tb_n[0] =
+          1; // Assuming always an ACK (No NACK or DTX)
 
-    }
-    else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0) &&
-                 (harq_information->harq_information_rel9_fdd.harq_size == 2)) {
-      pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG;
+    } else if ((harq_information->harq_information_rel9_fdd.ack_nack_mode == 0)
+               && (harq_information->harq_information_rel9_fdd.harq_size
+                   == 2)) {
+      pdu->harq_indication_fdd_rel13.tl.tag =
+          NFAPI_HARQ_INDICATION_FDD_REL13_TAG;
       pdu->harq_indication_fdd_rel13.mode = 0;
       pdu->harq_indication_fdd_rel13.number_of_ack_nack = 2;
-      pdu->harq_indication_fdd_rel13.harq_tb_n[0] = 1; // Assuming always an ACK (No NACK or DTX)
-      pdu->harq_indication_fdd_rel13.harq_tb_n[1] = 1; // Assuming always an ACK (No NACK or DTX)
-
+      pdu->harq_indication_fdd_rel13.harq_tb_n[0] =
+          1; // Assuming always an ACK (No NACK or DTX)
+      pdu->harq_indication_fdd_rel13.harq_tb_n[1] =
+          1; // Assuming always an ACK (No NACK or DTX)
     }
-  }else if(harq_information->harq_information_rel10_tdd.tl.tag == NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG ){
-      if ((harq_information->harq_information_rel10_tdd.ack_nack_mode == 0) &&
-          (harq_information->harq_information_rel10_tdd.harq_size == 1)) {
-        pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
-        pdu->harq_indication_tdd_rel13.mode = 0;
-        pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1;
-        pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1;
-
-      }  else if ((harq_information->harq_information_rel10_tdd.ack_nack_mode == 1) &&
-                  (harq_information->harq_information_rel10_tdd.harq_size == 2)) {
-        pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
-        pdu->harq_indication_tdd_rel13.mode = 0;
-        pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1;
-        pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1;
-        pdu->harq_indication_tdd_rel13.harq_data[1].bundling.value_0 = 1;
-
-      }
-  } else AssertFatal(1==0,"only format 1a/b for now, received \n");
-
+  } else if (harq_information->harq_information_rel10_tdd.tl.tag
+             == NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL10_TDD_TAG) {
+    if ((harq_information->harq_information_rel10_tdd.ack_nack_mode == 0)
+        && (harq_information->harq_information_rel10_tdd.harq_size == 1)) {
+      pdu->harq_indication_tdd_rel13.tl.tag =
+          NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
+      pdu->harq_indication_tdd_rel13.mode = 0;
+      pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1;
+      pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1;
+
+    } else if ((harq_information->harq_information_rel10_tdd.ack_nack_mode == 1)
+               && (harq_information->harq_information_rel10_tdd.harq_size
+                   == 2)) {
+      pdu->harq_indication_tdd_rel13.tl.tag =
+          NFAPI_HARQ_INDICATION_TDD_REL13_TAG;
+      pdu->harq_indication_tdd_rel13.mode = 0;
+      pdu->harq_indication_tdd_rel13.number_of_ack_nack = 1;
+      pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1;
+      pdu->harq_indication_tdd_rel13.harq_data[1].bundling.value_0 = 1;
+    }
+  } else
+    AssertFatal(1 == 0, "only format 1a/b for now, received \n");
 
   UL_INFO->harq_ind.harq_indication_body.number_of_harqs++;
-  LOG_D(PHY,"Incremented eNB->UL_INFO.harq_ind.number_of_harqs:%d\n", UL_INFO->harq_ind.harq_indication_body.number_of_harqs);
-  // change for mutiple UE's simulation.
-  //pthread_mutex_unlock(&UE_mac_inst[Mod_id].UL_INFO_mutex);
+  LOG_D(PHY,
+        "Incremented eNB->UL_INFO.harq_ind.number_of_harqs:%d\n",
+        UL_INFO->harq_ind.harq_indication_body.number_of_harqs);
   pthread_mutex_unlock(&fill_ul_mutex.harq_mutex);
-
 }
 
-
 void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
-                         nfapi_ul_config_request_pdu_t *ul_config_pdu,
-                         uint16_t frame,uint8_t subframe,uint8_t srs_present, int index)
-{
-
+                                nfapi_ul_config_request_pdu_t *ul_config_pdu,
+                                uint16_t frame,
+                                uint8_t subframe,
+                                uint8_t srs_present,
+                                int index) {
   if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) {
-    LOG_D(PHY,"Applying UL config for UE, rnti %x for frame %d, subframe %d\n",
-         (ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8).rnti,frame,subframe);
-    uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32)));
+    LOG_D(PHY,
+          "Applying UL config for UE, rnti %x for frame %d, subframe %d\n",
+          (ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8).rnti,
+          frame,
+          subframe);
+    uint8_t ulsch_buffer[5477] __attribute__((aligned(32)));
     uint16_t buflen = ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size;
 
     uint16_t rnti = ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti;
-    uint8_t access_mode=SCHEDULED_ACCESS;
-    if(buflen>0){
-    	if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case
-    		LOG_D(MAC, "handle_nfapi_ul_pdu_UE_MAC 2.2, Mod_id:%d, SFN/SF: %d/%d \n", Mod_id, frame, subframe);
-    		fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
-    		fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti, index);
-    		Msg3_transmitted(Mod_id, 0, frame, 0);
-    		//  Modification
-    		UE_mac_inst[Mod_id].UE_mode[0] = PUSCH;
-    		UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
-
-    		// This should be done after the reception of the respective hi_dci0
-    		//UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
-    	}
-    	else {
-    		ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
-    		fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
-    		fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti, index);
-    	}
+    uint8_t access_mode = SCHEDULED_ACCESS;
+    if (buflen > 0) {
+      if (UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { // Msg3 case
+        LOG_D(MAC,
+              "handle_nfapi_ul_pdu_UE_MAC 2.2, Mod_id:%d, SFN/SF: %d/%d \n",
+              Mod_id,
+              frame,
+              subframe);
+        fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
+        fill_rx_indication_UE_MAC(Mod_id,
+                                  frame,
+                                  subframe,
+                                  UL_INFO,
+                                  UE_mac_inst[Mod_id].RA_prach_resources.Msg3,
+                                  buflen,
+                                  rnti,
+                                  index);
+        Msg3_transmitted(Mod_id, 0, frame, 0);
+        //  Modification
+        UE_mac_inst[Mod_id].UE_mode[0] = PUSCH;
+        UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
+
+        // This should be done after the reception of the respective hi_dci0
+        // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
+      } else {
+        ue_get_sdu(Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
+        fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
+        fill_rx_indication_UE_MAC(Mod_id,
+                                  frame,
+                                  subframe,
+                                  UL_INFO,
+                                  ulsch_buffer,
+                                  buflen,
+                                  rnti,
+                                  index);
+      }
     }
   }
 
   else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE) {
+    // AssertFatal((UE_id =
+    // find_ulsch(ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0,
+    //            "No available UE ULSCH for rnti
+    //            %x\n",ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti);
+    uint8_t ulsch_buffer[5477] __attribute__((aligned(32)));
+    uint16_t buflen =
+        ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.size;
+    nfapi_ul_config_ulsch_harq_information *ulsch_harq_information =
+        &ul_config_pdu->ulsch_harq_pdu.harq_information;
+    uint16_t rnti = ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti;
+    uint8_t access_mode = SCHEDULED_ACCESS;
+    if (buflen > 0) {
+      if (UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { // Msg3 case
+        fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
+        fill_rx_indication_UE_MAC(Mod_id,
+                                  frame,
+                                  subframe,
+                                  UL_INFO,
+                                  UE_mac_inst[Mod_id].RA_prach_resources.Msg3,
+                                  buflen,
+                                  rnti,
+                                  index);
+        Msg3_transmitted(Mod_id, 0, frame, 0);
+        // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
+        // Modification
+        UE_mac_inst[Mod_id].UE_mode[0] = PUSCH;
+        UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
+      } else {
+        ue_get_sdu(Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
+        fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
+        fill_rx_indication_UE_MAC(Mod_id,
+                                  frame,
+                                  subframe,
+                                  UL_INFO,
+                                  ulsch_buffer,
+                                  buflen,
+                                  rnti,
+                                  index);
+      }
+    }
+    if (ulsch_harq_information != NULL)
+      fill_ulsch_harq_indication_UE_MAC(
+          Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti);
+
+  } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) {
+    uint8_t ulsch_buffer[5477] __attribute__((aligned(32)));
+    uint16_t buflen = ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.size;
+
+    uint16_t rnti = ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti;
+    uint8_t access_mode = SCHEDULED_ACCESS;
+    if (buflen > 0) {
+      if (UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { // Msg3 case
+        fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
+        fill_rx_indication_UE_MAC(Mod_id,
+                                  frame,
+                                  subframe,
+                                  UL_INFO,
+                                  UE_mac_inst[Mod_id].RA_prach_resources.Msg3,
+                                  buflen,
+                                  rnti,
+                                  index);
+        Msg3_transmitted(Mod_id, 0, frame, 0);
+        // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
+        // Modification
+        UE_mac_inst[Mod_id].UE_mode[0] = PUSCH;
+        UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
+      } else {
+        ue_get_sdu(Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
+        fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
+        fill_rx_indication_UE_MAC(Mod_id,
+                                  frame,
+                                  subframe,
+                                  UL_INFO,
+                                  ulsch_buffer,
+                                  buflen,
+                                  rnti,
+                                  index);
+      }
+    }
+  } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE) {
+    uint8_t ulsch_buffer[5477] __attribute__((aligned(32)));
+    uint16_t buflen = ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.size;
+    nfapi_ul_config_ulsch_harq_information *ulsch_harq_information =
+        &ul_config_pdu->ulsch_cqi_harq_ri_pdu.harq_information;
+
+    uint16_t rnti = ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti;
+    uint8_t access_mode = SCHEDULED_ACCESS;
+    if (buflen > 0) {
+      if (UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) { // Msg3 case
+        fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
+        fill_rx_indication_UE_MAC(Mod_id,
+                                  frame,
+                                  subframe,
+                                  UL_INFO,
+                                  UE_mac_inst[Mod_id].RA_prach_resources.Msg3,
+                                  buflen,
+                                  rnti,
+                                  index);
+        Msg3_transmitted(Mod_id, 0, frame, 0);
+        // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
+        // Modification
+        UE_mac_inst[Mod_id].UE_mode[0] = PUSCH;
+        UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
+      } else {
+        ue_get_sdu(Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
+        fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
+        fill_rx_indication_UE_MAC(Mod_id,
+                                  frame,
+                                  subframe,
+                                  UL_INFO,
+                                  ulsch_buffer,
+                                  buflen,
+                                  rnti,
+                                  index);
+      }
+    }
 
-	  //AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0,
-    //            "No available UE ULSCH for rnti %x\n",ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti);
-	  uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32)));
-	  uint16_t buflen = ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.size;
-	  nfapi_ul_config_ulsch_harq_information *ulsch_harq_information = &ul_config_pdu->ulsch_harq_pdu.harq_information;
-	  uint16_t rnti = ul_config_pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti;
-	  uint8_t access_mode=SCHEDULED_ACCESS;
-	  if(buflen>0){
-		  if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case
-			  fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
-			  fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti, index);
-			  Msg3_transmitted(Mod_id, 0, frame, 0);
-			  //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
-			  // Modification
-			  UE_mac_inst[Mod_id].UE_mode[0] = PUSCH;
-			  UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
-		  }
-		  else {
-			  ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
-			  fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
-			  fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti, index);
-		  }
-
-	  }
-	  if(ulsch_harq_information!=NULL)
-		  fill_ulsch_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti);
-
-  }
-  else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) {
-	 uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32)));
-	  uint16_t buflen = ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.size;
-
-	  uint16_t rnti = ul_config_pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti;
-	  uint8_t access_mode=SCHEDULED_ACCESS;
-	  if(buflen>0){
-		  if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case
-			  fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
-			  fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti, index);
-			  Msg3_transmitted(Mod_id, 0, frame, 0);
-			  //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
-			  // Modification
-			  UE_mac_inst[Mod_id].UE_mode[0] = PUSCH;
-			  UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
-		  }
-		  else {
-			  ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
-			  fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
-			  fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti, index);
-		  }
-	  }
-	  fill_ulsch_cqi_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti);
-
-  }
-  else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE) {
-
-	  uint8_t ulsch_buffer[5477] __attribute__ ((aligned(32)));
-	  uint16_t buflen = ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.size;
-	  nfapi_ul_config_ulsch_harq_information *ulsch_harq_information = &ul_config_pdu->ulsch_cqi_harq_ri_pdu.harq_information;
-
-	  uint16_t rnti = ul_config_pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti;
-	  uint8_t access_mode=SCHEDULED_ACCESS;
-	  if(buflen>0){
-		  if(UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){ // Msg3 case
-			  fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
-			  fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, UE_mac_inst[Mod_id].RA_prach_resources.Msg3,buflen, rnti, index);
-			  Msg3_transmitted(Mod_id, 0, frame, 0);
-			  //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
-			  // Modification
-			  UE_mac_inst[Mod_id].UE_mode[0] = PUSCH;
-			  UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
-		  }
-		  else {
-			  ue_get_sdu( Mod_id, 0, frame, subframe, 0, ulsch_buffer, buflen, &access_mode);
-			  fill_crc_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, 0, index, rnti);
-			  fill_rx_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_buffer,buflen, rnti, index);
-		  }
-	  }
-
-	  if(ulsch_harq_information!=NULL)
-		  fill_ulsch_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti);
-	  fill_ulsch_cqi_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti);
-
-  }
-  else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) {
-
-	  uint16_t rnti = ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti;
-
-	  nfapi_ul_config_harq_information *ulsch_harq_information = &ul_config_pdu->uci_harq_pdu.harq_information;
-	  if(ulsch_harq_information != NULL)
-		  fill_uci_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO,ulsch_harq_information, rnti);
-  }
-  else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE) {
-    AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE not handled yet\n");
-  }
-  else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE) {
-    AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE not handled yet\n");
-  }
-  else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE) {
-    AssertFatal(1==0,"NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE not handled yet\n");
-  }
-  else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE) {
-
-	  uint16_t rnti = ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti;
-
-	  if (ue_get_SR(Mod_id ,0,frame, 0, rnti, subframe))
-		  fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti);
-
-  }
-  else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE) {
-    //AssertFatal((UE_id = find_uci(rel8->rnti,proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0,
-    //            "No available UE UCI for rnti %x\n",ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti);
-
-	  uint16_t rnti = ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti;
-
-	  // We fill the sr_indication only if ue_get_sr() would normally instruct PHY to send a SR.
-	  if (ue_get_SR(Mod_id ,0,frame, 0, rnti, subframe))
-		  fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO,rnti);
-
-	  nfapi_ul_config_harq_information *ulsch_harq_information = &ul_config_pdu->uci_sr_harq_pdu.harq_information;
-	  if (ulsch_harq_information != NULL)
-		  fill_uci_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO,ulsch_harq_information, rnti);
-
+    if (ulsch_harq_information != NULL)
+      fill_ulsch_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti);
+  } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) {
+    uint16_t rnti = ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti;
+
+    nfapi_ul_config_harq_information *ulsch_harq_information = &ul_config_pdu->uci_harq_pdu.harq_information;
+    if (ulsch_harq_information != NULL)
+      fill_uci_harq_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti);
+  } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE) {
+    AssertFatal(1 == 0, "NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE not handled yet\n");
+  } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE) {
+    AssertFatal(1 == 0,
+                "NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE not handled yet\n");
+  } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE) {
+    AssertFatal(1 == 0,
+                "NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE not handled yet\n");
+  } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE) {
+    uint16_t rnti =
+        ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti;
+
+    if (ue_get_SR(Mod_id, 0, frame, 0, rnti, subframe))
+      fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti);
+
+  } else if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE) {
+    // AssertFatal((UE_id =
+    // find_uci(rel8->rnti,proc->frame_tx,proc->subframe_tx,eNB,SEARCH_EXIST_OR_FREE))>=0,
+    //            "No available UE UCI for rnti
+    //            %x\n",ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti);
+
+    uint16_t rnti =
+        ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti;
+
+    // We fill the sr_indication only if ue_get_sr() would normally instruct PHY
+    // to send a SR.
+    if (ue_get_SR(Mod_id, 0, frame, 0, rnti, subframe))
+      fill_sr_indication_UE_MAC(Mod_id, frame, subframe, UL_INFO, rnti);
+
+    nfapi_ul_config_harq_information *ulsch_harq_information =
+        &ul_config_pdu->uci_sr_harq_pdu.harq_information;
+    if (ulsch_harq_information != NULL)
+      fill_uci_harq_indication_UE_MAC(
+          Mod_id, frame, subframe, UL_INFO, ulsch_harq_information, rnti);
   }
-
 }
 
-
-
-
-
-
-int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int timer_frame, int timer_subframe, module_id_t Mod_id)
-{
-	//if (req!=NULL){ // && req->ul_config_request_body.ul_config_pdu_list !=NULL){
-  LOG_D(PHY,"[PNF] UL_CONFIG_REQ %s() sfn_sf:%d pdu:%d rach_prach_frequency_resources:%d srs_present:%u\n",
-      __FUNCTION__,
-      NFAPI_SFNSF2DEC(req->sfn_sf),
-      req->ul_config_request_body.number_of_pdus,
-      req->ul_config_request_body.rach_prach_frequency_resources,
-      req->ul_config_request_body.srs_present
-      );
+int ul_config_req_UE_MAC(nfapi_ul_config_request_t *req,
+                         int timer_frame,
+                         int timer_subframe,
+                         module_id_t Mod_id) {
+  LOG_D(PHY,
+        "[PNF] UL_CONFIG_REQ %s() sfn_sf:%d pdu:%d "
+        "rach_prach_frequency_resources:%d srs_present:%u\n",
+        __FUNCTION__,
+        NFAPI_SFNSF2DEC(req->sfn_sf),
+        req->ul_config_request_body.number_of_pdus,
+        req->ul_config_request_body.rach_prach_frequency_resources,
+        req->ul_config_request_body.srs_present);
 
   int sfn = NFAPI_SFNSF2SFN(req->sfn_sf);
   int sf = NFAPI_SFNSF2SF(req->sfn_sf);
 
-
-  LOG_D(MAC, "ul_config_req_UE_MAC() TOTAL NUMBER OF UL_CONFIG PDUs: %d, SFN/SF: %d/%d \n", req->ul_config_request_body.number_of_pdus, timer_frame, timer_subframe);
-
-
-
-  for (int i=0;i<req->ul_config_request_body.number_of_pdus;i++)
-  {
-
-    if (
-    		(req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].ulsch_pdu.ulsch_pdu_rel8.rnti == UE_mac_inst[Mod_id].crnti) ||
-    		(req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == UE_mac_inst[Mod_id].crnti) ||
-    		(req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == UE_mac_inst[Mod_id].crnti) ||
-    		(req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == UE_mac_inst[Mod_id].crnti) ||
-    		(req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].uci_cqi_harq_pdu.ue_information.ue_information_rel8.rnti == UE_mac_inst[Mod_id].crnti) ||
-    		(req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].uci_sr_pdu.ue_information.ue_information_rel8.rnti == UE_mac_inst[Mod_id].crnti) ||
-    		(req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE && req->ul_config_request_body.ul_config_pdu_list[i].uci_cqi_sr_harq_pdu.ue_information.ue_information_rel8.rnti == UE_mac_inst[Mod_id].crnti)
-       )
-    {
-
-      handle_nfapi_ul_pdu_UE_MAC(Mod_id,&req->ul_config_request_body.ul_config_pdu_list[i],sfn,sf,req->ul_config_request_body.srs_present, i);
-
-    }
-    else
-    {
-      //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() PDU:%i UNKNOWN type :%d\n", __FUNCTION__, i, ul_config_pdu_list[i].pdu_type);
+  LOG_D(MAC,
+        "ul_config_req_UE_MAC() TOTAL NUMBER OF UL_CONFIG PDUs: %d, SFN/SF: "
+        "%d/%d \n",
+        req->ul_config_request_body.number_of_pdus,
+        timer_frame,
+        timer_subframe);
+
+  const rnti_t rnti = UE_mac_inst[Mod_id].crnti;
+  for (int i = 0; i < req->ul_config_request_body.number_of_pdus; i++) {
+    nfapi_ul_config_request_pdu_t* pdu = &req->ul_config_request_body.ul_config_pdu_list[i];
+    const int pdu_type = pdu->pdu_type;
+    if (   (pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE
+            && pdu->ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)
+        || (pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE
+            && pdu->ulsch_harq_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)
+        || (pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE
+            && pdu->ulsch_cqi_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)
+        || (pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE
+            && pdu->ulsch_cqi_harq_ri_pdu.ulsch_pdu.ulsch_pdu_rel8.rnti == rnti)
+        || (pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE
+            && pdu->uci_cqi_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)
+        || (pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE
+            && pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti == rnti)
+        || (pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE
+            && pdu->uci_cqi_sr_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)) {
+      handle_nfapi_ul_pdu_UE_MAC(
+          Mod_id, pdu, sfn, sf, req->ul_config_request_body.srs_present, i);
+    } else {
+      // NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() PDU:%i UNKNOWN type :%d\n",
+      // __FUNCTION__, i, ul_config_pdu_list[i].pdu_type);
     }
   }
 
-//	}
-
   return 0;
 }
 
-
-
-int tx_req_UE_MAC(nfapi_tx_request_t* req)
-{
-
-  LOG_D(PHY,"%s() SFN/SF:%d/%d PDUs:%d\n", __FUNCTION__, NFAPI_SFNSF2SFN(req->sfn_sf), NFAPI_SFNSF2SF(req->sfn_sf), req->tx_request_body.number_of_pdus);
-
-
-    for (int i=0; i<req->tx_request_body.number_of_pdus; i++)
-    {
-      LOG_D(PHY,"%s() SFN/SF:%d/%d number_of_pdus:%d [PDU:%d] pdu_length:%d pdu_index:%d num_segments:%d\n",
+int tx_req_UE_MAC(nfapi_tx_request_t *req) {
+  LOG_D(PHY,
+        "%s() SFN/SF:%d/%d PDUs:%d\n",
+        __FUNCTION__,
+        NFAPI_SFNSF2SFN(req->sfn_sf),
+        NFAPI_SFNSF2SF(req->sfn_sf),
+        req->tx_request_body.number_of_pdus);
+
+  for (int i = 0; i < req->tx_request_body.number_of_pdus; i++) {
+    LOG_D(PHY,
+          "%s() SFN/SF:%d/%d number_of_pdus:%d [PDU:%d] pdu_length:%d "
+          "pdu_index:%d num_segments:%d\n",
           __FUNCTION__,
-          NFAPI_SFNSF2SFN(req->sfn_sf), NFAPI_SFNSF2SF(req->sfn_sf),
+          NFAPI_SFNSF2SFN(req->sfn_sf),
+          NFAPI_SFNSF2SF(req->sfn_sf),
           req->tx_request_body.number_of_pdus,
           i,
           req->tx_request_body.tx_pdu_list[i].pdu_length,
           req->tx_request_body.tx_pdu_list[i].pdu_index,
-          req->tx_request_body.tx_pdu_list[i].num_segments
-          );
-
-    }
+          req->tx_request_body.tx_pdu_list[i].num_segments);
+  }
 
   return 0;
 }
 
-
-int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, module_id_t Mod_id) //, nfapi_tx_request_pdu_t* tx_request_pdu_list)
-{
-	//if (req!=NULL && tx_request_pdu_list!=NULL){
+int dl_config_req_UE_MAC(nfapi_dl_config_request_t* req, module_id_t Mod_id) {
   int sfn = NFAPI_SFNSF2SFN(req->sfn_sf);
   int sf = NFAPI_SFNSF2SF(req->sfn_sf);
-  //Mod_id = 0; // Currently static (only for one UE) but this should change.
 
-  /*struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
-  L1_rxtx_proc_t *proc = &eNB->proc.L1_proc;*/
   nfapi_dl_config_request_pdu_t* dl_config_pdu_list = req->dl_config_request_body.dl_config_pdu_list;
-  nfapi_dl_config_request_pdu_t *dl_config_pdu_tmp;
-
-  //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX:%d/%d RX:%d/%d sfn_sf:%d DCI:%d PDU:%d\n", __FUNCTION__, proc->frame_tx, proc->subframe_tx, proc->frame_rx, proc->subframe_rx, NFAPI_SFNSF2DEC(req->sfn_sf), req->dl_config_request_body.number_dci, req->dl_config_request_body.number_pdu);
-
-
-
-  //LOG_D(PHY,"NFAPI: Sched_INFO:SFN/SF:%d%d dl_pdu:%d tx_req:%d hi_dci0:%d ul_cfg:%d num_pdcch_symbols:%d\n",
-  //	frame,subframe,number_dl_pdu,TX_req->tx_request_body.number_of_pdus,number_hi_dci0_pdu,number_ul_pdu, eNB->pdcch_vars[subframe&1].num_pdcch_symbols);
-
-  for (int i=0;i<req->dl_config_request_body.number_pdu;i++)
-  {
-    //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size);
-	  //LOG_E(MAC, "dl_config_req_UE_MAC 2 Received real ones: sfn/sf:%d.%d PDU[%d] size:%d\n", sfn, sf, i, dl_config_pdu_list[i].pdu_size);
-
-    if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)
-    {
-		if (dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 1) {
-			// C-RNTI (Normal DLSCH case)
-			dl_config_pdu_tmp = &dl_config_pdu_list[i+1];
-			if (dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && UE_mac_inst[Mod_id].crnti == dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti){
-
-				/*nfapi_tx_request_pdu_t *ptr = tx_request_pdu_list;
-				ptr += dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index*(sizeof(nfapi_tx_request_pdu_t));
-				nfapi_tx_request_pdu_t temp;
-				memset(&temp, 0, sizeof(nfapi_tx_request_pdu_t));
-				//if (!memcmp(&temp, ptr, sizeof(temp)) ...
-				if( *(char*)ptr != 0){
-				//if(tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data!= NULL && tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length >0){
-				*/
-
-				// to avoid unexpected error , add check pdu_index is more than 0.
-				if((dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index >= 0) &&(dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1)){
-				//if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){
-
-					LOG_E(MAC, "dl_config_req_UE_MAC 2 Received data: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d, tx_req_num_elems: %d \n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index, tx_req_num_elems);
-
-					ue_send_sdu(Mod_id, 0, sfn, sf,
-							tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data,
-							tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length,
-							0);
-					i++;
-				}
-				else{
-					LOG_E(MAC,"dl_config_req_UE_MAC 2: Problem with receiving data: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index);
-					i++;
-				}
-			}
-			else {
-				LOG_E(MAC,"[UE %d] Frame %d, subframe %d : DLSCH PDU from NFAPI not for this UE \n",Mod_id, sfn,sf);
-				i++;
-			}
-		}
-		else if (dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 2) {
-			dl_config_pdu_tmp = &dl_config_pdu_list[i+1];
-			if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFF && UE_mac_inst[Mod_id].UE_mode[0] != NOT_SYNCHED){ //&& UE_mac_inst[Mod_id].UE_mode[0] != NOT_SYNCHED
-
-				if(dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1){
-				//if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){
-					ue_decode_si(Mod_id, 0, sfn, 0,
-							tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data,
-							tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length);
-					i++;
-				}
-				else{
-					LOG_E(MAC,"dl_config_req_UE_MAC 3: Problem with receiving SI: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index);
-					i++;
-				}
-			}
-			else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE && dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti == 0xFFFE){
-				// P_RNTI case
-				//pdu = Tx_req->tx_request_body.tx_pdu_list[dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data;
-
-				if (dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1){
-				//if(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL){
-					ue_decode_p(Mod_id, 0, sfn, 0,
-							tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data,
-							tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_length);
-					i++;
-				}
-				else{
-					LOG_E(MAC,"dl_config_req_UE_MAC: Problem with receiving Paging: sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, dl_config_pdu_list[i].pdu_size, dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index);
-					i++;
-				}
-			}
-			else if(dl_config_pdu_tmp->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) {
-				// RA-RNTI case
-				LOG_E(MAC,"dl_config_req_UE_MAC 4 Received RAR? \n");
-				// RNTI parameter not actually used. Provided only to comply with existing function definition.
-				// Not sure about parameters to fill the preamble index.
-				//rnti_t c_rnti = UE_mac_inst[Mod_id].crnti;
-				rnti_t ra_rnti = UE_mac_inst[Mod_id].RA_prach_resources.ra_RNTI;
-				if ((UE_mac_inst[Mod_id].UE_mode[0] != PUSCH) &&
-				  (UE_mac_inst[Mod_id].RA_prach_resources.Msg3!=NULL) && (ra_rnti== dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti) &&
-				  //(tx_request_pdu_list + dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index!= NULL)) {
-				  (dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index <= tx_req_num_elems -1)) {
-					LOG_E(MAC,"dl_config_req_UE_MAC 5 Received RAR, PreambleIndex: %d \n", UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex);
-					ue_process_rar(Mod_id, 0, sfn,
-							ra_rnti, //RA-RNTI
-							tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data,
-							&dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti, //t-crnti
-							UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex,
-							tx_request_pdu_list[dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index].segments[0].segment_data);
-					UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE;
-					UE_mac_inst[Mod_id].first_ULSCH_Tx = 1; //Expecting an UL_CONFIG_ULSCH_PDU to enable Msg3 Txon (first ULSCH Txon for the UE)
-				}
-				i++;
-			}
-			else {
-				LOG_E(MAC,"[UE %d] Frame %d, subframe %d : Cannot extract DLSCH PDU from NFAPI 2\n",Mod_id, sfn, sf);
-				i++;
-			}
-
-		}
-    }
-    else if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_BCH_PDU_TYPE)
-    {
-    	// BCH case
-    	// Last parameter is 1 if first time synchronization and zero otherwise. Not sure which value to put
-    	// for our case.
-    	//LOG_E(MAC,"dl_config_req_UE_MAC 4 Received MIB: sfn/sf: %d.%d \n", sfn, sf);
-    	if(UE_mac_inst[Mod_id].UE_mode[0] == NOT_SYNCHED){
-    		dl_phy_sync_success(Mod_id,sfn,0, 1);
-    		LOG_E(MAC,"dl_config_req_UE_MAC 5 Received MIB: UE_mode: %d, sfn/sf: %d.%d\n", UE_mac_inst[Mod_id].UE_mode[0], sfn, sf);
-    		UE_mac_inst[Mod_id].UE_mode[0]=PRACH;
-    	}
-    	else
-    		dl_phy_sync_success(Mod_id,sfn,0, 0);
-
-    }
 
-    else
-    {
-      //NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() UNKNOWN:%d\n", __FUNCTION__, dl_config_pdu_list[i].pdu_type);
+  for (int i = 0; i < req->dl_config_request_body.number_pdu; i++) {
+    if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) {
+      const rnti_t rnti = dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti;
+      const int rnti_type = dl_config_pdu_list[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type;
+      /* We assume the DCI DL PDU is followed by the DLSCH (the standard is
+       * more free), so advance by one more and directly process the
+       * following DLSCH PDU */
+      i++;
+      AssertFatal(i < req->dl_config_request_body.number_pdu,
+                  "Need PDU following DCI at index %d, but not found\n",
+                  i);
+      nfapi_dl_config_request_pdu_t *dl_config_pdu_tmp = &dl_config_pdu_list[i];
+      if (dl_config_pdu_tmp->pdu_type != NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) {
+        LOG_E(MAC, "expected DLSCH PDU at index %d\n", i);
+        continue;
+      }
+      if (rnti != dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti) {
+        LOG_I(MAC,
+              "%s(): sfn/sf %d DLSCH PDU RNTI %x does not match DCI RNTI %x\n",
+              __func__,
+              NFAPI_SFNSF2DEC(req->sfn_sf),
+              rnti,
+              dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti);
+        continue;
+      }
+      const int pdu_index = dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index;
+      if (pdu_index < 0 && pdu_index >= tx_req_num_elems) {
+        LOG_E(MAC,
+              "dl_config_req_UE_MAC 2: Problem with receiving data: "
+              "sfn/sf:%d PDU[%d] size:%d, TX_PDU index: %d\n",
+              NFAPI_SFNSF2DEC(req->sfn_sf),
+              i,
+              dl_config_pdu_list[i].pdu_size,
+              dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index);
+        continue;
+      }
+      if (rnti_type == 1) {
+        // C-RNTI (Normal DLSCH case)
+        if (UE_mac_inst[Mod_id].crnti != rnti) {
+          LOG_D(MAC,
+                "sfn/sf %d/%d DCI not for UE %d/RNTI %x but for RNTI %x, "
+                "skipping\n",
+                sfn, sf, Mod_id, UE_mac_inst[Mod_id].crnti, rnti);
+          continue;
+        }
+
+        LOG_D(MAC,
+              "%s() Received data: sfn/sf:%d PDU[%d] "
+              "size:%d, TX_PDU index: %d, tx_req_num_elems: %d \n",
+              __func__,
+              NFAPI_SFNSF2DEC(req->sfn_sf),
+              i,
+              dl_config_pdu_list[i].pdu_size,
+              dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.pdu_index,
+              tx_req_num_elems);
+        ue_send_sdu(Mod_id, 0, sfn, sf,
+            tx_request_pdu_list[pdu_index].segments[0].segment_data,
+            tx_request_pdu_list[pdu_index].segments[0].segment_length,
+            0);
+      } else if (rnti_type == 2) {
+        if (rnti == 0xFFFF) { /* SI-RNTI */
+          if (UE_mac_inst[Mod_id].UE_mode[0] == NOT_SYNCHED) {
+            /* this check is in the code before refactoring, but I don't know
+             * why. Leave it in here for the moment */
+            continue;
+          }
+
+          ue_decode_si(Mod_id, 0, sfn, 0,
+              tx_request_pdu_list[pdu_index].segments[0].segment_data,
+              tx_request_pdu_list[pdu_index].segments[0].segment_length);
+        } else if (rnti == 0xFFFE) { /* PI-RNTI */
+          LOG_I(MAC, "%s() Received paging message: sfn/sf:%d PDU[%d]\n",
+                __func__, NFAPI_SFNSF2DEC(req->sfn_sf), i);
+          ue_decode_p(Mod_id, 0, sfn, 0,
+                      tx_request_pdu_list[pdu_index].segments[0].segment_data,
+                      tx_request_pdu_list[pdu_index].segments[0].segment_length);
+        } else if (rnti == 0x0002) { /* RA-RNTI */
+          LOG_E(MAC, "%s(): Received RAR?\n", __func__);
+          // RNTI parameter not actually used. Provided only to comply with
+          // existing function definition.  Not sure about parameters to fill
+          // the preamble index.
+          const rnti_t ra_rnti = UE_mac_inst[Mod_id].RA_prach_resources.ra_RNTI;
+          DevAssert(ra_rnti == 0x0002);
+          if (UE_mac_inst[Mod_id].UE_mode[0] != PUSCH
+              && UE_mac_inst[Mod_id].RA_prach_resources.Msg3 != NULL
+              && ra_rnti == dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti) {
+            LOG_E(MAC,
+                  "dl_config_req_UE_MAC 5 Received RAR, PreambleIndex: %d \n",
+                  UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex);
+            ue_process_rar(Mod_id, 0, sfn,
+                ra_rnti, //RA-RNTI
+                tx_request_pdu_list[pdu_index].segments[0].segment_data,
+                &dl_config_pdu_tmp->dlsch_pdu.dlsch_pdu_rel8.rnti, //t-crnti
+                UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex,
+                tx_request_pdu_list[pdu_index].segments[0].segment_data);
+            UE_mac_inst[Mod_id].UE_mode[0] = RA_RESPONSE;
+            // Expecting an UL_CONFIG_ULSCH_PDU to enable Msg3 Txon (first
+            // ULSCH Txon for the UE)
+            UE_mac_inst[Mod_id].first_ULSCH_Tx = 1;
+          }
+        } else {
+          LOG_W(MAC, "can not handle special RNTI %x\n", rnti);
+        }
+      }
+    } else if (dl_config_pdu_list[i].pdu_type == NFAPI_DL_CONFIG_BCH_PDU_TYPE) {
+      // BCH case: Last parameter is 1 if first time synchronization and zero
+      // otherwise.  Not sure which value to put for our case.
+      if (UE_mac_inst[Mod_id].UE_mode[0] == NOT_SYNCHED){
+        dl_phy_sync_success(Mod_id, sfn, 0, 1);
+        LOG_E(MAC,
+              "%s(): Received MIB: UE_mode: %d, sfn/sf: %d.%d\n",
+              __func__,
+              UE_mac_inst[Mod_id].UE_mode[0],
+              sfn,
+              sf);
+        UE_mac_inst[Mod_id].UE_mode[0] = PRACH;
+      } else {
+        dl_phy_sync_success(Mod_id, sfn, 0, 0);
+      }
     }
   }
-
   return 0;
-
 }
 
-
-int hi_dci0_req_UE_MAC(nfapi_hi_dci0_request_t* req, module_id_t Mod_id)
-{
-	if (req!=NULL && req->hi_dci0_request_body.hi_dci0_pdu_list!=NULL){
-  LOG_D(PHY,"[UE-PHY_STUB] hi dci0 request sfn_sf:%d number_of_dci:%d number_of_hi:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), req->hi_dci0_request_body.number_of_dci, req->hi_dci0_request_body.number_of_hi);
-
-
-
-  for (int i=0; i<req->hi_dci0_request_body.number_of_dci + req->hi_dci0_request_body.number_of_hi; i++)
-  {
-    LOG_D(PHY,"[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d]\n", NFAPI_SFNSF2DEC(req->sfn_sf), i);
-
-    if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE)
-    {
-      LOG_D(PHY,"[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_DCI_PDU_TYPE not used \n", NFAPI_SFNSF2DEC(req->sfn_sf), i);
-
-    }
-    else if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type == NFAPI_HI_DCI0_HI_PDU_TYPE)
-    {
-      //LOG_I(MAC,"[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_HI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i);
-
-      nfapi_hi_dci0_request_pdu_t *hi_dci0_req_pdu = &req->hi_dci0_request_body.hi_dci0_pdu_list[i];
-
-      // This is meaningful only after ACKnowledging the first ULSCH Txon (i.e. Msg3)
-      if(hi_dci0_req_pdu->hi_pdu.hi_pdu_rel8.hi_value == 1 && UE_mac_inst[Mod_id].first_ULSCH_Tx == 1){
-    	  //LOG_I(MAC,"[UE-PHY_STUB] HI_DCI0_REQ 2 sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_HI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i);
-    	  //UE_mac_inst[Mod_id].UE_mode[0] = PUSCH;
-    	  //UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
+int hi_dci0_req_UE_MAC(nfapi_hi_dci0_request_t *req, module_id_t Mod_id) {
+  if (req != NULL && req->hi_dci0_request_body.hi_dci0_pdu_list != NULL) {
+    LOG_D(PHY,
+          "[UE-PHY_STUB] hi dci0 request sfn_sf:%d number_of_dci:%d "
+          "number_of_hi:%d\n",
+          NFAPI_SFNSF2DEC(req->sfn_sf),
+          req->hi_dci0_request_body.number_of_dci,
+          req->hi_dci0_request_body.number_of_hi);
+
+    for (int i = 0; i < req->hi_dci0_request_body.number_of_dci
+                            + req->hi_dci0_request_body.number_of_hi;
+         i++) {
+      LOG_D(PHY,
+            "[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d]\n",
+            NFAPI_SFNSF2DEC(req->sfn_sf),
+            i);
+
+      if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type
+          == NFAPI_HI_DCI0_DCI_PDU_TYPE) {
+        LOG_D(PHY,
+              "[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - "
+              "NFAPI_HI_DCI0_DCI_PDU_TYPE\n",
+              NFAPI_SFNSF2DEC(req->sfn_sf),
+              i);
+        const nfapi_hi_dci0_dci_pdu_rel8_t *dci =
+            &req->hi_dci0_request_body.hi_dci0_pdu_list[i].dci_pdu.dci_pdu_rel8;
+        if (dci->rnti != UE_mac_inst[Mod_id].crnti)
+          continue;
+        const int sfn = NFAPI_SFNSF2SFN(req->sfn_sf);
+        const int sf = NFAPI_SFNSF2SF(req->sfn_sf);
+        if (dci->cqi_csi_request)
+          fill_ulsch_cqi_indication_UE_MAC(Mod_id, sfn, sf, UL_INFO, dci->rnti);
+      } else if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type
+                 == NFAPI_HI_DCI0_HI_PDU_TYPE) {
+        nfapi_hi_dci0_request_pdu_t *hi_dci0_req_pdu =
+            &req->hi_dci0_request_body.hi_dci0_pdu_list[i];
+
+        // This is meaningful only after ACKnowledging the first ULSCH Txon
+        // (i.e. Msg3)
+        if (hi_dci0_req_pdu->hi_pdu.hi_pdu_rel8.hi_value == 1
+            && UE_mac_inst[Mod_id].first_ULSCH_Tx == 1) {
+          // LOG_I(MAC,"[UE-PHY_STUB] HI_DCI0_REQ 2 sfn_sf:%d PDU[%d] -
+          // NFAPI_HI_DCI0_HI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i);
+          // UE_mac_inst[Mod_id].UE_mode[0] = PUSCH;
+          // UE_mac_inst[Mod_id].first_ULSCH_Tx = 0;
+        }
+
+      } else {
+        LOG_E(PHY,
+              "[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - unknown pdu "
+              "type:%d\n",
+              NFAPI_SFNSF2DEC(req->sfn_sf),
+              i,
+              req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type);
       }
-
     }
-    else
-    {
-      LOG_E(PHY,"[UE-PHY_STUB] HI_DCI0_REQ sfn_sf:%d PDU[%d] - unknown pdu type:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), i, req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type);
-    }
-  }
-
   }
 
-
   return 0;
 }
 
+// The following set of memcpy functions should be getting called as callback
+// functions from pnf_p7_subframe_ind.
+int memcpy_dl_config_req(nfapi_pnf_p7_config_t *pnf_p7,
+                         nfapi_dl_config_request_t *req) {
+  dl_config_req = (nfapi_dl_config_request_t *)malloc(sizeof(nfapi_dl_config_request_t));
 
+  // UE_mac_inst[Mod_id].dl_config_req->header = req->header;
+  dl_config_req->sfn_sf = req->sfn_sf;
 
+  dl_config_req->vendor_extension = req->vendor_extension;
 
+  dl_config_req->dl_config_request_body.number_dci = req->dl_config_request_body.number_dci;
+  dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols = req->dl_config_request_body.number_pdcch_ofdm_symbols;
+  dl_config_req->dl_config_request_body.number_pdsch_rnti = req->dl_config_request_body.number_pdsch_rnti;
+  dl_config_req->dl_config_request_body.number_pdu = req->dl_config_request_body.number_pdu;
 
-// The following set of memcpy functions should be getting called as callback functions from
-// pnf_p7_subframe_ind.
-int memcpy_dl_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_dl_config_request_t* req)
-{
-
-	//for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++){
-
-	dl_config_req = (nfapi_dl_config_request_t*)malloc(sizeof(nfapi_dl_config_request_t));
+  dl_config_req->dl_config_request_body.tl.tag = req->dl_config_request_body.tl.tag;
+  dl_config_req->dl_config_request_body.tl.length = req->dl_config_request_body.tl.length;
 
-	//UE_mac_inst[Mod_id].dl_config_req->header = req->header;
-	dl_config_req->sfn_sf = req->sfn_sf;
-
-	dl_config_req->vendor_extension = req->vendor_extension;
-
-	dl_config_req->dl_config_request_body.number_dci = req->dl_config_request_body.number_dci;
-	dl_config_req->dl_config_request_body.number_pdcch_ofdm_symbols = req->dl_config_request_body.number_pdcch_ofdm_symbols;
-	dl_config_req->dl_config_request_body.number_pdsch_rnti = req->dl_config_request_body.number_pdsch_rnti;
-	dl_config_req->dl_config_request_body.number_pdu = req->dl_config_request_body.number_pdu;
-
-	dl_config_req->dl_config_request_body.tl.tag = req->dl_config_request_body.tl.tag;
-	dl_config_req->dl_config_request_body.tl.length = req->dl_config_request_body.tl.length;
-
-	dl_config_req->dl_config_request_body.dl_config_pdu_list = (nfapi_dl_config_request_pdu_t*) calloc(req->dl_config_request_body.number_pdu, sizeof(nfapi_dl_config_request_pdu_t));
-	for(int i=0; i<dl_config_req->dl_config_request_body.number_pdu; i++) {
-		dl_config_req->dl_config_request_body.dl_config_pdu_list[i] = req->dl_config_request_body.dl_config_pdu_list[i];
-	}
-
-	//}
-
-	return 0;
+  dl_config_req->dl_config_request_body.dl_config_pdu_list =
+      calloc(req->dl_config_request_body.number_pdu,
+             sizeof(nfapi_dl_config_request_pdu_t));
+  for (int i = 0; i < dl_config_req->dl_config_request_body.number_pdu; i++) {
+    dl_config_req->dl_config_request_body.dl_config_pdu_list[i] =
+        req->dl_config_request_body.dl_config_pdu_list[i];
+  }
 
+  return 0;
 }
 
-int memcpy_ul_config_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_ul_config_request_t* req)
-{
-
-	//for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++){
-
-		ul_config_req = (nfapi_ul_config_request_t*)malloc(sizeof(nfapi_ul_config_request_t));
+int memcpy_ul_config_req(nfapi_pnf_p7_config_t *pnf_p7,
+                         nfapi_ul_config_request_t *req) {
+  ul_config_req = malloc(sizeof(nfapi_ul_config_request_t));
 
-	ul_config_req->sfn_sf = req->sfn_sf;
-	ul_config_req->vendor_extension = req->vendor_extension;
+  ul_config_req->sfn_sf = req->sfn_sf;
+  ul_config_req->vendor_extension = req->vendor_extension;
 
+  ul_config_req->ul_config_request_body.number_of_pdus = req->ul_config_request_body.number_of_pdus;
+  ul_config_req->ul_config_request_body.rach_prach_frequency_resources = req->ul_config_request_body.rach_prach_frequency_resources;
+  ul_config_req->ul_config_request_body.srs_present = req->ul_config_request_body.srs_present;
 
-	ul_config_req->ul_config_request_body.number_of_pdus = req->ul_config_request_body.number_of_pdus;
-	ul_config_req->ul_config_request_body.rach_prach_frequency_resources = req->ul_config_request_body.rach_prach_frequency_resources;
-	ul_config_req->ul_config_request_body.srs_present = req->ul_config_request_body.srs_present;
+  ul_config_req->ul_config_request_body.tl.tag = req->ul_config_request_body.tl.tag;
+  ul_config_req->ul_config_request_body.tl.length = req->ul_config_request_body.tl.length;
 
-	ul_config_req->ul_config_request_body.tl.tag = req->ul_config_request_body.tl.tag;
-	ul_config_req->ul_config_request_body.tl.length = req->ul_config_request_body.tl.length;
-
-	//LOG_D(MAC, "memcpy_ul_config_req 1 #ofULPDUs: %d \n", UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.number_of_pdus); //req->ul_config_request_body.number_of_pdus);
-	ul_config_req->ul_config_request_body.ul_config_pdu_list = (nfapi_ul_config_request_pdu_t*) malloc(req->ul_config_request_body.number_of_pdus*sizeof(nfapi_ul_config_request_pdu_t));
-	for(int i=0; i<ul_config_req->ul_config_request_body.number_of_pdus; i++) {
-			ul_config_req->ul_config_request_body.ul_config_pdu_list[i] = req->ul_config_request_body.ul_config_pdu_list[i];
-		}
-	//}
+  ul_config_req->ul_config_request_body.ul_config_pdu_list =
+      calloc(req->ul_config_request_body.number_of_pdus,
+             sizeof(nfapi_ul_config_request_pdu_t));
+  for (int i = 0; i < ul_config_req->ul_config_request_body.number_of_pdus; i++) {
+    ul_config_req->ul_config_request_body.ul_config_pdu_list[i] =
+        req->ul_config_request_body.ul_config_pdu_list[i];
+  }
 
-	return 0;
+  return 0;
 }
 
+int memcpy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) {
+  tx_req_num_elems = req->tx_request_body.number_of_pdus;
+  tx_request_pdu_list = calloc(tx_req_num_elems, sizeof(nfapi_tx_request_pdu_t));
+  for (int i = 0; i < tx_req_num_elems; i++) {
+    tx_request_pdu_list[i].num_segments = req->tx_request_body.tx_pdu_list[i].num_segments;
+    tx_request_pdu_list[i].pdu_index = req->tx_request_body.tx_pdu_list[i].pdu_index;
+    tx_request_pdu_list[i].pdu_length = req->tx_request_body.tx_pdu_list[i].pdu_length;
+    for (int j = 0; j < req->tx_request_body.tx_pdu_list[i].num_segments; j++) {
+      tx_request_pdu_list[i].segments[j].segment_length = req->tx_request_body.tx_pdu_list[i].segments[j].segment_length;
+      if (tx_request_pdu_list[i].segments[j].segment_length > 0) {
+        tx_request_pdu_list[i].segments[j].segment_data = calloc(
+            tx_request_pdu_list[i].segments[j].segment_length, sizeof(uint8_t));
+        memcpy(tx_request_pdu_list[i].segments[j].segment_data,
+               req->tx_request_body.tx_pdu_list[i].segments[j].segment_data,
+               tx_request_pdu_list[i].segments[j].segment_length);
+      }
+    }
+  }
 
-
-
-int memcpy_tx_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_tx_request_t* req)
-{
-
-	tx_req_num_elems = req->tx_request_body.number_of_pdus;
-	tx_request_pdu_list = (nfapi_tx_request_pdu_t*) calloc(tx_req_num_elems, sizeof(nfapi_tx_request_pdu_t));
-	for (int i=0; i<tx_req_num_elems; i++) {
-		tx_request_pdu_list[i].num_segments = req->tx_request_body.tx_pdu_list[i].num_segments;
-		tx_request_pdu_list[i].pdu_index = req->tx_request_body.tx_pdu_list[i].pdu_index;
-		tx_request_pdu_list[i].pdu_length = req->tx_request_body.tx_pdu_list[i].pdu_length;
-		for (int j=0; j<req->tx_request_body.tx_pdu_list[i].num_segments; j++){
-			//*tx_request_pdu_list[i].segments[j].segment_data = *req->tx_request_body.tx_pdu_list[i].segments[j].segment_data;
-			tx_request_pdu_list[i].segments[j].segment_length = req->tx_request_body.tx_pdu_list[i].segments[j].segment_length;
-			if(tx_request_pdu_list[i].segments[j].segment_length > 0){
-				tx_request_pdu_list[i].segments[j].segment_data = (uint8_t*)malloc(tx_request_pdu_list[i].segments[j].segment_length*sizeof (uint8_t));
-			memcpy(tx_request_pdu_list[i].segments[j].segment_data, req->tx_request_body.tx_pdu_list[i].segments[j].segment_data, tx_request_pdu_list[i].segments[j].segment_length);
-			}
-		}
-
-	}
-
-	return 0;
+  return 0;
 }
 
-int memcpy_hi_dci0_req (nfapi_pnf_p7_config_t* pnf_p7, nfapi_hi_dci0_request_t* req)
-{
-
-	//if(req!=0){
+int memcpy_hi_dci0_req(nfapi_pnf_p7_config_t *pnf_p7,
+                       nfapi_hi_dci0_request_t *req) {
+  hi_dci0_req = (nfapi_hi_dci0_request_t *)malloc(sizeof(nfapi_hi_dci0_request_t));
 
-	//for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++){
-	hi_dci0_req = (nfapi_hi_dci0_request_t*)malloc(sizeof(nfapi_hi_dci0_request_t));
+  hi_dci0_req->sfn_sf = req->sfn_sf;
+  hi_dci0_req->vendor_extension = req->vendor_extension;
 
-	hi_dci0_req->sfn_sf = req->sfn_sf;
-	hi_dci0_req->vendor_extension = req->vendor_extension;
+  hi_dci0_req->hi_dci0_request_body.number_of_dci = req->hi_dci0_request_body.number_of_dci;
+  hi_dci0_req->hi_dci0_request_body.number_of_hi = req->hi_dci0_request_body.number_of_hi;
+  hi_dci0_req->hi_dci0_request_body.sfnsf = req->hi_dci0_request_body.sfnsf;
 
-	hi_dci0_req->hi_dci0_request_body.number_of_dci = req->hi_dci0_request_body.number_of_dci;
-	hi_dci0_req->hi_dci0_request_body.number_of_hi = req->hi_dci0_request_body.number_of_hi;
-	hi_dci0_req->hi_dci0_request_body.sfnsf = req->hi_dci0_request_body.sfnsf;
+  // UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.tl =
+  // req->hi_dci0_request_body.tl;
+  hi_dci0_req->hi_dci0_request_body.tl.tag = req->hi_dci0_request_body.tl.tag;
+  hi_dci0_req->hi_dci0_request_body.tl.length = req->hi_dci0_request_body.tl.length;
 
-	//UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.tl = req->hi_dci0_request_body.tl;
-	hi_dci0_req->hi_dci0_request_body.tl.tag = req->hi_dci0_request_body.tl.tag;
-	hi_dci0_req->hi_dci0_request_body.tl.length = req->hi_dci0_request_body.tl.length;
+  int total_pdus = hi_dci0_req->hi_dci0_request_body.number_of_dci
+                   + hi_dci0_req->hi_dci0_request_body.number_of_hi;
 
-	int total_pdus = hi_dci0_req->hi_dci0_request_body.number_of_dci + hi_dci0_req->hi_dci0_request_body.number_of_hi;
+  hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list =
+      calloc(total_pdus, sizeof(nfapi_hi_dci0_request_pdu_t));
 
-	hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list = (nfapi_hi_dci0_request_pdu_t*) malloc(total_pdus*sizeof(nfapi_hi_dci0_request_pdu_t));
-
-	for(int i=0; i<total_pdus; i++){
-		hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list[i] = req->hi_dci0_request_body.hi_dci0_pdu_list[i];
-		//LOG_I(MAC, "Original hi_dci0 req. type:%d, Copy type: %d \n",req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type, UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type);
-	}
-
-	//}
-		return 0;
+  for (int i = 0; i < total_pdus; i++) {
+    hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list[i] = req->hi_dci0_request_body.hi_dci0_pdu_list[i];
+    // LOG_I(MAC, "Original hi_dci0 req. type:%d, Copy type: %d
+    // \n",req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type,
+    // UE_mac_inst[Mod_id].hi_dci0_req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type);
+  }
+  return 0;
 }
 
-
-
 void UE_config_stub_pnf(void) {
-  int               j;
+  int j;
   paramdef_t L1_Params[] = L1PARAMS_DESC;
-  paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST,NULL,0};
+  paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST, NULL, 0};
 
-  config_getlist( &L1_ParamList,L1_Params,sizeof(L1_Params)/sizeof(paramdef_t), NULL);
+  config_getlist(&L1_ParamList, L1_Params, sizeof(L1_Params) / sizeof(paramdef_t), NULL);
   if (L1_ParamList.numelt > 0) {
-	  for (j=0; j<L1_ParamList.numelt; j++){
-		  //nb_L1_CC = *(L1_ParamList.paramarray[j][L1_CC_IDX].uptr); // Number of component carriers is of no use for the
-	                                                            // phy_stub mode UE pnf. Maybe we can completely skip it.
-
-		  if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) {
-			  sf_ahead = 4; // Need 4 subframe gap between RX and TX
-			  }
-		  // Right now that we have only one UE (thread) it is ok to put the eth_params in the UE_mac_inst.
-		  // Later I think we have to change that to attribute eth_params to a global element for all the UEs.
-		  else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) {
-			  stub_eth_params.local_if_name            = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr));
-			  stub_eth_params.my_addr                  = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr));
-			  stub_eth_params.remote_addr              = strdup(*(L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr));
-			  stub_eth_params.my_portc                 = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr);
-			  stub_eth_params.remote_portc             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_IDX].iptr);
-			  stub_eth_params.my_portd                 = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr);
-			  stub_eth_params.remote_portd             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr);
-			  stub_eth_params.transp_preference        = ETH_UDP_MODE;
-
-			  sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2
-			  //configure_nfapi_pnf(UE_mac_inst[0].eth_params_n.remote_addr, UE_mac_inst[0].eth_params_n.remote_portc, UE_mac_inst[0].eth_params_n.my_addr, UE_mac_inst[0].eth_params_n.my_portd, UE_mac_inst[0].eth_params_n.remote_portd);
-			  configure_nfapi_pnf(stub_eth_params.remote_addr, stub_eth_params.remote_portc, stub_eth_params.my_addr, stub_eth_params.my_portd, stub_eth_params.remote_portd);
-		  }
-		  else { // other midhaul
-		  }
-	  }
-  }
-  else {
+    for (j = 0; j < L1_ParamList.numelt; j++) {
+      // nb_L1_CC = *(L1_ParamList.paramarray[j][L1_CC_IDX].uptr); // Number of
+      // component carriers is of no use for the
+      // phy_stub mode UE pnf. Maybe we can completely skip it.
 
+      if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) {
+        sf_ahead = 4; // Need 4 subframe gap between RX and TX
+      }
+      // Right now that we have only one UE (thread) it is ok to put the
+      // eth_params in the UE_mac_inst. Later I think we have to change that to
+      // attribute eth_params to a global element for all the UEs.
+      else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) {
+        stub_eth_params.local_if_name = strdup(
+            *(L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr));
+        stub_eth_params.my_addr = strdup(
+            *(L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr));
+        stub_eth_params.remote_addr = strdup(
+            *(L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr));
+        stub_eth_params.my_portc =
+            *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr);
+        stub_eth_params.remote_portc =
+            *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_IDX].iptr);
+        stub_eth_params.my_portd =
+            *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr);
+        stub_eth_params.remote_portd =
+            *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr);
+        stub_eth_params.transp_preference = ETH_UDP_MODE;
+
+        sf_ahead = 2; // Cannot cope with 4 subframes betweem RX and TX - set it to 2
+        // configure_nfapi_pnf(UE_mac_inst[0].eth_params_n.remote_addr,
+        // UE_mac_inst[0].eth_params_n.remote_portc,
+        // UE_mac_inst[0].eth_params_n.my_addr,
+        // UE_mac_inst[0].eth_params_n.my_portd,
+        // UE_mac_inst[0].eth_params_n.remote_portd);
+        configure_nfapi_pnf(stub_eth_params.remote_addr,
+                            stub_eth_params.remote_portc,
+                            stub_eth_params.my_addr,
+                            stub_eth_params.my_portd,
+                            stub_eth_params.remote_portd);
+      }
+    }
   }
 }
 
-
 /* Dummy functions*/
 
-void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc,
-                                  nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu)
-{
-
+void handle_nfapi_hi_dci0_dci_pdu(
+    PHY_VARS_eNB *eNB,
+    int frame,
+    int subframe,
+    L1_rxtx_proc_t *proc,
+    nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) {
 }
 
-
-void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc,
-                                 nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu)
-{
-
+void handle_nfapi_hi_dci0_hi_pdu(
+    PHY_VARS_eNB *eNB,
+    int frame,
+    int subframe,
+    L1_rxtx_proc_t *proc,
+    nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) {
 }
 
-
 void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB,
-                             int frame, int subframe,
+                             int frame,
+                             int subframe,
                              L1_rxtx_proc_t *proc,
-                             nfapi_dl_config_request_pdu_t *dl_config_pdu)
-{
-
+                             nfapi_dl_config_request_pdu_t *dl_config_pdu) {
 }
 
-
-void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
+void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,
+                          L1_rxtx_proc_t *proc,
                           nfapi_dl_config_request_pdu_t *dl_config_pdu,
-                          uint8_t *sdu)
-{
-
+                          uint8_t *sdu) {
 }
 
-
-void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc,
+void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,
+                            int frame,
+                            int subframe,
+                            L1_rxtx_proc_t *proc,
                             nfapi_dl_config_request_pdu_t *dl_config_pdu,
                             uint8_t codeword_index,
-                            uint8_t *sdu)
-{
-
+                            uint8_t *sdu) {
 }
 
-
-void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,
+void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,
+                         L1_rxtx_proc_t *proc,
                          nfapi_ul_config_request_pdu_t *ul_config_pdu,
-                         uint16_t frame,uint8_t subframe,uint8_t srs_present)
-{
-
+                         uint16_t frame,
+                         uint8_t subframe,
+                         uint8_t srs_present) {
 }
 
 void phy_config_request(PHY_Config_t *phy_config) {
@@ -1053,18 +1111,21 @@ void phy_config_request(PHY_Config_t *phy_config) {
 
 void phy_config_update_sib2_request(PHY_Config_t *phy_config) {
 }
+
 void phy_config_update_sib13_request(PHY_Config_t *phy_config) {
 }
 
-uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn) { return(0);}
+uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn) {
+  return (0);
+}
 
-int32_t get_uldl_offset(int eutra_bandP) { return(0);}
+int32_t get_uldl_offset(int eutra_bandP) {
+  return (0);
+}
 
 int l1_north_init_eNB(void) {
-return 0;
+  return 0;
 }
 
 void init_eNB_afterRU(void) {
-
 }
-
diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c
index d8f6ac145dd..583e10da94e 100644
--- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c
+++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c
@@ -3230,6 +3230,98 @@ uint8_t do_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP,
   return((enc_rval.encoded+7)/8);
 }
 
+//------------------------------------------------------------------------------
+uint8_t do_NR_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP,
+                                   uint8_t               *const buffer,
+                                   const uint8_t                Transaction_id)
+//------------------------------------------------------------------------------
+{
+  LTE_DL_DCCH_Message_t dl_dcch_msg;
+  LTE_RAT_Type_t rat_nr=LTE_RAT_Type_nr;
+  LTE_RAT_Type_t rat_eutra_nr=LTE_RAT_Type_eutra_nr;
+  asn_enc_rval_t enc_rval;
+  memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t));
+  dl_dcch_msg.message.present           = LTE_DL_DCCH_MessageType_PR_c1;
+  dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry;
+  dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.rrc_TransactionIdentifier = Transaction_id;
+  dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.present = LTE_UECapabilityEnquiry__criticalExtensions_PR_c1;
+  dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.present =
+    LTE_UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8;
+  dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count=0;
+  ASN_SEQUENCE_ADD(&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list,
+                   &rat_nr);
+  ASN_SEQUENCE_ADD(&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list,
+                   &rat_eutra_nr);
+
+  /* request NR configuration */
+  LTE_UECapabilityEnquiry_r8_IEs_t *r8 = &dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8;
+  LTE_UECapabilityEnquiry_v8a0_IEs_t r8_a0;
+  LTE_UECapabilityEnquiry_v1180_IEs_t r11_80;
+  LTE_UECapabilityEnquiry_v1310_IEs_t r13_10;
+  LTE_UECapabilityEnquiry_v1430_IEs_t r14_30;
+  LTE_UECapabilityEnquiry_v1510_IEs_t r15_10;
+
+  memset(&r8_a0, 0, sizeof(r8_a0));
+  memset(&r11_80, 0, sizeof(r11_80));
+  memset(&r13_10, 0, sizeof(r13_10));
+  memset(&r14_30, 0, sizeof(r14_30));
+  memset(&r15_10, 0, sizeof(r15_10));
+
+  r8->nonCriticalExtension = &r8_a0;
+  r8_a0.nonCriticalExtension = &r11_80;
+  r11_80.nonCriticalExtension = &r13_10;
+  r13_10.nonCriticalExtension = &r14_30;
+  r14_30.nonCriticalExtension = &r15_10;
+
+  /* TODO: no hardcoded values here */
+
+  OCTET_STRING_t req_freq;
+  //unsigned char req_freq_buf[5] = { 0x00, 0x20, 0x1a, 0x02, 0x68 };  // bands 7 & nr78
+  //unsigned char req_freq_buf[5] = { 0x00, 0x20, 0x1a, 0x08, 0x18 };  // bands 7 & nr260
+
+  //unsigned char req_freq_buf[13] = { 0x00, 0xc0, 0x18, 0x01, 0x01, 0x30, 0x4b, 0x04, 0x0e, 0x08, 0x24, 0x04, 0xd0 };
+  unsigned char req_freq_buf[21] = {
+0x01, 0x60, 0x18, 0x05, 0x80, 0xc0, 0x04, 0x04, 0xc1, 0x2c, 0x10, 0x08, 0x20, 0x30, 0x40, 0xe0, 0x82, 0x40, 0x28, 0x80, 0x9a
+  };
+
+  req_freq.buf = req_freq_buf;
+  req_freq.size = 5;
+  req_freq.size = 21;
+
+  r15_10.requestedFreqBandsNR_MRDC_r15 = &req_freq;
+
+  if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
+    xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void *)&dl_dcch_msg);
+  }
+
+  enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message,
+                                   NULL,
+                                   (void *)&dl_dcch_msg,
+                                   buffer,
+                                   100);
+
+  if(enc_rval.encoded == -1) {
+    LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n",
+          enc_rval.failed_type->name, enc_rval.encoded);
+    return -1;
+  }
+
+  LOG_D(RRC,"[eNB %d] NR UECapabilityRequest for UE %x Encoded %zd bits (%zd bytes)\n",
+        ctxt_pP->module_id,
+        ctxt_pP->rnti,
+        enc_rval.encoded,
+        (enc_rval.encoded+7)/8);
+
+  if (enc_rval.encoded==-1) {
+    LOG_E(RRC,"[eNB %d] ASN1 : NR UECapabilityRequest encoding failed for UE %x\n",
+          ctxt_pP->module_id,
+          ctxt_pP->rnti);
+    return(-1);
+  }
+
+  return((enc_rval.encoded+7)/8);
+}
+
 
 uint16_t do_RRCConnectionReconfiguration_BR(const protocol_ctxt_t        *const ctxt_pP,
     uint8_t                            *buffer,
diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.h b/openair2/RRC/LTE/MESSAGES/asn1_msg.h
index ccd5e1c5371..dda23406100 100644
--- a/openair2/RRC/LTE/MESSAGES/asn1_msg.h
+++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.h
@@ -358,6 +358,13 @@ do_UECapabilityEnquiry(
   const uint8_t                Transaction_id
 );
 
+uint8_t
+do_NR_UECapabilityEnquiry(
+  const protocol_ctxt_t *const ctxt_pP,
+  uint8_t               *const buffer,
+  const uint8_t                Transaction_id
+);
+
 uint8_t do_SecurityModeCommand(
   const protocol_ctxt_t *const ctxt_pP,
   uint8_t *const buffer,
diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h
index ad51927caa2..f050733a13f 100644
--- a/openair2/RRC/LTE/rrc_defs.h
+++ b/openair2/RRC/LTE/rrc_defs.h
@@ -92,6 +92,7 @@
 
 #define PC5_DISCOVERY_PAYLOAD_SIZE      29
 
+#define DEBUG_SCG_CONFIG 1
 
 typedef enum {
   UE_STATE_OFF_NETWORK,
@@ -264,7 +265,8 @@ typedef enum UE_STATE_e {
   RRC_SI_RECEIVED,
   RRC_CONNECTED,
   RRC_RECONFIGURED,
-  RRC_HO_EXECUTION
+  RRC_HO_EXECUTION,
+  RRC_NR_NSA,
 } UE_STATE_t;
 
 typedef enum HO_STATE_e {
@@ -644,6 +646,8 @@ typedef struct eNB_RRC_UE_s {
   uint32_t                           ue_rrc_inactivity_timer;
   uint8_t                            e_rab_release_command_flag;
   int8_t                             reestablishment_xid;
+  int                                does_nr;
+  int                                nr_capabilities_requested;
 } eNB_RRC_UE_t;
 
 typedef uid_t ue_uid_t;
diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c
index a91e6fcd005..1d25bf180a1 100644
--- a/openair2/RRC/LTE/rrc_eNB.c
+++ b/openair2/RRC/LTE/rrc_eNB.c
@@ -113,6 +113,8 @@ extern uint32_t to_earfcn_DL(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t
 extern int rrc_eNB_process_security(const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, security_capabilities_t *security_capabilities_pP);
 extern void process_eNB_security_key (const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, uint8_t *security_key_pP);
 extern int derive_keNB_star(const uint8_t *kenb_32, const uint16_t pci, const uint32_t earfcn_dl, const bool is_rel8_only, uint8_t *kenb_star);
+extern int rrc_eNB_generate_RRCConnectionReconfiguration_endc(protocol_ctxt_t *ctxt, rrc_eNB_ue_context_t *ue_context, unsigned char *buffer, int buffer_size, OCTET_STRING_t *scg_group_config, OCTET_STRING_t *scg_RB_config);
+extern struct rrc_eNB_ue_context_s * get_first_ue_context(eNB_RRC_INST *rrc_instance_pP);
 
 pthread_mutex_t      rrc_release_freelist;
 RRC_release_list_t   rrc_release_info;
@@ -1277,6 +1279,52 @@ rrc_eNB_generate_UECapabilityEnquiry(
     PDCP_TRANSMISSION_MODE_CONTROL);
 }
 
+//-----------------------------------------------------------------------------
+void
+rrc_eNB_generate_NR_UECapabilityEnquiry(
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP
+)
+//-----------------------------------------------------------------------------
+{
+  uint8_t                             buffer[100];
+  uint8_t                             size;
+  T(T_ENB_RRC_UE_CAPABILITY_ENQUIRY, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
+    T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
+  size = do_NR_UECapabilityEnquiry(
+           ctxt_pP,
+           buffer,
+           rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id));
+  LOG_I(RRC,
+        PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate NR UECapabilityEnquiry (bytes %d)\n",
+        PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+        size);
+  LOG_D(RRC,
+        PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (NR UECapabilityEnquiry MUI %d) --->[PDCP][RB %02d]\n",
+        PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+        size,
+        rrc_eNB_mui,
+        DCCH);
+  MSC_LOG_TX_MESSAGE(
+    MSC_RRC_ENB,
+    MSC_RRC_UE,
+    buffer,
+    size,
+    MSC_AS_TIME_FMT" rrcNRUECapabilityEnquiry UE %x MUI %d size %u",
+    MSC_AS_TIME_ARGS(ctxt_pP),
+    ue_context_pP->ue_context.rnti,
+    rrc_eNB_mui,
+    size);
+  rrc_data_req(
+    ctxt_pP,
+    DCCH,
+    rrc_eNB_mui++,
+    SDU_CONFIRM_NO,
+    size,
+    buffer,
+    PDCP_TRANSMISSION_MODE_CONTROL);
+}
+
 //-----------------------------------------------------------------------------
 void
 rrc_eNB_generate_RRCConnectionReject(
@@ -2808,11 +2856,14 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t
   LTE_MAC_MainConfig_t                   *mac_MainConfig                   = NULL;
   LTE_MeasObjectToAddModList_t           *MeasObj_list                     = NULL;
   LTE_MeasObjectToAddMod_t               *MeasObj                          = NULL;
+  LTE_MeasObjectToAddMod_t               *MeasObj2                         = NULL;
   LTE_ReportConfigToAddModList_t         *ReportConfig_list                = NULL;
   LTE_ReportConfigToAddMod_t             *ReportConfig_per, *ReportConfig_A1,
                                          *ReportConfig_A2, *ReportConfig_A3, *ReportConfig_A4, *ReportConfig_A5;
+  LTE_ReportConfigToAddMod_t             *ReportConfig_NR                  = NULL;
   LTE_MeasIdToAddModList_t               *MeasId_list                      = NULL;
   LTE_MeasIdToAddMod_t                   *MeasId0, *MeasId1, *MeasId2, *MeasId3, *MeasId4, *MeasId5;
+  LTE_MeasIdToAddMod_t                   *MeasId6;
   long                                   *sr_ProhibitTimer_r9              = NULL;
   long                                   *logicalchannelgroup              = NULL;
   long                                   *logicalchannelgroup_drb          = NULL;
@@ -3094,6 +3145,16 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t
   MeasId5->measObjectId = 1;
   MeasId5->reportConfigId = 6;
   ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId5);
+
+  if (ue_context_pP->ue_context.does_nr) {
+    MeasId6 = calloc(1, sizeof(LTE_MeasIdToAddMod_t));
+    if (MeasId6 == NULL) exit(1);
+    MeasId6->measId = 7;
+    MeasId6->measObjectId = 2;
+    MeasId6->reportConfigId = 7;
+    ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId6);
+  }
+
   //  LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList = MeasId_list;
   // Add one EUTRA Measurement Object
   MeasObj_list = CALLOC(1, sizeof(*MeasObj_list));
@@ -3143,6 +3204,27 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t
   ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj);
   //  LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list;
 
+  if (ue_context_pP->ue_context.does_nr) {
+    MeasObj2 = calloc(1, sizeof(LTE_MeasObjectToAddMod_t));
+    if (MeasObj2 == NULL) exit(1);
+    MeasObj2->measObjectId = 2;
+    MeasObj2->measObject.present = LTE_MeasObjectToAddMod__measObject_PR_measObjectNR_r15;
+    MeasObj2->measObject.choice.measObjectNR_r15.carrierFreq_r15 = 642256; //634000; //(634000 = 3.51GHz) (640000 = 3.6GHz) (641272 = 3619.08MHz = 3600 + 30/1000*106*12/2) (642256 is for 3.6GHz and absoluteFrequencySSB = 642016)
+    MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.measTimingConfig_r15.periodicityAndOffset_r15.present = LTE_MTC_SSB_NR_r15__periodicityAndOffset_r15_PR_sf20_r15;
+    MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.measTimingConfig_r15.periodicityAndOffset_r15.choice.sf20_r15 = 0;
+    MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.measTimingConfig_r15.ssb_Duration_r15 = LTE_MTC_SSB_NR_r15__ssb_Duration_r15_sf4;
+    MeasObj2->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.subcarrierSpacingSSB_r15 = LTE_RS_ConfigSSB_NR_r15__subcarrierSpacingSSB_r15_kHz30;
+    MeasObj2->measObject.choice.measObjectNR_r15.quantityConfigSet_r15 = 1;
+    MeasObj2->measObject.choice.measObjectNR_r15.ext1 = calloc(1, sizeof(struct LTE_MeasObjectNR_r15__ext1));
+    if (MeasObj2->measObject.choice.measObjectNR_r15.ext1 == NULL) exit(1);
+    MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15 = calloc(1, sizeof(struct LTE_MeasObjectNR_r15__ext1__bandNR_r15));
+    if (MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15 == NULL) exit(1);
+    MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15->present = LTE_MeasObjectNR_r15__ext1__bandNR_r15_PR_setup;
+    MeasObj2->measObject.choice.measObjectNR_r15.ext1->bandNR_r15->choice.setup = 78;
+
+    ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj2);
+  }
+
   if (!ue_context_pP->ue_context.measurement_info->events) {
     ue_context_pP->ue_context.measurement_info->events = CALLOC(1,sizeof(*(ue_context_pP->ue_context.measurement_info->events)));
   }
@@ -3155,6 +3237,9 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t
   ReportConfig_A3 = CALLOC(1, sizeof(*ReportConfig_A3));
   ReportConfig_A4 = CALLOC(1, sizeof(*ReportConfig_A4));
   ReportConfig_A5 = CALLOC(1, sizeof(*ReportConfig_A5));
+  if (ue_context_pP->ue_context.does_nr) {
+    ReportConfig_NR = CALLOC(1, sizeof(*ReportConfig_NR));
+  }
   ReportConfig_per->reportConfigId = 1;
   ReportConfig_per->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA;
   ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present =
@@ -3260,6 +3345,30 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t
   ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120;
   ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity;
   ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A5);
+
+  if (ue_context_pP->ue_context.does_nr) {
+    ReportConfig_NR->reportConfigId = 7;
+    ReportConfig_NR->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigInterRAT;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.triggerType.present = LTE_ReportConfigInterRAT__triggerType_PR_event;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.triggerType.choice.event.eventId.present = LTE_ReportConfigInterRAT__triggerType__event__eventId_PR_eventB1_NR_r15;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.triggerType.choice.event.eventId.choice.eventB1_NR_r15.b1_ThresholdNR_r15.present = LTE_ThresholdNR_r15_PR_nr_RSRP_r15;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.triggerType.choice.event.eventId.choice.eventB1_NR_r15.b1_ThresholdNR_r15.choice.nr_RSRP_r15 = 46;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.triggerType.choice.event.eventId.choice.eventB1_NR_r15.reportOnLeave_r15 = FALSE;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.triggerType.choice.event.hysteresis = 2;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.triggerType.choice.event.timeToTrigger = LTE_TimeToTrigger_ms80;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.maxReportCells = 4;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.reportInterval = LTE_ReportInterval_ms120;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.reportAmount = LTE_ReportConfigInterRAT__reportAmount_infinity;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.ext7 = calloc(1, sizeof(struct LTE_ReportConfigInterRAT__ext7));
+    if (ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.ext7 == NULL) exit(1);
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.ext7->reportQuantityCellNR_r15 = calloc(1, sizeof(struct LTE_ReportQuantityNR_r15));
+    if (ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.ext7->reportQuantityCellNR_r15 == NULL) exit(1);
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.ext7->reportQuantityCellNR_r15->ss_rsrp = TRUE;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.ext7->reportQuantityCellNR_r15->ss_rsrq = TRUE;
+    ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.ext7->reportQuantityCellNR_r15->ss_sinr = TRUE;
+    ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_NR);
+  }
+
   //  LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list;
 
   /* A3 event update */
@@ -4230,6 +4339,10 @@ rrc_eNB_process_MeasurementReport(
               ctxt_pP->subframe);
         break;
 
+      case 7:
+        LOG_D(RRC, "NR event frame %d subframe %d\n", ctxt_pP->frame, ctxt_pP->subframe);
+        break;
+
       default:
         LOG_D(RRC,"Other event report frame %d and subframe %d \n", ctxt_pP->frame, ctxt_pP->subframe);
         break;
@@ -4243,6 +4356,22 @@ rrc_eNB_process_MeasurementReport(
           ue_context_pP->ue_context.measResults->measResultPCell.rsrqResult/2 - 20);
   }
 
+  /* TODO: improve NR triggering */
+  if (measResults2->measId == 7) {
+    if (ue_context_pP->ue_context.Status != RRC_NR_NSA) {
+      MessageDef      *msg;
+      ue_context_pP->ue_context.Status = RRC_NR_NSA;
+
+      msg = itti_alloc_new_message(TASK_RRC_ENB, X2AP_ENDC_SGNB_ADDITION_REQ);
+      X2AP_ENDC_SGNB_ADDITION_REQ(msg).rnti = ctxt_pP->rnti;
+      LOG_I(RRC,
+            "[eNB %d] frame %d subframe %d: UE rnti %x switching to NSA mode\n",
+            ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->subframe, ctxt_pP->rnti);
+      itti_send_msg_to_task(TASK_X2AP, ENB_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), msg);
+      return;
+    }
+  }
+
   if (measResults2->measResultNeighCells == NULL)
     return;
 
@@ -6298,6 +6427,16 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete(
     free(DRB_Release_configList2);
     ue_context_pP->ue_context.DRB_Release_configList2[xid] = NULL;
   }
+
+  /* let's request NR capabilities if the UE supports NR
+   * maybe not the right place/time to request
+   */
+  if (ue_context_pP->ue_context.does_nr &&
+      !ue_context_pP->ue_context.nr_capabilities_requested) {
+    ue_context_pP->ue_context.nr_capabilities_requested = 1;
+    rrc_eNB_generate_NR_UECapabilityEnquiry(ctxt_pP, ue_context_pP);
+  }
+
 }
 
 //-----------------------------------------------------------------------------
@@ -7116,6 +7255,48 @@ rrc_eNB_decode_ccch(
   return rval;
 }
 
+//-----------------------------------------------------------------------------
+static int
+is_en_dc_supported(
+  LTE_UE_EUTRA_Capability_t *c
+)
+//-----------------------------------------------------------------------------
+{
+  /* to be refined - check that the eNB is connected to a gNB, check that
+   * the bands supported by the UE include the band of the gNB
+   */
+#define NCE nonCriticalExtension
+  return c != NULL
+      && c->NCE != NULL
+      && c->NCE->NCE != NULL
+      && c->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->irat_ParametersNR_r15 != NULL
+      && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->irat_ParametersNR_r15->en_DC_r15 != NULL
+      && *c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->irat_ParametersNR_r15->en_DC_r15 == LTE_IRAT_ParametersNR_r15__en_DC_r15_supported;
+#undef NCE
+}
+
 //-----------------------------------------------------------------------------
 int
 rrc_eNB_decode_dcch(
@@ -7645,6 +7826,22 @@ rrc_eNB_decode_dcch(
 
         LOG_I(RRC, "got UE capabilities for UE %x\n", ctxt_pP->rnti);
 
+        int eutra_index = -1;
+
+        for (i = 0; i < ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.count; i++) {
+          if (ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.array[i]->rat_Type == LTE_RAT_Type_eutra) {
+            if (eutra_index != -1) {
+              LOG_E(RRC, "fatal: more than 1 eutra capability\n");
+              exit(1);
+            }
+            eutra_index = i;
+          }
+        }
+
+        /* do nothing if no EUTRA capabilities (TODO: may be NR capabilities, to be processed somehow) */
+        if (eutra_index == -1)
+          break;
+
         if (ue_context_p->ue_context.UE_Capability) {
           LOG_I(RRC, "freeing old UE capabilities for UE %x\n", ctxt_pP->rnti);
           ASN_STRUCT_FREE(asn_DEF_LTE_UE_EUTRA_Capability,
@@ -7655,15 +7852,10 @@ rrc_eNB_decode_dcch(
         dec_rval = uper_decode(NULL,
                                &asn_DEF_LTE_UE_EUTRA_Capability,
                                (void **)&ue_context_p->ue_context.UE_Capability,
-                               ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.
-                               choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.
-                               array[0]->ueCapabilityRAT_Container.buf,
-                               ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.
-                               choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.
-                               array[0]->ueCapabilityRAT_Container.size, 0, 0);
-        ue_context_p->ue_context.UE_Capability_size = ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.
-            choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.
-            array[0]->ueCapabilityRAT_Container.size;
+                               ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.array[eutra_index]->ueCapabilityRAT_Container.buf,
+                               ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.array[eutra_index]->ueCapabilityRAT_Container.size,
+                               0, 0);
+        ue_context_p->ue_context.UE_Capability_size = ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.array[eutra_index]->ueCapabilityRAT_Container.size;
 
         if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
           xer_fprint(stdout, &asn_DEF_LTE_UE_EUTRA_Capability, ue_context_p->ue_context.UE_Capability);
@@ -7678,6 +7870,9 @@ rrc_eNB_decode_dcch(
           ue_context_p->ue_context.UE_Capability = 0;
         }
 
+        if (dec_rval.code == RC_OK)
+          ue_context_p->ue_context.does_nr = is_en_dc_supported(ue_context_p->ue_context.UE_Capability);
+
         if (EPC_MODE_ENABLED) {
           rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(ctxt_pP,
                                                 ue_context_p,
@@ -8241,6 +8436,100 @@ void rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) {
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX, VCD_FUNCTION_OUT);
 }
 
+void rrc_eNB_process_AdditionResponseInformation(const module_id_t enb_mod_idP, x2ap_ENDC_sgnb_addition_req_ACK_t *m) {
+
+
+	NR_CG_Config_t *CG_Config = NULL;
+
+	{
+		int i;
+		printf("%d: ", m->rrc_buffer_size);
+		for (i=0; i<m->rrc_buffer_size; i++) printf("%2.2x", (unsigned char)m->rrc_buffer[i]);
+		printf("\n");
+
+	}
+    asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
+						      &asn_DEF_NR_CG_Config,
+						      (void **)&CG_Config,
+						      (uint8_t *)m->rrc_buffer,
+						      (int) m->rrc_buffer_size);//m->rrc_buffer_size);
+
+    if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
+      AssertFatal(1==0,"NR_UL_DCCH_MESSAGE decode error\n");
+	// free the memory
+	SEQUENCE_free( &asn_DEF_NR_CG_Config, CG_Config, 1 );
+	return;
+    }
+    xer_fprint(stdout,&asn_DEF_NR_CG_Config, CG_Config);
+    // recreate enough of X2 EN-DC Container
+
+    AssertFatal(CG_Config->criticalExtensions.choice.c1->present == NR_CG_Config__criticalExtensions__c1_PR_cg_Config,
+		  "CG_Config not present\n");
+
+    OCTET_STRING_t *scg_CellGroupConfig = NULL;
+    OCTET_STRING_t *nr1_conf = NULL;
+
+    if(CG_Config->criticalExtensions.choice.c1->choice.cg_Config->scg_CellGroupConfig){
+    	scg_CellGroupConfig = CG_Config->criticalExtensions.choice.c1->choice.cg_Config->scg_CellGroupConfig;
+#ifdef DEBUG_SCG_CONFIG
+    	{
+    		int size_s = CG_Config->criticalExtensions.choice.c1->choice.cg_Config->scg_CellGroupConfig->size;
+    		int i;
+    		LOG_I(RRC, "Dumping scg_CellGroupConfig: %d", size_s);
+    		for (i=0; i<size_s; i++) printf("%2.2x", (unsigned char)CG_Config->criticalExtensions.choice.c1->choice.cg_Config->scg_CellGroupConfig->buf[i]);
+    		printf("\n");
+
+    	}
+#endif
+
+    }
+    else{
+    	LOG_W(RRC, "SCG Cell group configuration is not present in the Addition Response message \n");
+    	return;
+    }
+    if(CG_Config->criticalExtensions.choice.c1->choice.cg_Config->scg_RB_Config){
+    	nr1_conf = CG_Config->criticalExtensions.choice.c1->choice.cg_Config->scg_RB_Config;
+#ifdef DEBUG_SCG_CONFIG
+    	{
+    		int size_s = CG_Config->criticalExtensions.choice.c1->choice.cg_Config->scg_RB_Config->size;
+    		int i;
+    		LOG_I(RRC, "Dumping scg_RB_Config: %d", size_s);
+    		for (i=0; i<size_s; i++) printf("%2.2x", (unsigned char)CG_Config->criticalExtensions.choice.c1->choice.cg_Config->scg_RB_Config->buf[i]);
+    		printf("\n");
+
+    	}
+#endif
+    }
+    else{
+    	LOG_W(RRC, "SCG RB configuration is not present in the Addition Response message \n");
+    	return;
+    }
+
+    protocol_ctxt_t ctxt;
+    rrc_eNB_ue_context_t *ue_context;
+    unsigned char buffer[8192];
+    int size;
+
+    ue_context = rrc_eNB_get_ue_context(RC.rrc[enb_mod_idP], m->rnti);
+
+    PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt,
+                                    0,
+                                    ENB_FLAG_YES,
+                                    m->rnti,
+                                    0, 0);
+
+    size = rrc_eNB_generate_RRCConnectionReconfiguration_endc(&ctxt, ue_context, buffer, 8192, scg_CellGroupConfig, nr1_conf);
+
+    rrc_data_req(&ctxt,
+                   DCCH,
+                   rrc_eNB_mui++,
+                   SDU_CONFIRM_NO,
+                   size,
+                   buffer,
+                   PDCP_TRANSMISSION_MODE_CONTROL);
+}
+
+
 //-----------------------------------------------------------------------------
 void *rrc_enb_process_itti_msg(void *notUsed) {
   MessageDef                         *msg_p;
@@ -8519,6 +8808,12 @@ void *rrc_enb_process_itti_msg(void *notUsed) {
       break;
     }
 
+    case X2AP_ENDC_SGNB_ADDITION_REQ_ACK: {
+    	rrc_eNB_process_AdditionResponseInformation(ENB_INSTANCE_TO_MODULE_ID(instance), &X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg_p));
+    	break;
+    }
+
+
     /* Messages from eNB app */
     case RRC_CONFIGURATION_REQ:
       LOG_I(RRC, "[eNB %d] Received %s : %p\n", instance, msg_name_p, &RRC_CONFIGURATION_REQ(msg_p));
@@ -8597,11 +8892,17 @@ rrc_enb_task(
 //-----------------------------------------------------------------------------
 {
   rrc_enb_init();
+
   itti_mark_task_ready(TASK_RRC_ENB);
   LOG_I(RRC,"Entering main loop of RRC message task\n");
 
   while (1) {
     (void) rrc_enb_process_itti_msg(NULL);
+{
+  //extern volatile int go_nr;
+  void rrc_go_nr(void);
+  //if (go_nr) rrc_go_nr();
+}
   }
 }
 
diff --git a/openair2/RRC/LTE/rrc_proto.h b/openair2/RRC/LTE/rrc_proto.h
index d5009de270b..8f6baabcbf4 100644
--- a/openair2/RRC/LTE/rrc_proto.h
+++ b/openair2/RRC/LTE/rrc_proto.h
@@ -584,6 +584,12 @@ rrc_eNB_generate_UECapabilityEnquiry(
   rrc_eNB_ue_context_t          *const ue_context_pP
 );
 
+void
+rrc_eNB_generate_NR_UECapabilityEnquiry(
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t          *const ue_context_pP
+);
+
 void
 rrc_eNB_generate_SecurityModeCommand(
   const protocol_ctxt_t *const ctxt_pP,
diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c
index 2a9448218a9..1e8e45ef4d5 100644
--- a/openair2/RRC/NR/L2_nr_interface.c
+++ b/openair2/RRC/NR/L2_nr_interface.c
@@ -64,7 +64,7 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
   NR_BCCH_BCH_Message_t *mib;
   
   rrc     = RC.nrrrc[Mod_idP];
-  carrier = &rrc->carrier[0];
+  carrier = &rrc->carrier;
   mib     = &carrier->mib;
 
   if( (Srb_id & RAB_OFFSET ) == MIBCH) {
diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c
index b321aa3e4f5..a4092c11fa4 100644
--- a/openair2/RRC/NR/MESSAGES/asn1_msg.c
+++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c
@@ -129,16 +129,6 @@ extern unsigned char NB_gNB_INST;
 
 extern RAN_CONTEXT_t RC;
 
-uint16_t two_tier_hexagonal_nr_cellIds[7] = {0,1,2,4,5,7,8};
-uint16_t two_tier_hexagonal_adjacent_nr_cellIds[7][6] = {{1,2,4,5,7,8},    // CellId 0
-  {11,18,2,0,8,15}, // CellId 1
-  {18,13,3,4,0,1},  // CellId 2
-  {2,3,14,6,5,0},   // CellId 4
-  {0,4,6,16,9,7},   // CellId 5
-  {8,0,5,9,17,12},  // CellId 7
-  {15,1,0,7,12,10}
-};// CellId 8
-
 /*
  * This is a helper function for xer_sprint, which directs all incoming data
  * into the provided string.
@@ -180,34 +170,16 @@ int xer_nr_sprint (char *string, size_t string_size, asn_TYPE_descriptor_t *td,
   return er.encoded;
 }
 
-uint16_t get_adjacent_cell_id_NR(uint8_t Mod_id,uint8_t index) {
-  return(two_tier_hexagonal_adjacent_nr_cellIds[Mod_id][index]);
-}
-/* This only works for the hexagonal topology...need a more general function for other topologies */
-
-uint8_t get_adjacent_cell_mod_id_NR(uint16_t phyCellId) {
-  uint8_t i;
-
-  for(i=0; i<7; i++) {
-    if(two_tier_hexagonal_nr_cellIds[i] == phyCellId) {
-      return i;
-    }
-  }
-
-  LOG_E(RRC,"\nCannot get adjacent cell mod id! Fatal error!\n");
-  return 0xFF; //error!
-}
-
 //------------------------------------------------------------------------------
 
-uint8_t do_MIB_NR(rrc_gNB_carrier_data_t *carrier,
-                  uint32_t frame,
-                  uint32_t ssb_SubcarrierOffset,
-                  uint32_t pdcch_ConfigSIB1,
-                  uint32_t subCarrierSpacingCommon,
-                  uint32_t dmrs_TypeA_Position) {
+uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) { 
+
   asn_enc_rval_t enc_rval;
+  rrc_gNB_carrier_data_t *carrier = &rrc->carrier;  
+
   NR_BCCH_BCH_Message_t *mib = &carrier->mib;
+  NR_ServingCellConfigCommon_t *scc = carrier->servingcellconfigcommon;
+
   memset(mib,0,sizeof(NR_BCCH_BCH_Message_t));
   mib->message.present = NR_BCCH_BCH_MessageType_PR_mib;
   mib->message.choice.mib = CALLOC(1,sizeof(struct NR_MIB));
@@ -226,44 +198,47 @@ uint8_t do_MIB_NR(rrc_gNB_carrier_data_t *carrier,
   mib->message.choice.mib->spare.buf = (uint8_t *)spare;
   mib->message.choice.mib->spare.size = 1;
   mib->message.choice.mib->spare.bits_unused = 7;  // This makes a spare of 1 bits
-  mib->message.choice.mib->ssb_SubcarrierOffset = ssb_SubcarrierOffset;
-  mib->message.choice.mib->pdcch_ConfigSIB1.controlResourceSetZero = (pdcch_ConfigSIB1 / 16);
-  mib->message.choice.mib->pdcch_ConfigSIB1.searchSpaceZero = (pdcch_ConfigSIB1 % 16);
-
-  switch (subCarrierSpacingCommon) {
-    case 15:
-      mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs15or60;
-      break;
-
-    case 30:
-      mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs30or120;
-      break;
-
-    case 60:
-      mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs15or60;
-      break;
 
-    case 120:
-      mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs30or120;
-      break;
-
-    default:
-      AssertFatal(1==0, "Unknown subCarrierSpacingCommon %u\n", subCarrierSpacingCommon);
+  mib->message.choice.mib->ssb_SubcarrierOffset = (carrier->ssb_SubcarrierOffset)&15;
+  mib->message.choice.mib->pdcch_ConfigSIB1.controlResourceSetZero = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero;
+  mib->message.choice.mib->pdcch_ConfigSIB1.searchSpaceZero = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero;
+  AssertFatal(scc->ssbSubcarrierSpacing != NULL, "scc->ssbSubcarrierSpacing is null\n");
+  switch (*scc->ssbSubcarrierSpacing) {
+  case NR_SubcarrierSpacing_kHz15:
+    mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs15or60;
+    break;
+    
+  case NR_SubcarrierSpacing_kHz30:
+    mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs30or120;
+    break;
+    
+  case NR_SubcarrierSpacing_kHz60:
+    mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs15or60;
+    break;
+    
+  case NR_SubcarrierSpacing_kHz120:
+    mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs30or120;
+    break;
+    
+  case NR_SubcarrierSpacing_kHz240:
+    AssertFatal(1==0,"Unknown subCarrierSpacingCommon %d\n",(int)*scc->ssbSubcarrierSpacing);
+    break;
+    
+  default:
+      AssertFatal(1==0,"Unknown subCarrierSpacingCommon %d\n",(int)*scc->ssbSubcarrierSpacing);
   }
 
-  mib->message.choice.mib->subCarrierSpacingCommon = 1;
-
-  switch (dmrs_TypeA_Position) {
-    case 2:
-      mib->message.choice.mib->dmrs_TypeA_Position = NR_MIB__dmrs_TypeA_Position_pos2;
-      break;
-
-    case 3:
-      mib->message.choice.mib->dmrs_TypeA_Position = NR_MIB__dmrs_TypeA_Position_pos3;
-      break;
-
-    default:
-      AssertFatal(1==0, "Unknown dmrs_TypeA_Position %u\n", dmrs_TypeA_Position);
+  switch (scc->dmrs_TypeA_Position) {
+  case 	NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2:
+    mib->message.choice.mib->dmrs_TypeA_Position = NR_MIB__dmrs_TypeA_Position_pos2;
+    break;
+    
+  case 	NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos3:
+    mib->message.choice.mib->dmrs_TypeA_Position = NR_MIB__dmrs_TypeA_Position_pos3;
+    break;
+    
+  default:
+    AssertFatal(1==0,"Unknown dmrs_TypeA_Position %d\n",(int)scc->dmrs_TypeA_Position);
   }
 
   //  assign_enum
@@ -286,7 +261,6 @@ uint8_t do_MIB_NR(rrc_gNB_carrier_data_t *carrier,
   return((enc_rval.encoded+7)/8);
 }
 
-
 uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, 
 	               gNB_RrcConfigurationReq *configuration
                   ) {
@@ -382,519 +356,6 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier,
 }
 
 
-void do_SERVINGCELLCONFIGCOMMON(uint8_t Mod_id,
-                                int     CC_id,
-                                gNB_RrcConfigurationReq *configuration,
-                                int initial_flag
-                               ) {
-  NR_ServingCellConfigCommon_t                   **servingcellconfigcommon = &RC.nrrrc[Mod_id]->carrier[CC_id].servingcellconfigcommon;
-  NR_FreqBandIndicatorNR_t                       *dl_frequencyBandList;
-  NR_SCS_SpecificCarrier_t                       *dl_scs_SpecificCarrierList;
-  NR_TCI_StateId_t                               *TCI_StateId;
-  NR_ControlResourceSet_t                        *bwp_dl_controlresourceset;
-  NR_SearchSpace_t                               *bwp_dl_searchspace;
-  NR_PDSCH_TimeDomainResourceAllocation_t        *bwp_dl_timedomainresourceallocation;
-  NR_FreqBandIndicatorNR_t                       *ul_frequencyBandList;
-  NR_SCS_SpecificCarrier_t                       *ul_scs_SpecificCarrierList;
-  NR_PUSCH_TimeDomainResourceAllocation_t        *pusch_configcommontimedomainresourceallocation;
-  NR_RateMatchPattern_t                          *ratematchpattern;
-  NR_RateMatchPatternId_t                        *ratematchpatternid;
-  dl_frequencyBandList                           = CALLOC(1,sizeof(NR_FreqBandIndicatorNR_t));
-  ul_frequencyBandList                           = CALLOC(1,sizeof(NR_FreqBandIndicatorNR_t));
-  dl_scs_SpecificCarrierList                     = CALLOC(1,sizeof(NR_SCS_SpecificCarrier_t));
-  ul_scs_SpecificCarrierList                     = CALLOC(1,sizeof(NR_SCS_SpecificCarrier_t));
-  TCI_StateId                                    = CALLOC(1,sizeof(NR_TCI_StateId_t));
-  bwp_dl_searchspace                             = CALLOC(1,sizeof(NR_SearchSpace_t));
-  bwp_dl_timedomainresourceallocation            = CALLOC(1,sizeof(NR_PDSCH_TimeDomainResourceAllocation_t));
-  pusch_configcommontimedomainresourceallocation = CALLOC(1,sizeof(NR_PUSCH_TimeDomainResourceAllocation_t));
-  ratematchpattern                               = CALLOC(1,sizeof(NR_RateMatchPattern_t));
-  ratematchpatternid                             = CALLOC(1,sizeof(NR_RateMatchPatternId_t));
-
-  if(initial_flag == 1) {
-    (*servingcellconfigcommon)                                            = CALLOC(1,sizeof(NR_ServingCellConfigCommon_t));
-    (*servingcellconfigcommon)->physCellId                                = CALLOC(1,sizeof(NR_PhysCellId_t));
-    (*servingcellconfigcommon)->downlinkConfigCommon                      = CALLOC(1,sizeof(struct NR_DownlinkConfigCommon));
-    (*servingcellconfigcommon)->downlinkConfigCommon->frequencyInfoDL     = CALLOC(1,sizeof(struct NR_FrequencyInfoDL));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP  = CALLOC(1,sizeof(struct NR_BWP_DownlinkCommon));
-    (*servingcellconfigcommon)->uplinkConfigCommon                        = CALLOC(1,sizeof(struct NR_UplinkConfigCommon));
-    (*servingcellconfigcommon)->uplinkConfigCommon->frequencyInfoUL       = CALLOC(1,sizeof(struct NR_FrequencyInfoUL));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP      = CALLOC(1,sizeof(struct NR_BWP_UplinkCommon));
-    //(*servingcellconfigcommon)->supplementaryUplinkConfig       = CALLOC(1,sizeof(struct NR_UplinkConfigCommon));
-    (*servingcellconfigcommon)->ssb_PositionsInBurst                      = CALLOC(1,sizeof(struct NR_ServingCellConfigCommon__ssb_PositionsInBurst));
-    (*servingcellconfigcommon)->ssb_periodicityServingCell                = CALLOC(1,sizeof(long));
-    //(*servingcellconfigcommon)->lte_CRS_ToMatchAround           = CALLOC(1,sizeof(struct NR_SetupRelease_RateMatchPatternLTE_CRS));
-    (*servingcellconfigcommon)->rateMatchPatternToAddModList              = CALLOC(1,sizeof(struct NR_ServingCellConfigCommon__rateMatchPatternToAddModList));
-    (*servingcellconfigcommon)->rateMatchPatternToReleaseList             = CALLOC(1,sizeof(struct NR_ServingCellConfigCommon__rateMatchPatternToReleaseList));
-    (*servingcellconfigcommon)->ssbSubcarrierSpacing                      = CALLOC(1,sizeof(NR_SubcarrierSpacing_t));
-    (*servingcellconfigcommon)->tdd_UL_DL_ConfigurationCommon             = CALLOC(1,sizeof(struct NR_TDD_UL_DL_ConfigCommon));
-    (*servingcellconfigcommon)->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB     = CALLOC(1,sizeof(NR_ARFCN_ValueNR_t));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->genericParameters.cyclicPrefix    = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon                = CALLOC(1,sizeof(struct NR_SetupRelease_PDCCH_ConfigCommon));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup  = CALLOC(1,sizeof(struct NR_PDCCH_ConfigCommon));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero    = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero           = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet  = CALLOC(1,sizeof(NR_ControlResourceSet_t));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList     = CALLOC(1,
-        sizeof(struct NR_PDCCH_ConfigCommon__commonSearchSpaceList));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1                    = CALLOC(1,sizeof(NR_SearchSpaceId_t));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation  = CALLOC(1,sizeof(NR_SearchSpaceId_t));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->pagingSearchSpace                  = CALLOC(1,sizeof(NR_SearchSpaceId_t));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace                     = CALLOC(1,sizeof(NR_SearchSpaceId_t));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon                 = CALLOC(1,sizeof(struct NR_SetupRelease_PDSCH_ConfigCommon));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup   = CALLOC(1,sizeof(struct NR_PDSCH_ConfigCommon));
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = CALLOC(1,
-        sizeof(struct NR_PDSCH_TimeDomainResourceAllocationList));
-    (*servingcellconfigcommon)->uplinkConfigCommon->frequencyInfoUL->frequencyBandList          = CALLOC(1,sizeof(NR_MultiFrequencyBandListNR_t));
-    (*servingcellconfigcommon)->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA    = CALLOC(1,sizeof(NR_ARFCN_ValueNR_t));
-    (*servingcellconfigcommon)->uplinkConfigCommon->frequencyInfoUL->additionalSpectrumEmission = CALLOC(1,sizeof(NR_AdditionalSpectrumEmission_t));
-    (*servingcellconfigcommon)->uplinkConfigCommon->frequencyInfoUL->p_Max                      = CALLOC(1,sizeof(NR_P_Max_t));
-    (*servingcellconfigcommon)->uplinkConfigCommon->frequencyInfoUL->frequencyShift7p5khz       = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->genericParameters.cyclicPrefix    = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon                 = CALLOC(1,sizeof(NR_SetupRelease_RACH_ConfigCommon_t));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup   = CALLOC(1,sizeof(struct NR_RACH_ConfigCommon));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->totalNumberOfRA_Preambles                  = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB  = CALLOC(1,
-        sizeof(struct NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->groupBconfigured                           = CALLOC(1,
-        sizeof(struct NR_RACH_ConfigCommon__groupBconfigured));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rsrp_ThresholdSSB            = CALLOC(1,sizeof(NR_RSRP_Range_t));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rsrp_ThresholdSSB_SUL        = CALLOC(1,sizeof(NR_RSRP_Range_t));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing       = CALLOC(1,sizeof(NR_SubcarrierSpacing_t));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder       = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon                 = CALLOC(1,sizeof(NR_SetupRelease_PUSCH_ConfigCommon_t));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup   = CALLOC(1,sizeof(struct NR_PUSCH_ConfigCommon));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->groupHoppingEnabledTransformPrecoding = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList  = CALLOC(1,sizeof(NR_PUSCH_TimeDomainResourceAllocationList_t));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble              = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->p0_NominalWithGrant             = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon                                                = CALLOC(1,sizeof(struct NR_SetupRelease_PUCCH_ConfigCommon));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup                                  = CALLOC(1,sizeof(struct NR_PUCCH_ConfigCommon));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon            = CALLOC(1,sizeof(BIT_STRING_t));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->p0_nominal                      = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon            = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->hoppingId                       = CALLOC(1,sizeof(long));
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.buf  = MALLOC(1);
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.buf = MALLOC(1);
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf   = MALLOC(8);
-    bwp_dl_controlresourceset =(*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet;
-    bwp_dl_controlresourceset->cce_REG_MappingType.choice.interleaved               = CALLOC(1,sizeof(struct NR_ControlResourceSet__cce_REG_MappingType__interleaved));
-    bwp_dl_controlresourceset->frequencyDomainResources.buf                         = MALLOC(6);
-    bwp_dl_controlresourceset->cce_REG_MappingType.choice.interleaved->shiftIndex   = CALLOC(1,sizeof(long));
-    bwp_dl_controlresourceset->tci_StatesPDCCH_ToAddList                            = CALLOC(1,sizeof(struct NR_ControlResourceSet__tci_StatesPDCCH_ToAddList));
-    bwp_dl_controlresourceset->tci_PresentInDCI                                     = CALLOC(1,sizeof(long));
-    bwp_dl_controlresourceset->pdcch_DMRS_ScramblingID                              = CALLOC(1,sizeof(long));
-    bwp_dl_searchspace->controlResourceSetId                                        = CALLOC(1,sizeof(NR_ControlResourceSetId_t));
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset                          = CALLOC(1,sizeof(struct NR_SearchSpace__monitoringSlotPeriodicityAndOffset));
-    bwp_dl_searchspace->duration                                                    = CALLOC(1,sizeof(long));
-    bwp_dl_searchspace->monitoringSymbolsWithinSlot                                 = CALLOC(1,sizeof(BIT_STRING_t));
-    bwp_dl_searchspace->monitoringSymbolsWithinSlot->buf                            = MALLOC(2);
-    bwp_dl_searchspace->nrofCandidates                                              = CALLOC(1,sizeof(struct NR_SearchSpace__nrofCandidates));
-    bwp_dl_searchspace->searchSpaceType                                             = CALLOC(1,sizeof(struct NR_SearchSpace__searchSpaceType));
-    bwp_dl_timedomainresourceallocation->k0 = CALLOC(1,sizeof(long));
-    pusch_configcommontimedomainresourceallocation      = CALLOC(1,sizeof(NR_PUSCH_TimeDomainResourceAllocation_t));
-    pusch_configcommontimedomainresourceallocation->k2  = CALLOC(1,sizeof(long));
-    ratematchpattern->patternType.choice.bitmaps                                             = CALLOC(1,sizeof(struct NR_RateMatchPattern__patternType__bitmaps));
-    ratematchpattern->patternType.choice.bitmaps->resourceBlocks.buf                         = MALLOC(35);
-    ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.oneSlot.buf  = MALLOC(2);
-    ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.twoSlots.buf = MALLOC(4);
-    ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern                      = CALLOC(1,sizeof(struct NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern));
-    ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n2.buf       = MALLOC(1);
-    ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n4.buf       = MALLOC(1);
-    ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n5.buf       = MALLOC(1);
-    ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n8.buf       = MALLOC(1);
-    ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n10.buf      = MALLOC(2);
-    ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n20.buf      = MALLOC(3);
-    ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n40.buf      = MALLOC(5);
-    ratematchpattern->subcarrierSpacing                                                      = CALLOC(1,sizeof(NR_SubcarrierSpacing_t));
-  } else {
-    bwp_dl_controlresourceset =(*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonControlResourceSet;
-  }
-
-  //------------------------------------Start Fill ServingCellConfigCommon------------------------------------//
-  //physCellId
-  *((*servingcellconfigcommon)->physCellId)  = configuration->Nid_cell[CC_id];
-  //NR_DownlinkConfigCommon
-  *((*servingcellconfigcommon)->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB)  = configuration->absoluteFrequencySSB[CC_id];
-  *(dl_frequencyBandList)   = configuration->DL_FreqBandIndicatorNR[CC_id];
-  ASN_SEQUENCE_ADD(&(*servingcellconfigcommon)->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list,&dl_frequencyBandList);
-  (*servingcellconfigcommon)->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA = configuration->DL_absoluteFrequencyPointA[CC_id];
-  dl_scs_SpecificCarrierList->offsetToCarrier    = configuration->DL_offsetToCarrier[CC_id];
-  dl_scs_SpecificCarrierList->subcarrierSpacing  = configuration->DL_SCS_SubcarrierSpacing[CC_id];
-  dl_scs_SpecificCarrierList->carrierBandwidth   = configuration->DL_carrierBandwidth[CC_id];
-  ASN_SEQUENCE_ADD(&(*servingcellconfigcommon)->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list,&dl_scs_SpecificCarrierList);
-  //initialDownlinkBWP
-  //initialDownlinkBWP  -----  genericParameters
-  (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth = configuration->DL_locationAndBandwidth[CC_id];
-  (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing    = configuration->DL_BWP_SubcarrierSpacing[CC_id];
-
-  if(configuration->DL_BWP_prefix_type[CC_id]) {
-    (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->genericParameters.cyclicPrefix  = NR_BWP__cyclicPrefix_extended;
-  }
-
-  //initialDownlinkBWP  -----  pdcch_ConfigCommon
-  (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->present       = NR_SetupRelease_PDCCH_ConfigCommon_PR_setup;
-  //Fill  initialDownlinkBWP  ->  pdcch_ConfigCommon  ->  ControlResourceSet list //
-  *((*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->controlResourceSetZero) = configuration->controlResourceSetZero[CC_id];
-  *((*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceZero)        = configuration->searchSpaceZero[CC_id];
-  bwp_dl_controlresourceset->controlResourceSetId         = configuration->PDCCH_common_controlResourceSetId[CC_id];
-  //BIT STRING (SIZE (45))
-  bwp_dl_controlresourceset->frequencyDomainResources.size          = 6;
-  bwp_dl_controlresourceset->frequencyDomainResources.bits_unused   = 3;
-  bwp_dl_controlresourceset->frequencyDomainResources.buf[0]        = 0x1f;
-  bwp_dl_controlresourceset->frequencyDomainResources.buf[1]        = 0xff;
-  bwp_dl_controlresourceset->frequencyDomainResources.buf[2]        = 0xff;
-  bwp_dl_controlresourceset->frequencyDomainResources.buf[3]        = 0xff;
-  bwp_dl_controlresourceset->frequencyDomainResources.buf[4]        = 0xff;
-  bwp_dl_controlresourceset->frequencyDomainResources.buf[5]        = 0xff;
-  bwp_dl_controlresourceset->duration                     = configuration->PDCCH_common_ControlResourceSet_duration[CC_id];
-  bwp_dl_controlresourceset->cce_REG_MappingType.present  = configuration->PDCCH_cce_REG_MappingType[CC_id];
-
-  if(bwp_dl_controlresourceset->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved ) {
-    bwp_dl_controlresourceset->cce_REG_MappingType.choice.interleaved->reg_BundleSize    = configuration->PDCCH_reg_BundleSize[CC_id];
-    bwp_dl_controlresourceset->cce_REG_MappingType.choice.interleaved->interleaverSize   = configuration->PDCCH_interleaverSize[CC_id];
-    *(bwp_dl_controlresourceset->cce_REG_MappingType.choice.interleaved->shiftIndex)        = configuration->PDCCH_shiftIndex[CC_id];
-  } else if(bwp_dl_controlresourceset->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved) {
-    bwp_dl_controlresourceset->cce_REG_MappingType.choice.nonInterleaved = 0;
-  }
-
-  bwp_dl_controlresourceset->precoderGranularity =  configuration->PDCCH_precoderGranularity[CC_id];
-  *(TCI_StateId) = configuration->PDCCH_TCI_StateId[CC_id];
-  ASN_SEQUENCE_ADD(&bwp_dl_controlresourceset->tci_StatesPDCCH_ToAddList->list,&TCI_StateId);
-
-  if(configuration->tci_PresentInDCI[CC_id]) {
-    bwp_dl_controlresourceset->tci_PresentInDCI  = NR_ControlResourceSet__tci_PresentInDCI_enabled;
-  }
-
-  *(bwp_dl_controlresourceset->pdcch_DMRS_ScramblingID)   = configuration->PDCCH_DMRS_ScramblingID[CC_id];;
-  //Fill  downlinkConfigCommon  ->  initialDownlinkBWP  ->  pdcch_ConfigCommon  ->  SearchSpace list //
-  bwp_dl_searchspace->searchSpaceId             = configuration->SearchSpaceId[CC_id];
-  *(bwp_dl_searchspace->controlResourceSetId)   = configuration->commonSearchSpaces_controlResourceSetId[CC_id];
-  bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_choice[CC_id];
-
-  if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl1 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl2 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl4 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl5 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl8 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl10 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl16 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl20 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl40 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl80 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl160 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl320 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl640 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl1280 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  } else if(bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->present == NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560) {
-    bwp_dl_searchspace->monitoringSlotPeriodicityAndOffset->choice.sl2560 = configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id];
-  }
-
-  *(bwp_dl_searchspace->duration)                              = configuration->SearchSpace_duration[CC_id];
-  bwp_dl_searchspace->monitoringSymbolsWithinSlot->size        = 2;
-  bwp_dl_searchspace->monitoringSymbolsWithinSlot->bits_unused = 2;
-  bwp_dl_searchspace->monitoringSymbolsWithinSlot->buf[0]      = 0x3f;
-  bwp_dl_searchspace->monitoringSymbolsWithinSlot->buf[1]      = 0xff;
-  bwp_dl_searchspace->nrofCandidates->aggregationLevel1  = configuration->SearchSpace_nrofCandidates_aggregationLevel1[CC_id];
-  bwp_dl_searchspace->nrofCandidates->aggregationLevel2  = configuration->SearchSpace_nrofCandidates_aggregationLevel2[CC_id];
-  bwp_dl_searchspace->nrofCandidates->aggregationLevel4  = configuration->SearchSpace_nrofCandidates_aggregationLevel4[CC_id];
-  bwp_dl_searchspace->nrofCandidates->aggregationLevel8  = configuration->SearchSpace_nrofCandidates_aggregationLevel8[CC_id];
-  bwp_dl_searchspace->nrofCandidates->aggregationLevel16 = configuration->SearchSpace_nrofCandidates_aggregationLevel16[CC_id];
-  bwp_dl_searchspace->searchSpaceType->present = configuration->SearchSpace_searchSpaceType[CC_id];
-
-  if(bwp_dl_searchspace->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_common) {
-    bwp_dl_searchspace->searchSpaceType->choice.common                              = CALLOC(1,sizeof(struct NR_SearchSpace__searchSpaceType__common));
-    bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_0                                           = CALLOC(1,sizeof(struct NR_SearchSpace__searchSpaceType__common__dci_Format2_0));
-    bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_0->nrofCandidates_SFI.aggregationLevel1     = CALLOC(1,sizeof(long));
-    bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_0->nrofCandidates_SFI.aggregationLevel2     = CALLOC(1,sizeof(long));
-    bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_0->nrofCandidates_SFI.aggregationLevel4     = CALLOC(1,sizeof(long));
-    bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_0->nrofCandidates_SFI.aggregationLevel8     = CALLOC(1,sizeof(long));
-    bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_0->nrofCandidates_SFI.aggregationLevel16    = CALLOC(1,sizeof(long));
-    bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_3                                           = CALLOC(1,sizeof(struct NR_SearchSpace__searchSpaceType__common__dci_Format2_3));
-    bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_3->dummy1                                   = CALLOC(1,sizeof(long));
-    *(bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_0->nrofCandidates_SFI.aggregationLevel1)  = configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1[CC_id];
-    *(bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_0->nrofCandidates_SFI.aggregationLevel2)  = configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2[CC_id];
-    *(bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_0->nrofCandidates_SFI.aggregationLevel4)  = configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4[CC_id];
-    *(bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_0->nrofCandidates_SFI.aggregationLevel8)  = configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8[CC_id];
-    *(bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_0->nrofCandidates_SFI.aggregationLevel16) = configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16[CC_id];
-    *(bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_3->dummy1)                                = configuration->Common_dci_Format2_3_monitoringPeriodicity[CC_id];
-    bwp_dl_searchspace->searchSpaceType->choice.common->dci_Format2_3->dummy2                                   = configuration->Common_dci_Format2_3_nrofPDCCH_Candidates[CC_id];
-  } else if (bwp_dl_searchspace->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) {
-    bwp_dl_searchspace->searchSpaceType->choice.ue_Specific                         = CALLOC(1,sizeof(struct NR_SearchSpace__searchSpaceType__ue_Specific));
-    bwp_dl_searchspace->searchSpaceType->choice.ue_Specific->dci_Formats = configuration->ue_Specific__dci_Formats[CC_id];
-  }
-
-  ASN_SEQUENCE_ADD(&(*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,&bwp_dl_searchspace);
-  *((*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1)                    = configuration->searchSpaceSIB1[CC_id];
-  *((*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation)  = configuration->searchSpaceOtherSystemInformation[CC_id];
-  *((*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->pagingSearchSpace)                  = configuration->pagingSearchSpace[CC_id];
-  *((*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace)                     = configuration->ra_SearchSpace[CC_id];
-  //initialDownlinkBWP  -----  pdsch_ConfigCommon
-  (*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->present        = NR_SetupRelease_PDSCH_ConfigCommon_PR_setup;
-  *(bwp_dl_timedomainresourceallocation->k0)                            = configuration->PDSCH_TimeDomainResourceAllocation_k0[CC_id];
-  bwp_dl_timedomainresourceallocation->mappingType                      = configuration->PDSCH_TimeDomainResourceAllocation_mappingType[CC_id];
-  bwp_dl_timedomainresourceallocation->startSymbolAndLength             = configuration->PDSCH_TimeDomainResourceAllocation_startSymbolAndLength[CC_id];
-  ASN_SEQUENCE_ADD(&(*servingcellconfigcommon)->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list,&bwp_dl_timedomainresourceallocation);
-  //uplinkConfigCommon
-  //uplinkConfigCommon  frequencyInfoUL //
-  *(ul_frequencyBandList)   = configuration->UL_FreqBandIndicatorNR[CC_id];
-  ASN_SEQUENCE_ADD(&(*servingcellconfigcommon)->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list,&ul_frequencyBandList);
-  *((*servingcellconfigcommon)->uplinkConfigCommon->frequencyInfoUL->absoluteFrequencyPointA) = configuration->UL_absoluteFrequencyPointA[CC_id];
-  ul_scs_SpecificCarrierList->offsetToCarrier    = configuration->UL_offsetToCarrier[CC_id];
-  ul_scs_SpecificCarrierList->subcarrierSpacing  = configuration->UL_SCS_SubcarrierSpacing[CC_id];
-  ul_scs_SpecificCarrierList->carrierBandwidth   = configuration->UL_carrierBandwidth[CC_id];
-  ASN_SEQUENCE_ADD(&(*servingcellconfigcommon)->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list,&ul_scs_SpecificCarrierList);
-  *((*servingcellconfigcommon)->uplinkConfigCommon->frequencyInfoUL->additionalSpectrumEmission) = configuration->UL_additionalSpectrumEmission[CC_id];
-  *((*servingcellconfigcommon)->uplinkConfigCommon->frequencyInfoUL->p_Max)                      = configuration->UL_p_Max[CC_id];
-  *((*servingcellconfigcommon)->uplinkConfigCommon->frequencyInfoUL->frequencyShift7p5khz)       = configuration->UL_frequencyShift7p5khz[CC_id];
-  //uplinkConfigCommon  initialUplinkBWP //
-  //Fill  initialUplinkBWP -> BWP-UplinkCommon -> genericParameters//
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth = configuration->UL_locationAndBandwidth[CC_id];
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing    = configuration->UL_BWP_SubcarrierSpacing[CC_id];
-
-  if(configuration->UL_BWP_prefix_type[CC_id]) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->genericParameters.cyclicPrefix = NR_BWP__cyclicPrefix_extended;
-  }
-
-  //Fill  initialUplinkBWP -> BWP-UplinkCommon -> rach_ConfigCommon//
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->present       = NR_SetupRelease_RACH_ConfigCommon_PR_setup;
-  *((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->totalNumberOfRA_Preambles) = configuration->rach_totalNumberOfRA_Preambles[CC_id];
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present =
-    configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[CC_id];
-
-  if((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present       ==
-      NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneEighth) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneEighth =
-      configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[CC_id];
-  } else if((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present ==
-            NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneFourth) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneFourth =
-      configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[CC_id];
-  } else if((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present ==
-            NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneHalf) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.oneHalf   =
-      configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[CC_id];
-  } else if((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present ==
-            NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one       =
-      configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[CC_id];
-  } else if((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present ==
-            NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_two) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.two       =
-      configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[CC_id];
-  } else if((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present ==
-            NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_four) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.four      =
-      configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four[CC_id];
-  } else if((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present ==
-            NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_eight) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.eight     =
-      configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight[CC_id];
-  } else if((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present ==
-            NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_sixteen) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.sixteen   =
-      configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen[CC_id];
-  }
-
-  if(configuration->rach_groupBconfigured[CC_id]) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->groupBconfigured->ra_Msg3SizeGroupA            = configuration->rach_ra_Msg3SizeGroupA[CC_id];
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->groupBconfigured->messagePowerOffsetGroupB     = configuration->rach_messagePowerOffsetGroupB[CC_id];
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->groupBconfigured->numberOfRA_PreamblesGroupA   =
-      configuration->rach_numberOfRA_PreamblesGroupA[CC_id];
-  }
-
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->ra_ContentionResolutionTimer = configuration->rach_ra_ContentionResolutionTimer[CC_id];
-  *((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rsrp_ThresholdSSB)            = configuration->rsrp_ThresholdSSB[CC_id];
-  *((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rsrp_ThresholdSSB_SUL)        = configuration->rsrp_ThresholdSSB_SUL[CC_id];
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present   = configuration->prach_RootSequenceIndex_choice[CC_id];
-
-  if((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present == NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l839 = configuration->prach_RootSequenceIndex_l839[CC_id];
-  } else if ((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present ==
-             NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l139 = configuration->prach_RootSequenceIndex_l139[CC_id];
-  }
-
-  *((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg1_SubcarrierSpacing)    = configuration->prach_msg1_SubcarrierSpacing[CC_id];
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->restrictedSetConfig          = configuration->restrictedSetConfig[CC_id];
-
-  if(configuration->msg3_transformPrecoding[CC_id]) {
-    *((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder)   = NR_RACH_ConfigCommon__msg3_transformPrecoder_enabled;
-  }
-
-  //Fill  initialUplinkBWP -> BWP-UplinkCommon -> rach_ConfigCommon -> rach_ConfigGeneric//
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.prach_ConfigurationIndex       = configuration->prach_ConfigurationIndex[CC_id];
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FDM                       = configuration->prach_msg1_FDM[CC_id];
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FrequencyStart            = configuration->prach_msg1_FrequencyStart[CC_id];
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.zeroCorrelationZoneConfig      = configuration->zeroCorrelationZoneConfig[CC_id];
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleReceivedTargetPower    =
-    configuration->preambleReceivedTargetPower[CC_id];
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.preambleTransMax               = configuration->preambleTransMax[CC_id];
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.powerRampingStep               = configuration->powerRampingStep[CC_id];
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.ra_ResponseWindow              = configuration->ra_ResponseWindow[CC_id];
-  //Fill  initialUplinkBWP -> BWP-UplinkCommon -> pusch_ConfigCommon//
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->present        = NR_SetupRelease_PUSCH_ConfigCommon_PR_setup;
-
-  if(configuration->groupHoppingEnabledTransformPrecoding[CC_id]) {
-    (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->groupHoppingEnabledTransformPrecoding =
-      NR_PUSCH_ConfigCommon__groupHoppingEnabledTransformPrecoding_enabled;
-  }
-
-  *(pusch_configcommontimedomainresourceallocation->k2)                = configuration->PUSCH_TimeDomainResourceAllocation_k2[CC_id];
-  pusch_configcommontimedomainresourceallocation->mappingType          = configuration->PUSCH_TimeDomainResourceAllocation_mappingType[CC_id];
-  pusch_configcommontimedomainresourceallocation->startSymbolAndLength = configuration->PUSCH_TimeDomainResourceAllocation_startSymbolAndLength[CC_id];
-  ASN_SEQUENCE_ADD(&(*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list,
-                   &pusch_configcommontimedomainresourceallocation);
-  *((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->msg3_DeltaPreamble)   = configuration->msg3_DeltaPreamble[CC_id];
-  *((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->p0_NominalWithGrant)  = configuration->p0_NominalWithGrant[CC_id];
-  //Fill  initialUplinkBWP -> BWP-UplinkCommon -> pucch_ConfigCommon//
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->present      = NR_SetupRelease_PUCCH_ConfigCommon_PR_setup;
-  (*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_GroupHopping      = configuration->pucch_GroupHopping[CC_id];
-  *((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->p0_nominal)           = configuration->p0_nominal[CC_id];
-  *((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon) = configuration->pucch_ResourceCommon[CC_id];
-  *((*servingcellconfigcommon)->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->hoppingId)            = configuration->hoppingId[CC_id];
-  (*servingcellconfigcommon)->uplinkConfigCommon->dummy                    = configuration->UL_timeAlignmentTimerCommon[CC_id];
-  (*servingcellconfigcommon)->n_TimingAdvanceOffset = CALLOC(1,sizeof(long));
-  *((*servingcellconfigcommon)->n_TimingAdvanceOffset)=configuration->ServingCellConfigCommon_n_TimingAdvanceOffset[CC_id];
-  //ssb_PositionsInBurst
-  (*servingcellconfigcommon)->ssb_PositionsInBurst->present = configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id];
-  uint64_t t_freq;
-
-  if(configuration->nr_band[CC_id] == 41 || (configuration->nr_band[CC_id] > 76 && configuration->nr_band[CC_id] < 80))
-    t_freq = 2400000000;
-  else
-    t_freq = 3000000000;
-
-  if(configuration->downlink_frequency[CC_id]<t_freq) {
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.size = 1;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.bits_unused = 4;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.buf[0] = configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id];
-  } else if(configuration->downlink_frequency[CC_id]<6000000000) {
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.size = 1;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.bits_unused = 0;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.buf[0] = configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id];
-  } else {
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.size = 8;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.bits_unused = 0;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[0] = 0xff;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[1] = 0xff;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[2] = 0xff;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[3] = 0xff;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[4] = 0xff;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[5] = 0xff;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[6] = 0xff;
-    (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[7] = 0xff;
-  }
-
-  //ssb_periodicityServingCell
-  *(*servingcellconfigcommon)->ssb_periodicityServingCell  = configuration->ServingCellConfigCommon_ssb_periodicityServingCell[CC_id];
-  //dmrs_TypeA_Position
-  (*servingcellconfigcommon)->dmrs_TypeA_Position          = configuration->ServingCellConfigCommon_dmrs_TypeA_Position[CC_id];
-  //lte_CRS_ToMatchAround
-  //rateMatchPatternToAddModList
-  ratematchpattern->rateMatchPatternId    = configuration->rateMatchPatternId[CC_id];
-  ratematchpattern->patternType.present   = configuration->RateMatchPattern_patternType[CC_id];
-
-  if(ratematchpattern->patternType.present == NR_RateMatchPattern__patternType_PR_bitmaps) {
-    ratematchpattern->patternType.choice.bitmaps->resourceBlocks.size = 35;
-    ratematchpattern->patternType.choice.bitmaps->resourceBlocks.bits_unused = 5;
-    ratematchpattern->patternType.choice.bitmaps->resourceBlocks.buf[0] = 0x07;
-
-    for (int i =1; i<=34; i++ ) {
-      ratematchpattern->patternType.choice.bitmaps->resourceBlocks.buf[i] =0xff;
-    }
-
-    ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.present = configuration->symbolsInResourceBlock[CC_id];
-
-    if(ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.present == NR_RateMatchPattern__patternType__bitmaps__symbolsInResourceBlock_PR_oneSlot) {
-      ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.oneSlot.size=2;
-      ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.oneSlot.bits_unused=2;
-      ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.oneSlot.buf[0]=0x3f;
-      ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.oneSlot.buf[1]=0xff;
-    } else if(ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.present == NR_RateMatchPattern__patternType__bitmaps__symbolsInResourceBlock_PR_twoSlots) {
-      ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.twoSlots.size=4;
-      ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.twoSlots.bits_unused=4;
-      ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.twoSlots.buf[0]=0x0f;
-      ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.twoSlots.buf[1]=0xff;
-      ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.twoSlots.buf[2]=0xff;
-      ratematchpattern->patternType.choice.bitmaps->symbolsInResourceBlock.choice.twoSlots.buf[3]=0xff;
-    }
-
-    ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->present = configuration->periodicityAndPattern[CC_id];
-
-    if(ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->present == NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n2) {
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n2.size = 1;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n2.bits_unused = 6;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n2.buf[0] =0x03;
-    } else if(ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->present == NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n4) {
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n4.size = 1;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n4.bits_unused = 4;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n4.buf[0] = 0x0f;
-    } else if(ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->present == NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n5) {
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n5.size = 1;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n5.bits_unused = 3;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n5.buf[0] = 0x1f;
-    } else if(ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->present == NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n8) {
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n8.size = 1;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n8.bits_unused = 0;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n8.buf[0] = 0xff;
-    } else if(ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->present == NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n10) {
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n10.size = 2;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n10.bits_unused = 6;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n10.buf[0] = 0x03;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n10.buf[1] = 0xff;
-    } else if(ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->present == NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n20) {
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n20.size = 3;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n20.bits_unused = 4;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n20.buf[0] = 0x0f;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n20.buf[1] = 0xff;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n20.buf[2] = 0xff;
-    } else if(ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->present == NR_RateMatchPattern__patternType__bitmaps__periodicityAndPattern_PR_n40) {
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n40.size = 5;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n40.bits_unused = 0;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n40.buf[0] = 0xff;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n40.buf[1] = 0xff;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n40.buf[2] = 0xff;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n40.buf[3] = 0xff;
-      ratematchpattern->patternType.choice.bitmaps->periodicityAndPattern->choice.n40.buf[4] = 0xff;
-    }
-  } else if(ratematchpattern->patternType.present == NR_RateMatchPattern__patternType_PR_controlResourceSet) {
-    ratematchpattern->patternType.choice.controlResourceSet = configuration->RateMatchPattern_controlResourceSet[CC_id];
-  }
-
-  *(ratematchpattern->subcarrierSpacing) = configuration->RateMatchPattern_subcarrierSpacing[CC_id];
-  ratematchpattern->dummy = configuration->RateMatchPattern_mode[CC_id];
-  ASN_SEQUENCE_ADD(&(*servingcellconfigcommon)->rateMatchPatternToAddModList->list,&ratematchpattern);
-  //rateMatchPatternToReleaseList
-  *(ratematchpatternid) = configuration->rateMatchPatternId[CC_id];
-  ASN_SEQUENCE_ADD(&(*servingcellconfigcommon)->rateMatchPatternToReleaseList->list,&ratematchpatternid);
-  //subcarrierSpacing
-  *(*servingcellconfigcommon)->ssbSubcarrierSpacing         = configuration->NIA_SubcarrierSpacing[CC_id];
-  //tdd_UL_DL_ConfigurationCommon
-  (*servingcellconfigcommon)->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing             = configuration->referenceSubcarrierSpacing[CC_id];
-  (*servingcellconfigcommon)->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity = configuration->dl_UL_TransmissionPeriodicity[CC_id];
-  (*servingcellconfigcommon)->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots             = configuration->nrofDownlinkSlots[CC_id];
-  (*servingcellconfigcommon)->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols           = configuration->nrofDownlinkSymbols[CC_id];
-  (*servingcellconfigcommon)->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots               = configuration->nrofUplinkSlots[CC_id];
-  (*servingcellconfigcommon)->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols             = configuration->nrofUplinkSymbols[CC_id];
-  //ss_PBCH_BlockPower
-  (*servingcellconfigcommon)->ss_PBCH_BlockPower           = configuration->ServingCellConfigCommon_ss_PBCH_BlockPower[CC_id];
-}
-
-
 void  do_RLC_BEARER(uint8_t Mod_id,
                     int CC_id,
                     struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_BearerToAddModList,
@@ -1106,28 +567,14 @@ void  do_PHYSICALCELLGROUP(uint8_t Mod_id,
 }
 
 
-void do_SpCellConfig(uint8_t Mod_id,
-                     int CC_id,
-                     NR_SpCellConfig_t *spconfig) {
-  //spconfig->servCellIndex = CALLOC(1,sizeof(NR_ServCellIndex_t));
-  //*(spconfig->servCellIndex)=
+
+void do_SpCellConfig(gNB_RRC_INST *rrc,
+                      struct NR_SpCellConfig  *spconfig){
   gNB_RrcConfigurationReq  *common_configuration;
   common_configuration = CALLOC(1,sizeof(gNB_RrcConfigurationReq));
   //Fill servingcellconfigcommon config value
-  rrc_config_servingcellconfigcommon(Mod_id,
-                                     CC_id,
-                                     common_configuration
-                                    );
   //Fill common config to structure
-  do_SERVINGCELLCONFIGCOMMON(Mod_id,
-                             CC_id,
-                             common_configuration,
-                             0
-                            );
+  //  rrc->configuration = common_configuration;
   spconfig->reconfigurationWithSync = CALLOC(1,sizeof(struct NR_ReconfigurationWithSync));
-  /*
-    memcpy( spconfig->reconfigurationWithSync,
-            RC.nrrrc[Mod_id]->carrier[0].servingcellconfigcommon,
-            sizeof(struct NR_ServingCellConfigCommon));
-  */
 }
+
diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h
index 69ce650b237..3f647cb887b 100644
--- a/openair2/RRC/NR/MESSAGES/asn1_msg.h
+++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h
@@ -53,24 +53,9 @@
  */
 int xer_sprint_NR(char *string, size_t string_size, struct asn_TYPE_descriptor_s *td, void *sptr);
 
-uint16_t get_adjacent_cell_id_NR(uint8_t Mod_id,uint8_t index);
+uint8_t do_MIB_NR(gNB_RRC_INST *rrc,
+                  uint32_t frame);
 
-uint8_t get_adjacent_cell_mod_id_NR(uint16_t phyCellId);
-
-/**
-\brief Generate configuration for SIB1 (eNB).
-@param carrier pointer to Carrier information
-@param N_RB_DL Number of downlink PRBs
-@param phich_Resource PHICH resoure parameter
-@param phich_duration PHICH duration parameter
-@param frame radio frame number
-@return size of encoded bit stream in bytes*/
-uint8_t do_MIB_NR(rrc_gNB_carrier_data_t *carrier,
-                  uint32_t frame,
-                  uint32_t ssb_SubcarrierOffset,
-                  uint32_t pdcch_ConfigSIB1,
-                  uint32_t subCarrierSpacingCommon,
-                  uint32_t dmrs_TypeA_Position);
 /**
 \brief Generate configuration for SIB1 (gNB).
 @param carrier pointer to Carrier information
@@ -80,16 +65,10 @@ uint8_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier,
   gNB_RrcConfigurationReq *configuration
                   );
 
-void do_SERVINGCELLCONFIGCOMMON(uint8_t Mod_id,
-                                int CC_id,
-  gNB_RrcConfigurationReq *configuration,
-                                int initial_flag);
-
 void do_RLC_BEARER(uint8_t Mod_id,
-                   int CC_id,
-                   struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_BearerToAddModList,
-                   rlc_bearer_config_t *rlc_config);
-
+                    int CC_id,
+                    struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_BearerToAddModList,
+                    rlc_bearer_config_t  *rlc_config);
 void do_MAC_CELLGROUP(uint8_t Mod_id,
                       int CC_id,
                       NR_MAC_CellGroupConfig_t *mac_CellGroupConfig,
@@ -100,6 +79,6 @@ void do_PHYSICALCELLGROUP(uint8_t Mod_id,
                           NR_PhysicalCellGroupConfig_t *physicalCellGroupConfig,
                           physicalcellgroup_t *physicalcellgroup_config);
 
-void do_SpCellConfig(uint8_t Mod_id,
-                     int CC_id,
-                     NR_SpCellConfig_t *spconfig);
+
+void do_SpCellConfig(gNB_RRC_INST *rrc,
+                      struct NR_SpCellConfig  *spconfig);
diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c
index e09b1e60557..dedd4cf8396 100644
--- a/openair2/RRC/NR/nr_rrc_config.c
+++ b/openair2/RRC/NR/nr_rrc_config.c
@@ -30,142 +30,6 @@
 
 #include "nr_rrc_config.h"
 
-void rrc_config_servingcellconfigcommon(uint8_t Mod_id,
-                                        int CC_id,
-                                        gNB_RrcConfigurationReq *common_configuration
-                                       ){
-
-  common_configuration->MIB_subCarrierSpacingCommon[CC_id]                                = 0;
-  common_configuration->MIB_ssb_SubcarrierOffset[CC_id]                                   = 0;
-  common_configuration->MIB_dmrs_TypeA_Position[CC_id]                                    = 0;
-  common_configuration->pdcch_ConfigSIB1[CC_id]                                           = 0;
-  common_configuration->absoluteFrequencySSB[CC_id]                                       = 0;
-  common_configuration->DL_FreqBandIndicatorNR[CC_id]                                     = 0;
-  common_configuration->DL_absoluteFrequencyPointA[CC_id]                                 = 0;
-  common_configuration->DL_offsetToCarrier[CC_id]                                         = 0;
-  common_configuration->DL_SCS_SubcarrierSpacing[CC_id]                                   = 0;
-  common_configuration->DL_carrierBandwidth[CC_id]                                        = 0;
-  common_configuration->DL_locationAndBandwidth[CC_id]                                    = 0;
-  common_configuration->DL_BWP_SubcarrierSpacing[CC_id]                                   = 0;
-  common_configuration->DL_BWP_prefix_type[CC_id]                                         = 0;
-  common_configuration->UL_FreqBandIndicatorNR[CC_id]                                     = 0;
-  common_configuration->UL_absoluteFrequencyPointA[CC_id]                                 = 0;
-  common_configuration->UL_additionalSpectrumEmission[CC_id]                              = 0;
-  common_configuration->UL_p_Max[CC_id]                                                   = 0;
-  common_configuration->UL_frequencyShift7p5khz[CC_id]                                    = 0;
-  common_configuration->UL_offsetToCarrier[CC_id]                                         = 0;
-  common_configuration->UL_SCS_SubcarrierSpacing[CC_id]                                   = 0;
-  common_configuration->UL_carrierBandwidth[CC_id]                                        = 0;
-  common_configuration->UL_locationAndBandwidth[CC_id]                                    = 0;
-  common_configuration->UL_BWP_SubcarrierSpacing[CC_id]                                   = 0;
-  common_configuration->UL_BWP_prefix_type[CC_id]                                         = 0;
-  common_configuration->UL_timeAlignmentTimerCommon[CC_id]                                = 0;
-  common_configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id]            = 0;
-  common_configuration->ServingCellConfigCommon_ssb_periodicityServingCell[CC_id]         = 0;
-  common_configuration->ServingCellConfigCommon_dmrs_TypeA_Position[CC_id]                = 0;
-  common_configuration->NIA_SubcarrierSpacing[CC_id]                                      = 0;
-  common_configuration->ServingCellConfigCommon_ss_PBCH_BlockPower[CC_id]                 = 0;
-  common_configuration->referenceSubcarrierSpacing[CC_id]                                 = 0;
-  common_configuration->dl_UL_TransmissionPeriodicity[CC_id]                              = 0;
-  common_configuration->nrofDownlinkSlots[CC_id]                                          = 0;
-  common_configuration->nrofDownlinkSymbols[CC_id]                                        = 0;
-  common_configuration->nrofUplinkSlots[CC_id]                                            = 0;
-  common_configuration->nrofUplinkSymbols[CC_id]                                          = 0;
-  common_configuration->rach_totalNumberOfRA_Preambles[CC_id]                             = 0;
-  common_configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice[CC_id]      = 0;
-  common_configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth[CC_id]   = 0;
-  common_configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth[CC_id]   = 0;
-  common_configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf[CC_id]     = 0;
-  common_configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one[CC_id]         = 0;
-  common_configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two[CC_id]         = 0;
-  common_configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four[CC_id]        = 0;
-  common_configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight[CC_id]       = 0;
-  common_configuration->rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen[CC_id]     = 0;
-  common_configuration->rach_groupBconfigured[CC_id]                                      = 0;
-  common_configuration->rach_ra_Msg3SizeGroupA[CC_id]                                     = 0;
-  common_configuration->rach_messagePowerOffsetGroupB[CC_id]                              = 0;
-  common_configuration->rach_numberOfRA_PreamblesGroupA[CC_id]                            = 0;
-  common_configuration->rach_ra_ContentionResolutionTimer[CC_id]                          = 0;
-  common_configuration->rsrp_ThresholdSSB[CC_id]                                          = 0;
-  common_configuration->rsrp_ThresholdSSB_SUL[CC_id]                                      = 0;
-  common_configuration->prach_RootSequenceIndex_choice[CC_id]                             = 0;
-  common_configuration->prach_RootSequenceIndex_l839[CC_id]                               = 0;
-  common_configuration->prach_RootSequenceIndex_l139[CC_id]                               = 0;
-  common_configuration->prach_msg1_SubcarrierSpacing[CC_id]                               = 0;
-  common_configuration->restrictedSetConfig[CC_id]                                        = 0;
-  common_configuration->msg3_transformPrecoding[CC_id]                                    = 0;
-  common_configuration->prach_ConfigurationIndex[CC_id]                                   = 0;
-  common_configuration->prach_msg1_FDM[CC_id]                                             = 0;
-  common_configuration->prach_msg1_FrequencyStart[CC_id]                                  = 0;
-  common_configuration->zeroCorrelationZoneConfig[CC_id]                                  = 0;
-  common_configuration->preambleReceivedTargetPower[CC_id]                                = 0;
-  common_configuration->preambleTransMax[CC_id]                                           = 0;
-  common_configuration->powerRampingStep[CC_id]                                           = 0;
-  common_configuration->ra_ResponseWindow[CC_id]                                          = 0;
-  common_configuration->groupHoppingEnabledTransformPrecoding[CC_id]                      = 0;
-  common_configuration->msg3_DeltaPreamble[CC_id]                                         = 0;
-  common_configuration->p0_NominalWithGrant[CC_id]                                        = 0;
-  common_configuration->PUSCH_TimeDomainResourceAllocation_k2[CC_id]                      = 0;
-  common_configuration->PUSCH_TimeDomainResourceAllocation_mappingType[CC_id]             = 0;
-  common_configuration->PUSCH_TimeDomainResourceAllocation_startSymbolAndLength[CC_id]    = 0;
-  common_configuration->pucch_ResourceCommon[CC_id]                                       = 0;
-  common_configuration->pucch_GroupHopping[CC_id]                                         = 0;
-  common_configuration->hoppingId[CC_id]                                                  = 0;
-  common_configuration->p0_nominal[CC_id]                                                 = 0;
-  common_configuration->PDSCH_TimeDomainResourceAllocation_k0[CC_id]                      = 0;
-  common_configuration->PDSCH_TimeDomainResourceAllocation_mappingType[CC_id]             = 0;
-  common_configuration->PDSCH_TimeDomainResourceAllocation_startSymbolAndLength[CC_id]    = 0;
-  common_configuration->rateMatchPatternId[CC_id]                                         = 0;
-  common_configuration->RateMatchPattern_patternType[CC_id]                               = 0;
-  common_configuration->symbolsInResourceBlock[CC_id]                                     = 0;
-  common_configuration->periodicityAndPattern[CC_id]                                      = 0;
-  common_configuration->RateMatchPattern_controlResourceSet[CC_id]                        = 0;
-  common_configuration->RateMatchPattern_subcarrierSpacing[CC_id]                         = 0;
-  common_configuration->RateMatchPattern_mode[CC_id]                                      = 0;
-  common_configuration->controlResourceSetZero[CC_id]                                     = 0;
-  common_configuration->searchSpaceZero[CC_id]                                            = 0;
-  common_configuration->searchSpaceSIB1[CC_id]                                            = 0;
-  common_configuration->searchSpaceOtherSystemInformation[CC_id]                          = 0;
-  common_configuration->pagingSearchSpace[CC_id]                                          = 0;
-  common_configuration->ra_SearchSpace[CC_id]                                             = 0;
-  common_configuration->PDCCH_common_controlResourceSetId[CC_id]                          = 0;
-  common_configuration->PDCCH_common_ControlResourceSet_duration[CC_id]                   = 0;
-  common_configuration->PDCCH_cce_REG_MappingType[CC_id]                                  = 0;
-  common_configuration->PDCCH_reg_BundleSize[CC_id]                                       = 0;
-  common_configuration->PDCCH_interleaverSize[CC_id]                                      = 0;
-  common_configuration->PDCCH_shiftIndex[CC_id]                                           = 0;
-  common_configuration->PDCCH_precoderGranularity[CC_id]                                  = 0;
-  common_configuration->PDCCH_TCI_StateId[CC_id]                                          = 0;
-  common_configuration->tci_PresentInDCI[CC_id]                                           = 0;
-  common_configuration->PDCCH_DMRS_ScramblingID[CC_id]                                    = 0;
-  common_configuration->SearchSpaceId[CC_id]                                              = 0;
-  common_configuration->commonSearchSpaces_controlResourceSetId[CC_id]                    = 0;
-  common_configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_choice[CC_id]      = 0;
-  common_configuration->SearchSpace_monitoringSlotPeriodicityAndOffset_value[CC_id]       = 0;
-  common_configuration->SearchSpace_duration[CC_id]                                       = 0;
-  common_configuration->SearchSpace_nrofCandidates_aggregationLevel1[CC_id]               = 0;
-  common_configuration->SearchSpace_nrofCandidates_aggregationLevel2[CC_id]               = 0;
-  common_configuration->SearchSpace_nrofCandidates_aggregationLevel4[CC_id]               = 0;
-  common_configuration->SearchSpace_nrofCandidates_aggregationLevel8[CC_id]               = 0;
-  common_configuration->SearchSpace_nrofCandidates_aggregationLevel16[CC_id]              = 0;
-  common_configuration->SearchSpace_searchSpaceType[CC_id]                                = 0;
-  common_configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1[CC_id]  = 0;
-  common_configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2[CC_id]  = 0;
-  common_configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4[CC_id]  = 0;
-  common_configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8[CC_id]  = 0;
-  common_configuration->Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16[CC_id] = 0;
-  common_configuration->Common_dci_Format2_3_monitoringPeriodicity[CC_id]                 = 0;
-  common_configuration->Common_dci_Format2_3_nrofPDCCH_Candidates[CC_id]                  = 0;
-  common_configuration->ue_Specific__dci_Formats[CC_id]                                   = 0;
-  common_configuration->RateMatchPatternLTE_CRS_carrierFreqDL[CC_id]                      = 0;
-  common_configuration->RateMatchPatternLTE_CRS_carrierBandwidthDL[CC_id]                 = 0;
-  common_configuration->RateMatchPatternLTE_CRS_nrofCRS_Ports[CC_id]                      = 0;
-  common_configuration->RateMatchPatternLTE_CRS_v_Shift[CC_id]                            = 0;
-  common_configuration->RateMatchPatternLTE_CRS_radioframeAllocationPeriod[CC_id]         = 0;
-  common_configuration->RateMatchPatternLTE_CRS_radioframeAllocationOffset[CC_id]         = 0;
-  common_configuration->RateMatchPatternLTE_CRS_subframeAllocation_choice[CC_id]          = 0;
-}
-
 void rrc_config_rlc_bearer(uint8_t Mod_id,
                            int CC_id,
                            rlc_bearer_config_t *rlc_config
diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h
index 6b4a9864c7a..02b4154c41a 100644
--- a/openair2/RRC/NR/nr_rrc_defs.h
+++ b/openair2/RRC/NR/nr_rrc_defs.h
@@ -46,16 +46,10 @@
 //#include "COMMON/mac_rrc_primitives.h"
 
 #include "NR_SIB1.h"
-//#include "SystemInformation.h"
-//#include "RRCConnectionReconfiguration.h"
 #include "NR_RRCReconfigurationComplete.h"
 #include "NR_RRCReconfiguration.h"
-//#include "RRCConnectionReconfigurationComplete.h"
-//#include "RRCConnectionSetup.h"
-//#include "RRCConnectionSetupComplete.h"
-//#include "RRCConnectionRequest.h"
-//#include "RRCConnectionReestablishmentRequest.h"
 #include "NR_RRCReestablishmentRequest.h"
+#include "NR_BCCH-BCH-Message.h"
 #include "NR_BCCH-DL-SCH-Message.h"
 #include "NR_BCCH-BCH-Message.h"
 #include "NR_PLMN-IdentityInfo.h"
@@ -66,6 +60,7 @@
 //#include "AS-Config.h"
 //#include "AS-Context.h"
 #include "NR_UE-NR-Capability.h"
+#include "NR_UE-MRDC-Capability.h"
 #include "NR_MeasResults.h"
 #include "NR_CellGroupConfig.h"
 #include "NR_ServingCellConfigCommon.h"
@@ -86,12 +81,12 @@
 /*I will change the name of the structure for compile purposes--> hope not to undo this process*/
 
 typedef unsigned int uid_nr_t;
-#define NR_UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((NUMBER_OF_NR_UE_MAX/8)/sizeof(unsigned int)) + 1)
+#define NR_UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((MAX_MOBILES_PER_GNB/8)/sizeof(unsigned int)) + 1)
 
-/*typedef struct nr_uid_linear_allocator_s {
+typedef struct nr_uid_linear_allocator_s {
   unsigned int   bitmap[NR_UID_LINEAR_ALLOCATOR_BITMAP_SIZE];
-} nr_uid_allocator_t;*/
-
+} nr_uid_allocator_t;
+    
 
 #define PROTOCOL_NR_RRC_CTXT_UE_FMT                PROTOCOL_CTXT_FMT
 #define PROTOCOL_NR_RRC_CTXT_UE_ARGS(CTXT_Pp)      PROTOCOL_CTXT_ARGS(CTXT_Pp)
@@ -121,7 +116,6 @@ typedef enum UE_STATE_NR_e {
 } NR_UE_STATE_t;
 
 
-//#define NUMBER_OF_NR_UE_MAX MAX_MOBILES_PER_RG
 #define RRM_FREE(p)       if ( (p) != NULL) { free(p) ; p=NULL ; }
 #define RRM_MALLOC(t,n)   (t *) malloc16( sizeof(t) * n )
 #define RRM_CALLOC(t,n)   (t *) malloc16( sizeof(t) * n)
@@ -271,7 +265,14 @@ typedef struct gNB_RRC_UE_s {
   HANDOVER_INFO                     *handover_info;
   NR_MeasResults_t                  *measResults;
 
-  NR_UE_NR_Capability_t             *UE_Capability;
+
+  NR_UE_NR_Capability_t*             UE_Capability_nr;
+  NR_UE_MRDC_Capability_t*           UE_Capability_MRDC;
+
+  NR_CellGroupConfig_t               *secondaryCellGroup;
+  NR_RRCReconfiguration_t            *reconfig;
+  NR_RadioBearerConfig_t             *rb_config;
+
   ImsiMobileIdentity_t               imsi;
 
 #if defined(ENABLE_SECURITY)
@@ -374,24 +375,15 @@ typedef struct {
   uint8_t                                   *ServingCellConfigCommon;
   uint8_t                                   sizeof_servingcellconfigcommon;
 
-  //implicit parameters needed
-  int                                       physCellId;
-  int                                       Ncp; //cyclic prefix for DL
-  int                                       Ncp_UL; //cyclic prefix for UL
-  int                                       p_gNB; //number of tx antenna port
-  int                                       p_rx_gNB; //number of receiving antenna ports
-  uint64_t                                  dl_CarrierFreq; //detected by the UE
-  uint64_t                                  ul_CarrierFreq; //detected by the UE
-
-  //are the only static one (memory has been already allocated)
   NR_BCCH_BCH_Message_t                     mib;
+  int ssb_SubcarrierOffset;                  
+  int pdsch_AntennaPorts;
   NR_BCCH_DL_SCH_Message_t                  *siblock1;
-
   NR_ServingCellConfigCommon_t              *servingcellconfigcommon;
-
-
+  NR_CellGroupConfig_t                      *secondaryCellGroup[MAX_NR_RRC_UE_CONTEXTS];
   NR_SRB_INFO                               SI;
   NR_SRB_INFO                               Srb0;
+  int                                       initial_csi_index[MAX_NR_RRC_UE_CONTEXTS];
 
 } rrc_gNB_carrier_data_t;
 //---------------------------------------------------
@@ -401,19 +393,15 @@ typedef struct {
 //---NR---(completely change)---------------------
 typedef struct gNB_RRC_INST_s {
 
+  int                                                 module_id;
   eth_params_t                                        eth_params_s;
-  rrc_gNB_carrier_data_t                              carrier[MAX_NUM_CCs];
-  uid_allocator_t                                     uid_allocator; // for rrc_ue_head
+  rrc_gNB_carrier_data_t                              carrier;
+  nr_uid_allocator_t                                     uid_allocator; // for rrc_ue_head
   RB_HEAD(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s)     rrc_ue_head; // ue_context tree key search by rnti
-
-  uint8_t                                             Nb_ue;
-
+  int                                                 Nb_ue;
   hash_table_t                                        *initial_id2_s1ap_ids; // key is    content is rrc_ue_s1ap_ids_t
   hash_table_t                                        *s1ap_id2_s1ap_ids   ; // key is    content is rrc_ue_s1ap_ids_t
 
-  //RRC configuration
-  gNB_RrcConfigurationReq                             configuration;//rrc_messages_types.h
-
   // other PLMN parameters
   /// Mobile country code
   int mcc;
diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h
index ce90ee46fbe..5770b80595e 100644
--- a/openair2/RRC/NR/nr_rrc_proto.h
+++ b/openair2/RRC/NR/nr_rrc_proto.h
@@ -33,6 +33,12 @@
 
 #include "RRC/NR/nr_rrc_defs.h"
 #include "flexran_agent_extern.h"
+#include "NR_RRCReconfiguration.h"
+#include "NR_UE-NR-Capability.h"
+#include "NR_UE-CapabilityRAT-ContainerList.h"
+#include "LTE_UE-CapabilityRAT-ContainerList.h"
+#include "NR_CG-Config.h"
+#include "NR_CG-ConfigInfo.h"
 
 int rrc_init_nr_global_param(void);
 
@@ -57,6 +63,35 @@ void rrc_gNB_generate_SgNBAdditionRequestAcknowledge(
      rrc_gNB_ue_context_t   *const ue_context_pP
      );
 
+struct rrc_gNB_ue_context_s *rrc_gNB_allocate_new_UE_context(gNB_RRC_INST *rrc_instance_pP);
+
+void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc,LTE_UE_CapabilityRAT_ContainerList_t *UE_CapabilityRAT_ContainerList);
+
+void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_p);
+
+void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellconfigcommon,
+				     NR_CellGroupConfig_t *secondaryCellGroup,
+				     int scg_id,
+				     int servCellIndex,
+				     int n_physical_antenna_ports,
+				     int initial_csi_index);
+
+void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon,
+			   NR_RRCReconfiguration_IEs_t *reconfig,
+			   NR_CellGroupConfig_t *secondaryCellGroup,
+			   int n_physical_antenna_ports,
+			   int initial_csi_index);
+
+void fill_default_rbconfig(NR_RadioBearerConfig_t *rbconfig);
+
+int generate_CG_Config(gNB_RRC_INST *rrc, 
+		       NR_CG_Config_t *cg_Config,
+		       NR_RRCReconfiguration_t *reconfig,
+		       NR_RadioBearerConfig_t *rbconfig);
+
+int parse_CG_ConfigInfo(gNB_RRC_INST *rrc, NR_CG_ConfigInfo_t *CG_ConfigInfo);
+
+
 
 /**\brief RRC eNB task.
    \param void *args_p Pointer on arguments to start the task. */
diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c
index 586fcd34926..fba66105541 100644
--- a/openair2/RRC/NR/rrc_gNB.c
+++ b/openair2/RRC/NR/rrc_gNB.c
@@ -49,6 +49,8 @@
 #include "NR_DL-DCCH-Message.h"
 #include "NR_CellGroupConfig.h"
 #include "NR_MeasResults.h"
+#include "LTE_UECapabilityInformation.h"
+#include "LTE_UL-DCCH-Message.h"
 
 #include "rlc.h"
 #include "rrc_eNB_UE_context.h"
@@ -74,31 +76,17 @@
 #include "pdcp.h"
 #include "gtpv1u_eNB_task.h"
 
-#include "intertask_interface.h"
-
-
-#if ENABLE_RAL
-  #include "rrc_eNB_ral.h"
-#endif
 
+#include "intertask_interface.h"
 #include "SIMULATION/TOOLS/sim.h" // for taus
 
+#include "executables/softmodem-common.h"
+
 //#define XER_PRINT
 
 
 extern RAN_CONTEXT_t RC;
 
-#ifdef PHY_EMUL
-  extern EMULATION_VARS              *Emul_vars;
-#endif
-//extern eNB_MAC_INST                *eNB_mac_inst;
-//extern UE_MAC_INST                 *UE_mac_inst;
-#ifdef BIGPHYSAREA
-  extern void                        *bigphys_malloc(int);
-#endif
-
-extern uint16_t                     two_tier_hexagonal_cellIds[7];
-
 mui_t                               rrc_gNB_mui = 0;
 
 ///---------------------------------------------------------------------------------------------------------------///
@@ -107,12 +95,11 @@ mui_t                               rrc_gNB_mui = 0;
 void openair_nr_rrc_on(const protocol_ctxt_t *const ctxt_pP) {
   LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_FMT" gNB:OPENAIR NR RRC IN....\n",PROTOCOL_NR_RRC_CTXT_ARGS(ctxt_pP));
 
-  for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
-    rrc_config_nr_buffer (&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].SI, BCCH, 1);
-    RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].SI.Active = 1;
-    rrc_config_nr_buffer (&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].Srb0, CCCH, 1);
-    RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Active = 1;
-  }
+  rrc_config_nr_buffer (&RC.nrrrc[ctxt_pP->module_id]->carrier.SI, BCCH, 1);
+  RC.nrrrc[ctxt_pP->module_id]->carrier.SI.Active = 1;
+  rrc_config_nr_buffer (&RC.nrrrc[ctxt_pP->module_id]->carrier.Srb0, CCCH, 1);
+  RC.nrrrc[ctxt_pP->module_id]->carrier.Srb0.Active = 1;
+
 }
 
 ///---------------------------------------------------------------------------------------------------------------///
@@ -185,108 +172,181 @@ void rrc_gNB_generate_SgNBAdditionRequestAcknowledge(
                        ue_context_pP->ue_context.primaryCC_id,
                        physicalCellGroupConfig,
                        physicalcellgroup_config);
-  do_SpCellConfig(ctxt_pP->module_id,
-                  ue_context_pP->ue_context.primaryCC_id,
+
+  do_SpCellConfig(RC.nrrrc[ctxt_pP->module_id],
                   spCellConfig);
 }
 
 ///---------------------------------------------------------------------------------------------------------------///
 ///---------------------------------------------------------------------------------------------------------------///
 
-static void init_NR_SI(const protocol_ctxt_t *const ctxt_pP,
-                       const int              CC_id,
-                       gNB_RrcConfigurationReq *configuration
+static void init_NR_SI(gNB_RRC_INST *rrc) {
+
 
-                      ) {
-  //int                                 i;
   LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__);
-  // copy basic parameters
-  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].physCellId      = configuration->Nid_cell[CC_id];
-  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].p_gNB           = configuration->nb_antenna_ports[CC_id];
-  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].Ncp             = configuration->DL_prefix_type[CC_id];
-  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].Ncp_UL          = configuration->UL_prefix_type[CC_id];
-  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq  = configuration->downlink_frequency[CC_id];
-  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq  = configuration->downlink_frequency[CC_id]+ configuration->uplink_frequency_offset[CC_id];
-  ///MIB
-  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_MIB      = 0;
-  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].MIB             = (uint8_t *) malloc16(4);
-  RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_MIB      = do_MIB_NR(&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id],0,
-  configuration->MIB_ssb_SubcarrierOffset[CC_id],
-  configuration->pdcch_ConfigSIB1[CC_id],
-  configuration->MIB_subCarrierSpacingCommon[CC_id],
-  configuration->MIB_dmrs_TypeA_Position[CC_id]
-                                                                          );
-  do_SERVINGCELLCONFIGCOMMON(ctxt_pP->module_id,
-                             CC_id,
-                             configuration,
-                             1
-                            );
+
+
+
+  rrc->carrier.MIB             = (uint8_t*) malloc16(4);
+  rrc->carrier.sizeof_MIB      = do_MIB_NR(rrc,0);
+
+  
   LOG_I(NR_RRC,"Done init_NR_SI\n");
-  rrc_mac_config_req_gNB(ctxt_pP->module_id,
-                         CC_id,
-                         RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].physCellId,
-                         RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].p_gNB,
-                         configuration->nr_band[CC_id],
-                         configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id],
-                         configuration->ServingCellConfigCommon_ssb_periodicityServingCell[CC_id],
-                         RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq,
-                         configuration->N_RB_DL[CC_id],
-                         (NR_BCCH_BCH_Message_t *)&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].mib,
-                         (NR_ServingCellConfigCommon_t *)&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].servingcellconfigcommon
-                        );
+
+
+  rrc_mac_config_req_gNB(rrc->module_id,
+			 rrc->carrier.ssb_SubcarrierOffset,
+                         rrc->carrier.pdsch_AntennaPorts,
+                         (NR_ServingCellConfigCommon_t *)rrc->carrier.servingcellconfigcommon,
+			 0,
+			 0,
+			 (NR_CellGroupConfig_t *)NULL
+                         );
+
+
+  if (get_softmodem_params()->phy_test > 0) {
+    // This is for phytest only, emulate first X2 message if uecap.raw file is present
+    FILE *fd;
+
+    fd = fopen("uecap.raw","r");
+    if (fd != NULL) {
+      char buffer[4096];
+      int msg_len=fread(buffer,1,4096,fd);
+      LOG_I(RRC,"Read in %d bytes for uecap\n",msg_len);
+      LTE_UL_DCCH_Message_t *LTE_UL_DCCH_Message;
+
+      asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
+						      &asn_DEF_LTE_UL_DCCH_Message,
+						      (void **)&LTE_UL_DCCH_Message,
+						      (uint8_t *)buffer,
+						      msg_len); 
+      
+      if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
+        AssertFatal(1==0,"NR_UL_DCCH_MESSAGE decode error\n");
+	// free the memory
+	SEQUENCE_free( &asn_DEF_LTE_UL_DCCH_Message, LTE_UL_DCCH_Message, 1 );
+	return;
+      }      
+      fclose(fd);
+      xer_fprint(stdout,&asn_DEF_LTE_UL_DCCH_Message, LTE_UL_DCCH_Message);
+      // recreate enough of X2 EN-DC Container
+      AssertFatal(LTE_UL_DCCH_Message->message.choice.c1.present == LTE_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation,
+		  "ueCapabilityInformation not present\n");
+      NR_CG_ConfigInfo_t *CG_ConfigInfo = calloc(1,sizeof(*CG_ConfigInfo));
+      CG_ConfigInfo->criticalExtensions.present = NR_CG_ConfigInfo__criticalExtensions_PR_c1;
+      CG_ConfigInfo->criticalExtensions.choice.c1 = calloc(1,sizeof(*CG_ConfigInfo->criticalExtensions.choice.c1));
+      CG_ConfigInfo->criticalExtensions.choice.c1->present = NR_CG_ConfigInfo__criticalExtensions__c1_PR_cg_ConfigInfo;
+      CG_ConfigInfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo = calloc(1,sizeof(*CG_ConfigInfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo));
+      NR_CG_ConfigInfo_IEs_t *cg_ConfigInfo = CG_ConfigInfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo;
+      cg_ConfigInfo->ue_CapabilityInfo = calloc(1,sizeof(*cg_ConfigInfo->ue_CapabilityInfo));
+      asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UE_CapabilityRAT_ContainerList,NULL,(void*)&LTE_UL_DCCH_Message->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList,buffer,4096);
+      AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n",
+		   enc_rval.failed_type->name, enc_rval.encoded);
+      OCTET_STRING_fromBuf(cg_ConfigInfo->ue_CapabilityInfo,
+			   (const char *)buffer,
+			   (enc_rval.encoded+7)>>3); 
+      parse_CG_ConfigInfo(rrc,CG_ConfigInfo);      
+    }
+    else {
+      struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_allocate_new_UE_context(rrc);
+      
+      LOG_I(NR_RRC,"Adding new user (%p)\n",ue_context_p);    
+      rrc_add_nsa_user(rrc,ue_context_p);
+    } 
+  }
 }
 
 
 char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigurationReq *configuration) {
   protocol_ctxt_t      ctxt;
-  int                  CC_id;
+
+  gNB_RRC_INST         *rrc=RC.nrrrc[gnb_mod_idP];
+
   PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, gnb_mod_idP, GNB_FLAG_YES, NOT_A_RNTI, 0, 0,gnb_mod_idP);
+
   LOG_I(NR_RRC,
         PROTOCOL_NR_RRC_CTXT_FMT" Init...\n",
         PROTOCOL_NR_RRC_CTXT_ARGS(&ctxt));
 #if OCP_FRAMEWORK
 
-  while ( RC.nrrrc[gnb_mod_idP] == NULL ) {
+  while (rrc == NULL ) {
     LOG_E(NR_RRC, "RC.nrrrc not yet initialized, waiting 1 second\n");
     sleep(1);
   }
-
-#endif
-  AssertFatal(RC.nrrrc[gnb_mod_idP] != NULL, "RC.nrrrc not initialized!");
+#endif 
+  AssertFatal(rrc != NULL, "RC.nrrrc not initialized!");
   AssertFatal(NUMBER_OF_UE_MAX < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow");
   AssertFatal(configuration!=NULL,"configuration input is null\n");
-
-  RC.nrrrc[ctxt.module_id]->Nb_ue = 0;
-
-  for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
-    RC.nrrrc[ctxt.module_id]->carrier[CC_id].Srb0.Active = 0;
-  }
-
-  uid_linear_allocator_init(&RC.nrrrc[ctxt.module_id]->uid_allocator);
-  RB_INIT(&RC.nrrrc[ctxt.module_id]->rrc_ue_head);
-  RC.nrrrc[ctxt.module_id]->initial_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
-  RC.nrrrc[ctxt.module_id]->s1ap_id2_s1ap_ids    = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
-  memcpy(&RC.nrrrc[ctxt.module_id]->configuration,configuration,sizeof(gNB_RrcConfigurationReq));
+  rrc->module_id = gnb_mod_idP;
+  rrc->Nb_ue = 0;
+  
+  rrc->carrier.Srb0.Active = 0;
+
+  nr_uid_linear_allocator_init(&rrc->uid_allocator);
+  RB_INIT(&rrc->rrc_ue_head);
+  rrc->initial_id2_s1ap_ids = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
+  rrc->s1ap_id2_s1ap_ids    = hashtable_create (NUMBER_OF_UE_MAX * 2, NULL, NULL);
+  rrc->carrier.servingcellconfigcommon = configuration->scc;
+  rrc->carrier.ssb_SubcarrierOffset = configuration->ssb_SubcarrierOffset;
+  rrc->carrier.pdsch_AntennaPorts = configuration->pdsch_AntennaPorts;
   /// System Information INIT
   LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_FMT" Checking release \n",PROTOCOL_NR_RRC_CTXT_ARGS(&ctxt));
 
-  for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
-    init_NR_SI(&ctxt,
-               CC_id,
-               configuration
-              );
-  }//END for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++)
-
+  init_NR_SI(rrc);
   rrc_init_nr_global_param();
   openair_nr_rrc_on(&ctxt);
   return 0;
 }//END openair_rrc_gNB_configuration
 
 
-///---------------------------------------------------------------------------------------------------------------///
-///---------------------------------------------------------------------------------------------------------------///
+void rrc_gNB_process_AdditionRequestInformation(const module_id_t gnb_mod_idP, x2ap_ENDC_sgnb_addition_req_t *m) {
 
 
+    LTE_UL_DCCH_Message_t *LTE_UL_DCCH_Message = NULL; 
+
+    asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
+						      &asn_DEF_LTE_UL_DCCH_Message,
+						      (void **)&LTE_UL_DCCH_Message,
+						      (uint8_t *)m->rrc_buffer,
+						      (int) m->rrc_buffer_size);//m->rrc_buffer_size);
+
+/*    asn_dec_rval_t dec_rval = uper_decode( NULL,
+						      &asn_DEF_LTE_UL_DCCH_Message,
+						      (void **)&LTE_UL_DCCH_Message,
+						      (uint8_t *)m->rrc_buffer,
+						      (int) m->rrc_buffer_size, 0, 0);//m->rrc_buffer_size);
+*/
+    gNB_RRC_INST         *rrc=RC.nrrrc[gnb_mod_idP];
+
+    if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
+      AssertFatal(1==0,"NR_UL_DCCH_MESSAGE decode error\n");
+	// free the memory
+	SEQUENCE_free( &asn_DEF_LTE_UL_DCCH_Message, LTE_UL_DCCH_Message, 1 );
+	return;
+    }
+    xer_fprint(stdout,&asn_DEF_LTE_UL_DCCH_Message, LTE_UL_DCCH_Message);
+    // recreate enough of X2 EN-DC Container
+    AssertFatal(LTE_UL_DCCH_Message->message.choice.c1.present == LTE_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation,
+		  "ueCapabilityInformation not present\n");
+    NR_CG_ConfigInfo_t *CG_ConfigInfo = calloc(1,sizeof(*CG_ConfigInfo));
+    CG_ConfigInfo->criticalExtensions.present = NR_CG_ConfigInfo__criticalExtensions_PR_c1;
+    CG_ConfigInfo->criticalExtensions.choice.c1 = calloc(1,sizeof(*CG_ConfigInfo->criticalExtensions.choice.c1));
+    CG_ConfigInfo->criticalExtensions.choice.c1->present = NR_CG_ConfigInfo__criticalExtensions__c1_PR_cg_ConfigInfo;
+    CG_ConfigInfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo = calloc(1,sizeof(*CG_ConfigInfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo));
+    NR_CG_ConfigInfo_IEs_t *cg_ConfigInfo = CG_ConfigInfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo;
+    cg_ConfigInfo->ue_CapabilityInfo = calloc(1,sizeof(*cg_ConfigInfo->ue_CapabilityInfo));
+    asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UE_CapabilityRAT_ContainerList,NULL,(void*)&LTE_UL_DCCH_Message->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList,m->rrc_buffer,m->rrc_buffer_size);
+    AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n",
+		   enc_rval.failed_type->name, enc_rval.encoded);
+    OCTET_STRING_fromBuf(cg_ConfigInfo->ue_CapabilityInfo,
+			   (const char *)m->rrc_buffer,
+			   (enc_rval.encoded+7)>>3);
+    parse_CG_ConfigInfo(rrc,CG_ConfigInfo);
+   
+}
+
+///---------------------------------------------------------------------------------------------------------------///
+///---------------------------------------------------------------------------------------------------------------///
 void *rrc_gnb_task(void *args_p) {
   MessageDef                         *msg_p;
   const char                         *msg_name_p;
@@ -380,6 +440,17 @@ void *rrc_gnb_task(void *args_p) {
         openair_rrc_gNB_configuration(GNB_INSTANCE_TO_MODULE_ID(instance), &NRRRC_CONFIGURATION_REQ(msg_p));
         break;
 
+        /* Messages from X2AP */
+      case X2AP_ENDC_SGNB_ADDITION_REQ:
+    	LOG_I(NR_RRC, "Received ENDC sgNB addition request from X2AP \n");
+    	rrc_gNB_process_AdditionRequestInformation(GNB_INSTANCE_TO_MODULE_ID(instance), &X2AP_ENDC_SGNB_ADDITION_REQ(msg_p));
+    	break;
+
+      case X2AP_ENDC_SGNB_RECONF_COMPLETE:
+    	  LOG_I(NR_RRC, "Handling of reconfiguration complete message at RRC gNB is pending \n");
+    	  break;
+
+
       default:
         LOG_E(NR_RRC, "[gNB %d] Received unexpected message %s\n", instance, msg_name_p);
         break;
diff --git a/openair2/RRC/NR_UE/main_ue.c b/openair2/RRC/NR_UE/main_ue.c
index 69290400348..07409c60261 100644
--- a/openair2/RRC/NR_UE/main_ue.c
+++ b/openair2/RRC/NR_UE/main_ue.c
@@ -34,11 +34,8 @@
 #include "rrc_proto.h"
 #include "common/utils/LOG/log.h"
 
-int nr_l3_init_ue(void){
-    LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n");
-
-    openair_rrc_top_init_ue_nr();
-
-    return 0;
+NR_UE_RRC_INST_t* nr_l3_init_ue(char* rrc_config_path){
+    //LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n");
 
+    return openair_rrc_top_init_ue_nr(rrc_config_path); 
 }
diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c
index 7db6be499e6..87e899845e0 100755
--- a/openair2/RRC/NR_UE/rrc_UE.c
+++ b/openair2/RRC/NR_UE/rrc_UE.c
@@ -44,7 +44,7 @@
 #include "rrc_vars.h"
 #include "mac_proto.h"
 
-
+#include "executables/softmodem-common.h"
 
 
 // from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded)
@@ -80,11 +80,19 @@ int8_t nr_rrc_ue_decode_secondary_cellgroup_config(
         SEQUENCE_free(&asn_DEF_NR_CellGroupConfig, (void *)cell_group_config, 0);
     }
 
-    //nr_rrc_mac_config_req_ue( module_id_t module_id, int CC_id, uint8_t gNB_index, NR_MIB_t *mibP, NR_MAC_CellGroupConfig_t *mac_cell_group_configP, NR_PhysicalCellGroupConfig_t *phy_cell_group_configP, NR_SpCellConfig_t *spcell_configP );
+    //nr_rrc_mac_config_req_ue( 0,0,0,NULL, cell_group_config->mac_CellGroupConfig, cell_group_config->physicalCellGroupConfig, cell_group_config->spCellConfig );
 
     return 0;
 }
 
+int8_t nr_rrc_ue_process_RadioBearerConfig(NR_RadioBearerConfig_t *RadioBearerConfig){
+
+
+  xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void*)RadioBearerConfig);
+  // Configure PDCP
+
+  return 0;
+}
 
 // from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (decoded)
 // RRCReconfiguration
@@ -96,7 +104,7 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(NR_RRCReconfiguration_t *rrcReconfig
                 if(NR_UE_rrc_inst->radio_bearer_config == NULL){
                     NR_UE_rrc_inst->radio_bearer_config = rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->radioBearerConfig;                
                 }else{
-                    nr_rrc_ue_process_radio_bearer_config(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->radioBearerConfig);
+                    nr_rrc_ue_process_RadioBearerConfig(rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->radioBearerConfig);
                 }
             }
 
@@ -108,14 +116,17 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(NR_RRCReconfiguration_t *rrcReconfig
                             (uint8_t *)rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup->buf,
                             rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration->secondaryCellGroup->size, 0, 0); 
 
+		xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)cellGroupConfig);
+
                 if(NR_UE_rrc_inst->cell_group_config == NULL){
                     //  first time receive the configuration, just use the memory allocated from uper_decoder. TODO this is not good implementation, need to maintain RRC_INST own structure every time.
                     NR_UE_rrc_inst->cell_group_config = cellGroupConfig;
                     nr_rrc_ue_process_scg_config(cellGroupConfig);
                 }else{
                     //  after first time, update it and free the memory after.
+                    SEQUENCE_free(&asn_DEF_NR_CellGroupConfig, (void *)NR_UE_rrc_inst->cell_group_config, 0);
+                    NR_UE_rrc_inst->cell_group_config = cellGroupConfig;
                     nr_rrc_ue_process_scg_config(cellGroupConfig);
-                    SEQUENCE_free(&asn_DEF_NR_CellGroupConfig, (void *)cellGroupConfig, 0);
                 }
                 
             }
@@ -148,6 +159,8 @@ int8_t nr_rrc_ue_process_rrcReconfiguration(NR_RRCReconfiguration_t *rrcReconfig
     return 0;
 }
 
+
+
 int8_t nr_rrc_ue_process_meas_config(NR_MeasConfig_t *meas_config){
 
     return 0;
@@ -156,8 +169,7 @@ int8_t nr_rrc_ue_process_meas_config(NR_MeasConfig_t *meas_config){
 int8_t nr_rrc_ue_process_scg_config(NR_CellGroupConfig_t *cell_group_config){
     int i;
     if(NR_UE_rrc_inst->cell_group_config==NULL){
-        //  initial list
-      
+      //  initial list
         if(cell_group_config->spCellConfig != NULL){
             if(cell_group_config->spCellConfig->spCellConfigDedicated != NULL){
                 if(cell_group_config->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList != NULL){
@@ -167,8 +179,6 @@ int8_t nr_rrc_ue_process_scg_config(NR_CellGroupConfig_t *cell_group_config){
                 }
             }
         } 
-       
-
     }else{
         //  maintain list
         if(cell_group_config->spCellConfig != NULL){
@@ -197,13 +207,57 @@ int8_t nr_rrc_ue_process_scg_config(NR_CellGroupConfig_t *cell_group_config){
 
     return 0;
 }
-int8_t nr_rrc_ue_process_radio_bearer_config(NR_RadioBearerConfig_t *radio_bearer_config){
 
-    return 0;
-}
 
 
-int8_t openair_rrc_top_init_ue_nr(void){
+
+void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, void *message,int msg_len) {
+
+  switch (nsa_message_type) {
+    case nr_SecondaryCellGroupConfig_r15:
+      {
+	NR_RRCReconfiguration_t *RRCReconfiguration=NULL;
+	asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
+							&asn_DEF_NR_RRCReconfiguration,
+							(void **)&RRCReconfiguration,
+							(uint8_t *)message,
+							msg_len); 
+	
+	if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
+	  LOG_E(RRC,"NR_RRCReconfiguration decode error\n");
+	  // free the memory
+	  SEQUENCE_free( &asn_DEF_NR_RRCReconfiguration, RRCReconfiguration, 1 );
+	  return;
+	}      
+	nr_rrc_ue_process_rrcReconfiguration(RRCReconfiguration);
+      }
+      break;
+    case nr_RadioBearerConfigX_r15:
+      {
+	NR_RadioBearerConfig_t *RadioBearerConfig=NULL;
+	asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
+							&asn_DEF_NR_RadioBearerConfig,
+							(void **)&RadioBearerConfig,
+							(uint8_t *)message,
+							msg_len); 
+	
+	if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
+	  LOG_E(RRC,"NR_RadioBearerConfig decode error\n");
+	  // free the memory
+	  SEQUENCE_free( &asn_DEF_NR_RadioBearerConfig, RadioBearerConfig, 1 );
+	  return;
+	}      
+	nr_rrc_ue_process_RadioBearerConfig(RadioBearerConfig);
+      }
+      break;
+    default:
+      AssertFatal(1==0,"Unknown message %d\n",nsa_message_type);
+      break;
+  }
+
+}
+
+NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* rrc_config_path){
 
     if(NB_NR_UE_INST > 0){
         NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)malloc(NB_NR_UE_INST * sizeof(NR_UE_RRC_INST_t));
@@ -264,11 +318,44 @@ int8_t openair_rrc_top_init_ue_nr(void){
         RRC_LIST_INIT(NR_UE_rrc_inst->CSI_SSB_ResourceSet_list, NR_maxNrofCSI_SSB_ResourceSets);
         RRC_LIST_INIT(NR_UE_rrc_inst->CSI_ResourceConfig_list, NR_maxNrofCSI_ResourceConfigurations);
         RRC_LIST_INIT(NR_UE_rrc_inst->CSI_ReportConfig_list, NR_maxNrofCSI_ReportConfigurations);
+
+	if (get_softmodem_params()->phy_test==1) {
+	  // read in files for RRCReconfiguration and RBconfig
+	  FILE *fd;
+	  char filename[1024];
+	  if (rrc_config_path)
+	    sprintf(filename,"%s/reconfig.raw",rrc_config_path);
+	  else
+	    sprintf(filename,"reconfig.raw");
+	  fd = fopen(filename,"r");
+          char buffer[1024];
+	  AssertFatal(fd,
+	              "cannot read file %s: errno %d, %s\n",
+	              filename,
+	              errno,
+	              strerror(errno));
+	  int msg_len=fread(buffer,1,1024,fd);
+	  fclose(fd);
+	  process_nsa_message(NR_UE_rrc_inst, nr_SecondaryCellGroupConfig_r15, buffer,msg_len);
+	  if (rrc_config_path)
+	    sprintf(filename,"%s/rbconfig.raw",rrc_config_path);
+	  else
+	    sprintf(filename,"rbconfig.raw");
+	  fd = fopen(filename,"r");
+	  AssertFatal(fd,
+	              "cannot read file %s: errno %d, %s\n",
+	              filename,
+	              errno,
+	              strerror(errno));
+	  msg_len=fread(buffer,1,1024,fd);
+	  fclose(fd);
+	  process_nsa_message(NR_UE_rrc_inst, nr_RadioBearerConfigX_r15, buffer,msg_len); 
+	}
     }else{
         NR_UE_rrc_inst = NULL;
     }
 
-    return 0;
+    return NR_UE_rrc_inst;
 }
 
 
@@ -339,7 +426,7 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message(
       //    (void *)&bcch_message->message.choice.mib,
       //    sizeof(NR_MIB_t) );
       
-      nr_rrc_mac_config_req_ue( 0, 0, 0, mib, NULL, NULL, NULL);
+      nr_rrc_mac_config_req_ue( 0, 0, 0, mib, NULL);
     }
     
     return 0;
diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h
index e2b22ef243e..cb1207757dc 100644
--- a/openair2/RRC/NR_UE/rrc_defs.h
+++ b/openair2/RRC/NR_UE/rrc_defs.h
@@ -58,12 +58,17 @@
 
 typedef uint32_t channel_t;
 
+typedef enum {
+  nr_SecondaryCellGroupConfig_r15=0,
+  nr_RadioBearerConfigX_r15=1
+} nsa_message_t;
+
 typedef struct NR_UE_RRC_INST_s {
 
     NR_MeasConfig_t        *meas_config;
     NR_CellGroupConfig_t   *cell_group_config;
     NR_RadioBearerConfig_t *radio_bearer_config;
-
+  
     NR_MIB_t *mib;
   
     //  lists
diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h
index 111a9d2dd10..6e0d0a10dea 100644
--- a/openair2/RRC/NR_UE/rrc_proto.h
+++ b/openair2/RRC/NR_UE/rrc_proto.h
@@ -43,14 +43,14 @@
 //  main_rrc.c
 //
 /**\brief Layer 3 initialization*/
-int nr_l3_init_ue(void);
+NR_UE_RRC_INST_t* nr_l3_init_ue(char*);
 
 //
 //  UE_rrc.c
 //
 
 /**\brief Initial the top level RRC structure instance*/
-int8_t openair_rrc_top_init_ue_nr(void);
+NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char*);
 
 
 
diff --git a/openair2/X2AP/x2ap_eNB.c b/openair2/X2AP/x2ap_eNB.c
index b7ccb07461f..b297c96e569 100644
--- a/openair2/X2AP/x2ap_eNB.c
+++ b/openair2/X2AP/x2ap_eNB.c
@@ -101,7 +101,6 @@ void x2ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa
   x2ap_eNB_instance_t *instance_p;
   x2ap_eNB_data_t *x2ap_enb_data_p;
   DevAssert(sctp_new_association_resp != NULL);
-  printf("x2ap_eNB_handle_sctp_association_resp at 1\n");
   dump_trees();
   instance_p = x2ap_eNB_get_instance(instance);
   DevAssert(instance_p != NULL);
@@ -129,7 +128,6 @@ void x2ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa
   x2ap_enb_data_p = x2ap_get_eNB(instance_p, -1,
                                  sctp_new_association_resp->ulp_cnx_id);
   DevAssert(x2ap_enb_data_p != NULL);
-  printf("x2ap_eNB_handle_sctp_association_resp at 2\n");
   dump_trees();
 
   if (sctp_new_association_resp->sctp_state != SCTP_STATE_ESTABLISHED) {
@@ -142,17 +140,17 @@ void x2ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa
     return;
   }
 
-  printf("x2ap_eNB_handle_sctp_association_resp at 3\n");
   dump_trees();
   /* Update parameters */
   x2ap_enb_data_p->assoc_id    = sctp_new_association_resp->assoc_id;
   x2ap_enb_data_p->in_streams  = sctp_new_association_resp->in_streams;
   x2ap_enb_data_p->out_streams = sctp_new_association_resp->out_streams;
-  printf("x2ap_eNB_handle_sctp_association_resp at 4\n");
   dump_trees();
   /* Prepare new x2 Setup Request */
-  x2ap_eNB_generate_x2_setup_request(instance_p, x2ap_enb_data_p);
-  //x2ap_eNB_generate_ENDC_x2_setup_request(instance_p, x2ap_enb_data_p);
+  if(instance_p->cell_type == CELL_MACRO_GNB)
+	  x2ap_gNB_generate_ENDC_x2_setup_request(instance_p, x2ap_enb_data_p);
+  else
+	  x2ap_eNB_generate_x2_setup_request(instance_p, x2ap_enb_data_p);
 }
 
 static
@@ -448,6 +446,78 @@ void x2ap_eNB_handle_handover_req_ack(instance_t instance,
   x2ap_eNB_generate_x2_handover_request_ack(instance_p, target, x2ap_handover_req_ack);
 }
 
+static
+void x2ap_eNB_handle_sgNB_add_req(instance_t instance,
+                                  x2ap_ENDC_sgnb_addition_req_t *x2ap_ENDC_sgnb_addition_req)
+{
+  x2ap_id_manager     *id_manager;
+  x2ap_eNB_instance_t *instance_p;
+  x2ap_eNB_data_t     *x2ap_eNB_data;
+  int                 ue_id;
+
+  /* TODO: remove hardcoded value */
+  x2ap_eNB_data = x2ap_is_eNB_id_in_list(3584);
+  DevAssert(x2ap_eNB_data != NULL);
+
+  instance_p = x2ap_eNB_get_instance(instance);
+  DevAssert(instance_p != NULL);
+
+  /* allocate x2ap ID */
+  id_manager = &instance_p->id_manager;
+  ue_id = x2ap_allocate_new_id(id_manager);
+  if (ue_id == -1) {
+    X2AP_ERROR("could not allocate a new X2AP UE ID\n");
+    /* TODO: cancel NSA: send (to be defined) message to RRC */
+    exit(1);
+  }
+  /* id_source is ue_id, id_target is unknown yet */
+  x2ap_set_ids(id_manager, ue_id, x2ap_ENDC_sgnb_addition_req->rnti, ue_id, -1);
+  x2ap_id_set_state(id_manager, ue_id, X2ID_STATE_NSA_PREPARE);
+
+  x2ap_eNB_generate_ENDC_x2_SgNB_addition_request(instance_p, x2ap_eNB_data, ue_id);
+}
+
+static
+void x2ap_gNB_trigger_sgNB_add_req_ack(instance_t instance,
+		x2ap_ENDC_sgnb_addition_req_ACK_t *x2ap_ENDC_sgnb_addition_req_ACK)
+{
+  /* TODO: remove this hack (the goal is to find the correct
+   * eNodeB structure for the other end) - we need a proper way for RRC
+   * and X2AP to identify eNodeBs
+   * RRC knows about mod_id and X2AP knows about eNB_id (eNB_ID in
+   * the configuration file)
+   * as far as I understand.. CROUX
+   */
+
+
+  x2ap_eNB_instance_t *instance_p;
+  x2ap_eNB_data_t     *target;
+  /*int source_assoc_id = x2ap_ENDC_sgnb_addition_req_ACK->source_assoc_id;
+  int                 ue_id;
+  int                 id_source;
+  int                 id_target;*/
+
+  instance_p = x2ap_eNB_get_instance(instance);
+  DevAssert(instance_p != NULL);
+
+  /*target = x2ap_get_eNB(NULL, source_assoc_id, 0);
+  DevAssert(target != NULL);*/
+
+  // rnti is a new information, save it
+
+  /*ue_id     = x2ap_handover_req_ack->x2_id_target;
+  id_source = x2ap_id_get_id_source(&instance_p->id_manager, ue_id);
+  id_target = ue_id;
+  x2ap_set_ids(&instance_p->id_manager, ue_id, x2ap_handover_req_ack->rnti, id_source, id_target);*/
+
+
+  //target = x2ap_get_eNB(NULL, 17, 0);
+  target = x2ap_is_eNB_id_in_list (3585); //Currently hardcoded. Need to extract it differently
+  DevAssert(target != NULL);
+  x2ap_gNB_generate_ENDC_x2_SgNB_addition_request_ACK(instance_p, target, x2ap_ENDC_sgnb_addition_req_ACK, 0);
+}
+
+
 static
 void x2ap_eNB_ue_context_release(instance_t instance,
                                  x2ap_ue_context_release_t *x2ap_ue_context_release)
@@ -513,6 +583,17 @@ void *x2ap_task(void *arg) {
                                                 &X2AP_UE_CONTEXT_RELEASE(received_msg));
         break;
 
+      case X2AP_ENDC_SGNB_ADDITION_REQ:
+        x2ap_eNB_handle_sgNB_add_req(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+                                     &X2AP_ENDC_SGNB_ADDITION_REQ(received_msg));
+        break;
+
+      case X2AP_ENDC_SGNB_ADDITION_REQ_ACK:
+    	  x2ap_gNB_trigger_sgNB_add_req_ack(ITTI_MESSAGE_GET_INSTANCE(received_msg),
+    			  &X2AP_ENDC_SGNB_ADDITION_REQ_ACK(received_msg));
+    	LOG_I(X2AP, "Received elements for X2AP_ENDC_SGNB_ADDITION_REQ_ACK \n");
+    	break;
+
       case SCTP_INIT_MSG_MULTI_CNF:
         x2ap_eNB_handle_sctp_init_msg_multi_cnf(ITTI_MESSAGE_GET_INSTANCE(received_msg),
                                                 &received_msg->ittiMsg.sctp_init_msg_multi_cnf);
@@ -556,7 +637,6 @@ int is_x2ap_enabled(void)
   static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
   if (pthread_mutex_lock(&mutex)) goto mutex_error;
-
   if (config_loaded) {
     if (pthread_mutex_unlock(&mutex)) goto mutex_error;
     return enabled;
@@ -569,13 +649,20 @@ int is_x2ap_enabled(void)
 
   /* TODO: do it per module - we check only first eNB */
   config_get(p, sizeof(p)/sizeof(paramdef_t), "eNBs.[0]");
-  if (enable_x2 != NULL && strcmp(enable_x2, "yes") == 0)
-    enabled = 1;
+  if (enable_x2 != NULL && strcmp(enable_x2, "yes") == 0){
+	  enabled = 1;
+  }
+
+  /*Consider also the case of enabling X2AP for a gNB by parsing a gNB configuration file*/
+
+  config_get(p, sizeof(p)/sizeof(paramdef_t), "gNBs.[0]");
+    if (enable_x2 != NULL && strcmp(enable_x2, "yes") == 0){
+  	  enabled = 1;
+    }
 
   config_loaded = 1;
 
   if (pthread_mutex_unlock(&mutex)) goto mutex_error;
-
   return enabled;
 
 mutex_error:
diff --git a/openair2/X2AP/x2ap_eNB_decoder.c b/openair2/X2AP/x2ap_eNB_decoder.c
index 7b178fb109e..93b82c2765f 100644
--- a/openair2/X2AP/x2ap_eNB_decoder.c
+++ b/openair2/X2AP/x2ap_eNB_decoder.c
@@ -60,8 +60,14 @@ static int x2ap_eNB_decode_initiating_message(X2AP_X2AP_PDU_t *pdu)
       break;
 
     case X2AP_ProcedureCode_id_endcX2Setup:
-      X2AP_INFO("X2AP_ProcedureCode_id_endcX2Setup message!\n");
-      break;
+    	X2AP_INFO("X2AP_ProcedureCode_id_endcX2Setup message!\n");
+    	break;
+    case X2AP_ProcedureCode_id_sgNBAdditionPreparation:
+    	X2AP_INFO("X2AP_ProcedureCode_id_sgNBAdditionPreparation message!\n");
+    break;
+    case X2AP_ProcedureCode_id_sgNBReconfigurationCompletion:
+        	X2AP_INFO("X2AP_ProcedureCode_id_sgNBReconfigurationCompletion message!\n");
+        break;
 
     default:
       X2AP_ERROR("Unknown procedure ID (%d) for initiating message\n",
@@ -93,6 +99,10 @@ static int x2ap_eNB_decode_successful_outcome(X2AP_X2AP_PDU_t *pdu)
     	X2AP_INFO("x2ap_eNB_decode_successfuloutcome_message!\n");
     	break;
 
+    case X2AP_ProcedureCode_id_sgNBAdditionPreparation:
+    	X2AP_INFO("x2ap_eNB_decode_successfuloutcome_message!\n");
+    	break;
+
     default:
       X2AP_ERROR("Unknown procedure ID (%d) for successfull outcome message\n",
                   (int)pdu->choice.successfulOutcome.procedureCode);
@@ -134,9 +144,9 @@ int x2ap_eNB_decode_pdu(X2AP_X2AP_PDU_t *pdu, const uint8_t *const buffer, uint3
                         length,
                         0,
                         0);
-  if (asn1_xer_print) {
+  //if (asn1_xer_print) {
     xer_fprint(stdout, &asn_DEF_X2AP_X2AP_PDU, pdu);
-  }
+  //}
 
   if (dec_ret.code != RC_OK) {
     X2AP_ERROR("Failed to decode pdu\n");
diff --git a/openair2/X2AP/x2ap_eNB_encoder.c b/openair2/X2AP/x2ap_eNB_encoder.c
index 8b1c030d35d..392206e4d73 100644
--- a/openair2/X2AP/x2ap_eNB_encoder.c
+++ b/openair2/X2AP/x2ap_eNB_encoder.c
@@ -44,9 +44,9 @@ int x2ap_eNB_encode_pdu(X2AP_X2AP_PDU_t *pdu, uint8_t **buffer, uint32_t *len)
   DevAssert(buffer != NULL);
   DevAssert(len != NULL);
 
-  if (asn1_xer_print) {
+  //if (asn1_xer_print) {
     xer_fprint(stdout, &asn_DEF_X2AP_X2AP_PDU, (void *)pdu);
-  }
+  //}
 
   encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_X2AP_PDU, 0, pdu, (void **)buffer);
 
diff --git a/openair2/X2AP/x2ap_eNB_generate_messages.c b/openair2/X2AP/x2ap_eNB_generate_messages.c
index e43db6aa8af..47a3475063f 100644
--- a/openair2/X2AP/x2ap_eNB_generate_messages.c
+++ b/openair2/X2AP/x2ap_eNB_generate_messages.c
@@ -39,6 +39,7 @@
 #include "x2ap_ids.h"
 
 #include "x2ap_eNB_itti_messaging.h"
+#include "X2AP_SupportedSULFreqBandItem.h"
 
 #include "msc.h"
 #include "assertions.h"
@@ -1097,7 +1098,6 @@ int x2ap_eNB_generate_senb_addition_request (x2ap_eNB_instance_t *instance_p, x2
   return ret;
 }
 
-//Panos:
 int x2ap_eNB_generate_senb_addition_request_ack (x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p,
                                                x2ap_senb_addition_req_ack_t *x2ap_addition_req_ack)
 {
@@ -1118,8 +1118,6 @@ int x2ap_eNB_generate_senb_addition_request_ack (x2ap_eNB_instance_t *instance_p
   DevAssert(instance_p != NULL);
   DevAssert(x2ap_eNB_data_p != NULL);
 
-  //Panos: The fact that we have separate IDs here is because the ID for a specific UE might be different
-  //between the 2 eNBs?
   //ue_id     = x2ap_addition_req_ack->x2_id_target; //Panos: change name to master_x2...
   //id_source = x2ap_id_get_id_source(&instance_p->id_manager, ue_id);
   //id_target = ue_id;
@@ -1128,7 +1126,6 @@ int x2ap_eNB_generate_senb_addition_request_ack (x2ap_eNB_instance_t *instance_p
   memset(&pdu, 0, sizeof(pdu));
   pdu.present = X2AP_X2AP_PDU_PR_successfulOutcome;
   pdu.choice.successfulOutcome.procedureCode = X2AP_ProcedureCode_id_seNBAdditionPreparation;
-  //Panos: What does the criticality indicate here?
   pdu.choice.successfulOutcome.criticality = X2AP_Criticality_reject;
   pdu.choice.successfulOutcome.value.present = X2AP_SuccessfulOutcome__value_PR_SeNBAdditionRequestAcknowledge;
   out = &pdu.choice.successfulOutcome.value.choice.SeNBAdditionRequestAcknowledge;
@@ -1144,7 +1141,6 @@ int x2ap_eNB_generate_senb_addition_request_ack (x2ap_eNB_instance_t *instance_p
   /* mandatory */
   ie = (X2AP_SeNBAdditionRequestAcknowledge_IEs_t *)calloc(1, sizeof(X2AP_SeNBAdditionRequestAcknowledge_IEs_t));
   ie->id = X2AP_ProtocolIE_ID_id_SeNB_UE_X2AP_ID;
-  //Panos: Why for the X2_HANDOVER_REQ_ACK here the criticality is ignore whereas in the specs it is reject?
   ie->criticality = X2AP_Criticality_reject;
   ie->value.present = X2AP_SeNBAdditionRequestAcknowledge_IEs__value_PR_UE_X2AP_ID_1;
   ie->value.choice.UE_X2AP_ID_1 = 0;
@@ -1230,17 +1226,17 @@ int x2ap_eNB_generate_senb_addition_request_ack (x2ap_eNB_instance_t *instance_p
   return ret;
 }
 
-/*setup request message from an eNB to a gNB*/
-int x2ap_eNB_generate_ENDC_x2_setup_request(
+/*setup request message from a gNB to an eNB*/
+int x2ap_gNB_generate_ENDC_x2_setup_request(
   x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p)
 {
-	printf("In x2ap_eNB_generate_ENDC_x2_setup_request \n");
   X2AP_X2AP_PDU_t                     	 pdu;
   X2AP_ENDCX2SetupRequest_t              *out;
   X2AP_ENDCX2SetupRequest_IEs_t          *ie;
-  X2AP_ENB_ENDCX2SetupReqIEs_t 			 *ie_ENB_ENDC;
+  X2AP_En_gNB_ENDCX2SetupReqIEs_t 			 *ie_GNB_ENDC;
   X2AP_PLMN_Identity_t               	 *plmn;
-  ServedEUTRAcellsENDCX2ManagementList__Member                *servedCellMember;
+  ServedNRcellsENDCX2ManagementList__Member                *servedCellMember;
+  X2AP_SupportedSULFreqBandItem_t *SULFreqBandItem;
 
   uint8_t  *buffer;
   uint32_t  len;
@@ -1262,85 +1258,102 @@ int x2ap_eNB_generate_ENDC_x2_setup_request(
   ie = (X2AP_ENDCX2SetupRequest_IEs_t *)calloc(1, sizeof(X2AP_ENDCX2SetupRequest_IEs_t));
   ie->id = X2AP_ProtocolIE_ID_id_InitiatingNodeType_EndcX2Setup;
   ie->value.present = X2AP_ENDCX2SetupRequest_IEs__value_PR_InitiatingNodeType_EndcX2Setup;
-  ie->value.choice.InitiatingNodeType_EndcX2Setup.present = X2AP_InitiatingNodeType_EndcX2Setup_PR_init_eNB;
+  ie->value.choice.InitiatingNodeType_EndcX2Setup.present = X2AP_InitiatingNodeType_EndcX2Setup_PR_init_en_gNB;
 
-  ie_ENB_ENDC = (X2AP_ENB_ENDCX2SetupReqIEs_t *)calloc(1, sizeof(X2AP_ENB_ENDCX2SetupReqIEs_t));
-  ie_ENB_ENDC->id = X2AP_ProtocolIE_ID_id_GlobalENB_ID;
-  ie_ENB_ENDC->criticality = X2AP_Criticality_reject;
-  ie_ENB_ENDC->value.present = X2AP_ENB_ENDCX2SetupReqIEs__value_PR_GlobalENB_ID;
-  ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.present = X2AP_ENB_ID_PR_macro_eNB_ID;
-  MACRO_ENB_ID_TO_BIT_STRING(instance_p->eNB_id,
-                               &ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.choice.macro_eNB_ID);
-  MCC_MNC_TO_PLMNID(instance_p->mcc, instance_p->mnc, instance_p->mnc_digit_length,
-                      &ie_ENB_ENDC->value.choice.GlobalENB_ID.pLMN_Identity);
+  ie_GNB_ENDC = (X2AP_En_gNB_ENDCX2SetupReqIEs_t *)calloc(1, sizeof(X2AP_En_gNB_ENDCX2SetupReqIEs_t));
+  ie_GNB_ENDC->id = X2AP_ProtocolIE_ID_id_Globalen_gNB_ID;
+  ie_GNB_ENDC->criticality = X2AP_Criticality_reject;
+  ie_GNB_ENDC->value.present = X2AP_En_gNB_ENDCX2SetupReqAckIEs__value_PR_GlobalGNB_ID;
+  ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.present = X2AP_GNB_ID_PR_gNB_ID;
+  INT32_TO_OCTET_STRING(instance_p->eNB_id,
+                               &ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.choice.gNB_ID);
+
+X2AP_INFO("%d -> %02x%02x%02x\n", instance_p->eNB_id,
+		  ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.choice.gNB_ID.buf[0],
+		  ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.choice.gNB_ID.buf[1],
+		  ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.choice.gNB_ID.buf[2]);
 
-  ASN_SEQUENCE_ADD(&ie->value.choice.InitiatingNodeType_EndcX2Setup.choice.init_eNB.list, ie_ENB_ENDC);
+MCC_MNC_TO_PLMNID(instance_p->mcc, instance_p->mnc, instance_p->mnc_digit_length,
+                      &ie_GNB_ENDC->value.choice.GlobalGNB_ID.pLMN_Identity);
 
-  ie_ENB_ENDC = (X2AP_ENB_ENDCX2SetupReqIEs_t *)calloc(1, sizeof(X2AP_ENB_ENDCX2SetupReqIEs_t));
-  ie_ENB_ENDC->id = X2AP_ProtocolIE_ID_id_ServedEUTRAcellsENDCX2ManagementList;
-  ie_ENB_ENDC->criticality = X2AP_Criticality_reject;
-  ie_ENB_ENDC->value.present = X2AP_ENB_ENDCX2SetupReqIEs__value_PR_ServedEUTRAcellsENDCX2ManagementList;
+  ASN_SEQUENCE_ADD(&ie->value.choice.InitiatingNodeType_EndcX2Setup.choice.init_en_gNB.list, ie_GNB_ENDC);
+
+  ie_GNB_ENDC = (X2AP_En_gNB_ENDCX2SetupReqIEs_t *)calloc(1, sizeof(X2AP_En_gNB_ENDCX2SetupReqIEs_t));
+  ie_GNB_ENDC->id = X2AP_ProtocolIE_ID_id_ServedNRcellsENDCX2ManagementList;
+  ie_GNB_ENDC->criticality = X2AP_Criticality_reject;
+  ie_GNB_ENDC->value.present = X2AP_En_gNB_ENDCX2SetupReqIEs__value_PR_ServedNRcellsENDCX2ManagementList;
 
   {
       for (int i = 0; i<instance_p->num_cc; i++){
-        servedCellMember = (ServedEUTRAcellsENDCX2ManagementList__Member *)calloc(1,sizeof(ServedEUTRAcellsENDCX2ManagementList__Member));
+        servedCellMember = (ServedNRcellsENDCX2ManagementList__Member *)calloc(1,sizeof(ServedNRcellsENDCX2ManagementList__Member));
         {
-          servedCellMember->servedEUTRACellInfo.pCI = instance_p->Nid_cell[i];
+          servedCellMember->servedNRCellInfo.nrpCI = instance_p->Nid_cell[i];
 
           MCC_MNC_TO_PLMNID(instance_p->mcc, instance_p->mnc, instance_p->mnc_digit_length,
-                        &servedCellMember->servedEUTRACellInfo.cellId.pLMN_Identity);
-          MACRO_ENB_ID_TO_CELL_IDENTITY(instance_p->eNB_id,0,
-                                     &servedCellMember->servedEUTRACellInfo.cellId.eUTRANcellIdentifier);
+                        &servedCellMember->servedNRCellInfo.nrCellID.pLMN_Identity);
+          NR_CELL_ID_TO_BIT_STRING(instance_p->eNB_id,
+                                     &servedCellMember->servedNRCellInfo.nrCellID.nRcellIdentifier);
+          servedCellMember->servedNRCellInfo.fiveGS_TAC = calloc(1, sizeof(X2AP_FiveGS_TAC_t));
+          if (servedCellMember->servedNRCellInfo.fiveGS_TAC == NULL)
+            exit(1);
+          NR_FIVEGS_TAC_ID_TO_BIT_STRING(instance_p->tac, servedCellMember->servedNRCellInfo.fiveGS_TAC);
+
+          X2AP_INFO("TAC: %d -> %02x%02x%02x\n", instance_p->tac,
+        		  	  servedCellMember->servedNRCellInfo.fiveGS_TAC->buf[0],
+					  servedCellMember->servedNRCellInfo.fiveGS_TAC->buf[1],
+					  servedCellMember->servedNRCellInfo.fiveGS_TAC->buf[2]);
 
-          INT16_TO_OCTET_STRING(instance_p->tac, &servedCellMember->servedEUTRACellInfo.tAC);
           plmn = (X2AP_PLMN_Identity_t *)calloc(1,sizeof(X2AP_PLMN_Identity_t));
           {
             MCC_MNC_TO_PLMNID(instance_p->mcc, instance_p->mnc, instance_p->mnc_digit_length, plmn);
-            ASN_SEQUENCE_ADD(&servedCellMember->servedEUTRACellInfo.broadcastPLMNs.list, plmn);
+            ASN_SEQUENCE_ADD(&servedCellMember->servedNRCellInfo.broadcastPLMNs.list, plmn);
           }
 
-  	if (instance_p->frame_type[i] == FDD) {
-            servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.present = X2AP_EUTRA_Mode_Info_PR_fDD;
-            servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_EARFCN = instance_p->fdd_earfcn_DL[i];
-            servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_EARFCN = instance_p->fdd_earfcn_UL[i];
+  	if (instance_p->frame_type[i] == TDD) {
+            X2AP_FreqBandNrItem_t *freq_band;
+            servedCellMember->servedNRCellInfo.nrModeInfo.present = X2AP_ServedNRCell_Information__nrModeInfo_PR_tdd;
+            servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nRFreqInfo.nRARFCN = 0; //instance_p->tdd_nRARFCN[i];
+            /* addition of Frequency Band List */
+            freq_band = calloc(1, sizeof(X2AP_FreqBandNrItem_t));
+            if (freq_band == NULL)
+               exit(1);
+            freq_band->freqBandIndicatorNr = 1; /* TODO: put correct value */
+
+            SULFreqBandItem = calloc(1, sizeof(X2AP_SupportedSULFreqBandItem_t));
+            SULFreqBandItem->freqBandIndicatorNr=80; /* TODO: put correct value */
+            ASN_SEQUENCE_ADD(&freq_band->supportedSULBandList.list, SULFreqBandItem);
+
+            ASN_SEQUENCE_ADD(&servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nRFreqInfo.freqBandListNr, freq_band);
             switch (instance_p->N_RB_DL[i]) {
-              case 6:
-                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw6;
-                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw6;
-                break;
-              case 15:
-                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw15;
-                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw15;
-                break;
-              case 25:
-                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw25;
-                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw25;
-                break;
-              case 50:
-                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw50;
-                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw50;
-                break;
-              case 75:
-                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw75;
-                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw75;
-                break;
-              case 100:
-                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw100;
-                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw100;
-                break;
-              default:
-                AssertFatal(0,"Failed: Check value for N_RB_DL/N_RB_UL");
-                break;
-            }
-          }
+        	case 50:
+			//This is not correct. Just to be able to test X2 only using an eNB instead of gNB
+                	servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nR_TxBW.nRNRB = X2AP_NRNRB_nrb51;
+			break;
+		case 93 :
+			servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nR_TxBW.nRNRB = X2AP_NRNRB_nrb93;
+			break;
+		case 106:
+			servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nR_TxBW.nRNRB = X2AP_NRNRB_nrb106;
+			break;
+		case 121:
+			servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nR_TxBW.nRNRB = X2AP_NRNRB_nrb121;
+			break;
+		/*More cases to be added */
+		default:
+			AssertFatal(0,"Failed: Check value for N_RB_DL/N_RB_UL");
+			break;
+		}
+	}
           else {
-            AssertFatal(0,"X2Setuprequest not supported for TDD!");
+            AssertFatal(0,"ENDC_X2Setuprequest not supported for FDD!");
           }
+  	/*Don't know where to extract the value of measurementTimingConfiguration from. Set it to 0 for now */
+  	INT8_TO_OCTET_STRING(0, &servedCellMember->servedNRCellInfo.measurementTimingConfiguration);
         }
-        ASN_SEQUENCE_ADD(&ie_ENB_ENDC->value.choice.ServedEUTRAcellsENDCX2ManagementList.list, servedCellMember);
+        ASN_SEQUENCE_ADD(&ie_GNB_ENDC->value.choice.ServedNRcellsENDCX2ManagementList.list, servedCellMember);
       }
     }
-  ASN_SEQUENCE_ADD(&ie->value.choice.InitiatingNodeType_EndcX2Setup.choice.init_eNB.list, ie_ENB_ENDC);
+  ASN_SEQUENCE_ADD(&ie->value.choice.InitiatingNodeType_EndcX2Setup.choice.init_en_gNB.list, ie_GNB_ENDC);
 
 
   ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
@@ -1357,18 +1370,15 @@ int x2ap_eNB_generate_ENDC_x2_setup_request(
   return ret;
 }
 
-
-/*setup request message from an eNB to a gNB*/
-int x2ap_gNB_generate_ENDC_x2_setup_response(
+int x2ap_eNB_generate_ENDC_x2_setup_response(
   x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p)
 {
-	X2AP_INFO("In x2ap_gNB_generate_ENDC_x2_setup_response ()!\n");
   X2AP_X2AP_PDU_t                     	 pdu;
   X2AP_ENDCX2SetupResponse_t              *out;
   X2AP_ENDCX2SetupResponse_IEs_t          *ie;
-  X2AP_En_gNB_ENDCX2SetupReqAckIEs_t 			 *ie_GNB_ENDC;
+  X2AP_ENB_ENDCX2SetupReqAckIEs_t 			 *ie_ENB_ENDC;
   X2AP_PLMN_Identity_t               	 *plmn;
-  ServedNRcellsENDCX2ManagementList__Member                *servedCellMember;
+  ServedEUTRAcellsENDCX2ManagementList__Member                *servedCellMember;
 
   uint8_t  *buffer;
   uint32_t  len;
@@ -1390,121 +1400,85 @@ int x2ap_gNB_generate_ENDC_x2_setup_response(
   ie = (X2AP_ENDCX2SetupResponse_IEs_t *)calloc(1, sizeof(X2AP_ENDCX2SetupResponse_IEs_t));
   ie->id = X2AP_ProtocolIE_ID_id_RespondingNodeType_EndcX2Setup;
   ie->value.present = X2AP_ENDCX2SetupResponse_IEs__value_PR_RespondingNodeType_EndcX2Setup;
-  ie->value.choice.RespondingNodeType_EndcX2Setup.present = X2AP_RespondingNodeType_EndcX2Setup_PR_respond_en_gNB;
-
-  ie_GNB_ENDC = (X2AP_En_gNB_ENDCX2SetupReqAckIEs_t *)calloc(1, sizeof(X2AP_En_gNB_ENDCX2SetupReqAckIEs_t));
-  ie_GNB_ENDC->id = X2AP_ProtocolIE_ID_id_Globalen_gNB_ID;
-  ie_GNB_ENDC->criticality = X2AP_Criticality_reject;
-  ie_GNB_ENDC->value.present = X2AP_En_gNB_ENDCX2SetupReqAckIEs__value_PR_GlobalGNB_ID;
-  ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.present = X2AP_GNB_ID_PR_gNB_ID;
-
-  INT32_TO_OCTET_STRING(instance_p->eNB_id,
-                               &ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.choice.gNB_ID);
-
-  X2AP_INFO("%d -> %02x%02x%02x\n", instance_p->eNB_id,
-		  ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.choice.gNB_ID.buf[0],
-		  ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.choice.gNB_ID.buf[1],
-		  ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.choice.gNB_ID.buf[2]);
+  ie->value.choice.RespondingNodeType_EndcX2Setup.present = X2AP_RespondingNodeType_EndcX2Setup_PR_respond_eNB;
 
+  ie_ENB_ENDC = (X2AP_ENB_ENDCX2SetupReqAckIEs_t *)calloc(1, sizeof(X2AP_ENB_ENDCX2SetupReqAckIEs_t));
+  ie_ENB_ENDC->id = X2AP_ProtocolIE_ID_id_GlobalENB_ID;
+  ie_ENB_ENDC->criticality = X2AP_Criticality_reject;
+  ie_ENB_ENDC->value.present = X2AP_ENB_ENDCX2SetupReqAckIEs__value_PR_GlobalENB_ID;
+  ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.present = X2AP_ENB_ID_PR_macro_eNB_ID;
+  MACRO_ENB_ID_TO_BIT_STRING(instance_p->eNB_id,
+                               &ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.choice.macro_eNB_ID);
   MCC_MNC_TO_PLMNID(instance_p->mcc, instance_p->mnc, instance_p->mnc_digit_length,
-                      &ie_GNB_ENDC->value.choice.GlobalGNB_ID.pLMN_Identity);
+                      &ie_ENB_ENDC->value.choice.GlobalENB_ID.pLMN_Identity);
 
-  ASN_SEQUENCE_ADD(&ie->value.choice.RespondingNodeType_EndcX2Setup.choice.respond_en_gNB.list, ie_GNB_ENDC);
+  ASN_SEQUENCE_ADD(&ie->value.choice.RespondingNodeType_EndcX2Setup.choice.respond_eNB.list, ie_ENB_ENDC);
 
-  ie_GNB_ENDC = (X2AP_En_gNB_ENDCX2SetupReqAckIEs_t *)calloc(1, sizeof(X2AP_En_gNB_ENDCX2SetupReqAckIEs_t));
-  ie_GNB_ENDC->id = X2AP_ProtocolIE_ID_id_ServedNRcellsENDCX2ManagementList;
-  ie_GNB_ENDC->criticality = X2AP_Criticality_reject;
-  ie_GNB_ENDC->value.present = X2AP_En_gNB_ENDCX2SetupReqAckIEs__value_PR_ServedNRcellsENDCX2ManagementList;
+  ie_ENB_ENDC = (X2AP_ENB_ENDCX2SetupReqAckIEs_t *)calloc(1, sizeof(X2AP_ENB_ENDCX2SetupReqAckIEs_t));
+  ie_ENB_ENDC->id = X2AP_ProtocolIE_ID_id_ServedEUTRAcellsENDCX2ManagementList;
+  ie_ENB_ENDC->criticality = X2AP_Criticality_reject;
+  ie_ENB_ENDC->value.present = X2AP_ENB_ENDCX2SetupReqAckIEs__value_PR_ServedEUTRAcellsENDCX2ManagementList;
 
   {
       for (int i = 0; i<instance_p->num_cc; i++){
-        servedCellMember = (ServedNRcellsENDCX2ManagementList__Member *)calloc(1,sizeof(ServedNRcellsENDCX2ManagementList__Member));
+        servedCellMember = (ServedEUTRAcellsENDCX2ManagementList__Member *)calloc(1,sizeof(ServedEUTRAcellsENDCX2ManagementList__Member));
         {
-          servedCellMember->servedNRCellInfo.nrpCI = instance_p->Nid_cell[i];
+          servedCellMember->servedEUTRACellInfo.pCI = instance_p->Nid_cell[i];
 
           MCC_MNC_TO_PLMNID(instance_p->mcc, instance_p->mnc, instance_p->mnc_digit_length,
-                        &servedCellMember->servedNRCellInfo.nrCellID.pLMN_Identity);
-          NR_CELL_ID_TO_BIT_STRING(instance_p->eNB_id,
-                                     &servedCellMember->servedNRCellInfo.nrCellID.nRcellIdentifier);
-          servedCellMember->servedNRCellInfo.fiveGS_TAC = calloc(1, sizeof(X2AP_FiveGS_TAC_t));
-          if (servedCellMember->servedNRCellInfo.fiveGS_TAC == NULL)
-            exit(1);
-          NR_FIVEGS_TAC_ID_TO_BIT_STRING(instance_p->tac, servedCellMember->servedNRCellInfo.fiveGS_TAC);
-
-          X2AP_INFO("TAC: %d -> %02x%02x%02x\n", instance_p->tac,
-        		  	  servedCellMember->servedNRCellInfo.fiveGS_TAC->buf[0],
-					  servedCellMember->servedNRCellInfo.fiveGS_TAC->buf[1],
-					  servedCellMember->servedNRCellInfo.fiveGS_TAC->buf[2]);
+                        &servedCellMember->servedEUTRACellInfo.cellId.pLMN_Identity);
+          MACRO_ENB_ID_TO_CELL_IDENTITY(instance_p->eNB_id,0,
+                                     &servedCellMember->servedEUTRACellInfo.cellId.eUTRANcellIdentifier);
 
+          INT16_TO_OCTET_STRING(instance_p->tac, &servedCellMember->servedEUTRACellInfo.tAC);
           plmn = (X2AP_PLMN_Identity_t *)calloc(1,sizeof(X2AP_PLMN_Identity_t));
           {
             MCC_MNC_TO_PLMNID(instance_p->mcc, instance_p->mnc, instance_p->mnc_digit_length, plmn);
-            ASN_SEQUENCE_ADD(&servedCellMember->servedNRCellInfo.broadcastPLMNs.list, plmn);
+            ASN_SEQUENCE_ADD(&servedCellMember->servedEUTRACellInfo.broadcastPLMNs.list, plmn);
           }
 
-          if (instance_p->frame_type[i] == TDD) { // Panos: Remember to change that to TDD
-                  X2AP_FreqBandNrItem_t *freq_band;
-        	  servedCellMember->servedNRCellInfo.nrModeInfo.present = X2AP_ServedNRCell_Information__nrModeInfo_PR_tdd;
-        	  servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nRFreqInfo.nRARFCN = 0; //instance_p->tdd_nRARFCN[i];
-
-                  /* addition of Frequency Band List */
-                  freq_band = calloc(1, sizeof(X2AP_FreqBandNrItem_t));
-                  if (freq_band == NULL)
-                    exit(1);
-                  freq_band->freqBandIndicatorNr = 1; /* TODO: put correct value */
-                  ASN_SEQUENCE_ADD(&servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nRFreqInfo.freqBandListNr, freq_band);
-
+          if (instance_p->frame_type[i] == FDD) {
+                  servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.present = X2AP_EUTRA_Mode_Info_PR_fDD;
+            servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_EARFCN = instance_p->fdd_earfcn_DL[i];
+            servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_EARFCN = instance_p->fdd_earfcn_UL[i];
         	  switch (instance_p->N_RB_DL[i]) {
-        	  case 50:
-        		  //This is not correct. Just to be able to test X2 only using an eNB instead of gNB
-        		  servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nR_TxBW.nRNRB = X2AP_NRNRB_nrb51;
-        		  break;
-        	  case 93 :
-        		  servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nR_TxBW.nRNRB = X2AP_NRNRB_nrb93;
-        		  break;
-        	  case 106:
-        		  servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nR_TxBW.nRNRB = X2AP_NRNRB_nrb106;
-        		  break;
-        	  case 121:
-        		  servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nR_TxBW.nRNRB = X2AP_NRNRB_nrb121;
-        		  break;
-
-        		  /*More cases to be added */
-
-        	  default:
-        		  AssertFatal(0,"Failed: Check value for N_RB_DL/N_RB_UL");
-        		  break;
-        	  }
-
-        	  instance_p->nr_SCS[i] = 30; // Hardcoded for now. Normally this should originate from the gNB config file
-        	  switch (instance_p->nr_SCS[i]) {
-        	  case 15:
-        		  servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nR_TxBW.nRSCS = X2AP_NRSCS_scs15;
-        		  break;
-        	  case 30:
-        		  servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nR_TxBW.nRSCS = X2AP_NRSCS_scs30;
-        		  break;
-        	  case 60:
-        		  servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nR_TxBW.nRSCS = X2AP_NRSCS_scs60;
-        		  break;
-        	  case 120:
-        		  servedCellMember->servedNRCellInfo.nrModeInfo.choice.tdd.nR_TxBW.nRSCS = X2AP_NRSCS_scs120;
-        		  break;
-        	  default:
-        		  AssertFatal(0,"Failed: Check value for nr_SCS");
-        		  break;
-        	  }
+              case 6:
+                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw6;
+                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw6;
+                break;
+              case 15:
+                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw15;
+                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw15;
+                break;
+              case 25:
+                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw25;
+                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw25;
+                break;
+              case 50:
+                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw50;
+                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw50;
+                break;
+              case 75:
+                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw75;
+                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw75;
+                break;
+              case 100:
+                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.uL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw100;
+                servedCellMember->servedEUTRACellInfo.eUTRA_Mode_Info.choice.fDD.dL_Transmission_Bandwidth = X2AP_Transmission_Bandwidth_bw100;
+                break;
+              default:
+                AssertFatal(0,"Failed: Check value for N_RB_DL/N_RB_UL");
+                break;
+            }
           }
           else {
-        	  AssertFatal(0,"nr_X2Setupresponse not supported for FDD!");
+        	  AssertFatal(0,"X2Setupresponse not supported for TDD!");
           }
-          /*Don't know where to extract the value of measurementTimingConfiguration from. Set it to 0 for now */
-          INT8_TO_OCTET_STRING(0, &servedCellMember->servedNRCellInfo.measurementTimingConfiguration);
         }
-        ASN_SEQUENCE_ADD(&ie_GNB_ENDC->value.choice.ServedNRcellsENDCX2ManagementList.list, servedCellMember);
+        ASN_SEQUENCE_ADD(&ie_ENB_ENDC->value.choice.ServedEUTRAcellsENDCX2ManagementList.list, servedCellMember);
       }
     }
-  ASN_SEQUENCE_ADD(&ie->value.choice.RespondingNodeType_EndcX2Setup.choice.respond_en_gNB.list, ie_GNB_ENDC);
+  ASN_SEQUENCE_ADD(&ie->value.choice.RespondingNodeType_EndcX2Setup.choice.respond_eNB.list, ie_ENB_ENDC);
 
 
   ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
@@ -1521,3 +1495,360 @@ int x2ap_gNB_generate_ENDC_x2_setup_response(
   return ret;
 }
 
+int x2ap_eNB_generate_ENDC_x2_SgNB_addition_request(
+  x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p, int ue_id)
+{
+	X2AP_X2AP_PDU_t                     	 pdu;
+	X2AP_SgNBAdditionRequest_t               *out;
+	X2AP_SgNBAdditionRequest_IEs_t           *ie;
+	X2AP_E_RABs_ToBeAdded_SgNBAddReq_ItemIEs_t 		*e_RABS_ToBeAdded_SgNBAddReq_ItemIEs;
+	X2AP_E_RABs_ToBeAdded_SgNBAddReq_Item_t         *e_RABS_ToBeAdded_SgNBAddReq_Item;
+
+	uint8_t  *buffer;
+	uint32_t  len;
+	int       ret = 0;
+
+	// Currently hardcoded (dummy) values filling the fields of SgNB_addition_request message. To be substituted
+	// with values coming from RRC.
+	uint16_t nRencryptionAlgorithms = 0;
+	uint16_t nRintegrityProtectionAlgorithms = 0;
+	uint8_t  SgNBSecurityKey[32] = { 0 };
+	int uEaggregateMaximumBitRateDownlink = 100000000;
+	int uEaggregateMaximumBitRateUplink = 100000000;
+	int e_rabs_tobeadded = 1;
+	int e_RAB_ID = 1;
+	int drb_ID = 2;
+	long int pDCPatSgNB = X2AP_EN_DC_ResourceConfiguration__pDCPatSgNB_present;
+	long int mCGresources = X2AP_EN_DC_ResourceConfiguration__mCGresources_not_present;
+	long int sCGresources = X2AP_EN_DC_ResourceConfiguration__sCGresources_not_present;
+	long qCI = 1;
+	X2AP_Pre_emptionCapability_t pre_emptionCapability = X2AP_Pre_emptionCapability_shall_not_trigger_pre_emption;
+	X2AP_Pre_emptionVulnerability_t pre_emptionVulnerability = X2AP_Pre_emptionVulnerability_not_pre_emptable;
+	priority_level_t priority_level = PRIORITY_LEVEL_NO_PRIORITY;
+	e_rab_tobe_added_t e_MCG_rabs_tobeadded;
+	e_MCG_rabs_tobeadded.gtp_teid = 0;
+	e_MCG_rabs_tobeadded.eNB_addr.length = 24;
+	uint8_t buf[20] = { 0 };
+	memcpy(e_MCG_rabs_tobeadded.eNB_addr.buffer, buf, 20*sizeof(uint8_t));
+
+	FILE *fd;
+	fd = fopen("../../../executables/uecap.raw","r");
+	if (fd != NULL) {
+		OCTET_STRING_t CG_Config_Info;
+		CG_Config_Info.size = 4096;
+		CG_Config_Info.buf = (uint8_t *)calloc(4096, sizeof(uint8_t));
+		int msg_len=fread(CG_Config_Info.buf,1,CG_Config_Info.size,fd);
+		CG_Config_Info.size = msg_len;
+
+		/*char buffer[4096];
+		int msg_len=fread(buffer,1,4096,fd);*/
+		LOG_I(RRC,"Read in %d bytes for uecap\n",msg_len);
+
+
+	/*OCTET_STRING_t CG_Config_Info;
+	CG_Config_Info.size = 4096;
+	CG_Config_Info.buf = (uint8_t *)calloc(4096, sizeof(uint8_t));*/
+
+
+	DevAssert(instance_p != NULL);
+	DevAssert(x2ap_eNB_data_p != NULL);
+
+	x2ap_eNB_data_p->state = X2AP_ENB_STATE_WAITING;
+
+
+
+	/* Prepare the X2AP message to encode */
+	memset(&pdu, 0, sizeof(pdu));
+	pdu.present = X2AP_X2AP_PDU_PR_initiatingMessage;
+	pdu.choice.initiatingMessage.procedureCode = X2AP_ProcedureCode_id_sgNBAdditionPreparation;
+	pdu.choice.initiatingMessage.criticality = X2AP_Criticality_reject;
+	pdu.choice.initiatingMessage.value.present = X2AP_InitiatingMessage__value_PR_SgNBAdditionRequest;
+	out = &pdu.choice.initiatingMessage.value.choice.SgNBAdditionRequest;
+
+	ie = (X2AP_SgNBAdditionRequest_IEs_t *)calloc(1, sizeof(X2AP_SgNBAdditionRequest_IEs_t));
+	ie->id = X2AP_ProtocolIE_ID_id_MeNB_UE_X2AP_ID; //Not sure about that
+	ie->criticality= X2AP_Criticality_reject;
+	ie->value.present = X2AP_SgNBAdditionRequest_IEs__value_PR_UE_X2AP_ID;
+	ie->value.choice.UE_X2AP_ID = x2ap_id_get_id_source(&instance_p->id_manager, ue_id);
+	ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+	ie = (X2AP_SgNBAdditionRequest_IEs_t *)calloc(1, sizeof(X2AP_SgNBAdditionRequest_IEs_t));
+	ie->id = X2AP_ProtocolIE_ID_id_NRUESecurityCapabilities;
+	ie->criticality = X2AP_Criticality_reject;
+	ie->value.present = X2AP_SgNBAdditionRequest_IEs__value_PR_NRUESecurityCapabilities;
+	INT16_TO_BIT_STRING(nRencryptionAlgorithms, &ie->value.choice.NRUESecurityCapabilities.nRencryptionAlgorithms);
+	INT16_TO_BIT_STRING(nRintegrityProtectionAlgorithms, &ie->value.choice.NRUESecurityCapabilities.nRintegrityProtectionAlgorithms);
+	ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+	ie = (X2AP_SgNBAdditionRequest_IEs_t *)calloc(1, sizeof(X2AP_SgNBAdditionRequest_IEs_t));
+	ie->id = X2AP_ProtocolIE_ID_id_SgNBSecurityKey;
+	ie->criticality = X2AP_Criticality_reject;
+	ie->value.present = X2AP_SgNBAdditionRequest_IEs__value_PR_SgNBSecurityKey;
+	KENB_STAR_TO_BIT_STRING(SgNBSecurityKey, &ie->value.choice.SgNBSecurityKey);
+	ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+	ie = (X2AP_SgNBAdditionRequest_IEs_t *)calloc(1, sizeof(X2AP_SgNBAdditionRequest_IEs_t));
+	ie->id = X2AP_ProtocolIE_ID_id_SgNBUEAggregateMaximumBitRate;
+	ie->criticality = X2AP_Criticality_reject;
+	ie->value.present = X2AP_SgNBAdditionRequest_IEs__value_PR_UEAggregateMaximumBitRate;
+	ie->value.choice.UEAggregateMaximumBitRate.uEaggregateMaximumBitRateDownlink.buf = (uint8_t *)calloc(4, sizeof(uint8_t));
+	INT32_TO_BUFFER(uEaggregateMaximumBitRateDownlink, ie->value.choice.UEAggregateMaximumBitRate.uEaggregateMaximumBitRateDownlink.buf);
+	ie->value.choice.UEAggregateMaximumBitRate.uEaggregateMaximumBitRateDownlink.size = 4;
+
+	ie->value.choice.UEAggregateMaximumBitRate.uEaggregateMaximumBitRateUplink.buf = (uint8_t *)calloc(4, sizeof(uint8_t));
+	INT32_TO_BUFFER(uEaggregateMaximumBitRateUplink, ie->value.choice.UEAggregateMaximumBitRate.uEaggregateMaximumBitRateUplink.buf);
+	ie->value.choice.UEAggregateMaximumBitRate.uEaggregateMaximumBitRateUplink.size = 4;
+
+	ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+	ie = (X2AP_SgNBAdditionRequest_IEs_t *)calloc(1, sizeof(X2AP_SgNBAdditionRequest_IEs_t));
+	//Not sure if id should be X2AP_ProtocolIE_ID_id_E_RABs_ToBeAdded_List or X2AP_ProtocolIE_ID_id_E_RABs_ToBeAdded_SgNBAddReqList
+	ie->id = X2AP_ProtocolIE_ID_id_E_RABs_ToBeAdded_SgNBAddReqList;
+	ie->criticality = X2AP_Criticality_reject;
+	ie->value.present = X2AP_SgNBAdditionRequest_IEs__value_PR_E_RABs_ToBeAdded_SgNBAddReqList;
+
+    for (int i=0;i<e_rabs_tobeadded;i++) {
+    	e_RABS_ToBeAdded_SgNBAddReq_ItemIEs = (X2AP_E_RABs_ToBeAdded_SgNBAddReq_ItemIEs_t *)calloc(1,sizeof(X2AP_E_RABs_ToBeAdded_SgNBAddReq_ItemIEs_t));
+    	e_RABS_ToBeAdded_SgNBAddReq_ItemIEs->id = X2AP_ProtocolIE_ID_id_E_RABs_ToBeAdded_SgNBAddReq_Item;
+    	e_RABS_ToBeAdded_SgNBAddReq_ItemIEs->criticality = X2AP_Criticality_ignore;
+    	e_RABS_ToBeAdded_SgNBAddReq_ItemIEs->value.present = X2AP_E_RABs_ToBeAdded_SgNBAddReq_ItemIEs__value_PR_E_RABs_ToBeAdded_SgNBAddReq_Item;
+    	e_RABS_ToBeAdded_SgNBAddReq_Item = &e_RABS_ToBeAdded_SgNBAddReq_ItemIEs->value.choice.E_RABs_ToBeAdded_SgNBAddReq_Item;
+      {
+    	e_RABS_ToBeAdded_SgNBAddReq_Item->drb_ID = drb_ID;
+    	e_RABS_ToBeAdded_SgNBAddReq_Item->e_RAB_ID = e_RAB_ID;
+    	e_RABS_ToBeAdded_SgNBAddReq_Item->en_DC_ResourceConfiguration.pDCPatSgNB = pDCPatSgNB;
+    	e_RABS_ToBeAdded_SgNBAddReq_Item->en_DC_ResourceConfiguration.mCGresources = mCGresources;
+    	e_RABS_ToBeAdded_SgNBAddReq_Item->en_DC_ResourceConfiguration.sCGresources = sCGresources;
+    	if (pDCPatSgNB == X2AP_EN_DC_ResourceConfiguration__pDCPatSgNB_present){
+    		e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.present = X2AP_E_RABs_ToBeAdded_SgNBAddReq_Item__resource_configuration_PR_sgNBPDCPpresent;
+
+    		e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.full_E_RAB_Level_QoS_Parameters.qCI = qCI;
+    		e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.full_E_RAB_Level_QoS_Parameters.allocationAndRetentionPriority.pre_emptionCapability = pre_emptionCapability;
+    		e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.full_E_RAB_Level_QoS_Parameters.allocationAndRetentionPriority. pre_emptionVulnerability = pre_emptionVulnerability;
+    		e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.full_E_RAB_Level_QoS_Parameters.allocationAndRetentionPriority.priorityLevel = priority_level;
+
+    		//Continue from filling the UL_GTPtunnelEndpointInformation inspired from how it is done for the HO case
+    		INT32_TO_OCTET_STRING(e_MCG_rabs_tobeadded.gtp_teid, &e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_UL_GTPtunnelEndpoint.gTP_TEID);
+    		e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_UL_GTPtunnelEndpoint.transportLayerAddress.size = e_MCG_rabs_tobeadded.eNB_addr.length/8;
+    		e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_UL_GTPtunnelEndpoint.transportLayerAddress.bits_unused = e_MCG_rabs_tobeadded.eNB_addr.length%8;
+    		e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_UL_GTPtunnelEndpoint.transportLayerAddress.buf =
+    				calloc(1, e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_UL_GTPtunnelEndpoint.transportLayerAddress.size);
+
+    		memcpy (e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_UL_GTPtunnelEndpoint.transportLayerAddress.buf,
+    				e_MCG_rabs_tobeadded.eNB_addr.buffer,
+    				e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_UL_GTPtunnelEndpoint.transportLayerAddress.size);
+    	}
+
+      }
+      ASN_SEQUENCE_ADD(&ie->value.choice.E_RABs_ToBeAdded_SgNBAddReqList.list, e_RABS_ToBeAdded_SgNBAddReq_ItemIEs);
+    }
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+    ie = (X2AP_SgNBAdditionRequest_IEs_t *)calloc(1, sizeof(X2AP_SgNBAdditionRequest_IEs_t));
+    ie->id = X2AP_ProtocolIE_ID_id_MeNBtoSgNBContainer;
+    ie->criticality = X2AP_Criticality_reject;
+    ie->value.present = X2AP_SgNBAdditionRequest_IEs__value_PR_MeNBtoSgNBContainer;
+    ie->value.choice.MeNBtoSgNBContainer.buf = (uint8_t *)calloc(CG_Config_Info.size, sizeof(uint8_t));
+    memcpy(ie->value.choice.MeNBtoSgNBContainer.buf, CG_Config_Info.buf, CG_Config_Info.size);
+    ie->value.choice.MeNBtoSgNBContainer.size = CG_Config_Info.size; //4096;
+    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+    if (x2ap_eNB_encode_pdu(&pdu, &buffer, &len) < 0) {
+        X2AP_ERROR("Failed to encode ENDC X2 SgNB_addition request message\n");
+        return -1;
+    }
+
+    MSC_LOG_TX_MESSAGE (MSC_X2AP_SRC_ENB, MSC_X2AP_TARGET_ENB, NULL, 0, "0 X2Setup/initiatingMessage assoc_id %u", x2ap_eNB_data_p->assoc_id);
+
+    x2ap_eNB_itti_send_sctp_data_req(instance_p->instance, x2ap_eNB_data_p->assoc_id, buffer, len, 0);
+	fclose(fd);
+	}
+	else {
+		LOG_I(RRC, "uecap.raw file could not be opened... \n");
+		return -1;
+	}
+
+	return ret;
+
+}
+
+
+int x2ap_gNB_generate_ENDC_x2_SgNB_addition_request_ACK( x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p,
+		x2ap_ENDC_sgnb_addition_req_ACK_t *x2ap_sgnb_addition_req_ACK, int ue_id)
+{
+        
+		X2AP_X2AP_PDU_t                     	 			pdu;
+		X2AP_SgNBAdditionRequestAcknowledge_t               *out;
+		X2AP_SgNBAdditionRequestAcknowledge_IEs_t           *ie;
+		X2AP_E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_ItemIEs_t 			*e_RABS_AdmittedToBeAdded_SgNBAddReq_ItemIEs;
+		X2AP_E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_Item_t         	*e_RABS_AdmittedToBeAdded_SgNBAddReq_Item;
+
+		uint8_t  *buffer;
+		uint32_t  len;
+		int       ret = 0;
+		int MeNB_UE_X2AP_id = ue_id;
+		int SgNB_UE_X2AP_id = 0;
+
+		// Currently hardcoded (dummy) values filling the fields of SgNB_addition_request message. To be substituted
+		// with values coming from RRC.
+		uint16_t nRencryptionAlgorithms = 0;
+		uint16_t nRintegrityProtectionAlgorithms = 0;
+		uint8_t  SgNBSecurityKey[32] = { 0 };
+		int uEaggregateMaximumBitRateDownlink = 100000000;
+		int uEaggregateMaximumBitRateUplink = 100000000;
+		int e_rabs_admitted_tobeadded = 1;
+		int e_RAB_ID = 1;
+		long int pDCPatSgNB = X2AP_EN_DC_ResourceConfiguration__pDCPatSgNB_present;
+		long int mCGresources = X2AP_EN_DC_ResourceConfiguration__mCGresources_not_present;
+		long int sCGresources = X2AP_EN_DC_ResourceConfiguration__sCGresources_not_present;
+		e_rab_setup_t e_SCG_rabs_tobeadded;
+		e_SCG_rabs_tobeadded.gtp_teid = 0;
+		e_SCG_rabs_tobeadded.eNB_addr.length = 24;
+		uint8_t buf[20] = { 0 };
+		memcpy(e_SCG_rabs_tobeadded.eNB_addr.buffer, buf, 20*sizeof(uint8_t));
+
+		DevAssert(instance_p != NULL);
+		DevAssert(x2ap_eNB_data_p != NULL);
+
+		x2ap_eNB_data_p->state = X2AP_ENB_STATE_WAITING;
+
+		// Prepare the X2AP message to encode
+		memset(&pdu, 0, sizeof(pdu));
+		pdu.present = X2AP_X2AP_PDU_PR_successfulOutcome;
+		pdu.choice.successfulOutcome.procedureCode = X2AP_ProcedureCode_id_sgNBAdditionPreparation;
+		pdu.choice.successfulOutcome.criticality = X2AP_Criticality_reject;
+		pdu.choice.successfulOutcome.value.present = X2AP_SuccessfulOutcome__value_PR_SgNBAdditionRequestAcknowledge;
+		out = &pdu.choice.successfulOutcome.value.choice.SgNBAdditionRequestAcknowledge;
+
+		// MeNB_UE_X2AP_id
+		ie = (X2AP_SgNBAdditionRequestAcknowledge_IEs_t *)calloc(1, sizeof(X2AP_SgNBAdditionRequestAcknowledge_IEs_t));
+		ie->id = X2AP_ProtocolIE_ID_id_MeNB_UE_X2AP_ID;
+		ie->criticality= X2AP_Criticality_reject;
+		ie->value.present = X2AP_SgNBAdditionRequestAcknowledge_IEs__value_PR_UE_X2AP_ID;
+		ie->value.choice.UE_X2AP_ID = MeNB_UE_X2AP_id; //x2ap_id_get_id_source(&instance_p->id_manager, ue_id);
+		ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+		// SgNB_UE_X2AP_id
+		ie = (X2AP_SgNBAdditionRequestAcknowledge_IEs_t *)calloc(1, sizeof(X2AP_SgNBAdditionRequestAcknowledge_IEs_t));
+		ie->id = X2AP_ProtocolIE_ID_id_SgNB_UE_X2AP_ID;
+		ie->criticality= X2AP_Criticality_reject;
+		ie->value.present = X2AP_SgNBAdditionRequestAcknowledge_IEs__value_PR_SgNB_UE_X2AP_ID;
+		ie->value.choice.UE_X2AP_ID = SgNB_UE_X2AP_id; //x2ap_id_get_id_source(&instance_p->id_manager, ue_id);
+		ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+		ie = (X2AP_SgNBAdditionRequestAcknowledge_IEs_t *)calloc(1, sizeof(X2AP_SgNBAdditionRequestAcknowledge_IEs_t));
+		ie->id = X2AP_ProtocolIE_ID_id_E_RABs_Admitted_ToBeAdded_SgNBAddReqAckList;
+		ie->criticality = X2AP_Criticality_ignore;
+		ie->value.present = X2AP_SgNBAdditionRequestAcknowledge_IEs__value_PR_E_RABs_Admitted_ToBeAdded_SgNBAddReqAckList;
+
+	    for (int i=0;i<e_rabs_admitted_tobeadded;i++) {
+	    	e_RABS_AdmittedToBeAdded_SgNBAddReq_ItemIEs = (X2AP_E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_ItemIEs_t *)calloc(1,sizeof(X2AP_E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_ItemIEs_t));
+	    	e_RABS_AdmittedToBeAdded_SgNBAddReq_ItemIEs->id = X2AP_ProtocolIE_ID_id_E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_Item;
+	    	e_RABS_AdmittedToBeAdded_SgNBAddReq_ItemIEs->criticality = X2AP_Criticality_ignore;
+	    	e_RABS_AdmittedToBeAdded_SgNBAddReq_ItemIEs->value.present = X2AP_E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_ItemIEs__value_PR_E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_Item;
+	    	e_RABS_AdmittedToBeAdded_SgNBAddReq_Item = &e_RABS_AdmittedToBeAdded_SgNBAddReq_ItemIEs->value.choice.E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_Item;
+	      {
+	    		e_RABS_AdmittedToBeAdded_SgNBAddReq_Item->e_RAB_ID = e_RAB_ID;
+	    		e_RABS_AdmittedToBeAdded_SgNBAddReq_Item->en_DC_ResourceConfiguration.pDCPatSgNB = pDCPatSgNB;
+	    		e_RABS_AdmittedToBeAdded_SgNBAddReq_Item->en_DC_ResourceConfiguration.mCGresources = mCGresources;
+	    		e_RABS_AdmittedToBeAdded_SgNBAddReq_Item->en_DC_ResourceConfiguration.sCGresources = sCGresources;
+	    	if (pDCPatSgNB == X2AP_EN_DC_ResourceConfiguration__pDCPatSgNB_present){
+	    		e_RABS_AdmittedToBeAdded_SgNBAddReq_Item->resource_configuration.present = X2AP_E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_Item__resource_configuration_PR_sgNBPDCPpresent;
+
+	    		INT32_TO_OCTET_STRING(e_SCG_rabs_tobeadded.gtp_teid, &e_RABS_AdmittedToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_DL_GTPtunnelEndpoint.gTP_TEID);
+	    		e_RABS_AdmittedToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_DL_GTPtunnelEndpoint.transportLayerAddress.size  = e_SCG_rabs_tobeadded.eNB_addr.length/8;
+	    		e_RABS_AdmittedToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_DL_GTPtunnelEndpoint.transportLayerAddress.bits_unused = e_SCG_rabs_tobeadded.eNB_addr.length%8;
+	    		e_RABS_AdmittedToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_DL_GTPtunnelEndpoint.transportLayerAddress.buf =
+	    				calloc(1, e_RABS_AdmittedToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_DL_GTPtunnelEndpoint.transportLayerAddress.size);
+
+	    		memcpy (e_RABS_AdmittedToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_DL_GTPtunnelEndpoint.transportLayerAddress.buf,
+	    				e_SCG_rabs_tobeadded.eNB_addr.buffer,
+	    				e_RABS_AdmittedToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_DL_GTPtunnelEndpoint.transportLayerAddress.size);
+	    	}
+
+	      }
+	      ASN_SEQUENCE_ADD(&ie->value.choice.E_RABs_Admitted_ToBeAdded_SgNBAddReqAckList.list, e_RABS_AdmittedToBeAdded_SgNBAddReq_ItemIEs);
+	    }
+	    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+	    ie = (X2AP_SgNBAdditionRequestAcknowledge_IEs_t *)calloc(1, sizeof(X2AP_SgNBAdditionRequestAcknowledge_IEs_t));
+	    ie->id = X2AP_ProtocolIE_ID_id_SgNBtoMeNBContainer;
+	    ie->criticality = X2AP_Criticality_reject;
+	    ie->value.present = X2AP_SgNBAdditionRequestAcknowledge_IEs__value_PR_SgNBtoMeNBContainer;
+	    ie->value.choice.SgNBtoMeNBContainer.buf = (uint8_t *)calloc(x2ap_sgnb_addition_req_ACK->rrc_buffer_size, sizeof(uint8_t));
+	    memcpy(ie->value.choice.SgNBtoMeNBContainer.buf, x2ap_sgnb_addition_req_ACK->rrc_buffer, x2ap_sgnb_addition_req_ACK->rrc_buffer_size);
+	    ie->value.choice.SgNBtoMeNBContainer.size = x2ap_sgnb_addition_req_ACK->rrc_buffer_size; //4096;
+	    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+	    if (x2ap_eNB_encode_pdu(&pdu, &buffer, &len) < 0) {
+	        X2AP_ERROR("Failed to encode ENDC X2 SgNB_addition request message\n");
+	        return -1;
+	    }
+
+	    MSC_LOG_TX_MESSAGE (MSC_X2AP_SRC_ENB, MSC_X2AP_TARGET_ENB, NULL, 0, "0 X2Setup/initiatingMessage assoc_id %u", x2ap_eNB_data_p->assoc_id);
+
+	    x2ap_eNB_itti_send_sctp_data_req(instance_p->instance, x2ap_eNB_data_p->assoc_id, buffer, len, 0);
+
+		return ret;
+
+}
+
+
+int x2ap_eNB_generate_ENDC_x2_SgNB_reconfiguration_complete(
+  x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p, int ue_id, int SgNB_ue_id)
+{
+	X2AP_X2AP_PDU_t                     	 pdu;
+	X2AP_SgNBReconfigurationComplete_t               *out;
+	X2AP_SgNBReconfigurationComplete_IEs_t           *ie;
+
+	uint8_t  *buffer;
+	uint32_t  len;
+	int       ret = 0;
+
+	DevAssert(instance_p != NULL);
+	DevAssert(x2ap_eNB_data_p != NULL);
+
+	x2ap_eNB_data_p->state = X2AP_ENB_STATE_WAITING;
+
+
+	/* Prepare the X2AP message to encode */
+	memset(&pdu, 0, sizeof(pdu));
+	pdu.present = X2AP_X2AP_PDU_PR_initiatingMessage;
+	pdu.choice.initiatingMessage.procedureCode = X2AP_ProcedureCode_id_sgNBReconfigurationCompletion;
+	pdu.choice.initiatingMessage.criticality = X2AP_Criticality_ignore;
+	pdu.choice.initiatingMessage.value.present = X2AP_InitiatingMessage__value_PR_SgNBReconfigurationComplete;
+	out = &pdu.choice.initiatingMessage.value.choice.SgNBReconfigurationComplete;
+
+	ie = (X2AP_SgNBReconfigurationComplete_IEs_t *)calloc(1, sizeof(X2AP_SgNBReconfigurationComplete_IEs_t));
+	ie->id = X2AP_ProtocolIE_ID_id_MeNB_UE_X2AP_ID;
+	ie->criticality= X2AP_Criticality_reject;
+	ie->value.present = X2AP_SgNBReconfigurationComplete_IEs__value_PR_UE_X2AP_ID;
+	ie->value.choice.UE_X2AP_ID = ue_id; //x2ap_id_get_id_source(&instance_p->id_manager, ue_id);
+	ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+	ie = (X2AP_SgNBReconfigurationComplete_IEs_t *)calloc(1, sizeof(X2AP_SgNBReconfigurationComplete_IEs_t));
+	ie->id = X2AP_ProtocolIE_ID_id_SgNB_UE_X2AP_ID;
+	ie->criticality = X2AP_Criticality_reject;
+	ie->value.present = X2AP_SgNBReconfigurationComplete_IEs__value_PR_SgNB_UE_X2AP_ID;
+	ie->value.choice.SgNB_UE_X2AP_ID = SgNB_ue_id;
+	ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+	ie = (X2AP_SgNBReconfigurationComplete_IEs_t *)calloc(1, sizeof(X2AP_SgNBReconfigurationComplete_IEs_t));
+	ie->id = X2AP_ProtocolIE_ID_id_ResponseInformationSgNBReconfComp;
+	ie->criticality = X2AP_Criticality_ignore;
+	ie->value.present = X2AP_SgNBReconfigurationComplete_IEs__value_PR_ResponseInformationSgNBReconfComp;
+	ie->value.choice.ResponseInformationSgNBReconfComp.present = X2AP_ResponseInformationSgNBReconfComp_PR_success_SgNBReconfComp;
+	// meNBtoSgNBContainer should contain the RRCReconfigurationComplete message from the UE but in the specs 36.423(9.1.4.4) its presence is not mandatory
+	ie->value.choice.ResponseInformationSgNBReconfComp.choice.success_SgNBReconfComp.meNBtoSgNBContainer = NULL;
+	ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
+
+    if (x2ap_eNB_encode_pdu(&pdu, &buffer, &len) < 0) {
+        X2AP_ERROR("Failed to encode ENDC X2 SgNB_addition request message\n");
+        return -1;
+    }
+
+    x2ap_eNB_itti_send_sctp_data_req(instance_p->instance, x2ap_eNB_data_p->assoc_id, buffer, len, 0);
+
+	return ret;
+
+}
diff --git a/openair2/X2AP/x2ap_eNB_generate_messages.h b/openair2/X2AP/x2ap_eNB_generate_messages.h
index 6b0cd9c2da2..114ed84a686 100644
--- a/openair2/X2AP/x2ap_eNB_generate_messages.h
+++ b/openair2/X2AP/x2ap_eNB_generate_messages.h
@@ -66,8 +66,15 @@ int x2ap_eNB_generate_senb_addition_request (x2ap_eNB_instance_t *instance_p, x2
 int x2ap_eNB_generate_senb_addition_request_ack (x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p,
                                                x2ap_senb_addition_req_ack_t *x2ap_addition_req_ack);
 
-int x2ap_eNB_generate_ENDC_x2_setup_request(x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p);
+int x2ap_gNB_generate_ENDC_x2_setup_request(x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p);
 
-int x2ap_gNB_generate_ENDC_x2_setup_response( x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p);
+int x2ap_eNB_generate_ENDC_x2_setup_response( x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p);
+
+int x2ap_eNB_generate_ENDC_x2_SgNB_addition_request( x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p, int ue_id);
+
+int x2ap_gNB_generate_ENDC_x2_SgNB_addition_request_ACK( x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p, x2ap_ENDC_sgnb_addition_req_ACK_t *x2ap_sgnb_addition_req_ACK, int ue_id);
+
+int x2ap_eNB_generate_ENDC_x2_SgNB_reconfiguration_complete(
+  x2ap_eNB_instance_t *instance_p, x2ap_eNB_data_t *x2ap_eNB_data_p, int ue_id, int SgNB_ue_id);
 
 #endif /*  X2AP_ENB_GENERATE_MESSAGES_H_ */
diff --git a/openair2/X2AP/x2ap_eNB_handler.c b/openair2/X2AP/x2ap_eNB_handler.c
index bde7bd59d96..b7a9b705967 100644
--- a/openair2/X2AP/x2ap_eNB_handler.c
+++ b/openair2/X2AP/x2ap_eNB_handler.c
@@ -103,7 +103,7 @@ int x2ap_eNB_handle_senb_addition_request_reject (instance_t instance,
                                                   uint32_t stream,
                                                   X2AP_X2AP_PDU_t *pdu);
 
-int x2ap_gNB_handle_ENDC_x2_setup_request(instance_t instance,
+int x2ap_eNB_handle_ENDC_x2_setup_request(instance_t instance,
                                  uint32_t assoc_id,
                                  uint32_t stream,
                                  X2AP_X2AP_PDU_t *pdu);
@@ -114,8 +114,26 @@ x2ap_gNB_handle_ENDC_x2_setup_response(instance_t instance,
                                  uint32_t stream,
                                  X2AP_X2AP_PDU_t *pdu);
 
+static
+int x2ap_gNB_handle_ENDC_sGNB_addition_request (instance_t instance,
+                                          uint32_t assoc_id,
+                                          uint32_t stream,
+                                          X2AP_X2AP_PDU_t *pdu);
+
+static
+int x2ap_eNB_handle_ENDC_sGNB_addition_response (instance_t instance,
+                                          uint32_t assoc_id,
+                                          uint32_t stream,
+                                          X2AP_X2AP_PDU_t *pdu);
+
+static
+int x2ap_gNB_handle_ENDC_sGNB_reconfiguration_complete (instance_t instance,
+                                          uint32_t assoc_id,
+                                          uint32_t stream,
+                                          X2AP_X2AP_PDU_t *pdu);
+
 
-/* Handlers matrix. Only eNB related procedure present here */
+/* Handlers matrix. Only eNB related procedure present here. Placement of callback functions according to X2AP_ProcedureCode.h */
 x2ap_message_decoded_callback x2ap_messages_callback[][3] = {
   { x2ap_eNB_handle_handover_preparation, x2ap_eNB_handle_handover_response, 0 }, /* handoverPreparation */
   { x2ap_eNB_handle_handover_cancel, 0, 0 }, /* handoverCancel */
@@ -144,6 +162,8 @@ x2ap_message_decoded_callback x2ap_messages_callback[][3] = {
   { 0, 0, 0 }, /* seNBinitiatedSeNBRelease */
   { 0, 0, 0 }, /* seNBCounterCheck */
   { 0, 0, 0 },  /* retrieveUEContext */
+  { x2ap_gNB_handle_ENDC_sGNB_addition_request, x2ap_eNB_handle_ENDC_sGNB_addition_response, 0 }, /*X2AP_ProcedureCode_id_sgNBAdditionPreparation*/
+  { x2ap_gNB_handle_ENDC_sGNB_reconfiguration_complete, 0, 0 }, /*X2AP_ProcedureCode_id_sgNBReconfigurationCompletion*/
   { 0, 0, 0 },
   { 0, 0, 0 },
   { 0, 0, 0 },
@@ -151,9 +171,7 @@ x2ap_message_decoded_callback x2ap_messages_callback[][3] = {
   { 0, 0, 0 },
   { 0, 0, 0 },
   { 0, 0, 0 },
-  { 0, 0, 0 },
-  { 0, 0, 0 },
-  { x2ap_gNB_handle_ENDC_x2_setup_request, x2ap_gNB_handle_ENDC_x2_setup_response, 0 },
+  { x2ap_eNB_handle_ENDC_x2_setup_request, x2ap_gNB_handle_ENDC_x2_setup_response, 0 }, /*X2AP_ProcedureCode_id_endcX2Setup*/
   { 0, 0, 0 },
   { 0, 0, 0 },
   { 0, 0, 0 }
@@ -1324,7 +1342,7 @@ int x2ap_eNB_handle_senb_addition_request_reject (instance_t instance,
 }
 
 int
-x2ap_gNB_handle_ENDC_x2_setup_request(instance_t instance,
+x2ap_eNB_handle_ENDC_x2_setup_request(instance_t instance,
                                  uint32_t assoc_id,
                                  uint32_t stream,
                                  X2AP_X2AP_PDU_t *pdu)
@@ -1332,12 +1350,12 @@ x2ap_gNB_handle_ENDC_x2_setup_request(instance_t instance,
 
   X2AP_ENDCX2SetupRequest_t              *x2_ENDC_SetupRequest;
   X2AP_ENDCX2SetupRequest_IEs_t          *ie;
-  X2AP_ENB_ENDCX2SetupReqIEs_t 			 *ie_ENB_ENDC;
-  ServedEUTRAcellsENDCX2ManagementList__Member                *servedCellMember;
+  X2AP_En_gNB_ENDCX2SetupReqIEs_t 			 *ie_GNB_ENDC;
+  ServedNRcellsENDCX2ManagementList__Member                *servedCellMember;
 
   x2ap_eNB_instance_t                *instance_p;
   x2ap_eNB_data_t                    *x2ap_eNB_data;
-  uint32_t                           eNB_id = 0;
+  uint32_t                           gNB_id = 0;
 
   x2ap_eNB_data = NULL;
   DevAssert (pdu != NULL);
@@ -1372,37 +1390,25 @@ x2ap_gNB_handle_ENDC_x2_setup_request(instance_t instance,
     X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
     return -1;
   } else {
-	  if (ie->value.choice.InitiatingNodeType_EndcX2Setup.choice.init_eNB.list.count > 0) {
-		  //Panos: Here the container parameter in X2AP_FIND_PROTOCOLIE_BY_ID should be the x2_ENDC_SetupRequest
-		  //message or the ie to which there are more nested information elements?
-		  for (int i=0; i<ie->value.choice.InitiatingNodeType_EndcX2Setup.choice.init_eNB.list.count;i++) {
+	  if (ie->value.choice.InitiatingNodeType_EndcX2Setup.choice.init_en_gNB.list.count > 0) {
 
-			  ie_ENB_ENDC = (X2AP_ENB_ENDCX2SetupReqIEs_t*) ie->value.choice.InitiatingNodeType_EndcX2Setup.choice.init_eNB.list.array[i];
-			  if (ie_ENB_ENDC == NULL ) {
+		  for (int i=0; i<ie->value.choice.InitiatingNodeType_EndcX2Setup.choice.init_en_gNB.list.count;i++) {
+
+			  ie_GNB_ENDC = (X2AP_En_gNB_ENDCX2SetupReqIEs_t*) ie->value.choice.InitiatingNodeType_EndcX2Setup.choice.init_eNB.list.array[i];
+			  if (ie_GNB_ENDC == NULL ) {
 				  X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
 				  return -1;
 			  }
 
-			  else if (ie_ENB_ENDC->id == X2AP_ProtocolIE_ID_id_GlobalENB_ID) {
-				  if (ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.present == X2AP_ENB_ID_PR_home_eNB_ID) {
-					  // Home eNB ID = 28 bits
-					  uint8_t  *eNB_id_buf = ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.choice.home_eNB_ID.buf;
-					  if (ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.choice.macro_eNB_ID.size != 28) {
-						  //TODO: handle case were size != 28 -> notify ? reject ?
-					  }
-					  eNB_id = (eNB_id_buf[0] << 20) + (eNB_id_buf[1] << 12) + (eNB_id_buf[2] << 4) + ((eNB_id_buf[3] & 0xf0) >> 4);
-					  X2AP_DEBUG("Home eNB id: %07x\n", eNB_id);
-				  } else {
-					  // Macro eNB = 20 bits
-					  uint8_t *eNB_id_buf = ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.choice.macro_eNB_ID.buf;
-					  if (ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.choice.macro_eNB_ID.size != 20) {
-							  //TODO: handle case were size != 20 -> notify ? reject ?
-					  }
-					  eNB_id = (eNB_id_buf[0] << 12) + (eNB_id_buf[1] << 4) + ((eNB_id_buf[2] & 0xf0) >> 4);
-					  X2AP_DEBUG("macro eNB id: %05x\n", eNB_id);
+			  else if (ie_GNB_ENDC->id == X2AP_ProtocolIE_ID_id_Globalen_gNB_ID) {
+				  if (ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.choice.gNB_ID.size!= 28) {
+					  //TODO: handle case were size != 28 -> notify ? reject ?
 				  }
-				  X2AP_DEBUG("Adding eNB to the list of associated eNBs\n");
-				  if ((x2ap_eNB_data = x2ap_is_eNB_id_in_list (eNB_id)) == NULL) {
+				  OCTET_STRING_TO_INT32(&ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.choice.gNB_ID,gNB_id);
+				  X2AP_DEBUG("gNB id: %07x\n", gNB_id);
+
+				  X2AP_DEBUG("Adding gNB to the list of associated gNBs\n");
+				  if ((x2ap_eNB_data = x2ap_is_eNB_id_in_list (gNB_id)) == NULL) {
 					  /*
 				       * eNB has not been found in list of associated eNB,
 				       * * * * Add it to the tail of list and initialize data
@@ -1414,7 +1420,7 @@ x2ap_gNB_handle_ENDC_x2_setup_request(instance_t instance,
 						  return -1;
 					  } else {
 						  x2ap_eNB_data->state = X2AP_ENB_STATE_RESETTING;
-						  x2ap_eNB_data->eNB_id = eNB_id;
+						  x2ap_eNB_data->eNB_id = gNB_id;
 					  }
 				  } else {
 					  x2ap_eNB_data->state = X2AP_ENB_STATE_RESETTING;
@@ -1427,7 +1433,7 @@ x2ap_gNB_handle_ENDC_x2_setup_request(instance_t instance,
 						  /*
 						   * ??: Send an overload cause...
 						   */
-						  X2AP_ERROR("Rejecting x2 setup request as eNB id %d is already associated to an active sctp association" "Previous known: %d, new one: %d\n", eNB_id, x2ap_eNB_data->assoc_id, assoc_id);
+						  X2AP_ERROR("Rejecting x2 setup request as eNB id %d is already associated to an active sctp association" "Previous known: %d, new one: %d\n", gNB_id, x2ap_eNB_data->assoc_id, assoc_id);
 
 						  // Panos: Here we should be calling an ENDC specific setup_failure function instead
 						  x2ap_eNB_generate_x2_setup_failure (instance,
@@ -1442,12 +1448,26 @@ x2ap_gNB_handle_ENDC_x2_setup_request(instance_t instance,
 					   */
 				  }
 			  }
-			  else if (ie_ENB_ENDC->id == X2AP_ProtocolIE_ID_id_ServedEUTRAcellsENDCX2ManagementList){
-				  if (ie_ENB_ENDC->value.choice.ServedEUTRAcellsENDCX2ManagementList.list.count > 0) {
-				      x2ap_eNB_data->num_cc = ie_ENB_ENDC->value.choice.ServedEUTRAcellsENDCX2ManagementList.list.count;
-				      for (int i=0; i<ie_ENB_ENDC->value.choice.ServedEUTRAcellsENDCX2ManagementList.list.count;i++) {
-				    	  servedCellMember = (ServedEUTRAcellsENDCX2ManagementList__Member *)ie_ENB_ENDC->value.choice.ServedEUTRAcellsENDCX2ManagementList.list.array[i];
-				    	  x2ap_eNB_data->Nid_cell[i] = servedCellMember->servedEUTRACellInfo.pCI;
+			  else if (ie_GNB_ENDC->id == X2AP_ProtocolIE_ID_id_ServedNRcellsENDCX2ManagementList){
+				  if (ie_GNB_ENDC->value.choice.ServedNRcellsENDCX2ManagementList.list.count > 0) {
+				      x2ap_eNB_data->num_cc = ie_GNB_ENDC->value.choice.ServedNRcellsENDCX2ManagementList.list.count;
+				      for (int i=0; i<ie_GNB_ENDC->value.choice.ServedNRcellsENDCX2ManagementList.list.count;i++) {
+				    	  servedCellMember = (ServedNRcellsENDCX2ManagementList__Member *)ie_GNB_ENDC->value.choice.ServedNRcellsENDCX2ManagementList.list.array[i];
+				    	  x2ap_eNB_data->Nid_cell[i] = servedCellMember->servedNRCellInfo.nrpCI;
+				    	  //servedCellMember->servedNRCellInfo.nrCellID.pLMN_Identity.buf[0]
+                                          if (servedCellMember->servedNRCellInfo.fiveGS_TAC != NULL) {
+				    	    X2AP_INFO("TAC: %02x%02x%02x\n",
+				    			    servedCellMember->servedNRCellInfo.fiveGS_TAC->buf[0],
+				    			    servedCellMember->servedNRCellInfo.fiveGS_TAC->buf[1],
+				    			    servedCellMember->servedNRCellInfo.fiveGS_TAC->buf[2]);
+                                          } else {
+				    	    X2AP_INFO("TAC: (NULL)\n");
+                                          }
+
+				    	  X2AP_INFO("PLMN: %02x%02x%02x\n",
+				    			  servedCellMember->servedNRCellInfo.nrCellID.pLMN_Identity.buf[0],
+				    			  servedCellMember->servedNRCellInfo.nrCellID.pLMN_Identity.buf[1],
+				    			  servedCellMember->servedNRCellInfo.nrCellID.pLMN_Identity.buf[2]);
 				      }
 				  }
 			  }
@@ -1462,9 +1482,7 @@ x2ap_gNB_handle_ENDC_x2_setup_request(instance_t instance,
   instance_p = x2ap_eNB_get_instance(instance);
   DevAssert(instance_p != NULL);
 
-  // Panos: Here we should be calling an ENDC specific setup response function
-  return x2ap_gNB_generate_ENDC_x2_setup_response(instance_p, x2ap_eNB_data);
-  //return x2ap_eNB_generate_x2_setup_response(instance_p, x2ap_eNB_data);
+  return x2ap_eNB_generate_ENDC_x2_setup_response(instance_p, x2ap_eNB_data);
 }
 
 int
@@ -1476,12 +1494,12 @@ x2ap_gNB_handle_ENDC_x2_setup_response(instance_t instance,
 
   X2AP_ENDCX2SetupResponse_t              *x2_ENDC_SetupResponse;
   X2AP_ENDCX2SetupResponse_IEs_t          *ie;
-  X2AP_En_gNB_ENDCX2SetupReqAckIEs_t 			 *ie_GNB_ENDC;
-  ServedNRcellsENDCX2ManagementList__Member                *servedCellMember;
+  X2AP_ENB_ENDCX2SetupReqAckIEs_t 			 *ie_ENB_ENDC;
+  ServedEUTRAcellsENDCX2ManagementList__Member                *servedCellMember;
 
   x2ap_eNB_instance_t                *instance_p;
   x2ap_eNB_data_t                    *x2ap_eNB_data;
-  uint32_t                           gNB_id = 0;
+  uint32_t                           eNB_id = 0;
 
   x2ap_eNB_data = NULL;
   DevAssert (pdu != NULL);
@@ -1497,7 +1515,7 @@ x2ap_gNB_handle_ENDC_x2_setup_response(instance_t instance,
       /*
        * Send a x2 setup failure with protocol cause unspecified
        */
-    // Panos: Here we should be calling an ENDC specific setup_failure function instead
+    // Here we should be calling an ENDC specific setup_failure function instead
     return x2ap_eNB_generate_x2_setup_failure (instance,
                                                assoc_id,
                                                X2AP_Cause_PR_protocol,
@@ -1516,26 +1534,35 @@ x2ap_gNB_handle_ENDC_x2_setup_response(instance_t instance,
     X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
     return -1;
   } else {
-	  if (ie->value.choice.RespondingNodeType_EndcX2Setup.choice.respond_en_gNB.list.count > 0) {
-		  //Panos: Here the container parameter in X2AP_FIND_PROTOCOLIE_BY_ID should be the x2_ENDC_SetupRequest
-		  //message or the ie to which there are more nested information elements?
-		  for (int i=0; i<ie->value.choice.RespondingNodeType_EndcX2Setup.choice.respond_en_gNB.list.count;i++) {
+	  if (ie->value.choice.RespondingNodeType_EndcX2Setup.choice.respond_eNB.list.count > 0) {
+		  for (int i=0; i<ie->value.choice.RespondingNodeType_EndcX2Setup.choice.respond_eNB.list.count;i++) {
 
-			  ie_GNB_ENDC = (X2AP_En_gNB_ENDCX2SetupReqAckIEs_t*) ie->value.choice.RespondingNodeType_EndcX2Setup.choice.respond_en_gNB.list.array[i];
-			  if (ie_GNB_ENDC == NULL ) {
+			  ie_ENB_ENDC = (X2AP_ENB_ENDCX2SetupReqAckIEs_t*) ie->value.choice.RespondingNodeType_EndcX2Setup.choice.respond_eNB.list.array[i];
+			  if (ie_ENB_ENDC == NULL ) {
 				  X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
 				  return -1;
 			  }
 
-			  else if (ie_GNB_ENDC->id == X2AP_ProtocolIE_ID_id_Globalen_gNB_ID) {
-				  if (ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.choice.gNB_ID.size!= 28) {
-					  //TODO: handle case were size != 28 -> notify ? reject ?
+			  else if (ie_ENB_ENDC->id == X2AP_ProtocolIE_ID_id_GlobalENB_ID) {
+				  if (ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.present == X2AP_ENB_ID_PR_home_eNB_ID) {
+					  // Home eNB ID = 28 bits
+					  uint8_t  *eNB_id_buf = ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.choice.home_eNB_ID.buf;
+					  if (ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.choice.macro_eNB_ID.size != 28) {
+						  //TODO: handle case were size != 28 -> notify ? reject ?
+					  }
+					  eNB_id = (eNB_id_buf[0] << 20) + (eNB_id_buf[1] << 12) + (eNB_id_buf[2] << 4) + ((eNB_id_buf[3] & 0xf0) >> 4);
+					  X2AP_DEBUG("Home eNB id: %07x\n", eNB_id);
+				  } else {
+					  // Macro eNB = 20 bits
+					  uint8_t *eNB_id_buf = ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.choice.macro_eNB_ID.buf;
+					  if (ie_ENB_ENDC->value.choice.GlobalENB_ID.eNB_ID.choice.macro_eNB_ID.size != 20) {
+							  //TODO: handle case were size != 20 -> notify ? reject ?
+					  }
+					  eNB_id = (eNB_id_buf[0] << 12) + (eNB_id_buf[1] << 4) + ((eNB_id_buf[2] & 0xf0) >> 4);
+					  X2AP_DEBUG("macro eNB id: %05x\n", eNB_id);
 				  }
-				  OCTET_STRING_TO_INT32(&ie_GNB_ENDC->value.choice.GlobalGNB_ID.gNB_ID.choice.gNB_ID,gNB_id);
-				  X2AP_DEBUG("gNB id: %07x\n", gNB_id);
-
-				  X2AP_DEBUG("Adding gNB to the list of associated gNBs\n");
-				  if ((x2ap_eNB_data = x2ap_is_eNB_id_in_list (gNB_id)) == NULL) {
+				  X2AP_DEBUG("Adding eNB to the list of associated eNBs\n");
+				  if ((x2ap_eNB_data = x2ap_is_eNB_id_in_list (eNB_id)) == NULL) {
 					  /*
 				       * eNB has not been found in list of associated eNB,
 				       * * * * Add it to the tail of list and initialize data
@@ -1547,7 +1574,7 @@ x2ap_gNB_handle_ENDC_x2_setup_response(instance_t instance,
 						  return -1;
 					  } else {
 						  x2ap_eNB_data->state = X2AP_ENB_STATE_RESETTING;
-						  x2ap_eNB_data->eNB_id = gNB_id;
+						  x2ap_eNB_data->eNB_id = eNB_id;
 					  }
 				  } else {
 					  x2ap_eNB_data->state = X2AP_ENB_STATE_RESETTING;
@@ -1560,9 +1587,9 @@ x2ap_gNB_handle_ENDC_x2_setup_response(instance_t instance,
 						  /*
 						   * ??: Send an overload cause...
 						   */
-						  X2AP_ERROR("Rejecting x2 setup request as eNB id %d is already associated to an active sctp association" "Previous known: %d, new one: %d\n", gNB_id, x2ap_eNB_data->assoc_id, assoc_id);
+						  X2AP_ERROR("Rejecting x2 setup request as eNB id %d is already associated to an active sctp association" "Previous known: %d, new one: %d\n", eNB_id, x2ap_eNB_data->assoc_id, assoc_id);
 
-						  // Panos: Here we should be calling an ENDC specific setup_failure function instead
+						  // Here we should be calling an ENDC specific setup_failure function instead
 						  x2ap_eNB_generate_x2_setup_failure (instance,
 				                                          assoc_id,
 				                                          X2AP_Cause_PR_protocol,
@@ -1575,26 +1602,12 @@ x2ap_gNB_handle_ENDC_x2_setup_response(instance_t instance,
 					   */
 				  }
 			  }
-			  else if (ie_GNB_ENDC->id == X2AP_ProtocolIE_ID_id_ServedNRcellsENDCX2ManagementList){
-				  if (ie_GNB_ENDC->value.choice.ServedNRcellsENDCX2ManagementList.list.count > 0) {
-				      x2ap_eNB_data->num_cc = ie_GNB_ENDC->value.choice.ServedNRcellsENDCX2ManagementList.list.count;
-				      for (int i=0; i<ie_GNB_ENDC->value.choice.ServedNRcellsENDCX2ManagementList.list.count;i++) {
-				    	  servedCellMember = (ServedNRcellsENDCX2ManagementList__Member *)ie_GNB_ENDC->value.choice.ServedNRcellsENDCX2ManagementList.list.array[i];
-				    	  x2ap_eNB_data->Nid_cell[i] = servedCellMember->servedNRCellInfo.nrpCI;
-				    	  //servedCellMember->servedNRCellInfo.nrCellID.pLMN_Identity.buf[0]
-                                          if (servedCellMember->servedNRCellInfo.fiveGS_TAC != NULL) {
-				    	    X2AP_INFO("TAC: %02x%02x%02x\n",
-				    			    servedCellMember->servedNRCellInfo.fiveGS_TAC->buf[0],
-				    			    servedCellMember->servedNRCellInfo.fiveGS_TAC->buf[1],
-				    			    servedCellMember->servedNRCellInfo.fiveGS_TAC->buf[2]);
-                                          } else {
-				    	    X2AP_INFO("TAC: (NULL)\n");
-                                          }
-
-				    	  X2AP_INFO("PLMN: %02x%02x%02x\n",
-				    			  servedCellMember->servedNRCellInfo.nrCellID.pLMN_Identity.buf[0],
-				    			  servedCellMember->servedNRCellInfo.nrCellID.pLMN_Identity.buf[1],
-				    			  servedCellMember->servedNRCellInfo.nrCellID.pLMN_Identity.buf[2]);
+			  else if (ie_ENB_ENDC->id == X2AP_ProtocolIE_ID_id_ServedEUTRAcellsENDCX2ManagementList){
+				  if (ie_ENB_ENDC->value.choice.ServedEUTRAcellsENDCX2ManagementList.list.count > 0) {
+				      x2ap_eNB_data->num_cc = ie_ENB_ENDC->value.choice.ServedEUTRAcellsENDCX2ManagementList.list.count;
+				      for (int i=0; i<ie_ENB_ENDC->value.choice.ServedEUTRAcellsENDCX2ManagementList.list.count;i++) {
+				    	  servedCellMember = (ServedEUTRAcellsENDCX2ManagementList__Member *)ie_ENB_ENDC->value.choice.ServedEUTRAcellsENDCX2ManagementList.list.array[i];
+				    	  x2ap_eNB_data->Nid_cell[i] = servedCellMember->servedEUTRACellInfo.pCI;
 				      }
 				  }
 			  }
@@ -1622,4 +1635,379 @@ x2ap_gNB_handle_ENDC_x2_setup_response(instance_t instance,
     return 0;
 }
 
+static
+int x2ap_gNB_handle_ENDC_sGNB_addition_request (instance_t instance,
+                                          uint32_t assoc_id,
+                                          uint32_t stream,
+                                          X2AP_X2AP_PDU_t *pdu)
+{
+
+
+  X2AP_SgNBAdditionRequest_t             *x2SgNBAdditionRequest;
+  X2AP_SgNBAdditionRequest_IEs_t         *ie;
+
+  X2AP_E_RABs_ToBeAdded_SgNBAddReq_ItemIEs_t 		*e_RABS_ToBeAdded_SgNBAddReq_ItemIEs;
+  X2AP_E_RABs_ToBeAdded_SgNBAddReq_Item_t         *e_RABS_ToBeAdded_SgNBAddReq_Item;
+
+  x2ap_eNB_instance_t                *instance_p;
+  x2ap_eNB_data_t                    *x2ap_eNB_data;
+  MessageDef                         *msg;
+  int                                ue_id;
+
+  DevAssert (pdu != NULL);
+  x2SgNBAdditionRequest = &pdu->choice.initiatingMessage.value.choice.SgNBAdditionRequest;
+
+  /*if (stream == 0) {
+    X2AP_ERROR ("Received new x2 SgNB Addition request on stream == 0\n");
+    // TODO: send a x2 failure response
+    return 0;
+  }*/
+
+  X2AP_DEBUG ("Received a new X2 SgNB Addition request\n");
+
+  x2ap_eNB_data = x2ap_get_eNB(NULL, assoc_id, 0);
+  DevAssert(x2ap_eNB_data != NULL);
+
+  X2AP_INFO("X2AP Association id: %d \n",assoc_id);
+
+  instance_p = x2ap_eNB_get_instance(instance);
+  DevAssert(instance_p != NULL);
+
+  //Allocate an ITTI X2AP_SGNB_ADDITION_REQ message instead
+  msg = itti_alloc_new_message(TASK_X2AP, X2AP_ENDC_SGNB_ADDITION_REQ);
+
+  /* X2AP_ProtocolIE_ID_id_MeNB_UE_X2AP_ID */
+  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBAdditionRequest_IEs_t, ie, x2SgNBAdditionRequest,
+		  X2AP_ProtocolIE_ID_id_MeNB_UE_X2AP_ID, true);
+  if (ie == NULL ) {
+    X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
+    return -1;
+  }
+
+
+  // allocate a new X2AP UE ID
+  ue_id = x2ap_allocate_new_id(&instance_p->id_manager);
+  if (ue_id == -1) {
+    X2AP_ERROR("could not allocate a new X2AP UE ID\n");
+    // TODO: cancel handover: send HO preparation failure to source eNB
+    exit(1);
+  }
+  // rnti is unknown yet, must not be set to -1, 0 is fine
+  x2ap_set_ids(&instance_p->id_manager, ue_id, 0, ie->value.choice.UE_X2AP_ID, ue_id);
+  x2ap_id_set_state(&instance_p->id_manager, ue_id, X2ID_STATE_TARGET);
+
+  X2AP_ENDC_SGNB_ADDITION_REQ(msg).ue_x2_id = ue_id;
+
+
+  /* X2AP_ProtocolIE_ID_id_NRUESecurityCapabilities */
+  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBAdditionRequest_IEs_t, ie, x2SgNBAdditionRequest,
+		  X2AP_ProtocolIE_ID_id_NRUESecurityCapabilities, true);
+
+  X2AP_ENDC_SGNB_ADDITION_REQ(msg).security_capabilities.encryption_algorithms =
+		  BIT_STRING_to_uint16(&ie->value.choice.NRUESecurityCapabilities.nRencryptionAlgorithms);
+
+  X2AP_ENDC_SGNB_ADDITION_REQ(msg).security_capabilities.integrity_algorithms =
+  		  BIT_STRING_to_uint16(&ie->value.choice.NRUESecurityCapabilities.nRintegrityProtectionAlgorithms);
+
+  /* X2AP_ProtocolIE_ID_id_SgNBSecurityKey */
+  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBAdditionRequest_IEs_t, ie, x2SgNBAdditionRequest,
+		  X2AP_ProtocolIE_ID_id_SgNBSecurityKey, true);
+
+  if ((ie->value.choice.SgNBSecurityKey.buf) &&
+            (ie->value.choice.SgNBSecurityKey.size == 32)) {
+      memcpy(X2AP_ENDC_SGNB_ADDITION_REQ(msg).kgnb, ie->value.choice.SgNBSecurityKey.buf, 32);
+    } else {
+      X2AP_WARN ("Size of eNB key star does not match the expected value\n");
+    }
+
+
+  /* X2AP_ProtocolIE_ID_id_SgNBUEAggregateMaximumBitRate */
+  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBAdditionRequest_IEs_t, ie, x2SgNBAdditionRequest,
+		  X2AP_ProtocolIE_ID_id_SgNBUEAggregateMaximumBitRate, true);
+
+  //X2AP_ENDC_SGNB_ADDITION_REQ(msg).ue_ambr.br_dl =ie->value.choice.UEAggregateMaximumBitRate.uEaggregateMaximumBitRateDownlink;
+  //X2AP_ENDC_SGNB_ADDITION_REQ(msg).ue_ambr.br_ul = ie->value.choice.UEAggregateMaximumBitRate.uEaggregateMaximumBitRateUplink;
+
+  /* X2AP_ProtocolIE_ID_id_E_RABs_ToBeAdded_SgNBAddReqList */
+  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBAdditionRequest_IEs_t, ie, x2SgNBAdditionRequest,
+		  X2AP_ProtocolIE_ID_id_E_RABs_ToBeAdded_SgNBAddReqList, true);
+
+
+  if (ie->value.choice.E_RABs_ToBeAdded_SgNBAddReqList.list.count > 0) {
+
+	  X2AP_ENDC_SGNB_ADDITION_REQ(msg).nb_e_rabs_tobeadded = ie->value.choice.E_RABs_ToBeAdded_SgNBAddReqList.list.count;
+
+    for (int i=0;i<ie->value.choice.E_RABs_ToBeAdded_SgNBAddReqList.list.count;i++) {
+      e_RABS_ToBeAdded_SgNBAddReq_ItemIEs = (X2AP_E_RABs_ToBeAdded_SgNBAddReq_ItemIEs_t *) ie->value.choice.E_RABs_ToBeAdded_SgNBAddReqList.list.array[i];
+      e_RABS_ToBeAdded_SgNBAddReq_Item = &e_RABS_ToBeAdded_SgNBAddReq_ItemIEs->value.choice.E_RABs_ToBeAdded_SgNBAddReq_Item;
+
+      X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rabs_tobeadded[i].e_rab_id = e_RABS_ToBeAdded_SgNBAddReq_Item->e_RAB_ID ;
+      X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rabs_tobeadded[i].drb_ID = e_RABS_ToBeAdded_SgNBAddReq_Item->drb_ID;
+      if(e_RABS_ToBeAdded_SgNBAddReq_Item->en_DC_ResourceConfiguration.pDCPatSgNB == X2AP_EN_DC_ResourceConfiguration__pDCPatSgNB_present){
+    	  X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rab_param[i].qos.qci = e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.full_E_RAB_Level_QoS_Parameters.qCI;
+    	  X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rab_param[i].qos.allocation_retention_priority.pre_emp_vulnerability = e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.full_E_RAB_Level_QoS_Parameters.allocationAndRetentionPriority.pre_emptionVulnerability;
+    	  X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rab_param[i].qos.allocation_retention_priority.pre_emp_capability = e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.full_E_RAB_Level_QoS_Parameters.allocationAndRetentionPriority.pre_emptionCapability;
+    	  X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rab_param[i].qos.allocation_retention_priority.priority_level = e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.full_E_RAB_Level_QoS_Parameters.allocationAndRetentionPriority.priorityLevel;
+
+          memcpy(X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rabs_tobeadded[i].eNB_addr.buffer,
+        		  e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_UL_GTPtunnelEndpoint.transportLayerAddress.buf,
+        		  e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_UL_GTPtunnelEndpoint.transportLayerAddress.size);
+
+          X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rabs_tobeadded[i].eNB_addr.length =
+        		  e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_UL_GTPtunnelEndpoint.transportLayerAddress.size * 8 - e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_UL_GTPtunnelEndpoint.transportLayerAddress.bits_unused;
+
+          OCTET_STRING_TO_INT32(&e_RABS_ToBeAdded_SgNBAddReq_Item->resource_configuration.choice.sgNBPDCPpresent.s1_UL_GTPtunnelEndpoint.gTP_TEID,
+        		  X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rabs_tobeadded[i].gtp_teid);
+      }
+
+    }
+
+  }
+  else {
+    X2AP_ERROR ("Can't decode the e_RABs_ToBeSetup_List \n");
+  }
+
+  /* X2AP_ProtocolIE_ID_id_MeNBtoSgNBContainer */
+  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBAdditionRequest_IEs_t, ie, x2SgNBAdditionRequest,
+		  X2AP_ProtocolIE_ID_id_MeNBtoSgNBContainer, true);
+
+  X2AP_MeNBtoSgNBContainer_t *container = &ie->value.choice.MeNBtoSgNBContainer;
+
+    if (ie->value.choice.MeNBtoSgNBContainer.size > 8192 ) // TODO: this is the size of rrc_buffer in struct x2ap_handover_req_s
+      { printf("%s:%d: fatal: buffer too big\n", __FILE__, __LINE__); abort(); }
+
+    memcpy(X2AP_ENDC_SGNB_ADDITION_REQ(msg).rrc_buffer, ie->value.choice.MeNBtoSgNBContainer.buf, ie->value.choice.MeNBtoSgNBContainer.size);
+    X2AP_ENDC_SGNB_ADDITION_REQ(msg).rrc_buffer_size = ie->value.choice.MeNBtoSgNBContainer.size;
+
+  itti_send_msg_to_task(TASK_RRC_GNB, instance_p->instance, msg);
+
+  return 0;
+}
+
+
+static
+int x2ap_eNB_handle_ENDC_sGNB_addition_response (instance_t instance,
+                                          uint32_t assoc_id,
+                                          uint32_t stream,
+                                          X2AP_X2AP_PDU_t *pdu)
+{
+
+	  X2AP_SgNBAdditionRequestAcknowledge_t             *x2SgNBAdditionRequest_ack;
+	  X2AP_SgNBAdditionRequestAcknowledge_IEs_t         *ie;
+
+	  X2AP_E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_ItemIEs_t 		*e_RABS_Admitted_ToBeAdded_SgNBAddReqAck_ItemIEs;
+	  X2AP_E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_Item_t           *e_RABS_Admitted_ToBeAdded_SgNBAddReqAck_Item;
+
+	  x2ap_eNB_instance_t                *instance_p;
+	  x2ap_eNB_data_t                    *x2ap_eNB_data;
+	  MessageDef                         *msg;
+	  int                                ue_id;
+          int                                id_source;
+          int                                id_target;
+          int                                rnti;
+
+	  DevAssert (pdu != NULL);
+	  x2SgNBAdditionRequest_ack = &pdu->choice.successfulOutcome.value.choice.SgNBAdditionRequestAcknowledge;
+
+	  /*if (stream == 0) {
+	    X2AP_ERROR ("Received new x2 SgNB Addition request on stream == 0\n");
+	    // TODO: send a x2 failure response
+	    return 0;
+	  }*/
+
+	  X2AP_DEBUG ("Received a new X2 SgNB Addition request\n");
+
+	  x2ap_eNB_data = x2ap_get_eNB(NULL, assoc_id, 0);
+	  DevAssert(x2ap_eNB_data != NULL);
+
+	  X2AP_INFO("X2AP Association id: %d \n",assoc_id);
+
+	  instance_p = x2ap_eNB_get_instance(instance);
+	  DevAssert(instance_p != NULL);
+
+	  //Allocate an ITTI X2AP_SGNB_ADDITION_REQ message instead
+	  msg = itti_alloc_new_message(TASK_X2AP, X2AP_ENDC_SGNB_ADDITION_REQ_ACK);
+
+	  /* X2AP_ProtocolIE_ID_id_MeNB_UE_X2AP_ID */
+	  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBAdditionRequestAcknowledge_IEs_t, ie, x2SgNBAdditionRequest_ack,
+			  X2AP_ProtocolIE_ID_id_MeNB_UE_X2AP_ID, true);
+	  if (ie == NULL ) {
+	    X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
+	    return -1;
+	  }
+
+	  id_source = ie->value.choice.UE_X2AP_ID;
+
+	  X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).MeNB_ue_x2_id = ie->value.choice.UE_X2AP_ID;
+
+
+	  /* X2AP_ProtocolIE_ID_id_SgNB_UE_X2AP_ID */
+	  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBAdditionRequestAcknowledge_IEs_t, ie, x2SgNBAdditionRequest_ack,
+			  X2AP_ProtocolIE_ID_id_SgNB_UE_X2AP_ID, true);
+	  if (ie == NULL ) {
+		  X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
+		  return -1;
+	  }
+
+	  id_target = ie->value.choice.SgNB_UE_X2AP_ID;
+
+          ue_id = id_source;
+
+          if (ue_id != x2ap_find_id_from_id_source(&instance_p->id_manager, id_source)) {
+            X2AP_WARN("incorrect/unknown X2AP IDs for UE (old ID %d new ID %d), ignoring sGNB addition response\n",
+                      id_source, id_target);
+            itti_free(ITTI_MSG_ORIGIN_ID(msg), msg);
+            return 0;
+          }
+
+          rnti = x2ap_id_get_rnti(&instance_p->id_manager, ue_id);
+
+          /* id_target is a new information, store it */
+          x2ap_set_ids(&instance_p->id_manager, ue_id, rnti, id_source, id_target);
+
+	  X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).rnti = rnti;
+
+	  X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).SgNB_ue_x2_id = ie->value.choice.SgNB_UE_X2AP_ID;
+
+	  /* X2AP_ProtocolIE_ID_id_E_RABs_ToBeAdded_SgNBAddReqList */
+	  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBAdditionRequestAcknowledge_IEs_t, ie, x2SgNBAdditionRequest_ack,
+			  X2AP_ProtocolIE_ID_id_E_RABs_Admitted_ToBeAdded_SgNBAddReqAckList, true);
+
+	  if (ie == NULL ) {
+		  X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
+		  return -1;
+	  }
+
+
+	  if (ie->value.choice.E_RABs_Admitted_ToBeAdded_SgNBAddReqAckList.list.count > 0) {
+
+		  X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).nb_e_rabs_admitted_tobeadded = ie->value.choice.E_RABs_Admitted_ToBeAdded_SgNBAddReqAckList.list.count;
+
+	    for (int i=0;i<ie->value.choice.E_RABs_Admitted_ToBeAdded_SgNBAddReqAckList.list.count;i++) {
+
+	    	e_RABS_Admitted_ToBeAdded_SgNBAddReqAck_ItemIEs = (X2AP_E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_ItemIEs_t *) ie->value.choice.E_RABs_Admitted_ToBeAdded_SgNBAddReqAckList.list.array[i];
+	    	e_RABS_Admitted_ToBeAdded_SgNBAddReqAck_Item = &e_RABS_Admitted_ToBeAdded_SgNBAddReqAck_ItemIEs->value.choice.E_RABs_Admitted_ToBeAdded_SgNBAddReqAck_Item;
+
+	    	X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).e_rabs_admitted_tobeadded[i].e_rab_id = e_RABS_Admitted_ToBeAdded_SgNBAddReqAck_Item->e_RAB_ID ;
+	    	if(e_RABS_Admitted_ToBeAdded_SgNBAddReqAck_Item->en_DC_ResourceConfiguration.pDCPatSgNB == X2AP_EN_DC_ResourceConfiguration__pDCPatSgNB_present){
+
+	          memcpy(X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).e_rabs_admitted_tobeadded[i].eNB_addr.buffer,
+	        		  e_RABS_Admitted_ToBeAdded_SgNBAddReqAck_Item->resource_configuration.choice.sgNBPDCPpresent.s1_DL_GTPtunnelEndpoint.transportLayerAddress.buf,
+	        		  e_RABS_Admitted_ToBeAdded_SgNBAddReqAck_Item->resource_configuration.choice.sgNBPDCPpresent.s1_DL_GTPtunnelEndpoint.transportLayerAddress.size);
+	          X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).e_rabs_admitted_tobeadded[i].eNB_addr.length =
+	        		  e_RABS_Admitted_ToBeAdded_SgNBAddReqAck_Item->resource_configuration.choice.sgNBPDCPpresent.s1_DL_GTPtunnelEndpoint.transportLayerAddress.size * 8 - e_RABS_Admitted_ToBeAdded_SgNBAddReqAck_Item->resource_configuration.choice.sgNBPDCPpresent.s1_DL_GTPtunnelEndpoint.transportLayerAddress.bits_unused;
+
+	          OCTET_STRING_TO_INT32(&e_RABS_Admitted_ToBeAdded_SgNBAddReqAck_Item->resource_configuration.choice.sgNBPDCPpresent.s1_DL_GTPtunnelEndpoint.gTP_TEID,
+	        		  X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).e_rabs_admitted_tobeadded[i].gtp_teid);
+	      }
+
+	    }
+
+	  }
+	  else {
+	    X2AP_ERROR ("Can't decode the e_RABs_ToBeSetup_List \n");
+	  }
+
+	  /* X2AP_ProtocolIE_ID_id_SgNBtoMeNBContainer */
+
+	  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBAdditionRequestAcknowledge_IEs_t, ie, x2SgNBAdditionRequest_ack,
+			  X2AP_ProtocolIE_ID_id_SgNBtoMeNBContainer, true);
+
+	  if (ie == NULL ) {
+		  X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
+		  return -1;
+	  }
+
+	  //X2AP_MeNBtoSgNBContainer_t *container = &ie->value.choice.MeNBtoSgNBContainer;
+
+	    if (ie->value.choice.SgNBtoMeNBContainer.size > 8192 ) // TODO: this is the size of rrc_buffer in struct x2ap_handover_req_s
+	      { printf("%s:%d: fatal: buffer too big\n", __FILE__, __LINE__); abort(); }
+
+	    memcpy(X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).rrc_buffer, ie->value.choice.SgNBtoMeNBContainer.buf, ie->value.choice.SgNBtoMeNBContainer.size);
+	    X2AP_ENDC_SGNB_ADDITION_REQ_ACK(msg).rrc_buffer_size = ie->value.choice.SgNBtoMeNBContainer.size;
+
+	  itti_send_msg_to_task(TASK_RRC_ENB, instance_p->instance, msg);
+
+	  return 0;
+}
+
+static
+int x2ap_gNB_handle_ENDC_sGNB_reconfiguration_complete (instance_t instance,
+                                          uint32_t assoc_id,
+                                          uint32_t stream,
+                                          X2AP_X2AP_PDU_t *pdu) {
+
+	X2AP_SgNBReconfigurationComplete_t               *x2SgNBReconfigurationComplete;
+	X2AP_SgNBReconfigurationComplete_IEs_t           *ie;
+
+	x2ap_eNB_instance_t                *instance_p;
+	x2ap_eNB_data_t                    *x2ap_eNB_data;
+	MessageDef                         *msg;
+	int                                ue_id;
+
+		  DevAssert (pdu != NULL);
+		  x2SgNBReconfigurationComplete = &pdu->choice.initiatingMessage.value.choice.SgNBReconfigurationComplete;
+
+		  /*if (stream == 0) {
+		    X2AP_ERROR ("Received new x2 SgNB Addition request on stream == 0\n");
+		    // TODO: send a x2 failure response
+		    return 0;
+		  }*/
+
+		  X2AP_DEBUG ("Received X2 SgNB Reconfiguration complete message\n");
+
+		  x2ap_eNB_data = x2ap_get_eNB(NULL, assoc_id, 0);
+		  DevAssert(x2ap_eNB_data != NULL);
+
+		  X2AP_INFO("X2AP Association id: %d \n",assoc_id);
+
+		  instance_p = x2ap_eNB_get_instance(instance);
+		  DevAssert(instance_p != NULL);
+
+		  //Allocate an ITTI X2AP_SGNB_ADDITION_REQ message instead
+		  msg = itti_alloc_new_message(TASK_X2AP, X2AP_ENDC_SGNB_RECONF_COMPLETE);
+
+		  /* X2AP_ProtocolIE_ID_id_MeNB_UE_X2AP_ID */
+		  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBReconfigurationComplete_IEs_t, ie, x2SgNBReconfigurationComplete,
+				  X2AP_ProtocolIE_ID_id_MeNB_UE_X2AP_ID, true);
+		  if (ie == NULL ) {
+		    X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
+		    return -1;
+		  }
+
+		  X2AP_ENDC_SGNB_RECONF_COMPLETE(msg).MeNB_ue_x2_id = ie->value.choice.UE_X2AP_ID;
+
+
+		  /* X2AP_ProtocolIE_ID_id_SgNB_UE_X2AP_ID */
+		  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBReconfigurationComplete_IEs_t, ie, x2SgNBReconfigurationComplete,
+				  X2AP_ProtocolIE_ID_id_SgNB_UE_X2AP_ID, true);
+		  if (ie == NULL ) {
+			  X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
+			  return -1;
+		  }
+
+		  X2AP_ENDC_SGNB_RECONF_COMPLETE(msg).SgNB_ue_x2_id = ie->value.choice.SgNB_UE_X2AP_ID;
+
+
+		  X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBReconfigurationComplete_IEs_t, ie, x2SgNBReconfigurationComplete,
+				  X2AP_ProtocolIE_ID_id_ResponseInformationSgNBReconfComp, true);
+		  if (ie == NULL ) {
+			  X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
+			  return -1;
+		  }
+
+		  if(ie->value.choice.ResponseInformationSgNBReconfComp.present == X2AP_ResponseInformationSgNBReconfComp_PR_success_SgNBReconfComp){
+			  X2AP_ENDC_SGNB_RECONF_COMPLETE(msg).reconf_response = X2AP_RECONF_RESPONSE_SUCCESS;
+		  }
+		  else {
+			  X2AP_ENDC_SGNB_RECONF_COMPLETE(msg).reconf_response = X2AP_RECONF_RESPONSE_REJECT;
+		  }
+
+		  itti_send_msg_to_task(TASK_RRC_GNB, instance_p->instance, msg);
+
+
+	return 0;
+}
+
+
 
diff --git a/openair2/X2AP/x2ap_ids.h b/openair2/X2AP/x2ap_ids.h
index 3d2799e8c46..f2670f3612b 100644
--- a/openair2/X2AP/x2ap_ids.h
+++ b/openair2/X2AP/x2ap_ids.h
@@ -37,7 +37,8 @@
 typedef enum {
   X2ID_STATE_SOURCE_PREPARE,
   X2ID_STATE_SOURCE_OVERALL,
-  X2ID_STATE_TARGET
+  X2ID_STATE_TARGET,
+  X2ID_STATE_NSA_PREPARE,
 } x2id_state_t;
 
 typedef struct {
diff --git a/openair3/NAS/COMMON/UTIL/nas_log.h b/openair3/NAS/COMMON/UTIL/nas_log.h
index b41e34c51be..d1531fa6db1 100644
--- a/openair3/NAS/COMMON/UTIL/nas_log.h
+++ b/openair3/NAS/COMMON/UTIL/nas_log.h
@@ -95,14 +95,15 @@ typedef enum {
 /******************  E X P O R T E D    F U N C T I O N S  ******************/
 /****************************************************************************/
 
+#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
 #ifdef LOG_E
 # define LOG_TRACE(s, x, args...)                               \
 do {                                                            \
     switch (s) {                                                \
-        case ERROR:     LOG_E(NAS, " %s:%d  " x "\n", __FILE__, __LINE__, ##args); break;  \
-        case WARNING:   LOG_W(NAS, " %s:%d  " x "\n", __FILE__, __LINE__, ##args); break;  \
-        case INFO:      LOG_I(NAS, " %s:%d  " x "\n", __FILE__, __LINE__, ##args); break;  \
-        default:        LOG_D(NAS, " %s:%d  " x "\n", __FILE__, __LINE__, ##args); break;  \
+        case ERROR:     LOG_E(NAS, " %s:%d  " x "\n", __FILENAME__, __LINE__, ##args); break;  \
+        case WARNING:   LOG_W(NAS, " %s:%d  " x "\n", __FILENAME__, __LINE__, ##args); break;  \
+        case INFO:      LOG_I(NAS, " %s:%d  " x "\n", __FILENAME__, __LINE__, ##args); break;  \
+        default:        LOG_D(NAS, " %s:%d  " x "\n", __FILENAME__, __LINE__, ##args); break;  \
     }                                                           \
 } while (0)
 
diff --git a/openair3/NAS/UE/EMM/SecurityModeControl.c b/openair3/NAS/UE/EMM/SecurityModeControl.c
index 7bdd21572e2..67bfaf784e6 100644
--- a/openair3/NAS/UE/EMM/SecurityModeControl.c
+++ b/openair3/NAS/UE/EMM/SecurityModeControl.c
@@ -286,7 +286,7 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
       user->emm_data->security->selected_algorithms.encryption = seea;
       user->emm_data->security->selected_algorithms.integrity  = seia;
 #if  defined(NAS_BUILT_IN_UE)
-      nas_itti_kenb_refresh_req(security_data->kenb.value);
+      nas_itti_kenb_refresh_req(security_data->kenb.value, user->ueid);
 #endif
 
     }
diff --git a/openair3/NAS/UE/nas_itti_messaging.c b/openair3/NAS/UE/nas_itti_messaging.c
index 55566700d7b..885ebbdd81f 100644
--- a/openair3/NAS/UE/nas_itti_messaging.c
+++ b/openair3/NAS/UE/nas_itti_messaging.c
@@ -100,7 +100,7 @@ int nas_itti_protected_msg(const char *buffer, const nas_message_t *msg, const i
 
 extern unsigned char NB_eNB_INST;
 
-int nas_itti_kenb_refresh_req(const Byte_t kenb[32]) {
+int nas_itti_kenb_refresh_req(const Byte_t kenb[32], int user_id) {
   MessageDef *message_p;
   message_p = itti_alloc_new_message(TASK_NAS_UE, NAS_KENB_REFRESH_REQ);
   memcpy(NAS_KENB_REFRESH_REQ(message_p).kenb, kenb, sizeof(NAS_KENB_REFRESH_REQ(message_p).kenb));
@@ -125,7 +125,7 @@ int nas_itti_kenb_refresh_req(const Byte_t kenb[32]) {
     kenb[20], kenb[21], kenb[22], kenb[23],
     kenb[24], kenb[25], kenb[26], kenb[27],
     kenb[28], kenb[29], kenb[30], kenb[31]);
-  return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + 0 /* TODO to be virtualized */, message_p);
+  return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + user_id, message_p);
 }
 
 int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat, int user_id) {
diff --git a/openair3/NAS/UE/nas_itti_messaging.h b/openair3/NAS/UE/nas_itti_messaging.h
index d958317e5a1..967bbb30596 100644
--- a/openair3/NAS/UE/nas_itti_messaging.h
+++ b/openair3/NAS/UE/nas_itti_messaging.h
@@ -48,7 +48,7 @@ int nas_itti_protected_msg(
 
 # if defined(NAS_BUILT_IN_UE)
 
-int nas_itti_kenb_refresh_req(const Byte_t kenb[32]);
+int nas_itti_kenb_refresh_req(const Byte_t kenb[32], int user_id);
 
 int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat, int user_id);
 
diff --git a/openair3/UTILS/conversions.h b/openair3/UTILS/conversions.h
index e39a841d965..d28c9acccb2 100644
--- a/openair3/UTILS/conversions.h
+++ b/openair3/UTILS/conversions.h
@@ -116,8 +116,14 @@ do {                                \
 #define INT16_TO_OCTET_STRING(x, aSN)           \
 do {                                            \
     (aSN)->buf = calloc(2, sizeof(uint8_t));    \
-    (aSN)->size = 2;              \
-    INT16_TO_BUFFER(x, (aSN)->buf);             \
+    INT16_TO_BUFFER(x, ((aSN)->buf));           \
+    (aSN)->size = 2;                            \
+} while(0)
+
+#define INT16_TO_BIT_STRING(x, aSN) \
+do {                                \
+    INT16_TO_OCTET_STRING(x, aSN);  \
+    (aSN)->bits_unused = 0;         \
 } while(0)
 
 #define INT8_TO_OCTET_STRING(x, aSN)            \
diff --git a/targets/ARCH/COMMON/common_lib.c b/targets/ARCH/COMMON/common_lib.c
index 757ad6f75de..3066f0906fd 100644
--- a/targets/ARCH/COMMON/common_lib.c
+++ b/targets/ARCH/COMMON/common_lib.c
@@ -37,6 +37,7 @@
 #include <stdlib.h>
 
 #include "common_lib.h"
+#include "assertions.h"
 #include "common/utils/load_module_shlib.h"
 #include "common/utils/LOG/log.h"
 #include "targets/RT/USER/lte-softmodem.h"
@@ -91,38 +92,44 @@ int load_lib(openair0_device *device,
 {
   loader_shlibfunc_t shlib_fdesc[1];
   int ret=0;
-  char *libname;
+  char *deflibname=OAI_RF_LIBNAME;
   
   openair0_cfg->recplay_mode = read_recplayconfig(&(openair0_cfg->recplay_conf),&(device->recplay_state));
 
   if ( openair0_cfg->recplay_mode == RECPLAY_REPLAYMODE ) {
-  	  libname=OAI_IQPLAYER_LIBNAME;
+  	  deflibname=OAI_IQPLAYER_LIBNAME;
   	  shlib_fdesc[0].fname="device_init";
   	  set_softmodem_optmask(SOFTMODEM_RECPLAY_BIT);  // softmodem has to know we use the iqplayer to workaround randomized algorithms
   } else  if ( IS_SOFTMODEM_BASICSIM ) {
-	  libname=OAI_BASICSIM_LIBNAME;
+	  deflibname=OAI_BASICSIM_LIBNAME;
 	  shlib_fdesc[0].fname="device_init";
   } else if (IS_SOFTMODEM_RFSIM && flag == RAU_LOCAL_RADIO_HEAD) {
-	  libname=OAI_RFSIM_LIBNAME;
+	  deflibname=OAI_RFSIM_LIBNAME;
 	  shlib_fdesc[0].fname="device_init";
   } else if (flag == RAU_LOCAL_RADIO_HEAD) {
 	  if (IS_SOFTMODEM_RFSIM)
-		  libname="rfsimulator";
+		  deflibname="rfsimulator";
 	  else
-          libname=OAI_RF_LIBNAME;
+          deflibname=OAI_RF_LIBNAME;
       shlib_fdesc[0].fname="device_init";
   } else {
-	  libname=OAI_TP_LIBNAME;
+	  deflibname=OAI_TP_LIBNAME;
 	  shlib_fdesc[0].fname="transport_init";
   }
-  ret=load_module_shlib(libname,shlib_fdesc,1,NULL);
+  
+  char *devname=NULL;
+  paramdef_t device_params[]=DEVICE_PARAMS_DESC ;
+  int numparams = sizeof(device_params)/sizeof(paramdef_t);
+  int devname_pidx = config_paramidx_fromname(device_params,numparams, CONFIG_DEVICEOPT_NAME);
+  device_params[devname_pidx].defstrval=deflibname;
+  
+  config_get(device_params,numparams,DEVICE_SECTION);
+  
+  ret=load_module_shlib(devname,shlib_fdesc,1,NULL);
+  AssertFatal( (ret >= 0),
+  	           "Library %s couldn't be loaded\n",devname);
 
-  if (ret < 0) {
-    LOG_E(HW,"Library %s couldn't be loaded\n",libname);
-  } else {
-    ret=((devfunc_t)shlib_fdesc[0].fptr)(device,openair0_cfg,cfg);
-  }
-  return ret;
+  return ((devfunc_t)shlib_fdesc[0].fptr)(device,openair0_cfg,cfg);
 }
 
 
diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h
index 7e51bdc81a6..ecadb68c0ca 100644
--- a/targets/ARCH/COMMON/common_lib.h
+++ b/targets/ARCH/COMMON/common_lib.h
@@ -448,6 +448,24 @@ typedef struct {
 extern "C"
 {
 #endif
+
+
+#define  DEVICE_SECTION   "device"
+#define  CONFIG_HLP_DEVICE  "Identifies the oai device (the interface to RF) to use, the shared lib \"lib_<name>.so\" will be loaded"
+
+#define  CONFIG_DEVICEOPT_NAME "name"
+
+/* inclusion for device configuration */
+/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+/*                                            config parameters for oai device                                                                                               */
+/*   optname                     helpstr                paramflags                      XXXptr                  defXXXval                            type           numelt   */
+/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
+#define DEVICE_PARAMS_DESC {\
+    { CONFIG_DEVICEOPT_NAME,      CONFIG_HLP_DEVICE,          0,                strptr:&devname,                 defstrval:NULL,         TYPE_STRING,     0}\
+}
+
+
+
 /*! \brief get device name from device type */
 char *get_devname(int devtype);
 /*! \brief Initialize openair RF target. It returns 0 if OK */
diff --git a/targets/ARCH/COMMON/record_player.h b/targets/ARCH/COMMON/record_player.h
index 903dda006b0..500acdd7099 100644
--- a/targets/ARCH/COMMON/record_player.h
+++ b/targets/ARCH/COMMON/record_player.h
@@ -37,19 +37,6 @@
 extern "C"
 {
 #endif
-#define CONFIG_OPT_RECPLAY "enable_recplay"
-
-#define  CONFIG_HLP_RECPLAY  "Allow record player"
-#define USRP_SECTION "device.usrp"
-/* inclusion for device configuration */
-/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-/*                                            command line parameters for USRP record/playback                                                                               */
-/*   optname                     helpstr                paramflags                      XXXptr                  defXXXval                            type           numelt   */
-/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-#define DEVICE_PARAMS_DESC {  \
-    {CONFIG_OPT_RECPLAY,      CONFIG_HLP_RECPLAY, PARAMFLAG_BOOL,   uptr:&enable_recplay,                 defuintval:0,                    TYPE_UINT,     0} \
-  }
-
 
 /* inclusions for record player */
 #define RECPLAY_DISABLED     0
@@ -114,7 +101,7 @@ typedef struct {
     {CONFIG_OPT_SF_LOOPS,     CONFIG_HLP_SF_LOOPS,  0,                uptr:&((*recplay_conf)->u_sf_loops),                defintval:DEF_SF_NB_LOOP,        TYPE_UINT,   0}, \
     {CONFIG_OPT_SF_RDELAY,    CONFIG_HLP_SF_RDELAY, 0,                uptr:&((*recplay_conf)->u_sf_read_delay),           defintval:DEF_SF_DELAY_READ,     TYPE_UINT,   0}, \
     {CONFIG_OPT_SF_WDELAY,    CONFIG_HLP_SF_WDELAY, 0,                uptr:&((*recplay_conf)->u_sf_write_delay),          defintval:DEF_SF_DELAY_WRITE,    TYPE_UINT,   0}, \
-  }/*! \brief USRP Configuration and state */
+  }/*! \brief Record Player Configuration and state */
 typedef struct {
   char            u_sf_filename[1024];              // subframes file path
   unsigned int    u_sf_max ;                  // max number of recorded subframes
diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
index 5135be0cd49..f37c8cf5cf5 100644
--- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
+++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
@@ -270,14 +270,17 @@ static int trx_usrp_start(openair0_device *device) {
 
   // setup GPIO for TDD, GPIO(4) = ATR_RX
   //set data direction register (DDR) to output
-  s->usrp->set_gpio_attr("FP0", "DDR", 0x7f, 0x7f);
-  //set control register to ATR
-  s->usrp->set_gpio_attr("FP0", "CTRL", 0x7f,0x7f);
+  s->usrp->set_gpio_attr("FP0", "DDR", 0xfff, 0xfff);
+  //set lower 7 bits to be controlled automatically by ATR (the rest 5 bits are controlled manually) 
+  s->usrp->set_gpio_attr("FP0", "CTRL", 0x7f,0xfff);
   //set pins 4 (RX_TX_Switch) and 6 (Shutdown PA) to 1 when the radio is only receiving (ATR_RX)
   s->usrp->set_gpio_attr("FP0", "ATR_RX", (1<<4)|(1<<6), 0x7f);
   // set pin 5 (Shutdown LNA) to 1 when the radio is transmitting and receiveing (ATR_XX)
   // (we use full duplex here, because our RX is on all the time - this might need to change later)
   s->usrp->set_gpio_attr("FP0", "ATR_XX", (1<<5), 0x7f);
+  // set the output pins to 0
+  s->usrp->set_gpio_attr("FP0", "OUT", 7<<7, 0xf80);
+
   // init recv and send streaming
   uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
   LOG_I(HW,"Time in secs now: %llu \n", s->usrp->get_time_now().to_ticks(s->sample_rate));
@@ -326,10 +329,19 @@ static void trx_usrp_end(openair0_device *device) {
       @param antenna_id index of the antenna if the device has multiple antennas
       @param flags flags must be set to TRUE if timestamp parameter needs to be applied
 */
-static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) {
+static int trx_usrp_write(openair0_device *device,
+			  openair0_timestamp timestamp,
+			  void **buff,
+			  int nsamps,
+			  int cc,
+			  int flags) {
   int ret=0;
   usrp_state_t *s = (usrp_state_t *)device->priv;
   int nsamps2;  // aligned to upper 32 or 16 byte boundary
+
+  int flags_lsb = flags&0xff;
+  int flags_msb = (flags>>8)&0xff;
+    
 #if defined(__x86_64) || defined(__i386__)
   #ifdef __AVX2__
       nsamps2 = (nsamps+7)>>3;
@@ -363,40 +375,51 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp,
 
     boolean_t first_packet_state=false,last_packet_state=false;
 
-    if (flags == 2) { // start of burst
+    if (flags_lsb == 2) { // start of burst
       //      s->tx_md.start_of_burst = true;
       //      s->tx_md.end_of_burst = false;
       first_packet_state = true;
       last_packet_state  = false;
-    } else if (flags == 3) { // end of burst
+    } else if (flags_lsb == 3) { // end of burst
       //s->tx_md.start_of_burst = false;
       //s->tx_md.end_of_burst = true;
       first_packet_state = false;
       last_packet_state  = true;
-    } else if (flags == 4) { // start and end
-      //  s->tx_md.start_of_burst = true;
-      //  s->tx_md.end_of_burst = true;
+    } else if (flags_lsb == 4) { // start and end
+    //  s->tx_md.start_of_burst = true;
+    //  s->tx_md.end_of_burst = true;
       first_packet_state = true;
       last_packet_state  = true;
-    } else if (flags==1) { // middle of burst
-      //  s->tx_md.start_of_burst = false;
-      //  s->tx_md.end_of_burst = false;
+    } else if (flags_lsb==1) { // middle of burst
+    //  s->tx_md.start_of_burst = false;
+    //  s->tx_md.end_of_burst = false;
       first_packet_state = false;
       last_packet_state  = false;
-    } else if (flags==10) { // fail safe mode
-      // s->tx_md.has_time_spec = false;
-      // s->tx_md.start_of_burst = false;
-      // s->tx_md.end_of_burst = true;
-      first_packet_state = false;
-      last_packet_state  = true;
+    }
+    else if (flags_lsb==10) { // fail safe mode
+     // s->tx_md.has_time_spec = false;
+     // s->tx_md.start_of_burst = false;
+     // s->tx_md.end_of_burst = true;
+     first_packet_state = false;
+     last_packet_state  = true;
     }
 
+    
     s->tx_md.has_time_spec  = true;
     s->tx_md.start_of_burst = (s->tx_count==0) ? true : first_packet_state;
     s->tx_md.end_of_burst   = last_packet_state;
     s->tx_md.time_spec      = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate);
     s->tx_count++;
 
+    // bit 3 enables gpio (for backward compatibility)
+    if (flags_msb&8) {
+      // push GPIO bits 7-9 from flags_msb
+      int gpio789=(flags_msb&7)<<7;
+      s->usrp->set_command_time(s->tx_md.time_spec);
+      s->usrp->set_gpio_attr("FP0", "OUT", gpio789, 0x380);
+      s->usrp->clear_command_time();
+    }
+
     if (cc>1) {
       std::vector<void *> buff_ptrs;
 
@@ -404,7 +427,11 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp,
         buff_ptrs.push_back(&(((int16_t *)buff_tx[i])[0]));
 
       ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md);
-    } else ret = (int)s->tx_stream->send(&(((int16_t *)buff_tx[0])[0]), nsamps, s->tx_md);
+    } 
+    else {
+      ret = (int)s->tx_stream->send(&(((int16_t *)buff_tx[0])[0]), nsamps, s->tx_md);
+    }
+
   if (ret != nsamps) LOG_E(HW,"[xmit] tx samples %d != %d\n",ret,nsamps);
 
   return ret;
@@ -1116,4 +1143,4 @@ extern "C" {
   return 0;
 }
 /*@}*/
-}/* extern c */
\ No newline at end of file
+}/* extern c */
diff --git a/targets/ARCH/iqplayer/iqplayer_lib.c b/targets/ARCH/iqplayer/iqplayer_lib.c
index beb05de3fdb..c4133d1b116 100644
--- a/targets/ARCH/iqplayer/iqplayer_lib.c
+++ b/targets/ARCH/iqplayer/iqplayer_lib.c
@@ -25,6 +25,7 @@
  */
 #define _LARGEFILE_SOURCE
 #define _FILE_OFFSET_BITS 64
+#define NB_ANTENNAS_RX  2
 #include <string.h>
 #include <pthread.h>
 #include <unistd.h>
@@ -45,7 +46,9 @@
 
 
 static void parse_iqfile_header(openair0_device *device, iqfile_header_t *iq_fh) {
-  AssertFatal((memcmp(iq_fh->oaiid,OAIIQFILE_ID,sizeof(OAIIQFILE_ID)) == 0),"iqfile doesn't seem to be compatible with oai (invalid id in header)\n");
+  AssertFatal((memcmp(iq_fh->oaiid,OAIIQFILE_ID,sizeof(OAIIQFILE_ID)) == 0),
+  	           "iqfile doesn't seem to be compatible with oai (invalid id %.4s in header)\n",
+  	           iq_fh->oaiid);
   device->type = iq_fh->devtype;
   device->openair0_cfg[0].tx_sample_advance=iq_fh->tx_sample_advance;
   device->openair0_cfg[0].tx_bw =  device->openair0_cfg[0].rx_bw = iq_fh->bw;
@@ -138,6 +141,13 @@ static int iqplayer_loadfile(openair0_device *device, openair0_config_t *openair
   return 0;
 }
 
+/*! \brief start the oai iq player
+ * \param device, the hardware used
+ */
+static int trx_iqplayer_start(openair0_device *device){
+	return 0;
+}
+
 /*! \brief Terminate operation of the oai iq player
  * \param device, the hardware used
  */
@@ -287,7 +297,7 @@ static int trx_iqplayer_read(openair0_device *device, openair0_timestamp *ptimes
 
 int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
   device->openair0_cfg = openair0_cfg;
-  device->trx_start_func = NULL;
+  device->trx_start_func = trx_iqplayer_start;
   device->trx_get_stats_func = NULL;
   device->trx_reset_stats_func = NULL;
   device->trx_end_func   = trx_iqplayer_end;
diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c
index 906314a67cc..54dfd3b888a 100644
--- a/targets/ARCH/rfsimulator/simulator.c
+++ b/targets/ARCH/rfsimulator/simulator.c
@@ -478,9 +478,9 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
       }
 
       if ( b->headerMode==false ) {
-        LOG_D(HW,"UEsock: %d Set b->lastReceivedTS %ld\n", fd, b->lastReceivedTS);
         if ( ! b->trashingPacket ) {
           b->lastReceivedTS=b->th.timestamp+b->th.size-byteToSample(b->remainToTransfer,b->th.nbAnt);
+          LOG_D(HW,"UEsock: %d Set b->lastReceivedTS %ld\n", fd, b->lastReceivedTS);
         }
 
         if ( b->remainToTransfer==0) {
diff --git a/targets/COMMON/openairinterface5g_limits.h b/targets/COMMON/openairinterface5g_limits.h
index 42752b44e0a..aa99eee048d 100644
--- a/targets/COMMON/openairinterface5g_limits.h
+++ b/targets/COMMON/openairinterface5g_limits.h
@@ -21,21 +21,18 @@
 #                    define NUMBER_OF_CONNECTED_gNB_MAX 1
 #            	 else
 #                    define NUMBER_OF_UE_MAX 256
-#                    define NUMBER_OF_NR_UE_MAX 16
 #                    define NUMBER_OF_UCI_VARS_MAX 256
 #                    define NUMBER_OF_CONNECTED_eNB_MAX 1
 #                    define NUMBER_OF_CONNECTED_gNB_MAX 3
 #                endif
 #            else
 #                    define NUMBER_OF_UE_MAX 256
-#                    define NUMBER_OF_NR_UE_MAX 256
 #                    define NUMBER_OF_UCI_VARS_MAX 256
 #                    define NUMBER_OF_CONNECTED_eNB_MAX 1
 #                    define NUMBER_OF_CONNECTED_gNB_MAX 1
 #            endif
 #        else
 #                    define NUMBER_OF_UE_MAX 1
-#                    define NUMBER_OF_NR_UE_MAX 1
 #                    define NUMBER_OF_UCI_VARS_MAX 56
 #                    define NUMBER_OF_CONNECTED_eNB_MAX 1
 #                    define NUMBER_OF_CONNECTED_gNB_MAX 1
@@ -53,20 +50,17 @@ and the other are using MAX_MOBILES_PER_ENB in for-loop.
 */
 #            ifndef UESIM_EXPANSION
 #                define NUMBER_OF_UE_MAX 16
-#                define NUMBER_OF_NR_UE_MAX 20
 #                define NUMBER_OF_UCI_VARS_MAX 56
 #                define NUMBER_OF_CONNECTED_eNB_MAX 3
 #                define NUMBER_OF_CONNECTED_gNB_MAX 3
 #            else
 #                define NUMBER_OF_UE_MAX 256
-#                define NUMBER_OF_NR_UE_MAX 20
 #                define NUMBER_OF_UCI_VARS_MAX 256
 #                define NUMBER_OF_CONNECTED_eNB_MAX 1
 #                define NUMBER_OF_CONNECTED_gNB_MAX 3
 #            endif
 #        else
 #                define NUMBER_OF_UE_MAX 256
-#                define NUMBER_OF_NR_UE_MAX 256
 #                define NUMBER_OF_UCI_VARS_MAX 256
 #                define NUMBER_OF_CONNECTED_eNB_MAX 1
 #                define NUMBER_OF_CONNECTED_gNB_MAX 1
@@ -76,7 +70,6 @@ and the other are using MAX_MOBILES_PER_ENB in for-loop.
 #            undef  NUMBER_OF_gNB_MAX
 
 #            undef  NUMBER_OF_UE_MAX
-#            undef  NUMBER_OF_NR_UE_MAX
 
 #            undef  NUMBER_OF_RU_MAX
 #            undef  NUMBER_OF_NR_RU_MAX
@@ -85,7 +78,6 @@ and the other are using MAX_MOBILES_PER_ENB in for-loop.
 #            define NUMBER_OF_gNB_MAX 3
 
 #            define NUMBER_OF_UE_MAX 3
-#            define NUMBER_OF_NR_UE_MAX 3
 
 #            define NUMBER_OF_RU_MAX 3
 #            define NUMBER_OF_NR_RU_MAX 3
@@ -95,7 +87,6 @@ and the other are using MAX_MOBILES_PER_ENB in for-loop.
 #            undef  NUMBER_OF_gNB_MAX
 
 #            undef  NUMBER_OF_UE_MAX
-#            undef  NUMBER_OF_NR_UE_MAX
 
 #            undef  NUMBER_OF_CONNECTED_eNB_MAX
 #            undef  NUMBER_OF_CONNECTED_gNB_MAX
@@ -107,7 +98,6 @@ and the other are using MAX_MOBILES_PER_ENB in for-loop.
 #            define NUMBER_OF_gNB_MAX 2
 
 #            define NUMBER_OF_UE_MAX 120
-#            define NUMBER_OF_NR_UE_MAX 120
 
 #            define NUMBER_OF_RU_MAX 16
 #            define NUMBER_OF_NR_RU_MAX 16
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf
index b98adf5a95e..904a4556007 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf
@@ -21,183 +21,166 @@ gNBs =
 
     ////////// Physical parameters:
 
-    component_carriers = (
-      {
-      node_function                                                 = "3GPP_gNODEB";
-      node_timing                                                   = "synch_to_ext_device";
-      node_synch_ref                                                = 0;
-      frame_type                                                    = "TDD";
-      DL_prefix_type                                                = "NORMAL";
-      UL_prefix_type                                                = "NORMAL";
-      eutra_band                                                    = 78;
-      downlink_frequency                                            = 3510000000L;
-      uplink_frequency_offset                                       = -120000000;
-      Nid_cell                                                      = 0;
-      N_RB_DL                                                       = 106;
-      nb_antenna_ports                                              = 1;
-      nb_antennas_tx                                                = 1;
-      nb_antennas_rx                                                = 1;
-      tx_gain                                                       = 90;
-      rx_gain                                                       = 125;
-      MIB_subCarrierSpacingCommon                                   = 30;
-      MIB_ssb_SubcarrierOffset                                      = 0;
-      MIB_dmrs_TypeA_Position                                       = 2;
-      pdcch_ConfigSIB1                                              = 0;
-      SIB1_frequencyOffsetSSB                                       = "khz5";
-      SIB1_ssb_PeriodicityServingCell                               = 5;
-      SIB1_ss_PBCH_BlockPower                                       = -60;
-      absoluteFrequencySSB                                          = 0;
-      DL_FreqBandIndicatorNR                                        = 15;
-      DL_absoluteFrequencyPointA                                    = 15;
-      DL_offsetToCarrier                                            = 15;
-      DL_SCS_SubcarrierSpacing                                      = "kHz30";
-      DL_SCS_SpecificCarrier_k0                                     = 0;
-      DL_carrierBandwidth                                           = 15;
-      DL_locationAndBandwidth                                       = 15;
-      DL_BWP_SubcarrierSpacing                                      = "kHz30";
-      DL_BWP_prefix_type                                            = "NORMAL";
-      UL_FreqBandIndicatorNR                                        = 15;
-      UL_absoluteFrequencyPointA                                    = 13;
-      UL_additionalSpectrumEmission                                 = 3;
-      UL_p_Max                                                      = -1;
-      UL_frequencyShift7p5khz                                       = "TRUE";
-      UL_offsetToCarrier                                            = 10;
-      UL_SCS_SubcarrierSpacing                                      = "kHz30";
-      UL_SCS_SpecificCarrier_k0                                     = 0;
-      UL_carrierBandwidth                                           = 15;
-      UL_locationAndBandwidth                                       = 15;
-      UL_BWP_SubcarrierSpacing                                      = "kHz30";
-      UL_BWP_prefix_type                                            = "NORMAL";
-      UL_timeAlignmentTimerCommon                                   = "infinity";
-      ServingCellConfigCommon_n_TimingAdvanceOffset                 = "n0"
-      ServingCellConfigCommon_ssb_PositionsInBurst_PR               = 0x01;
-      ServingCellConfigCommon_ssb_periodicityServingCell            = 10;
-      ServingCellConfigCommon_dmrs_TypeA_Position                   = 2;
-      NIA_SubcarrierSpacing                                         = "kHz15"; 
-      ServingCellConfigCommon_ss_PBCH_BlockPower                    = -60;
-      referenceSubcarrierSpacing                                    = "kHz15";
-      dl_UL_TransmissionPeriodicity                                 = "ms0p5";
-      nrofDownlinkSlots                                             = 10;
-      nrofDownlinkSymbols                                           = 10;
-      nrofUplinkSlots                                               = 10;
-      nrofUplinkSymbols                                             = 10;
-      rach_totalNumberOfRA_Preambles                                = 63;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice         = "oneEighth";
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth      = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth      = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf        = 16;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one            = 24;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two            = 32;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four           = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight          = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen        = 2;
-      rach_groupBconfigured                                         = "ENABLE";
-      rach_ra_Msg3SizeGroupA                                        = 56;
-      rach_messagePowerOffsetGroupB                                 = "dB0";
-      rach_numberOfRA_PreamblesGroupA                               = 32;
-      rach_ra_ContentionResolutionTimer                             = 8;
-      rsrp_ThresholdSSB                                             = 64;
-      rsrp_ThresholdSSB_SUL                                         = 64;
-      prach_RootSequenceIndex_choice                                = "l839";
-      prach_RootSequenceIndex_l839                                  = 0;
-      prach_RootSequenceIndex_l139                                  = 0;
-      prach_msg1_SubcarrierSpacing                                  = "kHz30";
-      restrictedSetConfig                                           = "unrestrictedSet";
-      msg3_transformPrecoding                                       = "ENABLE";
-      prach_ConfigurationIndex                                      = 10;
-      prach_msg1_FDM                                                = "one";
-      prach_msg1_FrequencyStart                                     = 10;
-      zeroCorrelationZoneConfig                                     = 10;
-      preambleReceivedTargetPower                                   = -150;
-      preambleTransMax                                              = 6;
-      powerRampingStep                                              = "dB0";
-      ra_ResponseWindow                                             = 8;
-      groupHoppingEnabledTransformPrecoding                         = "ENABLE";
-      msg3_DeltaPreamble                                            = 0;
-      p0_NominalWithGrant                                           = 0;
-      PUSCH_TimeDomainResourceAllocation_k2                         = 0;
-      PUSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PUSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      pucch_ResourceCommon                                          = 0;
-      pucch_GroupHopping                                            = "neither";
-      hoppingId                                                     = 0;
-      p0_nominal                                                    = -30;
-      PDSCH_TimeDomainResourceAllocation_k0                         = 2;
-      PDSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PDSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      rateMatchPatternId                                            = 0;
-      RateMatchPattern_patternType                                  = "bitmaps";
-      symbolsInResourceBlock                                        = "oneSlot";
-      periodicityAndPattern                                         = 2;
-      RateMatchPattern_controlResourceSet                           = 5;
-      RateMatchPattern_subcarrierSpacing                            = "kHz30";
-      RateMatchPattern_mode                                         = "dynamic";
-      controlResourceSetZero                                        = 0;
-      searchSpaceZero                                               = 0;
-      searchSpaceSIB1                                               = 10;
-      searchSpaceOtherSystemInformation                             = 10;
-      pagingSearchSpace                                             = 10;
-      ra_SearchSpace                                                = 10;
-      PDCCH_common_controlResourceSetId                             = 5;
-      PDCCH_common_ControlResourceSet_duration                      = 2;
-      PDCCH_cce_REG_MappingType                                     = "nonInterleaved";
-      PDCCH_reg_BundleSize                                          = 3;
-      PDCCH_interleaverSize                                         = 3;
-      PDCCH_shiftIndex                                              = 10;  
-      PDCCH_precoderGranularity                                     = "sameAsREG-bundle";
-      PDCCH_TCI_StateId                                             = 32;
-      tci_PresentInDCI                                              = "ENABLE";
-      PDCCH_DMRS_ScramblingID                                       = 0;
-      SearchSpaceId                                                 = 10;
-      commonSearchSpaces_controlResourceSetId                       = 5;
-      SearchSpace_monitoringSlotPeriodicityAndOffset_choice         = "sl1";
-      SearchSpace_monitoringSlotPeriodicityAndOffset_value          = 0;
-      SearchSpace_duration                                          = 2;
-      SearchSpace_nrofCandidates_aggregationLevel1                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel2                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel4                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel8                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel16                 = 0;
-      SearchSpace_searchSpaceType                                   = "common";
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16    = 1; 
-      Common_dci_Format2_3_monitoringPeriodicity                    = 1;
-      Common_dci_Format2_3_nrofPDCCH_Candidates                     = 1;
-      ue_Specific__dci_Formats                                      = "formats0-0-And-1-0";
-      RateMatchPatternLTE_CRS_carrierFreqDL                         = 6;
-      RateMatchPatternLTE_CRS_carrierBandwidthDL                    = 6;
-      RateMatchPatternLTE_CRS_nrofCRS_Ports                         = 1;
-      RateMatchPatternLTE_CRS_v_Shift                               = 0;
-      RateMatchPatternLTE_CRS_radioframeAllocationPeriod            = 1;
-      RateMatchPatternLTE_CRS_radioframeAllocationOffset            = 0;
-      RateMatchPatternLTE_CRS_subframeAllocation_choice             = "oneFrame";
-      }
-    );
-
-
-    srb1_parameters :
+    ssb_SubcarrierOffset                                      = 0;
+    pdsch_AntennaPorts                                        = 1;
+	
+    servingCellConfigCommon = (
     {
-        # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
-        timer_poll_retransmit    = 80;
+ #spCellConfigCommon
 
-        # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
-        timer_reordering         = 35;
+      physCellId                                                    = 0;
 
-        # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
-        timer_status_prohibit    = 0;
+#  downlinkConfigCommon
+    #frequencyInfoDL
+      # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP)
+      absoluteFrequencySSB                                          = 641032;
+      dl_frequencyBand                                                 = 78;
+      # this is 3600 MHz
+      dl_absoluteFrequencyPointA                                       = 640000;
+      #scs-SpecificCarrierList
+        dl_offstToCarrier                                              = 0;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        dl_subcarrierSpacing                                           = 1;
+        dl_carrierBandwidth                                            = 106;
+     #initialDownlinkBWP
+      #genericParameters
+        # this is RBstart=0,L=50 (275*(L-1))+RBstart
+        initialDLBWPlocationAndBandwidth                                        = 13475;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialDLBWPsubcarrierSpacing                                           = 1;
+      #pdcch-ConfigCommon
+        initialDLBWPcontrolResourceSetZero                                      = 12;
+        initialDLBWPsearchSpaceZero                                             = 0;
+      #pdsch-ConfigCommon
+        #pdschTimeDomainAllocationList (up to 16 entries)
+             initialDLBWPk0_0                    = 0;
+             #initialULBWPmappingType
+	     #0=typeA,1=typeB
+             initialDLBWPmappingType_0           = 0;
+             #this is SS=2,L=3
+             initialDLBWPstartSymbolAndLength_0  = 40;
 
-        # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
-        poll_pdu                 =  4;
+             initialDLBWPk0_1                    = 0;
+             initialDLBWPmappingType_1           = 0;
+             #this is SS=2,L=12 
+             initialDLBWPstartSymbolAndLength_1  = 53;
 
-        # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
-        poll_byte                =  99999;
+             initialDLBWPk0_2                    = 0;
+             initialDLBWPmappingType_2           = 0;
+             #this is SS=1,L=12 
+             initialDLBWPstartSymbolAndLength_2  = 54;
+  #uplinkConfigCommon 
+     #frequencyInfoUL
+      ul_frequencyBand                                                 = 78;
+      #scs-SpecificCarrierList
+      ul_offstToCarrier                                              = 0;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      ul_subcarrierSpacing                                           = 1;
+      ul_carrierBandwidth                                            = 106;
+      pMax                                                          = 20;
+     #initialUplinkBWP
+      #genericParameters
+        initialULBWPlocationAndBandwidth                                        = 13475;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialULBWPsubcarrierSpacing                                           = 1;
+      #rach-ConfigCommon
+        #rach-ConfigGeneric
+          prach_ConfigurationIndex                                  = 98;
+#prach_msg1_FDM
+#0 = one, 1=two, 2=four, 3=eight
+          prach_msg1_FDM                                            = 0;
+          prach_msg1_FrequencyStart                                 = 0;
+          zeroCorrelationZoneConfig                                 = 13;
+          preambleReceivedTargetPower                               = -118;
+#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200)
+          preambleTransMax                                          = 6;
+#powerRampingStep
+# 0=dB0,1=dB2,2=dB4,3=dB6
+        powerRampingStep                                            = 1;
+#ra_ReponseWindow
+#1,2,4,8,10,20,40,80
+        ra_ResponseWindow                                           = 4;
+#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR
+#0=oneeighth,1=onefourth,2=half,3=one,4=two,5=four,6=eight,7=sixteen
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR                = 3;
+#oneHalf (0..15) 4,8,12,16,...60,64
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB                   = 15;
+#ra_ContentionResolutionTimer
+#(0..7) 8,16,24,32,40,48,56,64
+        ra_ContentionResolutionTimer                                = 7;
+        rsrp_ThresholdSSB                                           = 19;
+#prach-RootSequenceIndex_PR
+#0 = 839, 1 = 139
+        prach_RootSequenceIndex_PR                                  = 1;
+        prach_RootSequenceIndex                                     = 1;
+        # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex
+        #  
+        msg1_SubcarrierSpacing                                      = 1,
+
+# restrictedSetConfig
+# 0=unrestricted, 1=restricted type A, 2=restricted type B
+        restrictedSetConfig                                         = 0,
+      # pusch-ConfigCommon (up to 16 elements)
+        initialULBWPk2_0                      = 2;
+        initialULBWPmappingType_0             = 1
+        # this is SS=0 L=11
+        initialULBWPstartSymbolAndLength_0    = 55;
+ 	
+	initialULBWPk2_1                      = 2;
+        initialULBWPmappingType_1             = 1;
+        # this is SS=0 L=12
+        initialULBWPstartSymbolAndLength_1    = 69;
+
+
+        msg3_DeltaPreamble                                          = 1;
+        p0_NominalWithGrant                                         =-90;
+
+# pucch-ConfigCommon setup :
+# pucchGroupHopping
+# 0 = neither, 1= group hopping, 2=sequence hopping
+        pucchGroupHopping                                           = 0;
+        hoppingId                                                   = 40;
+        p0_nominal                                                  = -90;
+# ssb_PositionsInBurs_BitmapPR
+# 1=short, 2=medium, 3=long
+      ssb_PositionsInBurst_PR                                       = 2;
+      ssb_PositionsInBurst_Bitmap                                   = 1;
+
+# ssb_periodicityServingCell
+# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 
+      ssb_periodicityServingCell                                    = 2;
+
+# dmrs_TypeA_position
+# 0 = pos2, 1 = pos3
+      dmrs_TypeA_Position                                           = 0;
+
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      subcarrierSpacing                                             = 1;
+
+
+  #tdd-UL-DL-ConfigurationCommon
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      referenceSubcarrierSpacing                                    = 1;
+      # pattern1 
+      # dl_UL_TransmissionPeriodicity
+      # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10
+      dl_UL_TransmissionPeriodicity                                 = 6;
+      nrofDownlinkSlots                                             = 7;
+      nrofDownlinkSymbols                                           = 6;
+      nrofUplinkSlots                                               = 2;
+      nrofUplinkSymbols                                             = 4;
+
+  ssPBCH_BlockPower                                             = 10;
+  }
+
+  );
 
-        # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
-        max_retx_threshold       =  4;
-    }
 
     # ------- SCTP definitions
     SCTP :
@@ -246,17 +229,16 @@ L1s = (
 RUs = (
     {		  
        local_rf       = "yes"
-         nb_tx          = 1; 
-         nb_rx          = 1; 
-         att_tx         = 0; 
+         nb_tx          = 1
+         nb_rx          = 1
+         att_tx         = 0
          att_rx         = 0;
          bands          = [7];
          max_pdschReferenceSignalPower = -27;
          max_rxgain                    = 114;
          eNB_instances  = [0];
-
-	 sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2,clock_source=external,time_source=external";
-
+	 sdr_addrs = "addr=192.168.10.2,mgmt_addr=192.168.10.2";
+         #clock_src = "external";
     }
 );  
 
@@ -269,16 +251,6 @@ THREAD_STRUCT = (
   }
 );
 
-NETWORK_CONTROLLER :
-{
-    FLEXRAN_ENABLED        = "no";
-    FLEXRAN_INTERFACE_NAME = "lo";
-    FLEXRAN_IPV4_ADDRESS   = "127.0.0.1";
-    FLEXRAN_PORT           = 2210;
-    FLEXRAN_CACHE          = "/mnt/oai_agent_cache";
-    FLEXRAN_AWAIT_RECONF   = "no";
-};
-
      log_config :
      {
        global_log_level                      ="info";
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf
index 420188b80e8..06aa4f6f9f6 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf
@@ -21,183 +21,166 @@ gNBs =
 
     ////////// Physical parameters:
 
-    component_carriers = (
-      {
-      node_function                                                 = "3GPP_gNODEB";
-      node_timing                                                   = "synch_to_ext_device";
-      node_synch_ref                                                = 0;
-      frame_type                                                    = "TDD";
-      DL_prefix_type                                                = "NORMAL";
-      UL_prefix_type                                                = "NORMAL";
-      eutra_band                                                    = 78;
-      downlink_frequency                                            = 3510000000L;
-      uplink_frequency_offset                                       = 0;
-      Nid_cell                                                      = 0;
-      N_RB_DL                                                       = 106;
-      nb_antenna_ports                                              = 1;
-      nb_antennas_tx                                                = 1;
-      nb_antennas_rx                                                = 1;
-      tx_gain                                                       = 90;
-      rx_gain                                                       = 125;
-      MIB_subCarrierSpacingCommon                                   = 30;
-      MIB_ssb_SubcarrierOffset                                      = 0;
-      MIB_dmrs_TypeA_Position                                       = 2;
-      pdcch_ConfigSIB1                                              = 0;
-      SIB1_frequencyOffsetSSB                                       = "khz5";
-      SIB1_ssb_PeriodicityServingCell                               = 5;
-      SIB1_ss_PBCH_BlockPower                                       = -60;
-      absoluteFrequencySSB                                          = 0;
-      DL_FreqBandIndicatorNR                                        = 15;
-      DL_absoluteFrequencyPointA                                    = 15;
-      DL_offsetToCarrier                                            = 15;
-      DL_SCS_SubcarrierSpacing                                      = "kHz30";
-      DL_SCS_SpecificCarrier_k0                                     = 0;
-      DL_carrierBandwidth                                           = 15;
-      DL_locationAndBandwidth                                       = 15;
-      DL_BWP_SubcarrierSpacing                                      = "kHz30";
-      DL_BWP_prefix_type                                            = "NORMAL";
-      UL_FreqBandIndicatorNR                                        = 15;
-      UL_absoluteFrequencyPointA                                    = 13;
-      UL_additionalSpectrumEmission                                 = 3;
-      UL_p_Max                                                      = -1;
-      UL_frequencyShift7p5khz                                       = "TRUE";
-      UL_offsetToCarrier                                            = 10;
-      UL_SCS_SubcarrierSpacing                                      = "kHz30";
-      UL_SCS_SpecificCarrier_k0                                     = 0;
-      UL_carrierBandwidth                                           = 15;
-      UL_locationAndBandwidth                                       = 15;
-      UL_BWP_SubcarrierSpacing                                      = "kHz30";
-      UL_BWP_prefix_type                                            = "NORMAL";
-      UL_timeAlignmentTimerCommon                                   = "infinity";
-      ServingCellConfigCommon_n_TimingAdvanceOffset                 = "n0"
-      ServingCellConfigCommon_ssb_PositionsInBurst_PR               = 0x01;#####
-      ServingCellConfigCommon_ssb_periodicityServingCell            = 10;
-      ServingCellConfigCommon_dmrs_TypeA_Position                   = 2;
-      NIA_SubcarrierSpacing                                         = "kHz15"; 
-      ServingCellConfigCommon_ss_PBCH_BlockPower                    = -60;
-      referenceSubcarrierSpacing                                    = "kHz15";
-      dl_UL_TransmissionPeriodicity                                 = "ms0p5";
-      nrofDownlinkSlots                                             = 10;
-      nrofDownlinkSymbols                                           = 10;
-      nrofUplinkSlots                                               = 10;
-      nrofUplinkSymbols                                             = 10;
-      rach_totalNumberOfRA_Preambles                                = 63;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice         = "oneEighth";
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth      = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth      = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf        = 16;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one            = 24;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two            = 32;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four           = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight          = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen        = 2;
-      rach_groupBconfigured                                         = "ENABLE";
-      rach_ra_Msg3SizeGroupA                                        = 56;
-      rach_messagePowerOffsetGroupB                                 = "dB0";
-      rach_numberOfRA_PreamblesGroupA                               = 32;
-      rach_ra_ContentionResolutionTimer                             = 8;
-      rsrp_ThresholdSSB                                             = 64;
-      rsrp_ThresholdSSB_SUL                                         = 64;
-      prach_RootSequenceIndex_choice                                = "l839";
-      prach_RootSequenceIndex_l839                                  = 0;
-      prach_RootSequenceIndex_l139                                  = 0;
-      prach_msg1_SubcarrierSpacing                                  = "kHz30";
-      restrictedSetConfig                                           = "unrestrictedSet";
-      msg3_transformPrecoding                                       = "ENABLE";
-      prach_ConfigurationIndex                                      = 10;
-      prach_msg1_FDM                                                = "one";
-      prach_msg1_FrequencyStart                                     = 10;
-      zeroCorrelationZoneConfig                                     = 10;
-      preambleReceivedTargetPower                                   = -150;
-      preambleTransMax                                              = 6;
-      powerRampingStep                                              = "dB0";
-      ra_ResponseWindow                                             = 8;
-      groupHoppingEnabledTransformPrecoding                         = "ENABLE";
-      msg3_DeltaPreamble                                            = 0;
-      p0_NominalWithGrant                                           = 0;
-      PUSCH_TimeDomainResourceAllocation_k2                         = 0;
-      PUSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PUSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      pucch_ResourceCommon                                          = 0;
-      pucch_GroupHopping                                            = "neither";
-      hoppingId                                                     = 0;
-      p0_nominal                                                    = -30;
-      PDSCH_TimeDomainResourceAllocation_k0                         = 2;
-      PDSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PDSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      rateMatchPatternId                                            = 0;
-      RateMatchPattern_patternType                                  = "bitmaps";
-      symbolsInResourceBlock                                        = "oneSlot";
-      periodicityAndPattern                                         = 2;
-      RateMatchPattern_controlResourceSet                           = 5;
-      RateMatchPattern_subcarrierSpacing                            = "kHz30";
-      RateMatchPattern_mode                                         = "dynamic";
-      controlResourceSetZero                                        = 0;
-      searchSpaceZero                                               = 0;
-      searchSpaceSIB1                                               = 10;
-      searchSpaceOtherSystemInformation                             = 10;
-      pagingSearchSpace                                             = 10;
-      ra_SearchSpace                                                = 10;
-      PDCCH_common_controlResourceSetId                             = 5;
-      PDCCH_common_ControlResourceSet_duration                      = 2;
-      PDCCH_cce_REG_MappingType                                     = "nonInterleaved";
-      PDCCH_reg_BundleSize                                          = 3;
-      PDCCH_interleaverSize                                         = 3;
-      PDCCH_shiftIndex                                              = 10;  
-      PDCCH_precoderGranularity                                     = "sameAsREG-bundle";
-      PDCCH_TCI_StateId                                             = 32;
-      tci_PresentInDCI                                              = "ENABLE";
-      PDCCH_DMRS_ScramblingID                                       = 0;
-      SearchSpaceId                                                 = 10;
-      commonSearchSpaces_controlResourceSetId                       = 5;
-      SearchSpace_monitoringSlotPeriodicityAndOffset_choice         = "sl1";
-      SearchSpace_monitoringSlotPeriodicityAndOffset_value          = 0;
-      SearchSpace_duration                                          = 2;
-      SearchSpace_nrofCandidates_aggregationLevel1                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel2                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel4                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel8                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel16                 = 0;
-      SearchSpace_searchSpaceType                                   = "common";
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16    = 1; 
-      Common_dci_Format2_3_monitoringPeriodicity                    = 1;
-      Common_dci_Format2_3_nrofPDCCH_Candidates                     = 1;
-      ue_Specific__dci_Formats                                      = "formats0-0-And-1-0";
-      RateMatchPatternLTE_CRS_carrierFreqDL                         = 6;
-      RateMatchPatternLTE_CRS_carrierBandwidthDL                    = 6;
-      RateMatchPatternLTE_CRS_nrofCRS_Ports                         = 1;
-      RateMatchPatternLTE_CRS_v_Shift                               = 0;
-      RateMatchPatternLTE_CRS_radioframeAllocationPeriod            = 1;
-      RateMatchPatternLTE_CRS_radioframeAllocationOffset            = 0;
-      RateMatchPatternLTE_CRS_subframeAllocation_choice             = "oneFrame";
-      }
-    );
-
-
-    srb1_parameters :
+    ssb_SubcarrierOffset                                      = 0;
+    pdsch_AntennaPorts                                        = 1;
+	
+    servingCellConfigCommon = (
     {
-        # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
-        timer_poll_retransmit    = 80;
+ #spCellConfigCommon
 
-        # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
-        timer_reordering         = 35;
+      physCellId                                                    = 0;
 
-        # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
-        timer_status_prohibit    = 0;
+#  downlinkConfigCommon
+    #frequencyInfoDL
+      # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP)
+      absoluteFrequencySSB                                          = 633032;
+      dl_frequencyBand                                                 = 78;
+      # this is 3480 MHz
+      dl_absoluteFrequencyPointA                                       = 632000;
+      #scs-SpecificCarrierList
+        dl_offstToCarrier                                              = 0;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        dl_subcarrierSpacing                                           = 1;
+        dl_carrierBandwidth                                            = 106;
+     #initialDownlinkBWP
+      #genericParameters
+        # this is RBstart=0,L=50 (275*(L-1))+RBstart
+        initialDLBWPlocationAndBandwidth                                        = 13475;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialDLBWPsubcarrierSpacing                                           = 1;
+      #pdcch-ConfigCommon
+        initialDLBWPcontrolResourceSetZero                                      = 12;
+        initialDLBWPsearchSpaceZero                                             = 0;
+      #pdsch-ConfigCommon
+        #pdschTimeDomainAllocationList (up to 16 entries)
+             initialDLBWPk0_0                    = 0;
+             #initialULBWPmappingType
+	     #0=typeA,1=typeB
+             initialDLBWPmappingType_0           = 0;
+             #this is SS=2,L=3
+             initialDLBWPstartSymbolAndLength_0  = 40;
 
-        # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
-        poll_pdu                 =  4;
+             initialDLBWPk0_1                    = 0;
+             initialDLBWPmappingType_1           = 0;
+             #this is SS=2,L=12 
+             initialDLBWPstartSymbolAndLength_1  = 53;
 
-        # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
-        poll_byte                =  99999;
+             initialDLBWPk0_2                    = 0;
+             initialDLBWPmappingType_2           = 0;
+             #this is SS=1,L=12 
+             initialDLBWPstartSymbolAndLength_2  = 54;
+  #uplinkConfigCommon 
+     #frequencyInfoUL
+      ul_frequencyBand                                                 = 78;
+      #scs-SpecificCarrierList
+      ul_offstToCarrier                                              = 0;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      ul_subcarrierSpacing                                           = 1;
+      ul_carrierBandwidth                                            = 106;
+      pMax                                                          = 20;
+     #initialUplinkBWP
+      #genericParameters
+        initialULBWPlocationAndBandwidth                                        = 13475;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialULBWPsubcarrierSpacing                                           = 1;
+      #rach-ConfigCommon
+        #rach-ConfigGeneric
+          prach_ConfigurationIndex                                  = 98;
+#prach_msg1_FDM
+#0 = one, 1=two, 2=four, 3=eight
+          prach_msg1_FDM                                            = 0;
+          prach_msg1_FrequencyStart                                 = 0;
+          zeroCorrelationZoneConfig                                 = 13;
+          preambleReceivedTargetPower                               = -118;
+#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200)
+          preambleTransMax                                          = 6;
+#powerRampingStep
+# 0=dB0,1=dB2,2=dB4,3=dB6
+        powerRampingStep                                            = 1;
+#ra_ReponseWindow
+#1,2,4,8,10,20,40,80
+        ra_ResponseWindow                                           = 4;
+#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR
+#0=oneeighth,1=onefourth,2=half,3=one,4=two,5=four,6=eight,7=sixteen
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR                = 3;
+#oneHalf (0..15) 4,8,12,16,...60,64
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB                   = 15;
+#ra_ContentionResolutionTimer
+#(0..7) 8,16,24,32,40,48,56,64
+        ra_ContentionResolutionTimer                                = 7;
+        rsrp_ThresholdSSB                                           = 19;
+#prach-RootSequenceIndex_PR
+#0 = 839, 1 = 139
+        prach_RootSequenceIndex_PR                                  = 1;
+        prach_RootSequenceIndex                                     = 1;
+        # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex
+        #  
+        msg1_SubcarrierSpacing                                      = 1,
+
+# restrictedSetConfig
+# 0=unrestricted, 1=restricted type A, 2=restricted type B
+        restrictedSetConfig                                         = 0,
+      # pusch-ConfigCommon (up to 16 elements)
+        initialULBWPk2_0                      = 2;
+        initialULBWPmappingType_0             = 1
+        # this is SS=0 L=11
+        initialULBWPstartSymbolAndLength_0    = 55;
+ 	
+	initialULBWPk2_1                      = 2;
+        initialULBWPmappingType_1             = 1;
+        # this is SS=0 L=12
+        initialULBWPstartSymbolAndLength_1    = 69;
+
+
+        msg3_DeltaPreamble                                          = 1;
+        p0_NominalWithGrant                                         =-90;
+
+# pucch-ConfigCommon setup :
+# pucchGroupHopping
+# 0 = neither, 1= group hopping, 2=sequence hopping
+        pucchGroupHopping                                           = 0;
+        hoppingId                                                   = 40;
+        p0_nominal                                                  = -90;
+# ssb_PositionsInBurs_BitmapPR
+# 1=short, 2=medium, 3=long
+      ssb_PositionsInBurst_PR                                       = 2;
+      ssb_PositionsInBurst_Bitmap                                   = 255;
+
+# ssb_periodicityServingCell
+# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 
+      ssb_periodicityServingCell                                    = 2;
+
+# dmrs_TypeA_position
+# 0 = pos2, 1 = pos3
+      dmrs_TypeA_Position                                           = 0;
+
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      subcarrierSpacing                                             = 1;
+
+
+  #tdd-UL-DL-ConfigurationCommon
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      referenceSubcarrierSpacing                                    = 1;
+      # pattern1 
+      # dl_UL_TransmissionPeriodicity
+      # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10
+      dl_UL_TransmissionPeriodicity                                 = 6;
+      nrofDownlinkSlots                                             = 7;
+      nrofDownlinkSymbols                                           = 6;
+      nrofUplinkSlots                                               = 2;
+      nrofUplinkSymbols                                             = 4;
+
+  ssPBCH_BlockPower                                             = 10;
+  }
+
+  );
 
-        # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
-        max_retx_threshold       =  4;
-    }
 
     # ------- SCTP definitions
     SCTP :
@@ -246,7 +229,7 @@ L1s = (
 RUs = (
     {		  
        local_rf       = "yes"
-         nb_tx          = 1 
+         nb_tx          = 1
          nb_rx          = 1
          att_tx         = 0
          att_rx         = 0;
@@ -254,8 +237,7 @@ RUs = (
          max_pdschReferenceSignalPower = -27;
          max_rxgain                    = 114;
          eNB_instances  = [0];
-         sdr_addrs = "type=x300";
-
+	 sdr_addrs = "type=x300";
     }
 );  
 
@@ -268,16 +250,6 @@ THREAD_STRUCT = (
   }
 );
 
-NETWORK_CONTROLLER :
-{
-    FLEXRAN_ENABLED        = "no";
-    FLEXRAN_INTERFACE_NAME = "lo";
-    FLEXRAN_IPV4_ADDRESS   = "127.0.0.1";
-    FLEXRAN_PORT           = 2210;
-    FLEXRAN_CACHE          = "/mnt/oai_agent_cache";
-    FLEXRAN_AWAIT_RECONF   = "no";
-};
-
      log_config :
      {
        global_log_level                      ="info";
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf
index 06c52e1aff8..b82c455ef43 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf
@@ -21,183 +21,166 @@ gNBs =
 
     ////////// Physical parameters:
 
-    component_carriers = (
-      {
-      node_function                                                 = "3GPP_gNODEB";
-      node_timing                                                   = "synch_to_ext_device";
-      node_synch_ref                                                = 0;
-      frame_type                                                    = "TDD";
-      DL_prefix_type                                                = "NORMAL";
-      UL_prefix_type                                                = "NORMAL";
-      eutra_band                                                    = 78;
-      downlink_frequency                                            = 3510000000L;
-      uplink_frequency_offset                                       = -120000000;
-      Nid_cell                                                      = 0;
-      N_RB_DL                                                       = 217;
-      nb_antenna_ports                                              = 1;
-      nb_antennas_tx                                                = 1;
-      nb_antennas_rx                                                = 1;
-      tx_gain                                                       = 90;
-      rx_gain                                                       = 125;
-      MIB_subCarrierSpacingCommon                                   = 30;
-      MIB_ssb_SubcarrierOffset                                      = 0;
-      MIB_dmrs_TypeA_Position                                       = 2;
-      pdcch_ConfigSIB1                                              = 0;
-      SIB1_frequencyOffsetSSB                                       = "khz5";
-      SIB1_ssb_PeriodicityServingCell                               = 5;
-      SIB1_ss_PBCH_BlockPower                                       = -60;
-      absoluteFrequencySSB                                          = 0;
-      DL_FreqBandIndicatorNR                                        = 15;
-      DL_absoluteFrequencyPointA                                    = 15;
-      DL_offsetToCarrier                                            = 15;
-      DL_SCS_SubcarrierSpacing                                      = "kHz30";
-      DL_SCS_SpecificCarrier_k0                                     = 0;
-      DL_carrierBandwidth                                           = 15;
-      DL_locationAndBandwidth                                       = 15;
-      DL_BWP_SubcarrierSpacing                                      = "kHz30";
-      DL_BWP_prefix_type                                            = "NORMAL";
-      UL_FreqBandIndicatorNR                                        = 15;
-      UL_absoluteFrequencyPointA                                    = 13;
-      UL_additionalSpectrumEmission                                 = 3;
-      UL_p_Max                                                      = -1;
-      UL_frequencyShift7p5khz                                       = "TRUE";
-      UL_offsetToCarrier                                            = 10;
-      UL_SCS_SubcarrierSpacing                                      = "kHz30";
-      UL_SCS_SpecificCarrier_k0                                     = 0;
-      UL_carrierBandwidth                                           = 15;
-      UL_locationAndBandwidth                                       = 15;
-      UL_BWP_SubcarrierSpacing                                      = "kHz30";
-      UL_BWP_prefix_type                                            = "NORMAL";
-      UL_timeAlignmentTimerCommon                                   = "infinity";
-      ServingCellConfigCommon_n_TimingAdvanceOffset                 = "n0"
-      ServingCellConfigCommon_ssb_PositionsInBurst_PR               = 0x01;
-      ServingCellConfigCommon_ssb_periodicityServingCell            = 10;
-      ServingCellConfigCommon_dmrs_TypeA_Position                   = 2;
-      NIA_SubcarrierSpacing                                         = "kHz15"; 
-      ServingCellConfigCommon_ss_PBCH_BlockPower                    = -60;
-      referenceSubcarrierSpacing                                    = "kHz15";
-      dl_UL_TransmissionPeriodicity                                 = "ms0p5";
-      nrofDownlinkSlots                                             = 10;
-      nrofDownlinkSymbols                                           = 10;
-      nrofUplinkSlots                                               = 10;
-      nrofUplinkSymbols                                             = 10;
-      rach_totalNumberOfRA_Preambles                                = 63;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice         = "oneEighth";
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth      = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth      = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf        = 16;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one            = 24;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two            = 32;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four           = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight          = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen        = 2;
-      rach_groupBconfigured                                         = "ENABLE";
-      rach_ra_Msg3SizeGroupA                                        = 56;
-      rach_messagePowerOffsetGroupB                                 = "dB0";
-      rach_numberOfRA_PreamblesGroupA                               = 32;
-      rach_ra_ContentionResolutionTimer                             = 8;
-      rsrp_ThresholdSSB                                             = 64;
-      rsrp_ThresholdSSB_SUL                                         = 64;
-      prach_RootSequenceIndex_choice                                = "l839";
-      prach_RootSequenceIndex_l839                                  = 0;
-      prach_RootSequenceIndex_l139                                  = 0;
-      prach_msg1_SubcarrierSpacing                                  = "kHz30";
-      restrictedSetConfig                                           = "unrestrictedSet";
-      msg3_transformPrecoding                                       = "ENABLE";
-      prach_ConfigurationIndex                                      = 10;
-      prach_msg1_FDM                                                = "one";
-      prach_msg1_FrequencyStart                                     = 10;
-      zeroCorrelationZoneConfig                                     = 10;
-      preambleReceivedTargetPower                                   = -150;
-      preambleTransMax                                              = 6;
-      powerRampingStep                                              = "dB0";
-      ra_ResponseWindow                                             = 8;
-      groupHoppingEnabledTransformPrecoding                         = "ENABLE";
-      msg3_DeltaPreamble                                            = 0;
-      p0_NominalWithGrant                                           = 0;
-      PUSCH_TimeDomainResourceAllocation_k2                         = 0;
-      PUSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PUSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      pucch_ResourceCommon                                          = 0;
-      pucch_GroupHopping                                            = "neither";
-      hoppingId                                                     = 0;
-      p0_nominal                                                    = -30;
-      PDSCH_TimeDomainResourceAllocation_k0                         = 2;
-      PDSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PDSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      rateMatchPatternId                                            = 0;
-      RateMatchPattern_patternType                                  = "bitmaps";
-      symbolsInResourceBlock                                        = "oneSlot";
-      periodicityAndPattern                                         = 2;
-      RateMatchPattern_controlResourceSet                           = 5;
-      RateMatchPattern_subcarrierSpacing                            = "kHz30";
-      RateMatchPattern_mode                                         = "dynamic";
-      controlResourceSetZero                                        = 0;
-      searchSpaceZero                                               = 0;
-      searchSpaceSIB1                                               = 10;
-      searchSpaceOtherSystemInformation                             = 10;
-      pagingSearchSpace                                             = 10;
-      ra_SearchSpace                                                = 10;
-      PDCCH_common_controlResourceSetId                             = 5;
-      PDCCH_common_ControlResourceSet_duration                      = 2;
-      PDCCH_cce_REG_MappingType                                     = "nonInterleaved";
-      PDCCH_reg_BundleSize                                          = 3;
-      PDCCH_interleaverSize                                         = 3;
-      PDCCH_shiftIndex                                              = 10;  
-      PDCCH_precoderGranularity                                     = "sameAsREG-bundle";
-      PDCCH_TCI_StateId                                             = 32;
-      tci_PresentInDCI                                              = "ENABLE";
-      PDCCH_DMRS_ScramblingID                                       = 0;
-      SearchSpaceId                                                 = 10;
-      commonSearchSpaces_controlResourceSetId                       = 5;
-      SearchSpace_monitoringSlotPeriodicityAndOffset_choice         = "sl1";
-      SearchSpace_monitoringSlotPeriodicityAndOffset_value          = 0;
-      SearchSpace_duration                                          = 2;
-      SearchSpace_nrofCandidates_aggregationLevel1                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel2                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel4                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel8                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel16                 = 0;
-      SearchSpace_searchSpaceType                                   = "common";
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16    = 1; 
-      Common_dci_Format2_3_monitoringPeriodicity                    = 1;
-      Common_dci_Format2_3_nrofPDCCH_Candidates                     = 1;
-      ue_Specific__dci_Formats                                      = "formats0-0-And-1-0";
-      RateMatchPatternLTE_CRS_carrierFreqDL                         = 6;
-      RateMatchPatternLTE_CRS_carrierBandwidthDL                    = 6;
-      RateMatchPatternLTE_CRS_nrofCRS_Ports                         = 1;
-      RateMatchPatternLTE_CRS_v_Shift                               = 0;
-      RateMatchPatternLTE_CRS_radioframeAllocationPeriod            = 1;
-      RateMatchPatternLTE_CRS_radioframeAllocationOffset            = 0;
-      RateMatchPatternLTE_CRS_subframeAllocation_choice             = "oneFrame";
-      }
-    );
-
-
-    srb1_parameters :
+    ssb_SubcarrierOffset                                      = 0;
+    pdsch_AntennaPorts                                        = 1;
+	
+    servingCellConfigCommon = (
     {
-        # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
-        timer_poll_retransmit    = 80;
+ #spCellConfigCommon
 
-        # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
-        timer_reordering         = 35;
+      physCellId                                                    = 0;
 
-        # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
-        timer_status_prohibit    = 0;
+#  downlinkConfigCommon
+    #frequencyInfoDL
+      # this is 3600 MHz + 84 PRBs@30kHz SCS (same as initial BWP)
+      absoluteFrequencySSB                                          = 642364;
+      dl_frequencyBand                                                 = 78;
+      # this is 3600 MHz
+      dl_absoluteFrequencyPointA                                       = 640000;
+      #scs-SpecificCarrierList
+        dl_offstToCarrier                                              = 0;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        dl_subcarrierSpacing                                           = 1;
+        dl_carrierBandwidth                                            = 217;
+     #initialDownlinkBWP
+      #genericParameters
+        # this is RBstart=84,L=50 (275*(L-1))+RBstart
+        initialDLBWPlocationAndBandwidth                                        = 13559;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialDLBWPsubcarrierSpacing                                           = 1;
+      #pdcch-ConfigCommon
+        initialDLBWPcontrolResourceSetZero                                      = 12;
+        initialDLBWPsearchSpaceZero                                             = 0;
+      #pdsch-ConfigCommon
+        #pdschTimeDomainAllocationList (up to 16 entries)
+             initialDLBWPk0_0                    = 0;
+             #initialULBWPmappingType
+	     #0=typeA,1=typeB
+             initialDLBWPmappingType_0           = 0;
+             #this is SS=2,L=3
+             initialDLBWPstartSymbolAndLength_0  = 40;
 
-        # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
-        poll_pdu                 =  4;
+             initialDLBWPk0_1                    = 0;
+             initialDLBWPmappingType_1           = 0;
+             #this is SS=2,L=12 
+             initialDLBWPstartSymbolAndLength_1  = 53;
 
-        # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
-        poll_byte                =  99999;
+             initialDLBWPk0_2                    = 0;
+             initialDLBWPmappingType_2           = 0;
+             #this is SS=1,L=12 
+             initialDLBWPstartSymbolAndLength_2  = 54;
+  #uplinkConfigCommon 
+     #frequencyInfoUL
+      ul_frequencyBand                                                 = 78;
+      #scs-SpecificCarrierList
+      ul_offstToCarrier                                              = 0;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      ul_subcarrierSpacing                                           = 1;
+      ul_carrierBandwidth                                            = 217;
+      pMax                                                          = 20;
+     #initialUplinkBWP
+      #genericParameters
+        initialULBWPlocationAndBandwidth                                        = 13559;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialULBWPsubcarrierSpacing                                           = 1;
+      #rach-ConfigCommon
+        #rach-ConfigGeneric
+          prach_ConfigurationIndex                                  = 98;
+#prach_msg1_FDM
+#0 = one, 1=two, 2=four, 3=eight
+          prach_msg1_FDM                                            = 0;
+          prach_msg1_FrequencyStart                                 = 0;
+          zeroCorrelationZoneConfig                                 = 13;
+          preambleReceivedTargetPower                               = -118;
+#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200)
+          preambleTransMax                                          = 6;
+#powerRampingStep
+# 0=dB0,1=dB2,2=dB4,3=dB6
+        powerRampingStep                                            = 1;
+#ra_ReponseWindow
+#1,2,4,8,10,20,40,80
+        ra_ResponseWindow                                           = 4;
+#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR
+#0=oneeighth,1=onefourth,2=half,3=one,4=two,5=four,6=eight,7=sixteen
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR                = 3;
+#oneHalf (0..15) 4,8,12,16,...60,64
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB                   = 15;
+#ra_ContentionResolutionTimer
+#(0..7) 8,16,24,32,40,48,56,64
+        ra_ContentionResolutionTimer                                = 7;
+        rsrp_ThresholdSSB                                           = 19;
+#prach-RootSequenceIndex_PR
+#0 = 839, 1 = 139
+        prach_RootSequenceIndex_PR                                  = 1;
+        prach_RootSequenceIndex                                     = 1;
+        # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex
+        #  
+        msg1_SubcarrierSpacing                                      = 1,
+
+# restrictedSetConfig
+# 0=unrestricted, 1=restricted type A, 2=restricted type B
+        restrictedSetConfig                                         = 0,
+      # pusch-ConfigCommon (up to 16 elements)
+        initialULBWPk2_0                      = 2;
+        initialULBWPmappingType_0             = 1
+        # this is SS=0 L=11
+        initialULBWPstartSymbolAndLength_0    = 55;
+ 	
+	initialULBWPk2_1                      = 2;
+        initialULBWPmappingType_1             = 1;
+        # this is SS=0 L=12
+        initialULBWPstartSymbolAndLength_1    = 69;
+
+
+        msg3_DeltaPreamble                                          = 1;
+        p0_NominalWithGrant                                         =-90;
+
+# pucch-ConfigCommon setup :
+# pucchGroupHopping
+# 0 = neither, 1= group hopping, 2=sequence hopping
+        pucchGroupHopping                                           = 0;
+        hoppingId                                                   = 40;
+        p0_nominal                                                  = -90;
+# ssb_PositionsInBurs_BitmapPR
+# 1=short, 2=medium, 3=long
+      ssb_PositionsInBurst_PR                                       = 2;
+      ssb_PositionsInBurst_Bitmap                                   = 1;
+
+# ssb_periodicityServingCell
+# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 
+      ssb_periodicityServingCell                                    = 1;
+
+# dmrs_TypeA_position
+# 0 = pos2, 1 = pos3
+      dmrs_TypeA_Position                                           = 0;
+
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      subcarrierSpacing                                             = 1;
+
+
+  #tdd-UL-DL-ConfigurationCommon
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      referenceSubcarrierSpacing                                    = 1;
+      # pattern1 
+      # dl_UL_TransmissionPeriodicity
+      # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10
+      dl_UL_TransmissionPeriodicity                                 = 6;
+      nrofDownlinkSlots                                             = 7;
+      nrofDownlinkSymbols                                           = 6;
+      nrofUplinkSlots                                               = 2;
+      nrofUplinkSymbols                                             = 4;
+
+  ssPBCH_BlockPower                                             = 10;
+  }
+
+  );
 
-        # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
-        max_retx_threshold       =  4;
-    }
 
     # ------- SCTP definitions
     SCTP :
@@ -215,15 +198,29 @@ gNBs =
                               preference = "ipv4";
                             }
                           );
+                          
+    ///X2
+    enable_x2 = "no";
+    t_reloc_prep      = 1000;      /* unit: millisecond */
+    tx2_reloc_overall = 2000;      /* unit: millisecond */
+    target_enb_x2_ip_address      = (
+                                     { ipv4       = "192.168.12.108";
+                                       ipv6       = "192:168:30::17";
+                                       preference = "ipv4";
+                                     }
+                                    );                       
 
     NETWORK_INTERFACES :
     {
 
         GNB_INTERFACE_NAME_FOR_S1_MME            = "eth0";
-        GNB_IPV4_ADDRESS_FOR_S1_MME              = "192.168.12.111/24";
+        GNB_IPV4_ADDRESS_FOR_S1_MME              = "192.168.12.188/24";
         GNB_INTERFACE_NAME_FOR_S1U               = "eth0";
-        GNB_IPV4_ADDRESS_FOR_S1U                 = "192.168.12.111/24";
+        GNB_IPV4_ADDRESS_FOR_S1U                 = "192.168.12.188/24";
         GNB_PORT_FOR_S1U                         = 2152; # Spec 2152
+        
+        GNB_IPV4_ADDRESS_FOR_X2C                 = "192.168.12.188/23";
+        GNB_PORT_FOR_X2C                         = 36422; # Spec 36422
     };
   }
 );
@@ -268,13 +265,21 @@ THREAD_STRUCT = (
   }
 );
 
-     log_config :
+#rfsimulator :
+#{
+#   serveraddr = "server";
+#   serverport = "4043";
+#   options = ("chanmod");
+#   modelname = "AWGN";
+#};
+
+log_config :
      {
        global_log_level                      ="info";
        global_log_verbosity                  ="medium";
        hw_log_level                          ="info";
        hw_log_verbosity                      ="medium";
-       phy_log_level                         ="info";
+       phy_log_level                         ="debug";
        phy_log_verbosity                     ="medium";
        mac_log_level                         ="info";
        mac_log_verbosity                     ="high";
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf
index 691224b8835..4cbec5b86e7 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf
@@ -21,183 +21,166 @@ gNBs =
 
     ////////// Physical parameters:
 
-    component_carriers = (
-      {
-      node_function                                                 = "3GPP_gNODEB";
-      node_timing                                                   = "synch_to_ext_device";
-      node_synch_ref                                                = 0;
-      frame_type                                                    = "TDD";
-      DL_prefix_type                                                = "NORMAL";
-      UL_prefix_type                                                = "NORMAL";
-      eutra_band                                                    = 78;
-      downlink_frequency                                            = 3510000000L;
-      uplink_frequency_offset                                       = -120000000;
-      Nid_cell                                                      = 0;
-      N_RB_DL                                                       = 217;
-      nb_antenna_ports                                              = 1;
-      nb_antennas_tx                                                = 1;
-      nb_antennas_rx                                                = 1;
-      tx_gain                                                       = 90;
-      rx_gain                                                       = 125;
-      MIB_subCarrierSpacingCommon                                   = 30;
-      MIB_ssb_SubcarrierOffset                                      = 0;
-      MIB_dmrs_TypeA_Position                                       = 2;
-      pdcch_ConfigSIB1                                              = 0;
-      SIB1_frequencyOffsetSSB                                       = "khz5";
-      SIB1_ssb_PeriodicityServingCell                               = 5;
-      SIB1_ss_PBCH_BlockPower                                       = -60;
-      absoluteFrequencySSB                                          = 0;
-      DL_FreqBandIndicatorNR                                        = 15;
-      DL_absoluteFrequencyPointA                                    = 15;
-      DL_offsetToCarrier                                            = 15;
-      DL_SCS_SubcarrierSpacing                                      = "kHz30";
-      DL_SCS_SpecificCarrier_k0                                     = 0;
-      DL_carrierBandwidth                                           = 15;
-      DL_locationAndBandwidth                                       = 15;
-      DL_BWP_SubcarrierSpacing                                      = "kHz30";
-      DL_BWP_prefix_type                                            = "NORMAL";
-      UL_FreqBandIndicatorNR                                        = 15;
-      UL_absoluteFrequencyPointA                                    = 13;
-      UL_additionalSpectrumEmission                                 = 3;
-      UL_p_Max                                                      = -1;
-      UL_frequencyShift7p5khz                                       = "TRUE";
-      UL_offsetToCarrier                                            = 10;
-      UL_SCS_SubcarrierSpacing                                      = "kHz30";
-      UL_SCS_SpecificCarrier_k0                                     = 0;
-      UL_carrierBandwidth                                           = 15;
-      UL_locationAndBandwidth                                       = 15;
-      UL_BWP_SubcarrierSpacing                                      = "kHz30";
-      UL_BWP_prefix_type                                            = "NORMAL";
-      UL_timeAlignmentTimerCommon                                   = "infinity";
-      ServingCellConfigCommon_n_TimingAdvanceOffset                 = "n0"
-      ServingCellConfigCommon_ssb_PositionsInBurst_PR               = 0x0ff;
-      ServingCellConfigCommon_ssb_periodicityServingCell            = 10;
-      ServingCellConfigCommon_dmrs_TypeA_Position                   = 2;
-      NIA_SubcarrierSpacing                                         = "kHz15"; 
-      ServingCellConfigCommon_ss_PBCH_BlockPower                    = -60;
-      referenceSubcarrierSpacing                                    = "kHz15";
-      dl_UL_TransmissionPeriodicity                                 = "ms0p5";
-      nrofDownlinkSlots                                             = 10;
-      nrofDownlinkSymbols                                           = 10;
-      nrofUplinkSlots                                               = 10;
-      nrofUplinkSymbols                                             = 10;
-      rach_totalNumberOfRA_Preambles                                = 63;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice         = "oneEighth";
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth      = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth      = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf        = 16;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one            = 24;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two            = 32;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four           = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight          = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen        = 2;
-      rach_groupBconfigured                                         = "ENABLE";
-      rach_ra_Msg3SizeGroupA                                        = 56;
-      rach_messagePowerOffsetGroupB                                 = "dB0";
-      rach_numberOfRA_PreamblesGroupA                               = 32;
-      rach_ra_ContentionResolutionTimer                             = 8;
-      rsrp_ThresholdSSB                                             = 64;
-      rsrp_ThresholdSSB_SUL                                         = 64;
-      prach_RootSequenceIndex_choice                                = "l839";
-      prach_RootSequenceIndex_l839                                  = 0;
-      prach_RootSequenceIndex_l139                                  = 0;
-      prach_msg1_SubcarrierSpacing                                  = "kHz30";
-      restrictedSetConfig                                           = "unrestrictedSet";
-      msg3_transformPrecoding                                       = "ENABLE";
-      prach_ConfigurationIndex                                      = 10;
-      prach_msg1_FDM                                                = "one";
-      prach_msg1_FrequencyStart                                     = 10;
-      zeroCorrelationZoneConfig                                     = 10;
-      preambleReceivedTargetPower                                   = -150;
-      preambleTransMax                                              = 6;
-      powerRampingStep                                              = "dB0";
-      ra_ResponseWindow                                             = 8;
-      groupHoppingEnabledTransformPrecoding                         = "ENABLE";
-      msg3_DeltaPreamble                                            = 0;
-      p0_NominalWithGrant                                           = 0;
-      PUSCH_TimeDomainResourceAllocation_k2                         = 0;
-      PUSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PUSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      pucch_ResourceCommon                                          = 0;
-      pucch_GroupHopping                                            = "neither";
-      hoppingId                                                     = 0;
-      p0_nominal                                                    = -30;
-      PDSCH_TimeDomainResourceAllocation_k0                         = 2;
-      PDSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PDSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      rateMatchPatternId                                            = 0;
-      RateMatchPattern_patternType                                  = "bitmaps";
-      symbolsInResourceBlock                                        = "oneSlot";
-      periodicityAndPattern                                         = 2;
-      RateMatchPattern_controlResourceSet                           = 5;
-      RateMatchPattern_subcarrierSpacing                            = "kHz30";
-      RateMatchPattern_mode                                         = "dynamic";
-      controlResourceSetZero                                        = 0;
-      searchSpaceZero                                               = 0;
-      searchSpaceSIB1                                               = 10;
-      searchSpaceOtherSystemInformation                             = 10;
-      pagingSearchSpace                                             = 10;
-      ra_SearchSpace                                                = 10;
-      PDCCH_common_controlResourceSetId                             = 5;
-      PDCCH_common_ControlResourceSet_duration                      = 2;
-      PDCCH_cce_REG_MappingType                                     = "nonInterleaved";
-      PDCCH_reg_BundleSize                                          = 3;
-      PDCCH_interleaverSize                                         = 3;
-      PDCCH_shiftIndex                                              = 10;  
-      PDCCH_precoderGranularity                                     = "sameAsREG-bundle";
-      PDCCH_TCI_StateId                                             = 32;
-      tci_PresentInDCI                                              = "ENABLE";
-      PDCCH_DMRS_ScramblingID                                       = 0;
-      SearchSpaceId                                                 = 10;
-      commonSearchSpaces_controlResourceSetId                       = 5;
-      SearchSpace_monitoringSlotPeriodicityAndOffset_choice         = "sl1";
-      SearchSpace_monitoringSlotPeriodicityAndOffset_value          = 0;
-      SearchSpace_duration                                          = 2;
-      SearchSpace_nrofCandidates_aggregationLevel1                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel2                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel4                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel8                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel16                 = 0;
-      SearchSpace_searchSpaceType                                   = "common";
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16    = 1; 
-      Common_dci_Format2_3_monitoringPeriodicity                    = 1;
-      Common_dci_Format2_3_nrofPDCCH_Candidates                     = 1;
-      ue_Specific__dci_Formats                                      = "formats0-0-And-1-0";
-      RateMatchPatternLTE_CRS_carrierFreqDL                         = 6;
-      RateMatchPatternLTE_CRS_carrierBandwidthDL                    = 6;
-      RateMatchPatternLTE_CRS_nrofCRS_Ports                         = 1;
-      RateMatchPatternLTE_CRS_v_Shift                               = 0;
-      RateMatchPatternLTE_CRS_radioframeAllocationPeriod            = 1;
-      RateMatchPatternLTE_CRS_radioframeAllocationOffset            = 0;
-      RateMatchPatternLTE_CRS_subframeAllocation_choice             = "oneFrame";
-      }
-    );
-
-
-    srb1_parameters :
+    ssb_SubcarrierOffset                                      = 0;
+    pdsch_AntennaPorts                                        = 1;
+	
+    servingCellConfigCommon = (
     {
-        # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
-        timer_poll_retransmit    = 80;
+ #spCellConfigCommon
 
-        # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
-        timer_reordering         = 35;
+      physCellId                                                    = 0;
 
-        # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
-        timer_status_prohibit    = 0;
+#  downlinkConfigCommon
+    #frequencyInfoDL
+      # this is 3600 MHz + 84 PRBs@30kHz SCS (same as initial BWP)
+      absoluteFrequencySSB                                          = 642016;
+      dl_frequencyBand                                                 = 78;
+      # this is 3600 MHz
+      dl_absoluteFrequencyPointA                                       = 640000;
+      #scs-SpecificCarrierList
+        dl_offstToCarrier                                              = 0;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        dl_subcarrierSpacing                                           = 1;
+        dl_carrierBandwidth                                            = 217;
+     #initialDownlinkBWP
+      #genericParameters
+        # this is RBstart=84,L=50 (275*(L-1))+RBstart
+        initialDLBWPlocationAndBandwidth                                        = 13559;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialDLBWPsubcarrierSpacing                                           = 1;
+      #pdcch-ConfigCommon
+        initialDLBWPcontrolResourceSetZero                                      = 12;
+        initialDLBWPsearchSpaceZero                                             = 0;
+      #pdsch-ConfigCommon
+        #pdschTimeDomainAllocationList (up to 16 entries)
+             initialDLBWPk0_0                    = 0;
+             #initialULBWPmappingType
+	     #0=typeA,1=typeB
+             initialDLBWPmappingType_0           = 0;
+             #this is SS=2,L=3
+             initialDLBWPstartSymbolAndLength_0  = 40;
 
-        # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
-        poll_pdu                 =  4;
+             initialDLBWPk0_1                    = 0;
+             initialDLBWPmappingType_1           = 0;
+             #this is SS=2,L=12 
+             initialDLBWPstartSymbolAndLength_1  = 53;
 
-        # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
-        poll_byte                =  99999;
+             initialDLBWPk0_2                    = 0;
+             initialDLBWPmappingType_2           = 0;
+             #this is SS=1,L=12 
+             initialDLBWPstartSymbolAndLength_2  = 54;
+  #uplinkConfigCommon 
+     #frequencyInfoUL
+      ul_frequencyBand                                                 = 78;
+      #scs-SpecificCarrierList
+      ul_offstToCarrier                                              = 0;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      ul_subcarrierSpacing                                           = 1;
+      ul_carrierBandwidth                                            = 217;
+      pMax                                                          = 20;
+     #initialUplinkBWP
+      #genericParameters
+        initialULBWPlocationAndBandwidth                                        = 13559;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialULBWPsubcarrierSpacing                                           = 1;
+      #rach-ConfigCommon
+        #rach-ConfigGeneric
+          prach_ConfigurationIndex                                  = 98;
+#prach_msg1_FDM
+#0 = one, 1=two, 2=four, 3=eight
+          prach_msg1_FDM                                            = 0;
+          prach_msg1_FrequencyStart                                 = 0;
+          zeroCorrelationZoneConfig                                 = 13;
+          preambleReceivedTargetPower                               = -118;
+#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200)
+          preambleTransMax                                          = 6;
+#powerRampingStep
+# 0=dB0,1=dB2,2=dB4,3=dB6
+        powerRampingStep                                            = 1;
+#ra_ReponseWindow
+#1,2,4,8,10,20,40,80
+        ra_ResponseWindow                                           = 4;
+#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR
+#0=oneeighth,1=onefourth,2=half,3=one,4=two,5=four,6=eight,7=sixteen
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR                = 3;
+#oneHalf (0..15) 4,8,12,16,...60,64
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB                   = 15;
+#ra_ContentionResolutionTimer
+#(0..7) 8,16,24,32,40,48,56,64
+        ra_ContentionResolutionTimer                                = 7;
+        rsrp_ThresholdSSB                                           = 19;
+#prach-RootSequenceIndex_PR
+#0 = 839, 1 = 139
+        prach_RootSequenceIndex_PR                                  = 1;
+        prach_RootSequenceIndex                                     = 1;
+        # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex
+        #  
+        msg1_SubcarrierSpacing                                      = 1,
+
+# restrictedSetConfig
+# 0=unrestricted, 1=restricted type A, 2=restricted type B
+        restrictedSetConfig                                         = 0,
+      # pusch-ConfigCommon (up to 16 elements)
+        initialULBWPk2_0                      = 2;
+        initialULBWPmappingType_0             = 1
+        # this is SS=0 L=11
+        initialULBWPstartSymbolAndLength_0    = 55;
+ 	
+	initialULBWPk2_1                      = 2;
+        initialULBWPmappingType_1             = 1;
+        # this is SS=0 L=12
+        initialULBWPstartSymbolAndLength_1    = 69;
+
+
+        msg3_DeltaPreamble                                          = 1;
+        p0_NominalWithGrant                                         =-90;
+
+# pucch-ConfigCommon setup :
+# pucchGroupHopping
+# 0 = neither, 1= group hopping, 2=sequence hopping
+        pucchGroupHopping                                           = 0;
+        hoppingId                                                   = 40;
+        p0_nominal                                                  = -90;
+# ssb_PositionsInBurs_BitmapPR
+# 1=short, 2=medium, 3=long
+      ssb_PositionsInBurst_PR                                       = 2;
+      ssb_PositionsInBurst_Bitmap                                   = 255;
+
+# ssb_periodicityServingCell
+# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 
+      ssb_periodicityServingCell                                    = 2;
+
+# dmrs_TypeA_position
+# 0 = pos2, 1 = pos3
+      dmrs_TypeA_Position                                           = 0;
+
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      subcarrierSpacing                                             = 1;
+
+
+  #tdd-UL-DL-ConfigurationCommon
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      referenceSubcarrierSpacing                                    = 1;
+      # pattern1 
+      # dl_UL_TransmissionPeriodicity
+      # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10
+      dl_UL_TransmissionPeriodicity                                 = 6;
+      nrofDownlinkSlots                                             = 7;
+      nrofDownlinkSymbols                                           = 6;
+      nrofUplinkSlots                                               = 2;
+      nrofUplinkSymbols                                             = 4;
+
+  ssPBCH_BlockPower                                             = 10;
+  }
+
+  );
 
-        # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
-        max_retx_threshold       =  4;
-    }
 
     # ------- SCTP definitions
     SCTP :
@@ -246,7 +229,7 @@ L1s = (
 RUs = (
     {		  
        local_rf       = "yes"
-         nb_tx          = 8
+         nb_tx          = 1
          nb_rx          = 1
          att_tx         = 0
          att_rx         = 0;
@@ -255,29 +238,18 @@ RUs = (
          max_rxgain                    = 114;
          eNB_instances  = [0];
 	 sdr_addrs = "type=x300";
-
     }
 );  
 
 THREAD_STRUCT = (
   {
     #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT"
-    parallel_config    = "PARALLEL_SINGLE_THREAD";
+    parallel_config    = "PARALLEL_RU_L1_TRX_SPLIT";
     #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE"
     worker_config      = "WORKER_ENABLE";
   }
 );
 
-NETWORK_CONTROLLER :
-{
-    FLEXRAN_ENABLED        = "no";
-    FLEXRAN_INTERFACE_NAME = "lo";
-    FLEXRAN_IPV4_ADDRESS   = "127.0.0.1";
-    FLEXRAN_PORT           = 2210;
-    FLEXRAN_CACHE          = "/mnt/oai_agent_cache";
-    FLEXRAN_AWAIT_RECONF   = "no";
-};
-
      log_config :
      {
        global_log_level                      ="info";
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf
index ce8af8f5b84..f5e2298a997 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf
@@ -21,183 +21,166 @@ gNBs =
 
     ////////// Physical parameters:
 
-    component_carriers = (
-      {
-      node_function                                                 = "3GPP_gNODEB";
-      node_timing                                                   = "synch_to_ext_device";
-      node_synch_ref                                                = 0;
-      frame_type                                                    = "TDD";
-      DL_prefix_type                                                = "NORMAL";
-      UL_prefix_type                                                = "NORMAL";
-      eutra_band                                                    = 78;
-      downlink_frequency                                            = 3510000000L;
-      uplink_frequency_offset                                       = -120000000;
-      Nid_cell                                                      = 0;
-      N_RB_DL                                                       = 273;
-      nb_antenna_ports                                              = 1;
-      nb_antennas_tx                                                = 1;
-      nb_antennas_rx                                                = 1;
-      tx_gain                                                       = 90;
-      rx_gain                                                       = 125;
-      MIB_subCarrierSpacingCommon                                   = 30;
-      MIB_ssb_SubcarrierOffset                                      = 0;
-      MIB_dmrs_TypeA_Position                                       = 2;
-      pdcch_ConfigSIB1                                              = 0;
-      SIB1_frequencyOffsetSSB                                       = "khz5";
-      SIB1_ssb_PeriodicityServingCell                               = 5;
-      SIB1_ss_PBCH_BlockPower                                       = -60;
-      absoluteFrequencySSB                                          = 0;
-      DL_FreqBandIndicatorNR                                        = 15;
-      DL_absoluteFrequencyPointA                                    = 15;
-      DL_offsetToCarrier                                            = 15;
-      DL_SCS_SubcarrierSpacing                                      = "kHz30";
-      DL_SCS_SpecificCarrier_k0                                     = 0;
-      DL_carrierBandwidth                                           = 15;
-      DL_locationAndBandwidth                                       = 15;
-      DL_BWP_SubcarrierSpacing                                      = "kHz30";
-      DL_BWP_prefix_type                                            = "NORMAL";
-      UL_FreqBandIndicatorNR                                        = 15;
-      UL_absoluteFrequencyPointA                                    = 13;
-      UL_additionalSpectrumEmission                                 = 3;
-      UL_p_Max                                                      = -1;
-      UL_frequencyShift7p5khz                                       = "TRUE";
-      UL_offsetToCarrier                                            = 10;
-      UL_SCS_SubcarrierSpacing                                      = "kHz30";
-      UL_SCS_SpecificCarrier_k0                                     = 0;
-      UL_carrierBandwidth                                           = 15;
-      UL_locationAndBandwidth                                       = 15;
-      UL_BWP_SubcarrierSpacing                                      = "kHz30";
-      UL_BWP_prefix_type                                            = "NORMAL";
-      UL_timeAlignmentTimerCommon                                   = "infinity";
-      ServingCellConfigCommon_n_TimingAdvanceOffset                 = "n0"
-      ServingCellConfigCommon_ssb_PositionsInBurst_PR               = 0x01;
-      ServingCellConfigCommon_ssb_periodicityServingCell            = 10;
-      ServingCellConfigCommon_dmrs_TypeA_Position                   = 2;
-      NIA_SubcarrierSpacing                                         = "kHz15"; 
-      ServingCellConfigCommon_ss_PBCH_BlockPower                    = -60;
-      referenceSubcarrierSpacing                                    = "kHz15";
-      dl_UL_TransmissionPeriodicity                                 = "ms0p5";
-      nrofDownlinkSlots                                             = 10;
-      nrofDownlinkSymbols                                           = 10;
-      nrofUplinkSlots                                               = 10;
-      nrofUplinkSymbols                                             = 10;
-      rach_totalNumberOfRA_Preambles                                = 63;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice         = "oneEighth";
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth      = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth      = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf        = 16;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one            = 24;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two            = 32;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four           = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight          = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen        = 2;
-      rach_groupBconfigured                                         = "ENABLE";
-      rach_ra_Msg3SizeGroupA                                        = 56;
-      rach_messagePowerOffsetGroupB                                 = "dB0";
-      rach_numberOfRA_PreamblesGroupA                               = 32;
-      rach_ra_ContentionResolutionTimer                             = 8;
-      rsrp_ThresholdSSB                                             = 64;
-      rsrp_ThresholdSSB_SUL                                         = 64;
-      prach_RootSequenceIndex_choice                                = "l839";
-      prach_RootSequenceIndex_l839                                  = 0;
-      prach_RootSequenceIndex_l139                                  = 0;
-      prach_msg1_SubcarrierSpacing                                  = "kHz30";
-      restrictedSetConfig                                           = "unrestrictedSet";
-      msg3_transformPrecoding                                       = "ENABLE";
-      prach_ConfigurationIndex                                      = 10;
-      prach_msg1_FDM                                                = "one";
-      prach_msg1_FrequencyStart                                     = 10;
-      zeroCorrelationZoneConfig                                     = 10;
-      preambleReceivedTargetPower                                   = -150;
-      preambleTransMax                                              = 6;
-      powerRampingStep                                              = "dB0";
-      ra_ResponseWindow                                             = 8;
-      groupHoppingEnabledTransformPrecoding                         = "ENABLE";
-      msg3_DeltaPreamble                                            = 0;
-      p0_NominalWithGrant                                           = 0;
-      PUSCH_TimeDomainResourceAllocation_k2                         = 0;
-      PUSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PUSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      pucch_ResourceCommon                                          = 0;
-      pucch_GroupHopping                                            = "neither";
-      hoppingId                                                     = 0;
-      p0_nominal                                                    = -30;
-      PDSCH_TimeDomainResourceAllocation_k0                         = 2;
-      PDSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PDSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      rateMatchPatternId                                            = 0;
-      RateMatchPattern_patternType                                  = "bitmaps";
-      symbolsInResourceBlock                                        = "oneSlot";
-      periodicityAndPattern                                         = 2;
-      RateMatchPattern_controlResourceSet                           = 5;
-      RateMatchPattern_subcarrierSpacing                            = "kHz30";
-      RateMatchPattern_mode                                         = "dynamic";
-      controlResourceSetZero                                        = 0;
-      searchSpaceZero                                               = 0;
-      searchSpaceSIB1                                               = 10;
-      searchSpaceOtherSystemInformation                             = 10;
-      pagingSearchSpace                                             = 10;
-      ra_SearchSpace                                                = 10;
-      PDCCH_common_controlResourceSetId                             = 5;
-      PDCCH_common_ControlResourceSet_duration                      = 2;
-      PDCCH_cce_REG_MappingType                                     = "nonInterleaved";
-      PDCCH_reg_BundleSize                                          = 3;
-      PDCCH_interleaverSize                                         = 3;
-      PDCCH_shiftIndex                                              = 10;  
-      PDCCH_precoderGranularity                                     = "sameAsREG-bundle";
-      PDCCH_TCI_StateId                                             = 32;
-      tci_PresentInDCI                                              = "ENABLE";
-      PDCCH_DMRS_ScramblingID                                       = 0;
-      SearchSpaceId                                                 = 10;
-      commonSearchSpaces_controlResourceSetId                       = 5;
-      SearchSpace_monitoringSlotPeriodicityAndOffset_choice         = "sl1";
-      SearchSpace_monitoringSlotPeriodicityAndOffset_value          = 0;
-      SearchSpace_duration                                          = 2;
-      SearchSpace_nrofCandidates_aggregationLevel1                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel2                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel4                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel8                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel16                 = 0;
-      SearchSpace_searchSpaceType                                   = "common";
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16    = 1; 
-      Common_dci_Format2_3_monitoringPeriodicity                    = 1;
-      Common_dci_Format2_3_nrofPDCCH_Candidates                     = 1;
-      ue_Specific__dci_Formats                                      = "formats0-0-And-1-0";
-      RateMatchPatternLTE_CRS_carrierFreqDL                         = 6;
-      RateMatchPatternLTE_CRS_carrierBandwidthDL                    = 6;
-      RateMatchPatternLTE_CRS_nrofCRS_Ports                         = 1;
-      RateMatchPatternLTE_CRS_v_Shift                               = 0;
-      RateMatchPatternLTE_CRS_radioframeAllocationPeriod            = 1;
-      RateMatchPatternLTE_CRS_radioframeAllocationOffset            = 0;
-      RateMatchPatternLTE_CRS_subframeAllocation_choice             = "oneFrame";
-      }
-    );
-
-
-    srb1_parameters :
+    ssb_SubcarrierOffset                                      = 0;
+    pdsch_AntennaPorts                                        = 1;
+	
+    servingCellConfigCommon = (
     {
-        # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
-        timer_poll_retransmit    = 80;
+ #spCellConfigCommon
 
-        # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
-        timer_reordering         = 35;
+      physCellId                                                    = 0;
 
-        # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
-        timer_status_prohibit    = 0;
+#  downlinkConfigCommon
+    #frequencyInfoDL
+      # this is 3600 MHz + 84 PRBs@30kHz SCS (same as initial BWP)
+      absoluteFrequencySSB                                          = 642016;
+      dl_frequencyBand                                                 = 78;
+      # this is 3600 MHz
+      dl_absoluteFrequencyPointA                                       = 640000;
+      #scs-SpecificCarrierList
+        dl_offstToCarrier                                              = 0;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        dl_subcarrierSpacing                                           = 1;
+        dl_carrierBandwidth                                            = 273;
+     #initialDownlinkBWP
+      #genericParameters
+        # this is RBstart=84,L=50 (275*(L-1))+RBstart
+        initialDLBWPlocationAndBandwidth                                        = 13559;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialDLBWPsubcarrierSpacing                                           = 1;
+      #pdcch-ConfigCommon
+        initialDLBWPcontrolResourceSetZero                                      = 12;
+        initialDLBWPsearchSpaceZero                                             = 0;
+      #pdsch-ConfigCommon
+        #pdschTimeDomainAllocationList (up to 16 entries)
+             initialDLBWPk0_0                    = 0;
+             #initialULBWPmappingType
+	     #0=typeA,1=typeB
+             initialDLBWPmappingType_0           = 0;
+             #this is SS=2,L=3
+             initialDLBWPstartSymbolAndLength_0  = 40;
 
-        # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
-        poll_pdu                 =  4;
+             initialDLBWPk0_1                    = 0;
+             initialDLBWPmappingType_1           = 0;
+             #this is SS=2,L=12 
+             initialDLBWPstartSymbolAndLength_1  = 53;
 
-        # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
-        poll_byte                =  99999;
+             initialDLBWPk0_2                    = 0;
+             initialDLBWPmappingType_2           = 0;
+             #this is SS=1,L=12 
+             initialDLBWPstartSymbolAndLength_2  = 54;
+  #uplinkConfigCommon 
+     #frequencyInfoUL
+      ul_frequencyBand                                                 = 78;
+      #scs-SpecificCarrierList
+      ul_offstToCarrier                                              = 0;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      ul_subcarrierSpacing                                           = 1;
+      ul_carrierBandwidth                                            = 273;
+      pMax                                                          = 20;
+     #initialUplinkBWP
+      #genericParameters
+        initialULBWPlocationAndBandwidth                                        = 13559;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialULBWPsubcarrierSpacing                                           = 1;
+      #rach-ConfigCommon
+        #rach-ConfigGeneric
+          prach_ConfigurationIndex                                  = 98;
+#prach_msg1_FDM
+#0 = one, 1=two, 2=four, 3=eight
+          prach_msg1_FDM                                            = 0;
+          prach_msg1_FrequencyStart                                 = 0;
+          zeroCorrelationZoneConfig                                 = 13;
+          preambleReceivedTargetPower                               = -118;
+#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200)
+          preambleTransMax                                          = 6;
+#powerRampingStep
+# 0=dB0,1=dB2,2=dB4,3=dB6
+        powerRampingStep                                            = 1;
+#ra_ReponseWindow
+#1,2,4,8,10,20,40,80
+        ra_ResponseWindow                                           = 4;
+#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR
+#0=oneeighth,1=onefourth,2=half,3=one,4=two,5=four,6=eight,7=sixteen
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR                = 3;
+#oneHalf (0..15) 4,8,12,16,...60,64
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB                   = 15;
+#ra_ContentionResolutionTimer
+#(0..7) 8,16,24,32,40,48,56,64
+        ra_ContentionResolutionTimer                                = 7;
+        rsrp_ThresholdSSB                                           = 19;
+#prach-RootSequenceIndex_PR
+#0 = 839, 1 = 139
+        prach_RootSequenceIndex_PR                                  = 1;
+        prach_RootSequenceIndex                                     = 1;
+        # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex
+        #  
+        msg1_SubcarrierSpacing                                      = 1,
+
+# restrictedSetConfig
+# 0=unrestricted, 1=restricted type A, 2=restricted type B
+        restrictedSetConfig                                         = 0,
+      # pusch-ConfigCommon (up to 16 elements)
+        initialULBWPk2_0                      = 2;
+        initialULBWPmappingType_0             = 1
+        # this is SS=0 L=11
+        initialULBWPstartSymbolAndLength_0    = 55;
+ 	
+	initialULBWPk2_1                      = 2;
+        initialULBWPmappingType_1             = 1;
+        # this is SS=0 L=12
+        initialULBWPstartSymbolAndLength_1    = 69;
+
+
+        msg3_DeltaPreamble                                          = 1;
+        p0_NominalWithGrant                                         =-90;
+
+# pucch-ConfigCommon setup :
+# pucchGroupHopping
+# 0 = neither, 1= group hopping, 2=sequence hopping
+        pucchGroupHopping                                           = 0;
+        hoppingId                                                   = 40;
+        p0_nominal                                                  = -90;
+# ssb_PositionsInBurs_BitmapPR
+# 1=short, 2=medium, 3=long
+      ssb_PositionsInBurst_PR                                       = 2;
+      ssb_PositionsInBurst_Bitmap                                   = 255;
+
+# ssb_periodicityServingCell
+# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 
+      ssb_periodicityServingCell                                    = 2;
+
+# dmrs_TypeA_position
+# 0 = pos2, 1 = pos3
+      dmrs_TypeA_Position                                           = 0;
+
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      subcarrierSpacing                                             = 1;
+
+
+  #tdd-UL-DL-ConfigurationCommon
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+      referenceSubcarrierSpacing                                    = 1;
+      # pattern1 
+      # dl_UL_TransmissionPeriodicity
+      # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10
+      dl_UL_TransmissionPeriodicity                                 = 6;
+      nrofDownlinkSlots                                             = 7;
+      nrofDownlinkSymbols                                           = 6;
+      nrofUplinkSlots                                               = 2;
+      nrofUplinkSymbols                                             = 4;
+
+  ssPBCH_BlockPower                                             = 10;
+  }
+
+  );
 
-        # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
-        max_retx_threshold       =  4;
-    }
 
     # ------- SCTP definitions
     SCTP :
@@ -254,7 +237,8 @@ RUs = (
          max_pdschReferenceSignalPower = -27;
          max_rxgain                    = 114;
          eNB_instances  = [0];
-	 sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2,mgmt_addr=192.168.10.2,clock_source=external,time_source=external";
+	 sdr_addrs = "addr=192.168.10.2,mgmt_addr=192.168.10.2";
+         clock_src = "external";
     }
 );  
 
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.beamw.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.beamw.usrpn300.conf
deleted file mode 100644
index a9d251efa2d..00000000000
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.beamw.usrpn300.conf
+++ /dev/null
@@ -1,291 +0,0 @@
-Active_gNBs = ( "gNB-Eurecom-5GNRBox");
-# Asn1_verbosity, choice in: none, info, annoying
-Asn1_verbosity = "none";
-
-gNBs =
-(
- {
-    ////////// Identification parameters:
-    gNB_ID    =  0xe00;
-
-    cell_type =  "CELL_MACRO_GNB";
-
-    gNB_name  =  "gNB-Eurecom-5GNRBox";
-
-    // Tracking area code, 0x0000 and 0xfffe are reserved values
-    tracking_area_code  =  1;
-
-    plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;});	 
-
-    tr_s_preference     = "local_mac"
-
-    ////////// Physical parameters:
-
-    component_carriers = (
-      {
-      node_function                                                 = "3GPP_gNODEB";
-      node_timing                                                   = "synch_to_ext_device";
-      node_synch_ref                                                = 0;
-      frame_type                                                    = "TDD";
-      DL_prefix_type                                                = "NORMAL";
-      UL_prefix_type                                                = "NORMAL";
-      eutra_band                                                    = 78;
-      downlink_frequency                                            = 3510000000L;
-      uplink_frequency_offset                                       = -120000000;
-      Nid_cell                                                      = 0;
-      N_RB_DL                                                       = 217;
-      nb_antenna_ports                                              = 1;
-      nb_antennas_tx                                                = 1;
-      nb_antennas_rx                                                = 1;
-      tx_gain                                                       = 90;
-      rx_gain                                                       = 125;
-      MIB_subCarrierSpacingCommon                                   = 30;
-      MIB_ssb_SubcarrierOffset                                      = 0;
-      MIB_dmrs_TypeA_Position                                       = 2;
-      pdcch_ConfigSIB1                                              = 0;
-      SIB1_frequencyOffsetSSB                                       = "khz5";
-      SIB1_ssb_PeriodicityServingCell                               = 5;
-      SIB1_ss_PBCH_BlockPower                                       = -60;
-      absoluteFrequencySSB                                          = 0;
-      DL_FreqBandIndicatorNR                                        = 15;
-      DL_absoluteFrequencyPointA                                    = 15;
-      DL_offsetToCarrier                                            = 15;
-      DL_SCS_SubcarrierSpacing                                      = "kHz30";
-      DL_SCS_SpecificCarrier_k0                                     = 0;
-      DL_carrierBandwidth                                           = 15;
-      DL_locationAndBandwidth                                       = 15;
-      DL_BWP_SubcarrierSpacing                                      = "kHz30";
-      DL_BWP_prefix_type                                            = "NORMAL";
-      UL_FreqBandIndicatorNR                                        = 15;
-      UL_absoluteFrequencyPointA                                    = 13;
-      UL_additionalSpectrumEmission                                 = 3;
-      UL_p_Max                                                      = -1;
-      UL_frequencyShift7p5khz                                       = "TRUE";
-      UL_offsetToCarrier                                            = 10;
-      UL_SCS_SubcarrierSpacing                                      = "kHz30";
-      UL_SCS_SpecificCarrier_k0                                     = 0;
-      UL_carrierBandwidth                                           = 15;
-      UL_locationAndBandwidth                                       = 15;
-      UL_BWP_SubcarrierSpacing                                      = "kHz30";
-      UL_BWP_prefix_type                                            = "NORMAL";
-      UL_timeAlignmentTimerCommon                                   = "infinity";
-      ServingCellConfigCommon_n_TimingAdvanceOffset                 = "n0"
-      ServingCellConfigCommon_ssb_PositionsInBurst_PR               = 0x03;
-      ServingCellConfigCommon_ssb_periodicityServingCell            = 10;
-      ServingCellConfigCommon_dmrs_TypeA_Position                   = 2;
-      NIA_SubcarrierSpacing                                         = "kHz15"; 
-      ServingCellConfigCommon_ss_PBCH_BlockPower                    = -60;
-      referenceSubcarrierSpacing                                    = "kHz15";
-      dl_UL_TransmissionPeriodicity                                 = "ms0p5";
-      nrofDownlinkSlots                                             = 10;
-      nrofDownlinkSymbols                                           = 10;
-      nrofUplinkSlots                                               = 10;
-      nrofUplinkSymbols                                             = 10;
-      rach_totalNumberOfRA_Preambles                                = 63;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice         = "oneEighth";
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth      = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth      = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf        = 16;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one            = 24;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two            = 32;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four           = 8;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight          = 4;
-      rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen        = 2;
-      rach_groupBconfigured                                         = "ENABLE";
-      rach_ra_Msg3SizeGroupA                                        = 56;
-      rach_messagePowerOffsetGroupB                                 = "dB0";
-      rach_numberOfRA_PreamblesGroupA                               = 32;
-      rach_ra_ContentionResolutionTimer                             = 8;
-      rsrp_ThresholdSSB                                             = 64;
-      rsrp_ThresholdSSB_SUL                                         = 64;
-      prach_RootSequenceIndex_choice                                = "l839";
-      prach_RootSequenceIndex_l839                                  = 0;
-      prach_RootSequenceIndex_l139                                  = 0;
-      prach_msg1_SubcarrierSpacing                                  = "kHz30";
-      restrictedSetConfig                                           = "unrestrictedSet";
-      msg3_transformPrecoding                                       = "ENABLE";
-      prach_ConfigurationIndex                                      = 10;
-      prach_msg1_FDM                                                = "one";
-      prach_msg1_FrequencyStart                                     = 10;
-      zeroCorrelationZoneConfig                                     = 10;
-      preambleReceivedTargetPower                                   = -150;
-      preambleTransMax                                              = 6;
-      powerRampingStep                                              = "dB0";
-      ra_ResponseWindow                                             = 8;
-      groupHoppingEnabledTransformPrecoding                         = "ENABLE";
-      msg3_DeltaPreamble                                            = 0;
-      p0_NominalWithGrant                                           = 0;
-      PUSCH_TimeDomainResourceAllocation_k2                         = 0;
-      PUSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PUSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      pucch_ResourceCommon                                          = 0;
-      pucch_GroupHopping                                            = "neither";
-      hoppingId                                                     = 0;
-      p0_nominal                                                    = -30;
-      PDSCH_TimeDomainResourceAllocation_k0                         = 2;
-      PDSCH_TimeDomainResourceAllocation_mappingType                = "typeA";
-      PDSCH_TimeDomainResourceAllocation_startSymbolAndLength       = 0;
-      rateMatchPatternId                                            = 0;
-      RateMatchPattern_patternType                                  = "bitmaps";
-      symbolsInResourceBlock                                        = "oneSlot";
-      periodicityAndPattern                                         = 2;
-      RateMatchPattern_controlResourceSet                           = 5;
-      RateMatchPattern_subcarrierSpacing                            = "kHz30";
-      RateMatchPattern_mode                                         = "dynamic";
-      controlResourceSetZero                                        = 0;
-      searchSpaceZero                                               = 0;
-      searchSpaceSIB1                                               = 10;
-      searchSpaceOtherSystemInformation                             = 10;
-      pagingSearchSpace                                             = 10;
-      ra_SearchSpace                                                = 10;
-      PDCCH_common_controlResourceSetId                             = 5;
-      PDCCH_common_ControlResourceSet_duration                      = 2;
-      PDCCH_cce_REG_MappingType                                     = "nonInterleaved";
-      PDCCH_reg_BundleSize                                          = 3;
-      PDCCH_interleaverSize                                         = 3;
-      PDCCH_shiftIndex                                              = 10;  
-      PDCCH_precoderGranularity                                     = "sameAsREG-bundle";
-      PDCCH_TCI_StateId                                             = 32;
-      tci_PresentInDCI                                              = "ENABLE";
-      PDCCH_DMRS_ScramblingID                                       = 0;
-      SearchSpaceId                                                 = 10;
-      commonSearchSpaces_controlResourceSetId                       = 5;
-      SearchSpace_monitoringSlotPeriodicityAndOffset_choice         = "sl1";
-      SearchSpace_monitoringSlotPeriodicityAndOffset_value          = 0;
-      SearchSpace_duration                                          = 2;
-      SearchSpace_nrofCandidates_aggregationLevel1                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel2                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel4                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel8                  = 0;
-      SearchSpace_nrofCandidates_aggregationLevel16                 = 0;
-      SearchSpace_searchSpaceType                                   = "common";
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8     = 1;
-      Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16    = 1; 
-      Common_dci_Format2_3_monitoringPeriodicity                    = 1;
-      Common_dci_Format2_3_nrofPDCCH_Candidates                     = 1;
-      ue_Specific__dci_Formats                                      = "formats0-0-And-1-0";
-      RateMatchPatternLTE_CRS_carrierFreqDL                         = 6;
-      RateMatchPatternLTE_CRS_carrierBandwidthDL                    = 6;
-      RateMatchPatternLTE_CRS_nrofCRS_Ports                         = 1;
-      RateMatchPatternLTE_CRS_v_Shift                               = 0;
-      RateMatchPatternLTE_CRS_radioframeAllocationPeriod            = 1;
-      RateMatchPatternLTE_CRS_radioframeAllocationOffset            = 0;
-      RateMatchPatternLTE_CRS_subframeAllocation_choice             = "oneFrame";
-      }
-    );
-
-
-    srb1_parameters :
-    {
-        # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
-        timer_poll_retransmit    = 80;
-
-        # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
-        timer_reordering         = 35;
-
-        # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
-        timer_status_prohibit    = 0;
-
-        # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
-        poll_pdu                 =  4;
-
-        # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
-        poll_byte                =  99999;
-
-        # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
-        max_retx_threshold       =  4;
-    }
-
-    # ------- SCTP definitions
-    SCTP :
-    {
-        # Number of streams to use in input/output
-        SCTP_INSTREAMS  = 2;
-        SCTP_OUTSTREAMS = 2;
-    };
-
-
-    ////////// MME parameters:
-    mme_ip_address      = ( { ipv4       = "192.168.12.26";
-                              ipv6       = "192:168:30::17";
-                              active     = "yes";
-                              preference = "ipv4";
-                            }
-                          );
-
-    NETWORK_INTERFACES :
-    {
-
-        GNB_INTERFACE_NAME_FOR_S1_MME            = "eth0";
-        GNB_IPV4_ADDRESS_FOR_S1_MME              = "192.168.12.111/24";
-        GNB_INTERFACE_NAME_FOR_S1U               = "eth0";
-        GNB_IPV4_ADDRESS_FOR_S1U                 = "192.168.12.111/24";
-        GNB_PORT_FOR_S1U                         = 2152; # Spec 2152
-    };
-  }
-);
-
-MACRLCs = (
-	{
-	num_cc = 1;
-	tr_s_preference = "local_L1";
-	tr_n_preference = "local_RRC";
-        }  
-);
-
-L1s = (
-    	{
-	num_cc = 1;
-	tr_n_preference = "local_mac";
-        }  
-);
-
-RUs = (
-    {		  
-       local_rf       = "yes"
-         nb_tx          = 2
-         nb_rx          = 1
-         att_tx         = 0
-         att_rx         = 0;
-         bands          = [7];
-         max_pdschReferenceSignalPower = -27;
-         max_rxgain                    = 114;
-         eNB_instances  = [0];
-	 sdr_addrs = "addr=192.168.10.2";
-         # beamforming weights for static beams each of them is a int32 composed by two int16 representing imaginary and real part of the weight
-         # weights are input in an array, starting with the weights associated to first logical beam for all nb_tx , than the weights for 2nd logical beam and so on
-         # the list size is (nb_tx) X (number of logical beams) 
-   	 bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff];
-    }
-);  
-
-THREAD_STRUCT = (
-  {
-    #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT"
-    parallel_config    = "PARALLEL_RU_L1_TRX_SPLIT";
-    #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE"
-    worker_config      = "WORKER_ENABLE";
-  }
-);
-
-     log_config :
-     {
-       global_log_level                      ="info";
-       global_log_verbosity                  ="medium";
-       hw_log_level                          ="info";
-       hw_log_verbosity                      ="medium";
-       phy_log_level                         ="info";
-       phy_log_verbosity                     ="medium";
-       mac_log_level                         ="info";
-       mac_log_verbosity                     ="high";
-       rlc_log_level                         ="info";
-       rlc_log_verbosity                     ="medium";
-       pdcp_log_level                        ="info";
-       pdcp_log_verbosity                    ="medium";
-       rrc_log_level                         ="info";
-       rrc_log_verbosity                     ="medium";
-    };
-
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index f88d98536d3..e6364cad237 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -2194,7 +2194,9 @@ int start_rf(RU_t *ru) {
 }
 
 int stop_rf(RU_t *ru) {
-  ru->rfdevice.trx_end_func(&ru->rfdevice);
+    if(ru->rfdevice.trx_end_func != NULL) {
+      ru->rfdevice.trx_end_func(&ru->rfdevice);
+    }
   return 0;
 }
 
@@ -2342,11 +2344,15 @@ void init_RU_proc(RU_t *ru) {
     init_frame_parms(ru->frame_parms,1);
     ru->frame_parms->nb_antennas_rx = ru->nb_rx;
     phy_init_RU(ru);
-    openair0_device_load(&ru->rfdevice,&ru->openair0_cfg);
+    ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg);
+    if (ret < 0) {
+       LOG_I(PHY,"Exiting, cannot load device. Make sure that your SDR board is connected!\n");
+       exit(1);
+    }
 
     if (setup_RU_buffers(ru)!=0) {
-      printf("Exiting, cannot initialize RU Buffers\n");
-      exit(-1);
+      LOG_I(PHY,"Exiting, cannot initialize RU Buffers\n");
+      exit(1);
     }
   }
 
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index c08ab2a77ba..0b365ea938e 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -113,7 +113,7 @@ uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75,
 
 volatile int             oai_exit = 0;
 
-uint32_t                 downlink_frequency[MAX_NUM_CCs][4];
+uint64_t                 downlink_frequency[MAX_NUM_CCs][4];
 int32_t                  uplink_frequency_offset[MAX_NUM_CCs][4];
 
 int UE_scan = 1;
diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h
index 7b896b28172..5e1bf361605 100644
--- a/targets/RT/USER/lte-softmodem.h
+++ b/targets/RT/USER/lte-softmodem.h
@@ -141,7 +141,7 @@ 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 uint64_t downlink_frequency[MAX_NUM_CCs][4];
 extern int32_t  uplink_frequency_offset[MAX_NUM_CCs][4];
 
 extern int rx_input_level_dBm;
diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c
index 5a8afc23588..75ed0184346 100644
--- a/targets/RT/USER/lte-ue.c
+++ b/targets/RT/USER/lte-ue.c
@@ -88,7 +88,7 @@ extern void oai_subframe_ind(uint16_t sfn, uint16_t sf);
 extern void multicast_link_start(void (*rx_handlerP) (unsigned int, char *),
                                  unsigned char _multicast_group, char *multicast_ifname);
 extern int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind);
-extern int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind);
+extern int oai_nfapi_cqi_indication(nfapi_cqi_indication_t *cqi_ind);
 extern int oai_nfapi_harq_indication(nfapi_harq_indication_t *harq_ind);
 extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind);
 extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind);
@@ -992,6 +992,19 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
   phy_stub_ticking->num_single_thread[ue_thread_id] = -1;
   UE = rtd->UE;
 
+  UL_INFO = (UL_IND_t *)malloc(sizeof(UL_IND_t));
+  UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_rx_indication_pdu_t));
+  UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
+  UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_crc_indication_pdu_t));
+  UL_INFO->crc_ind.crc_indication_body.number_of_crcs = 0;
+  UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_harq_indication_pdu_t));
+  UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0;
+  UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_sr_indication_pdu_t));
+  UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0;
+  UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list =  calloc(NB_UE_INST, sizeof(nfapi_cqi_indication_pdu_t));
+  UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = calloc(NB_UE_INST, sizeof(nfapi_cqi_indication_raw_pdu_t));
+  UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0;
+
   if(ue_thread_id == 0) {
     phy_stub_ticking->ticking_var = -1;
     proc->subframe_rx=proc->sub_frame_start;
@@ -1064,20 +1077,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
         initRefTimes(t3);
         pickTime(current);
         updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)");*/
-      // Not sure whether we should put the memory allocation here and not sure how much memory
-      //we should allocate for each subframe cycle.
-      UL_INFO = (UL_IND_t *)malloc(sizeof(UL_IND_t));
-      UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = (nfapi_rx_indication_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_rx_indication_pdu_t));
-      UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
-      UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = (nfapi_crc_indication_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_crc_indication_pdu_t));
-      UL_INFO->crc_ind.crc_indication_body.number_of_crcs = 0;
-      UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = (nfapi_harq_indication_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_harq_indication_pdu_t));
-      UL_INFO->harq_ind.harq_indication_body.number_of_harqs = 0;
-      UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = (nfapi_sr_indication_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_sr_indication_pdu_t));
-      UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0;
-      UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list =  (nfapi_cqi_indication_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_cqi_indication_pdu_t));
-      UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = (nfapi_cqi_indication_raw_pdu_t *)malloc(NB_UE_INST*sizeof(nfapi_cqi_indication_raw_pdu_t));
-      UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0;
 
       if (pthread_mutex_lock(&phy_stub_ticking->mutex_single_thread) != 0) {
         LOG_E( MAC, "[SCHED][UE] error locking mutex for ue_thread_id %d (mutex_single_thread)\n",ue_thread_id);
@@ -1253,6 +1252,11 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
         UL_INFO->rx_ind.rx_indication_body.number_of_pdus = 0;
       }
 
+      if (UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis > 0) {
+        oai_nfapi_cqi_indication(&UL_INFO->cqi_ind);
+        UL_INFO->cqi_ind.cqi_indication_body.number_of_cqis = 0;
+      }
+
       if(UL_INFO->harq_ind.harq_indication_body.number_of_harqs>0) {
         //LOG_D(MAC, "ul_config_req_UE_MAC 2.4, SFN/SF of PNF counter:%d.%d, number_of_harqs: %d \n", timer_frame, timer_subframe, UL_INFO->harq_ind.harq_indication_body.number_of_harqs);
         oai_nfapi_harq_indication(&UL_INFO->harq_ind);
@@ -1267,30 +1271,6 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
         UL_INFO->sr_ind.sr_indication_body.number_of_srs = 0;
       }
 
-      // Free UL_INFO messages
-      //if(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list != NULL){
-      free(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list);
-      UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = NULL;
-      //}
-      //if(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list != NULL){
-      free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list);
-      UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL;
-      //}
-      //if(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list !=NULL){
-      free(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list);
-      UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = NULL;
-      //}
-      //if(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list!=NULL){
-      free(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list);
-      UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = NULL;
-      //}
-      free(UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list);
-      UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = NULL;
-      free(UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list);
-      UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = NULL;
-      free(UL_INFO);
-      UL_INFO = NULL;
-
       // De-allocate memory of nfapi requests copies before next subframe round
       if(dl_config_req!=NULL) {
         if(dl_config_req->vendor_extension!=NULL) {
@@ -1308,6 +1288,13 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
       }
 
       if(tx_request_pdu_list!=NULL) {
+        for (int i = 0; i < tx_req_num_elems; i++) {
+          for (int j = 0; j < tx_request_pdu_list[i].num_segments; j++) {
+            free(tx_request_pdu_list[i].segments[j].segment_data);
+            tx_request_pdu_list[i].segments[j].segment_data = NULL;
+          }
+        }
+        tx_req_num_elems = 0;
         free(tx_request_pdu_list);
         tx_request_pdu_list = NULL;
       }
@@ -1334,6 +1321,22 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
     }
   }
 
+  // Free UL_INFO messages
+  free(UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list);
+  UL_INFO->cqi_ind.cqi_indication_body.cqi_raw_pdu_list = NULL;
+  free(UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list);
+  UL_INFO->cqi_ind.cqi_indication_body.cqi_pdu_list = NULL;
+  free(UL_INFO->sr_ind.sr_indication_body.sr_pdu_list);
+  UL_INFO->sr_ind.sr_indication_body.sr_pdu_list = NULL;
+  free(UL_INFO->harq_ind.harq_indication_body.harq_pdu_list);
+  UL_INFO->harq_ind.harq_indication_body.harq_pdu_list = NULL;
+  free(UL_INFO->crc_ind.crc_indication_body.crc_pdu_list);
+  UL_INFO->crc_ind.crc_indication_body.crc_pdu_list = NULL;
+  free(UL_INFO->rx_ind.rx_indication_body.rx_pdu_list);
+  UL_INFO->rx_ind.rx_indication_body.rx_pdu_list = NULL;
+  free(UL_INFO);
+  UL_INFO = NULL;
+
   // thread finished
   free(arg);
   return &UE_thread_rxtx_retval;
diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c
index d0014b5e8a6..25371260bf9 100644
--- a/targets/RT/USER/lte-uesoftmodem.c
+++ b/targets/RT/USER/lte-uesoftmodem.c
@@ -120,7 +120,7 @@ clock_source_t clock_source = internal,time_source=internal;
 unsigned int                    mmapped_dma=0;
 
 
-uint32_t                 downlink_frequency[MAX_NUM_CCs][4];
+uint64_t                 downlink_frequency[MAX_NUM_CCs][4];
 int32_t                  uplink_frequency_offset[MAX_NUM_CCs][4];
 
 
-- 
GitLab