VHDL: with-select for multiple values
select, vhdl
Solution
Instead of with select, you could use case:
my_process_name : process(buttons)
begin
case buttons is
when x"1" =>
error <= '0';
code <= "00";
when x"2" =>
error <= '0';
code <= "01";
when x"4" =>
error <= '0';
code <= "10";
when x"8" =>
error <= '0';
code <= "11";
when others =>
error <= '1';
code <= "00";
end case;
end process;
Problem
I have the following code (it encodes a number of a pressed button): ``` with buttons select tmp <= "000" when x"1", "001" when x"2", "010" when x"4", "011" when x"8", "100" when others; code <= input(1 downto 0); error <= input(2); ``` I am trying to rewrite it without using `tmp` signal. Is it possible? The following doesn't work: ``` with buttons select error & code <= "000" when x"1", "001" when x"2", "010" when x"4", "011" when x"8", "100" when others; ```