# Soft constraints vs Hard constraints

**URL:** <https://verificationacademy.com/forums/t/soft-constraints-vs-hard-constraints/31329>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, soft-constraints-hard-constraints-constraints\
**Created:** [December 18, 2015, 2:17am UTC](https://verificationacademy.com/forums/t/soft-constraints-vs-hard-constraints/31329 "2015-12-18T02:17:24Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ayehia](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/ayehia/32/2099_2.png) [@ayehia](https://verificationacademy.com/forums/u/ayehia)\
**Post date:** [December 20, 2015, 10:26am UTC](https://verificationacademy.com/forums/t/soft-constraints-vs-hard-constraints/31329/5 "2015-12-20T10:26:07Z")

</div>

_In reply to [Sharandiva](https://verificationacademy.com/forums/t/soft-constraints-vs-hard-constraints/31329/4):_

Just to add, nothing in your second example can result in ignoring the soft constraints. Since test\_config.var1 and test\_config.var2 depend on cfg[0/1].var1 and cfg[0/1].var2, if you have additional constraints on test\_config.var1/var2 that would contradict with the soft constraints, this could result in the behavior you are seeing. For example:

```verilog

if ( cfg[0].enable)
      var1 == cfg[0].var1;
      var1 != cfg[1].var1; //contradicts soft constraints
    else {
      var1 == cfg[1].var1;
      var1 != cfg[0].var1; //contradicts soft constraints
    }

```

So a full example will clear any remaining confusion.

---

_[View the full topic](https://verificationacademy.com/forums/t/soft-constraints-vs-hard-constraints/31329)._
