Construct circuit that implements truth table

evinda

Well-known member
MHB Site Helper
Afterwards I guess we'll have to reuse that box multiple times to achieve adding 3 binary bits.

So we make the truth table for the sum of two inputs and then we find the truth value for the sum of the result that we find with a third input?

Or do we calculate directly the truth table of the sum of three inputs?

Klaas van Aarsen

MHB Seeker
Staff member
So we make the truth table for the sum of two inputs and then we find the truth value for the sum of the result that we find with a third input?

Or do we calculate directly the truth table of the sum of three inputs?
We could do either, but your problem statement says:
In addition, I want to use the above circuit to construct a full adder, i.e. a circuit that adds three 1-digit binary numbers.
So I believe we need to build a circuit from blocks that sum two inputs.

evinda

Well-known member
MHB Site Helper
We could do either, but your problem statement says:

So I believe we need to build a circuit from blocks that sum two inputs.

If we want to add two 1-digit binary numbers, we could give them as input at the circuit we created and the sum will be the value of K, won't it?

And then we could use the K above as the one input and the remaining 1-digit binary number and the new K that we will get will be the result of the sum of the three 1-digit binary numbers, right?

But is this that what we want ? Because the exercise asks to construct a circuit that adds three 1-digit binary numbers.... And the way I said it we implement twice a circuit, i.e. it is not a joined-up circuit and so there is no continuity.....

Klaas van Aarsen

MHB Seeker
Staff member
If we want to add two 1-digit binary numbers, we could give them as input at the circuit we created and the sum will be the value of K, won't it?

And then we could use the K above as the one input and the remaining 1-digit binary number and the new K that we will get will be the result of the sum of the three 1-digit binary numbers, right?

But is this that what we want ? Because the exercise asks to construct a circuit that adds three 1-digit binary numbers.... And the way I said it we implement twice a circuit, i.e. it is not a joined-up circuit and so there is no continuity.....
Isn't A what we get if we add P and Q together?
Except if P and Q are both 1, in which case we get the 2-digit number 10 that is represented by K and A together?
K is then the so called carry.

Last edited:

evinda

Well-known member
MHB Site Helper
Isn't A what we get if we add P and Q together?
Except if P and Q are both 1, in which case we get athe 2-digit number 10 that is represented by K and A together?
K is then the so called carry.
Ah I see!!! So with this circuit we can find the sum of two 1-digit binary numbers, right? What can we do to add also an other 1-digit binary number ?
Do we just implement again the operations of the circuit? Because the digits of A appear also at P.... Or do we do it somehow else?

Klaas van Aarsen

MHB Seeker
Staff member
We can add a third input R to the A we found, can't we?
And afterwards add both carries together?

evinda

Well-known member
MHB Site Helper
We can add a third input R to the A we found, can't we?
And afterwards add both carries together?
You mean that we pick the outputs of the circuit as inputs at an other circuit? Or do we add the third input R at the existing circuit?

evinda

Well-known member
MHB Site Helper
So is it somehow as below? If so, what do we do with the carries? Why do we add them? And also, if we use the sum, don't they have to be connected somehow at the circuits?

Klaas van Aarsen

MHB Seeker
Staff member
So is it somehow as below?

If so, what do we do with the carries? Why do we add them? And also, if we use the sum, don't they have to be connected somehow at the circuits?
Shouldn't the block in the left top be the same as the one at the right bottom?
I'll assume that it is, since otherwise it won't work.

Suppose we calculate $P+Q+R=1+1+0=10$.
Then we would get the outputs $K=1$, $K_2=0$, and $A_2=0$, wouldn't we?
How are those supposed to represent the result?
Shouldn't we have just 2 outputs?

evinda

Well-known member
MHB Site Helper
Shouldn't the block in the left top be the same as the one at the right bottom?
I'll assume that it is, since otherwise it won't work.
Oh yes, sorry!!! That's what I wanted to draw

Suppose we calculate $P+Q+R=1+1+0=10$.
Then we would get the outputs $K=1$, $K_2=0$, and $A_2=0$, wouldn't we?
Yes

