public static void readMem(FleetProcess fp, Ship memory, long offset, BitVector[] vals) throws RuntimeException {
doMem(true, fp, memory, offset, vals);
}
+ public static void writeMem(FleetProcess fp, Ship memory, long offset, long[] vals) throws RuntimeException {
+ doMem(false, fp, memory, offset, long2bv(fp.getFleet(), vals));
+ }
public static void writeMem(FleetProcess fp, Ship memory, long offset, BitVector[] vals) throws RuntimeException {
doMem(false, fp, memory, offset, vals);
}
System.out.println();
}
+ private static BitVector[] long2bv(Fleet fleet, long[] initialValues) {
+ BitVector[] bv = new BitVector[initialValues.length];
+ for(int i=0; i<initialValues.length; i++)
+ bv[i] = new BitVector(fleet.getWordWidth()).set(initialValues[i]);
+ return bv;
+ }
+
+ public static void putMemoryShipInDispatchMode(FleetProcess fp, Ship memoryShip) {
+ Context ctx = new Context(fp.getFleet());
+ LoopFactory lf;
+
+ lf = new LoopFactory(ctx, memoryShip.getDock("out"), 0);
+ lf.abortLoopIfTorpedoPresent();
+ lf.collectPacket();
+ lf.sendWord(null);
+
+ lf = new LoopFactory(ctx, memoryShip.getDock("inCBD"), 0);
+ lf.abortLoopIfTorpedoPresent();
+ lf.recvWord();
+ lf.deliver();
+
+ ctx.dispatch(fp);
+ }
+
+ public static void removeMemoryShipFromDispatchMode(FleetProcess fp, Ship memoryShip) {
+ fp.sendToken(memoryShip.getDock("out").getInstructionDestination());
+ fp.sendToken(memoryShip.getDock("inCBD").getInstructionDestination());
+ }
+
public static void main(String[] s) throws Exception {
Random random = new Random(System.currentTimeMillis());
Fleet fleet = new Fpga();