World's most popular travel blog for travel bloggers.

# Know when we have a cache default and if it loads

, ,
Problem Detail:

I have an exercise about cache memory, first the cache is empty :
I have a cache memory with 16 lines and each lines have 16 octet, the address is 16 bits

So I know that the INDEX will be composed of 4 bits and the offset will be composed of 4 bits too So i will have this :

bits number : (15 ... TAG... 8)(7.. INDEX.. 4) (3 .... OFFSET .... 0 )

Now if have to say if there is cache default or NOT and say if it will Loads or Not. Adress that I have :

3000 : tag = 30 / index = 0 , offset 0

2040 : tag = 20 / index = 4 , offset = 0

3001 : tag = 30 / index = 0 , offset = 1

2404 : tag =24 / index = 0 , offset = 4

3002 : tag = 30 / index = 0, offset = 2

20C4 tag = 20 / index = 12 , offset =4

3003 tag = 30 / index= 0 , offset =3

24C4 tag = 24 / index = 12 , offset = 4

If someone can explains me how I know if it loads and if I have a cache default, I would be very happy. Thanks

###### Answered By : TEMLIB
• Starting with an empty cache.
• Assuming direct map

Tag memory will contain for the 16 indexes the addresses [15:8] and a "valid" bit

``3000 : Miss -> Load 30 into tag 0 and fill line (3000..300F) 2040 : Miss -> Load 20 into tag 4 and fill line (2040..204F) 3001 : Hit : Already in the cache 2404 : Miss -> Load 24 into tag 0 and fill line (replaces 3000..300F -> 2400..240F) 3002 : Miss -> Load 30 into tag 0 and fill line (replaces 2400..240F -> 3000..300F) 20C4 : Miss -> Load 20 into tag C and fill line (20C0..20CF) 3003 : Hit : Already in the cache 24C4 : Miss -> Load 24 into tag C and fill line (24C0..24CF) ``

Very few hits here, would greatly benefit from a two ways set-associative cache.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/51772

3200 people like this

#### Post a Comment

Let us know your responses and feedback