I have a direct mapped cache of size S with the line size L. The cache is physically indexed and tagged. The physical address is 50 bits, numbered from 0 to 49 (with 0 being the least significant bit). The machine has a word size of 4 bits and the memory is byte-addressable. Which bits of the 50 bits are compared with the address tag?
In a direct-mapped cache, each location in memory has exactly one place in which it can be stored in the cache. So, assuming S is given in bytes, this means that the lower log2S bits of the address are used to locate the data in the cache. The rest of the address bits become the tag.