Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

Strange FFT Output

I've been using SignalTap to create a CSV file of the output from my FFT engine. However, when looking at the output in Matlab, it doesn't look right at all.

I know that the ADC's working properly, I'm sending in a 1kHz signal which looks perfect when plotted, so the FFT input is fine, but, the output is all over the place. Is there further processing I have to do on it to make it look like the Matlab example, or is there something going horribly wrong with my FFT core?

I've attached the plot of the Real values coming out of the FFT, any thoughts?

17 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    the value -6 should be filled with ones. This is correct in 2's complement.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It looks like you are doing something wrong with data formats or that your input entering the fft is not what you think. Have you actually captured digital vector entering fft core?

    Matlab model cannot be right either if you are looking at fft of a single sine input.

    Finally, is your sampling rate correct?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Right, I've identified an error here. As I've mentioned before, the input to my FFT is a 12-bit signed value, and for some reason, when the value is negative, the whole rest of the word is populated with 1s rather than just the MSB. For example, the value 111111111010 is used to represent -6, rather than 100000000010.

    I think this is causing the FFT to clip, and give me a really weird output. Any ideas why this would be happening?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I've done a few simulations using $fwrite to capture the data, both in Natural and Bit Reversed orders, and the output is still incorrect. I've attached an example output at the bottom. The input for both of these examples is a 17.36Hz sine wave, generated in the Verilog testbench.

    I know it's not a problem with the FFT engine, as running the testbench that is generated with the core gives exactly the same output as when run in Matlab. One thing I realised I was doing wrong previously, was using an unsigned integer as the input, something which I have now rectified.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Check the output order of your FFT samples. They may be in bit reversed order. Also, in simulation tools to can generate a .csv fairly easily by using $fwrite in verilog. I'm sure that VHDL has something similar.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Anakha,

    Thanks for this response, I'm taking a look at it now. Some info for you:

    1024 point FFT

    Quartus v11.1 (FFT core generated in this version)

    I have simulated the core previously, but I have been unable to look at the output properly. Is there a way to get a csv file or something out of modelsim? I'm also now trying to generate a 1kHz wave in my testbench to simulate with, so I should have some results soon.

    Dave
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    As long as your matlab is giving you just the real and imaginary output of the FFT calculations the output should look very similar. If Matlab is giving you a Magnitude plot. You need to calculate the magnitude of the output. But looking at your "Real" output, it looks like something is broken.

    Here's what I would check:

    1: Check your warnings. Make sure the FFT core is finding the twiddle ROM files. (Sin/cos lookup tables). If it doesn't find these files, the outputs will be incorrect.

    2: Make sure your Avalon streaming interface is working properly. (You should be able to check the "error" output and it should ALWAYS be zero. If this is not the case, the outputs will be incorrect.

    Here's some other general questions to answer that may help pinpoint the issue.

    What size of FFT are you running? (how many points?)

    What version of Quartus are you using?

    Was the FFT core generated with the same version of Quartus?

    Have you simulated the core? in Verilog/VHDL?

    Pete