How do I pass an empty integer_vector
with length
equals zero? (= NULL array)
Background:
Inside a Testbench I´d like to use a procedure for different types of transactions. Something like this:
entity foo is
end entity foo;
architecture bar of foo is
procedure Transaction (
constant RX_BYTES : integer_vector
) is
begin
report "RX_BYTES'length = " & to_string(RX_BYTES'length);
end procedure;
begin
Transaction(RX_BYTES => ""); -- it´s about this line
end architecture bar;
I have something like this in mind, but that doesn´t work:
Transaction(RX_BYTES => "");
ModelSim error:
** Error: C:/Users/sbuhrow/Desktop/NULL_Vector.vhd(13): (vcom-1600) No feasible entries for subprogram "Transaction".
Simply use an empty range:
Transaction(RX_BYTES => (1 to 0 => 0), ...);
Demo:
$ cat foo.vhd
entity foo is
end entity foo;
architecture bar of foo is
procedure p(constant c: integer_vector) is
begin
report "c'length = " & to_string(c'length);
end procedure p;
begin
p(c => (0 downto 1 => 0));
end architecture bar;
$ ghdl -a --std=08 foo.vhd
$ ghdl -r --std=08 foo
foo.vhd:7:5:@0ms:(report note): c'length = 0
Note: if you will use such an empty integer vector frequently you could also declare a constant:
constant empty_iv: integer_vector := (1 to 0 => 0);
And use it everywhere you need it.