hansikaweerasena / ice40-Quickstart

This repository is dedicated to helping FPGA enthusiasts and beginners explore the capabilities of the iCE40 FPGA.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iCE40 Quickstart

This repository is dedicated to helping FPGA enthusiasts and beginners explore the capabilities of the iCE40 FPGA. It contains a collection of basic programs designed to get you started with digital design. Inside, you'll find:

  • Blinky: A simple LED blinking program to demonstrate basic FPGA outputs.
  • Knight Rider: An LED pattern inspired by the famous moving light sequence, showcasing more complex LED control.
  • UART Communication: A module for sending and receiving messages using UART protocol, interfaced through Python, to demonstrate basic serial communication.

Each program comes with comprehensive documentation, including step-by-step guides on how to set up your development environment, compile the code, and deploy it to an iCE40 FPGA board. Whether you're a student, a hobbyist, or just curious about FPGAs, this repository has the necessary tools to get you started.

This repository will use Alchitry Cu FPGA with Lattice iCE40 FPGA which can use open-source toolchain that includes Yosys, Nextpnr, and IceStorm tools.

Following is the steps you need to build and run any RTL on Alchitry Cu using the toolchain. There is a docker container with th toolchain installed by Archfx that can be used if you're familiar with docker. Following are the steps you need to move forward with this quickstart.

  1. Clone this repository

git clone https://github.com/hansikaweerasena/ice40-Quickstart

  1. Pull the docker image from docker hub

docker pull archfx/ice40tools

  1. Run the docker image

docker run -t -p 6080:6080 -v "${PWD}/:/ice40-Quickstart" -w /ice40-Quickstart --name ice40tools archfx/ice40tools

  1. Get in to interactive shell inside docker

docker exec -it ice40tools /bin/bash

  1. Compile the design using following command
# Change to the appropriate directory
cd ice40-Quickstart/examples/blinky

# Synthesize the Verilog source into a JSON representation
yosys -p 'synth_ice40 -top blinky -json blinky.json' blinky.v

# Run placement and routing
nextpnr-ice40 --hx8k --json blinky.json --pcf blinky.pcf --asc blinky.asc --package cb132

# Generate the binary bitstream file
icepack blinky.asc blinky.bin 
  1. You need to download the alchitry loader if you're using Alchitry Cu chip from here to load .bin files directly to your board.

  2. Now enjoy

Important considerations

  • Pin Constraint Files (.pcf):

    • The Alchitry Cu board includes specific pin constraint files (.pcf) for each example, essential for mapping the design's input/output signals to the physical pins of the FPGA. When using a different board equipped with an iCE40 FPGA, these files must be updated to reflect the pin configurations of the new board.
  • FPGA Specification in Tool Commands:

    • The Alchitry Cu utilizes the ICE40HX8K-CB132IC FPGA, where HX8K indicates the family and capacity, and CB132 specifies the package type and pin count. If you are using a different iCE40 FPGA board, adjust the parameters (--hx8k and --package cb132) in place and route tools like Nextpnr to match the new board's FPGA specifications.

About

This repository is dedicated to helping FPGA enthusiasts and beginners explore the capabilities of the iCE40 FPGA.