L16- Building a Computer 1 Comp 411 – Spring 2008 3/27/08 Building a Computer I wonder where this goes? Instruction Memory A D 0 1 MIPS Kit ALU AB.

Slides:



Advertisements
Similar presentations
COMP541 Datapath & Single-Cycle MIPS
Advertisements

Now that’s what I call dirty laundry
COMP541 Datapath & Single-Cycle MIPS
The Processor: Datapath & Control
L18 – Pipeline Issues 1 Comp 411 – Spring /03/08 CPU Pipelining Issues Finishing up Chapter 6 This pipe stuff makes my head hurt! What have you.
L17 – Pipeline Issues 1 Comp 411 – Fall /1308 CPU Pipelining Issues Finishing up Chapter 6 This pipe stuff makes my head hurt! What have you been.
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.
ECE 4436ECE 5367 ISA I. ECE 4436ECE 5367 CPU = Seconds= Instructions x Cycles x Seconds Time Program Program Instruction Cycle CPU = Seconds= Instructions.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Computer Organization and Design Instruction Sets Montek Singh Wed, Sep 12, 2012 Lecture 5.
Fall EE 333 Lillevik 333f06-l7 University of Portland School of Engineering Computer Organization Lecture 7 ALU design MIPS data path.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
6.004 – Fall /29/0L15 – Building a Beta 1 Building the Beta.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 5:
1 Computer Sci. & Engr. University of Notre Dame 1 Lectures CSE MIPS Single Cycle Dataflow.
Lec 15Systems Architecture1 Systems Architecture Lecture 15: A Simple Implementation of MIPS Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
L16 – Pipelining 1 Comp 411 – Spring /20/2011 Pipelining Between 411 problems sets, I haven’t had a minute to do laundry Now that’s what I call dirty.
ECE 445 – Computer Organization
COMP541 Datapaths II & Single-Cycle MIPS
Computer Organization and Design Building a Computer!
EEM 486: Computer Architecture Designing a Single Cycle Datapath.
CDA 3101 Fall 2013 Introduction to Computer Organization
Computer Organization & Programming Chapter 6 Single Datapath CPU Architecture.
CS2100 Computer Organisation The Processor: Datapath (AY2015/6) Semester 1.
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
TEAM FRONT END ECEN 4243 Digital Computer Design.
1 A single-cycle MIPS processor  An instruction set architecture is an interface that defines the hardware operations which are available to software.
How Computers Work Lecture 3 Page 1 How Computers Work Lecture 3 A Direct Execution RISC Processor: The Unpipelined BETA.
Computer Organization and Design Pipelining Montek Singh Mon, Dec 2, 2013 Lecture 16.
Computer Organization and Design Pipelining Montek Singh Dec 2, 2015 Lecture 16 (SELF STUDY – not covered on the final exam)
COM181 Computer Hardware Lecture 6: The MIPs CPU.
Computer Organization and Design Instruction Sets - 1
Computer Organization and Design Building a Computer! Montek Singh Nov 18-20, 2015 Lecture 14.
L17 – Pipeline Issues 1 Comp 411 – Fall /23/09 CPU Pipelining Issues Read Chapter This pipe stuff makes my head hurt! What have you been.
MIPS Processor.
Lecture 5. MIPS Processor Design
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Access the Instruction from Memory

CS 230: Computer Organization and Assembly Language
Single-Cycle Datapath and Control
COMP541 Datapaths I Montek Singh Mar 28, 2012.
Introduction CPU performance factors
ELEN 468 Advanced Logic Design
Computer Organization and Design Instruction Sets - 2
Computer Organization and Design Building a Computer!
Processor (I).
Computer Organization and Design Instruction Sets
CSCI206 - Computer Organization & Programming
CSCE 212 Chapter 5 The Processor: Datapath and Control
Building a Computer I wonder where this goes? MIPS Kit ALU 1
Yuanqing Cheng Great Ideas in Computer Architecture Lecture 11: RISC-V Processor Datapath Yuanqing Cheng
Building a Computer I wonder where this goes? MIPS Kit ALU 1
Datapath & Control MIPS
Rocky K. C. Chang 6 November 2017
The Processor Lecture 3.2: Building a Datapath with Control
Lecture 9. MIPS Processor Design – Decoding and Execution
Systems Architecture I
COMS 361 Computer Organization
Basic Building Blocks Multiplexer Demultiplexer Adder +
Computer Organization and Design Building a Computer!
COMP541 Datapaths I Montek Singh Mar 18, 2010.
Building a Computer! Don Porter Lecture 14.
Basic Building Blocks Multiplexer Demultiplexer Adder +
Computer Organization and Design Building a Computer!
The Processor: Datapath & Control.
COMS 361 Computer Organization
Processor: Datapath and Control
Presentation transcript:

