Coverage Guide

Line, branch, and toggle code coverage collection and reporting.

RyuSim supports line, branch, and toggle code coverage. Pass coverage flags via your cocotb Makefile.

Enable coverage

Add coverage flags to EXTRA_ARGS in your Makefile:

SIM ?= ryusim TOPLEVEL_LANG := verilog VERILOG_SOURCES = $(PWD)/counter.sv TOPLEVEL = counter COCOTB_TEST_MODULES = test_counter # Enable coverage collection EXTRA_ARGS += --coverage --coverage-file=coverage.info include $(shell cocotb-config --makefiles)/Makefile.sim

Then run as usual:

make

Coverage types (use in EXTRA_ARGS):

View results

Requires the lcov package (sudo apt install lcov or brew install lcov).

genhtml coverage.info -o coverage_html

Functional coverage (covergroups)

RyuSim v2 supports native IEEE 1800-2023 clause-19 covergroups: bins (value, array, wildcard, ignore/illegal, transition), crosses with binsof selects, options, clocking-event and procedural sampling, and the 19.11 coverage computation (get_coverage/get_inst_coverage, merge_instances). Covergroup results ride the same coverage.info as code coverage (CGDA records — format subject to change until GA), merge across runs by bin-name identity via ryusim coverage merge, and render as per-covergroup pages in ryusim coverage html. The 19.9 system tasks ($get_coverage, $set_coverage_db_name, $load_coverage_db) are supported. See the coverage user guide for details.

Merge coverage

Combine coverage data from multiple test runs into a single report:

ryusim coverage merge -o merged.info test1.info test2.info