dol: initial dol commit
[jump.git] / dol / src / dol / visitor / systemC / lib / dol.h
diff --git a/dol/src/dol/visitor/systemC/lib/dol.h b/dol/src/dol/visitor/systemC/lib/dol.h
new file mode 100644 (file)
index 0000000..282bc4d
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef DOL_H
+#define DOL_H
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+/************************************************************************
+ * do not add code to this header
+ ************************************************************************/
+
+/**
+ *  - Local variables for each process can be defined in the structure
+ *    LocalState. For each process, a new instance of LocalState  is
+ *    instantiated.
+ *  - The ProcessInit function pointer points to the function which is
+ *    called to initialize a process.
+ *  - The ProcessFire function pointer points to the function which is
+ *    called repeatedly by the scheduler.
+ *  - The wptr is a placeholder for callback. A pointer to the wrapper
+ *    class instance of the process can be assigned. This is done in the
+ *    code generated by the code generation, so 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
+
+/**
+ * macro to create a variable to store a port name
+ *
+ * @param name name of the variable
+ */
+#define MAX_PORT_NAME_LENGTH 255
+#define CREATEPORTVAR(name) char name[MAX_PORT_NAME_LENGTH]
+
+
+/**
+ * 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, indices...) \
+  createPort(port, base, number_of_indices, indices)
+
+char* createPort(char* port,
+                 char* base,
+                 int number_of_indices,
+                 int indices, ...);
+
+int getIndex(const char* string, char* tokens, int indexNumber);
+
+#endif