Expression for overflow conditions in Adder/Subtractor

Discussion in 'Homework Help' started by Fraser_Integration, Dec 3, 2009.

  1. Fraser_Integration

    Thread Starter Member

    Nov 28, 2009
    142
    5
    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.
     
  2. Ratch

    New Member

    Mar 20, 2007
    1,068
    3
    Fraser_Integration,

    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
     
  3. Fraser_Integration

    Thread Starter Member

    Nov 28, 2009
    142
    5
    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.
     
Loading...