Question

A 16 GB main memory has a 8 MB cache organized as a 8-way set associative...

A 16 GB main memory has a 8 MB cache organized as a 8-way set associative cache with 128 Byte cache blocks (line). How many cache blocks are there in the cache? How many sets are there in the cache? (Show your computation.)

Show how the 36-bit address generated by the CPU would be divided to map into the cache.

(Indicate the sizes of the tag, line, etc.)

number of blocks can be found with help of cache size and size of each block as shown here :

Number of sets :

Now, total memory is 16GB which is 2^34. so there is a mistake in question,

Each address further gets divided into 3 parts. 1)tag bits 2) set bits 3) offset bits

In Cache, along with each block, tag bits for that block are stored too.

Following steps will be followed :

--> Find modulo :

lets say set bits of given address are : xxxx xxxx xxxx x

find modulo = (xxxx xxxx xxxx x) mod 213

result will give the set number of required block.

--> Compare tag bits of given address with tag bits of each of the 8 blocks stored in that set.

if the block is in cache, one block will have tab gits as same as the given address.

--> After finding block, add offsat bits to starting address of block. which will give required Byte from the block.

If you have any doubts, you can ask in comment section.