In reply to SparkyNZ:
“Functions are declared within a module, and can be called from continuous assignments, always blocks or other functions. In a continuous assignment, they are evaluated when any of its declared inputs change__. In a procedure, they are evaluated when invoked.”
OK, I guess this is where I went wrong.