SystemVerilog Struct To Python Script

In reply to desperadorocks:

If you want to call a Python script from SystemVerilog and don’t need the results back in SystemVerilog, you can use $system(“myPythonScript.py structAgs”);. You’ll need to format the structArgs as a recognizable tuple as there is no struct datatype in Python. The only way to get results back into SystemVerilog is through File I/O (Python script writes data to a file, SystemVerilog reads the file).

You can use SystemVerilog’s DPI to call C, and then use the Python’s C/C++ interface to call a Python script and set/get references to variables in the script so that you can exchange data between SystemVerilog and Python. See Python/C API Reference Manual — Python 3.11.4 documentation