Computer Architecture Chapter 5. Fall 2005 Department of Computer Science Kent State University

Similar documents
The single-cycle design from last time

The final datapath. M u x. Add. 4 Add. Shift left 2. PCSrc. RegWrite. MemToR. MemWrite. Read data 1 I [25-21] Instruction. Read. register 1 Read.

The extra single-cycle adders

EEC 483 Computer Organization

1048: Computer Organization

LECTURE 6. Multi-Cycle Datapath and Control

CSE 2021 COMPUTER ORGANIZATION

CPE 335. Basic MIPS Architecture Part II

Review. A single-cycle MIPS processor

Systems Architecture I

RISC Processor Design

Processor: Multi- Cycle Datapath & Control

CSE 2021 COMPUTER ORGANIZATION

CSE Introduction to Computer Architecture Chapter 5 The Processor: Datapath & Control

Lecture 5 and 6. ICS 152 Computer Systems Architecture. Prof. Juan Luis Aragón

1048: Computer Organization

CSSE232 Computer Architecture I. Mul5cycle Datapath

Topic #6. Processor Design

Review Multicycle: What is Happening. Controlling The Multicycle Design

Review: Computer Organization

Exceptions and interrupts

CC 311- Computer Architecture. The Processor - Control

Multiple Cycle Data Path

Points available Your marks Total 100

Inf2C - Computer Systems Lecture 12 Processor Design Multi-Cycle

ﻪﺘﻓﺮﺸﻴﭘ ﺮﺗﻮﻴﭙﻣﺎﻛ يرﺎﻤﻌﻣ MIPS يرﺎﻤﻌﻣ data path and ontrol control

Chapter 5: The Processor: Datapath and Control

Lecture 7. Building A Simple Processor

PART I: Adding Instructions to the Datapath. (2 nd Edition):

MIPS Architecture. Fibonacci (C) Fibonacci (Assembly) Another Example: MIPS. Example: subset of MIPS processor architecture

ALUOut. Registers A. I + D Memory IR. combinatorial block. combinatorial block. combinatorial block MDR

Multi-cycle Approach. Single cycle CPU. Multi-cycle CPU. Requires state elements to hold intermediate values. one clock cycle or instruction

1048: Computer Organization

RISC Architecture: Multi-Cycle Implementation

Computer Architecture

Computer Architecture

Quiz #1 EEC 483, Spring 2019

COMPUTER ORGANIZATION AND DESIGN. The Hardware/Software Interface. Chapter 4. The Processor: A Based on P&H

ECE369. Chapter 5 ECE369

Lecture 6: Microprogrammed Multi Cycle Implementation. James C. Hoe Department of ECE Carnegie Mellon University

Processor (I) - datapath & control. Hwansoo Han

CO Computer Architecture and Programming Languages CAPL. Lecture 18 & 19

CS 251, Spring 2018, Assignment 3.0 3% of course mark

RISC Design: Multi-Cycle Implementation

Design of the MIPS Processor

The multicycle datapath. Lecture 10 (Wed 10/15/2008) Finite-state machine for the control unit. Implementing the FSM

EEC 483 Computer Organization

CPE 335 Computer Organization. Basic MIPS Architecture Part I

RISC Architecture: Multi-Cycle Implementation

The Processor: Datapath & Control

ENE 334 Microprocessors

Processor (multi-cycle)

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 4: Datapath and Control

Chapter 5 Solutions: For More Practice

LECTURE 5. Single-Cycle Datapath and Control

What do we have so far? Multi-Cycle Datapath

Design of the MIPS Processor (contd)

EECE 417 Computer Systems Architecture

CS 251, Winter 2018, Assignment % of course mark

Lets Build a Processor

TDT4255 Friday the 21st of October. Real world examples of pipelining? How does pipelining influence instruction

MIPS Architecture. An Example: MIPS. From the Harris/Weste book Based on the MIPS-like processor from the Hennessy/Patterson book

Major CPU Design Steps

Systems Architecture

