top of page
15.1. Functions
A function is a procedural block that returns a single value. Functions execute in zero simulation time and cannot contain timing controls. They are primarily used for combinational logic operations and calculations.
Function Syntax and Structure
Verilog
Key Characteristics
-
Must return EXACTLY ONE value
-
At least ONE input (can have multiple)
-
NO timing controls (#delay, @event, wait)
-
Executes in ZERO simulation time
-
Cannot call tasks (can call other functions)
-
Return value assigned to function name
-
Can have local variables
Basic Function Examples
Verilog
Function Return Types
Verilog
Calling Functions
Verilog
Advanced Function Examples
Verilog
Function Restrictions
⚠ RESTRICTIONS:
-
Cannot contain timing controls (#, @, wait)
-
Cannot call tasks
-
Cannot have output or inout arguments
-
Must have at least one input
-
Must return exactly one value
-
Cannot enable other tasks
bottom of page
