From 49a7a90ead986c8e476682442afbebab56b029e3 Mon Sep 17 00:00:00 2001 From: megacz Date: Wed, 7 Jan 2009 19:30:56 -0800 Subject: [PATCH] move the packet queue out of InterpreterDestination and into InterpreterDock --- src/edu/berkeley/fleet/interpreter/DebugDock.java | 14 +----- .../fleet/interpreter/InterpreterDestination.java | 13 ++---- .../fleet/interpreter/InterpreterDock.java | 46 +++++++++++--------- 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/src/edu/berkeley/fleet/interpreter/DebugDock.java b/src/edu/berkeley/fleet/interpreter/DebugDock.java index e286ea5..75fb8ec 100644 --- a/src/edu/berkeley/fleet/interpreter/DebugDock.java +++ b/src/edu/berkeley/fleet/interpreter/DebugDock.java @@ -30,7 +30,7 @@ public class DebugDock { public BitVector getDataLatch() { return dock.dataLatch; } public Queue getDataDestPackets() { Queue values = new LinkedList(); - for (Packet p : dock.dataDestination.packets) { + for (Packet p : dock.dataPackets) { if (p.isToken()) continue; values.add(p.getValue()); @@ -40,17 +40,7 @@ public class DebugDock { public Queue getInstructionsInFabric() { Queue instr = new LinkedList(); - for (Packet p : dock.instructionDestination.packets) { - if (p.isToken()) - continue; - - BitVector bv = p.getValue(); - long val = 0; - for(int i=0; i packets = new LinkedList(); - private boolean isInstructionDestination; public InterpreterDestination(InterpreterDock d, boolean isInstructionDestination) { @@ -22,12 +20,7 @@ class InterpreterDestination extends Destination { } /** adds the included datum to the port from the switch fabric side */ - public void addDataFromFabric(Packet packet) { - packets.add(packet); - } - - public String toString() { - return getDock()+(isInstructionDestination ? ":i" : ""); - } + public abstract void addDataFromFabric(Packet packet); + public abstract String toString(); } diff --git a/src/edu/berkeley/fleet/interpreter/InterpreterDock.java b/src/edu/berkeley/fleet/interpreter/InterpreterDock.java index 9e4a692..f24bbdf 100644 --- a/src/edu/berkeley/fleet/interpreter/InterpreterDock.java +++ b/src/edu/berkeley/fleet/interpreter/InterpreterDock.java @@ -24,6 +24,7 @@ class InterpreterDock extends FleetTwoDock { Instruction executing = null; Queue instructions = new LinkedList(); Queue epilogue = new LinkedList(); + Queue dataPackets = new LinkedList(); boolean dataReadyForShip = false; boolean readyForDataFromShip = true; long dataFromShip; @@ -50,8 +51,26 @@ class InterpreterDock extends FleetTwoDock { // Destinations ////////////////////////////////////////////////////////////////////////////// /** includes the epilogue fifo */ - public InterpreterDestination instructionDestination = new InterpreterDestination(this, true); - public InterpreterDestination dataDestination = new InterpreterDestination(this, false); + public InterpreterDestination instructionDestination = new InterpreterDestination(this, true) { + public String toString() { return getDock()+":i"; } + public void addDataFromFabric(Packet p) { + if (p.isToken()) { + if (torpedoWaiting) throw new RuntimeException("two torpedoes collided!"); + torpedoWaiting = true; + } else { + BitVector bv = p.getValue(); + long val = 0; + for(int i=0; i 0) { - Packet p = instructionDestination.packets.remove(); - if (p.isToken()) { - if (torpedoWaiting) throw new RuntimeException("two torpedoes collided!"); - torpedoWaiting = true; - } else { - BitVector bv = p.getValue(); - long val = 0; - for(int i=0; i 0) { Instruction inst = epilogue.remove(); if (inst instanceof Instruction.Head) { @@ -165,8 +169,8 @@ class InterpreterDock extends FleetTwoDock { } if (move.dataIn && !isInputDock() && readyForDataFromShip) return; - if (move.dataIn && isInputDock() && dataDestination.packets.size()==0) return; - if (move.tokenIn && dataDestination.packets.size()==0) return; + if (move.dataIn && isInputDock() && dataPackets.size()==0) return; + if (move.tokenIn && dataPackets.size()==0) return; } if (executing.looping && olc>0) @@ -274,13 +278,13 @@ class InterpreterDock extends FleetTwoDock { Packet p = null; if (move.tokenIn) { - p = dataDestination.packets.remove(); + p = dataPackets.remove(); if (p.getSignal() != null) flag_c = p.getSignal().get(0); } if (move.dataIn) { BitVector bv = null; if (isInputDock()) { - p = dataDestination.packets.remove(); + p = dataPackets.remove(); bv = new BitVector(p.getValue()); if (p.getSignal() != null) flag_c = p.getSignal().get(0); } else { -- 1.7.10.4