Rocky K. C. Chang 6 November 2017

Slides:



Advertisements
Similar presentations
331 W08.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 8: Datapath Design [Adapted from Dave Patterson’s UCB CS152.
Advertisements

The Processor: Datapath & Control
Lec 17 Nov 2 Chapter 4 – CPU design data path design control logic design single-cycle CPU performance limitations of single cycle CPU multi-cycle CPU.
Computer Structure - Datapath and Control Goal: Design a Datapath  We will design the datapath of a processor that includes a subset of the MIPS instruction.
The Processor 2 Andreas Klappenecker CPSC321 Computer Architecture.
Copyright 1998 Morgan Kaufmann Publishers, Inc. All rights reserved. Digital Architectures1 Machine instructions execution steps (1) FETCH = Read the instruction.
The Processor: Datapath & Control. Implementing Instructions Simplified instruction set memory-reference instructions: lw, sw arithmetic-logical instructions:
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
Chapter 4 CSF 2009 The processor: Building the datapath.
Processor: Datapath and Control
Lec 15Systems Architecture1 Systems Architecture Lecture 15: A Simple Implementation of MIPS Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
Gary MarsdenSlide 1University of Cape Town Chapter 5 - The Processor  Machine Performance factors –Instruction Count, Clock cycle time, Clock cycles per.
ECE 445 – Computer Organization
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /19/2013 Lecture 17: The Processor - Overview Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
CDA 3101 Fall 2013 Introduction to Computer Organization
CS2100 Computer Organisation The Processor: Datapath (AY2015/6) Semester 1.
CPU Overview Computer Organization II 1 February 2009 © McQuain & Ribbens Introduction CPU performance factors – Instruction count n Determined.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
COM181 Computer Hardware Lecture 6: The MIPs CPU.
MIPS Processor.
Morgan Kaufmann Publishers The Processor
May 22, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 14: A Simple Implementation of MIPS * Jeremy R. Johnson Mon. May 17, 2000.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
EE204 Computer Architecture
CS Computer Architecture Week 10: Single Cycle Implementation
CS161 – Design and Architecture of Computer Systems
Single-Cycle Datapath and Control
Single Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Morgan Kaufmann Publishers
Introduction CPU performance factors
/ Computer Architecture and Design
Morgan Kaufmann Publishers The Processor
Morgan Kaufmann Publishers
Processor Architecture: Introduction to RISC Datapath (MIPS and Nios II) CSCE 230.
Morgan Kaufmann Publishers The Processor
Processor (I).
CS/COE0447 Computer Organization & Assembly Language
Design of the Control Unit for Single-Cycle Instruction Execution
MIPS processor continued
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Designing MIPS Processor (Single-Cycle) Presentation G
Morgan Kaufmann Publishers The Processor
CSCI206 - Computer Organization & Programming
CS/COE0447 Computer Organization & Assembly Language
Single-Cycle CPU DataPath.
CS/COE0447 Computer Organization & Assembly Language
Design of the Control Unit for One-cycle Instruction Execution
CSCI206 - Computer Organization & Programming
MIPS Processor.
Datapath & Control MIPS
Morgan Kaufmann Publishers The Processor
Topic 5: Processor Architecture Implementation Methodology
Composing the Elements
Composing the Elements
The Processor Lecture 3.2: Building a Datapath with Control
Topic 5: Processor Architecture
Systems Architecture I
COMS 361 Computer Organization
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Lecture 14: Single Cycle MIPS Processor
Processor: Multi-Cycle Datapath & Control
Single Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
MIPS processor continued
CS/COE0447 Computer Organization & Assembly Language
The Processor: Datapath & Control.
COMS 361 Computer Organization
MIPS Processor.
Processor: Datapath and Control
CS/COE0447 Computer Organization & Assembly Language
Presentation transcript:

Rocky K. C. Chang 6 November 2017 7. Building datapath Rocky K. C. Chang 6 November 2017

Goals of this lecture We will implement a subset of MIPS instructions using single clock cycle. Simple subset, shows most aspects Memory reference: lw, sw Arithmetic/logical: add, sub, and, or, slt Control transfer: beq, j

Instruction Processing Fetch instruction from memory Decode instruction Evaluate address Fetch operands from memory Execute operation Store result

Instruction Execution Morgan Kaufmann Publishers 6 December, 2018 Instruction Execution The first two steps are the same for all instructions: PC  instruction memory, fetch instruction PC  PC + 4 Decode the instruction: The operation and operands (register numbers, immediate, target address) Depending on the instruction class Use ALU to calculate Arithmetic-logical result Memory address for load/store Branch target address Access data memory for load/store PC  target address Chapter 4 — The Processor

Morgan Kaufmann Publishers 6 December, 2018 CPU Overview Chapter 4 — The Processor

Morgan Kaufmann Publishers 6 December, 2018 Multiplexers Can’t just join wires together Use multiplexers Chapter 4 — The Processor

Morgan Kaufmann Publishers 6 December, 2018 Control Chapter 4 — The Processor

Morgan Kaufmann Publishers 6 December, 2018 Building a Datapath Datapath Elements that process data and addresses in the CPU Registers, ALUs, mux’s, memories, … We will build a MIPS datapath incrementally Refining the overview design Chapter 4 — The Processor

Morgan Kaufmann Publishers 6 December, 2018 Instruction Fetching Program counter Adder Instruction memory Which one(s) is combinational / sequential circuit? Do they need control signal? Increment by 4 for next instruction 32-bit register Chapter 4 — The Processor

R-Format Instructions Morgan Kaufmann Publishers 6 December, 2018 R-Format Instructions E.g., add $s0,$s1,$s2 Read two register operands Perform arithmetic/logical operation Write register result Controlled by a write control signal Chapter 4 — The Processor

Load/Store Instructions (I format) Morgan Kaufmann Publishers 6 December, 2018 Load/Store Instructions (I format) lw/sw $t1, offset_value($t2) Read register operands Calculate address using 16-bit offset Use ALU, but sign-extend offset Load: Read memory and update register Store: Write register value to memory Chapter 4 — The Processor

Branch Instructions (I format) 1/2 Morgan Kaufmann Publishers 6 December, 2018 Branch Instructions (I format) 1/2 beq $t1, $t2, offset Read register operands Compare operands Use ALU, subtract and check Zero output Calculate target address Sign-extend displacement Shift left 2 places (word displacement) Add to PC + 4 Already calculated by instruction fetch Chapter 4 — The Processor

Morgan Kaufmann Publishers 6 December, 2018 Branch Instructions 2/2 Just re-routes wires Sign-bit wire replicated Chapter 4 — The Processor

Composing the Elements Morgan Kaufmann Publishers 6 December, 2018 Composing the Elements The data path does an instruction in one clock cycle. Each datapath element can only do one function at a time. Hence, we need separate instruction and data memories. Use multiplexers where alternate data sources are used for different instructions. Chapter 4 — The Processor

R-format/Load/Store Datapath 1/2 Problem: Building a datapath for R-format instructions and load/store instructions. Their main differences: One of the inputs to the ALU is different: a register for R-format instructions and a sign-extended 16-bit offset from the load/store instructions. The value stored in the destination register: the ALU for R-format and the memory for the load instruction. Solution: Allow two different sources for the input to the ALU. Allow two different sources for the data stored into the register file.

R-format/Load/Store Datapath 2/2 Morgan Kaufmann Publishers 6 December, 2018 R-format/Load/Store Datapath 2/2 Chapter 4 — The Processor

Full Datapath for R-format, load/store and branch Morgan Kaufmann Publishers 6 December, 2018 Full Datapath for R-format, load/store and branch Chapter 4 — The Processor

A simple implementation scheme Implement a subset of MIPS32 using the datapath from the last slide and a control function. This subset includes add, sub, AND, OR, set on less than lw, sw, beq, and j

ALU Control (from a Simple ALU) 1/4 Morgan Kaufmann Publishers 6 December, 2018 ALU Control (from a Simple ALU) 1/4 The four-bit ALU control: 1-bit Ainvert, 1-bit Binvert and 2-bit Operation 2-bit Operation: 00 (AND), 01 (OR), 10 (add), 11 (set-on-less-than) ALU control Function 0000 AND 0001 OR 0010 add 0110 subtract 0111 set-on-less-than 1100 NOR Chapter 4 — The Processor

ALU Control 2/4 AND: R-format OR: R-format Add: R-format and load/store Subtract: R-format and branch equal Set-on-less-than: R-format NOR: for other instructions

Morgan Kaufmann Publishers 6 December, 2018 ALU Control 3/4 Design a combinational logic circuit for generating the 4-bit ALU control bits Input: 2-bit ALUOp (derived from opcode) and the 6-bit function field in R- format instructions. opcode ALUOp Operation Funct ALU function ALU control lw 00 load word XXXXXX add 0010 sw store word beq 01 branch equal subtract 0110 R-type 10 Add 100000 Subtract 100010 AND 100100 0000 OR 100101 0001 set-on-less-than 101010 0111 Chapter 4 — The Processor

ALU control 4/4 2-bit ALUOp Main control Opcode ALU control Funct field for R-format instructions

Review question Design the combinational circuit for the ALU control unit on slide 21.

Other seven control signals

Morgan Kaufmann Publishers 6 December, 2018 Instruction decoding Identify the fields of an instruction and the control lines needed for slide 17. R-type rs rt rd shamt funct 31:26 5:0 25:21 20:16 15:11 10:6 Load/ Store 35 or 43 rs rt address 31:26 25:21 20:16 15:0 4 rs rt address 31:26 25:21 20:16 15:0 Branch opcode always read read, except for load write for R-format and load sign-extend and add Chapter 4 — The Processor

Instruction decoding op[5:0]: inputs to the main control unit for generating control signals for all instructions rs[25:21] and rt[20:16]: registers to be read for the R-format instructions, branch equal, and store. rs[25:21]: base register for load and store instructions. The destination register: rt[20:16] for load and rd[15:11] for R-format instructions. Need a multiplexer to select between the two. funct[5:0]: inputs to the ALU control

Morgan Kaufmann Publishers 6 December, 2018 Chapter 4 — The Processor

Data path for R-format instructions For example, add $t1,$t2,$t3. Three steps: The instruction fetched and the PC incremented Two registers, $t2 and $t3, read from the register file; the main control unit computes the setting of the control lines. The ALU operates on the data read from the register file, using the function code to generate the ALU function. These steps will be completed in one clock cycle.

Morgan Kaufmann Publishers 6 December, 2018 Which control lines should be active? Chapter 4 — The Processor

Data path for load instruction For example, lw $t1, offset($t2) Five steps: An instruction fetched and the PC incremented A register ($t2) value read from the register file The ALU computes the sum of the value read from the register file and the sign-extended, lower 16 bits of the instruction. The sum from the ALU is used as the address for the data memory. The data from the memory unit is written into the register file; the register destination is given by bits 20:16 of the instruction ($t1).

Morgan Kaufmann Publishers 6 December, 2018 Which control lines should be active? Chapter 4 — The Processor

Data path for Branch-on-Equal Instruction For example, beq $t1, $t2, offset Four steps: An instruction fetched and the PC incremented. Two registers, $t1 and $t2, read from the register file. The ALU performs a subtract on the data values read from the register file. Also, the value of PC + 4 is added to the sign-extended, lower 16 bits of the instruction shifted left by two; the result is the branch target address. The Zero result from the ALU is used to decide which adder result to store into the PC.

Morgan Kaufmann Publishers 6 December, 2018 Which control lines should be active? Chapter 4 — The Processor

Review question Fill in the table below. ALUSrc R-format lw sw beq Instruction RegDst ALUSrc Memto- Reg Reg- Write Mem- Read Branch ALUOp1 ALUOp0 R-format lw sw beq

Review question Design the digital logic circuit for the main control unit.

Morgan Kaufmann Publishers 6 December, 2018 Performance Issues Longest delay determines clock period Critical path: load instruction Instruction memory  register file  ALU  data memory  register file Not feasible to vary period for different instructions Violates design principle Making the common case fast Pipelining can improve performance. Chapter 4 — The Processor

Conclusions We have implemented R-format, store/load, and bne MIPS instructions using a single clock cycle. The main control unit The ALU control unit The ALU unit Two adders The memory (instruction and data) Register file 4 MUXes Sign extend Bit shifter AND gate PC

Reading Read B.7-B.8 in David Patterson and John Hennessy, Computer Organization and Design, 5th edition, Morgan Kaufmann, 2014.

Acknowledgements This set of slides are prepared mainly based on The slides prepared by K. Asanovic & V. Stojanovic for CS61C at UC/Berkeley (http://inst.eecs.Berkeley.edu/~cs61c/sp15)