You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
David Shah befc994806
Merge pull request #358 from YosysHQ/generic-improve
8 months ago
.cirrus ci: Update Yosys version 1 year ago
3rdparty Add GUI for executing python file 1 year ago
bba bba: Require explicit endianness flag, and supply it 11 months ago
common HeAP: more realistic timeout threshold 8 months ago
docs Update generic arch docs 8 months ago
ecp5 Merge pull request #356 from YosysHQ/ecp5-ff-density 8 months ago
generic generic: Add support for post-PnR simulation 8 months ago
gui Major Property improvements for common and iCE40 1 year ago
ice40 ice40: Make HeAP the default placer 8 months ago
json jsonwrite: Fix bus cell ports 8 months ago
python Fix typo 9 months ago
tests @ 8f93e7e0f8 Bump tests submodule 11 months ago
.cirrus.yml ci: Run generic post-PnR sim smoketest 8 months ago
.clang-format Set clangformat column limit to 120 2 years ago
.gitignore return FF_USED, formatting, correct INIT 9 months ago
.gitmodules [tests] Move existing tests/* into submodule nextpnr-tests 1 year ago
CMakeLists.txt cmake: Add boost system library 9 months ago
COPYING Add COPYING file 2 years ago
CodeCoverage.cmake Added test code coverage report 2 years ago General documentation updates 8 months ago

nextpnr -- a portable FPGA place and route tool

nextpnr aims to be a vendor neutral, timing driven, FOSS FPGA place and route tool.

Currently nextpnr supports:

  • Lattice iCE40 devices supported by Project IceStorm
  • Lattice ECP5 devices supported by Project Trellis
  • (experimental) a “generic” back-end for user-defined architectures

There is some work in progress towards support for Xilinx devices but it is not upstream and not intended for end users at the present time. We hope to see more FPGA families supported in the future. We would love your help in developing this awesome new project!

A brief (academic) paper describing the Yosys+nextpnr flow can be found on arXiv.

Here is a screenshot of nextpnr for iCE40. Build instructions and getting started notes can be found below.

See also:


The following packages need to be installed for building nextpnr, independent of the selected architecture:

  • CMake 3.3 or later
  • Modern C++11 compiler (clang-format required for development)
  • Qt5 or later (qt5-default for Ubuntu 16.04)
  • Python 3.5 or later, including development libraries (python3-dev for Ubuntu)
    • on Windows make sure to install same version as supported by vcpkg
  • Boost libraries (libboost-dev libboost-filesystem-dev libboost-thread-dev libboost-program-options-dev libboost-python-dev libboost-dev or libboost-all-dev for Ubuntu)
  • Eigen3 (libeigen3-dev for Ubuntu) is required to build the analytic placer
  • Latest git Yosys is required to synthesise the demo design
  • For building on Windows with MSVC, usage of vcpkg is advised for dependency installation.
    • For 32 bit builds: vcpkg install boost-filesystem boost-program-options boost-thread boost-python qt5-base eigen3
    • For 64 bit builds: vcpkg install boost-filesystem:x64-windows boost-program-options:x64-windows boost-thread:x64-windows boost-python:x64-windows qt5-base:x64-windows eigen3:x64-windows
    • For static builds, add -static to each of the package names. For example, change eigen3:x64-windows to eigen3:x64-windows-static
    • A copy of Python that matches the version in vcpkg (currently Python 3.6.4). You can download the Embeddable Zip File and extract it. You may need to extract within the embeddable zip file to a new directory called “Lib”.
  • For building on macOS, brew utility is needed.
    • Install all needed packages brew install cmake python boost boost-python3 qt5 eigen
    • Do not forget to add qt5 in path as well echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.bash_profile

Getting started


To build the iCE40 version of nextpnr, install icestorm with chipdbs installed in /usr/local/share/icebox, or another location, which should be passed as -DICEBOX_ROOT=/path/to/share/icebox (ensure to point it to share/icebox and not where the icebox binaries are installed) to CMake. Then build and install nextpnr-ice40 using the following commands:

cmake -DARCH=ice40 .
make -j$(nproc)
sudo make install

On Windows, you may specify paths explicitly:

cmake -DARCH=ice40 -DICEBOX_ROOT=C:/ProgramData/icestorm/share/icebox -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -G "Visual Studio 15 2017 Win64" -DPYTHON_EXECUTABLE=C:/Python364/python.exe -DPYTHON_LIBRARY=C:/vcpkg/packages/python3_x64-windows/lib/python36.lib -DPYTHON_INCLUDE_DIR=C:/vcpkg/packages/python3_x64-windows/include/python3.6
cmake --build . --config Release

To build a static release, change the target triplet from x64-windows to x64-windows-static and add -DBUILD_STATIC=ON.

A simple example that runs on the iCEstick dev board can be found in ice40/examples/blinky/blinky.*. Usage example:

cd ice40/examples/blinky
yosys -p 'synth_ice40 -top blinky -json blinky.json' blinky.v               # synthesize into blinky.json
nextpnr-ice40 --hx1k --json blinky.json --pcf blinky.pcf --asc blinky.asc   # run place and route
icepack blinky.asc blinky.bin                                               # generate binary bitstream file
iceprog blinky.bin                                                          # upload design to iCEstick

Running nextpnr in GUI mode:

nextpnr-ice40 --json blinky.json --pcf blinky.pcf --asc blinky.asc --gui

(Use the toolbar buttons or the Python command console to perform actions such as pack, place, route, and write output files.)


For ECP5 support, you must download Project Trellis, then follow its instructions to download the latest database and build libtrellis.

cmake -DARCH=ecp5 -DTRELLIS_ROOT=/path/to/prjtrellis .
make -j$(nproc)
sudo make install


The generic target allows running placement and routing for arbitrary custom architectures.

cmake -DARCH=generic .
make -j$(nproc)
sudo make install

An example of how to use the generic flow is in generic/examples. See also the Generic Architecture docs.

Additional notes for building nextpnr

Use cmake -D options to specify which version of nextpnr you want to build.

Use -DARCH=... to set the architecture. It is a semicolon separated list. Use cmake . -DARCH=all to build all supported architectures.

The following runs a debug build of the iCE40 architecture without GUI, without Python support, without the HeAP analytic placer and only HX1K support:

make -j$(nproc)

To make static build relase for iCE40 architecture use the following:

make -j$(nproc)

The HeAP placer’s solver can optionally use OpenMP for a speedup on very large designs. Enable this by passing -DUSE_OPENMP=yes to cmake (compiler support may vary).

You can change the location where nextpnr will be installed (this will usually default to /usr/local) by using -DCMAKE_INSTALL_PREFIX=/install/prefix.

It is possible to pre-generate .bba files. This can come in handy when building on time-constrained cloud instances, or in situations where python is unable to use modules. To do this, specify the path to pre- generated .bba files by passing -DPREGENERATED_BBA_PATH= to cmake.

Notes for developers

  • All code is formatted using clang-format according to the style rules in .clang-format (LLVM based with increased indent widths and brace wraps after classes).
  • To automatically format all source code, run make clangformat.
  • See the wiki for additional documentation on the architecture API.


  • To build test binaries as well, use -DBUILD_TESTS=ON and after make run make tests to run them, or you can run separate binaries.
  • To use code sanitizers use the cmake options:
  • Running valgrind example valgrind --leak-check=yes --tool=memcheck ./nextpnr-ice40 --json ice40/blinky.json
  • Running tests with code coverage use -DBUILD_TESTS=ON -DCOVERAGE and after make run make ice40-coverage
  • After that open ice40-coverage/index.html in your browser to view the coverage report
  • Note that lcov is needed in order to generate reports

Synthesis, simulation, and logic optimization

FPGA bitstream documentation (and tools) projects

Other FOSS FPGA place and route projects