Skip to content

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

  1. Initialize count 16 and accumulator zero.
  2. Each iteration increments x2, decrements x1, and executes BNE back to the first update while the count is nonzero.
  3. The branch is taken fifteen times and falls through on the sixteenth. The final values are x1=0 and x2=16.
  4. EBREAK completes 2 + 16 × 3 + 1 = 51 attempts.

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.

CheckpointTimeInstruction / addressExpected architectural effects
I07067ADDI @ 0x00000000raw=0x01000093, pc_after=0x00000004, wb=x1=0x00000010, mem=None, flow=next
I111067ADDI @ 0x00000004raw=0x00000113, pc_after=0x00000008, wb=x2=0x00000000, mem=None, flow=next
I215067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000001, mem=None, flow=next
I319067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000f, mem=None, flow=next
I423067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I527067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000002, mem=None, flow=next
I631067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000e, mem=None, flow=next
I735067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I839067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000003, mem=None, flow=next
I943067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000d, mem=None, flow=next
I1047067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I1151067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000004, mem=None, flow=next
I1255067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000c, mem=None, flow=next
I1359067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I1463067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000005, mem=None, flow=next
I1567067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000b, mem=None, flow=next
I1671067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I1775067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000006, mem=None, flow=next
I1879067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000a, mem=None, flow=next
I1983067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I2087067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000007, mem=None, flow=next
I2191067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000009, mem=None, flow=next
I2295067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I2399067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000008, mem=None, flow=next
I24103067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000008, mem=None, flow=next
I25107067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I26111067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000009, mem=None, flow=next
I27115067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000007, mem=None, flow=next
I28119067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I29123067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000a, mem=None, flow=next
I30127067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000006, mem=None, flow=next
I31131067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I32135067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000b, mem=None, flow=next
I33139067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000005, mem=None, flow=next
I34143067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I35147067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000c, mem=None, flow=next
I36151067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000004, mem=None, flow=next
I37155067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I38159067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000d, mem=None, flow=next
I39163067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000003, mem=None, flow=next
I40167067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I41171067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000e, mem=None, flow=next
I42175067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000002, mem=None, flow=next
I43179067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I44183067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000f, mem=None, flow=next
I45187067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000001, mem=None, flow=next
I46191067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I47195067ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000010, mem=None, flow=next
I48199067ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000000, mem=None, flow=next
I49203067BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000014, wb=None, mem=None, branch=BNE taken=false
I50207067EBREAK @ 0x00000014raw=0x00100073, pc_after=0x00000014, wb=None, mem=None, flow=next, halted=true

Open program 20 reference