3119f3999ebfd9328d0dc91e77deeb6aa008b7c4
[fleet.git] / src / edu / berkeley / fleet / dataflow / ForeverNode.java
1 package edu.berkeley.fleet.dataflow;
2 import edu.berkeley.fleet.loops.*;
3 import edu.berkeley.fleet.api.*;
4
5 /**
6  *  Deliver the constant at out forever.  Flow control in<->out is
7  *  maintained, but out is not flow-controlled, so be sure
8  *  that every datum sent there is consumed synchronously wiht
9  *  data items sent to out.
10  */
11 public class ForeverNode extends Node {
12     private BitVector bv;
13     public final OutPort out = new OutPort("out") {
14             public void sendToken(LoopFactory lf) { }
15             public void recvWord(LoopFactory lf) { }
16             public void build(Context ctx) { }
17             public void reset(Context ctx, int phase, Destination ackDestination) { }
18             public void setPeer(InPort peer) {
19                 this.peer = peer;
20                 DockInPort pip = ((DockInPort)peer);
21                 for(int i=0; i<pip.pattern.length; i++) {
22                     if (pip.pattern[i]==null)
23                         pip.pattern[i] = bv;
24                 }
25             }
26         };
27     public ForeverNode(DataFlowGraph dfg, long l) { this(dfg, new BitVector(dfg.fleet.getWordWidth()).set(l)); }
28     public ForeverNode(DataFlowGraph dfg, final BitVector bv) { super(dfg); this.bv = bv; }
29 }