Central Processing Unit.

Slides:



Advertisements
Similar presentations
Chapter 8: Central Processing Unit
Advertisements

Eng. Mohammed Timraz Electronics & Communication Engineer University of Palestine Faculty of Engineering and Urban planning Software Engineering Department.
Major components of CPU
ARITHMETIC LOGIC SHIFT UNIT
Lecture 18 Last Lecture Today’s Topic Instruction formats
Machine Instruction Characteristics
8.3 Stack Organization Stack: A storage device that stores information in such a manner that the item stored last is the first item retrieved. Also called.
Instruction Set Architecture
Chap. 8 Central Processing Unit
CONTROL UNIT OPERATION MICROPROGRAMMED CONTROL. 2.
Exam2 Review Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
Chap 7. Register Transfers and Datapaths. 7.1 Datapaths and Operations Two types of modules of digital systems –Datapath perform data-processing operations.
1 Purpose of This Chapter In this chapter we introduce a basic computer and show how its operation can be specified with register transfer statements.
Instruction.
CPU performs the bulk of data processing operations CPU performs the bulk of data processing operations The CPU is made up of three parts. They are Control.
CH-8 CENTRAL PROCESSING UNIT -BY ESHA S. SHAH 1.  CENTRAL PROCESSING UNIT Introduction General Register Organization Stack Organization Instruction Formats.
Computer Architecture. Instruction Set “The collection of different instructions that the processor can execute it”. Usually represented by assembly codes,
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Logic and Computer Design Fundamentals
Chapter 2. Machine Instructions and Programs
Displacement (Indexed) Stack
CENTRAL PROCESSING UNIT
CENTRAL PROCESSING UNIT
Control Unit Lecture 6.
Chapter 4 Register Transfer and Microoperations
Classification of Instruction Set of 8051
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
SUBJECT:COMPUTER ORGANISATION SUBJECT CODE: B.E. 4th SEMESTER
Chap 7. Register Transfers and Datapaths
Lecture Set 5 The 8051 Instruction Set.
Cpe 252: Computer Organization1 Dr. Lo’ai Tawalbeh Chapter 7: Microprogrammed Control.
Computer Organization and Design
REGISTER TRANSFER LANGUAGE
Computer Organization and Design
BASIC COMPUTER ORGANIZATION AND DESIGN
Assembly Language Programming Part 2
William Stallings Computer Organization and Architecture 8th Edition
Overview Control Memory Comparison of Implementations
Overview Introduction General Register Organization Stack Organization
Overview Introduction General Register Organization Stack Organization
Computer Organization and Design
MICROPROGRAMMED CONTROL
INDEX UNIT-III PPT SLIDES
CENTRAL PROCESSING UNIT
BASIC COMPUTER ORGANIZATION AND DESIGN
Falcon-E : Introduction
BIC 10503: COMPUTER ARCHITECTURE
Prepared By:- Parminder Mann
Central Processing Unit
Computer Organization and Design
Chapter 1. Basic Structure of Computers
CENTRAL PROCESSING UNIT
CENTRAL PROCESSING UNIT
Chapter 8 Central Processing Unit
Chapter 1. Basic Structure of Computers
CENTRAL PROCESSING UNIT
MICROPROGRAMMED CONTROL
CENTRAL PROCESSING UNIT
CENTRAL PROCESSING UNIT
By: A. H. Abdul Hafez Computer Architecture and Organization: L06: Stored program and Instruction code.
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
MICROPROGRAMMED CONTROL
MICROPROGRAMMED CONTROL
INSTRUCTION SET ARCHITECTURE
COMPUTER ORGANIZATION AND ARCHITECTURE
Prepared By:- Bhim Singh
Computer Operation 6/22/2019.
UNIT – III Microprogrammed Control
Presentation transcript:

Central Processing Unit

CPU CU Register File ALU

General Register Organization Input R1 R2 R3 R4 R5 R6 R7 MUX MUX LD SELA SELB 3 x 8 Decoder A B OPR ALU SELD

General Register Organization OPR Operation 00000 Transfer A 00001 Increment A 00010 Add A + B 00101 Subtract A − B 00110 Decrement A 01000 AND A and B 01010 OR A and B 01100 XOR A and B 01110 Complement A 10000 Shift right A 11000 Shift left A R1 R2 R3 R4 R5 R6 R7 MUX ALU 3 x 8 Decoder LD SELD SELA SELB OPR Input A B Examples: Microoperation SELA SELB SELD OPR R1 ← R2 − R3 010 011 001 00101 R4 ← SHL R4 100 000 11000

