Skip to main content

CocoTB Framework

License: MIT Python 3.10+

Reusable CocoTB verification infrastructure for RTL testing. Provides protocol-specific Bus Functional Models (BFMs), transaction scoreboards, and shared utilities for AMBA and other standard interfaces.

Extracted from the RTLDesignSherpa project as a standalone, pip-installable package.


Installation

pip install cocotb-framework

With all optional dependencies:

pip install cocotb-framework[all]

For development:

git clone https://github.com/sean-galloway/RTLDesignSherpa-DV.git
cd RTLDesignSherpa-DV
pip install -e ".[dev,all]"

Package Structure

CocoTBFramework/
├── components/           # Protocol-specific BFMs and drivers
│   ├── ace/             # AXI4-ACE (coherency extensions)
│   ├── axi4/            # AXI4 full protocol
│   ├── axi5/            # AXI5 (AMBA5) protocol
│   ├── axil4/           # AXI4-Lite
│   ├── apb/             # APB protocol
│   ├── apb5/            # APB5 protocol
│   ├── axis4/           # AXI-Stream
│   ├── axis5/           # AXI-Stream v5
│   ├── dfi/             # DDR PHY Interface (DFI) v2.1-v5.x BFMs
│   ├── fifo/            # Generic FIFO
│   ├── gaxi/            # GAXI — validate FIFO-based interfaces on small blocks
│   ├── smbus/           # System Management Bus
│   ├── uart/            # UART serial
│   ├── wavedrom/        # Waveform visualization
│   └── shared/          # Common utilities
└── scoreboards/         # Transaction verification
    ├── base_scoreboard  # Base class for all scoreboards
    ├── apb / gaxi / fifo / axi4 / dfi scoreboards
    └── axi4/            # AXI4-specific scoreboards (dwidth converter)

Protocol BFMs

Each protocol package provides a complete set of verification components: masters (drivers), slaves (responders), monitors (passive observers), and packets (transaction representations).

Note (2026-10-12): RTL Design Sherpa's monitor system is branded Ocelus. The monitor BFM classes in this framework (APBMonitor, GAXIMonitor, AXISMonitor, ...) are the verification companions of that fabric — class names and the MonBus fabric name are unchanged by the brand.

AMBA Protocols

AXI4 (Advanced eXtensible Interface)

Full AXI4 protocol implementation with compliance checking and constrained randomization.

from CocoTBFramework.components.axi4.axi4_interfaces import AXI4MasterRead, AXI4MasterWrite
from CocoTBFramework.components.axi4.axi4_interfaces import AXI4SlaveRead, AXI4SlaveWrite
from CocoTBFramework.components.axi4.axi4_packet import AXI4Packet
from CocoTBFramework.components.axi4.axi4_compliance_checker import AXI4ComplianceChecker
from CocoTBFramework.components.axi4.axi4_sequence import AXI4Sequence, run_axi4_sequence

Key classes:

  • AXI4MasterRead / AXI4MasterWrite — Full-duplex master with integrated compliance
  • AXI4SlaveRead / AXI4SlaveWrite — Slave responder with configurable timing
  • AXI4ComplianceChecker — Protocol violation detection and tracking
  • AXI4Sequence / run_axi4_sequence — Directed-random sequence authoring and pipelined execution
  • AXI4Packet — Complete transaction representation with field formatting

AXI4-ACE (AXI Coherency Extensions)

AXI4 extended with coherency: ARSNOOP/AWSNOOP on the front side, plus the AC/CR/CD snoop channels and RACK/WACK acknowledges. Implements the cache-ip ACE-shaped port contract (onyx D2 subset).

from CocoTBFramework.components.ace import (
    AXI4ACEMasterRead,
    AXI4ACEMasterWrite,
    AXI4ACESnoopMaster,
    AXI4ACESnoopSlave,
    ACEComplianceChecker,
)

Key classes:

  • AXI4ACEMasterRead / AXI4ACEMasterWrite — Coherent front-side masters with auto-pulsed RACK/WACK
  • AXI4ACESnoopMaster / AXI4ACESnoopSlave — CCU-side initiator and cache-side responder for AC/CR/CD
  • ACEComplianceChecker — Snoop-order and CRRESP validity checker
  • ACEPacket / SnoopPacket — Transaction packets including snoop-channel factory methods
  • ACETransactionType / SnoopType / CRRESP / CacheState — Coherent transaction and state enumerations

