Overview
blackbox ALU is a configuration option of the riscv-formal framework. It instructs the formal verification environment to hide (black-box) the arithmetic logic unit of the processor core under test when the goal of the check is to verify properties about the stream of retired instructions rather than the exact arithmetic results.
This is useful because reasoning about concrete ALU behavior can be a major source of complexity for the solver. By black-boxing the ALU, the formal engine only needs to establish consistency properties (for example, that retired instructions agree with the register file state) without having to prove the correctness of the ALU's internal computations.
How it is enabled
The behavior is controlled by the presence or absence of the blackbox option in the riscv-formal configuration. When enabled, the C preprocessor macro RISCV_FORMAL_BLACKBOX_ALU is defined and may be used inside the core-under-test source to conditionally hide the ALU.
When it is used
According to the riscv-formal documentation, the RISCV_FORMAL_BLACKBOX_ALU macro is intended for checks that operate on the consistency of the stream of retired instructions, such as the regcheck check. It is not meant for checks that must reason about the actual computed values produced by the ALU.
This contrasts with RISCV_FORMAL_BLACKBOX_REGS, which is used when checking for correct implementation of individual RISC-V instructions (the insncheck) and abstracts the register file instead of the ALU.
Practical implications
- Solver simplicity. Hiding the ALU reduces the internal state the formal tool must track during instruction-stream checks.
- Scope of verification. A black-boxed ALU check can confirm that the architectural contract of the retired instruction stream holds, without proving that the ALU computes the correct arithmetic result. To verify ALU correctness, ALU-internal checks (without
RISCV_FORMAL_BLACKBOX_ALU) are required. - Core-side integration. The core under test must conditionally compile the ALU out (or otherwise hide it from the formal tool) whenever
RISCV_FORMAL_BLACKBOX_ALUis defined.
Related configuration knobs in riscv-formal
The blackbox ALU option sits alongside other macros in the riscv-formal configuration system:
RISCV_FORMAL_BLACKBOX_REGS— black-boxes the register file for instruction-level checks (insncheck).RISCV_FORMAL_COMPRESSED— indicates support for the RISC-V Compressed ISA.RISCV_FORMAL_FAIRNESS— enables fairness guarantees needed for liveness checks.RISCV_FORMAL_INSN_MODEL— names the per-instruction model module used byinsnchecks.RISCV_FORMAL_CHECKER— names the checker module instantiated by the testbench.RISCV_FORMAL_RESET_CYCLES,RISCV_FORMAL_CHECK_CYCLE,RISCV_FORMAL_TRIG_CYCLE,RISCV_FORMAL_CHANNEL_IDX— control the timing and targeting of checks.RISCV_FORMAL_UNBOUNDED— signals unbounded model checking.RISCV_FORMAL_ASSUME— pulls in a user-providedassume_stmts.vhof SystemVerilog assumptions.- CSR-related macros (
RISCV_FORMAL_CSR_<name>,RISCV_FORMAL_CSRW_NAME,RISCV_FORMAL_CSRWH) for routing CSR state over RVFI.
See also
- riscv-formal (the framework that defines and consumes the
RISCV_FORMAL_BLACKBOX_ALUmacro)