CS61C : Machine Structures

Similar documents
CS61C : Machine Structures

UC Berkeley CS61C : Machine Structures

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

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

CS61C : Machine Structures

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

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

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

CS61C : Machine Structures

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

CpE242 Computer Architecture and Engineering Designing a Single Cycle Datapath

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

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

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

ECE468 Computer Organization and Architecture. Designing a Single Cycle Datapath

Lecture #17: CPU Design II Control

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

CS 110 Computer Architecture Single-Cycle CPU Datapath & Control

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

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

CPU Organization (Design)

UC Berkeley CS61C : Machine Structures

Ch 5: Designing a Single Cycle Datapath

COMP303 Computer Architecture Lecture 9. Single Cycle Control

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

UC Berkeley CS61C : Machine Structures

UC Berkeley CS61C : Machine Structures

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

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

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

CS61C : Machine Structures

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

MIPS-Lite Single-Cycle Control

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

CPU Design Steps. EECC550 - Shaaban

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

Single Cycle CPU Design. Mehran Rezaei

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

Working on the Pipeline

Major CPU Design Steps

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

Midterm I March 3, 1999 CS152 Computer Architecture and Engineering

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

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

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

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

The Processor: Datapath & Control

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

Designing a Multicycle Processor

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

If you didn t do as well as you d hoped

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

Lecture 6 Datapath and Controller

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

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

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

CS3350B Computer Architecture Quiz 3 March 15, 2018

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

Midterm I March 12, 2003 CS152 Computer Architecture and Engineering

CSE140: Components and Design Techniques for Digital Systems

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

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

Midterm I October 6, 1999 CS152 Computer Architecture and Engineering

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

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

Processor (I) - datapath & control. Hwansoo Han

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

CS61C : Machine Structures

CENG 3420 Lecture 06: Datapath

CS61C : Machine Structures

CS61C : Machine Structures

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

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

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

The MIPS Processor Datapath

CS3350B Computer Architecture Winter 2015

CS61c Final Review Fall Andy Carle 12/12/2004

CpE 442. Designing a Multiple Cycle Controller

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

Guerrilla Session 3: MIPS CPU

Chapter 4. The Processor

ECE468 Computer Organization and Architecture. Designing a Multiple Cycle Controller

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

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

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

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

Chapter 4. The Processor

CS 110 Computer Architecture Review Midterm II

Midterm I March 1, 2001 CS152 Computer Architecture and Engineering

Inf2C - Computer Systems Lecture Processor Design Single Cycle

Systems Architecture

Review. Pipeline big-delay CL for faster clock Finite State Machines extremely useful You ll see them again in 150, 152 & 164

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

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

Lecture 7 Pipelining. Peng Liu.

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

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

Midterm I March 12, 2003 CS152 Computer Architecture and Engineering

CS Computer Architecture Spring Week 10: Chapter

Transcription:

inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #17 Single Cycle CPU Datapath CPS today! 2005-10-31 There is one handout today at the front and back of the room! Lecturer PSOE, new dad Dan Garcia www.cs.berkeley.edu/~ddgarcia Halloween plans?! Try the Castro, SF! Today 2005-10-31, from 7pm-mid ($5 donation) go at least once CS61C L17 Single Cycle CPU Datapath (1) halloweeninthecastro.com Happy Halloween, everyone!

Wed!s talk : Jim Larus, µsoft (Cal Ph.D.) An Overview of the Singularity Project 306 Soda Hall, Wed 2005-11-02 @ 4-5pm Dr. Larus is the author of SPIM! ftp://ftp.research.microsoft.com/pub/tr/tr-2005-135.pdf Singularity is a research project in Microsoft Research that started with the question: what would a software platform look like if it was designed from scratch with the primary goal of dependability? Singularity is working to answer this question by building on advances in programming languages and tools to develop a new system architecture and operating system (named Singularity), with the aim of producing a more robust and dependable software platform. Singularity demonstrates the practicality of new technologies and architectural decisions, which should lead to the construction of more robust and dependable systems. CS61C L17 Single Cycle CPU Datapath (2)

Review Use muxes to select among input S input bits selects 2 S inputs Each input can be n-bits wide, indep of S Implement muxes hierarchically ALU can be implemented using a mux Coupled with basic block elements N-bit adder-subtractor done using N 1- bit adders with XOR gates on input XOR serves as conditional inverter Programmable Logic Arrays are often used to implement our CL CS61C L17 Single Cycle CPU Datapath (3)

Anatomy: 5 components of any Computer Personal Computer This week and next Computer Processor Control ( brain ) Datapath ( brawn ) Memory (where programs, data live when running) Devices Input Output Keyboard, Mouse Disk (where programs, data live when not running) Display, Printer CS61C L17 Single Cycle CPU Datapath (4)

Outline of Today!s Lecture Design a processor: step-by-step Requirements of the Instruction Set Hardware components that match the instruction set requirements CS61C L17 Single Cycle CPU Datapath (5)

