From 6c5d837062ad030263a636ae4f92ffde94faab55 Mon Sep 17 00:00:00 2001 From: adam Date: Tue, 4 Nov 2008 08:09:57 +0100 Subject: [PATCH] proper outWrite port on MemoryModule --- src/edu/berkeley/fleet/ir/Process.java | 49 +++++++++++++++++++------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/edu/berkeley/fleet/ir/Process.java b/src/edu/berkeley/fleet/ir/Process.java index b160757..eb31fc2 100644 --- a/src/edu/berkeley/fleet/ir/Process.java +++ b/src/edu/berkeley/fleet/ir/Process.java @@ -385,6 +385,7 @@ public class Process { public final InPort inDataWrite; public final OutPort outRead1; public final OutPort outRead2; + public final OutPort outWrite; public MemoryModule(Ship memoryShip) { this.ship = memoryShip; this.inAddrWrite = new DockInPort("inAddrWrite", ship.getDock("inAddrWrite")); @@ -425,6 +426,34 @@ public class Process { public void build(Context ctx) { } public void reset(Context ctx, int phase) { } }; + this.outWrite = new DockOutPort("out", ship.getDock("out")) { + protected void build(Context ctx, Context.LoopFactory lf) { + lf = lf.makeNext(0); + lf.abortLoopIfTorpedoPresent(); + lf.collectWord(); + + lf.setFlags(FlagFunction.ZERO, FlagFunction.ZERO.add(FlagC)); + if (this.peer != null) { + lf.setPredicate(Predicate.FlagB); + this.peer.recvToken(lf); + this.peer.sendWord(lf); + } + + lf.setPredicate(Predicate.NotFlagB); + lf.abortLoopIfTorpedoPresent(); + lf.recvToken(); + lf.setFlags(FlagFunction.ZERO.add(NotFlagC).add(FlagB), FlagFunction.ZERO.add(FlagC).add(FlagB)); + if (outRead1.peer != null) { + lf.setPredicate(Predicate.NotFlagB); + outRead1.peer.sendWord(lf); + } + if (outRead2.peer != null) { + lf.setPredicate(Predicate.NotFlagA); + outRead2.peer.sendWord(lf); + } + lf.setPredicate(null); + } + }; } public void build(Context ctx) { super.build(ctx); @@ -440,26 +469,6 @@ public class Process { lf.sendToken(ship.getDock("out").getDataDestination(), new BitVector(1).set(1)); lf.setPredicate(null); lf.deliver(); - - lf = ctx.new LoopFactory(ship.getDock("out"), 0); - lf.abortLoopIfTorpedoPresent(); - lf.collectWord(); - lf.setFlags(FlagFunction.ZERO, FlagFunction.ZERO.add(FlagC)); - lf.setPredicate(Predicate.FlagB); - // here: any code to be executed when inDataWrite gets completed - lf.setPredicate(Predicate.NotFlagB); - lf.abortLoopIfTorpedoPresent(); - lf.recvToken(); - lf.setFlags(FlagFunction.ZERO.add(NotFlagC).add(FlagB), FlagFunction.ZERO.add(FlagC).add(FlagB)); - if (outRead1.peer != null) { - lf.setPredicate(Predicate.NotFlagB); - outRead1.peer.sendWord(lf); - } - if (outRead2.peer != null) { - lf.setPredicate(Predicate.NotFlagA); - outRead2.peer.sendWord(lf); - } - lf.setPredicate(null); } } -- 1.7.10.4