Title: Modelbased Design of Embedded Software
1Model-based Design of
Embedded Software
Tom Henzinger University of California,
Berkeley September 10, 2002
2Requirements
Verification
Model
Environment
Implementation
Platform
3Requirements
formal automatic (model
checking)
Verification
Model
Environment
Implementation
automatic (compilation)
Platform
4Requirements
Verification
Model
Environment
property preserving
Implementation
Platform
5Requirements
Verification
Composition
Model
Implementation
Platform
6Requirements
Verification
Composition
Model
Deep compositionality
Implementation
Platform
7Our Research Explores Four Principles
1. In modeling, smooth the "boolean edges" of a
system. 2. In composition, treat inputs and
outputs contra-variantly. 3. In verification,
abstract automatically and on-demand. 4. In
implementation, preserve fixed logical execution
times.
8The FLET (Fixed Logical Execution Time) Assumption
Software Task
write actuator output at time td, for fixed d
read sensor input at time t
9The FLET (Fixed Logical Execution Time) Assumption
Software Task
write actuator output at time td, for fixed d
dgt0 is the task's "logical execution time"
read sensor input at time t
10High-level Embedded Programming
The programmer specifies d to solve the control
problem at hand. The compiler ensures that d is
met on a given platform (hardware resources and
performance) otherwise it rejects the program.
11The FLET (Fixed Logical Execution Time) Assumption
time t
time td
possible physical execution on CPU
buffer output
12Contrast the FLET with Standard Practice
output as soon as ready
13Advantages of the FLET -predictable timing and
value behavior (environment determined programs
no race conditions, minimal
jitter) -portable, composable code (as long as
the platform offers sufficient
performance) Disadvantage of the FLET -tasks
don't always use latest available data (a small
price to pay, e.g. model helicopter)
14The E(mbedded) Machine a virtual machine that
executes tasks in real time under the FLET
assumption. Giotto a structured, time-triggered
language that can be compiled into E machine
code. (The E machine is more general it supports
also event-triggered and asynchronous code.)
15The Giotto Tool Chain
Simulink Model
S/G Translator
RTW Embedded Coder
Giotto Program for task timing and interaction
C Functions for tasks
Giotto Compiler
C Compiler
E Code
Platform Code
performance information
invokes
E Machine
Platform (minimal OS hardware)
16The Giotto Tool Chain
S/G Simulator
Simulink Model
S/G Translator
RTW Embedded Coder
Giotto Program for task timing and interaction
C Functions for tasks
Giotto Compiler
C Compiler
E Code
Platform Code
performance information
invokes
E Machine
guaranteed conformance
Platform (minimal OS hardware)
17Our Research Explores Four Principles
1. In modeling, smooth the "boolean edges" of a
system. 2. In composition, treat inputs and
outputs contra-variantly. 3. In verification,
abstract automatically and on-demand. 4. In
implementation, preserve fixed logical execution
times.
18The Problem
Hybrid Model
Property
19The Problem
Hybrid Model
Property
slightly perturbed model
20The Problem
Hybrid Automaton
Safe
x 3
21The Problem
Hybrid Automaton
Unsafe
x 3?
22A Possible Solution Metric on
Traces
Model
Property
instead of
Yes or No
consider
?-Variation
23A More Radical Solution
value(Model,Property) States ? Yes, No
value(Model,Property) States ? R
24Discounting the Future
value(Model,Property) States ? Yes,
No value(m,?T) ?X. (T ? pre(X))
discountedValue(Model,Property) States ?
R discountedValue(m,?T) ?X. max(T, ??pre(X))
discount factor 0lt?lt1
25Robustness Theorem If discountedBisimilarity(m1,m
2) gt 1 - ?,
then discountedValue(m1,p) - discountedValue(m2,p
) lt f(?).
26Robustness Theorem If discountedBisimilarity(m1,m
2) gt 1 - ?,
then discountedValue(m1,p) - discountedValue(m2,p
) lt f(?).
Further Advantages of Discounting -approximabili
ty because of geometric convergence (avoids
non-termination) -applies also to probabilistic
systems and to games (enables control)
27Our Research Explores Four Principles
1. In modeling, smooth the "boolean edges" of a
system. 2. In composition, treat inputs and
outputs contra-variantly. 3. In verification,
abstract automatically and on-demand. 4. In
implementation, preserve fixed logical execution
times.
28 In composition, treat inputs and outputs
contra-variantly.
This seems obvious The "type" of a component
should be Inputs ? Outputs not Inputs ?
Outputs. (These two are the same in set theory,
but not in type theory!)
29 In composition, treat inputs and outputs
contra-variantly.
Surprisingly, this is rather non-standard If
your notion of composition is intersection or
product, or your notion of refinement /
abstraction is simulation or language
containment, then you treat inputs and outputs
co-variantly (and are in good company).
30y
z
x
Input constraint not xy1
Output constraint none
31y
z
x
Input constraint not xy1
Output constraint none
Possible behaviors x y z 0 0 0 0 0 1
0 1 0 0 1 1 1 0 0 1 0 1
32Compose with yz, forgetting what is input, what
output.
y
z
x
Input constraint not xy1
Output constraint none
Possible behaviors x y z 0 0 0 0 0 1
0 1 0 0 1 1 1 0 0 1 0 1
33Compose with yz, constraining only output.
y
z
x
Input constraint not xy1
New output constraint zy
Possible behaviors x y z 0 0 0 0 0 1
0 1 0 0 1 1 1 0 0 1 0 1
34Compose with yz, constraining only inputs.
y
z
x
Output constraint none
Possible behaviors x y z 0 0 0 0 0 1
0 1 0 0 1 1 1 0 0 1 0 1
Input constraint not xy1
35Compose with yz, constraining only inputs.
y
z
x
New input constraint x0
Output constraint none
Possible behaviors x y z 0 0 0 0 0 1
0 1 0 0 1 1 1 0 0 1 0 1
36Traditional Behavioral Refinement
Simulation or Language Containment
SpecInputs
SpecOutputs
?
?
ImpOutputs
ImpInputs
37 Compositional Refinement
Implementations can be substituted for
Specifications
SpecInputs
SpecOutputs
?
?
ImpOutputs
ImpInputs
produce only legal outputs
accept all legal inputs
38We call a formalism with -input constraining
composition -compositional refinement an
interface theory. We have developed several
interface theories, e.g. for -message-passing
components ("interface automata")
-possibly recursive software modules (the
CHIC tool) -real-time components.
39CHIC ("Checking Interface Compatibility")
Specify input and output constraints as Java
class annotations -call graph constraints
(e.g., method Init_Obj does not cause indirectly
a recursive invocation of itself) -precondition
constraints (e.g., method Read_File is called
only after method Open_File) CHIC checks the
compatibility of constraints across class
definitions.
40Compatibility
Interface
Interface
CHIC
Compliance BLAST
Code
Code
41Our Research Explores Four Principles
1. In modeling, smooth the "boolean edges" of a
system. 2. In composition, treat inputs and
outputs contra-variantly. 3. In verification,
abstract automatically and on-demand. 4. In
implementation, preserve fixed logical execution
times.
42BLAST (The Berkeley Lazy Abstraction Software
Verification Tool)
C code that specifies a safety monitor
C source code
BLAST
Counterexample trace or Correctness certificate
43BLAST (The Berkeley Lazy Abstraction Software
Verification Tool)
Code
Build Predicate Abstraction
New Predicates of Interest
Model Check Abstraction
Concretize Counterexample
Abstract Counterexample
Correctness Certificate
Concrete Counterexample
44BLAST (The Berkeley Lazy Abstraction Software
Verification Tool)
Code
Locally Refine
Build Predicate Abstraction
Refined Parts of the Abstraction
New Predicates of Interest
Model Check Abstraction
Concretize Counterexample
Abstract Counterexample
Correctness Certificate
Concrete Counterexample
45BLAST (The Berkeley Lazy Abstraction Software
Verification Tool)
Currently 10s of 1000s lines of C code checked in
a few minutes.
Code
Locally Refine
Build Predicate Abstraction
Refined Parts of the Abstraction
New Predicates of Interest
Model Check Abstraction
Concretize Counterexample
Abstract Counterexample
Correctness Certificate
Concrete Counterexample
46Credits
Giotto and E Machine Ben Horowitz, Christoph
Kirsch, Slobodan Matic, Wolfgang Pree, Marco
Sanvido. Interfaces Arindam Chakrabarti, Luca
de Alfaro, Marcin Jurdzinski, Freddy Mang,
Marielle Stoelinga. Lazy Abstraction Ranjit
Jhala, Rupak Majumdar, George Necula, Gregoire
Sutre, Wes Weimer. Robust Hybrid Systems Luca de
Alfaro, Arkadeb Ghosal, Vinayak Prabhu, Marcin
Jurdzinski, Rupak Majumdar.