William Stallings Computer Organization and Architecture

Similar documents
William Stallings Computer Organization and Architecture. Chapter 11 CPU Structure and Function

CPU Structure and Function

CPU Structure and Function. Chapter 12, William Stallings Computer Organization and Architecture 7 th Edition

CPU Structure and Function

UNIT- 5. Chapter 12 Processor Structure and Function

Chapter 12. CPU Structure and Function. Yonsei University

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 12 Processor Structure and Function

William Stallings Computer Organization and Architecture

UNIT V: CENTRAL PROCESSING UNIT

Processing Unit CS206T

Author : Dalbir Singh, Computer Science Deptt. CPU Structure and Functions. 1. Processor Organization

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

Micro-Operations. execution of a sequence of steps, i.e., cycles

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

Chapter 14 - Processor Structure and Function

Processor Structure and Function

William Stallings Computer Organization and Architecture 10 th Edition Pearson Education, Inc., Hoboken, NJ. All rights reserved.

Computer Architecture and Organization. Instruction Sets: Addressing Modes and Formats

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 11 Instruction Sets: Addressing Modes and Formats

Computer Organization and Technology Processor and System Structures

Pipelining, Branch Prediction, Trends

Addressing Modes. Immediate Direct Indirect Register Register Indirect Displacement (Indexed) Stack

RISC & Superscalar. COMP 212 Computer Organization & Architecture. COMP 212 Fall Lecture 12. Instruction Pipeline no hazard.

Main Points of the Computer Organization and System Software Module

Blog -

Module 5 - CPU Design

Outcomes. Lecture 13 - Introduction to the Central Processing Unit (CPU) Central Processing UNIT (CPU) or Processor

Chapter 2 Instruction Set Architecture

Lecture1: introduction. Outline: History overview Central processing unite Register set Special purpose address registers Datapath Control unit

William Stallings Computer Organization and Architecture

Module 4c: Pipelining

Chapter 11. Instruction Sets: Addressing Modes and Formats. Yonsei University

Running Applications

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CPU ARCHITECTURE. QUESTION 1 Explain how the width of the data bus and system clock speed affect the performance of a computer system.

SCRAM Introduction. Philipp Koehn. 19 February 2018

Instruction Sets: Characteristics and Functions Addressing Modes

GUJARAT TECHNOLOGICAL UNIVERSITY MASTER OF COMPUTER APPLICATION SEMESTER: III

ASSEMBLY LANGUAGE MACHINE ORGANIZATION

Control unit. Input/output devices provide a means for us to make use of a computer system. Computer System. Computer.

PIPELINE AND VECTOR PROCESSING

DC57 COMPUTER ORGANIZATION JUNE 2013

Digital System Design Using Verilog. - Processing Unit Design

Q.1 Explain Computer s Basic Elements

East Tennessee State University Department of Computer and Information Sciences CSCI 4717 Computer Architecture TEST 3 for Fall Semester, 2005

Class Notes. Dr.C.N.Zhang. Department of Computer Science. University of Regina. Regina, SK, Canada, S4S 0A2

General purpose registers These are memory units within the CPU designed to hold temporary data.

Chapter 16. Control Unit Operation. Yonsei University

Computer Organization CS 206 T Lec# 2: Instruction Sets

Computer Organization II CMSC 3833 Lecture 33

CSE 410. Operating Systems

What Are The Main Differences Between Program Counter Pc And Instruction Register Ir

Pipelining. Parts of these slides are from the support material provided by W. Stallings

Module 3 Instruction Set Architecture (ISA)

Basic Processing Unit: Some Fundamental Concepts, Execution of a. Complete Instruction, Multiple Bus Organization, Hard-wired Control,

Parallelism. Execution Cycle. Dual Bus Simple CPU. Pipelining COMP375 1

Major Advances (continued)

Computer System Overview

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 16 Micro-programmed Control

General Purpose Processors

