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

Merge coverage

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

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