C8 · Final exam
Final exam: computer organization
Twelve problems from the whole course: instructions and machine code, memory and the stack, bits and fixed point, interrupts and I/O, linking, performance, the single-cycle and pipelined processor, branch prediction, caches, virtual memory and multicore power, and one program to write. Give yourself three hours, work without the lessons open, and write out your reasoning before checking each answer. "Another set" deals a different exam.
Check
Encode the R-type instructions below (opcode 0x33).
(a)
sub x12, x5, x11 (funct3 0, funct7 0x20)
(b)
mul x12, x5, x11 (funct3 0, funct7 1)
Check
The word FF010113 is an addi.
(a)
Which register does it write?
(b)
What is its immediate?
Check
The word 9ABCDEF0 is stored at 0x3000, little-endian.
(a)
What byte is at 0x3001?
(b)
What does lh from 0x3002 load?
Check
A recursive function saves ra and 2 s registers in a frame rounded up to 16 bytes and recurses 8 levels deep.
(a)
How much stack does it use at the deepest point?
(b)
How much would a loop version, with one such frame, use?
Check
Fixed point: 0.45 in Q15, and a 12-bit ADC reading of 1327 with a 5000 mV reference.
(a)
What integer stores 0.45?
(b)
What does multiply-then-shift give for the reading, in millivolts?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
Check
A peripheral produces 200000 values a second. Interrupts cost 40 cycles on a 120 MHz core.
(a)
What load would one interrupt per value cause? (Over 100% is impossible.)
(b)
With double-buffered DMA blocks of 1024, how long may processing a block take?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
Check
A firmware build has 40 kB of .text, 5 kB of .rodata, 6 kB of .data, 30 kB of .bss and a 4 kB stack.
(a)
How much flash?
(b)
How much RAM?
Check
A fraction 0.8 of a program's time is in code made 3 times faster.
(a)
What is the overall speedup?
(b)
What is the limit as s grows?
Check
A single-cycle processor has clock-to-Q 35, memories 180, register read 140, ALU 200, mux 30 and register setup 50 (ps). A pipelined version's slowest stage is one memory access, plus 40 ps of register overhead.
(a)
What is the single-cycle clock period?
Write units the way you normally would: 1.5 ps and 0.0015 ns are the same answer.
(b)
How many times faster is the pipelined clock?
Check
0.2 of instructions are loads, 0.3 of them used at once; 0.2 are branches, predicted with accuracy 0.97, at a 2-cycle penalty.
(a)
What is the CPI?
(b)
What is the IPC?
Check
A loop of 8 iterations runs 20 times; count all runs, the predictors starting at not taken (1-bit) and weakly not taken (2-bit).
(a)
How many mispredictions does the 1-bit predictor make?
(b)
How many does the 2-bit counter make?
Check
A 32 KiB, 4-way L1 with 64-byte lines hits in 2 cycles and misses 0.05 of the time; L2 takes 12 cycles with a local miss rate of 0.25; memory takes 150 cycles.
(a)
How many tag bits does the L1 use (32-bit addresses)?
(b)
What is the AMAT?
Check
Address 03938700 is on a page mapped to physical page 002BC (4 KiB pages). A 1-cycle TLB hits 0.999 of the time, memory takes 100 cycles, and the page table has 4 levels.
(a)
What is the physical address?
(b)
What is the average access time?
Check
4 cores at 0.6 of a single core's clock and 0.9 of its voltage run a program that is 0.99 parallel.
(a)
What is their dynamic power relative to the one core?
(b)
What is the speedup over the one core?
Check
Leave the largest of the five words in vals minus the smallest (the range) in a0.
RISC-V RV32IM (base integer plus multiply and divide). End your program with ebreak. Tab indents; press Esc and then Tab to move on.
Check
A program is 20% loads and 10% branches. A multi-cycle processor (loads 5 cycles, branches 3, the rest 4) runs at 320 ps; a single-cycle one at 800 ps.
(a)
What is the multi-cycle time per instruction?
Write units the way you normally would: 1.5 ps and 0.0015 ns are the same answer.
(b)
What clock period would the multi-cycle design need to match the single-cycle one?
Have paper and a calculator ready. Work each problem out by hand, then enter the answer. Your first try on each one counts toward your score.
Practice
Keep practicing
16 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.