Introduction to synchronous programming langauges

  • 1,628 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,628
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
17
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • 1>Determinism : For a particular input sequence , always same output sequence will be produced. It uniquely define that particular output sequence. Suppose input sequence is I1,I2,I3 then output sequence must be O1,O2,O3 all the time. This makes system predictable. Therefore order of output is always preserved with respect to input. This makes system predictable. And hence easy to verify. 2>Time constraint : Must produce output within a given constraint .(Temporal constraints). 3>For safety critical systems logical correctness (system should work properly) and temporal correctness (produces output within a time) both are required. 4>Reliability: These system must be require reliability, because even a small bug can threat their reliability and leads to system failure. 5>Concurrency: complex system requires some sort of concurrency where different modules interact with each other to provide desired specification.
  • 1>Synchronous languages or formalism are based on synchrony hypothesis which states that reaction time of system is zero. It means that outputs are produced instantly with respect to inputs. Which is clearly unpractical. However synchronous language works fine provided it reacts sufficiently fast such that rate of inputs from environment is greater than computation to outputs. Here upper approximation of execution time can be known accuratly. In general languages computing worst case execution time is difficult due to constructs like loops etc. But these things never appeared in Synchronous programs. 2> Like Reaction time , communication time is also assumed to be instantaneous. Again not realistic , parallelism and communication are provided at the descriptive level of language, but in reality they are compiled into centralized sequential . Hence they do not explicitly provide parallelism and communication at execution time. In lustre parallelism is provided at logical level, if two statements are independent then parallelism is between them. But these parallel statements are converted to sequential code at compile time. This is done by node expansion. 3> Synchronous languages are easier to verify and specify than asynchronous languages. 4>Multiform time : here it is divided into logical discrete time. Computation is divided into non overlapping series of reactions. The only relevant notion is simultaneity and precedence between events. Physical time doesn't play any role like in ADA. Only order of events matters. System is divided into logical instant. Events occurred at same instant are simultaneous and those happen at different instants are ordered.
  • 1>Implementation: The main thing in implementing synchronous approach is to define step functions that will implement the behavior of an instant. The compilation of synchronous program may consist into expansion into flat automata. Finite state automata like mealy machine (deterministic) corresponds to the synchronous assumptions. In a given state by giving certain input it provides a certain order output and move to new state. 2> In synchronous programs outputs are synchronous to inputs. 3> how it handle concurrency with determinism . Idea is simple , concurrency is at logical level during compilation this concurrent ness is converted to sequential code leading the way to make the order preserved. Also no preemption . At compile time concurrency and communication are resolved.
  • 1>In lustre each variable ,constant denotes a flow. A program has cyclic behavior means at nth execution cycle of program all involved streams take nth values. 2> constants are those that have same value over entire clock cycles. 3>pointwise operator also called data operator and operates on operands sharing same clocks. 4> Temporal operators which can deal with operands of different clocks.
  • 1>Causality is the relationship between the event (cause) and event (effect) , where the effect is a consequence of cause. Means where output depends on past inputs but not on future inputs. A variable may not instantaneously depends on itself.means it depends on the previous values. Lustre allows execution of only acyclic equations. 2> Why causality in synchronous languages? Since compiler of synchronous languages like lustre doesnot give any sense to implicit definations like v = v+1; We find that W=E means W is identical to E. Here x doesnot depends on x. Values must be dependent on its previous value. Ex: x = not x ,it means how x is identical to not x. Therefore no solution of x for which this holds. X =X , it means X depends on its current value ,but it can’t be possible. It means if we want to find out the value of x at clock 5 , then it depends on value at clock 5 . It leads to non determinism. 3>Therefore cyclic equations are avoided in lustre and all. Only acyclic equations.
  • 1>Clock consistencies like y = x + (x when c) , here one stream is x and other is x when c, both belongs to different clocks , not same clock hence this statement is not possible. So require unbounded memory , which is not possible. (from xi to x2i+1 in our example). Clock consistency must be checked syntactically. 2> clock inconsistencies like x = a + (a when c) , since previous values can only be given by pre. 3>object code refers to the code after compilation of source code. 4> node expansion is required because we can’t compile single node independently. Because if it calls some other node then may be some condition like some sequence gets false only some are valid sequence. Ex: For a given node if it contains some other node directly on compilation of previous node we get X=a and y=b or y=b and x=a , but on expansion only the valid sequence is x=a and y=b , therefore we expand nodes.
  • 1>Synchronous observers are perform verification during the actual execution of program i.e runtime verification. 2>observer is written in the same language.
  • Synchronous languages are simple and can be defined by mathematical semantics. Since synchronous languages are not GPL therefore their compiler are easier to design. Compilers of SP are reliable and produce efficient code. Synchronous languages are SPL ,their compiler produces intermediate code . Then this code must be compiled by sequential classical language. How synchronous languages support determinism?
  • basic clock : variable occuring at all instants. Slower clocks can be obtained from basic clock by using when operator. Clock constraints: X = h +d ;clock(h) = clock(d) Y = e when s here clock of e is clock of s;
  • Continuous control can be verified through testing and validated through simulation. But for Discrete computation it requires Design verifier technique , it should not be tested because number of cases are so large that that it requires rigorous and time consuming testing. Environment specifications are required because otherwise it will take unrealistic values. If property is false then the generated counter example may be unrealistic.

