You are on page 1of 76

Introduction to CPU Brief History of the CPU Main Components and Structure of the CPU Computer Bus Overview

Single Bus Architecture Overview of Assembly Programming Microprogramming Gating and Control Sequencing Cache Memory Virtual Memory Memory Interleaving

In

order to work, a computer needs some sort of "brain" or "calculator". At the core of every computer is a device roughly the size of a large postage stamp.
device is known as the central processing unit, or CPU for short. This is the "brain" of the computer; it reads and executes program instructions, performs calculations, and makes decisions.

This

The

CPU is responsible for storing and retrieving information on disks and other media.
also handles information on from one part of the computer to another like a central switching station that directs the flow of traffic throughout the computer system.

It

The

CPU resides inside a box known as the system unit, along with various support devices and tools for storing information. The system unit case, that is the metal case itself, can either be short and wide, in which case it usually sits on top of your desk, often underneath the screen (left image), or it can be taller and narrow, in which case it generally sits underneath your desk and is referred to as a tower case (right image).

CPU

history starts in 1971, when a small unknown company, Intel, for the first time combined multiple transistors to form a central processing unit - a chip called Intel 4044. However, it was 8 years before the first Personal Computer was constructed. PC's are designed around different CPU generations. Intel is not the only company manufacturing CPU's, but by far the leading one. The following table shows the different CPU generations. They are predominantly Intel chips, but in the 5th generation we see alternatives.

PC 1st Generation 2nd Generation 3rd Generation 4th Generation

CPU's

Year 1978-81 1984 1987-88 1990-92 1993-95 1996 1996 1997 1997 1997 1998 1995 1997 1997 1998 1999

Number of Transistors 29,000 134,000 275,000 1,200,000 3,100,000 --3,500,000 4,500,000 6,000,000 6,000,000 5,500,000 8,800,000 7,500,000 9,300,000 27,400,000 18,900,000 9,300,000 -28,000,000

8086 and 8088 80286 80386SX and 80386DX 80486SX, 80486DX, 80486DX2 and 80486DX4 5th Generation Pentium Cyrix 6x86 AMD K5 IDT WinChip C6 Improved 5th Generation Pentium MMX IBM/Cyrix 6x86MX IDT WinChip2 3D 6th Generation Pentium Pro AMD K6 Pentium II AMD K6-2 Improved 6th Generation Mobile Pentium II Mobile Celeron Pentium III AMD K6-3 Pentium III CuMine

What does the CPU do?


Carries out instructions and tells the rest of the computer system what to do. This is done by the Control Unit of the CPU which sends command signals to the other components of the system. Performs arithmetic calculations and data manipulation, eg. comparisons, sorting, combining, etc. The computer's calculator is a part of the CPU known as the Arithmetic Logic Unit. Holds data and instructions which are in current use. These are kept in the Main Store or Memory.

directs

the entire computer system to carry out stored program instructions.


communicate with both the arithmetic logic unit and main memory. the instruction contained in the Instruction Register to decide which circuits need to be activated.

must

uses

co-ordinates

the activities of the other two units as well as all peripheral and auxiliary storage devices linked to the computer.
the arithmetic logic unit which arithmetic operations or logical operation is to be performed. literally in control.

instructs

is

Specialized electronic circuitry in the control unit is designed to decode program instructions held in the main memory. Each instruction is read from the memory into the instruction register. The process of reading an instruction is often referred to as the fetch-execute process.

executes

arithmetic and logical operations.

Arithmetic operations include addition, subtraction, multiplication and division. Logical operations compare numbers, letters and special characters.

Comparison operations test for three conditions: Equal - to condition in which two values are the same Less - than condition in which one value is smaller than the other Greater - than condition in which one value is larger than the other

Relational operations (=, <, >) are used to describe the comparison operations used by the arithmetic logic unit.

The arithmetic logic unit performs logic functions such as AND, OR and NOT.

The

Computer bus is a group of parallel wires that is a path or route between the different interconnecting components of a computer system. The two main buses in a computer are the internal or system bus and external or the expansion bus.

The

expansion bus connects external devices such as mouse, printer, keyboard or modem to the CPU, while the system bus connects the CPU to other devices that resides on the motherboard The system bus has two parts.

