11/4/2017 CIS-550 Advanced Computer Architecture Lecture 6: Multi-Cycle and Microprogrammed Microarchitectures Dr. Muhammad Abid DCIS, PIEAS Spring 2017.

Slides:



Advertisements
Similar presentations
Chapter 8: Central Processing Unit
Advertisements

Computer Architecture
Computer Architecture Lecture 6: Multi-Cycle and Microprogrammed Microarchitectures Prof. Onur Mutlu Carnegie Mellon University Spring 2014, 1/27/2014.
CS-447– Computer Architecture Lecture 12 Multiple Cycle Datapath
Chapter 16 Control Unit Operation No HW problems on this chapter. It is important to understand this material on the architecture of computer control units,
Microprogramming Andreas Klappenecker CPSC321 Computer Architecture.
1 COMP541 Sequencing – III (Sequencing a Computer) Montek Singh April 9, 2007.
Computer ArchitectureFall 2007 © October 3rd, 2007 Majd F. Sakr CS-447– Computer Architecture.
Chapter 16 Control Unit Implemntation. A Basic Computer Model.
Preparation for Midterm Binary Data Storage (integer, char, float pt) and Operations, Logic, Flip Flops, Switch Debouncing, Timing, Synchronous / Asynchronous.
Chapter 15 IA 64 Architecture Review Predication Predication Registers Speculation Control Data Software Pipelining Prolog, Kernel, & Epilog phases Automatic.
Lecture 16: Basic CPU Design
S. Barua – CPSC 440 CHAPTER 5 THE PROCESSOR: DATAPATH AND CONTROL Goals – Understand how the various.
Computing Systems The Processor: Datapath and Control.
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
Chapter 5 Basic Processing Unit
Lecture 16 Today’s topics: –MARIE Instruction Decoding and Control –Hardwired control –Micro-programmed control 1.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
1 COMP541 Multicycle MIPS Montek Singh Apr 4, 2012.
CSE 340 Computer Architecture Summer 2014 Basic MIPS Pipelining Review.
CS.305 Computer Architecture Enhancing Performance with Pipelining Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from.
5-1 Chapter 5—Processor Design—Advanced Topics Computer Systems Design and Architecture by V. Heuring and H. Jordan © 1997 V. Heuring and H. Jordan Chapter.
CPE232 Basic MIPS Architecture1 Computer Organization Multi-cycle Approach Dr. Iyad Jafar Adapted from Dr. Gheith Abandah slides
Computer Organization CDA 3103 Dr. Hassan Foroosh Dept. of Computer Science UCF © Copyright Hassan Foroosh 2002.
COMP541 Multicycle MIPS Montek Singh Mar 25, 2010.
Processor Data Path and Control How they work together.
1  2004 Morgan Kaufmann Publishers No encoding: –1 bit for each datapath operation –faster, requires more memory (logic) –used for Vax 780 — an astonishing.
Computer Architecture Lecture 7: Microprogrammed Microarchitectures Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 1/30/2013.
Types of Micro-operation  Transfer data between registers  Transfer data from register to external  Transfer data from external to register  Perform.
Computer Architecture Lecture 6: Multi-Cycle and Microprogrammed Microarchitectures Prof. Onur Mutlu Carnegie Mellon University Spring 2015, 1/28/2015.
Design a MIPS Processor (II)
Controller Implementation
Design of Digital Circuits Lecture 14: Microprogramming
Design of Digital Circuits Lecture 15: Pipelining
Design of Digital Circuits Lecture 13: Multi-Cycle Microarch.
Computer Organization and Architecture + Networks
CS161 – Design and Architecture of Computer Systems
Systems Architecture I
Computer Organization & Design Microcode for Control Sec. 5
15-740/ Computer Architecture Lecture 7: Pipelining
Overview Introduction General Register Organization Stack Organization
Computer Architecture Lecture 6: Multi-cycle Microarchitectures
Processor (I).
CS/COE0447 Computer Organization & Assembly Language
Design of the Control Unit for Single-Cycle Instruction Execution
Multiple Cycle Implementation of MIPS-Lite CPU
Chapter Five.
Processor: Finite State Machine & Microprogramming
Computer Architecture
Chapter Five The Processor: Datapath and Control
Computer Organization “Central” Processing Unit (CPU)
The Multicycle Implementation
MIPS Single and Multi Cycle Data Paths Mite 2
A Multiple Clock Cycle Instruction Implementation
Chapter Five The Processor: Datapath and Control
Control Unit Introduction Types Comparison Control Memory
The Multicycle Implementation
Systems Architecture I
The Processor Lecture 3.1: Introduction & Logic Design Conventions
Guest Lecturer TA: Shreyas Chand
Computer Architecture
Computer System Design Lecture 6
Multi-Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Chapter Four The Processor: Datapath and Control
Chapter 7 Microarchitecture
Chapter 7 Microarchitecture
Systems Architecture I
CS161 – Design and Architecture of Computer Systems
Chapter 4 The Von Neumann Model
Presentation transcript:

