380 likes | 615 Views
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!. Motivation. Esterel
E N D
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!
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:
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
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
Outline • Esterel • Synchronous Reactive Language • Syntax and Formal Semantics • Causality and Instantaneous Loops • Schizophrenia • Conclusion
inputs inputs outputs outputs inputs outputs inputs outputs time Reactive tick tick tick tick Reactive Approach • 0-delay abstraction ) reactions • Clock-triggered ) instants input output input input output input output Event-driven time
Asynchronous Synchronous Synchronous Concurrency • Parallel composition • Master clock • Instantaneous • 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 • loops INCORRECT INCORRECT
Outline • Esterel • Causality and Instantaneous Loops • Deterministic Semantics • Instantaneous Loop Detection • Schizophrenia • Conclusion
Instantaneous Loops - Causality [Gonthier88] Instantaneous Loop Causality
Non-Determinism INCORRECT
A Deterministic Semantics [Berry96] Logical Semantics Deterministic Semantics Constructive Semantics 1 1 1 0 0 0 2 2 0 0 1 1 0
Determinism + Explicit Errors A better semantics • correct programs: unchanged • incorrect programs: more easily handled • distinguishes causality errors and instantaneous loops + error propagation
Outline • Esterel • Causality and Instantaneous Loops • Schizophrenia • Example and Definition • Diagnosis and Cure • Conclusion
Schizophrenia [Berry92] Are these programs equivalent? NO YES How shall we define, diagnose, and cure schizophrenia?
Defining Schizophrenia * * * 2 1
Curing Schizophrenia ) Recursively replicate loop bodies [Mignard94]
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
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) Conclusion (SAS’03) (MEMOCODE’04) (SOS’04) (SLAP’04) PROOFS IMPLEMENTATION
Future Work • Mechanize proofs • Consider constructive causality • Apply gotopause to more optimizations… • Make gotopause available • Dynamic well-formedness? • Semantics of signals?