-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscheduler.cpp
More file actions
195 lines (141 loc) · 3.49 KB
/
scheduler.cpp
File metadata and controls
195 lines (141 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
Generated with CMSIS-Stream python scripts.
The generated code is not covered by CMSIS-Stream license.
The support classes and code are covered by CMSIS-Stream license.
*/
#include <cstdint>
#include "custom.h"
#include "cg_status.h"
#include "GenericNodes.h"
#include "AppNodes.h"
#include "scheduler.h"
#if !defined(CHECKERROR)
#define CHECKERROR if (cgStaticError < 0) \
{\
goto errorHandling;\
}
#endif
#if !defined(CG_BEFORE_ITERATION)
#define CG_BEFORE_ITERATION
#endif
#if !defined(CG_AFTER_ITERATION)
#define CG_AFTER_ITERATION
#endif
#if !defined(CG_BEFORE_SCHEDULE)
#define CG_BEFORE_SCHEDULE
#endif
#if !defined(CG_AFTER_SCHEDULE)
#define CG_AFTER_SCHEDULE
#endif
#if !defined(CG_BEFORE_BUFFER)
#define CG_BEFORE_BUFFER
#endif
#if !defined(CG_BEFORE_FIFO_BUFFERS)
#define CG_BEFORE_FIFO_BUFFERS
#endif
#if !defined(CG_BEFORE_FIFO_INIT)
#define CG_BEFORE_FIFO_INIT
#endif
#if !defined(CG_BEFORE_NODE_INIT)
#define CG_BEFORE_NODE_INIT
#endif
#if !defined(CG_AFTER_INCLUDES)
#define CG_AFTER_INCLUDES
#endif
#if !defined(CG_BEFORE_SCHEDULER_FUNCTION)
#define CG_BEFORE_SCHEDULER_FUNCTION
#endif
#if !defined(CG_BEFORE_NODE_EXECUTION)
#define CG_BEFORE_NODE_EXECUTION(ID)
#endif
#if !defined(CG_AFTER_NODE_EXECUTION)
#define CG_AFTER_NODE_EXECUTION(ID)
#endif
CG_AFTER_INCLUDES
using namespace arm_cmsis_stream;
/*
Description of the scheduling.
*/
static uint8_t schedule[19]=
{
2,2,0,1,2,0,1,2,2,0,1,1,2,0,1,2,0,1,1,
};
/*
Internal ID identification for the nodes
*/
#define PROCESSING_INTERNAL_ID 0
#define SINK_INTERNAL_ID 1
#define SOURCE_INTERNAL_ID 2
CG_BEFORE_FIFO_BUFFERS
/***********
FIFO buffers
************/
#define FIFOSIZE0 11
#define FIFOSIZE1 11
#define BUFFERSIZE0 11
CG_BEFORE_BUFFER
float buf0[BUFFERSIZE0]={0};
#define BUFFERSIZE1 11
CG_BEFORE_BUFFER
float buf1[BUFFERSIZE1]={0};
CG_BEFORE_SCHEDULER_FUNCTION
uint32_t scheduler(int *error)
{
int cgStaticError=0;
uint32_t nbSchedule=0;
int32_t debugCounter=1;
CG_BEFORE_FIFO_INIT;
/*
Create FIFOs objects
*/
FIFO<float,FIFOSIZE0,0,0> fifo0(buf0);
FIFO<float,FIFOSIZE1,0,0> fifo1(buf1);
CG_BEFORE_NODE_INIT;
/*
Create node objects
*/
ProcessingNode<float,7,float,7> processing(fifo0,fifo1); /* Node ID = 0 */
Sink<float,5> sink(fifo1); /* Node ID = 1 */
Source<float,5> source(fifo0); /* Node ID = 2 */
/* Run several schedule iterations */
CG_BEFORE_SCHEDULE;
while((cgStaticError==0) && (debugCounter > 0))
{
/* Run a schedule iteration */
CG_BEFORE_ITERATION;
unsigned long id=0;
for(; id < 19; id++)
{
CG_BEFORE_NODE_EXECUTION(schedule[id]);
switch(schedule[id])
{
case 0:
{
cgStaticError = processing.run();
}
break;
case 1:
{
cgStaticError = sink.run();
}
break;
case 2:
{
cgStaticError = source.run();
}
break;
default:
break;
}
CG_AFTER_NODE_EXECUTION(schedule[id]);
CHECKERROR;
}
debugCounter--;
CG_AFTER_ITERATION;
nbSchedule++;
}
errorHandling:
CG_AFTER_SCHEDULE;
*error=cgStaticError;
return(nbSchedule);
}