S2.2.1 Decode the Word

EasyImplement12 minIcarus Verilog · serverReview the topic

Four instruction words are cut at the six fixed places. Find the registers and the immediate of each.

Hardware context: Real RV32I instruction words from the assembler, cut at the six fixed field positions by test code; one 12-bit field widened by zero extension and by sign extension. Reading instruction words in a trace or a memory dump, and specifying an instruction decoder

Four words of RV32I are given in hex and in binary, cut at the six places that never move. Word A has the opcode of arithmetic on two registers. Word B has the opcode of arithmetic with an immediate. Word C is a store, and word D is a load.

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 four words
WordHex31 to 2524 to 2019 to 1514 to 1211 to 76 to 0
A00c5853300000000110001011000010100110011
Bffd3831311111111110100111000001100010011
C00942a2300000000100101000010101000100011
Dff81278311111111100000010010011110000011

Enter every value in decimal. A register is entered as its number: 7 for x7. For a yes or no question, enter 1 for yes and 0 for no.

EntryYour decision
RD_OF_AWhich register does word A write?
RS1_OF_AWhich register is rs1 of word A?
RS2_OF_AWhich register is rs2 of word A?
RD_OF_BWhich register does word B write?
RS1_OF_BWhich register is rs1 of word B?
B_IS_NEGATIVEIs the immediate of word B negative?
B_SIZEThe immediate of word B is minus what number?
RS2_OF_CWhich register does word C store?
RS1_OF_CWhich register holds the address in word C?
OFFSET_OF_CWhat is the immediate of word C?
RD_OF_DWhich register does word D write?
D_IS_NEGATIVEIs the immediate of word D negative?
D_SIZEThe immediate of word D is minus what number?
LOW_FIELD_FOR_KWord C becomes the store sw x9, K(x8), with K from 0 to 2047. Give the value in bits 11 to 7 of the word, as an expression in K.

Examples

Example 1

RD OF A
Input
Which register does word A write?
Output
matches = 1

Bits 11 to 7 are 01010, which is 10.

Example 2

RS1 OF A
Input
Which register is rs1 of word A?
Output
matches = 1

Bits 19 to 15 are 01011, which is 11.

Example 3

RS2 OF A
Input
Which register is rs2 of word A?
Output
matches = 1

Bits 24 to 20 are 01100, which is 12.

Constraints and Contract

  • Keep the parameter and named constants. Use the numeric codes and units on this page.
  • For LOW_FIELD_FOR_K, enter a constant expression using K. Only this entry changes with the parameter. The supported integer range is 20 through 2047, inclusive.

Hints

Hint 1

Name the format of each word from the text. It says which of the six places hold registers.

Hint 2

Turn each register field from binary into a number.

Hint 3

Collect the immediate bits of the format. If bit 31 is 1, the value is negative: take 4096 away.

What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.

14 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 3 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

RD OF A

Input
Which register does word A write?
Expected output
matches = 1

Bits 11 to 7 are 01010, which is 10.

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

Icarus Verilog · server