Download as pdf
Download as pdf
You are on page 1of 5
ee et ee cen eve eer + Each block holds one byte Beene ae MNEs eee eid eee es Oh) ‘many bits of storage are required to build the cache (e.g. for the da © Data words are 32 bits each * A cache block will contain 2048 bits of data © The cache is direct mappe: * The address supplied from the CPU is 32 bits long © = There are 2048 blocks in the cache e Addresses are to the word = 32 bits Determine the number of tag, index and offset bits. You have been asked to design a cache with the following properties: 2. You have been asked to design a cache with the following properties © Data words are 32 bits each ‘+ Accache block will contsin 2048 bits of deta © The cache is direct mapped © The address supplied from the CPU is 32 bits long ‘+ There are 2048 blocks in the cache © Addresses are to the word Determine the number of tag, index and offset bits. Answer: Cache block = 2048 bit 8 bits 256 bytes Index = 2048 blocks = 1og2048 log: ‘Tag = 32- 11-8= 13 bits 1 bits 3. Consider a direct mapped cache of size 16 KB with block size 256 bytes. The size of main memory is 128 KB. Find ({) Number of bits in tag (ii) Tag directory size Answer @— Offket =Bipek size =256 bytes = 1ogr256 = 8 bits No. of index = cache size/block size = 16x1024/256 = 64 Index = logi64 = 6 bits Main memory size = |28KB = 128x1024 = 131072 bytes = log2131072 = 17 bits Tag= 17-6-8=3 bits (i) Tag directory size ‘Number of tags x Tag size Number of lines ig cache x Number of bis in tag 64 x3 bits 92 bits 4 bytes Thus, size of tag directory = 14 bytes 4. Consider a direct mapped cache of size 512 KB with block size 1 KB. There are 7 bits in the tag. Find:_(j) Size of main memory (ji)Tag directory size Answer: Tadex = cache size/block size Tag =7 bits Main memory size = 7 +9 +10 =26 bite = 2° = 67108864 bytes = 65536 KB = 64MB_ 5. Consider a direct mapped cache with block size 4 KB. The size of main memory is 16 GB and there are 10 bits in the tag. Find: () Size of cache memory (ii) Tag directory size. Answer: @__ Offiet = Block size = 4KB = 4x1024=4096 bytes = log24096 = 12 bits Tag = 10 bits ‘Main memory size = 16GB = 24x2 Index = 34-10-12 = 12 bits Cache size = Index x block size = 2!? x 4K = 16777216 bytes = 16MB Ht = 34 bit Gi) Tag directory size ‘= Number of tags x Tag size jumber of lines in cache x Number of bits in tag, 2 x 10 bits 40960 bits 120 bytes ‘Thus, size of tag directory = 5120 bytes 6. Assuming a direct mapped cache with 16 cache line with each 4 word blocks, label the following references as a hit or a miss and show the contents of the cache after each cycle. Assume that the cache is initially empty. The referenced addresses in decimal are 20,17, 1, 4,8, 5, 56,89,100, 129, 100, 104, 108, 8, 4 Answer: Block size = 4 word = 4xdbytes = 16 bytes = 24 = 4 bits Index = 16 blocks = 2*= 4 bits jplag= [address/16] ‘Address Tag (decimal) Tndex Offset HitMiss reference, 20, 1 (000% 0100 M 17 1 0001 0001 H 1 0 ‘0000 ‘0001 M + oO ‘0000 (0100 H g 0 ‘0000 1000) H 3 oO ‘0000. O10L a 36 3 ‘0011 1000) M 89 5 0101 1001 M 100. 6 0110 (0100 M. 120 7 oun 1000 M 100. 6 110 (0100 H 104 6 110 1000 H 108. 6 o110 1100 i s 0 ‘0000 1000 HT 4 oO ‘0000, 0100 ia 7. Given the following series of address references given as word addresses in hexadecimal: 04, 05C, 07, 092, 0X1E, 0*5F, OBO, 0*5D, 091, 0108 and 0X6, Assuming a direct-mapped cache with a word size of 32 bits and address of 11 bits has a cache with 16 blocks and a block size of 2 words. Indicate whether the reference is a hit (H) or miss (M). Assume the cache is initially empty. Answer: Offset = 2 words =8 bytes = log:8 = 3 bits 1 mark Index= 16 blocks = log:16= 4 bits 1 mark ‘Tag =11-4-3 =4 bits 1 mark ‘Address Tag Index Offset Reference Oa ‘0000 ‘0000 100, M Ox5C (0000 1011 100) M Ox7, (0000 ‘0000. ait H 092 001 ‘0010 010) M Ox1E (0000 ‘0011, 110) M OxSF ‘0000 1011 411 H 0x80 001 ‘0110 000) M 0x50. ‘0000 1011 101, H 0x91 ‘0001 ‘0010. 001 H oxt08 0010 ‘0001. 000) M 0x6. ‘0000 ‘0000 110 M Index v Tag. ‘0000 1 ‘0000 ‘0001 1 ‘010 (0010 1 (0001 ‘0011. 4 ‘0000 ‘0100 ‘0101 0110 1 (001 O11 1000 1001 1010 1011 1 ‘0000

You might also like