From 9aa3483235cd90eb7a1fc3c89fd34e58ba3458ea Mon Sep 17 00:00:00 2001
From: yilmazt <turker.yilmaz@eurecom.fr>
Date: Thu, 3 Oct 2019 16:00:46 +0200
Subject: [PATCH] executables compiling again

---
 cmake_targets/CMakeLists.txt                  | 93 +++++++++++++------
 common/utils/LOG/vcd_signal_dumper.c          |  2 +-
 common/utils/ocp_itti/intertask_interface.h   |  5 +-
 executables/nr-softmodem-common.h             |  2 +-
 executables/nr-softmodem.h                    |  1 +
 executables/nr-uesoftmodem.c                  | 10 +-
 executables/nr-uesoftmodem.h                  |  1 +
 executables/softmodem-common.h                | 64 +++++++++++++
 openair1/PHY/CODING/TESTBENCH/ldpctest.c      | 51 +++-------
 openair1/PHY/CODING/TESTBENCH/polartest.c     |  8 +-
 .../PHY/CODING/TESTBENCH/smallblocktest.c     | 27 ++----
 openair1/SIMULATION/LTE_PHY/dlsim.c           | 18 ++--
 openair1/SIMULATION/NR_PHY/dlschsim.c         |  1 +
 openair1/SIMULATION/NR_PHY/dlsim.c            |  1 +
 openair1/SIMULATION/NR_PHY/nr_unitary_defs.h  |  2 +-
 openair1/SIMULATION/NR_PHY/pbchsim.c          |  1 +
 openair1/SIMULATION/NR_PHY/pucchsim.c         |  1 +
 openair1/SIMULATION/NR_PHY/ulschsim.c         |  1 +
 openair1/SIMULATION/NR_PHY/ulsim.c            |  1 +
 targets/ARCH/COMMON/common_lib.h              |  2 -
 targets/RT/USER/lte-softmodem.h               | 20 ++--
 21 files changed, 194 insertions(+), 118 deletions(-)
 create mode 100644 executables/softmodem-common.h

diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index f7a1c6fd00d..8e9b47e2aac 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -2631,69 +2631,108 @@ target_link_libraries (dlsim_tm4
 
 add_executable(polartest 
   ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/polartest.c
-  ${OPENAIR_DIR}/common/utils/backtrace.c)
-target_link_libraries(polartest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES})
-
+  ${OPENAIR_DIR}/common/utils/system.c
+  ${T_SOURCE}
+  ${SHLIB_LOADER_SOURCES}
+  )
+target_link_libraries(polartest
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE CONFIG_LIB -Wl,--end-group
+  m pthread ${ATLAS_LIBRARIES} dl
+  )
 
