esterel programming language

22
Esterel Programming Language

Upload: ros

Post on 21-Feb-2016

59 views

Category:

Documents


0 download

DESCRIPTION

Esterel Programming Language. Synchronous Programming Language: Reactive systems that interact continuously with their environment, at a speed imposed by the environment Imperative programming style: - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Esterel  Programming Language

Esterel Programming

Language

Page 2: Esterel  Programming Language

Main Characteristics• Synchronous Programming Language:

• Reactive systems that interact continuously with their environment, at a speed imposed by the environment

• Imperative programming style:• A programming paradigm that describes computation in

terms of statements that change a program state. It defines a sequence of commands for the computer to perform.

• This is opposed to declarative programming which expresses what a program should do without saying how it should do it.

Page 3: Esterel  Programming Language

Development• Design Goals:

• A natural expression of control allowing instantaneous propagation of control

• Simple and intuitive way of modeling system design and physical reality

• Ideal usage for hardware system control

time

Execution instants

Input Input InputOutput Output Output

Page 4: Esterel  Programming Language

Development• 1984:

• Jean-Paul Marmorat and Jean-Paul Rigault were researchers in Control Theory and Computer Science at the Ecole des Mines de Paris. While attempting to design a robotic car, they become frustrated in their attempts to express control algorithms in a natural and powerful way.

• In response they invent an original, mathematically defined formal notation that allows them to control the car.

• First Esterel Compiler is made

Jean-Paul Marmorat Jean-Paul Rigault

Page 5: Esterel  Programming Language

Development• 1988:

• Gerard Berry develops formal semantics and a first generation of code generation and formal verification tools

• 1989:• Simulog, a French software company, develops a

prototype version of the Esterel toolset for commercial use (Esterel v3 with enhanced compiler).

• First Industrial use with AT&T Bell Labs, Dassault Aviation, and Bertin.

Gerard Berry

Page 6: Esterel  Programming Language

Development• 1991:

• Esterel v4 integrates a hardware compiler for use with FPGA’s

• 1999:• Esterel Technologies is launched as a spinoff of Simulog

and continues development• 2003:

• Esterel v7 launches adding improved program structures, arrays of signals, delayed emissions, and multi-lock support

• 2006:• Standardization process begun for IEEE approval

Page 7: Esterel  Programming Language

Applications

Page 8: Esterel  Programming Language

Characteristics• Multiform Notion of Time

• Physical time is replaced with the notion of order• Only the simultaneity and presence of events are

considered, thus physical time is ignored• Esterel describes a totally ordered sequence of logical

events, with an arbitrary number of events happening in each instant

• Events that happen with in the same instant are considered to occur simultaneously

• Two types of events:• Those that start and end in the same instant (which

is considered instantaneous execution)• Those that delay for a certain amount of cycles

Page 9: Esterel  Programming Language

Characteristics• Multiform Notion of Time

Page 10: Esterel  Programming Language

Characteristics• Primitive statements

nothing Terminates immediately with no other effect.

pause Blocks control flow in the current cycle for resumption in the next cycle.

p ; q Runs p until it terminates and then, in the same reaction, start q.

p || q Runs p and q in parallel

loop p end

Restart 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 end Declares 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 end If signal S is present in the current instant, immediately run p, otherwise run q.

suspend p when S Suspends the execution of the body in instants where S is present.

trap T in p end Declare a labeled escape block.

exit T Jump to the end of the innermost T-labeled escape block.

Page 11: Esterel  Programming Language

Characteristics• Derived statements

Derived statement Expansion

halt loop pause endsustain s loop emit s; pause end

present s then p end present s then p else nothing end

await s trap T in loop pause; present s then exit T end end loop end

await immediate s trap T in loop present s then exit T end; pause end loop end

suspend p when immediate s suspend present s then pause end; p when s

abort p when (immediate) s trap T in suspend p when s; exit T || await (immediate) s; exit T; end

weak abort p when (immediate) s trap T in p; exit T || await (immediate) s; exit T; end

loop p each s loop abort p ; halt when s end loop

every (immediate) s do p end every await (immediate) s; loop p each s

Page 12: Esterel  Programming Language

Characteristics• Module Example:

“Wait until both A and B have occurred, then output O, unless the reset R occurs”

A B

B/0 A/O

AB/O

RR

R

module ABRO: input A, B, R; output O;

loop [ await A || await B ]; emit O each R

end module

Esterel programs built from modules

