Functions, Tasks, and Scope
Factor calculations and test sequences without hiding dependencies or mixing RTL with timing controls.
A subprogram collects an operation used in several places. Choose a function for a calculated result and a task for a sequence of actions, keeping RTL and testbench contexts clear.
Calculate without waiting
This function adds two bytes and saturates at 255: