public static final int P_IF_Z = 0x0004;
public final int predicate;
- public PredicatedInstruction(Pump pump) { super(pump); this.predicate = P_ALWAYS; }
public PredicatedInstruction(Pump pump, int predicate) { super(pump); this.predicate = predicate; }
public String toString() {
switch(predicate) {
}
public static class DecrLoop extends PredicatedInstruction {
- public DecrLoop(Pump pump) { super(pump); }
+ public DecrLoop(Pump pump) { super(pump, P_ALWAYS); }
public DecrLoop(Pump pump, int predicate) { super(pump, predicate); }
public boolean isDL() { return true; }
public boolean isLooping() { return true; }
public final long literal;
public final boolean high;
public boolean isRequeueing() { return true; }
- public HalfLiteral(Pump pump, long literal, int count, boolean high) { this(pump, P_ALWAYS, literal, count, high); }
public HalfLiteral(Pump pump, int predicate, long literal, int count, boolean high) {
- super(pump);
+ super(pump, predicate);
this.literal = literal;
this.high = high;
}
cb.add(new Instruction.Kill(pump, count));
continue;
} else if ("setflags".equals(tt.head())) {
- cb.add(new Instruction.SetFlags(pump, parseFlags(tt.child(0)), parseFlags(tt.child(1))));
+ cb.add(new Instruction.SetFlags(pump, predicate, parseFlags(tt.child(0)), parseFlags(tt.child(1))));
continue;
} else if ("loop".equals(tt.head())) {
- cb.add(new Instruction.Counter(pump, Instruction.Counter.LOOP_COUNTER, Instruction.Counter.DATA_LATCH));
+ cb.add(new Instruction.Counter(pump, predicate, Instruction.Counter.LOOP_COUNTER, Instruction.Counter.DATA_LATCH));
continue;
} else if ("load".equals(tt.head()) && "loop".equals(tt.child(0).head())) {
- cb.add(new Instruction.Counter(pump, Instruction.Counter.DATA_LATCH, Instruction.Counter.LOOP_COUNTER));
+ cb.add(new Instruction.Counter(pump, predicate, Instruction.Counter.DATA_LATCH, Instruction.Counter.LOOP_COUNTER));
continue;
} else if ("load".equals(tt.head()) && "repeat".equals(tt.child(0).head())) {
- cb.add(new Instruction.Counter(pump, Instruction.Counter.DATA_LATCH, Instruction.Counter.REPEAT_COUNTER));
+ cb.add(new Instruction.Counter(pump, predicate, Instruction.Counter.DATA_LATCH, Instruction.Counter.REPEAT_COUNTER));
continue;
} else if ("with".equals(tt.head()) && "loop".equals(tt.child(0).head())) {
- cb.add(new Instruction.Counter(pump, (int)number(tt.child(1)), Instruction.Counter.LOOP_COUNTER));
+ cb.add(new Instruction.Counter(pump, predicate, (int)number(tt.child(1)), Instruction.Counter.LOOP_COUNTER));
continue;
} else if ("with".equals(tt.head()) && "repeat".equals(tt.child(0).head())) {
- cb.add(new Instruction.Counter(pump, (int)number(tt.child(1)), Instruction.Counter.REPEAT_COUNTER));
+ cb.add(new Instruction.Counter(pump, predicate, (int)number(tt.child(1)), Instruction.Counter.REPEAT_COUNTER));
continue;
} else if ("massacre".equals(tt.head())) {
cb.add(new Instruction.Massacre(pump));
CodeBag cb2 = getCodeBag("anon"+(anoncount++));
for(Tree<String> statement : tq.child(0))
fillCodeBag(statement, cb2);
- cb.add(new Instruction.CodeBagDescriptor(pump, cb2.getFakeAddress(), 0));
+ cb.add(new Instruction.CodeBagDescriptor(pump, predicate, cb2.getFakeAddress(), 0));
continue OUTER;
} else if (tt.child(0).head().equals("Name")) {
String refname = name(tt.child(0));
CodeBag cb2 = getCodeBag(refname);
- cb.add(new Instruction.CodeBagDescriptor(pump, cb2.getFakeAddress(), 0));
+ cb.add(new Instruction.CodeBagDescriptor(pump, predicate, cb2.getFakeAddress(), 0));
continue OUTER;
} else if (tt.child(0).head().equals("[")) {
literal = parseSSL(tt.child(0));
} else if ("forever".equals(tt.child(1).head())) {
count = 0;
}
- cb.add(new Instruction.HalfLiteral(pump, getField(36, 19, literal), count, true));
- cb.add(new Instruction.HalfLiteral(pump, getField(18, 0, literal), count, false));
+ cb.add(new Instruction.HalfLiteral(pump, predicate, getField(36, 19, literal), count, true));
+ cb.add(new Instruction.HalfLiteral(pump, predicate, getField(18, 0, literal), count, false));
continue;
}
Tree ttx = null;
else if ("notify".equals(ttt.head())) { tokenOut = true; dest = portReference(ttt.child(0)); }
else if ("notifyLast".equals(ttt.head())) { tokenOut = true; ignoreUntilLast = true; dest = portReference(ttt.child(0)); }
}
- cb.add(new Instruction.Move(pump, Instruction.PredicatedInstruction.P_ALWAYS,
+ cb.add(new Instruction.Move(pump, predicate,
dest, count, tokenIn, dataIn,
latch, dataOutDest, dataOut, tokenOut, requeue, ignoreUntilLast));
}
}
PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(prefix+"/"+name+".v")));
fifo.dump(pw, true);
+ /*
+ pw.println("`define FIFO_LENGTH " + len);
+ //pw.println("`define NAME " + name);
+ pw.println("`include \"macros.v\"");
+ pw.println("module "+name+"(clk, rst ");
+ pw.println(" , in_r, in_a_, in");
+ pw.println(" , out_r_, out_a, out_);");
+ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("src/edu/berkeley/fleet/fpga/fifo.inc")));
+ String s;
+ while((s = br.readLine())!=null)
+ pw.println(s);
+ */
pw.flush();
return fifo;
}
public static final Mask SK = new Mask("...........1.........................");
public static final Mask DL = new Mask("............1........................");
public static final Mask P = new Mask(".............vv......................");
+ public static final Mask P_A = new Mask(".............00......................");
+ public static final Mask P_B = new Mask(".............10......................");
+ public static final Mask P_Z = new Mask(".............01......................");
+ public static final Mask P_ALWAYS = new Mask(".............11......................");
public static final Mask MOVE = new Mask("...............001...................");
public static final Mask STAND = new Mask("...................1.................");
public static final Mask TI = new Mask("....................1................");
public Instruction readInstruction(long inst) {
Pump name = getBoxByInstAddr(PUMP_NAME.getval(inst));
- if (LOOP_FROM_LITERAL.get(inst)) return new Counter(name, (int)LOOP_FROM_LITERAL.getval(inst), LOOP_COUNTER);
- if (REPEAT_FROM_LITERAL.get(inst)) return new Counter(name, (int)REPEAT_FROM_LITERAL.getval(inst), REPEAT_COUNTER);
- if (LOOP_FROM_DATA.get(inst)) return new Counter(name, DATA_LATCH, LOOP_COUNTER);
- if (REPEAT_FROM_DATA.get(inst)) return new Counter(name, DATA_LATCH, REPEAT_COUNTER);
- if (TAKE_LOOP.get(inst)) return new Counter(name, LOOP_COUNTER, DATA_LATCH);
-
- if (DL.get(inst)) return new Instruction.DecrLoop(name);
-
if (UNCLOG.get(inst)) return new Instruction.UnClog(name);
if (CLOG.get(inst)) return new Instruction.Clog(name);
if (MASSACRE.get(inst)) return new Instruction.Massacre(name);
if (KILL.get(inst)) return new Instruction.Kill(name, (int)(KILL.getval(inst)+1));
- if (LITERAL_LO.get(inst)) return new Instruction.HalfLiteral(name, LITERAL_LO.getval(inst), 0, false);
- if (LITERAL_HI.get(inst)) return new Instruction.HalfLiteral(name, LITERAL_HI.getval(inst), 0, true);
- if (FLAGS.get(inst)) return new Instruction.SetFlags(name, (int)FLAGS_A.getval(inst), (int)FLAGS_B.getval(inst));
+
+ int predicate = 0;
+ if (P_ALWAYS.get(inst)) predicate = Instruction.PredicatedInstruction.P_ALWAYS;
+ if (P_A.get(inst)) predicate = Instruction.PredicatedInstruction.P_IF_A;
+ if (P_B.get(inst)) predicate = Instruction.PredicatedInstruction.P_IF_B;
+ if (P_Z.get(inst)) predicate = Instruction.PredicatedInstruction.P_IF_Z;
+
+ if (LOOP_FROM_LITERAL.get(inst)) return new Counter(name, predicate, (int)LOOP_FROM_LITERAL.getval(inst), LOOP_COUNTER);
+ if (REPEAT_FROM_LITERAL.get(inst)) return new Counter(name, predicate, (int)REPEAT_FROM_LITERAL.getval(inst), REPEAT_COUNTER);
+ if (LOOP_FROM_DATA.get(inst)) return new Counter(name, predicate, DATA_LATCH, LOOP_COUNTER);
+ if (REPEAT_FROM_DATA.get(inst)) return new Counter(name, predicate, DATA_LATCH, REPEAT_COUNTER);
+ if (TAKE_LOOP.get(inst)) return new Counter(name, predicate, LOOP_COUNTER, DATA_LATCH);
+
+ if (DL.get(inst)) return new Instruction.DecrLoop(name, predicate);
+
+ if (LITERAL_LO.get(inst)) return new Instruction.HalfLiteral(name, predicate, LITERAL_LO.getval(inst), 0, false);
+ if (LITERAL_HI.get(inst)) return new Instruction.HalfLiteral(name, predicate, LITERAL_HI.getval(inst), 0, true);
+ if (FLAGS.get(inst)) return new Instruction.SetFlags(name, predicate, (int)FLAGS_A.getval(inst), (int)FLAGS_B.getval(inst));
if (!MOVE.get(inst)) throw new RuntimeException("unknown instruction: 0x" + Long.toString(inst, 16));
boolean standing = STAND.get(inst);
boolean dataOutDest = PATH_DATA.get(inst);
return new Instruction.Move(name,
- Instruction.PredicatedInstruction.P_ALWAYS, /* FIXME */
+ predicate,
dest,
standing?0:1,
tokenIn,
if (d.pump != null)
instr = PUMP_NAME.setval(instr, getBoxInstAddr(d.pump));
+ if (d instanceof Instruction.PredicatedInstruction) {
+ Instruction.PredicatedInstruction pi = (Instruction.PredicatedInstruction)d;
+ switch(pi.predicate) {
+ case Instruction.PredicatedInstruction.P_ALWAYS: instr = P_ALWAYS.set(instr); break;
+ case Instruction.PredicatedInstruction.P_IF_A: instr = P_A.set(instr); break;
+ case Instruction.PredicatedInstruction.P_IF_B: instr = P_B.set(instr); break;
+ case Instruction.PredicatedInstruction.P_IF_Z: instr = P_Z.set(instr); break;
+ }
+ }
+
if (d instanceof Instruction.CodeBagDescriptor) {
Instruction.CodeBagDescriptor lc = (Instruction.CodeBagDescriptor)d;
// MAJOR MAJOR FIXME: upper half here...
- d = new Instruction.HalfLiteral(lc.pump, ((lc.offset << WIDTH_CODEBAG_SIZE)) | lc.size, 1, false);
+ d = new Instruction.HalfLiteral(lc.pump, Instruction.PredicatedInstruction.P_ALWAYS,
+ ((lc.offset << WIDTH_CODEBAG_SIZE)) | lc.size, 1, false);
}
if (d instanceof Instruction.UnClog) {