Hello,
In a SystemVerilog constraint, we can use the array sum() method
constraint my_constraint {
my_array.sum() with (64'(item)) == _14GB;
}
Is there a way to create a similar scalable constraint that takes into account only the array elements that are on even index values?
E.g.:
constraint my_constraint {
my_array[0] + my_array[2] + my_array[4] == _14GB;
}
In reply to Mihai-Corneliu Cristescu:
Please try
constraint my_constraint {
my_array.sum() with (64'(item * 2)) == _14GB;
}
In reply to chr_sue:
In reply to Mihai-Corneliu Cristescu:
Please try
constraint my_constraint {
my_array.sum() with (64'(item * 2)) == _14GB;
}
I think the above solution is not correct as is doing multiplication on the item values before adding them up, not checking or filtering the even indexed values of the array, maybe you could try something like this
my_array.sum() with (64'(((item.index % 2) == 0) ? item : 0)) == _14GB;
HTH,
-R
In reply to rgarcia07:
Hi,
Thank you for your feedback! I confirm that rgarcia07’s solution works for me!
Best regards,
Mihai