49
02917: Advanced Topics in Embedded Systems Martin Fr ¨ anzle Andreas Eggers Carl von Ossietzky Universit ¨ at Dpt. of Computing Science Res. Group Hybrid Systems Oldenburg, Germany 02917: Introduction – p.1/49

02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Embed Size (px)

Citation preview

Page 1: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

02917: Advanced Topicsin Embedded Systems

Martin Franzle

Andreas Eggers

Carl von Ossietzky Universitat

Dpt. of Computing Science

Res. Group Hybrid Systems

Oldenburg, Germany

02917: Introduction – p.1/49

Page 2: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Multiple viewpoints

Requirements

analysis

Programming

"How?"

Algorithmics

"What?"

Aspects

Requirements

analysis

Programming

"How?"

Algorithmics

"What?"

Aspects

Consistent?

Requirements

analysis

Programming

"How?"

Algorithmics

"What?"

Aspects

Consistent?

"Consistent?"

Tests & proofs

Validation / verification

02917: Introduction – p.2/49

Page 3: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Formal Methods

• Formal methods are mathematically-based techniques for the

specification, development and verification of software and

hardware systems. [R.W. Butler, 2001]

• Motivated by the expectation that appropriate mathematical

analyses can contribute to the reliability and robustness of a

design. [M. Holloway, 1997]

• Alternative to less exhaustive analyses:

02917: Introduction – p.3/49

Page 4: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Embedded computer systems

Cogito,ergo sum!

Estimates for number of embedded systems in current

use exceed 1010.

[Rammig 2000, Motorola 2001]

02917: Introduction – p.4/49

Page 5: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Application domains

• Consumer & household products:CD players, TV sets, handheld games, electronic pets, cameras, alarmclocks, remote controls, dishwashers, microwave ovens, ...

• Office, telecommunications, etc.:Printers, network controllers, mobile phones, keyboards, CRTs andflatscreens, ...

• Environmental control:λ control, programmable heating systems, exhaust control, ...

• Traffic systems and traffic management:

Cars (body, powertrain, suspension, brakes), signalling devices, balises,

interlocks, autopilots, traffic information, ...

• Medicine:Measurement devices (thermometers, RR’s, X-ray, sonographic imaging,

EEG, ECG ...), treatment devices (perfusors, respirators, microwaveradiation treatment, ...)

• Supplies:Power plants, distribution networks, ...

02917: Introduction – p.5/49

Page 6: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

The roles, they are a changing...

Phase 1: Added value through add-on functionality:• automatic climate control,

• adaptive power steering,

• keyless entry,

• navigation system.

Phase 2: Integration into/hooking onto vital safety components:• anti-locking brake,

• electronic stability control,

• electric power steering,

• electronically variable transmission ratio of steering column.

Phase 3: Replacement of vital safety components:• steer-by-wire,

• brake-by-wire,

• driver-less go (automatic parking, autonomous lane change, . . .).

02917: Introduction – p.6/49

Page 7: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

A little mishap...

Source of problem:

• Car geometry:

- center of gravity

- wheelbase

• Reduced component-count axles

Solution:

• Patched with embed-ded control (“ESP”)

How to validate the patch?

02917: Introduction – p.7/49

Page 8: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Continuity?

Around 1999, the car industry fought for a unification of European

and American crash test scenarios because

“it is hardly possible to adjust the firing delay of the airbag to

both the ECE and the NCAP frontal crash.”

ECE test: 56km

h,

NCAP test: 64km

h.

02917: Introduction – p.8/49

Page 9: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

A Suggestion: Formal Methods

The term refers to a broad set of notations and tools for

1. Mathematically rigorous documentation of requirements• less ambiguous than prose

• amenable to formal analysis (check for consistency, check foradherence to well-formedness criteria,...)

2. Mathematically rigorous models of designs• rigorous semantics, removes ambiguity of design documentation in

prose, albeit only wrt. the viewpoint focused at

• early availability of abstract, yet concise model of the system underdesign

