Cache Schemes: Direct-Mapped Cache
Example of finding the format of a RAM address (the numbers of bits in each of the tag, block, and offset fields:
Suppose that a computer using direct mapped cache has $2^{10}$ bytes of main memory and a cache of $32$ blocks, where each cache block is of the size of $8$ bytes.
Now, let's find the format of a RAM address on this computer:
- Since each block is of the size of $8$ bytes, the offset needs to be of the size of $3$ bits since $2^3 = 8$ bytes can be uniquely represented using $3$ bits.
- Since there are $32$ cache blocks, the block field is of size $5$ bits since $2^5 = 32$ blocks can be uniquely represented by a binary number of $5$ bits.
- Finally, since a RAM address contains $10$ bits (because the RAM size is $2^{10}$ bytes,) to find the tag size, simply subtract $3$ and $5$ from $10$: $10 - 3 - 5 = 2$, so the tag consists of $2$ bits.