Data bus Address bus

Industry

Standard Architecture (ISA) bus is used in many computers to connect slower devices such as modem and other input devices. Universal Serial Bus (USB) is a hot swappable bus which means that a computer user can connect then disconnect a USB device without affecting the PC or laptop. Local bus is designed to attach faster devices to the CPU.

Accelerated Graphics Bus or Port (AGP Bus) allows the video card to access the RAM directly, thus increasing the speed of graphics performance for 3-D(Dimensional) and full motion video applications. PC Card Bus is used exclusively on laptop computer and is used as network cards, external modem Wi-Fi Card, thumb scanner and biometric security system. FireWire (IEEE 1394) bus is used to connect digital and video cameras. We can use the FireWire bus to transfer data in high speed rate.

Single Bus Slow Performance

Example of Triple
Bus Architecture

High-level programming - simple code can be easy-to-interpret: total := subTotal + salesTax

put Hello World!


for count:1..10 put count end for

Each

machine language line of code has 2 parts: - op-code describes the operation to be done - operand identifies the quantity to be operated on
All

commands are in binary, shown grouped as hexadecimal digits (4 binary digits = 1 hex digit)

Still

quite difficult to read and understand

Good

applications of binary/hex number systems and conversions

Assembly language uses alpha-numeric characters and more closely resembles English words or acronyms. e.g. Move immediate the value 33 into register A in machine language 3E 33

in assembly language MVI A 33 MVI MoVe Immediate

Intel released several 8-bit microprocessors in the 1970s including the 8080, 8085, 8088. Simulating a simple processor allows us to show the steps, registers, process in a scaled-down environment. Choose a processor and a corresponding assembly language that suits your needs and has the resources you need. (8085 used in profiles and here)

A Register (Accumulator)

8085 CPU Register s

B Register C Register D Register E Register H Register L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

MVI Put a specified value in a specified register. e.g. MVI A B8 - put B8 in A register MVI B 5F - put 5F in B register

B 8

A Register (Accumulator) B Register C Register D Register E Register H Register

MVI A B8

L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

A Register (Accumulator)

5 F

B Register C Register D Register E Register H Register

MVI B 5F

L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

MVI A 33 INR A STA 12C3 HLT

3 3

A Register (Accumulator) B Register C Register D Register E Register H Register

MVI A 33

L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

3 4

A Register (Accumulator) B Register C Register D Register E Register H Register

INR A

L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

12C3

3 4

A Register (Accumulator) B Register C Register D Register E Register H Register

STA 12C3 HLT

L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

LDA 55C1

SUI 10
STA 55C1

HLT
- for this example, let's suppose 55C1 starts with the value 6A

55C1

6 A

A Register (Accumulator) B Register C Register D Register E Register H Register

LDA 55C1

L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

5 A

A Register (Accumulator) B Register C Register D Register E Register H Register

SUI 10

L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

55C1

5 A

A Register (Accumulator) B Register C Register D Register E Register H Register

STA 55C1 HLT

L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

Immediate operand is a specific numerical value, not an address in RAM

e.g.

MVI B 52
ADI 22 SUI FF

A Register (Accumulator) B Register C Register

3 F 6 7
LXI D 3F67

D Register E Register H Register L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

Direct operand represents an address in RAM (address bus is 16 bits or 2 Bytes)


e.g. LDA 55A2 STA AB31

Indirect operand specifies a pair of registers (BC, DE, or HL) where the RAM address of the data is stored.

A2FF

A Register (Accumulator) B Register C Register

A 2 F F
LDAX D

D Register E Register H Register L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

MVI A 33
MVI B 89 MVI C 87 STAX B HLT

3 3

A Register (Accumulator) B Register C Register D Register E Register H Register

MVI A 33

L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

3 3 8 9

A Register (Accumulator)

B Register
C Register D Register E Register H Register

MVI B 89

L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

3 3 8 9 8 7

A Register (Accumulator)

B Register
C Register D Register E Register H Register

MVI C 87

L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

8987

3 3 8 9 8 7

A Register (Accumulator)

B Register
C Register D Register E Register H Register

STAX B HLT