• amenable to formal analysis (check for absence of design flaws, like

deadlock, wrong interfaces,...; check for side-conditions of design

steps,...)

3. Check of consistency between such• correctness of a design relative to requirements

• replacability of a design by another one

02917: Introduction – p.9/49

Page 10: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

State-Based Models

02917: Introduction – p.10/49

Page 11: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Open (contin. time & state) dynamical system

stateobservable

internal state

environmental

influence

disturbances ("noise")

controlSystem boundary

System

• Time is continuous: R≥0,

• internal state is a bunch of real-valued (or complex-val ued)

functions of time: ~x(.) : Time → Rn,

• observable state is a time-invariant function (usually projection)

thereof,

• environment influence is a bunch of real-valued (or

complex-valued) functions of time: ~u(.) : Time → Rm.

02917: Introduction – p.11/49

Page 12: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Some state-based models

• Finite automata

• discrete state space, finitely many states

• evolution through discrete transitions

• Differential equations

• continuous state space

• continuous flows

• Hybrid systems

• continuous and discrete state components

• both jumps (= discrete transitions) and continuous flows

02917: Introduction – p.12/49

Page 13: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

State-based models:

Finite Automata

02917: Introduction – p.13/49

Page 14: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Finite-state models

arise naturally in

• descriptions of hardware components,

• because these are computational devices with finite (though sometimes

large...) memory,

• descriptions of communication protocols,

• because these engage into an alternation of finitely many different

phases,

• descriptions of embedded computer systems,

• because these are computers with finite memory.

02917: Introduction – p.14/49

Page 15: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

The coffee vending machine — architecture

Vending machine

cout

Financial

administr.

Brewer

control

caf

canccoin req

02917: Introduction – p.15/49

Page 16: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

The coffee vending machine — dynamics

brewidle wait

no payno pay

(*, *, *, req, −caf)(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid(cin, *, −cout, *, *)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

02917: Introduction – p.16/49

Page 17: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

An example run

brewidle wait

no payno pay

(*, *, *, req, −caf)(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid(cin, *, −cout, *, *)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, −canc, −cout, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, canc, *, −req, −caf)

Brewer control

paid

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, −cout, *, caf)

