GATE 2006
191 questions
MCQ 1911-mark 191
Questions 76–80 of 191
Which of the following statements about relative addressing mode is FALSE?
Answer: (D)
(A) True. The instruction holds a small offset from the current address instead of a full absolute address, so the instruction is shorter.
(B) True. Keep the base address of the array in the displacement and the index in a register (base relative mode). Then the same instruction reaches every array element.
(C) True. When the code or data moves, only the base address changes. The instructions stay the same.
(D) False. The absolute address has to be worked out from the relative one by an addition. So relative addressing cannot be faster than absolute addressing. With special hardware it can match absolute addressing, but not beat it.
Answer: (D)
(B) True. Keep the base address of the array in the displacement and the index in a register (base relative mode). Then the same instruction reaches every array element.
(C) True. When the code or data moves, only the base address changes. The instructions stay the same.
(D) False. The absolute address has to be worked out from the relative one by an addition. So relative addressing cannot be faster than absolute addressing. With special hardware it can match absolute addressing, but not beat it.
Answer: (D)
The data path shown in the figure computes the number of 1s in the 32-bit input word corresponding to an unsigned even integer stored in the shift register.
The unsigned counter, initially zero, is incremented if the most significant bit of the shift register is 1.
The microprogram for the control is shown in the table below with missing control words for microinstructions .
The counter width (k), the number of missing microinstructions (n), and the control word for microinstructions are, respectively,
The unsigned counter, initially zero, is incremented if the most significant bit of the shift register is 1.
The microprogram for the control is shown in the table below with missing control words for microinstructions .
The counter width (k), the number of missing microinstructions (n), and the control word for microinstructions are, respectively,
Answer: (D)
Each missing microinstruction must shift the register left by one bit and let the counter add one if the bit at the MSB is 1.
Number of microinstructions. The input is an unsigned even integer, so its LSB (bit 0) is always . Only bits 31 down to 1 can be 1. Each shift brings the next bit to the MSB position, so shifts check all of them: . A 32nd shift would look only at the LSB, which is 0.
Counter width. The count of 1s is at most , because bit 0 is 0. , so bits are enough. (A count of 32 would need 6 bits, but it cannot occur.)
Control word (reset counter, shift left, load output):
- reset counter , otherwise the count would be cleared (it is only in BEGIN).
- shift left , to bring the next bit to the MSB.
- load output , since the result is loaded only in END.
So the word is .
. Option C has , which would load the output on every step, and A and B have the wrong and .
Answer: (D)
Number of microinstructions. The input is an unsigned even integer, so its LSB (bit 0) is always . Only bits 31 down to 1 can be 1. Each shift brings the next bit to the MSB position, so shifts check all of them: . A 32nd shift would look only at the LSB, which is 0.
Counter width. The count of 1s is at most , because bit 0 is 0. , so bits are enough. (A count of 32 would need 6 bits, but it cannot occur.)
Control word (reset counter, shift left, load output):
- reset counter , otherwise the count would be cleared (it is only in BEGIN).
- shift left , to bring the next bit to the MSB.
- load output , since the result is loaded only in END.
So the word is .
. Option C has , which would load the output on every step, and A and B have the wrong and .
Answer: (D)
A computer system has a level-1 instruction cache (1-cache), a level-1 data cache (D-cache) and a level-2 cache (L2-cache) with the following specifications:
The length of the physical address of a word in the main memory is 30 bits. The capacity of the tag memory in the I-cache, D-cache and L2-cache is, respectively,
The length of the physical address of a word in the main memory is 30 bits. The capacity of the tag memory in the I-cache, D-cache and L2-cache is, respectively,
Answer: (A)
1. I-cache
- Blocks in the cache:
- Bits needed for the block number:
- Words in one block:
- Bits needed for the word offset:
- Tag bits:
- Every block has its own tag bits, so the total tag memory is:
2. D-cache
- Blocks in the cache:
- Sets in the cache:
- Bits needed for the set number:
- Words in one block:
- Bits needed for the word offset:
- Tag bits:
- Every block has its own tag bits, so the total tag memory is:
3. L2 cache
- Blocks in the cache:
- Sets in the cache:
- Bits needed for the set number:
- Words in one block:
- Bits needed for the word offset:
- Tag bits:
- Every block has its own tag bits, so the total tag memory is:
Option (A).
A cache line is 64 bytes. The main memory has latency 32 ns and bandwidth 1 GBytes/s. The time required to fetch the entire cache line from the main memory is:
Answer: (C)
Bandwidth is . (The options only fit if 1 G is taken as , which is the usual choice for bandwidth.)
Transfer time for 64 bytes .
The memory latency is 32 ns.
Time to fetch the cache line .
Answer: (C)
Transfer time for 64 bytes .
The memory latency is 32 ns.
Time to fetch the cache line .
Answer: (C)
A CPU has a 32 KB direct mapped cache with 128-byte block size. Suppose A is a twodimensional array of size 512x512 with elements that occupy 8-bytes each. Consider the following two C code segments, P1 and P2.
The value of ratio is:
P1:
for (i=0; i<512; i++) {
for (j=0; j<512; j++) {
x += A[i][j];
}
}
P2:
for (i=0; i<512; i++) {
for (j=0; j<512; j++) {
x += A[j][i];
}
} P1 and P2 are executed independently with the same initial state, namely, the array A is not in the cache and i, j, x are in registers. Let the number of cache misses experienced by P1 be M1 and that for P2 be M2 . The value of ratio is:
Answer: (B)
The array has elements of 8 bytes. A block has 128 bytes, so it holds elements. The cache has lines. C stores the array in row-major order, so one row is bytes (32 blocks).
P1 reads the array in memory order. One miss brings in 16 elements, and the next 15 reads hit. So .
P2 reads down a column. One column touches 512 different blocks, which is more than the 256 lines. Each step down moves 4096 bytes, so consecutive blocks differ by 32 in block number and only different lines are used. So a block is replaced long before the next column needs its other 15 elements. Every access misses: .
Answer: (B)
P1 reads the array in memory order. One miss brings in 16 elements, and the next 15 reads hit. So .
P2 reads down a column. One column touches 512 different blocks, which is more than the 256 lines. Each step down moves 4096 bytes, so consecutive blocks differ by 32 in block number and only different lines are used. So a block is replaced long before the next column needs its other 15 elements. Every access misses: .
Answer: (B)