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

Similar documents
CS61C : Machine Structures

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

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

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

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

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

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

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

CpE242 Computer Architecture and Engineering Designing a Single Cycle Datapath

UC Berkeley CS61C : Machine Structures

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

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

CS61C : Machine Structures

ECE468 Computer Organization and Architecture. Designing a Single Cycle Datapath

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

CS61C : Machine Structures

CS 110 Computer Architecture Single-Cycle CPU Datapath & Control

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

Ch 5: Designing a Single Cycle Datapath

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

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

CPU Organization (Design)

Lecture #17: CPU Design II Control

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

CS3350B Computer Architecture Winter 2015

COMP303 Computer Architecture Lecture 9. Single Cycle Control

CS61C : Machine Structures

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

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

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

MIPS-Lite Single-Cycle Control

UC Berkeley CS61C : Machine Structures

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

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

Midterm I March 3, 1999 CS152 Computer Architecture and Engineering

CPU Design Steps. EECC550 - Shaaban

Working on the Pipeline

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

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

The Processor: Datapath & Control

UC Berkeley CS61C : Machine Structures

Major CPU Design Steps

CS3350B Computer Architecture Quiz 3 March 15, 2018

Single Cycle CPU Design. Mehran Rezaei

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

Lecture 6 Datapath and Controller

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

CS61C : Machine Structures

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

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

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

If you didn t do as well as you d hoped

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Lecture 27: Single- Cycle CPU Datapath Design

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

Designing a Multicycle Processor

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

The MIPS Processor Datapath

Processor (I) - datapath & control. Hwansoo Han

Midterm I October 6, 1999 CS152 Computer Architecture and Engineering

UC Berkeley CS61C : Machine Structures

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

Adding Support for jal to Single Cycle Datapath (For More Practice Exercise 5.20)

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

Clever Signed Adder/Subtractor. Five Components of a Computer. The CPU. Stages of the Datapath (1/5) Stages of the Datapath : Overview

Midterm I March 12, 2003 CS152 Computer Architecture and Engineering

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

CENG 3420 Lecture 06: Datapath

Chapter 4. The Processor

Chapter 4. The Processor

Systems Architecture

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

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

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

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

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

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

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

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

CS Computer Architecture Spring Week 10: Chapter

Guerrilla Session 3: MIPS CPU

ECE260: Fundamentals of Computer Engineering

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

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

Midterm I March 1, 2001 CS152 Computer Architecture and Engineering

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

Laboratory 5 Processor Datapath

ECE232: Hardware Organization and Design

Chapter 4. The Processor. Instruction count Determined by ISA and compiler. We will examine two MIPS implementations

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

Chapter 4. The Processor Designing the datapath

Review: Abstract Implementation View

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

CPSC614: Computer Architecture

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

Lecture 7 Pipelining. Peng Liu.

CPE 335 Computer Organization. Basic MIPS Architecture Part I

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

1048: Computer Organization

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

CpE 442. Designing a Multiple Cycle Controller

Transcription:

CS 61C: Great Ideas in Computer Architecture Datapath Instructors: John Wawrzynek & Vladimir Stojanovic http://inst.eecs.berkeley.edu/~cs61c/fa15 1

Components of a Computer Processor Control Enable? Read/Write Memory Input Datapath PC Address Program Bytes Registers Write Data Arithmetic & Logic Unit (ALU) Read Data Data Output Processor-Memory Interface I/O-Memory Interfaces 2

The CPU Processor (CPU): the active part of the computer that does all the work (data manipulation and decision-making) Datapath: portion of the processor that contains hardware necessary to perform operations required by the processor (the brawn) Control: portion of the processor (also in hardware) that tells the datapath what needs to be done (the brain) 3

Datapath and Control Datapath designed to support data transfers required by instructions Controller causes correct transfers to happen PC instruction memory rd rs rt registers ALU Data memory +4 imm opcode, funct Controller 4

Five Stages of Instruction Execution Stage 1: Instruction Fetch Stage 2: Instruction Decode Stage 3: ALU (Arithmetic-Logic Unit) Stage 4: Memory Access Stage 5: Register Write 5

