Error: Signal parameter requires signal expression on function call

372 Views Asked by At

Short question:

I've written a function that takes a signal integer as parameter. The compiler throws the error signal parameter requires signal expression when I call my_function(INTEGER_SIGNAL - 5) in a process. Could someone explain to me what a signal expression is and how I can call this function correctly?

Thanks in advance!

1

There are 1 best solutions below

0
On

Generally for functions you want to instead use a constant class parameter.

Signal class parameters require that you connect them to a signal - ie: no expressions. You only need a signal inside of a function when you use a signal parameter, such as 'event. For a procedure, you also need a signal when you expect the object to update - such as when it is used in a wait statement or is read after a wait statement (and you expect a potentially updated value).

With a constant class parameters allow you to connect them with any value of that type. That value can come from an expression or a literal value (X"4A"). A signal name or a variable name are simple forms of expressions.

Constant class also happens to be the default for inputs of you do not specify the class of the parameter. In the following code, parameters A and B are both constant class parameters.

function fred (
   constant A : integer ; 
            B : integer
) return integer is 
 ...
end function fred ;