Overview
Constraint-based random simulation is a state-of-the-art technique for verifying multi-million gate industrial designs. Stimuli are generated directly from constraints by a constraint solver, which selects stimulus patterns that satisfy the specified constraints. This approach is valuable because it covers corner case test scenarios that are usually hard to identify manually by the verification engineer, increasing the quality of design verification significantly.
However, when the verification engineer specifies constraints for a specific test scenario, the overall constraint may have no solution. This situation is called a constraint contradiction (equivalently referred to as over-constraining). When a contradiction occurs in a constraint-based random simulation run, the run has to be terminated because no valid stimulus patterns can be applied.
Definition
Formally, an overall constraint C — typically built as a conjunction of individual constraints using mechanisms such as SCV_CONSTRAINT() macros or inheritance from base classes — is contradictory iff it is not satisfiable, i.e., C evaluates to 0 for all assignments to the constraint variables:
C = ∧(i=0 to n-1) C_i is contradictory iff C is not satisfiable.
The same conjunction-based construction of overall constraints is found in SystemVerilog random constraints, so the contradiction problem is not specific to any one testbench library.
Causes and Manifestation
A constraint contradiction does not necessarily occur at the very beginning of a simulation run. Modern testbench languages such as SystemVerilog allow the addition of constraints dynamically during simulation, so over-constraining can surface later in a run. When it does, possible root causes include:
- A single self-contradicting constraint (an individual C_i that is itself unsatisfiable).
- Conflicting combinations of multiple constraints that are individually satisfiable but collectively unsatisfiable.
Identifying which case applies is typically very time-consuming given the complexity of constraints used to describe real test scenarios.
Impact and Traditional Debugging
Whenever a contradiction occurs, the verification engineer must identify its root cause and resolve it. In conventional practice this is done manually, by either code inspection or trial-and-error debugging. Both approaches are tedious and time-consuming, particularly because the engineer must reason about the joint behavior of many constraints at once.
Automated Contradiction Analysis
To alleviate manual debugging, fully automated contradiction analysis techniques have been proposed. The general approach works as follows:
- Reformulation. The overall constraint is reformulated so that potentially contradicting constraints can be disabled by introducing new free variables.
- Abstraction. An abstraction is computed that forms the basis for the subsequent analysis.
- Self-contradiction detection. Self-contradicting constraints are identified.
- Relevance filtering. All "non relevant" constraints (those that do not contribute to the contradiction) are determined.
- Minimal-reason enumeration. For the remaining constraints — typically only a very small set — a detailed analysis is performed that computes all minimal constraint combinations leading to the contradiction.
This pinpoints the verification engineer to exactly the sets of constraints that must be reconsidered to resolve the over-constraining, so that contradictions can often be resolved in a single step.
Practical Setting
Contradiction analysis has been demonstrated in a real-life SystemC-based verification environment using the SystemC Verification (SCV) library — an open source C++ class library introduced in 2002 on top of SystemC. Experiments conducted in this environment at the AMD Dresden Design Center showed a significant reduction of constraint debugging time.
Related Concept
The notion of a constraint contradiction is closely tied to the broader concept of over-constraining, which refers generally to any situation in which a constraint solver cannot find a valid solution for a given set of constraints. A constraint contradiction is the concrete state that results from over-constraining, and automated contradiction analysis is the principal technique used to diagnose it.