Cache Schemes: Direct-Mapped Cache

To find whether a certain variable is located in cache or not, the CPU needs to look into the main memory address of the variable that it is searching for. Then, based on the tag bits in that address (see more below,) the CPU will check inside cache if the variable is present in cache or not.

For this purpose, the main memory address is divided into sections:

  1. The offset number, which represents the depth of a byte inside a block,
  2. The block number, which is the cache block to which the RAM block where the variable is stored is mapped to, and
  3. The tag number, which, combined with the block number, represents the RAM block where the variable is stored.
             RAM Address
+---------+-----------+------------+
|   Tag   |   Block   |   Offset   |
+---------+-----------+------------+