S2.7.1 What Is in ID-EX

EasyImplement12 minIcarus Verilog · serverReview the topic

Three instructions travel through the pipeline. Say what each pipeline register holds for them, cycle by cycle.

Hardware context: The five stages of ap_rv32_p5 cut down to arithmetic, lw and sw, with the register file and the ALU of the real core and no hazard logic. Reading a pipeline diagram and a pipeline trace of a processor

The program below starts at address 0 and runs on the five-stage pipeline of the lesson. The first instruction is in IF in cycle 1, and nothing waits. The register x10 holds the address 8000_0000 in hex when the last three instructions need it. 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
Ten instructions and an ebreak. The three instructions at 16, 20 and 24 do nothing.
Address, in decimalInstruction
0addi x10, x0, 1
4slli x10, x10, 31
8addi x5, x0, 9
12addi x6, x0, 4
16addi x0, x0, 0
20addi x0, x0, 0
24addi x0, x0, 0
28sub x7, x5, x6
32sw x7, 8(x10)
36lw x8, 8(x10)
40ebreak

The pipeline register ID/EX holds an instruction while it is in EX. EX/MEM holds it while it is in MEM, and MEM/WB while it is in WB.

Enter every value in decimal. A control signal is 0 or 1. The signal alu_b_select is 1 when the second ALU operand is the immediate.

EntryYour decision
ADDRESS_IN_ID_EX_AT_10Give the address of the instruction that ID/EX holds in cycle 10.
RS1_DATA_AT_10What is rs1_data in ID/EX in cycle 10?
RS2_DATA_AT_10What is rs2_data in ID/EX in cycle 10?
RD_AT_10What is rd in ID/EX in cycle 10?
ALU_B_SELECT_AT_10What is alu_b_select in ID/EX in cycle 10?
REG_WRITE_AT_10What is reg_write in ID/EX in cycle 10?
MEM_WRITE_AT_11What is mem_write in ID/EX in cycle 11?
REG_WRITE_AT_11What is reg_write in ID/EX in cycle 11?
IMM_AT_11What is imm in ID/EX in cycle 11?
SW_IN_MEMIn which cycle does EX/MEM hold the store?
EX_SIGNALS_IN_EX_MEMOf alu_b_select, alu_operation, mem_write and reg_write: how many does EX/MEM still carry?
SIGNALS_IN_MEM_WBOf the same four signals: how many does MEM/WB still carry?
LW_IN_WBIn which cycle does MEM/WB hold the load at address 36?
X8_FOR_KThe instruction at address 12 becomes addi x6, x0, K. Give x8 when the program stops, as an expression in K.

Examples

Example 1

ADDRESS IN ID EX AT 10
Input
Give the address of the instruction that ID/EX holds in cycle 10.
Output
matches = 1

The sub at address 28 is the eighth instruction: IF in cycle 8, EX in cycle 10.

Example 2

RS1 DATA AT 10
Input
What is rs1_data in ID/EX in cycle 10?
Output
matches = 1

The sub read x5 in ID, in cycle 9. The third instruction wrote 9 into x5 long before.

Example 3

RS2 DATA AT 10
Input
What is rs2_data in ID/EX in cycle 10?
Output
matches = 1

The sub read x6, which holds 4 since the end of cycle 8.

Constraints and Contract

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

Hints

Hint 1

First find which instruction is in the stage. The register in front of the stage holds it.

Hint 2

The control signals of an instruction are made once, in ID. From then on they only travel.

Hint 3

A signal that a stage has used is not carried any further.

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

ADDRESS IN ID EX AT 10

Input
Give the address of the instruction that ID/EX holds in cycle 10.
Expected output
matches = 1

The sub at address 28 is the eighth instruction: IF in cycle 8, EX in cycle 10.

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

Icarus Verilog · server