Full marks 30. Division, floating point, the pipeline-stage question, and the cache-bits calculation.
Q1 β Arithmetic CO3
1abig(a) Devise the division algorithm to divide an n-bit integer by another n-bit integer. Estimate time and space complexity. [4]
Restoring division. Remainder β Dividend (in the low half). Repeat n+1 times:
Remainder = Remainder β Divisor
if (Remainder < 0):
Remainder = Remainder + Divisor # restore
shift Quotient left, set new bit = 0
else:
shift Quotient left, set new bit = 1
shift Divisor right by 1
In MIPS, Lo = quotient, Hi = remainder. Time:n+1 iterations of subtract/shift β O(n). Space: remainder, divisor and quotient registers β O(n).
2abig(a) Define pipelining and pipeline rate. Name the MIPS-32 pipeline stages and describe each. [4]
Pipelining overlaps the execution of multiple instructions by splitting each into stages that use separate hardware, so several instructions run in different stages at once. Pipeline rate = the rate at which instructions complete in steady state β one per clock cycle, so the rate equals the (pipelined) clock frequency 1/tcβ.
Stage
Operation
IF
Instruction Fetch β read the instruction at PC; PC β PC + 4.
2bbig(b) 5-stage pipeline, each stage 2 ns except MEM = 3 ns, 2000 instructions: (i) total pipelined time (ii) speedup (iii) single-instruction latency both ways (iv) throughput both ways. [6]
Ξ£=2+2+2+3+2=11Β ns,tcβ=max=3Β ns,k=5,Β n=2000
(i) Pipelined total =(5+2000β1)Γ3=2004Γ3=6012Β nsβ.
(ii) Non-pipelined =2000Γ11=22000 ns β Speedup =22000/6012β3.66Γβ.
(iii) Latency: non-pipelined =11 ns; pipelined =5Γ3=15 ns. Pipelining raises latency 11 β 15 ns.