CPU Performance Pipelined CPU

CPU Performance Pipelined CPU Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See P&H Chapters 1.4 and 4.5 “In a major m...
Author: Shawn Clark
29 downloads 0 Views 3MB Size
CPU Performance Pipelined CPU Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See P&H Chapters 1.4 and 4.5

“In a major matter, no details are small” French Proverb

2

Big Picture:  Building a Processor

memory

+4

inst

register file +4

=?

PC control

offset

new  pc

alu

cmp

addr din

dout

memory

target imm

extend

A Single cycle processor 3

MIPS instruction formats All MIPS instructions are 32 bits long, has 3 formats R‐type

op 6 bits

I‐type

op 6 bits

J‐type 

rs

rt

5 bits 5 bits

rs

rt

rd shamt func 5 bits

5 bits

6 bits

immediate

5 bits 5 bits

16 bits

op

immediate (target address)

6 bits

26 bits 4

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

5

Goals for today Review • Remaining Branch Instructions

Performance • CPI (Cycles Per Instruction)  • MIPS (Instructions Per Cycle) • Clock Frequency

Pipelining • Latency vs throuput

6

Memory Layout and A Simple CPU: remaining branch instructions

7

Memory Layout Examples (big/little endian): # r5 contains 5 (0x00000005) sb r5, 2(r0) lb r6, 2(r0)

sw r5, 8(r0) lb r7, 8(r0) lb r8, 11(r0)

0x00000000 0x00000001 0x00000002 0x00000003 0x00000004 0x00000005 0x00000006 0x00000007 0x00000008 0x00000009 0x0000000a 0x0000000b ... 0xffffffff

8

Endianness Endianness: Ordering of bytes within a memory word Little Endian = least significant part first (MIPS, x86) 1000 1001 1002 1003 as 4 bytes as 2 halfwords as 1 word

0x12345678

Big Endian = most significant part first (MIPS, networks) 1000 1001 1002 1003 as 4 bytes as 2 halfwords as 1 word

0x12345678 9

Control Flow: Jump Register 00000000011000000000000000001000 op

rs

6 bits op 0x0



5 bits 5 bits

func 0x08





func

5 bits

5 bits

6 bits

mnemonic JR rs

R‐Type

description PC = R[rs]

10

Jump Register Prog. inst Mem

ALU

Reg. File

+4

addr

555

PC

Data  Mem

control imm ||

op 0x0

tgt

func 0x08

ext

mnemonic JR rs

description PC = R[rs]

11

Examples (2) jump to 0xabcd1234 # assume 0