From cb7ee9ba0641d14d8cd04a109213d5c231eb027d Mon Sep 17 00:00:00 2001 From: adam Date: Thu, 26 Jun 2008 08:24:09 +0100 Subject: [PATCH] refactor codebag-memory-block creation code --- ships/Memory.ship | 29 +------ ships/Rotator.ship | 4 +- src/edu/berkeley/fleet/assembler/Parser.java | 81 +++++++++++++++++- src/edu/berkeley/fleet/fpga/Client.java | 110 +++---------------------- src/edu/berkeley/fleet/fpga/Fpga.java | 7 +- src/edu/berkeley/fleet/two/FleetTwoFleet.java | 23 ++++-- 6 files changed, 110 insertions(+), 144 deletions(-) diff --git a/ships/Memory.ship b/ships/Memory.ship index ed6d55e..8d86208 100644 --- a/ships/Memory.ship +++ b/ships/Memory.ship @@ -88,34 +88,7 @@ sequence guarantee problem mentioned in the previous paragraph. } mem[addr] = val; } -/* - public void dispatch(int addr, int size) { - for(int i=addr; i> 6); - base = base & ~(0xffffffff << 18); - int size = (int)launch; - size = size & ~(0xffffffff << 6); - dispatch(base, size); - } -*/ private long stride = 0; private long count = 0; private long addr = 0; @@ -153,7 +126,7 @@ sequence guarantee problem mentioned in the previous paragraph. writing = false; } else if (box_inAddrWrite.dataReadyForShip()) { - addr = box_inAddrWrite.peekPacketForShip().value; +// addr = box_inAddrWrite.peekPacketForShip().value; box_inAddrWrite.removeDataForShip(); stride = 0; count = 1; diff --git a/ships/Rotator.ship b/ships/Rotator.ship index 4ceec61..7c5c570 100644 --- a/ships/Rotator.ship +++ b/ships/Rotator.ship @@ -24,9 +24,9 @@ public void service() { if (box_inAmount.dataReadyForShip() && box_in.dataReadyForShip() && box_out.readyForDataFromShip()) { long amount = box_inAmount.removeDataForShip(); long data = box_in.removeDataForShip(); - long mask = ~((-1L) << getInterpreter().getWordSize()); + long mask = ~((-1L) << getInterpreter().getWordWidth()); data = data & mask; - box_out.addDataFromShip(((data << amount) | (data >> (getInterpreter().getWordSize()-amount))) & mask); + box_out.addDataFromShip(((data << amount) | (data >> (getInterpreter().getWordWidth()-amount))) & mask); } } diff --git a/src/edu/berkeley/fleet/assembler/Parser.java b/src/edu/berkeley/fleet/assembler/Parser.java index be45472..fe981c6 100644 --- a/src/edu/berkeley/fleet/assembler/Parser.java +++ b/src/edu/berkeley/fleet/assembler/Parser.java @@ -85,7 +85,7 @@ public class Parser { } else { dock = ((Interpreter)fleet).getUniversalSource(); } - baseCodeBag.add(new Set(dock, false, IgnoreOLC, SetDest.DataLatch, (rootCodeBag.getFakeAddress())), true); + //baseCodeBag.add(new Set(dock, false, IgnoreOLC, SetDest.DataLatch, (rootCodeBag.getFakeAddress())), true); Tree parsed = (Tree)parseIt(r); walk(parsed, rootCodeBag); @@ -118,6 +118,80 @@ public class Parser { count++; } } + long startcbd = 0; + for(int i=0; i ret = new ArrayList(); + Fleet fpga = fleet; + + Dock us = null; + if (fleet instanceof Fpga) { + us = ((Fpga)fleet).getUniversalSource(); + } else { + us = ((Interpreter)fleet).getUniversalSource(); + } + + Dock inAddrWrite = null; + Dock inDataWrite = null; + Dock inCBD = null; + Dock out = null; + Dock debugIn = null; + Dock ihorn = null; + + for(Ship ship : fpga) { + if ("Memory".equals(ship.getType()) && ship.getOrdinal()==0) { + inAddrWrite = ship.getDock("inAddrWrite"); + inDataWrite = ship.getDock("inDataWrite"); + inCBD = ship.getDock("inCBD"); + out = ship.getDock("out"); + ihorn = ship.getDock("outIhorn"); + } + if ("Debug".equals(ship.getType()) && ship.getOrdinal()==0) { + debugIn = ship.getDock("in"); + } + } + + for(int i=0; i> 6) & ~(-1L << 10); + long size = (lit >> 0) & ~(-1L << 6); + //startcbd = (offset << 6) | size; + size = 0; + offset = 0; + continue; + } + */ + long lit = ((Fpga)fpga).writeInstruction(instructions[i], us); + ret.add(discard(out)); + ret.add(new Instruction.Shift(inDataWrite, false, IgnoreOLC, new BitVector(fpga.getWordWidth()).set(getField(36, 19, lit)))); + ret.add(new Instruction.Shift(inDataWrite, false, IgnoreOLC, new BitVector(fpga.getWordWidth()).set(getField(18, 0, lit)))); + ret.add(deliver(inDataWrite)); + ret.add(new Instruction.Shift(inAddrWrite, false, IgnoreOLC, new BitVector(fpga.getWordWidth()).set(getField(36, 19, i)))); + ret.add(new Instruction.Shift(inAddrWrite, false, IgnoreOLC, new BitVector(fpga.getWordWidth()).set(getField(18, 0, i)))); + ret.add(deliver(inAddrWrite)); + } + ret.add(new Instruction.Shift(inCBD, false, IgnoreOLC, new BitVector(fpga.getWordWidth()).set(getField(36, 19, startcbd)))); + ret.add(new Instruction.Shift(inCBD, false, IgnoreOLC, new BitVector(fpga.getWordWidth()).set(getField(18, 0, startcbd)))); + ret.add(wait(inCBD)); + ret.add(deliver(inCBD)); + ret.add(sendto(out, out.getPath(inCBD.getDataDestination(),null))); + ret.add(new Instruction.Set(ihorn, false, IgnoreOLC, SetDest.InnerLoopCounter, SetSource.Infinity)); + ret.add(new Instruction.Move(ihorn, false, IgnoreOLC, false, null,false,true,true,true,true,false)); return (Instruction[])ret.toArray(new Instruction[0]); } @@ -477,4 +551,9 @@ public class Parser { public static interface FleetWithDynamicShips { public Ship createShip(String shiptype, String shipname); } + + private static Move discard(Dock dock) { return new Move(dock, false, IgnoreOLC, false, null, false, true, false, false, false, false); } + private static Move deliver(Dock dock) { return new Move(dock, false, IgnoreOLC, false, null, false, false, false, false, true, false); } + private static Move wait(Dock dock) { return new Move(dock, false, IgnoreOLC, false, null, true, false, false, false, false, false); } + private static Move sendto(Dock dock, Path path) { return new Move(dock, false, IgnoreOLC, false, path, false, false, false, false, true, false); } } diff --git a/src/edu/berkeley/fleet/fpga/Client.java b/src/edu/berkeley/fleet/fpga/Client.java index c07442a..793c987 100644 --- a/src/edu/berkeley/fleet/fpga/Client.java +++ b/src/edu/berkeley/fleet/fpga/Client.java @@ -43,93 +43,21 @@ public class Client extends FleetProcess { } catch (Exception e) { e.printStackTrace(); } } - public Client(String bitfile, byte[] program) throws Exception { + private Fpga fpga; + + public Client(Fpga fpga, String bitfile, Instruction[] instructions) throws Exception { + this.fpga = fpga; + s = new Socket(InetAddress.getByName("goliath.megacz.com"), 3133); OutputStream os = new BufferedOutputStream(s.getOutputStream()); PrintWriter pw = new PrintWriter(new OutputStreamWriter(os)); pw.print(Server.pass_string+" "+bitfile+"\n"); pw.flush(); - - Fpga fpga = new Fpga(); - ByteArrayOutputStream newp = new ByteArrayOutputStream(); - DataOutputStream newpd = new DataOutputStream(newp); - long startcbd = 0; - - Dock inAddrWrite = null; - Dock inDataWrite = null; - Dock inCBD = null; - Dock out = null; - Dock debugIn = null; - Dock ihorn = null; - - for(Ship ship : fpga) { - if ("Memory".equals(ship.getType()) && ship.getOrdinal()==0) { - inAddrWrite = ship.getDock("inAddrWrite"); - inDataWrite = ship.getDock("inDataWrite"); - inCBD = ship.getDock("inCBD"); - out = ship.getDock("out"); - ihorn = ship.getDock("outIhorn"); - } - if ("Debug".equals(ship.getType()) && ship.getOrdinal()==0) { - debugIn = ship.getDock("in"); - } - } - - for(int i=0; i> 6) & ~(-1L << 10); - long size = (lit >> 0) & ~(-1L << 6); - startcbd = (offset << 6) | size; - size = 0; - offset = 0; - inst = new Instruction.Shift(fpga.getUniversalSource(), false, IgnoreOLC, new BitVector(fpga.getWordWidth()).set(0)); - } else { - if (fpga.writeInstruction(inst, fpga.getUniversalSource()) != lit) - throw new RuntimeException("no match: " + inst + " @"+(i/6)+"\n"+Long.toString(lit,16)+ - "\n"+Long.toString(fpga.writeInstruction(inst, fpga.getUniversalSource()),16)); - } - //fpga.writeInstruction(newpd, fpga.getUniversalSource(), inst); - } - - for(int i=0; i