If by chance you have dealt with computer logic or digital electronics at one point or another, you already know what I am talking about. You can go ahead and refresh your know how. If you still unaware of this concept, worry not, this article has you covered. The gates discussed here are as implemented in computer processors and other digital circuits for one or more purposes. Read on as this logic is demystified.

A *logic gate* is an idealized or physical device that
performs a logical operation on one or more binary inputs and gives one
binary output. There are several ways in which these gates can be
implemented but for our case we shall use the transistor gates, more
specifically – metal-oxide semiconductor field effect transistor
(MOSFET). This transistor works in a very straight forward way; *when voltage is applied to the transistor, the transistor either turns the circuit on or off.*
When the circuit is turned off, this is considered to be a zero (0)
state in binary and when the circuit is on, this is considered to be one
(1).

In this kind of circuitry, the high state is either near or equal to 5 volts while the low state is near or equal to 0 volts. Consider a current passing through such a MOSFET. If the current is near or equal to zero, the circuit turns off producing a zero (0) or false value. In the case of a computer processor, this shall cause a reaction in the next gate and so forth thereby giving a desired end result. Millions of such gates act together and each gate can contain one or more transistors. Let us get right into the types of gates we have and how they perform.

There are *seven* basic logic gates and for each, this article shall explain them using their truth tables. A *truth table*
is a table used in connection with Boolean Algebra logic and calculus
to set out functional values of logical expressions for each of their
arguments. I shall not draw the tables but the explanation for each
shall suffice. Remember, the output of a logical gate is one value, the
input can be one or more values. We shall be using mathematical signs to
represent these gate because of the *algebraic equations* we
shall consider a bit later. I shall also refrain from using the equals
(=) sign for obvious reasons and instead, I shall use the sign: ⇒

**Logical gate** **AND** : This gate
dictates that for the output to be true (1), then both inputs must be
true (1) and for any other combination of inputs, the output is false
(0). The AND gate is represented using a period (**.**) to
mean the mathematical multiplication sign (x). As such, when passing
binary values through an AND logic gate then the output shall be as
follows.

1.1 ⇒ 1

1.0 ⇒ 0

0.1 ⇒ 0

0.0 ⇒ 0

**Logical gate** **OR** : For this gate,
the output is only false if both inputs are false. It is represented
using an addition sign (+). The results shall be as follows.

1+1 ⇒ 1

1+0 ⇒ 1

0+1 ⇒ 1

0+0 ⇒ 0

**Logical gate** **NOT** : This gates dictates the inversion of the input. If true is the input, the output becomes false. To represent the NOT gate (^{__}) is used on top of the input like so: Ā. Therefore, the results below show the output of a NOT gate.

Where A=1, Ā ⇒ 0

Where A=0, Ā ⇒ 1

Those are the first three fundamental gates. Basically all other gates are derivatives of those three gates. The next four gates are: XOR, NAND, NOR, and XNOR covered below.

**Logical gate XOR** : The XOR(exclusive-OR) acts in a
way that can escape the grasp of few especially when the gates are
complicated. For two inputs, the gate gives a true output only if either
of the values is true and gives a false output if both values of the
input are either true or false. In simpler terms, you only get 1 if you
have both 1 and 0 in your input. Examine the simple illustration below.

1+1 ⇒ 0

1+0 ⇒ 1

0+1 ⇒ 1

0+0 ⇒ 0

**Logical gate NAND** : This gate is basically an AND
gate followed by a NOT gate. The results are thus the inverse of those
of the AND gate. Observe the illustration below to understand better.

1.1 ⇒ 0

1.0 ⇒ 1

0.1 ⇒ 1

0.0 ⇒ 1

**Logical gate NOR** : Just like the NAND gate, this is a
combination of two gates. The OR gate followed by the NOT gate. The
output is inverse of the OR gate. Observe the illustration below.

1+1 ⇒ 0

1+0 ⇒ 0

0+1 ⇒ 0

0+0 ⇒ 1

**Logical gate XNOR** : Just like the NAND and NOR
gates, this is a combination of two gates. The XOR gate followed by the
NOT gate. The output is inverse of the XOR gate. Observe the
illustration below.

1+1 ⇒ 1

1+0 ⇒ 0

0+1 ⇒ 0

0+0 ⇒ 1

With that settled, let us get into a bit of algebra so that we can see the equations as should be represented. The equations become very important while dealing with complex logical gates that have been combined in various different ways. We’ll start simple then get complex, if you need to pick a pen and paper go right ahead and of course, any queries can be left in the comments section below.

*Problem 1: The AND Gate*

For our problem, we are going to
have two inputs A and B. Remember, we have the period (.) representing
the transition of both inputs through a gate.

Where A = 1 and B = 0,**A.B ⇒ 0**

Where A = 0 and B = 1,**A.B ⇒ 0**

Where A = 1 and B = 1,

**A.B ⇒ 1**

Where A = 0 and B = 0,**A.B ⇒ 0**

*Problem 2: The OR Gate*

For our problem, we are going to
have two inputs A and B. Remember, we have the plus (+) representing the
transition of both inputs through a gate.

Where A = 1 and B = 0,**A+B ⇒ 1**

Where A = 0 and B = 1,**A+B ⇒ 1**

Where A = 1 and B = 1,

**A+B ⇒ 1**

Where A = 0 and B = 0,**A+B ⇒ 0**

*Problem 3: The NAND Gate*

For our problem, we are going to
have two inputs A and B. Remember, we have the period (.) representing
the transition of both inputs through a gate and the NOT gate is also
present meaning we are going to have to invert the output of the AND
gate. Observe.

Where A = 1 and B = 0,**A.B ⇒ 1**

Where A = 0 and B = 1,**A.B ⇒ 1**

Where A = 1 and B = 1,**A.B ⇒ 0**

Where A = 0 and B = 0,**A.B ⇒ 1**

*Problem 4: The NOR Gate*

For our problem, we are going to
have two inputs A and B. Remember, we have the plus (+) representing the
transition of both inputs through a gate and the NOT gate is also
present meaning we are going to have to invert the output of the OR
gate. Observe.

Where A = 1 and B = 0,**A+B ⇒ 0**

Where A = 0 and B = 1,**A+B ⇒ 0**

Where A = 1 and B = 1,**A+B ⇒ 0**

Where A = 0 and B = 0,**A+B ⇒ 1**

Now, you do get the flow of Boolean Algebra. Pretty much straight
forward. Earlier in this article, I mentioned that indeed the gates can
be combined – in their millions as in processors to produce a desired
effect. In our final example, we shall combine several gates with the
intention of coming up with a final, single output.

Consider a system that has the following inputs: A and B and an output Q (*you can use any letter to represent the output*).
The system has three gates combined in this order: AND and NOR in
parallel and an OR gate in series to both the AND and NOR gates.
Diagrammatically, the system shall be as the figure below. (*Note that there are other several representations of gates and such systems*).

From the above image, it is visible that the AND and NOR have two
inputs each and the OR gate has two inputs too, one from each of the
previous gates. Consider the representation of the system in Boolean
Algebra. **Q = (A.B) + (****A+B****)** *where did I get this? Observe the explanation below. *

We have three gates and the equations for each is as follows.*AND gate*

A.B *NOR gate*

A + B

For the *OR *
gate, the input is the result of both the AND and the NOR gate. To make
sure the right order of operation is followed, you use brackets.
Therefore:*OR gate*

Q = (A.B) + (A + B)

That is where we get the equation. To work with actual binary, you substitute the letters with relevant numbers, either 1 or 0.

With that, you now have the fundamentals of logical gates.

## 2 thoughts to “Logic Gates”