library ieee;
use ieee.std_logic_1164.all;
entity qrbjq is
port( a: in std_logic_vector(6 downto 0); --7个人
num: buffer integer range 0 to 7; --表决通过人数
co: out std_logic); --是否通过信号
end;
architecture art of qrbjq is
begin
process(a)
variable b: integer range 0 to 7; --定义变量b
begin
b:=0;
for n in 0 to 6 loop
if a(n)='1' then b:=b+1; --统计通过人数
end if;
end loop;
num<=b;
if num>=4 then co<='1'; --4人以上同意,则通过
else co<='0';
end if;
end process;
end art;