The Esterel v5 21 System Manual - Courses
The Esterel v5 21 System Manual - Courses
The Esterel v5 21 System Manual - Courses
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
3.3. C CODE FOR DATA HANDLING 35<br />
Assignment Function<br />
A reference to the assignment procedure is generated in the following cases:<br />
• <strong>The</strong>re is an explicit assignment or variable initialization of type T, i.e.<br />
the assignment symbol “:=” is used somewhere for a variable of type<br />
T.<br />
• <strong>The</strong>re is a valued signal of type T, either in the main module or in<br />
one of its submodules. In the case of valued signals, assignment is<br />
necessary to handle signal emissions.<br />
• An exec statement calls a task with a reference parameter of type T.<br />
For assignments to be correctly generated, the user must write an assignment<br />
function for each user type T. This C function will be automatically called<br />
to execute assignments. It takes two arguments, the first one of type T*, the<br />
second one of type T. Since the result of an assignment function is never used,<br />
the result type should be void. For example, the source <strong>Esterel</strong> assignment<br />
X := exp<br />
where both X and exp are of type T generates the following C code:<br />
_T(&__PROG_Vxx, exp)<br />
WARNING: Assignment must always be done by full copy or<br />
be equivalent to a full copy (or bitwise copy). Arbitrarily strange<br />
behaviors can appear otherwise.<br />
If C supports assignment by bitwise copy on type T, then one can just define<br />
T in the following way:<br />
#define _T(x,y) (*(x)=y)<br />
<strong>The</strong> parentheses are needed to avoid priority conflicts. Notice that a source<br />
assignment X := exp generates the C assignment<br />
(*(&__PROG_Vxx) = exp)<br />
which is immediately translated back into PROG Vxx = exp by the C compiler.<br />
<strong>The</strong>re is no loss of efficiency.