Computer System Overview OPERATING SYSTEM TOP-LEVEL COMPONENTS. Simplified view: Operating Systems. Slide 1. Slide /S2. Slide 2.

CISC Processor Design

Chapter 3 : Control Unit

Pipeline and Vector Processing 1. Parallel Processing SISD SIMD MISD & MIMD

Computer Systems Overview

Overview. EE 4504 Computer Organization. Much of the computer s architecture / organization is hidden from a HLL programmer

5008: Computer Architecture HW#2

Instruction Set II. COMP 212 Computer Organization & Architecture. COMP 212 Fall Lecture 7. Instruction Set. Quiz. What is an Instruction Set?

There are four registers involved in the fetch cycle: MAR, MBR, PC, and IR.

Instruction-set Design Issues: what is the ML instruction format(s) ML instruction Opcode Dest. Operand Source Operand 1...

William Stallings Computer Organization and Architecture 10 th Edition Pearson Education, Inc., Hoboken, NJ. All rights reserved.

Darshan Institute of Engineering & Technology for Diploma Studies Unit - 1

CPE300: Digital System Architecture and Design

Processors. Young W. Lim. May 12, 2016

Notes: The Marie Simulator

Chapter 9 Pipelining. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

icroprocessor istory of Microprocessor ntel 8086:

2 MARKS Q&A 1 KNREDDY UNIT-I

There are different characteristics for exceptions. They are as follows:

Computer and Hardware Architecture I. Benny Thörnberg Associate Professor in Electronics

SISTEMI EMBEDDED. Computer Organization Central Processing Unit (CPU) Federico Baronti Last version:

Computer organization by G. Naveen kumar, Asst Prof, C.S.E Department 1

COMPUTER ORGANIZATION AND DESI

Where Does The Cpu Store The Address Of The

Hardware and Software Architecture. Chapter 2

Micro-programmed Control Ch 15

Chapter 5. Computer Architecture Organization and Design. Computer System Architecture Database Lab, SANGJI University

The Instruction Set. Chapter 5

Machine Instructions vs. Micro-instructions. Micro-programmed Control Ch 15. Machine Instructions vs. Micro-instructions (2) Hardwired Control (4)

Micro-programmed Control Ch 15

Chapter 1 Computer System Overview

COMPUTER ORGANIZATION & ARCHITECTURE

Chapter 2: Instructions How we talk to the computer

Computer Architecture and Organization (CS-507)

Computer Structure. Unit 4. Processor

Tutorial 4 KE What are the differences among sequential access, direct access, and random access?

The MARIE Architecture

CHAPTER 5 A Closer Look at Instruction Set Architectures

Introduction to Computers - Chapter 4

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

Transcription:

William Stallings Computer Organization and Architecture Chapter 11 CPU Structure and Function Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-1

CPU Functions CPU must: Fetch instructions Decode instructions Fetch operands Execute instructions / Process data Store data Check (and possibly serve) interrupts Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-2

CPU Components ALU CPU Internal Bus Registri PC IR AC MBR MAR Data Lines Address Lines Control Lines Control Unit Control Signals Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-3

Kind of Registers User visible and modifiable General Purpose Data (e.g. accumulator) Address (e.g. base addressing, index addressing) Control registers (not visible to user) Program Counter (PC) Instruction Decoding Register (IR) Memory Address Register (MAR) Memory Buffer Register (MBR) State register (visible to user but not directly modifiable) Program Status Word (PSW) Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-4

Kind of General Purpose Registers May be used in a general way or be restricted to contains only data or only addresses Advantages of general purpose registers Increase flexibility and programmer options Increase instruction size & complexity Advantages of specialized (data/address) registers Smaller (faster) instructions Less flexibility Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-5

How Many General Purposes Registers? Between 8-32 Fewer = more memory references More does not reduce memory references and takes up processor real estate Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-6

