Commit a0ffbdd7 authored by Xiwen JIANG's avatar Xiwen JIANG

some code optimisationsi; beamforming weights normalisation

parent cd2a5347
...@@ -1244,6 +1244,10 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, ...@@ -1244,6 +1244,10 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
if (eNB->node_function != NGFI_RCC_IF4p5) if (eNB->node_function != NGFI_RCC_IF4p5)
common_vars->txdata[eNB_id][i] = (int32_t*)malloc16_clear(fp->samples_per_tti*10*sizeof(int32_t) ); common_vars->txdata[eNB_id][i] = (int32_t*)malloc16_clear(fp->samples_per_tti*10*sizeof(int32_t) );
// initialze calibration matrix with idendity matrix
for (re=0; re<fp->ofdm_symbol_size; re++)
common_vars->tdd_calib_coeffs[eNB_id][i][re] = 0x00007fff;
#ifdef DEBUG_PHY #ifdef DEBUG_PHY
msg("[openair][LTE_PHY][INIT] lte_common_vars->txdataF_BF[%d][%d] = %p (%d bytes)\n", msg("[openair][LTE_PHY][INIT] lte_common_vars->txdataF_BF[%d][%d] = %p (%d bytes)\n",
eNB_id,i,common_vars->txdataF_BF[eNB_id][i], eNB_id,i,common_vars->txdataF_BF[eNB_id][i],
...@@ -1265,7 +1269,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, ...@@ -1265,7 +1269,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
} }
else if (i>4) { else if (i>4) {
for (re=0; re<fp->ofdm_symbol_size; re++) for (re=0; re<fp->ofdm_symbol_size; re++)
common_vars->beam_weights[eNB_id][i][j][re] = 0x00007fff/fp->nb_antennas_tx; common_vars->beam_weights[eNB_id][i][j][re] = 0x00007fff/sqrt(fp->nb_antennas_tx);
} }
#ifdef DEBUG_PHY #ifdef DEBUG_PHY
msg("[openair][LTE_PHY][INIT] lte_common_vars->beam_weights[%d][%d][%d] = %p (%d bytes)\n", msg("[openair][LTE_PHY][INIT] lte_common_vars->beam_weights[%d][%d][%d] = %p (%d bytes)\n",
...@@ -1314,7 +1318,10 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, ...@@ -1314,7 +1318,10 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
} }
} //eNB_id } //eNB_id
/* Create thread pool */ // Read TDD calibration coefficients
read_calibration_matrix(eNB->common_vars.tdd_calib_coeffs[0], "PROJECTS/TDDREC/results/calibF.m", fp);
// Create thread pool
eNB->pool = new_thread_pool(do_OFDM_mod_thread, eNB); eNB->pool = new_thread_pool(do_OFDM_mod_thread, eNB);
sleep(1); sleep(1);
......
...@@ -1984,6 +1984,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, ...@@ -1984,6 +1984,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB,
} }
// mapping ue specific beamforming weights from UE specified DLSCH structure to common space // mapping ue specific beamforming weights from UE specified DLSCH structure to common space
// TO DO: this doesn't have to be done here since we do it once in one frame
for (aa=0;aa<frame_parms->nb_antennas_tx;aa++){ for (aa=0;aa<frame_parms->nb_antennas_tx;aa++){
memcpy(phy_vars_eNB->common_vars.beam_weights[0][5][aa],dlsch0->ue_spec_bf_weights[0][aa],frame_parms->ofdm_symbol_size*sizeof(int32_t)); memcpy(phy_vars_eNB->common_vars.beam_weights[0][5][aa],dlsch0->ue_spec_bf_weights[0][aa],frame_parms->ofdm_symbol_size*sizeof(int32_t));
} }
......
...@@ -64,29 +64,31 @@ int beam_precoding(int32_t **txdataF, ...@@ -64,29 +64,31 @@ int beam_precoding(int32_t **txdataF,
memset(txdataF_BF[aa],0,sizeof(int32_t)*(frame_parms->ofdm_symbol_size)); memset(txdataF_BF[aa],0,sizeof(int32_t)*(frame_parms->ofdm_symbol_size));
for (p=0; p<14; p++) { for (p=0; p<14; p++) {
/* if (p==0 || p==1 || p==5) {
if (p==0 || p==1 || p==5) //multadd_cpx_vector((int16_t*)txdataF[p],(int16_t*)beam_weights[p][aa], (int16_t*)txdataF_BF[aa], 0, frame_parms->ofdm_symbol_size, 15);
multadd_cpx_vector((int16_t*)txdataF[p],(int16_t*)beam_weights[p][aa], (int16_t*)txdataF_BF[aa], 0, frame_parms->ofdm_symbol_size, 15);
*/ for (re=0;re<frame_parms->ofdm_symbol_size;re++) {
for (re=0;re<frame_parms->ofdm_symbol_size;re++) { if (txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re]!=0) {
if ((p==0 || p==1 || p==5) && txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re]!=0) { ((int16_t*)&txdataF_BF[aa][re])[0] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0]*((int16_t*)&beam_weights[p][aa][re])[0])>>15);
((int16_t*)&txdataF_BF[aa][re])[0] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0]*((int16_t*)&beam_weights[p][aa][re])[0])>>15); ((int16_t*)&txdataF_BF[aa][re])[0] -= (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1]*((int16_t*)&beam_weights[p][aa][re])[1])>>15);
((int16_t*)&txdataF_BF[aa][re])[0] -= (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1]*((int16_t*)&beam_weights[p][aa][re])[1])>>15); ((int16_t*)&txdataF_BF[aa][re])[1] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0]*((int16_t*)&beam_weights[p][aa][re])[1])>>15);
((int16_t*)&txdataF_BF[aa][re])[1] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0]*((int16_t*)&beam_weights[p][aa][re])[1])>>15); ((int16_t*)&txdataF_BF[aa][re])[1] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1]*((int16_t*)&beam_weights[p][aa][re])[0])>>15);
((int16_t*)&txdataF_BF[aa][re])[1] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1]*((int16_t*)&beam_weights[p][aa][re])[0])>>15);
/* /*
printf("beamforming.c:txdataF[%d][%d]=%d+j%d, beam_weights[%d][%d][%d]=%d+j%d,txdata_BF[%d][%d]=%d+j%d\n", printf("beamforming.c:txdataF[%d][%d]=%d+j%d, beam_weights[%d][%d][%d]=%d+j%d,txdata_BF[%d][%d]=%d+j%d\n",
p,slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re, p,slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re,
((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0], ((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0],
((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1], ((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1],
p,aa,re, p,aa,re,
((int16_t*)&beam_weights[p][aa][re])[0],((int16_t*)&beam_weights[p][aa][re])[1], ((int16_t*)&beam_weights[p][aa][re])[0],((int16_t*)&beam_weights[p][aa][re])[1],
aa,re, aa,re,
((int16_t*)&txdataF_BF[aa][re])[0], ((int16_t*)&txdataF_BF[aa][re])[0],
((int16_t*)&txdataF_BF[aa][re])[1]); ((int16_t*)&txdataF_BF[aa][re])[1]);
*/ */
}
} }
} }
} }
return 0; return 0;
} }
...@@ -7,13 +7,13 @@ int read_calibration_matrix(int32_t **tdd_calib_coeffs, char *calibF_fname, LTE_ ...@@ -7,13 +7,13 @@ int read_calibration_matrix(int32_t **tdd_calib_coeffs, char *calibF_fname, LTE_
FILE *calibF_fd ; FILE *calibF_fd ;
int aa,re,calibF_e ; int aa,re,calibF_e ;
printf("Number of antennas = %d\n", frame_parms->nb_antennas_tx) ; //printf("Number of antennas = %d\n", frame_parms->nb_antennas_tx) ;
printf("OFDM symbol size = %d\n", frame_parms->ofdm_symbol_size) ; //printf("OFDM symbol size = %d\n", frame_parms->ofdm_symbol_size) ;
calibF_fd = fopen(calibF_fname,"r") ; calibF_fd = fopen(calibF_fname,"r") ;
if (calibF_fd == NULL) { if (calibF_fd == NULL) {
printf("ERR: %s not found, running with defaults\n", calibF_fname); printf("ERR: %s not found, running with defaults\n", calibF_fname);
return 1; return(1);
} }
printf("Loading Calibration matrix from %s\n", calibF_fname); printf("Loading Calibration matrix from %s\n", calibF_fname);
...@@ -21,33 +21,37 @@ int read_calibration_matrix(int32_t **tdd_calib_coeffs, char *calibF_fname, LTE_ ...@@ -21,33 +21,37 @@ int read_calibration_matrix(int32_t **tdd_calib_coeffs, char *calibF_fname, LTE_
for (aa=0;aa<frame_parms->nb_antennas_tx;aa++) { for (aa=0;aa<frame_parms->nb_antennas_tx;aa++) {
for(re=0;re<frame_parms->ofdm_symbol_size;re++) { for(re=0;re<frame_parms->ofdm_symbol_size;re++) {
fscanf(calibF_fd, "%d", &calibF_e) ; fscanf(calibF_fd, "%d", &calibF_e) ;
printf("aa=%d, re=%d, tdd_calib[0]=%d\n", aa, re, calibF_e); //printf("aa=%d, re=%d, tdd_calib[0]=%d\n", aa, re, calibF_e);
((int16_t*)(&tdd_calib_coeffs[aa][re]))[0] = calibF_e; ((int16_t*)(&tdd_calib_coeffs[aa][re]))[0] = calibF_e;
fscanf(calibF_fd, "%d", &calibF_e) ; fscanf(calibF_fd, "%d", &calibF_e) ;
printf("aa=%d, re=%d, tdd_calib[1]=%d\n", aa, re, calibF_e); //printf("aa=%d, re=%d, tdd_calib[1]=%d\n", aa, re, calibF_e);
((int16_t*)(&tdd_calib_coeffs[aa][re]))[1] = calibF_e; ((int16_t*)(&tdd_calib_coeffs[aa][re]))[1] = calibF_e;
//printf("aa=%d, re=%d, tdd_calib=%d+i%d\n", aa, re, (int16_t*)(&tdd_calib_coeffs[aa][re])[0],(int16_t*)(&tdd_calib_coeffs[aa][re])[1]); //printf("aa=%d, re=%d, tdd_calib=%d+i%d\n", aa, re, (int16_t*)(&tdd_calib_coeffs[aa][re])[0],(int16_t*)(&tdd_calib_coeffs[aa][re])[1]);
} }
} }
} }
void estimate_DLCSI_from_ULCSI(int32_t **calib_dl_ch_estimates, int32_t **ul_ch_estimates, int32_t **tdd_calib_coeffs, LTE_DL_FRAME_PARMS *frame_parms) { int estimate_DLCSI_from_ULCSI(int32_t **calib_dl_ch_estimates, int32_t **ul_ch_estimates, int32_t **tdd_calib_coeffs, LTE_DL_FRAME_PARMS *frame_parms) {
int aa,re; int aa,re;
if (frame_parms->nb_antennas_tx != frame_parms->nb_antennas_rx) {
printf("ERR : Tx and Rx antennas should be the same for TDD calibration!");
return(1);
}
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) { for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
/*multadd_cpx_vector((int16_t*)(&tdd_calib_coeffs[aa][0]),(int16_t*)(&ul_ch_estimates[aa][0]),(int16_t*)(&calib_dl_ch_estimates[aa][0]),1,nb_freq,15);*/ multadd_cpx_vector((int16_t*)(&tdd_calib_coeffs[aa][0]),(int16_t*)(&ul_ch_estimates[aa][0]),(int16_t*)(&calib_dl_ch_estimates[aa][0]),1,frame_parms->ofdm_symbol_size,15);
for (re=0; re<frame_parms->ofdm_symbol_size; re++) { /*for (re=0; re<frame_parms->ofdm_symbol_size; re++) {
((int16_t*)(&calib_dl_ch_estimates[aa][re]))[0] += (((int16_t*)(&tdd_calib_coeffs[aa][re]))[0]*((int16_t*)(&ul_ch_estimates[aa][re]))[0])>>15; ((int16_t*)(&calib_dl_ch_estimates[aa][re]))[0] += (((int16_t*)(&tdd_calib_coeffs[aa][re]))[0]*((int16_t*)(&ul_ch_estimates[aa][re]))[0])>>15;
((int16_t*)(&calib_dl_ch_estimates[aa][re]))[0] -= (((int16_t*)(&tdd_calib_coeffs[aa][re]))[1]*((int16_t*)(&ul_ch_estimates[aa][re]))[1])>>15; ((int16_t*)(&calib_dl_ch_estimates[aa][re]))[0] -= (((int16_t*)(&tdd_calib_coeffs[aa][re]))[1]*((int16_t*)(&ul_ch_estimates[aa][re]))[1])>>15;
((int16_t*)(&calib_dl_ch_estimates[aa][re]))[1] += (((int16_t*)(&tdd_calib_coeffs[aa][re]))[0]*((int16_t*)(&ul_ch_estimates[aa][re]))[1])>>15; ((int16_t*)(&calib_dl_ch_estimates[aa][re]))[1] += (((int16_t*)(&tdd_calib_coeffs[aa][re]))[0]*((int16_t*)(&ul_ch_estimates[aa][re]))[1])>>15;
((int16_t*)(&calib_dl_ch_estimates[aa][re]))[1] += (((int16_t*)(&tdd_calib_coeffs[aa][re]))[1]*((int16_t*)(&ul_ch_estimates[aa][re]))[0])>>15; ((int16_t*)(&calib_dl_ch_estimates[aa][re]))[1] += (((int16_t*)(&tdd_calib_coeffs[aa][re]))[1]*((int16_t*)(&ul_ch_estimates[aa][re]))[0])>>15;*/
/*printf("aa=%d, re=%d tdd_calib_coeffs= (%d, %d), ul_ch_estimates = (%d, %d), calib_dl_ch_estimates = (%d, %d)\n", /*printf("aa=%d, re=%d tdd_calib_coeffs= (%d, %d), ul_ch_estimates = (%d, %d), calib_dl_ch_estimates = (%d, %d)\n",
aa, re, aa, re,
((int16_t*)&tdd_calib_coeffs[aa][re])[0], ((int16_t*)&tdd_calib_coeffs[aa][re])[1], ((int16_t*)&tdd_calib_coeffs[aa][re])[0], ((int16_t*)&tdd_calib_coeffs[aa][re])[1],
((int16_t*)&ul_ch_estimates[aa][re])[0], ((int16_t*)&ul_ch_estimates[aa][re])[1], ((int16_t*)&ul_ch_estimates[aa][re])[0], ((int16_t*)&ul_ch_estimates[aa][re])[1],
((int16_t*)&calib_dl_ch_estimates[aa][re])[0], ((int16_t*)&calib_dl_ch_estimates[aa][re])[1]);*/ ((int16_t*)&calib_dl_ch_estimates[aa][re])[0], ((int16_t*)&calib_dl_ch_estimates[aa][re])[1]);*/
} //}
} }
} }
...@@ -89,31 +93,31 @@ void main() { ...@@ -89,31 +93,31 @@ void main() {
printf("Test Compute BF weights.\n"); printf("Test Compute BF weights.\n");
int32_t **tdd_calib_coeffs, **calib_dl_ch_estimates, **ul_ch_estimates, **beam_weights; int32_t **tdd_calib_coeffs, **calib_dl_ch_estimates, **ul_ch_estimates, **beam_weights;
int nb_ant, nb_freq, aa, re; int nb_ant, nb_freq, aa, re;
char calibF_fname[] = "calibF.m"; char calibF_fname[] = "calibF.m";
char BF_fname[] = "BF_weights.m"; char BF_fname[] = "BF_weights.m";
FILE *BF_weights_fd; FILE *BF_weights_fd;
nb_ant = 8; nb_ant = 8;
nb_freq = 300; nb_freq = 300;
// memory allocation // memory allocation
tdd_calib_coeffs = (int32_t **)malloc(nb_ant*sizeof(int32_t *)); tdd_calib_coeffs = (int32_t **)malloc(nb_ant*sizeof(int32_t *));
calib_dl_ch_estimates = (int32_t **)malloc(nb_ant*sizeof(int32_t *)); calib_dl_ch_estimates = (int32_t **)malloc(nb_ant*sizeof(int32_t *));
ul_ch_estimates = (int32_t **)malloc(nb_ant*sizeof(int32_t *)); ul_ch_estimates = (int32_t **)malloc(nb_ant*sizeof(int32_t *));
beam_weights = (int32_t **)malloc(nb_ant*sizeof(int32_t *)); beam_weights = (int32_t **)malloc(nb_ant*sizeof(int32_t *));
for (aa=0; aa<nb_ant; aa++) { for (aa=0; aa<nb_ant; aa++) {
tdd_calib_coeffs[aa] = (int32_t *)malloc(nb_freq*sizeof(int32_t)); tdd_calib_coeffs[aa] = (int32_t *)malloc(nb_freq*sizeof(int32_t));
calib_dl_ch_estimates[aa] = (int32_t *)malloc(nb_freq*sizeof(int32_t)); calib_dl_ch_estimates[aa] = (int32_t *)malloc(nb_freq*sizeof(int32_t));
ul_ch_estimates[aa] = (int32_t *)malloc(nb_freq*sizeof(int32_t)); ul_ch_estimates[aa] = (int32_t *)malloc(nb_freq*sizeof(int32_t));
beam_weights[aa] = (int32_t *)malloc(nb_freq*sizeof(int32_t)); beam_weights[aa] = (int32_t *)malloc(nb_freq*sizeof(int32_t));
} }
// ul channel estimation initilisation // ul channel estimation initilisation
for (aa=0; aa<nb_ant; aa++) for (aa=0; aa<nb_ant; aa++)
for (re=0; re<nb_freq; re++) for (re=0; re<nb_freq; re++)
ul_ch_estimates[aa][re] = 0x7fff7fff; ul_ch_estimates[aa][re] = 0x7fff7fff;
// calibration coefficients loading // calibration coefficients loading
read_calibration_matrix(calibF_fname, nb_ant, nb_freq, tdd_calib_coeffs); read_calibration_matrix(calibF_fname, nb_ant, nb_freq, tdd_calib_coeffs);
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
int16_t conjug[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1} ; int16_t conjug[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1} ;
int16_t conjug2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1} ;
#define simd_q15_t __m128i #define simd_q15_t __m128i
#define simdshort_q15_t __m64 #define simdshort_q15_t __m64
#elif defined(__arm__) #elif defined(__arm__)
...@@ -124,3 +125,81 @@ int mult_cpx_conj_vector(int16_t *x1, ...@@ -124,3 +125,81 @@ int mult_cpx_conj_vector(int16_t *x1,
return(0); return(0);
} }
int multadd_cpx_vector(int16_t *x1,
int16_t *x2,
int16_t *y,
uint8_t zero_flag,
uint32_t N,
int output_shift)
{
// Multiply elementwise the complex conjugate of x1 with x2.
// x1 - input 1 in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)|
// We assume x1 with a dinamic of 15 bit maximum
//
// x2 - input 2 in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)|
// We assume x2 with a dinamic of 14 bit maximum
///
// y - output in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)|
//
// zero_flag - Set output (y) to zero prior to disable accumulation
//
// N - the size f the vectors (this function does N cpx mpy. WARNING: N>=4;
//
// output_shift - shift to be applied to generate output
uint32_t i; // loop counter
simd_q15_t *x1_128;
simd_q15_t *x2_128;
simd_q15_t *y_128;
#if defined(__x86_64__) || defined(__i386__)
simd_q15_t tmp_re,tmp_im;
simd_q15_t tmpy0,tmpy1;
#elif defined(__arm__)
int32x4_t tmp_re,tmp_im;
int32x4_t tmp_re1,tmp_im1;
int16x4x2_t tmpy;
int32x4_t shift = vdupq_n_s32(-output_shift);
#endif
x1_128 = (simd_q15_t *)&x1[0];
x2_128 = (simd_q15_t *)&x2[0];
y_128 = (simd_q15_t *)&y[0];
// we compute 4 cpx multiply for each loop
for(i=0; i<(N>>2); i++) {
#if defined(__x86_64__) || defined(__i386__)
tmp_re = _mm_sign_epi16(*x1_128,*(__m128i*)&conjug2[0]);
tmp_re = _mm_madd_epi16(tmp_re,*x2_128);
tmp_im = _mm_shufflelo_epi16(*x1_128,_MM_SHUFFLE(2,3,0,1));
tmp_im = _mm_shufflehi_epi16(tmp_im,_MM_SHUFFLE(2,3,0,1));
tmp_im = _mm_madd_epi16(tmp_im,*x2_128);
tmp_re = _mm_srai_epi32(tmp_re,output_shift);
tmp_im = _mm_srai_epi32(tmp_im,output_shift);
tmpy0 = _mm_unpacklo_epi32(tmp_re,tmp_im);
//print_ints("unpack lo:",&tmpy0[i]);
tmpy1 = _mm_unpackhi_epi32(tmp_re,tmp_im);
//print_ints("unpack hi:",&tmpy1[i]);
if (zero_flag == 1)
*y_128 = _mm_packs_epi32(tmpy0,tmpy1);
else
*y_128 = _mm_adds_epi16(*y_128,_mm_packs_epi32(tmpy0,tmpy1));
//print_shorts("*y_128:",&y_128[i]);
#elif defined(__arm__)
msg("mult_cpx_vector not implemented for __arm__");
#endif
x1_128++;
x2_128++;
y_128++;
}
_mm_empty();
_m_empty();
return(0);
}
...@@ -124,6 +124,25 @@ int mult_cpx_conj_vector(int16_t *x1, ...@@ -124,6 +124,25 @@ int mult_cpx_conj_vector(int16_t *x1,
uint32_t N, uint32_t N,
int output_shift); int output_shift);
/*!
Element-wise multiplication and accumulation of two complex vectors x1 and x2.
@param x1 - input 1 in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)|
We assume x1 with a dinamic of 15 bit maximum
@param x2 - input 2 in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)|
We assume x2 with a dinamic of 14 bit maximum
@param y - output in the format |Re0 Im0 Re1 Im1|,......,|Re(N-2) Im(N-2) Re(N-1) Im(N-1)|
@param zero_flag Set output (y) to zero prior to accumulation
@param N - the size f the vectors (this function does N cpx mpy. WARNING: N>=4;
@param output_shift - shift to be applied to generate output
*/
int multiadd_cpx_vector(int16_t *x1,
int16_t *x2,
int16_t *y,
uint32_t N,
int output_shift);
// lte_dfts.c // lte_dfts.c
void init_fft(uint16_t size, void init_fft(uint16_t size,
uint8_t logsize, uint8_t logsize,
......
...@@ -580,6 +580,7 @@ typedef struct PHY_VARS_eNB_s { ...@@ -580,6 +580,7 @@ typedef struct PHY_VARS_eNB_s {
time_stats_t dlsch_rate_matching_stats; time_stats_t dlsch_rate_matching_stats;
time_stats_t dlsch_turbo_encoding_stats; time_stats_t dlsch_turbo_encoding_stats;
time_stats_t dlsch_interleaving_stats; time_stats_t dlsch_interleaving_stats;
time_stats_t dl_ch_calib_stats;
time_stats_t ofdm_demod_stats; time_stats_t ofdm_demod_stats;
time_stats_t rx_dft_stats; time_stats_t rx_dft_stats;
......
...@@ -1818,7 +1818,7 @@ int main(int argc, char **argv) ...@@ -1818,7 +1818,7 @@ int main(int argc, char **argv)
if ((transmission_mode==1) || (transmission_mode==7)) { if ((transmission_mode==1) || (transmission_mode==7)) {
for (aa=0; aa<eNB->frame_parms.nb_antennas_tx; aa++) for (aa=0; aa<eNB->frame_parms.nb_antennas_tx; aa++)
for (re=0; re<eNB->frame_parms.ofdm_symbol_size; re++) for (re=0; re<eNB->frame_parms.ofdm_symbol_size; re++)
eNB->common_vars.beam_weights[0][0][aa][re] = 0x00007fff/eNB->frame_parms.nb_antennas_tx; eNB->common_vars.beam_weights[0][0][aa][re] = 0x00007fff/sqrt(eNB->frame_parms.nb_antennas_tx);
} }
eNB->mac_enabled=1; eNB->mac_enabled=1;
...@@ -2320,7 +2320,7 @@ int main(int argc, char **argv) ...@@ -2320,7 +2320,7 @@ int main(int argc, char **argv)
//PMI_FEEDBACK: //PMI_FEEDBACK:
// printf("Trial %d : Round %d, pmi_feedback %d \n",trials,round,pmi_feedback); // printf("Trial %d : Round %d, pmi_feedback %d \n",trials,round,pmi_feedback);
for (aa=0; aa<eNB->frame_parms.nb_antennas_tx; aa++) { for (aa=0; aa<eNB->frame_parms.nb_antenna_ports_eNB; aa++) {
memset(&eNB->common_vars.txdataF[eNB_id][aa][0],0,FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX*sizeof(int32_t)); memset(&eNB->common_vars.txdataF[eNB_id][aa][0],0,FRAME_LENGTH_COMPLEX_SAMPLES_NO_PREFIX*sizeof(int32_t));
} }
......
...@@ -992,10 +992,6 @@ int main(int argc, char **argv) ...@@ -992,10 +992,6 @@ int main(int argc, char **argv)
eNB->UE_stats[1].DL_pmi_single = 0; eNB->UE_stats[1].DL_pmi_single = 0;
} }
printf("tdd_calib = %d\n", tdd_calib);
if (tdd_calib == 1)
//for first tests initialze calibration matrix with idendity
read_calibration_matrix(eNB->common_vars.tdd_calib_coeffs[0], "calibF.m", frame_parms);
if (input_fd==NULL) { if (input_fd==NULL) {
...@@ -2108,6 +2104,8 @@ int main(int argc, char **argv) ...@@ -2108,6 +2104,8 @@ int main(int argc, char **argv)
initialize(&time_vector_tx_mod); initialize(&time_vector_tx_mod);
struct list time_vector_tx_enc; struct list time_vector_tx_enc;
initialize(&time_vector_tx_enc); initialize(&time_vector_tx_enc);
struct list time_vector_tx_calib;
initialize(&time_vector_tx_calib);
struct list time_vector_rx; struct list time_vector_rx;
initialize(&time_vector_rx); initialize(&time_vector_rx);
...@@ -2148,6 +2146,7 @@ int main(int argc, char **argv) ...@@ -2148,6 +2146,7 @@ int main(int argc, char **argv)
PMI_FEEDBACK: PMI_FEEDBACK:
if (tdd_calib == 1) { if (tdd_calib == 1) {
start_meas(&eNB->dl_ch_calib_stats);
//make sure dlsim is called with perfect channel estimation option (for freq_channel) //make sure dlsim is called with perfect channel estimation option (for freq_channel)
//fill drs_ch_estimates with data from eNB2UE->chF //fill drs_ch_estimates with data from eNB2UE->chF
for(aa=0; aa<frame_parms->nb_antenna_ports_eNB; aa++) { for(aa=0; aa<frame_parms->nb_antenna_ports_eNB; aa++) {
...@@ -2168,10 +2167,12 @@ PMI_FEEDBACK: ...@@ -2168,10 +2167,12 @@ PMI_FEEDBACK:
eNB->common_vars.tdd_calib_coeffs[0], eNB->common_vars.tdd_calib_coeffs[0],
frame_parms); frame_parms);
/*compute_BF_weights(eNB->dlsch[0][0]->ue_spec_bf_weights[0], compute_BF_weights(eNB->dlsch[0][0]->ue_spec_bf_weights[0],
eNB->dlsch[0][0]->calib_dl_ch_estimates, eNB->dlsch[0][0]->calib_dl_ch_estimates,
MRT, MRT,
frame_parms);*/ frame_parms);
stop_meas(&eNB->dl_ch_calib_stats);
} }
//printf("Trial %d : Round %d, pmi_feedback %d \n",trials,round,pmi_feedback); //printf("Trial %d : Round %d, pmi_feedback %d \n",trials,round,pmi_feedback);
...@@ -3795,6 +3796,7 @@ PMI_FEEDBACK: ...@@ -3795,6 +3796,7 @@ PMI_FEEDBACK:
double t_tx_ifft = (double)eNB->ofdm_mod_stats.p_time/cpu_freq_GHz/1000.0; double t_tx_ifft = (double)eNB->ofdm_mod_stats.p_time/cpu_freq_GHz/1000.0;
double t_tx_mod = (double)eNB->dlsch_modulation_stats.p_time/cpu_freq_GHz/1000.0; double t_tx_mod = (double)eNB->dlsch_modulation_stats.p_time/cpu_freq_GHz/1000.0;
double t_tx_enc = (double)eNB->dlsch_encoding_stats.p_time/cpu_freq_GHz/1000.0; double t_tx_enc = (double)eNB->dlsch_encoding_stats.p_time/cpu_freq_GHz/1000.0;
double t_tx_calib = (double)eNB->dl_ch_calib_stats.p_time/cpu_freq_GHz/1000.0;
double t_rx = (double)UE->phy_proc_rx.p_time/cpu_freq_GHz/1000.0; double t_rx = (double)UE->phy_proc_rx.p_time/cpu_freq_GHz/1000.0;
...@@ -3824,6 +3826,7 @@ PMI_FEEDBACK: ...@@ -3824,6 +3826,7 @@ PMI_FEEDBACK:
push_front(&time_vector_tx_ifft, t_tx_ifft); push_front(&time_vector_tx_ifft, t_tx_ifft);
push_front(&time_vector_tx_mod, t_tx_mod); push_front(&time_vector_tx_mod, t_tx_mod);
push_front(&time_vector_tx_enc, t_tx_enc); push_front(&time_vector_tx_enc, t_tx_enc);
push_front(&time_vector_tx_calib, t_tx_calib);
push_front(&time_vector_rx, t_rx); push_front(&time_vector_rx, t_rx);
push_front(&time_vector_rx_fft, t_rx_fft); push_front(&time_vector_rx_fft, t_rx_fft);
...@@ -3842,6 +3845,8 @@ PMI_FEEDBACK: ...@@ -3842,6 +3845,8 @@ PMI_FEEDBACK:
totable(table_tx_mod, &time_vector_tx_mod); totable(table_tx_mod, &time_vector_tx_mod);
double table_tx_enc[time_vector_tx_enc.size]; double table_tx_enc[time_vector_tx_enc.size];
totable(table_tx_enc, &time_vector_tx_enc); totable(table_tx_enc, &time_vector_tx_enc);
double table_tx_calib[time_vector_tx_calib.size];
totable(table_tx_calib, &time_vector_tx_calib);
double table_rx[time_vector_rx.size]; double table_rx[time_vector_rx.size];
totable(table_rx, &time_vector_rx); totable(table_rx, &time_vector_rx);
...@@ -3894,6 +3899,10 @@ PMI_FEEDBACK: ...@@ -3894,6 +3899,10 @@ PMI_FEEDBACK:
double tx_enc_q1 = table_tx_enc[time_vector_tx_enc.size/4]; double tx_enc_q1 = table_tx_enc[time_vector_tx_enc.size/4];
double tx_enc_q3 = table_tx_enc[3*time_vector_tx_enc.size/4]; double tx_enc_q3 = table_tx_enc[3*time_vector_tx_enc.size/4];
double tx_calib_median = table_tx_calib[time_vector_tx_calib.size/2];
double tx_calib_q1 = table_tx_calib[time_vector_tx_calib.size/4];
double tx_calib_q3 = table_tx_calib[3*time_vector_tx_calib.size/4];
double rx_median = table_rx[time_vector_rx.size/2]; double rx_median = table_rx[time_vector_rx.size/2];
double rx_q1 = table_rx[time_vector_rx.size/4]; double rx_q1 = table_rx[time_vector_rx.size/4];
double rx_q3 = table_rx[3*time_vector_rx.size/4]; double rx_q3 = table_rx[3*time_vector_rx.size/4];
...@@ -3914,6 +3923,7 @@ PMI_FEEDBACK: ...@@ -3914,6 +3923,7 @@ PMI_FEEDBACK:
double std_phy_proc_tx_ifft=0; double std_phy_proc_tx_ifft=0;
double std_phy_proc_tx_mod=0; double std_phy_proc_tx_mod=0;
double std_phy_proc_tx_enc=0; double std_phy_proc_tx_enc=0;
double std_phy_proc_tx_calib=0;
double std_phy_proc_rx=0; double std_phy_proc_rx=0;
double std_phy_proc_rx_fft=0; double std_phy_proc_rx_fft=0;
...@@ -3984,6 +3994,10 @@ PMI_FEEDBACK: ...@@ -3984,6 +3994,10 @@ PMI_FEEDBACK:
printf("|__ DLSCH sub-block interleaving time :%f us (%d trials)\n", printf("|__ DLSCH sub-block interleaving time :%f us (%d trials)\n",
((double)eNB->dlsch_interleaving_stats.trials/eNB->dlsch_encoding_stats.trials)*(double) ((double)eNB->dlsch_interleaving_stats.trials/eNB->dlsch_encoding_stats.trials)*(double)
eNB->dlsch_interleaving_stats.diff/eNB->dlsch_interleaving_stats.trials/cpu_freq_GHz/1000.0,eNB->dlsch_interleaving_stats.trials); eNB->dlsch_interleaving_stats.diff/eNB->dlsch_interleaving_stats.trials/cpu_freq_GHz/1000.0,eNB->dlsch_interleaving_stats.trials);
std_phy_proc_tx_calib = sqrt((double)eNB->dl_ch_calib_stats.diff_square/pow(cpu_freq_GHz,2)/pow(1000,
2)/eNB->dl_ch_calib_stats.trials - pow((double)eNB->dl_ch_calib_stats.diff/eNB->dl_ch_calib_stats.trials/cpu_freq_GHz/1000,2));
printf("TDD_DL_calib time :%f us (%d trials)\n",(double)eNB->dl_ch_calib_stats.diff/eNB->dl_ch_calib_stats.trials/cpu_freq_GHz/1000.0,eNB->dl_ch_calib_stats.trials);
printf("|__ Statistcs std: %fus median %fus q1 %fus q3 %fus \n",std_phy_proc_tx_calib, tx_calib_median, tx_calib_q1, tx_calib_q3);
printf("\n\nUE RX function statistics (per 1ms subframe)\n\n"); printf("\n\nUE RX function statistics (per 1ms subframe)\n\n");
std_phy_proc_rx = sqrt((double)UE->phy_proc_rx.diff_square/pow(cpu_freq_GHz,2)/pow(1000, std_phy_proc_rx = sqrt((double)UE->phy_proc_rx.diff_square/pow(cpu_freq_GHz,2)/pow(1000,
......
...@@ -1627,7 +1627,8 @@ int main( int argc, char **argv ) ...@@ -1627,7 +1627,8 @@ int main( int argc, char **argv )
if ((transmission_mode==1) || (transmission_mode==7)) { if ((transmission_mode==1) || (transmission_mode==7)) {
for (j=0; j<frame_parms[CC_id]->nb_antennas_tx; j++) for (j=0; j<frame_parms[CC_id]->nb_antennas_tx; j++)
for (re=0; re<frame_parms[CC_id]->ofdm_symbol_size; re++) for (re=0; re<frame_parms[CC_id]->ofdm_symbol_size; re++)
PHY_vars_eNB_g[0][CC_id]->common_vars.beam_weights[0][0][j][re] = 0x00007fff/frame_parms[CC_id]->nb_antennas_tx; //In softmodem: the power constraint is on each antenna, so we do not norm the beam weights
PHY_vars_eNB_g[0][CC_id]->common_vars.beam_weights[0][0][j][re] = 0x00007fff;///sqrt(frame_parms[CC_id]->nb_antennas_tx);
} }
if (phy_test==1) PHY_vars_eNB_g[0][CC_id]->mac_enabled = 0; if (phy_test==1) PHY_vars_eNB_g[0][CC_id]->mac_enabled = 0;
else PHY_vars_eNB_g[0][CC_id]->mac_enabled = 1; else PHY_vars_eNB_g[0][CC_id]->mac_enabled = 1;
......
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