OpenCores
URL https://opencores.org/ocsvn/uart2bus_testbench/uart2bus_testbench/trunk

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [uvm_src/] [base/] [uvm_links.svh] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 HanySalah
//
2
//-----------------------------------------------------------------------------
3
//   Copyright 2007-2011 Mentor Graphics Corporation
4
//   Copyright 2007-2011 Cadence Design Systems, Inc.
5
//   Copyright 2010 Synopsys, Inc.
6
//   Copyright 2013 NVIDIA Corporation
7
//   All Rights Reserved Worldwide
8
//
9
//   Licensed under the Apache License, Version 2.0 (the
10
//   "License"); you may not use this file except in
11
//   compliance with the License.  You may obtain a copy of
12
//   the License at
13
//
14
//       http://www.apache.org/licenses/LICENSE-2.0
15
//
16
//   Unless required by applicable law or agreed to in
17
//   writing, software distributed under the License is
18
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
19
//   CONDITIONS OF ANY KIND, either express or implied.  See
20
//   the License for the specific language governing
21
//   permissions and limitations under the License.
22
//-----------------------------------------------------------------------------
23
 
24
// File: UVM Links
25
//
26
// The  class, and its extensions, are provided as a mechanism
27
// to allow for compile-time safety when trying to establish links between
28
// records within a .
29
//
30
//
31
 
32
//------------------------------------------------------------------------------
33
//
34
// CLASS: uvm_link_base
35
//
36
// The ~uvm_link_base~ class presents a simple API for defining a link between
37
// any two objects.
38
//
39
// Using extensions of this class, a  can determine the
40
// type of links being passed, without relying on "magic" string names.
41
//
42
// For example:
43
// |
44
// | virtual function void do_establish_link(uvm_link_base link);
45
// |   uvm_parent_child_link pc_link;
46
// |   uvm_cause_effect_link ce_link;
47
// |
48
// |   if ($cast(pc_link, link)) begin
49
// |      // Record the parent-child relationship
50
// |   end
51
// |   else if ($cast(ce_link, link)) begin
52
// |      // Record the cause-effect relationship
53
// |   end
54
// |   else begin
55
// |      // Unsupported relationship!
56
// |   end
57
// | endfunction : do_establish_link
58
//
59
virtual class uvm_link_base extends uvm_object;
60
 
61
   // Function: new
62
   // Constructor
63
   //
64
   // Parameters:
65
   // name - Instance name
66
   function new(string name="unnamed-uvm_link_base");
67
      super.new(name);
68
   endfunction : new
69
 
70
   // Group:  Accessors
71
 
72
   // Function: set_lhs
73
   // Sets the left-hand-side of the link
74
   //
75
   // Triggers the  callback.
76
   function void set_lhs(uvm_object lhs);
77
      do_set_lhs(lhs);
78
   endfunction : set_lhs
79
 
80
   // Function: get_lhs
81
   // Gets the left-hand-side of the link
82
   //
83
   // Triggers the  callback
84
   function uvm_object get_lhs();
85
      return do_get_lhs();
86
   endfunction : get_lhs
87
 
88
   // Function: set_rhs
89
   // Sets the right-hand-side of the link
90
   //
91
   // Triggers the  callback.
92
   function void set_rhs(uvm_object rhs);
93
      do_set_rhs(rhs);
94
   endfunction : set_rhs
95
 
96
   // Function: get_rhs
97
   // Gets the right-hand-side of the link
98
   //
99
   // Triggers the  callback
100
   function uvm_object get_rhs();
101
      return do_get_rhs();
102
   endfunction : get_rhs
103
 
104
   // Function: set
105
   // Convenience method for setting both sides in one call.
106
   //
107
   // Triggers both the  and  callbacks.
108
   function void set(uvm_object lhs, rhs);
109
      do_set_lhs(lhs);
110
      do_set_rhs(rhs);
111
   endfunction : set
112
 
113
   // Group: Implementation Callbacks
114
 
115
   // Function: do_set_lhs
116
   // Callback for setting the left-hand-side
117
   pure virtual function void do_set_lhs(uvm_object lhs);
118
 
119
   // Function: do_get_lhs
