Safe Haskell | None |
---|
Extra operations on binary words of fixed length.
- class (Bits w, Bits (UnsignedWord w), Bits (SignedWord w)) => BinaryWord w where
- type UnsignedWord w
- type SignedWord w
- unsignedWord :: w -> UnsignedWord w
- signedWord :: w -> SignedWord w
- unwrappedAdd :: w -> w -> (w, UnsignedWord w)
- unwrappedMul :: w -> w -> (w, UnsignedWord w)
- leadingZeroes :: w -> Int
- trailingZeroes :: w -> Int
- allZeroes :: w
- allOnes :: w
- msb :: w
- lsb :: w
- testMsb :: w -> Bool
- testLsb :: w -> Bool
- setMsb :: w -> w
- setLsb :: w -> w
- clearMsb :: w -> w
- clearLsb :: w -> w
- lMsb :: (Functor f, BinaryWord w) => (Bool -> f Bool) -> w -> f w
- lLsb :: (Functor f, BinaryWord w) => (Bool -> f Bool) -> w -> f w
Documentation
class (Bits w, Bits (UnsignedWord w), Bits (SignedWord w)) => BinaryWord w whereSource
Two's complement, fixed length binary words.
unsignedWord :: w -> UnsignedWord wSource
Convert the word to the unsigned type (identical to fromIntegral
)
signedWord :: w -> SignedWord wSource
Convert the word to the signed type (identical to fromIntegral
)
unwrappedAdd :: w -> w -> (w, UnsignedWord w)Source
Unwrapped addition
unwrappedMul :: w -> w -> (w, UnsignedWord w)Source
Unwrapped multiplication
leadingZeroes :: w -> IntSource
Number of leading (from MSB) zero bits
trailingZeroes :: w -> IntSource
Number or trailing (from LSB) zero bits
The word with all bits set to 0
The word with all bits set to 1
The word with MSB set to 1 and all the other bits set to 0
The word with LSB set to 1 and all the other bits set to 0
Test if the MSB is 1
Test if the LSB is 1
Set the MSB to 1
Set the LSB to 1
Set the MSB to 0
Set the LSB to 0