Installation
The following applications are required:
- yosys
- nextpnr-himbaechel
- gowin_pack
- openFPGALoader
yosys and openfpgaloader
Install both yosys and openfpgaloader via apt.
apt install yosys openfpgaloader
https://github.com/yosyshq/yosys#setup
gowin_pack
Install via pip
pip install apycula
https://github.com/YosysHQ/apicula
It could be that the error “error: externally-managed-environment” occurs. This can be solved by adding the flag –break-system-packages to the install command.
nextpnr-himbaechel
This one is a bit more tricky as it needs to be compiled. For dependencies please see git repository: https://github.com/YosysHQ/nextpnr?tab=readme-ov-file#prerequisites.
git clone https://github.com/YosysHQ/nextpnr
cmake . -DARCH="himbaechel" -DHIMBAECHEL_GOWIN_DEVICES="all"
make -j$(nproc)
sudo make install
Usage
Now lets use the system we just installed. The code needed for this can be found in my git repository: https://github.com/douwedevries/tangnano20k. This includes sythesize.sh, tangnano20k.cst and topentity.v. They are all the files that are required.
sythesize.sh
This script first sets some variables to let the tools know we are working with a Tang Nano 20k. Next it goes though the tool chain. Each step should be confirmed with an enter. This allows you to read error messages. ctrl+c can be used to escape the script.
blink.v
This file contains a simple verilog description that allow the leds to count when a button is pressed.
tangnano20k.cst
This file connects object name to object location. Or simply said, the verilog name to the actual hardware pin. Sipeed provides a file called Tang_Nano_20K_3921_Schematics.pdf in which the hardware is described. From you can create your custom CST file. The file in my repository only contains the system clock, leds and keys.