$$ Physical Address Bits=log2(Main Memory Size in Bytes)\text{Physical Address Bits} = \log_2(\text{Main Memory Size in Bytes}) $$
Main Memory Blocks:
$$ Number of Blocks in Main Memory=Main Memory Size Block Size\text{Number of Blocks in Main Memory} = \frac{\text{Main Memory Size}}{\text{Block Size}} $$
Cache Memory Blocks:
$$ Number of Blocks in Cache Memory=Cache Memory SizeBlock Size\text{Number of Blocks in Cache Memory} = \frac{\text{Cache Memory Size}}{\text{Block Size}} $$
$$ Block Offset Bits=log2(Block Size in Bytes)\text{Block Offset Bits} = \log_2(\text{Block Size in Bytes}) $$
$$ Cache Block Index Bits=log2(Number of Blocks in Cache)\text{Cache Block Index Bits} = \log_2(\text{Number of Blocks in Cache}) $$
Direct Mapping:
$$ Tag Bits=Physical Address Bits−Cache Block Index Bits−Block Offset Bits\text{Tag Bits} = \text{Physical Address Bits} - \text{Cache Block Index Bits} - \text{Block Offset Bits} $$
Associative Mapping:
$$ Tag Bits=Physical Address Bits−Block Offset Bits\text{Tag Bits} = \text{Physical Address Bits} - \text{Block Offset Bits} $$
Set Associative Mapping:
$$ Tag Bits=Physical Address Bits−Set Offset Bits−Block Offset Bits\text{Tag Bits} = \text{Physical Address Bits} - \text{Set Offset Bits} - \text{Block Offset Bits} $$