Copyright | (C) 2013-2016 University of Twente 2016-2017 Myrtle Software Ltd |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Extensions |
|
Clash.Class.BitPack
Description
Documentation
class BitPack a where Source #
Convert to and from a BitVector
Associated Types
Methods
pack :: a -> BitVector (BitSize a) Source #
Convert element of type a
to a BitVector
>>>
pack (-5 :: Signed 6)
11_1011
pack :: (Generic a, GBitPack (Rep a), GBitSize (Rep a) ~ BitSize a) => a -> BitVector (BitSize a) Source #
Convert element of type a
to a BitVector
>>>
pack (-5 :: Signed 6)
11_1011
unpack :: BitVector (BitSize a) -> a Source #
Convert a BitVector
to an element of type a
>>>
pack (-5 :: Signed 6)
11_1011>>>
let x = pack (-5 :: Signed 6)
>>>
unpack x :: Unsigned 6
59>>>
pack (59 :: Unsigned 6)
11_1011
unpack :: (Generic a, GBitPack (Rep a), GBitSize (Rep a) ~ BitSize a) => BitVector (BitSize a) -> a Source #
Convert a BitVector
to an element of type a
>>>
pack (-5 :: Signed 6)
11_1011>>>
let x = pack (-5 :: Signed 6)
>>>
unpack x :: Unsigned 6
59>>>
pack (59 :: Unsigned 6)
11_1011
Instances
bitCoerce :: (BitPack a, BitPack b, BitSize a ~ BitSize b) => a -> b Source #
Coerce a value from one type to another through its bit representation.
>>>
pack (-5 :: Signed 6)
11_1011>>>
bitCoerce (-5 :: Signed 6) :: Unsigned 6
59>>>
pack (59 :: Unsigned 6)
11_1011