Signed Overflow Detection
Signed overflow occurs when the result of addition is too large for a given type to represent.

This occurs when either:


Addition of two positive integers result in a negative integer result (so the result msb - the sign bit - is 1 when it should be zero)


or


Addition of two negative integers result in a positive integer result (so the result msb is 0 when it should be 1).


For each condition, we would then have:

(Positive integers input)

s[7] would be '1' for a[7] and b[7] both being '0' given by (s[7] [1 if result is negative] &amp; (~a[7]) [result is 1 if input was positive] &amp; (~b7)) [result 1 if input was positive]; the logical and would show that two positive inputs resulted in a negative output.

(Negative integers input)

Overflow occurs if we have a positive result, so:

s[7] would be zero for a[7] and b[7] both being 1. This is given by (~s[7] [result is 1 if positive result] &amp;a[7] [would be 1 for negative input] &amp;b[7]) [would be 1 for negative input. if all these bits evaluate 1, overflow has occurred.

Your assignment captures the negative input case and not the positive input case where the quoted answer captures both.