SyoSil ApS UVM Scoreboard  1.0.3.0
pk_utils_uvm.sv
1 // ------------------------------------------------------------------------
2 // Classes for UVM utilities
3 // ------------------------------------------------------------------------
4 `ifndef __UTILS_UVM__
5 `define __UTILS_UVM__
6 package pk_utils_uvm;
7 
8  `include "uvm_macros.svh"
9  import uvm_pkg::*;
10 
11  /// Base class for a filter transformation.
12  /// If type IN is a subtype of uvm_sequence_item, this filter transforms simply performs
13  /// an identity transform by upcasting the input item to a uvm_sequence_item
14  /// If another transformation is desired, extend the class and override the #evaluate
15  /// and #transform methods
16  /// \param IN Input type of objects to transform
17  /// \param OUT Output type of transformed objects
18  class filter_trfm #(type IN = int, type OUT = uvm_sequence_item) extends uvm_subscriber #(IN);
19  /// Analysis port where transformed items are output
20  uvm_analysis_port#(OUT) ap;
21 
22  //--------------------------------------
23  // UVM macros
24  //--------------------------------------
25  `uvm_component_param_utils(filter_trfm#(IN, OUT))
26 
27  //--------------------------------------
28  // Constructor
29  //--------------------------------------
30  function new(string name = "", uvm_component parent = null);
31  super.new(name, parent);
32 
33  this.ap = new("ap", this);
34  endfunction : new
35 
36  /// Transforms the item of type IN to one or more items of type OUT
37  /// \param t The input object which should be transformed
38  /// \param items A reference to an array where output items will be returned.
39  /// If the handle is to an existing array, that array will be lost.
40  virtual function void transform(IN t, output OUT items[]);
41  items = new[1];
42 
43  items[0] = t;
44  endfunction : transform
45 
46  /// Evaluates whether the input should be transformed and forwarded, or whether it should be discarded.
47  /// If the method returns 0, the input item is discarded and may not be retrievable
48  /// \return 1 if the item should be transformed and forwarded, 0 otherwise.
49  virtual function bit evaluate(IN t);
50  return(1'b1);
51  endfunction : evaluate
52 
53  /// This filter transform's write-implementation from uvm_subscriber
54  /// When items are written to the filter transform, they are first evaluated with #evaluate to
55  /// decide whether a transformation should occur. If true, they are transformed with
56  /// #transform, and all output items are then written out on #ap
57  /// \param t The item written to this filter transform
58  function void write(IN t);
59  if(this.evaluate(t) == 1'b1) begin
60  OUT items[];
61 
62  this.transform(t, items);
63 
64  foreach (items[i]) begin
65  this.ap.write(items[i]);
66  end
67  end
68  endfunction : write
69  endclass : filter_trfm
70 endpackage : pk_utils_uvm
71 `endif // __UTILS_UVM__
virtual void transform(IN t, output OUT items[])
Transforms the item of type IN to one or more items of type OUT.
Definition: pk_utils_uvm.sv:40
virtual bit evaluate(IN t)
Evaluates whether the input should be transformed and forwarded, or whether it should be discarded...
Definition: pk_utils_uvm.sv:49
Base class for a filter transformation.
Definition: pk_utils_uvm.sv:18

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:40:32
Find a documentation bug? Report bugs to: scoreboard@syosil.com