public abstract class Destination {
- /** return the Ship to which this BenkoBox belongs */
+ /** return the Ship to which this Pump belongs */
public abstract Ship getShip();
/**
public static class Kill extends Instruction {
- public final BenkoBox benkoBox;
+ public final Pump pump;
public final int count;
public final boolean killOnlyStandingInstructions;
- public Kill(BenkoBox benkoBox, int count, boolean killOnlyStandingInstructions) {
- this.benkoBox=benkoBox;
+ public Kill(Pump pump, int count, boolean killOnlyStandingInstructions) {
+ this.pump=pump;
this.count=count;
this.killOnlyStandingInstructions = killOnlyStandingInstructions;
if (killOnlyStandingInstructions && count !=1)
public static class Executable extends Instruction {
- public final BenkoBox benkoBox;
+ public final Pump pump;
public final Destination dest;
public final int count;
public final boolean requeue;
/** count=0 denotes a standing move */
- public Executable(BenkoBox benkoBox,
+ public Executable(Pump pump,
Destination dest,
int count,
boolean tokenIn,
boolean dataOut,
boolean tokenOut,
boolean requeue) {
- this.benkoBox = benkoBox;
+ this.pump = pump;
this.dest = dest;
this.count = count;
this.tokenIn = tokenIn;
public Instruction.Executable decrementCount() {
if (count==1) return null;
- return new Executable(benkoBox, dest, count==0 ? 0 : count-1,
+ return new Executable(pump, dest, count==0 ? 0 : count-1,
tokenIn, dataIn, latch, dataOutDest, dataOut, tokenOut, requeue);
}
public String toString() {
- String ret = benkoBox.toString() + ": ";
+ String ret = pump.toString() + ": ";
if (count==0 || count>1 || requeue) {
ret += requeue ? "(" : "[";
if (count>1) ret += count;
boolean needcomma = false;
if (tokenIn) { ret += (needcomma ? ", " : "") + "wait"; needcomma = true; }
if (dataIn && latch) {
- if (benkoBox.isInbox())
+ if (pump.isInbox())
ret += (needcomma ? ", " : "") + "receive";
else
ret += (needcomma ? ", " : "") + "take";
}
if (dataIn && !latch) { ret += (needcomma ? ", " : "") + "dismiss"; needcomma = true; }
if (dataOut) {
- if (benkoBox.isInbox() || dest==null)
+ if (pump.isInbox() || dest==null)
ret += (needcomma ? ", " : "") + "deliver";
else
ret += (needcomma ? ", " : "") + "sendto "+dest;
package edu.berkeley.fleet.api;
import java.util.*;
-public abstract class BenkoBox {
+public abstract class Pump {
- public BenkoBox() { }
+ public Pump() { }
- /** the descriptive name of this benkobox (relative to its ship) */
+ /** the descriptive name of this pump (relative to its ship) */
public abstract String getName();
- /** return the Ship to which this BenkoBox belongs */
+ /** return the Ship to which this Pump belongs */
public abstract Ship getShip();
- /** the maximum number of instructions we can put in the BenkoBox instruction fifo,
+ /** the maximum number of instructions we can put in the Pump instruction fifo,
* or Integer.MAX_VALUE if unbounded */
public abstract int getInstructionFifoLength();
/** returns true if this is an outbox */
public abstract boolean isOutbox();
- /** get all destinations associated with this BenkoBox; default implementation: just itself */
+ /** get all destinations associated with this Pump; default implementation: just itself */
public abstract Iterable<Destination> getDestinations();
/** default implementation: the empty string */
public String getDestinationName() { return ""; }
- /** return the BenkoBox which is the destination of this Box's shortcut (if any) */
- public BenkoBox getShortcut() { return null; }
+ /** return the Pump which is the destination of this Box's shortcut (if any) */
+ public Pump getShortcut() { return null; }
public abstract long resolveLiteral(String literal);
}
/** returns the type of the ship ("Fetch", "ALU", etc) */
public abstract String getType();
- /** return all benkoboxes which feed this ship; order is NOT significant */
- public abstract Iterable<BenkoBox> getBenkoBoxes();
+ /** return all pumps which feed this ship; order is NOT significant */
+ public abstract Iterable<Pump> getPumps();
- public BenkoBox getBenkoBox(String s) {
- for(BenkoBox b : getBenkoBoxes())
+ public Pump getPump(String s) {
+ for(Pump b : getPumps())
if (b.getName().equals(s))
return b;
throw new RuntimeException("unknown port \""+getType()+"."+s+"\"");
Ship ship = shipMap.get(shipName);
if (ship==null) throw new RuntimeException("no such ship \""+shipName+"\"");
Destination ret = null;
- BenkoBox bb = null;
- for(BenkoBox b : ship.getBenkoBoxes())
+ Pump bb = null;
+ for(Pump b : ship.getPumps())
if (b.getName().equals(portName)) {
bb = b;
}
if (bb==null)
- throw new RuntimeException("no such benkobox \""+portName+"\"");
+ throw new RuntimeException("no such pump \""+portName+"\"");
if (subPort==null) subPort="";
for(Destination d : bb.getDestinations())
if (d.getDestinationName().equals(subPort))
return d;
if (ret==null)
- throw new RuntimeException("no such benkobox \""+portName+"\" on ships of type \""+ship.getType()+"\"");
+ throw new RuntimeException("no such pump \""+portName+"\" on ships of type \""+ship.getType()+"\"");
return ret;
}
- BenkoBox benkoBox(Tree<String> t) {
+ Pump pump(Tree<String> t) {
if (!"Port".equals(t.head()) && !"SubPort".equals(t.head()) && !"ShipSpecificLiteral".equals(t.head())) return null;
String shipName = name(t.child(0));
String portName = name(t.child(1));
Ship ship = shipMap.get(shipName);
if (ship==null) throw new RuntimeException("no such ship \""+shipName+"\"");
- BenkoBox bb = null;
- for(BenkoBox b : ship.getBenkoBoxes())
+ Pump bb = null;
+ for(Pump b : ship.getPumps())
if (b.getName().equals(portName))
return b;
- throw new RuntimeException("no such benkobox \""+portName+"\"");
+ throw new RuntimeException("no such pump \""+portName+"\"");
}
private HashMap<String,Integer> numAllocated = new HashMap<String,Integer>();
break;
}
}
- BenkoBox chosenport = chosenship.getBenkoBox(portName);
+ Pump chosenport = chosenship.getPump(portName);
Tree specs = t.child(0).child(2);
long literal = 0;
for(int i=0; i<specs.size(); i++) {
cb.add(new Instruction.Literal.CodeBagDescriptor(portReference(t.child(1)), cb2.getFakeAddress(), 0));
} else if (t.head().equals("Fiber")) {
- BenkoBox benkobox = (BenkoBox)benkoBox(t.child(0));
+ Pump pump = (Pump)pump(t.child(0));
OUTER: for(Tree tt : t.child(1)) {
int count = 1;
if ("Wait".equals(ttt.head())) { tokenIn = true; }
else if ("Nop".equals(ttt.head())) { }
else if ("KillStar".equals(ttt.head())) {
- cb.add(new Instruction.Kill(benkobox, count, true));
+ cb.add(new Instruction.Kill(pump, count, true));
continue OUTER;
} else if ("Kill".equals(ttt.head())) {
- cb.add(new Instruction.Kill(benkobox, count, false));
+ cb.add(new Instruction.Kill(pump, count, false));
continue OUTER;
}
else if ("Discard".equals(ttt.head())) { dataIn = true; latch = false; }
else if ("Deliver".equals(ttt.head())) { dataOut = true; }
else if ("Ack".equals(ttt.head())) { tokenOut = true; dest = portReference(ttt.child(0)); }
}
- cb.add(new Instruction.Executable(benkobox,
+ cb.add(new Instruction.Executable(pump,
dest, count, tokenIn, dataIn,
latch, dataOutDest, dataOut, tokenOut, requeue));
}
String tex = sd.getSection("tex");
if (tex!=null)
pw.println(tex);
- for(BenkoBoxDescription bbd : sd) {
+ for(PumpDescription bbd : sd) {
pw.println("\\subsection*{"+(bbd.isInbox() ? "Inbox: " : "Outbox: ")+"{\\tt "+bbd.getName()+"}}");
}
}
import java.io.*;
import java.util.*;
-public class BenkoBoxDescription implements Iterable<String> {
+public class PumpDescription implements Iterable<String> {
public String getName() { return name; }
public boolean isInbox() { return inbox; }
// FIXME
public HashMap<String,Constant> constants = new HashMap<String,Constant>();
- BenkoBoxDescription(ShipDescription ship, String name, boolean tokenOnly, boolean inbox) {
+ PumpDescription(ShipDescription ship, String name, boolean tokenOnly, boolean inbox) {
this(ship, name, tokenOnly, inbox, null);
}
- BenkoBoxDescription(ShipDescription ship, String name, boolean tokenOnly, boolean inbox, String shortcut) {
+ PumpDescription(ShipDescription ship, String name, boolean tokenOnly, boolean inbox, String shortcut) {
this.ship = ship;
this.name = name;
this.inbox = inbox;
hasval = true;
}
Constant c = getConstant(s);
- if (c==null) throw new RuntimeException("no constant " + s + " on benkobox " + this);
+ if (c==null) throw new RuntimeException("no constant " + s + " on pump " + this);
ret |= c.setbits;
ret &= ~c.clearbits;
if (hasval)
import java.util.*;
/** the Java representation of a .ship file */
-public class ShipDescription implements Iterable<BenkoBoxDescription> {
+public class ShipDescription implements Iterable<PumpDescription> {
public String getName() { return name; }
public String getSection(String sectionName) { return sections.get(sectionName); }
- public Iterator<BenkoBoxDescription> iterator() { return benkoBoxes.iterator(); }
+ public Iterator<PumpDescription> iterator() { return pumps.iterator(); }
public ShipDescription(String name, BufferedReader r) throws IOException {
if (name.endsWith(".ship"))
private String texDocumentation;
// must keep proper ordering for FPGA (FIXME: should alphabetize when synthesizing)
- private ArrayList<BenkoBoxDescription> benkoBoxes = new ArrayList<BenkoBoxDescription>();
+ private ArrayList<PumpDescription> pumps = new ArrayList<PumpDescription>();
private HashMap<String,String> sections = new HashMap<String,String>();
} else if (section.equals("ports")) {
BufferedReader br = new BufferedReader(new StringReader(sections.get(section)));
boolean rightSide = false;
- BenkoBoxDescription p = null;
+ PumpDescription p = null;
for(String s = br.readLine(); s != null; s = br.readLine()) {
if (s.trim().length()==0) { rightSide = true; continue; }
String val = s.substring(s.indexOf(':')+1).trim();
String boxname = val.indexOf('.') != -1 ? val.substring(0, val.indexOf('.')) : val;
String dest = val.indexOf('.') != -1 ? val.substring(val.indexOf('.')+1) : "";
- for (BenkoBoxDescription b : benkoBoxes)
+ for (PumpDescription b : pumps)
if (b.getName().equals(boxname)) { p = b; break; }
- if (p==null) p = new BenkoBoxDescription(this, boxname, tokenOnly, inbox);
+ if (p==null) p = new PumpDescription(this, boxname, tokenOnly, inbox);
p.addDest(dest);
}
}
}
- void add(BenkoBoxDescription b) { benkoBoxes.add(b); }
+ void add(PumpDescription b) { pumps.add(b); }
}
\ No newline at end of file
itake box = IMove { m_count=1, m_recycle=False, m_tokenIn=False, m_dataIn=True,
m_latch=True, m_dataOut=False, m_tokenOut=False, m_dest=Nothing,
- m_benkobox=box }
+ m_pump=box }
move box = (itake box){ m_dataOut=True }
copy box = (move box){ m_dataIn=False }
send box = (move box){ m_dataIn=False, m_latch=False }
notify box dest = IMove { m_count=1, m_recycle=False, m_tokenIn=False, m_dataIn=False,
m_latch=False, m_dataOut=False, m_tokenOut=True, m_dest=(Just dest),
- m_benkobox=box }
+ m_pump=box }
wait box = IMove { m_count=1, m_recycle=False, m_tokenIn=True, m_dataIn=False,
m_latch=False, m_dataOut=False, m_tokenOut=False, m_dest=Nothing,
- m_benkobox=box }
+ m_pump=box }
dismiss box = IMove { m_count=1, m_recycle=False, m_tokenIn=False, m_dataIn=True,
m_latch=False, m_dataOut=False, m_tokenOut=False, m_dest=Nothing,
- m_benkobox=box }
+ m_pump=box }
accept box = move box
-- Port ------------------------------------------------------------------------------
fromTree (Tree "Port" [a,b] _) = ShipPort (fromTree a) (fromTree b)
fromTree t = error (show t)
-type BenkoBox = Port
+type PortBox = Port
data Inst =
- IKill BenkoBox Int
- | ILiteral Int BenkoBox
- | ILiteralBag String BenkoBox
+ IKill PortBox Int
+ | ILiteral Int PortBox
+ | ILiteralBag String PortBox
| IBagDef String [Inst]
- | IMove { m_benkobox :: BenkoBox ,
- m_dest :: Maybe BenkoBox ,
+ | IMove { m_pump :: PortBox ,
+ m_dest :: Maybe PortBox ,
m_count :: Int ,
m_recycle :: Bool ,
m_tokenIn :: Bool ,
show (ILiteral lit bb) = (show lit)++": sendto "++(show bb)++";"
show (ILiteralBag bagname bb) = bagname++": sendto "++(show bb)++";"
show (IBagDef bagname is) = bagname++": {\n "++(join "" $ map (\i -> (show i)++"\n ") is)++"}\n"
- show m@(_) = (show $ m_benkobox m) ++
+ show m@(_) = (show $ m_pump m) ++
": "++
(showCount (m_count m) $ m_recycle m) ++
(join ", " $ showrest m)++
// FIXME: this is really ugly: the order of port declarations in
// the XXXShip.java file must match the order in the .balsa file!
- ArrayList instructionports = new ArrayList<FpgaBenkoBox>();
+ ArrayList instructionports = new ArrayList<FpgaPump>();
for(FpgaShip ship : shiplist)
- for(BenkoBox port : ship.getBenkoBoxes())
- if (!((FpgaBenkoBox)port).special())
+ for(Pump port : ship.getPumps())
+ if (!((FpgaPump)port).special())
instructionports.add(port);
FabricTree instructions =
- new FabricTree((FpgaBenkoBox[])instructionports.toArray(new FpgaBenkoBox[0]),
+ new FabricTree((FpgaPump[])instructionports.toArray(new FpgaPump[0]),
"ihorn",
"instruction");
- ArrayList inputports = new ArrayList<FpgaBenkoBox>();
+ ArrayList inputports = new ArrayList<FpgaPump>();
for(FpgaShip ship : shiplist)
- for(BenkoBox port : ship.getBenkoBoxes())
- if (!((FpgaBenkoBox)port).special())
+ for(Pump port : ship.getPumps())
+ if (!((FpgaPump)port).special())
inputports.add(port);
FabricTree inputs =
- new FabricTree((FpgaBenkoBox[])inputports.toArray(new FpgaBenkoBox[0]),
+ new FabricTree((FpgaPump[])inputports.toArray(new FpgaPump[0]),
"horn",
"dest");
- ArrayList outputports = new ArrayList<FpgaBenkoBox>();
+ ArrayList outputports = new ArrayList<FpgaPump>();
for(FpgaShip ship : shiplist)
- for(BenkoBox port : ship.getBenkoBoxes())
- if (!((FpgaBenkoBox)port).special() || ((FpgaBenkoBox)port).dhorn())
+ for(Pump port : ship.getPumps())
+ if (!((FpgaPump)port).special() || ((FpgaPump)port).dhorn())
outputports.add(port);
FabricTree outputs =
- new FabricTree((FpgaBenkoBox[])outputports.toArray(new FpgaBenkoBox[0]),
+ new FabricTree((FpgaPump[])outputports.toArray(new FpgaPump[0]),
"funnel",
"source");
- ArrayList ihornports = new ArrayList<FpgaBenkoBox>();
+ ArrayList ihornports = new ArrayList<FpgaPump>();
for(FpgaShip ship : shiplist)
- for(BenkoBox port : ship.getBenkoBoxes())
- if (((FpgaBenkoBox)port).ihorn())
+ for(Pump port : ship.getPumps())
+ if (((FpgaPump)port).ihorn())
ihornports.add(port);
FabricTree ihorns =
- new FabricTree((FpgaBenkoBox[])ihornports.toArray(new FpgaBenkoBox[0]),
+ new FabricTree((FpgaPump[])ihornports.toArray(new FpgaPump[0]),
"funnel",
"ihorn");
inputs.dumpChannels(true);
ihorns.dumpChannels(true);
for(FpgaShip ship : shiplist)
- for(BenkoBox port : ship.getBenkoBoxes())
- if (!((FpgaBenkoBox)port).special() || ((FpgaBenkoBox)port).dhorn())
+ for(Pump port : ship.getPumps())
+ if (!((FpgaPump)port).special() || ((FpgaPump)port).dhorn())
System.out.println(" wire [(`PACKET_WIDTH-1):0] data_"
+getUniqueName(ship)+"_"+port.getName()+";");
System.out.print("krunk"+(krunk++));
System.out.print("(clk, ");
boolean first = true;
- for(BenkoBox port : ship.getBenkoBoxes()) {
+ for(Pump port : ship.getPumps()) {
if (!first) System.out.print(", ");
first = false;
String prefix = "data_";
- if (((FpgaBenkoBox)port).ihorn()) prefix = "ihorn_";
- if (((FpgaBenkoBox)port).dhorn()) prefix = "source_";
+ if (((FpgaPump)port).ihorn()) prefix = "ihorn_";
+ if (((FpgaPump)port).dhorn()) prefix = "source_";
System.out.print(prefix+getUniqueName(port.getShip())+"_"+port.getName()+"_r, ");
System.out.print(prefix+getUniqueName(port.getShip())+"_"+port.getName()+"_a, ");
System.out.print(prefix+getUniqueName(port.getShip())+"_"+port.getName());
}
System.out.println(");");
- for(BenkoBox port : ship.getBenkoBoxes()) {
- if (((FpgaBenkoBox)port).special()) continue;
- if (((FpgaBenkoBox)port).inbox) {
+ for(Pump port : ship.getPumps()) {
+ if (((FpgaPump)port).special()) continue;
+ if (((FpgaPump)port).inbox) {
System.out.print("inbox");
} else {
System.out.print("outbox");
String prefix;
Node root;
public void dumpChannels(boolean decl) { root.dumpChannels(0, decl); }
- public FabricTree(FpgaBenkoBox[] ports, String component, String prefix) {
+ public FabricTree(FpgaPump[] ports, String component, String prefix) {
this.prefix = prefix;
root = (Node)mkNode("", component, ports, 0, ports.length, 0, 0);
}
- private Object mkNode(String name, String component, FpgaBenkoBox[] ports,
+ private Object mkNode(String name, String component, FpgaPump[] ports,
int start, int end, int addr, int bits) {
if (end-start == 0) return null;
if (end-start == 1) {
- FpgaBenkoBox p = ports[start];
+ FpgaPump p = ports[start];
if (prefix.equals("instruction")) {
p.instr_addr = (addr<<1);
p.instr_bits = bits+1;
p.addr = (addr << 1) | 1;
p.bits = bits+1;
if (bits >= 11)
- throw new RuntimeException("too many benkoboxen!");
+ throw new RuntimeException("too many pumps!");
int count = 0;
for(Destination d : p.getDestinations()) {
- if (!(d instanceof FpgaBenkoBox.VirtualPort)) continue;
- FpgaBenkoBox.VirtualPort vp = (FpgaBenkoBox.VirtualPort)d;
+ if (!(d instanceof FpgaPump.VirtualPort)) continue;
+ FpgaPump.VirtualPort vp = (FpgaPump.VirtualPort)d;
vp.addr = p.addr | (count << bits);
count++;
}
}
private String describe(String prefix, Object o) {
if (o==null) return null;
- if (o instanceof FpgaBenkoBox) {
- FpgaBenkoBox p = (FpgaBenkoBox)o;
+ if (o instanceof FpgaPump) {
+ FpgaPump p = (FpgaPump)o;
return prefix+"_"+getUniqueName(p.getShip())+"_"+p.getName();
}
if (o instanceof Node) {
pw.println("`include \"macros.v\"");
pw.println();
pw.println("module " + filename + "( clk");
- for(BenkoBoxDescription bb : sd) {
+ for(PumpDescription bb : sd) {
String bb_name = bb.getName();
pw.print(" ");
if (bb.isInbox()) {
pw.println(" );");
pw.println();
pw.println(" input clk;");
- for(BenkoBoxDescription bb : sd) {
+ for(PumpDescription bb : sd) {
String bb_name = bb.getName();
pw.print(" ");
if (bb.isInbox()) {
public void writeInstruction(DataOutputStream os, Instruction d) throws IOException { iie.writeInstruction(os, d); }
private class FpgaInstructionEncoder extends InstructionEncoder {
- public long getDestAddr(Destination box) { return ((FpgaBenkoBox.VirtualPort)box).addr; }
- public long getBoxInstAddr(BenkoBox box) { return ((FpgaBenkoBox)box).instr_addr; }
+ public long getDestAddr(Destination box) { return ((FpgaPump.VirtualPort)box).addr; }
+ public long getBoxInstAddr(Pump box) { return ((FpgaPump)box).instr_addr; }
public Destination getDestByAddr(long dest) {
for(Ship ship : Fpga.this)
- for(BenkoBox bb : ship.getBenkoBoxes())
+ for(Pump bb : ship.getPumps())
for(Destination d : bb.getDestinations())
if (getDestAddr(d)==dest)
return d;
return null;
}
- public BenkoBox getBoxByInstAddr(long dest) {
+ public Pump getBoxByInstAddr(long dest) {
for(Ship ship : Fpga.this)
- for(BenkoBox bb : ship.getBenkoBoxes())
- if (((FpgaBenkoBox)bb).instr_addr == dest)
+ for(Pump bb : ship.getPumps())
+ if (((FpgaPump)bb).instr_addr == dest)
return bb;
return null;
}
import edu.berkeley.fleet.doc.*;
import edu.berkeley.fleet.api.*;
import edu.berkeley.fleet.api.*;
-import edu.berkeley.fleet.api.BenkoBox;
+import edu.berkeley.fleet.api.Pump;
import java.util.*;
/** anything that has a destination address on the switch fabric */
-public class FpgaBenkoBox extends BenkoBox {
+public class FpgaPump extends Pump {
private final String name;
private final FpgaShip ship;
public int addr = (default_addr++);
public int instr_bits;
public int instr_addr = (default_instr_addr++);
- private final BenkoBoxDescription bbd;
+ private final PumpDescription bbd;
protected boolean special = false;
protected boolean ihorn = false;
protected boolean dhorn = false;
public long resolveLiteral(String literal) {
return bbd.resolveLiteral(literal);
}
- public FpgaBenkoBox(BenkoBoxDescription bbd, boolean inbox, FpgaShip ship, String name) {
+ public FpgaPump(PumpDescription bbd, boolean inbox, FpgaShip ship, String name) {
this(bbd, inbox, ship, name, false, false, false);
}
- public FpgaBenkoBox(BenkoBoxDescription bbd, boolean inbox, FpgaShip ship, String name, boolean special) {
+ public FpgaPump(PumpDescription bbd, boolean inbox, FpgaShip ship, String name, boolean special) {
this(bbd, inbox, ship, name, special, false, false);
}
- public FpgaBenkoBox(BenkoBoxDescription bbd, boolean inbox, FpgaShip ship, String name, boolean special, boolean ihorn, boolean dhorn) {
+ public FpgaPump(PumpDescription bbd, boolean inbox, FpgaShip ship, String name, boolean special, boolean ihorn, boolean dhorn) {
this.bbd = bbd;
this.inbox = inbox;
this.special = special;
this.ports = new Destination[ports.length];
for(int i=0; i<ports.length; i++)
this.ports[i] = new VirtualPort(ports[i]);
- ship.addBenkoBox(name, this);
+ ship.addPump(name, this);
}
public void addDestination(String dest) {
public String name;
public VirtualPort(String name) { this.name = name; }
public String getDestinationName() { return name; }
- public Ship getShip() { return FpgaBenkoBox.this.getShip(); }
- public void addDataFromFabric(long data) { FpgaBenkoBox.this.addDataFromFabric(name, (int)data); }
+ public Ship getShip() { return FpgaPump.this.getShip(); }
+ public void addDataFromFabric(long data) { FpgaPump.this.addDataFromFabric(name, (int)data); }
public String toString() { return getShip()+"."+getName(); }
// fixme
public long addr = (default_addr++);
/** You should instantiate a bunch of Inboxes and Outboxes in your constructor */
public FpgaShip(Fpga fleet, String name, String type, ShipDescription sd) {
this.fleet = fleet; this.type = type;
- for(BenkoBoxDescription sdbb : sd) {
- FpgaBenkoBox sbb = new FpgaBenkoBox(sdbb, sdbb.isInbox(), this, sdbb.getName());
+ for(PumpDescription sdbb : sd) {
+ FpgaPump sbb = new FpgaPump(sdbb, sdbb.isInbox(), this, sdbb.getName());
for(String port : sdbb) {
if (port.equals("")) continue;
sbb.addDestination(port);
}
}
if (type.equals("Debug")) {
- new FpgaBenkoBox(null, false, this, "out", true);
+ new FpgaPump(null, false, this, "out", true);
} else if (type.equals("Execute")) {
- new FpgaBenkoBox(null, false, this, "ihorn", true, true, false);
- new FpgaBenkoBox(null, false, this, "dhorn", true, false, true);
+ new FpgaPump(null, false, this, "ihorn", true, true, false);
+ new FpgaPump(null, false, this, "dhorn", true, false, true);
} else if (type.equals("Memory")) {
- new FpgaBenkoBox(null, true, this, "command", true);
- new FpgaBenkoBox(null, false, this, "ihorn", true, true, false);
- new FpgaBenkoBox(null, false, this, "dhorn", true, false, true);
+ new FpgaPump(null, true, this, "command", true);
+ new FpgaPump(null, false, this, "ihorn", true, true, false);
+ new FpgaPump(null, false, this, "dhorn", true, false, true);
}
}
}
// this is dumb, the fpga fleet currently requires these in declaration-order; it shouldn't
- private ArrayList<FpgaBenkoBox> portlist = new ArrayList<FpgaBenkoBox>();
- private HashMap<String,FpgaBenkoBox> ports = new HashMap<String,FpgaBenkoBox>();
+ private ArrayList<FpgaPump> portlist = new ArrayList<FpgaPump>();
+ private HashMap<String,FpgaPump> ports = new HashMap<String,FpgaPump>();
- public Iterable<BenkoBox> getBenkoBoxes() { return (Iterable<BenkoBox>)(Object)portlist; }
+ public Iterable<Pump> getPumps() { return (Iterable<Pump>)(Object)portlist; }
public String getType() { return type; }
public Fleet getFleet() { return fleet; }
public Fpga getSlipway() { return fleet; }
- void addBenkoBox(String name, FpgaBenkoBox port) { ports.put(name, port); portlist.add(port); }
+ void addPump(String name, FpgaPump port) { ports.put(name, port); portlist.add(port); }
}
pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(prefix+"/bitfields.v")));
pw.println("`define DATAWIDTH "+WIDTH_WORD);
pw.println("`define CODEBAG_SIZE_BITS "+WIDTH_CODEBAG_SIZE);
- pw.println("`define BENKOBOX_ADDRESS_BITS "+WIDTH_PUMP_ADDR);
+ pw.println("`define PUMP_ADDRESS_BITS "+WIDTH_PUMP_ADDR);
pw.println("`define DESTINATION_ADDRESS_BITS "+WIDTH_DEST_ADDR);
pw.println("`define COUNT_BITS "+WIDTH_COUNT);
pw.println("`define COUNT_WIDTH "+WIDTH_COUNT);
protected abstract long getDestAddr(Destination box);
/** get the bits describing this box's location on the INSTRUCTION HORN */
- protected abstract long getBoxInstAddr(BenkoBox box);
+ protected abstract long getBoxInstAddr(Pump box);
- /** given an INSTRUCTION HORN address, retrieve the corresponding BenkoBox object */
- protected abstract BenkoBox getBoxByInstAddr(long dest);
+ /** given an INSTRUCTION HORN address, retrieve the corresponding Pump object */
+ protected abstract Pump getBoxByInstAddr(long dest);
- /** given a DESTINATION HORN address, retrieve the corresponding BenkoBox object */
+ /** given a DESTINATION HORN address, retrieve the corresponding Pump object */
protected abstract Destination getDestByAddr(long dest);
/** read a machine-formatted instruction from a file (into a Java object) */
long inst = instr;
switch((int)getField(WIDTH_WORD-1, WIDTH_WORD-2, inst)) {
case 0: {
- BenkoBox name = getBoxByInstAddr(getIntField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, inst));
+ Pump name = getBoxByInstAddr(getIntField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, inst));
Destination dest = getDestByAddr (getIntField(OFFSET_DEST+WIDTH_DEST_ADDR-1, OFFSET_DEST, inst));
int count = getIntField( OFFSET_COUNT+WIDTH_COUNT-1, OFFSET_COUNT, inst);
boolean tokenIn = getBit(OFFSET_TI, instr);
// Kill is encoded as Execute with the illegal combination (Latch & ~DataIn)
if (d instanceof Instruction.Kill) {
Instruction.Kill k = (Instruction.Kill)d;
- d = new Instruction.Executable(k.benkoBox, null, k.count, k.killOnlyStandingInstructions,
+ d = new Instruction.Executable(k.pump, null, k.count, k.killOnlyStandingInstructions,
false, true, false, false, false, false);
}
if (d instanceof Instruction.Executable) {
Instruction.Executable inst = (Instruction.Executable)d;
- instr |= putField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, getBoxInstAddr(inst.benkoBox));
+ instr |= putField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, getBoxInstAddr(inst.pump));
instr |= putField(OFFSET_DEST+WIDTH_DEST_ADDR-1, OFFSET_DEST, inst.dest==null?0:getDestAddr(inst.dest));
instr |= putField(OFFSET_COUNT+WIDTH_COUNT-1, OFFSET_COUNT, inst.count);
instr |= putField(OFFSET_TI, OFFSET_TI, inst.tokenIn?1:0);
import java.util.*;
/** this is a generic inbox which stores <32-bit items (tokens or data) */
-public class Inbox extends InstructionBenkoBox {
+public class Inbox extends InstructionPump {
public boolean dataReadyForShip() { return itemReadyForShip; }
public Packet removePacketForShip() { remove(); return register; }
import java.util.*;
/** anything that has a source (instruction horn) address on the switch fabric */
-abstract class InstructionBenkoBox extends InterpreterBenkoBox {
+abstract class InstructionPump extends InterpreterPump {
/** the currently executing instruction */
private Instruction.Executable executing = null;
/** count of how many "standing instruction only" kills remain to be executed */
private int killNextStandingInstruction = 0;
- InstructionBenkoBox(InterpreterShip ship, String name, String[] ports) {
+ InstructionPump(InterpreterShip ship, String name, String[] ports) {
super(ship, name, ports);
}
public void dispatch(Instruction i, long address) {
Log.dispatch(i);
if (i instanceof Instruction.Executable) {
- InterpreterBenkoBox sourceBenkoBox = (InterpreterBenkoBox)(((Instruction.Executable)i).benkoBox);
- ((InstructionBenkoBox)sourceBenkoBox).addInstruction(((Instruction.Executable)i));
+ InterpreterPump sourcePump = (InterpreterPump)(((Instruction.Executable)i).pump);
+ ((InstructionPump)sourcePump).addInstruction(((Instruction.Executable)i));
} else if (i instanceof Instruction.Literal.CodeBagDescriptor) {
Instruction.Literal.CodeBagDescriptor cbd = (Instruction.Literal.CodeBagDescriptor)i;
(InterpreterDestination)(((Instruction.Literal.Absolute)i).dest)).send();
} else if (i instanceof Instruction.Kill) {
- InterpreterBenkoBox benkoBox = (InterpreterBenkoBox)(((Instruction.Kill)i).benkoBox);
- ((InstructionBenkoBox)benkoBox).kill(((Instruction.Kill)i).count,
+ InterpreterPump pump = (InterpreterPump)(((Instruction.Kill)i).pump);
+ ((InstructionPump)pump).kill(((Instruction.Kill)i).count,
((Instruction.Kill)i).killOnlyStandingInstructions);
} else {
public void writeInstruction(DataOutputStream os, Instruction d) throws IOException { iie.writeInstruction(os, d); }
public class InterpreterInstructionEncoder extends InstructionEncoder {
public long getDestAddr(Destination box) { return ((InterpreterDestination)box).getDestAddr(); }
- public long getBoxInstAddr(BenkoBox box) { return ((InterpreterBenkoBox)box).getDestAddr(); }
+ public long getBoxInstAddr(Pump box) { return ((InterpreterPump)box).getDestAddr(); }
public Destination getDestByAddr(long dest) {
for(Ship ship : Interpreter.this)
- for(BenkoBox bb : ship.getBenkoBoxes())
+ for(Pump bb : ship.getPumps())
for(Destination d : bb.getDestinations())
if (getDestAddr(d)==dest)
return d;
return null;
}
- public BenkoBox getBoxByInstAddr(long dest) {
+ public Pump getBoxByInstAddr(long dest) {
for(Ship ship : Interpreter.this)
- for(BenkoBox bb : ship.getBenkoBoxes())
+ for(Pump bb : ship.getPumps())
if (getBoxInstAddr(bb) == dest)
return bb;
return null;
pw.println("");
pw.println("public class "+filename+" extends InterpreterShip {");
pw.println("");
- for(BenkoBoxDescription b : sd) {
+ for(PumpDescription b : sd) {
String name = b.getName();
pw.print(" ");
if ( b.isInbox()) pw.print("Inbox");
pw.println("");
pw.println(" public "+filename+"(Interpreter fleet, String name) {");
pw.println(" super(fleet, name, \""+filename+"\");");
- for(BenkoBoxDescription b : sd)
- pw.println(" addBenkoBox(\""+b.getName()+"\", box_"+b.getName()+");");
+ for(PumpDescription b : sd)
+ pw.println(" addPump(\""+b.getName()+"\", box_"+b.getName()+");");
pw.println(" }");
pw.println("");
pw.println(sd.getSection("fleeterpreter"));
package edu.berkeley.fleet.interpreter;
import edu.berkeley.fleet.doc.*;
import edu.berkeley.fleet.api.*;
-import edu.berkeley.fleet.api.BenkoBox;
+import edu.berkeley.fleet.api.Pump;
import java.util.*;
/** anything that has a destination address on the switch fabric */
-public abstract class InterpreterBenkoBox extends BenkoBox {
+public abstract class InterpreterPump extends Pump {
private final String name;
private final InterpreterShip ship;
private final Destination[] ports;
private final int addr = max_addr++;
- private BenkoBoxDescription bbd;
+ private PumpDescription bbd;
- public void setDescription(BenkoBoxDescription bbd) {
+ public void setDescription(PumpDescription bbd) {
this.bbd = bbd;
}
public long resolveLiteral(String literal) {
return bbd.resolveLiteral(literal);
}
- public InterpreterBenkoBox(InterpreterShip ship, String name, String[] ports) {
+ public InterpreterPump(InterpreterShip ship, String name, String[] ports) {
this.ship = ship;
this.name = name;
this.ports = new Destination[ports.length];
for(int i=0; i<ports.length; i++)
this.ports[i] =
- new InterpreterBenkoBoxDestination(ports[i]);
+ new InterpreterPumpDestination(ports[i]);
}
public Iterable<Destination> getDestinations() {
private static int max_addr;
- private class InterpreterBenkoBoxDestination extends InterpreterDestination {
+ private class InterpreterPumpDestination extends InterpreterDestination {
public String name;
public long addr = max_addr++;
- public InterpreterBenkoBoxDestination(String name) { this.name = name; }
+ public InterpreterPumpDestination(String name) { this.name = name; }
public String getDestinationName() { return name; }
- public Ship getShip() { return InterpreterBenkoBox.this.getShip(); }
- public void addDataFromFabric(Packet packet) { InterpreterBenkoBox.this.addDataFromFabric(packet); }
+ public Ship getShip() { return InterpreterPump.this.getShip(); }
+ public void addDataFromFabric(Packet packet) { InterpreterPump.this.addDataFromFabric(packet); }
public String toString() { return getShip()+"."+getName(); }
public long getDestAddr() { return addr; }
}
private Interpreter fleet;
private String type;
- private HashMap<String,InterpreterBenkoBox> ports = new HashMap<String,InterpreterBenkoBox>();
+ private HashMap<String,InterpreterPump> ports = new HashMap<String,InterpreterPump>();
- public Iterable<BenkoBox> getBenkoBoxes() { return (Iterable<BenkoBox>)(Object)ports.values(); }
+ public Iterable<Pump> getPumps() { return (Iterable<Pump>)(Object)ports.values(); }
public String getType() { return type; }
public Fleet getFleet() { return fleet; }
public Interpreter getInterpreter() { return fleet; }
public void setShipDescription(ShipDescription sd) {
- for(InterpreterBenkoBox ibb : ports.values()) {
- for(BenkoBoxDescription bbd : sd) {
+ for(InterpreterPump ibb : ports.values()) {
+ for(PumpDescription bbd : sd) {
if (bbd.getName().equals(ibb.getName()))
ibb.setDescription(bbd);
}
public abstract void service();
public final void _service() {
- for(InterpreterBenkoBox p : ports.values()) p.service();
+ for(InterpreterPump p : ports.values()) p.service();
service();
}
- protected void addBenkoBox(String name, InterpreterBenkoBox port) {
+ protected void addPump(String name, InterpreterPump port) {
ports.put(name, port);
}
public void shutdown() {
- for(InterpreterBenkoBox p : ports.values())
+ for(InterpreterPump p : ports.values())
p.shutdown();
}
}
println(ANSI.green("dispatch: " + indent(d+"", " ")));
}
- public static void data(String data, BenkoBox source, Destination dest) {
+ public static void data(String data, Pump source, Destination dest) {
println((" data: ") + indent(ANSI.purple(data) +
(source==null ? "" :
(" : " + source))+(" -> "+ANSI.purple(""+dest)), " "));
}
- public static void token(BenkoBox source, Destination dest) {
+ public static void token(Pump source, Destination dest) {
println(ANSI.purple(" token: ") + (source + " -> " + ANSI.purple(dest+"")));
}
import edu.berkeley.fleet.ies44.*;
import edu.berkeley.fleet.api.Instruction;
-public class Outbox extends InstructionBenkoBox {
+public class Outbox extends InstructionPump {
/** are we ready to accept another item from the ship? */
private boolean readyForDataFromShip = false;
long value;
InterpreterDestination destination;
- public Packet(Interpreter interpreter, InterpreterBenkoBox source, long value, InterpreterDestination destination) {
+ public Packet(Interpreter interpreter, InterpreterPump source, long value, InterpreterDestination destination) {
Log.data(value+"", source, (Destination)destination);
this.interpreter = interpreter;
this.value = value;