Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / test / src / kind_fmcad08 / memory1 / FIREFLY_luke_rt.lus @ 22fe1c93

History | View | Annotate | Download (3.76 KB)

1
node First( X : int ) returns ( First : int );
2
let
3
    First = X -> pre First;
4
tel
5

    
6
node Sofar( X : bool ) returns ( Sofar : bool );
7
let
8
    Sofar = X -> X and pre Sofar;
9
tel
10

    
11
node excludes8( X1, X2, X3, X4, X5, X6, X7, X8 : bool ) returns ( excludes : bool );
12
let
13
    excludes = not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 or
14
                  X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 or
15
              not X1 and     X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 or
16
              not X1 and not X2 and     X3 and not X4 and not X5 and not X6 and not X7 and not X8 or
17
              not X1 and not X2 and not X3 and     X4 and not X5 and not X6 and not X7 and not X8 or
18
              not X1 and not X2 and not X3 and not X4 and     X5 and not X6 and not X7 and not X8 or
19
              not X1 and not X2 and not X3 and not X4 and not X5 and     X6 and not X7 and not X8 or
20
              not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and     X7 and not X8 or
21
              not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and     X8;
22
tel
23

    
24

    
25
node firefly(e1, e2, e3, e4, e5, e6, e7, e8 : bool; i_invalid : int) 
26
	returns(invalid, dirty, exclusive, shared : int);
27
var
28

    
29
	garde1, garde2, garde3, garde4, garde5, garde6, garde7, garde8 : bool;
30
	mem_invalid : int;
31

    
32
let
33
--	assert #(e1, e2, e3, e4, e5, e6, e7, e8);
34
--	assert i_invalid > 0;
35

    
36
	mem_invalid = i_invalid -> pre mem_invalid;
37

    
38
	garde1 = pre invalid>=1 and pre dirty=0 and pre shared=0 and pre exclusive=0 ;
39
	garde2 = pre invalid>=1 and pre dirty>=1;
40
	garde3 = pre invalid>=1 and pre shared+pre exclusive>=1;
41
	garde4 = pre exclusive>=1;
42
	garde5 = pre shared=1;
43
	garde6 = pre invalid>=1 and pre dirty=0 and pre shared=0 and pre exclusive=0;
44
	garde7 = pre invalid>=1 and pre dirty>=1;
45
	garde8 = pre invalid>=1 and pre shared+pre exclusive>=1;
46

    
47
	invalid = mem_invalid ->
48
	if(e1) then if(garde1) then pre invalid-1 else pre invalid else
49
	if(e2) then if(garde2) then pre invalid-1 else pre invalid else
50
	if(e3) then if(garde3) then pre invalid-1 else pre invalid else
51
	if(e6) then if(garde6) then pre invalid-1 else pre invalid else
52
	if(e7) then if(garde7) then pre invalid-1 else pre invalid else
53
	if(e8) then if(garde8) then pre invalid-1 else pre invalid else
54
	pre invalid;
55
	
56

    
57
	dirty = 0 -> 
58
	if(e2) then if(garde2) then pre dirty-1 else pre dirty else
59
	if(e4) then if(garde4) then pre dirty+1 else pre dirty else
60
	if(e6) then if(garde6) then 1 else pre dirty else
61
	if(e7) then if(garde7) then pre dirty-1 else pre dirty else
62
	pre dirty;
63

    
64
	exclusive = 0 -> 
65
	if(e1) then if(garde1) then pre exclusive+1 else pre exclusive else
66
	if(e3) then if(garde3) then 0 else pre exclusive else 
67
	if(e4) then if(garde4) then pre exclusive-1 else pre exclusive else
68
	if(e5) then if(garde5) then pre exclusive+1 else pre exclusive else
69
	if(e8) then if(garde8) then 0 else pre exclusive else
70
	pre exclusive;
71

    
72
	shared = 0 ->
73
	if(e2) then if(garde2) then pre shared+2 else pre shared else
74
	if(e3) then if(garde3) then pre shared + pre exclusive + 1 else pre shared else
75
	if(e5) then if(garde5) then pre 0 else pre shared else
76
	if(e7) then if(garde7) then pre shared+2 else pre shared else
77
	if(e8) then if(garde8) then pre shared + pre exclusive + 1 else pre shared else
78
	pre shared;
79

    
80
tel
81

    
82
node top(e1, e2, e3, e4, e5, e6, e7, e8 : bool; i_invalid : int) 
83
	returns( OK : bool );
84
    var invalid, dirty, exclusive, shared : int;
85
        env : bool;
86
let
87
    ( invalid, dirty, exclusive, shared ) =
88
        firefly( e1, e2, e3, e4, e5, e6, e7, e8, i_invalid );
89

    
90
    env = Sofar( excludes8( e1, e2, e3, e4, e5, e6, e7, e8 ) and
91
                 i_invalid >= 0 );
92

    
93
    OK = env => invalid + dirty + exclusive + shared = First( i_invalid );
94

    
95
    --%PROPERTY OK=true;
96
    --%MAIN;
97
tel