This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

using dsplib test files with FFT hardware accelerator

Hi,

I wish to call the fft hardware accelerator function for different FFT points (8-1024) for scale/no_scale and see the results. I need some help regarding this.

1) Can I use the .h files (t1_scale.h, t2_noscale.h,t2_scale.h etc.) from CFFT in the  EXAMPLE folder of dsplib_2.40.00? The results for fft hardware accelerator will be similar to the MATLAB results and MAX_error will be similar? Or dsplib FFT and fft hardware accelerator FFT results will vary?

2) As far as I understand, for FFT hardware accelerator input is 32 bit vector of length = FFT_LENGTH. Of these 32 bits, first 16 bits form the real part and last 16 bits form the imaginary part. Is each of these two parts [Re,Im]  in Q15 format individually ? Or they together are in Q31 format? The dsplib input and result arrays for the CFFT example are in Q15 format ?

3) To use Int16* x1[2*FFT_LENGTH]  from dsplib CFFT example as Int32* x2[FFT_LENGTH], is it ok to do

                                                                             x2[i] = x1[i]  << 16 + x1[i+1] ??

4) Finally I need to find the power or amplitude of the FFT results computed. I understand that I need to compute sum of squares of real and imaginary parts of FFT results. Is it ok if I do

                                                                               pow[i] = ((x2[i] & 0xFFFF0000)^2 + (x2[i] & 0x0000FFFF)^2)^0.5

Will data being in Q15 format make any difference? Should I convert the FFT results to float before computing power?

 

I am sorry if my questions are naive. Please calrify my doubts.

 

Thanks in advance,

Rijurekha

  • Hi, I am trying to test the hardware FFT functions using the test files provided in dsplib_2.40.00.  I am attaching a sample test file (after changing the extension from .h to .txt to allow uploading). In this test file, the x vector is input vector and rtest is the expected output vector after FFT. Both vectors have  16 bits real data in (2i)-th position and 16 bits imaginary data in (2i+1)-th (i= 0....127). The FFT hardware accelerator expects input vector of 32 bits in [Re,Im] format. So I need to pack one 16 bit real and one 16 bit imaginary data into one 32 bit complex data to form the input vector. I tried the following. 

    for (i = 0,j=0; i < FFT_LENGTH; i++){

            FilterIn[i] = ((long)(x[j])) << 16 | x[j+1];

            printf("i = %d\tj = %d\treal = %ld\timaginary = %d\tshifted = %ld\tInput = %ld\n",i,j,(long)x[j],x[j+1],((long)(x[j])) << 16,FilterIn[i]);

            j = j+2;

        }

    If either the real or the imaginary part is negative, I am getting a wrong complex value. The complex value is correct only if both real and imaginary parts are positive. Examples are:

    Id in test file                    Real                    Imaginary                    Shifted real                Complex

    18                                      395                        935                             25886720                  25887655

    0                                         481                        -351                           31522816                   -351

    2                                         -316                       198                             -20709376                 -20709178

    12                                      -101                        -154                           -6619136                    -154

     

    I am able to understand that shifting negative value is giving wrong results. Can someone help me to solve this problem of packing one 16 bit real and one 16 bit imaginary data into one 32 bit complex data?

     

  • Regarding my doubt in  finding power of HWAFFT result, I understand that 
         Uint16  Real_Part = CMPLX_Vec32[i] >> 16;
         Unit16  Imaginary_Part = CMPLX_Vec32[i] & 0x0000FFFF;
    
    Will ((Real_Part/32768)^2 + (Imaginary_Part/32768)^2)^0.5 give me a float value 
    denoting power of the signal? I am dividing both parts by 32768 to convert from Q15 to float.
    
    
    
    Let me know if this is correct.
    
    
    
    
    Thanks and regards,
    Riju