Designing a Single Cycle Datapath

Similar documents
Review: MIPS Addressing Modes/Instruction Formats

Computer organization

Computer Organization and Components

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Reduced Instruction Set Computer (RISC)

Introducción. Diseño de sistemas digitales.1

Instruction Set Architecture

Pipeline Hazards. Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. Based on the material prepared by Arvind and Krste Asanovic

Solutions. Solution The values of the signals are as follows:

Design of Digital Circuits (SS16)

CS352H: Computer Systems Architecture

Design of Pipelined MIPS Processor. Sept. 24 & 26, 1997

Pipeline Hazards. Structure hazard Data hazard. ComputerArchitecture_PipelineHazard1

l C-Programming l A real computer language l Data Representation l Everything goes down to bits and bytes l Machine representation Language

16-bit ALU, Register File and Memory Write Interface

Microprocessor & Assembly Language

MICROPROCESSOR AND MICROCOMPUTER BASICS

Let s put together a Manual Processor

(Refer Slide Time: 00:01:16 min)

Instruction Set Design

Addressing The problem. When & Where do we encounter Data? The concept of addressing data' in computations. The implications for our machine design(s)

CSE 141 Introduction to Computer Architecture Summer Session I, Lecture 1 Introduction. Pramod V. Argade June 27, 2005

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995

CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions

Execution Cycle. Pipelining. IF and ID Stages. Simple MIPS Instruction Formats

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

A s we saw in Chapter 4, a CPU contains three main sections: the register section,

Chapter 9 Computer Design Basics!

Systems I: Computer Organization and Architecture

To design digital counter circuits using JK-Flip-Flop. To implement counter using 74LS193 IC.

COMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December :59

Central Processing Unit (CPU)

CPU Organisation and Operation

CS 61C: Great Ideas in Computer Architecture Finite State Machines. Machine Interpreta4on

Generating MIF files

Preface. Any questions from last time? A bit more motivation, information about me. A bit more about this class. Later: Will review 1st 22 slides

In the Beginning The first ISA appears on the IBM System 360 In the good old days

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC

The 104 Duke_ACC Machine

Systems I: Computer Organization and Architecture

CPU Organization and Assembly Language

Chapter 01: Introduction. Lesson 02 Evolution of Computers Part 2 First generation Computers

Chapter 2 Logic Gates and Introduction to Computer Architecture

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings:

LSN 2 Computer Processors

İSTANBUL AYDIN UNIVERSITY

8085 INSTRUCTION SET

PART B QUESTIONS AND ANSWERS UNIT I

MACHINE ARCHITECTURE & LANGUAGE

Computer Organization. and Instruction Execution. August 22

Computer Organization and Architecture

CS:APP Chapter 4 Computer Architecture. Wrap-Up. William J. Taffe Plymouth State University. using the slides of

Chapter 2 Basic Structure of Computers. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

Digital Logic Design. Basics Combinational Circuits Sequential Circuits. Pu-Jen Cheng

EC 362 Problem Set #2

Sequential Logic. (Materials taken from: Principles of Computer Hardware by Alan Clements )

A SystemC Transaction Level Model for the MIPS R3000 Processor

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

EECS 427 RISC PROCESSOR

ECE410 Design Project Spring 2008 Design and Characterization of a CMOS 8-bit Microprocessor Data Path

WEEK 8.1 Registers and Counters. ECE124 Digital Circuits and Systems Page 1

CSE 141L Computer Architecture Lab Fall Lecture 2

TIMING DIAGRAM O 8085

Giving credit where credit is due

Memory unit. 2 k words. n bits per word

Summary of the MARIE Assembly Language

Memory Elements. Combinational logic cannot remember

CHAPTER 4 MARIE: An Introduction to a Simple Computer

Chapter 7. Registers & Register Transfers. J.J. Shann. J. J. Shann

BASIC COMPUTER ORGANIZATION AND DESIGN

Lecture 3 Addressing Modes, Instruction Samples, Machine Code, Instruction Execution Cycle

ARM. Architecture and Assembly. Modest Goal: Turn on an LED

Memory ICS 233. Computer Architecture and Assembly Language Prof. Muhamed Mudawar

A New Paradigm for Synchronous State Machine Design in Verilog

Computer Architecture TDTS10

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

SIM-PL: Software for teaching computer hardware at secondary schools in the Netherlands

Central Processing Unit

Systems I: Computer Organization and Architecture

Computer Organization and Components

ECE 3401 Lecture 7. Concurrent Statements & Sequential Statements (Process)

CHAPTER 7: The CPU and Memory

Processor Architectures

Router Architectures

Q. Consider a dynamic instruction execution (an execution trace, in other words) that consists of repeats of code in this pattern:

Solution: start more than one instruction in the same clock cycle CPI < 1 (or IPC > 1, Instructions per Cycle) Two approaches:

Instruction Set Architecture (ISA)

Lecture-3 MEMORY: Development of Memory:

1 Classical Universal Computer 3

ASYNCHRONOUS COUNTERS

Instruction Set Architecture. Datapath & Control. Instruction. LC-3 Overview: Memory and Registers. CIT 595 Spring 2010

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

ETEC 2301 Programmable Logic Devices. Chapter 10 Counters. Shawnee State University Department of Industrial and Engineering Technologies

Techniques for Accurate Performance Evaluation in Architecture Exploration

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z)

EE361: Digital Computer Organization Course Syllabus

Lecture Outline. Stack machines The MIPS assembly language. Code Generation (I)

Transcription:

Designing a Single Cycle Datapath Computer Science 14 cps 14 1 Outline of Today s Lecture Homework #3 Projects Reading Ch 41-43 Where are we with respect to the BIG picture? The Steps of Designing a Processor Datapath and timing for Reg-Reg Operations Datapath for Logical Operations with Immediate Datapath for Load and Store Operations Datapath for Branch and Jump Operations cps 14 2

Projects: What to submit Project description: eg, interpretations of instructions and description of principles behind design Source code (commented) Design files (full project directory) A description of each team member s contribution Demonstration cps 14 3 What is Computer Architecture? Coordination of levels of abstraction Application CPU Compiler Operating System Digital Design Circuit Design Firmware I/O system Software Interface Between HW and SW Set Architecture,, I/O Hardware Under a set of rapidly changing technology Forces cps 14 4

The Big Picture: Where are We Now? The Five Classic Components of a Computer Processor Control Input Datapath Output Today s Topic: Datapath Design cps 14 5 Datapath Design How do we build hardware to implement the MIPS instructions? Add, LW, SW, Beq, Jump cps 14 6

An Abstract View of the Implementation PC Address Ideal Rd 5 Rs 5 Rt 5 Imm Rw Ra Rb -bit A B Data Address Data In Ideal Data DataOut cps 14 7 The MIPS Formats All MIPS instructions are bits long The three instruction formats: 26 21 11 6 R-type op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits I-type 26 21 op rs rt immediate 6 bits 5 bits 5 bits bits J-type 26 op target address 6 bits 26 bits The different fields are: op: operation 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 the jump instruction cps 14 8

The MIPS Subset (We can t implement them all!) ADD and subtract add rd, rs, rt sub rd, rs, rt OR Immediate: ori rt, rs, imm LOAD and STORE lw rt, rs, imm sw rt, rs, imm BRANCH: beq rs, rt, imm 26 21 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 bits 11 6 JUMP: j target 26 op target address 6 bits 26 bits cps 14 9 The Hardware Program How do I build the hardware to implement the MIPS instructions and their sequencing? Fetch Decode Operand Fetch Execute Result Store Next cps 14 1

Combinational Logic Elements (Basic Building Blocks) Adder A Adder CarryIn Sum B Carry MUX Select A B MUX Y OP A Result B Zero cps 14 11 Storage Element: Register (Basic Building Block) Register Similar to the D Flip Flop except - N-bit input and output - Write Enable input Write Enable: - negated (): Data Out will not change - asserted (1): Data Out will become the same as Data In Write Enable Data In N Data Out N cps 14 12

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: RA selects the register to put on busa RB selects the register to put on busb RW selects the register to be written via busw when Write Enable is 1 Clock input (CLK) RW RA RB Write Enable 5 5 5 busw The CLK input is a factor ONLY during write operation -bit During read operation, behaves as a combinational logic block: - RA or RB valid => busa or busb valid after access time busa busb cps 14 13 Storage Element: Idealized Write Enable Address (idealized) One input bus: Data In One output bus: Data Out word is selected by: Write Enable = : Address selects the word to put on the Data Out bus Write Enable = 1: Address selects the memory word to be written via the Data In bus Clock input (CLK) Data In 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 cps 14 14

