Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 9: MIPS Lite 4 th edition: Chapter.

Slides:



Advertisements
Similar presentations
©UCB CS 161Computer Architecture Chapter 5 Lecture 9 Instructor: L.N. Bhuyan Adapted from notes by Dave Patterson (http.cs.berkeley.edu/~patterson)
Advertisements

The Processor: Datapath & Control
Processor II CPSC 321 Andreas Klappenecker. Midterm 1 Tuesday, October 5 Thursday, October 7 Advantage: less material Disadvantage: less preparation time.
©UCB CS 162 Computer Architecture Lecture 3: Pipelining Contd. Instructor: L.N. Bhuyan
331 W9.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 9 Building a Single-Cycle Datapath [Adapted from Dave Patterson’s.
331 Lec 14.1Fall 2002 Review: Abstract Implementation View  Split memory (Harvard) model - single cycle operation  Simplified to contain only the instructions:
©UCB CS 161Computer Architecture Chapter 5 Lecture 11 Instructor: L.N. Bhuyan Adapted from notes by Dave Patterson (http.cs.berkeley.edu/~patterson)
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.
The Processor 2 Andreas Klappenecker CPSC321 Computer Architecture.
Chapter Five The Processor: Datapath and Control.
CS 161, Spring 2006 Test 2 Answers. Q1(a) +10 = in 2’s complement. And in sign-extended -12 = in 2’s comp And.
©UCB CS 161Computer Architecture Chapter 5 Instructor: L.N. Bhuyan LECTURE 10.
CSE431 L05 Basic MIPS Architecture.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 05: Basic MIPS Architecture Review Mary Jane Irwin.
The Processor: Datapath & Control. Implementing Instructions Simplified instruction set memory-reference instructions: lw, sw arithmetic-logical instructions:
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.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
Processor: Datapath and Control
Lec 15Systems Architecture1 Systems Architecture Lecture 15: A Simple Implementation of MIPS Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
Gary MarsdenSlide 1University of Cape Town Chapter 5 - The Processor  Machine Performance factors –Instruction Count, Clock cycle time, Clock cycles per.
CS2100 Computer Organisation
Electrical and Computer Engineering University of Cyprus LAB 2: MIPS.
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
1 A single-cycle MIPS processor  An instruction set architecture is an interface that defines the hardware operations which are available to software.
ECE-C355 Computer Structures Winter 2008 The MIPS Datapath Slides have been adapted from Prof. Mary Jane Irwin ( )
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Single-Cycle Datapath and Control.
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.
COM181 Computer Hardware Lecture 6: The MIPs CPU.
1 Chapter 5: Datapath and Control (Part 2) CS 447 Jason Bakos.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 10: Control Design
May 22, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 14: A Simple Implementation of MIPS * Jeremy R. Johnson Mon. May 17, 2000.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Single-cycle CPU Control
Access the Instruction from Memory
EE204 Computer Architecture
CS Computer Architecture Week 10: Single Cycle Implementation
CS161 – Design and Architecture of Computer Systems
Electrical and Computer Engineering University of Cyprus
Single-Cycle Datapath and Control
Computer Architecture
Processor (I).
CS/COE0447 Computer Organization & Assembly Language
MIPS processor continued
Designing MIPS Processor (Single-Cycle) Presentation G
CSCI206 - Computer Organization & Programming
CS/COE0447 Computer Organization & Assembly Language
Single-Cycle CPU DataPath.
CS/COE0447 Computer Organization & Assembly Language
CSCI206 - Computer Organization & Programming
CS/COE0447 Computer Organization & Assembly Language
CS/COE0447 Computer Organization & Assembly Language
Datapath & Control MIPS
Topic 5: Processor Architecture Implementation Methodology
Rocky K. C. Chang 6 November 2017
Composing the Elements
Composing the Elements
The Processor Lecture 3.2: Building a Datapath with Control
Topic 5: Processor Architecture
Systems Architecture I
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Lecture 14: Single Cycle MIPS Processor
Single Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
MIPS processor continued
CS/COE0447 Computer Organization & Assembly Language
The Processor: Datapath & Control.
COMS 361 Computer Organization
Processor: Datapath and Control
CS/COE0447 Computer Organization & Assembly Language
Presentation transcript:

Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 9: MIPS Lite 4 th edition: Chapter 4; 3 rd edition: Chapter 5

ECE232: MIPS-Lite 2 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren MIPS-lite processor  Want to build a processor for a subset of MIPS instruction set (“MIPS-lite”) just enough to illustrate key ideas instruction set subset (3 groups): arithmetic-logical: add, sub, and, or, slt memory reference: lw, sw control flow:j, beq can we write real programs with just these?  Need up to 5 steps to execute any instruction in our subset Processor (CPU) Computer Control Datapath IMemory MIPS Instructions DMemory

ECE232: MIPS-Lite 3 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Instruction Execution Steps Instruction Fetch Decode, Inc PC and Read Registers ALU Operation, Branch address Data Memory operation Write Back 1. Read IM[PC] 2. Instruction Decode, PC = PC + 4, Register read 3. ALU operation, Branch address computation 4. LW/STORE in Data memory 5. Register Write

ECE232: MIPS-Lite 4 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Building a Datapath for MIPS (step 1) PC Instruction Memory Step 1  add $t0,$t0,$t0 add $t0,$s1,$t0 lw $t1,20($s0) sw $t1,4($t0) . PC-4 PC PC+4 PC+8. Flow of execution Step 1: instruction fetch

ECE232: MIPS-Lite 5 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Datapath Step 1: Any Instruction PC Instruction Memory (IMem) Address Instruction AddAdd “4” 32-bit adder or ALU wired only for add Clock Once program is loaded, IMem is read-only

ECE232: MIPS-Lite 6 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Building a Datapath for MIPS (step 2) PC Registers Step 1 Step 2: Decode and Read Registers add $t0,$s1,$t0 Instruction Memory op rs rt rd shamt funct R

ECE232: MIPS-Lite 7 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Datapath Step 2: Any Instruction Register File Read Register 1 Read data 1 Read data 2 Read Register 2 Write Register Write Data Instruction Control Datapath Control Points 6 op rs rt rd shamt funct R add $t0,$t1,$t2

ECE232: MIPS-Lite 8 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Remaining Steps in Executing Instructions  3rd step onwards depends on instruction class  EX: for ALU instructions: add $t0, $t1, $t2 outputs from registers t1 and t2 will be sent to the ALU input  For Memory-reference instruction: lw$t0,20($s0) Address  Base + offset ALUALU

ECE232: MIPS-Lite 9 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Building a Datapath for MIPS ( lw step 3) PCRegisters ALUALU Instruction Memory Step 1Step 2Step 3 op rs rt address lw $t0, 20($s0) I

ECE232: MIPS-Lite 10 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Datapath Step 3-4: R-format Instructions Registers Read Register 1 Read data 1 ALUALU Read data 2 Read Register 2 Write Register Write Data Instruction Result Zero ALU control 3 32 RegWrite add, sub, and, or [$t1] [$t2] [$t1]  [$t2] { +, -, AND, OR, etc.} [$t3]  [$t1]  [$t2]

ECE232: MIPS-Lite 11 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Datapath Step 3: Branch Registers Read Register 1 Read data 1 ALUALU Read data 2 Read Register 2 Write Register Write Data Instruc- tion Zero RegWrite Sign Extend AddAdd Branch target To branch control logic PC + 4 from step 1 datapath Mult by 4 beq $t0,$t1,loop ALU control 3 Result [$t0] [$t1]

ECE232: MIPS-Lite 12 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Steps 4,5 in Executing lw,sw  4th step depends on instruction class  Ex: for lw: Fetch Data from Memory Data  Mem[Address]  For sw: Put the contents of a register in Memory From Register for SW To register for LW lw $t1,20($s0) sw $t1,4($t0) PCRegisters ALUALU Step 1 Step 2 Step 3 Data Memory Step 4 Instruction Memory  5th step only for lw; rest are done  for lw: Write Result Reg[rt]  Data

ECE232: MIPS-Lite 13 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Datapath Step 3-5: Load/Store Registers Read Register 1 Read data 1 ALUALU Read data 2 Read Register 2 Write Register Write Data Instruc- tion Zero ALU control RegWrite Address Read data Write Data Sign Extend DMem MemRead MemWrite lw $t0,24($s3) op rs rt address Result [$s3] “24” [$s3]+24

ECE232: MIPS-Lite 14 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Compose Datapath: R-form + Load/Store Registers Read Register 1 Read data 1 ALUALU Read data 2 Read Register 2 Write Register Write Data Instruction Zero ALU control 3 RegWrite Address Read data Write Data Sign Extend DMem MemRead MemWrite 1Mux01Mux0 MemTo- Reg 0=R-form 1=L/S MuxMux ALUSrc 0 = R-format 1 = Load/Store Add muxes

ECE232: MIPS-Lite 15 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Compose Datapath: + IMem + PC Registers Read Reg1 Read data1 ALUALU Read data2 Read Reg2 Write Reg Write Data Zero ALU control 4 RegWrite Address Read data Write Data Sign Extend DMem MemRead MemWrite MuxMux MemTo- Reg MuxMux ALUSrc Read Addr Instruc- tion IMem “4” PCPC addadd

ECE232: MIPS-Lite 16 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Compose Datapath: + Branch Registers Read Reg1 Read data1 ALUALU Read data2 Read Reg2 Write Reg Write Data Zero ALUcon RegWrite Address Read data Write Data Sign Extend DMem MemRead MemWrite MuxMux MemTo- Reg MuxMux ALUSrc Read Addr Instruc- tion IMem “4” PCPC addadd addadd << 2 MuxMux PCSrc “Left Shift 2” module Supports all MIPS-lite instructions? (slt and ?)

ECE232: MIPS-Lite 17 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Datapath: Register fields  Destination registers may differ across instruction formats: R-format: [rd]  [rs] op [rt] add $t0,$s0,$s1 For this instruction, bits are the destination (t0), which should be connected to the write reg. inputs I-format:[rt]  mem [ [rs] + imm16 ] lw $t0,24($s3) For this instruction, bits should go to the write reg. port. Bits 0-15 go to the ALU as address Connection to the write reg. port changes!  Solution? mux to the rescue! oprsrtrdfunctshamt 6 bits5 bits 6 bits oprsrtoffset 6 bits5 bits 16 bits

ECE232: MIPS-Lite 18 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Datapath (add RegDst Mux) Regs Read Reg1 Read data1 ALUALU Read data2 Read Reg2 Write Reg Write Data Zero ALU- con RegWrite Address Read data Write Data Sign Extend DMem MemRead MemWrite MuxMux MemTo- Reg MuxMux Read Addr Instruc- tion IMem 4 PCPC addadd addadd << 2 MuxMux PCSrc ALU- src MuxMux 25:21 20:16 15:11 RegDst 15:0 31:0

ECE232: MIPS-Lite 19 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Datapath: Determine next PC  What if instruction is a conditional branch ( beq )? if operands equal, take branch (PC gets PC+4+offset) else PC gets PC+4  Therefore, set control point PCSrc = 1 if and only if beq and Zero asserted

ECE232: MIPS-Lite 20 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Datapath (add Branch control point) Regs Read Reg1 Read data1 ALUALU Read data2 Read Reg2 Write Reg Write Data Zero ALU- con RegWrite Address Read data Write Data Sign Extend DMem MemRead MemWrite MuxMux MemTo- Reg MuxMux Read Addr Instruc- tion IMem 4 PCPC addadd addadd << 2 MuxMux ALU- src MuxMux 25:21 20:16 15:11 RegDst 15:0 31:0 Branch PCSrc

ECE232: MIPS-Lite 21 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Adding Control  CPU = Datapath + Control  Single-Cycle Design: Instruction takes exactly one clock cycle Datapath units used only once per cycle Writable state updated at end of cycle  What must be “controlled”? Multiplexors (Muxes) Writable components: Register File, Data Memory (DMem) what about PC? IMem? ALU (which operation?)

ECE232: MIPS-Lite 22 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Processor = Datapath + Control Control Logic op rs rt rd shamt funct R-format instruction To datapath 6 6  Single-Cycle Design: everything happens in one clock cycle until next falling edge of clock, processor is just one big combinational circuit!!!  Control is a combinational circuit where the output is a function of the inputs outputs? control points in datapath inputs? the current instruction! (opcode, funct control everything)

ECE232: MIPS-Lite 23 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Defining Control  Note that funct field only present in R-format instruction - funct controls ALU only  To simplify control, define Main control, ALU control separately – using multiple levels will also increase speed – important optimization technique  ALUop inputs will be defined Control Logic Main Control ALU control op funct op funct ALU- con ALUop

ECE232: MIPS-Lite 24 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Defining ALU Control ALUcon ALUALU Zero Result ALUcon ALU functionInstruction(s) supported 0000ANDR-format (and) 0001ORR-format (or) 0010addR-format (add), lw, sw 0110subtractR-format (sub), beq 0111 set on less thanR-format (slt) 1100 NOR R-format (nor) ABAB

ECE232: MIPS-Lite 25 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Defining ALU Control InstructionDesired opcodeALU ActionALUOpfunctALUcon lwadd 00xxxxxx 0010 swadd 00xxxxxx 0010 beqsubtract 01xxxxxx 0110 R-typeadd (add) 0010 R-typesubtract (sub) 0110 R-typelogical AND (and) 0000 R-typelogical OR (or) 0001 R-typeset on less (slt) 0111 ALUOp Funct Field a1a0f5f4f3f2f1f0ALUcon 00xxxxxx 0010 x1xxxxxx xxx xxx xxx xxx xxx Don’t Cares c3 c2 c1 c0

ECE232: MIPS-Lite 26 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren OpCode field R-formatjjalbeqbneblezbgtz 001addiaddiusltisltiuandiorixori llolhitrap 100lblhlwlbulhu 101sbshsw

ECE232: MIPS-Lite 27 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Function field sllsrlsrasllvsrlvsrav 001jrjalr 010mfhimthimflomtlo 011multmultudivdivu 100addaddusubsubuandorxornor 101sltsltu

ECE232: MIPS-Lite 28 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Fully Minimized ALU Control F3 F2 F1 F0 ALUOp ALUcon 4th bit=0 funct c2 c1 c0 a0 a1  From the truth table, output signals can be easily derived because of don’t cares  c2 = a0 OR (a1 AND f1)  c1 = (Not a1) OR (Not f2)  c0 (lsb) = a1 AND (f3 OR f0)  ALUOp is supplied by the main control unit (to be designed) a1,0 f5,4,3,2,1,0 ALUcon 0 0 x x x x x x 0010 X 1 x x x x x x x x x x x x x x x x x x x x x

ECE232: MIPS-Lite 29 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Datapath + ALU Control Registers Read Reg1 Read data1 ALUALU Read data2 Read Reg2 Write Reg Write Data Zero ALU- con RegWrite Address Read data Write Data Sign Extend DMem MemRead MemWrite MuxMux MemTo- Reg MuxMux Read Addr Instruc- tion IMem “4” PCPC addadd addadd << 2 MuxMux PCSrc ALU Control Instr[5:0] ALUOp ALU- src

ECE232: MIPS-Lite 30 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Datapath With Control

ECE232: MIPS-Lite 31 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Adding Jumps  Update PC with concatenation of Top 4 bits of old PC 26-bit jump address 00  Need an extra control signal decoded from opcode 2address 31:2625:0 Jump

ECE232: MIPS-Lite 32 Adapted from Computer Organization and Design, Patterson&Hennessy, UCB, Kundu,UMassKoren Datapath With Jumps Added