Add DebugDock.java
[fleet.git] / src / edu / berkeley / fleet / interpreter / DebugDock.java
1 package edu.berkeley.fleet.interpreter;
2 import java.util.*;
3 import edu.berkeley.fleet.two.*;
4 import edu.berkeley.fleet.api.*;
5 import edu.berkeley.fleet.api.Instruction;
6 import static edu.berkeley.fleet.api.Predicate.*;
7
8 /** EXPERIMENTAL -- DO NOT RELY ON THIS INTERFACE */
9 public class DebugDock {
10     final InterpreterDock dock;
11
12     public DebugDock(Dock d) {
13         dock = (InterpreterDock)d;
14     }
15
16     public Dock getDock()                   { return dock; }
17     public int getOLC()                     { return dock.olc; }
18     public int getILC()                     { return dock.ilc; }
19     public Instruction getExecuting()       { return dock.executing; }
20     public Queue<Instruction> getInstructions() { return dock.instructions; }
21     public Queue<Instruction> getEpilogue() { return dock.epilogue; }
22     public boolean getDataReadyForShip()    { return dock.dataReadyForShip; }
23     public boolean getReadyForDataFromShip(){ return dock.readyForDataFromShip;}
24     public long getDataFromShip()           { return dock.dataFromShip; }
25     public boolean getTorpedoWaiting()      { return dock.torpedoWaiting; }
26     public boolean isHatchOpen()            { return dock.hatchIsOpen; }
27     public boolean isInputDock()            { return dock.hatchIsOpen; }
28     public boolean getFlagA()               { return dock.flag_a; }
29     public boolean getFlagB()               { return dock.flag_b; }
30     public boolean getFlagC()               { return dock.flag_c; }
31     public BitVector getDataLatch()         { return dock.dataLatch; }
32     public Queue<BitVector> getDataDestPackets() {
33         Queue<BitVector> values = new LinkedList<BitVector>();
34         for (Packet p : dock.dataDestination.packets) {
35             if (p.isToken)
36                 continue;
37             values.add(p.value);
38         }
39         return values;
40     }
41     public Queue<Instruction> getInstructionsInFabric() {
42         Queue<Instruction> instr = new LinkedList<Instruction>();
43
44         for (Packet p : dock.instructionDestination.packets) {
45             if (p.isToken)
46                 continue;
47
48             BitVector bv = p.value;
49             long val = 0;
50             for(int i=0; i<bv.length(); i++)
51                 if (bv.get(i))
52                     val |= (1L << i);
53             instr.add(dock.getInterpreter().readInstruction(val, dock));
54         }
55
56         return instr;
57     }
58 }