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
Thanks Dave. But wondering if there is any better way of formatting allowed in SV? Because this is a very basic example, but the complexity of the struct might be even more with multiple sub-structs, strings, arrays etc.
Thinking if we can write some functions which takes in a struct as input and print all the fields of the struct recursively [and for sub-structs re-call the function] or any such ideal flow which you will follow if you have to write something like this. :-)