Copyright | (C) 2013-2016, University of Twente |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
Safe Haskell | Unsafe |
Language | Haskell2010 |
Extensions |
|
- newtype BitVector n = BV {}
- type Bit = BitVector 1
- size# :: KnownNat n => BitVector n -> Int
- maxIndex# :: KnownNat n => BitVector n -> Int
- high :: Bit
- low :: Bit
- bLit :: KnownNat n => String -> Q (TExp (BitVector n))
- (++#) :: KnownNat m => BitVector n -> BitVector m -> BitVector (n + m)
- reduceAnd# :: KnownNat n => BitVector n -> BitVector 1
- reduceOr# :: BitVector n -> BitVector 1
- reduceXor# :: BitVector n -> BitVector 1
- index# :: KnownNat n => BitVector n -> Int -> Bit
- replaceBit# :: KnownNat n => BitVector n -> Int -> Bit -> BitVector n
- 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
- lsb# :: BitVector n -> Bit
- eq# :: BitVector n -> BitVector n -> Bool
- neq# :: BitVector n -> BitVector n -> Bool
- lt# :: BitVector n -> BitVector n -> Bool
- ge# :: BitVector n -> BitVector n -> Bool
- gt# :: BitVector n -> BitVector n -> Bool
- le# :: BitVector n -> BitVector n -> Bool
- enumFrom# :: BitVector n -> [BitVector n]
- enumFromThen# :: BitVector n -> BitVector n -> [BitVector n]
- enumFromTo# :: BitVector n -> BitVector n -> [BitVector n]
- enumFromThenTo# :: BitVector n -> BitVector n -> BitVector n -> [BitVector n]
- minBound# :: BitVector n
- maxBound# :: KnownNat n => BitVector n
- (+#) :: KnownNat n => BitVector n -> BitVector n -> BitVector n
- (-#) :: KnownNat n => BitVector n -> BitVector n -> BitVector n
- (*#) :: KnownNat n => BitVector n -> BitVector n -> BitVector n
- negate# :: KnownNat n => BitVector n -> BitVector n
- fromInteger# :: KnownNat n => Integer -> BitVector n
- 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)
- quot# :: BitVector n -> BitVector n -> BitVector n
- rem# :: BitVector n -> BitVector n -> BitVector n
- toInteger# :: BitVector n -> Integer
- and# :: BitVector n -> BitVector n -> BitVector n
- or# :: BitVector n -> BitVector n -> BitVector n
- xor# :: BitVector n -> BitVector n -> BitVector n
- complement# :: KnownNat n => BitVector n -> BitVector n
- shiftL# :: KnownNat n => BitVector n -> Int -> BitVector n
- shiftR# :: KnownNat n => BitVector n -> Int -> BitVector n
- rotateL# :: KnownNat n => BitVector n -> Int -> BitVector n
- rotateR# :: KnownNat n => BitVector n -> Int -> BitVector n
- popCountBV :: (KnownNat (n + 1), KnownNat (n + 2)) => BitVector (n + 1) -> Index (n + 2)
- resize# :: KnownNat m => BitVector n -> BitVector m
- shrinkSizedUnsigned :: (KnownNat n, Integral (p n)) => p n -> [p n]
Datatypes
A vector of bits.
- Bit indices are descending
Num
instance performs unsigned arithmetic.
BV | The constructor, |
Accessors
Length information
Construction
Initialisation
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 BitVector
s
Reduction
reduceAnd# :: KnownNat n => BitVector n -> BitVector 1 Source
reduceXor# :: BitVector n -> BitVector 1 Source
Indexing
setSlice# :: BitVector ((m + 1) + i) -> SNat m -> SNat n -> BitVector ((m + 1) - n) -> BitVector ((m + 1) + i) Source
Type classes
Eq
Ord
Enum (not synthesisable)
enumFromThen# :: BitVector n -> BitVector n -> [BitVector n] Source
enumFromTo# :: BitVector n -> BitVector n -> [BitVector n] Source
Bounded
Num
fromInteger# :: KnownNat n => Integer -> BitVector n Source
ExtendingNum
Integral
toInteger# :: BitVector n -> Integer Source
Bits
complement# :: KnownNat n => BitVector n -> BitVector n Source
Resize
QuickCheck
shrinkSizedUnsigned :: (KnownNat n, Integral (p n)) => p n -> [p n] Source
shrink
for sized unsigned types