DSPRelated.com
Forums

FFT implementation issue on TMS320C6474 with dsplib_v210

Started by iamrahulmaurya November 10, 2010
Hi,

I need to discuss regarding some conceptual verification of FFT implementation on TMS320C6474 by using dsplib_v210 library functions. I have run a test program shown bellow to evaluate the accuracy of execution and implementation understanding. In my view, after performing IFFT on FFT of input array I should get back the original array accurately. But here I am not able to get so. Program behavior raise these questions:

1. Why I m not able to get back my original array after IFFT.

2. After FFT implementation original array is also getting changed.

3. Why DSP_fft16x16 and DSP_ifft16x16 function is returning short, according to me it should be float.

Please help me to get to know my faults in execution. Thanks a lot.

#include

#include

#include

#include

#include

#include

#define N 16

#pragma DATA_ALIGN(x32, 8);

Int16 x32[2*N];

#pragma DATA_ALIGN(X32, 8);

Int16 X32[2*N];

#pragma DATA_ALIGN(y32, 8);

Int16 y32[2*N];

#pragma DATA_ALIGN(twiddle, 8);

Int16 twiddle[2*N];

#pragma DATA_ALIGN(itwiddle, 8);

Int16 itwiddle[2*N];

#pragma DATA_ALIGN(x32, 8);

Int16 x32[2*N];

void main()

