Skip to content

Platformio FPGA wiki home

Jesús Arroyo Torrens edited this page Oct 27, 2016 · 62 revisions

DEPRECATED

FPGAs support in PlatformIO continues in this repository:

Introduction

The goal is to add FPGAs to the PlatformIO opensource ecosystem

This is a working repo for testing and developing building scripts, boards and platforms definition. When they are ready, they will be pull-requested to the PlatformIO main project

ANY HELP IS WELCOME :-)

Installation

One goal of this project is to integrate the FPGAs opensource development toolchains and boards into platformio so that it will be very easy to install them in the future. According to the roadmap, the support will be integrated in platformio 2.9.0

But... in the meantime, here are the instructions for installing in earlier versions of platformio

Step 1: Install APIO

Follow the instructions of the Apio github project

Apio is a tool for easily installing and testing the fpga tools while they are integrated into platformio. The fpga integration in platformio is taken longer than expected due to the long delay responses to our issues and pull request. So, in the meanwhile, we have developed apio

Step 2: Install Platformio

Follow the instructions of the Platformio main site

Step 3: Install the platform lattice_ice40

This apio command install the necessary files for giving support to FPGAs in platformio:

$ apio install pio-fpga

Now execute this platformio command for completing the installation

$ pio platforms install lattice_ice40

When this commands is executed, the package toolchain-icestorm is downloaded and installed

Now everything is ready for working with the Lattice ICE40 FPGAs!!

Checking FPGA boards in platformio

  • The new installed icestick board can be checked by running this command:
$ pio boards icestick

  • The lattice_ice40 platform can be checked with this:
$ pio platforms search fpga

Testing the examples

Example 1: Hello world: leds

  • Enter into the examples/lattice_ice40/lattice_ic40_leds folder:
$ cd examples/lattice_ice40/lattice_ice40_leds/
  • Build the example:
$ pio run

  • Upload the bitstream into the icestick:
$ pio run --target upload

  • All the leds are now on:

Example 2: Counter

  • Enter into the directory examples/lattice_ice40/lattice_ice40_counter
$ cd examples/lattice_ice40/lattice_ice40_counter
  • Upload the bitstream directly:
$ pio run --target upload

It will build the project and then upload into the icestick board After some seconds you should see the 5-bits counter on the icestick leds

  • Install simulation tools: gtkwave, iverilog:
$ sudo apt-get install gtkwave iverilog

NOTE: on mac

$ brew install /homebrew/gui/gtkwave icarus-verilog
  • Simulate the counter:
$ pio run --target sim

The gtkwave window will be open showing counter signals:

Creating an example from scratch

Let's create our first hello world fpga project

  • Create a directory named hello_world_fpga and cd into it:
$ mkdir hello_world_fpga
$ cd hello_world_fpga
  • Create a new project for the Icestick board:
$ pio init --board icestick

The folder libs and src are created, as well as the platformio.ini file

  • Enter into the src folder and create the hello world verilog program (leds.v):

File src/leds.v:

//-- File: src/led.v
module leds(output wire D1,
            output wire D2,
            output wire D3,
            output wire D4,
            output wire D5);

//-- icestick Red leds
assign D1 = 1'b1;
assign D2 = 1'b1;
assign D3 = 1'b1;
assign D4 = 1'b1;

//-- Green led
assign D5 = 1;

endmodule
  • Add the leds.pcf file in the src directory:
set_io D1 99
set_io D2 98
set_io D3 97
set_io D4 96
set_io D5 95

This file associate each port name with an FPGA pin. Pins from 95 to 99 correspond to leds in the icestick board

The src folder should contain only these two files: leds.v and leds.pcf

  • Move up to the hello_world_fpga directory:
cd ..
  • Let's synthesize our design and generate the bitstream

Execute the command:

$ pio run

The initial messages generated are:

and this is the terminal once the process has finished:

  • Finally, let's upload the bitstream into the FPGA:
$ pio run --target upload

Notes on development

For developers: Notes on development

Authors

  • Juan González (Obijuan)
  • Jesús Arroyo

License

Licensed under the permissive Apache 2.0 licence, the same than platformio

Links