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.

关于6678 dsplib ifft的问题



我安装的dsplib 版本为3.1.0.0,在测试fft和ifft时,fft调用DSPF_sp_fftDPxDP函数,ifft调用DSPF_sp_ifftDPxDP函数。

将结果和matlab输出的结果进行对比,发现DSPF_sp_fftDPxDP输出结果和matlab输出的结果一致,但DSPF_sp_ifftDPxDP的结果和matlab的结果不一样,而且将数据经过fft后再进行ifft,结果与原数据不一致。比较过数据ifft输出的数据与原数据无任何比例关系。

请问下有人知道这是为什么吗?

  • 看一下是不是归一化的问题?
  • 代码如下,请帮我看下代码有没有问题:

    #include <stdio.h>
    #include <stdlib.h>
    #include <stdint.h>
    #include <math.h>
    #include <c6x.h>
    #include <time.h>
    #include <ti/dsplib/src/DSPF_sp_fftSPxSP/c66/DSPF_sp_fftSPxSP.h>
    #include <ti/dsplib/src/DSPF_sp_ifftSPxSP/c66/DSPF_sp_ifftSPxSP.h>


    #define N 32

    #define PI 3.14159265358979323846

    #pragma DATA_ALIGN(brev, 8);
    unsigned char brev[64] = {
    0x0, 0x20, 0x10, 0x30, 0x8, 0x28, 0x18, 0x38,
    0x4, 0x24, 0x14, 0x34, 0xc, 0x2c, 0x1c, 0x3c,
    0x2, 0x22, 0x12, 0x32, 0xa, 0x2a, 0x1a, 0x3a,
    0x6, 0x26, 0x16, 0x36, 0xe, 0x2e, 0x1e, 0x3e,
    0x1, 0x21, 0x11, 0x31, 0x9, 0x29, 0x19, 0x39,
    0x5, 0x25, 0x15, 0x35, 0xd, 0x2d, 0x1d, 0x3d,
    0x3, 0x23, 0x13, 0x33, 0xb, 0x2b, 0x1b, 0x3b,
    0x7, 0x27, 0x17, 0x37, 0xf, 0x2f, 0x1f, 0x3f
    };

    #pragma DATA_ALIGN(f_src, 8);
    float f_src [2*N];
    #pragma DATA_ALIGN(f_out, 8);
    float f_out [2*N];
    #pragma DATA_ALIGN(f_tw, 8);
    float f_tw [2*N];

    //static clock_t t_start, t_stop, t_overhead;

    /* Function for generating Specialized sequence of twiddle factors */
    int gen_tw_1d_single (float *w, int n)
    {
    int i, j, k;

    for (j = 1, k = 0; j <= n >> 2; j = j << 2)
    {
    for (i = 0; i < n >> 2; i += j)
    {
    w[k] = (float) sin (2 * PI * i / n);
    w[k + 1] = (float) cos (2 * PI * i / n);
    w[k + 2] = (float) sin (4 * PI * i / n);
    w[k + 3] = (float) cos (4 * PI * i / n);
    w[k + 4] = (float) sin (6 * PI * i / n);
    w[k + 5] = (float) cos (6 * PI * i / n);
    k += 6;
    }
    }

    return k;
    }

    void main()
    {
    int loop;

    for(loop = 0; loop < N ; loop ++)
    {
    f_src[loop * 2] = (float)(rand() % 16383);
    f_src[loop * 2 + 1] = 0;
    printf("%d\t", (int)f_src[loop * 2]);
    }

    printf("\n");

    gen_tw_1d_single(f_tw, N);

    //TSCL=0;TSCH=0;
    // t_start = _itoll(TSCH, TSCL);

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

    //DSPF_sp_fftSPxSP_cn(N, f_src , f_tw, f_out, brev, 4, 0, N);
    DSPF_sp_fftSPxSP(N, f_src , f_tw, f_out, brev, 4, 0, N);
    //t_stop = _itoll(TSCH, TSCL);
    //t_overhead = t_stop - t_start;

    for(loop = 0; loop < N * 2; loop ++)
    {
    f_src[loop] = f_out[loop]/N;
    }
    // printf("Cycle Consumed :%d\nTime Consumed:%f ms\n\n", t_overhead, (float)t_overhead / CYCLEPERMS);

    /*
    * @param N length of FFT in complex samples
    * @param ptr_x pointer to complex data input
    * @param ptr_w pointer to complex twiddle factor
    * @param ptr_y pointer to complex output data
    * @param brev pointer to bit reverse table containing 64 entries
    * @param n_min should be 4 if N can be represented as Power of 4 else, n_min should be 2
    * @param offset index in complex samples of sub-fft from start of main fft
    * @param n_max size of main fft in complex samples
    *
    */
    DSPF_sp_ifftSPxSP(N, f_src , f_tw, f_out, brev, 4, 0, N);

    for(loop = 0; loop < N; loop ++)
    {
    printf("%d\t", (int)f_out[loop * 2]);
    }

    printf("\n");
    }

  • 已经做了归一化处理。