How many bits per register? Large enough to hold full address value Large enough to hold full data value Often possible to combine two data registers to obtain a single register with a double length Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-7

State Registers Sets of individual bits e.g. store if result of last operation was zero or not Can be read (implicitly) by programs e.g. Jump if zero Can not (usually) be set by programs There is always a Program Status Word (see later) Possibly (for operating system purposes): Interrupt vectors Memory page table (virtual memory) Process control blocks (multitasking) Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-8

Program Status Word A set of bits, including condition code bits, giving the status of the program Sign of last result Zero Carry Equal Overflow Interrupt enable/disable Supervisor mode (allow to execute privileged instructions) Used by operating system (not available to user programs) Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-9

Example Register Organizations Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-10

Instruction Cycle (with Interrupt) Fetch Phase Execute Phase Interrupt Phase Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-11

Instruction Cycle (with Indirect Addressing) Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-12

A closer look at the execution phase Execute Decode Execute Decode Fetch Operand Execute Decode Calculate Address Fetch Operand Execute Decode Calculate Address Fetch Address Fetch Operand Execute Decode Calculate Operand Execute Write Result Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-13

Instruction Cycle State Diagram (with Indirection) Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-14

Data Flow for Instruction Fetch PC contains address of next instruction Sequence of actions needed to execute instruction fetch: 1. PC is moved to MAR 2. MAR content is placed on address bus 3. Control unit requests memory read 4. Memory read address bus and places result on data bus 5. Data bus is copied to MBR 6. MBR is copied to IR 7. Meanwhile, PC is incremented by 1 Action 7 can be executed in parallel with any other action after the first Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-15

Diagrams representing Data Flows The previous example shows 7 distinct actions, each corresponding to a DF (= data flow) Distinct DFs are not necessarily executed at distinct time steps (i.e.: DF n and DF n+1 might be executed during the same time step see chapter 14) Large arrows in white represents DFs with a true flow of data Large hatched arrows represents DFs where flow of data acts as a control: only the more relevant controls are shown Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-16

Data Flow Diagram for Instruction Fetch CPU 3 PC 1 MAR 2 4 4 Memory 7 Control Unit 3 IR 6 MBR 5 MAR = Memory Address Register MBR = Memory Buffer Register IR = Instruction Register PC = Program Counter Address Bus Data Bus Control Bus Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-17

Data Flow for Data Fetch: Immediate and Register Addressing ALWAYS: IR is examined to determine addressing mode Immediate addressing: The operand is already in IR Register addressing: Control unit requests read from register selected according to value in IR Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-18

Data Flow Diagram for Data Fetch with Register Addressing CPU Registers Control Unit IR MAR = Memory Address Register MBR = Memory Buffer Register IR = Instruction Register PC = Program Counter Address Bus Data Bus Control Bus Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-19

Data Flow for Data Fetch: Direct Addressing Direct addressing: 1. Address field is moved to MAR 2. MAR content is placed on address bus 3. Control unit requests memory read 4. Memory reads address bus and places result on data bus 5. Data bus (= operand) is copied to MBR Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-20

Data Flow Diagram for Data Fetch with Direct Addressing CPU 3 MAR 2 4 4 Memory 1 Control Unit 3 IR MBR 5 MAR = Memory Address Register MBR = Memory Buffer Register IR = Instruction Register PC = Program Counter Address Bus Data Bus Control Bus Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-21

Data Flow for Data Fetch: Register Indirect Addressing Register indirect addressing: 1. Control unit requests read from register selected according to value in IR 2. Selected register value is moved to MAR 3. MAR content is placed on address bus 4. Control unit requests memory read 5. Memory reads address bus and places result on data bus 6. Data bus (= operand) is moved to MBR Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-22

Data Flow Diagram for Data Fetch with Register Indirect Addressing CPU 4 2 MAR 3 5 5 Memory Registers 1 Control Unit 4 1 6 IR MBR MAR = Memory Address Register MBR = Memory Buffer Register IR = Instruction Register PC = Program Counter Address Bus Data Bus Control Bus Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-23

