DLD Lab Report 07
DLD Lab Report 07
DLD Lab Report 07
Lab report # 07
Design and Implementation of 𝒏 – 𝒃𝒊𝒕 Adder/Subtractor on FPGA
1.1: Objectives
1.1.1: Part 1:
This experiment is to design gate-level hierarchal description of a 4 − 𝑏𝑖𝑡 binary Adder /
Subtractor in HDL and implement it on FPGA and using ICs.
1.1.2: Part 2:
Introduce the different Verilog keyword (parameter) and use it to make the module
parameterized in Verilog. Parameterized method will allow us to make 𝑛 − 𝑏𝑖𝑡 binary Adder
/ Subtractor in Verilog.
1.1.3: Pre-Lab:
1.1.4: Background theory:
Binary Adder is digital circuit that produces the arithmetic sum of two binary numbers. It can
be constructed with full adders connected in cascade, with the output carry from each full
adder connected to the input carry of the next full adder in the chain. The process of addition
proceeds on a bit-by-bit basis, right to left, beginning with the least significant bit. After the
least significant bit, addition at each position adds not only the respective bits of the words,
but also consider a possible carry bit from addition at the previous position. Addition of 𝑛 −
𝑏𝑖𝑡 binary numbers requires the use of a 𝑛 full adder, or a chain of one-half adder and 𝑛 − 1
full adders. The four-bit adder is an example of a standard component. It can be used in many
applications involving arithmetic operations.
Binary Adder/Subtractor can be combined into one circuit with one common binary adder by
including an exclusive-OR gate with each full adder. A four-bit adder/subtractor circuit of
two binary numbers 𝐴(𝐴3𝐴2𝐴1𝐴0) and 𝐵(𝐵3𝐵2𝐵1𝐵0) is shown in Figure 7.1. The mode
input 𝑀 controls the operation. When 𝑀 = 0, the circuit is an adder. As 𝐵 ⊕ 0 = 𝐵,
𝐶0 = 0 , full adders receive the value of 𝐵, and the circuit performs 𝐴 + 𝐵. when 𝑀 = 1,
the circuit becomes a subtractor. Now we have 𝐵 ⊕ 1 = 𝐵
̅ and 𝐶0 = 1. The 𝐵 input is
complemented and a 1 is added through the input carry (𝐶0). The circuit performs the
operation 𝐴 plus the 2’s complement of 𝐵 i.e., 𝐴 − 𝐵. The exclusive-OR with output 𝑉 is for
detecting an overflow and 𝐶 is carry out.
Page 2 of 11
Figure:2.4.2: Results
Figure:2.4.3: results
Figure:2.4.7: comparator
Simulation:
Figure:3.1.5: output
Test bench:
Simulation:
Figure:3.2.3: output
Question # 02:
Page 10 of 11
Conclusion:
In this lab we have analysed that by a computer the addition of any two numbers is very basic
task to be implemented and processed on Xilinx and FPGA. The same circuit implementation
can also be used for subtraction. In this lab I have learnt how to design a 4-bit binary and
subtractor and implemented on FPGA. In Verilog.we have used Parameter and always
command, and we have analysed the result of it. These results were for 4- bit and 8-bit binary
numbers which are shown above in simulation graphs.
Page 11 of 11