Construct circuit that implements truth table

In summary: I just cant seem to get it right. :(It's not that hard, actually. Just follow these steps: 1. Draw a circle for each input.2. Draw a line from the circle to the input port.3. Draw another line from the output port to the circle.4. Draw an arrow from the input port to the circle.5. Draw an arrow from the output port to the output port.That's it. :)It's not that hard, actually. Just follow these steps: 1. Draw a circle for each input.2. Draw a line from the circle to the input port.3. Draw another line from the output port to the
  • #36
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?

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. 🤔

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?

What do you mean? o_O
 
Physics news on Phys.org
  • #37
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. 🤔

You mean that we conctruct for example a circuit that contains each logic gate of the above circuit twice? :unsure: :unsure:

Klaas van Aarsen said:
What do you mean? o_O

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? (Thinking)(Thinking)
 
  • #38
evinda said:
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$. 🤔

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?

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? :unsure:

If so, isn't $(1+0)+1$ missing then? :unsure:
 
  • #39
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$. 🤔

So is the desired circuit the following? :unsure: Then the sum P+Q+R is $A_4$.

A_4.png


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:

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? :unsure:
 
  • #40
evinda said:
So is the desired circuit the following? Then the sum P+Q+R is $A_4$.

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)

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?
Yep. (Nod)
 
  • #41
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)

Oh yes, right... :unsure::unsure: So do we have to add an other circuit in order to include $K_4$? :oops:
 
  • #42
evinda said:
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$? (Worried)
 
  • #43
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)
Oh yes, you are right! (Wasntme) 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? :unsure::unsure:
 
  • #44
I have thought about it again... :unsure:

Is the desired circuit the following?

output.png
 
  • #45
evinda said:
I have thought about it again...

Is the desired circuit the following?
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}
 
  • #46
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}

Nice, thanks a lot! (Party)
 

Similar threads

Replies
2
Views
1K
Replies
17
Views
2K
Replies
1
Views
1K
Replies
3
Views
1K
Replies
2
Views
1K
Replies
9
Views
2K
Replies
16
Views
1K
Replies
4
Views
1K
Back
Top