Commit 2a206b1a authored by Laurent THOMAS's avatar Laurent THOMAS

fix warings

parent 0e151c96
...@@ -56,7 +56,7 @@ void lte_gold(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_table[20][2][14] ...@@ -56,7 +56,7 @@ void lte_gold(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_table[20][2][14]
(((1+(Nid_cell<<1))*(1 + (((frame_parms->Ncp==0)?4:3)*l) + (7*(1+ns))))<<10); //cinit (((1+(Nid_cell<<1))*(1 + (((frame_parms->Ncp==0)?4:3)*l) + (7*(1+ns))))<<10); //cinit
//x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit //x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit
//n = 0 //n = 0
x1 = 1+ (1<<31); x1 = 1+ (1U<<31);
x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31); x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
// skip first 50 double words (1600 bits) // skip first 50 double words (1600 bits)
...@@ -103,7 +103,7 @@ void lte_gold_ue_spec(uint32_t lte_gold_uespec_table[2][20][2][21],uint16_t Nid_ ...@@ -103,7 +103,7 @@ void lte_gold_ue_spec(uint32_t lte_gold_uespec_table[2][20][2][21],uint16_t Nid_
//x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit //x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit
//n = 0 //n = 0
// printf("cinit (ns %d, l %d) => %d\n",ns,l,x2); // printf("cinit (ns %d, l %d) => %d\n",ns,l,x2);
x1 = 1+ (1<<31); x1 = 1+ (1U<<31);
x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31); x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
// skip first 50 double words (1600 bits) // skip first 50 double words (1600 bits)
...@@ -143,7 +143,7 @@ void lte_gold_ue_spec_port5(uint32_t lte_gold_uespec_port5_table[20][38],uint16_ ...@@ -143,7 +143,7 @@ void lte_gold_ue_spec_port5(uint32_t lte_gold_uespec_port5_table[20][38],uint16_
//x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit //x2 = frame_parms->Ncp + (Nid_cell<<1) + (1+(Nid_cell<<1))*(1 + (3*l) + (7*(1+ns))); //cinit
//n = 0 //n = 0
//printf("cinit (ns %d, l %d) => %d\n",ns,l,x2); //printf("cinit (ns %d, l %d) => %d\n",ns,l,x2);
x1 = 1+ (1<<31); x1 = 1+ (1U<<31);
x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31); x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
//skip first 50 double words (1600 bits) //skip first 50 double words (1600 bits)
......
...@@ -59,7 +59,7 @@ void lte_gold_mbsfn(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_mbsfn_tabl ...@@ -59,7 +59,7 @@ void lte_gold_mbsfn(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold_mbsfn_tabl
//n = 0 //n = 0
// printf("cinit (sfn %d, l %d) => %d\n",sfn,l,x2); // printf("cinit (sfn %d, l %d) => %d\n",sfn,l,x2);
// Initializing the Sequence // Initializing the Sequence
x1 = 1+ (1<<31); x1 = 1+ (1U<<31);
x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31); x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
// skip first 50 double words (1600 bits) // skip first 50 double words (1600 bits)
// printf("n=0 : x1 %x, x2 %x\n",x1,x2); // printf("n=0 : x1 %x, x2 %x\n",x1,x2);
...@@ -90,7 +90,7 @@ void lte_gold_mbsfn_khz_1dot25(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold ...@@ -90,7 +90,7 @@ void lte_gold_mbsfn_khz_1dot25(LTE_DL_FRAME_PARMS *frame_parms,uint32_t lte_gold
for (sfn=0; sfn<10; sfn++) { for (sfn=0; sfn<10; sfn++) {
x2 = (Nid_mbsfn) + (((1+(Nid_mbsfn<<1))*(1 + (7*(1+sfn))))<<9); //cinit x2 = (Nid_mbsfn) + (((1+(Nid_mbsfn<<1))*(1 + (7*(1+sfn))))<<9); //cinit
x1 = 1+ (1<<31); x1 = 1+ (1U<<31);
x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31); x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
for (n=1; n<50; n++) { for (n=1; n<50; n++) {
......
...@@ -121,7 +121,7 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, ...@@ -121,7 +121,7 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms,
for (n=0; n<(1+(G>>5)); n++) { for (n=0; n<(1+(G>>5)); n++) {
#ifdef DEBUG_SCRAMBLING #ifdef DEBUG_SCRAMBLING
for (int k=0; k<32; k++) printf("scrambling %d : %d xor %d = %d\n",k+(n<<5),e[k],(s>>k)&1,e[k]^((s>>k)&1)); for (int k=0; k<32; k++) printf("scrambling %d : %x xor %x = %d\n",k+(n<<5),e[k],(s>>k)&1,e[k]^((s>>k)&1));
#endif #endif
e[0] = (e[0]) ^ (s&1); e[0] = (e[0]) ^ (s&1);
......
...@@ -41,7 +41,7 @@ extern inline uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t res ...@@ -41,7 +41,7 @@ extern inline uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t res
{ {
// Init value for x1: x1(0) = 1, x1(n) = 0, n=1,2,...,30 // Init value for x1: x1(0) = 1, x1(n) = 0, n=1,2,...,30
// x1(31) = [x1(3) + x1(0)]mod2 = 1 // x1(31) = [x1(3) + x1(0)]mod2 = 1
*x1 = 1 + (1<<31); *x1 = 1 + (1U<<31);
// Init value for x2: cinit = sum_{i=0}^30 x2*2^i // Init value for x2: cinit = sum_{i=0}^30 x2*2^i
// x2(31) = [x2(3) + x2(2) + x2(1) + x2(0)]mod2 // x2(31) = [x2(3) + x2(2) + x2(1) + x2(0)]mod2
// = (*x2>>3) ^ (*x2>>2) + (*x2>>1) + *x2 // = (*x2>>3) ^ (*x2>>2) + (*x2>>1) + *x2
......
...@@ -374,7 +374,7 @@ static inline unsigned int lte_gold_unscram(unsigned int *x1, unsigned int *x2, ...@@ -374,7 +374,7 @@ static inline unsigned int lte_gold_unscram(unsigned int *x1, unsigned int *x2,
int n; int n;
if (reset) { if (reset) {
*x1 = 1+ (1<<31); *x1 = 1+ (1U<<31);
*x2=*x2 ^ ((*x2 ^ (*x2>>1) ^ (*x2>>2) ^ (*x2>>3))<<31); *x2=*x2 ^ ((*x2 ^ (*x2>>1) ^ (*x2>>2) ^ (*x2>>3))<<31);
// skip first 50 double words (1600 bits) // skip first 50 double words (1600 bits)
......
...@@ -150,7 +150,7 @@ void pseudo_random_sequence_optimised(unsigned int size, uint32_t *c, uint32_t c ...@@ -150,7 +150,7 @@ void pseudo_random_sequence_optimised(unsigned int size, uint32_t *c, uint32_t c
unsigned int n,x1,x2; unsigned int n,x1,x2;
/* init of m-sequences */ /* init of m-sequences */
x1 = 1+ (1<<31); x1 = 1+ (1U<<31);
x2 = cinit; x2 = cinit;
x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31); x2=x2 ^ ((x2 ^ (x2>>1) ^ (x2>>2) ^ (x2>>3))<<31);
......
...@@ -62,7 +62,7 @@ static double snr_dB=25; ...@@ -62,7 +62,7 @@ static double snr_dB=25;
static double sinr_dB=0; static double sinr_dB=0;
static unsigned int max_chan; static unsigned int max_chan;
static channel_desc_t **defined_channels; static channel_desc_t **defined_channels;
static char modellist_name[MAX_OPTNAME_SIZE]={0}; static char modellist_name[MAX_OPTNAME_SIZE]= {0};
void fill_channel_desc(channel_desc_t *chan_desc, void fill_channel_desc(channel_desc_t *chan_desc,
...@@ -139,8 +139,10 @@ void fill_channel_desc(channel_desc_t *chan_desc, ...@@ -139,8 +139,10 @@ void fill_channel_desc(channel_desc_t *chan_desc,
if (R_sqrt == NULL) { if (R_sqrt == NULL) {
chan_desc->R_sqrt = (struct complex **) calloc(nb_taps,sizeof(struct complex *)); chan_desc->R_sqrt = (struct complex **) calloc(nb_taps,sizeof(struct complex *));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_NTAPS ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_NTAPS ;
for (i = 0; i<nb_taps; i++) { for (i = 0; i<nb_taps; i++) {
chan_desc->R_sqrt[i] = (struct complex *) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex)); chan_desc->R_sqrt[i] = (struct complex *) calloc(nb_tx*nb_rx*nb_tx*nb_rx,sizeof(struct complex));
for (j = 0; j<nb_tx*nb_rx*nb_tx*nb_rx; j+=(nb_tx*nb_rx+1)) { for (j = 0; j<nb_tx*nb_rx*nb_tx*nb_rx; j+=(nb_tx*nb_rx+1)) {
chan_desc->R_sqrt[i][j].x = 1.0; chan_desc->R_sqrt[i][j].x = 1.0;
chan_desc->R_sqrt[i][j].y = 0.0; chan_desc->R_sqrt[i][j].y = 0.0;
...@@ -203,7 +205,8 @@ double tdl_a_delays[] = {0.0000, ...@@ -203,7 +205,8 @@ double tdl_a_delays[] = {0.0000,
4.7966, 4.7966,
5.0066, 5.0066,
5.3043, 5.3043,
9.6586}; 9.6586
};
double tdl_a_amps_dB[] = {-13.4, double tdl_a_amps_dB[] = {-13.4,
0, 0,
-2.2, -2.2,
...@@ -226,7 +229,8 @@ double tdl_a_amps_dB[] = {-13.4, ...@@ -226,7 +229,8 @@ double tdl_a_amps_dB[] = {-13.4,
-18.9, -18.9,
-16.6, -16.6,
-19.9, -19.9,
-29.7}; -29.7
};
double tdl_b_delays[] = {0.0000, double tdl_b_delays[] = {0.0000,
0.1072, 0.1072,
...@@ -250,7 +254,8 @@ double tdl_b_delays[] = {0.0000, ...@@ -250,7 +254,8 @@ double tdl_b_delays[] = {0.0000,
3.6187, 3.6187,
4.1067, 4.1067,
4.2790, 4.2790,
4.7834}; 4.7834
};
double tdl_b_amps_dB[] = {0, double tdl_b_amps_dB[] = {0,
-2.2, -2.2,
...@@ -274,7 +279,8 @@ double tdl_b_amps_dB[] = {0, ...@@ -274,7 +279,8 @@ double tdl_b_amps_dB[] = {0,
-11.4, -11.4,
-14.9, -14.9,
-9.2, -9.2,
-11.3}; -11.3
};
double tdl_c_delays[] = {0, double tdl_c_delays[] = {0,
0.2099, 0.2099,
...@@ -299,7 +305,8 @@ double tdl_c_delays[] = {0, ...@@ -299,7 +305,8 @@ double tdl_c_delays[] = {0,
6.3065, 6.3065,
6.6374, 6.6374,
7.0427, 7.0427,
8.6523}; 8.6523
};
double tdl_c_amps_dB[] = {-4.4, double tdl_c_amps_dB[] = {-4.4,
-1.2, -1.2,
...@@ -324,7 +331,8 @@ double tdl_c_amps_dB[] = {-4.4, ...@@ -324,7 +331,8 @@ double tdl_c_amps_dB[] = {-4.4,
-16, -16,
-15.7, -15.7,
-21.6, -21.6,
-22.8}; -22.8
};
double tdl_d_delays[] = {//0, double tdl_d_delays[] = {//0,
0, 0,
...@@ -339,10 +347,11 @@ double tdl_d_delays[] = {//0, ...@@ -339,10 +347,11 @@ double tdl_d_delays[] = {//0,
7.937, 7.937,
9.424, 9.424,
9.708, 9.708,
12.525}; 12.525
};
double tdl_d_amps_dB[] = {//-0.2, double tdl_d_amps_dB[] = {//-0.2,
//-13.5, //-13.5,
-.00147, -.00147,
-18.8, -18.8,
-21, -21,
...@@ -355,7 +364,8 @@ double tdl_d_amps_dB[] = {//-0.2, ...@@ -355,7 +364,8 @@ double tdl_d_amps_dB[] = {//-0.2,
-23.6, -23.6,
-24.8, -24.8,
-30.0, -30.0,
-27.7}; -27.7
};
#define TDL_D_RICEAN_FACTOR .046774 #define TDL_D_RICEAN_FACTOR .046774
...@@ -372,7 +382,8 @@ double tdl_e_delays[] = {0, ...@@ -372,7 +382,8 @@ double tdl_e_delays[] = {0,
3.7136, 3.7136,
5.4524, 5.4524,
12.0034, 12.0034,
20.6519}; 20.6519
};
double tdl_e_amps_dB[] = {//-0.03, double tdl_e_amps_dB[] = {//-0.03,
//-22.03, //-22.03,
...@@ -389,7 +400,8 @@ double tdl_e_amps_dB[] = {//-0.03, ...@@ -389,7 +400,8 @@ double tdl_e_amps_dB[] = {//-0.03,
-25.6, -25.6,
-20.2, -20.2,
-29.8, -29.8,
-29.2}; -29.2
};
#define TDL_E_RICEAN_FACTOR 0.0063096 #define TDL_E_RICEAN_FACTOR 0.0063096
...@@ -492,6 +504,74 @@ struct complex *R_sqrt_22_EPA_medium[1] = {R_sqrt_22_EPA_medium_tap}; ...@@ -492,6 +504,74 @@ struct complex *R_sqrt_22_EPA_medium[1] = {R_sqrt_22_EPA_medium_tap};
//Rayleigh1_orth_eff_ch_TM4 //Rayleigh1_orth_eff_ch_TM4
void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS_TDL, channel_desc_t *chan_desc ) {
int nb_rx=chan_desc-> nb_rx;
int nb_tx=chan_desc-> nb_tx;
int tdl_pathsby3 = tdl_paths/3;
if ((tdl_paths%3)>0)
tdl_pathsby3++;
chan_desc->nb_taps = tdl_paths;
chan_desc->Td = tdl_delays[tdl_paths-1]*DS_TDL;
printf("last path (%d) at %f * %e = %e\n",tdl_paths-1,tdl_delays[tdl_paths-1],DS_TDL,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));
printf("TDL : %f Ms/s, nb_taps %d, Td %e, channel_length %d\n",chan_desc->sampling_rate,tdl_paths,chan_desc->Td,chan_desc->channel_length);
double sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
for (int i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*tdl_amps_dB[i]);
sum_amps += chan_desc->amps[i];
}
for (int i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] /= sum_amps;
tdl_delays[i] *= DS_TDL;
}
chan_desc->delays = tdl_delays;
chan_desc->aoa = 0;
chan_desc->random_aoa = 0;
chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *));
chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *));
chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *));
for (int i = 0; i<nb_tx*nb_rx; i++)
chan_desc->ch[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex));
for (int i = 0; i<nb_tx*nb_rx; i++)
chan_desc->chF[i] = (struct complex *) malloc(1200 * sizeof(struct complex));
for (int i = 0; i<chan_desc->nb_taps; i++)
chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex));
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **));
if (nb_tx==2 && nb_rx==2) {
for (int i = 0; i<(tdl_pathsby3); i++)
chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0];
} else if (nb_tx==2 && nb_rx==1) {
for (int i = 0; i<(tdl_pathsby3); i++)
chan_desc->R_sqrt[i] = (struct complex *) &R21_sqrt[i][0];
} else if (nb_tx==1 && nb_rx==2) {
for (int i = 0; i<(tdl_pathsby3); i++)
chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0];
} else {
for (int i = 0; i<(tdl_pathsby3); i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
for (int j = 0; j<nb_tx*nb_rx*nb_tx*nb_rx; j+=(nb_tx*nb_rx+1)) {
chan_desc->R_sqrt[i][j].x = 1.0;
chan_desc->R_sqrt[i][j].y = 0.0;
}
LOG_W(OCM,"correlation matrix not implemented for nb_tx==%d and nb_rx==%d, using identity\n", nb_tx, nb_rx);
}
}
}
channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
uint8_t nb_rx, uint8_t nb_rx,
...@@ -504,21 +584,21 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -504,21 +584,21 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
double path_loss_dB, double path_loss_dB,
float noise_power_dB) { float noise_power_dB) {
channel_desc_t *chan_desc = (channel_desc_t *)calloc(1,sizeof(channel_desc_t)); channel_desc_t *chan_desc = (channel_desc_t *)calloc(1,sizeof(channel_desc_t));
for(int i=0; i<max_chan;i++) {
for(int i=0; i<max_chan; i++) {
if (defined_channels[i] == NULL) { if (defined_channels[i] == NULL) {
defined_channels[i]=chan_desc; defined_channels[i]=chan_desc;
chan_desc->chan_idx=i; chan_desc->chan_idx=i;
break; break;
} } else {
else {
AssertFatal(i<(max_chan-1), AssertFatal(i<(max_chan-1),
"No more channel descriptors available, increase channelmod.max_chan parameter above %u\n",max_chan); "No more channel descriptors available, increase channelmod.max_chan parameter above %u\n",max_chan);
} }
} }
uint16_t i,j; uint16_t i,j;
double sum_amps; double sum_amps;
double aoa,ricean_factor,Td,maxDoppler; double aoa,ricean_factor,Td,maxDoppler;
int channel_length,nb_taps; int channel_length,nb_taps;
chan_desc->modelid = channel_model; chan_desc->modelid = channel_model;
chan_desc->nb_tx = nb_tx; chan_desc->nb_tx = nb_tx;
...@@ -531,9 +611,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -531,9 +611,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
chan_desc->first_run = 1; chan_desc->first_run = 1;
chan_desc->ip = 0.0; chan_desc->ip = 0.0;
chan_desc->noise_power_dB = noise_power_dB; chan_desc->noise_power_dB = noise_power_dB;
LOG_I(OCM,"Channel Model (inside of new_channel_desc_scm)=%d\n\n", channel_model); LOG_I(OCM,"Channel Model (inside of new_channel_desc_scm)=%d\n\n", channel_model);
int tdl_paths=0; int tdl_paths=0;
double *tdl_amps_dB; double *tdl_amps_dB;
double *tdl_delays; double *tdl_delays;
...@@ -557,6 +635,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -557,6 +635,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0; sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) { for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]); chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]);
sum_amps += chan_desc->amps[i]; sum_amps += chan_desc->amps[i];
...@@ -595,6 +674,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -595,6 +674,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0]; chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0];
} else { } else {
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
for (i = 0; i<6; i++) { for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
...@@ -617,6 +697,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -617,6 +697,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0; sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) { for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]); chan_desc->amps[i] = pow(10,.1*scm_c_amps_dB[i]);
sum_amps += chan_desc->amps[i]; sum_amps += chan_desc->amps[i];
...@@ -655,6 +736,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -655,6 +736,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0]; chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0];
} else { } else {
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
for (i = 0; i<6; i++) { for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
...@@ -668,8 +750,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -668,8 +750,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
} }
break; break;
/* tapped delay line (TDL) channel model from TR 38.901 Section 7.7.2 */
/* tapped delay line (TDL) channel model from TR 38.901 Section 7.7.2 */
#define tdl_m(MoDel)\ #define tdl_m(MoDel)\
DevAssert(sizeof(tdl_ ## MoDel ## _amps_dB) == sizeof(tdl_ ## MoDel ## _delays)); \ DevAssert(sizeof(tdl_ ## MoDel ## _amps_dB) == sizeof(tdl_ ## MoDel ## _delays)); \
tdl_paths=sizeof(tdl_ ## MoDel ## _amps_dB)/sizeof(*tdl_ ## MoDel ## _amps_dB);\ tdl_paths=sizeof(tdl_ ## MoDel ## _amps_dB)/sizeof(*tdl_ ## MoDel ## _amps_dB);\
...@@ -677,86 +758,33 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -677,86 +758,33 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
tdl_amps_dB=tdl_ ## MoDel ## _amps_dB tdl_amps_dB=tdl_ ## MoDel ## _amps_dB
case TDL_A: case TDL_A:
case TDL_B:
case TDL_C:
case TDL_D:
case TDL_E:
chan_desc->ricean_factor = 1; chan_desc->ricean_factor = 1;
if (channel_model == TDL_A) {
tdl_m(a); tdl_m(a);
}else if (channel_model == TDL_B) { tdlModel(tdl_paths, tdl_delays, tdl_amps_dB, DS_TDL, chan_desc);
tdl_m(b); break;
}
else if (channel_model == TDL_C) {
tdl_m(c);
} else if (channel_model == TDL_D) {
tdl_m(d);
chan_desc->ricean_factor = TDL_D_RICEAN_FACTOR;
} else if (channel_model == TDL_E) {
tdl_m(e);
chan_desc->ricean_factor = TDL_E_RICEAN_FACTOR;
}
int tdl_pathsby3 = tdl_paths/3;
if ((tdl_paths%3)>0) tdl_pathsby3++;
chan_desc->nb_taps = tdl_paths;
chan_desc->Td = tdl_delays[tdl_paths-1]*DS_TDL;
printf("last path (%d) at %f * %e = %e\n",tdl_paths-1,tdl_delays[tdl_paths-1],DS_TDL,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));
printf("TDL : %f Ms/s, nb_taps %d, Td %e, channel_length %d\n",chan_desc->sampling_rate,tdl_paths,chan_desc->Td,chan_desc->channel_length);
sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*tdl_amps_dB[i]);
sum_amps += chan_desc->amps[i];
}
for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] /= sum_amps;
tdl_delays[i] *= DS_TDL;
}
chan_desc->delays = tdl_delays;
chan_desc->aoa = 0;
chan_desc->random_aoa = 0;
chan_desc->ch = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *));
chan_desc->chF = (struct complex **) malloc(nb_tx*nb_rx*sizeof(struct complex *));
chan_desc->a = (struct complex **) malloc(chan_desc->nb_taps*sizeof(struct complex *));
for (i = 0; i<nb_tx*nb_rx; i++)
chan_desc->ch[i] = (struct complex *) malloc(chan_desc->channel_length * sizeof(struct complex));
for (i = 0; i<nb_tx*nb_rx; i++)
chan_desc->chF[i] = (struct complex *) malloc(1200 * sizeof(struct complex));
for (i = 0; i<chan_desc->nb_taps; i++)
chan_desc->a[i] = (struct complex *) malloc(nb_tx*nb_rx * sizeof(struct complex));
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **));
if (nb_tx==2 && nb_rx==2) { case TDL_B:
for (i = 0; i<(tdl_pathsby3); i++) chan_desc->ricean_factor = 1;
chan_desc->R_sqrt[i] = (struct complex *) &R22_sqrt[i][0]; tdl_m(b);
} else if (nb_tx==2 && nb_rx==1) { tdlModel(tdl_paths, tdl_delays, tdl_amps_dB, DS_TDL, chan_desc);
for (i = 0; i<(tdl_pathsby3); i++) break;
chan_desc->R_sqrt[i] = (struct complex *) &R21_sqrt[i][0];
} else if (nb_tx==1 && nb_rx==2) {
for (i = 0; i<(tdl_pathsby3); i++)
chan_desc->R_sqrt[i] = (struct complex *) &R12_sqrt[i][0];
} else {
for (i = 0; i<(tdl_pathsby3); i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
for (j = 0; j<nb_tx*nb_rx*nb_tx*nb_rx; j+=(nb_tx*nb_rx+1)) { case TDL_C:
chan_desc->R_sqrt[i][j].x = 1.0; chan_desc->ricean_factor = 1;
chan_desc->R_sqrt[i][j].y = 0.0; tdl_m(c);
} tdlModel(tdl_paths, tdl_delays, tdl_amps_dB, DS_TDL, chan_desc);
break;
LOG_W(OCM,"correlation matrix not implemented for nb_tx==%d and nb_rx==%d, using identity\n", nb_tx, nb_rx); case TDL_D:
} chan_desc->ricean_factor = TDL_D_RICEAN_FACTOR;
} tdl_m(d);
tdlModel(tdl_paths, tdl_delays, tdl_amps_dB, DS_TDL, chan_desc);
break;
case TDL_E:
chan_desc->ricean_factor = TDL_E_RICEAN_FACTOR;
tdl_m(e);
tdlModel(tdl_paths, tdl_delays, tdl_amps_dB, DS_TDL, chan_desc);
break; break;
case EPA: case EPA:
...@@ -766,6 +794,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -766,6 +794,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0; sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) { for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]);
sum_amps += chan_desc->amps[i]; sum_amps += chan_desc->amps[i];
...@@ -799,6 +828,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -799,6 +828,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
} else { } else {
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
for (i = 0; i<6; i++) { for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
...@@ -820,6 +850,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -820,6 +850,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0; sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) { for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]);
sum_amps += chan_desc->amps[i]; sum_amps += chan_desc->amps[i];
...@@ -874,6 +905,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -874,6 +905,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0; sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) { for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]);
sum_amps += chan_desc->amps[i]; sum_amps += chan_desc->amps[i];
...@@ -928,6 +960,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -928,6 +960,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0; sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) { for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]); chan_desc->amps[i] = pow(10,.1*epa_amps_dB[i]);
sum_amps += chan_desc->amps[i]; sum_amps += chan_desc->amps[i];
...@@ -982,6 +1015,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -982,6 +1015,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0; sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) { for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*eva_amps_dB[i]); chan_desc->amps[i] = pow(10,.1*eva_amps_dB[i]);
sum_amps += chan_desc->amps[i]; sum_amps += chan_desc->amps[i];
...@@ -1015,6 +1049,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -1015,6 +1049,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
} else { } else {
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
for (i = 0; i<6; i++) { for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
...@@ -1036,6 +1071,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -1036,6 +1071,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0; sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) { for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*etu_amps_dB[i]); chan_desc->amps[i] = pow(10,.1*etu_amps_dB[i]);
sum_amps += chan_desc->amps[i]; sum_amps += chan_desc->amps[i];
...@@ -1069,6 +1105,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -1069,6 +1105,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
} else { } else {
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **)); chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex **));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
for (i = 0; i<6; i++) { for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
...@@ -1090,6 +1127,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -1090,6 +1127,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
sum_amps = 0; sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) { for (i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*mbsfn_amps_dB[i]); chan_desc->amps[i] = pow(10,.1*mbsfn_amps_dB[i]);
sum_amps += chan_desc->amps[i]; sum_amps += chan_desc->amps[i];
...@@ -1117,6 +1155,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -1117,6 +1155,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex *)); chan_desc->R_sqrt = (struct complex **) malloc(6*sizeof(struct complex *));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6;
for (i = 0; i<6; i++) { for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex)); chan_desc->R_sqrt[i] = (struct complex *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complex));
...@@ -1628,13 +1667,14 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -1628,13 +1667,14 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
return(chan_desc); return(chan_desc);
} /* channel_desc_t *new_channel_desc_scm */ } /* channel_desc_t *new_channel_desc_scm */
channel_desc_t * find_channel_desc_fromname( char *modelname ) { channel_desc_t *find_channel_desc_fromname( char *modelname ) {
for(int i=0; i<max_chan;i++) { for(int i=0; i<max_chan; i++) {
if (defined_channels[i] != NULL) { if (defined_channels[i] != NULL) {
if (strcmp(defined_channels[i]->model_name,modelname) == 0) if (strcmp(defined_channels[i]->model_name,modelname) == 0)
return defined_channels[i]; return defined_channels[i];
} }
} }
LOG_E(OCM,"Model %s not found \n", modelname); LOG_E(OCM,"Model %s not found \n", modelname);
return NULL; return NULL;
} /* channel_desc_t * new_channel_desc_fromconfig */ } /* channel_desc_t * new_channel_desc_fromconfig */
...@@ -1644,8 +1684,10 @@ channel_desc_t * find_channel_desc_fromname( char *modelname ) { ...@@ -1644,8 +1684,10 @@ channel_desc_t * find_channel_desc_fromname( char *modelname ) {
void free_channel_desc_scm(channel_desc_t *ch) { void free_channel_desc_scm(channel_desc_t *ch) {
// Must be made cleanly, a lot of leaks... // Must be made cleanly, a lot of leaks...
defined_channels[ch->chan_idx]=NULL; defined_channels[ch->chan_idx]=NULL;
if(ch->free_flags&CHANMODEL_FREE_AMPS) if(ch->free_flags&CHANMODEL_FREE_AMPS)
free(ch->amps); free(ch->amps);
for (int i = 0; i<ch->nb_tx*ch->nb_rx; i++) { for (int i = 0; i<ch->nb_tx*ch->nb_rx; i++) {
free(ch->ch[i]); free(ch->ch[i]);
free(ch->chF[i]); free(ch->chF[i]);
...@@ -1654,14 +1696,18 @@ void free_channel_desc_scm(channel_desc_t *ch) { ...@@ -1654,14 +1696,18 @@ void free_channel_desc_scm(channel_desc_t *ch) {
for (int i = 0; i<ch->nb_taps; i++) { for (int i = 0; i<ch->nb_taps; i++) {
free(ch->a[i]); free(ch->a[i]);
} }
if(ch->free_flags&CHANMODEL_FREE_DELAY) if(ch->free_flags&CHANMODEL_FREE_DELAY)
free(ch->delays); free(ch->delays);
if(ch->free_flags&CHANMODEL_FREE_RSQRT_6) if(ch->free_flags&CHANMODEL_FREE_RSQRT_6)
for (int i = 0; i<6; i++) for (int i = 0; i<6; i++)
free(ch->R_sqrt[i]); free(ch->R_sqrt[i]);
if(ch->free_flags&CHANMODEL_FREE_RSQRT_NTAPS) if(ch->free_flags&CHANMODEL_FREE_RSQRT_NTAPS)
for (int i = 0; i<ch->nb_taps;i++) for (int i = 0; i<ch->nb_taps; i++)
free(ch->R_sqrt[i]); free(ch->R_sqrt[i]);
free(ch->R_sqrt); free(ch->R_sqrt);
free(ch->ch); free(ch->ch);
free(ch->chF); free(ch->chF);
...@@ -1677,6 +1723,7 @@ void set_channeldesc_owner(channel_desc_t *cdesc, uint32_t module_id) { ...@@ -1677,6 +1723,7 @@ void set_channeldesc_owner(channel_desc_t *cdesc, uint32_t module_id) {
void set_channeldesc_name(channel_desc_t *cdesc,char *modelname) { void set_channeldesc_name(channel_desc_t *cdesc,char *modelname) {
if(cdesc->model_name != NULL) if(cdesc->model_name != NULL)
free(cdesc->model_name); free(cdesc->model_name);
cdesc->model_name=strdup(modelname); cdesc->model_name=strdup(modelname);
} }
...@@ -1869,6 +1916,7 @@ double N_RB2channel_bandwidth(uint16_t N_RB) { ...@@ -1869,6 +1916,7 @@ double N_RB2channel_bandwidth(uint16_t N_RB) {
LOG_E(OCM,"Unknown N_PRB\n"); LOG_E(OCM,"Unknown N_PRB\n");
return(-1); return(-1);
} }
return(channel_bandwidth); return(channel_bandwidth);
} }
...@@ -1894,6 +1942,7 @@ static void display_channelmodel(channel_desc_t *cd,int debug, telnet_printfunc_ ...@@ -1894,6 +1942,7 @@ static void display_channelmodel(channel_desc_t *cd,int debug, telnet_printfunc_
cd->max_Doppler, cd->path_loss_dB, cd->noise_power_dB, cd->channel_offset, cd->forgetting_factor); cd->max_Doppler, cd->path_loss_dB, cd->noise_power_dB, cd->channel_offset, cd->forgetting_factor);
prnt("Initial phase: %lf nb_path: %i \n", prnt("Initial phase: %lf nb_path: %i \n",
cd->ip, cd->nb_paths); cd->ip, cd->nb_paths);
for (int i=0; i<cd->nb_taps ; i++) { for (int i=0; i<cd->nb_taps ; i++) {
prnt("taps: %i lin. ampli. : %lf delay: %lf \n",i,cd->amps[i], cd->delays[i]); prnt("taps: %i lin. ampli. : %lf delay: %lf \n",i,cd->amps[i], cd->delays[i]);
} }
...@@ -1920,8 +1969,10 @@ static int channelmod_show_cmd(char *buff, int debug, telnet_printfunc_t prnt) { ...@@ -1920,8 +1969,10 @@ static int channelmod_show_cmd(char *buff, int debug, telnet_printfunc_t prnt) {
} else { } else {
channelmod_print_help(buff, debug, prnt); channelmod_print_help(buff, debug, prnt);
} }
free(subcmd); free(subcmd);
} }
return CMDSTATUS_FOUND; return CMDSTATUS_FOUND;
} }
...@@ -1931,10 +1982,12 @@ static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt) ...@@ -1931,10 +1982,12 @@ static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt)
char *param=NULL, *value=NULL; char *param=NULL, *value=NULL;
int cd_id= -1; int cd_id= -1;
int s = sscanf(buff,"%i %ms %ms \n",&cd_id,&param, &value); int s = sscanf(buff,"%i %ms %ms \n",&cd_id,&param, &value);
if (cd_id<0 || cd_id >= max_chan) { if (cd_id<0 || cd_id >= max_chan) {
prnt("ERROR, %i: Channel model id outof range (0-%i)\n",cd_id,max_chan-1); prnt("ERROR, %i: Channel model id outof range (0-%i)\n",cd_id,max_chan-1);
return CMDSTATUS_FOUND; return CMDSTATUS_FOUND;
} }
if (defined_channels[cd_id]==NULL) { if (defined_channels[cd_id]==NULL) {
prnt("ERROR, %i: Channel model has not been set\n",cd_id); prnt("ERROR, %i: Channel model has not been set\n",cd_id);
return CMDSTATUS_FOUND; return CMDSTATUS_FOUND;
...@@ -1943,18 +1996,21 @@ static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt) ...@@ -1943,18 +1996,21 @@ static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt)
if (s==3) { if (s==3) {
if ( strcmp(param,"riceanf") == 0) { if ( strcmp(param,"riceanf") == 0) {
double dbl = atof(value); double dbl = atof(value);
if (dbl <0 || dbl > 1) if (dbl <0 || dbl > 1)
prnt("ERROR: ricean factor range: 0 to 1, %lf is outof range\n",dbl); prnt("ERROR: ricean factor range: 0 to 1, %lf is outof range\n",dbl);
else else
defined_channels[cd_id]->ricean_factor=dbl; defined_channels[cd_id]->ricean_factor=dbl;
} else if ( strcmp(param,"aoa") == 0) { } else if ( strcmp(param,"aoa") == 0) {
double dbl = atof(value); double dbl = atof(value);
if (dbl <0 || dbl >6.28) if (dbl <0 || dbl >6.28)
prnt("ERROR: angle of arrival range: 0 to 2*Pi, %lf is outof range\n",dbl); prnt("ERROR: angle of arrival range: 0 to 2*Pi, %lf is outof range\n",dbl);
else else
defined_channels[cd_id]->aoa=dbl; defined_channels[cd_id]->aoa=dbl;
} else if ( strcmp(param,"randaoa") == 0) { } else if ( strcmp(param,"randaoa") == 0) {
int i = atoi(value); int i = atoi(value);
if (i!=0 && i!=1) if (i!=0 && i!=1)
prnt("ERROR: randaoa is a boolean, must be 0 or 1\n"); prnt("ERROR: randaoa is a boolean, must be 0 or 1\n");
else else
...@@ -1970,6 +2026,7 @@ static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt) ...@@ -1970,6 +2026,7 @@ static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt)
defined_channels[cd_id]->channel_offset=i; defined_channels[cd_id]->channel_offset=i;
} else if ( strcmp(param,"forgetf") == 0) { } else if ( strcmp(param,"forgetf") == 0) {
double dbl = atof(value); double dbl = atof(value);
if (dbl <0 || dbl > 1) if (dbl <0 || dbl > 1)
prnt("ERROR: forgetting factor range: 0 to 1 (disable variation), %lf is outof range\n",dbl); prnt("ERROR: forgetting factor range: 0 to 1 (disable variation), %lf is outof range\n",dbl);
else else
...@@ -1978,18 +2035,22 @@ static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt) ...@@ -1978,18 +2035,22 @@ static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt)
prnt("ERROR: %s, unknown channel parameter\n",param); prnt("ERROR: %s, unknown channel parameter\n",param);
return CMDSTATUS_FOUND; return CMDSTATUS_FOUND;
} }
display_channelmodel(defined_channels[cd_id],debug,prnt); display_channelmodel(defined_channels[cd_id],debug,prnt);
free(param); free(param);
free(value); free(value);
random_channel(defined_channels[cd_id],false); random_channel(defined_channels[cd_id],false);
} }
return CMDSTATUS_FOUND; return CMDSTATUS_FOUND;
} }
int modelid_fromstrtype(char *modeltype) { int modelid_fromstrtype(char *modeltype) {
int modelid=map_str_to_int(channelmod_names,modeltype); int modelid=map_str_to_int(channelmod_names,modeltype);
if (modelid < 0) if (modelid < 0)
LOG_E(OCM,"random_channel.c: Error channel model %s unknown\n",modeltype); LOG_E(OCM,"random_channel.c: Error channel model %s unknown\n",modeltype);
return modelid; return modelid;
} }
...@@ -2003,13 +2064,11 @@ double channelmod_get_sinr_dB(void) { ...@@ -2003,13 +2064,11 @@ double channelmod_get_sinr_dB(void) {
void init_channelmod(void) { void init_channelmod(void) {
paramdef_t channelmod_params[] = CHANNELMOD_PARAMS_DESC; paramdef_t channelmod_params[] = CHANNELMOD_PARAMS_DESC;
int numparams=sizeof(channelmod_params)/sizeof(paramdef_t); int numparams=sizeof(channelmod_params)/sizeof(paramdef_t);
int ret = config_get( channelmod_params,numparams,CHANNELMOD_SECTION); int ret = config_get( channelmod_params,numparams,CHANNELMOD_SECTION);
AssertFatal(ret >= 0, "configuration couldn't be performed"); AssertFatal(ret >= 0, "configuration couldn't be performed");
defined_channels=calloc(max_chan,sizeof( channel_desc_t*)); defined_channels=calloc(max_chan,sizeof( channel_desc_t *));
AssertFatal(defined_channels!=NULL, "couldn't allocate %u channel descriptors\n",max_chan); AssertFatal(defined_channels!=NULL, "couldn't allocate %u channel descriptors\n",max_chan);
/* look for telnet server, if it is loaded, add the channel modeling commands to it */ /* look for telnet server, if it is loaded, add the channel modeling commands to it */
add_telnetcmd_func_t addcmd = (add_telnetcmd_func_t)get_shlibmodule_fptr("telnetsrv", TELNET_ADDCMD_FNAME); add_telnetcmd_func_t addcmd = (add_telnetcmd_func_t)get_shlibmodule_fptr("telnetsrv", TELNET_ADDCMD_FNAME);
...@@ -2024,7 +2083,6 @@ int load_channellist(uint8_t nb_tx, uint8_t nb_rx, double sampling_rate, double ...@@ -2024,7 +2083,6 @@ int load_channellist(uint8_t nb_tx, uint8_t nb_rx, double sampling_rate, double
paramlist_def_t channel_list; paramlist_def_t channel_list;
memset(&channel_list,0,sizeof(paramlist_def_t)); memset(&channel_list,0,sizeof(paramlist_def_t));
memcpy(channel_list.listname,modellist_name,sizeof(channel_list.listname)-1); memcpy(channel_list.listname,modellist_name,sizeof(channel_list.listname)-1);
int numparams = sizeof(achannel_params)/sizeof(paramdef_t); int numparams = sizeof(achannel_params)/sizeof(paramdef_t);
config_getlist( &channel_list,achannel_params,numparams, CHANNELMOD_SECTION); config_getlist( &channel_list,achannel_params,numparams, CHANNELMOD_SECTION);
AssertFatal(channel_list.numelt>0, "List %s.%s not found in config file\n",CHANNELMOD_SECTION,channel_list.listname); AssertFatal(channel_list.numelt>0, "List %s.%s not found in config file\n",CHANNELMOD_SECTION,channel_list.listname);
...@@ -2037,15 +2095,18 @@ int load_channellist(uint8_t nb_tx, uint8_t nb_rx, double sampling_rate, double ...@@ -2037,15 +2095,18 @@ int load_channellist(uint8_t nb_tx, uint8_t nb_rx, double sampling_rate, double
int pindex_TYPE = config_paramidx_fromname(achannel_params,numparams, CHANNELMOD_MODEL_TYPE_PNAME); int pindex_TYPE = config_paramidx_fromname(achannel_params,numparams, CHANNELMOD_MODEL_TYPE_PNAME);
for (int i=0; i<channel_list.numelt; i++) { for (int i=0; i<channel_list.numelt; i++) {
int modid = modelid_fromstrtype( *(channel_list.paramarray[i][pindex_TYPE].strptr) ); int modid = modelid_fromstrtype( *(channel_list.paramarray[i][pindex_TYPE].strptr) );
if (modid <0) { if (modid <0) {
LOG_E(OCM,"Valid channel model types:\n"); LOG_E(OCM,"Valid channel model types:\n");
for (int m=0; channelmod_names[i].name != NULL ; m++) { for (int m=0; channelmod_names[i].name != NULL ; m++) {
printf(" %s ", map_int_to_str(channelmod_names,m )); printf(" %s ", map_int_to_str(channelmod_names,m ));
} }
AssertFatal(0, "\n Choose a valid model type\n"); AssertFatal(0, "\n Choose a valid model type\n");
} }
channel_desc_t *channeldesc_p = new_channel_desc_scm(nb_tx,nb_rx,modid,sampling_rate,channel_bandwidth, channel_desc_t *channeldesc_p = new_channel_desc_scm(nb_tx,nb_rx,modid,sampling_rate,channel_bandwidth,
*(channel_list.paramarray[i][pindex_DT].dblptr), *(channel_list.paramarray[i][pindex_FF].dblptr), *(channel_list.paramarray[i][pindex_DT].dblptr), *(channel_list.paramarray[i][pindex_FF].dblptr),
*(channel_list.paramarray[i][pindex_CO].iptr), *(channel_list.paramarray[i][pindex_PL].dblptr), *(channel_list.paramarray[i][pindex_CO].iptr), *(channel_list.paramarray[i][pindex_PL].dblptr),
...@@ -2055,6 +2116,7 @@ int load_channellist(uint8_t nb_tx, uint8_t nb_rx, double sampling_rate, double ...@@ -2055,6 +2116,7 @@ int load_channellist(uint8_t nb_tx, uint8_t nb_rx, double sampling_rate, double
LOG_I(OCM,"Model %s type %s allocated from config file, list %s\n",*(channel_list.paramarray[i][pindex_NAME].strptr), LOG_I(OCM,"Model %s type %s allocated from config file, list %s\n",*(channel_list.paramarray[i][pindex_NAME].strptr),
*(channel_list.paramarray[i][pindex_TYPE].strptr), modellist_name); *(channel_list.paramarray[i][pindex_TYPE].strptr), modellist_name);
} /* for loop on channel_list */ } /* for loop on channel_list */
return channel_list.numelt; return channel_list.numelt;
} /* load_channelist */ } /* load_channelist */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment