Generates type stubs for HDL designs to enable IDE autocomplete in cocotb testbenches.
- Add copra to your test dependencies
- Add copra to your Makefile:
COCOTB_TEST_MODULES = copra.integration.autostub,your_test_module - Run your cocotb tests - stubs generated in
copra_stubs.pyi
You can configure how copra works by setting environment variables:
| Variable name | Description | Default |
|---|---|---|
COPRA_STUB_DIRECTORY |
Directory to save stub file to | . |
COPRA_STUB_FILENAME |
Filename of file to store stubs in. Stub files should end in .pyi |
copra_stubs.pyi |
COPRA_MAX_DEPTH |
Maximum recursion depth of type discovery. | 100 |
Copra introspects the live cocotb hierarchy and maps HDL signals to cocotb handle types:
- Single logic →
LogicObject - Logic arrays →
LogicArrayObject - Unpacked arrays →
ArrayObject[...] - Generate blocks →
HierarchyArrayObject[...] - Modules →
HierarchyObject - Parameters →
IntegerObject
See examples directory.