GATE / CS ARCHIVE

SIMILAR QUESTIONS / COMPUTER ORGANIZATION & ARCHITECTURE

Partition cache addresses into tag, set and offset

16 questions solved the same way, newest first. Back to Computer Organization & Architecture

How these are solved

Convert capacity and block size into consistent addressable units, compute sets as capacity/(block size x ways), and partition address bits into offset, set index and tag. Variants ask a field width, set count, associativity, inverse memory/cache sizes, or a symbolic formula.

2 marks · MCQ
Report issue

Cache Memory

Question 39, GATE 2025: A byte-addressable system has a direct-mapped cache. Addresses contain 4 tag bits and 12 cache-index bits; each cache block holds one byte. Choose main-memory address capacity and cache data capacity, respectively.
Options: A. 64 KB,4 KB; B. 128 KB,16 KB; C. 64 KB,8 KB; D. 128 KB,6 KB. Use KB=1024 bytes. The original wording says no other information is stored per block.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

A one-byte block needs log2(1)=0 block-offset bits. Therefore each address has tag+index+offset=4+12+0=16 bits. With byte addressing it identifies 216 bytes, or 65536 bytes=64 KB of main memory.

The 12 index bits select one of 212=4096 cache lines. Each line holds one byte of data, so the cache data capacity is 4096 bytes=4 KB. This gives A.

Distinguish data capacity from total physical storage. The tag itself occupies 4 bits per line, so explicitly counting stored tags would add 4096·4 bits=2048 bytes=2 KB, making 6 KB before any other metadata. The offered correct option and standard cache-capacity convention use data bytes only. The original “no other information” wording does not turn the 4 tag bits into addressable data, and no option pairs the 64-KB address space with 6-KB physical storage. Answer: A under the stated data-capacity interpretation.

Original paper, page 30 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 64, GATE 2023: An 8-way set-associative cache has 64 KiB data capacity and 32-bit byte addresses divided into tag, set index, and block offset. Find the tag width.
Tap to enlarge
Answer & solution

Official answer: 19

Step through it (4 steps)

For byte addressing, cache data capacity equals associativity times number of sets times bytes per block. Therefore the number of sets times block size is 65536/8=8192=213. The index and block-offset fields together occupy 13 bits regardless of the particular power-of-two block size. The tag has 32-13=19 bits. As usual, the stated capacity is data capacity, excluding tag and replacement metadata.

Teaching detail. Let block size be 2b bytes and the number of sets be 2s. Eight ways means each set stores eight blocks, so 216=23·2s·2b and s+b=13. These lower address bits choose a set and byte within a block; the remaining bits identify which memory block occupies the selected way. Therefore tag width is independent of the unspecified block size, provided the conventional power-of-two partition is used. Associativity bits do not appear as a separate address field selecting a way.

Original paper, page 68 · Answer key

1 mark · NAT
Report issue

Cache Memory

Question 22, GATE 2021: A system has 2^32 bytes of byte-addressable main memory and a 32 KB direct-mapped cache, with 1 KB=2^10 bytes and 64-byte cache blocks. How many bits are in the address tag?
Tap to enlarge
Answer & solution

Official answer: 17

Step through it (6 steps)

A byte address has 32 bits. The64-byte block uses 6 offset bits; 32KB/64=512 cache lines use 9 index bits. The remaining tag has 32−6−9=17 bits.

A direct-mapped address is partitioned into tag | line index | block offset. The offset selects one of 64 bytes, so it takes log2 64=6 bits. The data capacity contains 32768/64=512 lines, so index needs log2 512=9 bits. Address width is log2(232)=32 bits, leaving 17. Cache size is assumed to mean data capacity, as usual in this exercise, not data plus tag-store overhead.

Original paper, page 21 · Answer key

1 mark · NAT
Report issue

Cache Memory

