Its a believe that Function can call only Function not Task..... this true for verilog only....but not for system verilog
Lets simulate this program with function calling task inside the fork / join_none. The simulation result proves me that “Task can be called inside the function".
// ****************************************************************************//
// This module is used to test functionalty of function and tasks define inside//
// the module //
// a) function is calling task ( with no delay ) //
// b) function is calling task ( with delay ) //
//*****************************************************************************//
module task_in_func();
task abc ();
$display(" task abc with delay %t ", $time);
#10;
$display(" task abc with delay %t", $time);
endtask:abc
task def ();
$display(" task def with no delay");
endtask:def
function void func_task_no_delay ();
fork
begin
def ();
end
begin
abc ();
end
join_none;
endfunction:func_task_no_delay
initial
begin
func_task_no_delay;
$display(" before end module %t", $time);
end
endmodule:task_in_func
RESULT
% before end module 0
% task def with no delay
% task abc with delay 0
% task abc with delay 10