A Mystery Esterel small no type inference subtyping
A Mystery • Esterel – small • • • no type inference, subtyping, … no recursion, functions, … no pointers, malloc, GC, … no complex data structures, libraries, … … – formal semantics [Berry&Cosserat 84, Gonthier 88] well… no! ) compiling Esterel is easy
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 [Schneider 04] but: ) • for correct programs • for circuit synthesis • for non-optimized circuits • let’s check correctness • let’s think generic • let’s aim at
Why Loops? • Synchronous loops impact – correctness: – performance: instantaneous loops schizophrenia • Specify code generation for loops – check correctness – achieve performance – generic (independent from target language) – amenable to certification
A Key to Many Improvements • Compiler • Semantics – better understanding of determinism + errors • Language – new construct: higher expressivity + lower complexity • Proofs
Outline • Esterel – Synchronous Reactive Language – Syntax and Formal Semantics • Causality and Instantaneous Loops • Schizophrenia • Conclusion
Reactive Approach input output Eventdriven time • 0 -delay abstraction ) reactions • Clock-triggered ) instants inputs outputs time tick Reactiv e
Synchronous Concurrency • Parallel composition • Master clock • Instantaneous Asynchrono us Synchrono us – broadcast of signals – reaction to presence and absence of signals ) deterministic concurrency
Example • pause • local signal declaration • signal emission • test • loop • parallel composition • sequence
Syntax wait for the next tick (in the document)
Non-Reactive Programs • signals INCORRECT • loops INCORRECT
Operational Semantics
Inputs and Outputs
Sequence and Concurrency
Deduction Trees
Loops and Local Signals
Example: Present Signal
Outline • Esterel • Causality and Instantaneous Loops – Deterministic Semantics – Instantaneous Loop Detection • Schizophrenia • Conclusion
Instantaneous Loops - Causality
Instantaneous Loops - Causality Instantaneous Loop [Gonthier 88] Causality
Non-Determinism • INCORRECT
A Deterministic Semantics Logical [Berry 9 6] Deterministic Constructive Semantics 1 0 2 1 1 0 0 0
Determinism + Explicit Errors
Determinism + Explicit Errors
Determinism + Explicit Errors A better semantics – correct programs: unchanged – incorrect programs: more easily handled + error propagation – distinguishes causality errors and instantaneous loops
Instantaneous Loop Detection
Outline • Esterel • Causality and Instantaneous Loops • Schizophrenia – Example and Definition – Diagnosis and Cure • Conclusion
Schizophrenia Are these programs equivalent? [Berry 9 2] NO YES How shall we define, diagnose, and cure
Defining Schizophrenia * * 1 * 2
Diagnosing Schizophrenia
Curing Schizophrenia ) Recursively replicate loop bodies [Mignard 94]
Curing Schizophrenia )
Curing Schizophrenia ) Unfolding using non-instantaneous gotopause
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
Implementation initial size (statements) quadratic rewriting quasi-linear rewriting abro 14 18 14 P 18 28 86 58 tcint 403 725 418 wristwatch 432 833 439 atds 100 890 1372 990 7644 67680 8020 10286 566585 16867 cabine globalopt
Conclusion • Loops – Instantaneous Loop Detection (SAS’ 03) – Schizophrenia (MEMOCODE’ 04) • generic + efficient • Better Language – Deterministic Semantics – gotopause (SOS’ 04) (SLAP’ 04) • makes compiling Esterel much easier (because of schizophrenia) • makes compiling to Esterel much easier (ex: Sync. Charts [And 95]) • makes optimizations much easier (source-to-source PROOFS IMPLEMENTATION transformation)
Future Work • • Mechanize proofs Consider constructive causality Apply gotopause to more optimizations… Make gotopause available • Dynamic well-formedness? • Semantics of signals?
- Slides: 38