new syntax: receive, notify, dismiss
authoradam <adam@megacz.com>
Fri, 16 Feb 2007 14:48:58 +0000 (15:48 +0100)
committeradam <adam@megacz.com>
Fri, 16 Feb 2007 14:48:58 +0000 (15:48 +0100)
src/edu/berkeley/fleet/api/Instruction.java
src/edu/berkeley/fleet/assembler/Parser.java
src/edu/berkeley/fleet/assembler/fleet.g
src/edu/berkeley/fleet/slipway/Slipway.java
tests/benkobox/kill-only-standing-instructions.fleet
tests/fifo/fifo-loop.fleet
tests/lut3/simple-lut3-test.fleet

index 263c40b..5e3c106 100644 (file)
@@ -65,16 +65,21 @@ public abstract class Instruction {
         public String toString() {
             String ret = benkoBox.toString() + ": ";
             if (count==0 || count>1 || recycle) {
-                ret += "[";
+                ret += recycle ? "(" : "[";
                 if (count>1) ret += count;
                 if (count==0) ret += "*";
-                if (recycle) ret += "r";
-                ret += "] ";
+                ret += recycle ? ")" : "] ";
             }
             boolean needcomma = false;
             if (tokenIn)           { ret += (needcomma ? ", " : "") + "wait";    needcomma = true; }
-            if (dataIn && latch)   { ret += (needcomma ? ", " : "") + "take";    needcomma = true; }
-            if (dataIn && !latch)  { ret += (needcomma ? ", " : "") + "discard"; needcomma = true; }
+            if (dataIn && latch)  {
+                if (benkoBox instanceof BenkoBox.Inbox)
+                    ret += (needcomma ? ", " : "") + "receive";
+                else
+                    ret += (needcomma ? ", " : "") + "take";
+                needcomma = true;
+            }
+            if (dataIn && !latch)  { ret += (needcomma ? ", " : "") + "dismiss"; needcomma = true; }
             if (dataOut)  {
                 if (benkoBox instanceof BenkoBox.Inbox || dest==null)
                     ret += (needcomma ? ", " : "") + "deliver";
@@ -82,7 +87,7 @@ public abstract class Instruction {
                     ret += (needcomma ? ", " : "") + "sendto "+dest;
                 needcomma = true;
             }
-            if (tokenOut) { ret += (needcomma ? ", " : "") + "ack "+dest; needcomma = true; }
+            if (tokenOut) { ret += (needcomma ? ", " : "") + "notify "+dest; needcomma = true; }
             return ret;
         }
 
index b2aeeda..1e3e12e 100644 (file)
@@ -222,15 +222,20 @@ public class Parser {
                 Tree ttx = null;
                 boolean recycle = false;
                 ttx = tt.child(1);
-                if (tt.size() > 1) {
-                    tt = tt.child(0);
-                    if (tt.size() > 0 && tt.child(0).size()>0) {
-                        tt = tt.child(0);
-                        if (tt.child(0).size() == 0) count=1;
-                        else if (tt.child(0).size() > 0 && "Star".equals(tt.child(0).child(0).head())) count=0;
-                        else count = Integer.parseInt(string(tt.child(0)));
-                        if (tt.size() > 1 && tt.child(1).size() > 0)
-                            recycle = true;
+                if (tt.size() > 1 && tt.child(0).size()>0) {
+                    tt = tt.child(0).child(0);
+                    if (tt.head().equals("BrackStar")) {
+                        count = 0;
+                        recycle = false;
+                    } else if (tt.head().equals("ParenStar")) {
+                        count = 0;
+                        recycle = true;
+                    } else if (tt.head().equals("Brack")) {
+                        count = Integer.parseInt(string(tt.child(0)));
+                        recycle = false;
+                    } else if (tt.head().equals("Paren")) {
+                        count = Integer.parseInt(string(tt.child(0)));
+                        recycle = true;
                     }
                 }
                 boolean tokenIn = false;
index 6d6fed0..736d4ae 100644 (file)
@@ -18,18 +18,22 @@ Statement       = Fiber::                  Source  ":" (Instruction +/ ws)     /
                 | CodeBagDescriptor::      CodeBag ":" "sendto" Port       ";" /ws
                 | NamedCodeBag::           name    ":" "{" CodeBagBody "}"     /ws
 
+CountField      = Brack::     "[" int "]"
+                | Paren::     "(" int ")"
+                | BrackStar:: "[*]"
+                | ParenStar:: "(*)"
 Instruction     = Instruction::
-                        (Brack:: "[" (int|(Star::"*"))? ("r")? "]" ws!)?
+                        (CountField ws!)?
                         (Command +/ (ws! "," ws!) ws! ";"!)
 Command         = Nop::      "nop"
                 | Kill::     "kill"
                 | KillStar:: "kill*"
                 | Wait::     "wait"
-                | Discard::  "discard"
-                | Take::     "take"
+                | Discard::  "dismiss"
+                | Take::     ("take"|"receive")
                 | SendTo::   "sendto" ws! Port
                 | Deliver::  "deliver"
-                | Ack::      "ack"    ws! Port
+                | Ack::      "notify" ws! Port
 
 Source         = Port
                | ShipSpecific
index c89b139..6c8d40b 100644 (file)
@@ -18,11 +18,10 @@ public class Slipway extends Interpreter {
 
     private String bitfile;
 
-    public Slipway() { this("superbowl2.bit"); }
+    public Slipway() { this("superbowl3.bit"); }
     public Slipway(String bitfile) {
         this.bitfile = bitfile;
         createShip("Debug",   "debug");
-        createShip("Fifo",    "fifo1");
         createShip("Alu2",    "alu2a");
         createShip("Alu2",    "alu2b");
         createShip("Alu2",    "alu2c");
index 8c74af5..9c3f456 100644 (file)
@@ -16,7 +16,7 @@ fifo2.out: wait, take, sendto fifo.in;
 
 fifo.out:
   [*] nop;
-  ack fifo2.out;
+  notify fifo2.out;
   take, sendto debug.in;
   take, sendto debug.in;
   kill*;
index 4edac1c..a0c713b 100644 (file)
@@ -11,5 +11,5 @@ fifo.in:
   take;
   [100] deliver;
 fifo.out:
-  [99r] take, sendto fifo.in;
-  [1r] take, sendto debug.in;
+  (99) take, sendto fifo.in;
+  (1)  take, sendto debug.in;
index d60e5e1..f087b1a 100644 (file)
@@ -281,12 +281,12 @@ alu.in: [*] take, deliver;
 0: sendto alu.in;
 alu.out:
   [*]  nop;
-  [*r] wait, take, sendto lut.inLut;
-  [*r] sendto alu.in;
+  (*) wait, take, sendto lut.inLut;
+  (*) sendto alu.in;
   kill;
 
 // acks from debug ship trigger new truth tables
-debug.in:   [*] take, deliver, ack alu.out;
+debug.in:   [*] take, deliver, notify alu.out;
 
 // kickoff
 0:           sendto lut.inLut;