number types of variable bit size and utils for bit manipulations
Project description
pyMathBitPrecise
This library contains data types of fixed bit size and utils for bit manipulations.
It also contains types with support for tri state values etc. (Python equivalents of VHDL std_logic_vector
, Verilog wire
/reg
.)
This may be usefull for tools which are simulating hardware or software which needs numbers of exact size.
Example
from pyMathBitPrecise.bits3t import Bits3t
#3t means that bits can have values 1,0,x
uint512_t = Bits3t(512, signed=False)
a = uint512_t.from_py(1)
# indexing on bits
# [note] == is not overloaded, because it would make the values unhashable
# because of support of partially valid values which can not be compared
assert a[0]._eq(1)
assert a[0]._dtype.bit_length() == 1
assert a[1]._eq(0)
assert a[8:]._eq(1)
assert a[8:]._dtype.bit_length() == 8
# arithmetic
b = a + 1
assert b._eq(2)
assert b._dtype == uint512_t
# bitwise operations
c = a >> 8
assert c._eq(0)
assert c._dtype == uint512_t
# casting
d = int(a)
assert d == 1 and isinstance(d, int)
uint8_t = Bits3t(8, signed=False)
e = a.cast(uint8_t)
assert e._dtype == uint8_t
Similar projects
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyMathBitPrecise-1.0.tar.gz
(14.1 kB
view details)
Built Distributions
pyMathBitPrecise-1.0-py3.9.egg
(36.2 kB
view details)
File details
Details for the file pyMathBitPrecise-1.0.tar.gz
.
File metadata
- Download URL: pyMathBitPrecise-1.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 225c68ffb4d2c3f68c6a5ab3ff75a49ab417baffee55d7a7ecfdfad2bdc6baa3 |
|
MD5 | 6f44f0c955d0cf8a514735f6ab818aba |
|
BLAKE2b-256 | 3a3ff495ce284105b134a33191509b6ce6811b60e6314de5cc574196fe825e9a |
File details
Details for the file pyMathBitPrecise-1.0-py3.9.egg
.
File metadata
- Download URL: pyMathBitPrecise-1.0-py3.9.egg
- Upload date:
- Size: 36.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1b2b12ddc715043bcbb9bd50e940f4704caaaf29a74eda52f810ab6cd77ff09 |
|
MD5 | ffac49d7cba3cdb351071998d7b366ea |
|
BLAKE2b-256 | 5f978f69aa0959b2f4ff79349179c9d2bb2c32ba745c99342cb3a426b24ad153 |
File details
Details for the file pyMathBitPrecise-1.0-py3-none-any.whl
.
File metadata
- Download URL: pyMathBitPrecise-1.0-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46dffc13df042e622fe5b00685f9dc1598290363d62878c29a7b9eefb3f82da7 |
|
MD5 | 22190b394ea75d2f25c944f531f7f2c6 |
|
BLAKE2b-256 | 40f25f7478c13518538fcf436c814ed05e42a50f3b1ce57c0730fecfffac719e |