COSC 243. Control Unit and Microprogramming. Lecture 12. COSC 243 (Computer Architecture)

Similar documents
(Refer Slide Time: 00:01:16 min)

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

CPU Organisation and Operation

Central Processing Unit (CPU)

CHAPTER 7: The CPU and Memory

Systems I: Computer Organization and Architecture

Let s put together a Manual Processor


LSN 2 Computer Processors

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

CHAPTER 4 MARIE: An Introduction to a Simple Computer

Chapter 2 Logic Gates and Introduction to Computer Architecture

Central Processing Unit

CSCI 4717 Computer Architecture. Function. Data Storage. Data Processing. Data movement to a peripheral. Data Movement

Microprocessor & Assembly Language

PROBLEMS #20,R0,R1 #$3A,R2,R4

Chapter 2 Basic Structure of Computers. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

Instruction Set Architecture. Datapath & Control. Instruction. LC-3 Overview: Memory and Registers. CIT 595 Spring 2010

Building a computer. Electronic Numerical Integrator and Computer (ENIAC)

Computer organization

A s we saw in Chapter 4, a CPU contains three main sections: the register section,

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995

Chapter 01: Introduction. Lesson 02 Evolution of Computers Part 2 First generation Computers

BASIC COMPUTER ORGANIZATION AND DESIGN

Computer Organization. and Instruction Execution. August 22

INSTRUCTION LEVEL PARALLELISM PART VII: REORDER BUFFER

Instruction Set Architecture (ISA)

To design digital counter circuits using JK-Flip-Flop. To implement counter using 74LS193 IC.

CPU Organization and Assembly Language

TIMING DIAGRAM O 8085

CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions

Lecture: Pipelining Extensions. Topics: control hazards, multi-cycle instructions, pipelining equations

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

CHAPTER 11: Flip Flops

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

PART B QUESTIONS AND ANSWERS UNIT I

An Introduction to the ARM 7 Architecture

CS352H: Computer Systems Architecture

Computer Organization and Components

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

PROBLEMS. which was discussed in Section

Counters and Decoders

MACHINE ARCHITECTURE & LANGUAGE

CS:APP Chapter 4 Computer Architecture. Wrap-Up. William J. Taffe Plymouth State University. using the slides of

Systems I: Computer Organization and Architecture

Chapter 4 Lecture 5 The Microarchitecture Level Integer JAVA Virtual Machine

MICROPROCESSOR AND MICROCOMPUTER BASICS

Solutions. Solution The values of the signals are as follows:

Giving credit where credit is due

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

Pipeline Hazards. Structure hazard Data hazard. ComputerArchitecture_PipelineHazard1

Computer System: User s View. Computer System Components: High Level View. Input. Output. Computer. Computer System: Motherboard Level

Chapter 9 Computer Design Basics!

WAR: Write After Read

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 OUTCOME 3 PART 1

Fastboot Techniques for x86 Architectures. Marcus Bortel Field Application Engineer QNX Software Systems

Summary of the MARIE Assembly Language

Solution: start more than one instruction in the same clock cycle CPI < 1 (or IPC > 1, Instructions per Cycle) Two approaches:

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Programming Logic controllers

1 Computer hardware. Peripheral Bus device "B" Peripheral device. controller. Memory. Central Processing Unit (CPU)

Instruction Set Design

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-12: ARM

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

The components. E3: Digital electronics. Goals:

Generating MIF files

Learning Outcomes. Simple CPU Operation and Buses. Composition of a CPU. A simple CPU design

COMPUTER ORGANIZATION AND ARCHITECTURE. Slides Courtesy of Carl Hamacher, Computer Organization, Fifth edition,mcgrawhill

Lecture-3 MEMORY: Development of Memory:

How It All Works. Other M68000 Updates. Basic Control Signals. Basic Control Signals

picojava TM : A Hardware Implementation of the Java Virtual Machine

Memory Elements. Combinational logic cannot remember

ETEC 2301 Programmable Logic Devices. Chapter 10 Counters. Shawnee State University Department of Industrial and Engineering Technologies

