Buffer

This example shows how to use cosim.vhpidirect.VHPIDIRECT (see VHPIDIRECT to interact with VUnit’s internal string_ptr/byte_vector_ptr and/or integer_vector_ptr, from C and/or Python.

  • run.py: supports a custom CLI option, --build, that will set VU.set_sim_option("ghdl.elab_e", True).

  • corun.py: allows to dynamically load and run any of the simulation binaries built with run.py. Given a testbench name, it finds the corresponding binary and arguments JSON file. Then, it is loaded dynamically and data buffers allocated in Python are shared with the simulation.

Example session:

# python3 run.py --build -v
...

# ls vunit_out/cosim/
tb_external_byte_vector.json  tb_external_integer_vector.json  tb_external_string.json

# python3 corun.py tb_external_byte_vector
...

Note

GHDL with mcode backend does NOT generate executable binaries. In order to use the two-step workflow, eithe LLVM or GCC backends need to be used.

Note

corun.py depends on cosim.utils, which requires some additional dependencies. File requirements.txt can be used to install all of them at once.