6 Adders Fall24v1
6 Adders Fall24v1
Adders
BASIC ADDERS
The Half-Adder
Nafiz Ahmed Chisty| Head (UG) and Associate Professor, Dept. of EEE, FE, AIUB
A half-Adder accepts adds two bits and produces a Sum and a Carry
output.
Circuit Diagram:
Expression:
Nafiz Ahmed Chisty| Associate Professor and Head (UG), Dept. of EEE, FE, AIUB| chisty@aiub.edu
The Half-Adder
Nafiz Ahmed Chisty| Head (UG) and Associate Professor, Dept. of EEE, FE, AIUB
assign S= A ^ B;
assign Cout= A & B;
endmodule
Nafiz Ahmed Chisty| Associate Professor and Head (UG), Dept. of EEE, FE, AIUB| chisty@aiub.edu
The Full-Adder
Nafiz Ahmed Chisty| Head (UG) and Associate Professor, Dept. of EEE, FE, AIUB
The Full-Adder accepts two input bits and an input carry and generates a sum output and
an output carry.
The Full-Adder
Nafiz Ahmed Chisty| Head (UG) and Associate Professor, Dept. of EEE, FE, AIUB
assign S= A ^ B ^ Cin;
assign Cout= (A & B) | ((A ^ B ) & Cin);
endmodule
Nafiz Ahmed Chisty| Associate Professor and Head (UG), Dept. of EEE, FE, AIUB| chisty@aiub.edu
• A 2-bit adder can be constructed by cascading (series placement) of two full adders.
//Top-Level module
//Device name and I/O ports
module Adder_2Bit (input wire [1:0] A, B,
output wire [1:0] S,
output wire Cout);
//Define internal C incorporating all carry type signals
wire [2:0] C;
assign C[0] = 0; //Use C[0] just for a “symmetric look”
//Level-2
//Device name and I/O ports
module FA (input wire Cin, A, B,
output wire S, Cout);
//Define behavior/structure of the circuit
assign S= A ^ B ^ Cin;
assign Cout= (A & B) | ((A ^ B ) & Cin);
endmodule
Adder Expansion
Nafiz Ahmed Chisty| Head (UG) and Associate Professor, Dept. of EEE, FE, AIUB
The 4-bit parallel adder can be expanded to handle the addition of two 8-bit numbers
by using two 4-bit adders.
Nafiz Ahmed Chisty| Associate Professor and Head (UG), Dept. of EEE, FE, AIUB| chisty@aiub.edu
if this is followed the carryout becomes an extra signal. Even if carryout is not considered
part of the result due to the above requirement, it can serve another purpose—that is it
serves as an overflow indicator.
• In addition, HIGH carryout indicates overflow.
• Overflow means that the result could not be mapped within the available number of bits.
• For example, consider 011 (3) + 110 (6) in a 3-bit
adder.
011(3)
110 (6)
1 001 (1)
We can graphically represent the addition in a number wheel.
We go clock-wise for addition.
For this example, start at 3, and then go 6 steps clock-wise to get the addition result.
If the arrow goes beyond max. number (111(7)), then overflow occurs. From number wheel, we get
3 + 6 = 1 as well.
000
111 001
110 010
101 011
100
Nafiz Ahmed Chisty| Associate Professor and Head (UG), Dept. of EEE, FE, AIUB| chisty@aiub.edu
Subtractor
Nafiz Ahmed Chisty| Head (UG) and Associate Professor, Dept. of EEE, FE, AIUB
• The logic equation for subtraction can be developed from truthtable. One can build
half- subtractor and full-subtractor from truthtable. Similar, to adders, multi-bit
subtracters can be built from full-subtractor.
• However, subtracters are typically realized with 2’s compliment addition in
industrial EDA tools. This is because, when 2’s compliment subtraction is used,
adders can be used for both addition and subtraction purposes.
• Subtraction of two numbers is defined as addition of 2’s compliment version of one
of the inputs with the other inputs kept unchanged. So, one input is kept unchanged,
while the other input is provided to the adder in its 2’s compliment form.
Ysub =A–B
= A + (-B)
= A + (2’s compliment of B)
110 010
101 011
100
Nafiz Ahmed Chisty| Associate Professor and Head (UG), Dept. of EEE, FE, AIUB| chisty@aiub.edu
Adder-Subtractor
Nafiz Ahmed Chisty| Head (UG) and Associate Professor, Dept. of EEE, FE, AIUB
• Since both addition and subtraction uses addition, one can develop a common expression for
addition and subtraction provided there is a control signal that selects whether addition or
subtraction should be performed.
• Addition: A+B
Subtraction: A – B = A + (-B) = A + 𝐵̅ + 1
• If we can control the 2nd input to the adder (say, B_to_add), regarding whether it
should be B or 𝐵̅, we can use the same adder to produce both addition and subtraction.
• Secondly, subtraction requires an extra 1, while the addition does not need any.
• So, if the control signal, say AS, is chosen in such a way that a AS = 0 ensures addition
and AS = 1 ensures subtraction, then the control signal itself can be added to the
addition process. This will provide that extra 1 for subtraction.
Adder-Subtractor
Nafiz Ahmed Chisty| Head (UG) and Associate Professor, Dept. of EEE, FE, AIUB
• A 1-bit adder-subtracter utilizes a full adder and an XOR gate. The control signal AS
would be connected to the Cin port of the full adder.
A A
B B
AS AS
B_to_add
COUT COUT
S S
Nafiz Ahmed Chisty| Associate Professor and Head (UG), Dept. of EEE, FE, AIUB| chisty@aiub.edu
Adder-Subtractor
Nafiz Ahmed Chisty| Head (UG) and Associate Professor, Dept. of EEE, FE, AIUB
• A 2-bit adder-subtracter would utilize two full adders and two XOR gates, as shown
below. The control signal AS would be connected to the Cin port of the full adder for
the LSB bit.
2
A
2
B
AS
COUT
2
S
Nafiz Ahmed Chisty| Head (UG) and Associate Professor, Dept. of EEE, FE, AIUB Nafiz Ahmed Chisty| Associate Professor and Head (UG), Dept. of EEE, FE, AIUB| chisty@aiub.edu
Reference:
[1] Thomas L. Floyd, “Digital Fundamentals” 11th edition, Prentice Hall.
[2] M. Morris Mano, “Digital Logic & Computer Design” Prentice Hall.
36
Thanks