07.01.2013 Views

Lecture Notes in Computer Science 3472

Lecture Notes in Computer Science 3472

Lecture Notes in Computer Science 3472

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

396 Axel Bel<strong>in</strong>fante, Lars Frantzen, and Christian Schallhart<br />

node COUNTER(val_<strong>in</strong>it, val_<strong>in</strong>cr : <strong>in</strong>t; reset : bool)<br />

returns (n : <strong>in</strong>t);<br />

let<br />

n = val_<strong>in</strong>it -> if reset then val_<strong>in</strong>it else pre(n)+val_<strong>in</strong>cr;<br />

tel;<br />

This example shows the two more fundamental time operators of Lustre 2 .The<br />

first operator -> is the followed-by operator. If A and B have the respective<br />

sequence of values a0, a1,... and b0, b1,... then A -> B declares the sequence<br />

a0, b1, b2,.... Therefore, <strong>in</strong> the example, the flow of n starts with the first value<br />

of val <strong>in</strong>it.<br />

The second time operator <strong>in</strong> the example is pre. GivenaflowA with the values<br />

a0, a1,..., pre(A) is the flow with the values nil, a0, a1,.... So <strong>in</strong> the code above,<br />

we f<strong>in</strong>d that if reset is true, then n is set to the current value of val <strong>in</strong>it.<br />

Otherwise n is set to the previous value of n plus the <strong>in</strong>crement val <strong>in</strong>cr. Two<br />

simple applications of this node are the follow<strong>in</strong>g two sequences.<br />

even=COUNTER(0,2,false);<br />

mod5=COUNTER(0,1,pre(mod5)=4);<br />

The first sequence generates the even numbers, and the second cycles through<br />

the numbers between 0 and 4. Note that the reset <strong>in</strong>put is <strong>in</strong>deed fed with<br />

another flow.<br />

To approximate the position of an accelerat<strong>in</strong>g vehicle, we can use the follow<strong>in</strong>g<br />

two flows<br />

speed=COUNTER(0,acceleration,false);<br />

position=COUNTER(0,speed,false);<br />

Note that speed used as <strong>in</strong>put <strong>in</strong> the second statement is a flow which is chang<strong>in</strong>g<br />

over time. E.g. if acceleration is the constant flow with value 4, then<br />

speed would be the sequence 0,4,8,12,16,. . . , and position would start with<br />

0,4,12,24,40,.. .<br />

Test<strong>in</strong>g Method<br />

The construction of the test sequence generation is formally described <strong>in</strong> the<br />

paper [dBORZ99]. Basically, a test sequence generator built by Lutess is based<br />

on an environment description given <strong>in</strong> Lustre and a set of further (probabilistic)<br />

2 Lustre also offers two other operators, namely when and current. These operators<br />

allow the manipulation of the clock of a dataflow. Each dataflow <strong>in</strong> Lustre has an<br />

associated clock which determ<strong>in</strong>es when a new value is added to the correspond<strong>in</strong>g<br />

flow. For example, a flow with the clock true, false, true,... would be expanded<br />

by a new value every second cycle. The when operator allows to declare a sequence<br />

which runs with a slower clock, while the current operator allows to <strong>in</strong>terpolate a<br />

flow with a slow clock such that it becomes accessible for recomb<strong>in</strong>ation with faster<br />

flows.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!