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
| Signal | Width | Role |
|---|---|---|
question | 8 | input of each check |
Full specification
| Address, in decimal | Instruction |
|---|---|
| 0 | addi x10, x0, 1 |
| 4 | slli x10, x10, 31 |
| 8 | addi x5, x0, 9 |
| 12 | addi x6, x0, 4 |
| 16 | addi x0, x0, 0 |
| 20 | addi x0, x0, 0 |
| 24 | addi x0, x0, 0 |
| 28 | sub x7, x5, x6 |
| 32 | sw x7, 8(x10) |
| 36 | lw x8, 8(x10) |
| 40 | ebreak |
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.
| Entry | Your decision |
|---|---|
| ADDRESS_IN_ID_EX_AT_10 | Give the address of the instruction that ID/EX holds in cycle 10. |
| RS1_DATA_AT_10 | What is rs1_data in ID/EX in cycle 10? |
| RS2_DATA_AT_10 | What is rs2_data in ID/EX in cycle 10? |
| RD_AT_10 | What is rd in ID/EX in cycle 10? |
| ALU_B_SELECT_AT_10 | What is alu_b_select in ID/EX in cycle 10? |
| REG_WRITE_AT_10 | What is reg_write in ID/EX in cycle 10? |
| MEM_WRITE_AT_11 | What is mem_write in ID/EX in cycle 11? |
| REG_WRITE_AT_11 | What is reg_write in ID/EX in cycle 11? |
| IMM_AT_11 | What is imm in ID/EX in cycle 11? |
| SW_IN_MEM | In which cycle does EX/MEM hold the store? |
| EX_SIGNALS_IN_EX_MEM | Of alu_b_select, alu_operation, mem_write and reg_write: how many does EX/MEM still carry? |
| SIGNALS_IN_MEM_WB | Of the same four signals: how many does MEM/WB still carry? |
| LW_IN_WB | In which cycle does MEM/WB hold the load at address 36? |
| X8_FOR_K | The 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