From 93c7fccaf707a3c83b429691d5d7365668e07843 Mon Sep 17 00:00:00 2001 From: Amir Kamil Date: Tue, 17 Jul 2007 06:12:06 +0100 Subject: [PATCH] fix a minor bug in the fleeterpreter ; add a bubble sort program --- contrib/sort.fleet | 107 ++++++++++++++++++++++++++++++++++++++ src/edu/berkeley/fleet/Main.java | 2 +- 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 contrib/sort.fleet diff --git a/contrib/sort.fleet b/contrib/sort.fleet new file mode 100644 index 0000000..e22f3a3 --- /dev/null +++ b/contrib/sort.fleet @@ -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 +// 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 +} diff --git a/src/edu/berkeley/fleet/Main.java b/src/edu/berkeley/fleet/Main.java index 51e7493..5310d58 100644 --- a/src/edu/berkeley/fleet/Main.java +++ b/src/edu/berkeley/fleet/Main.java @@ -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")) { -- 1.7.10.4