Getting Started

Welcome! This guide will help you get OpenTitan up and running by instructing you how to:

  1. clone the OpenTitan Git repository,
  2. setup an adequate build/testing environment on your machine, and
  3. build OpenTitan software/hardware for the target of your choosing.

Workflow Options

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.

Getting Started Workflow

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!

Step 0: Clone the OpenTitan Repository

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 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

Step 1: Check System Requirements

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 18.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.

Step 2: Install Package Manager Dependencies

Skip this step if using the Docker container.

A number of software packages from the distribution’s package manager are required. On Ubuntu 18.04, the required packages can be installed with the following command.

$ sudo apt install autoconf bison build-essential clang-format cmake curl \
    doxygen flex g++ git golang lcov libelf1 libelf-dev libftdi1-2 \
    libftdi1-dev libncurses5 libssl-dev libudev-dev libusb-1.0-0 lsb-release \
    make ninja-build perl pkgconf python3 python3-pip python3-setuptools \
    python3-urllib3 python3-wheel srecord tree xsltproc zlib1g-dev xz-utils

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

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, which should show ~/.local/bin/pip3. If it doesn’t, add ~/.local/bin to your PATH, e.g. by modifying your ~/.bashrc file.

Now install additional Python dependencies:

$ cd $REPO_TOP
$ pip3 install --user -r python-requirements.txt

Step 3: Install the LowRISC RISC-V Toolchain

Skip this step if using the Docker container.

To build device software you need a baremetal RISC-V toolchain. 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.

Troubleshooting

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.

Step 4: Build OpenTitan Software

Follow the dedicated guide to build OpenTitan’s software, and then return to this page.

Step 5: Set up your Simulation Tool or FPGA

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 built in the last step, 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 that applies to you:

Step 6: Optional Additional Steps

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:

  • If you want to contribute SystemVerilog code upstream to OpenTitan, follow step 6a to install Verible.
  • If you want to debug on-chip OpenTitan software with GDB, follow step 6b to install OpenOCD.
  • If you want to run supported formal verification flows for OpenTitan, using tools like JasperGold, follow step 6c to set up formal verification.
  • If you want to simulate OpenTitan using Siemens Questa, follow step 6d to set it up.

It also may make sense to stick with the basic setup and come back to these steps if you find you need them later.

Step 6a: Install Verible (optional)

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. 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 18.04:

$ export VERIBLE_VERSION=v0.0-2135-gb534c1fe

$ 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

$ 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 v0.0-2135-gb534c1fe, but it is expected that this version is going to be updated frequently, since the tool is under active develpment.

Step 6b: Install OpenOCD (optional)

See the OpenOCD install guide.

Step 6c: Set up formal verification (optional)

See the formal verification setup guide

Step 6d: Set up Siemens Questa (optional)

 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.

Step 7: Additional Resources

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.

General

Hardware

Software