add FpgaDestination.getPathLength() for measuring hop counts
[fleet.git] / src / edu / berkeley / fleet / fpga / FpgaDestination.java
index 976f0d7..37677ce 100644 (file)
@@ -1,6 +1,6 @@
 package edu.berkeley.fleet.fpga;
 import edu.berkeley.fleet.api.*;
-import edu.berkeley.fleet.ies44.*;
+import edu.berkeley.fleet.two.*;
 import edu.berkeley.fleet.*;
 import java.lang.reflect.*;
 import edu.berkeley.sbp.chr.*;
@@ -9,7 +9,7 @@ import edu.berkeley.sbp.meta.*;
 import edu.berkeley.sbp.util.*;
 import java.util.*;
 import java.io.*;
-import static edu.berkeley.fleet.ies44.InstructionEncoder.*;
+import static edu.berkeley.fleet.two.FleetTwoFleet.*;
 import static edu.berkeley.fleet.fpga.verilog.Verilog.*;
 import edu.berkeley.fleet.api.*;
 import edu.berkeley.fleet.api.Dock;
@@ -18,29 +18,34 @@ import java.util.*;
 
 public class FpgaDestination extends Destination implements FabricElement {
     private Module.Port port;
-    private FpgaDock dock;
+    private boolean isInstructionDestination;
+    FpgaDock dock;
 
     public FpgaDestination(FpgaDock dock, Module.Port port, boolean isInstructionDestination) {
         super(dock);
         this.port = port;
         this.dock = dock;
+        this.isInstructionDestination = isInstructionDestination;
     }
 
-    public Module.Port getOutputPort() { throw new RuntimeException(); }
+    public Module.SourcePort getOutputPort() { throw new RuntimeException(); }
     public Module.Port getInputPort()  { throw new RuntimeException(); }
     public void addOutput(FabricElement out, Module.Port outPort) { throw new RuntimeException(); }
 
-    public long getAddr() {
-        return ((Fpga)dock.getShip().getFleet()).top_horn.getPath(this,null).toLong();
+    public int      getPathLength(FpgaDestination dest) {
+        if (dest==this) {
+            return isInstructionDestination ? 0 : FpgaDock.DATA_FIFO_SIZE;
+        }
+        return 0;
     }
-    public FpgaPath getPath(FabricElement dest, BitVector signal) {
+    public FpgaPath getPath(FpgaDestination dest, BitVector signal) {
         if (dest==this) return FpgaPath.emptyPath(this, signal);
         return null;
     }
     public void addInput(FabricElement in, Module.Port inPort) {
-        inPort.connect((Module.SinkPort)port);
+        ((Module.SourcePort)inPort).connect((Module.SinkPort)port);
     }
     public String toString() {
-        return dock.toString();
+        return dock.toString() + (isInstructionDestination ? ":i" : "");
     }
 }