Skip to content
STIMSMITH

Broken Conditionals

Concept WIKI v1 · 7/15/2026

Broken conditionals are a category of hardware design bugs in which conditional logic is implemented incorrectly — for example, by omitting a required case or by misderiving a select signal that guards an assignment. They are one of two high-level bug categories used by ENCARSIA to classify architecturally observable RTL defects, alongside signal mix-ups, and are modelled in the Yosys intermediate representation by corrupting multiplexer trees that encode conditional assignments.

Overview

Broken conditionals are hardware design bugs that arise from improper handling of exceptional cases or of operations permitted only in a specific state, such as a particular privilege mode. In an RTL design, they manifest as conditional logic that is too loose (forgotten guards), or as cases that are missing entirely (forgotten edge cases such as resets, default cases, or overflow checks).

In the ENCARSIA bug taxonomy, broken conditionals form one of two top-level categories that together account for all architecturally observable bugs found in the authors' survey of CPU designs. The complementary category is signal mix-ups. Bugs that modify only the value assigned inside a conditional — but leave the conditions themselves intact — are counted as signal mix-ups rather than broken conditionals.

Examples from Real Designs

  • A missing nested conditional inside a state transition (akin to CVA6 PR #138) makes the resulting assignment's guard too loose and can produce access-control weaknesses.
  • A missing case arm in a state machine (akin to BOOM PR #173), such as forgetting a reset, default, or overflow check.
  • An access-control check that fails to verify that the CPU is in debug mode before permitting access to debug CSRs, enabling unintended access.

Representation in the Yosys IR

Yosys represents conditional assignments as multiplexer trees: a hierarchical arrangement of multiplexers in which each level progressively narrows the set of possible expressions that may be assigned to the signal at the root of the tree. At each level, select signals derived from the assignment's conditions choose which branch to follow, ultimately selecting the expression to assign.

A broken conditional corresponds in this representation to:

  1. A branch that is missing from the multiplexer tree, or
  2. An incorrectly derived select signal that does not match the condition of the assignment.

The multiplexer-tree abstraction allows ENCARSIA to handle complex conditional assignments with a unified injection approach.

Injection Approach (Table Representation)

ENCARSIA abstracts the multiplexer tree into a table representation. Each row maps a specific combination of select-signal values to the expression that the multiplexer tree root should assign in that case.

The tool injects realistic, complex transformations by performing simple operations on the table, such as removing or adding cases. This avoids the need to modify the circuit after each transformation. The transformations were derived from a survey of real bugs and are intended to model the subtle mistakes that designers actually make:

  • Removing a single row — models a designer forgetting to consider a special case.
  • Turning a select signal into X (don't-care) — models cases where designers place insufficient constraints on a case.
  • Turning a don't-care select signal into a specific value — models bugs where constraints are placed on cases mistakenly.

According to the authors, these transformations cover the entirety of the bugs in conditional logic that they revealed in their survey.

Reconstructing the Circuit

Once the table has been manipulated, it must be translated back into standard circuitry so the design can be simulated, instrumented, or otherwise analyzed by fuzzers. ENCARSIA achieves this by translating the table into a Yosys internal pmux cell — a many-input multiplexer that uses one-hot encoding (exactly one bit high per possible select value). Each row in the table becomes a possible case in the conditional assignment: the entry's assignment expression propagates exactly when the select-signal combination matches that row.

The construction proceeds as follows:

  1. Connect the row's expression to one of the inputs of the pmux.
  2. Generate the corresponding one-hot select bit by adding an eq cell that compares the table's select-signal combination against the actual select-signal value at runtime.
  3. Connect the pmux output back to the root wire that was originally driven by the multiplexer tree.

The Yosys backend that translates RTLIL back into Verilog then renders the pmux cell into a process that resembles the original conditional statement.

Survey Statistics

The ENCARSIA survey classified 177 relevant bug fixes across multiple open-source CPU designs. Broken conditionals accounted for 66 (37%) of these, distributed as follows:

Source Conditionals Mix-ups Total
Ibex 17 14 31
CVA6 22 11 33
Rocket 8 41 49
BOOM 13 33 46
HACK@DAC19 2 2 4
HACK@DAC21 4 10 14
Total 66 111 177

Relationship to Other Concepts

  • ENCARSIA — the CPU fuzzing evaluation framework that formally defines broken conditionals as one of two bug categories it models via automatic bug injection.
  • Signal mix-ups — the sibling bug category; bugs that change only the value assigned inside an existing conditional without altering any conditions are classified as signal mix-ups, not broken conditionals.
  • Yosys / RTLIL — the open synthesis suite whose intermediate representation (multiplexer trees, pmux cells, eq cells) ENCARSIA manipulates to inject broken-conditional bugs.

LINKED ENTITIES

1 links

CITATIONS

12 sources
12 citations
[1] Broken conditionals refer to issues arising from improper handling of exceptional cases or, e.g., operations allowed only in a specific privilege mode. Encarsia: Evaluating CPU Fuzzers via Automatic Bug Injection
[2] Yosys represents conditionals as multiplexer trees, a hierarchical arrangement of multiplexers where each level progressively narrows down the set of possible expressions assigned to the signal at the root of the tree. Encarsia: Evaluating CPU Fuzzers via Automatic Bug Injection
[3] In this representation, broken conditionals correspond to a potential branch missing from the multiplexer tree, or an incorrectly derived select signal that does not match the condition of the assignment. Encarsia: Evaluating CPU Fuzzers via Automatic Bug Injection
[4] ENCARSIA abstracts multiplexer trees into a table representation where the table maps specific select signal combinations to the corresponding expression chosen in that case. Encarsia: Evaluating CPU Fuzzers via Automatic Bug Injection
[5] Removing a single row from the table can model a designer forgetting to consider a special case. Encarsia: Evaluating CPU Fuzzers via Automatic Bug Injection
[6] Turning a select signal into an X (don't-care) can model cases where designers place insufficient constraints on a case; conversely turning a don't-care into a specific value models bugs where constraints are placed mistakenly. Encarsia: Evaluating CPU Fuzzers via Automatic Bug Injection
[7] These transformations cover the entirety of the bugs in conditional logic revealed in the survey. Encarsia: Evaluating CPU Fuzzers via Automatic Bug Injection
[8] ENCARSIA translates the manipulated table into a Yosys internal pmux cell (a many-input multiplexer using one-hot encoding) and uses eq cells to compare the table's select-signal combinations to runtime values. Encarsia: Evaluating CPU Fuzzers via Automatic Bug Injection
[9] Of 177 relevant bugs found in the survey, 111 (63%) were signal mix-ups and 66 (37%) were broken conditionals. Encarsia: Evaluating CPU Fuzzers via Automatic Bug Injection
[10] The survey reports broken-conditional counts per design: Ibex 17, CVA6 22, Rocket 8, BOOM 13, HACK@DAC19 2, HACK@DAC21 4. Encarsia: Evaluating CPU Fuzzers via Automatic Bug Injection
[11] Bugs affecting conditional assignments are classified as broken conditionals when they involve missing cases or incorrect conditions, exemplified by a forgotten nested conditional (like CVA6 PR #138) and a missing case in a switch statement (like BOOM PR #173). Encarsia: Evaluating CPU Fuzzers via Automatic Bug Injection
[12] Bugs that concern solely the conditionally assigned values but do not modify any conditions are classified as signal mix-ups rather than broken conditionals. Encarsia: Evaluating CPU Fuzzers via Automatic Bug Injection