Let’s look at a normal lw instruction first… 1. 2 Register file addresscontent 6 (00110)9 10 7 (00111)10000 10 OpcodeSource register Destination register.

Slides:



Advertisements
Similar presentations
1 Datapath and Control (Multicycle datapath) CDA 3101 Discussion Section 11.
Advertisements

Microprocessor Design Multi-cycle Datapath Nia S. Bradley Vijay.
1 Chapter Five The Processor: Datapath and Control.
The Processor Data Path & Control Chapter 5 Part 2 - Multi-Clock Cycle Design N. Guydosh 2/29/04.
EECE476 Lecture 9: Multi-cycle CPU Datapath Chapter 5: Section 5.5 The University of British ColumbiaEECE 476© 2005 Guy Lemieux.
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.
10/18/2005Comp 120 Fall October Questions? Instruction Execution.
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.
Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
Chapter 4 Sections 4.1 – 4.4 Appendix D.1 and D.2 Dr. Iyad F. Jafar Basic MIPS Architecture: Single-Cycle Datapath and Control.
Lecture 15: Midterm Review 1 Copyright © 2007 Frank Vahid Instructors of courses requiring Vahid's Digital Design textbook (published by John Wiley 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.
Multicycle Implementation
LECTURE 6 Multi-Cycle Datapath and Control. SINGLE-CYCLE IMPLEMENTATION As we’ve seen, single-cycle implementation, although easy to implement, could.
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.
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 In-Class Exercises.
Design a MIPS Processor (II)
Multi-Cycle Datapath and Control
IT 251 Computer Organization and Architecture
/ Computer Architecture and Design
ECE/CS 552: Multicycle Data Path
Systems Architecture I
Multi-Cycle CPU.
Extensions to the Multicycle CPU
Five Execution Steps Instruction Fetch
Single Cycle Processor
D.4 Finite State Diagram for the Multi-cycle processor
Multi-Cycle CPU.
ECS 154B Computer Architecture II Spring 2009
CS/COE0447 Computer Organization & Assembly Language
Multiple Cycle Implementation of MIPS-Lite CPU
CS/COE0447 Computer Organization & Assembly Language
CSCE 212 Chapter 5 The Processor: Datapath and Control
Chapter Five The Processor: Datapath and Control
CS/COE0447 Computer Organization & Assembly Language
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
Vishwani D. Agrawal James J. Danaher Professor
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Processor: Multi-Cycle Datapath & Control
Control Unit (single cycle implementation)
CS/COE0447 Computer Organization & Assembly Language
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.
CS/COE0447 Computer Organization & Assembly Language
Systems Architecture I
Control Unit for Multiple Cycle Implementation
FloorPlan for Multicycle MIPS
Alternative datapath (book): Multiple Cycle Datapath
The Processor: Datapath & Control.
CS161 – Design and Architecture of Computer Systems
CS/COE0447 Computer Organization & Assembly Language
Presentation transcript:

Let’s look at a normal lw instruction first… 1

2 Register file addresscontent 6 (00110) (00111) OpcodeSource register Destination register Immediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) $6  Memory[8 + contents of $7] PC value: Memory addresscontent lw encoding … …

3 Register file addresscontent 6 (00110) (00111) PC value: Memory addresscontent lw encoding … … This sequence of 1s and 0s OpcodeSource register Destination register Immediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) $6  Memory[8 + contents of $7]

4 Register file addresscontent 6 (00110) (00111) PC value:  Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) Cycle 1, State 0: Fetch load instruction IR  Memory(PC) || PC  PC + 4 IR contains: See control logic discussion 00

5 Register file addresscontent 6 (00110) (00111) PC value: Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) Cycle 2, State 1: Decode instruction A  RF[25:21] || B  RF[20:16] || ALUOut  PC + SignExt(IR[15:0]) Load into A register

6 Register file addresscontent 6 (00110) (00111) PC value: Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) Cycle 2, State 1: Decode instruction A  RF[25:21] || B  RF[20:16] || ALUOut  PC + SignExt(IR[15:0]) Load 9 10 into B register

7 Register file addresscontent 6 (00110) (00111) PC value: Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) Cycle 2, State 1: Decode instruction A  RF[25:21] || B  RF[20:16] || ALUOut  PC + SignExt(IR[15:0]) Calculate address in case it is needed. (hardware is available, so use ASAP)

