feldspar-language-0.6.0.2: A functional embedded language for DSP and parallelism

Safe Haskell | None

Feldspar.BitVector

Contents

- Types and classes
- Feldspar integration of BitVector
- Operations
- Boolean functions extended to words
- Wrapping for bitvectors
- Patch combinators for bitvectors

Description

A `Vector` interface to packed sequences of bits

Synopsis

- class (Type w, Numeric w, Bits w, Integral w) => Unit w where
  - width :: Proxy w -> Length
- data BitVector w = BitVector {
  - segments :: [Segment w]
  }
- data Segment w = Segment {
  - numUnits :: Data Length
  - elements :: Data Index -> Data w
  }
- length :: forall w. Unit w => BitVector w -> Data Length
- numOfUnits :: Unit w => BitVector w -> Data Length
- freezeBitVector :: forall w. Unit w => BitVector w -> Data [w]
- unfreezeBitVector :: forall w. Unit w => Data [w] -> BitVector w
- fromVector :: forall w. (Unit w, Size w ~ Range w) => Vector (Data Bool) -> BitVector w
- toVector :: forall w. (Unit w, Size w ~ Range w) => BitVector w -> Vector (Data Bool)
- fromBits :: forall w. Unit w => [Bool] -> BitVector w
- fromUnits :: Unit w => [w] -> BitVector w
- replUnit :: Unit w => Data Length -> w -> BitVector w
- indexed :: (Unit w, Size w ~ Range w) => Data Length -> (Data Index -> Data Bool) -> BitVector w
- map :: (Unit w, Size w ~ Range w) => (Data Bool -> Data Bool) -> BitVector w -> BitVector w
- takeUnits :: forall w. Unit w => Data Length -> BitVector w -> BitVector w
- dropUnits :: forall w. Unit w => Data Length -> BitVector w -> BitVector w
- (++) :: forall w. Unit w => BitVector w -> BitVector w -> BitVector w
- drop :: forall w. (Unit w, Size w ~ Range w) => Data Length -> Data w -> BitVector w -> BitVector w
- fold :: forall w a. (Syntax a, Unit w, Size w ~ Range w) => (a -> Data Bool -> a) -> a -> BitVector w -> a
- zipWith :: forall w. (Unit w, Size w ~ Range w) => (Data Bool -> Data Bool -> Data Bool) -> BitVector w -> BitVector w -> BitVector w
- head :: (Unit w, Size w ~ Range w) => BitVector w -> Data Bool
- tail :: forall w. (Unit w, Size w ~ Range w) => Data Bool -> BitVector w -> BitVector w
- boolFun1 :: (Syntax t, Unit w, Size w ~ Range w) => (Data Bool -> Data Bool) -> ((Data w -> Data w) -> t) -> t
- boolFun2 :: (Syntax t, Unit w, Size w ~ Range w) => (Data Bool -> Data Bool -> Data Bool) -> ((Data w -> Data w -> Data w) -> t) -> t
- tBV :: Patch w w -> Patch (BitVector w) (BitVector w)

# Types and classes

class (Type w, Numeric w, Bits w, Integral w) => Unit w where

A `Unit` is the internal representation of a `BitVector`

Methods

width :: Proxy w -> Length

Instances

Unit Word8 |
Unit Word16 |
Unit Word32 |

data BitVector w

Constructors

BitVector |

Fields

segments :: [Segment w]

Instances

Unit a => Syntactic (BitVector a) |
(Unit w, ~ * (Size w) (Range w)) => Indexed (BitVector w) |
Unit a => Syntax (BitVector a) |
Unit w => Wrap (BitVector w) (Data [w]) |
(Wrap t u, Unit w, Nat s) => Wrap (BitVector w -> t) (Data' s [w] -> u) |

data Segment w

Constructors

Segment |

Fields

numUnits :: Data Length
elements :: Data Index -> Data w

# Feldspar integration of BitVector

# Operations

length :: forall w. Unit w => BitVector w -> Data Length

numOfUnits :: Unit w => BitVector w -> Data Length

freezeBitVector :: forall w. Unit w => BitVector w -> Data [w]

unfreezeBitVector :: forall w. Unit w => Data [w] -> BitVector w

fromVector :: forall w. (Unit w, Size w ~ Range w) => Vector (Data Bool) -> BitVector w

Transforms a bool vector to a bitvector. Length of the vector has to be divisible by the wordlength, otherwise booleans at the end will be dropped.

toVector :: forall w. (Unit w, Size w ~ Range w) => BitVector w -> Vector (Data Bool)

fromBits :: forall w. Unit w => [Bool] -> BitVector w

fromUnits :: Unit w => [w] -> BitVector w

replUnit :: Unit w => Data Length -> w -> BitVector w

indexed :: (Unit w, Size w ~ Range w) => Data Length -> (Data Index -> Data Bool) -> BitVector w

map :: (Unit w, Size w ~ Range w) => (Data Bool -> Data Bool) -> BitVector w -> BitVector w

takeUnits :: forall w. Unit w => Data Length -> BitVector w -> BitVector w

dropUnits :: forall w. Unit w => Data Length -> BitVector w -> BitVector w

(++) :: forall w. Unit w => BitVector w -> BitVector w -> BitVector w

drop :: forall w. (Unit w, Size w ~ Range w) => Data Length -> Data w -> BitVector w -> BitVector w

fold :: forall w a. (Syntax a, Unit w, Size w ~ Range w) => (a -> Data Bool -> a) -> a -> BitVector w -> a

zipWith :: forall w. (Unit w, Size w ~ Range w) => (Data Bool -> Data Bool -> Data Bool) -> BitVector w -> BitVector w -> BitVector w

head :: (Unit w, Size w ~ Range w) => BitVector w -> Data Bool

tail :: forall w. (Unit w, Size w ~ Range w) => Data Bool -> BitVector w -> BitVector w

# Boolean functions extended to words

boolFun1 :: (Syntax t, Unit w, Size w ~ Range w) => (Data Bool -> Data Bool) -> ((Data w -> Data w) -> t) -> t

boolFun2 :: (Syntax t, Unit w, Size w ~ Range w) => (Data Bool -> Data Bool -> Data Bool) -> ((Data w -> Data w -> Data w) -> t) -> t

# Wrapping for bitvectors

# Patch combinators for bitvectors

tBV :: Patch w w -> Patch (BitVector w) (BitVector w)