How to Design a Processor: step-by-step 1. Analyze instruction set architecture (ISA)! datapath requirements meaning of each instruction is given by the register transfers datapath must include storage element for ISA registers datapath must support each register transfer 2. Select set of datapath components and establish clocking methodology 3. Assemble datapath meeting requirements 4. Analyze implementation of each instruction to determine setting of control points that effects the register transfer. 5. Assemble the control logic CS61C L17 Single Cycle CPU Datapath (6)

Review: 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 21 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 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 CS61C L17 Single Cycle CPU Datapath (7)

Step 1a: The MIPS-lite Subset for today 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 CS61C L17 Single Cycle CPU Datapath (8)

Register Transfer Language RTL gives the meaning of the instructions {op, rs, rt, rd, shamt, funct} = MEM[ PC ] {op, rs, rt, Imm16} = MEM[ PC ] All start by fetching the instruction 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] ) then PC = PC + 4 + (sign_ext(imm16) 00) else PC = PC + 4 CS61C L17 Single Cycle CPU Datapath (9)

Step 1: Requirements of the Instruction Set Memory (MEM) instructions & data Registers (R: x ) read RS read RT Write RT or RD PC Extender (sign extend) Add and Sub register or extended immediate Add 4 or extended immediate to PC CS61C L17 Single Cycle CPU Datapath (10)

Step 2: Components of the Datapath Combinational Elements Storage Elements Clocking methodology CS61C L17 Single Cycle CPU Datapath (11)

Combinational Logic Elements (Building Blocks) Adder A B Select Adder CarryIn Sum CarryOut MUX A Y B MUX OP ALU A B ALU Result CS61C L17 Single Cycle CPU Datapath (12)

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 chap 5 CS61C L17 Single Cycle CPU Datapath (13)

Administrivia Project 2 graded You have a week (2005-11-07) to regrade My wed OH this week moved to Fri @ 2p Final Exam location TBA (exam grp 14) Sat, 2005-12-17, 12:30 3:30pm ALL students are required to complete ALL of the exam (even if you aced the midterm) Same format as the midterm - 3 Hours - Closed book, except for 2 study sheets + green - Leave your backpacks, books at home CS61C L17 Single Cycle CPU Datapath (14)

Storage Element: Idealized Memory Write Enable Address Memory (idealized) One input bus: Data In Data In One output bus: Data Out Memory word is selected by: Address selects the word to put on Data Out Write Enable = 1: address selects the memory word to be written via the Data In bus Clock input (CLK) The 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 CS61C L17 Single Cycle CPU Datapath (15)

Storage Element: Register (Building Block) Similar to D Flip Flop except - N-bit input and output - Write Enable input Write Enable: - negated (or deasserted) (0): Data Out will not change - asserted (1): Data Out will become Data In Write Enable Data In Data Out N N CS61C L17 Single Cycle CPU Datapath (16)

Storage Element: Register File Register File consists of registers: Two -bit output busses: busa and busb One -bit input bus: busw RWRA RB Write Enable 5 5 5 busw -bit Registers busa busb Register is selected by: 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) The 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. CS61C L17 Single Cycle CPU Datapath (17)

Step 3: Assemble DataPath meeting requirements Register Transfer Requirements! Datapath Assembly Instruction Fetch Read Operands and Execute Operation CS61C L17 Single Cycle CPU Datapath (18)

3a: Overview of the Instruction Fetch Unit The common RTL operations Fetch the Instruction: mem[pc] Update the program counter: - Sequential Code: PC = PC + 4 - Branch and Jump: PC = something else PC Next Address Logic Address Instruction Memory Instruction Word CS61C L17 Single Cycle CPU Datapath (19)

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

Clocking Methodology............ Storage elements clocked by same edge Being physical devices, flip-flops (FF) 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, and we have the usual clock-to-q delay Critical path (longest path through logic) determines length of clock period CS61C L17 Single Cycle CPU Datapath (21)

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 busa, B Old Value Time New Value ALU Delay busw Old Value New Value busw Rd Rs Rt RegWr5 5 5 Rw Ra Rb -bit Registers busa busb ALUctr ALU Result Register Write Occurs Here CS61C L17 Single Cycle CPU Datapath (22)

3c: Logical Operations with Immediate R[rt] = R[rs] op ZeroExt[imm16] ] RegDst busw RegWr Rd imm16 Mux Rs Rt? 5 5 5 Rw Ra Rb -bit Registers 16 Rt 31 busb ZeroExt busa 26 Mux 21 op rs rt immediate 31 6 bits 5 bits 5 bits 16 15 rd? 16 bits 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 bits ALUSrc ALUct r ALU Result 16 11 immediate 16 bits What about Rt register read?? 0 0 Already defined -bit MUX; Zero Ext? CS61C L17 Single Cycle CPU Datapath (23)