Data Flow for Data Fetch: Indirect Addressing Indirect addressing: 1. Address field is moved to MAR 2. MAR content is placed on address bus 3. Control unit requests memory read 4. Memory reads address bus and places result on data bus 5. Data bus (= address of operand) is moved to MBR 6. MBR is transferred to MAR 7. MAR content is placed on address bus 8. Control unit requests memory read 9. Memory reads address bus and places result on data bus 10. Data bus (= operand) is copied to MBR Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-24

Data Flow Diagram for Data Fetch with Indirect Addressing CPU 3-8 MAR 2-7 4-9 4-9 Memory 1 6 Control Unit 3-8 IR MBR 5-10 MAR = Memory Address Register MBR = Memory Buffer Register IR = Instruction Register PC = Program Counter Address Bus Data Bus Control Bus Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-25

Data Flow for Data Fetch: Relative Addressing Relative addressing (a form of displacement): 1. Address field is moved to ALU 2. PC is moved to ALU 3. Control unit requests sum to ALU 4. Result from ALU is moved to MAR 5. MAR content is placed on address bus 6. Control unit requests memory read 7. Memory reads address bus and places result on data bus 8. Data bus (= operand) is copied to MBR Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-26

Data Flow Diagram for Data Fetch with Relative Addressing CPU 6 PC 2 ALU 4 MAR 5 7 7 Memory 3 Control Unit 6 1 8 IR MBR MAR = Memory Address Register MBR = Memory Buffer Register IR = Instruction Register PC = Program Counter ALU = Arithmetic Logic Unit Address Bus Data Bus Control Bus Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-27

Data Flow for Data Fetch: Base Addressing Base addressing (a form of displacement): 1. Control unit requests read from register selected according to value in IR (explicit selection) 2. Selected register value is moved to ALU 3. Address field is moved to ALU 4. Control unit requests sum to ALU 5. Result from ALU is moved to MAR 6. MAR content is placed on address bus 7. Control unit requests memory read 8. Memory reads address bus and places result on data bus 9. Result (= operand) is moved to MBR Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-28

Data Flow Diagram for Data Fetch with Base Addressing CPU 7 ALU 5 MAR 6 8 8 Memory 3 2 Registers 4 1 Control Unit 7 1 9 IR MBR MAR = Memory Address Register MBR = Memory Buffer Register IR = Instruction Register PC = Program Counter ALU = Arithmetic Logic Unit Address Bus Data Bus Control Bus Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-29

Data Flow for Data Fetch: Indexed Addressing Same data flow as Base addressing Indexed addressing (a form of displacement): 1. Control unit requests read from register selected according to value in IR (explicit selection) 2. Selected register value is moved to ALU 3. Address field is moved to ALU 4. Control unit requests sum to ALU 5. Result from ALU is moved to MAR 6. MAR content is placed on address bus 7. Control unit requests memory read 8. Memory reads address bus and places result on data bus 9. Result (= operand) is moved to MBR Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-30

Data Flow Diagram for Data Fetch with Indexed Addressing The diagram is the same as for Base addressing Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-31

Data Flow for Data Fetch with indirection and displacement Two different combinations of displacement and indirection (pre-index and post-index) See chapter 10 for the logical diagrams The data flow is a combination of what happens with the two techniques Try drawing the data flow diagrams yourself! Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-32

Data Flow for Execute May take many forms Depends on the actual instruction being executed May include Memory read/write Input/Output Register transfers ALU operations Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-33

