![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
skeleton for lab1
Dependencies: AvailableMemory mbed-rtos mbed
Fork of helloaabbc by
Diff: SDF.cpp
- Revision:
- 1:55e99f6e2aa5
- Parent:
- 0:1c8f2727e9f5
--- a/SDF.cpp Thu Apr 03 22:56:32 2014 +0000 +++ b/SDF.cpp Fri Apr 04 21:31:22 2014 +0000 @@ -177,7 +177,7 @@ } setInput(input); setOutput(output); - makeSchedule(); + schedule=makeSchedule(); } /*destructor, reclaim all the space allocated for nodes and FIFOs*/ @@ -493,45 +493,18 @@ } } -/*compile a schedule according to numOfFiringRequired; each time find a node which can fire and fire it; update the tokens on each FIFO, - repeat this process until all the nodes have fired the required number of times, which means a complete schedule has finished*/ -void SDFG::makeSchedule(){ - vector<int> buffers(fifos.size()), firingCount(nodes.size()); - for(int i=0; i<buffers.size(); i++)buffers[i]=fifos[i]->getSize(); - for(int i=0; i<firingCount.size(); i++)firingCount[i]=0; - bool finished; - do{ - /*check if all nodes have fired the number of times required, as computed in hasSchedule() function*/ - finished=true; - for(int i=0; i<firingCount.size(); i++){ - if(firingCount[i]<numOfFiringRequired[i]){ - /*this node has not fired that many times, then it has not finished*/ - finished=false; - vector<int> tempBuf(buffers); - bool valid=true; - /*test if this node can fire, namely if it has all its input data ready on the inbound FIFOs; we are doing matrix multiplication - with a vector in a compressed form, if the resulting buffer only has non-negative elements, then it means this node can - fire*/ - for(int j=0; j<tempBuf.size(); j++){ - if(topologyMatrix[j].getSrc()==i){ - tempBuf[j]+=topologyMatrix[j].getTokensProduced(); - }else if(topologyMatrix[j].getDst()==i){ - tempBuf[j]-=topologyMatrix[j].getTokensConsumed(); - if(tempBuf[j]<0){ - valid=false; - break; - } - } - } - if(valid){ - /*fire this node*/ - firingCount[i]++; - schedule.push_back(i); - for(int j=0; j<tempBuf.size(); j++)buffers[j]=tempBuf[j]; - } - } - } - }while(!finished); +/* + * Compute a schedule according to numOfFiringRequired; + * each time find a node which can fire and fire it; update the tokens on each FIFO, + * repeat this process until all the nodes have fired the required number of times, which means a complete schedule has finished + * As it is a function in the class SDFG, we could use all the data structures in SDFG, + * These may includes fifos, nodes, topologyMatrix + */ +vector<int> SDFG::makeSchedule(){ + vector<int> vSchedule; + // TODO HERE!!! + + return vSchedule; } /*display schedule*/