Re: Generic multiplexer
Use ieee.numeric_std instead of std_logic_[arith, unsigned].
Multiple concurrent assignments to the same signal (created by the
generate loop) create multiple drivers for that signal. Your attempt
could be modified to create a tristate mux (bus), but that is probably
not what you want either:
output <= input(i) when i = to_integer(unsigned(sel)) else 'Z';
Not sure what you're trying to do with 2nd If-generate...
You don't need the generate statements (loop or if) anyway:
-- since sel is constrained to be within input'range:
use ieee.numeric_std.all;
architecture concurrent of gen_mux1 is
begin
output <= input(to_integer(unsigned(sel)));
end architecture;
-- or this will work if value of sel could be
-- outside of input'range:
use ieee.numeric_std.all;
architecture sequential of gen_mux1 is
begin
process (input, sel) is
begin
output <= '0'; -- default assignment
for i in input'range loop
if i = to_integer(unsigned(sel)) then
output <= input(i);
end if;
end loop;
end process;
end architecture;
Andy
|