cocotb 1.9.2__cp313-cp313-win_amd64.whl → 2.0.0b1__cp313-cp313-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.
Potentially problematic release.
This version of cocotb might be problematic. Click here for more details.
- cocotb/{ANSI.py → _ANSI.py} +5 -25
- cocotb/__init__.py +76 -332
- cocotb/_base_triggers.py +513 -0
- cocotb/_bridge.py +187 -0
- cocotb/_decorators.py +515 -0
- cocotb/_deprecation.py +3 -3
- cocotb/_exceptions.py +7 -0
- cocotb/_extended_awaitables.py +419 -0
- cocotb/_gpi_triggers.py +382 -0
- cocotb/_init.py +295 -0
- cocotb/_outcomes.py +54 -0
- cocotb/_profiling.py +46 -0
- cocotb/_py_compat.py +100 -29
- cocotb/_scheduler.py +454 -0
- cocotb/_test.py +245 -0
- cocotb/_test_factory.py +309 -0
- cocotb/_test_functions.py +42 -0
- cocotb/_typing.py +7 -0
- cocotb/_utils.py +296 -0
- cocotb/_version.py +3 -7
- cocotb/_xunit_reporter.py +66 -0
- cocotb/clock.py +271 -108
- cocotb/handle.py +1342 -795
- cocotb/libs/cocotb.dll +0 -0
- cocotb/libs/cocotb.exp +0 -0
- cocotb/libs/cocotb.lib +0 -0
- cocotb/libs/cocotbfli_modelsim.dll +0 -0
- cocotb/libs/cocotbfli_modelsim.exp +0 -0
- cocotb/libs/cocotbfli_modelsim.lib +0 -0
- cocotb/libs/cocotbutils.dll +0 -0
- cocotb/libs/cocotbutils.exp +0 -0
- cocotb/libs/cocotbutils.lib +0 -0
- cocotb/libs/cocotbvhpi_aldec.dll +0 -0
- cocotb/libs/cocotbvhpi_aldec.exp +0 -0
- cocotb/libs/cocotbvhpi_aldec.lib +0 -0
- cocotb/libs/cocotbvhpi_modelsim.dll +0 -0
- cocotb/libs/cocotbvhpi_modelsim.exp +0 -0
- cocotb/libs/cocotbvhpi_modelsim.lib +0 -0
- cocotb/libs/cocotbvpi_aldec.dll +0 -0
- cocotb/libs/cocotbvpi_aldec.exp +0 -0
- cocotb/libs/cocotbvpi_aldec.lib +0 -0
- cocotb/libs/cocotbvpi_ghdl.dll +0 -0
- cocotb/libs/cocotbvpi_ghdl.exp +0 -0
- cocotb/libs/cocotbvpi_ghdl.lib +0 -0
- cocotb/libs/cocotbvpi_icarus.exp +0 -0
- cocotb/libs/cocotbvpi_icarus.lib +0 -0
- cocotb/libs/cocotbvpi_icarus.vpl +0 -0
- cocotb/libs/cocotbvpi_modelsim.dll +0 -0
- cocotb/libs/cocotbvpi_modelsim.exp +0 -0
- cocotb/libs/cocotbvpi_modelsim.lib +0 -0
- cocotb/libs/embed.dll +0 -0
- cocotb/libs/embed.exp +0 -0
- cocotb/libs/embed.lib +0 -0
- cocotb/libs/gpi.dll +0 -0
- cocotb/libs/gpi.exp +0 -0
- cocotb/libs/gpi.lib +0 -0
- cocotb/libs/gpilog.dll +0 -0
- cocotb/libs/gpilog.exp +0 -0
- cocotb/libs/gpilog.lib +0 -0
- cocotb/libs/pygpilog.dll +0 -0
- cocotb/libs/pygpilog.exp +0 -0
- cocotb/libs/pygpilog.lib +0 -0
- cocotb/{log.py → logging.py} +105 -110
- cocotb/queue.py +103 -57
- cocotb/regression.py +667 -712
- cocotb/result.py +17 -188
- cocotb/share/def/aldec.exp +0 -0
- cocotb/share/def/aldec.lib +0 -0
- cocotb/share/def/ghdl.exp +0 -0
- cocotb/share/def/ghdl.lib +0 -0
- cocotb/share/def/icarus.exp +0 -0
- cocotb/share/def/icarus.lib +0 -0
- cocotb/share/def/modelsim.def +1 -0
- cocotb/share/def/modelsim.exp +0 -0
- cocotb/share/def/modelsim.lib +0 -0
- cocotb/share/include/cocotb_utils.h +6 -29
- cocotb/share/include/embed.h +5 -28
- cocotb/share/include/gpi.h +137 -92
- cocotb/share/include/gpi_logging.h +221 -142
- cocotb/share/include/py_gpi_logging.h +7 -4
- cocotb/share/include/vpi_user_ext.h +4 -26
- cocotb/share/lib/verilator/verilator.cpp +59 -54
- cocotb/simulator.cp313-win_amd64.exp +0 -0
- cocotb/simulator.cp313-win_amd64.lib +0 -0
- cocotb/simulator.cp313-win_amd64.pyd +0 -0
- cocotb/simulator.pyi +107 -0
- cocotb/task.py +434 -212
- cocotb/triggers.py +55 -1092
- cocotb/types/__init__.py +25 -47
- cocotb/types/_abstract_array.py +151 -0
- cocotb/types/_array.py +264 -0
- cocotb/types/_logic.py +296 -0
- cocotb/types/_logic_array.py +834 -0
- cocotb/types/{range.py → _range.py} +36 -44
- cocotb/types/_resolve.py +76 -0
- cocotb/utils.py +119 -587
- cocotb-2.0.0b1.dist-info/METADATA +60 -0
- cocotb-2.0.0b1.dist-info/RECORD +143 -0
- {cocotb-1.9.2.dist-info → cocotb-2.0.0b1.dist-info}/WHEEL +1 -1
- cocotb-2.0.0b1.dist-info/entry_points.txt +2 -0
- {cocotb-1.9.2.dist-info → cocotb-2.0.0b1.dist-info}/top_level.txt +1 -0
- cocotb_tools/__init__.py +0 -0
- cocotb_tools/_coverage.py +33 -0
- cocotb_tools/_vendor/__init__.py +3 -0
- cocotb_tools/check_results.py +65 -0
- cocotb_tools/combine_results.py +152 -0
- cocotb_tools/config.py +241 -0
- {cocotb → cocotb_tools}/ipython_support.py +29 -22
- cocotb_tools/makefiles/Makefile.deprecations +27 -0
- {cocotb/share → cocotb_tools}/makefiles/Makefile.inc +82 -54
- {cocotb/share → cocotb_tools}/makefiles/Makefile.sim +8 -33
- {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.activehdl +9 -16
- cocotb_tools/makefiles/simulators/Makefile.cvc +61 -0
- cocotb_tools/makefiles/simulators/Makefile.dsim +39 -0
- {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.ghdl +13 -42
- cocotb_tools/makefiles/simulators/Makefile.icarus +80 -0
- cocotb_tools/makefiles/simulators/Makefile.ius +93 -0
- cocotb_tools/makefiles/simulators/Makefile.modelsim +9 -0
- cocotb_tools/makefiles/simulators/Makefile.nvc +60 -0
- cocotb_tools/makefiles/simulators/Makefile.questa +29 -0
- cocotb/share/makefiles/simulators/Makefile.questa → cocotb_tools/makefiles/simulators/Makefile.questa-compat +26 -54
- cocotb_tools/makefiles/simulators/Makefile.questa-qisqrun +149 -0
- {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.riviera +17 -56
- cocotb_tools/makefiles/simulators/Makefile.vcs +65 -0
- {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.verilator +15 -22
- {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.xcelium +20 -52
- cocotb_tools/py.typed +0 -0
- {cocotb → cocotb_tools}/runner.py +794 -361
- cocotb/_sim_versions.py → cocotb_tools/sim_versions.py +16 -21
- pygpi/entry.py +34 -17
- pygpi/py.typed +0 -0
- cocotb/binary.py +0 -858
- cocotb/config.py +0 -289
- cocotb/decorators.py +0 -332
- cocotb/memdebug.py +0 -35
- cocotb/outcomes.py +0 -56
- cocotb/scheduler.py +0 -1099
- cocotb/share/makefiles/Makefile.deprecations +0 -12
- cocotb/share/makefiles/simulators/Makefile.cvc +0 -94
- cocotb/share/makefiles/simulators/Makefile.icarus +0 -111
- cocotb/share/makefiles/simulators/Makefile.ius +0 -125
- cocotb/share/makefiles/simulators/Makefile.modelsim +0 -32
- cocotb/share/makefiles/simulators/Makefile.nvc +0 -64
- cocotb/share/makefiles/simulators/Makefile.vcs +0 -98
- cocotb/types/array.py +0 -309
- cocotb/types/logic.py +0 -292
- cocotb/types/logic_array.py +0 -298
- cocotb/wavedrom.py +0 -199
- cocotb/xunit_reporter.py +0 -80
- cocotb-1.9.2.dist-info/METADATA +0 -168
- cocotb-1.9.2.dist-info/RECORD +0 -121
- cocotb-1.9.2.dist-info/entry_points.txt +0 -2
- /cocotb/{_vendor/__init__.py → py.typed} +0 -0
- {cocotb-1.9.2.dist-info → cocotb-2.0.0b1.dist-info/licenses}/LICENSE +0 -0
- {cocotb → cocotb_tools}/_vendor/distutils_version.py +0 -0
cocotb/types/_logic.py
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# Copyright cocotb contributors
|
|
2
|
+
# Licensed under the Revised BSD License, see LICENSE for details.
|
|
3
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
+
from functools import lru_cache
|
|
5
|
+
from typing import (
|
|
6
|
+
Dict,
|
|
7
|
+
Set,
|
|
8
|
+
Type,
|
|
9
|
+
Union,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
from cocotb._deprecation import deprecated
|
|
13
|
+
from cocotb._py_compat import TypeAlias
|
|
14
|
+
from cocotb.types._resolve import RESOLVE_X, ResolverLiteral, get_str_resolver
|
|
15
|
+
|
|
16
|
+
LogicLiteralT: TypeAlias = Union[str, int, bool]
|
|
17
|
+
LogicConstructibleT: TypeAlias = Union[LogicLiteralT, "Logic"]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
_U = 0
|
|
21
|
+
_X = 1
|
|
22
|
+
_0 = 2
|
|
23
|
+
_1 = 3
|
|
24
|
+
_Z = 4
|
|
25
|
+
_W = 5
|
|
26
|
+
_L = 6
|
|
27
|
+
_H = 7
|
|
28
|
+
_D = 8
|
|
29
|
+
|
|
30
|
+
_literal_repr: Dict[LogicLiteralT, int] = {
|
|
31
|
+
# unassigned
|
|
32
|
+
"U": _U,
|
|
33
|
+
"u": _U,
|
|
34
|
+
# unknown
|
|
35
|
+
"X": _X,
|
|
36
|
+
"x": _X,
|
|
37
|
+
# 0
|
|
38
|
+
0: _0, # Also `False`
|
|
39
|
+
"0": _0,
|
|
40
|
+
# 1
|
|
41
|
+
1: _1, # Also `True`
|
|
42
|
+
"1": _1,
|
|
43
|
+
# high impedance
|
|
44
|
+
"Z": _Z,
|
|
45
|
+
"z": _Z,
|
|
46
|
+
# weak unknown
|
|
47
|
+
"W": _W,
|
|
48
|
+
"w": _W,
|
|
49
|
+
# weak 0
|
|
50
|
+
"L": _L,
|
|
51
|
+
"l": _L,
|
|
52
|
+
# weak 1
|
|
53
|
+
"H": _H,
|
|
54
|
+
"h": _H,
|
|
55
|
+
# don't care
|
|
56
|
+
"-": _D,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_str_literals: Set[str] = {k for k in _literal_repr if isinstance(k, str)}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class Logic:
|
|
63
|
+
r"""
|
|
64
|
+
Model of a 9-value (``U``, ``X``, ``0``, ``1``, ``Z``, ``W``, ``L``, ``H``, ``-``) datatype commonly seen in VHDL.
|
|
65
|
+
|
|
66
|
+
.. currentmodule:: cocotb.types
|
|
67
|
+
|
|
68
|
+
This is modeled after VHDL's ``std_ulogic`` type.
|
|
69
|
+
(System)Verilog's 4-value ``logic`` type only utilizes ``X``, ``0``, ``1``, and ``Z`` values.
|
|
70
|
+
|
|
71
|
+
:class:`Logic` can be converted to and from :class:`int`, :class:`str`, and :class:`bool`.
|
|
72
|
+
The list of values convertible to :class:`Logic` includes
|
|
73
|
+
``"U"``, ``"X"``, ``"0"``, ``"1"``, ``"Z"``, ``"W"``, ``"L"``, ``"H"``, ``"-"``, ``0``, ``1``, ``True``, and ``False``.
|
|
74
|
+
|
|
75
|
+
.. code-block:: pycon3
|
|
76
|
+
|
|
77
|
+
>>> Logic("X")
|
|
78
|
+
Logic('X')
|
|
79
|
+
>>> Logic(True)
|
|
80
|
+
Logic('1')
|
|
81
|
+
>>> Logic(1)
|
|
82
|
+
Logic('1')
|
|
83
|
+
|
|
84
|
+
>>> str(Logic("Z"))
|
|
85
|
+
'Z'
|
|
86
|
+
>>> bool(Logic(0))
|
|
87
|
+
False
|
|
88
|
+
>>> int(Logic(1))
|
|
89
|
+
1
|
|
90
|
+
|
|
91
|
+
.. note::
|
|
92
|
+
|
|
93
|
+
The :class:`int` and :class:`bool` conversions will raise :exc:`ValueError` if the value is not ``0``, ``1``, ``L``, or ``H``.
|
|
94
|
+
|
|
95
|
+
:class:`Logic` values are immutable and therefore hashable and can be placed in :class:`set`\ s and used as keys in :class:`dict`\ s.
|
|
96
|
+
|
|
97
|
+
:class:`Logic` supports the common logic operations ``&``, ``|``, ``^``, and ``~``.
|
|
98
|
+
|
|
99
|
+
.. code-block:: pycon3
|
|
100
|
+
|
|
101
|
+
>>> def full_adder(a: Logic, b: Logic, carry: Logic) -> Tuple[Logic, Logic]:
|
|
102
|
+
... res = a ^ b ^ carry
|
|
103
|
+
... carry_out = (a & b) | (b & carry) | (a & carry)
|
|
104
|
+
... return res, carry_out
|
|
105
|
+
|
|
106
|
+
>>> full_adder(a=Logic("0"), b=Logic("1"), carry=Logic("1"))
|
|
107
|
+
(Logic('0'), Logic('1'))
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
value: value to construct into a :class:`Logic`.
|
|
111
|
+
|
|
112
|
+
Raises:
|
|
113
|
+
ValueError: If the value if of the correct type, but cannot be constructed into a :class:`Logic`.
|
|
114
|
+
TypeError: If the value is of a type that can't be constructed into a :class:`Logic`.
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
_repr: int
|
|
118
|
+
|
|
119
|
+
@classmethod
|
|
120
|
+
@lru_cache(maxsize=None)
|
|
121
|
+
def _singleton(cls: Type["Logic"], _repr: int) -> "Logic":
|
|
122
|
+
"""Return the Logic object associated with the repr, enforcing singleton."""
|
|
123
|
+
self = object.__new__(cls)
|
|
124
|
+
self._repr = _repr
|
|
125
|
+
return self
|
|
126
|
+
|
|
127
|
+
@classmethod
|
|
128
|
+
@lru_cache(maxsize=None)
|
|
129
|
+
def _map_literal(
|
|
130
|
+
cls: Type["Logic"],
|
|
131
|
+
value: LogicLiteralT,
|
|
132
|
+
) -> "Logic":
|
|
133
|
+
"""Convert and cache all literals."""
|
|
134
|
+
try:
|
|
135
|
+
_repr = _literal_repr[value]
|
|
136
|
+
except KeyError:
|
|
137
|
+
raise ValueError(
|
|
138
|
+
f"{value!r} is not convertible to a {cls.__qualname__}"
|
|
139
|
+
) from None
|
|
140
|
+
obj = cls._singleton(_repr)
|
|
141
|
+
return obj
|
|
142
|
+
|
|
143
|
+
def __new__(
|
|
144
|
+
cls: Type["Logic"],
|
|
145
|
+
value: LogicConstructibleT,
|
|
146
|
+
) -> "Logic":
|
|
147
|
+
if isinstance(value, Logic):
|
|
148
|
+
return value
|
|
149
|
+
elif isinstance(value, (str, int)):
|
|
150
|
+
return cls._map_literal(value)
|
|
151
|
+
raise TypeError(f"Expected str, bool, or int, not {type(value).__qualname__}")
|
|
152
|
+
|
|
153
|
+
def __and__(self, other: "Logic") -> "Logic":
|
|
154
|
+
if not isinstance(other, Logic):
|
|
155
|
+
return NotImplemented
|
|
156
|
+
return Logic(
|
|
157
|
+
(
|
|
158
|
+
# -----------------------------------------------------
|
|
159
|
+
# U X 0 1 Z W L H - | |
|
|
160
|
+
# -----------------------------------------------------
|
|
161
|
+
("U", "U", "0", "U", "U", "U", "0", "U", "U"), # | U |
|
|
162
|
+
("U", "X", "0", "X", "X", "X", "0", "X", "X"), # | X |
|
|
163
|
+
("0", "0", "0", "0", "0", "0", "0", "0", "0"), # | 0 |
|
|
164
|
+
("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | 1 |
|
|
165
|
+
("U", "X", "0", "X", "X", "X", "0", "X", "X"), # | Z |
|
|
166
|
+
("U", "X", "0", "X", "X", "X", "0", "X", "X"), # | W |
|
|
167
|
+
("0", "0", "0", "0", "0", "0", "0", "0", "0"), # | L |
|
|
168
|
+
("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | H |
|
|
169
|
+
("U", "X", "0", "X", "X", "X", "0", "X", "X"), # | - |
|
|
170
|
+
)[self._repr][other._repr]
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
def __or__(self: "Logic", other: "Logic") -> "Logic":
|
|
174
|
+
if not isinstance(other, Logic):
|
|
175
|
+
return NotImplemented
|
|
176
|
+
return Logic(
|
|
177
|
+
(
|
|
178
|
+
# -----------------------------------------------------
|
|
179
|
+
# U X 0 1 Z W L H - | |
|
|
180
|
+
# -----------------------------------------------------
|
|
181
|
+
("U", "U", "U", "1", "U", "U", "U", "1", "U"), # | U |
|
|
182
|
+
("U", "X", "X", "1", "X", "X", "X", "1", "X"), # | X |
|
|
183
|
+
("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | 0 |
|
|
184
|
+
("1", "1", "1", "1", "1", "1", "1", "1", "1"), # | 1 |
|
|
185
|
+
("U", "X", "X", "1", "X", "X", "X", "1", "X"), # | Z |
|
|
186
|
+
("U", "X", "X", "1", "X", "X", "X", "1", "X"), # | W |
|
|
187
|
+
("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | L |
|
|
188
|
+
("1", "1", "1", "1", "1", "1", "1", "1", "1"), # | H |
|
|
189
|
+
("U", "X", "X", "1", "X", "X", "X", "1", "X"), # | - |
|
|
190
|
+
)[self._repr][other._repr]
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
def __xor__(self: "Logic", other: "Logic") -> "Logic":
|
|
194
|
+
if not isinstance(other, Logic):
|
|
195
|
+
return NotImplemented
|
|
196
|
+
return Logic(
|
|
197
|
+
(
|
|
198
|
+
# -----------------------------------------------------
|
|
199
|
+
# U X 0 1 Z W L H - | |
|
|
200
|
+
# -----------------------------------------------------
|
|
201
|
+
("U", "U", "U", "U", "U", "U", "U", "U", "U"), # | U |
|
|
202
|
+
("U", "X", "X", "X", "X", "X", "X", "X", "X"), # | X |
|
|
203
|
+
("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | 0 |
|
|
204
|
+
("U", "X", "1", "0", "X", "X", "1", "0", "X"), # | 1 |
|
|
205
|
+
("U", "X", "X", "X", "X", "X", "X", "X", "X"), # | Z |
|
|
206
|
+
("U", "X", "X", "X", "X", "X", "X", "X", "X"), # | W |
|
|
207
|
+
("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | L |
|
|
208
|
+
("U", "X", "1", "0", "X", "X", "1", "0", "X"), # | H |
|
|
209
|
+
("U", "X", "X", "X", "X", "X", "X", "X", "X"), # | - |
|
|
210
|
+
)[self._repr][other._repr]
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
def __invert__(self: "Logic") -> "Logic":
|
|
214
|
+
return Logic(("U", "X", "1", "0", "X", "X", "1", "0", "X")[self._repr])
|
|
215
|
+
|
|
216
|
+
def __eq__(self, other: object) -> bool:
|
|
217
|
+
if isinstance(other, Logic):
|
|
218
|
+
return self is other
|
|
219
|
+
elif isinstance(other, (int, str, bool)):
|
|
220
|
+
try:
|
|
221
|
+
other = Logic(other)
|
|
222
|
+
except ValueError:
|
|
223
|
+
return False
|
|
224
|
+
return self == other
|
|
225
|
+
else:
|
|
226
|
+
return NotImplemented
|
|
227
|
+
|
|
228
|
+
def __repr__(self) -> str:
|
|
229
|
+
return f"{type(self).__qualname__}({str(self)!r})"
|
|
230
|
+
|
|
231
|
+
def __str__(self) -> str:
|
|
232
|
+
return ("U", "X", "0", "1", "Z", "W", "L", "H", "-")[self._repr]
|
|
233
|
+
|
|
234
|
+
if RESOLVE_X is None:
|
|
235
|
+
|
|
236
|
+
def __bool__(self) -> bool:
|
|
237
|
+
if self._repr in (_0, _L):
|
|
238
|
+
return False
|
|
239
|
+
elif self._repr in (_1, _H):
|
|
240
|
+
return True
|
|
241
|
+
raise ValueError(f"Cannot convert {self!r} to bool")
|
|
242
|
+
|
|
243
|
+
def __int__(self) -> int:
|
|
244
|
+
if self._repr in (_0, _L):
|
|
245
|
+
return 0
|
|
246
|
+
elif self._repr in (_1, _H):
|
|
247
|
+
return 1
|
|
248
|
+
raise ValueError(f"Cannot convert {self!r} to int")
|
|
249
|
+
|
|
250
|
+
else:
|
|
251
|
+
|
|
252
|
+
def __bool__(self) -> bool:
|
|
253
|
+
return self._repr in (_1, _H)
|
|
254
|
+
|
|
255
|
+
def __int__(self) -> int:
|
|
256
|
+
s = str(self)
|
|
257
|
+
s = RESOLVE_X(s)
|
|
258
|
+
return int(s, 2)
|
|
259
|
+
|
|
260
|
+
def __index__(self) -> int:
|
|
261
|
+
return int(self)
|
|
262
|
+
|
|
263
|
+
def resolve(self, resolver: ResolverLiteral) -> "Logic":
|
|
264
|
+
"""Resolves non-0/1 values to 0/1.
|
|
265
|
+
|
|
266
|
+
The possible values of the *resolver* argument are:
|
|
267
|
+
|
|
268
|
+
* ``"weak"``: Weak values are resolved to their strong-valued equivalents.
|
|
269
|
+
|
|
270
|
+
* ``"zeros"``:
|
|
271
|
+
``L`` and ``H`` are resolved to ``0`` and ``1``, respectively.
|
|
272
|
+
Remaining non-``0``/``1`` values are resolved to ``0``.
|
|
273
|
+
|
|
274
|
+
* ``"ones"``:
|
|
275
|
+
``L`` and ``H`` are resolved to ``0`` and ``1``, respectively.
|
|
276
|
+
Remaining non-``0``/``1`` values are resolved to ``1``.
|
|
277
|
+
|
|
278
|
+
* ``"random"``:
|
|
279
|
+
``L`` and ``H`` are resolved to ``0`` and ``1``, respectively.
|
|
280
|
+
Remaining non-``0``/``1`` values are randomly resolved to either ``0`` or ``1``.
|
|
281
|
+
|
|
282
|
+
Args:
|
|
283
|
+
resolver: How to resolve non-``0``/``1`` values. See possible values above.
|
|
284
|
+
|
|
285
|
+
Returns:
|
|
286
|
+
The resolved Logic.
|
|
287
|
+
|
|
288
|
+
Raises:
|
|
289
|
+
ValueError: Invalid *resolver* value.
|
|
290
|
+
TypeError: Unsupported *value* type.
|
|
291
|
+
"""
|
|
292
|
+
return Logic(get_str_resolver(resolver)(str(self)))
|
|
293
|
+
|
|
294
|
+
@deprecated('`len(logic)` is deprecated. A Logic\'s "length" is always 1.')
|
|
295
|
+
def __len__(self) -> int:
|
|
296
|
+
return 1
|