There are many parameters that can vary in the design of a cache memory system, but many of them can be derived from other ones. For example, looking at the first two tables below, if you know the number of bytes per word and the number of words per block, you can calculate the number of bits per word, the number of bytes per block, and the number of bits per block.
On symbols: I’ve always thought that obscure symbols were an evil ruse on the part of mathematicians to make simple concepts difficult to understand. So I’ve tried to use mnemonic symbols as best I can here. Everything is uppercase except b (for bits) and B (for bytes), a common convention. I used a lowercase L in PBl because there were no more variants on the latin letter 'B' for distinguishing among bits, bytes, and blocks, and I didn’t want to go the evil mathematician route by introducing a letter from some other alphabet.
Also, I used the term “primary memory” as the basis for the symbols that refer to what is commonly called “main memory” to avoid confusion with the prefix letter M used for Mega.
Bits | Pb | total capacity, in bits |
Bytes | PB | total capacity, in bytes |
Words | PW | total capacity, in words |
Blocks | PBl | total capacity, in bocks |
Pb ÷ PB | bits per byte: always 8 |
PB ÷ PW | bytes per word |
PW ÷ PBl | words per block |
Number of Primary Memory Address bits is A.
A = log2(PB) for byte addressable memory
A = log2(PW) for word addressable memory
Bits | Cb | cache capacity, in bits |
Bytes | CB | cache capacity, in bytes |
Words | CW | cache capacity, in words |
Lines | CL | number of cache lines |
Sets | CS | number of cache sets |
Cb ÷ CB | Same as Pb ÷ PB (8) |
CB ÷ CW | Same as PB ÷ PW |
CW ÷ CL | Same as PW ÷ PBl |
CL ÷ CS | Set Size (n) |
n == 1 | Direct Mapped |
n == CL | Fully Associative |
1 < n < CL | n-way Set Associative |
[ tag | index | block or line offset | byte offset ]
Total number of bits is A, the number of Primary Memory Address bits.
A == tag + index + block or line offset + byte offset
Cache parameters are always powers of two, so log2(whatever) is always an integer. No need to use ceil(log2(whatever)).