Sipeed Tang Nano FPGA and Open Source toolchain

Sipeed makes a range of FPGA boards called Tang Nano, based around the Gowin’s GW1N range of FPGA chips. The current top model in the range is the Tang Nano 9k which supports 8640 LUT and can fit a RISC-V softcore such as PicoRV23 for around £12 + £5 shipping from China via AliExpress. You can spend a little more and get different sizes of LCD panels which connect to the board via a ribbon, I went for the 4.3″ panel which supports a resolution of 480×272. The board itself has an HDMI connector so that could be used instead.

The official vendor supplied toolchain is the Gowin IDE which is a closed source tool with an educational version that can be used for working with the Tang Nano series without having to apply for a license. Both Windows & Linux builds are offered for download but I was curios if I could avoid the IDE and just use a completely open source toolchain for working with the board, and I was pleasantly surprised to find that I could.

The toolchain consists of yosys (for synthesis), apicula (for generating the bitstream of Gowin FPGAs), nextpnr (for place and route), openFPGALoader (to program the board).

You can save yourself a lot of time compiling yosys and openFPGALoader by using the OSS CAD Suite which produces binaries of yosys, nextpnr, openFPGALoader alongside other tools for a range of operating systems and CPU architectures. Depending on your OS, you should be able to install apicula using pip but you will need to compile nextpnr-gowin yourself.

With yosys, apicula, nextpnr-gowin, openFPGALoader installed, the workflow for building and programming my board with the examples from the apicula source repository, like the blinky example, which flashes the 6 LEDs on the Tang Nano 9k board, goes something like this:

> yosys -D LEDS_NR=6 -p "read_verilog blinky.v; synth_gowin -json blinky.json"
> nextpnr-gowin --json blinky.json --write pnrblinky.json --device GW1NR-LV9QN88PC6/I5 --family GW1N-9C --cst tangnano9k.cst
> gowin_pack -d GW1N-9C -o pack.fs pnrblinky.json
> openFPGALoader -b tangnano9k pack.fs

This should cover steps for working with the Tang Nano 9k boards which is different to the other boards in the range with regards to flags passed to nextpnr and gowin_pak. The documentation for all of the components in the workflow do a good job of covering the build process and flags to use, so if you get stuck, they are worth reading.

ThinkPad X230 with terminal open showing first three commands listed above, executed, to prepare blinky example, waiting at the prompt to run openFPGALoader. There is a Sipeed Tang Nano 9k connected to an LCD panel sitting on the ThinkPad keyboard. Power is applied & the board loads its default program which cycles through its onboard LEDs whilst displaying a rainbow pattern. Enter is pressed on the keyboard to invoke openFPGALoader to flash another “blinky” program from the apicula source examples. The LCD turns white and the LEDs change the pattern they cycle through, having loaded the new program.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.