Computer Organization and Architecture
Question 1 |
(j mod v) * k to (j mod v) * k + (k-1) | |
(j mod v) to (j mod v) + (k-1) | |
(j mod k) to (j mod k) + (v-1) | |
(j mod k) * v to (j mod k) * v + (v-1) |
Discuss it
Question 2 |
MBR ← PC MAR ← X PC ← Y Memory ← MBRWhich one of the following is a possible operation performed by this sequence?
Instruction fetch | |
Operand fetch | |
Conditional branch | |
Initiation of interrupt service |
Discuss it
Question 3 |
Consider an instruction pipeline with five stages without any branch prediction: Fetch Instruction (FI), Decode Instruction (DI), Fetch Operand (FO), Execute Instruction (EI) and Write Operand (WO). The stage delays for FI, DI, FO, EI and WO are 5 ns, 7 ns, 10 ns, 8 ns and 6 ns, respectively. There are intermediate storage buffers after each stage and the delay of each buffer is 1 ns. A program consisting of 12 instructions I1, I2, I3, …, I12 is executed in this pipelined processor. Instruction I4 is the only branch instruction and its branch target is I9. If the branch is taken during the execution of this program, the time (in ns) needed to complete the program is
132 | |
165 | |
176 | |
328 |
Discuss it
Pipeline will have to be stalled till EI stage of I4 completes, as EI stage will tell whether to take branch or not. After that I4(WO) and I9(FI) can go in parallel and later the following instructions. So, till I4(EI) completes : 7 cycles * (10 + 1 ) ns = 77ns From I4(WO) or I9(FI) to I12(WO) : 8 cycles * (10 + 1)ns = 88ns Total = 77 + 88 = 165 ns
Question 4 |
4 | |
5 | |
6 | |
7 |
Discuss it
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 5 |
c = a + b; d = c * a; e = c + a; x = c * c; if (x > a) { y = a * a; } else { d = d * d; e = e * e; }Suppose the instruction set architecture of the processor has only two registers. The only allowed compiler optimization is code motion, which moves statements from one place to another while preserving correctness. What is the minimum number of spills to memory in the compiled code?
0 | |
1 | |
2 | |
3 |
Discuss it
r1......r2 a.......b......c = a + b a.......c......x = c * c a.......x......but we will have to store c in mem as we don't know if x > a ................. or not y.......x......y = a * a choosing the best case of x > a , min spills = 1
Question 6 |
Consider the same data as above question. What is the minimum number of registers needed in the instruction set architecture of the processor to compile this code segment without any spill to memory? Do not apply any optimization other than optimizing register allocation.
3 | |
4 | |
5 | |
6 |
Discuss it
Note that for solving the above problem we are not allowed for code motion. So, we will start analyzing the code line by line and determine how many registers will be required to execute the above code snippet. Assuming the registers are numbered R1, R2, R3 and R4. The analysis has been shown in the table below So from the above analysis we can conclude that we will need minimum 4 registers to execute the above code snippet. This explanation has been contributed by Namita Singh.
Question 7 |
64 bits | |
128 bits | |
1 Kbits | |
2 Kbits |
Discuss it
Question 8 |
Register renaming is done in pipelined processors
as an alternative to register allocation at compile time | |
for efficient access to function parameters and local variables | |
to handle certain kinds of hazards | |
as part of address translation |
Discuss it
Register renaming is done to eliminate WAR (Write after Read) and WAW (Write after Write) dependency between instructions which could have caused pipieline stalls. Hence, (C) is the answer.
Example:
I1: Read A to B
I2: Write C to A
Here, there is a WAR dependency and pipeline would need stalls. In order to avoid it register renaming is done and
Write C to A
will be
Write C to A
WAR dependency is actually called anti-dependency and there is no real dependency except the fact that both uses same memory location. Register renaming can avoid this. Similarly WAW also.
Question 9 |
11 | |
14 | |
16 | |
27 |
Discuss it
Question 10 |
Consider the data given in previous question. The size of the cache tag directory is
160 Kbits | |
136 bits | |
40 Kbits | |
32 bits |
Discuss it
16 bit address 2 bit valid 1 modified 1 replace Total bits = 20 20 × no. of blocks = 160 K bits.