From 85ffbc5fa6a1ea9ae28b2e0f3fde886f3c7ea8ed Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 16 Feb 2007 15:48:58 +0100 Subject: [PATCH] new syntax: receive, notify, dismiss --- src/edu/berkeley/fleet/api/Instruction.java | 17 ++++++++++----- src/edu/berkeley/fleet/assembler/Parser.java | 23 ++++++++++++-------- src/edu/berkeley/fleet/assembler/fleet.g | 12 ++++++---- src/edu/berkeley/fleet/slipway/Slipway.java | 3 +-- .../benkobox/kill-only-standing-instructions.fleet | 2 +- tests/fifo/fifo-loop.fleet | 4 ++-- tests/lut3/simple-lut3-test.fleet | 6 ++--- 7 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/edu/berkeley/fleet/api/Instruction.java b/src/edu/berkeley/fleet/api/Instruction.java index 263c40b..5e3c106 100644 --- a/src/edu/berkeley/fleet/api/Instruction.java +++ b/src/edu/berkeley/fleet/api/Instruction.java @@ -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; } diff --git a/src/edu/berkeley/fleet/assembler/Parser.java b/src/edu/berkeley/fleet/assembler/Parser.java index b2aeeda..1e3e12e 100644 --- a/src/edu/berkeley/fleet/assembler/Parser.java +++ b/src/edu/berkeley/fleet/assembler/Parser.java @@ -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; diff --git a/src/edu/berkeley/fleet/assembler/fleet.g b/src/edu/berkeley/fleet/assembler/fleet.g index 6d6fed0..736d4ae 100644 --- a/src/edu/berkeley/fleet/assembler/fleet.g +++ b/src/edu/berkeley/fleet/assembler/fleet.g @@ -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 diff --git a/src/edu/berkeley/fleet/slipway/Slipway.java b/src/edu/berkeley/fleet/slipway/Slipway.java index c89b139..6c8d40b 100644 --- a/src/edu/berkeley/fleet/slipway/Slipway.java +++ b/src/edu/berkeley/fleet/slipway/Slipway.java @@ -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"); diff --git a/tests/benkobox/kill-only-standing-instructions.fleet b/tests/benkobox/kill-only-standing-instructions.fleet index 8c74af5..9c3f456 100644 --- a/tests/benkobox/kill-only-standing-instructions.fleet +++ b/tests/benkobox/kill-only-standing-instructions.fleet @@ -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*; diff --git a/tests/fifo/fifo-loop.fleet b/tests/fifo/fifo-loop.fleet index 4edac1c..a0c713b 100644 --- a/tests/fifo/fifo-loop.fleet +++ b/tests/fifo/fifo-loop.fleet @@ -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; diff --git a/tests/lut3/simple-lut3-test.fleet b/tests/lut3/simple-lut3-test.fleet index d60e5e1..f087b1a 100644 --- a/tests/lut3/simple-lut3-test.fleet +++ b/tests/lut3/simple-lut3-test.fleet @@ -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; -- 1.7.10.4