Logo SoCRocket

Transaction-Level Modeling Framework for Space Applications

Files | Namespaces | Classes | Macros | Typedefs | Functions | Variables
Pysc
Collaboration diagram for Pysc:

Files

file  cci.cpp
 
file  cci.h
 
file  systemc.cpp
 
file  api.cpp
 
file  api.h
 
file  module.cpp
 
file  module.h
 
file  registry.cpp
 
file  registry.h
 
file  usi.h
 

Namespaces

 pysc
 
 blas
 

Classes

class  PythonModule
 
class  PyScModule
 
class  PyScObjectGenerator
 

Macros

#define PyString_FromString(x)   PyUnicode_FromStringAndSize(x, strlen(x))
 
#define PYSC_REGISTER_MODULE(name)
 
#define PYSC_THIS_MODULE()   (__pysc_module)
 
#define PyScThisModule()   (__pysc_module)
 
#define PYSC_INIT_MODULES()   PyScModule::registerEmbedded();
 
#define PYSC_PREPARE_MODULES()   PyScModule::prepareEmbedded();
 
#define PYSC_HAS_MODULE(name)
 
#define PYSC_REGISTER_OBJECT_GENERATOR(funct)
 
#define PYSC_REGISTER_OBJECT(type)
 
#define usi_init   pysc_init
 
#define usi_load   pysc_load
 
#define usi_start_of_initialization   pysc_start_of_initialization
 
#define usi_end_of_initialization   pysc_end_of_initialization
 
#define usi_start   pysc_start
 
#define USI_INIT_MODULES   PYSC_INIT_MODULES
 
#define USI_HAS_MODULE(module)   PYSC_HAS_MODULE(module)
 
#define USI_REGISTER_MODULE(module)   PYSC_REGISTER_MODULE(module)
 
#define USI_REGISTER_OBJECT_GENERATOR(if)   PYSC_REGISTER_OBJECT_GENERATOR(if)
 
#define USI_REGISTER_OBJECT(if)   PYSC_REGISTER_OBJECT(if)
 

Typedefs

typedef PyObjectPyScObject
 
typedef struct _object PyObject
 
typedef struct _ts PyThreadState
 
typedef PyScObject USIObject
 

Functions

 USI_REGISTER_MODULE (cci)
 
 USI_REGISTER_MODULE (systemc)
 
void pysc_init (int argc, char *argv[])
 
void pysc_load (const char *module)
 
void pysc_start_of_initialization ()
 
void pysc_end_of_initialization ()
 
void pysc_signal_handler (int sig)
 
void pysc_start ()
 
const charstr_value (const char *str)
 
 PythonModule::PythonModule (sc_core::sc_module_name name, const char *script_filename=0, int argc=0, char **argv=NULL)
 
virtual PythonModule::~PythonModule ()
 
void PythonModule::load (std::string script)
 
void PythonModule::exec (std::string statement)
 runs a Python command in a module-specific namespace More...
 
void PythonModule::add_to_pythonpath (std::string path)
 Adds a path to the load/import search path. More...
 
void PythonModule::start_of_initialization ()
 
void PythonModule::end_of_initialization ()
 
void PythonModule::start_of_elaboration ()
 
void PythonModule::end_of_elaboration ()
 
void PythonModule::start_of_simulation ()
 
void PythonModule::pause_of_simulation ()
 
void PythonModule::end_of_simulation ()
 
void PythonModule::start_of_evaluation ()
 
void PythonModule::end_of_evaluation ()
 
static void PythonModule::block_threads ()
 
static void PythonModule::unblock_threads ()
 Unblock our singleton thread. More...
 
 PyScModule::PyScModule (const char *, init_f funct=NULL)
 
static void PyScModule::registerEmbedded ()
 
static void PyScModule::prepareEmbedded ()
 
 PyScObjectGenerator::PyScObjectGenerator (generator_f funct=NULL)
 
static PyObjectPyScObjectGenerator::find_object_by_ptr (sc_core::sc_object *obj)
 
static sc_core::sc_object * PyScObjectGenerator::find_object_by_name (std::string name)
 

Variables

void(* cpp_sigint )(int) = NULL
 
void(* cpp_sigterm )(int) = NULL
 
