# What Are Logic Gates and How Do They Work?

102 views

Your computer is probably dealing with billions of bits a single second using instructions given by various program developers, but how does it do so at the most fundamental level? Well, computers use small logic gates that create powerful instructions when chained together at the right way. Let’s find out about them in this article.

#### The Three Logic Gates

There are three important logic gates for computers to manipulate bits. Here are the names of them:

• AND
• OR
• NOT

The AND gate only returns a value of 1 if both inputs are 1, and the OR gate returns a value of 1 if either or both of the inputs are 1. The NOT gate is different from the other two gates as it only accepts one bit as input, and it flips the bit. That means if the input is 0, the output will be 1, and if the input is 1, the gate will return a value of 0. Here is the table for the outputs corresponding to each gate and each set of input values.

#### What About Other Logic Gates?

You might have heard of logic gates other than the AND, OR, and NOT gates, like the XOR, NOR, and NAND gates. However, they can be chained from the three fundamental logic gates mentioned above.

A NAND gate is easy to construct because it only requires an AND gate and a NOT gate chained together. Likewise, a NOR gate only needs an OR and NOT gate to be made. The XOR gate is more complicated to build, but it can be built from one AND gate, one OR gate, and a NAND gate.

But what are these logic gates exactly? A NAND gate is the reverse of an AND gate, and a NOR gate is the reverse of the OR gate, as mentioned in the preceding paragraph. A XOR gate is also easy to understand, as it returns a value of 1 when the two inputs are not the same, and returns 0 in other cases. Just in case you are still confused with them, here is the table of outputs associated with the different inputs and gates.

After learning about the basic logic gates, you can make instructions out of these straightforward gates. One of the structures you will learn about when encountering logic gates is the adder, which will be explained in the following parts of the article.

To make an adder, we first have to make a half adder. It’s an adder that is able to add two one-bit inputs. This gate is made of a XOR gate and an AND gate, with the XOR gate handling the unit digit and the AND gate handling the twos digit. Here is a table for the outputs produced when it encounters two bits as input: