Module arithmetic

Source

Traits§

BitAdd
Expand
Popcnt

Functions§

bit_add
Add two L bit numbers together to produce an L+1 bit number. Thus it will not overflow. Note that this uses big endian byte order! If your host CPU is little endian and your numbers are >8 bits, you will need to call fix_endianness() on the bits.
comparator
(a > b, a == b, a < b)
fix_endianness
Since bitslice logic is big endian, if you are running on a little endian CPU (such as x86 and most ARMs) you must swap the byte order before and after doing math. This function will swap byte order only on little endian machines, on big endian machines it should compile to a null op.
full_adder
full_comparator
half_adder
half_comparator
pad
Pads the integer with zeros on the most significant side, thus preserving the value while permitting it to be transposed and such like.
popcnt2
Counts the number of bits on an array of bits.
popcnt4
Counts the number of bits on an array of bits.
popcnt8
Counts the number of bits on an array of bits.
popcnt16
Counts the number of bits on an array of bits.
popcnt32
Counts the number of bits on an array of bits.
popcnt64
Counts the number of bits on an array of bits.
popcnt128
Counts the number of bits on an array of bits.
popcnt256
Counts the number of bits on an array of bits.
popcnt512
Counts the number of bits on an array of bits.
popcnt1024
Counts the number of bits on an array of bits.