In Scenario 1/3 , the output value of c considers the value of input a and b passed during function call.
But , In Scenario 2 , the output value of c doesn’t consider the value of input a and b passed during function call .
Scenario 1 :
module mm;
function int s;
input int a;
input int b ;
int c ; //= a+b;
c= a+b;
$display("a=%d -- b=%d -- c=%d ",a,b,c);
return c;
endfunction
initial
$display ("-------------- %d",s(9,11));
endmodule
Result is :
a= 9 – b= 11 – c= 20
-------------- 20
Scenario 2 :
module mm;
function int s;
input int a;
input int b ;
int c = a+b;
//c= a+b;
$display("a=%d -- b=%d -- c=%d ",a,b,c);
return c;
endfunction
initial
$display ("-------------- %d",s(9,11));
endmodule
Result is :
a= 9 – b= 11 – c= 0
-------------- 0
Scenario 3 :
module mm;
function automatic int s;
input int a;
input int b ;
int c = a+b;
//c= a+b;
$display("a=%d -- b=%d -- c=%d ",a,b,c);
return c;
endfunction
initial
$display ("-------------- %d",s(9,11));
endmodule
Result is :
a= 9 – b= 11 – c= 20
-------------- 20
Kindly justify .
Thanks in advance .
Best Regards,
Pranoy