A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no...
-
date post
22-Dec-2015 -
Category
Documents
-
view
212 -
download
0
Transcript of A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no...
![Page 1: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/1.jpg)
![Page 2: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/2.jpg)
A Mystery
• Esterel– small
• no type inference, subtyping, …• no recursion, functions, …• no pointers, malloc, GC, …• no complex data structures, libraries, …• …
– formal semantics [Berry&Cosserat84,Gonthier88]
) compiling Esterel is easy well… no!
![Page 3: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/3.jpg)
Motivation
• Esterel– small kernel language + formal semantics– for embedded/real-time/safety-critical designs– compiled into C code, automata, digital circuits, VHDL…
• Mathematically certified compiler?– YES [Schneider04]
• for correct programs• for circuit synthesis• for non-optimized circuits
• let’s check correctness • let’s think generic• let’s aim at performance
)but:
![Page 4: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/4.jpg)
Why Loops?
• Synchronous loops impact– correctness: instantaneous loops– performance: schizophrenia
• Specify code generation for loops
– check correctness– achieve performance – generic (independent from target language)– amenable to certification
![Page 5: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/5.jpg)
A Key to Many Improvements
• Compiler
• Semantics– better understanding of determinism + errors
• Language– new construct: higher expressivity + lower complexity
• Proofs– easier proofs + collection of proof techniques
![Page 6: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/6.jpg)
Outline
• Esterel– Synchronous Reactive Language– Syntax and Formal Semantics
• Causality and Instantaneous Loops
• Schizophrenia
• Conclusion
![Page 7: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/7.jpg)
Reactive Approach
• 0-delay abstraction ) reactions
• Clock-triggered ) instants
time
input input inputoutput output outputinput Event-driven
tick tick tick tick
time
inputs inputs inputs inputsoutputs outputs outputs outputs
Reactive
![Page 8: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/8.jpg)
Synchronous Concurrency
• Parallel composition
• Master clock
• Instantaneous– broadcast of signals– reaction to presence and absence of signals
) deterministic concurrency
Asynchronous
Synchronous
![Page 9: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/9.jpg)
Example
• pause • local signal declaration• signal emission• test• loop• parallel composition• sequence
![Page 10: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/10.jpg)
Syntax
(in the document)
wait for the next tick
![Page 11: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/11.jpg)
Non-Reactive Programs
• signals
• loops
INCORRECT
INCORRECT
![Page 12: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/12.jpg)
Operational Semantics
![Page 13: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/13.jpg)
Inputs and Outputs
![Page 14: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/14.jpg)
Sequence and Concurrency
![Page 15: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/15.jpg)
Deduction Trees
![Page 16: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/16.jpg)
Loops and Local Signals
![Page 17: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/17.jpg)
Example: Present Signal
![Page 18: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/18.jpg)
Outline
• Esterel
• Causality and Instantaneous Loops– Deterministic Semantics– Instantaneous Loop Detection
• Schizophrenia
• Conclusion
![Page 19: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/19.jpg)
Instantaneous Loops - Causality
![Page 20: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/20.jpg)
Instantaneous Loops - Causality
Causality
Instantaneous Loop [Gonthier88]
![Page 21: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/21.jpg)
Non-Determinism
•
INCORRECT
![Page 22: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/22.jpg)
22
A Deterministic Semantics
Deterministic
Semantics
Logical
Semantics
1
0
1
1
0
0
1
Constructive
Semantics
0
1
0
0
[Berry96]
![Page 23: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/23.jpg)
Determinism + Explicit Errors
![Page 24: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/24.jpg)
Determinism + Explicit Errors
![Page 25: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/25.jpg)
Determinism + Explicit Errors
+ error propagation
A better semantics– correct programs: unchanged– incorrect programs: more easily handled– distinguishes causality errors and instantaneous loops
![Page 26: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/26.jpg)
Instantaneous Loop Detection
![Page 27: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/27.jpg)
Outline
• Esterel
• Causality and Instantaneous Loops
• Schizophrenia– Example and Definition– Diagnosis and Cure
• Conclusion
![Page 28: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/28.jpg)
Schizophrenia
Are these programs equivalent? NO
How shall we define, diagnose, and cure schizophrenia?YES
[Berry92]
![Page 29: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/29.jpg)
Defining Schizophrenia
1 2
*
*
*
![Page 30: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/30.jpg)
Diagnosing Schizophrenia
![Page 31: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/31.jpg)
Curing Schizophrenia
)
Recursively replicate loop bodies [Mignard94]
![Page 32: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/32.jpg)
Curing Schizophrenia
)
![Page 33: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/33.jpg)
Curing Schizophrenia
)
Unfolding using non-instantaneous gotopause
![Page 34: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/34.jpg)
And then…
• Extend Esterel with “gotopause”
• Specify the cure– proving it preserves the semantics– proving it cures schizophrenia
• Combine diagnosis and cure– to achieve performance
• Extend the algorithm to full Esterel
![Page 35: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/35.jpg)
Implementation
initial size
(statements)
quadratic
rewriting
quasi-linear
rewriting
abro 14 18 14
P18 28 86 58
tcint 403 725 418
wristwatch 432 833 439
atds100 890 1372 990
cabine 7644 67680 8020
globalopt 10286 566585 16867
![Page 36: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/36.jpg)
Conclusion
• Loops– Instantaneous Loop Detection– Schizophrenia
• generic + efficient
• Better Language– Deterministic Semantics– gotopause
• makes compiling Esterel much easier (because of schizophrenia)• makes compiling to Esterel much easier (ex: SyncCharts [And95])• makes optimizations much easier (source-to-source transformation)
(SAS’03)
(MEMOCODE’04)
(SOS’04)
(SLAP’04)
PROOFS IMPLEMENTATION
![Page 37: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/37.jpg)
Future Work
• Mechanize proofs• Consider constructive causality• Apply gotopause to more optimizations…• Make gotopause available
• Dynamic well-formedness?• Semantics of signals?
![Page 38: A Mystery Esterel –small no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries,](https://reader038.fdocuments.us/reader038/viewer/2022110323/56649d805503460f94a643a9/html5/thumbnails/38.jpg)