L16- Building a Computer 1 Comp 411 – Spring /27/08 Building a Computer I wonder where this goes? Instruction Memory A D 0 1 MIPS Kit ALU AB

L16- Building a Computer 2 Comp 411 – Spring /27/08 THIS IS IT! “Motivating Force” or “Inciting Incident” This is the point in the course where the PLOT actually begins. We are now ready to build a computer. The ingredients are all in place, now it is time to build a legitimate computer. One that executes instructions, much the way any other desktop, PDA, or other computer does.

L16- Building a Computer 3 Comp 411 – Spring /27/08 The MIPS ISA Instruction classes distinguished by types: 1) 3-operand ALU 2) ALU w/immediate 3) Loads/Stores 4) Branches 5) Jumps Instruction classes distinguished by types: 1) 3-operand ALU 2) ALU w/immediate 3) Loads/Stores 4) Branches 5) Jumps The MIPS instruction set as seen from a Hardware Perspective OP rsrs rtrt rdrd funcshamt R-type:ALU with Reguster operands Reg[rd]  Reg[rs] op Reg[rt] 001XXX rsrs rtrt immediate I-type: ALU with constant operand Reg[rt]  Reg[rs] op SEXT(immediate) 10X011 rsrs rtrt immediate I-type: Load and Store Reg[rt]  Mem[Reg[rs] + SEXT(immediate)] Mem[Reg[rs] + SEXT(immediate)]  Reg[rt] 10X011 immediate I-type: Branch Instructions if (Reg[rs] == Reg[rt]) PC  PC *SEXT(immediate) if (Reg[rs] != Reg[rt]) PC  PC *SEXT(immediate) rsrs rtrt 00001X 26-bit constant J-type: jump PC  (PC & 0xf ) | 4*(immediate)

L16- Building a Computer 4 Comp 411 – Spring /27/08 Design Approach Each instruction class can be implemented using a simple component repertoire. We’ll try implementing data paths for each class individually, and merge them (using MUXes, etc). Steps: 1. 3-Operand ALU instructions 2. ALU w/immediate instructions 2. Load & Store Instructions 3. Jump & Branch instructions 4. Exceptions 5. Merge data paths Our Bag of Components: Registers 0 1 Muxes ALU AB ALU & adders Data Memory WD A RD R/W Register File (3-port) RA1RA2 WA WE WD RD1RD2 Instruction Memory A D Memories Incremental Featurism +

L16- Building a Computer 5 Comp 411 – Spring /27/08 A Few ALU Tweaks Let’s review the ALU that we built a few lectures ago. (With a few minor additions) Flags V,C AB R Bidirectional Barrel Shifter Boolean Add/Sub Sub Bool Shft Math 1 0 … N Flag Z Flag Sub Bool Shft Math OP 0 XX 0 1 A+B 1 XX 0 1 A-B X X X X X B >A X B>>>A X A & B X A | B X A ^ B X A | B bit ALUFN

L16- Building a Computer 6 Comp 411 – Spring /27/08 Instruction Fetch/Decode INSTRUCTION WORD FIELDS PC +4 Instruction Memory A D Control Logic CONTROL SIGNALS 00 OP[31:26], FUNC[5:0] use PC as memory address add 4 to PC, load new value at end of cycle fetch instruction from memory º use some instruction fields directly (register numbers, 16-bit constant) º use bits and to generate controls 32 Use a counter to FETCH the next instruction: PROGRAM COUNTER (PC) Can be built with half-adders

L16- Building a Computer 7 Comp 411 – Spring /27/08 3-Operand ALU Data Path Register File RA1RA2 RD1RD2 WA WD WE Rd: PC +4 Instruction Memory A D Rt: ALU AB ALUFN Control Logic WERF ALUFN WERF Rs: rsrs rtrt rdrd 100XXX00000 R-type:ALU with Reguster operands Reg[rd]  Reg[rs] op Reg[rt] WERF!

L16- Building a Computer 8 Comp 411 – Spring /27/08 Shift Instructions Register File RA1RA2 RD1RD2 WA WD WE Rd: PC +4 Instruction Memory A D Rt: ALU AB ALUFN Control Logic WERF ALUFN WERF rsrs rtrt rdrd 000XXXshamt R-type:ALU with Reguster operands sll: Reg[rd]  Reg[rt] (shift) shamt sllv: Reg[rd]  Reg[rt] (shift) Reg[rs] ASEL Rs: ASEL 10 shamt: ASEL!

