Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
KTH
November 9, 2009
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 1 / 68
Outline
2 Statecharts Formalism
3 Esterel Language
4 Lustre Language
5 Signal Language
6 Challenges
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 2 / 68
Real-Time and Reactive Systems
Definition
A reactive system is a system that maintains a permanent interaction with
its environment.
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 3 / 68
Real-Time and Reactive Systems
Definition
A reactive system is a system that maintains a permanent interaction with
its environment.
Definition
A real-time system is a reactive system that is in addition subject to
externally defined timing constraints.
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 3 / 68
Real-Time and Reactive Systems
Definition
A reactive system is a system that maintains a permanent interaction with
its environment.
Definition
A real-time system is a reactive system that is in addition subject to
externally defined timing constraints.
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 3 / 68
Application areas
1 Pure task sequencers in command boards, computer integrated
manufacturing
high combinatorial complexity → convert specification to implementation
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 4 / 68
Application areas
1 Pure task sequencers in command boards, computer integrated
manufacturing
high combinatorial complexity → convert specification to implementation
2 Communication protocols in real-time LANs
similar concerns as above
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 4 / 68
Application areas
1 Pure task sequencers in command boards, computer integrated
manufacturing
high combinatorial complexity → convert specification to implementation
2 Communication protocols in real-time LANs
similar concerns as above
3 Low level signal processing in digital communication systems
high throughput → handle algorithm and architecture in same framework
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 4 / 68
Application areas
1 Pure task sequencers in command boards, computer integrated
manufacturing
high combinatorial complexity → convert specification to implementation
2 Communication protocols in real-time LANs
similar concerns as above
3 Low level signal processing in digital communication systems
high throughput → handle algorithm and architecture in same framework
4 Industrial process control in regulators supervised by interrupts and
sequential tasks
a tool allowing easy specification with correct implementation
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 4 / 68
Application areas
1 Pure task sequencers in command boards, computer integrated
manufacturing
high combinatorial complexity → convert specification to implementation
2 Communication protocols in real-time LANs
similar concerns as above
3 Low level signal processing in digital communication systems
high throughput → handle algorithm and architecture in same framework
4 Industrial process control in regulators supervised by interrupts and
sequential tasks
a tool allowing easy specification with correct implementation
5 Complex signal processing systems in radar and sonar
computationally intensive → same as above + speed
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 4 / 68
Application areas
1 Pure task sequencers in command boards, computer integrated
manufacturing
high combinatorial complexity → convert specification to implementation
2 Communication protocols in real-time LANs
similar concerns as above
3 Low level signal processing in digital communication systems
high throughput → handle algorithm and architecture in same framework
4 Industrial process control in regulators supervised by interrupts and
sequential tasks
a tool allowing easy specification with correct implementation
5 Complex signal processing systems in radar and sonar
computationally intensive → same as above + speed
6 Complex Control-and-Monitoring systems in govern aircraft and
transportation systems, hazardous plants
heuristics of high computational complexity +distributed architecture
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 4 / 68
Application areas
1 Pure task sequencers in command boards, computer integrated
manufacturing
high combinatorial complexity → convert specification to implementation
2 Communication protocols in real-time LANs
similar concerns as above
3 Low level signal processing in digital communication systems
high throughput → handle algorithm and architecture in same framework
4 Industrial process control in regulators supervised by interrupts and
sequential tasks
a tool allowing easy specification with correct implementation
5 Complex signal processing systems in radar and sonar
computationally intensive → same as above + speed
6 Complex Control-and-Monitoring systems in govern aircraft and
transportation systems, hazardous plants
heuristics of high computational complexity +distributed architecture
7 C3 -systems(Command-Control-Communicate) in military systems, air
traffic control
moving subsystems → communication links are time variant
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 4 / 68
Major Issues
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 5 / 68
Major Issues
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 5 / 68
Major Issues
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 5 / 68
Major Issues
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 5 / 68
Major Issues
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 5 / 68
Major Issues
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 5 / 68
Real-Time Programming Techniques
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 6 / 68
Real-Time Programming Techniques
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 6 / 68
Real-Time Programming Techniques
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 6 / 68
Real-Time Programming Techniques
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 6 / 68
Synchronous Approach
Main Simplification
Sets of ideal systems compose very well into other ideal systems
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 7 / 68
Example 1: Clicking on a Mouse
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 8 / 68
Example 2: A Digital Filter
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 9 / 68
Synchronous Modeling Summary
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 10 / 68
Synchronous Modeling Summary
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 10 / 68
Synchronous Modeling Summary
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 10 / 68
Synchronous Approach Considerations
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 11 / 68
Synchronous Approach Considerations
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 11 / 68
Synchronous Models vs. Asynchronous Systems
Actual machines for which the ideal synchronous model is valid exist. But:
many machines supporting such application are actually asynchronous
real-time systems are often implemented on distributed architectures
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 12 / 68
Synchronous Models vs. Asynchronous Systems
Actual machines for which the ideal synchronous model is valid exist. But:
many machines supporting such application are actually asynchronous
real-time systems are often implemented on distributed architectures
The synchronous approach to asynchronous implementations:
1 When feasible strictly synchronous execution of synchronous systems
are valid (VLSI)
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 12 / 68
Synchronous Models vs. Asynchronous Systems
Actual machines for which the ideal synchronous model is valid exist. But:
many machines supporting such application are actually asynchronous
real-time systems are often implemented on distributed architectures
The synchronous approach to asynchronous implementations:
1 When feasible strictly synchronous execution of synchronous systems
are valid (VLSI)
2 Verification and proofs of correct synchronization and logic are
available in synchronous approach
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 12 / 68
Synchronous Models vs. Asynchronous Systems
Actual machines for which the ideal synchronous model is valid exist. But:
many machines supporting such application are actually asynchronous
real-time systems are often implemented on distributed architectures
The synchronous approach to asynchronous implementations:
1 When feasible strictly synchronous execution of synchronous systems
are valid (VLSI)
2 Verification and proofs of correct synchronization and logic are
available in synchronous approach
3 A sequential execution scheme can be derived at compile time for any
synchronous system.
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 12 / 68
Synchronous Models vs. Asynchronous Systems
Actual machines for which the ideal synchronous model is valid exist. But:
many machines supporting such application are actually asynchronous
real-time systems are often implemented on distributed architectures
The synchronous approach to asynchronous implementations:
1 When feasible strictly synchronous execution of synchronous systems
are valid (VLSI)
2 Verification and proofs of correct synchronization and logic are
available in synchronous approach
3 A sequential execution scheme can be derived at compile time for any
synchronous system.
4 The idealized strict synchronicity hypothesis can be relaxed to yield
correct fully asynchronous executions.
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 12 / 68
Synchronous Models vs. Asynchronous Systems
Actual machines for which the ideal synchronous model is valid exist. But:
many machines supporting such application are actually asynchronous
real-time systems are often implemented on distributed architectures
The synchronous approach to asynchronous implementations:
1 When feasible strictly synchronous execution of synchronous systems
are valid (VLSI)
2 Verification and proofs of correct synchronization and logic are
available in synchronous approach
3 A sequential execution scheme can be derived at compile time for any
synchronous system.
4 The idealized strict synchronicity hypothesis can be relaxed to yield
correct fully asynchronous executions.
5 The formal verification tools based on the synchronous approach
provide a way to validate asynchronous executions
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 12 / 68
Outline
2 Statecharts Formalism
3 Esterel Language
4 Lustre Language
5 Signal Language
6 Challenges
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 13 / 68
Finite-State Machines
states and events are a priori a rather natural medium for describing
dynamic behavior of complex systems
a basic fragment of such a description is state transition
FSMs and their state diagrams collect such fragments into a whole
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 14 / 68
Finite-State Machines
states and events are a priori a rather natural medium for describing
dynamic behavior of complex systems
a basic fragment of such a description is state transition
FSMs and their state diagrams collect such fragments into a whole
Problem
a complex system cannot be described in this naive fashion due to
exponentially growing multitude of states.
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 14 / 68
Rethinking State/Event Approach
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 15 / 68
Introducing Statecharts
In a Nutshell
statecharts = state-diagrams + depth + orthogonality +
broadcast-communication
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 16 / 68
State-Levels: Clustering and Refinement
clustering refinement
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 17 / 68
State-Levels: Clustering and Refinement
clustering refinement
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 17 / 68
Contradiction and Non-determinism
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 18 / 68
Orthogonality: Independence and Concurrency
⇐⇒
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 19 / 68
Orthogonality: Independence and Concurrency
⇐⇒
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 19 / 68
Delays and Timeouts
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 20 / 68
Example: A Wrist Watch
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 21 / 68
Actions and Activities
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 22 / 68
Example on Actions and Activities
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 23 / 68
Possible extensions
parameterized states
overlapping states
incorporating temporal logic
recursive and probabilistic statecharts
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 24 / 68
Semantics of Statecharts
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 25 / 68
Semantics of Statecharts
The more difficult problems arise with the introduction of events and
conditions that are generated within statechart itself, and sensed in
orthogonal components.
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 25 / 68
Semantics of Statecharts - Non-determinism
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 26 / 68
Semantics of Statecharts - Non-determinism
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 26 / 68
Outline
2 Statecharts Formalism
3 Esterel Language
4 Lustre Language
5 Signal Language
6 Challenges
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 27 / 68
Underlying Model
1 Reactivity
when activated with an input event, a reactive system reacts by
producing an output event
life of the system is divided into instances that are the moments it
reacts
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 28 / 68
Underlying Model
1 Reactivity
when activated with an input event, a reactive system reacts by
producing an output event
life of the system is divided into instances that are the moments it
reacts
2 Atomicity of reactions
the basic hypothesis of Esterel is the perfect synchronous hypothesis
reactions are atomic, a reaction does not interfere with other reactions
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 28 / 68
Underlying Model
1 Reactivity
when activated with an input event, a reactive system reacts by
producing an output event
life of the system is divided into instances that are the moments it
reacts
2 Atomicity of reactions
the basic hypothesis of Esterel is the perfect synchronous hypothesis
reactions are atomic, a reaction does not interfere with other reactions
3 Instantaneous broadcast
communication is done using broadcast mechanism
communication is done over signals
emission and reception of signals do not terminate the current instance
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 28 / 68
Underlying Model
1 Reactivity
when activated with an input event, a reactive system reacts by
producing an output event
life of the system is divided into instances that are the moments it
reacts
2 Atomicity of reactions
the basic hypothesis of Esterel is the perfect synchronous hypothesis
reactions are atomic, a reaction does not interfere with other reactions
3 Instantaneous broadcast
communication is done using broadcast mechanism
communication is done over signals
emission and reception of signals do not terminate the current instance
4 Determinism
Nondeterminism is completely thrown out of Esterel (?)
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 28 / 68
Programming Primitives
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 29 / 68
Programming Style - Example 1
also, an alarm must be emitted when the button is not pressed within
the one second delay
do
await BUTTON;
emit ACTION;
watching SECOND
timeout emit ALARM
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 30 / 68
Programming Style - Example 2
module Counter:
input RST, CLICK;
output VAL(Integer);
var v : integer in
do
v := 0;
every immediate CLICK do
v := v+1;
end
watching RST;
emit VAL(v);
end
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 31 / 68
Programming Style - Example 2
module Emission:
module Counter:
input VAL(Integer);
input RST, CLICK;
output NONE, SINGLE, MANY;
output VAL(Integer);
await VAL;
var v : integer in
if ?VAL = 0 then
do
emit NONE
v := 0;
else
every immediate CLICK do
if ?VAL = 1 then
v := v+1;
emit SINGLE
end
else
watching RST;
emit MANY
emit VAL(v);
end
end
end
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 31 / 68
Programming Style - Example 2
module Mouse:
input CLICK, TOP;
output NONE, SINGLE, MANY;
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 32 / 68
Problems in Esterel
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 33 / 68
Problems in Esterel
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 33 / 68
Problems in Esterel
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 33 / 68
Semantics of Esterel
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 34 / 68
Semantics of Esterel
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 34 / 68
Compiling Esterel
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 35 / 68
Compiling Esterel
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 35 / 68
Compiling Esterel
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 35 / 68
Verification
−→
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 36 / 68
Outline
2 Statecharts Formalism
3 Esterel Language
4 Lustre Language
5 Signal Language
6 Challenges
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 37 / 68
The Data-flow approach
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 38 / 68
Synchronous Dataflow
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 39 / 68
Flows and Clocks
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 40 / 68
Flows and Clocks
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 40 / 68
Variables, Equations, Expressions
As a consequence
a Lustre program is written as a set of mathematical equations.
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 41 / 68
Sequence Operators
for any flow x, pre(x) (previous operator) is the the flow whose value
at each step is the previous value of x and nil at the very first step.
the − > operator (followed by operator) defines initial value. x− >y
is equal to x in th first step and equal to y thereafter.
when samples an expression according to a slower clock. if E is an
expression and B is a boolean expression with the same clock,
E when B is a flow whose clock is defined by B and is equal to
sequence of values of E when B is true
current interpolates an expression on the clock immediately faster
than its own.
B false true false true false false true true
X x1 x2 x3 x4 x5 x6 x7 x8
Y=X when B x2 x4 x7 x8
Z=current Y nil x2 x2 x4 x4 x4 x7 x8
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 42 / 68
Assertions
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 43 / 68
Program Structure
n = 0 -> pre(n) + 1;
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 44 / 68
Program Structure
n = 0 -> pre(n) + 1;
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 44 / 68
Causality in Lustre
the commercial scade tool forbids feeding back the output of a node
to its inputs without using a pre operator
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 45 / 68
Clock Calculus
Problem
in the second equations the b = true -> not pre b;
operand combines flows of y = x + (x when b);
different clocks
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 46 / 68
Clock Calculus
Problem
in the second equations the b = true -> not pre b;
operand combines flows of y = x + (x when b);
different clocks
the clock calculus consists of associating a clock with each expression
of the program, and of checking that any operator applies to
appropriately clocked operands:
primitive operators apply to operands of same clock
the clock of the operand of a current operator is not the basic clock of
the node it belongs to
the clock of a node operands should obey the clock requirements
stated in the node definition header
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 46 / 68
Lustre Compiler
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 47 / 68
Lustre Compiler
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 47 / 68
Distributed Code Generation
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 48 / 68
Verification I
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 49 / 68
Verification II
modular verification
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 50 / 68
Outline
2 Statecharts Formalism
3 Esterel Language
4 Lustre Language
5 Signal Language
6 Challenges
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 51 / 68
Introducing Signal
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 52 / 68
Monochronous Signals
Static monochronous operators are extensions to sequences of the
classical arithmetic or logical operators (+, -, /, **, and, not, etc.)
Y := U + V is coding of ∀n > 0 yn = un + vn
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 53 / 68
Monochronous Signals
Static monochronous operators are extensions to sequences of the
classical arithmetic or logical operators (+, -, /, **, and, not, etc.)
Y := U + V is coding of ∀n > 0 yn = un + vn
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 53 / 68
Monochronous Signals
Static monochronous operators are extensions to sequences of the
classical arithmetic or logical operators (+, -, /, **, and, not, etc.)
Y := U + V is coding of ∀n > 0 yn = un + vn
(| VY := Y$1 window 2
| VU := U window 3
| Y := PROD {A, VY} + PROD {B, VU}
|)
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 53 / 68
Polychronous Operators I
X: 1 2 ⊥ 3 4 ⊥ 5 6 9 ...
B: t f t f t f ⊥ f t ...
Y: 1 ⊥ ⊥ ⊥ 4 ⊥ ⊥ ⊥ 9 ...
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 54 / 68
Polychronous Operators I
X: 1 2 ⊥ 3 4 ⊥ 5 6 9 ...
B: t f t f t f ⊥ f t ...
Y: 1 ⊥ ⊥ ⊥ 4 ⊥ ⊥ ⊥ 9 ...
U: 1 2 ⊥ 3 4 ⊥ 5 6 9 ...
V: ⊥ ⊥ 3 4 10 8 9 2 ⊥ ...
Y: 1 2 3 3 4 8 5 2 9 ...
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 54 / 68
Polychronous Operators II
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 55 / 68
The Mouse example
process MOUSE = (integer DELTA)
{ ? event TICK, CLICK
! event SINGLE, DOUBLE }
(| (| START := CLICK not in ]START, RELAX]
| (| N := (#TICK in ]START, RELAX])
cell event N
| ZN := N $1 % initial value 0 %
| N ^= (CLICK default TICK)
| RELAX := TICK when (ZN = (DELTA-1))
|)
|)
| (| DOUBLE_CLICK := ((not START)
default
(CLICK in ]START, RELAX]))cell RELAX
| SINGLE := RELAX when (not
DOUBLE-CLICK)
| DOUBLE := RELAX when DOUBLE-CLICK |)
|)
where event START, RELAX;
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 56 / 68
Clock Calculus in Signal I
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 57 / 68
Clock Calculus in Signal II
Z := X op Y hZ = hX = hY
(X,Y)→Z
Y := X$1 hX = hY
hX = hU when B
X := U when B B→X
U→X when B
hX = hU ∨ hV
X := U default V U→X
V→X when (hV − hV )
P|Q abstract(P)∪abstract(Q)
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 58 / 68
Clock Calculus in Signal III
clock calculus provides answers such as:
does a program admit a behavior (no contradictions)?
(| x := a when (a>0)
| y := a when not(a>0) empty set assigned to the clocks, no
| z := x + y |) execution!
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 59 / 68
Clock Calculus in Signal III
clock calculus provides answers such as:
does a program admit a behavior (no contradictions)?
(| x := a when (a>0)
| y := a when not(a>0) empty set assigned to the clocks, no
| z := x + y |) execution!
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 59 / 68
Clock Calculus in Signal III
clock calculus provides answers such as:
does a program admit a behavior (no contradictions)?
(| x := a when (a>0)
| y := a when not(a>0) empty set assigned to the clocks, no
| z := x + y |) execution!
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 59 / 68
Signal’s Compiler
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 60 / 68
Parallel Code Generation - Order Enhancement
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 61 / 68
Parallel Code Generation - Order Enhancement
restructuring
R=(| a:=h(y) | y:=g(b) |)
S=(| x:=f(a) |)
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 61 / 68
More on Timing in Signal
specify local timing constraints involving very few different clocks and let
the compiler do the rest
this is different from Lustre’s style, where the programmer must have
a global view of timing
the language itself can be used as a partial proof system by
embedding the timing constraints inside the language
it usually turns out that the specification of a system is also its
programming
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 62 / 68
Outline
2 Statecharts Formalism
3 Esterel Language
4 Lustre Language
5 Signal Language
6 Challenges
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 63 / 68
Architecture Modeling
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 64 / 68
Beyond Synchrony I
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 65 / 68
Beyond Synchrony I
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 65 / 68
Beyond Synchrony II
as for the Signal, additional signaling is needed since it is not possible
to distinguish between no-token and late-token situation.
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 66 / 68
From Programs to Components and Systems
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 67 / 68
References
A. Benveniste and G. Berry.
The synchronous approach to reactive and real-time systems.
Proceedings of the IEEE, 79(9):1270–1282, 1991.
A. Benveniste, P. Caspi, S.A. Edwards, N. Halbwachs, P. Le Guernic, and
R. de Simone.
The synchronous languages 12 years later.
Proceedings of the IEEE, 91(1):64–83, 2003.
F. Boussinot and R. de Simone.
The ESTEREL language.
Proceedings of the IEEE, 79(9):1293–1304, 1991.
N. Halbwachs, P. Caspi, P. Raymond, and D. Pilaud.
The synchronous data flow programming language LUSTRE.
Proceedings of the IEEE, 79(9):1305–1320, 1991.
Nicolas Halbwachs.
Synchronous programming of reactive systems.
In Computer Aided Verification, pages 1–16. 1998.
David Harel.
Statecharts: a visual formalism for complex systems.
Science of Computer Programming, 8(3):231–274, June 1987.
P. LeGuernic, T. Gautier, M. Le Borgne, and C. Le Maire.
Programming real-time applications with SIGNAL.
Proceedings of the IEEE, 79(9):1321–1336, 1991.
Seyed Hosein Attarzadeh Niaki (KTH) Topic 1: Synchronous Languages November 9, 2009 68 / 68