L Register PC (Program Counter) SP (Stack Pointer) SR (Status Register)

Introduce

concept of looping with JMP Every instruction has a memory location (used by program counter)

e.g. JMP 0033


- means jump to instruction at memory location 0033
Must

keep track of how much space each instruction requires in order to loop to the right location

By

comparing two values, we cause flags to be set in the status register. Based on the result of this comparison we can decide to loop or not. Compare another register to A.

1.

e.g. CMP C
Sets

the flags in the status register as if we were subtracting contents of C from A. (Does not actually subtract)

e.g. CPI FF

MVI A 07 INR A CPI 0B JNZ ??

STA 4400
HLT

Process

of writing microcode for a microprocessor. Microcode is a low-level code that defines how a microprocessor should function when it executes machine-language instructions. Typically, one machine-language instruction translates into several microcode instructions. On some computers, the microcode is stored in ROM and cannot be modified; on some larger computers, it is stored in EPROM and therefore can be replaced with newer versions.

Cache Memory (L1, L2, caching Virtual Memory Memory Interleaving

techniques)

The CPU contains the basic instructions needed to operate the computer, but it cannot sure entire programs or large sets of data permanently. The CPU needs to have millions (or even trillions, in some computers) of bytes of space where it can quickly read or write programs and data while they are being used. This area is called memory, and it consists either on the motherboard or on small circuit board attached to the motherboard. It allows the CPU to store and retrieve data quickly

Volatile

(Nonpermanent)

Requires power to store data. Loses its contents when the computers power is shut off. The volatile memory in a computer is called random access memory (RAM) RAMs job is to hold programs and data while they are in use. Physically, RAM consists of chips on a small circuit board

Single

in-line memory modules (SIMMs) and Dual in-line memory module (DIMM)
Are chips found in desktop computers.

Small

Outline DIMM (SO-DIMM)

Are chips found in laptop computers.

Non-Volatile

(Permanent

Memory chips that hold data even when the computer is turned off. Putting data permanently into this kind of memory is called burning in the data Read-only memory (ROM), the data in these chips is only read and used not changed. Programmable read only memory (PROM), chips are often found on hard drives and printers. They contain the instructions that power the devices.

o Basic input output system (BIOS), set of start-up

instructions. In addition to booting the machine, BIOS contains another set of routines which ensure that the system is functioning properly and all expected hardware devices are present. This routines is called the power on self test (POST)
Flash

memory is a special type of nonvolatile memory. Examples are digital cameras, portable MP3 players, flash drives etc.

Moving

data between RAM and the CPUs registers is one of the most time-consuming operations a CPU must perform, simply because RAM is much slower than the CPU. A partial solution to this problem is to include a cache memory in the CPU. Cache (pronounced cash) memory is similar to RAM except that it is extremely fast compared to normal memory and it is used in a different way.

When

a program is running and the CPU needs to read a piece of data or program instructions from RAM, the CPU checks first to see whether the data is in cache memory. If the data is not there, the CPU reads the data from RAM into its registers, but also loads a copy of the data into cache memory. The next time the CPU needs the data, it finds it in the cache memory and saves the time needed to load the data from RAM

Cache

is present in several places in a computer. Without cache, your computer would be a much slower device. Since the late 1980s, most PC CPUs have had cache memory built into them. This CPUresident cache is often called Level-1 (L1) cache. Today, many CPUs have as much as 256KB built in. To add even more sped to modern CPUs, an additional cache is added to CPUs. This cache is called Level-2 (L2) cache. This cache used to be found on the motherboard.

Many

PCs being sold today have 512 KB or 1024 KB of motherboard cache memory; higher-end systems can have as much as 2MB of L2 cache. In addition to the cache memory built into the CPU, cache is also added to the motherboard. This motherboard-resident cache is now called Level-3 (L3) cache. L3 cache is found on very-high-end computers. It is not necessary for a computer to have L3 cache.

L1,

L2, and L3 all speed up the CPU, although in different ways. L1 cache holds instructions that have recently run. L2 cache holds potential upcoming instructions. L3 holds many of the possible instructions. In all cases, the cache memory is faster for the CPU to access, resulting in a quicker program execution.