SyoSil ApS UVM Scoreboard  1.0.3.0
cl_syoscb_comparer_config.svh
1 /// Utility class used to perform manipulations of uvm_comparer objects.
2 /// Contains a number of functions that simplify uvm_comparer related code, as the comparer API
3 /// differs based on the UVM version used.
4 /// These functions encapsulate those differences, providing a unified API regardless of UVM version.
5 class cl_syoscb_comparer_config extends uvm_object;
6  //-------------------------------------
7  // Non randomizable variables
8  //-------------------------------------
9 
10 
11  //-------------------------------------
12  // UVM Macros
13  //-------------------------------------
14  `uvm_object_utils_begin(cl_syoscb_comparer_config)
15 
16  `uvm_object_utils_end
17 
18  //-------------------------------------
19  // Constructor
20  //-------------------------------------
21  extern function new(string name = "cl_syoscb_comparer_config");
22 
23  //-------------------------------------
24  // Functions
25  //-------------------------------------
26 
27  extern static function void set_verbosity(uvm_comparer comparer, int unsigned cv = UVM_DEBUG);
28  extern static function int unsigned get_verbosity(uvm_comparer comparer);
29  extern static function void copy_comparer(uvm_comparer from, uvm_comparer to);
30  extern static function string get_miscompares_from_comparer(uvm_comparer comparer);
31  extern static function void do_help_pack(uvm_comparer comparer, uvm_packer packer);
32  extern static function uvm_comparer do_help_unpack(uvm_packer packer);
33  extern static function void set_show_max(uvm_comparer comparer, int unsigned sm);
34  extern static function int unsigned get_show_max(uvm_comparer comparer);
35 
37 
38 function cl_syoscb_comparer_config::new(string name = "cl_syoscb_comparer_config");
39  super.new(name);
40 endfunction: new
41 
42 /// Sets the verbosity level of a given comparer
43 ///
44 /// \param comparer The comparer object on which to set a new verbosity level
45 /// \param cv The new comparer verbosity level
46 function void cl_syoscb_comparer_config::set_verbosity(uvm_comparer comparer, int unsigned cv = UVM_DEBUG);
47  `ifdef UVM_VERSION
48  comparer.set_verbosity(cv);
49  `else
50  comparer.verbosity = cv;
51  `endif
52 endfunction: set_verbosity
53 
54 /// Gets the verbosity level for a given comparer
55 ///
56 /// \param comparer The comparer object for which to get the verbosity level
57 /// \return That comparer's verbosity level
58 function int unsigned cl_syoscb_comparer_config::get_verbosity(uvm_comparer comparer);
59  `ifdef UVM_VERSION
60  return comparer.get_verbosity();
61  `else
62  return comparer.verbosity;
63  `endif
64 endfunction: get_verbosity
65 
66 /// Copies all config information from one comparer into another.
67 ///
68 /// \param from Comparer containing the data to be copied
69 /// \param to Comparer to inherit configuration data in \c from
70 function void cl_syoscb_comparer_config::copy_comparer(uvm_comparer from, uvm_comparer to);
71  `ifdef UVM_VERSION
72  to.set_result(from.get_result());
73  to.set_recursion_policy(from.get_recursion_policy());
74  to.set_check_type(from.get_check_type());
75  to.set_show_max(from.get_show_max());
76  to.set_verbosity(from.get_verbosity());
77  to.set_severity(from.get_severity());
78  to.set_threshold(from.get_threshold());
79  `else
80  to.policy = from.policy;
81  to.show_max = from.show_max;
82  to.verbosity = from.verbosity;
83  to.sev = from.sev;
84  to.miscompares = from.miscompares;
85  to.physical = from.physical;
86  to.abstract = from.abstract;
87  to.check_type = from.check_type;
88  to.result = from.result;
89  `endif
90 endfunction: copy_comparer
91 
92 /// Packs all configuration data for the given uvm_comparer using the given uvm_packer.
93 /// Since uvm_comparer does not natively support pack/unpack operations,
94 /// these helper methods can be used to pack/unpack a comparer
95 ///
96 /// \param comparer The uvm_comparer for which all configuration values should be packed
97 /// \param packer The uvm_packer to use when packing the item
98 function void cl_syoscb_comparer_config::do_help_pack(uvm_comparer comparer, uvm_packer packer);
99  // This function is primarily meant to be used in cl_syoscb_cfg::do_pack to pack comparers
100  int unsigned result;
101  uvm_recursion_policy_enum policy;
102  bit check_type;
103  int unsigned show_max;
104  uvm_severity sev;
105  int unsigned verbosity;
106  int unsigned threshold;
107 
108  //Pack 4 bits to indicate if the comparer is null or non-null
109  if(comparer != null) begin
110  packer.pack_field_int(1, 4);
111  end else begin
112  packer.pack_field_int(0, 4);
113  return;
114  end
115 
116  `ifdef UVM_VERSION
117  result = comparer.get_result();
118  policy = comparer.get_recursion_policy();
119  check_type = comparer.get_check_type();
120  show_max = comparer.get_show_max();
121  sev = comparer.get_severity();
122  verbosity = comparer.get_verbosity();
123  threshold = comparer.get_threshold();
124  `else
125  result = comparer.result;
126  policy = comparer.policy;
127  check_type = comparer.check_type;
128  show_max = comparer.show_max;
129  sev = comparer.sev;
130  verbosity = comparer.verbosity;
131  threshold = 1; //Threshold value is not readable if UVM_VERSION is not set, defaults to 1
132  `endif
133 
134  packer.pack_field_int(result, $bits(result));
135  packer.pack_field_int(policy, $bits(policy));
136  packer.pack_field_int(check_type, $bits(check_type));
137  packer.pack_field_int(show_max, $bits(show_max));
138  packer.pack_field_int(sev, $bits(sev));
139  packer.pack_field_int(verbosity, $bits(verbosity));
140  packer.pack_field_int(threshold, $bits(threshold));
141 
142 endfunction: do_help_pack
143 
144 /// Unpacks comparer configuration data and returns a comparer with that configuration.
145 /// Since uvm_comparer does not natively support pack/unpack operations,
146 /// these helper methods can be used to pack/unpack a comparer
147 ///
148 /// \param packer The uvm_packer that was previously used to pack a \c uvm_comparer
149 /// \return A uvm_comparer with the packed configuration
150 function uvm_comparer cl_syoscb_comparer_config::do_help_unpack(uvm_packer packer);
151  // This function is primarily used in cl_syoscb_cfg::do_unpack to unpack configuration data
152  uvm_comparer comparer;
153  int unsigned result;
154  uvm_recursion_policy_enum policy;
155  bit check_type;
156  int unsigned show_max;
157  uvm_severity sev;
158  int unsigned verbosity;
159  int unsigned threshold;
160  int policy_value;
161  int sev_value;
162 
163  bit [3:0] is_null;
164 
165  is_null = packer.unpack_field_int($bits(is_null));
166 
167  if(is_null == 4'b0) begin
168  return null;
169  end
170 
171  result = packer.unpack_field_int($bits(result));
172  policy_value = packer.unpack_field_int($bits(policy));
173  check_type = packer.unpack_field_int($bits(check_type));
174  show_max = packer.unpack_field_int($bits(show_max));
175  sev_value = packer.unpack_field_int($bits(sev));
176  verbosity = packer.unpack_field_int($bits(verbosity));
177  threshold = packer.unpack_field_int($bits(threshold));
178 
179  //To conform to strong enum typing, we must use this workaround when assigning the value of policy
180  //Iterate through all possible enumeration values, check if they match retrieved value.
181  //If not, throw an error
182  policy = policy.first();
183  while(policy != policy_value && policy != policy.last()) begin
184  policy = policy.next();
185  end
186  if(policy != policy_value) begin
187  `uvm_error("ENUM_DECODE", $sformatf("Unable to interpret 'policy' enum. Unpacked value was %0d which is not valid", policy_value));
188  end
189 
190  //In UVM 1.1d, sev is not an enum - instead we simply enumerate all possible values
191  if(sev_value == UVM_INFO) begin
192  sev = UVM_INFO;
193  end else if (sev_value == UVM_WARNING) begin
194  sev = UVM_WARNING;
195  end else if (sev_value == UVM_ERROR) begin
196  sev = UVM_ERROR;
197  end else if (sev_value == UVM_FATAL) begin
198  sev = UVM_FATAL;
199  end else begin
200  `uvm_error("ENUM_DECODE", $sformatf("Unable to interpret 'sev' enum. Unpacked value was %0d which is not valid", sev_value))
201  end
202 
203  comparer = new;
204 
205  `ifdef UVM_VERSION
206  comparer.set_result(result);
207  comparer.set_recursion_policy(policy);
208  comparer.set_check_type(check_type);
209  comparer.set_show_max(show_max);
210  comparer.set_severity(sev);
211  comparer.set_verbosity(verbosity);
212  comparer.set_threshold(threshold);
213 `else
214  comparer.result = result;
215  comparer.policy = policy;
216  comparer.check_type = check_type;
217  comparer.show_max = show_max;
218  comparer.sev = sev;
219  comparer.verbosity = verbosity;
220  //Threshold value is not readable if UVM_VERSION is not set, defaults to 1
221 `endif
222 
223  return comparer;
224 endfunction: do_help_unpack
225 
226 /// Returns a string containing all miscompares from the given comparer.
227 ///
228 /// \param comparer The comparer from which to get all miscompares
229 /// \return A string containing information about the miscompares in the comparer
230 function string cl_syoscb_comparer_config::get_miscompares_from_comparer(uvm_comparer comparer);
231  `ifdef UVM_VERSION
232  return comparer.get_miscompares();
233  `else
234  return comparer.miscompares;
235  `endif
237 
238 /// Sets the value of the \c show_max knob in the given comparer.
239 ///
240 /// \param comparer The comparer to set the show_max knob for
241 /// \param sm The new value of the show_max knob
242 function void cl_syoscb_comparer_config::set_show_max(uvm_comparer comparer, int unsigned sm);
243  `ifdef UVM_VERSION
244  comparer.set_show_max(sm);
245  `else
246  comparer.show_max = sm;
247  `endif
248 endfunction: set_show_max
249 
250 /// Gets the value of the \c show_max knob in the given comparer
251 ///
252 /// \param comparer The comparer to get the show_max knob for
253 /// \return The value of show_max in the given comparer
254 function int unsigned cl_syoscb_comparer_config::get_show_max(uvm_comparer comparer);
255  `ifdef UVM_VERSION
256  return comparer.get_show_max();
257  `else
258  return comparer.show_max;
259  `endif
260 endfunction: get_show_max
static void set_verbosity(uvm_comparer comparer, int unsigned cv=UVM_DEBUG)
Sets the verbosity level of a given comparer.
static void copy_comparer(uvm_comparer from, uvm_comparer to)
Copies all config information from one comparer into another.
static string get_miscompares_from_comparer(uvm_comparer comparer)
Returns a string containing all miscompares from the given comparer.
static void do_help_pack(uvm_comparer comparer, uvm_packer packer)
Packs all configuration data for the given uvm_comparer using the given uvm_packer.
static void set_show_max(uvm_comparer comparer, int unsigned sm)
Sets the value of the show_max knob in the given comparer.
static uvm_comparer do_help_unpack(uvm_packer packer)
Unpacks comparer configuration data and returns a comparer with that configuration.
Utility class used to perform manipulations of uvm_comparer objects.
static int unsigned get_verbosity(uvm_comparer comparer)
Gets the verbosity level for a given comparer.
static int unsigned get_show_max(uvm_comparer comparer)
Gets the value of the show_max knob in the given comparer.

Project: SyoSil ApS UVM Scoreboard, Revision: 1.0.3.0

Copyright 2014-2022 SyoSil ApS
All Rights Reserved Worldwide

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
doxygen
Doxygen Version: 1.8.14
Generated with IDV SV Filter Version: 2.6.3
Fri Sep 2 2022 14:39:09
Find a documentation bug? Report bugs to: scoreboard@syosil.com