Current Top of Stack TOS Stack Organization LIFO Last In First Out 1 2 3 4 7 8 9 10 5 6 Stack DR Current Top of Stack TOS SP 0 1 2 3 0 0 5 5 FULL EMPTY 0 0 0 8 0 0 2 5 Stack Bottom 0 0 1 5

Current Top of Stack TOS Current Top of Stack TOS Stack Organization PUSH SP ← SP – 1 M[SP] ← DR If (SP = 0) then (FULL ← 1) EMPTY ← 0 1 2 3 4 7 8 9 10 5 6 Stack DR Current Top of Stack TOS Current Top of Stack TOS 1 6 9 0 1 6 9 0 SP 0 1 2 3 0 0 5 5 FULL EMPTY 0 0 0 8 0 0 2 5 Stack Bottom 0 0 1 5

Current Top of Stack TOS Current Top of Stack TOS Stack Organization POP DR ← M[SP] SP ← SP + 1 If (SP = 11) then (EMPTY ← 1) FULL ← 0 1 2 3 4 7 8 9 10 5 6 Stack DR Current Top of Stack TOS Current Top of Stack TOS 1 6 9 0 1 6 9 0 SP 0 1 2 3 0 0 5 5 FULL EMPTY 0 0 0 8 0 0 2 5 Stack Bottom 0 0 1 5

Memory Program Data Stack Stack Organization Memory Stack PUSH SP ← SP – 1 M[SP] ← DR POP DR ← M[SP] SP ← SP + 1 Memory PC 1 Program 2 AR 100 101 Data 102 200 SP 201 Stack 202

Reverse Polish Notation Infix Notation A + B Prefix or Polish Notation + A B Postfix or Reverse Polish Notation (RPN) A B + (2) (4)  (3) (3)  + (8) (3) (3)  + (8) (9) + 17 RPN A  B + C  D A B  C D  +

Reverse Polish Notation Example (A + B)  [C  (D + E) + F] (A B +) (D E +) C  F + 

Reverse Polish Notation Stack Operation (3) (4)  (5) (6)  + PUSH 3 PUSH 4 MULT PUSH 5 PUSH 6 ADD 6 5 30 4 42 3 12

CPU Organization Single Accumulator General Register Stack Result usually goes to the Accumulator Accumulator has to be saved to memory quite often General Register Registers hold operands thus reduce memory traffic Register bookkeeping Stack Operands and result are always in the stack

Operand(s) or Address(es) Instruction Formats Three-Address Instructions ADD R1, R2, R3 R1 ← R2 + R3 Two-Address Instructions ADD R1, R2 R1 ← R1 + R2 One-Address Instructions ADD M AC ← AC + M[AR] Zero-Address Instructions ADD TOS ← TOS + (TOS – 1) RISC Instructions Lots of registers. Memory is restricted to Load & Store Instruction Opcode Operand(s) or Address(es)

Example: Evaluate (A+B)  (C+D) Three-Address Instruction Formats Example: Evaluate (A+B)  (C+D) Three-Address 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

Example: Evaluate (A+B)  (C+D) Two-Address Instruction Formats Example: Evaluate (A+B)  (C+D) Two-Address MOV R1, A ; R1 ← M[A] ADD R1, B ; R1 ← R1 + M[B] 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

Example: Evaluate (A+B)  (C+D) One-Address Instruction Formats Example: Evaluate (A+B)  (C+D) One-Address 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

Example: Evaluate (A+B)  (C+D) Zero-Address Instruction Formats Example: Evaluate (A+B)  (C+D) Zero-Address PUSH A ; TOS ← A PUSH B ; TOS ← B ADD ; TOS ← (A + B) PUSH C ; TOS ← C PUSH D ; TOS ← D ADD ; TOS ← (C + D) MUL ; TOS ← (C+D)(A+B) POP X ; M[X] ← TOS

Example: Evaluate (A+B)  (C+D) RISC Instruction Formats Example: Evaluate (A+B)  (C+D) RISC LOAD R1, A ; R1 ← M[A] LOAD R2, B ; R2 ← M[B] LOAD R3, C ; R3 ← M[C] LOAD R4, D ; R4 ← M[D] ADD R1, R1, R2 ; R1 ← R1 + R2 ADD R3, R3, R4 ; R3 ← R3 + R4 MUL R1, R1, R3 ; R1 ← R1  R3 STORE X, R1 ; M[X] ← R1

