bv-embed-0.1.0: Define embeddings of small bit vectors into larger ones

Copyright(c) Galois Inc. 2018
LicenseBSD-3
Maintainerbenselfridge@galois.com
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Data.BitVector.Embed

Description

This module exports types and functions for defining how a small bit vector is embedded into a larger one.

Synopsis

Documentation

data BitEmbedding Source #

Defines a mapping from each bit of a small bit vector into a larger one.

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