Skip to content

cocotb extension for the AMBA APB protocol, with first-class 2.0 support

License

Notifications You must be signed in to change notification settings

matiasilva/cocotbext-apb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cocotb APB VIP

This repo houses an APB driver extension for cocotb. It has first-class support for cocotb 2.0 features. For a pre 2.0 VIP, see https://github.com/SystematIC-Design/cocotbext-apb.

Provided components:

  • APB requester driver

Planned components:

  • APB collector driver
  • APB bus monitor

Getting started

An APB requester driver requires a working clock and a dut with mandatory APB signals. Optional signals are allowed but are not driven. The naming scheme used is the same as that of the standard cocotb-bus component.

from cocotb.ext.apb import APBRequesterDriver

clk = Clock(dut.pclk, 1, units="ns")
cocotb.start_soon(clk.start(start_high=False))
driver = APBRequesterDriver(dut, "apbs", dut.pclk)

The above code initializes an APB requester using signals prefixed with apbs. To read and write data:

async def setup_dut(dut):
  await apb.write(CTRL_OFFSET, 0b101)
  rx = await apb.read(STATUS_OFFSET)
  print(rx.read_data)

All APB read/write operations return an instance of APBTransaction, which you can use to check for any slave errors or in the case of a read, the read data.

The width of the data bus is automatically detected but can be adjusted manually (do at your own peril).

Development

This repo follows the standard cocotb extension structure and thus should be easy to start hacking on.

Tests can be run with uv run pytest, or simply pytest if you have sourced an appropriate virtual environment.

Important

You must have a SystemVerilog simulator installed to run the tests. As the APB VIP is small, Icarus is sufficient.

License

MIT

Author

Matias Wang Silva, 2025

About

cocotb extension for the AMBA APB protocol, with first-class 2.0 support

Resources

License

Stars

Watchers

Forks

Contributors