public LoopFactory getLoopFactory(Dock d) { return getLoopFactory(d, 0); }
public LoopFactory getNextLoopFactory(Dock d, int count) {
LoopFactory lf = loops.get(d);
- if (lf!=null) loops.put(d, lf = context.new LoopFactory(d, count, d+"", lf));
+ if (lf!=null) loops.put(d, lf = lf.makeNext(count, d+""));
return getLoopFactory(d, count);
}
public LoopFactory getLoopFactory(Dock d, int count) {
LoopFactory lf = loops.get(d);
if (lf==null) {
- loops.put(d, lf = context.new LoopFactory(d, count, d+"", null));
+ loops.put(d, lf = context.new LoopFactory(d, count, d+""));
emitLoops.add(lf);
}
if (lf.count != count) throw new RuntimeException();
public void emit(ArrayList<Instruction> al) {
for(Segment s : segments) s.emitPrologue(al);
for(Segment s : segments) s.emitInstructions(al);
- for(Segment s : segments) s.emitEpilogue(al);
for(LoopFactory lf : emitLoops) lf.emit(al);
}
public abstract Dock[] _setInputs();
public void emitPrologue(ArrayList<Instruction> il) { }
public abstract void emitInstructions(ArrayList<Instruction> il);
- public void emitEpilogue(ArrayList<Instruction> il) { }
}
public class Debug extends Segment {
public void emitPrologue(ArrayList<Instruction> il) { }
public void emitInstructions(ArrayList<Instruction> il) {
LoopFactory lf;
- lf = context.new LoopFactory(debugShip.getDock("in"), 0, "debug.in", null);
+ lf = context.new LoopFactory(debugShip.getDock("in"), 0, "debug.in");
lf.recvWord();
lf.deliver();
}
- public void emitEpilogue(ArrayList<Instruction> il) { }
}
public class Constant extends Segment {
lf = getNextLoopFactory(fifoShip.getDock("in"), 0);
lf.deliver();
}
- public void emitEpilogue(ArrayList<Instruction> il) {
- }
}
public class Alu extends Segment {
recvSendTokenDeliver(alu.getDock("inOp"), inputs[2].getDataDestination());
LoopFactory lf;
lf = getLoopFactory(inputs[2], 0);
- lf.send(alu.getDock("inOp").getDataDestination());
+ lf.sendWord(alu.getDock("inOp").getDataDestination());
lf.recvToken();
} else {
LoopFactory lf;
recvSendTokenDeliver(alu.getDock("in1"), inputs[0].getDataDestination());
LoopFactory lf;
lf = getLoopFactory(inputs[0], 0);
- lf.send(alu.getDock("in1").getDataDestination());
+ lf.sendWord(alu.getDock("in1").getDataDestination());
lf.recvToken();
recvSendTokenDeliver(alu.getDock("in2"), inputs[1].getDataDestination());
lf = getLoopFactory(inputs[1], 0);
- lf.send(alu.getDock("in2").getDataDestination());
+ lf.sendWord(alu.getDock("in2").getDataDestination());
lf.recvToken();
}
- public void emitEpilogue(ArrayList<Instruction> il) {
- }
}
public class Counter extends Segment {
lf.literal(incr);
lf = getNextLoopFactory(alu.getDock("in2"), 0);
lf.deliver();
- }
- public void emitEpilogue(ArrayList<Instruction> il) {
- LoopFactory lf;
+
lf = getLoopFactory(alu.getDock("out"), 0);
- lf.send(alu.getDock("in1").getDataDestination());
+ lf.sendWord(alu.getDock("in1").getDataDestination());
lf.collectWord();
}
}
public void emitInstructions(ArrayList<Instruction> il) {
LoopFactory lf;
- lf = getLoopFactory(alu.getDock("inOp"), 0);
- lf.literal(4); // MAX
- lf.deliver();
+ lf = getLoopFactory(alu.getDock("inOp"), 1);
lf.literal(4); // MAX
+ lf = getNextLoopFactory(alu.getDock("inOp"), 0);
lf.deliver();
lf = getLoopFactory(alu.getDock("in1"), 0);
lf.deliver();
lf = getLoopFactory(inputs[0], 0);
- lf.send(alu.getDock("in2").getDataDestination());
- lf.send(alu.getDock("in1").getDataDestination());
+ lf.sendWord(alu.getDock("in2").getDataDestination());
+ lf.sendWord(alu.getDock("in1").getDataDestination());
lf.recvToken();
lf.recvToken();
}
-
- public void emitEpilogue(ArrayList<Instruction> il) { }
}
public class FifoWithInit extends Segment {
}
public void emitPrologue(ArrayList<Instruction> il) {
LoopFactory lf;
- lf = getLoopFactory(fifoShip.getDock("out"), 1);
+ lf = getLoopFactory(fifoShip.getDock("in"), 1);
lf.literal(init);
- lf = getNextLoopFactory(fifoShip.getDock("out"), 0);
- lf = getLoopFactory(fifoShip.getDock("in"), 0);
+ lf.deliver();
+ lf = getNextLoopFactory(fifoShip.getDock("in"), 0);
+
+ lf = getLoopFactory(fifoShip.getDock("out"), 0);
+ lf.collectWord();
}
public void emitInstructions(ArrayList<Instruction> il) {
LoopFactory lf;
lf = getLoopFactory(inputs[0], 0);
- lf.send(fifoShip.getDock("in").getDataDestination());
+ lf.sendWord(fifoShip.getDock("in").getDataDestination());
lf.recvToken();
recvSendTokenDeliver(fifoShip.getDock("in"), inputs[0].getDataDestination());
}
- public void emitEpilogue(ArrayList<Instruction> il) {
- LoopFactory lf;
- lf = getLoopFactory(fifoShip.getDock("out"), 0);
- lf.collectWord();
- }
}
public class Video extends Segment {
LoopFactory lf;
lf = getLoopFactory(inputs[0]);
- lf.send(videoShip.getDock("inX").getDataDestination());
+ lf.sendWord(videoShip.getDock("inX").getDataDestination());
lf.recvToken();
lf = getLoopFactory(inputs[1]);
- lf.send(videoShip.getDock("inY").getDataDestination());
+ lf.sendWord(videoShip.getDock("inY").getDataDestination());
lf.recvToken();
lf = getLoopFactory(inputs[2]);
- lf.send(videoShip.getDock("inData").getDataDestination());
+ lf.sendWord(videoShip.getDock("inData").getDataDestination());
lf.recvToken();
}
- public void emitEpilogue(ArrayList<Instruction> il) { }
}
public static Dock bouncer(New n, int delt, int start, int min, int max) throws Exception {
"Fifo", "Fifo",
"Fifo", "Fifo",
"Fifo", "Fifo",
- "alu2", "alu2",
- "alu2", "alu2",
- "alu2", "alu2",
- "alu2", "alu2",
- "alu2", "alu2",
- "alu2", "alu2",
+ "Alu", "Alu",
+ "Alu", "Alu",
+ "Alu", "Alu",
+ "Alu", "Alu",
+ "Alu", "Alu",
+ "Alu", "Alu",
"Video"
}, false));
Dock x_pos = bouncer(n, 1, 6, 5, 634);
Dock y_pos = bouncer(n, 1, 6, 5, 474);
- //Dock color = n.new Constant(2).setInputs(new Dock[0])[0];
- Dock color = n.new Counter(0,1).setInputs(new Dock[0])[0];
+ Dock color = n.new Constant(2).setInputs(new Dock[0])[0];
+ //Dock color = n.new Counter(0,1).setInputs(new Dock[0])[0];
//debug.setInputs(new Dock[] { x_pos });
Video vid = n.new Video();