Stages of Execution on Datapath PC instruction memory rd rs rt registers ALU Data memory +4 imm 1. Instruction Fetch 2. Decode/ Register Read 3. Execute 4. Memory 5. Register Write 6

Stages of Execution (1/5) There is a wide variety of MIPS instructions: so what general steps do they have in common? Stage 1: Instruction Fetch no matter what the instruction, the -bit instruction word must first be fetched from memory (the cache-memory hierarchy) also, this is where we Increment PC (that is, PC = PC + 4, to point to the next instruction: byte addressing so + 4) 7

Stages of Execution (2/5) Stage 2: Instruction Decode upon fetching the instruction, we next gather data from the fields (decode all necessary instruction data) first, read the opcode to determine instruction type and field lengths second, read in data from all necessary registers for add, read two registers for addi, read one register for jal, no reads necessary 8

Stages of Execution (3/5) Stage 3: ALU (Arithmetic-Logic Unit) the real work of most instructions is done here: arithmetic (+, -, *, /), shifting, logic (&, ), comparisons (slt) what about loads and stores? lw $t0, 40($t1) the address we are accessing in memory = the value in $t1 PLUS the value 40 so we do this addition in this stage 9

Stages of Execution (4/5) Stage 4: Memory Access actually only the load and store instructions do anything during this stage; the others remain idle during this stage or skip it all together since these instructions have a unique step, we need this extra stage to account for them as a result of the cache system, this stage is expected to be fast 10

Stages of Execution (5/5) Stage 5: Register Write most instructions write the result of some computation into a register examples: arithmetic, logical, shifts, loads, slt what about stores, branches, jumps? don t write anything into a register at the end these remain idle during this fifth stage or skip it all together 11

Stages of Execution on Datapath PC instruction memory rd rs rt registers ALU Data memory +4 imm 1. Instruction Fetch 2. Decode/ Register Read 3. Execute 4. Memory 5. Register Write 12

Datapath Walkthroughs (1/3) add $r3,$r1,$r2 # r3 = r1+r2 Stage 1: fetch this instruction, increment PC Stage 2: decode to determine it is an add, then read registers $r1 and $r2 Stage 3: add the two values retrieved in Stage 2 Stage 4: idle (nothing to write to memory) Stage 5: write result of Stage 3 into register $r3 13

Example: add Instruction PC add r3, r1, r2 instruction memory 3 1 2 registers reg[1] reg[2] reg[1] + reg[2] ALU Data memory +4 imm 14

Datapath Walkthroughs (2/3) slti $r3,$r1,17 # if (r1 <17 ) r3 = 1 else r3 = 0 Stage 1: fetch this instruction, increment PC Stage 2: decode to determine it is an slti, then read register $r1 Stage 3: compare value retrieved in Stage 2 with the integer 17 Stage 4: idle Stage 5: write the result of Stage 3 (1 if reg source was less than signed immediate, 0 otherwise) into register $r3 15

Example: slti Instruction PC slti r3, r1, 17 instruction memory x 1 3 registers reg[1] reg[1] < 17? ALU Data memory +4 imm 17 16

Datapath Walkthroughs (3/3) sw $r3,17($r1) # Mem[r1+17]=r3 Stage 1: fetch this instruction, increment PC Stage 2: decode to determine it is a sw, then read registers $r1 and $r3 Stage 3: add 17 to value in register $r1 (retrieved in Stage 2) to compute address Stage 4: write value in register $r3 (retrieved in Stage 2) into memory address computed in Stage 3 Stage 5: idle (nothing to write into a register) 17

Example: sw Instruction PC sw r3, 17(r1) instruction memory x 1 3 registers reg[1] reg[3] reg[1] + 17 ALU Data memory +4 imm 17 MEM[r1+17] = r3 18

Why Five Stages? (1/2) Could we have a different number of stages? Yes, other ISAs have different natural number of stages Why does MIPS have five if instructions tend to idle for at least one stage? Five stages are the union of all the operations needed by all the instructions. One instruction uses all five stages: the load 19

