- 16,335
- 258
We can add a third input R to the A we found, can't we?
And afterwards add both carries together?
And afterwards add both carries together?
Klaas van Aarsen said:We can add a third input R to the A we found, can't we?
And afterwards add both carries together?![]()
evinda said: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 said:Shouldn't the block in the left top be the same as the one at the right bottom? (Worried)
I'll assume that it is, since otherwise it won't work.
Klaas van Aarsen said: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?
Klaas van Aarsen said:How are those supposed to represent the result?
Shouldn't we have just 2 outputs?![]()
evinda said: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?
evinda said: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 said:How about something like this:
\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.![]()
Klaas van Aarsen said:What do you mean?![]()
evinda said:You mean that we conctruct for example a circuit that contains each logic gate of the above circuit twice?
evinda said: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?
evinda said: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 said: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$.![]()
Klaas van Aarsen said: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? :unsure:
evinda said:So is the desired circuit the following? Then the sum P+Q+R is $A_4$.
Yep. (Nod)evinda said: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 said:What about the carry?
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? (Worried)
We already have $K_4$ don't we?evinda said:Oh yes, right... So do we have to add an other circuit in order to include $K_4$?
Oh yes, you are right! (Wasntme) I have noticed that the second circuit gives the right result...Klaas van Aarsen said: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$? (Worried)
Looks good to me! (Nod)evinda said:I have thought about it again...
Is the desired circuit the following?
Klaas van Aarsen said:Looks good to me! (Nod)
Just for fun, I made a drawing as well. (Blush)
\begin{tikzpicture}
\usetikzlibrary{shapes.gates.logic.US}
\tikzset{
add/.pic = {
\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) {};
\draw (-3.5,1) pic (Add1) {add};
\draw (-0.5,-1) pic (Add2) {add};
\draw (2.5,0.5) pic (Add3) {add};
\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)
(Add2-A -| Block.east)+(1,0) coordinate[label=right:A] (A)
(Add3-A -| Block.east)+(1,0) coordinate[label=right:K] (K)
(P) -- node[shape=coordinate,label=left:Q] (Q) {} (R)
;
\draw (P) -| (Add1-in 1);
\draw (Q) -| (Add1-in 2);
\draw (R) -| (Add2-in 2);
\draw (Add1-A) -| (Add2-in 1);
\draw (Add1-K) -| (Add3-in 1);
\draw (Add2-A) -| (A);
\draw (Add2-K) -| (Add3-in 2);
\draw (Add3-A) -| (K);
\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}