0% found this document useful (0 votes)
5 views

Understanding Tasks and Functions in Verilog

Uploaded by

swaroop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Understanding Tasks and Functions in Verilog

Uploaded by

swaroop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Tasks, Functions & Void

Functions

by
Swaroop D
USN:4MH21EC104
Overview of Tasks & Functions

Time-Consuming No Return Value

Tasks can execute over time, incorporating delays, Tasks do not return a value and are typically used for
blocking statements, and wait conditions. procedural operations.

Enhance-Readability
Functions:
Combinational Logic
Instantaneous Return Value
Required
Functions execute instantly,
without delays or blocking Functions must return a
statements. value, which is typically
used in assignments.
Example of Task: Delay
and Blocking
task delay_and_wait;
#100; // Delay of 100 time units
wait(ready); // Wait for signal 'ready' to be high
endtask
Example of Function:
Logic Calculation
function logic [3:0] add4bit;
input logic [3:0] a, b;
add4bit = a + b;
endfunction
SystemVerilog
Enhancements: Void
Cast
function logic [3:0] add4bit;
input logic [3:0] a, b;
add4bit = a + b;
endfunction

void main;
void'(add4bit(2, 3)); // Call function and discard
return value
endfunction
Choosing Tasks and Functions
1 Sequential Logic 2 Combinational Logic
Use a task for operations that involve time or Use a function for logic calculations and
blocking statements. instantaneous operations.
Key Takeaways

Time
Tasks can take time, while functions are instantaneous.

Return Value
Functions return values, while tasks do not.

SystemVerilog
Use void casting to call functions without using the return value.

You might also like