L16- Building a Computer 9 Comp 411 – Spring /27/08 ALU with Immediate WA PC +4 Instruction Memory A D Rt: Register File RA1RA2 RD1RD2 ALU AB WA WD WE ALUFN Control Logic ALUFN BSEL 01 imm: BSEL WERF 00 BSEL! 001XXX rsrs rtrt immediate I-type: ALU with constant operand Reg[rt]  Reg[rs] op SEXT(immediate) Rd: Rt: SEXT ASEL BSEL Rs: ASEL 10 shamt: … SEXT … …

L16- Building a Computer 10 Comp 411 – Spring /27/08 Load Instruction WA PC +4 Instruction Memory A D Register File RA1RA2 RD1RD2 ALU AB WA WD WE ALUFN Control Logic Imm: Data Memory RD WD R/W Adr Wr WDSEL BSEL WDSEL ALUFN Wr WERF Rd: Rt: BSEL SEXT rsrs rtrt immediate I-type: Load Reg[rt]  Mem[Reg[rs] + SEXT(immediate)] ASEL Rt: Rs: SEXT BSEL 01 SEXT ASEL 10 shamt:

L16- Building a Computer 11 Comp 411 – Spring /27/08 Store Instruction WA PC +4 Instruction Memory A D Register File RA1RA2 RD1RD2 ALU AB WA WD WE ALUFN Control Logic Imm: Data Memory RD WD R/W Adr Wr WDSEL BSEL WDSEL ALUFN Wr WERF Rd: Rt: SEXT ASEL 10X011 rsrs rtrt immediate I-type: Store Mem[Reg[rs] + SEXT(immediate)]  Reg[rt] Rt: BSEL No WERF! Rs: ASEL 10 SEXT BSEL 01 SEXT shamt:

L16- Building a Computer 12 Comp 411 – Spring /27/08 JMP Instructions WA PC +4 Instruction Memory A D Register File RA1RA2 RD1RD2 ALU AB WA WD WE ALUFN Control Logic Data Memory RD WD R/W Adr Wr WDSEL BSEL WDSEL ALUFN Wr J: PCSEL WERF PC+4 Rt: Imm: ASEL SEXT 00001X 26-bit constant J-type: j: PC  (PC & 0xf ) | 4*(immediate) jal: PC  (PC & 0xf ) | 4*(immediate); Reg[31]  PC + 4 PC :J :00 WASEL Rs: ASEL 10 SEXT BSEL 01 SEXT shamt: PCSEL WASEL Rd: Rt: “31” “27”

L16- Building a Computer 13 Comp 411 – Spring /27/08 BEQ/BNE Instructions WA PC +4 Instruction Memory A D Register File RA1RA2 RD1RD2 ALU AB WA WD WE ALUFN Control Logic Data Memory RD WD R/W Adr Wr WDSEL BSEL WDSEL ALUFN Wr J: PCSEL WERF PC+4 Rt: Imm: ASEL SEXT 10X011 immediate rsrs rtrt R-type: Branch Instructions if (Reg[rs] == Reg[rt]) PC  PC *SEXT(immediate) if (Reg[rs] != Reg[rt]) PC  PC *SEXT(immediate) + x4 BT Z Z PC :J :00 Why add, another adder? Couldn’t we reuse the one in the ALU? Nope, it needs to do a subtraction. That “x4” unit is trivial. I’ll just wire the input shifted over 2–bit positions. WASEL Rs: ASEL 10 SEXT BSEL 01 SEXT shamt: PCSEL WASEL Rd: Rt: “31” “27”

L16- Building a Computer 14 Comp 411 – Spring /27/08 Jump Indirect Instructions WA PC +4 Instruction Memory A D Register File RA1RA2 RD1RD2 ALU AB WA WD WE ALUFN Control Logic Data Memory RD WD R/W Adr Wr WDSEL BSEL WDSEL ALUFN Wr J: PCSEL WERF PC+4 Rt: Imm: ASEL SEXT R-type: Jump Indirect, Jump and Link Indirect jr: PC  Reg[rs] jalr: PC  Reg[rs], Reg[rd]  PC x4 BT Z Z WASEL PC :J : rsrs rtrt rdrd 00100X JT Rs: ASEL 10 SEXT BSEL 01 SEXT shamt: PCSEL WASEL Rd: Rt: “31” “27”

