//img.uscri.be/pth/8af21422bc87fb911481eaa9e300139de33e7552
Cet ouvrage fait partie de la bibliothèque YouScribe
Obtenez un accès à la bibliothèque pour le lire en ligne
En savoir plus

Lucid Synchrone Release version

De
84 pages
Lucid Synchrone Release, version 3.0 Tutorial and Reference Manual Marc Pouzet April 2006 $Id: manual.tex,v 1.11 2007/01/08 17:58:09 pouzet Exp $

  • initial state

  • strong preemption

  • multi-clock systems

  • pattern matching over

  • pattern matching

  • higher- order features

  • state machines

  • functions


Voir plus Voir moins
Lucid Synchrone Release, version 3.0
Tutorial
and
Reference
Marc Pouzet April 2006
$Id: manual.tex,v 1.11 2007/01/08 17:58:09 pouzet Exp $
Manual
Contents
I
Lucid Synchrone
1 An introduction to Lucid Synchrone 1.1 The core language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.1 Point-wise Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2 Delays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . 1.1.3 Global declarations. . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1.1.4 Combinatorial Functions. . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.5 Sequential Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.6 Anonymous Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.7 Local definitions and Mutually Recursive Definition. . . . . . . . . . 1.1.8 Shared Memory and Initialization. . . . . . . . . . . . . . . . . . . . 1.1.9 Causality check. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.10 Initialization check. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Multi-clock systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1.2.1 Sampling: the operatorwhen. . . . . . . . . . . . . . . . . . . . . . . 1.2.2 Combining Sampled Streams: the operatormerge. . . . . . . . . . . . 1.2.3 Oversampling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.4 Clock constraints and error messages. . . . . . . . . . . . . . . . . . . 1.2.5 Equality and scope restrictions in the use of clocks. . . . . . . . . . . 1.3 Static Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . 1.4 Data-types, Pattern matching. . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.1 Type definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.2 Pattern matching. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.3 Local Definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.4 Implicit Definition of Shared Variables. . . . . . . . . . . . . . . . . . 1.5 Valued Signals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.1 Signals as Clock Abstraction. . . . . . . . . . . . . . . . . . . . . . . 1.5.2 Testing the Presence and Signal Matching. . . . . . . . . . . . . . . . 1.6 State Machines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . 1.6.1 Strong Preemption. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.6.2 Weak Preemption. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.6.3 ABRO and Modular Reseting. . . . . . . . . . . . . . . . . . . . . . . 1.6.4 Local Definitions in a State. . . . . . . . . . . . . . . . . . . . . . . . 1.6.5 Communication between States and Shared Memory. . . . . . . . . . 1.6.6 The Particular Role of the Initial State. . . . . . . . . . . . . . . . . 1.6.7 Resume a Local State. . . . . . . . . . . . . . . . . . . . . . . . . . .
3
9
11 11 11 12 12 13 14 16 16
17 18 19
19 19 21 22 25 26
27 28
28 28 31 31 32 32 32
34 35 35 36
37 39
39 41
1.7 Parameterized State Machines. . . . . . . . . . . . . . . . . . . . . . . . . . . 1.8 State Machines and Signals. . . . . . . . . . . . . . . . . . . . . . . . . . .. 1.8.1 Pattern Matching over Signals. . . . . . . . . . . . . . . . . . . . . . 1.8.2 The derived operatorawait/do. . . . . . . . . . . . . . . . . . . . .. 1.9 Alternative Syntax for Control Structures. . . . . . . . . . . . . . . . . . . . 1.10 Higher-order Reactive Features. . . . . . . . . . . . . . . . . . . . . . . . . . 1.10.1 Composing Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10.2 Combinators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 1.10.3 Streams of Functions and Functions of Streams. . . . . . . . . . . . . 1.10.4 Instantiating Streams of Functions. . . . . . . . . . . . . . . . . . . . 1.11 Non reactive higher-order features. . . . . . . . . . . . . . . . . . . . . . . .
2 Complete Examples 2.1 The Inverted Pendulum. . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 2.2 The Heater. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 The Coffee Machine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4 The Recursive Wired Buffer. . . . . . . . . . . . . . . . . . . . . . . . . . . .
II Reference manual
3
4
The language 3.1 Lexical conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.1 Basic values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 3.2.2 Tuples, records, sum types. . . . . . . . . . . . . . . . . . . . . . . .. 3.3 Global names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.1 Naming values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.2 Referring to named values. . . . . . . . . . . . . . . . . . . . . . . . . 3.4 Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . 3.5 Clocks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . 3.6 Constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 3.7 Patterns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.8 Signal Patterns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.9 Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 3.9.1 Simple expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . .. 3.9.2 Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.9.3 Control Structures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.10 Definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.11 Type definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.12 Module implementation. . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 3.13 Scalar Interfaces and Importing values. . . . . . . . . . . . . . . . . . . . . . 3.13.1 Making a Node from an Imported Value. . . . . . . . . . . . . . . . .
lucyc- The batch compiler
41 43 43 45 46 47 47 49 49
49 50
52 52 54 57 60
63
65 65 65 65 66
66 66 66
67 67 68 69
69 69 71 72 73
75 78 78
79 79
80
5
The 5.1 5.2
simulator Restrictions Availability
. .
. . . . . .
. .
. . . . . .
. .
. . . . . .
. . . . . .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
82 83 83
Foreword
This document describesLucid Synchrone, a dedicated to the implementation of reactive systems.Lucid Synchrone1an ML-extension of the synchronous data-flow languageis Lustre[4main features of the language are the following: ]. The
The language has a data-flow flavora`laLustreand the syntax is largely reminiscent to the one ofObjective Caml[7 manages ]. Itinfinite sequences or streams as primitive values. These streams are used for representing input and output signals of a reactive system.
The language provides some classical features ofMLlanguages such as higher-order (a function can be parameterized by a function or return a function) or type inference.
The language is build on the notion ofclocksas a way to specify different execution rates in a program. InLucid Synchrone, clocks are types and are computed automatically.
Two program analysis are also provided. A causality analysis rejects programs which cannot be statically scheduled and an initialization analysis rejects programs whose behavior depends on uninitialized delays.
allows for the definition of data-types:The language  types, record types and product sum types. Structured values can be accessed through a pattern matching construction.
Programs are compiled intoObjective Caml. When required (through a compilation flag), the compiler ensures that the resulting program is “real-time”, i.e., it uses bounded memory and has a bounded response time for all possible program inputs.
A module system is provided for importing values from the host languageObjective Camlor from other synchronous modules.
Version3is a major revision and offers new features with respect to versions1.0and2.0.
The language allows to combine data-flow equations with complex state machines with various forms of transitions).
Activation conditions are done through a pattern matching mechanism.
Besides the regular delay primitivepre, a new delay primitive calledlasthas been added in order to make the communication between shared variables in control struc-tures (activation conditions or automata) easier. 1The name is built fromLucid[1from the French word “synchrone” (for “synchronous”).] and
7
The language provides a way to define static values (i.e., infinite constant sequences). These static values may be arbitrarily complex but the compiler guaranty that they can be computed once for all, at instantiation time, before the first reaction starts.
It is possible to define valuedsignals. Signals are stream values paired with a presence information (calledenable Thein circuit terminology). value of signal can be accessed through a pattern matching construct.
The language supports streams of functions as a way to describe reconfigurable systems.
Sequentialfunctions (as opposed tocombinatorialfunction to keep circuit terminology) must now be explicitly declared with the keywordnode they are considered. Otherwise, to becombinatorial.
 abandoned the compilation WeInternally, the compiler has been completely rewritten. method introduced in version2.0and came back to the (co-iteration based) compilation method introduced in version1.0.
Availability
The current implementation is written inObjective Caml use of the language needs. The the installation ofObjective Caml.
Lucid Synchrone, version 3.0:fwrwi/./pl:rtwt.h/etuzpos-dicul/enorhcny Objective Caml, version 3.09:ww/wca.o.omlrgpt/:th
The language is experimental and evolves continuously. Please send comments or bug to Marc.Pouzet@lri.fr.
Copyright notice
This software includes theObjective Camlrun-time system, which is copyrighted INRIA, 2006.