Kosim‎ > ‎

Python

Kosim provides a Python interface using Boost.Python. Boost.Python is designed to wrap C++ interfaces non-intrusively, so that C++ code should not be changed at all in order to be exposed to Python.

The entire SystemC simulator is loaded in python as a module named libkosim_name_of_test (e.g. libkosim_generic_cpu). This module is a dynamic library called libkosim_name_of_test.so (e.g. libkosim_generic_cpu.so). The C++ constructs that are wrapped in python are declared in one file named wrap_name_of_test.cpp (e.g. wrap_generic_cpu.cpp) that is located in main/name_of_test directory (e.g. main/generic_cpu/). To see the syntax of wrapping in Python C++ function, classes, etc. please check the documentation of Boost.Python.

Once a function is wrapped for Python, that function can be called in the python script that starts the test.
For example, the function run_sim() that starts the simulation is wrapped by:
def("run_sim", run_sim); // entry point in SystemC program

In the python script it is called
import libkosim_generic_cpu as kosim_generic_cpu
 ...
kosim_generic_cpu.run_sim()