William Stallings Computer Organization and Architecture

Similar documents
Chapter 16. Control Unit Operation. Yonsei University

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

William Stallings Computer Organization and Architecture

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

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

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

CPU Structure and Function

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

Processing Unit CS206T

Blog -

Module 5 - CPU Design

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

Digital System Design Using Verilog. - Processing Unit Design

Chapter 3 : Control Unit

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

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

CPU Structure and Function

SCRAM Introduction. Philipp Koehn. 19 February 2018

Chapter 20 - Microprogrammed Control (9 th edition)

Computer Organization II CMSC 3833 Lecture 33

UNIT- 5. Chapter 12 Processor Structure and Function

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

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

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

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

Unit II Basic Computer Organization

BASIC COMPUTER ORGANIZATION AND DESIGN

Computer Organization CS 206 T Lec# 2: Instruction Sets

William Stallings Computer Organization and Architecture

CC312: Computer Organization

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

Chapter 2 Instruction Set Architecture

Faculty of Engineering Systems & Biomedical Dept. First Year Cairo University Sheet 6 Computer I

Blog -

BASIC COMPUTER ORGANIZATION AND DESIGN


Computer Organization (Autonomous)

Chapter 12. CPU Structure and Function. Yonsei University

Department of Computer and Mathematical Sciences. Lab 4: Introduction to MARIE

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

csitnepal Unit 3 Basic Computer Organization and Design

UNIT:2 BASIC COMPUTER ORGANIZATION AND DESIGN

Micro-programmed Control Ch 15

Lecture 10: Control Unit

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

Chapter 4. MARIE: An Introduction to a Simple Computer. Chapter 4 Objectives. 4.1 Introduction. 4.2 CPU Basics

Micro-programmed Control Ch 15

MARIE: An Introduction to a Simple Computer

Lecture 10: Control Unit

CISC Processor Design

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

MARIE: An Introduction to a Simple Computer

Chapter 4. MARIE: An Introduction to a Simple Computer

5-1 Instruction Codes

Micro-programmed Control Ch 17

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

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

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

DC57 COMPUTER ORGANIZATION JUNE 2013

Computer Architecture

Computer Logic II CCE 2010

4. MICROPROGRAMMED COMPUTERS

Instruction Sets: Characteristics and Functions Addressing Modes

MICROPROGRAMMED CONTROL

Memory General R0 Registers R1 R2. Input Register 1. Input Register 2. Program Counter. Instruction Register

Chapter 14 - Processor Structure and Function

Basic Computer Organization and Design Part 2/3

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

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

COMPUTER ORGANIZATION

THE MICROPROCESSOR Von Neumann s Architecture Model

Chapter 05: Basic Processing Units Control Unit Design. Lesson 15: Microinstructions

COSC 243. Computer Architecture 1. COSC 243 (Computer Architecture) Lecture 6 - Computer Architecture 1 1

Basics of Microprocessor

UNIT V: CENTRAL PROCESSING UNIT

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

Notes: The Marie Simulator

ASSIGNMENT ECE514 (COMPUTER ORGANIZATION) ASSIGNMENT NO. 3

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

The register set differs from one computer architecture to another. It is usually a combination of general-purpose and special purpose registers

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

Lecture 5: Computer Organization Instruction Execution. Computer Organization Block Diagram. Components. General Purpose Registers.

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

Where Does The Cpu Store The Address Of The

Chapter 4. Chapter 4 Objectives. MARIE: An Introduction to a Simple Computer

Chapter 4. Chapter 4 Objectives

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Computing Layers

CHAPTER SIX BASIC COMPUTER ORGANIZATION AND DESIGN

Major and Minor States

Computer Organization and Technology Processor and System Structures

Computer Structure. Unit 4. Processor

BASIC COMPUTER ORGANIZATION AND DESIGN

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

Register-Level Design

CHAPTER 8: Central Processing Unit (CPU)

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

Computer Architecture Programming the Basic Computer

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

Microcomputer Architecture and Programming

Transcription:

William Stallings Computer Organization and Architecture Chapter 16 Control Unit Operations Rev. 3.2 (2009-10) by Enrico Nardelli 16-1