AXI5

AMBA5-generation AXI with extended signals and features. Same class structure as AXI4.

from CocoTBFramework.components.axi5.axi5_interfaces import AXI5MasterRead, AXI5MasterWrite
from CocoTBFramework.components.axi5.axi5_compliance_checker import AXI5ComplianceChecker

AXI4-Lite

Simplified AXI for register-mapped peripherals.

from CocoTBFramework.components.axil4.axil4_interfaces import AXIL4MasterRead, AXIL4MasterWrite
from CocoTBFramework.components.axil4.axil4_compliance_checker import AXIL4ComplianceChecker

APB / APB5 (Advanced Peripheral Bus)

Simple bus protocol for low-bandwidth peripherals.

from CocoTBFramework.components.apb.apb_components import APBMaster, APBSlave, APBMonitor
from CocoTBFramework.components.apb.apb_packet import APBPacket
from CocoTBFramework.components.apb.apb_sequence import APBSequence
from CocoTBFramework.components.apb.apb_factories import create_apb4_monitor, create_apb4_scoreboard

AXI-Stream (AXIS4 / AXIS5)

Unidirectional streaming with handshake.

from CocoTBFramework.components.axis4.axis_master import AXISMaster
from CocoTBFramework.components.axis4.axis_slave import AXISSlave
from CocoTBFramework.components.axis4.axis_monitor import AXISMonitor
from CocoTBFramework.components.axis4.axis_packet import AXISPacket

Generic AXI (GAXI)

Lightweight valid/ready handshake protocol for validating individual FIFO-based interfaces on very small internal blocks. Interfaces can carry data packed into fields within a single bus, or have many discrete signals. Includes built-in coverage hooks and statistics tracking.

from CocoTBFramework.components.gaxi import GAXIMaster, GAXISlave, GAXIMonitor
from CocoTBFramework.components.gaxi import GaxiCoverageHook, register_coverage_hooks
from CocoTBFramework.components.gaxi.gaxi_packet import GAXIPacket
from CocoTBFramework.components.gaxi.gaxi_sequence import GAXISequence

Other Protocols

DFI (DDR PHY Interface)

DFI v2.1-v5.x master (memory controller side) and slave (PHY side) BFMs with per-version behavior classes, JEDEC timing enforcement, and DRAM state modeling.

from CocoTBFramework.components.dfi.dfi_master_mc import DFIMasterMC
from CocoTBFramework.components.dfi.dfi_slave_phy import DFISlavePHY
from CocoTBFramework.components.dfi.dfi_monitor import DFIMonitor

FIFO

Generic FIFO verification with masters, slaves, monitors, and command handling.

from CocoTBFramework.components.fifo.fifo_master import FIFOMaster
from CocoTBFramework.components.fifo.fifo_slave import FIFOSlave
from CocoTBFramework.components.fifo.fifo_monitor import FIFOMonitor

SMBus (System Management Bus)

SMBus/I2C protocol verification with open-drain tristate signal handling and CRC-8 PEC.

from CocoTBFramework.components.smbus.smbus_components import SMBusMaster, SMBusSlave, SMBusMonitor

UART

Serial UART protocol at the bit level.

from CocoTBFramework.components.uart.uart_components import UARTMaster, UARTSlave, UARTMonitor

Shared Utilities

Common infrastructure used across all protocol implementations.

from CocoTBFramework.components.shared.packet import Packet
from CocoTBFramework.components.shared.field_config import FieldConfig, FieldDefinition
from CocoTBFramework.components.shared.memory_model import MemoryModel
from CocoTBFramework.components.shared.flex_randomizer import FlexRandomizer
from CocoTBFramework.components.shared.packet_factory import PacketFactory
Module Purpose
packet.py Base class for all protocol packets with thread-safe field caching
field_config.py Type-safe field configuration and definition system
memory_model.py High-performance memory model with NumPy backend and region management
flex_randomizer.py Constrained randomization with ranges, sequences, and function-based generators
packet_factory.py Generic factory for creating packets across any protocol
master_statistics.py Master component metrics (throughput, latency, violations)
monitor_statistics.py Passive monitor statistics collection
arbiter_master.py Universal arbiter master with weighted/unweighted support
arbiter_monitor.py Round-robin and weighted arbitration monitoring
arbiter_compliance.py Arbiter protocol correctness validation
data_strategies.py Data collection and driving strategies
signal_mapping_helper.py Signal-to-field mapping and resolution
debug_object.py Base debugging utilities
protocol_error_handler.py Protocol error handling and reporting

