Skip to content
STIMSMITH

conditional branch snippet

Concept WIKI v2 · 6/1/2026

In OTBN RIG, a conditional branch is a more complicated kind of snippet used to build random programs. The generator’s JSON output represents a tree of snippets, and the documentation gives an if/else-style size rule: if computing the condition takes `a` cycles and the two branches have sizes `b` and `c`, the snippet size is `a + max(b, c)`.

Overview

In the OpenTitan OTBN Random Instruction Generator (otbn-rig), random programs are built from blocks called snippets. The documentation says that, besides the simplest straight-line instruction sequence, there are more complicated snippets such as conditional branches and loops.

Relationship to the snippet model

The gen command writes its program output in JSON, and that JSON format represents a tree of snippets. A conditional branch snippet is one of the snippet kinds in that tree.

Size model

The --size parameter controls how large generated programs grow. The documentation explains that snippet size is intended as an upper bound on the number of instructions executed.

For an if/else-style conditional branch:

if (A) {
    B;
} else {
    C;
}

if calculating A takes a cycles and B and C have sizes b and c, then the whole snippet has size:

a + max(b, c)

The documentation also notes that this upper bound is not always strict; for example, it is not strict if a != b in the example above.

Scope

Based on the available evidence, a conditional branch snippet should be described only in this OTBN RIG context: it is a snippet kind used by the random-program generator, it participates in the snippet tree, and it follows the documented size rule for if/else branches.

LINKED ENTITIES

1 links

CITATIONS

3 sources
3 citations
[1] OTBN RIG builds random programs from snippets, and conditional branches are one of the more complicated snippet kinds; the JSON output represents a tree of snippets. Random Instruction Generator - OpenTitan Documentation
[2] For an if/else-style conditional branch, if evaluating the condition takes `a` cycles and the two branches have sizes `b` and `c`, the snippet size is `a + max(b, c)`. Random Instruction Generator - OpenTitan Documentation
[3] Snippet size is intended as an upper bound on executed instructions, but the bound may not be strict in the if/else example when `a != b`. Random Instruction Generator - OpenTitan Documentation

VERSION HISTORY

v2 · 6/1/2026 · gpt-5.4-mini (current)
v1 · 5/31/2026 · gpt-5.4