C8 Computer organization · Practice
Midterm exam
Problems dealt one at a time, with new numbers every time. The kinds you miss come back more often, and you can keep going as long as you like.
Check
A program runs 4 million instructions at an average CPI of 1.25 on a 120 MHz clock.
(a)
How long does it take?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(b)
What is its MIPS rate?
Check
Consider addi x9, x0, 12 (opcode 0x13).
(a)
What is its encoding?
(b)
What is the word with only its immediate field filled in, everything else 0?
Check
The word DEADBEEF is stored at 0x2000 on this little-endian machine.
(a)
What byte is at 0x2000?
(b)
What does lb from 0x2003 load, as a signed number?
Check
A loop's branch at 1130 jumps back 4 instructions; elsewhere, jal ra, f at 1130 + 8 calls f at 1B58.
(a)
What offset does the branch hold?
(b)
What does the jal put in ra?
Check
struct sample { int t; short v; short flags; } is 8 bytes: t at offset 0, v at 4, flags at 6. An array of them starts at 1000.
(a)
At what address is s[3].v?
(b)
How far is s[3] from s[0]?
Check
A recursive function saves ra and 4 s registers in a frame rounded up to 16 bytes, and recurses 10 levels deep. sp starts at 0x10000.
(a)
How big is each frame?
(b)
What is sp at the deepest point?
Check
A control register holds 5B.
(a)
What does it hold after r ^= (1 << 0)?
(b)
What would r &= ~(1 << 0) give instead?
Check
0.55 and 0.25 are stored in Q15 and multiplied.
(a)
What integer stores 0.55?
(b)
The integer product is shifted right arithmetically by 15. What results?
Check
Signed integer division on RISC-V.
(a)
What does div give for −25 ÷ 2?
(b)
What does rem give for −25 and 2?
Check
Samples arrive at 48000 per second on a 96 MHz processor whose interrupts cost 50 cycles.
(a)
What load would an interrupt per sample put on it? (Over 100% means impossible.)
(b)
With DMA in double-buffered blocks of 512, how long does the processor have per block?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
Check
Firmware has 22 kB of code, 3 kB of constants, 5 kB of initialized globals, 20 kB of zeroed globals and a 2 kB stack.
(a)
How much flash?
(b)
How much RAM?
Check
A fraction 0.8 of a program's time is in a routine made 4 times faster.
(a)
What is the overall speedup?
(b)
What is the most any speedup of that routine could give?
Check
A program is 0.5 ALU instructions (1 cycle), 0.2 loads (4 cycles) and the rest branches (3 cycles on average).
(a)
What is its CPI?
(b)
What percentage of its cycles go to branches?
Check
Add up the absolute values of the four signed words in vals and leave the total 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
a0 holds a 10-bit ADC code; the reference is 2500 mV. Put the reading in millivolts in a1, rounded down.
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
On RV32, a struct holds 3 chars, then a 4-byte field aligned to 4, then one more char.
(a)
At what offset does the 4-byte field start?
(b)
How big is the struct?
A kind of problem counts as solid once you've got it right on the first try twice in a row. Back to the lesson · Practice every topic in C8