Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
609 views
in Technique[技术] by (71.8m points)

vhdl - Error: Signal parameter requires signal expression on function call

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!

question from:https://stackoverflow.com/questions/66048316/error-signal-parameter-requires-signal-expression-on-function-call

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 ;

    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...