# \#constraint-array

**URL:** https://verificationacademy.com/forums/tag/constraint-array/6400.md

[Latest](https://verificationacademy.com/forums/latest.md) · [Categories](https://verificationacademy.com/forums/categories.md) · [Tags](https://verificationacademy.com/forums/tags.md)

---

## [Constraint in a 2d pixel matrix](https://verificationacademy.com/forums/t/constraint-in-a-2d-pixel-matrix/36235)

<div class="topic-metadata">

**Author:** [@sparsh.gupta](https://verificationacademy.com/forums/u/sparsh.gupta)\
**Replies:** 4\
**Last updated:** [February 8, 2021, 3:53pm UTC](https://verificationacademy.com/forums/t/constraint-in-a-2d-pixel-matrix/36235 "2021-02-08T15:53:49Z")

</div>

Let’s assume there’s a 2d pixel matrix 1920 x 1080 in size. I want to constrain the matrix such that in the neighborhood of an off pixel(0) there are only ON pixels(1-255). The pattern should be something like this, for …

---

## [Can I constrain a sum/function of array element sizes?](https://verificationacademy.com/forums/t/can-i-constrain-a-sum-function-of-array-element-sizes/34202)

<div class="topic-metadata">

**Author:** [@jprochno](https://verificationacademy.com/forums/u/jprochno)\
**Replies:** 8\
**Last updated:** [January 9, 2021, 8:22pm UTC](https://verificationacademy.com/forums/t/can-i-constrain-a-sum-function-of-array-element-sizes/34202 "2021-01-09T20:22:53Z")

</div>

Hi, Is there a way in UVM to constrain a function of array element sizes? I provided some code below, and I know I cannot use variables inside a constraint, but I think it explains what I want to do. rand t\_byte\_q…

---

## ["Invalid random variable in index expression for constraint"](https://verificationacademy.com/forums/t/invalid-random-variable-in-index-expression-for-constraint/36904)

<div class="topic-metadata">

**Author:** [@khaledismail](https://verificationacademy.com/forums/u/khaledismail)\
**Replies:** 2\
**Last updated:** [December 10, 2019, 11:07am UTC](https://verificationacademy.com/forums/t/invalid-random-variable-in-index-expression-for-constraint/36904 "2019-12-10T11:07:19Z")

</div>

I am trying to constrain an enum variable to be randomized in a class but I get the following error on Questa Sim: \*\* Failure: noc\_prog.sv(0): Invalid random variable in index expression for constraint. My constraint…

---

## [An empty loop variable with multi dimension of the array not working](https://verificationacademy.com/forums/t/an-empty-loop-variable-with-multi-dimension-of-the-array-not-working/36734)

<div class="topic-metadata">

**Author:** [@Digeshkumar](https://verificationacademy.com/forums/u/Digeshkumar)\
**Replies:** 2\
**Last updated:** [October 30, 2019, 3:33pm UTC](https://verificationacademy.com/forums/t/an-empty-loop-variable-with-multi-dimension-of-the-array-not-working/36734 "2019-10-30T15:33:01Z")

</div>

I am trying to learn foreach iterative constraints. LRM says “An empty loop variable indicates no iteration over that dimension of the array” Also gave 2 examples for reference in LRM \*\*“foreach( A \[ i, j, k \] ) … fore…

---

## [Constraint](https://verificationacademy.com/forums/t/constraint/35947)

<div class="topic-metadata">

**Author:** [@RonakPatel](https://verificationacademy.com/forums/u/RonakPatel)\
**Replies:** 4\
**Last updated:** [April 8, 2019, 1:00pm UTC](https://verificationacademy.com/forums/t/constraint/35947 "2019-04-08T13:00:28Z")

</div>

Hi, How can we write a constraint for a random dynamic array to generate values in ascending order? Regards, Ronak

---

## [How to constrain 2 dynamic arrays to related to each other?](https://verificationacademy.com/forums/t/how-to-constrain-2-dynamic-arrays-to-related-to-each-other/34841)

<div class="topic-metadata">

**Author:** [@mlsxdx](https://verificationacademy.com/forums/u/mlsxdx)\
**Replies:** 6\
**Last updated:** [October 4, 2018, 5:53pm UTC](https://verificationacademy.com/forums/t/how-to-constrain-2-dynamic-arrays-to-related-to-each-other/34841 "2018-10-04T17:53:27Z")

</div>

Hi, Can someone help to constrain 2 dynamic arrays to get even distribution? C0,C1 evenly distribute E0,E1,E2,E3 evenly distribute En in C0 has same distribution as En in C1 One possible solution: Cs: C0,C0,C1,C1,C0…

---

## [Why randc solution is not cyclic?](https://verificationacademy.com/forums/t/why-randc-solution-is-not-cyclic/34650)

<div class="topic-metadata">

**Author:** [@mlsxdx](https://verificationacademy.com/forums/u/mlsxdx)\
**Replies:** 1\
**Last updated:** [July 6, 2018, 9:03pm UTC](https://verificationacademy.com/forums/t/why-randc-solution-is-not-cyclic/34650 "2018-07-06T21:03:45Z")

</div>

Hi, Can someone help to find out this 2 questions: 1.why the randc solution set is not cyclic? 2.how can I constraints to generate even distributed solution in val for given inner\_idx\[8\] & idx\[4\]\[2\] set? The solution…

---

## [Constraint on array to get even distribution](https://verificationacademy.com/forums/t/constraint-on-array-to-get-even-distribution/34634)

<div class="topic-metadata">

**Author:** [@mlsxdx](https://verificationacademy.com/forums/u/mlsxdx)\
**Replies:** 2\
**Last updated:** [July 1, 2018, 6:54pm UTC](https://verificationacademy.com/forums/t/constraint-on-array-to-get-even-distribution/34634 "2018-07-01T18:54:22Z")

</div>

Hi, I have some difficulty to constrain an dynamic array to get even distribution on each element. Can somebody help me how to write a constraint so that the 8 elements can evenly distribute? As the code posted, I go…
