Cache and main memory


Question 1
In a k-way set associative cache, the cache is divided into v sets, each of which consists of k lines. The lines of a set are placed in sequence one after another. The lines in set s are sequenced before the lines in set (s+1). The main memory blocks are numbered 0 onwards. The main memory block numbered j must be mapped to any one of the cache lines from.
A
(j mod v) * k to (j mod v) * k + (k-1)
B
(j mod v) to (j mod v) + (k-1)
C
(j mod k) to (j mod k) + (v-1)
D
(j mod k) * v to (j mod k) * v + (v-1)
GATE CS 2013    Computer Organization and Architecture    Cache and main memory    
Discuss it


Question 1 Explanation: 
Number of sets in cache = v. So, main memory block j will be mapped to set (j mod v), which will be any one of the cache lines from (j mod v) * k to (j mod v) * k + (k-1). (Associativity plays no role in mapping- k-way associativity means there are k spaces for a block and hence reduces the chances of replacement.)
Question 2
A RAM chip has a capacity of 1024 words of 8 bits each (1K × 8). The number of 2 × 4 decoders with enable line needed to construct a 16K × 16 RAM from 1K × 8 RAM is
A
4
B
5
C
6
D
7
GATE CS 2013    Computer Organization and Architecture    Cache and main memory    
Discuss it


Question 2 Explanation: 
RAM chip size = 1k ×8[1024 words of 8 bits each]
RAM to construct =16k ×16
Number of chips required = (16k x 16)/ ( 1k x 8)
                         = (16 x 2)
[16 chips vertically with each having 2 chips
horizontally]
So to select one chip out of 16 vertical chips, 
we need 4 x 16 decoder.

Available decoder is  2 x 4 decoder
To be constructed is 4 x 16 decoder

Hence 4 + 1 = 5 decoders are required.
Question 3
A computer has a 256 KByte, 4-way set associative, write back data cache with block size of 32 Bytes. The processor sends 32 bit addresses to the cache controller. Each cache tag directory entry contains, in addition to address tag, 2 valid bits, 1 modified bit and 1 replacement bit. The number of bits in the tag field of an address is
A
11
B
14
C
16
D
27
GATE CS 2012    Computer Organization and Architecture    Cache and main memory    
Discuss it


Question 3 Explanation: 
A set-associative scheme is a hybrid between a fully associative cache, and direct mapped cache. It's considered a reasonable compromise between the complex hardware needed for fully associative caches (which requires parallel searches of all slots), and the simplistic direct-mapped scheme, which may cause collisions of addresses to the same slot (similar to collisions in a hash table). (source: http://www.cs.umd.edu/class/spring2003/cmsc311/Notes/Memory/set.html). Also see http://csillustrated.berkeley.edu/PDFs/handouts/cache-3-associativity-handout.pdf   Number of blocks = Cache-Size/Block-Size = 256 KB / 32 Bytes = 213 Number of Sets = 213 / 4 = 211 Tag + Set offset + Byte offset = 32 Tag + 11 + 5 = 32 Tag = 16
Question 4
Consider the data given in previous question. The size of the cache tag directory is
A
160 Kbits
B
136 bits
C
40 Kbits
D
32 bits
GATE CS 2012    Computer Organization and Architecture    Cache and main memory    
Discuss it


Question 4 Explanation: 
16 bit address 2 bit valid 1 modified 1 replace Total bits = 20 20 × no. of blocks = 160 K bits.
Question 5
An 8KB direct-mapped write-back cache is organized as multiple blocks, each of size 32-bytes. The processor generates 32-bit addresses. The cache controller maintains the tag information for each cache block comprising of the following. 1 Valid bit 1 Modified bit As many bits as the minimum needed to identify the memory block mapped in the cache. What is the total size of memory needed at the cache controller to store meta-data (tags) for the cache?
A
4864 bits
B
6144 bits
C
6656 bits
D
5376 bits
GATE CS 2011    Computer Organization and Architecture    Cache and main memory    
Discuss it


Question 5 Explanation: 
   Cache size = 8 KB
   Block size = 32 bytes
   Number of cache lines = Cache size / Block size = (8 × 1024 bytes)/32 = 256

   gate2011A41

   total bits required to store meta-data of 1 line = 1 + 1 + 19 = 21 bits
   total memory required = 21 × 256 = 5376 bits
Question 6
A main memory unit with a capacity of 4 megabytes is built using 1M × 1-bit DRAM chips. Each DRAM chip has 1K rows of cells with 1K cells in each row. The time taken for a single refresh operation is 100 nanoseconds. The time required to perform one refresh operation on all the cells in the memory unit is
A
100 nanoseconds
B
100×210 nanoseconds
C
100×220 nanoseconds
D
3200×220 nanoseconds
GATE CS 2010    Computer Organization and Architecture    Cache and main memory    
Discuss it


