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

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

CS61C : Machine Structures

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

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

CS61C : Machine Structures

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

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

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!

UC Berkeley CS61C : Machine Structures

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

CpE242 Computer Architecture and Engineering Designing a Single Cycle Datapath

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

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

CS 110 Computer Architecture Single-Cycle CPU Datapath & Control

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

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

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

Lecture #17: CPU Design II Control

Ch 5: Designing a Single Cycle Datapath

CPU Organization (Design)

CS61C : Machine Structures

COMP303 Computer Architecture Lecture 9. Single Cycle Control

CS3350B Computer Architecture Winter 2015

UC Berkeley CS61C : Machine Structures

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

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

UC Berkeley CS61C : Machine Structures

MIPS-Lite Single-Cycle Control

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

CPU Design Steps. EECC550 - Shaaban

Working on the Pipeline

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

CS61C : Machine Structures

Midterm I March 3, 1999 CS152 Computer Architecture and Engineering

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

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

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

UC Berkeley CS61C : Machine Structures

Major CPU Design Steps

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

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

The Processor: Datapath & Control

Single Cycle CPU Design. Mehran Rezaei

If you didn t do as well as you d hoped

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

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

Designing a Multicycle Processor

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

Lecture 6 Datapath and Controller

CS3350B Computer Architecture Quiz 3 March 15, 2018

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

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

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

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

Midterm I October 6, 1999 CS152 Computer Architecture and Engineering

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

Truth Table! Review! Use this table and techniques we learned to transform from 1 to another! ! Gate Diagram! Today!

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

Midterm I March 12, 2003 CS152 Computer Architecture and Engineering

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

The MIPS Processor Datapath

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

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

CENG 3420 Lecture 06: Datapath

Processor (I) - datapath & control. Hwansoo Han

Systems Architecture

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

CpE 442. Designing a Multiple Cycle Controller

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

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

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

CS Computer Architecture Spring Week 10: Chapter

Guerrilla Session 3: MIPS CPU

Midterm I March 1, 2001 CS152 Computer Architecture and Engineering

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

Chapter 4. The Processor

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

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

Review: Abstract Implementation View

CPSC614: Computer Architecture

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

CS61c Final Review Fall Andy Carle 12/12/2004

Chapter 4. The Processor

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

ECE468 Computer Organization and Architecture. Designing a Multiple Cycle Controller

ECE260: Fundamentals of Computer Engineering

Lecture 7 Pipelining. Peng Liu.

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

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

Chapter 5: The Processor: Datapath and Control

Single Cycle Datapath

Laboratory 5 Processor Datapath

CSE 141 Computer Architecture Summer Session I, Lecture 3 Performance and Single Cycle CPU Part 1. Pramod V. Argade

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

Transcription:

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Single- Cycle CPU Datapath Control Part 1 Instructors: Krste Asanovic & Vladimir Stojanovic hfp://inst.eecs.berkeley.edu/~cs61c/

Review Timing constraints for Finite State Machines Setup Qme, Hold Time, Clock to Q Qme Use muxes to select among inputs S control bits selects from 2S inputs Each input can be n- bits wide, indep of S Can implement muxes hierarchically ALU can be implemented using a mux Coupled with basic block elements

How to design Adder/Subtractor?" Truth-table, then determine canonical form, then minimize and implement as we ve seen before" Look at breaking the problem down into smaller pieces that we can cascade or hierarchically layer"

Adder/Subtractor One-bit adder LSB "

Adder/Subtractor One-bit adder (1/2) "

Adder/Subtractor One-bit adder (2/2)"

N 1-bit adders 1 N-bit adder" b 0 " + + + What about overflow? Overflow = c n?

Extremely Clever Subtractor " + + + XOR serves as conditional inverter! x! y! XOR(x,y)! 0! 0! 0! 0! 1! 1! 1! 0! 1! 1! 1! 0!

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

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

Five Stages of InstrucQon ExecuQon Stage 1: InstrucQon Fetch Stage 2: InstrucQon Decode Stage 3: ALU (ArithmeQc- Logic Unit) Stage 4: Memory Access Stage 5: Register Write

Stages of ExecuQon (1/5) There is a wide variety of MIPS instrucqons: so what general steps do they have in common? Stage 1: InstrucQon Fetch no mafer what the instrucqon, the - bit instrucqon 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 instrucqon: byte addressing so + 4)

Stages of ExecuQon (2/5) Stage 2: InstrucQon Decode upon fetching the instrucqon, we next gather data from the fields (decode all necessary instrucqon data) first, read the opcode to determine instrucqon 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

Stages of ExecuQon (3/5) Stage 3: ALU (ArithmeQc- Logic Unit) the real work of most instrucqons is done here: arithmeqc (+, -, *, /), shiging, 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 addiqon in this stage

Stages of ExecuQon (4/5) Stage 4: Memory Access actually only the load and store instrucqons do anything during this stage; the others remain idle during this stage or skip it all together since these instrucqons 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

Stages of ExecuQon (5/5) Stage 5: Register Write most instrucqons write the result of some computaqon into a register examples: arithmeqc, logical, shigs, loads, slt what about stores, branches, jumps? don t write anything into a register at the end these remain idle during this figh stage or skip it all together

Administrivia 2/24/15 Fall 2011 - - Lecture #28 17

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

Datapath Walkthroughs (1/3) add $r3,$r1,$r2 # r3 = r1+r2 Stage 1: fetch this instrucqon, 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

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

Datapath Walkthroughs (2/3) slq $r3,$r1,17 # if (r1 <17 ) r3 = 1 else r3 = 0 Stage 1: fetch this instrucqon, increment PC Stage 2: decode to determine it is an slq, 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

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

Datapath Walkthroughs (3/3) sw $r3,17($r1) # Mem[r1+17]=r3 Stage 1: fetch this instrucqon, 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)

Example: sw InstrucQon 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

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 instrucqons tend to idle for at least one stage? Five stages are the union of all the operaqons needed by all the instrucqons. One instrucqon uses all five stages: the load

Why Five Stages? (2/2) lw $r3,17($r1) # r3=mem[r1+17] Stage 1: fetch this instrucqon, 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

Example: lw InstrucQon 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]

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

In the News At ISSCC 2015 in San Francisco yesterday, 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 instrucqons per cycle, 2 threads/core Up to 24 processor chips in shared memory node 2/24/15 Fall 2011 - - Lecture #28 29

Register Now: Berkeley IAP Workshop on the Future of Cloud Technologies Friday, February 27, 2015 Soda Hall Berkeley, CA q POSTERS: $500 Prizes for Best Undergrad & Best Grad q CAREER FAIR: During Lunch/Breaks, Bring Your Resume hfp://www.industry- academia.org/event- berkeley- cloud- workshop.html Industry-Academia Partnership 2015 All Rights Reserved Quotes from the MIT Workshop I was excited by the turnout and the breadth of the speakers. - Prof. Matei Zaharia, CTO Databricks In a nutshell, the workshop is an excellent opportunity for students, faculties and people from industry to share ideas. Po-An Tsai, PhD Student, MIT CSAIL, Best Poster Award

Processor Design: 5 steps Step 1: Analyze instrucqon set to determine datapath requirements Meaning of each instrucqon 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 implementaqon of each instrucqon to determine sewng of control points that realizes the register transfer Step 5: Assemble the control logic

The MIPS InstrucQon Formats All MIPS instrucqons 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: operaqon ( opcode ) of the instrucqon rs, rt, rd: the source and desqnaqon register specifiers shamt: shig amount funct: selects the variant of the operaqon in the op field address / immediate: address offset or immediate value target address: target address of jump instrucqon 21 16 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 26 21 16 op rs rt address/immediate 11 6 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 BRANCH: 31 31 31 31 beq rs,rt,imm16 26 21 16 op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 26 21 op rs rt immediate 6 bits 5 bits 5 bits 16 bits 26 21 op rs rt immediate 6 bits 5 bits 5 bits 16 bits 26 21 op rs rt immediate 6 bits 5 bits 5 bits 16 bits 16 16 16 11 6 0 0 0 0

Register Transfer Level (RTL) Colloquially called Register Transfer Language RTL gives the meaning of the instrucqons All start by fetching the instrucqon itself {op, rs, rt, rd, shamt, funct} MEM[ PC ]! {op, rs, rt, Imm16} MEM[ PC ]! Inst 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!

Step 1: Requirements of the InstrucQon Set Memory (MEM) InstrucQons & 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 operaqon on register(s) or extended immediate (ALU) Add 4 (+ maybe extended immediate) to PC Compare registers?

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

ALU Needs for MIPS- lite + Rest of MIPS AddiQon, subtracqon, 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 operaqon gives == test. How? P&H also adds AND, Set Less Than (1 if A < B, 0 otherwise) ALU follows Chapter 5

Storage Element: Idealized Memory Write Enable Address Magic Memory Data In One input bus: 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 wrifen via the Data In bus Clock input (CLK) CLK input is a factor ONLY during write operaqon During read operaqon, behaves as a combinaqonal logic block: Address valid Data Out valid ager access Qme DataOut

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 posiqve 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 wrifen via busw (data) when Write Enable is 1 Clock input (clk) Clk input is a factor ONLY during write operaqon During read operaqon, behaves as a combinaqonal logic block: RA or RB valid busa or busb valid ager access Qme. Clk RW RA RB 5 5 5 x - bit Registers busa busb

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

Step 3b: Add & Subtract R[rd] = R[rs] op R[rt] (addu rd,rs,rt)! Ra, Rb, and Rw come from instrucqon 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 ager decoding the instrucqon busw Rd Rs Rt RegWr 5 5 5 clk Rw Ra Rb x - bit Registers busa busb Already defined the register file & ALU ALUctr ALU Result

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

Register- Register Timing: One Complete Cycle Clk PC Old Value Rs, Rt, Rd, Op, Func ALUctr New Value Old Value Old Value InstrucQon 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 Rd Rs Rt ALUctr 5 5 5 Register Write Rw Ra Rb busa busw Occurs Here RegFile busb clk ALU

Puwng it All Together:A Single Cycle Datapath 4 PC Ext imm16 Adder Adder npc_sel Mux Inst Memory 00 PC clk Adr Rs RegDst Rd RegWr busw 1 clk <21:25> imm16 Rt 0 <16:20> Rt Rs 5 5 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

Peer InstrucQon A. Our ALU is a synchronous device B. We should use the main ALU to compute PC = PC + 4 C. The ALU is inacqve for memory reads or writes. Op:on 1 2 3 A F F F A T T T B F T F C F T T C T F F D T F T E T T F E F F T

Processor Design: 3 of 5 steps Step 1: Analyze instrucqon set to determine datapath requirements Meaning of each instrucqon 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 implementaqon of each instrucqon to determine sewng of control points that realizes the register transfer Step 5: Assemble the control logic

In Conclusion Divide and Conquer to build complex logic blocks from smaller simpler pieces (adder) Five stages of MIPS instrucqon execuqon Mapping instrucqons to datapath components Single long clock cycle per instrucqon 2/24/15 Fall 2011 - - Lecture #28 48