data-dword-0.2: Stick two binary words together to get a bigger one

Safe HaskellNone

Data.DoubleWord

Description

This module provides strict (low and high halves are unpacked) signed and unsigned binary word data types of sizes 96, 128, 160, 192, 224, and 256 bits.

Synopsis

Documentation

class Bits w => BinaryWord w whereSource

Extra bit-manipulation functions for binary words of fixed length.

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

class BinaryWord w => DoubleWord w whereSource

Defines a particular way to split a binary word in halves.

Associated Types

type LoWord w Source

The low half type

type HiWord w Source

The high half type

Methods

loWord :: w -> LoWord wSource

The low half of the word

hiWord :: w -> HiWord wSource

The high half of the word

fromHiAndLo :: HiWord w -> LoWord w -> wSource

Construct a word from the low and high halves

extendLo :: LoWord w -> wSource

Extend the low half

signExtendLo :: SignedWord (LoWord w) -> wSource

Sign-extend the low half