VERILOG-Task and Function
Copyrights ©2015 - www.indicustechnology.com
Function
• A function is enclosed within keyword ‘function’ and
‘endfunction’.
• functions can’t include timing delays.
• It can take any number of argument as inputs but only
one output (Function Name).
• it must have at least one input argument
• It can call another function but not another task.
• function always returns a value and return type of
function is function name itself.
• Variable declare in function is local to that function.
• Can be Used to design combinational logic.
Continue….
Copyrights ©2015 - www.indicustechnology.com
Function
• Syntax :
function [width] function_name (input arguments );
begin
function_body;
end
endfunction
• Calling a function
function_name (<expression_1>,<expression_2>….);
(note : while calling a function order of arguments must be same
as given while declaring a function)
• Synthesizable.
Copyrights ©2015 - www.indicustechnology.com
Task
• A task is enclosed within keyword ‘task’ and ‘endtask’.
• tasks can include timing delays.
• It can take any number of argument as inputs, outputs
and inouts. (it can also have zero argument)
• It can call another task as well as function.
• task never returns a value but can pass values to output
and inouts arguments.
• Variable declare in task is local to that task.
• Used to design both combinational and sequential
logic.
Continue….
Copyrights ©2015 - www.indicustechnology.com
Task
• Syntax :
task task_name (input/inout/output arguments );
begin
task_body;
end
endtask
• Calling a task
task_name (<expression_1>,<expression_2>….);
(note : while calling a task order of arguments must be same
as given while declaring a task)
• Task without delay is Synthesizable.
Copyrights ©2015 - www.indicustechnology.com
Thank You
Questions ??
Copyrights ©2015 - www.indicustechnology.com