120
   // Callback for retrieving the left-hand-side
121
   pure virtual function uvm_object do_get_lhs();
122
 
123
   // Function: do_set_rhs
124
   // Callback for setting the right-hand-side
125
   pure virtual function void do_set_rhs(uvm_object rhs);
126
 
127
   // Function: do_get_rhs
128
   // Callback for retrieving the right-hand-side
129
   pure virtual function uvm_object do_get_rhs();
130
 
131
endclass : uvm_link_base
132
 
133
//------------------------------------------------------------------------------
134
//
135
// CLASS: uvm_parent_child_link
136
//
137
// The ~uvm_parent_child_link~ is used to represent a Parent/Child relationship
138
// between two objects.
139
//
140
 
141
class uvm_parent_child_link extends uvm_link_base;
142
 
143
   // Variable- m_lhs,m_rhs
144
   // Implementation details
145
   local uvm_object m_lhs;
146
   local uvm_object m_rhs;
147
 
148
   // Object utils
149
   `uvm_object_utils_begin(uvm_parent_child_link)
150
   `uvm_object_utils_end
151
 
152
   // Function: new
153
   // Constructor
154
   //
155
   // Parameters:
156
   // name - Instance name
157
   function new(string name="unnamed-uvm_parent_child_link");
158
      super.new(name);
159
   endfunction : new
160
 
161
   // Function: get_link
162
   // Constructs a pre-filled link
163
   //
164
   // This allows for simple one-line link creations.
165
   // | my_db.establish_link(uvm_parent_child_link::get_link(record1, record2));
166
   //
167
   // Parameters:
168
   // lhs - Left hand side reference
169
   // rhs - Right hand side reference
170
   // name - Optional name for the link object
171
   //
172
   static function uvm_parent_child_link get_link(uvm_object lhs,
173
                                                  uvm_object rhs,
174
                                                  string name="pc_link");
175
      uvm_parent_child_link pc_link = new(name);
176
      pc_link.set(lhs, rhs);
177
      return pc_link;
178
   endfunction : get_link
179
 
180
   // Group: Implementation Callbacks
181
 
182
   // Function: do_set_lhs
183
   // Sets the left-hand-side (Parent)
184
   //
185
   virtual function void do_set_lhs(uvm_object lhs);
186
      m_lhs = lhs;
187
   endfunction : do_set_lhs
188
 
189
   // Function: do_get_lhs
190
   // Retrieves the left-hand-side (Parent)
191
   //
192
   virtual function uvm_object do_get_lhs();
193
      return m_lhs;
194
   endfunction : do_get_lhs
195
 
196
   // Function: do_set_rhs
197
   // Sets the right-hand-side (Child)
198
   //
199
   virtual function void do_set_rhs(uvm_object rhs);
200
      m_rhs = rhs;
201
   endfunction : do_set_rhs
202
 
203
   // Function: do_get_rhs
204
   // Retrieves the right-hand-side (Child)
205
   //
206
   virtual function uvm_object do_get_rhs();
207
      return m_rhs;
208
   endfunction : do_get_rhs
209
 
210
endclass : uvm_parent_child_link
211
 
212
//------------------------------------------------------------------------------
213
//
214
// CLASS: uvm_cause_effect_link
215
//
216
// The ~uvm_cause_effect_link~ is used to represent a Cause/Effect relationship
217
// between two objects.
218
//
219
 
220
class uvm_cause_effect_link extends uvm_link_base;
221
 
222
   // Variable- m_lhs,m_rhs
223
   // Implementation details
224
   local uvm_object m_lhs;
225
   local uvm_object m_rhs;
226
 
227
   // Object utils
228
   `uvm_object_utils_begin(uvm_cause_effect_link)
229
   `uvm_object_utils_end
230
 
231
   // Function: new
232
   // Constructor
233
   //
234
   // Parameters:
235
   // name - Instance name
236
   function new(string name="unnamed-uvm_cause_effect_link");
237
      super.new(name);
238
   endfunction : new
239
 
240
   // Function: get_link
241
   // Constructs a pre-filled link
242
   //
243
   // This allows for simple one-line link creations.
244
   // | my_db.establish_link(uvm_cause_effect_link::get_link(record1, record2));
