diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c index b21f526fcc05851a0253edf585983aafb395e52f..ce8188a3e7c55fd623070fda20549a573f31e765 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c @@ -131,14 +131,6 @@ void lte_sync_time_free(void) { } -static inline int abs32(int x) { - return (((int)((short*)&x)[0])*((int)((short*)&x)[0]) + ((int)((short*)&x)[1])*((int)((short*)&x)[1])); -} - -static inline double absF(struct complexd x) { - return x.r*x.r+x.i*x.i; -} - #define complexNull(c) bzero((void*) &(c), sizeof(c)) #define SHIFT 17 @@ -368,12 +360,6 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain } -static inline int64_t abs64(int64_t x) { - return (((int64_t)((int32_t *)&x)[0])*((int64_t)((int32_t *)&x)[0]) + ((int64_t) - ((int32_t *)&x)[1])*((int64_t)((int32_t *)&x)[1])); -} - - int ru_sync_time(RU_t *ru, int64_t *lev, int64_t *avg) { diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c index 0dcbbe48f4cad7040f8cefadabcc425b77115299..788675d67c2802ea9f27afb48a04ecfbb52006b8 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c @@ -35,16 +35,11 @@ //#define DEBUG_PDSCH //#define DEBUG_PDCCH -//#define DEBUG_CH -//#define DEBUG_PRS_CHEST -//#define DEBUG_PRS_PRINTS +//#define DEBUG_PBCH +//#define DEBUG_PRS_CHEST // To enable PRS Matlab dumps +//#define DEBUG_PRS_PRINTS // To enable PRS channel estimation debug logs extern short nr_qpsk_mod_table[8]; -static inline int abs32(int x) -{ - return (((int)((short*)&x)[0])*((int)((short*)&x)[0]) + ((int)((short*)&x)[1])*((int)((short*)&x)[1])); -} - int nr_prs_channel_estimation(uint8_t gNB_id, uint8_t rsc_id, uint8_t rep_num, @@ -613,7 +608,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, k = nushift; -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("PBCH DMRS Correlation : ThreadId %d, gNB_id %d , OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",proc->thread_id, gNB_id,ue->frame_parms.ofdm_symbol_size, ue->frame_parms.Ncp,Ns,k, symbol); #endif @@ -627,7 +622,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, pil = (int16_t *)&pilot[0]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("pbch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL); printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset); printf("rxF addr %p\n", rxF); @@ -641,7 +636,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, current_ssb->c_re += ch[0]; current_ssb->c_im += ch[1]; -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); #endif @@ -657,7 +652,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, current_ssb->c_re += ch[0]; current_ssb->c_im += ch[1]; -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif @@ -668,7 +663,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, current_ssb->c_re += ch[0]; current_ssb->c_im += ch[1]; -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif @@ -693,7 +688,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, current_ssb->c_re += ch[0]; current_ssb->c_im += ch[1]; -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif @@ -708,7 +703,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, current_ssb->c_re += ch[0]; current_ssb->c_im += ch[1]; -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif pil += 2; @@ -722,7 +717,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, current_ssb->c_re += ch[0]; current_ssb->c_im += ch[1]; -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif @@ -778,7 +773,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, k = nushift; -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("PBCH Channel Estimation : ThreadId %d, gNB_id %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",proc->thread_id, gNB_id,ch_offset,ue->frame_parms.ofdm_symbol_size, ue->frame_parms.Ncp,Ns,k, symbol); #endif @@ -870,7 +865,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, memset(dl_ch,0,sizeof(struct complex16)*(ue->frame_parms.ofdm_symbol_size)); -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("pbch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL); printf("k %d, first_carrier %d\n",k,ue->frame_parms.first_carrier_offset); printf("rxF addr %p\n", rxF); @@ -882,7 +877,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("ch 0 %d\n",((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])); printf("pilot 0 : rxF - > (%d,%d) addr %p ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]); #endif @@ -901,7 +896,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("pilot 1 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fm, @@ -915,7 +910,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("pilot 2 : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif @@ -943,7 +938,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fl, @@ -962,7 +957,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+1,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif multadd_real_vector_complex_scalar(fm, @@ -976,7 +971,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); -#ifdef DEBUG_CH +#ifdef DEBUG_PBCH printf("pilot %u : rxF - > (%d,%d) ch -> (%d,%d), pil -> (%d,%d) \n",pilot_cnt+2,rxF[0],rxF[1],ch[0],ch[1],pil[0],pil[1]); #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index d2034f3abf45d567d1915be0ce40736227bd613f..1236dfbc5155d6a8e69887c1917933b18ae66810 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -600,24 +600,6 @@ int pss_synchro_nr(PHY_VARS_NR_UE *PHY_vars_UE, int is, int rate_change) } -static inline int abs32(int x) -{ - return (((int)((short*)&x)[0])*((int)((short*)&x)[0]) + ((int)((short*)&x)[1])*((int)((short*)&x)[1])); -} - -static inline int64_t abs64(int64_t x) -{ - return (((int64_t)((int32_t*)&x)[0])*((int64_t)((int32_t*)&x)[0]) + ((int64_t)((int32_t*)&x)[1])*((int64_t)((int32_t*)&x)[1])); -} - -static inline double angle64(int64_t x) -{ - - double re=((int32_t*)&x)[0]; - double im=((int32_t*)&x)[1]; - return (atan2(im,re)); -} - /******************************************************************* * diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h index 892fb7c8644344529aadb050d54fc8f569d2970b..b9ecbb700d7591a8c72dccd744e2533af74961ac 100644 --- a/openair1/PHY/defs_common.h +++ b/openair1/PHY/defs_common.h @@ -1113,4 +1113,26 @@ static inline int release_thread(pthread_mutex_t *mutex, return(0); } +static inline int32_t abs32(int32_t x) +{ + return (((int32_t)((int16_t*)&x)[0])*((int32_t)((int16_t*)&x)[0]) + ((int32_t)((int16_t*)&x)[1])*((int32_t)((int16_t*)&x)[1])); +} + +static inline int64_t abs64(int64_t x) +{ + return (((int64_t)((int32_t*)&x)[0])*((int64_t)((int32_t*)&x)[0]) + ((int64_t)((int32_t*)&x)[1])*((int64_t)((int32_t*)&x)[1])); +} + +static inline double absF(struct complexd x) { + return x.r*x.r+x.i*x.i; +} + +static inline double angle64(int64_t x) +{ + + double re=((int32_t*)&x)[0]; + double im=((int32_t*)&x)[1]; + return (atan2(im,re)); +} + #endif // __PHY_DEFS_COMMON_H__