RISC Central Processing Unit

Similar documents
Computer Hardware. Pipeline

7/11/2012. Single Cycle (Review) CSE 2021: Computer Organization. Multi-Cycle Implementation. Single Cycle with Jump. Pipelining Analogy

Lecture Topics. Announcements. Today: Pipelined Processors (P&H ) Next: continued. Milestone #4 (due 2/23) Milestone #5 (due 3/2)

Chapter 4. Pipelining Analogy. The Processor. Pipelined laundry: overlapping execution. Parallelism improves performance. Four loads: Non-stop:

CS 110 Computer Architecture Lecture 11: Pipelining

Computer Architecture

Pipelining A B C D. Readings: Example: Doing the laundry. Ann, Brian, Cathy, & Dave. each have one load of clothes to wash, dry, and fold

7/19/2012. IF for Load (Review) CSE 2021: Computer Organization. EX for Load (Review) ID for Load (Review) WB for Load (Review) MEM for Load (Review)

CSE 2021: Computer Organization

RISC Design: Pipelining

Pipelined Processor Design

A B C D. Ann, Brian, Cathy, & Dave each have one load of clothes to wash, dry, and fold. Time

EECE 321: Computer Organiza5on

IF ID EX MEM WB 400 ps 225 ps 350 ps 450 ps 300 ps

IF ID EX MEM WB 400 ps 225 ps 350 ps 450 ps 300 ps

LECTURE 8. Pipelining: Datapath and Control

Instruction Level Parallelism. Data Dependence Static Scheduling

Lecture 4: Introduction to Pipelining

6.S084 Tutorial Problems L19 Control Hazards in Pipelined Processors

ECE473 Computer Architecture and Organization. Pipeline: Introduction

Selected Solutions to Problem-Set #3 COE 608: Computer Organization and Architecture Single Cycle Datapath and Control

Pipelined Beta. Handouts: Lecture Slides. Where are the registers? Spring /10/01. L16 Pipelined Beta 1

Suggested Readings! Lecture 12" Introduction to Pipelining! Example: We have to build x cars...! ...Each car takes 6 steps to build...! ! Readings!

Understanding Engineers #2

Asanovic/Devadas Spring Pipeline Hazards. Krste Asanovic Laboratory for Computer Science M.I.T.

CMSC 611: Advanced Computer Architecture

Basic Symbols for Register Transfers. Symbol Description Examples

CS420/520 Computer Architecture I

CS429: Computer Organization and Architecture

Controller Implementation--Part I. Cascading Edge-triggered Flip-Flops

Low-Power CMOS VLSI Design

ECE 2300 Digital Logic & Computer Organization. More Pipelined Microprocessor

Computer Elements and Datapath. Microarchitecture Implementation of an ISA

EE382V-ICS: System-on-a-Chip (SoC) Design

Project 5: Optimizer Jason Ansel

Computer Science 246. Advanced Computer Architecture. Spring 2010 Harvard University. Instructor: Prof. David Brooks

EE 457 Homework 5 Redekopp Name: Score: / 100_

Chapter 16 - Instruction-Level Parallelism and Superscalar Processors

Pipelined Architecture (2A) Young Won Lim 4/10/18

Pipelined Architecture (2A) Young Won Lim 4/7/18

EN164: Design of Computing Systems Lecture 22: Processor / ILP 3

Single vs. Mul2- cycle MIPS. Single Clock Cycle Length

Computer Architecture and Organization: L08: Design Control Lines

Korea Advanced Institute of Science and Technology Korea Advanced Institute of Science and Technology

Instruction Level Parallelism Part II - Scoreboard

On the Rules of Low-Power Design

CS521 CSE IITG 11/23/2012

Single-Cycle CPU The following exercises are taken from Hennessy and Patterson, CO&D 2 nd, 3 rd, and 4 th Ed.

CMP 301B Computer Architecture. Appendix C

Topics. Low Power Techniques. Based on Penn State CSE477 Lecture Notes 2002 M.J. Irwin and adapted from Digital Integrated Circuits 2002 J.

Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted from Hennessy & Patterson / 2003 Elsevier

COSC4201. Scoreboard

EECS 470 Lecture 4. Pipelining & Hazards II. Winter Prof. Ronald Dreslinski h8p://

Pipelining and ISA Design

Design of Microprogrammed Control Units (MCU) using VHDL Description. Arvutitehnika erikusus

Dynamic Scheduling II

CS 61C: Great Ideas in Computer Architecture. Pipelining Hazards. Instructor: Senior Lecturer SOE Dan Garcia

EC4205 Microprocessor and Microcontroller

