Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 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

    I normally write as follows:

    
    ---- write data_out to file
    process(clk)
    file file_out : text open write_mode is "filename.txt";
    variable line_in : line;
    variable tmp : integer := 0;
    begin
    if(rising_edge(clk))then
      if valid_out = '1' then
         tmp := to_integer(signed(data_out));
         write(line_in, tmp);    
         writeline(file_out,line_in);
      end if;
    end if;
    end process;
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Literally mate, you are a bloody hero. Don't let anyone tell you otherwise.

    Check the output now.

    Thankyou so much!!!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    sorry, im having a problem using the ifft/fft, my state machines that control the megafunctions are working properly, as i get no errors from the fft error bus and i get sop and eop where i am supposed to get it, after and a the beginning of my fft/ifft length, the problem is that my data is all over the place. my N=1024, i ifft 3+3i(600 times) and padd with zeros, but when i fft the output of the ifft, some of the values give correct data, while some of the values are negative, help please, been working on this problem for a while now

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

    Hi Sam_novice.

    I have done altera fft some 12 years ago !! and so it has quite changed now but the principles stay same.

    For the forum to help you may be you start a new thread explaining in as much detail as you can so that members can help.

    First describe your settings and tools/platforms and try not to be short and please do not use terms like if I fft the ifft ? as it has hard for many of us to keep track.

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

    Thank you i solved the problem, my fft works, both in variable streaming and normal streaming, the problem was i was not watching the response of the sink_valid signal thank you

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

    yes it does seem asserted all the time, but it is not, you need to put an option in your down stream fft state machine, that says that when sink_valid is high you sample and when it is not, you do not sample. This is made clearer in the Avalon interface specifications, read the section about data streaming and its control

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

    I wrote to you on message board the following, did you make use of my suggestion:

    Looks like your fft is not seeing the frame correctly (http://www.alteraforum.com/forum/member.php?u=7086#).

    try this matlab code and you will see what I mean:

    x = [ones(1,600)*3+j*3 zeros(1,1024-600)];

    y1 = round(ifft(x));

    y2 = round(fft([0 y1]));

    plot(real(x))

    hold

    plot(real(y2),'r-')

    Thus I inserted one zero at start of frame(y1) and I got all output wrong going up and down.

    You can use this approach to find out which way it equals your output e.g. insert one zero or two zeros or repeat first sample or insert zero at end ...etc