Seven instructions run on the datapath of the lesson. Follow the fields, the operands and the control signals of each.
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. It runs on the datapath of the lesson: a PC, a register file, an operand select and an ALU. Addresses are in decimal here, so that you can enter them as they are.
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 x5, x0, 9 |
| 4 | addi x6, x0, 5 |
| 8 | add x7, x5, x6 |
| 12 | sub x8, x7, x6 |
| 16 | slli x9, x6, 2 |
| 20 | add x0, x7, x7 |
| 24 | or x10, x9, x6 |
| 28 | ebreak |
Enter every value in decimal. A control signal is 0 or 1, as in the table of the lesson.
| Entry | Your decision |
|---|---|
| RS1_FIELD_AT_8 | Which register number is on the first read port for the instruction at address 8? |
| RS2_FIELD_AT_8 | Which register number is on the second read port for the instruction at address 8? |
| ALU_B_SELECT_AT_8 | What is alu_b_select for the instruction at address 8? |
| ALU_B_SELECT_AT_4 | What is alu_b_select for the instruction at address 4? |
| OPERAND_B_AT_4 | What value is on alu_operand_b for the instruction at address 4? |
| OPERAND_A_AT_16 | What value is on rs1_data for the instruction at address 16? |
| ALU_RESULT_AT_16 | What is alu_result for the instruction at address 16? |
| PC_NEXT_AT_12 | What is pc_next while the instruction at address 12 executes? |
| REG_WRITE_AT_20 | What is reg_write for the instruction at address 20? |
| X0_AFTER_20 | What does x0 hold after the instruction at address 20? |
| X8_AT_STOP | What does x8 hold when the program stops? |
| X10_AT_STOP | What does x10 hold when the program stops? |
| CYCLES | How many clock cycles do the seven instructions before the ebreak take on a single-cycle datapath? |
| X7_FOR_K | The first instruction becomes addi x5, x0, K. Give x7 when the program stops, as an expression in K. |
Examples
Example 1
RS1 FIELD AT 8- Input
Which register number is on the first read port for the instruction at address 8?
- Output
matches = 1
The add at 8 names x5 as rs1. That field goes straight to the first read port.
Example 2
RS2 FIELD AT 8- Input
Which register number is on the second read port for the instruction at address 8?
- Output
matches = 1
The add names x6 as rs2.
Example 3
ALU B SELECT AT 8- Input
What is alu_b_select for the instruction at address 8?
- Output
matches = 1
An add takes its second operand from a register: the select is 0.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For X7_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
For each instruction, write down rs1, rs2 and rd before anything else.
Hint 2
Ask of each instruction: does its second operand come from a register or from the word itself?
Hint 3
A register changes only at the clock edge that ends the cycle of the instruction that writes it.
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