Copyright | (c) Galois Inc. 2018 |
---|---|
License | BSD-3 |
Maintainer | benselfridge@galois.com |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
This module exports types and functions for defining how a small bit vector is embedded into a larger one.
Synopsis
- data BitEmbedding
- fromList :: [Int] -> BitEmbedding
- bitEmbed :: (Bits src, Bits tgt) => BitEmbedding -> src -> tgt -> tgt
- bitExtract :: (Bits src, Bits tgt) => BitEmbedding -> tgt -> src
Documentation
data BitEmbedding Source #
Defines a mapping from each bit of a small bit vector into a larger one.
Instances
Eq BitEmbedding Source # | |
Defined in Data.BitVector.Embed (==) :: BitEmbedding -> BitEmbedding -> Bool # (/=) :: BitEmbedding -> BitEmbedding -> Bool # | |
Ord BitEmbedding Source # | |
Defined in Data.BitVector.Embed compare :: BitEmbedding -> BitEmbedding -> Ordering # (<) :: BitEmbedding -> BitEmbedding -> Bool # (<=) :: BitEmbedding -> BitEmbedding -> Bool # (>) :: BitEmbedding -> BitEmbedding -> Bool # (>=) :: BitEmbedding -> BitEmbedding -> Bool # max :: BitEmbedding -> BitEmbedding -> BitEmbedding # min :: BitEmbedding -> BitEmbedding -> BitEmbedding # | |
Show BitEmbedding Source # | |
Defined in Data.BitVector.Embed showsPrec :: Int -> BitEmbedding -> ShowS # show :: BitEmbedding -> String # showList :: [BitEmbedding] -> ShowS # |
fromList :: [Int] -> BitEmbedding Source #
Construct a BitEmbedding
from a list, where the length of the list is the same
as the width of the "small" bit vector we are embedding into the larger one. The
nth element of the list tells us at which bit index in the target to embed bit n
of the source.
bitEmbed :: (Bits src, Bits tgt) => BitEmbedding -> src -> tgt -> tgt Source #
Embed a smaller bit vector into a larger one using a BitEmbedding
.
>>>
bitEmbed (fromList [4,5,7] 7 0)
176
bitExtract :: (Bits src, Bits tgt) => BitEmbedding -> tgt -> src Source #
Extract a smaller bit vector from a larger one using a BitEmbedding
.
>>>
bitExtract (fromList [4,5,7] 7 0) 176
7