Basic operations on bitvectors #
Std has defined bitvector of length w
as Fin (2^w)
.
Here we define a few more operations on these bitvectors
Main definitions #
Std.BitVec.sgt
: Signed greater-than comparison of bitvectorsStd.BitVec.sge
: Signed greater-equals comparison of bitvectorsStd.BitVec.ugt
: Unsigned greater-than comparison of bitvectorsStd.BitVec.uge
: Unsigned greater-equals comparison of bitvectors
Constants #
@[reducible, inline]
The bitvector representing 1
.
That is, the bitvector with least-significant bit 1
and all other bits 0
Equations
- BitVec.one w = 1
Instances For
Bitwise operations #
Arithmetic operators #
Add with carry (no overflow)
See also Std.BitVec.adc
, which stores the carry bit separately.
Equations
- x.adc' y c = let a := x.adc y c; BitVec.cons a.1 a.2
Instances For
Comparison operators #
Conversion to nat
and int
#
addLsb r b
is r + r + 1
if b
is true
and r + r
otherwise.
Equations
- BitVec.addLsb r b = Nat.bit b r