Fpga Final
Fpga Final
I. INTRODUCTION .............................................................................................................................................................................2
II. FULL ADDER .................................................................................................................................................................................3
III. RESULTS FOR FULL ADDER AFTER SIMULATION ON ISE TESTBENCH .................................................................... 8
IV. FULL SUBTRACTOR .................................................................................................................................................................10
V. RESULTS FOR FULL SUBTRACTOR AFTER SIMULATION ON ISE TESTBENCH ..................................................... 14
VI. CONCLUSION ............................................................................................................................................................................ 15
APPENDIX ............................................................................................................................................................................................15
1
I. INTRODUCTION
Full adders and full subtractors are important building blocks in digital circuits. They are used to perform
arithmetic operations such as addition and subtraction of binary numbers. In this project, we will explore the
design and implementation of full adders and full subtractors using logic gates.
A full adder is a combinational circuit that adds three binary digits: A, B, and C-in (carry-in) and produces
two outputs: S (sum) and C-out (carry-out). The sum output represents the least significant bit of the
addition, while the carry-out represents the most significant bit. Full adders are used in multi-bit addition
operations, where the carry-out from one full adder is fed as the carry-in to the next full adder.
A full subtractor is a combinational circuit that subtracts three binary digits: A, B, and B-in (borrow-in) and
produces two outputs: D (difference) and B-out (borrow-out). The difference output represents the result of
the subtraction, while the borrow-out represents whether a borrow is required from the next lower significant
bit. Full subtractors are used in multi-bit subtraction operations, where the borrow-out from one full
subtractor is fed as the borrow-in to the next full subtractor.
In this project, we will design and simulate full adders and full subtractors using logic gates such as AND,
OR, and XOR gates. Finally, we will test our circuits using the FPGA (Field Programmable Gate Array)
programmable logic device.
Full adders and full subtractors are commonly used in digital electronics for arithmetic operations. In
everyday life, these circuits can be found in calculators, computers, and other electronic devices that perform
mathematical calculations. They are also used in security systems, where they can be used to encrypt and
decrypt data. Additionally, full adders and full subtractors can be used in control systems to perform
operations such as counting and timing.
2
II. FULL ADDER
A binary adder is a logic circuit that adds two binary numbers together. It takes two inputs, the binary
numbers to be added, and produces a sum output. The simplest form of a binary adder is the half adder,
which can only add two single-bit binary numbers.
A half adder has two inputs, A and B, and two outputs, sum (S) and carry (C). Inputs are called Augend and
Added bits and Outputs are called Sum and Carry.
Since 1+1=10, the result must be two bit output. So, Above can be rewritten as,
0+0=00
0+1=01
1+0=01
1+1=10
The result of 1+1 is 10, where ‘1’ is carry-output (Cout) and ‘0’ is Sum-output (Normal Output)
INPUTS OUTPUTS
A B SUM CARRY
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
4
Though half adders can perform binary addition , half adders have certain limitations that make them
unsuitable for certain applications. Firstly, they can only add two single-digit binary numbers and cannot
handle carry-over from previous additions. Secondly, they do not have the ability to subtract or perform any
other arithmetic operations. Thirdly, they cannot handle multi-bit numbers, which means that they cannot be
used for complex calculations. Finally, they are not capable of performing logical operations such as AND,
OR, and NOT. These limitations make half adders less versatile than other types of adders and limit their use
to simple applications.
To overcome the above limitation faced with Half adders, Full Adders are implemented.
It is a arithmetic combinational logic circuit that performs addition of three single bits.It contains three
inputs (A, B, Cin) and produces two outputs (Sum and Cout).Where, Cin stands for Carry In and Cout for Carry
Out. A full adder is made up two half adders
INPUTS OUTPUTS
A B Cin Sum Cout
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
5
Table 4a:K map Simplification for output variable Sum ‘S’
6
Fig 4: Logic Diagram of Full Adder
7
III. RESULTS FOR FULL ADDER AFTER SIMULATION ON ISE TESTBENCH
To simulate the full adder, we used the software ISE 14.7 using its test-bench.
8
Fig 5a: The input parameters and clock definition
Fig 5b: Results of full adder after simulation in the TESTBENCH of ISE 14.7
9
Fig5c: Simplified diagram showing the input and output signals
A binary subtractor is a logic circuit that subtracts one binary number from another. It takes two inputs, the
binary numbers to be subtracted, and produces a difference output. The simplest form of a binary subtractor
is the half subtractor, which can only subtract two single-bit binary numbers. A half subtractor has two
inputs, A and B, and two outputs, difference (D) and borrow (B). The truth table for a half subtractor is as
follows:
INPUTS OUTPUTS
A B D Bo
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
10
D = A'B + AB'
D = A xor B
A half subtractor is a combinational circuit that is used to subtract two single-bit binary numbers.
However, it has certain limitations. Firstly, it can only subtract two single-bit binary numbers and cannot
perform subtraction of multi-bit binary numbers. Secondly, it cannot handle borrow operations, which
means that if the second number is greater than the first number, it cannot perform the subtraction operation.
Lastly, it can only perform subtraction of binary numbers in 2's complement form, which means that it
cannot perform subtraction of signed binary numbers in other forms such as signed magnitude or excess-3
code.
To overcome the above limitation faced with Half subtractors, Full subtractors are implemented.
11
Fig 8a: Block Diagram of Full subtractor
It is a Combinational logic circuit designed to perform subtraction of three single bits.It contains three
inputs(A, B, Bin) and produces two outputs (D, Bout).Where, A and B are called Minuend and
Subtrahend bits. And, Bin -> Borrow-In and Bout -> Borrow-Out
INPUTS OUTPUTS
A B Bin D Bout
0 0 0 0 0
0 0 1 1 1
0 1 0 1 1
0 1 1 0 1
1 0 0 1 0
1 0 1 0 0
1 1 0 0 0
1 1 1 1 1
12
which can be simplified as,
13
Fig 8b:Logic Diagram of Full Subtractor
TESTBENCH
Fig 8c:Results of full subtractor after simulation in the TESTBENCH of ISE 14.7
14
Fig 8d: Simplified Diagram showing input and output signals
VI. CONCLUSION
In conclusion, the implementation of full adders and full subtractors in VHDL programming language was
successfully achieved. The design was tested on the test-bench of ISE 14.7, and the results were consistent
with the expected output that was shown on the truth tables. The use of VHDL programming language
provided a flexible and efficient way to design and simulate digital circuits. This project demonstrated the
importance of careful planning and testing to ensure the accuracy and reliability of the design. Overall, this
project was a valuable learning experience in digital circuit design and VHDL programming
APPENDIX
ENTITY fulladdersim IS
END fulladdersim;
COMPONENT fulladdervhdl
PORT(
a : IN std_logic;
b : IN std_logic;
c : IN std_logic;
sum : OUT std_logic;
carry : OUT std_logic
);
END COMPONENT;
--Inputs
16
signal a : std_logic := '0';
signal b : std_logic := '0';
signal c : std_logic := '0';
--Outputs
signal sum : std_logic;
signal carry : std_logic;
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
BEGIN
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
17
-- insert stimulus here
wait;
end process;
END;
END ARCHITECTURE;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity fullsubtractorvhdl is
Port ( A,B,C : in STD_LOGIC;
D,Bout : out STD_LOGIC);
end fullsubtractorvhdl;
begin
D<=A XOR B XOR C;
Bout<= ((NOT A) AND B) OR ((NOT A) AND C) OR (B AND C);
end Behavioral;
CODE TESTBENCH:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
18
--USE ieee.numeric_std.ALL;
ENTITY fullsubtractorsim IS
END fullsubtractorsim;
COMPONENT fullsubtractorvhdl
PORT(
A : IN std_logic;
B : IN std_logic;
C : IN std_logic;
D : OUT std_logic;
Bout : OUT std_logic
);
END COMPONENT;
--Inputs
signal A : std_logic := '0';
signal B : std_logic := '0';
signal C : std_logic := '0';
--Outputs
signal D : std_logic;
signal Bout : std_logic;
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
BEGIN
wait;
end process;
END;
20