-
Notifications
You must be signed in to change notification settings - Fork 0
/
question10.sv
58 lines (46 loc) · 1.16 KB
/
question10.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
// Code for transaction class is mentioned in the Instruction tab. Write a code to send transaction data between generator and driver. Also, verify the data by
// printing the value of data members of Generator and Driver.
class transaction;
bit [7:0] addr = 7'h12;
bit [3:0] data = 4'h4;
bit we = 1'b1;
bit rst = 1'b0;
endclass
class generator;
transaction t;
mailbox #(transaction) mbx;
function new(mailbox #(transaction) mbx);
this.mbx=mbx;
endfunction
task run();
t=new();
mbx.put(t);
$display(" DATA SENT || addr = %0d, data = %0d, we = %0d, rst = %0d",t.addr,t.data,t.we,t.rst);
endtask
endclass
class driver;
transaction datac;
mailbox #(transaction) mbx;
function new(mailbox #(transaction) mbx);
this.mbx=mbx;
endfunction
task run();
mbx.get(datac);
$display(" DATA RCVD || addr = %0d, data = %0d, we = %0d, rst = %0d",datac.addr, datac.data, datac.we, datac.rst);
endtask
endclass
module tb;
mailbox #(transaction) mbx;
generator g;
driver d;
initial
begin
mbx=new();
g=new(mbx);
d=new(mbx);
fork
g.run();
d.run();
join
end
endmodule