1. Suppose we have a byte-addressable computer using direct mapping with a 16-bit main memory addresses and 32 blocks of cache, If each block contains 8 bytes, determine the size of the offset field. (direct-16-32-8-offset field)
Words or bytes can be divided into 2s+w addressable units.The block size is 2w words or bytes (cache line width excluding the tag).
How does direct mapping determine block size?
2s+w words or bytes are the total number of addressable units.Block size is equal to 2w words or bytes (cache line width excluding tags). There are 2 blocks in main memory (i.e., all the bits that are not in w).
Fully associative mapping allows every line of the cache that is now open for use to map to a block of main memory.Compared to direct mapping, fully associative mapping is more adaptable because of this.
The tag is made up of the top 27 address bits.Since the words in the block are located at successive addresses, the complete block only requires a single tag. 16 kB, or 16 * 1024, or 16384 bytes, are available for use.
Word has 4 bytes, so 16384 bytes divided by 4 bytes each word is 4096 words.Blocks are 4 words in length, hence there are 1024 (210) blocks in every 4096 words.This indicates that the index uses 10 bits.