Forum Discussion
Altera_Forum
Honored Contributor
10 years agomodelsim compiling error:external function 'xxxxx' may not be used in a constant expr
Consider the following code: package pkg;
function bit bitgen(int bit1idx);
automatic bit res = '0;
if (bit1idx >= 0 && bit1idx < 16)
res = 1'b1;
return res;
endfunction
func...
Altera_Forum
Honored Contributor
10 years agoYes, without the static or automatic keyword, it is difficult to know if the local variable gets initialized once at time 0, or each time the function gets called. I think its best to declare your package as automatic, then all the functions are automatic, and all the local variables inside the functions are automatic. Then, only declare local variables as 'static' when they need to be.