Lecture 11: Control Unit and Instruction Encoding

Similar documents
Lecture 04: Machine Instructions

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

Basic Processing Unit (Chapter 7)

The Processing Unit. TU-Delft. in1210/01-pds 1

Week 4: Assignment Solutions


Introduction to CPU Design

UNIT 3 - Basic Processing Unit

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

MC9211Computer Organization. Unit 4 Lesson 1 Processor Design

Module 5 - CPU Design


Computer Logic II CCE 2010

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

PESIT Bangalore South Campus

Chapter 4 The Von Neumann Model

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

LC-3 Architecture. (Ch4 ish material)

Processing Unit. Unit II

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

Chapter 4 The Von Neumann Model

Processing Unit CS206T

Objective now How are such control statements registers and other components Managed to ensure proper execution of each instruction

Chapter 04: Instruction Sets and the Processor organizations. Lesson 20: RISC and converged Architecture

PESIT Bangalore South Campus

PROBLEMS. 7.1 Why is the Wait-for-Memory-Function-Completed step needed when reading from or writing to the main memory?

DC57 COMPUTER ORGANIZATION JUNE 2013

Chapter 4 The Von Neumann Model

Lecture 01: Basic Structure of Computers

3. (2 pts) Clock rates have grown by a factor of 1000 while power consumed has only grown by a factor of 30. How was this accomplished?

Introduction to Computer Engineering. CS/ECE 252 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin Madison

Very short answer questions. You must use 10 or fewer words. "True" and "False" are considered very short answers.

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

CPU Organization. Hardware design. Vs. Microprogramming

THE MICROPROCESSOR Von Neumann s Architecture Model

ASSEMBLY LANGUAGE MACHINE ORGANIZATION

ECE 486/586. Computer Architecture. Lecture # 7

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

(1) Using a different mapping scheme will reduce which type of cache miss? (1) Which type of cache miss can be reduced by using longer lines?

COMPUTER ORGANIZATION & ARCHITECTURE

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

Digital System Design Using Verilog. - Processing Unit Design

Implementing the Control. Simple Questions

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

CISC Processor Design

SCRAM Introduction. Philipp Koehn. 19 February 2018

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

101. The memory blocks are mapped on to the cache with the help of a) Hash functions b) Vectors c) Mapping functions d) None of the mentioned

Very short answer questions. You must use 10 or fewer words. "True" and "False" are considered very short answers.

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

IAS Computer. Instructions

Computer Organization CS 206 T Lec# 2: Instruction Sets

Processor (I) - datapath & control. Hwansoo Han

1. Fundamental Concepts

TDT4255 Computer Design. Lecture 4. Magnus Jahre. TDT4255 Computer Design

COSC121: Computer Systems: Review

16.1. Unit 16. Computer Organization Design of a Simple Processor

Chapter 4. The Processor

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

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss

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

Chapter 4. The Processor

Lecture Topics ECE 341. Lecture # 8. Functional Units. Information Processed by a Computer

VLSI Project. Phase 1 Documentation GROUP 7

Chapter 3 : Control Unit

Blog -

Mark Redekopp and Gandhi Puvvada, All rights reserved. EE 357 Unit 15. Single-Cycle CPU Datapath and Control

Review: Abstract Implementation View

Designing Computers. The Von Neumann Architecture. The Von Neumann Architecture. The Von Neumann Architecture

The Von Neumann Architecture. Designing Computers. The Von Neumann Architecture. CMPUT101 Introduction to Computing - Spring 2001

The Processor: Datapath and Control. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

ECE 341. Lecture # 15

Very short answer questions. You must use 10 or fewer words. "True" and "False" are considered very short answers.

Computer Architecture (part 2)

Chapter 13. The ISA of a simplified DLX Why use abstractions?

ADVANCED COMPUTER ARCHITECTURE TWO MARKS WITH ANSWERS

Chapter 4. The Processor. Instruction count Determined by ISA and compiler. We will examine two MIPS implementations

Computer Architecture

EE 3170 Microcontroller Applications

Architectures & instruction sets R_B_T_C_. von Neumann architecture. Computer architecture taxonomy. Assembly language.

Processor Organization and Performance

Blog -

Systems Architecture

