From d219341905a5c4197eb8a123caad3c3d141cd68d Mon Sep 17 00:00:00 2001
From: Francesco Mani <francesco.mani@eurecom.fr>
Date: Tue, 25 Aug 2020 19:02:13 +0200
Subject: [PATCH] to make simulators compile

---
 cmake_targets/CMakeLists.txt          |  1 +
 executables/nr-uesoftmodem.c          |  6 ++++--
 openair1/PHY/INIT/nr_init.c           |  1 +
 openair1/SIMULATION/LTE_PHY/dlsim.c   |  6 +++++-
 openair1/SIMULATION/LTE_PHY/ulsim.c   |  2 +-
 openair1/SIMULATION/NR_PHY/dlschsim.c |  6 ++++--
 openair1/SIMULATION/NR_PHY/prachsim.c |  2 ++
 openair1/SIMULATION/NR_PHY/ulschsim.c | 14 +++++++++-----
 8 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index 09efb0b80af..61665ae71eb 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -3043,6 +3043,7 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr
     ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c
     ${OPENAIR_DIR}/common/utils/backtrace.c
     ${OPENAIR_DIR}/common/utils/system.c
+    ${OPENAIR_DIR}/common/utils/utils.c
     ${XFORMS_SOURCE}
     ${T_SOURCE}
     ${CONFIG_SOURCES}
diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c
index 8af6266ce1c..471641dc2e2 100644
--- a/executables/nr-uesoftmodem.c
+++ b/executables/nr-uesoftmodem.c
@@ -38,7 +38,7 @@
 #include "../../ARCH/ETHERNET/USERSPACE/LIB/if_defs.h"
 
 //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all
-
+#include "openair1/PHY/MODULATION/nr_modulation.h"
 #include "PHY/phy_vars_nr_ue.h"
 #include "PHY/LTE_TRANSPORT/transport_vars.h"
 #include "SCHED/sched_common_vars.h"
@@ -358,7 +358,9 @@ static void get_options(void) {
     frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0];
   }
 
-  init_symbol_rotation(frame_parms,frame_parms[CC_id]->dl_CarrierFreq);
+  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+    init_symbol_rotation(frame_parms[CC_id],frame_parms[CC_id]->dl_CarrierFreq);
+  }
 
   UE_scan=0;
 
diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c
index 664d90f1888..cf04dcaeb4c 100644
--- a/openair1/PHY/INIT/nr_init.c
+++ b/openair1/PHY/INIT/nr_init.c
@@ -27,6 +27,7 @@
 #include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h"
 #include "PHY/NR_TRANSPORT/nr_transport_proto.h"
 #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
+#include "openair1/PHY/MODULATION/nr_modulation.h"
 /*#include "RadioResourceConfigCommonSIB.h"
 #include "RadioResourceConfigDedicated.h"
 #include "TDD-Config.h"
diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c
index f65e1f9633f..94214ab3b37 100644
--- a/openair1/SIMULATION/LTE_PHY/dlsim.c
+++ b/openair1/SIMULATION/LTE_PHY/dlsim.c
@@ -78,6 +78,8 @@ 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 */
 