L16- Building a Computer 15 Comp 411 – Spring /27/08 Loose Ends WA PC +4 Instruction Memory A D Register File RA1RA2 RD1RD2 ALU AB WA WD WE ALUFN Control Logic Data Memory RD WD R/W Adr Wr WDSEL BSEL WDSEL ALUFN Wr J: PCSEL WERF PC+4 Rt: Imm: ASEL SEXT I-type: set on less than & set on less than unsigned immediate slti: if (Reg[rs] < SEXT(imm)) Reg[rt]  1; else Reg[rt]  0 sltiu: if (Reg[rs] < SEXT(imm)) Reg[rt]  1; else Reg[rt]  0 + x4 BT Z Z WASEL PC :J :00 JT 001XXX immediate rsrs rtrt VN N V Reminder: To evaluate (A < B) we first compute A-B and look at the flags. LT = N  V LTU = C C C Rs: ASEL 10 SEXT BSEL 01 SEXT shamt: PCSEL WASEL Rd: Rt: “31” “27”

L16- Building a Computer 16 Comp 411 – Spring /27/08 More Loose Ends WA PC +4 Instruction Memory A D Register File RA1RA2 RD1RD2 ALU AB WA WD WE ALUFN Control Logic Data Memory RD WD R/W Adr Wr WDSEL BSEL WDSEL ALUFN Wr J: PCSEL WERF PC+4 Rt: Imm: ASEL SEXT R-type: set on less than & set on less than unsigned slt: if (Reg[rs] < Reg[rt]) Reg[rd]  1; else Reg[rd]  0 sltu: if (Reg[rs] < Reg[rt]) Reg[rd]  1; else Reg[rd]  0 + x4 BT Z WASEL PC :J :00 JT rsrs rtrt rdrd 10101X N V C Z VNC Rs: ASEL 10 SEXT BSEL 01 SEXT shamt: PCSEL WASEL Rd: Rt: “31” “27”

L16- Building a Computer 17 Comp 411 – Spring /27/08 LUI Ends WA PC +4 Instruction Memory A D Register File RA1RA2 RD1RD2 ALU AB WA WD WE ALUFN Control Logic Data Memory RD WD R/W Adr Wr WDSEL BSEL WDSEL ALUFN Wr J: PCSEL WERF PC+4 Rt: Imm: ASEL SEXT I-type: Load upper immediate lui: Reg[rt]  Immediate << 16 + x4 BT Z WASEL PC :J :00 JT N V C Z VNC 001XXX immediate rtrt Rs: SEXT BSEL 01 SEXT PCSEL WASEL Rd: Rt: “31” “27” ASEL 20 shamt: “16” 1

L16- Building a Computer 18 Comp 411 – Spring /27/08 Reset, Interrupts, and Exceptions FIRST, we need some way to get our machine into a known initial state. This doesn’t mean that all registers will be initialized, just that we’ll know where to fetch the first instruction. We’ll call this control input, RESET We’d also like RECOVERABLE INTERRUPTS for FAULTS (eg, Illegal Instruction) - CPU or SYSTEM generated[synchronous] TRAPS & system calls (eg, read-a-character) - CPU generated [synchronous] I/O events (eg, key struck) - externally generated [asynchronous] EXCEPTION GOAL: Interrupt running program, invoke exception handler, return to continue execution. These are “Software” notions of synchrony and asynchrony. (Implemented as an “agreed” upon Illegal instruction)

L16- Building a Computer 19 Comp 411 – Spring /27/08 Exceptions WA PC +4 Instruction Memory A D Register File RA1RA2 RD1RD2 ALU AB WA WD WE ALUFN Control Logic Data Memory RD WD R/W Adr Wr WDSEL BSEL WDSEL ALUFN Wr J: PCSEL WERF PC+4 Rt: Imm: ASEL SEXT + x4 BT Z WASEL PC :J :00 JT N V C Z VNC Rs: SEXT BSEL 01 SEXT PCSEL LSEL IRQ 0x x x RESET IRQ: Reg[27]  PC+4; PC  0x Bad Opcode: Reg[27]  PC+4; PC  0x Reset: PC  0x These inputs should probably be registered a few times to avoid metastability problems ASEL 20 shamt: “16” 1 WASEL Rd: Rt: “31” “27”

L16- Building a Computer 20 Comp 411 – Spring /27/08 MIPS: Our Final Version This is a complete 32-bit processor. Although designed in one class lecture, it executes the majority of the MIPS R2000 instruction set. Executes one instruction per clock All that’s left is the control logic design

L16- Building a Computer 21 Comp 411 – Spring /27/08 MIPS Control The control unit can be built as a large ROM Instruction RESETRESET IRQIRQ ZNVC PCSELPCSEL SEXTSEXT WASELWASEL WDSELWDSEL ALUFN Sub Bool Shft Math WRWR WERFWERF ASELASEL BSELBSEL X1XXXXX X01XXXX add00XXXX sll andi lw sw beq