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.

how to use DSPF_sp_fftSPxSP_r2c() and DSPF_sp_ifftSPxSP_c2r()

It's nice to learn that in the new dsplib_c66x_3_4_0_0 you introduced the two functions,DSPF_sp_fftSPxSP_r2c() and DSPF_sp_ifftSPxSP_c2r(), to speed up FFT. However, there is little information on how to use them. I tried to run the fft and and ifft one after the other. I was expecting I can recover the fft input data. However, I could not. I wonder if you can point me to the right place to get more information.  Thanks.

  • Hi,

    Thanks for your post.

    I think, it is recommended to refer the DSP library user manual on the c66x dsp lib installation path to know more info. on the API references

    ~\ti\dsplib_c66x_3_4_0_0\docs\DSPLIB_Users_Manual.chm::/dsplib_html/group___d_s_p_f__sp__fft_s_p_x_s_p__r2c.html

    ~\ti\dsplib_c66x_3_4_0_0\docs\DSPLIB_Users_Manual.chm::/dsplib_html/group___d_s_p_f__sp__ifft_s_p_x_s_p__c2r.html

    You could also refer the source files for the above API's from the below paths:

    ~\ti\dsplib_c66x_3_4_0_0\packages\ti\dsplib\src\DSPF_sp_fftSPxSP_r2c\c66\

    ~\ti\dsplib_c66x_3_4_0_0\packages\ti\dsplib\src\DSPF_sp_ifftSPxSP_c2r\c66

    Also, there is a example DSP C code that uses TI C66x intrinsic FFT functions as below:

    http://processors.wiki.ti.com/index.php/MexExample?keyMatch=c66x dsplib&tisearch=Search-EN#Executing_the_Example

    You could also refer c64x+ DSP programmer's reference guide as below:

    http://www.ti.com/lit/ug/sprueb8b/sprueb8b.pdf

    Thanks & regards,

    Sivaraj K

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    --------------------------------------------------------------------------------------------------------

  • Hi Sivaraj,

    Thank you for your help. However, I was looking for more information. I had gone through these before I asked the question. The example and the programmer's reference guide doesn't cover the two newly introduced functions at all. I am pretty familiar with the subject. Currently, I am using the regular FFT and IFFT without the r2c and c2r part. I also implemented an FFT for real data based on your FFT (for complex data). Which will be very similar to the fft_r2c, ifft_c2r. I need a more efficient implementation.

    Let me ask the question differently. For an N sample real data. The size of the output of the FFT should be N sample of complex data. However, your fft_r2c output's size is N/2 complex data. The question is how the N/2 complex data are stored to represent the information of a regular N sample FFT output. In my own implementation, I discard the second of the FFT output as they are symmetric in complex conjugate.

     

    Thanks,

    Garry

     

  • Hi Garry,

    There is no other resources available for the API's mentioned above other than the source files available in the DSPLIB installation folder as below:

    ~\ti\dsplib_c66x_3_4_0_0\packages\ti\dsplib\src\DSPF_sp_fftSPxSP_r2c\c66\DSPF_sp_fftSPxSP_r2c_cn.c

    ~\ti\dsplib_c66x_3_4_0_0\packages\ti\dsplib\src\DSPF_sp_ifftSPxSP_c2r\c66\DSPF_sp_ifftSPxSP_c2r_cn.c

    Kindly walkthrough the above source files to address the question "how the N/2 complex data are stored to represent the information of a regular N sample FFT output"

    Thanks & regards,

    Sivaraj K

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    --------------------------------------------------------------------------------------------------------

  • Because the FFT outputs are bit reversed the output of FFT cannot be fed to the iFFT routine. Please treat them as seperate functions.
    Regards
    Asheesh
  • Hi Asheesh,

    Thanks for getting back to me. It would be nice if you can provide some document  on how to use the function and some examples. I went through the documents. I found nothing on DSPF_sp_fftSPxSP_r2c() except the source code, which is very helpful though. You wrote that the FFT outputs are bit reversed (DSPF_sp_fftSPxSP_r2c()'s output?), which is probably not true based on the output I get. Please see the attach plot. The normal ordered output is in red (real, imaginary). If it's bit reversed, we should see some big values in the middle of the blue plot as well.

     

  • Look at the function DSPF_sp_fftSPxSP_r2c_cn.c which is the C code in the project. There is bit reversal happening in the code in the final stage of the FFT processing. The FFT is pretty much standard text book implementation. You can refer the C code if not the optimised version for understanding.
    Regards,
    Asheesh
  • I wonder if could just tell me how the fft output is formatted. You mentioned bit reversal. However, we need more precise information. For N real floating-point input data, the normal fft output should be N complex data, which is 2N floating-point data (N real + N imaginary). As you can see, DSPF_sp_fftSPxSP_r2c() has only N floating point output ? My question is how is the output stored in the memory?  Thank you for your help.

  • The input to the function is read as N inputs with complex value having imaginary value as zero that's why the result is N outputs as complex with N real and N imaginary.

    Regards
    Asheesh

    Confirm Verify button if it answer your question.
  • Hi Asheesh,

     First of all, I think the input and output are the same size in terms of floating point data numbers. Therefore, you did not answer my question. I don't think you know the issue well. I am sorry for saying this. Thanks for trying to help. I wonder if you can discuss the issue with other team members.

    Regards,

    Garry

  • Garry,
    The input is N floating point real numbers and real to complex will create N values of complex values which is 2N floats.

    The function input is N complex values with N real and N imaginary float values and imaginary value is zero. The output is N complex which is 2N float values. This is exactly what you have asked above and what the function is doing.

    You can verify the values of input and output on the memory window.
    Regards,
    Asheesh
  • You are saying that the input is N complex values? I don't think that's correct. Look at the C code of function DSPF_sp_fftSPxSP_r2c(). It calls DSPF_sp_fftSPxSP() at the very beginning. In other words, function DSPF_sp_fftSPxSP_r2c() is N real values only without the imaginary part.

  • It calls DSPF_sp_fftSPxSP() with SIZE N/2.
  • Asheesh,

    Regarding 

    "The input is N floating point real numbers and real to complex will create N values of complex values which is 2N floats."

    It seems the real and imaginary part is NOT interleaved. From my experiment, it seems this function treat N consecutive data as real part, and following N data as imaginary data. 

    So in my case, I have to clear the imaginary part after I finished FFT, otherwise garbage data will be treated as imaginary part of next FFT.

    I'm eagerly to know if your team can provide a detailed explanation of how these two function works.

    BR,

    Justin

  • I need to correct my understanding as below:

    For a FFT_LENGTH real data  FFT function DSPF_sp_fftSPxSP_r2c take odd number as real part and even number as imaginary part
    The FFT is a complex FFT with complex length of FFT_LENGTH/2

    This is description from TI CHM:

    // DSPF_sp_fftSPxSP_r2c()
    // Parameters:
    // N length of FFT in complex samples
    // ptr_x pointer to complex data input
    // ptr_w pointer to complex twiddle factor
    // ptr_y pointer to real output data
    // brev pointer to bit reverse table containing 64 entries
    // n_min should be 4 if N can be represented as Power of 4 else, n_min should be 2
    // offset index in complex samples of sub - fft from start of main fft
    // n_max size of main fft in complex samples

    BR,

    Justin