+double DS_TDL = .03;
+
 int emulate_rf = 0;
 int split73=0;
 void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) {
@@ -161,7 +163,7 @@ void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR,
   // Multipath channel
   if (awgn_flag == 0) {
     multipath_channel(eNB2UE[round],s_re,s_im,r_re,r_im,
-                      2*UE->frame_parms.samples_per_tti,hold_channel);
+                      2*UE->frame_parms.samples_per_tti,hold_channel,0);
 
     //      printf("amc: ****************** eNB2UE[%d]->n_rx = %d,dd %d\n",round,eNB2UE[round]->nb_rx,eNB2UE[round]->channel_offset);
     if(abstx==1 && num_rounds>1)
@@ -1172,6 +1174,7 @@ int main(int argc, char **argv) {
                                    channel_model,
                                    N_RB2sampling_rate(eNB->frame_parms.N_RB_DL),
                                    N_RB2channel_bandwidth(eNB->frame_parms.N_RB_DL),
+                                   DS_TDL,
                                    forgetting_factor,
                                    rx_sample_offset,
                                    0);
@@ -1185,6 +1188,7 @@ int main(int argc, char **argv) {
                                        channel_model,
                                        N_RB2sampling_rate(eNB->frame_parms.N_RB_DL),
                                        N_RB2channel_bandwidth(eNB->frame_parms.N_RB_DL),
+                                       DS_TDL,
                                        forgetting_factor,
                                        rx_sample_offset,
                                        0);
diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c
index 42518c6438f..37ce3a65d60 100644
--- a/openair1/SIMULATION/LTE_PHY/ulsim.c
+++ b/openair1/SIMULATION/LTE_PHY/ulsim.c
@@ -1087,7 +1087,7 @@ int main(int argc, char **argv) {
           if (awgn_flag == 0) {
             if (UE2eNB->max_Doppler == 0) {
               multipath_channel(UE2eNB,s_re,s_im,r_re,r_im,
-                                eNB->frame_parms.samples_per_tti,hold_channel);
+                                eNB->frame_parms.samples_per_tti,hold_channel,0);
             } else {
               multipath_tv_channel(UE2eNB,s_re,s_im,r_re,r_im,
                                    2*eNB->frame_parms.samples_per_tti,hold_channel);
diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c
index b4069237b80..7b4525d7f59 100644
--- a/openair1/SIMULATION/NR_PHY/dlschsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlschsim.c
@@ -59,7 +59,8 @@ double cpuf;
 uint8_t nfapi_mode = 0;
 uint16_t NB_UE_INST = 1;
 
-
+uint8_t const nr_rv_round_map[4] = {0, 2, 1, 3};
+uint8_t const nr_rv_round_map_ue[4] = {0, 2, 1, 3};
 
 // needed for some functions
 PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } };
@@ -114,7 +115,7 @@ int main(int argc, char **argv)
 	uint16_t nb_rb = 50;
 	uint8_t Imcs = 9;
         uint8_t mcs_table = 0;
-
+        double DS_TDL = .03;
 	cpuf = get_cpu_freq_GHz();
 
 	if (load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY) == 0) {
@@ -337,6 +338,7 @@ int main(int argc, char **argv)
 	gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model, 
 				      61.44e6, //N_RB2sampling_rate(N_RB_DL),
 				      40e6, //N_RB2channel_bandwidth(N_RB_DL),
+                                      DS_TDL,
 				      0, 0, 0);
 
 	if (gNB2UE == NULL) {
diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c
index ec79274b8f0..826e8d54070 100644
--- a/openair1/SIMULATION/NR_PHY/prachsim.c
+++ b/openair1/SIMULATION/NR_PHY/prachsim.c
@@ -93,6 +93,7 @@ int main(int argc, char **argv){
   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;
+  double DS_TDL = .03;
 
   //  int8_t interf1=-19,interf2=-19;
   //  uint8_t abstraction_flag=0,calibration_flag=0;
@@ -558,6 +559,7 @@ int main(int argc, char **argv){
                                 channel_model,
                                 fs,
                                 bw,
+                                DS_TDL,
                                 0.0,
                                 delay,
                                 0);
diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c
index b0557ef1b41..ac85e6545b9 100644
--- a/openair1/SIMULATION/NR_PHY/ulschsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulschsim.c
@@ -56,6 +56,9 @@ int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
 
 void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {}
 
+uint8_t const nr_rv_round_map[4] = {0, 2, 1, 3};
+uint8_t const nr_rv_round_map_ue[4] = {0, 2, 1, 3};
+
 double cpuf;
 uint8_t nfapi_mode = 0;
 uint16_t NB_UE_INST = 1;
@@ -97,6 +100,8 @@ int main(int argc, char **argv)
   uint16_t nb_rb = 50;
   uint8_t Imcs = 9;
 
+  double DS_TDL = .03;
+
   cpuf = get_cpu_freq_GHz();
 
   if (load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY) == 0) {
@@ -316,13 +321,12 @@ int main(int argc, char **argv)
     snr1 = snr0 + 10;
 
   gNB2UE = new_channel_desc_scm(n_tx,
-		                        n_rx,
-								channel_model,
+		                n_rx,
+				channel_model,
                                 61.44e6, //N_RB2sampling_rate(N_RB_DL),
                                 40e6, //N_RB2channel_bandwidth(N_RB_DL),
-                                0,
-								0,
-								0);
+                                DS_TDL,
+                                0,0,0);
 
   if (gNB2UE == NULL) {
     printf("Problem generating channel model. Exiting.\n");
-- 
GitLab