LECTURE 6 Multi-Cycle Datapath and Control. SINGLE-CYCLE IMPLEMENTATION As we’ve seen, single-cycle implementation, although easy to implement, could.

Slides:



Advertisements
Similar presentations
Adding the Jump Instruction
Advertisements

1 Datapath and Control (Multicycle datapath) CDA 3101 Discussion Section 11.
1 Chapter Five The Processor: Datapath and Control.
The Processor: Datapath & Control
The Processor Data Path & Control Chapter 5 Part 2 - Multi-Clock Cycle Design N. Guydosh 2/29/04.
Chapter 5 The Processor: Datapath and Control Basic MIPS Architecture Homework 2 due October 28 th. Project Designs due October 28 th. Project Reports.
CSE378 Multicycle impl,.1 Drawbacks of single cycle implementation All instructions take the same time although –some instructions are longer than others;
1 5.5 A Multicycle Implementation A single memory unit is used for both instructions and data. There is a single ALU, rather than an ALU and two adders.
CMPUT Computer Organization and Architecture II1 CMPUT329 - Fall 2003 TopicI: Building a Multicycle Data Path and a Control Path for a Microprocessor.
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
Computer Structure - Datapath and Control Goal: Design a Datapath  We will design the datapath of a processor that includes a subset of the MIPS instruction.
331 W10.1Spring :332:331 Computer Architecture and Assembly Language Spring 2005 Week 10 Building a Multi-Cycle Datapath [Adapted from Dave Patterson’s.
The Multicycle Processor CPSC 321 Andreas Klappenecker.
1. 2 Multicycle Datapath  As an added bonus, we can eliminate some of the extra hardware from the single-cycle datapath. —We will restrict ourselves.
Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
Computer Architecture Chapter 5 Fall 2005 Department of Computer Science Kent State University.
Datapath and Control: MultiCycle Implementation. Performance of Single Cycle Machines °Assume following operation times: Memory units : 200 ps ALU and.
CPE232 Basic MIPS Architecture1 Computer Organization Multi-cycle Approach Dr. Iyad Jafar Adapted from Dr. Gheith Abandah slides
1 CS/COE0447 Computer Organization & Assembly Language Multi-Cycle Execution.
C HAPTER 5 T HE PROCESSOR : D ATAPATH AND C ONTROL M ULTICYCLE D ESIGN.
CDA 3101 Fall 2013 Introduction to Computer Organization Multicycle Datapath 9 October 2013.
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
MIPS processor continued. In Class Exercise Question Show the datapath of a processor that supports only R-type and jr reg instructions.
Multicycle Implementation
ECE-C355 Computer Structures Winter 2008 The MIPS Datapath Slides have been adapted from Prof. Mary Jane Irwin ( )
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Single-Cycle Datapath and Control.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
Elements of Datapath for the fetch and increment The first element we need: a memory unit to store the instructions of a program and supply instructions.
CS.305 Computer Architecture The Processor: Datapath and Control Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from.
MIPS processor continued
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
RegDst 1: RegFile destination No. for the WR Reg. comes from rd field. 0: RegFile destination No. for the WR Reg. comes from rt field.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 Part 3.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Design a MIPS Processor (II)
Multi-Cycle Datapath and Control
Single-Cycle Datapath and Control
IT 251 Computer Organization and Architecture
/ Computer Architecture and Design
Systems Architecture I
Multi-Cycle CPU.
D.4 Finite State Diagram for the Multi-cycle processor
Multi-Cycle CPU.
Basic MIPS Architecture
CS/COE0447 Computer Organization & Assembly Language
Multiple Cycle Implementation of MIPS-Lite CPU
MIPS processor continued
Multicycle Approach Break up the instructions into steps
The Multicycle Implementation
CSCI206 - Computer Organization & Programming
Chapter Five The Processor: Datapath and Control
Drawbacks of single cycle implementation
The Multicycle Implementation
Systems Architecture I
The Processor Lecture 3.2: Building a Datapath with Control
Vishwani D. Agrawal James J. Danaher Professor
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Processor: Multi-Cycle Datapath & Control
Multi-Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Chapter Four The Processor: Datapath and Control
Control Unit for Multiple Cycle Implementation
5.5 A Multicycle Implementation
Processor Design Datapath and Design.
Systems Architecture I
Control Unit for Multiple Cycle Implementation
FloorPlan for Multicycle MIPS
The Processor: Datapath & Control.
Presentation transcript:

LECTURE 6 Multi-Cycle Datapath and Control

SINGLE-CYCLE IMPLEMENTATION As we’ve seen, single-cycle implementation, although easy to implement, could potentially be very inefficient. In single-cycle, we define a clock cycle to be the length of time needed to execute a single instruction. So, our lower bound on the clock period is the length of the most- time consuming instruction. In our previous example, our jump instruction needs only 4ns but our clock period must be 13ns to accommodate the load word instruction!

MULTI-CYCLE IMPLEMENTATION We can get around some of the disadvantages by introducing a little more complexity to our datapath. Instead of viewing the instruction as one big task that needs to be performed, in multi-cycle the instructions are broken up into smaller fundamental steps. As a result, we can shorten the clock period and perform the instructions incrementally across multiple cycles. What are these fundamental steps? Well, let’s take a look at what our instructions actually need to do…

R-FORMAT STEPS An instruction is fetched from instruction memory and the PC is incremented. Reads two source register values from the register file. Performs the ALU operation on the register data operands. Writes the result of the ALU operation to the register file.

LOAD STEPS An instruction is fetched from instruction memory and the PC is incremented. Reads a source register value from the register file and sign-extend the 16 least significant bits of the instruction. Performs the ALU operation that computes the sum of the value in the register and the sign-extended immediate value from the instruction. Accesses data memory at the address of the sum from the ALU. Writes the result of the memory value to the register file.

STORE STEPS An instruction is fetched from instruction memory and the PC is incremented. Reads two source register values from the register file and sign-extend the 16 least significant bits of the instruction. Performs the ALU operation that computes the sum of the value in the register and the sign-extended immediate value from the instruction. Updates data memory at the address of the sum from the ALU.

BRANCH EQUAL STEPS An instruction is fetched from instruction memory and the PC is incremented. Reads two source register values from the register file and sign-extends the 16 least significant bits of the instruction and then left shifts it by two. The ALU performs a subtract on the data values read from the register file. The value of PC+4 is added with the sign-extended left-shifted by two immediate value from the instruction, which results in the branch target address. The Zero result from the ALU is used to decide which adder result to store into the PC.

JUMP STEPS An instruction is fetched from instruction memory and the PC is incremented. Concatenates the four most significant bits of the PC, the 26 least significant bits of the instruction, and two zero bits. Assigns the result to the PC.

GENERAL STEPS So, generally, we can say we need to perform the following steps: 1.Instruction Fetch Step. 2.Instruction Decode and Register Fetch Step. 3.Execution, Memory Address Computation, Branch Completion Step, or Jump Completion Step. 4.Memory Access or R-Type Instruction Completion Step. 5.Memory Read Completion Step.

MULTI-CYCLE DATAPATH Here is a general overview of our new multi-cycle datapath. We now have a single memory element that interacts with both instructions and data. Single ALU unit, no dedicated adders. Several temporary registers.

MULTI-CYCLE DATAPATH

These are some old datapath elements that we are already used to. Note, however, that the Memory element is now pulling double-duty as both the Instruction Memory and Data Memory element.

MULTI-CYCLE DATAPATH

New Temporary Registers: Instruction Register (IR) – holds the instruction after its been pulled from memory. Memory Data Register (MDR) – temporarily holds data grabbed from memory until the next cycle. A – temporarily holds the contents of read register 1 until the next cycle. B – temporarily holds the contents of read register 2 until the next cycle. ALUout – temporarily holds the contents of the ALU until the next cycle. Note: every register is written on every cycle except for the instruction register.

MULTI-CYCLE DATAPATH

The IorD control signal. Deasserted: The contents of PC is used as the Address for the memory unit. Asserted: The contents of ALUout is used as the Address for the memory unit.

MULTI-CYCLE DATAPATH

The RegDst control signal. Deasserted: The register file destination number for the Write register comes from the rt field. Asserted: The register file destination number for the Write register comes from the rd field.

MULTI-CYCLE DATAPATH

The MemToReg control signal. Deasserted: The value fed to the register file input comes from ALUout. Asserted: The value fed to the register file input comes from MDR.

MULTI-CYCLE DATAPATH

One of the changes we’ve made is that we’re using only a single ALU. We have no dedicated adders on the side. To implement this change, we need to add some multiplexors. ALUSrcA multiplexor chooses between the contents of PC or the contents of temporary register A as the first operand. ALUSrcB multiplexor chooses between the contents of temporary register B, the constant 4, the immediate field, or the left-shifted immediate field as the second operand.

MULTI-CYCLE DATAPATH AND CONTROL

1-Bit Signal NameEffect When DeassertedEffect When Asserted RegDstThe register file destination number for the Write register comes from the rt field. The register file destination number for the Write register comes from the rd field. RegWriteNoneWrite register is written with the value of the Write data input. ALUSrcAThe first ALU operand is PC.The first ALU operand is A register. MemReadNoneContent of memory at the location specified by the Address input is put on the Memory data output. MemWriteNoneMemory contents of the location specified by the Address input is replaced by the value on the Write data input.

MULTI-CYCLE DATAPATH AND CONTROL 1-Bit Signal NameEffect When DeassertedEffect When Asserted MemToRegThe value fed to the register file input is ALUout. The value fed to the register file input comes from Memory data register. IorDThe PC supplies the Address to the Memory element. ALUOut is used to supply the address to the memory unit. IRWriteNoneThe output of the memory is written into the Instruction Register (IR). PCWriteNoneThe PC is written; the source is controlled by PC-Source. PCWriteCondNoneThe PC is written if the Zero output from the ALU is also active.

MULTI-CYCLE DATAPATH AND CONTROL 2-bit SignalValueEffect ALUOp00The ALU performs an add operation. 01The ALU performs a subtract operation. 10The funct field of the instruction determines the operation. ALUSrcB00The second input to ALU comes from the B register. 01The second input to ALU is 4. 10The second input to the ALU is the sign-extended, lower 16 bits of the Instruction Register (IR). 11The second input to the ALU is the sign-extended, lower 16 bits of the IR shifted left by 2 bits. PCSource00Output of the ALU (PC+4) is sent to the PC for writing. 01The contents of ALUOut (the branch target address) are sent to the PC for writing. 10The jump target address (IR[25-0] shifted left 2 bits and concatenated with PC + 4[31-28]) is sent to the PC for writing.

MULTI-CYCLE DATAPATH AND CONTROL Ok, so we already observed that our instructions can be roughly broken up into the following steps: 1.Instruction Fetch Step. 2.Instruction Decode and Register Fetch Step. 3.Execution, Memory Address Computation, Branch Completion Step, or Jump Completion Step. 4.Memory Access or R-Type Instruction Completion Step. 5.Memory Read Completion Step. Instructions take 3-5 of the steps to complete. The first two are performed identically in all instructions.

INSTRUCTION FETCH STEP IR = Memory[PC]; PC = PC + 4; Operations: Send contents of PC to the Memory element as the Address. Read instruction from Memory. Write instruction into IR for use in next cycle. Increment PC by 4. So Fetch!

INSTRUCTION FETCH STEP SignalValue PCWrite IorD MemRead MemWrite IRWrite PCSource ALUOp ALUSrcB ALUSrcA RegWrite

INSTRUCTION FETCH STEP SignalValue PCWrite1 IorD0 MemRead1 MemWrite0 IRWrite1 PCSource00 ALUOp00 ALUSrcB01 ALUSrcA0 RegWrite0

INSTRUCTION DECODE + REG FETCH STEP A = Reg[IR[25-21]]; B = Reg[IR[20-16]]; ALUOut = PC + (sign-extend(IR[15-0]) << 2); Operations: Decode instruction. Optimistically read registers. Optimistically compute branch target.

INSTRUCTION DECODE + REG FETCH STEP SignalValue ALUOp ALUSrcB ALUSrcA

INSTRUCTION DECODE + REG FETCH STEP SignalValue ALUOp00 ALUSrcB11 ALUSrcA0

EXECUTION STEP Here is where our instructions diverge. Memory Reference: ALUOut = A + sign-extend(IR[15-0]); Arithmetic-Logical Reference: ALUOut = A op B; Branch: if (A == B) PC = ALUOut; Jump PC = PC[31-28] || (IR[25-0] << 2);

EXECUTION: MEMORY REFERENCE SignalValue ALUOp00 ALUSrcB10 ALUSrcA1

EXECUTION: ARITHMETIC/LOGICAL OP SignalValue ALUOp10 ALUSrcB00 ALUSrcA1

EXECUTION: BRANCH SignalValue ALUOp01 ALUSrcB00 ALUSrcA1 PCSource01 PCWriteCond1

EXECUTION: JUMP SignalValue PCSource10 PCWrite1

MEMORY ACCESS/R-TYPE COMPLETION STEP Memory Reference: Load: MDR = Memory[ALUOut]; Store: Memory[ALUOut] = B; R-type Instruction: Reg[IR[15-11]] = ALUOut;

MEMORY ACCESS: LOAD SignalValue MemRead1 IorD1 IRWrite0

MEMORY ACCESS: STORE SignalValue MemWrite1 IorD1

R-TYPE COMPLETION SignalValue MemtoReg0 RegWrite1 RegDst1

READ COMPLETION STEP Load operation: Reg[IR[20-16]] = MDR;

READ COMPLETION SignalValue RegWrite1 MemtoReg1 RegDst0

MULTI-CYCLE DATAPATH AND CONTROL So, now we know what the steps are and what happens in each step for each kind of instruction in our mini-MIPS instruction set. To make things clearer, let’s investigate how multi-cycle works for a particular instruction at a time.

R-FORMAT R-format instructions require 4 cycles to complete. Let’s imagine that we’re executing an add instruction. add $s0, $s1, $s2 which has the following fields: opcodersrtrdshamtfunct

R-FORMAT: CYCLE 1 SignalValue PCWrite1 IorD0 MemRead1 MemWrite0 IRWrite1 PCSource00 ALUOp00 ALUSrcB01 ALUSrcA0 RegWrite0

R-FORMAT: CYCLE 2 SignalValue ALUOp00 ALUSrcB11 ALUSrcA0 Note that we compute the speculative branching target in this step even though we will not need it. We have nothing better to do while we decode the instruction so we might as well.

R-FORMAT: CYCLE 3 SignalValue ALUOp10 ALUSrcB00 ALUSrcA1

R-FORMAT: CYCLE 4 SignalValue MemtoReg0 RegWrite1 RegDst1

BRANCH Branch instructions require 3 cycles to complete. Let’s imagine that we’re executing a beq instruction. beq $s0, $s1, L1 which has the following fields: opcodersrtimmed XXXXXXXXXXXXXXXX

BRANCH: CYCLE 1 SignalValue PCWrite1 IorD0 MemRead1 MemWrite0 IRWrite1 PCSource00 ALUOp00 ALUSrcB01 ALUSrcA0 RegWrite0

BRANCH: CYCLE 2 SignalValue ALUOp00 ALUSrcB11 ALUSrcA0

BRANCH: CYCLE 3 SignalValue ALUOp01 ALUSrcB00 ALUSrcA1 PCSource01 PCWriteCond1