forked from CTSRD-CHERI/bluecheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWedgeExample.bsv
147 lines (123 loc) · 4.15 KB
/
WedgeExample.bsv
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import Clocks::*;
import StmtFSM::*;
import BlueCheck::*;
module [BlueCheck] checkWedge#(Reset soft_rst, Bool stmtWithGuard)(Empty);
Reg#(Bit#(8)) r <- mkReg(0, reset_by soft_rst);
function Action doStuff(Bit#(8) x);
return (action
r <= x;
endaction);
endfunction
Stmt preStmt = (seq
doStuff(0);
delay(10);
endseq);
Stmt wedgeStmt = (seq
delay(10);
when( r != 'hFF, r._write(0) );
endseq);
Stmt postStmt = (seq
delay(10);
endseq);
prop("doStuff", doStuff);
if (stmtWithGuard)
prop("wedgeStmt", stmtWhen(r != 'hFF, wedgeStmt));
else
prop("wedgeStmt", wedgeStmt);
pre("doPre", preStmt);
post("checkPost", postStmt);
endmodule
(* synthesize *)
module [Module] mkWedgeExample(Empty);
Clock clk <- exposeCurrentClock;
MakeResetIfc my_rst <- mkReset(0, True, clk);
Reset soft_rst = my_rst.new_rst;
// Iterative Deepening
BlueCheck_Params my_params = bcParams;
ID_Params my_id_params = ID_Params {rst: my_rst, initialDepth: 10, testsPerDepth: 100, incDepth: ( ( \+ )(10) )};
my_params.verbose = True;
my_params.showTime = True;
// my_params.showNoOp = True;
my_params.wedgeDetect = True;
my_params.useIterativeDeepening = True;
my_params.id = my_id_params;
my_params.useShrinking = True;
// BlueCheck_Params my_params = bcParams;
// my_params.verbose = True;
// my_params.showTime = True;
// my_params.showNoOp = True;
// my_params.wedgeDetect = True;
// my_params.numIterations = 10;
Stmt s <- mkModelChecker(checkWedge(soft_rst, False), my_params);
mkAutoFSM(s);
endmodule
(* synthesize *)
module [Module] mkWedgeExampleWithGuardedStmt(Empty);
Clock clk <- exposeCurrentClock;
MakeResetIfc my_rst <- mkReset(0, True, clk);
Reset soft_rst = my_rst.new_rst;
// Iterative Deepening
BlueCheck_Params my_params = bcParams;
ID_Params my_id_params = ID_Params {rst: my_rst, initialDepth: 10, testsPerDepth: 100, incDepth: ( ( \+ )(10) )};
my_params.verbose = True;
my_params.showTime = True;
// my_params.showNoOp = True;
my_params.wedgeDetect = True;
my_params.useIterativeDeepening = True;
my_params.id = my_id_params;
my_params.useShrinking = True;
// BlueCheck_Params my_params = bcParams;
// my_params.verbose = True;
// my_params.showTime = True;
// my_params.showNoOp = True;
// my_params.wedgeDetect = True;
// my_params.numIterations = 10;
Stmt s <- mkModelChecker(checkWedge(soft_rst, True), my_params);
mkAutoFSM(s);
endmodule
module [BlueCheck] checkWedge2#(Reset soft_rst)(Empty);
Reg#(Bool) deadlock <- mkReg(False, reset_by soft_rst);
Reg#(Bit#(8)) r <- mkReg(0, reset_by soft_rst);
// Secret code for deadlock:
// action1(0xde)
// action2(0xad)
function Action action1(Bit#(8) x);
return when(!deadlock, action
r <= x;
endaction);
endfunction
function Action action2(Bit#(8) x);
return when(!deadlock, action
if (r == 'hde && x == 'had)
deadlock <= True;
else
r <= 0;
endaction);
endfunction
prop("action1", action1);
prop("action2", action2);
endmodule
(* synthesize *)
module [Module] mkWedgeExample2(Empty);
Clock clk <- exposeCurrentClock;
MakeResetIfc my_rst <- mkReset(0, True, clk);
Reset soft_rst = my_rst.new_rst;
// Iterative Deepening
BlueCheck_Params my_params = bcParams;
ID_Params my_id_params = ID_Params {rst: my_rst, initialDepth: 10, testsPerDepth: 100, incDepth: ( ( \+ )(10) )};
my_params.verbose = True;
my_params.showTime = True;
// my_params.showNoOp = True;
my_params.wedgeDetect = True;
my_params.useIterativeDeepening = True;
my_params.id = my_id_params;
my_params.useShrinking = True;
// BlueCheck_Params my_params = bcParams;
// my_params.verbose = True;
// my_params.showTime = True;
// my_params.showNoOp = True;
// my_params.wedgeDetect = True;
// my_params.numIterations = 10;
Stmt s <- mkModelChecker(checkWedge2(soft_rst), my_params);
mkAutoFSM(s);
endmodule