diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index 9fcb586e0949f0a75ebe3abbaa32154c2e76a3b3..3c635bb191372721f3c6182d7dd88ca34ce7793b 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -1547,6 +1547,7 @@ set(PHY_SRC_UE
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_dmrs_rx.c
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold.c
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/scrambling_luts.c
+  ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gen_mod_table.c
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/dmrs_nr.c
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/ptrs_nr.c
   ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/filt16a_32.c
@@ -1599,6 +1600,7 @@ set(PHY_SRC_UE
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/dmrs_nr.c
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/ptrs_nr.c
   ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gold_ue.c
+  ${OPENAIR1_DIR}/PHY/NR_REFSIG/nr_gen_mod_table.c
   ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/filt16a_32.c
   ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
   ${OPENAIR1_DIR}/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c
diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c
index ab10313c1a6c3cc8e60b3918438fd7607e205ccf..a3d0b325d67211d38d0bd1054857d7ac06648635 100644
--- a/executables/nr-softmodem.c
+++ b/executables/nr-softmodem.c
@@ -84,9 +84,6 @@ unsigned short config_frames[4] = {2,9,11,13};
 #include "NB_IoT_interface.h"
 #include "x2ap_eNB.h"
 
-short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT] = {0,0,16384,16384,-16384,-16384,16384,16384,16384,-16384,-16384,16384,-16384,-16384,7327,7327,7327,21981,21981,7327,21981,21981,7327,-7327,7327,-21981,21981,-7327,21981,-21981,-7327,7327,-7327,21981,-21981,7327,-21981,21981,-7327,-7327,-7327,-21981,-21981,-7327,-21981,-21981,10726,10726,10726,3576,3576,10726,3576,3576,10726,17876,10726,25027,3576,17876,3576,25027,17876,10726,17876,3576,25027,10726,25027,3576,17876,17876,17876,25027,25027,17876,25027,25027,10726,-10726,10726,-3576,3576,-10726,3576,-3576,10726,-17876,10726,-25027,3576,-17876,3576,-25027,17876,-10726,17876,-3576,25027,-10726,25027,-3576,17876,-17876,17876,-25027,25027,-17876,25027,-25027,-10726,10726,-10726,3576,-3576,10726,-3576,3576,-10726,17876,-10726,25027,-3576,17876,-3576,25027,-17876,10726,-17876,3576,-25027,10726,-25027,3576,-17876,17876,-17876,25027,-25027,17876,-25027,25027,-10726,-10726,-10726,-3576,-3576,-10726,-3576,-3576,-10726,-17876,-10726,-25027,-3576,-17876,-3576,-25027,-17876,-10726,-17876,-3576,-25027,-10726,-25027,-3576,-17876,-17876,-17876,-25027,-25027,-17876,-25027,-25027,8886,8886,8886,12439,12439,8886,12439,12439,8886,5332,8886,1778,12439,5332,12439,1778,5332,8886,5332,12439,1778,8886,1778,12439,5332,5332,5332,1778,1778,5332,1778,1778,8886,19547,8886,15993,12439,19547,12439,15993,8886,23101,8886,26655,12439,23101,12439,26655,5332,19547,5332,15993,1778,19547,1778,15993,5332,23101,5332,26655,1778,23101,1778,26655,19547,8886,19547,12439,15993,8886,15993,12439,19547,5332,19547,1778,15993,5332,15993,1778,23101,8886,23101,12439,26655,8886,26655,12439,23101,5332,23101,1778,26655,5332,26655,1778,19547,19547,19547,15993,15993,19547,15993,15993,19547,23101,19547,26655,15993,23101,15993,26655,23101,19547,23101,15993,26655,19547,26655,15993,23101,23101,23101,26655,26655,23101,26655,26655,8886,-8886,8886,-12439,12439,-8886,12439,-12439,8886,-5332,8886,-1778,12439,-5332,12439,-1778,5332,-8886,5332,-12439,1778,-8886,1778,-12439,5332,-5332,5332,-1778,1778,-5332,1778,-1778,8886,-19547,8886,-15993,12439,-19547,12439,-15993,8886,-23101,8886,-26655,12439,-23101,12439,-26655,5332,-19547,5332,-15993,1778,-19547,1778,-15993,5332,-23101,5332,-26655,1778,-23101,1778,-26655,19547,-8886,19547,-12439,15993,-8886,15993,-12439,19547,-5332,19547,-1778,15993,-5332,15993,-1778,23101,-8886,23101,-12439,26655,-8886,26655,-12439,23101,-5332,23101,-1778,26655,-5332,26655,-1778,19547,-19547,19547,-15993,15993,-19547,15993,-15993,19547,-23101,19547,-26655,15993,-23101,15993,-26655,23101,-19547,23101,-15993,26655,-19547,26655,-15993,23101,-23101,23101,-26655,26655,-23101,26655,-26655,-8886,8886,-8886,12439,-12439,8886,-12439,12439,-8886,5332,-8886,1778,-12439,5332,-12439,1778,-5332,8886,-5332,12439,-1778,8886,-1778,12439,-5332,5332,-5332,1778,-1778,5332,-1778,1778,-8886,19547,-8886,15993,-12439,19547,-12439,15993,-8886,23101,-8886,26655,-12439,23101,-12439,26655,-5332,19547,-5332,15993,-1778,19547,-1778,15993,-5332,23101,-5332,26655,-1778,23101,-1778,26655,-19547,8886,-19547,12439,-15993,8886,-15993,12439,-19547,5332,-19547,1778,-15993,5332,-15993,1778,-23101,8886,-23101,12439,-26655,8886,-26655,12439,-23101,5332,-23101,1778,-26655,5332,-26655,1778,-19547,19547,-19547,15993,-15993,19547,-15993,15993,-19547,23101,-19547,26655,-15993,23101,-15993,26655,-23101,19547,-23101,15993,-26655,19547,-26655,15993,-23101,23101,-23101,26655,-26655,23101,-26655,26655,-8886,-8886,-8886,-12439,-12439,-8886,-12439,-12439,-8886,-5332,-8886,-1778,-12439,-5332,-12439,-1778,-5332,-8886,-5332,-12439,-1778,-8886,-1778,-12439,-5332,-5332,-5332,-1778,-1778,-5332,-1778,-1778,-8886,-19547,-8886,-15993,-12439,-19547,-12439,-15993,-8886,-23101,-8886,-26655,-12439,-23101,-12439,-26655,-5332,-19547,-5332,-15993,-1778,-19547,-1778,-15993,-5332,-23101,-5332,-26655,-1778,-23101,-1778,-26655,-19547,-8886,-19547,-12439,-15993,-8886,-15993,-12439,-19547,-5332,-19547,-1778,-15993,-5332,-15993,-1778,-23101,-8886,-23101,-12439,-26655,-8886,-26655,-12439,-23101,-5332,-23101,-1778,-26655,-5332,-26655,-1778,-19547,-19547,-19547,-15993,-15993,-19547,-15993,-15993,-19547,-23101,-19547,-26655,-15993,-23101,-15993,-26655,-23101,-19547,-23101,-15993,-26655,-19547,-26655,-15993,-23101,-23101,-23101,-26655,-26655,-23101,-26655,-26655};
-
-
 pthread_cond_t nfapi_sync_cond;
 pthread_mutex_t nfapi_sync_mutex;
 int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex
diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c
index fa816b506c0b3d5111b225068487c30a9f29834e..2fbea2bbfb40a1376f1a26cb1aa9e4d431859bf0 100644
--- a/executables/nr-uesoftmodem.c
+++ b/executables/nr-uesoftmodem.c
@@ -44,7 +44,6 @@
 #include "SCHED/sched_common_vars.h"
 #include "PHY/MODULATION/modulation_vars.h"
 //#include "../../SIMU/USER/init_lte.h"
-#include "PHY/NR_REFSIG/nr_mod_table.h"
 
 #include "LAYER2/MAC/mac_vars.h"
 #include "RRC/LTE/rrc_vars.h"
diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c
index 9e095d5ab5b1b45e353880a346d5530098177bf7..136092f2d4a60c7d8b4496f39044683a871cdc55 100644
--- a/openair1/PHY/INIT/nr_init.c
+++ b/openair1/PHY/INIT/nr_init.c
@@ -132,6 +132,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
     }
   }
 
