Half Adder

Half Adder

HALF ADDER – DATA FLOW


library ieee;
use ieee.std_logic_1164.all;
  entity HA is
   port(A,B : in std_logic;
        Sum,Carry : out std_logic);
  end HA;
  architecture H_A of HA is
   begin
    Carry<= A AND B;
    Sum<= A XOR B;
   end H_A;


HALF ADDER – BEHAVIORAL

library ieee;
use ieee.std_logic_1164.all;
  entity HA is
   port (A, B : in std_logic;
        Sum, Carry : out std_logic);
  end entity HA;
  architecture H_A of HA is
    begin
     process(A,B)
      begin
      if(A='0' and B='0') then
      Sum <='0';
      Carry <='0';
      elsif(A='0' and B='1') then
      Sum <='1';
      Carry<='0';
      elsif(A='1' and B='0') then
      Sum <='1';
      Carry<='0';
      else
      Sum <='0';
      Carry<='1';
      end if;
    end process;
  end architecture H_A;