Execution of the Instruction Cycle It has many elementary phases, each executed in a single clock cycle (remember pipelining) In each phase only very simple operations (called micro-operations) are executed: Move contents between registers (internals, interface with ALU, interface with memory) Activate devices (ALU, memory) Micro-operations are the CPU atomic operations, hence define its low-level behaviour A micro-operation is the set of actions (data flows and controls) that can be completed in a single clock cycle Rev. 3.2 (2009-10) by Enrico Nardelli 16-2

Constituent Elements of Program Execution Rev. 3.2 (2009-10) by Enrico Nardelli 16-3

Sequence of micro-operations for instruction fetch t 1 : MAR <- PC <DF 1 > t 2 : MBR <- memory <DF 2 DF 3 DF 4 DF 5 > PC <- PC +1 <DF 7 > t 3: IR <- MBR <DF 6 > CPU (each t i is a clock cycle, 1 2 PC MAR i.e. an atomic time unit) An alternative organization 7 Control 3 Unit t 1 : MAR <- PC 6 5 t 2 : MBR <- memory IR MBR t 3 : PC <- PC +1 MAR = Memory Address Register Address MBR = Memory Buffer Register IR = Instruction Register IR <- MBR PC = Program Counter Data 3 4 4 Control Memory Rev. 3.2 (2009-10) by Enrico Nardelli 16-4

Rules for micro-operation sequencing Proper precedence must be observed MAR <- PC must precede MBR <- memory Conflicts must be avoided Must not read & write same register at same time MBR <- memory & IR <- MBR must not be in same cycle Also: PC <- PC +1 involves addition Depending on the kind of ALU may need additional micro-operations, hence it is better to have it in t 2 Minimization of the number of micro-operations is an algorithmic problem on graphs Rev. 3.2 (2009-10) by Enrico Nardelli 16-5

Sequence of micro-operations for direct addressing t 1 : MAR <- IR address <DF 1 > t 2 : MBR <- memory <DF 2 DF 3 DF 4 DF 5 > 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 Data Control Rev. 3.2 (2009-10) by Enrico Nardelli 16-6

Sequence of micro-operations for register addressing t 1 : Reg. <- IR register-address <DF 1 > CPU Registers 1 1 Control Unit IR MAR = Memory Address Register MBR = Memory Buffer Register IR = Instruction Register PC = Program Counter Address Data Control Rev. 3.3 (2009-10) by Enrico Nardelli 16-7

Sequence of micro-operations for register indirect addressing t 1 : MAR <- (IR register-address ) <DF 1 DF 2 > t 2 : MBR <- memory <DF 3 DF 4 DF 5 DF 6 > CPU 4 2 MAR 3 5 5 Memory Registers 1 Control Unit 4 1 IR MBR 6 MAR = Memory Address Register MBR = Memory Buffer Register IR = Instruction Register PC = Program Counter Address Data Control Rev. 3.2 (2009-10) by Enrico Nardelli 16-8

Sequence of micro-operations for indirect addressing t 1 : MAR <- IR address <DF 1 > t 2 : MBR <- memory <DF 2 DF 3 DF 4 DF 5 > t 3 : MAR <- MBR <DF 6 > t 4 : MBR <- memory <DF 7 DF 8 DF 9 DF 10 > 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 Data Control Rev. 3.2 (2009-10) by Enrico Nardelli 16-9

Sequence of micro-operations for relative addressing t 1 : MAR <- IR address + PC <DF 1 DF 2 DF 3 DF 4 > t 2 : MBR <- memory <DF 5 DF 6 DF 7 DF 8 > CPU 6 PC 2 ALU 4 MAR 5 7 7 Memory 3 Control Unit 6 1 IR MBR 8 MAR = Memory Address Register MBR = Memory Buffer Register IR = Instruction Register PC = Program Counter ALU = Arithmetic Logic Unit Address Data Control Rev. 3.2 (2009-10) by Enrico Nardelli 16-10

Sequence of micro-operations for base and indexed addressing t 1 : MAR <- (IR register-address ) + IR address <DF 1 DF 2 DF 3 DF 4 DF 5 > t 2 : MBR <- memory <DF 6 DF 7 DF 8 DF 9 > 3 ALU Registers IR 2 1 CPU 5 4 1 MAR Control Unit MBR 6 7 9 7 8 8 Memory MAR = Memory Address Register MBR = Memory Buffer Register IR = Instruction Register PC = Program Counter ALU = Arithmetic Logic Unit Address Data Control Rev. 3.2 (2009-10) by Enrico Nardelli 16-11