EECS 470. Lecture 9. MIPS R10000 Case Study. Fall 2018 Jon Beaumont

8-bit Microcontroller with 512/1024 Bytes In-System Programmable Flash. ATtiny4/5/9/10

SCALCORE: DESIGNING A CORE

CS152 Computer Architecture and Engineering Lecture 3: ReviewTechnology & Delay Modeling. September 3, 1997

CISC 662 Graduate Computer Architecture. Lecture 9 - Scoreboard

Multiple Predictors: BTB + Branch Direction Predictors

EECS 470 Lecture 8. P6 µarchitecture. Fall 2018 Jon Beaumont Core 2 Microarchitecture

EECS 427 Lecture 13: Leakage Power Reduction Readings: 6.4.2, CBF Ch.3. EECS 427 F09 Lecture Reminders

[Krishna, 2(9): September, 2013] ISSN: Impact Factor: INTERNATIONAL JOURNAL OF ENGINEERING SCIENCES & RESEARCH TECHNOLOGY

CSE502: Computer Architecture CSE 502: Computer Architecture

Clock-Powered CMOS: A Hybrid Adiabatic Logic Style for Energy-Efficient Computing

8-bit Microcontroller with 2K Bytes In-System Programmable Flash. ATtiny20

Instructor: Dr. Mainak Chaudhuri. Instructor: Dr. S. K. Aggarwal. Instructor: Dr. Rajat Moona

EECS 470. Tomasulo s Algorithm. Lecture 4 Winter 2018

Datapath Components. Multipliers, Counters, Timers, Register Files

Computer Architecture and Organization:

Unit-6 PROGRAMMABLE INTERRUPT CONTROLLERS 8259A-PROGRAMMABLE INTERRUPT CONTROLLER (PIC) INTRODUCTION

How a processor can permute n bits in O(1) cycles

Novel Low-Overhead Operand Isolation Techniques for Low-Power Datapath Synthesis

ECOM 4311 Digital System Design using VHDL. Chapter 9 Sequential Circuit Design: Practice

Department Computer Science and Engineering IIT Kanpur

Parallel architectures Electronic Computers LM

A LOW POWER DESIGN FOR ARITHMETIC AND LOGIC UNIT

2002 IEEE International Solid-State Circuits Conference 2002 IEEE

Topics Introduction to Microprocessors

8-bit Microcontroller with 4K Bytes In-System Programmable Flash and Boost Converter. ATtiny43U. Preliminary

ELEC 204 Digital Systems Design

EE241 - Spring 2004 Advanced Digital Integrated Circuits. Announcements. Borivoje Nikolic. Lecture 15 Low-Power Design: Supply Voltage Scaling

OOO Execution & Precise State MIPS R10000 (R10K)

The Metrics and Designs of an Arithmetic Logic Function over

Microprocessor & Interfacing Lecture Programmable Interval Timer

EECS 470 Lecture 5. Intro to Dynamic Scheduling (Scoreboarding) Fall 2018 Jon Beaumont

Vector Arithmetic Logic Unit Amit Kumar Dutta JIS College of Engineering, Kalyani, WB, India

Evolution of DSP Processors. Kartik Kariya EE, IIT Bombay

Architectural Core Salvaging in a Multi-Core Processor for Hard-Error Tolerance

CZ3001 ADVANCED COMPUTER ARCHITECTURE

Tomasolu s s Algorithm

Advanced Digital Logic Design

Tomasulo s Algorithm. Tomasulo s Algorithm

8-bit Atmel tinyavr Microcontroller with 16K Bytes In-System Programmable Flash. ATtiny1634

CSE502: Computer Architecture CSE 502: Computer Architecture

CS61C : Machine Structures

Transcription:

RISC Central Processing Unit Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C. Spring, 2014 ldvan@cs.nctu.edu.tw http://www.cs.nctu.edu.tw/~ldvan/ Source: Prof. M. Morris Mano and Prof. Charles R. Kime, Logic and Computer Design Fundamentals, 3rd Edition, 2004, Prentice Hall.

Outline Introduction Pipelined Datapath Pipelined Control The Reduced Instruction Set Computer (RISC) Summary 2

Introduction CPU: Datapath and control unit Datapath: Consist of a function unit, regs, and internal buses May be nonpiplined or pipelined Control unit: Consist of a program counter, an instr reg, and control logic May be hardwired, microprogrammed, or pipelined (if the datapath is pipelined) 3

Conventional datapath v.s. Pipelined datapath Fig 12-1 4

Detailed block diagram of the pipelined datapath: the increased cost: the pipeline platforms Fig 12-2 5

Pipeline Execution Pattern (1/2) Execution of pipeline -ops: Fig 12-3 6

