JupyterLab kernel for cocotb
Project description
cocotb Jupyter Kernel
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
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]
# Optional: 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cocotb_kernel-1.0.0.tar.gz
.
File metadata
- Download URL: cocotb_kernel-1.0.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 337eed4033914bb6bfbf7743aedc5c451b7b8cdebd43b925ba89e005c56b446a |
|
MD5 | b3da5f7b9ee40a290c3525f000f0d8e0 |
|
BLAKE2b-256 | 6e17210528150113b3c1eb1a571f3114da5651a55692ea208bf95531cfb40b28 |
File details
Details for the file cocotb_kernel-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: cocotb_kernel-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78b2c313f957d1f1a14968ff3a64285a465221e6b0a41defdec247cd52228177 |
|
MD5 | 33cdce518ec21a0dbbff8600f65f5947 |
|
BLAKE2b-256 | e6708b3c99d3893d3b84250d2c6de384a6be7013486dd4d1af796ffa7d073db2 |