From 5c30151d28f1ac3d2f14202e1ada2ad5559d0317 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger <florian.kaltenberger@eurecom.fr> Date: Tue, 13 Oct 2015 23:29:07 +0200 Subject: [PATCH] fixes issue 40 --- openair1/PHY/LTE_TRANSPORT/proto.h | 7 +- openair1/SIMULATION/LTE_PHY/dlsim.c | 20 +-- openair1/SIMULATION/LTE_PHY/mbmssim.c | 26 +--- openair1/SIMULATION/LTE_PHY/pbchsim.c | 12 +- openair1/SIMULATION/LTE_PHY/pdcchsim.c | 22 +-- openair1/SIMULATION/LTE_PHY/prachsim.c | 5 +- openair1/SIMULATION/LTE_PHY/pucchsim.c | 5 +- openair1/SIMULATION/LTE_PHY/ulsim.c | 26 +--- openair1/SIMULATION/TOOLS/abstraction.c | 2 +- openair1/SIMULATION/TOOLS/defs.h | 11 +- .../SIMULATION/TOOLS/multipath_tv_channel.c | 8 +- openair1/SIMULATION/TOOLS/random_channel.c | 127 ++++++++++++++---- targets/SIMU/USER/channel_sim.c | 8 +- targets/SIMU/USER/oaisim_functions.c | 32 +++-- targets/SIMU/USER/sinr_sim.c | 6 +- 15 files changed, 168 insertions(+), 149 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index eb32aab24e8..98911284567 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -72,8 +72,11 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint8_t N_RB_DL, ui */ void free_ue_dlsch(LTE_UE_DLSCH_t *dlsch); +LTE_eNB_ULSCH_t *new_eNB_ulsch(uint8_t Mdlharq,uint8_t max_turbo_iterations,uint8_t N_RB_UL, uint8_t abstraction_flag); + LTE_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint8_t max_turbo_iterations,uint8_t N_RB_DL, uint8_t abstraction_flag); +LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char Mdlharq,unsigned char N_RB_UL, uint8_t abstraction_flag); void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch, uint8_t abstraction_flag); @@ -1764,7 +1767,9 @@ double computeRhoB_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, LTE_UE_DLSCH_t *dlsch_ue); */ - uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, uint8_t tdd_mapindex, uint16_t Nf); +uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, uint8_t tdd_mapindex, uint16_t Nf); + +uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n); /**@}*/ #endif diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 28e7bc8216e..08ecfe9ddee 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -326,7 +326,7 @@ int main(int argc, char **argv) uint32_t DLSCH_RB_ALLOC = 0x1fff; int numCCE=0; int dci_length_bytes=0,dci_length=0; - double BW = 5.0; + //double channel_bandwidth = 5.0, sampling_rate=7.68; int common_flag=0,TPC=0; double cpu_freq_GHz; @@ -680,27 +680,19 @@ int main(int argc, char **argv) switch (N_RB_DL) { case 6: if (rballocset==0) DLSCH_RB_ALLOC = 0x3f; - - BW = 1.25; num_pdcch_symbols = 3; break; case 25: if (rballocset==0) DLSCH_RB_ALLOC = 0x1fff; - - BW = 5.00; break; case 50: if (rballocset==0) DLSCH_RB_ALLOC = 0x1ffff; - - BW = 10.00; break; case 100: if (rballocset==0) DLSCH_RB_ALLOC = 0x1ffffff; - - BW = 20.00; break; } @@ -708,8 +700,6 @@ int main(int argc, char **argv) } else NB_RB = 4; - NB_RB=conv_nprb(0,DLSCH_RB_ALLOC,N_RB_DL); - if ((transmission_mode > 1) && (n_tx != 2)) printf("n_tx must be >1 for transmission_mode %d\n",transmission_mode); @@ -955,7 +945,8 @@ int main(int argc, char **argv) eNB2UE[0] = new_channel_desc_scm(PHY_vars_eNB->lte_frame_parms.nb_antennas_tx, PHY_vars_UE->lte_frame_parms.nb_antennas_rx, channel_model, - BW, + N_RB2sampling_rate(PHY_vars_eNB->lte_frame_parms.N_RB_DL), + N_RB2channel_bandwidth(PHY_vars_eNB->lte_frame_parms.N_RB_DL), forgetting_factor, rx_sample_offset, 0); @@ -965,8 +956,9 @@ int main(int argc, char **argv) eNB2UE[n] = new_channel_desc_scm(PHY_vars_eNB->lte_frame_parms.nb_antennas_tx, PHY_vars_UE->lte_frame_parms.nb_antennas_rx, channel_model, - BW, - forgetting_factor, + N_RB2sampling_rate(PHY_vars_eNB->lte_frame_parms.N_RB_DL), + N_RB2channel_bandwidth(PHY_vars_eNB->lte_frame_parms.N_RB_DL), + forgetting_factor, rx_sample_offset, 0); } diff --git a/openair1/SIMULATION/LTE_PHY/mbmssim.c b/openair1/SIMULATION/LTE_PHY/mbmssim.c index 862edaa8644..0c313655873 100644 --- a/openair1/SIMULATION/LTE_PHY/mbmssim.c +++ b/openair1/SIMULATION/LTE_PHY/mbmssim.c @@ -54,8 +54,6 @@ #include "OCG_vars.h" -//#define BW 5.0 - PHY_VARS_eNB *PHY_vars_eNB; PHY_VARS_UE *PHY_vars_UE; @@ -172,7 +170,6 @@ int main(int argc, char **argv) unsigned int trials,errs[4]= {0,0,0,0}; //,round_trials[4]={0,0,0,0}; uint8_t N_RB_DL=25,osf=1; - double BW=5.0; uint32_t perfect_ce = 0; lte_frame_type_t frame_type = FDD; @@ -255,27 +252,9 @@ int main(int argc, char **argv) case 'R': N_RB_DL = atoi(optarg); - switch (N_RB_DL) { - case 6: - BW=1.25; - break; - - case 25: - BW=5.0; - break; - - case 50: - BW=10.0; - break; - - case 100: - BW=20.0; - break; - - default: + if ((N_RB_DL!=6) && (N_RB_DL!=25) && (N_RB_DL!=50) && (N_RB_DL!=100)) { printf("Unsupported Bandwidth %d\n",N_RB_DL); exit(-1); - break; } break; @@ -397,7 +376,8 @@ int main(int argc, char **argv) eNB2UE = new_channel_desc_scm(PHY_vars_eNB->lte_frame_parms.nb_antennas_tx, PHY_vars_UE->lte_frame_parms.nb_antennas_rx, channel_model, - BW, + N_RB2sampling_rate(PHY_vars_eNB->lte_frame_parms.N_RB_DL), + N_RB2channel_bandwidth(PHY_vars_eNB->lte_frame_parms.N_RB_DL), 0, 0, 0); diff --git a/openair1/SIMULATION/LTE_PHY/pbchsim.c b/openair1/SIMULATION/LTE_PHY/pbchsim.c index 5aa3fac9974..b7f9f57b6bb 100644 --- a/openair1/SIMULATION/LTE_PHY/pbchsim.c +++ b/openair1/SIMULATION/LTE_PHY/pbchsim.c @@ -53,9 +53,6 @@ #include "OCG_vars.h" -#define BW 5.0 - - PHY_VARS_eNB *PHY_vars_eNb,*PHY_vars_eNb1,*PHY_vars_eNb2; PHY_VARS_UE *PHY_vars_UE; @@ -485,7 +482,8 @@ int main(int argc, char **argv) eNB2UE = new_channel_desc_scm(PHY_vars_eNb->lte_frame_parms.nb_antennas_tx, PHY_vars_UE->lte_frame_parms.nb_antennas_rx, channel_model, - BW, + N_RB2sampling_rate(PHY_vars_eNb->lte_frame_parms.N_RB_DL), + N_RB2channel_bandwidth(PHY_vars_eNb->lte_frame_parms.N_RB_DL), 0, 0, 0); @@ -494,7 +492,8 @@ int main(int argc, char **argv) eNB2UE1 = new_channel_desc_scm(PHY_vars_eNb->lte_frame_parms.nb_antennas_tx, PHY_vars_UE->lte_frame_parms.nb_antennas_rx, channel_model, - BW, + N_RB2sampling_rate(PHY_vars_eNb->lte_frame_parms.N_RB_DL), + N_RB2channel_bandwidth(PHY_vars_eNb->lte_frame_parms.N_RB_DL), 0, 4, 0); @@ -503,7 +502,8 @@ int main(int argc, char **argv) eNB2UE2 = new_channel_desc_scm(PHY_vars_eNb->lte_frame_parms.nb_antennas_tx, PHY_vars_UE->lte_frame_parms.nb_antennas_rx, channel_model, - BW, + N_RB2sampling_rate(PHY_vars_eNb->lte_frame_parms.N_RB_DL), + N_RB2channel_bandwidth(PHY_vars_eNb->lte_frame_parms.N_RB_DL), 0, 8, 0); diff --git a/openair1/SIMULATION/LTE_PHY/pdcchsim.c b/openair1/SIMULATION/LTE_PHY/pdcchsim.c index caa7e1248d4..7a361329806 100644 --- a/openair1/SIMULATION/LTE_PHY/pdcchsim.c +++ b/openair1/SIMULATION/LTE_PHY/pdcchsim.c @@ -552,7 +552,6 @@ int main(int argc, char **argv) uint32_t *txptr; int aarx; int k; - double BW=5.0; uint32_t perfect_ce = 0; number_of_cards = 1; @@ -840,28 +839,11 @@ int main(int argc, char **argv) subframe,NUMBER_OF_OFDM_CARRIERS, PHY_vars_eNB->lte_frame_parms.Ncp,PHY_vars_eNB->lte_frame_parms.samples_per_tti,nsymb); - switch (N_RB_DL) { - case 6: - BW = 1.25; - break; - - case 25: - BW = 5.00; - break; - - case 50: - BW = 10.00; - break; - - case 100: - BW = 20.00; - break; - } - eNB2UE = new_channel_desc_scm(PHY_vars_eNB->lte_frame_parms.nb_antennas_tx_eNB, PHY_vars_UE->lte_frame_parms.nb_antennas_rx, channel_model, - BW, + N_RB2sampling_rate(PHY_vars_eNB->lte_frame_parms.N_RB_DL), + N_RB2channel_bandwidth(PHY_vars_eNB->lte_frame_parms.N_RB_DL), 0, 0, 0); diff --git a/openair1/SIMULATION/LTE_PHY/prachsim.c b/openair1/SIMULATION/LTE_PHY/prachsim.c index eeca52a274d..4df53b053f9 100644 --- a/openair1/SIMULATION/LTE_PHY/prachsim.c +++ b/openair1/SIMULATION/LTE_PHY/prachsim.c @@ -47,8 +47,6 @@ #include "OCG_vars.h" -#define BW 5.0 - int current_dlsch_cqi; //FIXME! PHY_VARS_eNB *PHY_vars_eNB; @@ -412,7 +410,8 @@ int main(int argc, char **argv) UE2eNB = new_channel_desc_scm(PHY_vars_UE->lte_frame_parms.nb_antennas_tx, PHY_vars_eNB->lte_frame_parms.nb_antennas_rx, channel_model, - BW, + N_RB2sampling_rate(PHY_vars_eNB->lte_frame_parms.N_RB_UL), + N_RB2channel_bandwidth(PHY_vars_eNB->lte_frame_parms.N_RB_UL), 0.0, delay, 0); diff --git a/openair1/SIMULATION/LTE_PHY/pucchsim.c b/openair1/SIMULATION/LTE_PHY/pucchsim.c index 919bec144dd..d9a3367b902 100644 --- a/openair1/SIMULATION/LTE_PHY/pucchsim.c +++ b/openair1/SIMULATION/LTE_PHY/pucchsim.c @@ -49,8 +49,6 @@ #include "OCG_vars.h" #include "UTIL/LOG/log_extern.h" -#define BW 5.0 - int current_dlsch_cqi; //FIXME! PHY_VARS_eNB *PHY_vars_eNB; @@ -418,7 +416,8 @@ int main(int argc, char **argv) UE2eNB = new_channel_desc_scm(PHY_vars_eNB->lte_frame_parms.nb_antennas_tx, PHY_vars_UE->lte_frame_parms.nb_antennas_rx, channel_model, - BW, + N_RB2sampling_rate(PHY_vars_eNB->lte_frame_parms.N_RB_UL), + N_RB2channel_bandwidth(PHY_vars_eNB->lte_frame_parms.N_RB_UL), 0.0, 0, 0); diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index dd697899b8c..42cbb72244c 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -58,23 +58,11 @@ extern unsigned short dftsizes[33]; extern short *ul_ref_sigs[30][2][33]; -//#define AWGN -//#define NO_DCI - -#define BW 7.68 -//#define ABSTRACTION -//#define PERFECT_CE - -/* - #define RBmask0 0x00fc00fc - #define RBmask1 0x0 - #define RBmask2 0x0 - #define RBmask3 0x0 -*/ + PHY_VARS_eNB *PHY_vars_eNB; PHY_VARS_UE *PHY_vars_UE; -#define MCS_COUNT 23//added for PHY abstraction +//#define MCS_COUNT 23//added for PHY abstraction channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX]; channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX]; @@ -155,11 +143,6 @@ void lte_param_init(unsigned char N_tx, unsigned char N_rx,unsigned char transmi -#define UL_RB_ALLOC 0x1ff; - - - - int main(int argc, char **argv) { @@ -172,8 +155,6 @@ int main(int argc, char **argv) double input_snr_step=.2,snr_int=30; double blerr; - //int **txdataF, **txdata; - int **txdata; LTE_DL_FRAME_PARMS *frame_parms; @@ -680,7 +661,8 @@ int main(int argc, char **argv) UE2eNB = new_channel_desc_scm(PHY_vars_eNB->lte_frame_parms.nb_antennas_tx, PHY_vars_UE->lte_frame_parms.nb_antennas_rx, channel_model, - BW, + N_RB2sampling_rate(PHY_vars_eNB->lte_frame_parms.N_RB_UL), + N_RB2channel_bandwidth(PHY_vars_eNB->lte_frame_parms.N_RB_UL), forgetting_factor, delay, 0); diff --git a/openair1/SIMULATION/TOOLS/abstraction.c b/openair1/SIMULATION/TOOLS/abstraction.c index d63d0b0fe9c..3720d9f9989 100644 --- a/openair1/SIMULATION/TOOLS/abstraction.c +++ b/openair1/SIMULATION/TOOLS/abstraction.c @@ -73,7 +73,7 @@ void init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) if (desc->nb_taps==1) delay = desc->delays[l]; else - delay = desc->delays[l]+NB_SAMPLES_CHANNEL_OFFSET/desc->BW; + delay = desc->delays[l]+NB_SAMPLES_CHANNEL_OFFSET/desc->sampling_rate; cos_lut[f+(n_samples>>1)][l] = cos(2*M_PI*freq*delay); sin_lut[f+(n_samples>>1)][l] = sin(2*M_PI*freq*delay); diff --git a/openair1/SIMULATION/TOOLS/defs.h b/openair1/SIMULATION/TOOLS/defs.h index 187ffcb241b..0dfea70b890 100644 --- a/openair1/SIMULATION/TOOLS/defs.h +++ b/openair1/SIMULATION/TOOLS/defs.h @@ -69,7 +69,9 @@ typedef struct { ///Maximum path delay in mus. double Td; ///Channel bandwidth in MHz. - double BW; + double channel_bandwidth; + ///System sampling rate in Msps. + double sampling_rate; ///Ricean factor of first tap wrt other taps (0..1, where 0 means AWGN and 1 means Rayleigh channel). double ricean_factor; ///Angle of arrival of wavefront (in radians). For Ricean channel only. This assumes that both RX and TX have linear antenna arrays with lambda/2 antenna spacing. Furhter it is assumed that the arrays are parallel to each other and that they are far enough apart so that we can safely assume plane wave propagation. @@ -202,7 +204,8 @@ typedef enum { channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, uint8_t nb_rx, SCM_t channel_model, - double BW, + double sampling_rate, + double channel_bandwidth, double forgetting_factor, int32_t channel_offset, double path_loss_dB); @@ -364,6 +367,10 @@ void multipath_tv_channel(channel_desc_t *desc, /**@} */ /**@} */ + +double N_RB2sampling_rate(uint16_t N_RB); +double N_RB2channel_bandwidth(uint16_t N_RB); + #endif diff --git a/openair1/SIMULATION/TOOLS/multipath_tv_channel.c b/openair1/SIMULATION/TOOLS/multipath_tv_channel.c index b1bd091ca7e..3568545f299 100644 --- a/openair1/SIMULATION/TOOLS/multipath_tv_channel.c +++ b/openair1/SIMULATION/TOOLS/multipath_tv_channel.c @@ -175,13 +175,13 @@ void tv_channel(channel_desc_t *desc,double complex ***H,uint16_t length) { for(p=0;p<desc->nb_paths;p++) { - H[i][j] += sqrt(desc->amps[j]/2)*alpha[p]*cexp(-I*(2*pi*w_Hz[p]*i*(1/(desc->BW*1e6))+phi_rad[p])); + H[i][j] += sqrt(desc->amps[j]/2)*alpha[p]*cexp(-I*(2*pi*w_Hz[p]*i*(1/(desc->sampling_rate*1e6))+phi_rad[p])); } } } for(j=0;j<desc->nb_paths;j++) { - phi_rad[j] = fmod(2*pi*w_Hz[j]*(length-1)*(1/desc->BW)+phi_rad[j],2*pi); + phi_rad[j] = fmod(2*pi*w_Hz[j]*(length-1)*(1/desc->sampling_rate)+phi_rad[j],2*pi); } */ @@ -193,13 +193,13 @@ void tv_channel(channel_desc_t *desc,double complex ***H,uint16_t length) H[i+(j*desc->nb_rx)][k][l] = 0; for(p=0; p<desc->nb_paths; p++) { - H[i+(j*desc->nb_rx)][k][l] += sqrt(desc->amps[l]/2)*alpha[p]*cexp(I*(2*pi*w_Hz[p]*k*(1/(desc->BW*1e6))+phi_rad[p])); + H[i+(j*desc->nb_rx)][k][l] += sqrt(desc->amps[l]/2)*alpha[p]*cexp(I*(2*pi*w_Hz[p]*k*(1/(desc->sampling_rate*1e6))+phi_rad[p])); } } } for(j=0; j<desc->nb_paths; j++) { - phi_rad[j] = fmod(2*pi*w_Hz[j]*(length-1)*(1/desc->BW)+phi_rad[j],2*pi); + phi_rad[j] = fmod(2*pi*w_Hz[j]*(length-1)*(1/desc->sampling_rate)+phi_rad[j],2*pi); } } } diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index 9233d94132c..417ff291627 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -48,7 +48,8 @@ void fill_channel_desc(channel_desc_t *chan_desc, double *delays, struct complex** R_sqrt, double Td, - double BW, + double sampling_rate, + double channel_bandwidth, double ricean_factor, double aoa, double forgetting_factor, @@ -81,7 +82,8 @@ void fill_channel_desc(channel_desc_t *chan_desc, chan_desc->delays = delays; chan_desc->Td = Td; - chan_desc->BW = BW; + chan_desc->sampling_rate = sampling_rate; + chan_desc->channel_bandwidth = channel_bandwidth; chan_desc->ricean_factor = ricean_factor; chan_desc->aoa = aoa; chan_desc->random_aoa = random_aoa; @@ -195,7 +197,8 @@ struct complex **R_sqrt_ptr2; channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, uint8_t nb_rx, SCM_t channel_model, - double BW, + double sampling_rate, + double channel_bandwidth, double forgetting_factor, int32_t channel_offset, double path_loss_dB) @@ -209,7 +212,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, chan_desc->nb_tx = nb_tx; chan_desc->nb_rx = nb_rx; - chan_desc->BW = BW; + chan_desc->sampling_rate = sampling_rate; + chan_desc->channel_bandwidth = channel_bandwidth; chan_desc->forgetting_factor = forgetting_factor; chan_desc->channel_offset = channel_offset; chan_desc->path_loss_dB = path_loss_dB; @@ -232,7 +236,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, case SCM_C: chan_desc->nb_taps = 18; chan_desc->Td = 4.625; - chan_desc->channel_length = (int) (2*chan_desc->BW*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->BW*chan_desc->Td)); + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); sum_amps = 0; chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); @@ -291,7 +295,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, LOG_W(OCM,"This is not the real SCM-D model! It is just SCM-C with an additional Rice factor!\n"); chan_desc->nb_taps = 18; chan_desc->Td = 4.625; - chan_desc->channel_length = (int) (2*chan_desc->BW*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->BW*chan_desc->Td)); + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); sum_amps = 0; chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); @@ -349,7 +353,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, case EPA: chan_desc->nb_taps = 7; chan_desc->Td = .410; - chan_desc->channel_length = (int) (2*chan_desc->BW*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->BW*chan_desc->Td)); + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); sum_amps = 0; chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); @@ -403,7 +407,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, case EVA: chan_desc->nb_taps = 9; chan_desc->Td = 2.51; - chan_desc->channel_length = (int) (2*chan_desc->BW*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->BW*chan_desc->Td)); + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); sum_amps = 0; chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); @@ -457,7 +461,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, case ETU: chan_desc->nb_taps = 9; chan_desc->Td = 5.0; - chan_desc->channel_length = (int) (2*chan_desc->BW*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->BW*chan_desc->Td)); + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); sum_amps = 0; chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); @@ -511,7 +515,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, case MBSFN: chan_desc->nb_taps = 18; chan_desc->Td = 28.58; - chan_desc->channel_length = (int) (2*chan_desc->BW*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->BW*chan_desc->Td)); + chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); sum_amps = 0; chan_desc->amps = (double*) malloc(chan_desc->nb_taps*sizeof(double)); @@ -558,7 +562,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, case Rayleigh8: nb_taps = 8; Td = 0.8; - channel_length = (int)11+2*BW*Td; + channel_length = (int)11+2*sampling_rate*Td; ricean_factor = 1; aoa = .03; maxDoppler = 0; @@ -572,7 +576,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, NULL, NULL, Td, - BW, + sampling_rate, + channel_bandwidth, ricean_factor, aoa, forgetting_factor, @@ -585,7 +590,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, case Rice8: nb_taps = 8; Td = 0.8; - channel_length = (int)11+2*BW*Td; + channel_length = (int)11+2*sampling_rate*Td; ricean_factor = 0.1; aoa = .03; maxDoppler = 0; @@ -598,7 +603,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, NULL, NULL, Td, - BW, + sampling_rate, + channel_bandwidth, ricean_factor, aoa, forgetting_factor, @@ -624,7 +630,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, NULL, NULL, Td, - BW, + sampling_rate, + channel_bandwidth, ricean_factor, aoa, forgetting_factor, @@ -650,7 +657,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, NULL, NULL, Td, - BW, + sampling_rate, + channel_bandwidth, ricean_factor, aoa, forgetting_factor, @@ -683,7 +691,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, NULL, R_sqrt_ptr2, Td, - BW, + sampling_rate, + channel_bandwidth, ricean_factor, aoa, forgetting_factor, @@ -716,7 +725,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, NULL, R_sqrt_ptr2, Td, - BW, + sampling_rate, + channel_bandwidth, ricean_factor, aoa, forgetting_factor, @@ -742,7 +752,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, NULL, NULL, Td, - BW, + sampling_rate, + channel_bandwidth, ricean_factor, aoa, forgetting_factor, @@ -768,7 +779,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, NULL, NULL, Td, - BW, + sampling_rate, + channel_bandwidth, ricean_factor, aoa, forgetting_factor, @@ -803,7 +815,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, NULL, R_sqrt_ptr2, Td, - BW, + sampling_rate, + channel_bandwidth, ricean_factor, aoa, forgetting_factor, @@ -836,7 +849,8 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, NULL, R_sqrt_ptr2, Td, - BW, + sampling_rate, + channel_bandwidth, ricean_factor, aoa, forgetting_factor, @@ -985,11 +999,11 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) desc->ch[aarx+(aatx*desc->nb_rx)][k].y = 0.0; for (l=0; l<desc->nb_taps; l++) { - if ((k - (desc->delays[l]*desc->BW) - NB_SAMPLES_CHANNEL_OFFSET) == 0) + if ((k - (desc->delays[l]*desc->sampling_rate) - NB_SAMPLES_CHANNEL_OFFSET) == 0) s = 1.0; else - s = sin(M_PI*(k - (desc->delays[l]*desc->BW) - NB_SAMPLES_CHANNEL_OFFSET))/ - (M_PI*(k - (desc->delays[l]*desc->BW) - NB_SAMPLES_CHANNEL_OFFSET)); + s = sin(M_PI*(k - (desc->delays[l]*desc->sampling_rate) - NB_SAMPLES_CHANNEL_OFFSET))/ + (M_PI*(k - (desc->delays[l]*desc->sampling_rate) - NB_SAMPLES_CHANNEL_OFFSET)); desc->ch[aarx+(aatx*desc->nb_rx)][k].x += s*desc->a[l][aarx+(aatx*desc->nb_rx)].x; desc->ch[aarx+(aatx*desc->nb_rx)][k].y += s*desc->a[l][aarx+(aatx*desc->nb_rx)].y; @@ -1014,22 +1028,77 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) return (0); } +double N_RB2sampling_rate(uint16_t N_RB) +{ + double sampling_rate; + switch (N_RB) { + case 6: + sampling_rate = 1.92; + break; + + case 25: + sampling_rate = 7.68; + break; + + case 50: + sampling_rate = 15.36; + break; + + case 100: + sampling_rate = 30.72; + break; + + default: + LOG_E(PHY,"Unknown N_PRB\n"); + return(-1); + } + + return(sampling_rate); +} + +double N_RB2channel_bandwidth(uint16_t N_RB) +{ + double channel_bandwidth; + switch (N_RB) { + case 6: + channel_bandwidth = 1.25; + break; + + case 25: + channel_bandwidth = 5.00; + break; + + case 50: + channel_bandwidth = 10.00; + break; + + case 100: + channel_bandwidth = 20.00; + break; + + default: + LOG_E(PHY,"Unknown N_PRB\n"); + return(-1); + } + return(channel_bandwidth); +} + #ifdef RANDOM_CHANNEL_MAIN -#define BW 5.0 +#define sampling_rate 5.0 #define Td 2.0 main(int argc,char **argv) { double amps[8] = {.8,.2,.1,.04,.02,.01,.005}; - struct complex ch[(int)(1+2*BW*Td)],phase; + struct complex ch[(int)(1+2*sampling_rate*Td)],phase; int i; randominit(); phase.x = 1.0; phase.y = 0; - random_channel(amps,Td, 8,BW,ch,(double)1.0,&phase); + random_channel(amps,Td, 8,sampling_rate,ch,(double)1.0,&phase); /* - for (i=0;i<(11+2*BW*Td);i++){ + for (i=0;i<(11+2*sampling_rate*Td);i++){ printf("%f + sqrt(-1)*%f\n",ch[i].x,ch[i].y); } */ diff --git a/targets/SIMU/USER/channel_sim.c b/targets/SIMU/USER/channel_sim.c index aeddfaddbe8..bba32a5a29b 100644 --- a/targets/SIMU/USER/channel_sim.c +++ b/targets/SIMU/USER/channel_sim.c @@ -303,8 +303,8 @@ void do_DL_sig(double **r_re0,double **r_im0, 10*log10(rx_pwr*(double)frame_parms->N_RB_DL*12),next_slot,next_slot>>1); LOG_D(OCM,"[SIM][DL] UE %d : rx_pwr (noise) -132 dBm/RE (N0fs = %.1f dBm, N0B = %.1f dBm) for slot %d (subframe %d)\n", UE_id, - 10*log10(eNB2UE[eNB_id][UE_id][CC_id]->BW*1e6)-174, - 10*log10(eNB2UE[eNB_id][UE_id][CC_id]->BW*1e6*12*frame_parms->N_RB_DL/(double)frame_parms->ofdm_symbol_size)-174, + 10*log10(eNB2UE[eNB_id][UE_id][CC_id]->sampling_rate*1e6)-174, + 10*log10(eNB2UE[eNB_id][UE_id][CC_id]->sampling_rate*1e6*12*frame_parms->N_RB_DL/(double)frame_parms->ofdm_symbol_size)-174, next_slot,next_slot>>1); #endif @@ -342,7 +342,7 @@ void do_DL_sig(double **r_re0,double **r_im0, r_im0, nb_antennas_rx, frame_parms->samples_per_tti>>1, - 1e3/eNB2UE[eNB_id][UE_id][CC_id]->BW, // sampling time (ns) + 1e3/eNB2UE[eNB_id][UE_id][CC_id]->sampling_rate, // sampling time (ns) (double)PHY_vars_UE_g[UE_id][CC_id]->rx_total_gain_dB - 66.227); // rx_gain (dB) (66.227 = 20*log10(pow2(11)) = gain from the adc that will be applied later) #ifdef DEBUG_SIM @@ -584,7 +584,7 @@ void do_UL_sig(double **r_re0,double **r_im0,double **r_re,double **r_im,double r_im, nb_antennas_rx, frame_parms->samples_per_tti>>1, - 1e3/UE2eNB[0][eNB_id][CC_id]->BW, // sampling time (ns) + 1e3/UE2eNB[0][eNB_id][CC_id]->sampling_rate, // sampling time (ns) (double)PHY_vars_eNB_g[eNB_id][CC_id]->rx_total_gain_eNB_dB - 66.227); // rx_gain (dB) (66.227 = 20*log10(pow2(11)) = gain from the adc that will be applied later) #ifdef DEBUG_SIM diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c index ebdb3c00d32..ca1ec9fccb9 100644 --- a/targets/SIMU/USER/oaisim_functions.c +++ b/targets/SIMU/USER/oaisim_functions.c @@ -1122,24 +1122,28 @@ void init_ocm(void) else */ - eNB2UE[eNB_id][UE_id][CC_id] = new_channel_desc_scm(PHY_vars_eNB_g[eNB_id][CC_id]->lte_frame_parms.nb_antennas_tx, - PHY_vars_UE_g[UE_id][CC_id]->lte_frame_parms.nb_antennas_rx, - map_str_to_int(small_scale_names,oai_emulation.environment_system_config.fading.small_scale.selected_option), - oai_emulation.environment_system_config.system_bandwidth_MB, - forgetting_factor, - 0, - 0); + eNB2UE[eNB_id][UE_id][CC_id] = + new_channel_desc_scm(PHY_vars_eNB_g[eNB_id][CC_id]->lte_frame_parms.nb_antennas_tx, + PHY_vars_UE_g[UE_id][CC_id]->lte_frame_parms.nb_antennas_rx, + map_str_to_int(small_scale_names,oai_emulation.environment_system_config.fading.small_scale.selected_option), + N_RB2sampling_rate(PHY_vars_eNB_g[eNB_id][CC_id]->lte_frame_parms.N_RB_DL), + N_RB2channel_bandwidth(PHY_vars_eNB_g[eNB_id][CC_id]->lte_frame_parms.N_RB_DL), + forgetting_factor, + 0, + 0); random_channel(eNB2UE[eNB_id][UE_id][CC_id],abstraction_flag); LOG_D(OCM,"[SIM] Initializing channel (%s, %d) from UE %d to eNB %d\n", oai_emulation.environment_system_config.fading.small_scale.selected_option, map_str_to_int(small_scale_names, oai_emulation.environment_system_config.fading.small_scale.selected_option),UE_id, eNB_id); - UE2eNB[UE_id][eNB_id][CC_id] = new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->lte_frame_parms.nb_antennas_tx, - PHY_vars_eNB_g[eNB_id][CC_id]->lte_frame_parms.nb_antennas_rx, - map_str_to_int(small_scale_names, oai_emulation.environment_system_config.fading.small_scale.selected_option), - oai_emulation.environment_system_config.system_bandwidth_MB, - forgetting_factor, - 0, - 0); + UE2eNB[UE_id][eNB_id][CC_id] = + new_channel_desc_scm(PHY_vars_UE_g[UE_id][CC_id]->lte_frame_parms.nb_antennas_tx, + PHY_vars_eNB_g[eNB_id][CC_id]->lte_frame_parms.nb_antennas_rx, + map_str_to_int(small_scale_names, oai_emulation.environment_system_config.fading.small_scale.selected_option), + N_RB2sampling_rate(PHY_vars_eNB_g[eNB_id][CC_id]->lte_frame_parms.N_RB_UL), + N_RB2channel_bandwidth(PHY_vars_eNB_g[eNB_id][CC_id]->lte_frame_parms.N_RB_UL), + forgetting_factor, + 0, + 0); random_channel(UE2eNB[UE_id][eNB_id][CC_id],abstraction_flag); diff --git a/targets/SIMU/USER/sinr_sim.c b/targets/SIMU/USER/sinr_sim.c index 8bdc4a50577..317fe53c609 100644 --- a/targets/SIMU/USER/sinr_sim.c +++ b/targets/SIMU/USER/sinr_sim.c @@ -254,7 +254,7 @@ void init_snr(channel_desc_t* eNB2UE, node_desc_t *enb_data, node_desc_t *ue_dat uint8_t qq; /* Thermal noise is calculated using 10log10(K*T*B) K = Boltzmann's constant T = room temperature B = bandwidth */ - thermal_noise = -174 + 10*log10(eNB2UE->BW*1e6); //value in dBm + thermal_noise = -174 + 10*log10(eNB2UE->sampling_rate*1e6); //value in dBm //for (aarx=0; aarx<eNB2UE->nb_rx; aarx++) *N0 = thermal_noise + ue_data->rx_noise_level;//? all the element have the same noise level????? @@ -496,7 +496,7 @@ void init_snr_up(channel_desc_t* UE2eNB, node_desc_t *enb_data, node_desc_t *ue_ // nb_rb = phy_vars_eNB->ulsch_eNB[UE_id]->harq_processes[harq_pid]->nb_rb; /* Thermal noise is calculated using 10log10(K*T*B) K = Boltzmann's constant T = room temperature B = bandwidth */ - thermal_noise = -174 + 10*log10(UE2eNB->BW*1e6); //value in dBm + thermal_noise = -174 + 10*log10(UE2eNB->sampling_rate*1e6); //value in dBm *N0 = thermal_noise + enb_data->rx_noise_level;//? all the element have the same noise level????? double lambda ; double residual; @@ -557,7 +557,7 @@ void calculate_sinr(channel_desc_t* eNB2UE, node_desc_t *enb_data, node_desc_t * short count; /* Thermal noise is calculated using 10log10(K*T*B) K = Boltzmann's constant T = room temperature B = bandwidth */ - thermal_noise = -174 + 10*log10(eNB2UE->BW*1e6); //value in dBm + thermal_noise = -174 + 10*log10(eNB2UE->sampling_rate*1e6); //value in dBm for (count = 0; count < 12 * nb_rb; count++) { sir = enb_data->tx_power_dBm -- GitLab