22
1 Memory Systems Memory Systems Caching Caching Lecture 24 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007

Memory Systems Caching

  • Upload
    debbie

  • View
    42

  • Download
    0

Embed Size (px)

DESCRIPTION

Memory Systems Caching. Lecture 24 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007. The Memory Interface. The Ideal Memory System. Memory Hierarchy. Memory Performance. Hit: is found in that level of memory hierarchy - PowerPoint PPT Presentation

Citation preview

Page 1: Memory Systems Caching

1

Memory SystemsMemory SystemsCachingCaching

Lecture 24Digital Design and Computer Architecture

Harris & HarrisMorgan Kaufmann / Elsevier, 2007

Page 2: Memory Systems Caching

2

The Memory InterfaceThe Memory Interface

Processor MemoryAddress

MemWrite

WriteData

ReadDataWE

CLK

Page 3: Memory Systems Caching

3

The Ideal Memory SystemThe Ideal Memory System

Page 4: Memory Systems Caching

4

Memory HierarchyMemory Hierarchy

Cache

Main Memory

Virtual Memory

Size

Speed

Technology cost / GB Access time

SRAM ~ $10,000 ~ 1 ns

DRAM ~ $100 ~ 100 ns

Hard Disk ~ $1 ~ 10,000,000 ns

Page 5: Memory Systems Caching

5

Memory PerformanceMemory Performance

• Hit: is found in that level of memory hierarchy

• Miss: is not found (must go to the next level of memory hierarchy)

Page 6: Memory Systems Caching

6

CachesCaches

A safe place to hide things

• What data is stored?• How is the data found?• What data is replaced?

Page 7: Memory Systems Caching

7

What data is stored?What data is stored?

Page 8: Memory Systems Caching

8

How is data found?How is data found?

Page 9: Memory Systems Caching

9

Direct-Mapped CacheDirect-Mapped Cache

7 (111)

00...00010000

230 Word Main Memory

mem[0x00...00]

mem[0x00...04]

mem[0x00...08]

mem[0x00...0C]

mem[0x00...10]

mem[0x00...14]

mem[0x00...18]

mem[0x00..1C]

mem[0x00..20]

mem[0x00...24]

mem[0xFF...E0]

mem[0xFF...E4]

mem[0xFF...E8]

mem[0xFF...EC]

mem[0xFF...F0]

mem[0xFF...F4]

mem[0xFF...F8]

mem[0xFF...FC]

23 Word Cache

Set Number

Address

00...00000000

00...00000100

00...00001000

00...00001100

00...00010100

00...00011000

00...00011100

00...00100000

00...00100100

11...11110000

11...11100000

11...11100100

11...11101000

11...11101100

11...11110100

11...11111000

11...11111100

6 (110)

5 (101)

4 (100)

3 (011)

2 (010)

1 (001)

0 (000)

Page 10: Memory Systems Caching

10

Direct-Mapped Cache HardwareDirect-Mapped Cache Hardware

DataTag

00Tag Set

ByteOffsetMemory

Address

DataHit

V

=

27 3

27 32

8-entry x(1+27+32)-bit

SRAM

Page 11: Memory Systems Caching

11

Direct-Mapped Cache PerformanceDirect-Mapped Cache Performance

# MIPS assembly code

addi $t0, $0, 5

loop: beq $t0, $0, done

lw $t1, 0x4($0)

lw $t2, 0xC($0)

lw $t3, 0x8($0)

addi $t0, $t0, -1

j loop

done:

DataTagV

Page 12: Memory Systems Caching

12

Direct-Mapped Cache PerformanceDirect-Mapped Cache Performance

# MIPS assembly code

addi $t0, $0, 5

loop: beq $t0, $0, done

lw $t1, 0x4($0)

lw $t2, 0x24($0)

addi $t0, $t0, -1

j loop

done:

DataTagV

Page 13: Memory Systems Caching

13

N-Way Set Associative CacheN-Way Set Associative Cache

DataTag

Tag SetByte

OffsetMemoryAddress

Data

Hit1

V

=

01

00

32 32

32

DataTagV

=

Hit1Hit0

Hit

28 2

28 28

Way 1 Way 0

Page 14: Memory Systems Caching

14

N-way Set Associative PerformanceN-way Set Associative Performance

# MIPS assembly code

addi $t0, $0, 5

loop: beq $t0, $0, done

lw $t1, 0x4($0)

lw $t2, 0x24($0)

addi $t0, $t0, -1

j loop

done:

DataTagV DataTagV

Way 1 Way 0

Page 15: Memory Systems Caching

15

Fully Associative CacheFully Associative Cache

DataTagV DataTagV DataTagV DataTagV DataTagV DataTagV DataTagV DataTagV

Page 16: Memory Systems Caching

16

Spatial Locality?Spatial Locality?

Page 17: Memory Systems Caching

17

Increasing Cache Line SizeIncreasing Cache Line Size

DataTag

00Tag

ByteOffsetMemory

Address

Data

V

00

01

10

11

BlockOffset

32 32 32 32

32

Hit

=

Set

27

27 2

Page 18: Memory Systems Caching

18

Direct-Mapped Cache PerformanceDirect-Mapped Cache Performance# MIPS assembly code

addi $t0, $0, 5

loop: beq $t0, $0, done

lw $t1, 0x4($0)

lw $t2, 0xC($0)

lw $t3, 0x8($0)

addi $t0, $t0, -1

j loop

done:

DataTag

00Tag

ByteOffsetMemory

Address

Data

V

00011011

BlockOffset

32 32 32 32

32

Hit

=

Set

27

27 2

Page 19: Memory Systems Caching

19

What data is replaced?What data is replaced?

Page 20: Memory Systems Caching

20

LRU ReplacementLRU Replacement# MIPS assembly

lw $t0, 0x04($0)lw $t1, 0x24($0)lw $t2, 0x54($0)

DataTagV DataTagVU

DataTagV DataTagVU

(a)

(b)

Set Number3 (11)

2 (10)

1 (01)

0 (00)

Set Number3 (11)

2 (10)

1 (01)

0 (00)

Page 21: Memory Systems Caching

21

Caching SummaryCaching Summary

• Temporal and spatial locality

• LRU or pseudo-LRU replacement

• Cache Parameters: C = capacity b = block size B = # blocks = C/b S = number of sets N = # blocks in a set (# of ways)

Page 22: Memory Systems Caching

22

Next TimeNext Time

Virtual Memory