ECE 313 Computer Organization FINAL EXAM December 14, This exam is open book and open notes. You have 2 hours.

Computer Science 141 Computing Hardware

The Processor. Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut. CSE3666: Introduction to Computer Architecture

Pipelining. Chapter 4

Lecture 8: Control COS / ELE 375. Computer Architecture and Organization. Princeton University Fall Prof. David August

Prof. Kozyrakis. 1. (10 points) Consider the following fragment of Java code:

Chapter 4. The Processor. Computer Architecture and IC Design Lab

Lecture 9: Microcontrolled Multi-Cycle Implementations

CS 251, Winter 2018, Assignment % of course mark

CS 251, Winter 2019, Assignment % of course mark

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

Enhanced Performance with Pipelining

EXAMINATIONS 2010 END OF YEAR NWEN 242 COMPUTER ORGANIZATION

Chapter 6 Enhancing Performance with. Pipelining. Pipelining. Pipelined vs. Single-Cycle Instruction Execution: the Plan. Pipelining: Keep in Mind

Note- E~ S. \3 \S U\e. ~ ~s ~. 4. \\ o~ (fw' \i<.t. (~e., 3\0)

Lab 8 (All Sections) Prelab: ALU and ALU Control

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Data Paths and Microprogramming

ECE232: Hardware Organization and Design

Chapter 6: Pipelining

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

COMP303 - Computer Architecture Lecture 8. Designing a Single Cycle Datapath

THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY Computer Organization (COMP 2611) Spring Semester, 2014 Final Examination

Control Unit for Multiple Cycle Implementation

Single vs. Multi-cycle Implementation

Instruction fetch. MemRead. IRWrite ALUSrcB = 01. ALUOp = 00. PCWrite. PCSource = 00. ALUSrcB = 00. R-type completion

Multicycle Approach. Designing MIPS Processor

CSE 2021: Computer Organization Fall 2010 Solution to Assignment # 3: Multicycle Implementation

CENG 3420 Lecture 06: Datapath

EECS150 - Digital Design Lecture 10- CPU Microarchitecture. Processor Microarchitecture Introduction

ECS 154B Computer Architecture II Spring 2009

Review: Abstract Implementation View

Animating the Datapath. Animating the Datapath: R-type Instruction. Animating the Datapath: Load Instruction. MIPS Datapath I: Single-Cycle

COMP303 - Computer Architecture Lecture 10. Multi-Cycle Design & Exceptions

CENG 3420 Computer Organization and Design. Lecture 06: MIPS Processor - I. Bei Yu

Alternative to single cycle. Drawbacks of single cycle implementation. Multiple cycle implementation. Instruction fetch

Transcription:

Compter Architectre Chapter 5 Fall 25 Department of Compter Science Kent State University

The Processor: Datapath & Control Or implementation of the MIPS is simplified memory-reference instrctions: lw, sw arithmetic-logical instrctions: add, sb, and, or, slt control flow instrctions: beq, j Generic implementation se the program conter (PC) to spply the instrction address and fetch the instrction from memory (and pdate the PC) decode the instrction (and read registers) eecte the instrction Eec Fetch PC = PC+4 All instrctions (ecept j) se the ALU after reading the registers Decode How? memory-reference? arithmetic? control flow?

Abstract / Simplified View 4 Add Add Data PC Address memory Register # Registers ALU Address Register # Register # Data memory Data Two types of fnctional nits: elements that operate on vales (combinational) elements that contain state (seqential)

More Implementation Details

Fetching s Fetching instrctions involves reading the instrction from the Memory pdating the PC to hold the address of the net instrction 4 Add Memory PC Address PC is pdated every cycle, so it does not need an eplicit write control signal Memory is read every cycle, so it doesn t need an eplicit read control signal

Fetch-Decode-Eecte In order to eecte an instrction we mst Fetch the instrction from memory Determine what the instrction is (decode) Eecte it Fetch and decode are the same for all instrctions Eecte depends on the type of instrction

Formats op rs rt rd shamt fnct 3:26 25:2 2:6 5: :6 5: op rs rt immed 3:26 25:2 2:6 5: op addr 3:26 25:

Decoding s Decoding instrctions involves sending the fetched instrction s opcode and fnction field bits to the control nit Control Unit Addr Register Addr 2 File Write Addr Write Data Data Data 2 reading two vales from the Register File Register File addresses are contained in the instrction

Eecting Load and Store Load Fetch operand (base address) from register Compte effective address from memory Write reslt back to register Store Fetch operands from registers Compte effective address Write to memory

Eecting Arithmetic/Logic Arithmetic/logic (add, sb, and, or, slt) Fetch operands from registers Perform operation Write reslt back to register

Eecting Branch and Jmp Conditional branch (beq) Fetch operands from registers Compare operands If eqal add displacement to PC Jmp (j) Write new vale to PC

ALU s Components Register File ALU Operation Use instrction fields to select registers sorce registers and send them to ALU Send ALU reslt to destination register

Components for ALU Instrs Register nmbers Data 5 3 register 5 5 register 2 Registers Write register Write 2 Data ALU control Zero ALU ALU reslt RegWrite a. Registers b. ALU

ALU Datapath register register 2 Registers Write register Write RegWrite 2 3 ALU operation Zero ALU ALU reslt

Memory Access Components Register File ALU Data Memory Sign-Etension Unit Operation ALU adds base register and sign-etended immediate Send ALU reslt to memory as the address the vale from memory into the destination register (lw) or write the vale from the sorce register into memory (sw)

Components for Mem Access MemWrite Address Write Data memory 6 Sign 32 etend Mem a. Data memory nit b. Sign-etension nit

Memory Access Datapath register register 2 Registers Write register Write RegWrite 2 3 ALU operation Zero ALU ALU reslt Address Write MemWrite Data memory 6 Sign 32 etend Mem

Branches Components Register File ALU Program Conter (PC) Adder Sign-Etension Unit Operation Send sorce register vales to ALU for comparison Adder comptes branch target address Control logic decides whether branch is taken or not

Branch Datapath PC + 4 from instrction path Add Sm Branch target Shift left 2 register register 2 Registers Write register Write RegWrite 2 6 Sign 32 etend 3 ALU ALU operation Zero To branch control logic

Ptting It All Together PCSrc 4 Add RegWrite Shift left 2 Add ALU reslt M PC address [3 ] memory [25 2] [2 6] M [5 ] RegDst [5 ] register register 2 Write register Write 2 Registers 6 Sign 32 etend ALUSrc M ALU control ALU Zero ALU reslt MemWrite Address Write Data memory Mem MemtoReg M [5 ] ALUOp

Control Unit Control nit takes an instrction as inpt and prodces control signals as otpt Types of control signals Mltipleor selector signals Write enables for state elements Control signals for other blocks (ALU, etc.) In a single-cycle path the control nit is simple, jst look p instrction in a table

Control Signals RegDst: Selects either rd or rt as the destination register RegWrite: The vale on the write port will be written into the register specified by the write register inpt when asserted ALUOp: Selects ALU operation ALUSrc: Selects the second ALU inpt to be either the second register otpt or the sign-etended immediate vale

Control Signals (cont'd) PCSrc: Selects new PC as either PC + 4 or the otpt of the branch target adder This signal is derived from the Branch control signal and the ALU's Zero otpt Mem/MemWrite: Cases memory to perform a read/write operation when asserted MemToReg: Selects either the ALU otpt or the memory otpt as the inpt into the register file

ALU Control In order to simplify design of the control nit we give the ALU its own control logic The ALU control block takes a 2-bit inpt from the control nit (ALUOp) and the fnct field from the instrction and prodces the ALU control signals

ALU Control Signals ALUOp fnct Field ALU Fnction ALU Inpts lw Add sw Add beq Sbtract add Add sb Sbtract and AND or OR slt Set on less than

Operation of Control Unit ALU lw sw beq ALUOp ALUSrc Branch Mem MemWrite MemToReg RegDst RegWrite

Datapath with Control Unit 4 Add [3 26] Control RegDst Branch Mem MemtoReg ALUOp MemWrite ALUSrc RegWrite Shift left 2 Add reslt ALU M PCSrc PC address memory [3 ] [25 2] [2 6] [5 ] M register Write register 2 Registers Write 2 register M Zero ALU ALU reslt Address Write Data memory M [5 ] 6 Sign 32 etend ALU control [5 ]

Jmp s The nconditional branch instrction (j) comptes its branch target differently from the conditional branch instrction (beq) Branch target address is: Top 4 bits of PC + 4 26-bit immediate vale Two zero bits

Datapath with Jmp [25 ] Shift Jmp address [3 ] left 2 26 28 4 Add PC+4 [3 28] [3 26] Control RegDst Jmp Branch Mem MemtoReg ALUOp MemWrite ALUSrc RegWrite Shift left 2 Add reslt ALU M M PC address memory [3 ] [25 2] [2 6] [5 ] M register Write register 2 Registers Write 2 register M Zero ALU ALU reslt Address Write Data memory M [5 ] 6 Sign 32 etend ALU control [5 ]

Performance The single-cycle path eectes each instrction in jst one cycle CPI is., which is optimal However, minimm clock cycle time is determined by slowest instrction In practice the eection time can vary considerably between instrctions making a single-cycle implementation a poor choice

Using Mltiple Cycles A mlti-cycle path splits instrction eection into mltiple steps, where each step take one cycle If an instrction doesn't need a step it skips it, so different instrctions rn for different nmbers of cycles Slow instrctions don't slow down the entire processor Control nit becomes more complicated Hardware can be shared between steps

Mlticycle Datapath () PC Address Memory Data or register Memory register Data Register # Registers Register # Register # A B ALU ALUOt

Mlticycle Differences A fnctional nit can be sed more than once in the eection of an instrction, so long as those ses occr in different steps memory and memory are combined into a single nit ALU takes over for the two separate adders Additional registers are needed to save information between steps

Mlticycle Registers register (IR): hold the instrction dring its eection Memory register (MDR): hold the read from memory for one cycle A: hold sorce register for one cycle B: hold sorce register for one cycle ALUOt: hold ALU otpt for one cycle

Mlticycle Datapath (2) PC M Address Write Memory MemData [25 2] [2 6] [5 ] register [5 ] Memory register M [5 ] M 6 register register 2 Registers Write register Write Sign etend 2 32 Shift left 2 A B 4 M M 2 3 Zero ALU ALU reslt ALUOt

Mlticycle Datapath (3) IorD Mem MemWrite IRWrite RegDst RegWrite ALUSrcA PC M Address Write Memory MemData [25 2] [2 6] [5 ] register [5 ] Memory register [5 ] M M 6 register register 2 Registers Write register Write Sign etend 2 32 Shift left 2 A B 4 M M 2 3 ALU control Zero ALU ALU reslt ALUOt [5 ] MemtoReg ALUSrcB ALUOp

New Control Signals ALUSrcA: selects first ALU operand to be either the PC or the A register ALUSrcB: selects second ALU operand from: B register, constant 4, sign-etended immediate, sign-etended and shifted immediate MemtoReg: selects register file write as coming from either ALUOt or MDR IorD: selects the memory address as coming from either PC or ALUOt

New Control Signals (cont'd) IRWrite: If asserted the memory otpt is written to IR PCSorce: Selects the new vale for the PC from: ALU, ALUOt, jmp target address PCWrite: If asserted the PC is written PCWriteCond: If asserted and the zero otpt from the ALU is then the PC is written

Eection Steps fetch decode and register fetch Eection, memory address comptation, or branch completion Memory access or R-type completion Memory read completion

Fetch Fetch instrction from memory IR Memory[PC] Increment the PC PC PC + 4

Decode Fetch operands from register file A Reg[IR[25:2]] B Reg[IR[2:6]] Compte branch target address ALUOt PC + (sign-etend(ir[5:]) << 2)

Eecte Load/store: Compte memory address ALUOt A + sign-etend(ir[5:]) R-type: Perform operation specified by instrction ALUOt A op B Branch: Compare registers and set PC if eqal if (A == B) PC ALUOt Jmp: Set PC to jmp target address PC {PC[3:28], (IR[25:] << 2)}

Memory Access Load: memory word into MDR MDR Memory[ALUOt] Store: Write B into memory Memory[ALUOt] B R-type: Write reslt to destination register Reg[IR[5:]] ALUOt

Memory Completion Load: Write reslt to destination register Reg[IR[2:6]] MDR

Mlticycle Datapath (4) PC M Address Write Memory MemData [25 2] [2 6] [5 ] register [5 ] Memory register PCWriteCond PCWrite IorD Otpts Mem MemWrite MemtoReg IRWrite Control Op [5 ] M [5 ] M PCSorce ALUOp ALUSrcB 6 ALUSrcA RegWrite RegDst [25 ] 26 28 Shift left 2 [3-26] PC [3-28] register register 2 Registers Write register Write Sign etend 2 32 Shift left 2 A B 4 M M 2 3 ALU control Zero ALU ALU reslt Jmp address [3-] ALUOt 2 M [5 ]

State Machine A state machine is a seqential logic device with: Set of states Net-state fnction which determines the net state from the crrent state and the inpts Otpt fnction which determines the otpts from the crrent state and possibly the inpts In a Moore machine the otpt depends only on the state; in a Mealy machine the otpt depends on the state and the inpts

Control with a State Machine The control nit for or mlticycle path will be a state machine The only inpt is the op field of the instrction; the otpts are the control signals Each step may have mltiple states if control signals depend on the instrction

Fetch and Decode States Start (Op = 'LW') or (Op = 'SW') fetch Mem ALUSrcA = IorD = IRWrite ALUSrcB = ALUOp = PCWrite PCSorce = (Op = R-type) (Op = 'BEQ') decode/ Register fetch ALUSrcA = ALUSrcB = ALUOp = (Op = 'JMP') Memory reference FSM (Figre 5.38) R-type FSM (Figre 5.39) Branch FSM (Figre 5.4) Jmp FSM (Figre 5.4)

Load and Store States 2 From state (Op = 'LW') or (Op = 'SW') Memory address comptation ALUSrcA = ALUSrcB = ALUOp = (Op = 'SW') 3 (Op = 'LW') Memory access 5 Memory access Mem IorD = MemWrite IorD = 4 Write-back step RegWrite MemtoReg = RegDst = To state (Figre 5.37)

R-Type States From state (Op = R-type) 6 Eection ALUSrcA = ALUSrcB = ALUOp = R-type completion 7 RegDst = RegWrite MemtoReg = To state (Figre 5.37)

Branch State From state (Op = 'BEQ') 8 ALUSrcA = ALUSrcB = ALUOp = PCWriteCond PCSorce = Branch completion To state (Figre 5.37)

Jmp State From state (Op = 'J') 9 Jmp completion PCWrite PCSorce = To state (Figre 5.37)

Complete State Machine 2 Memory address comptation ALUSrcA = ALUSrcB = ALUOp = Start fetch Mem ALUSrcA = IorD = IRWrite ALUSrcB = ALUOp = PCWrite PCSorce = 6 (Op = 'LW') or (Op = 'SW') Eection ALUSrcA = ALUSrcB = ALUOp= 8 (Op = R-type) Branch completion ALUSrcA = ALUSrcB = ALUOp = PCWriteCond PCSorce = decode/ register fetch (Op = 'BEQ') 9 ALUSrcA = ALUSrcB = ALUOp = (Op = 'J') Jmp completion PCWrite PCSorce = 3 (Op = 'LW') Memory access (Op = 'SW') 5 Memory access 7 R-type completion Mem IorD = MemWrite IorD = RegDst = RegWrite MemtoReg = 4 Write-back step RegDst = RegWrite MemtoReg =