How to Compile

Note

We recommend you to watch a tutorial video about how-to-compile before getting started

Supported Operating Systems

OpenFPGA is continously tested with Ubuntu 22.04 and partially on Ubuntu 20.04 It might work with earlier versions and other distributions.

In addition to continous integration, our community users have tested OpenFPGA on their local machines using the following operating systems:

  • CentOS 7.8

  • CentOS 8

  • Ubuntu 18.04

  • Ubuntu 21.04

Build Steps

OpenFPGA uses CMake to generate the Makefile scripts. In general, please follow the steps to compile

git clone https://github.com/LNIS-Projects/OpenFPGA.git
cd OpenFPGA
make all

Note

OpenFPGA requires gcc/g++ version > 9 and clang version > 10.

Note

cmake3.12+ is recommended to compile OpenFPGA with GUI

Note

Recommend using make -j<int> to accelerate the compilation, where <int> denotes the number of cores to be used in compilation.

Note

VPR’s GUI requires gtk-3, and can be enabled with make .. CMAKE_FLAGS="-DVPR_USE_EZGL=on"

Quick Compilation Verification

Note

Ensure that you install python dependences in Dependencies.

To quickly verify the tool is well compiled, users can run the following command from OpenFPGA root repository

python3 openfpga_flow/scripts/run_fpga_task.py compilation_verification --debug --show_thread_logs

Build Options

General build targets are available in the top-level makefile. Call help desk to see details

make help

The following options are available for a custom build

BUILD_TYPE=<string>

Specify the type of build. Can be either release or debug. By default, release mode is selected (full optimization on runtime)

CMAKE_FLAGS=<string>

Force build flags to CMake. The following flags are available

  • DOPENFPGA_WITH_TEST=[ON|OFF]: Enable/Disable the test build

  • DOPENFPGA_WITH_YOSYS=[ON|OFF]: Enable/Disable the build of yosys. Note that when disabled, the build of yosys-plugin is also disabled

  • DOPENFPGA_WITH_YOSYS_PLUGIN=[ON|OFF]: Enable/Disable the build of yosys-plugin.

  • DOPENFPGA_WITH_VERSION=[ON|OFF]: Enable/Disable the build of version number. When disabled, version number will be displayed as an empty string.

  • DOPENFPGA_WITH_SWIG=[ON|OFF]: Enable/Disable the build of SWIG, which is required for integrating to high-level interface.

  • OPENFPGA_ENABLE_STRICT_COMPILE=[ON|OFF]: Specifies whether compiler warnings should be treated as errors (e.g. -Werror)

Warning

By default, only required modules in Verilog-to-Routing (VTR) is enabled. On other words, abc, odin, yosys and other add-ons inside VTR are not built. If you want to enable them, please look into the dedicated options of CMake scripts.

CMAKE_GOALS=<string>

Specify the build target for CMake system. For example, cmake_goals=openfpga indicates that only openfpga binary will be compiled. For a detailed list of targets, use make list_cmake_targets to show. By default, all the build targets will be included.

Dependencies

Dependencies can be installed upon the use of OpenFPGA on different systems In general, OpenFPGA requires specific versions for the following dependencies:

cmake

version >3.12 for graphical interface

iverilog

version 10.3+ is required to run Verilog-to-Verification flow

Ubuntu 20.04

  • Dependencies required to build the code base

#!/usr/bin/env bash

# The package list is designed for Ubuntu 20.04 LTS
add-apt-repository -y ppa:ubuntu-toolchain-r/test
apt-get update
apt-get install -y \
    autoconf \
    automake \
    bison \
    ccache \
    cmake \
    ctags \
    curl \
    doxygen \
    flex \
    fontconfig \
    gdb \
    git \
    gperf \
    iverilog \
    libc6-dev \
    libcairo2-dev \
    libevent-dev \
    libffi-dev \
    libfontconfig1-dev \
    liblist-moreutils-perl \
    libncurses5-dev \
    libreadline-dev \
    libreadline8 \
    libx11-dev \
    libxft-dev \
    libxml++2.6-dev \
    make \
    perl \
    pkg-config \
    python3 \
    python3-setuptools \
    python3-lxml \
    python3-pip \
    qt5-default \
    tcllib \
    tcl8.6-dev \
    texinfo \
    time \
    valgrind \
    wget \
    zip \
    swig \
    expect \
    g++-7 \
    gcc-7 \
    g++-8 \
    gcc-8 \
    g++-9 \
    gcc-9 \
    g++-10 \
    gcc-10 \
    g++-11 \
    gcc-11 \
    clang-6.0 \
    clang-7 \
    clang-8 \
    clang-10 \
    clang-format-10 \
    libxml2-utils \
    libssl-dev
  • Dependencies required to run regression tests

