📄 三人表决器.vhd
字号:
--Three-input Majority Voter--The entity declaration is followed by three alternative architectures which achieve the same functionality in different ways.ENTITY maj ISPORT(a,b,c : IN BIT; m : OUT BIT);END maj;--Dataflow style architectureARCHITECTURE concurrent OF maj ISBEGIN--selected signal assignment statement (concurrent)WITH a&b&c SELECTm <= '1' WHEN "110"|"101"|"011"|"111",'0' WHEN OTHERS;END concurrent;--Behavioural style architecture using a look-up tableARCHITECTURE using_table OF maj ISBEGINPROCESS(a,b,c)CONSTANT lookuptable : BIT_VECTOR(0 TO 7) := "00010111";VARIABLE index : NATURAL;BEGINindex := 0; --index must be cleared each time process executesIF a = '1' THEN index := index + 1; END IF;IF b = '1' THEN index := index + 2; END IF;IF c = '1' THEN index := index + 4; END IF;m <= lookuptable(index);END PROCESS;END using_table;--Structural style architectureARCHITECTURE structure OF maj IS--declare components used in architectureCOMPONENT and2 PORT(in1, in2 : IN BIT; out1 : OUT BIT);END COMPONENT;COMPONENT or3 PORT(in1, in2, in3 : IN BIT; out1 : OUT BIT);END COMPONENT;--declare local signalsSIGNAL w1, w2, w3 : BIT;BEGIN--component instantiation statements.--ports of component are mapped to signals--within architecture by position.gate1 : and2 PORT MAP (a, b, w1);gate2 : and2 PORT MAP (b, c, w2);gate3 : and2 PORT MAP (a, c, w3);gate4 : or3 PORT MAP (w1, w2, w3, m);END structure;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -