Ok, so I tried that and got the same result, also, Y gets '1' only when there are exactly two out of five are high.
Here is the current code:
Code:
library ieee;
use ieee.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;
entity two_five is -- Begin entity
port(
A, B, C, D, E: in std_logic;
Y: out std_logic
);
end entity two_five; -- End entity
-------------------------------------------------
architecture beh of two_five is -- Begin architecture
signal sig: std_logic_vector (4 DOWNTO 0);
begin
sig <= A&B&C&D&E;
process (sig)
variable count: integer;
begin
count := 0;
for i in 0 to 4 loop
if sig(i) = '1' then
count := count + 1;
end if;
if count = 2 then
Y <= '1';
else Y <= '0';
end if;
end loop;
end process;
end beh;