11/4/2017 CIS-550 Advanced Computer Architecture Lecture 6: Multi-Cycle and Microprogrammed Microarchitectures Dr. Muhammad Abid DCIS, PIEAS Spring 2017 1

Agenda for Today & Next Few Lectures 11/4/2017 Agenda for Today & Next Few Lectures Single-cycle Microarchitectures Multi-cycle and Microprogrammed Microarchitectures Pipelining Issues in Pipelining: Control & Data Dependence Handling, State Maintenance and Recovery, … Out-of-Order Execution Issues in OoO Execution: Load-Store Handling, … 2

Readings P&P, Revised Appendix C P&H, Appendix D Optional 11/4/2017 Readings P&P, Revised Appendix C Microarchitecture of the LC-3b Appendix A (LC-3b ISA) will be useful in following this P&H, Appendix D Mapping Control to Hardware Optional Maurice Wilkes, “The Best Way to Design an Automatic Calculating Machine,” Manchester Univ. Computer Inaugural Conf., 1951. 3

Readings for Next Lecture 11/4/2017 Readings for Next Lecture Pipelining P&H Chapter 4.5-4.8 Pipelined LC-3b Microarchitecture http://www.ece.cmu.edu/~ece447/s14/lib/exe/fetch.php?medi a=18447-lc3b-pipelining.pdf 4

11/4/2017 Recap of Last Lecture Intro to Microarchitecture: Single-cycle Microarchitectures Single-cycle vs. multi-cycle Instruction processing “cycle” Datapath vs. control logic Hardwired vs. microprogrammed control Performance analysis: Execution time equation Power analysis: Dynamic power equation Detailed walkthrough of a single-cycle MIPS implementation Datapath Control logic Critical path analysis (Micro)architecture design principles 5

Multi-Cycle Microarchitectures 11/4/2017 Multi-Cycle Microarchitectures 6

Multi-Cycle Microarchitectures 11/4/2017 Multi-Cycle Microarchitectures Goal: Let each instruction take (close to) only as much time it really needs Idea Determine clock cycle time independently of instruction processing time Each instruction takes as many clock cycles as it needs to take Multiple state transitions per instruction The states followed by each instruction is different 7

Remember: The “Process instruction” Step 11/4/2017 Remember: The “Process instruction” Step ISA specifies abstractly what AS’ should be, given an instruction and AS It defines an abstract finite state machine where State = programmer-visible state Next-state logic = instruction execution specification From ISA point of view, there are no “intermediate states” between AS and AS’ during instruction execution One state transition per instruction Microarchitecture implements how AS is transformed to AS’ There are many choices in implementation We can have programmer-invisible state to optimize the speed of instruction execution: multiple state transitions per instruction Choice 1: AS  AS’ (transform AS to AS’ in a single clock cycle) Choice 2: AS  AS+MS1  AS+MS2  AS+MS3  AS’ (take multiple clock cycles to transform AS to AS’) 8

Multi-Cycle Microarchitecture 11/4/2017 Multi-Cycle Microarchitecture AS = Architectural (programmer visible) state at the beginning of an instruction Step 1: Process part of instruction in one clock cycle Step 2: Process part of instruction in the next clock cycle … AS’ = Architectural (programmer visible) state at the end of a clock cycle 9

Single cycle vs Multi-Cycle 11/4/2017 Single cycle vs Multi-Cycle 2. Decode/ Register Read 1. Instruction Fetch 3. Execute 4. Memory 5. Reg. Write 2. Decode/ Register Read 1. Instruction Fetch 3. Execute 4. Memory 5. Reg. Write 10

Benefits of Multi-Cycle Design 11/4/2017 Benefits of Multi-Cycle Design Critical path design Can keep reducing the critical path independently of the worst- case processing time of any instruction Bread and butter (common case) design Can optimize the number of states it takes to execute “important” instructions that make up much of the execution time Balanced design No need to provide more capability or resources than really needed An instruction that needs resource X multiple times does not require multiple X’s to be implemented Leads to more efficient hardware: Can reuse hardware components needed multiple times for an instruction 11

