summaryrefslogtreecommitdiff
path: root/tests/count.scade
blob: c5ce47de9f56e84ecf897a548b6a4b8840960c51 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
node count() returns (c: int)
let
	c = 0 -> (1 + pre c);
tel

node resettable_count (r: bool) returns (c: int)
let
    c = (restart count every r)();
tel

node nat() returns (s: int) s = 1 -> (1 + pre s);

node rst_clk(rst: bool; clock h: bool)
    returns (s: int; t: int)
let
    s = (restart nat every rst) ();
    t = merge(h; ((restart nat every rst) (() when h)); 0 when not h);
tel

node even_times(c: bool; i: int) returns (o: int)
let
    automaton
        initial state EVEN
        unless if c resume ODD;
        let
            o = i+1;
        tel

        state ODD
        unless if c resume EVEN;
        let
            o = -2 * i;
        tel
    returns o;
tel