Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
verimag
synchrone
lustre-v6
Commits
afeba5a2
Commit
afeba5a2
authored
Jun 16, 2020
by
erwan
Browse files
Doc: add a missing file
parent
59651322
Pipeline
#45497
passed with stages
in 5 minutes and 38 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
lv6-ref-man/objpdf/speed.lus.github.tex
0 → 100644
View file @
afeba5a2
% Automatically generated by utils/lus2tex
% from file /home/jahier/github/lustre-examples/verimag-v6/examples//speed.lus scriptsize
% the jeudi 11 juin 2020, 08:39:55 (UTC+0200)
\begin{minipage}
{
\textwidth
}
\begin{scriptsize}
\begin{alltt}
\coment
{
-- Time-stamp: <modified the 11/06/2020 (at 08:39) by Erwan Jahier>
}
\coment
{
-- Computes the speed (of some vehicle
\kwdd
{
with
}
wheels) out of 2 sampled inputs:
}
\coment
{
-- + Rot,
\kwdd
{
true
}
iff the wheel has performed a comp
\kwd
{
let
}
e rotation
}
\coment
{
-- + Tic,
\kwdd
{
true
}
iff some external clock has emitted a signal indicating that
}
\coment
{
-- some
\kwd
{
const
}
ant amount of time elapsed (e.g., 100 ms)
}
\coment
{
--
}
\coment
{
-- This example was inspired from a
\kwdd
{
real
}
program in a train regulating system
}
\kwd
{
const
}
period = 0.1;
\coment
{
-- in seconds
}
\kwd
{
const
}
wheel
_
girth = 1.4;
\coment
{
-- in meter
}
\kwd
{
const
}
size = 20;
\coment
{
-- size of the sliding window used to compute the speed
}
\kwd
{
node
}
compute
_
speed(Rot, Tic:
\kwdd
{
bool
}
)
\kwd
{
returns
}
(Speed:
\kwdd
{
real
}
);
var d,t,dx,tx:
\kwdd
{
real
}
;
\kwd
{
let
}
dx =
\kwdd
{
if
}
Rot
\kwdd
{
then
}
wheel
_
girth
\kwdd
{
else
}
0.0;
tx =
\kwdd
{
if
}
Tic
\kwdd
{
then
}
period
\kwdd
{
else
}
0.0;
d = sum<<size,0.0>>(dx);
t = sum<<size,period>>(tx);
\coment
{
-- the speed is actually the average speed during the last "size*period" seconds
}
Speed = (d/t);
\coment
{
-- nb : yes there can be some division by zero! For instance
\kwdd
{
if
}
the vehicle
}
\coment
{
-- overtakes the speed of size*wheel
_
girth/period
}
\coment
{
-- (i.e.,
\kwdd
{
with
}
size=20, period=0.1, wheel
_
girth=1.4,
\kwdd
{
if
}
the speed is > 1008km/h)
}
\coment
{
-- This means that for high-speed vehicle, one
\kwddd
{
needs
}
to increase "size".
}
\kwd
{
tel
}
\coment
{
-- The idea is to call the
\kwd
{
node
}
that do the computation only
\kwd
{
when
}
needed, i.e.,
}
\coment
{
--
\kwd
{
when
}
Tic
\kwdd
{
or
}
Rot is
\kwdd
{
true
}
.
}
\kwd
{
node
}
speed(Rot, Tic:
\kwdd
{
bool
}
)
\kwd
{
returns
}
(Speed:
\kwdd
{
real
}
);
var
TicOrRot :
\kwdd
{
bool
}
;
NewSpeed :
\kwdd
{
real
}
\kwd
{
when
}
TicOrRot;
\kwd
{
let
}
TicOrRot = Tic
\kwdd
{
or
}
Rot;
NewSpeed = compute
_
speed(Rot
\kwd
{
when
}
TicOrRot, Tic
\kwd
{
when
}
TicOrRot);
Speed = current(NewSpeed);
\kwd
{
tel
}
\coment
{
-- computes the sum of the last d values taken by s
}
\kwd
{
node
}
sum<<
\kwd
{
const
}
d:
\kwdd
{
int
}
; const init:
\kwdd
{
real
}
>>(s:
\kwdd
{
real
}
)
\kwd
{
returns
}
(res:
\kwdd
{
real
}
);
var
a,pre
_
a:
\kwdd
{
real
}^
d;
\coment
{
-- circular array
}
i:
\kwdd
{
int
}
;
\kwd
{
let
}
i = 0 fby i + 1;
pre
_
a = (init
^
d) fby a;
a = assign<<d>>(s, i mod d, pre
_
a);
res =red<<+; d>>(0.0, a);
\kwd
{
tel
}
\coment
{
-- assign the jth element of an array to a value. v.(j) <- i
}
\kwd
{
type
}
update
_
acc =
\{
i:
\kwdd
{
int
}
; j:
\kwdd
{
int
}
; v:
\kwdd
{
real
}
\}
;
\kwd
{
function
}
update
_
cell
_
do<<
\kwd
{
const
}
d:
\kwdd
{
int
}
>>(acc: update
_
acc; cell:
\kwdd
{
real
}
)
\kwd
{
returns
}
(nacc: update
_
acc; ncell:
\kwdd
{
real
}
);
\kwd
{
let
}
ncell =
\kwdd
{
if
}
acc.i = acc.j
\kwdd
{
then
}
acc.v
\kwdd
{
else
}
cell;
nacc = update
_
acc
\{
i = acc.i+1; j = acc.j ; v = acc.v
\}
;
\kwd
{
tel
}
\kwd
{
function
}
assign<<
\kwd
{
const
}
d:
\kwdd
{
int
}
>>(v:
\kwdd
{
real
}
; jv:
\kwdd
{
int
}
; t:
\kwdd
{
real
}^
d)
\kwd
{
returns
}
(nt:
\kwdd
{
real
}^
d)
var
dummy: update
_
acc;
\kwd
{
let
}
dummy, nt=fillred<<update
_
cell
_
do<<d>>; d>>( update
_
acc
\{
i=0 ; j=jv ; v=v
\}
, t);
\kwd
{
tel
}
\end{alltt}
\end{scriptsize}
\end{minipage}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment