# \#uvm-sv-constraints

**URL:** https://verificationacademy.com/forums/tag/uvm-sv-constraints/7944.md

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

---

## [Interview question on constraint](https://verificationacademy.com/forums/t/interview-question-on-constraint/39755)

<div class="topic-metadata">

**Author:** [@burra\_thanuja](https://verificationacademy.com/forums/u/burra_thanuja)\
**Replies:** 24\
**Last updated:** [January 20, 2026, 12:47pm UTC](https://verificationacademy.com/forums/t/interview-question-on-constraint/39755 "2026-01-20T12:47:25Z")

</div>

Can anyone plz help me with this constraint question… Take a rand variable with array size 10,need to get unique values in each location without using unique keyword and for any of 2 locations we need to get same value? …

---

## [Weighted constraint](https://verificationacademy.com/forums/t/weighted-constraint/48703)

<div class="topic-metadata">

**Author:** [@ashish\_saroj](https://verificationacademy.com/forums/u/ashish_saroj)\
**Replies:** 2\
**Last updated:** [October 14, 2024, 10:39pm UTC](https://verificationacademy.com/forums/t/weighted-constraint/48703 "2024-10-14T22:39:47Z")

</div>

hello, i am using weighted constraint for generation arith only for two times. but as per expectation it is not coming sometimes 3 or 5 or zero times arith value is comming below is my code. class alu\_trans\_c; typ…

---

## [System verilog constraint](https://verificationacademy.com/forums/t/system-verilog-constraint/48526)

<div class="topic-metadata">

**Author:** [@Rohit082](https://verificationacademy.com/forums/u/Rohit082)\
**Replies:** 6\
**Last updated:** [October 1, 2024, 7:13pm UTC](https://verificationacademy.com/forums/t/system-verilog-constraint/48526 "2024-10-01T19:13:08Z")

</div>

write a SystemVerilog constraint for a 64-bit variable data. The requirements are as follows: The variable should be declared as rand bit \[63:0\] data. Whenever a 1 is detected in the pattern, it should be represented a…

---

## [Prime numbers constraint](https://verificationacademy.com/forums/t/prime-numbers-constraint/47914)

<div class="topic-metadata">

**Author:** [@Surya\_prakash.Kapireddy](https://verificationacademy.com/forums/u/Surya_prakash.Kapireddy)\
**Replies:** 1\
**Last updated:** [July 17, 2024, 3:44pm UTC](https://verificationacademy.com/forums/t/prime-numbers-constraint/47914 "2024-07-17T15:44:23Z")

</div>

class prime\_numbers; rand int unsigned prime\[\]; constraint const\_prime {prime.size inside{1000}; foreach(prime\[i\]) if (i\>1 && (!((i%2==0 && i!=2) || (i%3==0 && …

---

## [Constraint for walking pattern (walking 1's)](https://verificationacademy.com/forums/t/constraint-for-walking-pattern-walking-1s/46870)

<div class="topic-metadata">

**Author:** [@Mahesh\_6](https://verificationacademy.com/forums/u/Mahesh_6)\
**Replies:** 7\
**Last updated:** [April 19, 2024, 11:58pm UTC](https://verificationacademy.com/forums/t/constraint-for-walking-pattern-walking-1s/46870 "2024-04-19T23:58:14Z")

</div>

Hi All, I am writing constraint for walking 1’s algorithm, but not able to get the required output module p1; class c1; rand bit \[7:0\] value; constraint c1{ foreach (value\[m\]){ value\[0\] == 1; …

---

## [Weighted Distribution in Constraints in system verilog](https://verificationacademy.com/forums/t/weighted-distribution-in-constraints-in-system-verilog/42151)

<div class="topic-metadata">

**Author:** [@Malyka](https://verificationacademy.com/forums/u/Malyka)\
**Replies:** 5\
**Last updated:** [January 21, 2024, 6:17pm UTC](https://verificationacademy.com/forums/t/weighted-distribution-in-constraints-in-system-verilog/42151 "2024-01-21T18:17:23Z")

</div>

The dist operator allows to create weighted distributions. Do I need to specify weight for all values? Look at the code: rand bit \[7:0\] a; constraint dist1 {a dist {0:=20, \[1:30\]:=50};} “a” can have 0 to 255 possible…

---

## [Constraint solver issue](https://verificationacademy.com/forums/t/constraint-solver-issue/42836)

<div class="topic-metadata">

**Author:** [@Blitzz0418](https://verificationacademy.com/forums/u/Blitzz0418)\
**Replies:** 1\
**Last updated:** [December 14, 2023, 3:57pm UTC](https://verificationacademy.com/forums/t/constraint-solver-issue/42836 "2023-12-14T15:57:58Z")

</div>

======================================================= MSG 23: The primary input node fans out to a foreach construct with a large number of copies; consider the use of unidirectional constraints to break the dependenc…

---

## [Randomization Question](https://verificationacademy.com/forums/t/randomization-question/42546)

<div class="topic-metadata">

**Author:** [@jyoveda](https://verificationacademy.com/forums/u/jyoveda)\
**Replies:** 4\
**Last updated:** [October 16, 2023, 4:51pm UTC](https://verificationacademy.com/forums/t/randomization-question/42546 "2023-10-16T16:51:38Z")

</div>

Hi I have an lut like this idx elements 0 0,1,2 1 3,4 2 5 3 6,7,8,9 4 10,11 5 12,13 6 14,15 I want to now randomly select n no: of elements in ascending order where…

---

## [How to generate unique array of queues using constraints](https://verificationacademy.com/forums/t/how-to-generate-unique-array-of-queues-using-constraints/41849)

<div class="topic-metadata">

**Author:** [@Prashanthp436](https://verificationacademy.com/forums/u/Prashanthp436)\
**Replies:** 1\
**Last updated:** [June 19, 2023, 3:38pm UTC](https://verificationacademy.com/forums/t/how-to-generate-unique-array-of-queues-using-constraints/41849 "2023-06-19T15:38:57Z")

</div>

module test; class check; rand bit\[3:0\] queues\[3\] \[$\]; bit \[3:0\] global\_queue\[$:100\]; constraint queue1 {foreach(queues\[i\]) {queues\[i\].size == 3; unique{queue…

---

## [Constraint to generate start and end address for a memory block](https://verificationacademy.com/forums/t/constraint-to-generate-start-and-end-address-for-a-memory-block/41657)

<div class="topic-metadata">

**Author:** [@jaswanth\_b](https://verificationacademy.com/forums/u/jaswanth_b)\
**Replies:** 2\
**Last updated:** [May 15, 2023, 3:36am UTC](https://verificationacademy.com/forums/t/constraint-to-generate-start-and-end-address-for-a-memory-block/41657 "2023-05-15T03:36:46Z")

</div>

Hi, I want to write a constraint to generate random start and end addresses to pick a block of memory inside a particular range of addresses, and i cannot use the address range which picked previous. can you please help…

---

## [Randomization in the class](https://verificationacademy.com/forums/t/randomization-in-the-class/41339)

<div class="topic-metadata">

**Author:** [@Blitzz0418](https://verificationacademy.com/forums/u/Blitzz0418)\
**Replies:** 1\
**Last updated:** [March 2, 2023, 8:27pm UTC](https://verificationacademy.com/forums/t/randomization-in-the-class/41339 "2023-03-02T20:27:54Z")

</div>

Hi , i am trying to randomize an array in my seq but i see array value being 0 all the time. what i am trying to do is randomizing the array in the sequence itself and write the random values to some registers as per t…

---

## [Write constraints for AHB HSize with 10 times inc4, then 20 times inc16 and then 40 times wrap?](https://verificationacademy.com/forums/t/write-constraints-for-ahb-hsize-with-10-times-inc4-then-20-times-inc16-and-then-40-times-wrap/40925)

<div class="topic-metadata">

**Author:** [@krk1234krk.gmail.com](https://verificationacademy.com/forums/u/krk1234krk.gmail.com)\
**Replies:** 0\
**Last updated:** [October 20, 2022, 5:58am UTC](https://verificationacademy.com/forums/t/write-constraints-for-ahb-hsize-with-10-times-inc4-then-20-times-inc16-and-then-40-times-wrap/40925 "2022-10-20T05:58:23Z")

</div>

Write constraints for AHB HSize with 10 times inc4, then 20 times inc16 and then 40 times wrap?

---

## [Cube root](https://verificationacademy.com/forums/t/cube-root/40300)

<div class="topic-metadata">

**Author:** [@ShashankGurijala](https://verificationacademy.com/forums/u/ShashankGurijala)\
**Replies:** 5\
**Last updated:** [May 28, 2022, 2:59pm UTC](https://verificationacademy.com/forums/t/cube-root/40300 "2022-05-28T14:59:15Z")

</div>

if (jjj == i) ------\> when I use this, it’s working fine. But, if ( j == i\*\*(1/3) ------\> is giving me the wrong outputs while trying to print only perfect cubes out of randmoized i with constraint i=\>1 and i=\<1000. So…

---

## [Assigning the elements in a 3d array](https://verificationacademy.com/forums/t/assigning-the-elements-in-a-3d-array/40403)

<div class="topic-metadata">

**Author:** [@ShashankGurijala](https://verificationacademy.com/forums/u/ShashankGurijala)\
**Replies:** 3\
**Last updated:** [May 17, 2022, 9:56am UTC](https://verificationacademy.com/forums/t/assigning-the-elements-in-a-3d-array/40403 "2022-05-17T09:56:16Z")

</div>

Hello! Look at the below code. Im trying to assign the elements as follows: class packet; rand int array \[\] \[\] \[\]; //diff b/w randc bit \[3:0\] \[1:0\] array \[\] \[\] \[\] and randc bit \[7:0\] array \[\] \[\] \[\] randc int s…

---

## [Syntax error while trying to use function name as array](https://verificationacademy.com/forums/t/syntax-error-while-trying-to-use-function-name-as-array/40379)

<div class="topic-metadata">

**Author:** [@ShashankGurijala](https://verificationacademy.com/forums/u/ShashankGurijala)\
**Replies:** 2\
**Last updated:** [May 10, 2022, 6:17am UTC](https://verificationacademy.com/forums/t/syntax-error-while-trying-to-use-function-name-as-array/40379 "2022-05-10T06:17:08Z")

</div>

Hello! Can you tell me about the syntax error in the below code? function bit \[3:0\] array\_dup \[10\] (int i, int j); for (i = 0; i \< 5; i++) begin array\_dup \[i\] = i; $display("a\[%0d\] = %0…

---

## [Functional constraints](https://verificationacademy.com/forums/t/functional-constraints/40357)

<div class="topic-metadata">

**Author:** [@ShashankGurijala](https://verificationacademy.com/forums/u/ShashankGurijala)\
**Replies:** 2\
**Last updated:** [May 4, 2022, 6:21pm UTC](https://verificationacademy.com/forums/t/functional-constraints/40357 "2022-05-04T18:21:01Z")

</div>

class sample; rand int i; rand bit \[2:0\] array \[10\]; //constraint array\_size {array.size() == 10;} function bit \[2:0\] a \[10\] (int i); for (i=0;i\<=4;i++) begin a\[i\] = i; $display("a\[%0d\] = %0d",i,a\[i\]); end for …

---

## [Static constraints' behaviour in inheritance](https://verificationacademy.com/forums/t/static-constraints-behaviour-in-inheritance/40343)

<div class="topic-metadata">

**Author:** [@ShashankGurijala](https://verificationacademy.com/forums/u/ShashankGurijala)\
**Replies:** 1\
**Last updated:** [May 3, 2022, 4:47am UTC](https://verificationacademy.com/forums/t/static-constraints-behaviour-in-inheritance/40343 "2022-05-03T04:47:15Z")

</div>

Hello! I’ve tried a program to see the working of static constraint while inheriting a normal constraint from another class. When I disable the static constraint, both the constraints have to be affected. But here when I…

---

## [Why is the variable a not randomizing with given constraints?](https://verificationacademy.com/forums/t/why-is-the-variable-a-not-randomizing-with-given-constraints/40315)

<div class="topic-metadata">

**Author:** [@ShashankGurijala](https://verificationacademy.com/forums/u/ShashankGurijala)\
**Replies:** 2\
**Last updated:** [April 26, 2022, 2:17pm UTC](https://verificationacademy.com/forums/t/why-is-the-variable-a-not-randomizing-with-given-constraints/40315 "2022-04-26T14:17:54Z")

</div>

Here is the code: class packet; rand bit \[6:0\] num; randc bit \[6:0\] a; rand enum {EVEN,ODD} number; constraint c1 {a inside {35,36,40,45,\[52:128\]};} constraint c2 {num == func(a);} function bit \[6:0…

---

## [Constraints](https://verificationacademy.com/forums/t/constraints/40310)

<div class="topic-metadata">

**Author:** [@ShashankGurijala](https://verificationacademy.com/forums/u/ShashankGurijala)\
**Replies:** 5\
**Last updated:** [April 26, 2022, 7:09am UTC](https://verificationacademy.com/forums/t/constraints/40310 "2022-04-26T07:09:17Z")

</div>

class packet; rand bit \[5:0\] array \[\]; rand int i; rand int prev\_i; constraint size\_array {array.size() \<10; array.size != prev\_i;} constraint elements { foreach (array\[i\]) …

---

## [Randomization of multiple classes objects inside one class](https://verificationacademy.com/forums/t/randomization-of-multiple-classes-objects-inside-one-class/40253)

<div class="topic-metadata">

**Author:** [@venkateshsr](https://verificationacademy.com/forums/u/venkateshsr)\
**Replies:** 3\
**Last updated:** [April 14, 2022, 6:05am UTC](https://verificationacademy.com/forums/t/randomization-of-multiple-classes-objects-inside-one-class/40253 "2022-04-14T06:05:45Z")

</div>

Hi, I have a class like this class main\_class; rand apr\_ab apr\_ab\_obj; rand apr\_ac apr\_ac\_obj; rand apr\_ad apr\_ad\_obj; rand apr\_ae apr\_ae\_obj; endclass each of apr\_ab , apr\_ac, apr\_ad and apr\_ae have abo…

---

## [Case statement inside constraint](https://verificationacademy.com/forums/t/case-statement-inside-constraint/40211)

<div class="topic-metadata">

**Author:** [@venkata-srikanth](https://verificationacademy.com/forums/u/venkata-srikanth)\
**Replies:** 5\
**Last updated:** [March 29, 2022, 11:26pm UTC](https://verificationacademy.com/forums/t/case-statement-inside-constraint/40211 "2022-03-29T23:26:16Z")

</div>

Hi, I want to use case statement inside a constraint, in my TB environment. Can anyone say whether it works or not? If not, then what are the alternative ways, other than if…else and implication operators?

---

## [2-Dimenson Dynamic array Constraints](https://verificationacademy.com/forums/t/2-dimenson-dynamic-array-constraints/40177)

<div class="topic-metadata">

**Author:** [@fenil\_shah](https://verificationacademy.com/forums/u/fenil_shah)\
**Replies:** 8\
**Last updated:** [March 25, 2022, 4:11am UTC](https://verificationacademy.com/forums/t/2-dimenson-dynamic-array-constraints/40177 "2022-03-25T04:11:20Z")

</div>

I am trying to write some constraints for a 2-D dynamic array. The requirement being addition of the values for each row and column needs to be 30. class hello\_world; rand bit \[7:0\] a \[5\]\[4\]; constraint a\_row { …

---

## [Uvm constraint issue obj.rand variables from top level](https://verificationacademy.com/forums/t/uvm-constraint-issue-obj-rand-variables-from-top-level/39606)

<div class="topic-metadata">

**Author:** [@sifiveuser007](https://verificationacademy.com/forums/u/sifiveuser007)\
**Replies:** 1\
**Last updated:** [September 24, 2021, 7:27pm UTC](https://verificationacademy.com/forums/t/uvm-constraint-issue-obj-rand-variables-from-top-level/39606 "2021-09-24T19:27:05Z")

</div>

class user\_class extends uvm\_sequence\_item; rand int thread\_id; rand int Var1; ... endclass : user\_class class AA extends uvm\_sequence\_item; rand int core\_id; rand user\_class u\_obj; constraint c\_set\_core\_thr…