An Abstract View of the Implementation PC Address Ideal Rd 5 Rs 5 Rt 5 Imm Rw Ra Rb -bit A B Data Address Data In Ideal Data DataOut cps 14 15 Clocking Methodology Setup Hold Don t Care Setup Hold All storage elements are clocked by the same clock edge Cycle Time >= CLK-to-Q + Longest Delay Path + Setup + Clock Skew Longest delay path = critical path cps 14

An Abstract View of the Critical Path Register file and ideal memory: The CLK input is a factor ONLY during write operation During read operation, behave as combinational logic: - Address valid => Output valid after access time PC Address Ideal Rd 5 Rs 5 Rt 5 Imm Rw Ra Rb -bit Data Address Data In Ideal Data DataOut cps 14 17 The Steps of Designing a Processor Set Architecture => Register Transfer Language Register Transfer Language => Datapath components Datapath interconnect Datapath components => Control signals Control signals => Control logic cps 14 18

Overview of the Fetch Unit The common RTL operations Fetch the : mem[pc] Update the program counter: - Sequential Code: PC <- PC + 4 - Branch and Jump: PC <- something else PC Next Address Logic Address Word cps 14 19 RTL: The ADD add rd, rs, rt mem[pc] Fetch the instruction from memory R[rd] <- R[rs] + R[rt] The ADD operation PC <- PC + 4 Calculate the next instruction s address cps 14 2

RTL: The Load lw rt, rs, imm mem[pc] Fetch the instruction from memory Address <- R[rs] + SignExt(imm) Calculate the memory address R[rt] <- Mem[Address] Load the data into the register PC <- PC + 4 Calculate the next instruction s address cps 14 21 RTL: The ADD 26 21 11 6 op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits add rd, rs, rt mem[pc] Fetch the instruction from memory R[rd] <- R[rs] + R[rt] The actual operation PC <- PC + 4 Calculate the next instruction s address cps 14 22

RTL: The Subtract 26 21 11 6 op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits sub rd, rs, rt mem[pc] Fetch the instruction from memory R[rd] <- R[rs] - R[rt] The actual operation PC <- PC + 4 Calculate the next instruction s address cps 14 23 Datapath for Register-Register Operations R[rd] <- R[rs] op R[rt] Example: add rd, rs, rt Ra, Rb, and Rw comes from instruction s rs, rt, and rd fields ctr and RegWr: control logic after decoding the instruction fields: op and func 26 21 11 6 op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits busw RegWr Rd Rs 5 5 5 Rw Ra Rb -bit Rt busa busb ctr Result cps 14 24

Register-Register Timing Inst fetch Decode Opr fetch Execute Write Back PC Old Value Rs, Rt, Rd, Op, Func ctr RegWr busa, B busw cps 14 25 busw -to-q New Value Old Value Old Value Old Value Old Value Old Value RegWr Access Time New Value Rd Rs Rt 5 5 5 Rw Ra Rb -bit Delay through Control Logic New Value busa busb New Value Register File Access Time New Value ctr Result Delay New Value Register Write Occurs Here RTL: The OR Immediate 26 21 op rs rt immediate 6 bits 5 bits 5 bits bits ori rt, rs, imm mem[pc] Fetch the instruction from memory R[rt] <- R[rs] or ZeroExt(imm) The OR operation PC <- PC + 4 Calculate the next instruction s address bits 15 immediate bits cps 14 26

Datapath for Logical Operations with Immediate R[rt] <- R[rs] op ZeroExt[imm]] Example: ori rt, rs, imm 26 21 op rs rt immediate 6 bits 5 bits 5 bits bits Rd Rt RegDst Don t Care Rs RegWr (Rt) 5 5 5 busw imm Rw Ra Rb -bit busb ZeroExt busa Src ctr Result cps 14 27 RTL: The Load lw rt, rs, imm 26 21 op rs rt immediate 6 bits 5 bits 5 bits bits mem[pc] Fetch the instruction from memory Address <- R[rs] + SignExt(imm) Calculate the memory address R[rt] <- Mem[Address] Load the data into the register PC <- PC + 4 Calculate the next instruction s address 15 bits 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 bits immediate bits immediate bits cps 14 28

