forked from hemanth-VP/SystemVerilog_Course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unbound.sv
80 lines (52 loc) · 1.36 KB
/
unbound.sv
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
//--------------------------------------------------------------------------------------------
//Unbounded mailbox:
//
//This mailbox will have unlimitted size.
//
//--------------------------------------------------------------------------------------------
//Transmitter
class A;
int a;
int i;
mailbox m;
function new(mailbox m1);
this.m = m1;
endfunction
task tra_data();
for(i =0;i<3;i++)begin:BEGIN_MAIN
a++;
m.put(a);
$display("[%0t] 1. Transmitter: value of a = %0d",$time,a);
end:BEGIN_MAIN
endtask
endclass:A
// Receiver
class B;
int a;
int i;
mailbox m;
function new(mailbox m2);
this.m = m2;
endfunction
task rec_data();
begin:BEGIN_MAIN
m.get(a);
$display("[%0t] 2. Receiver: value of a = %0d",$time,a);
end:BEGIN_MAIN
endtask
endclass:B
module tb();
A a1;
B b1;
mailbox main = new();
initial begin:BEGIN_MAIN
a1 = new(main);
b1 = new(main);
repeat(2)
begin:BEGIN_1
a1.tra_data();
$display("...............................................");
b1.rec_data();
end:BEGIN_1
end:BEGIN_MAIN
endmodule:tb