Esterel


Esterel is a synchronous programming language for the development of complex reactive systems. The imperative programming style of Esterel allows the simple expression of parallelism and preemption. As a consequence, it is well suited for control-dominated model designs.
The development of the language started in the early 1980s, and was mainly carried out by a team of Ecole des Mines de Paris and INRIA led by Gérard Berry in France. Current compilers take Esterel programs and generate C code or hardware implementations.
The language is still under development, with several compilers out. The commercial version of Esterel is the development environment Esterel Studio. The company that commercialize it initiated a normalization process with the IEEE in April 2007 however the working group dissolved March 2011. The is publicly available.

The Multiform Notion of Time

The notion of time used in Esterel differs from that of non-synchronous languages in the following way: The notion of physical time is replaced with the notion of order. Only the simultaneity and precedence of events are considered. This means that the physical time does not play any special role. This is called multiform notion of time. An Esterel program describes a totally ordered sequence of logical instants. At each instant, an arbitrary number of events occur. Event occurrences that happen at the same logical instant are considered simultaneous. Other events are ordered as their instances of occurrences. There are two types of statements: Those that take zero time and those that delay for a prescribed number of cycles.

Signals

Signals are the only means of communication. There are valued and non-valued signals. They are further categorized as being input, output, or local signals. A signal has the property of being either present or absent in an instant. Valued signals also contain a value. Signals are broadcast across the program, and that means any process can read or write a signal. The value of a valued signal can be determined in any instant, even if the signal is absent. The default status of a signal is absent. Signals remain absent until they are explicitly set to present using the emit statement.
Communication is instantaneous, that means that a signal emitted in a cycle is visible immediately. Note that one can communicate back and forth in the same cycle.

Signal Coherence rules

Thus
present A else
emit A
end
is an erroneous program: the writer "emit A" must run before the reader "present A", but the semantics of the language requires the "present A" to be performed first, resulting in a conflict in the program's semantics.

The language constructs

Primitive Esterel statements

Pure Esterel has eleven primitive statements.
nothingTerminates immediately with no other effect.
pauseBlocks control flow in the current cycle for resumption in the next cycle.
p ; qRuns p until it terminates and then, in the same reaction, start q.
p || qRuns p and q in parallel
loop p endRestart the body p as soon as it terminates. Every path through the loop body must contain at least one pause statement to avoid unbounded looping within a single reaction.
signal S in p endDeclares a local signal.
emit SMake signal S present in the current instant. A signal is absent unless it is emitted.
present S then p else q endIf signal S is present in the current instant, immediately run p, otherwise run q.
suspend p when SSuspends the execution of the body in instants where S is present.
trap T in p endDeclare a labeled escape block.
exit TJump to the end of the innermost T-labeled escape block.

Derived Esterel statements

Esterel has several derived constructions:
Derived statementExpansion
haltloop pause end
sustain sloop emit s; pause end
present s then p endpresent s then p else nothing end
await strap T in loop pause; present s then exit T end end loop end
await immediate strap T in loop present s then exit T end; pause end loop end
suspend p when immediate ssuspend present s then pause end; p when s
abort p when strap T in suspend p when s; exit T || await s; exit T; end
weak abort p when strap T in p; exit T || await s; exit T; end
loop p each sloop abort p ; halt when s end loop
every s do p end everyawait s; loop p each s

Other Esterel statements

The full Esterel language also has statements for declaring and instantiating modules, for variables, for calling external procedures, and for valued signals.

Example (ABRO)

The following program emits the output O as soon as both inputs A and B have been received. Reset the behaviour whenever the input R is received.
module ABRO:
input A, B, R;
output O;
loop
;
emit O
each R
end module

Advantages of Esterel