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
I07080ADDI @ 0x00000000raw=0x01000093, pc_after=0x00000004, wb=x1=0x00000010, mem=None, flow=next
I111080ADDI @ 0x00000004raw=0x00000113, pc_after=0x00000008, wb=x2=0x00000000, mem=None, flow=next
I215080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000001, mem=None, flow=next
I319080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000f, mem=None, flow=next
I423080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I527080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000002, mem=None, flow=next
I631080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000e, mem=None, flow=next
I735080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I839080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000003, mem=None, flow=next
I943080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000d, mem=None, flow=next
I1047080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I1151080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000004, mem=None, flow=next
I1255080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000c, mem=None, flow=next
I1359080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I1463080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000005, mem=None, flow=next
I1567080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000b, mem=None, flow=next
I1671080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I1775080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000006, mem=None, flow=next
I1879080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x0000000a, mem=None, flow=next
I1983080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I2087080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000007, mem=None, flow=next
I2191080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000009, mem=None, flow=next
I2295080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I2399080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000008, mem=None, flow=next
I24103080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000008, mem=None, flow=next
I25107080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I26111080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000009, mem=None, flow=next
I27115080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000007, mem=None, flow=next
I28119080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I29123080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000a, mem=None, flow=next
I30127080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000006, mem=None, flow=next
I31131080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I32135080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000b, mem=None, flow=next
I33139080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000005, mem=None, flow=next
I34143080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I35147080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000c, mem=None, flow=next
I36151080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000004, mem=None, flow=next
I37155080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I38159080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000d, mem=None, flow=next
I39163080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000003, mem=None, flow=next
I40167080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I41171080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000e, mem=None, flow=next
I42175080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000002, mem=None, flow=next
I43179080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I44183080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x0000000f, mem=None, flow=next
I45187080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000001, mem=None, flow=next
I46191080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000008, wb=None, mem=None, branch=BNE taken=true
I47195080ADDI @ 0x00000008raw=0x00110113, pc_after=0x0000000c, wb=x2=0x00000010, mem=None, flow=next
I48199080ADDI @ 0x0000000craw=0xfff08093, pc_after=0x00000010, wb=x1=0x00000000, mem=None, flow=next
I49203080BNE @ 0x00000010raw=0xfe009ce3, pc_after=0x00000014, wb=None, mem=None, branch=BNE taken=false
I50207080EBREAK @ 0x00000014raw=0x00100073, pc_after=0x00000014, wb=None, mem=None, flow=next, halted=true

Open program 20 reference