S2.1.1 What Is in x5

EasyImplement12 minIcarus Verilog · serverReview the topic

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

SignalWidthRole
question8input of each check
Full specification
The program
Addresses are in hex.
AddressInstruction
00addi x5, x0, 12
04addi x6, x0, 5
08sub x5, x5, x6
0cslli x7, x5, 2
10add x0, x7, x7
14lw x6, 0(x10)
18add x5, x6, x7
1csw x5, 4(x10)
20beq x5, x6, 0x28
24addi x5, x5, 1
28ebreak

Enter every value in decimal. For a yes or no question, enter 1 for yes and 0 for no.

EntryYour decision
X5_AFTER_00What does x5 hold after the instruction at 00?
X6_AFTER_04What does x6 hold after the instruction at 04?
X5_AFTER_08What does x5 hold after the instruction at 08?
X7_AFTER_0CWhat does x7 hold after the instruction at 0c?
X0_AFTER_10What does x0 hold after the instruction at 10?
X6_AFTER_14What does x6 hold after the instruction at 14?
X5_AFTER_18What does x5 hold after the instruction at 18?
WORD_AT_8000_0004What does the word at 8000_0004 hold at the end?
BRANCH_TAKENIs the branch at 20 taken?
X5_AT_STOPWhat does x5 hold when the program stops at ebreak?
DATA_TRANSFERSHow many bus transfers carry data? Do not count the fetches.
INSTRUCTIONS_RUNHow many instructions run before the ebreak?
X5_FOR_NThe 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

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

X5 AFTER 00

Input
What does x5 hold after the instruction at 00?
Expected output
matches = 1

addi adds 12 to x0, which is 0.

Run samples executes all 3 public checks. Check all tests runs 13 checks on the server.

Icarus Verilog · server