diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml
index ec3048c50e..ebe38363ee 100755
--- a/cmake_targets/autotests/test_case_list.xml
+++ b/cmake_targets/autotests/test_case_list.xml
@@ -436,30 +436,30 @@
(Test23: 3GPP G-FR1-A5-14, PUSCH Type B, 100 MHz BW, 30 kHz SCS, 4 RX Antennas Requirements Test),
(Test24: 3GPP G-FR1-A5-14, PUSCH Type B, 100 MHz BW, 30 kHz SCS, 8 RX Antennas Requirements Test)
nr_ulsim
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R106 -r106 -U 0,1,1,2 -z2 -s12.4 -S12.4
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R106 -r106 -U 0,1,1,2 -z4 -s8.5 -S8.5
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R106 -r106 -U 0,1,1,2 -z8 -s5.4 -S5.4
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 0 -m20 -R25 -r25 -U 1,1,1,2 -z2 -s12.5 -S12.5
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 0 -m20 -R25 -r25 -U 1,1,1,2 -z4 -s8.9 -S8.9
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 0 -m20 -R25 -r25 -U 1,1,1,2 -z8 -s5.7 -S5.7
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 0 -m20 -R52 -r52 -U 1,1,1,2 -z2 -s12.6 -S12.6
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 0 -m20 -R52 -r52 -U 1,1,1,2 -z4 -s8.9 -S8.9
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 0 -m20 -R52 -r52 -U 1,1,1,2 -z8 -s5.8 -S5.8
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 0 -m20 -R106 -r106 -U 1,1,1,2 -z2 -s12.3 -S12.3
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 0 -m20 -R106 -r106 -U 1,1,1,2 -z4 -s8.8 -S8.8
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 0 -m20 -R106 -r106 -U 1,1,1,2 -z8 -s5.7 -S5.7
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R24 -r24 -U 1,1,1,2 -z2 -s12.5 -S12.5
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R24 -r24 -U 1,1,1,2 -z4 -s8.6 -S8.6
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R24 -r24 -U 1,1,1,2 -z8 -s5.6 -S5.6
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R51 -r51 -U 1,1,1,2 -z2 -s12.5 -S12.5
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R51 -r51 -U 1,1,1,2 -z4 -s8.6 -S8.6
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R51 -r51 -U 1,1,1,2 -z8 -s5.6 -S5.6
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R106 -r106 -U 1,1,1,2 -z2 -s12.5 -S12.5
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R106 -r106 -U 1,1,1,2 -z4 -s8.7 -S8.7
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R106 -r106 -U 1,1,1,2 -z8 -s5.5 -S5.5
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R273 -r273 -U 1,1,1,2 -z2 -s13.1 -S13.1
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R273 -r273 -U 1,1,1,2 -z4 -s9.2 -S9.2
- -n100 -b14 -I15 -i 0,1 -g A,l -t70 -u 1 -m20 -R273 -r273 -U 1,1,1,2 -z8 -s5.9 -S5.9
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R106 -r106 -U 0,1,1,2 -z2 -s12.4 -S12.4
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R106 -r106 -U 0,1,1,2 -z4 -s8.5 -S8.5
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R106 -r106 -U 0,1,1,2 -z8 -s5.4 -S5.4
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 0 -m20 -R25 -r25 -U 1,1,1,2 -z2 -s12.5 -S12.5
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 0 -m20 -R25 -r25 -U 1,1,1,2 -z4 -s8.9 -S8.9
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 0 -m20 -R25 -r25 -U 1,1,1,2 -z8 -s5.7 -S5.7
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 0 -m20 -R52 -r52 -U 1,1,1,2 -z2 -s12.6 -S12.6
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 0 -m20 -R52 -r52 -U 1,1,1,2 -z4 -s8.9 -S8.9
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 0 -m20 -R52 -r52 -U 1,1,1,2 -z8 -s5.8 -S5.8
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 0 -m20 -R106 -r106 -U 1,1,1,2 -z2 -s12.3 -S12.3
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 0 -m20 -R106 -r106 -U 1,1,1,2 -z4 -s8.8 -S8.8
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 0 -m20 -R106 -r106 -U 1,1,1,2 -z8 -s5.7 -S5.7
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R24 -r24 -U 1,1,1,2 -z2 -s12.5 -S12.5
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R24 -r24 -U 1,1,1,2 -z4 -s8.6 -S8.6
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R24 -r24 -U 1,1,1,2 -z8 -s5.6 -S5.6
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R51 -r51 -U 1,1,1,2 -z2 -s12.5 -S12.5
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R51 -r51 -U 1,1,1,2 -z4 -s8.6 -S8.6
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R51 -r51 -U 1,1,1,2 -z8 -s5.6 -S5.6
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R106 -r106 -U 1,1,1,2 -z2 -s12.5 -S12.5
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R106 -r106 -U 1,1,1,2 -z4 -s8.7 -S8.7
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R106 -r106 -U 1,1,1,2 -z8 -s5.5 -S5.5
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R273 -r273 -U 1,1,1,2 -z2 -s13.1 -S13.1
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R273 -r273 -U 1,1,1,2 -z4 -s9.2 -S9.2
+ -n100 -b14 -I15 -i 0,1 -g A,l,10 -t70 -u 1 -m20 -R273 -r273 -U 1,1,1,2 -z8 -s5.9 -S5.9
test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 test15 test16 test17 test18 test19 test20 test21 test22 test23 test24
PUSCH test OK
segmentation fault|assertion|exiting|fatal
diff --git a/common/utils/nr/nr_common.c b/common/utils/nr/nr_common.c
index 5a5ab83420..d8398def67 100644
--- a/common/utils/nr/nr_common.c
+++ b/common/utils/nr/nr_common.c
@@ -135,7 +135,7 @@ uint16_t get_band(uint64_t downlink_frequency, int32_t delta_duplex)
const uint64_t dl_freq_khz = downlink_frequency / 1000;
const int32_t delta_duplex_khz = delta_duplex / 1000;
- uint64_t center_freq_diff_khz = 999999999999999999; // 2^64
+ uint64_t center_freq_diff_khz = UINT64_MAX; // 2^64
uint16_t current_band = 0;
for (int ind = 0; ind < sizeofArray(nr_bandtable); ind++) {
diff --git a/openair1/PHY/TOOLS/tools_defs.h b/openair1/PHY/TOOLS/tools_defs.h
index 3d417f1c2d..62945456c3 100644
--- a/openair1/PHY/TOOLS/tools_defs.h
+++ b/openair1/PHY/TOOLS/tools_defs.h
@@ -139,6 +139,13 @@ extern "C" {
};
}
+ __attribute__((always_inline)) inline cd_t cdMul(const cd_t a, const cd_t b)
+ {
+ return (cd_t) {
+ .r = a.r * b.r - a.i * b.i,
+ .i = a.r * b.i + a.i * b.r
+ };
+ }
// On N complex numbers
// y.r += (x * alpha.r) >> 14
diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c
index 5da6a3cde7..dcaff8f088 100644
--- a/openair1/SIMULATION/LTE_PHY/dlsim.c
+++ b/openair1/SIMULATION/LTE_PHY/dlsim.c
@@ -1190,8 +1190,10 @@ int main(int argc, char **argv) {
UE->frame_parms.nb_antennas_rx,
channel_model,
N_RB2sampling_rate(eNB->frame_parms.N_RB_DL),
+ 0,
N_RB2channel_bandwidth(eNB->frame_parms.N_RB_DL),
DS_TDL,
+ 0.0,
CORR_LEVEL_LOW,
forgetting_factor,
rx_sample_offset,
@@ -1206,8 +1208,10 @@ int main(int argc, char **argv) {
UE->frame_parms.nb_antennas_rx,
channel_model,
N_RB2sampling_rate(eNB->frame_parms.N_RB_DL),
+ 0,
N_RB2channel_bandwidth(eNB->frame_parms.N_RB_DL),
DS_TDL,
+ 0.0,
CORR_LEVEL_LOW,
forgetting_factor,
rx_sample_offset,
diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c
index 5db449e4b9..3d13a4244f 100644
--- a/openair1/SIMULATION/LTE_PHY/ulsim.c
+++ b/openair1/SIMULATION/LTE_PHY/ulsim.c
@@ -739,15 +739,15 @@ int main(int argc, char **argv) {
n_rx,
channel_model,
N_RB2sampling_rate(eNB->frame_parms.N_RB_UL),
+ 0,
N_RB2channel_bandwidth(eNB->frame_parms.N_RB_UL),
30e-9,
+ maxDoppler,
CORR_LEVEL_LOW,
forgetting_factor,
delay,
0,
0);
- // set Doppler
- UE2eNB->max_Doppler = maxDoppler;
// NN: N_RB_UL has to be defined in ulsim
for (int k=0; kulsch[k] = new_eNB_ulsch(max_turbo_iterations,N_RB_DL,0);
diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c
index 04c203b594..518a655f19 100644
--- a/openair1/SIMULATION/NR_PHY/dlschsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlschsim.c
@@ -334,10 +334,14 @@ int main(int argc, char **argv)
if (ouput_vcd)
vcd_signal_dumper_init("/tmp/openair_dump_nr_dlschsim.vcd");
- gNB2UE = new_channel_desc_scm(n_tx, n_rx, channel_model,
+ gNB2UE = new_channel_desc_scm(n_tx,
+ n_rx,
+ channel_model,
61.44e6, //N_RB2sampling_rate(N_RB_DL),
+ 0,
40e6, //N_RB2channel_bandwidth(N_RB_DL),
DS_TDL,
+ 0.0,
CORR_LEVEL_LOW,
0,
0,
diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c
index 663759aeee..b9deeadfd8 100644
--- a/openair1/SIMULATION/NR_PHY/dlsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlsim.c
@@ -901,8 +901,10 @@ int main(int argc, char **argv)
n_rx,
channel_model,
fs/1e6,//sampling frequency in MHz
+ 0,
txbw,
30e-9,
+ 0.0,
CORR_LEVEL_LOW,
0,
0,
diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c
index 1985e70e26..16396de9eb 100644
--- a/openair1/SIMULATION/NR_PHY/pbchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pbchsim.c
@@ -532,8 +532,10 @@ int main(int argc, char **argv)
n_rx,
channel_model,
fs,
+ 0,
bw,
300e-9,
+ 0.0,
CORR_LEVEL_LOW,
0,
0,
diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c
index 982e5b4136..6df4896bc5 100644
--- a/openair1/SIMULATION/NR_PHY/prachsim.c
+++ b/openair1/SIMULATION/NR_PHY/prachsim.c
@@ -729,8 +729,10 @@ int main(int argc, char **argv){
gNB->frame_parms.nb_antennas_rx,
channel_model,
fs,
+ 0,
bw,
DS_TDL,
+ 0.0,
CORR_LEVEL_LOW,
0.0,
delay,
diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c
index d3f7ef5c7b..3f0e493f3e 100644
--- a/openair1/SIMULATION/NR_PHY/pucchsim.c
+++ b/openair1/SIMULATION/NR_PHY/pucchsim.c
@@ -421,7 +421,7 @@ int main(int argc, char **argv)
&txbw,
&rxbw);
- UE2gNB = new_channel_desc_scm(n_tx, n_rx, channel_model, fs, txbw, DS_TDL, CORR_LEVEL_LOW, 0, 0, 0, 0);
+ UE2gNB = new_channel_desc_scm(n_tx, n_rx, channel_model, fs, 0, txbw, DS_TDL, 0.0, CORR_LEVEL_LOW, 0, 0, 0, 0);
if (UE2gNB==NULL) {
printf("Problem generating channel model. Exiting.\n");
diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c
index ac7b9b5c48..27f21515cc 100644
--- a/openair1/SIMULATION/NR_PHY/ulschsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulschsim.c
@@ -381,8 +381,10 @@ int main(int argc, char **argv)
n_rx,
channel_model,
61.44e6, //N_RB2sampling_rate(N_RB_DL),
+ 0,
40e6, //N_RB2channel_bandwidth(N_RB_DL),
DS_TDL,
+ 0.0,
CORR_LEVEL_LOW,
0,
0,
diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c
index 5a3be4306d..5a99f2c4ce 100644
--- a/openair1/SIMULATION/NR_PHY/ulsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulsim.c
@@ -435,6 +435,10 @@ int main(int argc, char **argv)
}
}
+ if (optarg[3] == ',') {
+ maxDoppler = atoi(&optarg[4]);
+ printf("Maximum Doppler Frequency: %.0f Hz\n", maxDoppler);
+ }
break;
case 'i':
@@ -621,7 +625,7 @@ int main(int argc, char **argv)
//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 Channel model configuration. Arguments list: Number of arguments = 2, {Channel model: [A] TDLA30, [B] TDLB100, [C] TDLC300}, {Correlation: [l] Low, [m] Medium, [h] High}, e.g. -g A,l\n");
+ printf("-g Channel model configuration. Arguments list: Number of arguments = 3, {Channel model: [A] TDLA30, [B] TDLB100, [C] TDLC300}, {Correlation: [l] Low, [m] Medium, [h] High}, {Maximum Doppler shift} e.g. -g A,l,10\n");
printf("-h This message\n");
printf("-i Change channel estimation technique. Arguments list: Number of arguments=2, Frequency domain {0:Linear interpolation, 1:PRB based averaging}, Time domain {0:Estimates of last DMRS symbol, 1:Average of DMRS symbols}. e.g. -i 1,0\n");
//printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n");
@@ -683,26 +687,6 @@ int main(int argc, char **argv)
&tx_bandwidth,
&rx_bandwidth);
- LOG_I( PHY,"++++++++++++++++++++++++++++++++++++++++++++++%i+++++++++++++++++++++++++++++++++++++++++",loglvl);
-
- UE2gNB = new_channel_desc_scm(n_tx,
- n_rx, channel_model,
- sampling_frequency/1e6,
- tx_bandwidth,
- DS_TDL,
- corr_level,
- 0,
- 0,
- 0,
- 0);
-
- if (UE2gNB == NULL) {
- printf("Problem generating channel model. Exiting.\n");
- exit(-1);
- }
-
- UE2gNB->max_Doppler = maxDoppler;
-
RC.gNB = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *));
RC.gNB[0] = calloc(1,sizeof(PHY_VARS_gNB));
gNB = RC.gNB[0];
@@ -809,8 +793,27 @@ int main(int argc, char **argv)
NR_BWP_Uplink_t *ubwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[0];
+ // Configure channel model
+ UE2gNB = new_channel_desc_scm(n_tx,
+ n_rx,
+ channel_model,
+ sampling_frequency / 1e6,
+ frame_parms->ul_CarrierFreq,
+ tx_bandwidth,
+ DS_TDL,
+ maxDoppler,
+ corr_level,
+ 0,
+ 0,
+ 0,
+ 0);
- //configure UE
+ if (UE2gNB == NULL) {
+ printf("Problem generating channel model. Exiting.\n");
+ exit(-1);
+ }
+
+ // Configure UE
UE = malloc(sizeof(PHY_VARS_NR_UE));
memset((void*)UE,0,sizeof(PHY_VARS_NR_UE));
PHY_vars_UE_g = malloc(sizeof(PHY_VARS_NR_UE**));
@@ -1290,11 +1293,7 @@ int main(int argc, char **argv)
}
}
- if (UE2gNB->max_Doppler == 0) {
- multipath_channel(UE2gNB, s_re, s_im, r_re, r_im, slot_length, 0, (n_trials==1)?1:0);
- } else {
- multipath_tv_channel(UE2gNB, s_re, s_im, r_re, r_im, 2*slot_length, 0);
- }
+ multipath_channel(UE2gNB, s_re, s_im, r_re, r_im, slot_length, 0, (n_trials == 1) ? 1 : 0);
add_noise(rxdata, (const double **) r_re, (const double **) r_im, sigma, slot_length, slot_offset, ts, delay, pdu_bit_map, frame_parms->nb_antennas_rx);
} /*End input_fd */
diff --git a/openair1/SIMULATION/TOOLS/multipath_channel.c b/openair1/SIMULATION/TOOLS/multipath_channel.c
index 992c6be461..4330219706 100644
--- a/openair1/SIMULATION/TOOLS/multipath_channel.c
+++ b/openair1/SIMULATION/TOOLS/multipath_channel.c
@@ -29,6 +29,7 @@
#include "sim.h"
//#define DEBUG_CH
+//#define DOPPLER_DEBUG
uint8_t multipath_channel_nosigconv(channel_desc_t *desc)
{
@@ -201,11 +202,16 @@ void __attribute__ ((no_sanitize_address)) multipath_channel(channel_desc_t *des
}
#endif
+ struct complexd cexp_doppler[length];
+ if (desc->max_Doppler != 0.0) {
+ get_cexp_doppler(cexp_doppler, desc, length);
+ }
+
for (int i=0; i<((int)length-dd); i++) {
for (int ii=0; iinb_rx; ii++) {
struct complexd rx_tmp={0};
for (int j=0; jnb_tx; j++) {
- struct complexd *chan=desc->ch[ii+(j*desc->nb_rx)];
+ struct complexd *chan=desc->ch[ii+(j*desc->nb_rx)];
for (int l = 0; l<(int)desc->channel_length; l++) {
if ((i>=0) && (i-l)>=0) {
struct complexd tx;
@@ -215,14 +221,23 @@ void __attribute__ ((no_sanitize_address)) multipath_channel(channel_desc_t *des
rx_tmp.i += (tx.i * chan[l].r) + (tx.r * chan[l].i);
}
if (i==0 && log_channel == 1) {
- printf("channel[%d][%d][%d] = %f dB \t(%e, %e)\n",
- ii, j, l, 10*log10(pow(chan[l].r,2.0)+pow(chan[l].i,2.0)),
- chan[l].r,
- chan[l].i);
+ printf("channel[%d][%d][%d] = %f dB \t(%e, %e)\n",
+ ii, j, l, 10 * log10(pow(chan[l].r, 2.0) + pow(chan[l].i, 2.0)), chan[l].r, chan[l].i);
}
} //l
} // j
+ if (desc->max_Doppler != 0.0)
+ rx_tmp = cdMul(rx_tmp, cexp_doppler[i]);
+
+#ifdef DOPPLER_DEBUG
+ printf("[k %2i] cexp_doppler = (%7.4f, %7.4f), abs(cexp_doppler) = %.4f\n",
+ i,
+ cexp_doppler[i].r,
+ cexp_doppler[i].i,
+ sqrt(cexp_doppler[i].r * cexp_doppler[i].r + cexp_doppler[i].i * cexp_doppler[i].i));
+#endif
+
rx_sig_re[ii][i+dd] = rx_tmp.r*path_loss;
rx_sig_im[ii][i+dd] = rx_tmp.i*path_loss;
#ifdef DEBUG_CH
diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c
index 39c5e5f564..d1c06e22c8 100644
--- a/openair1/SIMULATION/TOOLS/random_channel.c
+++ b/openair1/SIMULATION/TOOLS/random_channel.c
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
#include "PHY/TOOLS/tools_defs.h"
@@ -37,6 +38,7 @@
//#define DEBUG_CH
//#define DEBUG_CH_POWER
+//#define DOPPLER_DEBUG
#include "assertions.h"
@@ -451,6 +453,43 @@ void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS
}
}
+void get_cexp_doppler(struct complexd *cexp_doppler, channel_desc_t *chan_desc, const uint32_t length)
+{
+ // TS 38.104 - Table G.3-1
+ uint16_t Dmin = 2;
+ uint16_t Ds = 300;
+ double c = 299792458;
+ double v = chan_desc->max_Doppler * (c / (double)chan_desc->center_freq);
+
+#ifdef DOPPLER_DEBUG
+ printf("v = %f\n", v);
+#endif
+
+ double phase0 = 2 * M_PI * uniformrandom();
+ double cos_theta[length];
+ double fs[length];
+
+ for (uint32_t t_idx = 0; t_idx < length; t_idx++) {
+ double t = t_idx / (chan_desc->sampling_rate * 1e6);
+ if (t >= 0 && t <= Ds / v) {
+ cos_theta[t_idx] = (Ds / 2 - v * t) / sqrt(Dmin * Dmin + (Ds / 2 - v * t) * (Ds / 2 - v * t));
+ } else if (t > Ds / v && t <= 2 * Ds / v) {
+ cos_theta[t_idx] = (-1.5 * Ds + v * t) / sqrt(Dmin * Dmin + (-1.5 * Ds + v * t) * (-1.5 * Ds + v * t));
+ } else {
+ cos_theta[t_idx] = cos(fmod(t, 2 * Ds / v));
+ }
+ fs[t_idx] = chan_desc->max_Doppler * cos_theta[t_idx];
+
+ double complex tmp_cexp_doppler = cexp(I * (2 * M_PI * fs[t_idx] * t + phase0));
+ cexp_doppler[t_idx].r = creal(tmp_cexp_doppler);
+ cexp_doppler[t_idx].i = cimag(tmp_cexp_doppler);
+
+#ifdef DOPPLER_DEBUG
+ printf("(%2i) t_us = %f, cos_theta = %f, fs = %f, cexp_doppler = (%f, %f)\n", t_idx, t * 1e6, cos_theta[t_idx], fs[t_idx], cexp_doppler[t_idx].r, cexp_doppler[t_idx].i);
+#endif
+ }
+}
+
double get_normalization_ch_factor(channel_desc_t *desc)
{
if (!(desc->channel_length > 1 && desc->modelid >= TDL_A && desc->modelid <= TDL_E)) {
@@ -521,18 +560,20 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
uint8_t nb_rx,
SCM_t channel_model,
double sampling_rate,
+ uint64_t center_freq,
double channel_bandwidth,
double DS_TDL,
+ double maxDoppler,
const corr_level_t corr_level,
double forgetting_factor,
int32_t channel_offset,
double path_loss_dB,
- float noise_power_dB) {
-
+ float noise_power_dB)
+{
// To create tables for normal distribution
struct timespec t;
clock_gettime(CLOCK_MONOTONIC, &t);
- tableNor((long)(t.tv_nsec%INT_MAX));
+ tableNor((long) (t.tv_nsec % INT_MAX));
channel_desc_t *chan_desc = (channel_desc_t *)calloc(1,sizeof(channel_desc_t));
@@ -549,14 +590,16 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
uint16_t i,j;
double sum_amps;
- double aoa,ricean_factor,Td,maxDoppler;
+ double aoa, ricean_factor, Td;
int channel_length,nb_taps;
struct complexd *R_sqrt_ptr2;
chan_desc->modelid = channel_model;
chan_desc->nb_tx = nb_tx;
chan_desc->nb_rx = nb_rx;
chan_desc->sampling_rate = sampling_rate;
+ chan_desc->center_freq = center_freq;
chan_desc->channel_bandwidth = channel_bandwidth;
+ chan_desc->max_Doppler = maxDoppler;
chan_desc->corr_level = corr_level;
chan_desc->forgetting_factor = forgetting_factor;
chan_desc->channel_offset = channel_offset;
@@ -1856,6 +1899,7 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) {
#ifdef DEBUG_CH
printf("(%d,%d,%d)->(%e,%e)\n",k,aarx,aatx,desc->ch[aarx+(aatx*desc->nb_rx)][k].r,desc->ch[aarx+(aatx*desc->nb_rx)][k].i);
#endif
+
} //channel_length
#ifdef DEBUG_CH_POWER
ch_power_count++;
@@ -2123,8 +2167,10 @@ int load_channellist(uint8_t nb_tx, uint8_t nb_rx, double sampling_rate, double
nb_rx,
modid,
sampling_rate,
+ 0,
channel_bandwidth,
*(channel_list.paramarray[i][pindex_DT].dblptr),
+ 0.0,
CORR_LEVEL_LOW,
*(channel_list.paramarray[i][pindex_FF].dblptr),
*(channel_list.paramarray[i][pindex_CO].iptr),
diff --git a/openair1/SIMULATION/TOOLS/sim.h b/openair1/SIMULATION/TOOLS/sim.h
index 1e2602650f..92c11c8da5 100644
--- a/openair1/SIMULATION/TOOLS/sim.h
+++ b/openair1/SIMULATION/TOOLS/sim.h
@@ -80,6 +80,8 @@ typedef struct {
struct complexd **chF;
///Maximum path delay in mus.
double Td;
+ ///Carrier center frequency
+ uint64_t center_freq;
///Channel bandwidth in MHz.
double channel_bandwidth;
///System sampling rate in Msps.
@@ -315,8 +317,10 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
uint8_t nb_rx,
SCM_t channel_model,
double sampling_rate,
+ uint64_t center_freq,
double channel_bandwidth,
double DS_TDL,
+ double maxDoppler,
const corr_level_t corr_level,
double forgetting_factor,
int32_t channel_offset,
@@ -344,6 +348,15 @@ void set_channeldesc_owner(channel_desc_t *cdesc, channelmod_moduleid_t module_i
\param module_name is the C string to use as model name for the channel pointed by cdesc
*/
void set_channeldesc_name(channel_desc_t *cdesc,char *modelname);
+
+/** \fn void get_cexp_doppler(struct complexd *cexp_doppler, channel_desc_t *chan_desc, const uint32_t length)
+\brief This routine generates the complex exponential to apply the Doppler shift
+\param cexp_doppler Output with the complex exponential of Doppler shift
+\param desc Pointer to the channel descriptor
+\param length Size of complex exponential of Doppler shift
+*/
+void get_cexp_doppler(struct complexd *cexp_doppler, channel_desc_t *chan_desc, const uint32_t length);
+
/** \fn void random_channel(channel_desc_t *desc)
\brief This routine generates a random channel response (time domain) according to a tapped delay line model.
\param desc Pointer to the channel descriptor
diff --git a/radio/rfsimulator/simulator.c b/radio/rfsimulator/simulator.c
index 48a78448ed..b98e7a6172 100644
--- a/radio/rfsimulator/simulator.c
+++ b/radio/rfsimulator/simulator.c
@@ -341,17 +341,19 @@ static int rfsimu_setchanmod_cmd(char *buff, int debug, telnet_printfunc_t prnt,
if (b->channel_model->model_name==NULL)
continue;
if (b->conn_sock >= 0 && (strcmp(b->channel_model->model_name,modelname)==0)) {
-
- channel_desc_t *newmodel=new_channel_desc_scm(t->tx_num_channels,t->rx_num_channels,
- channelmod,
- t->sample_rate,
- t->tx_bw,
- 30e-9, // TDL delay-spread parameter
- CORR_LEVEL_LOW,
- t->chan_forgetfact, // forgetting_factor
- t->chan_offset, // maybe used for TA
- t->chan_pathloss,
- t->noise_power_dB); // path_loss in dB
+ channel_desc_t *newmodel = new_channel_desc_scm(t->tx_num_channels,
+ t->rx_num_channels,
+ channelmod,
+ t->sample_rate,
+ 0,
+ t->tx_bw,
+ 30e-9, // TDL delay-spread parameter
+ 0.0,
+ CORR_LEVEL_LOW,
+ t->chan_forgetfact, // forgetting_factor
+ t->chan_offset, // maybe used for TA
+ t->chan_pathloss,
+ t->noise_power_dB); // path_loss in dB
set_channeldesc_owner(newmodel, RFSIMU_MODULEID);
set_channeldesc_name(newmodel,modelname);
random_channel(newmodel,false);