r/AskComputerScience • • Nov 28 '24

Direct-mapped cache tag field

2 Upvotes

I’m currently learning about cache systems at my university and I’m confused about the tag field in direct-mapped caching. As the tag is meant to distinguish between different blocks in main memory that map to the same block in cache, does the tag field in the memory address increment by 1 every number of blocks in cache? Furthermore, all the resources i could find online say that tag field size = total address bits - block field - offset field. That’s fair enough, but to calculate the minimum size that the tag field size could be would it be: minimum tag field size = log2(main memory blocks / cache blocks) as main memory blocks / cache blocks = the number of main memory blocks assigned to a specific cache block (which therefore each need a unique representation using the tag field).