Transcript

  • 1. Study of Lustre and Scade for Safety Critical Systems Presented By : Bharat Jain 09305029 Guided By : Prof Kavi Arya
  • 2. Contents
    • Introduction
    • Safety Critical Systems
    • Synchronous Languages
    • Lustre
      • Basics and constructs
      • Compilation
      • verification
    • Scade
      • Basics and constructs
      • Scade tools
    • Conclusion
    • Implementation
  • 3. Introduction
    • Problems related to Safety critical systems.
    • Choice of programming language for Safety critical system.
    • Why conventional languages are not used ?
    • Requires different class of language.
    • Synchronous languages.
  • 4. Safety critical system
    • Reactive systems (Deterministic, Time constraint, Concurrent, Reliable).
    • Systems whose failure leads to unacceptable consequences is Safety critical system.
    • Correctness and completeness
    • No bug
    • Ex : Traffic signal system, aircraft
  • 5. Chronology
    • Hardware implementation
    • Assembly language
    • Classical languages (C, PASCAL etc)
    • General purpose languages (ADA, Occam etc)
    • Synchronous languages like Lustre, Scade, Esterel, Signal, Argos etc
  • 6. Synchronous languages
    • Synchrony hypothesis
    • Multiform notion of time.
    • Global vision.
  • 7. Architecture of synchronous languages
    • Interactive (I/O) interface
    • header files
    • Reactive Kernel
    • synchronous language programs
    • Data management
    • host languages
    Reactive Kernel Interface Data management
  • 8. Lustre
  • 9.
    • Developed by P.Caspi and N.Halbwachs.
    • Synchronous, Declarative, Deterministic, Functional, Dataflow language.
    • Program is collection of nodes.
    • Flow (stream , clock)
    • Cyclic execution
    • Node contains Interface and Body.
  • 10.
    • Constants , variables.
    • Operators :
    • Point wise (arithmetic, relational etc)
    • Temporal (pre, ->, current, when)
    • Causality : no unique and deterministic meaning.
    • like x = not x (no solution)
    • x = x non deterministic
    • Assertions : assert (boolean-exp)
  • 11. Compilation
    • Causality check (like x = not x ; x = x etc) and clock checking (due to clock inconsistencies).
    • To generate sequential code , nodes are expanded called expanded code.
    • Sequential automata is generated and used as intermediate code called object code.
    • Translator to Sequential code in (C, ADA) languages.
  • 12.
    • Code generated in host language is partial.
    • No main program.
    • User has to write main program.
    • Main program contains :
      • Input procedures call;
      • Output procedures call;
  • 13. Verification
    • For checking correctness of system.
    • Two properties :
      • Liveness properties
      • Safety properties.
    • Lustre can be used to describe properties of system (Liveness properties).
    • Create its own temporal operator.
  • 14.
    • Safety properties are described by Synchronous Observer.
    • Property to be checked under assumption.
    • Synchronous Observer is a program contains program node ,safety properties and assertions.
    • If property satisfied then output is yes else no.
    • Lesar tool is used.
    • Advantages of this specification technique.
    Synchronous Observer
  • 15. Reusability and tuple
    • Nodes can be reused in other nodes.
    • Using include<node.lus>
    • Nodes have several outputs can be expressed in the form of tuple.
  • 16. SCADE (safety critical application development environment)
  • 17.
    • Commercial tool developed for designing Safety critical systems , product of Esterel Technologies.
    • Used in various application areas like Defense, Transportation, Energy etc.
    • Commercial applications include Euro copter, Airbus A380 etc.
    • Integrated development environment.
    • Scade tools are : Scade editor, scade simulator, DV, KCG etc.
  • 18.
    • It is Graphical, Deterministic, Dataflow, declarative language.
    • Scade is based on Synchronous and Dataflow model.
    • Operators in Scade :
    • Pointwise (arithmetic, relational etc)
    • Temporal (followed, pre, when etc)
    • Scade contains some advanced features not present in Lustre.
  • 19.
    • User can also define its own operators by using node or function.
    • Library operators from different libraries in Scade. Ex : to use operator like Has never been true.
    • Two computational parts :
    • Continuous control : Always computation (numerical algorithms etc) represented as data blocks.
    • Discrete control : Computation when condition satisfy (decision logic, modes etc) represented as state machines.
  • 20. Activation of operator
    • Activation of operator/node when needed.
    • Ex :
    • count = (activate counter every condition initial default(0))(reset,init,incr);
    • Here node is activated when condition is satisfied.
  • 21. Polymorphism
    • Scade provides a facility for generic nodes also called as polymorphic node.
    • Type is generalized.
    • Ex :
    • node sum (a, b :’T) returns (c :’T)
    • let
    • c=a + b;
    • tel;
  • 22. Design Verifier
    • Tool used for verification of system.
    • To verify safety properties, which would otherwise be tested.
    • Consist of property node (property to be satisfied) and Observer node (consist of property node and main node).
    • If property fail generate counter example.
    • Properties can be expressed in scade itself.
  • 23. KCG
    • Also called qualified code generation.
    • Scade to C code.
    • Code generated is sequential and simple (no loops, jump etc).
    • Code generated is qualified and hence no need to check its conversion.
    • Deterministic behavior is guaranteed.
  • 24. Conclusion
    • Synchronous code converted to efficient sequential code .
    • Automatic Code generated is a Subset C code (no loop, no jump).
    • The execution time is always bounded and make system Deterministic and predictable.
    • This make system easier to Verify.
    • Verification can be done easily by writing synchronous observer in the same language. Express specification in same language.
    • Temporal bugs can be find out easily.
  • 25. Implementation of Lustre on FirebirdV
    • Whiteline follower using Lustre.
    • Lustre code generated is translated into C code.
    • This C code is partial, no main program.
    • Main program
      • Initialize device
      • Input procedures
      • Output procedures
  • 26. White line sensors
    • Three whiteline sensors
    • Receives integer values. If less than 40 means whiteline
      • LEFT_WHITELINE_VALUE
      • MIDDLE_WHITELINE_VALUE
      • RIGHT_WHITELINE_VALUE
  • 27. Infrared Sensors
    • Three Infra red sensors
    • Integer values as inputs (i.e distance in terms of mm)
      • FRONT_IR
      • LEFT_IR
      • RIGHT_IR
  • 28. Stepper motor
    • Three type of movements are possible.
    • Take Boolean value.
      • MOVE_FWD
      • MOVE_LEFT
      • MOVE_RIGHT
  • 29. Code :
    • node firebird (FRONT_IR_VALUE :int) returns (LCD_DISPLAY_INT1 : int); let LCD_DISPLAY_INT1 =FRONT_IR_VALUE; tel;
  • 30. Refrences
    • N.Halbwachs, P.Caspi, P.Raymond. The Synchronous dataflow programming language LUSTRE.
    • W.J. Cullyer, S.J. Goodenough, B.A. Wichmann. The choice of languages for use in safety critical systems.
    • Gerard Berry. Real Time Programming : Special Purpose or General Purpose languages.
    • Nicolas Halbwachs. A Synchronous Language at Work: the story of Lustre.
    • Scade-Language-Suite. www.esterel technologies.com.
    • Andrew J. Kornecki. Automatic Code Generation:Model-Code Semantic Consistency.
  • 31.
    • Andrew J. Kornecki. Automatic Code Generation: Model-Code Semantic Consistency.
    • Florence Maraninchi, Yann Remond. Argos : An automaton based Synchronous Language.
    • Nicolas Halbwachs. Synchronous Programming of Reactive Systems.
    • Nicolas Halbwachs, Christophe Ratel. Programming and verifying real time system, by means of synchronous data flow language: Lustre
    • SYNALP. Synchronous Applications, Languages and Programs.
  • 32. Thank You