O

Each module has an interface of input and output signals

Page 13: Esterel  Programming Language

Characteristics• Simpler, Faster Code:

A B

B/0 A/O

AB/O

RR

Rmodule ABRO: input A, B, R; output O;

loop [ await A || await B ]; emit O each R

end module

O

switch(state){case 0: state=1; break;case 1: if(!R)if(A)if(B) {O=1;state=4;} else state=2; else if(B)state=3;break;case 2: if(R)state=1; else if(B){O=1;state=4;} break;case 3: if(R)state=1; else if(A){O=1;state=4;} break;case 4: if(R)state=1;break;}

Page 14: Esterel  Programming Language

Signals• Esterel Signals:

• Signals are the only means of communication• Two types:

• Non-valued contains not data, they either exist or don’t exist (think true/false)

• Valued also contains data in addition to the state of its existence

• Any process can read or write a signal, which are broadcast across the program

• The default status of signals is absent, and must be explicitly set to present using the “emit” statement

• Signals are transmitted instantaneously (visible immediately within the cycle it is transmitted)

• Signal coherency is maintained by enforcement that all writers occur before any readers do

Page 15: Esterel  Programming Language

Signals

A signal emitted in a cycle is visible immediately[ pause; emit A; pause; emit A|| pause; present A then emit B end]

AB

A

Cycles

Groups of statements separated by || run concurrently and terminate when all groups have terminated

[ emit A; pause; emit B;|| pause; emit C; pause; emit D];emit E

A BC

DE

Cycles

Page 16: Esterel  Programming Language

Signals • Processes can communicate back and forth in the same cycle

[ pause; emit A; present B then emit C end; pause; emit A|| pause; present A then emit B end]

ABC

A

Cycles

• Signals are the only way for concurrent processes to communicate• Esterel does have variables, but they cannot be shared• Signal coherence rules ensure deterministic behavior• Language semantics clearly defines who must communicate with whom when

Page 17: Esterel  Programming Language

Await Statement The await statement waits for a particular cycleawait S waits for the next cycle in which S is present

[ emit A ; pause ; pause; emit A|| await A; emit B]

A AB

Cycles

Await normally waits for a cycle before beginning to checkawait immediate also checks the initial cycle

[ emit A ; pause ; pause; emit A|| await immediate A; emit B]

AB

A

Cycles

Page 18: Esterel  Programming Language

Await Statement

Cycles

• Esterel has an infinite loop statement• Rule: loop body cannot terminate instantly it needs at least one pause, await, etc. Can’t do an infinite amount of work in a single cycleloop emit A; pause; pause; emit Bend

A BA

BA

BA

Instantaneous nature of loops plus await provide very powerful synchronization mechanismsloop await 60 Sec; emit Minend Sec Sec Sec Sec Sec Sec Sec

Min

1 2 3 4 5 59 60…

Cycles

Page 19: Esterel  Programming Language

Circuit Translation

RESET = R & !BOOTA_TRIGGER = A_OUT & !RESET A_THEN = A_TRIGGER & AA_ELSE = A_TRIGGER & !AA_TERM = A_THEN | ! A_TRIGGERA_IN = BOOT | RESET | A_ELSE B_TRIGGER = B_OUT & !RESETB_THEN = B_TRIGGER & BB_ELSE = B_TRIGGER & !BB_TERM = B_THEN | ! B_TRIGGERB_IN = BOOT | RESET | B_ELSEACTIVE = A_TRIGGER | B_TRIGGERO = A_TERM & B_TERM & ACTIVE

loop [ await A || await B ]; emit O; haltevery R

boot

R

A

O

Page 20: Esterel  Programming Language

Esterel: When Control is Essential

• Model of time gives programmer precise control• Concurrency convenient for specifying control systems• Completely deterministic

• Guaranteed: no need for locks, semaphores, etc.• Finite-state language

• Easy to analyze• Execution time predictable• Much easier to verify formally

• Amenable to implementation in both hardware and software

Page 21: Esterel  Programming Language

Esterel: When Control is Essential

• Finite-state nature of the language limits flexibility• No dynamic memory allocation• No dynamic creation of processes

• Virtually nonexistent support for handling data• Really suited for simple decision-dominated controllers• Synchronous model of time can lead to over-specification• Semantic challenges

• Avoiding causality violations often difficult• Difficult to compile

• Limited number of users, tools, etc.

Page 22: Esterel  Programming Language

Questions?