CS161 – Design and Architecture of Computer Systems

Slides:



Advertisements
Similar presentations
The Processor: Datapath & Control
Advertisements

1  1998 Morgan Kaufmann Publishers Chapter Five The Processor: Datapath and Control.
Levels in Processor Design
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
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.
Chapter Five The Processor: Datapath and Control.
Copyright 1998 Morgan Kaufmann Publishers, Inc. All rights reserved. Digital Architectures1 Machine instructions execution steps (1) FETCH = Read the instruction.
©UCB CS 161Computer Architecture Chapter 5 Instructor: L.N. Bhuyan LECTURE 10.
Processor I CPSC 321 Andreas Klappenecker. Midterm 1 Thursday, October 7, during the regular class time Covers all material up to that point History MIPS.
The Processor Andreas Klappenecker CPSC321 Computer Architecture.
The Processor: Datapath & Control. Implementing Instructions Simplified instruction set memory-reference instructions: lw, sw arithmetic-logical instructions:
Chapter 4 Sections 4.1 – 4.4 Appendix D.1 and D.2 Dr. Iyad F. Jafar Basic MIPS Architecture: Single-Cycle Datapath and Control.
Computing Systems The Processor: Datapath and Control.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
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.
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
Datapath and Control Unit Design
1 A single-cycle MIPS processor  An instruction set architecture is an interface that defines the hardware operations which are available to software.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Single-Cycle Datapath and Control.
Elements of Datapath for the fetch and increment The first element we need: a memory unit to store the instructions of a program and supply instructions.
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.
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:
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 9: MIPS Lite 4 th edition: Chapter.
EE204 Computer Architecture
Electrical and Computer Engineering University of Cyprus
Single-Cycle Datapath and Control
Computer Architecture
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers The Processor
Morgan Kaufmann Publishers
MIPS 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
Single Cycle CPU Design
CS/COE0447 Computer Organization & Assembly Language
Single-Cycle CPU DataPath.
Design of the Control Unit for One-cycle Instruction Execution
CSCI206 - Computer Organization & Programming
MIPS Processor.
Levels in Processor Design
Topic 5: Processor Architecture Implementation Methodology
Rocky K. C. Chang 6 November 2017
Composing the Elements
Composing the Elements
The Processor Lecture 3.2: Building a Datapath with Control
The Processor Lecture 3.1: Introduction & Logic Design Conventions
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
Single Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Computer Architecture Processor: Datapath
Chapter Four The Processor: Datapath and Control
MIPS processor continued
The Processor: Datapath & Control.
COMS 361 Computer Organization
MIPS Processor.
Processor: Datapath and Control
CS/COE0447 Computer Organization & Assembly Language
Presentation transcript:

CS161 – Design and Architecture of Computer Systems Single Cycle CPU Design

CPU Organization We will build a CPU to implement our subset of the MIPS ISA Memory Reference Instructions: Load Word (LW) Store Word (SW) Arithmetic and Logic Instructions: ADD, SUB, AND, OR, SLT Branch and Jump Instructions: Branch if equal (BEQ) Jump unconditional (J) These basic instructions exercise a majority of the necessary datapath and control logic for a more complete implementation

Generic Implementation Use program counter (PC) to supply instruction address Get instruction from memory Read registers Use instruction to decide exactly what to do

CPU Implementations Single-cycle CPU (CPI = 1) All instructions execute in a single, long clock cycle Multi-cycle CPU (CPI = n) Instructions can take a different number of short clock cycles to execute

Single-Cycle Datapath Fetch: Use PC address to fetch instruction Decode & Register/Operand Fetch: Determine instruction type and fetch any register operands needed ALU instructions: Perform Add, Sub, etc. and write result back to register LW/SW: Calculate address and perform memory access BEQ/J: Update PC (possibly based on comparison)

Abstract/Simplified View Two types of functional units: Elements that operate on data values (combinational) Elements that contain state (sequential)

State Elements Unclocked vs clocked Clocks used in synchronous logic cycle time rising edge falling edge

Unclocked State Element Set-reset latch Output depends on present inputs and also on past inputs

