add commented-out version of UnPunctuatorNode2 to UnPunctuatorNode until I have time...
[fleet.git] / src / edu / berkeley / fleet / dataflow / OnceNode.java
1 package edu.berkeley.fleet.dataflow;
2 import java.util.*;
3 import edu.berkeley.fleet.loops.*;
4 import edu.berkeley.fleet.api.*;
5
6 public class OnceNode extends Node {
7     private BitVector bv;
8     public final OutPort out = new OutPort("out") {
9             public void sendToken(LoopFactory lf) { }
10             public void recvWord(LoopFactory lf) { }
11             public void build(CodeBag ctx) { }
12             public int  reset(CodeBag ctx, int phase, Destination ackDestination) { return 0; }
13             public void setPeer(InPort peer) {
14                 this.peer = peer;
15                 DockInPort pip = ((DockInPort)peer);
16                 BitVector[] pip_pattern = pip.pattern;
17                 BitVector[] temp = new BitVector[pip_pattern.length * 2];
18                 int j = 0;
19                 int i = 0;
20                 boolean done = false;
21                 // FIXME: if peer.count is already 1, this gets simpler and different
22                 for(i=0; i<temp.length; i++) {
23                     if (pip_pattern[j] != null) {
24                         temp[i] = pip_pattern[j];
25                     } else {
26                         if (done) break;
27                         done = true;
28                         temp[i] = bv;
29                     }
30                     j++;
31                     if (j >= pip_pattern.length) j = 0;
32                 }
33                 pip.pattern = new BitVector[i];
34                 System.arraycopy(temp, 0, pip.pattern, 0, i);
35                 pip.count = 1;
36             }
37         };
38     public OnceNode(DataFlowGraph dfg, long l) { this(dfg, new BitVector(dfg.fleet.getWordWidth()).set(l)); }
39     public OnceNode(DataFlowGraph dfg, final BitVector bv) { super(dfg); this.bv = bv; }
40 }