iCE40 is the first FPGA family with completely Free and Open source software tools thanks to Clifford Wolf who put incredible amount of time to create tool which compiles Verilog code to iCE40 bitstream by reverse engineering the output of the closed source Lattice tools.
As soon as we saw his presentation at FOSDEM we decided that we should make iCE40 FPGA board to use with his IceStorm tools.
Clifford built his tool to work with the Lattice stick, there they use FTDI chip to program the board, something we do not like at all🙂
What you will need to follow this tutorial:
- iCE40HX1K-EVB this is the core board with the FPGA, some buttons, LEDs, SRAM memory which will be very useful for the more advanced demos like VGA video generator, Oscilloscope with fast ADC etc which will follow
- OLIMEXINO-32U4 which will act as programmer instead of FTDI, instead this board you can use any Arduino or other board just have to wire the SPI signals to the iCE40HX1K-EVB programming connector, in this caseOLIMEXINO-32U4 UEXT connector is used and we connect it with 10 pin ribbon cable to iCE40HX1K-EVB
- CABLE-IDC10-15cm to connect between boards 1. and 2.
- USB-MINI-CABLE to connect OLIMEXINO-32U4 to your host computer where you will install Clifford’s IceStorm and will build your verilog code.
- SY0605E power supply 5V adapter for iCE40HX1K-EVB
- optional but highly recommended USB-ISO – after burning several USB ports on laptops and desktops while playing with development boards now I’m very careful and do not connect anything directly, its very easy to drop tweezers or wire or drop of solder on top of the development board while it’s connected to your computer and the result is USB damage and expensive repair.USB-ISO saves all these troubles and isolate your precious computer from problems with shorts, over voltages etc.
We will install IceStorm from sources so first we have to make sure we have all tools to build it:
sudo apt-get install build-essential clang bison flex libreadline-dev \ gawk tcl-dev libffi-dev git mercurial graphviz \ xdot pkg-config python python3 libftdi-dev
Installing the IceStorm Tools (icepack, icebox, iceprog, icetime, chip databases):
git clone https://github.com/cliffordwolf/icestorm.git icestorm cd icestorm make -j$(nproc) sudo make install
Installing Arachne-PNR (the place&route tool):
git clone https://github.com/cseed/arachne-pnr.git arachne-pnr cd arachne-pnr make -j$(nproc) sudo make install
Installing Yosys (Verilog synthesis):
git clone https://github.com/cliffordwolf/yosys.git yosys cd yosys make -j$(nproc) sudo make install
If everything completes with no errors – congratulations you successfully installed the IceStorm!
Preparing OLIMEXINO-32U4 as programmer
Now we have to prepare OLIMEXINO-32U4 as our FPGA programmer.
Download latest Arduino IDE . We recommend you to use the one from arduino.cc current revision is 1.6.9.
Copy iceprog.ino sketch from GitHub to examples folder.
Plug the USB cable to OLIMEXINO-32U4 and start the Arduino IDE
cd arduino-1.6.9 sudo ./arduino
From Tools menu select ‘Arduino Leonardo’ as board.
From the same menu select the PORT where the board is attached it will be something like: ‘/dev/ttyACM0 (Arduino Leonardo)’ or ‘/dev/ttyUSB0 (Arduino Leonardo)’
Open the iceprog.ino sketch.
From menu Sketch–Include library–Manage libraries check if you have SPI and SPIFlash libraries installed if not install them.
Compile and Upload the sketch.
Add support for OLIMEXINO-32U4 in IceStorm
Copy iceprogduino folder from GitHub to icestorm folder and build it
cd icestorm/iceprogduino make make install
Make your first program for FPGA – blink LED
Copy demo code from GitHub to icestorm/examples
cd icestorm/examples/ice40hx1k-evb make make prog
If everything finish with no error you will see LED1 and LED2 blinking on iCE40HX1K-EVB.
Congratulations! You made blinking LED on FPGA!
Now check what is the content of example.v , ice40hx1k-evb.pcf and Makefile and learn why the LEDs blink and what happen when you press together BUT1 and BUT2?
Next tutorial will be how to use iCE40HX1K-EVB with A20-OLinuXino-MICRO as both host for the IceStorm tool and programmer via UEXT connector with just cable and what additional options it gives like loading the code directly to FPGA whthout using SPI flash and your can change FPGA code in milliseconds.