Cpu and Memory

Embed Size (px)

Citation preview

  • 7/27/2019 Cpu and Memory

    1/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 ProgrammingMicroprogramming

    Gating and Control Sequencing

    Cache Memory

    Virtual Memory

    Memory Interleaving

  • 7/27/2019 Cpu and Memory

    2/76

    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.

    This device is known as the central

    processing unit, or CPU for short. This is the

    "brain" of the computer; it reads andexecutes program instructions, performs

    calculations, and makes decisions.

  • 7/27/2019 Cpu and Memory

    3/76

    The CPU is responsible for storing and

    retrieving information on disks and other

    media.

    It 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.

  • 7/27/2019 Cpu and Memory

    4/76

  • 7/27/2019 Cpu and Memory

    5/76

    The CPU resides inside a box known as the systemunit, 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 itusually sits on top of your desk, often underneath

    the screen (left image), or it can be taller andnarrow, in which case it generally sits underneathyour desk and is referred to as a tower case (rightimage).

  • 7/27/2019 Cpu and Memory

    6/76

    CPU history starts in 1971, when a smallunknown company, Intel, for the first timecombined multiple transistors to formacentral processing unit - a chip called

    Intel 4044. However, it was 8 years beforethe first Personal Computer was constructed.

    PC's are designed around different CPUgenerations. Intel is not the only company

    manufacturing CPU's, but by far the leadingone. The following table shows the differentCPUgenerations. They are predominantlyIntel chips, but in the 5th generation we seealternatives.

  • 7/27/2019 Cpu and Memory

    7/76

    PC CPU's Year Number of Transistors1st Generation 8086 and 8088 1978-81 29,0002nd Generation 80286 1984 134,0003rd Generation 80386SX and 80386DX 1987-88 275,0004th Generation 80486SX, 80486DX, 80486DX2 and

    80486DX4 1990-92 1,200,0005th Generation Pentium

    Cyrix 6x86

    AMD K5

    IDT WinChip C6

    1993-95

    1996

    1996

    1997

    3,100,000

    --

    --

    3,500,000Improved 5th GenerationPentium MMX

    IBM/Cyrix 6x86MX

    IDT WinChip2 3D1997

    1997

    19984,500,000

    6,000,000

    6,000,0006th Generation Pentium Pro

    AMD K6

    Pentium IIAMD K6-2

    1995

    1997

    19971998

    5,500,000

    8,800,000

    7,500,0009,300,000

    Improved 6th GenerationMobile Pentium IIMobile Celeron

    Pentium III

    AMD K6-3

    Pentium III CuMine

    1999 27,400,00018,900,000

    9,300,000

    --

    28,000,000-

  • 7/27/2019 Cpu and Memory

    8/76

    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 whichsends 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 CPUknown as theArithmetic Logic Unit.

    Holds data and instructions which are in current use.

    These are kept in theMain Store orMemory.

  • 7/27/2019 Cpu and Memory

    9/76

  • 7/27/2019 Cpu and Memory

    10/76

    directs the entire computer system to carry

    out stored program instructions.

    must communicate with both the arithmeticlogic unit and main memory.

    uses the instruction contained in

    the Instruction Register to decide whichcircuits need to be activated.

  • 7/27/2019 Cpu and Memory

    11/76

    co-ordinates the activities of the other two

    units as well as all peripheral and auxiliary

    storage devices linked to the computer.

    instructs the arithmetic logic

    unit which arithmetic operations or logical

    operation is to be performed.

    is literally in control.

  • 7/27/2019 Cpu and Memory

    12/76

    Specialized electronic circuitry in the control

    unit is designed to decode program instructions

    held in the main memory. Each instruction isread from the memory into the instructionregister. The process of reading an instruction isoften referred to as thefetch-execute process.

  • 7/27/2019 Cpu and Memory

    13/76

    executes arithmetic and logical operations.

    Arithmetic operations include addition,subtraction, multiplication and division.

    Logical operations compare numbers, lettersand special characters.

    Comparison operations test for three conditions:

    Equal - to condition in which two values are thesame

    Less - than condition in which one value is smallerthan the other

    Greater - than condition in which one value is largerthan the other

  • 7/27/2019 Cpu and Memory

    14/76

    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.

  • 7/27/2019 Cpu and Memory

    15/76

    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 theexpansion bus.

  • 7/27/2019 Cpu and Memory

    16/76

    The expansion bus connects externaldevices such as mouse, printer, keyboard or

    modem to the CPU, while the system busconnects the CPU to other devices that

    resides on the motherboard

    The system bus has two parts.

    Data bus

    Address bus

  • 7/27/2019 Cpu and Memory

    17/76

    Industry Standard Architecture (ISA) bus isused in many computers to connect slower

    devices such as modem and other input

    devices.

    Universal Serial Bus (USB) is a hotswappable 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.

  • 7/27/2019 Cpu and Memory

    18/76

    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 laptopcomputer 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.

  • 7/27/2019 Cpu and Memory

    19/76

    Single Bus

    Slow Performance

  • 7/27/2019 Cpu and Memory

    20/76

    Example of Triple

    Bus Architecture

  • 7/27/2019 Cpu and Memory

    21/76

  • 7/27/2019 Cpu and Memory

    22/76

    High-level programming

    - simple code can be easy-to-interpret:

    total := subTotal + salesTax

    put Hello World!

    for count:1..10

    put count

    end for

  • 7/27/2019 Cpu and Memory

    23/76

  • 7/27/2019 Cpu and Memory

    24/76

    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

  • 7/27/2019 Cpu and Memory

    25/76

    Assembly language uses alpha-numeric charactersand more closely resembles English words oracronyms.

    e.g. Move immediate the value 33 into register A

    in machine language 3E 33

    in assembly language MVI A 33

    MVIMoVe Immediate

  • 7/27/2019 Cpu and Memory

    26/76

    Intel released several 8-bit microprocessors in the1970s 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 assemblylanguage that suits your needs and has the

    resources you need. (8085 used in profiles and here)

  • 7/27/2019 Cpu and Memory

    27/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    8085CPU

    Registers

  • 7/27/2019 Cpu and Memory

    28/76

    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

  • 7/27/2019 Cpu and Memory

    29/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    MVI A B8

    B 8

  • 7/27/2019 Cpu and Memory

    30/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    MVI B 5F

    5 F

  • 7/27/2019 Cpu and Memory

    31/76

  • 7/27/2019 Cpu and Memory

    32/76

  • 7/27/2019 Cpu and Memory

    33/76

    MVI A 33

    INR A

    STA 12C3

    HLT

  • 7/27/2019 Cpu and Memory

    34/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    MVI A 33

    3 3

  • 7/27/2019 Cpu and Memory

    35/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    INR A

    3 4

  • 7/27/2019 Cpu and Memory

    36/76

  • 7/27/2019 Cpu and Memory

    37/76

    LDA 55C1

    SUI 10

    STA 55C1

    HLT

    - for this example, let's suppose 55C1 starts with thevalue 6A

    55C1

  • 7/27/2019 Cpu and Memory

    38/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    LDA 55C1

    6 A

    55C1

  • 7/27/2019 Cpu and Memory

    39/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    SUI 10

    5 A

  • 7/27/2019 Cpu and Memory

    40/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    STA 55C1HLT

    5 A

    55C1

  • 7/27/2019 Cpu and Memory

    41/76

    Immediate operand is a specific numerical value,

    not an address in RAM

    e.g. MVI B 52

    ADI 22

    SUI FF

  • 7/27/2019 Cpu and Memory

    42/76

  • 7/27/2019 Cpu and Memory

    43/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    LXI D 3F67

    3 F

    6 7

  • 7/27/2019 Cpu and Memory

    44/76

    Direct operand represents an address in RAM

    (address bus is 16 bits or 2 Bytes)

    e.g. LDA 55A2

    STA AB31

  • 7/27/2019 Cpu and Memory

    45/76

  • 7/27/2019 Cpu and Memory

    46/76

  • 7/27/2019 Cpu and Memory

    47/76

  • 7/27/2019 Cpu and Memory

    48/76

    A2FF

  • 7/27/2019 Cpu and Memory

    49/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    LDAX D

    A 2

    F F

    A2FF

    ? ?

  • 7/27/2019 Cpu and Memory

    50/76

  • 7/27/2019 Cpu and Memory

    51/76

    MVI A 33

    MVI B 89

    MVI C 87

    STAX B

    HLT

  • 7/27/2019 Cpu and Memory

    52/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    MVI A 33

    3 3

  • 7/27/2019 Cpu and Memory

    53/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    MVI B 89

    3 3

    8 9

  • 7/27/2019 Cpu and Memory

    54/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    MVI C 87

    3 3

    8 9

    8 7

    8987

  • 7/27/2019 Cpu and Memory

    55/76

    A Register (Accumulator)

    B Register

    C Register

    D Register

    E Register

    H Register

    L Register

    SR (Status Register)

    PC (Program Counter)

    SP (Stack Pointer)

    STAX BHLT

    3 3

    8 9

    8 7

  • 7/27/2019 Cpu and Memory

    56/76

    Introduce concept of looping withJMP

    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

  • 7/27/2019 Cpu and Memory

    57/76

    By comparing two values, we cause flags to be setin the status register. Based on the result of thiscomparison we can decide to loop or not.

    1. Compare another register to A.

    e.g. CMP C

    Sets the flags in the status register as if we weresubtracting contents of C from A. (Does notactually subtract)

  • 7/27/2019 Cpu and Memory

    58/76

  • 7/27/2019 Cpu and Memory

    59/76

  • 7/27/2019 Cpu and Memory

    60/76

    MVI A 07

    INR A

    CPI 0B

    JNZ ??

    STA 4400

    HLT

  • 7/27/2019 Cpu and Memory

    61/76

  • 7/27/2019 Cpu and Memory

    62/76

  • 7/27/2019 Cpu and Memory

    63/76

    Process of writing microcode for amicroprocessor.

    Microcode is a low-level code that defineshow a microprocessor should function when

    it executes machine-language instructions. Typically, one machine-language instruction

    translates into several microcodeinstructions. On some computers, the

    microcode is stored in ROM and cannot bemodified; on some larger computers, it isstored in EPROM and therefore can bereplaced with newer versions.

  • 7/27/2019 Cpu and Memory

    64/76

  • 7/27/2019 Cpu and Memory

    65/76

  • 7/27/2019 Cpu and Memory

    66/76

  • 7/27/2019 Cpu and Memory

    67/76

    The CPU contains the basic instructions neededto operate the computer, but it cannot sure

    entire programs or large sets of data

    permanently.

    The CPU needs to have millions (or eventrillions, 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 consistseither on the motherboard or on small circuit

    board attached to the motherboard. It allows the

    CPU to store and retrieve data quickly

  • 7/27/2019 Cpu and Memory

    68/76

    Volatile (Nonpermanent)

    Requires power to store data.

    Loses its contents when the computers power is

    shut off.

    The volatile memory in a computer is calledrandom access memory (RAM)

    RAMs job is to hold programs and data while

    they are in use.

    Physically, RAM consists of chips on a smallcircuit board

  • 7/27/2019 Cpu and Memory

    69/76

    Single in-line memory modules (SIMMs) andDual in-line memory module (DIMM)

    Are chips found in desktop computers.

    Small Outline DIMM (SO-DIMM)

    Are chips found in laptop computers.

  • 7/27/2019 Cpu and Memory

    70/76

    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 onlyread and used not changed.

    Programmable read only memory (PROM), chips are oftenfound on hard drives and printers. They contain the

    instructions that power the devices.

  • 7/27/2019 Cpu and Memory

    71/76

    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 ofnonvolatile memory. Examples are digital

    cameras, portable MP3 players, flash drives

    etc.

  • 7/27/2019 Cpu and Memory

    72/76

    Moving data between RAM and the CPUsregisters 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 fastcompared to normal memory and it is used in

    a different way.

  • 7/27/2019 Cpu and Memory

    73/76

    When a program is running and the CPUneeds 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 thedata 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 thetime needed to load the data from RAM

  • 7/27/2019 Cpu and Memory

    74/76

    Cache is present in several places in acomputer. Without cache, your computerwould be a much slower device.

    Since the late 1980s, most PC CPUs have had

    cache memory built into them. This CPU-resident cache is often called Level-1 (L1)cache. Today, many CPUs have as much as256KB built in.

    To add even more sped to modern CPUs, anadditional cache is added to CPUs. Thiscache is called Level-2 (L2) cache. Thiscache used to be found on the motherboard.

  • 7/27/2019 Cpu and Memory

    75/76

    Many PCs being sold today have 512 KB or1024 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. L3cache is found on very-high-end computers.

    It is not necessary for a computer to have L3

    cache.

  • 7/27/2019 Cpu and Memory

    76/76

    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 forthe CPU to access, resulting in a quicker

    program execution.