clash-prelude-0.6: CAES Language for Synchronous Hardware - Prelude library

Safe HaskellNone
LanguageHaskell2010

CLaSH.Sized.Internal.BitVector

Contents

Synopsis

Datatypes

newtype BitVector n

A vector of bits.

  • Bit indices are descending
  • Num instance performs unsigned arithmetic.

Constructors

BV

The constructor, BV, and the field, unsafeToInteger, are not synthesisable.

Instances

type Bit = BitVector 1

Accessors

Length information

Construction

Initialisation

high :: Bit

logic '1'

low :: Bit

logic '0'

bLit :: KnownNat n => String -> Q (TExp (BitVector n))

Create a binary literal

>>> $$(bLit "1001") :: BitVector 4
1001
>>> $$(bLit "1001") :: BitVector 3
001

NB: Will be removed once GHC 7.10 is released which has support for binary literals. Once GHC 7.10 is released you can just write:

>>> 0b1001 :: BitVector 4
1001

Concatenation

(++#) :: KnownNat m => BitVector n -> BitVector m -> BitVector (n + m)

Concatenate two BitVectors

Reduction

Indexing

index# :: KnownNat n => BitVector n -> Int -> Bit

setSlice# :: BitVector ((m + 1) + i) -> SNat m -> SNat n -> BitVector ((m + 1) - n) -> BitVector ((m + 1) + i)

slice# :: BitVector ((m + 1) + i) -> SNat m -> SNat n -> BitVector ((m + 1) - n)

split# :: KnownNat n => BitVector (m + n) -> (BitVector m, BitVector n)

msb# :: KnownNat n => BitVector n -> Bit

MSB

lsb# :: BitVector n -> Bit

LSB

Type classes

Eq

Ord

Enum (not synthesisable)

Bounded

Num

ExtendingNum

plus# :: KnownNat (Max m n + 1) => BitVector m -> BitVector n -> BitVector (Max m n + 1)

minus# :: KnownNat (Max m n + 1) => BitVector m -> BitVector n -> BitVector (Max m n + 1)

times# :: KnownNat (m + n) => BitVector m -> BitVector n -> BitVector (m + n)

Integral

Bits

Resize