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
I07067ADDI @ 0x00000000raw=0x10000093, pc_after=0x00000004, wb=x1=0x00000100, mem=None, flow=next
I111067ADDI @ 0x00000004raw=0x01000113, pc_after=0x00000008, wb=x2=0x00000010, mem=None, flow=next
I215067ADDI @ 0x00000008raw=0x00000193, pc_after=0x0000000c, wb=x3=0x00000000, mem=None, flow=next
I319067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000001, mem=Read Word @0x00000100 -> 0x00000001, flow=next
I423067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000001, mem=None, flow=next
I527067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000104, mem=None, flow=next
I631067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x0000000f, mem=None, flow=next
I735067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I839067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000002, mem=Read Word @0x00000104 -> 0x00000002, flow=next
I943067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000003, mem=None, flow=next
I1047067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000108, mem=None, flow=next
I1151067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x0000000e, mem=None, flow=next
I1255067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I1359067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000003, mem=Read Word @0x00000108 -> 0x00000003, flow=next
I1463067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000006, mem=None, flow=next
I1567067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x0000010c, mem=None, flow=next
I1671067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x0000000d, mem=None, flow=next
I1775067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I1879067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000004, mem=Read Word @0x0000010c -> 0x00000004, flow=next
I1983067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x0000000a, mem=None, flow=next
I2087067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000110, mem=None, flow=next
I2191067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x0000000c, mem=None, flow=next
I2295067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I2399067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000005, mem=Read Word @0x00000110 -> 0x00000005, flow=next
I24103067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x0000000f, mem=None, flow=next
I25107067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000114, mem=None, flow=next
I26111067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x0000000b, mem=None, flow=next
I27115067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I28119067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000006, mem=Read Word @0x00000114 -> 0x00000006, flow=next
I29123067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000015, mem=None, flow=next
I30127067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000118, mem=None, flow=next
I31131067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x0000000a, mem=None, flow=next
I32135067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I33139067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000007, mem=Read Word @0x00000118 -> 0x00000007, flow=next
I34143067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x0000001c, mem=None, flow=next
I35147067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x0000011c, mem=None, flow=next
I36151067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000009, mem=None, flow=next
I37155067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I38159067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000008, mem=Read Word @0x0000011c -> 0x00000008, flow=next
I39163067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000024, mem=None, flow=next
I40167067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000120, mem=None, flow=next
I41171067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000008, mem=None, flow=next
I42175067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I43179067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000009, mem=Read Word @0x00000120 -> 0x00000009, flow=next
I44183067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x0000002d, mem=None, flow=next
I45187067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000124, mem=None, flow=next
I46191067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000007, mem=None, flow=next
I47195067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I48199067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x0000000a, mem=Read Word @0x00000124 -> 0x0000000a, flow=next
I49203067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000037, mem=None, flow=next
I50207067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000128, mem=None, flow=next
I51211067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000006, mem=None, flow=next
I52215067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I53219067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x0000000b, mem=Read Word @0x00000128 -> 0x0000000b, flow=next
I54223067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000042, mem=None, flow=next
I55227067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x0000012c, mem=None, flow=next
I56231067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000005, mem=None, flow=next
I57235067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I58239067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x0000000c, mem=Read Word @0x0000012c -> 0x0000000c, flow=next
I59243067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x0000004e, mem=None, flow=next
I60247067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000130, mem=None, flow=next
I61251067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000004, mem=None, flow=next
I62255067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I63259067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x0000000d, mem=Read Word @0x00000130 -> 0x0000000d, flow=next
I64263067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x0000005b, mem=None, flow=next
I65267067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000134, mem=None, flow=next
I66271067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000003, mem=None, flow=next
I67275067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I68279067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x0000000e, mem=Read Word @0x00000134 -> 0x0000000e, flow=next
I69283067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000069, mem=None, flow=next
I70287067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000138, mem=None, flow=next
I71291067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000002, mem=None, flow=next
I72295067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I73299067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x0000000f, mem=Read Word @0x00000138 -> 0x0000000f, flow=next
I74303067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000078, mem=None, flow=next
I75307067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x0000013c, mem=None, flow=next
I76311067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000001, mem=None, flow=next
I77315067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x0000000c, wb=None, mem=None, branch=BNE taken=true
I78319067LW @ 0x0000000craw=0x0000a203, pc_after=0x00000010, wb=x4=0x00000010, mem=Read Word @0x0000013c -> 0x00000010, flow=next
I79323067ADD @ 0x00000010raw=0x004181b3, pc_after=0x00000014, wb=x3=0x00000088, mem=None, flow=next
I80327067ADDI @ 0x00000014raw=0x00408093, pc_after=0x00000018, wb=x1=0x00000140, mem=None, flow=next
I81331067ADDI @ 0x00000018raw=0xfff10113, pc_after=0x0000001c, wb=x2=0x00000000, mem=None, flow=next
I82335067BNE @ 0x0000001craw=0xfe0118e3, pc_after=0x00000020, wb=None, mem=None, branch=BNE taken=false
I83339067EBREAK @ 0x00000020raw=0x00100073, pc_after=0x00000020, wb=None, mem=None, flow=next, halted=true

Open program 21 reference