L33 - CS61C L33 Caches II Wawrzynek, Fall 2007 © UCB...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS61C L33 Caches II Wawrzynek, Fall 2007 © UCB 11/14/2007 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS61C – Machine Structures Lecture 33 - Caches II 1 CS61C L33 Caches II Wawrzynek, Fall 2007 © UCB Direct-Mapped Cache Review • Split memory address into felds. • Top bits ¡or tag • next bits ¡or color • Low bits ¡or byte number in block Memory Address: 01 03 05 07 09 0B 0D 0F 13 15 17 19 1B 1D 1F 8 Byte Direct Mapped Cache w/Tag! Cache Index 1 2 3 ...00,00,0 Tag Data (Block size = 2 bytes) 2 ...00,00,1 {tag#, color#, byte#} 1 3 1 ...00,01,0 ...00,01,1 ...00,10,0 ...00,10,1 ...00,11,0 ...00,11,1 ...01,00,0 ...01,00,1 ...01,01,0 ...01,01,1 ...01,10,0 ...01,10,1 ...01,11,0 ...01,11,1 ...10,00,0 ...10,00,1 ...10,01,0 ...10,01,1 ...10,10,0 ...10,10,1 ...10,11,0 ...10,11,1 ...11,00,0 ...11,00,1 ...11,01,0 ...11,01,1 ...11,10,0 ...11,10,1 ...11,11,0 ...11,11,1 00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E 11 CS61C L33 Caches II Wawrzynek, Fall 2007 © UCB Direct-Mapped Cache • Since multiple memory addresses map to same cache index, how do we tell which one is in there? • What if we have a block size > 1 byte? • Answer: divide memory address into three ¡elds ttttttttttttttttt iiiiiiiiii oooo tag index byte to check to offset if have select within correct block block block WIDTH HEIGHT Tag Index Offset 3 CS61C L33 Caches II Wawrzynek, Fall 2007 © UCB Direct-Mapped Cache Example (1/3) • Suppose we have a direct-mapped cache that holds 16KB of data with 4 word blocks • Determine the size of the tag, index and offset ¡elds if we ’ re using a 32-bit architecture • Offset •need to specify correct byte within a block •block contains 4 words = 16 bytes = 2 4 bytes •need 4 bits to specify correct byte 4 CS61C L33 Caches II Wawrzynek, Fall 2007 © UCB Direct-Mapped Cache Example (2/3) • Index: (cache is an “array of blocks”) •Index is used to specify correct block in cache - how many choices are there? •cache contains 16 KB = 2 14 bytes •block contains 2 4 bytes (4 words) •# blocks/cache = bytes/cache / bytes/block = 2 14 bytes/cache / 2 4 bytes/block = 2 10 blocks/cache •need 10 bits to specify this many blocks 5 CS61C L33 Caches II Wawrzynek, Fall 2007 © UCB Direct-Mapped Cache Example (3/3) • Tag: use remaining bits as tag •tag length = addr length – offset - index = 32 - 4 - 10 bits = 18 bits •so tag is leftmost 18 bits of memory address • Final result •Direct-mapped cache that holds 16KB of data with 4 word blocks (1024 blocks): 6 tag offset index 18 bits 10 bits 4 bits CS61C...
View Full Document

This note was uploaded on 04/09/2008 for the course CS 61A taught by Professor Harvey during the Spring '08 term at Berkeley.

Page1 / 17

L33 - CS61C L33 Caches II Wawrzynek, Fall 2007 © UCB...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online