作业帮 > 综合 > 作业

用VHDL语言编写下列题目要求的程序.

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/28 04:36:25
用VHDL语言编写下列题目要求的程序.
设计一个七人表决电路,参加表决者七人,同意为1,不同意为0,同意者过半表决通过,绿色指示灯灭.表决不通过则红指示灯亮.
library ieee;
use ieee.std_logic_1164.all;
entity voter is
port(voter_in: in std_logic_vector(7 downto 1);
red,green: out std_logic);
end entity voter;
architecture behave of voter is
begin
process(voter_in)
variable counter:integer;
begin
counter :=0;
for i in voter_in'range loop
if voter_in(i)='1' then
counter := counter + 1;
end if;
end loop;
if counter>3 then
red