CS359: Computer Architecture. The Processor (A) Yanyan Shen Department of Computer Science and Engineering

Similar documents
COMP303 Computer Architecture Lecture 9. Single Cycle Control

MIPS-Lite Single-Cycle Control

How to design a controller to produce signals to control the datapath

EEM 486: Computer Architecture. Lecture 3. Designing Single Cycle Control

361 control.1. EECS 361 Computer Architecture Lecture 9: Designing Single Cycle Control

ECE170 Computer Architecture. Single Cycle Control. Review: 3b: Add & Subtract. Review: 3e: Store Operations. Review: 3d: Load Operations

CS152 Computer Architecture and Engineering Lecture 10: Designing a Single Cycle Control. Recap: The MIPS Instruction Formats

Full Datapath. CSCI 402: Computer Architectures. The Processor (2) 3/21/19. Fengguang Song Department of Computer & Information Science IUPUI

The Big Picture: Where are We Now? EEM 486: Computer Architecture. Lecture 3. Designing a Single Cycle Datapath

ECE468 Computer Organization and Architecture. Designing a Single Cycle Datapath

CS3350B Computer Architecture Winter Lecture 5.7: Single-Cycle CPU: Datapath Control (Part 2)

Recap: The MIPS Subset ADD and subtract EEL Computer Architecture shamt funct add rd, rs, rt Single-Cycle Control Logic sub rd, rs, rt

CSCI 402: Computer Architectures. Fengguang Song Department of Computer & Information Science IUPUI. Today s Content

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

361 datapath.1. Computer Architecture EECS 361 Lecture 8: Designing a Single Cycle Datapath

CpE242 Computer Architecture and Engineering Designing a Single Cycle Datapath

CS 110 Computer Architecture Single-Cycle CPU Datapath & Control

Lecture #17: CPU Design II Control

Single Cycle CPU Design. Mehran Rezaei

Outline. EEL-4713 Computer Architecture Designing a Single Cycle Datapath

UC Berkeley CS61C : Machine Structures

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Single- Cycle CPU Datapath & Control Part 2

UC Berkeley CS61C : Machine Structures

Recap: A Single Cycle Datapath. CS 152 Computer Architecture and Engineering Lecture 8. Single-Cycle (Con t) Designing a Multicycle Processor

CENG 3420 Lecture 06: Datapath

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Single- Cycle CPU Datapath & Control Part 2. Clk

CS61C : Machine Structures

Lecture 6 Datapath and Controller

Ch 5: Designing a Single Cycle Datapath

CS 61C: Great Ideas in Computer Architecture Datapath. Instructors: John Wawrzynek & Vladimir Stojanovic

CS 61C: Great Ideas in Computer Architecture. MIPS CPU Datapath, Control Introduction

Designing a Multicycle Processor

Working on the Pipeline

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

CS61C : Machine Structures

CPU Organization (Design)

CPE 335 Computer Organization. Basic MIPS Architecture Part I

add rd, rs, rt Review: A Single Cycle Datapath We have everything Lecture Recap: Meaning of the Control Signals

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

CS 61C: Great Ideas in Computer Architecture Control and Pipelining

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Single Cycle MIPS CPU

If you didn t do as well as you d hoped

The Processor: Datapath & Control

CPU Design Steps. EECC550 - Shaaban

Instructor: Randy H. Katz hcp://inst.eecs.berkeley.edu/~cs61c/fa13. Fall Lecture #18. Warehouse Scale Computer

inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 19 CPU Design: The Single-Cycle II & Control !

Major CPU Design Steps

Review. N-bit adder-subtractor done using N 1- bit adders with XOR gates on input. Lecture #19 Designing a Single-Cycle CPU

CS61C : Machine Structures

CS 152 Computer Architecture and Engineering. Lecture 10: Designing a Multicycle Processor

Lecture 12: Single-Cycle Control Unit. Spring 2018 Jason Tang

Review: Abstract Implementation View

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Lecture 28: Single- Cycle CPU Datapath Control Part 1

CS61C : Machine Structures

University of California College of Engineering Computer Science Division -EECS. CS 152 Midterm I

CS3350B Computer Architecture Quiz 3 March 15, 2018

CS 61C: Great Ideas in Computer Architecture Lecture 12: Single- Cycle CPU, Datapath & Control Part 2

UC Berkeley CS61C : Machine Structures

Midterm I March 3, 1999 CS152 Computer Architecture and Engineering

