# Can we use Ternary operator in Constraints?

**URL:** <https://verificationacademy.com/forums/t/can-we-use-ternary-operator-in-constraints/37607>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, constraints\
**Created:** [May 20, 2020, 9:37am UTC](https://verificationacademy.com/forums/t/can-we-use-ternary-operator-in-constraints/37607 "2020-05-20T09:37:15Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [May 21, 2020, 3:00am UTC](https://verificationacademy.com/forums/t/can-we-use-ternary-operator-in-constraints/37607/6 "2020-05-21T03:00:01Z")

</div>

_In reply to [kitanisi](https://verificationacademy.com/forums/t/can-we-use-ternary-operator-in-constraints/37607/5):_

You are not correct. Please look at table 11-2 in the 1800-2017 LRM and find which operators have higher precedence. You can also make s simple test case and plug in values for a and b.

```verilog
$display (" the result of b == (a<2) ? 2 : 3 is %b", b == (a<2) ? 2 : 3. );

```

---

_[View the full topic](https://verificationacademy.com/forums/t/can-we-use-ternary-operator-in-constraints/37607)._