Sequence of micro-operations for combination of displacement and indirect addressing Try them yourself! Rev. 3.2 (2009-10) by Enrico Nardelli 16-12

Sequence of micro-operations for interrupt handling t 1 : MBR <- PC <DF 1a > MAR <- Stack-Pointer <DF 1b > t 2 : memory <- MBR <DF 1c DF 1d DF 1e > Stack-Pointer <- Stack-Pointer + 1 <DF non visualizzati> t 3 : MAR <- Interrupt_Address <DF 2a > t 4 : MBR <- memory <DF 2b DF 2c DF 2d DF 2e > t 5 : PC <- MBR CPU <DF 2f > 1d - 2c NOTE: We assume Interrupt_Address is a fixed location known by the Control Unit 1b Registers PC 1b 2f 1a MAR 2a Control Unit MBR 1c - 2b 1d - 2c 2e 1c 2d 1e 1e - 2d Memory MAR = Memory Address Register Rev. 3.2 (2009-10) by Enrico Nardelli Address Data Control MBR = Memory Buffer Register 16-13 IR = Instruction Register PC = Program Counter

Micro-operation sequencing for the execution phase (1) Different for each instruction SUM X sum the contents of memory cell X and Accumulator and store back the result in cell X Assuming that after the operand fetch phase content of cell at address X is in MBR : t 1 : t 2 : t 3 : t 4 : ALU <- AC + MBR AC <- ALU MBR <- AC; MAR <- IR address memory <- MBR Rev. 3.2 (2009-10) by Enrico Nardelli 16-14

Micro-operation sequencing for the execution phase (2) ISZ X - increment memory cell X and if it s zero skip the next instruction Assuming that content of cell at address X is in MBR after the operand fetch phase: t 1 : ALU <- MBR + 1 t 2 : t 3 : Note: MBR <- ALU memory <- MBR IF MBR == 0 THEN PC <- PC + 1 IF-THEN is a single micro-operation Rev. 3.2 (2009-10) by Enrico Nardelli 16-15

Micro-operation sequencing for the execution phase (3) CALL X - Save in stack the return address and jump to address X t 1 : t 2 : MBR <- PC MAR <- SP memory <- MBR ALU <- SP + 1 t 3 : PC <- IR address SP <- ALU Rev. 3.2 (2009-10) by Enrico Nardelli 16-16

A simplified flow diagram for the execution of instruction cycle ICC = Instruction Cycle Code 11 (Interrupt) 00 (Fetch) ICC? Execute interrupt handling micro-ops ICC = 00 10 (Execution) Opcode? Execute micro-ops for the given opcode Interrupt enabled? 01 (Indirect Addressing) Execute indirect addressing micro-ops ICC = 10 No Execute direct addressing micro-ops Execute instruction fetch micro-ops Indirect addressing? Yes ICC = 01 ICC = 11 ICC = 00 ICC = 10 Rev. 3.2 (2009-10) by Enrico Nardelli 16-17

Functions of Control Unit Sequencing Causing the CPU to step through a series of microoperations Execution Causing the execution of each micro-op ALL THESE ACTIONS are performed by means of Control Signals Rev. 3.2 (2009-10) by Enrico Nardelli 16-18

A simplified data flow diagram of a Control Unit Instruction Register Flags Control Unit Signals internal to CPU Control Signals Control Clock Control Signals Rev. 3.2 (2009-10) by Enrico Nardelli 16-19

Control Unit s Input Signals Clock One micro-op (or set of parallel ops) per clock cycle Different signals are needed for different steps Instruction register Op-code for current instruction Determines which micro-instructions are performed Flags State of CPU Results of previous operations Control Interrupts Acknowledgments Rev. 3.2 (2009-10) by Enrico Nardelli 16-20

Control Unit s Output Signals To other CPU components For data movement To activate specific functions To the Control To control memory To control I/O modules Output signals from the control unit (i.e., Control Signals) make all micro-operations happen Rev. 3.2 (2009-10) by Enrico Nardelli 16-21

Simplified schema of a CPU: connections and control gates Data C5 C12 M B R C8 C1 C3 C4 C10 C15 C11 AC PC C13 IR C6 C7 C9 Address Cx C0 M A R C2 Control Gate x: The flow of data is enabled when the Control Signal x is enabled C14 Flags C16 Control Unit Decod. Control signals Cx Clock ALU Control signals Cx Rev. 3.2 (2009-10) by Enrico Nardelli 16-22

