data-bword-0.1: Extra operations on binary words of fixed length

Safe HaskellNone

Data.BinaryWord

Description

Extra operations on binary words of fixed length.

Synopsis

Documentation

class (Bits w, Bits (UnsignedWord w), Bits (SignedWord w)) => BinaryWord w whereSource

Two's complement, fixed length binary words.

Associated Types

type UnsignedWord w Source

The unsigned variant type

type SignedWord w Source

The signed variant type

Methods

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

allZeroes :: wSource

The word with all bits set to 0

allOnes :: wSource

The word with all bits set to 1

msb :: wSource

The word with MSB set to 1 and all the other bits set to 0

lsb :: wSource

The word with LSB set to 1 and all the other bits set to 0

testMsb :: w -> BoolSource

Test if the MSB is 1

testLsb :: w -> BoolSource

Test if the LSB is 1

setMsb :: w -> wSource

Set the MSB to 1

setLsb :: w -> wSource

Set the LSB to 1

clearMsb :: w -> wSource

Set the MSB to 0

clearLsb :: w -> wSource

Set the LSB to 0

lMsb :: (Functor f, BinaryWord w) => (Bool -> f Bool) -> w -> f wSource

MSB lens.

lLsb :: (Functor f, BinaryWord w) => (Bool -> f Bool) -> w -> f wSource

LSB lens.