This repository stores the needed files to get started with the iCE40 line of FPGAs from Lattice.
There are two approaches for build tools: official tools for Lattice or open-source tools. This document uses the official tools on a Windows PC.
- Download and install
Lattice iCEcube2IDE from website. You'll need to make an account. - Get a license for the dev tools. You will need to email Lattice to request the free license. This may take a few days.
- Use the
LicenseSetup.exetool to add the license to your system. - Download the
Lattice Diamond Programmerand install it. Go here and scroll down toProgrammer Standalone 3.14 64-bit for Windowsand install.
Make sure you have the iCEstick hardware development board! This is available across the internet for around $30-40.
- Download this repo to your PC.
- Open iCEcube2 IDE
- Create a new project targetting the FPGA device on the iCEstick hardware:
- Set project name:
test1 - Set the directory to this repo
- Set device family:
iCE40 - Set device:
HX1K - Set device package:
TQ144 - Ensure junction temp range is
Commercial - Ensure core voltage torerance is +/-5% at 1.2V
- Set all I/O bank voltages to 3.3
- Ensure timing analysis is based on
Worstvalues - Ensure
Start from Synthesisis selected
- Set project name:
- Add the following files to the project:
top.v,sys.v,pll.vconstraints.sdcpins.pcf
- In iCEcube2, click
Tool>Run All
This kicks off the tool chain to generate the bitmap. It will synthesize and place & route the design. Upon success of each step, a green check mark should appear in the left window pane. Once Generate Bitmap has a green check mark, the process is done. It should take <10 seconds.
Note that the compilation process generates A LOT of information! This info is useful for many reasons, such as determining if the design meets timing requirements and seeing FPGA device resource utilization.
You may now close iCEcube2 IDE, we no longer need it.
We now have the required bitmap to program into the flash of the iCEstick hardware.
- Plug in the iCEstick to your PC
- Open
Diamond Programmer - Click
Detect Cableand select your device - Select
Create a new blank projectand clickOK - Under
Device Familycolumn, changeGeneric JTAG DevicetoiCE40 - Under
Devicecolumn, change toiCE40HX1K - Double-click on
Fast Programin theOperationcolumn to configure:- Change access mode to
SPI Flash Programming - Select the bitmap
.binfile generated from iCEcube2 (usually located at$REPO_ROOT/test1/test1_Implmnt/sbt/outputs/bitmap/top_bitmap.bin) - Set SPI Flash Family:
SPI Serial Flash - Set SPI Flash Vendor:
Micron - Set SPI Flash Device:
N25Q032 - Set SPI Flash Package:
8-pin VDFPN8 - Click
Load from File OK
- Change access mode to
- Click
Design>Program
This will send the bitmap binary contents over USB to the iCEstick and store them in the SPI flash device.
Congratulations! Your FPGA should be running and the LEDs should be blinking!
The template files configure the FPGA PLL to accept the 12MHz clock input CLK_IN from the oscillator on the PCB and derive a 120MHz clock clk which is used for the rest of the digital logic. They also provide a global, asynchronous, active-low reset signal rst_n which can be used to set initial values for registers.
You can adjust the PLL settings to use a different system clock frequency by editing pll.v. To generate the correct PLL settings, use the iCEcube2 PLL configuration tool: Tool > Configure ... > Configure PLL Module .... This wizard can be used to generate the right DIV* constants for various frequencies.