fix a minor bug in the fleeterpreter ; add a bubble sort program
authorAmir Kamil <kamil@cs.berkeley.edu>
Tue, 17 Jul 2007 05:12:06 +0000 (06:12 +0100)
committerAmir Kamil <kamil@cs.berkeley.edu>
Tue, 17 Jul 2007 05:12:06 +0000 (06:12 +0100)
contrib/sort.fleet [new file with mode: 0644]
src/edu/berkeley/fleet/Main.java

diff --git a/contrib/sort.fleet b/contrib/sort.fleet
new file mode 100644 (file)
index 0000000..e22f3a3
--- /dev/null
@@ -0,0 +1,107 @@
+// A bubble sort implementation.
+// This only works for 6 input elements. To change the number of input
+// elements, modify the counts in the lines marked below.
+// Author: Amir Kamil <kamil@cs.berkeley.edu>
+// Date:   7/16/07
+
+#import edu.berkeley.fleet.ships
+#ship alu          : Alu2b
+#ship blu          : Alu2b
+#ship debug        : Debug
+#ship fifo1        : Fifo
+#ship fifo2        : Fifo
+#ship fifo3        : Fifo
+#ship mem          : Memory
+
+#expect 1
+#expect 2
+#expect 3
+#expect 9
+#expect 8
+#expect 11
+
+// for debugging; the solution should work with any set of numbers
+
+9:          sendto fifo1.in;
+1:          sendto fifo1.in;
+3:          sendto fifo1.in;
+11:         sendto fifo1.in;
+2:          sendto fifo1.in;
+8:          sendto fifo1.in;
+
+// basic setup
+
+fifo1.in:   [*] take, deliver;
+fifo2.in:   [*] take, deliver;
+debug.in:   [*] take, deliver;
+alu.in1:    [*] take, deliver;
+alu.in2:    [*] take, deliver;
+blu.in1:    [*] take, deliver;
+blu.in2:    [*] take, deliver;
+fifo3.out:  [*] wait, take, sendto mem.inCBD;
+mem.inCBD:  [*] take, deliver;
+
+// one loop iteration
+// this code needs flow control
+
+ITER: {
+  fifo1.out:  take, sendto alu.in1.max;
+              sendto blu.in1.min;
+              [*] nop;
+              (*) take, sendto alu.in2;
+              (*) sendto blu.in2;
+              kill*;
+  alu.out:    [*] nop;
+              (*) take, sendto alu.in1.max;
+              (*) sendto blu.in1.min;
+              kill;
+  blu.out:    [5] take, sendto fifo2.in; // count = num - 1
+              notify fifo3.out;
+}
+
+// iteration cleanup
+
+END: {
+  0:          sendto alu.in2; // flush
+  0:          sendto blu.in2; // flush
+  fifo1.out:  kill;
+              kill;
+  alu.out:    kill;
+              kill;
+              sendto fifo2.in;
+              dismiss;
+  blu.out:    dismiss;
+  fifo2.out:  [6] take, sendto fifo1.in; // count = num
+              notify fifo3.out;
+}
+
+// overall control
+
+SENDDONE:   sendto fifo3.in;
+ITER:       sendto fifo2.in;
+END:        sendto fifo2.in;
+fifo2.out:  wait;
+            [*] nop;
+            (6) take, sendto fifo3.in;   // count = num
+            (6) sendto fifo2.in;         // count = num
+            (6) take, sendto fifo3.in;   // count = num
+            (6) sendto fifo2.in;         // count = num
+            kill*;
+fifo3.in:   take, deliver, notify fifo2.out;
+            [12] take, deliver;          // count = 2 * num
+            notify fifo3.out;
+            
+// send done cbd into fifo3
+
+SENDDONE: {
+  DONE:       sendto fifo3.in;
+  fifo2.out:  [2] dismiss;
+              notify fifo3.out;
+  fifo3.in:   take, deliver;
+}
+
+// done cbd
+
+DONE: {
+  fifo1.out:  [6] take, sendto debug.in; // count = num
+}
index 51e7493..5310d58 100644 (file)
@@ -43,7 +43,7 @@ public class Main {
             fleet = new Interpreter();
         }
 
-        if (!"true".equals(options.get("verbose")))
+        if (!"yes".equals(options.get("verbose")))
             Log.log = null;
 
         if (command.equals("run")) {