2011, The McGraw-Hill Companies, Inc. Chapter 5

Below is a diagram explaining the data packet and the timing related to the mouse clock while receiving a byte from the PS-2 mouse:

An Overview of Stack Architecture and the PSC 1000 Microprocessor

Q. Consider a dynamic instruction execution (an execution trace, in other words) that consists of repeats of code in this pattern:

l C-Programming l A real computer language l Data Representation l Everything goes down to bits and bytes l Machine representation Language

Chapter 1 Computer System Overview

1 Classical Universal Computer 3

IA-64 Application Developer s Architecture Guide

Digital Logic Design. Basics Combinational Circuits Sequential Circuits. Pu-Jen Cheng

The Microarchitecture of Superscalar Processors

Microprocessor and Microcontroller Architecture

Modeling Sequential Elements with Verilog. Prof. Chien-Nan Liu TEL: ext: Sequential Circuit

Computer Organization and Architecture

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

Systems I: Computer Organization and Architecture

EE482: Advanced Computer Organization Lecture #11 Processor Architecture Stanford University Wednesday, 31 May ILP Execution

A New Paradigm for Synchronous State Machine Design in Verilog

Processor Architectures

================================================================

Memory Basics. SRAM/DRAM Basics

Central Processing Unit Simulation Version v2.5 (July 2005) Charles André University Nice-Sophia Antipolis

Design Example: Counters. Design Example: Counters. 3-Bit Binary Counter. 3-Bit Binary Counter. Other useful counters:

Cascaded Counters. Page 1 BYU

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

WEEK 8.1 Registers and Counters. ECE124 Digital Circuits and Systems Page 1

8085 INSTRUCTION SET

Low Power AMD Athlon 64 and AMD Opteron Processors

Transcription:

COSC 243 Control Unit and Microprogramming 1

Operation of a CPU Each instruction has a bunch of things that need to happen: Get the instruction from memory: fetch cycle Load any operands from memory: indirect cycle Execute the instruction: execute cycle Check interrupts: interrupt cycle The Control unit is responsible for coordinating this 2

The Fetch Cycle The fetch cycle consists of a number of smaller steps 1. Copy PC into the Memory Address Register (MAR) 2. MAR output enable (put address on bus) 3. Memory read enable (put data on bus) 4. Read data off bus into memory buffer (MBR) 5. Copy the value MBR to IR 6. Add 1 to PC 3

The Fetch Cycle This can be written as a sequence of micro operations: t1: MAR (PC) t2: MBR Memory ; read t3: IR (MBR) t4: PC (PC) + 1 Initial t1 t2 t3 MAR MAR 00101100 MAR 00101100 MAR 00101100 t4 MAR 00101100 MBR PC 00101100 IR MBR PC 00101100 IR MBR 11011100 PC 00101100 IR MBR 11011100 PC 00101100 IR 11011100 MBR 11011100 PC 00101101 IR 11011100 4

Other cycles Each cycle is made up of more basic elements Transferring data in/out of registers Turning on/off control lines (for ALU, memory, etc.) Decision based on status flags

General control unit structure Inputs: Instruction register Status flags Clock signal Outputs: Control lines within CPU Control lines to bus (memory, I/O) State: Current micro-operation 6

General control unit structure Status Instruction Control Logic Control lines State 7

Control logic We need to calculate: Control signals Next state Based on: Current state Status flags instruction Two approaches: Hard wired: a combinatorial circuit microprogramming 8

Hardwired Approach Implemented with gates and flip-flops: State is instruction register, plus a counter Counter determines which micro-operation we are on Sequential design methodology is used State transition diagrams etc. Difficulties: Complicated state diagrams: many control lines, many states Long gate delays Hard to add instructions A typical CPU has between 50 and several hundred instructions Single mistake is difficult to fix 9

Microprogramming Store the sequences of micro-operations as a kind of program The control unit is a kind of mini-cpu: Executes micro-operations in sequence Can jump to other micro-operations based on status flags But only thing it does is turns control wires on and off, and determine the next micro-op Micro-program is stored in a ROM (or EEPROM etc.) Can be updated on boot in some CPUs 10