Data Flow for Interrupt Current PC has to be saved (usually to stack) to allow resumption after interrupt and execution has to continue at the interrupt handler routine 1. Save the content of PC a. Contents of PC is copied to MBR b. Special memory location (e.g. stack pointer) is loaded to MAR c. Contents of MAR and MBR are placed, respectively, on address and data bus d. Control unit requests memory write e. Memory reads address and data bus and store to memory location 2. PC is loaded with address of the handling routine for the specific interrupt (usually by means of indirect addressing through the Interrupt Vector) a. Move to MAR the address into the interrupt vector for the specific interrupt b. MAR content is placed on address bus c. Control unit requests memory read d. Memory reads address bus and places result on data bus e. Data bus is copied to MBR f. MBR is moved to PC Next instruction (first of the specific interrupt handler) can now be fetched Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-34

Data Flow Diagram for Interrupt CPU 1d - 2c 1b Registers 1b MAR 2a Control Unit 1c - 2b 1d - 2c 2d 1e 1e - 2d Memory 2f 2e PC MBR 1a 1c MAR = Memory Address Register MBR = Memory Buffer Register IR = Instruction Register PC = Program Counter Address Bus Data Bus Control Bus Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-35

Prefetch Fetch accesses main memory Execution usually does not access main memory CPU could fetch next instruction during the execution of current instruction Requires two sub-parts in CPU able to operate independently Called instruction prefetch Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-36

Improved Performance But performance is not doubled: Fetch usually shorter than execution (but for simple operations with many operands) Prefetch more than one instruction? Any conditional jump or branch means that prefetched instructions may be useless Performance can be improved by adding more stages in instruction processing... and more independent sub-parts in CPU Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-37

Pipelining Instruction cycle can be decomposed in elementary phases, for example: FI: Fetch instruction DI: Decode instruction CO: Calculate operands (i.e. calculate EAs) FO: Fetch operands EI: Execute instructions WO: Write output Pipelining improves performance by overlapping these phases (ideally can all be overlapped) Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-38

Timing of Pipeline Set up time Time Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-39

A general principle The more overlapping phases are in a pipeline the more additional processing is needed to manage each phase and synchronization among phases Logical dependencies between phases There is a trade-off between number of phases and speed-up of instruction execution Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-40

Control flow (1) Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-41

Branch in a Pipeline (1) Instruction 3 is an unconditional branch to instruction 15 Time Branch Penalty Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-42

Control flow (2) But an unconditional branch might be managed earlier than EI phase Empty Back Pipe Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-43

Branch in a Pipeline (2) The unconditional branch is managed after CO phase Time Branch Penalty Branch Penalty Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-44

Control flow (3) But conditional branches still have a large penalty Empty Back Pipe Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-45

Branch in a Pipeline (3) Here instruction 3 is a conditional branch to instruction 15 Time Branch Penalty Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-46

Dealing with Branches Multiple Streams Prefetch Branch Target Loop buffer Branch prediction Delayed branching Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-47

Multiple Streams Have two pipelines Prefetch each branch into a separate pipeline Use appropriate pipeline Leads to bus & register contention (only the sub-parts making up the pipeline are doubled) Additional branches entering the pipeline lead to further pipelines being needed Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-48

Prefetch Branch Target Target of branch is prefetched in addition to instructions following branch and stored in an additional dedicated register Keep target until branch is executed Used by IBM 360/91 Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-49

Loop Buffer Very fast memory internal to CPU Record the last n fetched instructions Maintained by fetch stage of pipeline Check loop buffer before fetching from memory Very good for small loops or close jumps The same concept as cache memory Used by CRAY-1 Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-50

Branch Prediction (1) Predict never taken Assume that jump will not happen Always fetch next instruction 68020 & VAX 11/780 VAX will not prefetch after branch if a page fault would result (O/S v CPU design) Predict always taken Assume that jump will happen Always fetch target instruction Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-51

Branch Prediction (2) Predict by Opcode Some instructions are more likely to result in a jump than others Can get up to 75% success Taken/Not taken switch Based on previous history of the instruction Good for loops Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-52

Branch Prediction State Diagram Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-53

Delayed Branch Used for RISC architectures Do not take jump until you have to Rearrange instructions Rev. 3.2.1 (2005-06) by Enrico Nardelli 11-54