245
   //
246
   // Parameters:
247
   // lhs - Left hand side reference
248
   // rhs - Right hand side reference
249
   // name - Optional name for the link object
250
   //
251
   static function uvm_cause_effect_link get_link(uvm_object lhs,
252
                                                 uvm_object rhs,
253
                                                 string name="ce_link");
254
      uvm_cause_effect_link ce_link = new(name);
255
      ce_link.set(lhs, rhs);
256
      return ce_link;
257
   endfunction : get_link
258
 
259
   // Group: Implementation Callbacks
260
 
261
   // Function: do_set_lhs
262
   // Sets the left-hand-side (Cause)
263
   //
264
   virtual function void do_set_lhs(uvm_object lhs);
265
      m_lhs = lhs;
266
   endfunction : do_set_lhs
267
 
268
   // Function: do_get_lhs
269
   // Retrieves the left-hand-side (Cause)
270
   //
271
   virtual function uvm_object do_get_lhs();
272
      return m_lhs;
273
   endfunction : do_get_lhs
274
 
275
   // Function: do_set_rhs
276
   // Sets the right-hand-side (Effect)
277
   //
278
   virtual function void do_set_rhs(uvm_object rhs);
279
      m_rhs = rhs;
280
   endfunction : do_set_rhs
281
 
282
   // Function: do_get_rhs
283
   // Retrieves the right-hand-side (Effect)
284
   //
285
   virtual function uvm_object do_get_rhs();
286
      return m_rhs;
287
   endfunction : do_get_rhs
288
 
289
endclass : uvm_cause_effect_link
290
 
291
//------------------------------------------------------------------------------
292
//
293
// CLASS: uvm_related_link
294
//
295
// The ~uvm_related_link~ is used to represent a generic "is related" link
296
// between two objects.
297
//
298
 
299
class uvm_related_link extends uvm_link_base;
300
 
301
   // Variable- m_lhs,m_rhs
302
   // Implementation details
303
   local uvm_object m_lhs;
304
   local uvm_object m_rhs;
305
 
306
   // Object utils
307
   `uvm_object_utils_begin(uvm_related_link)
308
   `uvm_object_utils_end
309
 
310
   // Function: new
311
   // Constructor
312
   //
313
   // Parameters:
314
   // name - Instance name
315
   function new(string name="unnamed-uvm_related_link");
316
      super.new(name);
317
   endfunction : new
318
 
319
   // Function: get_link
320
   // Constructs a pre-filled link
321
   //
322
   // This allows for simple one-line link creations.
323
   // | my_db.establish_link(uvm_related_link::get_link(record1, record2));
324
   //
325
   // Parameters:
326
   // lhs - Left hand side reference
327
   // rhs - Right hand side reference
328
   // name - Optional name for the link object
329
   //
330
   static function uvm_related_link get_link(uvm_object lhs,
331
                                                 uvm_object rhs,
332
                                                 string name="ce_link");
333
      uvm_related_link ce_link = new(name);
334
      ce_link.set(lhs, rhs);
335
      return ce_link;
336
   endfunction : get_link
337
 
338
   // Group: Implementation Callbacks
339
 
340
   // Function: do_set_lhs
341
   // Sets the left-hand-side
342
   //
343
   virtual function void do_set_lhs(uvm_object lhs);
344
      m_lhs = lhs;
345
   endfunction : do_set_lhs
346
 
347
   // Function: do_get_lhs
348
   // Retrieves the left-hand-side
349
   //
350
   virtual function uvm_object do_get_lhs();
351
      return m_lhs;
352
   endfunction : do_get_lhs
353
 
354
   // Function: do_set_rhs
355
   // Sets the right-hand-side
356
   //
357
   virtual function void do_set_rhs(uvm_object rhs);
358
      m_rhs = rhs;
359
   endfunction : do_set_rhs
360
 
361
   // Function: do_get_rhs
362
   // Retrieves the right-hand-side
363
   //
364
   virtual function uvm_object do_get_rhs();
365
      return m_rhs;
366
   endfunction : do_get_rhs
367
 
368
endclass : uvm_related_link
369
 
370
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.