L33 - CS61C Machine Structures Lecture 33 Caches II John...

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

View Full Document Right Arrow Icon
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 fields. Top bits for tag next bits for color Low bits for 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 0 1 2 3 ...00,00,0 Tag Data (Block size = 2 bytes) 2 ...00,00,1 {tag#, color#, byte#} 1 3 0 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
Image of page 1

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

View Full Document Right Arrow Icon
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 fields 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 fields 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
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern