Lab 5

Freeze a display while an interrupt clock keeps time

Debugger setup

CPUlator simulatorRISC-V · DE1-SoC Nios V computer, simulated in your browser. No board or sign-in needed.

  1. Get the sourceDownload interrupt_clock.s
  2. Open the simulatorOpen CPUlator

Plan a one-minute stopwatch. HEX3 and HEX2 show seconds. HEX1 and HEX0 show hundredths. The timer generates one interrupt per hundredth. While any switch is on, the display must hold its current reading. The stored time must keep advancing.

Check the time limit

Open interrupt_clock.s in CPUlator for RISC-V DE1-SoC. Count the hundredths from 00.00 through 59.99 inclusive. Use that number to correct the wrap comparison. Follow the interrupt from clock_trap into encode_time. Explain the purpose of the four byte shifts in the packing loop.

Temporarily change the initial elapsed word to 5998. Compile and load. In Disassembly, search for record_time, set a breakpoint on its first instruction and continue three times. Record a0 each time. This gives you a repeatable reading at a boundary that passes too quickly to see in the browser.

Read the two clocks

Remove the breakpoint, restore the initial value to zero and reload. Select Continue. Turn on switch 0 and record the four digits twice, about two seconds apart. Turn on switch 9 before lowering switch 0. What happens while switch 9 remains on? Lower switch 9, then read the display as soon as it updates.

Test Prediction Observation
First three interrupts from 5998
Two readings while switch 0 is on
Switch 9 alone remains on
All switches return to zero

Explain how the recovered reading tells you whether the timer itself paused. Include the machine timer compare value in ticks and the values from the breakpoint.

Adapted from FPGAcademy Computer Organization, Lab 5, Part IV. LabsLand wrote the assembly and activities. MIT notice

Run a signed maximum on a physical Nios V board