Compilation error using compare_field

Hi,

I am making a UVM environment and I have problems with

comparer.compare_field

I have this variable in the transaction class

rand logic [1:0][8:0] A [3:0];

and also I have a method

do_compare

where I have the following line of code

result &= comparer.compare_field("A", A, rhs_.A, $bits(A));

the compiler will exit with the error

(vlog-13215) Arg. 'lhs' of 'compare_field':  Cannot assign an unpacked type 'reg[8:0][1:0] $[3:0]' to a packed type 'reg signed[4095:0]'.

What does this mean? How can I mend it?

Thanks,
Marc

In reply to Marc43:

Your variable A is an unpacked array. having 1 unpacked dimension. But the argument is exüecting an object. See the UVM Reference Manual.

In reply to chr_sue:

In reply to Marc43:
Your variable A is an unpacked array. having 1 unpacked dimension. But the argument is exüecting an object. See the UVM Reference Manual.

Hi chr_sue, thanks for your reply.

I looked at the UVM Reference Manual, I see that there are four types: compare_field, compare_field_real, compare_object and compare_string. Respectively they expect a uvm_integral_t, real, uvm_object and string. None of them seems to fit for an unpacked array, how would you do this?

In reply to Marc43:

You need to put the compare in a foreach loop

foreach(A[ii])
result &= comparer.compare_field($sprintf("A[%0d]",ii)", A[ii], rhs_.A[ii], $bits(A[ii]));