rewire-user-2.8
Safe HaskellNone
LanguageHaskell2010

ReWire.BitWord

Synopsis

Documentation

type Vec (n :: Nat) a = Vector n a Source #

type Bit = Bool Source #

(>&&<) :: Bit -> Bit -> Bit Source #

AND

(>||<) :: Bit -> Bit -> Bit Source #

OR

(>^<) :: Bit -> Bit -> Bit Source #

XOR

(>==<) :: Bit -> Bit -> Bit Source #

Eq

(>~&<) :: Bit -> Bit -> Bit Source #

NAND

(>~|<) :: Bit -> Bit -> Bit Source #

NOR

(>~^<) :: Bit -> Bit -> Bit Source #

XNOR

rca :: Bit -> Bit -> Bit -> (Bit, Bit) Source #

a b c ~> (a+b+c,carry_out)

carryadd' :: [Bool] -> [Bool] -> Bool -> ([Bool], Bool) Source #

assumes inputs are same length

bitwiseXor' :: [Bool] -> [Bool] -> [Bool] Source #

bitwiseAnd' :: [Bool] -> [Bool] -> [Bool] Source #

bitwiseOr' :: [Bool] -> [Bool] -> [Bool] Source #

int2bits' :: Integer -> [Bool] Source #

Produces bits in little endian form.

pad' :: Int -> [Bool] -> [Bool] Source #

padTrunc' :: Int -> [Bool] -> [Bool] Source #

w is bigendian

toIntLE' :: [Bool] -> Int Source #

takes little endian bits

toInteger' :: forall (n :: Nat). Vec n Bool -> Integer Source #

bitsToInteger' :: [Bool] -> Integer Source #

The unsigned value of a big-endian bit list, as an Integer (exact at any width, unlike toInt').

intToBits' :: Int -> Integer -> [Bool] Source #

Materialize an Integer as exactly d bits, big-endian, reducing mod 2^d (so a negative value takes its d-bit two's-complement form).

resize' :: Int -> [Bool] -> [Bool] Source #

w is bigendian

plus' :: [Bool] -> [Bool] -> [Bool] Source #

minus' :: [Bool] -> [Bool] -> [Bool] Source #

nudgeL' :: ([Bool], Bool) -> (Bool, [Bool]) Source #

nudgeR' :: (Bool, [Bool]) -> ([Bool], Bool) Source #

rNudge' :: ([Bool], [Bool]) -> ([Bool], [Bool], Bool) Source #

boothround :: ([Bool], [Bool], Bool, [Bool]) -> ([Bool], [Bool], Bool, [Bool]) Source #

booth' :: ([Bool], [Bool]) -> ([Bool], [Bool]) Source #

assume all are same length, for example W8

times' :: [Bool] -> [Bool] -> [Bool] Source #

decr' :: [Bool] -> [Bool] Source #

iter' :: [Bool] -> ([Bool] -> [Bool]) -> [Bool] -> [Bool] Source #

shiftAmount' :: [Bool] -> [Bool] -> Int Source #

The shift amount as an Int, saturated to the word length (the guard compares in Integer, so amounts too wide for Int cannot wrap).

shiftL' :: [Bool] -> [Bool] -> [Bool] Source #

shiftR' :: [Bool] -> [Bool] -> [Bool] Source #

padMax' :: [Bool] -> [Bool] -> ([Bool], [Bool]) Source #

For (Unsigned!) comparison: we assume that the input words are the same length so we can use (lexicographic) ordering as defined on lists so we need a function pad the shorter word

power' :: [Bool] -> [Bool] -> [Bool] Source #

Modular exponentiation by squaring over the exponent's bits, so wide dynamic exponents evaluate in O(width) multiplies instead of O(value) (the result cycles mod 2^(length w) regardless).

nonrestoringDivide' :: [Bool] -> [Bool] -> [Bool] -> ([Bool], [Bool]) Source #

assumed positive inputs, n = dividend, d = divisor b is s.t. d << b <= n , d << b+1 > n returns (quotient,remainder)

divCounter' :: [Bool] -> [Bool] -> Int Source #

assumes n and d are the same length and n >= d

divide' :: [Bool] -> [Bool] -> [Bool] Source #

assumes the same length inputs

mod' :: [Bool] -> [Bool] -> [Bool] Source #

assumes the same length inputs

fours :: a -> [a] -> [(a, a, a, a)] Source #