Line, branch, and toggle code coverage collection and reporting.
RyuSim supports line, branch, and toggle code coverage. Pass coverage flags via your cocotb Makefile.
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):
--coverage — Full coverage (line, branch, toggle)--coverage-line — Line coverage only (fastest)--coverage-branch — Branch coverage--coverage-toggle — Toggle coverageRequires the lcov package (sudo apt install lcov or brew install lcov).
genhtml coverage.info -o coverage_html
Combine coverage data from multiple test runs into a single report:
ryusim coverage merge -o merged.info test1.info test2.info