4-Bit CSA/CLA Block Diagram 4-Bit CSA/CLA VHDL Code: S X + Y + Z + W
4-Bit CSA/CLA Block Diagram 4-Bit CSA/CLA VHDL Code: S X + Y + Z + W
4-Bit CSA/CLA Block Diagram 4-Bit CSA/CLA VHDL Code: S X + Y + Z + W
S =X+Y+Z+W
=X+Y+Z
-- CSA 1
= 2 x C1 + S1 + W -- CSA 2
= 2 x C2 + S2 = S3
-- CLA
fa_3: fa PORT MAP(X => X(3), Y => Y(3), C_in => C_in(3), S => S(3), C_out => C_out(3)); fa_4: fa PORT MAP(X => X(4), Y => Y(4), C_in => C_in(4), S => S(4), C_out => C_out(4)); end structural;
[entity CLA ]
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity CLA is Port ( X : in std_logic_vector(3 downto 0); Y : in std_logic_vector(3 downto 0); S : out std_logic_vector(3 downto 0); C_out : out std_logic); end CLA; architecture concurrent_behavioral of CLA is signal p0, p1, p2, p3, g0, g1, g2, g3 : std_logic; signal c0p0 : std_logic; signal p1g0, p1p0c0 : std_logic; signal p2g1, p2p1g0, p2p1p0c0 : std_logic; signal p3g2, p3p2g1, p3p2p1g0, p3p2p1p0c0 : std_logic; signal c1, c2, c3 : std_logic; signal c0 : std_logic := '0';
3BA5, 12th Lecture, M. Manzke,Page: 5 3BA5, 12th Lecture, M. Manzke,Page: 6
[begin]
[end concurrent_behavioral]
begin p0 <= (X(0) or Y(0)); p1 <= (X(1) or Y(1)); p2 <= (X(2) or Y(2)); p3 <= (X(3) or Y(3)); g0 <= (X(0) and Y(0)); g1 <= (X(1) and Y(1)); g2 <= (X(2) and Y(2)); g3 <= (X(3) and Y(3)); c0p0 <= (p0 and c0); c1 <= (g0 or c0p0); p1g0 <= (p1 and g0); p1p0c0 <= (p1 and p0 and c0); c2 <= (g1 or p1g0 or p1p0c0);
3BA5, 12th Lecture, M. Manzke,Page: 7
p2g1 <= (p2 and g1); p2p1g0 <= (p2 and p1 and g0); p2p1p0c0 <= (p2 and p1 and p0 and c0); c3 <= (g2 or p2g1 or p2p1g0 or p2p1p0c0); p3g2 <= (p3 and g2); p3p2g1 <= (p3 and p2 and g1); p3p2p1g0 <= (p3 and p2 and p1 and g0); p3p2p1p0c0 <= (p3 and p2 and p1 and p0 and c0); C_out <= (g3 or p3g2 or p3p2g1 or p3p2p1g0 or p3p2p1p0c0); S(0) <= (X(0) xor Y(0) xor c0); S(1) <= (X(1) xor Y(1) xor c1); S(2) <= (X(2) xor Y(2) xor c2); S(3) <= (X(3) xor Y(3) xor c3); end concurrent_behavioral;
3BA5, 12th Lecture, M. Manzke,Page: 8
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity XYZW_ADDER is Port ( X : in std_logic_vector(3 downto 0); Y : in std_logic_vector(3 downto 0); Z : in std_logic_vector(3 downto 0); W : in std_logic_vector(3 downto 0); S : out std_logic_vector(4 downto 0); C_out : out std_logic); end XYZW_ADDER;
architecture structural of XYZW_ADDER is COMPONENT csa PORT( X : IN std_logic_vector(4 downto 0); Y : IN std_logic_vector(4 downto 0); C_in : IN std_logic_vector(4 downto 0); S : OUT std_logic_vector(4 downto 0); C_out : OUT std_logic_vector(4 downto 0)); END COMPONENT; COMPONENT cla PORT( X : IN std_logic_vector(3 downto 0); Y : IN std_logic_vector(3 downto 0); S : OUT std_logic_vector(3 downto 0); C_out : OUT std_logic); END COMPONENT;
3BA5, 12th Lecture, M. Manzke,Page: 9 3BA5, 12th Lecture, M. Manzke,Page: 10
-- signal that connect the input ports with the CSAs signal X_in, Y_in, Z_in, W_in : std_logic_vector(4 downto 0); -- signal that connect the 1st CSA with the 2nd CSA signal S_01, C_out_01 : std_logic_vector(4 downto 0); -- signal that connect the 2nd CSA with the CLA signal S_CSA_2, C_out_12, C_out_01S : std_logic_vector(4 downto 0); begin X_in <= ('0' & X); Y_in <= ('0' & Y); Z_in <= ('0' & Z); W_in <= ('0' & W); C_out_01S <= (C_out_01(3 downto 0) & '0'); S(0) <= S_CSA_2(0);
3BA5, 12th Lecture, M. Manzke,Page: 11
X => X_in, Y => Y_in, C_in => Z_in, S => S_01, C_out => C_out_01); X => S_01, Y => W_in, C_in => C_out_01S, S => S_CSA_2, C_out => C_out_12); X => S_CSA_2(4 downto 1), Y => C_out_12(3 downto 0), S => S(4 downto 1), C_out => C_out);
end structural;
3BA5, 12th Lecture, M. Manzke,Page: 12
Repeated Summation
S = wi
i =1 k
// CSA
// CLA