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

Copyright(C) 2013-2016, University of Twente
LicenseBSD2 (see the file LICENSE)
MaintainerChristiaan Baaij <christiaan.baaij@gmail.com>
Safe HaskellUnsafe
LanguageHaskell2010
Extensions
  • UndecidableInstances
  • MonoLocalBinds
  • TemplateHaskell
  • ScopedTypeVariables
  • TypeFamilies
  • DataKinds
  • DeriveDataTypeable
  • FlexibleContexts
  • MultiParamTypeClasses
  • MagicHash
  • KindSignatures
  • TypeOperators
  • ExplicitNamespaces
  • ExplicitForAll

CLaSH.Sized.Internal.BitVector

Contents

Description

 

Synopsis

Datatypes

newtype BitVector n Source

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.

type Bit = BitVector 1 Source

Bit: a BitVector of length 1

Accessors

Length information

Construction

Initialisation

high :: Bit Source

logic '1'

low :: Bit Source

logic '0'

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

Create a binary literal

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

NB: You can also just write:

>>> 0b1001 :: BitVector 4
1001

The advantage of bLit is that you can use computations to create the string literal:

>>> import qualified Data.List as List
>>> $$(bLit (List.replicate 4 '1')) :: BitVector 4
1111

Concatenation

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

Concatenate two BitVectors

Reduction

Indexing

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

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

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

MSB

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) Source

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

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

Integral

Bits

popCountBV :: (KnownNat (n + 1), KnownNat (n + 2)) => BitVector (n + 1) -> Index (n + 2) Source

Resize

QuickCheck

shrinkSizedUnsigned :: (KnownNat n, Integral (p n)) => p n -> [p n] Source

shrink for sized unsigned types