-add_executable(smallblocktest
+add_executable(smallblocktest 
   ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/smallblocktest.c
-  ${OPENAIR_DIR}/common/utils/backtrace.c)
-target_link_libraries(smallblocktest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES})
+  ${T_SOURCE}
+  ${SHLIB_LOADER_SOURCES}
+  )
+target_link_libraries(smallblocktest
+  -Wl,--start-group UTIL SIMU PHY_NR CONFIG_LIB -Wl,--end-group
+  m pthread ${ATLAS_LIBRARIES} dl
+  )
 
 add_executable(ldpctest  
   ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c
-  ${OPENAIR_DIR}/common/utils/backtrace.c)
-target_link_libraries(ldpctest SIMU PHY PHY_NR m ${ATLAS_LIBRARIES})
+  ${T_SOURCE}
+  ${SHLIB_LOADER_SOURCES}
+  )
+target_link_libraries(ldpctest
+  -Wl,--start-group UTIL SIMU PHY_NR CONFIG_LIB -Wl,--end-group
+  m pthread ${ATLAS_LIBRARIES} dl
+  )
 
 add_executable(nr_dlschsim  
   ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c 
-  ${OPENAIR_DIR}/common/utils/backtrace.c
   ${OPENAIR_DIR}/common/utils/system.c
   ${UTIL_SRC}
-  ${T_SOURCE})
-target_link_libraries(nr_dlschsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl)
+  ${T_SOURCE}
+  ${SHLIB_LOADER_SOURCES}
+  )
+target_link_libraries(nr_dlschsim 
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
+  m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl
+  )
 
 add_executable(nr_pbchsim  
   ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c 
-  ${OPENAIR_DIR}/common/utils/backtrace.c
   ${OPENAIR_DIR}/common/utils/system.c
   ${UTIL_SRC}
-  ${T_SOURCE})
-target_link_libraries(nr_pbchsim  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB}  dl)
+  ${T_SOURCE}
+  ${SHLIB_LOADER_SOURCES}
+  )
+target_link_libraries(nr_pbchsim
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
+  m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl
+  )
 
 #PUCCH ---> Prashanth
 add_executable(nr_pucchsim  
   ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pucchsim.c 
-  ${OPENAIR_DIR}/common/utils/backtrace.c
   ${OPENAIR_DIR}/common/utils/system.c
   ${UTIL_SRC}
-  ${T_SOURCE})
-target_link_libraries(nr_pucchsim  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl)
+  ${T_SOURCE}
+  ${SHLIB_LOADER_SOURCES}
+  )
+target_link_libraries(nr_pucchsim
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
+  m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl
+  )
 #PUCCH ---> Prashanth
 
 add_executable(nr_dlsim
-  ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c 
-  ${OPENAIR_DIR}/common/utils/backtrace.c
+  ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c
   ${OPENAIR_DIR}/common/utils/system.c
   ${UTIL_SRC}
-  ${T_SOURCE})   
-target_link_libraries(nr_dlsim  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl)
+  ${T_SOURCE}
+  ${SHLIB_LOADER_SOURCES}
+  )   
+target_link_libraries(nr_dlsim
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group
+  m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl
+  )
 
 add_executable(nr_ulschsim
   ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulschsim.c
-  ${OPENAIR_DIR}/common/utils/backtrace.c
   ${OPENAIR_DIR}/common/utils/system.c
   ${UTIL_SRC}
-  ${T_SOURCE})
-target_link_libraries(nr_ulschsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl)
+  ${T_SOURCE}
+  ${SHLIB_LOADER_SOURCES}
+  )
+target_link_libraries(nr_ulschsim
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group
+  m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl
+  )
 
 add_executable(nr_ulsim
   ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulsim.c
-  ${OPENAIR_DIR}/common/utils/backtrace.c
   ${OPENAIR_DIR}/common/utils/system.c
   ${UTIL_SRC}
-  ${T_SOURCE})
-target_link_libraries(nr_ulsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl)
+  ${T_SOURCE}
+  ${SHLIB_LOADER_SOURCES}
+  )
+target_link_libraries(nr_ulsim
+  -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group
+  m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl
+  )
 
 
 foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim)
diff --git a/common/utils/LOG/vcd_signal_dumper.c b/common/utils/LOG/vcd_signal_dumper.c
index d25b78be042..7fe5f72937c 100644
--- a/common/utils/LOG/vcd_signal_dumper.c
+++ b/common/utils/LOG/vcd_signal_dumper.c
@@ -630,7 +630,7 @@ void *vcd_dumper_thread_rt(void *args)
   uint32_t data_ready_wait;
 
 # if defined(ENABLE_ITTI)
-  signal_mask();
+  return 0; //signal_mask(); //function defined at common/utils/ocp_itti/intertask_interface.cpp
 # endif
 
   sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO) + 1;
diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h
index 868a9ba2455..80493dc816c 100644
--- a/common/utils/ocp_itti/intertask_interface.h
+++ b/common/utils/ocp_itti/intertask_interface.h
@@ -25,7 +25,7 @@ typedef struct {
 typedef struct {
   uint32_t      interval_sec;
   uint32_t      interval_us;
-  long     task_id;
+  long          task_id;
   int32_t       instance;
   timer_type_t  type;
   void         *timer_arg;
@@ -33,7 +33,7 @@ typedef struct {
 } timer_create_t;
 
 typedef struct {
-  long     task_id;
+  long          task_id;
   long          timer_id;
 } timer_delete_t;
 
@@ -536,6 +536,7 @@ int timer_setup(
 int timer_remove(long timer_id);
 #define timer_stop timer_remove
 int signal_handle(int *end);
+int signal_mask(void);
 
 #ifdef __cplusplus
 }
diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h
index 0fec975e6fa..d3c58b00775 100644
--- a/executables/nr-softmodem-common.h
+++ b/executables/nr-softmodem-common.h
@@ -1,7 +1,7 @@
 #ifndef NR_SOFTMODEM_COMMON_H
 #define NR_SOFTMODEM_COMMON_H
 
-#ifndef  _GNU_SOURCE
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
 
diff --git a/executables/nr-softmodem.h b/executables/nr-softmodem.h
index 8856c920597..6a40300f9ee 100644
--- a/executables/nr-softmodem.h
+++ b/executables/nr-softmodem.h
@@ -2,6 +2,7 @@
 #define NR_SOFTMODEM_H
 
 #include <executables/nr-softmodem-common.h>
+#include <executables/softmodem-common.h>
 
 #include "flexran_agent.h"
 #include "PHY/defs_gNB.h"
diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c
index 0dbe3ae831c..cffb5d9b035 100644
--- a/executables/nr-uesoftmodem.c
+++ b/executables/nr-uesoftmodem.c
@@ -162,7 +162,7 @@ uint8_t nb_antenna_rx = 1;
 char ref[128] = "internal";
 char channels[128] = "0";
 
-typedef struct {
+/*typedef struct {
   uint64_t       optmask;
   THREAD_STRUCT  thread_struct;
   char           rf_config_file[1024];
@@ -176,14 +176,14 @@ typedef struct {
   unsigned int   start_msc;
   uint32_t       clock_source;
   int            hw_timing_advance;
-} softmodem_params_t;
+} softmodem_params_t;*/
 static softmodem_params_t softmodem_params;
 
 static char *parallel_config = NULL;
 static char *worker_config = NULL;
-static THREAD_STRUCT thread_struct;
+//static THREAD_STRUCT thread_struct;
 
-void set_parallel_conf(char *parallel_conf) {
+/*void set_parallel_conf(char *parallel_conf) {
   if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0)           thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD;
   else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0)        thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT;
   else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0)    thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT;
@@ -201,7 +201,7 @@ PARALLEL_CONF_t get_thread_parallel_conf(void) {
 }
 WORKER_CONF_t get_thread_worker_conf(void) {
   return thread_struct.worker_conf;
-}
+}*/
 int rx_input_level_dBm;
 
 //static int online_log_messages=0;
diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h
index 3edffc30e11..3c2c6140737 100644
--- a/executables/nr-uesoftmodem.h
+++ b/executables/nr-uesoftmodem.h
@@ -1,6 +1,7 @@
 #ifndef NR_UESOFTMODEM_H
 #define NR_UESOFTMODEM_H
 #include <executables/nr-softmodem-common.h>
+#include <executables/softmodem-common.h>
 #include "PHY/defs_nr_UE.h"
 #include "SIMULATION/ETH_TRANSPORT/proto.h"
 #include <openair2/LAYER2/NR_MAC_gNB/mac_proto.h>
diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h
new file mode 100644
index 00000000000..4776c0714b0
--- /dev/null
+++ b/executables/softmodem-common.h
@@ -0,0 +1,64 @@
+#ifndef SOFTMODEM_COMMON_H
+#define SOFTMODEM_COMMON_H
+
+//#include "threads_t.h"
+
+THREAD_STRUCT thread_struct;
+
+static inline void set_parallel_conf(char *parallel_conf) {
+  mapping config[]= {
+    FOREACH_PARALLEL(GENERATE_ENUMTXT)
+    {NULL,-1}
+  };
+  thread_struct.parallel_conf = (PARALLEL_CONF_t)map_str_to_int(config, parallel_conf);
+  if (thread_struct.parallel_conf == -1 ) {
+    LOG_E(ENB_APP,"Impossible value: %s\n", parallel_conf);
+    thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD;
+  }
+  printf("[CONFIG] parallel_conf is set to %d\n", thread_struct.parallel_conf);
+}
+
+static inline void set_worker_conf(char *worker_conf) {
+  mapping config[]={
+    FOREACH_WORKER(GENERATE_ENUMTXT)
+    {NULL, -1}
+  };
+  thread_struct.worker_conf = (WORKER_CONF_t)map_str_to_int(config, worker_conf);
+  if (thread_struct.worker_conf == -1 ) {
+    LOG_E(ENB_APP,"Impossible value: %s\n", worker_conf);
+    thread_struct.worker_conf = WORKER_DISABLE ;
+  }
+  printf("[CONFIG] worker_conf is set to %d\n", thread_struct.worker_conf);
+}
+
+static inline PARALLEL_CONF_t get_thread_parallel_conf(void) {
+  return thread_struct.parallel_conf;
+}
+
+static inline WORKER_CONF_t get_thread_worker_conf(void) {
+  return thread_struct.worker_conf;
+}
+
+typedef struct {
+  uint64_t       optmask;
+  THREAD_STRUCT  thread_struct;
+  char           rf_config_file[1024];
+  int            phy_test;
+  uint8_t        usim_test;
+  int            emulate_rf;
+  int            wait_for_sync; //eNodeB only
+  int            single_thread_flag; //eNodeB only
+  int            chain_offset;
+  int            numerology;
+  unsigned int   start_msc;
+  uint32_t       clock_source;
+  uint32_t       timing_source;
+  int            hw_timing_advance;
+  uint32_t       send_dmrs_sync;
+} softmodem_params_t;
+
+
+
+
+
+#endif
diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c
index d73cbd05e81..d213a657f59 100644
--- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c
+++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c
@@ -23,13 +23,14 @@
 #include <math.h>
 #include <stdio.h>
 #include <string.h>
-
 #include "assertions.h"
 #include "SIMULATION/TOOLS/sim.h"
 #include "PHY/CODING/nrLDPC_encoder/defs.h"
 #include "PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h"
+#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h"
 
 #define MAX_NUM_DLSCH_SEGMENTS 16
+#define MAX_BLOCK_LENGTH 8448
 
 #ifndef malloc16
 #  ifdef __AVX2__
@@ -42,7 +43,6 @@
 #define NR_LDPC_PROFILER_DETAIL
 #define NR_LDPC_ENABLE_PARITY_CHECK
 
-
 // 4-bit quantizer
 char quantize4bit(double D,double x)
 {
@@ -76,31 +76,15 @@ char quantize8bit(double D,double x)
   return((char)qxd);
 }
 
-char quantize(double D,double x,unsigned char B)
-{
-  double qxd;
-  short maxlev;
-  qxd = floor(x/D);
-
-  maxlev = 1<<(B-1);//(char)(pow(2,B-1));
-
-  //printf("x=%f,qxd=%f,maxlev=%d\n",x,qxd, maxlev);
-
-  if (qxd <= -maxlev)
-    qxd = -maxlev;
-  else if (qxd >= maxlev)
-    qxd = maxlev-1;
-
-  return((char)qxd);
-}
-
 typedef struct {
-double n_iter_mean;
-double n_iter_std;
-int n_iter_max;
+  double n_iter_mean;
+  double n_iter_std;
+  int n_iter_max;
 } n_iter_stats_t;
 
-#define MAX_BLOCK_LENGTH 8448
+RAN_CONTEXT_t RC;
+PHY_VARS_UE ***PHY_vars_UE_g;
+uint16_t NB_UE_INST = 1;
 
 short lift_size[51]= {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384};
 
@@ -662,8 +646,7 @@ int main(int argc, char *argv[])
 
   fprintf(fd,"SNR BLER BER UNCODED_BER ENCODER_MEAN ENCODER_STD ENCODER_MAX DECODER_TIME_MEAN DECODER_TIME_STD DECODER_TIME_MAX DECODER_ITER_MEAN DECODER_ITER_STD DECODER_ITER_MAX\n");
 
-  for (SNR=SNR0;SNR<SNR0+20.0;SNR+=SNR_step)
-  {
+  for (SNR=SNR0;SNR<SNR0+20.0;SNR+=SNR_step) {
 	  //reset_meas(&time_optim);
 	  //reset_meas(&time_decoder);
 	  //n_iter_stats_t dec_iter = {0, 0, 0};
@@ -719,23 +702,11 @@ int main(int argc, char *argv[])
     		dec_iter->n_iter_max
     		);
 
-    if (decoded_errors[i] == 0)
-    	break;
-    i=i+1;
-
+    if (decoded_errors[i] == 0) break;
 
+    i=i+1;
   }
   fclose(fd);
 
   return(0);
 }
-
-
-
-
-
-
-
-
-
-
diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c
index 76cde6c3bec..051e098187f 100644
--- a/openair1/PHY/CODING/TESTBENCH/polartest.c
+++ b/openair1/PHY/CODING/TESTBENCH/polartest.c
@@ -11,6 +11,7 @@
 #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h"
 #include "PHY/CODING/coding_defs.h"
 #include "SIMULATION/TOOLS/sim.h"
+#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h"
 //#include "PHY/NR_TRANSPORT/nr_transport.h"
 //#include "common/utils/LOG/log.h"
 
@@ -18,7 +19,12 @@
 //#define DEBUG_POLAR_TIMING
 //#define DEBUG_POLARTEST
 
-int main(int argc, char *argv[]) {
+RAN_CONTEXT_t RC;
+PHY_VARS_UE ***PHY_vars_UE_g;
+uint16_t NB_UE_INST = 1;
+
+int main(int argc, char *argv[])
+{
   //Default simulation values (Aim for iterations = 1000000.)
   int decoder_int16=0;
   int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, -1=UCI
diff --git a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c
index ee1a228ab80..02d5dc64e07 100644
--- a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c
+++ b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c
@@ -1,27 +1,16 @@
-#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h"
-#include "SIMULATION/TOOLS/sim.h"
 #include <getopt.h>
+#include "SIMULATION/TOOLS/sim.h"
+#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h"
+#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h"
 
 //#define DEBUG_SMALLBLOCKTEST
 
-signed char quantize(double D, double x, unsigned char B)
-{
-	double qxd;
-	short maxlev;
-	qxd = floor(x/D);
-
-	maxlev = 1<<(B-1);//(char)(pow(2,B-1));
-
-	if (qxd <= -maxlev)
-		qxd = -maxlev;
-	else if (qxd >= maxlev)
-		qxd = maxlev-1;
-
-	return((char)qxd);
-}
-
-int main(int argc, char *argv[]) {
+RAN_CONTEXT_t RC;
+PHY_VARS_UE ***PHY_vars_UE_g;
+uint16_t NB_UE_INST = 1;
 
+int main(int argc, char *argv[])
+{
 	time_stats_t timeEncoder,timeDecoder;
 	opp_enabled=1;
 	cpu_freq_GHz = get_cpu_freq_GHz();
diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c
index d04403d43c5..4cc6d502493 100644
--- a/openair1/SIMULATION/LTE_PHY/dlsim.c
+++ b/openair1/SIMULATION/LTE_PHY/dlsim.c
@@ -85,28 +85,28 @@ double t_rx_min = 1000000000; /*!< \brief initial min process time for rx */
 int n_tx_dropped = 0; /*!< \brief initial max process time for tx */
 int n_rx_dropped = 0; /*!< \brief initial max process time for rx */
 
-//THREAD_STRUCT thread_struct;
-static THREAD_STRUCT thread_struct;
+THREAD_STRUCT thread_struct;
+//static THREAD_STRUCT thread_struct;
 
-void set_parallel_conf(char *parallel_conf) {
+void set_parallel_conf_dlsim(char *parallel_conf) {
   if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0)           thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD;
   else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0)        thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT;
   else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0)    thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT;
 
   printf("[CONFIG] parallel conf is set to %d\n",thread_struct.parallel_conf);
 }
-void set_worker_conf(char *worker_conf) {
+void set_worker_conf_dlsim(char *worker_conf) {
   if(strcmp(worker_conf,"WORKER_DISABLE")==0)	                  thread_struct.worker_conf = WORKER_DISABLE;
   else if(strcmp(worker_conf,"WORKER_ENABLE")==0)                 thread_struct.worker_conf = WORKER_ENABLE;
 
   printf("[CONFIG] worker conf is set to %d\n",thread_struct.worker_conf);
 }
-PARALLEL_CONF_t get_thread_parallel_conf(void) {
+/*PARALLEL_CONF_t get_thread_parallel_conf(void) {
 	return thread_struct.parallel_conf;
 }
 WORKER_CONF_t get_thread_worker_conf(void) {
 	return thread_struct.worker_conf;
-}
+}*/
 
 
 int emulate_rf = 0;
@@ -641,7 +641,7 @@ int main(int argc, char **argv) {
   memset((void *)&TX_req,0,sizeof(TX_req));
   DL_req.dl_config_request_body.dl_config_pdu_list = dl_config_pdu_list;
   TX_req.tx_request_body.tx_pdu_list = tx_pdu_list;
-  set_parallel_conf("PARALLEL_SINGLE_THREAD");
+  set_parallel_conf_dlsim("PARALLEL_SINGLE_THREAD");
   cpuf = cpu_freq_GHz;
   //signal(SIGSEGV, handler);
   //signal(SIGABRT, handler);
@@ -891,7 +891,7 @@ int main(int argc, char **argv) {
         break;
 
       case 'Q':
-        set_parallel_conf(optarg);
+        set_parallel_conf_dlsim(optarg);
         break;
 
       default:
@@ -912,7 +912,7 @@ int main(int argc, char **argv) {
   if (help)
     exit(0);
   if (thread_struct.parallel_conf != PARALLEL_SINGLE_THREAD)
-    set_worker_conf("WORKER_ENABLE");
+    set_worker_conf_dlsim("WORKER_ENABLE");
 
   if (transmission_mode>1) pa=dBm3;
 
diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c
index c0a12cda474..f0901a0048b 100644
--- a/openair1/SIMULATION/NR_PHY/dlschsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlschsim.c
@@ -55,6 +55,7 @@ PHY_VARS_NR_UE *UE;
 RAN_CONTEXT_t RC;
 double cpuf;
 int nfapi_mode = 0;
+uint16_t NB_UE_INST = 1;
 
 // needed for some functions
 PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } };
diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c
index aca129623e9..5fcd7261aa0 100644
--- a/openair1/SIMULATION/NR_PHY/dlsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlsim.c
@@ -62,6 +62,7 @@ PHY_VARS_NR_UE *UE;
 RAN_CONTEXT_t RC;
 double cpuf;
 int nfapi_mode=0;
+uint16_t NB_UE_INST = 1;
 
 //Dummy Functions
 lte_subframe_t subframe_select(LTE_DL_FRAME_PARMS *frame_parms, unsigned char subframe) {return(SF_DL);}
diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
index be04bc82134..78596cc792a 100644
--- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
+++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h
@@ -41,7 +41,7 @@ void exit_function(const char* file, const char* function, const int line, const
   exit(-1);
 }
 
-char quantize(double D, double x, unsigned char B) {
+signed char quantize(double D, double x, unsigned char B) {
   double qxd;
   short maxlev;
   qxd = floor(x / D);
diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c
index 22abbbcbc28..7e0709da367 100644
--- a/openair1/SIMULATION/NR_PHY/pbchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pbchsim.c
@@ -54,6 +54,7 @@ PHY_VARS_NR_UE *UE;
 RAN_CONTEXT_t RC;
 double cpuf;
 int nfapi_mode=0;
+uint16_t NB_UE_INST = 1;
 
 // needed for some functions
 openair0_config_t openair0_cfg[MAX_CARDS];
diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c
index 9e03a06a821..08b73948b5d 100644
--- a/openair1/SIMULATION/NR_PHY/pucchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pucchsim.c
@@ -52,6 +52,7 @@ RAN_CONTEXT_t RC;
 openair0_config_t openair0_cfg[MAX_CARDS];
 double cpuf;
 int nfapi_mode=0;
+uint16_t NB_UE_INST = 1;
 
 // needed for some functions
 PHY_VARS_NR_UE * PHY_vars_UE_g[1][1]={{NULL}};
diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c
index ed5ee737696..caf2f204f30 100644
--- a/openair1/SIMULATION/NR_PHY/ulschsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulschsim.c
@@ -54,6 +54,7 @@ PHY_VARS_NR_UE *UE;
 RAN_CONTEXT_t RC;
 double cpuf;
 int nfapi_mode = 0;
+uint16_t NB_UE_INST = 1;
 
 // needed for some functions
 PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } };
diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c
index 85fec505e01..15e27b3c1f9 100644
--- a/openair1/SIMULATION/NR_PHY/ulsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulsim.c
@@ -62,6 +62,7 @@ PHY_VARS_NR_UE *UE;
 RAN_CONTEXT_t RC;
 double cpuf;
 int nfapi_mode = 0;
+uint16_t NB_UE_INST = 1;
 
 // dummy functions
 int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id, const int CC_id, const uint8_t gNB_index,
diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h
index 531ef9045bd..43740d1c63f 100644
--- a/targets/ARCH/COMMON/common_lib.h
+++ b/targets/ARCH/COMMON/common_lib.h
@@ -445,8 +445,6 @@ typedef struct {
 
 #define OPTION_LZ4  0x00000001          // LZ4 compression (option_value is set to compressed size)
 
-#define sample_t struct complex16 // 2*16 bits complex number
-
 #ifdef __cplusplus
 extern "C"
 {
diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h
index b4019d065ac..21badfdaf2f 100644
--- a/targets/RT/USER/lte-softmodem.h
+++ b/targets/RT/USER/lte-softmodem.h
@@ -20,8 +20,7 @@
 #include <sys/sysinfo.h>
 #include <sys/types.h>
 #include <unistd.h>
-
-#include <sys/sysinfo.h>
+#include "threads_t.h"
 #include "rt_wrapper.h"
 #include "../../ARCH/COMMON/common_lib.h"
 //#undef MALLOC
@@ -30,12 +29,11 @@
 #include "PHY/types.h"
 #include "PHY/defs_eNB.h"
 #include "PHY/defs_UE.h"
-#include "SIMULATION/ETH_TRANSPORT/proto.h"
-
 #include "flexran_agent.h"
 #include "s1ap_eNB.h"
 #include "SIMULATION/ETH_TRANSPORT/proto.h"
 #include "proto_agent.h"
+#include "executables/softmodem-common.h"
 
 /* help strings definition for command line options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */
 #define CONFIG_HLP_RFCFGF        "Configuration file for front-end (e.g. LMS7002M)\n"
@@ -241,13 +239,13 @@
 
 /***************************************************************************************************************************************/
 /*  */
-#include "threads_t.h"
+//#include "threads_t.h"
 //extern threads_t threads;
 
 //extern THREAD_STRUCT thread_struct;
-THREAD_STRUCT thread_struct;
+//THREAD_STRUCT thread_struct;
 
-static inline void set_parallel_conf(char *parallel_conf) {
+/*static inline void set_parallel_conf(char *parallel_conf) {
   mapping config[]= {
     FOREACH_PARALLEL(GENERATE_ENUMTXT)
     {NULL,-1}
@@ -257,6 +255,7 @@ static inline void set_parallel_conf(char *parallel_conf) {
     LOG_E(ENB_APP,"Impossible value: %s\n", parallel_conf);
     thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD;
   }
+  printf("[CONFIG] parallel_conf is set to %d\n", thread_struct.parallel_conf);
 }
 
 static inline void set_worker_conf(char *worker_conf) {
@@ -269,6 +268,7 @@ static inline void set_worker_conf(char *worker_conf) {
     LOG_E(ENB_APP,"Impossible value: %s\n", worker_conf);
     thread_struct.worker_conf = WORKER_DISABLE ;
   }
+  printf("[CONFIG] worker_conf is set to %d\n", thread_struct.worker_conf);
 }
 
 static inline PARALLEL_CONF_t get_thread_parallel_conf(void) {
@@ -277,7 +277,7 @@ static inline PARALLEL_CONF_t get_thread_parallel_conf(void) {
 
 static inline WORKER_CONF_t get_thread_worker_conf(void) {
   return thread_struct.worker_conf;
-}
+}*/
 
 /*PARALLEL_CONF_t get_thread_parallel_conf(void);
 WORKER_CONF_t   get_thread_worker_conf(void);
@@ -293,7 +293,7 @@ void set_worker_conf(char *worker_conf);
 #define SOFTMODEM_BASICSIM_BIT        (1<<11)
 #define SOFTMODEM_SIML1_BIT           (1<<12)
 #define SOFTMODEM_DOFORMS_BIT         (1<<15)
-typedef struct {
+/*typedef struct {
   uint64_t       optmask;
   THREAD_STRUCT  thread_struct;
   char           rf_config_file[1024];
@@ -309,7 +309,7 @@ typedef struct {
   uint32_t       timing_source;
   int            hw_timing_advance;
   uint32_t       send_dmrs_sync;
-} softmodem_params_t;
+} softmodem_params_t;*/
 
 #define IS_SOFTMODEM_NOS1            ( get_softmodem_optmask() & SOFTMODEM_NOS1_BIT)
 #define IS_SOFTMODEM_NOKRNMOD        ( get_softmodem_optmask() & SOFTMODEM_NOKRNMOD_BIT)
-- 
GitLab