In reply to Rsignori92:
In reply to jaswanth_b:
Hello if you call a task inside a function and that specific task has some sort of delay execution (event, waits or @ something) then you will be getting errors because you are trying to use delays or sync methods in a function that are illegal (at compile time).
module tb;
initial begin
fork
call_task(15);
call_task(10);
join_none
#1;
$finish();
end
function void call_task(input int a);
$display("FROM FUNCTION");
print(a);
endfunction
task print(input int v);
$display("FROM TASK");
// Events, waits or other constructs are illegal here and should result in error
// you will get warnings because it could bring delays
// #1; // -> error
$display("VALUE: %d",v);
endtask
endmodule
I believe the question is about calling tasks inside a function using fork-join_none which is described in the LRM 13.4.4 Background processes spawned by function calls
module tb;
initial begin
fork
call_task(15);
call_task(10);
join_none
#2;
$finish();
end
function void call_task(input int a);
$display("FROM FUNCTION");
fork //LRM 13.4.4 Background processes spawned by function calls
print(a);
join_none
endfunction
task print(input int v);
$display("FROM TASK at %0t", $realtime);
#1;
$display("VALUE: %d at %0t",v , $realtime);
endtask
endmodule
So this example the tasks will be spawned by the call_task function.
For example in questa I get the following output
VSIM 1> run -a
FROM FUNCTION
FROM TASK at 0
FROM FUNCTION
FROM TASK at 0
VALUE: 10 at 1
VALUE: 10 at 1
But you may need be careful with spawning threads and not checking them.
HTH,
-R