Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: AvailableMemory mbed-rtos mbed
Fork of helloaabbc by
Revision 1:55e99f6e2aa5, committed 2014-04-04
- Comitter:
- mbed36372
- Date:
- Fri Apr 04 21:31:22 2014 +0000
- Parent:
- 0:1c8f2727e9f5
- Commit message:
- SP14_lab1
Changed in this revision
--- a/RingBuffer.h Thu Apr 03 22:56:32 2014 +0000
+++ b/RingBuffer.h Fri Apr 04 21:31:22 2014 +0000
@@ -16,7 +16,7 @@
/*cur is used in next() method, denoting the current position in a sequential read, count is the number of elements*/
int cur,count;
- RingBuffer(int *data=NULL, int bs=0):buf(data),cur(0),count(0),bufSize(bs),start(0),end(0){}
+ RingBuffer(int *data=NULL, int bs=0):bufSize(bs),start(0),end(0),buf(data),cur(0),count(0){}
~RingBuffer(){buf=NULL;}
void insert(int sample);
int next();
--- 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*/
--- a/SDF.h Thu Apr 03 22:56:32 2014 +0000
+++ b/SDF.h Fri Apr 04 21:31:22 2014 +0000
@@ -296,7 +296,7 @@
bool hasSchedule();
vector<int> getNumOfFiringRequired()const{return numOfFiringRequired;}
void printNumOfFiringRequired()const;
- void makeSchedule();
+ vector<int> makeSchedule();
void printSchedule()const;
void setInput(RingBuffer *data);
void setOutput(RingBuffer *buf);
--- a/main.cpp Thu Apr 03 22:56:32 2014 +0000
+++ b/main.cpp Fri Apr 04 21:31:22 2014 +0000
@@ -19,7 +19,7 @@
int cntr2 = 0;
Mutex stdio_mutex;
-const int SamplingRate = 100;//sampling rate
+//const int SamplingRate = 100;//sampling rate
PwmOut led1(LED1);
PwmOut led2(LED2);
@@ -33,7 +33,7 @@
while(1)
{
- short temp;
+ int temp;
scanf("%d",&temp);
if (!temp)
{
@@ -52,25 +52,6 @@
}
}
-
-void monitor_thread(void const *args)
-{
- PRINT0("Monitor thread started...\n\r");
- RingBuffer* output= (RingBuffer*) args;
- int checksum = 0, pw = 0;
- for (int cntr=0;cntr<SAMPLES;cntr++)
- {
- while(cntr >= cntr2);
- pw = output->buf[cntr];
- checksum ^= pw;
- PRINT3("cntr: %d\tout: %d\tcs: %08X\n\r", cntr, pw, checksum);
- }
-
-
-}
-
-PwmOut myled(LED1);
-
int main() {
Thread controlThread(control_thread);
@@ -89,7 +70,7 @@
PRINT0("Starting filtering...\n\r");
int pw;
- int cntr=0;
+ //int cntr=0;
int checksum = 0;
while (true) {
@@ -111,9 +92,11 @@
}
led1 = (float)input->buf[input->cur]/1000;
- led4 = (float)pw/1000;
+ led2 = (float)pw/1000;
+ //PRINT1("LED1 = %d\r\n", input->cur);
+ //PRINT1("LED2 = %d\r\n", output->cur);
wait(0.02);
}
- abc;
+
}
