I remember studying about logic gates for the first time in a computer class in school, AND, NAND, OR, NOR, NOT, XOR gates. It sounded like the stupidest thing I had ever learnt. Added to that it was too easy to even be worth teaching. And why would anyone teach it in a computers course anyway??
AND logic gate has a minimum of two inputs. The gate/output is ON only when all its inputs are ON. This can also be written in the form of a table:
OR logic gate has a minimum of two inputs as well. The gate/output is ON when either of its inputs is ON. This can also be written in the form of a table:
NOT logic gate has only one input. The gate/output is ON only when its input is OFF. This can also be written in the form of a table:
EXAMPLE 3:
Has it got anything to do with computers??
The answer, Yes, it has everything to do with computers. The fact that a digital computer exists is because of logic gates. All of the decisions a computer takes and the tasks a computer does are dependent on logic gates.
It was only in college during my Digital Electronics course did I finally recognize the power of logic gates.
Although its self explanatory, let me first explain what a gate is. A gate is a device that allows an event to happen. It controls when the event happens and for how long that event happens. For eg. the switch acts as a gate for the light bulb since its operation determines when the light is switched ON and for how long does the light stay on. So gates have just two states, they may be ON or OFF (1 or 0 in binary).
Logic gates are devices that switch their gate/output depending on the state of its inputs. The inputs also have only two states ON or OFF.
Logic gates could be of 3 major types:
AND gate
OR gate
NOT gate
together they are also called AOI (And Or Invert) logic.
AND Gate:

for inputs X and Y and output Z
As can be seen in the above table Z is ON only when both X and Y are ON.
OR Gate:

for inputs X and Y and output Z
NOT Gate:

for input X and output Z
As can be seen in the above table Z is ON when X is OFF.
These three logic gates can be used to create any other logical operator.
There is one more special logic gate that is worth mentioning because of its uniqueness, even though it can be made using the above mentioned logic gates.
Its the XOR (eXclusive OR) gate.
For inputs X and Y and output Z the table looks like this:
This gate is interesting since the gate is ON when only one of the two inputs is ON. In other words, its output is OFF when the inputs are the same.
Even though I have explained the logic gates and their "Truth" tables, it still isn't very obvious where one would use them, so let me give you a few simple examples,
EXAMPLE 1:
Suppose you want to design a machine that gives you an umbrella. For this the machine needs 2 inputs. First, if you are going out and second, if it is raining. Now, we make a table for it:
Suppose you want to design a machine that gives you an umbrella. For this the machine needs 2 inputs. First, if you are going out and second, if it is raining. Now, we make a table for it:
If you replace Yes's and No's with 1's and 0's you will notice its actually an AND gate. So to make this machine we need to make an AND gate.
EXAMPLE 2:
Suppose you want to store water in a tank, with a tap on its side, to use later, but you want a machine that opens the tap when the tank is full so water won't overflow. For this, the machine needs 2 inputs. First, if the tank is full and second, if water is needed for use. Again, making a table for it:
Suppose you want to store water in a tank, with a tap on its side, to use later, but you want a machine that opens the tap when the tank is full so water won't overflow. For this, the machine needs 2 inputs. First, if the tank is full and second, if water is needed for use. Again, making a table for it:
Replacing the Yes's and No's with 1's and 0's we realize we need an OR gate.
EXAMPLE 3:
Suppose we want to make a machine that turns the streetlight ON at night. For this, the machine only needs one input- if there is sunlight or not. Again, making a table:
On replacing Yes's and No's with 1's and 0's we notice its a NOT gate.
Even though I have used very simple examples of machines but, regardless of how complex the machine is, if analyzed properly, one can design the machine using various combinations of this AOI logic.
In the upcoming posts I will be using this concept of logic gates to explain how I designed various parts of my computer. till then...
Got any queries???
E-Mail me at: shashwath.sundar@gmail.com
Comments
Post a Comment