VHDL:with-select for multiple values

rbu*_*rny 5 select vhdl

我有以下代码(它编码一个按下的按钮):

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);
Run Code Online (Sandbox Code Playgroud)

我试图在不使用tmp信号的情况下重写它.可能吗?以下不起作用:

with buttons select
  error & code <= "000" when x"1",
                  "001" when x"2",
                  "010" when x"4",  
                  "011" when x"8",
                  "100" when others;
Run Code Online (Sandbox Code Playgroud)

TOT*_*OTA 5

您可以使用 case 来代替 select:

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;
Run Code Online (Sandbox Code Playgroud)