# SystemVerilog constraint implication with multiple variable

**URL:** <https://verificationacademy.com/forums/t/systemverilog-constraint-implication-with-multiple-variable/41027>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, constraint-randomization, implication\
**Created:** [November 22, 2022, 7:26am UTC](https://verificationacademy.com/forums/t/systemverilog-constraint-implication-with-multiple-variable/41027 "2022-11-22T07:26:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArielElliassi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@ArielElliassi](https://verificationacademy.com/forums/u/ArielElliassi)\
**Post date:** [November 22, 2022, 7:26am UTC](https://verificationacademy.com/forums/t/systemverilog-constraint-implication-with-multiple-variable/41027/1 "2022-11-22T07:26:39Z")

</div>

Hello,  
I was wondering if it’s possible to use the implication with constraint for multiple variable in an elegant way?

```verilog

constraint example {
flag == true -> other_flag_1 == false;
flag == true -> other_flag_2 == false;
flag == true -> other_flag_3 == false;
}

```

To be in pseudocode something like:

```verilog

constraint example {
flag == true -> (other_flag_1 == false; other_flag_2 == false; other_flag_3 == false;);
}

```

Couldn’t figure out the syntax and couldn’t find something in the standard so maybe it’s not possible (and maybe worth adding?).

---

<div class="post-metadata">

**Author:** ![ABD\_91](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/c77e96/32.png) [@ABD\_91](https://verificationacademy.com/forums/u/ABD_91)\
**Post date:** [November 22, 2022, 11:18am UTC](https://verificationacademy.com/forums/t/systemverilog-constraint-implication-with-multiple-variable/41027/2 "2022-11-22T11:18:03Z")

</div>

You could write the multiple constraints using if-else constraint as well ::

```verilog

constraint example { if ( flag == true ) 
                        {
                           // Add multiple constraints here
                           other_flag_1 == false;
                           other_flag_2 == false;
                           other_flag_3 == false;
                        }
                     }

```

---

<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:** [November 22, 2022, 2:46pm UTC](https://verificationacademy.com/forums/t/systemverilog-constraint-implication-with-multiple-variable/41027/3 "2022-11-22T14:46:32Z")

</div>

_In reply to [Ariel Elliassi](https://verificationacademy.com/forums/t/systemverilog-constraint-implication-with-multiple-variable/41027/2):_

The right hand side of an implication can be a constraint set:

```verilog
constraint example {
flag == true -> {other_flag_1 == false;
                 other_flag_2 == false;
                 other_flag_3 == false;};
}

```

Note that when your constraints are Boolean expressions, it’s the same as the logically ANDing them into one Boolean expression

```verilog
constraint example {
flag == true -> other_flag_1 == false &&
                 other_flag_2 == false &&
                 other_flag_3 == false;
}

```

---

<div class="post-metadata">

**Author:** ![ArielElliassi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@ArielElliassi](https://verificationacademy.com/forums/u/ArielElliassi)\
**Post date:** [November 23, 2022, 7:11am UTC](https://verificationacademy.com/forums/t/systemverilog-constraint-implication-with-multiple-variable/41027/4 "2022-11-23T07:11:21Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/systemverilog-constraint-implication-with-multiple-variable/41027/3):_

Thank you very much for the detailed explanation.
