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 37<br />
for (i = 0; i < 10; i++)<br />
if (_ne_TIME(a1.array[i], a2.array[i])) return 0;<br />
return 1;<br />
}<br />
int _ne_ARRAY_10_OF_TIME (a1, a2) /* inequality */<br />
ARRAY_10_OF_TIME a1, a2;<br />
{<br />
int i;<br />
for (i = 0; i < 10; i++)<br />
if (_ne_TIME(a1.array[i], a2.array[i])) return 1;<br />
return 0;<br />
}<br />
3.3.4 Conversion To and From Strings<br />
When the <strong>Esterel</strong> C code is generated for interactive simulation, objects of<br />
arbitrary types must be printed by the simulators and possibly entered as<br />
input signal values. For this, the user must define a string representation for<br />
each user-defined type and provide three conversion functions: a function<br />
that converts an object into a string for printing, a function that converts a<br />
string to an object for reading, and a function that checks the syntax of a<br />
string to be read.<br />
<strong>The</strong> printing function for type T must be called T to text. It must take<br />
a type T object as argument and returns a pointer to characters.<br />
<strong>The</strong> reading function for type T must be called text to T and it must<br />
return void. It must take as arguments a pointer to characters and a pointer<br />
to T. <strong>The</strong> function must convert a string into a T object by performing sideeffects<br />
on its pointer argument, the T object being allocated in the generated<br />
code.<br />
<strong>The</strong> checking function must be called check TYPE. It must take a pointer<br />
to character as argument and return an int. <strong>The</strong> function must returns 0<br />
if the string is not valid, i.e. if the string is not accepted by the text to T<br />
conversion function as a T object representation.<br />
For example, if the <strong>Esterel</strong> program uses a type TIME declared as a<br />
C struct compound of three integer fields called hours, minutes, and<br />
seconds, the conversion functions could be defined as: