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

Similar documents
CS61C : Machine Structures

UC Berkeley CS61C : Machine Structures

CS61C : Machine Structures

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

CS61C : Machine Structures

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

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

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

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

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

ECE468 Computer Organization and Architecture. Designing a Single Cycle Datapath

CpE242 Computer Architecture and Engineering Designing a Single Cycle Datapath

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

CS61C : Machine Structures

Ch 5: Designing a Single Cycle Datapath

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

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 1

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

CS 110 Computer Architecture Single-Cycle CPU Datapath & Control

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

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

UC Berkeley CS61C : Machine Structures

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

CPU Organization (Design)

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

If you didn t do as well as you d hoped

COMP303 Computer Architecture Lecture 9. Single Cycle Control

Lecture #17: CPU Design II Control

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

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

CS61C : Machine Structures

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

UC Berkeley CS61C : Machine Structures

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

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

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

UC Berkeley CS61C : Machine Structures

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

Major CPU Design Steps

Lecture 6 Datapath and Controller

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

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

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

MIPS-Lite Single-Cycle Control

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

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

CPU Design Steps. EECC550 - Shaaban

CS3350B Computer Architecture Winter 2015

Working on the Pipeline

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

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

The Processor: Datapath & Control

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

Midterm I March 3, 1999 CS152 Computer Architecture and Engineering

Processor (I) - datapath & control. Hwansoo Han

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

CENG 3420 Lecture 06: Datapath

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

CSE140: Components and Design Techniques for Digital Systems

Midterm I March 12, 2003 CS152 Computer Architecture and Engineering

Chapter 4. The Processor

Chapter 4. The Processor

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

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

CPE 335 Computer Organization. Basic MIPS Architecture Part I

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

Midterm I October 6, 1999 CS152 Computer Architecture and Engineering

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

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

The MIPS Processor Datapath

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

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

1048: Computer Organization

CS3350B Computer Architecture Quiz 3 March 15, 2018

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

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

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

Designing a Multicycle Processor

Single Cycle CPU Design. Mehran Rezaei

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

Review: Abstract Implementation View

Lecture 10: Simple Data Path

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

Lecture 7 Pipelining. Peng Liu.

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

ECE260: Fundamentals of Computer Engineering

Systems Architecture

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

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

LECTURE 5. Single-Cycle Datapath and Control

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

CS Computer Architecture Spring Week 10: Chapter

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

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

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

CS 61c: Great Ideas in Computer Architecture

Computer and Information Sciences College / Computer Science Department The Processor: Datapath and Control

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

Transcription:

CS6C L9 CPU Design : Designing a Single-Cycle CPU () insteecsberkeleyedu/~cs6c CS6C : Machine Structures Lecture #9 Designing a Single-Cycle CPU 27-7-26 Scott Beamer Instructor AI Focuses on Poker Review N-bit adder-subtractor done using N - bit adders with XOR gates on input XOR serves as conditional inverter CPU design involves path,control path in MIPS involves 5 CPU stages ) Instruction Fetch 2) Instruction Decode & Register Read 3) (Execute) 4) 5) Register Write nytimescom CS6C L9 CPU Design : Designing a Single-Cycle CPU (2) path Summary The datapath based on data transfers required to perform instructions A controller causes the right transfers to happen +4 instruction memory rd rs rt imm registers memory CPU clocking (/2) For each instruction, how do we control the flow of information though the datapath? Single Cycle CPU: All stages of an instruction are completed within one long clock cycle The clock cycle is made sufficient long to allow each instruction to complete all stages without interruption and within one cycle Instruction Fetch 2 Decode/ Register Read 5 Reg 3 Execute 4 Write opcode, funct Controller CS6C L9 CPU Design : Designing a Single-Cycle CPU (3) CS6C L9 CPU Design : Designing a Single-Cycle CPU (4) CPU clocking (2/2) For each instruction, how do we control the flow of information though the datapath? Multiple-cycle CPU: Only one stage of instruction per clock cycle The clock is made as long as the slowest stage Instruction Fetch 2 Decode/ Register Read Several significant advantages over single cycle execution: Unused stages in a particular instruction can be skipped OR instructions can be pipelined (overlapped) CS6C L9 CPU Design : Designing a Single-Cycle CPU (5) 3 Execute 4 5 Reg Write How to Design a Processor: step-by-step 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 (hard part!) CS6C L9 CPU Design : Designing a Single-Cycle CPU (6)

