CompileDES  3.13
Executable-Code Generation from Synchronised libFAUDES Automata
cgp_embeddedc.h
Go to the documentation of this file.
1 
3 /*
4  FAU Discrete Event Systems Library (libFAUDES)
5 
6  Copyright (C) 2010, 2016 Thomas Moor
7 
8 */
9 
10 
11 
12 #ifndef FAUDES_EMBEDDEDC_H
13 #define FAUDES_EMBEDDEDC_H
14 
15 #include "libfaudes.h"
16 #include "cgp_codeprimitives.h"
17 
18 using namespace faudes;
19 
20 
21 
72 
73 public:
74 
75  /*****************************************
76  *****************************************
77  *****************************************
78  *****************************************/
79 
87 
91  virtual ~EmbeddedcCodeGenerator(void);
92 
97  virtual void Clear(void);
98 
99 
102 protected:
103 
105  void DoCompile(void);
106 
108  void DoGenerate(void);
109 
111  virtual void DecrementTimers(void);
112  void InsertExecHooks(void);
113 
115  virtual std::string TargetAddress(const AA& address);
116 
118  virtual AX TargetExpression(const AA& address);
119 
126  /* re-implement primitives */
127  virtual void Comment(const std::string& text);
128 
129  /* re-implement primitives */
130  virtual void IntegerDeclare(const AA& address);
131  virtual void IntegerDeclare(const AA& address, int val);
132  virtual void IntegerAssign(const AA& address, int val);
133  virtual void IntegerAssign(const AA& address, const AX& expression);
134  virtual void IntegerIncrement(const AA& address, int val=1);
135  virtual AX IntegerQuotient(const AX& expression, int val);
136  virtual AX IntegerRemainder(const AX& expression, int val);
137  virtual AX IntegerBitmask(const AX& expression);
138  virtual AX IntegerIsEq(const AA& address, int val);
139  virtual AX IntegerIsEq(const AA& address, const AX& expression);
140  virtual AX IntegerIsNotEq(const AA& address, int val);
141  virtual AX IntegerIsNotEq(const AA& address, const AX& expression);
142  virtual AX IntegerIsGreater(const AA& address, int val);
143  virtual AX IntegerIsLess(const AA& address, int val);
144  virtual AX IntegerConstant(int val);
145 
146  /* re-implement primitives */
147  virtual bool HasIntmaths(void);
148  virtual void WordDeclare(const AA& address);
149  virtual void WordDeclare(const AA& address, word_t val);
150  virtual void WordAssign(const AA& address, word_t val);
151  virtual void WordAssign(const AA& address, const AX& expression);
152  virtual void WordOr(const AA& address, word_t val);
153  virtual void WordOr(const AA& address, const AX& expression);
154  virtual void WordOr(const AA& address, const AA& op1, const AA& op2);
155  virtual void WordOr(const AA& address, const AA& op1, word_t op2);
156  virtual void WordAnd(const AA& address, word_t val);
157  virtual void WordAnd(const AA& address, const AX& expression);
158  virtual void WordAnd(const AA& address, const AA& op1, const AA& op2);
159  virtual void WordAnd(const AA& address, const AA& op1, word_t op2);
160  virtual void WordNand(const AA& address, const AX& expression);
161  virtual AX WordIsBitSet(const AA& address, int idx);
162  virtual AX WordIsBitClr(const AA& address, int idx);
163  virtual AX WordIsMaskSet(const AA& address, word_t mask);
164  virtual AX WordIsEq(const AA& address, word_t val);
165  virtual AX WordIsNotEq(const AA& address, word_t val);
166  virtual AX WordConstant(word_t val);
167 
168  /* re-implement primitives */
169  virtual AX StringConstant(const std::string& val);
170 
171  /* re-implement primitives */
172  virtual void CintarrayDeclare(const AA& address, int offset, const std::vector<int>& val);
173  virtual AA CintarrayAccess(const AA& address, int index);
174  virtual AA CintarrayAccess(const AA& address, const AA& indexaddr);
175  virtual bool HasCintarray(void);
176  virtual void CwordarrayDeclare(const AA& address, int offset, const std::vector<word_t>& val);
177  virtual AA CwordarrayAccess(const AA& address, int index);
178  virtual AA CwordarrayAccess(const AA& address, const AA& indexaddr);
179  virtual bool HasCwordarray(void);
180  virtual void CstrarrayDeclare(const AA& address, int offset, const std::vector<std::string>& val);
181  virtual AA CstrarrayAccess(const AA& address, int index);
182  virtual AA CstrarrayAccess(const AA& address, const AA& indexaddr);
183  virtual bool HasCstrarray(void);
184  virtual void IntarrayDeclare(const AA& address, int offset, int len);
185  virtual void IntarrayDeclare(const AA& address, int offset, const std::vector<int>& val);
186  virtual AA IntarrayAccess(const AA& address, int index);
187  virtual AA IntarrayAccess(const AA& address, const AA& indexaddr);
188  virtual bool HasIntarray(void);
189  virtual void WordarrayDeclare(const AA& address, int offset, int len);
190  virtual void WordarrayDeclare(const AA& address, int offset, const std::vector<word_t>& val);
191  virtual AA WordarrayAccess(const AA& address, int index);
192  virtual AA WordarrayAccess(const AA& address, const AA& indexaddr);
193  virtual bool HasWordarray(void);
194 
195 
196  /* re-implement primitives */
197  virtual void IfTrue(const AX& expression);
198  virtual void IfFalse(const AX& expression);
199  virtual void IfWord(const AX& expression);
200  virtual void IfElse(void);
201  virtual void IfElseIfTrue(const AX& expression);
202  virtual void IfEnd(void);
203 
204  /* re-implement primitives */
205  virtual void SwitchBegin(const AA& address);
206  virtual void SwitchCase(const AA& address, int val);
207  virtual void SwitchCases(const AA& address, int from, int to);
208  virtual void SwitchCases(const AA& address, const std::set< int>& vals);
209  virtual void SwitchBreak(void);
210  virtual void SwitchEnd(void);
211  virtual bool HasMultiCase(void);
212 
213  /* re-implement primitives */
214  virtual void LoopBegin(void);
215  virtual void LoopBreak(const AX& expression);
216  virtual void LoopEnd(void);
217  virtual void FunctionReturn(void);
218 
219  /* re-implement primitives */
220  virtual void RunActionSet(const std::string& address);
221  virtual void RunActionClr(const std::string& address);
222  virtual void RunActionExe(const AX& expression);
223 
224  /* re-implement primitives */
225  virtual void TimerDeclare(const AA& address, const std::string& litval);
226  virtual void TimerStart(const AA& address);
227  virtual void TimerStop(const AA& address);
228  virtual void TimerReset(const AA& address, const std::string& litval);
229  virtual AX TimerIsElapsed(const AA& address);
230 
233  // code generator primitives, embeddedc-only helper
234  AX IntarrayConstant(int offset, const std::vector<int>& val);
235  AX WordarrayConstant(int offset, const std::vector<word_t>& val);
236  AX StrarrayConstant(int offset, const std::vector<std::string>& val);
237 
238 
239 
252  virtual void DoReadTargetConfiguration(TokenReader& rTr);
253 
265  virtual void DoWriteTargetConfiguration(TokenWriter& rTw) const;
266 
267 };
268 
269 
270 #endif
Code-generator with abstract types and operations.
unsigned long word_t
Code-generator internal data type of target words.
Abstract address; see also Absstract_Addresses.
Abstract expression; see also Absstract_Addresses.
Execution semantics in terms of code primitives.
Implementation of code primitives by generic C-code.
Definition: cgp_embeddedc.h:71