diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index aac70e53aaee98595dba28270963768f6b0c11e3..7e59f38e8d88804e5ffc9de590388e48ef66f8a9 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -2900,6 +2900,7 @@ target_link_libraries(ldpctest
 add_executable(nr_dlschsim  
   ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c 
   ${OPENAIR_DIR}/common/utils/system.c
+  ${OPENAIR_DIR}/common/utils/nr/nr_common.c
   ${UTIL_SRC}
   ${T_SOURCE}
   ${SHLIB_LOADER_SOURCES}
@@ -2912,6 +2913,7 @@ target_link_libraries(nr_dlschsim
 add_executable(nr_pbchsim  
   ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c 
   ${OPENAIR_DIR}/common/utils/system.c
+  ${OPENAIR_DIR}/common/utils/nr/nr_common.c
   ${UTIL_SRC}
   ${T_SOURCE}
   ${SHLIB_LOADER_SOURCES}
@@ -2965,6 +2967,7 @@ target_link_libraries(nr_prachsim
 add_executable(nr_ulschsim
   ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c
   ${OPENAIR_DIR}/common/utils/system.c
+  ${OPENAIR_DIR}/common/utils/nr/nr_common.c
   ${UTIL_SRC}
   ${T_SOURCE}
   ${SHLIB_LOADER_SOURCES}
diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml
index 497e9f053be09aa95c4625b3c943e445f9dac139..786002e9823b6a0a866c11947b061489d5d85c89 100644
--- a/cmake_targets/autotests/test_case_list.xml
+++ b/cmake_targets/autotests/test_case_list.xml
@@ -1071,9 +1071,9 @@
       <main_exec> $OPENAIR_DIR/targets/bin/nr_pbchsim.Rel15</main_exec>
       <main_exec_args>-s0 -S1 -n1000 -R106
                       -s0 -S1 -n10 -I -R106
-		              -s0 -S1 -n1000 -R217
+		      -s0 -S1 -n1000 -R217
                       -s0 -S1 -n10 -I -R217
-		              -s0 -S1 -n1000 -R273
+		      -s0 -S1 -n1000 -R273
                       -s0 -S1 -n10 -I -R273</main_exec_args>
       <tags>nr_pbchsim.test1 nr_pbchsim.test2 nr_pbchsim.test3 nr_pbchsim.test4 nr_pbchsim.test5 nr_pbchsim.test6</tags>
       <search_expr_true>PBCH test OK</search_expr_true>
@@ -1091,8 +1091,11 @@
                                  (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>
+                                 (Test9: 106 PRBs 50 PDSCH-PRBs MCS Index 27),
+                                 (Test10: 106 PRBs 50 PDSCH-PRBs MCS Index 16),
+                                 (Test11: HARQ test 25% TP (4 rounds),
+                                 (Test12: HARQ test 33% TP (3 rounds),
+                                 (Test13: HARQ test 50% TP (2 rounds)</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>
@@ -1108,8 +1111,11 @@
                   -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>
+                  -n100 -e16 -s10 
+                  -n100 -s1 -t25
+                  -n100 -s1 -t33
+                  -n100 -s1 -t50</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 nr_dlsim.test12 nr_dlsim.test13</tags>
       <search_expr_true>PDSCH test OK</search_expr_true>
       <search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false>
       <nruns>3</nruns>
@@ -1217,11 +1223,9 @@
 		      -R 106 -i 1 -P 2 -b 11 -s6 -n1000
 		      -R 106 -i 1 -P 2 -q8 -b 12 -s-3 -n1000
 		      -R 106 -i 1 -P 2 -q8 -b 19 -s-3 -n1000
-		      -R 106 -i 1 -P 2 -q8 -b 19 -s-3 -n1000
 		      -R 106 -i 1 -P 2 -q8 -b 32 -s-3 -n1000
 		      -R 106 -i 1 -P 2 -q16 -b 32 -s-3 -n1000
-		      -R 106 -i 1 -P 2 -q16 -b 64 -s-3 -n1000
-                      </main_exec_args>
+		      -R 106 -i 1 -P 2 -q16 -b 64 -s-3 -n1000</main_exec_args>
       <tags>nr_pucchsim.test1 nr_pucchsim.test2 nr_pucchsim.test3 nr_pucchsim.test4 nr_pucchsim.test5 nr_pucchsim.test6 nr_pucchsim.test7 nr_pucchsim.test8 nr_pucchsim.test9 nr_pucchsim.test10 nr_pucchsim.test11 nr_pucchsim.test12 nr_pucchsim.test13 nr_pucchsim.test14 nr_pucchsim.test15 nr_pucchsim.test16 nr_pucchsim.test17</tags>
       <search_expr_true>PUCCH test OK</search_expr_true>
       <search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false>
@@ -1292,19 +1296,21 @@
 
     <testCase id="015112">
       <class>execution</class>
-      <desc>nr_prachsim Test cases. (Test1: 106 PRBs),
-                                    (Test2: 217 PRBs),
-                                    (Test3: 273 PRBs)</desc>
+      <desc>nr_prachsim Test cases. (Test1: 106 PRBs - Prach format A2),
+                                    (Test2: 217 PRBs - Prach format A2),
+                                    (Test3: 273 PRBs - Prach format A2),
+				    (Test4: 106 PRBs - Prach format 0)</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_prachsim.Rel15</main_exec>
-      <main_exec_args>-a -s -30 -n 100 -p 16 -R 106
-                      -a -s -30 -n 100 -p 16 -R 217
-                      -a -s -30 -n 100 -p 16 -R 273</main_exec_args>
-      <tags>nr_prachsim.test1 nr_prachsim.test2 nr_prachsim.test3</tags>
+      <main_exec_args>-a -s -30 -n 100 -p 63 -R 106
+                      -a -s -30 -n 100 -p 63 -R 217
+                      -a -s -30 -n 100 -p 63 -R 273
+		      -a -s -30 -n 100 -p 63 -R 106 -c 4</main_exec_args>
+      <tags>nr_prachsim.test1 nr_prachsim.test2 nr_prachsim.test3 nr_prachsim.test4</tags>
       <search_expr_true>PRACH test OK</search_expr_true>
       <search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false>
       <nruns>3</nruns>
diff --git a/doc/FEATURE_SET.md b/doc/FEATURE_SET.md
index 41ed3c77e77834c1dac58029efb1c18e548e8313..23d32effbbdef58bf8a0d530b4eb7b397a9ae918 100644
--- a/doc/FEATURE_SET.md
+++ b/doc/FEATURE_SET.md
@@ -352,7 +352,8 @@ The following features are valid for the gNB and the 5G-NR UE.
 - Initial sync and MIB detection
 - MAC -> PHY configuration of PHY via UE FAPI P5 interface
 - Basic MAC to control PHY via UE FAPI P7 interface
-- Random ccess procedure
+- Random access procedure
+
 
 **RLC**
 
diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c
index 0d87720e2c419633cecafe46c7b6f94527507423..27b0ed08ddbde4c335b8d670aaa98ec95f89f031 100644
--- a/executables/nr-gnb.c
+++ b/executables/nr-gnb.c
@@ -61,7 +61,6 @@
 
 #include "PHY/phy_extern.h"
 
-
 #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
 #include "RRC/LTE/rrc_extern.h"
 #include "PHY_INTERFACE/phy_interface.h"
@@ -964,12 +963,14 @@ void init_gNB(int single_thread_flag,int wait_for_sync) {
     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.pdu_list = gNB->rx_pdu_list;
     gNB->UL_INFO.crc_ind.crc_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;
   }
   
diff --git a/executables/nr-ue.c b/executables/nr-ue.c
index 63c317291707283af8fb319e3578b77ffdee07db..2f99027b759aa63d3e1cef7a4e819b054bd6492a 100644
--- a/executables/nr-ue.c
+++ b/executables/nr-ue.c
@@ -157,6 +157,7 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue,
 
   // initialize all signal buffers
   init_nr_ue_signal(ue, nb_connected_gNB, abstraction_flag);
+
   // intialize transport
   init_nr_ue_transport(ue, abstraction_flag);
 }
@@ -366,6 +367,7 @@ static void UE_synch(void *arg) {
 
 void processSlotTX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) {
 
+
   fapi_nr_config_request_t *cfg = &UE->nrUE_config;
   int tx_slot_type = nr_ue_slot_select(cfg, proc->frame_tx, proc->nr_tti_tx);
   uint8_t gNB_id = 0;
@@ -436,6 +438,23 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) {
       pdcp_run(&ctxt);
     }
   }
+
+  // no UL for now
+  /*
+  if (UE->mac_enabled==1) {
+    //  trigger L2 to run ue_scheduler thru IF module
+    //  [TODO] mapping right after NR initial sync
+    if(UE->if_inst != NULL && UE->if_inst->ul_indication != NULL) {
+      UE->ul_indication.module_id = 0;
+      UE->ul_indication.gNB_index = 0;
+      UE->ul_indication.cc_id = 0;
+      UE->ul_indication.frame = proc->frame_rx;
+      UE->ul_indication.slot = proc->nr_tti_rx;
+      UE->if_inst->ul_indication(&UE->ul_indication);
+    }
+  }
+  */
+
 }
 
 /*!
@@ -558,6 +577,12 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
 
 int computeSamplesShift(PHY_VARS_NR_UE *UE) {
 
+  if (IS_SOFTMODEM_RFSIM) {
+    LOG_D(PHY,"SET rx_offset %d \n",UE->rx_offset);
+    //UE->rx_offset_diff=0;
+    return 0;
+  }
+
   // compute TO compensation that should be applied for this frame
   if ( UE->rx_offset < UE->frame_parms.samples_per_frame/2  &&
        UE->rx_offset > 0 ) {
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 489a4535d42ecd51df6ce3e8220616bec7aa3f63..fea64e3f3e7d07208b19d254ca0062dbdd58b8f7 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
@@ -1560,7 +1560,7 @@ typedef struct
   uint16_t sfn;
   uint16_t slot;
   uint16_t num_ucis;
-  nfapi_nr_uci_t uci_list[NFAPI_MAX_NUM_UCI_INDICATION];
+  nfapi_nr_uci_t *uci_list;
 
 } nfapi_nr_uci_indication_t;
 
diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c
index 0769ab992acafe9f0b090ce15114e3d01f1905a3..555f314429b5636def3f9e0103764b181206e7ef 100644
--- a/openair1/PHY/CODING/crc_byte.c
+++ b/openair1/PHY/CODING/crc_byte.c
@@ -324,6 +324,7 @@ int check_crc(uint8_t* decoded_bytes, uint32_t n, uint32_t F, uint8_t crc_type)
       AssertFatal(1,"Invalid crc_type \n");
     }
 
+
     if (crc == oldcrc)
       return(1);
     else
diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c
index 0cffc2d85200d7783381e4739884d5960665b671..5294e79b9f33a96709d3e994e4cb1792ea2ea351 100644
--- a/openair1/PHY/CODING/nr_rate_matching.c
+++ b/openair1/PHY/CODING/nr_rate_matching.c
@@ -364,8 +364,8 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm,
   if (ind < Foffset) { // case where we have some bits before the filler and the rest after
     memcpy((void*)e,(void*)(w+ind),Foffset-ind);
 
-    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);
+    if (E + F <= Ncb-ind) { // E+F doesn't contain all coded bits
+      memcpy((void*)(e+Foffset-ind),(void*)(w+Foffset+F),E-Foffset+ind);
       k=E;
     }
     else {
@@ -375,11 +375,12 @@ int nr_rate_matching_ldpc(uint8_t Ilbrm,
   }
   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);
+      memcpy((void*)(e),(void*)(w+ind),E);
       k=E;
     }
     else {
-
+      memcpy((void*)(e),(void*)(w+ind),Ncb-ind);
+      k=Ncb-ind;
     }
   }
 
diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c
index e544a7d0c2f9d639bbcc23b232c983404b04bc2d..9e095d5ab5b1b45e353880a346d5530098177bf7 100644
--- a/openair1/PHY/INIT/nr_init.c
+++ b/openair1/PHY/INIT/nr_init.c
@@ -176,6 +176,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
   }
 
   uint32_t Nid_pusch[2] = {cfg->cell_config.phy_cell_id.value,cfg->cell_config.phy_cell_id.value};
+  LOG_D(PHY,"Initializing PUSCH DMRS Gold sequence with (%x,%x)\n",Nid_pusch[0],Nid_pusch[1]);
   nr_gold_pusch(gNB, &Nid_pusch[0]);
 
   /// Transport init necessary for NR synchro
@@ -503,6 +504,12 @@ void init_nr_transport(PHY_VARS_gNB *gNB) {
   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_PUCCH_MAX; i++) {
+    LOG_I(PHY,"Allocating Transport Channel Buffers for PUCCH %d/%d\n",i,NUMBER_OF_NR_PUCCH_MAX);
+    gNB->pucch[i] = new_gNB_pucch();
+    AssertFatal(gNB->pucch[i]!=NULL,"Can't initialize pucch %d \n", i);
+  }
+
   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);
diff --git a/openair1/PHY/INIT/nr_init_ru.c b/openair1/PHY/INIT/nr_init_ru.c
index ead2538e75c68ff3c0a9b295c7b9aea9caad4df7..8b70b523a50b8ed45e1cd529a9294cc1cf367e36 100644
--- a/openair1/PHY/INIT/nr_init_ru.c
+++ b/openair1/PHY/INIT/nr_init_ru.c
@@ -40,9 +40,6 @@ int nr_phy_init_RU(RU_t *ru) {
   int p;
   int re;
 
-  // For memory allocation of ru->prach_rxsigF
-  int mu = fp->numerology_index;
-
   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;
@@ -113,8 +110,8 @@ int nr_phy_init_RU(RU_t *ru) {
     ru->prach_rxsigF = (int16_t**)malloc(ru->nb_rx * sizeof(int16_t*));
 
     for (i=0; i<ru->nb_rx; i++) {
-      // for preamble format 1 and 2, more memory should be allocated
-      ru->prach_rxsigF[i] = (int16_t*)malloc16_clear( fp->ofdm_symbol_size*12*(1<<mu)*2*sizeof(int16_t) );
+      // largest size for PRACH FFT is 4x98304 (16*24576)
+      ru->prach_rxsigF[i] = (int16_t*)malloc16_clear( 4*98304*2*sizeof(int16_t) );
       LOG_D(PHY,"[INIT] prach_vars->rxsigF[%d] = %p\n",i,ru->prach_rxsigF[i]);
     }
     
diff --git a/openair1/PHY/MODULATION/nr_modulation.c b/openair1/PHY/MODULATION/nr_modulation.c
index b27b692e66122244cba89b409b0bc9343d235a88..dbfe93adee0837becc7d7948f77ef2848c99e091 100644
--- a/openair1/PHY/MODULATION/nr_modulation.c
+++ b/openair1/PHY/MODULATION/nr_modulation.c
@@ -34,6 +34,8 @@ void nr_modulation(uint32_t *in,
   offset = (mod_order==2)? NR_MOD_TABLE_QPSK_OFFSET : (mod_order==4)? NR_MOD_TABLE_QAM16_OFFSET : \
                     (mod_order==6)? NR_MOD_TABLE_QAM64_OFFSET: (mod_order==8)? NR_MOD_TABLE_QAM256_OFFSET : 0;
 
+  LOG_D(PHY,"nr_modulation: length %d, mod_order %d\n",length,mod_order);
+
   for (int i=0; i<length/mod_order; i++)
   {
     idx = 0;
diff --git a/openair1/PHY/MODULATION/slot_fep_nr.c b/openair1/PHY/MODULATION/slot_fep_nr.c
index 66f69c5d06ef1355501424516f702b773c79add4..cf0a50a0186dc19601385b2f496f8d88c523cd7a 100644
--- a/openair1/PHY/MODULATION/slot_fep_nr.c
+++ b/openair1/PHY/MODULATION/slot_fep_nr.c
@@ -465,6 +465,8 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
     dft(dftsize,(int16_t *)&rxdata[rxdata_offset-sample_offset],
         (int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1);
 
+  // clear DC carrier from OFDM symbols
+  rxdataF[symbol * frame_parms->ofdm_symbol_size] = 0;
 
   return(0);
 }
diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c
index f544655197b57443c09997d7151baed26b47debd..3f7c7817f77fac6807f87a0bac462e9b0f4a1075 100644
--- a/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c
+++ b/openair1/PHY/NR_ESTIMATION/nr_ul_channel_estimation.c
@@ -28,7 +28,7 @@
 #include "PHY/NR_UE_ESTIMATION/filt16a_32.h"
 
 //#define DEBUG_CH
-
+//#define DEBUG_PUSCH
 
 int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
                                 unsigned char Ns,
@@ -116,7 +116,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
 
   //------------------generate DMRS------------------//
 
-  if (pusch_pdu->transform_precoding) // if transform precoding is disabled
+  if (pusch_pdu->transform_precoding==1) // if transform precoding is disabled
     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->rb_start*NR_NB_SC_PER_RB, pusch_pdu->dmrs_config_type);
   else
     nr_pusch_dmrs_rx(gNB, Ns, gNB->nr_gold_pusch_dmrs[pusch_pdu->scid][Ns][symbol], &pilot[0], 1000, 0, nb_rb_pusch, 0, pusch_pdu->dmrs_config_type);
@@ -132,8 +132,9 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
     memset(ul_ch,0,4*(gNB->frame_parms.ofdm_symbol_size));
 
 #ifdef DEBUG_PUSCH
+    printf("symbol_offset %d, nushift %d\n",symbol_offset,nushift);
     printf("ch est pilot addr %p RB_DL %d\n",&pilot[0], gNB->frame_parms.N_RB_UL);
-    printf("k %d, first_carrier %d\n",k,gNB->frame_parms.first_carrier_offset);
+    printf("bwp_start_subcarrier %d, k %d, first_carrier %d\n",bwp_start_subcarrier,k,gNB->frame_parms.first_carrier_offset);
     printf("rxF addr %p p %d\n", rxF,p);
     printf("ul_ch addr %p nushift %d\n",ul_ch,nushift);
 #endif
@@ -148,7 +149,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
 #ifdef DEBUG_PUSCH
       printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1]));
       printf("pilot 0 : rxF - > (%d,%d) addr %p  ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
-      printf("data 0 : rxF - > (%d,%d) addr %p  ch -> (%d,%d), pil -> (%d,%d) \n",rxF[2],rxF[3],&rxF[2],ch[0],ch[1],pil[0],pil[1]);
+      printf("data 0 : rxF - > (%d,%d)\n",rxF[2],rxF[3]);
 #endif
 
       multadd_real_vector_complex_scalar(fl,
@@ -166,6 +167,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
 
 #ifdef DEBUG_PUSCH
       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("data 1 : rxF - > (%d,%d)\n",rxF[2],rxF[3]);
 #endif
       multadd_real_vector_complex_scalar(fml,
                                          ch,
@@ -181,6 +183,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
 
 #ifdef DEBUG_PUSCH
       printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
+      printf("data 2 : rxF - > (%d,%d)\n",rxF[2],rxF[3]);
 #endif
       multadd_real_vector_complex_scalar(fmm,
                                          ch,
@@ -201,7 +204,8 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
         ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
 
   #ifdef DEBUG_PUSCH
-        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 %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("data %u : rxF - > (%d,%d)\n",pilot_cnt,rxF[2],rxF[3]);
   #endif
         multadd_real_vector_complex_scalar(fml,
                                            ch,
@@ -217,6 +221,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
 
   #ifdef DEBUG_PUSCH
         printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
+	printf("data %u : rxF - > (%d,%d)\n",pilot_cnt+1,rxF[2],rxF[3]);
   #endif
         multadd_real_vector_complex_scalar(fmm,
                                            ch,
@@ -238,6 +243,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
       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("data %u : rxF - > (%d,%d)\n",pilot_cnt,rxF[2],rxF[3]);
 #endif
       multadd_real_vector_complex_scalar(fm,
                                          ch,
@@ -256,6 +262,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
 #ifdef DEBUG_PUSCH
       printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1]));
       printf("pilot %u: rxF - > (%d,%d) addr %p  ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
+      printf("data %u : rxF - > (%d,%d)\n",pilot_cnt+1,rxF[2],rxF[3]);
 #endif
       multadd_real_vector_complex_scalar(fmr,
                                          ch,
@@ -271,6 +278,7 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB,
       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+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]);
+      printf("data %u : rxF - > (%d,%d)\n",pilot_cnt+2,rxF[2],rxF[3]);
 #endif
       multadd_real_vector_complex_scalar(fr,
                                          ch,
diff --git a/openair1/PHY/NR_REFSIG/dmrs_nr.c b/openair1/PHY/NR_REFSIG/dmrs_nr.c
index 8718fc86102108fa982b899c6915d944fe6dc378..7042c152fdf8ee0544b7d4f68c0cb0bcb64414cc 100644
--- a/openair1/PHY/NR_REFSIG/dmrs_nr.c
+++ b/openair1/PHY/NR_REFSIG/dmrs_nr.c
@@ -33,7 +33,32 @@
 #include "PHY/NR_REFSIG/ss_pbch_nr.h"
 #include "PHY/NR_REFSIG/dmrs_nr.h"
 
-/***********************************************************************/
+
+
+uint8_t allowed_xlsch_re_in_dmrs_symbol(uint16_t k,
+                                        uint16_t start_sc,
+                                        uint8_t numDmrsCdmGrpsNoData,
+                                        uint8_t dmrs_type) {
+  uint8_t delta;
+  uint16_t diff;
+  if (k>start_sc)
+    diff = k-start_sc;
+  else
+    diff = start_sc-k;
+  for (int i = 0; i<numDmrsCdmGrpsNoData; i++){
+    if  (dmrs_type==NFAPI_NR_DMRS_TYPE1) {
+      delta = i;
+      if (((diff)%2)  == delta)
+        return (0);
+    }
+    else {
+      delta = i<<1;
+      if ( (((diff)%6)  == delta) || (((k-start_sc)%6)  == (delta+1)) )
+        return (0);
+    }
+  }
+  return (1);
+}
 
 
 /*******************************************************************
diff --git a/openair1/PHY/NR_REFSIG/dmrs_nr.h b/openair1/PHY/NR_REFSIG/dmrs_nr.h
index 6badf71745febf276cbe39cd057198ff9f1a3da7..c76f58ad181d091727f8a425fdde719b2682782b 100644
--- a/openair1/PHY/NR_REFSIG/dmrs_nr.h
+++ b/openair1/PHY/NR_REFSIG/dmrs_nr.h
@@ -56,6 +56,11 @@ void lte_gold_new(LTE_DL_FRAME_PARMS *frame_parms, uint32_t lte_gold_table[20][2
 void generate_dmrs_pbch(uint32_t dmrs_pbch_bitmap[DMRS_PBCH_I_SSB][DMRS_PBCH_N_HF][DMRS_BITMAP_SIZE], uint16_t Nid_cell);
 uint16_t get_dmrs_freq_idx_ul(uint16_t n, uint8_t k_prime, uint8_t delta, uint8_t dmrs_type);
 
+uint8_t allowed_xlsch_re_in_dmrs_symbol(uint16_t k,
+                                        uint16_t start_sc,
+                                        uint8_t numDmrsCdmGrpsNoData,
+                                        uint8_t dmrs_type);
+
 #undef EXTERN
 
 #endif /* DMRS_NR_H */
diff --git a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c
index 4580ccce8c72121e3388b3de9a28315a19e6155e..4eeb8a6e96f18214cfdcf2877e15b64b9328ba84 100644
--- a/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c
+++ b/openair1/PHY/NR_REFSIG/nr_dmrs_rx.c
@@ -32,7 +32,7 @@
 
 //#define NR_PBCH_DMRS_LENGTH_DWORD 5
 //#define NR_PBCH_DMRS_LENGTH 144
-//#define DEBUG_PDCCH
+//#define DEBUG_PUSCH
 
 #include "refsig_defs_ue.h"
 #include "PHY/defs_nr_UE.h"
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c
index 8508621ae52f61e8b381af78eb94cdb4d7542e32..1e65797719a5679cede4bf66c9bcdbdb1b043727 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dci.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c
@@ -155,7 +155,7 @@ void nr_pdcch_scrambling(uint32_t *in,
 
 
 uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu,
-			    nfapi_nr_ul_dci_request_pdus_t    *ul_dci_pdu,
+			    nfapi_nr_ul_dci_request_pdus_t *ul_dci_pdu,
                             uint32_t **gold_pdcch_dmrs,
                             int32_t *txdataF,
                             int16_t amp,
@@ -229,10 +229,11 @@ uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu,
     /// 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->dci_pdu.RNTI[d];
     uint16_t Nid    = pdcch_pdu_rel15->dci_pdu.ScramblingId[d];
     uint16_t scrambling_RNTI = pdcch_pdu_rel15->dci_pdu.ScramblingRNTI[d];
-    
+
     t_nrPolar_params *currentPtr = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, 
 						   pdcch_pdu_rel15->dci_pdu.PayloadSizeBits[d], 
 						   pdcch_pdu_rel15->dci_pdu.AggregationLevel[d],
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c
index 0ec835a42cc36081f179ba795e7f6fc6499e18c9..02ecfc44044fa5bb09a58f6bc2edff4fea11419f 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c
@@ -212,7 +212,6 @@ void nr_fill_dci(PHY_VARS_gNB *gNB,
 
     //uint64_t *dci_pdu = (uint64_t*)pdcch_pdu_rel15->dci_pdu.Payload[i];
 
-
     int dlsch_id = find_nr_dlsch(pdcch_pdu_rel15->dci_pdu.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->dci_pdu.RNTI[i],dlsch_id);
@@ -220,7 +219,8 @@ void nr_fill_dci(PHY_VARS_gNB *gNB,
     }
     
     dlsch = gNB->dlsch[dlsch_id][0];
-    int harq_pid = 0;//extract_harq_pid(i,pdu_rel15);
+    int num_slots_tdd = (gNB->frame_parms.slots_per_frame)>>(7-gNB->gNB_config.tdd_table.tdd_period.value);
+    int harq_pid = slot % num_slots_tdd;
 
     dlsch->slot_tx[slot]             = 1;
     dlsch->harq_ids[frame%2][slot]   = harq_pid;
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
index b8d9fdea185483b29b331e586d7c9d5c022b2ab1..8df2139b3bff2ee1d209c962c717f6643a735b8e 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
@@ -34,6 +34,7 @@
 #include "nr_dci.h"
 #include "nr_sch_dmrs.h"
 #include "PHY/MODULATION/nr_modulation.h"
+#include "PHY/NR_REFSIG/dmrs_nr.h"
 
 //#define DEBUG_DLSCH
 //#define DEBUG_DLSCH_MAPPING
@@ -126,26 +127,29 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch,
 			  time_stats_t *dlsch_interleaving_stats,
 			  time_stats_t *dlsch_segmentation_stats) {
 
-  int harq_pid = 0;
+  int harq_pid = dlsch->harq_ids[frame%2][slot];
   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;
-  uint8_t nodata_dmrs = 1;
   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];
-
+  int nb_re_dmrs;
+  uint16_t n_dmrs;
+  if (rel15->dmrsConfigType==NFAPI_NR_DMRS_TYPE1) {
+    nb_re_dmrs = 6*rel15->numDmrsCdmGrpsNoData;
+    n_dmrs = ((rel15->rbSize+rel15->rbStart)*6)<<1;
+  }
+  else {
+    nb_re_dmrs = 4*rel15->numDmrsCdmGrpsNoData;
+    n_dmrs = ((rel15->rbSize+rel15->rbStart)*4)<<1;
+  }
   uint16_t nb_re;
-  if (nodata_dmrs) // no data in dmrs symbol
-    nb_re = ((12*rel15->NrOfSymbols)-12-xOverhead)*rel15->rbSize*rel15->NrOfCodewords;
-  else
-    nb_re = ((12*rel15->NrOfSymbols)-nb_re_dmrs-xOverhead)*rel15->rbSize*rel15->NrOfCodewords;
+  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;
+  int16_t mod_dmrs[n_dmrs<<1];
 
   /// CRC, coding, interleaving and rate matching
   AssertFatal(harq->pdu!=NULL,"harq->pdu is null\n");
@@ -301,7 +305,7 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch,
         }
 
         else {
-          if( (l != dmrs_symbol) || !nodata_dmrs) {
+          if( (l != dmrs_symbol) || allowed_xlsch_re_in_dmrs_symbol(k,start_sc,rel15->numDmrsCdmGrpsNoData,dmrs_Type)) {
             ((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
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
index 3aa87d656ef4f85f88c9a06bb9708a77b22f9bb1..fc4c086e2c3c03feaea70426d2171046708d2754 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
@@ -335,12 +335,13 @@ int nr_dlsch_encoding(unsigned char *a,
   uint32_t E;
   uint8_t Ilbrm = 1;
   uint32_t Tbslbrm = 950984; //max tbs
-  uint8_t nodata_dmrs = 1;
   uint8_t nb_re_dmrs;
-  if (nodata_dmrs)
-    nb_re_dmrs = 12;
+
+  if (rel15->dmrsConfigType==NFAPI_NR_DMRS_TYPE1)
+    nb_re_dmrs = 6*rel15->numDmrsCdmGrpsNoData;
   else
-    nb_re_dmrs = rel15->dmrsConfigType==NFAPI_NR_DMRS_TYPE1 ? 6:4;
+    nb_re_dmrs = 4*rel15->numDmrsCdmGrpsNoData;
+
   uint16_t length_dmrs = get_num_dmrs(rel15->dlDmrsSymbPos);
   uint16_t R=rel15->targetCodeRate[0];
   float Coderate = 0.0;
@@ -464,6 +465,9 @@ int nr_dlsch_encoding(unsigned char *a,
 
   }
 
+    F = dlsch->harq_processes[harq_pid]->F;
+
+    Kr = dlsch->harq_processes[harq_pid]->K;
   for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) {
 
     if (F>0) {
diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach.c b/openair1/PHY/NR_TRANSPORT/nr_prach.c
index 312ad6a47502521d4909f57e18080acafb90fba1..2640a86240bba7abe906e54dc91530b75ff26e92 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_prach.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_prach.c
@@ -150,6 +150,7 @@ void rx_nr_prach_ru(RU_t *ru,
 
   int16_t            **rxsigF=NULL;
   NR_DL_FRAME_PARMS *fp=ru->nr_frame_parms;
+  int slot2=slot;
 
   int16_t *prach[ru->nb_rx];
   int prach_sequence_length = ru->config.prach_config.prach_sequence_length.value;
@@ -159,8 +160,11 @@ void rx_nr_prach_ru(RU_t *ru,
   rxsigF            = ru->prach_rxsigF;
 
   AssertFatal(ru->if_south == LOCAL_RF,"we shouldn't call this if if_south != LOCAL_RF\n");
-  for (int aa=0; aa<ru->nb_rx; aa++) 
-    prach[aa] = (int16_t*)&ru->common.rxdata[aa][(slot*fp->get_samples_per_slot(slot,fp))-ru->N_TA_offset];
+
+  for (int aa=0; aa<ru->nb_rx; aa++){ 
+    if (prach_sequence_length == 0) slot2=(slot/fp->slots_per_subframe)*fp->slots_per_subframe; 
+    prach[aa] = (int16_t*)&ru->common.rxdata[aa][(slot2*fp->get_samples_per_slot(slot,fp))-ru->N_TA_offset];
+  } 
 
   int dftlen=0;
   int mu = fp->numerology_index;
@@ -169,7 +173,7 @@ void rx_nr_prach_ru(RU_t *ru,
 
   if (prach_sequence_length == 0) {
     LOG_D(PHY,"PRACH (ru %d) in %d.%d, format %d, msg1_frequencyStart %d\n",
-	  ru->idx,frame,slot,prachFormat,msg1_frequencystart);
+	  ru->idx,frame,slot2,prachFormat,msg1_frequencystart);
     AssertFatal(prachFormat<4,"Illegal prach format %d for length 839\n",prachFormat);
     switch (prachFormat) {
     case 0:
@@ -282,7 +286,7 @@ void rx_nr_prach_ru(RU_t *ru,
             dft(DFT_49152,prach2,rxsigF[aa],1);
           }
 	  if (prachFormat == 1 || prachFormat == 2) {
-	    dft(DFT_49152,prach2+98304,rxsigF[aa]+98304,1);
+            dft(DFT_49152,prach2+98304,rxsigF[aa]+98304,1);
 	    reps++;
 	  }
 	  if (prachFormat == 2) {
@@ -348,7 +352,7 @@ void rx_nr_prach_ru(RU_t *ru,
 	    reps+=2;
 	  }
 	  if (prachFormat == 3) {
-            dftlen=9216;
+	    dftlen=9216;
 	    for (int i=0;i<4;i++) dft(DFT_9216,prach2+(i*9216*2),rxsigF[aa]+(i*9216*2),1);
 	    reps=4;
 	  }
@@ -358,7 +362,7 @@ void rx_nr_prach_ru(RU_t *ru,
 	      (mu==1 && prachStartSymbol == 0)) prach2+=48; // 24 samples @ 46.08 Ms/s in first symbol of each half subframe (15/30 kHz only)
 	  if (mu==0) AssertFatal(1==0,"Shouldn't get here\n");
 	  else if (mu==1) {
-            dftlen=1536;
+	    dftlen=1536;
 	    dft(DFT_1536,prach2,rxsigF[aa],1);
 	    if (prachFormat != 7) {
 	      dft(DFT_1536,prach2+3072,rxsigF[aa]+3072,1);
@@ -366,13 +370,13 @@ void rx_nr_prach_ru(RU_t *ru,
 	    }
 	    
 	    if (prachFormat == 1 || prachFormat == 2 || prachFormat == 4 || prachFormat == 5 || prachFormat == 6 || prachFormat == 8) {     
-              dft(DFT_1536,prach2+3072*2,rxsigF[aa]+3072*2,1);
-              dft(DFT_1536,prach2+3072*3,rxsigF[aa]+3072*3,1);
+	      dft(DFT_1536,prach2+3072*2,rxsigF[aa]+3072*2,1);
+	      dft(DFT_1536,prach2+3072*3,rxsigF[aa]+3072*3,1);
 	      reps+=2;
 	    } 
 	    if (prachFormat == 2 || prachFormat == 5 || prachFormat == 6) {     
-              dft(DFT_1536,prach2+3072*4,rxsigF[aa]+3072*4,1);
-              dft(DFT_1536,prach2+3072*5,rxsigF[aa]+3072*5,1);
+	      dft(DFT_1536,prach2+3072*4,rxsigF[aa]+3072*4,1);
+	      dft(DFT_1536,prach2+3072*5,rxsigF[aa]+3072*5,1);
 	      reps+=2;
 	    } 
 	    if (prachFormat == 6) {
@@ -418,7 +422,7 @@ void rx_nr_prach_ru(RU_t *ru,
 
 	  if (mu==0) AssertFatal(1==0,"Shouldn't get here\n");
 	  else if (mu==1) {
-            dftlen=4096;
+	    dftlen=4096;
 	    dft(DFT_4096,prach2,rxsigF[aa],1);
 	    if (prachFormat != 7) { //!=C0 
 	      dft(DFT_4096,prach2+8192,rxsigF[aa]+8192,1);
@@ -470,7 +474,7 @@ void rx_nr_prach_ru(RU_t *ru,
 
 	  if (mu==0) AssertFatal(1==0,"Shouldn't get here\n");
 	  else if (mu==1) {
-            dftlen=3072;
+	    dftlen=3072;
 	    dft(DFT_3072,prach2,rxsigF[aa],1);
 	    if (prachFormat != 7) { //!=C0
 	      dft(DFT_3072,prach2+6144,rxsigF[aa]+6144,1);
@@ -500,6 +504,7 @@ void rx_nr_prach_ru(RU_t *ru,
     }
 
     //Coherent combining of PRACH repetitions (assumes channel does not change, to be revisted for "long" PRACH)
+    LOG_D(PHY,"Doing PRACH combining of %d reptitions N_ZC %d\n",reps,N_ZC);
     int16_t rxsigF_tmp[N_ZC<<1];
     //    if (k+N_ZC > dftlen) { // PRACH signal is split around DC 
     int16_t *rxsigF2=rxsigF[aa];
@@ -578,9 +583,6 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
 
   restricted_set      = cfg->restricted_set_config.value;
 
-  AssertFatal(prach_sequence_length == 1, "no support yet for long prachSequenceLength\n");
-
-
   uint8_t prach_fmt = prach_pdu->prach_format;
   uint16_t N_ZC = (prach_sequence_length==0)?839:139;
 
@@ -592,13 +594,8 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
     if ((frame&1023) < 20) LOG_D(PHY,"PRACH (gNB) : running rx_prach for subframe %d, msg1_frequencystart %d, rootSequenceIndex %d\n", subframe,msg1_frequencystart,rootSequenceIndex);
   }
 
-
-
-
-
   start_meas(&gNB->rx_prach);
 
-
   prach_root_sequence_map = (cfg->prach_sequence_length.value==0) ? prach_root_sequence_map_0_3 : prach_root_sequence_map_abc;
 
   // PDP is oversampled, e.g. 1024 sample instead of 839
@@ -619,7 +616,7 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
 
     if (LOG_DEBUGFLAG(PRACH)){
       int en = dB_fixed(signal_energy((int32_t*)&rxsigF[0][0],(N_ZC==839) ? 840: 140));
-      if (en>60) LOG_I(PHY,"frame %d, subframe %d : Trying preamble %d \n",frame,subframe,preamble_index);
+      if (en>60) LOG_D(PHY,"frame %d, subframe %d : Trying preamble %d \n",frame,subframe,preamble_index);
     }
     if (restricted_set == 0) {
       // This is the relative offset in the root sequence table (5.7.2-4 from 36.211) for the given preamble index
@@ -745,22 +742,22 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
 	    prach_ifft[i] += ((int32_t)prach_ifft_tmp[i<<1]*(int32_t)prach_ifft_tmp[(i<<1)] + (int32_t)prach_ifft_tmp[1+(i<<1)]*(int32_t)prach_ifft_tmp[1+(i<<1)])>>10;
 	}
 
-        if (LOG_DUMPFLAG(PRACH)) {	
+	if (LOG_DUMPFLAG(PRACH)) {	
 	  if (aa==0) LOG_M("prach_rxF_comp0.m","prach_rxF_comp0",prachF,1024,1,1);
           if (aa==1) LOG_M("prach_rxF_comp1.m","prach_rxF_comp1",prachF,1024,1,1);
-        }
+	}
       }// antennas_rx
     } // new dft
     
     // check energy in nth time shift, for 
 
     preamble_shift2 = ((preamble_shift==0) ? 0 : ((preamble_shift<<log2_ifft_size)/N_ZC));
-    
-    
+
     for (i=0; i<NCS2; i++) {
       lev = (int32_t)prach_ifft[(preamble_shift2+i)];
       levdB = dB_fixed_times10(lev);
       if (levdB>*max_preamble_energy) {
+	LOG_D(PHY,"preamble_index %d, delay %d en %d dB > %d dB\n",preamble_index,i,levdB,*max_preamble_energy);
 	*max_preamble_energy  = levdB;
 	*max_preamble_delay   = i; // Note: This has to be normalized to the 30.72 Ms/s sampling rate 
 	*max_preamble         = preamble_index;
@@ -794,8 +791,8 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
 
 
   if (LOG_DUMPFLAG(PRACH)) {
-    int en = dB_fixed(signal_energy((int32_t*)&rxsigF[0][0],840));  
-    if (en>60) {
+    //int en = dB_fixed(signal_energy((int32_t*)&rxsigF[0][0],840));
+    //    if (en>60) {
       int k = (12*n_ra_prb) - 6*fp->N_RB_UL;
       
       if (k<0) k+=fp->ofdm_symbol_size;
@@ -809,7 +806,7 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
       LOG_M("prach_rxF_comp0.m","prach_rxF_comp0",prachF,1024,1,1);
       LOG_M("Xu.m","xu",Xu,N_ZC,1,1);
       LOG_M("prach_ifft0.m","prach_t0",prach_ifft,1024,1,1);
-    }
+      //    }
   } /* LOG_DUMPFLAG(PRACH) */
   stop_meas(&gNB->rx_prach);
 
diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach_common.c b/openair1/PHY/NR_TRANSPORT/nr_prach_common.c
index 251d1cbfd8357aa771ac7cc0b5aaa3aa642b2da7..a95c519d439290449bd82792465632cbf63c0df8 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_prach_common.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_prach_common.c
@@ -139,7 +139,7 @@ void compute_nr_prach_seq(uint8_t short_sequence,
     }
 
     u = prach_root_sequence_map[index];
-
+    LOG_D(PHY,"prach index %d => u=%d\n",index,u);
     inv_u = nr_ZC_inv[u]; // multiplicative inverse of u
 
 
diff --git a/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h b/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h
index 2b25464b84928cdee2005f4eae6e650d420b037d..491e24658e46b747edfbeac88a73068a3036c932 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h
+++ b/openair1/PHY/NR_TRANSPORT/nr_sch_dmrs.h
@@ -50,4 +50,4 @@ uint16_t get_dmrs_freq_idx(uint16_t n, uint8_t k_prime, uint8_t delta, uint8_t d
 
 uint8_t get_l0(uint16_t dlDmrsSymbPos);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h
index 38136184247a951707a66abecad1c7f0ebe77678..0e10f2b6786c8eede1ad3924b54e836d8357f077 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h
+++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h
@@ -137,12 +137,12 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
     @param symbol Symbol on which to act (within-in nr_TTI_rx)
     @param harq_pid HARQ process ID
 */
-void nr_rx_pusch(PHY_VARS_gNB *gNB,
-                 uint8_t UE_id,
-                 uint32_t frame,
-                 uint8_t nr_tti_rx,
-                 unsigned char symbol,
-                 unsigned char harq_pid);
+int nr_rx_pusch(PHY_VARS_gNB *gNB,
+                uint8_t UE_id,
+                uint32_t frame,
+                uint8_t nr_tti_rx,
+                unsigned char symbol,
+                unsigned char harq_pid);
 
 /** \brief This function performs RB extraction (signal and channel estimates) (currently signal only until channel estimation and compensation are implemented)
     @param rxdataF pointer to the received frequency domain signal
@@ -309,10 +309,24 @@ void nr_fill_prach_ru(RU_t *ru,
 int16_t find_nr_prach(PHY_VARS_gNB *gNB,int frame,int slot, int numRA, find_type_t type);
 int16_t find_nr_prach_ru(RU_t *ru,int frame,int slot, find_type_t type);
 
+NR_gNB_PUCCH_t *new_gNB_pucch(void);
+
+void nr_fill_pucch(PHY_VARS_gNB *gNB,
+                   int frame,
+                   int slot,
+                   nfapi_nr_pucch_pdu_t *pucch_pdu);
+
+int nr_find_pucch(uint16_t rnti,
+                  int frame,
+                  int slot,
+                  PHY_VARS_gNB *gNB);
+
+
 void init_prach_list(PHY_VARS_gNB *gNB);
 void init_prach_ru_list(RU_t *ru);
 void free_nr_ru_prach_entry(RU_t *ru, int prach_id);
 
+
 void nr_decode_pucch1(int32_t **rxdataF,
                       pucch_GroupHopping_t pucch_GroupHopping,
                       uint32_t n_id,       // hoppingID higher layer parameter
diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c
index 09e57eaf9facba2e47ddc8645595e12688becd1e..84fa6d358b15e6c7f24cb612222fa5af95cd5531 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c
@@ -527,7 +527,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
 #ifdef DEBUG_ULSCH_DECODING
     if (r==0) {
       write_output("decoder_llr.m","decllr",ulsch_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);
@@ -608,7 +608,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
   #endif
         ret = ulsch->max_ldpc_iterations + 1;
       }
-
       nb_total_decod++;
 
       if (no_iteration_ldpc > ulsch->max_ldpc_iterations){
diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c
index d1282a90e77cf68cdb7727dc68e097c8036c5370..a966db5844ad6de4170175655c6dffec5e05ae21 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c
@@ -283,6 +283,7 @@ void nr_ulsch_extract_rbs_single(int32_t **rxdataF,
         is_dmrs_re = 0;
 
       if (pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) {
+        K_ptrs = (pusch_pdu->pusch_ptrs.ptrs_freq_density)?4:2;
         if(is_ptrs_symbol(symbol, pusch_vars->ptrs_symbols))
             is_ptrs_symbol_flag = is_ptrs_subcarrier((start_re + re) % frame_parms->ofdm_symbol_size,
                                                      n_rnti,
@@ -1009,12 +1010,12 @@ void nr_ulsch_channel_compensation(int **rxdataF_ext,
 
 }
 
-void nr_rx_pusch(PHY_VARS_gNB *gNB,
-                 uint8_t UE_id,
-                 uint32_t frame,
-                 uint8_t nr_tti_rx,
-                 unsigned char symbol,
-                 unsigned char harq_pid)
+int nr_rx_pusch(PHY_VARS_gNB *gNB,
+                uint8_t ulsch_id,
+                uint32_t frame,
+                uint8_t nr_tti_rx,
+                unsigned char symbol,
+                unsigned char harq_pid)
 {
 
   uint8_t aarx, aatx, dmrs_symbol_flag; // dmrs_symbol_flag, a flag to indicate DMRS REs in current symbol
@@ -1023,22 +1024,21 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
   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;
-  uint8_t nodata_dmrs = 1; // FIXME to be properly configured from fapi
+  nfapi_nr_pusch_pdu_t *rel15_ul = &gNB->ulsch[ulsch_id][0]->harq_processes[harq_pid]->ulsch_pdu;
 
   dmrs_symbol_flag = 0;
-  gNB->pusch_vars[UE_id]->ptrs_sc_per_ofdm_symbol = 0;
+  gNB->pusch_vars[ulsch_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;
+    gNB->pusch_vars[ulsch_id]->rxdataF_ext_offset = 0;
+    gNB->pusch_vars[ulsch_id]->dmrs_symbol = 0;
+    gNB->pusch_vars[ulsch_id]->cl_done = 0;
+    gNB->pusch_vars[ulsch_id]->ptrs_symbols = 0;
 
     if (rel15_ul->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) {  // 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,
+      set_ptrs_symb_idx(&gNB->pusch_vars[ulsch_id]->ptrs_symbols,
                         rel15_ul->nr_of_symbols,
                         rel15_ul->start_symbol_index,
                         L_ptrs,
@@ -1053,18 +1053,23 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
   if (dmrs_symbol_flag == 1){
     if (((rel15_ul->ul_dmrs_symb_pos)>>((symbol+1)%frame_parms->symbols_per_slot))&0x01)
       AssertFatal(1==0,"Double DMRS configuration is not yet supported\n");
-    if (nodata_dmrs)
-      nb_re_pusch = 0;
-    else
-      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;
+
+    if (rel15_ul->dmrs_config_type == 0) {
+      // if no data in dmrs cdm group is 1 only even REs have no data
+      // if no data in dmrs cdm group is 2 both odd and even REs have no data
+      nb_re_pusch = rel15_ul->rb_size *(12 - (rel15_ul->num_dmrs_cdm_grps_no_data*6));
+    }
+    else {
+      nb_re_pusch = rel15_ul->rb_size *(12 - (rel15_ul->num_dmrs_cdm_grps_no_data*4));
+    }
+    gNB->pusch_vars[ulsch_id]->dmrs_symbol = symbol;
   } else {
     nb_re_pusch = rel15_ul->rb_size * NR_NB_SC_PER_RB;
   }
 
   if (rel15_ul->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) {  // if there is ptrs pdu
-    if(is_ptrs_symbol(symbol, gNB->pusch_vars[UE_id]->ptrs_symbols))
-      gNB->pusch_vars[UE_id]->ptrs_symbol_index = symbol;
+    if(is_ptrs_symbol(symbol, gNB->pusch_vars[ulsch_id]->ptrs_symbols))
+      gNB->pusch_vars[ulsch_id]->ptrs_symbol_index = symbol;
   }
 
 
@@ -1088,25 +1093,25 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
 
     start_meas(&gNB->ulsch_rbs_extraction_stats);
     nr_ulsch_extract_rbs_single(gNB->common_vars.rxdataF,
-                                gNB->pusch_vars[UE_id],
+                                gNB->pusch_vars[ulsch_id],
                                 symbol,
                                 dmrs_symbol_flag,
                                 rel15_ul,
                                 frame_parms);
     stop_meas(&gNB->ulsch_rbs_extraction_stats);
 
-    nr_ulsch_scale_channel(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext,
+    nr_ulsch_scale_channel(gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext,
                            frame_parms,
-                           gNB->ulsch[UE_id],
+                           gNB->ulsch[ulsch_id],
                            symbol,
                            dmrs_symbol_flag,
                            rel15_ul->rb_size,
                            rel15_ul->dmrs_config_type);
 
 
-    if (gNB->pusch_vars[UE_id]->cl_done==0) {
+    if (gNB->pusch_vars[ulsch_id]->cl_done==0) {
 
-      nr_ulsch_channel_level(gNB->pusch_vars[UE_id]->ul_ch_estimates_ext,
+      nr_ulsch_channel_level(gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext,
                              frame_parms,
                              avg,
                              symbol,
@@ -1119,38 +1124,44 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
         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]->cl_done = 1;
+      gNB->pusch_vars[ulsch_id]->log2_maxh = (log2_approx(avgs)/2)+1;
+      gNB->pusch_vars[ulsch_id]->cl_done = 1;
     }
 
     start_meas(&gNB->ulsch_channel_compensation_stats);
-    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,
+    nr_ulsch_channel_compensation(gNB->pusch_vars[ulsch_id]->rxdataF_ext,
+                                  gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext,
+                                  gNB->pusch_vars[ulsch_id]->ul_ch_mag0,
+                                  gNB->pusch_vars[ulsch_id]->ul_ch_magb0,
+                                  gNB->pusch_vars[ulsch_id]->rxdataF_comp,
+                                  (frame_parms->nb_antennas_tx>1) ? gNB->pusch_vars[ulsch_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);
+                                  gNB->pusch_vars[ulsch_id]->log2_maxh);
     stop_meas(&gNB->ulsch_channel_compensation_stats);
 
+
+    int rxsig = signal_energy(&gNB->pusch_vars[ulsch_id]->rxdataF_comp[0][(symbol*rel15_ul->rb_size*12)],
+                              rel15_ul->rb_size*12);
+
+    if (rxsig==1) return (rxsig);
+
 #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);
+    nr_idft(&((uint32_t*)gNB->pusch_vars[ulsch_id]->rxdataF_ext[0])[symbol * rel15_ul->rb_size * NR_NB_SC_PER_RB], nb_re_pusch);
 #endif
 
   //----------------------------------------------------------
   //-------------------- LLRs computation --------------------
   //----------------------------------------------------------
     start_meas(&gNB->ulsch_llr_stats);
-    AssertFatal(gNB->pusch_vars[UE_id]->rxdataF_ext_offset * rel15_ul->qam_mod_order+nb_re_pusch*rel15_ul->qam_mod_order < (8*((3*8*6144)+12)) , "Mysterious llr buffer size check");
-    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],
+    AssertFatal(gNB->pusch_vars[ulsch_id]->rxdataF_ext_offset * rel15_ul->qam_mod_order+nb_re_pusch*rel15_ul->qam_mod_order < (8*((3*8*6144)+12)) , "Mysterious llr buffer size check");
+    nr_ulsch_compute_llr(&gNB->pusch_vars[ulsch_id]->rxdataF_comp[0][symbol * rel15_ul->rb_size * NR_NB_SC_PER_RB],
+                         gNB->pusch_vars[ulsch_id]->ul_ch_mag0,
+                         gNB->pusch_vars[ulsch_id]->ul_ch_magb0,
+                         &gNB->pusch_vars[ulsch_id]->llr[gNB->pusch_vars[ulsch_id]->rxdataF_ext_offset * rel15_ul->qam_mod_order],
                          rel15_ul->rb_size,
                          nb_re_pusch,
                          symbol,
@@ -1159,6 +1170,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
 
   }
 
-  gNB->pusch_vars[UE_id]->rxdataF_ext_offset = gNB->pusch_vars[UE_id]->rxdataF_ext_offset +  nb_re_pusch;
-  
+  gNB->pusch_vars[ulsch_id]->rxdataF_ext_offset = gNB->pusch_vars[ulsch_id]->rxdataF_ext_offset +  nb_re_pusch;
+  return (0);
+
 }
diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c
index e17a549d8c0e8cbdc3523dac5619b0c86efd23db..501df8bb357b1d665ea55ff34952091a9cda56f2 100644
--- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c
+++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c
@@ -52,6 +52,54 @@
 
 //#define DEBUG_NR_PUCCH_RX 1
 
+NR_gNB_PUCCH_t *new_gNB_pucch(void){
+    NR_gNB_PUCCH_t *pucch;
+    pucch = (NR_gNB_PUCCH_t *)malloc16(sizeof(NR_gNB_PUCCH_t));
+    pucch->active = 0;
+    return (pucch);
+}
+
+int nr_find_pucch(uint16_t rnti,
+                  int frame,
+                  int slot,
+                  PHY_VARS_gNB *gNB) {
+
+  AssertFatal(gNB!=NULL,"gNB is null\n");
+  int index = -1;
+
+  for (int i=0; i<NUMBER_OF_NR_ULSCH_MAX; i++) {
+    AssertFatal(gNB->pucch[i]!=NULL,"gNB->pucch[%d] is null\n",i);
+    if ((gNB->pucch[i]->active >0) &&
+        (gNB->pucch[i]->pucch_pdu.rnti==rnti) &&
+        (gNB->pucch[i]->frame==frame) &&
+        (gNB->pucch[i]->slot==slot)) return(i);
+    else if ((gNB->pucch[i]->active == 0) && (index==-1)) index=i;
+  }
+
+  if (index==-1)
+    LOG_E(MAC,"PUCCH list is full\n");
+
+  return(index);
+}
+
+void nr_fill_pucch(PHY_VARS_gNB *gNB,
+                   int frame,
+                   int slot,
+                   nfapi_nr_pucch_pdu_t *pucch_pdu) {
+
+  int id = nr_find_pucch(pucch_pdu->rnti,frame,slot,gNB);
+  AssertFatal( (id>=0) && (id<NUMBER_OF_NR_PUCCH_MAX),
+              "invalid id found for pucch !!! rnti %04x id %d\n",pucch_pdu->rnti,id);
+
+  NR_gNB_PUCCH_t  *pucch = gNB->pucch[id];
+  pucch->frame = frame;
+  pucch->slot = slot;
+  pucch->active = 1;
+  memcpy((void*)&pucch->pucch_pdu, (void*)pucch_pdu, sizeof(nfapi_nr_pucch_pdu_t));
+
+}
+
+
 int get_pucch0_cs_lut_index(PHY_VARS_gNB *gNB,nfapi_nr_pucch_pdu_t* pucch_pdu) {
 
   int i=0;
@@ -319,9 +367,9 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
 
   uint8_t xrtmag_dB = dB_fixed(xrtmag);
   
-#ifdef DEBUG_NR_PUCCH_RX
+//#ifdef DEBUG_NR_PUCCH_RX
   printf("PUCCH 0 : maxpos %d\n",maxpos);
-#endif
+//#endif
 
   index=maxpos;
 #endif
@@ -361,8 +409,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
     uci_pdu->harq->harq_confidence_level = xrtmag_dB-(gNB->measurements.n0_subband_power_tot_dB[pucch_pdu->prb_start]+gNB->pucch0_thres);
     uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2);
 
-    uci_pdu->harq->harq_list[0].harq_value = index&0x01;
-    uci_pdu->harq->harq_list[1].harq_value = (index>>1)&0x01;
+    uci_pdu->harq->harq_list[1].harq_value = index&0x01;
+    uci_pdu->harq->harq_list[0].harq_value = (index>>1)&0x01;
 
     if (pucch_pdu->sr_flag == 1) {
       uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr));
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
index 8214bdca9996758714c18f02d6f7b94723de15b1..1a6006c3ba99fb952bc5eac6026258b9d09d9e17 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c
@@ -32,6 +32,7 @@
 
 #include "common/utils/LOG/vcd_signal_dumper.h"
 #include "PHY/defs_nr_UE.h"
+#include "SCHED_NR_UE/harq_nr.h"
 #include "PHY/phy_extern_nr_ue.h"
 #include "PHY/CODING/coding_extern.h"
 #include "PHY/CODING/coding_defs.h"
@@ -133,6 +134,7 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint
     memset(dlsch,0,sizeof(NR_UE_DLSCH_t));
     dlsch->Kmimo = Kmimo;
     dlsch->Mdlharq = Mdlharq;
+    dlsch->number_harq_processes_for_pdsch = Mdlharq;
     dlsch->Nsoft = Nsoft;
     dlsch->Mlimit = 4;
     dlsch->max_ldpc_iterations = max_ldpc_iterations;
@@ -143,6 +145,7 @@ 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));
+        init_downlink_harq_status(dlsch->harq_processes[i]);
         dlsch->harq_processes[i]->first_tx=1;
         dlsch->harq_processes[i]->b = (uint8_t*)malloc16(dlsch_bytes);
 
@@ -264,7 +267,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
 
   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 = 12;//(dmrs_Type==1)?6:4;
+  uint8_t nb_re_dmrs = (dmrs_Type==1)?6:4; // should be changed based on MAC parameters
   uint16_t dmrs_length = get_num_dmrs(harq_process->dlDmrsSymbPos);
   AssertFatal(dmrs_length == 1 || dmrs_length == 2,"Illegal dmrs_length %d\n",dmrs_length);
 
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c
index e9e36f2c779e9034fdabaaec27075d6462b025f9..79c542cd61ba27d5f6ca4cd1af1aa9141e6c4bc5 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c
@@ -42,7 +42,7 @@
 
 #include "T.h"
 
-#define NR_PRACH_DEBUG 1
+//#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];
@@ -59,6 +59,7 @@ 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];
 extern const char *prachfmt[9];
+extern const char *prachfmt03[4];
 
 // Note:
 // - prach_fmt_id is an ID used to map to the corresponding PRACH format value in prachfmt
@@ -78,6 +79,7 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){
   uint16_t rootSequenceIndex, prach_fmt_id, NCS, *prach_root_sequence_map, preamble_offset = 0;
   uint16_t preamble_shift = 0, preamble_index0, n_shift_ra, n_shift_ra_bar, d_start, numshift, N_ZC, u, offset, offset2, first_nonzero_root_idx;
   int16_t prach_tmp[98304*2*4] __attribute__((aligned(32)));
+
   int16_t Ncp = 0, amp, *prach, *prach2, *prachF, *Xu;
   int32_t Xu_re, Xu_im, samp_count;
   int prach_start, prach_sequence_length, i, prach_len, dftlen, mu, kbar, K, n_ra_prb, k;
@@ -207,9 +209,9 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){
   #ifdef NR_PRACH_DEBUG
     if (NCS>0)
       LOG_I(PHY, "PRACH [UE %d] generate PRACH for RootSeqIndex %d, Preamble Index %d, PRACH Format %s, NCS %d (N_ZC %d): Preamble_offset %d, Preamble_shift %d\n", Mod_id,
-        rootSequenceIndex,
-        preamble_index,
-        prachfmt[prach_fmt_id],
+    rootSequenceIndex,
+    preamble_index,
+    prach_sequence_length == 0 ? prachfmt03[prach_fmt_id]  : prachfmt[prach_fmt_id],
         NCS,
         N_ZC,
         preamble_offset,
@@ -557,7 +559,6 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){
           Ncp+=24; // This assumes we are transmitting starting in symbol 0 of a PRACH slot, 30 kHz, full sampling
           prach2 = prach+(Ncp<<1);
           idft(IDFT_1536,prachF,prach2,1);
-
           // here we have |empty | Prach1536 |
           if (prach_fmt_id != 7) {
             memmove(prach2+(1536<<1),prach2,(1536<<2));
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 d84a56eee5005d519c0de874f058d0680e8e23d3..bde9ae03f15bd35249d62c17df5dd13bc6950b04 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h
@@ -1387,8 +1387,10 @@ void ulsch_modulation(int32_t **txdataF,
                       NR_UE_ULSCH_t *ulsch);
 
 
-
-
+uint8_t allowed_ulsch_re_in_dmrs_symbol(uint16_t k,
+                                        uint16_t start_sc,
+                                        uint8_t numDmrsCdmGrpsNoData,
+                                        uint8_t dmrs_type);
 
 
 int generate_ue_dlsch_params_from_dci(int frame,
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
index b4b33ca50183c661780656bd6c8fc401824388f8..6b2d5e7255095e3faedd71cb72735811f885abaa 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
@@ -44,6 +44,7 @@
 
 #include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h"
 
+
 // structures below implement 36-211 and 36-212
 
 /** @addtogroup _PHY_TRANSPORT_
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
index 9be4a16fb584184c07d6263e2667ac0833719f42..93acda23f8b5d064b208851f560211a21aa1cad5 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
@@ -98,6 +98,8 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
                                uint8_t thread_id,
                                int gNB_id) {
 
+  LOG_D(PHY,"nr_ue_ulsch_procedures hard_id %d %d.%d\n",harq_pid,frame,slot);
+
   uint32_t available_bits, TBS;
   uint8_t mod_order, cwd_index, num_of_codewords, l;
   uint32_t scrambled_output[NR_MAX_NB_CODEWORDS][NR_MAX_PDSCH_ENCODED_LENGTH>>5];
@@ -114,7 +116,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
   uint8_t data_existing =0;
   uint8_t L_ptrs, K_ptrs; // PTRS parameters
   uint16_t beta_ptrs; // PTRS parameter related to power control
-  uint8_t no_data_in_dmrs = 1;
 
   NR_UE_ULSCH_t *ulsch_ue;
   NR_UL_UE_HARQ_t *harq_process_ul_ue=NULL;
@@ -128,7 +129,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
   N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig
   number_dmrs_symbols = 0;
 
-
   for (cwd_index = 0;cwd_index < num_of_codewords; cwd_index++) {
 
     ulsch_ue = UE->ulsch[thread_id][gNB_id][cwd_index];
@@ -149,10 +149,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
     rnti                  = harq_process_ul_ue->pusch_pdu.rnti;
     ulsch_ue->Nid_cell    = Nid_cell;
 
-    if(no_data_in_dmrs)
-      nb_dmrs_re_per_rb = 12;
-    else
-      nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4);
+    nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4)*harq_process_ul_ue->pusch_pdu.num_dmrs_cdm_grps_no_data;
 
     N_RE_prime = NR_NB_SC_PER_RB*number_of_symbols - nb_dmrs_re_per_rb*number_dmrs_symbols - N_PRB_oh;
 
@@ -174,7 +171,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
                                              0,
                                              harq_process_ul_ue->pusch_pdu.nrOfLayers);
 
-
     uint8_t access_mode = SCHEDULED_ACCESS;
 
     //-----------------------------------------------------//
@@ -186,10 +182,10 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
 
       if (IS_SOFTMODEM_NOS1){
         data_existing = nr_ue_get_sdu(UE->Mod_id, UE->CC_id, frame,
-          slot, 0, ulsch_input_buffer, TBS/8, &access_mode);
+                                      slot, 0, ulsch_input_buffer, TBS/8, &access_mode);
         //IP traffic to be transmitted
         if(data_existing){
-          //harq_process_ul_ue->a = (unsigned char*)calloc(TBS/8, sizeof(unsigned char));
+          //harq_process_ul_ue->a = (unsigned char*)calloc(harq_process_ul_ue->TBS/8, sizeof(unsigned char));
           memcpy(harq_process_ul_ue->a, ulsch_input_buffer, TBS/8);
         }
       }
@@ -372,7 +368,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
     
 
     uint8_t k_prime=0;
-    uint8_t is_dmrs, is_ptrs;
+    uint8_t is_dmrs, is_ptrs, is_dmrs_symbol;
     uint16_t m=0, n=0, dmrs_idx=0, ptrs_idx = 0;
 
     for (l=start_symbol; l<start_symbol+number_of_symbols; l++) {
@@ -387,8 +383,10 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
 
         is_dmrs = 0;
         is_ptrs = 0;
+        is_dmrs_symbol = 0;
 
         if((ul_dmrs_symb_pos >> l) & 0x01) {
+          is_dmrs_symbol = 1;
           if (k == ((start_sc+get_dmrs_freq_idx_ul(n, k_prime, delta, dmrs_type))%frame_parms->ofdm_symbol_size))
             is_dmrs = 1;
         }
@@ -439,7 +437,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
 
           ptrs_idx++;
 
-        } else if (((ul_dmrs_symb_pos >> l) & 0x01) == 0) {
+        } else if (!is_dmrs_symbol || allowed_xlsch_re_in_dmrs_symbol(k,start_sc,harq_process_ul_ue->pusch_pdu.num_dmrs_cdm_grps_no_data,dmrs_type)) {
 
           ((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];
diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c
index e1358602ce835b39613a82e7a1c46df24a4ebc29..b0c051973514fbea4bab51df5bd8746dc98a2f91 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c
@@ -54,7 +54,8 @@
 void nr_generate_pucch0(PHY_VARS_NR_UE *ue,
                         int32_t **txdataF,
                         NR_DL_FRAME_PARMS *frame_parms,
-                        PUCCH_CONFIG_DEDICATED *pucch_config_dedicated,
+                        long pucch_GroupHopping,
+                        long hoppingId,
                         int16_t amp,
                         int nr_tti_tx,
                         uint8_t m0,
@@ -111,7 +112,7 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue,
   for (int l=0; l<nrofSymbols; l++) {
     // if frequency hopping is enabled n_hop = 1 for second hop. Not sure frequency hopping concerns format 0. FIXME!!!
     // if ((PUCCH_Frequency_Hopping == 1)&&(l == (nrofSymbols-1))) n_hop = 1;
-    nr_group_sequence_hopping(ue->pucch_config_common_nr->pucch_GroupHopping,ue->pucch_config_common_nr->hoppingId,n_hop,nr_tti_tx,&u,&v); // calculating u and v value
+    nr_group_sequence_hopping(pucch_GroupHopping,hoppingId,n_hop,nr_tti_tx,&u,&v); // calculating u and v value
     alpha = nr_cyclic_shift_hopping(ue->pucch_config_common_nr->hoppingId,m0,mcs,l,startingSymbolIndex,nr_tti_tx);
 #ifdef DEBUG_NR_PUCCH_TX
     printf("\t [nr_generate_pucch0] sequence generation \tu=%d \tv=%d \talpha=%lf \t(for symbol l=%d)\n",u,v,alpha,l);
diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h
index a2446dccf99ccd38e31a4c7378e5aa26aaffac43..0e81045d660996f6a80938d81d01cde5a285e2fb 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h
+++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h
@@ -49,7 +49,8 @@
 void nr_generate_pucch0(PHY_VARS_NR_UE *ue,
                         int32_t **txdataF,
                         NR_DL_FRAME_PARMS *frame_parms,
-                        PUCCH_CONFIG_DEDICATED *pucch_config_dedicated,
+                        long pucch_GroupHopping,
+                        long hoppingId,
                         int16_t amp,
                         int nr_tti_tx,
                         uint8_t m0,
diff --git a/openair1/PHY/TOOLS/Makefile b/openair1/PHY/TOOLS/Makefile
index c71717dc8787cb6cfd29671228591d494af582ae..a59700bb7c058bc159cfda8befbb62e3c9370c9f 100644
--- a/openair1/PHY/TOOLS/Makefile
+++ b/openair1/PHY/TOOLS/Makefile
@@ -1,16 +1,16 @@
-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
+oai_dfts_sse4: oai_dfts.c
+	gcc-7 -O3 -std=gnu99 -msse4.1 -o oai_dfts_sse4 oai_dfts.c time_meas.c  ../../SIMULATION/TOOLS/taus.c -I$$OPENAIR_HOME -I$$OPENAIR1_DIR -I$$OPENAIR_TARGETS -I$$OPENAIR_TARGETS/COMMON -I$$OPENAIR_TARGETS/ARCH/COMMON -I$$OPENAIR2_DIR -I$$OPENAIR2_DIR/COMMON -I$$OPENAIR_HOME/common/utils -I$$OPENAIR_HOME/common/utils/T -I$$OPENAIR_HOME/common/utils/msc -I$$OPENAIR_HOME/nfapi/open-nFAPI/nfapi/public_inc -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 $$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
+oai_dfts_avx2: oai_dfts.c
+	gcc -O2 -std=gnu99 -mavx2 -g -ggdb -o oai_dfts_avx2 oai_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$$OPENAIR_TARGETS/COMMON -I$$OPENAIR_TARGETS/ARCH/COMMON -I$$OPENAIR2_DIR -I$$OPENAIR2_DIR/COMMON -I$$OPENAIR_HOME/common/utils -I$$OPENAIR_HOME/common/utils/T -I$$OPENAIR_HOME/common/utils/msc -I$$OPENAIR_HOME/nfapi/open-nFAPI/nfapi/public_inc -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 $$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
+oai_dfts_avx2.s: oai_dfts.c
+	gcc -O2 -std=gnu99 -mavx2 -S oai_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$$OPENAIR_TARGETS/COMMON -I$$OPENAIR_TARGETS/ARCH/COMMON -I$$OPENAIR2_DIR -I$$OPENAIR2_DIR/COMMON -I$$OPENAIR_HOME/common/utils -I$$OPENAIR_HOME/common/utils/T -I$$OPENAIR_HOME/common/utils/msc -I$$OPENAIR_HOME/nfapi/open-nFAPI/nfapi/public_inc -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 $$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
+oai_dfts_sse4.s: oai_dfts.c
+	gcc -O2 -std=gnu99 -msse4.1 -S oai_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$$OPENAIR_TARGETS/COMMON -I$$OPENAIR_TARGETS/ARCH/COMMON -I$$OPENAIR2_DIR -I$$OPENAIR2_DIR/COMMON -I$$OPENAIR_HOME/common/utils -I$$OPENAIR_HOME/common/utils/T -I$$OPENAIR_HOME/common/utils/msc -I$$OPENAIR_HOME/nfapi/open-nFAPI/nfapi/public_inc -DMR_MAIN -DNB_ANTENNAS_RX=1 -lm -lpthread # -DD256STATS #-DD64STATS
 
 
-dft_cycles_avx2: lte_dfts_avx2
-	./lte_dfts_avx2 | egrep cycles
+dft_cycles_avx2: oai_dfts_avx2
+	./oai_dfts_avx2 | egrep cycles
diff --git a/openair1/PHY/TOOLS/oai_dfts.c b/openair1/PHY/TOOLS/oai_dfts.c
index bb8c46592ccacae27649bf84618789921bed2582..25244eeff530732ae75a32f94c95f90126df53b4 100644
--- a/openair1/PHY/TOOLS/oai_dfts.c
+++ b/openair1/PHY/TOOLS/oai_dfts.c
@@ -5353,6 +5353,607 @@ void idft8192(int16_t *x,int16_t *y,unsigned char scale)
 
 #endif
 
+int16_t tw16384[3*2*4096];
+
+#ifndef __AVX2__
+void dft16384(int16_t *x,int16_t *y,unsigned char scale)
+{
+
+  simd_q15_t xtmp[4096],ytmp[4096],*tw16384_128p=(simd_q15_t *)tw16384,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y;
+  simd_q15_t *ytmpp = &ytmp[0];
+  int i,j;
+
+  for (i=0,j=0; i<4096; i+=4,j++) {
+    transpose16_ooff(x128+i,xtmp+j,1024);
+  }
+
+
+  dft4096((int16_t*)(xtmp),(int16_t*)(ytmp),1);
+  dft4096((int16_t*)(xtmp+1024),(int16_t*)(ytmp+1024),1);
+  dft4096((int16_t*)(xtmp+2048),(int16_t*)(ytmp+2048),1);
+  dft4096((int16_t*)(xtmp+3072),(int16_t*)(ytmp+3072),1);
+
+  for (i=0; i<1024; i++) {
+    bfly4(ytmpp,ytmpp+1024,ytmpp+2048,ytmpp+3072,
+          y128p,y128p+1024,y128p+2048,y128p+3072,
+          tw16384_128p,tw16384_128p+1024,tw16384_128p+2048);
+    tw16384_128p++;
+    y128p++;
+    ytmpp++;
+  }
+
+  if (scale>0) {
+
+    for (i=0; i<256; 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+=16;
+    }
+
+  }
+
+  _mm_empty();
+  _m_empty();
+
+}
+
+ 
+
+void idft16384(int16_t *x,int16_t *y,unsigned char scale)
+{
+
+  simd_q15_t xtmp[4096],ytmp[4096],*tw16384_128p=(simd_q15_t *)tw16384,*x128=(simd_q15_t *)x,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y;
+  simd_q15_t *ytmpp = &ytmp[0];
+  int i,j;
+
+  for (i=0,j=0; i<4096; i+=4,j++) {
+    transpose16_ooff(x128+i,xtmp+j,1024);
+  }
+
+
+  idft4096((int16_t*)(xtmp),(int16_t*)(ytmp),1);
+  idft4096((int16_t*)(xtmp+1024),(int16_t*)(ytmp+1024),1);
+  idft4096((int16_t*)(xtmp+2048),(int16_t*)(ytmp+2048),1);
+  idft4096((int16_t*)(xtmp+3072),(int16_t*)(ytmp+3072),1);
+
+  for (i=0; i<1024; i++) {
+    ibfly4(ytmpp,ytmpp+1024,ytmpp+2048,ytmpp+3072,
+           y128p,y128p+1024,y128p+2048,y128p+3072,
+           tw16384_128p,tw16384_128p+1024,tw16384_128p+2048);
+    tw16384_128p++;
+    y128p++;
+    ytmpp++;
+  }
+
+  if (scale>0) {
+
+    for (i=0; i<256; i++) {
+      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;
+    }
+ 
+  }
+
+  _mm_empty();
+  _m_empty();
+
+}
+
+#else //__AVX2__
+void dft16384(int16_t *x,int16_t *y,unsigned char scale)
+{
+
+  simd256_q15_t xtmp[2048],ytmp[2048],*tw16384_256p=(simd256_q15_t *)tw16384,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y;
+  simd256_q15_t *ytmpp = &ytmp[0];
+  int i,j;
+
+  for (i=0,j=0; i<2048; i+=4,j++) {
+    transpose16_ooff_simd256(x256+i,xtmp+j,512);
+  }
+
+
+  dft4096((int16_t*)(xtmp),(int16_t*)(ytmp),1);
+  dft4096((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1);
+  dft4096((int16_t*)(xtmp+1024),(int16_t*)(ytmp+1024),1);
+  dft4096((int16_t*)(xtmp+1536),(int16_t*)(ytmp+1536),1);
+
+  for (i=0; i<512; i++) {
+    bfly4_256(ytmpp,ytmpp+512,ytmpp+1024,ytmpp+1536,
+	      y256p,y256p+512,y256p+1024,y256p+1536,
+	      tw16384_256p,tw16384_256p+512,tw16384_256p+1024);
+    tw16384_256p++;
+    y256p++;
+    ytmpp++;
+  }
+
+  if (scale>0) {
+
+    for (i=0; i<128; i++) {
+      y256[0]  = shiftright_int16_simd256(y256[0],1);
+      y256[1]  = shiftright_int16_simd256(y256[1],1);
+      y256[2]  = shiftright_int16_simd256(y256[2],1);
+      y256[3]  = shiftright_int16_simd256(y256[3],1);
+      y256[4]  = shiftright_int16_simd256(y256[4],1);
+      y256[5]  = shiftright_int16_simd256(y256[5],1);
+      y256[6]  = shiftright_int16_simd256(y256[6],1);
+      y256[7]  = shiftright_int16_simd256(y256[7],1);
+      y256[8]  = shiftright_int16_simd256(y256[8],1);
+      y256[9]  = shiftright_int16_simd256(y256[9],1);
+      y256[10] = shiftright_int16_simd256(y256[10],1);
+      y256[11] = shiftright_int16_simd256(y256[11],1);
+      y256[12] = shiftright_int16_simd256(y256[12],1);
+      y256[13] = shiftright_int16_simd256(y256[13],1);
+      y256[14] = shiftright_int16_simd256(y256[14],1);
+      y256[15] = shiftright_int16_simd256(y256[15],1);
+
+      y256+=16;
+    }
+
+  }
+
+  _mm_empty();
+  _m_empty();
+
+}
+
+void idft16384(int16_t *x,int16_t *y,unsigned char scale)
+{
+
+  simd256_q15_t xtmp[2048],ytmp[2048],*tw16384_256p=(simd256_q15_t *)tw16384,*x256=(simd256_q15_t *)x,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y;
+  simd256_q15_t *ytmpp = &ytmp[0];
+  int i,j;
+
+  for (i=0,j=0; i<2048; i+=4,j++) {
+    transpose16_ooff_simd256(x256+i,xtmp+j,512);
+  }
+
+
+  idft4096((int16_t*)(xtmp),(int16_t*)(ytmp),1);
+  idft4096((int16_t*)(xtmp+512),(int16_t*)(ytmp+512),1);
+  idft4096((int16_t*)(xtmp+1024),(int16_t*)(ytmp+1024),1);
+  idft4096((int16_t*)(xtmp+1536),(int16_t*)(ytmp+1536),1);
+
+  for (i=0; i<512; i++) {
+    ibfly4_256(ytmpp,ytmpp+512,ytmpp+1024,ytmpp+1536,
+	       y256p,y256p+512,y256p+1024,y256p+1536,
+	       tw16384_256p,tw16384_256p+512,tw16384_256p+1024);
+    tw16384_256p++;
+    y256p++;
+    ytmpp++;
+  }
+
+  if (scale>0) {
+
+    for (i=0; i<128; i++) {
+      y256[0]  = shiftright_int16_simd256(y256[0],1);
+      y256[1]  = shiftright_int16_simd256(y256[1],1);
+      y256[2]  = shiftright_int16_simd256(y256[2],1);
+      y256[3]  = shiftright_int16_simd256(y256[3],1);
+      y256[4]  = shiftright_int16_simd256(y256[4],1);
+      y256[5]  = shiftright_int16_simd256(y256[5],1);
+      y256[6]  = shiftright_int16_simd256(y256[6],1);
+      y256[7]  = shiftright_int16_simd256(y256[7],1);
+      y256[8]  = shiftright_int16_simd256(y256[8],1);
+      y256[9]  = shiftright_int16_simd256(y256[9],1);
+      y256[10] = shiftright_int16_simd256(y256[10],1);
+      y256[11] = shiftright_int16_simd256(y256[11],1);
+      y256[12] = shiftright_int16_simd256(y256[12],1);
+      y256[13] = shiftright_int16_simd256(y256[13],1);
+      y256[14] = shiftright_int16_simd256(y256[14],1);
+      y256[15] = shiftright_int16_simd256(y256[15],1);
+
+      y256+=16;
+    }
+
+  }
+
+  _mm_empty();
+  _m_empty();
+
+}
+
+#endif //__AVX2__
+
+int16_t tw32768[2*16384] __attribute__((aligned(32)));
+
+#ifndef __AVX2__
+void dft32768(int16_t *x,int16_t *y,unsigned char scale)
+{
+
+  simdshort_q15_t xtmp[16384],*xtmpp,*x64 = (simdshort_q15_t *)x;
+  simd_q15_t ytmp[8192],*tw32768_128p=(simd_q15_t *)tw32768,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y;
+  simd_q15_t *ytmpp = &ytmp[0];
+  int i;
+  simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15);
+
+  xtmpp = xtmp;
+
+  for (i=0; i<256; i++) {
+    transpose4_ooff(x64  ,xtmpp,8192);
+    transpose4_ooff(x64+2,xtmpp+1,8192);
+    transpose4_ooff(x64+4,xtmpp+2,8192);
+    transpose4_ooff(x64+6,xtmpp+3,8192);
+    transpose4_ooff(x64+8,xtmpp+4,8192);
+    transpose4_ooff(x64+10,xtmpp+5,8192);
+    transpose4_ooff(x64+12,xtmpp+6,8192);
+    transpose4_ooff(x64+14,xtmpp+7,8192);
+    transpose4_ooff(x64+16,xtmpp+8,8192);
+    transpose4_ooff(x64+18,xtmpp+9,8192);
+    transpose4_ooff(x64+20,xtmpp+10,8192);
+    transpose4_ooff(x64+22,xtmpp+11,8192);
+    transpose4_ooff(x64+24,xtmpp+12,8192);
+    transpose4_ooff(x64+26,xtmpp+13,8192);
+    transpose4_ooff(x64+28,xtmpp+14,8192);
+    transpose4_ooff(x64+30,xtmpp+15,8192);
+    transpose4_ooff(x64+32,xtmpp+16,8192);
+    transpose4_ooff(x64+34,xtmpp+17,8192);
+    transpose4_ooff(x64+36,xtmpp+18,8192);
+    transpose4_ooff(x64+38,xtmpp+19,8192);
+    transpose4_ooff(x64+40,xtmpp+20,8192);
+    transpose4_ooff(x64+42,xtmpp+21,8192);
+    transpose4_ooff(x64+44,xtmpp+22,8192);
+    transpose4_ooff(x64+46,xtmpp+23,8192);
+    transpose4_ooff(x64+48,xtmpp+24,8192);
+    transpose4_ooff(x64+50,xtmpp+25,8192);
+    transpose4_ooff(x64+52,xtmpp+26,8192);
+    transpose4_ooff(x64+54,xtmpp+27,8192);
+    transpose4_ooff(x64+56,xtmpp+28,8192);
+    transpose4_ooff(x64+58,xtmpp+29,8192);
+    transpose4_ooff(x64+60,xtmpp+30,8192);
+    transpose4_ooff(x64+62,xtmpp+31,8192);
+    x64+=64;
+    xtmpp+=32;
+  }
+
+  dft16384((int16_t*)(xtmp),(int16_t*)ytmp,1);
+  dft16384((int16_t*)(xtmp+8192),(int16_t*)(ytmp+4096),1);
+
+
+  for (i=0; i<4096; i++) {
+    bfly2(ytmpp,ytmpp+4096,
+          y128p,y128p+4096,
+          tw32768_128p);
+    tw32768_128p++;
+    y128p++;
+    ytmpp++;
+  }
+
+  if (scale>0) {
+    y128p = y128;
+
+    for (i=0; i<512; i++) {
+      y128p[0]  = mulhi_int16(y128p[0],ONE_OVER_SQRT2_Q15_128);
+      y128p[1]  = mulhi_int16(y128p[1],ONE_OVER_SQRT2_Q15_128);
+      y128p[2]  = mulhi_int16(y128p[2],ONE_OVER_SQRT2_Q15_128);
+      y128p[3]  = mulhi_int16(y128p[3],ONE_OVER_SQRT2_Q15_128);
+      y128p[4]  = mulhi_int16(y128p[4],ONE_OVER_SQRT2_Q15_128);
+      y128p[5]  = mulhi_int16(y128p[5],ONE_OVER_SQRT2_Q15_128);
+      y128p[6]  = mulhi_int16(y128p[6],ONE_OVER_SQRT2_Q15_128);
+      y128p[7]  = mulhi_int16(y128p[7],ONE_OVER_SQRT2_Q15_128);
+      y128p[8]  = mulhi_int16(y128p[8],ONE_OVER_SQRT2_Q15_128);
+      y128p[9]  = mulhi_int16(y128p[9],ONE_OVER_SQRT2_Q15_128);
+      y128p[10] = mulhi_int16(y128p[10],ONE_OVER_SQRT2_Q15_128);
+      y128p[11] = mulhi_int16(y128p[11],ONE_OVER_SQRT2_Q15_128);
+      y128p[12] = mulhi_int16(y128p[12],ONE_OVER_SQRT2_Q15_128);
+      y128p[13] = mulhi_int16(y128p[13],ONE_OVER_SQRT2_Q15_128);
+      y128p[14] = mulhi_int16(y128p[14],ONE_OVER_SQRT2_Q15_128);
+      y128p[15] = mulhi_int16(y128p[15],ONE_OVER_SQRT2_Q15_128);
+      y128p+=16;
+    }
+  }
+
+  _mm_empty();
+  _m_empty();
+
+}
+
+void idft32768(int16_t *x,int16_t *y,unsigned char scale)
+{
+
+  simdshort_q15_t xtmp[16384],*xtmpp,*x64 = (simdshort_q15_t *)x;
+  simd_q15_t ytmp[8192],*tw32768_128p=(simd_q15_t *)tw32768,*y128=(simd_q15_t *)y,*y128p=(simd_q15_t *)y;
+  simd_q15_t *ytmpp = &ytmp[0];
+  int i;
+  simd_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16(ONE_OVER_SQRT2_Q15);
+  
+  xtmpp = xtmp;
+
+  for (i=0; i<256; i++) {
+    transpose4_ooff(x64  ,xtmpp,8192);
+    transpose4_ooff(x64+2,xtmpp+1,8192);
+    transpose4_ooff(x64+4,xtmpp+2,8192);
+    transpose4_ooff(x64+6,xtmpp+3,8192);
+    transpose4_ooff(x64+8,xtmpp+4,8192);
+    transpose4_ooff(x64+10,xtmpp+5,8192);
+    transpose4_ooff(x64+12,xtmpp+6,8192);
+    transpose4_ooff(x64+14,xtmpp+7,8192);
+    transpose4_ooff(x64+16,xtmpp+8,8192);
+    transpose4_ooff(x64+18,xtmpp+9,8192);
+    transpose4_ooff(x64+20,xtmpp+10,8192);
+    transpose4_ooff(x64+22,xtmpp+11,8192);
+    transpose4_ooff(x64+24,xtmpp+12,8192);
+    transpose4_ooff(x64+26,xtmpp+13,8192);
+    transpose4_ooff(x64+28,xtmpp+14,8192);
+    transpose4_ooff(x64+30,xtmpp+15,8192);
+    transpose4_ooff(x64+32,xtmpp+16,8192);
+    transpose4_ooff(x64+34,xtmpp+17,8192);
+    transpose4_ooff(x64+36,xtmpp+18,8192);
+    transpose4_ooff(x64+38,xtmpp+19,8192);
+    transpose4_ooff(x64+40,xtmpp+20,8192);
+    transpose4_ooff(x64+42,xtmpp+21,8192);
+    transpose4_ooff(x64+44,xtmpp+22,8192);
+    transpose4_ooff(x64+46,xtmpp+23,8192);
+    transpose4_ooff(x64+48,xtmpp+24,8192);
+    transpose4_ooff(x64+50,xtmpp+25,8192);
+    transpose4_ooff(x64+52,xtmpp+26,8192);
+    transpose4_ooff(x64+54,xtmpp+27,8192);
+    transpose4_ooff(x64+56,xtmpp+28,8192);
+    transpose4_ooff(x64+58,xtmpp+29,8192);
+    transpose4_ooff(x64+60,xtmpp+30,8192);
+    transpose4_ooff(x64+62,xtmpp+31,8192);
+    x64+=64;
+    xtmpp+=32;
+  }
+
+  idft16384((int16_t*)(xtmp),(int16_t*)ytmp,1);
+  idft16384((int16_t*)(xtmp+8192),(int16_t*)(ytmp+4096),1);
+
+
+  for (i=0; i<4096; i++) {
+    ibfly2(ytmpp,ytmpp+4096,
+           y128p,y128p+4096,
+           tw32768_128p);
+    tw32768_128p++;
+    y128p++;
+    ytmpp++;
+  }
+
+  if (scale>0) {
+    y128p = y128;
+
+    for (i=0; i<512; i++) {
+      y128p[0]  = mulhi_int16(y128p[0],ONE_OVER_SQRT2_Q15_128);
+      y128p[1]  = mulhi_int16(y128p[1],ONE_OVER_SQRT2_Q15_128);
+      y128p[2]  = mulhi_int16(y128p[2],ONE_OVER_SQRT2_Q15_128);
+      y128p[3]  = mulhi_int16(y128p[3],ONE_OVER_SQRT2_Q15_128);
+      y128p[4]  = mulhi_int16(y128p[4],ONE_OVER_SQRT2_Q15_128);
+      y128p[5]  = mulhi_int16(y128p[5],ONE_OVER_SQRT2_Q15_128);
+      y128p[6]  = mulhi_int16(y128p[6],ONE_OVER_SQRT2_Q15_128);
+      y128p[7]  = mulhi_int16(y128p[7],ONE_OVER_SQRT2_Q15_128);
+      y128p[8]  = mulhi_int16(y128p[8],ONE_OVER_SQRT2_Q15_128);
+      y128p[9]  = mulhi_int16(y128p[9],ONE_OVER_SQRT2_Q15_128);
+      y128p[10] = mulhi_int16(y128p[10],ONE_OVER_SQRT2_Q15_128);
+      y128p[11] = mulhi_int16(y128p[11],ONE_OVER_SQRT2_Q15_128);
+      y128p[12] = mulhi_int16(y128p[12],ONE_OVER_SQRT2_Q15_128);
+      y128p[13] = mulhi_int16(y128p[13],ONE_OVER_SQRT2_Q15_128);
+      y128p[14] = mulhi_int16(y128p[14],ONE_OVER_SQRT2_Q15_128);
+      y128p[15] = mulhi_int16(y128p[15],ONE_OVER_SQRT2_Q15_128);
+      y128p+=16;
+    }
+  }
+
+  _mm_empty();
+  _m_empty();
+
+}
+
+#else // __AVX2__
+void dft32768(int16_t *x,int16_t *y,unsigned char scale)
+{
+
+  simd256_q15_t xtmp[4096],*xtmpp,*x256 = (simd256_q15_t *)x;
+  simd256_q15_t ytmp[4096],*tw32768_256p=(simd256_q15_t *)tw32768,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y;
+
+  simd256_q15_t *ytmpp = &ytmp[0];
+  int i;
+  simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15);
+  
+  xtmpp = xtmp;
+
+  for (i=0; i<256; i++) {
+    transpose4_ooff_simd256(x256  ,xtmpp,2048);
+    transpose4_ooff_simd256(x256+2,xtmpp+1,2048);
+    transpose4_ooff_simd256(x256+4,xtmpp+2,2048);
+    transpose4_ooff_simd256(x256+6,xtmpp+3,2048);
+    transpose4_ooff_simd256(x256+8,xtmpp+4,2048);
+    transpose4_ooff_simd256(x256+10,xtmpp+5,2048);
+    transpose4_ooff_simd256(x256+12,xtmpp+6,2048);
+    transpose4_ooff_simd256(x256+14,xtmpp+7,2048);
+    transpose4_ooff_simd256(x256+16,xtmpp+8,2048);
+    transpose4_ooff_simd256(x256+18,xtmpp+9,2048);
+    transpose4_ooff_simd256(x256+20,xtmpp+10,2048);
+    transpose4_ooff_simd256(x256+22,xtmpp+11,2048);
+    transpose4_ooff_simd256(x256+24,xtmpp+12,2048);
+    transpose4_ooff_simd256(x256+26,xtmpp+13,2048);
+    transpose4_ooff_simd256(x256+28,xtmpp+14,2048);
+    transpose4_ooff_simd256(x256+30,xtmpp+15,2048);
+    transpose4_ooff_simd256(x256+32,xtmpp+16,2048);
+    transpose4_ooff_simd256(x256+34,xtmpp+17,2048);
+    transpose4_ooff_simd256(x256+36,xtmpp+18,2048);
+    transpose4_ooff_simd256(x256+38,xtmpp+19,2048);
+    transpose4_ooff_simd256(x256+40,xtmpp+20,2048);
+    transpose4_ooff_simd256(x256+42,xtmpp+21,2048);
+    transpose4_ooff_simd256(x256+44,xtmpp+22,2048);
+    transpose4_ooff_simd256(x256+46,xtmpp+23,2048);
+    transpose4_ooff_simd256(x256+48,xtmpp+24,2048);
+    transpose4_ooff_simd256(x256+50,xtmpp+25,2048);
+    transpose4_ooff_simd256(x256+52,xtmpp+26,2048);
+    transpose4_ooff_simd256(x256+54,xtmpp+27,2048);
+    transpose4_ooff_simd256(x256+56,xtmpp+28,2048);
+    transpose4_ooff_simd256(x256+58,xtmpp+29,2048);
+    transpose4_ooff_simd256(x256+60,xtmpp+30,2048);
+    transpose4_ooff_simd256(x256+62,xtmpp+31,2048);
+    x256+=64;
+    xtmpp+=32;
+  }
+
+  dft16384((int16_t*)(xtmp),(int16_t*)ytmp,1);
+  dft16384((int16_t*)(xtmp+2048),(int16_t*)(ytmp+2048),1);
+
+
+  for (i=0; i<2048; i++) {
+    bfly2_256(ytmpp,ytmpp+2048,
+	      y256p,y256p+2048,
+	      tw32768_256p);
+    tw32768_256p++;
+    y256p++;
+    ytmpp++;
+  }
+
+  if (scale>0) {
+    y256p = y256;
+
+    for (i=0; i<64; i++) {
+      y256p[0]  = mulhi_int16_simd256(y256p[0],ONE_OVER_SQRT2_Q15_128);
+      y256p[1]  = mulhi_int16_simd256(y256p[1],ONE_OVER_SQRT2_Q15_128);
+      y256p[2]  = mulhi_int16_simd256(y256p[2],ONE_OVER_SQRT2_Q15_128);
+      y256p[3]  = mulhi_int16_simd256(y256p[3],ONE_OVER_SQRT2_Q15_128);
+      y256p[4]  = mulhi_int16_simd256(y256p[4],ONE_OVER_SQRT2_Q15_128);
+      y256p[5]  = mulhi_int16_simd256(y256p[5],ONE_OVER_SQRT2_Q15_128);
+      y256p[6]  = mulhi_int16_simd256(y256p[6],ONE_OVER_SQRT2_Q15_128);
+      y256p[7]  = mulhi_int16_simd256(y256p[7],ONE_OVER_SQRT2_Q15_128);
+      y256p[8]  = mulhi_int16_simd256(y256p[8],ONE_OVER_SQRT2_Q15_128);
+      y256p[9]  = mulhi_int16_simd256(y256p[9],ONE_OVER_SQRT2_Q15_128);
+      y256p[10] = mulhi_int16_simd256(y256p[10],ONE_OVER_SQRT2_Q15_128);
+      y256p[11] = mulhi_int16_simd256(y256p[11],ONE_OVER_SQRT2_Q15_128);
+      y256p[12] = mulhi_int16_simd256(y256p[12],ONE_OVER_SQRT2_Q15_128);
+      y256p[13] = mulhi_int16_simd256(y256p[13],ONE_OVER_SQRT2_Q15_128);
+      y256p[14] = mulhi_int16_simd256(y256p[14],ONE_OVER_SQRT2_Q15_128);
+      y256p[15] = mulhi_int16_simd256(y256p[15],ONE_OVER_SQRT2_Q15_128);
+      y256p+=16;
+    }
+  }
+
+  _mm_empty();
+  _m_empty();
+
+}
+
+void idft32768(int16_t *x,int16_t *y,unsigned char scale)
+{
+
+  simd256_q15_t xtmp[4096],*xtmpp,*x256 = (simd256_q15_t *)x;
+  simd256_q15_t ytmp[4096],*tw32768_256p=(simd256_q15_t *)tw32768,*y256=(simd256_q15_t *)y,*y256p=(simd256_q15_t *)y;
+  simd256_q15_t *ytmpp = &ytmp[0];
+  int i;
+  simd256_q15_t ONE_OVER_SQRT2_Q15_128 = set1_int16_simd256(ONE_OVER_SQRT2_Q15);
+  
+  xtmpp = xtmp;
+
+  for (i=0; i<64; i++) {
+    transpose4_ooff_simd256(x256  ,xtmpp,2048);
+    transpose4_ooff_simd256(x256+2,xtmpp+1,2048);
+    transpose4_ooff_simd256(x256+4,xtmpp+2,2048);
+    transpose4_ooff_simd256(x256+6,xtmpp+3,2048);
+    transpose4_ooff_simd256(x256+8,xtmpp+4,2048);
+    transpose4_ooff_simd256(x256+10,xtmpp+5,2048);
+    transpose4_ooff_simd256(x256+12,xtmpp+6,2048);
+    transpose4_ooff_simd256(x256+14,xtmpp+7,2048);
+    transpose4_ooff_simd256(x256+16,xtmpp+8,2048);
+    transpose4_ooff_simd256(x256+18,xtmpp+9,2048);
+    transpose4_ooff_simd256(x256+20,xtmpp+10,2048);
+    transpose4_ooff_simd256(x256+22,xtmpp+11,2048);
+    transpose4_ooff_simd256(x256+24,xtmpp+12,2048);
+    transpose4_ooff_simd256(x256+26,xtmpp+13,2048);
+    transpose4_ooff_simd256(x256+28,xtmpp+14,2048);
+    transpose4_ooff_simd256(x256+30,xtmpp+15,2048);
+    transpose4_ooff_simd256(x256+32,xtmpp+16,2048);
+    transpose4_ooff_simd256(x256+34,xtmpp+17,2048);
+    transpose4_ooff_simd256(x256+36,xtmpp+18,2048);
+    transpose4_ooff_simd256(x256+38,xtmpp+19,2048);
+    transpose4_ooff_simd256(x256+40,xtmpp+20,2048);
+    transpose4_ooff_simd256(x256+42,xtmpp+21,2048);
+    transpose4_ooff_simd256(x256+44,xtmpp+22,2048);
+    transpose4_ooff_simd256(x256+46,xtmpp+23,2048);
+    transpose4_ooff_simd256(x256+48,xtmpp+24,2048);
+    transpose4_ooff_simd256(x256+50,xtmpp+25,2048);
+    transpose4_ooff_simd256(x256+52,xtmpp+26,2048);
+    transpose4_ooff_simd256(x256+54,xtmpp+27,2048);
+    transpose4_ooff_simd256(x256+56,xtmpp+28,2048);
+    transpose4_ooff_simd256(x256+58,xtmpp+29,2048);
+    transpose4_ooff_simd256(x256+60,xtmpp+30,2048);
+    transpose4_ooff_simd256(x256+62,xtmpp+31,2048);
+    x256+=64;
+    xtmpp+=32;
+  }
+
+  idft16384((int16_t*)(xtmp),(int16_t*)ytmp,1);
+  idft16384((int16_t*)(xtmp+2048),(int16_t*)(ytmp+2048),1);
+
+
+  for (i=0; i<2048; i++) {
+    ibfly2_256(ytmpp,ytmpp+2048,
+	       y256p,y256p+2048,
+	       tw32768_256p);
+    tw32768_256p++;
+    y256p++;
+    ytmpp++;
+  }
+
+  if (scale>0) {
+    y256p = y256;
+
+    for (i=0; i<256; i++) {
+      y256p[0]  = mulhi_int16_simd256(y256p[0],ONE_OVER_SQRT2_Q15_128);
+      y256p[1]  = mulhi_int16_simd256(y256p[1],ONE_OVER_SQRT2_Q15_128);
+      y256p[2]  = mulhi_int16_simd256(y256p[2],ONE_OVER_SQRT2_Q15_128);
+      y256p[3]  = mulhi_int16_simd256(y256p[3],ONE_OVER_SQRT2_Q15_128);
+      y256p[4]  = mulhi_int16_simd256(y256p[4],ONE_OVER_SQRT2_Q15_128);
+      y256p[5]  = mulhi_int16_simd256(y256p[5],ONE_OVER_SQRT2_Q15_128);
+      y256p[6]  = mulhi_int16_simd256(y256p[6],ONE_OVER_SQRT2_Q15_128);
+      y256p[7]  = mulhi_int16_simd256(y256p[7],ONE_OVER_SQRT2_Q15_128);
+      y256p[8]  = mulhi_int16_simd256(y256p[8],ONE_OVER_SQRT2_Q15_128);
+      y256p[9]  = mulhi_int16_simd256(y256p[9],ONE_OVER_SQRT2_Q15_128);
+      y256p[10] = mulhi_int16_simd256(y256p[10],ONE_OVER_SQRT2_Q15_128);
+      y256p[11] = mulhi_int16_simd256(y256p[11],ONE_OVER_SQRT2_Q15_128);
+      y256p[12] = mulhi_int16_simd256(y256p[12],ONE_OVER_SQRT2_Q15_128);
+      y256p[13] = mulhi_int16_simd256(y256p[13],ONE_OVER_SQRT2_Q15_128);
+      y256p[14] = mulhi_int16_simd256(y256p[14],ONE_OVER_SQRT2_Q15_128);
+      y256p[15] = mulhi_int16_simd256(y256p[15],ONE_OVER_SQRT2_Q15_128);
+      y256p+=16;
+    }
+  }
+
+  _mm_empty();
+  _m_empty();
+
+}
+
+
+#endif
+
+
 int16_t twa1536[1024],twb1536[1024];
 
 // 512 x 3
@@ -6176,12 +6777,99 @@ int16_t twb49152[32768] __attribute__((aligned(32)));
 // 16384 x 3
 void dft49152(int16_t *input, int16_t *output,uint8_t scale) {
 
-  AssertFatal(1==0,"Need to do this ..\n");
+  int i,i2,j;
+  uint32_t tmp[3][16384] __attribute__((aligned(32)));
+  uint32_t tmpo[3][16384] __attribute__((aligned(32)));
+  simd_q15_t *y128p=(simd_q15_t*)output;
+  simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15);
+
+  for (i=0,j=0; i<16384; i++) {
+    tmp[0][i] = ((uint32_t *)input)[j++];
+    tmp[1][i] = ((uint32_t *)input)[j++];
+    tmp[2][i] = ((uint32_t *)input)[j++];
+  }
+
+  dft16384((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1);
+  dft16384((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1);
+  dft16384((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1);
+
+  for (i=0,i2=0; i<32768; i+=8,i2+=4)  {
+    bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]),
+          (simd_q15_t*)(output+i),(simd_q15_t*)(output+32768+i),(simd_q15_t*)(output+65536+i),
+          (simd_q15_t*)(twa49152+i),(simd_q15_t*)(twb49152+i));
+  }
+  if (scale==1) {
+    for (i=0; i<768; i++) {
+      y128p[0]  = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128);
+      y128p[1]  = mulhi_int16(y128p[1],ONE_OVER_SQRT3_Q15_128);
+      y128p[2]  = mulhi_int16(y128p[2],ONE_OVER_SQRT3_Q15_128);
+      y128p[3]  = mulhi_int16(y128p[3],ONE_OVER_SQRT3_Q15_128);
+      y128p[4]  = mulhi_int16(y128p[4],ONE_OVER_SQRT3_Q15_128);
+      y128p[5]  = mulhi_int16(y128p[5],ONE_OVER_SQRT3_Q15_128);
+      y128p[6]  = mulhi_int16(y128p[6],ONE_OVER_SQRT3_Q15_128);
+      y128p[7]  = mulhi_int16(y128p[7],ONE_OVER_SQRT3_Q15_128);
+      y128p[8]  = mulhi_int16(y128p[8],ONE_OVER_SQRT3_Q15_128);
+      y128p[9]  = mulhi_int16(y128p[9],ONE_OVER_SQRT3_Q15_128);
+      y128p[10] = mulhi_int16(y128p[10],ONE_OVER_SQRT3_Q15_128);
+      y128p[11] = mulhi_int16(y128p[11],ONE_OVER_SQRT3_Q15_128);
+      y128p[12] = mulhi_int16(y128p[12],ONE_OVER_SQRT3_Q15_128);
+      y128p[13] = mulhi_int16(y128p[13],ONE_OVER_SQRT3_Q15_128);
+      y128p[14] = mulhi_int16(y128p[14],ONE_OVER_SQRT3_Q15_128);
+      y128p[15] = mulhi_int16(y128p[15],ONE_OVER_SQRT3_Q15_128);
+      y128p+=16;
+    }
+  }
+  _mm_empty();
+  _m_empty();
+
 }
 
 void idft49152(int16_t *input, int16_t *output,uint8_t scale) {
 
-  AssertFatal(1==0,"Need to do this ..\n");
+   int i,i2,j;
+  uint32_t tmp[3][16384] __attribute__((aligned(32)));
+  uint32_t tmpo[3][16384] __attribute__((aligned(32)));
+  simd_q15_t *y128p=(simd_q15_t*)output;
+  simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15);
+
+  for (i=0,j=0; i<16384; i++) {
+    tmp[0][i] = ((uint32_t *)input)[j++];
+    tmp[1][i] = ((uint32_t *)input)[j++];
+    tmp[2][i] = ((uint32_t *)input)[j++];
+  }
+
+  idft16384((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1);
+  idft16384((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1);
+  idft16384((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1);
+
+  for (i=0,i2=0; i<32768; i+=8,i2+=4)  {
+    ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]),
+	   (simd_q15_t*)(output+i),(simd_q15_t*)(output+32768+i),(simd_q15_t*)(output+65536+i),
+	   (simd_q15_t*)(twa49152+i),(simd_q15_t*)(twb49152+i));
+  }
+  if (scale==1) {
+    for (i=0; i<768; i++) {
+      y128p[0]  = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128);
+      y128p[1]  = mulhi_int16(y128p[1],ONE_OVER_SQRT3_Q15_128);
+      y128p[2]  = mulhi_int16(y128p[2],ONE_OVER_SQRT3_Q15_128);
+      y128p[3]  = mulhi_int16(y128p[3],ONE_OVER_SQRT3_Q15_128);
+      y128p[4]  = mulhi_int16(y128p[4],ONE_OVER_SQRT3_Q15_128);
+      y128p[5]  = mulhi_int16(y128p[5],ONE_OVER_SQRT3_Q15_128);
+      y128p[6]  = mulhi_int16(y128p[6],ONE_OVER_SQRT3_Q15_128);
+      y128p[7]  = mulhi_int16(y128p[7],ONE_OVER_SQRT3_Q15_128);
+      y128p[8]  = mulhi_int16(y128p[8],ONE_OVER_SQRT3_Q15_128);
+      y128p[9]  = mulhi_int16(y128p[9],ONE_OVER_SQRT3_Q15_128);
+      y128p[10] = mulhi_int16(y128p[10],ONE_OVER_SQRT3_Q15_128);
+      y128p[11] = mulhi_int16(y128p[11],ONE_OVER_SQRT3_Q15_128);
+      y128p[12] = mulhi_int16(y128p[12],ONE_OVER_SQRT3_Q15_128);
+      y128p[13] = mulhi_int16(y128p[13],ONE_OVER_SQRT3_Q15_128);
+      y128p[14] = mulhi_int16(y128p[14],ONE_OVER_SQRT3_Q15_128);
+      y128p[15] = mulhi_int16(y128p[15],ONE_OVER_SQRT3_Q15_128);
+      y128p+=16;
+    }
+  }
+  _mm_empty();
+  _m_empty();
 }
 
 int16_t twa73728[49152] __attribute__((aligned(32)));
@@ -6198,17 +6886,104 @@ void idft73728(int16_t *input, int16_t *output,uint8_t scale) {
 }
 
 
-int16_t twa98304[49152] __attribute__((aligned(32)));
-int16_t twb98304[49152] __attribute__((aligned(32)));
+int16_t twa98304[65536] __attribute__((aligned(32)));
+int16_t twb98304[65536] __attribute__((aligned(32)));
 // 32768 x 3
 void dft98304(int16_t *input, int16_t *output,uint8_t scale) {
 
-  AssertFatal(1==0,"Need to do this ..\n");
+  int i,i2,j;
+  uint32_t tmp[3][32768] __attribute__((aligned(32)));
+  uint32_t tmpo[3][32768] __attribute__((aligned(32)));
+  simd_q15_t *y128p=(simd_q15_t*)output;
+  simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15);
+
+  for (i=0,j=0; i<32768; i++) {
+    tmp[0][i] = ((uint32_t *)input)[j++];
+    tmp[1][i] = ((uint32_t *)input)[j++];
+    tmp[2][i] = ((uint32_t *)input)[j++];
+  }
+
+  dft32768((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1);
+  dft32768((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1);
+  dft32768((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1);
+
+  for (i=0,i2=0; i<65536; i+=8,i2+=4)  {
+    bfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]),
+          (simd_q15_t*)(output+i),(simd_q15_t*)(output+65536+i),(simd_q15_t*)(output+131072+i),
+          (simd_q15_t*)(twa98304+i),(simd_q15_t*)(twb98304+i));
+  }
+  if (scale==1) {
+    for (i=0; i<1536; i++) {
+      y128p[0]  = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128);
+      y128p[1]  = mulhi_int16(y128p[1],ONE_OVER_SQRT3_Q15_128);
+      y128p[2]  = mulhi_int16(y128p[2],ONE_OVER_SQRT3_Q15_128);
+      y128p[3]  = mulhi_int16(y128p[3],ONE_OVER_SQRT3_Q15_128);
+      y128p[4]  = mulhi_int16(y128p[4],ONE_OVER_SQRT3_Q15_128);
+      y128p[5]  = mulhi_int16(y128p[5],ONE_OVER_SQRT3_Q15_128);
+      y128p[6]  = mulhi_int16(y128p[6],ONE_OVER_SQRT3_Q15_128);
+      y128p[7]  = mulhi_int16(y128p[7],ONE_OVER_SQRT3_Q15_128);
+      y128p[8]  = mulhi_int16(y128p[8],ONE_OVER_SQRT3_Q15_128);
+      y128p[9]  = mulhi_int16(y128p[9],ONE_OVER_SQRT3_Q15_128);
+      y128p[10] = mulhi_int16(y128p[10],ONE_OVER_SQRT3_Q15_128);
+      y128p[11] = mulhi_int16(y128p[11],ONE_OVER_SQRT3_Q15_128);
+      y128p[12] = mulhi_int16(y128p[12],ONE_OVER_SQRT3_Q15_128);
+      y128p[13] = mulhi_int16(y128p[13],ONE_OVER_SQRT3_Q15_128);
+      y128p[14] = mulhi_int16(y128p[14],ONE_OVER_SQRT3_Q15_128);
+      y128p[15] = mulhi_int16(y128p[15],ONE_OVER_SQRT3_Q15_128);
+      y128p+=16;
+    }
+  }
+  _mm_empty();
+  _m_empty();
+
 }
 
 void idft98304(int16_t *input, int16_t *output,uint8_t scale) {
 
-  AssertFatal(1==0,"Need to do this ..\n");
+  int i,i2,j;
+  uint32_t tmp[3][32768] __attribute__((aligned(32)));
+  uint32_t tmpo[3][32768] __attribute__((aligned(32)));
+  simd_q15_t *y128p=(simd_q15_t*)output;
+  simd_q15_t ONE_OVER_SQRT3_Q15_128 = set1_int16(ONE_OVER_SQRT3_Q15);
+
+  for (i=0,j=0; i<32768; i++) {
+    tmp[0][i] = ((uint32_t *)input)[j++];
+    tmp[1][i] = ((uint32_t *)input)[j++];
+    tmp[2][i] = ((uint32_t *)input)[j++];
+  }
+
+  idft32768((int16_t*)(tmp[0]),(int16_t*)(tmpo[0]),1);
+  idft32768((int16_t*)(tmp[1]),(int16_t*)(tmpo[1]),1);
+  idft32768((int16_t*)(tmp[2]),(int16_t*)(tmpo[2]),1);
+
+  for (i=0,i2=0; i<65536; i+=8,i2+=4)  {
+    ibfly3((simd_q15_t*)(&tmpo[0][i2]),(simd_q15_t*)(&tmpo[1][i2]),((simd_q15_t*)&tmpo[2][i2]),
+	   (simd_q15_t*)(output+i),(simd_q15_t*)(output+65536+i),(simd_q15_t*)(output+131072+i),
+	   (simd_q15_t*)(twa98304+i),(simd_q15_t*)(twb98304+i));
+  }
+  if (scale==1) {
+    for (i=0; i<1536; i++) {
+      y128p[0]  = mulhi_int16(y128p[0],ONE_OVER_SQRT3_Q15_128);
+      y128p[1]  = mulhi_int16(y128p[1],ONE_OVER_SQRT3_Q15_128);
+      y128p[2]  = mulhi_int16(y128p[2],ONE_OVER_SQRT3_Q15_128);
+      y128p[3]  = mulhi_int16(y128p[3],ONE_OVER_SQRT3_Q15_128);
+      y128p[4]  = mulhi_int16(y128p[4],ONE_OVER_SQRT3_Q15_128);
+      y128p[5]  = mulhi_int16(y128p[5],ONE_OVER_SQRT3_Q15_128);
+      y128p[6]  = mulhi_int16(y128p[6],ONE_OVER_SQRT3_Q15_128);
+      y128p[7]  = mulhi_int16(y128p[7],ONE_OVER_SQRT3_Q15_128);
+      y128p[8]  = mulhi_int16(y128p[8],ONE_OVER_SQRT3_Q15_128);
+      y128p[9]  = mulhi_int16(y128p[9],ONE_OVER_SQRT3_Q15_128);
+      y128p[10] = mulhi_int16(y128p[10],ONE_OVER_SQRT3_Q15_128);
+      y128p[11] = mulhi_int16(y128p[11],ONE_OVER_SQRT3_Q15_128);
+      y128p[12] = mulhi_int16(y128p[12],ONE_OVER_SQRT3_Q15_128);
+      y128p[13] = mulhi_int16(y128p[13],ONE_OVER_SQRT3_Q15_128);
+      y128p[14] = mulhi_int16(y128p[14],ONE_OVER_SQRT3_Q15_128);
+      y128p[15] = mulhi_int16(y128p[15],ONE_OVER_SQRT3_Q15_128);
+      y128p+=16;
+    }
+  }
+  _mm_empty();
+  _m_empty();
 }
 
  
@@ -8823,6 +9598,8 @@ int dfts_autoinit(void)
   init_rad2(2048,tw2048);
   init_rad4(4096,tw4096);
   init_rad2(8192,tw8192);
+  init_rad4(16384,tw16384);
+  init_rad2(32768,tw32768);
   
   init_rad3(1536,twa1536,twb1536);
   init_rad3(3072,twa3072,twb3072);
@@ -8830,6 +9607,10 @@ int dfts_autoinit(void)
   init_rad3(12288,twa12288,twb12288);
   init_rad3(18432,twa18432,twb18432);
   init_rad3(24576,twa24576,twb24576);
+  init_rad3(36864,twa36864,twb36864);
+  init_rad3(49152,twa49152,twb49152);
+  init_rad3(98304,twa98304,twb98304);
+
 
   init_rad2_rep(24,tw24);
   init_rad3_rep(36,twa36,twb36);
@@ -8869,6 +9650,7 @@ int dfts_autoinit(void)
 
 
 
+#ifndef MR_MAIN
 
 void dft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag){
 	AssertFatal((sizeidx>=0 && sizeidx<(int)DFT_SIZE_IDXTABLESIZE),"Invalid dft size index %i\n",sizeidx);
@@ -8879,6 +9661,7 @@ void idft(uint8_t sizeidx, int16_t *sigF,int16_t *sig,unsigned char scale_flag){
 	AssertFatal((sizeidx>=0 && sizeidx<(int)IDFT_SIZE_IDXTABLESIZE),"Invalid idft size index %i\n",sizeidx);
 	idft_ftab[sizeidx](sigF,sig,scale_flag);
 };
+#endif
 
 /*---------------------------------------------------------------------------------------*/
 
@@ -9049,9 +9832,9 @@ int main(int argc, char**argv)
 
   time_stats_t ts;
 #ifdef __AVX2__
-  simd256_q15_t x[4096],x2[4096],y[4096],tw0,tw1,tw2,tw3;
+  simd256_q15_t x[16384],x2[16384],y[16384],tw0,tw1,tw2,tw3;
 #else
-  simd_q15_t x[8192],y[8192],tw0,tw1,tw2,tw3;
+  simd_q15_t x[32768],y[32768],tw0,tw1,tw2,tw3;
 #endif
   int i;
   simd_q15_t *x128=(simd_q15_t*)x,*y128=(simd_q15_t*)y;
@@ -9613,10 +10396,34 @@ int main(int argc, char**argv)
     stop_meas(&ts);
   }
 
-  printf("\n\n1536-point(%f cycles)\n",(double)ts.diff/(double)ts.trials);
+  printf("\n\n8192-point(%f cycles)\n",(double)ts.diff/(double)ts.trials);
   LOG_M("y8192.m","y8192",y,8192,1,1);
   LOG_M("x8192.m","x8192",x,8192,1,1);
 
+  memset((void*)x,0,16384*sizeof(int32_t));
+  for (i=2;i<9602;i++) {
+    if ((taus() & 1)==0)
+      ((int16_t*)x)[i] = 364;
+    else
+      ((int16_t*)x)[i] = -364;
+  }
+  for (i=2*(16384-4800);i<32768;i++) {
+    if ((taus() & 1)==0)
+      ((int16_t*)x)[i] = 364;
+    else
+      ((int16_t*)x)[i] = -364;
+  }
+  reset_meas(&ts);
+  for (i=0; i<10000; i++) {
+    start_meas(&ts);
+    dft16384((int16_t *)x,(int16_t *)y,1);
+    stop_meas(&ts);
+  }
+
+  printf("\n\n16384-point(%f cycles)\n",(double)ts.diff/(double)ts.trials);
+  LOG_M("y16384.m","y16384",y,16384,1,1);
+  LOG_M("x16384.m","x16384",x,16384,1,1);
+
   memset((void*)x,0,1536*sizeof(int32_t));
   for (i=2;i<1202;i++) {
     if ((taus() & 1)==0)
@@ -9765,6 +10572,56 @@ int main(int argc, char**argv)
   LOG_M("y24576.m","y24576",y,24576,1,1);
   LOG_M("x24576.m","x24576",x,24576,1,1);
 
+
+  memset((void*)x,0,2*18432*sizeof(int32_t));
+  for (i=2;i<(2*14402);i++) {
+    if ((taus() & 1)==0)
+      ((int16_t*)x)[i] = 364;
+    else
+      ((int16_t*)x)[i] = -364;
+  }
+  for (i=2*(36864-14400);i<(36864*2);i++) {
+    if ((taus() & 1)==0)
+      ((int16_t*)x)[i] = 364;
+    else
+      ((int16_t*)x)[i] = -364;
+  }
+  reset_meas(&ts);
+  for (i=0; i<10000; i++) {
+    start_meas(&ts);
+    dft36864((int16_t *)x,(int16_t *)y,1);
+    stop_meas(&ts);
+  }
+
+  printf("\n\n36864-point(%f cycles)\n",(double)ts.diff/(double)ts.trials);
+  LOG_M("y36864.m","y36864",y,36864,1,1);
+  LOG_M("x36864.m","x36864",x,36864,1,1);
+
+
+  memset((void*)x,0,49152*sizeof(int32_t));
+  for (i=2;i<28402;i++) {
+    if ((taus() & 1)==0)
+      ((int16_t*)x)[i] = 364;
+    else
+      ((int16_t*)x)[i] = -364;
+  } 
+  for (i=2*(49152-14400);i<98304;i++) {
+    if ((taus() & 1)==0)
+      ((int16_t*)x)[i] = 364;
+    else
+      ((int16_t*)x)[i] = -364;
+  }
+  reset_meas(&ts);
+  for (i=0; i<10000; i++) {
+    start_meas(&ts);
+    idft49152((int16_t *)x,(int16_t *)y,1);
+    stop_meas(&ts);
+  }
+
+  printf("\n\n49152-point(%f cycles)\n",(double)ts.diff/(double)ts.trials);
+  LOG_M("y49152.m","y49152",y,49152,1,1);
+  LOG_M("x49152.m","x49152",x,49152,1,1);
+  /*
   int dftsizes[33]={24,36,48,60,72,96,108,120,144,180,192,216,240,288,300,324,360,384,432,480,540,576,600,648,720,768,864,900,960,972,1080,1152,1200};
   void (*dft)(int16_t *x,int16_t *y,uint8_t scale)[33] = {dft24,dft36,dft48,dft60,dft72,dft96,dft108,dft120,dft144,dft180,dft192,dft216,dft240,dft288,dft300,dft324,dft360,dft384,dft432,dft480,dft540,dft576,dft600,dft648,dft720,dft768,dft864,dft900,dft960,dft972,dft1080,dft1152,dft1200};
   for (int n=0;n<33;n++) {
@@ -9797,7 +10654,7 @@ int main(int argc, char**argv)
     LOG_M(ystr,ystr2,y,dftsizes[n]*4,1,1);
     LOG_M(xstr,xstr2,x,dftsizes[n]*4,1,1);
   }
-
+  */
 
   return(0);
 }
diff --git a/openair1/PHY/TOOLS/tools_defs.h b/openair1/PHY/TOOLS/tools_defs.h
index 61ea785db82f6256ba403a4aaa7d58e653e67069..9c9b8aa821c3fe1a795246686f04caff3f159738 100644
--- a/openair1/PHY/TOOLS/tools_defs.h
+++ b/openair1/PHY/TOOLS/tools_defs.h
@@ -183,10 +183,6 @@ This function performs optimized fixed-point radix-2 FFT/IFFT.
 
 
 
-
-
-
-
 #ifdef OAIDFTS_MAIN
 typedef  void(*adftfunc_t)(int16_t *sigF,int16_t *sig,unsigned char scale_flag);  
 typedef  void(*aidftfunc_t)(int16_t *sigF,int16_t *sig,unsigned char scale_flag);     
diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h
index 378d89e4ea2115d6c6271135fc9e2a2d3b4ad3dd..e2cdebff3ad345c91d5e4144f316e03190694ace 100644
--- a/openair1/PHY/defs_gNB.h
+++ b/openair1/PHY/defs_gNB.h
@@ -340,6 +340,15 @@ typedef struct {
   uint16_t cba_rnti[NUM_MAX_CBA_GROUP];
 } NR_gNB_ULSCH_t;
 
+typedef struct {
+  uint8_t active;
+  /// Frame where current PUCCH pdu was sent
+  uint32_t frame;
+  /// Slot where current PUCCH pdu was sent
+  uint32_t slot;
+  /// ULSCH PDU
+  nfapi_nr_pucch_pdu_t pucch_pdu;
+} NR_gNB_PUCCH_t;
 
 typedef struct {
   /// \brief Pointers (dynamic) to the received data in the time domain.
@@ -619,9 +628,9 @@ typedef struct {
 
 #define MAX_NUM_NR_RX_RACH_PDUS 4
 #define MAX_NUM_NR_RX_PRACH_PREAMBLES 4
-#define MAX_UL_PDUS_PER_SLOT 100
-#define MAX_NUM_NR_SRS_PDUS 100
-#define MAX_NUM_NR_UCI_PDUS 100
+#define MAX_UL_PDUS_PER_SLOT 8
+#define MAX_NUM_NR_SRS_PDUS 8
+#define MAX_NUM_NR_UCI_PDUS 8
 
 /// Top-level PHY Data Structure for gNB
 typedef struct PHY_VARS_gNB_s {
@@ -675,6 +684,7 @@ typedef struct PHY_VARS_gNB_s {
   NR_gNB_COMMON      common_vars;
   NR_gNB_PRACH       prach_vars;
   NR_gNB_PUSCH       *pusch_vars[NUMBER_OF_NR_ULSCH_MAX];
+  NR_gNB_PUCCH_t     *pucch[NUMBER_OF_NR_PUCCH_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;
diff --git a/openair1/PHY/impl_defs_nr.h b/openair1/PHY/impl_defs_nr.h
index 44f2e314ea653ce8464f4389e23f6d65d142128f..3e09f3f593e2bebc905bdb77311a83ad70243507 100644
--- a/openair1/PHY/impl_defs_nr.h
+++ b/openair1/PHY/impl_defs_nr.h
@@ -757,11 +757,11 @@ typedef struct {
 #define MAX_NR_OF_SPATIAL_RELATION_INFOS          (8)
 
 typedef enum {
-  pucch_format0_nr  = 0,
-  pucch_format1_nr  = 1,
-  pucch_format2_nr  = 2,
-  pucch_format3_nr  = 3,
-  pucch_format4_nr  = 4,
+  pucch_format0_nr  = 1,
+  pucch_format1_nr  = 2,
+  pucch_format2_nr  = 3,
+  pucch_format3_nr  = 4,
+  pucch_format4_nr  = 5
 } pucch_format_nr_t;
 
 typedef enum {
diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c
index 40e4a566675dc0eb0d54988414913c16292a529d..ddebcc3e067e83d03c7ca33ac7164ad329670936 100644
--- a/openair1/SCHED_NR/fapi_nr_l1.c
+++ b/openair1/SCHED_NR/fapi_nr_l1.c
@@ -113,8 +113,6 @@ void handle_nfapi_nr_ul_dci_pdu(PHY_VARS_gNB *gNB,
 
   nr_fill_ul_dci(gNB,frame,slot);
 
-
-
 }
 
 void handle_nr_nfapi_pdsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
@@ -157,6 +155,10 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){
 
   int pdcch_received=0;
   gNB->num_pdsch_rnti=0;
+  for (int i=0; i<NUMBER_OF_NR_DLSCH_MAX; i++) {
+    gNB->dlsch[i][0]->rnti=0;
+    gNB->dlsch[i][0]->harq_mask=0;
+  }
   gNB->pdcch_pdu = NULL;
   gNB->pbch_configured=0;
 
@@ -210,7 +212,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){
         break;
       case NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE:
         LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_TTI_PUCCH_PDU_TYPE for %d.%d\n", frame, slot, UL_tti_req->SFN, UL_tti_req->Slot);
-        //  handle_nfapi_nr_pucch_pdu(gNB,frame,slot,UL_tti_req->pdus_list[i].pucch_pdu);
+        nr_fill_pucch(gNB,UL_tti_req->SFN, UL_tti_req->Slot, &UL_tti_req->pdus_list[i].pucch_pdu);
         break;
       case NFAPI_NR_UL_CONFIG_PRACH_PDU_TYPE:
         LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_TTI_PRACH_PDU_TYPE for %d.%d\n", frame, slot, UL_tti_req->SFN, UL_tti_req->Slot);
diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c
index 702571fef535dcb79c5004884c02d22b28f21a2e..01e0c419dbc0c10794e1f05feac6765b2a5a8f57 100644
--- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c
+++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c
@@ -49,6 +49,8 @@
 
 #include "intertask_interface.h"
 
+//#define DEBUG_RXDATA
+
 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};
 
 extern uint8_t nfapi_mode;
@@ -215,7 +217,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH
   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, nodata_dmrs = 1;
+  uint8_t ret;
   uint8_t l, number_dmrs_symbols = 0;
   uint32_t G;
   uint16_t start_symbol, number_symbols, nb_re_dmrs;
@@ -226,11 +228,10 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH
   for (l = start_symbol; l < start_symbol + number_symbols; l++)
     number_dmrs_symbols += ((pusch_pdu->ul_dmrs_symb_pos)>>l)&0x01;
 
-  if (nodata_dmrs)
-    nb_re_dmrs = 12;
+  if (pusch_pdu->dmrs_config_type==pusch_dmrs_type1)
+    nb_re_dmrs = 6*pusch_pdu->num_dmrs_cdm_grps_no_data;
   else
-    nb_re_dmrs = ((pusch_pdu->dmrs_config_type == pusch_dmrs_type1)?6:4);
-
+    nb_re_dmrs = 4*pusch_pdu->num_dmrs_cdm_grps_no_data;
 
   G = nr_get_G(pusch_pdu->rb_size,
                number_symbols,
@@ -265,6 +266,7 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH
                           G);
   stop_meas(&gNB->ulsch_decoding_stats);
 
+
   if (ret > gNB->ulsch[ULSCH_id][0]->max_ldpc_iterations){
     LOG_I(PHY, "ULSCH %d in error\n",ULSCH_id);
     nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 1);
@@ -382,32 +384,83 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx)
 
   LOG_D(PHY,"phy_procedures_gNB_uespec_RX frame %d, slot %d\n",frame_rx,slot_rx);
 
+  for (int i=0;i<NUMBER_OF_NR_PUCCH_MAX;i++){
+    NR_gNB_PUCCH_t *pucch = gNB->pucch[i];
+    if (pucch) {
+      if ((pucch->active == 1) &&
+	  (pucch->frame == frame_rx) &&
+	  (pucch->slot == slot_rx) ) {
+
+        nfapi_nr_pucch_pdu_t  *pucch_pdu = &pucch[i].pucch_pdu;
+        uint16_t num_ucis;
+
+        switch (pucch_pdu->format_type) {
+        case 0:
+
+          num_ucis = gNB->UL_INFO.uci_ind.num_ucis;
+          gNB->UL_INFO.uci_ind.uci_list = &gNB->uci_pdu_list[0];
+          gNB->UL_INFO.uci_ind.sfn = frame_rx;
+          gNB->UL_INFO.uci_ind.slot = slot_rx;
+          gNB->uci_pdu_list[num_ucis].pdu_type = NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE;
+          gNB->uci_pdu_list[num_ucis].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t);
+          nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu_format0 = &gNB->uci_pdu_list[num_ucis].pucch_pdu_format_0_1;
+
+          nr_decode_pucch0(gNB,
+	                   slot_rx,
+                           uci_pdu_format0,
+                           pucch_pdu);
+
+          gNB->UL_INFO.uci_ind.num_ucis += 1;
+          pucch->active = 0;
+	  break;
+        default:
+	  AssertFatal(1==0,"Only PUCCH format 0 is currently supported\n");
+        }
+      }
+    }
+  }
+
   for (int ULSCH_id=0;ULSCH_id<NUMBER_OF_NR_ULSCH_MAX;ULSCH_id++) {
     NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0];
     int harq_pid;
+    int no_sig;
     NR_UL_gNB_HARQ_t *ulsch_harq;
 
     if ((ulsch) &&
         (ulsch->rnti > 0)) {
       // for for an active HARQ process
       for (harq_pid=0;harq_pid<NR_MAX_ULSCH_HARQ_PROCESSES;harq_pid++) {
-        ulsch_harq = ulsch->harq_processes[harq_pid];
-        AssertFatal(ulsch_harq!=NULL,"harq_pid %d is not allocated\n",harq_pid);
-        if ((ulsch_harq->status == NR_ACTIVE) &&
-            (ulsch_harq->frame == frame_rx) &&
-            (ulsch_harq->slot == slot_rx) &&
-            (ulsch_harq->handled == 0)){
-
-          uint8_t symbol_start = ulsch_harq->ulsch_pdu.start_symbol_index;
-          uint8_t symbol_end = symbol_start + ulsch_harq->ulsch_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);
-          break;
-        }
+	ulsch_harq = ulsch->harq_processes[harq_pid];
+	AssertFatal(ulsch_harq!=NULL,"harq_pid %d is not allocated\n",harq_pid);
+	if ((ulsch_harq->status == NR_ACTIVE) &&
+	    (ulsch_harq->frame == frame_rx) &&
+	    (ulsch_harq->slot == slot_rx) &&
+	    (ulsch_harq->handled == 0)){
+
+#ifdef DEBUG_RXDATA
+          NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
+          RU_t *ru = gNB->RU_list[0];
+          int slot_offset = frame_parms->get_samples_slot_timestamp(slot_rx,frame_parms,0);
+          slot_offset -= ru->N_TA_offset;
+          char name[128];
+          FILE *f;
+          sprintf(name, "rxdata.%d.%d.raw", frame_rx,slot_rx);
+          f = fopen(name, "w"); if (f == NULL) exit(1);
+          fwrite(&ru->common.rxdata[0][slot_offset],2,frame_parms->get_samples_per_slot(slot_rx,frame_parms)*2, f);
+          fclose(f);
+#endif
+
+	  uint8_t symbol_start = ulsch_harq->ulsch_pdu.start_symbol_index;
+	  uint8_t symbol_end = symbol_start + ulsch_harq->ulsch_pdu.nr_of_symbols;
+	  for(uint8_t symbol = symbol_start; symbol < symbol_end; symbol++) {
+	    no_sig = nr_rx_pusch(gNB, ULSCH_id, frame_rx, slot_rx, symbol, harq_pid);
+            if (no_sig) return;
+	  }
+	  //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);
+	  break;
+	}
       }
     }
   }
diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c
index f7e03b7dfe06bcbcfb4ab3c90db8234e9f378733..f852ae4ae18d6be1ced80a05b5868dadd74eb169 100644
--- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c
+++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c
@@ -34,6 +34,8 @@
 
 #include "fapi_nr_ue_interface.h"
 #include "fapi_nr_ue_l1.h"
+#include "harq_nr.h"
+//#include "PHY/phy_vars_nr_ue.h"
 
 #include "PHY/defs_nr_UE.h"
 #include "PHY/impl_defs_nr.h"
@@ -54,12 +56,18 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
     NR_UE_DLSCH_t *dlsch0 = NULL;
     NR_UE_PDCCH *pdcch_vars = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[thread_id][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;
+    //PRACH_RESOURCES_t *prach_resources = PHY_vars_UE_g[module_id][cc_id]->prach_resources[0];
+        
+    //        PUCCH_ConfigCommon_nr_t    *pucch_config_common = PHY_vars_UE_g[module_id][cc_id]->pucch_config_common_nr[0];
+    //        PUCCH_Config_t             *pucch_config_dedicated = PHY_vars_UE_g[module_id][cc_id]->pucch_config_dedicated_nr[0];
 
     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) {
@@ -99,14 +107,14 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
             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;
             dlsch0->g_pucch = dlsch_config_pdu->accumulated_delta_PUCCH;
             dlsch0_harq->harq_ack.pucch_resource_indicator = dlsch_config_pdu->pucch_resource_id;
-            dlsch0_harq->harq_ack.slot_for_feedback_ack = dlsch_config_pdu->pdsch_to_harq_feedback_time_ind;
+            dlsch0_harq->harq_ack.slot_for_feedback_ack = (slot+dlsch_config_pdu->pdsch_to_harq_feedback_time_ind)%frame_parms.slots_per_frame;
             dlsch0_harq->Nl=1;
             dlsch0_harq->mcs_table=0;
-            dlsch0_harq->status = ACTIVE;
+            dlsch0_harq->harq_ack.rx_status = downlink_harq_process(dlsch0_harq, dlsch0->current_harq_pid, dlsch_config_pdu->ndi, dlsch0->rnti_type);
+            dlsch0_harq->harq_ack.vDAI_DL = dlsch_config_pdu->dai;
             LOG_D(MAC, ">>>> \tdlsch0->g_pucch = %d\tdlsch0_harq.mcs = %d\n", dlsch0->g_pucch, dlsch0_harq->mcs);
           }
         }
@@ -215,6 +223,8 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
 }
 
 
+
+
 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;
diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
index 8bcd5cbe263b70ff09a945f10a8f249812ac6efe..7de941cfc8227e6cb86e13696f285e855777f2b8 100644
--- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
+++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
@@ -44,6 +44,7 @@
 #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h"
 //#include "PHY/extern.h"
 #include "SCHED_NR_UE/defs.h"
+#include "SCHED_NR_UE/pucch_uci_ue_nr.h"
 #include "SCHED_NR/extern.h"
 #include "SCHED_NR_UE/phy_sch_processing_time.h"
 //#include <sched.h>
@@ -2226,6 +2227,8 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX,VCD_FUNCTION_IN);
 
+  memset(ue->common_vars.txdataF[0], 0, sizeof(int)*14*ue->frame_parms.ofdm_symbol_size);
+
   LOG_I(PHY,"****** start TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, slot_tx);
 
 #if UE_TIMING_TRACE
@@ -2246,6 +2249,15 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,
   } // UE_mode==PUSCH
 */
 
+   if (get_softmodem_params()->usim_test==0) {
+      LOG_D(PHY, "Sending PUCCH\n");
+      pucch_procedures_ue_nr(ue,
+                             gNB_id,
+                             proc,
+                             TRUE);
+   }
+
+    LOG_D(PHY, "Sending data \n");
     nr_ue_pusch_common_procedures(ue,
                                   harq_pid,
                                   slot_tx,
@@ -2253,7 +2265,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);
 
   /* RACH */
   if (get_softmodem_params()->do_ra==1) {
@@ -2762,9 +2774,9 @@ int nr_ue_pdcch_procedures(uint8_t gNB_id,
 				      nr_tti_rx,
 				      &dci_ind);
 
-//#ifdef NR_PDCCH_SCHED_DEBUG
+#ifdef NR_PDCCH_SCHED_DEBUG
   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
+#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);
@@ -3085,7 +3097,17 @@ void nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int eNB
 		    dlsch0->current_harq_pid);
       else { // This is to adjust the llr offset in the case of skipping over a dmrs symbol (i.e. in case of no PDSCH REs in DMRS)
 	if      (pdsch == RA_PDSCH) ue->pdsch_vars_ra[eNB_id]->llr_offset[m]=ue->pdsch_vars_ra[eNB_id]->llr_offset[m-1];
-	else if (pdsch == PDSCH)    ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->llr_offset[m]=ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->llr_offset[m-1];
+	else if (pdsch == PDSCH)    nr_rx_pdsch(ue,
+                                  pdsch,
+                                  eNB_id,
+                                  eNB_id_i,
+                                  proc->frame_rx,
+                                  nr_tti_rx,  // nr_tti_rx,
+                                  m,
+                                  first_symbol_flag,
+                                  dual_stream_UE,
+                                  i_mod,
+                                  dlsch0->current_harq_pid);
 	else AssertFatal(1==0,"not RA_PDSCH or PDSCH\n");
       }
       if (pdsch == PDSCH)  LOG_D(PHY,"Done processing symbol %d : llr_offset %d\n",m,ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->llr_offset[m]);
@@ -3262,16 +3284,15 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
        int *dlsch_errors,
        runmode_t mode) {
 
-  int harq_pid;
+  int harq_pid = dlsch0->current_harq_pid;
   int frame_rx = proc->frame_rx;
   int nr_tti_rx = proc->nr_tti_rx;
   int ret=0, ret1=0;
   NR_UE_PDSCH *pdsch_vars;
   uint8_t is_cw0_active = 0;
   uint8_t is_cw1_active = 0;
-  //nfapi_nr_config_request_t *cfg = &ue->nrUE_config;
-  //uint8_t dmrs_type = cfg->pdsch_config.dmrs_type.value;
-  uint8_t nb_re_dmrs = 12; //(dmrs_type==NFAPI_NR_DMRS_TYPE1)?6:4;
+  uint8_t dmrs_type = dlsch0->harq_processes[harq_pid]->dmrsConfigType;
+  uint8_t nb_re_dmrs = (dmrs_type==NFAPI_NR_DMRS_TYPE1)?6:4; // TODO: should changed my mac
   uint16_t length_dmrs = 1; //cfg->pdsch_config.dmrs_max_length.value;
   uint16_t nb_symb_sch = 9;
   nr_downlink_indication_t dl_indication;
@@ -3294,7 +3315,6 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
   if (dlsch0==NULL)
     AssertFatal(0,"dlsch0 should be defined at this level \n");
 
-  harq_pid = dlsch0->current_harq_pid;
   is_cw0_active = dlsch0->harq_processes[harq_pid]->status;
   nb_symb_sch = dlsch0->harq_processes[harq_pid]->nb_symbols;
   start_symbol = dlsch0->harq_processes[harq_pid]->start_symbol;
@@ -3354,13 +3374,13 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
     }
 
 
-      // start ldpc decode for CW 0
-      dlsch0->harq_processes[harq_pid]->G = nr_get_G(dlsch0->harq_processes[harq_pid]->nb_rb,
-						     nb_symb_sch,
-						     nb_re_dmrs,
-						     length_dmrs,
-						     dlsch0->harq_processes[harq_pid]->Qm,
-						     dlsch0->harq_processes[harq_pid]->Nl);
+    // start ldpc decode for CW 0
+    dlsch0->harq_processes[harq_pid]->G = nr_get_G(dlsch0->harq_processes[harq_pid]->nb_rb,
+                                                   nb_symb_sch,
+                                                   nb_re_dmrs,
+                                                   length_dmrs,
+                                                   dlsch0->harq_processes[harq_pid]->Qm,
+                                                   dlsch0->harq_processes[harq_pid]->Nl);
 #if UE_TIMING_TRACE
       start_meas(&ue->dlsch_unscrambling_stats);
 #endif
@@ -4012,6 +4032,7 @@ 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];
   fapi_nr_config_request_t *cfg = &ue->nrUE_config;
+
   uint8_t nb_symb_pdcch = pdcch_vars->nb_search_space > 0 ? pdcch_vars->pdcch_config[0].coreset.duration : 0;
   uint8_t dci_cnt = 0;
   NR_DL_FRAME_PARMS *fp = &ue->frame_parms;
diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c
index 1b4cbc2264919bec48ea5dcc63c04a1e156d9808..ccbe5021945d7cdd0fa7711b9effe5c69da73c7f 100644
--- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c
+++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c
@@ -37,7 +37,6 @@
 #include "PHY/defs_nr_UE.h"
 #include <openair1/SCHED/sched_common.h>
 #include <openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h>
-#include "LAYER2/NR_MAC_UE/mac_proto.h"
 
 #ifndef NO_RAT_NR
 
@@ -162,6 +161,8 @@ void nr_generate_pucch3_4(int32_t **txdataF,
 *
 *********************************************************************/
 
+static int bwp_id = 1;
+
 bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_t *proc, bool reset_harq)
 {
   uint8_t   sr_payload = 0;
@@ -186,12 +187,18 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
   int       pucch_resource_id = MAX_NB_OF_PUCCH_RESOURCES;
   int       pucch_resource_indicator = MAX_PUCCH_RESOURCE_INDICATOR;
   int       n_HARQ_ACK;
+
   uint16_t crnti=0x1234;
   int dmrs_scrambling_id=0,data_scrambling_id=0;
 
+
+  NR_UE_MAC_INST_t *mac = get_mac_inst(0);
+  NR_PUCCH_Resource_t *pucch_resource;
+  //NR_UE_MAC_INST_t *mac = get_mac_inst(0);
+
   /* update current context */
 
-  int subframe_number = (proc->nr_tti_rx)/(ue->frame_parms.ttis_per_subframe);
+  int subframe_number = (proc->nr_tti_rx)/(ue->frame_parms.slots_per_subframe);//ttis_per_subframe);
   nb_pucch_format_4_in_subframes[subframe_number] = 0; /* reset pucch format 4 counter at current rx position */
 
   int dl_harq_pid = ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->current_harq_pid;
@@ -214,11 +221,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,
-				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
+  			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;
@@ -250,10 +257,10 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
     }
     else {
       /* a resource set and a resource should be find according to payload size */
-      pucch_resource_set = find_pucch_resource_set( ue, gNB_id, N_UCI);
+      pucch_resource_set = find_pucch_resource_set( mac, gNB_id, N_UCI);
       if (pucch_resource_set != MAX_NB_OF_PUCCH_RESOURCE_SETS) {
         pucch_resource_indicator = 0;
-        pucch_resource_id = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_ResourceSet[pucch_resource_set]->pucch_resource_id[pucch_resource_indicator];  /* get the first resource of the set */
+        pucch_resource_id = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[pucch_resource_set]->resourceList.list.array[pucch_resource_indicator][0]; /* get the first resource of the set */
       }
       else {
         LOG_W(PHY,"PUCCH no resource set found for CSI at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
@@ -299,7 +306,7 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
 
   NR_UE_HARQ_STATUS_t *harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][0]->harq_processes[dl_harq_pid]->harq_ack;
 
-  if (select_pucch_resource(ue, gNB_id, N_UCI, pucch_resource_indicator, &initial_pucch_id, &pucch_resource_set,
+  if (select_pucch_resource(ue, mac, gNB_id, N_UCI, pucch_resource_indicator, &initial_pucch_id, &pucch_resource_set,
                             &pucch_resource_id, harq_status) == TRUE) {
     /* use of initial pucch configuration provided by system information 1 */
     /***********************************************************************/
@@ -340,33 +347,43 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
     /**********************************************/
     else if ((pucch_resource_set != MAX_NB_OF_PUCCH_RESOURCE_SETS) && (pucch_resource_id != MAX_NB_OF_PUCCH_RESOURCES)) {
       /* check that current configuration is supported */
-      if ((ue->cell_group_config.physicalCellGroupConfig.harq_ACK_SpatialBundlingPUCCH != FALSE)
-         || (ue->cell_group_config.physicalCellGroupConfig.pdsch_HARQ_ACK_Codebook != dynamic)) {
+      if ((mac->scg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH != NULL)
+         || (mac->scg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook != 1)) {
         LOG_E(PHY,"PUCCH Unsupported cell group configuration : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
         return(FALSE);
       }
-      else if (ue->PDSCH_ServingCellConfig.codeBlockGroupTransmission != NULL) {
+      else if (mac->scg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) {
         LOG_E(PHY,"PUCCH Unsupported code block group for serving cell config : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
         return(FALSE);
       }
-      format = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[pucch_resource_id]->format_parameters.format;
-      nb_symbols_total = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[pucch_resource_id]->format_parameters.nrofSymbols;
-      starting_symbol_index = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[pucch_resource_id]->format_parameters.startingSymbolIndex;
-      starting_prb = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[pucch_resource_id]->startingPRB;
+      pucch_resource = select_resource_by_id(pucch_resource_id, mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup);
+      format = pucch_resource->format.present;
+      nb_symbols_total = get_nb_symbols_pucch(pucch_resource, format);
+      starting_symbol_index = get_starting_symb_idx(pucch_resource, format);
+      starting_prb = pucch_resource->startingPRB;
       second_hop = starting_prb;
-      time_domain_occ = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[pucch_resource_id]->format_parameters.timeDomainOCC; /* format 1 only */
-      occ_length = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[pucch_resource_id]->format_parameters.occ_length; /* format 4 only */
-      occ_Index = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[pucch_resource_id]->format_parameters.occ_Index;   /* format 4 only */
+      if (format==pucch_format1_nr)
+        time_domain_occ = pucch_resource->format.choice.format1->timeDomainOCC;
+      if (format==pucch_format4_nr) {
+        occ_length = pucch_resource->format.choice.format4->occ_Length;
+        occ_Index  = pucch_resource->format.choice.format4->occ_Index;
+      }
 
-      if ((format == pucch_format0_nr) ||  (format == pucch_format1_nr)) {
-        m_0 = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[pucch_resource_id]->format_parameters.initialCyclicShift;
+      m_0 = get_ics_pucch(pucch_resource, format);
+      AssertFatal(m_0 >= 0, "Invalid m_0\n");
+      if (format == pucch_format3_nr) {
+        if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format3->choice.setup->additionalDMRS[0] == 1) {
+          index_additional_dmrs = I_PUCCH_ADDITIONAL_DMRS;
+        }
       }
-      else if ((format == pucch_format3_nr) ||  (format == pucch_format4_nr)) {
-        if (ue->pucch_config_dedicated_nr[gNB_id].formatConfig[format-1]->additionalDMRS == enable_feature) {
+      else if (format == pucch_format4_nr) {
+        if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format4->choice.setup->additionalDMRS[0] == 1) {
           index_additional_dmrs = I_PUCCH_ADDITIONAL_DMRS;
         }
+      }
 
-        if (ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[pucch_resource_id]->intraSlotFrequencyHopping == feature_enabled) {
+      if ((format == pucch_format3_nr) || (format == pucch_format4_nr)) {
+        if (pucch_resource->intraSlotFrequencyHopping[0] == 1) {
           index_hopping = I_PUCCH_HOPING;
         }
       }
@@ -385,6 +402,7 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
   int O_CRC = 0;
 
   nb_symbols = nb_symbols_total; /* by default, it can be reduced due to symbols reserved for dmrs */
+  pucch_resource = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceToAddModList->list.array[pucch_resource_id];
 
   switch(format) {
     case pucch_format0_nr:
@@ -401,14 +419,14 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
     }
     case pucch_format2_nr:
     {
-      nb_of_prbs = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[pucch_resource_id]->format_parameters.nrofPRBs;
+      nb_of_prbs = pucch_resource->format.choice.format2->nrofPRBs;
       N_sc_ctrl_RB = N_SC_RB - 4;
       break;
     }
     case pucch_format3_nr:
     {
-      nb_of_prbs = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[pucch_resource_id]->format_parameters.nrofPRBs;
-      if (ue->pucch_config_dedicated_nr[gNB_id].formatConfig[format-1]->pi2PBSK == feature_enabled) {
+      nb_of_prbs = pucch_resource->format.choice.format3->nrofPRBs;
+      if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format3->choice.setup->pi2BPSK[0] == 1) {
         Q_m = BITS_PER_SYMBOL_BPSK; /* set bpsk modulation type with 1 bit per modulation symbol */
       }
       N_sc_ctrl_RB = N_SC_RB;
@@ -417,12 +435,12 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
     }
     case pucch_format4_nr:
     {
-      if (ue->pucch_config_dedicated_nr[gNB_id].formatConfig[format-1]->pi2PBSK == feature_enabled) {
+      if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format4->choice.setup->pi2BPSK[0] == 1) {
         Q_m = BITS_PER_SYMBOL_BPSK; /* set bpsk modulation type with 1 bit per modulation symbol */
       }
       nb_symbols = nb_symbols_excluding_dmrs[nb_symbols_total-4][index_additional_dmrs][index_hopping];
       nb_of_prbs = 1;
-      subframe_number = nr_tti_tx/(ue->frame_parms.ttis_per_subframe);
+      subframe_number = nr_tti_tx/(ue->frame_parms.slots_per_subframe);//ttis_per_subframe);
       nb_pucch_format_4_in_subframes[subframe_number]++; /* increment number of transmit pucch 4 in current subframe */
       NR_TST_PHY_PRINTF("PUCCH Number of pucch format 4 in subframe %d is %d \n", subframe_number, nb_pucch_format_4_in_subframes[subframe_number]);
       N_sc_ctrl_RB = N_SC_RB/(nb_pucch_format_4_in_subframes[subframe_number]);
@@ -434,10 +452,10 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
   /* drop CSI report if simultaneous HARQ-ACK/SR and periodic/semi-periodic CSI cannot be transmitted at the same time */
   if (format !=  pucch_format0_nr) {
 
-    if (ue->pucch_config_dedicated_nr[gNB_id].formatConfig[format-1] != NULL) {
-      max_code_rate = code_rate_r_time_100[ue->pucch_config_dedicated_nr[gNB_id].formatConfig[format-1]->maxCodeRate]; /* it is code rate * 10 */
+    if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format1 != NULL) {
+      max_code_rate = code_rate_r_time_100[mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format1->choice.setup->maxCodeRate[0]]; /* it is code rate * 10 */
 
-      if ((O_ACK != 0) && (ue->pucch_config_dedicated_nr[gNB_id].formatConfig[format-1]->simultaneousHARQ_ACK_CSI == disable_feature)) {
+      if ((O_ACK != 0) && (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format1->choice.setup->simultaneousHARQ_ACK_CSI[0] == 0)) {
         N_UCI = N_UCI - O_CSI;
         O_CSI = cqi_status = ri_status = 0;
         csi_payload = 0; /* csi should be dropped in this case */
@@ -563,7 +581,8 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
     {
       nr_generate_pucch0(ue,ue->common_vars.txdataF,
                          &ue->frame_parms,
-                         &ue->pucch_config_dedicated[gNB_id],
+                         mac->ULbwp[bwp_id-1]->bwp_Common->pucch_ConfigCommon->choice.setup->pucch_GroupHopping,
+                         mac->ULbwp[bwp_id-1]->bwp_Common->pucch_ConfigCommon->choice.setup->hoppingId[0],
                          tx_amp,
                          nr_tti_tx,
                          (uint8_t)m_0,
@@ -679,8 +698,11 @@ uint8_t get_downlink_ack(PHY_VARS_NR_UE *ue, uint8_t gNB_id,  UE_nr_rxtx_proc_t
   int U_DAI_c = 0;
   int N_m_c_rx = 0;
   int V_DAI_m_DL = 0;
+  NR_UE_MAC_INST_t *mac = get_mac_inst(0);
+
+  if (mac->DLbwp[0] == NULL) return 0;
 
-  if (ue->PDSCH_Config.maxNrofCodeWordsScheduledByDCI == nb_code_n2) {
+  if (mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI[0] == 2) {
     two_transport_blocks = TRUE;
     number_of_code_word = 2;
   }
@@ -698,46 +720,49 @@ uint8_t get_downlink_ack(PHY_VARS_NR_UE *ue, uint8_t gNB_id,  UE_nr_rxtx_proc_t
 
     for (int dl_harq_pid = 0; dl_harq_pid < number_pid_dl; dl_harq_pid++) {
 
-      harq_status = &ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][code_word]->harq_processes[dl_harq_pid]->harq_ack;
+      for (int thread_idx = 0; thread_idx < RX_NB_TH; thread_idx++) {
 
-      /* check if current tx slot should transmit downlink acknowlegment */
-      if (harq_status->slot_for_feedback_ack == proc->nr_tti_tx) {
+        harq_status = &ue->dlsch[thread_idx][gNB_id][code_word]->harq_processes[dl_harq_pid]->harq_ack;
 
-        if (harq_status->ack == DL_ACKNACK_NO_SET) {
-          LOG_E(PHY,"PUCCH Downlink acknowledgment has not been set : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
-          return (0);
-        }
-        else if (harq_status->vDAI_DL == DL_DAI_NO_SET) {
-          LOG_E(PHY,"PUCCH Downlink DAI has not been set : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
-          return (0);
-        }
-        else if (harq_status->vDAI_DL > NR_DL_MAX_DAI) {
-          LOG_E(PHY,"PUCCH Downlink DAI has an invalid value : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
-          return (0);
-        }
-        else if (harq_status->send_harq_status == 0) {
-          LOG_E(PHY,"PUCCH Downlink ack can not be transmitted : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
-          return(0);
-        }
-        else {
+        /* check if current tx slot should transmit downlink acknowlegment */
+        if (harq_status->slot_for_feedback_ack == proc->nr_tti_tx) {
 
-          dai_current = harq_status->vDAI_DL;
-
-          if (dai_current == 0) {
-            LOG_E(PHY,"PUCCH Downlink dai is invalid : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
+          if (harq_status->ack == DL_ACKNACK_NO_SET) {
+            LOG_E(PHY,"PUCCH Downlink acknowledgment has not been set : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
+            return (0);
+          }
+          else if (harq_status->vDAI_DL == DL_DAI_NO_SET) {
+            LOG_E(PHY,"PUCCH Downlink DAI has not been set : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
+            return (0);
+          }
+          else if (harq_status->vDAI_DL > NR_DL_MAX_DAI) {
+            LOG_E(PHY,"PUCCH Downlink DAI has an invalid value : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
+            return (0);
+          }
+          else if (harq_status->send_harq_status == 0) {
+            LOG_E(PHY,"PUCCH Downlink ack can not be transmitted : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
             return(0);
-          } else if (dai_current > dai_max) {
-            dai_max = dai_current;
           }
+          else {
 
-          number_harq_feedback++;
-          ack_data[code_word][dai_current - 1] = harq_status->ack;
-          dai[code_word][dai_current - 1] = dai_current;
+            dai_current = harq_status->vDAI_DL+1; // DCI DAI to counter DAI conversion
+
+            if (dai_current == 0) {
+              LOG_E(PHY,"PUCCH Downlink dai is invalid : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
+              return(0);
+            } else if (dai_current > dai_max) {
+              dai_max = dai_current;
+            }
+
+            number_harq_feedback++;
+            ack_data[code_word][dai_current - 1] = harq_status->ack;
+            dai[code_word][dai_current - 1] = dai_current;
+          }
+          if (do_reset == TRUE) {
+            init_downlink_harq_status(ue->dlsch[thread_idx][gNB_id][code_word]->harq_processes[dl_harq_pid]);
+          }
         }
       }
-      if (do_reset == TRUE) {
-        init_downlink_harq_status(ue->dlsch[ue->current_thread_id[proc->nr_tti_rx]][gNB_id][code_word]->harq_processes[dl_harq_pid]);
-      }
     }
   }
 
@@ -756,8 +781,8 @@ uint8_t get_downlink_ack(PHY_VARS_NR_UE *ue, uint8_t gNB_id,  UE_nr_rxtx_proc_t
    U_DAI_c = number_harq_feedback/number_of_code_word;
    N_m_c_rx = number_harq_feedback;
    int N_SPS_c = 0; /* FFS TODO_NR multicells and SPS are not supported at the moment */
-   if (ue->cell_group_config.physicalCellGroupConfig.harq_ACK_SpatialBundlingPUCCH == FALSE) {
-     int N_TB_max_DL = ue->PDSCH_Config.maxNrofCodeWordsScheduledByDCI;
+   if (mac->scg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH == NULL) {
+     int N_TB_max_DL = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI[0];
      *n_HARQ_ACK = (((V_DAI_m_DL - U_DAI_c)%4) * N_TB_max_DL) + N_m_c_rx + N_SPS_c;
      NR_TST_PHY_PRINTF("PUCCH power n(%d) = ( V(%d) - U(%d) )mod4 * N_TB(%d) + N(%d) \n", *n_HARQ_ACK, V_DAI_m_DL, U_DAI_c, N_TB_max_DL, N_m_c_rx);
    }
@@ -853,7 +878,7 @@ uint8_t get_downlink_ack(PHY_VARS_NR_UE *ue, uint8_t gNB_id,  UE_nr_rxtx_proc_t
 *
 *********************************************************************/
 
-boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size, int pucch_resource_indicator, 
+boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, NR_UE_MAC_INST_t *mac, uint8_t gNB_id, int uci_size, int pucch_resource_indicator, 
                                 int *initial_pucch_id, int *resource_set_id, int *resource_id, NR_UE_HARQ_STATUS_t *harq_status)
 {
   boolean_t resource_set_found = FALSE;
@@ -861,18 +886,19 @@ boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size
   int current_resource_id = MAX_NB_OF_PUCCH_RESOURCES;
   pucch_format_nr_t format_pucch;
   int ready_pucch_resource_id = FALSE; /* in the case that it is already given */
+  NR_PUCCH_Resource_t *pucch_resource;
 
   /* ini values to unset */
   *initial_pucch_id = NB_INITIAL_PUCCH_RESOURCE;
   //*resource_set_id = MAX_NB_OF_PUCCH_RESOURCE_SETS;
   //*resource_id = MAX_NB_OF_PUCCH_RESOURCES;
 
-  if (ue->pucch_config_dedicated_nr[gNB_id].PUCCH_ResourceSet[0] == NULL) {
+  if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[0] == NULL) {
 
     /* No resource set has been already configured so pucch_configCommon from Sib1 should be used in this case */
 
     if (ue->UE_mode[gNB_id] != PUSCH) {
-      *initial_pucch_id = ue->pucch_config_common_nr[gNB_id].pucch_ResourceCommon;
+      *initial_pucch_id = mac->ULbwp[bwp_id-1]->bwp_Common->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon[0];
       if (*initial_pucch_id >= NB_INITIAL_PUCCH_RESOURCE) {
         LOG_E(PHY,"PUCCH Invalid initial resource index : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
         *initial_pucch_id = NB_INITIAL_PUCCH_RESOURCE;
@@ -897,7 +923,7 @@ boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size
     }
     nb_symbols_for_tx = initial_pucch_resource[*initial_pucch_id].nrofSymbols;
     format_pucch = initial_pucch_resource[*initial_pucch_id].format;
-    if (check_pucch_format(ue, gNB_id, format_pucch, nb_symbols_for_tx, uci_size) == TRUE) {
+    if (check_pucch_format(mac, gNB_id, format_pucch, nb_symbols_for_tx, uci_size) == TRUE) {
       return (TRUE);
     }
     else {
@@ -917,7 +943,7 @@ boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size
         -- This field can take integer values that are multiples of 4. Corresponds to L1 parameter 'N_2' or 'N_3' (see 38.213, section 9.2)
       */
       /* look for the first resource set which supports uci_size number of bits for payload */
-      pucch_resource_set_id = find_pucch_resource_set( ue, gNB_id, uci_size);
+      pucch_resource_set_id = find_pucch_resource_set(mac, gNB_id, uci_size);
       if (pucch_resource_set_id != MAX_NB_OF_PUCCH_RESOURCE_SETS) {
         resource_set_found = TRUE;
       }
@@ -932,13 +958,13 @@ boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size
     if (resource_set_found == TRUE) {
       if (pucch_resource_indicator < MAX_PUCCH_RESOURCE_INDICATOR) {
         /* check if resource indexing by pucch_resource_indicator of this set is compatible */
-        if ((ready_pucch_resource_id == TRUE) || (ue->pucch_config_dedicated_nr[gNB_id].PUCCH_ResourceSet[pucch_resource_set_id]->pucch_resource_id[pucch_resource_indicator] != MAX_NB_OF_PUCCH_RESOURCES)) {
+        if ((ready_pucch_resource_id == TRUE) || (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[pucch_resource_set_id]->resourceList.list.array[pucch_resource_indicator][0] != MAX_NB_OF_PUCCH_RESOURCES)) {
 
           if (ready_pucch_resource_id == TRUE) {
             current_resource_id = *resource_id;
           }
           else {
-            int R_PUCCH = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_ResourceSet[pucch_resource_set_id]->first_resources_set_R_PUCCH;
+            int R_PUCCH = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[pucch_resource_set_id]->resourceList.list.count;
             /* is it the first resource and its size exceeds 8 */
             if ((pucch_resource_set_id == 0)
              && (R_PUCCH > MAX_NB_OF_PUCCH_RESOURCES_PER_SET_NOT_0)) {
@@ -960,15 +986,22 @@ boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size
               current_resource_id = r_PUCCH;
             }
             else {
-              current_resource_id = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_ResourceSet[pucch_resource_set_id]->pucch_resource_id[pucch_resource_indicator];
+              current_resource_id = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[pucch_resource_set_id]->resourceList.list.array[pucch_resource_indicator][0];
             }
           }
-          if (ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[current_resource_id] != NULL) {
 
-            nb_symbols_for_tx = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[current_resource_id]->format_parameters.nrofSymbols;
-            format_pucch = ue->pucch_config_dedicated_nr[gNB_id].PUCCH_Resource[current_resource_id]->format_parameters.format;
+          /*uint8_t pucch_resource_count = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceToAddModList.list.count;
+          for (uint8_t i=0; i<pucch_resource_count; i++) {
+            if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceToAddModList.list.array[i]->pucch_ResourceId == current_resource_id)
+              pucch_resource = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceToAddModList.list.array[i];
+          }*/
+
+          pucch_resource = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceToAddModList->list.array[current_resource_id];
+          if (pucch_resource != NULL) {
+            format_pucch = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceToAddModList->list.array[current_resource_id]->format.present;
+            nb_symbols_for_tx = get_nb_symbols_pucch(pucch_resource, format_pucch);
 
-            if (check_pucch_format(ue, gNB_id, format_pucch, nb_symbols_for_tx, uci_size) == TRUE) {
+            if (check_pucch_format(mac, gNB_id, format_pucch, nb_symbols_for_tx, uci_size) == TRUE) {
               *resource_set_id = pucch_resource_set_id;
               *resource_id = current_resource_id;
               return (TRUE);
@@ -1014,9 +1047,10 @@ boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size
 *
 *********************************************************************/
 
-int find_pucch_resource_set(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size)
+int find_pucch_resource_set(NR_UE_MAC_INST_t *mac, uint8_t gNB_id, int uci_size)
 {
   int pucch_resource_set_id = 0;
+  long *pucch_max_pl_bits = NULL;
 
   /* from TS 38.331 field maxPayloadMinus1
     -- Maximum number of payload bits minus 1 that the UE may transmit using this PUCCH resource set. In a PUCCH occurrence, the UE
@@ -1027,8 +1061,9 @@ int find_pucch_resource_set(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size)
   */
   /* look for the first resource set which supports uci_size number of bits for payload */
   while (pucch_resource_set_id < MAX_NB_OF_PUCCH_RESOURCE_SETS) {
-    if (ue->pucch_config_dedicated_nr[gNB_id].PUCCH_ResourceSet[pucch_resource_set_id] != NULL) {
-      if (uci_size <= ue->pucch_config_dedicated_nr[gNB_id].PUCCH_ResourceSet[pucch_resource_set_id]->maxPayloadMinus1 + 1) {
+    if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[pucch_resource_set_id] != NULL) {
+      pucch_max_pl_bits = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[pucch_resource_set_id]->maxPayloadMinus1;
+      if (uci_size <= (((pucch_max_pl_bits != NULL) ? *pucch_max_pl_bits : 1706) + 1)) {
         NR_TST_PHY_PRINTF("PUCCH found resource set %d \n",  pucch_resource_set_id);
         return (pucch_resource_set_id);
         break;
@@ -1057,18 +1092,40 @@ int find_pucch_resource_set(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size)
 *
 *********************************************************************/
 
-boolean_t check_pucch_format(PHY_VARS_NR_UE *ue, uint8_t gNB_id, pucch_format_nr_t format_pucch, int nb_symbols_for_tx, int uci_size)
+boolean_t check_pucch_format(NR_UE_MAC_INST_t *mac, uint8_t gNB_id, pucch_format_nr_t format_pucch, int nb_symbols_for_tx, int uci_size)
 {
   pucch_format_nr_t selected_pucch_format;
   pucch_format_nr_t selected_pucch_format_second;
+  NR_SetupRelease_PUCCH_FormatConfig_t *identified_format = NULL;
 
-  if (format_pucch != pucch_format0_nr) {
-    if (ue->pucch_config_dedicated_nr[gNB_id].formatConfig[format_pucch-1] != NULL) {
-      if (ue->pucch_config_dedicated_nr[gNB_id].formatConfig[format_pucch-1]->nrofSlots != 1) {
-        LOG_E(PHY,"PUCCH not implemented multislots transmission : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
-        return (FALSE);
-      }
-    }
+  switch (format_pucch) {
+    case pucch_format1_nr:
+    if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format1 != NULL)
+      identified_format = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format1;
+    break;
+
+    case pucch_format2_nr:
+    if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format2 != NULL)
+      identified_format = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format2;
+    break;
+
+    case pucch_format3_nr:
+    if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format3 != NULL)
+      identified_format = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format3;
+    break;
+
+    case pucch_format4_nr:
+    if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format4 != NULL)
+      identified_format = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format4;
+    break;
+
+    default:
+    break;
+  }
+
+  if ((identified_format != NULL) && (identified_format->choice.setup->nrofSlots[0] != 1)) {
+    LOG_E(PHY,"PUCCH not implemented multislots transmission : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
+    return (FALSE);
   }
 
   if (nb_symbols_for_tx <= 2) {
@@ -1160,7 +1217,7 @@ int trigger_periodic_scheduling_request(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_n
     return (1); /* period is slot */
   }
 
-  int16_t N_slot_frame = NR_NUMBER_OF_SUBFRAMES_PER_FRAME * ue->frame_parms.ttis_per_subframe;
+  int16_t N_slot_frame = NR_NUMBER_OF_SUBFRAMES_PER_FRAME * ue->frame_parms.slots_per_subframe;//ttis_per_subframe;
   if (((proc->frame_tx * N_slot_frame) + proc->nr_tti_tx - SR_offset)%SR_periodicity == 0) {
     return (1);
   }
@@ -1219,4 +1276,74 @@ void set_csi_nr(int csi_status, uint32_t csi_payload)
   }
 }
 
+uint8_t get_nb_symbols_pucch(NR_PUCCH_Resource_t *pucch_resource, pucch_format_nr_t format_type)
+{
+  switch (format_type) {
+    case pucch_format0_nr:
+      return pucch_resource->format.choice.format0->nrofSymbols;
+
+    case pucch_format1_nr:
+      return pucch_resource->format.choice.format1->nrofSymbols;
+
+    case pucch_format2_nr:
+      return pucch_resource->format.choice.format2->nrofSymbols;
+
+    case pucch_format3_nr:
+      return pucch_resource->format.choice.format3->nrofSymbols;
+
+    case pucch_format4_nr:
+      return pucch_resource->format.choice.format4->nrofSymbols;
+  }
+  return 0;
+}
+
+uint16_t get_starting_symb_idx(NR_PUCCH_Resource_t *pucch_resource, pucch_format_nr_t format_type)
+{
+  switch (format_type) {
+    case pucch_format0_nr:
+      return pucch_resource->format.choice.format0->startingSymbolIndex;
+
+    case pucch_format1_nr:
+      return pucch_resource->format.choice.format1->startingSymbolIndex;
+
+    case pucch_format2_nr:
+      return pucch_resource->format.choice.format2->startingSymbolIndex;
+
+    case pucch_format3_nr:
+      return pucch_resource->format.choice.format3->startingSymbolIndex;
+
+    case pucch_format4_nr:
+      return pucch_resource->format.choice.format4->startingSymbolIndex;
+  }
+  return 0;
+}
+
+int get_ics_pucch(NR_PUCCH_Resource_t *pucch_resource, pucch_format_nr_t format_type)
+{
+  switch (format_type) {
+    case pucch_format0_nr:
+      return pucch_resource->format.choice.format0->initialCyclicShift;
+
+    case pucch_format1_nr:
+      return pucch_resource->format.choice.format1->initialCyclicShift;
+
+    default:
+      return -1;
+  }
+  return -1;
+}
+
+NR_PUCCH_Resource_t *select_resource_by_id(int resource_id, NR_PUCCH_Config_t *pucch_config)
+{
+  int n_list = pucch_config->resourceToAddModList->list.count; 
+  NR_PUCCH_Resource_t *pucchres;
+  AssertFatal(n_list>0,"PUCCH resourceToAddModList is empty\n");
+
+  for (int i=0; i<n_list; i++) {
+    pucchres = pucch_config->resourceToAddModList->list.array[i];
+    if (pucchres->pucch_ResourceId == resource_id)
+      return pucchres;
+  }
+  return NULL;
+}
 
diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.h b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.h
index 85cd969e2638d0478ce87077a36bde1a6bfec71c..089fae9f55cbb328617d4cef498477656713d433 100644
--- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.h
+++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.h
@@ -41,6 +41,9 @@
 /************** INCLUDE *******************************************/
 
 #include "PHY/defs_nr_UE.h"
+#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
+#include "openair2/LAYER2/NR_MAC_UE/mac_defs.h"
+#include "RRC/NR_UE/rrc_proto.h"
 
 #ifdef DEFINE_VARIABLES_PUCCH_UE_NR_H
 #define EXTERN
@@ -187,7 +190,7 @@ uint8_t get_downlink_ack(PHY_VARS_NR_UE *ue, uint8_t gNB_id,  UE_nr_rxtx_proc_t
     @param resource_id       pucch resource id if any
     @returns TRUE  a pucch resource has been found FALSE no valid pucch resource */
 
-boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size, int pucch_resource_indicator, 
+boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, NR_UE_MAC_INST_t *mac, uint8_t gNB_id, int uci_size, int pucch_resource_indicator, 
                                 int *initial_pucch_id, int *resource_set_id, int *resource_id, NR_UE_HARQ_STATUS_t *harq_status);
 
 /** \brief This function select a pucch resource set
@@ -196,7 +199,7 @@ boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size
     @param uci size number of uci bits
     @returns number of the pucch resource set */
 
-int find_pucch_resource_set(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size);
+int find_pucch_resource_set(NR_UE_MAC_INST_t *mac, uint8_t gNB_id, int uci_size);
 
 /** \brief This function check pucch format
     @param ue context
@@ -206,7 +209,7 @@ int find_pucch_resource_set(PHY_VARS_NR_UE *ue, uint8_t gNB_id, int uci_size);
     @param uci size number of uci bits
     @returns TRUE pucch format matched uci size and constraints, FALSE invalid pucch format */
 
-boolean_t check_pucch_format(PHY_VARS_NR_UE *ue, uint8_t gNB_id, pucch_format_nr_t format_pucch, int nb_symbols_for_tx, 
+boolean_t check_pucch_format(NR_UE_MAC_INST_t *mac, uint8_t gNB_id, pucch_format_nr_t format_pucch, int nb_symbols_for_tx, 
                              int uci_size);
 
 /** \brief This function selects a pucch resource
@@ -232,4 +235,11 @@ int get_csi_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint32_t *csi_payload);
 
 void set_csi_nr(int csi_status, uint32_t csi_payload);
 
+uint8_t get_nb_symbols_pucch(NR_PUCCH_Resource_t *pucch_resource, pucch_format_nr_t format_type);
+
+uint16_t get_starting_symb_idx(NR_PUCCH_Resource_t *pucch_resource, pucch_format_nr_t format_type);
+
+int get_ics_pucch(NR_PUCCH_Resource_t *pucch_resource, pucch_format_nr_t format_type);
+
+NR_PUCCH_Resource_t *select_resource_by_id(int resource_id, NR_PUCCH_Config_t *pucch_config);
 #endif /* PUCCH_UCI_UE_NR_H */
diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c
index 25813191be155fb7f5eb74936bc52e66b34591b7..9374050e58f99fd2af2e063d333592a072414166 100644
--- a/openair1/SIMULATION/NR_PHY/dlschsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlschsim.c
@@ -66,6 +66,8 @@ PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } };
 uint16_t n_rnti = 0x1234;
 openair0_config_t openair0_cfg[MAX_CARDS];
 
+void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {}
+
 int main(int argc, char **argv)
 {
 	char c;
@@ -428,7 +430,7 @@ int main(int argc, char **argv)
 	uint8_t is_crnti = 0, llr8_flag = 0;
 	unsigned int TBS = 8424;
 	unsigned int available_bits;
-	uint8_t nb_re_dmrs = 12;  // No data in dmrs symbol
+	uint8_t nb_re_dmrs = 6;  // No data in dmrs symbol
 	uint16_t length_dmrs = 1;
 	unsigned char mod_order;
         uint16_t rate;
@@ -455,6 +457,7 @@ int main(int argc, char **argv)
         rel15->dmrsConfigType = NFAPI_NR_DMRS_TYPE1;
 	rel15->dlDmrsSymbPos = 4;
 	rel15->mcsIndex[0] = Imcs;
+        rel15->numDmrsCdmGrpsNoData = 1;
 	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);
diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c
index 29d3a67771a950649df7b6974a83094a6deec7d2..137c358d7f610aed1239022b179eb8acf402cf99 100644
--- a/openair1/SIMULATION/NR_PHY/dlsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlsim.c
@@ -137,6 +137,12 @@ int main(int argc, char **argv)
   int i,aa;//,l;
   double sigma2, sigma2_dB=10, SNR, snr0=-2.0, snr1=2.0;
   uint8_t snr1set=0;
+  float roundStats[50];
+  float effRate;
+  //float psnr;
+  float eff_tp_check = 0.7;
+  uint8_t snrRun;
+  uint32_t TBS;
   int **txdata;
   double **s_re,**s_im,**r_re,**r_im;
   //double iqim = 0.0;
@@ -152,6 +158,8 @@ 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;
+  uint8_t round;
+  uint8_t num_rounds = 4;
 
   channel_desc_t *gNB2UE;
   //uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0;
@@ -203,7 +211,7 @@ int main(int argc, char **argv)
 
   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) {
+  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:w")) != -1) {
     switch (c) {
     case 'f':
       scg_fd = fopen(optarg,"r");
@@ -382,6 +390,14 @@ int main(int argc, char **argv)
       mu = atoi(optarg);
       break;
 
+    case 't':
+      eff_tp_check = (float)atoi(optarg)/100;
+      break;
+
+    case 'w':
+      output_fd = fopen("txdata.dat", "w+");
+      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",
@@ -411,7 +427,9 @@ int main(int argc, char **argv)
       printf("-c Start symbol for PDSCH (fixed for now)\n");
       printf("-j Number of symbols for PDSCH (fixed for now)\n");
       printf("-e MSC index\n");
+      printf("-t Acceptable effective throughput (in percentage)\n");
       printf("-P Print DLSCH performances\n");
+      printf("-w Write txdata to binary file (one frame)\n");
       exit (-1);
       break;
     }
@@ -656,7 +674,7 @@ int main(int argc, char **argv)
   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_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib,secondaryCellGroup);
 
 
   nr_dcireq_t dcireq;
@@ -677,6 +695,9 @@ int main(int argc, char **argv)
   
 
   nr_ue_phy_config_request(&UE_mac->phy_config);
+  NR_UE_list_t *UE_list = &RC.nrmac[0]->UE_list;
+  //NR_COMMON_channels_t *cc = RC.nrmac[0]->common_channels;
+  snrRun = 0;
 
   for (SNR = snr0; SNR < snr1; SNR += .2) {
 
@@ -694,6 +715,7 @@ int main(int argc, char **argv)
     reset_meas(&gNB->toutput);  
 
     n_errors = 0;
+    effRate = 0;
     //n_errors2 = 0;
     //n_alamouti = 0;
     errors_scrambling=0;
@@ -704,94 +726,6 @@ int main(int argc, char **argv)
       //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,&pucch_sched,&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 * ((double)UE->frame_parms.ofdm_symbol_size/(12*rel15.rbSize))) - SNR;
-      sigma2    = pow(10, sigma2_dB/10);
-      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)));
-	}
-      }
-      
       UE->rx_offset=0;
       UE_proc.frame_rx = frame;
       UE_proc.nr_tti_rx= slot;
@@ -799,43 +733,147 @@ int main(int argc, char **argv)
       
       dcireq.frame     = frame;
       dcireq.slot      = slot;
+
+      NR_UE_DLSCH_t *dlsch0 = UE->dlsch[UE->current_thread_id[UE_proc.nr_tti_rx]][0][0];
+
+      int harq_pid = slot;
+      NR_DL_UE_HARQ_t *UE_harq_process = dlsch0->harq_processes[harq_pid];
+
+      NR_gNB_DLSCH_t *gNB_dlsch = gNB->dlsch[0][0];
+      nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &gNB_dlsch->harq_processes[slot]->pdsch_pdu.pdsch_pdu_rel15;
       
-      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);
+      UE_harq_process->harq_ack.ack = 0;
+      round = 0;
+      UE_harq_process->round = round;
+      UE_harq_process->first_tx = 1;
+        
+      while ((round<num_rounds) && (UE_harq_process->harq_ack.ack==0)) {
+        memset(RC.nrmac[0]->cce_list[1][0],0,MAX_NUM_CCE*sizeof(int));
+        memset(RC.nrmac[0]->cce_list[1][1],0,MAX_NUM_CCE*sizeof(int));
+        clear_nr_nfapi_information(RC.nrmac[0], 0, frame, slot);
+
+        UE_list->UE_sched_ctrl[0].harq_processes[harq_pid].ndi = !(trial&1);
+
+        UE_list->UE_sched_ctrl[0].harq_processes[harq_pid].round = round;   
+        UE_list->UE_sched_ctrl[0].current_harq_pid = harq_pid;
+        gNB->dlsch[0][0]->harq_processes[harq_pid]->round = round;
       
-      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++;
+        if (css_flag == 0) nr_schedule_uss_dlsch_phytest(0,frame,slot,&pucch_sched,&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) {
+          printf("writing txdata to binary file\n");
+          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]);
+          }
+        }
+        
+        //AWGN
+        sigma2_dB = 10 * log10((double)txlev * ((double)UE->frame_parms.ofdm_symbol_size/(12*rel15->rbSize))) - SNR;
+        sigma2    = pow(10, sigma2_dB/10);
+        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)));
+          }
+        }
+        
+        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);
+        
+        //printf("dlsim round %d ends\n",round);
+        round++;
+      } // round
       
       //----------------------------------------------------------
       //---------------------- 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];
-      
+      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++;
+        
       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];
+      TBS                  = UE_harq_process->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;
+      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);
+      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++) {
 	
@@ -875,15 +913,18 @@ int main(int argc, char **argv)
 	if (n_trials == 1)
 	  printf("errors_bit = %u (trial %d)\n", errors_bit, trial);
       }
-      
+      roundStats[snrRun]+=((float)round); 
+      if (UE_harq_process->harq_ack.ack==1) effRate += ((float)TBS)/round;
     } // noise trials
 
+    roundStats[snrRun]/=((float)n_trials);
+    effRate /= n_trials;
     printf("*****************************************\n");
     printf("SNR %f, (false positive %f)\n", SNR,
            (float) n_errors / (float) n_trials);
     printf("*****************************************\n");
     printf("\n");
-    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("SNR %f : n_errors (negative CRC) = %d/%d, Avg round %.2f, Channel BER %e, Eff Rate %.4f bits/slot, Eff Throughput %.2f, TBS %d bits/slot\n", SNR, n_errors, n_trials,roundStats[snrRun],(double)errors_scrambling/available_bits/n_trials,effRate,effRate/TBS*100,TBS);
     printf("\n");
 
     if (n_trials == 1) {
@@ -896,7 +937,8 @@ int main(int argc, char **argv)
       break;
     }
 
-    if ((float)n_errors/(float)n_trials <= target_error_rate) {
+    //if ((float)n_errors/(float)n_trials <= target_error_rate) {
+    if (effRate >= (eff_tp_check*TBS)) {
       printf("PDSCH test OK\n");
       break;
     }
@@ -951,8 +993,18 @@ int main(int argc, char **argv)
       printStatIndent2(&UE->dlsch_tc_intl2_stats,"intl2+HardDecode+CRC");
       */
     }
+    snrRun++;
   } // NSR
 
+  /*if (n_trials>1) {
+    printf("HARQ stats:\nSNR\tRounds\n");
+    psnr = snr0;
+    for (uint8_t i=0; i<snrRun; i++) {
+      printf("%.1f\t%.2f\n",psnr,roundStats[i]);
+      psnr+=0.2;
+    }
+  }*/
+
   for (i = 0; i < 2; i++) {
     free(s_re[i]);
     free(s_im[i]);
diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c
index 8030bdf1e2771680ff8e10a58f281bb09031ffb5..2144652f8612ae3d5c34bcd578842ec8f93ba825 100644
--- a/openair1/SIMULATION/NR_PHY/pbchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pbchsim.c
@@ -62,6 +62,8 @@ uint16_t NB_UE_INST = 1;
 openair0_config_t openair0_cfg[MAX_CARDS];
 uint64_t get_softmodem_optmask(void) {return 0;}
 
+void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {}
+
 void nr_phy_config_request_sim_pbchsim(PHY_VARS_gNB *gNB,
                                int N_RB_DL,
                                int N_RB_UL,
diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c
index 5fddf3290d5c116a1e578e6cd47ea1b7ba42d251..2db5bc905c4b233406e21674bf40278ecacf16d9 100644
--- a/openair1/SIMULATION/NR_PHY/prachsim.c
+++ b/openair1/SIMULATION/NR_PHY/prachsim.c
@@ -83,20 +83,25 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, cons
 int main(int argc, char **argv){
 
   char c;
+
   double sigma2, sigma2_dB = 0, SNR, snr0 = -2.0, snr1 = 0.0, ue_speed0 = 0.0, ue_speed1 = 0.0;
   double **s_re, **s_im, **r_re, **r_im, iqim = 0.0, delay_avg = 0, ue_speed = 0, fs, bw;
   int i, aa, aarx, **txdata, trial, n_frames = 1, prach_start, rx_prach_start; //, ntrials=1;
   int N_RB_UL = 106, delay = 0, NCS_config = 13, rootSequenceIndex = 1, threequarter_fs = 0, mu = 1, fd_occasion = 0, loglvl = OAILOG_INFO, numRA = 0, prachStartSymbol = 0;
-  uint8_t snr1set = 0, ue_speed1set = 0, transmission_mode = 1, n_tx = 1, n_rx = 1, awgn_flag = 0, msg1_frequencystart = 0, num_prach_fd_occasions = 1, prach_format = 0;
-  uint8_t frame = 1, subframe = 19, config_index = 98, prach_sequence_length = 1, num_root_sequences = 16, restrictedSetConfig = 0, N_dur, N_t_slot, start_symbol;
+  uint8_t snr1set = 0, ue_speed1set = 0, transmission_mode = 1, n_tx = 1, n_rx = 1, awgn_flag = 0, msg1_frequencystart = 0, num_prach_fd_occasions = 1, prach_format=0;
+  uint8_t frame = 1, subframe = 9, slot=19, slot_gNB=19, config_index = 98, prach_sequence_length = 1, num_root_sequences = 16, restrictedSetConfig = 0, N_dur, N_t_slot, start_symbol;
   uint16_t Nid_cell = 0, preamble_tx = 0, preamble_delay, format, format0, format1;
   uint32_t tx_lev = 10000, prach_errors = 0, samp_count; //,tx_lev_dB;
   uint64_t SSB_positions = 0x01, absoluteFrequencyPointA = 640000;
+
   //  int8_t interf1=-19,interf2=-19;
   //  uint8_t abstraction_flag=0,calibration_flag=0;
   //  double prach_sinr;
   //  uint32_t nsymb;
   //  uint16_t preamble_max, preamble_energy_max;
+  FILE *input_fd=NULL;
+  char* input_file=NULL;
+  int n_bytes=0;
 
   NR_DL_FRAME_PARMS *frame_parms;
   NR_PRACH_RESOURCES_t prach_resources;
@@ -115,7 +120,7 @@ int main(int argc, char **argv){
 
   randominit(0);
 
-  while ((c = getopt (argc, argv, "hHaA:Cr:p:g:n:s:S:t:x:y:v:V:z:N:F:d:Z:L:R:E")) != -1) {
+  while ((c = getopt (argc, argv, "hHaA:Cc:r:p:g:n:s:S:t:x:y:v:V:z:N:F:d:Z:L:R:E")) != -1) {
     switch (c) {
     case 'a':
       printf("Running AWGN simulation\n");
@@ -124,6 +129,14 @@ int main(int argc, char **argv){
       //ntrials=1;
       break;
 
+    case 'c':
+      config_index = atoi(optarg);
+      break;
+
+    case 'r':
+      msg1_frequencystart = atoi(optarg);
+      break;
+
     case 'd':
       delay = atoi(optarg);
       break;
@@ -287,6 +300,14 @@ int main(int argc, char **argv){
       break;
 
     case 'F':
+      input_fd = fopen(optarg,"r");
+      input_file = optarg;
+      
+      if (input_fd==NULL) {
+	printf("Problem with filename %s\n",optarg);
+	exit(-1);
+      }
+      
       break;
 
     default:
@@ -316,6 +337,13 @@ int main(int argc, char **argv){
     }
   }
 
+  
+  if (config_index<67)  { prach_sequence_length=0; slot = subframe*2; slot_gNB = 1+(subframe*2); }
+  uint16_t N_ZC;
+  N_ZC = prach_sequence_length == 0 ? 839 : 139;
+
+  printf("Config_index %d, prach_sequence_length %d\n",config_index,prach_sequence_length);
+
   // Configure log
   logInit();
   set_glog(loglvl);
@@ -376,11 +404,11 @@ int main(int argc, char **argv){
   gNB->gNB_config.prach_config.num_prach_fd_occasions.value = num_prach_fd_occasions;
   gNB->gNB_config.prach_config.num_prach_fd_occasions_list = (nfapi_nr_num_prach_fd_occasions_t *) malloc(num_prach_fd_occasions*sizeof(nfapi_nr_num_prach_fd_occasions_t));
 
-  gNB->proc.slot_rx       = subframe;
+  gNB->proc.slot_rx       = slot;
 
-  get_nr_prach_info_from_index(config_index,
+  int ret = get_nr_prach_info_from_index(config_index,
                                (int)frame,
-                               (int)subframe,
+                               (int)slot_gNB,
                                absoluteFrequencyPointA,
                                mu,
                                frame_parms->frame_type,
@@ -389,20 +417,21 @@ int main(int argc, char **argv){
                                &N_t_slot,
                                &N_dur);
 
+  if (ret == 0) {printf("No prach in %d.%d, mu %d, config_index %d\n",frame,slot,mu,config_index); exit(-1);}
   format0 = format&0xff;      // first column of format from table
   format1 = (format>>8)&0xff; // second column of format from table
 
   if (format1 != 0xff) {
     switch(format0) {
-      case 0xa1:
-        prach_format = 9;
-        break;
-      case 0xa2:
-        prach_format = 10;
-        break;
-      case 0xa3:
-        prach_format = 11;
-        break;
+    case 0xa1:
+      prach_format = 9;
+      break;
+    case 0xa2:
+      prach_format = 10;
+      break;
+    case 0xa3:
+      prach_format = 11;
+      break;
     default:
       AssertFatal(1==0, "Only formats A1/B1 A2/B2 A3/B3 are valid for dual format");
     }
@@ -452,12 +481,14 @@ int main(int argc, char **argv){
     }
   }
 
+  printf("PRACH format %d\n",prach_format);
+      
   prach_config->num_prach_fd_occasions_list[fd_occasion].prach_root_sequence_index.value = rootSequenceIndex;
   prach_config->num_prach_fd_occasions_list[fd_occasion].k1.value                        = msg1_frequencystart;
   prach_config->restricted_set_config.value                                              = restrictedSetConfig;
   prach_config->prach_sequence_length.value                                              = prach_sequence_length;
-  prach_config->num_prach_fd_occasions_list[fd_occasion].num_root_sequences.value        = num_root_sequences;
   prach_pdu->num_cs                                                                      = get_NCS(NCS_config, format0, restrictedSetConfig);
+  prach_config->num_prach_fd_occasions_list[fd_occasion].num_root_sequences.value        = 1+(64/(N_ZC/prach_pdu->num_cs));
   prach_pdu->prach_format                                                                = prach_format;
 
   memcpy((void*)&ru->config,(void*)&RC.gNB[0]->gNB_config,sizeof(ru->config));
@@ -496,7 +527,7 @@ int main(int argc, char **argv){
   ue_prach_config->prach_sub_c_spacing                                                = mu;
   ue_prach_config->prach_sequence_length                                              = prach_sequence_length;
   ue_prach_config->restricted_set_config                                              = restrictedSetConfig;
-  ue_prach_config->num_prach_fd_occasions_list[fd_occasion].num_root_sequences        = num_root_sequences;
+  ue_prach_config->num_prach_fd_occasions_list[fd_occasion].num_root_sequences        = prach_config->num_prach_fd_occasions_list[fd_occasion].num_root_sequences.value ;
   ue_prach_config->num_prach_fd_occasions_list[fd_occasion].prach_root_sequence_index = rootSequenceIndex;
   ue_prach_config->num_prach_fd_occasions_list[fd_occasion].k1                        = msg1_frequencystart;
 
@@ -566,28 +597,23 @@ int main(int argc, char **argv){
 
   UE_nr_rxtx_proc_t proc={0};
   proc.frame_tx  = frame;
-  proc.nr_tti_tx = subframe;
+  proc.nr_tti_tx = slot;
   nr_ue_prach_procedures(UE,&proc,0,0);
 
   /* tx_lev_dB not used later, no need to set */
   //tx_lev_dB = (unsigned int) dB_fixed(tx_lev);
 
-  if (mu == 0)
-    samp_count = frame_parms->samples_per_subframe;
-  else
-    samp_count = (subframe%(frame_parms->slots_per_subframe/2)) ? frame_parms->samples_per_slotN0 : frame_parms->samples_per_slot0;
-
-  prach_start = subframe*samp_count - UE->N_TA_offset;
+  prach_start = subframe*frame_parms->samples_per_subframe-UE->N_TA_offset;
 
   #ifdef NR_PRACH_DEBUG
-    LOG_M("txsig0.m", "txs0", &txdata[0][prach_start], samp_count, 1, 1);
-    //LOG_M("txsig1.m","txs1", txdata[1],FRAME_LENGTH_COMPLEX_SAMPLES,1,1);
+  LOG_M("txsig0.m", "txs0", &txdata[0][subframe*frame_parms->samples_per_subframe], frame_parms->samples_per_subframe, 1, 1);
+    LOG_M("txsig0_frame.m","txs0", txdata[0],frame_parms->samples_per_frame,1,1);
   #endif
 
   // multipath channel
   // dump_nr_prach_config(&gNB->frame_parms,subframe);
 
-  for (i = 0; i < samp_count<<1; i++) {
+  for (i = 0; i < frame_parms->samples_per_subframe<<1; i++) {
     for (aa=0; aa<1; aa++) {
       if (awgn_flag == 0) {
         s_re[aa][i] = ((double)(((short *)&txdata[aa][prach_start]))[(i<<1)]);
@@ -622,7 +648,10 @@ int main(int argc, char **argv){
       ue_speed1 = ue_speed0 + 50;
   }
 
-  rx_prach_start = subframe*frame_parms->get_samples_per_slot(subframe,frame_parms);
+  rx_prach_start = subframe*frame_parms->samples_per_subframe;
+  if (n_frames==1) printf("slot %d, rx_prach_start %d\n",slot,rx_prach_start);
+  uint16_t preamble_rx, preamble_energy;
+
 
   for (SNR=snr0; SNR<snr1; SNR+=.1) {
     for (ue_speed=ue_speed0; ue_speed<ue_speed1; ue_speed+=10) {
@@ -634,9 +663,8 @@ int main(int argc, char **argv){
 
       for (trial=0; trial<n_frames; trial++) {
 
-        uint16_t preamble_rx, preamble_energy, N_ZC;
-
-        sigma2_dB = 10*log10((double)tx_lev) - SNR;
+	if (input_fd==NULL) {
+        sigma2_dB = 10*log10((double)tx_lev) - SNR - 10*log10(N_RB_UL*12/N_ZC);
 
         if (n_frames==1)
           printf("sigma2_dB %f (SNR %f dB) tx_lev_dB %f\n",sigma2_dB,SNR,10*log10((double)tx_lev));
@@ -655,20 +683,29 @@ int main(int argc, char **argv){
                  10*log10(tx_lev));
         }
 
-        for (i = 0; i< frame_parms->get_samples_per_slot(subframe,frame_parms); i++) {
+        for (i = 0; i< frame_parms->samples_per_subframe; i++) {
           for (aa = 0; aa < frame_parms->nb_antennas_rx; aa++) {
-            ((short*) &gNB->common_vars.rxdata[aa][rx_prach_start])[2*i] = (short) (.167*(r_re[aa][i] +sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
-            ((short*) &gNB->common_vars.rxdata[aa][rx_prach_start])[2*i+1] = (short) (.167*(r_im[aa][i] + (iqim*r_re[aa][i]) + sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
+            ((short*) &ru->common.rxdata[aa][rx_prach_start])[2*i] = (short) (.167*(r_re[aa][i] +sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
+            ((short*) &ru->common.rxdata[aa][rx_prach_start])[2*i+1] = (short) (.167*(r_im[aa][i] + (iqim*r_re[aa][i]) + sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
           }
         }
+	} else {
+	  n_bytes = fread(&ru->common.rxdata[0][rx_prach_start],sizeof(int32_t),frame_parms->samples_per_subframe,input_fd);
+	  printf("fread %d bytes from file %s\n",n_bytes,input_file);
+	  if (n_bytes!=frame_parms->samples_per_subframe) {
+	    printf("expected %d bytes\n",frame_parms->samples_per_subframe);
+	    exit(-1);
+	  }
+	}
 
-        rx_nr_prach_ru(ru, prach_format, numRA, prachStartSymbol, frame, subframe);
 
-        gNB->prach_vars.rxsigF = ru->prach_rxsigF;
+        rx_nr_prach_ru(ru, prach_format, numRA, prachStartSymbol, frame, slot);
 
+        gNB->prach_vars.rxsigF = ru->prach_rxsigF;
+	if (n_frames == 1) printf("ncs %d,num_seq %d\n",prach_pdu->num_cs,  prach_config->num_prach_fd_occasions_list[fd_occasion].num_root_sequences.value);
         rx_nr_prach(gNB, prach_pdu, frame, subframe, &preamble_rx, &preamble_energy, &preamble_delay);
 
-        printf(" preamble_energy %d preamble_rx %d preamble_tx %d \n", preamble_energy, preamble_rx, preamble_tx);
+	//        printf(" preamble_energy %d preamble_rx %d preamble_tx %d \n", preamble_energy, preamble_rx, preamble_tx);
 
         if (preamble_rx != preamble_tx)
           prach_errors++;
@@ -680,24 +717,30 @@ int main(int argc, char **argv){
         if (n_frames==1) {
           printf("preamble %d (tx %d) : energy %d, delay %d\n",preamble_rx,preamble_tx,preamble_energy,preamble_delay);
           #ifdef NR_PRACH_DEBUG
-            LOG_M("prach0.m","prach0", &txdata[0][prach_start], samp_count, 1, 1);
+	  LOG_M("prach0.m","prach0", &txdata[0][prach_start], frame_parms->samples_per_subframe, 1, 1);
             LOG_M("prachF0.m","prachF0", &gNB->prach_vars.prachF[0], N_ZC, 1, 1);
-            LOG_M("rxsig0.m","rxs0", &gNB->common_vars.rxdata[0][rx_prach_start], frame_parms->samples_per_subframe, 1, 1);
-            //LOG_M("ru_rxsig0.m","rxs0", &ru->common.rxdata[0][rx_prach_start], frame_parms->samples_per_subframe, 1, 1);
+            LOG_M("rxsig0.m","rxs0", &gNB->common_vars.rxdata[0][subframe*frame_parms->samples_per_subframe], frame_parms->samples_per_subframe, 1, 1);
+            LOG_M("ru_rxsig0.m","rxs0", &ru->common.rxdata[0][subframe*frame_parms->samples_per_subframe], frame_parms->samples_per_subframe, 1, 1);
             LOG_M("rxsigF0.m","rxsF0", gNB->prach_vars.rxsigF[0], N_ZC, 1, 1);
             LOG_M("prach_preamble.m","prachp", &gNB->X_u[0], N_ZC, 1, 1);
             LOG_M("ue_prach_preamble.m","prachp", &UE->X_u[0], N_ZC, 1, 1);
           #endif
         }
       }
+
       printf("SNR %f dB, UE Speed %f km/h: errors %d/%d (delay %f)\n", SNR, ue_speed, prach_errors, n_frames, delay_avg/(double)(n_frames-prach_errors));
+      if (input_fd)
+	break;
       if (prach_errors)
         break;
+
     } // UE Speed loop
     if (!prach_errors) {
       printf("PRACH test OK\n");
       break;
     }
+    if (input_fd)
+      break;
   } //SNR loop
 
   for (i=0; i<2; i++) {
@@ -712,5 +755,7 @@ int main(int argc, char **argv){
   free(r_re);
   free(r_im);
 
+  if (input_fd) fclose(input_fd);
+
   return(0);
 }
diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c
index dc5089a622e4fbf7c43189c63d9e922e5ddd4c42..004a7b8de8ae2868346b82576b6d34036ffb76ed 100644
--- a/openair1/SIMULATION/NR_PHY/pucchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pucchsim.c
@@ -59,6 +59,8 @@ uint16_t NB_UE_INST = 1;
 // needed for some functions
 PHY_VARS_NR_UE * PHY_vars_UE_g[1][1]={{NULL}};
 
+void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {}
+
 int main(int argc, char **argv)
 {
   char c;
@@ -477,7 +479,7 @@ int main(int argc, char **argv)
     for (trial=0; trial<n_trials; trial++) {
       bzero(txdataF[aa],frame_parms->ofdm_symbol_size*sizeof(int));
       if(format==0){
-        nr_generate_pucch0(UE,txdataF,frame_parms,UE->pucch_config_dedicated,amp,nr_tti_tx,m0,mcs,nrofSymbols,startingSymbolIndex,startingPRB);
+        nr_generate_pucch0(UE,txdataF,frame_parms,PUCCH_GroupHopping,hopping_id,amp,nr_tti_tx,m0,mcs,nrofSymbols,startingSymbolIndex,startingPRB);
       }
       else if (format == 1){
         nr_generate_pucch1(UE,txdataF,frame_parms,UE->pucch_config_dedicated,actual_payload,amp,nr_tti_tx,m0,nrofSymbols,startingSymbolIndex,startingPRB,startingPRB_intraSlotHopping,0,nr_bit);	
diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c
index a1a00b38f39d4cd6649cfdbfdce4189548d1d6fa..b0557ef1b417beeee6ef41f21489d11ebeb417d0 100644
--- a/openair1/SIMULATION/NR_PHY/ulschsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulschsim.c
@@ -54,6 +54,8 @@ PHY_VARS_NR_UE *UE;
 RAN_CONTEXT_t RC;
 int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
 
+void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {}
+
 double cpuf;
 uint8_t nfapi_mode = 0;
 uint16_t NB_UE_INST = 1;
diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c
index 40653600e8f16a051b6bdc994b472f5bc6d773f7..bcaa967a30c18bbc138ffd4c227c5ea905883ec8 100644
--- a/openair1/SIMULATION/NR_PHY/ulsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulsim.c
@@ -56,6 +56,7 @@
 //#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c"
 #include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
 #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h"
+
 #define inMicroS(a) (((double)(a))/(cpu_freq_GHz*1000.0))
 #include "SIMULATION/LTE_PHY/common_sim.h"
 
@@ -110,9 +111,9 @@ int main(int argc, char **argv)
   int i;
   double SNR, snr0 = -2.0, snr1 = 2.0;
   double sigma, sigma_dB;
-  double snr_step = 1;
+  double snr_step = .2;
   uint8_t snr1set = 0;
-  int slot = 0, frame = 0;
+  int slot = 8, 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;
@@ -126,7 +127,6 @@ 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 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;
@@ -145,12 +145,13 @@ int main(int argc, char **argv)
   float target_error_rate = 0.01;
   int print_perf = 0;
   cpuf = get_cpu_freq_GHz();
-
+  int msg3_flag = 0;
 
   UE_nr_rxtx_proc_t UE_proc;
   FILE *scg_fd=NULL;
 
-
+  int ibwps=24;
+  int ibwp_rboffset=41;
   if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0 ) {
     exit_fun("[NR_ULSIM] Error, configuration module init failed\n");
   }
@@ -158,208 +159,235 @@ int main(int argc, char **argv)
   //logInit();
   randominit(0);
 
-  while ((c = getopt(argc, argv, "d:f:g:h:i:j:l:m:n:p:r:s:y:z:F:M:N:PR:S:L:")) != -1) {
+  while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:i:j:kl:m:n:p:r:s:y:z:F:M:N:PR:S:L:")) != -1) {
+    printf("handling optarg %c\n",c);
     switch (c) {
 
       /*case 'd':
         frame_type = 1;
         break;*/
 
-      case 'd':
-        delay = atoi(optarg);
-        break;
-
-      case 'f':
-         scg_fd = fopen(optarg, "r");
-
-         if (scg_fd == NULL) {
-             printf("Error opening %s\n", optarg);
-             exit(-1);
-         }
-
-         break;
-
-      case 'g':
-        switch ((char) *optarg) {
-          case 'A':
-            channel_model = SCM_A;
-            break;
-
-          case 'B':
-            channel_model = SCM_B;
-            break;
-
-          case 'C':
-            channel_model = SCM_C;
-            break;
-
-          case 'D':
-            channel_model = SCM_D;
-            break;
-
-          case 'E':
-            channel_model = EPA;
-            break;
-
-          case 'F':
-            channel_model = EVA;
-            break;
-
-          case 'G':
-            channel_model = ETU;
-            break;
-
-          default:
-            printf("Unsupported channel model!\n");
-            exit(-1);
-        }
-
-        break;
+    case 'a':
+      start_symbol = atoi(optarg);
+      AssertFatal(start_symbol >= 0 && start_symbol < 13,"start_symbol %d is not in 0..12\n",start_symbol);
+      break;
+
+    case 'b':
+      nb_symb_sch = atoi(optarg);
+      AssertFatal(nb_symb_sch > 0 && nb_symb_sch < 15,"start_symbol %d is not in 1..14\n",nb_symb_sch);
+      break;
+    case 'c':
+      n_rnti = atoi(optarg);
+      AssertFatal(n_rnti > 0 && n_rnti<=65535,"Illegal n_rnti %x\n",n_rnti);
+      break;
+
+    case 'd':
+      delay = atoi(optarg);
+      break;
+      
+    case 'e':
+      msg3_flag = 1;
+      break;
+      
+    case 'f':
+      scg_fd = fopen(optarg, "r");
+      
+      if (scg_fd == NULL) {
+	printf("Error opening %s\n", optarg);
+	exit(-1);
+      }
 
+      break;
+      
+    case 'g':
+      switch ((char) *optarg) {
+      case 'A':
+	channel_model = SCM_A;
+	break;
+	
+      case 'B':
+	channel_model = SCM_B;
+	break;
+	
+      case 'C':
+	channel_model = SCM_C;
+	break;
+	
+      case 'D':
+	channel_model = SCM_D;
+	break;
+	
+      case 'E':
+	channel_model = EPA;
+	break;
+	
+      case 'F':
+	channel_model = EVA;
+	break;
+	
+      case 'G':
+	channel_model = ETU;
+	break;
+	
+      default:
+	printf("Unsupported channel model!\n");
+	exit(-1);
+      }
+      
+      break;
+      
       /*case 'i':
         interf1 = atoi(optarg);
         break;
-
-      case 'j':
+	
+	case 'j':
         interf2 = atoi(optarg);
         break;*/
 
-      case 'l':
-        nb_symb_sch = atoi(optarg);
-        break;
-
-      case 'm':
-        Imcs = atoi(optarg);
-        break;
-
-      case 'n':
-        n_trials = atoi(optarg);
-        break;
-
-      case 'p':
-        extended_prefix_flag = 1;
-        break;
-
-      case 'r':
-        nb_rb = atoi(optarg);
-        break;
-
-      case 's':
-        snr0 = atof(optarg);
-        printf("Setting SNR0 to %f\n", snr0);
-        break;
+    case 'k':
+      printf("Setting threequarter_fs_flag\n");
+      openair0_cfg[0].threequarter_fs= 1;
+      break;
 
+    case 'l':
+      nb_symb_sch = atoi(optarg);
+      break;
+      
+    case 'm':
+      Imcs = atoi(optarg);
+      break;
+      
+    case 'n':
+      n_trials = atoi(optarg);
+      break;
+      
+    case 'p':
+      extended_prefix_flag = 1;
+      break;
+      
+    case 'r':
+      nb_rb = atoi(optarg);
+      break;
+      
+    case 's':
+      snr0 = atof(optarg);
+      printf("Setting SNR0 to %f\n", snr0);
+      break;
+      
       /*
-       case 'r':
-       ricean_factor = pow(10,-.1*atof(optarg));
-       if (ricean_factor>1) {
-       printf("Ricean factor must be between 0 and 1\n");
-       exit(-1);
-       }
-       break;
-       */
-
+	case 'r':
+	ricean_factor = pow(10,-.1*atof(optarg));
+	if (ricean_factor>1) {
+	printf("Ricean factor must be between 0 and 1\n");
+	exit(-1);
+	}
+	break;
+      */
+      
       /*case 'x':
         transmission_mode = atoi(optarg);
         break;*/
+      
+    case 'y':
+      n_tx = atoi(optarg);
+      
+      if ((n_tx == 0) || (n_tx > 2)) {
+	printf("Unsupported number of tx antennas %d\n", n_tx);
+	exit(-1);
+      }
+      
+      break;
+      
+    case 'z':
+      n_rx = atoi(optarg);
+      
+      if ((n_rx == 0) || (n_rx > 2)) {
+	printf("Unsupported number of rx antennas %d\n", n_rx);
+	exit(-1);
+      }
+      
+      break;
+      
+    case 'F':
+      input_fd = fopen(optarg, "r");
+      
+      if (input_fd == NULL) {
+	printf("Problem with filename %s\n", optarg);
+	exit(-1);
+      }
+      
+      break;
+      
+    case 'M':
+     // SSB_positions = atoi(optarg);
+      break;
+      
+    case 'N':
+     // Nid_cell = atoi(optarg);
+      break;
+      
+    case 'R':
+      N_RB_DL = atoi(optarg);
+      N_RB_UL = N_RB_DL;
+      break;
+      
+    case 'S':
+      snr1 = atof(optarg);
+      snr1set = 1;
+      printf("Setting SNR1 to %f\n", snr1);
+      break;
+      
+    case 'P':
+      print_perf=1;
+      opp_enabled=1;
+      break;
+      
+    case 'L':
+      loglvl = 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", argv[0]);
+      //printf("-d Use TDD\n");
+      printf("-d Introduce delay in terms of number of samples\n");
+      printf("-f Number of frames to simulate\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("-h This message\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("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if ending SNR isn't given\n");
+      printf("-m MCS value\n");
+      printf("-n Number of trials to simulate\n");
+      printf("-p Use extended prefix mode\n");
+      printf("-t Delay spread for multipath channel\n");
+      //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");
+      printf("-R N_RB_DL\n");
+      printf("-S Ending SNR, runs from SNR0 to SNR1\n");
+      printf("-P Print ULSCH performances\n");
+      exit(-1);
+      break;
 
-      case 'y':
-        n_tx = atoi(optarg);
-
-        if ((n_tx == 0) || (n_tx > 2)) {
-          printf("Unsupported number of tx antennas %d\n", n_tx);
-          exit(-1);
-        }
-
-        break;
-
-      case 'z':
-        n_rx = atoi(optarg);
-
-        if ((n_rx == 0) || (n_rx > 2)) {
-          printf("Unsupported number of rx antennas %d\n", n_rx);
-          exit(-1);
-        }
-
-        break;
-
-      case 'F':
-        input_fd = fopen(optarg, "r");
-
-        if (input_fd == NULL) {
-            printf("Problem with filename %s\n", optarg);
-            exit(-1);
-        }
-
-        break;
-
-      case 'M':
-        //SSB_positions = atoi(optarg);
-        break;
-
-      case 'N':
-        //Nid_cell = atoi(optarg);
-        break;
-
-      case 'R':
-        N_RB_DL = atoi(optarg);
-        N_RB_UL = N_RB_DL;
-        break;
-
-      case 'S':
-        snr1 = atof(optarg);
-        snr1set = 1;
-        printf("Setting SNR1 to %f\n", snr1);
-        break;
-
-      case 'P':
-        print_perf=1;
-        opp_enabled=1;
-        break;
-
-      case 'L':
-        loglvl = 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", argv[0]);
-          //printf("-d Use TDD\n");
-          printf("-d Introduce delay in terms of number of samples\n");
-          printf("-f Number of frames to simulate\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("-h This message\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("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if ending SNR isn't given\n");
-          printf("-m MCS value\n");
-          printf("-n Number of trials to simulate\n");
-          printf("-p Use extended prefix mode\n");
-          printf("-t Delay spread for multipath channel\n");
-          //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");
-          printf("-R N_RB_DL\n");
-          printf("-S Ending SNR, runs from SNR0 to SNR1\n");
-          printf("-P Print ULSCH performances\n");
-          exit(-1);
-          break;
     }
   }
-
+  
   logInit();
   set_glog(loglvl);
   T_stdout = 1;
 
   get_softmodem_params()->phy_test = 1;
   get_softmodem_params()->do_ra = 0;
+  get_softmodem_params()->usim_test = 1;
+
 
   if (snr1set == 0)
     snr1 = snr0 + 10;
@@ -385,12 +413,15 @@ int main(int argc, char **argv)
   gNB->UL_INFO.rx_ind.number_of_pdus = 0;
   gNB->UL_INFO.crc_ind.number_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;
   frame_parms->N_RB_DL = N_RB_DL;
   frame_parms->N_RB_UL = N_RB_UL;
   frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL;
 
+
   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++)
@@ -419,6 +450,7 @@ int main(int argc, char **argv)
   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);
@@ -427,12 +459,14 @@ int main(int argc, char **argv)
   phy_init_nr_gNB(gNB,0,0);
   N_RB_DL = gNB->frame_parms.N_RB_DL;
 
+
+
+  NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[0];
+
   //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;
 
   //configure UE
   UE = malloc(sizeof(PHY_VARS_NR_UE));
@@ -480,7 +514,7 @@ int main(int argc, char **argv)
   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_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib,secondaryCellGroup);
 
   nr_ue_phy_config_request(&UE_mac->phy_config);
 
@@ -512,7 +546,7 @@ int main(int argc, char **argv)
   unsigned int TBS;
   uint16_t number_dmrs_symbols = 0;
   unsigned int available_bits;
-  uint8_t nb_re_dmrs, no_data_in_dmrs = 1;
+  uint8_t nb_re_dmrs;
   unsigned char mod_order;
   uint16_t code_rate;
   uint8_t ptrs_mcs1 = 2;
@@ -540,6 +574,7 @@ int main(int argc, char **argv)
 
   printf("\n");
 
+  for (int i=0;i<16;i++) printf("%f\n",gaussdouble(0.0,1.0));
   for (SNR = snr0; SNR < snr1; SNR += snr_step) {
 
       varArray_t *table_rx=initVarArray(1000,sizeof(double));
@@ -581,19 +616,40 @@ int main(int argc, char **argv)
       UL_tti_req->pdus_list[0].pdu_size = sizeof(nfapi_nr_pusch_pdu_t);
       memset(pusch_pdu,0,sizeof(nfapi_nr_pusch_pdu_t));
       
+      int abwp_size  = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275);
+      int abwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth,275);
+      int ibwp_size  = ibwps;
+      int ibwp_start = ibwp_rboffset;
+      if (msg3_flag == 1) {
+	if ((ibwp_start < abwp_start) || (ibwp_size > abwp_size))
+	  pusch_pdu->bwp_start = abwp_start;
+	else
+	  pusch_pdu->bwp_start = ibwp_start;
+	pusch_pdu->bwp_size = ibwp_size;
+	start_rb += (ibwp_start - abwp_start);
+	printf("msg3: ibwp_size %d, abwp_size %d, ibwp_start %d, abwp_start %d\n",
+	       ibwp_size,abwp_size,ibwp_start,abwp_start);
+      }
+      else {
+	pusch_pdu->bwp_start = abwp_start;
+	pusch_pdu->bwp_size = abwp_size;
+      }
+
       pusch_pdu->pdu_bit_map = pdu_bit_map;
       pusch_pdu->rnti = n_rnti;
       pusch_pdu->mcs_index = Imcs;
       pusch_pdu->mcs_table = mcs_table;
       pusch_pdu->target_code_rate = code_rate;
       pusch_pdu->qam_mod_order = mod_order;
-      pusch_pdu->transform_precoding = 0;
-      pusch_pdu->data_scrambling_id = 0;
+      pusch_pdu->transform_precoding = 1;
+      pusch_pdu->data_scrambling_id = *scc->physCellId;
       pusch_pdu->nrOfLayers = 1;
       pusch_pdu->ul_dmrs_symb_pos = l_prime_mask << start_symbol;
       pusch_pdu->dmrs_config_type = 0;
-      pusch_pdu->ul_dmrs_scrambling_id =  0;
+      pusch_pdu->ul_dmrs_scrambling_id =  *scc->physCellId;
       pusch_pdu->scid = 0;
+      pusch_pdu->dmrs_ports = 1;
+      pusch_pdu->num_dmrs_cdm_grps_no_data = 1;
       pusch_pdu->resource_alloc = 1; 
       pusch_pdu->rb_start = start_rb;
       pusch_pdu->rb_size = nb_rb;
@@ -611,6 +667,8 @@ int main(int argc, char **argv)
       pusch_pdu->pusch_ptrs.ptrs_ports_list   = (nfapi_nr_ptrs_ports_t *) malloc(2*sizeof(nfapi_nr_ptrs_ports_t));
       pusch_pdu->pusch_ptrs.ptrs_ports_list[0].ptrs_re_offset = 0;
 
+      // prepare ULSCH/PUSCH reception
+      nr_schedule_response(Sched_INFO);
 
       // --------- setting parameters for UE --------
 
@@ -635,6 +693,7 @@ int main(int argc, char **argv)
       ul_config.ul_config_list[0].pusch_config_pdu.dmrs_config_type = 0;
       ul_config.ul_config_list[0].pusch_config_pdu.mcs_index = Imcs;
       ul_config.ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table;
+      ul_config.ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1;
       ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0;
       ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = 0;
       ul_config.ul_config_list[0].pusch_config_pdu.nrOfLayers = precod_nbr_layers;
@@ -646,83 +705,135 @@ int main(int argc, char **argv)
       //there are plenty of other parameters that we don't seem to be using for now. e.g.
       ul_config.ul_config_list[0].pusch_config_pdu.absolute_delta_PUSCH = 0;
 
-      if(no_data_in_dmrs)
-        nb_re_dmrs = 12;
-      else
-        nb_re_dmrs = ((ul_config.ul_config_list[0].pusch_config_pdu.dmrs_config_type == pusch_dmrs_type1) ? 6 : 4);
+      nb_re_dmrs = ((ul_config.ul_config_list[0].pusch_config_pdu.dmrs_config_type == pusch_dmrs_type1) ? 6 : 4);
 
       available_bits = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, number_dmrs_symbols, mod_order, 1);
       TBS            = nr_compute_tbs(mod_order, code_rate, nb_rb, nb_symb_sch, nb_re_dmrs * number_dmrs_symbols, 0, 0, precod_nbr_layers);
-
       pusch_pdu->pusch_data.tb_size = TBS>>3;
       ul_config.ul_config_list[0].pusch_config_pdu.pusch_data.tb_size = TBS;
 
-      // prepare ULSCH/PUSCH reception
-      nr_schedule_response(Sched_INFO);
-
-      // set FAPI parameters for UE, put them in the scheduled response and call
-      nr_ue_scheduled_response(&scheduled_response);
-
-      /////////////////////////phy_procedures_nr_ue_TX///////////////////////
-      ///////////
-
-      phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0);
+      nr_fill_ulsch(gNB,frame,slot,pusch_pdu);
+      int slot_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);// - (int)(800*factor);
+      int slot_length = slot_offset - frame_parms->get_samples_slot_timestamp(slot-1,frame_parms,0);
+
+      for (int i=0;i<(TBS>>3);i++) ulsch_ue[0]->harq_processes[harq_pid]->a[i]=i&0xff;
+      double scale = 1;
+
+      if (input_fd == NULL) {
+
+        if (SNR==snr0) { 
+	  // set FAPI parameters for UE, put them in the scheduled response and call
+	  nr_ue_scheduled_response(&scheduled_response);
+	  
+	  
+	  /////////////////////////phy_procedures_nr_ue_TX///////////////////////
+	  ///////////
+	  
+	  phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, 0);
+	  
+	  
+	  if (n_trials==1) {
+	    LOG_M("txsig0.m","txs0", UE->common_vars.txdata[0],frame_parms->samples_per_subframe*10,1,1);
+	    LOG_M("txsig0F.m","txs0F", UE->common_vars.txdataF[0],frame_parms->ofdm_symbol_size*14,1,1);
+	  }
+	  ///////////
+	  ////////////////////////////////////////////////////
+	  tx_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);
+	  
+	  txlev = signal_energy(&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);
+	  
+	  txlev_float = (double)txlev/scale; // output of signal_energy is fixed point representation
+	  
+	  
+	  //AWGN
+	}
+      }	
+      else n_trials = 1;
 
-      if (n_trials==1)
-	LOG_M("txsig0.m","txs0", UE->common_vars.txdata[0],frame_length_complex_samples,1,1);
 
-      ///////////
-      ////////////////////////////////////////////////////
-      tx_offset = frame_parms->get_samples_slot_timestamp(slot,frame_parms,0);
-
-      txlev = signal_energy(&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);
-
-      txlev_float = (double)txlev; // output of signal_energy is fixed point representation
+      sigma_dB = 10*log10(txlev_float)-SNR;
+      sigma    = pow(10,sigma_dB/10);
+      printf("txlev_float %f, sigma_dB %f\n",10*log10(txlev_float),sigma_dB);
 
       n_errors = 0;
       n_false_positive = 0;
 
-      //AWGN
-      sigma_dB = 10*log10(txlev_float)-SNR;
-      sigma    = pow(10,sigma_dB/10);
+      errors_scrambling  = 0;
+      errors_decoding    = 0;
 
+      int error_flag;
       for (trial = 0; trial < n_trials; trial++) {
-
-        errors_scrambling  = 0;
-        errors_decoding    = 0;
-
-        //----------------------------------------------------------
-        //------------------------ add noise -----------------------
-        //----------------------------------------------------------
-        for (i=0; i<frame_length_complex_samples; i++) {
-          for (ap=0; ap<frame_parms->nb_antennas_rx; ap++) {
-            ((short*) gNB->common_vars.rxdata[ap])[(2*i) + (delay*2)]   = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)])   + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0)); // convert to fixed point
-            ((short*) gNB->common_vars.rxdata[ap])[2*i+1 + (delay*2)]   = (((int16_t *)UE->common_vars.txdata[ap])[(i<<1)+1]) + (int16_t)(sqrt(sigma/2)*gaussdouble(0.0,1.0));
-          }
-        }
-        ////////////////////////////////////////////////////////////
-
-        //----------------------------------------------------------
-        //------------------- gNB phy procedures -------------------
-        //----------------------------------------------------------
-        gNB->UL_INFO.rx_ind.number_of_pdus = 0;
-        gNB->UL_INFO.crc_ind.number_crcs = 0;
+	
+	error_flag = 0;
+	  //----------------------------------------------------------
+	  //------------------------ add noise -----------------------
+	  //----------------------------------------------------------
+	if (input_fd == NULL ) {
+	  for (i=0; i<slot_length; i++) {
+	    for (ap=0; ap<frame_parms->nb_antennas_rx; ap++) {
+	      ((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i) + (delay*2)]   = (int16_t)((double)(((int16_t *)&UE->common_vars.txdata[ap][slot_offset])[(i<<1)])/sqrt(scale)   + (sqrt(sigma/2)*gaussdouble(0.0,1.0))); // convert to fixed point
+	      ((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i)+1 + (delay*2)]   = (int16_t)((double)(((int16_t *)&UE->common_vars.txdata[ap][slot_offset])[(i<<1)+1])/sqrt(scale) + (sqrt(sigma/2)*gaussdouble(0.0,1.0)));
+	    }
+	  }
+	}
+	else {
+	  AssertFatal(frame_parms->nb_antennas_rx == 1, "nb_ant != 1\n");
+	  // 800 samples is N_TA_OFFSET for FR1 @ 30.72 Ms/s,
+	  AssertFatal(frame_parms->subcarrier_spacing==30000,"only 30 kHz for file input for now (%d)\n",frame_parms->subcarrier_spacing);
+	  double factor = 1;
+	  if (openair0_cfg[0].threequarter_fs== 1) factor =.75;
+	  int ta_offset=1600;
+	  if (N_RB_DL <217) ta_offset=800;
+	  else if (N_RB_DL < 106) ta_offset = 400;
+
+	  fread((void*)&gNB->common_vars.rxdata[0][slot_offset],
+		sizeof(int16_t),
+		slot_length<<1,
+		input_fd);
+	  for (int i=0;i<16;i+=2) printf("slot_offset %d : %d,%d\n",
+					 slot_offset,
+					 ((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[i],
+					 ((int16_t*)&gNB->common_vars.rxdata[0][slot_offset])[1+i]);
+	  fclose(input_fd);
+	}
+	////////////////////////////////////////////////////////////
+	
+	//----------------------------------------------------------
+	//------------------- gNB phy procedures -------------------
+	//----------------------------------------------------------
+	gNB->UL_INFO.rx_ind.number_of_pdus = 0;
+	gNB->UL_INFO.crc_ind.number_crcs = 0;
 
         start_meas(&gNB->phy_proc_rx);
         phy_procedures_gNB_common_RX(gNB, frame, slot);
 
-	if (n_trials==1)
-	  LOG_M("rxsigF0.m","rxsF0",gNB->common_vars.rxdataF[0],frame_length_complex_samples_no_prefix,1,1);
+	if (n_trials==1) {
+	  LOG_M("rxsig0.m","rx0",&gNB->common_vars.rxdata[0][0],frame_parms->samples_per_subframe*10,1,1);
 
+	  LOG_M("rxsigF0.m","rxsF0",gNB->common_vars.rxdataF[0]+start_symbol*frame_parms->ofdm_symbol_size,nb_symb_sch*frame_parms->ofdm_symbol_size,1,1);
+
+	}
         phy_procedures_gNB_uespec_RX(gNB, frame, slot);
+	if (n_trials == 1) { 
+	  LOG_M("rxsigF0_ext.m","rxsF0_ext",
+		&gNB->pusch_vars[0]->rxdataF_ext[0][(start_symbol+1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size,1,1);
+	  LOG_M("chestF0.m","chF0",
+		&gNB->pusch_vars[0]->ul_ch_estimates[0][start_symbol*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size,1,1);
+	  LOG_M("chestF0_ext.m","chF0_ext",
+		&gNB->pusch_vars[0]->ul_ch_estimates_ext[0][(start_symbol+1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size,1,1);
+	  LOG_M("rxsigF0_comp.m","rxsF0_comp",
+		&gNB->pusch_vars[0]->rxdataF_comp[0][(start_symbol+1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size,1,1);
+	}
         start_meas(&gNB->phy_proc_rx);
         ////////////////////////////////////////////////////////////
 
 	if (gNB->ulsch[0][0]->last_iteration_cnt >= 
-	    gNB->ulsch[0][0]->max_ldpc_iterations+1)
+	    gNB->ulsch[0][0]->max_ldpc_iterations+1) {
+	  error_flag = 1; 
 	  n_errors++;
-
+	}
+	
         //----------------------------------------------------------
         //----------------- count and print errors -----------------
         //----------------------------------------------------------
@@ -754,22 +865,30 @@ int main(int argc, char **argv)
             errors_decoding++;
           }
         }
-
-        if (errors_decoding > 0) {
+	if (n_trials == 1) {
+	  for (int r=0;r<ulsch_ue[0]->harq_processes[harq_pid]->C;r++) 
+	    for (int i=0;i<ulsch_ue[0]->harq_processes[harq_pid]->K>>3;i++) {
+	      if ((ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]) != 0) printf("************");
+	      printf("r %d: in[%d] %x, out[%d] %x (%x)\n",r,
+		     i,ulsch_ue[0]->harq_processes[harq_pid]->c[r][i],
+		     i,ulsch_gNB->harq_processes[harq_pid]->c[r][i],
+		     ulsch_ue[0]->harq_processes[harq_pid]->c[r][i]^ulsch_gNB->harq_processes[harq_pid]->c[r][i]);
+	    }
+	}
+        if (errors_decoding > 0 && error_flag == 0) {
           n_false_positive++;
 	  if (n_trials==1)
 	    printf("\x1B[31m""[frame %d][trial %d]\tnumber of errors in decoding     = %u\n" "\x1B[0m", frame, trial, errors_decoding);
         } 
-
       } // trial loop
 
       printf("*****************************************\n");
-      printf("SNR %f: n_errors (negative CRC) = %d/%d, false_positive %d/%d, errors_scrambling %u/%d\n", SNR, n_errors, n_trials, n_false_positive, n_trials, errors_scrambling, n_trials);
+      printf("SNR %f: n_errors (negative CRC) = %d/%d, false_positive %d/%d, errors_scrambling %u/%u\n", SNR, n_errors, n_trials, n_false_positive, n_trials, errors_scrambling, available_bits*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 (print_perf==1) {
         printDistribution(&gNB->phy_proc_rx,table_rx,"Total PHY proc rx");
         printStatIndent(&gNB->ulsch_channel_estimation_stats,"ULSCH channel estimation time");
@@ -795,7 +914,6 @@ int main(int argc, char **argv)
       }
       
   } // SNR loop
-
   printf("\n");
 
   free(test_input_bit);
diff --git a/openair1/SIMULATION/TOOLS/taus.c b/openair1/SIMULATION/TOOLS/taus.c
index 5fe0ce4d7887a36b6888629a3c97d985988803cc..cdd4aebec3dff23605946f97d1fb45e3e9ba81f1 100644
--- a/openair1/SIMULATION/TOOLS/taus.c
+++ b/openair1/SIMULATION/TOOLS/taus.c
@@ -21,7 +21,8 @@
 
 #include <time.h>
 #include <stdlib.h>
-#include "SIMULATION/TOOLS/sim.h"
+//#include "SIMULATION/TOOLS/sim.h"
+
 
 unsigned int s0, s1, s2, b;
 
diff --git a/openair2/COMMON/platform_constants.h b/openair2/COMMON/platform_constants.h
index 1eb58b16b2005d172e6ccffdad219f782358d7b9..77f7e26c67345dba27778cfed6270e574a880cfa 100644
--- a/openair2/COMMON/platform_constants.h
+++ b/openair2/COMMON/platform_constants.h
@@ -101,6 +101,7 @@
 
 #define NUMBER_OF_NR_DLSCH_MAX 2//16
 #define NUMBER_OF_NR_ULSCH_MAX 2//16
+#define NUMBER_OF_NR_PUCCH_MAX 2
 #define NUMBER_OF_NR_SR_MAX 16
 
 
diff --git a/openair2/GNB_APP/RRC_nr_paramsvalues.h b/openair2/GNB_APP/RRC_nr_paramsvalues.h
index 94243411e14fe1bd30c28b549aeb9d950cf24761..bc4c4cf9d945600a92e536aaefd19d3e3638a844 100644
--- a/openair2/GNB_APP/RRC_nr_paramsvalues.h
+++ b/openair2/GNB_APP/RRC_nr_paramsvalues.h
@@ -128,11 +128,11 @@
 #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_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_MSG3TRANSFPREC                        "msg3_transformPrecoder"
 #define GNB_CONFIG_STRING_PUSCHTIMEDOMAINALLOCATIONLIST         "puschTimeDomainAllocationList"
diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c
index 0a6f9063128f74433b0b129bbc005f8bed41975b..9bdd70926241bc8d86765b40e213a45bcfe615b0 100644
--- a/openair2/GNB_APP/gnb_app.c
+++ b/openair2/GNB_APP/gnb_app.c
@@ -131,6 +131,7 @@ 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                        gnb_id;
   MessageDef                      *msg_p           = NULL;
   const char                      *msg_name        = NULL;
diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h
index d133b679f17b48d63748e0ce36836b4889bbd4f2..591c2448b8486dc34e3b29a340aa39944002b0b9 100644
--- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h
+++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h
@@ -230,6 +230,70 @@ typedef struct {
   uint8_t TCRNTI_2: 8;    // octet 7 [7:0]
 } __attribute__ ((__packed__)) NR_MAC_RAR;
 
+// DCI pdu structures. Used by both gNB and UE.
+typedef struct {
+  uint16_t val;
+  uint8_t nbits;
+} dci_field_t;
+
+typedef struct {
+
+  uint8_t     format_indicator; //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     mcs; //5 bits
+  uint8_t     ndi; //1 bit
+  uint8_t     rv; //2 bits
+  uint8_t     harq_pid; //4 bits
+  uint8_t     tpc; //2 bits
+  uint8_t     short_messages_indicator; //2 bits
+  uint8_t     short_messages; //8 bits
+  uint8_t     tb_scaling; //2 bits
+  uint8_t     pucch_resource_indicator; //3 bits
+  uint8_t     dmrs_sequence_initialization; //1 bit
+  uint8_t     system_info_indicator; //1 bit
+
+  uint8_t     slot_format_indicator_count;
+  uint8_t     *slot_format_indicators;
+ 
+  uint8_t     pre_emption_indication_count;
+  uint16_t    *pre_emption_indications; //14 bit each
+ 
+  uint8_t     block_number_count;
+  uint8_t     *block_numbers;
+  uint8_t     padding;
+
+  dci_field_t mcs2; //variable
+  dci_field_t ndi2; //variable
+  dci_field_t rv2; //variable
+  dci_field_t frequency_domain_assignment; //variable
+  dci_field_t time_domain_assignment; //variable
+  dci_field_t frequency_hopping_flag; //variable
+  dci_field_t vrb_to_prb_mapping; //variable
+  dci_field_t dai[2]; //variable
+  dci_field_t pdsch_to_harq_feedback_timing_indicator; //variable
+  dci_field_t carrier_indicator; //variable
+  dci_field_t bwp_indicator; //variable
+  dci_field_t prb_bundling_size_indicator; //variable
+  dci_field_t rate_matching_indicator; //variable
+  dci_field_t zp_csi_rs_trigger; //variable
+  dci_field_t transmission_configuration_indication; //variable
+  dci_field_t srs_request; //variable
+  dci_field_t cbgti; //variable
+  dci_field_t cbgfi; //variable
+  dci_field_t srs_resource_indicator; //variable
+  dci_field_t precoding_information; //variable
+  dci_field_t csi_request; //variable
+  dci_field_t ptrs_dmrs_association; //variable
+  dci_field_t beta_offset_indicator; //variable
+  dci_field_t cloded_loop_indicator; //variable
+  dci_field_t ul_sul_indicator; //variable
+  dci_field_t antenna_ports; //variable
+  dci_field_t reserved; //1_0/C-RNTI:10 bits, 1_0/P-RNTI: 6 bits, 1_0/SI-&RA-RNTI: 16 bits
+
+} dci_pdu_rel15_t;
+
 //  38.321 ch6.2.1, 38.331
 #define DL_SCH_LCID_CCCH                           0x00
 #define DL_SCH_LCID_DCCH                           0x01
diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c
index 9cf83c02abd058df5c2c87366a8a5b44329f44bd..074908022cea17dcd4ced419e57cc3b7d548867c 100644
--- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c
+++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c
@@ -32,6 +32,8 @@
 
 #include "LAYER2/NR_MAC_gNB/mac_proto.h"
 
+const uint8_t nr_slots_per_frame[5] = {10, 20, 40, 80, 160};
+
 // 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
@@ -46,11 +48,13 @@ uint16_t NCS_restricted_TypeB_delta_f_RA_5[14]   = {36,57,60,63,65,68,71,77,81,8
 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};
 
 const char *prachfmt[]={"A1","A2","A3","B1","B2","B3","B4","C0","C2"};
-
-const uint16_t nr_slots_per_frame[5] = {10, 20, 40, 80, 160};
+const char *prachfmt03[]={"0","1","2","3"};
 
 uint16_t get_NCS(uint8_t index, uint16_t format0, uint8_t restricted_set_config) {
 
+  LOG_D(MAC,"get_NCS: indx %d,format0 %d, restriced_set_config %d\n",
+	index,format0,restricted_set_config);
+
   if (format0 < 3) {
     switch(restricted_set_config){
       case 0:
@@ -975,7 +979,7 @@ int get_nr_prach_info_from_index(uint8_t index,
     if ( (frame%x)==y || (frame%x)==y2 ) {
       slot_60khz = slot >> (mu-2); // in table slots are numbered wrt 60kHz
       s_map = table_6_3_3_2_4_prachConfig_Index[index][5];
-      if ( (s_map>>slot_60khz)&0x01 ) {
+      if ( ((s_map>>slot_60khz)&0x01) ) {
         if (mu == 3) {
           if ( (table_6_3_3_2_4_prachConfig_Index[index][7] == 1) && (slot%2 == 0) )
             return 0; // no prach in even slots @ 120kHz for 1 prach per 60khz slot
@@ -1015,7 +1019,7 @@ int get_nr_prach_info_from_index(uint8_t index,
         s_map = table_6_3_3_2_3_prachConfig_Index[index][4];
         if ( (s_map>>subframe)&0x01 ) {
           if (mu == 1) {
-            if ( (table_6_3_3_2_3_prachConfig_Index[index][6] == 1) && (slot%2 == 0) )
+            if ( (table_6_3_3_2_3_prachConfig_Index[index][6] <= 1) && (slot%2 == 0) )
               return 0; // no prach in even slots @ 30kHz for 1 prach per subframe
           }
           if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){
@@ -1025,9 +1029,9 @@ int get_nr_prach_info_from_index(uint8_t index,
             if (table_6_3_3_2_3_prachConfig_Index[index][1] != -1)
               format2 = (uint8_t) table_6_3_3_2_3_prachConfig_Index[index][1];
             *format = ((uint8_t) table_6_3_3_2_3_prachConfig_Index[index][0]) | (format2<<8);
-            LOG_D(MAC,"Frame %d slot %d: Getting PRACH info from index %d absoluteFrequencyPointA %u mu %u frame_type %u start_symbol %u N_t_slot %u N_dur %u \n", frame,
+            LOG_D(MAC,"Frame %d slot %d: Getting PRACH info from index %d (col 6 %ld) absoluteFrequencyPointA %u mu %u frame_type %u start_symbol %u N_t_slot %u N_dur %u \n", frame,
               slot,
-              index,
+              index, table_6_3_3_2_3_prachConfig_Index[index][6],
               pointa,
               mu,
               unpaired,
@@ -1051,7 +1055,7 @@ int get_nr_prach_info_from_index(uint8_t index,
         s_map = table_6_3_3_2_2_prachConfig_Index[index][4];
         if ( (s_map>>subframe)&0x01 ) {
           if (mu == 1) {
-            if ( (table_6_3_3_2_2_prachConfig_Index[index][6] == 1) && (slot%2 == 0) )
+            if ( (table_6_3_3_2_2_prachConfig_Index[index][6] <= 1) && (slot%2 == 0) )
               return 0; // no prach in even slots @ 30kHz for 1 prach per subframe
           }
           if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){
@@ -1136,7 +1140,7 @@ uint8_t compute_nr_root_seq(NR_RACH_ConfigCommon_t *rach_config,
   uint8_t ncs_index = rach_config->rach_ConfigGeneric.zeroCorrelationZoneConfig;
   uint16_t format0 = get_format0(config_index, unpaired);
   uint16_t NCS = get_NCS(ncs_index, format0, rach_config->restrictedSetConfig);
-  uint16_t L_ra = (rach_config->prach_RootSequenceIndex.present) ? 139 : 839;
+  uint16_t L_ra = (rach_config->prach_RootSequenceIndex.present==NR_RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139) ? 139 : 839;
   uint16_t r,u,index,q,d_u,n_shift_ra,n_shift_ra_bar,d_start;
   uint32_t w;
   uint8_t found_preambles = 0;
@@ -1532,7 +1536,7 @@ int32_t get_nr_uldl_offset(int nr_bandP)
 
 void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
 		   int x_overhead,
-                   uint8_t nodata_dmrs,
+                   uint8_t numdmrscdmgroupnodata,
                    uint8_t tb_scaling) {
 
   LOG_D(MAC, "TBS calculation\n");
@@ -1540,10 +1544,14 @@ void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
   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;
-  if (nodata_dmrs)
-    N_PRB_DMRS = 12;
-  else
-    N_PRB_DMRS = (pdsch_rel15->dmrsConfigType == NFAPI_NR_DMRS_TYPE1)?6:4; //This only works for antenna port 1000
+  if (pdsch_rel15->dmrsConfigType == NFAPI_NR_DMRS_TYPE1) {
+    // if no data in dmrs cdm group is 1 only even REs have no data
+    // if no data in dmrs cdm group is 2 both odd and even REs have no data
+    N_PRB_DMRS = numdmrscdmgroupnodata*6;
+  }
+  else {
+    N_PRB_DMRS = numdmrscdmgroupnodata*4;
+  }
   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;
@@ -1723,6 +1731,48 @@ int get_num_dmrs(uint16_t dmrs_mask ) {
   return(num_dmrs);
 }
 
+// Table 5.1.2.2.1-1 38.214
+uint8_t getRBGSize(uint16_t bwp_size, long rbg_size_config) {
+  
+  AssertFatal(bwp_size<276,"BWP Size > 275\n");
+  
+  if (bwp_size < 37)  return (rbg_size_config ? 4 : 2);
+  if (bwp_size < 73)  return (rbg_size_config ? 8 : 4);
+  if (bwp_size < 145) return (rbg_size_config ? 16 : 8);
+  else return 16;
+}
+
+uint8_t getNRBG(uint16_t bwp_size, uint16_t bwp_start, long rbg_size_config) {
+
+  uint8_t rbg_size = getRBGSize(bwp_size,rbg_size_config);
+
+  return (uint8_t)ceil((bwp_size+(bwp_start % rbg_size))/rbg_size);
+}
+
+uint8_t getAntPortBitWidth(NR_SetupRelease_DMRS_DownlinkConfig_t *typeA, NR_SetupRelease_DMRS_DownlinkConfig_t *typeB) {
+
+  uint8_t nbitsA = 0;
+  uint8_t nbitsB = 0;
+  uint8_t type,length,nbits;
+
+  if (typeA != NULL) {
+    type = (typeA->choice.setup->dmrs_Type==NULL) ? 1:2;
+    length = (typeA->choice.setup->maxLength==NULL) ? 1:2;
+    nbitsA = type + length + 2;
+    if (typeB == NULL) return nbitsA;
+  }
+  if (typeB != NULL) {
+    type = (typeB->choice.setup->dmrs_Type==NULL) ? 1:2;
+    length = (typeB->choice.setup->maxLength==NULL) ? 1:2;
+    nbitsB = type + length + 2;
+    if (typeA == NULL) return nbitsB;
+  }
+
+  nbits = (nbitsA > nbitsB) ? nbitsA : nbitsB;
+  return nbits;
+}
+
+
 /*******************************************************************
 *
 * NAME :         get_l0_ul
@@ -1829,11 +1879,17 @@ uint8_t get_K_ptrs(uint16_t nrb0, uint16_t nrb1, uint16_t N_RB) {
     return 1;
 }
 
-uint16_t nr_dci_size(nr_dci_format_t format,
+uint16_t nr_dci_size(NR_CellGroupConfig_t *secondaryCellGroup,
+                     dci_pdu_rel15_t *dci_pdu,
+                     nr_dci_format_t format,
 		     nr_rnti_type_t rnti_type,
-		     uint16_t N_RB) {
+		     uint16_t N_RB,
+                     int bwp_id) {
 
   uint16_t size = 0;
+  NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1];
+  NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1];
+  NR_PDSCH_Config_t *pdsch_config = bwp->bwp_Dedicated->pdsch_Config->choice.setup;
 
   switch(format) {
     /*Only sizes for 0_0 and 1_0 are correct at the moment*/
@@ -1841,7 +1897,7 @@ uint16_t nr_dci_size(nr_dci_format_t 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_dci_size(NR_DL_DCI_FORMAT_1_0, rnti_type, N_RB) - size; // Padding to match 1_0 size
+      size += nr_dci_size(secondaryCellGroup,dci_pdu,NR_DL_DCI_FORMAT_1_0, rnti_type, N_RB, bwp_id) - size; // Padding to match 1_0 size
       // UL/SUL indicator assumed to be 0
       break;
 
@@ -1874,29 +1930,123 @@ uint16_t nr_dci_size(nr_dci_format_t format,
       break;
 
     case NR_DL_DCI_FORMAT_1_1:
+      // General note: 0 bits condition is ignored as default nbits is 0.
+      // Format identifier
+      size = 1;
       // Carrier indicator
-      size += 1; // Format identifier
+      if (secondaryCellGroup->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig != NULL) {
+        dci_pdu->carrier_indicator.nbits=3;
+        size += dci_pdu->carrier_indicator.nbits;
+      }
       // BWP Indicator
+      uint8_t n_dl_bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count;
+      if (n_dl_bwp < 2)
+        dci_pdu->bwp_indicator.nbits = n_dl_bwp;
+      else
+        dci_pdu->bwp_indicator.nbits = 2;
+      size += dci_pdu->bwp_indicator.nbits;
       // Freq domain assignment
-      // Time domain assignment
-      // VRB to PRB mapping
+      long rbg_size_config = secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rbg_Size;
+      uint16_t numRBG = getNRBG(NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275),
+                                NRRIV2PRBOFFSET(bwp->bwp_Common->genericParameters.locationAndBandwidth,275),
+                                rbg_size_config);
+      if (pdsch_config->resourceAllocation == 0)
+        dci_pdu->frequency_domain_assignment.nbits = numRBG;
+      else if (pdsch_config->resourceAllocation == 1)
+        dci_pdu->frequency_domain_assignment.nbits = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
+      else
+        dci_pdu->frequency_domain_assignment.nbits = ((int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )>numRBG) ? (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) )+1 : numRBG+1;
+      size += dci_pdu->frequency_domain_assignment.nbits;
+      // Time domain assignment (see table 5.1.2.1.1-1 in 38.214
+      int num_entries;
+      if (pdsch_config->pdsch_TimeDomainAllocationList==NULL) {
+        if (bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList==NULL)
+          num_entries = 16; // num of entries in default table
+        else
+          num_entries = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count;
+      }
+      else
+        num_entries = pdsch_config->pdsch_TimeDomainAllocationList->choice.setup->list.count;
+      dci_pdu->time_domain_assignment.nbits = (int)ceil(log2(num_entries));
+      size += dci_pdu->time_domain_assignment.nbits;
+      // VRB to PRB mapping 
+      if ((pdsch_config->resourceAllocation == 1) && (bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver != NULL)) {
+        dci_pdu->vrb_to_prb_mapping.nbits = 1;
+        size += dci_pdu->vrb_to_prb_mapping.nbits;
+      }
       // PRB bundling size indicator
+      if (pdsch_config->prb_BundlingType.present == NR_PDSCH_Config__prb_BundlingType_PR_dynamicBundling) {
+        dci_pdu->prb_bundling_size_indicator.nbits = 1;
+        size += dci_pdu->prb_bundling_size_indicator.nbits;
+      }
       // Rate matching indicator
+      NR_RateMatchPatternGroup_t *group1 = pdsch_config->rateMatchPatternGroup1;
+      NR_RateMatchPatternGroup_t *group2 = pdsch_config->rateMatchPatternGroup2;
+      if ((group1 != NULL) && (group2 != NULL))
+        dci_pdu->rate_matching_indicator.nbits = 2;
+      if ((group1 != NULL) != (group2 != NULL))
+        dci_pdu->rate_matching_indicator.nbits = 1;
+      size += dci_pdu->rate_matching_indicator.nbits;
       // ZP CSI-RS trigger
-      /// TB1- MCS 5, NDI 1, RV 2
+      if (pdsch_config->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList != NULL) {
+        uint8_t nZP = pdsch_config->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList->list.count;
+        dci_pdu->zp_csi_rs_trigger.nbits = (int)ceil(log2(nZP+1));
+      }
+      size += dci_pdu->zp_csi_rs_trigger.nbits;
+      // TB1- MCS 5, NDI 1, RV 2
       size += 8;
       // TB2
-      size += 4 ;  // HARQ PID
+      long *maxCWperDCI = pdsch_config->maxNrofCodeWordsScheduledByDCI;
+      if ((maxCWperDCI != NULL) && (*maxCWperDCI == 2)) {
+        size += 8;
+      }
+      // HARQ PID
+      size += 4;
       // DAI
-      size += 2; // TPC PUCCH
-      size += 3; // PUCCH resource indicator
-      size += 3; // PDSCH to HARQ timing indicator
+      if (secondaryCellGroup->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook == NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic) { // FIXME in case of more than one serving cell
+        dci_pdu->dai[0].nbits = 2;
+        size += dci_pdu->dai[0].nbits;
+      }
+      // TPC PUCCH
+      size += 2;
+      // PUCCH resource indicator
+      size += 3;
+      // PDSCH to HARQ timing indicator
+      uint8_t I = ubwp->bwp_Dedicated->pucch_Config->choice.setup->dl_DataToUL_ACK->list.count;
+      dci_pdu->pdsch_to_harq_feedback_timing_indicator.nbits = (int)ceil(log2(I));
+      size += dci_pdu->pdsch_to_harq_feedback_timing_indicator.nbits;
       // Antenna ports
+      NR_SetupRelease_DMRS_DownlinkConfig_t *typeA = pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA;
+      NR_SetupRelease_DMRS_DownlinkConfig_t *typeB = pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeB;
+      dci_pdu->antenna_ports.nbits = getAntPortBitWidth(typeA,typeB);
+      size += dci_pdu->antenna_ports.nbits;
       // Tx Config Indication
-      size += 2; // SRS request
+      long *isTciEnable = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[bwp_id-1]->tci_PresentInDCI;
+      if (isTciEnable != NULL) {
+        dci_pdu->transmission_configuration_indication.nbits = 3;
+        size += dci_pdu->transmission_configuration_indication.nbits;
+      }
+      // SRS request
+      if (secondaryCellGroup->spCellConfig->spCellConfigDedicated->supplementaryUplink==NULL)
+        dci_pdu->srs_request.nbits = 2;
+      else
+        dci_pdu->srs_request.nbits = 3;
+      size += dci_pdu->srs_request.nbits;
       // CBGTI
-      // CBGFI
-      size += 1; // DMRS sequence init
+      if (secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL) {
+        uint8_t maxCBGperTB = (secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock + 1) * 2;
+        long *maxCWperDCI_rrc = pdsch_config->maxNrofCodeWordsScheduledByDCI;
+        uint8_t maxCW = (maxCWperDCI_rrc == NULL) ? 1 : *maxCWperDCI_rrc;
+        dci_pdu->cbgti.nbits = maxCBGperTB * maxCW;
+        size += dci_pdu->cbgti.nbits;
+        // CBGFI
+        if (secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator) {
+          dci_pdu->cbgfi.nbits = 1;
+          size += dci_pdu->cbgfi.nbits;
+        }
+      }
+      // DMRS sequence init
+      size += 1;
       break;
 
     case NR_DL_DCI_FORMAT_2_0:
diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h
index cc0dc5fd9e9dd13b10d7f9fadab8a9216835eae0..2f7f1449830a8426b3453dfbbd4ae57818b05660 100644
--- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h
+++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h
@@ -33,7 +33,8 @@
 #define __LAYER2_NR_MAC_COMMON_H__
 
 #include "NR_PDSCH-Config.h"
-#include "NR_ServingCellConfigCommon.h"
+#include "NR_CellGroupConfig.h"
+#include "nr_mac.h"
 
 typedef enum {
   NR_DL_DCI_FORMAT_1_0 = 0,
@@ -76,7 +77,12 @@ int is_nr_DL_slot(NR_ServingCellConfigCommon_t *scc,slot_t slotP);
 
 int is_nr_UL_slot(NR_ServingCellConfigCommon_t *scc,slot_t slotP);
 
-uint16_t nr_dci_size(nr_dci_format_t format, nr_rnti_type_t rnti_type, uint16_t N_RB);
+uint16_t nr_dci_size(NR_CellGroupConfig_t *secondaryCellGroup,
+                     dci_pdu_rel15_t *dci_pdu,
+                     nr_dci_format_t format,
+		     nr_rnti_type_t rnti_type,
+		     uint16_t N_RB,
+                     int bwp_id);
 
 void find_monitoring_periodicity_offset_common(NR_SearchSpace_t *ss,
                                                uint16_t *slot_period,
diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c
index f50c15df50aa86fb7a4bc0242397c258dd0a47dd..5a9620ed010a45edfeb9d7e614e64d062065a41c 100755
--- a/openair2/LAYER2/NR_MAC_UE/config_ue.c
+++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c
@@ -334,7 +334,7 @@ int nr_rrc_mac_config_req_ue(
     //    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_CellGroupConfig_t            *cell_group_config ){
 
     NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
 
@@ -345,18 +345,17 @@ int nr_rrc_mac_config_req_ue(
     if(mibP != NULL){
       mac->mib = mibP;    //  update by every reception
     }
-    
-    
-    if(spCell_ConfigP != NULL ){
-      mac->servCellIndex = *spCell_ConfigP->servCellIndex;
-      if (spCell_ConfigP->reconfigurationWithSync) {
-        mac->rach_ConfigDedicated = spCell_ConfigP->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink;
-        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);
+
+    if(cell_group_config != NULL ){
+      mac->servCellIndex = *cell_group_config->spCellConfig->servCellIndex;
+      if (cell_group_config->spCellConfig->reconfigurationWithSync) {
+        mac->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink;
+	mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
+	config_common_ue(mac,module_id,cc_idP);
+	mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity;
+	LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti);
       }
-      mac->scd = spCell_ConfigP->spCellConfigDedicated;
+      mac->scg = cell_group_config;
 
       /*      
       if(mac_cell_group_configP != NULL){
diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h
index a7115617479f8760641a68ea95e5e5e11705939d..5775e5bfb913a7cf73fe6dec3f56d1f887126102 100755
--- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h
+++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h
@@ -61,7 +61,7 @@
 #include "NR_MIB.h"
 #include "NR_MAC-CellGroupConfig.h"
 #include "NR_PhysicalCellGroupConfig.h"
-#include "NR_SpCellConfig.h"
+#include "NR_CellGroupConfig.h"
 #include "NR_ServingCellConfig.h"
 
 
@@ -155,7 +155,7 @@ typedef enum {
 typedef struct {
 
   NR_ServingCellConfigCommon_t    *scc;
-  NR_ServingCellConfig_t          *scd;
+  NR_CellGroupConfig_t            *scg;
   NR_RACH_ConfigDedicated_t       *rach_ConfigDedicated;
   int                             servCellIndex;
   ////  MAC config
diff --git a/openair2/LAYER2/NR_MAC_UE/mac_extern.h b/openair2/LAYER2/NR_MAC_UE/mac_extern.h
index 26e0ea26676418d498a18aed4946858deb8a90f3..54cdc4d14931207911f2359766d6ab178b6b7221 100644
--- a/openair2/LAYER2/NR_MAC_UE/mac_extern.h
+++ b/openair2/LAYER2/NR_MAC_UE/mac_extern.h
@@ -90,4 +90,6 @@ extern const int32_t table_38213_10_1_1_c2[5];
 //  for PUSCH from TS 38.214 subclause 6.1.2.1.1
 extern uint8_t table_6_1_2_1_1_2_time_dom_res_alloc_A[16][3];
 //  for PDSCH from TS 38.214 subclause 5.1.2.1.1
-extern uint8_t table_5_1_2_1_1_2_time_dom_res_alloc_A[16][3];
\ No newline at end of file
+extern uint8_t table_5_1_2_1_1_2_time_dom_res_alloc_A[16][3];
+
+extern dci_pdu_rel15_t *def_dci_pdu_rel15;
diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h
index 760ff9386cfbc210f4c1dee5ed88a36482a828bf..e9d7a97a5da2edc498caab32f8d65416b14de03c 100755
--- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h
+++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h
@@ -72,7 +72,7 @@ int nr_rrc_mac_config_req_ue(
     uint8_t                         gNB_index,
     NR_MIB_t                        *mibP,
     //NR_ServingCellConfigCommon_t    *sccP,
-    NR_SpCellConfig_t               *spCell_ConfigP);
+    NR_CellGroupConfig_t            *cell_group_config);
 
 /**\brief initialization NR UE MAC instance(s), total number of MAC instance based on NB_NR_UE_MAC_INST*/
 NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst);
@@ -101,7 +101,7 @@ 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, 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, 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);
@@ -161,7 +161,7 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
                          uint8_t dci_length,
                          uint16_t rnti,
                          uint64_t *dci_pdu,
-                         nr_dci_pdu_rel15_t *nr_pdci_info_extracted);
+                         dci_pdu_rel15_t *nr_pdci_info_extracted);
 
 
 uint8_t
diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
index c5154d7a1f7011f24c65f96edec1b610cacc8c0b..af9822a5dfa0e160c32ae572c71a9df1e01e08c4 100644
--- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
+++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c
@@ -52,7 +52,7 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst)
     //init mac here
     nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(sizeof(NR_UE_MAC_INST_t),NB_NR_UE_MAC_INST);
     if (rrc_inst) {
-      nr_rrc_mac_config_req_ue(0,0,0,NULL,rrc_inst->cell_group_config->spCellConfig);
+      nr_rrc_mac_config_req_ue(0,0,0,NULL,rrc_inst->cell_group_config);
       
       if (IS_SOFTMODEM_NOS1){
         if (rlc_module_init(0) != 0) {
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c
index 6a3f4ad90209fa2dde1fc19717c041ff0a27a51d..56ae14f98b8760d0708ebf9684a3b6fa060da999 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c
@@ -334,6 +334,7 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint
 // - retrieve TBS
 // - add mac_rrc_nr_data_req_ue, etc ...
 // - add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator)
+
 uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
                        module_id_t mod_id,
                        int CC_id,
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c
index a98a2b12113d4b542b59870d49b20584c76fb37f..a79b4083e31429380a0dde40974a1c2a8f61bd92 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c
@@ -46,6 +46,7 @@
 #endif
 #define LOG_DCI_PARM(a...) LOG_D(PHY,"\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci)" a)
 
+dci_pdu_rel15_t *def_dci_pdu_rel15;
 
 void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) {
 
@@ -63,7 +64,8 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd
 
 void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot) {
 
-  NR_ServingCellConfig_t *scd = mac->scd;
+  def_dci_pdu_rel15 = calloc(1,sizeof(dci_pdu_rel15_t));
+
   NR_BWP_Downlink_t *bwp;
   NR_BWP_DownlinkCommon_t *bwp_Common;
   NR_BWP_DownlinkDedicated_t *dl_bwp_Dedicated;
@@ -76,6 +78,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
   NR_ControlResourceSet_t *coreset;
 
   fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15;
+  NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated;
 
   uint8_t bwp_id = 1;
   int ss_id, sps;
@@ -167,7 +170,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
     AssertFatal(mac->scc != NULL, "scc is null\n");
 
     scc = mac->scc;
-    rel15->dci_format = NR_DL_DCI_FORMAT_1_0;
+    rel15->dci_format = NR_DL_DCI_FORMAT_1_1;
 
     // CoReSet configuration
     coreset = mac->coreset[0][0];
@@ -220,7 +223,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
         rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, 275);
         rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, 275); // NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, 275);
         rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing;
-        rel15->dci_length = nr_dci_size(rel15->dci_format, NR_RNTI_RA, rel15->BWPSize);
+        rel15->dci_length = nr_dci_size(mac->scg,def_dci_pdu_rel15,rel15->dci_format,NR_RNTI_C,rel15->BWPSize,bwp_id);
         for (int i = 0; i < sps; i++)
         if ((monitoringSymbolsWithinSlot >> (sps - 1 - i)) & 1) {
           rel15->coreset.StartSymbolIndex = i;
@@ -240,7 +243,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
       rel15->BWPSize = NRRIV2BW(bwp_Common->genericParameters.locationAndBandwidth, 275);
       rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, 275);
       rel15->SubcarrierSpacing = bwp_Common->genericParameters.subcarrierSpacing;
-      rel15->dci_length = nr_dci_size(rel15->dci_format, NR_RNTI_C, rel15->BWPSize);
+      rel15->dci_length = nr_dci_size(mac->scg,def_dci_pdu_rel15,rel15->dci_format,NR_RNTI_C,rel15->BWPSize,bwp_id);
       // get UE-specific search space
       for (ss_id = 0; ss_id < FAPI_NR_MAX_SS_PER_CORESET && mac->SSpace[0][0][ss_id] != NULL; ss_id++){
         uss = mac->SSpace[0][0][ss_id];
@@ -264,10 +267,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
       rel15->coreset.scrambling_rnti = mac->t_crnti;
     } else {
       rel15->coreset.pdcch_dmrs_scrambling_id = *scc->physCellId;
-      if(mac->ra_state == WAIT_RAR)
-        rel15->coreset.scrambling_rnti = 0;
-      else
-        rel15->coreset.scrambling_rnti = rel15->rnti;
+      rel15->coreset.scrambling_rnti = 0;
     }
 
     if (add_dci){
diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
index 0da02bd7d1475f707b2ba8a98a77f7a62271dc91..163855a093c880ed367c91296cecb54ca42e9beb 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
@@ -74,6 +74,8 @@
 //#define ENABLE_MAC_PAYLOAD_DEBUG 1
 #define DEBUG_EXTRACT_DCI 1
 
+extern int bwp_id;
+extern dci_pdu_rel15_t *def_dci_pdu_rel15;
 extern const uint16_t nr_slots_per_frame[5];
 
 extern void mac_rlc_data_ind     (
@@ -671,7 +673,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
 
     // check type0 from 38.213 13 if we have no CellGroupConfig
     // TODO: implementation to be completed
-    if (mac->scd == NULL) {
+    if (mac->scg == NULL) {
       if(dl_info->ssb_index != -1){
 
         if(mac->type0_pdcch_ss_mux_pattern == 1){
@@ -719,7 +721,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
         dl_config->number_pdus = dl_config->number_pdus + 1;
         mac->scheduled_response.dl_config = dl_config;
       }
-    } else { // we have an scd
+    } else { // we have an scg
 
       dcireq.module_id = mod_id;
       dcireq.gNB_index = gNB_index;
@@ -816,6 +818,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
     scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type;
     scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.mcs_index = mcs_index;
     scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table;
+    scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.num_dmrs_cdm_grps_no_data = 1;
     scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.new_data_indicator = 0;
     scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.pusch_data.rv_index = rv_index;
     scheduled_response.ul_config->ul_config_list[0].pusch_config_pdu.nrOfLayers = nrOfLayers;
@@ -856,9 +859,9 @@ void nr_ue_msg2_scheduler(module_id_t mod_id,
 
   uint8_t bwp_id = 1;
   NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
-  NR_ServingCellConfig_t *scd = mac->scd;
+  NR_CellGroupConfig_t *scg = mac->scg;
   NR_ServingCellConfigCommon_t *scc = mac->scc;
-  NR_BWP_Downlink_t *bwp = scd->downlinkBWP_ToAddModList->list.array[bwp_id - 1];
+  NR_BWP_Downlink_t *bwp = scg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id - 1];
   NR_SearchSpace_t *ss;
   struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList;
   uint8_t mu = *scc->ssbSubcarrierSpacing;
@@ -2292,17 +2295,17 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac,
 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) {
 
   NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
-  nr_dci_pdu_rel15_t dci_pdu_rel15;
 
   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);
 
-  nr_extract_dci_info(mac,dci->dci_format,dci->payloadSize,dci->rnti,(uint64_t *)dci->payloadBits,&dci_pdu_rel15);
-
-  return (nr_ue_process_dci(module_id, cc_id, gNB_index, &dci_pdu_rel15, dci->rnti, dci->dci_format));
+  nr_extract_dci_info(mac,dci->dci_format,dci->payloadSize,dci->rnti,(uint64_t *)dci->payloadBits,def_dci_pdu_rel15);
+  return (nr_ue_process_dci(module_id, cc_id, gNB_index, def_dci_pdu_rel15, dci->rnti, dci->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){
+int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, dci_pdu_rel15_t *dci, uint16_t rnti, uint32_t dci_format){
+
+  int bwp_id = 1;
 
   NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
   fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request;
@@ -2340,16 +2343,17 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
     nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu_0_0 = &ul_config->ul_config_list[ul_config->number_pdus].pusch_config_pdu;
     /* IDENTIFIER_DCI_FORMATS */
     /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */
-    nr_ue_process_dci_freq_dom_resource_assignment(pusch_config_pdu_0_0,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL);
+    nr_ue_process_dci_freq_dom_resource_assignment(pusch_config_pdu_0_0,NULL,n_RB_ULBWP,0,dci->frequency_domain_assignment.val);
     /* TIME_DOM_RESOURCE_ASSIGNMENT */
     nr_ue_process_dci_time_dom_resource_assignment(mac,
 						   pusch_config_pdu_0_0,NULL,
-						   dci->time_dom_resource_assignment);
+						   dci->time_domain_assignment.val);
 
     /* 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))
-      pusch_config_pdu_0_0->frequency_hopping = dci->freq_hopping_flag;
+      pusch_config_pdu_0_0->frequency_hopping = dci->frequency_hopping_flag.val;
+
     /* MCS */
     pusch_config_pdu_0_0->mcs_index = dci->mcs;
     /* NDI */
@@ -2357,19 +2361,19 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
     /* RV */
     pusch_config_pdu_0_0->pusch_data.rv_index = dci->rv;
     /* HARQ_PROCESS_NUMBER */
-    pusch_config_pdu_0_0->pusch_data.harq_process_id = dci->harq_process_number;
+    pusch_config_pdu_0_0->pusch_data.harq_process_id = dci->harq_pid;
     /* TPC_PUSCH */
     // according to TS 38.213 Table Table 7.1.1-1
-    if (dci->tpc_pusch == 0) {
+    if (dci->tpc == 0) {
       pusch_config_pdu_0_0->absolute_delta_PUSCH = -4;
     }
-    if (dci->tpc_pusch == 1) {
+    if (dci->tpc == 1) {
       pusch_config_pdu_0_0->absolute_delta_PUSCH = -1;
     }
-    if (dci->tpc_pusch == 2) {
+    if (dci->tpc == 2) {
       pusch_config_pdu_0_0->absolute_delta_PUSCH = 1;
     }
-    if (dci->tpc_pusch == 3) {
+    if (dci->tpc == 3) {
       pusch_config_pdu_0_0->absolute_delta_PUSCH = 4;
     }
     /* SUL_IND_0_0 */ // To be implemented, FIXME!!!
@@ -2413,16 +2417,16 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
     /* CARRIER_IND */
     /* SUL_IND_0_1 */
     /* BANDWIDTH_PART_IND */
-    //pusch_config_pdu_0_1->bandwidth_part_ind = dci->bandwidth_part_ind; //FIXME
+    //pusch_config_pdu_0_1->bandwidth_part_ind = dci->bwp_indicator.val;
     /* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */
-    nr_ue_process_dci_freq_dom_resource_assignment(pusch_config_pdu_0_1,NULL,n_RB_ULBWP,0,dci->freq_dom_resource_assignment_UL);
+    nr_ue_process_dci_freq_dom_resource_assignment(pusch_config_pdu_0_1,NULL,n_RB_ULBWP,0,dci->frequency_domain_assignment.val);
     /* TIME_DOM_RESOURCE_ASSIGNMENT */
     nr_ue_process_dci_time_dom_resource_assignment(mac,pusch_config_pdu_0_1,NULL,
-						   dci->time_dom_resource_assignment);
+						   dci->time_domain_assignment.val);
     /* 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))
-      pusch_config_pdu_0_1->frequency_hopping = dci->freq_hopping_flag;
+      pusch_config_pdu_0_1->frequency_hopping = dci->frequency_hopping_flag.val;
     /* MCS */
     pusch_config_pdu_0_1->mcs_index = dci->mcs;
     /* NDI */
@@ -2430,21 +2434,21 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
     /* RV */
     pusch_config_pdu_0_1->pusch_data.rv_index = dci->rv;
     /* HARQ_PROCESS_NUMBER */
-    pusch_config_pdu_0_1->pusch_data.harq_process_id = dci->harq_process_number;
+    pusch_config_pdu_0_1->pusch_data.harq_process_id = dci->harq_pid;
     /* 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) {
+    if (dci->tpc == 0) {
       pusch_config_pdu_0_1->absolute_delta_PUSCH = -4;
     }
-    if (dci->tpc_pusch == 1) {
+    if (dci->tpc == 1) {
       pusch_config_pdu_0_1->absolute_delta_PUSCH = -1;
     }
-    if (dci->tpc_pusch == 2) {
+    if (dci->tpc == 2) {
       pusch_config_pdu_0_1->absolute_delta_PUSCH = 1;
     }
-    if (dci->tpc_pusch == 3) {
+    if (dci->tpc == 3) {
       pusch_config_pdu_0_1->absolute_delta_PUSCH = 4;
     }
     /* SRS_RESOURCE_IND */
@@ -2462,16 +2466,16 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
 		(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) {
-	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][0];
-	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][1];
+	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][0];
+	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][1];
 	  }
 	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_partialAndNonCoherent){
-	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][2];
-	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][3];
+	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][2];
+	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][3];
 	  }
 	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){
-	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][4];
-	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][5];
+	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][4];
+	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][5];
 	  }
 	}
 	// Table 7.3.1.1.2-3: transformPrecoder= enabled, or transformPrecoder=disabled and maxRank = 1
@@ -2479,16 +2483,16 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
 	     || (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) {
-	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][6];
-	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][7];
+	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][6];
+	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][7];
 	  }
 	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_partialAndNonCoherent){
-	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][8];
-	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][9];
+	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][8];
+	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][9];
 	  }
 	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){
-	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][10];
-	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][11];
+	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][10];
+	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][11];
 	  }
 	}
       }
@@ -2497,12 +2501,12 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
 	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) {
-	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][12];
-	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][13];
+	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][12];
+	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][13];
 	  }
 	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){
-	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][14];
-	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][15];
+	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][14];
+	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][15];
 	  }
 	}
 	// Table 7.3.1.1.2-5: transformPrecoder= enabled, or transformPrecoder= disabled and maxRank = 1
@@ -2510,12 +2514,12 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
 	     || (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) {
-	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][16];
-	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][17];
+	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][16];
+	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][17];
 	  }
 	  if (mac->phy_config.config_req.ul_bwp_dedicated.pusch_config_dedicated.codebook_subset == codebook_subset_nonCoherent){
-	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][18];
-	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precod_nbr_layers][19];
+	    pusch_config_pdu_0_1->nrOfLayers = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][18];
+	    pusch_config_pdu_0_1->transform_precoding = table_7_3_1_1_2_2_3_4_5[dci->precoding_information.val][19];
 	  }
 	}
       }
@@ -2526,24 +2530,24 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
 	(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
       pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = 2; //TBC
-      pusch_config_pdu_0_1->dmrs_ports = dci->antenna_ports; //TBC
+      pusch_config_pdu_0_1->dmrs_ports = dci->antenna_ports.val; //TBC
     }
     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
       pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = 2; //TBC
-      pusch_config_pdu_0_1->dmrs_ports = (dci->antenna_ports > 3)?(dci->antenna_ports-4):(dci->antenna_ports); //TBC
+      pusch_config_pdu_0_1->dmrs_ports = (dci->antenna_ports.val > 3)?(dci->antenna_ports.val-4):(dci->antenna_ports.val); //TBC
       //pusch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 3)?2:1; //FIXME
     }
     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){
-	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports > 1)?2:1; //TBC
-	pusch_config_pdu_0_1->dmrs_ports = (dci->antenna_ports > 1)?(dci->antenna_ports-2):(dci->antenna_ports); //TBC
+	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 1)?2:1; //TBC
+	pusch_config_pdu_0_1->dmrs_ports = (dci->antenna_ports.val > 1)?(dci->antenna_ports.val-2):(dci->antenna_ports.val); //TBC
       }
       if (rank == 2){
-	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports > 0)?2:1; //TBC
+	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 0)?2:1; //TBC
 	pusch_config_pdu_0_1->dmrs_ports = 0; //FIXME
 	//pusch_config_pdu_0_1->dmrs_ports[0] = (dci->antenna_ports > 1)?(dci->antenna_ports > 2 ?0:2):0;
 	//pusch_config_pdu_0_1->dmrs_ports[1] = (dci->antenna_ports > 1)?(dci->antenna_ports > 2 ?2:3):1;
@@ -2568,57 +2572,57 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
 	(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){
-	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports > 1)?2:1; //TBC
-	pusch_config_pdu_0_1->dmrs_ports = (dci->antenna_ports > 1)?(dci->antenna_ports > 5 ?(dci->antenna_ports-6):(dci->antenna_ports-2)):dci->antenna_ports; //TBC
-	//pusch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 6)?2:1; //FIXME
+	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 1)?2:1; //TBC
+	pusch_config_pdu_0_1->dmrs_ports = (dci->antenna_ports.val > 1)?(dci->antenna_ports.val > 5 ?(dci->antenna_ports.val-6):(dci->antenna_ports.val-2)):dci->antenna_ports.val; //TBC
+	//pusch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports.val > 6)?2:1; //FIXME
       }
       if (rank == 2){
-	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports > 0)?2:1; //TBC
+	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 0)?2:1; //TBC
 	pusch_config_pdu_0_1->dmrs_ports = 0; //FIXME
-	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_13[dci->antenna_ports][1];
-	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_13[dci->antenna_ports][2];
-	//pusch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 3)?2:1; // FIXME
+	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_13[dci->antenna_ports.val][1];
+	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_13[dci->antenna_ports.val][2];
+	//pusch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports.val > 3)?2:1; // FIXME
       }
       if (rank == 3){
 	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = 2; //TBC
 	pusch_config_pdu_0_1->dmrs_ports = 0; //FIXME
-	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_14[dci->antenna_ports][1];
-	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_14[dci->antenna_ports][2];
-	//pusch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_14[dci->antenna_ports][3];
-	//pusch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 1)?2:1; //FIXME
+	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_14[dci->antenna_ports.val][1];
+	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_14[dci->antenna_ports.val][2];
+	//pusch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_14[dci->antenna_ports.val][3];
+	//pusch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports.val > 1)?2:1; //FIXME
       }
       if (rank == 4){
 	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = 2; //TBC
 	pusch_config_pdu_0_1->dmrs_ports = 0; //FIXME
-	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_15[dci->antenna_ports][1];
-	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_15[dci->antenna_ports][2];
-	//pusch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_15[dci->antenna_ports][3];
-	//pusch_config_pdu_0_1->dmrs_ports[3] = table_7_3_1_1_2_15[dci->antenna_ports][4];
-	//pusch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports > 1)?2:1; //FIXME
+	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_15[dci->antenna_ports.val][1];
+	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_15[dci->antenna_ports.val][2];
+	//pusch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_15[dci->antenna_ports.val][3];
+	//pusch_config_pdu_0_1->dmrs_ports[3] = table_7_3_1_1_2_15[dci->antenna_ports.val][4];
+	//pusch_config_pdu_0_1->n_front_load_symb = (dci->antenna_ports.val > 1)?2:1; //FIXME
       }
     }
     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){
-	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports > 1)?((dci->antenna_ports > 5)?3:2):1; //TBC
-	pusch_config_pdu_0_1->dmrs_ports = (dci->antenna_ports > 1)?(dci->antenna_ports > 5 ?(dci->antenna_ports-6):(dci->antenna_ports-2)):dci->antenna_ports; //TBC
+	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 1)?((dci->antenna_ports.val > 5)?3:2):1; //TBC
+	pusch_config_pdu_0_1->dmrs_ports = (dci->antenna_ports.val > 1)?(dci->antenna_ports.val > 5 ?(dci->antenna_ports.val-6):(dci->antenna_ports.val-2)):dci->antenna_ports.val; //TBC
       }
       if (rank == 2){
-	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports > 0)?((dci->antenna_ports > 2)?3:2):1; //TBC
+	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 0)?((dci->antenna_ports.val > 2)?3:2):1; //TBC
 	pusch_config_pdu_0_1->dmrs_ports = 0; //FIXME
-	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_17[dci->antenna_ports][1];
-	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_17[dci->antenna_ports][2];
+	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_17[dci->antenna_ports.val][1];
+	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_17[dci->antenna_ports.val][2];
       }
       if (rank == 3){
-	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports > 0)?3:2; //TBC
+	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = (dci->antenna_ports.val > 0)?3:2; //TBC
 	pusch_config_pdu_0_1->dmrs_ports = 0; //FIXME
-	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_18[dci->antenna_ports][1];
-	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_18[dci->antenna_ports][2];
-	//pusch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_18[dci->antenna_ports][3];
+	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_18[dci->antenna_ports.val][1];
+	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_18[dci->antenna_ports.val][2];
+	//pusch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_18[dci->antenna_ports.val][3];
       }
       if (rank == 4){
-	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = dci->antenna_ports + 2; //TBC
+	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = dci->antenna_ports.val + 2; //TBC
 	pusch_config_pdu_0_1->dmrs_ports = 0; //FIXME
 	//pusch_config_pdu_0_1->dmrs_ports[0] = 0;
 	//pusch_config_pdu_0_1->dmrs_ports[1] = 1;
@@ -2630,53 +2634,53 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
 	(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){
-	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_20[dci->antenna_ports][0]; //TBC
-	pusch_config_pdu_0_1->dmrs_ports = table_7_3_1_1_2_20[dci->antenna_ports][1]; //TBC
-	//pusch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_20[dci->antenna_ports][2]; //FIXME
+	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_20[dci->antenna_ports.val][0]; //TBC
+	pusch_config_pdu_0_1->dmrs_ports = table_7_3_1_1_2_20[dci->antenna_ports.val][1]; //TBC
+	//pusch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_20[dci->antenna_ports.val][2]; //FIXME
       }
       if (rank == 2){
-	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_21[dci->antenna_ports][0]; //TBC
+	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_21[dci->antenna_ports.val][0]; //TBC
 	pusch_config_pdu_0_1->dmrs_ports = 0; //FIXME
-	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_21[dci->antenna_ports][1];
-	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_21[dci->antenna_ports][2];
-	//pusch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_21[dci->antenna_ports][3]; //FIXME
+	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_21[dci->antenna_ports.val][1];
+	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_21[dci->antenna_ports.val][2];
+	//pusch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_21[dci->antenna_ports.val][3]; //FIXME
       }
       if (rank == 3){
-	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_22[dci->antenna_ports][0]; //TBC
+	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_22[dci->antenna_ports.val][0]; //TBC
 	pusch_config_pdu_0_1->dmrs_ports = 0; //FIXME
-	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_22[dci->antenna_ports][1];
-	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_22[dci->antenna_ports][2];
-	//pusch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_22[dci->antenna_ports][3];
-	//pusch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_22[dci->antenna_ports][4]; //FIXME
+	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_22[dci->antenna_ports.val][1];
+	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_22[dci->antenna_ports.val][2];
+	//pusch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_22[dci->antenna_ports.val][3];
+	//pusch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_22[dci->antenna_ports.val][4]; //FIXME
       }
       if (rank == 4){
-	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_23[dci->antenna_ports][0]; //TBC
+	pusch_config_pdu_0_1->num_dmrs_cdm_grps_no_data = table_7_3_1_1_2_23[dci->antenna_ports.val][0]; //TBC
 	pusch_config_pdu_0_1->dmrs_ports = 0; //FIXME
-	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_23[dci->antenna_ports][1];
-	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_23[dci->antenna_ports][2];
-	//pusch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_23[dci->antenna_ports][3];
-	//pusch_config_pdu_0_1->dmrs_ports[3] = table_7_3_1_1_2_23[dci->antenna_ports][4];
-	//pusch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_23[dci->antenna_ports][5]; //FIXME
+	//pusch_config_pdu_0_1->dmrs_ports[0] = table_7_3_1_1_2_23[dci->antenna_ports.val][1];
+	//pusch_config_pdu_0_1->dmrs_ports[1] = table_7_3_1_1_2_23[dci->antenna_ports.val][2];
+	//pusch_config_pdu_0_1->dmrs_ports[2] = table_7_3_1_1_2_23[dci->antenna_ports.val][3];
+	//pusch_config_pdu_0_1->dmrs_ports[3] = table_7_3_1_1_2_23[dci->antenna_ports.val][4];
+	//pusch_config_pdu_0_1->n_front_load_symb = table_7_3_1_1_2_23[dci->antenna_ports.val][5]; //FIXME
       }
     }
     /* 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!!!
-    //pusch_config_pdu_0_1->srs_config.aperiodicSRS_ResourceTrigger = (dci->srs_request & 0x11); // as per Table 7.3.1.1.2-24 TS 38.212 //FIXME
+    //pusch_config_pdu_0_1->srs_config.aperiodicSRS_ResourceTrigger = (dci->srs_request.val & 0x11); // as per Table 7.3.1.1.2-24 TS 38.212 //FIXME
     /* CSI_REQUEST */
-    //pusch_config_pdu_0_1->csi_reportTriggerSize = dci->csi_request; //FIXME
+    //pusch_config_pdu_0_1->csi_reportTriggerSize = dci->csi_request.val; //FIXME
     /* CBGTI */
-    //pusch_config_pdu_0_1->maxCodeBlockGroupsPerTransportBlock = dci->cbgti; //FIXME
+    //pusch_config_pdu_0_1->maxCodeBlockGroupsPerTransportBlock = dci->cbgti.val; //FIXME
     /* 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 {
-      //pusch_config_pdu_0_1->ptrs_dmrs_association_port = dci->ptrs_dmrs; //FIXME
+      //pusch_config_pdu_0_1->ptrs_dmrs_association_port = dci->ptrs_dmrs_association.val; //FIXME
     }
     /* BETA_OFFSET_IND */
     // Table 9.3-3 in [5, TS 38.213]
-    //pusch_config_pdu_0_1->beta_offset_ind = dci->beta_offset_ind; //FIXME
+    //pusch_config_pdu_0_1->beta_offset_ind = dci->beta_offset_indicator.val; //FIXME
     /* DMRS_SEQ_INI */
     // FIXME!!
     /* UL_SCH_IND */
@@ -2746,10 +2750,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
     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);
+    nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_0,0,n_RB_DLBWP,dci->frequency_domain_assignment.val);
     /* TIME_DOM_RESOURCE_ASSIGNMENT */
     nr_ue_process_dci_time_dom_resource_assignment(mac,NULL,dlsch_config_pdu_1_0,
-						   dci->time_dom_resource_assignment);
+						   dci->time_domain_assignment.val);
 
     /* dmrs symbol positions*/
     dlsch_config_pdu_1_0->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config,
@@ -2757,7 +2761,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
 							 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;
+    dlsch_config_pdu_1_0->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping.val == 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)*/
@@ -2765,9 +2769,9 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
     /* 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;
+    dlsch_config_pdu_1_0->harq_process_nbr = dci->harq_pid;
     /* 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;
+    dlsch_config_pdu_1_0->dai = dci->dai[0].val;
     /* 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;
@@ -2776,32 +2780,32 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
     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;
+    if (dci->tpc == 0) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = -1;
+    if (dci->tpc == 1) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 0;
+    if (dci->tpc == 2) dlsch_config_pdu_1_0->accumulated_delta_PUCCH = 1;
+    if (dci->tpc == 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;
+    //if (dci->pucch_resource_indicator == 0) dlsch_config_pdu_1_0->pucch_resource_id = 1; //pucch-ResourceId obtained from the 1st value of resourceList FIXME!!!
+    //if (dci->pucch_resource_indicator == 1) dlsch_config_pdu_1_0->pucch_resource_id = 2; //pucch-ResourceId obtained from the 2nd value of resourceList FIXME!!
+    //if (dci->pucch_resource_indicator == 2) dlsch_config_pdu_1_0->pucch_resource_id = 3; //pucch-ResourceId obtained from the 3rd value of resourceList FIXME!!
+    //if (dci->pucch_resource_indicator == 3) dlsch_config_pdu_1_0->pucch_resource_id = 4; //pucch-ResourceId obtained from the 4th value of resourceList FIXME!!
+    //if (dci->pucch_resource_indicator == 4) dlsch_config_pdu_1_0->pucch_resource_id = 5; //pucch-ResourceId obtained from the 5th value of resourceList FIXME!!
+    //if (dci->pucch_resource_indicator == 5) dlsch_config_pdu_1_0->pucch_resource_id = 6; //pucch-ResourceId obtained from the 6th value of resourceList FIXME!!
+    //if (dci->pucch_resource_indicator == 6) dlsch_config_pdu_1_0->pucch_resource_id = 7; //pucch-ResourceId obtained from the 7th value of resourceList FIXME!!
+    //if (dci->pucch_resource_indicator == 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_indicator;
     /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/
-    dlsch_config_pdu_1_0->pdsch_to_harq_feedback_time_ind = dci->pdsch_to_harq_feedback_time_ind;
+    dlsch_config_pdu_1_0->pdsch_to_harq_feedback_time_ind = dci->pdsch_to_harq_feedback_timing_indicator.val;
 
     LOG_D(MAC,"(nr_ue_procedures.c) rnti = %x 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,
+	  dci->frequency_domain_assignment.val,
 	  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,
+	  dci->time_domain_assignment.val,
 	  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",
@@ -2866,145 +2870,143 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, nr
     /* BANDWIDTH_PART_IND */
     //    dlsch_config_pdu_1_1->bandwidth_part_ind = dci->bandwidth_part_ind;
     /* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */
-    nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_1,0,n_RB_DLBWP,dci->freq_dom_resource_assignment_DL);
+    nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_1,0,n_RB_DLBWP,dci->frequency_domain_assignment.val);
     /* TIME_DOM_RESOURCE_ASSIGNMENT */
     nr_ue_process_dci_time_dom_resource_assignment(mac,NULL,dlsch_config_pdu_1_1,
-						   dci->time_dom_resource_assignment);
+						   dci->time_domain_assignment.val);
+    /* dmrs symbol positions*/
+    dlsch_config_pdu_1_1->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config,
+							 mac->scc->dmrs_TypeA_Position,
+							 dlsch_config_pdu_1_1->number_symbols);
+    dlsch_config_pdu_1_1->dmrsConfigType = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 1 : 2;
     /* 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;
+      dlsch_config_pdu_1_1->vrb_to_prb_mapping = (dci->vrb_to_prb_mapping.val == 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;
+    dlsch_config_pdu_1_1->prb_bundling_size_ind = dci->prb_bundling_size_indicator.val;
     /* RATE_MATCHING_IND */
-    dlsch_config_pdu_1_1->rate_matching_ind = dci->rate_matching_ind;
+    dlsch_config_pdu_1_1->rate_matching_ind = dci->rate_matching_indicator.val;
     /* ZP_CSI_RS_TRIGGER */
-    dlsch_config_pdu_1_1->zp_csi_rs_trigger = dci->zp_csi_rs_trigger;
+    dlsch_config_pdu_1_1->zp_csi_rs_trigger = dci->zp_csi_rs_trigger.val;
     /* MCS (for transport block 1)*/
-    dlsch_config_pdu_1_1->mcs = dci->tb1_mcs;
+    dlsch_config_pdu_1_1->mcs = dci->mcs;
     /* NDI (for transport block 1)*/
-    dlsch_config_pdu_1_1->ndi = dci->tb1_ndi;
+    dlsch_config_pdu_1_1->ndi = dci->ndi;
     /* RV (for transport block 1)*/
-    dlsch_config_pdu_1_1->rv = dci->tb1_rv;
+    dlsch_config_pdu_1_1->rv = dci->rv;
     /* MCS (for transport block 2)*/
-    dlsch_config_pdu_1_1->tb2_mcs = dci->tb2_mcs;
+    dlsch_config_pdu_1_1->tb2_mcs = dci->mcs2.val;
     /* NDI (for transport block 2)*/
-    dlsch_config_pdu_1_1->tb2_ndi = dci->tb2_ndi;
+    dlsch_config_pdu_1_1->tb2_ndi = dci->ndi2.val;
     /* RV (for transport block 2)*/
-    dlsch_config_pdu_1_1->tb2_rv = dci->tb2_rv;
+    dlsch_config_pdu_1_1->tb2_rv = dci->rv2.val;
     /* HARQ_PROCESS_NUMBER */
-    dlsch_config_pdu_1_1->harq_process_nbr = dci->harq_process_number;
+    dlsch_config_pdu_1_1->harq_process_nbr = dci->harq_pid;
     /* DAI */
-    dlsch_config_pdu_1_1->dai = dci ->dai;
+    dlsch_config_pdu_1_1->dai = dci->dai[0].val;
     /* 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;
+    if (dci->tpc == 0) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = -1;
+    if (dci->tpc == 1) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 0;
+    if (dci->tpc == 2) dlsch_config_pdu_1_1->accumulated_delta_PUCCH = 1;
+    if (dci->tpc == 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!!
+    dlsch_config_pdu_1_1->pucch_resource_id = dci->pucch_resource_indicator;
     /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */
     // according to TS 38.213 Table 9.2.3-1
-    dlsch_config_pdu_1_1-> pdsch_to_harq_feedback_time_ind = mac->phy_config.config_req.ul_bwp_dedicated.pucch_config_dedicated.dl_data_to_ul_ack[dci->pdsch_to_harq_feedback_time_ind];
+    dlsch_config_pdu_1_1->pdsch_to_harq_feedback_time_ind = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->dl_DataToUL_ACK->list.array[dci->pdsch_to_harq_feedback_timing_indicator.val][0];
     /* 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];
+      dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_1[dci->antenna_ports.val][0];
+      dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_1[dci->antenna_ports.val][1];
+      dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_1[dci->antenna_ports.val][2];
+      dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_1[dci->antenna_ports.val][3];
+      dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_1[dci->antenna_ports.val][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];
+	dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports.val][0];
+	dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports.val][1];
+	dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports.val][2];
+	dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports.val][3];
+	dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports.val][4];
+	dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_2_oneCodeword[dci->antenna_ports.val][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];
+	dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports.val][0];
+	dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports.val][1];
+	dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports.val][2];
+	dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports.val][3];
+	dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports.val][4];
+	dlsch_config_pdu_1_1->dmrs_ports[4]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports.val][5];
+	dlsch_config_pdu_1_1->dmrs_ports[5]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports.val][6];
+	dlsch_config_pdu_1_1->dmrs_ports[6]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports.val][7];
+	dlsch_config_pdu_1_1->dmrs_ports[7]     = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports.val][8];
+	dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_2_twoCodeword[dci->antenna_ports.val][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];
+	dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports.val][0];
+	dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports.val][1];
+	dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports.val][2];
+	dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports.val][3];
+	dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_3_oneCodeword[dci->antenna_ports.val][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];
+	dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports.val][0];
+	dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports.val][1];
+	dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports.val][2];
+	dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports.val][3];
+	dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports.val][4];
+	dlsch_config_pdu_1_1->dmrs_ports[4]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports.val][5];
+	dlsch_config_pdu_1_1->dmrs_ports[5]     = table_7_3_2_3_3_3_twoCodeword[dci->antenna_ports.val][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];
+	dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports.val][0];
+	dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports.val][1];
+	dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports.val][2];
+	dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports.val][3];
+	dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports.val][4];
+	dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_4_oneCodeword[dci->antenna_ports.val][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];
+	dlsch_config_pdu_1_1->n_dmrs_cdm_groups = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports.val][0];
+	dlsch_config_pdu_1_1->dmrs_ports[0]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports.val][1];
+	dlsch_config_pdu_1_1->dmrs_ports[1]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports.val][2];
+	dlsch_config_pdu_1_1->dmrs_ports[2]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports.val][3];
+	dlsch_config_pdu_1_1->dmrs_ports[3]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports.val][4];
+	dlsch_config_pdu_1_1->dmrs_ports[4]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports.val][5];
+	dlsch_config_pdu_1_1->dmrs_ports[5]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports.val][6];
+	dlsch_config_pdu_1_1->dmrs_ports[6]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports.val][7];
+	dlsch_config_pdu_1_1->dmrs_ports[7]     = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports.val][8];
+	dlsch_config_pdu_1_1->n_front_load_symb = table_7_3_2_3_3_4_twoCodeword[dci->antenna_ports.val][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;
+      dlsch_config_pdu_1_1->tci_state = dci->transmission_configuration_indication.val;
     }
     /* 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
+    dlsch_config_pdu_1_1->srs_config.aperiodicSRS_ResourceTrigger = (dci->srs_request.val & 0x11); // as per Table 7.3.1.1.2-24 TS 38.212
     /* CBGTI */
-    dlsch_config_pdu_1_1->cbgti = dci->cbgti;
+    dlsch_config_pdu_1_1->cbgti = dci->cbgti.val;
     /* CBGFI */
-    dlsch_config_pdu_1_1->codeBlockGroupFlushIndicator = dci->cbgfi;
+    dlsch_config_pdu_1_1->codeBlockGroupFlushIndicator = dci->cbgfi.val;
     /* DMRS_SEQ_INI */
     //FIXME!!!
 
@@ -3103,7 +3105,7 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
 			 uint8_t dci_size,
 			 uint16_t rnti,
 			 uint64_t *dci_pdu,
-			 nr_dci_pdu_rel15_t *dci_pdu_rel15) {
+			 dci_pdu_rel15_t *dci_pdu_rel15) {
   int rnti_type=-1;
 
   if       (rnti == mac->ra_rnti) rnti_type = NR_RNTI_RA;
@@ -3115,10 +3117,10 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
   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) ? 
+  int N_RB = (mac->scg != 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) ? 
+  int N_RB_UL = (mac->scg != NULL) ? 
     NRRIV2BW(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth,275) :
     NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth,275);
 
@@ -3132,22 +3134,22 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
       // 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);
+      dci_pdu_rel15->frequency_domain_assignment.val = *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);
+      LOG_D(MAC,"frequency-domain assignment %d (%d bits) N_RB_BWP %d=> %d (0x%lx)\n",dci_pdu_rel15->frequency_domain_assignment.val,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;
+      dci_pdu_rel15->time_domain_assignment.val = (*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);
+      LOG_D(MAC,"time-domain assignment %d  (3 bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_domain_assignment.val,dci_size-pos,*dci_pdu);
 #endif
       // VRB to PRB mapping
 	
       pos++;
-      dci_pdu_rel15->vrb_to_prb_mapping = (*dci_pdu>>(dci_size-pos))&0x1;
+      dci_pdu_rel15->vrb_to_prb_mapping.val = (*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);
+      LOG_D(MAC,"vrb to prb mapping %d  (1 bits)=> %d (0x%lx)\n",dci_pdu_rel15->vrb_to_prb_mapping.val,dci_size-pos,*dci_pdu);
 #endif
       // MCS
       pos+=5;
@@ -3169,23 +3171,23 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
 	
       // indicating a DL DCI format 1bit
       pos++;
-      dci_pdu_rel15->identifier_dci_formats = (*dci_pdu>>(dci_size-pos))&1;
+      dci_pdu_rel15->format_indicator = (*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);
+      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);
 #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);
+      dci_pdu_rel15->frequency_domain_assignment.val = (*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);
+      LOG_D(MAC,"Freq domain assignment %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->frequency_domain_assignment.val,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)) {
+	if (!((dci_pdu_rel15->frequency_domain_assignment.val>>i)&1)) {
 	  is_ra = 0;
 	  break;
 	}
@@ -3197,7 +3199,7 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
 	    
 	  // UL/SUL indicator  1 bit
 	  pos++;
-	  dci_pdu_rel15->sul_ind_0_1 = (*dci_pdu>>(dci_size-pos))&1;
+	  dci_pdu_rel15->ul_sul_indicator.val = (*dci_pdu>>(dci_size-pos))&1;
 	    
 	  // SS/PBCH index  6 bits
 	  pos+=6;
@@ -3213,16 +3215,16 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
 	// Time domain assignment 4bit
 		  
 	pos+=4;
-	dci_pdu_rel15->time_dom_resource_assignment = (*dci_pdu>>(dci_size-pos))&0xf;
+	dci_pdu_rel15->time_domain_assignment.val = (*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);
+	LOG_D(MAC,"Time domain assignment %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_domain_assignment.val,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;
+	dci_pdu_rel15->vrb_to_prb_mapping.val = (*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);
+	LOG_D(MAC,"VRB to PRB %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->vrb_to_prb_mapping.val,1,dci_size-pos,*dci_pdu);
 #endif
 	
 	// MCS 5bit  //bit over 32, so dci_pdu ++
@@ -3248,37 +3250,37 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
 	  
 	// HARQ process number  4bit
 	pos+=4;
-	dci_pdu_rel15->harq_process_number  = (*dci_pdu>>(dci_size-pos))&0xf;
+	dci_pdu_rel15->harq_pid  = (*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);
+	LOG_D(MAC,"HARQ_PID %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->harq_pid,4,dci_size-pos,*dci_pdu);
 #endif
 	  
 	// Downlink assignment index  2bit
 	pos+=2;
-	dci_pdu_rel15->dai = (*dci_pdu>>(dci_size-pos))&3;
+	dci_pdu_rel15->dai[0].val = (*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);
+	LOG_D(MAC,"DAI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->dai[0].val,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;
+	dci_pdu_rel15->tpc = (*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);
+	LOG_D(MAC,"TPC %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->tpc,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;
+	dci_pdu_rel15->pucch_resource_indicator = (*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);
+	LOG_D(MAC,"PUCCH RI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->pucch_resource_indicator,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;
+	dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = (*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);
+	LOG_D(MAC,"PDSCH to HARQ TI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val,3,dci_size-pos,*dci_pdu);
 #endif
 	  
       } //end else
@@ -3300,7 +3302,7 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
       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++);
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val&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++);
@@ -3322,7 +3324,7 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
       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++);
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val&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++);
@@ -3335,16 +3337,16 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
     case NR_RNTI_TC:
       // indicating a DL DCI format 1bit
       pos++;
-      dci_pdu_rel15->identifier_dci_formats = (*dci_pdu>>(dci_size-pos))&1;
+      dci_pdu_rel15->format_indicator = (*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);
+      dci_pdu_rel15->frequency_domain_assignment.val = (*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;
+      dci_pdu_rel15->time_domain_assignment.val = (*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;
+      dci_pdu_rel15->vrb_to_prb_mapping.val = (*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;
@@ -3355,16 +3357,16 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
       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;
+      dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf;
       // Downlink assignment index – 2 bits
       pos+=2;
-      dci_pdu_rel15->dai = (*dci_pdu>>(dci_size-pos))&3;
+      dci_pdu_rel15->dai[0].val = (*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;
+      dci_pdu_rel15->tpc  = (*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;
+      dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = (*dci_pdu>>(dci_size-pos))&7;
        
       break;
     }
@@ -3375,17 +3377,17 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
       {
       case NR_RNTI_C:
 	// indicating a DL DCI format 1bit
-	dci_pdu_rel15->identifier_dci_formats = (*dci_pdu>>(dci_size-pos))&1;
+	dci_pdu_rel15->format_indicator = (*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);
+	dci_pdu_rel15->frequency_domain_assignment.val = (*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;
+	dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&0xf;
 	// Frequency hopping flag – 1 bit
 	pos++;
-	dci_pdu_rel15->freq_hopping_flag= (*dci_pdu>>(dci_size-pos))&1;
+	dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1;
 	// MCS  5 bit
 	pos+=5;
 	dci_pdu_rel15->mcs= (*dci_pdu>>(dci_size-pos))&0x1f;
@@ -3397,10 +3399,10 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
 	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;
+	dci_pdu_rel15->harq_pid = (*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;
+	dci_pdu_rel15->tpc = (*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)
@@ -3447,6 +3449,90 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
 	
       }
     break;
+
+  case NR_DL_DCI_FORMAT_1_1:
+    // Format indicator
+    pos=1;
+    dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1;
+    // Carrier indicator
+    pos+=dci_pdu_rel15->carrier_indicator.nbits;
+    dci_pdu_rel15->carrier_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->carrier_indicator.nbits)-1);
+    // BWP Indicator
+    pos+=dci_pdu_rel15->bwp_indicator.nbits;
+    dci_pdu_rel15->bwp_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->bwp_indicator.nbits)-1);
+    // Frequency domain resource assignment
+    pos+=dci_pdu_rel15->frequency_domain_assignment.nbits;
+    dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->frequency_domain_assignment.nbits)-1);
+    // Time domain resource assignment
+    pos+=dci_pdu_rel15->time_domain_assignment.nbits;
+    dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->time_domain_assignment.nbits)-1);
+    // VRB-to-PRB mapping
+    pos+=dci_pdu_rel15->vrb_to_prb_mapping.nbits;
+    dci_pdu_rel15->vrb_to_prb_mapping.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->vrb_to_prb_mapping.nbits)-1);
+    // PRB bundling size indicator
+    pos+=dci_pdu_rel15->prb_bundling_size_indicator.nbits;
+    dci_pdu_rel15->prb_bundling_size_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->prb_bundling_size_indicator.nbits)-1);
+    // Rate matching indicator
+    pos+=dci_pdu_rel15->rate_matching_indicator.nbits;
+    dci_pdu_rel15->rate_matching_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->rate_matching_indicator.nbits)-1);
+    // ZP CSI-RS trigger
+    pos+=dci_pdu_rel15->zp_csi_rs_trigger.nbits;
+    dci_pdu_rel15->zp_csi_rs_trigger.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->zp_csi_rs_trigger.nbits)-1);
+    //TB1
+    // MCS 5bit
+    pos+=5;
+    dci_pdu_rel15->mcs = (*dci_pdu>>(dci_size-pos))&0x1f;
+    // New data indicator 1bit
+    pos+=1;
+    dci_pdu_rel15->ndi = (*dci_pdu>>(dci_size-pos))&0x1;
+    // Redundancy version  2bit
+    pos+=2;
+    dci_pdu_rel15->rv = (*dci_pdu>>(dci_size-pos))&0x3;
+    //TB2
+    // MCS 5bit
+    pos+=dci_pdu_rel15->mcs2.nbits;
+    dci_pdu_rel15->mcs2.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->mcs2.nbits)-1);
+    // New data indicator 1bit
+    pos+=dci_pdu_rel15->ndi2.nbits;
+    dci_pdu_rel15->ndi2.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->ndi2.nbits)-1);
+    // Redundancy version  2bit
+    pos+=dci_pdu_rel15->rv2.nbits;
+    dci_pdu_rel15->rv2.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->rv2.nbits)-1);
+    // HARQ process number  4bit
+    pos+=4;
+    dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf;
+    // Downlink assignment index
+    pos+=dci_pdu_rel15->dai[0].nbits;
+    dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->dai[0].nbits)-1);
+    // TPC command for scheduled PUCCH  2bit
+    pos+=2;
+    dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&0x3;
+    // PUCCH resource indicator  3bit
+    pos+=3;
+    dci_pdu_rel15->pucch_resource_indicator = (*dci_pdu>>(dci_size-pos))&0x3;
+    // PDSCH-to-HARQ_feedback timing indicator
+    pos+=dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.nbits;
+    dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.nbits)-1);
+    // Antenna ports
+    pos+=dci_pdu_rel15->antenna_ports.nbits;
+    dci_pdu_rel15->antenna_ports.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->antenna_ports.nbits)-1);
+    // TCI
+    pos+=dci_pdu_rel15->transmission_configuration_indication.nbits;
+    dci_pdu_rel15->transmission_configuration_indication.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->transmission_configuration_indication.nbits)-1);
+    // SRS request
+    pos+=dci_pdu_rel15->srs_request.nbits;
+    dci_pdu_rel15->srs_request.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->srs_request.nbits)-1);
+    // CBG transmission information
+    pos+=dci_pdu_rel15->cbgti.nbits;
+    dci_pdu_rel15->cbgti.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->cbgti.nbits)-1);
+    // CBG flushing out information
+    pos+=dci_pdu_rel15->cbgfi.nbits;
+    dci_pdu_rel15->cbgfi.val = (*dci_pdu>>(dci_size-pos))&((1<<dci_pdu_rel15->cbgfi.nbits)-1);
+    // DMRS sequence init
+    pos+=1;
+    dci_pdu_rel15->dmrs_sequence_initialization = (*dci_pdu>>(dci_size-pos))&0x1;
+    break;
+
   }
 }
 
diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c
index af75e6afff32112e28537d3974ea031a0ebbfdd8..36b81927f80e95283b2b2ab339340e9970fcd1ae 100644
--- a/openair2/LAYER2/NR_MAC_gNB/config.c
+++ b/openair2/LAYER2/NR_MAC_gNB/config.c
@@ -290,8 +290,7 @@ void config_common(int Mod_idP, int pdsch_AntennaPorts, NR_ServingCellConfigComm
                     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
-                  );
+                    scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols);
 
   if (return_tdd !=0){
      LOG_E(PHY,"TDD configuration can not be done\n");
@@ -374,6 +373,12 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
     if (add_ue == 1) {
       UE_id = add_new_nr_ue(Mod_idP,rnti);
       UE_list->secondaryCellGroup[UE_id] = secondaryCellGroup;
+      uint8_t num_preamble = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.count;
+      UE_list->preambles[UE_id].num_preambles = num_preamble;
+      UE_list->preambles[UE_id].preamble_list = (uint8_t *) malloc(num_preamble*sizeof(uint8_t));
+      for (int i=0; i<num_preamble; i++) {
+        UE_list->preambles[UE_id].preamble_list[i] = secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list.array[i]->ra_PreambleIndex;
+      }
       LOG_I(PHY,"Added new UE_id %d/%x with initial secondaryCellGroup\n",UE_id,rnti);
     }
     else { // secondaryCellGroup has been updated
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
index 9642d6db8039b02eab0ddc54470388045444317e..61eface5bcab1974c866327bcdaeb86a1f060e73 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c
@@ -59,6 +59,7 @@
 
 #include "executables/softmodem-common.h"
 
+const uint8_t slots_per_frame[5] = {10, 20, 40, 80, 160};
 uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 };
 
 void clear_nr_nfapi_information(gNB_MAC_INST * gNB,
@@ -304,12 +305,14 @@ void nr_schedule_pucch(int Mod_idP,
   NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1];
   nfapi_nr_ul_tti_request_t *UL_tti_req = &RC.nrmac[Mod_idP]->UL_tti_req[0];
 
-  NR_sched_pucch *curr_pucch = UE_list->UE_sched_ctrl[UE_id].sched_pucch;
-  NR_sched_pucch *temp_pucch;
-  int release_pucch = 0;
+  NR_sched_pucch *curr_pucch;
+  int nr_ulmix_slots = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots;
+  if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols!=0)
+    nr_ulmix_slots++;
 
-  if (curr_pucch != NULL) {
-    if ((frameP == curr_pucch->frame) && (slotP == curr_pucch->ul_slot)) {
+  for (int k=0; k<nr_ulmix_slots; k++) {
+    curr_pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[k];
+    if ((curr_pucch->dai_c > 0) && (frameP == curr_pucch->frame) && (slotP == curr_pucch->ul_slot)) {
       UL_tti_req->SFN = frameP;
       UL_tti_req->Slot = slotP;
       UL_tti_req->pdus_list[UL_tti_req->n_pdus].pdu_type = NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE;
@@ -320,6 +323,8 @@ void nr_schedule_pucch(int Mod_idP,
       O_ack = curr_pucch->dai_c;
       O_uci = O_ack; // for now we are just sending acknacks in pucch
 
+      LOG_I(MAC, "Scheduling pucch reception for frame %d slot %d\n", frameP, slotP);
+
       nr_configure_pucch(pucch_pdu,
 			 scc,
 			 ubwp,
@@ -328,16 +333,9 @@ void nr_schedule_pucch(int Mod_idP,
                          O_ack,
                          SR_flag);
 
-      release_pucch = 1;
+      curr_pucch->dai_c = 0;
     }
   }
-
-  if (release_pucch) {
-    temp_pucch = UE_list->UE_sched_ctrl[UE_id].sched_pucch;
-    UE_list->UE_sched_ctrl[UE_id].sched_pucch = UE_list->UE_sched_ctrl[UE_id].sched_pucch->next_sched_pucch;
-    free(temp_pucch);
-  }
-
 }
 
 bool is_xlsch_in_slot(uint64_t bitmap, sub_frame_t slot){
@@ -358,11 +356,34 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
 			       
   protocol_ctxt_t   ctxt;
   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;
+ 
+  int CC_id;
+  int UE_id;
+  uint64_t *dlsch_in_slot_bitmap=NULL;
+  uint64_t *ulsch_in_slot_bitmap=NULL;
+  int pucch_sched;
+
+  UE_id=0;
+  int bwp_id = 1;
+
   gNB_MAC_INST *gNB = RC.nrmac[module_idP];
   NR_UE_list_t *UE_list = &gNB->UE_list;
+  NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
   NR_COMMON_channels_t *cc = gNB->common_channels;
-  NR_sched_pucch *pucch_sched = (NR_sched_pucch*) malloc(sizeof(NR_sched_pucch));
+  NR_ServingCellConfigCommon_t        *scc     = cc->ServingCellConfigCommon;
+  int num_slots_per_tdd = (slots_per_frame[*scc->ssbSubcarrierSpacing])>>(7-scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity);
+
+  int nr_ulmix_slots = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots;
+  if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols!=0)
+    nr_ulmix_slots++;
+
+  if (slot_txP== 0 && (UE_list->fiveG_connected[UE_id] || get_softmodem_params()->phy_test)) {
+    for (int k=0; k<nr_ulmix_slots; k++) {
+      memset((void *) &UE_list->UE_sched_ctrl[UE_id].sched_pucch[k],
+             0,
+             sizeof(NR_sched_pucch));
+    }
+  }
 
   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);
@@ -373,10 +394,29 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
   RC.nrmac[module_idP]->frame    = frame_rxP;
   RC.nrmac[module_idP]->slot     = slot_rxP;
 
+  dlsch_in_slot_bitmap = &RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[UE_id].dlsch_in_slot_bitmap;  // static bitmap signaling which slot in a tdd period contains dlsch
+  ulsch_in_slot_bitmap = &RC.nrmac[module_idP]->UE_list.UE_sched_ctrl[UE_id].ulsch_in_slot_bitmap;  // static bitmap signaling which slot in a tdd period contains ulsch
+
+  // hardcoding dlsch to be in slot 1
+  if (!(slot_txP%num_slots_per_tdd)) {
+    if(slot_txP==0)
+      *dlsch_in_slot_bitmap = 0x02;
+    else
+      *dlsch_in_slot_bitmap = 0x00;
+  }
+
+  // hardcoding ulsch to be in slot 8
+  if (!(slot_rxP%num_slots_per_tdd)) {
+    if(slot_rxP==0)
+      *ulsch_in_slot_bitmap = 0x100;
+    else
+      *ulsch_in_slot_bitmap = 0x00;
+  }
+
   // 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));
+    memset(RC.nrmac[module_idP]->cce_list[bwp_id][0],0,MAX_NUM_CCE*sizeof(int)); // coreset0
+    memset(RC.nrmac[module_idP]->cce_list[bwp_id][1],0,MAX_NUM_CCE*sizeof(int)); // coresetid 1
     for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
       //mbsfn_status[CC_id] = 0;
 
@@ -392,7 +432,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
     for (i = 0; i < MAX_MOBILES_PER_GNB; i++) {
       if (UE_list->active[i]) {
 
-        nfapi_nr_config_request_t *cfg = &RC.nrmac[module_idP]->config[CC_id];
+        nfapi_nr_config_request_t *cfg = &RC.nrmac[module_idP]->config[CC_id];      
       
         rnti = 0;//UE_RNTI(module_idP, i);
         CC_id = 0;//UE_PCCID(module_idP, i);
@@ -406,9 +446,14 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
       schedule_nr_mib(module_idP, frame_txP, slot_txP);
     }
 
+    if (get_softmodem_params()->phy_test == 0)
+      nr_schedule_RA(module_idP, frame_txP, slot_txP);
+    else
+      UE_list->fiveG_connected[UE_id] = true;
+
     // Phytest scheduling
+
     if (get_softmodem_params()->phy_test) {
-      NR_UE_sched_ctrl_t *ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id];
 
       // TbD once RACH is available, start ta_timer when UE is connected
       if (ue_sched_ctl->ta_timer)
@@ -424,16 +469,15 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
         /* MAC CE flag indicating TA length */
         gNB->ta_len = 2;
       }
-
-      if (slot_txP == 1){
-        nr_schedule_uss_dlsch_phytest(module_idP, frame_txP, slot_txP, pucch_sched, NULL);
-        // resetting ta flag
-        gNB->ta_len = 0;
-      }
     }
 
-    if (get_softmodem_params()->phy_test == 0)
-      nr_schedule_RA(module_idP, frame_txP, slot_txP);
+    if (UE_list->fiveG_connected[UE_id] && (is_xlsch_in_slot(*dlsch_in_slot_bitmap,slot_txP%num_slots_per_tdd))) {
+      ue_sched_ctl->current_harq_pid = slot_txP % num_slots_per_tdd;
+      nr_update_pucch_scheduling(module_idP, UE_id, frame_txP, slot_txP, num_slots_per_tdd,&pucch_sched);
+      nr_schedule_uss_dlsch_phytest(module_idP, frame_txP, slot_txP, &UE_list->UE_sched_ctrl[UE_id].sched_pucch[pucch_sched], NULL);
+      // resetting ta flag
+      gNB->ta_len = 0;
+    }
 
     /*
     // Allocate CCEs for good after scheduling is done
@@ -446,11 +490,16 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
   if (is_nr_UL_slot(cc->ServingCellConfigCommon,slot_rxP)) { 
 
     if (get_softmodem_params()->phy_test == 0) {
+      if (UE_list->fiveG_connected[UE_id])
+        nr_schedule_pucch(module_idP, UE_id, frame_rxP, slot_rxP);
       schedule_nr_prach(module_idP, (frame_rxP+1)&1023, slot_rxP);
       nr_schedule_reception_msg3(module_idP, 0, frame_rxP, slot_rxP);
     }
-    if (get_softmodem_params()->phy_test && slot_rxP==8){
-      nr_schedule_uss_ulsch_phytest(module_idP, frame_rxP, slot_rxP);
+    if (get_softmodem_params()->phy_test){
+      nr_schedule_pucch(module_idP, UE_id, frame_rxP, slot_rxP);
+      if (is_xlsch_in_slot(*ulsch_in_slot_bitmap,slot_rxP%num_slots_per_tdd)){
+        nr_schedule_uss_ulsch_phytest(module_idP, frame_rxP, slot_rxP);
+      }
     }
   }
 
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
index 6ce72059fde3d75e934b573ca241fa1332d06b33..db93734a7ddc11d9315212fd1bc9e4bad3bf1594 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
@@ -42,7 +42,9 @@
 #include "SIMULATION/TOOLS/sim.h" // for taus
 
 extern RAN_CONTEXT_t RC;
-extern const uint16_t nr_slots_per_frame[5];
+
+const uint8_t nr_slots_per_frame_mac[5] = {10, 20, 40, 80, 160};
+
 uint8_t DELTA[4]= {2,3,4,6};
 
 void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) {
@@ -183,7 +185,7 @@ void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot,
     tdd_period_slot++;
 
   // computing start of next period
-  uint8_t start_next_period = (rach_slot-(rach_slot%tdd_period_slot)+tdd_period_slot)%nr_slots_per_frame[mu];
+  uint8_t start_next_period = (rach_slot-(rach_slot%tdd_period_slot)+tdd_period_slot)%nr_slots_per_frame_mac[mu];
   *msg2_slot = start_next_period + last_dl_slot_period; // initializing scheduling of slot to next mixed (or last dl) slot
   *msg2_frame = (*msg2_slot>(rach_slot))? rach_frame : (rach_frame +1);
 
@@ -215,15 +217,16 @@ void nr_schedule_msg2(uint16_t rach_frame, uint16_t rach_slot,
     default:
       AssertFatal(1==0,"Invalid response window value %d\n",response_window);
   }
-  AssertFatal(slot_window<=nr_slots_per_frame[mu],"Msg2 response window needs to be lower or equal to 10ms");
+  AssertFatal(slot_window<=nr_slots_per_frame_mac[mu],"Msg2 response window needs to be lower or equal to 10ms");
 
   // slot and frame limit to transmit msg2 according to response window
-  uint8_t slot_limit = (rach_slot + slot_window)%nr_slots_per_frame[mu];
+  uint8_t slot_limit = (rach_slot + slot_window)%nr_slots_per_frame_mac[mu];
   //uint8_t frame_limit = (slot_limit>(rach_slot))? rach_frame : (rach_frame +1);
 
+
   // go to previous slot if the current scheduled slot is beyond the response window
   // and if the slot is not among the PDCCH monitored ones (38.213 10.1)
-  while ((*msg2_slot>slot_limit) || ((*msg2_frame*nr_slots_per_frame[mu]+*msg2_slot-monitoring_offset)%monitoring_slot_period !=0))  {
+  while ((*msg2_slot>slot_limit) || ((*msg2_frame*nr_slots_per_frame_mac[mu]+*msg2_slot-monitoring_offset)%monitoring_slot_period !=0))  {
     if((*msg2_slot%tdd_period_slot) > 0)
       (*msg2_slot)--;
     else
@@ -243,18 +246,35 @@ void nr_initiate_ra_proc(module_id_t module_idP,
 
   uint8_t ul_carrier_id = 0; // 0 for NUL 1 for SUL
   NR_SearchSpace_t *ss;
-
+  int UE_id = 0;
   // ra_rnti from 5.1.3 in 38.321
   uint16_t ra_rnti=1+symbol+(slotP*14)+(freq_index*14*80)+(ul_carrier_id*14*80*8);
 
   uint16_t msg2_frame, msg2_slot,monitoring_slot_period,monitoring_offset;
   gNB_MAC_INST *nr_mac = RC.nrmac[module_idP];
   NR_UE_list_t *UE_list = &nr_mac->UE_list;
-  NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[0];
+  NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
   NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id];
   NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
   NR_RA_t *ra = &cc->ra[0];
 
+  // if the preamble received correspond to one of the listed
+  // the UE sent a RACH either for starting RA procedure or RA procedure failed and UE retries
+  int pr_found=0;
+  for (int i=0;i<UE_list->preambles[UE_id].num_preambles;i++) {
+    if (preamble_index == UE_list->preambles[UE_id].preamble_list[i]) {
+      pr_found=1;
+      break;
+    }
+  }
+  if (pr_found)
+    UE_list->fiveG_connected[UE_id] = false;
+  else {
+    LOG_E(MAC, "[gNB %d][RAPROC] FAILURE: preamble %d does not correspond to any of the ones in rach_ConfigDedicated for UE_id %d\n",
+          module_idP, preamble_index, UE_id);
+    return; // if the PRACH preamble does not correspond to any of the ones sent through RRC abort RA proc
+  }
+
   // This should be handled differently when we use the initialBWP for RA
   ra->bwp_id=1;
   NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1];
@@ -304,7 +324,7 @@ void nr_initiate_ra_proc(module_id_t module_idP,
 
     ra->RA_rnti = ra_rnti;
     ra->preamble_index = preamble_index;
-
+    UE_list->tc_rnti[UE_id] = ra->rnti;
 
     LOG_I(MAC,"[gNB %d][RAPROC] CC_id %d Frame %d Activating Msg2 generation in frame %d, slot %d using RA rnti %x\n",
       module_idP,
@@ -377,11 +397,11 @@ void nr_get_Msg3alloc(NR_ServingCellConfigCommon_t *scc,
   uint8_t k2 = *ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2;
 
   temp_slot = current_slot + k2 + DELTA[mu]; // msg3 slot according to 8.3 in 38.213
-  ra->Msg3_slot = temp_slot%nr_slots_per_frame[mu];
-  if (nr_slots_per_frame[mu]>temp_slot)
+  ra->Msg3_slot = temp_slot%nr_slots_per_frame_mac[mu];
+  if (nr_slots_per_frame_mac[mu]>temp_slot)
     ra->Msg3_frame = current_frame;
   else
-    ra->Msg3_frame = current_frame + (temp_slot/nr_slots_per_frame[mu]);
+    ra->Msg3_frame = current_frame + (temp_slot/nr_slots_per_frame_mac[mu]);
 
   ra->msg3_nb_rb = 18;
   ra->msg3_first_rb = 0;
@@ -402,6 +422,7 @@ void nr_schedule_reception_msg3(module_id_t module_idP, int CC_id, frame_t frame
       ul_req->pdus_list[ul_req->n_pdus].pdu_size = sizeof(nfapi_nr_pusch_pdu_t);
       ul_req->pdus_list[ul_req->n_pdus].pusch_pdu = ra->pusch_pdu;
       ul_req->n_pdus+=1;
+      ra->state = RA_IDLE;
     }
   }
 }
@@ -517,16 +538,15 @@ void nr_generate_Msg2(module_id_t module_idP,
                       frame_t frameP,
                       sub_frame_t slotP){
 
-  int UE_id = 0, dci_formats[2], rnti_types[2], CCEIndex, mcsIndex;
+  int UE_id = 0, dci_formats[2], rnti_types[2], mcsIndex;
   int startSymbolAndLength = 0, StartSymbolIndex = -1, NrOfSymbols = 14, StartSymbolIndex_tmp, NrOfSymbols_tmp, x_Overhead, time_domain_assignment;
-  int coreset_id, aggregation , search_space_type = 0;
   gNB_MAC_INST                      *nr_mac = RC.nrmac[module_idP];
   NR_COMMON_channels_t                  *cc = &nr_mac->common_channels[0];
   NR_RA_t                               *ra = &cc->ra[0];
   NR_UE_list_t                     *UE_list = &nr_mac->UE_list;
   NR_SearchSpace_t *ss = ra->ra_ss;
 
-  uint16_t RA_rnti = ra->RA_rnti, numDlDci;
+  uint16_t RA_rnti = ra->RA_rnti;
   long locationAndBandwidth;
   // uint8_t *vrb_map = cc[CC_id].vrb_map, CC_id;
 
@@ -561,20 +581,11 @@ void nr_generate_Msg2(module_id_t module_idP,
 
     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;
-    nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu_rel15->dci_pdu;
-    numDlDci = pdcch_pdu_rel15->numDlDci;
-
-    aggregation = find_aggregation_level(ss);
-    coreset_id = *ss->controlResourceSetId;
 
     // Checking if the DCI allocation is feasible in current subframe
     if (dl_req->nPDUs == NFAPI_NR_MAX_DL_TTI_PDUS) {
       LOG_I(MAC, "[RAPROC] Subframe %d: FAPI DL structure is full, skip scheduling UE %d\n", slotP, RA_rnti);
       return;
-    } else {
-      LOG_D(MAC, "[RAPROC] Subframe %d: Checking CCE feasibility format : (%x,%d) \n", slotP, RA_rnti, aggregation);
-      CCEIndex = allocate_nr_CCEs(nr_mac, ra->bwp_id, coreset_id, aggregation, search_space_type, UE_id, 0);
-      AssertFatal(CCEIndex >= 0,"CCEIndex is negative %d\n",CCEIndex);
     }
 
     LOG_I(MAC,"[gNB %d] [RAPROC] CC_id %d Frame %d, slotP %d: Generating RAR DCI, state %d\n", module_idP, CC_id, frameP, slotP, ra->state);
@@ -645,34 +656,27 @@ void nr_generate_Msg2(module_id_t module_idP,
     pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(NULL, scc->dmrs_TypeA_Position, 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,
+    dci_pdu_rel15[0].frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu_rel15->rbSize,
 										     pdsch_pdu_rel15->rbStart,dci10_bw);
-    dci_pdu_rel15[0].time_domain_assignment = time_domain_assignment;
-    dci_pdu_rel15[0].vrb_to_prb_mapping = 0;
+    dci_pdu_rel15[0].time_domain_assignment.val = time_domain_assignment;
+    dci_pdu_rel15[0].vrb_to_prb_mapping.val = 0;
     dci_pdu_rel15[0].mcs = pdsch_pdu_rel15->mcsIndex[0];
     dci_pdu_rel15[0].tb_scaling = 0;
 
     LOG_I(MAC, "[RAPROC] DCI type 1 payload: freq_alloc %d (%d,%d,%d), time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d \n",
-	  dci_pdu_rel15[0].frequency_domain_assignment,
+	  dci_pdu_rel15[0].frequency_domain_assignment.val,
 	  pdsch_pdu_rel15->rbStart,
 	  pdsch_pdu_rel15->rbSize,
 	  dci10_bw,
-	  dci_pdu_rel15[0].time_domain_assignment,
-	  dci_pdu_rel15[0].vrb_to_prb_mapping,
+	  dci_pdu_rel15[0].time_domain_assignment.val,
+	  dci_pdu_rel15[0].vrb_to_prb_mapping.val,
 	  dci_pdu_rel15[0].mcs,
 	  dci_pdu_rel15[0].tb_scaling);
 
-    nr_configure_pdcch(pdcch_pdu_rel15, 0, ss, scc, bwp);
+    nr_configure_pdcch(nr_mac, pdcch_pdu_rel15, RA_rnti, 0, ss, scc, bwp);
 
-    LOG_I(MAC, "Frame %d: Subframe %d : Adding common DL DCI for RA_RNTI %x CCEIndex %d\n", frameP, slotP, RA_rnti, CCEIndex);
+    LOG_I(MAC, "Frame %d: Subframe %d : Adding common DL DCI for RA_RNTI %x\n", frameP, slotP, RA_rnti);
 
-    dci_pdu->RNTI[numDlDci] = RA_rnti;
-    dci_pdu->ScramblingId[numDlDci] = *scc->physCellId;
-    dci_pdu->ScramblingRNTI[numDlDci] = 0;
-    dci_pdu->AggregationLevel[numDlDci] = aggregation;
-    dci_pdu->CceIndex[numDlDci] = CCEIndex;
-    dci_pdu->beta_PDCCH_1_0[numDlDci] = 0;
-    dci_pdu->powerControlOffsetSS[numDlDci] = 1;
     dci_formats[0] = NR_DL_DCI_FORMAT_1_0;
     rnti_types[0] = NR_RNTI_RA;
 
@@ -684,9 +688,7 @@ void nr_generate_Msg2(module_id_t module_idP,
       pdcch_pdu_rel15->StartSymbolIndex,
       pdcch_pdu_rel15->DurationSymbols);
 
-    pdcch_pdu_rel15->numDlDci++;
-    dci_pdu->PayloadSizeBits[0] = nr_dci_size(dci_formats[0], rnti_types[0], dci10_bw);
-    fill_dci_pdu_rel15(pdcch_pdu_rel15, &dci_pdu_rel15[0], dci_formats, rnti_types,dci10_bw);
+    fill_dci_pdu_rel15(secondaryCellGroup,pdcch_pdu_rel15, &dci_pdu_rel15[0], dci_formats, rnti_types,dci10_bw,ra->bwp_id);
 
     dl_req->nPDUs+=2;
 
@@ -698,7 +700,7 @@ void nr_generate_Msg2(module_id_t module_idP,
     LOG_D(MAC,"[gNB %d][RAPROC] Frame %d, Subframe %d: RA state %d\n", module_idP, frameP, slotP, ra->state);
 
     x_Overhead = 0;
-    nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, x_Overhead, 1, dci_pdu_rel15[0].tb_scaling);
+    nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, x_Overhead, pdsch_pdu_rel15->numDmrsCdmGrpsNoData, dci_pdu_rel15[0].tb_scaling);
 
     // DL TX request
     tx_req->PDU_length = pdsch_pdu_rel15->TBSize[0];
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
index 8bbb99c3aeb4be39efdf468275553a6d16a35807..338c94776b04f37925134db32e2ce782670e14dd 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c
@@ -250,11 +250,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t   module_idP,
 }
 
 
-
-
-
 int configure_fapi_dl_pdu(int Mod_idP,
-                          int *CCEIndex,
                           nfapi_nr_dl_tti_request_body_t *dl_req,
                           NR_sched_pucch *pucch_sched,
                           uint8_t *mcsIndex,
@@ -262,13 +258,18 @@ int configure_fapi_dl_pdu(int Mod_idP,
                           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;
+
+  int TBS;
+  int bwp_id=1;
+  int UE_id = 0;
+
   NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list;
 
   NR_CellGroupConfig_t *secondaryCellGroup = UE_list->secondaryCellGroup[UE_id];
@@ -280,10 +281,6 @@ int configure_fapi_dl_pdu(int Mod_idP,
   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;
-  // TO BE FIXED we are just selecting the first search space here (only one is configured)
-  ss=bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[0];
-
 
   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));
@@ -312,11 +309,12 @@ int configure_fapi_dl_pdu(int Mod_idP,
 
   pdsch_pdu_rel15->NrOfCodewords = 1;
   int mcs = (mcsIndex!=NULL) ? *mcsIndex : 9;
+  int current_harq_pid = UE_list->UE_sched_ctrl[UE_id].current_harq_pid;
   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->rvIndex[0] = (get_softmodem_params()->phy_test==1) ? 0 : UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round;
   pdsch_pdu_rel15->dataScramblingId = *scc->physCellId;
   pdsch_pdu_rel15->nrOfLayers = 1;    
   pdsch_pdu_rel15->transmissionScheme = 0;
@@ -347,52 +345,88 @@ int configure_fapi_dl_pdu(int Mod_idP,
 						     scc->dmrs_TypeA_Position,
 						     pdsch_pdu_rel15->NrOfSymbols);
 
-  dci_pdu_rel15_t dci_pdu_rel15[MAX_DCI_CORESET];
+  dci_pdu_rel15_t *dci_pdu_rel15 = calloc(MAX_DCI_CORESET,sizeof(dci_pdu_rel15_t));
   
-  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;
+  // bwp indicator
+  int n_dl_bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count;
+  if (n_dl_bwp < 4)
+    dci_pdu_rel15[0].bwp_indicator.val = bwp_id;
+  else
+    dci_pdu_rel15[0].bwp_indicator.val = bwp_id - 1; // as per table 7.3.1.1.2-1 in 38.212
+  // frequency domain assignment
+  if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation==NR_PDSCH_Config__resourceAllocation_resourceAllocationType1)
+    dci_pdu_rel15[0].frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu_rel15->rbSize,
+                                                                                         pdsch_pdu_rel15->rbStart,
+										         NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275));
+  else
+    AssertFatal(1==0,"Only frequency resource allocation type 1 is currently supported\n");
+  // time domain assignment
+  dci_pdu_rel15[0].time_domain_assignment.val = time_domain_assignment; // row index used here instead of SLIV;
+  // mcs ndi and rv
   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 = (pucch_sched->dai_c-1)&3;
-  dci_pdu_rel15[0].tpc = 2;
+  dci_pdu_rel15[0].rv = pdsch_pdu_rel15->rvIndex[0];
+  // harq pid
+  dci_pdu_rel15[0].harq_pid = current_harq_pid;
+  dci_pdu_rel15[0].ndi = UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].ndi;
+  // DAI
+  dci_pdu_rel15[0].dai[0].val = (pucch_sched->dai_c-1)&3;
+
+  // TPC for PUCCH
+  dci_pdu_rel15[0].tpc = 1; // table 7.2.1-1 in 38.213
+  // PUCCH resource indicator
   dci_pdu_rel15[0].pucch_resource_indicator = pucch_sched->resource_indicator;
-  dci_pdu_rel15[0].pdsch_to_harq_feedback_timing_indicator = pucch_sched->timing_indicator;
-  
+  // PDSCH to HARQ TI
+  dci_pdu_rel15[0].pdsch_to_harq_feedback_timing_indicator.val = pucch_sched->timing_indicator;
+  UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].feedback_slot = pucch_sched->ul_slot;
+  UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].is_waiting = 1;
+  // antenna ports
+  dci_pdu_rel15[0].antenna_ports.val = 0;  // nb of cdm groups w/o data 1 and dmrs port 0
+
   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,
+	dci_pdu_rel15[0].frequency_domain_assignment.val,
 	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].time_domain_assignment.val,
+	dci_pdu_rel15[0].vrb_to_prb_mapping.val,
 	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
-                     ss,
-		     scc,
-		     bwp);
-  
-  pdcch_pdu_rel15->numDlDci = 1;
-  pdcch_pdu_rel15->dci_pdu.AggregationLevel[0] = 4;
-  pdcch_pdu_rel15->dci_pdu.RNTI[0]=UE_list->rnti[0];
-  pdcch_pdu_rel15->dci_pdu.ScramblingRNTI[0]=UE_list->rnti[0];
-  pdcch_pdu_rel15->dci_pdu.CceIndex[0] = CCEIndex[0];
-  pdcch_pdu_rel15->dci_pdu.beta_PDCCH_1_0[0]=0;
-  pdcch_pdu_rel15->dci_pdu.powerControlOffsetSS[0]=1;
-  
+
+  NR_SearchSpace_t *ss;
+  int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific;
+
+  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");
+
+  int found=0;
+
+  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->searchSpaceType->present == target_ss) {
+      found=1;
+      break;
+    }
+  }
+  AssertFatal(found==1,"Couldn't find an adequate searchspace\n");
+
+  int ret = nr_configure_pdcch(nr_mac,
+                               pdcch_pdu_rel15,
+                               UE_list->rnti[UE_id],
+		               1, // ue-specific
+		               ss,
+		               scc,
+		               bwp);
+  if (ret < 0) {
+   LOG_I(MAC,"CCE list not empty, couldn't schedule PDSCH\n");
+   free(dci_pdu_rel15);
+   return (0);
+  }
+
   int dci_formats[2];
   int rnti_types[2];
   
@@ -403,8 +437,7 @@ int configure_fapi_dl_pdu(int Mod_idP,
 
   rnti_types[0]   = NR_RNTI_C;
 
-  pdcch_pdu_rel15->dci_pdu.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,pdcch_pdu_rel15->BWPSize);
+  fill_dci_pdu_rel15(secondaryCellGroup,pdcch_pdu_rel15,dci_pdu_rel15,dci_formats,rnti_types,pdsch_pdu_rel15->BWPSize,bwp_id);
 
   LOG_D(MAC, "DCI params: rnti %x, rnti_type %d, dci_format %d\n \
 	                      coreset params: FreqDomainResource %llx, start_symbol %d  n_symb %d\n",
@@ -416,7 +449,7 @@ int configure_fapi_dl_pdu(int Mod_idP,
 	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,1,0);
+  nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu,x_Overhead,pdsch_pdu_rel15->numDmrsCdmGrpsNoData,0);
 
   // Hardcode it for now
   TBS = dl_tti_pdsch_pdu->pdsch_pdu.pdsch_pdu_rel15.TBSize[0];
@@ -430,17 +463,19 @@ int configure_fapi_dl_pdu(int Mod_idP,
 	pdsch_pdu_rel15->NrOfCodewords,
 	pdsch_pdu_rel15->mcsIndex[0],
 	TBS);
+
+  free(dci_pdu_rel15);
   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, 
+  dci_pdu_rel15->frequency_domain_assignment.val = 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->time_domain_assignment.val = 2; // row index used here instead of SLIV;
+  dci_pdu_rel15->frequency_hopping_flag.val = 0;
   dci_pdu_rel15->mcs = 9;
   
   dci_pdu_rel15->format_indicator = 0;
@@ -451,9 +486,9 @@ void config_uldci(NR_BWP_Uplink_t *ubwp,nfapi_nr_pusch_pdu_t *pusch_pdu,nfapi_nr
   
   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->dci_pdu.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->frequency_domain_assignment.val,
+	dci_pdu_rel15->time_domain_assignment.val,
+	dci_pdu_rel15->frequency_hopping_flag.val,
 	dci_pdu_rel15->mcs,
 	dci_pdu_rel15->tpc,
 	dci_pdu_rel15->ndi, 
@@ -510,11 +545,11 @@ void nr_schedule_uss_dlsch_phytest(module_id_t   module_idP,
                                    NR_sched_pucch *pucch_sched,
                                    nfapi_nr_dl_tti_pdsch_pdu_rel15_t *dlsch_config){
 
-  LOG_D(MAC, "In nr_schedule_uss_dlsch_phytest \n");
+  LOG_D(MAC, "In nr_schedule_uss_dlsch_phytest frame %d slot %d\n",frameP,slotP);
 
   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;
+  int UE_id = 0, CC_id = 0;
 
   gNB_MAC_INST *gNB_mac = RC.nrmac[module_idP];
   //NR_COMMON_channels_t                *cc           = nr_mac->common_channels;
@@ -538,25 +573,15 @@ void nr_schedule_uss_dlsch_phytest(module_id_t   module_idP,
 
   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
-
-  AssertFatal(CCEIndex>0,"CCEIndex is negative\n");
-  int CCEIndices[2];
-  CCEIndices[0] = CCEIndex;
-
   TBS_bytes = configure_fapi_dl_pdu(module_idP,
-                                    CCEIndices,
                                     dl_req,
                                     pucch_sched,
                                     dlsch_config!=NULL ? dlsch_config->mcsIndex : NULL,
                                     dlsch_config!=NULL ? &dlsch_config->rbSize : NULL,
                                     dlsch_config!=NULL ? &dlsch_config->rbStart : NULL);
+
+  if (TBS_bytes == 0)
+   return;
  
   //The --NOS1 use case currently schedules DLSCH transmissions only when there is IP traffic arriving
   //through the LTE stack
@@ -614,11 +639,13 @@ void nr_schedule_uss_dlsch_phytest(module_id_t   module_idP,
       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)
+
     LOG_D(MAC,"Configuring DL_TX in %d.%d\n", frameP, slotP);
 
     // fill dlsch_buffer with random data
@@ -628,7 +655,7 @@ void nr_schedule_uss_dlsch_phytest(module_id_t   module_idP,
     }
     //Sending SDUs with size 1
     //Initialize elements of sdu_lcids and sdu_lengths
-    sdu_lcids[0] = 0x05; // DRB
+    sdu_lcids[0] = 0x3f; // DRB
     sdu_lengths[0] = TBS_bytes - ta_len - 3;
     header_length_total += 2 + (sdu_lengths[0] >= 128);
     sdu_length_total += sdu_lengths[0];
@@ -728,9 +755,6 @@ void nr_schedule_uss_ulsch_phytest(int Mod_idP,
   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;
-  // TO BE FIXED we are just selecting the first search space here (only one is configured)
-  ss=bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list.array[0];
 
   uint16_t rnti = UE_list->rnti[UE_id];
   nfapi_nr_ul_dci_request_pdus_t  *ul_dci_request_pdu;
@@ -776,6 +800,8 @@ void nr_schedule_uss_ulsch_phytest(int Mod_idP,
   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;
+
+  //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;
@@ -797,7 +823,7 @@ void nr_schedule_uss_ulsch_phytest(int Mod_idP,
   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->num_dmrs_cdm_grps_no_data = 1;
   //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
@@ -826,21 +852,29 @@ void nr_schedule_uss_ulsch_phytest(int Mod_idP,
   pusch_pdu->pusch_data.harq_process_id = 0;
   pusch_pdu->pusch_data.new_data_indicator = 0;
 
-  uint8_t no_data_in_dmrs = 1; // temp implementation
   uint8_t num_dmrs_symb = 0;
 
   for(int dmrs_counter = pusch_pdu->start_symbol_index; dmrs_counter < pusch_pdu->start_symbol_index + pusch_pdu->nr_of_symbols; dmrs_counter++)
     num_dmrs_symb += ((pusch_pdu->ul_dmrs_symb_pos >> dmrs_counter) & 1);
 
+  uint8_t N_PRB_DMRS;
+  if (pusch_pdu->dmrs_config_type == 0) {
+    N_PRB_DMRS = pusch_pdu->num_dmrs_cdm_grps_no_data*6;
+  }
+  else {
+    N_PRB_DMRS = pusch_pdu->num_dmrs_cdm_grps_no_data*4;
+  }
+
   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,
-						 ( no_data_in_dmrs ? 12 : ((pusch_pdu->dmrs_config_type == pusch_dmrs_type1) ? 6 : 4) ) * num_dmrs_symb,
+						 N_PRB_DMRS * num_dmrs_symb,
 						 0, //nb_rb_oh
                                                  0,
 						 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;
@@ -859,34 +893,51 @@ void nr_schedule_uss_ulsch_phytest(int Mod_idP,
   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
+  NR_SearchSpace_t *ss;
+  int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific;
 
-  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,
-                     ss,
-		     scc,
-		     bwp);
-  
-  dci_pdu_rel15_t dci_pdu_rel15[MAX_DCI_CORESET];
+  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");
 
-  AssertFatal(CCEIndex>=0,"CCEIndex is negative \n");
-  pdcch_pdu_rel15->dci_pdu.CceIndex[pdcch_pdu_rel15->numDlDci] = CCEIndex;
+  int found=0;
 
-  LOG_D(PHY,"CCEIndex %d\n",pdcch_pdu_rel15->dci_pdu.CceIndex[pdcch_pdu_rel15->numDlDci]);
+  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->searchSpaceType->present == target_ss) {
+      found=1;
+      break;
+    }
+  }
+  AssertFatal(found==1,"Couldn't find an adequate searchspace\n");
 
-  config_uldci(ubwp,pusch_pdu,pdcch_pdu_rel15, &dci_pdu_rel15[0], dci_formats, rnti_types);
-  
-  pdcch_pdu_rel15->dci_pdu.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,pdcch_pdu_rel15->BWPSize);
-  
+  if (ss->searchSpaceType->choice.ue_Specific->dci_Formats)
+    dci_formats[0]  = NR_UL_DCI_FORMAT_0_1;
+  else
+    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);
+
+  int ret = nr_configure_pdcch(nr_mac,
+                               pdcch_pdu_rel15,
+                               UE_list->rnti[UE_id],
+                               1, // ue-specific,
+		               ss,
+		               scc,
+		               bwp);
+
+  if (ret < 0) {
+   LOG_I(MAC,"CCE list not empty, couldn't schedule PUSCH\n");
+   UL_tti_req->n_pdus-=1;
+   return;
+  }
+  else {
+    dci_pdu_rel15_t dci_pdu_rel15[MAX_DCI_CORESET];
+    config_uldci(ubwp,pusch_pdu,pdcch_pdu_rel15, &dci_pdu_rel15[0], dci_formats, rnti_types);
+    fill_dci_pdu_rel15(secondaryCellGroup,pdcch_pdu_rel15,dci_pdu_rel15,dci_formats,rnti_types,pusch_pdu->bwp_size,bwp_id);
+  }
 }
 
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
index d3412095e3998856d342e95214f5f04c4cab253f..fc2a2e18cf86692e6a6c3f1eb4a19d4ea9ff3415 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c
@@ -129,29 +129,9 @@ static inline uint8_t get_max_cces(uint8_t scs) {
   return (nr_max_number_of_cces_per_slot[scs]);
 } 
 
-int find_aggregation_level (NR_SearchSpace_t *ss){
-
-  int level = 0;
-
-  if( ss->nrofCandidates->aggregationLevel1 != NR_SearchSpace__nrofCandidates__aggregationLevel1_n0)
-    level = 1;
-  if( ss->nrofCandidates->aggregationLevel2 != NR_SearchSpace__nrofCandidates__aggregationLevel2_n0)
-    level = 2;
-  if( ss->nrofCandidates->aggregationLevel4 != NR_SearchSpace__nrofCandidates__aggregationLevel4_n0)
-    level = 4;
-  if( ss->nrofCandidates->aggregationLevel8 != NR_SearchSpace__nrofCandidates__aggregationLevel8_n0)
-    level = 8;
-  if( ss->nrofCandidates->aggregationLevel16 != NR_SearchSpace__nrofCandidates__aggregationLevel16_n0)
-    level = 16;
-
-  AssertFatal(level!=0,"Unable to find aggregation level");
-  return level;
-
-}
-
 int allocate_nr_CCEs(gNB_MAC_INST *nr_mac,
 		     int bwp_id,
-		     int coreset_id,
+		     int list_id,
 		     int aggregation,
 		     int search_space, // 0 common, 1 ue-specific
 		     int UE_id,
@@ -172,15 +152,15 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac,
   bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1];
 
   if (search_space == 1) {
-    coreset = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[coreset_id];
+    coreset = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[list_id];
   }
   else {
     coreset = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet;
   }
 
+  int coreset_id = coreset->controlResourceSetId;
   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++) {
@@ -202,7 +182,7 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac,
   }
   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++) 
+  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;
@@ -429,12 +409,16 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
 
 }
 
-void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
-			int ss_type,
-                        NR_SearchSpace_t *ss,
-			NR_ServingCellConfigCommon_t *scc,
-			NR_BWP_Downlink_t *bwp){
-  
+int nr_configure_pdcch(gNB_MAC_INST *nr_mac,
+                       nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
+                       uint16_t rnti,
+                       int ss_type,
+                       NR_SearchSpace_t *ss,
+                       NR_ServingCellConfigCommon_t *scc,
+                       NR_BWP_Downlink_t *bwp){
+
+  int CCEIndex = -1;
+  int cid = 0;
   NR_ControlResourceSet_t *coreset = NULL;
 
   if (bwp) { // This is not the InitialBWP
@@ -455,6 +439,7 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
         temp_coreset = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[i];
         if (coresetid==temp_coreset->controlResourceSetId) {
           coreset = temp_coreset;
+          cid = i;
           break;
         }
       }
@@ -466,7 +451,6 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
     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;
-    
 
     // first symbol
     //AssertFatal(pdcch_scs==kHz15, "PDCCH SCS above 15kHz not allowed if a symbol above 2 is monitored");
@@ -490,6 +474,7 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
     
     for (int i=0;i<6;i++)
       pdcch_pdu->FreqDomainResource[i] = coreset->frequencyDomainResources.buf[i];
+
     
     //cce-REG-MappingType
     pdcch_pdu->CceRegMappingType = coreset->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved?
@@ -511,17 +496,45 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
     
     //precoderGranularity
     pdcch_pdu->precoderGranularity = coreset->precoderGranularity;
-    
-    if (ss_type) {
-      for (int i=0;i<pdcch_pdu->numDlDci;i++) {
-        //pdcch-DMRS-ScramblingID
-        AssertFatal(coreset->pdcch_DMRS_ScramblingID != NULL,"coreset0->pdcch_DMRS_ScramblingID is null\n");
-        pdcch_pdu->dci_pdu.ScramblingId[i] = *coreset->pdcch_DMRS_ScramblingID;
-      }
+
+    pdcch_pdu->dci_pdu.RNTI[pdcch_pdu->numDlDci]=rnti;
+
+    if (coreset->pdcch_DMRS_ScramblingID != NULL &&
+        ss->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) {
+      pdcch_pdu->dci_pdu.ScramblingId[pdcch_pdu->numDlDci] = *coreset->pdcch_DMRS_ScramblingID;
+      pdcch_pdu->dci_pdu.ScramblingRNTI[pdcch_pdu->numDlDci]=rnti;
+    }
+    else {
+      pdcch_pdu->dci_pdu.ScramblingId[pdcch_pdu->numDlDci] = *scc->physCellId;
+      pdcch_pdu->dci_pdu.ScramblingRNTI[pdcch_pdu->numDlDci]=0;
     }
 
-  }
+    uint8_t nr_of_candidates,aggregation_level;
+    find_aggregation_candidates(&aggregation_level,
+                               &nr_of_candidates,
+                               ss);
+
+    CCEIndex = allocate_nr_CCEs(nr_mac,
+                                1, // bwp_id
+                                cid,
+                                aggregation_level,
+                                ss->searchSpaceType->present-1, // search_space, 0 common, 1 ue-specific
+                                0, // UE-id
+                                0); // m
 
+    if (CCEIndex<0)
+     return (CCEIndex);
+
+    pdcch_pdu->dci_pdu.AggregationLevel[pdcch_pdu->numDlDci] = aggregation_level;
+    pdcch_pdu->dci_pdu.CceIndex[pdcch_pdu->numDlDci] = CCEIndex;
+
+    if (ss->searchSpaceType->choice.ue_Specific->dci_Formats==NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_0_And_1_0)
+      pdcch_pdu->dci_pdu.beta_PDCCH_1_0[pdcch_pdu->numDlDci]=0;
+
+    pdcch_pdu->dci_pdu.powerControlOffsetSS[pdcch_pdu->numDlDci]=1;
+    pdcch_pdu->numDlDci++;
+    return (0);
+  }
   else { // this is for InitialBWP
     AssertFatal(1==0,"Fill in InitialBWP PDCCH configuration\n");
   }
@@ -713,25 +726,91 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu,
 }
 
 
+void prepare_dci(NR_CellGroupConfig_t *secondaryCellGroup,
+                 dci_pdu_rel15_t *dci_pdu_rel15,
+                 nr_dci_format_t format,
+                 int bwp_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,
-			int N_RB) {
-  
+  NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1];
+
+  switch(format) {
+    case NR_DL_DCI_FORMAT_1_1:
+      // format indicator
+      dci_pdu_rel15->format_indicator = 1;
+      // carrier indicator
+      if (secondaryCellGroup->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig != NULL)
+        AssertFatal(1==0,"Cross Carrier Scheduling Config currently not supported\n");
+      //vrb to prb mapping
+      if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver==NULL)
+        dci_pdu_rel15->vrb_to_prb_mapping.val = 0;
+      else
+        dci_pdu_rel15->vrb_to_prb_mapping.val = 1;
+      //bundling size indicator
+      if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present == NR_PDSCH_Config__prb_BundlingType_PR_dynamicBundling)
+        AssertFatal(1==0,"Dynamic PRB bundling type currently not supported\n");
+      //rate matching indicator
+      uint16_t msb = (bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup1==NULL)?0:1;
+      uint16_t lsb = (bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup2==NULL)?0:1;
+      dci_pdu_rel15->rate_matching_indicator.val = lsb | (msb<<1);
+      // aperiodic ZP CSI-RS trigger
+      if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList != NULL)
+        AssertFatal(1==0,"Aperiodic ZP CSI-RS currently not supported\n");
+      // transmission configuration indication
+      if (bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[bwp_id-1]->tci_PresentInDCI != NULL)
+        AssertFatal(1==0,"TCI in DCI currently not supported\n");
+      //srs resource set
+      if (secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->carrierSwitching!=NULL) {
+        NR_SRS_CarrierSwitching_t *cs = secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->carrierSwitching->choice.setup;
+        if (cs->srs_TPC_PDCCH_Group!=NULL){
+          switch(cs->srs_TPC_PDCCH_Group->present) {
+            case NR_SRS_CarrierSwitching__srs_TPC_PDCCH_Group_PR_NOTHING:
+              dci_pdu_rel15->srs_request.val = 0;
+              break;
+            case NR_SRS_CarrierSwitching__srs_TPC_PDCCH_Group_PR_typeA:
+              AssertFatal(1==0,"SRS TPC PRCCH group type A currently not supported\n");
+              break;
+            case NR_SRS_CarrierSwitching__srs_TPC_PDCCH_Group_PR_typeB:
+              AssertFatal(1==0,"SRS TPC PRCCH group type B currently not supported\n");
+              break;
+          }
+        }
+        else
+          dci_pdu_rel15->srs_request.val = 0;
+      }
+      else
+        dci_pdu_rel15->srs_request.val = 0;
+    // CBGTI and CBGFI
+    if (secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->codeBlockGroupTransmission != NULL)
+      AssertFatal(1==0,"CBG transmission currently not supported\n");
+    // dmrs sequence initialization
+    dci_pdu_rel15->dmrs_sequence_initialization = 0; // FIXME no information on what this bit should be in 38.212
+    break;
+  default :
+    AssertFatal(1==0,"Prepare dci currently only implemented for 1_1 \n");
+  }
+}
+
+
+void fill_dci_pdu_rel15(NR_CellGroupConfig_t *secondaryCellGroup,
+                        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 N_RB,
+                        int bwp_id) {
 
   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->dci_pdu.Payload[d];
+    int dci_size = nr_dci_size(secondaryCellGroup,&dci_pdu_rel15[d],dci_formats[d],rnti_types[d],N_RB,bwp_id);
+    pdcch_pdu_rel15->dci_pdu.PayloadSizeBits[d] = dci_size;
     AssertFatal(pdcch_pdu_rel15->dci_pdu.PayloadSizeBits[d]<=64, "DCI sizes above 64 bits not yet supported");
 
-    int dci_size = pdcch_pdu_rel15->dci_pdu.PayloadSizeBits[d];
-
-    *dci_pdu=0;
-
+    if(dci_formats[d]==NR_DL_DCI_FORMAT_1_1)
+      prepare_dci(secondaryCellGroup,&dci_pdu_rel15[d],dci_formats[d],bwp_id);
+    
     /// Payload generation
     switch(dci_formats[d]) {
     case NR_DL_DCI_FORMAT_1_0:
@@ -740,23 +819,17 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	// Freq domain assignment
 	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));
-#ifdef DEBUG_FILL_DCI
-	LOG_I(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);
-#endif
+	*dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val&((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.val,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));
-#ifdef DEBUG_FILL_DCI
-	LOG_I(MAC,"time-domain assignment %d  (4 bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_domain_assignment,dci_size-pos,*dci_pdu);
-#endif
+	*dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val&0xf) << (dci_size-pos));
+	LOG_D(MAC,"time-domain assignment %d  (3 bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_domain_assignment.val,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);
-#ifdef DEBUG_FILL_DCI
-	LOG_I(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
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val&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.val,dci_size-pos,*dci_pdu);
 	// MCS
 	pos+=5;
 	*dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs&0x1f)<<(dci_size-pos);
@@ -781,13 +854,13 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	// 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));
+	*dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val&((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);
+	LOG_D(MAC,"Freq domain assignment %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->frequency_domain_assignment.val,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)) {
+	  if (!((dci_pdu_rel15->frequency_domain_assignment.val>>i)&1)) {
 	    is_ra = 0;
 	    break;
 	  }
@@ -799,7 +872,7 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	    
 	    // UL/SUL indicator  1 bit
 	    pos++;
-	    *dci_pdu |= (dci_pdu_rel15->ul_sul_indicator&1)<<(dci_size-pos);
+	    *dci_pdu |= (dci_pdu_rel15->ul_sul_indicator.val&1)<<(dci_size-pos);
 	    
 	    // SS/PBCH index  6 bits
 	    pos+=6;
@@ -816,13 +889,13 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	  // 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);
+	  *dci_pdu |= ((dci_pdu_rel15->time_domain_assignment.val&0xf) << (dci_size-pos));
+	  LOG_D(MAC,"Time domain assignment %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->time_domain_assignment.val,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);
+	  *dci_pdu |= (dci_pdu_rel15->vrb_to_prb_mapping.val&1)<<(dci_size-pos);
+	  LOG_D(MAC,"VRB to PRB %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->vrb_to_prb_mapping.val,1,dci_size-pos,*dci_pdu);
 	  
 	  // MCS 5bit  //bit over 32, so dci_pdu ++
 	  pos+=5;
@@ -846,8 +919,8 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	  
 	  // 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);
+	  *dci_pdu |= ((dci_pdu_rel15->dai[0].val&3)<<(dci_size-pos));
+	  LOG_D(MAC,"DAI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->dai[0].val,2,dci_size-pos,*dci_pdu);
 	  
 	  // TPC command for scheduled PUCCH  2bit
 	  pos+=2;
@@ -861,8 +934,8 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	  
 	  // 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);
+	  *dci_pdu |= ((dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val&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.val,3,dci_size-pos,*dci_pdu);
 	  
 	} //end else
 	break;
@@ -878,12 +951,12 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	// 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++);
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val>>(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++);
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val>>(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++);
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val&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++);
@@ -899,12 +972,12 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	// 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++);
+	  *dci_pdu |= ((dci_pdu_rel15->frequency_domain_assignment.val>>(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++);
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val>>(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++);
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val&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++);
@@ -920,12 +993,12 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	// 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++);
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val>>(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++);
+	  *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val>>(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++);
+	*dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val&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++);
@@ -940,7 +1013,7 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	
 	// 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++);
+	  *dci_pdu  |= (((uint64_t)dci_pdu_rel15->dai[0].val>>(1-i))&1)<<(dci_size-pos++);
 	
 	// TPC command for scheduled PUCCH – 2 bits
 	for (int i=0; i<2; i++)
@@ -953,7 +1026,7 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	
 	// 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++);
+	  *dci_pdu  |= (((uint64_t)dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val>>(2-i))&1)<<(dci_size-pos++);
 	
 	break;
       }
@@ -968,12 +1041,12 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	  // 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++);
+	    *dci_pdu |= ((dci_pdu_rel15->frequency_domain_assignment.val>>(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++);
+	    *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val>>(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++);
+	  *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_hopping_flag.val&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++);
@@ -997,7 +1070,7 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	  // 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++);
+	    *dci_pdu |= ((uint64_t)dci_pdu_rel15->ul_sul_indicator.val&1)<<(dci_size-pos++);
 	    */
 	  break;
 	  
@@ -1008,12 +1081,12 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	  // 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++);
+	    *dci_pdu |= ((dci_pdu_rel15->frequency_domain_assignment.val>>(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++);
+	    *dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val>>(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++);
+	  *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_hopping_flag.val&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++);
@@ -1038,12 +1111,119 @@ void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
 	  /*
 	    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++);
+	    *dci_pdu |= ((uint64_t)dci_pdu_rel15->ul_sul_indicator.val&1)<<(dci_size-pos++);
 	    */
 	  break;
 	  
 	    }
       break;
+
+    case NR_DL_DCI_FORMAT_1_1:
+      // Indicating a DL DCI format 1bit
+      pos=1;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator&0x1)<<(dci_size-pos);
+
+      // Carrier indicator
+      pos+=dci_pdu_rel15->carrier_indicator.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->carrier_indicator.val&((1<<dci_pdu_rel15->carrier_indicator.nbits)-1))<<(dci_size-pos);
+
+      // BWP indicator
+      pos+=dci_pdu_rel15->bwp_indicator.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->bwp_indicator.val&((1<<dci_pdu_rel15->bwp_indicator.nbits)-1))<<(dci_size-pos);
+
+      // Frequency domain resource assignment
+      pos+=dci_pdu_rel15->frequency_domain_assignment.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val&((1<<dci_pdu_rel15->frequency_domain_assignment.nbits)-1)) << (dci_size-pos);
+
+      // Time domain resource assignment
+      pos+=dci_pdu_rel15->time_domain_assignment.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->time_domain_assignment.val&((1<<dci_pdu_rel15->time_domain_assignment.nbits)-1)) << (dci_size-pos);
+
+      // VRB-to-PRB mapping
+      pos+=dci_pdu_rel15->vrb_to_prb_mapping.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val&((1<<dci_pdu_rel15->vrb_to_prb_mapping.nbits)-1))<<(dci_size-pos);
+      
+      // PRB bundling size indicator
+      pos+=dci_pdu_rel15->prb_bundling_size_indicator.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->prb_bundling_size_indicator.val&((1<<dci_pdu_rel15->prb_bundling_size_indicator.nbits)-1))<<(dci_size-pos);
+
+      // Rate matching indicator
+      pos+=dci_pdu_rel15->rate_matching_indicator.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->rate_matching_indicator.val&((1<<dci_pdu_rel15->rate_matching_indicator.nbits)-1))<<(dci_size-pos);
+
+      // ZP CSI-RS trigger
+      pos+=dci_pdu_rel15->zp_csi_rs_trigger.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->zp_csi_rs_trigger.val&((1<<dci_pdu_rel15->zp_csi_rs_trigger.nbits)-1)) << (dci_size-pos);
+
+      //TB1
+      // MCS 5bit
+      pos+=5;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs&0x1f)<<(dci_size-pos);
+      
+      // New data indicator 1bit
+      pos+=1;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi&0x1)<<(dci_size-pos);
+      
+      // Redundancy version  2bit
+      pos+=2;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->rv&0x3)<<(dci_size-pos);
+
+      //TB2
+      // MCS 5bit
+      pos+=dci_pdu_rel15->mcs2.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->mcs2.val&((1<<dci_pdu_rel15->mcs2.nbits)-1))<<(dci_size-pos);
+      
+      // New data indicator 1bit
+      pos+=dci_pdu_rel15->ndi2.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->ndi2.val&((1<<dci_pdu_rel15->ndi2.nbits)-1))<<(dci_size-pos);
+      
+      // Redundancy version  2bit
+      pos+=dci_pdu_rel15->rv2.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->rv2.val&((1<<dci_pdu_rel15->rv2.nbits)-1))<<(dci_size-pos);
+
+      // HARQ process number  4bit
+      pos+=4;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->harq_pid&0xf)<<(dci_size-pos);
+
+      // Downlink assignment index
+      pos+=dci_pdu_rel15->dai[0].nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->dai[0].val&((1<<dci_pdu_rel15->dai[0].nbits)-1))<<(dci_size-pos);
+
+      // TPC command for scheduled PUCCH  2bit
+      pos+=2;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->tpc&0x3)<<(dci_size-pos);
+      
+      // PUCCH resource indicator  3bit
+      pos+=3;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->pucch_resource_indicator&0x7)<<(dci_size-pos);
+
+      // PDSCH-to-HARQ_feedback timing indicator
+      pos+=dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val&((1<<dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.nbits)-1))<<(dci_size-pos);
+
+      // Antenna ports
+      pos+=dci_pdu_rel15->antenna_ports.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->antenna_ports.val&((1<<dci_pdu_rel15->antenna_ports.nbits)-1))<<(dci_size-pos);
+
+      // TCI
+      pos+=dci_pdu_rel15->transmission_configuration_indication.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->transmission_configuration_indication.val&((1<<dci_pdu_rel15->transmission_configuration_indication.nbits)-1))<<(dci_size-pos);
+
+      // SRS request
+      pos+=dci_pdu_rel15->srs_request.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->srs_request.val&((1<<dci_pdu_rel15->srs_request.nbits)-1))<<(dci_size-pos);
+
+      // CBG transmission information
+      pos+=dci_pdu_rel15->cbgti.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->cbgti.val&((1<<dci_pdu_rel15->cbgti.nbits)-1))<<(dci_size-pos);
+
+      // CBG flushing out information
+      pos+=dci_pdu_rel15->cbgfi.nbits;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->cbgfi.val&((1<<dci_pdu_rel15->cbgfi.nbits)-1))<<(dci_size-pos);
+
+      // DMRS sequence init
+      pos+=1;
+      *dci_pdu |= ((uint64_t)dci_pdu_rel15->dmrs_sequence_initialization&0x1)<<(dci_size-pos);
     }
   }
 }
@@ -1148,6 +1328,11 @@ 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;
+  NR_COMMON_channels_t *cc = RC.nrmac[mod_idP]->common_channels;
+  NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
+  int num_slots_ul = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots;
+  if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols>0)
+    num_slots_ul++;
   LOG_I(MAC, "[gNB %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n",
         mod_idP,
         rntiP,
@@ -1166,6 +1351,7 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){
     memset((void *) &UE_list->UE_sched_ctrl[UE_id],
            0,
            sizeof(NR_UE_sched_ctrl_t));
+    UE_list->UE_sched_ctrl[UE_id].sched_pucch = (NR_sched_pucch *)malloc(num_slots_ul*sizeof(NR_sched_pucch));
     LOG_I(MAC, "gNB %d] Add NR UE_id %d : rnti %x\n",
           mod_idP,
           UE_id,
@@ -1182,7 +1368,6 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP){
   return -1;
 }
 
-
 void get_pdsch_to_harq_feedback(int Mod_idP,
                                 int UE_id,
                                 NR_SearchSpace__searchSpaceType_PR ss_type,
@@ -1202,48 +1387,51 @@ void get_pdsch_to_harq_feedback(int Mod_idP,
       pdsch_to_harq_feedback[i] = i+1;
   }
   else {
+
     // searching for a ue specific search space
     int found=0;
-
+ 
     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->searchSpaceType->present == ss_type) {
-	found=1;
-	break;
+       found=1;
+       break;
       }
     }
     AssertFatal(found==1,"Couldn't find a ue specific searchspace\n");
+
+
     if (ss->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_0_And_1_0) {
       for (int i=0; i<8; i++)
         pdsch_to_harq_feedback[i] = i+1;
     }
     else {
-      if(ubwp->bwp_Dedicated->pucch_Config->choice.setup->dl_DataToUL_ACK != NULL)
-        pdsch_to_harq_feedback = (uint8_t *)ubwp->bwp_Dedicated->pucch_Config->choice.setup->dl_DataToUL_ACK;
+      if(ubwp->bwp_Dedicated->pucch_Config->choice.setup->dl_DataToUL_ACK != NULL) {
+        for (int i=0; i<8; i++)
+          pdsch_to_harq_feedback[i] = *ubwp->bwp_Dedicated->pucch_Config->choice.setup->dl_DataToUL_ACK->list.array[i];
+      }
       else
-        AssertFatal(found==1,"There is no allocated dl_DataToUL_ACK for pdsch to harq feedback\n");
+        AssertFatal(0==1,"There is no allocated dl_DataToUL_ACK for pdsch to harq feedback\n");
     }
   }
 }
 
-
 // function to update pucch scheduling parameters in UE list when a USS DL is scheduled
 void nr_update_pucch_scheduling(int Mod_idP,
                                 int UE_id,
                                 frame_t frameP,
                                 sub_frame_t slotP,
                                 int slots_per_tdd,
-                                NR_sched_pucch *sched_pucch) {
+                                int *pucch_id) {
 
   NR_ServingCellConfigCommon_t *scc = RC.nrmac[Mod_idP]->common_channels->ServingCellConfigCommon;
   NR_UE_list_t *UE_list = &RC.nrmac[Mod_idP]->UE_list;
-  int first_ul_slot_tdd,k;
   NR_sched_pucch *curr_pucch;
+  int first_ul_slot_tdd,k,i;
   uint8_t pdsch_to_harq_feedback[8];
   int found = 0;
-  int i = 0;
   int nr_ulmix_slots = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots;
   if (scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols!=0)
     nr_ulmix_slots++;
@@ -1252,97 +1440,58 @@ void nr_update_pucch_scheduling(int Mod_idP,
   NR_SearchSpace__searchSpaceType_PR ss_type = NR_SearchSpace__searchSpaceType_PR_ue_Specific;
   get_pdsch_to_harq_feedback(Mod_idP,UE_id,ss_type,pdsch_to_harq_feedback);
 
-  // if the list of pucch to be scheduled is empty
-  if (UE_list->UE_sched_ctrl[UE_id].sched_pucch == NULL) {
-    sched_pucch->frame = frameP;
-    sched_pucch->next_sched_pucch = NULL;
-    sched_pucch->dai_c = 1;
-    sched_pucch->resource_indicator = 0; // in phytest with only 1 UE we are using just the 1st resource
-    if ( nr_ulmix_slots > 0 ) {
+  // for each possible ul or mixed slot
+  for (k=0; k<nr_ulmix_slots; k++) {
+    curr_pucch = &UE_list->UE_sched_ctrl[UE_id].sched_pucch[k];
+    // if there is free room in current pucch structure
+    if (curr_pucch->dai_c<MAX_ACK_BITS) {
+      curr_pucch->frame = frameP;
+      curr_pucch->dai_c++;
+      curr_pucch->resource_indicator = 0; // in phytest with only 1 UE we are using just the 1st resource
       // first pucch occasion in first UL or MIXED slot
       first_ul_slot_tdd = scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots;
-      for (k=0; k<nr_ulmix_slots; k++) { // for each possible UL or mixed slot
-        while (i<8 && found == 0)  {  // look if timing indicator is among allowed values
-          if (pdsch_to_harq_feedback[i]==(first_ul_slot_tdd+k)-(slotP % slots_per_tdd))
-            found = 1;
-          if (found == 0) i++;
-        }
-        if (found == 1) break;
+      i = 0;
+      while (i<8 && found == 0)  {  // look if timing indicator is among allowed values
+        if (pdsch_to_harq_feedback[i]==(first_ul_slot_tdd+k)-(slotP % slots_per_tdd))
+          found = 1;
+        if (found == 0) i++;
       }
       if (found == 1) {
         // computing slot in which pucch is scheduled
-        sched_pucch->ul_slot = first_ul_slot_tdd + k + (slotP - (slotP % slots_per_tdd));
-        sched_pucch->timing_indicator = pdsch_to_harq_feedback[i];
+        curr_pucch->ul_slot = first_ul_slot_tdd + k + (slotP - (slotP % slots_per_tdd));
+        curr_pucch->timing_indicator = i; // index in the list of timing indicators
+        *pucch_id = k;
+        return;
       }
-      else
-        AssertFatal(1==0,"No Uplink slot available in accordance to allowed timing indicator\n");
     }
-    else
-      AssertFatal(1==0,"No Uplink Slots in this Frame\n");
+  }
+  AssertFatal(1==0,"No Uplink slot available in accordance to allowed timing indicator\n");
+}
 
-    UE_list->UE_sched_ctrl[UE_id].sched_pucch = sched_pucch;
+
+void find_aggregation_candidates(uint8_t *aggregation_level,
+                                 uint8_t *nr_of_candidates,
+                                 NR_SearchSpace_t *ss) {
+
+  if (ss->nrofCandidates->aggregationLevel1 != NR_SearchSpace__nrofCandidates__aggregationLevel1_n0) {
+    *aggregation_level = 1;
+    *nr_of_candidates = ss->nrofCandidates->aggregationLevel1;
   }
-  else {  // to be tested
-    curr_pucch = UE_list->UE_sched_ctrl[UE_id].sched_pucch;
-    if (curr_pucch->dai_c<MAX_ACK_BITS) {     // we are scheduling at most MAX_UCI_BITS harq-ack in the same pucch
-      while (i<8 && found == 0)  {  // look if timing indicator is among allowed values for current pucch
-        if (pdsch_to_harq_feedback[i]==(curr_pucch->ul_slot % slots_per_tdd)-(slotP % slots_per_tdd))
-          found = 1;
-        if (found == 0) i++;
-      }
-      if (found == 1) {  // scheduling this harq-ack in current pucch
-        sched_pucch = curr_pucch;
-        sched_pucch->dai_c = 1 + sched_pucch->dai_c;
-        sched_pucch->timing_indicator = pdsch_to_harq_feedback[i];
-      }
-    }
-    if (curr_pucch->dai_c==MAX_ACK_BITS || found == 0) { // if current pucch is full or no timing indicator allowed
-      // look for pucch occasions in other UL of mixed slots
-      for (k=scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots; k<slots_per_tdd; k++) { // for each possible UL or mixed slot
-        if (k!=(curr_pucch->ul_slot % slots_per_tdd)) { // skip current scheduled slot (already checked)
-          i = 0;
-          while (i<8 && found == 0)  {  // look if timing indicator is among allowed values
-            if (pdsch_to_harq_feedback[i]==k-(slotP % slots_per_tdd))
-              found = 1;
-            if (found == 0) i++;
-          }
-          if (found == 1) {
-            if (k<(curr_pucch->ul_slot % slots_per_tdd)) { // we need to add a pucch occasion before current pucch
-              sched_pucch->frame = frameP;
-              sched_pucch->ul_slot =  k + (slotP - (slotP % slots_per_tdd));
-              sched_pucch->next_sched_pucch = curr_pucch;
-              sched_pucch->dai_c = 1;
-              sched_pucch->resource_indicator = 0; // in phytest with only 1 UE we are using just the 1st resource
-              sched_pucch->timing_indicator = pdsch_to_harq_feedback[i];
-              UE_list->UE_sched_ctrl[UE_id].sched_pucch = sched_pucch;
-            }
-            else {
-              while (curr_pucch->next_sched_pucch != NULL && k!=(curr_pucch->ul_slot % slots_per_tdd))
-                curr_pucch = curr_pucch->next_sched_pucch;
-              if (curr_pucch == NULL) {  // creating a new item in the list
-                sched_pucch->frame = frameP;
-                sched_pucch->next_sched_pucch = NULL;
-                sched_pucch->dai_c = 1;
-                sched_pucch->timing_indicator = pdsch_to_harq_feedback[i];
-                sched_pucch->resource_indicator = 0; // in phytest with only 1 UE we are using just the 1st resource
-                sched_pucch->ul_slot = k + (slotP - (slotP % slots_per_tdd));
-                curr_pucch->next_sched_pucch = (NR_sched_pucch*) malloc(sizeof(NR_sched_pucch));
-                curr_pucch->next_sched_pucch = sched_pucch;
-              }
-              else {
-                if (curr_pucch->dai_c==MAX_ACK_BITS)
-                  found = 0; // if pucch at index k is already full we have to find a new one in a following occasion
-                else { // scheduling this harq-ack in current pucch
-                  sched_pucch = curr_pucch;
-                  sched_pucch->dai_c = 1 + sched_pucch->dai_c;
-                  sched_pucch->timing_indicator = pdsch_to_harq_feedback[i];
-                }
-              }
-            }
-          }
-        }
-      }
-    }
+  if (ss->nrofCandidates->aggregationLevel2 != NR_SearchSpace__nrofCandidates__aggregationLevel2_n0) {
+    *aggregation_level = 2;
+    *nr_of_candidates = ss->nrofCandidates->aggregationLevel2;
+  }
+  if (ss->nrofCandidates->aggregationLevel4 != NR_SearchSpace__nrofCandidates__aggregationLevel4_n0) {
+    *aggregation_level = 4;
+    *nr_of_candidates = ss->nrofCandidates->aggregationLevel4;
+  }
+  if (ss->nrofCandidates->aggregationLevel8 != NR_SearchSpace__nrofCandidates__aggregationLevel8_n0) {
+    *aggregation_level = 8;
+    *nr_of_candidates = ss->nrofCandidates->aggregationLevel8;
+  }
+  if (ss->nrofCandidates->aggregationLevel16 != NR_SearchSpace__nrofCandidates__aggregationLevel16_n0) {
+    *aggregation_level = 16;
+    *nr_of_candidates = ss->nrofCandidates->aggregationLevel16;
   }
 }
 
diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
index 0e42d79fdc82908762b24f4fcddb3a22a0597bfc..89c3fe69fe00c0b7f1cd628374ba28054074d36a 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
@@ -306,5 +306,20 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP,
       nr_process_mac_pdu(gnb_mod_idP, CC_idP, frameP, sduP, sdu_lenP);
     }
   }
+  else {
+    // random access pusch with TC-RNTI
+    if (sduP != NULL) { // if the CRC passed
+      for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) {
+        if (UE_list->active[i] == TRUE) {
+          if (UE_list->tc_rnti[i] == current_rnti) {
+            // for now the only thing we are doing is set the UE as 5G connected
+            UE_list->fiveG_connected[i] = true;
+            LOG_I(MAC, "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly and UE_id %d is now 5G connected\n",
+                  gnb_mod_idP, current_rnti, i);
+          }
+        }
+      }
+    }
+  }
 }
 
diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
index c6e24399b0071ca86033ace538c579f566a6e0f3..78920dd2ea2fb516320205a6eb773534a186ac1e 100644
--- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
+++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h
@@ -126,7 +126,6 @@ void nr_schedule_css_dlsch_phytest(module_id_t   module_idP,
                                    sub_frame_t   subframeP);
 
 int configure_fapi_dl_pdu(int Mod_id,
-                         int *CCEIndeces,
                          nfapi_nr_dl_tti_request_body_t *dl_req,
                          NR_sched_pucch *pucch_sched,
                          uint8_t *mcsIndex,
@@ -158,7 +157,7 @@ void nr_update_pucch_scheduling(int Mod_idP,
                                 frame_t frameP,
                                 sub_frame_t slotP,
                                 int slots_per_tdd,
-                                NR_sched_pucch *sched_pucch);
+                                int *pucch_id);
 
 void get_pdsch_to_harq_feedback(int Mod_idP,
                                 int UE_id,
@@ -183,6 +182,7 @@ int nr_is_dci_opportunity(nfapi_nr_search_space_t search_space,
                           uint16_t slot,
                           nfapi_nr_config_request_scf_t cfg);
 */
+
 void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu,
 			NR_ServingCellConfigCommon_t *scc,
 			NR_BWP_Uplink_t *bwp,
@@ -190,17 +190,35 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu,
                         uint16_t O_uci,
                         uint16_t O_ack,
                         uint8_t SR_flag);
-void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
-                        int ss_type,
-                        NR_SearchSpace_t *ss,
-                        NR_ServingCellConfigCommon_t *scc,
-                        NR_BWP_Downlink_t *bwp);
 
-void fill_dci_pdu_rel15(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
+void find_search_space(int ss_type,
+                       NR_BWP_Downlink_t *bwp,
+                       NR_SearchSpace_t *ss);
+
+int nr_configure_pdcch(gNB_MAC_INST *nr_mac,
+                       nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
+                       uint16_t rnti,
+                       int ss_type,
+                       NR_SearchSpace_t *ss,
+                       NR_ServingCellConfigCommon_t *scc,
+                       NR_BWP_Downlink_t *bwp);
+
+void fill_dci_pdu_rel15(NR_CellGroupConfig_t *secondaryCellGroup,
+                        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 N_RB);
+                        int N_RB,
+                        int bwp_id);
+
+void prepare_dci(NR_CellGroupConfig_t *secondaryCellGroup,
+                 dci_pdu_rel15_t *dci_pdu_rel15,
+                 nr_dci_format_t format,
+                 int bwp_id);
+
+void find_aggregation_candidates(uint8_t *aggregation_level,
+                                 uint8_t *nr_of_candidates,
+                                 NR_SearchSpace_t *ss);
 
 int get_spf(nfapi_nr_config_request_scf_t *cfg);
 
@@ -208,7 +226,7 @@ int to_absslot(nfapi_nr_config_request_scf_t *cfg,int frame,int slot);
 
 void nr_get_tbs_dl(nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu,
 		   int x_overhead,
-                   uint8_t nodata_dmrs,
+                   uint8_t numdmrscdmgroupnodata,
                    uint8_t tb_scaling);
 /** \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);
@@ -263,7 +281,6 @@ void nr_generate_Msg2(module_id_t module_idP,
 
 void nr_schedule_reception_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP);
 
-int find_aggregation_level (NR_SearchSpace_t *ss);
 
 void nr_process_mac_pdu(
     module_id_t module_idP,
diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c
index d38a251a2b2f4bafbb00affe1409e39aae168f6e..56e020838d267847670fce5b0b9b5b864b439219 100644
--- a/openair2/LAYER2/NR_MAC_gNB/main.c
+++ b/openair2/LAYER2/NR_MAC_gNB/main.c
@@ -113,6 +113,11 @@ void mac_top_init_gNB(void)
        UE_list->next[list_el] = list_el + 1;
       UE_list->next_ul[list_el] = list_el + 1;
       UE_list->active[list_el] = FALSE;
+      for (int list_harq = 0; list_harq < NR_MAX_NB_HARQ_PROCESSES; list_harq++) {
+        UE_list->UE_sched_ctrl[list_el].harq_processes[list_harq].round = 0;
+        UE_list->UE_sched_ctrl[list_el].harq_processes[list_harq].ndi = 0;
+        UE_list->UE_sched_ctrl[list_el].harq_processes[list_harq].is_waiting = 0;
+      }
     }
 
     UE_list->next[list_el] = -1;
diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
index 23401eea5843687de0b2998e8b19021bf5e8b2a4..f84e7a900c95eeb53e485dcf39dcc33d465f696b 100644
--- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
+++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h
@@ -251,9 +251,14 @@ typedef struct NR_sched_pucch {
   uint8_t dai_c;
   uint8_t timing_indicator;
   uint8_t resource_indicator;
-  struct NR_sched_pucch *next_sched_pucch;
 } NR_sched_pucch;
 
+typedef struct NR_UE_harq {
+  uint8_t is_waiting;
+  uint8_t ndi;
+  uint8_t round;
+  uint16_t feedback_slot;
+} NR_UE_harq_t;
 
 /*! \brief scheduling control information set through an API */
 typedef struct {
@@ -262,10 +267,17 @@ typedef struct {
   NR_sched_pucch *sched_pucch;
   uint16_t ta_timer;
   int16_t ta_update;
+  uint8_t current_harq_pid;
+  NR_UE_harq_t harq_processes[NR_MAX_NB_HARQ_PROCESSES];
   int dummy;
   NR_UE_mac_ce_ctrl_t UE_mac_ce_ctrl;// MAC CE related information
 } NR_UE_sched_ctrl_t;
 
+typedef struct NR_preamble_ue {
+  uint8_t num_preambles;
+  uint8_t *preamble_list;
+} NR_preamble_ue;
+
 /*! \brief UE list used by gNB to order UEs/CC for scheduling*/
 typedef struct {
   DLSCH_PDU DLSCH_pdu[4][MAX_MOBILES_PER_GNB];
@@ -278,7 +290,10 @@ typedef struct {
   int avail;
   int num_UEs;
   boolean_t active[MAX_MOBILES_PER_GNB];
+  boolean_t fiveG_connected[MAX_MOBILES_PER_GNB];
   rnti_t rnti[MAX_MOBILES_PER_GNB];
+  rnti_t tc_rnti[MAX_MOBILES_PER_GNB];
+  NR_preamble_ue preambles[MAX_MOBILES_PER_GNB];
   NR_CellGroupConfig_t *secondaryCellGroup[MAX_MOBILES_PER_GNB];
 } NR_UE_list_t;
 
@@ -348,65 +363,4 @@ typedef struct gNB_MAC_INST_s {
   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/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c
index 174e07cc330fd286908ab505eb9c461f2c14e178..ec969c674128694cf39bfcd412c805862258a70e 100644
--- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c
+++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c
@@ -38,6 +38,7 @@
 #include "LAYER2/MAC/mac_proto.h"
 #include "LAYER2/NR_MAC_gNB/mac_proto.h"
 #include "common/ran_context.h"
+#include "executables/softmodem-common.h"
 
 #define MAX_IF_MODULES 100
 
@@ -76,76 +77,60 @@ void handle_nr_rach(NR_UL_IND_t *UL_info) {
 }
 
 
-void handle_nr_sr(NR_UL_IND_t *UL_info) {
-
+void handle_nr_uci(NR_UL_IND_t *UL_info, NR_UE_sched_ctrl_t *sched_ctrl) {
+  // TODO
+  int max_harq_rounds = 4; // TODO define macro
+  int num_ucis = UL_info->uci_ind.num_ucis;
+  nfapi_nr_uci_t *uci_list = UL_info->uci_ind.uci_list;
+
+  for (int i = 0; i < num_ucis; i++) {
+    switch (uci_list[i].pdu_type) {
+      case NFAPI_NR_UCI_PDCCH_PDU_TYPE: break;
+
+      case NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE: {
+        if (get_softmodem_params()->phy_test == 0) {
+          nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu = &uci_list[i].pucch_pdu_format_0_1;
+          // handle harq
+          int harq_idx_s = 0;
+          // iterate over received harq bits
+          for (int harq_bit = 0; harq_bit < uci_pdu->harq->num_harq; harq_bit++) {
+            // search for the right harq process
+            for (int harq_idx = harq_idx_s; harq_idx < NR_MAX_NB_HARQ_PROCESSES-1; harq_idx++) {
+              if ((UL_info->slot-1) == sched_ctrl->harq_processes[harq_idx].feedback_slot) {
+                if (uci_pdu->harq->harq_list[harq_bit].harq_value == 0)
+                  sched_ctrl->harq_processes[harq_idx].round++;
+                if ((uci_pdu->harq->harq_list[harq_bit].harq_value == 1) ||
+                   (sched_ctrl->harq_processes[harq_idx].round == max_harq_rounds)) {
+                  sched_ctrl->harq_processes[harq_idx].ndi ^= 1;
+                  sched_ctrl->harq_processes[harq_idx].round = 0;
+                }
+                sched_ctrl->harq_processes[harq_idx].is_waiting = 0;
+                harq_idx_s = harq_idx + 1;
+                break;
+              }
+              // if gNB fails to receive a ACK/NACK
+              else if (((UL_info->slot-1) > sched_ctrl->harq_processes[harq_idx].feedback_slot) &&
+                      (sched_ctrl->harq_processes[harq_idx].is_waiting)) {
+                sched_ctrl->harq_processes[harq_idx].round++;
+                if (sched_ctrl->harq_processes[harq_idx].round == max_harq_rounds) {
+                  sched_ctrl->harq_processes[harq_idx].ndi ^= 1;
+                  sched_ctrl->harq_processes[harq_idx].round = 0;
+                }
+                sched_ctrl->harq_processes[harq_idx].is_waiting = 0;
+              }
+            }
+          }
+        }
+        break;
+      }
 
- /* 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);
+      case NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE: break;
     }
   }
-  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->sr_ind.sr_indication_body.number_of_srs=0;*/
+  UL_info->uci_ind.num_ucis = 0;
 }
 
-void handle_nr_cqi(NR_UL_IND_t *UL_info) {
-
-    /*
-    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);
-
-    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++)
-      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->harq_ind.harq_indication_body.number_of_harqs=0;
-  }*/
-}
 
 void handle_nr_ulsch(NR_UL_IND_t *UL_info) {
   if(nfapi_mode == 1) {
@@ -245,9 +230,7 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) {
   // clear DL/UL info for new scheduling round
   clear_nr_nfapi_information(mac,CC_id,UL_info->frame,UL_info->slot);
   handle_nr_rach(UL_info);
-  handle_nr_sr(UL_info);
-  handle_nr_cqi(UL_info);
-  handle_nr_harq(UL_info);
+  handle_nr_uci(UL_info, &mac->UE_list.UE_sched_ctrl[0]);
   // clear HI prior to handling ULSCH
   mac->UL_dci_req[CC_id].numPdus = 0;
   handle_nr_ulsch(UL_info);
diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
index 43f43922a8a74b2e8cf97df76149fd3375605ef0..b18831b5468c4ffbc0efda14324af096ca94c0b0 100644
--- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
+++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c
@@ -283,7 +283,7 @@ int nr_ue_dcireq(nr_dcireq_t *dcireq) {
   dl_config->slot=UE_mac->dl_config_request.slot;
   dl_config->number_pdus=0;
 
-  printf(" UE_mac->dl_config_request.slot %d VS dcireq->slot %d \n", UE_mac->dl_config_request.slot, dcireq->slot);
+  //printf(" UE_mac->dl_config_request.slot %d VS dcireq->slot %d \n", UE_mac->dl_config_request.slot, dcireq->slot);
 
   LOG_D(PHY, "Entering UE DCI configuration frame %d slot %d \n", dcireq->frame, dcireq->slot);
 
diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h
index 42fa5f6de1f163940b238f42bd37e26dcc3de7dc..e366061674279747ddf104af40afc85b8ce79edd 100644
--- a/openair2/RRC/LTE/rrc_defs.h
+++ b/openair2/RRC/LTE/rrc_defs.h
@@ -271,6 +271,7 @@ typedef enum UE_STATE_e {
   RRC_RECONFIGURED,
   RRC_HO_EXECUTION,
   RRC_NR_NSA,
+  RRC_NR_NSA_RECONFIGURED
 } UE_STATE_t;
 
 typedef enum HO_STATE_e {
diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c
index 08c322f9b8f16fc137978ac681d6d114e5edbdf5..1d44751dcaf6396c61305ccb709660c867f87f3b 100644
--- a/openair2/RRC/LTE/rrc_eNB.c
+++ b/openair2/RRC/LTE/rrc_eNB.c
@@ -3251,8 +3251,7 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t
 
     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.carrierFreq_r15 =641272; //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;
@@ -3400,7 +3399,7 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t
     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.b1_ThresholdNR_r15.choice.nr_RSRP_r15 = 0;
     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;
@@ -4614,7 +4613,7 @@ rrc_eNB_process_MeasurementReport(
 
   /* TODO: improve NR triggering */
   if (measResults2->measId == 7) {
-    if (ue_context_pP->ue_context.Status != RRC_NR_NSA) {
+    if ((ue_context_pP->ue_context.Status != RRC_NR_NSA) && (ue_context_pP->ue_context.Status != RRC_NR_NSA_RECONFIGURED)) {
       MessageDef      *msg;
       ue_context_pP->ue_context.Status = RRC_NR_NSA;
 
@@ -4637,7 +4636,7 @@ rrc_eNB_process_MeasurementReport(
         for (int e_rab=0; e_rab < X2AP_ENDC_SGNB_ADDITION_REQ(msg).nb_e_rabs_tobeadded; e_rab++) {
           X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rabs_tobeadded[e_rab].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id;
           X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rabs_tobeadded[e_rab].gtp_teid = ue_context_pP->ue_context.e_rab[e_rab].param.gtp_teid;
-          X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rabs_tobeadded[e_rab].drb_ID = 1;
+          X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rabs_tobeadded[e_rab].drb_ID = ue_context_pP->ue_context.DRB_configList->list.array[e_rab]->drb_Identity; 
           memcpy(&X2AP_ENDC_SGNB_ADDITION_REQ(msg).e_rabs_tobeadded[e_rab].sgw_addr,
                  &ue_context_pP->ue_context.e_rab[e_rab].param.sgw_addr,
                  sizeof(transport_layer_addr_t));
@@ -7774,42 +7773,29 @@ rrc_eNB_decode_dcch(
               LOG_I(RRC,
                     PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_HO_EXECUTION (xid %ld)\n",
                     PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
-            } else {
-              dedicated_DRB = 0;
-              ue_context_p->ue_context.Status = RRC_RECONFIGURED;
-              LOG_I(RRC,
-                    PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (default DRB, xid %ld)\n",
-                    PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
             }
-
-            ue_context_p->ue_context.reestablishment_xid = -1;
-
-            //Looking for a condition to trigger S1AP E-RAB-Modification-indication, based on the reception of RRCConnectionReconfigurationComplete
-            //including NR specific elements. Not sure if this is the correct one and the correct placement
-            /*if(ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.
-                nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->
-                scg_ConfigResponseNR_r15->buf!=NULL){
-              //Trigger E-RAB Modification Indication
-              rrc_eNB_send_E_RAB_Modification_Indication(ctxt_pP, ue_context_p);
-            }*/
-
-            if(ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.
-                nonCriticalExtension!=NULL) {
+            else if(ue_context_p->ue_context.Status == RRC_NR_NSA){
+              //Looking for a condition to trigger S1AP E-RAB-Modification-indication, based on the reception of RRCConnectionReconfigurationComplete
+              //including NR specific elements.
               if(ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.
-                  nonCriticalExtension->nonCriticalExtension!=NULL) {
+                  nonCriticalExtension!=NULL) {
                 if(ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.
-                    nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL) {
+                    nonCriticalExtension->nonCriticalExtension!=NULL) {
                   if(ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.
-                      nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL) {
+                      nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL) {
                     if(ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.
-                        nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL) {
-                      if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.
-                          nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL) {
-                        if(ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.
-                            nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension
-                            ->scg_ConfigResponseNR_r15!=NULL) {
-                          /*Trigger E-RAB Modification Indication */
-                          rrc_eNB_send_E_RAB_Modification_Indication(ctxt_pP, ue_context_p);
+                        nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL) {
+                      if(ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.
+                          nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL) {
+                        if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.
+                            nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL) {
+                          if(ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.
+                              nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension
+                              ->scg_ConfigResponseNR_r15!=NULL) {
+                            ue_context_p->ue_context.Status = RRC_NR_NSA_RECONFIGURED;
+                            /*Trigger E-RAB Modification Indication */
+                            rrc_eNB_send_E_RAB_Modification_Indication(ctxt_pP, ue_context_p);
+                          }
                         }
                       }
                     }
@@ -7817,6 +7803,16 @@ rrc_eNB_decode_dcch(
                 }
               }
             }
+            else {
+              dedicated_DRB = 0;
+              ue_context_p->ue_context.Status = RRC_RECONFIGURED;
+              LOG_I(RRC,
+                    PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (default DRB, xid %ld)\n",
+                    PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier);
+            }
+
+            ue_context_p->ue_context.reestablishment_xid = -1;
+
           } else {
             dedicated_DRB = 1;
             ue_context_p->ue_context.Status = RRC_RECONFIGURED;
@@ -8371,36 +8367,54 @@ rrc_eNB_decode_dcch(
     return 0;
     //TTN for D2D
   } else if (ul_dcch_msg->message.present == LTE_UL_DCCH_MessageType_PR_messageClassExtension) {
-    LOG_I(RRC, "THINH [LTE_UL_DCCH_MessageType_PR_messageClassExtension]\n");
+    LOG_I(RRC, "[LTE_UL_DCCH_MessageType_PR_messageClassExtension]\n");
 
     switch (ul_dcch_msg->message.choice.messageClassExtension.present) {
       case LTE_UL_DCCH_MessageType__messageClassExtension_PR_NOTHING: /* No components present */
         break;
 
       case LTE_UL_DCCH_MessageType__messageClassExtension_PR_c2: //SidelinkUEInformation
-        //case UL_DCCH_MessageType__messageClassExtension__c2_PR_sidelinkUEInformation_r12: //SidelinkUEInformation
-        LOG_I(RRC,"THINH [LTE_UL_DCCH_MessageType__messageClassExtension_PR_c2]\n");
-        LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP,
+        if(ul_dcch_msg->message.choice.messageClassExtension.choice.c2.present ==
+          LTE_UL_DCCH_MessageType__messageClassExtension__c2_PR_scgFailureInformationNR_r15){
+          if (ul_dcch_msg->message.choice.messageClassExtension.choice.c2.choice.scgFailureInformationNR_r15.
+            criticalExtensions.present == LTE_SCGFailureInformationNR_r15__criticalExtensions_PR_c1){
+            if (ul_dcch_msg->message.choice.messageClassExtension.choice.c2.choice.scgFailureInformationNR_r15.criticalExtensions.
+              choice.c1.present == LTE_SCGFailureInformationNR_r15__criticalExtensions__c1_PR_scgFailureInformationNR_r15){
+              if (ul_dcch_msg->message.choice.messageClassExtension.choice.c2.choice.scgFailureInformationNR_r15.criticalExtensions.
+                choice.c1.choice.scgFailureInformationNR_r15.failureReportSCG_NR_r15!=NULL) {
+                LOG_E(RRC, "Received NR scgFailureInformation from UE, failure type: %ld \n",
+                  ul_dcch_msg->message.choice.messageClassExtension.choice.c2.choice.scgFailureInformationNR_r15.criticalExtensions.
+                  choice.c1.choice.scgFailureInformationNR_r15.failureReportSCG_NR_r15->failureType_r15);
+                xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)ul_dcch_msg);
+              }
+            }
+          }
+        }
+        else if(ul_dcch_msg->message.choice.messageClassExtension.choice.c2.present == LTE_UL_DCCH_MessageType__messageClassExtension__c2_PR_sidelinkUEInformation_r12){
+          //case UL_DCCH_MessageType__messageClassExtension__c2_PR_sidelinkUEInformation_r12: //SidelinkUEInformation
+          LOG_I(RRC,"THINH [LTE_UL_DCCH_MessageType__messageClassExtension_PR_c2]\n");
+          LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP,
                     "[MSG] RRC SidelinkUEInformation \n");
-        MSC_LOG_RX_MESSAGE(
-          MSC_RRC_ENB,
-          MSC_RRC_UE,
-          Rx_sdu,
-          sdu_sizeP,
-          MSC_AS_TIME_FMT" SidelinkUEInformation UE %x size %u",
-          MSC_AS_TIME_ARGS(ctxt_pP),
-          ue_context_p->ue_context.rnti,
-          sdu_sizeP);
-        LOG_I(RRC,
-              PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
-              "(SidelinkUEInformation) ---> RRC_eNB\n",
-              PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
-              DCCH,
+          MSC_LOG_RX_MESSAGE(
+              MSC_RRC_ENB,
+              MSC_RRC_UE,
+              Rx_sdu,
+              sdu_sizeP,
+              MSC_AS_TIME_FMT" SidelinkUEInformation UE %x size %u",
+              MSC_AS_TIME_ARGS(ctxt_pP),
+              ue_context_p->ue_context.rnti,
               sdu_sizeP);
-        rrc_eNB_process_SidelinkUEInformation(
-          ctxt_pP,
-          ue_context_p,
-          &ul_dcch_msg->message.choice.messageClassExtension.choice.c2.choice.sidelinkUEInformation_r12);
+          LOG_I(RRC,
+            PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
+            "(SidelinkUEInformation) ---> RRC_eNB\n",
+            PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
+            DCCH,
+            sdu_sizeP);
+          rrc_eNB_process_SidelinkUEInformation(
+            ctxt_pP,
+            ue_context_p,
+            &ul_dcch_msg->message.choice.messageClassExtension.choice.c2.choice.sidelinkUEInformation_r12);
+          }
         break;
 
       default:
diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c
index 0bdfb274eadb571688e53ed910a087470154bb6f..f2bda868dcd843da2e4863093ac477b88fc9fb61 100644
--- a/openair2/RRC/NR/rrc_gNB_nsa.c
+++ b/openair2/RRC/NR/rrc_gNB_nsa.c
@@ -42,10 +42,12 @@
 
 void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc, LTE_UE_CapabilityRAT_ContainerList_t *UE_CapabilityRAT_ContainerList, x2ap_ENDC_sgnb_addition_req_t *m, NR_CG_ConfigInfo_IEs_t  *cg_config_info) {
   struct rrc_gNB_ue_context_s        *ue_context_p = NULL;
-  OCTET_STRING_t *ueCapabilityRAT_Container_nr = NULL;
-  OCTET_STRING_t *ueCapabilityRAT_Container_MRDC = NULL;
-  int list_size;
+
+  OCTET_STRING_t *ueCapabilityRAT_Container_nr=NULL;
+  OCTET_STRING_t *ueCapabilityRAT_Container_MRDC=NULL;
   asn_dec_rval_t dec_rval;
+  int list_size=0;
+
   AssertFatal(UE_CapabilityRAT_ContainerList!=NULL,"UE_CapabilityRAT_ContainerList is null\n");
   AssertFatal((list_size=UE_CapabilityRAT_ContainerList->list.count) >= 2, "UE_CapabilityRAT_ContainerList->list.size %d < 2\n",UE_CapabilityRAT_ContainerList->list.count);
 
@@ -116,6 +118,10 @@ void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc, LTE_UE_CapabilityRAT_Container
   rrc_add_nsa_user(rrc,ue_context_p, m);
 }
 
+/* generate prototypes for the tree management functions (RB_INSERT used in rrc_add_nsa_user) */
+RB_PROTOTYPE(rrc_nr_ue_tree_s, rrc_gNB_ue_context_s, entries,
+             rrc_gNB_compare_ue_rnti_id);
+
 void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_p, x2ap_ENDC_sgnb_addition_req_t *m) {
   // generate nr-Config-r15 containers for LTE RRC : inside message for X2 EN-DC (CG-Config Message from 38.331)
   rrc_gNB_carrier_data_t *carrier=&rrc->carrier;
diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c
index ba1d20e9abd8767e6290297412075251cf6625b8..7b0bb099f76ee93698909d69e50f51dc15c808b8 100644
--- a/openair2/RRC/NR/rrc_gNB_reconfig.c
+++ b/openair2/RRC/NR/rrc_gNB_reconfig.c
@@ -182,1714 +182,1820 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco
   secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,
       sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA));
   secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,
-      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup));
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,
-      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition));
-  *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition =
-    NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,
-      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList));
-  NR_TCI_State_t *tci0=calloc(1,sizeof(*tci0));
-  tci0->tci_StateId=0;
-  tci0->qcl_Type1.cell=NULL;
-  tci0->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci0->qcl_Type1.bwp_Id));
-  *tci0->qcl_Type1.bwp_Id=1;
-  tci0->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tci0->qcl_Type1.referenceSignal.choice.csi_rs = 2;
-  tci0->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci0);
-  NR_TCI_State_t *tci1=calloc(1,sizeof(*tci1));
-  tci1->tci_StateId=1;
-  tci1->qcl_Type1.cell=NULL;
-  tci1->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci1->qcl_Type1.bwp_Id));
-  *tci1->qcl_Type1.bwp_Id=1;
-  tci1->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tci1->qcl_Type1.referenceSignal.choice.csi_rs = 6;
-  tci1->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci1);
-  NR_TCI_State_t *tci2=calloc(1,sizeof(*tci2));
-  tci2->tci_StateId=2;
-  tci2->qcl_Type1.cell=NULL;
-  tci2->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci2->qcl_Type1.bwp_Id));
-  *tci2->qcl_Type1.bwp_Id=1;
-  tci2->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tci2->qcl_Type1.referenceSignal.choice.csi_rs = 10;
-  tci2->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci2);
-  NR_TCI_State_t *tci3=calloc(1,sizeof(*tci3));
-  tci3->tci_StateId=3;
-  tci3->qcl_Type1.cell=NULL;
-  tci3->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci3->qcl_Type1.bwp_Id));
-  *tci3->qcl_Type1.bwp_Id=1;
-  tci3->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tci3->qcl_Type1.referenceSignal.choice.csi_rs = 14;
-  tci3->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci3);
-  NR_TCI_State_t *tci4=calloc(1,sizeof(*tci4));
-  tci4->tci_StateId=4;
-  tci4->qcl_Type1.cell=NULL;
-  tci4->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci4->qcl_Type1.bwp_Id));
-  *tci4->qcl_Type1.bwp_Id=1;
-  tci4->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tci4->qcl_Type1.referenceSignal.choice.csi_rs = 18;
-  tci4->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci4);
-  NR_TCI_State_t *tci5=calloc(1,sizeof(*tci5));
-  tci5->tci_StateId=5;
-  tci5->qcl_Type1.cell=NULL;
-  tci5->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci5->qcl_Type1.bwp_Id));
-  *tci5->qcl_Type1.bwp_Id=1;
-  tci5->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tci5->qcl_Type1.referenceSignal.choice.csi_rs = 22;
-  tci5->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci5);
-  NR_TCI_State_t *tci6=calloc(1,sizeof(*tci6));
-  tci6->tci_StateId=6;
-  tci6->qcl_Type1.cell=NULL;
-  tci6->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci6->qcl_Type1.bwp_Id));
-  *tci6->qcl_Type1.bwp_Id=1;
-  tci6->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tci6->qcl_Type1.referenceSignal.choice.csi_rs = 26;
-  tci6->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci6);
-  NR_TCI_State_t *tci7=calloc(1,sizeof(*tci7));
-  tci7->tci_StateId=7;
-  tci7->qcl_Type1.cell=NULL;
-  tci7->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci7->qcl_Type1.bwp_Id));
-  *tci7->qcl_Type1.bwp_Id=1;
-  tci7->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tci7->qcl_Type1.referenceSignal.choice.csi_rs = 30;
-  tci7->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci7);
-  NR_TCI_State_t *tci8=calloc(1,sizeof(*tci8));
-  tci8->tci_StateId=8;
-  tci8->qcl_Type1.cell=NULL;
-  tci8->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci8->qcl_Type1.bwp_Id));
-  *tci8->qcl_Type1.bwp_Id=1;
-  tci8->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tci8->qcl_Type1.referenceSignal.choice.ssb = 0;
-  tci8->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci8);
-  NR_TCI_State_t *tci9=calloc(1,sizeof(*tci9));
-  tci9->tci_StateId=9;
-  tci9->qcl_Type1.cell=NULL;
-  tci9->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci9->qcl_Type1.bwp_Id));
-  *tci9->qcl_Type1.bwp_Id=1;
-  tci9->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tci9->qcl_Type1.referenceSignal.choice.ssb = 1;
-  tci9->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci9);
-  NR_TCI_State_t *tci10=calloc(1,sizeof(*tci10));
-  tci10->tci_StateId=10;
-  tci10->qcl_Type1.cell=NULL;
-  tci10->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci10->qcl_Type1.bwp_Id));
-  *tci10->qcl_Type1.bwp_Id=1;
-  tci10->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tci10->qcl_Type1.referenceSignal.choice.ssb = 2;
-  tci10->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci10);
-  NR_TCI_State_t *tci11=calloc(1,sizeof(*tci11));
-  tci11->tci_StateId=11;
-  tci11->qcl_Type1.cell=NULL;
-  tci11->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci11->qcl_Type1.bwp_Id));
-  *tci11->qcl_Type1.bwp_Id=1;
-  tci11->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tci11->qcl_Type1.referenceSignal.choice.ssb = 3;
-  tci11->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci11);
-  NR_TCI_State_t *tci12=calloc(1,sizeof(*tci12));
-  tci12->tci_StateId=12;
-  tci12->qcl_Type1.cell=NULL;
-  tci12->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci12->qcl_Type1.bwp_Id));
-  *tci12->qcl_Type1.bwp_Id=1;
-  tci12->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tci12->qcl_Type1.referenceSignal.choice.ssb = 4;
-  tci12->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci12);
-  NR_TCI_State_t *tci13=calloc(1,sizeof(*tci13));
-  tci13->tci_StateId=13;
-  tci13->qcl_Type1.cell=NULL;
-  tci13->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci13->qcl_Type1.bwp_Id));
-  *tci13->qcl_Type1.bwp_Id=1;
-  tci13->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tci13->qcl_Type1.referenceSignal.choice.ssb = 5;
-  tci13->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci13);
-  NR_TCI_State_t *tci14=calloc(1,sizeof(*tci14));
-  tci14->tci_StateId=14;
-  tci14->qcl_Type1.cell=NULL;
-  tci14->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci14->qcl_Type1.bwp_Id));
-  *tci14->qcl_Type1.bwp_Id=1;
-  tci14->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tci14->qcl_Type1.referenceSignal.choice.ssb = 6;
-  tci14->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci14);
-  NR_TCI_State_t *tci15=calloc(1,sizeof(*tci15));
-  tci15->tci_StateId=15;
-  tci15->qcl_Type1.cell=NULL;
-  tci15->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci15->qcl_Type1.bwp_Id));
-  *tci15->qcl_Type1.bwp_Id=1;
-  tci15->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tci15->qcl_Type1.referenceSignal.choice.ssb = 7;
-  tci15->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci15);
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->mcs_Table=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,
-      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI));
-  *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,
-      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling));
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize =
-    calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize));
-  *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize =
-    NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->sps_Config = NULL; //calloc(1,sizeof(struct NR_SetupRelease_SPS_Config));
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig = calloc(1,
-      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig));
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->present = NR_SetupRelease_RadioLinkMonitoringConfig_PR_setup;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup = calloc(1,
-      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup));
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToAddModList=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToReleaseList=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = calloc(1,
-      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount));
-  *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount =
-    NR_RadioLinkMonitoringConfig__beamFailureInstanceMaxCount_n3;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = calloc(1,
-      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer));
-  *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer =
-    NR_RadioLinkMonitoringConfig__beamFailureDetectionTimer_pbfd2;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToReleaseList= NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList));
-  NR_BWP_Downlink_t *bwp=calloc(1,sizeof(*bwp));
-  bwp->bwp_Id=1;
-  bwp->bwp_Common=calloc(1,sizeof(*bwp->bwp_Common));
-  // copy common BWP size from initial BWP except for bandwdith
-  memcpy((void *)&bwp->bwp_Common->genericParameters,
-         &servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters,
-         sizeof(bwp->bwp_Common->genericParameters));
-  bwp->bwp_Common->genericParameters.locationAndBandwidth=PRBalloc_to_locationandbandwidth(
-        servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0);
-  bwp->bwp_Common->pdcch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon));
-  bwp->bwp_Common->pdcch_ConfigCommon->present = NR_SetupRelease_PDCCH_ConfigCommon_PR_setup;
-  bwp->bwp_Common->pdcch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup));
-  bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=NULL;
-  bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet));
-  NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset));
-  coreset->controlResourceSetId=1;
-  // frequencyDomainResources '11111111 11111111 00000000 00000000 00000000 00000'B,
-  coreset->frequencyDomainResources.buf = calloc(1,6);
-  coreset->frequencyDomainResources.buf[0] = 0xff;
-  coreset->frequencyDomainResources.buf[1] = 0xff;
-  coreset->frequencyDomainResources.buf[2] = 0;
-  coreset->frequencyDomainResources.buf[3] = 0;
-  coreset->frequencyDomainResources.buf[4] = 0;
-  coreset->frequencyDomainResources.buf[5] = 0;
-  coreset->frequencyDomainResources.size = 6;
-  coreset->frequencyDomainResources.bits_unused = 3;
-  coreset->duration=1;
-  coreset->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved;
-  coreset->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle;
-  coreset->tci_StatesPDCCH_ToAddList=calloc(1,sizeof(*coreset->tci_StatesPDCCH_ToAddList));
-  NR_TCI_StateId_t *tci[8];
-
-  for (int i=0; i<8; i++) {
-    tci[i]=calloc(1,sizeof(*tci[i]));
-    *tci[i] = i;
-    ASN_SEQUENCE_ADD(&coreset->tci_StatesPDCCH_ToAddList->list,tci[i]);
-  }
-
-  coreset->tci_StatesPDCCH_ToReleaseList = NULL;
-  coreset->tci_PresentInDCI = NULL;
-  coreset->pdcch_DMRS_ScramblingID = NULL;
-  bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet = coreset;
-  bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceZero=NULL;
-  bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=NULL;
-  bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList));
-  NR_SearchSpace_t *ss=calloc(1,sizeof(*ss));
-  ss->searchSpaceId = 1;
-  ss->controlResourceSetId=calloc(1,sizeof(*ss->controlResourceSetId));
-  *ss->controlResourceSetId=1;
-  ss->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss->monitoringSlotPeriodicityAndOffset));
-  ss->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
-  ss->duration=NULL;
-  ss->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss->monitoringSymbolsWithinSlot));
-  ss->monitoringSymbolsWithinSlot->buf = calloc(1,2);
-  // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed
-  ss->monitoringSymbolsWithinSlot->buf[1] = 0;
-  ss->monitoringSymbolsWithinSlot->buf[0] = (1<<7) | (1<<6);
-  ss->monitoringSymbolsWithinSlot->size = 2;
-  ss->monitoringSymbolsWithinSlot->bits_unused = 2;
-  ss->nrofCandidates = calloc(1,sizeof(*ss->nrofCandidates));
-  ss->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0;
-  ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0;
-  ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1;
-  ss->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0;
-  ss->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0;
-  ss->searchSpaceType = calloc(1,sizeof(*ss->searchSpaceType));
-  ss->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common;
-  ss->searchSpaceType->choice.common=calloc(1,sizeof(*ss->searchSpaceType->choice.common));
-  ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0));
-  ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,ss);
-  bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=NULL;
-  bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation=NULL;
-  bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->pagingSearchSpace=NULL;
-  bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace));
-  *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=1;
-  bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ext1=NULL;
-  bwp->bwp_Common->pdsch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon));
-  bwp->bwp_Common->pdsch_ConfigCommon->present = NR_SetupRelease_PDSCH_ConfigCommon_PR_setup;
-  bwp->bwp_Common->pdsch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup));
-  bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList));
-  // copy PDSCH TimeDomainResourceAllocation from InitialBWP
-  NR_PDSCH_TimeDomainResourceAllocation_t *pdschi;
-
-  for (int i=0; i<servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count; i++) {
-    pdschi= calloc(1,sizeof(*pdschi));
-    AssertFatal(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0!=NULL,"element %d is null\n",i);
-    pdschi->k0 = calloc(1,sizeof(*pdschi->k0));
-    *pdschi->k0 = *servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0;
-    pdschi->mappingType = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->mappingType;
-    pdschi->startSymbolAndLength = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength;
-    ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list,pdschi);
-  }
-
-  bwp->bwp_Dedicated=calloc(1,sizeof(*bwp->bwp_Dedicated));
-  bwp->bwp_Dedicated->pdcch_Config=calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config));
-  bwp->bwp_Dedicated->pdcch_Config->present = NR_SetupRelease_PDCCH_Config_PR_setup;
-  bwp->bwp_Dedicated->pdcch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup));
-  bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList));
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list,
-                   coreset);
-  bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList));
-  NR_SearchSpace_t *ss2 = calloc(1,sizeof(*ss2));
-  ss2->searchSpaceId=2;
-  ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId));
-  *ss2->controlResourceSetId=1;
-  ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset));
-  ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
-  ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0;
-  ss2->duration=NULL;
-  ss2->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss2->monitoringSymbolsWithinSlot));
-  ss2->monitoringSymbolsWithinSlot->buf = calloc(1,2);
-  ss2->monitoringSymbolsWithinSlot->size = 2;
-  ss2->monitoringSymbolsWithinSlot->bits_unused = 2;
-  ss2->monitoringSymbolsWithinSlot->buf[0]=0xc0;
-  ss2->monitoringSymbolsWithinSlot->buf[1]=0x0;
-  ss2->nrofCandidates=calloc(1,sizeof(*ss2->nrofCandidates));
-  ss2->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0;
-  ss2->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0;
-  ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n4;
-  ss2->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0;
-  ss2->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0;
-  ss2->searchSpaceType=calloc(1,sizeof(*ss2->searchSpaceType));
-  ss2->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_ue_Specific;
-  ss2->searchSpaceType->choice.ue_Specific = calloc(1,sizeof(*ss2->searchSpaceType->choice.ue_Specific));
-  ss2->searchSpaceType->choice.ue_Specific->dci_Formats=NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_0_And_1_0;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list,
-                   ss2);
-  bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToReleaseList = NULL;
-  bwp->bwp_Dedicated->pdsch_Config = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config));
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup));
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL;
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition));
+ *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0;
+
+#if 0
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList));
+
+ NR_TCI_State_t*tci0=calloc(1,sizeof(*tci0));
+ tci0->tci_StateId=0;
+ tci0->qcl_Type1.cell=NULL;
+ tci0->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci0->qcl_Type1.bwp_Id));
+ *tci0->qcl_Type1.bwp_Id=1;
+ tci0->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tci0->qcl_Type1.referenceSignal.choice.csi_rs = 2;
+ tci0->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci0);
+
+ NR_TCI_State_t*tci1=calloc(1,sizeof(*tci1));
+ tci1->tci_StateId=1;
+ tci1->qcl_Type1.cell=NULL;
+ tci1->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci1->qcl_Type1.bwp_Id));
+ *tci1->qcl_Type1.bwp_Id=1;
+ tci1->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tci1->qcl_Type1.referenceSignal.choice.csi_rs = 6;
+ tci1->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci1);
+
+ NR_TCI_State_t*tci2=calloc(1,sizeof(*tci2));
+ tci2->tci_StateId=2;
+ tci2->qcl_Type1.cell=NULL;
+ tci2->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci2->qcl_Type1.bwp_Id));
+ *tci2->qcl_Type1.bwp_Id=1;
+ tci2->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tci2->qcl_Type1.referenceSignal.choice.csi_rs = 10;
+ tci2->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci2);
+
+ NR_TCI_State_t *tci3=calloc(1,sizeof(*tci3));
+ tci3->tci_StateId=3;
+ tci3->qcl_Type1.cell=NULL;
+ tci3->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci3->qcl_Type1.bwp_Id));
+ *tci3->qcl_Type1.bwp_Id=1;
+ tci3->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tci3->qcl_Type1.referenceSignal.choice.csi_rs = 14;
+ tci3->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci3);
+
+ NR_TCI_State_t*tci4=calloc(1,sizeof(*tci4));
+ tci4->tci_StateId=4;
+ tci4->qcl_Type1.cell=NULL;
+ tci4->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci4->qcl_Type1.bwp_Id));
+ *tci4->qcl_Type1.bwp_Id=1;
+ tci4->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tci4->qcl_Type1.referenceSignal.choice.csi_rs = 18;
+ tci4->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci4);
+
+ NR_TCI_State_t*tci5=calloc(1,sizeof(*tci5));
+ tci5->tci_StateId=5;
+ tci5->qcl_Type1.cell=NULL;
+ tci5->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci5->qcl_Type1.bwp_Id));
+ *tci5->qcl_Type1.bwp_Id=1;
+ tci5->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tci5->qcl_Type1.referenceSignal.choice.csi_rs = 22;
+ tci5->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci5);
+
+ NR_TCI_State_t*tci6=calloc(1,sizeof(*tci6));
+ tci6->tci_StateId=6;
+ tci6->qcl_Type1.cell=NULL;
+ tci6->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci6->qcl_Type1.bwp_Id));
+ *tci6->qcl_Type1.bwp_Id=1;
+ tci6->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tci6->qcl_Type1.referenceSignal.choice.csi_rs = 26;
+ tci6->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci6);
+
+ NR_TCI_State_t*tci7=calloc(1,sizeof(*tci7));
+ tci7->tci_StateId=7;
+ tci7->qcl_Type1.cell=NULL;
+ tci7->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci7->qcl_Type1.bwp_Id));
+ *tci7->qcl_Type1.bwp_Id=1;
+ tci7->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tci7->qcl_Type1.referenceSignal.choice.csi_rs = 30;
+ tci7->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci7);
+
+ NR_TCI_State_t*tci8=calloc(1,sizeof(*tci8));
+ tci8->tci_StateId=8;
+ tci8->qcl_Type1.cell=NULL;
+ tci8->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci8->qcl_Type1.bwp_Id));
+ *tci8->qcl_Type1.bwp_Id=1;
+ tci8->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tci8->qcl_Type1.referenceSignal.choice.ssb = 0;
+ tci8->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci8);
+
+ NR_TCI_State_t*tci9=calloc(1,sizeof(*tci9));
+ tci9->tci_StateId=9;
+ tci9->qcl_Type1.cell=NULL;
+ tci9->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci9->qcl_Type1.bwp_Id));
+ *tci9->qcl_Type1.bwp_Id=1;
+ tci9->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tci9->qcl_Type1.referenceSignal.choice.ssb = 1;
+ tci9->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci9);
+
+ NR_TCI_State_t*tci10=calloc(1,sizeof(*tci10));
+ tci10->tci_StateId=10;
+ tci10->qcl_Type1.cell=NULL;
+ tci10->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci10->qcl_Type1.bwp_Id));
+ *tci10->qcl_Type1.bwp_Id=1;
+ tci10->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tci10->qcl_Type1.referenceSignal.choice.ssb = 2;
+ tci10->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci10);
+
+ NR_TCI_State_t*tci11=calloc(1,sizeof(*tci11));
+ tci11->tci_StateId=11;
+ tci11->qcl_Type1.cell=NULL;
+ tci11->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci11->qcl_Type1.bwp_Id));
+ *tci11->qcl_Type1.bwp_Id=1;
+ tci11->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tci11->qcl_Type1.referenceSignal.choice.ssb = 3;
+ tci11->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci11);
+
+ NR_TCI_State_t*tci12=calloc(1,sizeof(*tci12));
+ tci12->tci_StateId=12;
+ tci12->qcl_Type1.cell=NULL;
+ tci12->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci12->qcl_Type1.bwp_Id));
+ *tci12->qcl_Type1.bwp_Id=1;
+ tci12->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tci12->qcl_Type1.referenceSignal.choice.ssb = 4;
+ tci12->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci12);
+
+ NR_TCI_State_t*tci13=calloc(1,sizeof(*tci13));
+ tci13->tci_StateId=13;
+ tci13->qcl_Type1.cell=NULL;
+ tci13->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci13->qcl_Type1.bwp_Id));
+ *tci13->qcl_Type1.bwp_Id=1;
+ tci13->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tci13->qcl_Type1.referenceSignal.choice.ssb = 5;
+ tci13->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci13);
+
+ NR_TCI_State_t*tci14=calloc(1,sizeof(*tci14));
+ tci14->tci_StateId=14;
+ tci14->qcl_Type1.cell=NULL;
+ tci14->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci14->qcl_Type1.bwp_Id));
+ *tci14->qcl_Type1.bwp_Id=1;
+ tci14->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tci14->qcl_Type1.referenceSignal.choice.ssb = 6;
+ tci14->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci14);
+
+ NR_TCI_State_t*tci15=calloc(1,sizeof(*tci15));
+ tci15->tci_StateId=15;
+ tci15->qcl_Type1.cell=NULL;
+ tci15->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci15->qcl_Type1.bwp_Id));
+ *tci15->qcl_Type1.bwp_Id=1;
+ tci15->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tci15->qcl_Type1.referenceSignal.choice.ssb = 7;
+ tci15->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci15);
+#endif
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->mcs_Table=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI));
+ *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling));
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize =
+   calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize));
+ *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->sps_Config = NULL; //calloc(1,sizeof(struct NR_SetupRelease_SPS_Config));
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig = NULL;
+#if 0
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig));
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->present = NR_SetupRelease_RadioLinkMonitoringConfig_PR_setup;
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup));
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToAddModList=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToReleaseList=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount));
+ *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = NR_RadioLinkMonitoringConfig__beamFailureInstanceMaxCount_n3;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer));
+ *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = NR_RadioLinkMonitoringConfig__beamFailureDetectionTimer_pbfd2;
+#endif
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToReleaseList= NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList));
+
+ NR_BWP_Downlink_t *bwp=calloc(1,sizeof(*bwp));
+ bwp->bwp_Id=1;
+ bwp->bwp_Common=calloc(1,sizeof(*bwp->bwp_Common));
+ // copy common BWP size from initial BWP except for bandwdith
+ memcpy((void*)&bwp->bwp_Common->genericParameters,
+	&servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters,
+	sizeof(bwp->bwp_Common->genericParameters));
+ bwp->bwp_Common->genericParameters.locationAndBandwidth=PRBalloc_to_locationandbandwidth(servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0);
+
+ 
+ bwp->bwp_Common->pdcch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon));
+ bwp->bwp_Common->pdcch_ConfigCommon->present = NR_SetupRelease_PDCCH_ConfigCommon_PR_setup;
+ bwp->bwp_Common->pdcch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup));
+ bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=NULL;
+ bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet));
+
+ NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset));
+ coreset->controlResourceSetId=1;
+ // frequencyDomainResources '11111111 11111111 00000000 00000000 00000000 00000'B,
+ coreset->frequencyDomainResources.buf = calloc(1,6);
+ coreset->frequencyDomainResources.buf[0] = 0xff;
+ coreset->frequencyDomainResources.buf[1] = 0xff;
+ coreset->frequencyDomainResources.buf[2] = 0;
+ coreset->frequencyDomainResources.buf[3] = 0;
+ coreset->frequencyDomainResources.buf[4] = 0;
+ coreset->frequencyDomainResources.buf[5] = 0;
+ coreset->frequencyDomainResources.size = 6;
+ coreset->frequencyDomainResources.bits_unused = 3;
+ coreset->duration=1;
+ coreset->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved;
+ coreset->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle;
+
+ coreset->tci_StatesPDCCH_ToAddList=calloc(1,sizeof(*coreset->tci_StatesPDCCH_ToAddList));
+ NR_TCI_StateId_t *tci[8];
+ for (int i=0;i<8;i++) {
+   tci[i]=calloc(1,sizeof(*tci[i]));
+   *tci[i] = i;
+   ASN_SEQUENCE_ADD(&coreset->tci_StatesPDCCH_ToAddList->list,tci[i]);
+ }
+ coreset->tci_StatesPDCCH_ToReleaseList = NULL;
+ coreset->tci_PresentInDCI = NULL;
+ coreset->pdcch_DMRS_ScramblingID = NULL;
+
+ bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet = coreset;
+
+ bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceZero=NULL;
+ bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=NULL;
+ bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList));
+
+ NR_SearchSpace_t *ss=calloc(1,sizeof(*ss));
+ ss->searchSpaceId = 1;
+ ss->controlResourceSetId=calloc(1,sizeof(*ss->controlResourceSetId));
+ *ss->controlResourceSetId=1;
+ ss->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss->monitoringSlotPeriodicityAndOffset));
+ ss->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
+ ss->duration=NULL; 
+ ss->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss->monitoringSymbolsWithinSlot));
+ ss->monitoringSymbolsWithinSlot->buf = calloc(1,2);
+ // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed
+ ss->monitoringSymbolsWithinSlot->buf[1] = 0;
+ ss->monitoringSymbolsWithinSlot->buf[0] = (1<<7) | (1<<6);
+ ss->monitoringSymbolsWithinSlot->size = 2;
+ ss->monitoringSymbolsWithinSlot->bits_unused = 2;
+ ss->nrofCandidates = calloc(1,sizeof(*ss->nrofCandidates));
+ ss->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0;
+ ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0;
+ ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1;
+ ss->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0;
+ ss->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0;
+ ss->searchSpaceType = calloc(1,sizeof(*ss->searchSpaceType));
+ ss->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common;
+ ss->searchSpaceType->choice.common=calloc(1,sizeof(*ss->searchSpaceType->choice.common));
+ ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0));
+
+ ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,ss);
+ 
+
+ bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=NULL;
+ bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation=NULL;
+ bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->pagingSearchSpace=NULL;
+ bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace));
+ *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=1;
+ bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ext1=NULL;
+
+ bwp->bwp_Common->pdsch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon));
+ bwp->bwp_Common->pdsch_ConfigCommon->present = NR_SetupRelease_PDSCH_ConfigCommon_PR_setup;
+ bwp->bwp_Common->pdsch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup));
+ bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList));
+
+ // copy PDSCH TimeDomainResourceAllocation from InitialBWP
+ 
+ NR_PDSCH_TimeDomainResourceAllocation_t *pdschi;
+ for (int i=0;i<servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count;i++) {
+   pdschi= calloc(1,sizeof(*pdschi));
+   AssertFatal(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0!=NULL,"element %d is null\n",i);
+ 
+   pdschi->k0 = calloc(1,sizeof(*pdschi->k0));
+   *pdschi->k0 = *servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0;
+   pdschi->mappingType = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->mappingType;
+   pdschi->startSymbolAndLength = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength;
+   ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list,pdschi);
+ }
+
+ bwp->bwp_Dedicated=calloc(1,sizeof(*bwp->bwp_Dedicated));
+
+ bwp->bwp_Dedicated->pdcch_Config=calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config));
+ bwp->bwp_Dedicated->pdcch_Config->present = NR_SetupRelease_PDCCH_Config_PR_setup;
+ bwp->bwp_Dedicated->pdcch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup));
+ bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList));
+
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list,
+		  coreset);
+
+ bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList));
+
+ NR_SearchSpace_t *ss2 = calloc(1,sizeof(*ss2));
+
+ ss2->searchSpaceId=2;
+ ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId));
+ *ss2->controlResourceSetId=1;
+ ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset));
+ ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
+ ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0;
+ ss2->duration=NULL;
+ ss2->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss2->monitoringSymbolsWithinSlot));
+ ss2->monitoringSymbolsWithinSlot->buf = calloc(1,2);
+ ss2->monitoringSymbolsWithinSlot->size = 2;
+ ss2->monitoringSymbolsWithinSlot->bits_unused = 2;
+ ss2->monitoringSymbolsWithinSlot->buf[0]=0xc0;
+ ss2->monitoringSymbolsWithinSlot->buf[1]=0x0;
+ ss2->nrofCandidates=calloc(1,sizeof(*ss2->nrofCandidates));
+ ss2->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0;
+ ss2->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0;
+ ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n4;
+ ss2->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0;
+ ss2->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0;
+ ss2->searchSpaceType=calloc(1,sizeof(*ss2->searchSpaceType));
+ ss2->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_ue_Specific;
+ ss2->searchSpaceType->choice.ue_Specific = calloc(1,sizeof(*ss2->searchSpaceType->choice.ue_Specific));
+ ss2->searchSpaceType->choice.ue_Specific->dci_Formats=NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1;
+
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list,
+		  ss2);
+
+
+ bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToReleaseList = NULL;
+
+ bwp->bwp_Dedicated->pdsch_Config = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config));
+
   bwp->bwp_Dedicated->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup;
   bwp->bwp_Dedicated->pdsch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup));
   bwp->bwp_Dedicated->pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL;
   bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA));
   bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,
-      sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup));
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,
-      sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition));
-  *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList));
-  NR_TCI_State_t *tcid0=calloc(1,sizeof(*tcid0));
-  tcid0->tci_StateId=0;
-  tcid0->qcl_Type1.cell=NULL;
-  tcid0->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid0->qcl_Type1.bwp_Id));
-  *tcid0->qcl_Type1.bwp_Id=1;
-  tcid0->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tcid0->qcl_Type1.referenceSignal.choice.csi_rs = 2;
-  tcid0->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid0);
-  NR_TCI_State_t *tcid1=calloc(1,sizeof(*tcid1));
-  tcid1->tci_StateId=0;
-  tcid1->qcl_Type1.cell=NULL;
-  tcid1->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid1->qcl_Type1.bwp_Id));
-  *tcid1->qcl_Type1.bwp_Id=1;
-  tcid1->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tcid1->qcl_Type1.referenceSignal.choice.csi_rs = 6;
-  tcid1->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid1);
-  NR_TCI_State_t *tcid2=calloc(1,sizeof(*tcid2));
-  tcid2->tci_StateId=2;
-  tcid2->qcl_Type1.cell=NULL;
-  tcid2->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid2->qcl_Type1.bwp_Id));
-  *tcid2->qcl_Type1.bwp_Id=1;
-  tcid2->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tcid2->qcl_Type1.referenceSignal.choice.csi_rs = 10;
-  tcid2->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid2);
-  NR_TCI_State_t *tcid3=calloc(1,sizeof(*tcid3));
-  tcid3->tci_StateId=3;
-  tcid3->qcl_Type1.cell=NULL;
-  tcid3->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid3->qcl_Type1.bwp_Id));
-  *tcid3->qcl_Type1.bwp_Id=1;
-  tcid3->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tcid3->qcl_Type1.referenceSignal.choice.csi_rs = 14;
-  tcid3->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid3);
-  NR_TCI_State_t *tcid4=calloc(1,sizeof(*tcid4));
-  tcid4->tci_StateId=4;
-  tcid4->qcl_Type1.cell=NULL;
-  tcid4->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid4->qcl_Type1.bwp_Id));
-  *tcid4->qcl_Type1.bwp_Id=1;
-  tcid4->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tcid4->qcl_Type1.referenceSignal.choice.csi_rs = 18;
-  tcid4->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid4);
-  NR_TCI_State_t *tcid5=calloc(1,sizeof(*tcid5));
-  tcid5->tci_StateId=5;
-  tcid5->qcl_Type1.cell=NULL;
-  tcid5->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid5->qcl_Type1.bwp_Id));
-  *tcid5->qcl_Type1.bwp_Id=1;
-  tcid5->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tcid5->qcl_Type1.referenceSignal.choice.csi_rs = 22;
-  tcid5->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid5);
-  NR_TCI_State_t *tcid6=calloc(1,sizeof(*tcid6));
-  tcid6->tci_StateId=6;
-  tcid6->qcl_Type1.cell=NULL;
-  tcid6->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid6->qcl_Type1.bwp_Id));
-  *tcid6->qcl_Type1.bwp_Id=1;
-  tcid6->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tcid6->qcl_Type1.referenceSignal.choice.csi_rs = 26;
-  tcid6->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid6);
-  NR_TCI_State_t *tcid7=calloc(1,sizeof(*tcid7));
-  tcid7->tci_StateId=7;
-  tcid7->qcl_Type1.cell=NULL;
-  tcid7->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid7->qcl_Type1.bwp_Id));
-  *tcid7->qcl_Type1.bwp_Id=1;
-  tcid7->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
-  tcid7->qcl_Type1.referenceSignal.choice.csi_rs = 30;
-  tcid7->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid7);
-  NR_TCI_State_t *tcid8=calloc(1,sizeof(*tcid8));
-  tcid8->tci_StateId=8;
-  tcid8->qcl_Type1.cell=NULL;
-  tcid8->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid8->qcl_Type1.bwp_Id));
-  *tcid8->qcl_Type1.bwp_Id=1;
-  tcid8->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tcid8->qcl_Type1.referenceSignal.choice.ssb = 0;
-  tcid8->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid8);
-  NR_TCI_State_t *tcid9=calloc(1,sizeof(*tcid9));
-  tcid9->tci_StateId=9;
-  tcid9->qcl_Type1.cell=NULL;
-  tcid9->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid9->qcl_Type1.bwp_Id));
-  *tcid9->qcl_Type1.bwp_Id=1;
-  tcid9->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tcid9->qcl_Type1.referenceSignal.choice.ssb = 1;
-  tcid9->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid9);
-  NR_TCI_State_t *tcid10=calloc(1,sizeof(*tcid10));
-  tcid10->tci_StateId=10;
-  tcid10->qcl_Type1.cell=NULL;
-  tcid10->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid10->qcl_Type1.bwp_Id));
-  *tcid10->qcl_Type1.bwp_Id=1;
-  tcid10->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tcid10->qcl_Type1.referenceSignal.choice.ssb = 2;
-  tcid10->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid10);
-  NR_TCI_State_t *tcid11=calloc(1,sizeof(*tcid11));
-  tcid11->tci_StateId=11;
-  tcid11->qcl_Type1.cell=NULL;
-  tcid11->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid11->qcl_Type1.bwp_Id));
-  *tcid11->qcl_Type1.bwp_Id=1;
-  tcid11->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tcid11->qcl_Type1.referenceSignal.choice.ssb = 3;
-  tcid11->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid11);
-  NR_TCI_State_t *tcid12=calloc(1,sizeof(*tcid12));
-  tcid12->tci_StateId=12;
-  tcid12->qcl_Type1.cell=NULL;
-  tcid12->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid12->qcl_Type1.bwp_Id));
-  *tcid12->qcl_Type1.bwp_Id=1;
-  tcid12->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tcid12->qcl_Type1.referenceSignal.choice.ssb = 4;
-  tcid12->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid12);
-  NR_TCI_State_t *tcid13=calloc(1,sizeof(*tcid13));
-  tcid13->tci_StateId=13;
-  tcid13->qcl_Type1.cell=NULL;
-  tcid13->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid13->qcl_Type1.bwp_Id));
-  *tcid13->qcl_Type1.bwp_Id=1;
-  tcid13->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tcid13->qcl_Type1.referenceSignal.choice.ssb = 5;
-  tcid13->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid13);
-  NR_TCI_State_t *tcid14=calloc(1,sizeof(*tcid14));
-  tcid14->tci_StateId=14;
-  tcid14->qcl_Type1.cell=NULL;
-  tcid14->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid14->qcl_Type1.bwp_Id));
-  *tcid14->qcl_Type1.bwp_Id=1;
-  tcid14->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tcid14->qcl_Type1.referenceSignal.choice.ssb = 6;
-  tcid14->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid14);
-  NR_TCI_State_t *tcid15=calloc(1,sizeof(*tcid15));
-  tcid15->tci_StateId=15;
-  tcid15->qcl_Type1.cell=NULL;
-  tcid15->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid15->qcl_Type1.bwp_Id));
-  *tcid15->qcl_Type1.bwp_Id=1;
-  tcid15->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
-  tcid15->qcl_Type1.referenceSignal.choice.ssb = 7;
-  tcid15->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
-  ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid15);
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI));
-  *bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling));
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize =
-    calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize));
-  *bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI));
-  *bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling));
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize =
-    calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize));
-  *bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
-  bwp->bwp_Dedicated->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL;
-  bwp->bwp_Dedicated->sps_Config = NULL; //calloc(1,sizeof(struct NR_SetupRelease_SPS_Config));
-  bwp->bwp_Dedicated->radioLinkMonitoringConfig = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig));
-  bwp->bwp_Dedicated->radioLinkMonitoringConfig->present = NR_SetupRelease_RadioLinkMonitoringConfig_PR_setup;
-  bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup));
-  bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToAddModList=NULL;
-  bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToReleaseList=NULL;
-  bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount));
-  *bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = NR_RadioLinkMonitoringConfig__beamFailureInstanceMaxCount_n3;
-  bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer));
-  *bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = NR_RadioLinkMonitoringConfig__beamFailureDetectionTimer_pbfd2;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list,bwp);
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id));
-  *secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id=1;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->bwp_InactivityTimer = NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig));
-  NR_BWP_UplinkDedicated_t *initialUplinkBWP = calloc(1,sizeof(*initialUplinkBWP));
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP = initialUplinkBWP;
-  initialUplinkBWP->pucch_Config = NULL;
-  initialUplinkBWP->pusch_Config = calloc(1,sizeof(*initialUplinkBWP->pusch_Config));
-  initialUplinkBWP->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup;
-  NR_PUSCH_Config_t *pusch_Config = calloc(1,sizeof(*pusch_Config));
-  initialUplinkBWP->pusch_Config->choice.setup = pusch_Config;
-  pusch_Config->txConfig=calloc(1,sizeof(*pusch_Config->txConfig));
-  *pusch_Config->txConfig= NR_PUSCH_Config__txConfig_codebook;
-  pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA = NULL;
-  pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB));
-  pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup;
-  pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup));
-  NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup;
-  NR_DMRS_UplinkConfig->dmrs_Type = NULL;
-  NR_DMRS_UplinkConfig->dmrs_AdditionalPosition =NR_DMRS_UplinkConfig__dmrs_AdditionalPosition_pos0;
-  NR_DMRS_UplinkConfig->phaseTrackingRS=NULL;
-  NR_DMRS_UplinkConfig->maxLength=NULL;
-  NR_DMRS_UplinkConfig->transformPrecodingDisabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingDisabled));
-  NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID0 = NULL;
-  NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID1 = NULL;
-  NR_DMRS_UplinkConfig->transformPrecodingEnabled = NULL;
-  pusch_Config->pusch_PowerControl = calloc(1,sizeof(*pusch_Config->pusch_PowerControl));
-  pusch_Config->pusch_PowerControl->tpc_Accumulation = NULL;
-  pusch_Config->pusch_PowerControl->msg3_Alpha = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->msg3_Alpha));
-  *pusch_Config->pusch_PowerControl->msg3_Alpha = NR_Alpha_alpha1;
-  pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = NULL;
-  pusch_Config->pusch_PowerControl->p0_AlphaSets = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_AlphaSets));
-  NR_P0_PUSCH_AlphaSet_t *aset = calloc(1,sizeof(*aset));
-  aset->p0_PUSCH_AlphaSetId=0;
-  aset->p0=calloc(1,sizeof(*aset->p0));
-  *aset->p0 = 0;
-  aset->alpha=calloc(1,sizeof(*aset->alpha));
-  *aset->alpha=NR_Alpha_alpha1;
-  ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->p0_AlphaSets->list,aset);
-  pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList));
-  NR_PUSCH_PathlossReferenceRS_t *pl = calloc(1,sizeof(*pl));
-  pl->pusch_PathlossReferenceRS_Id=0;
-  pl->referenceSignal.present = NR_PUSCH_PathlossReferenceRS__referenceSignal_PR_csi_RS_Index;
-  pl->referenceSignal.choice.csi_RS_Index=0;
-  ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList->list,pl);
-  pusch_Config->pusch_PowerControl->pathlossReferenceRSToReleaseList = NULL;
-  pusch_Config->pusch_PowerControl->twoPUSCH_PC_AdjustmentStates = NULL;
-  pusch_Config->pusch_PowerControl->deltaMCS = NULL;
-  pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList = NULL;
-  pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToReleaseList = NULL;
-  pusch_Config->frequencyHopping=NULL;
-  pusch_Config->frequencyHoppingOffsetLists=NULL;
-  pusch_Config->resourceAllocation = NR_PUSCH_Config__resourceAllocation_resourceAllocationType1;
-  pusch_Config->pusch_TimeDomainAllocationList = NULL;
-  pusch_Config->pusch_AggregationFactor=NULL;
-  pusch_Config->mcs_Table=NULL;
-  pusch_Config->mcs_TableTransformPrecoder=NULL;
-  pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder));
-  *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled;
-  pusch_Config->codebookSubset=calloc(1,sizeof(*pusch_Config->codebookSubset));
-  *pusch_Config->codebookSubset = NR_PUSCH_Config__codebookSubset_nonCoherent;
-  pusch_Config->maxRank=calloc(1,sizeof(*pusch_Config->maxRank));
-  *pusch_Config->maxRank= 1;
-  pusch_Config->rbg_Size=NULL;
-  pusch_Config->uci_OnPUSCH=NULL;
-  pusch_Config->tp_pi2BPSK=NULL;
-  initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config));
-  initialUplinkBWP->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup;
-  NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config));
-  initialUplinkBWP->srs_Config->choice.setup=srs_Config;
-  srs_Config->srs_ResourceSetToReleaseList=NULL;
-  srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList));
-  NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0));
-  srs_resset0->srs_ResourceSetId = 0;
-  srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList));
-  NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id));
-  *srs_resset0_id=0;
-  ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id);
-  srs_Config->srs_ResourceToReleaseList=NULL;
-  srs_resset0->resourceType.present =  NR_SRS_ResourceSet__resourceType_PR_aperiodic;
-  srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic));
-  srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1;
-  srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL;
-  srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset));
-  *srs_resset0->resourceType.choice.aperiodic->slotOffset=2;
-  srs_resset0->resourceType.choice.aperiodic->ext1=NULL;
-  srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook;
-  srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha));
-  *srs_resset0->alpha = NR_Alpha_alpha1;
-  srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0));
-  *srs_resset0->p0=-80;
-  srs_resset0->pathlossReferenceRS=NULL;
-  srs_resset0->srs_PowerControlAdjustmentStates=NULL;
-  ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0);
-  srs_Config->srs_ResourceToReleaseList=NULL;
-  srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList));
-  NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0));
-  srs_res0->srs_ResourceId=0;
-  srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1;
-  srs_res0->ptrs_PortIndex=NULL;
-  srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2;
-  srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2));
-  srs_res0->transmissionComb.choice.n2->combOffset_n2=0;
-  srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0;
-  srs_res0->resourceMapping.startPosition=2;
-  srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1;
-  srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1;
-  srs_res0->freqDomainPosition=0;
-  srs_res0->freqDomainShift=0;
-  srs_res0->freqHopping.c_SRS = 61;
-  srs_res0->freqHopping.b_SRS=0;
-  srs_res0->freqHopping.b_hop=0;
-  srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither;
-  srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic;
-  srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic));
-  srs_res0->sequenceId=40;
-  srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo));
-  srs_res0->spatialRelationInfo->servingCellId=NULL;
-  srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index;
-  srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0;
-  ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0);
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToReleaseList = NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList = calloc(1,
-      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList));
-  NR_BWP_Uplink_t *ubwp = calloc(1,sizeof(*ubwp));
-  ubwp->bwp_Id=1;
-  ubwp->bwp_Common = calloc(1,sizeof(*ubwp->bwp_Common));
-  // copy bwp_Common from Initial UL BWP except for bandwidth
-  memcpy((void *)&ubwp->bwp_Common->genericParameters,
-         (void *)&servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters,
-         sizeof(servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters));
-  ubwp->bwp_Common->genericParameters.locationAndBandwidth=PRBalloc_to_locationandbandwidth(
-        servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0);
-  ubwp->bwp_Common->rach_ConfigCommon  = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon;
-  ubwp->bwp_Common->pusch_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon;
-  ubwp->bwp_Common->pucch_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon;
-  ubwp->bwp_Dedicated = calloc(1,sizeof(*ubwp->bwp_Dedicated));
-  ubwp->bwp_Dedicated->pucch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pucch_Config));
-  ubwp->bwp_Dedicated->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup;
-  NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config));
-  ubwp->bwp_Dedicated->pucch_Config->choice.setup=pucch_Config;
-  pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList));
-  pucch_Config->resourceSetToReleaseList = NULL;
-  NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0));
-  NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1));
-  pucchresset0->pucch_ResourceSetId = 0;
-  NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0));
-  NR_PUCCH_ResourceId_t *pucchresset0id1=calloc(1,sizeof(*pucchresset0id1));
-  *pucchresset0id0=1;
-  ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id0);
-  *pucchresset0id1=2;
-  ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id1);
-  pucchresset0->maxPayloadMinus1=NULL;
-  ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0);
-  pucchresset1->pucch_ResourceSetId = 1;
-  NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0));
-  NR_PUCCH_ResourceId_t *pucchresset1id1=calloc(1,sizeof(*pucchresset1id1));
-  *pucchresset1id0=3;
-  ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id0);
-  *pucchresset1id1=4;
-  ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id1);
-  pucchresset1->maxPayloadMinus1=NULL;
-  ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1);
-  pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList));
-  pucch_Config->resourceToReleaseList = NULL;
-  NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0));
-  NR_PUCCH_Resource_t *pucchres1=calloc(1,sizeof(*pucchres1));
-  NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2));
-  NR_PUCCH_Resource_t *pucchres3=calloc(1,sizeof(*pucchres3));
-  pucchres0->pucch_ResourceId=1;
-  pucchres0->startingPRB=48;
-  pucchres0->intraSlotFrequencyHopping=NULL;
-  pucchres0->secondHopPRB=NULL;
-  pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0;
-  pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0));
-  pucchres0->format.choice.format0->initialCyclicShift=0;
-  pucchres0->format.choice.format0->nrofSymbols=1;
-  pucchres0->format.choice.format0->startingSymbolIndex=13;
-  ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0);
-  pucchres1->pucch_ResourceId=2;
-  pucchres1->startingPRB=48;
-  pucchres1->intraSlotFrequencyHopping=NULL;
-  pucchres1->secondHopPRB=NULL;
-  pucchres1->format.present= NR_PUCCH_Resource__format_PR_format0;
-  pucchres1->format.choice.format0=calloc(1,sizeof(*pucchres1->format.choice.format0));
-  pucchres1->format.choice.format0->initialCyclicShift=0;
-  pucchres1->format.choice.format0->nrofSymbols=1;
-  pucchres1->format.choice.format0->startingSymbolIndex=12;
-  ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres1);
-  pucchres2->pucch_ResourceId=3;
-  pucchres2->startingPRB=40;
-  pucchres2->intraSlotFrequencyHopping=NULL;
-  pucchres2->secondHopPRB=NULL;
-  pucchres2->format.present= NR_PUCCH_Resource__format_PR_format2;
-  pucchres2->format.choice.format2=calloc(1,sizeof(*pucchres2->format.choice.format2));
-  pucchres2->format.choice.format2->nrofPRBs=16;
-  pucchres2->format.choice.format2->nrofSymbols=1;
-  pucchres2->format.choice.format2->startingSymbolIndex=13;
-  ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2);
-  pucchres3->pucch_ResourceId=4;
-  pucchres3->startingPRB=40;
-  pucchres3->intraSlotFrequencyHopping=NULL;
-  pucchres3->secondHopPRB=NULL;
-  pucchres3->format.present= NR_PUCCH_Resource__format_PR_format2;
-  pucchres3->format.choice.format2=calloc(1,sizeof(*pucchres3->format.choice.format2));
-  pucchres3->format.choice.format2->nrofPRBs=16;
-  pucchres3->format.choice.format2->nrofSymbols=1;
-  pucchres3->format.choice.format2->startingSymbolIndex=12;
-  ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres3);
-  pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2));
-  pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup;
-  NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2));
-  pucch_Config->format2->choice.setup = pucchfmt2;
-  pucchfmt2->interslotFrequencyHopping=NULL;
-  pucchfmt2->additionalDMRS=NULL;
-  pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate));
-  *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot15;
-  pucchfmt2->nrofSlots=NULL;
-  pucchfmt2->pi2BPSK=NULL;
-  pucchfmt2->simultaneousHARQ_ACK_CSI=NULL;
-  pucch_Config->schedulingRequestResourceToAddModList=NULL;
-  pucch_Config->schedulingRequestResourceToReleaseList=NULL;
-  pucch_Config->multi_CSI_PUCCH_ResourceList=NULL;
-  pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK));
-  long *delay[8];
-
-  for (int i=0; i<8; i++) {
-    delay[i] = calloc(1,sizeof(*delay[i]));
-    *delay[i] = (i<6) ? (i+2) : 0;
-    ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]);
-  }
-
-  pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList));
-  NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial));
-  pucchspatial->pucch_SpatialRelationInfoId = 1;
-  pucchspatial->servingCellId = NULL;
-  pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index;
-  pucchspatial->referenceSignal.choice.csi_RS_Index = 0;
-  pucchspatial->pucch_PathlossReferenceRS_Id = 0;
-  pucchspatial->p0_PUCCH_Id = 1;
-  pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0;
-  ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial);
-  pucch_Config->spatialRelationInfoToReleaseList=NULL;
-  pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl));
-  pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0));
-  *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0;
-  pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1));
-  *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0;
-  pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2));
-  *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0;
-  pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3));
-  *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0;
-  pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4));
-  *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0;
-  pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set));
-  NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00));
-  p00->p0_PUCCH_Id=1;
-  p00->p0_PUCCH_Value = 0;
-  ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00);
-  pucch_Config->pucch_PowerControl->pathlossReferenceRSs = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->pathlossReferenceRSs));
-  NR_PUCCH_PathlossReferenceRS_t *pucchPLRef=calloc(1,sizeof(*pucchPLRef));
-  pucchPLRef->pucch_PathlossReferenceRS_Id=0;
-  pucchPLRef->referenceSignal.present = NR_PUCCH_PathlossReferenceRS__referenceSignal_PR_csi_RS_Index;
-  pucchPLRef->referenceSignal.choice.csi_RS_Index=0;
-  ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->pathlossReferenceRSs->list,pucchPLRef);
-  // copy pusch_Config from dedicated initialBWP
-  ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config));
-  ubwp->bwp_Dedicated->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup;
-  ubwp->bwp_Dedicated->pusch_Config->choice.setup = pusch_Config;
-  ubwp->bwp_Dedicated->configuredGrantConfig = NULL;
-  ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config));
-  ubwp->bwp_Dedicated->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup;
-  ubwp->bwp_Dedicated->srs_Config->choice.setup = srs_Config;
-  ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL;
-  ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list,ubwp);
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = calloc(1,
-      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id));
-  *secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = 1;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig = NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->carrierSwitching = NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->supplementaryUplink=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdcch_ServingCellConfig=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig));
-  NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig = calloc(1,sizeof(*pdsch_servingcellconfig));
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present = NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig;
-  pdsch_servingcellconfig->codeBlockGroupTransmission = NULL;
-  pdsch_servingcellconfig->xOverhead = NULL;
-  pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = NULL;
-  pdsch_servingcellconfig->pucch_Cell= NULL;
-  pdsch_servingcellconfig->ext1=calloc(1,sizeof(*pdsch_servingcellconfig->ext1));
-  pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1,sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers));
-  *pdsch_servingcellconfig->ext1->maxMIMO_Layers = 2;
-  pdsch_servingcellconfig->ext1->processingType2Enabled = NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig));
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup;
-  NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig));
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig;
-  csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList));
-  NR_NZP_CSI_RS_Resource_t *nzpres0 = calloc(1,sizeof(*nzpres0));
-  nzpres0->nzp_CSI_RS_ResourceId=0;
-  nzpres0->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_other;
-  nzpres0->resourceMapping.frequencyDomainAllocation.choice.other.buf = calloc(1,1);
-  nzpres0->resourceMapping.frequencyDomainAllocation.choice.other.size = 1;
-  nzpres0->resourceMapping.frequencyDomainAllocation.choice.other.bits_unused = 2;
-  nzpres0->resourceMapping.frequencyDomainAllocation.choice.other.buf[0]=1<<2;
-  nzpres0->resourceMapping.nrofPorts = (n_physical_antenna_ports==1)? NR_CSI_RS_ResourceMapping__nrofPorts_p1 : NR_CSI_RS_ResourceMapping__nrofPorts_p2;
-  nzpres0->resourceMapping.firstOFDMSymbolInTimeDomain=7;
-  nzpres0->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-  nzpres0->resourceMapping.cdm_Type = (n_physical_antenna_ports==1)? NR_CSI_RS_ResourceMapping__cdm_Type_noCDM : NR_CSI_RS_ResourceMapping__cdm_Type_fd_CDM2;
-  nzpres0->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_one;
-  nzpres0->resourceMapping.density.choice.one=(NULL_t)0;
-  nzpres0->resourceMapping.freqBand.startingRB=0;
-  nzpres0->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-  nzpres0->powerControlOffset=13;
-  nzpres0->powerControlOffsetSS=NULL;
-  nzpres0->scramblingID=40;
-  nzpres0->periodicityAndOffset = calloc(1,sizeof(*nzpres0->periodicityAndOffset));
-  nzpres0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320;
-  nzpres0->periodicityAndOffset->choice.slots320 = 2;
-  nzpres0->qcl_InfoPeriodicCSI_RS=NULL;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres0);
-
-  if (n_physical_antenna_ports > 1) {
-    NR_NZP_CSI_RS_Resource_t *nzpres2 = calloc(1,sizeof(*nzpres2));
-    nzpres2->nzp_CSI_RS_ResourceId=2;
-    nzpres2->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres2->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres2->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres2->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres2->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=1;
-    nzpres2->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres2->resourceMapping.firstOFDMSymbolInTimeDomain=4;
-    nzpres2->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres2->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres2->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres2->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres2->resourceMapping.freqBand.startingRB=0;
-    nzpres2->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres2->powerControlOffset=0;
-    nzpres2->powerControlOffsetSS=calloc(1,sizeof(*nzpres2->powerControlOffsetSS));
-    *nzpres2->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres2->scramblingID=40;
-    nzpres2->periodicityAndOffset = calloc(1,sizeof(*nzpres2->periodicityAndOffset));
-    nzpres2->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres2->periodicityAndOffset->choice.slots160 = 25;
-    nzpres2->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres2->qcl_InfoPeriodicCSI_RS));
-    *nzpres2->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres2);
-    NR_NZP_CSI_RS_Resource_t *nzpres3 = calloc(1,sizeof(*nzpres3));
-    nzpres3->nzp_CSI_RS_ResourceId=3;
-    nzpres3->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres3->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres3->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres3->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres3->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=1;
-    nzpres3->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres3->resourceMapping.firstOFDMSymbolInTimeDomain=8;
-    nzpres3->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres3->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres3->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres3->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres3->resourceMapping.freqBand.startingRB=0;
-    nzpres3->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres3->powerControlOffset=0;
-    nzpres3->powerControlOffsetSS=calloc(1,sizeof(*nzpres3->powerControlOffsetSS));
-    *nzpres3->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres3->scramblingID=40;
-    nzpres3->periodicityAndOffset = calloc(1,sizeof(*nzpres3->periodicityAndOffset));
-    nzpres3->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres3->periodicityAndOffset->choice.slots160 = 25;
-    nzpres3->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres3->qcl_InfoPeriodicCSI_RS));
-    *nzpres3->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres3);
-  }
-
-  if (n_physical_antenna_ports > 3) {
-    NR_NZP_CSI_RS_Resource_t *nzpres4 = calloc(1,sizeof(*nzpres4));
-    nzpres4->nzp_CSI_RS_ResourceId=4;
-    nzpres4->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres4->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres4->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres4->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres4->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=1;
-    nzpres4->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres4->resourceMapping.firstOFDMSymbolInTimeDomain=4;
-    nzpres4->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres4->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres4->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres4->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres4->resourceMapping.freqBand.startingRB=0;
-    nzpres4->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres4->powerControlOffset=0;
-    nzpres4->powerControlOffsetSS=calloc(1,sizeof(*nzpres4->powerControlOffsetSS));
-    *nzpres4->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres4->scramblingID=40;
-    nzpres4->periodicityAndOffset = calloc(1,sizeof(*nzpres4->periodicityAndOffset));
-    nzpres4->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres4->periodicityAndOffset->choice.slots160 = 26;
-    nzpres4->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres4->qcl_InfoPeriodicCSI_RS));
-    *nzpres4->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres4);
-    NR_NZP_CSI_RS_Resource_t *nzpres5 = calloc(1,sizeof(*nzpres5));
-    nzpres5->nzp_CSI_RS_ResourceId=5;
-    nzpres5->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres5->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres5->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres5->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres5->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=1;
-    nzpres5->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres5->resourceMapping.firstOFDMSymbolInTimeDomain=8;
-    nzpres5->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres5->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres5->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres5->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres5->resourceMapping.freqBand.startingRB=0;
-    nzpres5->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres5->powerControlOffset=0;
-    nzpres5->powerControlOffsetSS=calloc(1,sizeof(*nzpres5->powerControlOffsetSS));
-    *nzpres5->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres5->scramblingID=40;
-    nzpres5->periodicityAndOffset = calloc(1,sizeof(*nzpres5->periodicityAndOffset));
-    nzpres5->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres5->periodicityAndOffset->choice.slots160 = 26;
-    nzpres5->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres5->qcl_InfoPeriodicCSI_RS));
-    *nzpres5->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres5);
-  }
-
-  if (n_physical_antenna_ports > 7) {
-    NR_NZP_CSI_RS_Resource_t *nzpres6 = calloc(1,sizeof(*nzpres6));
-    nzpres6->nzp_CSI_RS_ResourceId=6;
-    nzpres6->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres6->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres6->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres6->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres6->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=4;
-    nzpres6->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres6->resourceMapping.firstOFDMSymbolInTimeDomain=4;
-    nzpres6->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres6->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres6->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres6->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres6->resourceMapping.freqBand.startingRB=0;
-    nzpres6->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres6->powerControlOffset=0;
-    nzpres6->powerControlOffsetSS=calloc(1,sizeof(*nzpres6->powerControlOffsetSS));
-    *nzpres6->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres6->scramblingID=40;
-    nzpres6->periodicityAndOffset = calloc(1,sizeof(*nzpres6->periodicityAndOffset));
-    nzpres6->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres6->periodicityAndOffset->choice.slots160 = 25;
-    nzpres6->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres6->qcl_InfoPeriodicCSI_RS));
-    *nzpres6->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres6);
-    NR_NZP_CSI_RS_Resource_t *nzpres7 = calloc(1,sizeof(*nzpres7));
-    nzpres7->nzp_CSI_RS_ResourceId=7;
-    nzpres7->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres7->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres7->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres7->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres7->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=4;
-    nzpres7->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres7->resourceMapping.firstOFDMSymbolInTimeDomain=8;
-    nzpres7->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres7->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres7->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres7->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres7->resourceMapping.freqBand.startingRB=0;
-    nzpres7->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres7->powerControlOffset=0;
-    nzpres7->powerControlOffsetSS=calloc(1,sizeof(*nzpres7->powerControlOffsetSS));
-    *nzpres7->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres7->scramblingID=40;
-    nzpres7->periodicityAndOffset = calloc(1,sizeof(*nzpres7->periodicityAndOffset));
-    nzpres7->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres7->periodicityAndOffset->choice.slots160 = 25;
-    nzpres7->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres7->qcl_InfoPeriodicCSI_RS));
-    *nzpres7->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres7);
-    NR_NZP_CSI_RS_Resource_t *nzpres8 = calloc(1,sizeof(*nzpres8));
-    nzpres8->nzp_CSI_RS_ResourceId=8;
-    nzpres8->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres8->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres8->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres8->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres8->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=4;
-    nzpres8->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres8->resourceMapping.firstOFDMSymbolInTimeDomain=4;
-    nzpres8->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres8->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres8->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres8->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres8->resourceMapping.freqBand.startingRB=0;
-    nzpres8->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres8->powerControlOffset=0;
-    nzpres8->powerControlOffsetSS=calloc(1,sizeof(*nzpres8->powerControlOffsetSS));
-    *nzpres8->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres8->scramblingID=40;
-    nzpres8->periodicityAndOffset = calloc(1,sizeof(*nzpres8->periodicityAndOffset));
-    nzpres8->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres8->periodicityAndOffset->choice.slots160 = 26;
-    nzpres8->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres8->qcl_InfoPeriodicCSI_RS));
-    *nzpres8->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres8);
-    NR_NZP_CSI_RS_Resource_t *nzpres9 = calloc(1,sizeof(*nzpres9));
-    nzpres9->nzp_CSI_RS_ResourceId=9;
-    nzpres9->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres9->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres9->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres9->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres9->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=4;
-    nzpres9->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres9->resourceMapping.firstOFDMSymbolInTimeDomain=8;
-    nzpres9->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres9->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres9->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres9->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres9->resourceMapping.freqBand.startingRB=0;
-    nzpres9->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres9->powerControlOffset=0;
-    nzpres9->powerControlOffsetSS=calloc(1,sizeof(*nzpres9->powerControlOffsetSS));
-    *nzpres9->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres9->scramblingID=40;
-    nzpres9->periodicityAndOffset = calloc(1,sizeof(*nzpres9->periodicityAndOffset));
-    nzpres9->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres9->periodicityAndOffset->choice.slots160 = 26;
-    nzpres9->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres9->qcl_InfoPeriodicCSI_RS));
-    *nzpres9->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres9);
-  }
-
-  if (n_physical_antenna_ports > 15) {
-    NR_NZP_CSI_RS_Resource_t *nzpres10 = calloc(1,sizeof(*nzpres10));
-    nzpres10->nzp_CSI_RS_ResourceId=10;
-    nzpres10->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres10->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres10->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres10->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres10->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=2;
-    nzpres10->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres10->resourceMapping.firstOFDMSymbolInTimeDomain=4;
-    nzpres10->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres10->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres10->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres10->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres10->resourceMapping.freqBand.startingRB=0;
-    nzpres10->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres10->powerControlOffset=0;
-    nzpres10->powerControlOffsetSS=calloc(1,sizeof(*nzpres10->powerControlOffsetSS));
-    *nzpres10->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres10->scramblingID=40;
-    nzpres10->periodicityAndOffset = calloc(1,sizeof(*nzpres10->periodicityAndOffset));
-    nzpres10->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres10->periodicityAndOffset->choice.slots160 = 25;
-    nzpres10->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres10->qcl_InfoPeriodicCSI_RS));
-    *nzpres10->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres10);
-    NR_NZP_CSI_RS_Resource_t *nzpres11 = calloc(1,sizeof(*nzpres11));
-    nzpres11->nzp_CSI_RS_ResourceId=11;
-    nzpres11->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres11->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres11->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres11->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres11->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=2;
-    nzpres11->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres11->resourceMapping.firstOFDMSymbolInTimeDomain=8;
-    nzpres11->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres11->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres11->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres11->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres11->resourceMapping.freqBand.startingRB=0;
-    nzpres11->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres11->powerControlOffset=0;
-    nzpres11->powerControlOffsetSS=calloc(1,sizeof(*nzpres11->powerControlOffsetSS));
-    *nzpres11->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres11->scramblingID=40;
-    nzpres11->periodicityAndOffset = calloc(1,sizeof(*nzpres11->periodicityAndOffset));
-    nzpres11->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres11->periodicityAndOffset->choice.slots160 = 25;
-    nzpres11->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres11->qcl_InfoPeriodicCSI_RS));
-    *nzpres11->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres11);
-    NR_NZP_CSI_RS_Resource_t *nzpres12 = calloc(1,sizeof(*nzpres12));
-    nzpres12->nzp_CSI_RS_ResourceId=12;
-    nzpres12->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres12->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres12->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres12->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres12->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=2;
-    nzpres12->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres12->resourceMapping.firstOFDMSymbolInTimeDomain=4;
-    nzpres12->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres12->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres12->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres12->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres12->resourceMapping.freqBand.startingRB=0;
-    nzpres12->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres12->powerControlOffset=0;
-    nzpres12->powerControlOffsetSS=calloc(1,sizeof(*nzpres12->powerControlOffsetSS));
-    *nzpres12->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres12->scramblingID=40;
-    nzpres12->periodicityAndOffset = calloc(1,sizeof(*nzpres12->periodicityAndOffset));
-    nzpres12->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres12->periodicityAndOffset->choice.slots160 = 26;
-    nzpres12->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres12->qcl_InfoPeriodicCSI_RS));
-    *nzpres12->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres12);
-    NR_NZP_CSI_RS_Resource_t *nzpres13 = calloc(1,sizeof(*nzpres13));
-    nzpres13->nzp_CSI_RS_ResourceId=13;
-    nzpres13->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres13->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres13->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres13->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres13->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=2;
-    nzpres13->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres13->resourceMapping.firstOFDMSymbolInTimeDomain=8;
-    nzpres13->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres13->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres13->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres13->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres13->resourceMapping.freqBand.startingRB=0;
-    nzpres13->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres13->powerControlOffset=0;
-    nzpres13->powerControlOffsetSS=calloc(1,sizeof(*nzpres13->powerControlOffsetSS));
-    *nzpres13->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres13->scramblingID=40;
-    nzpres13->periodicityAndOffset = calloc(1,sizeof(*nzpres13->periodicityAndOffset));
-    nzpres13->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres13->periodicityAndOffset->choice.slots160 = 26;
-    nzpres13->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres13->qcl_InfoPeriodicCSI_RS));
-    *nzpres13->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres13);
-    NR_NZP_CSI_RS_Resource_t *nzpres14 = calloc(1,sizeof(*nzpres14));
-    nzpres14->nzp_CSI_RS_ResourceId=14;
-    nzpres14->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres14->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres14->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres14->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres14->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=8;
-    nzpres14->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres14->resourceMapping.firstOFDMSymbolInTimeDomain=4;
-    nzpres14->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres14->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres14->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres14->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres14->resourceMapping.freqBand.startingRB=0;
-    nzpres14->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres14->powerControlOffset=0;
-    nzpres14->powerControlOffsetSS=calloc(1,sizeof(*nzpres14->powerControlOffsetSS));
-    *nzpres14->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres14->scramblingID=40;
-    nzpres14->periodicityAndOffset = calloc(1,sizeof(*nzpres14->periodicityAndOffset));
-    nzpres14->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres14->periodicityAndOffset->choice.slots160 = 25;
-    nzpres14->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres14->qcl_InfoPeriodicCSI_RS));
-    *nzpres14->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres14);
-    NR_NZP_CSI_RS_Resource_t *nzpres15 = calloc(1,sizeof(*nzpres15));
-    nzpres15->nzp_CSI_RS_ResourceId=15;
-    nzpres15->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres15->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres15->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres15->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres15->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=8;
-    nzpres15->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres15->resourceMapping.firstOFDMSymbolInTimeDomain=8;
-    nzpres15->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres15->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres15->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres15->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres15->resourceMapping.freqBand.startingRB=0;
-    nzpres15->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres15->powerControlOffset=0;
-    nzpres15->powerControlOffsetSS=calloc(1,sizeof(*nzpres15->powerControlOffsetSS));
-    *nzpres15->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres15->scramblingID=40;
-    nzpres15->periodicityAndOffset = calloc(1,sizeof(*nzpres15->periodicityAndOffset));
-    nzpres15->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres15->periodicityAndOffset->choice.slots160 = 25;
-    nzpres15->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres15->qcl_InfoPeriodicCSI_RS));
-    *nzpres15->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres15);
-    NR_NZP_CSI_RS_Resource_t *nzpres16 = calloc(1,sizeof(*nzpres16));
-    nzpres16->nzp_CSI_RS_ResourceId=16;
-    nzpres16->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres16->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres16->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres16->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres16->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=8;
-    nzpres16->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres16->resourceMapping.firstOFDMSymbolInTimeDomain=5;
-    nzpres16->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres16->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres16->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres16->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres16->resourceMapping.freqBand.startingRB=0;
-    nzpres16->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres16->powerControlOffset=0;
-    nzpres16->powerControlOffsetSS=calloc(1,sizeof(*nzpres16->powerControlOffsetSS));
-    *nzpres16->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres16->scramblingID=40;
-    nzpres16->periodicityAndOffset = calloc(1,sizeof(*nzpres16->periodicityAndOffset));
-    nzpres16->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres16->periodicityAndOffset->choice.slots160 = 26;
-    nzpres16->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres16->qcl_InfoPeriodicCSI_RS));
-    *nzpres16->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres16);
-    NR_NZP_CSI_RS_Resource_t *nzpres17 = calloc(1,sizeof(*nzpres17));
-    nzpres17->nzp_CSI_RS_ResourceId=9;
-    nzpres17->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
-    nzpres17->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
-    nzpres17->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
-    nzpres17->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
-    nzpres17->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=8;
-    nzpres17->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
-    nzpres17->resourceMapping.firstOFDMSymbolInTimeDomain=9;
-    nzpres17->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
-    nzpres17->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
-    nzpres17->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
-    nzpres17->resourceMapping.density.choice.three=(NULL_t)0;
-    nzpres17->resourceMapping.freqBand.startingRB=0;
-    nzpres17->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
-    nzpres17->powerControlOffset=0;
-    nzpres17->powerControlOffsetSS=calloc(1,sizeof(*nzpres17->powerControlOffsetSS));
-    *nzpres17->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
-    nzpres17->scramblingID=40;
-    nzpres17->periodicityAndOffset = calloc(1,sizeof(*nzpres17->periodicityAndOffset));
-    nzpres17->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
-    nzpres17->periodicityAndOffset->choice.slots160 = 26;
-    nzpres17->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres17->qcl_InfoPeriodicCSI_RS));
-    *nzpres17->qcl_InfoPeriodicCSI_RS=8;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres17);
-  }
-
-  if (n_physical_antenna_ports > 16) AssertFatal(1==0,"Fill in for more than 16 antenna elements\n");
-
-  csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList  = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList));
-  csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList = NULL;
-  NR_NZP_CSI_RS_ResourceSet_t *nzpresset0=calloc(1,sizeof(*nzpresset0));
-  nzpresset0->nzp_CSI_ResourceSetId=0;
-  NR_NZP_CSI_RS_ResourceSetId_t *nzpresset00=calloc(1,sizeof(*nzpresset00));
-  *nzpresset00=0;
-  ASN_SEQUENCE_ADD(&nzpresset0->nzp_CSI_RS_Resources.list,nzpresset00);
-  nzpresset0->repetition=NULL;
-  nzpresset0->aperiodicTriggeringOffset=NULL;
-  nzpresset0->trs_Info=NULL;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpresset0);
-
-  if (n_physical_antenna_ports > 1) {
-    NR_NZP_CSI_RS_ResourceSet_t *nzpresset3=calloc(1,sizeof(*nzpresset3));
-    nzpresset3->nzp_CSI_ResourceSetId=3;
-    NR_NZP_CSI_RS_ResourceSetId_t *nzpresset30=calloc(1,sizeof(*nzpresset30));
-    *nzpresset30=2;
-    ASN_SEQUENCE_ADD(&nzpresset3->nzp_CSI_RS_Resources.list,nzpresset30);
-
-    if (n_physical_antenna_ports > 3) {
-      NR_NZP_CSI_RS_ResourceSetId_t *nzpresset31=calloc(1,sizeof(*nzpresset31));
-      *nzpresset31=3;
-      ASN_SEQUENCE_ADD(&nzpresset3->nzp_CSI_RS_Resources.list,nzpresset31);
-      NR_NZP_CSI_RS_ResourceSetId_t *nzpresset32=calloc(1,sizeof(*nzpresset32));
-      *nzpresset32=4;
-      ASN_SEQUENCE_ADD(&nzpresset3->nzp_CSI_RS_Resources.list,nzpresset32);
-      NR_NZP_CSI_RS_ResourceSetId_t *nzpresset33=calloc(1,sizeof(*nzpresset33));
-      *nzpresset33=5;
-      ASN_SEQUENCE_ADD(&nzpresset3->nzp_CSI_RS_Resources.list,nzpresset33);
-      ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpresset3);
-    }
-
-    nzpresset3->repetition=calloc(1,sizeof(*nzpresset3->repetition));
-    *nzpresset3->repetition=NR_NZP_CSI_RS_ResourceSet__repetition_off;
-    nzpresset3->aperiodicTriggeringOffset=NULL;
-    nzpresset3->trs_Info=calloc(1,sizeof(*nzpresset3->trs_Info));
-    *nzpresset3->trs_Info=NR_NZP_CSI_RS_ResourceSet__trs_Info_true;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpresset3);
-  }
-
-  if (n_physical_antenna_ports > 7) {
-    NR_NZP_CSI_RS_ResourceSet_t *nzpresset4=calloc(1,sizeof(*nzpresset4));
-    nzpresset4->nzp_CSI_ResourceSetId=4;
-    NR_NZP_CSI_RS_ResourceSetId_t *nzpresset40=calloc(1,sizeof(*nzpresset40));
-    *nzpresset40=6;
-    ASN_SEQUENCE_ADD(&nzpresset4->nzp_CSI_RS_Resources.list,nzpresset40);
-    NR_NZP_CSI_RS_ResourceSetId_t *nzpresset41=calloc(1,sizeof(*nzpresset41));
-    *nzpresset41=7;
-    ASN_SEQUENCE_ADD(&nzpresset4->nzp_CSI_RS_Resources.list,nzpresset41);
-    NR_NZP_CSI_RS_ResourceSetId_t *nzpresset42=calloc(1,sizeof(*nzpresset42));
-    *nzpresset42=8;
-    ASN_SEQUENCE_ADD(&nzpresset4->nzp_CSI_RS_Resources.list,nzpresset42);
-    NR_NZP_CSI_RS_ResourceSetId_t *nzpresset43=calloc(1,sizeof(*nzpresset43));
-    *nzpresset43=9;
-    ASN_SEQUENCE_ADD(&nzpresset4->nzp_CSI_RS_Resources.list,nzpresset43);
-    nzpresset4->repetition=calloc(1,sizeof(*nzpresset4->repetition));
-    *nzpresset4->repetition=NR_NZP_CSI_RS_ResourceSet__repetition_off;
-    nzpresset4->aperiodicTriggeringOffset=NULL;
-    nzpresset4->trs_Info=calloc(1,sizeof(*nzpresset4->trs_Info));
-    *nzpresset4->trs_Info=NR_NZP_CSI_RS_ResourceSet__trs_Info_true;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpresset4);
-  }
-
-  if (n_physical_antenna_ports > 15) {
-    NR_NZP_CSI_RS_ResourceSet_t *nzpresset5=calloc(1,sizeof(*nzpresset5));
-    nzpresset5->nzp_CSI_ResourceSetId=5;
-    NR_NZP_CSI_RS_ResourceSetId_t *nzpresset50=calloc(1,sizeof(*nzpresset50));
-    *nzpresset50=10;
-    ASN_SEQUENCE_ADD(&nzpresset5->nzp_CSI_RS_Resources.list,nzpresset50);
-    NR_NZP_CSI_RS_ResourceSetId_t *nzpresset51=calloc(1,sizeof(*nzpresset51));
-    *nzpresset51=11;
-    ASN_SEQUENCE_ADD(&nzpresset5->nzp_CSI_RS_Resources.list,nzpresset51);
-    NR_NZP_CSI_RS_ResourceSetId_t *nzpresset52=calloc(1,sizeof(*nzpresset52));
-    *nzpresset52=12;
-    ASN_SEQUENCE_ADD(&nzpresset5->nzp_CSI_RS_Resources.list,nzpresset52);
-    NR_NZP_CSI_RS_ResourceSetId_t *nzpresset53=calloc(1,sizeof(*nzpresset53));
-    *nzpresset53=13;
-    ASN_SEQUENCE_ADD(&nzpresset5->nzp_CSI_RS_Resources.list,nzpresset53);
-    nzpresset5->repetition=calloc(1,sizeof(*nzpresset5->repetition));
-    *nzpresset5->repetition=NR_NZP_CSI_RS_ResourceSet__repetition_off;
-    nzpresset5->aperiodicTriggeringOffset=NULL;
-    nzpresset5->trs_Info=calloc(1,sizeof(*nzpresset5->trs_Info));
-    *nzpresset5->trs_Info=NR_NZP_CSI_RS_ResourceSet__trs_Info_true;
-    ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpresset5);
-  }
-
-  csi_MeasConfig->csi_IM_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceToAddModList));
-  csi_MeasConfig->csi_IM_ResourceToReleaseList = NULL;
-  NR_CSI_IM_Resource_t *imres0 = calloc(1,sizeof(*imres0));
-  imres0->csi_IM_ResourceId=0;
-  imres0->csi_IM_ResourceElementPattern=calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern));
-  imres0->csi_IM_ResourceElementPattern->present = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern_PR_pattern1 ;
-  imres0->csi_IM_ResourceElementPattern->choice.pattern1=calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern->choice.pattern1));
-  imres0->csi_IM_ResourceElementPattern->choice.pattern1->subcarrierLocation_p1 = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern__pattern1__subcarrierLocation_p1_s4;
-  imres0->csi_IM_ResourceElementPattern->choice.pattern1->symbolLocation_p1=7;
-  imres0->freqBand=calloc(1,sizeof(*imres0->freqBand));
-  imres0->freqBand->startingRB=0;
-  imres0->freqBand->nrofRBs=276;
-  imres0->periodicityAndOffset=calloc(1,sizeof(*imres0->periodicityAndOffset));
-  imres0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320;
-  imres0->periodicityAndOffset->choice.slots320 = 2;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceToAddModList->list,imres0);
-  csi_MeasConfig->csi_IM_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceSetToAddModList));
-  csi_MeasConfig->csi_IM_ResourceSetToReleaseList = NULL;
-  NR_CSI_IM_ResourceSet_t *imresset0 = calloc(1,sizeof(*imresset0));
-  imresset0->csi_IM_ResourceSetId=0;
-  NR_CSI_IM_ResourceId_t *imresset00=calloc(1,sizeof(*imresset00));
-  *imresset00=0;
-  ASN_SEQUENCE_ADD(&imresset0->csi_IM_Resources.list,imresset00);
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceSetToAddModList->list,imresset0);
-  csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList));
-  csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL;
-  NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0));
-  ssbresset0->csi_SSB_ResourceSetId=0;
-  NR_SSB_Index_t *ssbresset00=calloc(1,sizeof(*ssbresset00));
-  *ssbresset00=0;
-  ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset00);
-
-  if (n_physical_antenna_ports > 1) {
-    NR_SSB_Index_t *ssbresset01=calloc(1,sizeof(*ssbresset01));
-    *ssbresset01=1;
-    ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset01);
-  }
-
-  if (n_physical_antenna_ports > 3) {
-    NR_SSB_Index_t *ssbresset02=calloc(1,sizeof(*ssbresset02));
-    *ssbresset02=2;
-    ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset02);
-    NR_SSB_Index_t *ssbresset03=calloc(1,sizeof(*ssbresset03));
-    *ssbresset03=3;
-    ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset03);
-  }
-
-  if (n_physical_antenna_ports > 7) {
-    NR_SSB_Index_t *ssbresset04=calloc(1,sizeof(*ssbresset04));
-    *ssbresset04=4;
-    ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset04);
-    NR_SSB_Index_t *ssbresset05=calloc(1,sizeof(*ssbresset05));
-    *ssbresset05=5;
-    ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset05);
-    NR_SSB_Index_t *ssbresset06=calloc(1,sizeof(*ssbresset06));
-    *ssbresset06=6;
-    ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset06);
-    NR_SSB_Index_t *ssbresset07=calloc(1,sizeof(*ssbresset07));
-    *ssbresset07=7;
-    ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset07);
-  }
-
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0);
-  csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList));
-  csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL;
-  NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0));
-  csires0->csi_ResourceConfigId=0;
-  csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
-  csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
-  csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
-  csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
-  NR_NZP_CSI_RS_ResourceSetId_t *csires00 = calloc(1,sizeof(*csires00));
-  *csires00 = 0;
-  ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires00);
-  csires0->bwp_Id = 1;
-  csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0);
-  NR_CSI_ResourceConfig_t *csires11 = calloc(1,sizeof(*csires11));
-  csires11->csi_ResourceConfigId=11;
-  csires11->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList;
-  csires11->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList = calloc(1,sizeof(*csires11->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList));
-  NR_NZP_CSI_RS_ResourceSetId_t *csires110 = calloc(1,sizeof(*csires110));
-  *csires110 = 0;
-  ASN_SEQUENCE_ADD(&csires11->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csires110);
-  csires11->bwp_Id = 1;
-  csires11->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires11);
-  NR_CSI_ResourceConfig_t *csires10 = calloc(1,sizeof(*csires10));
-  csires10->csi_ResourceConfigId=10;
-  csires10->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
-  csires10->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires10->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
-  csires10->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires10->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
-  csires10->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
-  NR_NZP_CSI_RS_ResourceSetId_t *csires100 = calloc(1,sizeof(*csires100));
-  *csires100 = 0;
-  ASN_SEQUENCE_ADD(&csires10->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires100);
-  csires10->bwp_Id = 1;
-  csires10->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires10);
-  NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2));
-  csires2->csi_ResourceConfigId=2;
-  csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
-  csires2->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
-  csires2->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
-  csires2->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
-  NR_NZP_CSI_RS_ResourceSetId_t *csires20 = calloc(1,sizeof(*csires20));
-  *csires20 = 0;
-  ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires20);
-  csires2->bwp_Id = 1;
-  csires2->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires2);
-  NR_CSI_ResourceConfig_t *csires3 = calloc(1,sizeof(*csires3));
-  csires3->csi_ResourceConfigId=3;
-  csires3->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
-  csires3->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires3->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
-  csires3->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires3->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
-  csires3->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
-  NR_NZP_CSI_RS_ResourceSetId_t *csires30 = calloc(1,sizeof(*csires30));
-  *csires30 = 0;
-  ASN_SEQUENCE_ADD(&csires3->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires30);
-  csires3->bwp_Id = 1;
-  csires3->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires3);
-  NR_CSI_ResourceConfig_t *csires4 = calloc(1,sizeof(*csires4));
-  csires4->csi_ResourceConfigId=4;
-  csires4->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
-  csires4->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires4->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
-  csires4->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires4->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
-  csires4->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
-  NR_NZP_CSI_RS_ResourceSetId_t *csires40 = calloc(1,sizeof(*csires40));
-  *csires40 = 0;
-  ASN_SEQUENCE_ADD(&csires4->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires40);
-  csires4->bwp_Id = 1;
-  csires4->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires4);
-  NR_CSI_ResourceConfig_t *csires5 = calloc(1,sizeof(*csires5));
-  csires5->csi_ResourceConfigId=5;
-  csires5->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
-  csires5->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires5->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
-  csires5->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires5->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
-  csires5->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
-  NR_NZP_CSI_RS_ResourceSetId_t *csires50 = calloc(1,sizeof(*csires50));
-  *csires50 = 0;
-  ASN_SEQUENCE_ADD(&csires5->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires50);
-  csires5->bwp_Id = 1;
-  csires5->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires5);
-  NR_CSI_ResourceConfig_t *csires6 = calloc(1,sizeof(*csires6));
-  csires6->csi_ResourceConfigId=6;
-  csires6->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
-  csires6->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires6->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
-  csires6->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires6->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
-  csires6->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
-  NR_NZP_CSI_RS_ResourceSetId_t *csires60 = calloc(1,sizeof(*csires60));
-  *csires60 = 0;
-  ASN_SEQUENCE_ADD(&csires6->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires60);
-  csires6->bwp_Id = 1;
-  csires6->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires6);
-  NR_CSI_ResourceConfig_t *csires7 = calloc(1,sizeof(*csires7));
-  csires7->csi_ResourceConfigId=7;
-  csires7->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
-  csires7->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires7->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
-  csires7->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires7->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
-  csires7->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
-  NR_NZP_CSI_RS_ResourceSetId_t *csires70 = calloc(1,sizeof(*csires70));
-  *csires70 = 0;
-  ASN_SEQUENCE_ADD(&csires7->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires70);
-  csires7->bwp_Id = 1;
-  csires7->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires7);
-  NR_CSI_ResourceConfig_t *csires8 = calloc(1,sizeof(*csires8));
-  csires8->csi_ResourceConfigId=8;
-  csires8->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
-  csires8->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires8->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
-  csires8->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires8->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
-  csires8->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
-  NR_NZP_CSI_RS_ResourceSetId_t *csires80 = calloc(1,sizeof(*csires80));
-  *csires80 = 0;
-  ASN_SEQUENCE_ADD(&csires8->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires80);
-  csires8->bwp_Id = 1;
-  csires8->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires8);
-  NR_CSI_ResourceConfig_t *csires9 = calloc(1,sizeof(*csires9));
-  csires9->csi_ResourceConfigId=9;
-  csires9->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
-  csires9->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires9->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
-  csires9->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires9->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
-  csires9->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
-  NR_NZP_CSI_RS_ResourceSetId_t *csires90 = calloc(1,sizeof(*csires90));
-  *csires90 = 0;
-  ASN_SEQUENCE_ADD(&csires9->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires90);
-  csires9->bwp_Id = 1;
-  csires9->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires9);
-  csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList));
-  csi_MeasConfig->csi_ReportConfigToReleaseList = NULL;
-  NR_CSI_ReportConfig_t *csirep0 = calloc(1,sizeof(*csirep0));
-  csirep0->reportConfigId=0;
-  csirep0->carrier=NULL;
-  csirep0->resourcesForChannelMeasurement=0;
-  csirep0->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep0->csi_IM_ResourcesForInterference));
-  *csirep0->csi_IM_ResourcesForInterference=11;
-  csirep0->nzp_CSI_RS_ResourcesForInterference=NULL;
-  csirep0->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic;
-  csirep0->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep0->reportConfigType.choice.periodic));
-  csirep0->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320;
-  csirep0->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 9;
-  NR_PUCCH_CSI_Resource_t *pucchcsires0 = calloc(1,sizeof(*pucchcsires0));
-  pucchcsires0->uplinkBandwidthPartId=1;
-  pucchcsires0->pucch_Resource=11;
-  ASN_SEQUENCE_ADD(&csirep0->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires0);
-  csirep0->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_LI_PMI_CQI;
-  csirep0->reportQuantity.choice.cri_RI_PMI_CQI = (NULL_t)0;
-  csirep0->reportFreqConfiguration = calloc(1,sizeof(*csirep0->reportFreqConfiguration));
-  csirep0->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI;
-  csirep0->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI;
-  csirep0->reportFreqConfiguration->csi_ReportingBand=calloc(1,sizeof(*csirep0->reportFreqConfiguration->csi_ReportingBand));
-  AssertFatal(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id>0,"firstActiveDownlinkBWP_Id %d\n",
-              (int)*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id);
-  int NPRB  = NRRIV2BW(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id
-                       -1]->bwp_Common->genericParameters.locationAndBandwidth,275);
-  int sbsize = get_subband_size(NPRB,0);
-  int numsb = NPRB/sbsize;
-
-  if (NPRB%sbsize == 0) numsb++;
-
-  csirep0->reportFreqConfiguration->csi_ReportingBand->present=  NR_CSI_ReportConfig__reportFreqConfiguration__csi_ReportingBand_PR_NOTHING+(numsb-2);
-  csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.size=numsb/8;
-
-  if ((numsb&7) > 0) csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.size++;
-
-  csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.bits_unused = (8-(numsb&7))&7;
-  csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.buf=malloc(csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.size);
-
-  for (int i=0; i<csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.size; i++)
-    csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.buf[i]=0xff;
-
-  csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.buf[csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.size-1]&=~((
-        1<<csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.bits_unused)-1);
-  csirep0->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured;
-  csirep0->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured;
-  csirep0->codebookConfig=calloc(1,sizeof(*csirep0->codebookConfig));
-  csirep0->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1;
-  csirep0->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep0->codebookConfig->codebookType.choice.type1));
-  csirep0->codebookConfig->codebookType.choice.type1->subType.present = NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel;
-  csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel));
-  csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present=
-    NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two;
-  csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two=
-    calloc(1,sizeof(*csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two));
-  csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1;
-  csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2;
-  csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1);
-  csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc;
-  //'111111'B
-  csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1;
-  csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0;
-  csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1);
-  csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0xc0; //'00000011'B
-  csirep0->codebookConfig->codebookType.choice.type1->codebookMode=1;
-  csirep0->dummy = NULL;
-  csirep0->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled;
-  csirep0->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep0->groupBasedBeamReporting.choice.disabled));
-  csirep0->groupBasedBeamReporting.choice.disabled->nrofReportedRS = NULL;
-  csirep0->cqi_Table = calloc(1,sizeof(*csirep0->cqi_Table));
-  *csirep0->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1;
-  csirep0->subbandSize = NR_CSI_ReportConfig__subbandSize_value1;
-  csirep0->non_PMI_PortIndication = NULL;
-  csirep0->ext1 = NULL;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep0);
-  NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1));
-  csirep1->reportConfigId=2;
-  csirep1->carrier=NULL;
-  csirep1->resourcesForChannelMeasurement=initial_csi_index;
-  csirep1->csi_IM_ResourcesForInterference=NULL;
-  csirep1->nzp_CSI_RS_ResourcesForInterference=NULL;
-  csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic;
-  csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic));
-  csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320;
-  csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 49;
-  NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1));
-  pucchcsires1->uplinkBandwidthPartId=1;
-  pucchcsires1->pucch_Resource=12;
-  ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1);
-  csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP;
-  csirep1->reportQuantity.choice.ssb_Index_RSRP=(NULL_t)0;
-  csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration));
-  csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI;
-  csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI;
-  csirep1->reportFreqConfiguration->csi_ReportingBand=NULL;
-  csirep1->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured;
-  csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured;
-  csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig));
-  csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1;
-  csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1));
-  csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel;
-  csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel));
-  csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present=
-    NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two;
-  csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two=
-    calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two));
-  csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1;
-  csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2;
-  csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1);
-  csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc;
-  //'111111'B
-  csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1;
-  csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0;
-  csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1);
-  csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0xc0; //'00000011'B
-  csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1;
-  csirep1->dummy = NULL;
-  csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled;
-  csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled));
-  csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS));
-  *csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n2;
-  // this corresponds to:
-  //if the UE is configured with the higher layer parameter groupBasedBeamReporting set to 'disabled', the UE is not required to update measurements for more than 64 CSI-RS and/or SSB resources, and the UE shall report in a single report nrofReportedRS (higher layer configured) different CRI or SSBRI for each report setting.
-  csirep1->cqi_Table = calloc(1,sizeof(*csirep1->cqi_Table));
-  *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1;
-  csirep1->subbandSize = NR_CSI_ReportConfig__subbandSize_value1;
-  csirep1->non_PMI_PortIndication = NULL;
-  csirep1->ext1 = NULL;
-  ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep1);
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->sCellDeactivationTimer=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->tag_Id=0;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->dummy=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->pathlossReferenceLinking=NULL;
-  secondaryCellGroup->spCellConfig->spCellConfigDedicated->servingCellMO=NULL;
+
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup));
+
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL;
+
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition));
+ *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0;
+
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=NULL;
+#if 0
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList));
+
+ NR_TCI_State_t*tcid0=calloc(1,sizeof(*tcid0));
+ tcid0->tci_StateId=0;
+ tcid0->qcl_Type1.cell=NULL;
+ tcid0->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid0->qcl_Type1.bwp_Id));
+ *tcid0->qcl_Type1.bwp_Id=1;
+ tcid0->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tcid0->qcl_Type1.referenceSignal.choice.csi_rs = 2;
+ tcid0->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid0);
+
+ NR_TCI_State_t*tcid1=calloc(1,sizeof(*tcid1));
+ tcid1->tci_StateId=0;
+ tcid1->qcl_Type1.cell=NULL;
+ tcid1->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid1->qcl_Type1.bwp_Id));
+ *tcid1->qcl_Type1.bwp_Id=1;
+ tcid1->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tcid1->qcl_Type1.referenceSignal.choice.csi_rs = 6;
+ tcid1->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid1);
+
+ NR_TCI_State_t*tcid2=calloc(1,sizeof(*tcid2));
+ tcid2->tci_StateId=2;
+ tcid2->qcl_Type1.cell=NULL;
+ tcid2->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid2->qcl_Type1.bwp_Id));
+ *tcid2->qcl_Type1.bwp_Id=1;
+ tcid2->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tcid2->qcl_Type1.referenceSignal.choice.csi_rs = 10;
+ tcid2->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid2);
+
+ NR_TCI_State_t*tcid3=calloc(1,sizeof(*tcid3));
+ tcid3->tci_StateId=3;
+ tcid3->qcl_Type1.cell=NULL;
+ tcid3->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid3->qcl_Type1.bwp_Id));
+ *tcid3->qcl_Type1.bwp_Id=1;
+ tcid3->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tcid3->qcl_Type1.referenceSignal.choice.csi_rs = 14;
+ tcid3->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid3);
+
+ NR_TCI_State_t*tcid4=calloc(1,sizeof(*tcid4));
+ tcid4->tci_StateId=4;
+ tcid4->qcl_Type1.cell=NULL;
+ tcid4->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid4->qcl_Type1.bwp_Id));
+ *tcid4->qcl_Type1.bwp_Id=1;
+ tcid4->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tcid4->qcl_Type1.referenceSignal.choice.csi_rs = 18;
+ tcid4->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid4);
+
+ NR_TCI_State_t*tcid5=calloc(1,sizeof(*tcid5));
+ tcid5->tci_StateId=5;
+ tcid5->qcl_Type1.cell=NULL;
+ tcid5->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid5->qcl_Type1.bwp_Id));
+ *tcid5->qcl_Type1.bwp_Id=1;
+ tcid5->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tcid5->qcl_Type1.referenceSignal.choice.csi_rs = 22;
+ tcid5->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid5);
+
+ NR_TCI_State_t*tcid6=calloc(1,sizeof(*tcid6));
+ tcid6->tci_StateId=6;
+ tcid6->qcl_Type1.cell=NULL;
+ tcid6->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid6->qcl_Type1.bwp_Id));
+ *tcid6->qcl_Type1.bwp_Id=1;
+ tcid6->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tcid6->qcl_Type1.referenceSignal.choice.csi_rs = 26;
+ tcid6->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid6);
+
+ NR_TCI_State_t*tcid7=calloc(1,sizeof(*tcid7));
+ tcid7->tci_StateId=7;
+ tcid7->qcl_Type1.cell=NULL;
+ tcid7->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid7->qcl_Type1.bwp_Id));
+ *tcid7->qcl_Type1.bwp_Id=1;
+ tcid7->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
+ tcid7->qcl_Type1.referenceSignal.choice.csi_rs = 30;
+ tcid7->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid7);
+
+ NR_TCI_State_t*tcid8=calloc(1,sizeof(*tcid8));
+ tcid8->tci_StateId=8;
+ tcid8->qcl_Type1.cell=NULL;
+ tcid8->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid8->qcl_Type1.bwp_Id));
+ *tcid8->qcl_Type1.bwp_Id=1;
+ tcid8->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tcid8->qcl_Type1.referenceSignal.choice.ssb = 0;
+ tcid8->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid8);
+
+ NR_TCI_State_t*tcid9=calloc(1,sizeof(*tcid9));
+ tcid9->tci_StateId=9;
+ tcid9->qcl_Type1.cell=NULL;
+ tcid9->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid9->qcl_Type1.bwp_Id));
+ *tcid9->qcl_Type1.bwp_Id=1;
+ tcid9->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tcid9->qcl_Type1.referenceSignal.choice.ssb = 1;
+ tcid9->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid9);
+
+ NR_TCI_State_t*tcid10=calloc(1,sizeof(*tcid10));
+ tcid10->tci_StateId=10;
+ tcid10->qcl_Type1.cell=NULL;
+ tcid10->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid10->qcl_Type1.bwp_Id));
+ *tcid10->qcl_Type1.bwp_Id=1;
+ tcid10->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tcid10->qcl_Type1.referenceSignal.choice.ssb = 2;
+ tcid10->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid10);
+
+ NR_TCI_State_t*tcid11=calloc(1,sizeof(*tcid11));
+ tcid11->tci_StateId=11;
+ tcid11->qcl_Type1.cell=NULL;
+ tcid11->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid11->qcl_Type1.bwp_Id));
+ *tcid11->qcl_Type1.bwp_Id=1;
+ tcid11->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tcid11->qcl_Type1.referenceSignal.choice.ssb = 3;
+ tcid11->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid11);
+
+ NR_TCI_State_t*tcid12=calloc(1,sizeof(*tcid12));
+ tcid12->tci_StateId=12;
+ tcid12->qcl_Type1.cell=NULL;
+ tcid12->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid12->qcl_Type1.bwp_Id));
+ *tcid12->qcl_Type1.bwp_Id=1;
+ tcid12->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tcid12->qcl_Type1.referenceSignal.choice.ssb = 4;
+ tcid12->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid12);
+
+ NR_TCI_State_t*tcid13=calloc(1,sizeof(*tcid13));
+ tcid13->tci_StateId=13;
+ tcid13->qcl_Type1.cell=NULL;
+ tcid13->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid13->qcl_Type1.bwp_Id));
+ *tcid13->qcl_Type1.bwp_Id=1;
+ tcid13->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tcid13->qcl_Type1.referenceSignal.choice.ssb = 5;
+ tcid13->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid13);
+
+ NR_TCI_State_t*tcid14=calloc(1,sizeof(*tcid14));
+ tcid14->tci_StateId=14;
+ tcid14->qcl_Type1.cell=NULL;
+ tcid14->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid14->qcl_Type1.bwp_Id));
+ *tcid14->qcl_Type1.bwp_Id=1;
+ tcid14->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tcid14->qcl_Type1.referenceSignal.choice.ssb = 6;
+ tcid14->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid14);
+
+ NR_TCI_State_t*tcid15=calloc(1,sizeof(*tcid15));
+ tcid15->tci_StateId=15;
+ tcid15->qcl_Type1.cell=NULL;
+ tcid15->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid15->qcl_Type1.bwp_Id));
+ *tcid15->qcl_Type1.bwp_Id=1;
+ tcid15->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
+ tcid15->qcl_Type1.referenceSignal.choice.ssb = 7;
+ tcid15->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
+ ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid15);
+#endif
+
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI));
+ *bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling));
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize =
+   calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize));
+ *bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL;
+
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI));
+ *bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling));
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize =
+   calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize));
+ *bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
+ bwp->bwp_Dedicated->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL;
+ bwp->bwp_Dedicated->sps_Config = NULL; //calloc(1,sizeof(struct NR_SetupRelease_SPS_Config));
+
+ bwp->bwp_Dedicated->radioLinkMonitoringConfig = NULL;
+#if 0
+ bwp->bwp_Dedicated->radioLinkMonitoringConfig = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig));
+ bwp->bwp_Dedicated->radioLinkMonitoringConfig->present = NR_SetupRelease_RadioLinkMonitoringConfig_PR_setup;
+
+ bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup));
+ bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToAddModList=NULL;
+ bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToReleaseList=NULL;
+ bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount));
+ *bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = NR_RadioLinkMonitoringConfig__beamFailureInstanceMaxCount_n3;
+ bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer));
+ *bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = NR_RadioLinkMonitoringConfig__beamFailureDetectionTimer_pbfd2;
+#endif
+ 
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list,bwp);
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id));
+ 
+ *secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id=1;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->bwp_InactivityTimer = NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id));
+ *secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = 1;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig));
+
+ NR_BWP_UplinkDedicated_t *initialUplinkBWP = calloc(1,sizeof(*initialUplinkBWP));
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP = initialUplinkBWP;
+ initialUplinkBWP->pucch_Config = NULL;
+ initialUplinkBWP->pusch_Config = calloc(1,sizeof(*initialUplinkBWP->pusch_Config));
+ initialUplinkBWP->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup;
+ NR_PUSCH_Config_t *pusch_Config = calloc(1,sizeof(*pusch_Config));
+ initialUplinkBWP->pusch_Config->choice.setup = pusch_Config;
+ pusch_Config->txConfig=calloc(1,sizeof(*pusch_Config->txConfig));
+ *pusch_Config->txConfig= NR_PUSCH_Config__txConfig_codebook;
+ pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA = NULL;
+ pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB));
+ pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup;
+ pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup));
+ NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup;
+ NR_DMRS_UplinkConfig->dmrs_Type = NULL;
+ NR_DMRS_UplinkConfig->dmrs_AdditionalPosition =NR_DMRS_UplinkConfig__dmrs_AdditionalPosition_pos0;
+ NR_DMRS_UplinkConfig->phaseTrackingRS=NULL;
+ NR_DMRS_UplinkConfig->maxLength=NULL;
+ NR_DMRS_UplinkConfig->transformPrecodingDisabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingDisabled));
+ NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID0 = NULL;
+ NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID1 = NULL;
+ NR_DMRS_UplinkConfig->transformPrecodingEnabled = NULL;
+ pusch_Config->pusch_PowerControl = calloc(1,sizeof(*pusch_Config->pusch_PowerControl));
+ pusch_Config->pusch_PowerControl->tpc_Accumulation = NULL;
+ pusch_Config->pusch_PowerControl->msg3_Alpha = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->msg3_Alpha));
+ *pusch_Config->pusch_PowerControl->msg3_Alpha = NR_Alpha_alpha1;
+ pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = NULL;
+ pusch_Config->pusch_PowerControl->p0_AlphaSets = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_AlphaSets));
+ NR_P0_PUSCH_AlphaSet_t *aset = calloc(1,sizeof(*aset));
+ aset->p0_PUSCH_AlphaSetId=0;
+ aset->p0=calloc(1,sizeof(*aset->p0));
+ *aset->p0 = 0;
+ aset->alpha=calloc(1,sizeof(*aset->alpha));
+ *aset->alpha=NR_Alpha_alpha1;
+ ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->p0_AlphaSets->list,aset);
+ pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList));
+ NR_PUSCH_PathlossReferenceRS_t *pl = calloc(1,sizeof(*pl));
+ pl->pusch_PathlossReferenceRS_Id=0;
+ pl->referenceSignal.present = NR_PUSCH_PathlossReferenceRS__referenceSignal_PR_csi_RS_Index;
+ pl->referenceSignal.choice.csi_RS_Index=0;
+ ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList->list,pl);
+ pusch_Config->pusch_PowerControl->pathlossReferenceRSToReleaseList = NULL;
+ pusch_Config->pusch_PowerControl->twoPUSCH_PC_AdjustmentStates = NULL;
+ pusch_Config->pusch_PowerControl->deltaMCS = NULL;
+ pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList = NULL;
+ pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToReleaseList = NULL;
+ pusch_Config->frequencyHopping=NULL;
+ pusch_Config->frequencyHoppingOffsetLists=NULL;
+ pusch_Config->resourceAllocation = NR_PUSCH_Config__resourceAllocation_resourceAllocationType1;
+ pusch_Config->pusch_TimeDomainAllocationList = NULL;
+ pusch_Config->pusch_AggregationFactor=NULL;
+ pusch_Config->mcs_Table=NULL;
+ pusch_Config->mcs_TableTransformPrecoder=NULL;
+ pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder));
+ *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled;
+ pusch_Config->codebookSubset=calloc(1,sizeof(*pusch_Config->codebookSubset));
+ *pusch_Config->codebookSubset = NR_PUSCH_Config__codebookSubset_nonCoherent;
+ pusch_Config->maxRank=calloc(1,sizeof(*pusch_Config->maxRank));
+ *pusch_Config->maxRank= 1;
+ pusch_Config->rbg_Size=NULL;
+ pusch_Config->uci_OnPUSCH=NULL;
+ pusch_Config->tp_pi2BPSK=NULL;
+
+ initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config));
+ initialUplinkBWP->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup;
+ NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config));
+ initialUplinkBWP->srs_Config->choice.setup=srs_Config;
+ srs_Config->srs_ResourceSetToReleaseList=NULL;
+ srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList));
+ NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0));
+ srs_resset0->srs_ResourceSetId = 0;
+ srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList));
+ NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id));
+ *srs_resset0_id=0;
+ ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id);
+ srs_Config->srs_ResourceToReleaseList=NULL;
+ srs_resset0->resourceType.present =  NR_SRS_ResourceSet__resourceType_PR_aperiodic;
+ srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic));
+ srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1;
+ srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL;
+ srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset));
+ *srs_resset0->resourceType.choice.aperiodic->slotOffset=2;
+ srs_resset0->resourceType.choice.aperiodic->ext1=NULL;
+ srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook;
+ srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha));
+ *srs_resset0->alpha = NR_Alpha_alpha1;
+ srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0));
+ *srs_resset0->p0=-80;
+ srs_resset0->pathlossReferenceRS=NULL;
+ srs_resset0->srs_PowerControlAdjustmentStates=NULL;
+ ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0);
+ srs_Config->srs_ResourceToReleaseList=NULL;
+ srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList));
+ NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0));
+ srs_res0->srs_ResourceId=0;
+ srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1;
+ srs_res0->ptrs_PortIndex=NULL;
+ srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; 
+ srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2));
+ srs_res0->transmissionComb.choice.n2->combOffset_n2=0;
+ srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0;
+ srs_res0->resourceMapping.startPosition=2;
+ srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1;
+ srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1;
+ srs_res0->freqDomainPosition=0;
+ srs_res0->freqDomainShift=0;
+ srs_res0->freqHopping.c_SRS = 61;
+ srs_res0->freqHopping.b_SRS=0;
+ srs_res0->freqHopping.b_hop=0;
+ srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither;
+ srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic;
+ srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic));
+ srs_res0->sequenceId=40;
+ srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo));
+ srs_res0->spatialRelationInfo->servingCellId=NULL;
+ srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index;
+ srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0;
+ ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0);
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToReleaseList = NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList));
+ NR_BWP_Uplink_t *ubwp = calloc(1,sizeof(*ubwp));
+ ubwp->bwp_Id=1;
+ ubwp->bwp_Common = calloc(1,sizeof(*ubwp->bwp_Common));
+ // copy bwp_Common from Initial UL BWP except for bandwidth
+ memcpy((void*)&ubwp->bwp_Common->genericParameters,
+	(void*)&servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters,
+	sizeof(servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters));
+ ubwp->bwp_Common->genericParameters.locationAndBandwidth=PRBalloc_to_locationandbandwidth(servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0);
+
+ ubwp->bwp_Common->rach_ConfigCommon  = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon;
+ ubwp->bwp_Common->pusch_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon;
+ ubwp->bwp_Common->pucch_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon;
+ 
+ ubwp->bwp_Dedicated = calloc(1,sizeof(*ubwp->bwp_Dedicated));
+ ubwp->bwp_Dedicated->pucch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pucch_Config));
+ ubwp->bwp_Dedicated->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup;
+ NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config));
+ ubwp->bwp_Dedicated->pucch_Config->choice.setup=pucch_Config;
+ pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList));
+ pucch_Config->resourceSetToReleaseList = NULL;
+ NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0));
+ NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1));
+ pucchresset0->pucch_ResourceSetId = 0;
+ NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0));
+ NR_PUCCH_ResourceId_t *pucchresset0id1=calloc(1,sizeof(*pucchresset0id1));
+ *pucchresset0id0=1;
+ ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id0);
+ *pucchresset0id1=2;
+ ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id1);
+ pucchresset0->maxPayloadMinus1=NULL;
+
+ ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0);
+
+ pucchresset1->pucch_ResourceSetId = 1;
+ NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0));
+ NR_PUCCH_ResourceId_t *pucchresset1id1=calloc(1,sizeof(*pucchresset1id1));
+ *pucchresset1id0=3;
+ ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id0);
+ *pucchresset1id1=4;
+ ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id1);
+ pucchresset1->maxPayloadMinus1=NULL;
+ ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1);
+
+ pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList));
+ pucch_Config->resourceToReleaseList = NULL;
+ NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0));
+ NR_PUCCH_Resource_t *pucchres1=calloc(1,sizeof(*pucchres1));
+ NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2));
+ NR_PUCCH_Resource_t *pucchres3=calloc(1,sizeof(*pucchres3));
+ pucchres0->pucch_ResourceId=1;
+ pucchres0->startingPRB=48;
+ pucchres0->intraSlotFrequencyHopping=NULL;
+ pucchres0->secondHopPRB=NULL;
+ pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0;
+ pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0));
+ pucchres0->format.choice.format0->initialCyclicShift=0;
+ pucchres0->format.choice.format0->nrofSymbols=1;
+ pucchres0->format.choice.format0->startingSymbolIndex=13;
+ ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0);
+
+ pucchres1->pucch_ResourceId=2;
+ pucchres1->startingPRB=48;
+ pucchres1->intraSlotFrequencyHopping=NULL;
+ pucchres1->secondHopPRB=NULL;
+ pucchres1->format.present= NR_PUCCH_Resource__format_PR_format0;
+ pucchres1->format.choice.format0=calloc(1,sizeof(*pucchres1->format.choice.format0));
+ pucchres1->format.choice.format0->initialCyclicShift=0;
+ pucchres1->format.choice.format0->nrofSymbols=1;
+ pucchres1->format.choice.format0->startingSymbolIndex=12;
+ ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres1);
+
+ pucchres2->pucch_ResourceId=3;
+ pucchres2->startingPRB=40;
+ pucchres2->intraSlotFrequencyHopping=NULL;
+ pucchres2->secondHopPRB=NULL;
+ pucchres2->format.present= NR_PUCCH_Resource__format_PR_format2;
+ pucchres2->format.choice.format2=calloc(1,sizeof(*pucchres2->format.choice.format2));
+ pucchres2->format.choice.format2->nrofPRBs=16;
+ pucchres2->format.choice.format2->nrofSymbols=1;
+ pucchres2->format.choice.format2->startingSymbolIndex=13;
+ ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2);
+
+ pucchres3->pucch_ResourceId=4;
+ pucchres3->startingPRB=40;
+ pucchres3->intraSlotFrequencyHopping=NULL;
+ pucchres3->secondHopPRB=NULL;
+ pucchres3->format.present= NR_PUCCH_Resource__format_PR_format2;
+ pucchres3->format.choice.format2=calloc(1,sizeof(*pucchres3->format.choice.format2));
+ pucchres3->format.choice.format2->nrofPRBs=16;
+ pucchres3->format.choice.format2->nrofSymbols=1;
+ pucchres3->format.choice.format2->startingSymbolIndex=12;
+ ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres3);
+
+ pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2));
+ pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup;
+ NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2));
+ pucch_Config->format2->choice.setup = pucchfmt2;
+ pucchfmt2->interslotFrequencyHopping=NULL;
+ pucchfmt2->additionalDMRS=NULL;
+ pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate));
+ *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot15;
+ pucchfmt2->nrofSlots=NULL;
+ pucchfmt2->pi2BPSK=NULL;
+ pucchfmt2->simultaneousHARQ_ACK_CSI=NULL;
+ pucch_Config->schedulingRequestResourceToAddModList=NULL;
+ pucch_Config->schedulingRequestResourceToReleaseList=NULL;
+ pucch_Config->multi_CSI_PUCCH_ResourceList=NULL;
+ pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK));
+ long *delay[8];
+ for (int i=0;i<8;i++) {
+   delay[i] = calloc(1,sizeof(*delay[i]));
+   *delay[i] = (i<6) ? (i+2) : 0;
+   ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]);
+ }
+ pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList));
+ NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial));
+ pucchspatial->pucch_SpatialRelationInfoId = 1;
+ pucchspatial->servingCellId = NULL;
+ pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index;
+ pucchspatial->referenceSignal.choice.csi_RS_Index = 0;
+ pucchspatial->pucch_PathlossReferenceRS_Id = 0;
+ pucchspatial->p0_PUCCH_Id = 1;
+ pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0;
+ ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial);
+ pucch_Config->spatialRelationInfoToReleaseList=NULL;
+ pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl));
+ pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0));
+ *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0;
+ pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1));
+ *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0;
+ pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2));
+ *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0;
+ pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3));
+ *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0;
+ pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4));
+ *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0;
+ pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set));
+ NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00));
+ p00->p0_PUCCH_Id=1;
+ p00->p0_PUCCH_Value = 0;
+ ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00);
+ pucch_Config->pucch_PowerControl->pathlossReferenceRSs = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->pathlossReferenceRSs));
+ NR_PUCCH_PathlossReferenceRS_t *pucchPLRef=calloc(1,sizeof(*pucchPLRef));
+ pucchPLRef->pucch_PathlossReferenceRS_Id=0;
+ pucchPLRef->referenceSignal.present = NR_PUCCH_PathlossReferenceRS__referenceSignal_PR_csi_RS_Index;
+ pucchPLRef->referenceSignal.choice.csi_RS_Index=0;
+ ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->pathlossReferenceRSs->list,pucchPLRef);
+
+ // copy pusch_Config from dedicated initialBWP
+ ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config));
+ ubwp->bwp_Dedicated->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup;
+ ubwp->bwp_Dedicated->pusch_Config->choice.setup = pusch_Config;
+
+ ubwp->bwp_Dedicated->configuredGrantConfig = NULL;
+ ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config));
+ ubwp->bwp_Dedicated->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup;
+ ubwp->bwp_Dedicated->srs_Config->choice.setup = srs_Config;
+
+ ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL;
+
+ ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list,ubwp);
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id));
+ *secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = 1;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig = NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->carrierSwitching = NULL;
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->supplementaryUplink=NULL;
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdcch_ServingCellConfig=NULL;
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig));
+ NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig = calloc(1,sizeof(*pdsch_servingcellconfig));
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present = NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig;
+ pdsch_servingcellconfig->codeBlockGroupTransmission = NULL;
+ pdsch_servingcellconfig->xOverhead = NULL;
+ pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = NULL;
+ pdsch_servingcellconfig->pucch_Cell= NULL;
+ pdsch_servingcellconfig->ext1=calloc(1,sizeof(*pdsch_servingcellconfig->ext1));
+ pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1,sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers));
+ *pdsch_servingcellconfig->ext1->maxMIMO_Layers = 2;
+ pdsch_servingcellconfig->ext1->processingType2Enabled = NULL;
+ 
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig=NULL;
+ //secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig));
+ //secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup;
+
+
+ NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig));
+// secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig;
+ csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList));
+
+ NR_NZP_CSI_RS_Resource_t *nzpres0 = calloc(1,sizeof(*nzpres0));
+ nzpres0->nzp_CSI_RS_ResourceId=0;
+ nzpres0->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_other;
+ nzpres0->resourceMapping.frequencyDomainAllocation.choice.other.buf = calloc(1,1);
+ nzpres0->resourceMapping.frequencyDomainAllocation.choice.other.size = 1;
+ nzpres0->resourceMapping.frequencyDomainAllocation.choice.other.bits_unused = 2;
+ nzpres0->resourceMapping.frequencyDomainAllocation.choice.other.buf[0]=1<<2;
+ nzpres0->resourceMapping.nrofPorts = (n_physical_antenna_ports==1)? NR_CSI_RS_ResourceMapping__nrofPorts_p1 : NR_CSI_RS_ResourceMapping__nrofPorts_p2;
+ nzpres0->resourceMapping.firstOFDMSymbolInTimeDomain=7;
+ nzpres0->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+ nzpres0->resourceMapping.cdm_Type = (n_physical_antenna_ports==1)? NR_CSI_RS_ResourceMapping__cdm_Type_noCDM : NR_CSI_RS_ResourceMapping__cdm_Type_fd_CDM2;
+ nzpres0->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_one;
+ nzpres0->resourceMapping.density.choice.one=(NULL_t)0;
+ nzpres0->resourceMapping.freqBand.startingRB=0;
+ nzpres0->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+ nzpres0->powerControlOffset=13;
+ nzpres0->powerControlOffsetSS=NULL;
+ nzpres0->scramblingID=40;
+ nzpres0->periodicityAndOffset = calloc(1,sizeof(*nzpres0->periodicityAndOffset));
+ nzpres0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320;
+ nzpres0->periodicityAndOffset->choice.slots320 = 2;
+ nzpres0->qcl_InfoPeriodicCSI_RS=NULL;
+ ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres0);
+
+ if (n_physical_antenna_ports > 1) {
+   NR_NZP_CSI_RS_Resource_t *nzpres2 = calloc(1,sizeof(*nzpres2));
+   nzpres2->nzp_CSI_RS_ResourceId=2;
+   nzpres2->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres2->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres2->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres2->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres2->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=1;
+   nzpres2->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres2->resourceMapping.firstOFDMSymbolInTimeDomain=4;
+   nzpres2->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres2->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres2->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres2->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres2->resourceMapping.freqBand.startingRB=0;
+   nzpres2->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres2->powerControlOffset=0;
+   nzpres2->powerControlOffsetSS=calloc(1,sizeof(*nzpres2->powerControlOffsetSS));
+   *nzpres2->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres2->scramblingID=40;
+   nzpres2->periodicityAndOffset = calloc(1,sizeof(*nzpres2->periodicityAndOffset));
+   nzpres2->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres2->periodicityAndOffset->choice.slots160 = 25;
+   nzpres2->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres2->qcl_InfoPeriodicCSI_RS));
+   *nzpres2->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres2);
+   
+   
+   NR_NZP_CSI_RS_Resource_t *nzpres3 = calloc(1,sizeof(*nzpres3));
+   nzpres3->nzp_CSI_RS_ResourceId=3;
+   nzpres3->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres3->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres3->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres3->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres3->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=1;
+   nzpres3->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres3->resourceMapping.firstOFDMSymbolInTimeDomain=8;
+   nzpres3->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres3->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres3->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres3->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres3->resourceMapping.freqBand.startingRB=0;
+   nzpres3->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres3->powerControlOffset=0;
+   nzpres3->powerControlOffsetSS=calloc(1,sizeof(*nzpres3->powerControlOffsetSS));
+   *nzpres3->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres3->scramblingID=40;
+   nzpres3->periodicityAndOffset = calloc(1,sizeof(*nzpres3->periodicityAndOffset));
+   nzpres3->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres3->periodicityAndOffset->choice.slots160 = 25;
+   nzpres3->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres3->qcl_InfoPeriodicCSI_RS));
+   *nzpres3->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres3);
+ }
+ if (n_physical_antenna_ports > 3) {
+   NR_NZP_CSI_RS_Resource_t *nzpres4 = calloc(1,sizeof(*nzpres4));
+   nzpres4->nzp_CSI_RS_ResourceId=4;
+   nzpres4->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres4->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres4->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres4->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres4->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=1;
+   nzpres4->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres4->resourceMapping.firstOFDMSymbolInTimeDomain=4;
+   nzpres4->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres4->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres4->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres4->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres4->resourceMapping.freqBand.startingRB=0;
+   nzpres4->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres4->powerControlOffset=0;
+   nzpres4->powerControlOffsetSS=calloc(1,sizeof(*nzpres4->powerControlOffsetSS));
+   *nzpres4->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres4->scramblingID=40;
+   nzpres4->periodicityAndOffset = calloc(1,sizeof(*nzpres4->periodicityAndOffset));
+   nzpres4->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres4->periodicityAndOffset->choice.slots160 = 26;
+   nzpres4->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres4->qcl_InfoPeriodicCSI_RS));
+   *nzpres4->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres4);
+   
+   NR_NZP_CSI_RS_Resource_t *nzpres5 = calloc(1,sizeof(*nzpres5));
+   nzpres5->nzp_CSI_RS_ResourceId=5;
+   nzpres5->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres5->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres5->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres5->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres5->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=1;
+   nzpres5->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres5->resourceMapping.firstOFDMSymbolInTimeDomain=8;
+   nzpres5->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres5->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres5->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres5->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres5->resourceMapping.freqBand.startingRB=0;
+   nzpres5->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres5->powerControlOffset=0;
+   nzpres5->powerControlOffsetSS=calloc(1,sizeof(*nzpres5->powerControlOffsetSS));
+   *nzpres5->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres5->scramblingID=40;
+   nzpres5->periodicityAndOffset = calloc(1,sizeof(*nzpres5->periodicityAndOffset));
+   nzpres5->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres5->periodicityAndOffset->choice.slots160 = 26;
+   nzpres5->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres5->qcl_InfoPeriodicCSI_RS));
+   *nzpres5->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres5);
+ }
+ if (n_physical_antenna_ports > 7) {
+   NR_NZP_CSI_RS_Resource_t *nzpres6 = calloc(1,sizeof(*nzpres6));
+   nzpres6->nzp_CSI_RS_ResourceId=6;
+   nzpres6->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres6->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres6->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres6->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres6->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=4;
+   nzpres6->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres6->resourceMapping.firstOFDMSymbolInTimeDomain=4;
+   nzpres6->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres6->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres6->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres6->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres6->resourceMapping.freqBand.startingRB=0;
+   nzpres6->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres6->powerControlOffset=0;
+   nzpres6->powerControlOffsetSS=calloc(1,sizeof(*nzpres6->powerControlOffsetSS));
+   *nzpres6->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres6->scramblingID=40;
+   nzpres6->periodicityAndOffset = calloc(1,sizeof(*nzpres6->periodicityAndOffset));
+   nzpres6->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres6->periodicityAndOffset->choice.slots160 = 25;
+   nzpres6->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres6->qcl_InfoPeriodicCSI_RS));
+   *nzpres6->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres6);
+   
+   NR_NZP_CSI_RS_Resource_t *nzpres7 = calloc(1,sizeof(*nzpres7));
+   nzpres7->nzp_CSI_RS_ResourceId=7;
+   nzpres7->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres7->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres7->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres7->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres7->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=4;
+   nzpres7->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres7->resourceMapping.firstOFDMSymbolInTimeDomain=8;
+   nzpres7->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres7->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres7->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres7->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres7->resourceMapping.freqBand.startingRB=0;
+   nzpres7->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres7->powerControlOffset=0;
+   nzpres7->powerControlOffsetSS=calloc(1,sizeof(*nzpres7->powerControlOffsetSS));
+   *nzpres7->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres7->scramblingID=40;
+   nzpres7->periodicityAndOffset = calloc(1,sizeof(*nzpres7->periodicityAndOffset));
+   nzpres7->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres7->periodicityAndOffset->choice.slots160 = 25;
+   nzpres7->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres7->qcl_InfoPeriodicCSI_RS));
+   *nzpres7->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres7);
+   NR_NZP_CSI_RS_Resource_t *nzpres8 = calloc(1,sizeof(*nzpres8));
+   nzpres8->nzp_CSI_RS_ResourceId=8;
+   nzpres8->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres8->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres8->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres8->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres8->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=4;
+   nzpres8->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres8->resourceMapping.firstOFDMSymbolInTimeDomain=4;
+   nzpres8->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres8->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres8->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres8->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres8->resourceMapping.freqBand.startingRB=0;
+   nzpres8->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres8->powerControlOffset=0;
+   nzpres8->powerControlOffsetSS=calloc(1,sizeof(*nzpres8->powerControlOffsetSS));
+   *nzpres8->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres8->scramblingID=40;
+   nzpres8->periodicityAndOffset = calloc(1,sizeof(*nzpres8->periodicityAndOffset));
+   nzpres8->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres8->periodicityAndOffset->choice.slots160 = 26;
+   nzpres8->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres8->qcl_InfoPeriodicCSI_RS));
+   *nzpres8->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres8);
+   
+   NR_NZP_CSI_RS_Resource_t *nzpres9 = calloc(1,sizeof(*nzpres9));
+   nzpres9->nzp_CSI_RS_ResourceId=9;
+   nzpres9->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres9->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres9->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres9->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres9->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=4;
+   nzpres9->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres9->resourceMapping.firstOFDMSymbolInTimeDomain=8;
+   nzpres9->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres9->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres9->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres9->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres9->resourceMapping.freqBand.startingRB=0;
+   nzpres9->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres9->powerControlOffset=0;
+   nzpres9->powerControlOffsetSS=calloc(1,sizeof(*nzpres9->powerControlOffsetSS));
+   *nzpres9->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres9->scramblingID=40;
+   nzpres9->periodicityAndOffset = calloc(1,sizeof(*nzpres9->periodicityAndOffset));
+   nzpres9->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres9->periodicityAndOffset->choice.slots160 = 26;
+   nzpres9->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres9->qcl_InfoPeriodicCSI_RS));
+   *nzpres9->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres9);
+ }
+ if (n_physical_antenna_ports > 15) {
+   NR_NZP_CSI_RS_Resource_t *nzpres10 = calloc(1,sizeof(*nzpres10));
+   nzpres10->nzp_CSI_RS_ResourceId=10;
+   nzpres10->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres10->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres10->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres10->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres10->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=2;
+   nzpres10->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres10->resourceMapping.firstOFDMSymbolInTimeDomain=4;
+   nzpres10->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres10->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres10->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres10->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres10->resourceMapping.freqBand.startingRB=0;
+   nzpres10->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres10->powerControlOffset=0;
+   nzpres10->powerControlOffsetSS=calloc(1,sizeof(*nzpres10->powerControlOffsetSS));
+   *nzpres10->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres10->scramblingID=40;
+   nzpres10->periodicityAndOffset = calloc(1,sizeof(*nzpres10->periodicityAndOffset));
+   nzpres10->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres10->periodicityAndOffset->choice.slots160 = 25;
+   nzpres10->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres10->qcl_InfoPeriodicCSI_RS));
+   *nzpres10->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres10);
+   
+   NR_NZP_CSI_RS_Resource_t *nzpres11 = calloc(1,sizeof(*nzpres11));
+   nzpres11->nzp_CSI_RS_ResourceId=11;
+   nzpres11->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres11->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres11->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres11->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres11->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=2;
+   nzpres11->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres11->resourceMapping.firstOFDMSymbolInTimeDomain=8;
+   nzpres11->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres11->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres11->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres11->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres11->resourceMapping.freqBand.startingRB=0;
+   nzpres11->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres11->powerControlOffset=0;
+   nzpres11->powerControlOffsetSS=calloc(1,sizeof(*nzpres11->powerControlOffsetSS));
+   *nzpres11->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres11->scramblingID=40;
+   nzpres11->periodicityAndOffset = calloc(1,sizeof(*nzpres11->periodicityAndOffset));
+   nzpres11->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres11->periodicityAndOffset->choice.slots160 = 25;
+   nzpres11->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres11->qcl_InfoPeriodicCSI_RS));
+   *nzpres11->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres11);
+   NR_NZP_CSI_RS_Resource_t *nzpres12 = calloc(1,sizeof(*nzpres12));
+   nzpres12->nzp_CSI_RS_ResourceId=12;
+   nzpres12->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres12->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres12->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres12->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres12->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=2;
+   nzpres12->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres12->resourceMapping.firstOFDMSymbolInTimeDomain=4;
+   nzpres12->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres12->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres12->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres12->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres12->resourceMapping.freqBand.startingRB=0;
+   nzpres12->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres12->powerControlOffset=0;
+   nzpres12->powerControlOffsetSS=calloc(1,sizeof(*nzpres12->powerControlOffsetSS));
+   *nzpres12->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres12->scramblingID=40;
+   nzpres12->periodicityAndOffset = calloc(1,sizeof(*nzpres12->periodicityAndOffset));
+   nzpres12->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres12->periodicityAndOffset->choice.slots160 = 26;
+   nzpres12->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres12->qcl_InfoPeriodicCSI_RS));
+   *nzpres12->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres12);
+   
+   NR_NZP_CSI_RS_Resource_t *nzpres13 = calloc(1,sizeof(*nzpres13));
+   nzpres13->nzp_CSI_RS_ResourceId=13;
+   nzpres13->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres13->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres13->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres13->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres13->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=2;
+   nzpres13->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres13->resourceMapping.firstOFDMSymbolInTimeDomain=8;
+   nzpres13->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres13->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres13->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres13->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres13->resourceMapping.freqBand.startingRB=0;
+   nzpres13->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres13->powerControlOffset=0;
+   nzpres13->powerControlOffsetSS=calloc(1,sizeof(*nzpres13->powerControlOffsetSS));
+   *nzpres13->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres13->scramblingID=40;
+   nzpres13->periodicityAndOffset = calloc(1,sizeof(*nzpres13->periodicityAndOffset));
+   nzpres13->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres13->periodicityAndOffset->choice.slots160 = 26;
+   nzpres13->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres13->qcl_InfoPeriodicCSI_RS));
+   *nzpres13->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres13);
+   NR_NZP_CSI_RS_Resource_t *nzpres14 = calloc(1,sizeof(*nzpres14));
+   nzpres14->nzp_CSI_RS_ResourceId=14;
+   nzpres14->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres14->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres14->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres14->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres14->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=8;
+   nzpres14->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres14->resourceMapping.firstOFDMSymbolInTimeDomain=4;
+   nzpres14->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres14->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres14->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres14->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres14->resourceMapping.freqBand.startingRB=0;
+   nzpres14->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres14->powerControlOffset=0;
+   nzpres14->powerControlOffsetSS=calloc(1,sizeof(*nzpres14->powerControlOffsetSS));
+   *nzpres14->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres14->scramblingID=40;
+   nzpres14->periodicityAndOffset = calloc(1,sizeof(*nzpres14->periodicityAndOffset));
+   nzpres14->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres14->periodicityAndOffset->choice.slots160 = 25;
+   nzpres14->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres14->qcl_InfoPeriodicCSI_RS));
+   *nzpres14->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres14);
+   
+   NR_NZP_CSI_RS_Resource_t *nzpres15 = calloc(1,sizeof(*nzpres15));
+   nzpres15->nzp_CSI_RS_ResourceId=15;
+   nzpres15->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres15->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres15->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres15->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres15->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=8;
+   nzpres15->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres15->resourceMapping.firstOFDMSymbolInTimeDomain=8;
+   nzpres15->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres15->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres15->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres15->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres15->resourceMapping.freqBand.startingRB=0;
+   nzpres15->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres15->powerControlOffset=0;
+   nzpres15->powerControlOffsetSS=calloc(1,sizeof(*nzpres15->powerControlOffsetSS));
+   *nzpres15->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres15->scramblingID=40;
+   nzpres15->periodicityAndOffset = calloc(1,sizeof(*nzpres15->periodicityAndOffset));
+   nzpres15->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres15->periodicityAndOffset->choice.slots160 = 25;
+   nzpres15->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres15->qcl_InfoPeriodicCSI_RS));
+   *nzpres15->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres15);
+   NR_NZP_CSI_RS_Resource_t *nzpres16 = calloc(1,sizeof(*nzpres16));
+   nzpres16->nzp_CSI_RS_ResourceId=16;
+   nzpres16->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres16->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres16->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres16->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres16->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=8;
+   nzpres16->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres16->resourceMapping.firstOFDMSymbolInTimeDomain=5;
+   nzpres16->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres16->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres16->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres16->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres16->resourceMapping.freqBand.startingRB=0;
+   nzpres16->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres16->powerControlOffset=0;
+   nzpres16->powerControlOffsetSS=calloc(1,sizeof(*nzpres16->powerControlOffsetSS));
+   *nzpres16->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres16->scramblingID=40;
+   nzpres16->periodicityAndOffset = calloc(1,sizeof(*nzpres16->periodicityAndOffset));
+   nzpres16->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres16->periodicityAndOffset->choice.slots160 = 26;
+   nzpres16->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres16->qcl_InfoPeriodicCSI_RS));
+   *nzpres16->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres16);
+   
+   NR_NZP_CSI_RS_Resource_t *nzpres17 = calloc(1,sizeof(*nzpres17));
+   nzpres17->nzp_CSI_RS_ResourceId=9;
+   nzpres17->resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row1;
+   nzpres17->resourceMapping.frequencyDomainAllocation.choice.row1.buf = calloc(1,1);
+   nzpres17->resourceMapping.frequencyDomainAllocation.choice.row1.size = 1;
+   nzpres17->resourceMapping.frequencyDomainAllocation.choice.row1.bits_unused = 4;
+   nzpres17->resourceMapping.frequencyDomainAllocation.choice.row1.buf[0]=8;
+   nzpres17->resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
+   nzpres17->resourceMapping.firstOFDMSymbolInTimeDomain=9;
+   nzpres17->resourceMapping.firstOFDMSymbolInTimeDomain2=NULL;
+   nzpres17->resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
+   nzpres17->resourceMapping.density.present=NR_CSI_RS_ResourceMapping__density_PR_three;
+   nzpres17->resourceMapping.density.choice.three=(NULL_t)0;
+   nzpres17->resourceMapping.freqBand.startingRB=0;
+   nzpres17->resourceMapping.freqBand.nrofRBs= servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth;
+   nzpres17->powerControlOffset=0;
+   nzpres17->powerControlOffsetSS=calloc(1,sizeof(*nzpres17->powerControlOffsetSS));
+   *nzpres17->powerControlOffsetSS=NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
+   nzpres17->scramblingID=40;
+   nzpres17->periodicityAndOffset = calloc(1,sizeof(*nzpres17->periodicityAndOffset));
+   nzpres17->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots160;
+   nzpres17->periodicityAndOffset->choice.slots160 = 26;
+   nzpres17->qcl_InfoPeriodicCSI_RS=calloc(1,sizeof(*nzpres17->qcl_InfoPeriodicCSI_RS));
+   *nzpres17->qcl_InfoPeriodicCSI_RS=8;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpres17);
+ }
+
+ if (n_physical_antenna_ports > 16) AssertFatal(1==0,"Fill in for more than 16 antenna elements\n");
+ 
+ csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList  = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList));
+ csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList = NULL;
+ NR_NZP_CSI_RS_ResourceSet_t *nzpresset0=calloc(1,sizeof(*nzpresset0));
+ nzpresset0->nzp_CSI_ResourceSetId=0;
+ NR_NZP_CSI_RS_ResourceSetId_t *nzpresset00=calloc(1,sizeof(*nzpresset00));
+ *nzpresset00=0;
+ ASN_SEQUENCE_ADD(&nzpresset0->nzp_CSI_RS_Resources.list,nzpresset00);
+ nzpresset0->repetition=NULL;
+ nzpresset0->aperiodicTriggeringOffset=NULL;
+ nzpresset0->trs_Info=NULL;
+ ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpresset0);
+ if (n_physical_antenna_ports > 1) {
+   NR_NZP_CSI_RS_ResourceSet_t *nzpresset3=calloc(1,sizeof(*nzpresset3));
+   nzpresset3->nzp_CSI_ResourceSetId=3;
+   NR_NZP_CSI_RS_ResourceSetId_t *nzpresset30=calloc(1,sizeof(*nzpresset30));
+   *nzpresset30=2;
+   ASN_SEQUENCE_ADD(&nzpresset3->nzp_CSI_RS_Resources.list,nzpresset30);
+   if (n_physical_antenna_ports > 3) {
+   NR_NZP_CSI_RS_ResourceSetId_t *nzpresset31=calloc(1,sizeof(*nzpresset31));
+   *nzpresset31=3;
+   ASN_SEQUENCE_ADD(&nzpresset3->nzp_CSI_RS_Resources.list,nzpresset31);
+   NR_NZP_CSI_RS_ResourceSetId_t *nzpresset32=calloc(1,sizeof(*nzpresset32));
+   *nzpresset32=4;
+   ASN_SEQUENCE_ADD(&nzpresset3->nzp_CSI_RS_Resources.list,nzpresset32);
+   NR_NZP_CSI_RS_ResourceSetId_t *nzpresset33=calloc(1,sizeof(*nzpresset33));
+   *nzpresset33=5;
+   ASN_SEQUENCE_ADD(&nzpresset3->nzp_CSI_RS_Resources.list,nzpresset33);
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpresset3);
+   }
+   nzpresset3->repetition=calloc(1,sizeof(*nzpresset3->repetition));
+   *nzpresset3->repetition=NR_NZP_CSI_RS_ResourceSet__repetition_off;
+   nzpresset3->aperiodicTriggeringOffset=NULL;
+   nzpresset3->trs_Info=calloc(1,sizeof(*nzpresset3->trs_Info));
+   *nzpresset3->trs_Info=NR_NZP_CSI_RS_ResourceSet__trs_Info_true;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpresset3);
+ }
+
+ if (n_physical_antenna_ports > 7) {
+   NR_NZP_CSI_RS_ResourceSet_t *nzpresset4=calloc(1,sizeof(*nzpresset4));
+   nzpresset4->nzp_CSI_ResourceSetId=4;
+   NR_NZP_CSI_RS_ResourceSetId_t *nzpresset40=calloc(1,sizeof(*nzpresset40));
+   *nzpresset40=6;
+   ASN_SEQUENCE_ADD(&nzpresset4->nzp_CSI_RS_Resources.list,nzpresset40);
+   NR_NZP_CSI_RS_ResourceSetId_t *nzpresset41=calloc(1,sizeof(*nzpresset41));
+   *nzpresset41=7;
+   ASN_SEQUENCE_ADD(&nzpresset4->nzp_CSI_RS_Resources.list,nzpresset41);
+   NR_NZP_CSI_RS_ResourceSetId_t *nzpresset42=calloc(1,sizeof(*nzpresset42));
+   *nzpresset42=8;
+   ASN_SEQUENCE_ADD(&nzpresset4->nzp_CSI_RS_Resources.list,nzpresset42);
+   NR_NZP_CSI_RS_ResourceSetId_t *nzpresset43=calloc(1,sizeof(*nzpresset43));
+   *nzpresset43=9;
+   ASN_SEQUENCE_ADD(&nzpresset4->nzp_CSI_RS_Resources.list,nzpresset43);
+   nzpresset4->repetition=calloc(1,sizeof(*nzpresset4->repetition));
+   *nzpresset4->repetition=NR_NZP_CSI_RS_ResourceSet__repetition_off;
+   nzpresset4->aperiodicTriggeringOffset=NULL;
+   nzpresset4->trs_Info=calloc(1,sizeof(*nzpresset4->trs_Info));
+   *nzpresset4->trs_Info=NR_NZP_CSI_RS_ResourceSet__trs_Info_true;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpresset4);
+ }
+ if (n_physical_antenna_ports > 15) {
+   NR_NZP_CSI_RS_ResourceSet_t *nzpresset5=calloc(1,sizeof(*nzpresset5));
+   nzpresset5->nzp_CSI_ResourceSetId=5;
+   NR_NZP_CSI_RS_ResourceSetId_t *nzpresset50=calloc(1,sizeof(*nzpresset50));
+   *nzpresset50=10;
+   ASN_SEQUENCE_ADD(&nzpresset5->nzp_CSI_RS_Resources.list,nzpresset50);
+   NR_NZP_CSI_RS_ResourceSetId_t *nzpresset51=calloc(1,sizeof(*nzpresset51));
+   *nzpresset51=11;
+   ASN_SEQUENCE_ADD(&nzpresset5->nzp_CSI_RS_Resources.list,nzpresset51);
+   NR_NZP_CSI_RS_ResourceSetId_t *nzpresset52=calloc(1,sizeof(*nzpresset52));
+   *nzpresset52=12;
+   ASN_SEQUENCE_ADD(&nzpresset5->nzp_CSI_RS_Resources.list,nzpresset52);
+   NR_NZP_CSI_RS_ResourceSetId_t *nzpresset53=calloc(1,sizeof(*nzpresset53));
+   *nzpresset53=13;
+   ASN_SEQUENCE_ADD(&nzpresset5->nzp_CSI_RS_Resources.list,nzpresset53);
+   nzpresset5->repetition=calloc(1,sizeof(*nzpresset5->repetition));
+   *nzpresset5->repetition=NR_NZP_CSI_RS_ResourceSet__repetition_off;
+   nzpresset5->aperiodicTriggeringOffset=NULL;
+   nzpresset5->trs_Info=calloc(1,sizeof(*nzpresset5->trs_Info));
+   *nzpresset5->trs_Info=NR_NZP_CSI_RS_ResourceSet__trs_Info_true;
+   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpresset5);
+ }
+
+ csi_MeasConfig->csi_IM_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceToAddModList));
+ csi_MeasConfig->csi_IM_ResourceToReleaseList = NULL;
+ NR_CSI_IM_Resource_t *imres0 = calloc(1,sizeof(*imres0));
+ imres0->csi_IM_ResourceId=0;
+ imres0->csi_IM_ResourceElementPattern=calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern));
+ imres0->csi_IM_ResourceElementPattern->present = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern_PR_pattern1 ;
+ imres0->csi_IM_ResourceElementPattern->choice.pattern1=calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern->choice.pattern1));
+ imres0->csi_IM_ResourceElementPattern->choice.pattern1->subcarrierLocation_p1 = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern__pattern1__subcarrierLocation_p1_s4;
+ imres0->csi_IM_ResourceElementPattern->choice.pattern1->symbolLocation_p1=7;
+ imres0->freqBand=calloc(1,sizeof(*imres0->freqBand));
+ imres0->freqBand->startingRB=0;
+ imres0->freqBand->nrofRBs=106;
+ imres0->periodicityAndOffset=calloc(1,sizeof(*imres0->periodicityAndOffset));
+ imres0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320;
+ imres0->periodicityAndOffset->choice.slots320 = 2;
+ ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceToAddModList->list,imres0);
+ csi_MeasConfig->csi_IM_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceSetToAddModList));
+ csi_MeasConfig->csi_IM_ResourceSetToReleaseList = NULL;
+ NR_CSI_IM_ResourceSet_t *imresset0 = calloc(1,sizeof(*imresset0));
+ imresset0->csi_IM_ResourceSetId=0;
+ NR_CSI_IM_ResourceId_t *imresset00=calloc(1,sizeof(*imresset00));
+ *imresset00=0;
+ ASN_SEQUENCE_ADD(&imresset0->csi_IM_Resources.list,imresset00);
+ ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceSetToAddModList->list,imresset0);
+ 
+ csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList));
+ csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL;
+ NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0));
+ ssbresset0->csi_SSB_ResourceSetId=0; 
+ NR_SSB_Index_t *ssbresset00=calloc(1,sizeof(*ssbresset00));
+ *ssbresset00=0;
+ ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset00);
+ if (n_physical_antenna_ports > 1) {
+   NR_SSB_Index_t *ssbresset01=calloc(1,sizeof(*ssbresset01));
+   *ssbresset01=1;
+   ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset01);
+ }
+ if (n_physical_antenna_ports > 3) {
+   NR_SSB_Index_t *ssbresset02=calloc(1,sizeof(*ssbresset02));
+   *ssbresset02=2;
+   ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset02);
+   NR_SSB_Index_t *ssbresset03=calloc(1,sizeof(*ssbresset03));
+   *ssbresset03=3;
+   ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset03);
+ }
+ if (n_physical_antenna_ports > 7) {
+   NR_SSB_Index_t *ssbresset04=calloc(1,sizeof(*ssbresset04));
+   *ssbresset04=4;
+   ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset04);
+   NR_SSB_Index_t *ssbresset05=calloc(1,sizeof(*ssbresset05));
+   *ssbresset05=5;
+   ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset05);
+   NR_SSB_Index_t *ssbresset06=calloc(1,sizeof(*ssbresset06));
+   *ssbresset06=6;
+   ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset06);
+   NR_SSB_Index_t *ssbresset07=calloc(1,sizeof(*ssbresset07));
+   *ssbresset07=7;
+   ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset07);
+ }
+ ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0);
+
+ csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList));
+ csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL;
+ NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0));
+ csires0->csi_ResourceConfigId=0;
+ csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
+ csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
+ csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
+ csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
+ NR_NZP_CSI_RS_ResourceSetId_t *csires00 = calloc(1,sizeof(*csires00));
+ *csires00 = 0;
+ ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires00);
+ csires0->bwp_Id = 1;
+ csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
+ ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0);
+
+ NR_CSI_ResourceConfig_t *csires11 = calloc(1,sizeof(*csires11));
+ csires11->csi_ResourceConfigId=11;
+ csires11->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList;
+ csires11->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList = calloc(1,sizeof(*csires11->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList));
+ NR_NZP_CSI_RS_ResourceSetId_t *csires110 = calloc(1,sizeof(*csires110));
+ *csires110 = 0;
+ ASN_SEQUENCE_ADD(&csires11->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csires110);
+ csires11->bwp_Id = 1;
+ csires11->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
+ //ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires11);
+
+ NR_CSI_ResourceConfig_t *csires10 = calloc(1,sizeof(*csires10));
+ csires10->csi_ResourceConfigId=10;
+ csires10->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
+ csires10->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires10->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
+ csires10->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires10->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
+ csires10->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
+ NR_NZP_CSI_RS_ResourceSetId_t *csires100 = calloc(1,sizeof(*csires100));
+ *csires100 = 0;
+ ASN_SEQUENCE_ADD(&csires10->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires100);
+ csires10->bwp_Id = 1;
+ csires10->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
+ //ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires10);
+
+ NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2));
+ csires2->csi_ResourceConfigId=2;
+ csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
+ csires2->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
+ csires2->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
+ csires2->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
+ NR_NZP_CSI_RS_ResourceSetId_t *csires20 = calloc(1,sizeof(*csires20));
+ *csires20 = 0;
+ ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires20);
+ csires2->bwp_Id = 1;
+ csires2->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
+ //ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires2);
+
+ NR_CSI_ResourceConfig_t *csires3 = calloc(1,sizeof(*csires3));
+ csires3->csi_ResourceConfigId=3;
+ csires3->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
+ csires3->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires3->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
+ csires3->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires3->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
+ csires3->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
+ NR_NZP_CSI_RS_ResourceSetId_t *csires30 = calloc(1,sizeof(*csires30));
+ *csires30 = 0;
+ ASN_SEQUENCE_ADD(&csires3->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires30);
+ csires3->bwp_Id = 1;
+ csires3->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
+ //ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires3);
+
+ NR_CSI_ResourceConfig_t *csires4 = calloc(1,sizeof(*csires4));
+ csires4->csi_ResourceConfigId=4;
+ csires4->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
+ csires4->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires4->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
+ csires4->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires4->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
+ csires4->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
+ NR_NZP_CSI_RS_ResourceSetId_t *csires40 = calloc(1,sizeof(*csires40));
+ *csires40 = 0;
+ ASN_SEQUENCE_ADD(&csires4->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires40);
+ csires4->bwp_Id = 1;
+ csires4->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
+ //ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires4);
+
+ NR_CSI_ResourceConfig_t *csires5 = calloc(1,sizeof(*csires5));
+ csires5->csi_ResourceConfigId=5;
+ csires5->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
+ csires5->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires5->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
+ csires5->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires5->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
+ csires5->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
+ NR_NZP_CSI_RS_ResourceSetId_t *csires50 = calloc(1,sizeof(*csires50));
+ *csires50 = 0;
+ ASN_SEQUENCE_ADD(&csires5->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires50);
+ csires5->bwp_Id = 1;
+ csires5->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
+ //ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires5);
+
+ NR_CSI_ResourceConfig_t *csires6 = calloc(1,sizeof(*csires6));
+ csires6->csi_ResourceConfigId=6;
+ csires6->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
+ csires6->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires6->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
+ csires6->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires6->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
+ csires6->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
+ NR_NZP_CSI_RS_ResourceSetId_t *csires60 = calloc(1,sizeof(*csires60));
+ *csires60 = 0;
+ ASN_SEQUENCE_ADD(&csires6->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires60);
+ csires6->bwp_Id = 1;
+ csires6->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
+ //ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires6);
+
+ NR_CSI_ResourceConfig_t *csires7 = calloc(1,sizeof(*csires7));
+ csires7->csi_ResourceConfigId=7;
+ csires7->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
+ csires7->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires7->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
+ csires7->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires7->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
+ csires7->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
+ NR_NZP_CSI_RS_ResourceSetId_t *csires70 = calloc(1,sizeof(*csires70));
+ *csires70 = 0;
+ ASN_SEQUENCE_ADD(&csires7->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires70);
+ csires7->bwp_Id = 1;
+ csires7->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
+ //ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires7);
+
+ NR_CSI_ResourceConfig_t *csires8 = calloc(1,sizeof(*csires8));
+ csires8->csi_ResourceConfigId=8;
+ csires8->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
+ csires8->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires8->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
+ csires8->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires8->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
+ csires8->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
+ NR_NZP_CSI_RS_ResourceSetId_t *csires80 = calloc(1,sizeof(*csires80));
+ *csires80 = 0;
+ ASN_SEQUENCE_ADD(&csires8->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires80);
+ csires8->bwp_Id = 1;
+ csires8->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
+ //ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires8);
+
+ NR_CSI_ResourceConfig_t *csires9 = calloc(1,sizeof(*csires9));
+ csires9->csi_ResourceConfigId=9;
+ csires9->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
+ csires9->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires9->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
+ csires9->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires9->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
+ csires9->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = NULL;
+ NR_NZP_CSI_RS_ResourceSetId_t *csires90 = calloc(1,sizeof(*csires90));
+ *csires90 = 0;
+ ASN_SEQUENCE_ADD(&csires9->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,csires90);
+ csires9->bwp_Id = 1; 
+ csires9->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
+ //ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires9);
+
+ csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList));
+ csi_MeasConfig->csi_ReportConfigToReleaseList = NULL;
+ NR_CSI_ReportConfig_t *csirep0 = calloc(1,sizeof(*csirep0));
+ csirep0->reportConfigId=0;
+ csirep0->carrier=NULL;
+ csirep0->resourcesForChannelMeasurement=0;
+ csirep0->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep0->csi_IM_ResourcesForInterference));
+ *csirep0->csi_IM_ResourcesForInterference=11;
+ csirep0->nzp_CSI_RS_ResourcesForInterference=NULL;
+ csirep0->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic;
+ csirep0->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep0->reportConfigType.choice.periodic));
+ csirep0->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320;
+ csirep0->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 9;
+
+ NR_PUCCH_CSI_Resource_t *pucchcsires0 = calloc(1,sizeof(*pucchcsires0));
+ pucchcsires0->uplinkBandwidthPartId=1;
+ pucchcsires0->pucch_Resource=11;
+ ASN_SEQUENCE_ADD(&csirep0->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires0);
+ csirep0->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_LI_PMI_CQI;
+ csirep0->reportQuantity.choice.cri_RI_PMI_CQI = (NULL_t)0;
+ csirep0->reportFreqConfiguration = calloc(1,sizeof(*csirep0->reportFreqConfiguration));
+ csirep0->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI;
+ csirep0->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI;
+ csirep0->reportFreqConfiguration->csi_ReportingBand=calloc(1,sizeof(*csirep0->reportFreqConfiguration->csi_ReportingBand));
+ 
+ 
+ AssertFatal(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id>0,"firstActiveDownlinkBWP_Id %d\n",(int)*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id);
+ int NPRB  = NRRIV2BW(secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id-1]->bwp_Common->genericParameters.locationAndBandwidth,275);
+ int sbsize = get_subband_size(NPRB,0);
+ int numsb = NPRB/sbsize;
+ if (NPRB%sbsize == 0) numsb++;
+ csirep0->reportFreqConfiguration->csi_ReportingBand->present= 	NR_CSI_ReportConfig__reportFreqConfiguration__csi_ReportingBand_PR_NOTHING+(numsb-2);
+ csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.size=numsb/8;
+ if ((numsb&7) > 0) csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.size++;
+ csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.bits_unused = (8-(numsb&7))&7;
+ csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.buf=malloc(csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.size);
+ for (int i=0;i<csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.size;i++) 
+   csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.buf[i]=0xff;
+ csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.buf[csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.size-1]&=~((1<<csirep0->reportFreqConfiguration->csi_ReportingBand->choice.subbands18.bits_unused)-1);
+
+ csirep0->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured;
+ csirep0->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured;
+ csirep0->codebookConfig=calloc(1,sizeof(*csirep0->codebookConfig));
+ csirep0->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1;
+ csirep0->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep0->codebookConfig->codebookType.choice.type1));
+ csirep0->codebookConfig->codebookType.choice.type1->subType.present = NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel; 
+ csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel));
+ csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present=NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two;
+ csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two=
+   calloc(1,sizeof(*csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two));
+ csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1;
+ csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2;
+ csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1);
+ csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc;
+ //'111111'B
+
+
+ csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; 
+ csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0;
+ csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); 
+ csirep0->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0xc0; //'00000011'B
+
+ csirep0->codebookConfig->codebookType.choice.type1->codebookMode=1;
+ csirep0->dummy = NULL;
+ csirep0->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled;
+ csirep0->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep0->groupBasedBeamReporting.choice.disabled));
+ csirep0->groupBasedBeamReporting.choice.disabled->nrofReportedRS = NULL;
+ csirep0->cqi_Table = calloc(1,sizeof(*csirep0->cqi_Table));
+ *csirep0->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1;
+ csirep0->subbandSize = NR_CSI_ReportConfig__subbandSize_value1;
+ csirep0->non_PMI_PortIndication = NULL;
+ csirep0->ext1 = NULL;
+
+ ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep0);
+
+ NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1));
+ csirep1->reportConfigId=2;
+ csirep1->carrier=NULL;
+ csirep1->resourcesForChannelMeasurement=initial_csi_index;
+ csirep1->csi_IM_ResourcesForInterference=NULL;
+ csirep1->nzp_CSI_RS_ResourcesForInterference=NULL;
+ csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic;
+ csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic));
+ csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320;
+ csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 49;
+ NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1));
+ pucchcsires1->uplinkBandwidthPartId=1;
+ pucchcsires1->pucch_Resource=12;
+ ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1);
+ csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP;
+ csirep1->reportQuantity.choice.ssb_Index_RSRP=(NULL_t)0;
+ csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration));
+ csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI;
+ csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI;
+ csirep1->reportFreqConfiguration->csi_ReportingBand=NULL;
+ csirep1->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured;
+ csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured;
+ csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig));
+ csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1;
+ csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1));
+ csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel;
+ csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel));
+ csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present=NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two;
+ csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two=
+   calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two));
+ csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1;
+ csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2;
+ csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1);
+ csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc;
+ //'111111'B
+
+
+ csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1; 
+ csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0;
+ csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1); 
+ csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0xc0; //'00000011'B
+
+ csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1;
+ csirep1->dummy = NULL;
+ csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled;
+ csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled));
+ csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS));
+ *csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n2;
+ // this corresponds to:
+ //if the UE is configured with the higher layer parameter groupBasedBeamReporting set to 'disabled', the UE is not required to update measurements for more than 64 CSI-RS and/or SSB resources, and the UE shall report in a single report nrofReportedRS (higher layer configured) different CRI or SSBRI for each report setting. 
+
+ csirep1->cqi_Table = calloc(1,sizeof(*csirep1->cqi_Table));
+ *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1;
+ csirep1->subbandSize = NR_CSI_ReportConfig__subbandSize_value1;
+ csirep1->non_PMI_PortIndication = NULL;
+ csirep1->ext1 = NULL;
+
+ ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep1);
+
+
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->sCellDeactivationTimer=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->tag_Id=0;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->dummy=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->pathlossReferenceLinking=NULL;
+ secondaryCellGroup->spCellConfig->spCellConfigDedicated->servingCellMO=NULL;
+
 }
 void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon,
                            NR_RRCReconfiguration_IEs_t *reconfig,
@@ -1902,8 +2008,9 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon
   // radioBearerConfig
   reconfig->radioBearerConfig=NULL;
   // secondaryCellGroup
-  fill_default_secondaryCellGroup(servingcellconfigcommon,secondaryCellGroup,0,0,n_physical_antenna_ports,initial_csi_index);
-  xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void *)secondaryCellGroup);
+  fill_default_secondaryCellGroup(servingcellconfigcommon,secondaryCellGroup,1,1,n_physical_antenna_ports,initial_csi_index);
+  xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup);
+
   char scg_buffer[1024];
   asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, (void *)secondaryCellGroup, scg_buffer, 1024);
   AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", enc_rval.failed_type->name, enc_rval.encoded);
diff --git a/openair2/X2AP/x2ap_eNB_decoder.c b/openair2/X2AP/x2ap_eNB_decoder.c
index 93b82c2765fb985c414557f11cdd0f3edec76034..3762bc06dcc6bcdddcd1247d197ae57f753e2317 100644
--- a/openair2/X2AP/x2ap_eNB_decoder.c
+++ b/openair2/X2AP/x2ap_eNB_decoder.c
@@ -144,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_handler.c b/openair2/X2AP/x2ap_eNB_handler.c
index 87ef5bf69f1953c305aae170daa1029488e1963e..1c6c98cd81ec27dd43321de86f6058d7bd88fe3f 100644
--- a/openair2/X2AP/x2ap_eNB_handler.c
+++ b/openair2/X2AP/x2ap_eNB_handler.c
@@ -1768,8 +1768,7 @@ LOG_I(RRC,"x2u tunnel: index %d target sgw ip %d.%d.%d.%d length %d gtp teid %u\
   X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_SgNBAdditionRequest_IEs_t, ie, x2SgNBAdditionRequest,
 		  X2AP_ProtocolIE_ID_id_MeNBtoSgNBContainer, true);
 
-
-  if (ie->value.choice.MeNBtoSgNBContainer.size > 8192 )
+  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);
diff --git a/openair3/S1AP/s1ap_eNB_encoder.c b/openair3/S1AP/s1ap_eNB_encoder.c
index 86536ac52549e296837ee59a761d0348e9a77814..227a3cb6a991d9ecc3f3211818f189b50a955ecb 100644
--- a/openair3/S1AP/s1ap_eNB_encoder.c
+++ b/openair3/S1AP/s1ap_eNB_encoder.c
@@ -129,9 +129,9 @@ int s1ap_eNB_encode_initiating(S1AP_S1AP_PDU_t *pdu,
       return -1;
   }
 
-  //if (asn1_xer_print) {
+  if (asn1_xer_print) {
     xer_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, (void *)pdu);
-  //}
+  }
 
   memset(&res, 0, sizeof(res));
   res = asn_encode_to_new_buffer(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_S1AP_S1AP_PDU, pdu);
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_enb.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_enb.conf
new file mode 100644
index 0000000000000000000000000000000000000000..ea105d86b62abdd255804e375323f0eda99d1a14
--- /dev/null
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_enb.conf
@@ -0,0 +1,281 @@
+Active_eNBs = ( "eNB-Eurecom-LTEBox");
+# Asn1_verbosity, choice in: none, info, annoying
+Asn1_verbosity = "none";
+
+eNBs =
+(
+ {
+    # real_time choice in {hard, rt-preempt, no}
+    real_time       =  "no";
+    ////////// Identification parameters:
+    eNB_ID    =  0xe01;
+    
+    cell_type =  "CELL_MACRO_ENB";
+    
+    eNB_name  =  "eNB-Eurecom-LTEBox";
+    
+    // Tracking area code, 0x0000 and 0xfffe are reserved values
+    tracking_area_code  =  1;
+    plmn_list = (
+      { mcc = 222; mnc = 01; mnc_length = 2; }
+    );
+    
+    tr_s_preference     = "local_mac"
+
+       ////////// Physical parameters:
+  
+    component_carriers = (
+    		       	 {
+                           node_function = "eNodeB_3GPP";
+                           node_timing = "synch_to_ext_device";
+                           node_synch_ref = 0;
+                           nb_antenna_ports = 1;
+                           ue_TransmissionMode = 1;
+  			   frame_type					      = "FDD";	
+                           tdd_config 					      = 3;
+                           tdd_config_s            			      = 0;
+ 			   prefix_type             			      = "NORMAL";
+  			   eutra_band              			      = 7;
+                           downlink_frequency      			      = 2680000000L; //2655000000L;
+                           uplink_frequency_offset 			      = -120000000;
+  
+  			   Nid_cell					      = 0;
+                           N_RB_DL                 			      = 25; //100;
+                           Nid_cell_mbsfn          			      = 0;
+                           nb_antennas_tx          			      = 1;
+                           nb_antennas_rx          			      = 1; 
+                           prach_root              			      = 0;
+			   tx_gain                                            = 90;
+			   rx_gain                                            = 115;
+                           pbch_repetition                                    = "FALSE";
+                           prach_config_index      			      = 0;
+                           prach_high_speed        			      = "DISABLE";
+  	                   prach_zero_correlation  			      = 1;
+                           prach_freq_offset       			      = 2;
+			   pucch_delta_shift       			      = 1;
+                           pucch_nRB_CQI           			      = 0;
+                           pucch_nCS_AN            			      = 0;
+                           pucch_n1_AN             			      = 0;
+                           pdsch_referenceSignalPower 			      = -29;
+                           pdsch_p_b                  			      = 0;
+                           pusch_n_SB                 			      = 1; 
+                           pusch_enable64QAM          			      = "DISABLE";
+			   pusch_hoppingMode                                  = "interSubFrame";
+			   pusch_hoppingOffset                                = 0;
+     	                   pusch_groupHoppingEnabled  			      = "ENABLE";
+	                   pusch_groupAssignment      			      = 0;
+	                   pusch_sequenceHoppingEnabled		   	      = "DISABLE";
+	                   pusch_nDMRS1                                       = 1;
+	                   phich_duration                                     = "NORMAL";
+	                   phich_resource                                     = "ONESIXTH";
+	                   srs_enable                                         = "DISABLE";
+	               /*  srs_BandwidthConfig                                =;
+	                   srs_SubframeConfig                                 =;
+	                   srs_ackNackST                                      =;
+	                   srs_MaxUpPts                                       =;*/  
+
+	                   pusch_p0_Nominal                                   = -96;
+	                   pusch_alpha                                        = "AL1";
+	                   pucch_p0_Nominal                                   = -96;
+	                   msg3_delta_Preamble                                = 6;
+	                   pucch_deltaF_Format1                               = "deltaF2";
+	                   pucch_deltaF_Format1b                              = "deltaF3";
+	                   pucch_deltaF_Format2                               = "deltaF0";
+	                   pucch_deltaF_Format2a                              = "deltaF0";
+  	                   pucch_deltaF_Format2b		    	      = "deltaF0";
+	
+                           rach_numberOfRA_Preambles                          = 64;
+                           rach_preamblesGroupAConfig                         = "DISABLE";
+/*
+                           rach_sizeOfRA_PreamblesGroupA                      = ;
+                           rach_messageSizeGroupA                             = ;
+                           rach_messagePowerOffsetGroupB                      = ; 
+*/
+                           rach_powerRampingStep                              = 4;
+	                   rach_preambleInitialReceivedTargetPower            = -108;
+                           rach_preambleTransMax                              = 10;
+	                   rach_raResponseWindowSize                          = 10;
+	                   rach_macContentionResolutionTimer                  = 48;
+	                   rach_maxHARQ_Msg3Tx                                = 4;
+
+			   pcch_default_PagingCycle                           = 128;
+			   pcch_nB                                            = "oneT";
+			   bcch_modificationPeriodCoeff			      = 2;
+			   ue_TimersAndConstants_t300			      = 1000;
+			   ue_TimersAndConstants_t301			      = 1000;
+			   ue_TimersAndConstants_t310			      = 1000;
+			   ue_TimersAndConstants_t311			      = 10000;
+			   ue_TimersAndConstants_n310			      = 20;
+			   ue_TimersAndConstants_n311			      = 1;
+
+      //Parameters for SIB18
+      rxPool_sc_CP_Len                                       = "normal"; 
+      rxPool_sc_Period                                       = "sf40";  
+      rxPool_data_CP_Len                                     = "normal";  
+      rxPool_ResourceConfig_prb_Num                          = 20;
+      rxPool_ResourceConfig_prb_Start                        = 5;
+      rxPool_ResourceConfig_prb_End                          = 44;
+      rxPool_ResourceConfig_offsetIndicator_present          = "prSmall";
+      rxPool_ResourceConfig_offsetIndicator_choice           = 0;      
+      rxPool_ResourceConfig_subframeBitmap_present           = "prBs40";
+      rxPool_ResourceConfig_subframeBitmap_choice_bs_buf              = "00000000000000000000";
+      rxPool_ResourceConfig_subframeBitmap_choice_bs_size             = 5;
+      rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused      = 0;
+/*    rxPool_dataHoppingConfig_hoppingParameter                       = 0;
+      rxPool_dataHoppingConfig_numSubbands                            = "ns1";
+      rxPool_dataHoppingConfig_rbOffset                               = 0;
+      rxPool_commTxResourceUC-ReqAllowed                              = "TRUE";
+*/    
+      // Parameters for SIB19
+      discRxPool_cp_Len                                               = "normal"
+      discRxPool_discPeriod                                           = "rf32"
+      discRxPool_numRetx                                              = 1;   
+      discRxPool_numRepetition                                        = 2;
+      discRxPool_ResourceConfig_prb_Num                               = 5;  
+      discRxPool_ResourceConfig_prb_Start                             = 3;
+      discRxPool_ResourceConfig_prb_End                               = 21;
+      discRxPool_ResourceConfig_offsetIndicator_present               = "prSmall";
+      discRxPool_ResourceConfig_offsetIndicator_choice                = 0;      
+      discRxPool_ResourceConfig_subframeBitmap_present                = "prBs40";
+      discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf          = "f0ffffffff";
+      discRxPool_ResourceConfig_subframeBitmap_choice_bs_size         = 5;
+      discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused  = 0;
+
+			 }
+			 );
+
+    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;
+    };
+
+    enable_measurement_reports = "yes";
+
+    ////////// MME parameters:
+    mme_ip_address      = ( { ipv4       = "192.168.18.99";
+                              ipv6       = "192:168:30::17";
+                              active     = "yes";
+                              preference = "ipv4";
+                            }
+                          );
+
+    ///X2
+    enable_x2 = "yes";
+    t_reloc_prep      = 1000;      /* unit: millisecond */
+    tx2_reloc_overall = 2000;      /* unit: millisecond */
+
+    NETWORK_INTERFACES : 
+    {
+        ENB_INTERFACE_NAME_FOR_S1_MME            = "eth1";
+        ENB_IPV4_ADDRESS_FOR_S1_MME              = "192.168.18.199/24";
+
+        ENB_INTERFACE_NAME_FOR_S1U               = "eth1";
+        ENB_IPV4_ADDRESS_FOR_S1U                 = "192.168.18.199/24";
+        ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
+
+        ENB_IPV4_ADDRESS_FOR_X2C                 = "192.168.18.199/24";
+        ENB_PORT_FOR_X2C                         = 36422; # Spec 36422
+    };
+    
+    log_config : 
+    {
+	global_log_level                      ="info"; 
+    	global_log_verbosity                  ="high";
+	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                         ="debug"; 
+    	rlc_log_verbosity                     ="high";
+	pdcp_log_level                        ="info"; 
+    	pdcp_log_verbosity                    ="high";
+	rrc_log_level                         ="info"; 
+    	rrc_log_verbosity                     ="medium";
+   };	
+   
+  }
+);
+
+MACRLCs = (
+        {
+        num_cc = 1;
+        tr_s_preference = "local_L1";
+        tr_n_preference = "local_RRC";
+        phy_test_mode = 0;
+        puSch10xSnr     =  160;
+        puCch10xSnr     =  160;
+        }  
+);
+
+THREAD_STRUCT = (
+  {
+    parallel_config = "PARALLEL_RU_L1_TRX_SPLITaaaaaa";
+    worker_config = "ENABLE";
+  }
+);
+
+L1s = (
+        {
+        num_cc = 1;
+        tr_n_preference = "local_mac";
+        }  
+);
+
+RUs = (
+    {             
+       local_rf       = "yes"
+         nb_tx          = 1
+         nb_rx          = 1
+         att_tx         = 0
+         att_rx         = 0;
+         bands          = [7];
+         max_pdschReferenceSignalPower = -27;
+         max_rxgain                    = 118;
+         eNB_instances  = [0];
+         clock_src = "external";
+    }
+);  
+
+    log_config : 
+    {
+	global_log_level                      ="info"; 
+    	global_log_verbosity                  ="high";
+	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                     ="high";
+	pdcp_log_level                        ="info"; 
+    	pdcp_log_verbosity                    ="high";
+	rrc_log_level                         ="info"; 
+    	rrc_log_verbosity                     ="medium";
+   };	
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf
new file mode 100644
index 0000000000000000000000000000000000000000..b63939add2be238eeee83d1d0f710a793e30ba2b
--- /dev/null
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf
@@ -0,0 +1,293 @@
+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 = 222; mnc = 01; mnc_length = 2;});	 
+
+    tr_s_preference     = "local_mac"
+
+    ////////// Physical parameters:
+
+    ssb_SubcarrierOffset                                      = 31; //0;
+    pdsch_AntennaPorts                                        = 1;
+	
+    servingCellConfigCommon = (
+    {
+ #spCellConfigCommon
+
+      physCellId                                                    = 0;
+
+#  downlinkConfigCommon
+    #frequencyInfoDL
+      # this is 3600 MHz + 84 PRBs@30kHz SCS (same as initial BWP)
+      absoluteFrequencySSB                                          = 641272; //641032;      #641968; 641968=start of ssb at 3600MHz + 82 RBs    641032=center of SSB at center of cell
+      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=84,L=13 (275*(L-1))+RBstart
+        initialDLBWPlocationAndBandwidth                                        = 6366; //28875; //6366; #6407; #3384;
+# subcarrierSpacing
+# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120  
+        initialDLBWPsubcarrierSpacing                                           = 1;
+      #pdcch-ConfigCommon
+        initialDLBWPcontrolResourceSetZero                                      = 0;
+        initialDLBWPsearchSpaceZero                                             = 0;
+      #pdsch-ConfigCommon
+        #pdschTimeDomainAllocationList (up to 16 entries)
+             initialDLBWPk0_0                    = 0;
+             #initialULBWPmappingType
+	     #0=typeA,1=typeB
+             initialDLBWPmappingType_0           = 0;
+             #this is SS=1,L=13
+             initialDLBWPstartSymbolAndLength_0  = 40;
+
+             initialDLBWPk0_1                    = 0;
+             initialDLBWPmappingType_1           = 0;
+             #this is SS=2,L=12 
+             initialDLBWPstartSymbolAndLength_1  = 53;
+
+             initialDLBWPk0_2                    = 0;
+             initialDLBWPmappingType_2           = 0;
+             #this is SS=1,L=12 
+             initialDLBWPstartSymbolAndLength_2  = 54;
+
+             initialDLBWPk0_3                    = 0;
+             initialDLBWPmappingType_3           = 0;
+             #this is SS=1,L=4 //5 (4 is for 43, 5 is for 57)
+             initialDLBWPstartSymbolAndLength_3  = 57; //43; //57;
+  #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                                        = 6366; //28875; //6366; #6407; #3384;
+# 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                               = -100;
+#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                                           = 5;
+#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR
+#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR                = 4;
+#oneHalf (0..15) 4,8,12,16,...60,64
+        ssb_perRACH_OccasionAndCB_PreamblesPerSSB                   = 14; //15;
+#ra_ContentionResolutionTimer
+#(0..7) 8,16,24,32,40,48,56,64
+        ra_ContentionResolutionTimer                                = 7;
+        rsrp_ThresholdSSB                                           = 19;
+#prach-RootSequenceIndex_PR
+#1 = 839, 2 = 139
+        prach_RootSequenceIndex_PR                                  = 2;
+        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;
+
+        initialULBWPk2_2                      = 7;
+        initialULBWPmappingType_2             = 1;
+        # this is SS=10 L=4
+        initialULBWPstartSymbolAndLength_2    = 52;
+
+        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; #0x80;
+
+# 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; //8; //7;
+      nrofDownlinkSymbols                                           = 6; //0; //6;
+      nrofUplinkSlots                                               = 2;
+      nrofUplinkSymbols                                             = 4; //0; //4;
+
+  ssPBCH_BlockPower                                             = -25;
+  }
+
+  );
+
+
+    # ------- 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.18.99";
+                              ipv6       = "192:168:30::17";
+                              active     = "yes";
+                              preference = "ipv4";
+                            }
+                          );
+
+    ///X2
+    enable_x2 = "yes";
+    t_reloc_prep      = 1000;      /* unit: millisecond */
+    tx2_reloc_overall = 2000;      /* unit: millisecond */
+    target_enb_x2_ip_address      = (
+                                     { ipv4       = "192.168.18.199";
+                                       ipv6       = "192:168:30::17";
+                                       preference = "ipv4";
+                                     }
+                                    );
+
+    NETWORK_INTERFACES :
+    {
+
+        GNB_INTERFACE_NAME_FOR_S1_MME            = "eth0";
+        GNB_IPV4_ADDRESS_FOR_S1_MME              = "192.168.18.198/24";
+        GNB_INTERFACE_NAME_FOR_S1U               = "eth0";
+        GNB_IPV4_ADDRESS_FOR_S1U                 = "192.168.18.198/24";
+        GNB_PORT_FOR_S1U                         = 2152; # Spec 2152
+        GNB_IPV4_ADDRESS_FOR_X2C                 = "192.168.18.198/24";
+        GNB_PORT_FOR_X2C                         = 36422; # Spec 36422
+    };
+  }
+);
+
+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          = 1
+         nb_rx          = 1
+         att_tx         = 0
+         att_rx         = 0;
+         bands          = [7];
+         max_pdschReferenceSignalPower = -27;
+         max_rxgain                    = 114;
+         eNB_instances  = [0];
+         clock_src = "external";
+    }
+);  
+
+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";
+    parallel_config    = "PARALLEL_SINGLE_THREAD";
+    #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";
+    };
+