dol: initial dol commit
[jump.git] / dol / src / dol / visitor / systemC / lib / dol.h
1 #ifndef DOL_H
2 #define DOL_H
3
4 #include <stdarg.h>
5 #include <stdio.h>
6 #include <string.h>
7 #include <stdlib.h>
8
9 /************************************************************************
10  * do not add code to this header
11  ************************************************************************/
12
13 /**
14  *  - Local variables for each process can be defined in the structure
15  *    LocalState. For each process, a new instance of LocalState  is
16  *    instantiated.
17  *  - The ProcessInit function pointer points to the function which is
18  *    called to initialize a process.
19  *  - The ProcessFire function pointer points to the function which is
20  *    called repeatedly by the scheduler.
21  *  - The wptr is a placeholder for callback. A pointer to the wrapper
22  *    class instance of the process can be assigned. This is done in the
23  *    code generated by the code generation, so one can just leave it
24  *    blank.
25  */
26
27 //structure for local memory of process
28 typedef struct _local_states *LocalState;
29
30 //additional behavioral functions could be declared here
31 typedef void (*ProcessInit)(struct _process*);
32 typedef int (*ProcessFire)(struct _process*);
33 typedef void *WPTR;
34
35 //process handler
36 struct _process;
37
38 typedef struct _process {
39     LocalState     local;
40     ProcessInit    init;
41     ProcessFire    fire;
42     WPTR           wptr; //placeholder for wrapper instance
43 } DOLProcess;
44
45
46 //macros to deal with iterated ports
47
48 /**
49  * macro to create a variable to store a port name
50  *
51  * @param name name of the variable
52  */
53 #define MAX_PORT_NAME_LENGTH 255
54 #define CREATEPORTVAR(name) char name[MAX_PORT_NAME_LENGTH]
55
56
57 /**
58  * Create the port name of an iterated port based on its basename and the
59  * given indices.
60  *
61  * @param port buffer where the result is stored (created using
62  *             CREATEPORTVAR)
63  * @param base basename of the port
64  * @param number_of_indices number of dimensions of the port
65  * @param index_range_pairs index and range values for each dimension
66  */
67 #define CREATEPORT(port, base, number_of_indices, indices...) \
68   createPort(port, base, number_of_indices, indices)
69
70 char* createPort(char* port,
71                  char* base,
72                  int number_of_indices,
73                  int indices, ...);
74
75 int getIndex(const char* string, char* tokens, int indexNumber);
76
77 #endif