Length of the TAG field in k-way set associative = Length of TAG field in Direct Mapping + log base2(k)

= 10+log base2(16) =**14**

The Gateway to Computer Science Excellence

+39 votes

A cache memory unit with capacity of $N$ words and block size of $B$ words is to be designed. If it is designed as a direct mapped cache, the length of the TAG field is 10 bits. If the cache unit is now designed as a 16-way set-associative cache, the length of the TAG field is ____________ bits.

0

Length of the TAG field in k-way set associative = Length of TAG field in Direct Mapping + log base2(k)

= 10+log base2(16) =**14**

+3

$Direct-mapped:$

$Tag$ | $Line-offset$ | $Word-offset$ |

$10-bits$ | $(log_{2}N-log_{2}B)-bits$ | $(log_{2}B)-bits$ |

$16-way\ set\ associative\ cache:$

$Tag$ | $Line-offset$ | $Word-offset$ |

$x-bits$ | $(log_{2}N-log_{2}B-4)-bits$ | $(log_{2}B)-bits$ |

$10+(log_{2}N-log_{2}B)+(log_{2}B)=x+(log_{2}N-log_{2}B-4)+(log_{2}B)$

$x=14-bits$

+51 votes

Best answer

+44 votes

Cache capacity =N words

Block size= B words**,bits** for block offset=log(B)

No of lines in **Direct Mapped cache** =N/B,**bits** for no. of lines=log(N/B)

No of Sets in **16-way set associative cache**=N/16B,,**bits** for no. of sets=log(N/16B)

In direct mapped length of tag =10 bits

Length of **PHYSICAL ADDRESSES** :-

TAG-10 | LINE.NO:-LOG(N/B) | BLOCK OFFSET:-LOG(B) |

TAG-X | SET.NO-LOG(N/16B) | BLOCK OFFSET:-LOG(B) |

**As Physical address is same for both cache mappings**,

10+LOG(N/B)+LOG(B)=X+LOG(N/16B)+LOG(B)

10+LOG(N/B)=X+LOG(N/16B) //AFTER CANCELLING LOG(B)

2^(10+LOG(N/B))=2^(X+LOG(N/16B)) //EXPONENTIATION WITH 2 ,BOTH SIDES

(2^10) *(N/B)=(2^X) *(N/16B)

(2^10) =(2^X) *(1/2^4)

2^14=2^X

**X=14 ** //APPLYING LOG TO BOTH SIDES

+43 votes

+11 votes

in Direct mapping length is 10 bits that means at each index of cache 2^10 lines can be mapped

after 16 way set associative....16*(2^10) lines can be mapped in each set so total 2^14 lines hence tag bit must be able to address these many lines so 14 bits required

answer is 14 bits

after 16 way set associative....16*(2^10) lines can be mapped in each set so total 2^14 lines hence tag bit must be able to address these many lines so 14 bits required

answer is 14 bits

+8 votes

Since offset not given so we can neglect it because line offset in (**direct cache**) and set offset in (**set - associative cache**) is same.

In direct cache = Tag(**10)** + line (**x, assume)** + **offset (neglect it)**

In set associative = Tag**(t assume)** + Set**(x - 4)** + **offset (neglect it) , since set = $\frac{Number -of- Lines }{16- way -set- associative}$ = 2 ^{x-4}**

Now , **In direct cache = 16- way set associative**

Tag(**10)** + line (**x, assume) = **Tag**(t assume)** + Set**(x - 4)**

10 + x = Tag + (x - 4)

Tag = 10+4 = 14 bits

–1 vote

One approach will be we can find the number of blocks in main memory with the help of tag bits like given in the following picture

so total number of blocks in main memory is 131072 so we can find number of blocks in the cache as 131072/1024=128 blocks

now when mapping is set associative so total number of sets in cache is 128/16=8 sets so now total number of blocks in main memory is 131072/8=16384 which is 2^14 so 14 bits are needed in tag.

–1 vote

No of TAG bits in Direct Map Cache : (No. of bits Required for Main Memory Address **M**)-(number of bits for index** I**+bits for offset **O**)

No of TAG bits in 16-way set associative : M -(set bits + offset bits)

number of bits for set : index bits - 4 // 16 way set associative

No of TAG bits in 16-way set associative : M -(index bits - 4 + offset bits)

: (M-I-O)+4=10+4=14

- All categories
- General Aptitude 1.9k
- Engineering Mathematics 7.5k
- Digital Logic 2.9k
- Programming and DS 4.9k
- Algorithms 4.4k
- Theory of Computation 6.2k
- Compiler Design 2.1k
- Databases 4.1k
- CO and Architecture 3.4k
- Computer Networks 4.2k
- Non GATE 1.4k
- Others 1.4k
- Admissions 595
- Exam Queries 573
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 18

50,741 questions

57,251 answers

198,044 comments

104,652 users