Tuesday, July 13, 2010

FFT: Valid Values of Number of Stages Using Block RAM

If you have used the FFT block in System Generator, you probably have seen the error message below.


You've got to love these "you-did-something-wrong-but-I-am-not-gonna-tell-you-how-to-fix-it" error messages. If you read through the datasheet, you will find it's not any better as it asks you to run Core Generator to get the valid values for the FFT transform length you chose. I've gone through this quite a few times, so I put together the table below showing valid values of "Number of Stages Using Block RAM" for all supported FFT sizes (data extracted from CoreGen 12.1) for me to use it as a quick reference. I hope this will also save other people a few minutes by not having to run CoreGen to get this simple info which should have been clearly stated in the error message.

FFT SizeNumber of Stages Using Block RAM
80
160
320
640-1
1280-2
2560-3
5120-4
10241-5
20482-6
40963-7
81924-8
163845-9
327686-10
655367-11

Sunday, July 4, 2010

FFT results from Matlab fft, Bit Accurate C model and SysGen FFT block

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.

Saturday, June 12, 2010

Calculate OFFSET OUT value

 Let's say on your PCB you have an FPGA that sends data to a DAC like the picture below:



It's clear that you need an OFFSET OUT constraint on the FPGA data output so that the setup and hold times are met on the DAC side. The question is how to calculate the OFFSET OUT value. The best way to figure it out is to draw all clock and data signals at different points on a piece of paper and write down all propagations delays. You can then do the calculation very easily. The picture below shows clock and data signals at the DAC and FPGA:


Now let's plug in all the delay numbers:

CLK_period = 1/64MHz = 15.625ns
CLK_DELAY_PCB is about 1ns (160mm PCB trace at 1ns/6 inches)
DATA_DELAY_PCB is about 1ns (160mm PCB trace at 1ns/6 inches)
SETUP_DAC = 5.3ns

=> FPGA DATA OFFSET OUT 
= CLK period - CLK_DELAY_PCB - DATA_DELAY_PCB - SETUP_DAC 
= 15.625 - 1 - 1 - 5.3
= 8.325 ns


Tuesday, June 1, 2010

Virtex6 and Spartan6 handbooks - OBSOLETE

Now that Xilinx Document Navigator is live, I am marking this blog as OBSOLETE. I highly recommend everybody give the Xilinx Document Navigator a try. You will love it.

I always found myself having dozens of Virtex6 and Spartan6 DS/UGs open to get the information I want, so I  merged individual PDFs into one document for each family to not only reduce the cluttering on my desktop but also make search a lot easier. The handbooks can be downloaded from the links below in case somebody else may find them useful:

Download
  • Virtex-6 "Handbook": combined V6 datasheets and user guides, which are the most up-to-date versions as of Aug 4, 2010.
  • Spartan-6 "Handbook": combined S6 datasheets and user guides, which are the most up-to-date versions as of Aug 4, 2010. 

V6 handbook contents:
Name
Version
Date
DS150: Virtex-6 Family Overview
2.2
Jan 29, 2010
UG362 Virtex-6 FPGA Clocking Resources User Guide
1.5
Aug 16, 2010
UG364 Virtex-6 FPGA Configurable Logic Block User Guide
1.1
Sep 16, 2009
UG363 Virtex-6 FPGA Memory Resources User Guide
1.5
Aug 3, 2010
UG361 Virtex-6 FPGA SelectIO Resources User Guide
1.3
Aug 16, 2010
UG369 Virtex-6 FPGA DSP48E1 Slice User Guide
1.2
Sep 16, 2009
UG370 Virtex-6 FPGA System Monitor User Guide
1.1
Jun 14, 2010
UG368 Virtex-6 FPGA Embedded Tri-Mode Ethernet MAC User Guide
1.2
Jan 17, 2010
UG366 Virtex-6 FPGA GTX Transceivers User Guide
2.4
Oct 1, 2010
UG371 Virtex-6 FPGA GTH Transceivers User Guide
2.1
Oct 4, 2010
UG373 Virtex-6 FPGA PCB Design Guide
1.2
Jun 10, 2010
UG360 Virtex-6 FPGA Configuration User Guide
3.2
Nov 1, 2010
DS152 Virtex-6 FPGA Data Sheet: DC and Switching Characteristics
2.10
Oct 18, 2010

S6 handbook contents:


Name
Version
Date
DS160: Spartan-6 Family Overview
1.5
Aug 2, 2010
UG382 Spartan-6 FPGA Clocking Resources User Guide
1.4
Aug 24, 2010
UG384 Spartan-6 FPGA Configurable Logic Block User Guide
1.1
Feb 23, 2010
UG383 Spartan-6 FPGA Block RAM Resources User Guide
1.3
Oct 13, 2010
UG381 Spartan-6 FPGA SelectIO Resources User Guide
1.3
Mar 15, 2010
UG389 Spartan-6 FPGA DSP48A1 Slice User Guide
1.1
Aug  13, 2009
UG388 Spartan-6 FPGA Memory Controller User Guide
2.3
Aug 9,2010
UG386 Spartan-6 FPGA GTP Transceivers User Guide
2.2
Apr 30, 2010
UG393 Spartan-6 FPGA PCB Design and Pin Planning Guide
1.2
Jul 15, 2010
UG394 Spartan-6 FPGA Power Management User Guide
1.0
May 18, 2010
UG380 Spartan-6 FPGA Configuration User Guide
2.2
Jul 30, 2010
DS162 Spartan-6 FPGA Data Sheet: DC and Switching Characteristics
1.9
Aug 23, 2010

Sunday, April 4, 2010

Cool Programs in My Toolbox

Over years I have installed many cool little programs on my machine. They become handy for so many different things. I had to rebuild my computer recently and took me a while to google the Internet to find all the goodies. It occurred to me that it would be handy if I build a list for all these programs and put it somewhere I can easily access. And here the list goes (I will add things as I go, so it will always be work-in-progress):