library ieee;
use ieee.std_logic_1164.all;

entity TWO_OF_FIVE is
  port (I : in std_logic_vector(4 downto 0);
        O : out std_logic);
end TWO_OF_FIVE;

architecture BEHAV of TWO_OF_FIVE is
begin
  process(I)
    variable ONES_COUNT : integer range 0 to 5;
  begin
    ONES_COUNT := 0;
    for J in I'range loop
      if (I(J) = '1') then
        ONES_COUNT := ONES_COUNT + 1;
      end if;
    end loop;
    if (ONES_COUNT = 2) then
      O <= '1';
    else
      O <= '0';
    end if;
  end process;
end BEHAV;
