--- /dev/null
+# Makefile to generate a DOL program
+
+# Target List:
+# all -- generate the main executable [default]
+# run -- run the main executable
+# systemc -- generate SystemC code and Makefile.new
+# dotty -- show flattened process network
+# clean -- clean all generated files
+
+PROGRAM = example1
+
+# change according to your system
+DOLPATH = /home/basti/dol/bin
+SYSTEMC_INC = /home/basti/systemc/include
+SYSTEMC_LIB = /home/basti/systemc/lib-linux64/libsystemc.a
+
+# list of programs
+JAVA ?= java
+JAVAC ?= javac
+DOTTY ?= dotty
+ECHO ?= echo
+SED ?= sed
+CP ?= cp
+RM ?= rm
+
+# don't change anything below
+# ===========================================================================
+
+CLASSPATH = $(DOLPATH)/dol.jar:$(DOLPATH)/jdom.jar:$(DOLPATH)/xercesImpl.jar
+.PHONY : all run systemc dotty clean
+
+all: $(PROGRAM)
+
+systemc: systemc/src/Makefile.new
+
+run: $(PROGRAM)
+ @$(ECHO) "\t[RUN]\t$^"
+ @./$(PROGRAM)
+
+clean:
+ @$(ECHO) "\t[CLEAN]"
+ @$(RM) -rf $(PROGRAM) systemc/ $(PROGRAM)_flattened.xml \
+ $(PROGRAM)_Generator.java $(PROGRAM)_Generator.class \
+ $(PROGRAM).dot profile.txt
+
+$(PROGRAM): systemc/src/sc_application
+ @$(ECHO) "\t[COPY]\t$@"
+ @$(CP) $^ $@
+
+systemc/src/sc_application: systemc/src/Makefile.new
+ @$(ECHO) "\t[MAKE]\t$<"
+ @$(MAKE) -f Makefile.new -C systemc/src
+
+systemc/src/Makefile.new: systemc/src/Makefile
+ @$(ECHO) "\t[GEN]\t$@"
+ @$(SED) -e 's@^SYSTEMC_INC.*@SYSTEMC_INC = -I $(SYSTEMC_INC)@' \
+ -e 's@^SYSTEMC_LIB.*@SYSTEMC_LIB = $(SYSTEMC_LIB)@' \
+ -e 's@# -lpthread@-lpthread #@' \
+ systemc/src/Makefile > systemc/src/Makefile.new
+
+systemc/src/Makefile: $(PROGRAM)_flattened.xml
+ @$(ECHO) "\t[GEN]\t$@"
+ @$(JAVA) -cp $(CLASSPATH) dol.main.Main -P $(PROGRAM)_flattened.xml \
+ -H systemc -c >/dev/null
+
+$(PROGRAM)_flattened.xml: $(PROGRAM).xml
+ @$(ECHO) "\t[FLAT]\t$^"
+ @$(JAVA) -cp $(CLASSPATH) dol.helper.flattener.XMLFlattener \
+ $(PROGRAM).xml $(PROGRAM)_Generator >/dev/null
+ @$(JAVAC) $(PROGRAM)_Generator.java
+ @$(JAVA) $(PROGRAM)_Generator > $(PROGRAM)_flattened.xml
+
+$(PROGRAM).dot: $(PROGRAM)_flattened.xml
+ @$(ECHO) "\t[GEN]\t$@"
+ @$(JAVA) -cp $(CLASSPATH) dol.main.Main -P $(PROGRAM)_flattened.xml \
+ -D $(PROGRAM).dot -c >/dev/null
+
+dotty: $(PROGRAM).dot
+ @$(ECHO) "\t[RUN]\t$(DOTTY) $(PROGRAM).dot"
+ @$(DOTTY) $(PROGRAM).dot
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<processnetwork name="example1"
+ xmlns="http://www.tik.ee.ethz.ch/~shapes/schema/PROCESSNETWORK"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.tik.ee.ethz.ch/~shapes/schema/PROCESSNETWORK
+ http://www.tik.ee.ethz.ch/~shapes/schema/processnetwork.xsd">
+
+ <!-- processes -->
+ <process name="generator">
+ <port type="output" name="1"/>
+ <source type="c" location="generator.c"/>
+ </process>
+
+ <process name="consumer">
+ <port type="input" name="1"/>
+ <source type="c" location="consumer.c"/>
+ </process>
+
+ <process name="square">
+ <port type="input" name="1"/>
+ <port type="output" name="2"/>
+ <source type="c" location="square.c"/>
+ </process>
+
+ <!-- sw_channels -->
+ <sw_channel type="fifo" size="10" name="C1">
+ <port type="input" name="0"/>
+ <port type="output" name="1"/>
+ </sw_channel>
+
+ <sw_channel type="fifo" size="10" name="C2">
+ <port type="input" name="0"/>
+ <port type="output" name="1"/>
+ </sw_channel>
+
+ <!-- connections -->
+ <connection name="g-c">
+ <origin name="generator">
+ <port name="1"/>
+ </origin>
+ <target name="C1">
+ <port name="0"/>
+ </target>
+ </connection>
+
+ <connection name="c-c">
+ <origin name="C2">
+ <port name="1"/>
+ </origin>
+ <target name="consumer">
+ <port name="1"/>
+ </target>
+ </connection>
+
+ <connection name="s-c">
+ <origin name="square">
+ <port name="2"/>
+ </origin>
+ <target name="C2">
+ <port name="0"/>
+ </target>
+ </connection>
+
+ <connection name="c-s">
+ <origin name="C1">
+ <port name="1"/>
+ </origin>
+ <target name="square">
+ <port name="1"/>
+ </target>
+ </connection>
+</processnetwork>
--- /dev/null
+# Makefile to generate a DOL program
+
+# Target List:
+# dotty -- show flattened process network
+# systemc -- generate SystemC code
+# all -- generate the main executable
+# run -- run SystemC example
+
+PROGRAM = example1
+
+# change according to your system
+DOLPATH = /home/basti/dol/bin
+SYSTEMC_INC = /home/basti/systemc/include
+SYSTEMC_LIB = /home/basti/systemc/lib-linux64/libsystemc.a
+
+# list of programs
+JAVA ?= java
+JAVAC ?= javac
+DOTTY ?= dotty
+ECHO ?= echo
+SED ?= sed
+CP ?= cp
+RM ?= rm
+
+# don't change anything below
+# ===========================================================================
+
+CLASSPATH = $(DOLPATH)/dol.jar:$(DOLPATH)/jdom.jar:$(DOLPATH)/xercesImpl.jar
+
+all: $(PROGRAM)
+
+systemc: systemc/src/Makefile.new
+
+clean:
+ @$(ECHO) "\t[CLEAN]"
+ @$(RM) -rf $(PROGRAM) systemc/ $(PROGRAM)_flattened.xml \
+ $(PROGRAM)_Generator.java $(PROGRAM)_Generator.class \
+ $(PROGRAM).dot
+
+$(PROGRAM): systemc/src/sc_application
+ @$(ECHO) "\t[COPY]\t$@"
+ @$(CP) $^ $@
+
+systemc/src/sc_application: systemc/src/Makefile.new
+ @$(ECHO) "\t[MAKE]\t$<"
+ @$(MAKE) -f Makefile.new -C systemc/src
+
+systemc/src/Makefile.new: systemc/src/Makefile
+ @$(ECHO) "\t[GEN]\t$@"
+ @$(SED) -e 's@^SYSTEMC_INC.*@SYSTEMC_INC = -I $(SYSTEMC_INC)@' \
+ -e 's@^SYSTEMC_LIB.*@SYSTEMC_LIB = $(SYSTEMC_LIB)@' \
+ -e 's@# -lpthread@-lpthread #@' \
+ systemc/src/Makefile > systemc/src/Makefile.new
+
+systemc/src/Makefile: $(PROGRAM)_flattened.xml
+ @$(ECHO) "\t[GEN]\t$@"
+ @$(JAVA) -cp $(CLASSPATH) dol.main.Main -P $(PROGRAM)_flattened.xml \
+ -H systemc -c >/dev/null
+
+$(PROGRAM)_flattened.xml: $(PROGRAM).xml
+ @$(ECHO) "\t[FLAT]\t$^"
+ @$(JAVA) -cp $(CLASSPATH) dol.helper.flattener.XMLFlattener \
+ $(PROGRAM).xml $(PROGRAM)_Generator >/dev/null
+ @$(JAVAC) $(PROGRAM)_Generator.java
+ @$(JAVA) $(PROGRAM)_Generator > $(PROGRAM)_flattened.xml
+
+$(PROGRAM).dot: $(PROGRAM)_flattened.xml
+ @$(ECHO) "\t[GEN]\t$@"
+ @$(JAVA) -cp $(CLASSPATH) dol.main.Main -P $(PROGRAM)_flattened.xml \
+ -D $(PROGRAM).dot -c >/dev/null
+
+dotty: $(PROGRAM).dot
+ @$(ECHO) "\t[RUN]\t$(DOTTY) $(PROGRAM).dot"
+ @$(DOTTY) $(PROGRAM).dot
+
--- /dev/null
+#include <stdio.h>
+
+#include "consumer.h"
+
+void consumer_init(DOLProcess *p) {
+ sprintf(p->local->name, "consumer");
+ p->local->index = 0;
+ p->local->len = LENGTH;
+}
+
+int consumer_fire(DOLProcess *p) {
+ float c;
+ if (p->local->index < p->local->len) {
+ DOL_read((void*)PORT_IN, &c, sizeof(float), p);
+ printf("%s: %f\n", p->local->name, c);
+ p->local->index++;
+ }
+
+ if (p->local->index >= p->local->len) {
+ DOL_detach(p);
+ return -1;
+ }
+
+ return 0;
+}
+
--- /dev/null
+#ifndef CONSUMER_H
+#define CONSUMER_H
+
+#include <dol.h>
+#include "global.h"
+
+#define PORT_IN 1
+
+typedef struct _local_states {
+ char name[10];
+ int index;
+ int len;
+} Consumer_State;
+
+void consumer_init(DOLProcess *);
+int consumer_fire(DOLProcess *);
+
+#endif
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<processnetwork name="example1"
+ xmlns="http://www.tik.ee.ethz.ch/~shapes/schema/PROCESSNETWORK"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.tik.ee.ethz.ch/~shapes/schema/PROCESSNETWORK
+ http://www.tik.ee.ethz.ch/~shapes/schema/processnetwork.xsd">
+
+ <!-- processes -->
+ <process name="generator">
+ <port type="output" name="1"/>
+ <source type="c" location="generator.c"/>
+ </process>
+
+ <process name="consumer">
+ <port type="input" name="1"/>
+ <source type="c" location="consumer.c"/>
+ </process>
+
+ <process name="square">
+ <port type="input" name="1"/>
+ <port type="output" name="2"/>
+ <source type="c" location="square.c"/>
+ </process>
+
+ <!-- sw_channels -->
+ <sw_channel type="fifo" size="10" name="C1">
+ <port type="input" name="0"/>
+ <port type="output" name="1"/>
+ </sw_channel>
+
+ <sw_channel type="fifo" size="10" name="C2">
+ <port type="input" name="0"/>
+ <port type="output" name="1"/>
+ </sw_channel>
+
+ <!-- connections -->
+ <connection name="g-c">
+ <origin name="generator">
+ <port name="1"/>
+ </origin>
+ <target name="C1">
+ <port name="0"/>
+ </target>
+ </connection>
+
+ <connection name="c-c">
+ <origin name="C2">
+ <port name="1"/>
+ </origin>
+ <target name="consumer">
+ <port name="1"/>
+ </target>
+ </connection>
+
+ <connection name="s-c">
+ <origin name="square">
+ <port name="2"/>
+ </origin>
+ <target name="C2">
+ <port name="0"/>
+ </target>
+ </connection>
+
+ <connection name="c-s">
+ <origin name="C1">
+ <port name="1"/>
+ </origin>
+ <target name="square">
+ <port name="1"/>
+ </target>
+ </connection>
+</processnetwork>
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include "generator.h"
+
+// initialization function
+void generator_init(DOLProcess *p) {
+ p->local->index = 0;
+ p->local->len = LENGTH;
+}
+
+int generator_fire(DOLProcess *p) {
+
+ if (p->local->index < p->local->len) {
+ float x = (float)p->local->index;
+ DOL_write((void*)PORT_OUT, &(x), sizeof(float), p);
+ p->local->index++;
+ }
+
+ if (p->local->index >= p->local->len) {
+ DOL_detach(p);
+ return -1;
+ }
+
+ return 0;
+}
+
--- /dev/null
+#ifndef GENERATOR_H
+#define GENERATOR_H
+
+#include <dol.h>
+#include "global.h"
+
+#define PORT_OUT 1
+
+typedef struct _local_states {
+ int index;
+ int len;
+} Generator_State;
+
+void generator_init(DOLProcess *);
+int generator_fire(DOLProcess *);
+
+#endif
--- /dev/null
+#ifndef GLOBAL_H
+#define GLOBAL_H
+
+#include <stdio.h>
+
+#define ARRAY_LEN 10
+#define DEBUG 1
+#define LENGTH 16
+
+#endif
--- /dev/null
+#include <stdio.h>
+
+#include "square.h"
+
+void square_init(DOLProcess *p) {
+ p->local->index = 0;
+ p->local->len = LENGTH;
+}
+
+int square_fire(DOLProcess *p) {
+ float i;
+
+ if (p->local->index < p->local->len) {
+ DOL_read((void*)PORT_IN, &i, sizeof(float), p);
+ i = i*i;
+ DOL_write((void*)PORT_OUT, &i, sizeof(float), p);
+ p->local->index++;
+ }
+
+ if (p->local->index >= p->local->len) {
+ DOL_detach(p);
+ return -1;
+ }
+
+ return 0;
+}
+
--- /dev/null
+#ifndef SQUARE_H
+#define SQUARE_H
+
+#include <dol.h>
+#include "global.h"
+
+#define PORT_IN 1
+#define PORT_OUT 2
+
+typedef struct _local_states {
+ int index;
+ int len;
+} Square_State;
+
+void square_init(DOLProcess *);
+int square_fire(DOLProcess *);
+
+#endif