COMP3221: Microprocessors and. and Embedded Systems. Instruction Set Architecture (ISA) What makes an ISA? #1: Memory Models. What makes an ISA?

Hardware Design I Chap. 10 Design of microprocessor

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 2, 2016

EC-801 Advanced Computer Architecture

ECE260: Fundamentals of Computer Engineering

CSE A215 Assembly Language Programming for Engineers

A 32-bit Processor: Sequencing and Output Logic

INSTITUTO SUPERIOR TÉCNICO. Architectures for Embedded Computing

MICROPROGRAMMED CONTROL

MCQ's on Unit-3 Control Unit

Microprogrammed Control Approach

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

CSEE 3827: Fundamentals of Computer Systems

The Processor (1) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

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

Chapter 4 Topics. Comp. Sys. Design & Architecture 2 nd Edition Prentice Hall, Mark Franklin,S06

Chapter 4. The Processor Designing the datapath

Transcription:

CSCI25 Computer Organization Lecture : Control Unit and Instruction Encoding Ming-Chang YANG mcyang@cse.cuhk.edu.hk Reading: Chap. 7.4~7.5 (5 th Ed.)

Recall: Components of a Processor Register file: a memory unit for the processor s generalpurpose registers (GPRs) Register file Control circuitry Control circuitry: Interpret or decode the fetched instruction IR IR: Hold the instruction until its execution is completed (special purpose register) Arithmetic and Logic Unit (ALU): Perform an arithmetic or logic operation ALU Instruction address generator PC PC: Keep track of the address of the next instruction to be fetched and executed (special purpose register) Processor memory interface Processor-memory interface: Allow the communication between processor and memory CSCI25 Lec: Control Unit and Instruction Encoding 2

Outline Control Signal Generation ) Hard-wired Control 2) Micro-programmed Control Machine Instruction Encoding CSCI25 Lec: Control Unit and Instruction Encoding 3

Control Signal Generation The processor must have some means to generate the control signals for instruction execution: ) Hard-wired control 2) Micro-programmed control Every control signals (e.g., PC-out, MDR-in, ADD, SUB, ) are switched on (active) and off (inactive) at suitable time. The time duration is determined by the clock. CSCI25 Lec: Control Unit and Instruction Encoding 4

) Hard-wired Control Hard-wired Control: The combinational logic gates are used to determine the sequence of control signals: A counter is used keep track of the control steps. Control signals are functions of the IR, external inputs and condition codes Clock IR CLK Control step counter Decoder & Encoder (combinational logic gates) External inputs e.g. MFC Condition codes/ flags The control signals are produced at the right time (i.e., control step). Control signals An example of combinational logic gates. CSCI25 Lec: Control Unit and Instruction Encoding 5

Ri-in Ri-out Add IR-in IR-out MAR-in MDR-in MDR-out PC-in PC-out IncPC Read TEMP-out Write ) Hard-wired Control (Cont d) A simplified example: Fetch Phase: T: PC-out, MAR-in T: Read, IncPC T2: MDR-out, IR-in Execution Phase: load add store branch offset Decoder & Encoder Control Step Counter Control signals are switched on at the right control step (T, T, T2, T3, ) Control Signals https://people.cs.clemson.edu/~mark/uprog.html CSCI25 Lec: Control Unit and Instruction Encoding 6

Ri-in Ri-out Add IR-in IR-out MAR-in MDR-in MDR-out PC-in PC-out IncPC Read TEMP-out Write ) Hard-wired Control (Cont d) A simplified example: IR needs to be decoded to determine the instruction load add store branch offset Decoder & Encoder Control Decode Step Counter Fetch Phase: Execution Phase: T3: IR Decoding T4~T7: Operation (e.g., load) Control Signals https://people.cs.clemson.edu/~mark/uprog.html CSCI25 Lec: Control Unit and Instruction Encoding 7

Class Exercise. Student ID: Name: Date: The control sequences of different instructions may consist of a different number of steps. For example, the load instruction is composed of 6 steps (3 for the fetch, for the decode, and 3 for the execution). Can you tell how many control steps are required for the other three instructions (i.e., add, store, and branch) in the given simplified hard-wired control? CSCI25 Lec: Control Unit and Instruction Encoding 8

