CS 61C: Great Ideas in Computer Architecture. Lecture 11: Datapath. Bernhard Boser & Randy Katz

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

Processor. Han Wang CS3410, Spring 2012 Computer Science Cornell University. See P&H Chapter , 4.1 4

Computer Science 61C Spring Friedland and Weaver. The MIPS Datapath

CS3350B Computer Architecture Quiz 3 March 15, 2018

Anne Bracy CS 3410 Computer Science Cornell University. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon]

CENG 3420 Lecture 06: Datapath

CS 61c: Great Ideas in Computer Architecture

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

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

Lecture 10: Simple Data Path

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

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

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

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

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

Anne Bracy CS 3410 Computer Science Cornell University. See P&H Chapter: , , Appendix B

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

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

CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Formats

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

CS61C : Machine Structures

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

Lecture 4: MIPS Instruction Set

EECS 151/251A Fall 2017 Digital Design and Integrated Circuits. Instructor: John Wawrzynek and Nicholas Weaver. Lecture 13 EE141

CS 61C Fall 2016 Guerrilla Section 4: MIPS CPU (Datapath & Control)

ECE232: Hardware Organization and Design. Computer Organization - Previously covered

Lecture Topics. Announcements. Today: Single-Cycle Processors (P&H ) Next: continued. Milestone #3 (due 2/9) Milestone #4 (due 2/23)

CS 4200/5200 Computer Architecture I

The MIPS Instruction Set Architecture

CS 61C Summer 2016 Guerrilla Section 4: MIPS CPU (Datapath & Control)

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 3 2/8/2018

Chapter 4. The Processor

COMP303 Computer Architecture Lecture 9. Single Cycle Control

Chapter 4. Instruction Execution. Introduction. CPU Overview. Multiplexers. Chapter 4 The Processor 1. The Processor.


Midterm. Sticker winners: if you got >= 50 / 67

CS 351 Exam 2 Mon. 11/2/2015

UC Berkeley CS61C : Machine Structures

CSE 378 Midterm 2/12/10 Sample Solution

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

The Processor: Datapath & Control

Course Administration

CpE242 Computer Architecture and Engineering Designing a Single Cycle Datapath

ECE260: Fundamentals of Computer Engineering

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

Review of Last Lecture. CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Representation II. Agenda. Dealing With Large Immediates

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

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

A Processor! Hakim Weatherspoon CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

CS 110 Computer Architecture Single-Cycle CPU Datapath & Control

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

MIPS Coding Continued

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

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

Chapter 4. The Processor

CS61C : Machine Structures

Reduced Instruction Set Computer (RISC)

ECE260: Fundamentals of Computer Engineering

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

I-Format Instructions (3/4) Define fields of the following number of bits each: = 32 bits

Midterm I March 3, 1999 CS152 Computer Architecture and Engineering

Midterm Questions Overview

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

Ch 5: Designing a Single Cycle Datapath

CS61C : Machine Structures

Chapter 4. The Processor

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

Pipelining. CSC Friday, November 6, 2015

ECE468 Computer Organization and Architecture. Designing a Single Cycle Datapath

Review: Abstract Implementation View

CENG3420 Lecture 03 Review

Flow of Control -- Conditional branch instructions

CS Computer Architecture Spring Week 10: Chapter

Computer Organization MIPS ISA

MIPS%Assembly% E155%

COMP MIPS instructions 2 Feb. 8, f = g + h i;

Examples of branch instructions

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1

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

3/12/2014. Single Cycle (Review) CSE 2021: Computer Organization. Single Cycle with Jump. Multi-Cycle Implementation. Why Multi-Cycle?

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

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

EECS150 - Digital Design Lecture 9- CPU Microarchitecture. Watson: Jeopardy-playing Computer

Midterm Questions Overview

Inf2C - Computer Systems Lecture Processor Design Single Cycle

Instructions: Language of the Computer

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

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

ECE232: Hardware Organization and Design

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

Single Cycle CPU Design. Mehran Rezaei

Computer Architecture

Binvert Operation (add, and, or) M U X

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

Grading: 3 pts each part. If answer is correct but uses more instructions, 1 pt off. Wrong answer 3pts off.

The Processor: Datapath and Control. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

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

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

The overall datapath for RT, lw,sw beq instrucution

Transcription:

CS 61C: Great Ideas in Computer Architecture Lecture 11: Datapath Bernhard Boser & Randy Katz http://inst.eecs.berkeley.edu/~cs61c

Agenda MIPS Datapath add instruction register transfer level circuit timing control and, addi,... beq, j lw, sw And in Conclusion,... CS 61c Lecture 11: Datapath 2

