public final boolean tokenIn;
public final boolean dataIn;
public final boolean latch;
+ public final boolean dataOutDest;
public final boolean dataOut;
public final boolean tokenOut;
public final boolean requeue;
boolean tokenIn,
boolean dataIn,
boolean latch,
+ boolean dataOutDest,
boolean dataOut,
boolean tokenOut,
boolean requeue) {
this.tokenIn = tokenIn;
this.dataIn = dataIn;
this.latch = latch;
+ this.dataOutDest = dataOutDest;
this.dataOut = dataOut;
this.tokenOut = tokenOut;
this.requeue = requeue;
public Instruction.Executable decrementCount() {
if (count==1) return null;
return new Executable(benkoBox, dest, count==0 ? 0 : count-1,
- tokenIn, dataIn, latch, dataOut, tokenOut, requeue);
+ tokenIn, dataIn, latch, dataOutDest, dataOut, tokenOut, requeue);
}
public String toString() {
boolean latch = false;
boolean dataOut = false;
boolean tokenOut = false;
+ boolean dataOutDest = false;
Destination dest = null;
for(int i=0; i<ttx.size(); i++) {
Tree ttt = ttx.child(i);
else if ("Discard".equals(ttt.head())) { dataIn = true; latch = false; }
else if ("Take".equals(ttt.head())) { dataIn = true; latch = true; }
else if ("SendTo".equals(ttt.head())) { dataOut = true; dest = portReference(ttt.child(0)); }
+ else if ("DataOutDest".equals(ttt.head())) { dataOutDest = true; }
else if ("Deliver".equals(ttt.head())) { dataOut = true; }
else if ("Ack".equals(ttt.head())) { tokenOut = true; dest = portReference(ttt.child(0)); }
}
cb.add(new Instruction.Executable(benkobox,
dest, count, tokenIn, dataIn,
- latch, dataOut, tokenOut, requeue));
+ latch, dataOutDest, dataOut, tokenOut, requeue));
}
}
}
| Discard:: "dismiss"
| Take:: ("take"|"receive")
| SendTo:: "sendto" ws! Port
+ | DataOutDest:: "send"
| Deliver:: "deliver"
| Ack:: "notify" ws! Port
new ConditionalAction("`instruction_bit_tokenout(ondeck)",
new AssignAction(new SimpleAssignable("`packet_dest("+token_out.getName()+")"),
"`instruction_bit_dest(ondeck)")),
- new ConditionalAction("`instruction_bit_dataout(ondeck)",
+ new ConditionalAction("`instruction_bit_dataout(ondeck) && !`instruction_bit_tokenout(ondeck)",
inbox ? new SimpleAction("")
: new AssignAction(new SimpleAssignable("`packet_dest("+data_out.getName()+")"),
- "`instruction_bit_dest(ondeck)"))
+ "`instruction_bit_dest(ondeck)")),
+ new ConditionalAction("`instruction_bit_dataout(ondeck) && `instruction_bit_tokenout(ondeck)",
+ inbox ? new SimpleAction("")
+ : new AssignAction(new SimpleAssignable("`packet_dest("+data_out.getName()+")"),
+ data_out.getName()+"["+(WIDTH_WORD-1)+":"+(WIDTH_WORD-WIDTH_DEST_ADDR)+"]"))
}
- );
+ );
PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(prefix+"/"+name+".v")));
pw.println("`define instruction_bit_tokenout(instruction) instruction["+OFFSET_TO+"]");
import edu.berkeley.fleet.*;
import java.io.*;
-class BitManipulations {
+public class BitManipulations {
public static boolean getBit(int bit, long val) { return ((val & (1L << bit)) != 0); }
public static long getSignedField(int highBit, int lowBit, long val) {
long ret = getField(highBit, lowBit, val);
BenkoBox name = getBoxByInstAddr(getIntField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, inst));
Destination dest = getDestByAddr (getIntField(OFFSET_DEST+WIDTH_DEST_ADDR-1, OFFSET_DEST, inst));
int count = getIntField( OFFSET_COUNT+WIDTH_COUNT-1, OFFSET_COUNT, inst);
- boolean tokenIn = getBit(OFFSET_TI, instr);
- boolean dataIn = getBit(OFFSET_DI, instr);
- boolean latch = getBit(OFFSET_DL, instr);
- boolean dataOut = getBit(OFFSET_DO, instr);
- boolean tokenOut = getBit(OFFSET_TO, instr);
- boolean requeue = getBit(OFFSET_RQ, instr);
+ boolean tokenIn = getBit(OFFSET_TI, instr);
+ boolean dataIn = getBit(OFFSET_DI, instr);
+ boolean latch = getBit(OFFSET_DL, instr);
+ boolean dataOut = getBit(OFFSET_DO, instr);
+ boolean tokenOut = getBit(OFFSET_TO, instr);
+ boolean requeue = getBit(OFFSET_RQ, instr);
+ boolean dataOutDest = dataOut && tokenOut;
if (latch & !dataIn) return new Instruction.Kill(name, count, tokenIn);
- return new Instruction.Executable(name, dest, count, tokenIn, dataIn,
- latch, dataOut, tokenOut, requeue);
+ return new Instruction.Executable(name, dest, count, tokenIn, dataIn, latch, dataOutDest,
+ dataOut, tokenOut, requeue);
}
case 1: {
if (d instanceof Instruction.Kill) {
Instruction.Kill k = (Instruction.Kill)d;
d = new Instruction.Executable(k.benkoBox, null, k.count, k.killOnlyStandingInstructions,
- false, true, false, false, false);
+ false, true, false, false, false, false);
}
if (d instanceof Instruction.Executable) {
instr |= putField(OFFSET_TI, OFFSET_TI, inst.tokenIn?1:0);
instr |= putField(OFFSET_DI, OFFSET_DI, inst.dataIn?1:0);
instr |= putField(OFFSET_DL, OFFSET_DL, inst.latch?1:0);
- instr |= putField(OFFSET_DO, OFFSET_DO, inst.dataOut?1:0);
- instr |= putField(OFFSET_TO, OFFSET_TO, inst.tokenOut?1:0);
+ instr |= putField(OFFSET_DO, OFFSET_DO, (inst.dataOutDest||inst.dataOut)?1:0);
+ instr |= putField(OFFSET_TO, OFFSET_TO, (inst.dataOutDest||inst.tokenOut)?1:0);
instr |= putField(OFFSET_RQ, OFFSET_RQ, inst.requeue?1:0);
} else if (d instanceof Instruction.Literal.CodeBagDescriptor) {
// Instruction Encoding /////////////////////////////////////////////////////////////////////////
- private InterpreterInstructionEncoder iie = new InterpreterInstructionEncoder();
+ public final InterpreterInstructionEncoder iie = new InterpreterInstructionEncoder();
public Instruction readInstruction(DataInputStream is) throws IOException { return iie.readInstruction(is); }
public Instruction readInstruction(long instr) { return iie.readInstruction(instr); }
public long writeInstruction(Instruction d) { return writeInstruction(d); }
public void writeInstruction(DataOutputStream os, Instruction d) throws IOException { iie.writeInstruction(os, d); }
- private class InterpreterInstructionEncoder extends InstructionEncoder {
+ public class InterpreterInstructionEncoder extends InstructionEncoder {
public long getDestAddr(Destination box) { return ((InterpreterDestination)box).getDestAddr(); }
public long getBoxInstAddr(BenkoBox box) { return ((InterpreterBenkoBox)box).getDestAddr(); }
public Destination getDestByAddr(long dest) {
package edu.berkeley.fleet.interpreter;
import edu.berkeley.sbp.util.ANSI;
import edu.berkeley.fleet.api.*;
+import edu.berkeley.fleet.ies44.*;
import edu.berkeley.fleet.api.Instruction;
public class Outbox extends InstructionBenkoBox {
if (instruction.dataOut) {
// if item to be transmitted, send it
- new Packet(getInterpreter(), this, register, (InterpreterDestination)instruction.dest).send();
+ InterpreterDestination dest = (InterpreterDestination)instruction.dest;
+ if (instruction.dataOutDest) {
+ long bits = BitManipulations.getField(InstructionEncoder.WIDTH_WORD-1,
+ InstructionEncoder.WIDTH_WORD-InstructionEncoder.WIDTH_DEST_ADDR,
+ register);
+ dest = (InterpreterDestination)(((Interpreter)getInterpreter()).iie.getDestByAddr(bits));
+ }
+ new Packet(getInterpreter(), this, register, dest).send();
if (instruction.tokenOut)
throw new RuntimeException("outboxes may not send acks!");