用VHDL语言设计一个3输入的多数表决器

来源:百度知道 编辑:UC知道 时间:2024/06/04 11:06:19

-- Three-input Majority Voter
-- The entity declaration is followed by three alternative architectures which achieve the same functionality in different ways.
-- download from: www.pld.com.cn & www.fpga.com.cn

ENTITY maj IS
PORT(a,b,c : IN BIT; m : OUT BIT);
END maj;
--Dataflow style architecture
ARCHITECTURE concurrent OF maj IS
BEGIN
--selected signal assignment statement (concurrent)
WITH a&b&c SELECT
m <= '1' WHEN "110"|"101"|"011"|"111",'0' WHEN OTHERS;
END concurrent;

--Structural style architecture
ARCHITECTURE structure OF maj IS

--declare components used in architecture
COMPONENT and2 PORT(in1, in2 : IN BIT; out1 : OUT BIT);
END COMPONE