Processor Processor Control Enable? Read/Write Memory Datapath PC Address Program Bytes Registers Arithmetic & Logic Unit (ALU) Write Data Read Data Data Processor-Memory Interface CS 61c Lecture 11: Datapath 3

Datapath: addu - Specs Green Card MIPS ISA documentation CS 61c Lecture 11: Datapath 4

Instruction Datapath Design: addu Type 31 format (bits) 0 R Op Code (6) rs (5) rt (5) rd (5) shmt (5) funct (6) 0x0 rs rt rd 0 0x21 Effect - Register transfer level, RTL PC PC + 4 R[$rd] R[$rs] + R[$rt] CS 61c Lecture 11: Datapath 5

Circuit: addu Type 31 format (bits) 0 R Op Code (6) rs (5) rt (5) rd (5) shmt (5) funct (6) 0x0 rs rt rd 0 0x21 Register transfer level, RTL PC PC + 4 R[$rd] R[$rs] + R[$rt] CS 61c Lecture 11: Datapath 6

Timing: addu CS 61c Lecture 11: Datapath 7

Controller Controller CS 61c Lecture 11: Datapath 8

Control Signals calu correct ALU operation: add, sub, or, cregw Assert (1) to write to dest register Registers unchanged if 0 Determined by OpCode Func code (R-type instructions) CS 61c Lecture 11: Datapath 9

Control: addu CS 61c Lecture 11: Datapath 10

Control: addu Control Determined from OpCode and Func OpCode Func calu cregw 0x0 0x21 add 1 We will design the controller later For now, let s just remember the required signals CS 61c Lecture 11: Datapath 11

Datapath for addu - Summary Type 31 format (bits) 0 R Op Code (6) rs (5) rt (5) rd (5) shmt (5) funct (6) 0x0 rs rt rd 0 0x24 Register transfer level, RTL PC PC + 4 R[$rd] R[$rs] + R[$rt] OpCode Func calu cregw 0x0 0x21 add 1 CS 61c Lecture 11: Datapath 12

The 61C Mystery Channel Presents The mystery of add and addu CS 61c Lecture 11: Datapath 13

Detective 61C checks the evidence Smoking Gun aka 1-bit adder truth table Which of the following statements is correct? A B C in S C out 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 Answer A B C D E Statement TT is for signed addition TT is for unsigned addition TT is incorrect, its sole purpose is to hide the crime For 32-bit this is irrelevant, anyway TT is for signed and unsigned addition, since (Lecture 1) with two s complement representation they are the SAME CS 61c Lecture 11: Datapath 14

Sinister Motives What s the purpose of having two instructions, add addu? Midterm trick questions? Overflow differs for signed and unsigned! Lecture 1 add Raises exception on overflow, assuming operands are two s complement signed addu Ignores overflow It can therefore be used for signed AND unsigned two s complement numbers Despite its name! What about exceptions on unsigned overflow? Design your own MIPS! Now you know why you need to take 61C! CS 61c 15

When use add, addu? Address (pointer) arithmetic: signed overflow makes no sense always use addu Unsigned ints addu won t report overflow! Signed ints add if you care about overflow e.g. Fortran addu if you don t care about overflow e.g. C CS 61c Lecture 11: Datapath 16

So Since in 61C we program in C we always use addu and never add? You Got It! CS 61c Lecture 11: Datapath 17

And after this interlude 61C returns to rigorous always crystal clear and never confusing engineering facts! No more mystery! CS 61c Lecture 11: Datapath 18

Agenda MIPS Datapath add instruction register transfer level circuit timing control and, addi,... beq, j lw, sw And in Conclusion,... CS 61c Lecture 11: Datapath 19

Datapath for and Type 31 format (bits) 0 R Op Code (6) rs (5) rt (5) rd (5) shmt (5) funct (6) 0x0 rs rt rd 0 0x24 Register transfer level, RTL PC PC + 4 R[$rd] R[$rs] & R[$rt] OpCode Func calu cregw 0x0 0x24 and 1 Same as add except calu Ditto for sub, or, xor,

Agenda MIPS Datapath add instruction register transfer level circuit timing control and, addi,... beq, j lw, sw And in Conclusion,... CS 61c Lecture 11: Datapath 21

Datapath for addiu Type 31 format (bits) 0 I 0x9 rs (5) rt (5) immediate (16) Register transfer level, RTL PC PC + 4 R[$rt] R[$rs] + sign_ext(imm) Updated datapath to support immediate:

New Control Signals cdstreg cimm csignext AddrDst = $rt (not $rd) ALU B = immediate (not $rt) Sign extend immediate CS 61c Lecture 11: Datapath 23

