in CO and Architecture edited by
8,169 views
24 votes

A CPU has $32-bit$ memory address and a $256 \ KB$ cache memory. The cache is organized as a $4-way$ set associative cache with cache block size of $16$ bytes.

  1. What is the number of sets in the cache?
  2. What is the size (in bits) of the tag field per cache block?
  3. What is the number and size of comparators required for tag matching?
  4. How many address bits are required to find the byte offset within a cache block?
  5. What is the total amount of extra memory (in bytes) required for the tag bits?
in CO and Architecture edited by
8.2k views

2 Comments

For answering part (C) of this question refer diagram of Four‐Way Set Associative Cache on 

http://www.ece.ucsb.edu/~strukov/ece154aFall2012/lecture15.pdf

0
<tag, set, offset> = <16, 12, 4>
1

2 Answers

43 votes
 
Best answer

What is the number of sets in the cache

 $\text{Number of sets}=\dfrac{\text{Cache memory}}{\text{(set associativity $\times$ cache block size)}}$

 $=\dfrac{256KB}{(4\times 16 B)}$

 $=4096$

What is the size (in bits) of the tag field per cache block?

 Memory address size $=32\text{-bit}$

 Number of bits required to identify a particular set  $=12\text{ (Number of sets}= 4096)$

 Number of bits required to identify a paticular location in cache line $=4\text{ (cache block size = 16)}$

 Size of tag field $=32-12-4=16\text{-bit}$

What is the number and size of comparators required for tag matching?

We use $4\text{-way}$ set associate cache. So, we need $4$ comparators each of size $16\text{-bits}$

http://ecee.colorado.edu/~ecen2120/Manual/caches/cache.html

How many address bits are required to find the byte offset within a cache block?

Cache block size is $16\text{-byte.}$ so $4\text{-bits}$ are required to find the byte offset within a cache block.

What is the total amount of extra memory (in bytes) required for the tag bits?

size of tag $=16\text{-bits}$

Number of sets $=4096$

Set associativity $=4$

Extra memory required to store the tag bits $=16\times 4096\times 4\text{-bits}= 2^{18}\text{ bits}=2^{15}\text{ bytes}.$

edited by
by

13 Comments

Extra memory required for tag bits=2^18 bytes
5
I think, the extra memory required to store the tag bits=$2^{18}$ bits. In bytes, it should be $2^{15}$B.

Am i thinking wrong?
4

Extramemory required to store the tag bits = 16 * 4096 * 4 bits = 218 bytes

                  here it is not 218 bytes but it is 218 bits, which implies 215 Bytes or 32 KB. Thus 32 KB extra memory is required....

5
can someone explain how byte offset is determined from the block size??
2

@Anshul Shankar, Byte offset means how many bits will be required to address the no of bytes in a cache Block. As cache block is of 16B and thus only log2(16) i.e. 4 bits will be required.

2
Is that similar to the word offset and just the context with word and byte differs??
0
edited by
why number of sets is also multiplied for calculating the extra memory required.
I got this. Extra memory required= no of tag bits x no of blocks
since no of blocks = no of sets x set associativity.
so extra memory req= no of tag bits x no of sets x set associativity.
0
do you know why set associativity is multiplied I am not getting that there are 4096 set and each set has a tag of 16 bits so 16*4096 so why 4 is multiplied
0
Thanks a load !!!!
0

Every block in a set has a tag field so in our case, every set has 4 blocks. Therefore we are multiplying by 4

see this diagram set-associative

0
Tag memory = (Tag bits per block address +extra bits per block address(optional) )* Number of blocks in cache $= 16*2^{14} $b = $2^{18}$ b

Here extra bits mean like valid/invalid bit or dirty bit etc.
0
extra tag memory means size of tag directory which is equal to number of cache block*number of tag bits.
0

E}    tag memory = tag bit * no.of block in ceche = 2^18 bits=2^15 bytes

0
2 votes

A. To find the number of sets we need to determine the number of rows. To do that we need to determine the number of blocks. We are given that this is a 4-way set associative cache, hence each set has four blocks.

It holds:

#Blocks = Capacity / BlockSize = 218 / 24 = 214. There are 214 blocks.

#Sets = #Blocks / #ways = 214 / 22 = 212. There are 212 sets.

edited by

2 Comments

256 KB, not 256 B :)
2
Thanks for pointing out. I've corrected it.
2

Related questions