Thursday, 8 September 2022

Logic Gates And How They Work

Symbols of the logic gates

Logic gates are the basic building blocks of digital electronics. These are the components that we use for “doing stuff” with the 1s and 0s. You can combine them to create other building blocks like flip-flops, adders, and more.

The basic logic gates are AND, NAND, OR, NOR, XOR, XNOR, and NOT.

AND gate

The AND gate takes two (or more) inputs and gives out a 1 (HIGH/true) if all the inputs are 1. Otherwise, it gives out a 0 (LOW/false).

The truth table is below, but all you really need to remember is that the AND gate needs a 1 on input A and input B to give out 1.

AND gate symbol
Input A Input B Output Y
0 0 0
0 1 0
1 0 0
1 1 1
AND Gate Truth Table

If you want to use it in a circuit, the IC 4081 contains 4 AND gates.

NOT gate/Inverter

The simplest logic gate of all is the NOT gate. It takes one bit as input (A). And it gives as an output (Y) what is NOT on the input. So if there is a 1 on the input, its output is 0. And if there is 0 on the input, its output is 1. It’s also called an inverter.

Inverter or NOT gate symbol
Input (A) Output (Y)
0 1
1 0
NOT Gate Truth Table

If you want to use a NOT gate in your circuit, you can for example use the IC 4572 or IC 40106.

OR gate

The OR gate takes two (or more) inputs and gives out a 1 if any of the inputs are 1. Otherwise, it gives out a 0.

The truth table is below, but all you really need to remember is that the OR gate needs a 1 on input A or input B to give out 1.

OR gate symbol
Input A Input B Output Y
0 0 0
0 1 1
1 0 1
1 1 1
OR Gate Truth Table

If you want to use it in a circuit, the IC 4071 contains 4 OR gates.

NAND gate

The NAND (or NOT AND) gate operates in the opposite way of the AND gate. It’s like if an AND gate had a NOT gate on its output:

A NAND gate made from the logic gates AND and NOT

You’ll find the truth table below. But all you need to remember is that the only time the output of a NAND gate is 0 is when both the inputs are 1.

NAND gate symbol
Input A Input B Output Y
0 0 1
0 1 1
1 0 1
1 1 0
NAND Gate Truth Table

If you want to use NAND gates in a circuit, the CMOS IC 4011 contains 4 NAND gates.

NOR gate

The NOR (or NOT OR) gate operates in the opposite way of the OR gate. It’s as if an OR gate had a NOT gate on its output.

A NOR gate made from the logic gates OR and NOT

You’ll find the truth table below. But all you need to remember is that the only time the output of a NOR gate is 1 is when both the inputs are 0.

Logic gate symbol for NOR gate symbol
Input A Input B Output Y
0 0 1
0 1 0
1 0 0
1 1 0
NOR Gate Truth Table

If you want to use NOR gates in a circuit, the IC 4001 contains 4 NOR gates.

XOR gate

XOR gate symbol

The XOR (or Exclusive OR) gate outputs 1 if one of its two inputs is 1 – but not both. You can also look at it in this way – if the two inputs are different from each other, the output is true.

Input A Input B Output Y
0 0 0
0 1 1
1 0 1
1 1 0
XOR Gate Truth Table

If you want to use XOR gates in a circuit, the IC 4070 contains 4 XOR gates.

XNOR gate

XNOR gate symbol

The XNOR (or Exclusive NOT OR) gate works like an XOR gate with an inverter on the output. Another way to look at it is to notice that the output becomes 1 if its two inputs are equal – either two 1s or two 0s.

Input A Input B Output Y
0 0 1
0 1 0
1 0 0
1 1 1
XNOR Gate Truth Table

If you want to use XNOR gates in a circuit, you’ll find four of them in the IC 4077.

Using Logic Gates in Circuits

A logic gate can be built with transistors and usually comes as an Integrated Circuit (IC).

Illustration of an IC with logic gates

There are two classic IC series that contain a lot of the same functions; the 7400-series and the 4000-series.

The 7400-series is the oldest series. The 4000-series was introduced as a lower-power and more versatile option to the 7400. But today, several families of the 7400-series exist, some with similar properties as the 4000-series.

Check out my list of common 4000 series IC with pinouts, explanations, and example circuits for more info.

Complete list of ICs in the 4000-series (Wikipedia)
Complete list of ICs in the 7400-series (Wikipedia)

Copyright Build Electronic Circuits

No comments:

Post a Comment

Tiny, wireless antennas use light to monitor cellular communication

Researchers developed a biosensing technique that eliminates the need for wires. Instead, tiny, wireless antennas use light to detect minute...