Skip to main content

Project Apicula

Open source tools and Documentation for the Gowin FPGA bitstream format.

Project Apicula uses a combination of fuzzing and parsing of the vendor data files to provide Python tools for generating bitstreams.

Getting Started

Install the latest git yosys, nextpnr-himbaechel, openFPGALoader, and Python 3.9 or higher. Yowasp versions of Yosys and Nextpnr are also supported.

Currently supported boards are

  • Trenz TEC0117: GW1NR-UV9QN881C6/I5
  • Sipeed Tang Nano: GW1N-LV1QN48C6/I5
  • Sipeed Tang Nano 1K: GW1NZ-LV1QN48C6/I5
  • Sipeed Tang Nano 4K: GW1NSR-LV4CQN48PC7/I6
  • Sipeed Tang Nano 9K: GW1NR-LV9QN88PC6/I5 1
  • Sipeed Tang Nano 20K: GW2AR-LV18QN88C8/I7 1
  • Sipeed Tang Primer 20K: GW2A-LV18PG256C8/I7 1
  • Seeed RUNBER: GW1N-UV4LQ144C6/I5
  • szfpga: GW1NR-LV9LQ144PC6/I5

Install the tools with pip.

pip install apycula

On platforms where the default C extension dependencies are not available, you can use pure Python alternatives instead:

pip install --no-deps apycula msgpack cattrs

Note that on some systems the installed binaries might not be on the path. Either add the binaries to the path, or use the path of the installed binary directly. (running the source files will lead to import errors)

which gowin_pack # check if binaries are on the path
python -m site --user-base # find the site packages base directory
ls $HOME/.local/bin # confirm the binaries are installed in this folder
export PATH="$HOME/.local/bin:$PATH" # add binaries to the path

From there, compile a blinky.

The example below is for the Trenz TEC0117. For other devices, use the model numbers listed above for --device, and replace tec0117 with runber, tangnano, tangnano4k or tangnano9k accordingly. Also note the number of LEDs on your board: 8 for tec0117 and runber, 3 for honeycomb and tangnano. You can also use the Makefile in the examples folder to build the examples.

cd examples
yosys -D LEDS_NR=8 -p "read_verilog blinky.v; synth_gowin -json blinky.json"
DEVICE='GW1NR-UV9QN881C6/I5'  # change to your device
BOARD='tec0117' # change to your board
nextpnr-himbaechel --json blinky.json \
                   --write pnrblinky.json \
                   --device $DEVICE \
                   --vopt cst=$BOARD.cst
gowin_pack -d $DEVICE -o pack.fs pnrblinky.json # chango to your device
# gowin_unpack -d $DEVICE -o unpack.v pack.fs
# yosys -p "read_verilog -lib +/gowin/cells_sim.v; clean -purge; show" unpack.v
openFPGALoader -b $BOARD pack.fs

For the Tangnano9k board, you need to call nextpnr and gowin_pack with the chip family as follows:

nextpnr-himbaechel --json blinky.json \
                   --write pnrblinky.json \
                   --device $DEVICE \
                   --vopt family=GW1N-9C \
                   --vopt cst=$BOARD.cst
gowin_pack -d GW1N-9C -o pack.fs pnrblinky.json

For the Tangnano20k (TangPrimer20k) board, you need to call yosys with the chip family as follows:

yosys -D LEDS_NR=8 -p "read_verilog blinky.v; synth_gowin -json blinky.json -family gw2a"

Getting started for contributors

In addition to the above, to run the fuzzers and build the ChipDB, the following additional dependencies are needed.

Version 1.9.10.03 of the Gowin vendor tools. Newer versions may work, but have not been tested.

Alternatively, you can use the Dockerfile to run the fuzzers in a container.

To run the fuzzers, do the following in a checkout of this repo

pip install -e .
export GOWINHOME=/gowin/installation
make

Resources

Check out the doc folder for documentation about the FPGA architecture, vendor file structure, and bitstream structure.

My internship report about this project can be downloaded here.

My presentations at FPT2020 and RC3.

I did a few livestreams on twitch working on this project, which are collected on this playlist I've also started to write Jupyter notebooks of my explorations that are more condensed than a video.

You can also come chat on Matrix or IRC

Funding

This project was funded through the NGI0 PET and NGI Zero Entrust Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 825310 and 101069594.

  1. C devices require passing the --vopt family flag as well as --device to Nextpnr, and stating the family in place of device when passing -d to gowin_pack because the C isn't part of the device ID but only present in the date code. Check examples/Makefile for the correct command. 2 3

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apycula-0.33.tar.gz (20.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apycula-0.33-py3-none-any.whl (4.1 MB view details)

Uploaded Python 3

File details

Details for the file apycula-0.33.tar.gz.

File metadata

  • Download URL: apycula-0.33.tar.gz
  • Upload date:
  • Size: 20.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for apycula-0.33.tar.gz
Algorithm Hash digest
SHA256 9e356f5abf2c1f65000440f1bd34835c1b9381a64d2077e9870887075e086e16
MD5 3469cf55e55887357e9427e2ab14900f
BLAKE2b-256 8fcd834c8ce2eb981f45e5466b4747b3eb703af0fcb2040470a8d8d18558aad2

See more details on using hashes here.

File details

Details for the file apycula-0.33-py3-none-any.whl.

File metadata

  • Download URL: apycula-0.33-py3-none-any.whl
  • Upload date:
  • Size: 4.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for apycula-0.33-py3-none-any.whl
Algorithm Hash digest
SHA256 8c78b766da07fc9290d4e096fe64f143d67926434cb2d361405d7cd49f578286
MD5 685c59e5c7ca8833531e8a117652ed1e
BLAKE2b-256 0f044614442e8be95e79df75f06c3b2670cc4764749ec4d3d2d3de5b54ef93e7

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.33 This release

2 files

0.32

2 files

0.31

2 files

0.30

2 files

0.29

2 files

0.28

2 files

0.27

2 files

0.26

2 files

0.25

2 files

0.24

2 files

0.23

2 files

0.22

2 files

0.21

2 files

0.20

2 files

0.19

2 files

0.18

2 files

0.17

2 files

0.16

2 files

0.15

2 files

0.14

2 files

0.13

2 files

0.12

2 files

0.11.1

2 files

0.10.0

2 files

0.9.1

2 files

0.9.0

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

2 files

0.8

2 files

0.7

2 files

0.6.2

2 files

0.6.1

2 files

0.6

2 files

0.5.1

2 files

0.5

2 files

0.4

2 files

0.3.1

2 files

0.3

2 files

0.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page