Computer Systems Lecture 13 Pipeline Stages CS 230 - Spring 2020 - - PowerPoint PPT Presentation

computer systems
SMART_READER_LITE
LIVE PREVIEW

Computer Systems Lecture 13 Pipeline Stages CS 230 - Spring 2020 - - PowerPoint PPT Presentation

CS 230 Introduction to Computers and Computer Systems Lecture 13 Pipeline Stages CS 230 - Spring 2020 3-1 System Layers Python/C/Racket Code Multiprocessing and Operating Systems Build and Runtime Environments Memory and Caching


slide-1
SLIDE 1

CS 230 - Spring 2020 3-1

CS 230 – Introduction to Computers and Computer Systems Lecture 13 – Pipeline Stages

slide-2
SLIDE 2

System Layers

CS 230 - Spring 2020 0-2

Transistors and Electrical Properties Logic Gates Binary Signals & Number Representation CPU Instructions and Pipelining Memory and Caching Build and Runtime Environments Multiprocessing and Operating Systems Python/C/Racket Code CS 230 Finished! Finished! Here now!

slide-3
SLIDE 3

CS 230 - Spring 2019 3-3

Clock

 Clock cycle: beat of computer  Clock signal  Electrical signals propagate fast

 but not infinitely fast: remember gate delays

 Rising edge called a tick

 like a drummer for a dragon boat, keeps things in sync

time voltage

tick tick tick

slide-4
SLIDE 4

CS 230 - Spring 2019 3-4

CPU Clocking

 Do work, update state, do work, update state…  Split instruction into pipeline stages

 One pipeline stage per clock cycle  MIPS has 5 pipeline stages

Clock (cycles) Data transfer and computation Update state Clock period

slide-5
SLIDE 5

CS 230 - Spring 2019 3-5

MIPS Pipeline Stages

 IF: Instruction fetch

 retrieve the instruction

 ID: Instruction decode

 decode the instruction and load the registers we need

 EX: Execute

 operate the arithmetic logic unit (ALU)

 MEM: Memory access

 access memory

 WB: Write back

 write results back to registers

slide-6
SLIDE 6

CS 230 - Spring 2020 3-6

IF – Instruction Fetch

 Look at address in memory stored in PC  Load the 32-bit value from that address

 this is the next instruction  pass this value on to ID

 Increment PC by 4

slide-7
SLIDE 7

CS 230 - Spring 2020 3-7

ID – Instruction Decode

 Get 32-bit binary instruction from IF  Decode it

 what instruction is it?  what registers does it need?  what immediate values does it need?  if it is a branch:

 is the branch condition met?

if so, update PC accordingly

slide-8
SLIDE 8

MIPS Reference Sheet

CS 230 - Spring 2020 3-8

(also posted along with slides)

slide-9
SLIDE 9

CS 230 - Spring 2020 3-9

Instruction Decode Example

 Look at bits of instruction

00100000110000110000000000010001

slide-10
SLIDE 10

CS 230 - Spring 2020 3-10

Instruction Decode Example

 Look at bits of instruction

 what instruction is it?

00100000110000110000000000010001 addi

slide-11
SLIDE 11

CS 230 - Spring 2020 3-11

Instruction Decode Example

 Look at bits of instruction

 what instruction is it?  what registers does it need?

00100000110000110000000000010001 addi $3, $6

slide-12
SLIDE 12

CS 230 - Spring 2020 3-12

Instruction Decode Example

 Look at bits of instruction

 what instruction is it?  what registers does it need?  what immediate values does it contain?

 two’s complement

except .word when using hexadecimal, which is unsigned binary

00100000110000110000000000010001 addi $3, $6, 17

slide-13
SLIDE 13

Try it Yourself

What MIPS instructions are encoded as the following 32-bit binary numbers?

CS 230 - Spring 2020 3-13

00000000000000000110100000010000 00000000101010000011100000101010 10101100111001000000000000010000

slide-14
SLIDE 14

Try it Yourself

What MIPS instructions are encoded as the following 32-bit binary numbers?

CS 230 - Spring 2020 3-14

00000000000000000110100000010000 mfhi 00000000101010000011100000101010 10101100111001000000000000010000

slide-15
SLIDE 15

Try it Yourself

What MIPS instructions are encoded as the following 32-bit binary numbers?

CS 230 - Spring 2020 3-15

00000000000000000110100000010000 mfhi $13 00000000101010000011100000101010 10101100111001000000000000010000

slide-16
SLIDE 16

Try it Yourself

What MIPS instructions are encoded as the following 32-bit binary numbers?

CS 230 - Spring 2020 3-16

00000000000000000110100000010000 mfhi $13 00000000101010000011100000101010 slt 10101100111001000000000000010000

slide-17
SLIDE 17

Try it Yourself

What MIPS instructions are encoded as the following 32-bit binary numbers?

CS 230 - Spring 2020 3-17

