Search code examples
vhdl

Does a VHDL function have to return a value?


I would like to create a function to write a file via the TEXTIO library. This is quite a simple routine to write naturally, but for clarity of code I would prefer to write it as a function.

I know the typical way of writing a function is as follows

Heading type

function my_func(my_arg : my_arg_type) return return_type;

Body type

function my_func(my_arg : my_arg_type) return return_type is

However, if I am not interested in returning anything is there a way to avoid the critical warning -

return type is not specified

Solution

  • No. But, you could use a procedure instead:

    procedure my_func (my_arg : my_arg_type) is
    

    You can put a procedure in a package:

    package P is
      procedure my_func (my_arg : my_arg_type);
    end package P;
    
    package body P is
      procedure my_func (my_arg : my_arg_type) is
      begin
        // blah blah blah
      end procedure my_func;
    end package body P;
    

    SystemVerilog has void functions which have no return type, but this can't be done using VHDL.