Lessons.ADV.Hardware.05

Hardware Lesson 5:
Processors & Logic

Introduction

The processor is the heart of the computer, but there is something behind all of the parts of a computer that is even more important, and that is digital circuits. These circuits use logic to control how electricity flows through the computer, which can power different components of the computer and move data.

Switches

  • A Light SwitchA switch is a very simple component, but it is essential to computers.
  • Transistors are used as switches in current computers.
  • A switch works similarly to a light switch.
  • Turning a light switch on sends current to the bulb, turning the bulb on. If the switch is off no current is sent to the bulb so the bulb will turn off.
  • A switch in a computer A Transistor Switchis controlled by its input. If there is a current flowing through the input then the output will have a high voltage charge (or a 1 in binary). If there is no current flowing to the input the output will have low voltage (or a 0 in binary).
  • Switches can be used to control other switches. The chain of switches below would all have an output of 1 if the input for the first switch was 1.

Chain of Switches

Gates

  • Putting a bunch of switches together in a line is pretty useless, but switches can be put together in creative ways to create gates.
  • Putting three gates together like the picture below creates something called an AND gate.

AND Gate

  • AND GateThe output for an AND gate is only 1 if both of the inputs are 1. This gate is used so often that it is given a special symbol.
  • Truth tables can be used to determine the outputs of gates. A truth table is a mathematical table used to compute the results of logical expressions.
Input1 Input2 Output
0 0 0
0 1 0
1 0 0
1 1 1
  • Another common gate is the OR gate.

OR Gate

  • OR GateAn OR gate has an output if 1 if one or both of the inputs are 1.
  • The truth table for an OR gate looks like this:
Input1 Input2 Output
0 0 0
0 1 1
1 0 1
1 1 1
  • NOT GateThe other common gate type is a NOT gate. It simply changes the charge of the input.
  • A NOT Gate is much more complex than AND and OR gates, but if you want to see its architecture check out the links at the bottom of the lesson.

Binary Addition

  • Adding binary numbers is simple:

0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 2...but we only have two numbers in binary. In this case we carry a 1 to another digit resulting in 10.

Adding Binary Numbers

  • The gates we have learned about can be used to add binary numbers. Determining if there is a carried number can be done using an AND gate as seen below.

Half-Adder (Carry Only)

  • This half adder will be used to add two 1-bit binary numbers. Determining the result is a little bit more complex as you can see below.

Half Adder (Result)

  • This half adder will be used to add two 1-bit binary numbers. Determining the result is a little bit more complex as you can see below.
Input1 Input2 Output
0 0 0
0 1 1
1 0 1
1 1 0
  • The above set of gates is used so often that it is called an XOR gate or exclusive OR gate. The gate can be seen below joined with the AND gate for the carry part of the half adder.
  • The box on the right is used to represent the half adder. X and Y are the inputs, C is the carry out, and S is the sum.

Half Adder with XOR Gate

Processor Logic

  • Processors use logic. A group of adders called the ALU do most of the mathematical calculations of the computer. Below is a simple example of a processor.

Processor Logic

  • The address bus sends an address to memory so the memory knows where to write to or read from.
  • The data bus sends the data to memory that will be written to memory, or receive data that is read from the memory.
  • The boxes marked 3-state are tri-state buffers that can allow multiple inputs to connect to a wire but only one at a time can send a 0 or 1.
  • The RD (Read) and WR (Write) lines tell the memory whether to read or write to the address location.
  • Registers are used to store charges so they almost work like memory. The address latch works the same way.
  • The program counter works the same as registers, but has the extra ability of incrementing by 1 or reseting to 0 when told to do so.
  • The instruction decoder tells the CPU what to do.
  • Finally, the ALU is an 8-bit adder similar to the half adder we made.

More Information

If you are interested in learning more about processors or logic.