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

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

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

Resize