Getting started with tinyFPGA Bx

TinyFPGA BX Board DEV-14829 Sparkfun Australia - Express Delivery Australia Wide (Feature image)

A comparison of the various tinyFPGA boards is given here.

Installing APIO, a python-based toolbox

(using a Windows 10 here)

Open source ecosystem for open FPGA boards

Apio is a multiplatform toolbox, with static pre-built packages, project configuration tools and easy command interface to verify, synthesize, simulate and upload your verilog designs.

Documentation on apio is here https://apiodoc.readthedocs.io/en/stable/ Have a looks at the Quick Start section.

In your project folder, create a new project for the tinyFPGA and then create and activate a python virtual environment for the toolbox.

pip install apio tinyprog
apio install system scons icestorm iverilog
apio drivers --serial-enable

Note: you can also run the following instead of listing individual packages (also brings in examples and simulator packages):

 apio install --all

Now plug in your board and update the bootloader:

tinyprog --update-bootloader

Output of tinyprog –update-bootloader

Building and Uploading with APIO

At this point you can choose to install a IDE that utilizes the APIO toolbox, or you can just choose to use the command line interface of APIO, for example look here.

Bootloader Behavior

The following tip from https://tinyfpga.com/bx/guide.html is worth noting:

The bootloader behaves differently depending on what is connected to the USB port:

If the board is connected to a USB host, the bootloader will stay active. It will wait to be programmed by tinyprog. You can manually exit the bootloader and load the user image from the onboard SPI flash by running tinyprog -b.

If the board is connected to a dumb power supply, the bootloader will timeout after one second and load the existing user image from the onboard SPI flash.

Pressing the reset button will always return the board to the bootloader, but it will only stay in the bootloader if its plugged into a USB host.

Atom Development Environment

Install Atom with apio-ide package, following here.

Launch Atom from the command shell of the virtual environment created earlier.

ATOM + apio-ide interface

A small extension

In the example we are driving the on board LED. Now lets extend the design to drive an external LED.

I decided to use pin 13, add a resistor and led to ground on and connect the ground from the tinyFPGA.

Go to the pins.pcf and change the line for pin 13 to:

set_io --warn-no-port LED13 H2

in the module add the extra output: output LED13,

and then add the following assign: assign LED13 = LED;

upload the design and you should see the external and the on board led flash in unison.

external LED

Adding an input signal works similarly,

  • add input SW14,
  • add set_io --warn-no-port SW14 H9
  • change to: assign LED13 = LED | SW14;

now LED13 will be on if LED or SW14 is HIGH.

Wrapping Up

We have updated our bootloader and we have installed and tested our development environment for the tinyFPGA board. The on-board led should be blinking with the SOS pattern.

Next we will look into simulation and associated test benches for our FPGA Verilog designed devices. This will help us understand our designs better and accelerate our development.

One thought on “Getting started with tinyFPGA Bx

Leave a comment