UNIT V: CENTRAL PROCESSING UNIT

Similar documents
CPU Structure and Function

UNIT- 5. Chapter 12 Processor Structure and Function

William Stallings Computer Organization and Architecture

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

CPU Structure and Function

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

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

Chapter 12. CPU Structure and Function. Yonsei University

Instruc=on Set Architecture

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.

Instruc=on Set Architecture

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

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

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

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

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

Processor Architecture

Computer Architecture. CSE 1019Y Week 16. Introduc>on to MARIE

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

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

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

Processing Unit CS206T

Reading assignment. Chapter 3.1, 3.2 Chapter 4.1, 4.3

William Stallings Computer Organization and Architecture

CS 465 Final Review. Fall 2017 Prof. Daniel Menasce

Computer Organization and Technology Processor and System Structures

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

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

Chapter 3: Instruc0on Level Parallelism and Its Exploita0on

Main Points of the Computer Organization and System Software Module

Module 4c: Pipelining

Module 5 - CPU Design

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

The Instruction Set. Chapter 5

ASSEMBLY LANGUAGE MACHINE ORGANIZATION

Pipelining, Branch Prediction, Trends

CS 152 Computer Architecture and Engineering CS252 Graduate Computer Architecture. Lecture 3 - Pipelining

CSSE232 Computer Architecture I. Datapath

Ti Parallel Computing PIPELINING. Michał Roziecki, Tomáš Cipr

Computer Organization CS 206 T Lec# 2: Instruction Sets

Instruction Sets: Characteristics and Functions Addressing Modes

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Lecture 32: Pipeline Parallelism 3

Advanced Parallel Architecture Lessons 5 and 6. Annalisa Massini /2017

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

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer?

CISC Processor Design

Module 3 Instruction Set Architecture (ISA)

Running Applications

Chapter 2 Instruction Set Architecture

ECEC 355: Pipelining

Chapter 4. MARIE: An Introduction to a Simple Computer 4.8 MARIE 4.8 MARIE A Discussion on Decoding

6x86 PROCESSOR Superscalar, Superpipelined, Sixth-generation, x86 Compatible CPU

Micro-programmed Control Ch 15

Caching and Demand- Paged Virtual Memory

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

Micro-programmed Control Ch 15

Latches. IT 3123 Hardware and Software Concepts. Registers. The Little Man has Registers. Data Registers. Program Counter

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

DC57 COMPUTER ORGANIZATION JUNE 2013

Blog -

2012 David Black- Schaffer 1

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

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

SISTEMI EMBEDDED. Computer Organization Pipelining. Federico Baronti Last version:

CHAPTER 5 A Closer Look at Instruction Set Architectures

Chapter 13 Reduced Instruction Set Computers

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

Q.1 Explain Computer s Basic Elements

SCRAM Introduction. Philipp Koehn. 19 February 2018

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

The Kernel Abstrac/on

Processor Architecture. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Macro Assembler. Defini3on from h6p://

Understand the factors involved in instruction set

Micro-programmed Control Ch 17

General Purpose Processors

Hardwired Control (4) Micro-programmed Control Ch 17. Micro-programmed Control (3) Machine Instructions vs. Micro-instructions

The von Neumann Architecture. IT 3123 Hardware and Software Concepts. The Instruction Cycle. Registers. LMC Executes a Store.

COMPUTER ORGANIZATION & ARCHITECTURE

Processor Architecture

3/12/2014. Single Cycle (Review) CSE 2021: Computer Organization. Single Cycle with Jump. Multi-Cycle Implementation. Why Multi-Cycle?

CS430 Computer Architecture

EN164: Design of Computing Systems Topic 06.b: Superscalar Processor Design

GUJARAT TECHNOLOGICAL UNIVERSITY MASTER OF COMPUTER APPLICATION SEMESTER: III

Instruction Pipelining

Chapter 16. Control Unit Operation. Yonsei University

Instruction Pipelining

CC411: Introduction To Microprocessors

ECSE 425 Lecture 25: Mul1- threading

Computer Architecture

Superscalar Processors

Chapter 5. A Closer Look at Instruction Set Architectures

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

MICROPROCESSOR PROGRAMMING AND SYSTEM DESIGN

Register Are Two Names For The Same Place

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 14 Instruction Level Parallelism and Superscalar Processors

CHAPTER 5 A Closer Look at Instruction Set Architectures

SAE5C Computer Organization and Architecture. Unit : I - V

Transcription:

UNIT V: CENTRAL PROCESSING UNIT

Agenda Basic Instruc1on Cycle & Sets Addressing Instruc1on Format Processor Organiza1on Register Organiza1on Pipeline Processors Instruc1on Pipelining Co-Processors RISC computers vs. CISC computers Assignment 2

Addressing Modes Immediate Direct Indirect Register Register indirect Displacement Stack

Immediate Addressing Operand is part of instruc1on e.g. ADD 5 Add 5 to contents of accumulator 5 is operand No memory reference to fetch data Fast Limited range Instruction Opcode Operand

Direct Addressing Address field contains address of operand Effec1ve address (EA) = address field (A) e.g. ADD A Add contents of cell A to accumulator Look in memory at address A for operand Single memory reference to access data Limited address space Instruction Opcode Address A Memory Operand

Indirect Addressing Memory cell pointed to by address field contains the address of (pointer to) the operand e.g. ADD (A) Add contents of cell pointed to by contents of A to accumulator Instruction Opcode Address A Memory Pointer to operand Operand

Register Addressing Operand is held in register named in address filed EA = R Limited number of registers Opcode Instruction Register Address R Registers Operand

Register Indirect Addressing Operand is in memory cell pointed to by contents of register R Opcode Instruction Register Address R Memory Registers Pointer to Operand Operand

Displacement Addressing EA = A + (R) Address field hold two values A = base value R = register that holds displacement Opcode Register R Instruction Address A Memory Registers Pointer to Operand + Operand

Stack Addressing Operand is (implicitly) on top of stack e.g. ADD Pop top two items from stack and add

Instruc1on Formats Layout of bits in an instruc1on Includes opcode Includes (implicit or explicit) operand(s) Usually more than one instruc1on format in an instruc1on set

Instruc1on Length Affected by and affects: Memory size Memory organiza1on Bus structure CPU complexity CPU speed

Alloca1on of Bits Number of addressing modes Number of operands Register versus memory Number of register sets Address range Address granularity

Example: PDP-10 Instruc1on Format

Example: PDP-11 Instruc1on Format

Instruc1on Cycle Fetch: Read the next instruc1on from memory into the processor. Execute: Interpret the opcode and perform the indicated opera1on. Interrupt: If interrupts are enabled and an interrupt has occurred, save the current process state and service the interrupt.

Instruc1on Cycle with Interrupts

Instruc1on Cycle (with Interrupts) - State Diagram

Indirect Cycle The main line of ac1vity consists of alterna1ng instruc1on fetch and instruc1on execu1on ac1vi1es. A]er an instruc1on is fetched, it is examined to determine if any indirect addressing is involved. If so, the required operands are fetched using indirect addressing. Following execu1on, an interrupt may be processed before the next instruc1on fetch.

Instruc1on Cycle State Diagram

Data Flow (Instruc1on Fetch) 1 7 PC incremented by1 PC Contains address of the next instruction 4 Control Unit requests Memory read 2 Address moved to MAR 3 Address 5 Result 6 Result copied

Data Flow (Indirect Cycle) IR is examined If indirect addressing, indirect cycle is performed: 1 Rightmost N bits of MBR which contain the address reference are transferred to MAR 2 Control Unit requests Memory read 3 Result (address of operand) moved to MBR

Data Flow (Execute) May take many forms Depends on instruc1on being executed May include Memory read/write Input/Output Register transfers ALU opera1ons

