Welcome! This guide will help you get OpenTitan up and running.
An important preliminary note: to run OpenTitan software, you will need to not only build the software but somehow simulate the hardware it runs on. As shown in the diagram below, we currently support multiple build targets and workflows, including: Verilator, FPGA, and DV (commercial RTL simulators, such as VCS and Xcelium). However, if you are new to the project, we recommend simulation with Verilator. This uses only free tools, and does not require any additional hardware such as an FPGA.
This guide will focus on the Verilator workflow, but indicate when those following FPGA or DV workflows should do something different. Just keep in mind, if you‘re a new user and you don’t know you're part of the FPGA or DV crowd, “Verilator” means you!
Clone the OpenTitan repository:
git clone https://github.com/lowRISC/opentitan.git
If you wish to contribute to OpenTitan you will need to make a fork on GitHub and may wish to clone the fork instead. We have some [notes for using GitHub]({{< relref “github_notes.md” >}}) which explain how to work with your own fork (and perform many other GitHub tasks) in the OpenTitan context.
Note: throughout the documentation $REPO_TOP
refers to the path where the OpenTitan repository is checked out. Unless you've specified some other name in the clone, $REPO_TOP
will be a directory called opentitan
. You can create the environment variable by calling the following command from the same directory where you ran git clone
:
export REPO_TOP=$PWD/opentitan
OpenTitan installation requires Linux. If you do not have Linux, please stop right here and use the (experimental) Docker container. You can then skip to step 4 (building software).
If you do have Linux, you are still welcome to try the Docker container. However, as the container option is currently experimental, we recommend following the steps below to build manually if you plan on being a long-term user or contributor for the project.
Our continuous integration setup runs on Ubuntu 20.04 LTS, which gives us the most confidence that this distribution works out of the box. We do our best to support other distributions, but cannot guarantee they can be used “out of the box” and might require updates of packages. Please file a GitHub issue if you need help or would like to propose a change to increase compatibility with other distributions.
You will need at least 7GiB of available RAM in order to build the Verilator simulation. If you have an FPGA and download the bitstream from our cloud bucket rather than building it locally (the default setup) then this constraint does not apply.
If you are specifying a new machine to run top-level simulations of the whole of OpenTitan using Verilator, it is recommended that you have a minimum of 32GiB of physical RAM and at least 512GiB of SSD/HDD storage for the build tools, repository and Ubuntu installation.
Skip this step if using the Docker container.
A number of software packages from the distribution's package manager are required. On Ubuntu 20.04, the required packages can be installed with the following command.
{{< pkgmgr_cmd “apt” >}}
Some tools in this repository are written in Python 3 and require Python dependencies to be installed through pip
. We recommend installing the latest version of pip
and setuptools
(especially if on older systems such as Ubuntu 18.04) using:
python3 -m pip install --user -U pip "setuptools<66.0.0"
The pip
installation instructions use the --user
flag to install without root permissions. Binaries are installed to ~/.local/bin
; check that this directory is listed in your PATH
by running which pip3
. It should show ~/.local/bin/pip3
. If it doesn't, add ~/.local/bin
to your PATH
, e.g. by adding the following line to your ~/.bashrc
file:
export PATH=$PATH:~/.local/bin
Now install additional Python dependencies:
cd $REPO_TOP pip3 install --user -r python-requirements.txt
On Ubuntu 18.04 the package build-essential
includes the compilers gcc-7
and g++-7
. But for the OpenTitan project gcc-9
/g++-9
or higher is required, which has to be installed manually. Check that you have version 9 or higher of gcc
installed by:
gcc --version
If your version is lower, you have to upgrade it manually. For this, first, add ubuntu-toolchain-r/test
PPA to your system using the following commands:
sudo apt install software-properties-common sudo add-apt-repository ppa:ubuntu-toolchain-r/test
Next, install the necessary GCC and G++ version by:
sudo apt update sudo apt install gcc-9 g++-9
Finally, update the symbolic links for gcc
and g++
using these commands:
sudo ln -sf /usr/bin/gcc-9 /usr/bin/gcc sudo ln -sf /usr/bin/g++-9 /usr/bin/g++
Skip this step if using the Docker container.
To build device software you need a baremetal RISC-V toolchain (including, for example, a C compiler). Even if you already have one installed, we recommend using the prebuilt toolchain provided by lowRISC, because it is built with the specific patches and options that OpenTitan needs. You can install the toolchain using the util/get-toolchain.py
script, which will download and install the toolchain to the default path, /tools/riscv
.
cd $REPO_TOP ./util/get-toolchain.py
If you did not encounter errors running the script, you're done and can go to step 4. If you did, read on.
If you need to install to a different path than /tools/riscv
(for instance, if you do not have permission to write to the /tools
directory), then you can specify a different location using the --install-dir
option. Run ./util/get-toolchain.py --help
for details. You can alternatively download the tarball starting with lowrisc-toolchain-rv32imcb-
from GitHub releases and unpack it to the desired installation directory.
Assuming one of the above worked and you have installed to a non-standard location, you will need to set the TOOLCHAIN_PATH
environment variable to match whatever path you used. For example, if I wanted to install to ~/ot_tools/riscv
, then I would use:
./util/get-toolchain.py --install-dir ~/ot_tools/riscv export TOOLCHAIN_PATH=~/ot_tools/riscv
Add the export
command to your ~/.bashrc
or equivalent to ensure that the TOOLCHAIN_PATH
variable is set for future sessions. Check that it worked by opening a new terminal and running:
ls $TOOLCHAIN_PATH/bin/riscv32-unknown-elf-as
If that prints out the file path without errors, then you've successfully installed the toolchain. Otherwise, try to find the riscv32-unknown-elf-as
file in your file system and make sure $TOOLCHAIN_PATH
is correctly set.
Note: If you are using the pre-built Docker container, Verilator is already installed. Unless you know you need the FPGA or DV guides, you can skip this step.
In order to run the software, we need to have some way to emulate an OpenTitan chip. There are a few different options depending on your equipment and use-case. Follow the guide(s) that applies to you:
Follow the [dedicated guide]({{< relref “build_sw” >}}) to build OpenTitan's software and run tests.
If you have made it this far, congratulations! Hopefully you got a “Hello World!” demo running on OpenTitan using either the Verilator or FPGA targets.
Depending on the specific way you want to use or contribute to OpenTitan, there may be a few extra steps you want to do. In particular:
It also may make sense to stick with the basic setup and come back to these steps if you find you need them later.
Verible is an open source SystemVerilog style linter and formatting tool. The style linter is relatively mature and we use it as part of our [RTL design flow]({{< relref “doc/ug/design” >}}). The formatter is still under active development, and hence its usage is more experimental in OpenTitan.
You can download and build Verible from scratch as explained on the Verible GitHub page. But since this requires the Bazel build system the recommendation is to download and install a pre-built binary as described below.
Go to this page and download the correct binary archive for your machine.
The example below is for Ubuntu 20.04:
export VERIBLE_VERSION={{< tool_version "verible" >}} wget https://github.com/google/verible/releases/download/${VERIBLE_VERSION}/verible-${VERIBLE_VERSION}-Ubuntu-20.04-focal-x86_64.tar.gz tar -xf verible-${VERIBLE_VERSION}-Ubuntu-20.04-focal-x86_64.tar.gz
If you are using Ubuntu 18.04 then instead use:
export VERIBLE_VERSION={{< tool_version "verible" >}} wget https://github.com/google/verible/releases/download/${VERIBLE_VERSION}/verible-${VERIBLE_VERSION}-Ubuntu-18.04-bionic-x86_64.tar.gz tar -xf verible-${VERIBLE_VERSION}-Ubuntu-18.04-bionic-x86_64.tar.gz
Then install Verible within ‘tools’ using:
sudo mkdir -p /tools/verible/${VERIBLE_VERSION}/ sudo mv verible-${VERIBLE_VERSION}/* /tools/verible/${VERIBLE_VERSION}/
After installation you need to add /tools/verible/$VERIBLE_VERSION/bin
to your PATH
environment variable.
Note that we currently use version {{< tool_version “verible” >}}, but it is expected that this version is going to be updated frequently, since the tool is under active development.
See the [OpenOCD install guide]({{< relref “install_openocd.md” >}}).
See the [formal verification setup guide]({{< relref “setup_formal.md” >}})
 Once a standard installation of Questa has been completed, add QUESTA_HOME
as an environment variable which points to the Questa installation directory.
As of Questa version 21.4 there are some code incompatibilities with the OpenTitan code-base. See issue #9514 for the list of issues and temporary workarounds.
As you may have guessed, there are several other pieces of hardware and software, besides a “Hello World!” demo, that are being actively developed for the OpenTitan project. If you are interested in these, check out the additional resources below.