# System task/function call inside of a constraint

**URL:** <https://verificationacademy.com/forums/t/system-task-function-call-inside-of-a-constraint/35999>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, constraints\
**Created:** [April 20, 2019, 6:10am UTC](https://verificationacademy.com/forums/t/system-task-function-call-inside-of-a-constraint/35999 "2019-04-20T06:10:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![atalur](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@atalur](https://verificationacademy.com/forums/u/atalur)\
**Post date:** [April 20, 2019, 6:10am UTC](https://verificationacademy.com/forums/t/system-task-function-call-inside-of-a-constraint/35999/1 "2019-04-20T06:10:44Z")

</div>

Are system calls allowed in constraints? I do not see any references that say so in the LRM.

```verilog
parameter int N = 4;
constraint val { value >= 0; value < $pow(26,N); }

```

Tool C: says invalid usage  
ncvlog: \*E,RNCTYP (testbench.sv,8|42): A ‘system task/function call’ cannot be used within a constraint expression.

Tool S: says NYI  
Error-[CSTR-NYI-UCE] Unsupported constraint expression  
testbench.sv, 8  
$unit, “$pow(26, this.N)”  
The expression ‘$pow(26, this.N)’ is not yet supported in constraints in  
this context.  
Remove the expression from the constraints, replace it with an equivalent  
one, or make sure that any enclosing expression (e.g. an assignment pattern)  
is valid in this context.

---

<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:** [April 20, 2019, 3:59pm UTC](https://verificationacademy.com/forums/t/system-task-function-call-inside-of-a-constraint/35999/2 "2019-04-20T15:59:20Z")

</div>

_In reply to [kernalmode1](https://verificationacademy.com/forums/t/system-task-function-call-inside-of-a-constraint/35999):_

There is no restriction on system functions as long as they meed the requirements of section _18.5.12 Functions in Constraints_. When you get unsupported messages, it means the tool recognizes the construct but has not implemented it you.

One thing that is not clear in the LRM, is whether $pow(x,y) can be treated the same as an operator like x\*\*y and not divide the solution space.

---

<div class="post-metadata">

**Author:** ![atalur](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@atalur](https://verificationacademy.com/forums/u/atalur)\
**Post date:** [April 20, 2019, 8:45pm UTC](https://verificationacademy.com/forums/t/system-task-function-call-inside-of-a-constraint/35999/3 "2019-04-20T20:45:12Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/system-task-function-call-inside-of-a-constraint/35999/2):_

Yes, I am aware of the NYI error. I was trying to point out the fact that one tool says it cannot be done and one other says, you will be able to use it in a later version of the tool.

It seems like since a clear direction is not provided in the LRM, it is left to the whims and fancies (read interpretations of the LRM) of the tool vendor and end user is left with no predictability.

---

<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:** [April 21, 2019, 3:13am UTC](https://verificationacademy.com/forums/t/system-task-function-call-inside-of-a-constraint/35999/4 "2019-04-21T03:13:23Z")

</div>

_In reply to [kernalmode1](https://verificationacademy.com/forums/t/system-task-function-call-inside-of-a-constraint/35999/3):_

Exactly
