Uint¶
-
class
UintType
¶ Bases:
pygears.typing.uint.IntegerType
Fixed width generic unsigned integer data type.
- Generic parameters:
N: Bit width of the
Uint
representation
Uint
is a generic datatype derived fromInteger
. It represents unsigned integers with fixed width binary representation. Concrete data type is obtained by indexing:>>> u16 = Uint[16]
-
property
args
¶ Returns a list of values supplied for each generic parameter.
>>> Tuple[Uint[1], Uint[2]].args [Uint[1], Uint[2]]
-
property
base
¶ Returns base generic class of the type.
>>> assert Uint[16].base == Uint
-
property
fields
¶ Returns the names of the generic parameters.
>>> Tuple[Uint[1], Uint[2]].fields ('f0', 'f1')
>>> Tuple[{'u1': Uint[1], 'u2': Uint[2]}].fields ('u0', 'u1')
-
is_generic
()¶ Return True if no values have been supplied for the generic parameters.
>>> Uint.is_generic() True
>>> Uint['template'].is_generic() False
-
items
()¶ Generator that yields (key, element) pairs.
-
keys
()¶ Returns a list of keys that can be used for indexing the type.
>>> Int[8].keys() [0, 1, 2, 3, 4, 5, 6, 7]
-
property
specified
¶ Return True if all generic parameters were supplied concrete values.
>>> Uint['template'].specified False
>>> Uint[16].specified True
-
property
templates
¶ Returns a list of templated generic variables within the type. The type is searched recursively. Each template is reported only once.
>>> Tuple[Tuple['T1', 'T2'], 'T1'].templates ['T1', 'T2']
-
property
width
¶ Calculates the bit width of the type.
>>> int(Tuple[Uint[1], Uint[2]]) 3
-
class
Uint
¶ Bases:
pygears.typing.uint.Integer
Implements the
Uint
type instance.- Parameters:
val – Integer value to convert to
Uint
Uint
is a generic datatype derived fromInteger
. It represents unsigned integers with fixed width binary representation.>>> Uint[16](0xffff) Uint[16](65535)
-
__int__
()¶ int(self)
-
__len__
()¶ Returns the number of bits used for the representation
>>> len(Integer[8](0)) 8
-
bit_length
()¶ Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
-
classmethod
decode
(val)¶ Creates Integer object from any int-convertible object val.
>>> Integer[8].decode(0xffff) Integer[8](255)