From 7f4958fbb5eb13487bbfaf8411765fe997ae2ae7 Mon Sep 17 00:00:00 2001 From: adam Date: Tue, 26 Aug 2008 11:04:10 +0100 Subject: [PATCH] update to new AM37 syntax --- ships/Alu2.ship | 80 +++++------ ships/Debug.ship | 2 +- ships/Fifo.ship | 22 +-- ships/Lut3.ship | 50 +++---- ships/Memory.ship | 10 +- ships/Rotator.ship | 8 +- src/edu/berkeley/fleet/assembler/Parser.java | 147 +++++++++++++------- src/edu/berkeley/fleet/assembler/fleet.g | 91 +++++------- tests/codebags/fun-with-codebags.fleet | 10 +- tests/colliding-tokens.test | 12 +- tests/dock/kill-only-standing-instructions.fleet | 29 ++++ tests/dock/literal-at-pump.fleet | 3 + tests/dock/send-without-destination.fleet- | 40 ++++++ tests/dock/shift.test | 7 + tests/{pump => dock}/test-count.fleet | 6 +- .../test-repeat-counter-from-data-latch.fleet | 16 +-- tests/{pump => dock}/test-repeat-counter.fleet | 12 +- tests/{pump => dock}/test-repeat-zero.fleet | 10 +- .../dock/test-use-loop-counter-dl-on-non-nop.fleet | 40 ++++++ tests/dock/test-use-loop-counter.fleet | 43 ++++++ tests/flags/basic.test | 4 +- tests/flags/flags-ab-1.test | 6 +- tests/flags/flags-ab-2.test | 6 +- tests/flags/flags-ab-3.test | 6 +- tests/flags/flags-ab-4.test | 6 +- tests/flags/flags-ab-5.test | 8 +- tests/flags/flags-ab-not-1.test | 6 +- tests/flags/flags-ab-not-2.test | 6 +- tests/flags/flags-ab-not-3.test | 8 +- tests/flags/flags-ab-not-4.test | 8 +- tests/flags/flags-ab-not-5.test | 8 +- tests/flags/flags-reset.test | 14 +- tests/flags/signal-0-from-inbox-to-inbox.test | 12 +- .../flags/signal-0-from-inbox-to-outbox.test.test | 18 +-- tests/flags/signal-0-from-outbox-to-inbox.test | 12 +- .../flags/signal-0-from-outbox-to-outbox.test.test | 18 +-- tests/flags/signal-1-from-inbox-to-inbox.test | 12 +- .../flags/signal-1-from-inbox-to-outbox.test.test | 18 +-- tests/flags/signal-1-from-outbox-to-inbox.test | 12 +- .../flags/signal-1-from-outbox-to-outbox.test.test | 18 +-- tests/literals/negative-absolute-literals.fleet | 2 +- tests/memory/count.and.stride.fleet | 42 +++--- tests/memory/memory-test.fleet | 36 ++--- tests/multiply.test- | 64 ++++----- tests/ndp/p-plus.fleet- | 94 ++++++------- tests/pump/kill-only-standing-instructions.fleet | 29 ---- tests/pump/literal-at-pump.fleet | 3 - tests/pump/send-without-destination.fleet- | 40 ------ .../pump/test-use-loop-counter-dl-on-non-nop.fleet | 40 ------ tests/pump/test-use-loop-counter.fleet | 43 ------ tests/requeue/requeueing-literal.fleet | 16 +-- .../test-for-common-requeue-timing-error.fleet | 44 +++--- tests/requeue/test-requeue.fleet | 28 ++-- tests/torpedo/basic-torpedo.test | 15 +- tests/torpedo/epilogue-fifo.test | 19 +-- tests/torpedo/epilogue-fifo2.test | 8 +- 56 files changed, 700 insertions(+), 667 deletions(-) create mode 100644 tests/dock/kill-only-standing-instructions.fleet create mode 100644 tests/dock/literal-at-pump.fleet create mode 100644 tests/dock/pump+ create mode 100644 tests/dock/send-without-destination.fleet- create mode 100644 tests/dock/shift.test rename tests/{pump => dock}/test-count.fleet (93%) rename tests/{pump => dock}/test-repeat-counter-from-data-latch.fleet (54%) rename tests/{pump => dock}/test-repeat-counter.fleet (51%) rename tests/{pump => dock}/test-repeat-zero.fleet (52%) create mode 100644 tests/dock/test-use-loop-counter-dl-on-non-nop.fleet create mode 100644 tests/dock/test-use-loop-counter.fleet delete mode 100644 tests/pump/kill-only-standing-instructions.fleet delete mode 100644 tests/pump/literal-at-pump.fleet delete mode 100644 tests/pump/send-without-destination.fleet- delete mode 100644 tests/pump/test-use-loop-counter-dl-on-non-nop.fleet delete mode 100644 tests/pump/test-use-loop-counter.fleet diff --git a/ships/Alu2.ship b/ships/Alu2.ship index 7f270b6..2394534 100644 --- a/ships/Alu2.ship +++ b/ships/Alu2.ship @@ -165,60 +165,60 @@ public void service() { #expect 1 #expect 1 -debug.in: [*] take, deliver; +debug.in: set ilc=*; recv, deliver; alu.in1: - literal 9; - load repeat counter with 7; + set word= 9; + set ilc=7; deliver; - literal 9; + set word= 9; deliver; alu.in2: - literal 8; - load repeat counter with 7; + set word= 8; + set ilc=7; deliver; - literal 9; + set word= 9; deliver; alu.out: - load repeat counter with 4; - take, sendto debug.in; + set ilc=4; + collect, send to debug.in; alu.inOp: - literal Alu2.inOp[ADD]; deliver; - literal Alu2.inOp[SUB]; deliver; - literal Alu2.inOp[IN1]; deliver; - literal Alu2.inOp[IN2]; deliver; + set word= Alu2.inOp[ADD]; deliver; + set word= Alu2.inOp[SUB]; deliver; + set word= Alu2.inOp[IN1]; deliver; + set word= Alu2.inOp[IN2]; deliver; alu.inOp: - literal Alu2.inOp[MIN]; deliver; - literal Alu2.inOp[MAX]; deliver; - literal Alu2.inOp[CMP]; deliver; - literal Alu2.inOp[CMP]; deliver; + set word= Alu2.inOp[MIN]; deliver; + set word= Alu2.inOp[MAX]; deliver; + set word= Alu2.inOp[CMP]; deliver; + set word= Alu2.inOp[CMP]; deliver; alu.out: - take, sendto debug.in; // MIN - setflags a=c, b=b; - [a] literal 1; - [!a] literal 0; - sendto debug.in; - - take, sendto debug.in; // MAX - setflags a=c, b=b; - [a] literal 1; - [!a] literal 0; - sendto debug.in; - - take, sendto debug.in; // CMP - setflags a=c, b=b; - [a] literal 1; - [!a] literal 0; - sendto debug.in; - - take, sendto debug.in; // CMP - setflags a=c, b=b; - [a] literal 1; - [!a] literal 0; - sendto debug.in; + collect, send to debug.in; // MIN + set flags a=c, b=b; + [a] set word= 1; + [!a] set word= 0; + send to debug.in; + + collect, send to debug.in; // MAX + set flags a=c, b=b; + [a] set word= 1; + [!a] set word= 0; + send to debug.in; + + collect, send to debug.in; // CMP + set flags a=c, b=b; + [a] set word= 1; + [!a] set word= 0; + send to debug.in; + + collect, send to debug.in; // CMP + set flags a=c, b=b; + [a] set word= 1; + [!a] set word= 0; + send to debug.in; == Contributors ========================================================= Adam Megacz diff --git a/ships/Debug.ship b/ships/Debug.ship index 1e82d26..c8e102e 100644 --- a/ships/Debug.ship +++ b/ships/Debug.ship @@ -56,7 +56,7 @@ endmodule #ship debug : Debug debug.in: - literal 25; + set word= 25; deliver; == Contributors ========================================================= diff --git a/ships/Fifo.ship b/ships/Fifo.ship index 8cbd38c..0a620b2 100644 --- a/ships/Fifo.ship +++ b/ships/Fifo.ship @@ -51,21 +51,21 @@ at least 16 words. #ship debug : Debug #ship fifo : Fifo -debug.in: [*] take, deliver; +debug.in: set ilc=*; recv, deliver; fifo.in: - literal 9; + set word= 9; deliver; - load repeat counter with 63; - take, deliver; - load repeat counter with 37; - take, deliver; + set ilc=63; + recv, deliver; + set ilc=37; + recv, deliver; fifo.out: - load repeat counter with 63; - take, sendto fifo.in; - load repeat counter with 36; - take, sendto fifo.in; - take, sendto debug.in; + set ilc=63; + collect, send to fifo.in; + set ilc=36; + collect, send to fifo.in; + collect, send to debug.in; diff --git a/ships/Lut3.ship b/ships/Lut3.ship index 7781444..5a0460b 100644 --- a/ships/Lut3.ship +++ b/ships/Lut3.ship @@ -357,45 +357,45 @@ is considered ``bit zero''). #ship lut : Lut3 #ship alu : Alu2 -lut.in1: literal 85; [*] deliver; -lut.in2: literal 51; [*] deliver; -lut.in3: literal 15; [*] deliver; -lut.out: [*] take, sendto debug.in; +lut.in1: set word= 85; set ilc=*; deliver; +lut.in2: set word= 51; set ilc=*; deliver; +lut.in3: set word= 15; set ilc=*; deliver; +lut.out: set ilc=*; collect, send to debug.in; // cycle through truth tables using alu as INC alu.in2: - literal 1; - [*] deliver; + set word= 1; + set ilc=*; deliver; alu.inOp: - literal Alu2.inOp[ADD]; - [*] deliver; + set word= Alu2.inOp[ADD]; + set ilc=*; deliver; alu.in1: - literal 0; + set word= 0; deliver; - [*] take, deliver; + set ilc=*; recv, deliver; alu.out: - load loop counter with 2; - [L] wait, take, sendto lut.inLut; - [L] sendto alu.in1; + set olc=2; + [Rq] recv token, collect, send to lut.inLut; + [Rq] send to alu.in1; tail; lut.inLut: - literal 0; + set word= 0; deliver; - [*] take, deliver; + set ilc=*; recv, deliver; // acks from debug ship trigger new truth tables debug.in: - load repeat counter with 63; - take, deliver, notify alu.out; - load repeat counter with 63; - take, deliver, notify alu.out; - load repeat counter with 63; - take, deliver, notify alu.out; - load repeat counter with 63; - take, deliver, notify alu.out; - load repeat counter with 4; - take, deliver, notify alu.out; + set ilc=63; + recv, deliver, send token to alu.out; + set ilc=63; + recv, deliver, send token to alu.out; + set ilc=63; + recv, deliver, send token to alu.out; + set ilc=63; + recv, deliver, send token to alu.out; + set ilc=4; + recv, deliver, send token to alu.out; diff --git a/ships/Memory.ship b/ships/Memory.ship index c86e9ae..135102a 100644 --- a/ships/Memory.ship +++ b/ships/Memory.ship @@ -229,17 +229,17 @@ sequence guarantee problem mentioned in the previous paragraph. // which is dispatched when the code is loaded memory.out: - [*] take, send; + set ilc=*; collect packet, send; memory.inCBD: - literal BOB; + set word= BOB; deliver; BOB: { debug.in: - literal 12; deliver; - literal 13; deliver; - literal 14; deliver; + set word= 12; deliver; + set word= 13; deliver; + set word= 14; deliver; } diff --git a/ships/Rotator.ship b/ships/Rotator.ship index c6661c4..e12cddc 100644 --- a/ships/Rotator.ship +++ b/ships/Rotator.ship @@ -77,10 +77,10 @@ public void service() { #ship debug : Debug #ship rotator : Rotator -rotator.in: literal 1; deliver; literal 21615257152; deliver; -rotator.inAmount: literal 1; deliver; literal 20; deliver; -rotator.out: [*] take, sendto debug.in; -debug.in: [*] take, deliver; +rotator.in: set word= 1; deliver; set word= 21615257152; deliver; +rotator.inAmount: set word= 1; deliver; set word= 20; deliver; +rotator.out: set ilc=*; collect, send to debug.in; +debug.in: set ilc=*; recv, deliver; == Contributors ========================================================= diff --git a/src/edu/berkeley/fleet/assembler/Parser.java b/src/edu/berkeley/fleet/assembler/Parser.java index 91368ea..6eebcc2 100644 --- a/src/edu/berkeley/fleet/assembler/Parser.java +++ b/src/edu/berkeley/fleet/assembler/Parser.java @@ -195,9 +195,6 @@ public class Parser { for(Tree statement : t.child(1)) fillCodeBag(statement, cb); - } else if (head.equals("#import")) { - // ignored - } else if (head.equals("#ship")) { String name = name(t.child(0)); String type = string(t.child(1)); @@ -213,13 +210,6 @@ public class Parser { } shipMap.put(name, ship); - } else if (head.equals("#include")) { - try { - walk(parseIt(new InputStreamReader(new FileInputStream(string(t.child(0))))), cb); - } catch (Exception e) { - throw new RuntimeException(e); - } - } else if (head.equals("#expect")) { expect.add(number(t.child(0))); } else if (head.equals("#skip")) { @@ -249,10 +239,8 @@ public class Parser { Path path(Dock dock, Tree t) { if (!"Dock".equals(t.head()) && !"Destination".equals(t.head()) && !"ShipSpecificLiteral".equals(t.head())) return null; - t = t.child(0); String shipName = name(t.child(0)); String portName = name(t.child(1)); - String subPort = t.size()<3 ? null : name(t.child(2)); Ship ship = shipMap.get(shipName); if (ship==null) throw new RuntimeException("no such ship \""+shipName+"\""); Destination ret = null; @@ -263,10 +251,11 @@ public class Parser { } if (bb==null) throw new RuntimeException("no such pump \""+portName+"\""); - if (subPort==null) subPort=""; - if (":i".equals(t.head())) return dock.getPath(bb.getInstructionDestination(),SIGNAL_ZERO); - if (":1".equals(t.head())) return dock.getPath(bb.getDataDestination(),SIGNAL_ONE); - if (":0".equals(t.head())) return dock.getPath(bb.getDataDestination(),SIGNAL_ZERO); + if (t.size() >= 3) { + if (":i".equals(t.child(2).head())) return dock.getPath(bb.getInstructionDestination(),SIGNAL_ZERO); + if (":1".equals(t.child(2).head())) return dock.getPath(bb.getDataDestination(),SIGNAL_ONE); + if (":0".equals(t.child(2).head())) return dock.getPath(bb.getDataDestination(),SIGNAL_ZERO); + } return dock.getPath(bb.getDataDestination(),SIGNAL_ZERO); } @@ -370,6 +359,12 @@ public class Parser { Dock dock = (Dock)dock(t.child(0)); OUTER: for(Tree tt : t.child(1)) { + + if ("tail".equals(tt.head())) { + cb.add(new Tail(dock)); + continue; + } + int count = 1; Predicate predicate = Default; boolean looping = false; @@ -382,36 +377,45 @@ public class Parser { if ("[!a]".equals(ttt.head())) predicate = NotFlagA; if ("[!b]".equals(ttt.head())) predicate = NotFlagB; if ("[!c]".equals(ttt.head())) predicate = NotFlagC; - if ("[+]".equals(ttt.head())) predicate = IgnoreOLC; - if ("[I]".equals(ttt.head())) interruptible = true; - if ("[L]".equals(ttt.head())) looping = true; + // FIXME: test case for this + if ("[*]".equals(ttt.head())) predicate = IgnoreOLC; + // FIXME: test case for this + if ("[olc=0]".equals(ttt.head())) predicate = OLCZero; + if ("[Rq]".equals(ttt.head())) looping = true; } tt = tt.child(1); if ("tail".equals(tt.head())) { cb.add(new Tail(dock)); continue; - } else if ("setflags".equals(tt.head())) { + } else if ("flags".equals(tt.head())) { cb.add(new Set(dock, looping, predicate, parseFlags(tt.child(0)), parseFlags(tt.child(1)))); continue; - } else if ("load".equals(tt.head()) && "loop".equals(tt.child(0).head())) { + } else if ("olc=word".equals(tt.head())) { cb.add(new Set(dock, looping, predicate, SetDest.OuterLoopCounter, SetSource.DataLatch)); continue; - } else if ("load".equals(tt.head()) && "repeat".equals(tt.child(0).head())) { + } else if ("ilc=word".equals(tt.head())) { cb.add(new Set(dock, looping, predicate, SetDest.InnerLoopCounter, SetSource.DataLatch)); continue; } else if ("*".equals(tt.head())) { cb.add(new Set(dock, looping, predicate, SetDest.InnerLoopCounter, SetSource.Infinity)); continue; - } else if ("with".equals(tt.head()) && "loop".equals(tt.child(0).head())) { - cb.add(new Set(dock, looping, predicate, SetDest.OuterLoopCounter, (number(tt.child(1))))); + } else if ("olc=int".equals(tt.head())) { + cb.add(new Set(dock, looping, predicate, SetDest.OuterLoopCounter, (number(tt.child(0))))); continue; - } else if ("with".equals(tt.head()) && "repeat".equals(tt.child(0).head())) { - cb.add(new Set(dock, looping, predicate, SetDest.InnerLoopCounter, (number(tt.child(1))))); + } else if ("ilc=int".equals(tt.head())) { + cb.add(new Set(dock, looping, predicate, SetDest.InnerLoopCounter, (number(tt.child(0))))); continue; - } else if ("decrement".equals(tt.head())) { + } else if ("--".equals(tt.head())) { cb.add(new Set(dock, looping, predicate, SetDest.OuterLoopCounter, SetSource.Decrement)); continue; - } else if ("literal".equals(tt.head())) { + } else if ("nop".equals(tt.head())) { + // FIXME: test case for "torpedoable nop" + if (tt.child(0).size() > 0 && "[T]".equals(tt.child(0).head())) interruptible = true; + cb.add(new Move(dock, looping, predicate, interruptible, null, false, false, false, false, false, false)); + } else if ("shift".equals(tt.head())) { + cb.add(new Shift(dock, looping, predicate, + new BitVector(dock.getShip().getFleet().getWordWidth()).set(number(tt.child(0))))); + } else if ("word".equals(tt.head())) { long literal = 0; if (tt.child(0).head().equals("CodeBagBody")) { Tree tq = tt; @@ -431,11 +435,13 @@ public class Parser { literal = number(tt.child(0)); } count = 1; + /* if ("int".equals(tt.child(1).head())) { count = (int)number(tt.child(1)); } else if ("forever".equals(tt.child(1).head())) { count = 0; } + */ if (FleetTwoFleet.isSmallEnoughToFit(literal)) { @@ -455,23 +461,8 @@ public class Parser { } Tree ttx = null; boolean requeue = false; - ttx = tt.child(1).head().equals("Commands") ? tt.child(1) : tt; - if ("int".equals(tt.child(2).head())) { - count = (int)number(tt.child(2)); - requeue = true; - } else if ("forever".equals(tt.child(2).head())) { - count = 0; - requeue = true; - } - tt = tt.child(0); - if (tt.head().equals("[*]")) { - cb.add(new Set(dock, looping, predicate, SetDest.InnerLoopCounter, SetSource.Infinity)); - //count = 0; - requeue = false; - } else if (tt.head().equals("int")) { - count = (int)number(tt); - requeue = false; - } + if ("[T]".equals(tt.child(0).head())) interruptible = true; + ttx = tt.child(tt.size()-1); boolean tokenIn = false; boolean dataIn = false; boolean latch = false; @@ -484,18 +475,66 @@ public class Parser { Path path = null; for(int i=0; i