Consider a computer with a 4-ways set-associative mapped cache of the…

2008

Consider a computer with a 4-ways set-associative mapped cache of the following character­istics: a total of 1 MB of main memory, a word size of 1 byte, a block size of 128 words and a cache size of 8 KB. While accessing the memory location 0C795H by the CPU, the contents of the TAG field of the corresponding cache line is

  1. A.

    000011000

  2. B.

    110001111

  3. C.

    00011000

  4. D.

    110010101

Attempted by 174 students.

Show answer & explanation

Correct answer: A

Solution: compute tag bits for address 0C795H.

  • Address size: 1 MB = 2^20 bytes → 20-bit physical addresses.

  • Block offset: block size = 128 words → offset = log2(128) = 7 bits.

  • Index bits: cache size = 8 KB = 8192 bytes. With 4-way associativity and 128-byte blocks, number of sets = 8192 / (128 * 4) = 16 → index = log2(16) = 4 bits.

  • Tag bits: tag = 20 - 7 - 4 = 9 bits.

  • Convert the address 0C795H to 20-bit binary: 0 C 7 9 5 → 0000 1100 0111 1001 0101 → 00001100011110010101.

  • Extract the most significant 9 bits (tag): 000011000.

  • Therefore the TAG field of the corresponding cache line is 000011000.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir