Skip to main content

Jupyter kernel for cocotb

Project description

cocotb Jupyter Kernel

Binder

This kernel adds support for using cocotb within Jupyter notebooks.

Why is a dedicated kernel needed?

cocotb works in conjunction with an HDL simulator. As such, attempting to import cocotb within a notebook will not work because no simulator is attached. This kernel works by first building the HDL design and launching the simulator using cocotb's runners, then having a cocotb test module launch ipykernel, which will connect to the notebook and execute code cells.

Installation

Prerequisites:

  • Python 3.10+
  • JupyterLab 4+ or Jupyter Notebook 6+
  • An HDL simulator (such as Icarus Verilog, Verilator, or GHDL)

After installing the prerequisites, the kernel can be installed via pip.

pip install cocotb_kernel

# Install the kernel to JupyterLab's user directory
python -m cocotb_kernel.install --user

Usage

Before launching the kernel, create a TOML file named cocotb.toml within the project's root directory (similar to cocotb's Makefile).

The TOML file follows the cocotb runner build() and test() arguments, with a few exceptions, as shown:

# The simulator to build and simulate the HDL design
# https://docs.cocotb.org/en/stable/simulator_support.html
simulator = "icarus"

# The top level HDL module
hdl_toplevel = "foo"

# The language of the top level HDL module
hdl_toplevel_lang = "verilog"

# Optional: Verilog parameters or VHDL generics
[parameters]

# Build options
# https://docs.cocotb.org/en/stable/library_reference.html#cocotb.runner.Simulator.build
[build]
verilog_sources = ["hdl/foo.sv", "../hdl/foo.sv"] # specify sources relative to cocotb.toml
vhdl_sources = ["hdl/*.vhdl", "**/*.vhdl"]        # wildcards are also supported

# Optional: Defines to set for building
[build.defines]

# Test options
# https://docs.cocotb.org/en/stable/library_reference.html#cocotb.runner.Simulator.test
[test]

# Optional: Extra environment variables to set for testing
[test.extra_env]

Once the TOML file is created, navigate to or launch JupyterLab within the project's root directory and create or open a notebook with the cocotb kernel.

Planned Features

  • Move wavedrom support into kernel (cocotb v2.0 removes the wavedrom module)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cocotb_kernel-1.0.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

cocotb_kernel-1.0.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file cocotb_kernel-1.0.1.tar.gz.

File metadata

  • Download URL: cocotb_kernel-1.0.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for cocotb_kernel-1.0.1.tar.gz
Algorithm Hash digest
SHA256 dea46164e50d9820df2d2946b4f4cf1e517705c9ecadad73724ca838168466d5
MD5 8a26709d34066583c370aa7c2ca715dc
BLAKE2b-256 588ffa63f067a6622b5836fd7063bba40189930e09a8e0c3979cd63f5aad28c5

See more details on using hashes here.

File details

Details for the file cocotb_kernel-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for cocotb_kernel-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a0468e985cffbefc5a57b749d7986e9051c891a1e8be495a2764f5d2670e146
MD5 5dd3a9850ae1362f3affbf2c4c6b9188
BLAKE2b-256 f43f04373365871a852a56c854f4934121aae0464f41147f5e80d1bb98baf92a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page