# Boolean algebra and NAND gate

#### icelated

Joined Oct 15, 2010
12
I am a software engineering student taking a digital logic class, and i am trying to multiply this binary number. I am not sure what a carry in is and a Carry out. the teachers slides are horrible. It appears he used a truth table to do this but its confusing.
Rich (BB code):
   X1X0
+ Y1Y0
-----
Z2Z1Z0
I think thats how its set up! Now, for the multiplication part. Oh, i think the carry in and carry out is for adding?
If so, dont worry about the carry in and carry out part ok?
but i think i still need to use the multiplication answer for the table?

Rich (BB code):
       1  carry in?  like if we are adding? Now, that i think about it there is no carry in with multiplication!
110101
X 1101
------
101011001  thats what i ended up with. Probably, not right!
I think my truth table should look something like this: keep in mind this is not set up to my answer above

Rich (BB code):
       X1X0
+ Y1Y0
----
Z2Z1Z0

X0   Y0   Carry     Z0
0     0     0          0
1     0     0          1
0     1     0          1
1     1     1          0

X1    Y1     Carryin               Carryout    Z1
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
I get confused on the x1 and y1 part It would be easier if i can see it in action and labeled what the "carry in" is and "carry out" is while its being multiplied OR adding?.

would the "carry in" be the result of 1+1 and the "carry out" be the result of the next carry result?
I think after we get the truth table done with the carry in and carry out we are to use boolean algebra like:

Rich (BB code):
  Z1 = X1• Y1' • Carryin' + X1' • Y1• Carryin' + X1' • Y1' • Carryin + X1• Y1• Carryin
Carryout = X1• Y1• Carryin' + X1 • Y1' • Carryin + X1' • Y1• Carryin + X1 • Y1• Carryin
Z2 = Carryout
We are to "work out the equations for the AND, OR and NOT functions using only the NAND operator." not sure how to do this!

#### Georacer

Joined Nov 25, 2009
5,182
First things first! You must learn how to add binary numbers correctly. In this example we will learn how to add two 4-bit numbers.

The carry-in refers to a possible 1 that comes from a previous addition and must be taken into account for the current addition. Carry out refers to a possible carry that will be produced from our addition, if the result is larger than 4 bits (it can be at most 5 bits). It is a product of the current addition, not an operand

Suppose we want to add the numbers 1101 (12) and 1000 (8) and we have a carry in from a previous addition:

$$\begin{array}{ccccc} B4 & B3 & B2 & B1 & B0 \\ \ &\ &\ &\ &1\\ \ &1&1&0&1\\ +&1&0&0&0\\ -&-&-&-&-\\ 1&0&1&1&0 \end{array}$$

We make the additions of every column, starting from the right. In the result, we write only the last bit of the minor sum.
I remind that 0+0=0, 0+1=1, 1+1=10 and 1+1+1=11.

That said B0=1+1+0=10. We write 0 on the result and keep 1 as a carry for the next step.
B1=1+0+0=1
B2=1+0=1
B3=1+1=10
B4=1

As the result is larger (5 bits) than the operands, we usually say that we have an overflow and say that B4=1 is the carry out, while the result is 0110.

As for mutliplication, it is done exactly as in the decimal system. Refer here: http://en.wikipedia.org/wiki/Binary_multiplication#Multiplication for more info.