pyeda.boolalg.bfarray — Boolean Function Arrays¶
The pyeda.boolalg.bfarray module implements multi-dimensional arrays of Boolean functions.
Interface Functions:
- bddzeros()
- bddones()
- bddvars()
- exprzeros()
- exprones()
- exprvars()
- ttzeros()
- ttones()
- ttvars()
- uint2bdds()
- uint2exprs()
- uint2tts()
- int2bdds()
- int2exprs()
- int2tts()
- fcat()
Interface Classes:
Interface Functions¶
- pyeda.boolalg.bfarray.bddzeros(*dims)[source]¶
Return a multi-dimensional farray of BDDZERO.
BDDZERO is the BDD representation of the number zero.
The variadic dims input is a sequence of dimension specs. A dimension spec is a two-tuple: (start index, stop index). If a dimension is given as a single int, it will be converted to (0, stop).
The dimension starts at index start, and increments by one up to, but not including, stop. This follows the Python slice convention.
For example, to create a 4x4 farray of BDD zeros:
>>> zeros = bddzeros(4, 4) >>> zeros farray([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
- pyeda.boolalg.bfarray.bddones(*dims)[source]¶
Return a multi-dimensional farray of BDDONE.
BDDONE is the BDD representation of the number one.
The variadic dims input is a sequence of dimension specs. A dimension spec is a two-tuple: (start index, stop index). If a dimension is given as a single int, it will be converted to (0, stop).
The dimension starts at index start, and increments by one up to, but not including, stop. This follows the Python slice convention.
For example, to create a 4x4 farray of BDD ones:
>>> ones = bddones(4, 4) >>> ones farray([[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]])
- pyeda.boolalg.bfarray.bddvars(name, *dims)[source]¶
Return a multi-dimensional farray of BDD variables.
The name argument is passed directly to the pyeda.boolalg.bdd.bddvar() function, and may be either a str or tuple of str.
The variadic dims input is a sequence of dimension specs. A dimension spec is a two-tuple: (start index, stop index). If a dimension is given as a single int, it will be converted to (0, stop).
The dimension starts at index start, and increments by one up to, but not including, stop. This follows the Python slice convention.
For example, to create a 4x4 farray of BDD variables:
>>> vs = bddvars('a', 4, 4) >>> vs farray([[a[0,0], a[0,1], a[0,2], a[0,3]], [a[1,0], a[1,1], a[1,2], a[1,3]], [a[2,0], a[2,1], a[2,2], a[2,3]], [a[3,0], a[3,1], a[3,2], a[3,3]]])
- pyeda.boolalg.bfarray.exprzeros(*dims)[source]¶
Return a multi-dimensional farray of EXPRZERO.
EXPRZERO is the expression representation of the number zero.
The variadic dims input is a sequence of dimension specs. A dimension spec is a two-tuple: (start index, stop index). If a dimension is given as a single int, it will be converted to (0, stop).
The dimension starts at index start, and increments by one up to, but not including, stop. This follows the Python slice convention.
For example, to create a 4x4 farray of expression zeros:
>>> zeros = exprzeros(4, 4) >>> zeros farray([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
- pyeda.boolalg.bfarray.exprones(*dims)[source]¶
Return a multi-dimensional farray of EXPRONE.
EXPRONE is the expression representation of the number one.
The variadic dims input is a sequence of dimension specs. A dimension spec is a two-tuple: (start index, stop index). If a dimension is given as a single int, it will be converted to (0, stop).
The dimension starts at index start, and increments by one up to, but not including, stop. This follows the Python slice convention.
For example, to create a 4x4 farray of expression ones:
>>> ones = exprones(4, 4) >>> ones farray([[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]])
- pyeda.boolalg.bfarray.exprvars(name, *dims)[source]¶
Return a multi-dimensional farray of expression variables.
The name argument is passed directly to the pyeda.boolalg.expr.exprvar() function, and may be either a str or tuple of str.
The variadic dims input is a sequence of dimension specs. A dimension spec is a two-tuple: (start index, stop index). If a dimension is given as a single int, it will be converted to (0, stop).
The dimension starts at index start, and increments by one up to, but not including, stop. This follows the Python slice convention.
For example, to create a 4x4 farray of expression variables:
>>> vs = exprvars('a', 4, 4) >>> vs farray([[a[0,0], a[0,1], a[0,2], a[0,3]], [a[1,0], a[1,1], a[1,2], a[1,3]], [a[2,0], a[2,1], a[2,2], a[2,3]], [a[3,0], a[3,1], a[3,2], a[3,3]]])
- pyeda.boolalg.bfarray.ttzeros(*dims)[source]¶
Return a multi-dimensional farray of TTZERO.
TTZERO is the truth table representation of the number zero.
The variadic dims input is a sequence of dimension specs. A dimension spec is a two-tuple: (start index, stop index). If a dimension is given as a single int, it will be converted to (0, stop).
The dimension starts at index start, and increments by one up to, but not including, stop. This follows the Python slice convention.
For example, to create a 4x4 farray of truth table zeros:
>>> zeros = ttzeros(4, 4) >>> zeros farray([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
- pyeda.boolalg.bfarray.ttones(*dims)[source]¶
Return a multi-dimensional farray of TTONE.
TTONE is the truth table representation of the number one.
The variadic dims input is a sequence of dimension specs. A dimension spec is a two-tuple: (start index, stop index). If a dimension is given as a single int, it will be converted to (0, stop).
The dimension starts at index start, and increments by one up to, but not including, stop. This follows the Python slice convention.
For example, to create a 4x4 farray of truth table ones:
>>> ones = ttones(4, 4) >>> ones farray([[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]])
- pyeda.boolalg.bfarray.ttvars(name, *dims)[source]¶
Return a multi-dimensional farray of truth table variables.
The name argument is passed directly to the pyeda.boolalg.table.ttvar() function, and may be either a str or tuple of str.
The variadic dims input is a sequence of dimension specs. A dimension spec is a two-tuple: (start index, stop index). If a dimension is given as a single int, it will be converted to (0, stop).
The dimension starts at index start, and increments by one up to, but not including, stop. This follows the Python slice convention.
For example, to create a 4x4 farray of truth table variables:
>>> vs = ttvars('a', 4, 4) >>> vs farray([[a[0,0], a[0,1], a[0,2], a[0,3]], [a[1,0], a[1,1], a[1,2], a[1,3]], [a[2,0], a[2,1], a[2,2], a[2,3]], [a[3,0], a[3,1], a[3,2], a[3,3]]])
- pyeda.boolalg.bfarray.uint2bdds(num, length=None)[source]¶
Convert num to an farray of BDDs.
The num argument is a non-negative integer.
If no length parameter is given, the return value will have the minimal required length. Otherwise, the return value will be zero-extended to match length.
For example, to convert the byte 42 (binary 0b00101010):
>>> uint2bdds(42, 8) farray([0, 1, 0, 1, 0, 1, 0, 0])
- pyeda.boolalg.bfarray.uint2exprs(num, length=None)[source]¶
Convert num to an farray of expressions.
The num argument is a non-negative integer.
If no length parameter is given, the return value will have the minimal required length. Otherwise, the return value will be zero-extended to match length.
For example, to convert the byte 42 (binary 0b00101010):
>>> uint2exprs(42, 8) farray([0, 1, 0, 1, 0, 1, 0, 0])
- pyeda.boolalg.bfarray.uint2tts(num, length=None)[source]¶
Convert num to an farray of truth tables.
The num argument is a non-negative integer.
If no length parameter is given, the return value will have the minimal required length. Otherwise, the return value will be zero-extended to match length.
For example, to convert the byte 42 (binary 0b00101010):
>>> uint2tts(42, 8) farray([0, 1, 0, 1, 0, 1, 0, 0])
- pyeda.boolalg.bfarray.int2bdds(num, length=None)[source]¶
Convert num to an farray of BDDs.
The num argument is an int. Negative numbers will be converted using twos-complement notation.
If no length parameter is given, the return value will have the minimal required length. Otherwise, the return value will be sign-extended to match length.
For example, to convert the bytes 42 (binary 0b00101010), and -42 (binary 0b11010110):
>>> int2bdds(42, 8) farray([0, 1, 0, 1, 0, 1, 0, 0]) >>> int2bdds(-42, 8) farray([0, 1, 1, 0, 1, 0, 1, 1])
- pyeda.boolalg.bfarray.int2exprs(num, length=None)[source]¶
Convert num to an farray of expressions.
The num argument is an int. Negative numbers will be converted using twos-complement notation.
If no length parameter is given, the return value will have the minimal required length. Otherwise, the return value will be sign-extended to match length.
For example, to convert the bytes 42 (binary 0b00101010), and -42 (binary 0b11010110):
>>> int2exprs(42, 8) farray([0, 1, 0, 1, 0, 1, 0, 0]) >>> int2exprs(-42, 8) farray([0, 1, 1, 0, 1, 0, 1, 1])
- pyeda.boolalg.bfarray.int2tts(num, length=None)[source]¶
Convert num to an farray of truth tables.
The num argument is an int. Negative numbers will be converted using twos-complement notation.
If no length parameter is given, the return value will have the minimal required length. Otherwise, the return value will be sign-extended to match length.
For example, to convert the bytes 42 (binary 0b00101010), and -42 (binary 0b11010110):
>>> int2tts(42, 8) farray([0, 1, 0, 1, 0, 1, 0, 0]) >>> int2tts(-42, 8) farray([0, 1, 1, 0, 1, 0, 1, 1])
Interface Classes¶
- class pyeda.boolalg.bfarray.farray(objs, shape=None, ftype=None)[source]¶
Array of Boolean functions
- restrict(point)[source]¶
Return the farray that results from applying the restrict method to all functions.
- __lshift__(obj)[source]¶
Return the farray left-shifted by obj.
The obj argument may either be an int, or (int, farray). The int argument is num, and the farray argument is cin.
See also
- __rshift__(obj)[source]¶
Return the farray right-shifted by obj.
The obj argument may either be an int, or (int, farray). The int argument is num, and the farray argument is cin.
See also
- lsh(num, cin=None)[source]¶
Return the farray left-shifted by num places.
The num argument must be a non-negative int.
If the cin farray is provided, it will be shifted in. Otherwise, the carry-in is zero.
Returns a two-tuple (farray fs, farray cout), where fs is the shifted vector, and cout is the “carry out”.
- rsh(num, cin=None)[source]¶
Return the farray right-shifted by num places.
The num argument must be a non-negative int.
If the cin farray is provided, it will be shifted in. Otherwise, the carry-in is zero.
Returns a two-tuple (farray fs, farray cout), where fs is the shifted vector, and cout is the “carry out”.