Skip to content

Program 21: Sixteen-word array sum

Program catalogue · Instruction reference · Executable reference

Purpose

Provide a scalar array-sum workload combining a load-use dependency, address updates, a counter, and loop branches.

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-21
Headless selection --program 21
Visualizer scenario rv32i-program21
Registered test RV32ISingleCycleSystemTest/program-21
Instruction image 9 words, starting at 0x00000000; last word at 0x00000020
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
0x00000100 01 00 00 00
0x00000104 02 00 00 00
0x00000108 03 00 00 00
0x0000010C 04 00 00 00
0x00000110 05 00 00 00
0x00000114 06 00 00 00
0x00000118 07 00 00 00
0x0000011C 08 00 00 00
0x00000120 09 00 00 00
0x00000124 0A 00 00 00
0x00000128 0B 00 00 00
0x0000012C 0C 00 00 00
0x00000130 0D 00 00 00
0x00000134 0E 00 00 00
0x00000138 0F 00 00 00
0x0000013C 10 00 00 00

The table lists the complete preloaded data image, not instruction bytes. Data values use little-endian byte order.

Register Role established by the program
x1 Next input word address
x2 Remaining word count
x3 Sum
x4 Loaded word

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, 0x100             # 0x00000000 | 0x10000093
addi x2, x0, 16                # 0x00000004 | 0x01000113
addi x3, x0, 0                 # 0x00000008 | 0x00000193
loop:
lw x4, 0(x1)                   # 0x0000000C | 0x0000A203
add x3, x3, x4                 # 0x00000010 | 0x004181B3
addi x1, x1, 4                 # 0x00000014 | 0x00408093
addi x2, x2, -1                # 0x00000018 | 0xFFF10113
bne x2, x0, loop               # 0x0000001C | 0xFE0118E3
ebreak                         # 0x00000020 | 0x00100073

Execution

  1. Initialize source 0x100, count sixteen, and sum zero. Input words are the integers 1 through 16.
  2. Each pass loads one word, immediately adds it to the sum, advances the source by four bytes, decrements the count, and conditionally repeats.
  3. The sum is 16 × 17 / 2 = 136; the last loaded value is 16 and the source ends at 0x140.
  4. EBREAK ends 3 + 16 × 5 + 1 = 84 attempts. The branch is taken fifteen times.

Unlike Program 1, this fixture has no result stores. Its sum stays in x3, and the input memory is unchanged.

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 0x00000140 Next input word address
x2 0x00000000 Remaining word count
x3 0x00000088 Sum
x4 0x00000010 Loaded word
PC 0x00000020 EBREAK address
Attempts 84 Checkpoints I0–I83
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. The result is observed through architectural registers, not through an output buffer.

Simulation and checkpoints

For a headless functional check, run build/rv32i_experiment --core single --program 21 --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 84 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 84 instruction-attempt checkpoints of RV32ISingleCycleSystemTest/program-21, with a behavioral core. Times are absolute simulator units, not milliseconds or an ISA latency.

CheckpointTimeInstruction / addressExpected architectural effects
I07080ADDI @ 0x00000000raw=0x10000093, pc_after=0x00000004, wb=x1=0x00000100, mem=None, flow=next
I111080ADDI @ 0x00000004raw=0x01000113, pc_after=0x00000008, wb=x2=0x00000010, mem=None, flow=next
I215080ADDI @ 0x00000008raw=0x00000193, pc_after=0x0000000c, wb=x3=0x00000000, mem=None, flow=next
I319080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000001, mem=Read Word @0x00000100 -> 0x00000001, flow=next
I423080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000001, mem=None, flow=next
I527080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000104, mem=None, flow=next
I631080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x0000000f, mem=None, flow=next
I735080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I839080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000002, mem=Read Word @0x00000104 -> 0x00000002, flow=next
I943080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000003, mem=None, flow=next
I1047080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000108, mem=None, flow=next
I1151080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x0000000e, mem=None, flow=next
I1255080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I1359080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000003, mem=Read Word @0x00000108 -> 0x00000003, flow=next
I1463080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000006, mem=None, flow=next
I1567080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x0000010c, mem=None, flow=next
I1671080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x0000000d, mem=None, flow=next
I1775080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I1879080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000004, mem=Read Word @0x0000010c -> 0x00000004, flow=next
I1983080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x0000000a, mem=None, flow=next
I2087080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000110, mem=None, flow=next
I2191080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x0000000c, mem=None, flow=next
I2295080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I2399080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000005, mem=Read Word @0x00000110 -> 0x00000005, flow=next
I24103080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x0000000f, mem=None, flow=next
I25107080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000114, mem=None, flow=next
I26111080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x0000000b, mem=None, flow=next
I27115080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I28119080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000006, mem=Read Word @0x00000114 -> 0x00000006, flow=next
I29123080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000015, mem=None, flow=next
I30127080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000118, mem=None, flow=next
I31131080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x0000000a, mem=None, flow=next
I32135080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I33139080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000007, mem=Read Word @0x00000118 -> 0x00000007, flow=next
I34143080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x0000001c, mem=None, flow=next
I35147080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x0000011c, mem=None, flow=next
I36151080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000009, mem=None, flow=next
I37155080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I38159080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000008, mem=Read Word @0x0000011c -> 0x00000008, flow=next
I39163080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000024, mem=None, flow=next
I40167080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000120, mem=None, flow=next
I41171080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000008, mem=None, flow=next
I42175080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I43179080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000009, mem=Read Word @0x00000120 -> 0x00000009, flow=next
I44183080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x0000002d, mem=None, flow=next
I45187080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000124, mem=None, flow=next
I46191080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000007, mem=None, flow=next
I47195080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I48199080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x0000000a, mem=Read Word @0x00000124 -> 0x0000000a, flow=next
I49203080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000037, mem=None, flow=next
I50207080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000128, mem=None, flow=next
I51211080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000006, mem=None, flow=next
I52215080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I53219080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x0000000b, mem=Read Word @0x00000128 -> 0x0000000b, flow=next
I54223080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000042, mem=None, flow=next
I55227080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x0000012c, mem=None, flow=next
I56231080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000005, mem=None, flow=next
I57235080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I58239080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x0000000c, mem=Read Word @0x0000012c -> 0x0000000c, flow=next
I59243080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x0000004e, mem=None, flow=next
I60247080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000130, mem=None, flow=next
I61251080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000004, mem=None, flow=next
I62255080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I63259080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x0000000d, mem=Read Word @0x00000130 -> 0x0000000d, flow=next
I64263080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x0000005b, mem=None, flow=next
I65267080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000134, mem=None, flow=next
I66271080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000003, mem=None, flow=next
I67275080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I68279080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x0000000e, mem=Read Word @0x00000134 -> 0x0000000e, flow=next
I69283080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000069, mem=None, flow=next
I70287080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000138, mem=None, flow=next
I71291080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000002, mem=None, flow=next
I72295080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I73299080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x0000000f, mem=Read Word @0x00000138 -> 0x0000000f, flow=next
I74303080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000078, mem=None, flow=next
I75307080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x0000013c, mem=None, flow=next
I76311080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000001, mem=None, flow=next
I77315080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I78319080LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000010, mem=Read Word @0x0000013c -> 0x00000010, flow=next
I79323080ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000088, mem=None, flow=next
I80327080ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000140, mem=None, flow=next
I81331080ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000000, mem=None, flow=next
I82335080BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x00000020, wb=None, mem=None, branch=BNE taken=false
I83339080EBREAK @ 0x00000020raw=0x00100073, pc_after=0x00000020, wb=None, mem=None, flow=next, halted=true

Open program 21 reference