CSE 141 Computer Architecture Summer Session Lecture 3 ALU Part 2 Single Cycle CPU Part 1. Pramod V. Argade

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

361 multipath..1. EECS 361 Computer Architecture Lecture 10: Designing a Multiple Cycle Processor

Processor (multi-cycle)

1048: Computer Organization

inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 18 CPU Design: The Single-Cycle I ! Nasty new windows vulnerability!

Processor (I) - datapath & control. Hwansoo Han

ECE473 Computer Architecture and Organization. Processor: Combined Datapath

LECTURE 5. Single-Cycle Datapath and Control

ECE468 Computer Organization and Architecture. Designing a Multiple Cycle Controller

ECS 154B Computer Architecture II Spring 2009

Initial Representation Finite State Diagram Microprogram. Sequencing Control Explicit Next State Microprogram counter

CS 110 Computer Architecture Review Midterm II

CS152 Computer Architecture and Engineering. Lecture 8 Multicycle Design and Microcode John Lazzaro (

The MIPS Processor Datapath

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

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

Systems Architecture

ECE 361 Computer Architecture Lecture 11: Designing a Multiple Cycle Controller. Review of a Multiple Cycle Implementation

Fundamentals of Computer Systems

Midterm I March 12, 2003 CS152 Computer Architecture and Engineering

Midterm I October 6, 1999 CS152 Computer Architecture and Engineering

CC 311- Computer Architecture. The Processor - Control

ECE 361 Computer Architecture Lecture 10: Designing a Multiple Cycle Processor

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

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Single- Cycle CPU Datapath Control Part 1

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

ECE468. Computer Organization and Architecture. Designing a Multiple Cycle Processor

CPSC614: Computer Architecture

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

Mark Redekopp and Gandhi Puvvada, All rights reserved. EE 357 Unit 15. Single-Cycle CPU Datapath and Control

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

CPE 335. Basic MIPS Architecture Part II

Laboratory 5 Processor Datapath

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

Chapter 4 The Processor 1. Chapter 4A. The Processor

Computer Science 141 Computing Hardware

Lecture 3: The Processor (Chapter 4 of textbook) Chapter 4.1

ECE4680. Computer Organization and Architecture. Designing a Multiple Cycle Processor

RISC Design: Multi-Cycle Implementation

Transcription:

CS359: Computer Architecture The Processor (A) Yanyan Shen Department of Computer Science and Engineering

Eecuting R-type Instructions 7 Instructions ADD and subtract add rd, rs, rt sub rd, rs, rt OR Immediate: ori rt, rs, imm6 LOAD and STORE lw rt, rs, imm6 sw rt, rs, imm6 BRANCH: beq rs, rt, imm6 JUMP: j target 3 26 2 6 6 op rs rt rd shamt func 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 3 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits 3 26 op target address 6 bits 26 bits 2

Datapath of RR(R-type) 3 26 2 6 6 op rs rt rd shamt func 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits RTL:R[rd] R[rs] op R[rt] Eample: add rd, rs, rt RegWr busw Clk rd rs rt 5 5 5 Rw Ra Rb -bit Registers busa busb ctr:add/sub Result Ra, Rb, Rw correspond to rs, rt, rd ctr,regwr: control signal What are controls signals for add rd, rs, rt? ctr=add,regwr= 3

I-type instruction(ori) ADD and subtract add rd, rs, rt sub rd, rs, rt OR Immediate: ori rt, rs, imm6 LOAD and STORE lw rt, rs, imm6 sw rt, rs, imm6 BRANCH: beq rs, rt, imm6 JUMP: j target 3 26 2 6 6 op rs rt rd shamt func 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 3 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits 3 26 op target address 6 bits 26 bits 4

RTL: The OR Immediate Instruction 3 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits ori rt, rs, imm6 M[PC] Instruction Fetech R[rt] R[rs] or ZeroEt(imm6) zero etension of 6 bit constant or R[rs] PC PC + 4 update PC Zero etension ZeroEt(imm6) 3 65 6 bits immediate 6 bits 5

Datapath of Immediate Instruction R[rt] R[rs] op ZeroEt[imm6]] Eample: ori rt, rs, imm6 3 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits Write the results of R-Type instruction to Rd Why need multipleor here? Rd Rt RegDst Mu Don t Care RegWr 5 Rs 5 5 (Rt) ctr busw busa Rw Ra Rb -bit Result Registers Clk busb imm6 ZeroEt 6 Ori control signals:regdst=?;regwr=?;ctr=?;src=? Ori control signals:regdst=; RegWr=;str=or; Src= Mu Src 6

Datapath for lw (memory access instruction) ADD and subtract add rd, rs, rt sub rd, rs, rt OR Immediate: ori rt, rs, imm6 LOAD and STORE lw rt, rs, imm6 sw rt, rs, imm6 BRANCH: beq rs, rt, imm6 JUMP: j target 3 26 2 6 6 op rs rt rd shamt func 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 3 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits 3 26 op target address 6 bits 26 bits 7

RTL: The Load Instruction 3 lw rt, rs, imm6 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits M[PC] Instruction Fetch Addr R[rs] + SignEt(imm6) Compute the address R[rt] M [Addr] PC PC + 4 Load Data to rt Update PC Why using signed etension rather than zero etension? 3 6 5 3 6 bits 6 5 6 bits immediate 6 bits immediate 6 bits 8

Datapath for Load Instruction R[rt] M[ R[rs] + SignEt[imm6] ] Eample: lw rt, rs, imm6 3 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits Rd Rt RegDst Why? Mu Don t Care Rs RegWr ctr 5 5 5 (Rt) MemtoReg busa Rw Ra Rb busw -bit Clk Registers busb MemWr WrEn Adr Data In imm6 Data 6 Clk Memory Src Et Mu EtOp :zero etension,: sign etension What RegDst=, are control RegWr=, signals ctr=add, -- RegDst, EtOp=, RegWr, ctr, Src=, EtOp, MemWr=, Src, MemWr, MemtoReg= MemtoReg? Mu 9

SW instruction ADD and subtract add rd, rs, rt sub rd, rs, rt OR Immediate: ori rt, rs, imm6 LOAD and STORE lw rt, rs, imm6 sw rt, rs, imm6 BRANCH: beq rs, rt, imm6 JUMP: j target 3 26 2 6 6 op rs rt rd shamt func 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 3 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits 3 26 op target address 6 bits 26 bits

RTL: The Store Instruction 3 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits sw rt, rs, imm6 M[PC] Addr R[rs] + SignEt(imm6) Mem[Addr] R[rt] PC PC + 4

Datapath for SW M[ R[rs] + SignEt[imm6] R[rt] ] Eample: sw rt, rs, imm6 RegDst busw RegWr Clk Rd Rt Mu imm6 5 5 3 Rs 5 Rw Ra Rb -bit Registers 6 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits Why add this? Rt ctr MemWr busa busb Data In WrEn Adr Data Src Clk Memory Et Mu MemtoReg Mu EtOp RegDst=, RegWr=, ctr=add, EtOp=, Src=, MemWr=, MemtoReg= 2

Beq ADD and subtract add rd, rs, rt sub rd, rs, rt OR Immediate: ori rt, rs, imm6 LOAD and STORE lw rt, rs, imm6 sw rt, rs, imm6 BRANCH: beq rs, rt, imm6 JUMP: j target 3 26 2 6 6 op rs rt rd shamt func 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 3 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits 3 26 op target address 6 bits 26 bits 3

RTL: The Branch Instruction 3 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits beq rs, rt, imm6 M[PC] Cond R[rs] - R[rt] Compare rs and rt if (COND eq ) Calculate the net instruction s address PC PC + 4 + ( SignEt(imm6) 4 ) else PC PC + 4 4

Datapath for beq beq rs, rt, imm6 We need to compare Rs and Rt! 3 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits Branch Clk PC Rd Rt RegDst Mu imm6 Net Addr Rs Rt RegWr ctr 5 5 5 6 Logic busa Rw Ra Rb busw -bit Zero To Instruction Clk Registers busb Memory imm6 Q: How to design the addressing logic? 6 EtOp Src Et Mu RegDst=, RegWr=, ctr=sub, EtOp=, Src=, MemWr=, MemtoReg=, Branch= 5

Instruction Fetch Unit at the End of Branch 3 26 2 op rs rt immediate 6 if (Zero == ) then PC = PC + 4 + SignEt[imm6]*4 ; else PC = PC + 4 Branch Inst Memory Adr Instruction<3:> Zero imm6 4 PC Et Adder Adder MUX ctrl PC Mu clk busw Clk RegWr Rs Rt 5 5 5 Rw Ra Rb -bit Registers busb busa ctr Zero 6

