1 COMP541 Datapaths II & Control I Montek Singh Mar 22, 2010.

Slides:



Advertisements
Similar presentations
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 13 - A Verilog.
Advertisements

Pipeline Example: cycle 1 lw R10,9(R1) sub R11,R2, R3 and R12,R4, R5 or R13,R6, R7.
COMP541 Datapath & Single-Cycle MIPS
The Processor: Datapath & Control
331 W9.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 9 Building a Single-Cycle Datapath [Adapted from Dave Patterson’s.
331 Lec 14.1Fall 2002 Review: Abstract Implementation View  Split memory (Harvard) model - single cycle operation  Simplified to contain only the instructions:
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.
Copyright 1998 Morgan Kaufmann Publishers, Inc. All rights reserved. Digital Architectures1 Machine instructions execution steps (1) FETCH = Read the instruction.
The Datapath Andreas Klappenecker CPSC321 Computer Architecture.
©UCB CS 161Computer Architecture Chapter 5 Instructor: L.N. Bhuyan LECTURE 10.
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.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
1 COMP541 Multicycle MIPS Montek Singh Apr 4, 2012.
COMP541 Multicycle MIPS Montek Singh Apr 8, 2015.
COMP541 Datapaths II & Single-Cycle MIPS
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
1 A single-cycle MIPS processor  An instruction set architecture is an interface that defines the hardware operations which are available to software.
Chapter 7 Digital Design and Computer Architecture, 2 nd Edition Chapter 7 David Money Harris and Sarah L. Harris.
Another Example: MIPS From the Harris/Weste book Based on the MIPS-like processor from the Hennessy/Patterson book.
MIPS processor continued. In Class Exercise Question Show the datapath of a processor that supports only R-type and jr reg instructions.
COMP541 Multicycle MIPS Montek Singh Mar 25, 2010.
A Simplified MIPS Processor in Verilog
CSE331 W10.1Irwin&Li Fall 2006 PSU CSE 331 Computer Organization and Design Fall 2006 Week 10 Section 1: Mary Jane Irwin (
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Single-Cycle Datapath and Control.
A Simplified MIPS Processor in Verilog. Data Memory module DM(MemRead, MemWrite, ABUS, DIN, DATABUS); – MemWrite: Nothing happens if 0. If 1, the memory.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 Part 2.
MIPS processor continued
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.
1 Chapter 5: Datapath and Control (Part 2) CS 447 Jason Bakos.
MIPS Processor.
Lecture 9. MIPS Processor Design – Single-Cycle Processor Design Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
Lecture 5. MIPS Processor Design
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Single-cycle CPU Control
Access the Instruction from Memory
EE204 Computer Architecture
MIPS Microarchitecture Single-Cycle Processor Control
Single Cycle CPU - Control
Microarchitecture.
CS161 – Design and Architecture of Computer Systems
CS 230: Computer Organization and Assembly Language
Single-Cycle Datapath and Control
Computer Architecture
Single Cycle Processor
Multi-Cycle CPU.
MIPS processor continued
A Simplified MIPS Processor in Verilog
CS/COE0447 Computer Organization & Assembly Language
Single-Cycle CPU DataPath.
CS/COE0447 Computer Organization & Assembly Language
CSCI206 - Computer Organization & Programming
Datapath & Control MIPS
Rocky K. C. Chang 6 November 2017
Composing the Elements
Composing the Elements
The Processor Lecture 3.2: Building a Datapath with Control
Lecture 9. MIPS Processor Design – Decoding and Execution
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
COMP541 Datapaths I Montek Singh Mar 18, 2010.
MIPS processor continued
CS/COE0447 Computer Organization & Assembly Language
Control Unit (single cycle implementation)
The Processor: Datapath & Control.
COMS 361 Computer Organization
Processor: Datapath and Control
CS/COE0447 Computer Organization & Assembly Language
Presentation transcript:

1 COMP541 Datapaths II & Control I Montek Singh Mar 22, 2010

Topics  Single cycle MIPS Reading: Chapter 7 Reading: Chapter 7 Verilog code for MIPS at the end (!) Verilog code for MIPS at the end (!) If you don’t feel comfortable with assembly language, pls review Ch. 6 2

First, Top Level of CPU module top(input clk, reset, output [31:0] writedata, dataadr, output [31:0] writedata, dataadr, output memwrite); output memwrite); wire [31:0] pc, instr, readdata; wire [31:0] pc, instr, readdata; // instantiate processor and memories // instantiate processor and memories mips mips(clk, reset, pc, instr, memwrite, dataadr, mips mips(clk, reset, pc, instr, memwrite, dataadr, writedata, readdata); writedata, readdata); imem imem(pc[7:2], instr); imem imem(pc[7:2], instr); dmem dmem(clk, memwrite, dataadr, writedata, dmem dmem(clk, memwrite, dataadr, writedata, readdata); readdata);endmodule 3

Top Level Schematic (ISE) 4 MIPS imem dmem

Top Level of MIPS module mips(input clk, reset, output [31:0] pc, output [31:0] pc, input [31:0] instr, input [31:0] instr, output memwrite, output memwrite, output [31:0] aluout, writedata, output [31:0] aluout, writedata, input [31:0] readdata); input [31:0] readdata); wire memtoreg, branch, wire memtoreg, branch, pcsrc, zero, pcsrc, zero, alusrc, regdst, regwrite, jump; alusrc, regdst, regwrite, jump; wire [2:0] alucontrol; wire [2:0] alucontrol; controller c(instr[31:26], instr[5:0], zero, controller c(instr[31:26], instr[5:0], zero, memtoreg, memwrite, pcsrc, memtoreg, memwrite, pcsrc, alusrc, regdst, regwrite, jump, alusrc, regdst, regwrite, jump, alucontrol); alucontrol); datapath dp(clk, reset, memtoreg, pcsrc, datapath dp(clk, reset, memtoreg, pcsrc, alusrc, regdst, regwrite, jump, alusrc, regdst, regwrite, jump, alucontrol, alucontrol, zero, pc, instr, zero, pc, instr, aluout, writedata, readdata); aluout, writedata, readdata);endmodule 5

