## Logic Gates – What are logic gates?

> > Logic Gates – What are logic gates? # Logic Gates – What are logic gates?

Logic gates can be called as a type of amplifier circuits which are used in digital circuits to generate voltage signals corresponding to binary conditions True(high) and False(low) which can be also represented by o’s(false) and 1’s(true). Logic gates are based on Boolean algebra and they usually consist of two inputs and single output and the output will change according to the gate that is being used. These gates do not amplify the signals and they are mostly seen in integrated circuits (IC).

### Boolean algebra

To mathematically analyze and simply the digital circuits and gates we use Boolean algebra. This was invented by the English mathematician George Bool in 1854. Boolean algebra helps us to reduce the number of logic gates used in a selected circuit with the help of rules set called “Laws of Boolean”. Therefore, this is a method which is used to reduce the number of Boolean Expressions mathematically according to its own set of rules.

### Logic diagram

To represent a logic circuit graphically we design logic diagrams. This displays the connection between each individual logic gate with the wiring connection, represented using a specific graphical symbol for each individual logic gate.

## Logic Gates Types

The connection between the input and the output differs with a certain type of logic circuit. Basically, there are seven types of logic gates: AND gate: NAND gate OR gate NOR gate NOT gate XOR gate and XNOR gate. There are two types of symbols which is commonly used to represent logic gates. They are traditional symbols (the symbol widely used in education and industry purposes) and IEC(International ElectroTechnical Commission) symbol.

### Logic AND Gate

The AND gate has two or more inputs connections attached to it. Its logic works when all the inputs are True(high) then the output is High (True), otherwise all the outputs are False(low).

### Logic OR Gate

OR gate have a minimum of two inputs, and it can be more. If any of the input signals are True(high) the output is True. The output is only getting False(low) when all the inputs are False(low).

### NOT gate (Inverter)

NOT gate consists of only one input and one output and the output is the negation/inverse of the input. This gate is also called the inverter.

### Logic NAND Gate

This is known as Not AND gate. It has the same parameters as the AND gate but the output is inverted. Usually a NAND gate has two or more inputs attached to it and has only one output. If all the inputs are TRUE (high) the output is FALSE (low) otherwise the output is TRUE (high) all the time.

### Logic NOR Gate

This is known as Not OR gate. It has the same parameters as the OR gate, but the output is inverted. Usually NOR gate has two or more inputs attached to it and has only one output. If any input is TRUE (high) the output is FALSE (low) otherwise the output is TRUE (high) all the time.

### Logic XOR Gate

XOR gate is also known as EXclusive OR gate. This also looks like an OR gate but when the both inputs have the same values (TRUE, TRUE or FALSE, FALSE) the output is FALSE (low). When the both inputs have different values (TRUE and FALSE) the output is TRUE (high). This gate has only two inputs.

### Logic XNOR Gate

XOR gate is also known as EXclusive NOR gate. It has the same parameters as the XOR gate, but the output is inverted. When the both inputs have the same values (TRUE, TRUE or FALSE, FALSE) the output is TRUE (high). When the both inputs have different values (TRUE and FALSE) the output is FALSE (low). This gate has only two inputs.

### Buffer

Buffers have only one input and one output. Buffer acts like the negation of the NOT gate. This passes the input signal without changing the input in anyways. The purpose of the buffer is to increase the propagation delay of the logic circuit.

## Logic gate truth tables

Truth table is a table which is used to help show the Boolean expression of a logic gate. Therefore, it helps to understand the behavior of logic gates. Truth table helps us see the connection between its inputs and outputs by showing how the inputs of a logic gate connected to its resultant outputs.

In the Truth table, the left columns denote the inputs for the gates and right columns denote the outputs. Table consists of all the different possible input combinations and all the possible outputs related to that.

As an example, let’s consider a logic circuit having two variable inputs. Since there are two variable inputs, we can get four different combinations for those inputs {(HIGH, HIGH), (HIGH, LOW), (LOW, HIGH), (LOW, LOW)}. For those four combinations there are four outputs. When we write Boolean expressions and work with logic truth tables we use 1’s and 0’s instead of HIGH and LOW respectively.

Then, the tour different possible combinations of the two inputs can be given as follows:

1st Combination – “LOW” – “LOW” or (0, 0)

2nd Combination – “LOW” – “HIGH” or (0, 1)

3rd Combination – “HIGH” – “LOW” or (1, 0 )

4th Combination – “HIGH” – “HIGH” or (1, 1 )

According to above, when a logic circuit has 3 inputs there should be eight different combinations. We can conclude that the number of combinations increases with the increase of the number of inputs in power of 2. If the number of inputs is n there will be two to the power n (2n) number of combinations.

### AND Gate Truth table

The truth table for the 2-input AND gate is as follows. Let’s label A, B as inputs and the Q is the output.

### OR Gate Truth table

The truth table for the 2-input OR gate is as follows.. Let’s label A, B as inputs and the Q is the output.

### NOT Gate Truth table (Inverter)

Following is the truth table for NOT gate. Let’s label A as input and the Q is the output.

### NAND Gate Truth table

The truth table for the 2-input NAND gate is as follows.. Let’s label A, B as inputs and the Q is the output.

### NOR Gate Truth table

The truth table for the 2-input NOR gate is as follows. Let’s label A, B as inputs and the Q is the output.

### XOR Gate Truth table

The truth table for 2-input XOR gate is as follows. Let’s label A, B as inputs and the Q is the output. Usually we express the Exclusive-OR or Exclusive-NOR function by using a character with a plus sign inside a circle (⊕).

### XNOR Gate Truth table

The truth table for the 2-input XNOR gate is as follows. Let’s label A, B as inputs and the Q is the output.

## Pull-up and Pull-down Resistors

Pull-up and pull-down resistors can be seen in many of the electronic circuits. Those resistors are used to correctly bias the input signals of digital gates to prevent the inputs from random floating. With the help of the pull up and pull-down resistors microcontrollers can easily establish communication with their hardware devices. To achieve “HIGH” or “LOW” states we have to implement pull up and pull-down resistors into the logic circuit, if there is no connection to the GPIO pins we get a floating impedance state.

## Logic circuits

Usually logic circuits use voltage to represent the Boolean values (TRUE, FALSE). Logic circuits consist of inputs and outputs. Those outputs may partially depend on their inputs. Connection to one circuit to the other one is shown using arrows in the logic circuit diagram.

Logic circuits behave as a function or a method in a programming input analogous to the method/function parameters and the outputs are analogous to method/function returned values. Usually we can divide logic circuits into two categories. They are as follows

• Combinational circuits: This behaves like a simple function in programming.
• State circuitry: This behaves more like an object method in programming.

## Logic IC

IC which is also known as an integrated circuit is a digital circuit based on semiconductors. There are many types of ICs used in various applications. Logic ICs are the ones we use to implement certain functionalities, by keeping together in various combinations. We can find around 600 types of logic ICs in the market. There are two types of Logic ICs;

• TTL ICs – This stands for transistor-transistor logic IC, made from BJTs and runs on 5v power.
• CMOS ICs – This stands for complementary metal oxide semiconductor IC, made from MOSFETs and can be used with various voltages.