Jump Operation ADD and subtract add rd, rs, rt sub rd, rs, rt OR Immediate: ori rt, rs, imm6 LOAD and STORE lw rt, rs, imm6 sw rt, rs, imm6 BRANCH: beq rs, rt, imm6 JUMP: j target 3 26 2 6 6 op rs rt rd shamt func 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 3 26 2 6 op rs rt immediate 6 bits 5 bits 5 bits 6 bits 3 26 op target address 6 bits 26 bits 7

Eecuting Jump Operations Jump operation involves replace the lower 28 bits of the PC with the lower 26 bits of the fetched instruction shifted left by 2 bits Add 4 4 PC Instruction Memory Read Address Instruction 26 Shift left 2 28 Jump address 8

Single Cycle Datapath (Without Jump) 4 Add Op Instr[3-26] Control Unit Branch Src Shift left 2 Add PCSrc MemRead MemtoReg MemWrite PC Read Address Instruction Memory Instr[3-] RegDst Instr[25-2] Instr[2-6] Instr[5 -] Read Addr Register Read Read Addr 2 Data File Write Addr Write Data RegWrite Read Data 2 ovf zero Address Data Memory Write Data Read Data Instr[5-] Sign 6 Etend control Instr[5-] 9

Step 4: Adding the Control Selecting the operations to perform (, Register File and Memory read/write) Controlling the flow of data (multipleor inputs) Observations op field always in bits 3-26 R-type: addr of registers J-type: to be read are always specified by the op target address rs field (bits 25-2) and rt field (bits 2-6); for lw and sw rs is the base register addr. of register to be written is in one of two places in rt (bits 2-6) for lw; in rd (bits 5-) for R-type instructions offset for beq, lw, and sw always in bits 5-3 25 2 5 5 op rs rt rd shamt funct 3 25 2 5 I-Type: op rs rt address offset 3 25 2

R-type Instruction Data/Control Flow 4 Add Op Instr[3-26] Control Unit Branch Src Shift left 2 Add PCSrc MemRead MemtoReg MemWrite PC Read Address Instruction Memory Instr[3-] RegDst Instr[25-2] Instr[2-6] Instr[5 -] Read Addr Register Read Read Addr 2 Data File Write Addr Write Data RegWrite Read Data 2 ovf zero Address Data Memory Write Data Read Data Instr[5-] Sign 6 Etend control Instr[5-] 2

Load Word Instruction Data/Control Flow 4 Add Op Instr[3-26] Control Unit Branch Src Shift left 2 Add PCSrc MemRead MemtoReg MemWrite PC Read Address Instruction Memory Instr[3-] RegDst Instr[25-2] Instr[2-6] Instr[5 -] Read Addr Register Read Read Addr 2 Data File Write Addr Write Data RegWrite Read Data 2 ovf zero Address Data Memory Write Data Read Data Instr[5-] Sign 6 Etend control Instr[5-] 22

Branch Instruction Data/Control Flow 4 Add Op Instr[3-26] Control Unit Branch Src Shift left 2 Add PCSrc MemRead MemtoReg MemWrite PC Read Address Instruction Memory Instr[3-] RegDst Instr[25-2] Instr[2-6] Instr[5 -] Read Addr Register Read Read Addr 2 Data File Write Addr Write Data RegWrite Read Data 2 ovf zero Address Data Memory Write Data Read Data Instr[5-] Sign 6 Etend control Instr[5-] 23

Adding the Jump Operation 4 Add Instr[25-] 26 Op Instr[3-26] Shift left 2 Control Unit 28 Branch PC+4[3-28] Jump Src Shift left 2 Add PCSrc MemRead MemtoReg MemWrite PC Read Address Instruction Memory Instr[3-] RegDst Instr[25-2] Instr[2-6] Instr[5 -] Read Addr Register Read Read Addr 2 Data File Write Addr Write Data RegWrite Read Data 2 ovf zero Address Data Memory Write Data Read Data Instr[5-] Sign 6 Etend control Instr[5-] 24

Assemble Control Logic Instruction<3:> Inst Memory Adr <:5> <:5> <6:2> <2:25> <2:25> Op Fun Rt Rs Rd Imm6 Decoder npc_sel RegWr RegDst EtOp Src ctr MemWr MemtoReg Equal DATA PATH 25

A Summary of the Control Signals func We Don t Care :-) op add sub ori lw sw beq jump RegDst Src MemtoReg RegWrite MemWrite Branch Jump EtOp ctr<2:> Add Subtr Or Add Add Subtr R-type 3 26 2 6 6 op rs rt rd shamt func add, sub I-type op rs rt immediate ori, lw, sw, beq J-type op target address jump 26

