Top Banner

of 27

12640_cmput101.ch5.1

Apr 10, 2018

Download

Documents

sagarkapoor
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/8/2019 12640_cmput101.ch5.1

    1/27

    The Von Neumann ArchitectureThe Von Neumann Architecture

    Chapter 5.1Chapter 5.1--5.25.2

    Von NeumannVon NeumannArchitectureArchitecture

  • 8/8/2019 12640_cmput101.ch5.1

    2/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 2

    Designing ComputersDesigning Computers

    All computers more or less based on the sameAll computers more or less based on the same

    basic design, thebasic design, the Von Neumann ArchitectureVon Neumann Architecture!!

  • 8/8/2019 12640_cmput101.ch5.1

    3/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 3

    The Von Neumann ArchitectureThe Von Neumann Architecture

    Model for designing and building computers,Model for designing and building computers,

    based on the following three characteristics:based on the following three characteristics:

    1)1) The computer consists of four main subThe computer consists of four main sub--systems:systems:

    Memory Memory

    ALU (Arithmetic/Logic Unit)ALU (Arithmetic/Logic Unit)

    Control Unit Control Unit Input/Output System (I/O)Input/Output System (I/O)

    2)2) Program is stored in memory during execution.Program is stored in memory during execution.

    3)3) Program instructions are executed sequentially.Program instructions are executed sequentially.

  • 8/8/2019 12640_cmput101.ch5.1

    4/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 4

    The Von Neumann ArchitectureThe Von Neumann Architecture

    Memory

    Processor (CPU)

    Input-OutputControl Unit

    ALU

    Store data and programStore data and program

    Execute programExecute program

    Do arithmetic/logic operationsDo arithmetic/logic operations

    requested by programrequested by program

    Communicate withCommunicate with

    "outside world","outside world",e.g.e.g.

    ScreenScreen

    KeyboardKeyboard

    Storage devicesStorage devices

    ......

    Bus

  • 8/8/2019 12640_cmput101.ch5.1

    5/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 5

    Memory SubsystemMemory Subsystem

    Memory, also calledMemory, also calledRAMRAM((RRandomandomAAccessccess

    MMemory),emory),

    Consists of many memory cells (storage units) of a fixedConsists of many memory cells (storage units) of a fixed

    size.size.

    Each cell has an address associated with it: 0, 1, Each cell has an address associated with it: 0, 1,

    All accesses to memory are to a specified address.All accesses to memory are to a specified address.

    A cell is the minimum unit of access (fetch/store a completeA cell is the minimum unit of access (fetch/store a complete

    cell).cell).

    The time it takes to fetch/store a cell is the same for allThe time it takes to fetch/store a cell is the same for all

    cells.cells.

    When the computer is running, bothWhen the computer is running, both

  • 8/8/2019 12640_cmput101.ch5.1

    6/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 6

    RAMRAM Need to distinguish betweenNeed to distinguish between

    thethe addressaddress of a memory cellof a memory celland theand the contentcontent of a memoryof a memorycellcell

    Memory width (Memory width (WW):): How many bits is each memoryHow many bits is each memory

    cell, typically onecell, typically one bytebyte (=8 bits)(=8 bits)

    Address width (Address width (NN):):

    How many bits used toHow many bits used torepresent each address,represent each address,determines the maximumdetermines the maximummemory size =memory size = address spaceaddress space

    If address width isIf address width is NN--bits, thenbits, then

    address space isaddress space is 22NN

    (0,1,...,2(0,1,...,2NN

    --1)1)

    ...

    00

    11

    22

    22NN--11

    1 bit1 bit

    WW

    00000000000000010000000000000001

    NN

    22NN

  • 8/8/2019 12640_cmput101.ch5.1

    7/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 7

    Memory Size / SpeedMemory Size / Speed

    Typical memory in a personal computer (PC):Typical memory in a personal computer (PC): 64MB64MB -- 256MB256MB

    Memory sizes:Memory sizes:

    KilobyteKilobyte (KB)(KB) = 2 = 21010== 1,024 bytes ~ 1 thousand1,024 bytes ~ 1 thousand Megabyte(MB)Megabyte(MB) = 2= 22020== 1,048,576 bytes ~ 1 million1,048,576 bytes ~ 1 million

    GigabyteGigabyte(GB)(GB) = 2 = 23030== 1,073,741,824 bytes ~ 1 billion1,073,741,824 bytes ~ 1 billion

    Memory Access Time (read from/ write to memory)Memory Access Time (read from/ write to memory)

    50 50--75 nanoseconds (1 nsec. = 0.000000001 sec.)75 nanoseconds (1 nsec. = 0.000000001 sec.)

    RAM isRAM is volatile (can only store when power is on)volatile (can only store when power is on)

    relatively expensiverelatively expensive

  • 8/8/2019 12640_cmput101.ch5.1

    8/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 8

    Operations on MemoryOperations on Memory Fetch (address):Fetch (address):

    Fetch a copy of the content of memory cell with the specifiedFetch a copy of the content of memory cell with the specified

    address.address.

    NonNon--destructive, copies value in memory cell.destructive, copies value in memory cell.

    Store (address, value):Store (address, value):

    Store the specified value into the memory cell specified byStore the specified value into the memory cell specified by

    address.address.

    Destructive, overwrites the previous value of the memory cell.Destructive, overwrites the previous value of the memory cell.

    The memory system is interfaced via:The memory system is interfaced via:

    Memory Address Register (MAR)Memory Address Register (MAR)

    Memory Data Register (MDR)Memory Data Register (MDR)

    Fetch/Store signalFetch/Store signal

  • 8/8/2019 12640_cmput101.ch5.1

    9/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 9

    Structure of the Memory SubsystemStructure of the Memory Subsystem

    Fetch(address)Fetch(address) Load address into MAR.Load address into MAR.

    Decode the address in MAR.Decode the address in MAR.

    Copy the content of memory cellCopy the content of memory cellwith specified address into MDR.with specified address into MDR.

    Store(address, value)Store(address, value) Load the address into MAR.Load the address into MAR.

    Load the value into MDR.Load the value into MDR. Decode the address in MARDecode the address in MAR

    Copy the content of MDR intoCopy the content of MDR intomemory cell with the specifiedmemory cell with the specifiedaddress.address.

    MAR MDR

    ...

    Memorydecoder

    circuit

    Fetch/Storecontroller

    F/S

  • 8/8/2019 12640_cmput101.ch5.1

    10/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 10

    Input/Output SubsystemInput/Output Subsystem

    Handles devices that allow the computer systemHandles devices that allow the computer systemto:to:

    Communicate and interact with the outside worldCommunicate and interact with the outside world

    Screen, keyboard, printer, ...Screen, keyboard, printer, ...

    Store information (massStore information (mass--storage)storage)

    HardHard--drives, floppies, CD, tapes, drives, floppies, CD, tapes,

    MassMass--Storage Device Access Methods:Storage Device Access Methods: Direct Access Storage Devices (DASDs)Direct Access Storage Devices (DASDs)

    Hard Hard--drives, floppydrives, floppy--disks, CDdisks, CD--ROMs, ...ROMs, ...

    Sequential Access Storage Devices (SASDs)Sequential Access Storage Devices (SASDs)

    Tapes (for example, used as backup devices)Tapes (for example, used as backup devices)

  • 8/8/2019 12640_cmput101.ch5.1

    11/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 11

    I/O ControllersI/O Controllers

    Speed of I/O devices is slow compared to RAMSpeed of I/O devices is slow compared to RAM

    RAM ~ 50 nsec.RAM ~ 50 nsec.

    HardHard--Drive ~ 10msec. = (10,000,000 nsec)Drive ~ 10msec. = (10,000,000 nsec)

    Solution:Solution: I/O Controller, a special purpose processor:I/O Controller, a special purpose processor:

    Has a small memory buffer, and a control logic to controlHas a small memory buffer, and a control logic to controlI/O device (e.g. move disk arm).I/O device (e.g. move disk arm).

    Sends an interrupt signal to CPU when done read/write.Sends an interrupt signal to CPU when done read/write. Data transferred between RAM and memory buffer.Data transferred between RAM and memory buffer.

    Processor free to do something else while I/O controllerProcessor free to do something else while I/O controllerreads/writes data from/to device into I/O buffer.reads/writes data from/to device into I/O buffer.

  • 8/8/2019 12640_cmput101.ch5.1

    12/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 12

    I/O controller

    Structure of the I/O SubsystemStructure of the I/O Subsystem

    I/O Buffer

    Control/Logic

    I/O device

    Data from/to memoryInterrupt signal (to processor)

  • 8/8/2019 12640_cmput101.ch5.1

    13/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 13

    The ALU SubsystemThe ALU Subsystem

    The ALU (Arithmetic/Logic Unit) performsThe ALU (Arithmetic/Logic Unit) performs

    mathematical operations (+,mathematical operations (+, --, x, /, ), x, /, )

    logic operations (=, , and, or, not, ...)logic operations (=, , and, or, not, ...)

    In today's computers integrated into the CPUIn today's computers integrated into the CPU

    Consists of:Consists of:

    Circuits to do the arithmetic/logic operations.Circuits to do the arithmetic/logic operations.

    Registers (fast storage units) to store intermediateRegisters (fast storage units) to store intermediate

    computational results.computational results.

    Bus that connects the two.Bus that connects the two.

  • 8/8/2019 12640_cmput101.ch5.1

    14/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 14

    Structure of the ALUStructure of the ALU

    Registers:Registers: Very fast local memory cells, thatVery fast local memory cells, that

    store operands of operations andstore operands of operations andintermediate results.intermediate results.

    CCR CCR (condition code register), a(condition code register), aspecial purpose register thatspecial purpose register thatstores the result of stores the result of operationsoperations

    ALU circuitry:ALU circuitry: Contains an array of circuits toContains an array of circuits to

    do mathematical/logicdo mathematical/logicoperations.operations.

    Bus:Bus:

    Data path interconnecting theData path interconnecting the

    ALU circuitry

    GT EQ LT

    R0

    R1

    R2

    Rn

  • 8/8/2019 12640_cmput101.ch5.1

    15/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 15

    The Control UnitThe Control Unit

    Program is stored in memoryProgram is stored in memory

    as machine language instructions, in binaryas machine language instructions, in binary

    The task of theThe task of the control unitcontrol unitis to executeis to executeprograms by repeatedly:programs by repeatedly:

    FetchFetch from memory the next instruction to befrom memory the next instruction to be

    executed.executed.

    DecodeDecode it, that is, determine what is to be done.it, that is, determine what is to be done.

    ExecuteExecute it by issuing the appropriate signals to theit by issuing the appropriate signals to the

    ALU, memory, and I/O subsystems.ALU, memory, and I/O subsystems.

    Continues until the HALT instructionContinues until the HALT instruction

  • 8/8/2019 12640_cmput101.ch5.1

    16/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 16

    Machine Language InstructionsMachine Language Instructions

    A machine language instruction consists of:A machine language instruction consists of:

    Operation codeOperation code, telling which operation to, telling which operation to

    performperform

    Address field(s)Address field(s), telling the memory addresses of, telling the memory addresses ofthe values on which the operation works.the values on which the operation works.

    Example: ADD X, YExample: ADD X, Y (Add content of memory(Add content of memory

    locations X and Y, and store back in memory location Y).locations X and Y, and store back in memory location Y). Assume: opcode for ADD is 9, and addresses X=99, Y=100Assume: opcode for ADD is 9, and addresses X=99, Y=100

    00001001 0000000001100011 0000000001100100

    Opcode (8 bits)Opcode (8 bits) Address 1 (16 bits)Address 1 (16 bits) Address 2 (16 bits)Address 2 (16 bits)

  • 8/8/2019 12640_cmput101.ch5.1

    17/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 17

    Instruction Set DesignInstruction Set Design

    Two different approaches:Two different approaches:

    Reduced Instruction Set Computers (RISC)Reduced Instruction Set Computers (RISC)

    Instruction set as small and simple as possible.Instruction set as small and simple as possible. Minimizes amount of circuitryMinimizes amount of circuitry ----> faster computers> faster computers

    Complex Instruction Set Computers (CISC)Complex Instruction Set Computers (CISC)

    More instructions, many very complexMore instructions, many very complex

    Each instruction can do more work, but require moreEach instruction can do more work, but require morecircuitry.circuitry.

  • 8/8/2019 12640_cmput101.ch5.1

    18/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 18

    Typical Machine InstructionsTypical Machine Instructions

    Notation:Notation:

    We use X, Y, Z to denote RAM cellsWe use X, Y, Z to denote RAM cells

    Assume only one register R (for simplicity)Assume only one register R (for simplicity) Use EnglishUse English--like descriptions (should be binary)like descriptions (should be binary)

    Data Transfer InstructionsData Transfer Instructions

    LOADLOAD XX Load content of memory location X to RLoad content of memory location X to R

    STORE XSTORE X Load content of R to memory location XLoad content of R to memory location X

    MOVEMOVE X, YX, Y Copy content of memory location X to loc.Copy content of memory location X to loc.YY

    (not absolutely necessary)(not absolutely necessary)

  • 8/8/2019 12640_cmput101.ch5.1

    19/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 19

    Machine Instructions (cont.)Machine Instructions (cont.)

    ArithmeticArithmetic ADD X, Y, ZADD X, Y, Z CON(Z) = CON(X) + CON(Y)CON(Z) = CON(X) + CON(Y)

    ADD X, YADD X, Y CON(Y) = CON(X) + CON(Y)CON(Y) = CON(X) + CON(Y)

    ADD XADD X R = CON(X) + RR = CON(X) + R similar instructions for other operators, e.g. SUBTR,OR, ...similar instructions for other operators, e.g. SUBTR,OR, ...

    CompareCompare

    COMPARE X, YCOMPARE X, YCompare the content of memory cell X to the content ofCompare the content of memory cell X to the content of

    memory cell Y and set the condition codes (CCR)memory cell Y and set the condition codes (CCR)

    accordingly.accordingly.

    E.g.E.g. If CON(X) = R then set EQ=1, GT=0, LT=0If CON(X) = R then set EQ=1, GT=0, LT=0

  • 8/8/2019 12640_cmput101.ch5.1

    20/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 20

    Machine Instructions (cont.)Machine Instructions (cont.)

    BranchBranch

    JUMP XJUMP X Load next instruction fromLoad next instruction from

    memory loc. Xmemory loc. X JUMPGT XJUMPGT X Load next instruction from memory loc.Load next instruction from memory loc.

    X X only if GT flag in CCR is set,only if GT flag in CCR is set,

    otherwise loadotherwise load statement from nextstatement from next

    sequence loc. assequence loc. as usual.usual.

    JUMPEQ, JUMPLT, JUMPGE, JUMPLE,JUMPNEQJUMPEQ, JUMPLT, JUMPGE, JUMPLE,JUMPNEQ

    ControlControl

    HALTHALT Stop program execution.Stop program execution.

  • 8/8/2019 12640_cmput101.ch5.1

    21/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 21

    ExampleExample

    PseudoPseudo--code:code: Set A to B + CSet A to B + C

    Assuming variable:Assuming variable:

    A stored in memory cell 100, B stored in memoryA stored in memory cell 100, B stored in memory

    cell 150, C stored in memory cell 151cell 150, C stored in memory cell 151

    Machine language (really in binary)Machine language (really in binary)

    LOAD 150LOAD 150

    ADDADD 151151 STORE 100STORE 100

    or or

    (ADD(ADD 150, 151, 100)150, 151, 100)

  • 8/8/2019 12640_cmput101.ch5.1

    22/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 22

    Structure of the Control UnitStructure of the Control Unit

    PC (Program Counter):PC (Program Counter): stores the address of next instruction to fetchstores the address of next instruction to fetch

    IR (Instruction Register):IR (Instruction Register):

    stores the instruction fetched from memorystores the instruction fetched from memory

    Instruction Decoder:Instruction Decoder: Decodes instruction and activates necessaryDecodes instruction and activates necessary

    circuitrycircuitry

    Instruction

    Decoder

    IR

    +1

    PC

  • 8/8/2019 12640_cmput101.ch5.1

    23/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 23

    von Neumannvon Neumann

    ArchitectureArchitecture

    von Neumannvon Neumann

    ArchitectureArchitecture

  • 8/8/2019 12640_cmput101.ch5.1

    24/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 24

    How does this all work together?How does this all work together?

    Program Execution:Program Execution:

    PC is set to the address where the first programPC is set to the address where the first program

    instruction is stored in memory.instruction is stored in memory. Repeat until HALT instruction or fatal errorRepeat until HALT instruction or fatal error

    Fetch instructionFetch instruction

    Decode instructionDecode instruction

    Execute instructionExecute instruction

    End of loopEnd of loop

  • 8/8/2019 12640_cmput101.ch5.1

    25/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 25

    Program Execution (cont.)Program Execution (cont.)

    Fetch phaseFetch phase

    PC PC ----> MAR> MAR (put address in PC into MAR)(put address in PC into MAR)

    Fetch signalFetch signal (signal memory to fetch value into(signal memory to fetch value intoMDR)MDR)

    MDRMDR ----> IR> IR (move value to Instruction Register)(move value to Instruction Register)

    PC + 1PC + 1 ----> PC> PC (Increase address in program(Increase address in program

    counter)counter)

    Decode PhaseDecode Phase

    IR IR --> Instruction decoder> Instruction decoder(decode instruction in IR)(decode instruction in IR)

    Instruction decoder will then generate the signals toInstruction decoder will then generate the signals to

  • 8/8/2019 12640_cmput101.ch5.1

    26/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 26

    Program Execution (cont.)Program Execution (cont.)

    Execute PhaseExecute Phase

    Differs from one instruction to the next.Differs from one instruction to the next.

    Example:Example: LOAD X (load value in addr. X into register)LOAD X (load value in addr. X into register)

    IR_addressIR_address --> MAR> MAR

    Fetch signalFetch signal

    MDR MDR ----> R> R ADD XADD X

    left as an exerciseleft as an exercise

  • 8/8/2019 12640_cmput101.ch5.1

    27/27

    CMPUT101 Introduction to Computing (c) Yngvi Bjornsson 27

    Instruction Set for Our Von Neumann MachineInstruction Set for Our Von Neumann MachineOpcodeOpcode OperationOperation MeaningMeaning

    0000 LOAD X CON(X) --> R

    0001 STORE X R --> CON(X)

    0010 CLEAR X 0 --> CON(X)

    0011 ADD X R + CON(X) --> R

    0100 INCREMENT X CON(X) + 1 --> CON(X)

    0101 SUBTRACT X R - CON(X) --> R

    0101 DECREMENT X CON(X) - 1 --> CON(X)

    0111

    COMPARE X If CON(X) > R then GT = 1 else 0

    If CON(X) = R then EQ = 1 else 0

    If CON(X) < R then LT = 1 else 0

    1000 JUMP X Get next instruction from memory location X 1001 JUMPGT X Get next instruction from memory loc. X if GT=1

    ... JUMPxx X xx = LT / EQ / NEQ

    1101 IN X Input an integer value and store in X

    1110 OUT X Output, in decimal notation, content of mem. loc. X

    1111 HALT Stop program execution