arxpy.bitvector.core module¶
Provide the basic bit-vector types.
-
class
arxpy.bitvector.core.
Term
[source]¶ Bases:
sympy.core.basic.Basic
Represent bit-vector terms.
Bit-vector terms are constants, variables and operations applied to terms.
Bit-vector terms support many operations with the standard operators symbols (<=, +, ^, etc.). See
operation
for more information.This class is not meant to be instantiated but to provide a base class for the different types of terms.
Note that Term inherits the methods of the SymPy class Basic; many of these methods work with bit-vector terms out of the box.
-
property
width
¶ The bit-width of the term.
-
property
formula_size
¶ The formula size of the bit-vector term.
As defined in Complexity of Fixed-Size Bit-Vector Logics.
-
doit
()[source]¶ Evaluate the term.
Terms are evaluated by default, but this behaviour can be disabled. See
Evaluation
for more information.
-
property
-
class
arxpy.bitvector.core.
Constant
[source]¶ Bases:
sympy.core.basic.Atom
,arxpy.bitvector.core.Term
Represent bit-vector constants.
Bit-vector constants are interpreted as unsigned integers in base 2, that is, a bit-vector \((x_{n-1}, \dots, x_1, x_0)\) represents the non-negative integer \(x_0 + 2 x_1 + \dots + 2^{n-1} x_{n-1}\).
- Parameters
val – the integer value.
width – the bit-width.
>>> from arxpy.bitvector.core import Constant >>> Constant(3, 12) 0x003 >>> Constant(0b11, 12) 0x003 >>> Constant(0x003, 12) 0x003 >>> Constant(3, 12).vrepr() 'Constant(0b000000000011, width=12)'
-
property
val
¶ The integer represented by the bit-vector constant.
-
property
formula_size
¶ The formula size of the constant.
-
bin
()[source]¶ Return the binary representation.
>>> from arxpy.bitvector.core import Constant >>> print(Constant(3, 4).bin()) 0b0011 >>> print(Constant(4, 6).bin()) 0b000100
-
class
arxpy.bitvector.core.
Variable
[source]¶ Bases:
sympy.core.basic.Atom
,arxpy.bitvector.core.Term
Represent bit-vector variables.
- Parameters
name – the name of the variable.
width – the bit-width.
>>> from arxpy.bitvector.core import Variable >>> Variable("x", 12) x >>> Variable("x", 12).vrepr() "Variable('x', width=12)"
-
property
name
¶ The name of the variable.
-
property
formula_size
¶ The formula size of the variable.