Guest
Hi,
I am new to verilog. On a tutorial, it says: The differences between tasks and functions are reflected in the way they are defined and invoked. First of all a function returns a single result that is available through the function's invocation. The requires an assignment to a local variable that has the same name as the function itself. Any other assignment target in local variables cannot return more than one output.
I do not understand the last two lines. What is "the same name" means in the following?
"The requires an assignment to a local variable that has the same name as the function itself."
If there is function:
function [31:0] Factorial;
input [3:0] op1
reg [3:0] in;
begin
Factorial = 1;
for (in=2; in<=op1; in=in+1)
Factorial = in * Factorial;
end
endfunction
....
wire w_in;
net r_tmp;
r_tmp=Factorial(r_in);
What is the local variable? It is r_tmp in the above example?
Second question, what is "other assignment target"?
Thanks in advance.
I am new to verilog. On a tutorial, it says: The differences between tasks and functions are reflected in the way they are defined and invoked. First of all a function returns a single result that is available through the function's invocation. The requires an assignment to a local variable that has the same name as the function itself. Any other assignment target in local variables cannot return more than one output.
I do not understand the last two lines. What is "the same name" means in the following?
"The requires an assignment to a local variable that has the same name as the function itself."
If there is function:
function [31:0] Factorial;
input [3:0] op1
reg [3:0] in;
begin
Factorial = 1;
for (in=2; in<=op1; in=in+1)
Factorial = in * Factorial;
end
endfunction
....
wire w_in;
net r_tmp;
r_tmp=Factorial(r_in);
What is the local variable? It is r_tmp in the above example?
Second question, what is "other assignment target"?
Thanks in advance.