Förderjahr 2019 / Project Call #14 / ProjektID: 4501 / Projekt: Cloud_FPGA_tool
FPGA toolchains are notoriously complicated to install. Proprietary toolchains range from gigabytes to tens of gigabytes in size and run on a limited set of operating systems.
FOSS toolchains move quickly, such that it is necessary to build the latest version from source code, and can be challenging to compile for end users. Fortunately, we can improve the latter!
The traditional approach for distributing C/C++ software is to build it for every combination of OS and CPU that is important for end users. In some cases, additional tricks are necessary to ensure proper compatibility, such as integrating with the OS-specifc package manager or eliminating dependencies on system libraries. This process is costly, both during initial implementation, ongoing maintenance, and support. Sometimes, this cost can be greatly reduced. Though much C/C++ software requires integration with the platform it's running on to function properly, batch toolchains, like Yosys and nextpnr, are an exception: in a typical FPGA workflow, a batch toolchain only performs computation and simple I/O. Since it does not use any platform features, it doesn't need to be integrated with the platform at all, and in principle, a single build of a toolchain--a "universal binary"--could be used on every platform.
WebAssembly and WASI make universal binaries a reality. WebAssembly is a kind of machine code that can be produced from C/C++ code by clang. WASI is an interface providing basic operating system services, like memory allocation or file I/O, to WebAssembly applications. We have ported Yosys and nextpnr so that they would run on WASI. This port serves as a basis for YoWASP. YoWASP, short for "Yosys WebAssembly-based Synthesis and P&R", is a distribution based on universal WebAssembly binaries that consists, at the moment, of Yosys, nextpnr-ice40, and nextpnr-ecp5. The tools are currently provided in the form of Python packages, though the approach is not inherently tied to Python, and it is possible that other kinds of packages will be added later.
Although traditional cross-platform distributions of Yosys and nextpnr exist, the approach taken by YoWASP provides significant benefits for Python-based EDA tools and FPGA-based applications. Any project that is built on nMigen can use standard Python package management workflow to install its toolchain. Even better, the exact version of the toolchain can be frozen together with other dependencies, ensuring complete reproducibility.
Internally, nMigen relies on Yosys to emit Verilog code for toolchains that require it, and it uses the same technology as YoWASP to avoid the need to install Yosys to use nMigen with proprietary toolchains for a smoother workflow. It will also be used as a part of the CXXRTL integration. Another application that benefits from YoWASP is Glasgow, a digital electronics multitool built on Yosys, nextpnr, and nMigen. Glasgow is efficiently fine-tuned for any application at hand by quickly generating bitstreams on the fly for any requested configuration. It would not be possible to build it if not for the FOSS FPGA toolchain, which is extremely fast and freely redistributable. However, only with YoWASP it becomes possible to make the FPGA toolchain an automatically, transparently installed *component* of the application, rather than a *dependency* managed by the end user. This approach enables an entire new class of applications that generate FPGA bitstreams on demand tailored to a specific problem, and leads to more effective use of FPGA resources.