edited by
25,741 views
38 votes
38 votes
A $4$-way set-associative cache memory unit with a capacity of $16$ KB is built using a block size of $8$ words. The word length is $32$ bits. The size of the physical address space is $4$ GB. The number of bits for the TAG field is ____
edited by

5 Answers

Best answer
53 votes
53 votes
Number of sets$=\dfrac{\text{cache size}}{\text{sizeof a set}}$

Size of a set $=\text{blocksize}\times  \text{no. of blocks in a set}$
$= 8 \text{ words}\times 4\text{ (4-way set-associative)}$
$= 8\times 4\times 4\text{ (since a word is 32 bits = 4 bytes)}$
$= 128\text{ bytes}.$

So, number of sets $=\dfrac{16\ KB}{(128\ B)}=128$

Now, we can divide the physical address space equally between these $128$ sets.
So, the number of bytes each set can access
$=\dfrac{4\ GB}{128}$

$={32\ MB}$

$=\dfrac{32}{4}=8\text{ M words}=1 \text{ M blocks. ($2^{20}$ blocks)}$

So, we need $20$ tag bits to identify these $2^{20}$ blocks.
edited by
36 votes
36 votes

 Irrespective of byte or word addressable system number of bits required for TAG won't get affected

Let us fist assume that system is byte addressable

So to proceed ahead convert everything in byte addressable format

Block size= 32byte

Number of blocks in main memory= 16KB/32B= 512 blocks

Number of sets = 512/4= 128 sets

Format is TAG |SET | BLOCK

Set= 7 bit,

block = 5 bit,

tag = 32-5-7=20 bits

 

Now let us consider word addressable system

Convert everything with respect to word

Cache size is 4K words, physical address space is 1G words

Number of blocks in cache= 4K/8=512 blocks

Number of sets = 128 sets

Format = Tag| set | word

Set = 7 bit

Word = 3 bit

Tag =30-7-3= 20 bits

 

Conclusion irrespective of byte or word addressable system number of bits required for TAG won't be affected provided we define everything as per byte addressable or word addressable system

edited by
4 votes
4 votes

We try to convert in one format either byte addressable or word addressable.both case we will get same tag bits .

 

1 votes
1 votes
> Total address length = bits required to represent no of words in Physical Address Space =  Log (Physical address size / Word size)

= Log(4 GB / 32 bits) = 30

> Block size = 8 words = 8 * 32 bits = 32 Bytes

> Bits required for set field = log (cache size / (block size * associativity)) = log(16 KB / (32 Bytes * 4)) = 7

> Bits required for word field = log (no of words in each block) = log 8 = 3

> So bits required for Tag field = 30 - 7 - 3 = 20 bits.
Answer:

Related questions

19 votes
19 votes
3 answers
3