introduction to IT support

Computer Language

Character Encoding

Binary

Supplemental Reading on Logic Gates


Logic Gates

Knowing how logic gates work is important to understanding how a computer works. Computers work by performing binary calculations. Logic gates are electrical components that tell a computer how to perform binary calculations. They specify rules for how to produce an electrical output based on one or more electrical inputs. Computers use these electrical signals to represent two binary states: either an “on” state or an “off” state. A logic gate takes in one or more of these binary states and determines whether to pass along an “on” or “off” signal.

Several logic gates have been developed to represent different rules for producing a binary output. This reading covers six of the most common logic gates. 

Six common logic gates

NOT gate 

The NOT gate is the simplest because it has only one input signal. The NOT gate takes that input signal and outputs a signal with the opposite binary state. If the input signal is “on,” a NOT gate outputs an “off” signal. If the input signal is “off,” a NOT gate outputs an “on” signal. All the logic gates can be defined using a schematic diagram and truth table. Here’s how this logic rule is often represented:

Not gate schema and truth table

On the left, you have a schematic diagram of a NOT gate. Schematic drawings usually represent a physical NOT gate as a triangle with a small circle on the output side of the gate. To the right of the schematic diagram, you also have a “truth table” that tells you the output value for each of the two possible input values.

AND gate 

The AND gate involves two input signals rather than just one. Having two input signals means there will be four possible combinations of input values. The AND rule outputs an “on” signal only when both the inputs are “on.” Otherwise, the output signal will be “off.”

AND gate schema and truth table

OR gate 

The OR gate involves two input signals. The OR rule outputs an “off” signal only when both the inputs are “off.” Otherwise, the output signal will be “on.”

OR gate schema and truth table

XOR Gate 

The XOR gate also involves two input signals. The XOR rule outputs an “on” signal when only one (but not both) of the inputs are “on.” Otherwise, the output signal will be “off.”

XOR gate schema and truth table

The truth tables for XOR and OR gates are very similar. The only difference is that the XOR gate outputs an “off” when both inputs are “on” while the OR outputs an “on.” Sometimes you may hear the XOR gate referred to as an “exclusive OR” gate.

NAND gate 

The NAND gate involves two input signals. The NAND rule outputs an “off” signal only when both the inputs are “on.” Otherwise, the output signal will be “on.”

NAND gate schema and truth table

If you compare the truth tables for the NAND and AND gates, you may notice that the NAND outputs are the opposite of the AND outputs. This is because the NAND rule is just a combination of the AND and NOT rules: it takes the AND output and runs it through the NOT rule! For this reason, you might hear the NAND referred to as a “not-AND” gate.

XNOR gate 

Finally, consider the XNOR gate. It also involves two input signals. The XNOR rule outputs an “on” signal only when both the inputs are the same (both “On” or both “Off”). Otherwise, the output signal will be “off.”

XNOR gate schema and truth table

The XNOR rule is another combination of two earlier rules: it takes the XOR output and runs it through the NOT rule. For this reason, you might hear the XNOR referred to as a “not-XOR” gate.

Combining gates (building circuits)

Logic gates are physical electronic components—a person can buy them and plug them into a circuit board. Logic gates can be linked together to create complex electrical systems (circuits) that perform complicated binary calculations. You link gates together by letting the output from one gate serve as an input for another gate or by using the same inputs for multiple gates. Computers are this kind of complex electrical system. 

Here’s a schematic drawing for a small circuit built with gates described above:

Combined circuit schematic

Here is the truth table for this circuit:

Combined circuit truth table

This circuit uses three logic gates: an XOR gate, a NOT gate, and an AND gate. It takes two inputs (A and B) and produces two outputs (1 and 2). A and B are the inputs for the XOR gate. The output of that gate became the input of the NOT gate. Then, the output of the NOT gate became an input for the AND gate (with input A as the other). Output 1 is the output from the AND gate. Output 2 is the output from the XOR gate. 

Key takeaways

Logic gates are the physical components that allow computers to make binary calculations.

Logic gates represent different rules for taking one or more binary inputs and outputting a specific binary value (“on” or “off”).

Logic gates can be linked so that the output of one gate serves as the input for other gates.

Circuits are complex electrical systems built by linking logic gates together. Computers are this kind of complex electrical system.

How to Count in Binary

Binary is the fundamental communication block of computers, but it's used to represent more than just text and images. It's used in many aspects of computing, like computer networking, what you'll learn about in a later course. It's important that you understand how computers count in binary. We've shown you simple look up tables that you can use like the ASCII binary table. But as an IT support specialist whether you're working on networking or security, you'll need to know how binary works, so let's get started. You'll probably need a trusty pen and paper, a calculator and some good old fashioned brainpower to help you in this video. The binary system is how our computers count using 1s and 0s, but humans don't count like that. When you were a child you may have counted using ten fingers on your hand, that innate counting system is called the decimal form or base ten system. In the decimal system there are ten possible numbers you can use ranging from 0 to 9. When we count binary which only uses 0 and 1, we convert it to a system that we can understand, decimal. 330, 250 to 44 million, they're all decimal numbers. We use the decimal system to help us figure out what bits our computer can use. We can represent any number in existence just by using bits. That's right, we can represent this number just using ones and zeros, so how does that work? Let's consider these numbers, 128, 64, 32, 16, 8, 4, 2 and 1, what patterns do you see? Hopefully you'll see that each number is a double of the previous number going right to left, what happens if you add them all up? You get 255, that's kind of weird, I thought we could have 256 values for a byte. Well, we do, the 0 is counted as a value, so the maximum decibel number you can have is 255. What do you think the number is represented here? See where the 1s and the 0s are represented? Remember, if our computers use the 1 then the value was on, if it sees a 0 then the value was off. If you add these numbers up you'll get a decimal value. If you guess 10, then you're right, good job, if you didn't get it, that's okay too, take another look. The 2 and 8 are on and if we add them up we get 10. Let's look at our ASCII binary table again, the letter h in binary is 01101000. Now let's look at an ASCII to decimal table. The letter h and decimal is 104. Now let's try our conversion chart again, 64+32+8=104. Look at that, the math checks out. Now we're cooking, wow, we've gone over all the essentials of the basic building blocks of computing and machine language.