Datapath for Load Operations R[rt] <- Mem[R[rs] + SignExt[imm]] Example: lw rt, rs, imm 26 21 op rs rt immediate 6 bits 5 bits 5 bits bits Rd Rt RegDst Don t Care Rs RegWr (Rt) 5 5 5 busw imm Rw Ra Rb -bit busb Extender busa Src ctr Data In MemWr WrEn Adr Data MemtoReg cps 14 29 ExtOp RTL: The Store 26 6 bits 5 bits 5 bits bits sw rt, rs, imm 21 op rs rt immediate mem[pc] Fetch the instruction from memory Address <- R[rs] + SignExt(imm) Calculate the memory address Mem[Address] <- R[rt] Store the register into memory PC <- PC + 4 Calculate the next instruction s address cps 14 3

Datapath for Store Operations Mem[R[rs] + SignExt[imm] <- R[rt]] Example: sw rt, rs, imm 26 21 op rs rt immediate 6 bits 5 bits 5 bits bits RegDst busw Rd Rt RegWr 5 5 imm Rs Rt 5 Rw Ra Rb -bit busb Extender busa Src ctr Data In MemWr WrEn Adr Data MemtoReg cps 14 ExtOp RTL: The Branch 26 21 op rs rt immediate 6 bits 5 bits 5 bits bits beq rs, rt, imm mem[pc] Fetch the instruction from memory Cond <- R[rs] - R[rt] Calculate the branch condition if (COND eq ) Calculate the next instruction s address - PC <- PC + 4 + ( SignExt(imm) x 4 ) else - PC <- PC + 4 cps 14

Datapath for Branch Operations beq rs, rt, imm We need to compare Rs and Rt! 26 21 op rs rt immediate 6 bits 5 bits 5 bits bits Rd Rt RegDst Rs Rt RegWr 5 5 5 busw imm Rw Ra Rb -bit busb Extender busa Src ctr imm Branch Zero PC Next Address Logic To cps 14 33 ExtOp Binary Arithmetic for the Next Address In theory, the PC is a -bit byte address into the instruction memory: Sequential operation: PC<:> = PC<:> + 4 Branch operation: PC<:> = PC<:> + 4 + SignExt[Imm] * 4 The magic number 4 always comes up because: The -bit PC is a byte address And all our instructions are 4 bytes ( bits) long In other words: The 2 LSBs of the -bit PC are always zeros There is no reason to have hardware to keep the 2 LSBs In practice, we can simplify the hardware by using a 3-bit PC<:2>: Sequential operation: PC<:2> = PC<:2> + 1 Branch operation: PC<:2> = PC<:2> + 1 + SignExt[Imm] In either case: --Address = PC<:2> concat cps 14 34

Next Address Logic: Expensive and Fast Solution Using a 3-bit PC: Sequential operation: PC<:2> = PC<:2> + 1 Branch operation: PC<:2> = PC<:2> + 1 + SignExt[Imm] In either case: --Address = PC<:2> concat PC 3 1 imm <15:> SignExt Adder 3 3 3 3 Adder 3 1 Addr<:2> Addr<1:> <:> Branch Zero cps 14 35 Next Address Logic 3 PC imm <15:> 3 SignExt 3 1 3 1 Carry In Adder 3 Addr<:2> Addr<1:> <:> Branch Zero cps 14 36

RTL: The Jump 26 op target address 6 bits 26 bits j target mem[pc] Fetch the instruction from memory PC <- PC+4<:28> concat target<25:> concat <> Calculate the next instruction s address cps 14 37 Fetch Unit j target PC<:2> <- PC+4<:28> concat target<25:> 3 PC+4<:28> 4 Target <25:> 26 3 3 1 Addr<:2> Addr<1:> PC 3 1 imm <15:> Adder SignExt 3 Adder 3 3 1 Jump <:> Branch Zero cps 14 38

Putting it All Together: A Single Cycle Datapath We have everything except control signals RegDst busw 1 Rs Rt RegWr 5 5 5 Rd imm Rt Rw Ra Rb -bit busb Extender Branch Jump busa 1 Src Fetch Unit ctr Data In Zero <:> Rt <21:25> WrEn Rs <:2> MemWr Adr Data Rd <11:15> <:15> Imm 1 MemtoReg cps 14 39 ExtOp