Commit 92c7c808 authored by knopp's avatar knopp

initial debugging of UE band scanning

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7278 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 1cfdf8f9
......@@ -141,7 +141,7 @@ set(CMAKE_C_FLAGS
# these changes are related to hardcoded path to include .h files
add_definitions(-DCMAKER)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -ggdb -DMALLOC_CHECK_=3")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -ggdb -DMALLOC_CHECK_=3 -O3")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -ggdb -DMALLOC_CHECK_=3 -O2")
# Below has been put in comment because does not work with
# SVN authentication.
......
......@@ -48,7 +48,7 @@
#include "PHY/extern.h"
#include "pss6144.h"
#define DEBUG_TF 1
extern void print_shorts(char*,__m128i*);
void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
......@@ -67,15 +67,16 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
__m128i s;
int re,re256;
__m128i mmtmp00,mmtmp01,mmtmp02,mmtmp10,mmtmp11,mmtmp12;
int maxcorr[3],minamp,pos,pssind;
int maxcorr[3],minamp,pos=0,pssind;
int16_t *pss6144_0,*pss6144_1,*pss6144_2;
/* char fname[100],vname[100];*/
// for (i=0;i<38400*4;i+=3072) // steps of 200 us with 100 us overlap, 0 to 5s
write_output("rxsig0.m","rxs0",ue->lte_ue_common_vars.rxdata[0],30720,1,1);
for (i=0;i<38400*4;i+=3072) { // steps of 200 us with 100 us overlap, 0 to 5s
// write_output("rxsig0.m","rxs0",ue->lte_ue_common_vars.rxdata[0],30720,1,1);
for (i = 15360-3072*2; i<15360+3072+1; i+=3072) {
//for (i = 15360-3072*2; i<15360+3072+1; i+=3072) {
//compute frequency-domain representation of 6144-sample chunk
......@@ -88,17 +89,20 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
//compute frequency-domain representation of 6144-sample chunk
fft6144((int16_t *)rxp,
sp);
printf("i %d: sp %p\n",i,sp);
/*
printf("i %d: sp %p\n",i,sp);
if (i==12288) {
write_output("scan6144F.m","s6144F",sp,6144,1,1);
write_output("scan6144.m","s6144",rxp,6144,1,1);
}
write_output("pss0_6144.m","pss0",pss6144_0_0,256,1,1);
}*/
for (f = -130; f<-125; f++) { // this is -10MHz to 10 MHz in 5 kHz steps
for (f = -2000; f<2000; f++) { // this is -10MHz to 10 MHz in 5 kHz steps
if ((f<-256)||(f>=0)) { // no split around DC
printf("No split, f %d (%d)\n",f,f&3);
// printf("No split, f %d (%d)\n",f,f&3);
// align filters and input buffer pointer to 128-bit
switch (f&3) {
......@@ -106,34 +110,35 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
pss6144_0 = &pss6144_0_0[0];
pss6144_1 = &pss6144_1_0[0];
pss6144_2 = &pss6144_2_0[0];
sp2 = (f<0) ? (__m128i*)&sp[12288+(f<<1)] : (__m128i*)&sp;
sp2 = (f<0) ? (__m128i*)&sp[12288+(f<<1)] : (__m128i*)&sp[(f<<1)];
break;
case 1:
pss6144_0 = &pss6144_0_1[0];
pss6144_1 = &pss6144_1_1[0];
pss6144_2 = &pss6144_2_1[0];
sp2 = (f<0) ? (__m128i*)&sp[12286+(f<<1)] : (__m128i*)sp;
sp2 = (f<0) ? (__m128i*)&sp[12286+(f<<1)] : (__m128i*)&sp[-2+(f<<1)];
break;
case 2:
pss6144_0 = &pss6144_0_2[0];
pss6144_1 = &pss6144_1_2[0];
pss6144_2 = &pss6144_2_2[0];
sp2 = (f<0) ? (__m128i*)&sp[12284+(f<<1)] : (__m128i*)sp;
sp2 = (f<0) ? (__m128i*)&sp[12284+(f<<1)] : (__m128i*)&sp[-4+(f<<1)];
break;
case 3:
pss6144_0 = &pss6144_0_3[0];
pss6144_1 = &pss6144_1_3[0];
pss6144_2 = &pss6144_2_3[0];
sp2 = (f<0) ? (__m128i*)&sp[12282+(f<<1)] : (__m128i*)sp;
sp2 = (f<0) ? (__m128i*)&sp[12282+(f<<1)] : (__m128i*)&sp[-6+(f<<1)];
break;
}
re256=32;
for (re = 0; re<256/4; re++) { // loop over 256 points of upsampled PSS
// printf("f %d, re %d\n",f,re);
s = sp2[re];
mmtmp00 = _mm_srai_epi32(_mm_madd_epi16(((__m128i*)pss6144_0)[re],s),15);
mmtmp01 = _mm_srai_epi32(_mm_madd_epi16(((__m128i*)pss6144_1)[re],s),15);
......@@ -153,7 +158,7 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
re256 = (re256+1)&0x3f;
}
} else { // Split around DC, this is the negative frequencies
printf("split around DC, f %d (f/4 %d, f&3 %d)\n",f,f>>2,f&3);
// printf("split around DC, f %d (f/4 %d, f&3 %d)\n",f,f>>2,f&3);
// align filters and input buffer pointer to 128-bit
switch (f&3) {
......@@ -190,9 +195,9 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
for (re = 0; re<(-f+3)/4; re++) { // loop over 256 points of upsampled PSS
s = sp2[re];
printf("re %d, %p\n",re,&sp2[re]);
/* printf("re %d, %p\n",re,&sp2[re]);
print_shorts("s",&s);
print_shorts("pss",&((__m128i*)pss6144_0)[re]);
print_shorts("pss",&((__m128i*)pss6144_0)[re]);*/
mmtmp00 = _mm_srai_epi32(_mm_madd_epi16(((__m128i*)pss6144_0)[re],s),15);
mmtmp01 = _mm_srai_epi32(_mm_madd_epi16(((__m128i*)pss6144_1)[re],s),15);
......@@ -245,9 +250,9 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
for (re = 0; re<(256+f)/4; re++) { // loop over 256 points of upsampled PSS
s = sp2[re];
printf("re %d %p\n",re,&sp2[re]);
/* printf("re %d %p\n",re,&sp2[re]);
print_shorts("s",&s);
print_shorts("pss",&((__m128i*)pss6144_0)[re]);
print_shorts("pss",&((__m128i*)pss6144_0)[re]);*/
mmtmp00 = _mm_srai_epi32(_mm_madd_epi16(((__m128i*)pss6144_0)[re],s),15);
mmtmp01 = _mm_srai_epi32(_mm_madd_epi16(((__m128i*)pss6144_1)[re],s),15);
mmtmp02 = _mm_srai_epi32(_mm_madd_epi16(((__m128i*)pss6144_2)[re],s),15);
......@@ -270,11 +275,15 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
// ifft, accumulate energy over two half-frames
idft256((int16_t*)autocorr0,(int16_t*)tmp_t,1);
/*
if (i==12288) {
write_output("corr256F.m","c256F",autocorr0,256,1,1);
write_output("corr256.m","c256",tmp_t,256,1,1);
}
sprintf(fname,"corr256F_%d.m",abs(f));
sprintf(vname,"c256F_%d",abs(f));
write_output(fname,vname,autocorr0,256,1,1);
sprintf(fname,"corr256_%d.m",abs(f));
sprintf(vname,"c256_%d",abs(f));
write_output(fname,vname,tmp_t,256,1,1);
}*/
memset((void*)autocorr0_t,0,256*4);
memset((void*)autocorr1_t,0,256*4);
......@@ -283,12 +292,12 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
for (re=0; re<(256/4); re++)
autocorr0_t[re] = _mm_add_epi32(autocorr0_t[re],_mm_madd_epi16(tmp_t[re],tmp_t[re]));
idft256((int16_t*)autocorr1,(int16_t*)autocorr1_t,1);
idft256((int16_t*)autocorr1,(int16_t*)tmp_t,1);
for (re=0; re<(256/4); re++)
autocorr1_t[re] = _mm_add_epi32(autocorr1_t[re],_mm_madd_epi16(tmp_t[re],tmp_t[re]));
idft256((int16_t*)autocorr2,(int16_t*)autocorr2_t,1);
idft256((int16_t*)autocorr2,(int16_t*)tmp_t,1);
for (re=0; re<(256/4); re++)
autocorr2_t[re] = _mm_add_epi32(autocorr2_t[re],_mm_madd_epi16(tmp_t[re],tmp_t[re]));
......@@ -300,13 +309,9 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
maxcorr[2] = 0;
for (re=0; re<256; re++) {
#ifdef DEBUG_TF
printf("%d,",((int32_t*)autocorr0_t)[re]);
#endif
if (((int32_t*)autocorr0_t)[re] > maxcorr[0]) {
maxcorr[0]=((int32_t*)autocorr0_t)[re];
printf("*");
}
if (((int32_t*)autocorr1_t)[re] > maxcorr[1])
......@@ -316,13 +321,9 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
maxcorr[2]=((int32_t*)autocorr2_t)[re];
}
#ifdef DEBUG_TF
printf("\n");
#endif
for (pssind=0; pssind<3; pssind++) {
printf("pss %d, amp %d freq %u, i %d\n",pssind,maxcorr[pssind],((f+128)*5000)+DL_freq,i);
minamp=(int)((1<<30)-1);
for (band_idx=0; band_idx<10; band_idx++)
......@@ -333,7 +334,8 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
if (maxcorr[pssind]>minamp) {
scan_info->amp[pssind][pos]=maxcorr[pssind];
scan_info->freq_offset_Hz[pssind][pos]=(f*5000)+DL_freq;
scan_info->freq_offset_Hz[pssind][pos]=((f+128)*5000)+DL_freq;
printf("pss %d, amp %d (%d>%d) freq %u (%d), i %d\n",pssind,dB_fixed(maxcorr[pssind]),maxcorr[pssind],minamp,((f+128)*5000)+DL_freq,f,i);
}
} // loop on pss index
}
......@@ -347,8 +349,12 @@ void lte_sync_timefreq(PHY_VARS_UE *ue,int band,unsigned int DL_freq)
}
}// loop on time index i
#ifdef DEBUG_TF
exit(-1);
#endif
for (band_idx=0; band_idx<10; band_idx++)
printf("pss 0: level %d dB, freq %u\n", dB_fixed(scan_info->amp[0][band_idx]),scan_info->freq_offset_Hz[0][band_idx]);
for (band_idx=0; band_idx<10; band_idx++)
printf("pss 1: level %d dB, freq %u\n", dB_fixed(scan_info->amp[1][band_idx]),scan_info->freq_offset_Hz[1][band_idx]);
for (band_idx=0; band_idx<10; band_idx++)
printf("pss 2: level %d dB, freq %u\n", dB_fixed(scan_info->amp[2][band_idx]),scan_info->freq_offset_Hz[2][band_idx]);
}
......@@ -12,35 +12,74 @@ d1(1+(31:61)) = exp(-sqrt(-1)*pi*29*(32:62).*(33:63)/63);
d2(1+(31:61)) = exp(-sqrt(-1)*pi*34*(32:62).*(33:63)/63);
pss0f = zeros(1,2048);
pss0f(2:32) = d0(1:31);
pss0f(2048+(-30:0)) = d0(32:62);
pss0f(2:32) = d0(32:62);
pss0f(2048+(-30:0)) = d0(1:31);
pss1f = zeros(1,2048);
pss1f(2:32) = d1(1:31);
pss1f(2048+(-30:0)) = d1(32:62);
pss1f(2:32) = d1(32:62);
pss1f(2048+(-30:0)) = d1(1:31);
pss2f = zeros(1,2048);
pss2f(2:32) = d2(1:31);
pss2f(2048+(-30:0)) = d2(32:62);
pss2f(2:32) = d2(32:62);
pss2f(2048+(-30:0)) = d2(1:31);
pss0_6144f = fftshift(fft(ifft(pss0f)*sqrt(2048),6144)/sqrt(6144));
pss1_6144f = fftshift(fft(ifft(pss1f)*sqrt(2048),6144)/sqrt(6144));
pss2_6144f = fftshift(fft(ifft(pss2f)*sqrt(2048),6144)/sqrt(6144));
pss0_6144f = fft(ifft(pss0f)*sqrt(2048),6144)/sqrt(6144);
pss1_6144f = fft(ifft(pss1f)*sqrt(2048),6144)/sqrt(6144);
pss2_6144f = fft(ifft(pss2f)*sqrt(2048),6144)/sqrt(6144);
pss0_6144_fp = zeros(1,512);
pss0_6144_fp(1:2:512) = (floor(32767*real(pss0_6144f(3072+(-128:127)))));
pss0_6144_fp(2:2:512) = (floor(32767*imag(pss0_6144f(3072+(-128:127)))));
pss0_6144_fp(1:2:256) = (floor(32767*real(pss0_6144f(6144+(-127:0)))));
pss0_6144_fp(2:2:256) = (floor(32767*imag(pss0_6144f(6144+(-127:0)))));
pss0_6144_fp(256+(1:2:256)) = (floor(32767*real(pss0_6144f(1:128))));
pss0_6144_fp(256+(2:2:256)) = (floor(32767*imag(pss0_6144f(1:128))));
pss1_6144_fp = zeros(1,512);
pss1_6144_fp(1:2:512) = (floor(32767*real(pss1_6144f(3072+(-128:127)))));
pss1_6144_fp(2:2:512) = (floor(32767*imag(pss1_6144f(3072+(-128:127)))));
pss1_6144_fp(1:2:256) = (floor(32767*real(pss1_6144f(6144+(-127:0)))));
pss1_6144_fp(2:2:256) = (floor(32767*imag(pss1_6144f(6144+(-127:0)))));
pss1_6144_fp(256+(1:2:256)) = (floor(32767*real(pss1_6144f(1:128))));
pss1_6144_fp(256+(2:2:256)) = (floor(32767*imag(pss1_6144f(1:128))));
pss2_6144_fp = zeros(1,512);
pss2_6144_fp(1:2:512) = (floor(32767*real(pss2_6144f(3072+(-128:127)))));
pss2_6144_fp(2:2:512) = (floor(32767*imag(pss2_6144f(3072+(-128:127)))));
pss2_6144_fp(1:2:256) = (floor(32767*real(pss2_6144f(6144+(-127:0)))));
pss2_6144_fp(2:2:256) = (floor(32767*imag(pss2_6144f(6144+(-127:0)))));
pss2_6144_fp(256+(1:2:256)) = (floor(32767*real(pss2_6144f(1:128))));
pss2_6144_fp(256+(2:2:256)) = (floor(32767*imag(pss2_6144f(1:128))));
fprintf("int16_t pss6144_0[512]={");
fprintf("static int16_t pss6144_0_0[512]__attribute__((aligned(16)))={");
fprintf("%d,",pss0_6144_fp(1:511));
fprintf("%d};\n",pss0_6144_fp(512));
fprintf("int16_t pss6144_1[512]={");
fprintf("static int16_t pss6144_0_1[512]__attribute__((aligned(16)))={0,0,");
fprintf("%d,",pss0_6144_fp(1:509));
fprintf("%d};\n",pss0_6144_fp(510));
fprintf("static int16_t pss6144_0_2[512]__attribute__((aligned(16)))={0,0,0,0,");
fprintf("%d,",pss0_6144_fp(1:507));
fprintf("%d};\n",pss0_6144_fp(508));
fprintf("static int16_t pss6144_0_3[512]__attribute__((aligned(16)))={0,0,0,0,0,0,");
fprintf("%d,",pss0_6144_fp(1:505));
fprintf("%d};\n",pss0_6144_fp(506));
fprintf("static int16_t pss6144_1_0[512]__attribute__((aligned(16)))={");
fprintf("%d,",pss1_6144_fp(1:511));
fprintf("%d};\n",pss1_6144_fp(512));
fprintf("int16_t pss6144_2[512]={");
fprintf("static int16_t pss6144_1_1[512]__attribute__((aligned(16)))={0,0");
fprintf("%d,",pss1_6144_fp(1:509));
fprintf("%d};\n",pss0_6144_fp(510));
fprintf("static int16_t pss6144_1_2[512]__attribute__((aligned(16)))={0,0,0,0,");
fprintf("%d,",pss1_6144_fp(1:507));
fprintf("%d};\n",pss1_6144_fp(508));
fprintf("static int16_t pss6144_1_3[512]__attribute__((aligned(16)))={0,0,0,0,0,0,");
fprintf("%d,",pss1_6144_fp(1:505));
fprintf("%d};\n",pss1_6144_fp(506));
fprintf("static int16_t pss6144_2_0[512]__attribute__((aligned(16)))={");
fprintf("%d,",pss2_6144_fp(1:511));
fprintf("%d};\n",pss2_6144_fp(512));
fprintf("static int16_t pss6144_2_1[512]__attribute__((aligned(16)))={0,0,");
fprintf("%d,",pss2_6144_fp(1:509));
fprintf("%d};\n",pss2_6144_fp(510));
fprintf("static int16_t pss6144_2_2[512]__attribute__((aligned(16)))={0,0,0,0,");
fprintf("%d,",pss2_6144_fp(1:507));
fprintf("%d};\n",pss2_6144_fp(508));
fprintf("static int16_t pss6144_2_3[512]__attribute__((aligned(16)))={0,0,0,0,0,0,");
fprintf("%d,",pss2_6144_fp(1:505));
fprintf("%d};\n",pss2_6144_fp(506));
This diff is collapsed.
......@@ -42,7 +42,9 @@
#include "PHY/defs.h"
#include "dci.h"
#include "uci.h"
#ifndef STANDALONE_COMPILE
#include "UTIL/LISTS/list.h"
#endif
#define MOD_TABLE_QPSK_OFFSET 1
#define MOD_TABLE_16QAM_OFFSET 5
......
......@@ -523,23 +523,27 @@ int main(int argc, char **argv)
&PHY_vars_eNb->lte_frame_parms,
(PHY_vars_eNb->lte_frame_parms.Ncp==NORMAL) ? 6 : 5,
0);
/*
generate_sss(PHY_vars_eNb->lte_eNB_common_vars.txdataF[0],
AMP,
&PHY_vars_eNb->lte_frame_parms,
(PHY_vars_eNb->lte_frame_parms.Ncp==0) ? 5 : 4,
0);
0);*/
generate_pss(PHY_vars_eNb->lte_eNB_common_vars.txdataF[0],
AMP,
&PHY_vars_eNb->lte_frame_parms,
(PHY_vars_eNb->lte_frame_parms.Ncp==0) ? 6 : 5,
10);
/*
generate_sss(PHY_vars_eNb->lte_eNB_common_vars.txdataF[0],
AMP,
&PHY_vars_eNb->lte_frame_parms,
(PHY_vars_eNb->lte_frame_parms.Ncp==0) ? 5 : 4,
10);
*/
} else {
generate_sss(PHY_vars_eNb->lte_eNB_common_vars.txdataF[0],
AMP,
&PHY_vars_eNb->lte_frame_parms,
......
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