Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 1 – –Second level Third level – –Fourth level » »Fifth level 1 The Von Neumann Model Proposed in 1946Proposed in 1946 Two main ideas:Two main ideas: components of an architecturecomponents of an architecture how instructions are processedhow instructions are processed
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 2 – –Second level Third level – –Fourth level » »Fifth level 2 Basic Architecture memory memory processor processor input input output output control unit control unit contains instructions that comprise a program a program executes the instructions orders the execution of the instructions an instruction is a unit of work
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 3 – –Second level Third level – –Fourth level » »Fifth level 3 Organization
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 4 – –Second level Third level – –Fourth level » »Fifth level 4 LC-2 Organization
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 5 – –Second level Third level – –Fourth level » »Fifth level 5 Memory Recall the 2 2 by 3 memory of Ch. 3Recall the 2 2 by 3 memory of Ch. 3 more realistically, many PCs aremore realistically, many PCs are 2 28 address space (256 MB)2 28 address space (256 MB) 8 bit addressability8 bit addressability LC-2 is 2 16 by 16LC-2 is 2 16 by 16
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 6 – –Second level Third level – –Fourth level » »Fifth level 6 Special Registers MAR: memory address registerMAR: memory address register location to be read/writtenlocation to be read/written MDR: memory data registerMDR: memory data register data value to be read/writtendata value to be read/written what has to be asserted for a value to be written?what has to be asserted for a value to be written?
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 7 – –Second level Third level – –Fourth level » »Fifth level 7 Contents of Memory/Registers Memory MARMDRWE Causes memory to be read into MDR Causes memory to be written from MDR
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 8 – –Second level Third level – –Fourth level » »Fifth level 8 Processing Unit may contain specialized functional units may contain specialized functional units LC-2 ALU has only ADD, AND, NOT operations LC-2 ALU has only ADD, AND, NOT operations size of information processed by ALU size of information processed by ALU is the word length of the computer is the word length of the computer LC-2 has 16 bit word length LC-2 has 16 bit word length
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 9 – –Second level Third level – –Fourth level » »Fifth level 9 Registers temporary storage used by CPU for intermediate values of computations temporary storage used by CPU for intermediate values of computations DEC Alpha has 32 registers DEC Alpha has 32 registers LC-2 has 8 (R0-R7) LC-2 has 8 (R0-R7)
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 10 – –Second level Third level – –Fourth level » »Fifth level 10 Input/output peripherals that allow computer to be connected to the outside worldperipherals that allow computer to be connected to the outside world get data/programs in and outget data/programs in and out input: keyboard, mouse, scanners, disksinput: keyboard, mouse, scanners, disks output: monitor, printers, disksoutput: monitor, printers, disks floppy, hard drives, zip disks, CDsfloppy, hard drives, zip disks, CDs
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 11 – –Second level Third level – –Fourth level » »Fifth level 11 Control Unit keeps track of current instruction in a program and current step in executing an instructionkeeps track of current instruction in a program and current step in executing an instruction coordinates activities between componentscoordinates activities between components registersregisters IR: holds current instructionIR: holds current instruction PC: holds address of next instructionPC: holds address of next instruction
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 12 – –Second level Third level – –Fourth level » »Fifth level 12 Discuss LC-2 as an Example of a Von Neumann Architecture some registers not yet discussedsome registers not yet discussed KBSR: status of keys struckKBSR: status of keys struck KBDR: value of key struckKBDR: value of key struck CRTSR: status of monitorCRTSR: status of monitor CRTDR: value to be written on monitorCRTDR: value to be written on monitor
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 13 – –Second level Third level – –Fourth level » »Fifth level 13 Central ideas of VN architecture Instructions and data are both sequences of bits stored in memory Instructions and data are both sequences of bits stored in memory One instruction at a time is executed (sequentially) One instruction at a time is executed (sequentially)
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 14 – –Second level Third level – –Fourth level » »Fifth level 14 Instruction Processing 2 parts:2 parts: opcode: what is to be doneopcode: what is to be done operands: what data is manipulatedoperands: what data is manipulated LC-2 instruction:LC-2 instruction: [15:12] opcode[15:12] opcode [11:0] how to locate operands[11:0] how to locate operands How many distinct operations in LC-2?How many distinct operations in LC-2?
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 15 – –Second level Third level – –Fourth level » »Fifth level 15 ADD Example opcode for ADD is 0001 opcode for ADD is 0001 ADD requires values to be pre-stored in registers, then the result is stored in a register ADD requires values to be pre-stored in registers, then the result is stored in a register Operands from register2 and register 3, result put in register 1 Operands from register2 and register 3, result put in register 1 opcode register 1 register 2 not used register 3 15………12 11……………9 8……….….6 5…..……..3 2………...0
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 16 – –Second level Third level – –Fourth level » »Fifth level 16 LDR Example load register with a value from memory load register with a value from memory causes value of 2nd register to be added to offset value, and value at that location is stored in 1st register causes value of 2nd register to be added to offset value, and value at that location is stored in 1st register opcode for LDR is 0110 opcode for LDR is 0110 opcode register 1 register2 offset 15………12 11……………9 8…..…….6 5………….0..
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 17 – –Second level Third level – –Fourth level » »Fifth level 17 LDR cont’d 15………12 11……………9 8……………….6 5………………….… value (2nd register + offset) stored in 1st register contents of memory in location (R3 + 6) goes into R2 called base + offset addressing mode addressing mode: describes the computation needed to yield values for operands
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 18 – –Second level Third level – –Fourth level » »Fifth level 18 The Instruction Cycle Sequence of steps carried out by control unit to execute instructions Sequence of steps carried out by control unit to execute instructions called phases called phases 6 phases, all may not be used by each instruction 6 phases, all may not be used by each instruction
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 19 – –Second level Third level – –Fourth level » »Fifth level 19 Fetch-Decode-Execute Cycle 1. fetch: gets next instruction from memory into IR MAR PC MDR contents of memory at location given in MAR IR MDR PC PC + 1
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 20 – –Second level Third level – –Fourth level » »Fifth level 20 Fetch-Decode-Execute Cycle 2. decode: in LC-2, a 4 to 16 decoder looks at the 4 opcode bits and asserts the appropriate output line to indicate the instruction to be executed 3. evaluate address: if a memory address is to be accessed (as in LDR) this phase computes the address not needed in ADD
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 21 – –Second level Third level – –Fourth level » »Fifth level 21 Fetch-Decode-Execute Cycle 4. fetch operands: obtains values of operands 5. execute: carries out instruction in ALU 6. store result: write result to designated destination LDR gets value from memory into a register ADD gets values from registers not needed in LDR increment PC, go to 1
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 22 – –Second level Third level – –Fourth level » »Fifth level 22 Changing the Execution Order 2 issues:2 issues: how to alter the execution order?how to alter the execution order? how to stop at the end of a program?how to stop at the end of a program? have to change the PC before the next fetch phasehave to change the PC before the next fetch phase
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 23 – –Second level Third level – –Fourth level » »Fifth level 23 Instruction Types 3 kinds of instructions:3 kinds of instructions: operate (e.g., ADD)operate (e.g., ADD) move data (e.g., LDR)move data (e.g., LDR) control instruction (e.g., JMPR)control instruction (e.g., JMPR) control instructions load the PC during the execute phasecontrol instructions load the PC during the execute phase
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 24 – –Second level Third level – –Fourth level » »Fifth level 24 JMPR Example puts an address in the PC puts an address in the PC useful for executing loops or skipping around useful for executing loops or skipping around uses base + offset addressing uses base + offset addressing JMPR opcode is 1100 JMPR opcode is 1100 opcode not used register1 offset 15………12 11……………9 8……………….6 5……………….0
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 25 – –Second level Third level – –Fourth level » »Fifth level 25 Tying It All Together: Example Algorithm Tying It All Together: Example Algorithm 1. Initialize a counter to 12 and a sum to If counter is 0, go to step else get next data item; 4. add item to sum; 5. decrement counter; 6. Output “sum is:” sum. 7. End
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 26 – –Second level Third level – –Fourth level » »Fifth level 26 Machine Language Example LEA R1, x3100 AND R3, 0 AND R2, 0 ADD R2, 12 BRz R2, x300A LDR R4, M[R1] ADD R3, R4 ADD R1, 1 ADD R2, -1 BRnzp x3004 Corresponding Assembly Language opcodes
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 27 – –Second level Third level – –Fourth level » »Fifth level 27 C++ Example // assumes an array holding 12 integers // has been declared and initialized int sum = 0; for (int i = 0; i < 12; i++) sum = sum + array[i]; LEA R1, x3100 AND R3, 0 AND R2, 0 ADD R2, 12 BRz R2, x300A LDR R4, M[R1] ADD R3, R4 ADD R1, 1 ADD R2, -1 BRnzp x3004
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 28 – –Second level Third level – –Fourth level » »Fifth level 28 Example continued A B C Data memory containing 12 values to sum Register s used R1 – address of data value R2 – number of data values left to add R3 – Sum of values which have been added R4 – current value to add to the sum
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 29 – –Second level Third level – –Fourth level » »Fifth level 29 Example continued Contents of Registers, first time thru the loop (in hexadecimal) (in hexadecimal) After instruction R1 R2 R3 R4 000C After instruction R1 R2 R3 R4 000B 0001
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 30 – –Second level Third level – –Fourth level » »Fifth level 30 Example continued Contents of Registers, 2 nd time thru the loop (in hexadecimal ) (in hexadecimal ) After instruction R1 R2 R3 R4 000B After instruction R1 R2 R3 R4 000A
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 31 – –Second level Third level – –Fourth level » »Fifth level 31 Example continued Contents of Registers, 3 rd time thru the loop (in hexadecimal) (in hexadecimal) After instruction R1 R2 R3 R4 000A 0003 After instruction R1 R2 R3 R
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 32 – –Second level Third level – –Fourth level » »Fifth level 32 Example continued Contents of Registers, 12 th time thru the loop (in hexadecimal) (in hexadecimal) After instruction C R1 R2 R3 R D After instruction D R1 R2 R3 R E 000D
Click to edit Master title style Click to edit Master text styles – –Second level Third level – –Fourth level » »Fifth level 33 – –Second level Third level – –Fourth level » »Fifth level 33 Foundation for Programming When you write C++ programs next quarter, you know they are translated to assembly language by a compiler When you write C++ programs next quarter, you know they are translated to assembly language by a compiler then translated to machine language to be executed by the hardware then translated to machine language to be executed by the hardware hardware consists of functional units in Von Neumann architecture hardware consists of functional units in Von Neumann architecture functional units are made up of gates functional units are made up of gates gates are implemented by transistors gates are implemented by transistors