From: adam Date: Mon, 3 Nov 2008 13:00:59 +0000 (+0100) Subject: more sophisticated version of Process.verifyClean() X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=9db671f990c00be011120d9661601f7e29d288de;p=fleet.git more sophisticated version of Process.verifyClean() --- diff --git a/src/edu/berkeley/fleet/ir/Process.java b/src/edu/berkeley/fleet/ir/Process.java index e63e905..ad27f6a 100644 --- a/src/edu/berkeley/fleet/ir/Process.java +++ b/src/edu/berkeley/fleet/ir/Process.java @@ -493,7 +493,7 @@ public class Process { if (fp.recvWord().toLong() != 12) throw new RuntimeException("debug dock not properly initialized"); if (fp.recvWord().toLong() != 5) throw new RuntimeException("debug dock not properly initialized"); - int k = 0; + long k = 0; for(Ship ship : fp.getFleet()) if (!"Debug".equals(ship.getType())) for (Dock dock : ship) { @@ -501,19 +501,43 @@ public class Process { k = (k + 23) % 65535; ctx = new Context(fp.getFleet()); - lf = ctx.new LoopFactory(debugIn, 1); - lf.literal(k); + + boolean reverse = (k%2)==0; + + lf = ctx.new LoopFactory(debugIn, 2); lf.recvToken(); + lf.setFlags(FlagFunction.ZERO.add(FlagC), FlagFunction.ZERO); + lf.setPredicate(Predicate.NotFlagA); + lf.literal(k); + lf.setPredicate(Predicate.FlagA); + lf.literal(k+1); + lf.setPredicate(null); lf.deliver(); + lf = ctx.new LoopFactory(dock, 1); - lf.sendToken(debugIn.getDataDestination()); + lf.sendToken(dock.getDataDestination(), new BitVector(1).set(reverse ? 1 : 0)); + lf.sendToken(dock.getDataDestination(), new BitVector(1).set(reverse ? 0 : 1)); + lf = lf.makeNext(2); + lf.recvToken(); + lf.setFlags(FlagFunction.ZERO.add(FlagC), FlagFunction.ZERO); + lf.setPredicate(Predicate.NotFlagA); + lf.sendToken(debugIn.getDataDestination(), new BitVector(1).set(0)); + lf.setPredicate(Predicate.FlagA); + lf.sendToken(debugIn.getDataDestination(), new BitVector(1).set(1)); + lf.setPredicate(null); + ai = new ArrayList(); ctx.emit(ai); for(Instruction ins : ai) fp.sendInstruction(ins); fp.flush(); - if (fp.recvWord().toLong() != k) - throw new RuntimeException(dock+" not properly initialized"); + long kk; + kk = fp.recvWord().toLong(); + if (kk != (reverse ? k+1 : k)) + throw new RuntimeException(dock+" not properly initialized (1)"); + kk = fp.recvWord().toLong(); + if (kk != (reverse ? k : k+1)) + throw new RuntimeException(dock+" not properly initialized (2)"); } }