Skip to content

Commit fd566bf

Browse files
martin-velayrswarbrick
authored andcommitted
[dv] Add do_compare function to tl_agent
- declare do_compare method which will be automatically called by the uvm_object compare() method. This implementation is not comparing all the fields of the sequence item as they don't all make sense to be compared. Signed-off-by: Martin Velay <[email protected]>
1 parent c7a0ce1 commit fd566bf

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

hw/dv/sv/tl_agent/tl_seq_item.sv

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,37 @@ class tl_seq_item extends uvm_sequence_item;
202202
return str;
203203
endfunction
204204

205+
// Note: the do_compare() method should only be coded for those properties which can be compared
206+
// that's the reason why the following fields are not part it:
207+
// req_abort_after_a_valid_len, rsp_abort_after_d_valid_len, req_completed, rsp_completed
208+
function bit do_compare(uvm_object rhs, uvm_comparer comparer);
209+
tl_seq_item rhs_;
210+
// If the cast fails, comparison has also failed
211+
// A check for null is not needed because that is done in the compare() function which
212+
// calls do_compare()
213+
if (!$cast(rhs_, rhs)) begin
214+
return 0;
215+
end
216+
217+
return (super.do_compare(rhs, comparer) &&
218+
(a_addr == rhs_.a_addr ) &&
219+
(a_data == rhs_.a_data ) &&
220+
(a_mask == rhs_.a_mask ) &&
221+
(a_size == rhs_.a_size ) &&
222+
(a_param == rhs_.a_param ) &&
223+
(a_source == rhs_.a_source ) &&
224+
(a_opcode == rhs_.a_opcode ) &&
225+
(a_user == rhs_.a_user ) &&
226+
(d_data == rhs_.d_data ) &&
227+
(d_size == rhs_.d_size ) &&
228+
(d_param == rhs_.d_param ) &&
229+
(d_source == rhs_.d_source ) &&
230+
(d_opcode == rhs_.d_opcode ) &&
231+
(d_error == rhs_.d_error ) &&
232+
(d_user == rhs_.d_user ) &&
233+
(d_sink == rhs_.d_sink ));
234+
endfunction : do_compare
235+
205236
function void disable_a_chan_randomization();
206237
a_addr.rand_mode(0);
207238
a_data.rand_mode(0);

0 commit comments

Comments
 (0)