Microprogramming Instruction Register Status Clock Sequence logic Next address Firmware ROM Decode Next address control Control lines 11

Sequence logic Each micro-operation in firmware has a unique address (just like a normal program in main memory) Sequence logic just determines address of next micro-operation Basic sequence logic, on each clock pulse: Check any branch conditions. If condition is met, branch to given address Check if this instruction is done. If it is, load start address for next instruction Otherwise, increment address 12

Microinstructions Microinstructions need to be decoded Two main strategies: Horizontal microinstructions: Each control wire's output is stored as a bit in the instruction. No decoding necessary. Very wide instructions (> 40 bits common) Vertical microinstructions: Control wires are encoded (eg. binary encoded number of register, rather than one bit per register) Shorter instructions, but decoding necessary Many variations are possible. Horizontal is most common 13

Instruction Pipelining Recall: Fetch Cycle Indirect Cycle Execute Cycle Interrupt Cycle What is the fetch hardware doing during the execute cycle? Can we put it to good use? 14

Instruction Pre-fetching In a 2-stage pipeline the fetch unit pre-fetches the next instruction while the execute unit performs the current instruction If it s the wrong instruction (due to a branch) it discards it and loads the correct instruction New Address Instruction Fetch Instruction Execute Result Discard 15

Speedup If the fetch and execution times were the same then the speedup would be 100% (double the throughput) However, Instruction times are usually dominated by execution time So in practice it doesn t double in a 2-stage pipeline Branch instructions can slow it down Because it has pre-fetched from the wrong addresses Also note, Extra hardware is needed to buffer the reads 16

Branches In a pipelined system the next instruction is pre-fetched If the current instruction is if there are two outcomes: Continue with the next instruction Go somewhere else In the first case the pre-fetch is correct The pipeline continues In the second case it is incorrect The result must be discarded and the pipeline restarted How can we use this to our advantage when programming in a high level language? 17

6-Stage Pipeline The more stages the instruction is broken into the more instructions that can be pipelined. In a 6-stage pipeline we see: Fetch Instruction Decode Instruction Calculate Operands Fetch Operands Execute Instruction Write Operand It s assumed that all instructions go through all stages And that there are no bus collisions 18

6-Stage Pipeline Clock cycle Instruction 1 2 3 4 5 6 7 8 1 Fetch Decode Calculate Operands Fetch Operands 2 Fetch Decode Calculate Operands Execute Fetch Operands 3 Fetch Decode Calculate Operands Write Execute Fetch Operands 4 Fetch Decode Calculate Operands Write Execute Fetch Operands Write Execute 19

Problems with Pipelines Data must be moved from stage to stage in the pipeline This takes time, so much time that the overall time of each instruction can be increased The extra hardware is complex So complex that it can become more complex than the operations themselves 20

Conditional Branches What happens with a conditional branch instruction? What if we need the results of the previous instruction in the next instruction? 21

Pipeline Hazards Resource hazard / structural hazard Two or more instructions need the same resource Such as reading from memory, the ALU, etc Data hazard Read after write (RAW) One instruction writes to a memory location then another reads from it But, in the pipeline the data has already been read Write after read (WAR) One instruction reads from a memory location then another writes to it But if the write finished before the read occurs they are out-of-order Write after write (WAW) Two instructions write to a memory location one after the other But they happen out-of-order in the pipeline 22

Control Hazards Control hazard Incorrect prediction of the outcome of a conditional branch Solutions to the Control Hazard Multiple Streams Fill a second pipeline with the alternative destination Expensive and hard to avoid contention Pre-fetch Branch Target Preload just the branch target instruction Loop Buffer Small cache in the fetch unit that stores the last n instructions Branch prediction Never / always / opcode / history 23

Summary Each instruction has 4 cycles Fetch / Indirect / Execute / Interrupt These can be broken down into smaller steps Micro operations And micro programmed In microcode They can also be run separately and joined together In a pipeline 24