Question 19, GATE 2021: Byte-addressable set-associative cache: capacity 2KB, block 64 bytes, addresses 32 bits, tag 22 bits, KB=1024 bytes. Find associativity.
Tap to enlarge
Answer & solution

Official answer: 2

A64-byte block needs 6 offset bits. The remaining index width is 32−22−6=4 bits, giving 16 sets. Capacity2048/64=32 cache lines means 32/16=2 lines per set, so two-way associativity.

Address format is [tag | set index | byte offset]. Capacity includes all ways, so number of sets is not total number of lines unless the cache is direct-mapped. Check reconstruction: 16 sets×2 ways×64 bytes=2048 bytes and 22+4+6=32 address bits.

Original paper, page 64 · Answer key

1 mark · MCQ
Report issue

Tag and index bits in a fully associative cache

Cache Memory

Question 1, GATE 2019: A byte-addressed processor has 32-bit addresses and a fully associative 16 kB cache with 16-byte blocks. Find tag bits and index bits, in that order. Choices: A (24,0); B (28,4); C (24,4); D (28,0).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Step through it (6 steps)

Method: partition the address into tag, set index, and block offset.

1. Because memory is byte-addressed, the offset selects one of the 16 bytes in a block. It requires log2(16) = 4 bits.
2. A fully associative cache has only one set containing all cache lines. Any memory block can occupy any line, so the processor address supplies no set index: log2(1) = 0 bits.
3. The remaining address bits identify which memory block is stored: tag bits = 32 − 4 − 0 = 28.
4. The 16 kB capacity determines the number of available lines, not an address index in this organization. Interpreting kB as 1024 bytes gives 1024 lines, all compared associatively.

Result: D, 28 tag bits and 0 index bits. The four low-order bits are an offset, not an index.

Original paper, page 4 · Answer key

2 marks · MCQ
Report issue

Set-associative cache tag width

Cache Memory

Question 34, GATE 2018: Physical addresses span 2^P bytes, words have 2^W bytes, cache capacity is 2^N bytes, blocks hold 2^M words, and associativity is K. Choose tag bits: A P−N−log₂K; B P−N+log₂K; C P−N−M−W−log₂K; D P−N−M−W+log₂K.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Method

A byte address has P bits. First convert block capacity from words to bytes, obtaining 2M+W. Cache blocks total 2N−M−W; grouping K per set divides this by K. Address bits split into tag, set index and byte-within-block offset. Increasing associativity at fixed capacity reduces index bits and therefore increases tag bits, a useful sign check on the log₂K term. The result assumes integral power-of-two field sizes.

Solution

A block contains 2M+W bytes. There are 2N−M−W/K sets, so index bits=N−M−W−log2K, and block-offset bits=M+W. Subtract both from P address bits: tag=P−N+log2K, B, under the conventional power-of-two cache parameters.

Original paper, page 14 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 53, GATE 2017: A byte-addressable main memory contains 2^32 bytes, divided into 32-byte blocks. A direct-mapped cache has 512 lines. How many address bits form the tag field?
Tap to enlarge
Answer & solution

Official answer: 18.0

Our answer: 18

Step through it (6 steps)

1. There are 232 separately addressable bytes, so a memory address needs 32 bits. A 32-byte block needs log₂32=5 low-order offset bits to select a byte within it.

2. A direct-mapped cache with 512=29 lines uses 9 index bits to select the one cache line where a block may reside.

3. The remaining high-order bits distinguish the different memory blocks that map to that same line: tag=32-5-9=18 bits. Equivalently, memory has 227 blocks and each of 29 lines represents 218 possible blocks. Do not use 512 as the cache byte capacity; it is the number of lines.

Original paper, page 21 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 32, GATE 2016: A machine’s physical addresses have 40 bits. Find tag width in a 512 KB, 8-way set-associative cache under the usual byte-addressed binary-capacity convention.
Tap to enlarge
Answer & solution

Official answer: 24.0 : 24.0