Instruction Addressing Modes Implied Immediate Register AC is implied in “ADD M[AR]” in “One-Address” instr. TOS is implied in “ADD” in “Zero-Address” instr. Immediate The use of a constant in “MOV R1, 5”, i.e. R1 ← 5 Register Indicate which register holds the operand Instruction Opcode Mode ...

Autoincrement / Autodecrement Addressing Modes Register Indirect Indicate the register that holds the number of the register that holds the operand MOV R1, (R2) Autoincrement / Autodecrement Access & update in 1 instr. Direct Address Use the given address to access a memory location R1 R2 = 3 R3 = 5

Memory Addressing Modes Indirect Address Indicate the memory location that holds the address of the memory location that holds the data 100 101 102 103 104 Memory AR = 101 0 1 0 4 1 1 0 A

Could be Positive or Negative (2’s Complement) Addressing Modes Relative Address EA = PC + Relative Addr 100 101 102 103 104 Memory 1 2 Program PC = 2 + AR = 100 Data 1 1 0 A Could be Positive or Negative (2’s Complement)

Memory Addressing Modes Indexed EA = Index Register + Relative Addr 100 101 102 103 104 Memory Useful with “Autoincrement” or “Autodecrement” XR = 2 + AR = 100 Could be Positive or Negative (2’s Complement) 1 1 0 A

Memory Addressing Modes Base Register EA = Base Register + Relative Addr 100 101 102 103 104 Memory Could be Positive or Negative (2’s Complement) AR = 2 + 0 0 0 5 BR = 100 0 0 1 2 0 0 0 A Usually points to the beginning of an array 0 1 0 7 0 0 5 9

Numerical Example of Addressing modes

Data value is not modified Types of Instructions Data Transfer Instructions Data Manipulation Instructions Program Control Instructions Name Mnemonic Load LD Store ST Move MOV Exchange XCH Input IN Output OUT Push PUSH Pop POP Data value is not modified

Data Transfer Instructions Mode Assembly Register Transfer Direct address LD ADR AC ← M[ADR] Indirect address LD @ADR AC ← M[M[ADR]] Relative address LD $ADR AC ← M[PC+ADR] Immediate operand LD #NBR AC ← NBR Index addressing LD ADR(X) AC ← M[ADR+XR] Register LD R1 AC ← R1 Register indirect LD (R1) AC ← M[R1] Autoincrement LD (R1)+ AC ← M[R1], R1 ← R1+1

Data Manipulation Instructions Arithmetic Logical & Bit Manipulation Shift Name Mnemonic Increment INC Decrement DEC Add ADD Subtract SUB Multiply MUL Divide DIV Add with carry ADDC Subtract with borrow SUBB Negate NEG Name Mnemonic Clear CLR Complement COM AND OR Exclusive-OR XOR Clear carry CLRC Set carry SETC Complement carry COMC Enable interrupt EI Disable interrupt DI Name Mnemonic Logical shift right SHR Logical shift left SHL Arithmetic shift right SHRA Arithmetic shift left SHLA Rotate right ROR Rotate left ROL Rotate right through carry RORC Rotate left through carry ROLC

Program Control Instructions Name Mnemonic Branch BR Jump JMP Skip SKP Call CALL Return RET Compare (Subtract) CMP Test (AND) TST Subtract A – B but don’t store the result 1 1 Mask

Status Bits ALU Cn-1 A B Cn F V Z S C Fn-1 Zero Check

Conditional Branch Instructions Mnemonic Branch Condition Tested Condition BZ Branch if zero Z = 1 BNZ Branch if not zero Z = 0 BC Branch if carry C = 1 BNC Branch if no carry C = 0 BP Branch if plus S = 0 BM Branch if minus S = 1 BV Branch if overflow V = 1 BNV Branch if no overflow V = 0

Conditional Branch Instructions Example: A: 1 1 1 1 0 0 0 0 B: 0 0 0 1 0 1 0 0 A: 1 1 1 1 0 0 0 0 +(−B): 1 1 1 0 1 1 0 0 1 1 0 1 1 1 0 0 C = 1 Z = 0 S = 1 V = 0

Program Interrupts Save: PC Registers Status Bits Main Program • 10 CMA 11 • 12 STA [201] Interrupt ISR • Load AC RET Program Status Word PSW

