1 |
16 |
HanySalah |
//----------------------------------------------------------------------
|
2 |
|
|
// Copyright 2010 Mentor Graphics Corporation
|
3 |
|
|
// Copyright 2010 Synopsys, Inc.
|
4 |
|
|
// All Rights Reserved Worldwide
|
5 |
|
|
//
|
6 |
|
|
// Licensed under the Apache License, Version 2.0 (the
|
7 |
|
|
// "License"); you may not use this file except in
|
8 |
|
|
// compliance with the License. You may obtain a copy of
|
9 |
|
|
// the License at
|
10 |
|
|
//
|
11 |
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
12 |
|
|
//
|
13 |
|
|
// Unless required by applicable law or agreed to in
|
14 |
|
|
// writing, software distributed under the License is
|
15 |
|
|
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
16 |
|
|
// CONDITIONS OF ANY KIND, either express or implied. See
|
17 |
|
|
// the License for the specific language governing
|
18 |
|
|
// permissions and limitations under the License.
|
19 |
|
|
//----------------------------------------------------------------------
|
20 |
|
|
|
21 |
|
|
//----------------------------------------------------------------------
|
22 |
|
|
// Title: TLM Sockets
|
23 |
|
|
//
|
24 |
|
|
// Each uvm_tlm_*_socket class is derived from a corresponding
|
25 |
|
|
// uvm_tlm_*_socket_base class. The base class contains most of the
|
26 |
|
|
// implementation of the class, The derived classes (in this file)
|
27 |
|
|
// contain the connection semantics.
|
28 |
|
|
//
|
29 |
|
|
// Sockets come in several flavors: Each socket is either an initiator or a
|
30 |
|
|
// target, a pass-through or a terminator. Further, any particular socket
|
31 |
|
|
// implements either the blocking interfaces or the nonblocking interfaces.
|
32 |
|
|
// Terminator sockets are used on initiators and targets as well as
|
33 |
|
|
// interconnect components as shown in the figure above. Pass-through
|
34 |
|
|
// sockets are used to enable connections to cross hierarchical boundaries.
|
35 |
|
|
//
|
36 |
|
|
// There are eight socket types: the cross of blocking and nonblocking,
|
37 |
|
|
// pass-through and termination, target and initiator
|
38 |
|
|
//
|
39 |
|
|
// Sockets are specified based on what they are (IS-A)
|
40 |
|
|
// and what they contains (HAS-A).
|
41 |
|
|
// IS-A and HAS-A are types of object relationships.
|
42 |
|
|
// IS-A refers to the inheritance relationship and
|
43 |
|
|
// HAS-A refers to the ownership relationship.
|
44 |
|
|
// For example if you say D is a B that means that D is derived from base B.
|
45 |
|
|
// If you say object A HAS-A B that means that B is a member of A.
|
46 |
|
|
//----------------------------------------------------------------------
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
//----------------------------------------------------------------------
|
50 |
|
|
// Class: uvm_tlm_b_initiator_socket
|
51 |
|
|
//
|
52 |
|
|
// IS-A forward port; has no backward path except via the payload
|
53 |
|
|
// contents
|
54 |
|
|
//----------------------------------------------------------------------
|
55 |
|
|
|
56 |
|
|
class uvm_tlm_b_initiator_socket #(type T=uvm_tlm_generic_payload)
|
57 |
|
|
extends uvm_tlm_b_initiator_socket_base #(T);
|
58 |
|
|
|
59 |
|
|
// Function: new
|
60 |
|
|
// Construct a new instance of this socket
|
61 |
|
|
function new(string name, uvm_component parent);
|
62 |
|
|
super.new(name, parent);
|
63 |
|
|
endfunction
|
64 |
|
|
|
65 |
|
|
// Function: Connect
|
66 |
|
|
//
|
67 |
|
|
// Connect this socket to the specified
|
68 |
|
|
function void connect(this_type provider);
|
69 |
|
|
|
70 |
|
|
uvm_tlm_b_passthrough_initiator_socket_base #(T) initiator_pt_socket;
|
71 |
|
|
uvm_tlm_b_passthrough_target_socket_base #(T) target_pt_socket;
|
72 |
|
|
uvm_tlm_b_target_socket_base #(T) target_socket;
|
73 |
|
|
|
74 |
|
|
uvm_component c;
|
75 |
|
|
|
76 |
|
|
super.connect(provider);
|
77 |
|
|
|
78 |
|
|
if($cast(initiator_pt_socket, provider) ||
|
79 |
|
|
$cast(target_pt_socket, provider) ||
|
80 |
|
|
$cast(target_socket, provider))
|
81 |
|
|
return;
|
82 |
|
|
|
83 |
|
|
c = get_comp();
|
84 |
|
|
`uvm_error_context(get_type_name(),
|
85 |
|
|
"type mismatch in connect -- connection cannot be completed", c)
|
86 |
|
|
|
87 |
|
|
endfunction
|
88 |
|
|
|
89 |
|
|
endclass
|
90 |
|
|
|
91 |
|
|
//----------------------------------------------------------------------
|
92 |
|
|
// Class: uvm_tlm_b_target_socket
|
93 |
|
|
//
|
94 |
|
|
// IS-A forward imp; has no backward path except via the payload
|
95 |
|
|
// contents.
|
96 |
|
|
//
|
97 |
|
|
// The component instantiating this socket must implement
|
98 |
|
|
// a b_transport() method with the following signature
|
99 |
|
|
//
|
100 |
|
|
//| task b_transport(T t, uvm_tlm_time delay);
|
101 |
|
|
//
|
102 |
|
|
//----------------------------------------------------------------------
|
103 |
|
|
|
104 |
|
|
class uvm_tlm_b_target_socket #(type IMP=int,
|
105 |
|
|
type T=uvm_tlm_generic_payload)
|
106 |
|
|
extends uvm_tlm_b_target_socket_base #(T);
|
107 |
|
|
|
108 |
|
|
local IMP m_imp;
|
109 |
|
|
|
110 |
|
|
// Function: new
|
111 |
|
|
// Construct a new instance of this socket
|
112 |
|
|
// ~imp~ is a reference to the class implementing the
|
113 |
|
|
// b_transport() method.
|
114 |
|
|
// If not specified, it is assume to be the same as ~parent~.
|
115 |
|
|
function new (string name, uvm_component parent, IMP imp = null);
|
116 |
|
|
super.new (name, parent);
|
117 |
|
|
if (imp == null) $cast(m_imp, parent);
|
118 |
|
|
else m_imp = imp;
|
119 |
|
|
if (m_imp == null)
|
120 |
|
|
`uvm_error("UVM/TLM2/NOIMP", {"b_target socket ", name,
|
121 |
|
|
" has no implementation"});
|
122 |
|
|
endfunction
|
123 |
|
|
|
124 |
|
|
// Function: Connect
|
125 |
|
|
//
|
126 |
|
|
// Connect this socket to the specified
|
127 |
|
|
function void connect(this_type provider);
|
128 |
|
|
|
129 |
|
|
uvm_component c;
|
130 |
|
|
|
131 |
|
|
super.connect(provider);
|
132 |
|
|
|
133 |
|
|
c = get_comp();
|
134 |
|
|
`uvm_error_context(get_type_name(),
|
135 |
|
|
"You cannot call connect() on a target termination socket", c)
|
136 |
|
|
endfunction
|
137 |
|
|
|
138 |
|
|
`UVM_TLM_B_TRANSPORT_IMP(m_imp, T, t, delay)
|
139 |
|
|
|
140 |
|
|
endclass
|
141 |
|
|
|
142 |
|
|
//----------------------------------------------------------------------
|
143 |
|
|
// Class: uvm_tlm_nb_initiator_socket
|
144 |
|
|
//
|
145 |
|
|
// IS-A forward port; HAS-A backward imp
|
146 |
|
|
//
|
147 |
|
|
// The component instantiating this socket must implement
|
148 |
|
|
// a nb_transport_bw() method with the following signature
|
149 |
|
|
//
|
150 |
|
|
//| function uvm_tlm_sync_e nb_transport_bw(T t, ref P p, input uvm_tlm_time delay);
|
151 |
|
|
//
|
152 |
|
|
//----------------------------------------------------------------------
|
153 |
|
|
|
154 |
|
|
class uvm_tlm_nb_initiator_socket #(type IMP=int,
|
155 |
|
|
type T=uvm_tlm_generic_payload,
|
156 |
|
|
type P=uvm_tlm_phase_e)
|
157 |
|
|
extends uvm_tlm_nb_initiator_socket_base #(T,P);
|
158 |
|
|
|
159 |
|
|
uvm_tlm_nb_transport_bw_imp #(T,P,IMP) bw_imp;
|
160 |
|
|
|
161 |
|
|
// Function: new
|
162 |
|
|
// Construct a new instance of this socket
|
163 |
|
|
// ~imp~ is a reference to the class implementing the
|
164 |
|
|
// nb_transport_bw() method.
|
165 |
|
|
// If not specified, it is assume to be the same as ~parent~.
|
166 |
|
|
function new(string name, uvm_component parent, IMP imp = null);
|
167 |
|
|
super.new (name, parent);
|
168 |
|
|
if (imp == null) $cast(imp, parent);
|
169 |
|
|
if (imp == null)
|
170 |
|
|
`uvm_error("UVM/TLM2/NOIMP", {"nb_initiator socket ", name,
|
171 |
|
|
" has no implementation"});
|
172 |
|
|
bw_imp = new("bw_imp", imp);
|
173 |
|
|
endfunction
|
174 |
|
|
|
175 |
|
|
// Function: Connect
|
176 |
|
|
//
|
177 |
|
|
// Connect this socket to the specified
|
178 |
|
|
function void connect(this_type provider);
|
179 |
|
|
|
180 |
|
|
uvm_tlm_nb_passthrough_initiator_socket_base #(T,P) initiator_pt_socket;
|
181 |
|
|
uvm_tlm_nb_passthrough_target_socket_base #(T,P) target_pt_socket;
|
182 |
|
|
uvm_tlm_nb_target_socket_base #(T,P) target_socket;
|
183 |
|
|
|
184 |
|
|
uvm_component c;
|
185 |
|
|
|
186 |
|
|
super.connect(provider);
|
187 |
|
|
|
188 |
|
|
if($cast(initiator_pt_socket, provider)) begin
|
189 |
|
|
initiator_pt_socket.bw_export.connect(bw_imp);
|
190 |
|
|
return;
|
191 |
|
|
end
|
192 |
|
|
if($cast(target_pt_socket, provider)) begin
|
193 |
|
|
target_pt_socket.bw_port.connect(bw_imp);
|
194 |
|
|
return;
|
195 |
|
|
end
|
196 |
|
|
|
197 |
|
|
if($cast(target_socket, provider)) begin
|
198 |
|
|
target_socket.bw_port.connect(bw_imp);
|
199 |
|
|
return;
|
200 |
|
|
end
|
201 |
|
|
|
202 |
|
|
c = get_comp();
|
203 |
|
|
`uvm_error_context(get_type_name(),
|
204 |
|
|
"type mismatch in connect -- connection cannot be completed", c)
|
205 |
|
|
|
206 |
|
|
endfunction
|
207 |
|
|
|
208 |
|
|
endclass
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
//----------------------------------------------------------------------
|
212 |
|
|
// Class: uvm_tlm_nb_target_socket
|
213 |
|
|
//
|
214 |
|
|
// IS-A forward imp; HAS-A backward port
|
215 |
|
|
//
|
216 |
|
|
// The component instantiating this socket must implement
|
217 |
|
|
// a nb_transport_fw() method with the following signature
|
218 |
|
|
//
|
219 |
|
|
//| function uvm_tlm_sync_e nb_transport_fw(T t, ref P p, input uvm_tlm_time delay);
|
220 |
|
|
//
|
221 |
|
|
//----------------------------------------------------------------------
|
222 |
|
|
|
223 |
|
|
class uvm_tlm_nb_target_socket #(type IMP=int,
|
224 |
|
|
type T=uvm_tlm_generic_payload,
|
225 |
|
|
type P=uvm_tlm_phase_e)
|
226 |
|
|
extends uvm_tlm_nb_target_socket_base #(T,P);
|
227 |
|
|
|
228 |
|
|
local IMP m_imp;
|
229 |
|
|
|
230 |
|
|
// Function: new
|
231 |
|
|
// Construct a new instance of this socket
|
232 |
|
|
// ~imp~ is a reference to the class implementing the
|
233 |
|
|
// nb_transport_fw() method.
|
234 |
|
|
// If not specified, it is assume to be the same as ~parent~.
|
235 |
|
|
function new (string name, uvm_component parent, IMP imp = null);
|
236 |
|
|
super.new (name, parent);
|
237 |
|
|
if (imp == null) $cast(m_imp, parent);
|
238 |
|
|
else m_imp = imp;
|
239 |
|
|
bw_port = new("bw_port", get_comp());
|
240 |
|
|
if (m_imp == null)
|
241 |
|
|
`uvm_error("UVM/TLM2/NOIMP", {"nb_target socket ", name,
|
242 |
|
|
" has no implementation"});
|
243 |
|
|
endfunction
|
244 |
|
|
|
245 |
|
|
// Function: connect
|
246 |
|
|
//
|
247 |
|
|
// Connect this socket to the specified
|
248 |
|
|
function void connect(this_type provider);
|
249 |
|
|
|
250 |
|
|
uvm_component c;
|
251 |
|
|
|
252 |
|
|
super.connect(provider);
|
253 |
|
|
|
254 |
|
|
c = get_comp();
|
255 |
|
|
`uvm_error_context(get_type_name(),
|
256 |
|
|
"You cannot call connect() on a target termination socket", c)
|
257 |
|
|
endfunction
|
258 |
|
|
|
259 |
|
|
`UVM_TLM_NB_TRANSPORT_FW_IMP(m_imp, T, P, t, p, delay)
|
260 |
|
|
|
261 |
|
|
endclass
|
262 |
|
|
|
263 |
|
|
|
264 |
|
|
//----------------------------------------------------------------------
|
265 |
|
|
// Class: uvm_tlm_b_passthrough_initiator_socket
|
266 |
|
|
//
|
267 |
|
|
// IS-A forward port;
|
268 |
|
|
//----------------------------------------------------------------------
|
269 |
|
|
|
270 |
|
|
class uvm_tlm_b_passthrough_initiator_socket #(type T=uvm_tlm_generic_payload)
|
271 |
|
|
extends uvm_tlm_b_passthrough_initiator_socket_base #(T);
|
272 |
|
|
|
273 |
|
|
function new(string name, uvm_component parent);
|
274 |
|
|
super.new(name, parent);
|
275 |
|
|
endfunction
|
276 |
|
|
|
277 |
|
|
// Function : connect
|
278 |
|
|
//
|
279 |
|
|
// Connect this socket to the specified
|
280 |
|
|
function void connect(this_type provider);
|
281 |
|
|
|
282 |
|
|
uvm_tlm_b_passthrough_initiator_socket_base #(T) initiator_pt_socket;
|
283 |
|
|
uvm_tlm_b_passthrough_target_socket_base #(T) target_pt_socket;
|
284 |
|
|
uvm_tlm_b_target_socket_base #(T) target_socket;
|
285 |
|
|
|
286 |
|
|
uvm_component c;
|
287 |
|
|
|
288 |
|
|
super.connect(provider);
|
289 |
|
|
|
290 |
|
|
if($cast(initiator_pt_socket, provider) ||
|
291 |
|
|
$cast(target_pt_socket, provider) ||
|
292 |
|
|
$cast(target_socket, provider))
|
293 |
|
|
return;
|
294 |
|
|
|
295 |
|
|
c = get_comp();
|
296 |
|
|
`uvm_error_context(get_type_name(), "type mismatch in connect -- connection cannot be completed", c)
|
297 |
|
|
|
298 |
|
|
endfunction
|
299 |
|
|
|
300 |
|
|
endclass
|
301 |
|
|
|
302 |
|
|
//----------------------------------------------------------------------
|
303 |
|
|
// Class: uvm_tlm_b_passthrough_target_socket
|
304 |
|
|
//
|
305 |
|
|
// IS-A forward export;
|
306 |
|
|
//----------------------------------------------------------------------
|
307 |
|
|
class uvm_tlm_b_passthrough_target_socket #(type T=uvm_tlm_generic_payload)
|
308 |
|
|
extends uvm_tlm_b_passthrough_target_socket_base #(T);
|
309 |
|
|
|
310 |
|
|
function new(string name, uvm_component parent);
|
311 |
|
|
super.new(name, parent);
|
312 |
|
|
endfunction
|
313 |
|
|
|
314 |
|
|
// Function : connect
|
315 |
|
|
//
|
316 |
|
|
// Connect this socket to the specified
|
317 |
|
|
function void connect(this_type provider);
|
318 |
|
|
|
319 |
|
|
uvm_tlm_b_passthrough_target_socket_base #(T) target_pt_socket;
|
320 |
|
|
uvm_tlm_b_target_socket_base #(T) target_socket;
|
321 |
|
|
|
322 |
|
|
uvm_component c;
|
323 |
|
|
|
324 |
|
|
super.connect(provider);
|
325 |
|
|
|
326 |
|
|
if($cast(target_pt_socket, provider) ||
|
327 |
|
|
$cast(target_socket, provider))
|
328 |
|
|
return;
|
329 |
|
|
|
330 |
|
|
c = get_comp();
|
331 |
|
|
`uvm_error_context(get_type_name(),
|
332 |
|
|
"type mismatch in connect -- connection cannot be completed", c)
|
333 |
|
|
endfunction
|
334 |
|
|
|
335 |
|
|
endclass
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
//----------------------------------------------------------------------
|
340 |
|
|
// Class: uvm_tlm_nb_passthrough_initiator_socket
|
341 |
|
|
//
|
342 |
|
|
// IS-A forward port; HAS-A backward export
|
343 |
|
|
//----------------------------------------------------------------------
|
344 |
|
|
|
345 |
|
|
class uvm_tlm_nb_passthrough_initiator_socket #(type T=uvm_tlm_generic_payload,
|
346 |
|
|
type P=uvm_tlm_phase_e)
|
347 |
|
|
extends uvm_tlm_nb_passthrough_initiator_socket_base #(T,P);
|
348 |
|
|
|
349 |
|
|
function new(string name, uvm_component parent);
|
350 |
|
|
super.new(name, parent);
|
351 |
|
|
endfunction
|
352 |
|
|
|
353 |
|
|
// Function : connect
|
354 |
|
|
//
|
355 |
|
|
// Connect this socket to the specified
|
356 |
|
|
function void connect(this_type provider);
|
357 |
|
|
|
358 |
|
|
uvm_tlm_nb_passthrough_initiator_socket_base #(T,P) initiator_pt_socket;
|
359 |
|
|
uvm_tlm_nb_passthrough_target_socket_base #(T,P) target_pt_socket;
|
360 |
|
|
uvm_tlm_nb_target_socket_base #(T,P) target_socket;
|
361 |
|
|
|
362 |
|
|
uvm_component c;
|
363 |
|
|
|
364 |
|
|
super.connect(provider);
|
365 |
|
|
|
366 |
|
|
if($cast(initiator_pt_socket, provider)) begin
|
367 |
|
|
bw_export.connect(initiator_pt_socket.bw_export);
|
368 |
|
|
return;
|
369 |
|
|
end
|
370 |
|
|
|
371 |
|
|
if($cast(target_pt_socket, provider)) begin
|
372 |
|
|
target_pt_socket.bw_port.connect(bw_export);
|
373 |
|
|
return;
|
374 |
|
|
end
|
375 |
|
|
|
376 |
|
|
if($cast(target_socket, provider)) begin
|
377 |
|
|
target_socket.bw_port.connect(bw_export);
|
378 |
|
|
return;
|
379 |
|
|
end
|
380 |
|
|
|
381 |
|
|
c = get_comp();
|
382 |
|
|
`uvm_error_context(get_type_name(),
|
383 |
|
|
"type mismatch in connect -- connection cannot be completed", c)
|
384 |
|
|
|
385 |
|
|
endfunction
|
386 |
|
|
|
387 |
|
|
endclass
|
388 |
|
|
|
389 |
|
|
//----------------------------------------------------------------------
|
390 |
|
|
// Class: uvm_tlm_nb_passthrough_target_socket
|
391 |
|
|
//
|
392 |
|
|
// IS-A forward export; HAS-A backward port
|
393 |
|
|
//----------------------------------------------------------------------
|
394 |
|
|
|
395 |
|
|
class uvm_tlm_nb_passthrough_target_socket #(type T=uvm_tlm_generic_payload,
|
396 |
|
|
type P=uvm_tlm_phase_e)
|
397 |
|
|
extends uvm_tlm_nb_passthrough_target_socket_base #(T,P);
|
398 |
|
|
|
399 |
|
|
function new(string name, uvm_component parent);
|
400 |
|
|
super.new(name, parent);
|
401 |
|
|
endfunction
|
402 |
|
|
|
403 |
|
|
// Function: connect
|
404 |
|
|
//
|
405 |
|
|
// Connect this socket to the specified
|
406 |
|
|
function void connect(this_type provider);
|
407 |
|
|
|
408 |
|
|
uvm_tlm_nb_passthrough_target_socket_base #(T,P) target_pt_socket;
|
409 |
|
|
uvm_tlm_nb_target_socket_base #(T,P) target_socket;
|
410 |
|
|
|
411 |
|
|
uvm_component c;
|
412 |
|
|
|
413 |
|
|
super.connect(provider);
|
414 |
|
|
|
415 |
|
|
if($cast(target_pt_socket, provider)) begin
|
416 |
|
|
target_pt_socket.bw_port.connect(bw_port);
|
417 |
|
|
return;
|
418 |
|
|
end
|
419 |
|
|
|
420 |
|
|
if($cast(target_socket, provider)) begin
|
421 |
|
|
target_socket.bw_port.connect(bw_port);
|
422 |
|
|
return;
|
423 |
|
|
end
|
424 |
|
|
|
425 |
|
|
c = get_comp();
|
426 |
|
|
`uvm_error_context(get_type_name(),
|
427 |
|
|
"type mismatch in connect -- connection cannot be completed", c)
|
428 |
|
|
|
429 |
|
|
endfunction
|
430 |
|
|
|
431 |
|
|
endclass
|
432 |
|
|
|
433 |
|
|
//----------------------------------------------------------------------
|