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;
			

上一篇:电子数据取证-磁盘恢复(第1题)


下一篇:VHD作为引导盘后阻止动态扩展到完整大小,防止蓝屏。