static PythonModulePythonModule::globalInstance = NULL
 Global PythonModule Instance (The last created one) More...
 

Detailed Description

Macro Definition Documentation

#define PYSC_HAS_MODULE (   name)
Value:
extern PyScModule *__pysc_module_##name; \
__pysc_module_##name->embedded = true;
Definition: registry.h:19
string name
Definition: setup.py:15
#define PYSC_INIT_MODULES ( )    PyScModule::registerEmbedded();
#define PYSC_PREPARE_MODULES ( )    PyScModule::prepareEmbedded();
#define PYSC_REGISTER_MODULE (   name)
Value:
extern "C" { \
void init_##name(void); \
}; \
static PyScModule __pysc_module("_"#name, init_##name); \
volatile PyScModule *__pysc_module_##name = &__pysc_module;
Definition: registry.h:19
string name
Definition: setup.py:15
#define PYSC_REGISTER_OBJECT (   type)
Value:
PyObject *find_##type##_object(sc_core::sc_object *obj, std::string name) { \
PyObject *result = NULL; \
type *instance = dynamic_cast<type *>(obj); \
if(instance) { \
result = SWIG_NewPointerObj(SWIG_as_voidptr(instance), SWIGTYPE_p_##type, 0); \
} \
return result; \
} \
PYSC_REGISTER_OBJECT_GENERATOR(find_##type##_object);
#define PYSC_REGISTER_OBJECT_GENERATOR(funct)
Definition: registry.h:86
complex32 result[64]
Definition: results.h:4
struct _object PyObject
Definition: module.h:20
string name
Definition: setup.py:15
#define PYSC_REGISTER_OBJECT_GENERATOR (   funct)
Value:
static PyScObjectGenerator __pysc_generator_##funct##__(&funct); \
volatile PyScObjectGenerator *__pysc_generator_##funct = &__pysc_generator_##funct##__;
Definition: registry.h:72
#define PYSC_THIS_MODULE ( )    (__pysc_module)
#define PyScThisModule ( )    (__pysc_module)
#define PyString_FromString (   x)    PyUnicode_FromStringAndSize(x, strlen(x))
#define usi_end_of_initialization   pysc_end_of_initialization
#define USI_HAS_MODULE (   module)    PYSC_HAS_MODULE(module)

Referenced by sc_main().

#define usi_init   pysc_init

Referenced by sc_main().

#define USI_INIT_MODULES   PYSC_INIT_MODULES
#define usi_load   pysc_load

Referenced by sc_main().

#define USI_REGISTER_MODULE (   module)    PYSC_REGISTER_MODULE(module)
#define USI_REGISTER_OBJECT (   if)    PYSC_REGISTER_OBJECT(if)
#define USI_REGISTER_OBJECT_GENERATOR (   if)    PYSC_REGISTER_OBJECT_GENERATOR(if)
#define usi_start   pysc_start

Referenced by sc_main().

#define usi_start_of_initialization   pysc_start_of_initialization

Referenced by sc_main().

Typedef Documentation

typedef struct _object PyObject
typedef PyObject* PyScObject
typedef struct _ts PyThreadState

Function Documentation

void PythonModule::add_to_pythonpath ( std::string  path)

Adds a path to the load/import search path.

References PythonModule::block_threads(), PyString_FromString, and PythonModule::unblock_threads().

Referenced by PythonModule::PythonModule().

Here is the call graph for this function:

void PythonModule::block_threads ( )
static

Block out singleton thread This should not be neccesarry but who knows

Todo:
: This is not good we shuld think about removing the blocks

Referenced by PythonModule::add_to_pythonpath(), pysc::api::cci::CallbackAdapter::call(), PythonModule::exec(), PythonModule::load(), and PythonModule::PythonModule().

void PythonModule::end_of_elaboration ( )
void PythonModule::end_of_evaluation ( )

Referenced by pysc_start().

void PythonModule::end_of_initialization ( )
void PythonModule::end_of_simulation ( )
void PythonModule::exec ( std::string  statement)

runs a Python command in a module-specific namespace

References PythonModule::block_threads(), and PythonModule::unblock_threads().

Referenced by PythonModule::PythonModule().

Here is the call graph for this function:

sc_core::sc_object * PyScObjectGenerator::find_object_by_name ( std::string  name)
static

References sc_find_by_name().

Referenced by USIDelegate::USIDelegate().

Here is the call graph for this function:

PyObject * PyScObjectGenerator::find_object_by_ptr ( sc_core::sc_object *  obj)
static

References i, and result.

Referenced by USIDelegate::USIDelegate().

void PythonModule::load ( std::string  script)

References PythonModule::block_threads(), setup::name, s, and PythonModule::unblock_threads().

Referenced by pysc_load(), and PythonModule::PythonModule().

Here is the call graph for this function:

void PythonModule::pause_of_simulation ( )

Referenced by pysc_start().

void PyScModule::prepareEmbedded ( )
static
void pysc_end_of_initialization ( )

This function marks the end of the initialization. It will call all python dunctions registered to this phase.

References PythonModule::end_of_initialization().

Here is the call graph for this function:

void pysc_init ( int  argc,
char argv[] 
)

Initialize the USI Python environment. Take the application argc argv arguments to provide them to the python script. Therefore the scripting environment can be used to initialize the simulation.

Parameters
argcNumber of arguments
argvList of arguments
void pysc_load ( const char module)

Load a python script by file path or module name. This function instructs the USI Pythn environment to execute a python script. The script can be either provided as a file path ending with the file extension .py. Or it can be a hierachial python module path rooted in the SoCRocket top level directory or linked into the site-packages of the venv of SoCRocket.

Parameters
moduleModule name or path.

References PythonModule::load().

Here is the call graph for this function:

void pysc_signal_handler ( int  sig)

The signal handler for the python environment. It should be registered in order to use system signals with the simulation.

Parameters
sigthe signal sent to the process.

References cpp_sigint, cpp_sigterm, and pysc::api::systemc::wait().

Referenced by pysc_start().

Here is the call graph for this function:

void pysc_start ( )

Starts the simulation. This is a wrapper for sc_start. It extens the simulation environment with the capapbility to react on simulation interruptions. Therefore if the user presses Ctrl-c during simulation or sc_pause() is executed during simulation all scripts registered to the phase pause_of_simulation are executed until the simulation will be started again.

References cpp_sigint, cpp_sigterm, PythonModule::end_of_evaluation(), PythonModule::end_of_initialization(), PythonModule::pause_of_simulation(), pysc_signal_handler(), PythonModule::signal, and PythonModule::start_of_evaluation().

Here is the call graph for this function:

void pysc_start_of_initialization ( )

This function marks the begin of the initialization. It will call all python functions registered to this phase.

References PythonModule::start_of_initialization().

Here is the call graph for this function:

PyScModule::PyScModule ( const char name,
PyScModule::init_f  funct = NULL 
)
PyScObjectGenerator::PyScObjectGenerator ( PyScObjectGenerator::generator_f  funct = NULL)
PythonModule::PythonModule ( sc_core::sc_module_name  name,
const char script_filename = 0,
int  argc = 0,
char **  argv = NULL 
)

References PythonModule::add_to_pythonpath(), usi.shell::args(), PythonModule::block_threads(), PythonModule::exec(), getWafConfig(), i, PythonModule::load(), setup::name, PYSC_INIT_MODULES, PYSC_PREPARE_MODULES, PyString_FromString, and PythonModule::unblock_threads().

Here is the call graph for this function:

void PyScModule::registerEmbedded ( )
static
void PythonModule::start_of_elaboration ( )
void PythonModule::start_of_evaluation ( )

Referenced by pysc_start().

void PythonModule::start_of_initialization ( )
void PythonModule::start_of_simulation ( )
const char* str_value ( const char str)
void PythonModule::unblock_threads ( )
static
USI_REGISTER_MODULE ( systemc  )
USI_REGISTER_MODULE ( cci  )
PythonModule::~PythonModule ( )
virtual

Variable Documentation

void(* cpp_sigint)(int) = NULL

Referenced by pysc_signal_handler(), and pysc_start().

void(* cpp_sigterm)(int) = NULL

Referenced by pysc_signal_handler(), and pysc_start().

PythonModule * PythonModule::globalInstance = NULL
static

Global PythonModule Instance (The last created one)