In reply to dave_59:
Hi Dave,
.and reduction and also .product reduction worked perfectly for these cases.
cnum.product with (int'(item.index%2?item:!item))==1;
'{'h0, 'h1, 'h0, 'h1, 'h0, 'h1, 'h0, 'h1, 'h0, 'h1, 'h0, 'h1, 'h0, 'h1, 'h0, 'h1}
But I fail to understand why .sum would not work. Here is my understanding on what was supposed to happen with .sum
As long as array index %2 is non-zero, generate 1 else generate 0 qualified by adding the values so that they evaluate to 8, which is size/2.
This works when I try to print the value after randomization.
$display("\n %d", t.cnum.sum with (int'(item.index%2?item:0)));
csum = 8
What am I missing here in its usage in constraints as opposed to its usage in regular code?
Does it work the same way in both?