-- Entity declaration for a 4-bit binary adder. -- -------------------------------------------------- entity ADD4 is port (A,B: in BIT_VECTOR (3 downto 0); CIN: in BIT; S: out BIT_VECTOR (3 downto 0); COUT: out BIT); end ADD4; ------------------------------------------------------- -- Typical definition of adder using a program loop. -- ------------------------------------------------------- architecture LOOP_ADDER of ADD4 is begin process (A, B, CIN) variable CARRY: BIT := '0'; variable SUM: BIT_VECTOR (3 downto 0); begin CARRY := CIN; for I in 0 to 3 loop SUM(I) := A(I) xor B(I) xor CARRY; CARRY := (A(I) and B(I)) or (A(I) and CARRY) or (B(I) and CARRY); end loop; S <= SUM; COUT <= CARRY; end process; end LOOP_ADDER; ---Figure 12.61 VHDL program for a ripple carry adder.