# Constraint randomization of an array

**URL:** <https://verificationacademy.com/forums/t/constraint-randomization-of-an-array/28283>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog\
**Created:** [January 7, 2013, 11:20pm UTC](https://verificationacademy.com/forums/t/constraint-randomization-of-an-array/28283 "2013-01-07T23:20:27Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![gnich](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/gnich/32/3311_2.png) [@gnich](https://verificationacademy.com/forums/u/gnich)\
**Post date:** [September 2, 2016, 1:59pm UTC](https://verificationacademy.com/forums/t/constraint-randomization-of-an-array/28283/9 "2016-09-02T13:59:35Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/constraint-randomization-of-an-array/28283/8):_

Hi Dave,

I’m trying to constrain an array that has a sum of 2048.

rand bit [11:0] vf;  
constraint c\_vf\_queues {  
vf.size == 248;  
vf.sum == 2048;  
foreach (vf[i]) vf[i] inside {[0:2048]};  
}

I can’t get the individual values in the array to sum to 2048.  
All the values are too large.

Thank you,  
George

---

_[View the full topic](https://verificationacademy.com/forums/t/constraint-randomization-of-an-array/28283)._
