import java.util.*;
import java.io.*;
-public class Slipway extends Fleet {
+public class Fpga extends Fleet {
- public ArrayList<SlipwayShip> shiplist = new ArrayList<SlipwayShip>();
- public HashMap<String,SlipwayShip> ships = new HashMap<String,SlipwayShip>();
+ public ArrayList<FpgaShip> shiplist = new ArrayList<FpgaShip>();
+ public HashMap<String,FpgaShip> ships = new HashMap<String,FpgaShip>();
public Iterator<Ship> iterator() { return (Iterator<Ship>)(Object)shiplist.iterator(); }
private String bitfile;
public static void main(String[] s) throws Exception {
- new Slipway().dumpFabric(false);
+ new Fpga().dumpFabric(false);
}
- public Slipway() { this("gaspified.bit"); }
- public Slipway(String bitfile) {
+ public Fpga() { this("gaspified.bit"); }
+ public Fpga(String bitfile) {
this.bitfile = bitfile;
createShip("Debug", "debug");
createShip("Memory", "Memory");
public Ship createShip(String type, String name) {
try {
ShipDescription sd = new ShipDescription(name, new BufferedReader(new InputStreamReader(new FileInputStream("ships/"+type+".ship"))));
- SlipwayShip ship = new SlipwayShip(this, name, type, sd);
+ FpgaShip ship = new FpgaShip(this, name, type, sd);
ships.put(name, ship);
shiplist.add(ship);
return ship;
// 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<SlipwayBenkoBox>();
- for(SlipwayShip ship : shiplist)
+ ArrayList instructionports = new ArrayList<FpgaBenkoBox>();
+ for(FpgaShip ship : shiplist)
for(BenkoBox port : ship.getBenkoBoxes())
- if (!((SlipwayBenkoBox)port).special())
+ if (!((FpgaBenkoBox)port).special())
instructionports.add(port);
FabricTree instructions =
- new FabricTree((SlipwayBenkoBox[])instructionports.toArray(new SlipwayBenkoBox[0]),
+ new FabricTree((FpgaBenkoBox[])instructionports.toArray(new FpgaBenkoBox[0]),
"ihorn",
"instruction");
- ArrayList inputports = new ArrayList<SlipwayBenkoBox>();
- for(SlipwayShip ship : shiplist)
+ ArrayList inputports = new ArrayList<FpgaBenkoBox>();
+ for(FpgaShip ship : shiplist)
for(BenkoBox port : ship.getBenkoBoxes())
- if (!((SlipwayBenkoBox)port).special())
+ if (!((FpgaBenkoBox)port).special())
inputports.add(port);
FabricTree inputs =
- new FabricTree((SlipwayBenkoBox[])inputports.toArray(new SlipwayBenkoBox[0]),
+ new FabricTree((FpgaBenkoBox[])inputports.toArray(new FpgaBenkoBox[0]),
"horn",
"dest");
- ArrayList outputports = new ArrayList<SlipwayBenkoBox>();
- for(SlipwayShip ship : shiplist)
+ ArrayList outputports = new ArrayList<FpgaBenkoBox>();
+ for(FpgaShip ship : shiplist)
for(BenkoBox port : ship.getBenkoBoxes())
- if (!((SlipwayBenkoBox)port).special() || ((SlipwayBenkoBox)port).dhorn())
+ if (!((FpgaBenkoBox)port).special() || ((FpgaBenkoBox)port).dhorn())
outputports.add(port);
FabricTree outputs =
- new FabricTree((SlipwayBenkoBox[])outputports.toArray(new SlipwayBenkoBox[0]),
+ new FabricTree((FpgaBenkoBox[])outputports.toArray(new FpgaBenkoBox[0]),
"funnel",
"source");
- ArrayList ihornports = new ArrayList<SlipwayBenkoBox>();
- for(SlipwayShip ship : shiplist)
+ ArrayList ihornports = new ArrayList<FpgaBenkoBox>();
+ for(FpgaShip ship : shiplist)
for(BenkoBox port : ship.getBenkoBoxes())
- if (((SlipwayBenkoBox)port).ihorn())
+ if (((FpgaBenkoBox)port).ihorn())
ihornports.add(port);
FabricTree ihorns =
- new FabricTree((SlipwayBenkoBox[])ihornports.toArray(new SlipwayBenkoBox[0]),
+ new FabricTree((FpgaBenkoBox[])ihornports.toArray(new FpgaBenkoBox[0]),
"funnel",
"ihorn");
outputs.dumpChannels(true);
inputs.dumpChannels(true);
ihorns.dumpChannels(true);
- for(SlipwayShip ship : shiplist)
+ for(FpgaShip ship : shiplist)
for(BenkoBox port : ship.getBenkoBoxes())
- if (!((SlipwayBenkoBox)port).special() || ((SlipwayBenkoBox)port).dhorn())
+ if (!((FpgaBenkoBox)port).special() || ((FpgaBenkoBox)port).dhorn())
System.out.println(" wire [(`PACKET_WIDTH-1):0] data_"
+getUniqueName(ship)+"_"+port.getName()+";");
System.out.println("");
ihorns.dumpChannels(false);
System.out.println("");
- for(SlipwayShip ship : shiplist) {
+ for(FpgaShip ship : shiplist) {
System.out.print(ship.getType().toLowerCase());
System.out.print(" ");
System.out.print("krunk"+(krunk++));
if (!first) System.out.print(", ");
first = false;
String prefix = "data_";
- if (((SlipwayBenkoBox)port).ihorn()) prefix = "ihorn_";
- if (((SlipwayBenkoBox)port).dhorn()) prefix = "source_";
+ if (((FpgaBenkoBox)port).ihorn()) prefix = "ihorn_";
+ if (((FpgaBenkoBox)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 (((SlipwayBenkoBox)port).special()) continue;
- if (((SlipwayBenkoBox)port).inbox) {
+ if (((FpgaBenkoBox)port).special()) continue;
+ if (((FpgaBenkoBox)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(SlipwayBenkoBox[] ports, String component, String prefix) {
+ public FabricTree(FpgaBenkoBox[] 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, SlipwayBenkoBox[] ports,
+ private Object mkNode(String name, String component, FpgaBenkoBox[] ports,
int start, int end, int addr, int bits) {
if (end-start == 0) return null;
if (end-start == 1) {
- SlipwayBenkoBox p = ports[start];
+ FpgaBenkoBox p = ports[start];
if (prefix.equals("instruction")) {
p.instr_addr = addr;
p.instr_bits = bits;
throw new RuntimeException("too many benkoboxen!");
int count = 0;
for(Destination d : p.getDestinations()) {
- if (!(d instanceof SlipwayBenkoBox.VirtualPort)) continue;
- SlipwayBenkoBox.VirtualPort vp = (SlipwayBenkoBox.VirtualPort)d;
+ if (!(d instanceof FpgaBenkoBox.VirtualPort)) continue;
+ FpgaBenkoBox.VirtualPort vp = (FpgaBenkoBox.VirtualPort)d;
vp.addr = p.addr | (count << bits);
count++;
}
}
private String describe(String prefix, Object o) {
if (o==null) return null;
- if (o instanceof SlipwayBenkoBox) {
- SlipwayBenkoBox p = (SlipwayBenkoBox)o;
+ if (o instanceof FpgaBenkoBox) {
+ FpgaBenkoBox p = (FpgaBenkoBox)o;
return prefix+"_"+getUniqueName(p.getShip())+"_"+p.getName();
}
if (o instanceof Node) {
public void writeInstruction(DataOutputStream os, Instruction d) throws IOException { iie.writeInstruction(os, d); }
private class SlipwayInstructionEncoder extends InstructionEncoder {
- public long getDestAddr(Destination box) { return ((SlipwayBenkoBox.VirtualPort)box).addr; }
- public long getBoxInstAddr(BenkoBox box) { return ((SlipwayBenkoBox)box).instr_addr; }
+ public long getDestAddr(Destination box) { return ((FpgaBenkoBox.VirtualPort)box).addr; }
+ public long getBoxInstAddr(BenkoBox box) { return ((FpgaBenkoBox)box).instr_addr; }
public Destination getDestByAddr(long dest) {
- for(Ship ship : Slipway.this)
+ for(Ship ship : Fpga.this)
for(BenkoBox bb : ship.getBenkoBoxes())
for(Destination d : bb.getDestinations())
if (getDestAddr(d)==dest)
return null;
}
public BenkoBox getBoxByInstAddr(long dest) {
- for(Ship ship : Slipway.this)
+ for(Ship ship : Fpga.this)
for(BenkoBox bb : ship.getBenkoBoxes())
- if (((SlipwayBenkoBox)bb).instr_addr == dest)
+ if (((FpgaBenkoBox)bb).instr_addr == dest)
return bb;
return null;
}
import java.util.*;
/** anything that has a destination address on the switch fabric */
-public class SlipwayBenkoBox extends BenkoBox {
+public class FpgaBenkoBox extends BenkoBox {
private final String name;
- private final SlipwayShip ship;
+ private final FpgaShip ship;
private Destination[] ports;
public Iterable<Destination> getDestinations() {
public boolean inbox;
public boolean isInbox() { return inbox; }
public boolean isOutbox() { return !inbox; }
- public SlipwayBenkoBox(boolean inbox, SlipwayShip ship, String name) {
+ public FpgaBenkoBox(boolean inbox, FpgaShip ship, String name) {
this(inbox, ship, name, false, false, false);
}
- public SlipwayBenkoBox(boolean inbox, SlipwayShip ship, String name, boolean special) {
+ public FpgaBenkoBox(boolean inbox, FpgaShip ship, String name, boolean special) {
this(inbox, ship, name, special, false, false);
}
- public SlipwayBenkoBox(boolean inbox, SlipwayShip ship, String name, boolean special, boolean ihorn, boolean dhorn) {
+ public FpgaBenkoBox(boolean inbox, FpgaShip ship, String name, boolean special, boolean ihorn, boolean dhorn) {
this.inbox = inbox;
this.special = special;
this.dhorn = dhorn;
public String name;
public VirtualPort(String name) { this.name = name; }
public String getDestinationName() { return name; }
- public Ship getShip() { return SlipwayBenkoBox.this.getShip(); }
- public void addDataFromFabric(long data) { SlipwayBenkoBox.this.addDataFromFabric(name, (int)data); }
+ public Ship getShip() { return FpgaBenkoBox.this.getShip(); }
+ public void addDataFromFabric(long data) { FpgaBenkoBox.this.addDataFromFabric(name, (int)data); }
public String toString() { return getShip()+"."+getName(); }
// fixme
public long addr = (default_addr++);
import java.io.*;
/** a ship, which belongs to a fleet and which may have many ports */
-public class SlipwayShip extends Ship {
+public class FpgaShip extends Ship {
/** You should instantiate a bunch of Inboxes and Outboxes in your constructor */
- public SlipwayShip(Slipway fleet, String name, String type, ShipDescription sd) {
+ public FpgaShip(Fpga fleet, String name, String type, ShipDescription sd) {
this.fleet = fleet; this.type = type;
for(BenkoBoxDescription sdbb : sd) {
- SlipwayBenkoBox sbb = new SlipwayBenkoBox(sdbb.isInbox(), this, sdbb.getName());
+ FpgaBenkoBox sbb = new FpgaBenkoBox(sdbb.isInbox(), this, sdbb.getName());
for(String port : sdbb) {
if (port.equals("")) continue;
sbb.addDestination(port);
}
}
if (type.equals("Debug")) {
- new SlipwayBenkoBox(false, this, "out", true);
+ new FpgaBenkoBox(false, this, "out", true);
} else if (type.equals("Execute")) {
- new SlipwayBenkoBox(false, this, "ihorn", true, true, false);
- new SlipwayBenkoBox(false, this, "dhorn", true, false, true);
+ new FpgaBenkoBox(false, this, "ihorn", true, true, false);
+ new FpgaBenkoBox(false, this, "dhorn", true, false, true);
} else if (type.equals("Memory")) {
- new SlipwayBenkoBox(true, this, "command", true);
- new SlipwayBenkoBox(false, this, "ihorn", true, true, false);
- new SlipwayBenkoBox(false, this, "dhorn", true, false, true);
+ new FpgaBenkoBox(true, this, "command", true);
+ new FpgaBenkoBox(false, this, "ihorn", true, true, false);
+ new FpgaBenkoBox(false, this, "dhorn", true, false, true);
}
}
- private Slipway fleet;
+ private Fpga fleet;
private String type;
public long resolveLiteral(String s) {
}
// this is dumb, the fpga fleet currently requires these in declaration-order; it shouldn't
- private ArrayList<SlipwayBenkoBox> portlist = new ArrayList<SlipwayBenkoBox>();
- private HashMap<String,SlipwayBenkoBox> ports = new HashMap<String,SlipwayBenkoBox>();
+ private ArrayList<FpgaBenkoBox> portlist = new ArrayList<FpgaBenkoBox>();
+ private HashMap<String,FpgaBenkoBox> ports = new HashMap<String,FpgaBenkoBox>();
public Iterable<BenkoBox> getBenkoBoxes() { return (Iterable<BenkoBox>)(Object)portlist; }
public String getType() { return type; }
public Fleet getFleet() { return fleet; }
- public Slipway getSlipway() { return fleet; }
+ public Fpga getSlipway() { return fleet; }
- void addBenkoBox(String name, SlipwayBenkoBox port) { ports.put(name, port); portlist.add(port); }
+ void addBenkoBox(String name, FpgaBenkoBox port) { ports.put(name, port); portlist.add(port); }
}