Full Adder using Half Adder
| A | B | Cin | S1 = A ⊕ B | C1 = A·B | Sum = S1 ⊕ Cin | C2 = S1·Cin | Cout = C1 + C2 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 | 0 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 | 1 | 1 | 0 | 1 |
Dataflow — Half Adder
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 19:55:52 04/06/2026
-- Design Name:
-- Module Name: HALF_ADDER_MODULE - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity HALF_ADDER_MODULE is
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
SUM : out STD_LOGIC;
CARRY : out STD_LOGIC);
end HALF_ADDER_MODULE;
architecture Dataflow of HALF_ADDER_MODULE is
begin
SUM <= A xor B;
CARRY <= A and B;
end Dataflow;
Dataflow — Full Adder Using Half Adder
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 18:17:46 04/13/2026
-- Design Name:
-- Module Name: FullAdderUsingHalfAdder - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity FullAdderUsingHalfAdder is
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
Cin : in STD_LOGIC;
Sum : out STD_LOGIC;
Cout : out STD_LOGIC);
end FullAdderUsingHalfAdder;
architecture Dataflow of FullAdderUsingHalfAdder is
component HALF_ADDER_MODULE is
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
Sum : out STD_LOGIC;
Carry : out STD_LOGIC);
end component;
signal S1, C1, C2 : STD_LOGIC;
begin
HA1: HALF_ADDER_MODULE port map (A, B, S1, C1);
HA2: HALF_ADDER_MODULE port map (S1, Cin, Sum, C2);
end Dataflow;
Testbench
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 18:31:03 04/13/2026
-- Design Name:
-- Module Name: /home/student/Desktop/13000224121/FULL_ADDER_USING_HALF_ADDER_PROJECT/FullAdderUsingHalfAdder_tb.vhd
-- Project Name: FULL_ADDER_USING_HALF_ADDER_PROJECT
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: FullAdderUsingHalfAdder
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY FullAdderUsingHalfAdder_tb IS
END FullAdderUsingHalfAdder_tb;
ARCHITECTURE behavior OF FullAdderUsingHalfAdder_tb IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT FullAdderUsingHalfAdder
PORT(
A : IN std_logic;
B : IN std_logic;
Cin : IN std_logic;
Sum : OUT std_logic;
Cout : OUT std_logic
);
END COMPONENT;
--Inputs
signal A : std_logic := '0';
signal B : std_logic := '0';
signal Cin : std_logic := '0';
--Outputs
signal Sum : std_logic;
signal Cout : std_logic;
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
-- constant <clock>_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: FullAdderUsingHalfAdder PORT MAP (
A => A,
B => B,
Cin => Cin,
Sum => Sum,
Cout => Cout
);
-- Clock process definitions
-- <clock>_process :process
-- begin
-- <clock> <= '0';
-- wait for <clock>_period/2;
-- <clock> <= '1';
-- wait for <clock>_period/2;
-- end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
A <= '0'; B <= '0'; Cin <= '0'; Wait for 100 ns;
A <= '0'; B <= '0'; Cin <= '1'; Wait for 100 ns;
A <= '0'; B <= '1'; Cin <= '0'; Wait for 100 ns;
A <= '0'; B <= '1'; Cin <= '1'; Wait for 100 ns;
A <= '1'; B <= '0'; Cin <= '0'; Wait for 100 ns;
A <= '1'; B <= '0'; Cin <= '1'; Wait for 100 ns;
A <= '1'; B <= '1'; Cin <= '0'; Wait for 100 ns;
A <= '1'; B <= '1'; Cin <= '1'; Wait for 100 ns;
wait;
end process;
END;