Hakim Weatherspoon CS 3410, Spring 2010 Computer Science Cornell University A Processor See: P&H Chapter 2.16-20, 4.1-3.

Slides:



Advertisements
Similar presentations
Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
Advertisements

331 W08.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 8: Datapath Design [Adapted from Dave Patterson’s UCB CS152.
1 RISC Pipeline Han Wang CS3410, Spring 2010 Computer Science Cornell University See: P&H Chapter 4.6.
1 CS3410 Guest Lecture A Simple CPU: remaining branch instructions CPU Performance Pipelined CPU Tudor Marian.
Pipeline Hazards Hakim Weatherspoon CS 3410, Spring 2011 Computer Science Cornell University See P&H Appendix 4.7.
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University A Processor See: P&H Chapter ,
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University RISC & CISC.
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.
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.
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See P&H Chapter: , , Appendix B.
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.
CS3350B Computer Architecture Winter 2015 Lecture 5.6: Single-Cycle CPU: Datapath Control (Part 1) Marc Moreno Maza [Adapted.
IT253: Computer Organization Lecture 5: Assembly Language and an Introduction to MIPS Tonga Institute of Higher Education.
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.
CPU Performance Pipelined CPU Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See P&H Chapters 1.4 and 4.5.
Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University CPU Performance Pipelined CPU See P&H Chapters 1.4 and 4.5.
MIPS Pipeline Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See P&H Chapter 4.6.
ECE 445 – Computer Organization
EEM 486: Computer Architecture Designing a Single Cycle Datapath.
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
Computer Organization Rabie A. Ramadan Lecture 3.
Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University MIPS Pipeline See P&H Chapter 4.6.
EET 4250 Instruction Representation & Formats Acknowledgements: Some slides and lecture notes for this course adapted from Prof. Mary Jane Penn.
MIPS Instructions Instructions: Language of the Machine
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
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.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
CS 230: Computer Organization and Assembly Language
COMPUTER ARCHITECTURE & OPERATIONS I
IT 251 Computer Organization and Architecture
Introduction CPU performance factors
Prof. Sirer CS 316 Cornell University
Instructions - Type and Format
Han Wang CS3410, Spring 2012 Computer Science Cornell University
Single-Cycle CPU DataPath.
CSCI206 - Computer Organization & Programming
The University of Adelaide, School of Computer Science
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
COMS 361 Computer Organization
Computer Instructions
Computer Architecture
Access the Instruction from Memory
Prof. Sirer CS 316 Cornell University
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
MIPS Instruction Set Architecture
Datapath and Control Exceptions
Hakim Weatherspoon CS 3410 Computer Science Cornell University
CS352H Computer Systems Architecture
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
COMS 361 Computer Organization
CS 3410, Spring 2014 Computer Science Cornell University
Presentation transcript:

Hakim Weatherspoon CS 3410, Spring 2010 Computer Science Cornell University A Processor See: P&H Chapter , 4.1-3

2 Announcements HW2 available later today HW2 due in one week and a half Work alone Use your resources FAQ, class notes, book, Sections, office hours, newsgroup, CSUGLab Make sure you Registered for class, can access CMS, have a Section, and have a project partner Check online syllabus/schedule, review slides and lecture notes, Office Hours, early homework and programming assignments

3 Announcements Prelims: Evening of Thursday, March 10 and April 28 th Late Policy 1) Each person has a total of four “slip days” 2) For projects, slip days are deducted from all partners 3) 10% deducted per day late after slip days are exhausted

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

5 Instructions 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

6 Instruction Types 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

7 Complexity 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] = Reduced Instruction Set Computer (RlSC)

8 MIPS Register file 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 clk W 32 A B r1 r2 … r WERWRW RARA RBRB 32

9 MIPS Memory Up to 32-bit address 32-bit data (but byte addressed) Enable + 2 bit memory control 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

10 Instruction Usage Basic CPU execution loop 1.fetch one instruction 2.increment PC 3.decode 4.execute

11 Instruction Fetch Instruction Fetch Circuit Fetch instruction from memory Calculate address of next instruction Repeat Program Memory inst 32 PC

12 Arithmetic Instructions 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

13 Arithmetic and Logic 5 ALU 55 control Reg. File PC Prog. Mem inst +4

14 Example Programs r4 = (r1 + r2) | r3 r8 = 4*r3 + r4 – 1 r9 = 9 ADDU rd, rs, rt SUBU rd, rs, rt OR rd, rs, rt XOR rd, rs, rt NOR rd, rs rt

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

16 Arithmetic Instructions: Shift op-rtrdshamtfunc 6 bits5 bits 6 bits opfuncmnemonicdescription 0x0 SLL rd, rs, shamtR[rd] = R[rt] << shamt 0x00x2SRL rd, rs, shamtR[rd] = R[rt] >>> shamt (zero ext.) 0x00x3SRA rd, rs, shamtR[rd] = R[rs] >> shamt (sign ext.) ex: r5 = r3 * 8 R-Type

17 Shift 5 ALU 55 control Reg. File PC Prog. Mem inst +4 shamt

18 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 Arithmetic Instructions: Immediates 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) oprsrdimmediate 6 bits5 bits 16 bits I-Type ex: r5 += 5 ex: r9 = -1ex: r9 = 65535

19 Immediates 5 imm 55 control extend +4 shamt control Reg. File PC Prog. Mem ALU inst