Remember: Performance Analysis 11/4/2017 Remember: Performance Analysis Execution time of an instruction {CPI} x {clock cycle time} Execution time of a program Sum over all instructions [{CPI} x {clock cycle time}] {# of instructions} x {Average CPI} x {clock cycle time} Single cycle microarchitecture performance CPI = 1 Clock cycle time = long Multi-cycle microarchitecture performance CPI = different for each instruction Average CPI  hopefully small Clock cycle time = short Now, we have two degrees of freedom to optimize independently 12

A Multi-Cycle Microarchitecture A Closer Look 11/4/2017 A Multi-Cycle Microarchitecture A Closer Look 13

Multi-Cycle uArch Key Idea for Realization 11/4/2017 Multi-Cycle uArch Key Idea for Realization One can implement the “process instruction” step as a finite state machine that sequences between states and eventually returns back to the “fetch instruction” state A state is defined by the control signals asserted in it Control signals for the next state can be determined in current state 14

The Instruction Processing Cycle 11/4/2017 The Instruction Processing Cycle Fetch Decode Execute Memory R/ W Write Back 15

A Basic Multi-Cycle Microarchitecture 11/4/2017 A Basic Multi-Cycle Microarchitecture Instruction processing cycle divided into “states” A stage in the instruction processing cycle can take multiple states A multi-cycle microarchitecture sequences from state to state to process an instruction The behavior of the machine in a state is completely determined by control signals in that state The behavior of the entire processor is specified fully by a finite state machine In a state (clock cycle), control signals control two things: How the datapath should process the data How to generate the control signals for the next clock cycle 16

What Happens In A Clock Cycle? 11/4/2017 What Happens In A Clock Cycle? The control signals for the current state control two things: Processing in the data path Generation of control signals for the next cycle See Supplemental Figure 1 (next slide) Question: why not generate control signals for the current cycle in the current cycle? This will lengthen the clock cycle Why would it lengthen the clock cycle? See Supplemental Figure 2 17

11/4/2017 A Clock Cycle 18

11/4/2017 A Bad Clock Cycle! 19

MIPS Multicycle Concept 11/4/2017 MIPS Multicycle Concept Split the processing into five processing segments. 20

Intermediate Result Storage Requirements 11/4/2017 Intermediate Result Storage Requirements 21

Storage Registers Placement 11/4/2017 Storage Registers Placement 22

Preliminary Multicycle Design 11/4/2017 Preliminary Multicycle Design 23

Multicycle Design with PC & ALU Control 11/4/2017 Multicycle Design with PC & ALU Control 24

Complete Multicycle Design 11/4/2017 Complete Multicycle Design 25

Steps of an Instruction 11/4/2017 Steps of an Instruction Guidelines No step can contain more than one ALU operation No step can contain more than one register file access No step can contain more than one memory access 26

Instruction Fetch Step 11/4/2017 Instruction Fetch Step Fetch instructions from memory Compute address of next instruction 27

Instruction Fetch Step Signals 11/4/2017 Instruction Fetch Step Signals 28

Complete Multicycle Design 11/4/2017 Complete Multicycle Design 29

Instruction Decode and register fetch 11/4/2017 Instruction Decode and register fetch Read registers rs1 and rs2 from register file (every cycle) and store in RegA and RegB Compute branch target address in case it is used later (Instruction not known). 30

Complete Multicycle Design 11/4/2017 Complete Multicycle Design 31

11/4/2017 Execution Step Memory Reference Instruction 32

Complete Multicycle Design 11/4/2017 Complete Multicycle Design 33

11/4/2017 Execution Step Arithmetic/Logical Instruction 34

Complete Multicycle Design 11/4/2017 Complete Multicycle Design 35

11/4/2017 Execution Step Branch Instruction 36

Complete Multicycle Design 11/4/2017 Complete Multicycle Design 37

11/4/2017 Execution Step Jump Instruction 38

Complete Multicycle Design 11/4/2017 Complete Multicycle Design 39

Memory Reference Step Memory Reference (load) Memory Reference (store) 11/4/2017 Memory Reference Step Memory Reference (load) Memory Reference (store) 40

Complete Multicycle Design 11/4/2017 Complete Multicycle Design 41

Register File WB Step (loads) 11/4/2017 Register File WB Step (loads) 42

Complete Multicycle Design 11/4/2017 Complete Multicycle Design 43

Register File WB Step Arithmetic/logical instruction (R-type) 11/4/2017 Register File WB Step Arithmetic/logical instruction (R-type) 44

Complete Multicycle Design 11/4/2017 Complete Multicycle Design 45

Multicycle DataPath & Control Summary 11/4/2017 Multicycle DataPath & Control Summary 46

Complete Multicycle Design 11/4/2017 Complete Multicycle Design 47

11/4/2017 Defining Control Individual control lines like single cycle will not work! Control is more complicated since what we do in one cycle depends on instr + last cycle Two methods: FSM with no control store Microprogramming with control store 48

Finite State Machines Describe using FSM 11/4/2017 Finite State Machines Describe using FSM Set of states + two functions (next_state and output) Set of states: all possible values of internal storage Next_state: combination logic given inputs and/ or current state Output: produces a set of outputs from current states 49

11/4/2017 Finite State Machine Synchronous state machines: state change with clock edge, new state computed every clock cycle. 50

11/4/2017 FSM Implementation 51

FSM for Multicycle Implementation 11/4/2017 FSM for Multicycle Implementation 52

MIPS Finite-State Control Unit Table 11/4/2017 MIPS Finite-State Control Unit Table 53

FSM Implementation using PLA 11/4/2017 FSM Implementation using PLA 54

A Multi-Cycle Microarchitecture Micro-programmed A Closer Look 11/4/2017 A Multi-Cycle Microarchitecture Micro-programmed A Closer Look 55

How Do We Implement This(uprog)? 11/4/2017 How Do We Implement This(uprog)? Maurice Wilkes, “The Best Way to Design an Automatic Calculating Machine,” Manchester Univ. Computer Inaugural Conf., 1951. The concept of microcoded/microprogrammed machines 56

Microprogrammed Control Terminology 11/4/2017 Microprogrammed Control Terminology Control signals associated with the current state Microinstruction Act of transitioning from one state to another Determining the next state and the microinstruction for the next state Microsequencing Control store stores control signals for every possible state Store for microinstructions for the entire FSM Microsequencer determines which set of control signals will be used in the next clock cycle (i.e., next state) 57

A Simple LC-3 Control and Datapath 11/4/2017 A Simple LC-3 Control and Datapath 58

What Determines Next-State Control Signals? 11/4/2017 What Determines Next-State Control Signals? What is happening in the current clock cycle See the 10 control signals coming from “Control” block The instruction that is being executed IR[15:11] coming from the Data Path The privilege mode of the program that is executing PSR[15] from data path Whether the condition of a branch is met BEN bit coming from the datapath Whether the memory oper completing in the current cycle R bit coming from memory Whether or not an external device is requesting that the processor be interrupted INT coming from I/O device 59

A Simple LC-3 Control and Datapath 11/4/2017 A Simple LC-3 Control and Datapath 60

The State Machine for Multi-Cycle Processing 11/4/2017 The State Machine for Multi-Cycle Processing The behavior of the LC-3 uarch is completely determined by the 49 control signals and additional 9 bits that go into the control logic from the datapath/ I/O 49 control signals completely describe the state of the control structure We can completely describe the behavior of the LC-3 as a state machine, i.e. a directed graph of Nodes (one corresponding to each state) Arcs (showing flow from each state to the next state(s)) 61

An LC-3 State Machine Patt and Patel, Appendix C, Figure C.2 11/4/2017 An LC-3 State Machine Patt and Patel, Appendix C, Figure C.2 Each state must be uniquely specified Done by means of state variables 52 distinct states in this LC-3 state machine Encoded with 6 state variables Examples State 18 corresponds to the beginning of the instruction processing cycle Fetch phase: state 18  state 33  state 35 Decode phase: state 32 62

11/4/2017

LC-3 State Machine: Some Questions 11/4/2017 LC-3 State Machine: Some Questions How many states does the fastest instruction take? How many states does the slowest instruction take? Why does the BR take as long as it takes in the FSM? What determines the clock cycle time? 64

LC-3 Datapath Patt and Patel, Appendix C, Figure C.3 11/4/2017 LC-3 Datapath Patt and Patel, Appendix C, Figure C.3 Single-bus datapath design At any point only one value can be “gated” on the bus (i.e., can be driving the bus) Advantage: Low hardware cost: one bus Disadvantage: Reduced concurrency – if instruction needs the bus twice for two different things, these need to happen in different states Control signals (39 of them) determine what happens in the datapath in one clock cycle Patt and Patel, Appendix C, Table C.1 65

11/4/2017

11/4/2017

11/4/2017

LC-3 Datapath: Some Questions 11/4/2017 LC-3 Datapath: Some Questions How does instruction fetch happen in this datapath according to the state machine? What is the difference between gating and loading? Is this the smallest hardware you can design? 69

LC-3 Microprogrammed Control Structure 11/4/2017 LC-3 Microprogrammed Control Structure Patt and Patel, Appendix C, Figure C.4 Three components: Microinstruction, control store, microsequencer Microinstruction: control signals that control the datapath (39 of them) and help determine the next state (10 of them) Each microinstruction is stored in a unique location in the control store (a special memory structure) Microinstruction address corresponds to state number Microsequencer determines the address of the next microinstruction (i.e., next state) 70

11/4/2017

LC-3 Microsequencer Patt and Patel, Appendix C, Figure C.5 11/4/2017 LC-3 Microsequencer Patt and Patel, Appendix C, Figure C.5 The purpose of the microsequencer is to determine the address of the next microinstruction (i.e., next state) Next address depends on 10 control signals (plus 9 data signals) 72

11/4/2017

11/4/2017 Control Store

The Control Store: Some Questions 11/4/2017 The Control Store: Some Questions What control signals can be stored in the control store? vs. What control signals have to be generated in hardwired logic? i.e., what signal cannot be available without processing in the datapath? Remember the MIPS datapath One PCSrc signal depends on processing that happens in the datapath (bcond logic) 75

Variable-Latency Memory 11/4/2017 Variable-Latency Memory The ready signal (R) enables memory read/write to execute correctly Example: transition from state 33 to state 35 is controlled by the R bit asserted by memory when memory data is available 76

The Power of Abstraction 11/4/2017 The Power of Abstraction The concept of a control store of microinstructions enables the hardware designer with a new abstraction: microprogramming The designer can translate any desired operation to a sequence of microinstructions All the designer needs to provide is The sequence of microinstructions needed to implement the desired operation The ability for the control logic to correctly sequence through the microinstructions Any additional datapath control signals needed (no need if the operation can be “translated” into existing control signals) 77

Advantages of Microprogrammed Control 11/4/2017 Advantages of Microprogrammed Control Allows a very simple design to do powerful computation by controlling the datapath (using a sequencer) High-level ISA translated into microcode (sequence of microinstructions) Enables easy extensibility of the ISA Can support a new instruction by changing the microcode Can support complex instructions as a sequence of simple microinstructions If I can sequence an arbitrary instruction then I can sequence an arbitrary “program” as a microprogram sequence will need some new state (e.g. loop counters) in the microcode for sequencing more elaborate programs 78

Update of Machine Behavior 11/4/2017 Update of Machine Behavior The ability to update/patch microcode in the field (after a processor is shipped) enables Ability to add new instructions without changing the processor! Ability to “fix” buggy hardware implementations Examples IBM 370 Model 145: microcode stored in main memory, can be updated after a reboot IBM System z: Similar to 370/145. Heller and Farrell, “Millicode in an IBM zSeries processor,” IBM JR&D, May/Jul 2004. B1700 microcode can be updated while the processor is running User-microprogrammable machine! 79

Multi-Cycle vs. Single-Cycle uArch 11/4/2017 Multi-Cycle vs. Single-Cycle uArch Advantages Disadvantages You should be very familiar with this right now 80

Microprogrammed vs. Hardwired Control 11/4/2017 Microprogrammed vs. Hardwired Control Advantages Disadvantages You should be very familiar with this right now 81

The Microsequencer: Some Questions 11/4/2017 The Microsequencer: Some Questions When is the IRD signal asserted? What happens if an illegal instruction is decoded? What are condition (COND) bits for? How is variable latency memory handled? How do you do the state encoding? Minimize number of state variables (~ control store size) Start with the 16-way branch Then determine constraint tables and states dependent on COND 82

11/4/2017 Can We Do Better? What limitations do you see with the multi-cycle design? Limited concurrency Some hardware resources are idle during different phases of instruction processing cycle “Fetch” logic is idle when an instruction is being “decoded” or “executed” Most of the datapath is idle when a memory access is happening 83

Can We Use the Idle Hardware to Improve Concurrency? 11/4/2017 Can We Use the Idle Hardware to Improve Concurrency? Goal: Concurrency  throughput (more “work” completed in one cycle) Idea: When an instruction is using some resources in its processing phase, process other instructions on idle resources not needed by that instruction E.g., when an instruction is being decoded, fetch the next instruction E.g., when an instruction is being executed, decode another instruction E.g., when an instruction is accessing data memory (ld/st), execute the next instruction E.g., when an instruction is writing its result into the register file, access data memory for the next instruction 84