Lecture
Notes
Central
Processing Unit
The Central Processing Unit (CPU) is the control center of a computer. It carries out all instructions sent to it by the operating system or applications software.
Lets see how it carries out its job.
CPU
Overview
Control
Unit
ALU
Registers
Instruction
Set
Instruction
Cycle
CPU
Overview
The CPU is the circuitry that receives
and carries out instructions involving operations on data. it receives
instructions and data from RAM, carries out those instructions and sends the
results back to RAM

The CPU
circuitry contains two main units that carry out the necessary actions to
execute the instructions from RAM and several memory locations where data/instructions are held temporarily while
the data is being processed. These are the...
 |
Control
Unit: directs and coordinates the flow of data. |
 |
Arithmetic/Logic
Unit: executes seven basic mathematical and logical operations. |
 |
Registers:
temporary memory locations.
|
Lets
explore each in more detail.
Control
Unit
The control unit
coordinates and directs all processing. The control unit uses an instruction
pointer, which is an address of the location in RAM where the next
instruction is stored. To carry out an instruction, the control unit
first checks the instruction pointer to find the location of the
instruction in RAM. The instruction is transported from this address in
RAM and stored in the control unit's instruction register.
The
control unit then interprets the instruction. Then it sends a signal along the
data bus to fetch data from RAM and another signal to the ALU to instruct it
about the process that has to be carried out on the data.
You
can imagine the control unit as a director on a movie set. It..
 |
Reads/interprets
instructions |
 |
Controls
the flow of data to the ALU |
 |
Maintains
the timing of operations |

ALU
The ALU or Arithmetic
Logic Unit carries out
 |
Arithmetic
operations |
addition

subtraction
as well as multiplication
and division.
 |
Logical & Comparison
Operations |
comparisons of two binary
words at a time such as
num1 <
num 2 
as well
as <= >
>= =
and also Boolean
comparison such as AND
OR NOT
 |
and the results
are stored in the accumulator |
The
Registers
Registers are temporary storage areas within the CPU that are used when data must be manipulated or instructions carried out.
There are usually at least four registers, and often more. The most common registers are:
 |
Accumulator:
holds the results of calculations. |
 |
Buffers: holding area for information taken from or to be sent to memory. |
 |
Address:
holds the location of information or instructions the computer needs for processing. |
 |
General
Purpose: used for multiple functions to include arithmetic or addressing. |
Registers
each hold one word of data or one address. The word length (number of bits) of different
computers vary. Early computers had 8 or 16-bit registers, later
computers have 32-bit registers and modern ones have 64-bit registers.
Instruction
Set
Each family
of of processor has a specific instruction set. The instruction set
tells the processor what operation to carry out. There are two parts to
an instruction set; the op code and the operand
 |
op
code: this is short for operation code and is a command for an
operation such as addition, subtraction, comparison, etc |
 |
operand:
this is the data to be operated on. |
Let's
look at an example

This
means move the value stored in the accumulator to the memory location with
address M1
Here's
another example

This
means add the value stored in memory location M1 to the value stored in memory
location M2. In this case we have one op code and two operands.
The table
below lists an microprocessor instruction set. Perhaps you should
consider how remarkable it is that a computer can carry out all the operations
you are familiar with such as word-processing, displaying images on the
monitor, etc. with what seems to be a small set of instructions to work
with.
Op Code |
Description |
Example |
CLA |
clears
the accumulator to 0 |
CLA |
CMP |
compare
the values in two register for equality. If they are equal put 1 in the accumulator,
otherwise put 0 |
CMP
R1 R2 |
INP |
input
the given value to a specific memory location |
INP
3 M1 |
JMP |
jump to the
instruction at the given memory location |
JMP
P1 |
JPZ |
jump to the given
memory location if the accumulator holds a zero |
JPZ
P2 |
JPN |
jump to the given
memory location if the accumulator does not hold a zero |
JPN
P1 |
HLT |
halt execution of
the program |
HLT |
ADD |
add the values
from two given registers and place the result in the accumulator |
ADD
R1 R2 |
SUB |
subtract the
values from two given registers and place the result in the accumulator |
SUB
R2 R3 |
MUL |
multiply the
values from two given registers and place the result in the accumulator |
MUL
R1 R2 |
DIV |
divide the values
from two given registers and place the result in the accumulator |
DIV
R3 R2 |
INC |
increase the value
in the accumulator by 1 |
INC |
DEC |
decrease the value
in the accumulator by 1 |
DEC |
MAR |
move the value
from the accumulator to the given register |
MAR
R2 |
MAM |
move
the value in the accumulator to the given memory location |
MAM
M1 |
MMR |
move
the value from the given memory location to the given register |
MMR
M1 R1 |
Instruction
Cycle
We
have examined how the ALU unit performs arithmetic and logic operations and how
the control unit gets instructions from RAM and instructs the ALU on which
operation to carry out. Now let's look at the whole instruction cycle.


That is folks!!
|