Welcome to our community

Be a part of something great, join today!

Construct circuit that implements truth table

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
Hello!!! (Wave)

I want to construct a circuit that implements the following truth table:


\begin{equation*}
\begin{array}{c|c|c|c|c}
P(Input) & Q(Input) & K(Output) & A(Output) \\
\hline
1 & 1 & 1 & 0 \\
1 & 0 & 0 & 1 \\
0 & 1 & 0 & 1 \\
0 & 0 & 0 & 0
\end{array}
\end{equation*}


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.


Could you help me to construct the wanted circuit that implements the truth table? :unsure:
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,684
Hey evinda !!

Isn't output K the result of an AND port?
And output A the result of a XOR port?
Can we construct a circuit from those? πŸ€”

To add three 1-digit binary numbers, we need a truth table with inputs P, Q, R, and outputs K, A, don't we? πŸ€”
 

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
Hey evinda !!

Isn't output K the result of an AND port?
And output A the result of a XOR port?
Can we construct a circuit from those? πŸ€”
The XOR port gives $1$ when the input of true inputs is odd and $0$ otherwise, right? (Wasntme)

Can you help me construct the desired circuit? Do we create circles that represent the AND and XOR port and create arrows representing each possible input and ending at the output of the port? Or do we do something else? :unsure::unsure:
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,684
The XOR port gives $1$ when the input of true inputs is odd and $0$ otherwise, right?
Yep. (Nod)

Can you help me construct the desired circuit? Do we create circles that represent the AND and XOR port and create arrows representing each possible input and ending at the output of the port? Or do we do something else?
The are usually drawn as shown in the wiki article about Logic Gates. πŸ€”
 

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
The are usually drawn as shown in the wiki article about Logic Gates. πŸ€”
So you mean we construct the circuits as follows?

circuits.PNG


If so, does this mean that the we distinguish the circuits, i.e. what they represent, by taking into consideration the form ? :unsure::unsure::unsure:
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,684
So you mean we construct the circuits as follows?
Yep. :)

If so, does this mean that the we distinguish the circuits, i.e. what they represent, by taking into consideration the form ?
What do you mean? o_O
Distinguish which circuits?
Consider which form?
 

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
What do you mean? o_O
Distinguish which circuits?
Consider which form?
I meant the boxes that take the input. Do we look at the form of the boxes to see which logical operation we have? :unsure: For example, at the above circuits the only difference is the sumbol of the output and the form of the box... Isn't it? :unsure::unsure:
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,684
I meant the boxes that take the input. Do we look at the form of the boxes to see which logical operation we have? For example, at the above circuits the only difference is the sumbol of the output and the form of the box... Isn't it?
Yes, the shapes of the boxes identify the operations.
And the letters identify the inputs and the outputs. (Nod)
 

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
To add three 1-digit binary numbers, we need a truth table with inputs P, Q, R, and outputs K, A, don't we? πŸ€”
We need to get the outputs K,A in order to use thae above circuit? :unsure:

Also do we put the two circuits into one box so that it is joined-up? (Thinking)
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,684
We need to get the outputs K,A in order to use thae above circuit?

Also do we put the two circuits into one box so that it is joined-up?
Yes, put the two logic gates into 1 box, which will have inputs P and Q, and outputs K and A.
Afterwards I guess we'll have to reuse that box multiple times to achieve adding 3 binary bits. πŸ€”
 

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
Yes, put the two logic gates into 1 box, which will have inputs P and Q, and outputs K and A.
So we just draw a box including the both circuits above? Then the circuits would be independent one an other.... Or do we connect them somehow? :unsure:
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,684
So we just draw a box including the both circuits above? Then the circuits would be independent one an other.... Or do we connect them somehow?
The surrounding box should have only 2 inputs.
Inside the box those inputs should be split and go to both of the logic gates. πŸ€”
 

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
The surrounding box should have only 2 inputs.
Inside the box those inputs should be split and go to both of the logic gates. πŸ€”
You mean that the circuit has the following form? :unsure:

circ.PNG

Or do I have to change something? :unsure::unsure:
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,684
P and Q should not be connected to each other should they? (Worried)

Instead each of them should go separately to each logic gate. πŸ€”
 

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
P and Q should not be connected to each other should they? (Worried)

Instead each of them should go separately to each logic gate. πŸ€”
I have tried several times to draw such a circuit, but can it happen that the arrows of P and Q do not meet? :unsure: :unsure:
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,684
How about:
\begin{tikzpicture}

\usetikzlibrary{shapes.gates.logic.US}
\tikzstyle{branch}=[fill,shape=circle,minimum size=3pt,inner sep=0pt]

\node (P) at (-1,2) {P};
\node (Q) at (-1,1) {Q};
\coordinate (Pbranch) at (0.5,2) {};
\coordinate (Qbranch) at (1,1) {};

\node[and gate US, draw, logic gate inputs=nn] at (2,2) (And1) {};
\node[xor gate US, draw, logic gate inputs=nn] at (2,1) (Xor1) {};

\draw (P) -- (Pbranch) node[branch] {};
\draw (Q) -- (Qbranch) node[branch] {};
\draw (Pbranch) |- (And1.input 1);
\draw (Pbranch) |- (Xor1.input 1);
\draw (Qbranch) |- (And1.input 2);
\draw (Qbranch) |- (Xor1.input 2);
\draw (And1.output) -- +(2,0) node[ right ] { K };
\draw (Xor1.output) -- +(2,0) node[ right ] { A };

\draw[thick] (0,0) rectangle (3,3);

\end{tikzpicture}
πŸ€”
 

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
How about:
\begin{tikzpicture}

\usetikzlibrary{shapes.gates.logic.US}
\tikzstyle{branch}=[fill,shape=circle,minimum size=3pt,inner sep=0pt]