Pipeline Execution Pattern (2/2) In the first two clock cycles, not all of the pipeline stages are active. => filling In the next five clock cycles, all stages of the pipeline are active. => fully utilized In the last two clock cycles, not all pipeline stages are active. => emptying Speedup = (7 12)/ (9 5) = 1.9 More pipelines, much better?? No The delay contributed by the pipeline platforms The difference between the delay of the logic assigned to each stage Thus, there exists one optimized pipelined stages. 7

Pipelined Control Based on the single-cycle computer: (hardwired control) Fig 10-15 Fig 12-2 8

Block diagram of pipelined computer: 9

Pipeline Stages Stage 1: Instr fetch (IF) Stage 2: Instr decoder & reg file read (DOF) (decode & operand fetch) Stage 3: The function unit & data mem read and write (EX) Stage 4: Reg file write (WB) Pipeleine Principle: The location of the pipeline platforms has balanced the partitioning of the delays. Timing: 5 ns/stage 200 MHz, speedup = 3.4 (w.r.t single-cycle) 10

Pipeline Programming and Performance (1/3) E.g.: Load constants 1 ~ 7 into regs R1 ~ R7 1 LDI R1, 1 2 LDI R2, 2 3 LDI R3, 3 4 LDI R4, 4 5 LDI R5, 5 6 LDI R6, 6 7 LDI R7, 7 11

Pipeline Programming and Performance (2/3) In the first 4 clk periods: 20 ns 1/4 + 1/2 + 3/4 + 1 = 2.5 instrs completed Overall time: 50 ns 10 clk cycles for 7 instrs Speedup = (7 17) / 50 = 2.38 Filling: the first 3 clks Fully utilized: the next 4 clks Speedup = (4 17) / 20 = 3.4 Emptying: the last 3 clks 12

Pipeline Programming and Performance (3/3) For a k-stage pipelined computer: The speedup is not k w.r.t. the single-cycle computer The delays cannot be divided into k equal pieces. The delays of the added pipeline platforms The delay of the function unit is larger than that of ideal k equal delays. The filling and emptying of the pipeline Data hazard Control hazard 13

Design goal: The Reduced Instruction Set Computer A RISC with a pipelined datapath and control unit The instr set arch: load/store mem access, 4 addressing modes, A single instr format length, Instrs that require only elementary ops. The ops, resembling those that can be performed by the single-cycle computer, can be performed by a single pass through the pipeline. 14

Instruction Set Architecture The CPU regs accessible to the programmer: Fig12-6 Reg file: 32 regs, 32 bits/reg, R0 = 0 The size of the reg file: RISC > CISC, load/store instr set arch PC: 32 bits No stack pointer or status reg 15

Instruction Format Instr formats: 3-reg type 2-reg type Branch: target addr = PC + target offset 16

Instructions (1/2) 17

Instructions (2/2) All of the ops are elementary and can be described by a single reg transfer statement. The only ops that can access memory: Load & Store The immediate field: 15 bits 32 bits and using zero fill or sign extension BZ, BNZ, SLT: handle the absence of stored versions of status bits JML: Jump and Link 18

Addressing Modes 4 addressing modes: specified by the opcode i. Register: the 3-operand data manipulation instrs ii. Register indirect: load and store instrs iii. Immediate: the 2-reg format instrs iv. Relative: branch and jump instrs Implement an addressing mode not directly provided: Use a sequence of RISC instrs E.g.: Indexed addressing, R15 M[R5 + 0 I] AIU R9, R5, I LD R15, R9 19

Datapath Organization The Pipelined computer in Fig 12-4: 16-bit version 20

Modifications of datapath: Fig 12-4 Fig 12-8: 32-bit version Register file Function unit Bus structure Modifications of control unit: Instruction decoder Control logic related to the PC Modified Datapath and Control Unit Pipeline platforms 21

Register File and Function Unit Reg file: 16 16-bit regs & all regs are identical in function 32 32-bit regs & R0 = 0 edge triggered read-after-write reg file Function unit: ALU: 16 bits 32 bits Shifter: Single-bit position shifter Barrel shifter with lsr or lsl of 0 ~ 31 positions (SH: IR[4:0]) 22

32-bit Barrel Shifter Left/right: a control signal decoded from OPCODE SH: = IR(4:0), the shift amount field Perform both the left and right shift by using a right rotate: p-position right shift rotate p position to the right p-position left shift rotate 64 p position to the right 23

Bus structure: Bus Structure zero fill constant unit: CS = 0, zero fill ; CS = 1, sign extension 0 IM se IM MUX A is added: provide a path for PC 1 to the reg file for implementing JML instr Jump and Link: PC PC + se IM, R[DR] PC + 1 MUX D is extended: help implement SLT instr Set if Less Than: If R[SA] < R [SB] then R[DR] = 1 24

