Hello,
I’ve a question. I want to constraint the sum of an array elements. For example:
rand int array[1000];
I want the sum of all elements to be 2345. Anyone has a method to do this using a constraint block in a UVM class
Thanks in advance
Hello,
I’ve a question. I want to constraint the sum of an array elements. For example:
rand int array[1000];
I want the sum of all elements to be 2345. Anyone has a method to do this using a constraint block in a UVM class
Thanks in advance
Use
constraint c_sum {array.sum() < 2345;}
You may want to use int unsigned if you do not want to consider negative numbers in the array.
In reply to dave_59:
Thanks Dave very much. Can this be used for an array of real values ?
rand real array[1000];
In reply to Mustafa:
No. Real variables cannot be randomized, array or no array.