Forum Discussion
Altera_Forum
Honored Contributor
8 years agoHi Tricky,
Thank you for your reply. It's probably the best to do. Do you know what happend if you don't have a quantity of input equal to a power of 2 (= size of mux_in array size) because you can't specify any default value. So if
type array_type is array (5 downto 0) of std_logic_vector(15 downto 0);
signal mux_in: array_type;
signal mux_slct: unsigned(2 downto 0);
signal mux_out: std_logic_vector(15 downto 0);
...
-- no problem with that
mux_slct <= "011";
mux_out1 <= mux_in(to_integer(mux_slct);
-- what about this situation
mux_slct <= "111";
mux_out2 <= mux_in(to_integer(mux_slct);
So maybe the best would be:
p_mux : process(mux_slct,mux_in)
begin
if(mux_slct < mux_in'length) then
mux_out <= mux_in(to_integer(mux_slct));
else
mux_out <= (others<='0');
end if;
end process p_mux; ? Is it the most robust way to do it? Cheers, Jean