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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [uvm_src/] [comps/] [uvm_policies.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-2010 Cadence Design Systems, Inc.
5
//   Copyright 2010 Synopsys, Inc.
6
//   All Rights Reserved Worldwide
7
//
8
//   Licensed under the Apache License, Version 2.0 (the
9
//   "License"); you may not use this file except in
10
//   compliance with the License.  You may obtain a copy of
11
//   the License at
12
//
13
//       http://www.apache.org/licenses/LICENSE-2.0
14
//
15
//   Unless required by applicable law or agreed to in
16
//   writing, software distributed under the License is
17
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
18
//   CONDITIONS OF ANY KIND, either express or implied.  See
19
//   the License for the specific language governing
20
//   permissions and limitations under the License.
21
//----------------------------------------------------------------------
22
 
23
 
24
// Title: Policy Classes
25
//
26
// Policy classes are used to implement polymorphic operations that
27
// differ between built-in types and class-based types. Generic
28
// components can then be built that work with either classes or
29
// built-in types, depending on what policy class is used.
30
 
31
 
32
//----------------------------------------------------------------------
33
// CLASS: uvm_built_in_comp #(T)
34
//
35
// This policy class is used to compare built-in types.
36
//
37
// Provides a comp method that compares the built-in type,
38
// T, for which the == operator is defined.
39
//----------------------------------------------------------------------
40
 
41
class uvm_built_in_comp #(type T=int);
42
 
43
  static function bit comp(T a, T b);
44
    return a == b;
45
  endfunction
46
 
47
endclass
48
 
49
 
50
//----------------------------------------------------------------------
51
// CLASS: uvm_built_in_converter #(T)
52
//
53
// This policy class is used to convert built-in types to strings.
54
//
55
// Provides a convert2string method that converts the built-in type, T,
56
// to a string using the %p format specifier.
57
//----------------------------------------------------------------------
58
 
59
class uvm_built_in_converter #(type T=int);
60
  static function string convert2string(input T t);
61
    return $sformatf("%p" , t );
62
  endfunction
63
endclass
64
 
65
 
66
//----------------------------------------------------------------------
67
// CLASS: uvm_built_in_clone #(T)
68
//
69
// This policy class is used to clone built-in types via the = operator.
70
//
71
// Provides a clone method that returns a copy of the built-in type, T.
72
//----------------------------------------------------------------------
73
 
74
class uvm_built_in_clone #(type T=int);
75
 
76
  static function T clone(input T from);
77
    return from;
78
  endfunction
79
 
80
endclass
81
 
82
 
83
//----------------------------------------------------------------------
84
// CLASS: uvm_class_comp #(T)
85
//
86
// This policy class is used to compare two objects of the same type.
87
//
88
// Provides a comp method that compares two objects of type T. The
89
// class T must provide the method "function bit compare(T rhs)",
90
// similar to the  method.
91
//----------------------------------------------------------------------
92
 
93
class uvm_class_comp #(type T=int);
94
 
95
  static function bit comp(input T a, input T b);
96
    return a.compare(b);
97
  endfunction
98
 
99
endclass
100
 
101
 
102
//----------------------------------------------------------------------
103
// CLASS: uvm_class_converter #(T)
104
//
105
// This policy class is used to convert a class object to a string.
106
//
107
// Provides a convert2string method that converts an instance of type T
108
// to a string. The class T must provide the method
109
// "function string convert2string()",
110
// similar to the  method.
111
//----------------------------------------------------------------------
112
 
113
class uvm_class_converter #(type T=int);
114
 
115
  static function string convert2string(input T t);
116
    return t.convert2string();
117
  endfunction
118
 
119
endclass
120
 
121
 
122
//----------------------------------------------------------------------
123
// CLASS: uvm_class_clone #(T)
124
//
125
// This policy class is used to clone class objects.
126
//
127
// Provides a clone method that returns a copy of the built-in type, T.
128
// The class T must implement the clone method, to which this class
129
// delegates the operation. If T is derived from , then
130
// T must instead implement , either directly or
131
// indirectly through use of the `uvm_field macros.
132
//----------------------------------------------------------------------
133
 
134
class uvm_class_clone #(type T=int);
135
 
136
  static function uvm_object clone(input T from);
137
    return from.clone();
138
  endfunction
139
 
140
endclass
141
 

powered by: WebSVN 2.1.0

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