dv-solve 0.2.3__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. dv_solve/__init__.py +253 -0
  2. dv_solve/__version__.py +42 -0
  3. dv_solve/_resolve.py +594 -0
  4. dv_solve/buffer_inference.py +181 -0
  5. dv_solve/builder.py +451 -0
  6. dv_solve/bvsat.py +235 -0
  7. dv_solve/ctx.py +483 -0
  8. dv_solve/dv_solve.dll +0 -0
  9. dv_solve/dv_solve.lib +0 -0
  10. dv_solve/dv_solve_debug.dll +0 -0
  11. dv_solve/dv_solve_debug.lib +0 -0
  12. dv_solve/dv_solve_dpi.dll +0 -0
  13. dv_solve/dv_solve_dpi.lib +0 -0
  14. dv_solve/flow_constraint_store.py +114 -0
  15. dv_solve/icl.py +96 -0
  16. dv_solve/lib.py +385 -0
  17. dv_solve/partitioner.py +119 -0
  18. dv_solve/problem.py +282 -0
  19. dv_solve/scheduling_graph.py +293 -0
  20. dv_solve/share/include/dv_solve/compat/win/msvc_compat.h +130 -0
  21. dv_solve/share/include/dv_solve/compat/win/sys/resource.h +26 -0
  22. dv_solve/share/include/dv_solve/compat/win/sys/time.h +25 -0
  23. dv_solve/share/include/dv_solve/compat/win/unistd.h +42 -0
  24. dv_solve/share/include/dv_solve/dv_solve.h +407 -0
  25. dv_solve/share/include/dv_solve/dvs_aig.h +107 -0
  26. dv_solve/share/include/dv_solve/dvs_aig_cnf.h +65 -0
  27. dv_solve/share/include/dv_solve/dvs_alloc.h +30 -0
  28. dv_solve/share/include/dv_solve/dvs_arena.h +110 -0
  29. dv_solve/share/include/dv_solve/dvs_bbsolver.h +289 -0
  30. dv_solve/share/include/dv_solve/dvs_bitblast.h +102 -0
  31. dv_solve/share/include/dv_solve/dvs_block_alloc.h +69 -0
  32. dv_solve/share/include/dv_solve/dvs_builder.h +199 -0
  33. dv_solve/share/include/dv_solve/dvs_bvbounds.h +116 -0
  34. dv_solve/share/include/dv_solve/dvs_bvdom.h +138 -0
  35. dv_solve/share/include/dv_solve/dvs_contradiction.h +173 -0
  36. dv_solve/share/include/dv_solve/dvs_costguided.h +238 -0
  37. dv_solve/share/include/dv_solve/dvs_ctx.h +411 -0
  38. dv_solve/share/include/dv_solve/dvs_cube.h +44 -0
  39. dv_solve/share/include/dv_solve/dvs_diffcycle.h +54 -0
  40. dv_solve/share/include/dv_solve/dvs_dpi.h +139 -0
  41. dv_solve/share/include/dv_solve/dvs_explain.h +134 -0
  42. dv_solve/share/include/dv_solve/dvs_i128.h +157 -0
  43. dv_solve/share/include/dv_solve/dvs_lcg.h +304 -0
  44. dv_solve/share/include/dv_solve/dvs_placement.h +157 -0
  45. dv_solve/share/include/dv_solve/dvs_pool.h +83 -0
  46. dv_solve/share/include/dv_solve/dvs_problem.h +514 -0
  47. dv_solve/share/include/dv_solve/dvs_propagator.h +561 -0
  48. dv_solve/share/include/dv_solve/dvs_sat.h +226 -0
  49. dv_solve/share/include/dv_solve/dvs_sat_backend.h +87 -0
  50. dv_solve/share/include/dv_solve/dvs_search.h +144 -0
  51. dv_solve/share/include/dv_solve/dvs_shave.h +31 -0
  52. dv_solve/share/include/dv_solve/dvs_stack.h +79 -0
  53. dv_solve/share/include/dv_solve/dvs_stackinfo.h +39 -0
  54. dv_solve/share/include/dv_solve/dvs_sv.h +105 -0
  55. dv_solve/share/include/dv_solve/dvs_thread.h +86 -0
  56. dv_solve/share/include/dv_solve/dvs_trail.h +146 -0
  57. dv_solve/share/include/dv_solve/dvs_variable.h +79 -0
  58. dv_solve/share/include/dv_solve/dvs_wiremask.h +81 -0
  59. dv_solve/share/include/dv_solve/smt2/smt2_frontend.h +620 -0
  60. dv_solve/share/include/dv_solve/smt2/smt2_lexer.h +106 -0
  61. dv_solve/share/include/dv_solve/smt2/smt2_parser.h +90 -0
  62. dv_solve/share/include/dv_solve/svdpi_compat.h +60 -0
  63. dv_solve/share/sv/dvs_dpi_pkg.sv +74 -0
  64. dv_solve/share/sv/dvs_randomizer_pkg.sv +76 -0
  65. dv_solve/state_graph.py +249 -0
  66. dv_solve/stream_solver.py +304 -0
  67. dv_solve/structural_solver.py +297 -0
  68. dv_solve-0.2.3.data/scripts/dv-solve-smt2.exe +0 -0
  69. dv_solve-0.2.3.dist-info/DELVEWHEEL +2 -0
  70. dv_solve-0.2.3.dist-info/METADATA +110 -0
  71. dv_solve-0.2.3.dist-info/RECORD +78 -0
  72. dv_solve-0.2.3.dist-info/WHEEL +5 -0
  73. dv_solve-0.2.3.dist-info/licenses/LICENSE +201 -0
  74. dv_solve-0.2.3.dist-info/top_level.txt +1 -0
  75. dv_solve.libs/.load-order-dv_solve-0.2.3 +3 -0
  76. dv_solve.libs/msvcp140.dll +0 -0
  77. dv_solve.libs/vcruntime140.dll +0 -0
  78. dv_solve.libs/vcruntime140_1.dll +0 -0
