Program 20: Branch-heavy loop¶
Program catalogue · Instruction reference · Executable reference
Purpose¶
Provide frequent taken branches interleaved with two simple ALU updates.
This is one of the six workload fixtures. This page specifies its instructions and architectural result; pipeline cycles, stalls, and throughput are implementation-specific and are not established by this reference run.
Setup¶
| Property | Value |
|---|---|
| Benchmark workload ID | program-20 |
| Headless selection | --program 20 |
| Visualizer scenario | rv32i-program20 |
| Registered test | RV32ISingleCycleSystemTest/program-20 |
| Instruction image | 6 words, starting at 0x00000000; last word at 0x00000014 |
| Initial state | PC = 0x00000000; all registers zero; neither halted nor trapped |
| Memories | Separate instruction and data memories, 256 KiB each; unlisted data bytes zero |
| Start address | Bytes, in increasing address order |
|---|---|
| None | — |
The table lists the complete preloaded data image, not instruction bytes. No data image is required.
| Register | Role established by the program |
|---|---|
x1 |
Countdown from 16 |
x2 |
Accumulator counting iterations |
The shared setup describes reset, loading, and the behavioral-core selection. These hand-written programs do not use the standard ABI stack.
Assembly¶
Every instruction word is shown, including words that a trap or branch may prevent from executing. Address and word comments identify the exact fixture image.
addi x1, x0, 16 # 0x00000000 | 0x01000093
addi x2, x0, 0 # 0x00000004 | 0x00000113
loop:
addi x2, x2, 1 # 0x00000008 | 0x00110113
addi x1, x1, -1 # 0x0000000C | 0xFFF08093
bne x1, x0, loop # 0x00000010 | 0xFE009CE3
ebreak # 0x00000014 | 0x00100073
Execution¶
- Initialize count 16 and accumulator zero.
- Each iteration increments
x2, decrementsx1, and executes BNE back to the first update while the count is nonzero. - The branch is taken fifteen times and falls through on the sixteenth. The final values are
x1=0andx2=16. - EBREAK completes
2 + 16 × 3 + 1 = 51attempts.
One branch per three loop instructions makes redirects frequent. The reference does not assign a pipeline flush penalty to them.
Expected result¶
These are the fixture's explicit final-state assertions. Unlisted registers are not implicitly zero; their values follow the assembly. The store table enumerates every written byte, including zero-valued writes.
| Item | Expected value | Meaning |
|---|---|---|
x1 |
0x00000000 |
Countdown from 16 |
x2 |
0x00000010 |
Accumulator counting iterations |
PC |
0x00000014 |
EBREAK address |
Attempts |
51 | Checkpoints I0–I50 |
HALTED |
1 | Project halt |
TRAPPED |
0 | No exception |
TRAP_CAUSE |
0 | None, a project enum code |
| Start address | Bytes, in increasing address order |
|---|---|
| None | — |
No data writes occur; the initial data image is unchanged. All data memory remains unchanged; there are no loads or stores.
Simulation and checkpoints¶
For a headless functional check, run build/rv32i_experiment --core single --program 20 --period 4000 --max-cycles 4096 --allocation-limit-mib 512. Select baseline or advanced for the same fixture on another core; add --fidelity reference for the structural-datapath reference profile. The explicit period is a scheduling choice, not a performance result. Use the campaign procedure for clock-certified measurements.
All 51 instruction attempts are included, with absolute simulator time and checkpoint number. The terminating EBREAK is included. The table is scrollable in both directions. Observation conventions distinguish these attempts from loaded word addresses and hardware cycles.
All 51 instruction-attempt checkpoints of RV32ISingleCycleSystemTest/program-20, with a behavioral core. Times are absolute simulator units, not milliseconds or an ISA latency.
| Checkpoint | Time | Instruction / address | Expected architectural effects |
|---|---|---|---|
| I0 | 7080 | ADDI @ 0x00000000 | raw=0x01000093, pc_after=0x00000004, wb=x1=0x00000010, mem=None, flow=next |
| I1 | 11080 | ADDI @ 0x00000004 | raw=0x00000113, pc_after=0x00000008, wb=x2=0x00000000, mem=None, flow=next |
| I2 | 15080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000001, mem=None, flow=next |
| I3 | 19080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000f, mem=None, flow=next |
| I4 | 23080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I5 | 27080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000002, mem=None, flow=next |
| I6 | 31080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000e, mem=None, flow=next |
| I7 | 35080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I8 | 39080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000003, mem=None, flow=next |
| I9 | 43080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000d, mem=None, flow=next |
| I10 | 47080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I11 | 51080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000004, mem=None, flow=next |
| I12 | 55080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000c, mem=None, flow=next |
| I13 | 59080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I14 | 63080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000005, mem=None, flow=next |
| I15 | 67080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000b, mem=None, flow=next |
| I16 | 71080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I17 | 75080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000006, mem=None, flow=next |
| I18 | 79080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000a, mem=None, flow=next |
| I19 | 83080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I20 | 87080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000007, mem=None, flow=next |
| I21 | 91080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000009, mem=None, flow=next |
| I22 | 95080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I23 | 99080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000008, mem=None, flow=next |
| I24 | 103080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000008, mem=None, flow=next |
| I25 | 107080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I26 | 111080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000009, mem=None, flow=next |
| I27 | 115080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000007, mem=None, flow=next |
| I28 | 119080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I29 | 123080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000a, mem=None, flow=next |
| I30 | 127080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000006, mem=None, flow=next |
| I31 | 131080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I32 | 135080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000b, mem=None, flow=next |
| I33 | 139080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000005, mem=None, flow=next |
| I34 | 143080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I35 | 147080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000c, mem=None, flow=next |
| I36 | 151080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000004, mem=None, flow=next |
| I37 | 155080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I38 | 159080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000d, mem=None, flow=next |
| I39 | 163080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000003, mem=None, flow=next |
| I40 | 167080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I41 | 171080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000e, mem=None, flow=next |
| I42 | 175080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000002, mem=None, flow=next |
| I43 | 179080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I44 | 183080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000f, mem=None, flow=next |
| I45 | 187080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000001, mem=None, flow=next |
| I46 | 191080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true |
| I47 | 195080 | ADDI @ 0x00000008 | raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000010, mem=None, flow=next |
| I48 | 199080 | ADDI @ 0x0000000c | raw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000000, mem=None, flow=next |
| I49 | 203080 | BNE @ 0x00000010 | raw=0xfe009ce3, pc_after=0x00000014, wb=None, mem=None, branch=BNE taken=false |
| I50 | 207080 | EBREAK @ 0x00000014 | raw=0x00100073, pc_after=0x00000014, wb=None, mem=None, flow=next, halted=true |