Why Five Stages? (2/2) lw $r3,17($r1) # r3=mem[r1+17] Stage 1: fetch this instruction, increment PC Stage 2: decode to determine it is a lw, then read register $r1 Stage 3: add 17 to value in register $r1 (retrieved in Stage 2) Stage 4: read value from memory address computed in Stage 3 Stage 5: write value read in Stage 4 into register $r3 20

Example: lw Instruction PC lw r3, 17(r1) instruction memory x 1 3 registers reg[1] reg[1] + 17 ALU Data memory +4 imm 17 MEM[r1+17] 21

Clickers/Peer Instruction Which type of MIPS instruction is active in the fewest stages? A: LW B: BEQ C: J D: JAL E: ADDU 22

In the News At ISSCC 2015 in San Francisco, latest IBM mainframe chip details z13 designed in 22nm SOI technology with seventeen metal layers, 4 billion transistors/chip 8 cores/chip, with 2MB L2 cache, 64MB L3 cache, and 480MB L4 cache. 5GHz clock rate, 6 instructions per cycle, 2 threads/core Up to 24 processor chips in shared memory node 23

Processor Design: 5 steps Step 1: Analyze instruction set to determine datapath requirements Meaning of each instruction is given by register transfers Datapath must include storage element for ISA registers Datapath must support each register transfer Step 2: Select set of datapath components & establish clock methodology Step 3: Assemble datapath components that meet the requirements Step 4: Analyze implementation of each instruction to determine setting of control points that realizes the register transfer Step 5: Assemble the control logic 24

The MIPS Instruction Formats All MIPS instructions are bits long. 3 formats: R-type I-type J-type 31 31 31 op rs rt rd shamt funct 6 bits 5 bits 5 bits 16 bits 26 op 26 target address 6 bits 26 bits The different fields are: op: operation ( opcode ) of the instruction rs, rt, rd: the source and destination register specifiers shamt: shift amount funct: selects the variant of the operation in the op field address / immediate: address offset or immediate value target address: target address of jump instruction 21 16 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 26 21 16 op rs rt address/immediate 11 6 25 0 0 0

The MIPS-lite Subset ADDU and SUBU addu rd,rs,rt subu rd,rs,rt OR Immediate: ori rt,rs,imm16 LOAD and STORE Word lw rt,rs,imm16 sw rt,rs,imm16 31 31 31 31 BRANCH: beq rs,rt,imm16 26 21 16 11 6 op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 26 21 16 op rs rt immediate 6 bits 5 bits 5 bits 16 bits 26 21 16 op rs rt immediate 6 bits 5 bits 5 bits 16 bits 26 21 16 op rs rt immediate 6 bits 5 bits 5 bits 16 bits 26 0 0 0 0

Colloquially called Register Transfer Language RTL gives the meaning of the instructions All start by fetching the instruction itself {op, rs, rt, rd, shamt, funct} MEM[ PC ] {op, rs, rt, Imm16} MEM[ PC ] Inst Register Transfer Level (RTL) Register Transfers ADDU R[rd] R[rs] + R[rt]; PC PC + 4 SUBU R[rd] R[rs] R[rt]; PC PC + 4 ORI R[rt] R[rs] zero_ext(imm16); PC PC + 4 LOAD R[rt] MEM[ R[rs] + sign_ext(imm16)]; PC PC + 4 STORE MEM[ R[rs] + sign_ext(imm16) ] R[rt]; PC PC + 4 BEQ if ( R[rs] == R[rt] ) PC PC + 4 + {sign_ext(imm16), 2 b00} else PC PC + 4 27

Step 1: Requirements of the Instruction Set Memory (MEM) Instructions & data (will use one for each) Registers (R:, -bit wide registers) Read RS Read RT Write RT or RD Program Counter (PC) Extender (sign/zero extend) Add/Sub/OR/etc unit for operation on register(s) or extended immediate (ALU) Add 4 (+ maybe extended immediate) to PC Compare registers? 28

A B Step 2: Components of the Datapath Combinational Elements Storage Elements + Clocking Methodology Building Blocks Adder CarryIn Select A Sum CarryOut B MUX Adder Multiplexer A Y B OP ALU ALU Result 29

