1 package edu.berkeley.fleet.ir;
4 import edu.berkeley.fleet.two.*;
5 import edu.berkeley.fleet.api.*;
6 import edu.berkeley.fleet.fpga.*;
7 import edu.berkeley.fleet.api.Instruction.*;
8 import edu.berkeley.fleet.api.Instruction.Set;
9 import edu.berkeley.fleet.api.Instruction.Set.*;
10 import static edu.berkeley.fleet.api.Predicate.*;
11 import static edu.berkeley.fleet.util.BitManipulations.*;
15 - refactor the cleanup into the subclasses of Port (phase1, phase2, etc)
18 // does peer.recvWord() have to honor the currently-set predicate?
20 // public class ReplaceModule extends Module { }
21 // public class CountMergeModule extends Module { }
22 // public class SortMergeModule extends Module { }
23 // public class FanOutModule extends Module { }
24 // public class MemoryModule extends Module { }
25 // public class DoneModule extends Module { }
27 public class Process {
29 public static int reset_count = 0;
30 public static HashSet<Dock> torpedoes = new HashSet<Dock>();
32 public final Fleet fleet;
33 public final ShipPool pool;
35 public Process(Fleet fleet) {
37 this.pool = new ShipPool(fleet);
40 private HashSet<Module> modules = new HashSet<Module>();
42 public void build(Context ctx) {
43 for(Module mod : modules)
46 public void reset(Context ctx, int phase) {
49 for(Module mod : modules)
50 mod.reset(ctx, phase);
56 Process.this.modules.add(this);
59 private HashMap<String,Port> ports = new HashMap<String,Port>();
61 public InPort getInPort(String name) { return (InPort)ports.get(name); }
62 public OutPort getOutPort(String name) { return (OutPort)ports.get(name); }
64 public void build(Context ctx) { for(Port p : ports.values()) p.build(ctx); }
65 public void reset(Context ctx, int phase) { for(Port p : ports.values()) p.reset(ctx, phase); }
67 public abstract class Port {
68 public final String name;
69 public Port(String name) {
71 if (Module.this.ports.get(name)!=null) throw new RuntimeException();
72 Module.this.ports.put(name,this);
74 public abstract void build(Context ctx);
75 public abstract void reset(Context ctx, int phase);
78 public abstract class InPort extends Port {
80 public InPort(String name) { super(name); }
81 public void connect(OutPort peer) {
85 public void setPeer(OutPort peer) {
86 if (this.peer!=null) throw new RuntimeException("cannot call setPeer() twice");
90 /** this port's peer (an OutPort) invokes this to have "recvToken" or equivalent inserted */
91 public abstract void recvToken(Context.LoopFactory loopfactory_at_output_dock);
92 /** this port's peer (an OutPort) invokes this to have "sendWord" or equivalent inserted */
93 public abstract void sendWord(Context.LoopFactory loopfactory_at_output_dock);
95 public int getTokensToAbsorb() { return 0; }
98 public abstract class OutPort extends Port {
100 public OutPort(String name) { super(name); }
101 public void connect(InPort peer) {
105 public void setPeer(InPort peer) {
106 if (this.peer!=null) throw new RuntimeException("cannot call setPeer() twice");
110 /** this port's peer (an InPort) invokes this to have "sendToken" or equivalent inserted */
111 public abstract void sendToken(Context.LoopFactory loopfactory_at_input_dock);
112 /** this port's peer (an InPort) invokes this to have "recvWord" or equivalent inserted */
113 public abstract void recvWord(Context.LoopFactory loopfactory_at_input_dock);
116 public final class DockInPort extends InPort {
120 public DockInPort(String name, Dock dock) { this(name, dock, 0); }
121 public DockInPort(String name, Dock dock, int count) { this(name, dock, count, new BitVector[] { null }); }
122 public DockInPort(String name, Dock dock, int count, BitVector[] pattern) {
126 this.pattern = pattern;
128 public void recvToken(Context.LoopFactory lf) { lf.recvToken(); }
129 public void sendWord(Context.LoopFactory lf) { lf.sendWord(dock.getDataDestination()); }
130 public void build(Context ctx) {
131 if (peer==null && pattern.length==1 && pattern[0]==null) return;
132 build(ctx, ctx.new LoopFactory(dock, 1));
134 // number-in-flight is considered a property of the input dock in a pair
135 //public int getInflight() { return 4; }
136 public int getInflight() { return 1; }
137 public int getTokensToAbsorb() { return getInflight(); }
138 public void reset(Context ctx, int phase) {
139 if (dock.getShip().getType().equals("Debug")) {
142 if (peer==null && pattern.length==1 && pattern[0]==null) return;
151 Context.LoopFactory lf = ctx.new LoopFactory(dock, 1);
152 lf.sendToken(fleet.getShip("Debug",0).getDock("in").getDataDestination());
153 if (peer != null && peer instanceof DockOutPort) {
154 DockOutPort dop_peer = (DockOutPort)peer;
156 lf.abortLoopIfTorpedoPresent();
158 lf.sendToken(dop_peer.dock.getDataDestination());
163 if (peer != null && peer instanceof DockOutPort) {
170 protected void build(Context ctx, Context.LoopFactory lf) {
171 if (peer==null && pattern.length==1 && pattern[0]==null) return;
172 int inflight = (count != 0 && count < getInflight()) ? count : getInflight();
175 for(int i=0; i<inflight; i++) peer.sendToken(lf);
177 lf = lf.makeNext(count);
178 for(int i=0; i<pattern.length; i++) {
179 if (pattern[i]==null) {
180 lf.abortLoopIfTorpedoPresent();
185 lf.literal(pattern[i]);
186 lf.abortLoopIfTorpedoPresent();
192 // "torpedoable nop" to keep the dock in a receptive state
193 lf.abortLoopIfTorpedoPresent();
199 public /*final*/ class DockOutPort extends OutPort {
200 public final Dock dock;
201 public final int count;
202 public DockOutPort(String name, Dock dock) { this(name, dock, 0); }
203 public DockOutPort(String name, Dock dock, int count) { super(name); this.dock = dock; this.count = count; }
204 public void sendToken(Context.LoopFactory lf) { lf.sendToken(dock.getDataDestination()); }
205 public void recvWord(Context.LoopFactory lf) { lf.recvWord(); }
206 public void build(Context ctx) { build(ctx, ctx.new LoopFactory(dock, 1)); }
207 protected void build(Context ctx, Context.LoopFactory lf) {
208 if (peer==null) return;
210 lf = lf.makeNext(count);
211 lf.abortLoopIfTorpedoPresent();
213 //lf.abortLoopIfTorpedoPresent(); // FIXME: do I need this twice?
218 public void reset(Context ctx, int phase) {
226 Context.LoopFactory lf = ctx.new LoopFactory(dock, 1);
228 //System.out.println("absorbing tokens from " + dip_peer.dock + " to " + dock + "(a "+Module.this.getClass().getName()+")");
229 for(int i=0; i<peer.getTokensToAbsorb(); i++) {
232 //lf.sendToken(dip_peer.dock.getInstructionDestination());
234 lf.sendToken(fleet.getShip("Debug",0).getDock("in").getDataDestination());
236 lf.abortLoopIfTorpedoPresent();
249 private BitVector bv(long l) { return new BitVector(fleet.getWordWidth()).set(l); }
252 * For every datum transmitted to in, pass it along to out and
253 * deliver the constant at out. Flow control in<->out is
254 * maintained, but out is not flow-controlled, so be sure
255 * that every datum sent there is consumed synchronously wiht
256 * data items sent to out.
258 public class ForeverModule extends Module {
259 private BitVector bv;
260 public final OutPort out = new OutPort("out") {
261 public void sendToken(Context.LoopFactory lf) { }
262 public void recvWord(Context.LoopFactory lf) { }
263 public void build(Context ctx) { }
264 public void reset(Context ctx, int phase) { }
265 public void setPeer(InPort peer) {
267 DockInPort pip = ((DockInPort)peer);
268 for(int i=0; i<pip.pattern.length; i++) {
269 if (pip.pattern[i]==null)
274 public ForeverModule(long l) { this(new BitVector(fleet.getWordWidth()).set(l)); }
275 public ForeverModule(final BitVector bv) { this.bv = bv; }
278 public class OnceModule extends Module {
279 private BitVector bv;
280 public final OutPort out = new OutPort("out") {
281 public void sendToken(Context.LoopFactory lf) { }
282 public void recvWord(Context.LoopFactory lf) { }
283 public void build(Context ctx) { }
284 public void reset(Context ctx, int phase) { }
285 public void setPeer(InPort peer) {
287 DockInPort pip = ((DockInPort)peer);
288 BitVector[] pip_pattern = pip.pattern;
289 BitVector[] temp = new BitVector[pip_pattern.length * 2];
292 boolean done = false;
293 // FIXME: if peer.count is already 1, this gets simpler and different
294 for(i=0; i<temp.length; i++) {
295 if (pip_pattern[j] != null) {
296 temp[i] = pip_pattern[j];
303 if (j >= pip_pattern.length) j = 0;
305 pip.pattern = new BitVector[i];
306 System.arraycopy(temp, 0, pip.pattern, 0, i);
310 public OnceModule(long l) { this(new BitVector(fleet.getWordWidth()).set(l)); }
311 public OnceModule(final BitVector bv) { this.bv = bv; }
314 public class DebugModule extends Module {
315 public final Ship ship = pool.allocateShip("Debug");
316 public final InPort in = new DockInPort("in", ship.getDock("in"));
317 // NOTE: shutdown needs to treat this specially
318 public DebugModule() { }
321 public class UnPunctuatorModule extends Module {
322 private final Ship ship = pool.allocateShip("Counter");
323 public final OutPort out = new DockOutPort("out", ship.getDock("out"));
324 public final InPort val = new DockInPort("in1", ship.getDock("in1"));
325 public final InPort count = new DockInPort("in2", ship.getDock("in2"), 0, new BitVector[] { null, bv(1) });
326 public final InPort op = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { bv(6 /*PASS_C2_V1*/), bv(10 /*DROP_C2_V1*/) } );
327 public UnPunctuatorModule() { }
330 public class PunctuatorModule extends Module {
331 private final long punc;
332 private final Ship ship = pool.allocateShip("Counter");
333 public final OutPort out = new DockOutPort("out", ship.getDock("out"));
334 public final InPort val = new DockInPort("in1", ship.getDock("in1"));
335 public final InPort op = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { bv(6 /*PASS_C2_V1*/), bv(7 /*PASS_C2_V2*/) } );
336 public final InPort count;
337 public PunctuatorModule(long punc) {
339 this.count = new DockInPort("in2", ship.getDock("in2"), 0, new BitVector[] { null, bv(1), bv(punc) });
343 public class AluModule extends Module {
344 public final Ship ship = pool.allocateShip("Alu");
345 public final InPort in1 = new DockInPort("in1", ship.getDock("in1"));
346 public final InPort in2 = new DockInPort("in2", ship.getDock("in2"));
347 public final InPort inOp = new DockInPort("inOp", ship.getDock("inOp"));
348 public final OutPort out = new DockOutPort("out", ship.getDock("out"));
349 public AluModule() { }
352 public class DownCounterModule extends Module {
353 public final Ship ship = pool.allocateShip("Counter");
354 public final InPort start = new DockInPort("in1", ship.getDock("in1"));
355 public final InPort incr = new DockInPort("in2", ship.getDock("in2"));
356 public final InPort inOp = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { bv(12 /*COUNTDOWN*/) });
357 public final OutPort out = new DockOutPort("out", ship.getDock("out"));
358 public DownCounterModule() { }
361 public class RepeatModule extends Module {
362 public final Ship ship = pool.allocateShip("Counter");
363 public final InPort count = new DockInPort("in1", ship.getDock("in1"));
364 public final InPort val = new DockInPort("in2", ship.getDock("in2"));
365 public final InPort inOP = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { bv(1 /*REPEAT_C1_V2*/) });
366 public final OutPort out = new DockOutPort("out", ship.getDock("out"));
367 public RepeatModule() { }
370 public class SortedMergeModule extends Module {
371 public final Ship ship = pool.allocateShip("Alu");
372 public final InPort in1 = new DockInPort("in1", ship.getDock("in1"));
373 public final InPort in2 = new DockInPort("in2", ship.getDock("in2"));
374 public final InPort inOp = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { bv(9 /*MAXMERGE*/) });
375 public final OutPort out = new DockOutPort("out", ship.getDock("out"));
376 public SortedMergeModule() { }
379 public class MemoryModule extends Module {
380 public final Ship ship;
381 public final InPort inAddrRead1;
382 public final InPort inAddrRead2;
383 public final InPort inAddrWrite;
384 public final InPort inDataWrite;
385 public final OutPort outRead1;
386 public final OutPort outRead2;
387 public MemoryModule(Ship memoryShip) {
388 this.ship = memoryShip;
389 this.inAddrWrite = new DockInPort("inAddrWrite", ship.getDock("inAddrWrite"));
390 this.inDataWrite = new DockInPort("inDataWrite", ship.getDock("inDataWrite"));
391 this.inAddrRead1 = new InPort("inAddrRead1") {
392 public void recvToken(Context.LoopFactory lf) { lf.recvToken(); }
393 public void sendWord(Context.LoopFactory lf) { lf.sendWord(ship.getDock("inAddrRead").getDataDestination(), new BitVector(1).set(0)); }
394 public void build(Context ctx) { }
395 public int getTokensToAbsorb() { return outRead1.peer.getTokensToAbsorb(); }
396 public void reset(Context ctx, int phase) {
398 torpedoes.add(ship.getDock("inAddrRead"));
399 torpedoes.add(ship.getDock("out"));
403 this.inAddrRead2 = new InPort("inAddrRead2") {
404 public void recvToken(Context.LoopFactory lf) { lf.recvToken(); }
405 public void sendWord(Context.LoopFactory lf) { lf.sendWord(ship.getDock("inAddrRead").getDataDestination(), new BitVector(1).set(1)); }
406 public void build(Context ctx) { }
407 public int getTokensToAbsorb() { return outRead2.peer.getTokensToAbsorb(); }
408 public void reset(Context ctx, int phase) {
410 torpedoes.add(ship.getDock("inAddrRead"));
411 torpedoes.add(ship.getDock("out"));
415 this.outRead1 = new OutPort("outRead1") {
416 public void sendToken(Context.LoopFactory lf) { inAddrRead1.peer.sendToken(lf); }
417 public void recvWord(Context.LoopFactory lf) { lf.recvWord(); }
418 public void build(Context ctx) { }
419 public void reset(Context ctx, int phase) { }
421 this.outRead2 = new OutPort("outRead2") {
422 public void sendToken(Context.LoopFactory lf) { inAddrRead2.peer.sendToken(lf); }
423 public void recvWord(Context.LoopFactory lf) { lf.recvWord(); }
424 public void build(Context ctx) { }
425 public void reset(Context ctx, int phase) { }
428 public void build(Context ctx) {
430 Context.LoopFactory lf;
432 lf = ctx.new LoopFactory(ship.getDock("inAddrRead"), 0);
433 lf.abortLoopIfTorpedoPresent();
435 lf.setFlags(FlagFunction.ZERO.add(FlagC), FlagFunction.ZERO);
436 lf.setPredicate(Predicate.NotFlagA);
437 lf.sendToken(ship.getDock("out").getDataDestination(), new BitVector(1).set(0));
438 lf.setPredicate(Predicate.FlagA);
439 lf.sendToken(ship.getDock("out").getDataDestination(), new BitVector(1).set(1));
440 lf.setPredicate(null);
443 lf = ctx.new LoopFactory(ship.getDock("out"), 0);
444 lf.abortLoopIfTorpedoPresent();
446 lf.setFlags(FlagFunction.ZERO, FlagFunction.ZERO.add(FlagC));
447 lf.setPredicate(Predicate.FlagB);
448 // here: any code to be executed when inDataWrite gets completed
449 lf.setPredicate(Predicate.NotFlagB);
450 lf.abortLoopIfTorpedoPresent();
452 lf.setFlags(FlagFunction.ZERO.add(NotFlagC).add(FlagB), FlagFunction.ZERO.add(FlagC).add(FlagB));
453 if (outRead1.peer != null) {
454 lf.setPredicate(Predicate.NotFlagB);
455 outRead1.peer.sendWord(lf);
457 if (outRead2.peer != null) {
458 lf.setPredicate(Predicate.NotFlagA);
459 outRead2.peer.sendWord(lf);
461 lf.setPredicate(null);
465 public static void main(String[] s) throws Exception {
466 Fleet fleet = new Fpga();
467 Random random = new Random(System.currentTimeMillis());
468 long[] vals = new long[256];
469 for(int i=0; i<vals.length; i++) {
470 vals[i] = Math.abs(random.nextInt());
476 while(stride < vals.length) {
477 if (fp==null) fp = fleet.run(new Instruction[0]);
478 System.out.println("stride " + stride);
479 vals = mergeSort(fp, fleet, vals, stride);
481 //fp.terminate(); fp = null;
482 System.out.println();
483 System.out.println("results:");
484 for(int i=0; i<vals.length; i++)
485 System.out.println(vals[i]);
489 // won't verify that the switch fabric is empty, however
490 public static void verifyClean(FleetProcess fp) {
491 Ship debug = fp.getFleet().getShip("Debug", 0);
492 Dock debugIn = debug.getDock("in");
495 Context.LoopFactory lf;
497 ctx = new Context(fp.getFleet());
498 lf = ctx.new LoopFactory(debugIn, 1);
503 ArrayList<Instruction> ai = new ArrayList<Instruction>();
505 for(Instruction ins : ai) fp.sendInstruction(ins);
508 System.out.println("checking debug.in");
509 if (fp.recvWord().toLong() != 12) throw new RuntimeException("debug dock not properly initialized");
510 if (fp.recvWord().toLong() != 5) throw new RuntimeException("debug dock not properly initialized");
513 for(Ship ship : fp.getFleet())
514 if (!"Debug".equals(ship.getType()))
515 for (Dock dock : ship) {
516 System.out.println("checking " + dock);
518 k = (k + 23) % 65535;
519 ctx = new Context(fp.getFleet());
521 boolean reverse = (k%2)==0;
523 lf = ctx.new LoopFactory(debugIn, 2);
525 lf.setFlags(FlagFunction.ZERO.add(FlagC), FlagFunction.ZERO);
526 lf.setPredicate(Predicate.NotFlagA);
528 lf.setPredicate(Predicate.FlagA);
530 lf.setPredicate(null);
533 lf = ctx.new LoopFactory(dock, 1);
534 lf.sendToken(dock.getDataDestination(), new BitVector(1).set(reverse ? 1 : 0));
535 lf.sendToken(dock.getDataDestination(), new BitVector(1).set(reverse ? 0 : 1));
538 lf.setFlags(FlagFunction.ZERO.add(FlagC), FlagFunction.ZERO);
539 lf.setPredicate(Predicate.NotFlagA);
540 lf.sendToken(debugIn.getDataDestination(), new BitVector(1).set(0));
541 lf.setPredicate(Predicate.FlagA);
542 lf.sendToken(debugIn.getDataDestination(), new BitVector(1).set(1));
543 lf.setPredicate(null);
545 ai = new ArrayList<Instruction>();
547 for(Instruction ins : ai) fp.sendInstruction(ins);
551 kk = fp.recvWord().toLong();
552 if (kk != (reverse ? k+1 : k))
553 throw new RuntimeException(dock+" not properly initialized (1)");
554 kk = fp.recvWord().toLong();
555 if (kk != (reverse ? k : k+1))
556 throw new RuntimeException(dock+" not properly initialized (2)");
560 // FIXME: numbers seem to get duplicated when stride=2
561 public static long[] mergeSort(FleetProcess fp, Fleet fleet, long[] vals, int stride_length) throws Exception {
563 BitVector[] mem = new BitVector[vals.length];
564 for(int i=0; i<mem.length; i++) mem[i] = new BitVector(fleet.getWordWidth()).set(vals[i]);
566 Ship memoryShip = fleet.getShip("DRAM", 0);
567 Gadgets.writeMem(fp, memoryShip, 0, mem);
569 //////////////////////////////////////////////////////////////////////////////
571 Process proc = new Process(fleet);
572 DebugModule dm = proc.new DebugModule();
574 int end_of_data = vals.length;
575 int num_strides = end_of_data / (stride_length * 2);
577 MemoryModule mm = proc.new MemoryModule(memoryShip);
578 SortedMergeModule sm = proc.new SortedMergeModule();
581 for(int i=0; i<2; i++) {
583 Module.OutPort stride_length_1 = proc.new OnceModule(stride_length).out;
584 Module.OutPort stride_length_2 = proc.new OnceModule(stride_length).out;
585 Module.OutPort twice_stride_length_1 = proc.new OnceModule(stride_length*2).out;
586 Module.OutPort end_of_data_1 = proc.new OnceModule(end_of_data + i*stride_length).out;
588 Module.OutPort num_strides_1 = proc.new OnceModule(num_strides).out;
589 Module.OutPort num_strides_2 = proc.new OnceModule(num_strides).out;
591 RepeatModule r0 = proc.new RepeatModule();
592 RepeatModule r1 = proc.new RepeatModule();
593 RepeatModule r2 = proc.new RepeatModule();
594 DownCounterModule c0 = proc.new DownCounterModule();
595 DownCounterModule c1 = proc.new DownCounterModule();
596 ForeverModule fmm = proc.new ForeverModule(1);
597 ForeverModule fmm2 = proc.new ForeverModule(2); // 2=ADD
598 AluModule alu = proc.new AluModule();
600 stride_length_1.connect(r0.val);
601 num_strides_1.connect(r0.count);
602 r0.out.connect(c0.start);
603 fmm.out.connect(c0.incr);
604 c0.out.connect(alu.in2);
606 end_of_data_1.connect(c1.start);
607 twice_stride_length_1.connect(c1.incr);
608 c1.out.connect(r1.val);
609 stride_length_2.connect(r2.val);
610 num_strides_2.connect(r2.count);
611 r2.out.connect(r1.count);
612 r1.out.connect(alu.in1);
613 fmm2.out.connect(alu.inOp);
615 alu.out.connect(i==0 ? mm.inAddrRead1 : mm.inAddrRead2);
617 ForeverModule fm = proc.new ForeverModule(stride_length);
618 PunctuatorModule punc = proc.new PunctuatorModule(-1);
619 fm.out.connect(punc.count);
620 (i==0 ? mm.outRead1 : mm.outRead2).connect(punc.val);
621 punc.out.connect(i==0 ? sm.in1 : sm.in2);
624 ForeverModule fm = proc.new ForeverModule(2*stride_length);
625 UnPunctuatorModule unpunc = proc.new UnPunctuatorModule();
626 sm.out.connect(unpunc.val);
627 fm.out.connect(unpunc.count);
628 unpunc.out.connect(dm.in);
630 //////////////////////////////////////////////////////////////////////////////
632 Context ctx = new Context(fp.getFleet());
633 ctx.setAutoflush(true);
635 ArrayList<Instruction> ai = new ArrayList<Instruction>();
638 for(Instruction ins : ai) {
639 System.out.println(ins);
640 fp.sendInstruction(ins);
644 System.out.println("reading back...");
646 for(int i=0; i<vals.length; i++) {
648 BitVector bv = fp.recvWord();
649 System.out.println("\r"+bv + " " + bv.toLong() + " #read="+inc);
652 System.out.println("\rdone. ");
653 long[] ret = new long[vals.length];
654 for(int i=0; i<ret.length; i++) ret[i] = mem[ret.length-i-1].toLong();
656 //if (true) return ret;
658 Context ctx2 = new Context(fp.getFleet());
659 Dock debugIn = fleet.getShip("Debug",0).getDock("in");
661 fp.sendToken(debugIn.getInstructionDestination());
663 Context.LoopFactory lf = ctx2.new LoopFactory(debugIn, 0);
665 lf.abortLoopIfTorpedoPresent();
669 ctx2.emit(ai = new ArrayList<Instruction>());
670 for(Instruction ins : ai)
671 fp.sendInstruction(ins);
676 for(int phase=0; phase<=2; phase++) {
677 System.out.println("== phase "+phase+" ==================================================================");
678 ctx2 = new Context(fp.getFleet());
679 proc.reset(ctx2, phase);
680 for(Dock dock : torpedoes) fp.sendToken(dock.getInstructionDestination());
681 ctx2.emit(ai = new ArrayList<Instruction>());
682 for(Instruction ins : ai) fp.sendInstruction(ins);
684 System.out.println("flushed");
685 for(int ii=0; ii<reset_count; ii++)
686 System.out.print("\r phase "+phase+" ==> " + fp.recvWord().toLong() + " " + (ii+1) + " / " + reset_count);
687 System.out.println();
691 ctx2 = new Context(fp.getFleet());
692 ai = new ArrayList<Instruction>();
693 for(Ship ship : ctx.allocatedShips)
694 if (!ship.getType().equals("Debug"))
695 for(Dock dock : ship)
696 if (dock.isInputDock()) {
697 lf = ctx2.new LoopFactory(dock, 0);
703 fp.sendToken(debugIn.getInstructionDestination());
706 //System.out.println("verifying cleanup:");
711 private BitVector[] longsToBitVectors(long[] initialValues) {
712 BitVector[] bv = new BitVector[initialValues.length];
713 for(int i=0; i<initialValues.length; i++)
714 bv[i] = new BitVector(fleet.getWordWidth()).set(initialValues[i]);