How are those supposed to represent the result?
Shouldn't we have just 2 outputs?
We do not get the result because the carries are not added, right?

Should we have in general only two outputs? So do we connect the arrows of the first circuit directly with the second circuit? Also do we have to connect in the second circuit the results $K_1$ and $K_2$ in order to get the right carry as output?

In general, the only possible results are $1+0+0=1$, $1+1+0=0$ with carry $1$ and $1+1+1=1$ with carry $1$ and we can get it with any possible order of $0,1$ at the sum, right?

Klaas van Aarsen

MHB Seeker
Staff member
We do not get the result because the carries are not added, right?

Should we have in general only two outputs? So do we connect the arrows of the first circuit directly with the second circuit? Also do we have to connect in the second circuit the results $K_1$ and $K_2$ in order to get the right carry as output?
\begin{tikzpicture}
\draw (0,0) rectangle (8,6);
\draw (0,5) -- +(-1,0) node[ left ] {P};
\draw (0,3) -- +(-1,0) node[ left ] {Q};
\draw (0,1) -- +(-1,0) node[ left ] {R};
\draw (8,4) -- +(1,0) node[ right ] {K};
\draw (8,2) -- +(1,0) node[ right ] {A};
\draw (2,2) node {+} +(-0.5,+0.2) -- +(-1,+0.2) +(-0.5,-0.2) -- +(-1,-0.2) +(0.5,+0.2) -- +(1,+0.2) +(0.5,-0.2) -- +(1,-0.2) +(-0.5,-0.5) rectangle +(0.5,0.5);
\draw (3,3.5) node {+} +(-0.5,+0.2) -- +(-1,+0.2) +(-0.5,-0.2) -- +(-1,-0.2) +(0.5,+0.2) -- +(1,+0.2) +(0.5,-0.2) -- +(1,-0.2) +(-0.5,-0.5) rectangle +(0.5,0.5);
\draw (6,1) node {+} +(-0.5,+0.2) -- +(-1,+0.2) +(-0.5,-0.2) -- +(-1,-0.2) +(0.5,+0.2) -- +(1,+0.2) +(0.5,-0.2) -- +(1,-0.2) +(-0.5,-0.5) rectangle +(0.5,0.5);
\draw (5,5) node {+} +(-0.5,+0.2) -- +(-1,+0.2) +(-0.5,-0.2) -- +(-1,-0.2) +(0.5,+0.2) -- +(1,+0.2) +(0.5,-0.2) -- +(1,-0.2) +(-0.5,-0.5) rectangle +(0.5,0.5);
\end{tikzpicture}
That leaves how to connect the lines so that all possible sums are summed correctly.

In general, the only possible results are $1+0+0=1$, $1+1+0=0$ with carry $1$ and $1+1+1=1$ with carry $1$ and we can get it with any possible order of $0,1$ at the sum, right?
What do you mean?

evinda

Well-known member
MHB Site Helper
\begin{tikzpicture}
\draw (0,0) rectangle (8,6);
\draw (0,5) -- +(-1,0) node[ left ] {P};
\draw (0,3) -- +(-1,0) node[ left ] {Q};
\draw (0,1) -- +(-1,0) node[ left ] {R};
\draw (8,4) -- +(1,0) node[ right ] {K};
\draw (8,2) -- +(1,0) node[ right ] {A};
\draw (2,2) node {+} +(-0.5,+0.2) -- +(-1,+0.2) +(-0.5,-0.2) -- +(-1,-0.2) +(0.5,+0.2) -- +(1,+0.2) +(0.5,-0.2) -- +(1,-0.2) +(-0.5,-0.5) rectangle +(0.5,0.5);
\draw (3,3.5) node {+} +(-0.5,+0.2) -- +(-1,+0.2) +(-0.5,-0.2) -- +(-1,-0.2) +(0.5,+0.2) -- +(1,+0.2) +(0.5,-0.2) -- +(1,-0.2) +(-0.5,-0.5) rectangle +(0.5,0.5);
\draw (6,1) node {+} +(-0.5,+0.2) -- +(-1,+0.2) +(-0.5,-0.2) -- +(-1,-0.2) +(0.5,+0.2) -- +(1,+0.2) +(0.5,-0.2) -- +(1,-0.2) +(-0.5,-0.5) rectangle +(0.5,0.5);
\draw (5,5) node {+} +(-0.5,+0.2) -- +(-1,+0.2) +(-0.5,-0.2) -- +(-1,-0.2) +(0.5,+0.2) -- +(1,+0.2) +(0.5,-0.2) -- +(1,-0.2) +(-0.5,-0.5) rectangle +(0.5,0.5);
\end{tikzpicture}
That leaves how to connect the lines so that all possible sums are summed correctly.
You mean that we conctruct for example a circuit that contains each logic gate of the above circuit twice?

