what's the best way to return an unconstrained vector in vhdl?
function func(selector : natural) return std_logic_vector is
begin
case selector is
when 3 => return std_logic_vector("11");
when 4 => return std_logic_vector("101");
when others => return std_logic_vector("0");
end case;
end function;
In this case i get string literal cannot be a type conversion operand, so it doesn't work. The signal selector is generic, so it don't have to be synthesizeable.
std_logic_vector'("11"),std_logic_vector'("101");andstd_logic_vector'("0"). The error message you haven't shown would tell you that you can't type convert a string to std_logic_vector, their element types aren't the same (character and std_ulogic) . Those ':'s should be "=>".=>for associating a choice with the following return statement.when 3 => return std_logic_vector'("11");, etc. Please supply a Minimal, Complete and Verifiable example. Include a complete error message. Your question is not useful as it stands. Note that the return value type isstd_logic_vectorand can provide the type of the string literals without the qualified expressions as Matthew Taylor commented to his answer.