CHAPTER 8: Central Processing Unit (CPU)

Similar documents
COMPUTER ARCHITECTURE AND PARALEL PROCESSING STUDY NOTES

Computer Architecture and Organization: L09: CPU Organization

CENTRAL PROCESSING UNIT

CENTRAL PROCESSING UNIT

Fig: Computer memory with Program, data, and Stack. Blog - NEC (Autonomous) 1

STRUCTURE OF DESKTOP COMPUTERS

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

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

Computer Architecture

CPU Design John D. Carpinelli, All Rights Reserved 1

Introduction. 3 major parts of CPU : Fig Design Examples of simple CPU. In this chapter : Chap. 8. Chap. 8 Central Processing Unit

TYPES OF INTERRUPTS: -

Computer Organization and Architecture

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

Computer Architecture

PESIT Bangalore South Campus

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

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

COMPUTER HARDWARE. Instruction Set Architecture

2. ADDRESSING METHODS

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

Chapter 2 Instruction Set Architecture

COMPUTER ARCHITECTURE AND ORGANIZATION Register Transfer and Micro-operations 1. Introduction A digital system is an interconnection of digital

Digital System Design Using Verilog. - Processing Unit Design

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss

CHAPTER SIX BASIC COMPUTER ORGANIZATION AND DESIGN

Computer Organization CS 206 T Lec# 2: Instruction Sets

Programming Level A.R. Hurson Department of Computer Science Missouri University of Science & Technology Rolla, Missouri

Chapter 16. Control Unit Operation. Yonsei University

5-1 Instruction Codes

REGISTER TRANSFER LANGUAGE

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

