dv-solve
dv-solve is a constraint solver for design verification. It finds values for
bit-vector variables that satisfy a set of constraints, and when asked for many
solutions it spreads them across the solution space. That suits it both to
constrained-random stimulus generation and to answering yes/no questions from
formal tools. Answers are sound: sat and unsat are definitive, and when
dv-solve can't decide a problem it says unknown rather than guessing.
Documentation: https://dvkit.org/fvutils/dv-solve/
Ways to use it
| If you are... | Use | Start here |
|---|---|---|
| Building constraint problems from Python | the dv_solve package |
Python quick start |
| Running SMT-LIB2 files, or plugging a solver into a tool that speaks SMT-LIB2 | the dv-solve-smt2 executable |
SMT-LIB2 quick start |
| Randomizing SystemVerilog classes in Verilator | dv-solve-smt2 as Verilator's constraint solver |
Verilator quick start |
| Randomizing from SystemVerilog through DPI, on any simulator | dvs_dpi_pkg and libdv_solve_dpi |
DPI guide |
| Embedding the solver in a C or C++ program | libdv_solve and dv_solve.h |
C API |
Install
pip install dv-solve
The wheel holds the Python package, the native libraries, the C header and the
SystemVerilog packages. dv-solve-smt2 comes from a source build:
cmake -S . -B build -DDVS_WITH_CADICAL=OFF
cmake --build build
See Installation for the details, including the optional CaDiCaL back end.
To develop in a checkout, set up the workspace with IVPM and build in place:
ivpm update -d dev
packages/python/bin/python setup.py build_ext --inplace
That fetches CaDiCaL and the Python environment into packages/, then builds
the libraries into build/lib and dv-solve-smt2 into build/bin. The
dv_solve package in src/ loads the library from build/lib.
Quick start
from dv_solve.builder import SolveProblemBuilder
from dv_solve.ctx import SolveCtx, SOLVE_OK
from dv_solve.problem import BIN_GT
b = SolveProblemBuilder()
X = 0
b.add_var(X, width=8, is_signed=False, lo=0, hi=255)
b.add_constraint(b.expr_binary(BIN_GT, b.expr_var(X), b.expr_const(100)))
problem, _ = b.finalize()
with SolveCtx(problem) as ctx:
assert ctx.solve(seed=1, fair_pick=True) == SOLVE_OK
print("x =", ctx.get_value(X))
Public API
| Module | Purpose |
|---|---|
dv_solve.builder |
SolveProblemBuilder: declare variables and constraints |
dv_solve.ctx |
SolveCtx: compile and solve; status codes and exceptions |
dv_solve.problem |
operator constants (BIN_*, UN_*) |
dv_solve |
get_libs(), get_libdirs(), get_incdirs(), get_svdirs(), get_dpi_lib() for build systems |
Other modules are internal and may change. The C API is the one header
dv_solve.h; other installed headers are internal. See the
reference.
License
Apache-2.0.
Metadata
Release files for dv-solve 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dv_solve-0.2.2-py3-none-manylinux_2_34_x86_64.whl | Python 3 | none | Linux glibc 2.34+ x86-64 | Details |
| dv_solve-0.2.2-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 | Details |
Total release size: 6.7 MB
Release files / dv_solve-0.2.2-py3-none-manylinux_2_34_x86_64.whl
| Download URL | dv_solve-0.2.2-py3-none-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | Linux glibc 2.34+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
ed9b6e1c8ff45f520ced491a397bb4c959e62ceb05e00042daaf512f51f04416
|
|
BLAKE2b-256 checksum How to use checksums |
29214bfac9241e77f26b9e67b2bcec8119b91556fd90f13e43004e1d1ead466a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / dv_solve-0.2.2-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | dv_solve-0.2.2-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
d0ba4d817e67449dcf559cf498360ef5c954a2ee3a9b41d3e5f83570d5790b94
|
|
BLAKE2b-256 checksum How to use checksums |
aa7f2d2ccd58b6bc2c99c38d8c943e5223050bb5078fdc453ce8eb31cb4a02d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|