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
Metadata
Release files for pyMathBitPrecise 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyMathBitPrecise-1.0.tar.gz | 14.1 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyMathBitPrecise-1.0-py3.9.egg | Legacy Egg format | - | - | Details |
| pyMathBitPrecise-1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 66.4 kB
Release files / pyMathBitPrecise-1.0.tar.gz
| Download URL | pyMathBitPrecise-1.0.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
225c68ffb4d2c3f68c6a5ab3ff75a49ab417baffee55d7a7ecfdfad2bdc6baa3
|
|
BLAKE2b-256 checksum How to use checksums |
3a3ff495ce284105b134a33191509b6ce6811b60e6314de5cc574196fe825e9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pyMathBitPrecise-1.0-py3.9.egg
| Download URL | pyMathBitPrecise-1.0-py3.9.egg |
|---|---|
| Size | 36.2 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
b1b2b12ddc715043bcbb9bd50e940f4704caaaf29a74eda52f810ab6cd77ff09
|
|
BLAKE2b-256 checksum How to use checksums |
5f978f69aa0959b2f4ff79349179c9d2bb2c32ba745c99342cb3a426b24ad153
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pyMathBitPrecise-1.0-py3-none-any.whl
| Download URL | pyMathBitPrecise-1.0-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46dffc13df042e622fe5b00685f9dc1598290363d62878c29a7b9eefb3f82da7
|
|
BLAKE2b-256 checksum How to use checksums |
40f25f7478c13518538fcf436c814ed05e42a50f3b1ce57c0730fecfffac719e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|