cocotb-bus
raw JSON → 0.3.0 verified Fri May 01 auth: no python
cocotb-bus provides bus interface components for cocotb, including AXI, Avalon, and Wishbone protocols. Current version 0.3.0 supports cocotb 2.0. Release cadence is low, with major updates tied to cocotb versions.
pip install cocotb-bus Common errors
error ModuleNotFoundError: No module named 'cocotb_bus' ↓
cause cocotb-bus not installed or installed in wrong environment.
fix
Run 'pip install cocotb-bus' in the same Python environment as cocotb.
error AttributeError: module 'cocotb' has no attribute 'drivers' ↓
cause Using cocotb 2.0 where drivers moved to cocotb-bus.
fix
Change import to 'from cocotb_bus.drivers import ...'
error ImportError: cannot import name 'AXIMaster' from 'cocotb.drivers' ↓
cause AXIMaster no longer part of cocotb core in version 2.0.
fix
Use 'from cocotb_bus.drivers import AXIMaster'.
Warnings
breaking cocotb-bus 0.3.0 only supports cocotb 2.0. Do not use with cocotb 1.x. ↓
fix Upgrade cocotb to 2.0 or use cocotb-bus <=0.2.1 for cocotb 1.x.
gotcha Import paths changed in cocotb 2.0. Bus drivers are no longer in cocotb proper; they moved to cocotb-bus. ↓
fix Import from cocotb_bus.drivers, not cocotb.drivers.
deprecated cocotb-bus 0.2.x is deprecated; not compatible with cocotb 2.0. ↓
fix Upgrade to cocotb-bus 0.3.0 and cocotb 2.0.
Imports
- AXIMaster wrong
from cocotb.drivers import AXIMastercorrectfrom cocotb_bus.drivers import AXIMaster - AXISlave
from cocotb_bus.drivers import AXISlave - AvalonMaster
from cocotb_bus.drivers import AvalonMaster - WishboneMaster
from cocotb_bus.drivers import WishboneMaster - AXIStreamDriver
from cocotb_bus.drivers import AXIStreamDriver
Quickstart
import cocotb
from cocotb.clock import Clock
from cocotb.triggers import ClockCycles
from cocotb_bus.drivers import AXIMaster
from cocotb_bus.monitors import AXIMonitor
@cocotb.test()
async def test_axi(dut):
cocotb.start_soon(Clock(dut.clk, 10, units='ns').start())
# Reset
dut.rstn.value = 0
await ClockCycles(dut.clk, 5)
dut.rstn.value = 1
# Create AXI master
axi_master = AXIMaster(dut, "axi", dut.clk)
# Write example
await axi_master.write(0x100, 0xDEADBEEF)
# Read back
data = await axi_master.read(0x100, 4)
dut._log.info("Read data: %s", data)