CPU: SOFTWARE ARCHITECTURE INSTRUCTION SET (PART

Microcomputer Architecture and Programming

COMPUTER ORGANIZATION

CHAPTER 5 Basic Organization and Design Outline Instruction Codes Computer Registers Computer Instructions Timing and Control Instruction Cycle

Processing Unit CS206T

PROGRAM CONTROL UNIT (PCU)

C.P.U Organization. Memory Unit. Central Processing Unit (C.P.U) Input-Output Processor (IOP) Figure (1) Digital Computer Block Diagram

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

Blog -

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

TYPICAL QUESTIONS & ANSWERS

Computer Architecture and Organization: L04: Micro-operations

CPE 323 MSP430 INSTRUCTION SET ARCHITECTURE (ISA)

THE MICROPROCESSOR Von Neumann s Architecture Model

csitnepal Unit 3 Basic Computer Organization and Design

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

Computer Organization and Technology Processor and System Structures

Chapter 3 : Control Unit

Basic Computer Organization - Designing your first computer. Acknowledgment: Most of the slides are adapted from Prof. Hyunsoo Yoon s slides.

COMPUTER ORGANIZATION & ARCHITECTURE

Computer Organization II CMSC 3833 Lecture 33

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

Chapter 3 Machine Instructions & Programs. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

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

BASIC COMPUTER ORGANIZATION AND DESIGN

Computer Organization and Design

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

Instruction Sets: Characteristics and Functions Addressing Modes

Expectations. Why learn Assembly Language? Administrative Issues. Assignments. CSC 3210 Computer Organization and Programming

William Stallings Computer Organization and Architecture

10-1 C D Pearson Education, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

REGISTER TRANSFER AND MICROOPERATIONS

Infix to Postfix Conversion

COA. Prepared By: Dhaval R. Patel Page 1. Q.1 Define MBR.

SECTION 5 PROGRAM CONTROL UNIT

CSC 220: Computer Organization Unit 12 CPU programming

CHAPTER 4: Register Transfer Language and Microoperations

Computer Architecture Programming the Basic Computer

Problem with Scanning an Infix Expression

Stack Applications. Lecture 27 Sections Robb T. Koether. Hampden-Sydney College. Wed, Mar 29, 2017

CPU Structure and Function

MICROPROGRAMMED CONTROL

BASIC COMPUTER ORGANIZATION AND DESIGN

Register Transfer and Micro-operations

Blog -

Chapter 9. Programming Framework

We briefly explain an instruction cycle now, before proceeding with the details of addressing modes.

Computer Architecture and Organization: L06: Instruction Cycle

ASSEMBLY LANGUAGE MACHINE ORGANIZATION

BASIC COMPUTER ORGANIZATION AND DESIGN

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

UNIT-III REGISTER TRANSFER LANGUAGE AND DESIGN OF CONTROL UNIT

UNIT:2 BASIC COMPUTER ORGANIZATION AND DESIGN

Assembly Language Programming of 8085


2 MARKS Q&A 1 KNREDDY UNIT-I

icroprocessor istory of Microprocessor ntel 8086:

Code segment Stack segment

REGISTER TRANSFER AND MICROOPERATIONS

Lesson 2. Instruction set design

Computer Organization (Autonomous)

COMPUTER ORGANIZATION AND ARCHITECTURE

Understand the factors involved in instruction set

Basic Computer Organization and Design Part 2/3

Introduction to Microprocessor

Note that none of the above MAY be a VALID ANSWER.

MICROPROCESSOR PROGRAMMING AND SYSTEM DESIGN

For Example: P: LOAD 5 R0. The command given here is used to load a data 5 to the register R0.

Transcription:

CS 224: Computer Organization S.KHABET CHAPTER 8: Central Processing Unit (CPU) Outline Introduction General Register Organization Stack Organization Instruction Formats Addressing Modes 1

Major Components of CPU Storage Components Registers Flags Execution (Processing) Components Arithmetic Logic Unit (ALU) Transfer Components Bus Control Components Control Unit Registers Flags ALU Control Unit 2

Registers In Basic Computer, there is only one general purpose register, the Accumulator (AC) In modern CPUs, there are many general purpose registers It is advantageous to have many registers Transfer between registers within the processor are relatively fast Going off the processor to access memory is much slower How many registers will be the best? 3

General Register Organization Clock Input R1 R2 R3 R4 R5 R6 R7 Load (7 lines) SELA { MUX MUX } SELB 3 x 8 decoder A bus B bus SELD OPR ALU Output 4

Operation of Control Unit The control unit Directs the information flow through ALU by Selecting various Components in the system Selecting the Function of ALU Example: R1 R2 + R3 [1] MUX A selector (SELA): BUS A R2 [2] MUX B selector (SELB): BUS B R3 [3] ALU operation selector (OPR): ALU to ADD [4] Decoder destination selector (SELD): R1 Out Bus Control Word 3 3 3 5 SELA SELB SELD OPR 5

Operation of Control Unit Encoding of register selection fields Binary Code SELA SELB SELD 000 Input Input None 001 R1 R1 R1 010 R2 R2 R2 011 R3 R3 R3 100 R4 R4 R4 101 R5 R5 R5 110 R6 R6 R6 111 R7 R7 R7 6

ALU Control (1) Encoding of ALU Microoperations OPR Select Operation Symbol 00000 Transfer A TSFA 00001 Increment A INCA 00010 ADD A + B ADD 00101 Subtract A - B SUB 00110 Decrement A DECA 01000 AND A and B AND 01010 OR A and B OR 01100 XOR A and B XOR 01110 Complement A COMA 10000 Shift right A SHRA 11000 Shift left A SHLA 7

ALU Control (2) Examples of ALU Microoperations Symbolic Designation Microoperation SELA SELB SELD OPR Control Word R1 R2 R3 R2 R3 R1 SUB 010 011 001 00101 R4 R4 R5 R4 R5 R4 OR 100 101 100 01010 R6 R6 + 1 R6 - R6 INCA 110 000 110 00001 R7 R1 R1 - R7 TSFA 001 000 111 00000 Output R2 R2 - None TSFA 010 000 000 00000 Output Input Input - None TSFA 000 000 000 00000 R4 Shl R4 R4 - R4 SHLA 100 000 100 11000 R5 0 R5 R5 R5 XOR 101 101 101 01100 8

Register Stack Organization (1) Stack Is a memory unit with an address register Very useful feature for nested subroutines, nested interrupt services Also efficient for arithmetic expression evaluation Storage which can be accessed in LIFO Stack Pointer: SP SP holds the address of the word that is currently on the top Only PUSH and POP operations are applicable Register Stack Stack can be a portion of large memory Or a collection of finite number of memory words or registers 9

Register Stack Organization (2) Push, Pop operations The first word is stored in address 1 and the last one in address 0. /* Initially, SP = 0, EMPTY = 1, FULL = 0 */ PUSH SP SP + 1 M[SP] DR If (SP = 0) then (FULL 1) EMPTY 0 POP DR M[SP] SP SP 1 If (SP = 0) then (EMPTY 1) FULL 0 Flags FULL EMPTY Stack pointer SP 6 bits stack C B A DR Address 63 4 3 2 1 0 10

Register Stack Organization (3) A stack can exist as a stand alone unit as in the preceding slide It can be also implemented in a random access memory attached to a CPU Use one of the processor registers as SP 11

Memory Stack Organization Memory with Program, Data, and Stack Segments PC Program (instructions) 1000 - A portion of memory is used as a stack with a processor register as a stack pointer - First word is stored at 4000 and last word at 4001 - PUSH: SP SP 1 - POP: DR M[SP] M[SP] DR SP SP + 1 AR SP Data (operands) stack 3000 3997 3998 3999 4000 4001 Stack grows In this direction - Stack limits Most computers do not provide hardware to check stack overflow (full stack) or underflow (empty stack) must be done in software One register can be used to hold the upper limit and the other to hold the lower limit A comparison is done between SP and one of these registers after each POP or PUSH 12

Reverse Polish Notation Arithmetic Expressions: A + B A + B Infix notation + A B Prefix or Polish notation A B + Postfix or reverse Polish notation Note: The reverse Polish notation is very suitable for stack manipulation Evaluation of Arithmetic Expressions Any arithmetic expression can be expressed in parenthesis-free Polish notation, including reverse Polish notation (3 * 4) + (5 * 6) 3 4 * 5 6 * + 6 4 5 5 30 3 3 12 12 12 12 42 3 4 * 5 6 * + 13

Processor Organization In general, most processors are organized in one of 3 ways: Single register (Accumulator) organization Basic Computer is a good example Accumulator is the only general purpose register General register organization Used by most modern computer processors Any of the registers can be used as the source or destination for computer operations Stack organization All operations are done using the hardware stack For example, an OR instruction will pop the two top elements from the stack, do a logical OR on them, and push the result on the stack 14

Instruction Format (1) Instruction Fields OP-Code field specifies the operation to be performed Address field designates memory address(es) or a processor register(s) Mode field determines how the address field is to be interpreted (to get effective address or the operand) The number of address fields in the instruction format depends on the internal organization of CPU 15

Instruction Format (2) The three most common CPU organizations: Single accumulator organization: ADD X /* AC AC + M[X] */ General register organization: ADD R1, R2, R3 /* R1 R2 + R3 */ ADD R1, R2 /* R1 R1 + R2 */ MOV R1, R2 /* R1 R2 */ ADD R1, X /* R1 R1 + M[X] */ Stack organization: PUSH X /* TOS M[X] */ ADD 16

Three Address Instructions Three-Address Instructions Program to evaluate X = (A + B) * (C + D) : ADD R1, A, B /* R1 M[A] + M[B] */ ADD R2, C, D /* R2 M[C] + M[D] */ MUL X, R1, R2 /* M[X] R1 * R2 */ The 3 addresses may be register or memory addresses (1 register and 2 memory or 2 registers and 1 memory which is more used) Results in short programs Instruction becomes long (many bits) because it consists of many address fields 17

Two Address Instructions Two-Address Instructions Program to evaluate X = (A + B) * (C + D) : MOV R1, A /* R1 M[A] */ ADD R1, B /* R1 R1 + M[A] */ MOV R2, C /* R2 M[C] */ ADD R2, D /* R2 R2 + M[D] */ MUL R1, R2 /* R1 R1 * R2 */ MOV X, R1 /* M[X] R1 */ 18

One Address Instructions One-Address Instructions Use an implied AC register for all data manipulation Program to evaluate X = (A + B) * (C + D) : LOAD A /* AC M[A] */ ADD B /* AC AC + M[B] */ STORE T /* M[T] AC */ LOAD C /* AC M[C] */ ADD D /* AC AC + M[D] */ MUL T /* AC AC * M[T] */ STORE X /* M[X] AC */ 19

Zero Address Instructions Zero-Address Instructions Can be found in a stack-organized computer ( TOS stands to Top Of Stack) Program to evaluate X = (A + B) * (C + D) : PUSH A / * TOS A */ PUSH B / * TOS B */ ADD PUSH C / * TOS (A + B */ / * TOS C */ PUSH D ADD / * / * TOS D */ TOS (C + D) */ MUL / * TOS (C + D) * (A + B) */ POP X / * M[X] TOS */ 20

Addressing Modes Addressing Modes Specifies a rule for interpreting or modifying the address field of the instruction (before the operand is actually referenced) Variety of addressing modes to give programming flexibility to the user (use of pointer, indexing, counters) to use the bits in the address field of the instruction efficiently Give the programmer the flexibility of writing programs that are more efficient with respect the execution time and of the number of instructions 21

Types of Addressing Modes (1) Implied Mode Address of the operands are specified implicitly in the definition of the instruction No need to specify address in the instruction EA = AC, or EA = Stack [SP] Examples from Basic Computer CLA, CME, INP Immediate Mode Instead of specifying the address of the operand, operand itself is specified No need to specify address in the instruction However, operand itself needs to be specified Sometimes, require more bits than the address 22

Types of Addressing Modes (2) Register Mode Address specified in the instruction is the register address Designated operand need to be in a register Shorter address than the memory address Saving address field in the instruction Faster to acquire an operand than the memory addressing EA = IR(R) (IR(R): Register field of IR) 23

Types of Addressing Modes (3) Register Indirect Mode Instruction specifies a register which contains the memory address of the operand Saving instruction bits since register address is shorter than the memory address Slower to acquire an operand than both the register addressing or memory addressing EA = [IR(R)] ([x]: Content of x) Autoincrement or Autodecrement Mode When the address in the register is used to access memory, the value in the register is incremented or decremented by 1 automatically Used to access tables in the memory 24

Types of Addressing Modes (4) Direct Address Mode Instruction specifies the memory address which can be used directly to access the memory Faster than the other memory addressing modes Too many bits are needed to specify the address for a large physical memory space EA = IR(addr) (IR(addr): address field of IR) 25

Types of Addressing Modes (5) Indirect Addressing Mode The address field of an instruction specifies the address of a memory location that contains the address of the operand When the abbreviated address is used large physical memory can be addressed with a relatively small number of bits Slow to acquire an operand because of an additional memory access EA = M [IR(address)] 26

Types of Addressing Modes (6) Relative Addressing Modes The Address fields of an instruction specifies the part of the address which can be used along with a designated register to calculate the address of the operand Address field of the instruction is short Large physical memory can be accessed with a small number of address bits EA = IR(address)+R, R is a register 27

Types of addressing Modes (7) 3 different Relative Addressing Modes depending on R; PC Relative Addressing Mode (R = PC) EA = PC + IR(address) Content of PC is a signed number Used for branch instruction Shorter address field Indexed Addressing Mode (R = IX, where IX: Index Register) EA = IX + IR(address) Used to access arrays Sometimes a register is dedicated to be the index register and sometimes one register should be specified in the instruction itself Base Register Addressing Mode (R = BAR, where BAR: Base Address Register) EA = BAR + IR(address) The base register contains a base address 28

Addressing Modes - Examples Autoincrement mode ( R1)+ after the execution of the instruction Autodecrement mode ( R1) prior to the execution of the instruction Addressing Effective Content Mode Address of AC Direct address 500 /* AC (500) */ 800 Immediate operand - /* AC 500 */ 500 Indirect address 800 /* AC ((500)) */ 300 Relative address 702 /* AC (PC+500) */ 325 Indexed address 600 /* AC (XR+500) */ 900 Register - /* AC R1 */ 400 Register indirect 400 /* AC (R1) */ 700 Autoincrement 400 /* AC (R1)+ */ 700 Autodecrement 399 /* AC -(R1) */ 450 PC = 200 R1 = 400 XR = 100 AC Address 200 201 202 399 400 Memory Load to AC Mode Address = 500 Next instruction 450 700 500 800 600 900 702 325 800 300 29