What do you mean?
I meant that these are the possible operations that we could have, given that we take into consideration the sum of three one-digit binary numbers... Or am I wrong?

Klaas van Aarsen

MHB Seeker
Staff member
You mean that we conctruct for example a circuit that contains each logic gate of the above circuit twice?
I meant that we have a 'global' $K$ and $A$ as output, and we have to figure out how to get them.
We might also call them $K_{\text{3 digit sum}}$ and $A_{\text{3 digit sum}}$ to make it more explicit.
Actually, let's make them $K_3$ and $A_3$ for short.

I've simplified the circuit we are supposed to use as a building block by representing it as a square with a $\boxed{+}$ sign in it.
The $\boxed{+}$ represents the combination of the AND gate and the XOR gate.

I think we can also assume that we will start with adding $P$ and $Q$ together, can't we?
If we do, then perhaps we can call its intermediate outputs $K_1$ and $A_1$.

I meant that these are the possible operations that we could have, given that we take into consideration the sum of three one-digit binary numbers... Or am I wrong?
In general, the only possible results are $1+0+0=1$, $1+1+0=0$ with carry $1$ and $1+1+1=1$ with carry $1$ and we can get it with any possible order of $0,1$ at the sum, right?
Did you mean "any possible order of $0,1$ at the first sum"?
That is, we treat (1+0)+R the same as (0+1)+R?

If so, isn't $(1+0)+1$ missing then?

evinda

Well-known member
MHB Site Helper
I meant that we have a 'global' $K$ and $A$ as output, and we have to figure out how to get them.
We might also call them $K_{\text{3 digit sum}}$ and $A_{\text{3 digit sum}}$ to make it more explicit.
Actually, let's make them $K_3$ and $A_3$ for short.

I've simplified the circuit we are supposed to use as a building block by representing it as a square with a $\boxed{+}$ sign in it.
The $\boxed{+}$ represents the combination of the AND gate and the XOR gate.

I think we can also assume that we will start with adding $P$ and $Q$ together, can't we?
If we do, then perhaps we can call its intermediate outputs $K_1$ and $A_1$.
So is the desired circuit the following? Then the sum P+Q+R is $A_4$.

Did you mean "any possible order of $0,1$ at the first sum"?
That is, we treat (1+0)+R the same as (0+1)+R?

If so, isn't $(1+0)+1$ missing then?
So at the first step the possible sums are 0+0, 0+1 and 1+0, 1+1 and then at the second step the possible sums are the results of these + 0 or 1, right?

Klaas van Aarsen

MHB Seeker
Staff member
So is the desired circuit the following? Then the sum P+Q+R is $A_4$.
Shouldn't we have $K_4$ as output then as well?

Suppose $+Q+R=0+1+1=10$. Then we get $A_4=1$ don't we?

So at the first step the possible sums are 0+0, 0+1 and 1+0, 1+1 and then at the second step the possible sums are the results of these + 0 or 1, right?
Yep.

evinda

Well-known member
MHB Site Helper
Shouldn't we have $K_4$ as output then as well?

Suppose $+Q+R=0+1+1=10$. Then we get $A_4=1$ don't we?
Oh yes, right... So do we have to add an other circuit in order to include $K_4$?

Klaas van Aarsen

MHB Seeker
Staff member
Oh yes, right... So do we have to add an other circuit in order to include $K_4$?
We already have $K_4$ don't we?

