-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCode_29 UVM Port to export&export.sv
165 lines (95 loc) · 3.34 KB
/
Code_29 UVM Port to export&export.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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
`include "uvm_macros.svh"
import uvm_pkg::*;
class producer extends uvm_component;
`uvm_component_utils(producer)
int data = 12;
uvm_blocking_put_port #(int) port;
function new(input string path = "producer", uvm_component parent = null);
super.new(path, parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
port = new("port", this);
endfunction
task main_phase(uvm_phase phase);
phase.raise_objection(this);
`uvm_info("PROD", $sformatf("Data Sent : %0d", data), UVM_NONE);
port.put(data);
phase.drop_objection(this);
endtask
endclass
////////////////////////////////////////////////
////////////////////////////////////////////////
class subconsumer extends uvm_component;
`uvm_component_utils(subconsumer)
uvm_blocking_put_imp#(int, subconsumer) imp;
function new(input string path = "subconsumer", uvm_component parent = null);
super.new(path, parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
imp = new("imp", this);
endfunction
function void put(int datar);
`uvm_info("SUBCONS", $sformatf("Data Rcvd : %0d", datar), UVM_NONE);
endfunction
endclass
/////////////////////////////////////////////////
class consumer extends uvm_component;
`uvm_component_utils(consumer)
uvm_blocking_put_export#(int) expo;
subconsumer s;
function new(input string path = "consumer", uvm_component parent = null);
super.new(path, parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
expo = new("expo", this);
s = subconsumer::type_id::create("s", this);
endfunction
virtual function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
expo.connect(s.imp);
endfunction
endclass
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
class env extends uvm_env;
`uvm_component_utils(env)
producer p;
consumer c;
function new(input string path = "env", uvm_component parent = null);
super.new(path, parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
p = producer::type_id::create("p",this);
c = consumer::type_id::create("c", this);
endfunction
virtual function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
p.port.connect(c.expo);
endfunction
endclass
///////////////////////////////////////////////////
class test extends uvm_test;
`uvm_component_utils(test)
env e;
function new(input string path = "test", uvm_component parent = null);
super.new(path, parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
e = env::type_id::create("e",this);
endfunction
virtual function void end_of_elaboration_phase(uvm_phase phase);
super.end_of_elaboration_phase(phase);
uvm_top.print_topology();
endfunction
endclass
//////////////////////////////////////////////
module tb;
initial begin
run_test("test");
end
endmodule