| Copyright | (C) 2013-2016 University of Twente |
|---|---|
| License | BSD2 (see the file LICENSE) |
| Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
| Safe Haskell | Safe |
| Language | Haskell2010 |
| Extensions |
|
Clash.Class.Resize
Description
Documentation
class Resize (f :: Nat -> *) where #
Coerce a value to be represented by a different number of bits
Minimal complete definition
Methods
resize :: (KnownNat a, KnownNat b) => f a -> f b #
A sign-preserving resize operation
- For signed datatypes: Increasing the size of the number replicates the sign bit to the left. Truncating a number to length L keeps the sign bit and the rightmost L-1 bits.
- For unsigned datatypes: Increasing the size of the number extends with zeros to the left. Truncating a number of length N to a length L just removes the left (most significant) N-L bits.
extend :: (KnownNat a, KnownNat b) => f a -> f (b + a) #
Perform a zeroExtend for unsigned datatypes, and signExtend for a
signed datatypes
zeroExtend :: (KnownNat a, KnownNat b) => f a -> f (b + a) #
Add extra zero bits in front of the MSB
signExtend :: (KnownNat a, KnownNat b) => f a -> f (b + a) #
Add extra sign bits in front of the MSB
truncateB :: KnownNat a => f (a + b) -> f a #
Remove bits from the MSB
Instances
| Resize BitVector # | |
Defined in Clash.Sized.Internal.BitVector Methods resize :: (KnownNat a, KnownNat b) => BitVector a -> BitVector b # extend :: (KnownNat a, KnownNat b) => BitVector a -> BitVector (b + a) # zeroExtend :: (KnownNat a, KnownNat b) => BitVector a -> BitVector (b + a) # signExtend :: (KnownNat a, KnownNat b) => BitVector a -> BitVector (b + a) # truncateB :: KnownNat a => BitVector (a + b) -> BitVector a # | |
| Resize Index # | |
Defined in Clash.Sized.Internal.Index | |
| Resize Unsigned # | |
Defined in Clash.Sized.Internal.Unsigned | |
| Resize Signed # | |
Defined in Clash.Sized.Internal.Signed | |