Ri-in Ri-out Add IR-in IR-out MAR-in MDR-in MDR-out PC-in PC-out IncPC Read TEMP-out Write Class Exercise. A simplified example: load add store branch offset Decoder & Encoder Control Decode Step Counter Control Signals https://people.cs.clemson.edu/~mark/uprog.html CSCI25 Lec: Control Unit and Instruction Encoding 9

) Hard-wired Control (Cont d) The wiring of the logic gates for control signal generation is fixed. Simple signal: PC-out = T Complicated signal : MDR-inE = ((IR == ADD) and ((T2) or (T5))) or ((IR == SUB) and ((T2) or (T5))) or CarryFlag or and or and and The hard-wired control can operate at high speed. However, the hard-wired control has little flexibility. It can only implement instruction set of limited complexity. CSCI25 Lec: Control Unit and Instruction Encoding

MARin Read MDRout Select Add Zout WMFC End 2) Micro-programmed Control The control signals are generated by a micro-program. Every line is a control word. Micro-programs are stored in a special memory (control store). Ex: ADD R, (R3), B in, MDR ine, MDR ine, Bin Micro - instruction PCin PCout IRin Yin Zin Rout Rin R3out B in MDR ine Micro- Program 2 3 Control word 4 5 6 7 CSCI25 Lec: Control Unit and Instruction Encoding 2

MARin Read MDRout Select Add Zout WMFC End Class Exercise.2 Please fill in the missing control word in the below micro-program for the instruction ADD R, (R3): Ex: ADD R, (R3), B in, MDR ine, MDR ine, Bin Micro - instruction PCin PCout IRin Yin Zin Rout Rin R3out B in MDR ine 2 3 Control word 4 5 6 7 CSCI25 Lec: Control Unit and Instruction Encoding 3

2) Micro-programmed Control (Cont d) A micro-program counter (upc) is used to read control words sequentially from control store. Whenever a new instruction is loaded into IR, Starting Address Generator loads the starting address into upc. upc increments by clock, causing successive microinstructions to be read out from the control store. Control signals are generated in the correct sequence defined by a micro-program. CSCI25 Lec: Control Unit and Instruction Encoding Control word 5

2) Micro-programmed Control (Cont d) The previous scheme is not able to change the control sequence by other inputs. It cannot support branch on condition code (e.g. Jump if < ) Starting and branch address generator: Load new address into upc when instructed. Check condition codes and external inputs that can affect upc. IR Clock Starting and branch address generator Control store External inputs Condition codes Control Word CSCI25 Lec: Control Unit and Instruction Encoding 6 mpc

2) Micro-programmed Control (Cont d) upc is incremented every cycle except: When a new instruction loaded into IR, upc is loaded with starting address of the micro-program. IR Starting and branch address generator External inputs Condition codes When taken branches, upc is updated with the branch address. Clock mpc When taken END micro-instruction, upc is reset. Control store Control Word CSCI25 Lec: Control Unit and Instruction Encoding 7

Outline Control Signal Generation ) Hard-wired Control 2) Micro-programmed Control Machine Instruction Encoding CSCI25 Lec: Control Unit and Instruction Encoding 8

Machine Instruction Encoding An instruction must be encoded in a compact binary pattern. Clock CLK Control step counter The decoder must interpret (or decode) the instruction, and generate the control signals correctly. IR Decoder & Encoder External inputs e.g. MFC Condition codes/ flags Control signals CSCI25 Lec: Control Unit and Instruction Encoding 9

Why Machine Instruction Encoding? We have a bunch of instructions: Such as add, subtract, move, shift, rotate, branch, etc. Instructions may use operands of different sizes. Such as 32-bit and 8-bit number, or 8-bit ASCII characters. Both the type of operation and the type of operands need to be specified in encoded binary patterns. Type of Operation: Often referred to as the OP code. E.g., 8 bits can represent 256 different OP codes. Type of Operands: Addressing modes. An operand is the part of an instruction that specifies data to be operating on or manipulated. CSCI25 Lec: Control Unit and Instruction Encoding 2

Example: 85/852 OP Code Map CSCI25 Lec: Control Unit and Instruction Encoding 2

