0

full adder circuit

In this adder-subtractor design with the "M" input as the flag for subtraction, 0 minus 0 seems to provide the incorrect Cout. Let's assume that we're only using one full adder here (ignore A1/B1, A2/B2, A3/B3) for simplicity, and M=1, A0=0, A1=0:

The full adder will get the inputs of:

0 (B0) XOR 1 (M) = 1

0 (A0) = 0

1 (M) = 1

This results in 1+1=0, with Cout = 1 - but Cout should equal 0 for a full adder:

full adder truth table

I think inverting the final Cout will provide the correct result, but everywhere I look online for this adder-subtractor circuit has no inverter for the final Cout. Is this circuit supposed to have an inverter at the final Cout to fix this problem?

platizin
  • 792
  • 3
  • 10
  • 21

1 Answers1

1

The carry out equal to 1 is perfectly normal in this case.

When you work with unsigned logic the carry out is used as an overflow flag: assuming you're working with 4-bits operands, the operation:

a = 1000, b = 1001 (Decimal a = 8, b = 9)

  1000 +
  1001 =
--------
1 0001

produces a carry out of 1'b1 because the result of 8+9 cannot be represented on 4 bits.

On the other hand, when working with signed logic the carry out signal loses its 'overflow' meaning. Let's make an example:

a = 0111, b = 0010 (Decimal a = 7, b = 2)

  0111 +
  0010 =
--------
0 1001

In this case the result is 1001, that is -7 in two's complement. It's obvious that we had an overflow, since we added two positive numbers and we got a negative one. The carry out, anyway, is equal to 0. As a last case, if we consider:

a = 1111, b = 0001 (Decimal a = -1, b = 1)

  1111 + 
  0001 =
--------
1 0000

we see that even though the result is correct -1+1=0, the carry out is set.

To conclude, if you work in signed logic and you need to understand whether there was an overflow, you need to check the sign of the two operands against the result's one.

  • Both operands positive (MSB = 0) and result negative (MSB = 1): overflow
  • Both operands negative (MSB = 1) and result positive (MSB = 0): overflow
  • Any other case: no overflow
Sandro Sartoni
  • 123
  • 1
  • 11