Commit f364d13d authored by Cedric Roux's avatar Cedric Roux

Merge branch 'develop_integration_w24' into 'develop'

develop_integration_w24 into develop

Summary or changes:
- work on transmission mode 3 and 4

See merge request !204
parents 7580d021 85ac4e46
......@@ -941,9 +941,14 @@
(Test 7b, 5 MHz, R3-1.FDD (MCS 15), ETU70, 1.4 dB (30%)),
(Test 10, 5 MHz, R6.FDD (MCS 25), EVA5, 17.4 dB (70%)),
(Test 10b, 5 MHz, R6-1.FDD (MCS 24,18 PRB), EVA5, 17.5dB (70%)),
(Test 11, 10 MHz, R7.FDD (MCS 25), EVA5, 17.7dB (70%))
(Test 11, 10 MHz, R7.FDD (MCS 25), EVA5, 17.7dB (70%)),
(Test 11b, 10 MHz, R7-1.FDD (MCS 25), EVA5, 16.7dB (70%)),
(Test 15, 20 MHz, R.9 FDD (MCS 26), EVA5, 17.6dB (70%)),
(Test 15b, 20 MHz, R.9-2 FDD (MCS 26, 17PRB), EVA5, 17.3dB (70%)),
(Test 15c, 20 MHz, R.9-1 FDD (MCS 26, 83 PRB), EVA5, 16.6dB (70%)),
(TM2 Test 1 10 MHz, R.11 FDD (MCS 14), EVA5, 6.8 dB (70%)),
(TM2 Test 1b 20 MHz, R.11-2 FDD (MCS 13), EVA5, 5.9 dB (70%)),
(TM2 Test 1b 5 MHz, R.11-2 FDD (MCS 13), EVA5, 5.9 dB (70%)),
</desc>
<pre_compile_prog></pre_compile_prog>
<compile_prog>$OPENAIR_DIR/cmake_targets/build_oai</compile_prog>
......@@ -960,6 +965,9 @@
-m25 -gF -s17.4 -w1.0 -f.2 -n500 -B25 -c3 -z2 -O70
-m25 -gF -s17.5 -w1.0 -f.2 -n500 -B25 -c3 -z2 -r1022 -O70
-m26 -gF -s17.7 -w1.0 -f.2 -n500 -B50 -c2 -z2 -O70
-m26 -gF -s17.6 -w1.0 -f.2 -n500 -B100 -c2 -z2 -O70
-m26 -gF -s17.3 -w1.0 -f.2 -n500 -B100 -c2 -z2 -r1600 -O70
-m26 -gF -s16.6 -w1.0 -f.2 -n500 -B100 -c2 -z2 -r1899 -O70
-m14 -gF -s6.8 -w1.0 -f.2 -n500 -B50 -c2 -x2 -y2 -z2 -O70
-m13 -gF -s5.9 -w1.0 -f.2 -n500 -B25 -c3 -x2 -y2 -z2 -O70</main_exec_args>
<tags>dlsim.test1 dlsim.test5 dlsim.test6 dlsim.test6b dlsim.test7 dlsim.test7b dlsim.test10 dlsim.test10b dlsim.test11 dlsim.TM2_test1 dlsim.TM2_test1b</tags>
......
......@@ -3,7 +3,7 @@ set(PACKAGE_NAME "unitary_tests_simulators")
set(PHYSIM True)
set(RF_BOARD None)
set(XFORMS True)
set(ENABLE_ITTI False)
set(DEBUG_PHY False)
set(MU_RECIEVER False)
set(RANDOM_BF False)
......
......@@ -58,7 +58,7 @@ filter/filter.a:
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f *.o core tracer_remote textlog enb vcd record replay
rm -f *.o core tracer_remote textlog enb ue vcd record replay
rm -f extract_config macpdu2wireshark
cd gui && make clean
cd view && make clean
......
......@@ -161,7 +161,7 @@ int lte_est_freq_offset(int **dl_ch_estimates,
LTE_DL_FRAME_PARMS *frame_parms,
int l,
int* freq_offset,
int reset);
int reset);
int lte_mbsfn_est_freq_offset(int **dl_ch_estimates,
LTE_DL_FRAME_PARMS *frame_parms,
......@@ -180,7 +180,7 @@ This function computes the time domain channel response, finds the peak and adju
void lte_adjust_synch(LTE_DL_FRAME_PARMS *frame_parms,
PHY_VARS_UE *phy_vars_ue,
module_id_t eNb_id,
uint8_t subframe,
uint8_t subframe,
unsigned char clear,
short coef);
......@@ -189,7 +189,8 @@ void lte_ue_measurements(PHY_VARS_UE *phy_vars_ue,
unsigned int subframe_offset,
unsigned char N0_symbol,
unsigned char abstraction_flag,
uint8_t subframe);
unsigned char rank_adaptation,
uint8_t subframe);
//! \brief This function performance RSRP/RSCP measurements
void ue_rrc_measurements(PHY_VARS_UE *phy_vars_ue,
......@@ -214,11 +215,11 @@ int8_t set_RSRQ_filtered(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index,floa
//! Automatic gain control
void phy_adjust_gain (PHY_VARS_UE *phy_vars_ue,
uint32_t rx_power_fil_dB,
uint32_t rx_power_fil_dB,
unsigned char eNB_id);
int lte_ul_channel_estimation(PHY_VARS_eNB *phy_vars_eNB,
eNB_rxtx_proc_t *proc,
eNB_rxtx_proc_t *proc,
module_id_t eNB_id,
module_id_t UE_id,
uint8_t l,
......@@ -246,7 +247,7 @@ int lte_est_timing_advance(LTE_DL_FRAME_PARMS *frame_parms,
int lte_est_timing_advance_pusch(PHY_VARS_eNB* phy_vars_eNB,module_id_t UE_id);
void lte_eNB_I0_measurements(PHY_VARS_eNB *phy_vars_eNB,
int subframe,
int subframe,
module_id_t eNB_id,
unsigned char clear);
......
......@@ -34,6 +34,9 @@
//#define DEBUG_MEAS_RRC
//#define DEBUG_MEAS_UE
//#define DEBUG_RANK_EST
int16_t cond_num_threshold = 0;
#ifdef USER_MODE
void print_shorts(char *s,short *x)
......@@ -207,8 +210,8 @@ void ue_rrc_measurements(PHY_VARS_UE *ue,
if(ue->frame_parms.frame_type == FDD)
{
rxF_sss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[aarx][(5*ue->frame_parms.ofdm_symbol_size)];
rxF_pss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[aarx][(6*ue->frame_parms.ofdm_symbol_size)];
rxF_sss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[aarx][(5*ue->frame_parms.ofdm_symbol_size)];
rxF_pss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[aarx][(6*ue->frame_parms.ofdm_symbol_size)];
}
else
{
......@@ -218,17 +221,17 @@ void ue_rrc_measurements(PHY_VARS_UE *ue,
//-ve spectrum from SSS
//+ve spectrum from SSS
ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+70]*rxF_sss[2+70])+((int32_t)rxF_sss[2+69]*rxF_sss[2+69]));
ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+70]*rxF_sss[2+70])+((int32_t)rxF_sss[2+69]*rxF_sss[2+69]));
ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+68]*rxF_sss[2+68])+((int32_t)rxF_sss[2+67]*rxF_sss[2+67]));
ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+66]*rxF_sss[2+66])+((int32_t)rxF_sss[2+65]*rxF_sss[2+65]));
// ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+64]*rxF_sss[2+64])+((int32_t)rxF_sss[2+63]*rxF_sss[2+63]));
// printf("sssp32 %d\n",ue->measurements.n0_power[aarx]);
// ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[2+64]*rxF_sss[2+64])+((int32_t)rxF_sss[2+63]*rxF_sss[2+63]));
// printf("sssp32 %d\n",ue->measurements.n0_power[aarx]);
//+ve spectrum from PSS
ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+70]*rxF_pss[2+70])+((int32_t)rxF_pss[2+69]*rxF_pss[2+69]));
ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+68]*rxF_pss[2+68])+((int32_t)rxF_pss[2+67]*rxF_pss[2+67]));
ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+66]*rxF_pss[2+66])+((int32_t)rxF_pss[2+65]*rxF_pss[2+65]));
// ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+64]*rxF_pss[2+64])+((int32_t)rxF_pss[2+63]*rxF_pss[2+63]));
// printf("pss32 %d\n",ue->measurements.n0_power[aarx]); //-ve spectrum from PSS
// ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[2+64]*rxF_pss[2+64])+((int32_t)rxF_pss[2+63]*rxF_pss[2+63]));
// printf("pss32 %d\n",ue->measurements.n0_power[aarx]); //-ve spectrum from PSS
if(ue->frame_parms.frame_type == FDD)
{
rxF_sss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[aarx][(6*ue->frame_parms.ofdm_symbol_size)];
......@@ -239,29 +242,29 @@ void ue_rrc_measurements(PHY_VARS_UE *ue,
rxF_sss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[(subframe+1)&0x1].rxdataF[aarx][(14*ue->frame_parms.ofdm_symbol_size)];
rxF_pss = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[aarx][(3*ue->frame_parms.ofdm_symbol_size)];
}
// ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-72]*rxF_pss[-72])+((int32_t)rxF_pss[-71]*rxF_pss[-71]));
// printf("pssm36 %d\n",ue->measurements.n0_power[aarx]);
// ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-72]*rxF_pss[-72])+((int32_t)rxF_pss[-71]*rxF_pss[-71]));
// printf("pssm36 %d\n",ue->measurements.n0_power[aarx]);
ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-70]*rxF_pss[-70])+((int32_t)rxF_pss[-69]*rxF_pss[-69]));
ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-68]*rxF_pss[-68])+((int32_t)rxF_pss[-67]*rxF_pss[-67]));
ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-66]*rxF_pss[-66])+((int32_t)rxF_pss[-65]*rxF_pss[-65]));
ue->measurements.n0_power[aarx] = (((int32_t)rxF_sss[-70]*rxF_sss[-70])+((int32_t)rxF_sss[-69]*rxF_sss[-69]));
ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[-68]*rxF_sss[-68])+((int32_t)rxF_sss[-67]*rxF_sss[-67]));
ue->measurements.n0_power[aarx] += (((int32_t)rxF_sss[-66]*rxF_sss[-66])+((int32_t)rxF_sss[-65]*rxF_sss[-65]));
// ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-64]*rxF_pss[-64])+((int32_t)rxF_pss[-63]*rxF_pss[-63]));
// printf("pssm32 %d\n",ue->measurements.n0_power[aarx]);
// ue->measurements.n0_power[aarx] += (((int32_t)rxF_pss[-64]*rxF_pss[-64])+((int32_t)rxF_pss[-63]*rxF_pss[-63]));
// printf("pssm32 %d\n",ue->measurements.n0_power[aarx]);
ue->measurements.n0_power_dB[aarx] = (unsigned short) dB_fixed(ue->measurements.n0_power[aarx]/12);
ue->measurements.n0_power_tot /*+=*/ = ue->measurements.n0_power[aarx];
}
}
//LOG_I(PHY,"Subframe %d RRC UE MEAS Noise Level %d \n", subframe, ue->measurements.n0_power_tot);
ue->measurements.n0_power_tot_dB = (unsigned short) dB_fixed(ue->measurements.n0_power_tot/(12*aarx));
ue->measurements.n0_power_tot_dBm = ue->measurements.n0_power_tot_dB - ue->rx_total_gain_dB - dB_fixed(ue->frame_parms.ofdm_symbol_size);
} else {
ue->measurements.n0_power_tot_dB = (unsigned short) dB_fixed(ue->measurements.n0_power_tot/(12*aarx));
ue->measurements.n0_power_tot_dBm = ue->measurements.n0_power_tot_dB - ue->rx_total_gain_dB - dB_fixed(ue->frame_parms.ofdm_symbol_size);
} else {
LOG_E(PHY, "Not yet implemented: noise power calculation when prefix length = EXTENDED\n");
}
}
}
else if ((ue->frame_parms.frame_type == TDD) &&
((subframe == 1) || (subframe == 6))) { // TDD PSS/SSS, compute noise in DTX REs // 2016-09-29 wilson fix incorrect noise power calculation
......@@ -310,12 +313,11 @@ void ue_rrc_measurements(PHY_VARS_UE *ue,
// printf("pssm32 %d\n",ue->measurements.n0_power[aarx]);
ue->measurements.n0_power_dB[aarx] = (unsigned short) dB_fixed(ue->measurements.n0_power[aarx]/12);
ue->measurements.n0_power_tot /*+=*/ = ue->measurements.n0_power[aarx];
}
}
ue->measurements.n0_power_tot_dB = (unsigned short) dB_fixed(ue->measurements.n0_power_tot/(12*aarx));
ue->measurements.n0_power_tot_dBm = ue->measurements.n0_power_tot_dB - ue->rx_total_gain_dB - dB_fixed(ue->frame_parms.ofdm_symbol_size);
//LOG_I(PHY,"Subframe %d RRC UE MEAS Noise Level %d \n", subframe, ue->measurements.n0_power_tot);
}
......@@ -357,8 +359,8 @@ void ue_rrc_measurements(PHY_VARS_UE *ue,
ue->measurements.rsrp[eNB_offset] += (((int32_t)(rxF[off])*rxF[off])+((int32_t)(rxF[off+1])*rxF[off+1]));
// printf("rb %d, off %d : %d\n",rb,off,((((int32_t)rxF[off])*rxF[off])+((int32_t)(rxF[off+1])*rxF[off+1])));
// if ((ue->frame_rx&0x3ff) == 0)
// printf("rb %d, off %d : %d\n",rb,off,((rxF[off]*rxF[off])+(rxF[off+1]*rxF[off+1])));
// if ((ue->frame_rx&0x3ff) == 0)
// printf("rb %d, off %d : %d\n",rb,off,((rxF[off]*rxF[off])+(rxF[off+1]*rxF[off+1])));
off+=12;
......@@ -424,7 +426,7 @@ void ue_rrc_measurements(PHY_VARS_UE *ue,
// if (slot == 0) {
if (eNB_offset == 0)
LOG_I(PHY,"[UE %d] Frame %d, subframe %d RRC Measurements => rssi %3.1f dBm (digital: %3.1f dB, gain %d), N0 %d dBm\n",ue->Mod_id,
LOG_I(PHY,"[UE %d] Frame %d, subframe %d RRC Measurements => rssi %3.1f dBm (digital: %3.1f dB, gain %d), N0 %d dBm\n",ue->Mod_id,
ue->proc.proc_rxtx[subframe&1].frame_rx,subframe,10*log10(ue->measurements.rssi)-ue->rx_total_gain_dB,
10*log10(ue->measurements.rssi),
ue->rx_total_gain_dB,
......@@ -454,7 +456,8 @@ void lte_ue_measurements(PHY_VARS_UE *ue,
unsigned int subframe_offset,
unsigned char N0_symbol,
unsigned char abstraction_flag,
uint8_t subframe)
unsigned char rank_adaptation,
uint8_t subframe)
{
......@@ -468,17 +471,17 @@ void lte_ue_measurements(PHY_VARS_UE *ue,
int16x8_t *dl_ch0_128, *dl_ch1_128;
#endif
int *dl_ch0,*dl_ch1;
LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
int nb_subbands,subband_size,last_subband_size;
int N_RB_DL = frame_parms->N_RB_DL;
int rank_tm3_tm4;
ue->measurements.nb_antennas_rx = frame_parms->nb_antennas_rx;
if (ue->transmission_mode[eNB_id]!=4)
ue->measurements.rank[eNB_id] = 0;
else
ue->measurements.rank[eNB_id] = 1;
// printf ("tx mode %d\n", ue->transmission_mode[eNB_id]);
// printf ("rank %d\n", ue->PHY_measurements.rank[eNB_id]);
switch (N_RB_DL) {
case 6:
......@@ -539,6 +542,28 @@ void lte_ue_measurements(PHY_VARS_UE *ue,
} //eNB_id
eNB_id=0;
if (ue->transmission_mode[0]==4 || ue->transmission_mode[0]==3){
if (rank_adaptation == 1)
rank_tm3_tm4 = rank_estimation_tm3_tm4(&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][0][4],
&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][2][4],
&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][1][4],
&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].dl_ch_estimates[eNB_id][3][4],
N_RB_DL);
else
rank_tm3_tm4=1;
#ifdef DEBUG_RANK_EST
printf("rank tm3 or tm4 %d\n", rank_tm3_tm4);
#endif
}
if (ue->transmission_mode[eNB_id]!=4 && ue->transmission_mode[eNB_id]!=3)
ue->measurements.rank[eNB_id] = 0;
else
ue->measurements.rank[eNB_id] = rank_tm3_tm4;
// printf ("tx mode %d\n", ue->transmission_mode[eNB_id]);
// printf ("rank %d\n", ue->PHY_measurements.rank[eNB_id]);
// filter to remove jitter
if (ue->init_averaging == 0) {
for (eNB_id = 0; eNB_id < ue->n_connected_eNB; eNB_id++)
......@@ -547,7 +572,7 @@ void lte_ue_measurements(PHY_VARS_UE *ue,
(k2*((long long int)(ue->measurements.rx_power_tot[eNB_id]))))>>10);
//LOG_I(PHY,"Noise Power Computation: k1 %d k2 %d n0 avg %d n0 tot %d\n", k1, k2, ue->measurements.n0_power_avg,
// ue->measurements.n0_power_tot);
// ue->measurements.n0_power_tot);
ue->measurements.n0_power_avg = (int)
(((k1*((long long int) (ue->measurements.n0_power_avg))) +
(k2*((long long int) (ue->measurements.n0_power_tot))))>>10);
......@@ -567,12 +592,12 @@ void lte_ue_measurements(PHY_VARS_UE *ue,
#ifdef DEBUG_MEAS_UE
LOG_I(PHY,"[eNB %d] Subframe %d, RSSI %d dBm, RSSI (digital) %d dB, WBandCQI %d dB, rxPwrAvg %d, n0PwrAvg %d\n",
eNB_id,
subframe,
subframe,
ue->measurements.rx_rssi_dBm[eNB_id],
ue->measurements.rx_power_avg_dB[eNB_id],
ue->measurements.wideband_cqi_avg[eNB_id],
ue->measurements.rx_power_avg[eNB_id],
ue->measurements.n0_power_avg);
ue->measurements.n0_power_tot);
#endif
}
......@@ -633,7 +658,7 @@ void lte_ue_measurements(PHY_VARS_UE *ue,
}
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
//printf("aarx=%d", aarx);
//printf("aarx=%d", aarx);
// skip the first 4 RE due to interpolation filter length of 5 (not possible to skip 5 due to 128i alignment, must be multiple of 128bit)
#if defined(__x86_64__) || defined(__i386__)
......@@ -654,12 +679,12 @@ void lte_ue_measurements(PHY_VARS_UE *ue,
// pmi
#if defined(__x86_64__) || defined(__i386__)
pmi128_re = _mm_xor_si128(pmi128_re,pmi128_re);
pmi128_re = _mm_xor_si128(pmi128_re,pmi128_re);
pmi128_im = _mm_xor_si128(pmi128_im,pmi128_im);
#elif defined(__arm__)
pmi128_re = vdupq_n_s32(0);
pmi128_im = vdupq_n_s32(0);
pmi128_im = vdupq_n_s32(0);
#endif
// limit is the number of groups of 4 REs in a subband (12 = 4 RBs, 3 = 1 RB)
// for 5 MHz channelization, there are 7 subbands, 6 of size 4 RBs and 1 of size 1 RB
......@@ -671,48 +696,48 @@ void lte_ue_measurements(PHY_VARS_UE *ue,
for (i=0; i<limit; i++) {
#if defined(__x86_64__) || defined(__i386__)
mmtmpPMI0 = _mm_xor_si128(mmtmpPMI0,mmtmpPMI0);
mmtmpPMI0 = _mm_xor_si128(mmtmpPMI0,mmtmpPMI0);
mmtmpPMI1 = _mm_xor_si128(mmtmpPMI1,mmtmpPMI1);
// For each RE in subband perform ch0 * conj(ch1)
// multiply by conjugated channel
// print_ints("ch0",&dl_ch0_128[0]);
// print_ints("ch1",&dl_ch1_128[0]);
// print_ints("ch0",&dl_ch0_128[0]);
// print_ints("ch1",&dl_ch1_128[0]);
mmtmpPMI0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch1_128[0]);
// print_ints("re",&mmtmpPMI0);
mmtmpPMI0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch1_128[0]);
// print_ints("re",&mmtmpPMI0);
mmtmpPMI1 = _mm_shufflelo_epi16(dl_ch1_128[0],_MM_SHUFFLE(2,3,0,1));
// print_ints("_mm_shufflelo_epi16",&mmtmpPMI1);
mmtmpPMI1 = _mm_shufflehi_epi16(mmtmpPMI1,_MM_SHUFFLE(2,3,0,1));
// print_ints("_mm_shufflehi_epi16",&mmtmpPMI1);
// print_ints("_mm_shufflehi_epi16",&mmtmpPMI1);
mmtmpPMI1 = _mm_sign_epi16(mmtmpPMI1,*(__m128i*)&conjugate[0]);
// print_ints("_mm_sign_epi16",&mmtmpPMI1);
// print_ints("_mm_sign_epi16",&mmtmpPMI1);
mmtmpPMI1 = _mm_madd_epi16(mmtmpPMI1,dl_ch0_128[0]);
// print_ints("mm_madd_epi16",&mmtmpPMI1);
// print_ints("mm_madd_epi16",&mmtmpPMI1);
// mmtmpPMI1 contains imag part of 4 consecutive outputs (32-bit)
pmi128_re = _mm_add_epi32(pmi128_re,mmtmpPMI0);
// print_ints(" pmi128_re 0",&pmi128_re);
// print_ints(" pmi128_re 0",&pmi128_re);
pmi128_im = _mm_add_epi32(pmi128_im,mmtmpPMI1);
// print_ints(" pmi128_im 0 ",&pmi128_im);
// print_ints(" pmi128_im 0 ",&pmi128_im);
/* mmtmpPMI0 = _mm_xor_si128(mmtmpPMI0,mmtmpPMI0);
/* mmtmpPMI0 = _mm_xor_si128(mmtmpPMI0,mmtmpPMI0);
mmtmpPMI1 = _mm_xor_si128(mmtmpPMI1,mmtmpPMI1);
mmtmpPMI0 = _mm_madd_epi16(dl_ch0_128[1],dl_ch1_128[1]);
// print_ints("re",&mmtmpPMI0);
mmtmpPMI0 = _mm_madd_epi16(dl_ch0_128[1],dl_ch1_128[1]);
// print_ints("re",&mmtmpPMI0);
mmtmpPMI1 = _mm_shufflelo_epi16(dl_ch1_128[1],_MM_SHUFFLE(2,3,0,1));
// print_ints("_mm_shufflelo_epi16",&mmtmpPMI1);
mmtmpPMI1 = _mm_shufflehi_epi16(mmtmpPMI1,_MM_SHUFFLE(2,3,0,1));
// print_ints("_mm_shufflehi_epi16",&mmtmpPMI1);
// print_ints("_mm_shufflehi_epi16",&mmtmpPMI1);
mmtmpPMI1 = _mm_sign_epi16(mmtmpPMI1,*(__m128i*)&conjugate);
// print_ints("_mm_sign_epi16",&mmtmpPMI1);
// print_ints("_mm_sign_epi16",&mmtmpPMI1);
mmtmpPMI1 = _mm_madd_epi16(mmtmpPMI1,dl_ch0_128[1]);
// print_ints("mm_madd_epi16",&mmtmpPMI1);
// print_ints("mm_madd_epi16",&mmtmpPMI1);
// mmtmpPMI1 contains imag part of 4 consecutive outputs (32-bit)
pmi128_re = _mm_add_epi32(pmi128_re,mmtmpPMI0);
// print_ints(" pmi128_re 1",&pmi128_re);
// print_ints(" pmi128_re 1",&pmi128_re);
pmi128_im = _mm_add_epi32(pmi128_im,mmtmpPMI1);
//print_ints(" pmi128_im 1 ",&pmi128_im);*/
//print_ints(" pmi128_im 1 ",&pmi128_im);*/
#elif defined(__arm__)
......@@ -806,3 +831,553 @@ void lte_ue_measurements_emul(PHY_VARS_UE *ue,uint8_t subframe,uint8_t eNB_id)
msg("[PHY] EMUL UE lte_ue_measurements_emul subframe %d, eNB_id %d\n",subframe,eNB_id);
}
uint8_t rank_estimation_tm3_tm4 (int *dl_ch_estimates_00, // please respect the order of channel estimates
int *dl_ch_estimates_01,
int *dl_ch_estimates_10,
int *dl_ch_estimates_11,
unsigned short nb_rb)
{
int i=0;
int rank=0;
int N_RB=nb_rb;
int *ch00_rank, *ch01_rank, *ch10_rank, *ch11_rank;
int32_t shift;
int avg_0[2];
int avg_1[2];
int count=0;
/* we need at least alignment to 16 bytes, let's put 32 to be sure
* (maybe not necessary but doesn't hurt)
*/
int32_t conjch00_ch01[12*N_RB] __attribute__((aligned(32)));
int32_t conjch01_ch00[12*N_RB] __attribute__((aligned(32)));
int32_t conjch10_ch11[12*N_RB] __attribute__((aligned(32)));
int32_t conjch11_ch10[12*N_RB] __attribute__((aligned(32)));
int32_t conjch00_ch00[12*N_RB] __attribute__((aligned(32)));
int32_t conjch01_ch01[12*N_RB] __attribute__((aligned(32)));
int32_t conjch10_ch10[12*N_RB] __attribute__((aligned(32)));
int32_t conjch11_ch11[12*N_RB] __attribute__((aligned(32)));
int32_t af_mf_00[12*N_RB] __attribute__((aligned(32)));
int32_t af_mf_00_sq[12*N_RB] __attribute__((aligned(32)));
int32_t af_mf_01_sq[12*N_RB] __attribute__((aligned(32)));
int32_t af_mf_10_sq[12*N_RB] __attribute__((aligned(32)));
int32_t af_mf_11_sq[12*N_RB] __attribute__((aligned(32)));
int32_t af_mf_01[12*N_RB] __attribute__((aligned(32)));
int32_t af_mf_10[12*N_RB] __attribute__((aligned(32)));
int32_t af_mf_11[12*N_RB] __attribute__((aligned(32)));
int32_t determ_fin[12*N_RB] __attribute__((aligned(32)));
int32_t denum_db[12*N_RB] __attribute__((aligned(32)));
int32_t numer_fin[12*N_RB] __attribute__((aligned(32)));
int32_t numer_db[12*N_RB] __attribute__((aligned(32)));
int32_t cond_db[12*N_RB] __attribute__((aligned(32)));
ch00_rank = dl_ch_estimates_00;
ch01_rank = dl_ch_estimates_01;
ch10_rank = dl_ch_estimates_10;
ch11_rank = dl_ch_estimates_11;
dlsch_channel_level_TM34_meas(ch00_rank,
ch01_rank,
ch10_rank,
ch11_rank,
avg_0,
avg_1,
N_RB);
avg_0[0] = (log2_approx(avg_0[0])/2);
shift = cmax(avg_0[0],0);
#ifdef DEBUG_RANK_EST
printf("\n shift %d \n" , shift);
printf("\n conj(ch00)ch01 \n");
#endif
conjch0_mult_ch1(ch00_rank,
ch01_rank,
conjch00_ch01,
N_RB,
shift); // this is an arbitrary shift to avoid overflow. can be changed.
#ifdef DEBUG_RANK_EST
printf("\n conj(ch01)ch00 \n");
#endif
conjch0_mult_ch1(ch01_rank,
ch00_rank,
conjch01_ch00,
N_RB,
shift);
#ifdef DEBUG_RANK_EST
printf("\n conj(ch10)ch11 \n");
#endif
conjch0_mult_ch1(ch10_rank,
ch11_rank,
conjch10_ch11,
N_RB,
shift);
#ifdef DEBUG_RANK_EST
printf("\n conj(ch11)ch10 \n");
#endif
conjch0_mult_ch1(ch11_rank,
ch10_rank,
conjch11_ch10,
N_RB,
shift);
#ifdef DEBUG_RANK_EST
printf("\n conj(ch00)ch00 \n");
#endif
conjch0_mult_ch1(ch00_rank,
ch00_rank,
conjch00_ch00,
N_RB,
shift);
#ifdef DEBUG_RANK_EST
printf("\n conj(ch01)ch01 \n");
#endif
conjch0_mult_ch1(ch01_rank,
ch01_rank,
conjch01_ch01,
N_RB,
shift);
#ifdef DEBUG_RANK_EST
printf("\n conj(ch10)ch10 \n");
#endif
conjch0_mult_ch1(ch10_rank,
ch10_rank,
conjch10_ch10,
N_RB,
shift);
#ifdef DEBUG_RANK_EST
printf("\n conj(ch11)ch11 \n");
#endif
conjch0_mult_ch1(ch11_rank,
ch11_rank,
conjch11_ch11,
N_RB,
shift);
construct_HhH_elements(conjch00_ch00,
conjch01_ch01,
conjch11_ch11,
conjch10_ch10,
conjch00_ch01,
conjch01_ch00,
conjch10_ch11,
conjch11_ch10,
af_mf_00,
af_mf_01,
af_mf_10,
af_mf_11,
N_RB);
#ifdef DEBUG_RANK_EST
printf("\n |HhH00|^2 \n");
#endif
squared_matrix_element(af_mf_00,
af_mf_00_sq,
N_RB);
#ifdef DEBUG_RANK_EST
printf("\n |HhH01|^2 \n");
#endif
squared_matrix_element(af_mf_01,
af_mf_01_sq,
N_RB);
#ifdef DEBUG_RANK_EST
printf("\n |HhH10|^2 \n");
#endif
squared_matrix_element(af_mf_10,
af_mf_10_sq,
N_RB);
#ifdef DEBUG_RANK_EST
printf("\n |HhH11|^2 \n");
#endif
squared_matrix_element(af_mf_11,
af_mf_11_sq,
N_RB);
det_HhH(af_mf_00,
af_mf_01,
af_mf_10,
af_mf_11,
determ_fin,
N_RB);
numer(af_mf_00_sq,
af_mf_01_sq,
af_mf_10_sq,
af_mf_11_sq,
numer_fin,
N_RB);
for (i=1; i<12*N_RB; i++)
{
denum_db[i]=dB_fixed(determ_fin[i]);
numer_db[i]=dB_fixed(numer_fin[i]);
cond_db[i]=(numer_db[i]-denum_db[i]);
if (cond_db[i] < cond_num_threshold)
count++;
#ifdef DEBUG_RANK_EST
printf("cond_num_threshold =%d \n", cond_num_threshold);
printf("i %d numer_db[i] = %d \n", i, numer_db[i]);
printf("i %d denum_db[i] = %d \n", i, denum_db[i]);
printf("i %d cond_db[i] = %d \n", i, cond_db[i]);
printf("i %d counter = %d \n", i, count);
#endif
}
if (count >= 6*N_RB) // conditional number is lower 10dB in half on more Res Blocks
rank=1;
#ifdef DEBUG_RANK_EST
printf(" rank = %d \n", rank);
#endif
return(rank);
}
void conjch0_mult_ch1(int *ch0,
int *ch1,
int32_t *ch0conj_ch1,
unsigned short nb_rb,
unsigned char output_shift0)
{
//This function is used to compute multiplications in Hhermitian * H matrix
unsigned short rb;
__m128i *dl_ch0_128,*dl_ch1_128, *ch0conj_ch1_128, mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3;
dl_ch0_128 = (__m128i *)ch0;
dl_ch1_128 = (__m128i *)ch1;
ch0conj_ch1_128 = (__m128i *)ch0conj_ch1;
for (rb=0; rb<3*nb_rb; rb++) {
mmtmpD0 = _mm_madd_epi16(dl_ch0_128[0],dl_ch1_128[0]);
mmtmpD1 = _mm_shufflelo_epi16(dl_ch0_128[0],_MM_SHUFFLE(2,3,0,1));
mmtmpD1 = _mm_shufflehi_epi16(mmtmpD1,_MM_SHUFFLE(2,3,0,1));
mmtmpD1 = _mm_sign_epi16(mmtmpD1,*(__m128i*)&conjugate[0]);
mmtmpD1 = _mm_madd_epi16(mmtmpD1,dl_ch1_128[0]);
mmtmpD0 = _mm_srai_epi32(mmtmpD0,output_shift0);
mmtmpD1 = _mm_srai_epi32(mmtmpD1,output_shift0);
mmtmpD2 = _mm_unpacklo_epi32(mmtmpD0,mmtmpD1);
mmtmpD3 = _mm_unpackhi_epi32(mmtmpD0,mmtmpD1);
ch0conj_ch1_128[0] = _mm_packs_epi32(mmtmpD2,mmtmpD3);
#ifdef DEBUG_RANK_EST
printf("\n Computing conjugates \n");
print_shorts("ch0:",(int16_t*)&dl_ch0_128[0]);
print_shorts("ch1:",(int16_t*)&dl_ch1_128[0]);
print_shorts("pack:",(int16_t*)&ch0conj_ch1_128[0]);
#endif
dl_ch0_128+=1;
dl_ch1_128+=1;
ch0conj_ch1_128+=1;
}
_mm_empty();
_m_empty();
}
void construct_HhH_elements(int *ch0conj_ch0, //00_00
int *ch1conj_ch1,//01_01
int *ch2conj_ch2,//11_11
int *ch3conj_ch3,//10_10
int *ch0conj_ch1,//00_01
int *ch1conj_ch0,//01_00
int *ch2conj_ch3,//10_11
int *ch3conj_ch2,//11_10
int32_t *after_mf_00,
int32_t *after_mf_01,
int32_t *after_mf_10,
int32_t *after_mf_11,
unsigned short nb_rb)
{
unsigned short rb;
__m128i *ch0conj_ch0_128, *ch1conj_ch1_128, *ch2conj_ch2_128, *ch3conj_ch3_128;
__m128i *ch0conj_ch1_128, *ch1conj_ch0_128, *ch2conj_ch3_128, *ch3conj_ch2_128;
__m128i *after_mf_00_128, *after_mf_01_128, *after_mf_10_128, *after_mf_11_128;