- 1 - embedded systems—state charts specifications
TRANSCRIPT
- 2 -Embedded Systems—State charts
Specification language for embedded systems should represent the following features: (1)
• HierarchyHumans not capable to understand systems containing more than ~5 objects. Most actual systems require more objects – Behavioral hierarchy
Examples: states, processes, procedures.– Structural hierarchy
Examples: processors, racks, printed circuit boards• Timing behavior.
• State-oriented behaviorRequired for reactive systems; classical automata insufficient (no timing).
• HierarchyHumans not capable to understand systems containing more than ~5 objects. Most actual systems require more objects – Behavioral hierarchy
Examples: states, processes, procedures.– Structural hierarchy
Examples: processors, racks, printed circuit boards• Timing behavior.
• State-oriented behaviorRequired for reactive systems; classical automata insufficient (no timing).
- 3 -Embedded Systems—State charts
Requirements for specification techniques (2)
• Event-handling (external or internal events)• No obstacles for efficient implementation• Support for the design of dependable systems
Unambiguous semantics, ...• Exception-oriented behavior
Not acceptable to describe exceptions for every state.
• Event-handling (external or internal events)• No obstacles for efficient implementation• Support for the design of dependable systems
Unambiguous semantics, ...• Exception-oriented behavior
Not acceptable to describe exceptions for every state.
We will see, how all the arrows labeled k can be replaced by a single one..
exception
- 4 -Embedded Systems—State charts
Requirements for specification techniques (3)
• ConcurrencyReal-life systems are concurrent
• Synchronization and communicationComponents have to communicate!
• Presence of programming elementsFor example, arithmetic operations, loops, and function calls should be available
• Executability (no algebraic specification)• Support for the design of large systems ( OO)• Domain-specific support (control-dominated, data-
dominated, centralized and distributed applications-domains)
• ConcurrencyReal-life systems are concurrent
• Synchronization and communicationComponents have to communicate!
• Presence of programming elementsFor example, arithmetic operations, loops, and function calls should be available
• Executability (no algebraic specification)• Support for the design of large systems ( OO)• Domain-specific support (control-dominated, data-
dominated, centralized and distributed applications-domains)
- 5 -Embedded Systems—State charts
Requirements for specification techniques (4)
• Readability : human, computer.• Portability and flexibility• Termination
It should be clear, at which time all computations are completed
• Support for non-standard I/O devicesDirect access to switches, displays, ...
• Non-functional propertiesfault-tolerance, disposability, EMC-properties, weight, size, user friendliness, extendibility, expected life time, power consumption...
• Adequate model of computation
• Readability : human, computer.• Portability and flexibility• Termination
It should be clear, at which time all computations are completed
• Support for non-standard I/O devicesDirect access to switches, displays, ...
• Non-functional propertiesfault-tolerance, disposability, EMC-properties, weight, size, user friendliness, extendibility, expected life time, power consumption...
• Adequate model of computation
- 6 -Embedded Systems—State charts
Models of computation- Definition -
Models of computation define [Lee, UCB, 1999]:• What it means to be a component:
Subroutine? Process? Thread?• The mechanisms by which components interact:
Message passing? Rendez-vous?• Possibly also:
What components know about each other(global variables? Implicit behavior of other components)
• Do not define interaction vocabulary
Models of computation define [Lee, UCB, 1999]:• What it means to be a component:
Subroutine? Process? Thread?• The mechanisms by which components interact:
Message passing? Rendez-vous?• Possibly also:
What components know about each other(global variables? Implicit behavior of other components)
• Do not define interaction vocabulary
- 7 -Embedded Systems—State charts
Models of computation- Examples (1) -
• Communicating finite state machines (CFSMs): SDL• Communicating finite state machines (CFSMs): SDL
• Discrete event model: VHDL, Verilog• Discrete event model: VHDL, Verilog
abc
timeactiona:=5 b:=7 c:=8 a:=6 a:=9
queue
5 10 13 15 19
- 8 -Embedded Systems—State charts
Models of computation- Examples (2) -
• Asynchronous message passing (buffer, overflow)• Asynchronous message passing (buffer, overflow)
• Differential equations (analog)• Differential equations (analog)
• Synchronous message passing (rendez-vous)• Synchronous message passing (rendez-vous)
bt
x
2
2
FIFO
- 9 -Embedded Systems—State charts
StateCharts: recap of classical automata
Classical automata:Classical automata:
• Moore-automata:Y = (Z); Z+ = (X, Z)
• Mealy-automataY = (X, Z); Z+ = (X, Z)
• Moore-automata:Y = (Z); Z+ = (X, Z)
• Mealy-automataY = (X, Z); Z+ = (X, Z)
Internal state Zinput X output Y
Next state Z+ computed by function Output computed by function
Z0 Z1
Z2Z3
e=1
e=1
e=1
e=1
0 1
23
clockMoore- + Mealy automata=finite state machines (FSMs)
Moore- + Mealy automata=finite state machines (FSMs)
- 10 -Embedded Systems—State charts
StateCharts
Classical automata not useful for complex systems
(complex graphs cannot be understood by humans).
Introduction of hierarchy StateCharts [Harel, 1987]
StateChart = the only unused combination of
“flow” or “state” with “diagram” or “chart”
Classical automata not useful for complex systems
(complex graphs cannot be understood by humans).
Introduction of hierarchy StateCharts [Harel, 1987]
StateChart = the only unused combination of
“flow” or “state” with “diagram” or “chart”
- 11 -Embedded Systems—State charts
Introducing hierarchy
super-state S
sub-states
FSM will be in exactly one of the substates of S if S is active(either in A or in B or ..)
FSM will be in exactly one of the substates of S if S is active(either in A or in B or ..)
- 12 -Embedded Systems—State charts
Modeling of Hierarchy: Definitions
• Current states of FSMs are also called active states.• States which are not composed of other states are called
basic states.• States containing other states are called super-states.• For each basic state s, the super-states containing s are
called ancestor states.• Super-states S are called OR-super-states, if exactly one
of the sub-states of S is active whenever S is active.
• Current states of FSMs are also called active states.• States which are not composed of other states are called
basic states.• States containing other states are called super-states.• For each basic state s, the super-states containing s are
called ancestor states.• Super-states S are called OR-super-states, if exactly one
of the sub-states of S is active whenever S is active.
ancestor state of E
- 13 -Embedded Systems—State charts
Default state mechanism
Filled circleindicates sub-state entered whenever super-state is entered.
Not a state by itself!
Allows internal structure to be hidden for outside world.
Filled circleindicates sub-state entered whenever super-state is entered.
Not a state by itself!
Allows internal structure to be hidden for outside world.
- 14 -Embedded Systems—State charts
History mechanism
For input m, S enters the state it was in before S was left (can be A, B, C, D, or E). If S is entered for the very first time, the default mechanism applies.
History and default mechanisms can be used hierarchically.
For input m, S enters the state it was in before S was left (can be A, B, C, D, or E). If S is entered for the very first time, the default mechanism applies.
History and default mechanisms can be used hierarchically.
(behavior different from last slide)
- 16 -Embedded Systems—State charts
Concurrency
Convenient ways of describing concurrency are required.
AND-super-states: FSM is in all (immediate) sub-states of a super-state; Example:
Convenient ways of describing concurrency are required.
AND-super-states: FSM is in all (immediate) sub-states of a super-state; Example:
- 17 -Embedded Systems—State charts
Entering and leaving AND-super-states
Line-monitoring and key-monitoring are entered and left, when service switch is operated.
Line-monitoring and key-monitoring are entered and left, when service switch is operated.
incl.
- 18 -Embedded Systems—State charts
Types of states
In StateCharts, states are either
• basic states, or
• AND-super-states, or
• OR-super-states.
In StateCharts, states are either
• basic states, or
• AND-super-states, or
• OR-super-states.
- 19 -Embedded Systems—State charts
Timers
Since time needs to be modeled in embedded systems,
timers need to be modeled.
In StateCharts, special edges can be used for timeouts.
Since time needs to be modeled in embedded systems,
timers need to be modeled.
In StateCharts, special edges can be used for timeouts.
If event a does not happen while the system is in the left state for 20 ms, a timeout will take place.
If event a does not happen while the system is in the left state for 20 ms, a timeout will take place.
- 21 -Embedded Systems—State charts
General form of edge labels
Events:• Exist only until the next evaluation of the model• Can be either internally or externally generatedConditions:• Refer to values of variables that keep their value until
they are reassignedReactions:• Can either be assignments for variables or creation of
eventsExample:• service-off [not in Lproc] / service:=0
Events:• Exist only until the next evaluation of the model• Can be either internally or externally generatedConditions:• Refer to values of variables that keep their value until
they are reassignedReactions:• Can either be assignments for variables or creation of
eventsExample:• service-off [not in Lproc] / service:=0
event [condition] / reaction
- 22 -Embedded Systems—State charts
The StateCharts simulation phases
How are edge labels evaluated?
Three phases:
1. Effect of external changes on events and conditions is
evaluated,
2. The set of transitions to be made in the current step and
right hand sides of assignments are computed,
3. Transitions become effective, variables obtain new
values.
Separation into phases 2 and 3 guarantees deterministic
and reproducible behavior.
How are edge labels evaluated?
Three phases:
1. Effect of external changes on events and conditions is
evaluated,
2. The set of transitions to be made in the current step and
right hand sides of assignments are computed,
3. Transitions become effective, variables obtain new
values.
Separation into phases 2 and 3 guarantees deterministic
and reproducible behavior.
- 23 -Embedded Systems—State charts
Example
In phase 2, variables a and b are assigned to temporary variables. In phase 3, these are assigned to a and b. As a result, variables a and b are swapped.
In a single phase environment, executing the left state first would assign the old value of b (=0) to a and b. Executing the right state first would assign the old value of a (=1) to a and b. The execution would be non-deterministic.
In phase 2, variables a and b are assigned to temporary variables. In phase 3, these are assigned to a and b. As a result, variables a and b are swapped.
In a single phase environment, executing the left state first would assign the old value of b (=0) to a and b. Executing the right state first would assign the old value of a (=1) to a and b. The execution would be non-deterministic.
- 24 -Embedded Systems—State charts
Reflects model of clocked hardware
In an actual clocked (synchronous) hardware system, both registers would be swapped as well.
In an actual clocked (synchronous) hardware system, both registers would be swapped as well.
Same separation into phases found in other languages as well, especially those that are intended to model hardware.
Same separation into phases found in other languages as well, especially those that are intended to model hardware.
- 25 -Embedded Systems—State charts
Steps
Execution of a StateChart model consists of a sequence of (status, step) pairs
Execution of a StateChart model consists of a sequence of (status, step) pairs
Status= values of all variables + set of events + current time
Step = execution of the three phases
Status= values of all variables + set of events + current time
Step = execution of the three phases
Statusphase 2
phase 3
phase 1
- 26 -Embedded Systems—State charts
Broadcast mechanism
Values of variables are visible to all parts of the StateChart model.
New values become effective in phase 3 of the current step and are obtained by all parts of the model in the following step.
Values of variables are visible to all parts of the StateChart model.
New values become effective in phase 3 of the current step and are obtained by all parts of the model in the following step.
StateCharts implicitly assumes a broadcast mechanism for variables.
StateCharts is appropriate for local control systems (), but not for distributed applications for which updating variables might take some time ().
StateCharts implicitly assumes a broadcast mechanism for variables.
StateCharts is appropriate for local control systems (), but not for distributed applications for which updating variables might take some time ().
- 27 -Embedded Systems—State charts
Lifetime of events
Events live until the step following the one in which they are generated (“one shot-events“).
Events live until the step following the one in which they are generated (“one shot-events“).
- 28 -Embedded Systems—State charts
Evaluation of StateCharts (1)
Pros:• Hierarchy allows arbitrary nesting of AND- and OR-
superstates.• Semantics defined in a follow-up paper to original paper.• Large number of commercial simulation tools available
(StateMate, StateFlow, BetterState, ...)• Available “back-ends” translate StateCharts into C or
VHDL, thus enabling software or hardware implementations.
Pros:• Hierarchy allows arbitrary nesting of AND- and OR-
superstates.• Semantics defined in a follow-up paper to original paper.• Large number of commercial simulation tools available
(StateMate, StateFlow, BetterState, ...)• Available “back-ends” translate StateCharts into C or
VHDL, thus enabling software or hardware implementations.
- 29 -Embedded Systems—State charts
Evaluation of StateCharts (2)
Cons:• Generated C programs frequently inefficient,• Not useful for distributed applications,• No program constructs,• No description of non-functional behavior,• No object-orientation,• No description of structural hierarchy.
Cons:• Generated C programs frequently inefficient,• Not useful for distributed applications,• No program constructs,• No description of non-functional behavior,• No object-orientation,• No description of structural hierarchy.
Extensions:• Module charts for description of structural hierarchy.
Extensions:• Module charts for description of structural hierarchy.