Forum Discussion
Altera_Forum
Honored Contributor
17 years agoI have several suggestions and also want to point out that it is not quite fair to compare Altera's FFT to Matlab's FFT.
First of all, Matlab's FFT implementation (the fft function) is actually a floating point DFT implementation- and we don't really have control over twiddle precision within the fft function. So that wouldn't exactly be a fair comparison... Also one thing I found about Altera's FFT core (especially with the older architectures that utilize block floating point representation: i.e. streaming, burst and buffered burst), it is best if you scale up your data (so you are using all of the dynamic range). I presume it is due to the block floating point structure (the data is scaled after each stage of butterfly... therefore if you are not using enough precision, it is very possible that your data would completely disappear somewhere within the FFT core). Please see my attached .zip file for detail. In the zip file, you will find three files: - in.mat (this is your original input) - FFT_Altera_model.m -> this is the bit-accurate matlab simulation model generated by Altera's FFT megacore, version 8.0 (here I am using a streaming FFT core) - FFT_Altera_tb.m -> this is my testbench comparing Altera's result with matlab fft's result (using your input)... Two things to note: 1. By scaling up the input prior to Altera's fft function and then scaling the output back, we see that Altera's fft generates similar output to matlab's fft function. The bigger the data and twiddle resolution, the smaller the difference between Altera's and Matlab's fft spectrum. The difference can be attribute to the fact that Matlab uses floating point representation. 2. Also your Altera's fft output is really = data_out*2^(-exp_out) -> see appendix in FFT UG. Did you remember to do this? 3. Without properly scaling the input data prior to Altera's fft function.... the difference is pretty big.... I imagine this is what you're seeing... Also if you are using the FFT core, you do need to pay attention to the sink_ready signal... make sure you don't input data while sink_ready is low... That gave me some trouble before... Anyhow, hope this helps...