X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Flib%2Fdol.h;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Flib%2Fdol.h;h=8e9967133560f2322bdbf81a19553e0e8f3b4e48;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/hdsd/lib/dol.h b/dol/src/dol/visitor/hdsd/lib/dol.h new file mode 100644 index 0000000..8e99671 --- /dev/null +++ b/dol/src/dol/visitor/hdsd/lib/dol.h @@ -0,0 +1,141 @@ +#ifndef DOL_H +#define DOL_H + +#include +#include +#include + +#ifdef __DOL_ETHZ_GEN__ +#include +using sc_core::sc_port; +#endif + +/************************************************************************ + * do not add code to this header + ************************************************************************/ + +/** + * Define the DOL process handler scheme. + * - Local variables are defined in structure LocalState. Local + * variables may vary from different processes. + * - The ProcessInit function pointer points to a function which + * initializes a process. + * - The ProcessFire function pointer points to a function which + * performs the actual computation. The communication between + * processes is inside the ProcessFire function. + * - The WPTR is a placeholder for callback. One can just + * leave it blank. + */ + +//structure for local memory of process +typedef struct _local_states *LocalState; + +//additional behavioral functions could be declared here +typedef void (*ProcessInit)(struct _process*); +typedef int (*ProcessFire)(struct _process*); +typedef void *WPTR; + +//process handler +struct _process; + +typedef struct _process { + LocalState local; + ProcessInit init; + ProcessFire fire; + WPTR wptr; //placeholder for wrapper instance +} DOLProcess; + + +//macros to deal with iterated ports +/** + ****************************************************** + * The HdS code is needed to replace the current ETHZ * + * implementation. * + ****************************************************** + * + * Macro to create a variable to store a port name. + * + * @param name name of the variable + */ +#ifdef __DOL_ETHZ_GEN__ +#define CREATEPORTVAR(name) sc_port *name +#else +#define CREATEPORTVAR(name) // Hds Code +#endif + +/** + * Create the port name of an iterated port based on its basename and the + * given indices. + * + * @param port buffer where the result is stored (created using + * CREATEPORTVAR) + * @param base basename of the port + * @param number_of_indices number of dimensions of the port + * @param index_range_pairs index and range values for each dimension + */ +#define CREATEPORT(port, base, number_of_indices, index_range_pairs...) \ + createPort(&port, base, number_of_indices, index_range_pairs) + +int getIndex(const char* string, char* tokens, int indexNumber); + +/* + ****************************************************** + * The HdS code is needed to replace the current ETHZ * + * implementation. * + ****************************************************** + */ +#ifdef __DOL_ETHZ_GEN__ +template +sc_port *createPort(sc_port **port, + void *base, + int number_of_indices, + int index0, int range0) { + *port = &((static_cast *>(base))[index0]); + return &((static_cast *>(base))[index0]); +} + +template +sc_port *createPort(sc_port **port, + void *base, + int number_of_indices, + int index0, int range0, + int index1, int range1) { + *port = &((static_cast *>(base))[ + index0 * range1 + index1]); + return &((static_cast *>(base))[ + index0 * range1 + index1]); +} + +template +sc_port *createPort(sc_port **port, + void *base, + int number_of_indices, + int index0, int range0, + int index1, int range1, + int index2, int range2) { + *port = &((static_cast *>(base))[ + index0 * range1 * range2 + index1 * range0 + index2]); + return &((static_cast *>(base))[ + index0 * range1 * range2 + index1 * range0 + index2]); +} + +template +sc_port *createPort(sc_port **port, + void *base, + int number_of_indices, + int index0, int range0, + int index1, int range1, + int index2, int range2, + int index3, int range3) { + *port = &((static_cast *>(base))[ + index0 * range1 * range2 * range3 + + index1 * range2 * range3 + index2 * range3 + index3]); + return &((static_cast *>(base))[ + index0 * range1 * range2 * range3 + + index1 * range2 * range3 + index2 * range3 + index3]); +} +#else +#define createPort() //HdS code +#endif + +#endif