Task and Functions in Vera :
1. Functions :
Open Vera funcitons can have zero or more arguments and it can return on value. The syntax for the function is
function data_type func_name ( data_type arg_list )
{
statements;
}
data_type : it can be build in or user defined data type. Return value has the same data_type as declared in the function. Function can not return Arrays.
func_name : Function name which will be used to call the function throughout the program
arg_list : An argument is a variable, including the data type, that is passed to the function when the function is called. You can pass all data types, including interface signals. Array arguments can be regular or associative, as well as var (that is, array arguments can be passed by reference). The type and dimension of the array in the call must match the type and dimension of the array in the function declaration. Separate multiple arguments using commas.
statements : Can be any valid open vera statement
A function can be called with statement like :
ret_val = func ();
Function returns a value so it should be called in a assignment statement. If you want to discard the return value use it like
void = func (a, b, c);
Return Statement :
A return statement casues the function to return immediately to its caller. A return statement is is shown below :
function integer add (integer a, integer b)
{
add = a + b;
return ;
}
2. Tasks :
|