Cocotb Setup

Python runs SystemVerilog

You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.

Throughout your time in 6.205, testbenches and simulations will be your dear friend, letting you see what your hardware designs will accomplish without waiting for minutes before loading a design onto an FPGA1

Installation

We'd strongly recommend you install any Python libraries (including cocotb) using a virtual environment. You can create one with the command:

python3 -m venv ~/6205_python

Where "6205_python" is the name of the Python virtual environment. You can use this Python environment and avoid messing up your system python with the installations.

You can activate the environment with the command source ~/6205_python/bin/activate. You'll see (6205_python) precede lines in your shell indicating the environment is active. Do this whenever you start a terminal and begin working on your 6.205 work!

While a virtual environment is running, you can deactivate it and return to your typical Python environment with the shell command deactivate.

Cocotb is available through the pip package manager, so installing it is very simple! Once you have a virtual envrionment running, install cocotb with the command:

pip3 install cocotb

And cocotb will be installed! Keep in mind that in order to use it, you'll need to also have some simulator available in your environment--in our case, that's iVerilog, so make sure you have it installed. Finally, go on to the next page to install software to view the waveform results from our simulations!

Usage

In week 01, the Testing exercise gives a crash course in using cocotb, and will likely keep being a helpful reference for what you can accomplish in your testbenches.

Beyond this, the documentation for cocotb is a very helpful tool! Keep it in your back pocket for great references on how to go about writing Python testbenches.


 
Footnotes

1just to discover the silliest typo causing your design to break... (click to return to text)