Latches and Flip-flops Output is equal to the stored value inside the element (don't need to ask for permission to look at the value) Change of state (value) is based on the clock Latches: whenever the inputs change, and the clock is asserted Flip-flop: state changes only on a clock edge (edge-triggered methodology)

D-latch Two inputs: Two outputs: the data value to be stored (D) the clock signal (C) indicating when to read & store D Two outputs: the value of the internal state (Q) and it's complement

D flip-flop (Register) Output changes only on the clock edge

Our Implementation An edge triggered methodology Typical execution: Read contents of some state elements, Send values through some combinational logic Write results to one or more state elements

Register File Built using D flip-flips

Register File Note: We still use the real clock to determine when to write

Simple Implementation Include the functional units we need for each instruction Think of this as a puzzle! 

Instruction Ordering Identify which components each instruction type would use and in what order: ALU-Type, LW, SW, BEQ ALU-Type (ADD R3, R2, R1) PC I-Mem Registers ALU WB to Reg. LW (LW R2, 4(R1)) PC I-Mem Base. Reg. ALU Read Mem WB to Reg. SW (SW R2, 8(R1)) PC I-Mem Base. Reg ALU Write Mem BEQ (BEQ R3, R1, displace) PC I-Mem Register Access Compare If Zero, Update PC = PC+disp

Fetch Components Required operations Components Taking address from PC and reading instruction from memory Incrementing PC to point at next instruction Components PC register Instruction Memory / Cache Adder to increment PC value

Fetch Datapath PC value serves as address to instruction memory while also being incremented by 4 using the adder Instruction word is returned by memory after some delay New PC value is clocked into PC register at end of clock cycle

Fetch Datapath Example The PC and adder operation is shown The PC doesn’t update until the end of the current cycle The instruction being read out from the instruction memory We have shown “assembly” syntax and the field by field machine code breakdown

Modified Fetch Datapath Support for branch instruction added

Modified Fetch Example Mux provides a path for branch target address

Decode Opcode and func. field are decoded to produce other control signals Execution of an ALU instruction (ADD $3,$1,$2) requires reading 2 register values and writing the result to a third REGWrite is an enable signal indicating the write data should be written to the specified register

ALU Datapath ALU takes inputs from register file and performs the add, sub, and, or, slt operations Result is written back to dest. register

Memory Access Datapath Operands are read from register file while offset is sign extended ALU calculates effective address Memory access is performed If LW, read data is written back to register

Branch Datapath BEQ requires… ALU for comparison (examine ‘zero’ output) Sign extension unit for branch offset Adder to add PC and offset Need a separate adder since ALU is used to perform comparison

Memory Access LW and SW require: Sign extension unit for address offset ALU to compute (add) base address + offset Data memory

Combining Datapaths Combine all datapaths into one We can have multiple options for certain inputs Use muxes to select appropriate input for a given instruction Generate control bits to control mux

ALUSrc Mux Mux controlling second input to ALU ALU instruction provides Read Register 2 data to the 2nd input of ALU LW/SW uses 2nd input of ALU as an offset to form effective address

MemtoReg Mux Mux controlling writeback value to register file ALU instructions use the result of the ALU LW uses the read data from data memory

PCSrc Mux Next instruction can either be PC+4, or the branch target address, PC+Offset

RegDst Mux Different destination register ID fields for ALU and LW instructions

Single Cycle CPU Datapath

Control We now have data path in place, but how do we control which path an instruction will take? Single-Cycle Design: Instruction takes exactly one clock cycle Datapath units used only once per cycle Writable state updated at end of cycle What must be “controlled”? Muxes Writeable state elements: RF, Mem ALU

Control Single-Cycle Design: everything happens in one clock cycle until next falling edge of clock, processor just one big combinational circuit!!! control is just a combinational circuit (output, just function of inputs) outputs? control points in datapath inputs? the current instruction! (opcode, funct control everything)

Datapath + Control

Defining Control Most control signals are a function of the opcode (i.e. LW/SW, R-Type, Branch, Jump)

Defining Control Funct field only present in R-type instruction Funct controls ALU only To simplify control, define Main and ALU control separately

ALU Control ALU Control needs to know what instruction type it is: R-Type (op. depends on func. code) LW/SW (op. = ADD) BEQ (op. = SUB) Let main control unit produce ALUOp[1:0] to indicate instruction type, then use function bits if necessary to tell the ALU what to do

ALU Control A L U Note: We don’t use NOR. Ignore MSB in ALUCon. ALUCon Zero Result Note: We don’t use NOR. Ignore MSB in ALUCon. ALUCon ALU function Instruction supported 0000 AND R-format (AND) 0001 OR R-format (OR) 0010 Add R-format (Add), lw, sw 0110 Subtract R-format (Sub), beq 0111 Set on less than R-format (Slt) 1100 NOR R-format (Nor)

ALU Control Truth Table ALUControl[2:0] is a function of ALUOp[1:0] and Func[5:0] Instruc. Instruction Operation Desired ALU Action ALUOp[1:0] Func[5:0] ALUControl LW Load Word Add 00 X 010 SW Store Word Branch BEQ Subtract 01 110 R-Type AND And 10 100100 000 OR Or 100101 001 100000 Sub 100010 SLT Set on less than 101010 111

Simplified ALUControl Truth Table We can simplify using don’t cares Can turn into gates ALUControl2 = ALUOp0 OR (ALUOp1 AND F1) ALUControl1 = ALUOp1 NOR F2 ALUControl0 = ALUOp1 AND (F3 OR F0) ALUOp Funct Field ALUCont. ALUOp1 ALUOp0 F5 F4 F3 F2 F1 F0 X 010 1 110 000 001 111

Fully Minimized ALU Control p A L U O p A L U O p 1 O p e r a t i o n 2 F 3 ALUcon 4th bit=0 F 2 O p e r a t i o n 1 funct F 1 O p e r a t i o n F

Datapath + Control

Main Control Signals Main control signals are function of opcode Could generate each control signal by writing full truth table of the 6-bit opcode Simpler for humans to design if we decode the opcode and then use instruction signals to generate desired control signals

Main Control Signal Logic

Main Control Signal Truth Table

Review – R-type Instructions

Review – Lw Instruction

Review – Branch Instructions

Jump Instruction JAL (Jump and Link) for function calls How do we add JAL to datapath? 1. Place PC+4 (return address) into $ra 2. Extend RegDst mux to include 31 ($ra) 3. Extend MemtoReg mux at write data input to have PC+4 as input

Jump Instruction Implementation What changes are needed to support JAL?

Acknowledgements Slide sources from: UCR CS161 USC EE457 Walid Najjar Laxmi Bhuyan USC EE457 Mark Redekopp Gandhi Puvvada