The Concept of Local Decoding Two levels of decoding: Main Control and Control RegDst Src MemtoReg RegWrite MemWrite Branch Jump EtOp ctr op op 6 How many bits will N need? R-type ori lw sw beq jump Add/Subtr Or Add Add Subtr Main Control R, or, +, -, and, func 6 op N=? 3, why? Control (Local) ctr 3 ctr is determined by op and func, while other control signals are determined by op 27

The Decoding of the func Field op 6 Main Control Encoding op as follows func 6 op N Control (Local) ctr R-type ori lw sw beq jump op (Symbolic) R-type Or Add Add Subtr op<2:> 3 3 26 2 6 6 R-type rs rt rd shamt func func<5:> Instruction Operation ctr ctr<2:> Operation add Add subtract Subtract and or And Or set-on-less-than Subtract 28

The Truth Table for ctr R-type Instructions determined by funct Non-R-type Instructions determined by op op R-type ori lw sw beq (Symbolic) R-type Or Add Add Subtr op<2:> funct<3:> Instruction Op. add subtract and or set-on-less-than op func bit2 bit bit bit<3> bit<2> bit<> bit<> Operation ctr bit<2> bit<> bit<> Add Subtract Or Add Subtract And Or Subtract 29

The Logic Equation for ctr<> Choose the rows with ctr[]= op func bit<2> bit<> bit<> bit<3> bit<2> bit<> bit<> ctr<> This makes func<3> a don t care ctr<> =!op<2> & op<> + op<2> &!func<2> & func<> &!func<> 3

The Logic Equation for ctr<> Choose the rows with ctr[]= op func bit<2> bit<> bit<> bit<3> bit<2> bit<> bit<> ctr<> ctr<> =!op<2> & op<> &! op<> + op<2> &!func<3> & func<2> &!func<> 3

The Logic Equation for ctr<2> Choose the rows with ctr[2]= op func bit<2> bit<> bit<> bit<3> bit<2> bit<> bit<> ctr<2> ctr<2> =!op<2> & op<> &!op<> + op<2> &!func<3> & func<2> &!func<> & func<>

Summary of Control Logic of Local Control func 6 op 3 Contro l (Local) ctr 3 ctr<> =!op<2> & op<> + op<2> &!func<2> & func<> &!func<> ctr<> =!op<2> & op<> &!op<> + op<2> &!func<3> & func<2> &!func<> ctr<2> =!op<2> & op<> &!op<> + op<2> &!func<3> & func<2> &!func<> & func<> 33

The Truth Table for the Main Control op 6 Output of Main Control Input of main control Main Control RegDst Src : op 3 func 6 Control (Local) op R-type ori lw sw beq jump RegDst Src MemtoReg RegWrite MemWrite Branch Jump EtOp op (Symbolic) R-type Or Add Add Subtr op <2> op <> op <> ctr 3 34

The Truth Table for RegWrite op R-type ori lw sw beq jump RegWrite RegWrite = R-type + ori + lw =!op<5> &!op<4> &!op<3> &!op<2> &!op<> &!op<> (R-type) +!op<5> &!op<4> & op<3> & op<2> &!op<> & op<>(ori) + op<5> &!op<4> &!op<3> &!op<2> & op<> & op<>(lw) op<5>.. op<5>.. op<5>.. op<5>.. op<5>.. op<5>.. <> <> <> <> <> op<> Decoder R-type ori lw sw beq jump RegWrite 35

Assemble Main Control (PLA) op<5>.. op<5>.. op<5>.. op<5>.. op<5>.. op<5>.. <> <> <> <> <> op<> Decoder R-type ori lw sw beq jump RegWrite Src RegDst MemtoReg MemWrite Branch Jump EtOp op<2> op<> op<> 36

The Complete Single Cycle Data Path with Control op 6 Instr<3:26> RegDst busw Clk RegWr Main Control Rd Mu imm6 Instr<5:> Rt 5 5 Rs 5 Rw Ra Rb -bit Registers 6 op RegDst Src : Rt busb Et Branch Jump Clk busa 3 Instr<5:> Mu ctr Src func Instruction Fetch Unit Data In 6 Clk Zero Instruction<3:> Rt <2:25> Control WrEn Rs MemWr Data <6:2> Adr Memory ctr Rd <:5> 3 <:5> Imm6 MemtoReg Mu EtOp 37