ALU Needs for MIPS-lite + Rest of MIPS Addition, subtraction, logical OR, ==: ADDU R[rd] = R[rs] + R[rt];... SUBU R[rd] = R[rs] R[rt];... ORI R[rt] = R[rs] zero_ext(imm16)... BEQ if ( R[rs] == R[rt] )... Test to see if output == 0 for any ALU operation gives == test. How? P&H also adds AND, Set Less Than (1 if A < B, 0 otherwise) ALU follows Chapter 5 30

Storage Element: Idealized Memory Write Enable Address Magic Memory One input bus: Data In Data In One output bus: Data Out Clk Memory word is found by: For Read: Address selects the word to put on Data Out For Write: Set Write Enable = 1: address selects the memory word to be written via the Data In bus Clock input (CLK) CLK input is a factor ONLY during write operation During read operation, behaves as a combinational logic block: Address valid Data Out valid after access time DataOut 31

Storage Element: Register (Building Block) Similar to D Flip Flop except N-bit input and output Write Enable input Write Enable: Data In Negated (or deasserted) (0): Data Out will not change Asserted (1): Data Out will become Data In on positive edge of clock N Write Enable clk Data Out N

Storage Element: Register File Register File consists of registers: Two -bit output busses: busa and busb One -bit input bus: busw Register is selected by: Write Enable busw RA (number) selects the register to put on busa (data) RB (number) selects the register to put on busb (data) RW (number) selects the register to be written via busw (data) when Write Enable is 1 Clock input (clk) Clk input is a factor ONLY during write operation During read operation, behaves as a combinational logic block: RA or RB valid busa or busb valid after access time. Clk RW RA RB 5 5 5 x -bit Registers busa busb 33

Step 3a: Instruction Fetch Unit Register Transfer Requirements Datapath Assembly Instruction Fetch Read Operands and Execute Operation Common RTL operations Fetch the Instruction: mem[pc] Update the program counter: Sequential Code: PC PC + 4 Branch and Jump: PC something else clk PC Address Instruction Memory Next Address Logic Instruction Word 34

Step 3b: Add & Subtract R[rd] = R[rs] op R[rt] (addu rd,rs,rt) Ra, Rb, and Rw come from instruction s Rs, Rt, and Rd fields 31 26 21 16 11 6 0 op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits ALUctr and RegWr: control logic after decoding the instruction busw clk RegWr Rd Rs Rt 5 5 5 Rw Ra Rb x -bit Registers busa busb Already defined the register file & ALU ALUctr ALU Result 35

Clocking Methodology Clk............ Storage elements clocked by same edge Flip-flops (FFs) and combinational logic have some delays Gates: delay from input change to output change Signals at FF D input must be stable before active clock edge to allow signal to travel within the FF (set-up time), and we have the usual clock-to-q delay Critical path (longest path through logic) determines length of clock period 36

Clk Register-Register Timing: One Complete Cycle PC Old Value Rs, Rt, Rd, Op, Func ALUctr New Value Old Value Old Value Instruction Memory Access Time New Value Delay through Control Logic New Value RegWr Old Value New Value Register File Access Time busa, B Old Value New Value ALU Delay busw Old Value New Value RegWr busw clk Rd 5 5 Rs Rw Ra Rb RegFile Rt 5 busa busb ALUctr ALU Register Write Occurs Here 37

Putting it All Together:A Single Cycle Datapath 4 PC Ext imm16 Adder Adder npc_sel Mux Inst Memory 00 PC clk Adr Rs RegDst RegWr busw Rd 1 clk <21:25> Rt 5 5 imm16 0 <16:20> Rt Rs Rw Ra Rb RegFile 16 Rd Rt 5 <11:15> Extender busa busb ExtOp <0:15> Imm16 Equal Instruction<31:0> 0 1 ALUSrc ALUctr MemtoReg MemWr = ALU Data In clk WrEn Adr Data Memory 0 1 38

In Conclusion Divide and Conquer to build complex logic blocks from smaller simpler pieces (adder) Five stages of MIPS instruction execution Mapping instructions to datapath components Single long clock cycle per instruction 39