Run eleven lines of RV32I assembly by hand, and write down what each register holds.
Hardware context: A small model of an RV32I processor as test code: 32 registers, a PC and data memory, running a program given as rows. Reading a processor trace and writing short RV32I programs
A program starts at address 0. Every register holds 0, except x10: it holds 8000_0000. The word at 8000_0000 holds 40. The table below is the program. The instruction slli shifts a register left by the number of bits given, and sub subtracts the second source from the first.
This worksheet uses named constants. The first three entries show how to record your decisions.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
question | 8 | input of each check |
Full specification
| Address | Instruction |
|---|---|
| 00 | addi x5, x0, 12 |
| 04 | addi x6, x0, 5 |
| 08 | sub x5, x5, x6 |
| 0c | slli x7, x5, 2 |
| 10 | add x0, x7, x7 |
| 14 | lw x6, 0(x10) |
| 18 | add x5, x6, x7 |
| 1c | sw x5, 4(x10) |
| 20 | beq x5, x6, 0x28 |
| 24 | addi x5, x5, 1 |
| 28 | ebreak |
Enter every value in decimal. For a yes or no question, enter 1 for yes and 0 for no.
| Entry | Your decision |
|---|---|
| X5_AFTER_00 | What does x5 hold after the instruction at 00? |
| X6_AFTER_04 | What does x6 hold after the instruction at 04? |
| X5_AFTER_08 | What does x5 hold after the instruction at 08? |
| X7_AFTER_0C | What does x7 hold after the instruction at 0c? |
| X0_AFTER_10 | What does x0 hold after the instruction at 10? |
| X6_AFTER_14 | What does x6 hold after the instruction at 14? |
| X5_AFTER_18 | What does x5 hold after the instruction at 18? |
| WORD_AT_8000_0004 | What does the word at 8000_0004 hold at the end? |
| BRANCH_TAKEN | Is the branch at 20 taken? |
| X5_AT_STOP | What does x5 hold when the program stops at ebreak? |
| DATA_TRANSFERS | How many bus transfers carry data? Do not count the fetches. |
| INSTRUCTIONS_RUN | How many instructions run before the ebreak? |
| X5_FOR_N | The first instruction becomes addi x5, x0, N. Give x5 at the ebreak, as an expression in N. |
Examples
Example 1
X5 AFTER 00- Input
What does x5 hold after the instruction at 00?
- Output
matches = 1
addi adds 12 to x0, which is 0.
Example 2
X6 AFTER 04- Input
What does x6 hold after the instruction at 04?
- Output
matches = 1
addi adds 5 to x0.
Example 3
X5 AFTER 08- Input
What does x5 hold after the instruction at 08?
- Output
matches = 1
sub takes x6 from x5: 12 less 5.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For X5_FOR_N, enter a constant expression using N. Only this entry changes with the parameter. The supported integer range is 12 through 58, inclusive.
Hints
Hint 1
Keep a small table of x5, x6 and x7. Change one entry for each instruction.
Hint 2
In every line except the store and the branch, the first register is the one written.
Hint 3
Decide the branch from the two values in your table. Then follow the PC.
What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.
13 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 problems on this path