3d: Load Operations R[rt] = Mem[R[rs] + SignExt[imm16]] Example: lw rt,rs,imm16 RegDst busw 31 Rd RegWr Mux imm16 26 21 16 op rs rt immediate 6 bits 5 bits 5 bits 16 bits Rt Rs 5 5 5 Rw Ra Rb -bit Registers 16 Rt busb Extender busa Mux ALUctr ALU Data In?? ALUSrc MemWr WrEn Adr Data Memory 0 W_Src Mux ExtOp CS61C L17 Single Cycle CPU Datapath (24)

3e: Store Operations Mem[ R[rs] + SignExt[imm16] ] = R[rt] Ex.: sw rt, rs, imm16 31 26 21 16 op rs rt immediate 6 bits 5 bits 5 bits 16 bits Rd Rt ALUctr MemWr RegDst Mux Rs Rt RegWr5 5 5 busa busw imm16 Rw Ra Rb -bit Registers 16 busb Extender Mux ALU Data In WrEnAdr Data Memory 0 W_Src Mux ExtOp CS61C L17 Single Cycle CPU Datapath (25) ALUSrc

3f: The Branch Instruction beq rs, rt, imm16 mem[pc] Fetch the instruction from memory Equal = R[rs] == R[rt] Calculate branch condition if (Equal) Calculate the next instruction!s address - PC = PC + 4 + ( SignExt(imm16) x 4 ) else - PC = PC + 4 31 26 21 16 0 op rs rt immediate 6 bits 5 bits 5 bits 16 bits CS61C L17 Single Cycle CPU Datapath (26)

Datapath for Branch Operations beq rs, rt, imm16 Datapath generates condition (equal) 4 imm16 PC Ext 31 Adder 26 21 16 op rs rt immediate 6 bits 5 bits 5 bits 16 bits Adder npc_sel Mux 00 PC CS61C L17 Single Cycle CPU Datapath (27) Inst Address RegWr busw Rs Rt 5 5 5 busa Rw Ra Rb -bit Registers busb 0 Cond Already MUX, adder, sign extend, zero Equal?

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

An Abstract View of the Implementation Instruction Address Next Address Ideal Instruction Memory PC Rd 5 Instruction Rs 5 Rt 5 Rw Ra Rb -bit Registers A B Control Control Signals Conditions ALU Data Address Data In Ideal Data Memory Data Out Datapath CS61C L17 Single Cycle CPU Datapath (29)

Peer Instruction A. If the destination reg is the same as the source reg, we could compute the incorrect value! B. We!re going to be able to read 2 registers and write a 3 rd in 1 cycle C. Datapath is hard, Control is easy CS61C L17 Single Cycle CPU Datapath (30) ABC 1: FFF 2: FFT 3: FTF 4: FTT 5: TFF 6: TFT 7: TTF 8: TTT

Peer Instruction A. Our ALU is a synchronous device B. We should use the main ALU to compute PC=PC+4 C. The ALU is inactive for memory reads or writes. CS61C L17 Single Cycle CPU Datapath (31) ABC 1: FFF 2: FFT 3: FTF 4: FTT 5: TFF 6: TFT 7: TTF 8: TTT

Peer Instruction A. SW can peek at HW (past ISA abstraction boundary) for optimizations B. SW can depend on particular HW implementation of ISA C. Timing diagrams serve as a critical debugging tool in the EE toolkit CS61C L17 Single Cycle CPU Datapath () ABC 1: FFF 2: FFT 3: FTF 4: FTT 5: TFF 6: TFT 7: TTF 8: TTT

Peer Instruction A. (a+b) (a+b) = b B. N-input gates can be thought of cascaded 2- input gates. I.e., (a " b " c " d) = a " (b " (c " d)) where " is one of AND, OR, XOR, NAND C. You can use NOR(s) with clever wiring to simulate AND, OR, & NOT CS61C L17 Single Cycle CPU Datapath (33) ABC 1: FFF 2: FFT 3: FTF 4: FTT 5: TFF 6: TFT 7: TTF 8: TTT

Peer Instruction A. Truth table for mux with 4-bits of signals has 2 4 rows B. We could cascade N 1-bit shifters to make 1 N-bit shifter for sll, srl C. If 1-bit adder delay is T, the N-bit adder delay would also be T CS61C L17 Single Cycle CPU Datapath (37) ABC 1: FFF 2: FFT 3: FTF 4: FTT 5: TFF 6: TFT 7: TTF 8: TTT

Summary: Single cycle datapath 5 steps to design a processor 1. Analyze instruction set! datapath requirements 2. Select set of datapath components & establish clock methodology 3. Assemble datapath meeting the requirements 4. Analyze implementation of each instruction to determine setting of control points that effects the register transfer. Processor 5. Assemble the control logic Input Control Control is the hard part Memory Next time! Datapath Output CS61C L17 Single Cycle CPU Datapath (39)