Skip to content
STIMSMITH

ALU Constraint Verification

Concept WIKI v1 · 7/2/2026

ALU Constraint Verification refers to the use of constrained-random verification techniques to model and check the behavior of an Arithmetic Logic Unit (ALU) at various operand bit widths. It is presented in the CRAVE framework as a benchmark demonstrating how constraint solvers scale (or fail to scale) with ALU width, and is used comparatively against the SystemC Verification (SCV) library.

Overview

ALU Constraint Verification describes the application of declarative, constraint-based modeling to an Arithmetic Logic Unit (ALU) design, in order to automatically generate stimulus vectors that respect the ALU's operational semantics. In the CRAVE constrained-random verification framework, the ALU is encoded as a randomized object whose fields — an opcode and two operands — are bound by conditional constraints that express valid ALU behavior for each supported operation.

CRAVE ALU Encoding (16-bit example)

The canonical illustration is the 16-bit ALU model shown in Figure 7 of the CRAVE paper. It declares an opcode op of type sc_bv<2> and two operands a and b of type sc_uint<16>. For each of the four opcode values, an implication-style constraint restricts the operand ranges or relations so that the arithmetic is well-defined (no overflow for addition, subtraction, and multiplication, and a non-zero divisor for the division-like operation):

  • op == 0: 65535 >= a() + b() (overflow-free addition)
  • op == 1: 65535 >= a() - b() and b() <= a() (overflow-free subtraction with a >= b)
  • op == 2: 65535 >= a() * b() (overflow-free multiplication)
  • op == 3: b() != 0 (non-zero divisor)

The pattern uses IF_THEN to make these constraints conditional on the opcode, allowing the same randomized object to cover all ALU operations.

Scalability Across ALU Bit Widths

The CRAVE paper reports a direct comparison of CRAVE against the SCV library for ALU widths of 4, 12, 16, 24, and 32 bits. The reported run-times (in seconds) are:

Library Phase ALU4 ALU12 ALU16 ALU24 ALU32
SCV first <0.01 13.77 MO TO TO
SCV finished 0.09 19.84 MO TO TO
CRAVE first <0.01 <0.01 0.01 0.01 0.01
CRAVE finished 0.14 0.30 0.37 0.40 0.49

(TO denotes time-out; MO denotes memory-out.)

As the bit width grows, SCV fails to solve the ALU constraints — at ALU16 it already hits its 32-bit memory restriction (a BDD representation that must encode every solution path is required to give each solution equal probability), while CRAVE continues to scale using its SMT-based backend, generating stimuli before the BDD is ready. This contrast is the central empirical claim of the ALU experiment in CRAVE.

Verification Implications

ALU Constraint Verification in this style demonstrates that:

  1. ALU semantics can be expressed compactly as conditional constraints on opcode and operands.
  2. Constraint solvers vary significantly in their ability to handle wide-integer arithmetic, with BDD-based approaches exhausting memory at modest widths and SMT-based approaches remaining tractable.
  3. CRAVE exposes multiple solver backends (Z3, Boolector, MiniSAT, PicoSAT, CUDD, AIGER, SWORD), enabling the ALU benchmark to be run across engines to compare performance.

CITATIONS

4 sources
4 citations
[1] The 16-bit ALU is encoded in CRAVE with a 2-bit opcode `op` and two 16-bit operands `a` and `b`, with overflow-free constraints for add/sub/mul and a non-zero-divisor constraint for division, expressed via `IF_THEN` implications. CRAVE: An Advanced Constrained RAndom Verification Environment for SystemC
[2] A scalability comparison (Table III) reports that SCV fails with MO at ALU16 and TO at ALU24/ALU32, while CRAVE completes all ALU widths up to ALU32 with sub-second first-solution times and finished times of 0.14–0.49 seconds. CRAVE: An Advanced Constrained RAndom Verification Environment for SystemC
[3] SCV's failure at ALU16 is attributed to a 32-bit memory restriction caused by representing all solutions as a BDD in order to give each solution equal probability via weighted paths in a reduced ordered BDD. CRAVE: An Advanced Constrained RAndom Verification Environment for SystemC
[4] CRAVE's backend exposes multiple constraint solvers including SWORD, Z3, Boolector, MiniSAT, PicoSAT, CUDD, and AIGER, against which ALU constraint models can be evaluated. CRAVE: An Advanced Constrained RAndom Verification Environment for SystemC