Home

Awesome

<div align='center'> <img src='https://google.github.io/xls/images/xls_logo.svg' alt='XLS Logo'> </div>

XLS: Accelerated HW Synthesis

Docs | Quick Start Open In Colab | Tutorials

Conda packages Anaconda-Server Badge Anaconda-Server Badge

Ubuntu 22.04 CI Ubuntu 22.04 Nightly

What is XLS?

XLS implements a High Level Synthesis toolchain that produces synthesizable designs (Verilog and SystemVerilog) from flexible, high-level descriptions of functionality. It is Apache 2 licensed.

XLS (Accelerated HW Synthesis) aims to be the Software Development Kit (SDK) for the End of Moore's Law (EoML) era. In this "age of specialization", software and hardware engineers must do more co-design across their domain boundaries -- collaborate on shared artifacts, understand each other's cost models, and share tooling/methodology. XLS attempts to leverage automation, software engineers, and machine cycles to accelerate this overall process.

XLS enables the rapid development of hardware IP that also runs as efficient host software via "software style" methodology. An XLS design runs at native speeds for use in host software or a simulator, but that design can also generate hardware block output -- the XLS tools' correctness ensures (and provides tools to help formally verify) that they are functionally identical.

XLS supports both (optionally pipelined) functions with pure-wire I/O interfaces and concurrent processes (or procs). Procs are stateful, allowing induction over time, and include more general communication interfaces.

State of the Project

XLS is experimental, undergoing rapid development, and not an officially supported Google product. Expect bugs and sharp edges. Please help by trying it out, running through some tutorials, reporting bugs.

We are early stage and this has some practical effects:

Colab Notebooks

For a more setup-free and environment-independent way of trying out XLS, see our colab notebooks:

Install Latest Release

The following downloads the latest github repo release binaries for an x64 Linux machine:

# Determine the url of the latest release tarball.
LATEST_XLS_RELEASE_TARBALL_URL=$(curl -s -L \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/google/xls/releases | \
  grep -m 1 -o 'https://.*/releases/download/.*\.tar\.gz')

# Download the tarball and unpack it, observe the version numbers for each of the included tools.
curl -O -L ${LATEST_XLS_RELEASE_TARBALL_URL}
tar -xzvvf xls-*.tar.gz
cd xls-*/
./interpreter_main --version
./ir_converter_main --version
./opt_main --version
./codegen_main --version
./proto_to_dslx_main --version

Building From Source

Aside from the binary releases (available for x64 Linux as described above), and the available colab notebooks, XLS must be built from source using the Bazel build system.

The following instructions are for the Ubuntu 22.04 (Jammy Jellyfish) Linux distribution.

On an average 8-core VM:

Please see the two corresponding command lines below -- we start by assuming Bazel has been installed:

~$ git clone https://github.com/google/xls.git
~$ cd xls

~/xls$ # Follow the bazel install instructions to install bazel 7
~/xls$ # https://bazel.build/install/ubuntu

~/xls$ # Note we're going to tell Ubuntu that `/usr/bin/env python` is actually python3
~/xls$ # here, since that has not been the case by default on past Ubuntus.
~/xls$ # This is important. Without this step, you may experience cryptic error messages:
~/xls$ sudo apt install python3-distutils python3-dev libtinfo5 python-is-python3

~/xls$ # Now build/test in optimized build mode.
~/xls$ # If you don't plan on using the C++ front-end, which is not strictly
~/xls$ # needed (i.e. DSLX front-end only), use this command line:
~/xls$ bazel test -c opt -- //xls/... -//xls/contrib/xlscc/...

~/xls$ # To build everything, including the C++ front-end:
~/xls$ bazel test -c opt -- //xls/...

Reference build/test environment setups are also provided via Dockerfiles, if you have difficulty setting up the (limited set of) dependencies shown above in your environment:

~$ git clone https://github.com/google/xls.git
~$ cd xls
~/xls$ docker build . -f Dockerfile-ubuntu-22.04  # Performs optimized build-and-test.

Adding Additional Build Caching

Many programmers are used to using programs like ccache to improve caching for a build, but Bazel actually ships with very-high quality caching layers. In particular, incremental builds are more safe.

However, there are circumstances where Bazel might decide to recompile files where the results could have been cached locally - or where it might be safe to reuse certain intermediate results, even after a bazel clean. To improve this, you can tell Bazel to use a shared "disk cache", storing files persistently elsewhere on disk; just create a directory somewhere (e.g., ~/.bazel_disk_cache/), and then run:

echo "build --disk_cache=$(realpath ~/.bazel_disk_cache)" >> ~/.bazelrc
echo "test --disk_cache=$(realpath ~/.bazel_disk_cache)" >> ~/.bazelrc

!!! WARNING Bazel does not automate garbage collection of this directory, so it will grow over time without bounds. You will need to clean it up periodically, either manually or with an automated script.

Alternatively, you can add a remote cache that takes care of garbage collection for you. This can be hosted on a personal server or even on the local machine. We've personally had good results with localhost instances of bazel-remote.

Getting Clangd completions

A compile_commands.json file compatible with clangd and similar tools can be created by running xls/dev_tools/make-compilation-db.sh. Follow directions for your editor to install clangd code completion.

Stack Diagram and Project Layout

Navigating a new code base can be daunting; the following description provides a high-level view of the important directories and their intended organization / purpose, and correspond to the components in this XLS stack diagram:

<div align='center'> <img src='https://google.github.io/xls/images/xls_stack_diagram.png' alt='XLS Stack Diagram'> </div>

Community

Discussions about XLS - development, debugging, usage, etc:

Contributors

The following are contributors to the XLS project, see our contributing documentation and good first issues if you're interested in contributing, or reach out via GitHub discussions!