8 Register file addresscontent 6 (00110) (00111) PC value: Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) Cycle 2, State 1: Decode instruction A  RF[25:21] || B  RF[20:16] || ALUOut  PC + SignExt(IR[15:0]) 0 11 See control logic discussion

9 Register file addresscontent 6 (00110) (00111) PC value: Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) Cycle 3, State 2 Calculate address ALUOut  A + SignExt(IR[15:0]) ‘A’ register is: Immediate value is: 8 10 ( ) Immediate value is padded with leading 0s to get 2 nd 32-bit number

10 Register file addresscontent 6 (00110) (00111) PC value: Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) 1 10 See control logic discussion Cycle 3, State 2: Calculate address ALUOut  A + SignExt(IR[15:0]) ALUOut contains address to send to memory

11 Register file addresscontent 6 (00110) (00111) PC value: Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) Cycle 4, State 3: Get data from memory MDR  Memory[ALUOut] Address sent to memory Want to load into Memory Data Register Data from memory is 70 10

12 Register file addresscontent 6 (00110) (00111) PC value: Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) Cycle 4, State 3: Get data from memory MDR  Memory[ALUOut] 1 Choose ALUOut to get memory address Put in MDR

13 Register file addresscontent 6 (00110) (00111) PC value: Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) Cycle 5, State 4: Write data from memory to the register file RF[IR(20:16)]  MDR

14 Register file addresscontent 6 (00110) (00111) PC value: Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) Cycle 5, State 4: Write data from memory to the register file RF[IR(20:16)]  MDR

15 Register file addresscontent 6 (00110)9 10  (00111) PC value: Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw $6,8($7) Cycle 5, State 4: Write data from memory to the register file RF[IR(20:16)]  MDR

Now, let’s revisit lw++ 16

Recall… lw++ would do the following… –lw++ $6, 8($7) $6  Memory[8 + content of $7] || $7  $7 + 4 Why is this useful? –Assume we wanted to iterate through an array … we might use the following sequence of instructions: lw $t, 0($x) addi $x, $x, 4 –The above 2 instruction sequence (requiring 9 CCs) could be replaced by a single instruction that takes 5 or 6 CCs Now, let’s talk about the hardware to make lw++ work! 17

18 Register file addresscontent 6 (00110) (00111) OpcodeSource register Destination register Immediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw++ $6,8($7) $6  Memory[8 + contents of $7] $7  $7 + 4 PC value: Memory addresscontent lw++ encoding … … Opcode must change! (Assume is available.)

19 Register file addresscontent 6 (00110) (00111) PC value: This sequence of 1s and 0s OpcodeSource register Destination register Immediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw++ $6,8($7) $6  Memory[8 + contents of $7] $7  $7 + 4 Memory addresscontent lw++ encoding … …

20 Register file addresscontent 6 (00110) (00111) PC value:  OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw++ $6,8($7) Cycle 1, State 0: Fetch load instruction IR  Memory(PC) || PC  PC + 4 IR contains: See control logic discussion 00 Same as normal lw Memory addresscontent lw++ encoding … …

21 Register file addresscontent 6 (00110) (00111) PC value: OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw++ $6,8($7) Cycle 2, State 1: Decode instruction A  RF[25:21] || B  RF[20:16] || ALUOut  PC + SignExt(IR[15:0]) Load into A register Same as normal lw Memory addresscontent lw++ encoding … …

22 Register file addresscontent 6 (00110) (00111) PC value: OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw++ $6,8($7) Cycle 2, State 1: Decode instruction A  RF[25:21] || B  RF[20:16] || ALUOut  PC + SignExt(IR[15:0]) Load 9 10 into B register Same as normal lw Memory addresscontent lw++ encoding … …

23 Register file addresscontent 6 (00110) (00111) PC value: OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw++ $6,8($7) Cycle 2, State 1: Decode instruction A  RF[25:21] || B  RF[20:16] || ALUOut  PC + SignExt(IR[15:0]) Calculate address in case it is needed. (hardware is available, so use ASAP) Same as normal lw Memory addresscontent lw++ encoding … …