(*, *, *, *, caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

02917: Introduction – p.17/49

Page 18: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

The coffee vending machine

Product automaton: Financial admin. * Brewer ctrl.

(*, −canc, −cout, req, −caf)

no pay no pay no pay

paid paid paid

(*, −canc, −cout, −req, −caf)

(−cin, *, −cout, *, caf)

(−cin, *, −cout, req, −caf)

(−cin, −canc, −cout, −req, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(−cin, *, −cout, *, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −

caf)

(cin, *, −cout, *, −

caf)

(*, *, −cout, *, caf)

brew

idle wait brew

idle wait(−cin, canc, −cout, −req, −caf)

(*, c

anc, co

ut, re

q, −ca

f)

Product automaton: Financial admin. * Brewer ctrl.

(*, −canc, −cout, req, −caf)

no pay no pay no pay

paid paid paid

(*, −canc, −cout, −req, −caf)

(−cin, *, −cout, *, caf)

(−cin, *, −cout, req, −caf)

(−cin, −canc, −cout, −req, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(−cin, *, −cout, *, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −

caf)

(cin, *, −cout, *, −

caf)

(*, *, −cout, *, caf)

brew

idle wait brew

idle wait(−cin, canc, −cout, −req, −caf)

(*, c

anc, co

ut, re

q, −ca

f)

Unreachable states!

Product automaton: Financial admin. * Brewer ctrl.

(*, −canc, −cout, req, −caf)

no pay no pay no pay

paid paid paid

(*, −canc, −cout, −req, −caf)

(−cin, *, −cout, req, −caf)

(−cin, −canc, −cout, −req, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(−cin, *, −cout, *, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −

caf)

(*, *, −cout, *, caf)

brew

idle wait brew

idle wait(−cin, canc, −cout, −req, −caf)

(cin, *, −cout, *, −

caf)

(*, c

anc, co

ut, re

q, −ca

f)

(−cin, *, −cout, *, caf)

Free coffee!

02917: Introduction – p.18/49

Page 19: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Embedded systems in-the-large

Would you like to draw the automaton?

02917: Introduction – p.19/49

Page 20: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

State-based models:

Differential equations

02917: Introduction – p.20/49

Page 21: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Open (contin. time & state) dynamical system

stateobservable

internal state

environmental

influence

disturbances ("noise")

controlSystem boundary

System

• Time is continuous: R≥0,

• internal state is a bunch of real-valued (or complex-valued)

functions of time: ~x(.) : Time → Rn,

• observable state is a time-invariant function (usually projection)

thereof,

• environment influence is a bunch of real-valued (or

complex-valued) functions of time: ~u(.) : Time → Rm.

02917: Introduction – p.21/49

Page 22: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Continuous modeling with DEs

1. Add further, derived state components: the derivatives~·x(.),

~··x(.), . . . of the state components.

2. Formulate dynamics as equations between~·x(.),

~··x(.), ~u(.), . . .

N.B. Higher-order derivatives x(n), n > 1, can always be removed by

1. adding a fresh state variable y(.),

2. adding the equation y(t) = x(n)(t),

3. replacing every occurrence of x(n+1) by·y.

02917: Introduction – p.22/49

Page 23: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Differential equation w/o input / disturbance

The DE describes dynamics of the system by

• providing a state space Rn,

• providing a (piecewise) continuous vector field f : Rn → R

n

constraining the possible evolutions through the equation

dx

dt= f(x)

The initial value x0 ∈ Rn defines the start state of the dynamic

evolution.

A solution in the sense of Carathéodory is a time-dependent signal

x : [0, a) → Rn such that

• x is piecewise differentiable,

• ∀t ∈ [0, a) • x(t) = x0 +∫t

0f(x(s))ds.

Then dx

dt(t) = f(x(t)) for almost all t ∈ [0, a).

02917: Introduction – p.23/49

Page 24: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Differential equation with input

The DE describes dynamics of the system by

• providing a state space Rn,

• providing an input space Rm,

• providing a (piecewise) contin. vector field f : Rn+m → R

n

constraining the possible evolutions through the equation

dx

dt= f(x, u)

The initial value x0 ∈ Rn defines the start state of the dynamic

evolution.

A solution wrt. a (piecewise) continuous input u : [0, a) → Rm is a

time-dependent signal x : [0, a) → Rn such that

• x is piecewise differentiable,

• ∀t ∈ [0, a) • x(t) = x0 +∫t

0f(x(s), u(s))ds.

Then dx

dt(t) = f(x(t), u(t)) for almost all t ∈ [0, a).

02917: Introduction – p.24/49

Page 25: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Example: spring-mass system w. disturbance

! ! ! !

! ! ! !

! ! ! !m

" " " " " " " " " "

" " " " " " " " " "

" " " " " " " " " "

# # # # # # # # # #

# # # # # # # # # #

# # # # # # # # # #

u(t)

y(t)

• Basic model:··y (t) =

F(t)

m

F(t) = k (l(t) − l0)

l(t) = u(t) − y(t)

• Replace higher-order derivatives:

Add v(t) =·y (t).

Gives·y (t) = v(t)·v (t) = k

m(u(t) − y(t) − l0)

02917: Introduction – p.25/49

Page 26: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

State-based modeling:

Hybrid systems

02917: Introduction – p.26/49

Page 27: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Hybrid Systems

1

Plant

ControlAnalogswitch

Continuouscontrollers

D/A

Discretesupervisor

A/D

Plant

observablestate

environmental

influence

disturbances ("noise")

control

selection

setpoints

active control law

setpointspart ofobservablestate

task selection

2

02917: Introduction – p.27/49

Page 28: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Hybrid Automata

ball is moving down

ball is moving up

vertical position of the ball

velocity

−10

0

−20

10

0 5 10 15 20

20

y

x

x= y

x ≥ 0

y= −9.81

x = 0.0 ∧ y ≤ 0.0 /

y ′= −0.8 · y

x = 20.0 ∧ y = 0.0

y < 0

y > 0

x :

y :

ball is moving down

ball is moving up

vertical position of the ball

velocity

−10

0

−20

10

0 5 10 15 20

20

y

x

y < 0

y > 0

x :

y :

x= y

x ≥ 0

y= −9.81

x = 0.0 ∧ y ≤ 0.0 /

y ′= −0.8 · y

x = 20.0 ∧ y = 0.0

ball is moving down

ball is moving up

vertical position of the ball

velocity

−10

0

−20

10

0 5 10 15 20

20

y

x

y < 0

y > 0

x :

y :

x= y

x ≥ 0

y= −9.81

x = 0.0 ∧ y ≤ 0.0 /

y ′= −0.8 · y

x = 20.0 ∧ y = 0.0

ball is moving down

ball is moving up

vertical position of the ball

velocity

−10

0

−20

10

0 5 10 15 20

20

y

x

y < 0

y > 0

x :

y :

x= y

x ≥ 0

y= −9.81

x = 0.0 ∧ y ≤ 0.0 /

y ′= −0.8 · y

x = 20.0 ∧ y = 0.0

ball is moving down

ball is moving up

vertical position of the ball

velocity

−10

0

−20

10

0 5 10 15 20

20

y

x

y < 0

y > 0

x :

y :

x= y

x ≥ 0

y= −9.81

x = 0.0 ∧ y ≤ 0.0 /

y ′= −0.8 · y

x = 20.0 ∧ y = 0.0

ball is moving down

ball is moving up

vertical position of the ball

velocity

−10

0

−20

10

0 5 10 15 20

20

y

x

y < 0

y > 0

x :

y :

x= y

x ≥ 0

y= −9.81

x = 0.0 ∧ y ≤ 0.0 /

y ′= −0.8 · y

x = 20.0 ∧ y = 0.0

ball is moving down

ball is moving up

vertical position of the ball

velocity

−10

0

−20

10

0 5 10 15 20

20

y

x

y < 0

y > 0

x :

y :

x= y

x ≥ 0

y= −9.81

x = 0.0 ∧ y ≤ 0.0 /

y ′= −0.8 · y

x = 20.0 ∧ y = 0.0

ball is moving down

ball is moving up

vertical position of the ball

velocity

−10

0

−20

10

0 5 10 15 20

20

y

x

y < 0

y > 0

x :

y :

x= y

x ≥ 0

y= −9.81

x = 0.0 ∧ y ≤ 0.0 /

y ′= −0.8 · y

x = 20.0 ∧ y = 0.0

ball is moving down

ball is moving up

vertical position of the ball

velocity

−10

0

−20

10

0 5 10 15 20

20

y

x

y < 0

y > 0

x :

y :

x= y

x ≥ 0

y= −9.81

x = 0.0 ∧ y ≤ 0.0 /

y ′= −0.8 · y

x = 20.0 ∧ y = 0.0

02917: Introduction – p.28/49

Page 29: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

State and Dimension Explosion

Number of continuous variables linear in num-ber of cars

• Positions, speeds, accelerations,• torque, slip, ...

Number of discrete states exponential in num-ber of cars

• Operational modes, control modes,• state of communication subsystem, ...

Symmetry reduction often impossible

• Latency in ctrl. loop depends on numberof cars due to communication subsystem.

• Hidden channels due to coupled dynam-ics.

• Need a scalable approach• Trying to achieve this through strictly symbolic methods.

02917: Introduction – p.29/49

Page 30: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Semantic Modeling of ES

“Embedded Systems are Predicates”

( c©E. Hehner)

02917: Introduction – p.30/49

Page 31: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Symbolic transition system

Given a predicate language L, a symbolic transition system STS over

L comprises

• a set V of variable names belonging to L,

plus a sort-preserving renaming operation . ′ assigning to each

variable in V a “copy” v ′ 6∈ V ,

• an initialization predicate I ∈ L with free (I) ⊆ V ,

• a (symbolic or predicative) transition relation T ∈ L with

free (T) ⊆ V ∪ V ′.

A run of symb. trans. sys. STS is a (finite or infinite) sequence

r = 〈σ1, σ2, σ3, . . .〉 of L-interpretations such that

Initiation: σ1 |= I and

Consecution: σi,i+1 |= T for each i < len(r), where

σi,i+1(x) =

{σi(x) iff x 6∈ V ′

σi+1(x) iff x ∈ V ′

02917: Introduction – p.31/49

Page 32: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Parallel composition

Assume STS1 = (V1, I1, T1) and STS2 = (V2, I2, T2)

• control (i.e., constrain v ′) a subset Outi ⊂ Vi of variables,

• leave the remaining variables unconstrained.

Synchronous execution: If Out1 ∩Out2 = ∅ then

STS‖ = (V1 ∪ V2, I1 ∧ I2, T1 ∧ T2)

yields step-synchronous parallel execution.

Asynchronous execution:

STS‖ = (V1∪V2, I1∧I2, (T1 ∧∧

v∈O2\O1

v ′ = v

︸ ︷︷ ︸framing

) ∨ (T2 ∧∧

v∈O1\O2

v ′ = v

︸ ︷︷ ︸framing

))

yields (non-fair) interleaving.02917: Introduction – p.32/49

Page 33: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Symbolic Representation: Principle

A: A:

σσ

x= 10 ∧ x = 0 ∧ y =

y

2− 1

x = 0 ∧ y = 0

∃∆t.

x =↼

x +∆t

y =↼

y +∆t

x ≤ 10

x := 0, y := 0

dydt

= 1

x = 10 → x := 0, y :=y2− 1

dxdt

= 1

x ≤ 10

• symbolic representation of linear size• provided ODEs are of appropriate kind.

02917: Introduction – p.33/49

Page 34: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Generalizing the concept: Simulink+Stateflow

02917: Introduction – p.34/49

Page 35: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

‘Algebraic’ blocks

outputinputf

• time-invariant transfer function output(t) = f (input(t))

• made 1st-order by making time implicit: Flow ≡ output = f (input)

• no constraints on initial value: Init ≡ true,

• discontinuous jumps always admissible Jump ≡ true,

All the formulae are elements of a suitably rich

1st-order logics over R.

02917: Introduction – p.35/49

Page 36: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Integrators

outputinput 1/s

init

• integrates its input over time: output(t) = init +∫t

0input(u) du.

• made semi-1st-order by using derivatives: Flow ≡ doutput

dt= input

• initial value is rest value: Init ≡ output = init,

• discontinuous jumps don’t affect output Jump ≡ output =↼

output,

02917: Introduction – p.36/49

Page 37: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Getting started with STS: NuSMV

02917: Introduction – p.37/49

Page 38: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Model checking

Device Specification

Device Descript.

architecture behaviour

of processor is

process fetch

if halt=0 then

if mem_wait=0 then

nextins <= dport

...

Model Checker

♦(π ⇐ φ)

Hello world

This is DeDuCe V 1.4

Give me your design

Approval/

Counterexample

02917: Introduction – p.38/49

Page 39: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

NuSMV

• NuSMV (A. Cimmati, E. Clarke, F. Giunchiglia, A. Morichetti, M.

Roveri et al.) is an optimized reengineering of the symbolic

model checker SMV (K. McMillan, 1993)

• It is dedicated to finite state systems, providing

• Booleans, bounded integers, enumerations as data types.

• It has a structured, symbolic language for describing initial state

sets and transitions:

• either declarative

TRANS

next(output) = !input;

where totality of the transition relation has to be guaranteed

by the user, or• “imperative” (single assignment!) providing such guarantee

ASSIGN

next(output) := !input;

02917: Introduction – p.39/49

Page 40: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

The imperative syntax

An inverter taking one step delay:

MODULE main

VAR

input : boolean;

output : boolean;

ASSIGN

init(output) := 0;

next(output) := !input;

Note that input is unconstrained!

02917: Introduction – p.40/49

Page 41: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

The imperative syntax

An inverter taking arbitrary delay (and missing transient inputs):

MODULE main

VAR

input : boolean;

output : boolean;

ASSIGN

init(output) := 0;

next(output) := (!input) union output;

Note that output has a non-deterministic assignment!

02917: Introduction – p.41/49

Page 42: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

The imperative syntax

MODULE inverter(input)

VAR

output : boolean;

ASSIGN

init(output) := 0;

next(output) := !input;

MODULE main

VAR

gate1 : inverter(gate3.output);

gate2 : inverter(gate1.output);

gate3 : inverter(gate2.output);

This is synchronous execution, while...

02917: Introduction – p.42/49

Page 43: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

The imperative syntax

MODULE inverter(input)

VAR

output : boolean;

ASSIGN

init(output) := 0;

next(output) := !input;

MODULE main

VAR

gate1 : process inverter(gate3.output);

gate2 : process inverter(gate1.output);

gate3 : process inverter(gate2.output);

this is asynchronous execution, and...

02917: Introduction – p.43/49

Page 44: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

The imperative syntax

MODULE inverter(input)

VAR

output : boolean;

ASSIGN

init(output) := 0;

next(output) := !input;

FAIRNESS

running;

MODULE main

VAR

gate1 : process inverter(gate3.output);

gate2 : process inverter(gate1.output);

gate3 : process inverter(gate2.output);

is fair asynchronous execution.02917: Introduction – p.44/49

Page 45: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Rules governing the “imperative” fragment

In order to ensure totlity of the transition relation, there is a

single assignment rule: For each variable, there is at most one

assignment (which may contain case distictions).

next(abr) :=

case forget = 0 : ab;

forget = 1 : abr;

esac;

Note that assignments to both v and next(v) do also constitute

multiple assignments to v!

non-circular dependencies rule: Circular dependencies are to be

broken by “delays”, i.e. a variable may only depend on older

values of itself.

02917: Introduction – p.45/49

Page 46: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Specification patterns for the exercises

You’ll need the following types of CTL (computation tree logic

formulae):

φ holds invariably: AGφ

• On all computation paths, φ holds generally.

φ leads toψ: AG (φ->AFψ)

• On all computation paths, it holds generally that if φ holds

then necessarily (= on all computation paths), ψ holds

eventually.

Tutorial available at

http://nusmv.irst.itc.it/NuSMV/tutorial/v24/tutorial.pdf

02917: Introduction – p.46/49

Page 47: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Course Schedule

(this week)

02917: Introduction – p.47/49

Page 48: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Schedule

4 Slots a day, 2 in the morning, 2 in the afternoon.

Monday:

1. Introductory lecture

2.+3. Exercise class: State-exploratory verification using NuSMV

4. Lecture: CTL and CTL model checking

Tuesday: public holiday

Wednesday:

1. Lecture: Checking Circuit Equivalence

2.+3. Exercise lass: dito

4. Lecture: Satisfiability solving of large propositional formulae

02917: Introduction – p.48/49

Page 49: 02917: Advanced Topics in Embedded Systems · 02917: Advanced Topics in Embedded Systems ... suspension, brakes), signalling devices, balises, ... yet concise model of the system

Schedule (cntd.)

Thursday:

1. Lecture: Arithmetic satisfiability solving

2.+3. Exercise class: Using arith. SAT solving for scheduling

4. Lecture: Symbolic reachability procedures

Friday:

1. Lecture: Hybrid state-space exploration I

2. Exercise class: Introduction to the projects,

time to continue with previous exercises

3. Lecture: Hybrid state-space exploration II

4. Consultation time regarding projects

02917: Introduction – p.49/49