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

A cache holds 64 words where each word is 4 bytes. Assuming a 32-bit address, gi

ID: 3573023 • Letter: A

Question

A cache holds 64 words where each word is 4 bytes. Assuming a 32-bit address, give

a. A direct-mapped cache with block size = 8 words

b. 2-way set-associative cache with block size = 8 words

c. 4-way set-associative cache with block size = 4 words

d. A fully associative cache with block size = 16 words.

Complete the table for each cache.

Cache A Cache b Cache C Cache d total # bits for word & byte displacement # bits in tag # sets in cache # bits (total) per set (including valid and dirty bits)

Explanation / Answer

a) A direct-mapped cache with block size = 8 words

total # bits for word & byte displacement = 8 bits
---------------------------------------------------------------------
#bits in tag => offset = 32/8 = 4 ==> 2^2 = 4 so offset 2 bits.
Tag bits = 32 - 2 - 8 = 22
------------------------------------------------------------------------
#sets in cache
2^n blocks ==> 2^8 ==> 256 blocks
-----------------------------------------------------------------------
#bits total are = 32 bits

*********************************************************************************
b)2-way set-associative cache with block size = 8 words

total # bits for word & byte displacement are 6 bits
--------------------------------------------------------------------
#bits in tag ==> 2^32 - 2^2 => 2^30 ==> 30 bits
-----------------------------------------------------------------------
#sets in cache
2^n blocks ==> 2^8/2^2 ==> 128 blocks
--------------------------------------------------------------------
#bits total are = 26 bits


*********************************************************************************
c) 4-way set-associative cache with block size = 4 words

total # bits for word & byte displacement are 4 bits
--------------------------------------------------------------------
#bits in tag ==> 2^32 - 2^4 => 2^28 ==> 28 bits
-----------------------------------------------------------------------
#sets in cache
2^n blocks ==> 2^8/2^4 ==> 64 blocks
--------------------------------------------------------------------
#bits total are = 26 bits

**************************************************************************************
c) A fully associative cache with block size = 16 words.

total # bits for word & byte displacement are 16 bits
--------------------------------------------------------------------
#bits in tag ==> 2^32 - 2^16 => 2^16 ==> 16 bits
-----------------------------------------------------------------------
#sets in cache
2^n blocks ==> 2^16 ==> 2^16 blocks
--------------------------------------------------------------------
#bits total are = 26 bits