return of an access type from a function should be an implicit variable and not a constant type... here's why...
` $ vcom -2002 test1.vhd
** Error: test1.vhd(44): (vcom-1047)
Actual (string literal) for class variable formal
"path_in2" is not a variable.
** Error: test1.vhd(44): Function call returns
type (error); expecting type std.TEXTIO.LINE.
** Note: test1.vhd(50): VHDL Compiler exiting
End time: 08:38:08 on Mar 23,2022, Elapsed time: 0:00:00
Errors: 2, Warnings: 0
use std.textio.all;
entity test1 is
end entity;
architecture beh of test1 is
procedure join_path(
variable path_in1 :in line;
variable path_in2 :in line;
variable path_out :out line
) is
variable mout :line;
variable has_slash :boolean := false;
begin
path_out := null;
if (path_in1 = null) then
path_out := path_in2;
return;
end if;
if (path_in1.all(path_in1'length-1) = '/' or
path_in1.all(path_in1'length-1) = '\'
) then
has_slash := true;
end if;
write(mout, path_in1.all);
if (not has_slash) then
write(mout, '/');
end if;
write(mout, path_in2.all);
path_out := mout;
return;
end procedure;
impure function to_line(constant s :string)
return line is
variable m:line;
begin
write(m, s);
return m;
end function;
begin
process
variable projdir :line := null;
variable mempath :line := null;
begin
join_path(
path_in1 => projdir,
path_in2 => to_line("mem.txt"), --LINE 44
path_out => mempath
);
report mempath.all;
wait;
end process;
end architecture;
`
Edited by Bill Moore