Scoreboards

Queue-based transaction verification with protocol-specific comparators and cross-protocol adapters.

from CocoTBFramework.scoreboards.base_scoreboard import BaseScoreboard
from CocoTBFramework.scoreboards.gaxi_scoreboard import GAXIScoreboard
from CocoTBFramework.scoreboards.fifo_scoreboard import FIFOScoreboard
from CocoTBFramework.scoreboards.apb_scoreboard import APBScoreboard
from CocoTBFramework.scoreboards.apb_gaxi_scoreboard import APBGAXIScoreboard
Scoreboard Purpose
BaseScoreboard Foundation with queue-based expected vs actual comparison
GAXIScoreboard GAXI transaction verification with field configuration
APBScoreboard APB transaction verification
APBGAXIScoreboard APB-to-GAXI cross-protocol transformation verification
FIFOScoreboard FIFO transaction verification with memory adapters
AXI4Scoreboard AXI4 master/slave transaction matching with per-ID tracking
DFIScoreboard DFI semantic-shift event counting and assertion
AXI4DWidthConverterScoreboard AXI4 data width converter validation

Cross-Protocol Adapters

from CocoTBFramework.scoreboards.apb_gaxi_transformer import APBtoGAXITransformer

The scoreboard system includes transformers and adapters for verifying protocol bridges and converters (APB ↔ GAXI, GAXI ↔ Memory, etc.).


Waveform Visualization

Generate WaveJSON timing diagrams from simulation signals.

from CocoTBFramework.components.wavedrom.wavejson_gen import WaveJSONGenerator
from CocoTBFramework.components.wavedrom.signal_binder import WavedromSignalBinder
from CocoTBFramework.components.wavedrom.constraint_solver import TemporalConstraintSolver  # needs the [wavedrom] extra (OR-Tools)

Dependencies

Required

Package Purpose
cocotb>=1.9.0 Core simulation framework
cocotb-bus>=0.2.1 BusDriver/BusMonitor base classes
cocotb-coverage>=1.2.0 Coverage-driven verification
psutil>=5.9.0 System resource monitoring
rich>=14.0.0 Table display and formatting
numpy>=2.0.0 High-performance memory model backend

Optional Extras

pip install cocotb-framework[wavedrom]   # OR-Tools for constraint solving
pip install cocotb-framework[crc]        # CRC computation
pip install cocotb-framework[all]        # All optional dependencies

Development

# Install in development mode
pip install -e ".[dev,all]"

# Lint
ruff check src/

# Build distributable
python -m build

  • RTLDesignSherpa — Parent project with 350+ RTL modules, testbenches, and verification infrastructure
  • cocotb — Coroutine-based cosimulation framework
  • cocotb-bus — Bus driver and monitor base classes

License

MIT License. See LICENSE for details.

Metadata

Release files for cocotb-framework 1.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cocotb-framework 1.2.6
File Size Uploaded
cocotb_framework-1.2.6.tar.gz 670.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cocotb-framework 1.2.6
File Interpreter ABI Platform
cocotb_framework-1.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 1.5 MB

Release files / cocotb_framework-1.2.6.tar.gz

Download URL cocotb_framework-1.2.6.tar.gz
Size 670.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a4770908a081408971cf26a786c71555b8ed0fa143e111fa4c3b10dd6a12fcbc
BLAKE2b-256 checksum
How to use checksums
8e3ffb3ae89c183c60142571ab981ac25db5bb52157dd1631da80479677ae014
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release files / cocotb_framework-1.2.6-py3-none-any.whl

Download URL cocotb_framework-1.2.6-py3-none-any.whl
Size 810.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c101bc419a382697d15f906c8b5cd6d1257f422089acec8037b9e464e269655
BLAKE2b-256 checksum
How to use checksums
89ca595e8c990805093d44c2daa4e6d59135905d7d44d72082812b9a7bfc6eb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.6 This release

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.6.9

2 release files

0.6.8

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page