MIPS Schematic 6

Datapath 7

MIPS State Elements 8 We’ll fill out the datapath and control logic for basic single cycle MIPS First the datapath then the control logic

Let’s Design lw  What does it do? 9

Single-Cycle Datapath: lw fetch  First consider executing lw How does lw work? How does lw work?  STEP 1: Fetch instruction

Single-Cycle Datapath: lw register read  STEP 2: Read source operands from register file

Single-Cycle Datapath: lw immediate  STEP 3: Sign-extend the immediate

Single-Cycle Datapath: lw address  STEP 4: Compute the memory address Note Control

Single-Cycle Datapath: lw memory read  STEP 5: Read data from memory and write it back to register file

Single-Cycle Datapath: lw PC increment  STEP 6: Determine the address of the next instruction

Let’s be Clear  Although the slides said “STEP” … … all that stuff executed in one cycle!!! … all that stuff executed in one cycle!!!  Let’s look at sw  and then R-type 16

Single-Cycle Datapath: sw, write back  Write data in rt to memory

Single-Cycle Datapath: R-type instr  Read from rs and rt  Write ALUResult to register file  Write to rd (instead of rt )

Single-Cycle Datapath: beq  Determine whether values in rs and rt are equal  Calculate branch target address: BTA = (sign-extended immediate << 2) + (PC+4) BTA = (sign-extended immediate << 2) + (PC+4)

Complete Single-Cycle Processor (w/control)

Control Unit

Review: ALU F 2:0 Function 000A & B 001A | B 010A + B 011not used 100A & ~B 101A | ~B 110A - B 111SLT

Review: ALU Design F 2:0 Function 000A & B 001A | B 010A + B 011not used 100A & ~B 101A | ~B 110A - B 111SLT

Fields: –op: the operation code or opcode (0 for R-type instructions) –funct: the function together, the opcode and function tell the computer what operation to perform Review: R-Type

Controller (2 modules) module controller(input [5:0] op, funct, input zero, input zero, output memtoreg, memwrite, output memtoreg, memwrite, output pcsrc, alusrc, output pcsrc, alusrc, output regdst, regwrite, output regdst, regwrite, output jump, output jump, output [2:0] alucontrol); output [2:0] alucontrol); wire [1:0] aluop; wire [1:0] aluop; wire branch; wire branch; maindec md(op, memtoreg, memwrite, branch, maindec md(op, memtoreg, memwrite, branch, alusrc, regdst, regwrite, jump, alusrc, regdst, regwrite, jump, aluop); aluop); aludec ad(funct, aluop, alucontrol); aludec ad(funct, aluop, alucontrol); assign pcsrc = branch & zero; assign pcsrc = branch & zero;endmodule 25

