Sharing Simulation Functions
If you want to share code between multiple cocotb testbenches, you can place re-usable python modules in a test_api directory in your project. These python modules can then be imported in any testbenches in your project, or projects that depend on your project.
Put these routines into a test_api directory
You need to add an empty test_api/__init__.py so that python recognizes the directory as a module
From your test python code you can now use them like so
# ...
import <swim_project_name>.<some_module>
from <swim_project_name>.<some_module> import <something>
# ...Python will place bytecode next to the python files in the test_api directory, add the following to your .gitignore to ignore them automatically.
# Python Bytecode
**/__pycache__