SyoSil ApS UVM Scoreboard  1.0.3.0
cl_syoscb_item.svh
1 /// The UVM scoreboard item which wraps uvm_sequence_item . This ensures that future
2 /// extensions to the UVM scoreboard will always be able to use all uvm_sequence_items from
3 /// already existing testbenches etc. even though more META data is added to the wrapping item.
4 class cl_syoscb_item extends uvm_object;
5  //-------------------------------------
6  // Non randomizable variables
7  //-------------------------------------
8  /// Name of the producer that generated this seq. item
9  local string producer;
10 
11  /// Handle to the wrapped uvm_sequence_item
12  local uvm_sequence_item item;
13 
14  /// Insertion index N means that this is the N'th item inserted in that queue
15  local longint unsigned insertion_index;
16 
17  /// This item's position in the queue.
18  /// This field is only valid when the queue is dumped, as a queue index may change
19  /// throughout simulation as items ahead of this item are removed from the queue.
20  local longint queue_index;
21 
22  //-------------------------------------
23  // UVM Macros
24  //-------------------------------------
25  `uvm_object_utils_begin(cl_syoscb_item)
26  `uvm_field_int(insertion_index, UVM_DEFAULT | UVM_NOCOMPARE | UVM_NOPACK | UVM_DEC)
27  `uvm_field_int(queue_index, UVM_DEFAULT | UVM_NOCOMPARE | UVM_NOPACK | UVM_DEC)
28  `ifdef SYOSIL_APPLY_TLM_GP_CMP_WORKAROUND
29  `uvm_field_string(producer, UVM_DEFAULT | UVM_NOCOMPARE)
30  `uvm_field_object(item, UVM_DEFAULT | UVM_NOCOMPARE)
31  `else
32  `uvm_field_string(producer, UVM_DEFAULT)
33  `uvm_field_object(item, UVM_DEFAULT)
34  `endif
35  `uvm_object_utils_end
36 
37  //-------------------------------------
38  // Constructor
39  //-------------------------------------
40  function new(string name = "cl_syoscb_item");
41  super.new(name);
42  endfunction : new
43 
44  //-------------------------------------
45  // Item API
46  //-------------------------------------
47  extern virtual function string get_producer();
48  extern virtual function void set_producer(string producer);
49  extern virtual function uvm_sequence_item get_item();
50  extern virtual function void set_item(uvm_sequence_item item);
51 
52  extern virtual function void set_insertion_index(longint unsigned ii);
53  extern virtual function longint unsigned get_insertion_index();
54  extern virtual function void set_queue_index(longint qi);
55  extern virtual function longint get_queue_index();
56 
57  extern virtual function string convert2string();
58 
59 `ifdef SYOSIL_APPLY_TLM_GP_CMP_WORKAROUND
60  //-------------------------------------
61  // UVM TLM2 Generic Payload compare
62  // workaround
63  //-------------------------------------
64  //If a miscompare happens when comparing two GP items, the miscompare is printed as a UVM_INFO
65  //message by default and the comparison returns 1'b1, where it should return 1'b0;
66  //To fix this, we manually compare the GP items as ordinary objects using comparer::compare_object.
67  //This ensures that we properly raise a UVM_ERROR if the GP items are not the same.
68  function bit do_compare(uvm_object rhs, uvm_comparer comparer);
69  bit status = 1'b1;
70  cl_syoscb_item that;
71 
72  // Code it properly using the comparer policy
73  if(!$cast(that, rhs)) begin
74  status = 1'b0;
75  end else begin
76  // "producer" compare using the comparer object
77  status &= comparer.compare_string("producer", this.producer, that.producer);
78 
79  // Apply WORKAROUND:
80  // Ensure that the comparer object is properly updated at this level
81  // and propagate the compare result bit correctly
82  status &= comparer.compare_object("item", this.item, that.item);
83  end
84  return(status);
85  endfunction: do_compare
86 `endif
87 endclass: cl_syoscb_item
88 
89 /// <b>Item API:</b> Returns the producer of the wrapped sequence item
90 function string cl_syoscb_item::get_producer();
91  return this.producer;
92 endfunction: get_producer
93 
94 /// <b>Item API:</b> Sets the producer of the wrapped sequence item.
95 /// The validity of the producer name must be checked by the caller before setting it in this item.
96 /// \param producer The name of the producer of the wrapped seq. item.
97 function void cl_syoscb_item::set_producer(string producer);
98  // The producer has been checked by the parent prior
99  // to the insertion
100  this.producer = producer;
101 endfunction: set_producer
102 
103 /// <b>Item API:</b> Returns the wrapped uvm_sequence_item
104 function uvm_sequence_item cl_syoscb_item::get_item();
105  return this.item;
106 endfunction: get_item
107 
108 /// <b>Item API:</b> Sets the uvm_sequence_item wrapped by this wrapper item
109 function void cl_syoscb_item::set_item(uvm_sequence_item item);
110  this.item = item;
111 endfunction: set_item
112 
113 /// <b>Item API:</b> Gets the insertion index of the wrapped sequence item
114 function void cl_syoscb_item::set_insertion_index(longint unsigned ii);
115  this.insertion_index = ii;
116 endfunction: set_insertion_index
117 
118 /// <b>Item API:</b> Sets the insertion index of the wrapped sequence item
119 function longint unsigned cl_syoscb_item::get_insertion_index();
120  return this.insertion_index;
121 endfunction: get_insertion_index
122 
123 /// <b>Item API:</b> Sets the queue index of the wrapped sequence item
124 function void cl_syoscb_item::set_queue_index(longint qi);
125  this.queue_index = qi;
126 endfunction: set_queue_index
127 
128 /// <b>Item API:</b> Gets the queue index of the wrapped sequence item
130  return this.queue_index;
131 endfunction: get_queue_index
132 
133 /// Converts a cl_syoscb_item to a compact string representation.
134 /// Does this by simply returning the convert2string-implementation of the wrapped sequence item.
135 /// \note Raises a warning if newlines are contained in the output, as this may make the output uglier
137  string c2s;
138  c2s = this.item.convert2string();
139 
140  //Check if newlines exist and a warning should be generated
141  for(int i=0; i<c2s.len(); i++) begin
142  if(c2s[i] == "\n") begin
143  `uvm_warning("C2S_WARNING", $sformatf(
144  {"The convert2string()-implementation of type %s contains newlines.\n",
145  "Consider removing these for prettier scb dumps when cfg.enable_c2s_full_scb_dump is set."},
146  this.item.get_type_name()))
147  break;
148  end
149  end
150 
151  return c2s;
152 endfunction: convert2string
virtual longint get_queue_index()
Item API: Gets the queue index of the wrapped sequence item
string producer
Name of the producer that generated this seq. item.
virtual void set_producer(string producer)
Item API: Sets the producer of the wrapped sequence item.
The UVM scoreboard item which wraps uvm_sequence_item .
uvm_sequence_item item
Handle to the wrapped uvm_sequence_item.
virtual longint unsigned get_insertion_index()
Item API: Sets the insertion index of the wrapped sequence item
virtual string convert2string()
Converts a cl_syoscb_item to a compact string representation.
virtual void set_queue_index(longint qi)
Item API: Sets the queue index of the wrapped sequence item
virtual void set_insertion_index(longint unsigned ii)
Item API: Gets the insertion index of the wrapped sequence item
longint unsigned insertion_index
Insertion index N means that this is the N&#39;th item inserted in that queue.
virtual void set_item(uvm_sequence_item item)
Item API: Sets the uvm_sequence_item wrapped by this wrapper item
virtual uvm_sequence_item get_item()
Item API: Returns the wrapped uvm_sequence_item
virtual string get_producer()
Item API: Returns the producer of the wrapped sequence item
longint queue_index
This item&#39;s position in the queue.

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