Getting Started With an OSS toolchain for FPGA dev
Intro
For a very long time I've been wanting to get started learning and working with an FPGA. Price was one thing that put me off, but also the need to use proprietary tools and some times even Windows.
A few months ago I found this little gem, the Gnarly Grey UPDuino: it's a very small and inexpensive FPGA dev board that includes an FTDI chip to program. It also happens to work out of the box with the OSS project icestorm.
Here are the specs of this little board (available for ~$16 at the time of writing):
- Lattice Ultra Plus FPGA (iCE40 UltraPlus 5k)
- RGB LED
- FTDI chip for easy programming
- All I/O pins exposed
- 32M-bit (4M-Byte) SPI Flash
- Best of all: fully OSS design
The iCE40 is really powerful: it includes a DSP and SPI cores. I'll try to add examples on how to use them as I myself learn.
Setup dev toolchain
You need a few things to start working with the iCE40:
- Yosys (Verilog synthesis)
- Arachne-PNR (Place and route tool)
- IceStorm Tools (analyze and create bitstream files)
How to install them would depend on your distribution, for instance on Arch Linux, you can use the AUR packages icestorm-git, arachne-pnr-git and yosys-git.
FPGA Hello World
Once you have everything ready, it's time to run your Hello World. For this case, and keeping the assumption you're using the UPDuino, then we can use one of the examples included in the IceStorm project.
Get the sources
git clone https://github.com/cliffordwolf/icestorm.git
cd icestorm/examples/up5k_rgb
In the up5k_rgb
directory, you might need to edit the Makefile to
make sure you're programming the FPGA and not the flash memory:
diff --git a/examples/up5k_rgb/Makefile b/examples/up5k_rgb/Makefile index 51c1f72..25654de 100644 --- a/examples/up5k_rgb/Makefile +++ b/examples/up5k_rgb/Makefile @@ -23,7 +23,7 @@ all: $(PROJ).bin $(ICETIME) -d $(DEVICE) -mtr $@ $< prog: $(PROJ).bin - $(ICEPROG) -S $< + $(ICEPROG) $< sudo-prog: $(PROJ).bin @echo 'Executing prog as root!!!'
Build and program
With that small change, you're ready to plug in your UPDuino to your computer and then synthesize and program your FPGA:
sudo make prog
Your UPDuino should now start showing glowing RGB LED (changing from red -> green -> blue -> white).
Conclusion
That's it! now you're ready to start building interesting things and playing with the awesome field of programmable hardware :)
As for me, I'm still learning how to play with this. I'll try to make a new post when I'm able to read/write from the SPI Flash.