Difference between task and function
Difference between task and function
Model answer
{|l|l|l|}\hline Aspect & Function & Task\\ \hline Time control (\#,\ @,\ wait) & not allowed & allowed\\ \hline Return & one value (or void) & no return value\\ \hline Outputs & inputs only (Verilog) & input / output / inout\\ \hline Can call & functions only & functions and tasks\\ \hline Used in expression & yes & no, called as a statement\\ \hline Simulation time & zero time & may consume time\\ \hline verilog module func_task_example; function automatic int max2(input int a, b); return (a > b) ? a : b; endfunction verilog initial begin bit done; $display("max = %0d", max2(5, 9)); compare(9, 5, done); if (done) $display("comparison completed at time = %0t", $time); end endmodule