Our answer: 24

Step through it (4 steps)

For byte-addressed memory and binary KB, cache capacity 512 KiB=219 bytes with 8 ways gives 216 bytes per way. Index plus block-offset bits total 16 regardless of block size, leaving 40−16=24 tag bits. The usual power-of-two cache and byte-address convention is assumed.

Let a block contain 2b bytes. The number of cache sets is 219/(2³×2b)=216−b. Therefore the address has b offset bits and 16−b index bits; their sum is fixed even though block size is unstated. The remaining high 24 bits distinguish memory blocks mapping to the same set.

Original paper, page 33 · Answer key

1 mark · NAT
Report issue

Cache Memory

Question 9, GATE 2014: A 16 KB cache is 4-way set associative. A block contains 8 words, each 32 bits. Physical address space is 4 GB. Find the number of tag bits.
Tap to enlarge
Answer & solution

Official answer: 20

Step through it (7 steps)

1. Set up the reasoning. Use the textbook binary KB/GB and byte-addressing convention. Convert words to bytes first: one line has 8×4=32 bytes; compute line count, set count, and their base-two logarithms.

2. Derive the result. A block is 8×4=32 bytes, requiring 5 offset bits. The cache has 16384/32=512 lines and 128 sets, requiring 7 index bits. A4GB byte address is 32 bits, leaving 32−7−5=20 tag bits.

3. Check the interpretation. Do not allocate only three offset bits: those identify the eight words but miss the two byte-within-word bits. The tag, set index, and byte offset together must total the 32 physical-address bits.

Original paper, page 31 · Answer key

2 marks · MCQ
Report issue

Tag bits in a four-way cache

Cache Memory

Question 54, GATE 2012: A 256 KByte, four-way set-associative write-back cache uses 32-byte blocks and 32-bit byte addresses. Every tag-directory entry holds the tag plus 2 valid bits, 1 modified bit, and 1 replacement bit.
How many address tag bits are there?
(A) 11 (B) 14 (C) 16 (D) 27.
Question 54, GATE 2012: A 256 KByte, four-way set-associative write-back cache uses 32-byte blocks and 32-bit byte addresses. Every tag-directory entry holds the tag plus 2 valid bits, 1 modified bit, and 1 replacement bit.
How many address tag bits are there?
(A) 11 (B) 14 (C) 16 (D) 27.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (7 steps)

Using binary cache units, 256 KiB/32 bytes=8192 cache lines. Four lines per set give 2048=2¹¹ sets, so the set index uses 11 bits. A 32-byte block requires 5 byte-offset bits. The remaining address bits are tag bits: 32−11−5=16, C.

Check: The address splits as [16 tag bits | 11 set bits | 5 byte-offset bits]. Associativity reduces the number of sets relative to the number of lines, so using 13 line-index bits would incorrectly treat the cache as direct mapped.

Original paper, page 15 · Answer key

1 mark · MCQ
Report issue

Cache tag set and word bits

Cache Memory

Question 10, GATE 2007: A 4-way set-associative cache has 128 lines of 64 words each. Main-memory word addresses are 20 bits. What are the TAG, LINE and WORD field lengths, respectively?
Options:
(A) 9,6,5
(B) 7,7,6
(C) 7,5,8
(D) 9,5,6
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step through it (7 steps)

1. Approach. First divide total lines by associativity to obtain sets. The address chooses a word inside a line, then a set; the remaining high bits form the tag.

2. Derivation and interpretation. There are 128/4=32 sets, needing 5 set-index bits. A 64-word line needs 6 word-offset bits. With 20-bit word addresses the tag uses 20−5−6=9 bits. Thus 9,5,6, option D; the stated LINE field is the set index in this associative organization.

Original paper, page 3

2 marks · MCQ
Report issue

Direct-mapped cache index and tag

Cache Memory

