FPGARelated.com
Forums

FFT core has reversed output data

Started by kristian February 2, 2009
Hello,

I'm implementing a autocorrelation function using a fft and ifft hard core
(v6.0) on a Virtex5. When starting the fft, I see at the output that the
result is reversed in the frequency domain.

Example: The input signal is a sinus with a frequency of 2 Hz. As output
signal I expect a dirac impuls at the beginning (imaginary).
-> f(0)=0; f(1)=0; f(2)=1; f(3)=0; �; f(N-3)=0; f(N-2)=-1; f(N-1)=0;
f(N)=0;   (*)

But I get:
-> f(0)=0; f(1)=0; f(2)=-1; f(3)=0; �; f(N-3)=0; f(N-2)=1; f(N-1)=0;
f(N)=0;

Other input signals also get the same result, that the output is
reversed.
Can you please explain me why the output order is reversed? I have no
explanation!
Is it possible to reorder the output signal like (*)?

Best regards,
Kris 


kristian <kris11@gmx.de> wrote:
 
> I'm implementing a autocorrelation function using a fft and ifft hard core > (v6.0) on a Virtex5. When starting the fft, I see at the output that the > result is reversed in the frequency domain.
If you are feeding the result of fft into ifft, possibly with some frequency domain filtering, it is much more efficient that way. If not, there should be cores that generate in the more usual order. -- glen
>kristian <kris11@gmx.de> wrote: > >> I'm implementing a autocorrelation function using a fft and ifft hard
core
>> (v6.0) on a Virtex5. When starting the fft, I see at the output that
the
>> result is reversed in the frequency domain. > >If you are feeding the result of fft into ifft, possibly with some >frequency domain filtering, it is much more efficient that way. > >If not, there should be cores that generate in the more usual order. > >-- glen >
hi glen, the ifft expects the values in normal order. the only way is to save the values from the fft in ram. is this normal that the fft core from xilinx has reversed output data? Regards, kris
On Feb 2, 3:49=A0pm, "kristian" <kri...@gmx.de> wrote:
> >kristian <kri...@gmx.de> wrote: > > >> I'm implementing a autocorrelation function using a fft and ifft hard > core > >> (v6.0) on a Virtex5. When starting the fft, I see at the output that > the > >> result is reversed in the frequency domain. > > >If you are feeding the result of fft into ifft, possibly with some > >frequency domain filtering, it is much more efficient that way. > > >If not, there should be cores that generate in the more usual order. > > >-- glen > > hi glen, > > the ifft expects the values in normal order. the only way is to save the > values from the fft in ram. is this normal that the fft core from xilinx > has reversed output data? > > Regards, > kris
Kris, No idea about the details of the Xilinx core, but if you have real valued input data and complex output data, you can expect that the output (if you reverse the output samples, with the DC value at the middle) is the negative complex conjugate (see Wikipedia or a standard textbook). That means you could just swap the real and imaginary output, assuming it's a real bug that you want to hack up a fix for. Alternatively, the behaviour you describe for a simple sinusoid could be correct, since you didn't specify the start phase. A sinusoid that's off by 180 degrees (pi radians) will have its value (dirac fft coeffs) multiplied by exp(i*pi) =3D -1. - Kenn
On Feb 3, 7:37=A0am, kennheinr...@sympatico.ca wrote:
> On Feb 2, 3:49=A0pm, "kristian" <kri...@gmx.de> wrote: > > > > > >kristian <kri...@gmx.de> wrote: > > > >> I'm implementing a autocorrelation function using a fft and ifft har=
d
> > core > > >> (v6.0) on a Virtex5. When starting the fft, I see at the output that > > the > > >> result is reversed in the frequency domain. > > > >If you are feeding the result of fft into ifft, possibly with some > > >frequency domain filtering, it is much more efficient that way. > > > >If not, there should be cores that generate in the more usual order. > > > >-- glen > > > hi glen, > > > the ifft expects the values in normal order. the only way is to save th=
e
> > values from the fft in ram. is this normal that the fft core from xilin=
x
> > has reversed output data? > > > Regards, > > kris > > Kris, > > No idea about the details of the Xilinx core, but if you have real > valued input data and complex output data, you can expect that the > output (if you reverse the output samples, with the DC value at the > middle) is the negative complex conjugate (see Wikipedia or a standard > textbook). That means you could just swap the real and imaginary > output, assuming it's a real bug that you want to hack up a fix for.
Mental misfire... negative complex conjugate is just inverting the real part; no swap required.
> > Alternatively, the behaviour you describe for a simple sinusoid could > be correct, since you didn't specify the start phase. A sinusoid > that's off by 180 degrees (pi radians) will have its value (dirac fft > coeffs) multiplied by exp(i*pi) =3D -1. > > =A0- Kenn
>> >> Kris, >> >> No idea about the details of the Xilinx core, but if you have real >> valued input data and complex output data, you can expect that the >> output (if you reverse the output samples, with the DC value at the >> middle) is the negative complex conjugate (see Wikipedia or a standard >> textbook). That means you could just swap the real and imaginary >> output, assuming it's a real bug that you want to hack up a fix for. > >Mental misfire... negative complex conjugate is just inverting the >real part; no swap required. > >> >> Alternatively, the behaviour you describe for a simple sinusoid could >> be correct, since you didn't specify the start phase. A sinusoid >> that's off by 180 degrees (pi radians) will have its value (dirac fft >> coeffs) multiplied by exp(i*pi) =3D -1. >> >> =A0- Kenn > >
Hi Kenn, to verify the results of the fft core I used a java applet (http://sepwww.stanford.edu/oldsep/hale/FftLab.html). When I put at the input of the core a sinus for the real part and a cosinus for the imaginary part then the java applet show only a positiv dirac puls at x(k) at the imaginary frequency domain. This result I also expect at the fft core output. But I get at x(N-k) a positiv dirac puls. Regards, Kris
On Feb 3, 1:53=A0pm, "kristian" <kri...@gmx.de> wrote:
> >> Kris, > > >> No idea about the details of the Xilinx core, but if you have real > >> valued input data and complex output data, you can expect that the > >> output (if you reverse the output samples, with the DC value at the > >> middle) is the negative complex conjugate (see Wikipedia or a standard > >> textbook). That means you could just swap the real and imaginary > >> output, assuming it's a real bug that you want to hack up a fix for. > > >Mental misfire... negative complex conjugate is just inverting the > >real part; no swap required.
Aargh...simple conjugate... have to remember to do the math before I open my mouth.
> > >> Alternatively, the behaviour you describe for a simple sinusoid could > >> be correct, since you didn't specify the start phase. A sinusoid > >> that's off by 180 degrees (pi radians) will have its value (dirac fft > >> coeffs) multiplied by exp(i*pi) =3D3D -1. > > >> =3DA0- Kenn > > Hi Kenn, > > to verify the results of the fft core I used a java applet > (http://sepwww.stanford.edu/oldsep/hale/FftLab.html). When I put at the > input of the core a sinus for the real part and a cosinus for the imagina=
ry
> part then the java applet show only a positiv dirac puls at x(k) at the > imaginary frequency domain. This result I also expect at the fft core > output. But I get at x(N-k) a positiv dirac puls. > > Regards, > Kris
Interesting. If you consider a sine input at pi/2, the input data looks like [0,+1,0,-1,...] For a 16-point FFT, the exponential term exp(-j2pi*nk/N) in the fft series for X[4] looks like [1, -i, -1, +i, ...] So the sum of products should be negative imaginary at X[4]. I can see this expected value out of Matlab's fft as well, and it matches your measured output. But when I type this data into your java simulator, it doesn't give me what I expect. So, assuming your input data is the same, perhaps your testbench rather than your implementation has the bug :-) - Kenn