Step through your first RISC-V instructions
Online version: https://fpga.labsland.com/altera/computer-organization/lab-01/part-01/
Debugger setup
CPUlator simulatorRISC-V · DE1-SoC Nios V computer, simulated in your browser. No board or sign-in needed.
- Get the sourceDownload
stride.s - Open the simulatorOpen CPUlator
Watch the FPGAcademy introduction to CPUlator. Open the RISC-V DE1-SoC simulator, load stride.s with File → Open, then choose Compile and Load. Find the highlighted instruction in Disassembly and the a0 register on the left.
Predict the next register value
The program computes a byte distance for words four bytes apart. Read the three instructions before hold. Write down the value you expect in a0 after each instruction. Press Step Into once per row. Record the PC before each step and the actual value in a0 afterward.
| Instruction | PC before | Predicted a0 | Observed a0 |
|---|---|---|---|
| li | |||
| slli | |||
| addi |
Change one assumption
Change the initial word index from 3 to 5. Compile and load again. At hold, explain how you got from the index to the byte distance. Check whether taking one more step at hold changes a0 or the PC.
For a physical follow-on, try the signed-maximum exercise in Lab 6 and read the value returned by the real board.
Adapted from FPGAcademy · Computer Organization 24.1 · Lab 1, I. Original LabsLand assembly and worksheet. MIT
