4
\$\begingroup\$

I'm currently trying to learn how binary adders work, but I don't understand what a "carry in" is for. What is the purpose of a "carry in"?

\$\endgroup\$
5
\$\begingroup\$

It's important to understand there's a difference between a half-adder and a full-adder.

A half-adder is the simplest. It has 2 inputs and 2 outputs. It's basically a XOR.

The primary output is only 1 if one of both inputs is 1, but not if both are 1. That's Sum. The second output is only 1 if both inputs are 1. That's Carry.

That's nice, but only if you're adding two bits. If you need more bits, you'll have to combine some adders together. Here's where full-adders come into play. The Least Significant Adder is a half-adder, and every More Significant Adder will be a full-adder which will take the Carry of the previous adder.

A   B   Cin     Cout    Sum
0   0   0       0       0
1   0   0       0       1
0   1   0       0       1
1   1   0       1       0
0   0   1       0       1
1   0   1       1       0
0   1   1       1       0
1   1   1       1       1

(shamelessly copied from Wikipedia)

If Carry in is 0, the behaviour of a full-adder is identical to a half-adder.

However, if Carry in is 1, the behaviour of Sum is inversed and the behaviour of Carry out changes into a OR. As long as any of the inputs is 1, Carry out is 1.

Carry in is required to turn a basic 2-bit adder into a multiple-bit counter. That's the purpose of Carry in.

\$\endgroup\$
  • 1
    \$\begingroup\$ With twos complement format (-x == ~x + 1), the carry-in can also be used for subtraction (inverting the subtrahend and setting the carry-in negates the value which can then be added). \$\endgroup\$ – Paul A. Clayton Jul 24 '15 at 0:21
  • \$\begingroup\$ @PaulA.Clayton Technically that would be a subtractor. I had the idea that would provide an information overload for OP, there is much more information to share about this matter. \$\endgroup\$ – Mast Jul 24 '15 at 0:32
  • \$\begingroup\$ Avoiding info-dumps can be difficult for some people (like me); your judgment is probably correct. \$\endgroup\$ – Paul A. Clayton Jul 24 '15 at 3:06
5
\$\begingroup\$

Besides what is said by those who replied earlier, Carry can also mean an input coming from the flag register that allows linking one sum on a ALU to the next one. By linking I mean that, if your computer architecture has a ALU with a word size of 8 bits and you need to do a 16 bit sum, the ALU can use the Carry flag, placing it on its carry in as a way to allow the processor to continue the sum from the previous one. This allows two 8 bit sums to become a single two step 16bit sum.

\$\endgroup\$
4
\$\begingroup\$

The purpose of the "carry" in is to accept the "carry" out of the previous adder. Carry works just like normal arithmetic.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.