Using cocotb requires installation of prerequisites and installation of cocotb itself.
In this document, we are assuming that you already have a
supported simulator available in
Installation of Prerequisites
The current stable version of cocotb requires:
Python development packages (Python/C API headers and embedding library)
GCC 4.8.1+, Clang 3.3+ or Microsoft Visual C++ 14.21+ and associated development packages
GNU Make 3+
A Verilog or VHDL simulator, depending on your RTL source code
Changed in version 1.6.0: Dropped Python 3.5 support
Changed in version 1.4: Dropped Python 2 support
In order to use a 32-bit simulator you need to use a 32-bit version of Python.
The installation instructions vary depending on your operating system:
Conda is an open-source package and environment management system that we recommend for Windows.
conda install -c msys2 m2-base m2-make
In a terminal, run
sudo apt-get install make gcc g++ python3 python3-dev python3-pip
In a terminal, run
sudo yum install make gcc gcc-c++ libstdc++-devel python3 python3-devel python3-pip
We recommend using the Homebrew package manager. After installing it, run the following line in a terminal:
brew install python icarus-verilog gtkwave
Installation of cocotb
The stable version of cocotb can be installed by running
pip install cocotb
The reusable bus interfaces and testbenching components have recently been moved to the cocotb-bus package.
You can easily install these at the same time as cocotb by adding the
bus extra install:
pip install cocotb[bus].
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).
pip may belong to a different Python installation to what you expect.
pip -V to check.
If this prints “(python 2.7)”, use pip3 or
python3 -m pip in place of pip in the command shown.
If you need to test VHDL in Questa, you must make sure that Questa is in your PATH before attempting to install cocotb. Failure to do so will build cocotb without FLI support necessary to test VHDL in Questa. If you end up in the situation where your cocotb doesn’t have FLI support and you need it, add the –no-cache-dir option to pip install to rebuild cocotb from scratch.
If you want to install the development version of cocotb, instructions are here.
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.
This may happen when you use the
--user option to pip,
in which case the location is documented here.
For more installation options, please see our Wiki.