Example of Control Signal Sequence Instruction Fetch (1) t 1 : MAR <- PC Control unit (CU) activates signal C2 to open gate from PC to MAR t 2-1 : MBR <- memory CU activates C0 to open gate from MAR to address bus CU activates the memory read control signal (CR - not shown) to the memory CU activates C5 to open gate from data bus to MBR Rev. 3.2 (2009-10) by Enrico Nardelli 16-23

Example of Control Signal Sequence Instruction Fetch (2) t 2-2 : PC <- PC +1 In the considered CPU s internal schema, ALU s output is not directly connected to PC but only to AC. Therefore this micro-operation has to be split in two subsequent time units. What would happen if we had ALU s output directly connected to PC? t 3 : IR <- MBR CU activates C4 to open gate from MBR to IR Rev. 3.2 (2009-10) by Enrico Nardelli 16-24

Example of Control Signal Sequence Instruction Fetch (3) Splitting the increment of Program Counter ALU is a fast combinational circuit whose inputs and output are not buffered ALU has a specific control signal CA for unitary increment without a second input t 2-2 : PC <- PC +1 t 2-2-1 : ALU <- PC CU activates C14 from PC to ALU increment ALU CU act. control signal CA (not shown) for ALU AC <- ALU CU activates C9 from ALU to PC t 2-2-2 : PC <- AC CU activates C15 from AC to PC Rev. 3.2 (2009-10) by Enrico Nardelli 16-25

Example of Control Signal Sequence Instruction Fetch (4) Optimization t 2-1 and t 2-2-1 can be executed together t 2-2-2 and t 3 can be executer together New organization t 1 : MAR <- PC C2 t 2 : MBR <- memory C0 CR C5 ALU <- PC C14 increment ALU CA AC <- ALU C9 t 3 : PC <- AC C15 IR <- MBR C4 Rev. 3.2 (2009-10) by Enrico Nardelli 16-26

Example of Control Signal Sequence - Direct Addressing Direct addressing is executed right after instruction fetch in our simplified flow diagram for the execution of an instruction cycle. Hence: t 4 : t 5 : MAR <- IR address CU activates C16 to open gate from IR to MAR MBR <- memory CU act. C0 to open gate from MAR to address bus CU act. the memory read control signal CR CU act. C5 to open gate from data bus to MBR Rev. 3.2 (2009-10) by Enrico Nardelli 16-27

Example of Control Signal Sequence - Indirect Addressing t 1 : MAR <- IR address CU activates C16 to open gate from IR to MAR t 2 : MBR <- memory CU act. C0 to open gate from MAR to address bus CU act. the memory read control signal CR CU act. C5 to open gate from data bus to MBR t 3 : MAR <- MBR CU activates C8 to open gate from MBR to MAR t 4 : MBR <- memory CU activates C0, CR and C5 as above Rev. 3.2 (2009-10) by Enrico Nardelli 16-28

Example of Control Signal Sequence Execution: SUM t 1 : t 2 : ALU <- AC + MBR CU activates C6 to open gate from MBR to ALU CU activates C7 to open gate from AC to ALU CU activates for the ALU the sum control signal CS AC <- ALU CU activates C9 to open gate from ALU to AC t 2 : MBR <- AC; MAR <- IR address t 2 : CU activates C11 to open gate from AC to MBR CU activates C16 to open gate from IR to MAR memory <- MBR CU activates C0 to open gate from MAR to address bus CU activates C12 to open gate from MBR to data bus CU activates the memory write control signal CW NOTE: Now ALU s output needs to be buffered : this means that its output lines are not directly coming from the internal combinational circuits but from a registry (buffer) that receives combinational circuits outputs and store them for a subsequent reading Rev. 3.2 (2009-10) by Enrico Nardelli 16-29

Limitations The simplified internal schema of a CPU does not show registers, hence we cannot show Register addressing Register indirect addressing Base addressing Indexed addressing Combination of displacement and indirect addressing Try adding to the simplified schema one or more of the above addressing modalities and derive the required micro-operations! Rev. 3.2 (2009-10) by Enrico Nardelli 16-30

Internal Organization of CPU Usually a single internal bus less complex then having direct data paths between registers and ALU Control gates control movement of data onto and off the internal bus Control signals control also data transfer to and from external systems bus Temporary registers (i.e., buffers) in input to ALU are now needed for proper operation of ALU After Appendix B try yourself deriving the control signal sequences for a single internal bus CPU! Rev. 3.2 (2009-10) by Enrico Nardelli 16-31

