rewire-user-2.8
Safe HaskellNone
LanguageHaskell2010

ReWire.Bits

Synopsis

Documentation

type Lit = W 128 Source #

bit :: W 1 -> Bit Source #

toInteger :: forall (n :: Nat). W n -> Integer Source #

The unsigned value of a bit vector, as an Integer. A GHC-only convenience for simulation and testing: rwc does not compile uses of this function (Integer is a compile-time-literal-only type in the compiled fragment).

(@@) :: forall (n :: Nat) (m :: Nat). (KnownNat n, KnownNat m) => W n -> (Integer, Integer) -> W m Source #

Project range of bits. a @@ (j, i) returns bits j (most significant) to i (least significant) from a (j >= i). The Integer arguments must be non-negative integer literals (after inlining).

(@.) :: forall (n :: Nat). KnownNat n => W n -> Integer -> Bit Source #

Project single bit. The Integer argument must be a non-negative integer literal (after inlining).

Primitive bitwise operations based on Verilog operators.

lit :: forall (n :: Nat). KnownNat n => Integer -> W n Source #

Interpret an Integer literal into a bit vector. Truncates most significant bits or zero-pads to make it fit.

resize :: forall (m :: Nat) (n :: Nat). KnownNat m => W n -> W m Source #

Resize bitvector, truncating or zero padding most significant bits.

sext :: forall (m :: Nat) (n :: Natural). KnownNat m => W (1 + n) -> W (m + (1 + n)) Source #

Sign-extend a bitvector by m bits (the result width is inferred from the use site). Compiles to the idiomatic replicated-msb concatenation.

bitSlice :: forall (n :: Nat) (m :: Nat). (KnownNat n, KnownNat m) => W n -> Integer -> Integer -> W m Source #

bitIndex :: forall (n :: Nat). KnownNat n => W n -> Integer -> Bit Source #

finBitSlice :: forall (m :: Nat) (n :: Nat). KnownNat m => W n -> Finite n -> Finite n -> W m Source #

finBitIndex :: forall (n :: Nat). W n -> Finite n -> Bit Source #

(+) :: forall (n :: Nat). KnownNat n => W n -> W n -> W n infixl 7 Source #

Add.

(-) :: forall (n :: Nat). KnownNat n => W n -> W n -> W n infixl 7 Source #

Subtract.

(*) :: forall (n :: Nat). KnownNat n => W n -> W n -> W n infixl 8 Source #

Multiply.

(/) :: forall (n :: Nat). KnownNat n => W n -> W n -> W n infixl 8 Source #

Unsigned division. Division by zero yields all-ones (2^n - 1), following the SMT-LIB convention (compiled RTL, the interpreter, and the GHC implementation agree).

(%) :: forall (n :: Nat). KnownNat n => W n -> W n -> W n infixl 8 Source #

Unsigned modulus. A zero divisor yields the dividend, following the SMT-LIB convention (compiled RTL, the interpreter, and the GHC implementation agree).

(**) :: forall (n :: Nat). KnownNat n => W n -> W n -> W n infixr 9 Source #

Exponentiation.

(&&&) :: Bool -> Bool -> Bool infixr 2 Source #

Prelude (&&), but using built-ins.

(|||) :: Bool -> Bool -> Bool infixr 1 Source #

Prelude (||), but using built-ins.

(&&.) :: forall (n :: Nat). W n -> W n -> Bool infixr 2 Source #

Logical and.

(||.) :: forall (n :: Nat). W n -> W n -> Bool infixr 1 Source #

Logical or.

lnot :: forall (n :: Nat). W n -> Bit Source #

Logical not.

(.&.) :: forall (n :: Nat). W n -> W n -> W n infixl 5 Source #

Bitwise and.

(.|.) :: forall (n :: Nat). W n -> W n -> W n infixl 3 Source #

Bitwise or.

bnot :: forall (n :: Nat). W n -> W n Source #

Bitwise not.

(^) :: forall (n :: Nat). W n -> W n -> W n infixl 4 Source #

Bitwise exclusive or.

xor :: Bool -> Bool -> Bool infixl 4 Source #

Logical xor, for Bit/Bool (using the built-in operator).

(~^) :: forall (n :: Nat). W n -> W n -> W n infixl 4 Source #

Bitwise exclusive nor.

(<<.) :: forall (n :: Nat). KnownNat n => W n -> W n -> W n infixl 6 Source #

Shift left.

(>>.) :: forall (n :: Nat). KnownNat n => W n -> W n -> W n infixl 6 Source #

Shift right.

(>>>) :: forall (n :: Nat). KnownNat n => W n -> W n -> W n infixl 6 Source #

Shift right, sign-extend.

rotR :: forall (m :: Nat). KnownNat m => W m -> W m -> W m Source #

Rotate right

rotL :: forall (m :: Nat). KnownNat m => W m -> W m -> W m Source #

Rotate left

(==) :: forall (n :: Nat). W n -> W n -> Bool Source #

Equal.

(/=) :: forall (n :: Nat). W n -> W n -> Bool Source #

Not equal.

(>) :: forall (n :: Nat). W n -> W n -> Bool infixl 6 Source #

Greater-than.

(>=) :: forall (n :: Nat). W n -> W n -> Bool infixl 6 Source #

Greater-than or equal.

(<) :: forall (n :: Nat). W n -> W n -> Bool infixl 6 Source #

Less-than.

(<=) :: forall (n :: Nat). W n -> W n -> Bool infixl 6 Source #

Less-than or equal.

(<>) :: forall (n :: Nat) (m :: Nat). W n -> W m -> W (n + m) infixr 6 Source #

Concatenate.

rAnd :: forall (n :: Nat). W n -> Bit Source #

Reduction and.

rNAnd :: forall (n :: Natural). W (1 + n) -> Bit Source #

Reduction nand.

rOr :: forall (n :: Nat). W n -> Bit Source #

Reduction or.

rNor :: forall (n :: Natural). W (1 + n) -> Bit Source #

Reduction nor.

rXOr :: forall (n :: Natural). W (1 + n) -> Bit Source #

Reduction xor.

rXNor :: forall (n :: Natural). W (1 + n) -> Bit Source #

Reduction xnor.

msbit :: forall (n :: Natural). W (1 + n) -> Bit Source #

Most significant bit.

odd :: forall (n :: Natural). W (1 + n) -> Bool Source #

Least significant bit.

even :: forall (n :: Natural). W (1 + n) -> Bool Source #

Negation of the least significant bit.