Forums - Open Redstone Engineers
Logic Gates Basics - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: ORE General (https://forum.openredstone.org/forum-39.html)
+--- Forum: Tutorials (https://forum.openredstone.org/forum-24.html)
+---- Forum: Fundamental Tutorials (https://forum.openredstone.org/forum-25.html)
+---- Thread: Logic Gates Basics (/thread-12364.html)



Logic Gates Basics - FreeProGamer - 06-03-2017

Hello, here you will read a brief and simple explanation about Logic Gates.
Lets take the "Gate" expression, imagine there is a gate, a closed one, and two guards are standing in the two front sides of it.
Each guard has a statement - a thing he requests from you - to open the gate, only when both of the guards are pleased, the gate will open and you can pass.
Lets set the statement to be giving a cookie, we will also say that you have infinite amount of cookies but you can give only one cookie to each guard.
Now, after we set upped our example, lets use it by the first gate - we can't call it a REAL gate, but it exists, the Input/Output gate:
In this case, we have only one guard securing the gate, when you come near the gate, the guard tells you his request: "I really like cookies, therefore, if you will give me a cookie, I will open the gate for you, else the gate will stay closed".
If we will translate it to computer engineering, this gate has only one input, and if it is ON, the output will be ON, else, the output will be OFF. Here is the truth table:
Input Output
0 0
1 1
Now, after you understood how the example works, we will continue, in a faster pace:
The NOT Gate:
Again, we have only one guard securing the gate, and he tells you the next: "Not like my brother, (the guard in the pervious gate) I do not like cookies, to be honest, I am alergic to them, so here's the deal, you will not give me cookies and I will open the gate, but if you will give me cookies, I will keep it close".
If we will translate it to computer engineering we will see this:
If the input is ON the output is OFF, else the output is ON. Here's the truth table:
Input Output
0 1
1 0
The next gate is OR Gate, it is a really basic but useful gate:
This time, the gate has two guards, and when you come nerby, one of them tells you the next: "If you will give a cookie to at least one of us (the guards) we will let you in".
When translated to computer engineering, we see that if the first input is ON, OR the second input is ON OR if both inputs are ON, the output will be ON, else it will be OFF. The truth table:
Input 1 Input 2 Output
0 0 0
1 0 1
0 1 1
1 1 1
The next gate will be the AND Gate:
And in this gate there are two guards, but they tell you almost the opposite of the OR Gate: "Only if you will BOTH of us cookies, we will let you in".
If we will translate it to computer engineering, it will look like this: Only if the first input AND the second input are ON, the output will be ON, else, the output will be OFF. We can see it more clearly in the truth table:
Input 1 Input 2 Output
0 0 0
1 0 0
0 1 0
1 1 1
If you will compare between the AND Gate, and the OR Gate, you will see they are almost the opposite.

At last we have the XOR gate:
Imagine the gate with two guards again, but this time, the guards hate each other, so when you come near, they tell you: "I will open the gate for you, but I will do so, if you will give a cookie ONLY to me, and not to him (the other guard)".
Basically, if translated to computer engineering, if the inputs' status will be different (one ON and one OFF) the output will be ON, else, if the inputs are the same (both OFF or ON), the output is OFF. The truth table looks like this:
Input 1 Input 2 Output
0 0 0
1 0 1
0 1 1
1 1 0
Now, we are done with the gates, the normal and basic at least. Next comes combinations, Gate + NOT, which in circuits looks like Gate --> Not Gate.
It basically means we take the gates we learned till now, and connect the output to a NOT gate.
Lets start with the NOR (NOT OR) Gate.
Remember the NOT Gate? The brother of the Input/Output's Gate Guard, yes the one that is alergic to cookies.
So, let's replace the guards in the OR Gate with these guards. And we get the next situation:
"Hey, we (the two guards) don't like cookies! We saw you gave everyone cookies but we don't like them! If you will give us cookies, at least 1, we will not open the gate, but if you will not give us cookies, we will open the gate".
Translated to circuits (computer engineering), if the NOR gate gets an input (at least one) the output is OFF, else, if the NOR gate does not get an input (both are OFF), the output is ON. The truth table looks like this:
Input 1 Input 2 Output
0 0 1
1 0 0
0 1 0
1 1 0
Now, comes the NAND Gate, here, one guard is alergic and one is not:
"Hey, I am alergic to cookies, but the other guard is not, if you will give him a cookie, or just won't give any of us a cookie, we will open the gate, else, if you will give both of us cookies, the gate will stay closed".
It might sound confusing so I will make it brief: NOT + [Gate]s are basically the opposite of the normal gate, which means, it inverts the output; If the output of the normal gate is ON, then the opposite of it will be OFF, and if the output of the normal gate is OFF, then the output of the NOT + [Gate] will be ON. So, if we will compare between AND and NAND gate's truth tables, we will see the next:
AND: Input 1 Input 2 Output NAND: Input 1 Input 2 Output
0 0 0 0 0 1
1 0 0 1 0 1
0 1 0 0 1 1
1 1 1 1 1 0
As you can see, where the output in the AND gate is 0, in the NAND is 1, and where the output of the AND is 1, the output of the NAND is 0.
Same happens with XNOR:
"Hey! Wait a second! We are alergic to cookies, but not as much as the others, so we can eat one, but we can also not eat cookies, so if you will give both of us or none of us cookies, we will open the gate. Else, the gate will stay closed".
Which means if the inputs have the same status, the output will be ON, else, if the inputs will have different status (as in XOR), the output will be OFF. Not suprisignly the same situation is located here too:
Input 1 Input 2 Output
0 0 1
1 0 0
0 1 0
1 1 1
This is it for logic gates, last note: There are a few more logic gates but they are almost useless, also, no matter what gate it is, it must have at least 1 input and only 1 output.
by Eldar Bakerman (also known as FreeProGamer)
Do not claim this post as yours.
© All rights reserved. Eldar Bakerman 2017


RE: Logic Gates Basics - LambdaPI - 06-03-2017

I like cookies.

Pretty good explanation tho. Nice job