Title: Esterel Overview
1Esterel Overview
- Roberto Passerone
- ee249 discussion section
2Classes of applications
- Transformational
- Interactive
- Reactive
3Model of Time
- Totally ordered sequence of instants
- Instants are also called ticks
- There is nothing in between instants
4Esterel
- Esterel is a reactive programming language
- Esterel is also a Synchronous language
- Everything proceeds in lock-step
5You might hear that...
- In Esterel computation takes zero time
- Communication also takes zero time
- In other words, reactions to events are
instantaneous
6Model 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
7Model 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
8Interaction 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
9Checking for presence
- Processes can test for the presence or absence of
events in signals - present A then else ...
10Awaiting an event
- Processes can stop their execution until an event
is present in a signal - await A
- await A or B
11Emitting an event
- Processes can emit an event to a signal to make
it present - emit A
- emit A, 10
12Execution 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
13When 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
14Important
- 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
15Atomicity 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
16How 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
17Compiling 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
18Causality 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
19The 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
20Esterel supports exceptions
- Useful to jump out of a fragment of code
- Abort when an event occurs
- abort
- code
- code
- when A
21Seat-belt
If the driver turns on the key, and does not
fasten the seat belt within 5 seconds then an
alarm beeps for 5 seconds, or until the driver
fastens the seat belt, or until the driver turns
off the key
If the driver turns on the key, and does not
fasten the seat belt within 5 seconds then an
alarm beeps for 5 seconds, or until the driver
fastens the seat belt, or until the driver turns
off the key
If the driver turns on the key, and does not
fasten the seat belt within 5 seconds then an
alarm beeps for 5 seconds, or until the driver
fastens the seat belt, or until the driver turns
off the key
If the driver turns on the key, and does not
fasten the seat belt within 5 seconds then an
alarm beeps for 5 seconds, or until the driver
fastens the seat belt, or until the driver turns
off the key
If the driver turns on the key, and does not
fasten the seat belt within 5 seconds then an
alarm beeps for 5 seconds, or until the driver
fastens the seat belt, or until the driver turns
off the key
input KEY_ON
, END_TIMER
, KEY_OFF, BELT_ON
, RESET
output START_TIMER
, BEEP
loop
abort
present KEY_ON then
emit START_TIMER(5) await END_TIMER
emit START_TIMER(5) abort sustain BEEP when
END_TIMER
end
when KEY_OFF or BELT_ON
each RESET
22You 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
23Immediate reactions
- Alternative formulation of await
- It doesnt wait until the next reaction if the
signal is present - Often creates causality problems
- loop
- await immediate A
- X X 1
- end loop