Design A Half Adder Using Dataflow Architecture in VHDL Code (Autorecovered)
Design A Half Adder Using Dataflow Architecture in VHDL Code (Autorecovered)
A half adder is an arithmetic combinational circuit that takes in two binary digits and
adds them. The half adder gives out two outputs, the SUM of the operation and the
CARRY generated in the operation. Since this carry is not added to the final answer,
the addition process is somewhat incomplete. Hence, it’s known as the half adder.
Below you will find the logic circuit and the corresponding logic equation of the half
adder. This circuit is made using simple digital logic gates; the EX-OR and AND gates.
We will use this equation to program a half adder circuit using VHDL.
SUM =
CARRY = AB
library ieee;
use ieee.std_logic_1164.all;
entity half_adder is
port(a,b: in bit;s,c: out bit);
end half_adder;
end half_adder;
RTL SCHEMATIC
TECHNOLOGY SCHEMATIC
SIMULATION RESULTS
➢ DESIGN A HALF ADDER USING STRUCTURAL MODELLING IN VHDL CODE
• FIRST COMPONENT:
XOR GATE
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity xor_2 is
port (A,B: in BIT; Z: out BIT);
end xor_2;
architecture DataFlow of xor_2 is
begin
Z <= (not A and B) or (A and not(B));
end DataFlow;
• SECOND COMPONENT:
AND GATE
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity and_2 is
port(A,B: in BIT; Z: out BIT);
end and_2;
architecture DataFlow of and_2 is
begin
Z <= A and B;
end DataFlow;
HALF ADDER DESIGN
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--Interface
entity H_ADDER is
port (A, B: in BIT; SUM, CRY: out BIT);
end H_ADDER;
--Body
architecture STRUCTURAL of H_ADDER is
component xor_2
port (A, B: in BIT; Z: out BIT);
end component;
component and_2
port (A, B: in BIT; Z: out BIT);
end component;
begin
X1: xor_2 port map (A, B, SUM);
A1: and_2 port map (A, B, CRY);
end STRUCTURAL;
RTL SCHEMATIC
➢ DESIGN A FULL ADDER USING DATAFLOW ARCHITECTURE IN VHDL CODE
SUM =
CARRY = Y(A+B) + AB
A B Y SUM CARRY
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
library ieee;
use ieee.std_logic_1164.all;
entity full_adder is
port(a,b,c: in bit;sum,carry: out bit);
end full_adder;
RTL SCHEMATIC
TECHNOLOGY SCHEMATIC
SIMULATION RESULTS
➢ DESIGN A FULL ADDER USING HALF ADDER COMPONENTS (STRUCTURAL
MODELLING) IN VHDL CODE
• FIRST COMPONENT:
HALF ADDER 1
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--Interface
entity H_ADDER is
port (A, B: in BIT; SUM, CRY: out BIT);
end H_ADDER;
--Body
architecture STRUCTURAL of H_ADDER is
component xor_2
port (A, B: in BIT; Z: out BIT);
end component;
component and_2
port (A, B: in BIT; Z: out BIT);
end component;
begin
X1: xor_2 port map (A, B, SUM);
A1: and_2 port map (A, B, CRY);
end STRUCTURAL;
• SECOND COMPONENT:
HALF ADDER 2
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--Interface
entity H_ADDER is
port (A, B: in BIT; SUM, CRY: out BIT);
end H_ADDER;
--Body
architecture STRUCTURAL of H_ADDER is
component xor_2
port (A, B: in BIT; Z: out BIT);
end component;
component and_2
port (A, B: in BIT; Z: out BIT);
end component;
begin
X1: xor_2 port map (A, B, SUM);
A1: and_2 port map (A, B, CRY);
end STRUCTURAL;
• THIRD COMPONENT:
OR GATE
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity or_2 is
port (A, B: in BIT; Z: out BIT);
end or_2;
architecture DataFlow of or_2 is
begin
Z <= A or B;
end DataFlow;
RTL SCHEMATIC
TECHNOLOGY SCHEMATIC
SIMULATION RESULTS