From 16ebccf15fb6d37c81f5db5acc725962dc976122 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 26 Aug 2007 05:21:03 +0100 Subject: [PATCH] remove last vestiges of old literal system --- ships/Choice.ship | 1 - ships/Execute.ship | 2 +- ships/Memory.ship | 51 +++++--------------- src/edu/berkeley/fleet/api/Instruction.java | 27 ++++++----- src/edu/berkeley/fleet/assembler/Parser.java | 33 ++++++------- src/edu/berkeley/fleet/assembler/fleet.g | 4 +- .../berkeley/fleet/ies44/InstructionEncoder.java | 41 ++++++---------- .../berkeley/fleet/interpreter/Interpreter.java | 3 +- .../choice/{demux-test.fleet => demux-test.fleet-} | 0 tests/choice/{mux-test.fleet => mux-test.fleet-} | 0 tests/choice/{swap-test.fleet => swap-test.fleet-} | 0 tests/memory/count.and.stride.fleet | 20 ++++---- tests/pump/send-without-destination.fleet | 24 ++++----- tests/recycle/test-recycle.fleet | 3 +- 14 files changed, 85 insertions(+), 124 deletions(-) rename tests/choice/{demux-test.fleet => demux-test.fleet-} (100%) rename tests/choice/{mux-test.fleet => mux-test.fleet-} (100%) rename tests/choice/{swap-test.fleet => swap-test.fleet-} (100%) diff --git a/ships/Choice.ship b/ships/Choice.ship index 3761b83..6a14d09 100644 --- a/ships/Choice.ship +++ b/ships/Choice.ship @@ -212,7 +212,6 @@ public void service() { #skip #ship debug : Debug #expect 0 -0: sendto debug.in; == Contributors ========================================================= Adam Megacz diff --git a/ships/Execute.ship b/ships/Execute.ship index 82934eb..2c4e158 100644 --- a/ships/Execute.ship +++ b/ships/Execute.ship @@ -65,7 +65,7 @@ endmodule #skip #ship debug : Debug #expect 0 -0: sendto debug.in; + == Contributors ========================================================= Adam Megacz diff --git a/ships/Memory.ship b/ships/Memory.ship index 39110c8..7eb60c3 100644 --- a/ships/Memory.ship +++ b/ships/Memory.ship @@ -153,8 +153,6 @@ module memory (clk, `input(stride_r, stride_a, stride_a_, [(`DATAWIDTH-1):0], stride_d) `input(count_r, count_a, count_a_, [(`DATAWIDTH-1):0], count_d) `output(out_r, out_r_, out_a, [(`DATAWIDTH-1):0], out_d_) - //`defreg(out_d_, [(`DATAWIDTH-1):0], out_d) - `input(preload_r, preload_a, preload_a_, [(`DATAWIDTH-1):0], preload_d) `input(cbd_r, cbd_a, cbd_a_, [(`DATAWIDTH-1):0], cbd_d) `output(ihorn_r, ihorn_r_, ihorn_a, [(`PACKET_WIDTH-1):0], ihorn_d_) @@ -250,33 +248,10 @@ module memory (clk, end else if (command_valid) begin command_valid <= 0; command = ramread; - case (command[(`INSTRUCTION_WIDTH-1):(`INSTRUCTION_WIDTH-2)]) - 0: begin - ihorn_full <= 1; - `packet_data(ihorn_d) <= `instruction_data(command); - `packet_dest(ihorn_d) <= `instruction_dest(command); - end - 1: begin - dhorn_full <= 1; - temp = command[(`INSTRUCTION_WIDTH-(2+`DESTINATION_ADDRESS_BITS)):0]; - temp = temp + ( { current_instruction_read_from, {(`CODEBAG_SIZE_BITS){1'b0}} }); - data[(`DATAWIDTH-1):(`CODEBAG_SIZE_BITS)] = temp; - data[(`CODEBAG_SIZE_BITS-1):0] = command[(`CODEBAG_SIZE_BITS-1):0]; - `packet_data(dhorn_d) <= temp; - `packet_dest(dhorn_d) <= - command[(`INSTRUCTION_WIDTH-3):(`INSTRUCTION_WIDTH-(3+`DESTINATION_ADDRESS_BITS)+1)]; - end - 2: begin - dhorn_full <= 1; - `packet_data(dhorn_d) <= { {(`DATAWIDTH-24){command[23]}}, command[23:0] }; - `packet_dest(dhorn_d) <= command[34:24]; - end - 3: begin - dhorn_full <= 1; - `packet_data(dhorn_d) <= { {(`DATAWIDTH-24){command[23]}}, command[23:0] } + current_instruction_read_from; - `packet_dest(dhorn_d) <= command[34:24]; - end - endcase + ihorn_full <= 1; + `packet_data(ihorn_d) <= `instruction_data(command); + `packet_dest(ihorn_d) <= `instruction_dest(command); + end end else if (cbd_pos < cbd_size) begin current_instruction_read_from <= cbd_base+cbd_pos; @@ -332,19 +307,15 @@ endmodule // instructions not in any codebag are part of the "root codebag" // which is dispatched when the code is loaded -BOB: sendto memory.inCBD; -memory.inCBD: [*] take, deliver; -debug.in: [*] take, deliver; - - -// This codebag illustrates how to do a loop. Notice that this -// is actually an uncontrolled data emitter -- it could clog the -// switch fabric! +memory.inCBD: + literal BOB; + deliver; BOB: { - 12: sendto debug.in; - 13: sendto debug.in; - 14: sendto debug.in; + debug.in: + literal 12; deliver; + literal 13; deliver; + literal 14; deliver; } diff --git a/src/edu/berkeley/fleet/api/Instruction.java b/src/edu/berkeley/fleet/api/Instruction.java index 8ca41b7..e9a74b6 100644 --- a/src/edu/berkeley/fleet/api/Instruction.java +++ b/src/edu/berkeley/fleet/api/Instruction.java @@ -129,18 +129,23 @@ public abstract class Instruction { return "(@"+offset+"): sendto " + dest; } } + } - public static class CodeBagDescriptor extends Literal { - /** address of CBD, relative to address that this instruction was loaded from */ - public final long offset; - public final long size; - public CodeBagDescriptor(Destination dest, long offset, long size) { - super(dest); this.offset = offset; this.size = size; } - public String toString() { - String off = ""+offset; - if (offset > 0) off = "+"+off; - return "(CBD @"+off+"+"+size+"): sendto " + dest; - } + public static class CodeBagDescriptor extends Instruction { + /** address of CBD, relative to address that this instruction was loaded from */ + public final Pump pump; + public final long offset; + public final long size; + public CodeBagDescriptor(Pump pump, long offset, long size) { + this.pump = pump; + this.offset = offset; + this.size = size; + } + public String toString() { + String off = ""+offset; + if (offset > 0) off = "+"+off; + return "(CBD @"+off+"+"+size+"): sendto " + pump; } } + } diff --git a/src/edu/berkeley/fleet/assembler/Parser.java b/src/edu/berkeley/fleet/assembler/Parser.java index 29fe1ad..a6a55a9 100644 --- a/src/edu/berkeley/fleet/assembler/Parser.java +++ b/src/edu/berkeley/fleet/assembler/Parser.java @@ -85,10 +85,11 @@ public class Parser { if (inst instanceof Instruction.Literal.CodeBagDescriptor) { dos.flush(); Instruction.Literal.CodeBagDescriptor old = (Instruction.Literal.CodeBagDescriptor)inst; - int offset = codeBagMap[(int)old.offset] - count; - inst = new Instruction.Literal.CodeBagDescriptor(old.dest, + int offset = codeBagMap[(int)old.offset];// - count; + inst = new Instruction.Literal.CodeBagDescriptor(old.pump, offset, codeBags.get((int)old.offset).size()); + //System.out.println("cbd: " + offset + " " + codeBags.get((int)old.offset).size() + " " + codeBags.get((int)old.offset).name + " " + codeBags.get((int)old.offset)); } fleet.writeInstruction(dos, inst); count++; @@ -181,7 +182,8 @@ public class Parser { } Pump pump(Tree t) { - if (!"Port".equals(t.head()) && !"SubPort".equals(t.head()) && !"ShipSpecificLiteral".equals(t.head())) return null; + if (!"Port".equals(t.head()) && !"SubPort".equals(t.head()) && !"ShipSpecificLiteral".equals(t.head())) + throw new RuntimeException(t+""); String shipName = name(t.child(0)); String portName = name(t.child(1)); Ship ship = shipMap.get(shipName); @@ -239,19 +241,6 @@ public class Parser { for(Tree statement : t.child(1)) fillCodeBag(statement, cb2); - } else if (t.head().equals("ShipSpecificLiteral")) { - long literal = parseSSL(t.child(0)); - cb.add(new Instruction.Literal.Absolute(portReference(t.child(1)), literal)); - - } else if (t.head().equals("Literal")) { - long literal = Long.parseLong(string(t.child(0))); - cb.add(new Instruction.Literal.Absolute(portReference(t.child(1)), literal)); - - } else if (t.head().equals("CodeBagDescriptor")) { - String refname = name(t.child(0).child(0)); - CodeBag cb2 = getCodeBag(refname); - cb.add(new Instruction.Literal.CodeBagDescriptor(portReference(t.child(1)), cb2.getFakeAddress(), 0)); - } else if (t.head().equals("Fiber")) { Pump pump = (Pump)pump(t.child(0)); @@ -300,7 +289,12 @@ public class Parser { else if ("Take".equals(ttt.head())) { dataIn = true; latch = true; } else if ("SendTo".equals(ttt.head())) { dataOut = true; dest = portReference(ttt.child(0)); } else if ("LocalLiteral".equals(ttt.head())) { localLiteral = true; literal = Long.parseLong(string(ttt.child(0))); } - else if ("LocalLiteralConst".equals(ttt.head())) { + else if ("LocalLiteralCodeBag".equals(ttt.head())) { + String refname = name(ttt.child(0).child(0)); + CodeBag cb2 = getCodeBag(refname); + cb.add(new Instruction.Literal.CodeBagDescriptor(pump, cb2.getFakeAddress(), 0)); + continue OUTER; + } else if ("LocalLiteralConst".equals(ttt.head())) { localLiteral = true; literal = parseSSL(ttt.child(0)); } @@ -320,8 +314,9 @@ public class Parser { private class CodeBag extends ArrayList { public long address = -1; - public CodeBag() { codeBags.add(this); } - public CodeBag(String name) { this(); codeBagsByName.put(name, this); } + public final String name; + public CodeBag() { codeBags.add(this); this.name = "root"; } + public CodeBag(String name) { codeBags.add(this); codeBagsByName.put(name, this); this.name = name; } public long getFakeAddress() { return codeBags.indexOf(this); } public boolean equals(Object o) { return this==o; } } diff --git a/src/edu/berkeley/fleet/assembler/fleet.g b/src/edu/berkeley/fleet/assembler/fleet.g index f4b1b4e..c891737 100644 --- a/src/edu/berkeley/fleet/assembler/fleet.g +++ b/src/edu/berkeley/fleet/assembler/fleet.g @@ -14,9 +14,6 @@ Program = Program:: Directive+/ws | Program:: ("":: Directive+/ws) ws! CodeBagBody Statement = Fiber:: Source ":" ("":: Instruction +/ ws) /ws - | Literal:: int ":" "sendto" Port ";" /ws - | ShipSpecificLiteral:: SSL ":" "sendto" Port ";" /ws - | CodeBagDescriptor:: CodeBag ":" "sendto" Port ";" /ws | NamedCodeBag:: name ":" "{" CodeBagBody "}" /ws CountField = Brack:: "[" int "]" @@ -37,6 +34,7 @@ Command = Nop:: "nop" | Deliver:: "deliver" | LocalLiteral:: "literal" ws! int | LocalLiteralConst:: "literal" ws! SSL + | LocalLiteralCodeBag:: "literal" ws! CodeBag | Ack:: "notify" ws! Port Source = Port diff --git a/src/edu/berkeley/fleet/ies44/InstructionEncoder.java b/src/edu/berkeley/fleet/ies44/InstructionEncoder.java index 767ada7..2758df7 100644 --- a/src/edu/berkeley/fleet/ies44/InstructionEncoder.java +++ b/src/edu/berkeley/fleet/ies44/InstructionEncoder.java @@ -75,14 +75,14 @@ public abstract class InstructionEncoder { return new Instruction.Executable(name, dest, count, tokenIn, dataIn, latch, dataOutDest, dataOut, tokenOut, requeue); } - + /* case 1: { Destination name = getDestByAddr(getField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_DEST_ADDR+1, inst)); long offset = getSignedField(WIDTH_WORD-3-WIDTH_DEST_ADDR, WIDTH_CODEBAG_SIZE, instr); long size = getSignedField(WIDTH_CODEBAG_SIZE-1, 0, instr); return new Instruction.Literal.CodeBagDescriptor(name, offset, size); } - + */ case 2: { Destination name = getDestByAddr(getField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_PUMP_ADDR+1, inst)); return new Instruction.Literal.Absolute(name, getSignedField(WIDTH_WORD-3-WIDTH_PUMP_ADDR, 0, instr)); @@ -107,12 +107,22 @@ public abstract class InstructionEncoder { d = new Instruction.Executable(k.pump, null, k.count, k.killOnlyStandingInstructions, false, true, false, false, false, false); } + + if (d instanceof Instruction.Literal.CodeBagDescriptor) { + Instruction.Literal.CodeBagDescriptor lc = (Instruction.Literal.CodeBagDescriptor)d; + d = new Instruction.LocalLiteral(lc.pump, ((lc.offset << WIDTH_CODEBAG_SIZE)) | lc.size); + } + if (d instanceof Instruction.LocalLiteral) { Instruction.LocalLiteral inst = (Instruction.LocalLiteral)d; - instr |= putField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, getBoxInstAddr(inst.pump)); - instr |= putField(OFFSET_TI, OFFSET_TI, 1); - instr |= putField(OFFSET_TO, OFFSET_TO, 1); - instr |= putField(OFFSET_LITERAL+WIDTH_LITERAL-1, OFFSET_LITERAL, inst.literal); + if (inst.pump != null) { + instr |= putField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, getBoxInstAddr(inst.pump)); + instr |= putField(OFFSET_TI, OFFSET_TI, 1); + instr |= putField(OFFSET_TO, OFFSET_TO, 1); + instr |= putField(OFFSET_LITERAL+WIDTH_LITERAL-1, OFFSET_LITERAL, inst.literal); + } else { + instr = inst.literal; + } } else if (d instanceof Instruction.Executable) { Instruction.Executable inst = (Instruction.Executable)d; @@ -126,25 +136,6 @@ public abstract class InstructionEncoder { instr |= putField(OFFSET_TO, OFFSET_TO, (inst.dataOutDest||inst.tokenOut)?1:0); instr |= putField(OFFSET_RQ, OFFSET_RQ, inst.requeue?1:0); - } else if (d instanceof Instruction.Literal.CodeBagDescriptor) { - Instruction.Literal.CodeBagDescriptor lc = (Instruction.Literal.CodeBagDescriptor)d; - instr = putField(WIDTH_WORD-1, WIDTH_WORD-2, 1); - if (lc.dest != null) instr |= putField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_DEST_ADDR+1, getDestAddr(lc.dest)); - instr |= putSignedField(WIDTH_WORD-3-WIDTH_DEST_ADDR, WIDTH_CODEBAG_SIZE, lc.offset); - instr |= putField(WIDTH_CODEBAG_SIZE-1, 0, lc.size); - - } else if (d instanceof Instruction.Literal.Absolute) { - Instruction.Literal.Absolute ld = (Instruction.Literal.Absolute)d; - instr = putField(WIDTH_WORD-1, WIDTH_WORD-2, 2); - instr |= putField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_DEST_ADDR+1, getDestAddr(ld.dest)); - instr |= putSignedField(WIDTH_WORD-3-WIDTH_DEST_ADDR, 0, ld.value); - - } else if (d instanceof Instruction.Literal.Relative) { - Instruction.Literal.Relative lr = (Instruction.Literal.Relative)d; - instr = putField(WIDTH_WORD-1, WIDTH_WORD-2, 3); - instr |= putField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_DEST_ADDR+1, getDestAddr(lr.dest)); - instr |= putSignedField(WIDTH_WORD-3-WIDTH_DEST_ADDR, 0, lr.offset); - } return instr; } diff --git a/src/edu/berkeley/fleet/interpreter/Interpreter.java b/src/edu/berkeley/fleet/interpreter/Interpreter.java index dda42a7..0f239fc 100644 --- a/src/edu/berkeley/fleet/interpreter/Interpreter.java +++ b/src/edu/berkeley/fleet/interpreter/Interpreter.java @@ -88,7 +88,8 @@ public class Interpreter extends Fleet implements Fleet.WithDynamicShips { } else if (i instanceof Instruction.Literal.CodeBagDescriptor) { Instruction.Literal.CodeBagDescriptor cbd = (Instruction.Literal.CodeBagDescriptor)i; long absolute_cbd = ((cbd.offset+address) << 6) | cbd.size; - new Packet(this, null, (int)absolute_cbd, (InterpreterDestination)cbd.dest).send(); + throw new RuntimeException(); + //new Packet(this, null, (int)absolute_cbd, (InterpreterDestination)cbd.pump).send(); } else if (i instanceof Instruction.Literal.Absolute) { new Packet(this, null, diff --git a/tests/choice/demux-test.fleet b/tests/choice/demux-test.fleet- similarity index 100% rename from tests/choice/demux-test.fleet rename to tests/choice/demux-test.fleet- diff --git a/tests/choice/mux-test.fleet b/tests/choice/mux-test.fleet- similarity index 100% rename from tests/choice/mux-test.fleet rename to tests/choice/mux-test.fleet- diff --git a/tests/choice/swap-test.fleet b/tests/choice/swap-test.fleet- similarity index 100% rename from tests/choice/swap-test.fleet rename to tests/choice/swap-test.fleet- diff --git a/tests/memory/count.and.stride.fleet b/tests/memory/count.and.stride.fleet index e56402a..959490e 100644 --- a/tests/memory/count.and.stride.fleet +++ b/tests/memory/count.and.stride.fleet @@ -20,13 +20,13 @@ memory.inStride: [*] take, deliver; fifo.in: [*] take, deliver; // addresses and values to initialize the memory with -1: sendto memory.inAddrWrite; -4: sendto memory.inCount; -1: sendto memory.inStride; -11: sendto memory.inDataWrite; -12: sendto memory.inDataWrite; -13: sendto memory.inDataWrite; -14: sendto memory.inDataWrite; +//1: sendto memory.inAddrWrite; +//4: sendto memory.inCount; +//1: sendto memory.inStride; +//11: sendto memory.inDataWrite; +//12: sendto memory.inDataWrite; +//13: sendto memory.inDataWrite; +//14: sendto memory.inDataWrite; // send write-completion tokens to the fifo output memory.out: @@ -40,7 +40,7 @@ fifo.out: take, sendto memory.inAddrRead; // read addresses -4: sendto fifo.in; -4: sendto memory.inCount; --1: sendto memory.inStride; +//4: sendto fifo.in; +//4: sendto memory.inCount; +//-1: sendto memory.inStride; diff --git a/tests/pump/send-without-destination.fleet b/tests/pump/send-without-destination.fleet index a0ba82d..b265025 100644 --- a/tests/pump/send-without-destination.fleet +++ b/tests/pump/send-without-destination.fleet @@ -1,5 +1,5 @@ // output /////////////////////////////////////////////////////////////////// -#expect 5263440 +#expect 5263 // program ////////////////////////////////////////////////////////////////// #ship debug : Debug @@ -12,23 +12,25 @@ debug.in: [*] take, deliver; memory.inAddrRead: [*] take, deliver; memory.inAddrWrite: [*] take, deliver; memory.inDataWrite: [*] take, deliver; -bitfifo.in: [*] take, deliver; -bitfifo.inOp: [*] take, deliver; -bitfifo.outOp: [*] take, deliver; FRED: { - fifo.in: take, deliver, notify fifo.out; + fifo.in: deliver, notify fifo.out; } -5263440: sendto fifo.in; + +fifo.in: literal 5263; fifo.out: wait, take, sendto debug.in; -0: sendto bitfifo.in; // six bits of leading zero (to wash out the codebag size) -FRED: sendto bitfifo.in; // FRED = { address_of_fred[31], size_of_fred[6] } +bitfifo.in: + literal 0; deliver; // six bits of leading zero (to wash out the codebag size) + literal FRED; deliver; // FRED = { address_of_fred[31], size_of_fred[6] } // strip off bottom 6 bits -BitFifo.inOp[take=6]: sendto bitfifo.inOp; -BitFifo.inOp[take=37]: sendto bitfifo.inOp; -BitFifo.outOp[take=37]: sendto bitfifo.outOp; +bitfifo.inOp: + literal BitFifo.inOp[take=6]; deliver; + literal BitFifo.inOp[take=37]; deliver; +bitfifo.outOp: + literal BitFifo.outOp[take=37]; deliver; + bitfifo.out: take, sendto memory.inAddrRead; // value read out will be the instruction at FRED diff --git a/tests/recycle/test-recycle.fleet b/tests/recycle/test-recycle.fleet index 6fea3e1..a33b9ae 100644 --- a/tests/recycle/test-recycle.fleet +++ b/tests/recycle/test-recycle.fleet @@ -57,7 +57,6 @@ f.in: literal 2; deliver; literal 4; deliver; f.out: take, sendto alu.in1; take, sendto alu.in2; -Alu2.inOp[ADD]: sendto alu.inOp; alu.in1: [*] nop; (*) take, deliver; (*) deliver; @@ -66,7 +65,7 @@ alu.in1: [*] nop; kill*; alu.in2: take; [*] deliver; -alu.inOp: take; +alu.inOp: literal Alu2.inOp[ADD]; [*] deliver; alu.out: [*] nop; (40) take, sendto alu.in1; -- 1.7.10.4