cocotb
cocotb is a coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python.
What it is and what it does
cocotb is a Python-based testbench framework that lets hardware engineers write verification code in Python instead of VHDL or Verilog. It uses coroutines to drive and monitor HDL simulations, bridging the gap between Python's ease of use and the low-level requirements of hardware verification. The framework handles the communication between your Python test code and a running HDL simulator, allowing you to read and write signals, check assertions, and orchestrate complex test scenarios.
The package is designed for digital design verification workflows where you need to test RTL (register-transfer level) designs. It depends on find_libpython to locate the Python runtime, and requires an external HDL simulator to actually run the tests. The project is actively maintained, supports Python 3.6 through 3.13, and has been in development since 2018, with a mature ecosystem of extensions and community resources.
Use it for:
- Verify VHDL or Verilog RTL designs by writing test scenarios in Python instead of hardware description languages
- Automate regression testing for digital designs by integrating testbenches into CI/CD pipelines
- Rapidly prototype hardware verification by leveraging Python's standard libraries and testing frameworks
- Drive complex stimulus patterns and monitor design behavior across multiple simulation runs
- Combine Python data processing with HDL simulation for algorithm validation in hardware
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
cocotb is a Python framework for writing testbenches that simulate and verify VHDL and Verilog hardware designs through coroutine-based cosimulation.
Yes, if you are developing or verifying VHDL or Verilog designs and want to write testbenches in Python. The framework is actively maintained, supports current Python versions, has no known vulnerabilities, and carries a permissive license. Install friction is moderate due to compiled wheels, but the broad platform support (macOS, Linux, Windows; x86_64, ARM, i686) mitigates this. Verify that your target HDL simulator is compatible before committing.
Install
cocotb on PyPI
pip
pip install cocotbuv
uv add cocotbpoetry
poetry add cocotbInstalling cocotb
Before you install
Medium install friction due to compiled wheel distribution across multiple Python versions and architectures. The project is actively maintained with recent commits and a stable release cadence, suggesting reliable ongoing support.
License in practice
BSD-3-Clause is a permissive license allowing commercial use, modification, and distribution with minimal restrictions—suitable for most projects.
Quickstart
pip install cocotb
import cocotb
from cocotb.triggers import Timer
@cocotb.test()
async def simple_test(dut):
await Timer(1, units='ns')
Requires a compatible HDL simulator (e.g., Icarus Verilog, GHDL, or commercial simulators) and appropriate environment setup to run testbenches against actual designs.
Verify before relying
- Which specific HDL simulators are officially supported or tested with version 2.0.1
- Whether the single runtime dependency find_libpython is sufficient or if system libraries are also required
- Performance characteristics or scalability limits for large testbenches
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.6.2) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — find_libpython |
| Maintenance | actively maintained — 272 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 589,198/month — #5,863 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cocotb-2.0.1-cp310-cp310-macosx_10_9_x86_64.whl; cocotb-2.0.1-cp310-cp310-macosx_11_0_arm64.whl; cocotb-2.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; cocotb-2.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; cocotb-2.0.1-cp310-cp310-win32.whl; cocotb-2.0.1-cp310-cp310-win_amd64.whl; cocotb-2.0.1-cp311-cp311-macosx_10_9_x86_64.whl; cocotb-2.0.1-cp311-cp311-macosx_11_0_arm64.whl; cocotb-2.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; cocotb-2.0.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; cocotb-2.0.1-cp311-cp311-win32.whl; cocotb-2.0.1-cp311-cp311-win_amd64.whl; cocotb-2.0.1-cp312-cp312-macosx_10_9_x86_64.whl; cocotb-2.0.1-cp312-cp312-macosx_11_0_arm64.whl; cocotb-2.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; cocotb-2.0.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl; cocotb-2.0.1-cp312-cp312-win32.whl; cocotb-2.0.1-cp312-cp312-win_amd64.whl; cocotb-2.0.1-cp313-cp313-macosx_10_13_x86_64.whl; cocotb-2.0.1-cp313-cp313-macosx_11_0_arm64.whl
Tags
More Electronic Design Automation (EDA) packages
Parses and elaborates SystemRDL 2.0 register…
permissive · top 15,000 on PyPI
planarityTests whether a graph is planar, computes…
permissive · top 15,000 on PyPI
pyslangpyslang provides Python bindings to parse,…
permissive · top 15,000 on PyPI
peakrdl-ipxactConverts between SystemRDL register…
copyleft · top 15,000 on PyPI
klayoutKLayout is a Python package for layout viewing,…
copyleft · top 15,000 on PyPI
cocotb-coverageAdds constrained randomization and functional…
permissive · top 15,000 on PyPI
amaranthAmaranth is a Python-based hardware definition…
permissive · top 15,000 on PyPI
cocotb-buscocotb-bus provides pre-built testbenching…
unclear · top 15,000 on PyPI
cocotb-testcocotb-test wraps cocotb hardware simulations…
permissive · top 15,000 on PyPI
pyuvmImplements the IEEE 1800.2 Universal…
permissive · top 15,000 on PyPI
fusesocFuseSoC is a package manager and build…
permissive · top 15,000 on PyPI
peakrdl-regblockCompiles SystemRDL register descriptions into…
copyleft · top 15,000 on PyPI
tree-sitter-verilogProvides a SystemVerilog grammar parser for…
permissive · top 5,000 on PyPI
pyvscPyVSC generates randomized test stimulus and…
permissive · top 15,000 on PyPI
vcdvcdParses Verilog value change dump (VCD) files…
unclear · top 15,000 on PyPI