Skip to main content

cocotb-coverage

Functional Coverage and Constrained Randomization Extensions for Cocotb

Documentation Status Regression Tests PyPI

This package allows you to use constrained randomization and functional coverage techniques known from CRV (constrained random verification) and MDV (metric-driven verification) methodologies, available in SystemVerilog or e. Such extensions enable the implementation of an advanced verification environment for complex projects.

The implemented functionality is intended to be easily understandable by SystemVerilog users and provides significant extensions compared to Hardware Verification Languages.

There is an option to export coverage database to a readable XML or YML format and a function which allows for merging such files is provided.

Installation

The package can be installed with pip. Version 2.0.0 is the latest one and recommended, adjusted for cocotb >= 2.0. For cocotb vesrions < 2.0, you may need to use 1.2.0 to get the examples and tests working. However, the core of cocotb-coverage is the same.

pip install cocotb-coverage

References

Roadmap

  • 2.0 released - 3 Oct 2025
  • 1.2 released - 15 Nov 2023
  • 1.1 released - 7 Aug 2020
  • Planned basic support for UCIS coverage database format
  • Any suggestions welcome - you are encouraged to open an issue!

Code Example

# point represented by x and y coordinates in range (-10,10)
class Point(crv.Randomized):

    def __init__(self, x, y):
        crv.Randomized.__init__(self)
        self.x = x
        self.y = y

        self.add_rand("x", list(range(-10, 10)))
        self.add_rand("y", list(range(-10, 10)))
        # constraining the space so that x < y
        self.add_constraint(lambda x, y: x < y)

...

# create an arbitrary point
p = Point(0,0)

for _ in range (10):

    # cover example arithmetic properties
    @CoverPoint("top.x_negative", xf = lambda point : point.x < 0, bins = [True, False])
    @CoverPoint("top.y_negative", xf = lambda point : point.y < 0, bins = [True, False])
    @CoverPoint("top.xy_equal", xf = lambda point : point.x == point.y, bins = [True, False])
    @CoverCross("top.cross", items = ["top.x_negative", "top.y_negative"])
    def plot_point(point):
        ...

    p.randomize()  # randomize object
    plot_point(p)  # call a function which will sample the coverage

# export coverage to XML
coverage_db.export_to_xml(filename="coverage.xml")
# export coverage to YAML
coverage_db.export_to_yaml(filename="coverage.yml")

Release files for cocotb-coverage 2.0

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

Built distribution (wheel)

Table of built distributions (wheels) for cocotb-coverage 2.0
File Interpreter ABI Platform
cocotb_coverage-2.0-py3-none-any.whl Python 3 none any Details

Release files / cocotb_coverage-2.0-py3-none-any.whl

Download URL cocotb_coverage-2.0-py3-none-any.whl
Size 21.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f65a15f7431b254bcb5f5a5d1b4676c5e89919546de4faaa4dbfda86f8300cb
BLAKE2b-256 checksum
How to use checksums
aecfc49f7a475f2d0303007f8a5aaf9e3cbe098179c6bb956d770e881e88735a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6
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