The usage of the
FFT core is straightforward, however, it does have a lot more knobs to turn compared to a simple fft() function in Matlab. Sometimes when the output from the FFT core doesn't match Matlab fft() result you start to question if there is a bug in the FFT core. I will use a simple example here hopefully to
- provide some assurance that the result from the FFT core match well with Matlab fft() function and FFT bit accurate C model
- provide a starting point so you can look at configurations as well as timing of control and data signals of the core in case you didn't have time to read the FFT core data sheet
Below is the SysGen model that uses a 256-point FFT with pipelined streaming IO and unscaled output in natural order. The input vector is a simple ramp (-128:127)/128 in fixed 16.15 format.
The waveform below shows the FFT signals at the beginning of the simulation in
WaveScope (a great tool in Xilinx Blockset for debugging, by the way). Note that in FFT v7.0 and newer, there is no longer a requirement of 3 cycle offset between xn_index and xn_re/xn_im inputs.
The waveform below is at the end of FFT computation and data start to unload. Note that xk_index is incrementing as the core output is in natural order.
The simulation results are collected in workspace. A m script is then run to compare the results from Matlab fft(), FFT bit accurate C model, and the Simulink simulation. Below is an overlay plot showing all three outputs, where the difference is negligible.
The script also prints all elements of outputs side by side for easy comparison.
idx Matlab Bit Accurate SysGen
0 1.000000 1.000000 1.000000
1 81.489376 81.489504 81.489595
2 40.747756 40.747746 40.747868
3 27.168581 27.168709 27.168739
4 20.380016 20.380048 20.380078
5 16.307697 16.307667 16.307587
...
251 16.307697 16.307667 16.307545
252 20.380016 20.380048 20.380017
253 27.168581 27.168709 27.168495
254 40.747756 40.747746 40.747960
255 81.489376 81.489504 81.489687
In case you want to play with the example design, you can
download it from here. You will need to download the bit accurate C model from
FFT core web site yourself because it requires registration.