Question 6 Explanation: 
Number of chips required for 4MB MM = (4 * 2^20 * 8) / (1 * 2^20) = 32 chips In a refresh cycle, a whole row of a memory chip is refreshed at once. This implies the given time of 100 ns for one refresh operation refreshes one row of memory chip. Since there are 1K=2^10 such rows, time for refreshing a whole chip would be: 2^10 * 100 ns. Second question arises, how to arrange these chips as there can be many possible arrangements. There is a logical arrangement provided in the problem statement itself as "1M x 1 bit chip". This indicates that to make a "1M x 32 bits" MM, we need to arrange all 32 chips in a line. It is to be noted that a row in all chips in series can be refreshed in one refresh cycle. This makes the total time to refresh the 4MBytes of memory as same as that of one chip. Hence, time required to refresh MM = 100 * 2^10 ns. So, option (B) is correct.
Question 7
A computer system has an L1 cache, an L2 cache, and a main memory unit connected as shown below. The block size in L1 cache is 4 words. The block size in L2 cache is 16 words. The memory access times are 2 nanoseconds. 20 nanoseconds and 200 nanoseconds for L1 cache, L2 cache and main memory unit respectively. CSE_201048 When there is a miss in L1 cache and a hit in L2 cache, a block is transferred from L2 cache to L1 cache. What is the time taken for this transfer?
A
2 nanoseconds
B
20 nanoseconds
C
22 nanoseconds
D
88 nanoseconds
GATE CS 2010    Computer Organization and Architecture    Cache and main memory    
Discuss it


Question 7 Explanation: 
A block to access in L2 cache requires 20 nanoseconds, and 2 seconds to place in L1-cache. The block size in L1 cache is 4 words, so total time is =time to access L2 + time to place in L1 = 20+2 = 22 ns.
Question 8
Consider the data from above question. When there is a miss in both L1 cache and L2 cache, first a block is transferred from main memory to L2 cache, and then a block is transferred from L2 cache to L1 cache. What is the total time taken for these transfers?
A
222 nanoseconds
B
888 nanoseconds
C
902 nanoseconds
D
968 nanoseconds
GATE CS 2010    Computer Organization and Architecture    Cache and main memory    
Discuss it


Question 8 Explanation: 
Since the block size of L2 cache is 16 words and the bandwidth of mainmem->L2 cache is 4 words, it requires a transfer of 4 words 4 times and then a transfer of required 4 words from L2 cache to L1 cache. So total time is 4*(200 + 20) + 1*(20 + 2) = 902 nanoseconds. Option (C) is correct.
Question 9
How many 32K x 1 RAM chips are needed to provide a memory capacity of 256K-bytes?
A
8
B
32
C
64
D
128
GATE-CS-2009    Computer Organization and Architecture    Cache and main memory    
Discuss it


Question 9 Explanation: 
We need 256 Kbytes, i.e., 256 x 1024 x 8 bits. We have RAM chips of capacity 32 Kbits = 32 x 1024 bits. (256 * 1024 * 8)/(32 * 1024) = 64
Question 10
Consider a 4-way set associative cache (initially empty) with total 16 cache blocks. The main memory consists of 256 blocks and the request for memory blocks is in the following order: 0, 255, 1, 4, 3, 8, 133, 159, 216, 129, 63, 8, 48, 32, 73, 92, 155. Which one of the following memory block will NOT be in cache if LRU replacement policy is used?
A
3
B
8
C
129
D
216
GATE-CS-2009    Computer Organization and Architecture    Cache and main memory    
Discuss it


Question 10 Explanation: 
4 way set associative so 16 block will be divided in 4 sets of 4 blocks each. We apply(Address mod  4) function to decide set.
Set 0 0 48 0 mod4=0 *
4 32 255 mod4=3 *
8 8 1 mod4=1 *
216 92 4 mod4=0 *
Set 1 1 1 3 mod4=3 *
133 133 8 mod4=0 *
129 129 133 mod4=1 *
73 73 159 mod4=3 *
Set 2 216 mod4=0 *
129 mod4=1 *
          63 mod4=3 *
8 mod4=0 *
Set 3 255 155 98 mod4=0 *
3 3 32 mod4=0 *
159 159 73 mod4=1 *
63 63 92 mod4=0 *
155 Mod4=3 *
All  * are misses S1 in the first stage ans S2 in the second. In the second stage 216 is not present in the cache. So (D) is correct option.  
There are 55 questions to complete.


My Personal Notes arrow_drop_up