VHDL language

Seven people voter: Seven people vote, if more than or equal to four people agree, the output is 1, otherwise the output is 0.

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 8;
	   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;
			

Guess you like

Origin blog.csdn.net/qq_45229168/article/details/109363111