I am trying to constrain the sum of each column of a 2D array to certain values provided by another array but I am getting an error “cannot mix packed and unpacked types in this operation”. I think I am using unpacked arrays all along in my example shown below so can someone please explain where exactly I am making a mistake here.
class sample;
rand int arr[2][4];
int a[4] = '{9,7,6,5};
constraint x{
foreach(arr[i,j]){
arr[i][j]>0;
arr[i][j]<10;
}}
constraint xy{
foreach(a[i]){
(arr.sum with ((item.index(2)==i)?item:0)) == a[i];
}
}
endclass
module tb;
sample s=new();
initial begin
s.randomize();
$display("%p",s.arr);
end
endmodule