Write a constraint to an array
1.array elements sum=50
2.at least one element should be multiple of 7
3.we need to come up with constraint for array size based on above two constraints
module multi7;
class mul7;
rand bit[5:0] a[];
constraint c1
{
a.size() inside {[2:44]};
a.sum with (int'(item)) == 50;
a.sum with ((item%7==0) >= 1) == 50;//this constraint is wrong and not getting multiple of 7
}
endclass
initial begin
static mul7 m1=new;
m1.randomize();
//$display("values:%p",m1.a);
foreach(m1.a[i])
$display("%d ",m1.a[i]);
end
endmodule