Commit d81f42d3 authored by masayuki.harada's avatar masayuki.harada Committed by Haruki NAOI

Fix: FFT overflow.

(cherry picked from commit 27c97696ce5ada578c454aeb5abbff5f07eda730)
parent 71565ba1
......@@ -45,7 +45,6 @@
//extern int **ulchmag_eren;
//eren
static short jitter[8] __attribute__ ((aligned(16))) = {1,0,0,1,0,1,1,0};
static short jitterc[8] __attribute__ ((aligned(16))) = {0,1,1,0,1,0,0,1};
void lte_idft(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Msc_PUSCH)
......@@ -809,6 +808,8 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext,
uint8_t aarx;//,symbol_mod;
__m128i mmtmpU0,mmtmpU1,mmtmpU2,mmtmpU3;
static short ref_min[8] __attribute__ ((aligned(16))) = {SHRT_MIN ,SHRT_MIN ,SHRT_MIN ,SHRT_MIN ,SHRT_MIN ,SHRT_MIN ,SHRT_MIN ,SHRT_MIN };
#elif defined(__arm__)
int16x4_t *ul_ch128,*rxdataF128;
......@@ -819,7 +820,7 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext,
int16_t conj[4]__attribute__((aligned(16))) = {1,-1,1,-1};
int32x4_t output_shift128 = vmovq_n_s32(-(int32_t)output_shift);
static short ref_min[8] __attribute__ ((aligned(16))) = {SHRT_MIN ,SHRT_MIN ,SHRT_MIN ,SHRT_MIN ,SHRT_MIN ,SHRT_MIN ,SHRT_MIN ,SHRT_MIN };
#endif
......@@ -952,9 +953,9 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext,
// print_shorts("pack:",rxdataF_comp128[2]);
// Add a jitter to compensate for the saturation in "packs" resulting in a bias on the DC after IDFT
rxdataF_comp128[0] = _mm_add_epi16(rxdataF_comp128[0],(*(__m128i*)&jitter[0]));
rxdataF_comp128[1] = _mm_add_epi16(rxdataF_comp128[1],(*(__m128i*)&jitter[0]));
rxdataF_comp128[2] = _mm_add_epi16(rxdataF_comp128[2],(*(__m128i*)&jitter[0]));
rxdataF_comp128[0] = _mm_subs_epi16(rxdataF_comp128[0], _mm_cmpeq_epi16(rxdataF_comp128[0],(*(__m128i*)&ref_min[0])));
rxdataF_comp128[1] = _mm_subs_epi16(rxdataF_comp128[1], _mm_cmpeq_epi16(rxdataF_comp128[1],(*(__m128i*)&ref_min[0])));
rxdataF_comp128[2] = _mm_subs_epi16(rxdataF_comp128[2], _mm_cmpeq_epi16(rxdataF_comp128[2],(*(__m128i*)&ref_min[0])));
ul_ch128+=3;
ul_ch_mag128+=3;
......@@ -1009,10 +1010,9 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext,
rxdataF_comp128[2] = vcombine_s16(vmovn_s32(mmtmpU0),vmovn_s32(mmtmpU1));
// Add a jitter to compensate for the saturation in "packs" resulting in a bias on the DC after IDFT
rxdataF_comp128[0] = vqaddq_s16(rxdataF_comp128[0],(*(int16x8_t*)&jitter[0]));
rxdataF_comp128[1] = vqaddq_s16(rxdataF_comp128[1],(*(int16x8_t*)&jitter[0]));
rxdataF_comp128[2] = vqaddq_s16(rxdataF_comp128[2],(*(int16x8_t*)&jitter[0]));
rxdataF_comp128[0] = vqsubq_s16(rxdataF_comp128[0], vceqq_s16(rxdataF_comp128[0],(*(int16x8_t*)&ref_min[0])));
rxdataF_comp128[1] = vqsubq_s16(rxdataF_comp128[1], vceqq_s16(rxdataF_comp128[1],(*(int16x8_t*)&ref_min[0])));
rxdataF_comp128[2] = vqsubq_s16(rxdataF_comp128[2], vceqq_s16(rxdataF_comp128[1],(*(int16x8_t*)&ref_min[0])));
ul_ch128+=6;
ul_ch_mag128+=3;
......@@ -1152,7 +1152,10 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
LOG_E(PHY, "PUSCH (%d/%x) nb_rb=0!\n", harq_pid,ulsch[UE_id]->rnti);
return;
}
short *rxF_ext;
int re;
double ave_power=0;
int shift=0;
for (l=0; l<(frame_parms->symbols_per_tti-ulsch[UE_id]->harq_processes[harq_pid]->srs_active); l++) {
if(LOG_DEBUGFLAG(DEBUG_ULSCH)) {
......@@ -1170,6 +1173,28 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
l%(frame_parms->symbols_per_tti/2),
l/(frame_parms->symbols_per_tti/2),
frame_parms);
for(re=0;re<ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12;re++){
rxF_ext = (short*)&pusch_vars->rxdataF_ext[0][(l*frame_parms->N_RB_UL*12)+re];
ave_power+=rxF_ext[0]*rxF_ext[0]+rxF_ext[1]*rxF_ext[1];
}
}
ave_power/=(double)(ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12*(frame_parms->symbols_per_tti-ulsch[UE_id]->harq_processes[harq_pid]->srs_active));
LOG_D(PHY,"rxF_ext ave %lf\n",sqrt(ave_power));
if(ave_power>1.0){
shift = 3 - (int)log2(sqrt((double)ave_power));
}
if(shift>0){
short * temp_iq;
for(i=0;i<frame_parms->symbols_per_tti*frame_parms->ofdm_symbol_size;i++){
temp_iq=(short*)&pusch_vars->rxdataF_ext[0][i];
temp_iq[0]<<=shift;
temp_iq[1]<<=shift;
}
}else{
shift=0;
}
for (l=0; l<(frame_parms->symbols_per_tti-ulsch[UE_id]->harq_processes[harq_pid]->srs_active); l++) {
if (lte_ul_channel_estimation(eNB,proc,
UE_id,
......@@ -1211,6 +1236,8 @@ void rx_ulsch(PHY_VARS_eNB *eNB,
pusch_vars->ulsch_interference_power[i] = pusch_vars->ulsch_interference_power[i]/correction_factor;
pusch_vars->ulsch_power[i] = pusch_vars->ulsch_power[i]/correction_factor;
pusch_vars->ulsch_power[i] /= pow(4,shift);
pusch_vars->ulsch_interference_power[i] /= pow(4,shift);
if(pusch_vars->ulsch_power[i]>0x20000000){
pusch_vars->ulsch_power[i] = 0x20000000;
pusch_vars->ulsch_interference_power[i] = 1;
......
......@@ -589,7 +589,6 @@ void init_fep_thread(RU_t *ru,pthread_attr_t *attr_fep) {
pthread_create(&proc->pthread_fep, attr_fep, fep_thread, (void*)ru);
}
extern void kill_fep_thread(RU_t *ru)
......@@ -772,8 +771,31 @@ void fep_full(RU_t *ru) {
LTE_DL_FRAME_PARMS *fp=&ru->frame_parms;
if ((fp->frame_type == TDD) &&
(subframe_select(fp,proc->subframe_rx) != SF_UL)) return;
(subframe_select(fp,proc->subframe_rx) != SF_UL)) {
double recv_pow=0;
int i,idx;
int shift=0;
short * temp_iq;
for(i=0;i<fp->samples_per_tti;i++){
idx=i+fp->samples_per_tti*proc->subframe_rx- ru->N_TA_offset;
if(idx<0) idx+=fp->samples_per_tti*10;
temp_iq=(short*)&ru->common.rxdata[0][idx];
recv_pow += (double)temp_iq[0]*(double)temp_iq[0]+(double)temp_iq[1]*(double)temp_iq[1];
}
recv_pow /= (double)fp->samples_per_tti;
if(recv_pow>1.0){
shift = 3 - (int)log2(sqrt((double)recv_pow));
}
if(shift>0){
LOG_D(PHY,"ave pow %lf shift %d\n",sqrt((double)recv_pow),shift);
for(i=0;i<fp->samples_per_tti;i++){
idx=i+fp->samples_per_tti*proc->subframe_rx- ru->N_TA_offset;
if(idx<0) idx+=fp->samples_per_tti*10;
temp_iq=(short*)&ru->common.rxdata[0][idx];
temp_iq[0]<<=shift;
temp_iq[1]<<=shift;
}
}
start_meas(&ru->ofdm_demod_stats);
if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX+ru->idx, 1 );
......@@ -795,6 +817,14 @@ void fep_full(RU_t *ru) {
if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX+ru->idx, 0 );
stop_meas(&ru->ofdm_demod_stats);
if(shift>0){
short * temp_iq;
for(i=0;i<fp->ofdm_symbol_size*14;i++){
temp_iq=(short*)&ru->common.rxdataF[0][i];
temp_iq[0]>>=shift;
temp_iq[1]>>=shift;
}
}
}
......
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