forked from hemanth-VP/SystemVerilog_Course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
num.sv
57 lines (34 loc) · 1.24 KB
/
num.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
//--------------------------------------------------------------------------------------------
//num_method:
//
//Returns number of messages in the mailbox.
//
//--------------------------------------------------------------------------------------------
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] Transmitter: value of a = %0d",$time,a);
$display(" No of messages in mailbox = %0d",m.num());
end:BEGIN_MAIN
$display(".....................................................");
endtask
endclass:A
module tb();
A a1;
mailbox main = new();
initial begin:BEGIN_MAIN
a1 = new(main);
repeat(2)
begin:BEGIN_1
a1.tra_data();
end:BEGIN_1
end:BEGIN_MAIN
endmodule:tb