dv_solve/__init__.py ADDED
@@ -0,0 +1,253 @@
1
+ """""" # start delvewheel patch
2
+ def _delvewheel_patch_1_13_0():
3
+ import ctypes
4
+ import os
5
+ import platform
6
+ import sys
7
+ libs_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'dv_solve.libs'))
8
+ is_conda_cpython = platform.python_implementation() == 'CPython' and (hasattr(ctypes.pythonapi, 'Anaconda_GetVersion') or 'packaged by conda-forge' in sys.version)
9
+ if sys.version_info[:2] >= (3, 8) and not is_conda_cpython or sys.version_info[:2] >= (3, 10):
10
+ if os.path.isdir(libs_dir):
11
+ os.add_dll_directory(libs_dir)
12
+ else:
13
+ load_order_filepath = os.path.join(libs_dir, '.load-order-dv_solve-0.2.3')
14
+ if os.path.isfile(load_order_filepath):
15
+ import ctypes.wintypes
16
+ with open(os.path.join(libs_dir, '.load-order-dv_solve-0.2.3')) as file:
17
+ load_order = file.read().split()
18
+ kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
19
+ kernel32.LoadLibraryExW.restype = ctypes.wintypes.HMODULE
20
+ kernel32.LoadLibraryExW.argtypes = ctypes.wintypes.LPCWSTR, ctypes.wintypes.HANDLE, ctypes.wintypes.DWORD
21
+ for lib in load_order:
22
+ lib_path = os.path.join(os.path.join(libs_dir, lib))
23
+ if os.path.isfile(lib_path) and not kernel32.LoadLibraryExW(lib_path, None, 8):
24
+ raise OSError('Error loading {}; {}'.format(lib, ctypes.FormatError(ctypes.get_last_error())))
25
+
26
+
27
+ _delvewheel_patch_1_13_0()
28
+ del _delvewheel_patch_1_13_0
29
+ # end delvewheel patch
30
+
31
+ import os
32
+ import platform
33
+
34
+ from . import _resolve
35
+
36
+ # The same file setup.py exec()s to supply the wheel's version, so an
37
+ # installed dv_solve and its distribution metadata cannot disagree. Importing
38
+ # it here is safe: the constraint that ruled out a dynamic attr: is a
39
+ # BUILD-time one (the package is not importable while the wheel is being
40
+ # built), and by the time this runs the package is installed.
41
+ from .__version__ import _pkg_version as __version__
42
+
43
+
44
+ def _pkg_dir():
45
+ # Delegated so that ``_resolve`` is the ONE place either location is
46
+ # decided. Keeping a second copy here meant the fallback paths below could
47
+ # name a different installation than the search itself had considered.
48
+ return _resolve._pkg_dir()
49
+
50
+
51
+ def _src_root():
52
+ # packages/dv-solve/ (up from src/dv_solve/) in a source tree.
53
+ return _resolve._src_root()
54
+
55
+
56
+ def get_libs():
57
+ """Names of the libraries a C consumer links against."""
58
+ return ["dv_solve"]
59
+
60
+
61
+ def _lib_filename(stem):
62
+ """The platform's file name for shared library *stem* (no directory)."""
63
+ return _resolve.lib_filename(stem)
64
+
65
+
66
+ def _lib_search_dirs():
67
+ """Every directory a dv-solve shared library may live in, best first.
68
+
69
+ Now just the shared contract in :mod:`dv_solve._resolve`. This list used to
70
+ be maintained here independently of the ctypes loader's, and the two had
71
+ drifted: the loader also honoured ``DVS_SOLVER_PATH``, the package's
72
+ ``lib/`` subdirectory and three alternate build-directory names, none of
73
+ which this function knew about. On a host using any of them the solver ran
74
+ out of one installation and generated C linked against another.
75
+ """
76
+ return _resolve.lib_search_dirs()
77
+
78
+
79
+ def get_libdirs():
80
+ """Directories containing the dv-solve shared libraries.
81
+
82
+ Returning only the package directory described a layout a *source tree* does
83
+ not have, so a consumer that compiled against a checkout failed to link:
84
+
85
+ /usr/bin/ld: cannot find -ldv_solve
86
+
87
+ which is how pssc's generated ``libpssc_scenario.so`` failed once dv-solve
88
+ was installed editable rather than from a wheel. The same reasoning, and the
89
+ same fix, as ``get_incdirs()`` -- see its docstring.
90
+
91
+ Probes for the library rather than the directory: in a source tree
92
+ ``build/lib`` exists as soon as CMake configures, well before anything is
93
+ linked into it.
94
+
95
+ Only the UNVERSIONED library name counts here, because that is the one
96
+ ``-ldv_solve`` resolves. It is sought in the SAME installation the ctypes
97
+ loader opens (see :mod:`dv_solve._resolve`). If that installation holds
98
+ only ``libdv_solve.so.1`` -- loadable, not linkable -- this raises
99
+ ``RuntimeError`` naming it. It used to carry on searching and report a
100
+ different installation's library, so the Python API ran one solver build
101
+ while generated C linked another.
102
+
103
+ Raises ``RuntimeError`` likewise when ``DVS_SOLVER_PATH`` is set but holds
104
+ no library: an explicit override is never silently replaced.
105
+ """
106
+ if _resolve.select_installation() is not None:
107
+ return [os.path.dirname(_resolve.require_library("dv_solve",
108
+ linkable=True))]
109
+ # Nothing built anywhere. The package directory is the installed-wheel
110
+ # answer and keeps the failure identical to what a missing wheel library
111
+ # already produces, rather than naming a build tree that does not exist.
112
+ return [_pkg_dir()]
113
+
114
+
115
+ def get_deps():
116
+ return []
117
+
118
+
119
+ def get_incdirs():
120
+ """Directories containing the public dv-solve C headers.
121
+
122
+ The wheel case returns BOTH ``share/include`` and ``share/include/dv_solve``
123
+ because the two trees disagree on layout and only the nested one actually
124
+ holds headers:
125
+
126
+ * source tree -- headers sit FLAT in ``src/c``, so ``#include
127
+ "dvs_ctx.h"`` resolves;
128
+ * installed wheel -- CMake puts them in ``include/dv_solve``
129
+ (CMakeLists.txt: ``DESTINATION include/dv_solve``), so that same
130
+ unqualified include does NOT resolve against the base directory, and
131
+ the base directory on its own contains no headers at all.
132
+
133
+ Returning only the base therefore described a layout the wheel does not
134
+ have. A consumer following this API could compile against a checkout and
135
+ then fail against the released wheel with
136
+
137
+ fatal error: dvs_block_alloc.h: No such file or directory
138
+
139
+ which is exactly how pssc's generated ``pssc_solve.c`` fails, since it emits
140
+ unqualified includes.
141
+
142
+ NOTE ON NAMESPACING: these headers are installed under ``dv_solve/`` so
143
+ they cannot shadow another project's headers of the same name. Before the
144
+ ``dvs_`` prefix, dv-solve and zuspec-be-sw both shipped a ``zsp_alloc.h``
145
+ defining ``struct zsp_alloc_s`` incompatibly; the prefix removes that clash,
146
+ and the install layout keeps internal header names out of a consumer's
147
+ include path.
148
+
149
+ Probes for an actual header rather than testing ``isdir``. A staging bug
150
+ that creates ``share/include`` but populates nothing under it used to pass
151
+ the directory test and then fail deep inside a consumer's compile.
152
+
153
+ Taken from the installation the solver library is loaded from; raises
154
+ ``RuntimeError`` if that installation has no headers rather than pairing
155
+ its library with another installation's headers.
156
+ """
157
+ if _resolve.select_installation() is not None:
158
+ return _resolve.require_incdirs()
159
+ found = _resolve.find_incdirs()
160
+ if found is not None:
161
+ return found
162
+ # Nothing found: name the installed-wheel location, so the failure is the
163
+ # same "no headers here" a missing wheel already produces.
164
+ return [os.path.join(_pkg_dir(), "share", "include")]
165
+
166
+
167
+ def get_svdirs():
168
+ """SystemVerilog package search dir (dvs_dpi_pkg.sv, dvs_randomizer_pkg.sv).
169
+
170
+ From the selected installation, like :func:`get_incdirs`; raises
171
+ ``RuntimeError`` if that installation has none.
172
+ """
173
+ if _resolve.select_installation() is not None:
174
+ return _resolve.require_svdirs()
175
+ found = _resolve.find_svdirs()
176
+ if found is not None:
177
+ return found
178
+ return [os.path.join(_pkg_dir(), "share", "sv")]
179
+
180
+
181
+ def get_dpi_lib():
182
+ """Absolute path to the DPI shared library for an SV simulator's -sv_lib.
183
+
184
+ Searches the same places as :func:`get_libdirs` -- this library is staged
185
+ into the wheel alongside ``libdv_solve`` and built into the same
186
+ ``build/<libdir>`` in a checkout, so it had the same source-tree gap.
187
+
188
+ Resolved by its OWN filename rather than by appending to whatever directory
189
+ the core library was found in: the two are staged together today, but a
190
+ ``-sv_lib`` pointed at a path that merely ought to exist fails inside the
191
+ simulator's elaborator, a long way from anything that names dv-solve.
192
+
193
+ Taken from the installation the core library is loaded from, never from
194
+ another one: the DPI shim calls into the core library and must match it.
195
+ Raises ``RuntimeError`` if that installation has no DPI library.
196
+ """
197
+ if _resolve.select_installation() is not None:
198
+ return _resolve.require_library("dv_solve_dpi")
199
+ return os.path.join(_pkg_dir(), _lib_filename("dv_solve_dpi"))
200
+
201
+
202
+ def get_smt2_exe():
203
+ """Absolute path to the ``dv-solve-smt2`` SMT-LIB2 command-line tool.
204
+
205
+ The wheel installs it into the environment's scripts directory, so in an
206
+ activated environment it is also simply ``dv-solve-smt2`` on PATH. Use
207
+ this when PATH may hold a different copy, or when the environment is not
208
+ activated (for example, to set ``VERILATOR_SOLVER`` from a script).
209
+
210
+ Order: ``DVS_SOLVER_PATH`` (alone, when set), this package's own wheel
211
+ install, a built source checkout (``build/bin``, then ``build``), PATH.
212
+ The tool is statically linked, so any copy found is self-contained.
213
+
214
+ Raises ``RuntimeError`` naming every location searched when none is found
215
+ -- always the case on Windows today, whose wheel does not include it.
216
+ """
217
+ return _resolve.require_smt2_exe()
218
+
219
+
220
+ def resolve_report():
221
+ """What this installation actually resolved to, for diagnostics.
222
+
223
+ Deployment problems in this area are all of the form "which installation
224
+ did it pick?", and answering that from the outside means replicating the
225
+ search. Returns a dict of plain strings/lists, safe to print or assert on.
226
+
227
+ Never raises: an artifact the selected installation lacks is ``None``
228
+ here, with the reason under ``errors``.
229
+ """
230
+ inst = _resolve.select_installation()
231
+ errors = {}
232
+ for key, fn in (("link_dirs", get_libdirs), ("dpi_lib", get_dpi_lib),
233
+ ("incdirs", get_incdirs), ("svdirs", get_svdirs),
234
+ ("smt2_exe", get_smt2_exe)):
235
+ try:
236
+ fn()
237
+ except RuntimeError as e:
238
+ errors[key] = str(e)
239
+ link = _resolve.find_library("dv_solve", linkable=True)
240
+ return {
241
+ "package_dir": _pkg_dir(),
242
+ "override": _resolve.override_root(),
243
+ "search_dirs": list(_lib_search_dirs()),
244
+ "installation": ({"kind": inst.kind, "root": inst.root}
245
+ if inst is not None else None),
246
+ "core_lib": _resolve.find_library("dv_solve"),
247
+ "link_dirs": [os.path.dirname(link)] if link else None,
248
+ "dpi_lib": _resolve.find_library("dv_solve_dpi"),
249
+ "incdirs": _resolve.find_incdirs(),
250
+ "svdirs": _resolve.find_svdirs(),
251
+ "smt2_exe": _resolve.find_smt2_exe(),
252
+ "errors": errors,
253
+ }
@@ -0,0 +1,42 @@
1
+ #****************************************************************************
2
+ # Copyright 2019-2025 Matthew Ballance and contributors
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #****************************************************************************
16
+
17
+ # The single source of this package's version, following the same shape as
18
+ # pssparser's python/pssparser/__version__.py.
19
+ #
20
+ # BASE is the released version and is what a `v<BASE>` tag must match; the
21
+ # publish job in .github/workflows/wheels.yml rejects a tag that disagrees
22
+ # with it. SUFFIX is rewritten by CI for non-release builds so a development
23
+ # wheel can never collide with a release.
24
+ #
25
+ # 0.1.0 rather than 0.0.1: PyPI already holds run-id-stamped dev releases of
26
+ # sibling packages numbered 0.0.1.<run-id>, which sort ABOVE a bare 0.0.1.
27
+ # The estate moves to 0.1.0 so that a real release outranks that stream.
28
+
29
+ BASE = "0.2.3"
30
+ SUFFIX = ""
31
+
32
+ __version__ = (BASE, SUFFIX)
33
+
34
+ # Read by setup.py for dynamic versioning. setup.py exec()s THIS FILE rather
35
+ # than importing the package, which is the whole point of the arrangement:
36
+ # a `[tool.setuptools.dynamic] version = {attr = ...}` was tried first and
37
+ # reverted, because setuptools can only read an attr: statically when it is a
38
+ # literal. BASE + SUFFIX is computed, so setuptools fell back to IMPORTING
39
+ # dv_solve -- and the package is not importable during
40
+ # get_requires_for_build_wheel under the ivpm_build backend. That failed only
41
+ # inside the manylinux container, not under a local `uv build`.
42
+ _pkg_version = BASE + SUFFIX