S2.4.2 Which Wires Does Lw Use

EasyImplement12 minIcarus Verilog · serverReview the topic

A load, a store, a branch and a jump run on the full datapath. Say which wires each one uses, and what they carry.

Hardware context: The datapath of ap_rv32_sc for an arithmetic instruction: a PC, the real register file and the real ALU of ap_rv32, an operand select and a write back, with given control signals. Reading the datapath of any processor core

The program below starts at address 0, with 0 in every register. The first two instructions put 8000_0000 into x10. The data memory starts there, and its word at 8000_0004 holds 9. The program runs on the full datapath of the lesson. Addresses of instructions are in decimal here.

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
A branch or jump target is an address, in decimal here.
Address, in decimalInstruction
0addi x10, x0, 1
4slli x10, x10, 31
8lw x6, 4(x10)
12addi x7, x6, 3
16sw x7, 8(x10)
20beq x6, x7, 32
24jal x1, 32
28addi x7, x7, 1
32ebreak

Enter every value in decimal. A control signal is 0 or 1, and result_select is 0, 1 or 2, as in the table of the lesson. For a yes or no question, enter 1 for yes and 0 for no.

EntryYour decision
LW_ALU_B_SELECTWhat is alu_b_select for the lw at address 8?
LW_OPERAND_BWhat value is on alu_operand_b for that lw?
LW_RESULT_SELECTWhat is result_select for that lw?
LW_MEM_READWhat is mem_read for that lw?
LW_ADDRESS_LOWWhat are the low 8 bits of dmem_addr for that lw, as a number?
LW_USES_RS2_DATADoes the value on rs2_data reach a register or the memory during that lw?
LW_USES_TARGETDoes the PC take the output of the target adder after that lw?
SW_REG_WRITEWhat is reg_write for the sw at address 16?
SW_WDATAWhat value is on dmem_wdata for that sw?
SW_ADDRESS_LOWWhat are the low 8 bits of dmem_addr for that sw?
BEQ_CONDITIONWhat is the output of the branch compare for the beq at address 20?
PC_AFTER_BEQWhat is the address of the instruction that runs after that beq?
X1_AT_STOPWhat does x1 hold when the program stops?
JAL_RESULT_SELECTWhat is result_select for the jal at address 24?
INSTRUCTIONS_RUNHow many instructions run before the ebreak?
WORD_FOR_KThe word at 8000_0004 holds K at the start. Give the word at 8000_0008 when the program stops, as an expression in K.

Examples

Example 1

LW ALU B SELECT
Input
What is alu_b_select for the lw at address 8?
Output
matches = 1

The address is rs1_data plus the immediate. So the second operand is the immediate.

Example 2

LW OPERAND B
Input
What value is on alu_operand_b for that lw?
Output
matches = 1

The immediate of lw x6, 4(x10).

Example 3

LW RESULT SELECT
Input
What is result_select for that lw?
Output
matches = 1

The value for rd comes from the load unit: select 1.

Constraints and Contract

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

Hints

Hint 1

Name the class of each instruction: load, store, branch or jump. The class fixes the control signals.

Hint 2

For each instruction that writes rd, ask which of three values goes there.

Hint 3

After each instruction, the PC takes the PC plus 4 or the target. Decide which, and why.

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

16 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

LW ALU B SELECT

Input
What is alu_b_select for the lw at address 8?
Expected output
matches = 1

The address is rs1_data plus the immediate. So the second operand is the immediate.

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

Icarus Verilog · server