-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtb.v
105 lines (78 loc) · 1.54 KB
/
tb.v
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
`timescale 1ns/1ps
module tb;
`include "useful_tasks.v" // some helper tasks
reg rst_async_n; // asynchronous reset
reg cm0_a;
reg cm0_b;
reg mut0_r1;
reg mut0_r2;
cmuller U_CM0(.z(cm0_z),
.a(cm0_a),
.b(cm0_b),
.rstn(rst_async_)
);
mutex U_MUTEX0(
.g1(mut0_g1),
.g2(mut0_g2),
.r1(mut0_r1),
.r2(mut0_r2)
);
// Dump all nets to a vcd file called tb.vcd
initial
begin
$dumpfile("tb.vcd");
$dumpvars(0,tb);
end
// Start by pulsing the reset low for some nanoseconds
initial begin
rst_async_n = 1'b0;
cm0_a <= 0;
cm0_b <= 0;
mut0_r1 <= 1'b0;
mut0_r2 <= 1'b0;
#5;
rst_async_n = 1'b1;
$display("-I- Reset is released");
// Muller C-Element
#10;
cm0_a <= 0;
cm0_b <= 0;
#10;
cm0_a <= 1;
cm0_b <= 0;
#10;
cm0_a <= 1;
cm0_b <= 1;
#10;
cm0_a <= 1;
cm0_b <= 0;
#10;
cm0_a <= 0;
cm0_b <= 0;
#10;
// Mutex
mut0_r1 <= 1'b1;
mut0_r2 <= 1'b0;
#10;
mut0_r1 <= 1'b0;
mut0_r2 <= 1'b0;
#10;
mut0_r1 <= 1'b0;
mut0_r2 <= 1'b1;
#10;
mut0_r1 <= 1'b0;
mut0_r2 <= 1'b0;
#10;
mut0_r1 <= 1'b1;
mut0_r2 <= 1'b1;
#10;
mut0_r1 <= 1'b0;
mut0_r2 <= 1'b1;
#10;
mut0_r1 <= 1'b0;
mut0_r2 <= 1'b0;
#10;
$display("-I- Done !");
$finish;
end
endmodule // tb