• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.cirrus/H04-Sep-2020-6253

3rdparty/H04-Sep-2020-293,501202,518

bba/H03-May-2022-541445

common/H04-Sep-2020-13,26810,511

docs/H04-Sep-2020-1,170716

ecp5/H03-May-2022-20,74218,781

frontend/H04-Sep-2020-987672

generic/H07-May-2022-2,3211,707

gui/H03-May-2022-6,3074,503

ice40/H03-May-2022-19,42016,049

json/H04-Sep-2020-266200

python/H04-Sep-2020-5035

tests/H03-Sep-2019-11,52510,227

.cirrus.ymlH A D04-Sep-20201,000 1816

.clang-formatH A D04-Sep-20202.5 KiB8887

.gitignoreH A D04-Sep-2020433 3635

.gitmodulesH A D04-Sep-202082 43

COPYINGH A D04-Sep-20201 KiB1916

CodeCoverage.cmakeH A D04-Sep-202011.6 KiB304263

README.mdH A D04-Sep-202010 KiB230164

README.md

1nextpnr -- a portable FPGA place and route tool
2===============================================
3
4nextpnr aims to be a vendor neutral, timing driven, FOSS FPGA place and route
5tool.
6
7Currently nextpnr supports:
8 * Lattice iCE40 devices supported by [Project IceStorm](http://www.clifford.at/icestorm/)
9 * Lattice ECP5 devices supported by [Project Trellis](https://github.com/YosysHQ/prjtrellis)
10 * *(experimental)* a "generic" back-end for user-defined architectures
11
12There is some work in progress towards [support for Xilinx devices](https://github.com/daveshah1/nextpnr-xilinx/) 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!
13
14A brief (academic) paper describing the Yosys+nextpnr flow can be found
15on [arXiv](https://arxiv.org/abs/1903.10407).
16
17Here is a screenshot of nextpnr for iCE40. Build instructions and
18[getting started notes](#getting-started) can be found below.
19
20<img src="https://i.imgur.com/0spmlBa.png" width="640"/>
21
22See also:
23- [F.A.Q.](docs/faq.md)
24- [Architecture API](docs/archapi.md)
25
26
27Prerequisites
28-------------
29
30The following packages need to be installed for building nextpnr, independent
31of the selected architecture:
32
33- CMake 3.3 or later
34- Modern C++11 compiler (`clang-format` required for development)
35- Qt5 or later (`qt5-default` for Ubuntu 16.04)
36- Python 3.5 or later, including development libraries (`python3-dev` for Ubuntu)
37  - on Windows make sure to install same version as supported by [vcpkg](https://github.com/Microsoft/vcpkg/blob/master/ports/python3/CONTROL)
38- Boost libraries (`libboost-dev libboost-filesystem-dev libboost-thread-dev libboost-program-options-dev libboost-python-dev libboost-iostreams-dev libboost-dev` or `libboost-all-dev` for Ubuntu)
39- Eigen3 (`libeigen3-dev` for Ubuntu) is required to build the analytic placer
40- Latest git Yosys is required to synthesise the demo design
41- For building on Windows with MSVC, usage of vcpkg is advised for dependency installation.
42  - For 32 bit builds: `vcpkg install boost-filesystem boost-program-options boost-thread boost-python qt5-base eigen3`
43  - 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`
44  - For static builds, add `-static` to each of the package names.  For example, change `eigen3:x64-windows` to `eigen3:x64-windows-static`
45  - A copy of Python that matches the version in vcpkg (currently Python 3.6.4).  You can download the [Embeddable Zip File](https://www.python.org/downloads/release/python-364/) and extract it.  You may need to extract `python36.zip` within the embeddable zip file to a new directory called "Lib".
46- For building on macOS, brew utility is needed.
47  - Install all needed packages `brew install cmake python boost boost-python3 qt5 eigen`
48  - Do not forget to add qt5 in path as well `echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.bash_profile`
49
50    NOTE: this change is effective in next terminal session, so please re-open terminal window before next step
51
52Getting started
53---------------
54
55### nextpnr-ice40
56
57For iCE40 support, install [Project IceStorm](http://www.clifford.at/icestorm/) to `/usr/local` or another location, which should be passed as `-DICESTORM_INSTALL_PREFIX=/usr` to CMake. Then build and install `nextpnr-ice40` using the following commands:
58
59```
60cmake . -DARCH=ice40
61make -j$(nproc)
62sudo make install
63```
64
65On Windows, you may specify paths explicitly:
66
67```
68cmake . -DARCH=ice40 -DICESTORM_INSTALL_PREFIX=C:/ProgramData/icestorm -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 .
69cmake --build . --config Release
70```
71
72To build a static release, change the target triplet from `x64-windows` to `x64-windows-static` and add `-DBUILD_STATIC=ON`.
73
74A simple example that runs on the iCEstick dev board can be found in `ice40/examples/blinky/blinky.*`.
75Usage example:
76
77```
78cd ice40/examples/blinky
79yosys -p 'synth_ice40 -top blinky -json blinky.json' blinky.v               # synthesize into blinky.json
80nextpnr-ice40 --hx1k --json blinky.json --pcf blinky.pcf --asc blinky.asc   # run place and route
81icepack blinky.asc blinky.bin                                               # generate binary bitstream file
82iceprog blinky.bin                                                          # upload design to iCEstick
83```
84
85Running nextpnr in GUI mode:
86
87```
88nextpnr-ice40 --json blinky.json --pcf blinky.pcf --asc blinky.asc --gui
89```
90
91(Use the toolbar buttons or the Python command console to perform actions
92such as pack, place, route, and write output files.)
93
94### nextpnr-ecp5
95
96For ECP5 support, install [Project Trellis](https://github.com/YosysHQ/prjtrellis) to `/usr/local` or another location, which should be passed as `-DTRELLIS_INSTALL_PREFIX=/usr/local` to CMake. Then build and install `nextpnr-ecp5` using the following commands:
97
98```
99cmake . -DARCH=ecp5 -DTRELLIS_INSTALL_PREFIX=/usr
100make -j$(nproc)
101sudo make install
102```
103
104 - Examples of the ECP5 flow for a range of boards can be found in the [Project Trellis Examples](https://github.com/YosysHQ/prjtrellis/tree/master/examples).
105
106
107### nextpnr-generic
108
109The generic target allows running placement and routing for arbitrary custom architectures.
110
111```
112cmake . -DARCH=generic
113make -j$(nproc)
114sudo make install
115```
116
117An example of how to use the generic flow is in [generic/examples](generic/examples). See also the [Generic Architecture docs](docs/generic.md).
118
119### Multiple architectures
120
121To build nextpnr for multiple architectures at once, a semicolon-separated list can be used with `-DARCH`.
122
123```
124cmake . -DARCH="ice40;ecp5"
125make -j$(nproc)
126sudo make install
127```
128
129To build every available architecture, use `-DARCH=all`.
130
131Pre-generating chip databases
132-----------------------------
133
134It is possible to pre-generate chip databases (`.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, build the architecture as a standalone project, which will produce the chip database alone. For example, for iCE40:
135
136```
137cd ice40
138cmake .
139make
140```
141
142This will create a `chipdb` directory with `.bba` files. Provide the path to this directory when building nextpnr by using `-D<arch>_CHIPDB=/path/to/chipdb`.
143
144Cross-compilation
145-----------------
146
147Apart from chip databases, nextpnr requires the `bba` tool to be compiled for the build system. This tool can be compiled as a separate project:
148
149```
150cd bba
151cmake .
152make
153```
154
155This will create a `bba-export.cmake` file. Provide the path to this file when cross-building nextpnr by using `-DBBA_IMPORT=/path/to/bba-export.cmake`.
156
157Additional notes for building nextpnr
158-------------------------------------
159
160The following runs a debug build of the iCE40 architecture without GUI, without Python support, without the HeAP analytic placer and only HX1K support:
161
162```
163cmake . -DARCH=ice40 -DCMAKE_BUILD_TYPE=Debug -DBUILD_PYTHON=OFF -DBUILD_GUI=OFF -DBUILD_HEAP=OFF -DICE40_HX1K_ONLY=1
164make -j$(nproc)
165```
166
167To make static build release for iCE40 architecture use the following:
168
169```
170cmake . -DARCH=ice40 -DBUILD_PYTHON=OFF -DBUILD_GUI=OFF -DSTATIC_BUILD=ON
171make -j$(nproc)
172```
173
174The 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).
175
176You can change the location where nextpnr will be installed (this will usually default to `/usr/local`) by using `-DCMAKE_INSTALL_PREFIX=/install/prefix`.
177
178Notes for developers
179--------------------
180
181- All code is formatted using `clang-format` according to the style rules in `.clang-format` (LLVM based with
182  increased indent widths and brace wraps after classes).
183- To automatically format all source code, run `make clangformat`.
184- See the wiki for additional documentation on the architecture API.
185
186Recording a movie
187-----------------
188
189- To save a movie recording of place-and-route click recording icon in toolbar and select empty directory
190  where recording files will be stored and select frames to skip.
191- Manualy start all PnR operations you wish
192- Click on recording icon again to stop recording
193- Go to directory containing files and exeecute `ffmpeg -f image2 -r 1 -i movie_%05d.png -c:v libx264 nextpnr.mp4`
194
195Testing
196-------
197
198- To build test binaries as well, use `-DBUILD_TESTS=ON` and after `make` run `make test` to run them, or you can run separate binaries.
199- To use code sanitizers use the `cmake` options:
200  - `-DSANITIZE_ADDRESS=ON`
201  - `-DSANITIZE_MEMORY=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++`
202  - `-DSANITIZE_THREAD=ON`
203  - `-DSANITIZE_UNDEFINED=ON`
204- Running valgrind example `valgrind --leak-check=yes --tool=memcheck ./nextpnr-ice40 --json ice40/blinky.json`
205- Running tests with code coverage use `-DBUILD_TESTS=ON -DCOVERAGE` and after `make` run `make ice40-coverage`
206- After that open `ice40-coverage/index.html` in your browser to view the coverage report
207- Note that `lcov` is needed in order to generate reports
208
209Links and references
210--------------------
211
212### Synthesis, simulation, and logic optimization
213
214- [Yosys](http://www.clifford.at/yosys/)
215- [Icarus Verilog](http://iverilog.icarus.com/)
216- [ABC](https://people.eecs.berkeley.edu/~alanmi/abc/)
217
218### FPGA bitstream documentation (and tools) projects
219
220- [Project IceStorm (Lattice iCE40)](http://www.clifford.at/icestorm/)
221- [Project Trellis (Lattice ECP5)](https://yosyshq.github.io/prjtrellis-db/)
222- [Project X-Ray (Xilinx 7-Series)](https://symbiflow.github.io/prjxray-db/)
223- [Project Chibi (Intel MAX-V)](https://github.com/rqou/project-chibi)
224
225### Other FOSS FPGA place and route projects
226
227- [Arachne PNR](https://github.com/cseed/arachne-pnr)
228- [VPR/VTR](https://verilogtorouting.org/)
229- [SymbiFlow](https://github.com/SymbiFlow/symbiflow-arch-defs)
230