Direct mapped cache tag index offset
![direct mapped cache tag index offset direct mapped cache tag index offset](https://d2vlcm61l7u1fs.cloudfront.net/media/9aa/9aa216e5-d005-49f5-b1cf-2773d2d02d62/phpi1xeKM.png)
Tag corresponds to the remaining bits.There are 64 sets in the cache, and because 2^6 = 64, there are 6 index bits. Index corresponds to bits used to determine the set of the Cache.Because the cache lines are 4 bytes long, there are 2 offset bits. Offset corresponds to the bits used to determine the byte to be accessed from the cache line.The incoming address to the cache is divided into bits for Offset, Index and Tag. Since each cache block is of size 4 bytes, the total number of sets in the cache is 256/4, which equals 64 sets. Because the main memory is 16kB, we need a minimum of 14 bits to uniquely represent a memory address. Ĭonsider a main memory of 16 kilobytes, which is organized as 4-byte blocks, and a direct-mapped cache of 256 bytes with a block size of 4 bytes. Every time a new memory is referenced to the same set, the cache line is replaced, which causes conflict miss. It has lower cache hit rate, as there is only one cache line available in a set.It requires cheap hardware as only one tag needs to be checked at a time.The placement policy and the replacement policy is simple.This placement policy is power efficient as it avoids the search through all the cache lines.Else there is a cache miss and the memory block is fetched from the lower memory ( main memory, disk). If the tag matches, then there is a cache hit and the cache block is returned to the processor. The tag bits derived from the memory block address are compared with the tag bits associated with the set.The set is identified by the index bits of the address.If the cache line is previously occupied, then the new data replaces the memory block in the cache.The memory block is placed in the set identified and the tag is stored in the tag field associated with the set.The set is determined by the index bits derived from the address of the memory block.The cache can be framed as a (n*1) column matrix. Based on the address of the memory block, it can only occupy a single cache line. In a direct-mapped cache structure, the cache is organized into multiple sets with a single cache line per set.