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
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'.
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.

Basic cocotb test using cocotb-bus AXI master and monitor.

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)