library IEEE;
use IEEE.std_logic_1164.all;

entity ADDER3 is
    port ( A, B: in  STD_LOGIC_VECTOR(2 downto 0);
           CI:   in  STD_LOGIC;
           S:    out STD_LOGIC_VECTOR(3 downto 0) );
end ADDER3;

architecture ADDER3_arch of ADDER3 is

component FA port ( A, B, CI: in  STD_LOGIC;
                    S, CO:    out STD_LOGIC );
end component;

signal C: STD_LOGIC_VECTOR(0 to 3);
begin
  C(0) <= CI;
  U1: for i in 0 to 2 generate
    U1C: FA port map (A(i), B(i), C(i), S(i), C(i+1));
  end generate;
  S(3) <= C(3);
end ADDER3_arch;
