The repository contains a Verilog project specially designed for the Tang Nano 9K FPGA board. Its main objective is to provide automation for synthesizing, placing, and routing Verilog designs. This is achieved using a series of scripts that also facilitate the setup of the development environment and facilitate the FPGA programming process. The two primary scripts are build.sh, which oversees the entire synthesis to bitstream generation, and setenv.sh which handles the FPGA toolchain environment setup. An additional feature is the Docker integration, allowing the encapsulation of the development environment for easy replication and distribution.
- yosys - https://github.com/YosysHQ/yosys
- nextpnr-gowin - https://github.com/YosysHQ/nextpnr
- openFPGAloader - https://github.com/trabucayre/openFPGALoader
- Docker with root permissions - https://docs.docker.com/engine/install/linux-postinstall/
.
├── board
│ └── tangnano9k.cst # Constraints file for Tang Nano 9K
├── build.sh # Script for synthesis, placement, routing, and more
├── Docker
│ └── Dockerfile # Dockerfile to set up the development environment
├── setenv.sh # Script to set up the FPGA toolchain environment
└── src # Source folder the script looks for verilog files here
└── add.v # Sample Verilog source file
The build.sh script automates the following tasks:
- Checks if
yosysandnextpnr-gowinare available in PATH. - Defines constants used for synthesis and routing.
- Contains an option to build and run a Docker environment (
buildenvargument). - Houses logic to create necessary directories and clean them if needed (
cleanargument). - Includes logic to flash the bitstream to the FPGA board (
flashargument). - Finds and synthesizes all Verilog files in the
src/directory usingyosys. - Executes placement and routing using
nextpnr-gowin. - Packs the result into a bitstream suitable for the target FPGA.
The setenv.sh script sets up the FPGA toolchain environment:
- Clones repositories for
yosys,nextpnr, andopenFPGALoader. - Compiles and installs each tool.
- Cleans up by removing the cloned repositories.
Run the build.sh script to set up the docker development environment.
./build.sh buildenvThis script will install the yosys, nextpnr-gowin and openFPGAloader inside the docker.
Run the build.sh script without any arguments to trigger the entire flow from synthesis to bitstream generation:
./build.sh buildTo remove all generated files and directories, use:
./build.sh cleanAfter generating the bitstream, flash it to the FPGA board with:
./build.sh flash