Logic Gates - What are they?
As we saw in the previous article on the binary number system , computers use binary data for their functioning. Computers need a way to manipulate the inputs coming in as 0s and 1s to perform various operations and produce binary output. This is where logic gates come in. Logic gates are devices like transistors that can be used to implement Boolean functions. Boolean functions stand for logical operations where there are multiple binary inputs and a single output. Therefore, logic gates are essentially the building blocks of digital systems.
Logic gates work on the principle that digital circuits operate on two logic/binary values of 0 and 1. When the binary inputs enter the gate, the output assumes either a 0 or 1 value after performing some logical operations(wired in the gate). Logic gates are constructed using diodes or transistors which act like switches. Logic gates can be interconnected in multiple ways to represent any Boolean function and therefore any algorithm or complex operation. These gates are used in a multitude of digital circuits such as registers, computer memory, arithmetic logic units(ALU), microprocessors etc.
There are seven types of logic gates. The inputs and outputs of the gates are represented as 0 and 1 or True(T) and False(F) values. We can represent the function performed by a logic gate as a Boolean expression or a truth table. Truth tables represent different combinations of inputs and the corresponding output for any given logic gate. Let's look at the different types of 2 input logic gates:
1) AND Gate: The AND gate has two inputs (A and B) and has one output(Q). The value of Q is 1(T) only when both A and B are 1(T).
Boolean expression: Q = A.B
Q = A AND B
2) OR Gate: The OR gate has two inputs (A and B) and has one output(Q). The value of Q takes on the value of 1(T) if either A or B or both are 1(T).
Boolean expression: Q = A+B
Q = A OR B
3) NOT Gate: The NOT gate has one input(A) and one output(Q). The value of Q is the negated value of the input. Hence if A is 1(T), Q is 0(F) and vice versa.
Boolean expression: Q = NOT A
4) NAND Gate: The NAND gate has two inputs(A and B) and has one output(Q). The value of Q is the negated AND gate output. Hence, this gate returns a 1(T) when either one of the inputs is 0(F).
Boolean expression: Q = NOT(A.B)
Q = NOT(A AND B)
5) NOR Gate: The NOR gate has two inputs(A and B) and has one output(Q). The value of Q is the negated OR gate output. Hence this gate returns a 0(F) when either of the inputs is a 1(T).
Boolean expression: Q = NOT(A+B)
Q = NOT(A OR B)
6) XOR Gate: XOR gate stands for Exclusive OR gate. This gate has two inputs (A and B) and one output Q. The output Q is 1(T) if either A or B is true but Q is 0(F) when both of them are 1(T).
Boolean expression: Q = (A AND NOT B) OR (NOT A AND B)
Q = A⊕B
7) XNOR Gate: XNOR gate stands for Exclusive NOR gate. This gate has two inputs (A and B) and one output Q. The output Q is 1(T) only when both the inputs A and B are both 0(F) or both 1(T).
Boolean expression: Q = (A AND B) OR (NOT A AND NOT B)
Q= NOT(A⊕B)