# Constraints

**URL:** <https://verificationacademy.com/forums/t/constraints/32277>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog\
**Created:** [September 19, 2016, 4:46am UTC](https://verificationacademy.com/forums/t/constraints/32277 "2016-09-19T04:46:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HardikTrivedi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/e79b87/32.png) [@HardikTrivedi](https://verificationacademy.com/forums/u/HardikTrivedi)\
**Post date:** [September 19, 2016, 4:46am UTC](https://verificationacademy.com/forums/t/constraints/32277/1 "2016-09-19T04:46:34Z")

</div>

In Systemverilog why multiple relational operators are not allow in the constraint block ?

```verilog
class Bus
  rand bit[15:0] a,b,c;
  constraint c1 { 0 < a < b < c; }
endclass

```

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [September 19, 2016, 5:26am UTC](https://verificationacademy.com/forums/t/constraints/32277/2 "2016-09-19T05:26:40Z")

</div>

\*In reply to [Hardik Trivedi](https://verificationacademy.com/forums/t/constraints/32277):\*You can certainly put as many relational operators as you want in a constraint block - it just does not give you the results you are looking for. A constraint expression evaluates true or false following the same Boolean/arithmetic rules found elsewhere in SystemVerilog (like the condition of an **if** statement)… Those rules (from table 11-2) say that the operators associate from left to right. So your constraint expression evaluates the same as

```auto
{( (0 < a) < b) < c;}

```

Since the result of a single relational operator is a single bit, you don’t get what you expect.  
What you really want is this expression

```verilog
{0 < a && a < b && b < c;}

```

But since all constraint must evaluate true, you can write this as three separate constraint and save a few keystrokes.

```verilog
{0 < a ; a < b ; b < c;}

```

---

<div class="post-metadata">

**Author:** ![HardikTrivedi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/e79b87/32.png) [@HardikTrivedi](https://verificationacademy.com/forums/u/HardikTrivedi)\
**Post date:** [September 19, 2016, 6:02am UTC](https://verificationacademy.com/forums/t/constraints/32277/3 "2016-09-19T06:02:04Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/constraints/32277/2):_

Thanks a lot Dave !!
