Expression for overflow conditions in Adder/Subtractor

Thread Starter

Fraser_Integration

Joined Nov 28, 2009
142
Hi there.

I have been working on the attached question re Digital and would like to check my ideas with you. As you can see the question first asks you how you would perform addition and subtraction depending on a control line X, I have solved this using twos complement and X-or gates. The second section asks for Boolean Expressions for overflow conditions.

I can only summise that overflow occurs when you try to subtract a number with greater magnitude than 8, i.e. the MSB of M will be a zero (as it will have been twos complemented), A will be zero, X will be 1 for subtraction, and the Sum bit will be zero (again due to twos complement) -

so: A'B'S'X

And also when adding two numbers, so A and B are true, S is false due to a carry, and X is false as addition not subtraction:

so ABS'X'

is my logic flawed?

Thanks very much.
Fraser.
 

Attachments

Ratch

Joined Mar 20, 2007
1,070
Fraser_Integration,

I can only summise that overflow occurs when you try to subtract a number with greater magnitude than 8, i.e. the MSB of M will be a zero (as it will have been twos complemented), A will be zero, X will be 1 for subtraction, and the Sum bit will be zero (again due to twos complement) -
Here is a generic rule you can follow whether you are adding/subtracting binary numbers. Assuming bit-3 is the most significant bit, whenever there is a carry for bit-3 not matched by a carry for bit-2,then overflow occurs. If a borrow occurs for bit-3 that is not matched by a borrow for bit-2, then the overflow occurs.

The carry flag determines whether a carry or borrow occured for bit-3. What you have to do is figure out logic to determine whether a carry or borrow occurred for bit-2.

Ratch
 

Thread Starter

Fraser_Integration

Joined Nov 28, 2009
142
Hi there, I didnt really understand your answer. But it made me think about the problem again and I think I answered my own question.

The sign bit of the sum must equal the sign bit of the two components (when they are the same - i.e. both positive or both negative). C

Thanks for the reply.
 
Top