clash-prelude-0.9.3: 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 HaskellTrustworthy
LanguageHaskell2010
ExtensionsMagicHash

CLaSH.Sized.BitVector

Contents

Description

 

Synopsis

Datatypes

data BitVector n Source

A vector of bits.

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

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