Instruction Decoder Instruction decoder: to deal with the new instr set SH is added as an IR field. A 1-bit CS field is added to the instr decoder. A 1-bit MA field is added to the instr decoder. MD is expanded to two bits. A new pipeline platform for SH & expanded 2-bit platforms for MD 25

Control Logic (1/2) Control logic related to the PC: Permit the loading of addrs into the PC for implementing branches and jumps MUX C: in EX stage, selects from 3 different sources for the next value of PC (BS, PS) PC + 1 BrA: for branches and jumps R[AA]: for reg jump Pipeline regs PC 1 & PC 2 PC PC + 1 + se IM PC R[AA] 26

Control Logic (2/2) 27

Control Words for Instrs 28

29

Data Hazards Data hazard example: Solutions of data hazard: Program-based solution Data hazard stall Data forwarding 30

Program-Based Solution Disadv. of program-based sol.: The program is longer (unless some unrelated instrs may be placed in the NOP positions) Reduce the throughput 31

Data Hazard Stall (1/4) Data hazard stall: HW-based sol. 32

Data Hazard Stall (2/4) When an operand is found at the DOF stage that has not been written back yet, the associated execution and write-back are delayed by stalling the pipeline flow in IF and DOF for one clock cycle. The pipeline is said to be stalled, i.e., contain a bubble in subsequent clock cycles and stages for that instr. Disadv.: Has the same throughput penalty as the program w/ the NOPs 33

Data Hazard Stall (3/4) The following events must all occur for HA. MA in the DOF stage must be 0, meaning that the A operand is coming from the register file. AA in the DOF stage equals DA in the EX stage, meaning that there is potentially a register being read in the DOF stage that is to be written in the next clock cycle. RW in the EX stage is 1, meaning that register DA in the EX stage will definitely be written in WB during the next clock cycle. The OR of all bits of DA is 1, meaning that the register to be written is not R0 and so is a register that must be written before being read. 34

Data Hazard Stall (4/4) Pipelined RISC with Data hazard stall: Added or modified hardware: Data hazard detection: DHS DHS HA HB HA MA HB MB DOF DOF ( DA ( DA EX EX AA BA DOF DOF ) RW ) RW EX EX 4 i 0 4 i 0 ( DA ( DA EX EX ) ) i i Pipeline stalling: DHS is inverted to initiate a bubble in the pipeline for the instr currently in the IR and to stop the PC and IR from changing. 35

36

Data Forwarding (1/2) Data forwarding: HW-based sol. 37

Data Forwarding (2/2) Pipelined RISC w/ Data forwarding: Added or modified hardware: Data hazard detection: HA, HB Data forwarding: The information needed to form the result is available on the inputs to the pipeline platform that provides the inputs to MUX D. MUX D is added to produce the result on Bus D Add an additional input to MUX A & MUX B from Bus D 38

39

Control Hazards Control hazard example: If R1 = 0 1 BZ R1, 18 2 MOVA R2, R3 3 MOVA R1, R2 20 MOVA R5, R6 Solutions of control hazard: Program-based solution Branch hazard stall Branch prediction 40

Program-Based Solution 2 NOPs are inserted after the branch instr. (These wasted cycles can sometimes be avoided by rearranging the order of instrs.) 41

Branch Hazard Stall Branch hazard stall: HW-based sol. Just as in the case of the data hazard, a stall can be used to deal w/ the control hazard. Produce 2 bubbles after the branch instr Disadv.: The reduction in throughput will be the same as w/ the insertion of NOPs. 42

Branch Prediction (1/3) Branch prediction Simplest form: predict that branches will never be taken Instrs will be fetched and decoded and operands fetched on the basis of +1 to the value of the PC. If the branch is not taken, the instrs already in the pipeline due to the prediction will be allowed to proceed. If the branch is taken, the instrs following the branch instr need to be cancelled. The cancellation may be done by inserting bubbles into EX & WB stages. 43

Branch Prediction (2/3) E.g.: Branch prediction with branch non-taken Figure 12-16, p.555 If the branch is taken 44

Branch Prediction (3/3) Pipelined RISC w/ Branch prediction Figure 12-17, p.556 Added or modified hardware: Branch detection: EX stage the selection values on the inputs to MUX C are not 00 Instruction canceling: IF & DOF stages 45

46

Summary Widely discussed in the following topics. Pipelined Datapath Pieplined Control RISC Instruction Set Architecture Addressing Modes Datapath Data Hazard Control Hazard 47