Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer with steps/explainations for me to follow: Problem 1: Suppose we h

ID: 3838443 • Letter: P

Question

Please answer with steps/explainations for me to follow:

Problem 1:

Suppose we have a 4 KB direct-mapped data cache with 4-byte blocks.

a) Show how a 32-bit memory address is divided into tag, index and offset. Show clearly how many bits are in each field.

b) How many total bits are there in this cache? (10 points)

c) Consider this address trace:

0x48014554

0x48014548

0x48014754

0x48034760

0x48014554

0x48014560

0x48014760

0x48014554

For this cache, for each address in the above trace, show the tag, index and offset in binary (or hex). Indicate whether each reference is a hit or a miss. What is the miss rate?

Explanation / Answer

A

Given Cache size is 4KB

Block size/line size = 4Bytes

Offset is nothing but, number of bits required to identify a Byte in a block.

Here offset is 2 bits

Cache can be divided into block or lines. And each line size is equals to block size.

No of lines in cache are 4KB/4B = 2^10

Index is nothing but number of bits required to identify a line/block in cache.

Here we have 2^10 lines in cache, to identify them we need 10bits

And Tag = Main memory size/Cache size

                =2^32/2^12

                =2^20

Tag bits are 20 bits

Tag

20

Index

10

Offset

2

B

Number of bits in cache is (2^index bits) * (valid bits + tag bits + (data bits * 2^offset bits))

= (2^10) * (1 + 20 + (32 * 2^2))

= 152576 bits

C

Address                               Tag bits               Index               Offset Hit/Miss

0x48014554 – 00000010110111001010    0100110110          10             Miss

0x48014548 – 00000010110111001010   0100110101            00            Miss

0x48014754 – 00000010110111001010   0101101000          10              Miss

0x48034760 – 00000010110111001111   0011110010            00           Miss

0x48014554 – 00000010110111001010   0100110110          10              Hit

0x48014560 – 00000010110111001010   0100111000          00             Miss

0x48014760 – 00000010110111001010   0101101010            00            Miss

0x48014554 – 00000010110111001010   0100110110             10     Hit

To find miss or hit,

Assume that cache is empty, now you adding each address in the cache if it is not found, if it found you declare that it is a hit.

0x48014554 not found in the cache, because cache is empty so it is miss. So we add it into cache

0x48014548, 0x48014754, 0x48034760 also not found in the cache, so we just add into cache.

0x48014554 is found in cache, we added the same address in cache previously. It is a hit

0x48014560, 0x48014760 not found, so Miss

0x48014554 found, Hit

Miss rate = no of addresses not found/total number of address

                    = 6/8

                      =75%

Tag

20

Index

10

Offset

2