From c23eba7d19b10b7e6d5b7339e51843397eed0372 Mon Sep 17 00:00:00 2001 From: Adam Megacz Date: Fri, 31 Jul 2009 16:38:51 -0700 Subject: [PATCH] add FleetProcess.sendWord() that takes a signal --- src/edu/berkeley/fleet/api/FleetProcess.java | 12 ++++++++++++ src/edu/berkeley/fleet/fpga/Client.java | 12 ++++++++---- src/edu/berkeley/fleet/interpreter/Interpreter.java | 5 +++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/edu/berkeley/fleet/api/FleetProcess.java b/src/edu/berkeley/fleet/api/FleetProcess.java index 1db837f..c232405 100644 --- a/src/edu/berkeley/fleet/api/FleetProcess.java +++ b/src/edu/berkeley/fleet/api/FleetProcess.java @@ -23,9 +23,21 @@ public abstract class FleetProcess { /** dispatch a word to a given destination; may be buffered */ public abstract void sendWord(Destination d, BitVector word); + /** dispatch a word to a given destination; may be buffered */ + public abstract void sendWord(Destination d, BitVector word, BitVector signal); + + /** convenience method: sends the word to d's data destination */ + public void sendWord(Dock d, BitVector word) { sendWord(d.getDataDestination(), word); } + /** dispatch a token to a given destination; may be buffered */ public abstract void sendToken(Destination d); + /** convenience method: sends a token to d's data destination */ + public void sendToken(Dock d) { sendToken(d.getDataDestination()); } + + /** convenience method: sends a token to d's instruction destination */ + public void sendTorpedo(Dock d) { sendToken(d.getInstructionDestination()); } + /** flush all instructions, words, and tokens dispatched so far */ public abstract void flush(); diff --git a/src/edu/berkeley/fleet/fpga/Client.java b/src/edu/berkeley/fleet/fpga/Client.java index 235e183..4c223fd 100644 --- a/src/edu/berkeley/fleet/fpga/Client.java +++ b/src/edu/berkeley/fleet/fpga/Client.java @@ -106,15 +106,19 @@ public class Client extends FleetProcess { flush(); } - public void sendToken(Destination d) { sendWord(d, new BitVector(fpga.getWordWidth()), true); } - public void sendWord(Destination d, BitVector word) { sendWord(d, word, false); } - private void sendWord(Destination d, BitVector word, boolean token) { + public void sendToken(Destination d) { sendWord(d, new BitVector(fpga.getWordWidth()), null, true); } + public void sendWord(Destination d, BitVector word) { sendWord(d, word, null, false); } + public void sendWord(Destination d, BitVector word, BitVector signal) { sendWord(d, word, signal, false); } + private void sendWord(Destination d, BitVector word, BitVector signal, boolean token) { try { Dock dispatchFrom = fpga.debugShip.getDock("in"); long out = 0; out = fpga.PACKET_DATA.setval(out, word); out = fpga.PACKET_TOKEN.setval(out, token ? 1 : 0); - out = fpga.PACKET_SIGNAL.setval(out, 0); + if (signal==null) + out = fpga.PACKET_SIGNAL.setval(out, 0); + else + out = fpga.PACKET_SIGNAL.setval(out, signal); out = fpga.PACKET_DEST.setval(out, ((FpgaPath)dispatchFrom.getPath(d, null)).toLong()); synchronized(this) { for(int i=9; i>=0; i--) diff --git a/src/edu/berkeley/fleet/interpreter/Interpreter.java b/src/edu/berkeley/fleet/interpreter/Interpreter.java index e58eb3d..87b203e 100644 --- a/src/edu/berkeley/fleet/interpreter/Interpreter.java +++ b/src/edu/berkeley/fleet/interpreter/Interpreter.java @@ -171,8 +171,9 @@ public class Interpreter extends FleetTwoFleet { public class InterpreterProcess extends FleetProcess implements Runnable { private Instruction[] instructions; - public synchronized void sendWord(Destination d, BitVector word) { - InterpreterPath path = (InterpreterPath)debugShip.getDock("in").getPath(d, new BitVector(1)); + public synchronized void sendWord(Destination d, BitVector word) { sendWord(d, word, null); } + public synchronized void sendWord(Destination d, BitVector word, BitVector signal) { + InterpreterPath path = (InterpreterPath)debugShip.getDock("in").getPath(d, signal==null?new BitVector(1):signal); ((InterpreterDestination)d). addDataFromFabric(new Packet(path, word, false)); } -- 1.7.10.4