Data Flow (Interrupt Cycle) The current contents of the PC must be saved so that the processor can resume normal ac1vity a]er the interrupt. Thus, the contents of the PC are transferred to the MBR to be wri`en into memory. The special memory loca1on reserved for this purpose is loaded into the MAR from the control unit. The PC is loaded with the address of the interrupt rou1ne. As a result, the next instruc1on cycle will begin by fetching the appropriate instruc1on.

Processor Organiza1on CPU must: Fetch instruc=on: The processor reads an instruc1on from memory (register, cache, main memory). Interpret instruc=on: The instruc1on is decoded to determine what ac1on is required. Fetch data: The execu1on of an instruc1on may require reading data from memory or an I/O module. Process data: The execu1on of an instruc1on may require performing some arithme1c or logical opera1on on data. Write data: The results of an execu1on may require wri1ng data to memory or an I/O module.

CPU With Systems Bus

CPU Internal Structure

Register Organiza1on User-visible registers: Enable the machine- or assembly language programmer to minimize main memory references by op1mizing use of registers. Control and status registers: Used by the control unit to control the opera1on of the processor and by privileged, opera1ng system programs to control the execu1on of programs.

User Visible Registers General Purpose Registers: May be used for data or addressing Data registers: Used only to hold data Address registers: Devoted to a par1cular addressing mode. Examples- Index registers, Stack pointer Condi=on codes: Bits set by the processor hardware as the result of opera1ons. For example, an arithme1c opera1on may produce a posi1ve, nega1ve, zero, or overflow result. In addi1on to the result itself being stored in a register or memory, a condi1on code is also set. The code may subsequently be tested as part of a condi1onal branch opera1on. Can be read (implicitly) by programs e.g. Jump if zero

Control & Status Registers Program counter (PC): Contains the address of an instruc1on to be fetched Instruc=on register (IR): Contains the instruc1on most recently fetched Memory address register (MAR): Contains the address of a loca1on in memory Memory buffer register (MBR): Contains a word of data to be wri`en to memory or the word most recently read

Program Status Word Sign: Contains the sign bit of the result of the last arithme1c opera1on. Zero: Set when the result is 0. Carry: Set if an opera1on resulted in a carry (addi1on) into or borrow (subtrac1on) out of a high-order bit. Used for mul1word arithme1c opera1ons. Equal: Set if a logical compare result is equality. Overflow: Used to indicate arithme1c overflow. Interrupt Enable/Disable: Used to enable or disable interrupts. Supervisor: Indicates whether the processor is execu1ng in supervisor or user mode. Certain privileged instruc1ons can be executed only in supervisor mode, and certain areas of memory can be accessed only in supervisor mode.

Example Register Organiza1ons

Pipeline Processor Pipelining: A means of introducing parallelism into the essen1ally sequen1al nature of a machine instruc1on program. Example: Instruc1on Pipelining A processor which works on the property of parallelism is known as pipeline processor.

Pipelining Two stages: fetch instruc1on and execute instruc1on. The first stage fetches an instruc1on and buffers it. When the second stage is free, the first stage passes it the buffered instruc1on. While the second stage is execu1ng the instruc1on, the first stage takes advantage of any unused memory cycles to fetch and buffer the next instruc1on. This is called instruc(on prefetch or fetch overlap. Advantage: This process will speed up instruc1on execu1on. If the fetch and execute stages were of equal dura1on, the instruc1on cycle 1me would be halved.

Pipelining Disadvantage: 1. The execu1on 1me will generally be longer than the fetch 1me. Execu1on will involve reading and storing operands and the performance of some opera1on. Thus, the fetch stage may have to wait for some 1me before it can empty its buffer. 2. A condi1onal branch instruc1on makes the address of the next instruc1on to be fetched unknown. Thus, the fetch stage must wait un1l it receives the next instruc1on address from the execute stage. The execute stage may then have to wait while the next instruc1on is fetched.

Pipelining A simple rule for the above problem: When a condi1onal branch instruc1on is passed on from the fetch to the execute stage, the fetch stage fetches the next instruc1on in memory a]er the branch instruc1on. Then, if the branch is not taken, no 1me is lost. If the branch is taken, the fetched instruc1on must be discarded and a new instruc1on fetched.