CS6C L9 CPU Design : Designing a Single-Cycle CPU (7) Review: The MIPS Instruction Formats All MIPS instructions are bits long 3 formats: R-type I-type J-type 3 26 2 6 6 op rs rt rd shamt funct 5 bits 5 bits 6 bits 3 26 2 6 op rs rt address/immediate 6 bits 3 26 op 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 Step a: The MIPS-lite Subset for today ADDU and SUBU addu rd,rs,rt subu rd,rs,rt OR Immediate: ori rt,rs,imm6 3 LOAD and STORE Word lw rt,rs,imm6 sw rt,rs,imm6 BRANCH: beq rs,rt,imm6 3 26 2 6 6 op rs rt rd shamt funct 5 bits 5 bits 6 bits 3 26 2 6 6 bits 26 2 6 6 bits 3 26 2 6 6 bits CS6C L9 CPU Design : Designing a Single-Cycle CPU (8) Register Transfer Language RTL gives the meaning of the instructions {op, rs, rt, rd, shamt, funct} MEM[ ] {op, rs, rt, Imm6} MEM[ ] All start by fetching the instruction inst Register Transfers ADDU R[rd] R[rs] + R[rt]; + 4 SUBU R[rd] R[rs] R[rt]; + 4 ORI R[rt] R[rs] zero_ext(imm6); + 4 LOAD R[rt] MEM[ R[rs] + sign_ext(imm6)]; + 4 STORE MEM[ R[rs] + sign_ext(imm6) ] R[rt]; + 4 BEQ if ( R[rs] == R[rt] ) then + 4 + (sign_ext(imm6) ) else + 4 CS6C L9 CPU Design : Designing a Single-Cycle CPU (9) Step : Requirements of the Instruction Set (MEM) instructions & data (will use one for each) Registers (R: x ) read RS read RT Write RT or RD (sign/zero extend) Add/Sub/OR unit for operation on register(s) or extended immediate Add 4 or extended immediate to Compare registers? CS6C L9 CPU Design : Designing a Single-Cycle CPU () Step 2: Components of the path Combinational Elements Storage Elements Clocking methodology Combinational Logic Elements (Building Blocks) Adder MUX A B Select A Y B MUX CarryIn Adder Sum CarryOut OP A B Result CS6C L9 CPU Design : Designing a Single-Cycle CPU () CS6C L9 CPU Design : Designing a Single-Cycle CPU (2)

CS6C L9 CPU Design : Designing a Single-Cycle CPU (3) 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(imm6) BEQ if ( R[rs] == R[rt] ) Test to see if output == for any operation gives == test How? P&H also adds AND, Set Less Than ( if A < B, otherwise) follows chap 5 What Hardware Is Needed? (/2) : a register which keeps track of memory addr of the next instruction General Purpose Registers used in Stages 2 (Read) and 5 (Write) MIPS has of these used in Stages (Fetch) and 4 (R/W) cache system makes these two stages as fast as the others, on average CS6C L9 CPU Design : Designing a Single-Cycle CPU (4) What Hardware Is Needed? (2/2) used in Stage 3 something that performs all necessary functions: arithmetic, logicals, etc we ll design details later Miscellaneous Registers In implementations with only one stage per clock cycle, registers are inserted between stages to hold intermediate data and control signals as they travels from stage to stage Note: Register is a general purpose term meaning something that stores bits Not all registers are in the register file CS6C L9 CPU Design : Designing a Single-Cycle CPU (5) Storage Element: Idealized (idealized) In One input bus: In One output bus: Out Clk word is selected by: Address selects the word to put on Out Write Enable = : address selects the memory word to be written via the 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 Out valid after access time CS6C L9 CPU Design : Designing a Single-Cycle CPU (6) Write Enable Address Out Storage Element: Register (Building Block) Similar to D Flip Flop except N-bit input and output Write Enable input Write Enable: negated (or deasserted) (): Out will not change In asserted (): Out will become In on positive edge of clock N Write Enable Out N Storage Element: Register File Register File consists of registers: Two -bit output busses: and One -bit input bus: RWRA RB Write Enable -bit Registers Register is selected by: Clk RA (number) selects the register to put on (data) RB (number) selects the register to put on (data) RW (number) selects the register to be written via (data) when Write Enable is Clock input () The input is a factor ONLY during write operation During read operation, behaves as a combinational logic block: RA or RB valid or valid after access time CS6C L9 CPU Design : Designing a Single-Cycle CPU (7) CS6C L9 CPU Design : Designing a Single-Cycle CPU (8)

