When I used FPGAs in the past, e.g. for my LED Display, I was using Xilinx FPGAs with their proprietary software which unfortunately runs only under Windows or Linux. This was very inconvenient and in addition the software was slow as hell.
Fortunately a new era has begun: Open-Source FPGA toolchains! It was started some time back by Clifford Wolf, who first wrote a synthesis tool called Yosys and later reverse-engineered the bitstream format for Lattice iCE-40 FPGAs. Recently a new place-and-route tool called nextpnr was developed as well. Clifford has given several talks about those tools at various events which are worth watching:
- 32C3: A Free and Open Source Verilog-to-Bitstream Flow for iCE40 FPGAs
- EH16: Verilog Synthesis and more with Yosys
- 35C3: The nextpnr FOSS FPGA place-and-route tool
At 35C3 @esden gave several workshops explaining this toolchain using the iCEBreaker board. Although I didn't have the fortune to attend one of this workshops I had the chance to chat with @esden and he was kind enough to give me an iCEBreaker to play with.
Installing all the tools on OS X in a non-invasive way was a little bit tricky and therefor I created some homebrew recipes for easy usage. To get started with the Open Source FPGA Toolchain and the iCEBreaker board you need to follow the following steps:
- Tap my homebrew recipes using
brew tap twam/openfpga
- Install yosys using
brew install yosys
- Install icestorm using
brew install icestorm
- Install nextpnr using
brew install nextpnr --without-gui --without-arch-ecp5
You can also install nextpnr with GUI and the additional ECP5 architecture, but this takes much longer and is not required for the iCEBreaker
- Clone the iCEBreaker examples using
git clone https://github.com/icebreaker-fpga/icebreaker-examples.git
- Go to your favorite example, e.g. using
cd icebreaker-examples/blink_count_shift
- Build the example using
make
- Connect your iCEBreaker via USB and run the example using
make prog
Many thanks for the brew formula for nextpnr on OSX!
May I suggest two more options? --no-python to exclude python scripting support and --with-static to do a build with the Boost libs statically linked.
class Nextpnr :build
depends_on "ninja" => :build
depends_on "boost"
depends_on "boost-python3"
depends_on "eigen"
depends_on "icestorm" if build.with? "arch-ice40"
depends_on "prjtrellis" if build.with? "arch-ecp5"
depends_on "python"
depends_on "qt" if build.with? "gui"
def install
args = []
args << "-DBUILD_GUI=OFF" if build.without? "gui"
args << "-DBUILD_PYTHON=OFF" if build.without? "python"
args << "-DSTATIC_BUILD=ON" if build.with? "static"
archs = []
archs << "ice40" if build.with? "arch-ice40"
archs << "ecp5" if build.with? "arch-ecp5"
archs << "generic" if build.with? "arch-generic"
args << ("-DARCH=" << archs.join(";"))
system "cmake", *args, ".", "-GNinja", *std_cmake_args
system "ninja"
system "ninja", "install"
end
test do
system "#{bin}/nextpnr-ecp5", "--help" if build.with? "arch-ecp5"
system "#{bin}/nextpnr-ice40", "--help" if build.with? "arch-ice40"
end
end
Added 🙂
Thanks for the brew formula!
I am missing iverilog. (Tried to build it from github but it fails)
I can follow all steps until the build of nextPNR.
Until we get to :
cmake -DBoost_NO_BOOST_CMAKE=ON -DCURRENT_GIT_VERSION=f692269 . -GNinja -DCMAKE_C_FLAGS_RELEASE=-DNDE
Then I get an error seemingly a missing or misplaced dependancy.
-- Found PythonInterp: /usr/local/opt/python/bin/python3 (found suitable version "3.7.6", minimum required is "3.5")
CMake Error at /usr/local/Cellar/cmake/3.16.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
I am unsure if this is a matter of moving or linking the correct directory. I am new to the world of opensource toolchains for FPGAs and terminal thrashing as well. Hope to get a simple demo up and running free from the use of IceStudio. Any help is greatly appreciated.
I was able to resolve this issue by taking the advice of the above comment by PNR. All issues were resolved by excluding the python scripting support using --without-python. Thank you for the clear and concise guidance.
Awesome! However it should also work with the scripting. I'll have a look. 🙂
Thanks for the brew formulas! I was trying to install from source but ran into a problem linking to libtbb. I was looking for info on that error when I found your page.
I installed nextpnr with "brew install nextpnr" (i.e. without the --without-gui option) to try the GUI. The install completed without any errors, but the resulting executable for nextpnr-ice40 complains that --gui is an unrecognized option. Note, it did install qt 6.0.3_2.
Do you have any ideas what I should try to get the nextpnr gui?
I tried reinstalling with an explicit option:
brew reinstall nextpnr --with-gui
but that resulted in the following build messages:
==> Reinstalling twam/openfpga/nextpnr --without-gui
==> cmake -DBUILD_GUI=OFF -DICESTORM_INSTALL_PREFIX=/usr/local/opt/icestorm -DTR
==> ninja
So I reinstalled again with no options since I want the gui and the ECP5 support:
brew reinstall nextpnr
and I got the same build messages regarding the GUI
==> Reinstalling twam/openfpga/nextpnr --without-gui
==> cmake -DBUILD_GUI=OFF -DICESTORM_INSTALL_PREFIX=/usr/local/opt/icestorm -DTRELLIS_INSTALL_PREFIX=/usr
==> ninja
So how do I tell the formula to build with gui support?
Looks like nextpnr changed their options for enabling the gui. I fixed the package. You should be able to install it with
brew install nextpnr --with-gui
now.
Thanks again! Now building with -DBUILD_GUI=ON.