How to implement the instruction cycle in hardware? ICC = Instruction Cycle Code 11 (Interrupt) 00 (Fetch) ICC? Execute interrupt handling micro-ops ICC = 00 10 (Execution) Opcode? Execute micro-ops for the given opcode Interrupt enabled? 01 (Indirect Addressing) Execute indirect addressing micro-ops ICC = 10 No Execute direct addressing micro-ops Execute instruction fetch micro-ops Indirect addressing? Yes ICC = 01 ICC = 11 ICC = 00 ICC = 10 Rev. 3.2 (2009-10) by Enrico Nardelli 16-32

Hardwired Implementation (1) Consider the control unit as a combinational circuit Outputs of the circuit are the control signals Inputs of the circuit are: ICC register bits (note that ICC is not visualized in the CPU s simplified internal schema) Status flags, including interrupt-enable/disable (T) Direct/indirect address bit (D) Decoded opcodes (OC n ) Clocks (t n ) For each configuration of inputs produce a proper output That is, the activation of a given control signal Cn has to happen when (condition A is true) OR (condition B is true) OR Rev. 3.2 (2009-10) by Enrico Nardelli 16-33

Data flow diagram of the Control Unit for the hardwired implement. of the CPU s simplified schema Instruction Register ICC D Decoder OC 1 OC m Clock Flags clocks for mops T t 1 t n Control Unit Control Signals internal to CPU External Control Signals Control Rev. 3.2 (2009-10) by Enrico Nardelli 16-34

Hardwired Implementation (2) Control signals P and Q code ICC: then fetch (instruction + direct addr.) is coded by P Q, indirect by P Q, execute by PQ, and interrupt by PQ Direct addressing is coded by D (D = indirect) Decoded opcodes provide are further control signals Interrupt enable is coded by T (T = interrupt disabled) Each clock t n is a control signal Boolean expression activating C5 in the simplified schema of a CPU (see slides 26, 27, 28 and 13): C5 = P Q (t 2 + Dt 5 ) + P Q(t 2 + t 4 ) + PQ B + PQ t 4 where B is the boolean expression representing, for all opcodes activating C5, all micro-operations actually activating it example: if C5 is activated only by opcode 3 during t 2 and t 4 and by opcode 7 during t 3 and t 4 then B is: OC3(t 2 +t 4 )+OC7(t 3 +t 4 ) Rev. 3.2 (2009-10) by Enrico Nardelli 16-35

Hardwired Implementation (3) Updating ICC: Assume no micro-procedure requires more than 5 time units Update P and Q using clock t 6, current values of P and Q, interrupt enabled flag (T), direct address signal (D) At the end of direct addressing branch of fetch phase (00) P = P Q t 6 D Q = P Q t 6 D At the end of indirect addressing branch of fetch phase (00) P = P Q t 6 D Q = P Q t 6 D At the end of indirect addressing phase (01) P = P Q t 6 Q = P Q t 6 At the end of interrupt enabled branch of execution phase (10) P = PQ t 6 T Q = PQ t 6 T At the end of interrupt disabled branch of execution phase (10) P = PQ t 6 T Q = PQ t 6 T At the end of interrupt phase (11) P = PQ t 6 Q = PQ t 6 Rev. 3.2 (2009-10) by Enrico Nardelli 16-36

Hardwired Implementation (4) Do we forget anything? Discarding t 6 (present in all terms) we have P = P Q D + P Q + PQ T and P = P Q D + PQ T + PQ Q = P Q D + PQ T and Q = P Q D + P Q + PQ T + PQ P P Q P Q PQ PQ 00 01 11 10 T D 00 0 1 0 0 T D 01 1 1 0 0 TD 11 1 1 0 1 TD 10 0 1 0 1 Q P Q P Q PQ PQ 00 01 11 10 T D 00 1 0 0 0 T D 01 0 0 0 0 TD 11 0 0 0 1 TD 10 1 0 0 1 Rev. 3.2 (2009-10) by Enrico Nardelli 16-37

Problems with the Hardwired Implementation Complex sequencing & micro-operation logic Difficult to design and test Inflexible design Difficult to add new instruction Rev. 3.2 (2009-10) by Enrico Nardelli 16-38