Main Decoder module maindec(input [5:0] op, output memtoreg, memwrite, branch, alusrc, output memtoreg, memwrite, branch, alusrc, output regdst, regwrite, jump, output regdst, regwrite, jump, output [1:0] aluop); output [1:0] aluop); reg [8:0] controls; reg [8:0] controls; assign {regwrite, regdst, alusrc, assign {regwrite, regdst, alusrc, branch, memwrite, branch, memwrite, memtoreg, jump, aluop} = controls; memtoreg, jump, aluop} = controls; case(op) case(op) 6'b000000: controls <= 9'b ; //Rtype 6'b000000: controls <= 9'b ; //Rtype 6'b100011: controls <= 9'b ; //LW 6'b100011: controls <= 9'b ; //LW 6'b101011: controls <= 9'b ; //SW 6'b101011: controls <= 9'b ; //SW 6'b000100: controls <= 9'b ; //BEQ 6'b000100: controls <= 9'b ; //BEQ 6'b001000: controls <= 9'b ; //ADDI 6'b001000: controls <= 9'b ; //ADDI 6'b000010: controls <= 9'b ; //J 6'b000010: controls <= 9'b ; //J default: controls <= 9'bxxxxxxxxx; //??? default: controls <= 9'bxxxxxxxxx; //??? endcase endcaseendmodule 26 Why do this?

ALU Decoder module aludec(input [5:0] funct, input [1:0] aluop, input [1:0] aluop, output reg [2:0] alucontrol); output reg [2:0] alucontrol); case(aluop) case(aluop) 2'b00: alucontrol <= 3'b010; // add 2'b00: alucontrol <= 3'b010; // add 2'b01: alucontrol <= 3'b110; // sub 2'b01: alucontrol <= 3'b110; // sub default: case(funct) // RTYPE default: case(funct) // RTYPE 6'b100000: alucontrol <= 3'b010; // ADD 6'b100000: alucontrol <= 3'b010; // ADD 6'b100010: alucontrol <= 3'b110; // SUB 6'b100010: alucontrol <= 3'b110; // SUB 6'b100100: alucontrol <= 3'b000; // AND 6'b100100: alucontrol <= 3'b000; // AND 6'b100101: alucontrol <= 3'b001; // OR 6'b100101: alucontrol <= 3'b001; // OR 6'b101010: alucontrol <= 3'b111; // SLT 6'b101010: alucontrol <= 3'b111; // SLT default: alucontrol <= 3'bxxx; // ??? default: alucontrol <= 3'bxxx; // ??? endcase endcase endmodule 27

Control Unit: ALU Decoder ALUOp 1:0 Meaning 00Add 01Subtract 10Look at Funct 11Not Used ALUOp 1:0 FunctALUControl 2:0 00X010 (Add) X1X110 (Subtract) 1X ( add ) 010 (Add) 1X ( sub ) 110 (Subtract) 1X ( and ) 000 (And) 1X ( or ) 001 (Or) 1X ( slt ) 111 (SLT)

Control Unit: Main Decoder InstructionOp 5:0 RegWriteRegDstAluSrcBranchMemWriteMemtoRegALUOp 1:0 R-type lw sw X101X00 beq X010X01

Single-Cycle Datapath Example: or

Extended Functionality: addi  No change to datapath

Control Unit: addi InstructionOp 5:0 RegWriteRegDstAluSrcBranchMemWriteMemtoRegALUOp 1:0 R-type lw sw X101X00 beq X010X01 addi

Extended Functionality: j

Control Unit: Main Decoder InstructionOp 5:0 RegWriteRegDstAluSrcBranchMemWriteMemtoRegALUOp 1:0 Jump R-type lw sw X101X00 beq X010X01 j XXX0XXX1

Review: Processor Performance Program Execution Time = (# instructions)(cycles/instruction)(seconds/cycle) = # instructions x CPI x TC

Single-Cycle Performance  T C is limited by the critical path (lw)

Single-Cycle Performance Single-cycle critical path: T c = t pcq_PC + t mem + max(t RFread, t sext + t mux ) + t ALU + t mem + t mux + t RFsetup In most implementations, limiting paths are: –memory, ALU, register file. –T c = t pcq_PC + 2t mem + t RFread + t ALU + t RFsetup + t mux

Single-Cycle Performance Example T c = t pcq_PC + 2t mem + t RFread + t mux + t ALU + t RFsetup = [30 + 2(250) ] ps = 925 ps

Single-Cycle Performance Example For a program with 100 billion instructions executing on a single-cycle MIPS processor, Execution Time = # instructions x CPI x T C = (100 × 10 9 )(1)(925 × s) = 92.5 seconds

Any potentials problems?  How do our Block RAMs differ from the RAM illustrated here?  Do we want a Harvard architecture? instruction memory and data memory are separate instruction memory and data memory are separate 40

Next Time  We’ll look at multi-cycle MIPS  Adding functionality to our design 41