I am trying to solve the below constraint, and i see constraint solver issue, Can you please help identify the issue?
An array has size 10 integers, 4 elements should be unique, Rest 6 elements should have 3 pairs of duplicates.
class packet;
rand int unsigned a[10];
rand int unsigned b[3];
rand int unsigned c[4];
constraint a_b {
foreach(b[i]){
a.sum(item) with (item == b[i]) == 2;
}
foreach(c[i]){
a.sum(item) with (item == c[i]) == 1;
}
}
constraint c_c{
unique{c,b};
}
endclass
module constr;
initial begin
packet pkt;
pkt = new();
//repeat(10) begin
pkt.randomize();
$display("\tValue of a = %p, b = %p, c = %p",pkt.a,pkt.b, pkt.c);
//end
end
endmodule
Solver failed when solving following set of constraints
rand bit[31:0] b[2]; // rand_mode = ON
rand bit[31:0] a[0]; // rand_mode = ON
rand bit[31:0] a[1]; // rand_mode = ON
rand bit[31:0] a[2]; // rand_mode = ON
rand bit[31:0] a[3]; // rand_mode = ON
rand bit[31:0] a[4]; // rand_mode = ON
rand bit[31:0] a[5]; // rand_mode = ON
rand bit[31:0] a[6]; // rand_mode = ON
rand bit[31:0] a[7]; // rand_mode = ON
rand bit[31:0] a[8]; // rand_mode = ON
rand bit[31:0] a[9]; // rand_mode = ON
constraint a_b // (from this) (constraint_mode = ON) (testbench.sv:9)
{
((1’(((((((((((a[0] == b[2]) + (a[1] == b[2])) + (a[2] == b[2])) + (a[3] == b[2])) + (a[4] == b[2])) + (a[5] == b[2])) + (a[6] == b[2])) + (a[7] == b[2])) + (a[8] == b[2])) + (a[9] == b[2])))) == 2);
}