CocoTB support#
The COCOTB command generates a ready-to-use Python script that integrates a Hog project with the cocotb hardware verification framework.
It reads the project’s Hog list files, resolves the full compile order (respecting library dependencies), and emits a self-contained Python file that calls cocotb_tools.runner to compile every HDL source and run a test against a chosen simulator.
Usage#
./Hog/Do COCOTB <project_name> [options]
<project_name> is the name of an existing Hog project (as listed by ./Hog/Do LIST).
Options#
Option |
Description |
|---|---|
|
Path to a pre-compiled simulation library (e.g. |
|
Absolute path for source files stored externally to the git repository. |
|
Enable verbose/debug output. |
What It Does#
Parses the project’s
.srcand.extHog list files to obtain the full source file set.Resolves the compile order using the Hog
Hierarchyutility.Writes a Python script named
cocotb_<project>.pyin the repository root.
The generated script contains:
test_placeholder– an empty@cocotb.test()coroutine to be replaced with actual test logic.build_libs(sim, build_dir)– iterates over every HDL source file in compile order and callsrunner.build()for each one, setting:hdl_libraryto the Hog library name for that file.build_argsto["-2008"]for VHDL files (plus-modelsiminiwhen a sim-lib path is provided).build_argswith+incdir+entries for every directory containing.svh/.vhheader files, for SystemVerilog/Verilog files.
run_test(sim, build_dir, toplevel)– callsrunner.test()against the generated test module.A
__main__block withargparsefor--sim,--build-dir, and--toplevel.
Output#
A single Python file is created at:
<repo_root>/cocotb_<project>.py
Running the Generated Script#
python cocotb_<project>.py --sim questa --toplevel <your_top_entity>
Argument |
Default |
Description |
|---|---|---|
|
|
Simulator backend (e.g. |
|
|
Directory where build artefacts are written. |
|
|
Name of the HDL top-level entity/module to test. |
Example#
# Generate the cocotb script for project MyFirmware
./Hog/Do COCOTB MyFirmware
# Optionally, point to a pre-compiled simulation library
./Hog/Do COCOTB MyFirmware -lib SimulationLib/
# Run the generated script with GHDL
python cocotb_MyFirmware.py --sim ghdl --toplevel my_top
Notes#
The generated script is a template: the placeholder test does nothing and must be replaced with meaningful verification logic.
The compile order emitted by the script mirrors Hog’s internal dependency resolution, so libraries are compiled before the design units that depend on them.
The
COCOTBcommand runs entirely intclshwithout launching any IDE.Supported HDL file extensions:
.vhd,.vhdl,.v,.sv,.svh,.vh.