00000000000000000110100000010000 mfhi $13 00000000101010000011100000101010 slt $7 10101100111001000000000000010000

slide-18
SLIDE 18

Try it Yourself

What MIPS instructions are encoded as the following 32-bit binary numbers?

CS 230 - Spring 2020 3-18

00000000000000000110100000010000 mfhi $13 00000000101010000011100000101010 slt $7, $5 10101100111001000000000000010000

slide-19
SLIDE 19

Try it Yourself

What MIPS instructions are encoded as the following 32-bit binary numbers?

CS 230 - Spring 2020 3-19

00000000000000000110100000010000 mfhi $13 00000000101010000011100000101010 slt $7, $5, $8 10101100111001000000000000010000

slide-20
SLIDE 20

Try it Yourself

What MIPS instructions are encoded as the following 32-bit binary numbers?

CS 230 - Spring 2020 3-20

00000000000000000110100000010000 mfhi $13 00000000101010000011100000101010 slt $7, $5, $8 10101100111001000000000000010000 sw

slide-21
SLIDE 21

Try it Yourself

What MIPS instructions are encoded as the following 32-bit binary numbers?

CS 230 - Spring 2020 3-21

00000000000000000110100000010000 mfhi $13 00000000101010000011100000101010 slt $7, $5, $8 10101100111001000000000000010000 sw $4

slide-22
SLIDE 22

Try it Yourself

What MIPS instructions are encoded as the following 32-bit binary numbers?

CS 230 - Spring 2020 3-22

00000000000000000110100000010000 mfhi $13 00000000101010000011100000101010 slt $7, $5, $8 10101100111001000000000000010000 sw $4, ($7)

slide-23
SLIDE 23

Try it Yourself

What MIPS instructions are encoded as the following 32-bit binary numbers?

CS 230 - Spring 2020 3-23

00000000000000000110100000010000 mfhi $13 00000000101010000011100000101010 slt $7, $5, $8 10101100111001000000000000010000 sw $4, 16($7)

slide-24
SLIDE 24

Try it Yourself

What are the binary representations of the following MIPS instructions?

CS 230 - Spring 2020 3-24

add $2, $3, $1 beq $1, $0, 3

slide-25
SLIDE 25

Try it Yourself

What are the binary representations of the following MIPS instructions?

CS 230 - Spring 2020 3-25

add $2, $3, $1 000000 00000100000 beq $1, $0, 3

slide-26
SLIDE 26

Try it Yourself

What are the binary representations of the following MIPS instructions?

CS 230 - Spring 2020 3-26

add $2, $3, $1 000000 0001000000100000 beq $1, $0, 3

slide-27
SLIDE 27

Try it Yourself

What are the binary representations of the following MIPS instructions?

CS 230 - Spring 2020 3-27

add $2, $3, $1 00000000011 0001000000100000 beq $1, $0, 3

slide-28
SLIDE 28

Try it Yourself

What are the binary representations of the following MIPS instructions?

CS 230 - Spring 2020 3-28

add $2, $3, $1 00000000011000010001000000100000 beq $1, $0, 3

slide-29
SLIDE 29

Try it Yourself

What are the binary representations of the following MIPS instructions?

CS 230 - Spring 2020 3-29

add $2, $3, $1 00000000011000010001000000100000 beq $1, $0, 3 000100

slide-30
SLIDE 30

Try it Yourself

What are the binary representations of the following MIPS instructions?

CS 230 - Spring 2020 3-30

add $2, $3, $1 00000000011000010001000000100000 beq $1, $0, 3 00010000001

slide-31
SLIDE 31

Try it Yourself

What are the binary representations of the following MIPS instructions?

CS 230 - Spring 2020 3-31

add $2, $3, $1 00000000011000010001000000100000 beq $1, $0, 3 0001000000100000

slide-32
SLIDE 32

Try it Yourself

What are the binary representations of the following MIPS instructions?

CS 230 - Spring 2020 3-32

add $2, $3, $1 00000000011000010001000000100000 beq $1, $0, 3 00010000001000000000000000000011

slide-33
SLIDE 33

CS 230 - Spring 2020 3-33

EX – Execute

 Get from ID the:

 32-bit input register contents  instruction to do

 for lw and sw this is an addition of the offset

 destination register

 Use the ALU to do the math for the instruction  Pass on to MEM the:

 32-bit result of the math  destination register and instruction

slide-34
SLIDE 34

CS 230 - Spring 2020 3-34

MEM – Memory Access

 Get from EX the:

 32-bit result of the math  destination register and instruction

 If instruction is lw or sw

 load from or store to memory  otherwise do nothing (just pass on values)

 Pass on to WB the:

 32-bit result, or value loaded from memory (for lw)  destination register and instruction

slide-35
SLIDE 35

CS 230 - Spring 2020 3-35

WB – Write Back

 Get from MEM the:

 32-bit result of the math or loaded value  destination register and instruction

 If instruction is not sw

 put result or loaded value into destination register