EDA与VHDL题目——七人表决器
作者:互联网
EDA与VHDL题目——七人表决器
代码
LIBRARY IEEE; --七人表决器
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY VOTE IS
PORT(a,b,c,d,e,f,g:IN STD_LOGIC; -- 七输入
o:OUT STD_LOGIC); -- 一输出
END ENTITY VOTE;
ARCHITECTURE VT OF VOTE IS
BEGIN
PROCESS(a,b,c,d,e,f,g)
VARIABLE sum:INTEGER RANGE 0 TO 7; -- 定义变量范围0~7
BEGIN
IF a='1' THEN
sum:=1;
ELSE
sum:=0;
END IF;
IF b='1' THEN
sum:=sum+1;
ELSE
sum:=sum;
END IF;
IF c='1' THEN
sum:=sum+1;
ELSE
sum:=sum;
END IF;
IF d='1' THEN
sum:=sum+1;
ELSE
sum:=sum;
END IF;
IF e='1' THEN
sum:=sum+1;
ELSE
sum:=sum;
END IF;
IF f='1' THEN
sum:=sum+1;
ELSE
sum:=sum;
END IF;
IF g='1' THEN
sum:=sum+1;
ELSE
sum:=sum;
END IF;
IF sum>=4 THEN -- 判断是否亮灯
o<='1';
ELSE
o<='0';
END IF;
END PROCESS;
END ARCHITECTURE VT;
标签:EDA,END,VHDL,--,表决器,ELSE,LOGIC,sum 来源: https://blog.csdn.net/Alexa_/article/details/113789997