S2.15.1 Rename the Sequence

HardImplement22 minIcarus Verilog · serverReview the topic

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

SignalWidthRole
question8input of each check
Full specification
The program
The eight instructions. Their addresses in the real program are 04 to 20; here they are numbered from 00.
Address, in hexInstruction
00lw x5, 0(x8)
04add x6, x5, x9
08addi x5, x8, 4
0clw x7, 0(x5)
10add x6, x6, x7
14addi x5, x5, 4
18sub x9, x6, x5
1csw 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.

EntryYour decision
DESTINATION_OF_00Which physical register does the lw at 00 write?
FIRST_SOURCE_OF_04Which physical register does the add at 04 read for x5?
DESTINATION_OF_08Which physical register does the addi at 08 write?
SECOND_SOURCE_OF_04Which physical register does the add at 04 read for x9?
DESTINATION_OF_04Which physical register does the add at 04 write?
SOURCE_OF_0CWhich physical register does the lw at 0c read for x5?
DESTINATION_OF_0CWhich physical register does the lw at 0c write?
FIRST_SOURCE_OF_10Which physical register does the add at 10 read for x6?
DESTINATION_OF_10Which physical register does the add at 10 write?
SOURCE_OF_14Which physical register does the addi at 14 read for x5?
DESTINATION_OF_14Which physical register does the addi at 14 write?
FIRST_SOURCE_OF_18Which physical register does the sub at 18 read for x6?
SECOND_SOURCE_OF_18Which physical register does the sub at 18 read for x5?
DATA_SOURCE_OF_1CWhich physical register does the sw at 1c read for x9?
FREE_REGISTERS_LEFTHow many of the 16 free physical registers are left after the eight instructions?
ADDI_AT_08_NO_RENAMINGWithout renaming, in which cycle is the addi at 08 finished?
ADDI_AT_08_RENAMEDWith renaming, in which cycle is the addi at 08 finished?
ALL_DONE_RENAMEDWith renaming, in which cycle is the last of the eight finished?
LAST_DESTINATION_FOR_KThe 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

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

DESTINATION OF 00

Input
Which physical register does the lw at 00 write?
Expected output
matches = 1

The first free one.

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

Icarus Verilog · server