Recall: Type of Operands Addressing Modes: the ways for specifying the locations of instruction operands. Address Mode Assembler Syntax Addressing Function ) Immediate #Value Operand = Value 2) Register Ri EA = Ri 3) Absolute LOC EA = LOC 4) Register indirect (Ri) EA = [Ri] 5) Index X(Ri) EA = Ri + X 6) Base with index (Ri, Rj) EA = Ri + [Rj] EA: effective address Value: a signed number X: index value CSCI25 Lec4: Machine Instructions 22

One-word Instruction (/2) Some instructions can be encoded in one 32-bit word: 8 OP code: 8 bits 3+4 3+4 OP code Source Dest Other info Src and Dest: 3 bits (addressing mode) + 4 bits (register #) Other info: bits (such as index value) ADD R, R2 MOV R5, 24(R) Needs to specify OP code, SRC and DEST registers. 8 bits for OP code. 3 bits are needed for addressing modes. 4 bits are required to distinguish 6 registers. Needs to specify OP code, two registers and an index value of 24. bits of other info can be used for the index value. CSCI25 Lec: Control Unit and Instruction Encoding 23

One-word Instruction (2/2) Some instructions can be encoded in one 32-bit word: 8 24 OP code Branch address OP code: 8 bits Branch address: 24 bits Branch> Offset 8 bits for OP code 24 bits are left for the branch address. Question: How can we branch farther away using different addressing modes? CSCI25 Lec: Control Unit and Instruction Encoding 24

Two-word Instruction What if we want to specify a memory operand using the absolute addressing mode? MOV R2, LOC 8 bits for OP code, 3+4 bits for addressing mode and register number for R2, 3 bits for addressing mode for LOC. Only 4 bits left for specifying the memory address. Some instructions need an additional word to contain the absolute memory address or an immediate value: OP code Source Dest Other info Memory address / Immediate operand E.g., Add R2, FF h (immediate operand) CSCI25 Lec: Control Unit and Instruction Encoding 25

Multi-word Instruction (/2) What if we want to allow an instruction in which both two operands can be specified using the absolute addressing mode? MOV LOC, LOC2 It becomes necessary to use two additional words for the 32-bit addresses of the two operands... OP code Source Dest Other info Memory address / Immediate operand Memory address / Immediate operand CSCI25 Lec: Control Unit and Instruction Encoding 26

Multi-word Instruction (2/2) If we allow instructions using two 32-bit direct address operands, we need three words in total for the instruction encoding scheme. E.g., MOV LOC, LOC2 Multiple length instructions are difficult to implement with high clock rate. The design of the Instruction Register (IR) and the Instruction Decoder will be complex. The Control Unit will be difficult to design. Shall we go for simple or complex? CSCI25 Lec: Control Unit and Instruction Encoding 27

Recall: RISC vs. CISC Styles RISC Simple addressing modes All instructions fitting in a single word Fewer instructions in the instruction set, and simpler addressing modes Arithmetic and logic operations that can be performed only on operands in processor registers Don t allow direct transfers from one memory location to another Note: Such transfers must take place via a processor register. Programs that tend to be larger in size, because more but simpler instructions are needed to perform complex tasks Simple instructions that are conducive to fast execution by the processing unit using techniques such as pipelining CISC More complex addressing modes More complex instructions, where an instruction may span multiple words Many instructions that implement complex tasks, and complicated addressing modes Arithmetic and logic operations that can be performed on memory and register operands Possible to transfer from one memory location to another by using a single Move instruction Programs that tend to be smaller in size, because fewer but more complex instructions are needed to perform complex tasks CSCI25 Lec4: Machine Instructions 28

CISC vs RISC CISC OR RISC? CISC machines usually require less instructions to do something but have a lower clock rate RISC machines require more instructions to do something but have a higher clock rate The Best of Both World: CISC WITH RISC Modern processors usually combine the strengths of both CISC and RISC. E.g., a CISC design with a RISC core: Design a RISC-style core instruction decoder with high clock rates. Provide a rich set of CISC-style instructions and addressing modes to assembly programmers. CSCI25 Lec: Control Unit and Instruction Encoding 29

Summary Control Signal Generation ) Hard-wired Control 2) Micro-programmed Control Machine Instruction Encoding CSCI25 Lec: Control Unit and Instruction Encoding 3