Sign Extension Type 31 format (bits) 0 I 0x9 rs (5) rt (5) immediate (16) Sign extension: 31 0 No sign extension: 31 0 CS 61c Lecture 11: Datapath 24

Control for addiu

Datapath for addiu - Control Type 31 format (bits) 0 I 0x9 rs (5) rt (5) immediate (16) Register transfer level, RTL PC PC + 4 R[$rt] R[$rs] + sign_ext(imm) Instr OpCode Func calu cregw cregdst csignext cimm add 0x0 0x20 add 1 0 0 0 addi CS 61c Lecture 11: Datapath 26

Datapath for addiu - Summary Type 31 format (bits) 0 I 0x8 rs (5) rt (5) immediate (16) Register transfer level, RTL PC PC + 4 R[$rt] R[$rs] + sign_ext(imm) Instr OpCode Func calu cregw cregdst csignext cimm add 0x0 0x20 add 1 0 0 0 addi 0x9 X add 1 1 1 1 CS 61c Lecture 11: Datapath 27

Your Turn - ori I 0xd rs (5) rt (5) immediate (16) Answer OpCode Func calu cregw cregdst csignext cimm A 0xd X or 0 1 0 1 B 0xd X or 1 1 0 1 C 0x0 0xd or 1 1 0 1 D 0xd X ori 1 1 1 1 E 0xd X or 1 1 1 1

Your Turn - ori I 0xd rs (5) rt (5) immediate (16) Answer OpCode Func calu cregw cregdst csignext cimm A 0xd X or 0 1 0 1 B 0xd X or 1 1 0 1 C 0x0 0xd or 1 1 0 1 D 0xd X ori 1 1 1 1 E 0xd X or 1 1 1 1

Gorilla Tutoring Gorilla Sessions Wednesdays 7:30 9:30 pm 405 Soda or 293 Cory 10 tutors review & practice questions Private Tutoring 2 tutors 10 students max Sign-up instructions on Piazza CS 61c Lecture 11: Datapath 30

Agenda MIPS Datapath add instruction register transfer level circuit timing control and, addi,... beq, j lw, sw And in Conclusion,... CS 61c Lecture 11: Datapath 31

Datapath for beq Type 31 format (bits) 0 I 0x5 rs (5) rt (5) offset (16) Register transfer level, RTL PC PC + 4 + if (R[$rs]==R[$rt]) then signext(4*off) else 0 CS 61c Lecture 11: Datapath 32

Control for beq Type 31 format (bits) 0 I 0x4 rs (5) rt (5) offset (16) Instr OpCode Func Zero calu cregw cregdst csignext cimm cbranch addiu 0x9 X X add 1 1 1 1 0 addu 0x0 0x21 X add 1 0 0 0 0 beq CS 61c Lecture 11: Datapath 33

Control for beq Type 31 format (bits) 0 I 0x5 rs (5) rt (5) offset (16) Instr OpCode Func Zero calu cregw cregdst csignext cimm cbranch addi 0x8 X X add 1 1 1 1 0 add 0x0 0x20 X add 1 0 0 0 0 beq 0x4 X 1 sub 0 X X 0 1 CS 61c Lecture 11: Datapath 34 beq 0x4 X 0 sub 0 X X 0 0

Datapath for bneq Type 31 format (bits) 0 I 0x5 rs (5) rt (5) offset (16) Instr OpCode Func Zero calu cregw cregdst csignext cimm cbranch beq 0x4 X 1 sub 0 X X 0 1 beq 0x4 X 0 sub 0 X X 0 0 bneq 0x5 CS 61c Lecture 11: Datapath 35

Agenda MIPS Datapath add instruction register transfer level circuit timing control and, addi,... beq, j lw, sw And in Conclusion,... CS 61c Lecture 11: Datapath 36

Datapath for j Type 31 format (bits) 0 J 0x2 target address (26) Register transfer level, RTL PC[2 28] target address CS 61c Lecture 11: Datapath 37

j Destination address Type 31 format (bits) 0 J 0x2 (6) target address (26) old 31 28 27 2 1 0 PC new 31 28 27 2 1 0 PC CS 61c Lecture 11: Datapath 38

Control for j Type 31 format (bits) 0 J 0x2 target address (26) Instr OpCode Func Zero calu cregw cregdst csignext cimm cbranch cjump addiu 0x9 X X add 1 1 1 1 0 0 addu 0x0 0x21 X add 1 0 0 0 0 0 CS 61c Lecture 11: Datapath 39 j 0x2 X X X 0 X X X X 1

