|
发表于 2018-8-10 11:28:56
|
显示全部楼层
给楼主一个建议,这种语法上的东西,最好查看一下标准,你的问题标准上已经很明确给出定义了。学习的时候看些书可以,但是遇到问题有疑惑的时候优先查标准
13.4.1 Return values and void functions
The function definition shall implicitly declare a variable, internal to the function, with the same name as the
function. This variable has the same type as the function return value. Function return values can be
specified in two ways, either by using a return statement or by assigning a value to the internal variable
with the same name as the function. For example:
function [15:0] myfunc1 (input [7:0] x,y);
myfunc1 = x * y - 1; // return value assigned to function name
endfunction
function [15:0] myfunc2 (input [7:0] x,y);
return x * y - 1; //return value is specified using return statement
endfunction
The return statement shall override any value assigned to the function name. When the return statement is
used, nonvoid functions shall specify an expression with the return. |
|