+  nr_generate_modulation_table();
   nr_init_pdcch_dmrs(gNB, cfg->cell_config.phy_cell_id.value);
   nr_init_pbch_interleaver(gNB->nr_pbch_interleaver);
   //PDSCH DMRS init
diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c
index 1729ac0d9e3eee312da2f4e9233fe52625243a67..fed58dea12ddbbe5da86228ab7caecfbef8dfa40 100644
--- a/openair1/PHY/INIT/nr_init_ue.c
+++ b/openair1/PHY/INIT/nr_init_ue.c
@@ -39,6 +39,7 @@
 #include "PHY/NR_REFSIG/pss_nr.h"
 #include "PHY/NR_REFSIG/ul_ref_seq_nr.h"
 #include "PHY/NR_REFSIG/refsig_defs_ue.h"
+#include "PHY/NR_REFSIG/nr_refsig.h"
 
 //uint8_t dmrs1_tab_ue[8] = {0,2,3,4,6,8,9,10};
 
@@ -681,6 +682,8 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
     ue->bitrate[eNB_id] = 0;
     ue->total_received_bits[eNB_id] = 0;
   }
+  // init NR modulation lookup tables
+  nr_generate_modulation_table();
 
   /////////////////////////PUSCH init/////////////////////////
   ///////////
diff --git a/openair1/PHY/MODULATION/nr_modulation.c b/openair1/PHY/MODULATION/nr_modulation.c
index dbfe93adee0837becc7d7948f77ef2848c99e091..764b02065f70de8421e65cb1609a114a68ba59d5 100644
--- a/openair1/PHY/MODULATION/nr_modulation.c
+++ b/openair1/PHY/MODULATION/nr_modulation.c
@@ -20,36 +20,138 @@
  */
 
 #include "nr_modulation.h"
-
-extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT];
+#include "PHY/NR_REFSIG/nr_mod_table.h"
 
 void nr_modulation(uint32_t *in,
                    uint32_t length,
                    uint16_t mod_order,
                    int16_t *out)
 {
-  uint16_t offset;
-  uint8_t idx, b_idx;
-
-  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;
+  uint16_t mask = ((1<<mod_order)-1);
+  int32_t* nr_mod_table32;
+  int32_t* out32 = (int32_t*) out;
+  uint8_t* in_bytes = (uint8_t*) in;
+  uint64_t* in64 = (uint64_t*) in;
+  int64_t* out64 = (int64_t*) out;
+  uint8_t idx;
+  uint32_t i,j;
+  uint32_t bit_cnt;
+  uint64_t x,x1,x2;
+    
+#if defined(__SSE2__)
+  __m128i *nr_mod_table128;
+  __m128i *out128;
+#endif
 
   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;
-    for (int j=0; j<mod_order; j++)
-    {
-      b_idx = (i*mod_order+j)&0x1f;
-      if (i && (!b_idx))
-        in++;
-      idx ^= (((*in)>>b_idx)&1)<<(mod_order-j-1);
+  switch (mod_order) {
+
+#if defined(__SSE2__)
+  case 2:
+    nr_mod_table128 = (__m128i*) nr_qpsk_byte_mod_table;
+    out128 = (__m128i*) out;
+    for (i=0; i<length/8; i++)
+      out128[i] = nr_mod_table128[in_bytes[i]];
+    // the bits that are left out
+    i = i*8/2;
+    nr_mod_table32 = (int32_t*) nr_qpsk_mod_table;
+    while (i<length/2){
+      idx = ((in_bytes[(i*2)/8]>>((i*2)&0x7)) & mask);
+      out32[i] = nr_mod_table32[idx];
+      i++;
+    }
+    return;
+#else
+  case 2:
+    nr_mod_table32 = (int32_t*) nr_qpsk_mod_table;
+    for (i=0; i<length/mod_order; i++) {
+      idx = ((in[i*2/32]>>((i*2)&0x1f)) & mask);
+      out32[i] = nr_mod_table32[idx];
+    }
+    return;
+#endif
+
+  case 4:
+    out64 = (int64_t*) out;
+    for (i=0; i<length/8; i++)
+      out64[i] = nr_16qam_byte_mod_table[in_bytes[i]];
+    // the bits that are left out
+    i = i*8/4;
+    while (i<length/4){
+      idx = ((in_bytes[(i*4)/8]>>((i*4)&0x7)) & mask);
+      out32[i] = nr_16qam_mod_table[idx];
+      i++;
+    }
+    return;
+
+  case 6:
+    j = 0;
+    for (i=0; i<length/192; i++) {
+      x = in64[i*3]; 
+      x1 = x&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x>>12)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x>>24)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x>>36)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x>>48)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x2 = (x>>60);
+      x = in64[i*3+1];
+      x2 |= x<<4;
+      x1 = x2&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x2>>12)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x2>>24)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x2>>36)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x2>>48)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x2 = ((x>>56)&0xf0) | (x2>>60);
+      x = in64[i*3+2];
+      x2 |= x<<8;
+      x1 = x2&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x2>>12)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x2>>24)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x2>>36)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x2>>48)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x2 = ((x>>52)&0xff0) | (x2>>60);
+      out64[j++] = nr_64qam_mod_table[x2];
+    }
+    i *= 24;
+    bit_cnt = i * 8;
+    while (bit_cnt < length) {
+      x = *((uint32_t*)(in_bytes+i));
+      x1 = x&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      x1 = (x>>12)&4095;
+      out64[j++] = nr_64qam_mod_table[x1];
+      i += 3;
+      bit_cnt += 24;
     }
+    return;
+      
+  case 8:
+    nr_mod_table32 = (int32_t*) nr_256qam_mod_table;
+    for (i=0; i<length/8; i++)
+      out32[i] = nr_mod_table32[in_bytes[i]];
+    return;
 
-    out[i<<1] = nr_mod_table[(offset+idx)<<1];
-    out[(i<<1)+1] = nr_mod_table[((offset+idx)<<1)+1];
+  default:
+    break;
   }