20 Arithmetic Instructions: Immediates opmnemonicdescription 0xFLUI rd, immR[rd] = imm << 16 op-rdimmediate 6 bits5 bits 16 bits I-Type ex: r5 = 0xdeadbeef

21 Immediates 5 imm 55 control extend +4 shamt control Reg. File PC Prog. Mem ALU inst 16

22 MIPS Instruction Types 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

23 Memory Instructions opmnemonicdescription 0x20LB rd, offset(rs)R[rd] = sign_ext(Mem[offset+R[rs]]) 0x24LBU rd, offset(rs)R[rd] = zero_ext(Mem[offset+R[rs]]) 0x21LH rd, offset(rs)R[rd] = sign_ext(Mem[offset+R[rs]]) 0x25LHU rd, offset(rs)R[rd] = zero_ext(Mem[offset+R[rs]]) 0x23LW rd, offset(rs)R[rd] = Mem[offset+R[rs]] 0x28SB rd, offset(rs)Mem[offset+R[rs]] = R[rd] 0x29SH rd, offset(rs)Mem[offset+R[rs]] = R[rd] 0x2bSW rd, offset(rs)Mem[offset+R[rs]] = R[rd] oprsrdoffset 6 bits5 bits 16 bits base + offset addressing I-Type signed offsets

24 Memory Operations Data Mem addr ext +4 5 imm 55 control Reg. File PC Prog. Mem ALU inst

25 Example int h, A[]; A[12] = h + A[8];

26 Memory Layout Examples: # r5 contains 0x5 sb r5, 2(r0) lb r6, 2(r0) sw r5, 8(r0) lb r7, 8(r0) lb r8, 11(r0) 0x x x x x x x x x x x a 0x b... 0xffffffff

27 Endianness Endianness: Ordering of bytes within a memory word x Big Endian = most significant part first (MIPS, networks) Little Endian = least significant part first (MIPS, x86) as 4 bytes as 2 halfwords as 1 word x as 4 bytes as 2 halfwords as 1 word

28 Control Flow: Absolute Jump Absolute addressing for jumps Jump from 0x to 0x ? NO Reverse? NO –But: Jumps from 0x2FFFFFFF to 0x3xxxxxxx are possible, but not reverse Trade-off: out-of-region jumps vs. 32-bit instruction encoding MIPS Quirk: jump targets computed using already incremented PC opmnemonicdescription 0x2J targetPC = target opimmediate 6 bits26 bits J-Type opmnemonicdescription 0x2J targetPC = target || 00 opmnemonicdescription 0x2J targetPC = (PC+4) || target || 00

29 Absolute Jump tgt +4 || Data Mem addr ext 555 Reg. File PC Prog. Mem ALU inst control imm

30 Control Flow: Jump Register op rs---func 6 bits5 bits 6 bits opfuncmnemonicdescription 0x00x08JR rsPC = R[rs] R-Type

31 Jump Register +4 || tgt Data Mem addr ext 555 Reg. File PC Prog. Mem ALU inst control imm

32 Examples (2) jump to 0xabcd1234

33 Examples (2) jump to 0xabcd1234 # assume 0 <= r3 <= 1 if (r3 == 0) jump to 0xdecafe0 else jump to 0xabcd1234

34 Examples (2) jump to 0xabcd1234 # assume 0 <= r3 <= 1 if (r3 == 0) jump to 0xdecafe0 else jump to 0xabcd1234

35 Control Flow: Branches opmnemonicdescription 0x4BEQ rs, rd, offsetif R[rs] == R[rd] then PC = PC+4 + (offset<<2) 0x5BNE rs, rd, offsetif R[rs] != R[rd] then PC = PC+4 + (offset<<2) oprsrdoffset 6 bits5 bits 16 bits signed offsets I-Type

36 Examples (3) if (i == j) { i = i * 4; } else { j = i - j; }

37 Absolute Jump tgt +4 || Data Mem addr ext 555 Reg. File PC Prog. Mem ALU inst control imm offset + Could have used ALU for branch add =? Could have used ALU for branch cmp

38 Absolute Jump tgt +4 || Data Mem addr ext 555 Reg. File PC Prog. Mem ALU inst control imm offset + Could have used ALU for branch add =? Could have used ALU for branch cmp

39 Control Flow: More Branches oprssubopoffset 6 bits5 bits 16 bits signed offsets almost I-Type opsubopmnemonicdescription 0x10x0BLTZ rs, offsetif R[rs] < 0 then PC = PC+4+ (offset<<2) 0x1 BGEZ rs, offsetif R[rs] ≥ 0 then PC = PC+4+ (offset<<2) 0x60x0BLEZ rs, offsetif R[rs] ≤ 0 then PC = PC+4+ (offset<<2) 0x70x0BGTZ rs, offsetif R[rs] > 0 then PC = PC+4+ (offset<<2)

40 Absolute Jump tgt +4 || Data Mem addr ext 555 Reg. File PC Prog. Mem ALU inst control imm offset + Could have used ALU for branch cmp =? cmp

41 Control Flow: Jump and Link opmnemonicdescription 0x3JAL targetr31 = PC+8 PC = (PC+4) || target || 00 opimmediate 6 bits 26 bits J-Type

42 Absolute Jump tgt +4 || Data Mem addr ext 555 Reg. File PC Prog. Mem ALU inst control imm offset + =? cmp Could have used ALU for link add +4

43 Next Time CPU Performance Pipelined CPU