{

Int16 x16[N] = { 75,68,75,75,75,68,61,54,61,54,61,54,68,68,75,68};

Int16 i, k;

memset(x32,0,sizeof(Int16)*N*2);

for(i=0,k=0; i
x32[k] = x16[i];

gen_twiddle_fft16x16(twiddle, N);

DSP_fft16x16(twiddle, N, X32, x32);

DSP_ifft16x16(twiddle, N, X32, y32);

}

Output:

x16:

75, 68, 75, 75, 75, 68, 61, 54, 61, 54, 61, 54, 68, 68, 75, 68,

x32 Before FFT:

(75,0) (68,0) (75,0) (75,0) (75,0) (68,0) (61,0) (54,0) (61,0) (54,0) (61,0) (54,0) (68,0) (68,0) (75,0) (68,0)

twiddle for FFT:

(0,32767) (12540,30273) (0,-32767) (-23170,-23170) (0,32767) (30273,12540) (23170,23170) (30273,12540) (-32767,0) (-23170,23170) (23170,-23170) (-12540,-30273) (-32704,-5161) (23558,22104) (13260,14095) (-21941,-19219)

x32 After FFT:

(5651,-10480) (16969,-28888) (-19868,-21882) (24130,23716) (14869,-29232) (9322,-861) (25706,12908) (24399,6273) (-29703,24174) (-27675,-22754) (-25284,-7302) (7650,31002) (21963,14722) (2640,10367) (-9522,3280) (-16531,-1155)

X32 After FFT:

(3195,-16588) (3443,-10437) (17547,-9333) (-18534,25878) (314,-10534) (13968,137) (-5667,-15287) (8354,-3204) (-7242,13135) (-1053,21546) (-15334,5041) (3761,3932) (9912,14959) (2263,8411) (5978,12400) (5977,-12054)

X32 After IFFT:

(3090,486) (9311,9829) (1262,-3589) (-221,7276) (-14803,13107) (2019,-11810) (-10955,-7442) (5276,19041) (-7136,-3939) (-3988,5799) (-702,-951) (3053,17526) (-7528,-10062) (9369,5926) (-2801,-871) (2466,-11612)

y32 After IFFT:

(13442,14002) (-18463,12896) (-8773,18435) (1506,-16619) (-725,13607) (27003,17292) (5293,-10029) (-22265,-2288) (-4738,-20208) (32483,-1566) (-6903,-28215) (-22164,-5247) (4381,-5457) (30837,23806) (-18161,4053) (12811,-16094)

_____________________________________
Hi Rahul Maurya,

I'll try to briefly attend your questions, but in the reverse order:

Re 3: That's fine, the routine has been designed just to do so.

Re 2: That's possible. It could be a matter of optimization. A
routine generally is not obliged to keep it's input intact.

Re 1: This is one of the characteristics of the fixed point math.
It includes roundoff error in the process of multiplication,
which may result in complete cancellation, and there might
be an overflow during addition or subtraction operation.
To cope with overflows, a scaling is usually being performed.

As the basic FFT operation is addition and subtraction followed
by multiplication - the result might need to be scaled. Usually
the necessity of this is not known apriory, so the scaling
is either performed all at once on the input, which is more bad,
or shift by shift after each of the log2(N) (or whatever radix
is being used) phase of the transform.

The short ahswer to 1 is "it is not possible"...

Rgds,

Andrew

> 1. FFT implementation issue on TMS320C6474 with dsplib_v210
> Posted by: "iamrahulmaurya" er dot rahulmaurya at gmail dot com iamrahulmaurya
> Date: Tue Nov 9, 2010 10:59 pm ((PST))
>
> Hi,
>
> I need to discuss regarding some conceptual verification of FFT
> implementation on TMS320C6474 by using dsplib_v210 library functions. I have
> run a test program shown bellow to evaluate the accuracy of execution and
> implementation understanding. In my view, after performing IFFT on FFT of
> input array I should get back the original array accurately. But here I am
> not able to get so. Program behavior raise these questions:
>
> 1. Why I m not able to get back my original array after IFFT.
>
> 2. After FFT implementation original array is also getting changed.
>
> 3. Why DSP_fft16x16 and DSP_ifft16x16 function is returning short,
> according to me it should be float.
>
> Please help me to get to know my faults in execution. Thanks a lot.
>
> #include
> #include
> #include
> #include
> #include
> #include
> #define N 16
>
> #pragma DATA_ALIGN(x32, 8);
> Int16 x32[2*N];
>
> #pragma DATA_ALIGN(X32, 8);
> Int16 X32[2*N];
>
> #pragma DATA_ALIGN(y32, 8);
> Int16 y32[2*N];
>
> #pragma DATA_ALIGN(twiddle, 8);
> Int16 twiddle[2*N];
>
> #pragma DATA_ALIGN(itwiddle, 8);
> Int16 itwiddle[2*N];
>
> #pragma DATA_ALIGN(x32, 8);
> Int16 x32[2*N];
>
> void main()
> {
> Int16 x16[N] = { 75,68,75,75,75,68,61,54,61,54,61,54,68,68,75,68};
> Int16 i, k;
>
> memset(x32,0,sizeof(Int16)*N*2);
>
> for(i=0,k=0; i > x32[k] = x16[i];
>
> gen_twiddle_fft16x16(twiddle, N);
>
> DSP_fft16x16(twiddle, N, X32, x32);
>
> DSP_ifft16x16(twiddle, N, X32, y32);
> }
>
> Output:
>
> x16:
> 75, 68, 75, 75, 75, 68, 61, 54, 61, 54, 61, 54, 68, 68, 75, 68,
>
> x32 Before FFT:
> (75,0) (68,0) (75,0) (75,0) (75,0) (68,0) (61,0) (54,0) (61,0) (54,0) (61,0)
> (54,0) (68,0) (68,0) (75,0) (68,0)
>
> twiddle for FFT:
> (0,32767) (12540,30273) (0,-32767) (-23170,-23170) (0,32767) (30273,12540)
> (23170,23170) (30273,12540) (-32767,0) (-23170,23170) (23170,-23170)
> (-12540,-30273) (-32704,-5161) (23558,22104) (13260,14095) (-21941,-19219)
>
> x32 After FFT:
> (5651,-10480) (16969,-28888) (-19868,-21882) (24130,23716) (14869,-29232)
> (9322,-861) (25706,12908) (24399,6273) (-29703,24174) (-27675,-22754)
> (-25284,-7302) (7650,31002) (21963,14722) (2640,10367) (-9522,3280)
> (-16531,-1155)
>
> X32 After FFT:
> (3195,-16588) (3443,-10437) (17547,-9333) (-18534,25878) (314,-10534)
> (13968,137) (-5667,-15287) (8354,-3204) (-7242,13135) (-1053,21546)
> (-15334,5041) (3761,3932) (9912,14959) (2263,8411) (5978,12400) (5977,-12054)
>
> X32 After IFFT:
> (3090,486) (9311,9829) (1262,-3589) (-221,7276) (-14803,13107) (2019,-11810)
> (-10955,-7442) (5276,19041) (-7136,-3939) (-3988,5799) (-702,-951)
> (3053,17526) (-7528,-10062) (9369,5926) (-2801,-871) (2466,-11612)
>
> y32 After IFFT:
> (13442,14002) (-18463,12896) (-8773,18435) (1506,-16619) (-725,13607)
> (27003,17292) (5293,-10029) (-22265,-2288) (-4738,-20208) (32483,-1566)
> (-6903,-28215) (-22164,-5247) (4381,-5457) (30837,23806) (-18161,4053)
> (12811,-16094)

_____________________________________