0% found this document useful (0 votes)
32 views

4-Bit Add/Sub Unit: Zero Overflow

This document describes a 4-bit add/sub unit that can perform addition and subtraction in 2's complement. It works by adding the 2's complement of one number to the other number to perform subtraction. The 2's complement is generated by inverting each bit using an XOR gate and adding a carry bit. An overflow occurs if two positive numbers yield a negative sum or two negative numbers yield a positive sum, which can be detected by examining the most significant digits of the numbers.

Uploaded by

unknown45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

4-Bit Add/Sub Unit: Zero Overflow

This document describes a 4-bit add/sub unit that can perform addition and subtraction in 2's complement. It works by adding the 2's complement of one number to the other number to perform subtraction. The 2's complement is generated by inverting each bit using an XOR gate and adding a carry bit. An overflow occurs if two positive numbers yield a negative sum or two negative numbers yield a positive sum, which can be detected by examining the most significant digits of the numbers.

Uploaded by

unknown45
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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