Commit 75cf5870 authored by lfarizav's avatar lfarizav

new signal function

parent 8316e294
This diff is collapsed.
......@@ -2163,6 +2163,7 @@ int32_t generate_prach_freq(PHY_VARS_UE *phy_vars_ue,uint8_t eNB_id,uint8_t subf
*/
void rx_prach(PHY_VARS_eNB *phy_vars_eNB,uint16_t *preamble_energy_list, uint16_t *preamble_delay_list, uint16_t Nf, uint8_t tdd_mapindex);
void rx_prach_freq(PHY_VARS_eNB *phy_vars_eNB,uint16_t *preamble_energy_list, uint16_t *preamble_delay_list, uint16_t Nf, uint8_t tdd_mapindex);
/*!
\brief Helper for MAC, returns number of available PRACH in TDD for a particular configuration index
......
......@@ -308,6 +308,7 @@ void mmxcopy(void *dest,void *src,int size);
\brief Computes the signal energy per subcarrier
*/
int32_t signal_energy(int32_t *,uint32_t);
int32_t signal_energy_prach(int32_t *,uint32_t);
#ifdef LOCALIZATION
/*!\fn int32_t signal_energy(int *,uint32_t);
......
......@@ -113,7 +113,52 @@ int32_t signal_energy(int32_t *input,uint32_t length)
return((temp>0)?temp:1);
}
int32_t signal_energy_prach(int32_t *input,uint32_t length)
{
int32_t i;
int32_t temp,temp2;
register __m64 mm0,mm1,mm2,mm3;
__m64 *in = (__m64 *)input;
mm0 = _mm_setzero_si64();//pxor(mm0,mm0);
mm3 = _mm_setzero_si64();//pxor(mm3,mm3);
for (i=0; i<length; i+=2) {
mm1 = in[i];
mm2 = mm1;
mm1 = _m_pmaddwd(mm1,mm1);
mm1 = _m_psradi(mm1,shift);// shift any 32 bits blocs of the word by the value shift
mm0 = _m_paddd(mm0,mm1);// add the two 64 bits words 4 bytes by 4 bytes
// mm2 = _m_psrawi(mm2,shift_DC);
mm3 = _m_paddw(mm3,mm2);// add the two 64 bits words 2 bytes by 2 bytes
}
mm1 = mm0;
mm0 = _m_psrlqi(mm0,32);
mm0 = _m_paddd(mm0,mm1);
temp = _m_to_int(mm0);
temp/=(length/2);
temp<<=shift; // this is the average of x^2
// now remove the DC component
mm2 = _m_psrlqi(mm3,32);
mm2 = _m_paddw(mm2,mm3);
mm2 = _m_pmaddwd(mm2,mm2);
temp2 = _m_to_int(mm2);
temp2/=(length*length/4);
// temp2<<=(2*shift_DC);
temp -= temp2;
_mm_empty();
_m_empty();
return((temp>0)?temp:1);
}
int32_t signal_energy_nodc(int32_t *input,uint32_t length)
{
......
......@@ -1996,21 +1996,34 @@ void prach_procedures(PHY_VARS_eNB *eNB) {
int subframe = eNB->proc.subframe_prach;
int frame = eNB->proc.frame_prach;
uint8_t CC_id = eNB->CC_id;
int do_ofdm_mod = PHY_vars_UE_g[0][0]->do_ofdm_mod;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,1);
memset(&preamble_energy_list[0],0,64*sizeof(uint16_t));
memset(&preamble_delay_list[0],0,64*sizeof(uint16_t));
if (eNB->abstraction_flag == 0) {
LOG_D(PHY,"[eNB %d][RAPROC] Frame %d, Subframe %d : PRACH RX Signal Power : %d dBm\n",eNB->Mod_id,
if (do_ofdm_mod)
{
LOG_D(PHY,"[eNB %d][RAPROC] Frame %d, Subframe %d : PRACH RX Signal Power : %d dBm\n",eNB->Mod_id,
frame,subframe,dB_fixed(signal_energy(&eNB->common_vars.rxdataF[0][0][subframe*fp->symbols_per_tti*fp->ofdm_symbol_size],512)) - eNB->rx_total_gain_dB);
rx_prach_freq(eNB,
preamble_energy_list,
preamble_delay_list,
frame,
0);
}
else
{
LOG_D(PHY,"[eNB %d][RAPROC] Frame %d, Subframe %d : PRACH RX Signal Power : %d dBm\n",eNB->Mod_id,
frame,subframe,dB_fixed(signal_energy(&eNB->common_vars.rxdata[0][0][subframe*fp->samples_per_tti],512)) - eNB->rx_total_gain_dB);
rx_prach(eNB,
rx_prach(eNB,
preamble_energy_list,
preamble_delay_list,
frame,
0);
}
} else {
for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
......
......@@ -2671,6 +2671,11 @@ void ue_measurement_procedures(
// LOG_I(PHY," l==(6-ue->frame_parms.Ncp) ue_rrc_measurements\n");
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_RRC_MEASUREMENTS, VCD_FUNCTION_IN);
if (ue->do_ofdm_mod)
ue_rrc_measurements_freq(ue,
slot,
abstraction_flag);
else
ue_rrc_measurements(ue,
slot,
abstraction_flag);
......@@ -3731,12 +3736,13 @@ void ue_pdsch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, PDSC
//TM7 UE specific channel estimation here!!!
if (ue->transmission_mode[eNB_id]==7) {
if (ue->frame_parms.Ncp==0) {
if ((m==3) || (m==6) || (m==9) || (m==12))
if ((m==3) || (m==6) || (m==9) || (m==12)){
//LOG_D(PHY,"[UE %d] dlsch->active in subframe %d => %d, l=%d\n",phy_vars_ue->Mod_id,subframe_rx,phy_vars_ue->dlsch_ue[eNB_id][0]->active, l);
if (ue->do_ofdm_mod)
lte_dl_bf_channel_estimation_freq(ue,eNB_id,0,subframe_rx*2+(m>6?1:0),5,m);
else
lte_dl_bf_channel_estimation(ue,eNB_id,0,subframe_rx*2+(m>6?1:0),5,m);
}
} else {
LOG_E(PHY,"[UE %d]Beamforming channel estimation not supported yet for TM7 extented CP.\n",ue->Mod_id);
}
......
......@@ -148,7 +148,7 @@ double dac_fixed_gain_prach(double *s_re[2],
amp1 = 0;
for (aa=0; aa<nb_tx_antennas; aa++) {
amp1 += sqrt((double)signal_energy((int32_t*)&input[input_offset_meas],length_meas)/NB_RE);
amp1 += sqrt((double)signal_energy_prach((int32_t*)&input[input_offset_meas],length_meas*2)/NB_RE);
}
amp1/=nb_tx_antennas;
......@@ -166,11 +166,12 @@ double dac_fixed_gain_prach(double *s_re[2],
//printf("DL: amp1 %f dB (%d,%d), tx_power %f\n",20*log10(amp1),input_offset,input_offset_meas,txpwr_dBm);
*/
for (i=0; i<length; i++) {
printf("[dac_fixed_gain_prach] input_offset %d\n",input_offset);
for (i=0; i<length*2; i+=2) {
for (aa=0; aa<nb_tx_antennas; aa++) {
s_re[aa][i] = amp*((double)(((short *)input))[((i+input_offset)<<1)])/amp1; ///(1<<(B-1));
s_im[aa][i] = amp*((double)(((short *)input))[((i+input_offset)<<1)+1])/amp1; ///(1<<(B-1));
printf("[dac_fixed_gain_prach] input (%d,%d)\n",(((short *)input))[((i+input_offset))],(((short *)input))[((i+input_offset))+1]);
s_re[aa][i/2] = amp*((double)(((short *)input))[((i+input_offset))])/amp1; ///(1<<(B-1));
s_im[aa][i/2] = amp*((double)(((short *)input))[((i+input_offset))+1])/amp1; ///(1<<(B-1));
}
}
......
......@@ -154,7 +154,7 @@ int init_freq_channel_prach(channel_desc_t *desc,uint16_t nb_rb,int16_t n_sample
return(-1);
}
if (nb_rb-prach_prb_offset<6) {
fprintf(stderr, "freq_channel_init: Impossible to allocate PRACH, modify prach_prb_offset value\n");
fprintf(stderr, "freq_channel_init: Impossible to allocate PRACH, check prach_prb_offset value (r_ra_prb=%d)\n",prach_prb_offset);
return(-1);
}
prach_samples = (prach_fmt<4)?13+839+12:3+139+2;
......@@ -165,10 +165,10 @@ int init_freq_channel_prach(channel_desc_t *desc,uint16_t nb_rb,int16_t n_sample
delta_f = (prach_fmt<4)?nb_rb*180000/((n_samples-1)*12):nb_rb*180000/((n_samples-1)*2);//1.25 khz for preamble format 1,2,3. 7.5 khz for preample format 4
max_nb_rb_samples = nb_rb*180000/delta_f;//7200 if prach_fmt<4
prach_pbr_offset_samples = (prach_prb_offset+6)*180000/delta_f;//864 if prach_prb_offset=0,7200 if prach_prb_offset=44=50-6
printf("prach_samples = %d, delta_f = %e, max_nb_rb_samples= %d, prach_pbr_offset_samples = %d\n",prach_samples,delta_f,max_nb_rb_samples,prach_pbr_offset_samples);
printf("prach_samples = %d, delta_f = %e, max_nb_rb_samples= %d, prach_pbr_offset_samples = %d, nb_taps = %d\n",prach_samples,delta_f,max_nb_rb_samples,prach_pbr_offset_samples,desc->nb_taps);
for (f=max_nb_rb_samples/2-prach_pbr_offset_samples,f1=0; f<max_nb_rb_samples/2-prach_pbr_offset_samples+prach_samples; f++,f1++) {//3600-864,3600-864+864|3600-7200,3600-7200+839
freq=delta_f*(double)f*1e-6;// due to the fact that delays is in mus
printf("[init_freq_channel_prach] freq %e\n",freq);
cos_lut[f1] = (double *)malloc((int)desc->nb_taps*sizeof(double));
sin_lut[f1] = (double *)malloc((int)desc->nb_taps*sizeof(double));
......@@ -208,7 +208,7 @@ int freq_channel_prach(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int
return(-1);
}
if (nb_rb-prach_prb_offset<6) {
fprintf(stderr, "freq_channel_init: Impossible to allocate PRACH, check prach_prb_offset value\n");
fprintf(stderr, "freq_channel_init: Impossible to allocate PRACH, check r_ra_prb value (r_ra_prb=%d)\n",prach_prb_offset);
return(-1);
}
if (freq_channel_init == 0) {
......@@ -227,17 +227,18 @@ int freq_channel_prach(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int
slut = sin_lut[f];
for (aarx=0; aarx<desc->nb_rx; aarx++) {
for (aatx=0; aatx<desc->nb_tx; aatx++) {
desc->chF[aarx+(aatx*desc->nb_rx)][f].x=0.0;
desc->chF[aarx+(aatx*desc->nb_rx)][f].y=0.0;
desc->chF_prach[aarx+(aatx*desc->nb_rx)][f].x=0.0;
desc->chF_prach[aarx+(aatx*desc->nb_rx)][f].y=0.0;
for (l=0; l<(int)desc->nb_taps; l++) {
desc->chF[aarx+(aatx*desc->nb_rx)][f].x+=(desc->a[l][aarx+(aatx*desc->nb_rx)].x*clut[l]+
desc->chF_prach[aarx+(aatx*desc->nb_rx)][f].x+=(desc->a[l][aarx+(aatx*desc->nb_rx)].x*clut[l]+
desc->a[l][aarx+(aatx*desc->nb_rx)].y*slut[l]);
desc->chF[aarx+(aatx*desc->nb_rx)][f].y+=(-desc->a[l][aarx+(aatx*desc->nb_rx)].x*slut[l]+
desc->chF_prach[aarx+(aatx*desc->nb_rx)][f].y+=(-desc->a[l][aarx+(aatx*desc->nb_rx)].x*slut[l]+
desc->a[l][aarx+(aatx*desc->nb_rx)].y*clut[l]);
}
}
}
printf("chF_prach[0][%d], (x,y) = (%e,%e)\n",f,desc->chF_prach[0][f].x,desc->chF_prach[0][f].y);
}
stop_meas(&desc->interp_freq);
return(0);
......
......@@ -59,6 +59,8 @@ typedef struct {
struct complex **ch;
///Sampled frequency response (90 kHz resolution)
struct complex **chF;
///Sampled prach frequency response (frequency analysis)
struct complex **chF_prach;
///Maximum path delay in mus.
double Td;
///Channel bandwidth in MHz.
......@@ -310,7 +312,8 @@ void multipath_channel_prach(channel_desc_t *desc,
uint8_t eNB_id,
uint8_t UE_id,
uint8_t CC_id,
uint8_t th_id);
uint8_t th_id,
uint8_t subframe);
/*
\fn double compute_pbch_sinr(channel_desc_t *desc,
channel_desc_t *desc_i1,
......
......@@ -350,7 +350,8 @@ void multipath_channel_prach(channel_desc_t *desc,
uint8_t eNB_id,
uint8_t UE_id,
uint8_t CC_id,
uint8_t th_id)
uint8_t th_id,
uint8_t subframe)
{
LTE_DL_FRAME_PARMS* const fp = &PHY_vars_UE_g[UE_id][CC_id]->frame_parms;
int prach_samples;
......@@ -380,32 +381,31 @@ void multipath_channel_prach(channel_desc_t *desc,
// do nothing - keep channel
} else {
random_channel(desc,0);//Find a(l)
freq_channel_prach(desc,nb_rb,n_samples,prach_fmt,n_ra_prb);//Find desc->chF
freq_channel_prach(desc,nb_rb,n_samples,prach_fmt,n_ra_prb);//Find desc->chF_prach
}
for (l=0;l<symbols_per_tti;l++){//0-13 normal cyclic prefix
k = (12*n_ra_prb) - 6*fp->N_RB_UL;
if (k<0)
k+=fp->ofdm_symbol_size;
k*=12;
//k+=13;
k+=1;
printf("[multipath prach] k: %d\n",k);
k+=13;
k*=2;
for (f=0;f<prach_samples; f++) {
if (k>=((prach_fmt<4)?12:2)*ofdm_symbol_size)
k=0;
rx_tmp.x = 0;
rx_tmp.y = 0;
rx_tmp.x = 0;
rx_tmp.y = 0;
for (ii=0; ii<desc->nb_rx; ii++) {
for (j=0; j<desc->nb_tx; j++) {
//RX_RE(k) = TX_RE(k).chF(k).x - TX_IM(k).chF(k).y
rx_tmp.x += ((tx_sig_re[ii][k+l*ofdm_symbol_size*12] * desc->chF[ii+(j*desc->nb_rx)][f].x)-(tx_sig_im[ii][k+l*ofdm_symbol_size*12] * desc->chF[ii+(j*desc->nb_rx)][f].y));
rx_tmp.x += ((tx_sig_re[ii][k+l*ofdm_symbol_size*12] * desc->chF_prach[ii+(j*desc->nb_rx)][f].x)-(tx_sig_im[ii][k+l*ofdm_symbol_size*12] * desc->chF_prach[ii+(j*desc->nb_rx)][f].y));
//RX_IM(k) = TX_IM(k).chF(k).x + TX_RE(k).chF(k).y
rx_tmp.y += ((tx_sig_im[ii][k+l*ofdm_symbol_size*12] * desc->chF[ii+(j*desc->nb_rx)][f].x)+(tx_sig_re[ii][k+l*ofdm_symbol_size*12] * desc->chF[ii+(j*desc->nb_rx)][f].y));
rx_tmp.y += ((tx_sig_im[ii][k+l*ofdm_symbol_size*12] * desc->chF_prach[ii+(j*desc->nb_rx)][f].x)+(tx_sig_re[ii][k+l*ofdm_symbol_size*12] * desc->chF_prach[ii+(j*desc->nb_rx)][f].y));
} // j
rx_sig_re[ii][k+l*ofdm_symbol_size*12] = rx_tmp.x*path_loss;
rx_sig_im[ii][k+l*ofdm_symbol_size*12] = rx_tmp.y*path_loss;
//printf("[multipath prach] k: %d\n",k/2);
rx_sig_re[ii][(k++)+l*ofdm_symbol_size*12] = rx_tmp.x*path_loss;
rx_sig_im[ii][(k++)+l*ofdm_symbol_size*12] = rx_tmp.y*path_loss;
} // ii
k++;
} // f
}//l
}
......
This diff is collapsed.
This diff is collapsed.
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