# Soft constraints

**URL:** <https://verificationacademy.com/forums/t/soft-constraints/39827>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, constraint\
**Created:** [November 19, 2021, 6:18pm UTC](https://verificationacademy.com/forums/t/soft-constraints/39827 "2021-11-19T18:18:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shatrish](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@shatrish](https://verificationacademy.com/forums/u/shatrish)\
**Post date:** [November 19, 2021, 6:18pm UTC](https://verificationacademy.com/forums/t/soft-constraints/39827/1 "2021-11-19T18:18:49Z")

</div>

I have a bit of a doubt on the soft constraints.

This is what LRM mentions about the soft constraint:

> a constraint expression defined as soft designates a constraint that is to be satisfied unless contradicted by another constraint—either by a hard constraint or by a soft constraint with higher priority.

So, in the following code, is this a contradiction:

```verilog
constraint deflt { soft length < 5 ; }
constraint new_const { soft length < 10 ; }

```

In the above example, would the soft constraint be overridden and only the new\_const considered or both the constraints would be considered?  
Similarly, what happens when the constraints are interchanged like below:

```verilog
constraint deflt { soft length < 10 ; }
constraint new_const { soft length < 5 ; }

```

---

<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 19, 2021, 8:51pm UTC](https://verificationacademy.com/forums/t/soft-constraints/39827/2 "2021-11-19T20:51:27Z")

</div>

_In reply to [shatrish](https://verificationacademy.com/forums/t/soft-constraints/39827):_

These constraints do not contradict each other they both can be satisfied with numbers less than 5. Other the other hand if you had

```verilog
constraint deflt { soft length < 5 ; }
constraint new_const { soft length > 10 ; }

```

Both these constraints cannot be satisfied together. The last constraint “new\_const” has priority.