Agenda MIPS Datapath add instruction register transfer level circuit timing control and, addi,... beq, j lw, sw And in Conclusion,... CS 61c Lecture 11: Datapath 40

Datapath for lw Type 31 format (bits) 0 I 0x23 rs (5) rt (5) offset (16) Register transfer level, RTL PC PC + 4 R[$rt] MEM[ R[$rs] + signext(offset) ] CS 61c Lecture 11: Datapath 41

Timing for lw CS 61c Lecture 11: Datapath 42

Control for lw Instr OpCode Func Zero calu cregw cregdst csignext cimm cbr cj clw cmemw addiu 0x9 X X add 1 1 1 1 0 0 0 0 addu 0x0 0x21 X add 1 0 0 0 0 0 0 0 j 0x2 X X X 0 X X X X 1 X 0 lw 0x23 CS 61c Lecture 11: Datapath 43

Control for lw Instr OpCode Func Zero calu cregw cregdst csignext cimm cbr cj clw cmemw addiu 0x9 X X add 1 1 1 1 0 0 0 0 addu 0x0 0x21 X add 1 0 0 0 0 0 0 0 j 0x2 X X X 0 X X X X 1 X 0 lw 0x23 X X add 1 1 1 1 0 0 1 0 CS 61c Lecture 11: Datapath 44

Datapath for sw Type 31 format (bits) 0 I 0x15 rs (5) rt (5) offset (16) Register transfer level, RTL PC PC + 4 MEM[ R[$rs] + signext(offset) ] R[$rt] CS 61c Lecture 11: Datapath 45

Control for sw Instr OpCode Func Zero calu cregw cregdst csignext cimm cbr cj clw cmemw addiu 0x9 X X add 1 1 1 1 0 0 0 0 addu 0x0 0x21 X add 1 0 0 0 0 0 0 0 j 0x2 X X X 0 X X X X 1 X 0 lw 0x23 X X add 1 1 1 1 0 0 1 0 sw 0x2b X X add 0 X 1 1 0 0 X 1 CS 61c Lecture 11: Datapath 46

MIPS Datapath Summary Phase Action Time Slot Hardware Used 1 Fetch instruction t IF Instr Memory 2 Decode instr, read registers t ID Instr Dec, Register File 3 Execute instruction t EX ALU 4 Access data memory t MEM Data Memory 5 Write register, PC t WB Register File, PC Note: not all instructions are active in all phases CS 61c Lecture 11: Datapath 47

Your Turn Which instruction is active in the fewest/most phases? Answer Fewest Most A nor lw B bne sw C j lw D jr lw E slt sw CS 61c Lecture 11: Datapath 48

Your Turn Which instruction is active in the fewest/most phases? Answer Fewest Most A nor lw B bne sw C j lw D jr lw E slt sw CS 61c Lecture 11: Datapath 49

Agenda MIPS Datapath add instruction register transfer level circuit timing control and, addi,... beq, j lw, sw dowhile And in Conclusion,... CS 61c Lecture 11: Datapath 50

MIPS 2000, 4000, MIPS 61C! int j = -1; do // a[i] = b[i] * c[i]; i = i+j; while (i!= 0); New instruction that updates i and branches: dowhile $i, $j, label CS 61c Lecture 11: Datapath 51

dowhile $rt, $rs, label Type 31 format (bits) 0 I 0x61c* rs (5) rt (5) offset (16) *just replace one of the less useful instructions Register transfer level, RTL R[$rt] = R[$rt] + R[$rs] PC PC + 4 + if (R[$rs]==R[$rt]) then signext(4*off) else 0 CS 61c Lecture 11: Datapath 52

Control for dowhile Instr OpCode Zero calu cregw cregdst csignext cimm cbr cj clw cmemw dowhile 0x61c CS 61c Lecture 11: Datapath 53

Control for dowhile Instr OpCode Zero calu cregw cregdst csignext cimm cbr cj clw cmemw dowhile 0x61c 1 add 1 1 X 0 1 0 0 0 0 add 1 1 X 0 0 0 0 0 CS 61c Lecture 11: Datapath 54

Agenda MIPS Datapath add instruction register transfer level circuit timing control and, addi,... beq, j lw, sw And in Conclusion,... CS 61c Lecture 11: Datapath 55

And in Conclusion, Universal datapath Capable of executing all MIPS instructions Not all units (hardware) used by all instructions 5 Phases of execution IF, ID, EX, MEM, WB Not all instructions are active in all phases Controller specifies how to execute instructions Even new ones (dowhile) CS 61c Lecture 11: Datapath 56