But I think the circuit is not correct yet.
If we have $P+Q+R=0+1+1$ we should get $10$ shouldn't we? That is, $K_4=1$ and $A_4=0$.
But don't we get $K_4=0$ and $A_4=1$?

evinda

Well-known member
MHB Site Helper
We already have $K_4$ don't we?

But I think the circuit is not correct yet.
If we have $P+Q+R=0+1+1$ we should get $10$ shouldn't we? That is, $K_4=1$ and $A_4=0$.
But don't we get $K_4=0$ and $A_4=1$?
Oh yes, you are right!! I have noticed that the second circuit gives the right result...
Does this happen for any possible case? So is $A_2$ with carry $K_2$the desired sum?

evinda

Well-known member
MHB Site Helper
I have thought about it again.....

Is the desired circuit the following?

Klaas van Aarsen

MHB Seeker
Staff member
I have thought about it again.....

Is the desired circuit the following?
Looks good to me!

Just for fun, I made a drawing as well.

\begin{tikzpicture}
\usetikzlibrary{shapes.gates.logic.US}
\tikzset{
\draw[thick] (-0.8,-0.8) rectangle (0.8,0.8);
\node[and gate US,draw] at (0,0.35) (And1) {};
\node[xor gate US,draw] at (0,-0.35) (Xor1) {};
\path
(And1.input 1)+(-1,0) coordinate (-in 1)
(Xor1.input 2)+(-1,0) coordinate (-in 2)
(And1.output)+(1,0) coordinate (-K)
(Xor1.output)+(1,0) coordinate (-A);

\draw (-in 1) -- (And1.input 1) +(-0.35,0) |- (Xor1.input 1);
\draw (-in 2) -- (Xor1.input 2) +(-0.2,0) |- (And1.input 2);
\draw (And1.output) -- (-K);
\draw (Xor1.output) -- (-A);
}
}

\node[draw,minimum width=10cm,minimum height=5cm] (Block) {};

\path
(Add1-in 1 -| Block.west)+(-1,0) coordinate[label=left: P] (P)
(Add2-in 2 -| Block.west)+(-1,0) coordinate[label=left:R] (R)
(P) -- node[shape=coordinate,label=left:Q] (Q) {} (R)
;

\node[above] at (Add1-A) {$A_1$};
\node[above] at (Add1-K) {$K_1$};
\node[above] at (Add2-A) {$A_2$};
\node[above] at (Add2-K) {$K_2$};
\node[above] at (Add3-A) {$A_3$};
\node[above] at (Add3-K) {$K_3$};

\end{tikzpicture}

evinda

Well-known member
MHB Site Helper
Looks good to me!

Just for fun, I made a drawing as well.

\begin{tikzpicture}
\usetikzlibrary{shapes.gates.logic.US}
\tikzset{
\draw[thick] (-0.8,-0.8) rectangle (0.8,0.8);
\node[and gate US,draw] at (0,0.35) (And1) {};
\node[xor gate US,draw] at (0,-0.35) (Xor1) {};
\path
(And1.input 1)+(-1,0) coordinate (-in 1)
(Xor1.input 2)+(-1,0) coordinate (-in 2)
(And1.output)+(1,0) coordinate (-K)
(Xor1.output)+(1,0) coordinate (-A);

\draw (-in 1) -- (And1.input 1) +(-0.35,0) |- (Xor1.input 1);
\draw (-in 2) -- (Xor1.input 2) +(-0.2,0) |- (And1.input 2);
\draw (And1.output) -- (-K);
\draw (Xor1.output) -- (-A);
}
}

\node[draw,minimum width=10cm,minimum height=5cm] (Block) {};

\path
(Add1-in 1 -| Block.west)+(-1,0) coordinate[label=left: P] (P)
(Add2-in 2 -| Block.west)+(-1,0) coordinate[label=left:R] (R)
(P) -- node[shape=coordinate,label=left:Q] (Q) {} (R)
;

\node[above] at (Add1-A) {$A_1$};
\node[above] at (Add1-K) {$K_1$};
\node[above] at (Add2-A) {$A_2$};
\node[above] at (Add2-K) {$K_2$};
\node[above] at (Add3-A) {$A_3$};
\node[above] at (Add3-K) {$K_3$};