You are on page 1of 2

4-bit Add/Sub Unit

In 2’s complement, we can simply add the two numbers without considering the sign of the
number. We can subtract two numbers by adding the 2’s complement of a number to the other. If
we want take the 2’s complement of a number, we have to take the invert of each bit and add a
single bit to the number. Invertion is done via the XOR gate and the additional bit is provided by
the carry in (C0).
Consider the truth table of the XOR gate.
B S D (B XOR S) Invertion Operation
0 0 0 Not Inverted Addition
1 0 1
0 1 1 Inverted Subtraction
1 1 0
Looking at the truth table, we can see how the control signal S controls the invertion of the bit,
B. Also, when S = 1, C0 is also 1. Therefore, it prvoides an additional bit to the adder as well.
Thus, the conversion of 2’s complement is complete.

Zero
When the all output bits of the Adder is 0, the zero LED is indicated.

Overflow
An overflow can occur if both numbers are either positive or negative. The rules for detecting an
overflow has the following sequence.
1. If the sum of two positive numbers yields a negative result, the sum has overflowed.
2. If the sum of two negative numbers yields a positive result, the sum has overflowed.
3. Otherwise, the sum has not overflowed.
We must only consider the sign of the numbers. Therefore, we only need the MSD of each
number. If the MSDs have the following combination, there’s an overflow.

You might also like