esterel overview roberto passerone ee249 discussion section
Post on 20-Dec-2015
223 views
TRANSCRIPT
April 18, 2023 Esterel notes 3
Model of Time
• Totally ordered sequence of instants
• Instants are also called ticks
• There is nothing in between instants
April 18, 2023 Esterel notes 4
Esterel
• Esterel is a reactive programming language
• Esterel is also a Synchronous language
• Everything proceeds in lock-step
April 18, 2023 Esterel notes 5
You might hear that...
• In Esterel computation takes zero time
• Communication also takes zero time
• In other words, reactions to events are instantaneous
April 18, 2023 Esterel notes 6
Model of Execution
• There is a set of events E
• We have a sequence of instants
• For each instant a subset of the events in E is present
• Hence the execution is a totally ordered sequence of events
April 18, 2023 Esterel notes 7
Model of a System
• The System implicitly represents the execution
• The System is a collection of processes executing concurrently
• Processes are placed in parallel using the parallel operator ||
April 18, 2023 Esterel notes 8
Interaction of Processes
• Processes interact by through signals that carry events
• Events in signals can be either Present or Absent
• Processes do NOT interact through shared variables
April 18, 2023 Esterel notes 9
Checking for presence
• Processes can test for the presence or absence of events in signals– present A then … else ...
April 18, 2023 Esterel notes 10
Awaiting an event
• Processes can stop their execution until an event is present in a signal– await A;– await [ A or B ]
April 18, 2023 Esterel notes 11
Emitting an event
• Processes can emit an event to a signal to make it present– emit A– emit A, 10
April 18, 2023 Esterel notes 12
Execution of the System
• Input events are posted for the current instant
• The System reacts to the input event in the current instant
• The System posts the output events for the current instant
• Only at this point does the instant increment
April 18, 2023 Esterel notes 13
When things occur
• present tests the presence of signals in the current reaction
• await stops the execution for the current reaction, until at least the next instant
• emit emits the event during the current reaction
April 18, 2023 Esterel notes 14
Important
• There is no ordering of events within a reaction• All events present during a reaction occur at the
same exact time (instant)• Hence when executing a present:
– if the signal is present continue with the “then”
– if absent, must wait until it either becomes present or can prove it will not be emitted during the current reaction
April 18, 2023 Esterel notes 15
Atomicity of reaction• The triple (input, reaction, output) is executed
atomically– Atomic means that others cannot observe the
intermediate steps. It is not necessarily instantaneous
– Intermediate steps are only necessary to compute the overall reaction
– All goes as if the computation took zero time
– There are micro-steps: they converge to a fixed point
April 18, 2023 Esterel notes 16
How to execute
• Start with the input events present• Activate all processes awaiting a present event• If events are emitted, activate processes that may
be waiting• If presence is tested, wait until you know the
outcome• Stop a process when it reaches an await
April 18, 2023 Esterel notes 17
Compiling Esterel
• The interpreter does the previous procedure– might have to look ahead
• The compiler computes the reaction for all possible patterns of events– it constructs a finite automaton– construction similar to the derivative
construction
April 18, 2023 Esterel notes 18
Causality Problems
• A reaction ends when all processes arrive at an await
• What if you never hit one?– Loop
– emit A;
– X = X + 1;
– end loop
• Same as combinational loops in hardware
April 18, 2023 Esterel notes 19
The fixed point may not exist
• There are no solutions– present X then nothing else emit X;
• There are too many solutions– present X then emit X end;
April 18, 2023 Esterel notes 20
Esterel supports exceptions
• Useful to jump out of a fragment of code
• Abort when an event occurs– abort– code– code– when A;
April 18, 2023 Esterel notes 21
Seat-beltIf the driver turns on the key, and
does not fasten the seat belt within 5 seconds
then an alarm beeps for 5 seconds, oruntil the driver fastens the seat belt, or
until the driver turns off the key
If the driver turns on the key, anddoes not fasten the seat belt within 5 seconds
then an alarm beeps for 5 seconds, oruntil the driver fastens the seat belt, or
until the driver turns off the key
present KEY_ON then
input KEY_ON
If the driver turns on the key, anddoes not fasten the seat belt within 5 seconds
then an alarm beeps for 5 seconds, oruntil the driver fastens the seat belt, or
until the driver turns off the key
emit START_TIMER(5); await END_TIMER;
, END_TIMER
output START_TIMER
emit START_TIMER(5); abort sustain BEEP when END_TIMER;
end
abort
when KEY_OFF or BELT_ON
If the driver turns on the key, anddoes not fasten the seat belt within 5 seconds
then an alarm beeps for 5 seconds, oruntil the driver fastens the seat belt, or
until the driver turns off the key
If the driver turns on the key, anddoes not fasten the seat belt within 5 seconds
then an alarm beeps for 5 seconds, oruntil the driver fastens the seat belt, or
until the driver turns off the key
, KEY_OFF, BELT_ON
, BEEP;
loop
each RESET
, RESET;
April 18, 2023 Esterel notes 22
You can run examples
• Compile with -simul to run textual simulation
• Use xes for graphical debugging
• If we have time we can look at a simple example