Saturday, June 17, 2017

Welcome to FPGA land

Welcome to FPGA land.. where the processing is faster, the resources more basic, and the number of three or four letter acronyms is huge. FPGA's (Field Programmable Gate Arrays) always fascinated me, but I never had the chance to work with them. Since they are a more application specific and harder to use than microcontrollers it has taken a little longer before they appeared in the hobby-space. Nowadays there are several development board available. Joel Williams did a really nice list of boards on his blog, so I don't have to repeat that. Still, a lot of the boards are $100,- and more, which still is a significant amount of money. Then I bumped into the Numato Labs 'Elbert V2 -Spartan 3A Development board' at only $29,95, which seems like a nice 'lets have go' price.
Getting it connected to my PC was easy. Just plug in the USB cable, and the board immediately starts running it's demo. Windows automatically recognizes and installs it as a USB comport. To use the board you should install the Numato Lab USB CDC Driver, which is available on their website. After downloading and unpacking the driver, just find the USB serial port in Windows Device Manager, right click and select 'Update driver'. Use the 'Browse my computer for drivers' option to point it at the driver you just downloaded and install. The port will now show up with the board name:

Software

This appeared to be the hard part. There is basically just one option to program the Spartan-3 and that is the Xilinx ISE Design Suite. It is free, but it has not been maintained since 2014, so Windows 10 is not officially supported. It's also HUGE. It's nearly 7GB download, and takes up exactly 20GB of disk space after installation. So be prepared to spend at least a day to get everything up and running.
First get the Xilinx WebPack at:
https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/design-tools.html
I downloaded the 'All platforms' suite, which comes in 4 separate parts:
But further down the page there are also complete installers for either Windows or Linux.
All together this is 7 GB download, so you'll need some patience here.
If you downloaded the four parts as shown above, unzip only the first one (the one that ends in .zip, all the others have an extra .zx extension). This will create the file 'xsetup.exe'. Just click this to start the setup process. Which also takes at least an hour, so again: be patient.
After installation you will have to run the 'settings64.bat' file to setup the environment variables, which is in C:\Xilinx\14.7\ISE_DS.
Then click the ISE Design icon on your desktop to start the program..or not. On my machine it started, but crashed with the message: '_pn.exe stopped working'. The Xilinx forum came up with the following solution:


For everyone trying to use Xilinx ISE 14.5 in Windows 8 x64.
Rename libPortability.dll to libPortability.dll.orig, and copy libPortabilityNOSH.dll to libPortability.dll.

Do this in:

C:\Xilinx\14.5\ISE_DS\ISE\lib\nt64
C:\Xilinx\14.5\ISE_DS\common\lib\nt64 (copy dll from first location)

 This turns off SmartHeap.


OK. So we'll have to do without the SmartHeap, whatever that is. But now the program indeed starts fine, also on my Windows 10 machine.
Next step is to acquire a license. The software points you at the right page on the Xilinx website, where you'll have to register again, select the required license and have this key mailed to you. This can be imported into the software, and finally we can start doing some real work...
  

Programming

A FPGA is programmed using a HDL (Hardware Description Language). There are two common flavours right now: Verilog and VHDL. I chose VHDL, mainly because I a colleague lent me a book named 'FPGA Protototyping By VHDL Examples Xilinx Spartan-3 Version ' by Pong P.Chu. (there is a Verilog version too, so it does not really matter).
Now this is a really expensive book, but there are also plenty of online resources. However, they may not all be specific to the Spartan-3. The FPGA centre for example has a nice VHDL Starter Guide.