Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does a direct mapped cache with 16 one-word blocks vary from one with 8 two-word blocks

Tags:

caching

I am looking to determine Binary address, tag, index, and Hit or miss of a cache with 16 one-word blocks and one which uses 8 2-word blocks all assumed empty at the begginning

Say I have the referenced instructions 4, 4, 32, 31, 5, 32

For the first cache (16 one word blocks) you must first convert 4 to binary then that binary value is split to get tag then if you find that index again it will be mark as a hit

That being said, I believe the table below to be correct using this method.

Ref | Binary |  Tag  | Index | Hit or Miss
 4   00000100   0000   0100      miss
 4   00000100   0000   0100      hit
32   00100000   0010   0000      miss
31   00011111   0001   1111      miss
 5   00000101   0000   0101      miss
32   00100000   0010   0000      hit

I wish to do the same for the the second cache(8 two-word blocks) however I am unsure how to continue.

I figure the binary is the same for the numbers however I am confused on how to determine tag and index from it and whether there was a hit or a miss on the same referenced instructions as the first cache.

How would one determine the tag, index, and whether or not it was a hit or miss in this cache?

like image 752
John Avatar asked Oct 30 '25 20:10

John


1 Answers

It varies in that you have half as many cache lines to work with, giving 4 bits of tag, 3 bits of index and 1 bit of displacement within the cache line (indicating which word of a two-word block is addressed). For the example given, the wider fetches will garner one additional hit since accessing 4 fetches 5 as well.

Ref | Binary |  Tag  | Index | Disp |  Hit or Miss
 4   00000100   0000   010     0       miss
 4   00000100   0000   010     0       hit
32   00100000   0010   000     0       miss
31   00011111   0001   111     1       miss
 5   00000101   0000   010     1      *hit
32   00100000   0010   000     0       hit
like image 66
Jeffrey Hantin Avatar answered Nov 03 '25 13:11

Jeffrey Hantin