Installation#

Note

If you want to install the development version of cocotb, instructions are here.

Using cocotb requires installation of prerequisites and installation of cocotb itself.

Alternatively, you may use a package manager, see Alternative installation using a Package Manager.

In this document, we are assuming that you already have a supported simulator available in PATH.

Installation of Prerequisites#

The current stable version of cocotb requires:

  • Python 3.6.2+

  • GNU Make 3+

  • A Verilog or VHDL simulator, depending on your RTL source code

Changed in version 1.7: Dropped requirement of Python development headers and C++ compiler for release versions.

Changed in version 1.6: Dropped Python 3.5 support

Changed in version 1.4: Dropped Python 2 support

Note

In order to use a 32-bit simulator you need to use a 32-bit version of Python.

Note

Type checking cocotb code requires Python 3.11+.

The installation instructions vary depending on your operating system:

We recommend users who are running Windows and who are more comfortable with a Unix shell, or who have legacy Makefile-based projects, to use Windows Subsystem for Linux (WSL). After installing WSL and a supported Linux distribution, follow the Linux installation instructions for cocotb.

Conda is an open-source package and environment management system that we recommend for users who are more comfortable with native Windows development. Download and install Miniconda from https://conda.io/. From an Anaconda Prompt, use the following line to install a compiler (GCC or Clang) and GNU Make:

conda install -c msys2 m2-base m2-make

In a terminal, run

sudo apt-get install make python3 python3-pip libpython3-dev

In a terminal, run

sudo yum install make python3 python3-pip python3-libs

We recommend using the Homebrew package manager. After installing it, run the following line in a terminal:

brew install python

Installation of cocotb#

You are reading the documentation for cocotb 2.0. To install this version, or any later compatible version, run

pip install "cocotb~=2.0"

Note

If your user does not have permissions to install cocotb using the instructions above, try adding the --user option to pip (see the pip documentation).

Warning

pip may belong to a different Python installation to what you expect. Use pip -V to check. If this prints “(python 2.7)”, use pip3 or python3 -m pip in place of pip in the command shown.

Alternative installation using a Package Manager#

The installation instructions vary depending on your package manager:

In a terminal, run

guix install python-cocotb

Post installation#

After installation, you should be able to execute cocotb-config. If it is not found, you need to append its location to the PATH environment variable.

For more installation options, please see our Wiki.