Types of Interrupts External Interrupts Internal Interrupts Keyboard, Mouse … etc Internal Interrupts Timers, Divide-By-Zero … etc Software Interrupts Main Program • 10 INT 11 • ISR • RET

Complex Instruction Set Computer CISC Complex Instruction Set Computer Large number of instructions with a complicated ALU Some instructions perform specialized tasks and are used infrequently Large variety of addressing modes Variable length instruction formats Instructions can manipulate operands in memory

Reduced Instruction Set Computer RISC Reduced Instruction Set Computer Relatively few instructions, hence simple ALU Relatively few addressing modes Memory access limited to “load” and “store” All operations done within “registers” of the CPU Fixed-length and easily decoded instruction format Single-cycle instruction execution Hardwired control unit

Homework Chapter 8 8-1 8-3 8-7 8-8 8-9 8-11 8-13 8-14 8-15 8-16 8-17 8-18 8-32

Homework Mano 8-1 A bus-organized CPU has 16 registers with 32 bits in each, an ALU, and a destination decoder. a. How many multiplexers are there in the A bus, and what is the size of each multiplexer? b. How many selection inputs are needed for MUX A and MUX B? c. How many inputs and outputs are there in the decoder? d. How many inputs and outputs are there in the ALU for data, including input and output carries? e. Formulate a control word for the system assuming that the ALU has 35 operations.

Homework 8-3 Specify the control word that must be applied to the processor of Fig. 8-2 to implement the following microoperations. a. R1 ← R2 + R3 b. R4 ← R4 c. R5 ← R5 – 1 d. R6 ← shl R1 e. R7 ← input

Homework 8-7 Convert the following arithmetic expressions from infix to reverse Polish notation. a. A  B + C  D + E  F b. A  B + A  (B  D + C  E) c. A + B  [C  D + E  (F + G)] A * [B + C  (D + E)] d. ───────────── F  (G + H)

Homework 8-5 Convert the following arithmetic expressions from reverse Polish notation to infix notation. a. A B C D E +  − / b. A B C D E  / − + c. A B C  / D − E F / + d. A B C D E F G +  +  +  8-9 Convert the following numerical arithmetic expression into reverse Polish notation and show the stack operations for evaluating the numerical result. (3 + 4) [10 (2 + 6) + 8]

Homework 8-11 A computer has 32-bit instructions and 12-bit addresses. If there are 250 two-address instructions, how many one-address instructions can be formulated? 8-13 The memory unit of a computer has 256K words of 32 bits each. The computer has an instruction format with four fields: an operation code field, a mode field to specify one of seven addressing modes, a register address field to specify one of 60 processor registers, and a memory address. Specify the instruction format and the number of bits in each field if the instruction is in one memory word.

Homework 8-14 A two-word instruction is stored in memory at an address designated by the symbol W. The address field of the instruction (stored at W + 1) is designated by the symbol Y. The operand used during the execution of the instruction is stored at an address symbolized by Z. An index register contains the value X. State how Z is calculated from the other addresses if the addressing mode of the instruction is a. direct b. indirect c. relative d. indexed

Homework 8-15 A relative mode branch type of instruction is stored in memory at an address equivalent to decimal 750. The branch is made to an address equivalent to decimal 500. a. What should be the value of the relative address field of the instruction (in decimal)? b. Determine the relative address value in binary using 12 bits. (Why must the number be in 2’s complement?) c. Determine the binary value in PC after the fetch phase and calculate the binary value of 500. Then show that the binary value in PC plus the relative address calculated in part (b) is equal to the binary value of 500.

Homework 8-16 How many times does the control unit refer to memory when it fetches and executes an indirect addressing mode instruction if the instruction is (a) a computational type requiring an operand from memory; (b) a branch type. 8-17 What must the address field of an indexed addressing mode instruction be to make it the same as a register indirect mode instruction? 8-18 An instruction is stored at location 300 with its address field at location 301. The address field has the value 400. A processor register R1 contains the number 200. Evaluate the effective address if the addressing mode of the instruction is (a) direct; (b) immediate; (c) relative; (d) register direct; (e) index with R1 as the index register.

Homework 8-32 The content of the top of a memory stack is 5320. The content of the stack pointer SP is 3560. A two-word call subroutine instruction is located in memory at address 1120 followed by the address field of 6720 at location 1121. What are the content of PC, SP, and the top of the stack: a. Before the call instruction is fetched from memory? b. After the call instruction is executed? c. After the return from subroutine?