Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See P&H Chapter: 2.16-2.20, 4.1-4.4, Appendix B.

Slides:



Advertisements
Similar presentations
Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University See P&H Appendix B.7. B.8, B.10, B.11.
Advertisements

CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
Chapter 2 Instructions: Language of the Computer
Chapter 2.
331 W08.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 8: Datapath Design [Adapted from Dave Patterson’s UCB CS152.
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University A Processor See: P&H Chapter ,
CS 3410, Spring 2014 Computer Science Cornell University See P&H Chapter: , 1.4, Appendix A.
CS61C L25 CPU Design : Designing a Single-Cycle CPU (1) Garcia, Fall 2006 © UCB T-Mobile’s Wi-Fi / Cell phone  T-mobile just announced a new phone that.
The Processor 2 Andreas Klappenecker CPSC321 Computer Architecture.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 25 CPU design (of a single-cycle CPU) Intel is prototyping circuits that.
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See P&H Chapter: , 1.6, Appendix B.
Hakim Weatherspoon CS 3410, Spring 2010 Computer Science Cornell University A Processor See: P&H Chapter ,
Processor Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See P&H Chapter ,
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See: P&H Chapter 2.4, 3.2, B.2, B.5, B.6.
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See P&H Appendix B.8 (register files) and B.9.
CS3350B Computer Architecture Winter 2015 Lecture 5.6: Single-Cycle CPU: Datapath Control (Part 1) Marc Moreno Maza [Adapted.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See P&H Chapter: , 1.6, Appendix B.
Memory Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University.
Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University CPU Performance Pipelined CPU See P&H Chapters 1.4 and 4.5.
Module : Algorithmic state machines. Machine language Machine language is built up from discrete statements or instructions. On the processing architecture,
MIPS Pipeline Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See P&H Chapter 4.6.
Computer Organization CS224 Fall 2012 Lesson 22. The Big Picture  The Five Classic Components of a Computer  Chapter 4 Topic: Processor Design Control.
EEM 486: Computer Architecture Designing a Single Cycle Datapath.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /08/2013 Lecture 10: MIPS Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE.
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]
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.
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University MIPS Pipeline See P&H Chapter 4.6.
MIPS Instructions Instructions: Language of the Machine
Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University MIPS Pipeline See P&H Chapter 4.6.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 7, 8 Instruction Set Architecture.
MIPS Instruction Set Architecture Prof. Sirer CS 316 Cornell University.
Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University A Processor See: P&H Chapter ,
COM181 Computer Hardware Lecture 6: The MIPs CPU.
Processor Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See P&H Chapter ,
CPU Performance Pipelined CPU Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See P&H Chapters 1.4 and 4.5.
CS 61C: Great Ideas in Computer Architecture MIPS Datapath 1 Instructors: Nicholas Weaver & Vladimir Stojanovic
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Electrical and Computer Engineering University of Cyprus
CS 230: Computer Organization and Assembly Language
COMPUTER ARCHITECTURE & OPERATIONS I
IT 251 Computer Organization and Architecture
ELEN 468 Advanced Logic Design
Prof. Sirer CS 316 Cornell University
The University of Adelaide, School of Computer Science
Instructions - Type and Format
Han Wang CS3410, Spring 2012 Computer Science Cornell University
CSCI206 - Computer Organization & Programming
Computer Architecture & Operations I
The University of Adelaide, School of Computer Science
ECE232: Hardware Organization and Design
Hakim Weatherspoon CS 3410 Computer Science Cornell University
Rocky K. C. Chang 6 November 2017
The Processor Lecture 3.1: Introduction & Logic Design Conventions
Guest Lecturer TA: Shreyas Chand
COMS 361 Computer Organization
Computer Architecture
Prof. Sirer CS 316 Cornell University
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
MIPS Instruction Set Architecture
Hakim Weatherspoon CS 3410 Computer Science Cornell University
The RISC-V Processor Hakim Weatherspoon CS 3410 Computer Science
MIPS Pipeline Hakim Weatherspoon CS 3410, Spring 2013 Computer Science
The RISC-V Processor Hakim Weatherspoon CS 3410 Computer Science
CS 3410, Spring 2014 Computer Science Cornell University
Processor: Datapath and Control
Presentation transcript:

Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See P&H Chapter: , , Appendix B

Project Partner finding assignment on CMS Office hours over break

Make sure to go to your Lab Section this week Lab2 due in class this week (it is not homework) Lab1: Completed Lab1 due this Friday, Feb 13 th, before winter break Note, a Design Document is due when you submit Lab1 final circuit Work alone Save your work! Save often. Verify file is non-zero. Periodically save to Dropbox, . Beware of MacOSX 10.5 (leopard) and 10.6 (snow-leopard) Homework1 is out Due a week before prelim1, Monday, February 23rd Work on problems incrementally, as we cover them in lecture (i.e. part 1) Office Hours for help Work alone Work alone, BUT use your resources Lab Section, Piazza.com, Office Hours Class notes, book, Sections, CSUGLab

Check online syllabus/schedule Slides and Reading for lectures Office Hours Pictures of all TAs Homework and Programming Assignments Dates to keep in Mind Prelims: Tue Mar 3rd and Thur April 30th Lab 1: Due this Friday, Feb 13th before Winter break Proj2: Due Thur Mar 26th before Spring break Final Project: Due when final would be (not known until Feb 14th) Schedule is subject to change

“Black Board” Collaboration Policy Can discuss approach together on a “black board” Leave and write up solution independently Do not copy solutions Late Policy Each person has a total of four “slip days” Max of two slip days for any individual assignment Slip days deducted first for any late assignment, cannot selectively apply slip days For projects, slip days are deducted from all partners 25% deducted per day late after slip days are exhausted Regrade policy Submit written request to lead TA, and lead TA will pick a different grader Submit another written request, lead TA will regrade directly Submit yet another written request for professor to regrade.

PC imm memory target offset cmp control =? new pc memory d in d out addr register file inst extend +4 A Single cycle processor alu

Understanding the basics of a processor We now have enough building blocks to build machines that can perform non-trivial computational tasks Putting it all together: Arithmetic Logic Unit (ALU)—Lab0 & 1, Lecture 2 & 3 Register File—Lecture 4 and 5 Memory—Lecture 5 –SRAM: cache –DRAM: main memory Instruction-types Instruction Datapaths

PC imm memory target offset cmp control =? new pc memory d in d out addr register file inst extend +4 A Single cycle processor alu

MIPS register file 32 registers, 32-bits each (with r0 wired to zero) Write port indexed via R W –Writes occur on falling edge but only if WE is high Read ports indexed via R A, R B Dual-Read-Port Single-Write-Port 32 x 32 Register File QAQA QBQB DWDW RWRW RARA RBRB WE

MIPS register file 32 registers, 32-bits each (with r0 wired to zero) Write port indexed via R W –Writes occur on falling edge but only if WE is high Read ports indexed via R A, R B A B W RWRW RARA RBRB WE r1 r2 … r31

Registers Numbered from 0 to 31. Each register can be referred by number or name. $0, $1, $2, $3 … $31 Or, by convention, each register has a name. –$16 - $23  $s0 - $s7 –$8 - $15  $t0 - $t7 –$0 is always $zero. –Patterson and Hennessy p105.

PC imm memory target offset cmp control =? new pc memory d in d out addr register file inst extend +4 A Single cycle processor alu

MIPS Memory 32-bit address 32-bit data (but byte addressed) Enable + 2 bit memory control (mc) 00: read word (4 byte aligned) 01: write byte 10: write halfword (2 byte aligned) 11: write word (4 byte aligned) memory 32 addr 2 mc 32 E D in D out 0x x x x x x x x x x x a 0x b... 0xffffffff 0x05

PC imm memory target offset cmp control =? new pc memory d in d out addr register file inst extend +4 A Single cycle processor alu

Need a program Stored program computer Architectures von Neumann architecture Harvard (modified) architecture

Need a program Stored program computer (a Universal Turing Machine) Architectures von Neumann architecture Harvard (modified) architecture

Let’s build a MIPS CPU …but using (modified) Harvard architecture CPU Registers Data Memory data, address, control ALU Control Program Memory

A processor executes instructions Processor has some internal state in storage elements (registers) A memory holds instructions and data (modified) Harvard architecture: separate insts and data von Neumann architecture: combined inst and data A bus connects the two We now have enough building blocks to build machines that can perform non-trivial computational tasks

How to program and execute instructions on a MIPS processor?

Programs written in a High Level Language C, Java, Python, Ruby, … Loops, control flow, variables for (i = 0; i < 10; i++) printf(“go cucs”); main:addi r2, r0, 10 addi r1, r0, 0 loop:slt r3, r1, r Need translation to a lower- level computer understandable format Assembly is human readable machine language Processors operate on Machine Language ALU, Control, Register File, … Machine Implementation op=addi r0 r2 10 op=reg r1 r2 r3 func=slt

High Level Language C, Java, Python, Ruby, … Loops, control flow, variables for (i = 0; i < 10; i++) printf(“go cucs”); main:addi r2, r0, 10 addi r1, r0, 0 loop:slt r3, r1, r Assembly Language No symbols (except labels) One operation per statement Machine Langauge Binary-encoded assembly Labels become addresses ALU, Control, Register File, … Machine Implementation op=addi r0 r2 10 op=reg r1 r2 r3 func=slt

Instructions are stored in memory, encoded in binary A basic processor fetches decodes executes one instruction at a time pc adder cur inst decode regs execute addrdata op=addi r0 r2 10

Simplicity favors regularity 32 bit instructions Smaller is faster Small register file Make the common case fast Include support for constants Good design demands good compromises Support for different type of interpretations/classes

Arithmetic add, subtract, shift left, shift right, multiply, divide Memory load value from memory to a register store value to memory from a register Control flow unconditional jumps conditional jumps (branches) jump and link (subroutine call) Many other instructions are possible vector add/sub/mul/div, string operations manipulate coprocessor I/O

The types of operations permissible in machine language define the ISA MIPS: load/store, arithmetic, control flow, … VAX: load/store, arithmetic, control flow, strings, … Cray: vector operations, … Two classes of ISAs Reduced Instruction Set Computers (RISC) Complex Instruction Set Computers (CISC) We’ll study the MIPS ISA in this course

Instruction Set Architecture (ISA) Different CPU architecture specifies different set of instructions. Intel x86, IBM PowerPC, Sun Sparc, MIPS, etc. MIPS ≈ 200 instructions, 32 bits each, 3 formats –mostly orthogonal all operands in registers –almost all are 32 bits each, can be used interchangeably ≈ 1 addressing mode: Mem[reg + imm] x86 = Complex Instruction Set Computer (ClSC) > 1000 instructions, 1 to 15 bytes each operands in special registers, general purpose registers, memory, on stack, … –can be 1, 2, 4, 8 bytes, signed or unsigned 10s of addressing modes –e.g. Mem[segment + reg + reg*scale + offset]

Load/store architecture Data must be in registers to be operated on Keeps hardware simple Emphasis on efficient implementation Integer data types: byte: 8 bits half-words: 16 bits words: 32 bits MIPS supports signed and unsigned data types

All MIPS instructions are 32 bits long, has 3 formats R-type I-type J-type oprsrtrdshamtfunc 6 bits5 bits 6 bits oprsrtimmediate 6 bits5 bits 16 bits opimmediate (target address) 6 bits 26 bits

Simplicity favors regularity 32 bit instructions Smaller is faster Small register file Make the common case fast Include support for constants Good design demands good compromises Support for different type of interpretations/classes

A MIPS processor and ISA (instruction set architecture) is an example a Reduced Instruction Set Computers (RISC) where simplicity is key, thus enabling us to build it!!

How are instructions executed? What is the general datapath to execute an instruction?

Instructions are stored in memory, encoded in binary A basic processor fetches decodes executes one instruction at a time pc adder cur inst decode regs execute addrdata op=addi r0 r2 10

5 ALU 55 control Reg. File PC Prog. Mem inst +4 Data Mem Fetch DecodeExecute MemoryWB A Single cycle processor

Basic CPU execution loop 1.Instruction Fetch 2.Instruction Decode 3.Execution (ALU) 4.Memory Access 5.Register Writeback Instruction types/format Arithmetic/Register:addu $s0, $s2, $s3 Arithmetic/Immediate:slti $s0, $s2, 4 Memory:lw $s0, 20($s3) Control/Jump:j 0xdeadbeef

Stage 1: Instruction Fetch Fetch 32-bit instruction from memory. (Instruction cache or memory) Increment PC accordingly. –+4, byte addressing –+N PC Prog. Mem +4 inst

5 ALU 55 control Reg. File PC Prog. Mem inst +4 Data Mem Fetch DecodeExecute MemoryWB A Single cycle processor

Stage 2: Instruction Decode Gather data from the instruction Read opcode to determine instruction type and field length Read in data from register file –E.g. for addu, read two registers. –E.g. for addi, read one registers. –E.g. for jal, read no registers. 555 control Reg. File

All MIPS instructions are 32 bits long, has 3 formats R-type I-type J-type oprsrtrdshamtfunc 6 bits5 bits 6 bits oprsrtimmediate 6 bits5 bits 16 bits opimmediate (target address) 6 bits 26 bits

5 ALU 55 control Reg. File PC Prog. Mem inst +4 Data Mem Fetch DecodeExecute MemoryWB A Single cycle processor

Stage 3: Execution (ALU) Useful work is done here (+, -, *, /), shift, logic operation, comparison (slt). Load/Store? –lw $t2, 32($t3) –Compute the address of the memory. ALU

5 55 control Reg. File PC Prog. Mem inst +4 Data Mem Fetch DecodeExecute MemoryWB A Single cycle processor

Stage 4: Memory access Used by load and store instructions only. Other instructions will skip this stage. Data Mem If sw Data to store from reg to mem R/W If lw Data from memory Target addr from ALU

5 ALU 55 control Reg. File PC Prog. Mem inst +4 Data Mem Fetch DecodeExecute MemoryWB A Single cycle processor

Stage 5: For instructions that need to write value to register. Examples: arithmetic, logic, shift, etc, load. Store, branches, jump?? Reg. File PC WriteBack from ALU or Memory New instruction address If branch or jump

5 ALU 55 control Reg. File PC Prog. Mem inst +4 Data Mem Fetch DecodeExecute MemoryWB

5 ALU 55 control Reg. File PC Prog. Mem inst +4 Data Mem Fetch DecodeExecute MemoryWB

The datapath for a MIPS processor has five stages: 1.Instruction Fetch 2.Instruction Decode 3.Execution (ALU) 4.Memory Access 5.Register Writeback This five stage datapath is used to execute all MIPS instructions

Specific datapaths MIPS Instructions

Arithmetic/Logical R-type: result and two source registers, shift amount I-type: 16-bit immediate with sign/zero extension Memory Access load/store between registers and memory word, half-word and byte operations Control flow conditional branches: pc-relative addresses jumps: fixed offsets, register absolute

All MIPS instructions are 32 bits long, has 3 formats R-type I-type J-type oprsrtrdshamtfunc 6 bits5 bits 6 bits oprsrtimmediate 6 bits5 bits 16 bits opimmediate (target address) 6 bits 26 bits

oprsrtrd-func 6 bits5 bits 6 bits opfuncmnemonicdescription 0x00x21ADDU rd, rs, rtR[rd] = R[rs] + R[rt] 0x00x23SUBU rd, rs, rtR[rd] = R[rs] – R[rt] 0x00x25OR rd, rs, rtR[rd] = R[rs] | R[rt] 0x00x26XOR rd, rs, rt R[rd] = R[rs]  R[rt] 0x00x27NOR rd, rs rtR[rd] = ~ ( R[rs] | R[rt] ) R-Type ex: r4 = r8  r6 # XOR r4, r8, r6

5 ALU 55 Reg. File PC Prog. Mem inst +4 control Fetch DecodeExecute MemoryWB skip r8 r6 xor r4 xor ex: r4 = r8  r6 # XOR r4, r8, r6

Instruction fetch + decode + ALU = Babbage’s engine+ speed+ reliability– hand crank

op-rtrdshamtfunc 6 bits5 bits 6 bits opfuncmnemonicdescription 0x0 SLL rd, rt, shamtR[rd] = R[rt] << shamt 0x00x2SRL rd, rt, shamtR[rd] = R[rt] >>> shamt (zero ext.) 0x00x3SRA rd, rt, shamtR[rd] = R[rt] >> shamt (sign ext.) ex: r8 = r4 * 64 # SLL r8, r4, 6 r8 = r4 << 6 R-Type

5 ALU 55 Reg. File PC Prog. Mem inst +4 shamt control r4 shamt = 6 r8 sll ex: r8 = r4 * 64 # SLL r8, r4, 6 r8 = r4 << 6 Fetch DecodeExecute MemoryWB skip

opmnemonicdescription 0x9ADDIU rd, rs, immR[rd] = R[rs] + imm 0xcANDI rd, rs, immR[rd] = R[rs] & imm 0xdORI rd, rs, immR[rd] = R[rs] | imm oprsrdimmediate 6 bits5 bits 16 bits I-Type ex: r5 += -1ex: r5 += opmnemonicdescription 0x9ADDIU rd, rs, immR[rd] = R[rs] + sign_extend(imm) 0xcANDI rd, rs, immR[rd] = R[rs] & zero_extend(imm) 0xdORI rd, rs, immR[rd] = R[rs] | zero_extend(imm) ex: r5 = r5 + 5# ADDIU r5, r5, 5 r5 += 5 What if immediate is negative?

5 imm 55 extend +4 shamt Reg. File PC Prog. Mem ALU inst control r5 addiu 5 ex: r5 = r5 + 5# ADDIU r5, r5, 5 r5 += 5 Fetch DecodeExecute MemoryWB skip

5 imm 55 extend +4 shamt Reg. File PC Prog. Mem ALU inst control r5 addiu 5 ex: r5 = r5 + 5# ADDIU r5, r5, 5 r5 += 5 Fetch DecodeExecute MemoryWB skip

opmnemonicdescription 0xFLUI rd, immR[rd] = imm << 16 op-rdimmediate 6 bits5 bits 16 bits I-Type ex: LUI r5, 0xdead ORI r5, r5 0xbeef ex: r5 = 0x50000# LUI r5, 5 What does r5 = ? r5 = 0xdeadbeef

5 imm 55 extend +4 shamt Reg. File PC Prog. Mem ALU inst 16 control r5 liu 5 ex: r5 = 0x50000# LUI r5, 5 Fetch DecodeExecute MemoryWB skip

Arithmetic/Logical R-type: result and two source registers, shift amount I-type: 16-bit immediate with sign/zero extension Memory Access load/store between registers and memory word, half-word and byte operations Control flow conditional branches: pc-relative addresses jumps: fixed offsets, register absolute Next Time

We have all that it takes to build a processor! Arithmetic Logic Unit (ALU)—Lab0 & 1, Lecture 2 & 3 Register File—Lecture 4 and 5 Memory—Lecture 5 –SRAM: cache –DRAM: main memory A MIPS processor and ISA (instruction set architecture) is an example a Reduced Instruction Set Computers (RISC) where simplicity is key, thus enabling us to build it!! We know the data path for the MIPS ISA register and memory instructions