CS6C L9 CPU Design : Designing a Single-Cycle CPU (9) Administrivia Assignments HW5 due Tonight HW6 due 7/29 Midterm Grading standards up If you wish to have a problem regraded Staple your reasons to the front of the exam Return your exam to your TA Scott is now holding regular OH on Fridays -2 in 9 Soda Step 3: Assemble Path meeting requirements Register Transfer Requirements path Assembly Instruction Fetch Read Operands and Execute Operation CS6C L9 CPU Design : Designing a Single-Cycle CPU (2) 3a: Overview of the Instruction Fetch Unit The common RTL operations Fetch the Instruction: mem[] Update the program counter: Sequential Code: + 4 Branch and Jump: something else CS6C L9 CPU Design : Designing a Single-Cycle CPU (2) Address Instruction Next Address Logic Instruction Word 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 3 26 2 6 6 ctr and RegWr: control logic after decoding the instruction Rd Rs Rt RegWr -bit Registers CS6C L9 CPU Design : Designing a Single-Cycle CPU (22) op rs rt rd shamt funct 5 bits 5 bits 6 bits ctr Result Already defined the register file & Clocking Methodology Clk Register-Register Timing: One complete cycle Clk Old Value Rs, Rt, Rd, Op, Func ctr New Value Instruction Access Time Old Value New Value Delay through Control Logic Old Value New Value 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 (set-up time), and we have the usual clock-to-q delay Critical path (longest path through logic) determines length of clock period RegWr Old Value New Value Register File Access, B Old Value Time New Value Delay Old Value New Value RegWr Rd Rs Rt ctr Register Write Occurs Here CS6C L9 CPU Design : Designing a Single-Cycle CPU (23) CS6C L9 CPU Design : Designing a Single-Cycle CPU (24)

CS6C L9 CPU Design : Designing a Single-Cycle CPU (25) 3c: Logical Operations with Immediate R[rt] = R[rs] op ZeroExt[imm6] ] RegWr Rd Rs Rt 3 26 2 6 3 6 5 6 bits immediate 6 bits 6 bits But we re writing to Rt register?? ctr 3c: Logical Operations with Immediate R[rt] = R[rs] op ZeroExt[imm6] ] RegDst Rd Rt imm6 6 3 26 2 6 3 6 5 6 bits immediate 6 bits 6 bits ZeroExt What about Rt register read?? ctr Src Already defined -bit MUX; Zero Ext? CS6C L9 CPU Design : Designing a Single-Cycle CPU (26) 3d: Load Operations R[rt] = Mem[R[rs] + SignExt[imm6]] Example: lw rt,rs,imm6 3 26 2 6 6 bits imm6 6 ZeroExt ctr Src 3d: Load Operations R[rt] = Mem[R[rs] + SignExt[imm6]] Example: lw rt,rs,imm6 3 26 2 6 6 bits imm6 6 ctr MemtoReg? WrEn Adr In Src CS6C L9 CPU Design : Designing a Single-Cycle CPU (27) CS6C L9 CPU Design : Designing a Single-Cycle CPU (28) 3e: Store Operations Mem[ R[rs] + SignExt[imm6] ] = R[rt] Ex: sw rt, rs, imm6 3 26 2 6 6 bits ctr MemtoReg imm6 6 In Src WrEn Adr 3e: Store Operations Mem[ R[rs] + SignExt[imm6] ] = R[rt] Ex: sw rt, rs, imm6 3 26 2 6 6 bits ctr MemtoReg imm6 6 In Src WrEn Adr CS6C L9 CPU Design : Designing a Single-Cycle CPU (29) CS6C L9 CPU Design : Designing a Single-Cycle CPU (3)

CS6C L9 CPU Design : Designing a Single-Cycle CPU (3) 3f: The Branch Instruction beq rs, rt, imm6 mem[] Fetch the instruction from memory Equal = R[rs] == R[rt] Calculate branch condition if (Equal) Calculate the next instruction s address = + 4 + ( SignExt(imm6) x 4 ) else 3 26 2 6 6 bits = + 4 path for Branch Operations beq rs, rt, imm6 path generates condition (equal) 4 Ext imm6 Adder Adder 3 26 2 6 6 bits Inst Address n_sel Mux Already have mux, adder, need special sign extender for, need equal compare (sub?) CS6C L9 CPU Design : Designing a Single-Cycle CPU () Equal = ctr Putting it All Together:A Single Cycle path 4 Ext imm6 Adder Adder <2:25> imm6 <6:2> 6 CS6C L9 CPU Design : Designing a Single-Cycle CPU (33) <:5> Adr Rs Rt Rd n_sel RegDst Rd Rt Mux Inst <:5> Imm6 Equal Instruction<3:> Src ctr MemtoReg = In WrEn Adr Peer Instruction A For the CPU designed so far, the Controller only needs to look at opcode/funct and Equal B Adding jal would only require changing the Instruction Fetch block C Making our single-cycle CPU multi-cycle will be easy CS6C L9 CPU Design : Designing a Single-Cycle CPU (34) ABC : FFF : FFT 2: FTF 3: FTT 4: TFF 5: TFT 6: TTF 7: TTT How to Design a Processor: step-by-step 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 CS6C L9 CPU Design : Designing a Single-Cycle CPU (35)