文档介绍:一位全加器真值表一位全加器的逻辑表达式S=A⊕B⊕CinCo=AB+BCin+ACin其中A,B为要相加的数,Cin为进位输入;S为和,Co是进位输出;Libraryieee;;;EntityfulladderIsPort(Ci,a,b:INstd_logic;s,Co:OUTstd_logic);Endfulladder;Architecturem1OffulladderIsSignaltmp:std_logic_vector(1downto0);Begintmp<=('0'&a)+b+Ci;s<=tmp(0);Co<=tmp(1);Endm1;一位全加器的数据流(逻辑)描述Libraryieee;;;EntityfulladderisPort(A,B,CI:instd_logic;S,CO:outstd_logic);Endfulladder;ArchitecturedataflowoffulladderisBeginS<=CIxorAxorB;CO<=(AandB)or(CIandA)or(CIandB);Enddataflow;一位全加器的行为描述Libraryieee;;;EntityfulladderisPort(a,b,cin:Inbit;sum,cout:Outbit);Endfulladder;ArchitecturebehaveOffulladderIsBeginProcess(a,b,cin)BeginIf(aOrbOrcin)=‘0’Thensum<=‘0’;cout<=‘0’;Elsif(aANDbANDcin)=’1’Thensum<=‘1’;cout<=‘1’;Elsif(aXORbXORcin)=’0’Thensum<=‘0’;cout<=‘1’;Elsesum<=‘1’;cout<=‘0’;EndIf;EndProcess;Endbehave;4位全加器的设计,先设计4个1位的全加器,然后将低位的进位输出与高位的进位输入相连,将要进行加法运算的两个4位数的每一位分别作为每一个1位全加器的输入,进行加法运算,所有的1位全加器的输出组成一个4位数,即输入的两个4位数之和,最高位的全加器产生的进位输出即两个4位数求和的进位输出。(如图)Libraryieee;;;Entityadder4IsPort(Cin:INstd_logic;x,y:INstd_logic_vector(3downto0);sum:OUTstd_logic_vector(3downto0);Cout:OUTstd_logic);Endadder4;ArchitectureaxOfadder4IsSignalc:std_logic_vector(0to4);ComponentfulladderPort(Ci,a,