+  AssertFatal(false,"Invalid or unsupported modulation order %d\n",mod_order);
+
 }
 
 void nr_layer_mapping(int16_t **mod_symbs,
diff --git a/openair1/PHY/NR_REFSIG/nr_gen_mod_table.c b/openair1/PHY/NR_REFSIG/nr_gen_mod_table.c
new file mode 100644
index 0000000000000000000000000000000000000000..b0f9e6d03c55562555bfb1048b86e5c132758fa4
--- /dev/null
+++ b/openair1/PHY/NR_REFSIG/nr_gen_mod_table.c
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The OpenAirInterface Software Alliance licenses this file to You under
+ * the OAI Public License, Version 1.1  (the "License"); you may not use this file
+ * except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.openairinterface.org/?page_id=698
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *-------------------------------------------------------------------------------
+ * For more information about the OpenAirInterface (OAI) Software Alliance:
+ *      contact@openairinterface.org
+ */
+
+#include "nr_refsig.h"
+#include "nr_mod_table.h"
+
+void nr_generate_modulation_table() {
+  float sqrt2 = 0.70711;
+  float sqrt10 = 0.31623;
+  float sqrt42 = 0.15430;
+  float sqrt170 = 0.076696;
+  float val = 32768.0;
+  uint32_t i,j;
+  short* table;
+
+  // QPSK
+  for (i=0; i<4; i++) {
+    nr_qpsk_mod_table[i*2]   = (short)(1-2*(i&1))*val*sqrt2*sqrt2;
+    nr_qpsk_mod_table[i*2+1] = (short)(1-2*((i>>1)&1))*val*sqrt2*sqrt2;
+    //printf("%d j%d\n",nr_qpsk_mod_table[i*2],nr_qpsk_mod_table[i*2+1]);
+  }
+
+#if defined(__SSE2__)
+  //QPSK m128
+  table = (short*) nr_qpsk_byte_mod_table;
+  for (i=0; i<256; i++) {
+    for (j=0; j<4; j++) {
+      table[i*8+(j*2)]   = (short)(1-2*((i>>(j*2))&1))*val*sqrt2*sqrt2;
+      table[i*8+(j*2)+1] = (short)(1-2*((i>>(j*2+1))&1))*val*sqrt2*sqrt2;
+      //printf("%d j%d\n",nr_qpsk_byte_mod_table[i*8+(j*2)],nr_qpsk_byte_mod_table[i*8+(j*2)+1]);
+    }
+  }
+#endif
+
+  //16QAM
+  table = (short*) nr_16qam_byte_mod_table;
+  for (i=0; i<256; i++) {
+    for (j=0; j<2; j++) {
+      table[i*4+(j*2)]   = (short)((1-2*((i>>(j*4))&1))*(2-(1-2*((i>>(j*4+2))&1))))*val*sqrt10*sqrt2;
+      table[i*4+(j*2)+1] = (short)((1-2*((i>>(j*4+1))&1))*(2-(1-2*((i>>(j*4+3))&1))))*val*sqrt10*sqrt2;
+     //printf("%d j%d\n",nr_16qam_byte_mod_table[i*4+(j*2)],nr_16qam_byte_mod_table[i*4+(j*2)+1]);
+    }
+  }
+
+  table = (short*) nr_16qam_mod_table;
+  for (i=0; i<16; i++) {
+    table[i*2]   = (short)((1-2*(i&1))*(2-(1-2*((i>>2)&1))))*val*sqrt10*sqrt2;
+    table[i*2+1] = (short)((1-2*((i>>1)&1))*(2-(1-2*((i>>3)&1))))*val*sqrt10*sqrt2;
+    //printf("%d j%d\n",table[i*2],table[i*2+1]);
+  }
+
+  //64QAM
+  table = (short*) nr_64qam_mod_table;
+  for (i=0; i<4096; i++) {
+    for (j=0; j<2; j++) {
+      table[i*4+(j*2)]   = (short)((1-2*((i>>(j*6))&1))*(4-(1-2*((i>>(j*6+2))&1))*(2-(1-2*((i>>(j*6+4))&1)))))*val*sqrt42*sqrt2;
+      table[i*4+(j*2)+1] = (short)((1-2*((i>>(j*6+1))&1))*(4-(1-2*((i>>(j*6+3))&1))*(2-(1-2*((i>>(j*6+5))&1)))))*val*sqrt42*sqrt2;
+      //printf("%d j%d\n",table[i*4+(j*2)],table[i*4+(j*2)+1]);
+    }
+  }
+
+  //256QAM
+  table = (short*) nr_256qam_mod_table;
+  for (i=0; i<256; i++) {
+    table[i*2]   = (short)((1-2*(i&1))*(8-(1-2*((i>>2)&1))*(4-(1-2*((i>>4)&1))*(2-(1-2*((i>>6)&1))))))*val*sqrt170*sqrt2;
+    table[i*2+1] = (short)((1-2*((i>>1)&1))*(8-(1-2*((i>>3)&1))*(4-(1-2*((i>>5)&1))*(2-(1-2*((i>>7)&1))))))*val*sqrt170*sqrt2;
+  }
+}
+
diff --git a/openair1/PHY/NR_REFSIG/nr_gen_mod_table.m b/openair1/PHY/NR_REFSIG/nr_gen_mod_table.m
index 13a8d4ad09c38741bca610bccb6bd15e79204b89..6e1415bf2843d23f5d7fc29fad7608c5d12f6258 100644
--- a/openair1/PHY/NR_REFSIG/nr_gen_mod_table.m
+++ b/openair1/PHY/NR_REFSIG/nr_gen_mod_table.m
@@ -45,7 +45,7 @@ for r=0:1 %0 -- 1 LS
 for j=0:1 %0 -- 1 MS
   %% Formula is dispalayed
 
-qpsk_table(2*r+j+1) = ((1-r*2)*QPSK +  1j*(1-2*j)*QPSK);
+qpsk_table(2*j+r+1) = ((1-r*2)*QPSK +  1j*(1-2*j)*QPSK);
 end
 end
 
@@ -61,7 +61,7 @@ for b0=0:1
 for b1=0:1
 for b2=0:1
 for b3=0:1
-qam16_table2(b0*8+b1*4+b2*2+b3*1+1) = qam16_table(b0*2+b2*1+1) + 1j*qam16_table(b1*2+b3*1+1);
+qam16_table2(b3*8+b2*4+b1*2+b0*1+1) = qam16_table(b0*2+b2*1+1) + 1j*qam16_table(b1*2+b3*1+1);
 end
 end
 end
@@ -84,7 +84,7 @@ for b2=0:1
 for b3=0:1
 for b4=0:1
 for b5=0:1
-qam64_table2(b0*32+b1*16+b2*8+b3*4+b4*2+b5*1+1) = qam64_table(b0*4+b2*2+b4*1+1) + 1j*qam64_table(b1*4+b3*2+b5*1+1);
+qam64_table2(b5*32+b4*16+b3*8+b2*4+b1*2+b0*1+1) = qam64_table(b0*4+b2*2+b4*1+1) + 1j*qam64_table(b1*4+b3*2+b5*1+1);
 end
 end
 end
@@ -116,7 +116,50 @@ for b6=0:1
 for b7=0:1
 
 %%qam64_table2(b0*32+b1*16+b2*8+b3*4+b4*2+b5*1+1) = qam64_table(b0*4+b2*2+b4*1+1) + 1j*qam64_table(b1*4+b3*2+b5*1+1);
-qam256_table2(b0*128+b1*64+b2*32+b3*16+b4*8+b5*4+b6*2+b7*1+1) = qam256_table(b0*8+b2*4+b4*2+b6*1+1) + 1j*qam256_table(b1*8+b3*4+b5*2+b7*1+1);
+qam256_table2(b7*128+b6*64+b5*32+b4*16+b3*8+b2*4+b1*2+b0*1+1) = qam256_table(b0*8+b2*4+b4*2+b6*1+1) + 1j*qam256_table(b1*8+b3*4+b5*2+b7*1+1);
+end
+end
+end
+end
+end
+end
+end
+end
+
+%%QPSK byte
+for b0=0:1
+for b1=0:1
+for b2=0:1
+for b3=0:1
+for b4=0:1
+for b5=0:1
+for b6=0:1
+for b7=0:1
+qpsk_byte_table2(b7*128+b6*64+b5*32+b4*16+b3*8+b2*4+b1*2+b0*1+1,:)=[(1-b0*2)*QPSK (1-2*b1)*QPSK (1-b2*2)*QPSK (1-2*b3)*QPSK ...
+    (1-b4*2)*QPSK (1-2*b5)*QPSK (1-b6*2)*QPSK (1-2*b7)*QPSK];
+
+end
+end
+end
+end
+end
+end
+end
+end
+
+%%16QAM byte
+qam16_byte_table2=[];
+for b0=0:1
+for b1=0:1
+for b2=0:1
+for b3=0:1
+for b4=0:1
+for b5=0:1
+for b6=0:1
+for b7=0:1
+qam16_byte_table2(b7*128+b6*64+b5*32+b4*16+b3*8+b2*4+b1*2+b0*1+1,:)=[qam16_table(b0*2+b2*1+1) qam16_table(b1*2+b3*1+1) ...
+    qam16_table(b4*2+b6*1+1) qam16_table(b5*2+b7*1+1) ];
+
 end
 end
 end
@@ -133,6 +176,8 @@ save mod_table.mat table
 table2 = zeros(1,length(table)*2);
 table2(1:2:end) = real(table);
 table2(2:2:end) = imag(table);
+qpsk_byte_table2=round(K * qpsk_byte_table2'(:));
+qam16_byte_table2=round(K * qam16_byte_table2'(:));
 
 fd = fopen("nr_mod_table.h","w");
 fprintf(fd,"#define NR_MOD_TABLE_SIZE_SHORT %d\n", length(table)*2);
@@ -144,4 +189,10 @@ fprintf(fd,"#define NR_MOD_TABLE_QAM256_OFFSET %d\n", 87);
 fprintf(fd,"short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT] = {");
 fprintf(fd,"%d,",table2(1:end-1));
 fprintf(fd,"%d};\n",table2(end));
+fprintf(fd,"short nr_qpsk_mod_table[2048] = {");
+fprintf(fd,"%d,",qpsk_byte_table2(1:end-1));
+fprintf(fd,"%d};\n",qpsk_byte_table2(end));
+fprintf(fd,"short nr_qam16_mod_table[1024] = {");
+fprintf(fd,"%d,",qam16_byte_table2(1:end-1));
+fprintf(fd,"%d};\n",qam16_byte_table2(end));
 fclose(fd);
diff --git a/openair1/PHY/NR_REFSIG/nr_mod_table.h b/openair1/PHY/NR_REFSIG/nr_mod_table.h
index c34dadb663e8faf88efcb1851f38028c6b113b1d..aa8b99f584b6d2554c1fbbd6563c1a64db5b9470 100644
--- a/openair1/PHY/NR_REFSIG/nr_mod_table.h
+++ b/openair1/PHY/NR_REFSIG/nr_mod_table.h
@@ -28,6 +28,17 @@
 #define NR_MOD_TABLE_QAM16_OFFSET 7
 #define NR_MOD_TABLE_QAM64_OFFSET 23
 #define NR_MOD_TABLE_QAM256_OFFSET 87
-short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT] = {0,0,16384,16384,-16384,-16384,16384,16384,16384,-16384,-16384,16384,-16384,-16384,7327,7327,7327,21981,21981,7327,21981,21981,7327,-7327,7327,-21981,21981,-7327,21981,-21981,-7327,7327,-7327,21981,-21981,7327,-21981,21981,-7327,-7327,-7327,-21981,-21981,-7327,-21981,-21981,10726,10726,10726,3576,3576,10726,3576,3576,10726,17876,10726,25027,3576,17876,3576,25027,17876,10726,17876,3576,25027,10726,25027,3576,17876,17876,17876,25027,25027,17876,25027,25027,10726,-10726,10726,-3576,3576,-10726,3576,-3576,10726,-17876,10726,-25027,3576,-17876,3576,-25027,17876,-10726,17876,-3576,25027,-10726,25027,-3576,17876,-17876,17876,-25027,25027,-17876,25027,-25027,-10726,10726,-10726,3576,-3576,10726,-3576,3576,-10726,17876,-10726,25027,-3576,17876,-3576,25027,-17876,10726,-17876,3576,-25027,10726,-25027,3576,-17876,17876,-17876,25027,-25027,17876,-25027,25027,-10726,-10726,-10726,-3576,-3576,-10726,-3576,-3576,-10726,-17876,-10726,-25027,-3576,-17876,-3576,-25027,-17876,-10726,-17876,-3576,-25027,-10726,-25027,-3576,-17876,-17876,-17876,-25027,-25027,-17876,-25027,-25027,8886,8886,8886,12439,12439,8886,12439,12439,8886,5332,8886,1778,12439,5332,12439,1778,5332,8886,5332,12439,1778,8886,1778,12439,5332,5332,5332,1778,1778,5332,1778,1778,8886,19547,8886,15993,12439,19547,12439,15993,8886,23101,8886,26655,12439,23101,12439,26655,5332,19547,5332,15993,1778,19547,1778,15993,5332,23101,5332,26655,1778,23101,1778,26655,19547,8886,19547,12439,15993,8886,15993,12439,19547,5332,19547,1778,15993,5332,15993,1778,23101,8886,23101,12439,26655,8886,26655,12439,23101,5332,23101,1778,26655,5332,26655,1778,19547,19547,19547,15993,15993,19547,15993,15993,19547,23101,19547,26655,15993,23101,15993,26655,23101,19547,23101,15993,26655,19547,26655,15993,23101,23101,23101,26655,26655,23101,26655,26655,8886,-8886,8886,-12439,12439,-8886,12439,-12439,8886,-5332,8886,-1778,12439,-5332,12439,-1778,5332,-8886,5332,-12439,1778,-8886,1778,-12439,5332,-5332,5332,-1778,1778,-5332,1778,-1778,8886,-19547,8886,-15993,12439,-19547,12439,-15993,8886,-23101,8886,-26655,12439,-23101,12439,-26655,5332,-19547,5332,-15993,1778,-19547,1778,-15993,5332,-23101,5332,-26655,1778,-23101,1778,-26655,19547,-8886,19547,-12439,15993,-8886,15993,-12439,19547,-5332,19547,-1778,15993,-5332,15993,-1778,23101,-8886,23101,-12439,26655,-8886,26655,-12439,23101,-5332,23101,-1778,26655,-5332,26655,-1778,19547,-19547,19547,-15993,15993,-19547,15993,-15993,19547,-23101,19547,-26655,15993,-23101,15993,-26655,23101,-19547,23101,-15993,26655,-19547,26655,-15993,23101,-23101,23101,-26655,26655,-23101,26655,-26655,-8886,8886,-8886,12439,-12439,8886,-12439,12439,-8886,5332,-8886,1778,-12439,5332,-12439,1778,-5332,8886,-5332,12439,-1778,8886,-1778,12439,-5332,5332,-5332,1778,-1778,5332,-1778,1778,-8886,19547,-8886,15993,-12439,19547,-12439,15993,-8886,23101,-8886,26655,-12439,23101,-12439,26655,-5332,19547,-5332,15993,-1778,19547,-1778,15993,-5332,23101,-5332,26655,-1778,23101,-1778,26655,-19547,8886,-19547,12439,-15993,8886,-15993,12439,-19547,5332,-19547,1778,-15993,5332,-15993,1778,-23101,8886,-23101,12439,-26655,8886,-26655,12439,-23101,5332,-23101,1778,-26655,5332,-26655,1778,-19547,19547,-19547,15993,-15993,19547,-15993,15993,-19547,23101,-19547,26655,-15993,23101,-15993,26655,-23101,19547,-23101,15993,-26655,19547,-26655,15993,-23101,23101,-23101,26655,-26655,23101,-26655,26655,-8886,-8886,-8886,-12439,-12439,-8886,-12439,-12439,-8886,-5332,-8886,-1778,-12439,-5332,-12439,-1778,-5332,-8886,-5332,-12439,-1778,-8886,-1778,-12439,-5332,-5332,-5332,-1778,-1778,-5332,-1778,-1778,-8886,-19547,-8886,-15993,-12439,-19547,-12439,-15993,-8886,-23101,-8886,-26655,-12439,-23101,-12439,-26655,-5332,-19547,-5332,-15993,-1778,-19547,-1778,-15993,-5332,-23101,-5332,-26655,-1778,-23101,-1778,-26655,-19547,-8886,-19547,-12439,-15993,-8886,-15993,-12439,-19547,-5332,-19547,-1778,-15993,-5332,-15993,-1778,-23101,-8886,-23101,-12439,-26655,-8886,-26655,-12439,-23101,-5332,-23101,-1778,-26655,-5332,-26655,-1778,-19547,-19547,-19547,-15993,-15993,-19547,-15993,-15993,-19547,-23101,-19547,-26655,-15993,-23101,-15993,-26655,-23101,-19547,-23101,-15993,-26655,-19547,-26655,-15993,-23101,-23101,-23101,-26655,-26655,-23101,-26655,-26655};
 
+short nr_qpsk_mod_table[8];
+
+int32_t nr_16qam_mod_table[16];
+#if defined(__SSE2__)
+__m128i nr_qpsk_byte_mod_table[2048];
+#endif
+
+int64_t nr_16qam_byte_mod_table[1024];
+
+int64_t nr_64qam_mod_table[4096];
+
+int32_t nr_256qam_mod_table[512];
 #endif
diff --git a/openair1/PHY/NR_REFSIG/nr_refsig.h b/openair1/PHY/NR_REFSIG/nr_refsig.h
index 1bf2ef4fb2d8201cf235070bb64fde6a0e3bf02c..786fb2af358eeb530b74b42a0c04e82bc317f004 100644
--- a/openair1/PHY/NR_REFSIG/nr_refsig.h
+++ b/openair1/PHY/NR_REFSIG/nr_refsig.h
@@ -53,6 +53,8 @@ int nr_pusch_dmrs_rx(PHY_VARS_gNB *gNB,
 
 void init_scrambling_luts(void);
 
+void nr_generate_modulation_table(void);
+
 extern __m64 byte2m64_re[256];
 extern __m64 byte2m64_im[256];
 
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c
index a29211b55b5dfcaff7892fa43dba513db9d00afb..3a44ebc49a0c589ef13d1c45b3ea95c7b6bca970 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dci.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c
@@ -161,7 +161,7 @@ uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu,
                             int16_t amp,
                             NR_DL_FRAME_PARMS frame_parms) {
 
-  int16_t mod_dmrs[NR_MAX_CSET_DURATION][NR_MAX_PDCCH_DMRS_LENGTH>>1]; // 3 for the max coreset duration
+  int16_t mod_dmrs[NR_MAX_CSET_DURATION][NR_MAX_PDCCH_DMRS_LENGTH>>1] __attribute__((aligned(16))); // 3 for the max coreset duration
   uint16_t cset_start_sc;
   uint8_t cset_start_symb, cset_nsymb;
   int k,l,k_prime,dci_idx, dmrs_idx;
@@ -260,7 +260,7 @@ uint8_t nr_generate_dci_top(nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu,
 	   scrambled_output[6], scrambled_output[7], scrambled_output[8], scrambled_output[9], scrambled_output[10],scrambled_output[11] );
 #endif
     /// QPSK modulation
-    int16_t mod_dci[NR_MAX_DCI_SIZE>>1];
+    int16_t mod_dci[NR_MAX_DCI_SIZE>>1] __attribute__((aligned(16)));
     nr_modulation(scrambled_output, encoded_length, DMRS_MOD_ORDER, mod_dci); //Qm = 2 as DMRS is QPSK modulated
 #ifdef DEBUG_DCI
     
diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
index 23466132d6a1c89abf0f36ba0850c93136f61969..2849986833b2311bbc7ffe7d21e45dc145597120 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c
@@ -150,7 +150,7 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch,
   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];
+  int16_t mod_dmrs[n_dmrs<<1] __attribute__ ((aligned(16)));
 
   /// CRC, coding, interleaving and rate matching
   AssertFatal(harq->pdu!=NULL,"harq->pdu is null\n");
diff --git a/openair1/PHY/NR_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_TRANSPORT/nr_pbch.c
index bc33d938115f935a31ce2f51cd375db0e804091b..bd1278b2eb192e82bba8f817e17716effaed7101 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_pbch.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_pbch.c
@@ -40,7 +40,7 @@
 //#define DEBUG_PBCH_ENCODING
 //#define DEBUG_PBCH_DMRS
 
-extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT];
+extern short nr_qpsk_mod_table[8];
 
 uint8_t nr_pbch_payload_interleaving_pattern[32] = {16, 23, 18, 17, 8, 30, 10, 6, 24, 7, 0, 5, 3, 2, 1, 4,
                                                     9, 11, 12, 13, 14, 15, 19, 20, 21, 22, 25, 26, 27, 28, 29, 31
@@ -61,9 +61,9 @@ int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
 
   /// QPSK modulation
   for (int m=0; m<NR_PBCH_DMRS_LENGTH; m++) {
-    idx = ((((gold_pbch_dmrs[(m<<1)>>5])>>((m<<1)&0x1f))&1)<<1) ^ (((gold_pbch_dmrs[((m<<1)+1)>>5])>>(((m<<1)+1)&0x1f))&1);
-    mod_dmrs[m<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1];
-    mod_dmrs[(m<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1) + 1];
+    idx = (((gold_pbch_dmrs[(m<<1)>>5])>>((m<<1)&0x1f))&3);
+    mod_dmrs[m<<1] = nr_qpsk_mod_table[idx<<1];
+    mod_dmrs[(m<<1)+1] = nr_qpsk_mod_table[(idx<<1) + 1];
 #ifdef DEBUG_PBCH_DMRS
     printf("m %d idx %d gold seq %d b0-b1 %d-%d mod_dmrs %d %d\n", m, idx, gold_pbch_dmrs[(m<<1)>>5], (((gold_pbch_dmrs[(m<<1)>>5])>>((m<<1)&0x1f))&1),
            (((gold_pbch_dmrs[((m<<1)+1)>>5])>>(((m<<1)+1)&0x1f))&1), mod_dmrs[(m<<1)], mod_dmrs[(m<<1)+1]);
@@ -323,9 +323,9 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
 
   /// QPSK modulation
   for (int i=0; i<NR_POLAR_PBCH_E>>1; i++) {
-    idx = (((pbch->pbch_e[(i<<1)>>5]>>((i<<1)&0x1f))&1)<<1) ^ ((pbch->pbch_e[((i<<1)+1)>>5]>>(((i<<1)+1)&0x1f))&1);
-    mod_pbch_e[i<<1] = nr_mod_table[(NR_MOD_TABLE_QPSK_OFFSET + idx)<<1];
-    mod_pbch_e[(i<<1)+1] = nr_mod_table[((NR_MOD_TABLE_QPSK_OFFSET + idx)<<1)+1];
+    idx = ((pbch->pbch_e[(i<<1)>>5]>>((i<<1)&0x1f))&3);
+    mod_pbch_e[i<<1] = nr_qpsk_mod_table[idx<<1];
+    mod_pbch_e[(i<<1)+1] = nr_qpsk_mod_table[(idx<<1)+1];
 #ifdef DEBUG_PBCH
     printf("i %d idx %d  mod_pbch %d %d\n", i, idx, mod_pbch_e[2*i], mod_pbch_e[2*i+1]);
 #endif
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
index 6ffb6f21a3747d3299d32ac24f3646c2cd0e65b8..d1dd0f785b9c20378a35c1e9ecd7aec09eebc0da 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h
@@ -177,7 +177,7 @@ typedef struct {
   /// Scrambled "b"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
   uint8_t b_tilde[MAX_NUM_NR_CHANNEL_BITS];
   /// Modulated "d"-sequences (for definition see 36-211 V8.6 2009-03, p.14)
-  uint32_t d_mod[MAX_NUM_NR_RE];
+  uint32_t d_mod[MAX_NUM_NR_RE] __attribute__ ((aligned(16)));
   /// Transform-coded "y"-sequences (for definition see 38-211 V15.3.0 2018-09, subsection 6.3.1.4)
   uint32_t y[MAX_NUM_NR_RE] __attribute__ ((aligned(16)));
   /*
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
index cbde6e9a30e71ca6e7986973fad222d4a5076357..34cd6e92af48b9c044cc4e2d0e1af4b79c0714e3 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
@@ -218,7 +218,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
   ///////////
   pusch_dmrs = UE->nr_gold_pusch_dmrs[slot];
   n_dmrs = (nb_rb*((dmrs_type == pusch_dmrs_type1) ? 6:4)*number_dmrs_symbols);
-  int16_t mod_dmrs[n_dmrs<<1];
+  int16_t mod_dmrs[n_dmrs<<1] __attribute((aligned(16)));
   ///////////
   ////////////////////////////////////////////////////////////////////////
 
diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c
index b4069237b80248b6c57bd5d46b4e94af4437c184..5e2d42a0f72ad569d56dbbeb841b1ac4e214995c 100644
--- a/openair1/SIMULATION/NR_PHY/dlschsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlschsim.c
@@ -37,7 +37,6 @@
 #include "PHY/INIT/phy_init.h"
 #include "PHY/MODULATION/modulation_eNB.h"
 #include "PHY/MODULATION/modulation_UE.h"
-#include "PHY/NR_REFSIG/nr_mod_table.h"
 #include "PHY/NR_REFSIG/refsig_defs_ue.h"
 #include "PHY/NR_TRANSPORT/nr_dlsch.h"
 #include "PHY/NR_TRANSPORT/nr_transport_proto.h"
diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c
index 137c358d7f610aed1239022b179eb8acf402cf99..64ab482db894faef45b7637b5ae70e0277a970de 100644
--- a/openair1/SIMULATION/NR_PHY/dlsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlsim.c
@@ -39,7 +39,6 @@
 #include "PHY/INIT/phy_init.h"
 #include "PHY/MODULATION/modulation_eNB.h"
 #include "PHY/MODULATION/modulation_UE.h"
-#include "PHY/NR_REFSIG/nr_mod_table.h"
 #include "PHY/NR_REFSIG/refsig_defs_ue.h"
 #include "PHY/NR_TRANSPORT/nr_transport_proto.h"
 #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h"
@@ -927,22 +926,6 @@ int main(int argc, char **argv)
     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) {
-      
-      LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0], frame_length_complex_samples, 1, 1);
-      if (UE->frame_parms.nb_antennas_rx>1)
-	LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1], frame_length_complex_samples, 1, 1);
-      LOG_M("chestF0.m","chF0",UE->pdsch_vars[0][0]->dl_ch_estimates_ext,N_RB_DL*12*14,1,1);
-      write_output("rxF_comp.m","rxFc",&UE->pdsch_vars[0][0]->rxdataF_comp0[0][0],N_RB_DL*12*14,1,1);
-      break;
-    }
-
-    //if ((float)n_errors/(float)n_trials <= target_error_rate) {
-    if (effRate >= (eff_tp_check*TBS)) {
-      printf("PDSCH test OK\n");
-      break;
-    }
-
     if (print_perf==1) {
       printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, TBS %d, Kr %d (Zc %d))\n",
 	     1000>>*scc->ssbSubcarrierSpacing,dlsch_config.rbSize,dlsch_config.mcsIndex[0],
@@ -993,6 +976,23 @@ int main(int argc, char **argv)
       printStatIndent2(&UE->dlsch_tc_intl2_stats,"intl2+HardDecode+CRC");
       */
     }
+
+    if (n_trials == 1) {
+      
+      LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0], frame_length_complex_samples, 1, 1);
+      if (UE->frame_parms.nb_antennas_rx>1)
+	LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1], frame_length_complex_samples, 1, 1);
+      LOG_M("chestF0.m","chF0",UE->pdsch_vars[0][0]->dl_ch_estimates_ext,N_RB_DL*12*14,1,1);
+      write_output("rxF_comp.m","rxFc",&UE->pdsch_vars[0][0]->rxdataF_comp0[0][0],N_RB_DL*12*14,1,1);
+      break;
+    }
+
+    //if ((float)n_errors/(float)n_trials <= target_error_rate) {
+    if (effRate >= (eff_tp_check*TBS)) {
+      printf("PDSCH test OK\n");
+      break;
+    }
+
     snrRun++;
   } // NSR
 
diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c
index 2144652f8612ae3d5c34bcd578842ec8f93ba825..8c37024858408eac29cc897d662f3af267d5b436 100644
--- a/openair1/SIMULATION/NR_PHY/pbchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pbchsim.c
@@ -33,7 +33,6 @@
 #include "PHY/defs_nr_UE.h"
 #include "PHY/defs_gNB.h"
 #include "PHY/NR_REFSIG/refsig_defs_ue.h"
-#include "PHY/NR_REFSIG/nr_mod_table.h"
 #include "PHY/MODULATION/modulation_eNB.h"
 #include "PHY/MODULATION/modulation_UE.h"
 #include "PHY/INIT/phy_init.h"
diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c
index 2db5bc905c4b233406e21674bf40278ecacf16d9..950f9a67f665a0c548e56650af71889dea70dfd0 100644
--- a/openair1/SIMULATION/NR_PHY/prachsim.c
+++ b/openair1/SIMULATION/NR_PHY/prachsim.c
@@ -37,7 +37,6 @@
 #include "SCHED_NR_UE/phy_frame_config_nr.h"
 #include "PHY/phy_vars_nr_ue.h"
 #include "PHY/NR_REFSIG/refsig_defs_ue.h"
-#include "PHY/NR_REFSIG/nr_mod_table.h"
 #include "PHY/MODULATION/modulation_eNB.h"
 #include "PHY/MODULATION/modulation_UE.h"
 #include "PHY/INIT/phy_init.h"
diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c
index 004a7b8de8ae2868346b82576b6d34036ffb76ed..86f7d651e40129023245d2ca82e2719caca32a7a 100644
--- a/openair1/SIMULATION/NR_PHY/pucchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pucchsim.c
@@ -33,7 +33,6 @@
 #include "PHY/defs_nr_UE.h"
 #include "PHY/defs_gNB.h"
 #include "PHY/NR_REFSIG/refsig_defs_ue.h"
-#include "PHY/NR_REFSIG/nr_mod_table.h"
 #include "PHY/MODULATION/modulation_eNB.h"
 #include "PHY/MODULATION/modulation_UE.h"
 #include "PHY/INIT/phy_init.h"
diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c
index b0557ef1b417beeee6ef41f21489d11ebeb417d0..af49aa757b94f88d2082def48678bae547ac62a8 100644
--- a/openair1/SIMULATION/NR_PHY/ulschsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulschsim.c
@@ -34,7 +34,6 @@
 #include "PHY/defs_gNB.h"
 #include "PHY/INIT/phy_init.h"
 #include "PHY/NR_REFSIG/refsig_defs_ue.h"
-#include "PHY/NR_REFSIG/nr_mod_table.h"
 #include "PHY/MODULATION/modulation_eNB.h"
 #include "PHY/MODULATION/modulation_UE.h"
 #include "PHY/NR_TRANSPORT/nr_transport_proto.h"
diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c
index 8ffdd98970834030003cede89f4097dbd7e53818..ac4b93b9736a3e4c0e13c54969a9aa4b125021f7 100644
--- a/openair1/SIMULATION/NR_PHY/ulsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulsim.c
@@ -37,7 +37,6 @@
 #include "PHY/MODULATION/modulation_UE.h"
 #include "PHY/MODULATION/nr_modulation.h"
 #include "PHY/NR_REFSIG/dmrs_nr.h"
-#include "PHY/NR_REFSIG/nr_mod_table.h"
 #include "PHY/NR_REFSIG/refsig_defs_ue.h"
 #include "PHY/NR_TRANSPORT/nr_dlsch.h"
 #include "PHY/NR_TRANSPORT/nr_sch_dmrs.h"