Eight instructions write x5 three times and x6 twice. Rename them with a table and a free list, and say which physical register every value lives in.
Hardware context: Test code beside the core: a sum that prices two programs of the real core ap_rv32 on pipelines of 5, 8 and 12 stages, and a model of a two-wide in-order core that replays the instructions the real core executed. ap_rv32 itself is single-issue. Reading the claims of a core: its depth, its width and its IPC on a real program
The core of this worksheet is a model with register renaming. Before the first instruction, x0 to x31 are in the physical registers p0 to p31. The free list holds p32 to p47, and hands them out in this order. For each instruction the sources are looked up first. Then, if it writes a register, the destination takes the next free physical register. Nothing is given back.
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 hex | Instruction |
|---|---|
| 00 | lw x5, 0(x8) |
| 04 | add x6, x5, x9 |
| 08 | addi x5, x8, 4 |
| 0c | lw x7, 0(x5) |
| 10 | add x6, x6, x7 |
| 14 | addi x5, x5, 4 |
| 18 | sub x9, x6, x5 |
| 1c | sw x9, 0(x8) |
Enter a physical register as its number: p32 is 32. For the timing entries: as many instructions as are ready may run in a cycle, a load takes 3 cycles and everything else 1, and the first cycle is cycle 1.
| Entry | Your decision |
|---|---|
| DESTINATION_OF_00 | Which physical register does the lw at 00 write? |
| FIRST_SOURCE_OF_04 | Which physical register does the add at 04 read for x5? |
| DESTINATION_OF_08 | Which physical register does the addi at 08 write? |
| SECOND_SOURCE_OF_04 | Which physical register does the add at 04 read for x9? |
| DESTINATION_OF_04 | Which physical register does the add at 04 write? |
| SOURCE_OF_0C | Which physical register does the lw at 0c read for x5? |
| DESTINATION_OF_0C | Which physical register does the lw at 0c write? |
| FIRST_SOURCE_OF_10 | Which physical register does the add at 10 read for x6? |
| DESTINATION_OF_10 | Which physical register does the add at 10 write? |
| SOURCE_OF_14 | Which physical register does the addi at 14 read for x5? |
| DESTINATION_OF_14 | Which physical register does the addi at 14 write? |
| FIRST_SOURCE_OF_18 | Which physical register does the sub at 18 read for x6? |
| SECOND_SOURCE_OF_18 | Which physical register does the sub at 18 read for x5? |
| DATA_SOURCE_OF_1C | Which physical register does the sw at 1c read for x9? |
| FREE_REGISTERS_LEFT | How many of the 16 free physical registers are left after the eight instructions? |
| ADDI_AT_08_NO_RENAMING | Without renaming, in which cycle is the addi at 08 finished? |
| ADDI_AT_08_RENAMED | With renaming, in which cycle is the addi at 08 finished? |
| ALL_DONE_RENAMED | With renaming, in which cycle is the last of the eight finished? |
| LAST_DESTINATION_FOR_K | The eight instructions are executed K times in a row, with nothing given back and enough free registers. Which physical register does the last sub write? Give an expression in K. |
Examples
Example 1
DESTINATION OF 00- Input
Which physical register does the lw at 00 write?
- Output
matches = 1
The first free one.
Example 2
FIRST SOURCE OF 04- Input
Which physical register does the add at 04 read for x5?
- Output
matches = 1
The table was changed by the lw: x5 is in p32.
Example 3
DESTINATION OF 08- Input
Which physical register does the addi at 08 write?
- Output
matches = 1
The add at 04 took p33. This is the second value of x5, in a place of its own.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For LAST_DESTINATION_FOR_K, enter a constant expression using K. Only this entry changes with the parameter. The supported integer range is 1 through 5, inclusive.
Hints
Hint 1
One line for x5, x6, x7 and x9. Cross out the old place at every write.
Hint 2
For each instruction, read the places of its sources from the table as it is. Only then change the table.
Hint 3
Every instruction that writes a register takes one place. A store takes none.
What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.
19 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