library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity test_2 is
port(
key : in std_logic_vector(6 downto 0);
tmp : buffer std_logic_vector(2 downto 0)
);
end entity test_2;
architecture behave of test_2 is
begin
p1:process(key)
begin
loop1 : for i in 0 to 6 loop
if(key(i) = '1')then
tmp <= tmp + 1;
end if;
end loop;
end process;
end architecture;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity exp11_2 is
port(
key : in std_logic_vector(6 downto 0);
-- vote : out std_logic;
tmp : out std_logic_vector(2 downto 0)
-- ledag : out std_logic_vector(6 downto 0)
);
end entity exp11_2;
architecture behave of exp11_2 is
--signaltmp : std_logic_vector(2 downto 0);
begin
p1:process(key)
variable count:std_logic_vector(2 downto 0);
begin
loop1 : for i in 0 to 6 loop
if(key(i) = '1')then
count := count + 1;
end if;
end loop;
tmp <= count;
end process;
end architecture;