Commit 40338296 authored by Raymond Knopp's avatar Raymond Knopp

Merge branch 'l1-sidelink' of https://gitlab.eurecom.fr/matzakos/LTE-D2D into l1-sidelink

parents 07349091 e07db38f
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
int32_t* sync_corr_ue0 = NULL; int32_t* sync_corr_ue0 = NULL;
int32_t* sync_corr_ue1 = NULL; int32_t* sync_corr_ue1 = NULL;
int32_t* sync_corr_ue2 = NULL; int32_t* sync_corr_ue2 = NULL;
int32_t sync_tmp[2048*4] __attribute__((aligned(32)));
int16_t syncF_tmp[2048*2] __attribute__((aligned(32)));
extern int16_t s6n_kHz_7_5[1920]; extern int16_t s6n_kHz_7_5[1920];
...@@ -63,6 +61,8 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com ...@@ -63,6 +61,8 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
{ {
int i,k; int i,k;
int32_t sync_tmp[2048*4] __attribute__((aligned(32)));
int16_t syncF_tmp[2048*2] __attribute__((aligned(32)));
sync_corr_ue0 = (int32_t *)malloc16(4*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*sizeof(int32_t)*frame_parms->samples_per_tti); sync_corr_ue0 = (int32_t *)malloc16(4*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*sizeof(int32_t)*frame_parms->samples_per_tti);
sync_corr_ue1 = (int32_t *)malloc16(4*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*sizeof(int32_t)*frame_parms->samples_per_tti); sync_corr_ue1 = (int32_t *)malloc16(4*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*sizeof(int32_t)*frame_parms->samples_per_tti);
...@@ -167,7 +167,7 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com ...@@ -167,7 +167,7 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
} else AssertFatal(1==0,"primary_synch1SL_time_rx not allocated\n"); } else AssertFatal(1==0,"primary_synch1SL_time_rx not allocated\n");
memset((void*)syncF_tmp,0,2048*sizeof(int32_t));
// generate oversampled sync_time sequences // generate oversampled sync_time sequences
k=frame_parms->ofdm_symbol_size-36; k=frame_parms->ofdm_symbol_size-36;
...@@ -217,6 +217,8 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com ...@@ -217,6 +217,8 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
for (i=0; i<frame_parms->ofdm_symbol_size; i++) for (i=0; i<frame_parms->ofdm_symbol_size; i++)
((int32_t*)primary_synch0_time)[i] = sync_tmp[i]; ((int32_t*)primary_synch0_time)[i] = sync_tmp[i];
memset((void*)syncF_tmp,0,2048*sizeof(int32_t));
k=frame_parms->ofdm_symbol_size-36; k=frame_parms->ofdm_symbol_size-36;
for (i=0; i<72; i++) { for (i=0; i<72; i++) {
...@@ -265,6 +267,8 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com ...@@ -265,6 +267,8 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
for (i=0; i<frame_parms->ofdm_symbol_size; i++) for (i=0; i<frame_parms->ofdm_symbol_size; i++)
((int32_t*)primary_synch1_time)[i] = sync_tmp[i]; ((int32_t*)primary_synch1_time)[i] = sync_tmp[i];
memset((void*)syncF_tmp,0,2048*sizeof(int32_t));
k=frame_parms->ofdm_symbol_size-36; k=frame_parms->ofdm_symbol_size-36;
for (i=0; i<72; i++) { for (i=0; i<72; i++) {
...@@ -313,6 +317,8 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com ...@@ -313,6 +317,8 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
for (i=0; i<frame_parms->ofdm_symbol_size; i++) for (i=0; i<frame_parms->ofdm_symbol_size; i++)
((int32_t*)primary_synch2_time)[i] = sync_tmp[i]; ((int32_t*)primary_synch2_time)[i] = sync_tmp[i];
memset((void*)syncF_tmp,0,2048*sizeof(int32_t));
k=frame_parms->ofdm_symbol_size-36; k=frame_parms->ofdm_symbol_size-36;
for (i=0; i<72; i++) { for (i=0; i<72; i++) {
...@@ -325,7 +331,7 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com ...@@ -325,7 +331,7 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
} }
} }
uint16_t *kHz7_5ptr; int16_t *kHz7_5ptr;
switch (frame_parms->N_RB_DL) { switch (frame_parms->N_RB_DL) {
...@@ -333,21 +339,21 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com ...@@ -333,21 +339,21 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
idft128((int16_t*)syncF_tmp, /// complex input idft128((int16_t*)syncF_tmp, /// complex input
(int16_t*)sync_tmp, /// complex output (int16_t*)sync_tmp, /// complex output
1); 1);
kHz7_5ptr = (frame_parms->Ncp==0) ? (((uint32_t*)s6n_kHz_7_5)+138): (((uint32_t*)s6e_kHz_7_5)+160); kHz7_5ptr = (frame_parms->Ncp==0) ? &s6n_kHz_7_5[2*138]: &s6e_kHz_7_5[2*160];
break; break;
case 25: case 25:
idft512((int16_t*)syncF_tmp, /// complex input idft512((int16_t*)syncF_tmp, /// complex input
(int16_t*)sync_tmp, /// complex output (int16_t*)sync_tmp, /// complex output
1); 1);
kHz7_5ptr = (frame_parms->Ncp==0) ? (((uint32_t*)s25n_kHz_7_5)+552) : (((uint32_t*)s25e_kHz_7_5)+640); kHz7_5ptr = (frame_parms->Ncp==0) ? &s25n_kHz_7_5[2*552] : &s25e_kHz_7_5[2*640];
break; break;
case 50: case 50:
idft1024((int16_t*)syncF_tmp, /// complex input idft1024((int16_t*)syncF_tmp, /// complex input
(int16_t*)sync_tmp, /// complex output (int16_t*)sync_tmp, /// complex output
1); 1);
kHz7_5ptr = (frame_parms->Ncp==0) ? &s50n_kHz_7_5[2*1104] : s50e_kHz_7_5[2*1280]; kHz7_5ptr = (frame_parms->Ncp==0) ? &s50n_kHz_7_5[2*1104] : &s50e_kHz_7_5[2*1280];
printf("%p\n",kHz7_5ptr); printf("%p\n",kHz7_5ptr);
break; break;
...@@ -355,14 +361,14 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com ...@@ -355,14 +361,14 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
idft1536((int16_t*)syncF_tmp, /// complex input idft1536((int16_t*)syncF_tmp, /// complex input
(int16_t*)sync_tmp, (int16_t*)sync_tmp,
1); /// complex output 1); /// complex output
kHz7_5ptr = (frame_parms->Ncp==0) ? (((uint32_t*)s75n_kHz_7_5)+1656) : (((uint32_t*)s75e_kHz_7_5)+1920); kHz7_5ptr = (frame_parms->Ncp==0) ? &s75n_kHz_7_5[2*1656]: &s75e_kHz_7_5[2*1920];
break; break;
case 100: case 100:
idft2048((int16_t*)syncF_tmp, /// complex input idft2048((int16_t*)syncF_tmp, /// complex input
(int16_t*)sync_tmp, /// complex output (int16_t*)sync_tmp, /// complex output
1); 1);
kHz7_5ptr = (frame_parms->Ncp==0) ? (((uint32_t*)s100n_kHz_7_5)+2208) : (((uint32_t*)s100e_kHz_7_5)+2560); kHz7_5ptr = (frame_parms->Ncp==0) ? &s100n_kHz_7_5[2*2208] : &s100e_kHz_7_5[2*2560];
break; break;
default: default:
...@@ -379,7 +385,8 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com ...@@ -379,7 +385,8 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
primary_synch0SL_time_rx[i<<1] = (int16_t)(((int32_t)primary_synch0SL_time[imod<<1]*kHz7_5ptr[i<<1])>>15) - (int16_t)(((int32_t)primary_synch0SL_time[1+(imod<<1)]*kHz7_5ptr[1+(i<<1)])>>15); primary_synch0SL_time_rx[i<<1] = (int16_t)(((int32_t)primary_synch0SL_time[imod<<1]*kHz7_5ptr[i<<1])>>15) - (int16_t)(((int32_t)primary_synch0SL_time[1+(imod<<1)]*kHz7_5ptr[1+(i<<1)])>>15);
primary_synch0SL_time_rx[1+(i<<1)] = (int16_t)(((int32_t)primary_synch0SL_time[imod<<1]*kHz7_5ptr[1+(i<<1)])>>15) + (int16_t)(((int32_t)primary_synch0SL_time[1+(imod<<1)]*kHz7_5ptr[i<<1])>>15); primary_synch0SL_time_rx[1+(i<<1)] = (int16_t)(((int32_t)primary_synch0SL_time[imod<<1]*kHz7_5ptr[1+(i<<1)])>>15) + (int16_t)(((int32_t)primary_synch0SL_time[1+(imod<<1)]*kHz7_5ptr[i<<1])>>15);
} }
memset((void*)syncF_tmp,0,2048*sizeof(int32_t));
k=frame_parms->ofdm_symbol_size-36; k=frame_parms->ofdm_symbol_size-36;
...@@ -425,28 +432,40 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com ...@@ -425,28 +432,40 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
break; break;
} }
for (i=0;i<(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples);i++)
((int32_t*)primary_synch1SL_time)[i] = sync_tmp[(i+(frame_parms->ofdm_symbol_size-frame_parms->nb_prefix_samples))%frame_parms->ofdm_symbol_size];
for (i=0; i<(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*2; i++) { for (i=0; i<(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*2; i++) {
imod = i%(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples); imod = i%(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples);
if (i<(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples))
((int32_t*)primary_synch1SL_time)[i] = sync_tmp[(i+(frame_parms->ofdm_symbol_size-frame_parms->nb_prefix_samples))%frame_parms->ofdm_symbol_size];
primary_synch1SL_time_rx[i<<1] = (int16_t)(((int32_t)primary_synch1SL_time[imod<<1]*kHz7_5ptr[i<<1])>>15) - primary_synch1SL_time_rx[i<<1] = (int16_t)(((int32_t)primary_synch1SL_time[imod<<1]*kHz7_5ptr[i<<1])>>15) +
(int16_t)(((int32_t)primary_synch1SL_time[1+(imod<<1)]*kHz7_5ptr[1+(i<<1)])>>15); (int16_t)(((int32_t)primary_synch1SL_time[1+(imod<<1)]*kHz7_5ptr[1+(i<<1)])>>15);
primary_synch1SL_time_rx[1+(i<<1)] = (int16_t)(((int32_t)primary_synch1SL_time[imod<<1]*kHz7_5ptr[1+(i<<1)])>>15) + primary_synch1SL_time_rx[1+(i<<1)] = -(int16_t)(((int32_t)primary_synch1SL_time[imod<<1]*kHz7_5ptr[1+(i<<1)])>>15) +
(int16_t)(((int32_t)primary_synch1SL_time[1+(imod<<1)]*kHz7_5ptr[i<<1])>>15); (int16_t)(((int32_t)primary_synch1SL_time[1+(imod<<1)]*kHz7_5ptr[i<<1])>>15);
/* printf("sync_timeSL1(%d) : (%d,%d) x (%d,%d)' = (%d,%d)\n",
i,
primary_synch1SL_time[imod<<1],
primary_synch1SL_time[1+(imod<<1)],
kHz7_5ptr[i<<1],
kHz7_5ptr[1+(i<<1)],
primary_synch1SL_time_rx[i<<1],
primary_synch1SL_time_rx[1+(i<<1)]);
*/
} }
/* /*
write_output("primary_sync0.m","psync0",primary_synch0_time,frame_parms->ofdm_symbol_size,1,1); write_output("primary_sync0.m","psync0",primary_synch0_time,frame_parms->ofdm_symbol_size,1,1);
write_output("primary_sync1.m","psync1",primary_synch1_time,frame_parms->ofdm_symbol_size,1,1); write_output("primary_sync1.m","psync1",primary_synch1_time,frame_parms->ofdm_symbol_size,1,1);
write_output("primary_sync2.m","psync2",primary_synch2_time,frame_parms->ofdm_symbol_size,1,1); write_output("primary_sync2.m","psync2",primary_synch2_time,frame_parms->ofdm_symbol_size,1,1);*/
write_output("primary_syncSL0.m","psyncSL0",primary_synch0SL_time,frame_parms->ofdm_symbol_size,1,1); write_output("primary_syncSL0.m","psyncSL0",primary_synch0SL_time,frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples,1,1);
write_output("primary_syncSL1.m","psyncSL1",primary_synch1SL_time,frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples,1,1);
write_output("primary_syncSL1.m","psyncSL1",primary_synch1SL_time_rx,2*(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples),1,1); write_output("primary_syncSL1rx.m","psyncSL1rx",primary_synch1SL_time_rx,2*(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples),1,1);
write_output("primary_syncSL0.m","psyncSL0",primary_synch0SL_time_rx,2*(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples),1,1); write_output("primary_syncSL0rx.m","psyncSL0rx",primary_synch0SL_time_rx,2*(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples),1,1);
write_output("kHz75.m","kHz75",kHz7_5ptr,2*1096,1,1); write_output("kHz75.m","kHz75",kHz7_5ptr,2*1096,1,1);
*/
return (1); return (1);
} }
...@@ -509,6 +528,11 @@ static inline int32_t abs32(int32_t x) ...@@ -509,6 +528,11 @@ 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])); 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]));
}
#ifdef DEBUG_PHY #ifdef DEBUG_PHY
int debug_cnt=0; int debug_cnt=0;
#endif #endif
...@@ -680,12 +704,12 @@ int lte_sync_timeSL(PHY_VARS_UE *ue, ...@@ -680,12 +704,12 @@ int lte_sync_timeSL(PHY_VARS_UE *ue,
(void*)&ue->common_vars.rxdata_syncSL[ar][0], (void*)&ue->common_vars.rxdata_syncSL[ar][0],
frame_parms->ofdm_symbol_size); frame_parms->ofdm_symbol_size);
int32_t tmp0,tmp1; int64_t tmp0,tmp1;
int32_t magtmp0,magtmp1,maxlev0=0,maxlev1=0; int64_t magtmp0,magtmp1,maxlev0=0,maxlev1=0;
int maxpos0=0,maxpos1=0; int maxpos0=0,maxpos1=0;
int64_t avg0=0,avg1=0; int64_t avg0=0,avg1=0;
int32_t result; int64_t result;
int32_t **rxdata = ue->common_vars.rxdata_syncSL; ///rx data in time domain int32_t **rxdata = (int32_t**)ue->common_vars.rxdata_syncSL; ///rx data in time domain
RU_t ru_tmp; RU_t ru_tmp;
int16_t **rxdata_7_5kHz = ue->sl_rxdata_7_5kHz; int16_t **rxdata_7_5kHz = ue->sl_rxdata_7_5kHz;
...@@ -697,39 +721,51 @@ int lte_sync_timeSL(PHY_VARS_UE *ue, ...@@ -697,39 +721,51 @@ int lte_sync_timeSL(PHY_VARS_UE *ue,
ru_tmp.common.rxdata_7_5kHz = (int32_t**)rxdata_7_5kHz; ru_tmp.common.rxdata_7_5kHz = (int32_t**)rxdata_7_5kHz;
ru_tmp.nb_rx = frame_parms->nb_antennas_rx; ru_tmp.nb_rx = frame_parms->nb_antennas_rx;
int maxval=0;
for (int i=0;i<2*(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples);i++) {
for (int n=0; n<length; n+=4) { maxval = max(maxval,primary_synch0SL_time_rx[i]);
maxval = max(maxval,-primary_synch0SL_time_rx[i]);
maxval = max(maxval,primary_synch1SL_time_rx[i]);
maxval = max(maxval,-primary_synch1SL_time_rx[i]);
}
int shift = log2_approx(maxval);//*(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*2);
printf("Synchtime SL : shifting by %d bits\n",shift);
for (int n=0; n<length; n+=4)
{
tmp0 = 0; tmp0 = 0;
tmp1 = 0; tmp1 = 0;
int32_t tmp0_re=((int32_t*)&tmp0)[0], tmp0_im=((int32_t*)&tmp0)[1];
int32_t tmp1_re=((int32_t*)&tmp1)[0], tmp1_im=((int32_t*)&tmp1)[1];
//calculate dot product of primary_synch0_time and rxdata[ar][n] (ar=0..nb_ant_rx) and store the sum in temp[n]; //calculate dot product of primary_synch0_time and rxdata[ar][n] (ar=0..nb_ant_rx) and store the sum in temp[n];
for (int ar=0; ar<frame_parms->nb_antennas_rx; ar++) { for (int ar=0; ar<frame_parms->nb_antennas_rx; ar++) {
result = dot_product((int16_t*)primary_synch0SL_time_rx, result = dot_product(primary_synch0SL_time_rx,
(int16_t*) &(rxdata[ar][n]), (int16_t*) &(rxdata[ar][n]),
(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*2, (frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*2,
11); shift);
((int16_t*)&tmp0)[0] += ((int16_t*) &result)[0]; tmp0_re += ((int32_t*) &result)[0];
((int16_t*)&tmp0)[1] += ((int16_t*) &result)[1]; tmp0_im += ((int32_t*) &result)[1];
result = dot_product((int16_t*)primary_synch1SL_time_rx, result = dot_product(primary_synch1SL_time_rx,
(int16_t*) &(rxdata[ar][n]), (int16_t*) &(rxdata[ar][n]),
(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*2, (frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*2,
11); shift);
((int16_t*)&tmp1)[0] += ((int16_t*) &result)[0]; tmp1_re += ((int32_t*) &result)[0];
((int16_t*)&tmp1)[1] += ((int16_t*) &result)[1]; tmp1_im += ((int32_t*) &result)[1];
} }
// tmpi holds <synchi,rx0>+<synci,rx1>+...+<synchi,rx_{nbrx-1}> // tmpi holds <synchi,rx0>+<synci,rx1>+...+<synchi,rx_{nbrx-1}>
magtmp0 = abs32(tmp0); magtmp0 = (int64_t)tmp0_re*tmp0_re + (int64_t)tmp0_im*tmp0_im;
magtmp1 = abs32(tmp1); magtmp1 = (int64_t)tmp1_re*tmp1_re + (int64_t)tmp1_im*tmp1_im;
//printf("0: n %d (%d,%d) => %lld\n",n,tmp0_re,tmp0_im,magtmp0);
//printf("1: n %d (%d,%d) => %lld\n",n,tmp1_re,tmp1_im,magtmp1);
// this does max |tmpi(n)|^2 + |tmpi(n-L)|^2 and argmax |tmpi(n)|^2 + |tmpi(n-L)|^2 // this does max |tmpi(n)|^2 + |tmpi(n-L)|^2 and argmax |tmpi(n)|^2 + |tmpi(n-L)|^2
if (magtmp0>maxlev0) { maxlev0 = magtmp0; maxpos0 = n; } if (magtmp0>maxlev0) { maxlev0 = magtmp0; maxpos0 = n; }
...@@ -737,8 +773,8 @@ int lte_sync_timeSL(PHY_VARS_UE *ue, ...@@ -737,8 +773,8 @@ int lte_sync_timeSL(PHY_VARS_UE *ue,
avg0 += magtmp0; avg0 += magtmp0;
avg1 += magtmp1; avg1 += magtmp1;
if (n<4*FRAME_LENGTH_COMPLEX_SAMPLES) { if (n<4*FRAME_LENGTH_COMPLEX_SAMPLES) {
sync_corr_ue1[n] = magtmp1; sync_corr_ue1[n] = (int32_t)(magtmp1>>31);
sync_corr_ue0[n] = magtmp0; sync_corr_ue0[n] = (int32_t)(magtmp0>>31);
} }
} }
avg0/=(length/4); avg0/=(length/4);
...@@ -746,7 +782,8 @@ int lte_sync_timeSL(PHY_VARS_UE *ue, ...@@ -746,7 +782,8 @@ int lte_sync_timeSL(PHY_VARS_UE *ue,
// PSS in symbol 1 // PSS in symbol 1
int pssoffset = frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples0; int pssoffset = frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples0;
printf("maxpos1 = %d, pssoffset = %d\n",maxpos1,pssoffset); printf("maxpos = (%d,%d), pssoffset = %d, maxlev= (%lld,%lld) avglev (%lld,%lld)\n",maxpos0,maxpos1,pssoffset,
(long long int)maxlev0,(long long int)maxlev1,(long long int)avg0,(long long int)avg1);
if (maxlev0 > maxlev1) { if (maxlev0 > maxlev1) {
if ((int64_t)maxlev0 > (5*avg0)) {*lev = maxlev0; *ind=0; *avg=avg0; return((length+maxpos0-pssoffset)%length);}; if ((int64_t)maxlev0 > (5*avg0)) {*lev = maxlev0; *ind=0; *avg=avg0; return((length+maxpos0-pssoffset)%length);};
......
...@@ -50,23 +50,21 @@ int initial_syncSL(PHY_VARS_UE *ue) { ...@@ -50,23 +50,21 @@ int initial_syncSL(PHY_VARS_UE *ue) {
&index, &index,
&psslevel, &psslevel,
&avglevel); &avglevel);
printf("index %d, psslevel %lld dB avglevel %lld dB => %d sample offset\n", printf("index %d, psslevel %d dB avglevel %d dB => %d sample offset\n",
index,dB_fixed(psslevel),dB_fixed(avglevel),ue->rx_offsetSL); index,dB_fixed64((uint64_t)psslevel),dB_fixed64((uint64_t)avglevel),ue->rx_offsetSL);
if (ue->rx_offsetSL >= 0) { if (ue->rx_offsetSL >= 0) {
int32_t sss_metric; int32_t sss_metric;
int32_t phase_max; int32_t phase_max;
rx_slsss(ue,&sss_metric,&phase_max,index); rx_slsss(ue,&sss_metric,&phase_max,index);
generate_sl_grouphop(ue); generate_sl_grouphop(ue);
if (rx_psbch(ue) == -1) { if (rx_psbch(ue) == -1) {
ue->slbch_errors++; ue->slbch_errors++;
/*
write_output("rxsig0.m","rxs0",&ue->common_vars.rxdata_syncSL[0][0],40*ue->frame_parms.samples_per_tti,1,1); write_output("rxsig0.m","rxs0",&ue->common_vars.rxdata_syncSL[0][0],40*ue->frame_parms.samples_per_tti,1,1);
write_output("corr0.m","rxsync0",sync_corr_ue0,40*ue->frame_parms.samples_per_tti,1,2); write_output("corr0.m","rxsync0",sync_corr_ue0,40*ue->frame_parms.samples_per_tti,1,2);
write_output("corr1.m","rxsync1",sync_corr_ue1,40*ue->frame_parms.samples_per_tti,1,2); write_output("corr1.m","rxsync1",sync_corr_ue1,40*ue->frame_parms.samples_per_tti,1,2);
exit(-1); exit(-1);
*/
return(-1); return(-1);
} }
else { else {
......
...@@ -359,10 +359,10 @@ int rx_slsss(PHY_VARS_UE *ue,int32_t *tot_metric,uint8_t *phase_max,int Nid2) ...@@ -359,10 +359,10 @@ int rx_slsss(PHY_VARS_UE *ue,int32_t *tot_metric,uint8_t *phase_max,int Nid2)
0); 0);
// write_output("rxdataF0.m","rxF0",&rxdataF[0][0],2*14*ue->frame_parms.ofdm_symbol_size,1,1); // write_output("rxdataF0.m","rxF0",&rxdataF[0][0],2*14*ue->frame_parms.ofdm_symbol_size,1,1);
/* write_output("pss0_ext.m","pss0ext",pss0_ext,72,1,1); write_output("pss0_ext.m","pss0ext",pss0_ext,72,1,1);
write_output("sss0_ext.m","sss0ext",sss0_ext,72,1,1); write_output("sss0_ext.m","sss0ext",sss0_ext,72,1,1);
write_output("pss1_ext.m","pss1ext",pss1_ext,72,1,1); write_output("pss1_ext.m","pss1ext",pss1_ext,72,1,1);
write_output("sss1_ext.m","sss1ext",sss1_ext,72,1,1); */ write_output("sss1_ext.m","sss1ext",sss1_ext,72,1,1);
...@@ -400,9 +400,10 @@ int rx_slsss(PHY_VARS_UE *ue,int32_t *tot_metric,uint8_t *phase_max,int Nid2) ...@@ -400,9 +400,10 @@ int rx_slsss(PHY_VARS_UE *ue,int32_t *tot_metric,uint8_t *phase_max,int Nid2)
sss0_comp16[i] = (int16_t)(sss0comp[i]>>shift); sss0_comp16[i] = (int16_t)(sss0comp[i]>>shift);
sss1_comp16[i] = (int16_t)(sss1comp[i]>>shift); sss1_comp16[i] = (int16_t)(sss1comp[i]>>shift);
} }
/*write_output("sss0_comp0.m","sss0comp0",sss0_comp16,72,1,1); /*
write_output("sss1_comp0.m","sss1comp0",sss1_comp16,72,1,1);*/ write_output("sss0_comp0.m","sss0comp0",sss0_comp16,72,1,1);
// exit(-1); write_output("sss1_comp0.m","sss1comp0",sss1_comp16,72,1,1);
exit(-1); */
// now do the SSS detection based on the precomputed sequences in PHY/LTE_TRANSPORT/sss.h // now do the SSS detection based on the precomputed sequences in PHY/LTE_TRANSPORT/sss.h
*tot_metric = -99999999; *tot_metric = -99999999;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "defs.h" #include "defs.h"
#include "PHY/sse_intrin.h" #include "PHY/sse_intrin.h"
#include <stdio.h>
// returns the complex dot product of x and y // returns the complex dot product of x and y
#ifdef MAIN #ifdef MAIN
...@@ -30,7 +30,7 @@ void print_shorts(char *s,__m128i *x); ...@@ -30,7 +30,7 @@ void print_shorts(char *s,__m128i *x);
void print_bytes(char *s,__m128i *x); void print_bytes(char *s,__m128i *x);
#endif #endif
int32_t dot_product(int16_t *x, int64_t dot_product(int16_t *x,
int16_t *y, int16_t *y,
uint32_t N, //must be a multiple of 8 uint32_t N, //must be a multiple of 8
uint8_t output_shift) uint8_t output_shift)
...@@ -40,7 +40,6 @@ int32_t dot_product(int16_t *x, ...@@ -40,7 +40,6 @@ int32_t dot_product(int16_t *x,
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
__m128i *x128,*y128,mmtmp1,mmtmp2,mmtmp3,mmcumul,mmcumul_re,mmcumul_im; __m128i *x128,*y128,mmtmp1,mmtmp2,mmtmp3,mmcumul,mmcumul_re,mmcumul_im;
__m64 mmtmp7;
__m128i minus_i = _mm_set_epi16(-1,1,-1,1,-1,1,-1,1); __m128i minus_i = _mm_set_epi16(-1,1,-1,1,-1,1,-1,1);
int32_t result; int32_t result;
...@@ -52,37 +51,37 @@ int32_t dot_product(int16_t *x, ...@@ -52,37 +51,37 @@ int32_t dot_product(int16_t *x,
for (n=0; n<(N>>2); n++) { for (n=0; n<(N>>2); n++) {
//printf("n=%d, x128=%p, y128=%p\n",n,x128,y128); // printf("n=%d, x128=%p, y128=%p\n",n,x128,y128);
// print_shorts("x",&x128[0]); // print_shorts("x",&x128[0]);
// print_shorts("y",&y128[0]); // print_shorts("y",&y128[0]);
// this computes Re(z) = Re(x)*Re(y) + Im(x)*Im(y) // this computes Re(z) = Re(x)*Re(y) + Im(x)*Im(y)
mmtmp1 = _mm_madd_epi16(x128[0],y128[0]); mmtmp1 = _mm_madd_epi16(x128[0],y128[0]);
// print_ints("re",&mmtmp1); // print_ints("retmp",&mmtmp1);
// mmtmp1 contains real part of 4 consecutive outputs (32-bit) // mmtmp1 contains real part of 4 consecutive outputs (32-bit)
// shift and accumulate results // shift and accumulate results
mmtmp1 = _mm_srai_epi32(mmtmp1,output_shift); mmtmp1 = _mm_srai_epi32(mmtmp1,output_shift);
mmcumul_re = _mm_add_epi32(mmcumul_re,mmtmp1); mmcumul_re = _mm_add_epi32(mmcumul_re,mmtmp1);
// print_ints("re",&mmcumul_re); //print_ints("re",&mmcumul_re);
// this computes Im(z) = Re(x)*Im(y) - Re(y)*Im(x) // this computes Im(z) = Re(x)*Im(y) - Re(y)*Im(x)
mmtmp2 = _mm_shufflelo_epi16(y128[0],_MM_SHUFFLE(2,3,0,1)); mmtmp2 = _mm_shufflelo_epi16(y128[0],_MM_SHUFFLE(2,3,0,1));
// print_shorts("y",&mmtmp2); //print_shorts("y",&mmtmp2);
mmtmp2 = _mm_shufflehi_epi16(mmtmp2,_MM_SHUFFLE(2,3,0,1)); mmtmp2 = _mm_shufflehi_epi16(mmtmp2,_MM_SHUFFLE(2,3,0,1));
// print_shorts("y",&mmtmp2); //print_shorts("y",&mmtmp2);
mmtmp2 = _mm_sign_epi16(mmtmp2,minus_i); mmtmp2 = _mm_sign_epi16(mmtmp2,minus_i);
// print_shorts("y",&mmtmp2); // print_shorts("y",&mmtmp2);
mmtmp3 = _mm_madd_epi16(x128[0],mmtmp2); mmtmp3 = _mm_madd_epi16(x128[0],mmtmp2);
// print_ints("im",&mmtmp3); //print_ints("imtmp",&mmtmp3);
// mmtmp3 contains imag part of 4 consecutive outputs (32-bit) // mmtmp3 contains imag part of 4 consecutive outputs (32-bit)
// shift and accumulate results // shift and accumulate results
mmtmp3 = _mm_srai_epi32(mmtmp3,output_shift); mmtmp3 = _mm_srai_epi32(mmtmp3,output_shift);
mmcumul_im = _mm_add_epi32(mmcumul_im,mmtmp3); mmcumul_im = _mm_add_epi32(mmcumul_im,mmtmp3);
// print_ints("im",&mmcumul_im); //print_ints("im",&mmcumul_im);
x128++; x128++;
y128++; y128++;
...@@ -90,24 +89,18 @@ int32_t dot_product(int16_t *x, ...@@ -90,24 +89,18 @@ int32_t dot_product(int16_t *x,
// this gives Re Re Im Im // this gives Re Re Im Im
mmcumul = _mm_hadd_epi32(mmcumul_re,mmcumul_im); mmcumul = _mm_hadd_epi32(mmcumul_re,mmcumul_im);
// print_ints("cumul1",&mmcumul); //print_ints("cumul1",&mmcumul);
// this gives Re Im Re Im // this gives Re Im Re Im
mmcumul = _mm_hadd_epi32(mmcumul,mmcumul); mmcumul = _mm_hadd_epi32(mmcumul,mmcumul);
// print_ints("cumul2",&mmcumul); //print_ints("cumul2",&mmcumul);
//mmcumul = _mm_srai_epi32(mmcumul,output_shift); //mmcumul = _mm_srai_epi32(mmcumul,output_shift);
// extract the lower half // extract the lower half
mmtmp7 = _mm_movepi64_pi64(mmcumul); result = _mm_extract_epi64(mmcumul,0);
// print_ints("mmtmp7",&mmtmp7); //printf("result: (%d,%d)\n",((int32_t*)&result)[0],((int32_t*)&result)[1]);
// pack the result
mmtmp7 = _mm_packs_pi32(mmtmp7,mmtmp7);
// print_shorts("mmtmp7",&mmtmp7);
// convert back to integer
result = _mm_cvtsi64_si32(mmtmp7);
_mm_empty(); _mm_empty();
_m_empty(); _m_empty();
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
// Approximate 10*log10(x) in fixed point : x = 0...(2^32)-1 // Approximate 10*log10(x) in fixed point : x = 0...(2^32)-1
int8_t dB_table[256] = { uint8_t dB_table[256] = {
0, 0,
3, 3,
5, 5,
...@@ -282,7 +282,7 @@ int8_t dB_table[256] = { ...@@ -282,7 +282,7 @@ int8_t dB_table[256] = {
24 24
}; };
int16_t dB_table_times10[256] = { uint16_t dB_table_times10[256] = {
0, 0,
30, 30,
47, 47,
...@@ -571,9 +571,9 @@ int8_t dB_fixed(int x) { ...@@ -571,9 +571,9 @@ int8_t dB_fixed(int x) {
} }
*/ */
int16_t dB_fixed_times10(uint32_t x) uint16_t dB_fixed_times10(uint32_t x)
{ {
int16_t dB_power=0; uint8_t dB_power=0;
if (x==0) { if (x==0) {
...@@ -597,10 +597,17 @@ int16_t dB_fixed_times10(uint32_t x) ...@@ -597,10 +597,17 @@ int16_t dB_fixed_times10(uint32_t x)
return dB_power; return dB_power;
} }
int8_t dB_fixed(uint32_t x) uint8_t dB_fixed64(uint64_t x)
{ {
int8_t dB_power=0; if (x<(((uint64_t)1)<<32)) return(dB_fixed((uint32_t)x));
else return(4*dB_table[255] + dB_fixed(x>>32));
}
uint8_t dB_fixed(uint32_t x)
{
uint8_t dB_power=0;
if (x==0) { if (x==0) {
...@@ -624,7 +631,7 @@ int8_t dB_fixed(uint32_t x) ...@@ -624,7 +631,7 @@ int8_t dB_fixed(uint32_t x)
return dB_power; return dB_power;
} }
int8_t dB_fixed2(uint32_t x, uint32_t y) uint8_t dB_fixed2(uint32_t x, uint32_t y)
{ {
if ((x>0) && (y>0) ) if ((x>0) && (y>0) )
......
...@@ -347,16 +347,18 @@ Compensate the phase rotation of the RF. WARNING: This function is currently unu ...@@ -347,16 +347,18 @@ Compensate the phase rotation of the RF. WARNING: This function is currently unu
*/ */
int8_t dB_fixed(uint32_t x); uint8_t dB_fixed(uint32_t x);
int8_t dB_fixed2(uint32_t x,uint32_t y); uint8_t dB_fixed2(uint32_t x,uint32_t y);
int16_t dB_fixed_times10(uint32_t x); uint8_t dB_fixed64(uint64_t x);
uint16_t dB_fixed_times10(uint32_t x);
int32_t phy_phase_compensation_top (uint32_t pilot_type, uint32_t initial_pilot, int32_t phy_phase_compensation_top (uint32_t pilot_type, uint32_t initial_pilot,
uint32_t last_pilot, int32_t ignore_prefix); uint32_t last_pilot, int32_t ignore_prefix);
int32_t dot_product(int16_t *x, int64_t dot_product(int16_t *x,
int16_t *y, int16_t *y,
uint32_t N, //must be a multiple of 8 uint32_t N, //must be a multiple of 8
uint8_t output_shift); uint8_t output_shift);
......
...@@ -60,11 +60,11 @@ extern short primary_synch1SL[144]; ...@@ -60,11 +60,11 @@ extern short primary_synch1SL[144];
extern unsigned char primary_synch0_tab[72]; extern unsigned char primary_synch0_tab[72];
extern unsigned char primary_synch1_tab[72]; extern unsigned char primary_synch1_tab[72];
extern unsigned char primary_synch2_tab[72]; extern unsigned char primary_synch2_tab[72];
extern const int16_t *primary_synch0_time; //!< index: [0..ofdm_symbol_size*2[ extern int16_t *primary_synch0_time; //!< index: [0..ofdm_symbol_size*2[
extern const int16_t *primary_synch1_time; //!< index: [0..ofdm_symbol_size*2[ extern int16_t *primary_synch1_time; //!< index: [0..ofdm_symbol_size*2[
extern const int16_t *primary_synch2_time; //!< index: [0..ofdm_symbol_size*2[ extern int16_t *primary_synch2_time; //!< index: [0..ofdm_symbol_size*2[
extern const int16_t *primary_synch0SL_time; extern int16_t *primary_synch0SL_time;
extern const int16_t *primary_synch1SL_time; extern int16_t *primary_synch1SL_time;
extern int16_t *primary_synch0SL_time_rx; extern int16_t *primary_synch0SL_time_rx;
extern int16_t *primary_synch1SL_time_rx; extern int16_t *primary_synch1SL_time_rx;
......
...@@ -33,13 +33,13 @@ char* namepointer_log2; ...@@ -33,13 +33,13 @@ char* namepointer_log2;
#include "PHY/LTE_REFSIG/primary_synch.h" #include "PHY/LTE_REFSIG/primary_synch.h"
#include "PHY/LTE_REFSIG/primary_synch_SL.h" #include "PHY/LTE_REFSIG/primary_synch_SL.h"
const int16_t *primary_synch0_time; int16_t *primary_synch0_time;
const int16_t *primary_synch1_time; int16_t *primary_synch1_time;
const int16_t *primary_synch2_time; int16_t *primary_synch2_time;
const int16_t *primary_synch0SL_time; int16_t *primary_synch0SL_time;
const int16_t *primary_synch1SL_time; int16_t *primary_synch1SL_time;
int16_t *primary_synch0SL_time_rx; int16_t *primary_synch0SL_time_rx;
int16_t *primary_synch1SL_time_rx; int16_t *primary_synch1SL_time_rx;
......
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