# Update as required by some packages
apt-get update
apt-get install --no-install-recommends -y \
libdatetime-perl libc6 libffi-dev libgcc1 libreadline8 libstdc++6 \
libtcl8.6 tcl python3.8 python3-pip zlib1g libbz2-1.0 \
iverilog git rsync make curl wget tree python3.8-venv

Note

Python packages are also required

python3 -m pip install -r requirements.txt
  • Dependencies required to build documentation

#!/usr/bin/env bash

# The package list is designed for Ubuntu 20.04 LTS
apt-get install python3-sphinx
python3 -m pip install -r docs/requirements.txt

Ubuntu 22.04

  • Dependencies required to build the code base

#!/usr/bin/env bash

# The package list is designed for Ubuntu 20.04 LTS
add-apt-repository -y ppa:ubuntu-toolchain-r/test
apt-get update
apt-get install -y \
    autoconf \
    automake \
    bison \
    ccache \
    cmake \
    exuberant-ctags \
    curl \
    doxygen \
    flex \
    fontconfig \
    gdb \
    git \
    gperf \
    iverilog \
    libc6-dev \
    libcairo2-dev \
    libevent-dev \
    libffi-dev \
    libfontconfig1-dev \
    liblist-moreutils-perl \
    libncurses5-dev \
    libreadline-dev \
    libreadline8 \
    libx11-dev \
    libxft-dev \
    libxml++2.6-dev \
    make \
    perl \
    pkg-config \
    python3 \
    python3-setuptools \
    python3-lxml \
    python3-pip \
    qtbase5-dev \
    tcllib \
    tcl8.6-dev \
    texinfo \
    time \
    valgrind \
    wget \
    zip \
    swig \
    expect \
    g++-9 \
    gcc-9 \
    g++-10 \
    gcc-10 \
    g++-11 \
    gcc-11 \
    clang-11 \
    clang-12 \
    clang-13 \
    clang-14 \
    clang-format-14 \
    libxml2-utils
  • Dependencies required to run regression tests

# Update as required by some packages
apt-get update
apt-get install --no-install-recommends -y \
libdatetime-perl libc6 libffi-dev libgcc1 libreadline8 libstdc++6 \
libtcl8.6 tcl python3-pip zlib1g libbz2-1.0 \
iverilog git rsync make curl wget tree

Note

Python packages are also required

python3 -m pip install -r requirements.txt
  • Dependencies required to build documentation

#!/usr/bin/env bash

# The package list is designed for Ubuntu 20.04 LTS
apt-get install python3-sphinx
python3 -m pip install -r docs/requirements.txt

Running with pre-built docker image

Users can skip the traditional installation process by using the Dockerized version of the OpenFPGA tool. The OpenFPGA project maintains the docker image/Github package of the latest stable version of OpenFPGA in the following repository openfpga-master. This image contains precompiled OpenFPGA binaries with all prerequisites installed.

# To get the docker image from the repository,
docker pull ghcr.io/lnis-uofu/openfpga-master:latest

# To invoke openfpga_shell
docker run -it ghcr.io/lnis-uofu/openfpga-master:latest openfpga/openfpga bash

# To run the task that already exists in the repository.
docker run -it ghcr.io/lnis-uofu/openfpga-master:latest bash -c "source openfpga.sh && run-task compilation_verification"

# To link the local directory wihth docker
mkdir work

docker run -it -v work:/opt/openfpga/ ghcr.io/lnis-uofu/openfpga-master:latest bash
# Inside container
source openfpga.sh
cd work
create_task _my_task yosys_vpr