Functions are a type of subprogam in VHDL which can be used to avoid repeating code.
The blog post for this video:
https://vhdlwhiz.com/function/
In VHDL, functions always return a value. They can take any number of parameters as inputs. Function parameters behave like constant inputs. They cannot be changed inside of the function. Parameters may be given a default value in the function declaration. The default value is used if nothing is assigned to the parameter when the function is called.
A function call always consume zero time. Therefore, Wait statements cannot be used within a function.
There is a declarative region between "is" and "begin" keyword in the function declaration. Here, variables, constants, and even other functions can be declared. Objects declared in the declarative region are scoped to the function, meaning that they do not exist outside of it.