Skip to content
STIMSMITH

Bit Operators in SCV Constraints

Concept WIKI v1 · 7/13/2026

Bit operators (bitwise and, bitwise or, bitwise not, bit-select, and slice-select) were not supported by the constraint solver in the SystemC Verification (SCV) Library. The Große/Ebendt/Drechsler paper introduces overloading of the relevant operators and new member functions in the scv_expression class so that bit operators can be used when specifying constraints, allowing more compact formulations of complex constraints that otherwise could not be expressed using only arithmetic, relational, and logical operators.

Bit Operators in SCV Constraints

Background

The SystemC Verification (SCV) Library provides constraint-based randomization for SystemC models. Internally, a constraint is represented by its characteristic function, which is true for all solutions of the constraint, and the characteristic function is stored as a reduced, ordered Binary Decision Diagram (BDD). The BDD package CUDD is used by the SCV library for this representation. Internally, an expression is held in the class scv_expression as an expression tree whose leaf nodes are variables or constants and whose non-terminal nodes are marked with operators. The constraint solver operates on individual bits when solving constraints.

Operator Support in the Original SCV Constraint Solver

The operators supported by the original SCV constraint solver were limited to:

  • Arithmetic operators: +, -, *
  • Relational operators: ==, !=, >, >=, <, <=
  • Logical operators: !, &&, ||

Bit operators were not part of this set. Because the SCV constraint solver works on individual bits, each bit operator has to be mapped to the corresponding BDD synthesis operations; for a bitwise AND, for example, the resulting bit vector is computed by the BDD-AND operation applied to each bit of the two input vectors. Several special cases (different vector lengths, different data types, and similar) must also be taken into account.

Bit Operators Added by the Improvements

The paper Improvements for Constraint Solving in the SystemC Verification Library addresses this gap by implementing the following bit operators so that verification engineers can write simpler and more compact constraints:

  1. Bitwise and: a() & b()
  2. Bitwise or: a() | b()
  3. Bitwise not: ~a()
  4. Bit-select: a()[i] for constant i
  5. Slice-select: a().range(x, y) for constant x and y

According to the authors, "bit operators are very important for the verification engineer during the specification of constraints. Bit operators allow for simpler and more compact formulations of complex constraints."

Implementation

The implementation was carried out in the scv_expression class:

  • The corresponding operators were overloaded.
  • New member functions were added to support the new operations.

Because the SCV library stores the internal representation of constraint expressions as an expression tree inside scv_expression, and constructs BDDs from that tree, overloading these operators in scv_expression is what makes the new bitwise and selection operations available inside the SCV_CONSTRAINT() macro.

Related Concepts

  • The paper introduces this concept as one of two main improvements to the SCV library; the second improvement is guaranteeing a uniform distribution of constraint solutions, which requires correcting the per-node probabilities computed during a pre-processing weighting traversal (the original solver only weights the initial BDD once and therefore fails to keep probabilities uniform after simplifications such as fixing variables to certain values).
  • scv_expression is the code artifact that implements the overloaded operators and new member functions that make bit operators usable inside SCV constraints.

See Also

CITATIONS

6 sources
6 citations
[1] The SCV constraint solver originally supported only arithmetic (+, -, *), relational (==, !=, >, >=, <, <=) and logical (!, &&, ||) operators and had no support for bit operators. Improvements for Constraint Solving in the SystemC Verification Library
[2] Five bit operators were added: bitwise and (a() & b()), bitwise or (a() | b()), bitwise not (~a()), bit-select (a()[i] for constant i), and slice-select (a().range(x,y) for constant x and y). Improvements for Constraint Solving in the SystemC Verification Library
[3] Bit operators allow simpler and more compact formulations of complex constraints that otherwise could not be expressed in such a simple and compact way. Improvements for Constraint Solving in the SystemC Verification Library
[4] The bit operators were implemented by overloading the corresponding operators and adding new member functions in the scv_expression class, which holds the expression tree (leaf nodes are variables or constants, non-terminal nodes are marked with operators) and is used for the BDD representation of an SCV expression. Improvements for Constraint Solving in the SystemC Verification Library
[5] The SCV constraint solver operates on individual bits, so each bit operator must be mapped to the corresponding BDD synthesis operation; for example, a bitwise AND is computed by applying the BDD-AND operation to each bit of the two input vectors, with special cases such as differing vector lengths and data types handled explicitly. Improvements for Constraint Solving in the SystemC Verification Library
[6] The paper introduces two main improvements to the SCV library: support for bit operators in constraints, and guaranteeing a uniform distribution of constraint solutions. Improvements for Constraint Solving in the SystemC Verification Library