Question 67, GATE 2005: Direct-mapped cache data capacity 32 KB, block 32 bytes, CPU 32-bit byte addresses. Required(index bits, tag bits): A(10, 17); B(10, 22); C(15, 17); D(5, 17). Use binary capacity units.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (6 steps)

The cache contains 32 KiB/32 bytes =1024 lines, so its index needs 10 bits. A block offset needs log2(32)=5 bits. Of the 32 address bits, 32−10−5=17 remain for the tag. Thus (10, 17), option A.

First divide data capacity by block size to obtain 1024 distinct cache positions. Choosing one needs 10 bits. Choosing a byte within 32-byte block needs 5 low-order bits. The tag identifies which memory block is currently occupying that position, using the remaining 32−10−5=17 bits. Check 10+17+5=32. The cache’s total number of bytes is not the number of line indices.

Original paper, page 9

Descriptive
Report issue

Number of cache sets

Cache Memory

Question 9(a), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the number of cache sets.
Question 9(a), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the number of cache sets.
Tap to enlarge
Shared context

32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Answer & solution

Answer: 4096 sets. (no official key was published)

Step through it (7 steps)

1. First count cache blocks: 218 bytes ÷24 bytes/block =214 blocks, or 16,384 blocks.

2. Four-way associativity means four blocks in each set, not four sets. Divide by four to obtain 214/2²=212=4096 sets.

3. Equivalently, one set holds 4×16=64 data bytes, and 262,144/64=4096. This cross-check uses the complete data capacity.

4. Consequently the set index requires 12 bits, a fact used when partitioning the address in later parts.

Original paper, page 8

Descriptive
Report issue

Cache tag width

Cache Memory

Question 9(b), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the tag-field width per block.
Question 9(b), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the tag-field width per block.
Tap to enlarge
Shared context

32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Answer & solution

Answer: 16 tag bits per block. (no official key was published)

Step through it (7 steps)

1. An address separates into tag, set index, and byte offset. The 16-byte block needs log₂16=4 offset bits.

2. There are (256×1024)/(4×16)=4096 sets, so the set index needs log₂4096=12 bits.

3. The remaining bits are tag bits: 32−12−4=16. In bit positions, tag=A31…A16, set=A15…A4, byte offset=A3…A0.

4. Associativity affects the number of sets and hence the tag width. There is no address field selecting a way; the stored tags determine which of the four candidate ways matches.

Original paper, page 8

Descriptive
Report issue

Cache byte offset width

Cache Memory

Question 9(d), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the byte-offset address width.
Question 9(d), GATE 2001: 32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Task: Find the byte-offset address width.
Tap to enlarge
Shared context

32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.

Answer & solution

Answer: 4 bits. (no official key was published)

Step through it (7 steps)

1. A block stores 16 individually addressable bytes. The byte offset must distinguish positions 0 through 15 within that block.

2. An unsigned b-bit field distinguishes 2b positions, so 2b=16 gives b=4.

3. These are the lowest four address bits A3…A0. For example offsets 0000 and 1111 identify the first and last byte.

4. The four-way organization does not change this field: associativity changes where a whole block is placed, not how bytes inside it are selected.

Original paper, page 8

2 marks · MCQ
Report issue

Set and offset bits in a cache

Cache Memory

Question 2.25, GATE 1995: A 4K-word cache is four-way set associative with 64 words per block. Find SET and WORD field widths.
Tap to enlarge
Your answer
Answer & solution

Answer: D: 4 set bits,6 word bits (no official key was published)

Step through it (5 steps)

The cache contains 4096/64=64 blocks. Grouping four blocks per set gives 64/4=16 sets, requiring log₂16=4 set-index bits. A block contains 64 words, requiring log₂64=6 word-offset bits. Associativity changes the number of sets, not the within-block offset. No tag width can be computed without the total main-memory address width, but it is not requested. These counts use word addresses, as specified, rather than adding an unstated byte offset.

Original paper, page 5