24 Register file addresscontent 6 (00110) (00111) PC value: OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits address : lw++ $6,8($7) Cycle 3, State 2 Calculate address ALUOut  A + SignExt(IR[15:0]) A register is: Immediate value is: 8 10 ( ) Immediate value is padded with leading 0s to get 2 nd 32-bit number Same as normal lw Memory addresscontent lw++ encoding … …

25 Register file addresscontent 6 (00110) (00111) PC value: OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits Cycle 4, State 3: Get data from memory MDR  Memory[ALUOut] Address sent to memory Want to load into Memory Data Register Data from memory is address : lw++ $6,8($7) Part 1: Same as normal lw Memory addresscontent lw++ encoding … …

26 Register file addresscontent 6 (00110) (00111) PC value: OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits Cycle 4, State 3: Get data from memory MDR  Memory[ALUOut] || ALUOut  [A] + 4 address : lw++ $6,8($7) Memory addresscontent lw++ encoding … … Part 2: NEW! Content of A and B registers still has not changed Idea: Use idle ALU to update the value in register A (i.e. $7) while the memory access occurs.

27 Register file addresscontent 6 (00110) (00111) PC value: OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits Cycle 4, State 3: Get data from memory MDR  Memory[ALUOut] || ALUOut  [A] + 4 address : lw++ $6,8($7) Memory addresscontent lw++ encoding … … Part 2: NEW! To make this work, need to assert other control signals in State 3 to do an add operation: ALUSrcA = 1 # select A input ALUSrcB = 01# select 4 input ALUOp = 00# perform add MemRead IorD = 1 ALUSrcA = 1 ALUSrcB = 01 ALUOp = 00 3 New state would look like…

28 Register file addresscontent 6 (00110) (00111) PC value: OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits Cycle 4, State 3: Get data from memory MDR  Memory[ALUOut] || ALUOut  [A] + 4 address : lw++ $6,8($7) Memory addresscontent lw++ encoding … … Part 2: NEW! See control logic discussion do add ALUOut contains

Now, to finish, we need to support the write back of both the MDR register AND the ALUOut register For dramatic effect, let’s continue on another slide… 29

Option A: Write back MDR and ALUOut in the same CC… 30

31 Register file addresscontent 6 (00110) (00111) PC value: OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits Cycle 5, State 12: Write data back… RF[IR(20-16)]  MDR || RF[IR(25:21)]  ALUOut address : lw++ $6,8($7) Memory addresscontent lw++ encoding … … Option A Aw, snap! With existing datapath, only 1 register can be written at a time…

Option A: Write back MDR and ALUOut in the same CC… 32 Solution: Add register file hardware Update the FSM Let’s update the register file hardware 1 st …

33 OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits Cycle 5, State 12: Write data back… RF[IR(20-16)]  MDR || RF[IR(25:21)]  ALUOut address : lw++ $6,8($7) Option A Can keep existing hardware the same, but need to add: Another address port “Write register 2” Another data port “Write data 2” Another control signal RegWrite2 IR(25:21) – i.e Input to Write Register 2 ALUOut ( ) Input to Write Data 2 New control signal: RegWrite2

New FSM diagram is thus: 34 RegDst = 0 RegWrite MemtoReg = 1 RegWrite2 12 lw++ Need a new state because we want to do different things for lw and lw ++

Option B: Write back MDR and ALUOut in the different CCs… 35

36 Register file addresscontent 6 (00110)9 10  (00111) PC value: Memory addresscontent lw encoding … … OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits Cycle 5, State 4: Write data from memory to the register file RF[IR(20:16)]  MDR address : lw++ $6,8($7) Same as normal lw

37 OpcodeSourceDestinationImmediate value Bits 31-26Bits 25-21Bits 20-16Bits Cycle 5, State 13: Write data from ALUOut to the register file RF[IR(25:21)]  ALUOut address : lw++ $6,8($7) Aw, snap! No path for bits 25:21 of IR to use as write address… To fix: Add another input to mux Now need 2 control signals instead of IR(20:16) IR(15:11) IR(25:21)

New FSM diagram is thus: 38 RegDst = 10 RegWrite MemtoReg = 0 13 lw++ Notes: RegDst = 10 Selects IR(25:21) RegWrite Enables register file to be written MemtoReg = 0 Selects ALUOut as input to the register file