skeleton for lab1
Dependencies: AvailableMemory mbed-rtos mbed
Fork of helloaabbc by
SDF.h@0:1c8f2727e9f5, 2014-04-03 (annotated)
- Committer:
- y7jin
- Date:
- Thu Apr 03 22:56:32 2014 +0000
- Revision:
- 0:1c8f2727e9f5
- Child:
- 1:55e99f6e2aa5
hello
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
y7jin | 0:1c8f2727e9f5 | 1 | #ifndef _SDF_H |
y7jin | 0:1c8f2727e9f5 | 2 | #define _SDF_H |
y7jin | 0:1c8f2727e9f5 | 3 | |
y7jin | 0:1c8f2727e9f5 | 4 | #include "mbed.h" |
y7jin | 0:1c8f2727e9f5 | 5 | #include "RationalNum.h" |
y7jin | 0:1c8f2727e9f5 | 6 | #include "RingBuffer.h" |
y7jin | 0:1c8f2727e9f5 | 7 | #include "Parser.h" |
y7jin | 0:1c8f2727e9f5 | 8 | #include <queue> |
y7jin | 0:1c8f2727e9f5 | 9 | #include <vector> |
y7jin | 0:1c8f2727e9f5 | 10 | |
y7jin | 0:1c8f2727e9f5 | 11 | |
y7jin | 0:1c8f2727e9f5 | 12 | using namespace std; |
y7jin | 0:1c8f2727e9f5 | 13 | |
y7jin | 0:1c8f2727e9f5 | 14 | enum NodeType {I, O, A, S, M, D, U, C, F}; |
y7jin | 0:1c8f2727e9f5 | 15 | |
y7jin | 0:1c8f2727e9f5 | 16 | class FIFO; |
y7jin | 0:1c8f2727e9f5 | 17 | |
y7jin | 0:1c8f2727e9f5 | 18 | /*base class for all kinds of node in SDF*/ |
y7jin | 0:1c8f2727e9f5 | 19 | class SDFNode{ |
y7jin | 0:1c8f2727e9f5 | 20 | protected: |
y7jin | 0:1c8f2727e9f5 | 21 | int id; |
y7jin | 0:1c8f2727e9f5 | 22 | NodeType type; |
y7jin | 0:1c8f2727e9f5 | 23 | public: |
y7jin | 0:1c8f2727e9f5 | 24 | virtual int getId()const=0; |
y7jin | 0:1c8f2727e9f5 | 25 | virtual NodeType getType()const=0; |
y7jin | 0:1c8f2727e9f5 | 26 | virtual void execute()=0; |
y7jin | 0:1c8f2727e9f5 | 27 | virtual void display()const=0; |
y7jin | 0:1c8f2727e9f5 | 28 | }; |
y7jin | 0:1c8f2727e9f5 | 29 | |
y7jin | 0:1c8f2727e9f5 | 30 | /*input node*/ |
y7jin | 0:1c8f2727e9f5 | 31 | class INode : public SDFNode{ |
y7jin | 0:1c8f2727e9f5 | 32 | private: |
y7jin | 0:1c8f2727e9f5 | 33 | /*input data, inode reads data from a ring buffer*/ |
y7jin | 0:1c8f2727e9f5 | 34 | RingBuffer *input; |
y7jin | 0:1c8f2727e9f5 | 35 | /*edges (fifos) going outward from this node*/ |
y7jin | 0:1c8f2727e9f5 | 36 | vector<FIFO*> outbounds; |
y7jin | 0:1c8f2727e9f5 | 37 | public: |
y7jin | 0:1c8f2727e9f5 | 38 | INode(int k=-1,RingBuffer *in=NULL){id=k;input=in;type=I;} |
y7jin | 0:1c8f2727e9f5 | 39 | ~INode(){input=NULL;} |
y7jin | 0:1c8f2727e9f5 | 40 | virtual int getId()const{return id;} |
y7jin | 0:1c8f2727e9f5 | 41 | virtual NodeType getType()const{return type;} |
y7jin | 0:1c8f2727e9f5 | 42 | virtual void execute(); |
y7jin | 0:1c8f2727e9f5 | 43 | virtual void display()const; |
y7jin | 0:1c8f2727e9f5 | 44 | void setInput(RingBuffer *buf); |
y7jin | 0:1c8f2727e9f5 | 45 | void addOutbound(FIFO* fifo){outbounds.push_back(fifo);} |
y7jin | 0:1c8f2727e9f5 | 46 | }; |
y7jin | 0:1c8f2727e9f5 | 47 | |
y7jin | 0:1c8f2727e9f5 | 48 | /*output node*/ |
y7jin | 0:1c8f2727e9f5 | 49 | class ONode : public SDFNode{ |
y7jin | 0:1c8f2727e9f5 | 50 | private: |
y7jin | 0:1c8f2727e9f5 | 51 | /*edge coming into this node*/ |
y7jin | 0:1c8f2727e9f5 | 52 | FIFO *inbound; |
y7jin | 0:1c8f2727e9f5 | 53 | /*ring buffer where to write output*/ |
y7jin | 0:1c8f2727e9f5 | 54 | RingBuffer *output; |
y7jin | 0:1c8f2727e9f5 | 55 | /*checksum of all output samples*/ |
y7jin | 0:1c8f2727e9f5 | 56 | int checksum; |
y7jin | 0:1c8f2727e9f5 | 57 | public: |
y7jin | 0:1c8f2727e9f5 | 58 | ONode(int k=-1,RingBuffer *out=NULL):checksum(0){id=k;output=out;type=O;} |
y7jin | 0:1c8f2727e9f5 | 59 | ~ONode(){inbound=NULL;output=NULL;} |
y7jin | 0:1c8f2727e9f5 | 60 | virtual int getId()const{return id;} |
y7jin | 0:1c8f2727e9f5 | 61 | virtual NodeType getType()const{return type;} |
y7jin | 0:1c8f2727e9f5 | 62 | virtual void execute(); |
y7jin | 0:1c8f2727e9f5 | 63 | virtual void display()const; |
y7jin | 0:1c8f2727e9f5 | 64 | virtual void setInbound(FIFO* fifo){inbound=fifo;} |
y7jin | 0:1c8f2727e9f5 | 65 | void setOutput(RingBuffer *buf); |
y7jin | 0:1c8f2727e9f5 | 66 | int getChecksum()const{return checksum;} |
y7jin | 0:1c8f2727e9f5 | 67 | }; |
y7jin | 0:1c8f2727e9f5 | 68 | |
y7jin | 0:1c8f2727e9f5 | 69 | class ANode : public SDFNode{ |
y7jin | 0:1c8f2727e9f5 | 70 | private: |
y7jin | 0:1c8f2727e9f5 | 71 | /*two edges coming into this node, representing the two operands in an addition: op1+op2*/ |
y7jin | 0:1c8f2727e9f5 | 72 | FIFO *op1, *op2; |
y7jin | 0:1c8f2727e9f5 | 73 | /*edges going outward from this node*/ |
y7jin | 0:1c8f2727e9f5 | 74 | vector<FIFO*> outbounds; |
y7jin | 0:1c8f2727e9f5 | 75 | public: |
y7jin | 0:1c8f2727e9f5 | 76 | ANode(int k=-1){id=k;type=A;} |
y7jin | 0:1c8f2727e9f5 | 77 | ~ANode(){op1=op2=NULL;} |
y7jin | 0:1c8f2727e9f5 | 78 | virtual int getId()const{return id;} |
y7jin | 0:1c8f2727e9f5 | 79 | virtual NodeType getType()const{return type;} |
y7jin | 0:1c8f2727e9f5 | 80 | virtual void execute(); |
y7jin | 0:1c8f2727e9f5 | 81 | virtual void display()const; |
y7jin | 0:1c8f2727e9f5 | 82 | void addOutbound(FIFO* fifo){outbounds.push_back(fifo);} |
y7jin | 0:1c8f2727e9f5 | 83 | void setInbound(FIFO *in1, FIFO *in2){op1=in1;op2=in2;} |
y7jin | 0:1c8f2727e9f5 | 84 | }; |
y7jin | 0:1c8f2727e9f5 | 85 | |
y7jin | 0:1c8f2727e9f5 | 86 | class SNode : public SDFNode{ |
y7jin | 0:1c8f2727e9f5 | 87 | private: |
y7jin | 0:1c8f2727e9f5 | 88 | /*two edges coming into this node, representing the two operands in an subtraction: op1-op2*/ |
y7jin | 0:1c8f2727e9f5 | 89 | FIFO *op1, *op2; |
y7jin | 0:1c8f2727e9f5 | 90 | /*edges going outward from this node*/ |
y7jin | 0:1c8f2727e9f5 | 91 | vector<FIFO*> outbounds; |
y7jin | 0:1c8f2727e9f5 | 92 | public: |
y7jin | 0:1c8f2727e9f5 | 93 | SNode(int k=-1){id=k;type=S;} |
y7jin | 0:1c8f2727e9f5 | 94 | ~SNode(){op1=op2=NULL;} |
y7jin | 0:1c8f2727e9f5 | 95 | virtual int getId()const{return id;} |
y7jin | 0:1c8f2727e9f5 | 96 | virtual NodeType getType()const{return type;} |
y7jin | 0:1c8f2727e9f5 | 97 | virtual void execute(); |
y7jin | 0:1c8f2727e9f5 | 98 | virtual void display()const; |
y7jin | 0:1c8f2727e9f5 | 99 | void addOutbound(FIFO *fifo){outbounds.push_back(fifo);} |
y7jin | 0:1c8f2727e9f5 | 100 | void setInbound(FIFO *in1, FIFO *in2){op1=in1; op2=in2;} |
y7jin | 0:1c8f2727e9f5 | 101 | }; |
y7jin | 0:1c8f2727e9f5 | 102 | |
y7jin | 0:1c8f2727e9f5 | 103 | class MNode : public SDFNode{ |
y7jin | 0:1c8f2727e9f5 | 104 | private: |
y7jin | 0:1c8f2727e9f5 | 105 | /*edge providing input data for this node*/ |
y7jin | 0:1c8f2727e9f5 | 106 | FIFO *inbound; |
y7jin | 0:1c8f2727e9f5 | 107 | /*coefficients needed by the multiplier: as specified in the document, op*c/d */ |
y7jin | 0:1c8f2727e9f5 | 108 | int c,d; |
y7jin | 0:1c8f2727e9f5 | 109 | /*edges going outward from this node*/ |
y7jin | 0:1c8f2727e9f5 | 110 | vector<FIFO*> outbounds; |
y7jin | 0:1c8f2727e9f5 | 111 | public: |
y7jin | 0:1c8f2727e9f5 | 112 | MNode(int k=-1, int i=1, int j=1){id=k;c=i;d=j;type=M;} |
y7jin | 0:1c8f2727e9f5 | 113 | ~MNode(){inbound=NULL;} |
y7jin | 0:1c8f2727e9f5 | 114 | virtual int getId()const{return id;} |
y7jin | 0:1c8f2727e9f5 | 115 | virtual NodeType getType()const{return type;} |
y7jin | 0:1c8f2727e9f5 | 116 | virtual void execute(); |
y7jin | 0:1c8f2727e9f5 | 117 | virtual void display()const; |
y7jin | 0:1c8f2727e9f5 | 118 | void setInbound(FIFO *fifo){inbound=fifo;} |
y7jin | 0:1c8f2727e9f5 | 119 | void addOutbound(FIFO *fifo){outbounds.push_back(fifo);} |
y7jin | 0:1c8f2727e9f5 | 120 | }; |
y7jin | 0:1c8f2727e9f5 | 121 | |
y7jin | 0:1c8f2727e9f5 | 122 | class DNode : public SDFNode{ |
y7jin | 0:1c8f2727e9f5 | 123 | private: |
y7jin | 0:1c8f2727e9f5 | 124 | /*number of samples to read at a time from input edge*/ |
y7jin | 0:1c8f2727e9f5 | 125 | int numOfSamples; |
y7jin | 0:1c8f2727e9f5 | 126 | /*edge providing input to this node*/ |
y7jin | 0:1c8f2727e9f5 | 127 | FIFO *inbound; |
y7jin | 0:1c8f2727e9f5 | 128 | /*edges going outward from this node*/ |
y7jin | 0:1c8f2727e9f5 | 129 | vector<FIFO*> outbounds; |
y7jin | 0:1c8f2727e9f5 | 130 | public: |
y7jin | 0:1c8f2727e9f5 | 131 | DNode(int k=-1, int n=0){id=k;numOfSamples=n;type=D;} |
y7jin | 0:1c8f2727e9f5 | 132 | ~DNode(){inbound=NULL;} |
y7jin | 0:1c8f2727e9f5 | 133 | virtual int getId()const{return id;} |
y7jin | 0:1c8f2727e9f5 | 134 | virtual NodeType getType()const{return type;} |
y7jin | 0:1c8f2727e9f5 | 135 | int getNumOfSamples()const{return numOfSamples;} |
y7jin | 0:1c8f2727e9f5 | 136 | virtual void execute(); |
y7jin | 0:1c8f2727e9f5 | 137 | virtual void display()const; |
y7jin | 0:1c8f2727e9f5 | 138 | void setInbound(FIFO *fifo){inbound=fifo;} |
y7jin | 0:1c8f2727e9f5 | 139 | void addOutbound(FIFO *fifo){outbounds.push_back(fifo);} |
y7jin | 0:1c8f2727e9f5 | 140 | }; |
y7jin | 0:1c8f2727e9f5 | 141 | |
y7jin | 0:1c8f2727e9f5 | 142 | class UNode : public SDFNode{ |
y7jin | 0:1c8f2727e9f5 | 143 | private: |
y7jin | 0:1c8f2727e9f5 | 144 | /*number of samples to duplicate*/ |
y7jin | 0:1c8f2727e9f5 | 145 | int numOfCopies; |
y7jin | 0:1c8f2727e9f5 | 146 | /*edge providing input to this node*/ |
y7jin | 0:1c8f2727e9f5 | 147 | FIFO *inbound; |
y7jin | 0:1c8f2727e9f5 | 148 | /*edges going outward from this node*/ |
y7jin | 0:1c8f2727e9f5 | 149 | vector<FIFO*> outbounds; |
y7jin | 0:1c8f2727e9f5 | 150 | public: |
y7jin | 0:1c8f2727e9f5 | 151 | UNode(int k=-1, int n=0){id=k;numOfCopies=n;type=U;} |
y7jin | 0:1c8f2727e9f5 | 152 | ~UNode(){inbound=NULL;} |
y7jin | 0:1c8f2727e9f5 | 153 | virtual int getId()const{return id;} |
y7jin | 0:1c8f2727e9f5 | 154 | virtual NodeType getType()const{return type;} |
y7jin | 0:1c8f2727e9f5 | 155 | int getNumOfCopies()const{return numOfCopies;} |
y7jin | 0:1c8f2727e9f5 | 156 | virtual void execute(); |
y7jin | 0:1c8f2727e9f5 | 157 | virtual void display()const; |
y7jin | 0:1c8f2727e9f5 | 158 | void setInbound(FIFO *fifo){inbound=fifo;} |
y7jin | 0:1c8f2727e9f5 | 159 | void addOutbound(FIFO *fifo){outbounds.push_back(fifo);} |
y7jin | 0:1c8f2727e9f5 | 160 | }; |
y7jin | 0:1c8f2727e9f5 | 161 | |
y7jin | 0:1c8f2727e9f5 | 162 | class CNode : public SDFNode{ |
y7jin | 0:1c8f2727e9f5 | 163 | private: |
y7jin | 0:1c8f2727e9f5 | 164 | /*constant value this node provides*/ |
y7jin | 0:1c8f2727e9f5 | 165 | const int constant; |
y7jin | 0:1c8f2727e9f5 | 166 | /*edges going outward from this node*/ |
y7jin | 0:1c8f2727e9f5 | 167 | vector<FIFO*> outbounds; |
y7jin | 0:1c8f2727e9f5 | 168 | public: |
y7jin | 0:1c8f2727e9f5 | 169 | CNode(int k=-1, int c=0):constant(c){id=k;} |
y7jin | 0:1c8f2727e9f5 | 170 | ~CNode(){} |
y7jin | 0:1c8f2727e9f5 | 171 | virtual int getId()const{return id;} |
y7jin | 0:1c8f2727e9f5 | 172 | virtual NodeType getType()const{return type;} |
y7jin | 0:1c8f2727e9f5 | 173 | virtual void execute(); |
y7jin | 0:1c8f2727e9f5 | 174 | virtual void display()const; |
y7jin | 0:1c8f2727e9f5 | 175 | void addOutbound(FIFO *fifo){outbounds.push_back(fifo);} |
y7jin | 0:1c8f2727e9f5 | 176 | }; |
y7jin | 0:1c8f2727e9f5 | 177 | |
y7jin | 0:1c8f2727e9f5 | 178 | class FNode : public SDFNode{ |
y7jin | 0:1c8f2727e9f5 | 179 | private: |
y7jin | 0:1c8f2727e9f5 | 180 | /*edge providing input to this node*/ |
y7jin | 0:1c8f2727e9f5 | 181 | FIFO *inbound; |
y7jin | 0:1c8f2727e9f5 | 182 | /*edges going outward from this node*/ |
y7jin | 0:1c8f2727e9f5 | 183 | vector<FIFO*> outbounds; |
y7jin | 0:1c8f2727e9f5 | 184 | public: |
y7jin | 0:1c8f2727e9f5 | 185 | FNode(int k=-1){id=k;type=F;} |
y7jin | 0:1c8f2727e9f5 | 186 | ~FNode(){inbound=NULL;} |
y7jin | 0:1c8f2727e9f5 | 187 | virtual int getId()const{return id;} |
y7jin | 0:1c8f2727e9f5 | 188 | virtual NodeType getType()const{return type;} |
y7jin | 0:1c8f2727e9f5 | 189 | virtual void execute(); |
y7jin | 0:1c8f2727e9f5 | 190 | virtual void display()const; |
y7jin | 0:1c8f2727e9f5 | 191 | void setInbound(FIFO *fifo){inbound=fifo;} |
y7jin | 0:1c8f2727e9f5 | 192 | void addOutbound(FIFO *fifo){outbounds.push_back(fifo);} |
y7jin | 0:1c8f2727e9f5 | 193 | }; |
y7jin | 0:1c8f2727e9f5 | 194 | |
y7jin | 0:1c8f2727e9f5 | 195 | /*each edge is represented by a First-in-First-out queue, producer puts data into the queue, consumer removes data from the queue*/ |
y7jin | 0:1c8f2727e9f5 | 196 | class FIFO{ |
y7jin | 0:1c8f2727e9f5 | 197 | private: |
y7jin | 0:1c8f2727e9f5 | 198 | /*id of the fifo*/ |
y7jin | 0:1c8f2727e9f5 | 199 | int id; |
y7jin | 0:1c8f2727e9f5 | 200 | /*queue holding data*/ |
y7jin | 0:1c8f2727e9f5 | 201 | queue<int> fifo; |
y7jin | 0:1c8f2727e9f5 | 202 | /*src is producer node, dst is consumer node*/ |
y7jin | 0:1c8f2727e9f5 | 203 | SDFNode *src, *dst; |
y7jin | 0:1c8f2727e9f5 | 204 | public: |
y7jin | 0:1c8f2727e9f5 | 205 | int getData(); |
y7jin | 0:1c8f2727e9f5 | 206 | void putData(int d); |
y7jin | 0:1c8f2727e9f5 | 207 | SDFNode *getSrc()const{return src;} |
y7jin | 0:1c8f2727e9f5 | 208 | SDFNode *getDst()const{return dst;} |
y7jin | 0:1c8f2727e9f5 | 209 | void setSrc(SDFNode *s){src=s;} |
y7jin | 0:1c8f2727e9f5 | 210 | void setDst(SDFNode *d){dst=d;} |
y7jin | 0:1c8f2727e9f5 | 211 | void display()const; |
y7jin | 0:1c8f2727e9f5 | 212 | int getId()const{return id;} |
y7jin | 0:1c8f2727e9f5 | 213 | int getSize()const{return fifo.size();} |
y7jin | 0:1c8f2727e9f5 | 214 | FIFO(int k=-1):id(k),src(NULL),dst(NULL){} |
y7jin | 0:1c8f2727e9f5 | 215 | ~FIFO(){src=dst=NULL;} |
y7jin | 0:1c8f2727e9f5 | 216 | }; |
y7jin | 0:1c8f2727e9f5 | 217 | |
y7jin | 0:1c8f2727e9f5 | 218 | /*compressed topology matrix*/ |
y7jin | 0:1c8f2727e9f5 | 219 | class TMatrixRow{ |
y7jin | 0:1c8f2727e9f5 | 220 | private: |
y7jin | 0:1c8f2727e9f5 | 221 | /*srcNode is the id of the producer node, dstNode is the id of the consumer node*/ |
y7jin | 0:1c8f2727e9f5 | 222 | int srcNode, dstNode; |
y7jin | 0:1c8f2727e9f5 | 223 | /*tokensProduced is the number of tokens produced by producer, tokensConsumed is the number of tokens consumed by consumer*/ |
y7jin | 0:1c8f2727e9f5 | 224 | int tokensProduced, tokensConsumed; |
y7jin | 0:1c8f2727e9f5 | 225 | public: |
y7jin | 0:1c8f2727e9f5 | 226 | TMatrixRow(int sn=-1, int pt=-1, int dn=-1, int ct=-1):srcNode(sn),dstNode(dn),tokensProduced(pt),tokensConsumed(ct){} |
y7jin | 0:1c8f2727e9f5 | 227 | void setValue(int sn, int pt, int dn, int ct){srcNode=sn;tokensProduced=pt;dstNode=dn;tokensConsumed=ct;} |
y7jin | 0:1c8f2727e9f5 | 228 | int getSrc()const{return srcNode;} |
y7jin | 0:1c8f2727e9f5 | 229 | int getDst()const{return dstNode;} |
y7jin | 0:1c8f2727e9f5 | 230 | int getTokensConsumed()const{return tokensConsumed;} |
y7jin | 0:1c8f2727e9f5 | 231 | int getTokensProduced()const{return tokensProduced;} |
y7jin | 0:1c8f2727e9f5 | 232 | }; |
y7jin | 0:1c8f2727e9f5 | 233 | |
y7jin | 0:1c8f2727e9f5 | 234 | /*synchronous data flow*/ |
y7jin | 0:1c8f2727e9f5 | 235 | class SDFG{ |
y7jin | 0:1c8f2727e9f5 | 236 | private: |
y7jin | 0:1c8f2727e9f5 | 237 | /*input node, each sdf has one and only one input node*/ |
y7jin | 0:1c8f2727e9f5 | 238 | INode *gin; |
y7jin | 0:1c8f2727e9f5 | 239 | /*output node, each sdf has one and only one output node*/ |
y7jin | 0:1c8f2727e9f5 | 240 | ONode *gout; |
y7jin | 0:1c8f2727e9f5 | 241 | /*list of nodes (including gin and gout)*/ |
y7jin | 0:1c8f2727e9f5 | 242 | vector<SDFNode*> nodes; |
y7jin | 0:1c8f2727e9f5 | 243 | /*list of FIFOs*/ |
y7jin | 0:1c8f2727e9f5 | 244 | vector<FIFO*> fifos; |
y7jin | 0:1c8f2727e9f5 | 245 | /*topology matrix corresponding to this sdf*/ |
y7jin | 0:1c8f2727e9f5 | 246 | TMatrixRow topologyMatrix[256]; |
y7jin | 0:1c8f2727e9f5 | 247 | /*number of nodes in sdf, equals nodes.size()*/ |
y7jin | 0:1c8f2727e9f5 | 248 | int numOfNodes; |
y7jin | 0:1c8f2727e9f5 | 249 | /*number of FIFOs in sdf, equals fifos.size()*/ |
y7jin | 0:1c8f2727e9f5 | 250 | int numOfFIFOs; |
y7jin | 0:1c8f2727e9f5 | 251 | /*if hasSchedule() method has ever been called, this variable is intended to avoid recalculating hasSchedule() again*/ |
y7jin | 0:1c8f2727e9f5 | 252 | bool scheduleTested; |
y7jin | 0:1c8f2727e9f5 | 253 | /*mark if this sdf is schedulable; together with scheduleTested variable, we can avoid recalculating hasSchedule()*/ |
y7jin | 0:1c8f2727e9f5 | 254 | bool schedulable; |
y7jin | 0:1c8f2727e9f5 | 255 | /*schedule, for example, 1,2,4,3... means firing node 1 first, then 2, then 4, then 3*/ |
y7jin | 0:1c8f2727e9f5 | 256 | vector<int> schedule; |
y7jin | 0:1c8f2727e9f5 | 257 | /*a vector storing the number of times each node has to fire in ONE schedule, e.g. numOfFiringRequired[0] is the |
y7jin | 0:1c8f2727e9f5 | 258 | number of times node 0 has to fire in the schedule, numOfFiringRequired[1] is the number of times node 1 has to |
y7jin | 0:1c8f2727e9f5 | 259 | fire in the schedule*/ |
y7jin | 0:1c8f2727e9f5 | 260 | vector<int> numOfFiringRequired; |
y7jin | 0:1c8f2727e9f5 | 261 | /*mark if a schedule has been found*/ |
y7jin | 0:1c8f2727e9f5 | 262 | bool scheduleFound; |
y7jin | 0:1c8f2727e9f5 | 263 | public: |
y7jin | 0:1c8f2727e9f5 | 264 | SDFG():gin(NULL),gout(NULL),numOfNodes(0),numOfFIFOs(0),scheduleTested(false),schedulable(false), scheduleFound(false){} |
y7jin | 0:1c8f2727e9f5 | 265 | SDFG(char*, RingBuffer*, RingBuffer*); |
y7jin | 0:1c8f2727e9f5 | 266 | ~SDFG(); |
y7jin | 0:1c8f2727e9f5 | 267 | INode *getInput()const{return this->gin;} |
y7jin | 0:1c8f2727e9f5 | 268 | ONode *getOutput()const{return this->gout;} |
y7jin | 0:1c8f2727e9f5 | 269 | void addNode(SDFNode *node); |
y7jin | 0:1c8f2727e9f5 | 270 | //get the fifo with a specific id, if the fifo does not exist, create one and insert into fifos. |
y7jin | 0:1c8f2727e9f5 | 271 | FIFO* getFIFO(int id); |
y7jin | 0:1c8f2727e9f5 | 272 | vector<SDFNode *> getNodes()const{return this->nodes;} |
y7jin | 0:1c8f2727e9f5 | 273 | SDFNode *getNodeAt(int i)const{return (i<this->nodes.size())? this->nodes[i]:NULL;} |
y7jin | 0:1c8f2727e9f5 | 274 | //get fifo at a position i in fifos vector, actually in our case, fifos is sorted vector indicating i is also the id of the fifo |
y7jin | 0:1c8f2727e9f5 | 275 | FIFO *getFIFOAt(int i)const{return (i<this->fifos.size()) ? this->fifos[i]:NULL;} |
y7jin | 0:1c8f2727e9f5 | 276 | vector<FIFO *> getFIFOs()const{return this->fifos;} |
y7jin | 0:1c8f2727e9f5 | 277 | int getNumOfNodes()const{return this->numOfNodes;} |
y7jin | 0:1c8f2727e9f5 | 278 | void setNumOfNodes(int k){numOfNodes=k;} |
y7jin | 0:1c8f2727e9f5 | 279 | int getNumOfFIFOs()const{return this->numOfFIFOs;} |
y7jin | 0:1c8f2727e9f5 | 280 | void setNumOfFIFOs(int k){numOfFIFOs=k;} |
y7jin | 0:1c8f2727e9f5 | 281 | //create node of specific kind |
y7jin | 0:1c8f2727e9f5 | 282 | void getINode(int nodeId, int params[], int count); |
y7jin | 0:1c8f2727e9f5 | 283 | void getONode(int nodeId, int params[], int count); |
y7jin | 0:1c8f2727e9f5 | 284 | void getANode(int nodeId, int params[], int count); |
y7jin | 0:1c8f2727e9f5 | 285 | void getSNode(int nodeId, int params[], int count); |
y7jin | 0:1c8f2727e9f5 | 286 | void getMNode(int nodeId, int params[], int count); |
y7jin | 0:1c8f2727e9f5 | 287 | void getDNode(int nodeId, int params[], int count); |
y7jin | 0:1c8f2727e9f5 | 288 | void getUNode(int nodeId, int params[], int count); |
y7jin | 0:1c8f2727e9f5 | 289 | void getCNode(int nodeId, int params[], int count); |
y7jin | 0:1c8f2727e9f5 | 290 | void getFNode(int nodeId, int params[], int count); |
y7jin | 0:1c8f2727e9f5 | 291 | void addDelay(int params[], int count); |
y7jin | 0:1c8f2727e9f5 | 292 | //build compressed topology matrix, compressing the columns |
y7jin | 0:1c8f2727e9f5 | 293 | void buildTopologyMatrix(); |
y7jin | 0:1c8f2727e9f5 | 294 | void printTopologyMatrix()const; |
y7jin | 0:1c8f2727e9f5 | 295 | /*calling sequence: hasSchedule<makeSchedule<execute*/ |
y7jin | 0:1c8f2727e9f5 | 296 | bool hasSchedule(); |
y7jin | 0:1c8f2727e9f5 | 297 | vector<int> getNumOfFiringRequired()const{return numOfFiringRequired;} |
y7jin | 0:1c8f2727e9f5 | 298 | void printNumOfFiringRequired()const; |
y7jin | 0:1c8f2727e9f5 | 299 | void makeSchedule(); |
y7jin | 0:1c8f2727e9f5 | 300 | void printSchedule()const; |
y7jin | 0:1c8f2727e9f5 | 301 | void setInput(RingBuffer *data); |
y7jin | 0:1c8f2727e9f5 | 302 | void setOutput(RingBuffer *buf); |
y7jin | 0:1c8f2727e9f5 | 303 | void execute(int numOfRepetions); |
y7jin | 0:1c8f2727e9f5 | 304 | int getChecksum()const{return gout->getChecksum();} |
y7jin | 0:1c8f2727e9f5 | 305 | }; |
y7jin | 0:1c8f2727e9f5 | 306 | #endif |