Lookup a 4 byte integer at address 0x08048088. Assume the machine is little endian.
hex > 0x08048088 binary > 0000 1000 0000 0100 1000 0000 1000 1000 T:S:B > 0000 1000 0000 0100 10:00 0000 100:0 1000 T > 00 0010 0000 0001 0010 = 0x02012 S > 0 0000 0100 = 0x004 = 4 B > 0 1000 = 0x08
So look in set S = 4 and compare the tag in the (only) line of set 4 with 0x02012.
-
Suppose the first 16 bytes of the data block of the line in set 4 of the cache is
Tag: 0x2012 Block data: 01 02 00 00 FF FF FF FF EF BE AD DE 01 02 03 04 So address 0x08048090 is a cache hit
Since B = 8, the integer data starts at byte offset 8 in the block data.
Integers are 4 bytes and the bytes are stored in reverse order on little endian machines.
So the integer value is 0xDEADBEEF
-
If the cache line had been:
Tag: 0x2080 Block data: 01 02 00 00 FF FF FF FF EF BE AD DE 01 02 03 04 The tag would not match and address 0x08048090 would be a cache miss.