I'm attempting to simulate a fixed point variable streaming FFT IP core in Matlab, and compare its output to the output of the built-in Matlab fft. The core produces transforms that are similar to the output from Matlab, but the peaks for test signals tend to show up at different frequencies, and the error varies depending on the input frequency. Is this to be expected, or have I missed something?
The following is my Matlab script:
%set up input parameters
DATA_WIDTH = 1024;
SAMP_RATE = 100;
INVERSE = 0;
%input parameters
AMPLITUDE = 127;
FREQ = 30;
%define time
time = (0:1/SAMP_RATE:(DATA_WIDTH/SAMP_RATE));
%create input signal
data_in = (AMPLITUDE*sin(2*pi*FREQ*time));
%take the fft of the input with MATLAB's function
matlabfft = fft(data_in);
%use the IP core to take the FFT. Undo the digit reverse
alterafft = fft_ii_0_example_design_model(data_in,DATA_WIDTH,INVERSE);
alterafft = alterafft(digit_reverse(0:(1024-1), log2(1024)) + 1);
Thank you!
Link Copied
Hi,
Sorry for the delay. I have been performing some tests in Matlab on this. For your information, based on my understanding, Matlab FFT seems to be working with Natural data type only. I have generated a FFT instance with configuration similar to yours but set the Input Order = Natural instead of Digit Reverse. This is to further isolate the part of undoing digit reverse.
As I simulated the Matlab model using your fft_test.m, it seems like I am able to get similar peak frequency between Matlab FFT and CV FFT. I have sent the simulation zip and the screenshot to you through the Forum email for your reference.
Note that I am using CV FFT in Q17.0Std and Matlab R2015a since I only have these available in my PC.
Please let me know if there is any concern. Thank you.
Best regards,
Chee Pin
Hi,
As I understand it, you seems to observe discrepancy between the FFT IP core vs Matlab built-in FFT in Matlab simulation. To ensure we are on the same page, just would like to check with you on the following:
Please let me know if there is any concern. Thank you.
Hello!
My apologies for the missing information. I am using Quartus Prime Version 18.1.0 Build 625 09/12/2018 SJ Lite Edition, Matlab version 9.7.0.1190202 (R2019b), and I am targeting A Cyclone V 5CSEBA6U23I7DK. I have attached a .zip with all of the IP files (including the .qip) inside.
When I run the Matlab script, I see the following:
The actual frequency should be 15.2 (from my test script).
In order to generate the FFT IP core, in my Quartus Project, I open the IP catalog, search for "FFT" and double click it. I give the core a name (test_fft_ip.qsys in this case), and set the parameters to the following:
Then I click "Generate Example Design", select the default directory and click "OK".
I have not yet tried simulating with Modelsim, I will do that now.
Thank you so much!
Hi,
Thanks for your update. I will further look into them and provide you an update on the progress by early next week or as soon as there is any valid finding. Thank you very much.
Hi,
Sorry for the delay. I have been performing some tests in Matlab on this. For your information, based on my understanding, Matlab FFT seems to be working with Natural data type only. I have generated a FFT instance with configuration similar to yours but set the Input Order = Natural instead of Digit Reverse. This is to further isolate the part of undoing digit reverse.
As I simulated the Matlab model using your fft_test.m, it seems like I am able to get similar peak frequency between Matlab FFT and CV FFT. I have sent the simulation zip and the screenshot to you through the Forum email for your reference.
Note that I am using CV FFT in Q17.0Std and Matlab R2015a since I only have these available in my PC.
Please let me know if there is any concern. Thank you.
Best regards,
Chee Pin
Awesome, thank you!
For more complete information about compiler optimizations, see our Optimization Notice.