}
public int getWordWidth() { return 37; }
- private static final BitVector SIGNAL_ZERO = new BitVector(1);
- private static final BitVector SIGNAL_ONE = new BitVector(1);
- static {
- SIGNAL_ONE.set(0,true);
- }
public Module top;
public FabricElement top_horn;
public long getDestAddr(Path path) {
return ((FpgaPath)path).toLong();
}
- public Path getPathByAddr(Dock source, long dest) {
- for(Ship ship : Fpga.this)
- for(Dock bb : ship) {
- for(Destination d : new Destination[] { bb.getInstructionDestination(), bb.getDataDestination() }) {
- for(BitVector signal : new BitVector[] { SIGNAL_ZERO, SIGNAL_ONE }) {
- FpgaPath p = (FpgaPath)source.getPath(d, signal);
- if (p.toLong() == dest) return p;
- }
- }
- }
- return null;
- }
public Dock getBoxByInstAddr(long dest) {
for(Ship ship : Fpga.this)
for(Dock bb : ship)
// Instruction Encoding /////////////////////////////////////////////////////////////////////////
public long getDestAddr(Path path) {
- // FIXME
- throw new RuntimeException();
- }
- public Path getPathByAddr(Dock source, long dest) {
- // FIXME
- throw new RuntimeException();
+ long ret = ((InterpreterDestination)path.getDestination()).addr;
+ BitVector bv = path.getSignal();
+ if (bv.length() > 1) throw new RuntimeException();
+ if (bv.length() > 0 && bv.get(0)) ret |= 1;
+ return ret;
}
class InterpreterDestination extends Destination {
+ private static int max_dest = 0;
+
+ int addr;
+
public InterpreterDestination(InterpreterDock d, boolean isInstructionDestination) {
super(d);
+ synchronized(InterpreterDestination.class) {
+ this.addr = max_dest;
+ max_dest += 2;
+ }
}
/** adds the included datum to the port from the switch fabric side */
// FIXME this should use a BitVector not a long!
protected abstract long getDestAddr(Path box);
+ private static final BitVector SIGNAL_ZERO = new BitVector(1);
+ private static final BitVector SIGNAL_ONE = new BitVector(1);
+ static {
+ SIGNAL_ONE.set(0,true);
+ }
+
/** decode a path, given the starting point and the bits that comprise it */
// FIXME this should use a BitVector not a long!
- protected abstract Path getPathByAddr(Dock source, long dest);
+ //protected abstract Path getPathByAddr(Dock source, long dest);
+ protected Path getPathByAddr(Dock source, long dest) {
+ for(Ship ship : this)
+ for(Dock bb : ship) {
+ for(Destination d : new Destination[] { bb.getInstructionDestination(), bb.getDataDestination() }) {
+ for(BitVector signal : new BitVector[] { SIGNAL_ZERO, SIGNAL_ONE }) {
+ Path p = (Path)source.getPath(d, signal);
+ if (getDestAddr(p) == dest) return p;
+ }
+ }
+ }
+ return null;
+ }
/** read a machine-formatted instruction from a file (into a Java object) */
public Instruction readInstruction(DataInputStream is, Dock dispatchFrom) throws IOException {