\node (P) at (-1,2) {P};
\node (Q) at (-1,1) {Q};
\coordinate (Pbranch) at (0.5,2) {};
\coordinate (Qbranch) at (1,1) {};

\node[and gate US, draw, logic gate inputs=nn] at (2,2) (And1) {};
\node[xor gate US, draw, logic gate inputs=nn] at (2,1) (Xor1) {};

\draw (P) -- (Pbranch) node[branch] {};
\draw (Q) -- (Qbranch) node[branch] {};
\draw (Pbranch) |- (And1.input 1);
\draw (Pbranch) |- (Xor1.input 1);
\draw (Qbranch) |- (And1.input 2);
\draw (Qbranch) |- (Xor1.input 2);
\draw (And1.output) -- +(2,0) node[ right ] { K };
\draw (Xor1.output) -- +(2,0) node[ right ] { A };

\draw[thick] (0,0) rectangle (3,3);

\end{tikzpicture}
πŸ€”
Seems reasonable... (Thinking) What do the dots represent? :unsure::unsure:
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,684
Seems reasonable... What do the dots represent?
A dot shows that the lines are connected. It's like they are soldered together.
Without a dot the lines cross without connection. 🧐
 

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
A dot shows that the lines are connected. It's like they are soldered together.
Without a dot the lines cross without connection. 🧐
What would it be if the dots would be missing at the specific case? So that I understand it better... :unsure:
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,684
What would it be if the dots would be missing at the specific case? So that I understand it better...
The same thing since in this particular case since the lines are not crossing where the dots are.
So they are connected anyway. In this case we could leave out the 2 dots. They merely clarify that the line crossings are not connected. 🧐
 
Last edited:

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
The same thing since in this particular case since the lines are not crossing where the dots are.
So they are connected anyway. In this case we could leave out the 2 dots. They merely clarify that the line crossings are not connected. 🧐
And what would happen if we would place dots at the point where the arrows of P and Q intersect? o_O I am confused right now.... :(
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,684
And what would happen if we would place dots at the point where the arrows of P and Q intersect? I am confused right now....
Then those lines would be connected and current can flow directly between the inputs P and Q.
It means we have a short circuit and if there are any fuses around they will blow up.
Or otherwise a fire will be started.
It is bad. 🧨 πŸŽ†πŸ”₯(Bandit)πŸ‘©β€πŸš’πŸ§―
 

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
Then those lines would be connected and current can flow directly between the inputs P and Q.
It means we have a short circuit and if there are any fuses around they will blow up.
Or otherwise a fire will be started.
It is bad. 🧨 πŸŽ†πŸ”₯(Bandit)πŸ‘©β€πŸš’πŸ§―
So in this case we just draw them in order to emphasize the different directions that the inputs go, they do not represent anything about the intersection of the different inputs, right? (Thinking)

Also, according to what you said , in any circuit of the logical expressions, we don't have dots at the intersection points. Or am I wrong? :unsure::unsure:
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,684
So in this case we just draw them in order to emphasize the different directions that the inputs go.
Yes... :unsure:

They do not represent anything about the intersection of the different inputs, right?
Different inputs should never intersect. It would mean we have a short circuit. (Worried)

Also, according to what you said , in any circuit of the logical expressions, we don't have dots at the intersection points. Or am I wrong?
We can have dots... I guess it may be a matter of preference...
The important thing is that there is no ambiguity... 🧐

Here's a different way to eliminate any ambiguity.
\begin{tikzpicture}
\usetikzlibrary{shapes.gates.logic.US}

\node[ and gate US, draw, logic gate inputs=nn ] at (2,2) (And1) {};
\node[ xor gate US, draw, logic gate inputs=nn ] at (2,1) (Xor1) {};

\draw (And1.input 1) -- +(-2.5,0) node[ left ] {P} +(-1.5,0) |- (Xor1.input 1);
\draw (Xor1.input 2) -- +(-2.5,0) node[ left ] {Q} +(-1,0) -- +(-1,0.09) arc (-90:90:0.08) |- (And1.input 2);;
\draw (And1.output) -- +(2,0) node[ right ] {K};
\draw (Xor1.output) -- +(2,0) node[ right ] {A};

\draw[ thick ] (0,0) rectangle (3,3);
\end{tikzpicture}
There are no dots, but now there is a hoop in one of the connections to show that the lines are not connected. πŸ€”
 

evinda

Well-known member
MHB Site Helper
Apr 13, 2013
3,718
Yes... :unsure:



Different inputs should never intersect. It would mean we have a short circuit. (Worried)



We can have dots... I guess it may be a matter of preference...
The important thing is that there is no ambiguity... 🧐

Here's a different way to eliminate any ambiguity.
\begin{tikzpicture}
\usetikzlibrary{shapes.gates.logic.US}

\node[ and gate US, draw, logic gate inputs=nn ] at (2,2) (And1) {};
\node[ xor gate US, draw, logic gate inputs=nn ] at (2,1) (Xor1) {};

\draw (And1.input 1) -- +(-2.5,0) node[ left ] {P} +(-1.5,0) |- (Xor1.input 1);
\draw (Xor1.input 2) -- +(-2.5,0) node[ left ] {Q} +(-1,0) -- +(-1,0.09) arc (-90:90:0.08) |- (And1.input 2);;
\draw (And1.output) -- +(2,0) node[ right ] {K};
\draw (Xor1.output) -- +(2,0) node[ right ] {A};

\draw[ thick ] (0,0) rectangle (3,3);
\end{tikzpicture}
There are no dots, but now there is a hoop in one of the connections to show that the lines are not connected. πŸ€”
I see.... (Wasntme)