Commit 00ecef77 authored by frtabu's avatar frtabu

add code to debug pucch dft

parent 4d19f6ae
...@@ -1420,7 +1420,7 @@ set(KISSFFT_DIR ${OPENAIR_DIR}/kiss_fft130) ...@@ -1420,7 +1420,7 @@ set(KISSFFT_DIR ${OPENAIR_DIR}/kiss_fft130)
add_library(dfts_fpkiss MODULE ${OPENAIR1_DIR}/PHY/TOOLS/oai_kissdfts.c ${OPENAIR1_DIR}/PHY/TOOLS/oai_dfts_tmp.c ${KISSFFT_DIR}/kiss_fft.c) add_library(dfts_fpkiss MODULE ${OPENAIR1_DIR}/PHY/TOOLS/oai_kissdfts.c ${OPENAIR1_DIR}/PHY/TOOLS/oai_dfts_tmp.c ${KISSFFT_DIR}/kiss_fft.c)
target_compile_definitions(dfts_fpkiss PUBLIC -DFIXED_POINT=16 ) target_compile_definitions(dfts_fpkiss PUBLIC -DFIXED_POINT=16 )
target_compile_options(dfts_fpkiss PUBLIC -O3 -mtune=native -ffast-math -fomit-frame-pointer -dA -fverbose-asm ) target_compile_options(dfts_fpkiss PUBLIC -O3 -mtune=native -ffast-math -fomit-frame-pointer -dA -fverbose-asm )
add_library(dfts_flkiss MODULE ${OPENAIR1_DIR}/PHY/TOOLS/oai_kissdfts.c ${KISSFFT_DIR}/kiss_fft.c) add_library(dfts_flkiss MODULE ${OPENAIR1_DIR}/PHY/TOOLS/oai_kissdfts.c ${OPENAIR1_DIR}/PHY/TOOLS/oai_dfts_tmp.c ${KISSFFT_DIR}/kiss_fft.c)
target_compile_definitions(dfts_fpkiss PUBLIC ) target_compile_definitions(dfts_fpkiss PUBLIC )
target_compile_options(dfts_fpkiss PUBLIC -O3 -mtune=native -ffast-math -fomit-frame-pointer -dA -fverbose-asm ) target_compile_options(dfts_fpkiss PUBLIC -O3 -mtune=native -ffast-math -fomit-frame-pointer -dA -fverbose-asm )
......
...@@ -51,7 +51,7 @@ static int fftsizes[] = DFT_SIZES; ...@@ -51,7 +51,7 @@ static int fftsizes[] = DFT_SIZES;
static int ifftsizes[] = IDFT_SIZES; static int ifftsizes[] = IDFT_SIZES;
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
/* dft library entry points: */ /* dft library entry points: */
static int16_t *tmpbuff;
int dfts_autoinit(void) int dfts_autoinit(void)
{ {
for (int i=0; i<DFT_SIZE_IDXTABLESIZE ; i++) { for (int i=0; i<DFT_SIZE_IDXTABLESIZE ; i++) {
...@@ -61,6 +61,7 @@ int dfts_autoinit(void) ...@@ -61,6 +61,7 @@ int dfts_autoinit(void)
ifftcfg[i]=kiss_fft_alloc(ifftsizes[i],1,NULL,NULL); ifftcfg[i]=kiss_fft_alloc(ifftsizes[i],1,NULL,NULL);
} }
#ifdef FIXED_POINT #ifdef FIXED_POINT
tmpbuff=malloc(98304*2*sizeof(int16_t));
olddfts_autoinit(); olddfts_autoinit();
#endif #endif
return 0; return 0;
...@@ -104,6 +105,14 @@ void rescale_down_int16buff(int size,int16_t *input, int factor){ ...@@ -104,6 +105,14 @@ void rescale_down_int16buff(int size,int16_t *input, int factor){
} }
} }
void rescale_dft_int16buff(int size,int16_t *input, int factor){
for (int i=0;i<(size*2);i=i+1){
int32_t tmpi=input[i]*factor;
input[i]=tmpi/4096;
}
}
void print_minmax(int size,int16_t *buf,int scale_flag) { void print_minmax(int size,int16_t *buf,int scale_flag) {
int16_t vmin=0, vmax=0; int16_t vmin=0, vmax=0;
for (int i=0;i<(size*2);i=i+1){ for (int i=0;i<(size*2);i=i+1){
...@@ -113,32 +122,74 @@ void print_minmax(int size,int16_t *buf,int scale_flag) { ...@@ -113,32 +122,74 @@ void print_minmax(int size,int16_t *buf,int scale_flag) {
if (scale_flag == 0 || (vmax - vmin)>10) if (scale_flag == 0 || (vmax - vmin)>10)
printf("%i: %i - %i\n",scale_flag,vmin,vmax); printf("%i: %i - %i\n",scale_flag,vmin,vmax);
} }
void dft(uint8_t sizeidx,int16_t *input,int16_t *output,unsigned char scale_flag){ void dft(uint8_t sizeidx,int16_t *input,int16_t *output,unsigned char scale_flag){
#ifndef FIXED_POINT #ifndef FIXED_POINT
float input_float[98304*2*sizeof(float)]; float input_float[98304*2];
float output_float[98304*2*sizeof(float)]; float output_float[98304*2];
convert_shorttofloat(fftsizes[sizeidx],input,input_float,1); switch(sizeidx) {
kiss_fft(fftcfg[sizeidx],(kiss_fft_cpx *)input_float,(kiss_fft_cpx *)output_float); case DFT_128:
if (scale_flag) case DFT_256:
convert_floattoshort(fftsizes[sizeidx],output_float,output,786732); case DFT_512:
else case DFT_1024:
convert_floattoshort(fftsizes[sizeidx],output_float,output,98304); case DFT_1536:
case DFT_2048:
case DFT_3072:
case DFT_4096:
case DFT_6144:
case DFT_8192:
case DFT_9216:
case DFT_12288:
case DFT_18432:
case DFT_24576:
case DFT_36864:
case DFT_49152:
case DFT_73728:
case DFT_98304:
convert_shorttofloat(fftsizes[sizeidx],input,input_float,8192);
kiss_fft(fftcfg[sizeidx],(kiss_fft_cpx *)input_float,(kiss_fft_cpx *)output_float);
if (scale_flag)
convert_floattoshort(fftsizes[sizeidx],output_float,output,8192);
else
convert_floattoshort(fftsizes[sizeidx],output_float,output,98304);
break;
default:
olddft(sizeidx,input,output,scale_flag);
break;
}
#else #else
int16_t tmpbuff[98304*2*sizeof(int16_t)]; switch(sizeidx) {
int16_t *inputptr; case DFT_128:
// if (scale_flag) { case DFT_256:
rescale_up_newint16buff(fftsizes[sizeidx],input,tmpbuff,16); case DFT_512:
inputptr=tmpbuff; case DFT_1024:
// } case DFT_1536:
// else case DFT_2048:
// inputptr=input; case DFT_3072:
kiss_fft(fftcfg[sizeidx],(kiss_fft_cpx *)inputptr,(kiss_fft_cpx *)output); case DFT_4096:
if (scale_flag) case DFT_6144:
rescale_down_int16buff(fftsizes[sizeidx],output,64); case DFT_8192:
else case DFT_9216:
rescale_down_int16buff(fftsizes[sizeidx],output,16); case DFT_12288:
// olddft(sizeidx,input,output,scale_flag); case DFT_18432:
print_minmax(fftsizes[sizeidx],output,scale_flag); case DFT_24576:
case DFT_36864:
case DFT_49152:
case DFT_73728:
case DFT_98304:
if (scale_flag)
rescale_up_int16buff(fftsizes[sizeidx],input,16);
//
kiss_fft(fftcfg[sizeidx],(kiss_fft_cpx *)input,(kiss_fft_cpx *)output);
// if (scale_flag)
// rescale_down_int16buff(fftsizes[sizeidx],output,16);
break;
default:
olddft(sizeidx,input,output,scale_flag);
break;
}
// print_minmax(fftsizes[sizeidx],output,scale_flag);
#endif #endif
}; };
...@@ -146,7 +197,7 @@ void idft(uint8_t sizeidx, int16_t *input,int16_t *output,unsigned char scale_fl ...@@ -146,7 +197,7 @@ void idft(uint8_t sizeidx, int16_t *input,int16_t *output,unsigned char scale_fl
#ifndef FIXED_POINT #ifndef FIXED_POINT
float input_float2[98304*2]; float input_float2[98304*2];
float output_float2[98304*2]; float output_float2[98304*2];
convert_shorttofloat(ifftsizes[sizeidx],input,input_float2,8192); convert_shorttofloat(ifftsizes[sizeidx],input,input_float2, 4096);
kiss_fft(ifftcfg[sizeidx],(kiss_fft_cpx *)input_float2,(kiss_fft_cpx *)output_float2); kiss_fft(ifftcfg[sizeidx],(kiss_fft_cpx *)input_float2,(kiss_fft_cpx *)output_float2);
convert_floattoshort(ifftsizes[sizeidx],output_float2,output,98304); convert_floattoshort(ifftsizes[sizeidx],output_float2,output,98304);
#else #else
......
...@@ -293,11 +293,11 @@ typedef enum DFT_size_idx { ...@@ -293,11 +293,11 @@ typedef enum DFT_size_idx {
} dft_size_idx_t; } dft_size_idx_t;
#define DFT_SIZES {\ #define DFT_SIZES {\
12, 24, 36, 48, 60, 72, 96,\ 12*4, 24*4, 36*4, 48*4, 60*4, 72*4, 96*4,\
108, 120, 128, 144, 180, 192, 216, 240,\ 108*4, 120*4, 128, 144*4, 180*4, 192*4, 216*4, 240*4,\
256, 288, 300, 324, 360, 384, 432, 480,\ 256, 288*4, 300*4, 324*4, 360*4, 384*4, 432*4, 480*4,\
512, 540, 576, 600, 648, 720, 768, 864,\ 512, 540*4, 576*4, 600*4, 648*4, 720*4, 768*4, 864*4,\
900, 960, 972, 1024, 1080, 1152, 1200, 1536,\ 900*4, 960*4, 972*4, 1024, 1080*4, 1152*4, 1200*4, 1536,\
2048, 3072, 4096, 6144, 8192 ,9216, 12288, 18432,\ 2048, 3072, 4096, 6144, 8192 ,9216, 12288, 18432,\
24576, 36864, 49152,73728, 98304} 24576, 36864, 49152,73728, 98304}
......
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