Prior to VHDL 93, all (self declared) functions were implicitely pure.
This means, that when you call them with the same parameters, you will
always get the same result. In computer language these are called
functions with "no side effects".
If you know that functions have no side effects, several optimizations
are possible. For instance, the construct
IF func1(a,b) and func2(a,b) THEN
can evaluate func1 and func2 in any order, if func1 and func2 are pure.
This means, the result will be the same (excpt errors). If func1
returns false, the call of func2 may even be omitted, and vice versa.
Mathematical functions (sin(x), exp(x)) are pure functions. However,
functions like random(), or even read() are impure. Impure functions
have some internal state (coming from variables/signals outside the
function).
If you want to create a random number generator with a function
random(), this was not possible in VHDL'87 - you had to use a procedure
with an out parameter. In VHDL93 you can declare the function random as
impure:
--- very dumb random generator, unchecked
shared variable rstate:=3;
impure function random return integer is
begin
rstate:=(5*rstate+3) mod 16;
end function random;
Hubble.