+++ /dev/null
-package edu.berkeley.fleet.slipway;
-import edu.berkeley.fleet.doc.*;
-import edu.berkeley.fleet.api.*;
-import java.util.*;
-import java.io.*;
-
-/** a ship, which belongs to a fleet and which may have many ports */
-public class SlipwayShip extends Ship {
-
- /** You should instantiate a bunch of Inboxes and Outboxes in your constructor */
- public SlipwayShip(Slipway 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());
- for(String port : sdbb) {
- if (port.equals("")) continue;
- sbb.addDestination(port);
- }
- }
- if (type.equals("Debug")) {
- new SlipwayBenkoBox(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);
-
- } 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);
- }
- }
-
- private Slipway fleet;
- private String type;
-
- public long resolveLiteral(String s) {
- if (s.equals("NEG")) return 0;
- if (s.equals("INC")) return 1;
- if (s.equals("DEC")) return 2;
- if (s.equals("ABS")) return 3;
- if (s.equals("ADD")) return 0;
- if (s.equals("SUB")) return 1;
- if (s.equals("MAX")) return 2;
- if (s.equals("MIN")) return 3;
- return super.resolveLiteral(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>();
-
- public Iterable<BenkoBox> getBenkoBoxes() { return (Iterable<BenkoBox>)(Object)portlist; }
- public String getType() { return type; }
- public Fleet getFleet() { return fleet; }
- public Slipway getSlipway() { return fleet; }
-
- void addBenkoBox(String name, SlipwayBenkoBox port) { ports.put(name, port); portlist.add(port); }
-
-}