Pipelining Fetch instruc=on (FI): Read the next expected instruc1on into a buffer. Decode instruc=on (DI): Determine the opcode and the operand specifiers. Calculate operands (CO): Calculate the effec1ve address of each source operand. Fetch operands (FO): Fetch each operand from memory. Execute instruc=on (EI): Perform the indicated opera1on and store the result, if any, in the specified des1na1on operand loca1on. Write operand (WO): Store the result in memory.

Timing Diagram: Instruc1on Pipeline Opera1on Six-stage pipeline can reduce the execu1on 1me for 9 instruc1ons from 54 1me units to 14 1me units. (Assump1on: All stages takes equal dura1on)

Pipelining: example (condi1onal branch) Assume that instruc1on 3 is a condi1onal branch to instruc1on 15. Un1l the instruc1on is executed, there is no way of knowing which instruc1on will come next. The pipeline, in this example, simply loads the next instruc1on in sequence (instruc1on 4) and proceeds. This is not determined un1l the end of 1me unit 7. At this point, the pipeline must be cleared of instruc1ons that are not useful. During 1me unit 8, instruc1on 15 enters the pipeline. No instruc1ons complete during 1me units 9 through 12; this is the performance penalty incurred because we could not an1cipate the branch.

The Effect of a Condi1onal Branch on Instruc1on Pipeline Opera1on

Six Stage Instruc1on Pipeline

Alterna1ve Pipeline Depic1on Fig b: The pipeline is full at 1mes 6 and 7. At 1me 7, instruc1on 3 is in the execute stage and executes a branch to instruc1on 15. At this point, instruc1ons I4 through I7 are flushed from the pipeline, so that at 1me 8, only two instruc1ons are in the pipeline, I3 and I15.

Speedup Factors with Instruc1on Pipelining

Pipeline Hazards A pipeline hazard occurs when the pipeline, or some por1on of the pipeline, must stall because condi1ons do not permit con1nued execu1on. Such a pipeline stall is also referred to as a pipeline bubble. There are three types of hazards: Resource Hazards Data Hazards Control Hazards

Resource Hazard A resource hazard occurs when two (or more) instruc1ons that are already in the pipeline need the same resource. The result is that the instruc1ons must be executed in serial rather than parallel for a por1on of the pipeline.

Resource Hazard: Example Now assume that main memory has a single port. In this case, an operand read to or write from memory cannot be performed in parallel with an instruction fetch. Assume that the source operand for instruc1on I1 is in memory, rather than a register. Therefore, the fetch instruc1on stage of the pipeline must idle for one cycle before beginning the instruc1on fetch for instruc1on I3. Assume that all other operands are in registers.

Data Hazard A data hazard occurs when there is a conflict in the access of an operand loca1on. In general terms, we can state the hazard in this form: Two instruc1ons in a program are to be executed in sequence and both access a par1cular memory or register operand. If the two instruc1ons are executed in strict sequence, no problem occurs. However, if the instruc1ons are executed in a pipeline, then it is possible for the operand value to be updated in such a way as to produce a different result than would occur with strict sequen1al execu1on. In other words, the program produces an incorrect result because of the use of pipelining.

Data Hazard: Example As an example, consider the following x86 machine instruc1on sequence: ADD EAX, EBX /* EAX = EAX + EBX SUB ECX, EAX /* ECX = ECX - EAX The ADD instruc1on does not update register EAX un1l the end of stage 5, which occurs at clock cycle 5. But the SUB instruc1on needs that value at the beginning of its stage 2, which occurs at clock cycle 4. To maintain correct opera1on, the pipeline must stall for two clocks cycles. Thus, a data hazard results in inefficient pipeline usage.

Data Hazard: Types WAR WAW

Data Hazard: Types

Control Hazards A control hazard, also known as a branch hazard, occurs when the pipeline makes the wrong decision on a branch predic1on and therefore brings instruc1ons into the pipeline that must subsequently be discarded.

Co-Processors A coprocessor is a computer processor used to supplement the func1ons of the primary processor (the CPU). Opera1ons performed by the coprocessor may be floa1ng point arithme1c, graphics, signal processing, string processing, encryp1on or I/O Interfacing with peripheral devices.